react-native-appwrite 0.1.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/.github/ISSUE_TEMPLATE/bug.yaml +82 -0
- package/.github/ISSUE_TEMPLATE/documentation.yaml +32 -0
- package/.github/ISSUE_TEMPLATE/feature.yaml +40 -0
- package/.github/workflows/publish.yml +33 -0
- package/.gitpod.yml +10 -0
- package/CHANGELOG.md +1 -0
- package/LICENSE +12 -0
- package/README.md +111 -0
- package/dist/cjs/sdk.js +3127 -0
- package/dist/cjs/sdk.js.map +1 -0
- package/dist/esm/sdk.js +3108 -0
- package/dist/esm/sdk.js.map +1 -0
- package/dist/iife/sdk.js +3126 -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-identity.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-identities.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-document.md +18 -0
- package/docs/examples/databases/delete-document.md +18 -0
- package/docs/examples/databases/get-document.md +18 -0
- package/docs/examples/databases/list-documents.md +18 -0
- package/docs/examples/databases/update-document.md +18 -0
- package/docs/examples/functions/create-execution.md +18 -0
- package/docs/examples/functions/get-execution.md +18 -0
- package/docs/examples/functions/list-executions.md +18 -0
- package/docs/examples/graphql/mutation.md +18 -0
- package/docs/examples/graphql/query.md +18 -0
- package/docs/examples/locale/get.md +18 -0
- package/docs/examples/locale/list-codes.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/storage/create-file.md +18 -0
- package/docs/examples/storage/delete-file.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/list-files.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-prefs.md +18 -0
- package/docs/examples/teams/get.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-status.md +18 -0
- package/docs/examples/teams/update-membership.md +18 -0
- package/docs/examples/teams/update-name.md +18 -0
- package/docs/examples/teams/update-prefs.md +18 -0
- package/package.json +47 -0
- package/rollup.config.js +31 -0
- package/src/client.ts +437 -0
- package/src/id.ts +9 -0
- package/src/index.ts +14 -0
- package/src/models.ts +1021 -0
- package/src/permission.ts +22 -0
- package/src/query.ts +74 -0
- package/src/role.ts +100 -0
- package/src/service.ts +30 -0
- package/src/services/account.ts +1066 -0
- package/src/services/avatars.ts +352 -0
- package/src/services/databases.ts +216 -0
- package/src/services/functions.ts +125 -0
- package/src/services/graphql.ts +68 -0
- package/src/services/locale.ts +169 -0
- package/src/services/storage.ts +411 -0
- package/src/services/teams.ts +484 -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,74 @@
|
|
|
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 isNull = (attribute: string): string =>
|
|
25
|
+
`isNull("${attribute}")`;
|
|
26
|
+
|
|
27
|
+
static isNotNull = (attribute: string): string =>
|
|
28
|
+
`isNotNull("${attribute}")`;
|
|
29
|
+
|
|
30
|
+
static between = (attribute: string, start: string|number, end: string|number): string =>
|
|
31
|
+
`between("${attribute}", ${Query.parseValues(start)}, ${Query.parseValues(end)})`;
|
|
32
|
+
|
|
33
|
+
static startsWith = (attribute: string, value: string): string =>
|
|
34
|
+
Query.addQuery(attribute, "startsWith", value);
|
|
35
|
+
|
|
36
|
+
static endsWith = (attribute: string, value: string): string =>
|
|
37
|
+
Query.addQuery(attribute, "endsWith", value);
|
|
38
|
+
|
|
39
|
+
static select = (attributes: string[]): string =>
|
|
40
|
+
`select([${attributes.map((attr: string) => `"${attr}"`).join(",")}])`;
|
|
41
|
+
|
|
42
|
+
static search = (attribute: string, value: string): string =>
|
|
43
|
+
Query.addQuery(attribute, "search", value);
|
|
44
|
+
|
|
45
|
+
static orderDesc = (attribute: string): string =>
|
|
46
|
+
`orderDesc("${attribute}")`;
|
|
47
|
+
|
|
48
|
+
static orderAsc = (attribute: string): string =>
|
|
49
|
+
`orderAsc("${attribute}")`;
|
|
50
|
+
|
|
51
|
+
static cursorAfter = (documentId: string): string =>
|
|
52
|
+
`cursorAfter("${documentId}")`;
|
|
53
|
+
|
|
54
|
+
static cursorBefore = (documentId: string): string =>
|
|
55
|
+
`cursorBefore("${documentId}")`;
|
|
56
|
+
|
|
57
|
+
static limit = (limit: number): string =>
|
|
58
|
+
`limit(${limit})`;
|
|
59
|
+
|
|
60
|
+
static offset = (offset: number): string =>
|
|
61
|
+
`offset(${offset})`;
|
|
62
|
+
|
|
63
|
+
private static addQuery = (attribute: string, method: string, value: QueryTypes): string =>
|
|
64
|
+
value instanceof Array
|
|
65
|
+
? `${method}("${attribute}", [${value
|
|
66
|
+
.map((v: QueryTypesSingle) => Query.parseValues(v))
|
|
67
|
+
.join(",")}])`
|
|
68
|
+
: `${method}("${attribute}", [${Query.parseValues(value)}])`;
|
|
69
|
+
|
|
70
|
+
private static parseValues = (value: QueryTypes): string =>
|
|
71
|
+
typeof value === "string" || value instanceof String
|
|
72
|
+
? `"${value}"`
|
|
73
|
+
: `${value}`;
|
|
74
|
+
}
|
package/src/role.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper class to generate role strings for `Permission`.
|
|
3
|
+
*/
|
|
4
|
+
export class Role {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Grants access to anyone.
|
|
8
|
+
*
|
|
9
|
+
* This includes authenticated and unauthenticated users.
|
|
10
|
+
*
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
public static any(): string {
|
|
14
|
+
return 'any'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Grants access to a specific user by user ID.
|
|
19
|
+
*
|
|
20
|
+
* You can optionally pass verified or unverified for
|
|
21
|
+
* `status` to target specific types of users.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} id
|
|
24
|
+
* @param {string} status
|
|
25
|
+
* @returns {string}
|
|
26
|
+
*/
|
|
27
|
+
public static user(id: string, status: string = ''): string {
|
|
28
|
+
if (status === '') {
|
|
29
|
+
return `user:${id}`
|
|
30
|
+
}
|
|
31
|
+
return `user:${id}/${status}`
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Grants access to any authenticated or anonymous user.
|
|
36
|
+
*
|
|
37
|
+
* You can optionally pass verified or unverified for
|
|
38
|
+
* `status` to target specific types of users.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} status
|
|
41
|
+
* @returns {string}
|
|
42
|
+
*/
|
|
43
|
+
public static users(status: string = ''): string {
|
|
44
|
+
if (status === '') {
|
|
45
|
+
return 'users'
|
|
46
|
+
}
|
|
47
|
+
return `users/${status}`
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Grants access to any guest user without a session.
|
|
52
|
+
*
|
|
53
|
+
* Authenticated users don't have access to this role.
|
|
54
|
+
*
|
|
55
|
+
* @returns {string}
|
|
56
|
+
*/
|
|
57
|
+
public static guests(): string {
|
|
58
|
+
return 'guests'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Grants access to a team by team ID.
|
|
63
|
+
*
|
|
64
|
+
* You can optionally pass a role for `role` to target
|
|
65
|
+
* team members with the specified role.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} id
|
|
68
|
+
* @param {string} role
|
|
69
|
+
* @returns {string}
|
|
70
|
+
*/
|
|
71
|
+
public static team(id: string, role: string = ''): string {
|
|
72
|
+
if (role === '') {
|
|
73
|
+
return `team:${id}`
|
|
74
|
+
}
|
|
75
|
+
return `team:${id}/${role}`
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Grants access to a specific member of a team.
|
|
80
|
+
*
|
|
81
|
+
* When the member is removed from the team, they will
|
|
82
|
+
* no longer have access.
|
|
83
|
+
*
|
|
84
|
+
* @param {string} id
|
|
85
|
+
* @returns {string}
|
|
86
|
+
*/
|
|
87
|
+
public static member(id: string): string {
|
|
88
|
+
return `member:${id}`
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Grants access to a user with the specified label.
|
|
93
|
+
*
|
|
94
|
+
* @param {string} name
|
|
95
|
+
* @returns {string}
|
|
96
|
+
*/
|
|
97
|
+
public static label(name: string): string {
|
|
98
|
+
return `label:${name}`
|
|
99
|
+
}
|
|
100
|
+
}
|
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
|
+
}
|