node-appwrite 8.1.0 → 9.0.0

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.
Files changed (43) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +5 -5
  3. package/docs/examples/account/update-password.md +1 -1
  4. package/docs/examples/account/update-phone.md +1 -1
  5. package/docs/examples/databases/create-relationship-attribute.md +20 -0
  6. package/docs/examples/databases/update-boolean-attribute.md +20 -0
  7. package/docs/examples/{locale/get-continents.md → databases/update-datetime-attribute.md} +2 -2
  8. package/docs/examples/databases/update-email-attribute.md +20 -0
  9. package/docs/examples/databases/update-enum-attribute.md +20 -0
  10. package/docs/examples/databases/update-float-attribute.md +20 -0
  11. package/docs/examples/databases/update-integer-attribute.md +20 -0
  12. package/docs/examples/{locale/get-countries-phones.md → databases/update-ip-attribute.md} +2 -2
  13. package/docs/examples/{locale/get-countries-e-u.md → databases/update-relationship-attribute.md} +2 -2
  14. package/docs/examples/databases/update-string-attribute.md +20 -0
  15. package/docs/examples/databases/update-url-attribute.md +20 -0
  16. package/docs/examples/functions/{retry-build.md → create-build.md} +1 -1
  17. package/docs/examples/functions/create.md +1 -1
  18. package/docs/examples/functions/update.md +1 -1
  19. package/docs/examples/{locale/get-currencies.md → graphql/mutation.md} +2 -2
  20. package/docs/examples/{locale/get-languages.md → graphql/query.md} +2 -2
  21. package/docs/examples/teams/create-membership.md +1 -1
  22. package/docs/examples/{account/get-logs.md → teams/get-prefs.md} +2 -2
  23. package/docs/examples/teams/{get-memberships.md → update-name.md} +1 -1
  24. package/docs/examples/{account/get-sessions.md → teams/update-prefs.md} +2 -2
  25. package/docs/examples/users/update-password.md +1 -1
  26. package/docs/examples/users/update-phone.md +1 -1
  27. package/index.d.ts +406 -136
  28. package/index.js +2 -0
  29. package/lib/client.js +2 -1
  30. package/lib/inputFile.js +6 -8
  31. package/lib/query.js +18 -0
  32. package/lib/services/account.js +12 -12
  33. package/lib/services/databases.js +721 -107
  34. package/lib/services/functions.js +48 -50
  35. package/lib/services/graphql.js +72 -0
  36. package/lib/services/storage.js +44 -37
  37. package/lib/services/teams.js +88 -23
  38. package/package.json +6 -4
  39. package/docs/examples/locale/get-countries.md +0 -20
  40. package/docs/examples/teams/update.md +0 -20
  41. package/docs/examples/users/get-logs.md +0 -20
  42. package/docs/examples/users/get-memberships.md +0 -20
  43. package/docs/examples/users/get-sessions.md +0 -20
