@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/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 JSON.stringify({
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) => JSON.parse(query))).toString();
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) => JSON.parse(query))).toString();
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
  */
@@ -461,7 +465,6 @@ class Client {
461
465
  this.config = {
462
466
  endpoint: 'https://cloud.appwrite.io/v1',
463
467
  endpointRealtime: '',
464
- selfSigned: false,
465
468
  project: '',
466
469
  key: '',
467
470
  jwt: '',
@@ -469,6 +472,8 @@ class Client {
469
472
  mode: '',
470
473
  cookie: '',
471
474
  platform: '',
475
+ selfSigned: false,
476
+ session: undefined,
472
477
  };
473
478
  /**
474
479
  * Custom headers for API requests.
@@ -477,7 +482,7 @@ class Client {
477
482
  'x-sdk-name': 'Console',
478
483
  'x-sdk-platform': 'console',
479
484
  'x-sdk-language': 'web',
480
- 'x-sdk-version': '2.1.0',
485
+ 'x-sdk-version': '2.1.2',
481
486
  'X-Appwrite-Response-Format': '1.8.0',
482
487
  };
483
488
  this.realtime = {
@@ -515,7 +520,7 @@ class Client {
515
520
  }
516
521
  this.realtime.heartbeat = window === null || window === void 0 ? void 0 : window.setInterval(() => {
517
522
  var _a;
518
- (_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify({
523
+ (_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.send(JSONbig.stringify({
519
524
  type: 'ping'
520
525
  }));
521
526
  }, 20000);
@@ -573,18 +578,18 @@ class Client {
573
578
  onMessage: (event) => {
574
579
  var _a, _b;
575
580
  try {
576
- const message = JSON.parse(event.data);
581
+ const message = JSONbig.parse(event.data);
577
582
  this.realtime.lastMessage = message;
578
583
  switch (message.type) {
579
584
  case 'connected':
580
585
  let session = this.config.session;
581
586
  if (!session) {
582
- const cookie = JSON.parse((_a = window.localStorage.getItem('cookieFallback')) !== null && _a !== void 0 ? _a : '{}');
587
+ const cookie = JSONbig.parse((_a = window.localStorage.getItem('cookieFallback')) !== null && _a !== void 0 ? _a : '{}');
583
588
  session = cookie === null || cookie === void 0 ? void 0 : cookie[`a_session_${this.config.project}`];
584
589
  }
585
590
  const messageData = message.data;
586
591
  if (session && !messageData.user) {
587
- (_b = this.realtime.socket) === null || _b === void 0 ? void 0 : _b.send(JSON.stringify({
592
+ (_b = this.realtime.socket) === null || _b === void 0 ? void 0 : _b.send(JSONbig.stringify({
588
593
  type: 'authentication',
589
594
  data: {
590
595
  session
@@ -840,7 +845,7 @@ class Client {
840
845
  else {
841
846
  switch (headers['content-type']) {
842
847
  case 'application/json':
843
- options.body = JSON.stringify(params);
848
+ options.body = JSONbig.stringify(params);
844
849
  break;
845
850
  case 'multipart/form-data':
846
851
  const formData = new FormData();
@@ -923,7 +928,7 @@ class Client {
923
928
  warnings.split(';').forEach((warning) => console.warn('Warning: ' + warning));
924
929
  }
925
930
  if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
926
- data = yield response.json();
931
+ data = JSONbig.parse(yield response.text());
927
932
  }
928
933
  else if (responseType === 'arrayBuffer') {
929
934
  data = yield response.arrayBuffer();
@@ -936,7 +941,7 @@ class Client {
936
941
  if (400 <= response.status) {
937
942
  let responseText = '';
938
943
  if (((_b = response.headers.get('content-type')) === null || _b === void 0 ? void 0 : _b.includes('application/json')) || responseType === 'arrayBuffer') {
939
- responseText = JSON.stringify(data);
944
+ responseText = JSONbig.stringify(data);
940
945
  }
941
946
  else {
942
947
  responseText = data === null || data === void 0 ? void 0 : data.message;
@@ -6932,6 +6937,54 @@ class Domains {
6932
6937
  };
6933
6938
  return this.client.call('post', uri, apiHeaders, payload);
6934
6939
  }
6940
+ listSuggestions(paramsOrFirst, ...rest) {
6941
+ let params;
6942
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
6943
+ params = (paramsOrFirst || {});
6944
+ }
6945
+ else {
6946
+ params = {
6947
+ query: paramsOrFirst,
6948
+ tlds: rest[0],
6949
+ limit: rest[1],
6950
+ filterType: rest[2],
6951
+ priceMax: rest[3],
6952
+ priceMin: rest[4]
6953
+ };
6954
+ }
6955
+ const query = params.query;
6956
+ const tlds = params.tlds;
6957
+ const limit = params.limit;
6958
+ const filterType = params.filterType;
6959
+ const priceMax = params.priceMax;
6960
+ const priceMin = params.priceMin;
6961
+ if (typeof query === 'undefined') {
6962
+ throw new AppwriteException('Missing required parameter: "query"');
6963
+ }
6964
+ const apiPath = '/domains/suggestions';
6965
+ const payload = {};
6966
+ if (typeof query !== 'undefined') {
6967
+ payload['query'] = query;
6968
+ }
6969
+ if (typeof tlds !== 'undefined') {
6970
+ payload['tlds'] = tlds;
6971
+ }
6972
+ if (typeof limit !== 'undefined') {
6973
+ payload['limit'] = limit;
6974
+ }
6975
+ if (typeof filterType !== 'undefined') {
6976
+ payload['filterType'] = filterType;
6977
+ }
6978
+ if (typeof priceMax !== 'undefined') {
6979
+ payload['priceMax'] = priceMax;
6980
+ }
6981
+ if (typeof priceMin !== 'undefined') {
6982
+ payload['priceMin'] = priceMin;
6983
+ }
6984
+ const uri = new URL(this.client.config.endpoint + apiPath);
6985
+ const apiHeaders = {};
6986
+ return this.client.call('get', uri, apiHeaders, payload);
6987
+ }
6935
6988
  get(paramsOrFirst) {
6936
6989
  let params;
6937
6990
  if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
@@ -9732,7 +9785,7 @@ class Health {
9732
9785
  * Check the Appwrite in-memory cache servers are up and connection is successful.
9733
9786
  *
9734
9787
  * @throws {AppwriteException}
9735
- * @returns {Promise<Models.HealthStatus>}
9788
+ * @returns {Promise<Models.HealthStatusList>}
9736
9789
  */
9737
9790
  getCache() {
9738
9791
  const apiPath = '/health/cache';
@@ -9765,7 +9818,7 @@ class Health {
9765
9818
  * Check the Appwrite database servers are up and connection is successful.
9766
9819
  *
9767
9820
  * @throws {AppwriteException}
9768
- * @returns {Promise<Models.HealthStatus>}
9821
+ * @returns {Promise<Models.HealthStatusList>}
9769
9822
  */
9770
9823
  getDB() {
9771
9824
  const apiPath = '/health/db';
@@ -9778,7 +9831,7 @@ class Health {
9778
9831
  * Check the Appwrite pub-sub servers are up and connection is successful.
9779
9832
  *
9780
9833
  * @throws {AppwriteException}
9781
- * @returns {Promise<Models.HealthStatus>}
9834
+ * @returns {Promise<Models.HealthStatusList>}
9782
9835
  */
9783
9836
  getPubSub() {
9784
9837
  const apiPath = '/health/pubsub';
@@ -9787,6 +9840,26 @@ class Health {
9787
9840
  const apiHeaders = {};
9788
9841
  return this.client.call('get', uri, apiHeaders, payload);
9789
9842
  }
9843
+ getQueueAudits(paramsOrFirst) {
9844
+ let params;
9845
+ if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
9846
+ params = (paramsOrFirst || {});
9847
+ }
9848
+ else {
9849
+ params = {
9850
+ threshold: paramsOrFirst
9851
+ };
9852
+ }
9853
+ const threshold = params.threshold;
9854
+ const apiPath = '/health/queue/audits';
9855
+ const payload = {};
9856
+ if (typeof threshold !== 'undefined') {
9857
+ payload['threshold'] = threshold;
9858
+ }
9859
+ const uri = new URL(this.client.config.endpoint + apiPath);
9860
+ const apiHeaders = {};
9861
+ return this.client.call('get', uri, apiHeaders, payload);
9862
+ }
9790
9863
  getQueueBillingProjectAggregation(paramsOrFirst) {
9791
9864
  let params;
9792
9865
  if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
@@ -13906,7 +13979,7 @@ class Organizations {
13906
13979
  }
13907
13980
  estimationCreateOrganization(paramsOrFirst, ...rest) {
13908
13981
  let params;
13909
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
13982
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'billingPlan' in paramsOrFirst)) {
13910
13983
  params = (paramsOrFirst || {});
13911
13984
  }
13912
13985
  else {
@@ -16183,6 +16256,36 @@ class Projects {
16183
16256
  };
16184
16257
  return this.client.call('delete', uri, apiHeaders, payload);
16185
16258
  }
16259
+ updateLabels(paramsOrFirst, ...rest) {
16260
+ let params;
16261
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
16262
+ params = (paramsOrFirst || {});
16263
+ }
16264
+ else {
16265
+ params = {
16266
+ projectId: paramsOrFirst,
16267
+ labels: rest[0]
16268
+ };
16269
+ }
16270
+ const projectId = params.projectId;
16271
+ const labels = params.labels;
16272
+ if (typeof projectId === 'undefined') {
16273
+ throw new AppwriteException('Missing required parameter: "projectId"');
16274
+ }
16275
+ if (typeof labels === 'undefined') {
16276
+ throw new AppwriteException('Missing required parameter: "labels"');
16277
+ }
16278
+ const apiPath = '/projects/{projectId}/labels'.replace('{projectId}', projectId);
16279
+ const payload = {};
16280
+ if (typeof labels !== 'undefined') {
16281
+ payload['labels'] = labels;
16282
+ }
16283
+ const uri = new URL(this.client.config.endpoint + apiPath);
16284
+ const apiHeaders = {
16285
+ 'content-type': 'application/json',
16286
+ };
16287
+ return this.client.call('put', uri, apiHeaders, payload);
16288
+ }
16186
16289
  updateOAuth2(paramsOrFirst, ...rest) {
16187
16290
  let params;
16188
16291
  if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
@@ -25441,8 +25544,6 @@ var OAuthProvider;
25441
25544
  OAuthProvider["Yandex"] = "yandex";
25442
25545
  OAuthProvider["Zoho"] = "zoho";
25443
25546
  OAuthProvider["Zoom"] = "zoom";
25444
- OAuthProvider["Mock"] = "mock";
25445
- OAuthProvider["Mockunverified"] = "mock-unverified";
25446
25547
  OAuthProvider["GithubImagine"] = "githubImagine";
25447
25548
  OAuthProvider["GoogleImagine"] = "googleImagine";
25448
25549
  })(OAuthProvider || (OAuthProvider = {}));
@@ -26166,6 +26267,12 @@ var IndexType;
26166
26267
  IndexType["Spatial"] = "spatial";
26167
26268
  })(IndexType || (IndexType = {}));
26168
26269
 
26270
+ var FilterType;
26271
+ (function (FilterType) {
26272
+ FilterType["Premium"] = "premium";
26273
+ FilterType["Suggestion"] = "suggestion";
26274
+ })(FilterType || (FilterType = {}));
26275
+
26169
26276
  var Runtime;
26170
26277
  (function (Runtime) {
26171
26278
  Runtime["Node145"] = "node-14.5";
@@ -26277,6 +26384,7 @@ var Name;
26277
26384
  Name["V1webhooks"] = "v1-webhooks";
26278
26385
  Name["V1certificates"] = "v1-certificates";
26279
26386
  Name["V1builds"] = "v1-builds";
26387
+ Name["V1screenshots"] = "v1-screenshots";
26280
26388
  Name["V1messaging"] = "v1-messaging";
26281
26389
  Name["V1migrations"] = "v1-migrations";
26282
26390
  })(Name || (Name = {}));
@@ -26294,6 +26402,25 @@ var SmtpEncryption;
26294
26402
  SmtpEncryption["Tls"] = "tls";
26295
26403
  })(SmtpEncryption || (SmtpEncryption = {}));
