@appwrite.io/console 2.1.0 → 2.1.2

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 (46) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +2 -2
  3. package/dist/cjs/sdk.js +153 -22
  4. package/dist/cjs/sdk.js.map +1 -1
  5. package/dist/esm/sdk.js +150 -23
  6. package/dist/esm/sdk.js.map +1 -1
  7. package/dist/iife/sdk.js +3910 -22
  8. package/docs/examples/domains/list-suggestions.md +18 -0
  9. package/docs/examples/health/get-queue-audits.md +13 -0
  10. package/docs/examples/organizations/create.md +2 -2
  11. package/docs/examples/organizations/estimation-create-organization.md +2 -2
  12. package/docs/examples/organizations/estimation-update-plan.md +2 -2
  13. package/docs/examples/organizations/update-plan.md +2 -2
  14. package/docs/examples/projects/update-labels.md +14 -0
  15. package/package.json +7 -1
  16. package/rollup.config.js +40 -24
  17. package/src/client.ts +20 -10
  18. package/src/enums/billing-plan.ts +17 -0
  19. package/src/enums/filter-type.ts +4 -0
  20. package/src/enums/name.ts +1 -0
  21. package/src/enums/o-auth-provider.ts +0 -2
  22. package/src/index.ts +2 -0
  23. package/src/models.ts +129 -59
  24. package/src/query.ts +14 -11
  25. package/src/services/databases.ts +30 -30
  26. package/src/services/domains.ts +91 -0
  27. package/src/services/health.ts +55 -6
  28. package/src/services/organizations.ts +37 -36
  29. package/src/services/projects.ts +65 -2
  30. package/src/services/storage.ts +4 -4
  31. package/src/services/tables-db.ts +30 -30
  32. package/types/client.d.ts +8 -1
  33. package/types/enums/billing-plan.d.ts +17 -0
  34. package/types/enums/filter-type.d.ts +4 -0
  35. package/types/enums/name.d.ts +1 -0
  36. package/types/enums/o-auth-provider.d.ts +0 -2
  37. package/types/index.d.ts +2 -0
  38. package/types/models.d.ts +126 -59
  39. package/types/query.d.ts +8 -8
  40. package/types/services/databases.d.ts +20 -20
  41. package/types/services/domains.d.ts +35 -0
  42. package/types/services/health.d.ts +23 -6
  43. package/types/services/organizations.d.ts +17 -16
  44. package/types/services/projects.d.ts +24 -2
  45. package/types/services/storage.d.ts +4 -4
  46. package/types/services/tables-db.d.ts +20 -20
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.1.2
4
+
5
+ * Fix only use `bigint` for min, max and default attributes
6
+
7
+ ## 2.1.1
8
+
9
+ * Allow `bigint` to be passed in all methods that previously only accepted `number`
10
+
3
11
  ## 2.1.0
4
12
 
5
13
  * 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.2"></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.2',
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;
@@ -6934,6 +6943,54 @@ class Domains {
6934
6943
  };
6935
6944
  return this.client.call('post', uri, apiHeaders, payload);
6936
6945
  }
