1
0
Fork 0
mirror of synced 2024-09-30 01:08:13 +13:00

Updated Console SDK

This commit is contained in:
Eldad Fux 2021-07-31 23:40:34 +03:00
parent 48acc2fcf1
commit b24225b92c
8 changed files with 327 additions and 97 deletions

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

@ -28,8 +28,8 @@ App::post('/v1/database/collections')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('event', 'database.collections.create') ->label('event', 'database.collections.create')
->label('scope', 'collections.write') ->label('scope', 'collections.write')
->label('sdk.namespace', 'database')
->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'database')
->label('sdk.method', 'createCollection') ->label('sdk.method', 'createCollection')
->label('sdk.description', '/docs/references/database/create-collection.md') ->label('sdk.description', '/docs/references/database/create-collection.md')
->label('sdk.response.code', Response::STATUS_CODE_CREATED) ->label('sdk.response.code', Response::STATUS_CODE_CREATED)
@ -74,8 +74,8 @@ App::get('/v1/database/collections')
->desc('List Collections') ->desc('List Collections')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('scope', 'collections.read') ->label('scope', 'collections.read')
->label('sdk.namespace', 'database')
->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'database')
->label('sdk.method', 'listCollections') ->label('sdk.method', 'listCollections')
->label('sdk.description', '/docs/references/database/list-collections.md') ->label('sdk.description', '/docs/references/database/list-collections.md')
->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.code', Response::STATUS_CODE_OK)
@ -103,8 +103,8 @@ App::get('/v1/database/collections/:collectionId')
->desc('Get Collection') ->desc('Get Collection')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('scope', 'collections.read') ->label('scope', 'collections.read')
->label('sdk.namespace', 'database')
->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'database')
->label('sdk.method', 'getCollection') ->label('sdk.method', 'getCollection')
->label('sdk.description', '/docs/references/database/get-collection.md') ->label('sdk.description', '/docs/references/database/get-collection.md')
->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.code', Response::STATUS_CODE_OK)
@ -131,8 +131,8 @@ App::put('/v1/database/collections/:collectionId')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('scope', 'collections.write') ->label('scope', 'collections.write')
->label('event', 'database.collections.update') ->label('event', 'database.collections.update')
->label('sdk.namespace', 'database')
->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'database')
->label('sdk.method', 'updateCollection') ->label('sdk.method', 'updateCollection')
->label('sdk.description', '/docs/references/database/update-collection.md') ->label('sdk.description', '/docs/references/database/update-collection.md')
->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.code', Response::STATUS_CODE_OK)
@ -185,8 +185,8 @@ App::delete('/v1/database/collections/:collectionId')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('scope', 'collections.write') ->label('scope', 'collections.write')
->label('event', 'database.collections.delete') ->label('event', 'database.collections.delete')
->label('sdk.namespace', 'database')
->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'database')
->label('sdk.method', 'deleteCollection') ->label('sdk.method', 'deleteCollection')
->label('sdk.description', '/docs/references/database/delete-collection.md') ->label('sdk.description', '/docs/references/database/delete-collection.md')
->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT)
@ -229,8 +229,8 @@ App::post('/v1/database/collections/:collectionId/attributes')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('event', 'database.attributes.create') ->label('event', 'database.attributes.create')
->label('scope', 'attributes.write') ->label('scope', 'attributes.write')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'database') ->label('sdk.namespace', 'database')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.method', 'createAttribute') ->label('sdk.method', 'createAttribute')
->label('sdk.description', '/docs/references/database/create-attribute.md') ->label('sdk.description', '/docs/references/database/create-attribute.md')
->label('sdk.response.code', Response::STATUS_CODE_CREATED) ->label('sdk.response.code', Response::STATUS_CODE_CREATED)
@ -303,8 +303,8 @@ App::get('/v1/database/collections/:collectionId/attributes')
->desc('List Attributes') ->desc('List Attributes')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('scope', 'attributes.read') ->label('scope', 'attributes.read')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'database') ->label('sdk.namespace', 'database')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.method', 'listAttributes') ->label('sdk.method', 'listAttributes')
->label('sdk.description', '/docs/references/database/list-attributes.md') ->label('sdk.description', '/docs/references/database/list-attributes.md')
->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.code', Response::STATUS_CODE_OK)
@ -341,8 +341,8 @@ App::get('/v1/database/collections/:collectionId/attributes/:attributeId')
->desc('Get Attribute') ->desc('Get Attribute')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('scope', 'attributes.read') ->label('scope', 'attributes.read')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'database') ->label('sdk.namespace', 'database')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.method', 'getAttribute') ->label('sdk.method', 'getAttribute')
->label('sdk.description', '/docs/references/database/get-attribute.md') ->label('sdk.description', '/docs/references/database/get-attribute.md')
->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.code', Response::STATUS_CODE_OK)
@ -383,8 +383,8 @@ App::delete('/v1/database/collections/:collectionId/attributes/:attributeId')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('scope', 'attributes.write') ->label('scope', 'attributes.write')
->label('event', 'database.attributes.delete') ->label('event', 'database.attributes.delete')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'database') ->label('sdk.namespace', 'database')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.method', 'deleteAttribute') ->label('sdk.method', 'deleteAttribute')
->label('sdk.description', '/docs/references/database/delete-attribute.md') ->label('sdk.description', '/docs/references/database/delete-attribute.md')
->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT)
@ -445,8 +445,8 @@ App::post('/v1/database/collections/:collectionId/indexes')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('event', 'database.indexes.create') ->label('event', 'database.indexes.create')
->label('scope', 'indexes.write') ->label('scope', 'indexes.write')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'database') ->label('sdk.namespace', 'database')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.method', 'createIndex') ->label('sdk.method', 'createIndex')
->label('sdk.description', '/docs/references/database/create-index.md') ->label('sdk.description', '/docs/references/database/create-index.md')
->label('sdk.response.code', Response::STATUS_CODE_CREATED) ->label('sdk.response.code', Response::STATUS_CODE_CREATED)
@ -534,8 +534,8 @@ App::get('/v1/database/collections/:collectionId/indexes')
->desc('List Indexes') ->desc('List Indexes')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('scope', 'indexes.read') ->label('scope', 'indexes.read')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'database') ->label('sdk.namespace', 'database')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.method', 'listIndexes') ->label('sdk.method', 'listIndexes')
->label('sdk.description', '/docs/references/database/list-indexes.md') ->label('sdk.description', '/docs/references/database/list-indexes.md')
->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.code', Response::STATUS_CODE_OK)
@ -572,8 +572,8 @@ App::get('/v1/database/collections/:collectionId/indexes/:indexId')
->desc('Get Index') ->desc('Get Index')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('scope', 'indexes.read') ->label('scope', 'indexes.read')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'database') ->label('sdk.namespace', 'database')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.method', 'getIndex') ->label('sdk.method', 'getIndex')
->label('sdk.description', '/docs/references/database/get-index.md') ->label('sdk.description', '/docs/references/database/get-index.md')
->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.code', Response::STATUS_CODE_OK)
@ -614,8 +614,8 @@ App::delete('/v1/database/collections/:collectionId/indexes/:indexId')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('scope', 'indexes.write') ->label('scope', 'indexes.write')
->label('event', 'database.indexes.delete') ->label('event', 'database.indexes.delete')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'database') ->label('sdk.namespace', 'database')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.method', 'deleteIndex') ->label('sdk.method', 'deleteIndex')
->label('sdk.description', '/docs/references/database/delete-index.md') ->label('sdk.description', '/docs/references/database/delete-index.md')
->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT)
@ -676,8 +676,8 @@ App::post('/v1/database/collections/:collectionId/documents')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('event', 'database.documents.create') ->label('event', 'database.documents.create')
->label('scope', 'documents.write') ->label('scope', 'documents.write')
->label('sdk.namespace', 'database')
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
->label('sdk.namespace', 'database')
->label('sdk.method', 'createDocument') ->label('sdk.method', 'createDocument')
->label('sdk.description', '/docs/references/database/create-document.md') ->label('sdk.description', '/docs/references/database/create-document.md')
->label('sdk.response.code', Response::STATUS_CODE_CREATED) ->label('sdk.response.code', Response::STATUS_CODE_CREATED)
@ -738,8 +738,8 @@ App::get('/v1/database/collections/:collectionId/documents')
->desc('List Documents') ->desc('List Documents')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('scope', 'documents.read') ->label('scope', 'documents.read')
->label('sdk.namespace', 'database')
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
->label('sdk.namespace', 'database')
->label('sdk.method', 'listDocuments') ->label('sdk.method', 'listDocuments')
->label('sdk.description', '/docs/references/database/list-documents.md') ->label('sdk.description', '/docs/references/database/list-documents.md')
->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.code', Response::STATUS_CODE_OK)
@ -792,8 +792,8 @@ App::get('/v1/database/collections/:collectionId/documents/:documentId')
->desc('Get Document') ->desc('Get Document')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('scope', 'documents.read') ->label('scope', 'documents.read')
->label('sdk.namespace', 'database')
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
->label('sdk.namespace', 'database')
->label('sdk.method', 'getDocument') ->label('sdk.method', 'getDocument')
->label('sdk.description', '/docs/references/database/get-document.md') ->label('sdk.description', '/docs/references/database/get-document.md')
->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.code', Response::STATUS_CODE_OK)
@ -827,8 +827,8 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('event', 'database.documents.update') ->label('event', 'database.documents.update')
->label('scope', 'documents.write') ->label('scope', 'documents.write')
->label('sdk.namespace', 'database')
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
->label('sdk.namespace', 'database')
->label('sdk.method', 'updateDocument') ->label('sdk.method', 'updateDocument')
->label('sdk.description', '/docs/references/database/update-document.md') ->label('sdk.description', '/docs/references/database/update-document.md')
->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.code', Response::STATUS_CODE_OK)
@ -898,8 +898,8 @@ App::delete('/v1/database/collections/:collectionId/documents/:documentId')
->groups(['api', 'database']) ->groups(['api', 'database'])
->label('scope', 'documents.write') ->label('scope', 'documents.write')
->label('event', 'database.documents.delete') ->label('event', 'database.documents.delete')
->label('sdk.namespace', 'database')
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
->label('sdk.namespace', 'database')
->label('sdk.method', 'deleteDocument') ->label('sdk.method', 'deleteDocument')
->label('sdk.description', '/docs/references/database/delete-document.md') ->label('sdk.description', '/docs/references/database/delete-document.md')
->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT)

