@appwrite.io/console 0.6.0 → 0.6.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.
package/dist/esm/sdk.js CHANGED
@@ -1,6 +1,3 @@
1
- import 'isomorphic-form-data';
2
- import { fetch } from 'cross-fetch';
3
-
4
1
  /******************************************************************************
5
2
  Copyright (c) Microsoft Corporation.
6
3
 
@@ -24,6 +21,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
24
21
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
25
22
  step((generator = generator.apply(thisArg, _arguments || [])).next());
26
23
  });
24
+ }
25
+
26
+ function __classPrivateFieldGet(receiver, state, kind, f) {
27
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
28
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
29
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
27
30
  }
28
31
 
29
32
  class Service {
@@ -115,7 +118,7 @@ class Client {
115
118
  'x-sdk-name': 'Console',
116
119
  'x-sdk-platform': 'console',
117
120
  'x-sdk-language': 'web',
118
- 'x-sdk-version': '0.6.0',
121
+ 'x-sdk-version': '0.6.2',
119
122
  'X-Appwrite-Response-Format': '1.5.0',
120
123
  };
121
124
  this.realtime = {
@@ -147,9 +150,12 @@ class Client {
147
150
  }
148
151
  },
149
152
  createSocket: () => {
150
- var _a, _b;
151
- if (this.realtime.channels.size < 1)
153
+ var _a, _b, _c;
154
+ if (this.realtime.channels.size < 1) {
155
+ this.realtime.reconnect = false;
156
+ (_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.close();
152
157
  return;
158
+ }
153
159
  const channels = new URLSearchParams();
154
160
  channels.set('project', this.config.project);
155
161
  this.realtime.channels.forEach(channel => {
@@ -158,10 +164,10 @@ class Client {
158
164
  const url = this.config.endpointRealtime + '/realtime?' + channels.toString();
159
165
  if (url !== this.realtime.url || // Check if URL is present
160
166
  !this.realtime.socket || // Check if WebSocket has not been created
161
- ((_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.readyState) > WebSocket.OPEN // Check if WebSocket is CLOSING (3) or CLOSED (4)
167
+ ((_b = this.realtime.socket) === null || _b === void 0 ? void 0 : _b.readyState) > WebSocket.OPEN // Check if WebSocket is CLOSING (3) or CLOSED (4)
162
168
  ) {
163
169
  if (this.realtime.socket &&
164
- ((_b = this.realtime.socket) === null || _b === void 0 ? void 0 : _b.readyState) < WebSocket.CLOSING // Close WebSocket if it is CONNECTING (0) or OPEN (1)
170
+ ((_c = this.realtime.socket) === null || _c === void 0 ? void 0 : _c.readyState) < WebSocket.CLOSING // Close WebSocket if it is CONNECTING (0) or OPEN (1)
165
171
  ) {
166
172
  this.realtime.reconnect = false;
167
173
  this.realtime.socket.close();
@@ -378,7 +384,7 @@ class Client {
378
384
  };
379
385
  }
380
386
  call(method, url, headers = {}, params = {}) {
381
- var _a, _b;
387
+ var _a;
382
388
  return __awaiter(this, void 0, void 0, function* () {
383
389
  method = method.toUpperCase();
384
390
  headers = Object.assign({}, this.headers, headers);
@@ -388,7 +394,10 @@ class Client {
388
394
  credentials: 'include'
389
395
  };
390
396
  if (typeof window !== 'undefined' && window.localStorage) {
391
- headers['X-Fallback-Cookies'] = (_a = window.localStorage.getItem('cookieFallback')) !== null && _a !== void 0 ? _a : '';
397
+ const cookieFallback = window.localStorage.getItem('cookieFallback');
398
+ if (cookieFallback) {
399
+ headers['X-Fallback-Cookies'] = cookieFallback;
400
+ }
392
401
  }
393
402
  if (method === 'GET') {
394
403
  for (const [key, value] of Object.entries(Service.flatten(params))) {
@@ -420,7 +429,7 @@ class Client {
420
429
  try {
421
430
  let data = null;
422
431
  const response = yield fetch(url.toString(), options);
423
- if ((_b = response.headers.get('content-type')) === null || _b === void 0 ? void 0 : _b.includes('application/json')) {
432
+ if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
424
433
  data = yield response.json();
425
434
  }
426
435
  else {
@@ -695,7 +704,7 @@ class Account extends Service {
695
704
  *
696
705
  * Add an authenticator app to be used as an MFA factor. Verify the
697
706
  * authenticator using the [verify
698
- * authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator)
707
+ * authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator)
699
708
  * method.
700
709
  *
701
710
  * @param {AuthenticatorType} type
@@ -719,8 +728,8 @@ class Account extends Service {
719
728
  * Verify Authenticator
720
729
  *
721
730
  * Verify an authenticator app after adding it using the [add
722
- * authenticator](/docs/references/cloud/client-web/account#addAuthenticator)
723
- * method.
731
+ * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
732
+ * method. add
724
733
  *
725
734
  * @param {AuthenticatorType} type
726
735
  * @param {string} otp
@@ -5867,10 +5876,11 @@ class Messaging extends Service {
5867
5876
  * @param {string[]} cc
5868
5877
  * @param {string[]} bcc
5869
5878
  * @param {string} scheduledAt
5879
+ * @param {string[]} attachments
5870
5880
  * @throws {AppwriteException}
5871
5881
  * @returns {Promise}
5872
5882
  */
