react-native-appwrite 0.2.2 → 0.3.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 +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/types/client.d.ts +133 -0
- package/types/enums/authentication-factor.d.ts +6 -0
- package/types/enums/authenticator-type.d.ts +3 -0
- package/types/enums/browser.d.ts +16 -0
- package/types/enums/credit-card.d.ts +18 -0
- package/types/enums/execution-method.d.ts +8 -0
- package/types/enums/flag.d.ts +197 -0
- package/types/enums/image-format.d.ts +7 -0
- package/types/enums/image-gravity.d.ts +11 -0
- package/types/enums/o-auth-provider.d.ts +41 -0
- package/types/id.d.ts +5 -0
- package/types/index.d.ts +25 -0
- package/types/models.d.ts +1195 -0
- package/types/permission.d.ts +7 -0
- package/types/query.d.ts +34 -0
- package/types/role.d.ts +70 -0
- package/types/service.d.ts +8 -0
- package/types/services/account.d.ts +676 -0
- package/types/services/avatars.d.ts +149 -0
- package/types/services/databases.d.ts +77 -0
- package/types/services/functions.d.ts +49 -0
- package/types/services/graphql.d.ts +25 -0
- package/types/services/locale.d.ts +91 -0
- package/types/services/messaging.d.ts +29 -0
- package/types/services/storage.d.ts +147 -0
- package/types/services/teams.d.ts +197 -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
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Client, Storage } from "appwrite";
|
|
1
|
+
import { Client, Storage } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const storage = new Storage(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
;
|
|
11
|
-
|
|
12
|
-
const result = storage.getFileView('[BUCKET_ID]', '[FILE_ID]');
|
|
9
|
+
const result = storage.getFileView(
|
|
10
|
+
'<BUCKET_ID>', // bucketId
|
|
11
|
+
'<FILE_ID>' // fileId
|
|
12
|
+
);
|
|
13
13
|
|
|
14
|
-
console.log(result);
|
|
14
|
+
console.log(result);
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { Client, Storage } from "appwrite";
|
|
1
|
+
import { Client, Storage } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const storage = new Storage(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
;
|
|
11
|
-
|
|
12
|
-
const promise = storage.getFile('[BUCKET_ID]', '[FILE_ID]');
|
|
9
|
+
const result = await storage.getFile(
|
|
10
|
+
'<BUCKET_ID>', // bucketId
|
|
11
|
+
'<FILE_ID>' // fileId
|
|
12
|
+
);
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
14
|
+
console.log(response);
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { Client, Storage } from "appwrite";
|
|
1
|
+
import { Client, Storage } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const storage = new Storage(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const promise = storage.listFiles('[BUCKET_ID]');
|
|
9
|
+
const result = await storage.listFiles(
|
|
10
|
+
'<BUCKET_ID>', // bucketId
|
|
11
|
+
[], // queries (optional)
|
|
12
|
+
'<SEARCH>' // search (optional)
|
|
13
|
+
);
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
15
|
+
console.log(response);
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { Client, Storage } from "appwrite";
|
|
1
|
+
import { Client, Storage } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const storage = new Storage(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const result = await storage.updateFile(
|
|
10
|
+
'<BUCKET_ID>', // bucketId
|
|
11
|
+
'<FILE_ID>', // fileId
|
|
12
|
+
'<NAME>', // name (optional)
|
|
13
|
+
["read("any")"] // permissions (optional)
|
|
14
|
+
);
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
16
|
+
console.log(response);
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { Client, Teams } from "appwrite";
|
|
1
|
+
import { Client, Teams } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const teams = new Teams(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const result = await teams.createMembership(
|
|
10
|
+
'<TEAM_ID>', // teamId
|
|
11
|
+
[], // roles
|
|
12
|
+
'email@example.com', // email (optional)
|
|
13
|
+
'<USER_ID>', // userId (optional)
|
|
14
|
+
'+12065550100', // phone (optional)
|
|
15
|
+
'https://example.com', // url (optional)
|
|
16
|
+
'<NAME>' // name (optional)
|
|
17
|
+
);
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
19
|
+
console.log(response);
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { Client, Teams } from "appwrite";
|
|
1
|
+
import { Client, Teams } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const teams = new Teams(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const promise = teams.create('[TEAM_ID]', '[NAME]');
|
|
9
|
+
const result = await teams.create(
|
|
10
|
+
'<TEAM_ID>', // teamId
|
|
11
|
+
'<NAME>', // name
|
|
12
|
+
[] // roles (optional)
|
|
13
|
+
);
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
15
|
+
console.log(response);
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { Client, Teams } from "appwrite";
|
|
1
|
+
import { Client, Teams } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const teams = new Teams(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
;
|
|
11
|
-
|
|
12
|
-
const promise = teams.deleteMembership('[TEAM_ID]', '[MEMBERSHIP_ID]');
|
|
9
|
+
const result = await teams.deleteMembership(
|
|
10
|
+
'<TEAM_ID>', // teamId
|
|
11
|
+
'<MEMBERSHIP_ID>' // membershipId
|
|
12
|
+
);
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
14
|
+
console.log(response);
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import { Client, Teams } from "appwrite";
|
|
1
|
+
import { Client, Teams } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const teams = new Teams(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
;
|
|
11
|
-
|
|
12
|
-
const promise = teams.delete('[TEAM_ID]');
|
|
9
|
+
const result = await teams.delete(
|
|
10
|
+
'<TEAM_ID>' // teamId
|
|
11
|
+
);
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
13
|
+
console.log(response);
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { Client, Teams } from "appwrite";
|
|
1
|
+
import { Client, Teams } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const teams = new Teams(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
;
|
|
11
|
-
|
|
12
|
-
const promise = teams.getMembership('[TEAM_ID]', '[MEMBERSHIP_ID]');
|
|
9
|
+
const result = await teams.getMembership(
|
|
10
|
+
'<TEAM_ID>', // teamId
|
|
11
|
+
'<MEMBERSHIP_ID>' // membershipId
|
|
12
|
+
);
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
14
|
+
console.log(response);
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import { Client, Teams } from "appwrite";
|
|
1
|
+
import { Client, Teams } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const teams = new Teams(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
;
|
|
11
|
-
|
|
12
|
-
const promise = teams.getPrefs('[TEAM_ID]');
|
|
9
|
+
const result = await teams.getPrefs(
|
|
10
|
+
'<TEAM_ID>' // teamId
|
|
11
|
+
);
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
13
|
+
console.log(response);
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import { Client, Teams } from "appwrite";
|
|
1
|
+
import { Client, Teams } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const teams = new Teams(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
;
|
|
11
|
-
|
|
12
|
-
const promise = teams.get('[TEAM_ID]');
|
|
9
|
+
const result = await teams.get(
|
|
10
|
+
'<TEAM_ID>' // teamId
|
|
11
|
+
);
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
13
|
+
console.log(response);
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { Client, Teams } from "appwrite";
|
|
1
|
+
import { Client, Teams } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const teams = new Teams(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const promise = teams.listMemberships('[TEAM_ID]');
|
|
9
|
+
const result = await teams.listMemberships(
|
|
10
|
+
'<TEAM_ID>', // teamId
|
|
11
|
+
[], // queries (optional)
|
|
12
|
+
'<SEARCH>' // search (optional)
|
|
13
|
+
);
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
15
|
+
console.log(response);
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { Client, Teams } from "appwrite";
|
|
1
|
+
import { Client, Teams } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const teams = new Teams(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
;
|
|
11
|
-
|
|
12
|
-
const promise = teams.list();
|
|
9
|
+
const result = await teams.list(
|
|
10
|
+
[], // queries (optional)
|
|
11
|
+
'<SEARCH>' // search (optional)
|
|
12
|
+
);
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
14
|
+
console.log(response);
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { Client, Teams } from "appwrite";
|
|
1
|
+
import { Client, Teams } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const teams = new Teams(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const result = await teams.updateMembershipStatus(
|
|
10
|
+
'<TEAM_ID>', // teamId
|
|
11
|
+
'<MEMBERSHIP_ID>', // membershipId
|
|
12
|
+
'<USER_ID>', // userId
|
|
13
|
+
'<SECRET>' // secret
|
|
14
|
+
);
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
16
|
+
console.log(response);
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { Client, Teams } from "appwrite";
|
|
1
|
+
import { Client, Teams } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const teams = new Teams(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const promise = teams.updateMembership('[TEAM_ID]', '[MEMBERSHIP_ID]', []);
|
|
9
|
+
const result = await teams.updateMembership(
|
|
10
|
+
'<TEAM_ID>', // teamId
|
|
11
|
+
'<MEMBERSHIP_ID>', // membershipId
|
|
12
|
+
[] // roles
|
|
13
|
+
);
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
15
|
+
console.log(response);
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { Client, Teams } from "appwrite";
|
|
1
|
+
import { Client, Teams } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const teams = new Teams(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
;
|
|
11
|
-
|
|
12
|
-
const promise = teams.updateName('[TEAM_ID]', '[NAME]');
|
|
9
|
+
const result = await teams.updateName(
|
|
10
|
+
'<TEAM_ID>', // teamId
|
|
11
|
+
'<NAME>' // name
|
|
12
|
+
);
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
14
|
+
console.log(response);
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { Client, Teams } from "appwrite";
|
|
1
|
+
import { Client, Teams } from "react-native-appwrite";
|
|
2
2
|
|
|
3
|
-
const client = new Client()
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('5df5acd0d48c2'); // Your project ID
|
|
4
6
|
|
|
5
7
|
const teams = new Teams(client);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
;
|
|
11
|
-
|
|
12
|
-
const promise = teams.updatePrefs('[TEAM_ID]', {});
|
|
9
|
+
const result = await teams.updatePrefs(
|
|
10
|
+
'<TEAM_ID>', // teamId
|
|
11
|
+
{} // prefs
|
|
12
|
+
);
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
console.log(response); // Success
|
|
16
|
-
}, function (error) {
|
|
17
|
-
console.log(error); // Failure
|
|
18
|
-
});
|
|
14
|
+
console.log(response);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "react-native-appwrite",
|
|
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.
|
|
5
|
+
"version": "0.3.1",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "dist/cjs/sdk.js",
|
|
8
8
|
"exports": {
|
package/src/client.ts
CHANGED
|
@@ -91,19 +91,20 @@ class AppwriteException extends Error {
|
|
|
91
91
|
|
|
92
92
|
class Client {
|
|
93
93
|
config = {
|
|
94
|
-
endpoint: 'https://
|
|
94
|
+
endpoint: 'https://cloud.appwrite.io/v1',
|
|
95
95
|
endpointRealtime: '',
|
|
96
96
|
project: '',
|
|
97
97
|
jwt: '',
|
|
98
98
|
locale: '',
|
|
99
|
+
session: '',
|
|
99
100
|
platform: '',
|
|
100
101
|
};
|
|
101
102
|
headers: Headers = {
|
|
102
|
-
'x-sdk-name': '
|
|
103
|
+
'x-sdk-name': 'React Native',
|
|
103
104
|
'x-sdk-platform': 'client',
|
|
104
|
-
'x-sdk-language': '
|
|
105
|
-
'x-sdk-version': '
|
|
106
|
-
'X-Appwrite-Response-Format': '1.
|
|
105
|
+
'x-sdk-language': 'reactnative',
|
|
106
|
+
'x-sdk-version': '0.3.0',
|
|
107
|
+
'X-Appwrite-Response-Format': '1.5.0',
|
|
107
108
|
};
|
|
108
109
|
|
|
109
110
|
/**
|
|
@@ -192,6 +193,21 @@ class Client {
|
|
|
192
193
|
return this;
|
|
193
194
|
}
|
|
194
195
|
|
|
196
|
+
/**
|
|
197
|
+
* Set Session
|
|
198
|
+
*
|
|
199
|
+
* The user session to authenticate with
|
|
200
|
+
*
|
|
201
|
+
* @param value string
|
|
202
|
+
*
|
|
203
|
+
* @return {this}
|
|
204
|
+
*/
|
|
205
|
+
setSession(value: string): this {
|
|
206
|
+
this.headers['X-Appwrite-Session'] = value;
|
|
207
|
+
this.config.session = value;
|
|
208
|
+
return this;
|
|
209
|
+
}
|
|
210
|
+
|
|
195
211
|
|
|
196
212
|
private realtime: Realtime = {
|
|
197
213
|
socket: undefined,
|
|
@@ -222,7 +238,11 @@ class Client {
|
|
|
222
238
|
}
|
|
223
239
|
},
|
|
224
240
|
createSocket: () => {
|
|
225
|
-
if (this.realtime.channels.size < 1)
|
|
241
|
+
if (this.realtime.channels.size < 1) {
|
|
242
|
+
this.realtime.reconnect = false;
|
|
243
|
+
this.realtime.socket?.close();
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
226
246
|
|
|
227
247
|
const channels = new URLSearchParams();
|
|
228
248
|
channels.set('project', this.config.project);
|
|
@@ -278,7 +298,7 @@ class Client {
|
|
|
278
298
|
})
|
|
279
299
|
}
|
|
280
300
|
},
|
|
281
|
-
onMessage:
|
|
301
|
+
onMessage: (event) => {
|
|
282
302
|
try {
|
|
283
303
|
const message: RealtimeResponse = JSON.parse(event.data);
|
|
284
304
|
this.realtime.lastMessage = message;
|
|
@@ -307,7 +327,7 @@ class Client {
|
|
|
307
327
|
cleanUp: channels => {
|
|
308
328
|
this.realtime.channels.forEach(channel => {
|
|
309
329
|
if (channels.includes(channel)) {
|
|
310
|
-
let found = Array.from(this.realtime.subscriptions).some(([_key, subscription])
|
|
330
|
+
let found = Array.from(this.realtime.subscriptions).some(([_key, subscription] )=> {
|
|
311
331
|
return subscription.channels.includes(channel);
|
|
312
332
|
})
|
|
313
333
|
|
|
@@ -367,7 +387,8 @@ class Client {
|
|
|
367
387
|
method = method.toUpperCase();
|
|
368
388
|
|
|
369
389
|
headers = Object.assign({}, this.headers, headers);
|
|
370
|
-
headers.Origin = `appwrite-${Platform.OS}://${this.config.platform}
|
|
390
|
+
headers.Origin = `appwrite-${Platform.OS}://${this.config.platform}`
|
|
391
|
+
|
|
371
392
|
let options: RequestInit = {
|
|
372
393
|
method,
|
|
373
394
|
headers,
|
|
@@ -419,6 +440,13 @@ class Client {
|
|
|
419
440
|
throw new AppwriteException(data?.message, response.status, data?.type, data);
|
|
420
441
|
}
|
|
421
442
|
|
|
443
|
+
const cookieFallback = response.headers.get('X-Fallback-Cookies');
|
|
444
|
+
|
|
445
|
+
if (typeof window !== 'undefined' && window.localStorage && cookieFallback) {
|
|
446
|
+
window.console.warn('Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.');
|
|
447
|
+
window.localStorage.setItem('cookieFallback', cookieFallback);
|
|
448
|
+
}
|
|
449
|
+
|
|
422
450
|
return data;
|
|
423
451
|
} catch (e) {
|
|
424
452
|
if (e instanceof AppwriteException) {
|
|
@@ -430,6 +458,4 @@ class Client {
|
|
|
430
458
|
}
|
|
431
459
|
|
|
432
460
|
export { Client, AppwriteException };
|
|
433
|
-
export { Query } from './query';
|
|
434
461
|
export type { Models, Payload };
|
|
435
|
-
export type { QueryTypes, QueryTypesList } from './query';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export enum Browser {
|
|
2
|
+
AvantBrowser = 'aa',
|
|
3
|
+
AndroidWebViewBeta = 'an',
|
|
4
|
+
GoogleChrome = 'ch',
|
|
5
|
+
GoogleChromeIOS = 'ci',
|
|
6
|
+
GoogleChromeMobile = 'cm',
|
|
7
|
+
Chromium = 'cr',
|
|
8
|
+
MozillaFirefox = 'ff',
|
|
9
|
+
Safari = 'sf',
|
|
10
|
+
MobileSafari = 'mf',
|
|
11
|
+
MicrosoftEdge = 'ps',
|
|
12
|
+
MicrosoftEdgeIOS = 'oi',
|
|
13
|
+
OperaMini = 'om',
|
|
14
|
+
Opera = 'op',
|
|
15
|
+
OperaNext = 'on',
|
|
16
|
+
}
|