Merge branch 'refactor-workers-sn' of https://github.com/appwrite/appwrite into chhore-parallelize-tests

This commit is contained in:
Christy Jacob 2023-10-18 21:49:43 +00:00
commit 6141d02e16
246 changed files with 4158 additions and 3886 deletions

2
.env
View file

@ -9,7 +9,9 @@ _APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io
_APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io
_APP_SYSTEM_RESPONSE_FORMAT=
_APP_OPTIONS_ABUSE=disabled
_APP_OPTIONS_ROUTER_PROTECTION=disbled
_APP_OPTIONS_FORCE_HTTPS=disabled
_APP_OPTIONS_FUNCTIONS_FORCE_HTTPS=disabled
_APP_OPENSSL_KEY_V1=your-secret-key
_APP_DOMAIN=localhost
_APP_DOMAIN_FUNCTIONS=functions.localhost

View file

@ -1,9 +1,9 @@
name: "Build and Publish"
name: "Build and Publish Appwrite Images for Cloud"
on:
push:
tags:
- appwrite-*
- cl-*
jobs:
build-publish:
@ -16,7 +16,7 @@ jobs:
with:
fetch-depth: 2
submodules: recursive
ref: feat-db-pools-master
ref: cl-1.4.x
- name: Login to Docker Hub
uses: docker/login-action@v2

2
.gitmodules vendored
View file

@ -1,4 +1,4 @@
[submodule "app/console"]
path = app/console
url = https://github.com/appwrite/console
branch = 3.0.4
branch = 3.2.1

View file