5873
- updateEmail(messageId, topics, users, targets, subject, content, draft, html, cc, bcc, scheduledAt) {
5883
+ updateEmail(messageId, topics, users, targets, subject, content, draft, html, cc, bcc, scheduledAt, attachments) {
5874
5884
  return __awaiter(this, void 0, void 0, function* () {
5875
5885
  if (typeof messageId === 'undefined') {
5876
5886
  throw new AppwriteException('Missing required parameter: "messageId"');
@@ -5907,6 +5917,9 @@ class Messaging extends Service {
5907
5917
  if (typeof scheduledAt !== 'undefined') {
5908
5918
  payload['scheduledAt'] = scheduledAt;
5909
5919
  }
5920
+ if (typeof attachments !== 'undefined') {
5921
+ payload['attachments'] = attachments;
5922
+ }
5910
5923
  const uri = new URL(this.client.config.endpoint + apiPath);
5911
5924
  return yield this.client.call('patch', uri, {
5912
5925
  'content-type': 'application/json',
@@ -6619,14 +6632,14 @@ class Messaging extends Service {
6619
6632
  *
6620
6633
  * @param {string} providerId
6621
6634
  * @param {string} name
6622
- * @param {string} from
6635
+ * @param {string} templateId
6623
6636
  * @param {string} senderId
6624
6637
  * @param {string} authKey
6625
6638
  * @param {boolean} enabled
6626
6639
  * @throws {AppwriteException}
6627
6640
  * @returns {Promise}
6628
6641
  */
6629
- createMsg91Provider(providerId, name, from, senderId, authKey, enabled) {
6642
+ createMsg91Provider(providerId, name, templateId, senderId, authKey, enabled) {
6630
6643
  return __awaiter(this, void 0, void 0, function* () {
6631
6644
  if (typeof providerId === 'undefined') {
6632
6645
  throw new AppwriteException('Missing required parameter: "providerId"');
@@ -6642,8 +6655,8 @@ class Messaging extends Service {
6642
6655
  if (typeof name !== 'undefined') {
6643
6656
  payload['name'] = name;
6644
6657
  }
6645
- if (typeof from !== 'undefined') {
6646
- payload['from'] = from;
6658
+ if (typeof templateId !== 'undefined') {
6659
+ payload['templateId'] = templateId;
6647
6660
  }
6648
6661
  if (typeof senderId !== 'undefined') {
6649
6662
  payload['senderId'] = senderId;
@@ -6668,13 +6681,13 @@ class Messaging extends Service {
6668
6681
  * @param {string} providerId
6669
6682
  * @param {string} name
6670
6683
  * @param {boolean} enabled
6684
+ * @param {string} templateId
6671
6685
  * @param {string} senderId
6672
6686
  * @param {string} authKey
6673
- * @param {string} from
6674
6687
  * @throws {AppwriteException}
6675
6688
  * @returns {Promise}
6676
6689
  */
6677
- updateMsg91Provider(providerId, name, enabled, senderId, authKey, from) {
6690
+ updateMsg91Provider(providerId, name, enabled, templateId, senderId, authKey) {
6678
6691
  return __awaiter(this, void 0, void 0, function* () {
6679
6692
  if (typeof providerId === 'undefined') {
6680
6693
  throw new AppwriteException('Missing required parameter: "providerId"');
@@ -6687,15 +6700,15 @@ class Messaging extends Service {
6687
6700
  if (typeof enabled !== 'undefined') {
6688
6701
  payload['enabled'] = enabled;
6689
6702
  }
6703
+ if (typeof templateId !== 'undefined') {
6704
+ payload['templateId'] = templateId;
6705
+ }
6690
6706
  if (typeof senderId !== 'undefined') {
6691
6707
  payload['senderId'] = senderId;
6692
6708
  }
6693
6709
  if (typeof authKey !== 'undefined') {
6694
6710
  payload['authKey'] = authKey;
6695
6711
  }
6696
- if (typeof from !== 'undefined') {
6697
- payload['from'] = from;
6698
- }
6699
6712
  const uri = new URL(this.client.config.endpoint + apiPath);
6700
6713
  return yield this.client.call('patch', uri, {
6701
6714
  'content-type': 'application/json',
@@ -12881,14 +12894,30 @@ class Role {
12881
12894
  }
12882
12895
  }
12883
12896
 
12897
+ var _a, _ID_hexTimestamp;
12884
12898
  class ID {
12885
12899
  static custom(id) {
12886
12900
  return id;
12887
12901
  }
12888
- static unique() {
12889
- return 'unique()';
12902
+ static unique(padding = 7) {
12903
+ // Generate a unique ID with padding to have a longer ID
12904
+ const baseId = __classPrivateFieldGet(ID, _a, "m", _ID_hexTimestamp).call(ID);
12905
+ let randomPadding = '';
12906
+ for (let i = 0; i < padding; i++) {
12907
+ const randomHexDigit = Math.floor(Math.random() * 16).toString(16);
12908
+ randomPadding += randomHexDigit;
12909
+ }
12910
+ return baseId + randomPadding;
12890
12911
  }
12891
12912
  }
12913
+ _a = ID, _ID_hexTimestamp = function _ID_hexTimestamp() {
12914
+ const now = new Date();
12915
+ const sec = Math.floor(now.getTime() / 1000);
12916
+ const msec = now.getMilliseconds();
12917
+ // Convert to hexadecimal
12918
+ const hexTimestamp = sec.toString(16) + msec.toString(16).padStart(5, '0');
12919
+ return hexTimestamp;
12920
+ };
12892
12921
 
12893
12922
  var AuthenticatorType;
12894
12923
  (function (AuthenticatorType) {
@@ -13019,7 +13048,7 @@ var Flag;
13019
13048
  Flag["Switzerland"] = "ch";
13020
13049
  Flag["Chile"] = "cl";
13021
13050
  Flag["China"] = "cn";
13022
- Flag["CTeDIvoire"] = "ci";
13051
+ Flag["CoteDIvoire"] = "ci";
13023
13052
  Flag["Cameroon"] = "cm";
13024
13053
  Flag["DemocraticRepublicOfTheCongo"] = "cd";
13025
13054
  Flag["RepublicOfTheCongo"] = "cg";
@@ -13127,6 +13156,7 @@ var Flag;
13127
13156
  Flag["Palau"] = "pw";
13128
13157
  Flag["PapuaNewGuinea"] = "pg";
13129
13158
  Flag["Poland"] = "pl";
13159
+ Flag["FrenchPolynesia"] = "pf";
13130
13160
  Flag["NorthKorea"] = "kp";
13131
13161
  Flag["Portugal"] = "pt";
13132
13162
  Flag["Paraguay"] = "py";
@@ -13232,6 +13262,10 @@ var Runtime;
13232
13262
  Runtime["Python310"] = "python-3.10";
13233
13263
  Runtime["Python311"] = "python-3.11";
13234
13264
  Runtime["Python312"] = "python-3.12";
13265
+ Runtime["Pythonml311"] = "python-ml-3.11";
13266
+ Runtime["Deno121"] = "deno-1.21";
13267
+ Runtime["Deno124"] = "deno-1.24";
13268
+ Runtime["Deno135"] = "deno-1.35";
13235
13269
  Runtime["Deno140"] = "deno-1.40";
13236
13270
  Runtime["Dart215"] = "dart-2.15";
13237
13271
  Runtime["Dart216"] = "dart-2.16";