@zeroin.earth/appwrite-graphql 0.15.0 → 0.15.2
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/dist/index.d.mts +29 -49
- package/dist/index.d.ts +29 -49
- package/dist/index.js +141 -147
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -157
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,108 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
// src/useAppwrite.ts
|
|
8
|
-
import { useMemo } from "react";
|
|
9
|
-
import { Account, Client, Databases, Functions, Graphql } from "appwrite";
|
|
10
|
-
import { print } from "graphql";
|
|
11
|
-
import { atom, useAtom } from "jotai";
|
|
12
|
-
var client = new Client();
|
|
13
|
-
var endpoint = process.env.APPWRITE_ENDPOINT ?? process.env.NEXT_PUBLIC_APPWRITE_URL ?? "http://localhost/v1";
|
|
14
|
-
var projectId = process.env.APPWRITE_PROJECT_ID ?? process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID ?? "[PROJECT_ID]";
|
|
15
|
-
client.setEndpoint(endpoint).setProject(projectId);
|
|
16
|
-
var account = new Account(client);
|
|
17
|
-
var databases = new Databases(client);
|
|
18
|
-
var functions = new Functions(client);
|
|
19
|
-
var graphql = new Graphql(client);
|
|
20
|
-
var AccountAtom = atom(account);
|
|
21
|
-
var DatabasesAtom = atom(databases);
|
|
22
|
-
var FunctionsAtom = atom(functions);
|
|
23
|
-
var GraphqlAtom = atom(graphql);
|
|
24
|
-
function useAppwrite() {
|
|
25
|
-
const [account2] = useAtom(AccountAtom);
|
|
26
|
-
const [databases2] = useAtom(DatabasesAtom);
|
|
27
|
-
const [functions2] = useAtom(FunctionsAtom);
|
|
28
|
-
const [graphqlAppwrite] = useAtom(GraphqlAtom);
|
|
29
|
-
const graphql2 = useMemo(
|
|
30
|
-
() => ({
|
|
31
|
-
client: graphqlAppwrite.client,
|
|
32
|
-
query: async ({
|
|
33
|
-
query,
|
|
34
|
-
variables
|
|
35
|
-
}) => {
|
|
36
|
-
const { data, errors } = await graphqlAppwrite.query({
|
|
37
|
-
query: print(query),
|
|
38
|
-
variables
|
|
39
|
-
});
|
|
40
|
-
return { data, errors };
|
|
41
|
-
},
|
|
42
|
-
mutation: async ({
|
|
43
|
-
query,
|
|
44
|
-
variables
|
|
45
|
-
}) => {
|
|
46
|
-
const { data, errors } = await graphqlAppwrite.mutation({
|
|
47
|
-
query: print(query),
|
|
48
|
-
variables
|
|
49
|
-
});
|
|
50
|
-
return { data, errors };
|
|
51
|
-
}
|
|
52
|
-
}),
|
|
53
|
-
[graphqlAppwrite]
|
|
54
|
-
);
|
|
55
|
-
return {
|
|
56
|
-
account: account2,
|
|
57
|
-
databases: databases2,
|
|
58
|
-
functions: functions2,
|
|
59
|
-
graphql: graphql2
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// src/useMutation.ts
|
|
64
|
-
import {
|
|
65
|
-
useMutation as useReactMutation
|
|
66
|
-
} from "@tanstack/react-query";
|
|
67
|
-
|
|
68
|
-
// src/useQueryClient.ts
|
|
69
|
-
import { useAtom as useAtom2 } from "jotai";
|
|
70
|
-
|
|
71
|
-
// src/states/query.ts
|
|
72
|
-
import { QueryClient } from "@tanstack/react-query";
|
|
73
|
-
import { atom as atom2 } from "jotai";
|
|
74
|
-
var queryClient = new QueryClient();
|
|
75
|
-
var QueryAtom = atom2(queryClient);
|
|
76
|
-
|
|
77
|
-
// src/useQueryClient.ts
|
|
78
|
-
function useQueryClient() {
|
|
79
|
-
const [queryClient2] = useAtom2(QueryAtom);
|
|
80
|
-
return queryClient2;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// src/useMutation.ts
|
|
84
|
-
function useMutation(options) {
|
|
85
|
-
const queryClient2 = useQueryClient();
|
|
86
|
-
return useReactMutation(options, queryClient2);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// src/useQuery.ts
|
|
90
|
-
import {
|
|
91
|
-
useQuery as useReactQuery
|
|
92
|
-
} from "@tanstack/react-query";
|
|
93
|
-
function useQuery(options) {
|
|
94
|
-
const queryClient2 = useQueryClient();
|
|
95
|
-
return useReactQuery(options, queryClient2);
|
|
1
|
+
// src/__generated__/fragment-masking.ts
|
|
2
|
+
function getFragmentData(_documentNode, fragmentType) {
|
|
3
|
+
return fragmentType;
|
|
96
4
|
}
|
|
97
5
|
|
|
98
|
-
// src/account/useAccount.ts
|
|
99
|
-
import { useEffect } from "react";
|
|
100
|
-
import { castDraft, produce } from "immer";
|
|
101
|
-
|
|
102
6
|
// src/__generated__/graphql.ts
|
|
103
|
-
var
|
|
104
|
-
var
|
|
105
|
-
var AccountGetDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "AccountGet" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountGet" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "
|
|
7
|
+
var Account_UserFragmentDoc = { "kind": "Document", "definitions": [{ "kind": "FragmentDefinition", "name": { "kind": "Name", "value": "Account_User" }, "typeCondition": { "kind": "NamedType", "name": { "kind": "Name", "value": "User" } }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "name" } }, { "kind": "Field", "name": { "kind": "Name", "value": "email" } }, { "kind": "Field", "name": { "kind": "Name", "value": "prefs" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "data" } }] } }] } }] };
|
|
8
|
+
var Identity_ProviderFragmentDoc = { "kind": "Document", "definitions": [{ "kind": "FragmentDefinition", "name": { "kind": "Name", "value": "Identity_Provider" }, "typeCondition": { "kind": "NamedType", "name": { "kind": "Name", "value": "Identity" } }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userId" } }, { "kind": "Field", "name": { "kind": "Name", "value": "provider" } }] } }] };
|
|
9
|
+
var AccountGetDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "AccountGet" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountGet" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "Account_User" } }] } }] } }, { "kind": "FragmentDefinition", "name": { "kind": "Name", "value": "Account_User" }, "typeCondition": { "kind": "NamedType", "name": { "kind": "Name", "value": "User" } }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "name" } }, { "kind": "Field", "name": { "kind": "Name", "value": "email" } }, { "kind": "Field", "name": { "kind": "Name", "value": "prefs" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "data" } }] } }] } }] };
|
|
106
10
|
var CreateAnonymousSessionDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "CreateAnonymousSession" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountCreateAnonymousSession" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "expire" } }, { "kind": "Field", "name": { "kind": "Name", "value": "current" } }] } }] } }] };
|
|
107
11
|
var CreateEmailTokenDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "CreateEmailToken" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "userId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "email" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "phrase" } }, "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "Boolean" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountCreateEmailToken" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "userId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "userId" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "email" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "email" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "phrase" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "phrase" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "expire" } }] } }] } }] };
|
|
108
12
|
var CreateJwtDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "CreateJWT" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountCreateJWT" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "jwt" } }] } }] } }] };
|
|
@@ -116,10 +20,11 @@ var CreateSessionDocument = { "kind": "Document", "definitions": [{ "kind": "Ope
|
|
|
116
20
|
var DeleteIdentityDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "DeleteIdentity" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "identityId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountDeleteIdentity" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "identityId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "identityId" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "status" } }] } }] } }] };
|
|
117
21
|
var DeleteMfaAuthenticatorDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "DeleteMfaAuthenticator" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "type" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "otp" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountDeleteMfaAuthenticator" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "type" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "type" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "otp" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "otp" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "mfa" } }] } }] } }] };
|
|
118
22
|
var DeleteSessionDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "DeleteSession" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "sessionId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountDeleteSession" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "sessionId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "sessionId" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "status" } }] } }] } }] };
|
|
23
|
+
var DeleteSessionsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "DeleteSessions" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountDeleteSessions" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "status" } }] } }] } }] };
|
|
119
24
|
var GetMfaRecoveryCodesDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetMfaRecoveryCodes" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountGetMfaRecoveryCodes" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "recoveryCodes" } }] } }] } }] };
|
|
120
25
|
var GetPrefsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetPrefs" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountGetPrefs" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "data" } }] } }] } }] };
|
|
121
26
|
var GetSessionDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetSession" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "sessionId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountGetSession" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "sessionId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "sessionId" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userId" } }, { "kind": "Field", "name": { "kind": "Name", "value": "expire" } }, { "kind": "Field", "name": { "kind": "Name", "value": "current" } }] } }] } }] };
|
|
122
|
-
var ListIdentitiesDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "ListIdentities" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "queries" } }, "type": { "kind": "ListType", "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountListIdentities" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "queries" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "queries" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "total" } }, { "kind": "Field", "name": { "kind": "Name", "value": "identities" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "
|
|
27
|
+
var ListIdentitiesDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "ListIdentities" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "queries" } }, "type": { "kind": "ListType", "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountListIdentities" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "queries" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "queries" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "total" } }, { "kind": "Field", "name": { "kind": "Name", "value": "identities" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "Identity_Provider" } }] } }] } }] } }, { "kind": "FragmentDefinition", "name": { "kind": "Name", "value": "Identity_Provider" }, "typeCondition": { "kind": "NamedType", "name": { "kind": "Name", "value": "Identity" } }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userId" } }, { "kind": "Field", "name": { "kind": "Name", "value": "provider" } }] } }] };
|
|
123
28
|
var ListMfaFactorsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "ListMfaFactors" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountListMfaFactors" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "totp" } }, { "kind": "Field", "name": { "kind": "Name", "value": "phone" } }, { "kind": "Field", "name": { "kind": "Name", "value": "email" } }] } }] } }] };
|
|
124
29
|
var ListSessionsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "ListSessions" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountListSessions" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "sessions" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "_createdAt" } }, { "kind": "Field", "name": { "kind": "Name", "value": "osName" } }, { "kind": "Field", "name": { "kind": "Name", "value": "clientName" } }] } }] } }] } }] };
|
|
125
30
|
var CreateEmailPasswordSessionDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "CreateEmailPasswordSession" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "email" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "password" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountCreateEmailPasswordSession" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "email" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "email" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "password" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "password" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userId" } }, { "kind": "Field", "name": { "kind": "Name", "value": "expire" } }, { "kind": "Field", "name": { "kind": "Name", "value": "current" } }] } }] } }] };
|
|
@@ -152,9 +57,9 @@ var GetFunctionExecutionDocument = { "kind": "Document", "definitions": [{ "kind
|
|
|
152
57
|
|
|
153
58
|
// src/__generated__/gql.ts
|
|
154
59
|
var documents = {
|
|
155
|
-
"\n fragment
|
|
156
|
-
"\n fragment
|
|
157
|
-
"\n query AccountGet {\n accountGet {\n ...
|
|
60
|
+
"\n fragment Account_User on User {\n _id\n name\n email\n prefs {\n data\n }\n }\n": Account_UserFragmentDoc,
|
|
61
|
+
"\n fragment Identity_Provider on Identity {\n userId\n provider\n }\n": Identity_ProviderFragmentDoc,
|
|
62
|
+
"\n query AccountGet {\n accountGet {\n ...Account_User\n }\n }\n": AccountGetDocument,
|
|
158
63
|
"\n mutation CreateAnonymousSession {\n accountCreateAnonymousSession {\n _id\n expire\n current\n }\n }\n": CreateAnonymousSessionDocument,
|
|
159
64
|
"\n mutation CreateEmailToken($userId: String!, $email: String!, $phrase: Boolean) {\n accountCreateEmailToken(userId: $userId, email: $email, phrase: $phrase) {\n expire\n }\n }\n": CreateEmailTokenDocument,
|
|
160
65
|
"\n mutation CreateJWT {\n accountCreateJWT {\n jwt\n }\n }\n": CreateJwtDocument,
|
|
@@ -168,10 +73,11 @@ var documents = {
|
|
|
168
73
|
"\n mutation DeleteIdentity($identityId: String!) {\n accountDeleteIdentity(identityId: $identityId) {\n status\n }\n }\n": DeleteIdentityDocument,
|
|
169
74
|
"\n mutation DeleteMfaAuthenticator($type: String!, $otp: String!) {\n accountDeleteMfaAuthenticator(type: $type, otp: $otp) {\n mfa\n }\n }\n": DeleteMfaAuthenticatorDocument,
|
|
170
75
|
"\n mutation DeleteSession($sessionId: String!) {\n accountDeleteSession(sessionId: $sessionId) {\n status\n }\n }\n": DeleteSessionDocument,
|
|
76
|
+
"\n mutation DeleteSessions {\n accountDeleteSessions {\n status\n }\n }\n": DeleteSessionsDocument,
|
|
171
77
|
"\n query GetMfaRecoveryCodes {\n accountGetMfaRecoveryCodes {\n recoveryCodes\n }\n }\n": GetMfaRecoveryCodesDocument,
|
|
172
78
|
"\n query GetPrefs {\n accountGetPrefs {\n data\n }\n }\n": GetPrefsDocument,
|
|
173
79
|
"\n query GetSession($sessionId: String!) {\n accountGetSession(sessionId: $sessionId) {\n userId\n expire\n current\n }\n }\n": GetSessionDocument,
|
|
174
|
-
"\n query ListIdentities($queries: [String!]) {\n accountListIdentities(queries: $queries) {\n total\n identities {\n ...
|
|
80
|
+
"\n query ListIdentities($queries: [String!]) {\n accountListIdentities(queries: $queries) {\n total\n identities {\n ...Identity_Provider\n }\n }\n }\n": ListIdentitiesDocument,
|
|
175
81
|
"\n query ListMfaFactors {\n accountListMfaFactors {\n totp\n phone\n email\n }\n }\n": ListMfaFactorsDocument,
|
|
176
82
|
"\n query ListSessions {\n accountListSessions {\n sessions {\n _id\n _createdAt\n osName\n clientName\n }\n }\n }\n": ListSessionsDocument,
|
|
177
83
|
"\n mutation CreateEmailPasswordSession($email: String!, $password: String!) {\n accountCreateEmailPasswordSession(email: $email, password: $password) {\n userId\n expire\n current\n }\n }\n": CreateEmailPasswordSessionDocument,
|
|
@@ -206,13 +112,130 @@ function gql(source) {
|
|
|
206
112
|
return documents[source] ?? {};
|
|
207
113
|
}
|
|
208
114
|
|
|
115
|
+
// src/account/fragments.ts
|
|
116
|
+
var Account_User = gql(
|
|
117
|
+
/* GraphQL */
|
|
118
|
+
`
|
|
119
|
+
fragment Account_User on User {
|
|
120
|
+
_id
|
|
121
|
+
name
|
|
122
|
+
email
|
|
123
|
+
prefs {
|
|
124
|
+
data
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
`
|
|
128
|
+
);
|
|
129
|
+
var Identity_Provider = gql(
|
|
130
|
+
/* GraphQL */
|
|
131
|
+
`
|
|
132
|
+
fragment Identity_Provider on Identity {
|
|
133
|
+
userId
|
|
134
|
+
provider
|
|
135
|
+
}
|
|
136
|
+
`
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
// src/useAppwrite.ts
|
|
140
|
+
import { useMemo } from "react";
|
|
141
|
+
import { Account, Client, Databases, Functions, Graphql } from "appwrite";
|
|
142
|
+
import { print } from "graphql";
|
|
143
|
+
import { atom, useAtom } from "jotai";
|
|
144
|
+
var client = new Client();
|
|
145
|
+
var endpoint = process.env.APPWRITE_ENDPOINT ?? process.env.NEXT_PUBLIC_APPWRITE_URL ?? "http://localhost/v1";
|
|
146
|
+
var projectId = process.env.APPWRITE_PROJECT_ID ?? process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID ?? "[PROJECT_ID]";
|
|
147
|
+
client.setEndpoint(endpoint).setProject(projectId);
|
|
148
|
+
var account = new Account(client);
|
|
149
|
+
var databases = new Databases(client);
|
|
150
|
+
var functions = new Functions(client);
|
|
151
|
+
var graphql = new Graphql(client);
|
|
152
|
+
var AccountAtom = atom(account);
|
|
153
|
+
var DatabasesAtom = atom(databases);
|
|
154
|
+
var FunctionsAtom = atom(functions);
|
|
155
|
+
var GraphqlAtom = atom(graphql);
|
|
156
|
+
function useAppwrite() {
|
|
157
|
+
const [account2] = useAtom(AccountAtom);
|
|
158
|
+
const [databases2] = useAtom(DatabasesAtom);
|
|
159
|
+
const [functions2] = useAtom(FunctionsAtom);
|
|
160
|
+
const [graphqlAppwrite] = useAtom(GraphqlAtom);
|
|
161
|
+
const graphql2 = useMemo(
|
|
162
|
+
() => ({
|
|
163
|
+
client: graphqlAppwrite.client,
|
|
164
|
+
query: async ({
|
|
165
|
+
query,
|
|
166
|
+
variables
|
|
167
|
+
}) => {
|
|
168
|
+
const { data, errors } = await graphqlAppwrite.query({
|
|
169
|
+
query: print(query),
|
|
170
|
+
variables
|
|
171
|
+
});
|
|
172
|
+
return { data, errors };
|
|
173
|
+
},
|
|
174
|
+
mutation: async ({
|
|
175
|
+
query,
|
|
176
|
+
variables
|
|
177
|
+
}) => {
|
|
178
|
+
const { data, errors } = await graphqlAppwrite.mutation({
|
|
179
|
+
query: print(query),
|
|
180
|
+
variables
|
|
181
|
+
});
|
|
182
|
+
return { data, errors };
|
|
183
|
+
}
|
|
184
|
+
}),
|
|
185
|
+
[graphqlAppwrite]
|
|
186
|
+
);
|
|
187
|
+
return {
|
|
188
|
+
account: account2,
|
|
189
|
+
databases: databases2,
|
|
190
|
+
functions: functions2,
|
|
191
|
+
graphql: graphql2
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// src/useMutation.ts
|
|
196
|
+
import {
|
|
197
|
+
useMutation as useReactMutation
|
|
198
|
+
} from "@tanstack/react-query";
|
|
199
|
+
|
|
200
|
+
// src/useQueryClient.ts
|
|
201
|
+
import { useAtom as useAtom2 } from "jotai";
|
|
202
|
+
|
|
203
|
+
// src/states/query.ts
|
|
204
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
205
|
+
import { atom as atom2 } from "jotai";
|
|
206
|
+
var queryClient = new QueryClient();
|
|
207
|
+
var QueryAtom = atom2(queryClient);
|
|
208
|
+
|
|
209
|
+
// src/useQueryClient.ts
|
|
210
|
+
function useQueryClient() {
|
|
211
|
+
const [queryClient2] = useAtom2(QueryAtom);
|
|
212
|
+
return queryClient2;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// src/useMutation.ts
|
|
216
|
+
function useMutation(options) {
|
|
217
|
+
const queryClient2 = useQueryClient();
|
|
218
|
+
return useReactMutation(options, queryClient2);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// src/useQuery.ts
|
|
222
|
+
import {
|
|
223
|
+
useQuery as useReactQuery
|
|
224
|
+
} from "@tanstack/react-query";
|
|
225
|
+
function useQuery(options) {
|
|
226
|
+
const queryClient2 = useQueryClient();
|
|
227
|
+
return useReactQuery(options, queryClient2);
|
|
228
|
+
}
|
|
229
|
+
|
|
209
230
|
// src/account/useAccount.ts
|
|
231
|
+
import { useEffect } from "react";
|
|
232
|
+
import { castDraft, produce } from "immer";
|
|
210
233
|
var getAccount = gql(
|
|
211
234
|
/* GraphQL */
|
|
212
235
|
`
|
|
213
236
|
query AccountGet {
|
|
214
237
|
accountGet {
|
|
215
|
-
...
|
|
238
|
+
...Account_User
|
|
216
239
|
}
|
|
217
240
|
}
|
|
218
241
|
`
|
|
@@ -260,11 +283,6 @@ function useAccount() {
|
|
|
260
283
|
return queryResult;
|
|
261
284
|
}
|
|
262
285
|
|
|
263
|
-
// src/__generated__/fragment-masking.ts
|
|
264
|
-
function getFragmentData(_documentNode, fragmentType) {
|
|
265
|
-
return fragmentType;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
286
|
// src/account/useCreateAnonymousSession.ts
|
|
269
287
|
var createAnonymousSession = gql(
|
|
270
288
|
/* GraphQL */
|
|
@@ -692,11 +710,11 @@ function useDeleteSession() {
|
|
|
692
710
|
}
|
|
693
711
|
|
|
694
712
|
// src/account/useDeleteSessions.ts
|
|
695
|
-
var
|
|
713
|
+
var deleteSessions = gql(
|
|
696
714
|
/* GraphQL */
|
|
697
715
|
`
|
|
698
|
-
mutation
|
|
699
|
-
|
|
716
|
+
mutation DeleteSessions {
|
|
717
|
+
accountDeleteSessions {
|
|
700
718
|
status
|
|
701
719
|
}
|
|
702
720
|
}
|
|
@@ -705,17 +723,14 @@ var deleteSession2 = gql(
|
|
|
705
723
|
function useDeleteSessions() {
|
|
706
724
|
const { graphql: graphql2 } = useAppwrite();
|
|
707
725
|
const queryResult = useMutation({
|
|
708
|
-
mutationFn: async (
|
|
726
|
+
mutationFn: async () => {
|
|
709
727
|
const { data, errors } = await graphql2.mutation({
|
|
710
|
-
query:
|
|
711
|
-
variables: {
|
|
712
|
-
sessionId
|
|
713
|
-
}
|
|
728
|
+
query: deleteSessions
|
|
714
729
|
});
|
|
715
730
|
if (errors) {
|
|
716
731
|
throw errors;
|
|
717
732
|
}
|
|
718
|
-
return data.
|
|
733
|
+
return data.accountDeleteSessions;
|
|
719
734
|
}
|
|
720
735
|
});
|
|
721
736
|
return { ...queryResult };
|
|
@@ -816,7 +831,7 @@ var accountListIdentities = gql(
|
|
|
816
831
|
accountListIdentities(queries: $queries) {
|
|
817
832
|
total
|
|
818
833
|
identities {
|
|
819
|
-
...
|
|
834
|
+
...Identity_Provider
|
|
820
835
|
}
|
|
821
836
|
}
|
|
822
837
|
}
|
|
@@ -947,7 +962,7 @@ function useLogin() {
|
|
|
947
962
|
}
|
|
948
963
|
|
|
949
964
|
// src/account/useLogout.ts
|
|
950
|
-
var
|
|
965
|
+
var deleteSession2 = gql(
|
|
951
966
|
/* GraphQL */
|
|
952
967
|
`
|
|
953
968
|
mutation DeleteSession($sessionId: String!) {
|
|
@@ -963,7 +978,7 @@ function useLogout() {
|
|
|
963
978
|
const queryResult = useMutation({
|
|
964
979
|
mutationFn: async ({ sessionId }) => {
|
|
965
980
|
const { data, errors } = await graphql2.mutation({
|
|
966
|
-
query:
|
|
981
|
+
query: deleteSession2,
|
|
967
982
|
variables: {
|
|
968
983
|
sessionId
|
|
969
984
|
}
|
|
@@ -2150,39 +2165,12 @@ function useSuspenseFunction({
|
|
|
2150
2165
|
};
|
|
2151
2166
|
}
|
|
2152
2167
|
|
|
2153
|
-
// src/account/fragments.ts
|
|
2154
|
-
var fragments_exports = {};
|
|
2155
|
-
__export(fragments_exports, {
|
|
2156
|
-
Account_UserFragment: () => Account_UserFragment,
|
|
2157
|
-
Identity_ProviderFragment: () => Identity_ProviderFragment
|
|
2158
|
-
});
|
|
2159
|
-
var Account_UserFragment = gql(
|
|
2160
|
-
/* GraphQL */
|
|
2161
|
-
`
|
|
2162
|
-
fragment Account_UserFragment on User {
|
|
2163
|
-
_id
|
|
2164
|
-
name
|
|
2165
|
-
email
|
|
2166
|
-
prefs {
|
|
2167
|
-
data
|
|
2168
|
-
}
|
|
2169
|
-
}
|
|
2170
|
-
`
|
|
2171
|
-
);
|
|
2172
|
-
var Identity_ProviderFragment = gql(
|
|
2173
|
-
/* GraphQL */
|
|
2174
|
-
`
|
|
2175
|
-
fragment Identity_ProviderFragment on Identity {
|
|
2176
|
-
userId
|
|
2177
|
-
provider
|
|
2178
|
-
}
|
|
2179
|
-
`
|
|
2180
|
-
);
|
|
2181
|
-
|
|
2182
2168
|
// src/index.ts
|
|
2183
|
-
var fragments
|
|
2184
|
-
|
|
2185
|
-
|
|
2169
|
+
var fragments;
|
|
2170
|
+
((fragments2) => {
|
|
2171
|
+
fragments2.Account_UserFragment = Account_User;
|
|
2172
|
+
fragments2.Identity_ProviderFragment = Identity_Provider;
|
|
2173
|
+
})(fragments || (fragments = {}));
|
|
2186
2174
|
export {
|
|
2187
2175
|
fragments,
|
|
2188
2176
|
getFragmentData,
|