@ -1,3 +1,67 @@
# Version 1.4.5
## Changes
- Bump console to version 3.2.1 in [#6868](https://github.com/appwrite/appwrite/pull/6868)
## Fixes
- Fix realtime logs in [#6478](https://github.com/appwrite/appwrite/pull/6478)
- Fix "File not found" error in executor in [#6476](https://github.com/appwrite/appwrite/pull/6476)
- Fix missing array flag on migration errors response model rule in [#6469](https://github.com/appwrite/appwrite/pull/6469)
- Ensure openruntimes-executor restarts after a server reboot in [#6490](https://github.com/appwrite/appwrite/pull/6490)
# Version 1.4.4
## Features
- Feat: Function domains force https in [#6269](https://github.com/appwrite/appwrite/pull/6269)
- Feat: router protection in [#6272](https://github.com/appwrite/appwrite/pull/6272)
- Feat: Parse event body in [#6317](https://github.com/appwrite/appwrite/pull/6317)
## Fixes
- Fix: wrong device type in [#6271](https://github.com/appwrite/appwrite/pull/6271)
- Fix: build race condition in [#6270](https://github.com/appwrite/appwrite/pull/6270)
- Fix: Large builds in [#6273](https://github.com/appwrite/appwrite/pull/6273)
- Fix: migrations in [#6302](https://github.com/appwrite/appwrite/pull/6302)
- Add Description for Download Deployment in [#6268](https://github.com/appwrite/appwrite/pull/6268)
- Fix deployment delete in [#6290](https://github.com/appwrite/appwrite/pull/6290)
- Fix project deletion in [#6260](https://github.com/appwrite/appwrite/pull/6260)
- fix-6212-Issue-With-Linkedin-OAuth in [#6229](https://github.com/appwrite/appwrite/pull/6229)
- Fix: Execution body limit in [#6326](https://github.com/appwrite/appwrite/pull/6326)
- Patch: Disable console protection in [#6329](https://github.com/appwrite/appwrite/pull/6329)
- converted desc to sentence case in [#5926](https://github.com/appwrite/appwrite/pull/5926)
- Update avatar font and default colors in [#6277](https://github.com/appwrite/appwrite/pull/6277)
- Bump composer to fix migration bug in [#6344](https://github.com/appwrite/appwrite/pull/6344)
- Fix execution call timeout in [#6332](https://github.com/appwrite/appwrite/pull/6332)
- Bump appwrite-assistant to prevent it from crashing w/o open ai key in [#6342](https://github.com/appwrite/appwrite/pull/6342)
- Remove Special Chars from Initials [#6164](https://github.com/appwrite/appwrite/pull/6164)
# Version 1.4.3
## Features
- Support for the all new bun runtime [#6230](https://github.com/appwrite/appwrite/pull/6230)
- Stripe function templates [Console #540](https://github.com/appwrite/console/pull/540)
## Fixes
- Fix missing _APP_OPENSSL_KEY_V1 in the compose file [#6199](https://github.com/appwrite/appwrite/pull/6199)
- Fix V2 functions env vars [#6215](https://github.com/appwrite/appwrite/pull/6215)
- Fix Don't update User Accessed At for Users and Teams APIs [#6222](https://github.com/appwrite/appwrite/pull/6222)
- Fix Git deploys with S3 [#6227](https://github.com/appwrite/appwrite/pull/6227)
- Fix manual internal id insertion [#6232](https://github.com/appwrite/appwrite/pull/6232)
- Fix function timeout [#6235](https://github.com/appwrite/appwrite/pull/6235)
- Fix collections with datetime attributes migration [#17](https://github.com/utopia-php/migration/pull/17)
- Fix not all user data being migrated [#17](https://github.com/utopia-php/migration/pull/17)
- Fix team memberships migration [#16](https://github.com/utopia-php/migration/pull/16)
- Fix events validation on create/update webhooks [#6219](https://github.com/appwrite/appwrite/pull/6219)
- Fix schedules task [#6246](https://github.com/appwrite/appwrite/pull/6246)
- Fix missing keys when updating document via relationship [Database #320](https://github.com/utopia-php/database/pull/320)
- Fix Discord template [Console #538](https://github.com/appwrite/console/pull/538)
- Fix form var is url not text [Console #539](https://github.com/appwrite/console/pull/539)
- Fix incorrect link to migration docs for self-hosted to cloud [Console #543](https://github.com/appwrite/console/pull/543)
- Fix can't disable smtp [Console #548](https://github.com/appwrite/console/pull/548)
- Fix create function cover for case where VCS is not enabled [Console #544](https://github.com/appwrite/console/pull/544)
- Fix users list not re-rendering [Console #537](https://github.com/appwrite/console/pull/537)
- Fix create attribute modal null when selecting same time twice [Console #549](https://github.com/appwrite/console/pull/549)
- Fix runtime versions in templates [Console #546](https://github.com/appwrite/console/pull/546)
# Version 1.4.2
## Fixes

View file

@ -2,6 +2,11 @@
We would ❤️ you to contribute to Appwrite and help make it better! We want contributing to Appwrite to be fun, enjoyable, and educational for anyone and everyone. All contributions are welcome, including issues, and new docs, as well as updates and tweaks, blog posts, workshops, and more.
## Here for Hacktoberfest?
If you're here to contribute during Hacktoberfest, we're so happy to see you here. Appwrite has been a long-time participant of Hacktoberfest and we welcome you, whatever your experience level. This year, we're **only taking contributions for issues tagged** `hacktoberfest`, so we can focus our resources to support your contributions.
You can [find issues using this query](https://github.com/search?q=org%3Aappwrite+is%3Aopen+type%3Aissue+label%3Ahacktoberfest&type=issues).
## How to Start?
If you are worried or dont know where to start, check out the next section that explains what kind of help we could use and where you can get involved. You can send your questions to [@appwrite](https://twitter.com/appwrite) on Twitter or to anyone from the [Appwrite team on Discord](https://appwrite.io/discord). You can also submit an issue, and a maintainer can guide you!
@ -201,7 +206,6 @@ Appwrite's current structure is a combination of both [Monolithic](https://en.wi
│ ├── Network
│ ├── OpenSSL
│ ├── Promises
│ ├── Resque
│ ├── Specification
│ ├── Task
│ ├── Template
@ -246,7 +250,6 @@ Appwrite stack is a combination of a variety of open-source technologies and too
- Imagemagick - for manipulating and managing image media files.
- Webp - for better compression of images on supporting clients.
- SMTP - for sending email messages and alerts.
- Resque - for managing data queues and scheduled tasks over a Redis server.
## Package Managers

View file

@ -37,99 +37,8 @@ ARG VERSION=dev
ARG DEBUG=false
ENV DEBUG=$DEBUG
ENV DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
ENV DOCKER_COMPOSE_VERSION=v2.5.0
ENV _APP_SERVER=swoole \
_APP_ENV=production \
_APP_LOCALE=en \
_APP_WORKER_PER_CORE= \
_APP_DOMAIN=localhost \
_APP_DOMAIN_FUNCTIONS=functions.localhost \
_APP_DOMAIN_TARGET=localhost \
_APP_HOME=https://appwrite.io \
_APP_EDITION=community \
_APP_CONSOLE_WHITELIST_ROOT=enabled \
_APP_CONSOLE_WHITELIST_EMAILS= \
_APP_CONSOLE_WHITELIST_IPS= \
_APP_SYSTEM_EMAIL_NAME= \
_APP_SYSTEM_EMAIL_ADDRESS= \
_APP_SYSTEM_RESPONSE_FORMAT= \
_APP_SYSTEM_SECURITY_EMAIL_ADDRESS= \
_APP_OPTIONS_ABUSE=enabled \
_APP_OPTIONS_FORCE_HTTPS=disabled \
_APP_OPENSSL_KEY_V1=your-secret-key \
_APP_STORAGE_LIMIT=10000000 \
_APP_STORAGE_ANTIVIRUS=enabled \
_APP_STORAGE_ANTIVIRUS_HOST=clamav \
_APP_STORAGE_ANTIVIRUS_PORT=3310 \
_APP_STORAGE_DEVICE=Local \
_APP_STORAGE_S3_ACCESS_KEY= \
_APP_STORAGE_S3_SECRET= \
_APP_STORAGE_S3_REGION= \
_APP_STORAGE_S3_BUCKET= \
_APP_STORAGE_DO_SPACES_ACCESS_KEY= \
_APP_STORAGE_DO_SPACES_SECRET= \
_APP_STORAGE_DO_SPACES_REGION= \
_APP_STORAGE_DO_SPACES_BUCKET= \
_APP_STORAGE_BACKBLAZE_ACCESS_KEY= \
_APP_STORAGE_BACKBLAZE_SECRET= \
_APP_STORAGE_BACKBLAZE_REGION= \
_APP_STORAGE_BACKBLAZE_BUCKET= \
_APP_STORAGE_LINODE_ACCESS_KEY= \
_APP_STORAGE_LINODE_SECRET= \
_APP_STORAGE_LINODE_REGION= \
_APP_STORAGE_LINODE_BUCKET= \
_APP_STORAGE_WASABI_ACCESS_KEY= \
_APP_STORAGE_WASABI_SECRET= \
_APP_STORAGE_WASABI_REGION= \
_APP_STORAGE_WASABI_BUCKET= \
_APP_REDIS_HOST=redis \
_APP_REDIS_PORT=6379 \
_APP_DB_HOST=mariadb \
_APP_DB_PORT=3306 \
_APP_DB_USER=root \
_APP_DB_PASS=password \
_APP_DB_SCHEMA=appwrite \
_APP_INFLUXDB_HOST=influxdb \
_APP_INFLUXDB_PORT=8086 \
_APP_STATSD_HOST=telegraf \
_APP_STATSD_PORT=8125 \
_APP_SMTP_HOST= \
_APP_SMTP_PORT= \
_APP_SMTP_SECURE= \
_APP_SMTP_USERNAME= \
_APP_SMTP_PASSWORD= \
_APP_SMS_PROVIDER= \
_APP_SMS_FROM= \
_APP_FUNCTIONS_SIZE_LIMIT=30000000 \
_APP_FUNCTIONS_TIMEOUT=900 \
_APP_FUNCTIONS_CONTAINERS=10 \
_APP_FUNCTIONS_CPUS=1 \
_APP_FUNCTIONS_MEMORY=128 \
_APP_FUNCTIONS_MEMORY_SWAP=128 \
_APP_EXECUTOR_SECRET=a-random-secret \
_APP_EXECUTOR_HOST=http://appwrite-executor/v1 \
_APP_EXECUTOR_RUNTIME_NETWORK=appwrite_runtimes \
_APP_SETUP=self-hosted \
_APP_VERSION=$VERSION \
_APP_USAGE_STATS=enabled \
_APP_USAGE_AGGREGATION_INTERVAL=30 \
# 14 Days = 1209600 s
_APP_MAINTENANCE_RETENTION_EXECUTION=1209600 \
_APP_MAINTENANCE_RETENTION_AUDIT=1209600 \
# 1 Day = 86400 s
_APP_MAINTENANCE_RETENTION_ABUSE=86400 \
_APP_MAINTENANCE_RETENTION_USAGE_HOURLY=8640000 \
_APP_MAINTENANCE_INTERVAL=86400 \
_APP_LOGGING_PROVIDER= \
_APP_LOGGING_CONFIG= \
_APP_VCS_GITHUB_APP_NAME= \
_APP_VCS_GITHUB_PRIVATE_KEY= \
_APP_VCS_GITHUB_APP_ID= \
_APP_VCS_GITHUB_CLIENT_ID= \
_APP_VCS_GITHUB_CLIENT_SECRET= \
_APP_VCS_GITHUB_WEBHOOK_SECRET=
ENV _APP_VERSION=$VERSION \
_APP_HOME=https://appwrite.io
RUN \
if [ "$DEBUG" == "true" ]; then \

57
HACKTOBERFEST.md Normal file
View file

@ -0,0 +1,57 @@
# Appwrite hacktoberfest contribution
Welcome to the Appwrite Hacktoberfest contribution! We appreciate your interest in contributing to our open-source project. Please read this carefully to understand how to get started and make your contributions count.
## Familiarize with the project
Before you start contributing, familiarize yourself with our project by reading the [main README](https://github.com/appwrite/appwrite/blob/main/README.md).
## Code of conduct
Please ensure that you always follow our [Code of Conduct](https://github.com/appwrite/awesome-appwrite/blob/master/CODE_OF_CONDUCT.md). We aim to maintain a respectful and inclusive community.
## Contributing guide
Please review our [Contributing Guide](https://github.com/appwrite/appwrite/blob/main/CONTRIBUTING.md) before contributing. It will help you learn about the architecture, instructions on how to update code, run tests, and submit a PR.
## Hacktoberfest contribution guidelines
To participate in Hacktoberfest with Appwrite, follow these guidelines:
1. **Valid issues**: To make your contribution count, please look for issues labeled with `hacktoberfest`. Only issues labeled with `hacktoberfest` will count as a valid contribution.
2. **Wait for issue assignment**: After you have identified an issue to work on, please wait for it to be assigned to you by our team. We assign issues on a first-come, first-serve basis.
3. **Knowing about labels**: We do not have the `hacktoberfest` label in our repositories, but we use it on specific issues. For your pull request to be valid, our team will review and add the `hacktoberfest-accepted` label once it meets the criteria.
4. **Discuss new issues**: If you're interested in finding and adding new issues for Hacktoberfest, please discuss it with the team on our [Discord server](https://appwrite.io/discord) in the `#hacktoberfest` channel.
5. **Be patient with pull request reviews**: PR reviews may take up to 15 days due to the volume of contributions. However, we also host PR review parties every week where you can add your PRs for instant review.
6. **Regular updates**: If you've been assigned an issue, it's essential to share updates every 3 days. Failure to do so may result in being unassigned from the issue.
## Getting started
1. Fork the Appwrite repository you'd like to contribute to.
2. Clone your forked repository to your local machine.
```bash
git clone https://github.com/your-username/repository-name.git
```
3. Create a new branch for your contribution.
```bash
git checkout -b TYPE-ISSUE_ID-DESCRIPTION
```
4. Make your changes, commit them, and push them to your forked repository.
```bash
git commit -m "Add your commit message here"
git push origin TYPE-ISSUE_ID-DESCRIPTION
```
5. Create a Pull Request (PR) from your forked repository to the Appwrite repository. Be sure to reference the issue you are addressing in your PR description.
Thank you for contributing to Appwrite, and we look forward to your Hacktoberfest contributions! If you have any questions or need assistance, feel free to ask on our Discord server or in the issue discussion. Happy hacking!

View file

@ -2,7 +2,7 @@
<br />
<p align="center">
<a href="https://appwrite.io" target="_blank"><img width="260" height="39" src="https://appwrite.io/images/appwrite.svg" alt="Appwrite Logo"></a>
<a href="https://appwrite.io" target="_blank"><img src="./public/images/banner.png" alt="Appwrite Logo"></a>
<br />
<br />
<b>适用于[Flutter/Vue/Angular/React/iOS/Android/* 等等平台 *]的完整后端服务</b>
@ -66,7 +66,7 @@ docker run -it --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
--entrypoint="install" \
appwrite/appwrite:1.4.2
appwrite/appwrite:1.4.5
```
### Windows
@ -78,7 +78,7 @@ docker run -it --rm ^
--volume //var/run/docker.sock:/var/run/docker.sock ^
--volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^
--entrypoint="install" ^
appwrite/appwrite:1.4.2
appwrite/appwrite:1.4.5
```
#### PowerShell
@ -88,7 +88,7 @@ docker run -it --rm `
--volume /var/run/docker.sock:/var/run/docker.sock `
--volume ${pwd}/appwrite:/usr/src/code/appwrite:rw `
--entrypoint="install" `
appwrite/appwrite:1.4.2
appwrite/appwrite:1.4.5
```
运行后,可以在浏览器上访问 http://localhost 找到 Appwrite 控制台。在非 Linux 的本机主机上完成安装后,服务器可能需要几分钟才能启动。
@ -113,14 +113,14 @@ docker run -it --rm `
### 软件服务
* [**帐户**](https://appwrite.io/docs/client/account) -管理当前用户的帐户和登录方式。跟踪和管理用户 Session登录设备登录方法和查看相关记录。
* [**帐户**](https://appwrite.io/docs/references/cloud/client-web/account) -管理当前用户的帐户和登录方式。跟踪和管理用户 Session登录设备登录方法和查看相关记录。
* [**用户**](https://appwrite.io/docs/server/users) - 在以管理员模式登录时管理和列出所有用户。
* [**团队**](https://appwrite.io/docs/client/teams) - 管理用户分组。邀请成员,管理团队中的用户权限和用户角色。
* [**数据库**](https://appwrite.io/docs/client/databases) - 管理数据库文档和文档集。用检索界面来对文档和文档集进行读取,创建,更新,和删除。
* [**贮存**](https://appwrite.io/docs/client/storage) - 管理文件的阅读、创建、删除和预览。设置文件的预览来满足程序的个性化需求。所有文件都由 ClamAV 扫描并安全存储和加密。
* [**团队**](https://appwrite.io/docs/references/cloud/client-web/teams) - 管理用户分组。邀请成员,管理团队中的用户权限和用户角色。
* [**数据库**](https://appwrite.io/docs/references/cloud/client-web/databases) - 管理数据库文档和文档集。用检索界面来对文档和文档集进行读取,创建,更新,和删除。
* [**贮存**](https://appwrite.io/docs/references/cloud/client-web/storage) - 管理文件的阅读、创建、删除和预览。设置文件的预览来满足程序的个性化需求。所有文件都由 ClamAV 扫描并安全存储和加密。
* [**云函数**](https://appwrite.io/docs/server/functions) - 在安全隔离的环境中运行自定义代码。这些代码可以被事件CRON或者手动操作触发。
* [**语言适配**](https://appwrite.io/docs/client/locale) - 根据用户所在的的国家和地区做出合适的语言适配。
* [**头像**](https://appwrite.io/docs/client/avatars) -管理用户头像、国家旗帜、浏览器图标、信用卡符号,和生成二维码。
* [**语言适配**](https://appwrite.io/docs/references/cloud/client-web/locale) - 根据用户所在的的国家和地区做出合适的语言适配。
* [**头像**](https://appwrite.io/docs/references/cloud/client-web/avatars) -管理用户头像、国家旗帜、浏览器图标、信用卡符号,和生成二维码。
如需完整的 API 界面文档,请访问 [https://appwrite.io/docs](https://appwrite.io/docs)。如需更多教程、新闻和公告,请订阅我们的 [博客](https://medium.com/appwrite-io) 和 加入我们的[Discord 社区](https://discord.gg/GSeTUeA)。
### 开发套件

View file

@ -2,7 +2,8 @@
<br />
<p align="center">
<a href="https://appwrite.io" target="_blank"><img width="260" height="39" src="https://appwrite.io/images/appwrite.svg" alt="Appwrite Logo"></a>
<a href="https://appwrite.io" target="_blank"><img src="./public/images/banner.png" alt="Appwrite Logo"></a>
<br />
<br />
<b>Appwrite is a backend platform for developing Web, Mobile, and Flutter applications. Built with the open source community and optimized for developer experience in the coding languages you love.</b>
<br />
@ -75,7 +76,7 @@ docker run -it --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
--entrypoint="install" \
appwrite/appwrite:1.4.2
appwrite/appwrite:1.4.5
```
### Windows
@ -87,7 +88,7 @@ docker run -it --rm ^
--volume //var/run/docker.sock:/var/run/docker.sock ^
--volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^
--entrypoint="install" ^
appwrite/appwrite:1.4.2
appwrite/appwrite:1.4.5
```
#### PowerShell
@ -97,7 +98,7 @@ docker run -it --rm `
--volume /var/run/docker.sock:/var/run/docker.sock `
--volume ${pwd}/appwrite:/usr/src/code/appwrite:rw `
--entrypoint="install" `
appwrite/appwrite:1.4.2
appwrite/appwrite:1.4.5
```
Once the Docker installation is complete, go to http://localhost to access the Appwrite console from your browser. Please note that on non-Linux native hosts, the server might take a few minutes to start after completing the installation.
@ -150,15 +151,15 @@ Getting started with Appwrite is as easy as creating a new project, choosing you
### Services
- [**Account**](https://appwrite.io/docs/client/account) - Manage current user authentication and account. Track and manage the user sessions, devices, sign-in methods, and security logs.
- [**Account**](https://appwrite.io/docs/references/cloud/client-web/account) - Manage current user authentication and account. Track and manage the user sessions, devices, sign-in methods, and security logs.
- [**Users**](https://appwrite.io/docs/server/users) - Manage and list all project users when building backend integrations with Server SDKs.
- [**Teams**](https://appwrite.io/docs/client/teams) - Manage and group users in teams. Manage memberships, invites, and user roles within a team.
- [**Databases**](https://appwrite.io/docs/client/databases) - Manage databases, collections, and documents. Read, create, update, and delete documents and filter lists of document collections using advanced filters.
- [**Storage**](https://appwrite.io/docs/client/storage) - Manage storage files. Read, create, delete, and preview files. Manipulate the preview of your files to perfectly fit your app. All files are scanned by ClamAV and stored in a secure and encrypted way.
- [**Teams**](https://appwrite.io/docs/references/cloud/client-web/teams) - Manage and group users in teams. Manage memberships, invites, and user roles within a team.
- [**Databases**](https://appwrite.io/docs/references/cloud/client-web/databases) - Manage databases, collections, and documents. Read, create, update, and delete documents and filter lists of document collections using advanced filters.
- [**Storage**](https://appwrite.io/docs/references/cloud/client-web/storage) - Manage storage files. Read, create, delete, and preview files. Manipulate the preview of your files to perfectly fit your app. All files are scanned by ClamAV and stored in a secure and encrypted way.
- [**Functions**](https://appwrite.io/docs/server/functions) - Customize your Appwrite server by executing your custom code in a secure, isolated environment. You can trigger your code on any Appwrite system event either manually or using a CRON schedule.
- [**Realtime**](https://appwrite.io/docs/realtime) - Listen to real-time events for any of your Appwrite services including users, storage, functions, databases, and more.
- [**Locale**](https://appwrite.io/docs/client/locale) - Track your user's location and manage your app locale-based data.
- [**Avatars**](https://appwrite.io/docs/client/avatars) - Manage your users' avatars, countries' flags, browser icons, and credit card symbols. Generate QR codes from links or plaintext strings.
- [**Locale**](https://appwrite.io/docs/references/cloud/client-web/locale) - Track your user's location and manage your app locale-based data.
- [**Avatars**](https://appwrite.io/docs/references/cloud/client-web/avatars) - Manage your users' avatars, countries' flags, browser icons, and credit card symbols. Generate QR codes from links or plaintext strings.
For the complete API documentation, visit [https://appwrite.io/docs](https://appwrite.io/docs). For more tutorials, news and announcements check out our [blog](https://medium.com/appwrite-io) and [Discord Server](https://discord.gg/GSeTUeA).

Binary file not shown.

View file

@ -3,6 +3,8 @@
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/controllers/general.php';
use Appwrite\Event\Delete;
use Appwrite\Event\Certificate;
use Appwrite\Event\Func;
use Appwrite\Platform\Appwrite;
use Utopia\CLI\CLI;
@ -17,6 +19,7 @@ use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Logger\Log;
use Utopia\Pools\Group;
use Utopia\Queue\Connection;
use Utopia\Registry\Registry;
Authorization::disable();
@ -86,7 +89,7 @@ CLI::setResource('dbForConsole', function ($pools, $cache) {
CLI::setResource('getProjectDB', function (Group $pools, Database $dbForConsole, $cache) {
$databases = []; // TODO: @Meldiron This should probably be responsibility of utopia-php/pools
$getProjectDB = function (Document $project) use ($pools, $dbForConsole, $cache, &$databases) {
return function (Document $project) use ($pools, $dbForConsole, $cache, &$databases) {
if ($project->isEmpty() || $project->getId() === 'console') {
return $dbForConsole;
}
@ -112,8 +115,6 @@ CLI::setResource('getProjectDB', function (Group $pools, Database $dbForConsole,
return $database;
};
return $getProjectDB;
}, ['pools', 'dbForConsole', 'cache']);
CLI::setResource('influxdb', function (Registry $register) {
@ -140,10 +141,18 @@ CLI::setResource('influxdb', function (Registry $register) {
return $database;
}, ['register']);
CLI::setResource('queueForFunctions', function (Group $pools) {
return new Func($pools->get('queue')->pop()->getResource());
CLI::setResource('queue', function (Group $pools) {
return $pools->get('queue')->pop()->getResource();
}, ['pools']);
CLI::setResource('queueForFunctions', function (Connection $queue) {
return new Func($queue);
}, ['queue']);
CLI::setResource('queueForDeletes', function (Connection $queue) {
return new Delete($queue);
}, ['queue']);
CLI::setResource('queueForCertificates', function (Connection $queue) {
return new Certificate($queue);
}, ['queue']);
CLI::setResource('logError', function (Registry $register) {
return function (Throwable $error, string $namespace, string $action) use ($register) {
$logger = $register->get('logger');

View file

@ -2,31 +2,31 @@
"settings.inspire": "\"El arte de ser sabio es el arte de saber qué pasar por alto\"",
"settings.locale": "es",
"settings.direction": "ltr",
"emails.sender": "Equipo %s",
"emails.sender": "El equipo de %s",
"emails.verification.subject": "Verificación de cuenta",
"emails.verification.hello": "Hola {{user}}",
"emails.verification.body": "Haz clic en este enlace para verificar tu correo.",
"emails.verification.hello": "Hola, {{name}}",
"emails.verification.body": "Haz clic en este enlace para verificar tu correo:",
"emails.verification.footer": "Si no has solicitado verificar este correo, puedes ignorar este mensaje.",
"emails.verification.thanks": "Gracias",
"emails.verification.signature": "Equipo de {{project}}",
"emails.verification.thanks": "Gracias.",
"emails.verification.signature": "El equipo de {{project}}.",
"emails.magicSession.subject": "Inicio de sesión",
"emails.magicSession.hello": "Hola,",
"emails.magicSession.body": "Haz clic en este enlace para iniciar sesión.",
"emails.magicSession.footer": "Si no has solicitado ingresar usando este correo, puedes ignorar este mensaje.",
"emails.magicSession.thanks": "Gracias",
"emails.magicSession.signature": "Equipo de {{project}}",
"emails.magicSession.hello": "Hola",
"emails.magicSession.body": "Haz clic en este enlace para iniciar sesión:",
"emails.magicSession.footer": "Si no has solicitado iniciar sesión usando este correo, puedes ignorar este mensaje.",
"emails.magicSession.thanks": "Gracias.",
"emails.magicSession.signature": "El equipo de {{project}}",
"emails.recovery.subject": "Restablecer contraseña",
"emails.recovery.hello": "Hola {{user}}",
"emails.recovery.body": "Haz clic en este enlace para restablecer la contraseña de {{project}}.",
"emails.recovery.hello": "Hola, {{name}}",
"emails.recovery.body": "Haz clic en este enlace para restablecer la contraseña de {{project}}:",
"emails.recovery.footer": "Si no has solicitado restablecer la contraseña, puedes ignorar este mensaje.",
"emails.recovery.thanks": "Gracias",
"emails.recovery.signature": "Equipo de {{project}}",
"emails.recovery.thanks": "Gracias.",
"emails.recovery.signature": "El equipo de {{project}}",
"emails.invitation.subject": "Invitación al equipo %s en %s",
"emails.invitation.hello": "Hola",
"emails.invitation.body": "Este correo ha sido enviado a petición de {{owner}} quien quiere invitarte a formar parte del equipo {{team}} en {{project}}.",
"emails.invitation.footer": "Si no estas interesado, puedes ignorar este mensaje.",
"emails.invitation.thanks": "Gracias",
"emails.invitation.signature": "Equipo de {{project}}",
"emails.invitation.body": "Este correo ha sido enviado a petición de {{owner}} quién quiere invitarte a formar parte del equipo {{team}} en {{project}}.",
"emails.invitation.footer": "Si no estás interesado, puedes ignorar este mensaje.",
"emails.invitation.thanks": "Gracias.",
"emails.invitation.signature": "El equipo de {{project}}",
"locale.country.unknown": "Desconocido",
"countries.af": "Afganistán",
"countries.ao": "Angola",
@ -229,4 +229,4 @@
"continents.na": "América del Norte",
"continents.oc": "Oceanía",
"continents.sa": "América del Sur"
}
}

View file

@ -8,7 +8,7 @@ return [
APP_PLATFORM_CLIENT => [
'key' => APP_PLATFORM_CLIENT,
'name' => 'Client',
'description' => 'Client libraries for integrating with Appwrite to build client-based applications and websites. Read the [getting started for web](/docs/getting-started-for-web) or [getting started for Flutter](/docs/getting-started-for-flutter) tutorials to start building your first application.',
'description' => 'Client libraries for integrating with Appwrite to build client-based applications and websites. Read the [getting started for web](https://appwrite.io/docs/getting-started-for-web) or [getting started for Flutter](https://appwrite.io/docs/getting-started-for-flutter) tutorials to start building your first application.',
'enabled' => true,
'beta' => false,
'sdks' => [
@ -81,7 +81,7 @@ return [
[
'key' => 'apple',
'name' => 'Apple',
'version' => '4.0.0',
'version' => '4.0.1',
'url' => 'https://github.com/appwrite/sdk-for-apple',
'package' => 'https://github.com/appwrite/sdk-for-apple',
'enabled' => true,
@ -203,7 +203,7 @@ return [
[
'key' => 'cli',
'name' => 'Command Line',
'version' => '4.0.0',
'version' => '4.1.0',
'url' => 'https://github.com/appwrite/sdk-for-cli',
'package' => 'https://www.npmjs.com/package/appwrite-cli',
'enabled' => true,
@ -224,7 +224,7 @@ return [
APP_PLATFORM_SERVER => [
'key' => APP_PLATFORM_SERVER,
'name' => 'Server',
'description' => 'Libraries for integrating with Appwrite to build server side integrations. Read the [getting started for server](/docs/getting-started-for-server) tutorial to start building your first server integration.',
'description' => 'Libraries for integrating with Appwrite to build server side integrations. Read the [getting started for server](https://appwrite.io/docs/getting-started-for-server) tutorial to start building your first server integration.',
'enabled' => true,
'beta' => false,
'sdks' => [
@ -415,7 +415,7 @@ return [
[
'key' => 'swift',
'name' => 'Swift',
'version' => '4.0.0',
'version' => '4.0.1',
'url' => 'https://github.com/appwrite/sdk-for-swift',
'package' => 'https://github.com/appwrite/sdk-for-swift',
'enabled' => true,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -36,13 +36,31 @@ return [
],
[
'name' => '_APP_OPTIONS_FORCE_HTTPS',
'description' => 'Allows you to force HTTPS connection to your API. This feature redirects any HTTP call to HTTPS and adds the \'Strict-Transport-Security\' header to all HTTP responses. By default, set to \'enabled\'. To disable, set to \'disabled\'. This feature will work only when your ports are set to default 80 and 443.',
'description' => 'Allows you to force HTTPS connection to your API. This feature redirects any HTTP call to HTTPS and adds the \'Strict-Transport-Security\' header to all HTTP responses. By default, set to \'enabled\'. To disable, set to \'disabled\'. This feature will work only when your ports are set to default 80 and 443, and you have set up wildcard certificates with DNS challenge.',
'introduction' => '',
'default' => 'disabled',
'required' => false,
'question' => '',
'filter' => ''
],
[
'name' => '_APP_OPTIONS_FUNCTIONS_FORCE_HTTPS',
'description' => 'Allows you to force HTTPS connection to function domains. This feature redirects any HTTP call to HTTPS and adds the \'Strict-Transport-Security\' header to all HTTP responses. By default, set to \'enabled\'. To disable, set to \'disabled\'. This feature will work only when your ports are set to default 80 and 443.',
'introduction' => '',
'default' => 'disabled',
'required' => false,
'question' => '',
'filter' => ''
],
[
'name' => '_APP_OPTIONS_ROUTER_PROTECTION',
'description' => 'Protects server from serving requests from unknown hostnames, and from serving Console for custom project domains. By default, set to \'disabled\'. To start router protection, set to \'enabled\'. It is recommended to enable this variable on production environment.',
'introduction' => '1.4.4',
'default' => 'disabled',
'required' => false,
'question' => '',
'filter' => ''
],
[
'name' => '_APP_OPENSSL_KEY_V1',
'description' => 'This is your server private secret key that is used to encrypt all sensitive data on your server. Appwrite server encrypts all secret data on your server like webhooks, HTTP passwords, user sessions, and storage files. The var is not set by default, if you wish to take advantage of Appwrite encryption capabilities you should change it and make sure to **keep it a secret and have a backup for it**.',
@ -65,7 +83,7 @@ return [
'name' => '_APP_DOMAIN_FUNCTIONS',
'description' => 'A domain to use for function preview URLs. Setting to empty turns off function preview URLs.',
'introduction' => '',
'default' => '',
'default' => 'functions.localhost',
'required' => false,
'question' => '',
'filter' => ''
@ -846,10 +864,11 @@ return [
],
[
'name' => '_APP_FUNCTIONS_MAINTENANCE_INTERVAL',
'description' => 'Interval how often executor checks for inactive runimes. The default value is 60 seconds.',
'introduction' => '1.2.0',
'default' => '60',
'description' => 'Interval value containing the number of seconds that the executor should wait before checking for inactive runtimes. The default value is 3600 seconds (1 hour).',
'introduction' => '1.4.0',
'default' => '3600',
'required' => false,
'overwrite' => true,
'question' => '',
'filter' => ''
],

@ -1 +1 @@
Subproject commit e07f0379f4124a202772bcd4bd38a3c8e2662eea
Subproject commit 2f47e4e77b3c832679c5a83a604dd7b8e8fc1903

View file

@ -50,7 +50,7 @@ $oauthDefaultSuccess = '/auth/oauth2/success';
$oauthDefaultFailure = '/auth/oauth2/failure';
App::post('/v1/account')
->desc('Create Account')
->desc('Create account')
->groups(['api', 'account', 'auth'])
->label('event', 'users.[userId].create')
->label('scope', 'public')
@ -76,8 +76,9 @@ App::post('/v1/account')
->inject('user')
->inject('project')
->inject('dbForProject')
->inject('events')
->action(function (string $userId, string $email, string $password, string $name, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Event $events) {
->inject('queueForEvents')
->action(function (string $userId, string $email, string $password, string $name, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Event $queueForEvents) {
$email = \strtolower($email);
if ('console' === $project->getId()) {
$whitelistEmails = $project->getAttribute('authWhitelistEmails');
@ -146,6 +147,7 @@ App::post('/v1/account')
'search' => implode(' ', [$userId, $email, $name]),
'accessedAt' => DateTime::now(),
]);
$user->removeAttribute('$internalId');
Authorization::skip(fn() => $dbForProject->createDocument('users', $user));
} catch (Duplicate) {
throw new Exception(Exception::USER_ALREADY_EXISTS);
@ -155,7 +157,7 @@ App::post('/v1/account')
Authorization::setRole(Role::user($user->getId())->toString());
Authorization::setRole(Role::users()->toString());
$events->setParam('userId', $user->getId());
$queueForEvents->setParam('userId', $user->getId());
$response
->setStatusCode(Response::STATUS_CODE_CREATED)
@ -164,7 +166,7 @@ App::post('/v1/account')
App::post('/v1/account/sessions/email')
->alias('/v1/account/sessions')
->desc('Create Email Session')
->desc('Create email session')
->groups(['api', 'account', 'auth', 'session'])
->label('event', 'users.[userId].sessions.[sessionId].create')
->label('scope', 'public')
@ -192,8 +194,8 @@ App::post('/v1/account/sessions/email')
->inject('project')
->inject('locale')
->inject('geodb')
->inject('events')
->action(function (string $email, string $password, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Reader $geodb, Event $events) {
->inject('queueForEvents')
->action(function (string $email, string $password, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Reader $geodb, Event $queueForEvents) {
$email = \strtolower($email);
$protocol = $request->getProtocol();
@ -275,7 +277,7 @@ App::post('/v1/account/sessions/email')
->setAttribute('expire', $expire)
;
$events
$queueForEvents
->setParam('userId', $user->getId())
->setParam('sessionId', $session->getId())
;
@ -284,7 +286,7 @@ App::post('/v1/account/sessions/email')
});
App::get('/v1/account/sessions/oauth2/:provider')
->desc('Create OAuth2 Session')
->desc('Create OAuth2 session')
->groups(['api', 'account'])
->label('error', __DIR__ . '/../../views/general/error.phtml')
->label('scope', 'public')
@ -350,7 +352,7 @@ App::get('/v1/account/sessions/oauth2/:provider')
});
App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
->desc('OAuth2 Callback')
->desc('OAuth2 callback')
->groups(['account'])
->label('error', __DIR__ . '/../../views/general/error.phtml')
->label('scope', 'public')
@ -382,7 +384,7 @@ App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
});
App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
->desc('OAuth2 Callback')
->desc('OAuth2 callback')
->groups(['account'])
->label('error', __DIR__ . '/../../views/general/error.phtml')
->label('scope', 'public')
@ -415,7 +417,7 @@ App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
});
App::get('/v1/account/sessions/oauth2/:provider/redirect')
->desc('OAuth2 Redirect')
->desc('OAuth2 redirect')
->groups(['api', 'account', 'session'])
->label('error', __DIR__ . '/../../views/general/error.phtml')
->label('event', 'users.[userId].sessions.[sessionId].create')
@ -439,8 +441,8 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
->inject('user')
->inject('dbForProject')
->inject('geodb')
->inject('events')
->action(function (string $provider, string $code, string $state, string $error, string $error_description, Request $request, Response $response, Document $project, Document $user, Database $dbForProject, Reader $geodb, Event $events) use ($oauthDefaultSuccess) {
->inject('queueForEvents')
->action(function (string $provider, string $code, string $state, string $error, string $error_description, Request $request, Response $response, Document $project, Document $user, Database $dbForProject, Reader $geodb, Event $queueForEvents) use ($oauthDefaultSuccess) {
$protocol = $request->getProtocol();
$callback = $protocol . '://' . $request->getHostname() . '/v1/account/sessions/oauth2/callback/' . $provider . '/' . $project->getId();
@ -653,6 +655,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
'search' => implode(' ', [$userId, $email, $name]),
'accessedAt' => DateTime::now(),
]);
$user->removeAttribute('$internalId');
Authorization::skip(fn() => $dbForProject->createDocument('users', $user));
} catch (Duplicate) {
$failureRedirect(Exception::USER_ALREADY_EXISTS);
@ -756,7 +759,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
$session->setAttribute('expire', $expire);
$events
$queueForEvents
->setParam('userId', $user->getId())
->setParam('sessionId', $session->getId())
->setPayload($response->output($session, Response::MODEL_SESSION))
@ -870,7 +873,7 @@ App::delete('/v1/account/identities/:identityId')
});
App::post('/v1/account/sessions/magic-url')
->desc('Create Magic URL session')
->desc('Create magic URL session')
->groups(['api', 'account'])
->label('scope', 'public')
->label('auth.type', 'magic-url')
@ -895,9 +898,9 @@ App::post('/v1/account/sessions/magic-url')
->inject('project')
->inject('dbForProject')
->inject('locale')
->inject('events')
->inject('mails')
->action(function (string $userId, string $email, string $url, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Locale $locale, Event $events, Mail $mails) {
->inject('queueForEvents')
->inject('queueForMails')
->action(function (string $userId, string $email, string $url, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Locale $locale, Event $queueForEvents, Mail $queueForMails) {
if (empty(App::getEnv('_APP_SMTP_HOST'))) {
throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP disabled');
@ -955,6 +958,7 @@ App::post('/v1/account/sessions/magic-url')
'accessedAt' => DateTime::now(),
]);
$user->removeAttribute('$internalId');
Authorization::skip(fn () => $dbForProject->createDocument('users', $user));
}
@ -1017,7 +1021,7 @@ App::post('/v1/account/sessions/magic-url')
$replyTo = $smtp['replyTo'];
}
$mails
$queueForMails
->setSmtpHost($smtp['host'] ?? '')
->setSmtpPort($smtp['port'] ?? '')
->setSmtpUsername($smtp['username'] ?? '')
@ -1039,7 +1043,7 @@ App::post('/v1/account/sessions/magic-url')
$subject = $customTemplate['subject'] ?? $subject;
}
$mails
$queueForMails
->setSmtpReplyTo($replyTo)
->setSmtpSenderEmail($senderEmail)
->setSmtpSenderName($senderName);
@ -1063,14 +1067,14 @@ App::post('/v1/account/sessions/magic-url')
'redirect' => $url
];
$mails
$queueForMails
->setSubject($subject)
->setBody($body)
->setVariables($emailVariables)
->setRecipient($email)
->trigger();
$events->setPayload(
$queueForEvents->setPayload(
$response->output(
$token->setAttribute('secret', $loginSecret),
Response::MODEL_TOKEN
@ -1087,7 +1091,7 @@ App::post('/v1/account/sessions/magic-url')
});
App::put('/v1/account/sessions/magic-url')
->desc('Create Magic URL session (confirmation)')
->desc('Create magic URL session (confirmation)')
->groups(['api', 'account', 'session'])
->label('scope', 'public')
->label('event', 'users.[userId].sessions.[sessionId].create')
@ -1114,8 +1118,8 @@ App::put('/v1/account/sessions/magic-url')
->inject('project')
->inject('locale')
->inject('geodb')
->inject('events')
->action(function (string $userId, string $secret, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Reader $geodb, Event $events) {
->inject('queueForEvents')
->action(function (string $userId, string $secret, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Reader $geodb, Event $queueForEvents) {
/** @var Utopia\Database\Document $user */
@ -1183,7 +1187,7 @@ App::put('/v1/account/sessions/magic-url')
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed saving user to DB');
}
$events
$queueForEvents
->setParam('userId', $user->getId())
->setParam('sessionId', $session->getId());
@ -1209,7 +1213,7 @@ App::put('/v1/account/sessions/magic-url')
});
App::post('/v1/account/sessions/phone')
->desc('Create Phone session')
->desc('Create phone session')
->groups(['api', 'account'])
->label('scope', 'public')
->label('auth.type', 'phone')
@ -1232,10 +1236,10 @@ App::post('/v1/account/sessions/phone')
->inject('user')
->inject('project')
->inject('dbForProject')
->inject('events')
->inject('messaging')
->inject('queueForEvents')
->inject('queueForMessaging')
->inject('locale')
->action(function (string $userId, string $phone, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Event $events, EventPhone $messaging, Locale $locale) {
->action(function (string $userId, string $phone, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Event $queueForEvents, EventPhone $queueForMessaging, Locale $locale) {
if (empty(App::getEnv('_APP_SMS_PROVIDER'))) {
throw new Exception(Exception::GENERAL_PHONE_DISABLED, 'Phone provider not configured');
@ -1284,6 +1288,7 @@ App::post('/v1/account/sessions/phone')
'accessedAt' => DateTime::now(),
]);
$user->removeAttribute('$internalId');
Authorization::skip(fn () => $dbForProject->createDocument('users', $user));
}
@ -1322,12 +1327,12 @@ App::post('/v1/account/sessions/phone')
$message = $message->setParam('{{token}}', $secret);
$message = $message->render();
$messaging
$queueForMessaging
->setRecipient($phone)
->setMessage($message)
->trigger();
$events->setPayload(
$queueForEvents->setPayload(
$response->output(
$token->setAttribute('secret', $secret),
Response::MODEL_TOKEN
@ -1344,7 +1349,7 @@ App::post('/v1/account/sessions/phone')
});
App::put('/v1/account/sessions/phone')
->desc('Create Phone Session (confirmation)')
->desc('Create phone session (confirmation)')
->groups(['api', 'account', 'session'])
->label('scope', 'public')
->label('event', 'users.[userId].sessions.[sessionId].create')
@ -1366,8 +1371,8 @@ App::put('/v1/account/sessions/phone')
->inject('project')
->inject('locale')
->inject('geodb')
->inject('events')
->action(function (string $userId, string $secret, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Reader $geodb, Event $events) {
->inject('queueForEvents')
->action(function (string $userId, string $secret, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Reader $geodb, Event $queueForEvents) {
$userFromRequest = Authorization::skip(fn() => $dbForProject->getDocument('users', $userId));
@ -1431,7 +1436,7 @@ App::put('/v1/account/sessions/phone')
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed saving user to DB');
}
$events
$queueForEvents
->setParam('userId', $user->getId())
->setParam('sessionId', $session->getId())
;
@ -1460,7 +1465,7 @@ App::put('/v1/account/sessions/phone')
});
App::post('/v1/account/sessions/anonymous')
->desc('Create Anonymous Session')
->desc('Create anonymous session')
->groups(['api', 'account', 'auth', 'session'])
->label('event', 'users.[userId].sessions.[sessionId].create')
->label('scope', 'public')
@ -1486,8 +1491,8 @@ App::post('/v1/account/sessions/anonymous')
->inject('project')
->inject('dbForProject')
->inject('geodb')
->inject('events')
->action(function (Request $request, Response $response, Locale $locale, Document $user, Document $project, Database $dbForProject, Reader $geodb, Event $events) {
->inject('queueForEvents')
->action(function (Request $request, Response $response, Locale $locale, Document $user, Document $project, Database $dbForProject, Reader $geodb, Event $queueForEvents) {
$protocol = $request->getProtocol();
@ -1534,6 +1539,7 @@ App::post('/v1/account/sessions/anonymous')
'search' => $userId,
'accessedAt' => DateTime::now(),
]);
$user->removeAttribute('$internalId');
Authorization::skip(fn() => $dbForProject->createDocument('users', $user));
// Create session token
@ -1569,7 +1575,7 @@ App::post('/v1/account/sessions/anonymous')
$dbForProject->deleteCachedDocument('users', $user->getId());
$events
$queueForEvents
->setParam('userId', $user->getId())
->setParam('sessionId', $session->getId())
;
@ -1643,7 +1649,7 @@ App::post('/v1/account/jwt')
});
App::get('/v1/account')
->desc('Get Account')
->desc('Get account')
->groups(['api', 'account'])
->label('scope', 'account')
->label('usage.metric', 'users.{scope}.requests.read')
@ -1664,7 +1670,7 @@ App::get('/v1/account')
});
App::get('/v1/account/prefs')
->desc('Get Account Preferences')
->desc('Get account preferences')
->groups(['api', 'account'])
->label('scope', 'account')
->label('usage.metric', 'users.{scope}.requests.read')
@ -1687,7 +1693,7 @@ App::get('/v1/account/prefs')
});
App::get('/v1/account/sessions')
->desc('List Sessions')
->desc('List sessions')
->groups(['api', 'account'])
->label('scope', 'account')
->label('usage.metric', 'users.{scope}.requests.read')
@ -1726,7 +1732,7 @@ App::get('/v1/account/sessions')
});
App::get('/v1/account/logs')
->desc('List Logs')
->desc('List logs')
->groups(['api', 'account'])
->label('scope', 'account')
->label('usage.metric', 'users.{scope}.requests.read')
@ -1787,7 +1793,7 @@ App::get('/v1/account/logs')
});
App::get('/v1/account/sessions/:sessionId')
->desc('Get Session')
->desc('Get session')
->groups(['api', 'account'])
->label('scope', 'account')
->label('usage.metric', 'users.{scope}.requests.read')
@ -1832,7 +1838,7 @@ App::get('/v1/account/sessions/:sessionId')
});
App::patch('/v1/account/name')
->desc('Update Name')
->desc('Update name')
->groups(['api', 'account'])
->label('event', 'users.[userId].update.name')
->label('scope', 'account')
@ -1853,20 +1859,20 @@ App::patch('/v1/account/name')
->inject('response')
->inject('user')
->inject('dbForProject')
->inject('events')
->action(function (string $name, ?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $events) {
->inject('queueForEvents')
->action(function (string $name, ?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $queueForEvents) {
$user->setAttribute('name', $name);
$user = $dbForProject->withRequestTimestamp($requestTimestamp, fn () => $dbForProject->updateDocument('users', $user->getId(), $user));
$events->setParam('userId', $user->getId());
$queueForEvents->setParam('userId', $user->getId());
$response->dynamic($user, Response::MODEL_ACCOUNT);
});
App::patch('/v1/account/password')
->desc('Update Password')
->desc('Update password')
->groups(['api', 'account'])
->label('event', 'users.[userId].update.password')
->label('scope', 'account')
@ -1890,8 +1896,8 @@ App::patch('/v1/account/password')
->inject('user')
->inject('project')
->inject('dbForProject')
->inject('events')
->action(function (string $password, string $oldPassword, ?\DateTime $requestTimestamp, Response $response, Document $user, Document $project, Database $dbForProject, Event $events) {
->inject('queueForEvents')
->action(function (string $password, string $oldPassword, ?\DateTime $requestTimestamp, Response $response, Document $user, Document $project, Database $dbForProject, Event $queueForEvents) {
// Check old password only if its an existing user.
if (!empty($user->getAttribute('passwordUpdate')) && !Auth::passwordVerify($oldPassword, $user->getAttribute('password'), $user->getAttribute('hash'), $user->getAttribute('hashOptions'))) { // Double check user password
@ -1927,13 +1933,13 @@ App::patch('/v1/account/password')
$user = $dbForProject->withRequestTimestamp($requestTimestamp, fn () => $dbForProject->updateDocument('users', $user->getId(), $user));
$events->setParam('userId', $user->getId());
$queueForEvents->setParam('userId', $user->getId());
$response->dynamic($user, Response::MODEL_ACCOUNT);
});
App::patch('/v1/account/email')
->desc('Update Email')
->desc('Update email')
->groups(['api', 'account'])
->label('event', 'users.[userId].update.email')
->label('scope', 'account')
@ -1955,8 +1961,8 @@ App::patch('/v1/account/email')
->inject('response')
->inject('user')
->inject('dbForProject')
->inject('events')
->action(function (string $email, string $password, ?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $events) {
->inject('queueForEvents')
->action(function (string $email, string $password, ?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $queueForEvents) {
// passwordUpdate will be empty if the user has never set a password
$passwordUpdate = $user->getAttribute('passwordUpdate');
@ -1997,13 +2003,13 @@ App::patch('/v1/account/email')
throw new Exception(Exception::USER_EMAIL_ALREADY_EXISTS);
}
$events->setParam('userId', $user->getId());
$queueForEvents->setParam('userId', $user->getId());
$response->dynamic($user, Response::MODEL_ACCOUNT);
});
App::patch('/v1/account/phone')
->desc('Update Phone')
->desc('Update phone')
->groups(['api', 'account'])
->label('event', 'users.[userId].update.phone')
->label('scope', 'account')
@ -2025,8 +2031,8 @@ App::patch('/v1/account/phone')
->inject('response')
->inject('user')
->inject('dbForProject')
->inject('events')
->action(function (string $phone, string $password, ?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $events) {
->inject('queueForEvents')
->action(function (string $phone, string $password, ?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $queueForEvents) {
// passwordUpdate will be empty if the user has never set a password
$passwordUpdate = $user->getAttribute('passwordUpdate');
@ -2056,13 +2062,13 @@ App::patch('/v1/account/phone')
throw new Exception(Exception::USER_PHONE_ALREADY_EXISTS);
}
$events->setParam('userId', $user->getId());
$queueForEvents->setParam('userId', $user->getId());
$response->dynamic($user, Response::MODEL_ACCOUNT);
});
App::patch('/v1/account/prefs')
->desc('Update Preferences')
->desc('Update preferences')
->groups(['api', 'account'])
->label('event', 'users.[userId].update.prefs')
->label('scope', 'account')
@ -2083,20 +2089,20 @@ App::patch('/v1/account/prefs')
->inject('response')
->inject('user')
->inject('dbForProject')
->inject('events')
->action(function (array $prefs, ?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $events) {
->inject('queueForEvents')
->action(function (array $prefs, ?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $queueForEvents) {
$user->setAttribute('prefs', $prefs);
$user = $dbForProject->withRequestTimestamp($requestTimestamp, fn () => $dbForProject->updateDocument('users', $user->getId(), $user));
$events->setParam('userId', $user->getId());
$queueForEvents->setParam('userId', $user->getId());
$response->dynamic($user, Response::MODEL_ACCOUNT);
});
App::patch('/v1/account/status')
->desc('Update Status')
->desc('Update status')
->groups(['api', 'account'])
->label('event', 'users.[userId].update.status')
->label('scope', 'account')
@ -2115,14 +2121,14 @@ App::patch('/v1/account/status')
->inject('response')
->inject('user')
->inject('dbForProject')
->inject('events')
->action(function (?\DateTime $requestTimestamp, Request $request, Response $response, Document $user, Database $dbForProject, Event $events) {
->inject('queueForEvents')
->action(function (?\DateTime $requestTimestamp, Request $request, Response $response, Document $user, Database $dbForProject, Event $queueForEvents) {
$user->setAttribute('status', false);
$user = $dbForProject->withRequestTimestamp($requestTimestamp, fn () => $dbForProject->updateDocument('users', $user->getId(), $user));
$events
$queueForEvents
->setParam('userId', $user->getId())
->setPayload($response->output($user, Response::MODEL_ACCOUNT));
@ -2140,7 +2146,7 @@ App::patch('/v1/account/status')
});
App::delete('/v1/account/sessions/:sessionId')
->desc('Delete Session')
->desc('Delete session')
->groups(['api', 'account'])
->label('scope', 'account')
->label('event', 'users.[userId].sessions.[sessionId].delete')
@ -2161,9 +2167,9 @@ App::delete('/v1/account/sessions/:sessionId')
->inject('user')
->inject('dbForProject')
->inject('locale')
->inject('events')
->inject('queueForEvents')
->inject('project')
->action(function (?string $sessionId, ?\DateTime $requestTimestamp, Request $request, Response $response, Document $user, Database $dbForProject, Locale $locale, Event $events, Document $project) {
->action(function (?string $sessionId, ?\DateTime $requestTimestamp, Request $request, Response $response, Document $user, Database $dbForProject, Locale $locale, Event $queueForEvents, Document $project) {
$protocol = $request->getProtocol();
$authDuration = $project->getAttribute('auths', [])['duration'] ?? Auth::TOKEN_EXPIRATION_LOGIN_LONG;
@ -2203,7 +2209,7 @@ App::delete('/v1/account/sessions/:sessionId')
$dbForProject->deleteCachedDocument('users', $user->getId());
$events
$queueForEvents
->setParam('userId', $user->getId())
->setParam('sessionId', $session->getId())
->setPayload($response->output($session, Response::MODEL_SESSION))
@ -2216,7 +2222,7 @@ App::delete('/v1/account/sessions/:sessionId')
});
App::patch('/v1/account/sessions/:sessionId')
->desc('Update OAuth Session (Refresh Tokens)')
->desc('Update OAuth session (refresh tokens)')
->groups(['api', 'account'])
->label('scope', 'account')
->label('event', 'users.[userId].sessions.[sessionId].update')
@ -2239,8 +2245,8 @@ App::patch('/v1/account/sessions/:sessionId')
->inject('dbForProject')
->inject('project')
->inject('locale')
->inject('events')
->action(function (?string $sessionId, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Event $events) {
->inject('queueForEvents')
->action(function (?string $sessionId, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Event $queueForEvents) {
$authDuration = $project->getAttribute('auths', [])['duration'] ?? Auth::TOKEN_EXPIRATION_LOGIN_LONG;
$sessionId = ($sessionId === 'current')
? Auth::sessionVerify($user->getAttribute('sessions'), Auth::$secret, $authDuration)
@ -2288,7 +2294,7 @@ App::patch('/v1/account/sessions/:sessionId')
$session->setAttribute('expire', DateTime::formatTz(DateTime::addSeconds(new \DateTime($session->getCreatedAt()), $authDuration)));
$events
$queueForEvents
->setParam('userId', $user->getId())
->setParam('sessionId', $session->getId())
->setPayload($response->output($session, Response::MODEL_SESSION))
@ -2302,7 +2308,7 @@ App::patch('/v1/account/sessions/:sessionId')
});
App::delete('/v1/account/sessions')
->desc('Delete Sessions')
->desc('Delete sessions')
->groups(['api', 'account'])
->label('scope', 'account')
->label('event', 'users.[userId].sessions.[sessionId].delete')
@ -2321,8 +2327,8 @@ App::delete('/v1/account/sessions')
->inject('user')
->inject('dbForProject')
->inject('locale')
->inject('events')
->action(function (Request $request, Response $response, Document $user, Database $dbForProject, Locale $locale, Event $events) {
->inject('queueForEvents')
->action(function (Request $request, Response $response, Document $user, Database $dbForProject, Locale $locale, Event $queueForEvents) {
$protocol = $request->getProtocol();
$sessions = $user->getAttribute('sessions', []);
@ -2349,13 +2355,13 @@ App::delete('/v1/account/sessions')
->addCookie(Auth::$cookieName, '', \time() - 3600, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, Config::getParam('cookieSamesite'));
// Use current session for events.
$events->setPayload($response->output($session, Response::MODEL_SESSION));
$queueForEvents->setPayload($response->output($session, Response::MODEL_SESSION));
}
}
$dbForProject->deleteCachedDocument('users', $user->getId());
$events
$queueForEvents
->setParam('userId', $user->getId())
->setParam('sessionId', $session->getId());
@ -2363,7 +2369,7 @@ App::delete('/v1/account/sessions')
});
App::post('/v1/account/recovery')
->desc('Create Password Recovery')
->desc('Create password recovery')
->groups(['api', 'account'])
->label('scope', 'public')
->label('event', 'users.[userId].recovery.[tokenId].create')
@ -2388,9 +2394,9 @@ App::post('/v1/account/recovery')
->inject('dbForProject')
->inject('project')
->inject('locale')
->inject('mails')
->inject('events')
->action(function (string $email, string $url, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Mail $mails, Event $events) {
->inject('queueForMails')
->inject('queueForEvents')
->action(function (string $email, string $url, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Mail $queueForMails, Event $queueForEvents) {
if (empty(App::getEnv('_APP_SMTP_HOST'))) {
throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP Disabled');
@ -2472,7 +2478,7 @@ App::post('/v1/account/recovery')
$replyTo = $smtp['replyTo'];
}
$mails
$queueForMails
->setSmtpHost($smtp['host'] ?? '')
->setSmtpPort($smtp['port'] ?? '')
->setSmtpUsername($smtp['username'] ?? '')
@ -2494,7 +2500,7 @@ App::post('/v1/account/recovery')
$subject = $customTemplate['subject'] ?? $subject;
}
$mails
$queueForMails
->setSmtpReplyTo($replyTo)
->setSmtpSenderEmail($senderEmail)
->setSmtpSenderName($senderName);
@ -2519,7 +2525,7 @@ App::post('/v1/account/recovery')
];
$mails
$queueForMails
->setRecipient($profile->getAttribute('email', ''))
->setName($profile->getAttribute('name'))
->setBody($body)
@ -2527,7 +2533,7 @@ App::post('/v1/account/recovery')
->setSubject($subject)
->trigger();
$events
$queueForEvents
->setParam('userId', $profile->getId())
->setParam('tokenId', $recovery->getId())
->setUser($profile)
@ -2546,7 +2552,7 @@ App::post('/v1/account/recovery')
});
App::put('/v1/account/recovery')
->desc('Create Password Recovery (confirmation)')
->desc('Create password recovery (confirmation)')
->groups(['api', 'account'])
->label('scope', 'public')
->label('event', 'users.[userId].recovery.[tokenId].update')
@ -2571,8 +2577,8 @@ App::put('/v1/account/recovery')
->inject('user')
->inject('dbForProject')
->inject('project')
->inject('events')
->action(function (string $userId, string $secret, string $password, string $passwordAgain, Response $response, Document $user, Database $dbForProject, Document $project, Event $events) {
->inject('queueForEvents')
->action(function (string $userId, string $secret, string $password, string $passwordAgain, Response $response, Document $user, Database $dbForProject, Document $project, Event $queueForEvents) {
if ($password !== $passwordAgain) {
throw new Exception(Exception::USER_PASSWORD_MISMATCH);
}
@ -2625,7 +2631,7 @@ App::put('/v1/account/recovery')
$dbForProject->deleteDocument('tokens', $recovery);
$dbForProject->deleteCachedDocument('users', $profile->getId());
$events
$queueForEvents
->setParam('userId', $profile->getId())
->setParam('tokenId', $recoveryDocument->getId())
;
@ -2634,7 +2640,7 @@ App::put('/v1/account/recovery')
});
App::post('/v1/account/verification')
->desc('Create Email Verification')
->desc('Create email verification')
->groups(['api', 'account'])
->label('scope', 'account')
->label('event', 'users.[userId].verification.[tokenId].create')
@ -2657,9 +2663,9 @@ App::post('/v1/account/verification')
->inject('user')
->inject('dbForProject')
->inject('locale')
->inject('events')
->inject('mails')
->action(function (string $url, Request $request, Response $response, Document $project, Document $user, Database $dbForProject, Locale $locale, Event $events, Mail $mails) {
->inject('queueForEvents')
->inject('queueForMails')
->action(function (string $url, Request $request, Response $response, Document $project, Document $user, Database $dbForProject, Locale $locale, Event $queueForEvents, Mail $queueForMails) {
if (empty(App::getEnv('_APP_SMTP_HOST'))) {
throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP Disabled');
@ -2724,7 +2730,7 @@ App::post('/v1/account/verification')
$replyTo = $smtp['replyTo'];
}
$mails
$queueForMails
->setSmtpHost($smtp['host'] ?? '')
->setSmtpPort($smtp['port'] ?? '')
->setSmtpUsername($smtp['username'] ?? '')
@ -2746,7 +2752,7 @@ App::post('/v1/account/verification')
$subject = $customTemplate['subject'] ?? $subject;
}
$mails
$queueForMails
->setSmtpReplyTo($replyTo)
->setSmtpSenderEmail($senderEmail)
->setSmtpSenderName($senderName);
@ -2770,7 +2776,7 @@ App::post('/v1/account/verification')
'redirect' => $url
];
$mails
$queueForMails
->setSubject($subject)
->setBody($body)
->setVariables($emailVariables)
@ -2778,7 +2784,7 @@ App::post('/v1/account/verification')
->setName($user->getAttribute('name') ?? '')
->trigger();
$events
$queueForEvents
->setParam('userId', $user->getId())
->setParam('tokenId', $verification->getId())
->setPayload($response->output(
@ -2795,7 +2801,7 @@ App::post('/v1/account/verification')
});
App::put('/v1/account/verification')
->desc('Create Email Verification (confirmation)')
->desc('Create email verification (confirmation)')
->groups(['api', 'account'])
->label('scope', 'public')
->label('event', 'users.[userId].verification.[tokenId].update')
@ -2816,8 +2822,8 @@ App::put('/v1/account/verification')
->inject('response')
->inject('user')
->inject('dbForProject')
->inject('events')
->action(function (string $userId, string $secret, Response $response, Document $user, Database $dbForProject, Event $events) {
->inject('queueForEvents')
->action(function (string $userId, string $secret, Response $response, Document $user, Database $dbForProject, Event $queueForEvents) {
$profile = Authorization::skip(fn() => $dbForProject->getDocument('users', $userId));
@ -2847,7 +2853,7 @@ App::put('/v1/account/verification')
$dbForProject->deleteDocument('tokens', $verification);
$dbForProject->deleteCachedDocument('users', $profile->getId());
$events
$queueForEvents
->setParam('userId', $userId)
->setParam('tokenId', $verificationDocument->getId())
;
@ -2856,7 +2862,7 @@ App::put('/v1/account/verification')
});
App::post('/v1/account/verification/phone')
->desc('Create Phone Verification')
->desc('Create phone verification')
->groups(['api', 'account'])
->label('scope', 'account')
->label('event', 'users.[userId].verification.[tokenId].create')
@ -2876,11 +2882,11 @@ App::post('/v1/account/verification/phone')
->inject('response')
->inject('user')
->inject('dbForProject')
->inject('events')
->inject('messaging')
->inject('queueForEvents')
->inject('queueForMessaging')
->inject('project')
->inject('locale')
->action(function (Request $request, Response $response, Document $user, Database $dbForProject, Event $events, EventPhone $messaging, Document $project, Locale $locale) {
->action(function (Request $request, Response $response, Document $user, Database $dbForProject, Event $queueForEvents, EventPhone $queueForMessaging, Document $project, Locale $locale) {
if (empty(App::getEnv('_APP_SMS_PROVIDER'))) {
throw new Exception(Exception::GENERAL_PHONE_DISABLED);
@ -2928,13 +2934,13 @@ App::post('/v1/account/verification/phone')
$message = $message->setParam('{{token}}', $secret);
$message = $message->render();
$messaging
$queueForMessaging
->setRecipient($user->getAttribute('phone'))
->setMessage($message)
->trigger()
;
$events
$queueForEvents
->setParam('userId', $user->getId())
->setParam('tokenId', $verification->getId())
->setPayload($response->output(
@ -2952,7 +2958,7 @@ App::post('/v1/account/verification/phone')
});
App::put('/v1/account/verification/phone')
->desc('Create Phone Verification (confirmation)')
->desc('Create phone verification (confirmation)')
->groups(['api', 'account'])
->label('scope', 'public')
->label('event', 'users.[userId].verification.[tokenId].update')
@ -2973,8 +2979,8 @@ App::put('/v1/account/verification/phone')
->inject('response')
->inject('user')
->inject('dbForProject')
->inject('events')
->action(function (string $userId, string $secret, Response $response, Document $user, Database $dbForProject, Event $events) {
->inject('queueForEvents')
->action(function (string $userId, string $secret, Response $response, Document $user, Database $dbForProject, Event $queueForEvents) {
$profile = Authorization::skip(fn() => $dbForProject->getDocument('users', $userId));
@ -3002,7 +3008,7 @@ App::put('/v1/account/verification/phone')
$dbForProject->deleteDocument('tokens', $verification);
$dbForProject->deleteCachedDocument('users', $profile->getId());
$events
$queueForEvents
->setParam('userId', $user->getId())
->setParam('tokenId', $verificationDocument->getId())
;

View file

@ -191,7 +191,7 @@ $getUserGitHub = function (string $userId, Document $project, Database $dbForPro
};
App::get('/v1/avatars/credit-cards/:code')
->desc('Get Credit Card Icon')
->desc('Get credit card icon')
->groups(['api', 'avatars'])
->label('scope', 'avatars.read')
->label('cache', true)
@ -211,7 +211,7 @@ App::get('/v1/avatars/credit-cards/:code')
->action(fn (string $code, int $width, int $height, int $quality, Response $response) => $avatarCallback('credit-cards', $code, $width, $height, $quality, $response));
App::get('/v1/avatars/browsers/:code')
->desc('Get Browser Icon')
->desc('Get browser icon')
->groups(['api', 'avatars'])
->label('scope', 'avatars.read')
->label('cache', true)
@ -231,7 +231,7 @@ App::get('/v1/avatars/browsers/:code')
->action(fn (string $code, int $width, int $height, int $quality, Response $response) => $avatarCallback('browsers', $code, $width, $height, $quality, $response));
App::get('/v1/avatars/flags/:code')
->desc('Get Country Flag')
->desc('Get country flag')
->groups(['api', 'avatars'])
->label('scope', 'avatars.read')
->label('cache', true)
@ -251,7 +251,7 @@ App::get('/v1/avatars/flags/:code')
->action(fn (string $code, int $width, int $height, int $quality, Response $response) => $avatarCallback('flags', $code, $width, $height, $quality, $response));
App::get('/v1/avatars/image')
->desc('Get Image from URL')
->desc('Get image from URL')
->groups(['api', 'avatars'])
->label('scope', 'avatars.read')
->label('cache', true)
@ -307,7 +307,7 @@ App::get('/v1/avatars/image')
});
App::get('/v1/avatars/favicon')
->desc('Get Favicon')
->desc('Get favicon')
->groups(['api', 'avatars'])
->label('scope', 'avatars.read')
->label('cache', true)
@ -449,7 +449,7 @@ App::get('/v1/avatars/favicon')
});
App::get('/v1/avatars/qr')
->desc('Get QR Code')
->desc('Get QR code')
->groups(['api', 'avatars'])
->label('scope', 'avatars.read')
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
@ -489,7 +489,7 @@ App::get('/v1/avatars/qr')
});
App::get('/v1/avatars/initials')
->desc('Get User Initials')
->desc('Get user initials')
->groups(['api', 'avatars'])
->label('scope', 'avatars.read')
->label('cache.resource', 'avatar/initials')
@ -509,12 +509,11 @@ App::get('/v1/avatars/initials')
->action(function (string $name, int $width, int $height, string $background, Response $response, Document $user) {
$themes = [
['background' => '#FFA1CE'], // Default (Pink)
['background' => '#FDC584'], // Orange
['background' => '#94DBD1'], // Green
['background' => '#A1C4FF'], // Blue
['background' => '#FFA1CE'], // Pink
['background' => '#CBB1FC'] // Purple
['background' => '#FD366E'], // Default (Pink)
['background' => '#FE9567'], // Orange
['background' => '#7C67FE'], // Purple
['background' => '#68A3FE'], // Blue
['background' => '#85DBD8'], // Mint
];
$name = (!empty($name)) ? $name : $user->getAttribute('name', $user->getAttribute('email', ''));
@ -526,11 +525,13 @@ App::get('/v1/avatars/initials')
$code = 0;
foreach ($words as $key => $w) {
$initials .= $w[0] ?? '';
$code += (isset($w[0])) ? \ord($w[0]) : 0;
if (ctype_alnum($w[0] ?? '')) {
$initials .= $w[0];
$code += ord($w[0]);
if ($key == 1) {
break;
if ($key == 1) {
break;
}
}
}
@ -548,8 +549,8 @@ App::get('/v1/avatars/initials')
$punch->newImage($width, $height, 'transparent');
$draw->setFont(__DIR__ . "/../../assets/fonts/poppins-v9-latin-500.ttf");
$image->setFont(__DIR__ . "/../../assets/fonts/poppins-v9-latin-500.ttf");
$draw->setFont(__DIR__ . "/../../assets/fonts/inter-v8-latin-regular.woff2");
$image->setFont(__DIR__ . "/../../assets/fonts/inter-v8-latin-regular.woff2");
$draw->setFillColor(new ImagickPixel('black'));
$draw->setFontSize($fontSize);
@ -724,7 +725,7 @@ App::get('/v1/cards/cloud')
$text = new \ImagickDraw();
$text->setTextAlignment(Imagick::ALIGN_CENTER);
$text->setFont(__DIR__ . '/../../../public/fonts/Poppins-Bold.ttf');
$text->setFont(__DIR__ . '/../../../public/fonts/Inter-Bold.ttf');
$text->setFillColor(new \ImagickPixel('#FFFFFF'));
if (\strlen($name) > 32) {
@ -1108,7 +1109,7 @@ App::get('/v1/cards/cloud-og')
$textName = new \ImagickDraw();
$textName->setTextAlignment(Imagick::ALIGN_CENTER);
$textName->setFont(__DIR__ . '/../../../public/fonts/Poppins-Bold.ttf');
$textName->setFont(__DIR__ . '/../../../public/fonts/Inter-Bold.ttf');
$textName->setFillColor(new \ImagickPixel('#FFFFFF'));
if (\strlen($name) > 32) {

View file

@ -17,7 +17,7 @@ App::init()
App::get('/v1/console/variables')
->desc('Get Variables')
->desc('Get variables')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])

File diff suppressed because it is too large Load diff

View file

@ -6,8 +6,7 @@ use Appwrite\Event\Build;
use Appwrite\Event\Delete;
use Appwrite\Event\Event;
use Appwrite\Event\Func;
use Appwrite\Event\Usage;
use Appwrite\Event\Validator\Event as ValidatorEvent;
use Appwrite\Event\Validator\FunctionEvent;
use Appwrite\Utopia\Response\Model\Rule;
use Appwrite\Extend\Exception;
use Appwrite\Utopia\Database\Validator\CustomId;
@ -50,7 +49,7 @@ use Utopia\VCS\Adapter\Git\GitHub;
include_once __DIR__ . '/../shared/api.php';
$redeployVcs = function (Request $request, Document $function, Document $project, Document $installation, Database $dbForProject, Document $template, GitHub $github) {
$redeployVcs = function (Request $request, Document $function, Document $project, Document $installation, Database $dbForProject, Build $queueForBuilds, Document $template, GitHub $github) {
$deploymentId = ID::unique();
$entrypoint = $function->getAttribute('entrypoint', '');
$providerInstallationId = $installation->getAttribute('providerInstallationId', '');
@ -84,6 +83,7 @@ $redeployVcs = function (Request $request, Document $function, Document $project
Permission::delete(Role::any()),
],
'resourceId' => $function->getId(),
'resourceInternalId' => $function->getInternalId(),
'resourceType' => 'functions',
'entrypoint' => $entrypoint,
'commands' => $function->getAttribute('commands', ''),
@ -108,8 +108,7 @@ $redeployVcs = function (Request $request, Document $function, Document $project
'activate' => true,
]));
$buildEvent = new Build();
$buildEvent
$queueForBuilds
->setType(BUILD_TYPE_DEPLOYMENT)
->setResource($function)
->setDeployment($deployment)
@ -120,7 +119,7 @@ $redeployVcs = function (Request $request, Document $function, Document $project
App::post('/v1/functions')
->groups(['api', 'functions'])
->desc('Create Function')
->desc('Create function')
->label('scope', 'functions.write')
->label('event', 'functions.[functionId].create')
->label('audits.event', 'function.create')
@ -136,7 +135,7 @@ App::post('/v1/functions')
->param('name', '', new Text(128), 'Function name. Max length: 128 chars.')
->param('runtime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Execution runtime.')
->param('execute', [], new Roles(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' roles are allowed, each 64 characters long.', true)
->param('events', [], new ArrayList(new ValidatorEvent(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Events list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.', true)
->param('events', [], new ArrayList(new FunctionEvent(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Events list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.', true)
->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true)
->param('timeout', 15, new Range(1, (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)), 'Function maximum execution time in seconds.', true)
->param('enabled', true, new Boolean(), 'Is function enabled? When set to \'disabled\', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.', true)
@ -157,10 +156,11 @@ App::post('/v1/functions')
->inject('dbForProject')
->inject('project')
->inject('user')
->inject('events')
->inject('queueForEvents')
->inject('queueForBuilds')
->inject('dbForConsole')
->inject('gitHub')
->action(function (string $functionId, string $name, string $runtime, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $commands, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateBranch, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $eventsInstance, Database $dbForConsole, GitHub $github) use ($redeployVcs) {
->action(function (string $functionId, string $name, string $runtime, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $commands, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateBranch, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) use ($redeployVcs) {
$functionId = ($functionId == 'unique()') ? ID::unique() : $functionId;
// build from template
@ -260,7 +260,7 @@ App::post('/v1/functions')
// Redeploy vcs logic
if (!empty($providerRepositoryId)) {
$redeployVcs($request, $function, $project, $installation, $dbForProject, $template, $github);
$redeployVcs($request, $function, $project, $installation, $dbForProject, $queueForBuilds, $template, $github);
}
$functionsDomain = App::getEnv('_APP_DOMAIN_FUNCTIONS', '');
@ -285,7 +285,12 @@ App::post('/v1/functions')
/** Trigger Webhook */
$ruleModel = new Rule();
$ruleCreate = new Event(Event::WEBHOOK_QUEUE_NAME, Event::WEBHOOK_CLASS_NAME);
$ruleCreate =
$queueForEvents
->setClass(Event::WEBHOOK_CLASS_NAME)
->setQueue(Event::WEBHOOK_QUEUE_NAME)
;
$ruleCreate
->setProject($project)
->setEvent('rules.[ruleId].create')
@ -325,7 +330,7 @@ App::post('/v1/functions')
);
}
$eventsInstance->setParam('functionId', $function->getId());
$queueForEvents->setParam('functionId', $function->getId());
$response
->setStatusCode(Response::STATUS_CODE_CREATED)
@ -334,7 +339,7 @@ App::post('/v1/functions')
App::get('/v1/functions')
->groups(['api', 'functions'])
->desc('List Functions')
->desc('List functions')
->label('scope', 'functions.read')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'functions')
@ -409,7 +414,7 @@ App::get('/v1/functions/runtimes')
App::get('/v1/functions/:functionId')
->groups(['api', 'functions'])
->desc('Get Function')
->desc('Get function')
->label('scope', 'functions.read')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'functions')
@ -432,7 +437,7 @@ App::get('/v1/functions/:functionId')
});
App::get('/v1/functions/:functionId/usage')
->desc('Get Function Usage')
->desc('Get function usage')
->groups(['api', 'functions', 'usage'])
->label('scope', 'functions.read')
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
@ -529,7 +534,7 @@ App::get('/v1/functions/:functionId/usage')
'range' => $range,
'executionsTotal' => $stats["executions.$functionId.compute.total"] ?? [],
'executionsFailure' => $stats["executions.$functionId.compute.failure"] ?? [],
'executionsSuccesse' => $stats["executions.$functionId.compute.success"] ?? [],
'executionsSuccess' => $stats["executions.$functionId.compute.success"] ?? [],
'executionsTime' => $stats["executions.$functionId.compute.time"] ?? [],
'buildsTotal' => $stats["builds.$functionId.compute.total"] ?? [],
'buildsFailure' => $stats["builds.$functionId.compute.failure"] ?? [],
@ -542,7 +547,7 @@ App::get('/v1/functions/:functionId/usage')
});
App::get('/v1/functions/usage')
->desc('Get Functions Usage')
->desc('Get functions usage')
->groups(['api', 'functions', 'usage'])
->label('scope', 'functions.read')
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
@ -646,7 +651,7 @@ App::get('/v1/functions/usage')
App::put('/v1/functions/:functionId')
->groups(['api', 'functions'])
->desc('Update Function')
->desc('Update function')
->label('scope', 'functions.write')
->label('event', 'functions.[functionId].update')
->label('audits.event', 'function.update')
@ -662,7 +667,7 @@ App::put('/v1/functions/:functionId')
->param('name', '', new Text(128), 'Function name. Max length: 128 chars.')
->param('runtime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Execution runtime.', true)
->param('execute', [], new Roles(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' roles are allowed, each 64 characters long.', true)
->param('events', [], new ArrayList(new ValidatorEvent(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Events list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.', true)
->param('events', [], new ArrayList(new FunctionEvent(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Events list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.', true)
->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true)
->param('timeout', 15, new Range(1, (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)), 'Maximum execution time in seconds.', true)
->param('enabled', true, new Boolean(), 'Is function enabled? When set to \'disabled\', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.', true)
@ -678,10 +683,11 @@ App::put('/v1/functions/:functionId')
->inject('response')
->inject('dbForProject')
->inject('project')
->inject('events')
->inject('queueForEvents')
->inject('queueForBuilds')
->inject('dbForConsole')
->inject('gitHub')
->action(function (string $functionId, string $name, string $runtime, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $commands, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, Request $request, Response $response, Database $dbForProject, Document $project, Event $eventsInstance, Database $dbForConsole, GitHub $github) use ($redeployVcs) {
->action(function (string $functionId, string $name, string $runtime, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $commands, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, Request $request, Response $response, Database $dbForProject, Document $project, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) use ($redeployVcs) {
// TODO: If only branch changes, re-deploy
$function = $dbForProject->getDocument('functions', $functionId);
@ -806,7 +812,7 @@ App::put('/v1/functions/:functionId')
// Redeploy logic
if (!$isConnected && !empty($providerRepositoryId)) {
$redeployVcs($request, $function, $project, $installation, $dbForProject, new Document(), $github);
$redeployVcs($request, $function, $project, $installation, $dbForProject, $queueForBuilds, new Document(), $github);
}
// Inform scheduler if function is still active
@ -817,7 +823,7 @@ App::put('/v1/functions/:functionId')
->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment')));
Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule));
$eventsInstance->setParam('functionId', $function->getId());
$queueForEvents->setParam('functionId', $function->getId());
$response->dynamic($function, Response::MODEL_FUNCTION);
});
@ -911,7 +917,7 @@ App::get('/v1/functions/:functionId/deployments/:deploymentId/download')
App::patch('/v1/functions/:functionId/deployments/:deploymentId')
->groups(['api', 'functions'])
->desc('Update Function Deployment')
->desc('Update function deployment')
->label('scope', 'functions.write')
->label('event', 'functions.[functionId].deployments.[deploymentId].update')
->label('audits.event', 'deployment.update')
@ -927,9 +933,9 @@ App::patch('/v1/functions/:functionId/deployments/:deploymentId')
->param('deploymentId', '', new UID(), 'Deployment ID.')
->inject('response')
->inject('dbForProject')
->inject('events')
->inject('queueForEvents')
->inject('dbForConsole')
->action(function (string $functionId, string $deploymentId, Response $response, Database $dbForProject, Event $events, Database $dbForConsole) {
->action(function (string $functionId, string $deploymentId, Response $response, Database $dbForProject, Event $queueForEvents, Database $dbForConsole) {
$function = $dbForProject->getDocument('functions', $functionId);
$deployment = $dbForProject->getDocument('deployments', $deploymentId);
@ -964,7 +970,7 @@ App::patch('/v1/functions/:functionId/deployments/:deploymentId')
->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment')));
Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule));
$events
$queueForEvents
->setParam('functionId', $function->getId())
->setParam('deploymentId', $deployment->getId());
@ -973,7 +979,7 @@ App::patch('/v1/functions/:functionId/deployments/:deploymentId')
App::delete('/v1/functions/:functionId')
->groups(['api', 'functions'])
->desc('Delete Function')
->desc('Delete function')
->label('scope', 'functions.write')
->label('event', 'functions.[functionId].delete')
->label('audits.event', 'function.delete')
@ -987,10 +993,10 @@ App::delete('/v1/functions/:functionId')
->param('functionId', '', new UID(), 'Function ID.')
->inject('response')
->inject('dbForProject')
->inject('deletes')
->inject('events')
->inject('queueForDeletes')
->inject('queueForEvents')
->inject('dbForConsole')
->action(function (string $functionId, Response $response, Database $dbForProject, Delete $deletes, Event $events, Database $dbForConsole) {
->action(function (string $functionId, Response $response, Database $dbForProject, Delete $queueForDeletes, Event $queueForEvents, Database $dbForConsole) {
$function = $dbForProject->getDocument('functions', $functionId);
@ -1009,18 +1015,18 @@ App::delete('/v1/functions/:functionId')
->setAttribute('active', false);
Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule));
$deletes
$queueForDeletes
->setType(DELETE_TYPE_DOCUMENT)
->setDocument($function);
$events->setParam('functionId', $function->getId());
$queueForEvents->setParam('functionId', $function->getId());
$response->noContent();
});
App::post('/v1/functions/:functionId/deployments')
->groups(['api', 'functions'])
->desc('Create Deployment')
->desc('Create deployment')
->label('scope', 'functions.write')
->label('event', 'functions.[functionId].deployments.[deploymentId].create')
->label('audits.event', 'deployment.create')
@ -1042,11 +1048,13 @@ App::post('/v1/functions/:functionId/deployments')
->inject('request')
->inject('response')
->inject('dbForProject')
->inject('events')
->inject('queueForEvents')
->inject('project')
->inject('deviceFunctions')
->inject('deviceLocal')
->action(function (string $functionId, ?string $entrypoint, ?string $commands, mixed $code, mixed $activate, Request $request, Response $response, Database $dbForProject, Event $events, Document $project, Device $deviceFunctions, Device $deviceLocal) {
->inject('queueForBuilds')
->action(function (string $functionId, ?string $entrypoint, ?string $commands, mixed $code, bool $activate, Request $request, Response $response, Database $dbForProject, Event $queueForEvents, Document $project, Device $deviceFunctions, Device $deviceLocal, Build $queueForBuilds) {
$activate = filter_var($activate, FILTER_VALIDATE_BOOLEAN);
$function = $dbForProject->getDocument('functions', $functionId);
@ -1079,7 +1087,7 @@ App::post('/v1/functions/:functionId/deployments')
}
$fileExt = new FileExt([FileExt::TYPE_GZIP]);
$fileSizeValidator = new FileSize(App::getEnv('_APP_FUNCTIONS_SIZE_LIMIT', 0));
$fileSizeValidator = new FileSize(App::getEnv('_APP_FUNCTIONS_SIZE_LIMIT', '30000000'));
$upload = new Upload();
// Make sure we handle a single file and multiple files the same way
@ -1190,8 +1198,7 @@ App::post('/v1/functions/:functionId/deployments')
}
// Start the build
$buildEvent = new Build();
$buildEvent
$queueForBuilds
->setType(BUILD_TYPE_DEPLOYMENT)
->setResource($function)
->setDeployment($deployment)
@ -1228,7 +1235,7 @@ App::post('/v1/functions/:functionId/deployments')
$metadata = null;
$events
$queueForEvents
->setParam('functionId', $function->getId())
->setParam('deploymentId', $deployment->getId());
@ -1239,7 +1246,7 @@ App::post('/v1/functions/:functionId/deployments')
App::get('/v1/functions/:functionId/deployments')
->groups(['api', 'functions'])
->desc('List Deployments')
->desc('List deployments')
->label('scope', 'functions.read')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'functions')
@ -1309,7 +1316,7 @@ App::get('/v1/functions/:functionId/deployments')
App::get('/v1/functions/:functionId/deployments/:deploymentId')
->groups(['api', 'functions'])
->desc('Get Deployment')
->desc('Get deployment')
->label('scope', 'functions.read')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'functions')
@ -1351,7 +1358,7 @@ App::get('/v1/functions/:functionId/deployments/:deploymentId')
App::delete('/v1/functions/:functionId/deployments/:deploymentId')
->groups(['api', 'functions'])
->desc('Delete Deployment')
->desc('Delete deployment')
->label('scope', 'functions.write')
->label('event', 'functions.[functionId].deployments.[deploymentId].delete')
->label('audits.event', 'deployment.delete')
@ -1366,10 +1373,10 @@ App::delete('/v1/functions/:functionId/deployments/:deploymentId')
->param('deploymentId', '', new UID(), 'Deployment ID.')
->inject('response')
->inject('dbForProject')
->inject('deletes')
->inject('events')
->inject('queueForDeletes')
->inject('queueForEvents')
->inject('deviceFunctions')
->action(function (string $functionId, string $deploymentId, Response $response, Database $dbForProject, Delete $deletes, Event $events, Device $deviceFunctions) {
->action(function (string $functionId, string $deploymentId, Response $response, Database $dbForProject, Delete $queueForDeletes, Event $queueForEvents, Device $deviceFunctions) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {
@ -1402,11 +1409,11 @@ App::delete('/v1/functions/:functionId/deployments/:deploymentId')
])));
}
$events
$queueForEvents
->setParam('functionId', $function->getId())
->setParam('deploymentId', $deployment->getId());
$deletes
$queueForDeletes
->setType(DELETE_TYPE_DOCUMENT)
->setDocument($deployment);
@ -1415,7 +1422,7 @@ App::delete('/v1/functions/:functionId/deployments/:deploymentId')
App::post('/v1/functions/:functionId/deployments/:deploymentId/builds/:buildId')
->groups(['api', 'functions'])
->desc('Create Build')
->desc('Create build')
->label('scope', 'functions.write')
->label('event', 'functions.[functionId].deployments.[deploymentId].update')
->label('audits.event', 'deployment.update')
@ -1433,8 +1440,9 @@ App::post('/v1/functions/:functionId/deployments/:deploymentId/builds/:buildId')
->inject('response')
->inject('dbForProject')
->inject('project')
->inject('events')
->action(function (string $functionId, string $deploymentId, string $buildId, Request $request, Response $response, Database $dbForProject, Document $project, Event $events) use ($redeployVcs) {
->inject('queueForEvents')
->inject('queueForBuilds')
->action(function (string $functionId, string $deploymentId, string $buildId, Request $request, Response $response, Database $dbForProject, Document $project, Event $queueForEvents, Build $queueForBuilds) {
$function = $dbForProject->getDocument('functions', $functionId);
@ -1456,9 +1464,9 @@ App::post('/v1/functions/:functionId/deployments/:deploymentId/builds/:buildId')
$deploymentId = ID::unique();
$deployment->removeAttribute('$internalId');
$deployment = $dbForProject->createDocument('deployments', $deployment->setAttributes([
'$id' => $deploymentId,
'$internalId' => '',
'buildId' => '',
'buildInternalId' => '',
'entrypoint' => $function->getAttribute('entrypoint'),
@ -1466,16 +1474,14 @@ App::post('/v1/functions/:functionId/deployments/:deploymentId/builds/:buildId')
'search' => implode(' ', [$deploymentId, $function->getAttribute('entrypoint')]),
]));
$buildEvent = new Build();
$buildEvent
$queueForBuilds
->setType(BUILD_TYPE_DEPLOYMENT)
->setResource($function)
->setDeployment($deployment)
->setProject($project)
->trigger();
$events
$queueForEvents
->setParam('functionId', $function->getId())
->setParam('deploymentId', $deployment->getId());
@ -1484,7 +1490,7 @@ App::post('/v1/functions/:functionId/deployments/:deploymentId/builds/:buildId')
App::post('/v1/functions/:functionId/executions')
->groups(['api', 'functions'])
->desc('Create Execution')
->desc('Create execution')
->label('scope', 'execution.write')
->label('event', 'functions.[functionId].executions.[executionId].create')
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
@ -1495,7 +1501,7 @@ App::post('/v1/functions/:functionId/executions')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_EXECUTION)
->param('functionId', '', new UID(), 'Function ID.')
->param('body', '', new Text(8192, 0), 'HTTP body of execution. Default value is empty string.', true)
->param('body', '', new Text(0, 0), 'HTTP body of execution. Default value is empty string.', true)
->param('async', false, new Boolean(), 'Execute code in the background. Default value is false.', true)
->param('path', '/', new Text(2048), 'HTTP path of execution. Path can include query params. Default value is /', true)
->param('method', 'POST', new Whitelist(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], true), 'HTTP method of execution. Default value is GET.', true)
@ -1504,12 +1510,12 @@ App::post('/v1/functions/:functionId/executions')
->inject('project')
->inject('dbForProject')
->inject('user')
->inject('events')
->inject('queueForEvents')
->inject('usage')
->inject('mode')
->inject('queueForFunctions')
->inject('geodb')
->action(function (string $functionId, string $body, bool $async, string $path, string $method, array $headers, Response $response, Document $project, Database $dbForProject, Document $user, Event $events, Stats $usage, string $mode, Func $queueForFunctions, Reader $geodb) {
->action(function (string $functionId, string $body, bool $async, string $path, string $method, array $headers, Response $response, Document $project, Database $dbForProject, Document $user, Event $queueForEvents, Stats $usage, string $mode, Func $queueForFunctions, Reader $geodb) {
$function = Authorization::skip(fn () => $dbForProject->getDocument('functions', $functionId));
@ -1625,7 +1631,7 @@ App::post('/v1/functions/:functionId/executions')
'search' => implode(' ', [$functionId, $executionId]),
]);
$events
$queueForEvents
->setParam('functionId', $function->getId())
->setParam('executionId', $execution->getId())
->setContext('function', $function);
@ -1658,6 +1664,16 @@ App::post('/v1/functions/:functionId/executions')
$vars = [];
// V2 vars
if ($version === 'v2') {
$vars = \array_merge($vars, [
'APPWRITE_FUNCTION_TRIGGER' => $headers['x-appwrite-trigger'] ?? '',
'APPWRITE_FUNCTION_DATA' => $body ?? '',
'APPWRITE_FUNCTION_USER_ID' => $headers['x-appwrite-user-id'] ?? '',
'APPWRITE_FUNCTION_JWT' => $headers['x-appwrite-user-jwt'] ?? ''
]);
}
// Shared vars
foreach ($function->getAttribute('varsProject', []) as $var) {
$vars[$var->getAttribute('key')] = $var->getAttribute('value', '');
@ -1697,7 +1713,8 @@ App::post('/v1/functions/:functionId/executions')
path: $path,
method: $method,
headers: $headers,
runtimeEntrypoint: $command
runtimeEntrypoint: $command,
requestTimeout: 30
);
$headersFiltered = [];
@ -1763,7 +1780,7 @@ App::post('/v1/functions/:functionId/executions')
App::get('/v1/functions/:functionId/executions')
->groups(['api', 'functions'])
->desc('List Executions')
->desc('List executions')
->label('scope', 'execution.read')
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
->label('sdk.namespace', 'functions')
@ -1838,7 +1855,7 @@ App::get('/v1/functions/:functionId/executions')
App::get('/v1/functions/:functionId/executions/:executionId')
->groups(['api', 'functions'])
->desc('Get Execution')
->desc('Get execution')
->label('scope', 'execution.read')
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
->label('sdk.namespace', 'functions')
@ -1886,7 +1903,7 @@ App::get('/v1/functions/:functionId/executions/:executionId')
// Variables
App::post('/v1/functions/:functionId/variables')
->desc('Create Variable')
->desc('Create variable')
->groups(['api', 'functions'])
->label('scope', 'functions.write')
->label('audits.event', 'variable.create')
@ -1950,7 +1967,7 @@ App::post('/v1/functions/:functionId/variables')
});
App::get('/v1/functions/:functionId/variables')
->desc('List Variables')
->desc('List variables')
->groups(['api', 'functions'])
->label('scope', 'functions.read')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
@ -1977,7 +1994,7 @@ App::get('/v1/functions/:functionId/variables')
});
App::get('/v1/functions/:functionId/variables/:variableId')
->desc('Get Variable')
->desc('Get variable')
->groups(['api', 'functions'])
->label('scope', 'functions.read')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
@ -2016,7 +2033,7 @@ App::get('/v1/functions/:functionId/variables/:variableId')
});
App::put('/v1/functions/:functionId/variables/:variableId')
->desc('Update Variable')
->desc('Update variable')
->groups(['api', 'functions'])
->label('scope', 'functions.write')
->label('audits.event', 'variable.update')
@ -2077,7 +2094,7 @@ App::put('/v1/functions/:functionId/variables/:variableId')
});
App::delete('/v1/functions/:functionId/variables/:variableId')
->desc('Delete Variable')
->desc('Delete variable')
->groups(['api', 'functions'])
->label('scope', 'functions.write')
->label('audits.event', 'variable.delete')

View file

@ -18,7 +18,7 @@ use Utopia\Validator\JSON;
use Utopia\Validator\Text;
App::get('/v1/graphql')
->desc('GraphQL Endpoint')
->desc('GraphQL endpoint')
->groups(['graphql'])
->label('scope', 'graphql')
->label('sdk.auth', [APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_JWT])
@ -58,7 +58,7 @@ App::get('/v1/graphql')
});
App::post('/v1/graphql/mutation')
->desc('GraphQL Endpoint')
->desc('GraphQL endpoint')
->groups(['graphql'])
->label('scope', 'graphql')
->label('sdk.auth', [APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_JWT])
@ -103,7 +103,7 @@ App::post('/v1/graphql/mutation')
});
App::post('/v1/graphql')
->desc('GraphQL Endpoint')
->desc('GraphQL endpoint')
->groups(['graphql'])
->label('scope', 'graphql')
->label('sdk.auth', [APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_JWT])

Some files were not shown because too many files have changed in this diff Show more