@@ -51,8 +51,8 @@ class Functions extends Service {
51
51
  *
52
52
  * @param {string} functionId
53
53
  * @param {string} name
54
- * @param {string[]} execute
55
54
  * @param {string} runtime
55
+ * @param {string[]} execute
56
56
  * @param {string[]} events
57
57
  * @param {string} schedule
58
58
  * @param {number} timeout
@@ -60,7 +60,7 @@ class Functions extends Service {
60
60
  * @throws {AppwriteException}
61
61
  * @returns {Promise}
62
62
  */
63
- async create(functionId, name, execute, runtime, events, schedule, timeout, enabled) {
63
+ async create(functionId, name, runtime, execute, events, schedule, timeout, enabled) {
64
64
  let path = '/functions';
65
65
  let payload = {};
66
66
  if (typeof functionId === 'undefined') {
@@ -71,10 +71,6 @@ class Functions extends Service {
71
71
  throw new AppwriteException('Missing required parameter: "name"');
72
72
  }
73
73
 
74
- if (typeof execute === 'undefined') {
75
- throw new AppwriteException('Missing required parameter: "execute"');
76
- }
77
-
78
74
  if (typeof runtime === 'undefined') {
79
75
  throw new AppwriteException('Missing required parameter: "runtime"');
80
76
  }
@@ -182,10 +178,6 @@ class Functions extends Service {
182
178
  throw new AppwriteException('Missing required parameter: "name"');
183
179
  }
184
180
 
185
- if (typeof execute === 'undefined') {
186
- throw new AppwriteException('Missing required parameter: "execute"');
187
- }
188
-
189
181
 
190
182
  if (typeof name !== 'undefined') {
191
183
  payload['name'] = name;
@@ -382,48 +374,56 @@ class Functions extends Service {
382
374
 
383
375
  return await new Promise((resolve, reject) => {
384
376
  const writeStream = new Stream.Writable();
385
- writeStream._write = async (mainChunk, encoding, next) => {
386
- // Segment incoming chunk into up to 5MB chunks
387
- const mainChunkSize = Buffer.byteLength(mainChunk);
388
- const chunksCount = Math.ceil(mainChunkSize / client.CHUNK_SIZE);
389
- const chunks = [];
390
-
391
- for(let i = 0; i < chunksCount; i++) {
392
- const chunk = mainChunk.slice(i * client.CHUNK_SIZE, client.CHUNK_SIZE);
393
- chunks.push(chunk);
394
- }
377
+ writeStream._write = async (mainChunk, encoding, callback) => {
378
+ try {
379
+ // Segment incoming chunk into up to 5MB chunks
380
+ const mainChunkSize = Buffer.byteLength(mainChunk);
381
+ const chunksCount = Math.ceil(mainChunkSize / client.CHUNK_SIZE);
382
+ const chunks = [];
383
+
384
+ for(let i = 0; i < chunksCount; i++) {
385
+ const chunk = mainChunk.slice(i * client.CHUNK_SIZE, (i + 1) * client.CHUNK_SIZE);
386
+ chunks.push(chunk);
387
+ }
395
388
 
396
- for (const chunk of chunks) {
397
- const chunkSize = Buffer.byteLength(chunk);
398
-
399
- if(chunkSize + currentChunkSize == client.CHUNK_SIZE) {
400
- // Upload chunk
401
- currentChunk = Buffer.concat([currentChunk, chunk]);
402
- await uploadChunk();
403
- currentChunk = Buffer.from('');
404
- currentChunkSize = 0;
405
- } else if(chunkSize + currentChunkSize > client.CHUNK_SIZE) {
406
- // Upload chunk, put rest into next chunk
407
- const bytesToUpload = client.CHUNK_SIZE - currentChunkSize;
408
- const newChunkSection = chunk.slice(0, bytesToUpload);
409
- currentChunk = Buffer.concat([currentChunk, newChunkSection]);
410
- currentChunkSize = Buffer.byteLength(currentChunk);
411
- await uploadChunk();
412
- currentChunk = chunk.slice(bytesToUpload, undefined);
413
- currentChunkSize = chunkSize - bytesToUpload;
414
- } else {
415
- // Append into current chunk
416
- currentChunk = Buffer.concat([currentChunk, chunk]);
417
- currentChunkSize = chunkSize + currentChunkSize;
389
+ for (const chunk of chunks) {
390
+ const chunkSize = Buffer.byteLength(chunk);
391
+
392
+ if(chunkSize + currentChunkSize == client.CHUNK_SIZE) {
393
+ // Upload chunk
394
+ currentChunk = Buffer.concat([currentChunk, chunk]);
395
+ await uploadChunk();
396
+ currentChunk = Buffer.from('');
397
+ currentChunkSize = 0;
398
+ } else if(chunkSize + currentChunkSize > client.CHUNK_SIZE) {
399
+ // Upload chunk, put rest into next chunk
400
+ const bytesToUpload = client.CHUNK_SIZE - currentChunkSize;
401
+ const newChunkSection = chunk.slice(0, bytesToUpload);
402
+ currentChunk = Buffer.concat([currentChunk, newChunkSection]);
403
+ currentChunkSize = Buffer.byteLength(currentChunk);
404
+ await uploadChunk();
405
+ currentChunk = chunk.slice(bytesToUpload, undefined);
406
+ currentChunkSize = chunkSize - bytesToUpload;
407
+ } else {
408
+ // Append into current chunk
409
+ currentChunk = Buffer.concat([currentChunk, chunk]);
410
+ currentChunkSize = chunkSize + currentChunkSize;
411
+ }
418
412
  }
419
- }
420
413
 
421
- next();
414
+ callback();
415
+ } catch (e) {
416
+ callback(e);
417
+ }
422
418
  }
423
419
 
424
420
  writeStream.on("finish", async () => {
425
421
  if(currentChunkSize > 0) {
426
- await uploadChunk(true);
422
+ try {
423
+ await uploadChunk(true);
424
+ } catch (e) {
425
+ reject(e);
426
+ }
427
427
  }
428
428
 
429
429
  resolve(response);
@@ -522,7 +522,7 @@ class Functions extends Service {
522
522
  }
523
523
 
524
524
  /**
525
- * Retry Build
525
+ * Create Build
526
526
  *
527
527
  * @param {string} functionId
528
528
  * @param {string} deploymentId
@@ -530,7 +530,7 @@ class Functions extends Service {
530
530
  * @throws {AppwriteException}
531
531
  * @returns {Promise}
532
532
  */
533
- async retryBuild(functionId, deploymentId, buildId) {
533
+ async createBuild(functionId, deploymentId, buildId) {
534
534
  let path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId);
535
535
  let payload = {};
536
536
  if (typeof functionId === 'undefined') {
@@ -555,9 +555,7 @@ class Functions extends Service {
555
555
  * List Executions
556
556
  *
557
557
  * Get a list of all the current user function execution logs. You can use the
558
- * query params to filter your results. On admin mode, this endpoint will
559
- * return a list of all of the project's executions. [Learn more about
560
- * different API modes](/docs/admin).
558
+ * query params to filter your results.
561
559
  *
562
560
  * @param {string} functionId
563
561
  * @param {string[]} queries
@@ -0,0 +1,72 @@
1
+ const Service = require('../service.js');
2
+ const AppwriteException = require('../exception.js');
3
+ const InputFile = require('../inputFile.js');
4
+ const client = require('../client.js');
5
+ const Stream = require('stream');
6
+ const { promisify } = require('util');
7
+ const fs = require('fs');
8
+
9
+ class Graphql extends Service {
10
+
11
+ constructor(client)
12
+ {
13
+ super(client);
14
+ }
15
+
16
+
17
+ /**
18
+ * GraphQL Endpoint
19
+ *
20
+ * Execute a GraphQL mutation.
21
+ *
22
+ * @param {object} query
23
+ * @throws {AppwriteException}
24
+ * @returns {Promise}
25
+ */
26
+ async query(query) {
27
+ let path = '/graphql';
28
+ let payload = {};
29
+ if (typeof query === 'undefined') {
30
+ throw new AppwriteException('Missing required parameter: "query"');
31
+ }
32
+
33
+
34
+ if (typeof query !== 'undefined') {
35
+ payload['query'] = query;
36
+ }
37
+
38
+ return await this.client.call('post', path, {
39
+ 'x-sdk-graphql': 'true',
40
+ 'content-type': 'application/json',
41
+ }, payload);
42
+ }
43
+
44
+ /**
45
+ * GraphQL Endpoint
46
+ *
47
+ * Execute a GraphQL mutation.
48
+ *
49
+ * @param {object} query
50
+ * @throws {AppwriteException}
51
+ * @returns {Promise}
52
+ */
53
+ async mutation(query) {
54
+ let path = '/graphql/mutation';
55
+ let payload = {};
56
+ if (typeof query === 'undefined') {
57
+ throw new AppwriteException('Missing required parameter: "query"');
58
+ }
59
+
60
+
61
+ if (typeof query !== 'undefined') {
62
+ payload['query'] = query;
63
+ }
64
+
65
+ return await this.client.call('post', path, {
66
+ 'x-sdk-graphql': 'true',
67
+ 'content-type': 'application/json',
68
+ }, payload);
69
+ }
70
+ }
71
+
72
+ module.exports = Graphql;
@@ -237,8 +237,7 @@ class Storage extends Service {
237
237
  * List Files
238
238
  *
239
239
  * Get a list of all the user files. You can use the query params to filter
240
- * your results. On admin mode, this endpoint will return a list of all of the
241
- * project's files. [Learn more about different API modes](/docs/admin).
240
+ * your results.
242
241
  *
243
242
  * @param {string} bucketId
244
243
  * @param {string[]} queries
@@ -389,48 +388,56 @@ class Storage extends Service {
389
388
 
390
389
  return await new Promise((resolve, reject) => {
391
390
  const writeStream = new Stream.Writable();
392
- writeStream._write = async (mainChunk, encoding, next) => {
393
- // Segment incoming chunk into up to 5MB chunks
394
- const mainChunkSize = Buffer.byteLength(mainChunk);
395
- const chunksCount = Math.ceil(mainChunkSize / client.CHUNK_SIZE);
396
- const chunks = [];
397
-
398
- for(let i = 0; i < chunksCount; i++) {
399
- const chunk = mainChunk.slice(i * client.CHUNK_SIZE, client.CHUNK_SIZE);
400
- chunks.push(chunk);
401
- }
391
+ writeStream._write = async (mainChunk, encoding, callback) => {
392
+ try {
393
+ // Segment incoming chunk into up to 5MB chunks
394
+ const mainChunkSize = Buffer.byteLength(mainChunk);
395
+ const chunksCount = Math.ceil(mainChunkSize / client.CHUNK_SIZE);
396
+ const chunks = [];
397
+
398
+ for(let i = 0; i < chunksCount; i++) {
399
+ const chunk = mainChunk.slice(i * client.CHUNK_SIZE, (i + 1) * client.CHUNK_SIZE);
400
+ chunks.push(chunk);
401
+ }
402
402
 
403
- for (const chunk of chunks) {
404
- const chunkSize = Buffer.byteLength(chunk);
405
-
406
- if(chunkSize + currentChunkSize == client.CHUNK_SIZE) {
407
- // Upload chunk
408
- currentChunk = Buffer.concat([currentChunk, chunk]);
409
- await uploadChunk();
410
- currentChunk = Buffer.from('');
411
- currentChunkSize = 0;
412
- } else if(chunkSize + currentChunkSize > client.CHUNK_SIZE) {
413
- // Upload chunk, put rest into next chunk
414
- const bytesToUpload = client.CHUNK_SIZE - currentChunkSize;
415
- const newChunkSection = chunk.slice(0, bytesToUpload);
416
- currentChunk = Buffer.concat([currentChunk, newChunkSection]);
417
- currentChunkSize = Buffer.byteLength(currentChunk);
418
- await uploadChunk();
419
- currentChunk = chunk.slice(bytesToUpload, undefined);
420
- currentChunkSize = chunkSize - bytesToUpload;
421
- } else {
422
- // Append into current chunk
423
- currentChunk = Buffer.concat([currentChunk, chunk]);
424
- currentChunkSize = chunkSize + currentChunkSize;
403
+ for (const chunk of chunks) {
404
+ const chunkSize = Buffer.byteLength(chunk);
405
+
406
+ if(chunkSize + currentChunkSize == client.CHUNK_SIZE) {
407
+ // Upload chunk
408
+ currentChunk = Buffer.concat([currentChunk, chunk]);
409
+ await uploadChunk();
410
+ currentChunk = Buffer.from('');
411
+ currentChunkSize = 0;
412
+ } else if(chunkSize + currentChunkSize > client.CHUNK_SIZE) {
413
+ // Upload chunk, put rest into next chunk
414
+ const bytesToUpload = client.CHUNK_SIZE - currentChunkSize;
415
+ const newChunkSection = chunk.slice(0, bytesToUpload);
416
+ currentChunk = Buffer.concat([currentChunk, newChunkSection]);
417
+ currentChunkSize = Buffer.byteLength(currentChunk);
418
+ await uploadChunk();
419
+ currentChunk = chunk.slice(bytesToUpload, undefined);
420
+ currentChunkSize = chunkSize - bytesToUpload;
421
+ } else {
422
+ // Append into current chunk
423
+ currentChunk = Buffer.concat([currentChunk, chunk]);
424
+ currentChunkSize = chunkSize + currentChunkSize;
425
+ }
425
426
  }
426
- }
427
427
 
428
- next();
428
+ callback();
429
+ } catch (e) {
430
+ callback(e);
431
+ }
429
432
  }
430
433
 
431
434
  writeStream.on("finish", async () => {
432
435
  if(currentChunkSize > 0) {
433
- await uploadChunk(true);
436
+ try {
437
+ await uploadChunk(true);
438
+ } catch (e) {
439
+ reject(e);
440
+ }
434
441
  }
435
442
 
436
443
  resolve(response);
@@ -18,10 +18,7 @@ class Teams extends Service {
18
18
  * List Teams
19
19
  *
20
20
  * Get a list of all the teams in which the current user is a member. You can
21
- * use the parameters to filter your results.
22
- *
23
- * In admin mode, this endpoint returns a list of all the teams in the current
24
- * project. [Learn more about different API modes](/docs/admin).
21
+ * use the parameters to filter your results.
25
22
  *
26
23
  * @param {string[]} queries
27
24
  * @param {string} search
@@ -110,17 +107,16 @@ class Teams extends Service {
110
107
  }
111
108
 
112
109
  /**
113
- * Update Team
110
+ * Update Name
114
111
  *
115
- * Update a team using its ID. Only members with the owner role can update the
116
- * team.
112
+ * Update the team's name by its unique ID.
117
113
  *
118
114
  * @param {string} teamId
119
115
  * @param {string} name
120
116
  * @throws {AppwriteException}
121
117
  * @returns {Promise}
122
118
  */
123
- async update(teamId, name) {
119
+ async updateName(teamId, name) {
124
120
  let path = '/teams/{teamId}'.replace('{teamId}', teamId);
125
121
  let payload = {};
126
122
  if (typeof teamId === 'undefined') {
@@ -200,41 +196,45 @@ class Teams extends Service {
200
196
  /**
201
197
  * Create Team Membership
202
198
  *
203
- * Invite a new member to join your team. If initiated from the client SDK, an
204
- * email with a link to join the team will be sent to the member's email
205
- * address and an account will be created for them should they not be signed
206
- * up already. If initiated from server-side SDKs, the new member will
207
- * automatically be added to the team.
199
+ * Invite a new member to join your team. Provide an ID for existing users, or
200
+ * invite unregistered users using an email or phone number. If initiated from
201
+ * a Client SDK, Appwrite will send an email or sms with a link to join the
202
+ * team to the invited user, and an account will be created for them if one
203
+ * doesn't exist. If initiated from a Server SDK, the new member will be added
204
+ * automatically to the team.
208
205
  *
209
- * Use the 'url' parameter to redirect the user from the invitation email back
210
- * to your app. When the user is redirected, use the [Update Team Membership
206
+ * You only need to provide one of a user ID, email, or phone number. Appwrite
207
+ * will prioritize accepting the user ID > email > phone number if you provide
208
+ * more than one of these parameters.
209
+ *
210
+ * Use the `url` parameter to redirect the user from the invitation email to
211
+ * your app. After the user is redirected, use the [Update Team Membership
211
212
  * Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow
212
213
  * the user to accept the invitation to the team.
213
214
  *
214
215
  * Please note that to avoid a [Redirect
215
216
  * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
216
- * the only valid redirect URL's are the once from domains you have set when
217
- * adding your platforms in the console interface.
217
+ * Appwrite will accept the only redirect URLs under the domains you have
218
+ * added as a platform on the Appwrite Console.
219
+ *
218
220
  *
219
221
  * @param {string} teamId
220
- * @param {string} email
221
222
  * @param {string[]} roles
222
223
  * @param {string} url
224
+ * @param {string} email
225
+ * @param {string} userId
226
+ * @param {string} phone
223
227
  * @param {string} name
224
228
  * @throws {AppwriteException}
225
229
  * @returns {Promise}
226
230
  */
227
- async createMembership(teamId, email, roles, url, name) {
231
+ async createMembership(teamId, roles, url, email, userId, phone, name) {
228
232
  let path = '/teams/{teamId}/memberships'.replace('{teamId}', teamId);
229
233
  let payload = {};
230
234
  if (typeof teamId === 'undefined') {
231
235
  throw new AppwriteException('Missing required parameter: "teamId"');
232
236
  }
233
237
 
234
- if (typeof email === 'undefined') {
235
- throw new AppwriteException('Missing required parameter: "email"');
236
- }
237
-
238
238
  if (typeof roles === 'undefined') {
239
239
  throw new AppwriteException('Missing required parameter: "roles"');
240
240
  }
@@ -248,6 +248,14 @@ class Teams extends Service {
248
248
  payload['email'] = email;
249
249
  }
250
250
 
251
+ if (typeof userId !== 'undefined') {
252
+ payload['userId'] = userId;
253
+ }
254
+
255
+ if (typeof phone !== 'undefined') {
256
+ payload['phone'] = phone;
257
+ }
258
+
251
259
  if (typeof roles !== 'undefined') {
252
260
  payload['roles'] = roles;
253
261
  }
@@ -410,6 +418,63 @@ class Teams extends Service {
410
418
  'content-type': 'application/json',
411
419
  }, payload);
412
420
  }
421
+
422
+ /**
423
+ * Get Team Preferences
424
+ *
425
+ * Get the team's shared preferences by its unique ID. If a preference doesn't
426
+ * need to be shared by all team members, prefer storing them in [user
427
+ * preferences](/docs/client/account#accountGetPrefs).
428
+ *
429
+ * @param {string} teamId
430
+ * @throws {AppwriteException}
431
+ * @returns {Promise}
432
+ */
433
+ async getPrefs(teamId) {
434
+ let path = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
435
+ let payload = {};
436
+ if (typeof teamId === 'undefined') {
437
+ throw new AppwriteException('Missing required parameter: "teamId"');
438
+ }
439
+
440
+
441
+ return await this.client.call('get', path, {
442
+ 'content-type': 'application/json',
443
+ }, payload);
444
+ }
445
+
446
+ /**
447
+ * Update Preferences
448
+ *
449
+ * Update the team's preferences by its unique ID. The object you pass is
450
+ * stored as is and replaces any previous value. The maximum allowed prefs
451
+ * size is 64kB and throws an error if exceeded.
452
+ *
453
+ * @param {string} teamId
454
+ * @param {object} prefs
455
+ * @throws {AppwriteException}
456
+ * @returns {Promise}
457
+ */
458
+ async updatePrefs(teamId, prefs) {
459
+ let path = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
460
+ let payload = {};
461
+ if (typeof teamId === 'undefined') {
462
+ throw new AppwriteException('Missing required parameter: "teamId"');
463
+ }
464
+
465
+ if (typeof prefs === 'undefined') {
466
+ throw new AppwriteException('Missing required parameter: "prefs"');
467
+ }
468
+
469
+
470
+ if (typeof prefs !== 'undefined') {
471
+ payload['prefs'] = prefs;
472
+ }
473
+
474
+ return await this.client.call('put', path, {
475
+ 'content-type': 'application/json',
476
+ }, payload);
477
+ }
413
478
  }
414
479
 
415
480
  module.exports = Teams;
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": "8.1.0",
5
+ "version": "9.0.0",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "./index.js",
8
8
  "types": "./index.d.ts",
@@ -10,9 +10,11 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/appwrite/sdk-for-node"
12
12
  },
13
- "devDependencies": {},
13
+ "devDependencies": {
14
+ "@types/node": "^18.16.1"
15
+ },
14
16
  "dependencies": {
15
- "axios": "^0.27.2",
17
+ "axios": "^1.3.6",
16
18
  "form-data": "^4.0.0"
17
19
  }
18
- }
20
+ }
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const locale = new sdk.Locale(client);
7
-
8
- client
9
- .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
10
- .setProject('5df5acd0d48c2') // Your project ID
11
- .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
- ;
13
-
14
- const promise = locale.getCountries();
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const teams = new sdk.Teams(client);
7
-
8
- client
9
- .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
10
- .setProject('5df5acd0d48c2') // Your project ID
11
- .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
- ;
13
-
14
- const promise = teams.update('[TEAM_ID]', '[NAME]');
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const users = new sdk.Users(client);
7
-
8
- client
9
- .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
10
- .setProject('5df5acd0d48c2') // Your project ID
11
- .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
- ;
13
-
14
- const promise = users.getLogs('[USER_ID]');
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const users = new sdk.Users(client);
7
-
8
- client
9
- .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
10
- .setProject('5df5acd0d48c2') // Your project ID
11
- .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
- ;
13
-
14
- const promise = users.getMemberships('[USER_ID]');
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });
@@ -1,20 +0,0 @@
1
- const sdk = require('node-appwrite');
2
-
3
- // Init SDK
4
- const client = new sdk.Client();
5
-
6
- const users = new sdk.Users(client);
7
-
8
- client
9
- .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
10
- .setProject('5df5acd0d48c2') // Your project ID
11
- .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12
- ;
13
-
14
- const promise = users.getSessions('[USER_ID]');
15
-
16
- promise.then(function (response) {
17
- console.log(response);
18
- }, function (error) {
19
- console.log(error);
20
- });