26296
26404
 
26405
+ var BillingPlan;
26406
+ (function (BillingPlan) {
26407
+ BillingPlan["Tier0"] = "tier-0";
26408
+ BillingPlan["Tier1"] = "tier-1";
26409
+ BillingPlan["Tier2"] = "tier-2";
26410
+ BillingPlan["Imaginetier0"] = "imagine-tier-0";
26411
+ BillingPlan["Imaginetier1"] = "imagine-tier-1";
26412
+ BillingPlan["Imaginetier150"] = "imagine-tier-1-50";
26413
+ BillingPlan["Imaginetier1100"] = "imagine-tier-1-100";
26414
+ BillingPlan["Imaginetier1200"] = "imagine-tier-1-200";
26415
+ BillingPlan["Imaginetier1290"] = "imagine-tier-1-290";
26416
+ BillingPlan["Imaginetier1480"] = "imagine-tier-1-480";
26417
+ BillingPlan["Imaginetier1700"] = "imagine-tier-1-700";
26418
+ BillingPlan["Imaginetier1900"] = "imagine-tier-1-900";
26419
+ BillingPlan["Imaginetier11100"] = "imagine-tier-1-1100";
26420
+ BillingPlan["Imaginetier11650"] = "imagine-tier-1-1650";
26421
+ BillingPlan["Imaginetier12200"] = "imagine-tier-1-2200";
26422
+ })(BillingPlan || (BillingPlan = {}));
26423
+
26297
26424
  var ProjectUsageRange;