6946
+ listSuggestions(paramsOrFirst, ...rest) {
6947
+ let params;
6948
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
6949
+ params = (paramsOrFirst || {});
6950
+ }
6951
+ else {
6952
+ params = {
6953
+ query: paramsOrFirst,
6954
+ tlds: rest[0],
6955
+ limit: rest[1],
6956
+ filterType: rest[2],
6957
+ priceMax: rest[3],
6958
+ priceMin: rest[4]
6959
+ };
6960
+ }
6961
+ const query = params.query;
6962
+ const tlds = params.tlds;
6963
+ const limit = params.limit;
6964
+ const filterType = params.filterType;
6965
+ const priceMax = params.priceMax;
6966
+ const priceMin = params.priceMin;
6967
+ if (typeof query === 'undefined') {
6968
+ throw new AppwriteException('Missing required parameter: "query"');
6969
+ }
6970
+ const apiPath = '/domains/suggestions';
6971
+ const payload = {};
6972
+ if (typeof query !== 'undefined') {
6973
+ payload['query'] = query;
6974
+ }
6975
+ if (typeof tlds !== 'undefined') {
6976
+ payload['tlds'] = tlds;
6977
+ }
6978
+ if (typeof limit !== 'undefined') {
6979
+ payload['limit'] = limit;
6980
+ }
6981
+ if (typeof filterType !== 'undefined') {
6982
+ payload['filterType'] = filterType;
6983
+ }
6984
+ if (typeof priceMax !== 'undefined') {
6985
+ payload['priceMax'] = priceMax;
6986
+ }
6987
+ if (typeof priceMin !== 'undefined') {
6988
+ payload['priceMin'] = priceMin;
6989
+ }
6990
+ const uri = new URL(this.client.config.endpoint + apiPath);
6991
+ const apiHeaders = {};
6992
+ return this.client.call('get', uri, apiHeaders, payload);
6993
+ }
6937
6994
  get(paramsOrFirst) {
6938
6995
  let params;
6939
6996
  if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
@@ -9734,7 +9791,7 @@ class Health {
9734
9791
  * Check the Appwrite in-memory cache servers are up and connection is successful.
9735
9792
  *
9736
9793
  * @throws {AppwriteException}
9737
- * @returns {Promise<Models.HealthStatus>}
9794
+ * @returns {Promise<Models.HealthStatusList>}
9738
9795
  */
9739
9796
  getCache() {
9740
9797
  const apiPath = '/health/cache';
@@ -9767,7 +9824,7 @@ class Health {
9767
9824
  * Check the Appwrite database servers are up and connection is successful.
9768
9825
  *
9769
9826
  * @throws {AppwriteException}
9770
- * @returns {Promise<Models.HealthStatus>}
9827
+ * @returns {Promise<Models.HealthStatusList>}
9771
9828
  */
9772
9829
  getDB() {
9773
9830
  const apiPath = '/health/db';
@@ -9780,7 +9837,7 @@ class Health {
9780
9837
  * Check the Appwrite pub-sub servers are up and connection is successful.
9781
9838
  *
9782
9839
  * @throws {AppwriteException}
9783
- * @returns {Promise<Models.HealthStatus>}
9840
+ * @returns {Promise<Models.HealthStatusList>}
9784
9841
  */
9785
9842
  getPubSub() {
9786
9843
  const apiPath = '/health/pubsub';
@@ -9789,6 +9846,26 @@ class Health {
9789
9846
  const apiHeaders = {};
9790
9847
  return this.client.call('get', uri, apiHeaders, payload);
9791
9848
  }
9849
+ getQueueAudits(paramsOrFirst) {
9850
+ let params;
9851
+ if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
9852
+ params = (paramsOrFirst || {});
9853
+ }
9854
+ else {
9855
+ params = {
9856
+ threshold: paramsOrFirst
9857
+ };
9858
+ }
9859
+ const threshold = params.threshold;
9860
+ const apiPath = '/health/queue/audits';
9861
+ const payload = {};
9862
+ if (typeof threshold !== 'undefined') {
9863
+ payload['threshold'] = threshold;
9864
+ }
9865
+ const uri = new URL(this.client.config.endpoint + apiPath);
9866
+ const apiHeaders = {};
9867
+ return this.client.call('get', uri, apiHeaders, payload);
9868
+ }
9792
9869
  getQueueBillingProjectAggregation(paramsOrFirst) {
9793
9870
  let params;
9794
9871
  if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
@@ -13908,7 +13985,7 @@ class Organizations {
13908
13985
  }
13909
13986
  estimationCreateOrganization(paramsOrFirst, ...rest) {
13910
13987
  let params;
13911
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
13988
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'billingPlan' in paramsOrFirst)) {
13912
13989
  params = (paramsOrFirst || {});
13913
13990
  }
13914
13991
  else {
@@ -16185,6 +16262,36 @@ class Projects {
16185
16262
  };
16186
16263
  return this.client.call('delete', uri, apiHeaders, payload);
16187
16264
  }
16265
+ updateLabels(paramsOrFirst, ...rest) {
16266
+ let params;
16267
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
16268
+ params = (paramsOrFirst || {});
16269
+ }
16270
+ else {
16271
+ params = {
16272
+ projectId: paramsOrFirst,
16273
+ labels: rest[0]
16274
+ };
16275
+ }
16276
+ const projectId = params.projectId;
16277
+ const labels = params.labels;
16278
+ if (typeof projectId === 'undefined') {
16279
+ throw new AppwriteException('Missing required parameter: "projectId"');
16280
+ }
16281
+ if (typeof labels === 'undefined') {
16282
+ throw new AppwriteException('Missing required parameter: "labels"');
16283
+ }
16284
+ const apiPath = '/projects/{projectId}/labels'.replace('{projectId}', projectId);
16285
+ const payload = {};
16286
+ if (typeof labels !== 'undefined') {
16287
+ payload['labels'] = labels;
16288
+ }
16289
+ const uri = new URL(this.client.config.endpoint + apiPath);
16290
+ const apiHeaders = {
16291
+ 'content-type': 'application/json',
16292
+ };
16293
+ return this.client.call('put', uri, apiHeaders, payload);
16294
+ }
16188
16295
  updateOAuth2(paramsOrFirst, ...rest) {
16189
16296
  let params;
16190
16297
  if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
@@ -25443,8 +25550,6 @@ exports.OAuthProvider = void 0;
25443
25550
  OAuthProvider["Yandex"] = "yandex";
25444
25551
  OAuthProvider["Zoho"] = "zoho";
25445
25552
  OAuthProvider["Zoom"] = "zoom";
25446
- OAuthProvider["Mock"] = "mock";
25447
- OAuthProvider["Mockunverified"] = "mock-unverified";
25448
25553
  OAuthProvider["GithubImagine"] = "githubImagine";
25449
25554
  OAuthProvider["GoogleImagine"] = "googleImagine";
25450
25555
  })(exports.OAuthProvider || (exports.OAuthProvider = {}));
@@ -26168,6 +26273,12 @@ exports.IndexType = void 0;
26168
26273
  IndexType["Spatial"] = "spatial";
26169
26274
  })(exports.IndexType || (exports.IndexType = {}));
26170
26275
 
26276
+ exports.FilterType = void 0;
26277
+ (function (FilterType) {
26278
+ FilterType["Premium"] = "premium";
26279
+ FilterType["Suggestion"] = "suggestion";
26280
+ })(exports.FilterType || (exports.FilterType = {}));
26281
+
26171
26282
  exports.Runtime = void 0;
26172
26283
  (function (Runtime) {
26173
26284
  Runtime["Node145"] = "node-14.5";
@@ -26279,6 +26390,7 @@ exports.Name = void 0;
26279
26390
  Name["V1webhooks"] = "v1-webhooks";
26280
26391
  Name["V1certificates"] = "v1-certificates";
26281
26392
  Name["V1builds"] = "v1-builds";
26393
+ Name["V1screenshots"] = "v1-screenshots";
26282
26394
  Name["V1messaging"] = "v1-messaging";
26283
26395
  Name["V1migrations"] = "v1-migrations";
26284
26396
  })(exports.Name || (exports.Name = {}));
@@ -26296,6 +26408,25 @@ exports.SmtpEncryption = void 0;
26296
26408
  SmtpEncryption["Tls"] = "tls";
26297
26409
  })(exports.SmtpEncryption || (exports.SmtpEncryption = {}));
