@zeroin.earth/appwrite-graphql 0.15.1 → 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 +18 -16
- package/dist/index.d.ts +18 -16
- package/dist/index.js +131 -136
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +135 -146
- 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,7 +24,7 @@ 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" } }] } }] } }] };
|
|
@@ -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,7 +77,7 @@ 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,
|
|
@@ -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
|
}
|
|
@@ -2149,39 +2165,12 @@ function useSuspenseFunction({
|
|
|
2149
2165
|
};
|
|
2150
2166
|
}
|
|
2151
2167
|
|
|
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
2168
|
// src/index.ts
|
|
2182
|
-
var fragments
|
|
2183
|
-
|
|
2184
|
-
|
|
2169
|
+
var fragments;
|
|
2170
|
+
((fragments2) => {
|
|
2171
|
+
fragments2.Account_UserFragment = Account_User;
|
|
2172
|
+
fragments2.Identity_ProviderFragment = Identity_Provider;
|
|
2173
|
+
})(fragments || (fragments = {}));
|
|
2185
2174
|
export {
|
|
2186
2175
|
fragments,
|
|
2187
2176
|
getFragmentData,
|