26298
26425
  (function (ProjectUsageRange) {
26299
26426
  ProjectUsageRange["OneHour"] = "1h";
@@ -26921,5 +27048,5 @@ var BillingPlanGroup;
26921
27048
  BillingPlanGroup["Scale"] = "scale";
26922
27049
  })(BillingPlanGroup || (BillingPlanGroup = {}));
26923
27050
 
26924
- export { Account, Adapter, Api, ApiService, AppwriteException, Assistant, AttributeStatus, AuthMethod, AuthenticationFactor, AuthenticatorType, Avatars, Backups, BillingPlanGroup, Browser, BuildRuntime, Client, ColumnStatus, Compression, Condition, Console, ConsoleResourceType, CreditCard, DatabaseType, Databases, DeploymentDownloadType, DeploymentStatus, Domains, EmailTemplateLocale, EmailTemplateType, ExecutionMethod, ExecutionStatus, ExecutionTrigger, Flag, Framework, Functions, Graphql, Health, HealthAntivirusStatus, HealthCheckStatus, ID, ImageFormat, ImageGravity, IndexStatus, IndexType, Locale, MessagePriority, MessageStatus, Messaging, MessagingProviderType, Migrations, Name, OAuthProvider, Operator, Organizations, PasswordHash, Permission, Platform, PlatformType, Project, ProjectUsageRange, Projects, Proxy, ProxyResourceType, ProxyRuleDeploymentResourceType, ProxyRuleStatus, Query, Realtime, Region, RelationMutate, RelationshipType, Role, Runtime, SMTPSecure, Sites, SmsTemplateLocale, SmsTemplateType, SmtpEncryption, Status, StatusCode, Storage, TablesDB, Teams, TemplateReferenceType, Theme, Timezone, Tokens, UsageRange, Users, VCSDetectionType, VCSReferenceType, Vcs };
27051
+ export { Account, Adapter, Api, ApiService, AppwriteException, Assistant, AttributeStatus, AuthMethod, AuthenticationFactor, AuthenticatorType, Avatars, Backups, BillingPlan, BillingPlanGroup, Browser, BuildRuntime, Client, ColumnStatus, Compression, Condition, Console, ConsoleResourceType, CreditCard, DatabaseType, Databases, DeploymentDownloadType, DeploymentStatus, Domains, EmailTemplateLocale, EmailTemplateType, ExecutionMethod, ExecutionStatus, ExecutionTrigger, FilterType, Flag, Framework, Functions, Graphql, Health, HealthAntivirusStatus, HealthCheckStatus, ID, ImageFormat, ImageGravity, IndexStatus, IndexType, Locale, MessagePriority, MessageStatus, Messaging, MessagingProviderType, Migrations, Name, OAuthProvider, Operator, Organizations, PasswordHash, Permission, Platform, PlatformType, Project, ProjectUsageRange, Projects, Proxy, ProxyResourceType, ProxyRuleDeploymentResourceType, ProxyRuleStatus, Query, Realtime, Region, RelationMutate, RelationshipType, Role, Runtime, SMTPSecure, Sites, SmsTemplateLocale, SmsTemplateType, SmtpEncryption, Status, StatusCode, Storage, TablesDB, Teams, TemplateReferenceType, Theme, Timezone, Tokens, UsageRange, Users, VCSDetectionType, VCSReferenceType, Vcs };
26925
27052
  //# sourceMappingURL=sdk.js.map