diff --git a/.github/workflows/tests.yml.tmp b/.github/workflows/tests.yml similarity index 68% rename from .github/workflows/tests.yml.tmp rename to .github/workflows/tests.yml index 29bd70ec83..bff77612f1 100644 --- a/.github/workflows/tests.yml.tmp +++ b/.github/workflows/tests.yml @@ -1,10 +1,9 @@ name: "Tests" - on: [pull_request] jobs: tests: name: Unit & E2E - runs-on: self-hosted + runs-on: ubuntu-latest steps: - name: Checkout repository @@ -19,16 +18,29 @@ jobs: - run: git checkout HEAD^2 if: ${{ github.event_name == 'pull_request' }} - - name: Build Appwrite - # Upstream bug causes buildkit pulls to fail so prefetch base images - # https://github.com/moby/moby/issues/41864 + - name: Prepare Docker run: | + export COMPOSE_INTERACTIVE_NO_CLI + export DOCKER_BUILDKIT=1 + export COMPOSE_DOCKER_CLI_BUILD=1 echo "_APP_FUNCTIONS_RUNTIMES=php-8.0" >> .env docker pull composer:2.0 docker pull php:8.0-cli-alpine - docker compose build --progress=plain + docker compose pull + + - name: Prepare Cache + uses: satackey/action-docker-layer-caching@v0.0.11 + # Ignore the failure of a step and avoid terminating the job. + continue-on-error: true + + - name: Build Appwrite + run: docker compose build --progress=plain + + - name: Start Appwrite + run: | docker compose up -d sleep 30 + - name: Doctor run: docker compose exec -T appwrite doctor @@ -37,9 +49,3 @@ jobs: - name: Run Tests run: docker compose exec -T appwrite test --debug - - - name: Teardown - if: always() - run: | - docker compose down -v - docker ps -aq | xargs docker rm --force diff --git a/.travis-ci/build.sh b/.travis-ci/build.sh deleted file mode 100644 index 57aa5ca110..0000000000 --- a/.travis-ci/build.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash bash - -RED='\033[0;31m' -NC='\033[0m' # No Color - -if [ -z "$1" ] -then - echo "Missing tag number" - exit 1 -fi - -if [ -z "$2" ] -then - echo "Missing version number" - exit 1 -fi - -if test $(find "./app/db/DBIP/dbip-country-lite-2021-12.mmdb" -mmin +259200) -then - printf "${RED}GEO country DB has not been updated for more than 6 months. Go to https://db-ip.com/db/download/ip-to-country-lite to download a newer version${NC}\n" -fi - -echo 'Starting build...' - -docker build --build-arg VERSION="$2" --tag appwrite/appwrite:"$1" . - -echo 'Pushing build to registry...' - -docker push appwrite/appwrite:"$1" diff --git a/.travis-ci/deploy.sh b/.travis-ci/deploy.sh deleted file mode 100644 index b4c132022a..0000000000 --- a/.travis-ci/deploy.sh +++ /dev/null @@ -1 +0,0 @@ -echo 'Nothing to deploy right now.' \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index da5897dec5..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,87 +0,0 @@ -dist: focal - -arch: - - amd64 - -os: linux - -vm: - size: large - -language: shell - -notifications: - email: - - team@appwrite.io - -before_install: -# Install latest Docker -- curl -fsSL https://get.docker.com | sh -# Enable Buildkit in Docker config -- echo '{"experimental":"enabled"}' | sudo tee /etc/docker/daemon.json -- mkdir -p $HOME/.docker -- echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json -- sudo service docker start -# Login to increase Docker Hub ratelimit -- > - if [ ! -z "${DOCKERHUB_PULL_USERNAME:-}" ]; then - echo "${DOCKERHUB_PULL_PASSWORD}" | docker login --username "${DOCKERHUB_PULL_USERNAME}" --password-stdin - fi -- docker --version -# Install latest Compose -- sudo rm /usr/local/bin/docker-compose -- curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > docker-compose -- chmod +x docker-compose -- sudo mv docker-compose /usr/local/bin -- docker-compose --version -# Enable Buildkit -- docker buildx create --name travis_builder --use -- export COMPOSE_INTERACTIVE_NO_CLI -- export DOCKER_BUILDKIT=1 -- export COMPOSE_DOCKER_CLI_BUILD=1 -- export BUILDKIT_PROGRESS=plain -# Only pass a single runtime for CI stability -- echo "_APP_FUNCTIONS_RUNTIMES=php-8.0" >> .env -# Ensure Travis scripts are executable -- chmod -R u+x ./.travis-ci - -install: -- docker-compose pull -# Upstream bug causes buildkit pulls to fail so prefetch base images -# https://github.com/moby/moby/issues/41864 -- docker pull composer:2.0 -- docker pull php:8.0-cli-alpine -- docker-compose build -- docker-compose up -d -- sleep 60 - -script: -- docker ps -a -# Tests should fail if any container is in exited status -# - ALL_UP=`docker ps -aq --filter "status=exited"` -# - > -# if [[ "$ALL_UP" != "" ]]; then -# exit 1 -# fi -- docker-compose logs appwrite -- docker-compose logs appwrite-realtime -- docker-compose logs mariadb -- docker-compose logs appwrite-worker-functions -- docker-compose exec appwrite doctor -- docker-compose exec appwrite vars -- docker-compose exec appwrite test --debug - -after_script: -# travis re-uses their build nodes so clean them up -- docker buildx rm travis_builder - -after_failure: -- docker-compose logs appwrite - -deploy: - - provider: script - edge: true - script: ./.travis-ci/deploy.sh - on: - repo: appwrite/appwrite - branch: deploy diff --git a/Dockerfile b/Dockerfile index 4f8192427d..a4ae5c1563 100755 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN composer install --ignore-platform-reqs --optimize-autoloader \ --no-plugins --no-scripts --prefer-dist \ `if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi` -FROM node:16-alpine as node +FROM node:16.13.2-alpine3.15 as node WORKDIR /usr/local/src/ @@ -24,7 +24,7 @@ COPY public /usr/local/src/public RUN npm ci RUN npm run build -FROM php:8.0-cli-alpine as compile +FROM php:8.0.14-cli-alpine3.15 as compile ARG DEBUG=false ENV DEBUG=$DEBUG @@ -123,7 +123,7 @@ RUN \ ./configure && \ make && make install -FROM php:8.0-cli-alpine as final +FROM php:8.0.14-cli-alpine3.15 as final LABEL maintainer="team@appwrite.io" diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 2ff087b725..19c8cf3b27 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -44,7 +44,7 @@ App::post('/v1/account') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_USER) ->label('abuse-limit', 10) - ->param('userId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') + ->param('userId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('email', '', new Email(), 'User email.') ->param('password', '', new Password(), 'User password. Must be at least 8 chars.') ->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true) @@ -615,7 +615,7 @@ App::post('/v1/account/sessions/magic-url') ->label('sdk.response.model', Response::MODEL_TOKEN) ->label('abuse-limit', 10) ->label('abuse-key', 'url:{url},email:{param-email}') - ->param('userId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') + ->param('userId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('email', '', new Email(), 'User email.') ->param('url', '', function ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', true, ['clients']) ->inject('request') diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index c6fb149700..9d5ac716b3 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -148,7 +148,7 @@ App::post('/v1/database/collections') ->label('sdk.response.code', Response::STATUS_CODE_CREATED) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_COLLECTION) - ->param('collectionId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') + ->param('collectionId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('name', '', new Text(128), 'Collection name. Max length: 128 chars.') ->param('permission', null, new WhiteList(['document', 'collection']), 'Permissions type model to use for reading documents in this collection. You can use collection-level permission set once on the collection using the `read` and `write` params, or you can set document-level permission where each document read and write params will decide who has access to read and write to each document individually. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.') ->param('read', null, new Permissions(), 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.') @@ -230,7 +230,7 @@ App::get('/v1/database/collections') $queries = []; if (!empty($search)) { - $queries[] = new Query('name', Query::TYPE_SEARCH, [$search]); + $queries[] = new Query('search', Query::TYPE_SEARCH, [$search]); } $usage->setParam('database.collections.read', 1); @@ -1563,7 +1563,7 @@ App::post('/v1/database/collections/:collectionId/documents') ->label('sdk.response.code', Response::STATUS_CODE_CREATED) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_DOCUMENT) - ->param('documentId', '', new CustomId(), 'Document ID. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') + ->param('documentId', '', new CustomId(), 'Document ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('collectionId', null, new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). Make sure to define attributes before creating documents.') ->param('data', [], new JSON(), 'Document data as JSON object.') ->param('read', null, new Permissions(), 'An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', true) @@ -1832,7 +1832,7 @@ App::get('/v1/database/collections/:collectionId/documents/:documentId') $usage ->setParam('database.documents.read', 1) ->setParam('collectionId', $collectionId) - ; + ; $response->dynamic($document, Response::MODEL_DOCUMENT); }); diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index eab8f322a4..a64c47597a 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -39,7 +39,7 @@ App::post('/v1/functions') ->label('sdk.response.code', Response::STATUS_CODE_CREATED) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_FUNCTION) - ->param('functionId', '', new CustomId(), 'Function ID. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') + ->param('functionId', '', new CustomId(), 'Function ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('name', '', new Text(128), 'Function name. Max length: 128 chars.') ->param('execute', [], new ArrayList(new Text(64)), 'An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.') ->param('runtime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Execution runtime.') @@ -714,7 +714,7 @@ App::post('/v1/functions/:functionId/executions') throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404); } - $validator = new Authorization($function, 'execute'); + $validator = new Authorization('execute'); if (!$validator->isValid($function->getAttribute('execute'))) { // Check if user has write access to execute function throw new Exception($validator->getDescription(), 401); diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 1ef711e6fe..b65eb5db7b 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -43,7 +43,7 @@ App::post('/v1/projects') ->label('sdk.response.code', Response::STATUS_CODE_CREATED) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_PROJECT) - ->param('projectId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') + ->param('projectId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') ->param('teamId', '', new UID(), 'Team unique ID.') ->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true) diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 4a5fb7cfe1..1dba0c722a 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -41,7 +41,7 @@ App::post('/v1/storage/files') ->label('sdk.response.code', Response::STATUS_CODE_CREATED) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_FILE) - ->param('fileId', '', new CustomId(), 'File ID. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') + ->param('fileId', '', new CustomId(), 'File ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('file', [], new File(), 'Binary file.', false) ->param('read', null, new ArrayList(new Text(64)), 'An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', true) ->param('write', null, new ArrayList(new Text(64)), 'An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', true) diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index ab5534edc6..d9809bf305 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -34,7 +34,7 @@ App::post('/v1/teams') ->label('sdk.response.code', Response::STATUS_CODE_CREATED) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_TEAM) - ->param('teamId', '', new CustomId(), 'Team ID. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') + ->param('teamId', '', new CustomId(), 'Team ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('name', null, new Text(128), 'Team name. Max length: 128 chars.') ->param('roles', ['owner'], new ArrayList(new Key()), 'Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Max length for each role is 32 chars.', true) ->inject('response') diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index ff64259409..ac030f7e7d 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -34,7 +34,7 @@ App::post('/v1/users') ->label('sdk.response.code', Response::STATUS_CODE_CREATED) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_USER) - ->param('userId', '', new CustomId(), 'User ID. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') + ->param('userId', '', new CustomId(), 'User ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('email', '', new Email(), 'User email.') ->param('password', '', new Password(), 'User password. Must be at least 8 chars.') ->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true) diff --git a/app/controllers/general.php b/app/controllers/general.php index 8b0fbf8e09..7f82c36a30 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -167,6 +167,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $dbForCons break; case version_compare ($responseFormat , '0.8.0', '<=') : Response::setFilter(new V08()); + break; case version_compare ($responseFormat , '0.11.0', '<=') : Response::setFilter(new V11()); break; diff --git a/app/views/console/database/collection.phtml b/app/views/console/database/collection.phtml index 2091209e52..93db293ad1 100644 --- a/app/views/console/database/collection.phtml +++ b/app/views/console/database/collection.phtml @@ -620,6 +620,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -675,6 +676,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -706,10 +708,10 @@ $logs = $this->getParam('logs', null);