@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/.travis.yml +2 -2
- package/README.md +2 -2
- package/dist/cjs/sdk.js +62 -28
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +61 -27
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +64 -27
- package/docs/examples/messaging/create-msg91provider.md +1 -1
- package/docs/examples/messaging/update-email.md +2 -1
- package/docs/examples/messaging/update-msg91provider.md +2 -2
- package/package.json +1 -5
- package/rollup.config.js +1 -5
- package/src/client.ts +10 -5
- package/src/enums/flag.ts +2 -1
- package/src/enums/runtime.ts +4 -0
- package/src/id.ts +23 -4
- package/src/models.ts +11 -3
- package/src/services/account.ts +4 -4
- package/src/services/messaging.ts +16 -11
- package/types/client.d.ts +0 -1
- package/types/enums/flag.d.ts +2 -1
- package/types/enums/runtime.d.ts +4 -0
- package/types/id.d.ts +2 -1
- package/types/models.d.ts +11 -3
- package/types/services/account.d.ts +4 -4
- package/types/services/messaging.d.ts +6 -5
package/.travis.yml
CHANGED
|
@@ -5,7 +5,7 @@ node_js:
|
|
|
5
5
|
jobs:
|
|
6
6
|
include:
|
|
7
7
|
- stage: NPM RC Release
|
|
8
|
-
if: tag
|
|
8
|
+
if: tag =~ /-(rc|RC)/
|
|
9
9
|
node_js: "14.16"
|
|
10
10
|
script:
|
|
11
11
|
- npm install
|
|
@@ -17,7 +17,7 @@ jobs:
|
|
|
17
17
|
api_key: $NPM_API_KEY
|
|
18
18
|
tag: next
|
|
19
19
|
- stage: NPM Release
|
|
20
|
-
if: tag
|
|
20
|
+
if: not tag =~ /-(rc|RC)/
|
|
21
21
|
node_js: "14.16"
|
|
22
22
|
script:
|
|
23
23
|
- npm install
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Appwrite Console SDK
|
|
2
2
|
|
|
3
3
|

|
|
4
|
-

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