@appwrite.io/console 0.0.1 → 0.0.2-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/README.md +2 -2
- package/dist/cjs/sdk.js +7252 -0
- package/dist/cjs/sdk.js.map +1 -0
- package/dist/esm/sdk.js +7234 -0
- package/dist/esm/sdk.js.map +1 -0
- package/dist/iife/sdk.js +7253 -0
- package/docs/examples/account/create.md +1 -1
- package/docs/examples/account/update-password.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/users/update-password.md +1 -1
- package/package.json +1 -1
- package/src/client.ts +1 -1
- package/src/models.ts +8 -0
- package/src/services/projects.ts +62 -0
- package/src/services/teams.ts +27 -15
- 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 +2548 -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 +494 -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 +183 -0
- package/types/services/users.d.ts +340 -0
|
@@ -9,7 +9,7 @@ client
|
|
|
9
9
|
.setProject('5df5acd0d48c2') // Your project ID
|
|
10
10
|
;
|
|
11
11
|
|
|
12
|
-
const promise = account.create('[USER_ID]', 'email@example.com', '
|
|
12
|
+
const promise = account.create('[USER_ID]', 'email@example.com', '');
|
|
13
13
|
|
|
14
14
|
promise.then(function (response) {
|
|
15
15
|
console.log(response); // Success
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Client, Projects } from "@appwrite.io/console";
|
|
2
|
+
|
|
3
|
+
const client = new Client();
|
|
4
|
+
|
|
5
|
+
const projects = new Projects(client);
|
|
6
|
+
|
|
7
|
+
client
|
|
8
|
+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
|
9
|
+
.setProject('5df5acd0d48c2') // Your project ID
|
|
10
|
+
;
|
|
11
|
+
|
|
12
|
+
const promise = projects.updateAuthPasswordDictionary('[PROJECT_ID]', false);
|
|
13
|
+
|
|
14
|
+
promise.then(function (response) {
|
|
15
|
+
console.log(response); // Success
|
|
16
|
+
}, function (error) {
|
|
17
|
+
console.log(error); // Failure
|
|
18
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Client, Projects } from "@appwrite.io/console";
|
|
2
|
+
|
|
3
|
+
const client = new Client();
|
|
4
|
+
|
|
5
|
+
const projects = new Projects(client);
|
|
6
|
+
|
|
7
|
+
client
|
|
8
|
+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
|
9
|
+
.setProject('5df5acd0d48c2') // Your project ID
|
|
10
|
+
;
|
|
11
|
+
|
|
12
|
+
const promise = projects.updateAuthPasswordHistory('[PROJECT_ID]', 0);
|
|
13
|
+
|
|
14
|
+
promise.then(function (response) {
|
|
15
|
+
console.log(response); // Success
|
|
16
|
+
}, function (error) {
|
|
17
|
+
console.log(error); // Failure
|
|
18
|
+
});
|
|
@@ -9,7 +9,7 @@ client
|
|
|
9
9
|
.setProject('5df5acd0d48c2') // Your project ID
|
|
10
10
|
;
|
|
11
11
|
|
|
12
|
-
const promise = teams.createMembership('[TEAM_ID]',
|
|
12
|
+
const promise = teams.createMembership('[TEAM_ID]', [], 'https://example.com');
|
|
13
13
|
|
|
14
14
|
promise.then(function (response) {
|
|
15
15
|
console.log(response); // Success
|
|
@@ -9,7 +9,7 @@ client
|
|
|
9
9
|
.setProject('5df5acd0d48c2') // Your project ID
|
|
10
10
|
;
|
|
11
11
|
|
|
12
|
-
const promise = users.updatePassword('[USER_ID]', '
|
|
12
|
+
const promise = users.updatePassword('[USER_ID]', '');
|
|
13
13
|
|
|
14
14
|
promise.then(function (response) {
|
|
15
15
|
console.log(response); // Success
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@appwrite.io/console",
|
|
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": "0.0.
|
|
5
|
+
"version": "0.0.2-preview-0.0",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "dist/cjs/sdk.js",
|
|
8
8
|
"exports": {
|
package/src/client.ts
CHANGED
package/src/models.ts
CHANGED
|
@@ -1720,6 +1720,14 @@ export namespace Models {
|
|
|
1720
1720
|
* Max sessions allowed per user. 100 maximum.
|
|
1721
1721
|
*/
|
|
1722
1722
|
authSessionsLimit: number;
|
|
1723
|
+
/**
|
|
1724
|
+
* Max allowed passwords in the history list per user. Max passwords limit allowed in history is 20. Use 0 for disabling password history.
|
|
1725
|
+
*/
|
|
1726
|
+
authPasswordHistory: number;
|
|
1727
|
+
/**
|
|
1728
|
+
* Whether or not to check user's password against most commonly used passwords.
|
|
1729
|
+
*/
|
|
1730
|
+
authPasswordDictionary: boolean;
|
|
1723
1731
|
/**
|
|
1724
1732
|
* List of Providers.
|
|
1725
1733
|
*/
|
package/src/services/projects.ts
CHANGED
|
@@ -353,6 +353,68 @@ export class Projects extends Service {
|
|
|
353
353
|
}, payload);
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
+
/**
|
|
357
|
+
* Update authentication password disctionary status. Use this endpoint to enable or disable the dicitonary check for user password
|
|
358
|
+
*
|
|
359
|
+
*
|
|
360
|
+
* @param {string} projectId
|
|
361
|
+
* @param {boolean} enabled
|
|
362
|
+
* @throws {AppwriteException}
|
|
363
|
+
* @returns {Promise}
|
|
364
|
+
*/
|
|
365
|
+
async updateAuthPasswordDictionary(projectId: string, enabled: boolean): Promise<Models.Project> {
|
|
366
|
+
if (typeof projectId === 'undefined') {
|
|
367
|
+
throw new AppwriteException('Missing required parameter: "projectId"');
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (typeof enabled === 'undefined') {
|
|
371
|
+
throw new AppwriteException('Missing required parameter: "enabled"');
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
let path = '/projects/{projectId}/auth/password-dictionary'.replace('{projectId}', projectId);
|
|
375
|
+
let payload: Payload = {};
|
|
376
|
+
|
|
377
|
+
if (typeof enabled !== 'undefined') {
|
|
378
|
+
payload['enabled'] = enabled;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
382
|
+
return await this.client.call('patch', uri, {
|
|
383
|
+
'content-type': 'application/json',
|
|
384
|
+
}, payload);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Update authentication password history. Use this endpoint to set the number of password history to save and 0 to disable password history.
|
|
389
|
+
*
|
|
390
|
+
*
|
|
391
|
+
* @param {string} projectId
|
|
392
|
+
* @param {number} limit
|
|
393
|
+
* @throws {AppwriteException}
|
|
394
|
+
* @returns {Promise}
|
|
395
|
+
*/
|
|
396
|
+
async updateAuthPasswordHistory(projectId: string, limit: number): Promise<Models.Project> {
|
|
397
|
+
if (typeof projectId === 'undefined') {
|
|
398
|
+
throw new AppwriteException('Missing required parameter: "projectId"');
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if (typeof limit === 'undefined') {
|
|
402
|
+
throw new AppwriteException('Missing required parameter: "limit"');
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
let path = '/projects/{projectId}/auth/password-history'.replace('{projectId}', projectId);
|
|
406
|
+
let payload: Payload = {};
|
|
407
|
+
|
|
408
|
+
if (typeof limit !== 'undefined') {
|
|
409
|
+
payload['limit'] = limit;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
413
|
+
return await this.client.call('patch', uri, {
|
|
414
|
+
'content-type': 'application/json',
|
|
415
|
+
}, payload);
|
|
416
|
+
}
|
|
417
|
+
|
|
356
418
|
/**
|
|
357
419
|
* Update Project auth method status. Use this endpoint to enable or disable a given auth method for this project.
|
|
358
420
|
*
|
package/src/services/teams.ts
CHANGED
|
@@ -227,39 +227,43 @@ export class Teams extends Service {
|
|
|
227
227
|
/**
|
|
228
228
|
* Create Team Membership
|
|
229
229
|
*
|
|
230
|
-
* Invite a new member to join your team.
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
230
|
+
* Invite a new member to join your team. Provide an ID for existing users, or
|
|
231
|
+
* invite unregistered users using an email or phone number. If initiated from
|
|
232
|
+
* a Client SDK, Appwrite will send an email or sms with a link to join the
|
|
233
|
+
* team to the invited user, and an account will be created for them if one
|
|
234
|
+
* doesn't exist. If initiated from a Server SDK, the new member will be added
|
|
235
|
+
* automatically to the team.
|
|
235
236
|
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
237
|
+
* You only need to provide one of a user ID, email, or phone number. Appwrite
|
|
238
|
+
* will prioritize accepting the user ID > email > phone number if you provide
|
|
239
|
+
* more than one of these parameters.
|
|
240
|
+
*
|
|
241
|
+
* Use the `url` parameter to redirect the user from the invitation email to
|
|
242
|
+
* your app. After the user is redirected, use the [Update Team Membership
|
|
238
243
|
* Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow
|
|
239
244
|
* the user to accept the invitation to the team.
|
|
240
245
|
*
|
|
241
246
|
* Please note that to avoid a [Redirect
|
|
242
247
|
* Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
|
243
|
-
* the only
|
|
244
|
-
*
|
|
248
|
+
* Appwrite will accept the only redirect URLs under the domains you have
|
|
249
|
+
* added as a platform on the Appwrite Console.
|
|
250
|
+
*
|
|
245
251
|
*
|
|
246
252
|
* @param {string} teamId
|
|
247
|
-
* @param {string} email
|
|
248
253
|
* @param {string[]} roles
|
|
249
254
|
* @param {string} url
|
|
255
|
+
* @param {string} email
|
|
256
|
+
* @param {string} userId
|
|
257
|
+
* @param {string} phone
|
|
250
258
|
* @param {string} name
|
|
251
259
|
* @throws {AppwriteException}
|
|
252
260
|
* @returns {Promise}
|
|
253
261
|
*/
|
|
254
|
-
async createMembership(teamId: string,
|
|
262
|
+
async createMembership(teamId: string, roles: string[], url: string, email?: string, userId?: string, phone?: string, name?: string): Promise<Models.Membership> {
|
|
255
263
|
if (typeof teamId === 'undefined') {
|
|
256
264
|
throw new AppwriteException('Missing required parameter: "teamId"');
|
|
257
265
|
}
|
|
258
266
|
|
|
259
|
-
if (typeof email === 'undefined') {
|
|
260
|
-
throw new AppwriteException('Missing required parameter: "email"');
|
|
261
|
-
}
|
|
262
|
-
|
|
263
267
|
if (typeof roles === 'undefined') {
|
|
264
268
|
throw new AppwriteException('Missing required parameter: "roles"');
|
|
265
269
|
}
|
|
@@ -275,6 +279,14 @@ export class Teams extends Service {
|
|
|
275
279
|
payload['email'] = email;
|
|
276
280
|
}
|
|
277
281
|
|
|
282
|
+
if (typeof userId !== 'undefined') {
|
|
283
|
+
payload['userId'] = userId;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (typeof phone !== 'undefined') {
|
|
287
|
+
payload['phone'] = phone;
|
|
288
|
+
}
|
|
289
|
+
|
|
278
290
|
if (typeof roles !== 'undefined') {
|
|
279
291
|
payload['roles'] = roles;
|
|
280
292
|
}
|
|
@@ -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';
|