@appwrite.io/console 2.0.0 → 2.1.1
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/CHANGELOG.md +8 -0
- package/README.md +2 -2
- package/dist/cjs/sdk.js +81 -15
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +77 -15
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +3838 -15
- package/docs/examples/account/update-payment-method.md +1 -1
- package/docs/examples/projects/update-labels.md +14 -0
- package/package.json +7 -1
- package/rollup.config.js +40 -24
- package/src/client.ts +49 -10
- package/src/models.ts +432 -424
- package/src/query.ts +14 -11
- package/src/services/account.ts +20 -20
- package/src/services/avatars.ts +117 -117
- package/src/services/backups.ts +18 -18
- package/src/services/console.ts +24 -24
- package/src/services/databases.ts +119 -119
- package/src/services/domains.ts +204 -204
- package/src/services/functions.ts +30 -30
- package/src/services/health.ts +146 -146
- package/src/services/messaging.ts +54 -54
- package/src/services/migrations.ts +36 -36
- package/src/services/organizations.ts +42 -42
- package/src/services/projects.ts +146 -83
- package/src/services/sites.ts +30 -30
- package/src/services/storage.ts +49 -49
- package/src/services/tables-db.ts +119 -119
- package/src/services/users.ts +39 -39
- package/types/client.d.ts +27 -1
- package/types/models.d.ts +432 -424
- package/types/query.d.ts +8 -8
- package/types/services/account.d.ts +11 -11
- package/types/services/avatars.d.ts +82 -82
- package/types/services/backups.d.ts +8 -8
- package/types/services/console.d.ts +14 -14
- package/types/services/databases.d.ts +70 -70
- package/types/services/domains.d.ts +104 -104
- package/types/services/functions.d.ts +15 -15
- package/types/services/health.d.ts +72 -72
- package/types/services/messaging.d.ts +24 -24
- package/types/services/migrations.d.ts +16 -16
- package/types/services/organizations.d.ts +22 -22
- package/types/services/projects.d.ts +60 -38
- package/types/services/sites.d.ts +15 -15
- package/types/services/storage.d.ts +34 -34
- package/types/services/tables-db.d.ts +70 -70
- package/types/services/users.d.ts +24 -24
package/dist/esm/sdk.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import JSONbigModule from 'json-bigint';
|
|
2
|
+
|
|
1
3
|
/******************************************************************************
|
|
2
4
|
Copyright (c) Microsoft Corporation.
|
|
3
5
|
|
|
@@ -29,6 +31,7 @@ function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
|
29
31
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
30
32
|
}
|
|
31
33
|
|
|
34
|
+
const JSONbig$1 = JSONbigModule({ useNativeBigInt: true });
|
|
32
35
|
/**
|
|
33
36
|
* Helper class to generate query strings.
|
|
34
37
|
*/
|
|
@@ -58,7 +61,7 @@ class Query {
|
|
|
58
61
|
* @returns {string}
|
|
59
62
|
*/
|
|
60
63
|
toString() {
|
|
61
|
-
return
|
|
64
|
+
return JSONbig$1.stringify({
|
|
62
65
|
method: this.method,
|
|
63
66
|
attribute: this.attribute,
|
|
64
67
|
values: this.values,
|
|
@@ -131,8 +134,8 @@ Query.isNotNull = (attribute) => new Query("isNotNull", attribute).toString();
|
|
|
131
134
|
* Filter resources where attribute is between start and end (inclusive).
|
|
132
135
|
*
|
|
133
136
|
* @param {string} attribute
|
|
134
|
-
* @param {string | number} start
|
|
135
|
-
* @param {string | number} end
|
|
137
|
+
* @param {string | number | bigint} start
|
|
138
|
+
* @param {string | number | bigint} end
|
|
136
139
|
* @returns {string}
|
|
137
140
|
*/
|
|
138
141
|
Query.between = (attribute, start, end) => new Query("between", attribute, [start, end]).toString();
|
|
@@ -245,8 +248,8 @@ Query.notSearch = (attribute, value) => new Query("notSearch", attribute, value)
|
|
|
245
248
|
* Filter resources where attribute is not between start and end (exclusive).
|
|
246
249
|
*
|
|
247
250
|
* @param {string} attribute
|
|
248
|
-
* @param {string | number} start
|
|
249
|
-
* @param {string | number} end
|
|
251
|
+
* @param {string | number | bigint} start
|
|
252
|
+
* @param {string | number | bigint} end
|
|
250
253
|
* @returns {string}
|
|
251
254
|
*/
|
|
252
255
|
Query.notBetween = (attribute, start, end) => new Query("notBetween", attribute, [start, end]).toString();
|
|
@@ -316,14 +319,14 @@ Query.updatedBetween = (start, end) => Query.between("$updatedAt", start, end);
|
|
|
316
319
|
* @param {string[]} queries
|
|
317
320
|
* @returns {string}
|
|
318
321
|
*/
|
|
319
|
-
Query.or = (queries) => new Query("or", undefined, queries.map((query) =>
|
|
322
|
+
Query.or = (queries) => new Query("or", undefined, queries.map((query) => JSONbig$1.parse(query))).toString();
|
|
320
323
|
/**
|
|
321
324
|
* Combine multiple queries using logical AND operator.
|
|
322
325
|
*
|
|
323
326
|
* @param {string[]} queries
|
|
324
327
|
* @returns {string}
|
|
325
328
|
*/
|
|
326
|
-
Query.and = (queries) => new Query("and", undefined, queries.map((query) =>
|
|
329
|
+
Query.and = (queries) => new Query("and", undefined, queries.map((query) => JSONbig$1.parse(query))).toString();
|
|
327
330
|
/**
|
|
328
331
|
* Filter resources where attribute is at a specific distance from the given coordinates.
|
|
329
332
|
*
|
|
@@ -429,6 +432,7 @@ Query.touches = (attribute, values) => new Query("touches", attribute, [values])
|
|
|
429
432
|
*/
|
|
430
433
|
Query.notTouches = (attribute, values) => new Query("notTouches", attribute, [values]).toString();
|
|
431
434
|
|
|
435
|
+
const JSONbig = JSONbigModule({ useNativeBigInt: true });
|
|
432
436
|
/**
|
|
433
437
|
* Exception thrown by the package
|
|
434
438
|
*/
|
|
@@ -466,7 +470,10 @@ class Client {
|
|
|
466
470
|
jwt: '',
|
|
467
471
|
locale: '',
|
|
468
472
|
mode: '',
|
|
473
|
+
cookie: '',
|
|
469
474
|
platform: '',
|
|
475
|
+
selfSigned: false,
|
|
476
|
+
session: undefined,
|
|
470
477
|
};
|
|
471
478
|
/**
|
|
472
479
|
* Custom headers for API requests.
|
|
@@ -475,7 +482,7 @@ class Client {
|
|
|
475
482
|
'x-sdk-name': 'Console',
|
|
476
483
|
'x-sdk-platform': 'console',
|
|
477
484
|
'x-sdk-language': 'web',
|
|
478
|
-
'x-sdk-version': '2.
|
|
485
|
+
'x-sdk-version': '2.1.1',
|
|
479
486
|
'X-Appwrite-Response-Format': '1.8.0',
|
|
480
487
|
};
|
|
481
488
|
this.realtime = {
|
|
@@ -513,7 +520,7 @@ class Client {
|
|
|
513
520
|
}
|
|
514
521
|
this.realtime.heartbeat = window === null || window === void 0 ? void 0 : window.setInterval(() => {
|
|
515
522
|
var _a;
|
|
516
|
-
(_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.send(
|
|
523
|
+
(_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.send(JSONbig.stringify({
|
|
517
524
|
type: 'ping'
|
|
518
525
|
}));
|
|
519
526
|
}, 20000);
|
|
@@ -571,18 +578,18 @@ class Client {
|
|
|
571
578
|
onMessage: (event) => {
|
|
572
579
|
var _a, _b;
|
|
573
580
|
try {
|
|
574
|
-
const message =
|
|
581
|
+
const message = JSONbig.parse(event.data);
|
|
575
582
|
this.realtime.lastMessage = message;
|
|
576
583
|
switch (message.type) {
|
|
577
584
|
case 'connected':
|
|
578
585
|
let session = this.config.session;
|
|
579
586
|
if (!session) {
|
|
580
|
-
const cookie =
|
|
587
|
+
const cookie = JSONbig.parse((_a = window.localStorage.getItem('cookieFallback')) !== null && _a !== void 0 ? _a : '{}');
|
|
581
588
|
session = cookie === null || cookie === void 0 ? void 0 : cookie[`a_session_${this.config.project}`];
|
|
582
589
|
}
|
|
583
590
|
const messageData = message.data;
|
|
584
591
|
if (session && !messageData.user) {
|
|
585
|
-
(_b = this.realtime.socket) === null || _b === void 0 ? void 0 : _b.send(
|
|
592
|
+
(_b = this.realtime.socket) === null || _b === void 0 ? void 0 : _b.send(JSONbig.stringify({
|
|
586
593
|
type: 'authentication',
|
|
587
594
|
data: {
|
|
588
595
|
session
|
|
@@ -666,6 +673,17 @@ class Client {
|
|
|
666
673
|
this.config.endpointRealtime = endpointRealtime;
|
|
667
674
|
return this;
|
|
668
675
|
}
|
|
676
|
+
/**
|
|
677
|
+
* Set self-signed
|
|
678
|
+
*
|
|
679
|
+
* @param {boolean} selfSigned
|
|
680
|
+
*
|
|
681
|
+
* @returns {this}
|
|
682
|
+
*/
|
|
683
|
+
setSelfSigned(selfSigned) {
|
|
684
|
+
this.config.selfSigned = selfSigned;
|
|
685
|
+
return this;
|
|
686
|
+
}
|
|
669
687
|
/**
|
|
670
688
|
* Set Project
|
|
671
689
|
*
|
|
@@ -732,6 +750,20 @@ class Client {
|
|
|
732
750
|
this.config.mode = value;
|
|
733
751
|
return this;
|
|
734
752
|
}
|
|
753
|
+
/**
|
|
754
|
+
* Set Cookie
|
|
755
|
+
*
|
|
756
|
+
* The user cookie to authenticate with
|
|
757
|
+
*
|
|
758
|
+
* @param value string
|
|
759
|
+
*
|
|
760
|
+
* @return {this}
|
|
761
|
+
*/
|
|
762
|
+
setCookie(value) {
|
|
763
|
+
this.headers['Cookie'] = value;
|
|
764
|
+
this.config.cookie = value;
|
|
765
|
+
return this;
|
|
766
|
+
}
|
|
735
767
|
/**
|
|
736
768
|
* Set Platform
|
|
737
769
|
*
|
|
@@ -813,7 +845,7 @@ class Client {
|
|
|
813
845
|
else {
|
|
814
846
|
switch (headers['content-type']) {
|
|
815
847
|
case 'application/json':
|
|
816
|
-
options.body =
|
|
848
|
+
options.body = JSONbig.stringify(params);
|
|
817
849
|
break;
|
|
818
850
|
case 'multipart/form-data':
|
|
819
851
|
const formData = new FormData();
|
|
@@ -896,7 +928,7 @@ class Client {
|
|
|
896
928
|
warnings.split(';').forEach((warning) => console.warn('Warning: ' + warning));
|
|
897
929
|
}
|
|
898
930
|
if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
|
|
899
|
-
data = yield response.
|
|
931
|
+
data = JSONbig.parse(yield response.text());
|
|
900
932
|
}
|
|
901
933
|
else if (responseType === 'arrayBuffer') {
|
|
902
934
|
data = yield response.arrayBuffer();
|
|
@@ -909,7 +941,7 @@ class Client {
|
|
|
909
941
|
if (400 <= response.status) {
|
|
910
942
|
let responseText = '';
|
|
911
943
|
if (((_b = response.headers.get('content-type')) === null || _b === void 0 ? void 0 : _b.includes('application/json')) || responseType === 'arrayBuffer') {
|
|
912
|
-
responseText =
|
|
944
|
+
responseText = JSONbig.stringify(data);
|
|
913
945
|
}
|
|
914
946
|
else {
|
|
915
947
|
responseText = data === null || data === void 0 ? void 0 : data.message;
|
|
@@ -16156,6 +16188,36 @@ class Projects {
|
|
|
16156
16188
|
};
|
|
16157
16189
|
return this.client.call('delete', uri, apiHeaders, payload);
|
|
16158
16190
|
}
|
|
16191
|
+
updateLabels(paramsOrFirst, ...rest) {
|
|
16192
|
+
let params;
|
|
16193
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
16194
|
+
params = (paramsOrFirst || {});
|
|
16195
|
+
}
|
|
16196
|
+
else {
|
|
16197
|
+
params = {
|
|
16198
|
+
projectId: paramsOrFirst,
|
|
16199
|
+
labels: rest[0]
|
|
16200
|
+
};
|
|
16201
|
+
}
|
|
16202
|
+
const projectId = params.projectId;
|
|
16203
|
+
const labels = params.labels;
|
|
16204
|
+
if (typeof projectId === 'undefined') {
|
|
16205
|
+
throw new AppwriteException('Missing required parameter: "projectId"');
|
|
16206
|
+
}
|
|
16207
|
+
if (typeof labels === 'undefined') {
|
|
16208
|
+
throw new AppwriteException('Missing required parameter: "labels"');
|
|
16209
|
+
}
|
|
16210
|
+
const apiPath = '/projects/{projectId}/labels'.replace('{projectId}', projectId);
|
|
16211
|
+
const payload = {};
|
|
16212
|
+
if (typeof labels !== 'undefined') {
|
|
16213
|
+
payload['labels'] = labels;
|
|
16214
|
+
}
|
|
16215
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
16216
|
+
const apiHeaders = {
|
|
16217
|
+
'content-type': 'application/json',
|
|
16218
|
+
};
|
|
16219
|
+
return this.client.call('put', uri, apiHeaders, payload);
|
|
16220
|
+
}
|
|
16159
16221
|
updateOAuth2(paramsOrFirst, ...rest) {
|
|
16160
16222
|
let params;
|
|
16161
16223
|
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|