@appwrite.io/console 2.1.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 (48) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +2 -2
  3. package/dist/cjs/sdk.js +55 -16
  4. package/dist/cjs/sdk.js.map +1 -1
  5. package/dist/esm/sdk.js +51 -16
  6. package/dist/esm/sdk.js.map +1 -1
  7. package/dist/iife/sdk.js +3812 -16
  8. package/docs/examples/projects/update-labels.md +14 -0
  9. package/package.json +7 -1
  10. package/rollup.config.js +40 -24
  11. package/src/client.ts +20 -10
  12. package/src/models.ts +432 -424
  13. package/src/query.ts +14 -11
  14. package/src/services/account.ts +20 -20
  15. package/src/services/avatars.ts +117 -117
  16. package/src/services/backups.ts +18 -18
  17. package/src/services/console.ts +24 -24
  18. package/src/services/databases.ts +119 -119
  19. package/src/services/domains.ts +204 -204
  20. package/src/services/functions.ts +30 -30
  21. package/src/services/health.ts +146 -146
  22. package/src/services/messaging.ts +54 -54
  23. package/src/services/migrations.ts +36 -36
  24. package/src/services/organizations.ts +42 -42
  25. package/src/services/projects.ts +146 -83
  26. package/src/services/sites.ts +30 -30
  27. package/src/services/storage.ts +49 -49
  28. package/src/services/tables-db.ts +119 -119
  29. package/src/services/users.ts +39 -39
  30. package/types/client.d.ts +8 -1
  31. package/types/models.d.ts +432 -424
  32. package/types/query.d.ts +8 -8
  33. package/types/services/account.d.ts +11 -11
  34. package/types/services/avatars.d.ts +82 -82
  35. package/types/services/backups.d.ts +8 -8
  36. package/types/services/console.d.ts +14 -14
  37. package/types/services/databases.d.ts +70 -70
  38. package/types/services/domains.d.ts +104 -104
  39. package/types/services/functions.d.ts +15 -15
  40. package/types/services/health.d.ts +72 -72
  41. package/types/services/messaging.d.ts +24 -24
  42. package/types/services/migrations.d.ts +16 -16
  43. package/types/services/organizations.d.ts +22 -22
  44. package/types/services/projects.d.ts +60 -38
  45. package/types/services/sites.d.ts +15 -15
  46. package/types/services/storage.d.ts +34 -34
  47. package/types/services/tables-db.d.ts +70 -70
  48. package/types/services/users.d.ts +24 -24
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
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
+
3
7
  ## 2.1.0
4
8
 
5
9
  * Add `setSelfSigned` and `setCookie` methods to `Client` class
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.1.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
  */
@@ -463,7 +471,6 @@ class Client {
463
471
  this.config = {
464
472
  endpoint: 'https://cloud.appwrite.io/v1',
465
473
  endpointRealtime: '',
466
- selfSigned: false,
467
474
  project: '',
468
475
  key: '',
469
476
  jwt: '',
@@ -471,6 +478,8 @@ class Client {
471
478
  mode: '',
472
479
  cookie: '',
473
480
  platform: '',
481
+ selfSigned: false,
482
+ session: undefined,
474
483
  };
475
484
  /**
476
485
  * Custom headers for API requests.
@@ -479,7 +488,7 @@ class Client {
479
488
  'x-sdk-name': 'Console',
480
489
  'x-sdk-platform': 'console',
481
490
  'x-sdk-language': 'web',
482
- 'x-sdk-version': '2.1.0',
491
+ 'x-sdk-version': '2.1.1',
483
492
  'X-Appwrite-Response-Format': '1.8.0',
484
493
  };
485
494
  this.realtime = {
@@ -517,7 +526,7 @@ class Client {
517
526
  }
518
527
  this.realtime.heartbeat = window === null || window === void 0 ? void 0 : window.setInterval(() => {
519
528
  var _a;
520
- (_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({
521
530
  type: 'ping'
522
531
  }));
523
532
  }, 20000);
@@ -575,18 +584,18 @@ class Client {
575
584
  onMessage: (event) => {
576
585
  var _a, _b;
577
586
  try {
578
- const message = JSON.parse(event.data);
587
+ const message = JSONbig.parse(event.data);
579
588
  this.realtime.lastMessage = message;
580
589
  switch (message.type) {
581
590
  case 'connected':
582
591
  let session = this.config.session;
583
592
  if (!session) {
584
- 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 : '{}');
585
594
  session = cookie === null || cookie === void 0 ? void 0 : cookie[`a_session_${this.config.project}`];
586
595
  }
587
596
  const messageData = message.data;
588
597
  if (session && !messageData.user) {
589
- (_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({
590
599
  type: 'authentication',
591
600
  data: {
592
601
  session
@@ -842,7 +851,7 @@ class Client {
842
851
  else {
843
852
  switch (headers['content-type']) {
844
853
  case 'application/json':
845
- options.body = JSON.stringify(params);
854
+ options.body = JSONbig.stringify(params);
846
855
  break;
847
856
  case 'multipart/form-data':
848
857
  const formData = new FormData();
@@ -925,7 +934,7 @@ class Client {
925
934
  warnings.split(';').forEach((warning) => console.warn('Warning: ' + warning));
926
935
  }
927
936
  if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
928
- data = yield response.json();
937
+ data = JSONbig.parse(yield response.text());
929
938
  }
930
939
  else if (responseType === 'arrayBuffer') {
931
940
  data = yield response.arrayBuffer();
@@ -938,7 +947,7 @@ class Client {
938
947
  if (400 <= response.status) {
939
948
  let responseText = '';
940
949
  if (((_b = response.headers.get('content-type')) === null || _b === void 0 ? void 0 : _b.includes('application/json')) || responseType === 'arrayBuffer') {
941
- responseText = JSON.stringify(data);
950
+ responseText = JSONbig.stringify(data);
942
951
  }
943
952
  else {
944
953
  responseText = data === null || data === void 0 ? void 0 : data.message;
@@ -16185,6 +16194,36 @@ class Projects {
16185
16194
  };
16186
16195
  return this.client.call('delete', uri, apiHeaders, payload);
16187
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
+ }
16188
16227
  updateOAuth2(paramsOrFirst, ...rest) {
16189
16228
  let params;
16190
16229
  if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {