@zeroin.earth/appwrite-graphql 0.14.7 → 0.14.9
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 +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +88 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +93 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
1
7
|
// src/useAppwrite.ts
|
|
2
8
|
import { useMemo } from "react";
|
|
3
9
|
import { Account, Client, Databases, Functions, Graphql } from "appwrite";
|
|
@@ -135,7 +141,7 @@ var UpdatePhoneSessionDocument = { "kind": "Document", "definitions": [{ "kind":
|
|
|
135
141
|
var UpdatePhoneVerificationDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "UpdatePhoneVerification" }, "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" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountUpdatePhoneVerification" }, "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" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "expire" } }] } }] } }] };
|
|
136
142
|
var UpdatePrefsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "UpdatePrefs" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "prefs" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "JSON" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountUpdatePrefs" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "prefs" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "prefs" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "prefs" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "data" } }] } }] } }] } }] };
|
|
137
143
|
var UpdateSessionDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "UpdateSession" }, "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": "accountUpdateSession" }, "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" } }] } }] } }] };
|
|
138
|
-
var UpdateVerificationDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "UpdateVerification" }, "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" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountUpdateVerification" }, "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" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "expire" } }] } }] } }] };
|
|
144
|
+
var UpdateVerificationDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "UpdateVerification" }, "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" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accountUpdateVerification" }, "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" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "secret" } }, { "kind": "Field", "name": { "kind": "Name", "value": "expire" } }, { "kind": "Field", "name": { "kind": "Name", "value": "userId" } }] } }] } }] };
|
|
139
145
|
var ListDocumentsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "ListDocuments" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "databaseId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "collectionId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "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": "databasesListDocuments" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "databaseId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "databaseId" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "collectionId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "collectionId" } } }, { "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": "documents" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "data" } }] } }] } }] } }] };
|
|
140
146
|
var CreateDocumentDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "CreateDocument" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "databaseId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "collectionId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "documentId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "data" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "JSON" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "permissions" } }, "type": { "kind": "ListType", "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "databasesCreateDocument" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "databaseId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "databaseId" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "collectionId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "collectionId" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "documentId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "documentId" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "data" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "data" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "permissions" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "permissions" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "_id" } }] } }] } }] };
|
|
141
147
|
var DeleteDocumentDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "DeleteDocument" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "databaseId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "collectionId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "documentId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "databasesDeleteDocument" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "databaseId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "databaseId" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "collectionId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "collectionId" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "documentId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "documentId" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "status" } }] } }] } }] };
|
|
@@ -187,7 +193,7 @@ var documents = {
|
|
|
187
193
|
"\n mutation UpdatePhoneVerification($userId: String!, $secret: String!) {\n accountUpdatePhoneVerification(userId: $userId, secret: $secret) {\n expire\n }\n }\n": UpdatePhoneVerificationDocument,
|
|
188
194
|
"\n mutation UpdatePrefs($prefs: JSON!) {\n accountUpdatePrefs(prefs: $prefs) {\n prefs {\n data\n }\n }\n }\n": UpdatePrefsDocument,
|
|
189
195
|
"\n mutation UpdateSession($sessionId: String!) {\n accountUpdateSession(sessionId: $sessionId) {\n userId\n expire\n current\n }\n }\n": UpdateSessionDocument,
|
|
190
|
-
"\n mutation UpdateVerification($userId: String!, $secret: String!) {\n accountUpdateVerification(userId: $userId, secret: $secret) {\n expire\n }\n }\n": UpdateVerificationDocument,
|
|
196
|
+
"\n mutation UpdateVerification($userId: String!, $secret: String!) {\n accountUpdateVerification(userId: $userId, secret: $secret) {\n secret\n expire\n userId\n }\n }\n": UpdateVerificationDocument,
|
|
191
197
|
"\n query ListDocuments($databaseId: String!, $collectionId: String!, $queries: [String!]) {\n databasesListDocuments(\n databaseId: $databaseId\n collectionId: $collectionId\n queries: $queries\n ) {\n total\n documents {\n _id\n data\n }\n }\n }\n": ListDocumentsDocument,
|
|
192
198
|
"\n mutation CreateDocument(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $data: JSON!\n $permissions: [String!]\n ) {\n databasesCreateDocument(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n data: $data\n permissions: $permissions\n ) {\n _id\n }\n }\n": CreateDocumentDocument,
|
|
193
199
|
"\n mutation DeleteDocument($databaseId: String!, $collectionId: String!, $documentId: String!) {\n databasesDeleteDocument(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n ) {\n status\n }\n }\n": DeleteDocumentDocument,
|
|
@@ -1576,7 +1582,9 @@ var updateVerification = gql(
|
|
|
1576
1582
|
`
|
|
1577
1583
|
mutation UpdateVerification($userId: String!, $secret: String!) {
|
|
1578
1584
|
accountUpdateVerification(userId: $userId, secret: $secret) {
|
|
1585
|
+
secret
|
|
1579
1586
|
expire
|
|
1587
|
+
userId
|
|
1580
1588
|
}
|
|
1581
1589
|
}
|
|
1582
1590
|
`
|
|
@@ -2088,8 +2096,89 @@ function useFunction() {
|
|
|
2088
2096
|
currentExecution: getExecution
|
|
2089
2097
|
};
|
|
2090
2098
|
}
|
|
2099
|
+
function useSuspenseFunction({
|
|
2100
|
+
functionId,
|
|
2101
|
+
body = {},
|
|
2102
|
+
async = false,
|
|
2103
|
+
path = "",
|
|
2104
|
+
method = "POST"
|
|
2105
|
+
}) {
|
|
2106
|
+
const { graphql: graphql2 } = useAppwrite();
|
|
2107
|
+
const [currentExecution, setCurrentExecution] = useState(null);
|
|
2108
|
+
const [currentFunction, setCurrentFunction] = useState(null);
|
|
2109
|
+
const executeFunction = useSuspenseQuery(
|
|
2110
|
+
{
|
|
2111
|
+
queryKey: ["appwrite", "functions", functionId],
|
|
2112
|
+
queryFn: async () => {
|
|
2113
|
+
setCurrentFunction(functionId);
|
|
2114
|
+
const { data } = await graphql2.mutation({
|
|
2115
|
+
query: createExecution,
|
|
2116
|
+
variables: {
|
|
2117
|
+
functionId,
|
|
2118
|
+
body: JSON.stringify(body),
|
|
2119
|
+
async,
|
|
2120
|
+
path,
|
|
2121
|
+
method
|
|
2122
|
+
// headers,
|
|
2123
|
+
}
|
|
2124
|
+
});
|
|
2125
|
+
let unsubscribe = null;
|
|
2126
|
+
const { _id, status, responseBody, errors } = data.functionsCreateExecution ?? {};
|
|
2127
|
+
if (status === "completed") {
|
|
2128
|
+
return JSON.parse(responseBody ?? "{}");
|
|
2129
|
+
}
|
|
2130
|
+
if (status === "failed" && errors) {
|
|
2131
|
+
throw new Error(errors);
|
|
2132
|
+
}
|
|
2133
|
+
setCurrentExecution(_id ?? null);
|
|
2134
|
+
const response = await new Promise((resolve, reject) => {
|
|
2135
|
+
unsubscribe = graphql2.client.subscribe(`executions.${_id}`, (event) => {
|
|
2136
|
+
switch (event.payload.status) {
|
|
2137
|
+
case "completed":
|
|
2138
|
+
setCurrentExecution(null);
|
|
2139
|
+
resolve(JSON.parse(event.payload.responseBody));
|
|
2140
|
+
break;
|
|
2141
|
+
case "failed":
|
|
2142
|
+
setCurrentExecution(null);
|
|
2143
|
+
reject(event.payload.errors);
|
|
2144
|
+
break;
|
|
2145
|
+
}
|
|
2146
|
+
return 1;
|
|
2147
|
+
});
|
|
2148
|
+
});
|
|
2149
|
+
unsubscribe?.();
|
|
2150
|
+
return response;
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
);
|
|
2154
|
+
const getExecution = useQuery({
|
|
2155
|
+
queryKey: ["appwrite", "functions", currentFunction, currentExecution],
|
|
2156
|
+
queryFn: async () => {
|
|
2157
|
+
if (!currentExecution || !currentFunction) {
|
|
2158
|
+
return null;
|
|
2159
|
+
}
|
|
2160
|
+
const { data } = await graphql2.query({
|
|
2161
|
+
query: getFunctionExecution,
|
|
2162
|
+
variables: {
|
|
2163
|
+
functionId: currentFunction,
|
|
2164
|
+
executionId: currentExecution
|
|
2165
|
+
}
|
|
2166
|
+
});
|
|
2167
|
+
return data.functionsGetExecution ?? {};
|
|
2168
|
+
}
|
|
2169
|
+
});
|
|
2170
|
+
return {
|
|
2171
|
+
executeFunction,
|
|
2172
|
+
currentExecution: getExecution
|
|
2173
|
+
};
|
|
2174
|
+
}
|
|
2091
2175
|
|
|
2092
2176
|
// src/account/fragments.ts
|
|
2177
|
+
var fragments_exports = {};
|
|
2178
|
+
__export(fragments_exports, {
|
|
2179
|
+
Account_UserFragment: () => Account_UserFragment,
|
|
2180
|
+
Identity_ProviderFragment: () => Identity_ProviderFragment
|
|
2181
|
+
});
|
|
2093
2182
|
var Account_UserFragment = gql(
|
|
2094
2183
|
/* GraphQL */
|
|
2095
2184
|
`
|
|
@@ -2115,8 +2204,7 @@ var Identity_ProviderFragment = gql(
|
|
|
2115
2204
|
|
|
2116
2205
|
// src/index.ts
|
|
2117
2206
|
var fragments = {
|
|
2118
|
-
|
|
2119
|
-
Identity_ProviderFragment
|
|
2207
|
+
...fragments_exports
|
|
2120
2208
|
};
|
|
2121
2209
|
export {
|
|
2122
2210
|
fragments,
|
|
@@ -2159,6 +2247,7 @@ export {
|
|
|
2159
2247
|
useSignUp,
|
|
2160
2248
|
useSuspenseCollection,
|
|
2161
2249
|
useSuspenseCreateJWT,
|
|
2250
|
+
useSuspenseFunction,
|
|
2162
2251
|
useUpdateDocument,
|
|
2163
2252
|
useUpdateEmail,
|
|
2164
2253
|
useUpdateMagicURLSession,
|