@appwrite.io/console 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cjs/sdk.js +44 -20
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +44 -20
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +44 -20
- package/docs/examples/databases/upsert-document.md +17 -0
- package/docs/examples/functions/create.md +1 -5
- package/package.json +1 -1
- package/src/client.ts +5 -2
- package/src/models.ts +12 -0
- package/src/services/databases.ts +45 -0
- package/src/services/functions.ts +1 -17
- package/src/services/tokens.ts +1 -1
- package/types/models.d.ts +12 -0
- package/types/services/databases.d.ts +12 -0
- package/types/services/functions.d.ts +1 -5
- package/types/services/tokens.d.ts +1 -1
package/dist/esm/sdk.js
CHANGED
|
@@ -278,7 +278,7 @@ class Client {
|
|
|
278
278
|
'x-sdk-name': 'Console',
|
|
279
279
|
'x-sdk-platform': 'console',
|
|
280
280
|
'x-sdk-language': 'web',
|
|
281
|
-
'x-sdk-version': '1.
|
|
281
|
+
'x-sdk-version': '1.8.0',
|
|
282
282
|
'X-Appwrite-Response-Format': '1.7.0',
|
|
283
283
|
};
|
|
284
284
|
this.realtime = {
|
|
@@ -576,8 +576,10 @@ class Client {
|
|
|
576
576
|
let options = {
|
|
577
577
|
method,
|
|
578
578
|
headers,
|
|
579
|
-
credentials: 'include',
|
|
580
579
|
};
|
|
580
|
+
if (headers['X-Appwrite-Dev-Key'] === undefined) {
|
|
581
|
+
options.credentials = 'include';
|
|
582
|
+
}
|
|
581
583
|
if (method === 'GET') {
|
|
582
584
|
for (const [key, value] of Object.entries(Client.flatten(params))) {
|
|
583
585
|
url.searchParams.append(key, value);
|
|
@@ -4515,6 +4517,44 @@ class Databases {
|
|
|
4515
4517
|
const apiHeaders = {};
|
|
4516
4518
|
return this.client.call('get', uri, apiHeaders, payload);
|
|
4517
4519
|
}
|
|
4520
|
+
/**
|
|
4521
|
+
* Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.
|
|
4522
|
+
*
|
|
4523
|
+
* @param {string} databaseId
|
|
4524
|
+
* @param {string} collectionId
|
|
4525
|
+
* @param {string} documentId
|
|
4526
|
+
* @param {object} data
|
|
4527
|
+
* @param {string[]} permissions
|
|
4528
|
+
* @throws {AppwriteException}
|
|
4529
|
+
* @returns {Promise<Document>}
|
|
4530
|
+
*/
|
|
4531
|
+
upsertDocument(databaseId, collectionId, documentId, data, permissions) {
|
|
4532
|
+
if (typeof databaseId === 'undefined') {
|
|
4533
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
4534
|
+
}
|
|
4535
|
+
if (typeof collectionId === 'undefined') {
|
|
4536
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
4537
|
+
}
|
|
4538
|
+
if (typeof documentId === 'undefined') {
|
|
4539
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
4540
|
+
}
|
|
4541
|
+
if (typeof data === 'undefined') {
|
|
4542
|
+
throw new AppwriteException('Missing required parameter: "data"');
|
|
4543
|
+
}
|
|
4544
|
+
const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
|
|
4545
|
+
const payload = {};
|
|
4546
|
+
if (typeof data !== 'undefined') {
|
|
4547
|
+
payload['data'] = data;
|
|
4548
|
+
}
|
|
4549
|
+
if (typeof permissions !== 'undefined') {
|
|
4550
|
+
payload['permissions'] = permissions;
|
|
4551
|
+
}
|
|
4552
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
4553
|
+
const apiHeaders = {
|
|
4554
|
+
'content-type': 'application/json',
|
|
4555
|
+
};
|
|
4556
|
+
return this.client.call('put', uri, apiHeaders, payload);
|
|
4557
|
+
}
|
|
4518
4558
|
/**
|
|
4519
4559
|
* Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.
|
|
4520
4560
|
*
|
|
@@ -6379,14 +6419,10 @@ class Functions {
|
|
|
6379
6419
|
* @param {boolean} providerSilentMode
|
|
6380
6420
|
* @param {string} providerRootDirectory
|
|
6381
6421
|
* @param {string} specification
|
|
6382
|
-
* @param {string} templateRepository
|
|
6383
|
-
* @param {string} templateOwner
|
|
6384
|
-
* @param {string} templateRootDirectory
|
|
6385
|
-
* @param {string} templateVersion
|
|
6386
6422
|
* @throws {AppwriteException}
|
|
6387
6423
|
* @returns {Promise<Models.Function>}
|
|
6388
6424
|
*/
|
|
6389
|
-
create(functionId, name, runtime, execute, events, schedule, timeout, enabled, logging, entrypoint, commands, scopes, installationId, providerRepositoryId, providerBranch, providerSilentMode, providerRootDirectory, specification
|
|
6425
|
+
create(functionId, name, runtime, execute, events, schedule, timeout, enabled, logging, entrypoint, commands, scopes, installationId, providerRepositoryId, providerBranch, providerSilentMode, providerRootDirectory, specification) {
|
|
6390
6426
|
if (typeof functionId === 'undefined') {
|
|
6391
6427
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
6392
6428
|
}
|
|
@@ -6452,18 +6488,6 @@ class Functions {
|
|
|
6452
6488
|
if (typeof specification !== 'undefined') {
|
|
6453
6489
|
payload['specification'] = specification;
|
|
6454
6490
|
}
|
|
6455
|
-
if (typeof templateRepository !== 'undefined') {
|
|
6456
|
-
payload['templateRepository'] = templateRepository;
|
|
6457
|
-
}
|
|
6458
|
-
if (typeof templateOwner !== 'undefined') {
|
|
6459
|
-
payload['templateOwner'] = templateOwner;
|
|
6460
|
-
}
|
|
6461
|
-
if (typeof templateRootDirectory !== 'undefined') {
|
|
6462
|
-
payload['templateRootDirectory'] = templateRootDirectory;
|
|
6463
|
-
}
|
|
6464
|
-
if (typeof templateVersion !== 'undefined') {
|
|
6465
|
-
payload['templateVersion'] = templateVersion;
|
|
6466
|
-
}
|
|
6467
6491
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
6468
6492
|
const apiHeaders = {
|
|
6469
6493
|
'content-type': 'application/json',
|
|
@@ -14639,7 +14663,7 @@ class Tokens {
|
|
|
14639
14663
|
return this.client.call('get', uri, apiHeaders, payload);
|
|
14640
14664
|
}
|
|
14641
14665
|
/**
|
|
14642
|
-
* Create a new token. A token is linked to a file. Token can be passed as a
|
|
14666
|
+
* Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter.
|
|
14643
14667
|
*
|
|
14644
14668
|
* @param {string} bucketId
|
|
14645
14669
|
* @param {string} fileId
|