@zeroin.earth/appwrite-graphql 0.15.1 → 0.15.3
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 +18 -27
- package/dist/index.d.ts +18 -27
- package/dist/index.js +137 -153
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +141 -163
- 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" } }] } }] } }] };
|
|
@@ -120,13 +24,13 @@ var DeleteSessionsDocument = { "kind": "Document", "definitions": [{ "kind": "Op
|
|
|
120
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" } }] } }] } }] };
|
|
121
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" } }] } }] } }] };
|
|
122
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" } }] } }] } }] };
|
|
123
|
-
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" } }] } }] };
|
|
124
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" } }] } }] } }] };
|
|
125
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" } }] } }] } }] } }] };
|
|
126
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" } }] } }] } }] };
|
|
127
31
|
var ListLogsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "ListLogs" }, "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": "accountListLogs" }, "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": "logs" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "event" } }, { "kind": "Field", "name": { "kind": "Name", "value": "userId" } }, { "kind": "Field", "name": { "kind": "Name", "value": "userEmail" } }, { "kind": "Field", "name": { "kind": "Name", "value": "userName" } }, { "kind": "Field", "name": { "kind": "Name", "value": "mode" } }, { "kind": "Field", "name": { "kind": "Name", "value": "ip" } }, { "kind": "Field", "name": { "kind": "Name", "value": "time" } }, { "kind": "Field", "name": { "kind": "Name", "value": "osCode" } }, { "kind": "Field", "name": { "kind": "Name", "value": "osName" } }, { "kind": "Field", "name": { "kind": "Name", "value": "osVersion" } }, { "kind": "Field", "name": { "kind": "Name", "value": "clientType" } }, { "kind": "Field", "name": { "kind": "Name", "value": "clientCode" } }, { "kind": "Field", "name": { "kind": "Name", "value": "clientName" } }, { "kind": "Field", "name": { "kind": "Name", "value": "clientVersion" } }, { "kind": "Field", "name": { "kind": "Name", "value": "clientEngine" } }, { "kind": "Field", "name": { "kind": "Name", "value": "clientEngineVersion" } }, { "kind": "Field", "name": { "kind": "Name", "value": "deviceName" } }, { "kind": "Field", "name": { "kind": "Name", "value": "deviceBrand" } }, { "kind": "Field", "name": { "kind": "Name", "value": "deviceModel" } }, { "kind": "Field", "name": { "kind": "Name", "value": "countryCode" } }, { "kind": "Field", "name": { "kind": "Name", "value": "countryName" } }] } }] } }] } }] };
|
|
128
32
|
var CreateRecoveryDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "CreateRecovery" }, "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": "url" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountCreateRecovery" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "email" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "email" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "url" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "url" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "expire" } }] } }] } }] };
|
|
129
|
-
var UpdateRecoveryDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "UpdateRecovery" }, "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": "secret" } }, "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" } } } }
|
|
33
|
+
var UpdateRecoveryDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "UpdateRecovery" }, "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": "secret" } }, "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": "accountUpdateRecovery" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "userId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "userId" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "secret" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "secret" } } }, { "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": "expire" } }] } }] } }] };
|
|
130
34
|
var CreateAccountDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "CreateAccount" }, "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": "name" } }, "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": "password" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountCreate" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "userId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "userId" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "name" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "name" } } }, { "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": "name" } }, { "kind": "Field", "name": { "kind": "Name", "value": "email" } }] } }] } }] };
|
|
131
35
|
var VerifyEmailDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "VerifyEmail" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "url" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountCreateVerification" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "url" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "url" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "expire" } }] } }] } }] };
|
|
132
36
|
var UpdateEmailDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "UpdateEmail" }, "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": "accountUpdateEmail" }, "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": "name" } }, { "kind": "Field", "name": { "kind": "Name", "value": "email" } }] } }] } }] };
|
|
@@ -153,9 +57,9 @@ var GetFunctionExecutionDocument = { "kind": "Document", "definitions": [{ "kind
|
|
|
153
57
|
|
|
154
58
|
// src/__generated__/gql.ts
|
|
155
59
|
var documents = {
|
|
156
|
-
"\n fragment
|
|
157
|
-
"\n fragment
|
|
158
|
-
"\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,
|
|
159
63
|
"\n mutation CreateAnonymousSession {\n accountCreateAnonymousSession {\n _id\n expire\n current\n }\n }\n": CreateAnonymousSessionDocument,
|
|
160
64
|
"\n mutation CreateEmailToken($userId: String!, $email: String!, $phrase: Boolean) {\n accountCreateEmailToken(userId: $userId, email: $email, phrase: $phrase) {\n expire\n }\n }\n": CreateEmailTokenDocument,
|
|
161
65
|
"\n mutation CreateJWT {\n accountCreateJWT {\n jwt\n }\n }\n": CreateJwtDocument,
|
|
@@ -173,13 +77,13 @@ var documents = {
|
|
|
173
77
|
"\n query GetMfaRecoveryCodes {\n accountGetMfaRecoveryCodes {\n recoveryCodes\n }\n }\n": GetMfaRecoveryCodesDocument,
|
|
174
78
|
"\n query GetPrefs {\n accountGetPrefs {\n data\n }\n }\n": GetPrefsDocument,
|
|
175
79
|
"\n query GetSession($sessionId: String!) {\n accountGetSession(sessionId: $sessionId) {\n userId\n expire\n current\n }\n }\n": GetSessionDocument,
|
|
176
|
-
"\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,
|
|
177
81
|
"\n query ListMfaFactors {\n accountListMfaFactors {\n totp\n phone\n email\n }\n }\n": ListMfaFactorsDocument,
|
|
178
82
|
"\n query ListSessions {\n accountListSessions {\n sessions {\n _id\n _createdAt\n osName\n clientName\n }\n }\n }\n": ListSessionsDocument,
|
|
179
83
|
"\n mutation CreateEmailPasswordSession($email: String!, $password: String!) {\n accountCreateEmailPasswordSession(email: $email, password: $password) {\n userId\n expire\n current\n }\n }\n": CreateEmailPasswordSessionDocument,
|
|
180
84
|
"\n query ListLogs($queries: [String!]) {\n accountListLogs(queries: $queries) {\n total\n logs {\n event\n userId\n userEmail\n userName\n mode\n ip\n time\n osCode\n osName\n osVersion\n clientType\n clientCode\n clientName\n clientVersion\n clientEngine\n clientEngineVersion\n deviceName\n deviceBrand\n deviceModel\n countryCode\n countryName\n }\n }\n }\n": ListLogsDocument,
|
|
181
85
|
"\n mutation CreateRecovery($email: String!, $url: String!) {\n accountCreateRecovery(email: $email, url: $url) {\n expire\n }\n }\n": CreateRecoveryDocument,
|
|
182
|
-
"\n mutation UpdateRecovery(
|
|
86
|
+
"\n mutation UpdateRecovery($userId: String!, $secret: String!, $password: String!) {\n accountUpdateRecovery(userId: $userId, secret: $secret, password: $password) {\n expire\n }\n }\n": UpdateRecoveryDocument,
|
|
183
87
|
"\n mutation CreateAccount($userId: String!, $name: String, $email: String!, $password: String!) {\n accountCreate(userId: $userId, name: $name, email: $email, password: $password) {\n name\n email\n }\n }\n": CreateAccountDocument,
|
|
184
88
|
"\n mutation VerifyEmail($url: String!) {\n accountCreateVerification(url: $url) {\n expire\n }\n }\n": VerifyEmailDocument,
|
|
185
89
|
"\n mutation UpdateEmail($email: String!, $password: String!) {\n accountUpdateEmail(email: $email, password: $password) {\n name\n email\n }\n }\n": UpdateEmailDocument,
|
|
@@ -208,13 +112,130 @@ function gql(source) {
|
|
|
208
112
|
return documents[source] ?? {};
|
|
209
113
|
}
|
|
210
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
|
+
|
|
211
230
|
// src/account/useAccount.ts
|
|
231
|
+
import { useEffect } from "react";
|
|
232
|
+
import { castDraft, produce } from "immer";
|
|
212
233
|
var getAccount = gql(
|
|
213
234
|
/* GraphQL */
|
|
214
235
|
`
|
|
215
236
|
query AccountGet {
|
|
216
237
|
accountGet {
|
|
217
|
-
...
|
|
238
|
+
...Account_User
|
|
218
239
|
}
|
|
219
240
|
}
|
|
220
241
|
`
|
|
@@ -262,11 +283,6 @@ function useAccount() {
|
|
|
262
283
|
return queryResult;
|
|
263
284
|
}
|
|
264
285
|
|
|
265
|
-
// src/__generated__/fragment-masking.ts
|
|
266
|
-
function getFragmentData(_documentNode, fragmentType) {
|
|
267
|
-
return fragmentType;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
286
|
// src/account/useCreateAnonymousSession.ts
|
|
271
287
|
var createAnonymousSession = gql(
|
|
272
288
|
/* GraphQL */
|
|
@@ -815,7 +831,7 @@ var accountListIdentities = gql(
|
|
|
815
831
|
accountListIdentities(queries: $queries) {
|
|
816
832
|
total
|
|
817
833
|
identities {
|
|
818
|
-
...
|
|
834
|
+
...Identity_Provider
|
|
819
835
|
}
|
|
820
836
|
}
|
|
821
837
|
}
|
|
@@ -1073,18 +1089,8 @@ function usePasswordRecovery() {
|
|
|
1073
1089
|
var updateRecovery = gql(
|
|
1074
1090
|
/* GraphQL */
|
|
1075
1091
|
`
|
|
1076
|
-
mutation UpdateRecovery(
|
|
1077
|
-
$userId:
|
|
1078
|
-
$secret: String!
|
|
1079
|
-
$password: String!
|
|
1080
|
-
$passwordAgain: String!
|
|
1081
|
-
) {
|
|
1082
|
-
accountUpdateRecovery(
|
|
1083
|
-
userId: $userId
|
|
1084
|
-
secret: $secret
|
|
1085
|
-
password: $password
|
|
1086
|
-
passwordAgain: $passwordAgain
|
|
1087
|
-
) {
|
|
1092
|
+
mutation UpdateRecovery($userId: String!, $secret: String!, $password: String!) {
|
|
1093
|
+
accountUpdateRecovery(userId: $userId, secret: $secret, password: $password) {
|
|
1088
1094
|
expire
|
|
1089
1095
|
}
|
|
1090
1096
|
}
|
|
@@ -1093,14 +1099,13 @@ var updateRecovery = gql(
|
|
|
1093
1099
|
function useResetPassword() {
|
|
1094
1100
|
const { graphql: graphql2 } = useAppwrite();
|
|
1095
1101
|
const queryResult = useMutation({
|
|
1096
|
-
mutationFn: async ({ userId, secret, password
|
|
1102
|
+
mutationFn: async ({ userId, secret, password }) => {
|
|
1097
1103
|
const { data, errors } = await graphql2.mutation({
|
|
1098
1104
|
query: updateRecovery,
|
|
1099
1105
|
variables: {
|
|
1100
1106
|
userId,
|
|
1101
1107
|
secret,
|
|
1102
|
-
password
|
|
1103
|
-
passwordAgain: confirmPassword
|
|
1108
|
+
password
|
|
1104
1109
|
}
|
|
1105
1110
|
});
|
|
1106
1111
|
if (errors) {
|
|
@@ -2149,39 +2154,12 @@ function useSuspenseFunction({
|
|
|
2149
2154
|
};
|
|
2150
2155
|
}
|
|
2151
2156
|
|
|
2152
|
-
// src/account/fragments.ts
|
|
2153
|
-
var fragments_exports = {};
|
|
2154
|
-
__export(fragments_exports, {
|
|
2155
|
-
Account_UserFragment: () => Account_UserFragment,
|
|
2156
|
-
Identity_ProviderFragment: () => Identity_ProviderFragment
|
|
2157
|
-
});
|
|
2158
|
-
var Account_UserFragment = gql(
|
|
2159
|
-
/* GraphQL */
|
|
2160
|
-
`
|
|
2161
|
-
fragment Account_UserFragment on User {
|
|
2162
|
-
_id
|
|
2163
|
-
name
|
|
2164
|
-
email
|
|
2165
|
-
prefs {
|
|
2166
|
-
data
|
|
2167
|
-
}
|
|
2168
|
-
}
|
|
2169
|
-
`
|
|
2170
|
-
);
|
|
2171
|
-
var Identity_ProviderFragment = gql(
|
|
2172
|
-
/* GraphQL */
|
|
2173
|
-
`
|
|
2174
|
-
fragment Identity_ProviderFragment on Identity {
|
|
2175
|
-
userId
|
|
2176
|
-
provider
|
|
2177
|
-
}
|
|
2178
|
-
`
|
|
2179
|
-
);
|
|
2180
|
-
|
|
2181
2157
|
// src/index.ts
|
|
2182
|
-
var fragments
|
|
2183
|
-
|
|
2184
|
-
|
|
2158
|
+
var fragments;
|
|
2159
|
+
((fragments2) => {
|
|
2160
|
+
fragments2.Account_UserFragment = Account_User;
|
|
2161
|
+
fragments2.Identity_ProviderFragment = Identity_Provider;
|
|
2162
|
+
})(fragments || (fragments = {}));
|
|
2185
2163
|
export {
|
|
2186
2164
|
fragments,
|
|
2187
2165
|
getFragmentData,
|