@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.
Files changed (49) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +2 -2
  3. package/dist/cjs/sdk.js +81 -15
  4. package/dist/cjs/sdk.js.map +1 -1
  5. package/dist/esm/sdk.js +77 -15
  6. package/dist/esm/sdk.js.map +1 -1
  7. package/dist/iife/sdk.js +3838 -15
  8. package/docs/examples/account/update-payment-method.md +1 -1
  9. package/docs/examples/projects/update-labels.md +14 -0
  10. package/package.json +7 -1
  11. package/rollup.config.js +40 -24
  12. package/src/client.ts +49 -10
  13. package/src/models.ts +432 -424
  14. package/src/query.ts +14 -11
  15. package/src/services/account.ts +20 -20
  16. package/src/services/avatars.ts +117 -117
  17. package/src/services/backups.ts +18 -18
  18. package/src/services/console.ts +24 -24
  19. package/src/services/databases.ts +119 -119
  20. package/src/services/domains.ts +204 -204
  21. package/src/services/functions.ts +30 -30
  22. package/src/services/health.ts +146 -146
  23. package/src/services/messaging.ts +54 -54
  24. package/src/services/migrations.ts +36 -36
  25. package/src/services/organizations.ts +42 -42
  26. package/src/services/projects.ts +146 -83
  27. package/src/services/sites.ts +30 -30
  28. package/src/services/storage.ts +49 -49
  29. package/src/services/tables-db.ts +119 -119
  30. package/src/services/users.ts +39 -39
  31. package/types/client.d.ts +27 -1
  32. package/types/models.d.ts +432 -424
  33. package/types/query.d.ts +8 -8
  34. package/types/services/account.d.ts +11 -11
  35. package/types/services/avatars.d.ts +82 -82
  36. package/types/services/backups.d.ts +8 -8
  37. package/types/services/console.d.ts +14 -14
  38. package/types/services/databases.d.ts +70 -70
  39. package/types/services/domains.d.ts +104 -104
  40. package/types/services/functions.d.ts +15 -15
  41. package/types/services/health.d.ts +72 -72
  42. package/types/services/messaging.d.ts +24 -24
  43. package/types/services/migrations.d.ts +16 -16
  44. package/types/services/organizations.d.ts +22 -22
  45. package/types/services/projects.d.ts +60 -38
  46. package/types/services/sites.d.ts +15 -15
  47. package/types/services/storage.d.ts +34 -34
  48. package/types/services/tables-db.d.ts +70 -70
  49. package/types/services/users.d.ts +24 -24
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.1.1
4
+
5
+ * Allow `bigint` to be passed in all methods that previously only accepted `number`
6
+
7
+ ## 2.1.0
8
+
9
+ * Add `setSelfSigned` and `setCookie` methods to `Client` class
10
+
3
11
  ## 2.0.0
4
12
 
5
13
  * Update SDK examples to use object-based parameters instead of positional arguments
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Appwrite Console SDK
2
2
 
