@appwrite.io/console 0.6.0 → 0.6.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.
package/dist/iife/sdk.js CHANGED
@@ -24,6 +24,12 @@
24
24
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
25
25
  step((generator = generator.apply(thisArg, _arguments || [])).next());
26
26
  });
27
+ }
28
+
29
+ function __classPrivateFieldGet(receiver, state, kind, f) {
30
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
31
+ 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");
32
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
27
33
  }
28
34
 
29
35
  class Service {
@@ -115,7 +121,7 @@
115
121
  'x-sdk-name': 'Console',
116
122
  'x-sdk-platform': 'console',
117
123
  'x-sdk-language': 'web',
118
- 'x-sdk-version': '0.6.0',
124
+ 'x-sdk-version': '0.6.1',
119
125
  'X-Appwrite-Response-Format': '1.5.0',
120
126
  };
121
127
  this.realtime = {
@@ -6619,14 +6625,14 @@
6619
6625
  *
6620
6626
  * @param {string} providerId
6621
6627
  * @param {string} name
6622
- * @param {string} from
6628
+ * @param {string} templateId
6623
6629
  * @param {string} senderId
6624
6630
  * @param {string} authKey
6625
6631
  * @param {boolean} enabled
6626
6632
  * @throws {AppwriteException}
6627
6633
  * @returns {Promise}
6628
6634
  */
6629
- createMsg91Provider(providerId, name, from, senderId, authKey, enabled) {
6635
+ createMsg91Provider(providerId, name, templateId, senderId, authKey, enabled) {
6630
6636
  return __awaiter(this, void 0, void 0, function* () {
6631
6637
  if (typeof providerId === 'undefined') {
6632
6638
  throw new AppwriteException('Missing required parameter: "providerId"');
@@ -6642,8 +6648,8 @@
6642
6648
  if (typeof name !== 'undefined') {
6643
6649
  payload['name'] = name;
6644
6650
  }
6645
- if (typeof from !== 'undefined') {
6646
- payload['from'] = from;
6651
+ if (typeof templateId !== 'undefined') {
6652
+ payload['templateId'] = templateId;
6647
6653
  }
6648
6654
  if (typeof senderId !== 'undefined') {
6649
6655
  payload['senderId'] = senderId;
@@ -6668,13 +6674,13 @@
6668
6674
  * @param {string} providerId
6669
6675
  * @param {string} name
6670
6676
  * @param {boolean} enabled
6677
+ * @param {string} templateId
6671
6678
  * @param {string} senderId
6672
6679
  * @param {string} authKey
6673
- * @param {string} from
6674
6680
  * @throws {AppwriteException}
6675
6681
  * @returns {Promise}
6676
6682
  */
6677
- updateMsg91Provider(providerId, name, enabled, senderId, authKey, from) {
6683
+ updateMsg91Provider(providerId, name, enabled, templateId, senderId, authKey) {
6678
6684
  return __awaiter(this, void 0, void 0, function* () {
6679
6685
  if (typeof providerId === 'undefined') {
6680
6686
  throw new AppwriteException('Missing required parameter: "providerId"');
@@ -6687,15 +6693,15 @@
6687
6693
  if (typeof enabled !== 'undefined') {
6688
6694
  payload['enabled'] = enabled;
6689
6695
  }
6696
+ if (typeof templateId !== 'undefined') {
6697
+ payload['templateId'] = templateId;
6698
+ }
6690
6699
  if (typeof senderId !== 'undefined') {
6691
6700
  payload['senderId'] = senderId;
6692
6701
  }
6693
6702
  if (typeof authKey !== 'undefined') {
6694
6703
  payload['authKey'] = authKey;
6695
6704
  }
6696
- if (typeof from !== 'undefined') {
6697
- payload['from'] = from;
6698
- }
6699
6705
  const uri = new URL(this.client.config.endpoint + apiPath);
6700
6706
  return yield this.client.call('patch', uri, {
6701
6707
  'content-type': 'application/json',
@@ -12881,14 +12887,30 @@
12881
12887
  }
12882
12888
  }
12883
12889
 
12890
+ var _a, _ID_hexTimestamp;
12884
12891
  class ID {
12885
12892
  static custom(id) {
12886
12893
  return id;
12887
12894
  }
12888
- static unique() {
12889
- return 'unique()';
12895
+ static unique(padding = 7) {
12896
+ // Generate a unique ID with padding to have a longer ID
12897
+ const baseId = __classPrivateFieldGet(ID, _a, "m", _ID_hexTimestamp).call(ID);
12898
+ let randomPadding = '';
12899
+ for (let i = 0; i < padding; i++) {
12900
+ const randomHexDigit = Math.floor(Math.random() * 16).toString(16);
12901
+ randomPadding += randomHexDigit;
12902
+ }
12903
+ return baseId + randomPadding;
12890
12904
  }
12891
12905
  }
12906
+ _a = ID, _ID_hexTimestamp = function _ID_hexTimestamp() {
12907
+ const now = new Date();
12908
+ const sec = Math.floor(now.getTime() / 1000);
12909
+ const msec = now.getMilliseconds();
12910
+ // Convert to hexadecimal
12911
+ const hexTimestamp = sec.toString(16) + msec.toString(16).padStart(5, '0');
12912
+ return hexTimestamp;
12913
+ };
12892
12914
 
12893
12915
  exports.AuthenticatorType = void 0;
12894
12916
  (function (AuthenticatorType) {
@@ -13019,7 +13041,7 @@
13019
13041
  Flag["Switzerland"] = "ch";
13020
13042
  Flag["Chile"] = "cl";
13021
13043
  Flag["China"] = "cn";
13022
- Flag["CTeDIvoire"] = "ci";
13044
+ Flag["CoteDIvoire"] = "ci";
13023
13045
  Flag["Cameroon"] = "cm";
13024
13046
  Flag["DemocraticRepublicOfTheCongo"] = "cd";
13025
13047
  Flag["RepublicOfTheCongo"] = "cg";
@@ -9,7 +9,7 @@ const messaging = new Messaging(client);
9
9
  const result = await messaging.createMsg91Provider(
10
10
  '<PROVIDER_ID>', // providerId
11
11
  '<NAME>', // name
12
- '+12065550100', // from (optional)
12
+ '<TEMPLATE_ID>', // templateId (optional)
13
13
  '<SENDER_ID>', // senderId (optional)
14
14
  '<AUTH_KEY>', // authKey (optional)
15
15
  false // enabled (optional)
@@ -10,9 +10,9 @@ const result = await messaging.updateMsg91Provider(
10
10
  '<PROVIDER_ID>', // providerId
11
11
  '<NAME>', // name (optional)
12
12
  false, // enabled (optional)
13
+ '<TEMPLATE_ID>', // templateId (optional)
13
14
  '<SENDER_ID>', // senderId (optional)
14
- '<AUTH_KEY>', // authKey (optional)
15
- '<FROM>' // from (optional)
15
+ '<AUTH_KEY>' // authKey (optional)
16
16
  );
17
17
 
18
18
  console.log(response);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@appwrite.io/console",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5
- "version": "0.6.0",
5
+ "version": "0.6.1",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/cjs/sdk.js",
8
8
  "exports": {
package/src/client.ts CHANGED
@@ -104,7 +104,7 @@ class Client {
104
104
  'x-sdk-name': 'Console',
105
105
  'x-sdk-platform': 'console',
106
106
  'x-sdk-language': 'web',
107
- 'x-sdk-version': '0.6.0',
107
+ 'x-sdk-version': '0.6.1',
108
108
  'X-Appwrite-Response-Format': '1.5.0',
109
109
  };
110
110
 
package/src/enums/flag.ts CHANGED
@@ -32,7 +32,7 @@ export enum Flag {
32
32
  Switzerland = 'ch',
33
33
  Chile = 'cl',
34
34
  China = 'cn',
35
- CTeDIvoire = 'ci',
35
+ CoteDIvoire = 'ci',
36
36
  Cameroon = 'cm',
37
37
  DemocraticRepublicOfTheCongo = 'cd',
38
38
  RepublicOfTheCongo = 'cg',
package/src/id.ts CHANGED
@@ -1,9 +1,28 @@
1
1
  export class ID {
2
+ // Generate an hex ID based on timestamp
3
+ // Recreated from https://www.php.net/manual/en/function.uniqid.php
4
+ static #hexTimestamp(): string {
5
+ const now = new Date();
6
+ const sec = Math.floor(now.getTime() / 1000);
7
+ const msec = now.getMilliseconds();
8
+
9
+ // Convert to hexadecimal
10
+ const hexTimestamp = sec.toString(16) + msec.toString(16).padStart(5, '0');
11
+ return hexTimestamp;
12
+ }
13
+
2
14
  public static custom(id: string): string {
3
15
  return id
4
16
  }
5
-
6
- public static unique(): string {
7
- return 'unique()'
17
+
18
+ public static unique(padding: number = 7): string {
19
+ // Generate a unique ID with padding to have a longer ID
20
+ const baseId = ID.#hexTimestamp();
21
+ let randomPadding = '';
22
+ for (let i = 0; i < padding; i++) {
23
+ const randomHexDigit = Math.floor(Math.random() * 16).toString(16);
24
+ randomPadding += randomHexDigit;
25
+ }
26
+ return baseId + randomPadding;
8
27
  }
9
- }
28
+ }
@@ -1018,14 +1018,14 @@ export class Messaging extends Service {
1018
1018
  *
1019
1019
  * @param {string} providerId
1020
1020
  * @param {string} name
1021
- * @param {string} from
1021
+ * @param {string} templateId
1022
1022
  * @param {string} senderId
1023
1023
  * @param {string} authKey
1024
1024
  * @param {boolean} enabled
1025
1025
  * @throws {AppwriteException}
1026
1026
  * @returns {Promise}
1027
1027
  */
1028
- async createMsg91Provider(providerId: string, name: string, from?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider> {
1028
+ async createMsg91Provider(providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider> {
1029
1029
  if (typeof providerId === 'undefined') {
1030
1030
  throw new AppwriteException('Missing required parameter: "providerId"');
1031
1031
  }
@@ -1045,8 +1045,8 @@ export class Messaging extends Service {
1045
1045
  payload['name'] = name;
1046
1046
  }
1047
1047
 
1048
- if (typeof from !== 'undefined') {
1049
- payload['from'] = from;
1048
+ if (typeof templateId !== 'undefined') {
1049
+ payload['templateId'] = templateId;
1050
1050
  }
1051
1051
 
1052
1052
  if (typeof senderId !== 'undefined') {
@@ -1075,13 +1075,13 @@ export class Messaging extends Service {
1075
1075
  * @param {string} providerId
1076
1076
  * @param {string} name
1077
1077
  * @param {boolean} enabled
1078
+ * @param {string} templateId
1078
1079
  * @param {string} senderId
1079
1080
  * @param {string} authKey
1080
- * @param {string} from
1081
1081
  * @throws {AppwriteException}
1082
1082
  * @returns {Promise}
1083
1083
  */
1084
- async updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, senderId?: string, authKey?: string, from?: string): Promise<Models.Provider> {
1084
+ async updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string): Promise<Models.Provider> {
1085
1085
  if (typeof providerId === 'undefined') {
1086
1086
  throw new AppwriteException('Missing required parameter: "providerId"');
1087
1087
  }
@@ -1097,6 +1097,10 @@ export class Messaging extends Service {
1097
1097
  payload['enabled'] = enabled;
1098
1098
  }
1099
1099
 
1100
+ if (typeof templateId !== 'undefined') {
1101
+ payload['templateId'] = templateId;
1102
+ }
1103
+
1100
1104
  if (typeof senderId !== 'undefined') {
1101
1105
  payload['senderId'] = senderId;
1102
1106
  }
@@ -1105,10 +1109,6 @@ export class Messaging extends Service {
1105
1109
  payload['authKey'] = authKey;
1106
1110
  }
1107
1111
 
1108
- if (typeof from !== 'undefined') {
1109
- payload['from'] = from;
1110
- }
1111
-
1112
1112
  const uri = new URL(this.client.config.endpoint + apiPath);
1113
1113
  return await this.client.call('patch', uri, {
1114
1114
  'content-type': 'application/json',
@@ -32,7 +32,7 @@ export declare enum Flag {
32
32
  Switzerland = "ch",
33
33
  Chile = "cl",
34
34
  China = "cn",
35
- CTeDIvoire = "ci",
35
+ CoteDIvoire = "ci",
36
36
  Cameroon = "cm",
37
37
  DemocraticRepublicOfTheCongo = "cd",
38
38
  RepublicOfTheCongo = "cg",
package/types/id.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare class ID {
2
+ #private;
2
3
  static custom(id: string): string;
3
- static unique(): string;
4
+ static unique(padding?: number): string;
4
5
  }
@@ -301,14 +301,14 @@ export declare class Messaging extends Service {
301
301
  *
302
302
  * @param {string} providerId
303
303
  * @param {string} name
304
- * @param {string} from
304
+ * @param {string} templateId
305
305
  * @param {string} senderId
306
306
  * @param {string} authKey
307
307
  * @param {boolean} enabled
308
308
  * @throws {AppwriteException}
309
309
  * @returns {Promise}
310
310
  */
311
- createMsg91Provider(providerId: string, name: string, from?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider>;
311
+ createMsg91Provider(providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider>;
312
312
  /**
313
313
  * Update Msg91 provider
314
314
  *
@@ -317,13 +317,13 @@ export declare class Messaging extends Service {
317
317
  * @param {string} providerId
318
318
  * @param {string} name
319
319
  * @param {boolean} enabled
320
+ * @param {string} templateId
320
321
  * @param {string} senderId
321
322
  * @param {string} authKey
322
- * @param {string} from
323
323
  * @throws {AppwriteException}
324
324
  * @returns {Promise}
325
325
  */
326
- updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, senderId?: string, authKey?: string, from?: string): Promise<Models.Provider>;
326
+ updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string): Promise<Models.Provider>;
327
327
  /**
328
328
  * Create Sendgrid provider
329
329
  *