@appwrite.io/console 0.6.1 → 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/iife/sdk.js CHANGED
@@ -1,4 +1,4 @@
1
- (function (exports, isomorphicFormData, crossFetch) {
1
+ (function (exports) {
2
2
  'use strict';
3
3
 
4
4
  /******************************************************************************
@@ -121,7 +121,7 @@
121
121
  'x-sdk-name': 'Console',
122
122
  'x-sdk-platform': 'console',
123
123
  'x-sdk-language': 'web',
124
- 'x-sdk-version': '0.6.1',
124
+ 'x-sdk-version': '0.6.2',
125
125
  'X-Appwrite-Response-Format': '1.5.0',
126
126
  };
127
127
  this.realtime = {
@@ -153,9 +153,12 @@
153
153
  }
154
154
  },
155
155
  createSocket: () => {
156
- var _a, _b;
157
- if (this.realtime.channels.size < 1)
156
+ var _a, _b, _c;
157
+ if (this.realtime.channels.size < 1) {
158
+ this.realtime.reconnect = false;
159
+ (_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.close();
158
160
  return;
161
+ }
159
162
  const channels = new URLSearchParams();
160
163
  channels.set('project', this.config.project);
161
164
  this.realtime.channels.forEach(channel => {
@@ -164,10 +167,10 @@
164
167
  const url = this.config.endpointRealtime + '/realtime?' + channels.toString();
165
168
  if (url !== this.realtime.url || // Check if URL is present
166
169
  !this.realtime.socket || // Check if WebSocket has not been created
167
- ((_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.readyState) > WebSocket.OPEN // Check if WebSocket is CLOSING (3) or CLOSED (4)
170
+ ((_b = this.realtime.socket) === null || _b === void 0 ? void 0 : _b.readyState) > WebSocket.OPEN // Check if WebSocket is CLOSING (3) or CLOSED (4)
168
171
  ) {
169
172
  if (this.realtime.socket &&
170
- ((_b = this.realtime.socket) === null || _b === void 0 ? void 0 : _b.readyState) < WebSocket.CLOSING // Close WebSocket if it is CONNECTING (0) or OPEN (1)
173
+ ((_c = this.realtime.socket) === null || _c === void 0 ? void 0 : _c.readyState) < WebSocket.CLOSING // Close WebSocket if it is CONNECTING (0) or OPEN (1)
171
174
  ) {
172
175
  this.realtime.reconnect = false;
173
176
  this.realtime.socket.close();
@@ -384,7 +387,7 @@
384
387
  };
385
388
  }
386
389
  call(method, url, headers = {}, params = {}) {
387
- var _a, _b;
390
+ var _a;
388
391
  return __awaiter(this, void 0, void 0, function* () {
389
392
  method = method.toUpperCase();
390
393
  headers = Object.assign({}, this.headers, headers);
@@ -394,7 +397,10 @@
394
397
  credentials: 'include'
395
398
  };
396
399
  if (typeof window !== 'undefined' && window.localStorage) {
397
- headers['X-Fallback-Cookies'] = (_a = window.localStorage.getItem('cookieFallback')) !== null && _a !== void 0 ? _a : '';
400
+ const cookieFallback = window.localStorage.getItem('cookieFallback');
401
+ if (cookieFallback) {
402
+ headers['X-Fallback-Cookies'] = cookieFallback;
403
+ }
398
404
  }
399
405
  if (method === 'GET') {
400
406
  for (const [key, value] of Object.entries(Service.flatten(params))) {
@@ -425,8 +431,8 @@
425
431
  }
426
432
  try {
427
433
  let data = null;
428
- const response = yield crossFetch.fetch(url.toString(), options);
429
- if ((_b = response.headers.get('content-type')) === null || _b === void 0 ? void 0 : _b.includes('application/json')) {
434
+ const response = yield fetch(url.toString(), options);
435
+ if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
430
436
  data = yield response.json();
431
437
  }
432
438
  else {
@@ -701,7 +707,7 @@
701
707
  *
702
708
  * Add an authenticator app to be used as an MFA factor. Verify the
703
709
  * authenticator using the [verify
704
- * authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator)
710
+ * authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator)
705
711
  * method.
706
712
  *
707
713
  * @param {AuthenticatorType} type
@@ -725,8 +731,8 @@
725
731
  * Verify Authenticator
726
732
  *
727
733
  * Verify an authenticator app after adding it using the [add
728
- * authenticator](/docs/references/cloud/client-web/account#addAuthenticator)
729
- * method.
734
+ * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
735
+ * method. add
730
736
  *
731
737
  * @param {AuthenticatorType} type
732
738
  * @param {string} otp
@@ -5873,10 +5879,11 @@
5873
5879
  * @param {string[]} cc
5874
5880
  * @param {string[]} bcc
5875
5881
  * @param {string} scheduledAt
5882
+ * @param {string[]} attachments
5876
5883
  * @throws {AppwriteException}
5877
5884
  * @returns {Promise}
5878
5885
  */
5879
- updateEmail(messageId, topics, users, targets, subject, content, draft, html, cc, bcc, scheduledAt) {
5886
+ updateEmail(messageId, topics, users, targets, subject, content, draft, html, cc, bcc, scheduledAt, attachments) {
5880
5887
  return __awaiter(this, void 0, void 0, function* () {
5881
5888
  if (typeof messageId === 'undefined') {
5882
5889
  throw new AppwriteException('Missing required parameter: "messageId"');
@@ -5913,6 +5920,9 @@
5913
5920
  if (typeof scheduledAt !== 'undefined') {
5914
5921
  payload['scheduledAt'] = scheduledAt;
5915
5922
  }
5923
+ if (typeof attachments !== 'undefined') {
5924
+ payload['attachments'] = attachments;
5925
+ }
5916
5926
  const uri = new URL(this.client.config.endpoint + apiPath);
5917
5927
  return yield this.client.call('patch', uri, {
5918
5928
  'content-type': 'application/json',
@@ -13149,6 +13159,7 @@
13149
13159
  Flag["Palau"] = "pw";
13150
13160
  Flag["PapuaNewGuinea"] = "pg";
13151
13161
  Flag["Poland"] = "pl";
13162
+ Flag["FrenchPolynesia"] = "pf";
13152
13163
  Flag["NorthKorea"] = "kp";
13153
13164
  Flag["Portugal"] = "pt";
13154
13165
  Flag["Paraguay"] = "py";
@@ -13254,6 +13265,10 @@
13254
13265
  Runtime["Python310"] = "python-3.10";
13255
13266
  Runtime["Python311"] = "python-3.11";
13256
13267
  Runtime["Python312"] = "python-3.12";
13268
+ Runtime["Pythonml311"] = "python-ml-3.11";
13269
+ Runtime["Deno121"] = "deno-1.21";
13270
+ Runtime["Deno124"] = "deno-1.24";
13271
+ Runtime["Deno135"] = "deno-1.35";
13257
13272
  Runtime["Deno140"] = "deno-1.40";
13258
13273
  Runtime["Dart215"] = "dart-2.15";
13259
13274
  Runtime["Dart216"] = "dart-2.16";
@@ -13774,4 +13789,4 @@
13774
13789
 
13775
13790
  Object.defineProperty(exports, '__esModule', { value: true });
13776
13791
 
13777
- })(this.Appwrite = this.Appwrite || {}, null, window);
13792
+ })(this.Appwrite = this.Appwrite || {});
@@ -17,7 +17,8 @@ const result = await messaging.updateEmail(
17
17
  false, // html (optional)
18
18
  [], // cc (optional)
19
19
  [], // bcc (optional)
20
- '' // scheduledAt (optional)
20
+ '', // scheduledAt (optional)
21
+ [] // attachments (optional)
21
22
  );
22
23
 
23
24
  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.1",
5
+ "version": "0.6.2",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/cjs/sdk.js",
8
8
  "exports": {
@@ -32,10 +32,6 @@
32
32
  "tslib": "2.4.0",
33
33
  "typescript": "4.7.2"
34
34
  },
35
- "dependencies": {
36
- "cross-fetch": "3.1.5",
37
- "isomorphic-form-data": "2.0.0"
38
- },
39
35
  "jsdelivr": "dist/iife/sdk.js",
40
36
  "unpkg": "dist/iife/sdk.js"
41
37
  }
package/rollup.config.js CHANGED
@@ -2,7 +2,7 @@ import pkg from "./package.json";
2
2
  import typescript from "@rollup/plugin-typescript";
3
3
 
4
4
  export default {
5
- external: Object.keys(pkg.dependencies),
5
+ external: Object.keys(pkg.dependencies ?? {}),
6
6
  input: "src/index.ts",
7
7
  plugins: [typescript()],
8
8
  output: [
@@ -22,10 +22,6 @@ export default {
22
22
  file: pkg.jsdelivr,
23
23
  name: "Appwrite",
24
24
  extend: true,
25
- globals: {
26
- "cross-fetch": "window",
27
- "FormData": "FormData",
28
- },
29
25
  },
30
26
  ],
31
27
  };
package/src/client.ts CHANGED
@@ -1,5 +1,3 @@
1
- import 'isomorphic-form-data';
2
- import { fetch } from 'cross-fetch';
3
1
  import { Models } from './models';
4
2
  import { Service } from './service';
5
3
 
@@ -104,7 +102,7 @@ class Client {
104
102
  'x-sdk-name': 'Console',
105
103
  'x-sdk-platform': 'console',
106
104
  'x-sdk-language': 'web',
107
- 'x-sdk-version': '0.6.1',
105
+ 'x-sdk-version': '0.6.2',
108
106
  'X-Appwrite-Response-Format': '1.5.0',
109
107
  };
110
108
 
@@ -238,7 +236,11 @@ class Client {
238
236
  }
239
237
  },
240
238
  createSocket: () => {
241
- if (this.realtime.channels.size < 1) return;
239
+ if (this.realtime.channels.size < 1) {
240
+ this.realtime.reconnect = false;
241
+ this.realtime.socket?.close();
242
+ return;
243
+ }
242
244
 
243
245
  const channels = new URLSearchParams();
244
246
  channels.set('project', this.config.project);
@@ -401,7 +403,10 @@ class Client {
401
403
  };
402
404
 
403
405
  if (typeof window !== 'undefined' && window.localStorage) {
404
- headers['X-Fallback-Cookies'] = window.localStorage.getItem('cookieFallback') ?? '';
406
+ const cookieFallback = window.localStorage.getItem('cookieFallback');
407
+ if (cookieFallback) {
408
+ headers['X-Fallback-Cookies'] = cookieFallback;
409
+ }
405
410
  }
406
411
 
407
412
  if (method === 'GET') {
package/src/enums/flag.ts CHANGED
@@ -140,6 +140,7 @@ export enum Flag {
140
140
  Palau = 'pw',
141
141
  PapuaNewGuinea = 'pg',
142
142
  Poland = 'pl',
143
+ FrenchPolynesia = 'pf',
143
144
  NorthKorea = 'kp',
144
145
  Portugal = 'pt',
145
146
  Paraguay = 'py',
@@ -18,6 +18,10 @@ export enum Runtime {
18
18
  Python310 = 'python-3.10',
19
19
  Python311 = 'python-3.11',
20
20
  Python312 = 'python-3.12',
21
+ Pythonml311 = 'python-ml-3.11',
22
+ Deno121 = 'deno-1.21',
23
+ Deno124 = 'deno-1.24',
24
+ Deno135 = 'deno-1.35',
21
25
  Deno140 = 'deno-1.40',
22
26
  Dart215 = 'dart-2.15',
23
27
  Dart216 = 'dart-2.16',
package/src/models.ts CHANGED
@@ -1320,6 +1320,10 @@ export namespace Models {
1320
1320
  * Session creation date in ISO 8601 format.
1321
1321
  */
1322
1322
  $createdAt: string;
1323
+ /**
1324
+ * Session update date in ISO 8601 format.
1325
+ */
1326
+ $updatedAt: string;
1323
1327
  /**
1324
1328
  * User ID.
1325
1329
  */
@@ -3266,17 +3270,21 @@ export namespace Models {
3266
3270
  */
3267
3271
  export type MfaFactors = {
3268
3272
  /**
3269
- * TOTP
3273
+ * Can TOTP be used for MFA challenge for this account.
3270
3274
  */
3271
3275
  totp: boolean;
3272
3276
  /**
3273
- * Phone
3277
+ * Can phone (SMS) be used for MFA challenge for this account.
3274
3278
  */
3275
3279
  phone: boolean;
3276
3280
  /**
3277
- * Email
3281
+ * Can email be used for MFA challenge for this account.
3278
3282
  */
3279
3283
  email: boolean;
3284
+ /**
3285
+ * Can recovery code be used for MFA challenge for this account.
3286
+ */
3287
+ recoveryCode: boolean;
3280
3288
  }
3281
3289
  /**
3282
3290
  * Provider
@@ -272,7 +272,7 @@ export class Account extends Service {
272
272
  *
273
273
  * Add an authenticator app to be used as an MFA factor. Verify the
274
274
  * authenticator using the [verify
275
- * authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator)
275
+ * authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator)
276
276
  * method.
277
277
  *
278
278
  * @param {AuthenticatorType} type
@@ -297,8 +297,8 @@ export class Account extends Service {
297
297
  * Verify Authenticator
298
298
  *
299
299
  * Verify an authenticator app after adding it using the [add
300
- * authenticator](/docs/references/cloud/client-web/account#addAuthenticator)
301
- * method.
300
+ * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
301
+ * method. add
302
302
  *
303
303
  * @param {AuthenticatorType} type
304
304
  * @param {string} otp
@@ -337,7 +337,7 @@ export class Account extends Service {
337
337
  * @throws {AppwriteException}
338
338
  * @returns {Promise}
339
339
  */
340
- async deleteMfaAuthenticator<Preferences extends Models.Preferences>(type: AuthenticatorType, otp: string): Promise<Models.User<Preferences>> {
340
+ async deleteMfaAuthenticator(type: AuthenticatorType, otp: string): Promise<{}> {
341
341
  if (typeof type === 'undefined') {
342
342
  throw new AppwriteException('Missing required parameter: "type"');
343
343
  }
@@ -146,10 +146,11 @@ export class Messaging extends Service {
146
146
  * @param {string[]} cc
147
147
  * @param {string[]} bcc
148
148
  * @param {string} scheduledAt
149
+ * @param {string[]} attachments
149
150
  * @throws {AppwriteException}
150
151
  * @returns {Promise}
151
152
  */
152
- async updateEmail(messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string): Promise<Models.Message> {
153
+ async updateEmail(messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[]): Promise<Models.Message> {
153
154
  if (typeof messageId === 'undefined') {
154
155
  throw new AppwriteException('Missing required parameter: "messageId"');
155
156
  }
@@ -197,6 +198,10 @@ export class Messaging extends Service {
197
198
  payload['scheduledAt'] = scheduledAt;
198
199
  }
199
200
 
201
+ if (typeof attachments !== 'undefined') {
202
+ payload['attachments'] = attachments;
203
+ }
204
+
200
205
  const uri = new URL(this.client.config.endpoint + apiPath);
201
206
  return await this.client.call('patch', uri, {
202
207
  'content-type': 'application/json',
package/types/client.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import 'isomorphic-form-data';
2
1
  import { Models } from './models';
3
2
  declare type Payload = {
4
3
  [key: string]: any;
@@ -140,6 +140,7 @@ export declare enum Flag {
140
140
  Palau = "pw",
141
141
  PapuaNewGuinea = "pg",
142
142
  Poland = "pl",
143
+ FrenchPolynesia = "pf",
143
144
  NorthKorea = "kp",
144
145
  Portugal = "pt",
145
146
  Paraguay = "py",
@@ -18,6 +18,10 @@ export declare enum Runtime {
18
18
  Python310 = "python-3.10",
19
19
  Python311 = "python-3.11",
20
20
  Python312 = "python-3.12",
21
+ Pythonml311 = "python-ml-3.11",
22
+ Deno121 = "deno-1.21",
23
+ Deno124 = "deno-1.24",
24
+ Deno135 = "deno-1.35",
21
25
  Deno140 = "deno-1.40",
22
26
  Dart215 = "dart-2.15",
23
27
  Dart216 = "dart-2.16",
package/types/models.d.ts CHANGED
@@ -1320,6 +1320,10 @@ export declare namespace Models {
1320
1320
  * Session creation date in ISO 8601 format.
1321
1321
  */
1322
1322
  $createdAt: string;
1323
+ /**
1324
+ * Session update date in ISO 8601 format.
1325
+ */
1326
+ $updatedAt: string;
1323
1327
  /**
1324
1328
  * User ID.
1325
1329
  */
@@ -3266,17 +3270,21 @@ export declare namespace Models {
3266
3270
  */
3267
3271
  type MfaFactors = {
3268
3272
  /**
3269
- * TOTP
3273
+ * Can TOTP be used for MFA challenge for this account.
3270
3274
  */
3271
3275
  totp: boolean;
3272
3276
  /**
3273
- * Phone
3277
+ * Can phone (SMS) be used for MFA challenge for this account.
3274
3278
  */
3275
3279
  phone: boolean;
3276
3280
  /**
3277
- * Email
3281
+ * Can email be used for MFA challenge for this account.
3278
3282
  */
3279
3283
  email: boolean;
3284
+ /**
3285
+ * Can recovery code be used for MFA challenge for this account.
3286
+ */
3287
+ recoveryCode: boolean;
3280
3288
  };
3281
3289
  /**
3282
3290
  * Provider
@@ -120,7 +120,7 @@ export declare class Account extends Service {
120
120
  *
121
121
  * Add an authenticator app to be used as an MFA factor. Verify the
122
122
  * authenticator using the [verify
123
- * authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator)
123
+ * authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator)
124
124
  * method.
125
125
  *
126
126
  * @param {AuthenticatorType} type
@@ -132,8 +132,8 @@ export declare class Account extends Service {
132
132
  * Verify Authenticator
133
133
  *
134
134
  * Verify an authenticator app after adding it using the [add
135
- * authenticator](/docs/references/cloud/client-web/account#addAuthenticator)
136
- * method.
135
+ * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
136
+ * method. add
137
137
  *
138
138
  * @param {AuthenticatorType} type
139
139
  * @param {string} otp
@@ -151,7 +151,7 @@ export declare class Account extends Service {
151
151
  * @throws {AppwriteException}
152
152
  * @returns {Promise}
153
153
  */
154
- deleteMfaAuthenticator<Preferences extends Models.Preferences>(type: AuthenticatorType, otp: string): Promise<Models.User<Preferences>>;
154
+ deleteMfaAuthenticator(type: AuthenticatorType, otp: string): Promise<{}>;
155
155
  /**
156
156
  * Create 2FA Challenge
157
157
  *
@@ -53,10 +53,11 @@ export declare class Messaging extends Service {
53
53
  * @param {string[]} cc
54
54
  * @param {string[]} bcc
55
55
  * @param {string} scheduledAt
56
+ * @param {string[]} attachments
56
57
  * @throws {AppwriteException}
57
58
  * @returns {Promise}
58
59
  */
59
- updateEmail(messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string): Promise<Models.Message>;
60
+ updateEmail(messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[]): Promise<Models.Message>;
60
61
  /**
61
62
  * Create push notification
62
63
  *