@appwrite.io/console 0.0.1 → 0.1.0-preview-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 (56) hide show
  1. package/.travis.yml +32 -0
  2. package/README.md +2 -2
  3. package/dist/cjs/sdk.js +7743 -0
  4. package/dist/cjs/sdk.js.map +1 -0
  5. package/dist/esm/sdk.js +7725 -0
  6. package/dist/esm/sdk.js.map +1 -0
  7. package/dist/iife/sdk.js +7744 -0
  8. package/docs/examples/account/create.md +1 -1
  9. package/docs/examples/account/update-password.md +1 -1
  10. package/docs/examples/databases/update-boolean-attribute.md +18 -0
  11. package/docs/examples/databases/update-datetime-attribute.md +18 -0
  12. package/docs/examples/databases/update-email-attribute.md +18 -0
  13. package/docs/examples/databases/update-enum-attribute.md +18 -0
  14. package/docs/examples/databases/update-float-attribute.md +18 -0
  15. package/docs/examples/databases/update-integer-attribute.md +18 -0
  16. package/docs/examples/databases/update-ip-attribute.md +18 -0
  17. package/docs/examples/databases/update-string-attribute.md +18 -0
  18. package/docs/examples/databases/update-url-attribute.md +18 -0
  19. package/docs/examples/functions/create.md +1 -1
  20. package/docs/examples/functions/update.md +1 -1
  21. package/docs/examples/projects/update-auth-password-dictionary.md +18 -0
  22. package/docs/examples/projects/update-auth-password-history.md +18 -0
  23. package/docs/examples/teams/create-membership.md +1 -1
  24. package/docs/examples/teams/get-prefs.md +18 -0
  25. package/docs/examples/teams/update-name.md +18 -0
  26. package/docs/examples/teams/update-prefs.md +18 -0
  27. package/docs/examples/teams/update.md +1 -1
  28. package/docs/examples/users/update-password.md +1 -1
  29. package/package.json +1 -1
  30. package/src/client.ts +1 -1
  31. package/src/models.ts +15 -3
  32. package/src/services/account.ts +7 -7
  33. package/src/services/databases.ts +516 -0
  34. package/src/services/functions.ts +3 -11
  35. package/src/services/projects.ts +62 -0
  36. package/src/services/teams.ts +92 -22
  37. package/types/client.d.ts +135 -0
  38. package/types/id.d.ts +4 -0
  39. package/types/index.d.ts +17 -0
  40. package/types/models.d.ts +2552 -0
  41. package/types/permission.d.ts +7 -0
  42. package/types/query.d.ts +21 -0
  43. package/types/role.d.ts +8 -0
  44. package/types/service.d.ts +8 -0
  45. package/types/services/account.d.ts +442 -0
  46. package/types/services/avatars.d.ts +145 -0
  47. package/types/services/databases.d.ts +637 -0
  48. package/types/services/functions.d.ts +280 -0
  49. package/types/services/graphql.d.ts +25 -0
  50. package/types/services/health.d.ts +106 -0
  51. package/types/services/locale.d.ts +81 -0
  52. package/types/services/projects.d.ts +400 -0
  53. package/types/services/storage.d.ts +229 -0
  54. package/types/services/teams.d.ts +207 -0
  55. package/types/services/users.d.ts +340 -0
  56. package/.github/workflows/publish.yml +0 -18
