react-native-appwrite 0.2.2 → 0.3.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/workflows/publish.yml +13 -4
- package/CHANGELOG.md +1 -1
- package/LICENSE +1 -1
- package/README.md +22 -9
- package/dist/cjs/sdk.js +1193 -269
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +1193 -270
- package/dist/esm/sdk.js.map +1 -1
- package/docs/examples/account/create-anonymous-session.md +6 -13
- package/docs/examples/account/create-email-password-session.md +14 -0
- package/docs/examples/account/create-email-token.md +15 -0
- package/docs/examples/account/create-j-w-t.md +6 -13
- package/docs/examples/account/create-magic-u-r-l-token.md +16 -0
- package/docs/examples/account/create-mfa-authenticator.md +13 -0
- package/docs/examples/account/create-mfa-challenge.md +13 -0
- package/docs/examples/account/create-mfa-recovery-codes.md +11 -0
- package/docs/examples/account/create-o-auth2session.md +10 -9
- package/docs/examples/account/create-o-auth2token.md +15 -0
- package/docs/examples/account/create-phone-token.md +14 -0
- package/docs/examples/account/create-phone-verification.md +6 -13
- package/docs/examples/account/create-push-target.md +15 -0
- package/docs/examples/account/create-recovery.md +9 -13
- package/docs/examples/account/create-session.md +14 -0
- package/docs/examples/account/create-verification.md +8 -13
- package/docs/examples/account/create.md +11 -13
- package/docs/examples/account/delete-identity.md +8 -13
- package/docs/examples/account/delete-mfa-authenticator.md +14 -0
- package/docs/examples/account/delete-push-target.md +13 -0
- package/docs/examples/account/delete-session.md +8 -13
- package/docs/examples/account/delete-sessions.md +6 -13
- package/docs/examples/account/get-mfa-recovery-codes.md +11 -0
- package/docs/examples/account/get-prefs.md +6 -13
- package/docs/examples/account/get-session.md +8 -13
- package/docs/examples/account/get.md +6 -13
- package/docs/examples/account/list-identities.md +8 -13
- package/docs/examples/account/list-logs.md +8 -13
- package/docs/examples/account/list-mfa-factors.md +11 -0
- package/docs/examples/account/list-sessions.md +6 -13
- package/docs/examples/account/update-email.md +9 -13
- package/docs/examples/account/update-m-f-a.md +13 -0
- package/docs/examples/account/update-magic-u-r-l-session.md +9 -13
- package/docs/examples/account/update-mfa-authenticator.md +14 -0
- package/docs/examples/account/update-mfa-challenge.md +14 -0
- package/docs/examples/account/update-mfa-recovery-codes.md +11 -0
- package/docs/examples/account/update-name.md +8 -13
- package/docs/examples/account/update-password.md +9 -13
- package/docs/examples/account/update-phone-session.md +9 -13
- package/docs/examples/account/update-phone-verification.md +9 -13
- package/docs/examples/account/update-phone.md +9 -13
- package/docs/examples/account/update-prefs.md +8 -13
- package/docs/examples/account/update-push-target.md +14 -0
- package/docs/examples/account/update-recovery.md +10 -13
- package/docs/examples/account/update-session.md +8 -13
- package/docs/examples/account/update-status.md +6 -13
- package/docs/examples/account/update-verification.md +9 -13
- package/docs/examples/avatars/get-browser.md +11 -9
- package/docs/examples/avatars/get-credit-card.md +11 -9
- package/docs/examples/avatars/get-favicon.md +8 -9
- package/docs/examples/avatars/get-flag.md +11 -9
- package/docs/examples/avatars/get-image.md +10 -9
- package/docs/examples/avatars/get-initials.md +11 -9
- package/docs/examples/avatars/get-q-r.md +11 -9
- package/docs/examples/databases/create-document.md +12 -13
- package/docs/examples/databases/delete-document.md +10 -13
- package/docs/examples/databases/get-document.md +11 -13
- package/docs/examples/databases/list-documents.md +10 -13
- package/docs/examples/databases/update-document.md +12 -13
- package/docs/examples/functions/create-execution.md +13 -13
- package/docs/examples/functions/get-execution.md +9 -13
- package/docs/examples/functions/list-executions.md +10 -13
- package/docs/examples/graphql/mutation.md +8 -13
- package/docs/examples/graphql/query.md +8 -13
- package/docs/examples/locale/get.md +6 -13
- package/docs/examples/locale/list-codes.md +6 -13
- package/docs/examples/locale/list-continents.md +6 -13
- package/docs/examples/locale/list-countries-e-u.md +6 -13
- package/docs/examples/locale/list-countries-phones.md +6 -13
- package/docs/examples/locale/list-countries.md +6 -13
- package/docs/examples/locale/list-currencies.md +6 -13
- package/docs/examples/locale/list-languages.md +6 -13
- package/docs/examples/messaging/create-subscriber.md +15 -0
- package/docs/examples/messaging/delete-subscriber.md +14 -0
- package/docs/examples/storage/create-file.md +11 -13
- package/docs/examples/storage/delete-file.md +9 -13
- package/docs/examples/storage/get-file-download.md +9 -9
- package/docs/examples/storage/get-file-preview.md +20 -9
- package/docs/examples/storage/get-file-view.md +9 -9
- package/docs/examples/storage/get-file.md +9 -13
- package/docs/examples/storage/list-files.md +10 -13
- package/docs/examples/storage/update-file.md +11 -13
- package/docs/examples/teams/create-membership.md +14 -13
- package/docs/examples/teams/create.md +10 -13
- package/docs/examples/teams/delete-membership.md +9 -13
- package/docs/examples/teams/delete.md +8 -13
- package/docs/examples/teams/get-membership.md +9 -13
- package/docs/examples/teams/get-prefs.md +8 -13
- package/docs/examples/teams/get.md +8 -13
- package/docs/examples/teams/list-memberships.md +10 -13
- package/docs/examples/teams/list.md +9 -13
- package/docs/examples/teams/update-membership-status.md +11 -13
- package/docs/examples/teams/update-membership.md +10 -13
- package/docs/examples/teams/update-name.md +9 -13
- package/docs/examples/teams/update-prefs.md +9 -13
- package/package.json +1 -1
- package/src/client.ts +37 -11
- package/src/enums/authentication-factor.ts +6 -0
- package/src/enums/authenticator-type.ts +3 -0
- package/src/enums/browser.ts +16 -0
- package/src/enums/credit-card.ts +18 -0
- package/src/enums/execution-method.ts +8 -0
- package/src/enums/flag.ts +197 -0
- package/src/enums/image-format.ts +7 -0
- package/src/enums/image-gravity.ts +11 -0
- package/src/enums/o-auth-provider.ts +41 -0
- package/src/id.ts +23 -4
- package/src/index.ts +13 -2
- package/src/models.ts +174 -0
- package/src/query.ts +61 -34
- package/src/service.ts +4 -7
- package/src/services/account.ts +643 -119
- package/src/services/avatars.ts +12 -6
- package/src/services/databases.ts +7 -4
- package/src/services/functions.ts +6 -2
- package/src/services/graphql.ts +3 -0
- package/src/services/locale.ts +3 -0
- package/src/services/messaging.ts +84 -0
- package/src/services/storage.ts +12 -6
- package/src/services/teams.ts +3 -0
- package/docs/examples/account/create-email-session.md +0 -18
- package/docs/examples/account/create-magic-u-r-l-session.md +0 -18
- package/docs/examples/account/create-phone-session.md +0 -18
package/src/query.ts
CHANGED
|
@@ -1,74 +1,101 @@
|
|
|
1
1
|
type QueryTypesSingle = string | number | boolean;
|
|
2
|
-
export type QueryTypesList = string[] | number[] | boolean[];
|
|
2
|
+
export type QueryTypesList = string[] | number[] | boolean[] | Query[];
|
|
3
3
|
export type QueryTypes = QueryTypesSingle | QueryTypesList;
|
|
4
|
+
type AttributesTypes = string | string[];
|
|
4
5
|
|
|
5
6
|
export class Query {
|
|
7
|
+
method: string;
|
|
8
|
+
attribute: AttributesTypes | undefined;
|
|
9
|
+
values: QueryTypesList | undefined;
|
|
10
|
+
|
|
11
|
+
constructor(
|
|
12
|
+
method: string,
|
|
13
|
+
attribute?: AttributesTypes,
|
|
14
|
+
values?: QueryTypes
|
|
15
|
+
) {
|
|
16
|
+
this.method = method;
|
|
17
|
+
this.attribute = attribute;
|
|
18
|
+
|
|
19
|
+
if (values !== undefined) {
|
|
20
|
+
if (Array.isArray(values)) {
|
|
21
|
+
this.values = values;
|
|
22
|
+
} else {
|
|
23
|
+
this.values = [values] as QueryTypesList;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
toString(): string {
|
|
29
|
+
return JSON.stringify({
|
|
30
|
+
method: this.method,
|
|
31
|
+
attribute: this.attribute,
|
|
32
|
+
values: this.values,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
6
36
|
static equal = (attribute: string, value: QueryTypes): string =>
|
|
7
|
-
Query
|
|
37
|
+
new Query("equal", attribute, value).toString();
|
|
8
38
|
|
|
9
39
|
static notEqual = (attribute: string, value: QueryTypes): string =>
|
|
10
|
-
Query
|
|
40
|
+
new Query("notEqual", attribute, value).toString();
|
|
11
41
|
|
|
12
42
|
static lessThan = (attribute: string, value: QueryTypes): string =>
|
|
13
|
-
Query
|
|
43
|
+
new Query("lessThan", attribute, value).toString();
|
|
14
44
|
|
|
15
45
|
static lessThanEqual = (attribute: string, value: QueryTypes): string =>
|
|
16
|
-
Query
|
|
46
|
+
new Query("lessThanEqual", attribute, value).toString();
|
|
17
47
|
|
|
18
48
|
static greaterThan = (attribute: string, value: QueryTypes): string =>
|
|
19
|
-
Query
|
|
49
|
+
new Query("greaterThan", attribute, value).toString();
|
|
20
50
|
|
|
21
51
|
static greaterThanEqual = (attribute: string, value: QueryTypes): string =>
|
|
22
|
-
Query
|
|
52
|
+
new Query("greaterThanEqual", attribute, value).toString();
|
|
23
53
|
|
|
24
54
|
static isNull = (attribute: string): string =>
|
|
25
|
-
|
|
55
|
+
new Query("isNull", attribute).toString();
|
|
26
56
|
|
|
27
57
|
static isNotNull = (attribute: string): string =>
|
|
28
|
-
|
|
58
|
+
new Query("isNotNull", attribute).toString();
|
|
29
59
|
|
|
30
|
-
static between = (attribute: string, start: string|number, end: string|number)
|
|
31
|
-
|
|
60
|
+
static between = (attribute: string, start: string | number, end: string | number) =>
|
|
61
|
+
new Query("between", attribute, [start, end] as QueryTypesList).toString();
|
|
32
62
|
|
|
33
63
|
static startsWith = (attribute: string, value: string): string =>
|
|
34
|
-
Query
|
|
64
|
+
new Query("startsWith", attribute, value).toString();
|
|
35
65
|
|
|
36
66
|
static endsWith = (attribute: string, value: string): string =>
|
|
37
|
-
Query
|
|
67
|
+
new Query("endsWith", attribute, value).toString();
|
|
38
68
|
|
|
39
69
|
static select = (attributes: string[]): string =>
|
|
40
|
-
|
|
70
|
+
new Query("select", undefined, attributes).toString();
|
|
41
71
|
|
|
42
72
|
static search = (attribute: string, value: string): string =>
|
|
43
|
-
Query
|
|
73
|
+
new Query("search", attribute, value).toString();
|
|
44
74
|
|
|
45
75
|
static orderDesc = (attribute: string): string =>
|
|
46
|
-
|
|
76
|
+
new Query("orderDesc", attribute).toString();
|
|
47
77
|
|
|
48
78
|
static orderAsc = (attribute: string): string =>
|
|
49
|
-
|
|
79
|
+
new Query("orderAsc", attribute).toString();
|
|
50
80
|
|
|
51
81
|
static cursorAfter = (documentId: string): string =>
|
|
52
|
-
|
|
82
|
+
new Query("cursorAfter", undefined, documentId).toString();
|
|
53
83
|
|
|
54
84
|
static cursorBefore = (documentId: string): string =>
|
|
55
|
-
|
|
85
|
+
new Query("cursorBefore", undefined, documentId).toString();
|
|
56
86
|
|
|
57
87
|
static limit = (limit: number): string =>
|
|
58
|
-
|
|
88
|
+
new Query("limit", undefined, limit).toString();
|
|
59
89
|
|
|
60
90
|
static offset = (offset: number): string =>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
? `"${value}"`
|
|
73
|
-
: `${value}`;
|
|
74
|
-
}
|
|
91
|
+
new Query("offset", undefined, offset).toString();
|
|
92
|
+
|
|
93
|
+
static contains = (attribute: string, value: string | string[]): string =>
|
|
94
|
+
new Query("contains", attribute, value).toString();
|
|
95
|
+
|
|
96
|
+
static or = (queries: string[]) =>
|
|
97
|
+
new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString();
|
|
98
|
+
|
|
99
|
+
static and = (queries: string[]) =>
|
|
100
|
+
new Query("and", undefined, queries.map((query) => JSON.parse(query))).toString();
|
|
101
|
+
}
|
package/src/service.ts
CHANGED
|
@@ -13,14 +13,11 @@ export class Service {
|
|
|
13
13
|
static flatten(data: Payload, prefix = ''): Payload {
|
|
14
14
|
let output: Payload = {};
|
|
15
15
|
|
|
16
|
-
for (const key
|
|
17
|
-
let
|
|
18
|
-
let finalKey = prefix ? `${prefix}[${key}]` : key;
|
|
19
|
-
|
|
16
|
+
for (const [key, value] of Object.entries(data)) {
|
|
17
|
+
let finalKey = prefix ? prefix + '[' + key +']' : key;
|
|
20
18
|
if (Array.isArray(value)) {
|
|
21
|
-
output =
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
19
|
+
output = { ...output, ...Service.flatten(value, finalKey) };
|
|
20
|
+
} else {
|
|
24
21
|
output[finalKey] = value;
|
|
25
22
|
}
|
|
26
23
|
}
|