@appwrite.io/console 0.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/.github/workflows/publish.yml +18 -0
- package/CHANGELOG.md +1 -0
- package/LICENSE +12 -0
- package/README.md +111 -0
- package/dist/cjs/package.json +3 -0
- package/dist/esm/package.json +3 -0
- package/docs/examples/account/create-anonymous-session.md +18 -0
- package/docs/examples/account/create-email-session.md +18 -0
- package/docs/examples/account/create-j-w-t.md +18 -0
- package/docs/examples/account/create-magic-u-r-l-session.md +18 -0
- package/docs/examples/account/create-o-auth2session.md +14 -0
- package/docs/examples/account/create-phone-session.md +18 -0
- package/docs/examples/account/create-phone-verification.md +18 -0
- package/docs/examples/account/create-recovery.md +18 -0
- package/docs/examples/account/create-verification.md +18 -0
- package/docs/examples/account/create.md +18 -0
- package/docs/examples/account/delete-session.md +18 -0
- package/docs/examples/account/delete-sessions.md +18 -0
- package/docs/examples/account/get-prefs.md +18 -0
- package/docs/examples/account/get-session.md +18 -0
- package/docs/examples/account/get.md +18 -0
- package/docs/examples/account/list-logs.md +18 -0
- package/docs/examples/account/list-sessions.md +18 -0
- package/docs/examples/account/update-email.md +18 -0
- package/docs/examples/account/update-magic-u-r-l-session.md +18 -0
- package/docs/examples/account/update-name.md +18 -0
- package/docs/examples/account/update-password.md +18 -0
- package/docs/examples/account/update-phone-session.md +18 -0
- package/docs/examples/account/update-phone-verification.md +18 -0
- package/docs/examples/account/update-phone.md +18 -0
- package/docs/examples/account/update-prefs.md +18 -0
- package/docs/examples/account/update-recovery.md +18 -0
- package/docs/examples/account/update-session.md +18 -0
- package/docs/examples/account/update-status.md +18 -0
- package/docs/examples/account/update-verification.md +18 -0
- package/docs/examples/avatars/get-browser.md +14 -0
- package/docs/examples/avatars/get-credit-card.md +14 -0
- package/docs/examples/avatars/get-favicon.md +14 -0
- package/docs/examples/avatars/get-flag.md +14 -0
- package/docs/examples/avatars/get-image.md +14 -0
- package/docs/examples/avatars/get-initials.md +14 -0
- package/docs/examples/avatars/get-q-r.md +14 -0
- package/docs/examples/databases/create-boolean-attribute.md +18 -0
- package/docs/examples/databases/create-collection.md +18 -0
- package/docs/examples/databases/create-datetime-attribute.md +18 -0
- package/docs/examples/databases/create-document.md +18 -0
- package/docs/examples/databases/create-email-attribute.md +18 -0
- package/docs/examples/databases/create-enum-attribute.md +18 -0
- package/docs/examples/databases/create-float-attribute.md +18 -0
- package/docs/examples/databases/create-index.md +18 -0
- package/docs/examples/databases/create-integer-attribute.md +18 -0
- package/docs/examples/databases/create-ip-attribute.md +18 -0
- package/docs/examples/databases/create-string-attribute.md +18 -0
- package/docs/examples/databases/create-url-attribute.md +18 -0
- package/docs/examples/databases/create.md +18 -0
- package/docs/examples/databases/delete-attribute.md +18 -0
- package/docs/examples/databases/delete-collection.md +18 -0
- package/docs/examples/databases/delete-document.md +18 -0
- package/docs/examples/databases/delete-index.md +18 -0
- package/docs/examples/databases/delete.md +18 -0
- package/docs/examples/databases/get-attribute.md +18 -0
- package/docs/examples/databases/get-collection-usage.md +18 -0
- package/docs/examples/databases/get-collection.md +18 -0
- package/docs/examples/databases/get-database-usage.md +18 -0
- package/docs/examples/databases/get-document.md +18 -0
- package/docs/examples/databases/get-index.md +18 -0
- package/docs/examples/databases/get-usage.md +18 -0
- package/docs/examples/databases/get.md +18 -0
- package/docs/examples/databases/list-attributes.md +18 -0
- package/docs/examples/databases/list-collection-logs.md +18 -0
- package/docs/examples/databases/list-collections.md +18 -0
- package/docs/examples/databases/list-document-logs.md +18 -0
- package/docs/examples/databases/list-documents.md +18 -0
- package/docs/examples/databases/list-indexes.md +18 -0
- package/docs/examples/databases/list-logs.md +18 -0
- package/docs/examples/databases/list.md +18 -0
- package/docs/examples/databases/update-collection.md +18 -0
- package/docs/examples/databases/update-document.md +18 -0
- package/docs/examples/databases/update.md +18 -0
- package/docs/examples/functions/create-build.md +18 -0
- package/docs/examples/functions/create-deployment.md +18 -0
- package/docs/examples/functions/create-execution.md +18 -0
- package/docs/examples/functions/create-variable.md +18 -0
- package/docs/examples/functions/create.md +18 -0
- package/docs/examples/functions/delete-deployment.md +18 -0
- package/docs/examples/functions/delete-variable.md +18 -0
- package/docs/examples/functions/delete.md +18 -0
- package/docs/examples/functions/get-deployment.md +18 -0
- package/docs/examples/functions/get-execution.md +18 -0
- package/docs/examples/functions/get-function-usage.md +18 -0
- package/docs/examples/functions/get-usage.md +18 -0
- package/docs/examples/functions/get-variable.md +18 -0
- package/docs/examples/functions/get.md +18 -0
- package/docs/examples/functions/list-deployments.md +18 -0
- package/docs/examples/functions/list-executions.md +18 -0
- package/docs/examples/functions/list-runtimes.md +18 -0
- package/docs/examples/functions/list-variables.md +18 -0
- package/docs/examples/functions/list.md +18 -0
- package/docs/examples/functions/update-deployment.md +18 -0
- package/docs/examples/functions/update-variable.md +18 -0
- package/docs/examples/functions/update.md +18 -0
- package/docs/examples/graphql/mutation.md +18 -0
- package/docs/examples/graphql/query.md +18 -0
- package/docs/examples/health/get-antivirus.md +18 -0
- package/docs/examples/health/get-cache.md +18 -0
- package/docs/examples/health/get-d-b.md +18 -0
- package/docs/examples/health/get-queue-certificates.md +18 -0
- package/docs/examples/health/get-queue-functions.md +18 -0
- package/docs/examples/health/get-queue-logs.md +18 -0
- package/docs/examples/health/get-queue-webhooks.md +18 -0
- package/docs/examples/health/get-storage-local.md +18 -0
- package/docs/examples/health/get-time.md +18 -0
- package/docs/examples/health/get.md +18 -0
- package/docs/examples/locale/get.md +18 -0
- package/docs/examples/locale/list-continents.md +18 -0
- package/docs/examples/locale/list-countries-e-u.md +18 -0
- package/docs/examples/locale/list-countries-phones.md +18 -0
- package/docs/examples/locale/list-countries.md +18 -0
- package/docs/examples/locale/list-currencies.md +18 -0
- package/docs/examples/locale/list-languages.md +18 -0
- package/docs/examples/projects/create-domain.md +18 -0
- package/docs/examples/projects/create-key.md +18 -0
- package/docs/examples/projects/create-platform.md +18 -0
- package/docs/examples/projects/create-webhook.md +18 -0
- package/docs/examples/projects/create.md +18 -0
- package/docs/examples/projects/delete-domain.md +18 -0
- package/docs/examples/projects/delete-key.md +18 -0
- package/docs/examples/projects/delete-platform.md +18 -0
- package/docs/examples/projects/delete-webhook.md +18 -0
- package/docs/examples/projects/delete.md +18 -0
- package/docs/examples/projects/get-domain.md +18 -0
- package/docs/examples/projects/get-key.md +18 -0
- package/docs/examples/projects/get-platform.md +18 -0
- package/docs/examples/projects/get-usage.md +18 -0
- package/docs/examples/projects/get-webhook.md +18 -0
- package/docs/examples/projects/get.md +18 -0
- package/docs/examples/projects/list-domains.md +18 -0
- package/docs/examples/projects/list-keys.md +18 -0
- package/docs/examples/projects/list-platforms.md +18 -0
- package/docs/examples/projects/list-webhooks.md +18 -0
- package/docs/examples/projects/list.md +18 -0
- package/docs/examples/projects/update-auth-duration.md +18 -0
- package/docs/examples/projects/update-auth-limit.md +18 -0
- package/docs/examples/projects/update-auth-sessions-limit.md +18 -0
- package/docs/examples/projects/update-auth-status.md +18 -0
- package/docs/examples/projects/update-domain-verification.md +18 -0
- package/docs/examples/projects/update-key.md +18 -0
- package/docs/examples/projects/update-o-auth2.md +18 -0
- package/docs/examples/projects/update-platform.md +18 -0
- package/docs/examples/projects/update-service-status.md +18 -0
- package/docs/examples/projects/update-webhook-signature.md +18 -0
- package/docs/examples/projects/update-webhook.md +18 -0
- package/docs/examples/projects/update.md +18 -0
- package/docs/examples/storage/create-bucket.md +18 -0
- package/docs/examples/storage/create-file.md +18 -0
- package/docs/examples/storage/delete-bucket.md +18 -0
- package/docs/examples/storage/delete-file.md +18 -0
- package/docs/examples/storage/get-bucket-usage.md +18 -0
- package/docs/examples/storage/get-bucket.md +18 -0
- package/docs/examples/storage/get-file-download.md +14 -0
- package/docs/examples/storage/get-file-preview.md +14 -0
- package/docs/examples/storage/get-file-view.md +14 -0
- package/docs/examples/storage/get-file.md +18 -0
- package/docs/examples/storage/get-usage.md +18 -0
- package/docs/examples/storage/list-buckets.md +18 -0
- package/docs/examples/storage/list-files.md +18 -0
- package/docs/examples/storage/update-bucket.md +18 -0
- package/docs/examples/storage/update-file.md +18 -0
- package/docs/examples/teams/create-membership.md +18 -0
- package/docs/examples/teams/create.md +18 -0
- package/docs/examples/teams/delete-membership.md +18 -0
- package/docs/examples/teams/delete.md +18 -0
- package/docs/examples/teams/get-membership.md +18 -0
- package/docs/examples/teams/get.md +18 -0
- package/docs/examples/teams/list-logs.md +18 -0
- package/docs/examples/teams/list-memberships.md +18 -0
- package/docs/examples/teams/list.md +18 -0
- package/docs/examples/teams/update-membership-roles.md +18 -0
- package/docs/examples/teams/update-membership-status.md +18 -0
- package/docs/examples/teams/update.md +18 -0
- package/docs/examples/users/create-argon2user.md +18 -0
- package/docs/examples/users/create-bcrypt-user.md +18 -0
- package/docs/examples/users/create-m-d5user.md +18 -0
- package/docs/examples/users/create-p-h-pass-user.md +18 -0
- package/docs/examples/users/create-s-h-a-user.md +18 -0
- package/docs/examples/users/create-scrypt-modified-user.md +18 -0
- package/docs/examples/users/create-scrypt-user.md +18 -0
- package/docs/examples/users/create.md +18 -0
- package/docs/examples/users/delete-session.md +18 -0
- package/docs/examples/users/delete-sessions.md +18 -0
- package/docs/examples/users/delete.md +18 -0
- package/docs/examples/users/get-prefs.md +18 -0
- package/docs/examples/users/get-usage.md +18 -0
- package/docs/examples/users/get.md +18 -0
- package/docs/examples/users/list-logs.md +18 -0
- package/docs/examples/users/list-memberships.md +18 -0
- package/docs/examples/users/list-sessions.md +18 -0
- package/docs/examples/users/list.md +18 -0
- package/docs/examples/users/update-email-verification.md +18 -0
- package/docs/examples/users/update-email.md +18 -0
- package/docs/examples/users/update-name.md +18 -0
- package/docs/examples/users/update-password.md +18 -0
- package/docs/examples/users/update-phone-verification.md +18 -0
- package/docs/examples/users/update-phone.md +18 -0
- package/docs/examples/users/update-prefs.md +18 -0
- package/docs/examples/users/update-status.md +18 -0
- package/package.json +40 -0
- package/rollup.config.js +31 -0
- package/src/client.ts +472 -0
- package/src/id.ts +9 -0
- package/src/index.ts +17 -0
- package/src/models.ts +2540 -0
- package/src/permission.ts +22 -0
- package/src/query.ts +56 -0
- package/src/role.ts +34 -0
- package/src/service.ts +30 -0
- package/src/services/account.ts +1009 -0
- package/src/services/avatars.ts +351 -0
- package/src/services/databases.ts +1525 -0
- package/src/services/functions.ts +814 -0
- package/src/services/graphql.ts +68 -0
- package/src/services/health.ts +202 -0
- package/src/services/locale.ts +150 -0
- package/src/services/projects.ts +1235 -0
- package/src/services/storage.ts +691 -0
- package/src/services/teams.ts +445 -0
- package/src/services/users.ts +1020 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class Permission {
|
|
2
|
+
|
|
3
|
+
static read = (role: string): string => {
|
|
4
|
+
return `read("${role}")`
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
static write = (role: string): string => {
|
|
8
|
+
return `write("${role}")`
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static create = (role: string): string => {
|
|
12
|
+
return `create("${role}")`
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static update = (role: string): string => {
|
|
16
|
+
return `update("${role}")`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static delete = (role: string): string => {
|
|
20
|
+
return `delete("${role}")`
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/query.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
type QueryTypesSingle = string | number | boolean;
|
|
2
|
+
export type QueryTypesList = string[] | number[] | boolean[];
|
|
3
|
+
export type QueryTypes = QueryTypesSingle | QueryTypesList;
|
|
4
|
+
|
|
5
|
+
export class Query {
|
|
6
|
+
static equal = (attribute: string, value: QueryTypes): string =>
|
|
7
|
+
Query.addQuery(attribute, "equal", value);
|
|
8
|
+
|
|
9
|
+
static notEqual = (attribute: string, value: QueryTypes): string =>
|
|
10
|
+
Query.addQuery(attribute, "notEqual", value);
|
|
11
|
+
|
|
12
|
+
static lessThan = (attribute: string, value: QueryTypes): string =>
|
|
13
|
+
Query.addQuery(attribute, "lessThan", value);
|
|
14
|
+
|
|
15
|
+
static lessThanEqual = (attribute: string, value: QueryTypes): string =>
|
|
16
|
+
Query.addQuery(attribute, "lessThanEqual", value);
|
|
17
|
+
|
|
18
|
+
static greaterThan = (attribute: string, value: QueryTypes): string =>
|
|
19
|
+
Query.addQuery(attribute, "greaterThan", value);
|
|
20
|
+
|
|
21
|
+
static greaterThanEqual = (attribute: string, value: QueryTypes): string =>
|
|
22
|
+
Query.addQuery(attribute, "greaterThanEqual", value);
|
|
23
|
+
|
|
24
|
+
static search = (attribute: string, value: string): string =>
|
|
25
|
+
Query.addQuery(attribute, "search", value);
|
|
26
|
+
|
|
27
|
+
static orderDesc = (attribute: string): string =>
|
|
28
|
+
`orderDesc("${attribute}")`;
|
|
29
|
+
|
|
30
|
+
static orderAsc = (attribute: string): string =>
|
|
31
|
+
`orderAsc("${attribute}")`;
|
|
32
|
+
|
|
33
|
+
static cursorAfter = (documentId: string): string =>
|
|
34
|
+
`cursorAfter("${documentId}")`;
|
|
35
|
+
|
|
36
|
+
static cursorBefore = (documentId: string): string =>
|
|
37
|
+
`cursorBefore("${documentId}")`;
|
|
38
|
+
|
|
39
|
+
static limit = (limit: number): string =>
|
|
40
|
+
`limit(${limit})`;
|
|
41
|
+
|
|
42
|
+
static offset = (offset: number): string =>
|
|
43
|
+
`offset(${offset})`;
|
|
44
|
+
|
|
45
|
+
private static addQuery = (attribute: string, method: string, value: QueryTypes): string =>
|
|
46
|
+
value instanceof Array
|
|
47
|
+
? `${method}("${attribute}", [${value
|
|
48
|
+
.map((v: QueryTypesSingle) => Query.parseValues(v))
|
|
49
|
+
.join(",")}])`
|
|
50
|
+
: `${method}("${attribute}", [${Query.parseValues(value)}])`;
|
|
51
|
+
|
|
52
|
+
private static parseValues = (value: QueryTypes): string =>
|
|
53
|
+
typeof value === "string" || value instanceof String
|
|
54
|
+
? `"${value}"`
|
|
55
|
+
: `${value}`;
|
|
56
|
+
}
|
package/src/role.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export class Role {
|
|
2
|
+
public static any(): string {
|
|
3
|
+
return 'any'
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
public static user(id: string, status: string = ''): string {
|
|
7
|
+
if(status === '') {
|
|
8
|
+
return `user:${id}`
|
|
9
|
+
}
|
|
10
|
+
return `user:${id}/${status}`
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public static users(status: string = ''): string {
|
|
14
|
+
if(status === '') {
|
|
15
|
+
return 'users'
|
|
16
|
+
}
|
|
17
|
+
return `users/${status}`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public static guests(): string {
|
|
21
|
+
return 'guests'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public static team(id: string, role: string = ''): string {
|
|
25
|
+
if(role === '') {
|
|
26
|
+
return `team:${id}`
|
|
27
|
+
}
|
|
28
|
+
return `team:${id}/${role}`
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public static member(id: string): string {
|
|
32
|
+
return `member:${id}`
|
|
33
|
+
}
|
|
34
|
+
}
|
package/src/service.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Client } from './client';
|
|
2
|
+
import type { Payload } from './client';
|
|
3
|
+
|
|
4
|
+
export class Service {
|
|
5
|
+
static CHUNK_SIZE = 5*1024*1024; // 5MB
|
|
6
|
+
|
|
7
|
+
client: Client;
|
|
8
|
+
|
|
9
|
+
constructor(client: Client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static flatten(data: Payload, prefix = ''): Payload {
|
|
14
|
+
let output: Payload = {};
|
|
15
|
+
|
|
16
|
+
for (const key in data) {
|
|
17
|
+
let value = data[key];
|
|
18
|
+
let finalKey = prefix ? `${prefix}[${key}]` : key;
|
|
19
|
+
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
output = Object.assign(output, this.flatten(value, finalKey));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
output[finalKey] = value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return output;
|
|
29
|
+
}
|
|
30
|
+
}
|