View file

@ -5,7 +5,6 @@ use Appwrite\Auth\Validator\Password;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
use Utopia\App; use Utopia\App;
use Utopia\Exception; use Utopia\Exception;
use Utopia\Validator;
use Utopia\Validator\Assoc; use Utopia\Validator\Assoc;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
use Appwrite\Network\Validator\Email; use Appwrite\Network\Validator\Email;

View file

@ -73,7 +73,7 @@
} }
], ],
"require-dev": { "require-dev": {
"appwrite/sdk-generator": "0.12.0", "appwrite/sdk-generator": "0.13.0",
"swoole/ide-helper": "4.6.7", "swoole/ide-helper": "4.6.7",
"phpunit/phpunit": "9.5.6", "phpunit/phpunit": "9.5.6",
"vimeo/psalm": "4.7.2" "vimeo/psalm": "4.7.2"

14
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "17c1c46d283e4745df9915d082c22078", "content-hash": "58102c809e5d82ce2c41dfca515a18dc",
"packages": [ "packages": [
{ {
"name": "adhocore/jwt", "name": "adhocore/jwt",
@ -2726,16 +2726,16 @@
}, },
{ {
"name": "appwrite/sdk-generator", "name": "appwrite/sdk-generator",
"version": "0.12.0", "version": "0.13.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/appwrite/sdk-generator.git", "url": "https://github.com/appwrite/sdk-generator.git",
"reference": "ca8e34f091b3a66f94a8972cb94b0b8e1161dada" "reference": "ea867bf585b03d2e22315820bf7ebca59c4cbd61"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/ca8e34f091b3a66f94a8972cb94b0b8e1161dada", "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/ea867bf585b03d2e22315820bf7ebca59c4cbd61",
"reference": "ca8e34f091b3a66f94a8972cb94b0b8e1161dada", "reference": "ea867bf585b03d2e22315820bf7ebca59c4cbd61",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2769,9 +2769,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": { "support": {
"issues": "https://github.com/appwrite/sdk-generator/issues", "issues": "https://github.com/appwrite/sdk-generator/issues",
"source": "https://github.com/appwrite/sdk-generator/tree/0.12.0" "source": "https://github.com/appwrite/sdk-generator/tree/0.13.0"
}, },
"time": "2021-07-06T16:20:51+00:00" "time": "2021-07-31T20:27:03+00:00"
}, },
{ {
"name": "composer/semver", "name": "composer/semver",

View file

@ -46,7 +46,7 @@
mode: '', mode: '',
}; };
this.headers = { this.headers = {
'x-sdk-version': 'appwrite:web:2.0.0', 'x-sdk-version': 'appwrite:web:2.1.0',
'X-Appwrite-Response-Format': '0.9.0', 'X-Appwrite-Response-Format': '0.9.0',
}; };
this.account = { this.account = {
@ -472,6 +472,14 @@
* first. Use the success and failure arguments to provide a redirect URL's * first. Use the success and failure arguments to provide a redirect URL's
* back to your app when login is completed. * back to your app when login is completed.
* *
* If there is already an active session, the new session will be attached to
* the logged-in account. If there are no active sessions, the server will
* attempt to look for a user with the same email address as the email
* received from the OAuth2 provider and attach the new session to the
* existing user. If no matching user is found - the server will create a new
* user..
*
*
* @param {string} provider * @param {string} provider
* @param {string} success * @param {string} success
* @param {string} failure * @param {string} failure
@ -921,13 +929,12 @@
* Create a new Collection. * Create a new Collection.
* *
* @param {string} name * @param {string} name
* @param {string[]} read * @param {string} read
* @param {string[]} write * @param {string} write
* @param {string[]} rules
* @throws {AppwriteException} * @throws {AppwriteException}
* @returns {Promise} * @returns {Promise}
*/ */
createCollection: (name, read, write, rules) => __awaiter(this, void 0, void 0, function* () { createCollection: (name, read, write) => __awaiter(this, void 0, void 0, function* () {
if (typeof name === 'undefined') { if (typeof name === 'undefined') {
throw new AppwriteException('Missing required parameter: "name"'); throw new AppwriteException('Missing required parameter: "name"');
} }
@ -937,9 +944,6 @@
if (typeof write === 'undefined') { if (typeof write === 'undefined') {
throw new AppwriteException('Missing required parameter: "write"'); throw new AppwriteException('Missing required parameter: "write"');
} }
if (typeof rules === 'undefined') {
throw new AppwriteException('Missing required parameter: "rules"');
}
let path = '/database/collections'; let path = '/database/collections';
let payload = {}; let payload = {};
if (typeof name !== 'undefined') { if (typeof name !== 'undefined') {
@ -951,9 +955,6 @@
if (typeof write !== 'undefined') { if (typeof write !== 'undefined') {
payload['write'] = write; payload['write'] = write;
} }
if (typeof rules !== 'undefined') {
payload['rules'] = rules;
}
const uri = new URL(this.config.endpoint + path); const uri = new URL(this.config.endpoint + path);
return yield this.call('post', uri, { return yield this.call('post', uri, {
'content-type': 'application/json', 'content-type': 'application/json',
@ -987,13 +988,12 @@
* *
* @param {string} collectionId * @param {string} collectionId
* @param {string} name * @param {string} name
* @param {string[]} read * @param {string} read
* @param {string[]} write * @param {string} write
* @param {string[]} rules
* @throws {AppwriteException} * @throws {AppwriteException}
* @returns {Promise} * @returns {Promise}
*/ */
updateCollection: (collectionId, name, read, write, rules) => __awaiter(this, void 0, void 0, function* () { updateCollection: (collectionId, name, read, write) => __awaiter(this, void 0, void 0, function* () {
if (typeof collectionId === 'undefined') { if (typeof collectionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "collectionId"'); throw new AppwriteException('Missing required parameter: "collectionId"');
} }
@ -1011,9 +1011,6 @@
if (typeof write !== 'undefined') { if (typeof write !== 'undefined') {
payload['write'] = write; payload['write'] = write;
} }
if (typeof rules !== 'undefined') {
payload['rules'] = rules;
}
const uri = new URL(this.config.endpoint + path); const uri = new URL(this.config.endpoint + path);
return yield this.call('put', uri, { return yield this.call('put', uri, {
'content-type': 'application/json', 'content-type': 'application/json',
@ -1040,6 +1037,126 @@
'content-type': 'application/json', 'content-type': 'application/json',
}, payload); }, payload);
}), }),
/**
* List Attributes
*
*
* @param {string} collectionId
* @throws {AppwriteException}
* @returns {Promise}
*/
listAttributes: (collectionId) => __awaiter(this, void 0, void 0, function* () {
if (typeof collectionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "collectionId"');
}
let path = '/database/collections/{collectionId}/attributes'.replace('{collectionId}', collectionId);
let payload = {};
const uri = new URL(this.config.endpoint + path);
return yield this.call('get', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Create Attribute
*
*
* @param {string} collectionId
* @param {string} id
* @param {string} type
* @param {number} size
* @param {boolean} required
* @param {string} xdefault
* @param {boolean} array
* @throws {AppwriteException}
* @returns {Promise}
*/
createAttribute: (collectionId, id, type, size, required, xdefault, array) => __awaiter(this, void 0, void 0, function* () {
if (typeof collectionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "collectionId"');
}
if (typeof id === 'undefined') {
throw new AppwriteException('Missing required parameter: "id"');
}
if (typeof type === 'undefined') {
throw new AppwriteException('Missing required parameter: "type"');
}
if (typeof size === 'undefined') {
throw new AppwriteException('Missing required parameter: "size"');
}
if (typeof required === 'undefined') {
throw new AppwriteException('Missing required parameter: "required"');
}
let path = '/database/collections/{collectionId}/attributes'.replace('{collectionId}', collectionId);
let payload = {};
if (typeof id !== 'undefined') {
payload['id'] = id;
}
if (typeof type !== 'undefined') {
payload['type'] = type;
}
if (typeof size !== 'undefined') {
payload['size'] = size;
}
if (typeof required !== 'undefined') {
payload['required'] = required;
}
if (typeof xdefault !== 'undefined') {
payload['xdefault'] = xdefault;
}
if (typeof array !== 'undefined') {
payload['array'] = array;
}
const uri = new URL(this.config.endpoint + path);
return yield this.call('post', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Get Attribute
*
*
* @param {string} collectionId
* @param {string} attributeId
* @throws {AppwriteException}
* @returns {Promise}
*/
getAttribute: (collectionId, attributeId) => __awaiter(this, void 0, void 0, function* () {
if (typeof collectionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "collectionId"');
}
if (typeof attributeId === 'undefined') {
throw new AppwriteException('Missing required parameter: "attributeId"');
}
let path = '/database/collections/{collectionId}/attributes/{attributeId}'.replace('{collectionId}', collectionId).replace('{attributeId}', attributeId);
let payload = {};
const uri = new URL(this.config.endpoint + path);
return yield this.call('get', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Delete Attribute
*
*
* @param {string} collectionId
* @param {string} attributeId
* @throws {AppwriteException}
* @returns {Promise}
*/
deleteAttribute: (collectionId, attributeId) => __awaiter(this, void 0, void 0, function* () {
if (typeof collectionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "collectionId"');
}
if (typeof attributeId === 'undefined') {
throw new AppwriteException('Missing required parameter: "attributeId"');
}
let path = '/database/collections/{collectionId}/attributes/{attributeId}'.replace('{collectionId}', collectionId).replace('{attributeId}', attributeId);
let payload = {};
const uri = new URL(this.config.endpoint + path);
return yield this.call('delete', uri, {
'content-type': 'application/json',
}, payload);
}),
/** /**
* List Documents * List Documents
* *
@ -1049,24 +1166,22 @@
* modes](/docs/admin). * modes](/docs/admin).
* *
* @param {string} collectionId * @param {string} collectionId
* @param {string[]} filters * @param {string[]} queries
* @param {number} limit * @param {number} limit
* @param {number} offset * @param {number} offset
* @param {string} orderField * @param {string[]} orderAttributes
* @param {string} orderType * @param {string[]} orderTypes
* @param {string} orderCast
* @param {string} search
* @throws {AppwriteException} * @throws {AppwriteException}
* @returns {Promise} * @returns {Promise}
*/ */
listDocuments: (collectionId, filters, limit, offset, orderField, orderType, orderCast, search) => __awaiter(this, void 0, void 0, function* () { listDocuments: (collectionId, queries, limit, offset, orderAttributes, orderTypes) => __awaiter(this, void 0, void 0, function* () {
if (typeof collectionId === 'undefined') { if (typeof collectionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "collectionId"'); throw new AppwriteException('Missing required parameter: "collectionId"');
} }
let path = '/database/collections/{collectionId}/documents'.replace('{collectionId}', collectionId); let path = '/database/collections/{collectionId}/documents'.replace('{collectionId}', collectionId);
let payload = {}; let payload = {};
if (typeof filters !== 'undefined') { if (typeof queries !== 'undefined') {
payload['filters'] = filters; payload['queries'] = queries;
} }
if (typeof limit !== 'undefined') { if (typeof limit !== 'undefined') {
payload['limit'] = limit; payload['limit'] = limit;
@ -1074,17 +1189,11 @@
if (typeof offset !== 'undefined') { if (typeof offset !== 'undefined') {
payload['offset'] = offset; payload['offset'] = offset;
} }
if (typeof orderField !== 'undefined') { if (typeof orderAttributes !== 'undefined') {
payload['orderField'] = orderField; payload['orderAttributes'] = orderAttributes;
} }
if (typeof orderType !== 'undefined') { if (typeof orderTypes !== 'undefined') {
payload['orderType'] = orderType; payload['orderTypes'] = orderTypes;
}
if (typeof orderCast !== 'undefined') {
payload['orderCast'] = orderCast;
}
if (typeof search !== 'undefined') {
payload['search'] = search;
} }
const uri = new URL(this.config.endpoint + path); const uri = new URL(this.config.endpoint + path);
return yield this.call('get', uri, { return yield this.call('get', uri, {
@ -1101,15 +1210,12 @@
* *
* @param {string} collectionId * @param {string} collectionId
* @param {object} data * @param {object} data
* @param {string[]} read * @param {string} read
* @param {string[]} write * @param {string} write
* @param {string} parentDocument
* @param {string} parentProperty
* @param {string} parentPropertyType
* @throws {AppwriteException} * @throws {AppwriteException}
* @returns {Promise} * @returns {Promise}
*/ */
createDocument: (collectionId, data, read, write, parentDocument, parentProperty, parentPropertyType) => __awaiter(this, void 0, void 0, function* () { createDocument: (collectionId, data, read, write) => __awaiter(this, void 0, void 0, function* () {
if (typeof collectionId === 'undefined') { if (typeof collectionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "collectionId"'); throw new AppwriteException('Missing required parameter: "collectionId"');
} }
@ -1127,15 +1233,6 @@
if (typeof write !== 'undefined') { if (typeof write !== 'undefined') {
payload['write'] = write; payload['write'] = write;
} }
if (typeof parentDocument !== 'undefined') {
payload['parentDocument'] = parentDocument;
}
if (typeof parentProperty !== 'undefined') {
payload['parentProperty'] = parentProperty;
}
if (typeof parentPropertyType !== 'undefined') {
payload['parentPropertyType'] = parentPropertyType;
}
const uri = new URL(this.config.endpoint + path); const uri = new URL(this.config.endpoint + path);
return yield this.call('post', uri, { return yield this.call('post', uri, {
'content-type': 'application/json', 'content-type': 'application/json',
@ -1175,8 +1272,8 @@
* @param {string} collectionId * @param {string} collectionId
* @param {string} documentId * @param {string} documentId
* @param {object} data * @param {object} data
* @param {string[]} read * @param {string} read
* @param {string[]} write * @param {string} write
* @throws {AppwriteException} * @throws {AppwriteException}
* @returns {Promise} * @returns {Promise}
*/ */
@ -1231,6 +1328,115 @@
return yield this.call('delete', uri, { return yield this.call('delete', uri, {
'content-type': 'application/json', 'content-type': 'application/json',
}, payload); }, payload);
}),
/**
* List Indexes
*
*
* @param {string} collectionId
* @throws {AppwriteException}
* @returns {Promise}
*/
listIndexes: (collectionId) => __awaiter(this, void 0, void 0, function* () {
if (typeof collectionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "collectionId"');
}
let path = '/database/collections/{collectionId}/indexes'.replace('{collectionId}', collectionId);
let payload = {};
const uri = new URL(this.config.endpoint + path);
return yield this.call('get', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Create Index
*
*
* @param {string} collectionId
* @param {string} id
* @param {string} type
* @param {string[]} attributes
* @param {string[]} orders
* @throws {AppwriteException}
* @returns {Promise}
*/
createIndex: (collectionId, id, type, attributes, orders) => __awaiter(this, void 0, void 0, function* () {
if (typeof collectionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "collectionId"');
}
if (typeof id === 'undefined') {
throw new AppwriteException('Missing required parameter: "id"');
}
if (typeof type === 'undefined') {
throw new AppwriteException('Missing required parameter: "type"');
}
if (typeof attributes === 'undefined') {
throw new AppwriteException('Missing required parameter: "attributes"');
}
let path = '/database/collections/{collectionId}/indexes'.replace('{collectionId}', collectionId);
let payload = {};
if (typeof id !== 'undefined') {
payload['id'] = id;
}
if (typeof type !== 'undefined') {
payload['type'] = type;
}
if (typeof attributes !== 'undefined') {
payload['attributes'] = attributes;
}
if (typeof orders !== 'undefined') {
payload['orders'] = orders;
}
const uri = new URL(this.config.endpoint + path);
return yield this.call('post', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Get Index
*
*
* @param {string} collectionId
* @param {string} indexId
* @throws {AppwriteException}
* @returns {Promise}
*/
getIndex: (collectionId, indexId) => __awaiter(this, void 0, void 0, function* () {
if (typeof collectionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "collectionId"');
}
if (typeof indexId === 'undefined') {
throw new AppwriteException('Missing required parameter: "indexId"');
}
let path = '/database/collections/{collectionId}/indexes/{indexId}'.replace('{collectionId}', collectionId).replace('{indexId}', indexId);
let payload = {};
const uri = new URL(this.config.endpoint + path);
return yield this.call('get', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Delete Index
*
*
* @param {string} collectionId
* @param {string} indexId
* @throws {AppwriteException}
* @returns {Promise}
*/
deleteIndex: (collectionId, indexId) => __awaiter(this, void 0, void 0, function* () {
if (typeof collectionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "collectionId"');
}
if (typeof indexId === 'undefined') {
throw new AppwriteException('Missing required parameter: "indexId"');
}
let path = '/database/collections/{collectionId}/indexes/{indexId}'.replace('{collectionId}', collectionId).replace('{indexId}', indexId);
let payload = {};
const uri = new URL(this.config.endpoint + path);
return yield this.call('delete', uri, {
'content-type': 'application/json',
}, payload);
}) })
}; };
this.functions = { this.functions = {
@ -1421,31 +1627,23 @@
* different API modes](/docs/admin). * different API modes](/docs/admin).
* *
* @param {string} functionId * @param {string} functionId
* @param {string} search
* @param {number} limit * @param {number} limit
* @param {number} offset * @param {number} offset
* @param {string} orderType
* @throws {AppwriteException} * @throws {AppwriteException}
* @returns {Promise} * @returns {Promise}
*/ */
listExecutions: (functionId, search, limit, offset, orderType) => __awaiter(this, void 0, void 0, function* () { listExecutions: (functionId, limit, offset) => __awaiter(this, void 0, void 0, function* () {
if (typeof functionId === 'undefined') { if (typeof functionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "functionId"'); throw new AppwriteException('Missing required parameter: "functionId"');
} }
let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId); let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
let payload = {}; let payload = {};
if (typeof search !== 'undefined') {
payload['search'] = search;
}
if (typeof limit !== 'undefined') { if (typeof limit !== 'undefined') {
payload['limit'] = limit; payload['limit'] = limit;
} }
if (typeof offset !== 'undefined') { if (typeof offset !== 'undefined') {
payload['offset'] = offset; payload['offset'] = offset;
} }
if (typeof orderType !== 'undefined') {
payload['orderType'] = orderType;
}
const uri = new URL(this.config.endpoint + path); const uri = new URL(this.config.endpoint + path);
return yield this.call('get', uri, { return yield this.call('get', uri, {
'content-type': 'application/json', 'content-type': 'application/json',
@ -2710,6 +2908,36 @@
'content-type': 'application/json', 'content-type': 'application/json',
}, payload); }, payload);
}), }),
/**
* Update service status
*
*
* @param {string} projectId
* @param {string} service
* @param {boolean} status
* @throws {AppwriteException}
* @returns {Promise}
*/
serviceStatus: (projectId, service, status) => __awaiter(this, void 0, void 0, function* () {
if (typeof projectId === 'undefined') {
throw new AppwriteException('Missing required parameter: "projectId"');
}
if (typeof service === 'undefined') {
throw new AppwriteException('Missing required parameter: "service"');
}
let path = '/projects/{projectId}/service'.replace('{projectId}', projectId);
let payload = {};
if (typeof service !== 'undefined') {
payload['service'] = service;
}
if (typeof status !== 'undefined') {
payload['status'] = status;
}
const uri = new URL(this.config.endpoint + path);
return yield this.call('patch', uri, {
'content-type': 'application/json',
}, payload);
}),
/** /**
* List Tasks * List Tasks
* *
@ -3567,14 +3795,17 @@
/** /**
* Create Team Membership * Create Team Membership
* *
* Use this endpoint to invite a new member to join your team. An email with a * Use this endpoint to invite a new member to join your team. If initiated
* link to join the team will be sent to the new member email address if the * from Client SDK, an email with a link to join the team will be sent to the
* member doesn't exist in the project it will be created automatically. * new member's email address if the member doesn't exist in the project it
* will be created automatically. If initiated from server side SDKs, new
* member will automatically be added to the team.
* *
* Use the 'URL' parameter to redirect the user from the invitation email back * Use the 'URL' parameter to redirect the user from the invitation email back
* to your app. When the user is redirected, use the [Update Team Membership * to your app. When the user is redirected, use the [Update Team Membership
* Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow * Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow
* the user to accept the invitation to the team. * the user to accept the invitation to the team. While calling from side
* SDKs the redirect url can be empty string.
* *
* Please note that in order to avoid a [Redirect * Please note that in order to avoid a [Redirect
* Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
@ -3964,7 +4195,7 @@
* Update the user status by its unique ID. * Update the user status by its unique ID.
* *
* @param {string} userId * @param {string} userId
* @param {number} status * @param {boolean} status
* @throws {AppwriteException} * @throws {AppwriteException}
* @returns {Promise} * @returns {Promise}
*/ */