@@ -21,7 +21,7 @@ export class Teams extends Service {
21
21
  * @throws {AppwriteException}
22
22
  * @returns {Promise}
23
23
  */
24
- async list(queries?: string[], search?: string): Promise<Models.TeamList> {
24
+ async list<Preferences extends Models.Preferences>(queries?: string[], search?: string): Promise<Models.TeamList<Preferences>> {
25
25
  let path = '/teams';
26
26
  let payload: Payload = {};
27
27
 
@@ -52,7 +52,7 @@ export class Teams extends Service {
52
52
  * @throws {AppwriteException}
53
53
  * @returns {Promise}
54
54
  */
55
- async create(teamId: string, name: string, roles?: string[]): Promise<Models.Team> {
55
+ async create<Preferences extends Models.Preferences>(teamId: string, name: string, roles?: string[]): Promise<Models.Team<Preferences>> {
56
56
  if (typeof teamId === 'undefined') {
57
57
  throw new AppwriteException('Missing required parameter: "teamId"');
58
58
  }
@@ -91,7 +91,7 @@ export class Teams extends Service {
91
91
  * @throws {AppwriteException}
92
92
  * @returns {Promise}
93
93
  */
94
- async get(teamId: string): Promise<Models.Team> {
94
+ async get<Preferences extends Models.Preferences>(teamId: string): Promise<Models.Team<Preferences>> {
95
95
  if (typeof teamId === 'undefined') {
96
96
  throw new AppwriteException('Missing required parameter: "teamId"');
97
97
  }
@@ -106,17 +106,16 @@ export class Teams extends Service {
106
106
  }
107
107
 
108
108
  /**
109
- * Update Team
109
+ * Update Name
110
110
  *
111
- * Update a team using its ID. Only members with the owner role can update the
112
- * team.
111
+ * Update the team's name by its unique ID.
113
112
  *
114
113
  * @param {string} teamId
115
114
  * @param {string} name
116
115
  * @throws {AppwriteException}
117
116
  * @returns {Promise}
118
117
  */
119
- async update(teamId: string, name: string): Promise<Models.Team> {
118
+ async updateName<Preferences extends Models.Preferences>(teamId: string, name: string): Promise<Models.Team<Preferences>> {
120
119
  if (typeof teamId === 'undefined') {
121
120
  throw new AppwriteException('Missing required parameter: "teamId"');
122
121
  }
@@ -227,39 +226,43 @@ export class Teams extends Service {
227
226
  /**
228
227
  * Create Team Membership
229
228
  *
230
- * Invite a new member to join your team. If initiated from the client SDK, an
231
- * email with a link to join the team will be sent to the member's email
232
- * address and an account will be created for them should they not be signed
233
- * up already. If initiated from server-side SDKs, the new member will
234
- * automatically be added to the team.
229
+ * Invite a new member to join your team. Provide an ID for existing users, or
230
+ * invite unregistered users using an email or phone number. If initiated from
231
+ * a Client SDK, Appwrite will send an email or sms with a link to join the
232
+ * team to the invited user, and an account will be created for them if one
233
+ * doesn't exist. If initiated from a Server SDK, the new member will be added
234
+ * automatically to the team.
235
235
  *
236
- * Use the 'url' parameter to redirect the user from the invitation email back
237
- * to your app. When the user is redirected, use the [Update Team Membership
236
+ * You only need to provide one of a user ID, email, or phone number. Appwrite
237
+ * will prioritize accepting the user ID > email > phone number if you provide
238
+ * more than one of these parameters.
239
+ *
240
+ * Use the `url` parameter to redirect the user from the invitation email to
241
+ * your app. After the user is redirected, use the [Update Team Membership
238
242
  * Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow
239
243
  * the user to accept the invitation to the team.
240
244
  *
241
245
  * Please note that to avoid a [Redirect
242
246
  * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
243
- * the only valid redirect URL's are the once from domains you have set when
244
- * adding your platforms in the console interface.
247
+ * Appwrite will accept the only redirect URLs under the domains you have
248
+ * added as a platform on the Appwrite Console.
249
+ *
245
250
  *
246
251
  * @param {string} teamId
247
- * @param {string} email
248
252
  * @param {string[]} roles
249
253
  * @param {string} url
254
+ * @param {string} email
255
+ * @param {string} userId
256
+ * @param {string} phone
250
257
  * @param {string} name
251
258
  * @throws {AppwriteException}
252
259
  * @returns {Promise}
253
260
  */
254
- async createMembership(teamId: string, email: string, roles: string[], url: string, name?: string): Promise<Models.Membership> {
261
+ async createMembership(teamId: string, roles: string[], url: string, email?: string, userId?: string, phone?: string, name?: string): Promise<Models.Membership> {
255
262
  if (typeof teamId === 'undefined') {
256
263
  throw new AppwriteException('Missing required parameter: "teamId"');
257
264
  }
258
265
 
259
- if (typeof email === 'undefined') {
260
- throw new AppwriteException('Missing required parameter: "email"');
261
- }
262
-
263
266
  if (typeof roles === 'undefined') {
264
267
  throw new AppwriteException('Missing required parameter: "roles"');
265
268
  }
@@ -275,6 +278,14 @@ export class Teams extends Service {
275
278
  payload['email'] = email;
276
279
  }
277
280
 
281
+ if (typeof userId !== 'undefined') {
282
+ payload['userId'] = userId;
283
+ }
284
+
285
+ if (typeof phone !== 'undefined') {
286
+ payload['phone'] = phone;
287
+ }
288
+
278
289
  if (typeof roles !== 'undefined') {
279
290
  payload['roles'] = roles;
280
291
  }
@@ -442,4 +453,63 @@ export class Teams extends Service {
442
453
  'content-type': 'application/json',
443
454
  }, payload);
444
455
  }
456
+
457
+ /**
458
+ * Get Team Preferences
459
+ *
460
+ * Get the team's shared preferences by its unique ID. If a preference doesn't
461
+ * need to be shared by all team members, prefer storing them in [user
462
+ * preferences](/docs/client/account#accountGetPrefs).
463
+ *
464
+ * @param {string} teamId
465
+ * @throws {AppwriteException}
466
+ * @returns {Promise}
467
+ */
468
+ async getPrefs<Preferences extends Models.Preferences>(teamId: string): Promise<Preferences> {
469
+ if (typeof teamId === 'undefined') {
470
+ throw new AppwriteException('Missing required parameter: "teamId"');
471
+ }
472
+
473
+ let path = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
474
+ let payload: Payload = {};
475
+
476
+ const uri = new URL(this.client.config.endpoint + path);
477
+ return await this.client.call('get', uri, {
478
+ 'content-type': 'application/json',
479
+ }, payload);
480
+ }
481
+
482
+ /**
483
+ * Update Preferences
484
+ *
485
+ * Update the team's preferences by its unique ID. The object you pass is
486
+ * stored as is and replaces any previous value. The maximum allowed prefs
487
+ * size is 64kB and throws an error if exceeded.
488
+ *
489
+ * @param {string} teamId
490
+ * @param {object} prefs
491
+ * @throws {AppwriteException}
492
+ * @returns {Promise}
493
+ */
494
+ async updatePrefs<Preferences extends Models.Preferences>(teamId: string, prefs: object): Promise<Preferences> {
495
+ if (typeof teamId === 'undefined') {
496
+ throw new AppwriteException('Missing required parameter: "teamId"');
497
+ }
498
+
499
+ if (typeof prefs === 'undefined') {
500
+ throw new AppwriteException('Missing required parameter: "prefs"');
501
+ }
502
+
503
+ let path = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
504
+ let payload: Payload = {};
505
+
506
+ if (typeof prefs !== 'undefined') {
507
+ payload['prefs'] = prefs;
508
+ }
509
+
510
+ const uri = new URL(this.client.config.endpoint + path);
511
+ return await this.client.call('put', uri, {
512
+ 'content-type': 'application/json',
513
+ }, payload);
514
+ }
445
515
  };
@@ -0,0 +1,135 @@
1
+ import 'isomorphic-form-data';
2
+ import { Models } from './models';
3
+ declare type Payload = {
4
+ [key: string]: any;
5
+ };
6
+ declare type Headers = {
7
+ [key: string]: string;
8
+ };
9
+ export declare type RealtimeResponseEvent<T extends unknown> = {
10
+ events: string[];
11
+ channels: string[];
12
+ timestamp: number;
13
+ payload: T;
14
+ };
15
+ export declare type UploadProgress = {
16
+ $id: string;
17
+ progress: number;
18
+ sizeUploaded: number;
19
+ chunksTotal: number;
20
+ chunksUploaded: number;
21
+ };
22
+ declare class AppwriteException extends Error {
23
+ code: number;
24
+ response: string;
25
+ type: string;
26
+ constructor(message: string, code?: number, type?: string, response?: string);
27
+ }
28
+ declare class Client {
29
+ config: {
30
+ endpoint: string;
31
+ endpointRealtime: string;
32
+ project: string;
33
+ key: string;
34
+ jwt: string;
35
+ locale: string;
36
+ mode: string;
37
+ };
38
+ headers: Headers;
39
+ /**
40
+ * Set Endpoint
41
+ *
42
+ * Your project endpoint
43
+ *
44
+ * @param {string} endpoint
45
+ *
46
+ * @returns {this}
47
+ */
48
+ setEndpoint(endpoint: string): this;
49
+ /**
50
+ * Set Realtime Endpoint
51
+ *
52
+ * @param {string} endpointRealtime
53
+ *
54
+ * @returns {this}
55
+ */
56
+ setEndpointRealtime(endpointRealtime: string): this;
57
+ /**
58
+ * Set Project
59
+ *
60
+ * Your project ID
61
+ *
62
+ * @param value string
63
+ *
64
+ * @return {this}
65
+ */
66
+ setProject(value: string): this;
67
+ /**
68
+ * Set Key
69
+ *
70
+ * Your secret API key
71
+ *
72
+ * @param value string
73
+ *
74
+ * @return {this}
75
+ */
76
+ setKey(value: string): this;
77
+ /**
78
+ * Set JWT
79
+ *
80
+ * Your secret JSON Web Token
81
+ *
82
+ * @param value string
83
+ *
84
+ * @return {this}
85
+ */
86
+ setJWT(value: string): this;
87
+ /**
88
+ * Set Locale
89
+ *
90
+ * @param value string
91
+ *
92
+ * @return {this}
93
+ */
94
+ setLocale(value: string): this;
95
+ /**
96
+ * Set Mode
97
+ *
98
+ * @param value string
99
+ *
100
+ * @return {this}
101
+ */
102
+ setMode(value: string): this;
103
+ private realtime;
104
+ /**
105
+ * Subscribes to Appwrite events and passes you the payload in realtime.
106
+ *
107
+ * @param {string|string[]} channels
108
+ * Channel to subscribe - pass a single channel as a string or multiple with an array of strings.
109
+ *
110
+ * Possible channels are:
111
+ * - account
112
+ * - collections
113
+ * - collections.[ID]
114
+ * - collections.[ID].documents
115
+ * - documents
116
+ * - documents.[ID]
117
+ * - files
118
+ * - files.[ID]
119
+ * - executions
120
+ * - executions.[ID]
121
+ * - functions.[ID]
122
+ * - teams
123
+ * - teams.[ID]
124
+ * - memberships
125
+ * - memberships.[ID]
126
+ * @param {(payload: RealtimeMessage) => void} callback Is called on every realtime update.
127
+ * @returns {() => void} Unsubscribes from events.
128
+ */
129
+ subscribe<T extends unknown>(channels: string | string[], callback: (payload: RealtimeResponseEvent<T>) => void): () => void;
130
+ call(method: string, url: URL, headers?: Headers, params?: Payload): Promise<any>;
131
+ }
132
+ export { Client, AppwriteException };
133
+ export { Query } from './query';
134
+ export type { Models, Payload };
135
+ export type { QueryTypes, QueryTypesList } from './query';
package/types/id.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare class ID {
2
+ static custom(id: string): string;
3
+ static unique(): string;
4
+ }
@@ -0,0 +1,17 @@
1
+ export { Client, Query, AppwriteException } from './client';
2
+ export { Account } from './services/account';
3
+ export { Avatars } from './services/avatars';
4
+ export { Databases } from './services/databases';
5
+ export { Functions } from './services/functions';
6
+ export { Graphql } from './services/graphql';
7
+ export { Health } from './services/health';
8
+ export { Locale } from './services/locale';
9
+ export { Projects } from './services/projects';
10
+ export { Storage } from './services/storage';
11
+ export { Teams } from './services/teams';
12
+ export { Users } from './services/users';
13
+ export type { Models, Payload, RealtimeResponseEvent, UploadProgress } from './client';
14
+ export type { QueryTypes, QueryTypesList } from './query';
15
+ export { Permission } from './permission';
16
+ export { Role } from './role';
17
+ export { ID } from './id';