@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/iife/sdk.js
CHANGED
|
@@ -281,7 +281,7 @@
|
|
|
281
281
|
'x-sdk-name': 'Console',
|
|
282
282
|
'x-sdk-platform': 'console',
|
|
283
283
|
'x-sdk-language': 'web',
|
|
284
|
-
'x-sdk-version': '1.
|
|
284
|
+
'x-sdk-version': '1.8.0',
|
|
285
285
|
'X-Appwrite-Response-Format': '1.7.0',
|
|
286
286
|
};
|
|
287
287
|
this.realtime = {
|
|
@@ -579,8 +579,10 @@
|
|
|
579
579
|
let options = {
|
|
580
580
|
method,
|
|
581
581
|
headers,
|
|
582
|
-
credentials: 'include',
|
|
583
582
|
};
|
|
583
|
+
if (headers['X-Appwrite-Dev-Key'] === undefined) {
|
|
584
|
+
options.credentials = 'include';
|
|
585
|
+
}
|
|
584
586
|
if (method === 'GET') {
|
|
585
587
|
for (const [key, value] of Object.entries(Client.flatten(params))) {
|
|
586
588
|
url.searchParams.append(key, value);
|
|
@@ -4518,6 +4520,44 @@
|
|
|
4518
4520
|
const apiHeaders = {};
|
|
4519
4521
|
return this.client.call('get', uri, apiHeaders, payload);
|
|
4520
4522
|
}
|
|
4523
|
+
/**
|
|
4524
|
+
* 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.
|
|
4525
|
+
*
|
|
4526
|
+
* @param {string} databaseId
|
|
4527
|
+
* @param {string} collectionId
|
|
4528
|
+
* @param {string} documentId
|
|
4529
|
+
* @param {object} data
|
|
4530
|
+
* @param {string[]} permissions
|
|
4531
|
+
* @throws {AppwriteException}
|
|
4532
|
+
* @returns {Promise<Document>}
|
|
4533
|
+
*/
|
|
4534
|
+
upsertDocument(databaseId, collectionId, documentId, data, permissions) {
|
|
4535
|
+
if (typeof databaseId === 'undefined') {
|
|
4536
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
4537
|
+
}
|
|
4538
|
+
if (typeof collectionId === 'undefined') {
|
|
4539
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
4540
|
+
}
|
|
4541
|
+
if (typeof documentId === 'undefined') {
|
|
4542
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
4543
|
+
}
|
|
4544
|
+
if (typeof data === 'undefined') {
|
|
4545
|
+
throw new AppwriteException('Missing required parameter: "data"');
|
|
4546
|
+
}
|
|
4547
|
+
const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
|
|
4548
|
+
const payload = {};
|
|
4549
|
+
if (typeof data !== 'undefined') {
|
|
4550
|
+
payload['data'] = data;
|
|
4551
|
+
}
|
|
4552
|
+
if (typeof permissions !== 'undefined') {
|
|
4553
|
+
payload['permissions'] = permissions;
|
|
4554
|
+
}
|
|
4555
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
4556
|
+
const apiHeaders = {
|
|
4557
|
+
'content-type': 'application/json',
|
|
4558
|
+
};
|
|
4559
|
+
return this.client.call('put', uri, apiHeaders, payload);
|
|
4560
|
+
}
|
|
4521
4561
|
/**
|
|
4522
4562
|
* Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.
|
|
4523
4563
|
*
|
|
@@ -6382,14 +6422,10 @@
|
|
|
6382
6422
|
* @param {boolean} providerSilentMode
|
|
6383
6423
|
* @param {string} providerRootDirectory
|
|
6384
6424
|
* @param {string} specification
|
|
6385
|
-
* @param {string} templateRepository
|
|
6386
|
-
* @param {string} templateOwner
|
|
6387
|
-
* @param {string} templateRootDirectory
|
|
6388
|
-
* @param {string} templateVersion
|
|
6389
6425
|
* @throws {AppwriteException}
|
|
6390
6426
|
* @returns {Promise<Models.Function>}
|
|
6391
6427
|
*/
|
|
6392
|
-
create(functionId, name, runtime, execute, events, schedule, timeout, enabled, logging, entrypoint, commands, scopes, installationId, providerRepositoryId, providerBranch, providerSilentMode, providerRootDirectory, specification
|
|
6428
|
+
create(functionId, name, runtime, execute, events, schedule, timeout, enabled, logging, entrypoint, commands, scopes, installationId, providerRepositoryId, providerBranch, providerSilentMode, providerRootDirectory, specification) {
|
|
6393
6429
|
if (typeof functionId === 'undefined') {
|
|
6394
6430
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
6395
6431
|
}
|
|
@@ -6455,18 +6491,6 @@
|
|
|
6455
6491
|
if (typeof specification !== 'undefined') {
|
|
6456
6492
|
payload['specification'] = specification;
|
|
6457
6493
|
}
|
|
6458
|
-
if (typeof templateRepository !== 'undefined') {
|
|
6459
|
-
payload['templateRepository'] = templateRepository;
|
|
6460
|
-
}
|
|
6461
|
-
if (typeof templateOwner !== 'undefined') {
|
|
6462
|
-
payload['templateOwner'] = templateOwner;
|
|
6463
|
-
}
|
|
6464
|
-
if (typeof templateRootDirectory !== 'undefined') {
|
|
6465
|
-
payload['templateRootDirectory'] = templateRootDirectory;
|
|
6466
|
-
}
|
|
6467
|
-
if (typeof templateVersion !== 'undefined') {
|
|
6468
|
-
payload['templateVersion'] = templateVersion;
|
|
6469
|
-
}
|
|
6470
6494
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
6471
6495
|
const apiHeaders = {
|
|
6472
6496
|
'content-type': 'application/json',
|
|
@@ -14642,7 +14666,7 @@
|
|
|
14642
14666
|
return this.client.call('get', uri, apiHeaders, payload);
|
|
14643
14667
|
}
|
|
14644
14668
|
/**
|
|
14645
|
-
* Create a new token. A token is linked to a file. Token can be passed as a
|
|
14669
|
+
* Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter.
|
|
14646
14670
|
*
|
|
14647
14671
|
* @param {string} bucketId
|
|
14648
14672
|
* @param {string} fileId
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Client, Databases } from "@appwrite.io/console";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const databases = new Databases(client);
|
|
8
|
+
|
|
9
|
+
const result = await databases.upsertDocument(
|
|
10
|
+
'<DATABASE_ID>', // databaseId
|
|
11
|
+
'<COLLECTION_ID>', // collectionId
|
|
12
|
+
'<DOCUMENT_ID>', // documentId
|
|
13
|
+
{}, // data
|
|
14
|
+
["read("any")"] // permissions (optional)
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
console.log(result);
|
|
@@ -24,11 +24,7 @@ const result = await functions.create(
|
|
|
24
24
|
'<PROVIDER_BRANCH>', // providerBranch (optional)
|
|
25
25
|
false, // providerSilentMode (optional)
|
|
26
26
|
'<PROVIDER_ROOT_DIRECTORY>', // providerRootDirectory (optional)
|
|
27
|
-
''
|
|
28
|
-
'<TEMPLATE_REPOSITORY>', // templateRepository (optional)
|
|
29
|
-
'<TEMPLATE_OWNER>', // templateOwner (optional)
|
|
30
|
-
'<TEMPLATE_ROOT_DIRECTORY>', // templateRootDirectory (optional)
|
|
31
|
-
'<TEMPLATE_VERSION>' // templateVersion (optional)
|
|
27
|
+
'' // specification (optional)
|
|
32
28
|
);
|
|
33
29
|
|
|
34
30
|
console.log(result);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@appwrite.io/console",
|
|
3
3
|
"homepage": "https://appwrite.io/support",
|
|
4
4
|
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.8.0",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "dist/cjs/sdk.js",
|
|
8
8
|
"exports": {
|
package/src/client.ts
CHANGED
|
@@ -316,7 +316,7 @@ class Client {
|
|
|
316
316
|
'x-sdk-name': 'Console',
|
|
317
317
|
'x-sdk-platform': 'console',
|
|
318
318
|
'x-sdk-language': 'web',
|
|
319
|
-
'x-sdk-version': '1.
|
|
319
|
+
'x-sdk-version': '1.8.0',
|
|
320
320
|
'X-Appwrite-Response-Format': '1.7.0',
|
|
321
321
|
};
|
|
322
322
|
|
|
@@ -636,9 +636,12 @@ class Client {
|
|
|
636
636
|
let options: RequestInit = {
|
|
637
637
|
method,
|
|
638
638
|
headers,
|
|
639
|
-
credentials: 'include',
|
|
640
639
|
};
|
|
641
640
|
|
|
641
|
+
if (headers['X-Appwrite-Dev-Key'] === undefined) {
|
|
642
|
+
options.credentials = 'include';
|
|
643
|
+
}
|
|
644
|
+
|
|
642
645
|
if (method === 'GET') {
|
|
643
646
|
for (const [key, value] of Object.entries(Client.flatten(params))) {
|
|
644
647
|
url.searchParams.append(key, value);
|
package/src/models.ts
CHANGED
|
@@ -735,6 +735,10 @@ export namespace Models {
|
|
|
735
735
|
* Default value for attribute when not provided. Cannot be set when attribute is required.
|
|
736
736
|
*/
|
|
737
737
|
default?: string;
|
|
738
|
+
/**
|
|
739
|
+
* Defines whether this attribute is encrypted or not.
|
|
740
|
+
*/
|
|
741
|
+
encrypt?: boolean;
|
|
738
742
|
}
|
|
739
743
|
/**
|
|
740
744
|
* AttributeInteger
|
|
@@ -5382,6 +5386,14 @@ export namespace Models {
|
|
|
5382
5386
|
* How many policies does plan support
|
|
5383
5387
|
*/
|
|
5384
5388
|
backupPolicies: number;
|
|
5389
|
+
/**
|
|
5390
|
+
* Maximum function and site deployment size in MB
|
|
5391
|
+
*/
|
|
5392
|
+
deploymentSize: number;
|
|
5393
|
+
/**
|
|
5394
|
+
* Maximum function and site deployment size in MB
|
|
5395
|
+
*/
|
|
5396
|
+
buildSize: number;
|
|
5385
5397
|
}
|
|
5386
5398
|
/**
|
|
5387
5399
|
* BillingPlanAddon
|
|
@@ -1867,6 +1867,51 @@ export class Databases {
|
|
|
1867
1867
|
payload
|
|
1868
1868
|
);
|
|
1869
1869
|
}
|
|
1870
|
+
/**
|
|
1871
|
+
* 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.
|
|
1872
|
+
*
|
|
1873
|
+
* @param {string} databaseId
|
|
1874
|
+
* @param {string} collectionId
|
|
1875
|
+
* @param {string} documentId
|
|
1876
|
+
* @param {object} data
|
|
1877
|
+
* @param {string[]} permissions
|
|
1878
|
+
* @throws {AppwriteException}
|
|
1879
|
+
* @returns {Promise<Document>}
|
|
1880
|
+
*/
|
|
1881
|
+
upsertDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise<Document> {
|
|
1882
|
+
if (typeof databaseId === 'undefined') {
|
|
1883
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1884
|
+
}
|
|
1885
|
+
if (typeof collectionId === 'undefined') {
|
|
1886
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1887
|
+
}
|
|
1888
|
+
if (typeof documentId === 'undefined') {
|
|
1889
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
1890
|
+
}
|
|
1891
|
+
if (typeof data === 'undefined') {
|
|
1892
|
+
throw new AppwriteException('Missing required parameter: "data"');
|
|
1893
|
+
}
|
|
1894
|
+
const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
|
|
1895
|
+
const payload: Payload = {};
|
|
1896
|
+
if (typeof data !== 'undefined') {
|
|
1897
|
+
payload['data'] = data;
|
|
1898
|
+
}
|
|
1899
|
+
if (typeof permissions !== 'undefined') {
|
|
1900
|
+
payload['permissions'] = permissions;
|
|
1901
|
+
}
|
|
1902
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1903
|
+
|
|
1904
|
+
const apiHeaders: { [header: string]: string } = {
|
|
1905
|
+
'content-type': 'application/json',
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
return this.client.call(
|
|
1909
|
+
'put',
|
|
1910
|
+
uri,
|
|
1911
|
+
apiHeaders,
|
|
1912
|
+
payload
|
|
1913
|
+
);
|
|
1914
|
+
}
|
|
1870
1915
|
/**
|
|
1871
1916
|
* Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.
|
|
1872
1917
|
*
|
|
@@ -64,14 +64,10 @@ export class Functions {
|
|
|
64
64
|
* @param {boolean} providerSilentMode
|
|
65
65
|
* @param {string} providerRootDirectory
|
|
66
66
|
* @param {string} specification
|
|
67
|
-
* @param {string} templateRepository
|
|
68
|
-
* @param {string} templateOwner
|
|
69
|
-
* @param {string} templateRootDirectory
|
|
70
|
-
* @param {string} templateVersion
|
|
71
67
|
* @throws {AppwriteException}
|
|
72
68
|
* @returns {Promise<Models.Function>}
|
|
73
69
|
*/
|
|
74
|
-
create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string
|
|
70
|
+
create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise<Models.Function> {
|
|
75
71
|
if (typeof functionId === 'undefined') {
|
|
76
72
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
77
73
|
}
|
|
@@ -137,18 +133,6 @@ export class Functions {
|
|
|
137
133
|
if (typeof specification !== 'undefined') {
|
|
138
134
|
payload['specification'] = specification;
|
|
139
135
|
}
|
|
140
|
-
if (typeof templateRepository !== 'undefined') {
|
|
141
|
-
payload['templateRepository'] = templateRepository;
|
|
142
|
-
}
|
|
143
|
-
if (typeof templateOwner !== 'undefined') {
|
|
144
|
-
payload['templateOwner'] = templateOwner;
|
|
145
|
-
}
|
|
146
|
-
if (typeof templateRootDirectory !== 'undefined') {
|
|
147
|
-
payload['templateRootDirectory'] = templateRootDirectory;
|
|
148
|
-
}
|
|
149
|
-
if (typeof templateVersion !== 'undefined') {
|
|
150
|
-
payload['templateVersion'] = templateVersion;
|
|
151
|
-
}
|
|
152
136
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
153
137
|
|
|
154
138
|
const apiHeaders: { [header: string]: string } = {
|
package/src/services/tokens.ts
CHANGED
|
@@ -43,7 +43,7 @@ export class Tokens {
|
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
* Create a new token. A token is linked to a file. Token can be passed as a
|
|
46
|
+
* Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter.
|
|
47
47
|
*
|
|
48
48
|
* @param {string} bucketId
|
|
49
49
|
* @param {string} fileId
|
package/types/models.d.ts
CHANGED
|
@@ -735,6 +735,10 @@ export declare namespace Models {
|
|
|
735
735
|
* Default value for attribute when not provided. Cannot be set when attribute is required.
|
|
736
736
|
*/
|
|
737
737
|
default?: string;
|
|
738
|
+
/**
|
|
739
|
+
* Defines whether this attribute is encrypted or not.
|
|
740
|
+
*/
|
|
741
|
+
encrypt?: boolean;
|
|
738
742
|
};
|
|
739
743
|
/**
|
|
740
744
|
* AttributeInteger
|
|
@@ -5382,6 +5386,14 @@ export declare namespace Models {
|
|
|
5382
5386
|
* How many policies does plan support
|
|
5383
5387
|
*/
|
|
5384
5388
|
backupPolicies: number;
|
|
5389
|
+
/**
|
|
5390
|
+
* Maximum function and site deployment size in MB
|
|
5391
|
+
*/
|
|
5392
|
+
deploymentSize: number;
|
|
5393
|
+
/**
|
|
5394
|
+
* Maximum function and site deployment size in MB
|
|
5395
|
+
*/
|
|
5396
|
+
buildSize: number;
|
|
5385
5397
|
};
|
|
5386
5398
|
/**
|
|
5387
5399
|
* BillingPlanAddon
|
|
@@ -511,6 +511,18 @@ export declare class Databases {
|
|
|
511
511
|
* @returns {Promise<Document>}
|
|
512
512
|
*/
|
|
513
513
|
getDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise<Document>;
|
|
514
|
+
/**
|
|
515
|
+
* 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.
|
|
516
|
+
*
|
|
517
|
+
* @param {string} databaseId
|
|
518
|
+
* @param {string} collectionId
|
|
519
|
+
* @param {string} documentId
|
|
520
|
+
* @param {object} data
|
|
521
|
+
* @param {string[]} permissions
|
|
522
|
+
* @throws {AppwriteException}
|
|
523
|
+
* @returns {Promise<Document>}
|
|
524
|
+
*/
|
|
525
|
+
upsertDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise<Document>;
|
|
514
526
|
/**
|
|
515
527
|
* Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.
|
|
516
528
|
*
|
|
@@ -38,14 +38,10 @@ export declare class Functions {
|
|
|
38
38
|
* @param {boolean} providerSilentMode
|
|
39
39
|
* @param {string} providerRootDirectory
|
|
40
40
|
* @param {string} specification
|
|
41
|
-
* @param {string} templateRepository
|
|
42
|
-
* @param {string} templateOwner
|
|
43
|
-
* @param {string} templateRootDirectory
|
|
44
|
-
* @param {string} templateVersion
|
|
45
41
|
* @throws {AppwriteException}
|
|
46
42
|
* @returns {Promise<Models.Function>}
|
|
47
43
|
*/
|
|
48
|
-
create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string
|
|
44
|
+
create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise<Models.Function>;
|
|
49
45
|
/**
|
|
50
46
|
* Get a list of all runtimes that are currently active on your instance.
|
|
51
47
|
*
|
|
@@ -14,7 +14,7 @@ export declare class Tokens {
|
|
|
14
14
|
*/
|
|
15
15
|
list(bucketId: string, fileId: string, queries?: string[]): Promise<Models.ResourceTokenList>;
|
|
16
16
|
/**
|
|
17
|
-
* Create a new token. A token is linked to a file. Token can be passed as a
|
|
17
|
+
* Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter.
|
|
18
18
|
*
|
|
19
19
|
* @param {string} bucketId
|
|
20
20
|
* @param {string} fileId
|