26298
26410
 
26411
+ exports.BillingPlan = void 0;
26412
+ (function (BillingPlan) {
26413
+ BillingPlan["Tier0"] = "tier-0";
26414
+ BillingPlan["Tier1"] = "tier-1";
26415
+ BillingPlan["Tier2"] = "tier-2";
26416
+ BillingPlan["Imaginetier0"] = "imagine-tier-0";
26417
+ BillingPlan["Imaginetier1"] = "imagine-tier-1";
26418
+ BillingPlan["Imaginetier150"] = "imagine-tier-1-50";
26419
+ BillingPlan["Imaginetier1100"] = "imagine-tier-1-100";
26420
+ BillingPlan["Imaginetier1200"] = "imagine-tier-1-200";
26421
+ BillingPlan["Imaginetier1290"] = "imagine-tier-1-290";
26422
+ BillingPlan["Imaginetier1480"] = "imagine-tier-1-480";
26423
+ BillingPlan["Imaginetier1700"] = "imagine-tier-1-700";
26424
+ BillingPlan["Imaginetier1900"] = "imagine-tier-1-900";
26425
+ BillingPlan["Imaginetier11100"] = "imagine-tier-1-1100";
26426
+ BillingPlan["Imaginetier11650"] = "imagine-tier-1-1650";
26427
+ BillingPlan["Imaginetier12200"] = "imagine-tier-1-2200";
26428
+ })(exports.BillingPlan || (exports.BillingPlan = {}));
26429
+
26299
26430
  exports.ProjectUsageRange = void 0;
26300
26431
  (function (ProjectUsageRange) {
26301
26432
  ProjectUsageRange["OneHour"] = "1h";