@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.
- package/.travis.yml +32 -0
- package/README.md +2 -2
- package/dist/cjs/sdk.js +7743 -0
- package/dist/cjs/sdk.js.map +1 -0
- package/dist/esm/sdk.js +7725 -0
- package/dist/esm/sdk.js.map +1 -0
- package/dist/iife/sdk.js +7744 -0
- package/docs/examples/account/create.md +1 -1
- package/docs/examples/account/update-password.md +1 -1
- package/docs/examples/databases/update-boolean-attribute.md +18 -0
- package/docs/examples/databases/update-datetime-attribute.md +18 -0
- package/docs/examples/databases/update-email-attribute.md +18 -0
- package/docs/examples/databases/update-enum-attribute.md +18 -0
- package/docs/examples/databases/update-float-attribute.md +18 -0
- package/docs/examples/databases/update-integer-attribute.md +18 -0
- package/docs/examples/databases/update-ip-attribute.md +18 -0
- package/docs/examples/databases/update-string-attribute.md +18 -0
- package/docs/examples/databases/update-url-attribute.md +18 -0
- package/docs/examples/functions/create.md +1 -1
- package/docs/examples/functions/update.md +1 -1
- package/docs/examples/projects/update-auth-password-dictionary.md +18 -0
- package/docs/examples/projects/update-auth-password-history.md +18 -0
- package/docs/examples/teams/create-membership.md +1 -1
- package/docs/examples/teams/get-prefs.md +18 -0
- package/docs/examples/teams/update-name.md +18 -0
- package/docs/examples/teams/update-prefs.md +18 -0
- package/docs/examples/teams/update.md +1 -1
- package/docs/examples/users/update-password.md +1 -1
- package/package.json +1 -1
- package/src/client.ts +1 -1
- package/src/models.ts +15 -3
- package/src/services/account.ts +7 -7
- package/src/services/databases.ts +516 -0
- package/src/services/functions.ts +3 -11
- package/src/services/projects.ts +62 -0
- package/src/services/teams.ts +92 -22
- package/types/client.d.ts +135 -0
- package/types/id.d.ts +4 -0
- package/types/index.d.ts +17 -0
- package/types/models.d.ts +2552 -0
- package/types/permission.d.ts +7 -0
- package/types/query.d.ts +21 -0
- package/types/role.d.ts +8 -0
- package/types/service.d.ts +8 -0
- package/types/services/account.d.ts +442 -0
- package/types/services/avatars.d.ts +145 -0
- package/types/services/databases.d.ts +637 -0
- package/types/services/functions.d.ts +280 -0
- package/types/services/graphql.d.ts +25 -0
- package/types/services/health.d.ts +106 -0
- package/types/services/locale.d.ts +81 -0
- package/types/services/projects.d.ts +400 -0
- package/types/services/storage.d.ts +229 -0
- package/types/services/teams.d.ts +207 -0
- package/types/services/users.d.ts +340 -0
- package/.github/workflows/publish.yml +0 -18
package/src/services/teams.ts
CHANGED
|
@@ -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
|
|
109
|
+
* Update Name
|
|
110
110
|
*
|
|
111
|
-
* Update
|
|
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
|
|
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.
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
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
|
-
*
|
|
237
|
-
*
|
|
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
|
|
244
|
-
*
|
|
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,
|
|
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
package/types/index.d.ts
ADDED
|
@@ -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';
|