3
3
  ![License](https://img.shields.io/github/license/appwrite/sdk-for-console.svg?style=flat-square)
4
- ![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square)
4
+ ![Version](https://img.shields.io/badge/api%20version-1.8.1-blue.svg?style=flat-square)
5
5
  [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
6
6
  [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
7
7
  [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
@@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console";
33
33
  To install with a CDN (content delivery network) add the following scripts to the bottom of your <body> tag, but before you use any Appwrite services:
34
34
 
35
35
  ```html
36
- <script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@2.0.0"></script>
36
+ <script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@2.1.1"></script>
37
37
  ```
38
38
 
39
39
 
package/dist/cjs/sdk.js CHANGED
@@ -1,5 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ var JSONbigModule = require('json-bigint');
4
+
5
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
6
+
7
+ var JSONbigModule__default = /*#__PURE__*/_interopDefaultLegacy(JSONbigModule);
8
+
3
9
  /******************************************************************************
4
10
  Copyright (c) Microsoft Corporation.
5
11
 
@@ -31,6 +37,7 @@ function __classPrivateFieldGet(receiver, state, kind, f) {
31
37
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
32
38
  }
33
39
 
40
+ const JSONbig$1 = JSONbigModule__default["default"]({ useNativeBigInt: true });
34
41
  /**
35
42
  * Helper class to generate query strings.
36
43
  */
@@ -60,7 +67,7 @@ class Query {
60
67
  * @returns {string}
61
68
  */
62
69
  toString() {
63
- return JSON.stringify({
70
+ return JSONbig$1.stringify({
64
71
  method: this.method,
65
72
  attribute: this.attribute,
66
73
  values: this.values,
@@ -133,8 +140,8 @@ Query.isNotNull = (attribute) => new Query("isNotNull", attribute).toString();
133
140
  * Filter resources where attribute is between start and end (inclusive).
134
141
  *
135
142
  * @param {string} attribute
136
- * @param {string | number} start
137
- * @param {string | number} end
143
+ * @param {string | number | bigint} start
144
+ * @param {string | number | bigint} end
138
145
  * @returns {string}
139
146
  */
140
147
  Query.between = (attribute, start, end) => new Query("between", attribute, [start, end]).toString();
@@ -247,8 +254,8 @@ Query.notSearch = (attribute, value) => new Query("notSearch", attribute, value)
247
254
  * Filter resources where attribute is not between start and end (exclusive).
248
255
  *
249
256
  * @param {string} attribute
250
- * @param {string | number} start
251
- * @param {string | number} end
257
+ * @param {string | number | bigint} start
258
+ * @param {string | number | bigint} end
252
259
  * @returns {string}
253
260
  */
254
261
  Query.notBetween = (attribute, start, end) => new Query("notBetween", attribute, [start, end]).toString();
@@ -318,14 +325,14 @@ Query.updatedBetween = (start, end) => Query.between("$updatedAt", start, end);
318
325
  * @param {string[]} queries
319
326
  * @returns {string}
320
327
  */
321
- Query.or = (queries) => new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString();
328
+ Query.or = (queries) => new Query("or", undefined, queries.map((query) => JSONbig$1.parse(query))).toString();
322
329
  /**
323
330
  * Combine multiple queries using logical AND operator.
324
331
  *
325
332
  * @param {string[]} queries
326
333
  * @returns {string}
327
334
  */
328
- Query.and = (queries) => new Query("and", undefined, queries.map((query) => JSON.parse(query))).toString();
335
+ Query.and = (queries) => new Query("and", undefined, queries.map((query) => JSONbig$1.parse(query))).toString();
329
336
  /**
330
337
  * Filter resources where attribute is at a specific distance from the given coordinates.
331
338
  *
@@ -431,6 +438,7 @@ Query.touches = (attribute, values) => new Query("touches", attribute, [values])
431
438
  */
432
439
  Query.notTouches = (attribute, values) => new Query("notTouches", attribute, [values]).toString();
433
440
 
441
+ const JSONbig = JSONbigModule__default["default"]({ useNativeBigInt: true });
434
442
  /**
435
443
  * Exception thrown by the package
436
444
  */
@@ -468,7 +476,10 @@ class Client {
468
476
  jwt: '',
469
477
  locale: '',
470
478
  mode: '',
479
+ cookie: '',
471
480
  platform: '',
481
+ selfSigned: false,
482
+ session: undefined,
472
483
  };
473
484
  /**
474
485
  * Custom headers for API requests.
@@ -477,7 +488,7 @@ class Client {
477
488
  'x-sdk-name': 'Console',
478
489
  'x-sdk-platform': 'console',
479
490
  'x-sdk-language': 'web',
480
- 'x-sdk-version': '2.0.0',
491
+ 'x-sdk-version': '2.1.1',
481
492
  'X-Appwrite-Response-Format': '1.8.0',
482
493
  };
483
494
  this.realtime = {
@@ -515,7 +526,7 @@ class Client {
515
526
  }
516
527
  this.realtime.heartbeat = window === null || window === void 0 ? void 0 : window.setInterval(() => {
517
528
  var _a;
518
- (_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify({
529
+ (_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.send(JSONbig.stringify({
519
530
  type: 'ping'
520
531
  }));
521
532
  }, 20000);
@@ -573,18 +584,18 @@ class Client {
573
584
  onMessage: (event) => {
574
585
  var _a, _b;
575
586
  try {
576
- const message = JSON.parse(event.data);
587
+ const message = JSONbig.parse(event.data);
577
588
  this.realtime.lastMessage = message;
578
589
  switch (message.type) {
579
590
  case 'connected':
580
591
  let session = this.config.session;
581
592
  if (!session) {
582
- const cookie = JSON.parse((_a = window.localStorage.getItem('cookieFallback')) !== null && _a !== void 0 ? _a : '{}');
593
+ const cookie = JSONbig.parse((_a = window.localStorage.getItem('cookieFallback')) !== null && _a !== void 0 ? _a : '{}');
583
594
  session = cookie === null || cookie === void 0 ? void 0 : cookie[`a_session_${this.config.project}`];
584
595
  }
585
596
  const messageData = message.data;
586
597
  if (session && !messageData.user) {
587
- (_b = this.realtime.socket) === null || _b === void 0 ? void 0 : _b.send(JSON.stringify({
598
+ (_b = this.realtime.socket) === null || _b === void 0 ? void 0 : _b.send(JSONbig.stringify({
588
599
  type: 'authentication',
589
600
  data: {
590
601
  session
@@ -668,6 +679,17 @@ class Client {
668
679
  this.config.endpointRealtime = endpointRealtime;
669
680
  return this;
670
681
  }
682
+ /**
683
+ * Set self-signed
684
+ *
685
+ * @param {boolean} selfSigned
686
+ *
687
+ * @returns {this}
688
+ */
689
+ setSelfSigned(selfSigned) {
690
+ this.config.selfSigned = selfSigned;
691
+ return this;
692
+ }
671
693
  /**
672
694
  * Set Project
673
695
  *
@@ -734,6 +756,20 @@ class Client {
734
756
  this.config.mode = value;
735
757
  return this;
736
758
  }
759
+ /**
760
+ * Set Cookie
761
+ *
762
+ * The user cookie to authenticate with
763
+ *
764
+ * @param value string
765
+ *
766
+ * @return {this}
767
+ */
768
+ setCookie(value) {
769
+ this.headers['Cookie'] = value;
770
+ this.config.cookie = value;
771
+ return this;
772
+ }
737
773
  /**
738
774
  * Set Platform
739
775
  *
@@ -815,7 +851,7 @@ class Client {
815
851
  else {
816
852
  switch (headers['content-type']) {
817
853
  case 'application/json':
818
- options.body = JSON.stringify(params);
854
+ options.body = JSONbig.stringify(params);
819
855
  break;
820
856
  case 'multipart/form-data':
821
857
  const formData = new FormData();
@@ -898,7 +934,7 @@ class Client {
898
934
  warnings.split(';').forEach((warning) => console.warn('Warning: ' + warning));
899
935
  }
900
936
  if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
901
- data = yield response.json();
937
+ data = JSONbig.parse(yield response.text());
902
938
  }
903
939
  else if (responseType === 'arrayBuffer') {
904
940
  data = yield response.arrayBuffer();
@@ -911,7 +947,7 @@ class Client {
911
947
  if (400 <= response.status) {
912
948
  let responseText = '';
913
949
  if (((_b = response.headers.get('content-type')) === null || _b === void 0 ? void 0 : _b.includes('application/json')) || responseType === 'arrayBuffer') {
914
- responseText = JSON.stringify(data);
950
+ responseText = JSONbig.stringify(data);
915
951
  }
916
952
  else {
917
953
  responseText = data === null || data === void 0 ? void 0 : data.message;
@@ -16158,6 +16194,36 @@ class Projects {
16158
16194
  };
16159
16195
  return this.client.call('delete', uri, apiHeaders, payload);
16160
16196
  }
16197
+ updateLabels(paramsOrFirst, ...rest) {
16198
+ let params;
16199
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
16200
+ params = (paramsOrFirst || {});
16201
+ }
16202
+ else {
16203
+ params = {
16204
+ projectId: paramsOrFirst,
16205
+ labels: rest[0]
16206
+ };
16207
+ }
16208
+ const projectId = params.projectId;
16209
+ const labels = params.labels;
16210
+ if (typeof projectId === 'undefined') {
16211
+ throw new AppwriteException('Missing required parameter: "projectId"');
16212
+ }
16213
+ if (typeof labels === 'undefined') {
16214
+ throw new AppwriteException('Missing required parameter: "labels"');
16215
+ }
16216
+ const apiPath = '/projects/{projectId}/labels'.replace('{projectId}', projectId);
16217
+ const payload = {};
16218
+ if (typeof labels !== 'undefined') {
16219
+ payload['labels'] = labels;
16220
+ }
16221
+ const uri = new URL(this.client.config.endpoint + apiPath);
16222
+ const apiHeaders = {
16223
+ 'content-type': 'application/json',
16224
+ };
16225
+ return this.client.call('put', uri, apiHeaders, payload);
16226
+ }
16161
16227
  updateOAuth2(paramsOrFirst, ...rest) {
16162
16228
  let params;
16163
16229
  if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {