mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge remote-tracking branch 'origin/1.9.x' into feat/sites-build-spec-default
This commit is contained in:
commit
8e3a8ba07c
100 files changed
+1267
-725
No files matched your search
+111
-217
@@ -1,17 +1,19 @@
|
||||
name: CI
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
group: ci-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
env:
|
||||
COMPOSE_FILE: docker-compose.yml
|
||||
IMAGE: appwrite-dev
|
||||
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}/appwrite-dev
|
||||
K6_VERSION: '0.53.0'
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- 1.9.x
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
response_format:
|
||||
@@ -89,111 +91,13 @@ jobs:
|
||||
sarif_file: 'trivy-fs-results.sarif'
|
||||
category: 'trivy-source'
|
||||
|
||||
composer:
|
||||
name: Checks / Composer
|
||||
checks:
|
||||
name: Checks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
|
||||
with:
|
||||
php-version: '8.3'
|
||||
tools: composer:v2
|
||||
coverage: none
|
||||
|
||||
- name: Validate
|
||||
run: composer validate
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-progress --ignore-platform-reqs
|
||||
|
||||
- name: Audit
|
||||
env:
|
||||
COMPOSER_NO_AUDIT: 0
|
||||
run: composer audit
|
||||
|
||||
format:
|
||||
name: Checks / Format
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- run: git checkout HEAD^2
|
||||
if: github.event_name == 'pull_request'
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
|
||||
with:
|
||||
php-version: '8.3'
|
||||
tools: composer:v2
|
||||
coverage: none
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-progress --ignore-platform-reqs
|
||||
|
||||
- name: Run Linter
|
||||
run: composer lint
|
||||
|
||||
refactor:
|
||||
name: Checks / Refactor
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
|
||||
with:
|
||||
php-version: '8.3'
|
||||
tools: composer:v2
|
||||
coverage: none
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-progress --ignore-platform-reqs
|
||||
|
||||
- name: Run Rector
|
||||
run: composer refactor:check
|
||||
|
||||
analyze:
|
||||
name: Checks / Analyze
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
|
||||
with:
|
||||
php-version: '8.3'
|
||||
tools: composer:v2
|
||||
coverage: none
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-progress --ignore-platform-reqs
|
||||
|
||||
- name: Cache PHPStan result cache
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
with:
|
||||
path: .phpstan-cache
|
||||
key: phpstan-${{ github.sha }}
|
||||
restore-keys: |
|
||||
phpstan-
|
||||
|
||||
- name: Run PHPStan
|
||||
run: composer analyze -- --no-progress
|
||||
|
||||
specs:
|
||||
name: Checks / Specs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
|
||||
with:
|
||||
@@ -202,10 +106,42 @@ jobs:
|
||||
tools: composer:v2
|
||||
coverage: none
|
||||
|
||||
- name: Validate composer.json
|
||||
run: composer validate
|
||||
|
||||
- name: Install dependencies
|
||||
id: install
|
||||
run: composer install --prefer-dist --no-progress --ignore-platform-reqs
|
||||
|
||||
- name: Cache PHPStan result cache
|
||||
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
with:
|
||||
path: .phpstan-cache
|
||||
key: phpstan-${{ github.sha }}
|
||||
restore-keys: |
|
||||
phpstan-
|
||||
|
||||
- name: Audit dependencies
|
||||
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
|
||||
env:
|
||||
COMPOSER_NO_AUDIT: 0
|
||||
run: composer audit
|
||||
|
||||
- name: Run Linter
|
||||
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
|
||||
run: composer lint
|
||||
|
||||
- name: Run Rector
|
||||
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
|
||||
run: composer refactor:check
|
||||
|
||||
- name: Run PHPStan
|
||||
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
|
||||
run: composer analyze -- --no-progress
|
||||
|
||||
- name: Generate specs
|
||||
if: ${{ !cancelled() && steps.install.outcome == 'success' }}
|
||||
run: _APP_STORAGE_LIMIT=5368709120 php app/cli.php specs --version=latest --git=no
|
||||
|
||||
locale:
|
||||
@@ -236,36 +172,36 @@ jobs:
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
script: |
|
||||
const runner4 = `runs-on=${context.runId}/runner=4cpu-linux-x64/volume=120g/spot=false/extras=otel`;
|
||||
const runner8 = `runs-on=${context.runId}/runner=8cpu-linux-x64/volume=120g/spot=false/extras=otel`;
|
||||
const runner4 = `runs-on=${context.runId}/runner=4cpu-linux-x64/volume=120g/spot=false/extras=otel+ecr-cache`;
|
||||
const runner8 = `runs-on=${context.runId}/runner=8cpu-linux-x64/volume=120g/spot=false/extras=otel+ecr-cache`;
|
||||
|
||||
const services = [
|
||||
{ name: 'Account', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Avatars', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Console', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Databases', runner: runner8, functional: false, processes: 3, timeout: 30 },
|
||||
{ name: 'TablesDB', runner: runner8, functional: false, processes: 3, timeout: 30 },
|
||||
{ name: 'Functions', runner: runner4, functional: false, processes: null, timeout: 20 },
|
||||
{ name: 'FunctionsSchedule', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'GraphQL', runner: runner4, functional: false, processes: null, timeout: 20 },
|
||||
{ name: 'Health', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Advisor', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Locale', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Projects', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Realtime', runner: runner4, functional: false, processes: null, timeout: 20 },
|
||||
{ name: 'Sites', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Proxy', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Storage', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Tokens', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Teams', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Users', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'ProjectWebhooks', runner: runner4, functional: false, processes: null, timeout: 20 },
|
||||
{ name: 'Webhooks', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'VCS', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Messaging', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Migrations', runner: runner4, functional: true, processes: 1, timeout: 20 },
|
||||
{ name: 'Project', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Presences', runner: runner4, functional: true, processes: null, timeout: 20 },
|
||||
{ name: 'Account', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Avatars', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Console', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Databases', runner: runner8, functional: false, processes: 3, timeout: 15 },
|
||||
{ name: 'TablesDB', runner: runner8, functional: false, processes: 3, timeout: 15 },
|
||||
{ name: 'Functions', runner: runner4, functional: false, processes: null, timeout: 15 },
|
||||
{ name: 'FunctionsSchedule', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'GraphQL', runner: runner4, functional: false, processes: null, timeout: 15 },
|
||||
{ name: 'Health', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Advisor', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Locale', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Projects', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Realtime', runner: runner4, functional: false, processes: null, timeout: 15 },
|
||||
{ name: 'Sites', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Proxy', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Storage', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Tokens', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Teams', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Users', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'ProjectWebhooks', runner: runner4, functional: false, processes: null, timeout: 15 },
|
||||
{ name: 'Webhooks', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'VCS', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Messaging', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Migrations', runner: runner4, functional: true, processes: 1, timeout: 15 },
|
||||
{ name: 'Project', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
{ name: 'Presences', runner: runner4, functional: true, processes: null, timeout: 15 },
|
||||
];
|
||||
core.setOutput('services', JSON.stringify(services));
|
||||
|
||||
@@ -300,7 +236,7 @@ jobs:
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: runs-on=${{ github.run_id }}/runner=4cpu-linux-x64/volume=120g/spot=false/extras=otel+s3-cache+ecr-cache
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
@@ -313,13 +249,6 @@ jobs:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
||||
|
||||
@@ -328,9 +257,9 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
tags: ${{ env.RUNS_ON_ECR_CACHE }}:${{ env.IMAGE }}-${{ github.sha }}
|
||||
cache-from: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }}
|
||||
cache-to: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max
|
||||
target: development
|
||||
build-args: |
|
||||
DEBUG=false
|
||||
@@ -339,7 +268,7 @@ jobs:
|
||||
|
||||
unit:
|
||||
name: Tests / Unit
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: runs-on=${{ github.run_id }}/runner=4cpu-linux-x64/volume=120g/spot=false/extras=otel+ecr-cache
|
||||
needs: build
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -355,17 +284,10 @@ jobs:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Pull Docker Image
|
||||
run: |
|
||||
docker pull ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}
|
||||
docker tag ${{ env.REGISTRY_IMAGE }}:${{ github.sha }} ${{ env.IMAGE }}
|
||||
docker pull ${{ env.RUNS_ON_ECR_CACHE }}:${{ env.IMAGE }}-${{ github.sha }}
|
||||
docker tag ${{ env.RUNS_ON_ECR_CACHE }}:${{ env.IMAGE }}-${{ github.sha }} ${{ env.IMAGE }}
|
||||
|
||||
- name: Load and Start Appwrite
|
||||
timeout-minutes: 5
|
||||
@@ -377,9 +299,10 @@ jobs:
|
||||
run: docker compose exec -T appwrite vars
|
||||
|
||||
- name: Run Unit Tests
|
||||
uses: itznotabug/php-retry@d6bef45a8bff490babfb613e33b00d133e4062f0 # v3
|
||||
timeout-minutes: 15
|
||||
uses: itznotabug/php-retry@60547503cb2126eddaa082d0999e99cfca2b3856 # v4
|
||||
with:
|
||||
max_attempts: 2
|
||||
max_attempts: ${{ github.event_name == 'pull_request' && 2 || 1 }}
|
||||
retry_wait_seconds: 60
|
||||
timeout_minutes: 15
|
||||
job_id: ${{ job.check_run_id }}
|
||||
@@ -392,7 +315,7 @@ jobs:
|
||||
|
||||
e2e_general:
|
||||
name: Tests / E2E / General
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: runs-on=${{ github.run_id }}/runner=4cpu-linux-x64/volume=120g/spot=false/extras=otel+ecr-cache
|
||||
needs: build
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -408,17 +331,10 @@ jobs:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Pull Docker Image
|
||||
run: |
|
||||
docker pull ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}
|
||||
docker tag ${{ env.REGISTRY_IMAGE }}:${{ github.sha }} ${{ env.IMAGE }}
|
||||
docker pull ${{ env.RUNS_ON_ECR_CACHE }}:${{ env.IMAGE }}-${{ github.sha }}
|
||||
docker tag ${{ env.RUNS_ON_ECR_CACHE }}:${{ env.IMAGE }}-${{ github.sha }} ${{ env.IMAGE }}
|
||||
|
||||
- name: Load and Start Appwrite
|
||||
timeout-minutes: 5
|
||||
@@ -435,9 +351,10 @@ jobs:
|
||||
done
|
||||
|
||||
- name: Run General Tests
|
||||
uses: itznotabug/php-retry@d6bef45a8bff490babfb613e33b00d133e4062f0 # v3
|
||||
timeout-minutes: 15
|
||||
uses: itznotabug/php-retry@60547503cb2126eddaa082d0999e99cfca2b3856 # v4
|
||||
with:
|
||||
max_attempts: 2
|
||||
max_attempts: ${{ github.event_name == 'pull_request' && 2 || 1 }}
|
||||
retry_wait_seconds: 60
|
||||
timeout_minutes: 15
|
||||
job_id: ${{ job.check_run_id }}
|
||||
@@ -499,17 +416,10 @@ jobs:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Pull Docker Image
|
||||
run: |
|
||||
docker pull ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}
|
||||
docker tag ${{ env.REGISTRY_IMAGE }}:${{ github.sha }} ${{ env.IMAGE }}
|
||||
docker pull ${{ env.RUNS_ON_ECR_CACHE }}:${{ env.IMAGE }}-${{ github.sha }}
|
||||
docker tag ${{ env.RUNS_ON_ECR_CACHE }}:${{ env.IMAGE }}-${{ github.sha }} ${{ env.IMAGE }}
|
||||
|
||||
- name: Load and Start Appwrite
|
||||
timeout-minutes: 5
|
||||
@@ -531,9 +441,10 @@ jobs:
|
||||
done
|
||||
|
||||
- name: Run tests
|
||||
uses: itznotabug/php-retry@d6bef45a8bff490babfb613e33b00d133e4062f0 # v3
|
||||
timeout-minutes: 15
|
||||
uses: itznotabug/php-retry@60547503cb2126eddaa082d0999e99cfca2b3856 # v4
|
||||
with:
|
||||
max_attempts: 2
|
||||
max_attempts: ${{ github.event_name == 'pull_request' && 2 || 1 }}
|
||||
retry_wait_seconds: 60
|
||||
timeout_minutes: ${{ matrix.service.timeout }}
|
||||
job_id: ${{ job.check_run_id }}
|
||||
@@ -566,7 +477,7 @@ jobs:
|
||||
|
||||
e2e_abuse:
|
||||
name: Tests / E2E / Abuse (${{ matrix.mode }})
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: runs-on=${{ github.run_id }}/runner=4cpu-linux-x64/volume=120g/spot=false/extras=otel+ecr-cache
|
||||
needs: [build, matrix]
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -588,17 +499,10 @@ jobs:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Pull Docker Image
|
||||
run: |
|
||||
docker pull ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}
|
||||
docker tag ${{ env.REGISTRY_IMAGE }}:${{ github.sha }} ${{ env.IMAGE }}
|
||||
docker pull ${{ env.RUNS_ON_ECR_CACHE }}:${{ env.IMAGE }}-${{ github.sha }}
|
||||
docker tag ${{ env.RUNS_ON_ECR_CACHE }}:${{ env.IMAGE }}-${{ github.sha }} ${{ env.IMAGE }}
|
||||
|
||||
- name: Load and Start Appwrite
|
||||
timeout-minutes: 5
|
||||
@@ -612,9 +516,10 @@ jobs:
|
||||
docker compose up -d --quiet-pull --wait
|
||||
|
||||
- name: Run tests
|
||||
uses: itznotabug/php-retry@d6bef45a8bff490babfb613e33b00d133e4062f0 # v3
|
||||
timeout-minutes: 15
|
||||
uses: itznotabug/php-retry@60547503cb2126eddaa082d0999e99cfca2b3856 # v4
|
||||
with:
|
||||
max_attempts: 2
|
||||
max_attempts: ${{ github.event_name == 'pull_request' && 2 || 1 }}
|
||||
retry_wait_seconds: 60
|
||||
timeout_minutes: 15
|
||||
job_id: ${{ job.check_run_id }}
|
||||
@@ -633,7 +538,7 @@ jobs:
|
||||
|
||||
e2e_screenshots:
|
||||
name: Tests / E2E / Screenshots (${{ matrix.mode }})
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: runs-on=${{ github.run_id }}/runner=4cpu-linux-x64/volume=120g/spot=false/extras=otel+ecr-cache
|
||||
needs: [build, matrix]
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -653,17 +558,10 @@ jobs:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Pull Docker Image
|
||||
run: |
|
||||
docker pull ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}
|
||||
docker tag ${{ env.REGISTRY_IMAGE }}:${{ github.sha }} ${{ env.IMAGE }}
|
||||
docker pull ${{ env.RUNS_ON_ECR_CACHE }}:${{ env.IMAGE }}-${{ github.sha }}
|
||||
docker tag ${{ env.RUNS_ON_ECR_CACHE }}:${{ env.IMAGE }}-${{ github.sha }} ${{ env.IMAGE }}
|
||||
|
||||
- name: Load and Start Appwrite
|
||||
timeout-minutes: 5
|
||||
@@ -684,9 +582,10 @@ jobs:
|
||||
done
|
||||
|
||||
- name: Run tests
|
||||
uses: itznotabug/php-retry@d6bef45a8bff490babfb613e33b00d133e4062f0 # v3
|
||||
timeout-minutes: 15
|
||||
uses: itznotabug/php-retry@60547503cb2126eddaa082d0999e99cfca2b3856 # v4
|
||||
with:
|
||||
max_attempts: 2
|
||||
max_attempts: ${{ github.event_name == 'pull_request' && 2 || 1 }}
|
||||
retry_wait_seconds: 60
|
||||
timeout_minutes: 15
|
||||
job_id: ${{ job.check_run_id }}
|
||||
@@ -705,8 +604,8 @@ jobs:
|
||||
|
||||
benchmark:
|
||||
name: Benchmark
|
||||
if: github.event_name == 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'pull_request' || github.event_name == 'push'
|
||||
runs-on: runs-on=${{ github.run_id }}/runner=4cpu-linux-x64/volume=120g/spot=false/extras=otel+ecr-cache
|
||||
needs: build
|
||||
permissions:
|
||||
actions: read
|
||||
@@ -726,18 +625,11 @@ jobs:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Pull Appwrite image
|
||||
run: |
|
||||
docker pull ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}
|
||||
docker tag ${{ env.REGISTRY_IMAGE }}:${{ github.sha }} ${{ env.IMAGE }}
|
||||
docker tag ${{ env.REGISTRY_IMAGE }}:${{ github.sha }} ${{ env.IMAGE }}:after
|
||||
docker pull ${{ env.RUNS_ON_ECR_CACHE }}:${{ env.IMAGE }}-${{ github.sha }}
|
||||
docker tag ${{ env.RUNS_ON_ECR_CACHE }}:${{ env.IMAGE }}-${{ github.sha }} ${{ env.IMAGE }}
|
||||
docker tag ${{ env.RUNS_ON_ECR_CACHE }}:${{ env.IMAGE }}-${{ github.sha }} ${{ env.IMAGE }}:after
|
||||
|
||||
- name: Setup k6
|
||||
uses: grafana/setup-k6-action@db07bd9765aac508ef18982e52ab937fe633a065 # v1.2.1
|
||||
@@ -747,9 +639,11 @@ jobs:
|
||||
- name: Prepare benchmark before
|
||||
id: benchmark_before_prepare
|
||||
continue-on-error: true
|
||||
env:
|
||||
BENCHMARK_BEFORE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
|
||||
run: |
|
||||
git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }}
|
||||
git worktree add --detach /tmp/appwrite-benchmark-before ${{ github.event.pull_request.base.sha }}
|
||||
git fetch --depth=1 origin "${BENCHMARK_BEFORE_SHA}"
|
||||
git worktree add --detach /tmp/appwrite-benchmark-before "${BENCHMARK_BEFORE_SHA}"
|
||||
docker build \
|
||||
--cache-from ${{ env.IMAGE }}:after \
|
||||
--target development \
|
||||
@@ -871,8 +765,8 @@ jobs:
|
||||
if: always()
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
env:
|
||||
BENCHMARK_BASE_REF: ${{ github.event.pull_request.base.ref }}
|
||||
BENCHMARK_HEAD_REF: ${{ github.event.pull_request.head.ref }}
|
||||
BENCHMARK_BASE_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.event.before }}
|
||||
BENCHMARK_HEAD_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.sha }}
|
||||
with:
|
||||
script: |
|
||||
const comment = require('./.github/workflows/benchmark-comment.js');
|
||||
|
||||
@@ -15,6 +15,8 @@ Self-hosted Backend-as-a-Service platform. Hybrid monolithic-microservice archit
|
||||
| `composer lint <file>` | Check formatting of a file |
|
||||
| `composer analyze` | Static analysis (PHPStan level 3) |
|
||||
| `composer check` | Same as `analyze` |
|
||||
| `composer refactor:check` | Rector dry-run over `tests/` (CI "Refactor" check) |
|
||||
| `composer refactor` | Apply Rector fixes |
|
||||
|
||||
## Stack
|
||||
|
||||
|
||||
@@ -2405,6 +2405,7 @@ Http::post('/v1/account/tokens/magic-url')
|
||||
project: $project,
|
||||
recipient: $email,
|
||||
subject: $subject,
|
||||
template: MAIL_TEMPLATE_MAGIC_URL,
|
||||
body: $body,
|
||||
preview: $preview,
|
||||
smtp: $smtpConfig,
|
||||
@@ -2751,6 +2752,7 @@ Http::post('/v1/account/tokens/email')
|
||||
project: $project,
|
||||
recipient: $email,
|
||||
subject: $subject,
|
||||
template: MAIL_TEMPLATE_OTP,
|
||||
bodyTemplate: $bodyTemplate,
|
||||
body: $body,
|
||||
preview: $preview,
|
||||
@@ -3868,6 +3870,7 @@ Http::post('/v1/account/recovery')
|
||||
recipient: $profile->getAttribute('email', ''),
|
||||
name: $profile->getAttribute('name', ''),
|
||||
subject: $subject,
|
||||
template: MAIL_TEMPLATE_RECOVERY,
|
||||
body: $body,
|
||||
preview: $preview,
|
||||
smtp: $smtpConfig,
|
||||
@@ -4222,6 +4225,7 @@ Http::post('/v1/account/verifications/email')
|
||||
recipient: $user->getAttribute('email'),
|
||||
name: $user->getAttribute('name') ?? '',
|
||||
subject: $subject,
|
||||
template: MAIL_TEMPLATE_VERIFICATION,
|
||||
bodyTemplate: $bodyTemplate,
|
||||
body: $body,
|
||||
preview: $preview,
|
||||
|
||||
@@ -38,27 +38,31 @@ Http::patch('/v1/projects/:projectId/oauth2')
|
||||
->inject('dbForPlatform')
|
||||
->action(function (string $projectId, string $provider, ?string $appId, ?string $secret, ?bool $enabled, Response $response, Database $dbForPlatform) {
|
||||
|
||||
$project = $dbForPlatform->getDocument('projects', $projectId);
|
||||
$project = $dbForPlatform->withTransaction(function () use ($dbForPlatform, $projectId, $provider, $appId, $secret, $enabled) {
|
||||
$project = $dbForPlatform->getDocument('projects', $projectId, forUpdate: true);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$providers = $project->getAttribute('oAuthProviders', []);
|
||||
$providers = $project->getAttribute('oAuthProviders', []);
|
||||
|
||||
if ($appId !== null) {
|
||||
$providers[$provider . 'Appid'] = $appId;
|
||||
}
|
||||
if ($appId !== null) {
|
||||
$providers[$provider . 'Appid'] = $appId;
|
||||
}
|
||||
|
||||
if ($secret !== null) {
|
||||
$providers[$provider . 'Secret'] = $secret;
|
||||
}
|
||||
if ($secret !== null) {
|
||||
$providers[$provider . 'Secret'] = $secret;
|
||||
}
|
||||
|
||||
if ($enabled !== null) {
|
||||
$providers[$provider . 'Enabled'] = $enabled;
|
||||
}
|
||||
if ($enabled !== null) {
|
||||
$providers[$provider . 'Enabled'] = $enabled;
|
||||
}
|
||||
|
||||
$project = $dbForPlatform->updateDocument('projects', $project->getId(), $project->setAttribute('oAuthProviders', $providers));
|
||||
return $dbForPlatform->updateDocument('projects', $project->getId(), new Document([
|
||||
'oAuthProviders' => $providers,
|
||||
]));
|
||||
});
|
||||
|
||||
$response->dynamic($project, Response::MODEL_PROJECT);
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@ use Appwrite\Event\Publisher\Delete as DeletePublisher;
|
||||
use Appwrite\Extend\Exception as AppwriteException;
|
||||
use Appwrite\Network\Cors;
|
||||
use Appwrite\Platform\Appwrite;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Transformation\Adapter\Preview;
|
||||
@@ -1662,11 +1663,10 @@ Http::get('/v1/ping')
|
||||
namespace: 'ping',
|
||||
group: null,
|
||||
name: 'get',
|
||||
hide: true,
|
||||
description: <<<EOT
|
||||
Send a ping to project as part of onboarding.
|
||||
EOT,
|
||||
auth: [],
|
||||
auth: [AuthType::ADMIN, AuthType::KEY, AuthType::JWT, AuthType::SESSION],
|
||||
responses: [
|
||||
new SDKResponse(
|
||||
code: Response::STATUS_CODE_OK,
|
||||
|
||||
+6
-6
@@ -270,8 +270,8 @@ function createDatabase(Container $resources, string $resourceKey, string $dbNam
|
||||
'$id' => ID::custom($index['$id']),
|
||||
'type' => $index['type'],
|
||||
'attributes' => $index['attributes'],
|
||||
'lengths' => $index['lengths'],
|
||||
'orders' => $index['orders'],
|
||||
'lengths' => $index['lengths'] ?? [],
|
||||
'orders' => $index['orders'] ?? [],
|
||||
]), $collection['indexes']);
|
||||
|
||||
$database->createCollection($key, $attributes, $indexes);
|
||||
@@ -353,8 +353,8 @@ $http->on(Constant::EVENT_START, function ($http) use ($payloadSize, $totalWorke
|
||||
'$id' => ID::custom($index['$id']),
|
||||
'type' => $index['type'],
|
||||
'attributes' => $index['attributes'],
|
||||
'lengths' => $index['lengths'],
|
||||
'orders' => $index['orders'],
|
||||
'lengths' => $index['lengths'] ?? [],
|
||||
'orders' => $index['orders'] ?? [],
|
||||
]), $files['indexes']);
|
||||
|
||||
$dbForPlatform->createCollection('bucket_' . $bucket->getSequence(), $attributes, $indexes);
|
||||
@@ -399,8 +399,8 @@ $http->on(Constant::EVENT_START, function ($http) use ($payloadSize, $totalWorke
|
||||
'$id' => ID::custom($index['$id']),
|
||||
'type' => $index['type'],
|
||||
'attributes' => $index['attributes'],
|
||||
'lengths' => $index['lengths'],
|
||||
'orders' => $index['orders'],
|
||||
'lengths' => $index['lengths'] ?? [],
|
||||
'orders' => $index['orders'] ?? [],
|
||||
]), $files['indexes']);
|
||||
|
||||
$authorization->skip(fn () => $dbForPlatform->createCollection('bucket_' . $bucket->getSequence(), $attributes, $indexes));
|
||||
|
||||
@@ -272,6 +272,17 @@ const FUNCTION_ALLOWLIST_HEADERS_RESPONSE = ['content-type', 'content-length'];
|
||||
const MESSAGE_TYPE_EMAIL = 'email';
|
||||
const MESSAGE_TYPE_SMS = 'sms';
|
||||
const MESSAGE_TYPE_PUSH = 'push';
|
||||
const MAIL_TEMPLATE_CERTIFICATE_FAILED = 'certificate-failed';
|
||||
const MAIL_TEMPLATE_DATA_EXPORT = 'data-export';
|
||||
const MAIL_TEMPLATE_INVITATION = 'invitation';
|
||||
const MAIL_TEMPLATE_MAGIC_URL = 'magic-url';
|
||||
const MAIL_TEMPLATE_MFA_CHALLENGE = 'mfa-challenge';
|
||||
const MAIL_TEMPLATE_OTP = 'otp';
|
||||
const MAIL_TEMPLATE_RECOVERY = 'recovery';
|
||||
const MAIL_TEMPLATE_SESSION_ALERT = 'session-alert';
|
||||
const MAIL_TEMPLATE_SMTP_TEST = 'smtp-test';
|
||||
const MAIL_TEMPLATE_VERIFICATION = 'verification';
|
||||
const MAIL_TEMPLATE_WEBHOOK_FAILED = 'webhook-failed';
|
||||
// API key types
|
||||
const API_KEY_STANDARD = 'standard';
|
||||
const API_KEY_EPHEMERAL = 'ephemeral';
|
||||
|
||||
+16
-19
@@ -6,7 +6,6 @@ use Appwrite\Hooks\Hooks;
|
||||
use Appwrite\PubSub\Adapter\Redis as PubSub;
|
||||
use Appwrite\URL\URL as AppwriteURL;
|
||||
use MaxMind\Db\Reader;
|
||||
use Swoole\Database\PDOProxy;
|
||||
use Utopia\Cache\Adapter\Redis as RedisCache;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Console;
|
||||
@@ -291,15 +290,14 @@ $register->set('pools', function () {
|
||||
$resource = match ($dsnScheme) {
|
||||
'mysql',
|
||||
'mariadb' => function () use ($dsnHost, $dsnPort, $dsnUser, $dsnPass, $dsnDatabase) {
|
||||
return new PDOProxy(function () use ($dsnHost, $dsnPort, $dsnUser, $dsnPass, $dsnDatabase) {
|
||||
return new PDO("mysql:host={$dsnHost};port={$dsnPort};dbname={$dsnDatabase};charset=utf8mb4", $dsnUser, $dsnPass, [
|
||||
\PDO::ATTR_TIMEOUT => 3, // Seconds
|
||||
\PDO::ATTR_PERSISTENT => false,
|
||||
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
|
||||
\PDO::ATTR_EMULATE_PREPARES => true,
|
||||
\PDO::ATTR_STRINGIFY_FETCHES => true
|
||||
]);
|
||||
});
|
||||
return new PDO("mysql:host={$dsnHost};port={$dsnPort};dbname={$dsnDatabase};charset=utf8mb4", $dsnUser, $dsnPass, [
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
||||
\PDO::ATTR_TIMEOUT => 3, // Seconds
|
||||
\PDO::ATTR_PERSISTENT => false,
|
||||
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
|
||||
\PDO::ATTR_EMULATE_PREPARES => true,
|
||||
\PDO::ATTR_STRINGIFY_FETCHES => true
|
||||
]);
|
||||
},
|
||||
'mongodb' => function () use ($dsnHost, $dsnPort, $dsnUser, $dsnPass, $dsnDatabase) {
|
||||
try {
|
||||
@@ -312,15 +310,14 @@ $register->set('pools', function () {
|
||||
}
|
||||
},
|
||||
'postgresql' => function () use ($dsnHost, $dsnPort, $dsnUser, $dsnPass, $dsnDatabase) {
|
||||
return new PDOProxy(function () use ($dsnHost, $dsnPort, $dsnUser, $dsnPass, $dsnDatabase) {
|
||||
return new PDO("pgsql:host={$dsnHost};port={$dsnPort};dbname={$dsnDatabase};connect_timeout=3", $dsnUser, $dsnPass, array(
|
||||
\PDO::ATTR_TIMEOUT => 3, // Seconds
|
||||
\PDO::ATTR_PERSISTENT => false,
|
||||
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
|
||||
\PDO::ATTR_EMULATE_PREPARES => true,
|
||||
\PDO::ATTR_STRINGIFY_FETCHES => true
|
||||
));
|
||||
});
|
||||
return new PDO("pgsql:host={$dsnHost};port={$dsnPort};dbname={$dsnDatabase};connect_timeout=3", $dsnUser, $dsnPass, array(
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
||||
\PDO::ATTR_TIMEOUT => 3, // Seconds
|
||||
\PDO::ATTR_PERSISTENT => false,
|
||||
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
|
||||
\PDO::ATTR_EMULATE_PREPARES => true,
|
||||
\PDO::ATTR_STRINGIFY_FETCHES => true
|
||||
));
|
||||
},
|
||||
default => function () use ($dsnHost, $dsnPort, $dsnPass) {
|
||||
$redis = new \Redis();
|
||||
|
||||
@@ -1108,7 +1108,11 @@ return function (Container $context): void {
|
||||
return new Document([]);
|
||||
}
|
||||
|
||||
$token = $authorization->skip(fn () => $dbForProject->getDocument('resourceTokens', $tokenId));
|
||||
try {
|
||||
$token = $authorization->skip(fn () => $dbForProject->getDocument('resourceTokens', $tokenId));
|
||||
} catch (\Utopia\Database\Exception\NotFound) {
|
||||
return new Document([]);
|
||||
}
|
||||
|
||||
if ($token->isEmpty()) {
|
||||
return new Document([]);
|
||||
|
||||
@@ -12,6 +12,7 @@ $version = $this->getParam('version', '');
|
||||
$organization = $this->getParam('organization', '');
|
||||
$image = $this->getParam('image', '');
|
||||
$enableAssistant = $this->getParam('enableAssistant', false);
|
||||
$executorImages = $this->getParam('executorImages', '');
|
||||
$dbService = $this->getParam('database', 'mongodb');
|
||||
$allowedDbServices = ['mariadb', 'mongodb'];
|
||||
if (!\in_array($dbService, $allowedDbServices, true)) {
|
||||
@@ -988,10 +989,9 @@ $hostPath = rtrim($this->getParam('hostPath', ''), '/');
|
||||
<<: *x-logging
|
||||
restart: unless-stopped
|
||||
stop_signal: SIGINT
|
||||
image: openruntimes/executor:0.24.1
|
||||
image: openruntimes/executor:0.25.1
|
||||
networks:
|
||||
- appwrite
|
||||
- runtimes
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- appwrite-builds:/storage/builds:rw
|
||||
@@ -1003,6 +1003,7 @@ $hostPath = rtrim($this->getParam('hostPath', ''), '/');
|
||||
environment:
|
||||
- OPR_EXECUTOR_CONNECTION_STORAGE=local://localhost
|
||||
- OPR_EXECUTOR_CONNECTION_BUILD_CACHE_STORAGE=
|
||||
- OPR_EXECUTOR_IMAGES=<?php echo $executorImages; ?>
|
||||
- OPR_EXECUTOR_INACTIVE_TRESHOLD=$_APP_COMPUTE_INACTIVE_THRESHOLD
|
||||
- OPR_EXECUTOR_MAINTENANCE_INTERVAL=$_APP_COMPUTE_MAINTENANCE_INTERVAL
|
||||
- OPR_EXECUTOR_NETWORK=$_APP_COMPUTE_RUNTIMES_NETWORK
|
||||
|
||||
+6
-6
@@ -53,17 +53,17 @@
|
||||
"ext-sockets": "*",
|
||||
"appwrite/php-runtimes": "0.20.*",
|
||||
"appwrite/php-clamav": "2.0.*",
|
||||
"utopia-php/abuse": "1.3.*",
|
||||
"utopia-php/abuse": "1.4.*",
|
||||
"utopia-php/agents": "2.*",
|
||||
"utopia-php/analytics": "0.15.*",
|
||||
"utopia-php/audit": "^2.4",
|
||||
"utopia-php/auth": "0.5.*",
|
||||
"utopia-php/audit": "2.6.*",
|
||||
"utopia-php/auth": "^0.6",
|
||||
"utopia-php/cache": "^3.0",
|
||||
"utopia-php/cli": "^0.24",
|
||||
"utopia-php/compression": "0.1.*",
|
||||
"utopia-php/config": "1.*",
|
||||
"utopia-php/console": "0.1.*",
|
||||
"utopia-php/database": "5.*",
|
||||
"utopia-php/database": "6.0.*",
|
||||
"utopia-php/detector": "0.2.*",
|
||||
"utopia-php/domains": "^2.2",
|
||||
"utopia-php/emails": "0.7.*",
|
||||
@@ -76,8 +76,8 @@
|
||||
"utopia-php/locale": "0.8.*",
|
||||
"utopia-php/lock": "0.2.*",
|
||||
"utopia-php/logger": "0.8.*",
|
||||
"utopia-php/messaging": "1.0.*",
|
||||
"utopia-php/migration": "1.*",
|
||||
"utopia-php/messaging": "^1.1",
|
||||
"utopia-php/migration": "1.14.*",
|
||||
"utopia-php/platform": "^1.0@RC",
|
||||
"utopia-php/pools": "1.*",
|
||||
"utopia-php/span": "3.0.*",
|
||||
|
||||
Generated
+57
-62
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "fe6368e3d42f385c63d7e5e2e911febd",
|
||||
"content-hash": "bf0c07c029c54b225566c1a731fccae0",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
@@ -69,16 +69,16 @@
|
||||
},
|
||||
{
|
||||
"name": "appwrite/appwrite",
|
||||
"version": "24.2.0",
|
||||
"version": "26.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/appwrite/sdk-for-php.git",
|
||||
"reference": "d3217b6524b9d174ab91fb7ffc555c68bfa1da97"
|
||||
"reference": "533865f24f306cf6ac6f1737965553a5c54672e0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/d3217b6524b9d174ab91fb7ffc555c68bfa1da97",
|
||||
"reference": "d3217b6524b9d174ab91fb7ffc555c68bfa1da97",
|
||||
"url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/533865f24f306cf6ac6f1737965553a5c54672e0",
|
||||
"reference": "533865f24f306cf6ac6f1737965553a5c54672e0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -88,7 +88,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "1.6.12",
|
||||
"phpunit/phpunit": "^10"
|
||||
"phpunit/phpunit": "^12"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
@@ -104,10 +104,10 @@
|
||||
"support": {
|
||||
"email": "team@appwrite.io",
|
||||
"issues": "https://github.com/appwrite/sdk-for-php/issues",
|
||||
"source": "https://github.com/appwrite/sdk-for-php/tree/24.2.0",
|
||||
"source": "https://github.com/appwrite/sdk-for-php/tree/26.1.0",
|
||||
"url": "https://appwrite.io/support"
|
||||
},
|
||||
"time": "2026-05-21T18:56:51+00:00"
|
||||
"time": "2026-06-19T08:16:32+00:00"
|
||||
},
|
||||
{
|
||||
"name": "appwrite/php-clamav",
|
||||
@@ -3118,25 +3118,25 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/abuse",
|
||||
"version": "1.3.1",
|
||||
"version": "1.4.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/abuse.git",
|
||||
"reference": "00e59c89a1ac5f4ad771695e5dbee020b3c7ac44"
|
||||
"reference": "8f5df0274869cf9022eea7d8030ca1a0d458b3b2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/00e59c89a1ac5f4ad771695e5dbee020b3c7ac44",
|
||||
"reference": "00e59c89a1ac5f4ad771695e5dbee020b3c7ac44",
|
||||
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/8f5df0274869cf9022eea7d8030ca1a0d458b3b2",
|
||||
"reference": "8f5df0274869cf9022eea7d8030ca1a0d458b3b2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"appwrite/appwrite": "24.*",
|
||||
"appwrite/appwrite": "^26.0",
|
||||
"ext-curl": "*",
|
||||
"ext-pdo": "*",
|
||||
"ext-redis": "*",
|
||||
"php": ">=8.2",
|
||||
"utopia-php/database": "5.*"
|
||||
"utopia-php/database": "^6.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/pint": "1.*",
|
||||
@@ -3164,9 +3164,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/abuse/issues",
|
||||
"source": "https://github.com/utopia-php/abuse/tree/1.3.1"
|
||||
"source": "https://github.com/utopia-php/abuse/tree/1.4.1"
|
||||
},
|
||||
"time": "2026-06-03T07:30:05+00:00"
|
||||
"time": "2026-06-18T11:18:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/agents",
|
||||
@@ -3269,21 +3269,21 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/audit",
|
||||
"version": "2.4.2",
|
||||
"version": "2.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/audit.git",
|
||||
"reference": "6f15caaac5455c98cec06e02fe8da3af9477ff38"
|
||||
"reference": "f5bb07841e335e9ea7d4bd5860da1f580447014a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/audit/zipball/6f15caaac5455c98cec06e02fe8da3af9477ff38",
|
||||
"reference": "6f15caaac5455c98cec06e02fe8da3af9477ff38",
|
||||
"url": "https://api.github.com/repos/utopia-php/audit/zipball/f5bb07841e335e9ea7d4bd5860da1f580447014a",
|
||||
"reference": "f5bb07841e335e9ea7d4bd5860da1f580447014a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.4",
|
||||
"utopia-php/database": "5.*",
|
||||
"utopia-php/database": "^6.0.0",
|
||||
"utopia-php/fetch": "^1.1",
|
||||
"utopia-php/query": "0.1.*",
|
||||
"utopia-php/validators": "0.2.*"
|
||||
@@ -3313,22 +3313,22 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/audit/issues",
|
||||
"source": "https://github.com/utopia-php/audit/tree/2.4.2"
|
||||
"source": "https://github.com/utopia-php/audit/tree/2.6.0"
|
||||
},
|
||||
"time": "2026-06-03T03:42:22+00:00"
|
||||
"time": "2026-06-22T03:33:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/auth",
|
||||
"version": "0.5.1",
|
||||
"version": "0.6.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/auth.git",
|
||||
"reference": "9245a6342ed94f00425aef6963a32b8af9b0dc9d"
|
||||
"reference": "8323a51314f6988c62926117ed642588ca8e8c4a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/auth/zipball/9245a6342ed94f00425aef6963a32b8af9b0dc9d",
|
||||
"reference": "9245a6342ed94f00425aef6963a32b8af9b0dc9d",
|
||||
"url": "https://api.github.com/repos/utopia-php/auth/zipball/8323a51314f6988c62926117ed642588ca8e8c4a",
|
||||
"reference": "8323a51314f6988c62926117ed642588ca8e8c4a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3338,12 +3338,6 @@
|
||||
"ext-sodium": "*",
|
||||
"php": ">=8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/pint": "1.2.*",
|
||||
"phpstan/phpstan": "1.9.x-dev",
|
||||
"phpunit/phpunit": "^9.3",
|
||||
"vimeo/psalm": "4.0.1"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -3369,9 +3363,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/auth/issues",
|
||||
"source": "https://github.com/utopia-php/auth/tree/0.5.1"
|
||||
"source": "https://github.com/utopia-php/auth/tree/0.6.1"
|
||||
},
|
||||
"time": "2026-05-30T12:21:17+00:00"
|
||||
"time": "2026-06-20T09:45:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/cache",
|
||||
@@ -3682,16 +3676,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/database",
|
||||
"version": "5.9.2",
|
||||
"version": "6.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "698952455dd645ff41057621c90a4cea977fb1bf"
|
||||
"reference": "fff9f0effbd40359ff925741ff9424856d8b4fde"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/698952455dd645ff41057621c90a4cea977fb1bf",
|
||||
"reference": "698952455dd645ff41057621c90a4cea977fb1bf",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/fff9f0effbd40359ff925741ff9424856d8b4fde",
|
||||
"reference": "fff9f0effbd40359ff925741ff9424856d8b4fde",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3736,9 +3730,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/5.9.2"
|
||||
"source": "https://github.com/utopia-php/database/tree/6.0.0"
|
||||
},
|
||||
"time": "2026-06-12T08:33:14+00:00"
|
||||
"time": "2026-06-18T10:37:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/detector",
|
||||
@@ -4354,16 +4348,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/messaging",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/messaging.git",
|
||||
"reference": "1aca8968c3bf3c78c428a399dfe97cbe9b366ec4"
|
||||
"reference": "2a8e82cda89b373833e10923ae959f56466300a3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/messaging/zipball/1aca8968c3bf3c78c428a399dfe97cbe9b366ec4",
|
||||
"reference": "1aca8968c3bf3c78c428a399dfe97cbe9b366ec4",
|
||||
"url": "https://api.github.com/repos/utopia-php/messaging/zipball/2a8e82cda89b373833e10923ae959f56466300a3",
|
||||
"reference": "2a8e82cda89b373833e10923ae959f56466300a3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -4371,7 +4365,8 @@
|
||||
"ext-openssl": "*",
|
||||
"giggsey/libphonenumber-for-php-lite": "9.0.23",
|
||||
"php": ">=8.1.0",
|
||||
"phpmailer/phpmailer": "6.9.1"
|
||||
"phpmailer/phpmailer": "6.9.1",
|
||||
"utopia-php/telemetry": "^0.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/pint": "1.*",
|
||||
@@ -4399,31 +4394,31 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/messaging/issues",
|
||||
"source": "https://github.com/utopia-php/messaging/tree/1.0.0"
|
||||
"source": "https://github.com/utopia-php/messaging/tree/1.1.0"
|
||||
},
|
||||
"time": "2026-06-02T14:54:22+00:00"
|
||||
"time": "2026-06-16T03:44:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/migration",
|
||||
"version": "1.13.2",
|
||||
"version": "1.14.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/migration.git",
|
||||
"reference": "50526e121efcf73e11309446f194623a431d7e32"
|
||||
"reference": "f70dba326f1499d1ff4dd18b218b26a858aff1dd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/migration/zipball/50526e121efcf73e11309446f194623a431d7e32",
|
||||
"reference": "50526e121efcf73e11309446f194623a431d7e32",
|
||||
"url": "https://api.github.com/repos/utopia-php/migration/zipball/f70dba326f1499d1ff4dd18b218b26a858aff1dd",
|
||||
"reference": "f70dba326f1499d1ff4dd18b218b26a858aff1dd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"appwrite/appwrite": "24.*",
|
||||
"appwrite/appwrite": "^26.0",
|
||||
"ext-curl": "*",
|
||||
"ext-openssl": "*",
|
||||
"halaxa/json-machine": "^1.2",
|
||||
"php": ">=8.2",
|
||||
"utopia-php/database": "5.*",
|
||||
"utopia-php/database": "^6.0.0",
|
||||
"utopia-php/dsn": "0.2.*",
|
||||
"utopia-php/storage": "2.*"
|
||||
},
|
||||
@@ -4454,9 +4449,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/migration/issues",
|
||||
"source": "https://github.com/utopia-php/migration/tree/1.13.2"
|
||||
"source": "https://github.com/utopia-php/migration/tree/1.14.0"
|
||||
},
|
||||
"time": "2026-06-04T05:09:07+00:00"
|
||||
"time": "2026-06-18T11:19:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/mongo",
|
||||
@@ -5129,16 +5124,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/vcs",
|
||||
"version": "4.2.2",
|
||||
"version": "4.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/vcs.git",
|
||||
"reference": "bb42584d3efb95ff4eb241605bb15165c56974de"
|
||||
"reference": "598cbd2793a5a6394493f1046743e75ec6544a57"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/vcs/zipball/bb42584d3efb95ff4eb241605bb15165c56974de",
|
||||
"reference": "bb42584d3efb95ff4eb241605bb15165c56974de",
|
||||
"url": "https://api.github.com/repos/utopia-php/vcs/zipball/598cbd2793a5a6394493f1046743e75ec6544a57",
|
||||
"reference": "598cbd2793a5a6394493f1046743e75ec6544a57",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -5172,9 +5167,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/vcs/issues",
|
||||
"source": "https://github.com/utopia-php/vcs/tree/4.2.2"
|
||||
"source": "https://github.com/utopia-php/vcs/tree/4.2.3"
|
||||
},
|
||||
"time": "2026-06-10T08:08:48+00:00"
|
||||
"time": "2026-06-16T12:14:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/websocket",
|
||||
|
||||
+1
-1
@@ -1249,7 +1249,7 @@ services:
|
||||
hostname: exc1
|
||||
<<: *x-logging
|
||||
stop_signal: SIGINT
|
||||
image: openruntimes/executor:0.24.1
|
||||
image: openruntimes/executor:0.25.1
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- appwrite
|
||||
|
||||
@@ -143,6 +143,7 @@ class Mails extends Listener
|
||||
project: $project,
|
||||
recipient: $event->user['email'],
|
||||
subject: $subject,
|
||||
template: MAIL_TEMPLATE_SESSION_ALERT,
|
||||
bodyTemplate: __DIR__ . '/../../../../app/config/locale/templates/' . $smtpBaseTemplate . '.tpl',
|
||||
body: $body,
|
||||
preview: $preview,
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\Event\Message;
|
||||
|
||||
use Utopia\Database\Document;
|
||||
|
||||
final class Executions extends Base
|
||||
{
|
||||
/**
|
||||
* @param array<Document> $executions
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly Document $project,
|
||||
public readonly array $executions,
|
||||
) {
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'project' => $this->project->getArrayCopy(),
|
||||
'executions' => \array_map(
|
||||
fn (Document $execution) => $execution->getArrayCopy(),
|
||||
$this->executions
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
public static function fromArray(array $data): static
|
||||
{
|
||||
return new self(
|
||||
project: new Document($data['project'] ?? []),
|
||||
executions: \array_map(
|
||||
fn (array $execution) => new Document($execution),
|
||||
$data['executions'] ?? []
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ final class Mail extends Base
|
||||
public readonly string $recipient = '',
|
||||
public readonly string $name = '',
|
||||
public readonly string $subject = '',
|
||||
public readonly string $template = '',
|
||||
public readonly string $bodyTemplate = '',
|
||||
public readonly string $body = '',
|
||||
public readonly string $preview = '',
|
||||
@@ -33,6 +34,7 @@ final class Mail extends Base
|
||||
'recipient' => $this->recipient,
|
||||
'name' => $this->name,
|
||||
'subject' => $this->subject,
|
||||
'template' => $this->template,
|
||||
'bodyTemplate' => $this->bodyTemplate,
|
||||
'body' => $this->body,
|
||||
'preview' => $this->preview,
|
||||
@@ -52,6 +54,7 @@ final class Mail extends Base
|
||||
recipient: $data['recipient'] ?? '',
|
||||
name: $data['name'] ?? '',
|
||||
subject: $data['subject'] ?? '',
|
||||
template: $data['template'] ?? '',
|
||||
bodyTemplate: $data['bodyTemplate'] ?? '',
|
||||
body: $data['body'] ?? '',
|
||||
preview: $data['preview'] ?? '',
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Appwrite\Event\Publisher;
|
||||
|
||||
use Appwrite\Event\Message\Execution as ExecutionMessage;
|
||||
use Appwrite\Event\Message\Executions as ExecutionsMessage;
|
||||
use Utopia\Queue\Publisher;
|
||||
use Utopia\Queue\Queue;
|
||||
|
||||
@@ -15,7 +16,7 @@ readonly class Execution extends Base
|
||||
parent::__construct($publisher);
|
||||
}
|
||||
|
||||
public function enqueue(ExecutionMessage $message): string|bool
|
||||
public function enqueue(ExecutionMessage|ExecutionsMessage $message): string|bool
|
||||
{
|
||||
return $this->publish($this->queue, $message);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,14 @@ class Install extends Action
|
||||
->param('accountPassword', '', new Password(allowEmpty: true), 'Account password', true)
|
||||
->param('database', '', new WhiteList(['mongodb', 'mariadb', 'postgresql']), 'Database adapter', true)
|
||||
->param('installId', '', new Text(64, 0), 'Installation ID', true)
|
||||
->param('retryStep', null, new Nullable(new WhiteList([Server::STEP_DOCKER_COMPOSE, Server::STEP_ENV_VARS, Server::STEP_DOCKER_CONTAINERS], true)), 'Retry from step', true)
|
||||
->param('retryStep', null, new Nullable(new WhiteList([
|
||||
Server::STEP_CONFIG_FILES,
|
||||
Server::STEP_DOCKER_COMPOSE,
|
||||
Server::STEP_ENV_VARS,
|
||||
Server::STEP_DOCKER_CONTAINERS,
|
||||
Server::STEP_ACCOUNT_SETUP,
|
||||
Server::STEP_MIGRATION,
|
||||
], true)), 'Retry from step', true)
|
||||
->param('migrate', false, new \Utopia\Validator\Boolean(true), 'Run database migration after upgrade', true)
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
|
||||
@@ -69,17 +69,33 @@ class Reset extends Action
|
||||
$isLocal = $config->isLocal();
|
||||
$composeFileName = $isLocal ? 'docker-compose.web-installer.yml' : 'docker-compose.yml';
|
||||
$envFileName = $isLocal ? '.env.web-installer' : '.env';
|
||||
$path = $isLocal ? '/usr/src/code' : '/usr/src/code/appwrite';
|
||||
$path = $isLocal ? $config->getHostPath() : '/usr/src/code/appwrite';
|
||||
|
||||
if ($path === null || $path === '') {
|
||||
return 'Missing host path for local installer reset';
|
||||
}
|
||||
|
||||
$composeFile = $path . '/' . $composeFileName;
|
||||
$envFile = $path . '/' . $envFileName;
|
||||
|
||||
if (file_exists($composeFile)) {
|
||||
$command = array_map(escapeshellarg(...), [
|
||||
$command = [
|
||||
'docker', 'compose',
|
||||
'-f', $composeFile,
|
||||
];
|
||||
if (file_exists($envFile)) {
|
||||
$command[] = '--env-file';
|
||||
$command[] = $envFile;
|
||||
}
|
||||
$command = array_map(escapeshellarg(...), [
|
||||
...$command,
|
||||
'-f',
|
||||
$composeFile,
|
||||
...($isLocal ? ['--project-name', 'appwrite'] : []),
|
||||
'--project-directory', $path,
|
||||
'down', '-v', '--remove-orphans',
|
||||
'--project-directory',
|
||||
$path,
|
||||
'down',
|
||||
'-v',
|
||||
'--remove-orphans',
|
||||
]);
|
||||
|
||||
$output = [];
|
||||
@@ -92,7 +108,6 @@ class Reset extends Action
|
||||
@unlink($composeFile);
|
||||
}
|
||||
|
||||
$envFile = $path . '/' . $envFileName;
|
||||
if (file_exists($envFile)) {
|
||||
@unlink($envFile);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,6 @@ class Server
|
||||
}
|
||||
|
||||
if (isset($opts['docker'])) {
|
||||
$this->printInstallerUrl($host, $port);
|
||||
$this->startDockerInstaller($opts);
|
||||
}
|
||||
|
||||
@@ -365,9 +364,13 @@ class Server
|
||||
'-i',
|
||||
'--rm',
|
||||
'--name', $container,
|
||||
'--label', 'com.docker.compose.project=appwrite-installer',
|
||||
'--label', 'com.docker.compose.service=appwrite-installer',
|
||||
'--add-host', 'host.docker.internal:host-gateway',
|
||||
'-p', "127.0.0.1:$port:" . self::INSTALLER_WEB_PORT,
|
||||
'--volume', '/var/run/docker.sock:/var/run/docker.sock',
|
||||
'--volume', "$volumePath:/usr/src/code:rw",
|
||||
'--volume', "$volumePath:$volumePath:rw",
|
||||
];
|
||||
$args[] = '-e';
|
||||
$args[] = 'APPWRITE_INSTALLER_CONFIG=' . $configJson;
|
||||
|
||||
@@ -336,6 +336,7 @@ class Create extends Action
|
||||
project: $project,
|
||||
recipient: $user->getAttribute('email'),
|
||||
subject: $subject,
|
||||
template: MAIL_TEMPLATE_MFA_CHALLENGE,
|
||||
bodyTemplate: $bodyTemplate,
|
||||
body: $body,
|
||||
preview: $preview,
|
||||
|
||||
@@ -21,6 +21,41 @@ class Action extends AppwriteAction
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Database types this path may operate on. Single source of truth shared by
|
||||
* the list filter ({@see getDatabaseTypeQueryFilters()}) and the by-id guard
|
||||
* ({@see isDatabaseTypeMismatch()}) so they cannot diverge.
|
||||
*
|
||||
* TablesDB is the compatibility successor to the legacy databases API, so it
|
||||
* also serves legacy-typed databases; the other product APIs are scoped to
|
||||
* their own type. Every database carries a non-null `type` (set on create
|
||||
* and backfilled to 'legacy' by migration V23), so null is not represented.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getAllowedDatabaseTypes(): array
|
||||
{
|
||||
return match ($this->getDatabaseType()) {
|
||||
DATABASE_TYPE_TABLESDB => [DATABASE_TYPE_TABLESDB, DATABASE_TYPE_LEGACY],
|
||||
default => [$this->getDatabaseType()],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A database resolved by id on a product-DB path must be one of the path's
|
||||
* allowed types; otherwise it is treated as not-found rather than proceeding
|
||||
* to a type-mismatched backend operation that surfaces as an opaque 500. The
|
||||
* legacy /v1/databases API is intentionally not type-guarded.
|
||||
*/
|
||||
protected function isDatabaseTypeMismatch(Document $database): bool
|
||||
{
|
||||
if ($this->getDatabaseType() === DATABASE_TYPE_LEGACY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !in_array($database->getAttribute('type', ''), $this->getAllowedDatabaseTypes(), true);
|
||||
}
|
||||
|
||||
public function setHttpPath(string $path): self
|
||||
{
|
||||
if (\str_contains($path, '/tablesdb')) {
|
||||
|
||||
+8
-6
@@ -6,6 +6,7 @@ use Appwrite\Event\Event;
|
||||
use Appwrite\Event\Message\Database as DatabaseMessage;
|
||||
use Appwrite\Event\Publisher\Database as DatabasePublisher;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Action as DatabasesAction;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
use Throwable;
|
||||
@@ -21,10 +22,9 @@ use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Validator\Structure;
|
||||
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
|
||||
use Utopia\Platform\Action as UtopiaAction;
|
||||
use Utopia\Validator\Range;
|
||||
|
||||
abstract class Action extends UtopiaAction
|
||||
abstract class Action extends DatabasesAction
|
||||
{
|
||||
/**
|
||||
* @var string The current context (either 'column' or 'attribute')
|
||||
@@ -36,12 +36,14 @@ abstract class Action extends UtopiaAction
|
||||
*/
|
||||
abstract protected function getResponseModel(): string|array;
|
||||
|
||||
public function setHttpPath(string $path): UtopiaAction
|
||||
public function setHttpPath(string $path): DatabasesAction
|
||||
{
|
||||
if (\str_contains($path, '/tablesdb')) {
|
||||
$this->context = COLUMNS;
|
||||
}
|
||||
return parent::setHttpPath($path);
|
||||
parent::setHttpPath($path);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,7 +335,7 @@ abstract class Action extends UtopiaAction
|
||||
|
||||
$db = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
|
||||
if ($db->isEmpty()) {
|
||||
if ($db->isEmpty() || $this->isDatabaseTypeMismatch($db)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
@@ -495,7 +497,7 @@ abstract class Action extends UtopiaAction
|
||||
{
|
||||
$db = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
|
||||
if ($db->isEmpty()) {
|
||||
if ($db->isEmpty() || $this->isDatabaseTypeMismatch($db)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ class Delete extends Action
|
||||
public function action(string $databaseId, string $collectionId, string $key, UtopiaResponse $response, Database $dbForProject, DatabasePublisher $publisherForDatabase, Event $queueForEvents, Authorization $authorization): void
|
||||
{
|
||||
$db = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($db->isEmpty()) {
|
||||
if ($db->isEmpty() || $this->isDatabaseTypeMismatch($db)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ class Get extends Action
|
||||
public function action(string $databaseId, string $collectionId, string $key, UtopiaResponse $response, Database $dbForProject, Authorization $authorization): void
|
||||
{
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -7,6 +7,7 @@ use Appwrite\Event\Publisher\Database as DatabasePublisher;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Attributes\Action;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
@@ -57,6 +58,10 @@ class Create extends Action
|
||||
model: $this->getResponseModel()
|
||||
)
|
||||
],
|
||||
deprecated: new Deprecated(
|
||||
since: '1.8.0',
|
||||
replaceWith: 'tablesDB.createLongtextColumn',
|
||||
),
|
||||
))
|
||||
->param('databaseId', '', new UID(), 'Database ID.')
|
||||
->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).')
|
||||
|
||||
+5
@@ -6,6 +6,7 @@ use Appwrite\Event\Event;
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Attributes\Action;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
@@ -55,6 +56,10 @@ class Update extends Action
|
||||
)
|
||||
],
|
||||
contentType: ContentType::JSON,
|
||||
deprecated: new Deprecated(
|
||||
since: '1.8.0',
|
||||
replaceWith: 'tablesDB.updateLongtextColumn',
|
||||
),
|
||||
))
|
||||
->param('databaseId', '', new UID(), 'Database ID.')
|
||||
->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).')
|
||||
|
||||
+5
@@ -7,6 +7,7 @@ use Appwrite\Event\Publisher\Database as DatabasePublisher;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Attributes\Action;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
@@ -57,6 +58,10 @@ class Create extends Action
|
||||
model: $this->getResponseModel()
|
||||
)
|
||||
],
|
||||
deprecated: new Deprecated(
|
||||
since: '1.8.0',
|
||||
replaceWith: 'tablesDB.createMediumtextColumn',
|
||||
),
|
||||
))
|
||||
->param('databaseId', '', new UID(), 'Database ID.')
|
||||
->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).')
|
||||
|
||||
+5
@@ -6,6 +6,7 @@ use Appwrite\Event\Event;
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Attributes\Action;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
@@ -55,6 +56,10 @@ class Update extends Action
|
||||
)
|
||||
],
|
||||
contentType: ContentType::JSON,
|
||||
deprecated: new Deprecated(
|
||||
since: '1.8.0',
|
||||
replaceWith: 'tablesDB.updateMediumtextColumn',
|
||||
),
|
||||
))
|
||||
->param('databaseId', '', new UID(), 'Database ID.')
|
||||
->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).')
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ class Create extends Action
|
||||
$twoWayKey ??= $collectionId;
|
||||
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -7,6 +7,7 @@ use Appwrite\Event\Publisher\Database as DatabasePublisher;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Attributes\Action;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
@@ -57,6 +58,10 @@ class Create extends Action
|
||||
model: $this->getResponseModel()
|
||||
)
|
||||
],
|
||||
deprecated: new Deprecated(
|
||||
since: '1.8.0',
|
||||
replaceWith: 'tablesDB.createTextColumn',
|
||||
),
|
||||
))
|
||||
->param('databaseId', '', new UID(), 'Database ID.')
|
||||
->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).')
|
||||
|
||||
+5
@@ -6,6 +6,7 @@ use Appwrite\Event\Event;
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Attributes\Action;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
@@ -55,6 +56,10 @@ class Update extends Action
|
||||
)
|
||||
],
|
||||
contentType: ContentType::JSON,
|
||||
deprecated: new Deprecated(
|
||||
since: '1.8.0',
|
||||
replaceWith: 'tablesDB.updateTextColumn',
|
||||
),
|
||||
))
|
||||
->param('databaseId', '', new UID(), 'Database ID.')
|
||||
->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).')
|
||||
|
||||
+5
@@ -7,6 +7,7 @@ use Appwrite\Event\Publisher\Database as DatabasePublisher;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Attributes\Action;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
@@ -59,6 +60,10 @@ class Create extends Action
|
||||
model: $this->getResponseModel()
|
||||
)
|
||||
],
|
||||
deprecated: new Deprecated(
|
||||
since: '1.8.0',
|
||||
replaceWith: 'tablesDB.createVarcharColumn',
|
||||
),
|
||||
))
|
||||
->param('databaseId', '', new UID(), 'Database ID.')
|
||||
->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).')
|
||||
|
||||
+5
@@ -6,6 +6,7 @@ use Appwrite\Event\Event;
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Attributes\Action;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
@@ -57,6 +58,10 @@ class Update extends Action
|
||||
)
|
||||
],
|
||||
contentType: ContentType::JSON,
|
||||
deprecated: new Deprecated(
|
||||
since: '1.8.0',
|
||||
replaceWith: 'tablesDB.updateVarcharColumn',
|
||||
),
|
||||
))
|
||||
->param('databaseId', '', new UID(), 'Database ID.')
|
||||
->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).')
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ class XList extends Action
|
||||
public function action(string $databaseId, string $collectionId, array $queries, bool $includeTotal, UtopiaResponse $response, Database $dbForProject, Authorization $authorization): void
|
||||
{
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ class Create extends Action
|
||||
{
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class Delete extends Action
|
||||
public function action(string $databaseId, string $collectionId, UtopiaResponse $response, Database $dbForProject, callable $getDatabasesDB, DatabasePublisher $publisherForDatabase, Event $queueForEvents, Authorization $authorization): void
|
||||
{
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ class Decrement extends Action
|
||||
$isPrivilegedUser = $user->isPrivileged($authorization->getRoles());
|
||||
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ class Increment extends Action
|
||||
$isPrivilegedUser = $user->isPrivileged($authorization->getRoles());
|
||||
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ class Delete extends Action
|
||||
public function action(string $databaseId, string $collectionId, array $queries, ?string $transactionId, UtopiaResponse $response, Database $dbForProject, callable $getDatabasesDB, Context $usage, Event $queueForEvents, Event $queueForRealtime, FunctionPublisher $publisherForFunctions, Event $queueForWebhooks, array $plan, EventProcessor $eventProcessor): void
|
||||
{
|
||||
$database = $dbForProject->getDocument('databases', $databaseId);
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ class Update extends Action
|
||||
}
|
||||
|
||||
$database = $dbForProject->getDocument('databases', $databaseId);
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ class Upsert extends Action
|
||||
public function action(string $databaseId, string $collectionId, array $documents, ?string $transactionId, UtopiaResponse $response, Database $dbForProject, callable $getDatabasesDB, Context $usage, Event $queueForEvents, Event $queueForRealtime, FunctionPublisher $publisherForFunctions, Event $queueForWebhooks, array $plan, EventProcessor $eventProcessor): void
|
||||
{
|
||||
$database = $dbForProject->getDocument('databases', $databaseId);
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -209,7 +209,7 @@ class Create extends Action
|
||||
}
|
||||
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database) || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ class Delete extends Action
|
||||
$isAPIKey = $user->isKey($authorization->getRoles());
|
||||
$isPrivilegedUser = $user->isPrivileged($authorization->getRoles());
|
||||
|
||||
if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database) || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ class Get extends Action
|
||||
$isPrivilegedUser = $user->isPrivileged($authorization->getRoles());
|
||||
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database) || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ class XList extends Action
|
||||
public function action(string $databaseId, string $collectionId, string $documentId, array $queries, UtopiaResponse $response, Database $dbForProject, callable $getDatabasesDB, Locale $locale, Reader $geodb, Authorization $authorization, Audit $audit): void
|
||||
{
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ class Update extends Action
|
||||
$isAPIKey = $user->isKey($authorization->getRoles());
|
||||
$isPrivilegedUser = $user->isPrivileged($authorization->getRoles());
|
||||
|
||||
if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database) || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ class Upsert extends Action
|
||||
$isPrivilegedUser = $user->isPrivileged($authorization->getRoles());
|
||||
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database) || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ class XList extends Action
|
||||
$isPrivilegedUser = $user->isPrivileged($authorization->getRoles());
|
||||
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database) || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class Get extends Action
|
||||
{
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -3,9 +3,9 @@
|
||||
namespace Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Indexes;
|
||||
|
||||
use Appwrite\Extend\Exception;
|
||||
use Utopia\Platform\Action as UtopiaAction;
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Action as DatabasesAction;
|
||||
|
||||
abstract class Action extends UtopiaAction
|
||||
abstract class Action extends DatabasesAction
|
||||
{
|
||||
/**
|
||||
* The current API context (either 'columnIndex' or 'index').
|
||||
@@ -17,12 +17,14 @@ abstract class Action extends UtopiaAction
|
||||
*/
|
||||
abstract protected function getResponseModel(): string;
|
||||
|
||||
public function setHttpPath(string $path): UtopiaAction
|
||||
public function setHttpPath(string $path): DatabasesAction
|
||||
{
|
||||
if (\str_contains($path, '/tablesdb')) {
|
||||
$this->context = COLUMN_INDEX;
|
||||
}
|
||||
return parent::setHttpPath($path);
|
||||
parent::setHttpPath($path);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ class Create extends Action
|
||||
{
|
||||
$db = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
|
||||
if ($db->isEmpty()) {
|
||||
if ($db->isEmpty() || $this->isDatabaseTypeMismatch($db)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ class Delete extends Action
|
||||
{
|
||||
$db = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
|
||||
if ($db->isEmpty()) {
|
||||
if ($db->isEmpty() || $this->isDatabaseTypeMismatch($db)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
$collection = $dbForProject->getDocument('database_' . $db->getSequence(), $collectionId);
|
||||
|
||||
@@ -67,7 +67,7 @@ class Get extends Action
|
||||
{
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
$collection = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId);
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ class XList extends Action
|
||||
/** @var Document $database */
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class XList extends Action
|
||||
{
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class Update extends Action
|
||||
public function action(string $databaseId, string $collectionId, ?string $name, ?array $permissions, bool $documentSecurity, bool $enabled, bool $purge, UtopiaResponse $response, Database $dbForProject, callable $getDatabasesDB, Event $queueForEvents, Authorization $authorization): void
|
||||
{
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class XList extends Action
|
||||
{
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
|
||||
use Utopia\Platform\Action;
|
||||
|
||||
class Delete extends Action
|
||||
{
|
||||
@@ -68,7 +67,7 @@ class Delete extends Action
|
||||
{
|
||||
$database = $dbForProject->getDocument('databases', $databaseId);
|
||||
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
|
||||
use Utopia\Platform\Action;
|
||||
|
||||
class Get extends Action
|
||||
{
|
||||
@@ -60,7 +59,7 @@ class Get extends Action
|
||||
{
|
||||
$database = $dbForProject->getDocument('databases', $databaseId);
|
||||
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Appwrite\Platform\Modules\Databases\Http\Databases\Logs;
|
||||
|
||||
use Appwrite\Detector\Detector;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Action;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
@@ -23,7 +24,6 @@ use Utopia\Database\Validator\Query\Offset;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
|
||||
use Utopia\Locale\Locale;
|
||||
use Utopia\Platform\Action;
|
||||
|
||||
class XList extends Action
|
||||
{
|
||||
@@ -75,7 +75,7 @@ class XList extends Action
|
||||
{
|
||||
$database = $dbForProject->getDocument('databases', $databaseId);
|
||||
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Appwrite\Platform\Modules\Databases\Http\Databases\Transactions;
|
||||
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
@@ -49,7 +50,11 @@ class Create extends Action
|
||||
model: UtopiaResponse::MODEL_TRANSACTION,
|
||||
)
|
||||
],
|
||||
contentType: ContentType::JSON
|
||||
contentType: ContentType::JSON,
|
||||
deprecated: new Deprecated(
|
||||
since: '1.8.0',
|
||||
replaceWith: 'tablesDB.createTransaction',
|
||||
)
|
||||
))
|
||||
->param('ttl', APP_DATABASE_TXN_TTL_DEFAULT, new Range(min: APP_DATABASE_TXN_TTL_MIN, max: APP_DATABASE_TXN_TTL_MAX), 'Seconds before the transaction expires.', true)
|
||||
->inject('response')
|
||||
|
||||
@@ -7,6 +7,7 @@ use Appwrite\Event\Publisher\Delete as DeletePublisher;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
@@ -48,7 +49,11 @@ class Delete extends Action
|
||||
model: UtopiaResponse::MODEL_NONE,
|
||||
)
|
||||
],
|
||||
contentType: ContentType::NONE
|
||||
contentType: ContentType::NONE,
|
||||
deprecated: new Deprecated(
|
||||
since: '1.8.0',
|
||||
replaceWith: 'tablesDB.deleteTransaction',
|
||||
)
|
||||
))
|
||||
->param('transactionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Transaction ID.', false, ['dbForProject'])
|
||||
->inject('response')
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Appwrite\Platform\Modules\Databases\Http\Databases\Transactions;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
@@ -45,7 +46,11 @@ class Get extends Action
|
||||
model: UtopiaResponse::MODEL_TRANSACTION,
|
||||
)
|
||||
],
|
||||
contentType: ContentType::JSON
|
||||
contentType: ContentType::JSON,
|
||||
deprecated: new Deprecated(
|
||||
since: '1.8.0',
|
||||
replaceWith: 'tablesDB.getTransaction',
|
||||
)
|
||||
))
|
||||
->param('transactionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Transaction ID.', false, ['dbForProject'])
|
||||
->inject('response')
|
||||
|
||||
+7
-2
@@ -7,6 +7,7 @@ use Appwrite\Extend\Exception;
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Transactions\Action;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Database\Documents\User;
|
||||
@@ -56,7 +57,11 @@ class Create extends Action
|
||||
model: UtopiaResponse::MODEL_TRANSACTION,
|
||||
)
|
||||
],
|
||||
contentType: ContentType::JSON
|
||||
contentType: ContentType::JSON,
|
||||
deprecated: new Deprecated(
|
||||
since: '1.8.0',
|
||||
replaceWith: 'tablesDB.createOperations',
|
||||
)
|
||||
))
|
||||
->param('transactionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Transaction ID.', false, ['dbForProject'])
|
||||
->param('operations', [], new ArrayList(new Operation(type: 'legacy')), 'Array of staged operations.', true)
|
||||
@@ -117,7 +122,7 @@ class Create extends Action
|
||||
}
|
||||
|
||||
$database = $databases[$operation['databaseId']] ??= $authorization->skip(fn () => $dbForProject->getDocument('databases', $operation['databaseId']));
|
||||
if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database) || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$operation['databaseId']]);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ use Appwrite\Extend\Exception;
|
||||
use Appwrite\Functions\EventProcessor;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Usage\Context;
|
||||
@@ -65,7 +66,11 @@ class Update extends Action
|
||||
model: UtopiaResponse::MODEL_TRANSACTION,
|
||||
)
|
||||
],
|
||||
contentType: ContentType::JSON
|
||||
contentType: ContentType::JSON,
|
||||
deprecated: new Deprecated(
|
||||
since: '1.8.0',
|
||||
replaceWith: 'tablesDB.updateTransaction',
|
||||
)
|
||||
))
|
||||
->param('transactionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Transaction ID.', false, ['dbForProject'])
|
||||
->param('commit', false, new Boolean(), 'Commit transaction?', true)
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Appwrite\Platform\Modules\Databases\Http\Databases\Transactions;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Database\Validator\Queries\Transactions;
|
||||
@@ -48,7 +49,11 @@ class XList extends Action
|
||||
model: UtopiaResponse::MODEL_TRANSACTION_LIST,
|
||||
)
|
||||
],
|
||||
contentType: ContentType::JSON
|
||||
contentType: ContentType::JSON,
|
||||
deprecated: new Deprecated(
|
||||
since: '1.8.0',
|
||||
replaceWith: 'tablesDB.listTransactions',
|
||||
)
|
||||
))
|
||||
->param('queries', [], new Transactions(), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries).', true)
|
||||
->inject('response')
|
||||
|
||||
@@ -13,7 +13,6 @@ use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Validator\Boolean;
|
||||
use Utopia\Validator\Text;
|
||||
|
||||
@@ -69,7 +68,7 @@ class Update extends Action
|
||||
{
|
||||
$database = $dbForProject->getDocument('databases', $databaseId);
|
||||
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Appwrite\Platform\Modules\Databases\Http\Databases\Usage;
|
||||
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\Platform\Action;
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Action as DatabasesAction;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Deprecated;
|
||||
@@ -20,7 +20,7 @@ use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
|
||||
use Utopia\Platform\Enum;
|
||||
use Utopia\Validator\WhiteList;
|
||||
|
||||
class Get extends Action
|
||||
class Get extends DatabasesAction
|
||||
{
|
||||
public static function getName(): string
|
||||
{
|
||||
@@ -29,7 +29,7 @@ class Get extends Action
|
||||
|
||||
protected $databaseType = DATABASE_TYPE_LEGACY;
|
||||
|
||||
public function setHttpPath(string $path): Action
|
||||
public function setHttpPath(string $path): DatabasesAction
|
||||
{
|
||||
$this->databaseType = match (true) {
|
||||
str_contains($path, '/documentsdb') => DATABASE_TYPE_DOCUMENTSDB,
|
||||
@@ -114,7 +114,7 @@ class Get extends Action
|
||||
{
|
||||
$database = $dbForProject->getDocument('databases', $databaseId);
|
||||
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class XList extends Action
|
||||
|
||||
protected function getDatabaseTypeQueryFilters(): array
|
||||
{
|
||||
return [Query::equal('type', [$this->getDatabaseType()])];
|
||||
return [Query::equal('type', $this->getAllowedDatabaseTypes())];
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Appwrite\Platform\Modules\Databases\Http\TablesDB\Logs;
|
||||
|
||||
use Appwrite\Detector\Detector;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Action;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Method;
|
||||
@@ -22,7 +23,6 @@ use Utopia\Database\Validator\Query\Offset;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
|
||||
use Utopia\Locale\Locale;
|
||||
use Utopia\Platform\Action;
|
||||
|
||||
class XList extends Action
|
||||
{
|
||||
@@ -70,7 +70,7 @@ class XList extends Action
|
||||
{
|
||||
$database = $dbForProject->getDocument('databases', $databaseId);
|
||||
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Database\Validator\Queries\Databases;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
|
||||
use Utopia\Validator\Boolean;
|
||||
use Utopia\Validator\Text;
|
||||
@@ -21,16 +20,6 @@ class XList extends DatabaseXList
|
||||
return 'listTablesDatabases';
|
||||
}
|
||||
|
||||
protected function getDatabaseTypeQueryFilters(): array
|
||||
{
|
||||
return [
|
||||
Query::or([
|
||||
Query::equal('type', [DATABASE_TYPE_TABLESDB, DATABASE_TYPE_LEGACY]),
|
||||
Query::isNull('type'),
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
|
||||
@@ -85,7 +85,7 @@ class Create extends CollectionAction
|
||||
{
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ class Update extends CollectionAction
|
||||
public function action(string $databaseId, string $collectionId, ?string $name, ?int $dimensions, ?array $permissions, bool $documentSecurity, ?bool $enabled, UtopiaResponse $response, Database $dbForProject, callable $getDatabasesDB, Event $queueForEvents, Authorization $authorization): void
|
||||
{
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty()) {
|
||||
if ($database->isEmpty() || $this->isDatabaseTypeMismatch($database)) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
||||
@@ -218,6 +218,10 @@ class Create extends Base
|
||||
throw new Exception(Exception::INSTALLATION_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (!empty($installationId) && $installation->getAttribute('projectId') !== $project->getId()) {
|
||||
throw new Exception(Exception::INSTALLATION_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (!empty($providerRepositoryId) && (empty($installationId) || empty($providerBranch))) {
|
||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'When connecting to VCS (Version Control System), you need to provide "installationId" and "providerBranch".');
|
||||
}
|
||||
|
||||
@@ -182,6 +182,10 @@ class Update extends Base
|
||||
|
||||
$isConnected = !empty($function->getAttribute('providerRepositoryId', ''));
|
||||
|
||||
if (!empty($installationId) && $installation->getAttribute('projectId') !== $project->getId()) {
|
||||
throw new Exception(Exception::INSTALLATION_NOT_FOUND);
|
||||
}
|
||||
|
||||
// Omitted providerRepositoryId (null) on a connected function — preserve existing VCS values
|
||||
if ($isConnected && $providerRepositoryId === null) {
|
||||
$providerRepositoryId = $function->getAttribute('providerRepositoryId', '');
|
||||
|
||||
@@ -152,6 +152,7 @@ class Create extends Action
|
||||
project: $project,
|
||||
recipient: $email,
|
||||
subject: $subject,
|
||||
template: MAIL_TEMPLATE_SMTP_TEST,
|
||||
bodyTemplate: APP_CE_CONFIG_DIR . '/locale/templates/email-base-styled.tpl',
|
||||
body: $template->render(),
|
||||
smtp: [
|
||||
|
||||
@@ -151,6 +151,10 @@ class Create extends Base
|
||||
throw new Exception(Exception::INSTALLATION_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (!empty($installationId) && $installation->getAttribute('projectId') !== $project->getId()) {
|
||||
throw new Exception(Exception::INSTALLATION_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (!empty($providerRepositoryId) && (empty($installationId) || empty($providerBranch))) {
|
||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'When connecting to VCS (Version Control System), you need to provide "installationId" and "providerBranch".');
|
||||
}
|
||||
|
||||
@@ -183,6 +183,10 @@ class Update extends Base
|
||||
|
||||
$isConnected = !empty($site->getAttribute('providerRepositoryId', ''));
|
||||
|
||||
if (!empty($installationId) && $installation->getAttribute('projectId') !== $project->getId()) {
|
||||
throw new Exception(Exception::INSTALLATION_NOT_FOUND);
|
||||
}
|
||||
|
||||
// Omitted providerRepositoryId (null) on a connected site — preserve existing VCS values
|
||||
if ($isConnected && $providerRepositoryId === null) {
|
||||
$providerRepositoryId = $site->getAttribute('providerRepositoryId', '');
|
||||
|
||||
@@ -129,8 +129,8 @@ class Create extends Action
|
||||
'$id' => $index['$id'],
|
||||
'type' => $index['type'],
|
||||
'attributes' => $index['attributes'],
|
||||
'lengths' => $index['lengths'],
|
||||
'orders' => $index['orders'],
|
||||
'lengths' => $index['lengths'] ?? [],
|
||||
'orders' => $index['orders'] ?? [],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -418,6 +418,7 @@ class Create extends Action
|
||||
recipient: $invitee->getAttribute('email'),
|
||||
name: $invitee->getAttribute('name', ''),
|
||||
subject: $subject,
|
||||
template: MAIL_TEMPLATE_INVITATION,
|
||||
body: $body,
|
||||
preview: $preview,
|
||||
smtp: $smtpConfig,
|
||||
|
||||
@@ -538,6 +538,19 @@ class Install extends Action
|
||||
|
||||
$assistantKey = (string) ($input['_APP_ASSISTANT_OPENAI_API_KEY'] ?? '');
|
||||
$enableAssistant = trim($assistantKey) !== '';
|
||||
$enabledRuntimes = \array_unique(\array_filter(\array_map(
|
||||
'trim',
|
||||
\explode(',', ($input['_APP_FUNCTIONS_RUNTIMES'] ?? '') . ',' . ($input['_APP_SITES_RUNTIMES'] ?? ''))
|
||||
)));
|
||||
$runtimes = Config::getParam('runtimes', []);
|
||||
$runtimeImages = [];
|
||||
foreach ($enabledRuntimes as $runtime) {
|
||||
$imageName = $runtimes[$runtime]['image'] ?? '';
|
||||
if ($imageName !== '') {
|
||||
$runtimeImages[] = $imageName;
|
||||
}
|
||||
}
|
||||
$executorImages = \implode(',', \array_unique($runtimeImages));
|
||||
|
||||
$templateForCompose
|
||||
->setParam('httpPort', $httpPort)
|
||||
@@ -547,17 +560,24 @@ class Install extends Action
|
||||
->setParam('image', $image)
|
||||
->setParam('database', $database)
|
||||
->setParam('hostPath', $this->hostPath)
|
||||
->setParam('enableAssistant', $enableAssistant);
|
||||
->setParam('enableAssistant', $enableAssistant)
|
||||
->setParam('executorImages', $executorImages);
|
||||
|
||||
$templateForEnv->setParam('vars', $input);
|
||||
|
||||
$steps = [
|
||||
InstallerServer::STEP_DOCKER_COMPOSE,
|
||||
InstallerServer::STEP_ENV_VARS,
|
||||
InstallerServer::STEP_DOCKER_CONTAINERS
|
||||
InstallerServer::STEP_DOCKER_CONTAINERS,
|
||||
InstallerServer::STEP_ACCOUNT_SETUP,
|
||||
InstallerServer::STEP_MIGRATION,
|
||||
];
|
||||
|
||||
$startIndex = 0;
|
||||
$resumeFromStep = match ($resumeFromStep) {
|
||||
InstallerServer::STEP_CONFIG_FILES => InstallerServer::STEP_DOCKER_COMPOSE,
|
||||
default => $resumeFromStep,
|
||||
};
|
||||
if ($resumeFromStep !== null) {
|
||||
$resumeIndex = array_search($resumeFromStep, $steps, true);
|
||||
if ($resumeIndex !== false) {
|
||||
@@ -597,37 +617,43 @@ class Install extends Action
|
||||
$this->updateProgress($progress, InstallerServer::STEP_CONFIG_FILES, InstallerServer::STATUS_COMPLETED, $messages);
|
||||
}
|
||||
|
||||
if ($database === 'mongodb' && !$useExistingConfig) {
|
||||
if ($database === 'mongodb' && !$useExistingConfig && $startIndex <= 1) {
|
||||
$this->copyMongoEntrypointIfNeeded();
|
||||
}
|
||||
|
||||
if (!$noStart) {
|
||||
$currentStep = InstallerServer::STEP_DOCKER_CONTAINERS;
|
||||
$this->updateProgress($progress, InstallerServer::STEP_DOCKER_CONTAINERS, InstallerServer::STATUS_IN_PROGRESS, $messages);
|
||||
$this->runDockerCompose($input, $isLocalInstall, $useExistingConfig, $isCLI, $progress, $isUpgrade);
|
||||
$shouldStartContainers = $startIndex <= 2;
|
||||
if ($shouldStartContainers) {
|
||||
$currentStep = InstallerServer::STEP_DOCKER_CONTAINERS;
|
||||
$this->updateProgress($progress, InstallerServer::STEP_DOCKER_CONTAINERS, InstallerServer::STATUS_IN_PROGRESS, $messages);
|
||||
$this->runDockerCompose($input, $isLocalInstall, $useExistingConfig, $isCLI, $progress, $isUpgrade);
|
||||
|
||||
if (!$isUpgrade) {
|
||||
$this->updateProgress($progress, InstallerServer::STEP_DOCKER_CONTAINERS, InstallerServer::STATUS_COMPLETED, $messages);
|
||||
$this->updateProgress($progress, InstallerServer::STEP_ACCOUNT_SETUP, InstallerServer::STATUS_IN_PROGRESS, messageOverride: 'Creating Appwrite account...');
|
||||
if (!$isUpgrade) {
|
||||
$this->updateProgress($progress, InstallerServer::STEP_DOCKER_CONTAINERS, InstallerServer::STATUS_COMPLETED, $messages);
|
||||
$this->updateProgress($progress, InstallerServer::STEP_ACCOUNT_SETUP, InstallerServer::STATUS_IN_PROGRESS, messageOverride: 'Creating Appwrite account...');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isLocalInstall) {
|
||||
if (!$isLocalInstall || file_exists('/.dockerenv') || file_exists('/run/.containerenv')) {
|
||||
$this->connectInstallerToAppwriteNetwork();
|
||||
}
|
||||
|
||||
$domain = $input['_APP_DOMAIN'] ?? 'localhost';
|
||||
|
||||
$healthStep = $isUpgrade ? InstallerServer::STEP_DOCKER_CONTAINERS : InstallerServer::STEP_ACCOUNT_SETUP;
|
||||
if ($isUpgrade && $startIndex >= 4) {
|
||||
$healthStep = InstallerServer::STEP_MIGRATION;
|
||||
}
|
||||
if (!$isUpgrade) {
|
||||
$currentStep = InstallerServer::STEP_ACCOUNT_SETUP;
|
||||
}
|
||||
$apiUrl = $this->waitForApiReady($domain, $httpPort, $isLocalInstall, $progress, $healthStep);
|
||||
|
||||
if ($isUpgrade) {
|
||||
if ($isUpgrade && $shouldStartContainers) {
|
||||
$this->updateProgress($progress, InstallerServer::STEP_DOCKER_CONTAINERS, InstallerServer::STATUS_COMPLETED, $messages);
|
||||
}
|
||||
|
||||
if (!$isUpgrade) {
|
||||
if (!$isUpgrade && $startIndex <= 3) {
|
||||
$this->createInitialAdminAccount($account, $progress, $apiUrl, $domain);
|
||||
}
|
||||
|
||||
@@ -762,13 +788,30 @@ class Install extends Action
|
||||
// Allow the SSE chunk to flush before the blocking exec
|
||||
usleep(100_000);
|
||||
|
||||
// Static command — no user input involved
|
||||
$command = $isLocalInstall
|
||||
? 'docker compose exec appwrite migrate 2>&1'
|
||||
: 'docker exec appwrite migrate 2>&1';
|
||||
if ($isLocalInstall) {
|
||||
$composePath = $this->hostPath !== '' ? $this->hostPath : $this->path;
|
||||
$command = [
|
||||
'docker',
|
||||
'compose',
|
||||
'--env-file',
|
||||
$composePath . '/' . $this->getEnvFileName(),
|
||||
'-f',
|
||||
$composePath . '/' . $this->getComposeFileName(),
|
||||
'--project-name',
|
||||
'appwrite',
|
||||
'--project-directory',
|
||||
$composePath,
|
||||
'exec',
|
||||
'appwrite',
|
||||
'migrate',
|
||||
];
|
||||
} else {
|
||||
$command = ['docker', 'exec', 'appwrite', 'migrate'];
|
||||
}
|
||||
$commandLine = implode(' ', array_map(escapeshellarg(...), $command));
|
||||
|
||||
$output = [];
|
||||
\exec($command, $output, $exit);
|
||||
\exec($commandLine . ' 2>&1', $output, $exit);
|
||||
|
||||
if ($exit !== 0) {
|
||||
$message = trim(implode("\n", $output));
|
||||
@@ -856,9 +899,9 @@ class Install extends Action
|
||||
* the runtime context and returns whichever responds first.
|
||||
*
|
||||
* Candidates (in order of preference):
|
||||
* - Docker internal DNS (http://appwrite) — only if on the appwrite network
|
||||
* - host.docker.internal:{port} — reaches host-published ports from inside a container
|
||||
* - Docker internal DNS (http://appwrite) — preferred when on the appwrite network
|
||||
* - localhost:{port} — works when running directly on the host (local dev)
|
||||
* - host.docker.internal:{port} — non-local fallback for host-published ports
|
||||
*/
|
||||
private function waitForApiReady(string $domain, string $httpPort, bool $isLocalInstall, ?callable $progress, string $step = InstallerServer::STEP_ACCOUNT_SETUP): string
|
||||
{
|
||||
@@ -872,6 +915,7 @@ class Install extends Action
|
||||
|
||||
if ($isLocalInstall) {
|
||||
$candidates = [
|
||||
self::APPWRITE_API_URL . $healthPath,
|
||||
'http://localhost:' . $httpPort . $healthPath,
|
||||
];
|
||||
} else {
|
||||
@@ -1081,12 +1125,18 @@ class Install extends Action
|
||||
Console::log("Running \"docker compose up -d --remove-orphans --renew-anon-volumes\"");
|
||||
}
|
||||
|
||||
$composeFileName = $this->getComposeFileName();
|
||||
$composeFile = $this->path . '/' . $composeFileName;
|
||||
$composePath = $this->path;
|
||||
if ($isLocalInstall && $this->hostPath !== '') {
|
||||
$composePath = $this->hostPath;
|
||||
}
|
||||
$composeFile = $composePath . '/' . $this->getComposeFileName();
|
||||
$envFile = $composePath . '/' . $this->getEnvFileName();
|
||||
|
||||
$command = [
|
||||
'docker',
|
||||
'compose',
|
||||
'--env-file',
|
||||
$envFile,
|
||||
'-f',
|
||||
$composeFile,
|
||||
];
|
||||
@@ -1097,7 +1147,7 @@ class Install extends Action
|
||||
}
|
||||
|
||||
$command[] = '--project-directory';
|
||||
$command[] = $this->path;
|
||||
$command[] = $composePath;
|
||||
$command[] = 'up';
|
||||
$command[] = '-d';
|
||||
$command[] = '--remove-orphans';
|
||||
|
||||
@@ -180,20 +180,29 @@ class Specs extends Action
|
||||
'ImpersonateUserId' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Id',
|
||||
'description' => 'Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'description' => 'Impersonate a user by ID',
|
||||
'in' => 'header',
|
||||
'x-appwrite' => [
|
||||
'optional' => true,
|
||||
],
|
||||
],
|
||||
'ImpersonateUserEmail' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Email',
|
||||
'description' => 'Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'description' => 'Impersonate a user by email',
|
||||
'in' => 'header',
|
||||
'x-appwrite' => [
|
||||
'optional' => true,
|
||||
],
|
||||
],
|
||||
'ImpersonateUserPhone' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Phone',
|
||||
'description' => 'Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'description' => 'Impersonate a user by phone',
|
||||
'in' => 'header',
|
||||
'x-appwrite' => [
|
||||
'optional' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
APP_SDK_PLATFORM_SERVER => [
|
||||
@@ -258,20 +267,29 @@ class Specs extends Action
|
||||
'ImpersonateUserId' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Id',
|
||||
'description' => 'Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'description' => 'Impersonate a user by ID',
|
||||
'in' => 'header',
|
||||
'x-appwrite' => [
|
||||
'optional' => true,
|
||||
],
|
||||
],
|
||||
'ImpersonateUserEmail' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Email',
|
||||
'description' => 'Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'description' => 'Impersonate a user by email',
|
||||
'in' => 'header',
|
||||
'x-appwrite' => [
|
||||
'optional' => true,
|
||||
],
|
||||
],
|
||||
'ImpersonateUserPhone' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Phone',
|
||||
'description' => 'Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'description' => 'Impersonate a user by phone',
|
||||
'in' => 'header',
|
||||
'x-appwrite' => [
|
||||
'optional' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
APP_SDK_PLATFORM_CONSOLE => [
|
||||
@@ -336,20 +354,29 @@ class Specs extends Action
|
||||
'ImpersonateUserId' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Id',
|
||||
'description' => 'Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'description' => 'Impersonate a user by ID',
|
||||
'in' => 'header',
|
||||
'x-appwrite' => [
|
||||
'optional' => true,
|
||||
],
|
||||
],
|
||||
'ImpersonateUserEmail' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Email',
|
||||
'description' => 'Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'description' => 'Impersonate a user by email',
|
||||
'in' => 'header',
|
||||
'x-appwrite' => [
|
||||
'optional' => true,
|
||||
],
|
||||
],
|
||||
'ImpersonateUserPhone' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Phone',
|
||||
'description' => 'Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'description' => 'Impersonate a user by phone',
|
||||
'in' => 'header',
|
||||
'x-appwrite' => [
|
||||
'optional' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -5,11 +5,11 @@ namespace Appwrite\Platform\Workers;
|
||||
use Appwrite\Event\Message\Audit;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use Utopia\Console;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Exception\Structure;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Queue\Message;
|
||||
use Utopia\Span\Span;
|
||||
use Utopia\System\System;
|
||||
|
||||
class Audits extends Action
|
||||
@@ -63,8 +63,6 @@ class Audits extends Action
|
||||
|
||||
$auditMessage = Audit::fromArray($payload);
|
||||
|
||||
Console::info('Aggregating audit logs');
|
||||
|
||||
$event = $auditMessage->event;
|
||||
|
||||
$auditPayload = '';
|
||||
@@ -123,10 +121,11 @@ class Audits extends Action
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($this->logs[$auditMessage->project->getSequence()])) {
|
||||
$this->logs[$auditMessage->project->getSequence()]['logs'][] = $eventData;
|
||||
$projectSequence = (string) $auditMessage->project->getSequence();
|
||||
if (isset($this->logs[$projectSequence])) {
|
||||
$this->logs[$projectSequence]['logs'][] = $eventData;
|
||||
} else {
|
||||
$this->logs[$auditMessage->project->getSequence()] = [
|
||||
$this->logs[$projectSequence] = [
|
||||
'project' => new Document([
|
||||
'$id' => $auditMessage->project->getId(),
|
||||
'$sequence' => $auditMessage->project->getSequence(),
|
||||
@@ -148,22 +147,25 @@ class Audits extends Action
|
||||
return;
|
||||
}
|
||||
|
||||
$projects = 0;
|
||||
$events = 0;
|
||||
foreach ($this->logs as $sequence => $projectLogs) {
|
||||
try {
|
||||
Console::log('Processing Project "' . $sequence . '" batch with ' . count($projectLogs['logs']) . ' events');
|
||||
|
||||
$projectDocument = $projectLogs['project'];
|
||||
$audit = $getAudit($projectDocument);
|
||||
$audit = $getAudit($projectLogs['project']);
|
||||
$audit->logBatch($projectLogs['logs']);
|
||||
|
||||
Console::success('Audit logs processed successfully');
|
||||
$projects++;
|
||||
$events += count($projectLogs['logs']);
|
||||
} catch (Throwable $e) {
|
||||
Console::error('Error processing audit logs for Project "' . $sequence . '": ' . $e->getMessage());
|
||||
Span::add('audits.error', $e->getMessage());
|
||||
} finally {
|
||||
unset($this->logs[$sequence]);
|
||||
}
|
||||
}
|
||||
|
||||
Span::add('audits.projects', $projects);
|
||||
Span::add('audits.count', $events);
|
||||
|
||||
$this->lastTriggeredTime = time();
|
||||
}
|
||||
}
|
||||
@@ -572,6 +572,7 @@ class Certificates extends Action
|
||||
recipient: System::getEnv('_APP_EMAIL_CERTIFICATES', System::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS')),
|
||||
name: 'Appwrite Administrator',
|
||||
subject: $subject,
|
||||
template: MAIL_TEMPLATE_CERTIFICATE_FAILED,
|
||||
bodyTemplate: __DIR__ . '/../../../../app/config/locale/templates/email-base-styled.tpl',
|
||||
body: $body,
|
||||
preview: $preview,
|
||||
|
||||
@@ -1106,7 +1106,7 @@ class Deletes extends Action
|
||||
// fast path, no need to list anything!
|
||||
$delete($dbForProject, $resourceInternalId, $resourceType);
|
||||
} else {
|
||||
$processResource = function (string $type) use ($dbForProject, $delete) {
|
||||
foreach ([RESOURCE_TYPE_SITES, RESOURCE_TYPE_FUNCTIONS] as $type) {
|
||||
$this->listByGroup(
|
||||
collection: $type,
|
||||
queries: [Query::select(['$id', '$sequence'])],
|
||||
@@ -1115,13 +1115,7 @@ class Deletes extends Action
|
||||
$delete($dbForProject, $resource->getSequence(), $type);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/* perform processing in parallel */
|
||||
batch([
|
||||
fn () => $processResource(RESOURCE_TYPE_SITES),
|
||||
fn () => $processResource(RESOURCE_TYPE_FUNCTIONS),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Appwrite\Platform\Workers;
|
||||
|
||||
use Appwrite\Event\Message\Execution;
|
||||
use Appwrite\Event\Message\Executions as ExecutionsMessage;
|
||||
use Exception;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Platform\Action;
|
||||
@@ -11,6 +12,8 @@ use Utopia\Span\Span;
|
||||
|
||||
class Executions extends Action
|
||||
{
|
||||
private const int UPSERT_BATCH_SIZE = 100;
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'executions';
|
||||
@@ -33,19 +36,36 @@ class Executions extends Action
|
||||
Message $message,
|
||||
Database $dbForProject,
|
||||
): void {
|
||||
$executionMessage = Execution::fromArray($message->getPayload());
|
||||
$execution = $executionMessage->execution;
|
||||
$payload = $message->getPayload();
|
||||
$isBatch = isset($payload['executions']) && \is_array($payload['executions']);
|
||||
|
||||
if ($execution->isEmpty()) {
|
||||
throw new Exception('Missing execution');
|
||||
if ($isBatch) {
|
||||
$executionMessage = ExecutionsMessage::fromArray($payload);
|
||||
$executions = \array_values(\array_filter(
|
||||
$executionMessage->executions,
|
||||
fn ($execution) => !$execution->isEmpty()
|
||||
));
|
||||
} else {
|
||||
$executionMessage = Execution::fromArray($payload);
|
||||
$executions = [$executionMessage->execution];
|
||||
}
|
||||
|
||||
if (empty($executions)) {
|
||||
throw new Exception($isBatch ? 'Missing executions' : 'Missing execution');
|
||||
}
|
||||
|
||||
Span::add('project.id', $executionMessage->project->getId());
|
||||
Span::add('function.id', $execution->getAttribute('resourceId', ''));
|
||||
Span::add('execution.id', $execution->getId());
|
||||
Span::add('deployment.id', $execution->getAttribute('deploymentId', ''));
|
||||
Span::add('resource.type', $execution->getAttribute('resourceType', ''));
|
||||
|
||||
$dbForProject->upsertDocument('executions', $execution);
|
||||
if ($isBatch) {
|
||||
Span::add('executions.count', \count($executions));
|
||||
$dbForProject->upsertDocuments('executions', $executions, self::UPSERT_BATCH_SIZE);
|
||||
} else {
|
||||
$execution = $executions[0];
|
||||
Span::add('function.id', $execution->getAttribute('resourceId', ''));
|
||||
Span::add('execution.id', $execution->getId());
|
||||
Span::add('deployment.id', $execution->getAttribute('deploymentId', ''));
|
||||
Span::add('resource.type', $execution->getAttribute('resourceType', ''));
|
||||
$dbForProject->upsertDocument('executions', $execution);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,9 @@ use Utopia\Messaging\Messages\Email\Attachment;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Queue\Message;
|
||||
use Utopia\Registry\Registry;
|
||||
use Utopia\Span\Span;
|
||||
use Utopia\System\System;
|
||||
use Utopia\Telemetry\Adapter as Telemetry;
|
||||
|
||||
class Mails extends Action
|
||||
{
|
||||
@@ -39,6 +41,7 @@ class Mails extends Action
|
||||
->inject('project')
|
||||
->inject('register')
|
||||
->inject('log')
|
||||
->inject('telemetry')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
|
||||
@@ -55,10 +58,11 @@ class Mails extends Action
|
||||
* @param Document $project
|
||||
* @param Registry $register
|
||||
* @param Log $log
|
||||
* @param Telemetry $telemetry
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function action(Message $message, Document $project, Registry $register, Log $log): void
|
||||
public function action(Message $message, Document $project, Registry $register, Log $log, Telemetry $telemetry): void
|
||||
{
|
||||
Runtime::setHookFlags(SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_TCP);
|
||||
$payload = $message->getPayload();
|
||||
@@ -81,6 +85,12 @@ class Mails extends Action
|
||||
|
||||
$recipient = $payload['recipient'];
|
||||
$subject = $payload['subject'];
|
||||
$template = $payload['template'] ?? 'unknown';
|
||||
$recipientDomain = \strtolower(\substr(\strrchr($recipient, '@') ?: '', 1));
|
||||
|
||||
Span::add('mail.template', $template);
|
||||
Span::add('mail.smtp_type', $type);
|
||||
Span::add('mail.recipient_domain', $recipientDomain);
|
||||
$variables = $payload['variables'];
|
||||
$variables['host'] = $protocol . '://' . $hostname;
|
||||
$name = $payload['name'];
|
||||
@@ -150,6 +160,7 @@ class Mails extends Action
|
||||
keepAlive: true,
|
||||
timelimit: 30,
|
||||
);
|
||||
$adapter->setTelemetry($telemetry);
|
||||
|
||||
// Resolve from/replyTo using fallback hierarchy: Custom options > SMTP config > Defaults
|
||||
$defaultFromEmail = System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM);
|
||||
@@ -202,14 +213,19 @@ class Mails extends Action
|
||||
attachments: $attachments,
|
||||
html: true,
|
||||
);
|
||||
$emailMessage->setOrigin(MESSAGE_SEND_TYPE_INTERNAL);
|
||||
|
||||
try {
|
||||
$adapter->send($emailMessage);
|
||||
} catch (\Throwable $error) {
|
||||
Span::add('mail.status', 'failure');
|
||||
|
||||
if ($type === 'smtp') {
|
||||
throw new Exception('Error sending mail: ' . $error->getMessage(), 401);
|
||||
}
|
||||
throw new Exception('Error sending mail: ' . $error->getMessage(), 500);
|
||||
}
|
||||
|
||||
Span::add('mail.status', 'success');
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@ use Utopia\Storage\Device;
|
||||
use Utopia\Storage\Device\Local;
|
||||
use Utopia\Storage\Storage;
|
||||
use Utopia\System\System;
|
||||
use Utopia\Telemetry\Adapter as Telemetry;
|
||||
|
||||
use function Swoole\Coroutine\batch;
|
||||
|
||||
@@ -56,6 +57,8 @@ class Messaging extends Action
|
||||
{
|
||||
private ?SMSAdapter $adapter = null;
|
||||
|
||||
private Telemetry $telemetry;
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'messaging';
|
||||
@@ -74,6 +77,7 @@ class Messaging extends Action
|
||||
->inject('dbForProject')
|
||||
->inject('deviceForFiles')
|
||||
->inject('publisherForUsage')
|
||||
->inject('telemetry')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
|
||||
@@ -84,6 +88,7 @@ class Messaging extends Action
|
||||
* @param Database $dbForProject
|
||||
* @param Device $deviceForFiles
|
||||
* @param UsagePublisher $publisherForUsage
|
||||
* @param Telemetry $telemetry
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
@@ -93,9 +98,12 @@ class Messaging extends Action
|
||||
Log $log,
|
||||
Database $dbForProject,
|
||||
Device $deviceForFiles,
|
||||
UsagePublisher $publisherForUsage
|
||||
UsagePublisher $publisherForUsage,
|
||||
Telemetry $telemetry
|
||||
): void {
|
||||
Runtime::setHookFlags(SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_TCP);
|
||||
|
||||
$this->telemetry = $telemetry;
|
||||
$payload = $message->getPayload();
|
||||
|
||||
if (empty($payload)) {
|
||||
@@ -143,6 +151,8 @@ class Messaging extends Action
|
||||
$userIds = $message->getAttribute('users', []);
|
||||
$providerType = $message->getAttribute('providerType');
|
||||
|
||||
Span::add('message.provider_type', $providerType);
|
||||
|
||||
$default = $dbForProject->findOne('providers', [
|
||||
Query::equal('enabled', [true]),
|
||||
Query::equal('type', [$providerType]),
|
||||
@@ -268,6 +278,11 @@ class Messaging extends Action
|
||||
$message->setAttribute('search', "{$message->getAttribute('search')} {$provider->getAttribute('name')} {$provider->getAttribute('provider')} {$provider->getAttribute('type')}");
|
||||
}
|
||||
|
||||
Span::add('message.providers', \implode(',', \array_unique(\array_map(
|
||||
fn (Document $provider) => $provider->getAttribute('provider'),
|
||||
\array_values($providers)
|
||||
))));
|
||||
|
||||
$message->setAttribute('deliveredTotal', $deliveredTotal);
|
||||
$message->setAttribute('deliveredAt', DateTime::now());
|
||||
|
||||
@@ -533,6 +548,7 @@ class Messaging extends Action
|
||||
] = $this->retrySend($batch, $message, $provider, $providerType, $adapter, $dbForProject, $deviceForFiles, $project);
|
||||
|
||||
$failed = $recipients - $delivered;
|
||||
|
||||
$usage = new UsageContext();
|
||||
$usage
|
||||
->addMetric(METRIC_MESSAGES, $recipients)
|
||||
@@ -758,12 +774,16 @@ class Messaging extends Action
|
||||
$messageData = clone $message;
|
||||
$messageData->setAttribute('to', $to);
|
||||
|
||||
return match ($providerType) {
|
||||
$data = match ($providerType) {
|
||||
MESSAGE_TYPE_SMS => $this->buildSmsMessage($messageData, $provider),
|
||||
MESSAGE_TYPE_PUSH => $this->buildPushMessage($messageData),
|
||||
MESSAGE_TYPE_EMAIL => $this->buildEmailMessage($dbForProject, $messageData, $provider, $deviceForFiles, $project),
|
||||
default => throw new \Exception('Provider with the requested ID is of the incorrect type')
|
||||
};
|
||||
|
||||
$data->setOrigin(MESSAGE_SEND_TYPE_EXTERNAL);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function sendInternalSMSMessage(Document $message, Document $project, array $recipients, Log $log): void
|
||||
@@ -802,6 +822,7 @@ class Messaging extends Action
|
||||
$message->getAttribute('data')['content'],
|
||||
$from
|
||||
);
|
||||
$sms->setOrigin(MESSAGE_SEND_TYPE_INTERNAL);
|
||||
|
||||
$this->adapter->send($sms);
|
||||
}
|
||||
@@ -811,7 +832,7 @@ class Messaging extends Action
|
||||
{
|
||||
$credentials = $provider->getAttribute('credentials');
|
||||
|
||||
return match ($provider->getAttribute('provider')) {
|
||||
$adapter = match ($provider->getAttribute('provider')) {
|
||||
'mock' => (new Mock('username', 'password'))->setEndpoint('http://request-catcher-sms:5000/'),
|
||||
'twilio' => new Twilio(
|
||||
$credentials['accountSid'] ?? '',
|
||||
@@ -848,6 +869,12 @@ class Messaging extends Action
|
||||
),
|
||||
default => null
|
||||
};
|
||||
|
||||
if ($adapter !== null) {
|
||||
$adapter->setTelemetry($this->telemetry);
|
||||
}
|
||||
|
||||
return $adapter;
|
||||
}
|
||||
|
||||
protected function getPushAdapter(Document $provider): ?PushAdapter
|
||||
@@ -855,7 +882,7 @@ class Messaging extends Action
|
||||
$credentials = $provider->getAttribute('credentials');
|
||||
$options = $provider->getAttribute('options');
|
||||
|
||||
return match ($provider->getAttribute('provider')) {
|
||||
$adapter = match ($provider->getAttribute('provider')) {
|
||||
'mock' => new Mock('username', 'password'),
|
||||
'apns' => new APNS(
|
||||
$credentials['authKey'] ?? '',
|
||||
@@ -867,6 +894,12 @@ class Messaging extends Action
|
||||
'fcm' => new FCM(\json_encode($credentials['serviceAccountJSON'])),
|
||||
default => null
|
||||
};
|
||||
|
||||
if ($adapter !== null) {
|
||||
$adapter->setTelemetry($this->telemetry);
|
||||
}
|
||||
|
||||
return $adapter;
|
||||
}
|
||||
|
||||
protected function getEmailAdapter(Document $provider): ?EmailAdapter
|
||||
@@ -875,7 +908,7 @@ class Messaging extends Action
|
||||
$options = $provider->getAttribute('options', []);
|
||||
$apiKey = $credentials['apiKey'] ?? '';
|
||||
|
||||
return match ($provider->getAttribute('provider')) {
|
||||
$adapter = match ($provider->getAttribute('provider')) {
|
||||
'mock' => new Mock('username', 'password'),
|
||||
'smtp' => new SMTP(
|
||||
$credentials['host'] ?? '',
|
||||
@@ -901,6 +934,12 @@ class Messaging extends Action
|
||||
),
|
||||
default => null
|
||||
};
|
||||
|
||||
if ($adapter !== null) {
|
||||
$adapter->setTelemetry($this->telemetry);
|
||||
}
|
||||
|
||||
return $adapter;
|
||||
}
|
||||
|
||||
private function buildEmailMessage(
|
||||
@@ -1117,6 +1156,7 @@ class Messaging extends Action
|
||||
$defaultProvider = $this->createProviderFromDSN($defaultDSN);
|
||||
$adapter = $this->getSmsAdapter($defaultProvider);
|
||||
$geosms = new GEOSMS($adapter);
|
||||
$geosms->setTelemetry($this->telemetry);
|
||||
|
||||
/** @var DSN $localDSN */
|
||||
foreach ($localDSNs as $localDSN) {
|
||||
|
||||
@@ -947,6 +947,7 @@ class Migrations extends Action
|
||||
recipient: $user->getAttribute('email'),
|
||||
name: $user->getAttribute('name', $user->getAttribute('email')),
|
||||
subject: $subject,
|
||||
template: MAIL_TEMPLATE_DATA_EXPORT,
|
||||
bodyTemplate: __DIR__ . '/../../../../app/config/locale/templates/email-base-styled.tpl',
|
||||
body: $emailBody,
|
||||
preview: $preview,
|
||||
|
||||
@@ -272,6 +272,7 @@ class Webhooks extends Action
|
||||
recipient: $user->getAttribute('email'),
|
||||
name: $user->getAttribute('name', ''),
|
||||
subject: $subject,
|
||||
template: MAIL_TEMPLATE_WEBHOOK_FAILED,
|
||||
body: $body->render(),
|
||||
preview: $preview,
|
||||
variables: ['user' => $user->getAttribute('name', '')],
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Tests\E2E\Services\Project;
|
||||
|
||||
use Appwrite\Tests\Async;
|
||||
use Appwrite\Tests\Async\Exceptions\Critical;
|
||||
use CURLFile;
|
||||
use Tests\E2E\Client;
|
||||
use Utopia\Console;
|
||||
@@ -11,7 +10,6 @@ use Utopia\Database\Document;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Validator\Datetime as DatetimeValidator;
|
||||
use Utopia\System\System;
|
||||
|
||||
trait VariablesBase
|
||||
{
|
||||
@@ -738,246 +736,6 @@ trait VariablesBase
|
||||
$this->assertSame('variable_not_found', $delete['body']['type']);
|
||||
}
|
||||
|
||||
// Integration tests
|
||||
|
||||
/**
|
||||
* Test that project variables are available in function build and runtime.
|
||||
*/
|
||||
public function testProjectVariableInFunction(): void
|
||||
{
|
||||
$projectId = $this->getProject()['$id'];
|
||||
$apiKey = $this->getProject()['apiKey'];
|
||||
|
||||
// 1. Create a project variable
|
||||
$variable = $this->createVariable(
|
||||
ID::unique(),
|
||||
'GLOBAL_VARIABLE',
|
||||
'Project Variable Value',
|
||||
false
|
||||
);
|
||||
|
||||
$this->assertSame(201, $variable['headers']['status-code']);
|
||||
$variableId = $variable['body']['$id'];
|
||||
|
||||
// 2. Create a function with build commands that echo the variable
|
||||
$function = $this->client->call(Client::METHOD_POST, '/functions', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
], [
|
||||
'functionId' => ID::unique(),
|
||||
'name' => 'Project Variable Test',
|
||||
'runtime' => 'node-22',
|
||||
'entrypoint' => 'index.js',
|
||||
'execute' => ['any'],
|
||||
'timeout' => 15,
|
||||
'commands' => 'echo $GLOBAL_VARIABLE',
|
||||
]);
|
||||
|
||||
$this->assertSame(201, $function['headers']['status-code']);
|
||||
$functionId = $function['body']['$id'];
|
||||
|
||||
// 3. Deploy the function (basic function reads GLOBAL_VARIABLE from env)
|
||||
$deployment = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/deployments', [
|
||||
'content-type' => 'multipart/form-data',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
], [
|
||||
'code' => $this->packageCode('functions', 'basic'),
|
||||
'activate' => true,
|
||||
]);
|
||||
|
||||
$this->assertSame(202, $deployment['headers']['status-code']);
|
||||
$deploymentId = $deployment['body']['$id'] ?? '';
|
||||
|
||||
// 4. Wait for deployment to be ready and activated
|
||||
$this->assertEventually(function () use ($projectId, $apiKey, $functionId, $deploymentId) {
|
||||
$deployment = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/deployments/' . $deploymentId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
|
||||
$status = $deployment['body']['status'] ?? '';
|
||||
if ($status === 'failed') {
|
||||
throw new Critical('Deployment build failed: ' . ($deployment['body']['buildLogs'] ?? 'no logs'));
|
||||
}
|
||||
|
||||
$this->assertSame('ready', $status, 'Deployment status is not ready');
|
||||
}, 120000, 500);
|
||||
|
||||
$this->assertEventually(function () use ($projectId, $apiKey, $functionId, $deploymentId) {
|
||||
$function = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
$this->assertSame($deploymentId, $function['body']['deploymentId'] ?? '');
|
||||
}, 120000, 500);
|
||||
|
||||
// 5. Verify the project variable was available during build
|
||||
$deployment = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/deployments/' . $deploymentId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
$this->assertSame(200, $deployment['headers']['status-code']);
|
||||
$this->assertStringContainsString('Project Variable Value', $deployment['body']['buildLogs']);
|
||||
|
||||
// 6. Execute the function and verify the project variable is in runtime output
|
||||
$execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
], $this->getHeaders()), [
|
||||
'async' => false,
|
||||
]);
|
||||
|
||||
$this->assertSame(201, $execution['headers']['status-code']);
|
||||
$this->assertSame('completed', $execution['body']['status']);
|
||||
$this->assertSame(200, $execution['body']['responseStatusCode']);
|
||||
$output = json_decode($execution['body']['responseBody'], true);
|
||||
$this->assertSame('Project Variable Value', $output['GLOBAL_VARIABLE']);
|
||||
|
||||
// Cleanup
|
||||
$this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
$this->deleteVariable($variableId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that project variables are available in site build and SSR runtime.
|
||||
*/
|
||||
public function testProjectVariableInSite(): void
|
||||
{
|
||||
$projectId = $this->getProject()['$id'];
|
||||
$apiKey = $this->getProject()['apiKey'];
|
||||
|
||||
// 1. Create a project variable
|
||||
$variable = $this->createVariable(
|
||||
ID::unique(),
|
||||
'name',
|
||||
'ProjectVarTest',
|
||||
);
|
||||
|
||||
$this->assertSame(201, $variable['headers']['status-code']);
|
||||
$variableId = $variable['body']['$id'];
|
||||
|
||||
// 2. Create a site
|
||||
$site = $this->client->call(Client::METHOD_POST, '/sites', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
], [
|
||||
'siteId' => ID::unique(),
|
||||
'name' => 'Project Variable Astro Site',
|
||||
'framework' => 'astro',
|
||||
'adapter' => 'ssr',
|
||||
'buildRuntime' => 'node-22',
|
||||
'outputDirectory' => './dist',
|
||||
'buildCommand' => 'echo $name && npm run build',
|
||||
'installCommand' => 'npm ci',
|
||||
'fallbackFile' => '',
|
||||
]);
|
||||
|
||||
$this->assertSame(201, $site['headers']['status-code']);
|
||||
$siteId = $site['body']['$id'];
|
||||
|
||||
// 3. Setup domain for proxy access
|
||||
$sitesDomain = \explode(',', System::getEnv('_APP_DOMAIN_SITES', ''))[0];
|
||||
$rule = $this->client->call(Client::METHOD_POST, '/proxy/rules/site', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
], $this->getHeaders()), [
|
||||
'domain' => ID::unique() . '.' . $sitesDomain,
|
||||
'siteId' => $siteId,
|
||||
]);
|
||||
|
||||
$this->assertSame(201, $rule['headers']['status-code']);
|
||||
|
||||
// 4. Deploy the site (astro site reads import.meta.env.name)
|
||||
$deployment = $this->client->call(Client::METHOD_POST, '/sites/' . $siteId . '/deployments', [
|
||||
'content-type' => 'multipart/form-data',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
], [
|
||||
'code' => $this->packageCode('sites', 'astro'),
|
||||
'activate' => 'true',
|
||||
]);
|
||||
|
||||
$this->assertSame(202, $deployment['headers']['status-code']);
|
||||
$deploymentId = $deployment['body']['$id'] ?? '';
|
||||
|
||||
// 5. Wait for deployment to be ready and activated
|
||||
$this->assertEventually(function () use ($projectId, $apiKey, $siteId, $deploymentId) {
|
||||
$deployment = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/deployments/' . $deploymentId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
|
||||
$status = $deployment['body']['status'] ?? '';
|
||||
if ($status === 'failed') {
|
||||
throw new Critical('Site deployment failed: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT));
|
||||
}
|
||||
|
||||
$this->assertSame('ready', $status, 'Deployment status is not ready');
|
||||
}, 120000, 500);
|
||||
|
||||
$this->assertEventually(function () use ($projectId, $apiKey, $siteId, $deploymentId) {
|
||||
$site = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
$this->assertSame($deploymentId, $site['body']['deploymentId'] ?? '');
|
||||
}, 120000, 500);
|
||||
|
||||
// 6. Verify the project variable was available during build
|
||||
$deployment = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/deployments/' . $deploymentId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
$this->assertSame(200, $deployment['headers']['status-code']);
|
||||
$this->assertStringContainsString('ProjectVarTest', $deployment['body']['buildLogs']);
|
||||
|
||||
// 7. Get the domain and access the site
|
||||
$rules = $this->client->call(Client::METHOD_GET, '/proxy/rules', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::equal('deploymentResourceId', [$siteId])->toString(),
|
||||
Query::equal('trigger', ['manual'])->toString(),
|
||||
Query::equal('type', ['deployment'])->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertSame(200, $rules['headers']['status-code']);
|
||||
$this->assertGreaterThanOrEqual(1, \count($rules['body']['rules']));
|
||||
$domain = $rules['body']['rules'][0]['domain'];
|
||||
|
||||
$proxyClient = new Client();
|
||||
$proxyClient->setEndpoint('http://' . $domain);
|
||||
|
||||
$response = $proxyClient->call(Client::METHOD_GET, '/');
|
||||
|
||||
$this->assertSame(200, $response['headers']['status-code']);
|
||||
$this->assertStringContainsString('Env variable is ProjectVarTest', $response['body']);
|
||||
$this->assertStringNotContainsString('Variable not found', $response['body']);
|
||||
|
||||
// Cleanup
|
||||
$this->client->call(Client::METHOD_DELETE, '/sites/' . $siteId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
$this->deleteVariable($variableId);
|
||||
}
|
||||
|
||||
// Helpers
|
||||
|
||||
protected function createVariable(string $variableId, ?string $key, ?string $value, ?bool $secret = null, bool $authenticated = true): mixed
|
||||
|
||||
@@ -4,13 +4,256 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\E2E\Services\Project;
|
||||
|
||||
use Appwrite\Tests\Async\Exceptions\Critical;
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideServer;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\System\System;
|
||||
|
||||
final class VariablesCustomServerTest extends Scope
|
||||
{
|
||||
use VariablesBase;
|
||||
use ProjectCustom;
|
||||
use SideServer;
|
||||
|
||||
/**
|
||||
* Test that project variables are available in function build and runtime.
|
||||
*/
|
||||
public function testProjectVariableInFunction(): void
|
||||
{
|
||||
$projectId = $this->getProject()['$id'];
|
||||
$apiKey = $this->getProject()['apiKey'];
|
||||
|
||||
// 1. Create a project variable
|
||||
$variable = $this->createVariable(
|
||||
ID::unique(),
|
||||
'GLOBAL_VARIABLE',
|
||||
'Project Variable Value',
|
||||
false
|
||||
);
|
||||
|
||||
$this->assertSame(201, $variable['headers']['status-code']);
|
||||
$variableId = $variable['body']['$id'];
|
||||
|
||||
// 2. Create a function with build commands that echo the variable
|
||||
$function = $this->client->call(Client::METHOD_POST, '/functions', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
], [
|
||||
'functionId' => ID::unique(),
|
||||
'name' => 'Project Variable Test',
|
||||
'runtime' => 'node-22',
|
||||
'entrypoint' => 'index.js',
|
||||
'execute' => ['any'],
|
||||
'timeout' => 15,
|
||||
'commands' => 'echo $GLOBAL_VARIABLE',
|
||||
]);
|
||||
|
||||
$this->assertSame(201, $function['headers']['status-code']);
|
||||
$functionId = $function['body']['$id'];
|
||||
|
||||
// 3. Deploy the function (basic function reads GLOBAL_VARIABLE from env)
|
||||
$deployment = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/deployments', [
|
||||
'content-type' => 'multipart/form-data',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
], [
|
||||
'code' => $this->packageCode('functions', 'basic'),
|
||||
'activate' => true,
|
||||
]);
|
||||
|
||||
$this->assertSame(202, $deployment['headers']['status-code']);
|
||||
$deploymentId = $deployment['body']['$id'] ?? '';
|
||||
|
||||
// 4. Wait for deployment to be ready and activated
|
||||
$this->assertEventually(function () use ($projectId, $apiKey, $functionId, $deploymentId) {
|
||||
$deployment = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/deployments/' . $deploymentId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
|
||||
$status = $deployment['body']['status'] ?? '';
|
||||
if ($status === 'failed') {
|
||||
throw new Critical('Deployment build failed: ' . ($deployment['body']['buildLogs'] ?? 'no logs'));
|
||||
}
|
||||
|
||||
$this->assertSame('ready', $status, 'Deployment status is not ready');
|
||||
}, 120000, 500);
|
||||
|
||||
$this->assertEventually(function () use ($projectId, $apiKey, $functionId, $deploymentId) {
|
||||
$function = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
$this->assertSame($deploymentId, $function['body']['deploymentId'] ?? '');
|
||||
}, 120000, 500);
|
||||
|
||||
// 5. Verify the project variable was available during build
|
||||
$deployment = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/deployments/' . $deploymentId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
$this->assertSame(200, $deployment['headers']['status-code']);
|
||||
$this->assertStringContainsString('Project Variable Value', (string) $deployment['body']['buildLogs']);
|
||||
|
||||
// 6. Execute the function and verify the project variable is in runtime output
|
||||
$execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
], $this->getHeaders()), [
|
||||
'async' => false,
|
||||
]);
|
||||
|
||||
$this->assertSame(201, $execution['headers']['status-code']);
|
||||
$this->assertSame('completed', $execution['body']['status']);
|
||||
$this->assertSame(200, $execution['body']['responseStatusCode']);
|
||||
$output = json_decode($execution['body']['responseBody'], true);
|
||||
$this->assertSame('Project Variable Value', $output['GLOBAL_VARIABLE']);
|
||||
|
||||
// Cleanup
|
||||
$this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
$this->deleteVariable($variableId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that project variables are available in site build and SSR runtime.
|
||||
*/
|
||||
public function testProjectVariableInSite(): void
|
||||
{
|
||||
$projectId = $this->getProject()['$id'];
|
||||
$apiKey = $this->getProject()['apiKey'];
|
||||
|
||||
// 1. Create a project variable
|
||||
$variable = $this->createVariable(
|
||||
ID::unique(),
|
||||
'name',
|
||||
'ProjectVarTest',
|
||||
);
|
||||
|
||||
$this->assertSame(201, $variable['headers']['status-code']);
|
||||
$variableId = $variable['body']['$id'];
|
||||
|
||||
// 2. Create a site
|
||||
$site = $this->client->call(Client::METHOD_POST, '/sites', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
], [
|
||||
'siteId' => ID::unique(),
|
||||
'name' => 'Project Variable Astro Site',
|
||||
'framework' => 'astro',
|
||||
'adapter' => 'ssr',
|
||||
'buildRuntime' => 'node-22',
|
||||
'outputDirectory' => './dist',
|
||||
'buildCommand' => 'echo $name && npm run build',
|
||||
'installCommand' => 'npm ci',
|
||||
'fallbackFile' => '',
|
||||
]);
|
||||
|
||||
$this->assertSame(201, $site['headers']['status-code']);
|
||||
$siteId = $site['body']['$id'];
|
||||
|
||||
// 3. Setup domain for proxy access
|
||||
$sitesDomain = \explode(',', System::getEnv('_APP_DOMAIN_SITES', ''))[0];
|
||||
$rule = $this->client->call(Client::METHOD_POST, '/proxy/rules/site', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
], $this->getHeaders()), [
|
||||
'domain' => ID::unique() . '.' . $sitesDomain,
|
||||
'siteId' => $siteId,
|
||||
]);
|
||||
|
||||
$this->assertSame(201, $rule['headers']['status-code']);
|
||||
|
||||
// 4. Deploy the site (astro site reads import.meta.env.name)
|
||||
$deployment = $this->client->call(Client::METHOD_POST, '/sites/' . $siteId . '/deployments', [
|
||||
'content-type' => 'multipart/form-data',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
], [
|
||||
'code' => $this->packageCode('sites', 'astro'),
|
||||
'activate' => 'true',
|
||||
]);
|
||||
|
||||
$this->assertSame(202, $deployment['headers']['status-code']);
|
||||
$deploymentId = $deployment['body']['$id'] ?? '';
|
||||
|
||||
// 5. Wait for deployment to be ready and activated
|
||||
$this->assertEventually(function () use ($projectId, $apiKey, $siteId, $deploymentId) {
|
||||
$deployment = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/deployments/' . $deploymentId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
|
||||
$status = $deployment['body']['status'] ?? '';
|
||||
if ($status === 'failed') {
|
||||
throw new Critical('Site deployment failed: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT));
|
||||
}
|
||||
|
||||
$this->assertSame('ready', $status, 'Deployment status is not ready');
|
||||
}, 120000, 500);
|
||||
|
||||
$this->assertEventually(function () use ($projectId, $apiKey, $siteId, $deploymentId) {
|
||||
$site = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
$this->assertSame($deploymentId, $site['body']['deploymentId'] ?? '');
|
||||
}, 120000, 500);
|
||||
|
||||
// 6. Verify the project variable was available during build
|
||||
$deployment = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/deployments/' . $deploymentId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
$this->assertSame(200, $deployment['headers']['status-code']);
|
||||
$this->assertStringContainsString('ProjectVarTest', (string) $deployment['body']['buildLogs']);
|
||||
|
||||
// 7. Get the domain and access the site
|
||||
$rules = $this->client->call(Client::METHOD_GET, '/proxy/rules', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::equal('deploymentResourceId', [$siteId])->toString(),
|
||||
Query::equal('trigger', ['manual'])->toString(),
|
||||
Query::equal('type', ['deployment'])->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertSame(200, $rules['headers']['status-code']);
|
||||
$this->assertGreaterThanOrEqual(1, \count($rules['body']['rules']));
|
||||
$domain = $rules['body']['rules'][0]['domain'];
|
||||
|
||||
$proxyClient = new Client();
|
||||
$proxyClient->setEndpoint('http://' . $domain);
|
||||
|
||||
$response = $proxyClient->call(Client::METHOD_GET, '/');
|
||||
|
||||
$this->assertSame(200, $response['headers']['status-code']);
|
||||
$this->assertStringContainsString('Env variable is ProjectVarTest', (string) $response['body']);
|
||||
$this->assertStringNotContainsString('Variable not found', (string) $response['body']);
|
||||
|
||||
// Cleanup
|
||||
$this->client->call(Client::METHOD_DELETE, '/sites/' . $siteId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apiKey,
|
||||
]);
|
||||
$this->deleteVariable($variableId);
|
||||
}
|
||||
}
|
||||
@@ -715,6 +715,112 @@ final class VCSConsoleClientTest extends Scope
|
||||
], $this->getHeaders()));
|
||||
}
|
||||
|
||||
public function testCrossProjectInstallationRejected(): void
|
||||
{
|
||||
$installationId = $this->setupInstallation();
|
||||
$consoleHeaders = [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
|
||||
'x-appwrite-project' => 'console',
|
||||
];
|
||||
|
||||
$team = $this->client->call(Client::METHOD_POST, '/teams', $consoleHeaders, [
|
||||
'teamId' => ID::unique(),
|
||||
'name' => 'Cross Project Team',
|
||||
]);
|
||||
$this->assertEquals(201, $team['headers']['status-code']);
|
||||
|
||||
$project2 = $this->client->call(Client::METHOD_POST, '/projects', $consoleHeaders, [
|
||||
'projectId' => ID::unique(),
|
||||
'name' => 'Cross Project Test',
|
||||
'teamId' => $team['body']['$id'],
|
||||
'region' => System::getEnv('_APP_REGION', 'default'),
|
||||
]);
|
||||
$this->assertEquals(201, $project2['headers']['status-code']);
|
||||
$project2Id = $project2['body']['$id'];
|
||||
|
||||
$key = $this->client->call(Client::METHOD_POST, '/projects/' . $project2Id . '/keys', $consoleHeaders, [
|
||||
'keyId' => ID::unique(),
|
||||
'name' => 'Test Key',
|
||||
'scopes' => ['functions.write', 'sites.write'],
|
||||
]);
|
||||
$this->assertEquals(201, $key['headers']['status-code']);
|
||||
|
||||
$headers2 = [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $project2Id,
|
||||
'x-appwrite-key' => $key['body']['secret'],
|
||||
];
|
||||
|
||||
try {
|
||||
// createFunction with installation from project 1 → should fail
|
||||
$function = $this->client->call(Client::METHOD_POST, '/functions', $headers2, [
|
||||
'functionId' => ID::unique(),
|
||||
'name' => 'Test Cross',
|
||||
'runtime' => 'php-8.0',
|
||||
'entrypoint' => 'index.php',
|
||||
'installationId' => $installationId,
|
||||
'providerRepositoryId' => $this->providerRepositoryId,
|
||||
'providerBranch' => 'main',
|
||||
]);
|
||||
$this->assertEquals(404, $function['headers']['status-code']);
|
||||
|
||||
// createSite with installation from project 1 → should fail
|
||||
$site = $this->client->call(Client::METHOD_POST, '/sites', $headers2, [
|
||||
'siteId' => ID::unique(),
|
||||
'name' => 'Test Cross Site',
|
||||
'framework' => 'other',
|
||||
'buildRuntime' => 'node-22',
|
||||
'installationId' => $installationId,
|
||||
'providerRepositoryId' => $this->providerRepositoryId3,
|
||||
'providerBranch' => 'main',
|
||||
]);
|
||||
$this->assertEquals(404, $site['headers']['status-code']);
|
||||
|
||||
// updateFunction with cross-project installation → should fail
|
||||
$fn = $this->client->call(Client::METHOD_POST, '/functions', $headers2, [
|
||||
'functionId' => ID::unique(),
|
||||
'name' => 'Test No VCS',
|
||||
'runtime' => 'php-8.0',
|
||||
'entrypoint' => 'index.php',
|
||||
]);
|
||||
$this->assertEquals(201, $fn['headers']['status-code']);
|
||||
|
||||
$updated = $this->client->call(Client::METHOD_PUT, '/functions/' . $fn['body']['$id'], $headers2, [
|
||||
'name' => 'Test No VCS',
|
||||
'runtime' => 'php-8.0',
|
||||
'entrypoint' => 'index.php',
|
||||
'installationId' => $installationId,
|
||||
'providerRepositoryId' => $this->providerRepositoryId,
|
||||
'providerBranch' => 'main',
|
||||
]);
|
||||
$this->assertEquals(404, $updated['headers']['status-code']);
|
||||
|
||||
// updateSite with cross-project installation → should fail
|
||||
$siteNoVcs = $this->client->call(Client::METHOD_POST, '/sites', $headers2, [
|
||||
'siteId' => ID::unique(),
|
||||
'name' => 'Test No VCS Site',
|
||||
'framework' => 'other',
|
||||
'buildRuntime' => 'node-22',
|
||||
]);
|
||||
$this->assertEquals(201, $siteNoVcs['headers']['status-code']);
|
||||
|
||||
$updatedSite = $this->client->call(Client::METHOD_PUT, '/sites/' . $siteNoVcs['body']['$id'], $headers2, [
|
||||
'name' => 'Test No VCS Site',
|
||||
'framework' => 'other',
|
||||
'buildRuntime' => 'node-22',
|
||||
'installationId' => $installationId,
|
||||
'providerRepositoryId' => $this->providerRepositoryId3,
|
||||
'providerBranch' => 'main',
|
||||
]);
|
||||
$this->assertEquals(404, $updatedSite['headers']['status-code']);
|
||||
} finally {
|
||||
$this->client->call(Client::METHOD_DELETE, '/projects/' . $project2Id, $consoleHeaders);
|
||||
$this->client->call(Client::METHOD_DELETE, '/teams/' . $team['body']['$id'], $consoleHeaders);
|
||||
}
|
||||
}
|
||||
|
||||
public function testCreateRepository(): void
|
||||
{
|
||||
$installationId = $this->setupInstallation();
|
||||
|
||||
@@ -15,16 +15,22 @@ class TestFinishedSubscriber implements FinishedSubscriber
|
||||
public function notify(Finished $event): void
|
||||
{
|
||||
$test = $event->test()->name();
|
||||
$time = $event->telemetryInfo()->durationSinceStart()->seconds();
|
||||
$testId = $event->test()->id();
|
||||
|
||||
$elapsed = $event->telemetryInfo()->durationSinceStart()->asFloat();
|
||||
$start = TestPreparationStartedSubscriber::$startSeconds[$testId] ?? null;
|
||||
$time = $start === null ? $elapsed : $elapsed - $start;
|
||||
|
||||
unset(TestPreparationStartedSubscriber::$startSeconds[$testId]);
|
||||
|
||||
printf(
|
||||
"%s ended in %s milliseconds\n",
|
||||
"%s ended in %d milliseconds\n",
|
||||
$test,
|
||||
$time * 1000
|
||||
(int) round($time * 1000)
|
||||
);
|
||||
|
||||
if ($time > $this->maxSecondsAllowed) {
|
||||
fwrite(STDOUT, sprintf("\e[31mThe %s test is slow, it took %s seconds!\n\e[0m", $test, $time));
|
||||
fwrite(STDOUT, sprintf("\e[31mThe %s test is slow, it took %.2f seconds!\n\e[0m", $test, $time));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ class TestHook implements Extension
|
||||
|
||||
public function bootstrap(Configuration $configuration, Facade $facade, ParameterCollection $parameters): void
|
||||
{
|
||||
$facade->registerSubscriber(new TestPreparationStartedSubscriber());
|
||||
$facade->registerSubscriber(new TestFinishedSubscriber(self::MAX_SECONDS_ALLOWED));
|
||||
$facade->registerSubscriber(new RetrySubscriber());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\Tests;
|
||||
|
||||
use PHPUnit\Event\Test\PreparationStarted;
|
||||
use PHPUnit\Event\Test\PreparationStartedSubscriber;
|
||||
|
||||
class TestPreparationStartedSubscriber implements PreparationStartedSubscriber
|
||||
{
|
||||
/**
|
||||
* Elapsed-since-run-start, in seconds, captured when each test begins
|
||||
* preparation. Keyed by the test id so TestFinishedSubscriber can compute
|
||||
* the true per-test duration as (finish elapsed - start elapsed).
|
||||
*
|
||||
* Stamped on PreparationStarted (before setUp/fixtures run) rather than
|
||||
* Prepared, so expensive setup work is included in the reported duration.
|
||||
*
|
||||
* @var array<string, float>
|
||||
*/
|
||||
public static array $startSeconds = [];
|
||||
|
||||
public function notify(PreparationStarted $event): void
|
||||
{
|
||||
self::$startSeconds[$event->test()->id()] = $event->telemetryInfo()->durationSinceStart()->asFloat();
|
||||
}
|
||||
}
|
||||
@@ -558,6 +558,7 @@ class ScriptedEmailAdapter extends EmailAdapter
|
||||
*/
|
||||
public function __construct(private readonly array $script = [])
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Platform\Modules\Databases;
|
||||
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Action;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Utopia\Database\Document;
|
||||
|
||||
final class DatabaseTypeMismatchTest extends TestCase
|
||||
{
|
||||
public function testTablesdbAllowsTablesdbAndLegacyButRejectsOtherProducts(): void
|
||||
{
|
||||
$action = new class () extends Action {
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'testTablesdbTypeGuard';
|
||||
}
|
||||
|
||||
public function exposeMismatch(Document $database): bool
|
||||
{
|
||||
return $this->isDatabaseTypeMismatch($database);
|
||||
}
|
||||
|
||||
/** @return string[] */
|
||||
public function exposeAllowedTypes(): array
|
||||
{
|
||||
return $this->getAllowedDatabaseTypes();
|
||||
}
|
||||
};
|
||||
$action->setHttpPath('/v1/tablesdb/:databaseId/tables');
|
||||
|
||||
// TablesDB is the compatibility successor to the legacy databases API:
|
||||
// the allowed set must equal what listTablesDatabases advertises.
|
||||
$this->assertSame([DATABASE_TYPE_TABLESDB, DATABASE_TYPE_LEGACY], $action->exposeAllowedTypes());
|
||||
|
||||
$this->assertFalse($action->exposeMismatch(new Document(['type' => DATABASE_TYPE_TABLESDB])));
|
||||
$this->assertFalse($action->exposeMismatch(new Document(['type' => DATABASE_TYPE_LEGACY])));
|
||||
$this->assertTrue($action->exposeMismatch(new Document(['type' => DATABASE_TYPE_DOCUMENTSDB])));
|
||||
$this->assertTrue($action->exposeMismatch(new Document(['type' => DATABASE_TYPE_VECTORSDB])));
|
||||
// Databases always carry a non-null type (V23 backfilled old rows to
|
||||
// legacy); an unexpected empty type is excluded by both the list and guard.
|
||||
$this->assertTrue($action->exposeMismatch(new Document([])));
|
||||
}
|
||||
|
||||
public function testDocumentsAndVectorsPathsScopeStrictlyToTheirOwnType(): void
|
||||
{
|
||||
$documents = new class () extends Action {
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'testDocumentsdbTypeGuard';
|
||||
}
|
||||
|
||||
public function exposeMismatch(Document $database): bool
|
||||
{
|
||||
return $this->isDatabaseTypeMismatch($database);
|
||||
}
|
||||
};
|
||||
$documents->setHttpPath('/v1/documentsdb/:databaseId/collections');
|
||||
$this->assertFalse($documents->exposeMismatch(new Document(['type' => DATABASE_TYPE_DOCUMENTSDB])));
|
||||
$this->assertTrue($documents->exposeMismatch(new Document(['type' => DATABASE_TYPE_VECTORSDB])));
|
||||
$this->assertTrue($documents->exposeMismatch(new Document(['type' => DATABASE_TYPE_LEGACY])));
|
||||
$this->assertTrue($documents->exposeMismatch(new Document([])));
|
||||
|
||||
$vectors = new class () extends Action {
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'testVectorsdbTypeGuard';
|
||||
}
|
||||
|
||||
public function exposeMismatch(Document $database): bool
|
||||
{
|
||||
return $this->isDatabaseTypeMismatch($database);
|
||||
}
|
||||
};
|
||||
$vectors->setHttpPath('/v1/vectorsdb/:databaseId/collections');
|
||||
$this->assertFalse($vectors->exposeMismatch(new Document(['type' => DATABASE_TYPE_VECTORSDB])));
|
||||
$this->assertTrue($vectors->exposeMismatch(new Document(['type' => DATABASE_TYPE_DOCUMENTSDB])));
|
||||
$this->assertTrue($vectors->exposeMismatch(new Document(['type' => DATABASE_TYPE_LEGACY])));
|
||||
}
|
||||
|
||||
public function testLegacyDatabasesPathIsNeverTypeGuarded(): void
|
||||
{
|
||||
$legacy = new class () extends Action {
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'testLegacyTypeGuard';
|
||||
}
|
||||
|
||||
public function exposeMismatch(Document $database): bool
|
||||
{
|
||||
return $this->isDatabaseTypeMismatch($database);
|
||||
}
|
||||
};
|
||||
$legacy->setHttpPath('/v1/databases/:databaseId/collections');
|
||||
$this->assertFalse($legacy->exposeMismatch(new Document(['type' => DATABASE_TYPE_LEGACY])));
|
||||
$this->assertFalse($legacy->exposeMismatch(new Document([])));
|
||||
$this->assertFalse($legacy->exposeMismatch(new Document(['type' => DATABASE_TYPE_TABLESDB])));
|
||||
$this->assertFalse($legacy->exposeMismatch(new Document(['type' => DATABASE_TYPE_DOCUMENTSDB])));
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Utopia;
|
||||
|
||||
use Appwrite\Models\Project as GeneratedProject;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model\Project as ProjectModel;
|
||||
use Exception;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionProperty;
|
||||
@@ -110,6 +112,56 @@ final class ResponseTest extends TestCase
|
||||
]), 'single');
|
||||
}
|
||||
|
||||
public function testProjectResponseCanHydrateGeneratedSdkProjectWithoutOAuth2Fields(): void
|
||||
{
|
||||
$this->response->setModel(new ProjectModel());
|
||||
|
||||
$project = $this->response->output(new Document([
|
||||
'$id' => 'project',
|
||||
'$createdAt' => '2026-06-19T00:00:00.000+00:00',
|
||||
'$updatedAt' => '2026-06-19T00:00:00.000+00:00',
|
||||
'name' => 'Project',
|
||||
'teamId' => 'team',
|
||||
'region' => 'default',
|
||||
]), Response::MODEL_PROJECT);
|
||||
|
||||
$generated = GeneratedProject::from($project);
|
||||
|
||||
foreach ([
|
||||
'oAuth2ServerEnabled',
|
||||
'oAuth2ServerAuthorizationUrl',
|
||||
'oAuth2ServerScopes',
|
||||
'oAuth2ServerAuthorizationDetailsTypes',
|
||||
'oAuth2ServerAccessTokenDuration',
|
||||
'oAuth2ServerRefreshTokenDuration',
|
||||
'oAuth2ServerPublicAccessTokenDuration',
|
||||
'oAuth2ServerPublicRefreshTokenDuration',
|
||||
'oAuth2ServerConfidentialPkce',
|
||||
'oAuth2ServerVerificationUrl',
|
||||
'oAuth2ServerUserCodeLength',
|
||||
'oAuth2ServerUserCodeFormat',
|
||||
'oAuth2ServerDeviceCodeDuration',
|
||||
'oAuth2ServerDiscoveryUrl',
|
||||
] as $key) {
|
||||
$this->assertArrayNotHasKey($key, $project);
|
||||
}
|
||||
|
||||
$this->assertNull($generated->oAuth2ServerEnabled);
|
||||
$this->assertNull($generated->oAuth2ServerAuthorizationUrl);
|
||||
$this->assertNull($generated->oAuth2ServerScopes);
|
||||
$this->assertNull($generated->oAuth2ServerAuthorizationDetailsTypes);
|
||||
$this->assertNull($generated->oAuth2ServerAccessTokenDuration);
|
||||
$this->assertNull($generated->oAuth2ServerRefreshTokenDuration);
|
||||
$this->assertNull($generated->oAuth2ServerPublicAccessTokenDuration);
|
||||
$this->assertNull($generated->oAuth2ServerPublicRefreshTokenDuration);
|
||||
$this->assertNull($generated->oAuth2ServerConfidentialPkce);
|
||||
$this->assertNull($generated->oAuth2ServerVerificationUrl);
|
||||
$this->assertNull($generated->oAuth2ServerUserCodeLength);
|
||||
$this->assertNull($generated->oAuth2ServerUserCodeFormat);
|
||||
$this->assertNull($generated->oAuth2ServerDeviceCodeDuration);
|
||||
$this->assertNull($generated->oAuth2ServerDiscoveryUrl);
|
||||
}
|
||||
|
||||
public function testResponseModelLists(): void
|
||||
{
|
||||
$output = $this->response->output(new Document([
|
||||
|
||||
Reference in new issue
Block a user