node-appwrite 12.0.0 → 12.0.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/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Appwrite Node.js 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)
|
|
@@ -10,7 +10,7 @@ const messaging = new sdk.Messaging(client);
|
|
|
10
10
|
const result = await messaging.createMsg91Provider(
|
|
11
11
|
'<PROVIDER_ID>', // providerId
|
|
12
12
|
'<NAME>', // name
|
|
13
|
-
'
|
|
13
|
+
'<TEMPLATE_ID>', // templateId (optional)
|
|
14
14
|
'<SENDER_ID>', // senderId (optional)
|
|
15
15
|
'<AUTH_KEY>', // authKey (optional)
|
|
16
16
|
false // enabled (optional)
|
|
@@ -11,7 +11,7 @@ const result = await messaging.updateMsg91Provider(
|
|
|
11
11
|
'<PROVIDER_ID>', // providerId
|
|
12
12
|
'<NAME>', // name (optional)
|
|
13
13
|
false, // enabled (optional)
|
|
14
|
+
'<TEMPLATE_ID>', // templateId (optional)
|
|
14
15
|
'<SENDER_ID>', // senderId (optional)
|
|
15
|
-
'<AUTH_KEY>'
|
|
16
|
-
'<FROM>' // from (optional)
|
|
16
|
+
'<AUTH_KEY>' // authKey (optional)
|
|
17
17
|
);
|
package/index.d.ts
CHANGED
|
@@ -4926,14 +4926,14 @@ declare module "node-appwrite" {
|
|
|
4926
4926
|
*
|
|
4927
4927
|
* @param {string} providerId
|
|
4928
4928
|
* @param {string} name
|
|
4929
|
-
* @param {string}
|
|
4929
|
+
* @param {string} templateId
|
|
4930
4930
|
* @param {string} senderId
|
|
4931
4931
|
* @param {string} authKey
|
|
4932
4932
|
* @param {boolean} enabled
|
|
4933
4933
|
* @throws {AppwriteException}
|
|
4934
4934
|
* @returns {Promise}
|
|
4935
4935
|
*/
|
|
4936
|
-
createMsg91Provider(providerId: string, name: string,
|
|
4936
|
+
createMsg91Provider(providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider>;
|
|
4937
4937
|
/**
|
|
4938
4938
|
* Update Msg91 provider
|
|
4939
4939
|
*
|
|
@@ -4942,13 +4942,13 @@ declare module "node-appwrite" {
|
|
|
4942
4942
|
* @param {string} providerId
|
|
4943
4943
|
* @param {string} name
|
|
4944
4944
|
* @param {boolean} enabled
|
|
4945
|
+
* @param {string} templateId
|
|
4945
4946
|
* @param {string} senderId
|
|
4946
4947
|
* @param {string} authKey
|
|
4947
|
-
* @param {string} from
|
|
4948
4948
|
* @throws {AppwriteException}
|
|
4949
4949
|
* @returns {Promise}
|
|
4950
4950
|
*/
|
|
4951
|
-
updateMsg91Provider(providerId: string, name?: string, enabled?: boolean,
|
|
4951
|
+
updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string): Promise<Models.Provider>;
|
|
4952
4952
|
/**
|
|
4953
4953
|
* Create Sendgrid provider
|
|
4954
4954
|
*
|
package/lib/client.js
CHANGED
|
@@ -12,11 +12,11 @@ class Client {
|
|
|
12
12
|
this.headers = {
|
|
13
13
|
'accept-encoding': '*',
|
|
14
14
|
'content-type': '',
|
|
15
|
-
'user-agent' : `AppwriteNodeJSSDK/12.0.
|
|
15
|
+
'user-agent' : `AppwriteNodeJSSDK/12.0.1 (${os.type()}; ${os.version()}; ${os.arch()})`,
|
|
16
16
|
'x-sdk-name': 'Node.js',
|
|
17
17
|
'x-sdk-platform': 'server',
|
|
18
18
|
'x-sdk-language': 'nodejs',
|
|
19
|
-
'x-sdk-version': '12.0.
|
|
19
|
+
'x-sdk-version': '12.0.1',
|
|
20
20
|
'X-Appwrite-Response-Format' : '1.5.0',
|
|
21
21
|
};
|
|
22
22
|
this.selfSigned = false;
|
package/lib/id.js
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
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 = () => {
|
|
5
|
+
const now = new Date();
|
|
6
|
+
const sec = Math.floor(now.getTime() / 1000);
|
|
7
|
+
const msec = now.getMilliseconds();
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
|
|
9
|
+
// Convert to hexadecimal
|
|
10
|
+
const hexTimestamp = sec.toString(16) + msec.toString(16).padStart(5, '0');
|
|
11
|
+
return hexTimestamp;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Generate a unique ID with padding to have a longer ID
|
|
15
|
+
static unique = (padding = 7) => {
|
|
16
|
+
const baseId = ID.#hexTimestamp();
|
|
17
|
+
let randomPadding = '';
|
|
18
|
+
|
|
19
|
+
for (let i = 0; i < padding; i++) {
|
|
20
|
+
const randomHexDigit = Math.floor(Math.random() * 16).toString(16);
|
|
21
|
+
randomPadding += randomHexDigit;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return baseId + randomPadding;
|
|
5
25
|
}
|
|
6
26
|
|
|
7
27
|
static custom = (id) => {
|
|
@@ -1005,14 +1005,14 @@ class Messaging extends Service {
|
|
|
1005
1005
|
*
|
|
1006
1006
|
* @param {string} providerId
|
|
1007
1007
|
* @param {string} name
|
|
1008
|
-
* @param {string}
|
|
1008
|
+
* @param {string} templateId
|
|
1009
1009
|
* @param {string} senderId
|
|
1010
1010
|
* @param {string} authKey
|
|
1011
1011
|
* @param {boolean} enabled
|
|
1012
1012
|
* @throws {AppwriteException}
|
|
1013
1013
|
* @returns {Promise}
|
|
1014
1014
|
*/
|
|
1015
|
-
async createMsg91Provider(providerId, name,
|
|
1015
|
+
async createMsg91Provider(providerId, name, templateId, senderId, authKey, enabled) {
|
|
1016
1016
|
const apiPath = '/messaging/providers/msg91';
|
|
1017
1017
|
let payload = {};
|
|
1018
1018
|
if (typeof providerId === 'undefined') {
|
|
@@ -1032,8 +1032,8 @@ class Messaging extends Service {
|
|
|
1032
1032
|
payload['name'] = name;
|
|
1033
1033
|
}
|
|
1034
1034
|
|
|
1035
|
-
if (typeof
|
|
1036
|
-
payload['
|
|
1035
|
+
if (typeof templateId !== 'undefined') {
|
|
1036
|
+
payload['templateId'] = templateId;
|
|
1037
1037
|
}
|
|
1038
1038
|
|
|
1039
1039
|
if (typeof senderId !== 'undefined') {
|
|
@@ -1061,13 +1061,13 @@ class Messaging extends Service {
|
|
|
1061
1061
|
* @param {string} providerId
|
|
1062
1062
|
* @param {string} name
|
|
1063
1063
|
* @param {boolean} enabled
|
|
1064
|
+
* @param {string} templateId
|
|
1064
1065
|
* @param {string} senderId
|
|
1065
1066
|
* @param {string} authKey
|
|
1066
|
-
* @param {string} from
|
|
1067
1067
|
* @throws {AppwriteException}
|
|
1068
1068
|
* @returns {Promise}
|
|
1069
1069
|
*/
|
|
1070
|
-
async updateMsg91Provider(providerId, name, enabled, senderId, authKey
|
|
1070
|
+
async updateMsg91Provider(providerId, name, enabled, templateId, senderId, authKey) {
|
|
1071
1071
|
const apiPath = '/messaging/providers/msg91/{providerId}'.replace('{providerId}', providerId);
|
|
1072
1072
|
let payload = {};
|
|
1073
1073
|
if (typeof providerId === 'undefined') {
|
|
@@ -1083,6 +1083,10 @@ class Messaging extends Service {
|
|
|
1083
1083
|
payload['enabled'] = enabled;
|
|
1084
1084
|
}
|
|
1085
1085
|
|
|
1086
|
+
if (typeof templateId !== 'undefined') {
|
|
1087
|
+
payload['templateId'] = templateId;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1086
1090
|
if (typeof senderId !== 'undefined') {
|
|
1087
1091
|
payload['senderId'] = senderId;
|
|
1088
1092
|
}
|
|
@@ -1091,10 +1095,6 @@ class Messaging extends Service {
|
|
|
1091
1095
|
payload['authKey'] = authKey;
|
|
1092
1096
|
}
|
|
1093
1097
|
|
|
1094
|
-
if (typeof from !== 'undefined') {
|
|
1095
|
-
payload['from'] = from;
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
1098
|
return await this.client.call('patch', apiPath, {
|
|
1099
1099
|
'content-type': 'application/json',
|
|
1100
1100
|
}, payload);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "node-appwrite",
|
|
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": "12.0.
|
|
5
|
+
"version": "12.0.1",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./index.d.ts",
|