@lupinum/better-convex-nuxt 0.8.0-beta.40
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/LICENSE +21 -0
- package/LICENSES/Apache-2.0.txt +201 -0
- package/README.md +151 -0
- package/THIRD_PARTY_NOTICES.md +38 -0
- package/dist/module.d.mts +55 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +309 -0
- package/dist/runtime/auth/auth-identity.d.ts +31 -0
- package/dist/runtime/auth/auth-identity.js +21 -0
- package/dist/runtime/auth/better-auth-browser-adapter.d.ts +33 -0
- package/dist/runtime/auth/better-auth-browser-adapter.js +215 -0
- package/dist/runtime/auth/client-engine-types.d.ts +4 -0
- package/dist/runtime/auth/client-engine-types.js +0 -0
- package/dist/runtime/auth/integrated-client.d.ts +25 -0
- package/dist/runtime/auth/integrated-client.js +132 -0
- package/dist/runtime/auth/operation-tracker.d.ts +7 -0
- package/dist/runtime/auth/operation-tracker.js +14 -0
- package/dist/runtime/auth/session-synchronization.d.ts +23 -0
- package/dist/runtime/auth/session-synchronization.js +156 -0
- package/dist/runtime/auth/token-fetcher.d.ts +66 -0
- package/dist/runtime/auth/token-fetcher.js +131 -0
- package/dist/runtime/auth/validate-auth-client-definition.d.ts +12 -0
- package/dist/runtime/auth/validate-auth-client-definition.js +47 -0
- package/dist/runtime/auth-client/convex-client-plugin.d.ts +31 -0
- package/dist/runtime/auth-client/convex-client-plugin.js +14 -0
- package/dist/runtime/auth-client/definition-types.d.ts +6 -0
- package/dist/runtime/auth-client/definition-types.js +0 -0
- package/dist/runtime/auth-client/empty-definition.d.ts +2 -0
- package/dist/runtime/auth-client/empty-definition.js +2 -0
- package/dist/runtime/auth-client/index.d.ts +71 -0
- package/dist/runtime/auth-client/index.js +3 -0
- package/dist/runtime/cli/auth-schema.d.ts +2 -0
- package/dist/runtime/cli/auth-schema.js +169 -0
- package/dist/runtime/cli/convex.d.ts +11 -0
- package/dist/runtime/cli/convex.js +274 -0
- package/dist/runtime/composables/useConvex.d.ts +4 -0
- package/dist/runtime/composables/useConvex.js +9 -0
- package/dist/runtime/composables/useConvexAction.d.ts +4 -0
- package/dist/runtime/composables/useConvexAction.js +18 -0
- package/dist/runtime/composables/useConvexAttachment.d.ts +9 -0
- package/dist/runtime/composables/useConvexAttachment.js +14 -0
- package/dist/runtime/composables/useConvexAuth.d.ts +10 -0
- package/dist/runtime/composables/useConvexAuth.js +37 -0
- package/dist/runtime/composables/useConvexConfig.d.ts +12 -0
- package/dist/runtime/composables/useConvexConfig.js +7 -0
- package/dist/runtime/composables/useConvexConnectionState.d.ts +33 -0
- package/dist/runtime/composables/useConvexConnectionState.js +24 -0
- package/dist/runtime/composables/useConvexFileUpload.d.ts +169 -0
- package/dist/runtime/composables/useConvexFileUpload.js +198 -0
- package/dist/runtime/composables/useConvexMutation.d.ts +13 -0
- package/dist/runtime/composables/useConvexMutation.js +24 -0
- package/dist/runtime/composables/useConvexPaginatedQuery.d.ts +13 -0
- package/dist/runtime/composables/useConvexPaginatedQuery.js +256 -0
- package/dist/runtime/composables/useConvexQuery.d.ts +19 -0
- package/dist/runtime/composables/useConvexQuery.js +308 -0
- package/dist/runtime/convex-auth/adapter/create-adapter.d.ts +33 -0
- package/dist/runtime/convex-auth/adapter/create-adapter.js +308 -0
- package/dist/runtime/convex-auth/adapter/define-functions.d.ts +160 -0
- package/dist/runtime/convex-auth/adapter/define-functions.js +497 -0
- package/dist/runtime/convex-auth/adapter/generate-schema.d.ts +16 -0
- package/dist/runtime/convex-auth/adapter/generate-schema.js +332 -0
- package/dist/runtime/convex-auth/adapter/metadata.d.ts +44 -0
- package/dist/runtime/convex-auth/adapter/metadata.js +91 -0
- package/dist/runtime/convex-auth/adapter/query.d.ts +32 -0
- package/dist/runtime/convex-auth/adapter/query.js +275 -0
- package/dist/runtime/convex-auth/adapter/relationships.d.ts +20 -0
- package/dist/runtime/convex-auth/adapter/relationships.js +128 -0
- package/dist/runtime/convex-auth/component/_generated/api.js +5 -0
- package/dist/runtime/convex-auth/component/_generated/component.d.ts +116 -0
- package/dist/runtime/convex-auth/component/_generated/component.js +0 -0
- package/dist/runtime/convex-auth/component/_generated/dataModel.js +0 -0
- package/dist/runtime/convex-auth/component/_generated/server.js +16 -0
- package/dist/runtime/convex-auth/component/adapter.d.ts +142 -0
- package/dist/runtime/convex-auth/component/adapter.js +16 -0
- package/dist/runtime/convex-auth/component/convex.config.d.ts +2 -0
- package/dist/runtime/convex-auth/component/convex.config.js +3 -0
- package/dist/runtime/convex-auth/component/schema.d.ts +799 -0
- package/dist/runtime/convex-auth/component/schema.js +180 -0
- package/dist/runtime/convex-auth/component/schemaMetadata.d.ts +2094 -0
- package/dist/runtime/convex-auth/component/schemaMetadata.js +2161 -0
- package/dist/runtime/convex-auth/context.d.ts +5 -0
- package/dist/runtime/convex-auth/context.js +8 -0
- package/dist/runtime/convex-auth/create-auth-component.d.ts +41 -0
- package/dist/runtime/convex-auth/create-auth-component.js +157 -0
- package/dist/runtime/convex-auth/index.d.ts +11 -0
- package/dist/runtime/convex-auth/index.js +7 -0
- package/dist/runtime/convex-auth/internal-session.d.ts +2 -0
- package/dist/runtime/convex-auth/internal-session.js +1 -0
- package/dist/runtime/convex-auth/jwks-rotation.d.ts +58 -0
- package/dist/runtime/convex-auth/jwks-rotation.js +163 -0
- package/dist/runtime/convex-auth/oauth-live-access.d.ts +17 -0
- package/dist/runtime/convex-auth/oauth-live-access.js +78 -0
- package/dist/runtime/convex-auth/oauth-provider-compat.d.ts +10 -0
- package/dist/runtime/convex-auth/oauth-provider-compat.js +170 -0
- package/dist/runtime/convex-auth/oauth-resource.d.ts +39 -0
- package/dist/runtime/convex-auth/oauth-resource.js +118 -0
- package/dist/runtime/convex-auth/oauth-security.d.ts +82 -0
- package/dist/runtime/convex-auth/oauth-security.js +454 -0
- package/dist/runtime/convex-auth/origin.d.ts +4 -0
- package/dist/runtime/convex-auth/origin.js +9 -0
- package/dist/runtime/convex-auth/plugin.d.ts +18 -0
- package/dist/runtime/convex-auth/plugin.js +605 -0
- package/dist/runtime/convex-auth/provider.d.ts +2 -0
- package/dist/runtime/convex-auth/provider.js +11 -0
- package/dist/runtime/convex-auth/test.d.ts +410 -0
- package/dist/runtime/convex-auth/test.js +9 -0
- package/dist/runtime/convex-auth/types.d.ts +18 -0
- package/dist/runtime/convex-auth/types.js +0 -0
- package/dist/runtime/convex-auth/user-projection.d.ts +106 -0
- package/dist/runtime/convex-auth/user-projection.js +128 -0
- package/dist/runtime/devtools/auth-proxy-registry.d.ts +4 -0
- package/dist/runtime/devtools/auth-proxy-registry.js +47 -0
- package/dist/runtime/devtools/bridge-setup.d.ts +21 -0
- package/dist/runtime/devtools/bridge-setup.js +165 -0
- package/dist/runtime/devtools/path-utils.d.ts +2 -0
- package/dist/runtime/devtools/path-utils.js +12 -0
- package/dist/runtime/devtools/server.d.ts +2 -0
- package/dist/runtime/devtools/server.js +108 -0
- package/dist/runtime/devtools/setup-client.d.ts +16 -0
- package/dist/runtime/devtools/setup-client.js +43 -0
- package/dist/runtime/devtools/sink.d.ts +18 -0
- package/dist/runtime/devtools/sink.js +110 -0
- package/dist/runtime/devtools/transport.d.ts +16 -0
- package/dist/runtime/devtools/transport.js +149 -0
- package/dist/runtime/devtools/types.d.ts +167 -0
- package/dist/runtime/devtools/types.js +1 -0
- package/dist/runtime/devtools/ui/dist/200.html +1 -0
- package/dist/runtime/devtools/ui/dist/404.html +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/C4MASuCh.js +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/DJHkqtZq.js +3 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/DWwrCltl.js +2 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/DZ_UiYoH.js +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/_m9ujb-i.js +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/builds/latest.json +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/builds/meta/better-convex-nuxt-devtools.json +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/entry.DpFDKYZ5.css +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/error-404.DYUJo5xt.css +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/error-500.DQdoJJXg.css +1 -0
- package/dist/runtime/devtools/ui/dist/convex-logo.svg +5 -0
- package/dist/runtime/devtools/ui/dist/index.html +1 -0
- package/dist/runtime/errors/index.d.ts +7 -0
- package/dist/runtime/errors/index.js +5 -0
- package/dist/runtime/middleware/convex-auth.global.d.ts +2 -0
- package/dist/runtime/middleware/convex-auth.global.js +31 -0
- package/dist/runtime/plugin.auth.client.d.ts +3 -0
- package/dist/runtime/plugin.auth.client.js +217 -0
- package/dist/runtime/plugin.client.d.ts +3 -0
- package/dist/runtime/plugin.client.js +43 -0
- package/dist/runtime/plugin.server.d.ts +12 -0
- package/dist/runtime/plugin.server.js +98 -0
- package/dist/runtime/plugins/convex-call-error-payload.d.ts +14 -0
- package/dist/runtime/plugins/convex-call-error-payload.js +12 -0
- package/dist/runtime/runtime-context.d.ts +26 -0
- package/dist/runtime/runtime-context.js +48 -0
- package/dist/runtime/server/api/auth/[...].d.ts +10 -0
- package/dist/runtime/server/api/auth/[...].js +509 -0
- package/dist/runtime/server/api/auth/authorization-server-metadata.d.ts +2 -0
- package/dist/runtime/server/api/auth/authorization-server-metadata.js +6 -0
- package/dist/runtime/server/api/auth/body-size.d.ts +15 -0
- package/dist/runtime/server/api/auth/body-size.js +179 -0
- package/dist/runtime/server/api/auth/headers.d.ts +6 -0
- package/dist/runtime/server/api/auth/headers.js +98 -0
- package/dist/runtime/server/api/auth/jwks.d.ts +2 -0
- package/dist/runtime/server/api/auth/jwks.js +6 -0
- package/dist/runtime/server/api/auth/security.d.ts +14 -0
- package/dist/runtime/server/api/auth/security.js +85 -0
- package/dist/runtime/server/api/release-fingerprint.d.ts +2 -0
- package/dist/runtime/server/api/release-fingerprint.js +36 -0
- package/dist/runtime/server/index.d.ts +1 -0
- package/dist/runtime/server/index.js +3 -0
- package/dist/runtime/server/plugins/runtime-config.d.ts +7 -0
- package/dist/runtime/server/plugins/runtime-config.js +7 -0
- package/dist/runtime/server/utils/auth-snapshot.d.ts +26 -0
- package/dist/runtime/server/utils/auth-snapshot.js +165 -0
- package/dist/runtime/server/utils/http.d.ts +16 -0
- package/dist/runtime/server/utils/http.js +133 -0
- package/dist/runtime/server/utils/server-convex-caller.d.ts +31 -0
- package/dist/runtime/server/utils/server-convex-caller.js +151 -0
- package/dist/runtime/server/utils/server-convex-options.d.ts +83 -0
- package/dist/runtime/server/utils/server-convex-options.js +69 -0
- package/dist/runtime/server/utils/signed-client-ip.d.ts +6 -0
- package/dist/runtime/server/utils/signed-client-ip.js +29 -0
- package/dist/runtime/server/utils/ssr-auth-headers.d.ts +26 -0
- package/dist/runtime/server/utils/ssr-auth-headers.js +49 -0
- package/dist/runtime/server/utils/token-exchange.d.ts +27 -0
- package/dist/runtime/server/utils/token-exchange.js +96 -0
- package/dist/runtime/shared/auth-cookie.d.ts +4 -0
- package/dist/runtime/shared/auth-cookie.js +25 -0
- package/dist/runtime/shared/auth-origin.d.ts +15 -0
- package/dist/runtime/shared/auth-origin.js +42 -0
- package/dist/runtime/shared/bounded-stream.d.ts +2 -0
- package/dist/runtime/shared/bounded-stream.js +50 -0
- package/dist/runtime/shared/client-ip.d.ts +21 -0
- package/dist/runtime/shared/client-ip.js +123 -0
- package/dist/runtime/shared/release-fingerprint.d.ts +5 -0
- package/dist/runtime/shared/release-fingerprint.js +17 -0
- package/dist/runtime/types.d.ts +19 -0
- package/dist/runtime/utils/auth-config.d.ts +24 -0
- package/dist/runtime/utils/auth-config.js +45 -0
- package/dist/runtime/utils/auth-contract.d.ts +22 -0
- package/dist/runtime/utils/auth-contract.js +0 -0
- package/dist/runtime/utils/auth-errors.d.ts +5 -0
- package/dist/runtime/utils/auth-errors.js +22 -0
- package/dist/runtime/utils/auth-identity-state.d.ts +4 -0
- package/dist/runtime/utils/auth-identity-state.js +8 -0
- package/dist/runtime/utils/auth-pending-state.d.ts +13 -0
- package/dist/runtime/utils/auth-pending-state.js +4 -0
- package/dist/runtime/utils/auth-pending.d.ts +10 -0
- package/dist/runtime/utils/auth-pending.js +30 -0
- package/dist/runtime/utils/auth-route-protection.d.ts +16 -0
- package/dist/runtime/utils/auth-route-protection.js +58 -0
- package/dist/runtime/utils/auth-status.d.ts +47 -0
- package/dist/runtime/utils/auth-status.js +8 -0
- package/dist/runtime/utils/bounded-convex-fetch.d.ts +18 -0
- package/dist/runtime/utils/bounded-convex-fetch.js +152 -0
- package/dist/runtime/utils/callable-devtools.d.ts +17 -0
- package/dist/runtime/utils/callable-devtools.js +49 -0
- package/dist/runtime/utils/callable-observer.d.ts +2 -0
- package/dist/runtime/utils/callable-observer.js +1 -0
- package/dist/runtime/utils/composable-scope.d.ts +2 -0
- package/dist/runtime/utils/composable-scope.js +8 -0
- package/dist/runtime/utils/config-defaults.d.ts +8 -0
- package/dist/runtime/utils/config-defaults.js +8 -0
- package/dist/runtime/utils/convex-cache.d.ts +68 -0
- package/dist/runtime/utils/convex-cache.js +47 -0
- package/dist/runtime/utils/convex-config.d.ts +16 -0
- package/dist/runtime/utils/convex-config.js +50 -0
- package/dist/runtime/utils/convex-shared.d.ts +67 -0
- package/dist/runtime/utils/convex-shared.js +134 -0
- package/dist/runtime/utils/identity-changed-error.d.ts +4 -0
- package/dist/runtime/utils/identity-changed-error.js +12 -0
- package/dist/runtime/utils/identity-key.d.ts +19 -0
- package/dist/runtime/utils/identity-key.js +10 -0
- package/dist/runtime/utils/integrated-auth-client.d.ts +5 -0
- package/dist/runtime/utils/integrated-auth-client.js +0 -0
- package/dist/runtime/utils/logger.d.ts +42 -0
- package/dist/runtime/utils/logger.js +190 -0
- package/dist/runtime/utils/mime-type.d.ts +33 -0
- package/dist/runtime/utils/mime-type.js +10 -0
- package/dist/runtime/utils/query-execution-gate.d.ts +47 -0
- package/dist/runtime/utils/query-execution-gate.js +63 -0
- package/dist/runtime/utils/query-execution.d.ts +8 -0
- package/dist/runtime/utils/query-execution.js +19 -0
- package/dist/runtime/utils/query-foundation.d.ts +20 -0
- package/dist/runtime/utils/query-foundation.js +39 -0
- package/dist/runtime/utils/query-state.d.ts +12 -0
- package/dist/runtime/utils/query-state.js +12 -0
- package/dist/runtime/utils/reactive-args.d.ts +5 -0
- package/dist/runtime/utils/reactive-args.js +42 -0
- package/dist/runtime/utils/runtime-config-normalize.d.ts +22 -0
- package/dist/runtime/utils/runtime-config-normalize.js +28 -0
- package/dist/runtime/utils/runtime-config.d.ts +4 -0
- package/dist/runtime/utils/runtime-config.js +8 -0
- package/dist/runtime/utils/sanitize-diagnostic.d.ts +6 -0
- package/dist/runtime/utils/sanitize-diagnostic.js +81 -0
- package/dist/runtime/utils/shared-helpers.d.ts +46 -0
- package/dist/runtime/utils/shared-helpers.js +139 -0
- package/dist/runtime/utils/site-url.d.ts +4 -0
- package/dist/runtime/utils/site-url.js +15 -0
- package/dist/runtime/utils/ssr-pagination-state.d.ts +3 -0
- package/dist/runtime/utils/ssr-pagination-state.js +3 -0
- package/dist/runtime/utils/types.d.ts +29 -0
- package/dist/runtime/utils/types.js +0 -0
- package/dist/runtime/utils/upload-core.d.ts +16 -0
- package/dist/runtime/utils/upload-core.js +116 -0
- package/dist/types.d.mts +21 -0
- package/package.json +253 -0
- package/security/upstream-convex-better-auth.json +477 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { mergedStream, stream } from "convex-helpers/server/stream";
|
|
2
|
+
import { getAuthFieldMetadata, getAuthModelMetadata } from "./metadata.js";
|
|
3
|
+
function compareNullable(left, right) {
|
|
4
|
+
if (left === right) return 0;
|
|
5
|
+
if (left === null || left === void 0) return -1;
|
|
6
|
+
if (right === null || right === void 0) return 1;
|
|
7
|
+
if (typeof left === "number" && typeof right === "number") return left < right ? -1 : 1;
|
|
8
|
+
if (typeof left === "string" && typeof right === "string") return left < right ? -1 : 1;
|
|
9
|
+
if (typeof left === "boolean" && typeof right === "boolean") return left === false ? -1 : 1;
|
|
10
|
+
return String(left).localeCompare(String(right));
|
|
11
|
+
}
|
|
12
|
+
export function matchesAuthWhere(doc, where = []) {
|
|
13
|
+
if (where.length === 0) return true;
|
|
14
|
+
const evaluate = (clause) => {
|
|
15
|
+
const actual = doc[clause.field];
|
|
16
|
+
const expected = clause.value;
|
|
17
|
+
const insensitive = clause.mode === "insensitive";
|
|
18
|
+
const normalize = (value) => insensitive && typeof value === "string" ? value.toLocaleLowerCase() : value;
|
|
19
|
+
const normalizedActual = normalize(actual);
|
|
20
|
+
const normalizedExpected = Array.isArray(expected) ? expected.map((value) => normalize(value)) : normalize(expected);
|
|
21
|
+
switch (clause.operator ?? "eq") {
|
|
22
|
+
case "eq":
|
|
23
|
+
return expected === null ? actual === null || actual === void 0 : normalizedActual === normalizedExpected;
|
|
24
|
+
case "ne":
|
|
25
|
+
return normalizedActual !== normalizedExpected;
|
|
26
|
+
case "lt":
|
|
27
|
+
return expected !== null && compareNullable(actual, expected) < 0;
|
|
28
|
+
case "lte":
|
|
29
|
+
return expected !== null && compareNullable(actual, expected) <= 0;
|
|
30
|
+
case "gt":
|
|
31
|
+
return expected !== null && compareNullable(actual, expected) > 0;
|
|
32
|
+
case "gte":
|
|
33
|
+
return expected !== null && compareNullable(actual, expected) >= 0;
|
|
34
|
+
case "in":
|
|
35
|
+
return Array.isArray(normalizedExpected) && normalizedExpected.includes(normalizedActual);
|
|
36
|
+
case "not_in":
|
|
37
|
+
return Array.isArray(normalizedExpected) && !normalizedExpected.includes(normalizedActual);
|
|
38
|
+
case "contains":
|
|
39
|
+
return typeof normalizedActual === "string" && typeof normalizedExpected === "string" && normalizedActual.includes(normalizedExpected);
|
|
40
|
+
case "starts_with":
|
|
41
|
+
return typeof normalizedActual === "string" && typeof normalizedExpected === "string" && normalizedActual.startsWith(normalizedExpected);
|
|
42
|
+
case "ends_with":
|
|
43
|
+
return typeof normalizedActual === "string" && typeof normalizedExpected === "string" && normalizedActual.endsWith(normalizedExpected);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
let result = evaluate(where[0]);
|
|
47
|
+
for (const clause of where.slice(1)) {
|
|
48
|
+
const clauseResult = evaluate(clause);
|
|
49
|
+
result = clause.connector === "OR" ? result || clauseResult : result && clauseResult;
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
export function validateAuthReadArgs(metadata, args) {
|
|
54
|
+
const model = getAuthModelMetadata(metadata, args.model);
|
|
55
|
+
if (args.offset !== void 0 && args.offset !== 0) throw new Error("AUTH_OFFSET_UNSUPPORTED");
|
|
56
|
+
for (const clause of args.where ?? []) {
|
|
57
|
+
const field = getAuthFieldMetadata(metadata, args.model, clause.field);
|
|
58
|
+
if (clause.mode === "insensitive" && typeof clause.value !== "string" && !(Array.isArray(clause.value) && clause.value.every((value) => typeof value === "string"))) {
|
|
59
|
+
throw new Error(`AUTH_CASE_INSENSITIVE_VALUE_INVALID:${args.model}.${field.physicalName}`);
|
|
60
|
+
}
|
|
61
|
+
if ((clause.operator === "in" || clause.operator === "not_in") && !Array.isArray(clause.value)) {
|
|
62
|
+
throw new Error(`AUTH_ARRAY_OPERATOR_REQUIRES_ARRAY:${args.model}.${field.physicalName}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
for (const fieldName of args.select ?? []) getAuthFieldMetadata(metadata, args.model, fieldName);
|
|
66
|
+
if (args.sortBy) {
|
|
67
|
+
const field = getAuthFieldMetadata(metadata, args.model, args.sortBy.field);
|
|
68
|
+
if (!field.sortable && field.physicalName !== "createdAt") {
|
|
69
|
+
throw new Error(`AUTH_FIELD_NOT_SORTABLE:${model.physicalName}.${field.physicalName}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const AUTH_IN_FANOUT_LIMIT = 64;
|
|
74
|
+
function chooseExactIndexedIn(model, where, sortBy) {
|
|
75
|
+
if (sortBy || where.some((clause2) => clause2.connector === "OR" || clause2.mode === "insensitive")) {
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
const clauses = where.filter((clause2) => clause2.operator === "in");
|
|
79
|
+
if (clauses.length !== 1) return void 0;
|
|
80
|
+
const clause = clauses[0];
|
|
81
|
+
if (!Array.isArray(clause.value)) return void 0;
|
|
82
|
+
const index = model.indexes.find(
|
|
83
|
+
(candidate) => candidate.fields.length === 1 && candidate.fields[0] === clause.field
|
|
84
|
+
);
|
|
85
|
+
if (!index) return void 0;
|
|
86
|
+
if (clause.value.length > AUTH_IN_FANOUT_LIMIT) {
|
|
87
|
+
throw new Error("AUTH_IN_FANOUT_LIMIT_EXCEEDED");
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
clause,
|
|
91
|
+
index
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function planForIndex(index, where) {
|
|
95
|
+
const equality = [];
|
|
96
|
+
let range;
|
|
97
|
+
let prefix = 0;
|
|
98
|
+
for (const field of index.fields) {
|
|
99
|
+
const eq = where.find(
|
|
100
|
+
(clause) => clause.field === field && (clause.operator === void 0 || clause.operator === "eq")
|
|
101
|
+
);
|
|
102
|
+
if (eq) {
|
|
103
|
+
equality.push(eq);
|
|
104
|
+
prefix += 1;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
range = where.find(
|
|
108
|
+
(clause) => clause.field === field && (clause.operator === "lt" || clause.operator === "lte" || clause.operator === "gt" || clause.operator === "gte")
|
|
109
|
+
);
|
|
110
|
+
if (range) prefix += 1;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
if (prefix === 0) return void 0;
|
|
114
|
+
return { index, equality, range, score: prefix * 10 + equality.length };
|
|
115
|
+
}
|
|
116
|
+
function chooseIndex(model, where) {
|
|
117
|
+
if (where.some((clause) => clause.connector === "OR" || clause.mode === "insensitive")) {
|
|
118
|
+
return void 0;
|
|
119
|
+
}
|
|
120
|
+
return model.indexes.map((index) => planForIndex(index, where)).filter((plan) => plan !== void 0).sort((left, right) => right.score - left.score)[0];
|
|
121
|
+
}
|
|
122
|
+
function planForSortIndex(index, where, sortField) {
|
|
123
|
+
if (index.fields.at(-1) !== sortField) return void 0;
|
|
124
|
+
const equality = [];
|
|
125
|
+
for (const field of index.fields.slice(0, -1)) {
|
|
126
|
+
const clause = where.find(
|
|
127
|
+
(candidate) => candidate.field === field && (candidate.operator === void 0 || candidate.operator === "eq")
|
|
128
|
+
);
|
|
129
|
+
if (!clause) return void 0;
|
|
130
|
+
equality.push(clause);
|
|
131
|
+
}
|
|
132
|
+
const range = where.find(
|
|
133
|
+
(clause) => clause.field === sortField && (clause.operator === "lt" || clause.operator === "lte" || clause.operator === "gt" || clause.operator === "gte")
|
|
134
|
+
);
|
|
135
|
+
return {
|
|
136
|
+
index,
|
|
137
|
+
equality,
|
|
138
|
+
range,
|
|
139
|
+
score: index.fields.length * 10 + equality.length
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function chooseSortIndex(model, where, sortField) {
|
|
143
|
+
const filterOnly = where.some(
|
|
144
|
+
(clause) => clause.connector === "OR" || clause.mode === "insensitive"
|
|
145
|
+
);
|
|
146
|
+
return model.indexes.filter((index) => !filterOnly || index.fields.length === 1).map((index) => planForSortIndex(index, filterOnly ? [] : where, sortField)).filter((plan) => plan !== void 0).sort((left, right) => right.score - left.score)[0];
|
|
147
|
+
}
|
|
148
|
+
function applyIndexRange(builder, plan) {
|
|
149
|
+
let result = builder;
|
|
150
|
+
for (const clause of plan.equality) result = result.eq(clause.field, clause.value);
|
|
151
|
+
if (!plan.range) return result;
|
|
152
|
+
switch (plan.range.operator) {
|
|
153
|
+
case "lt":
|
|
154
|
+
return result.lt(plan.range.field, plan.range.value);
|
|
155
|
+
case "lte":
|
|
156
|
+
return result.lte(plan.range.field, plan.range.value);
|
|
157
|
+
case "gt":
|
|
158
|
+
return result.gt(plan.range.field, plan.range.value);
|
|
159
|
+
case "gte":
|
|
160
|
+
return result.gte(plan.range.field, plan.range.value);
|
|
161
|
+
default:
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function createAuthQuery(ctx, schema, metadata, args) {
|
|
166
|
+
validateAuthReadArgs(metadata, args);
|
|
167
|
+
const model = getAuthModelMetadata(metadata, args.model);
|
|
168
|
+
const exactIndexedIn = chooseExactIndexedIn(model, args.where ?? [], args.sortBy);
|
|
169
|
+
if (exactIndexedIn && exactIndexedIn.clause.value.length > 0) {
|
|
170
|
+
const values = [...new Set(exactIndexedIn.clause.value)];
|
|
171
|
+
const streams = values.map(
|
|
172
|
+
(value) => stream(ctx.db, schema).query(args.model).withIndex(
|
|
173
|
+
exactIndexedIn.index.descriptor,
|
|
174
|
+
(builder) => builder.eq(exactIndexedIn.clause.field, value)
|
|
175
|
+
)
|
|
176
|
+
);
|
|
177
|
+
return mergedStream(streams, ["_creationTime"]).filterWith(
|
|
178
|
+
async (doc) => matchesAuthWhere(doc, args.where ?? [])
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
const plan = chooseIndex(model, args.where ?? []);
|
|
182
|
+
let query = stream(ctx.db, schema).query(args.model);
|
|
183
|
+
if (plan) {
|
|
184
|
+
query = query.withIndex(
|
|
185
|
+
plan.index.descriptor,
|
|
186
|
+
(builder) => applyIndexRange(builder, plan)
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
if (args.sortBy) {
|
|
190
|
+
const sortPlan = chooseSortIndex(model, args.where ?? [], args.sortBy.field);
|
|
191
|
+
if (!sortPlan) {
|
|
192
|
+
throw new Error(`AUTH_SORT_INDEX_MISSING:${args.model}.${args.sortBy.field}`);
|
|
193
|
+
}
|
|
194
|
+
query = stream(ctx.db, schema).query(args.model).withIndex(
|
|
195
|
+
sortPlan.index.descriptor,
|
|
196
|
+
(builder) => applyIndexRange(builder, sortPlan)
|
|
197
|
+
).order(args.sortBy.direction);
|
|
198
|
+
}
|
|
199
|
+
return query.filterWith(
|
|
200
|
+
async (doc) => matchesAuthWhere(doc, args.where ?? [])
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
export function toBetterAuthDocument(doc, select) {
|
|
204
|
+
if (!doc) return null;
|
|
205
|
+
const clean = Object.fromEntries(
|
|
206
|
+
Object.entries(doc).filter(([field]) => field !== "_id" && field !== "_creationTime")
|
|
207
|
+
);
|
|
208
|
+
if (!select?.length) return clean;
|
|
209
|
+
return Object.fromEntries(
|
|
210
|
+
select.filter((field) => field in clean).map((field) => [field, clean[field]])
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
export async function paginateAuthRows(ctx, schema, metadata, args, paginationOpts) {
|
|
214
|
+
const result = await createAuthQuery(ctx, schema, metadata, args).paginate({
|
|
215
|
+
...paginationOpts,
|
|
216
|
+
maximumRowsRead: Math.max((paginationOpts.numItems ?? 0) + 1, 200)
|
|
217
|
+
});
|
|
218
|
+
return {
|
|
219
|
+
...result,
|
|
220
|
+
page: result.page.map((doc) => toBetterAuthDocument(doc, args.select))
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
export async function collectAuthRows(ctx, schema, metadata, args, maximum) {
|
|
224
|
+
if (maximum !== void 0 && (!Number.isSafeInteger(maximum) || maximum < 0)) {
|
|
225
|
+
throw new TypeError("AUTH_QUERY_LIMIT_INVALID");
|
|
226
|
+
}
|
|
227
|
+
const rows = [];
|
|
228
|
+
let cursor = null;
|
|
229
|
+
do {
|
|
230
|
+
const requested = maximum === void 0 ? 100 : Math.min(100, maximum + 1 - rows.length);
|
|
231
|
+
const page = await createAuthQuery(ctx, schema, metadata, args).paginate({
|
|
232
|
+
cursor,
|
|
233
|
+
numItems: requested,
|
|
234
|
+
maximumRowsRead: 200
|
|
235
|
+
});
|
|
236
|
+
rows.push(...page.page);
|
|
237
|
+
if (maximum !== void 0 && rows.length > maximum) {
|
|
238
|
+
throw new Error(`AUTH_QUERY_LIMIT_EXCEEDED:${maximum}`);
|
|
239
|
+
}
|
|
240
|
+
if (page.isDone) {
|
|
241
|
+
cursor = null;
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (typeof page.continueCursor !== "string" || page.continueCursor === cursor) {
|
|
245
|
+
throw new Error("AUTH_QUERY_PAGINATION_STALLED");
|
|
246
|
+
}
|
|
247
|
+
cursor = page.continueCursor;
|
|
248
|
+
} while (cursor !== null);
|
|
249
|
+
return rows;
|
|
250
|
+
}
|
|
251
|
+
export async function countAuthRows(ctx, schema, metadata, args) {
|
|
252
|
+
let count = 0;
|
|
253
|
+
let cursor = null;
|
|
254
|
+
while (true) {
|
|
255
|
+
const cursorBefore = cursor;
|
|
256
|
+
const page = await createAuthQuery(ctx, schema, metadata, args).paginate({
|
|
257
|
+
cursor,
|
|
258
|
+
numItems: 100,
|
|
259
|
+
maximumRowsRead: 200
|
|
260
|
+
});
|
|
261
|
+
count += page.page.length;
|
|
262
|
+
if (page.isDone) return count;
|
|
263
|
+
if (typeof page.continueCursor !== "string") {
|
|
264
|
+
throw new TypeError("AUTH_COUNT_PAGINATION_INVALID");
|
|
265
|
+
}
|
|
266
|
+
cursor = page.continueCursor;
|
|
267
|
+
if (cursor === cursorBefore && page.page.length === 0) {
|
|
268
|
+
throw new Error("AUTH_COUNT_PAGINATION_STALLED");
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
export async function findAuthRows(ctx, schema, metadata, args, maximum = 2) {
|
|
273
|
+
const rows = await collectAuthRows(ctx, schema, metadata, args, maximum);
|
|
274
|
+
return rows;
|
|
275
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SchemaDefinition } from 'convex/server';
|
|
2
|
+
import type { AuthSchemaMetadata } from './metadata.js';
|
|
3
|
+
import { collectAuthRows } from './query.js';
|
|
4
|
+
interface RelationshipTriggerHandles {
|
|
5
|
+
onDeleteHandle?: string;
|
|
6
|
+
onDeleteModels?: readonly string[];
|
|
7
|
+
onUpdateHandle?: string;
|
|
8
|
+
onUpdateModels?: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
type TriggerRunner = (ctx: any, handle: string | undefined, payload: Record<string, unknown>) => Promise<void>;
|
|
11
|
+
export declare function createAuthRelationshipEngine(input: {
|
|
12
|
+
schema: SchemaDefinition<any, any>;
|
|
13
|
+
metadata: AuthSchemaMetadata;
|
|
14
|
+
runTrigger: TriggerRunner;
|
|
15
|
+
}): Readonly<{
|
|
16
|
+
applyDeletion: (ctx: any, roots: Record<string, unknown>[], rootModel: string, handles: RelationshipTriggerHandles) => Promise<void>;
|
|
17
|
+
assertTargets: (ctx: any, modelName: string, row: Record<string, unknown>, changedFields?: ReadonlySet<string>) => Promise<void>;
|
|
18
|
+
collectOperationRows: (ctx: any, args: Parameters<typeof collectAuthRows>[3]) => Promise<Record<string, unknown>[]>;
|
|
19
|
+
}>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { getAuthModelMetadata } from "./metadata.js";
|
|
2
|
+
import { collectAuthRows, findAuthRows, toBetterAuthDocument } from "./query.js";
|
|
3
|
+
const AUTH_BULK_OPERATION_LIMIT = 128;
|
|
4
|
+
function rejectOversizedOperation() {
|
|
5
|
+
throw new Error("AUTH_BULK_OPERATION_LIMIT_EXCEEDED");
|
|
6
|
+
}
|
|
7
|
+
function plannedRow(model, row) {
|
|
8
|
+
return { key: `${model}:${String(row._id)}`, model, row };
|
|
9
|
+
}
|
|
10
|
+
export function createAuthRelationshipEngine(input) {
|
|
11
|
+
const { schema, metadata, runTrigger } = input;
|
|
12
|
+
const inboundByModel = /* @__PURE__ */ new Map();
|
|
13
|
+
for (const model of Object.values(metadata.models)) {
|
|
14
|
+
for (const field of Object.values(model.fields)) {
|
|
15
|
+
if (!field.reference) continue;
|
|
16
|
+
const inbound = inboundByModel.get(field.reference.model) ?? [];
|
|
17
|
+
inbound.push({ model: model.physicalName, field });
|
|
18
|
+
inboundByModel.set(field.reference.model, inbound);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async function assertTargets(ctx, modelName, row, changedFields) {
|
|
22
|
+
const model = getAuthModelMetadata(metadata, modelName);
|
|
23
|
+
for (const field of Object.values(model.fields)) {
|
|
24
|
+
if (!field.reference || changedFields && !changedFields.has(field.physicalName)) continue;
|
|
25
|
+
const value = row[field.physicalName];
|
|
26
|
+
if (value === null) continue;
|
|
27
|
+
const matches = await findAuthRows(
|
|
28
|
+
ctx,
|
|
29
|
+
schema,
|
|
30
|
+
metadata,
|
|
31
|
+
{
|
|
32
|
+
model: field.reference.model,
|
|
33
|
+
where: [{ field: field.reference.field, value }]
|
|
34
|
+
},
|
|
35
|
+
2
|
|
36
|
+
);
|
|
37
|
+
if (matches.length === 0) {
|
|
38
|
+
throw new Error(`AUTH_REFERENCE_TARGET_MISSING:${modelName}.${field.physicalName}`);
|
|
39
|
+
}
|
|
40
|
+
if (matches.length > 1) {
|
|
41
|
+
throw new Error(`AUTH_REFERENCE_TARGET_AMBIGUOUS:${modelName}.${field.physicalName}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async function findReferencingRows(ctx, parent, childModel, childField) {
|
|
46
|
+
const parentField = childField.reference.field;
|
|
47
|
+
return collectOperationRows(ctx, {
|
|
48
|
+
model: childModel,
|
|
49
|
+
where: [{ field: childField.physicalName, value: parent.row[parentField] }]
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async function collectOperationRows(ctx, args) {
|
|
53
|
+
try {
|
|
54
|
+
return await collectAuthRows(ctx, schema, metadata, args, AUTH_BULK_OPERATION_LIMIT);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (error instanceof Error && error.message === `AUTH_QUERY_LIMIT_EXCEEDED:${AUTH_BULK_OPERATION_LIMIT}`) {
|
|
57
|
+
rejectOversizedOperation();
|
|
58
|
+
}
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function applyDeletion(ctx, roots, rootModel, handles) {
|
|
63
|
+
const visited = /* @__PURE__ */ new Set();
|
|
64
|
+
const deletionOrder = [];
|
|
65
|
+
const deleteTriggerModels = new Set(handles.onDeleteModels ?? []);
|
|
66
|
+
const updateTriggerModels = new Set(handles.onUpdateModels ?? []);
|
|
67
|
+
const collectCascade = async (candidate) => {
|
|
68
|
+
if (visited.has(candidate.key)) return;
|
|
69
|
+
if (visited.size === AUTH_BULK_OPERATION_LIMIT) rejectOversizedOperation();
|
|
70
|
+
visited.add(candidate.key);
|
|
71
|
+
for (const inbound of inboundByModel.get(candidate.model) ?? []) {
|
|
72
|
+
if (inbound.field.reference.onDelete !== "cascade") continue;
|
|
73
|
+
const children = await findReferencingRows(ctx, candidate, inbound.model, inbound.field);
|
|
74
|
+
for (const child of children) await collectCascade(plannedRow(inbound.model, child));
|
|
75
|
+
}
|
|
76
|
+
deletionOrder.push(candidate);
|
|
77
|
+
};
|
|
78
|
+
for (const root of roots) await collectCascade(plannedRow(rootModel, root));
|
|
79
|
+
const setNullPatches = /* @__PURE__ */ new Map();
|
|
80
|
+
for (const candidate of deletionOrder) {
|
|
81
|
+
for (const inbound of inboundByModel.get(candidate.model) ?? []) {
|
|
82
|
+
const policy = inbound.field.reference.onDelete;
|
|
83
|
+
if (policy === "cascade") continue;
|
|
84
|
+
const children = await findReferencingRows(ctx, candidate, inbound.model, inbound.field);
|
|
85
|
+
for (const child of children) {
|
|
86
|
+
const planned = plannedRow(inbound.model, child);
|
|
87
|
+
if (visited.has(planned.key)) continue;
|
|
88
|
+
if (policy === "restrict") {
|
|
89
|
+
throw new Error(
|
|
90
|
+
`AUTH_REFERENCE_DELETE_RESTRICTED:${candidate.model}.${inbound.field.reference.field}`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
if (!inbound.field.nullable) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
`AUTH_REFERENCE_SET_NULL_REQUIRED:${inbound.model}.${inbound.field.physicalName}`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
const existing = setNullPatches.get(planned.key) ?? { planned, patch: {} };
|
|
99
|
+
if (!setNullPatches.has(planned.key) && visited.size + setNullPatches.size === AUTH_BULK_OPERATION_LIMIT) {
|
|
100
|
+
rejectOversizedOperation();
|
|
101
|
+
}
|
|
102
|
+
existing.patch[inbound.field.physicalName] = null;
|
|
103
|
+
setNullPatches.set(planned.key, existing);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
for (const { planned, patch } of setNullPatches.values()) {
|
|
108
|
+
await ctx.db.patch(planned.model, planned.row._id, patch);
|
|
109
|
+
if (!handles.onUpdateHandle || !updateTriggerModels.has(planned.model)) continue;
|
|
110
|
+
const updated = await ctx.db.get(planned.model, planned.row._id);
|
|
111
|
+
if (!updated) throw new Error("AUTH_REFERENCE_SET_NULL_READBACK_FAILED");
|
|
112
|
+
await runTrigger(ctx, handles.onUpdateHandle, {
|
|
113
|
+
model: planned.model,
|
|
114
|
+
oldDoc: toBetterAuthDocument(planned.row),
|
|
115
|
+
newDoc: toBetterAuthDocument(updated)
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
for (const candidate of deletionOrder) {
|
|
119
|
+
await ctx.db.delete(candidate.model, candidate.row._id);
|
|
120
|
+
if (!handles.onDeleteHandle || !deleteTriggerModels.has(candidate.model)) continue;
|
|
121
|
+
await runTrigger(ctx, handles.onDeleteHandle, {
|
|
122
|
+
model: candidate.model,
|
|
123
|
+
doc: toBetterAuthDocument(candidate.row)
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return Object.freeze({ applyDeletion, assertTargets, collectOperationRows });
|
|
128
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated `ComponentApi` utility.
|
|
3
|
+
*
|
|
4
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
5
|
+
*
|
|
6
|
+
* To regenerate, run `pnpm exec better-convex-nuxt-convex codegen --component-dir src/runtime/convex-auth/component`.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { FunctionReference, PaginationOptions, PaginationResult } from 'convex/server';
|
|
10
|
+
type AuthValue = string | number | boolean | string[] | number[] | null;
|
|
11
|
+
type AuthWhere = {
|
|
12
|
+
connector?: 'AND' | 'OR';
|
|
13
|
+
field: string;
|
|
14
|
+
mode?: 'sensitive' | 'insensitive';
|
|
15
|
+
operator?: 'lt' | 'lte' | 'gt' | 'gte' | 'eq' | 'in' | 'not_in' | 'ne' | 'contains' | 'starts_with' | 'ends_with';
|
|
16
|
+
value: AuthValue;
|
|
17
|
+
};
|
|
18
|
+
type AuthDocument = Record<string, AuthValue>;
|
|
19
|
+
type TriggerArgs = {
|
|
20
|
+
onCreateHandle?: string;
|
|
21
|
+
onDeleteHandle?: string;
|
|
22
|
+
onUpdateHandle?: string;
|
|
23
|
+
};
|
|
24
|
+
type SigningKeyCandidate = {
|
|
25
|
+
alg: 'RS256';
|
|
26
|
+
crv: null;
|
|
27
|
+
id: string;
|
|
28
|
+
privateKey: string;
|
|
29
|
+
publicKey: string;
|
|
30
|
+
};
|
|
31
|
+
type SigningKeyRotationMetadata = {
|
|
32
|
+
createdAt: number;
|
|
33
|
+
newKid: string;
|
|
34
|
+
previousKids: string[];
|
|
35
|
+
previousVerifyUntil: number;
|
|
36
|
+
rotatedAt: number;
|
|
37
|
+
};
|
|
38
|
+
/** A utility for accepting the mounted Better Convex Nuxt auth component. */
|
|
39
|
+
export type ComponentApi<Name extends string | undefined = string | undefined> = {
|
|
40
|
+
adapter: {
|
|
41
|
+
consumeOne: FunctionReference<'mutation', 'internal', {
|
|
42
|
+
model: string;
|
|
43
|
+
where: AuthWhere[];
|
|
44
|
+
onDeleteHandle?: string;
|
|
45
|
+
onDeleteModels?: string[];
|
|
46
|
+
onUpdateHandle?: string;
|
|
47
|
+
onUpdateModels?: string[];
|
|
48
|
+
}, AuthDocument | null, Name>;
|
|
49
|
+
count: FunctionReference<'query', 'internal', {
|
|
50
|
+
model: string;
|
|
51
|
+
where?: AuthWhere[];
|
|
52
|
+
}, number, Name>;
|
|
53
|
+
create: FunctionReference<'mutation', 'internal', {
|
|
54
|
+
data: Record<string, unknown>;
|
|
55
|
+
model: string;
|
|
56
|
+
} & TriggerArgs, AuthDocument, Name>;
|
|
57
|
+
deleteMany: FunctionReference<'mutation', 'internal', {
|
|
58
|
+
model: string;
|
|
59
|
+
where: AuthWhere[];
|
|
60
|
+
onDeleteHandle?: string;
|
|
61
|
+
onDeleteModels?: string[];
|
|
62
|
+
onUpdateHandle?: string;
|
|
63
|
+
onUpdateModels?: string[];
|
|
64
|
+
}, number, Name>;
|
|
65
|
+
deleteOne: FunctionReference<'mutation', 'internal', {
|
|
66
|
+
model: string;
|
|
67
|
+
where: AuthWhere[];
|
|
68
|
+
onDeleteHandle?: string;
|
|
69
|
+
onDeleteModels?: string[];
|
|
70
|
+
onUpdateHandle?: string;
|
|
71
|
+
onUpdateModels?: string[];
|
|
72
|
+
}, AuthDocument | null, Name>;
|
|
73
|
+
findMany: FunctionReference<'query', 'internal', {
|
|
74
|
+
join?: unknown;
|
|
75
|
+
limit?: number;
|
|
76
|
+
model: string;
|
|
77
|
+
offset?: number;
|
|
78
|
+
paginationOpts: PaginationOptions;
|
|
79
|
+
select?: string[];
|
|
80
|
+
sortBy?: {
|
|
81
|
+
direction: 'asc' | 'desc';
|
|
82
|
+
field: string;
|
|
83
|
+
};
|
|
84
|
+
where?: AuthWhere[];
|
|
85
|
+
}, PaginationResult<AuthDocument>, Name>;
|
|
86
|
+
findOne: FunctionReference<'query', 'internal', {
|
|
87
|
+
join?: unknown;
|
|
88
|
+
model: string;
|
|
89
|
+
select?: string[];
|
|
90
|
+
where?: AuthWhere[];
|
|
91
|
+
}, AuthDocument | null, Name>;
|
|
92
|
+
incrementOne: FunctionReference<'mutation', 'internal', {
|
|
93
|
+
increment: Record<string, number>;
|
|
94
|
+
model: string;
|
|
95
|
+
onUpdateHandle?: string;
|
|
96
|
+
set?: Record<string, unknown>;
|
|
97
|
+
where: AuthWhere[];
|
|
98
|
+
}, AuthDocument | null, Name>;
|
|
99
|
+
rotateSigningKey: FunctionReference<'mutation', 'internal', {
|
|
100
|
+
next: SigningKeyCandidate;
|
|
101
|
+
}, SigningKeyRotationMetadata, Name>;
|
|
102
|
+
updateMany: FunctionReference<'mutation', 'internal', {
|
|
103
|
+
model: string;
|
|
104
|
+
onUpdateHandle?: string;
|
|
105
|
+
update: Record<string, unknown>;
|
|
106
|
+
where: AuthWhere[];
|
|
107
|
+
}, number, Name>;
|
|
108
|
+
updateOne: FunctionReference<'mutation', 'internal', {
|
|
109
|
+
model: string;
|
|
110
|
+
onUpdateHandle?: string;
|
|
111
|
+
update: Record<string, unknown>;
|
|
112
|
+
where: AuthWhere[];
|
|
113
|
+
}, AuthDocument | null, Name>;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
export {};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
actionGeneric,
|
|
3
|
+
httpActionGeneric,
|
|
4
|
+
internalActionGeneric,
|
|
5
|
+
internalMutationGeneric,
|
|
6
|
+
internalQueryGeneric,
|
|
7
|
+
mutationGeneric,
|
|
8
|
+
queryGeneric
|
|
9
|
+
} from "convex/server";
|
|
10
|
+
export const query = queryGeneric;
|
|
11
|
+
export const internalQuery = internalQueryGeneric;
|
|
12
|
+
export const mutation = mutationGeneric;
|
|
13
|
+
export const internalMutation = internalMutationGeneric;
|
|
14
|
+
export const action = actionGeneric;
|
|
15
|
+
export const internalAction = internalActionGeneric;
|
|
16
|
+
export const httpAction = httpActionGeneric;
|