@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,256 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useConvexPaginatedQuery as useVuePaginatedQuery
|
|
3
|
+
} from "@lupinum/better-convex-vue";
|
|
4
|
+
import { computed, onScopeDispose, ref, toValue, watch } from "vue";
|
|
5
|
+
import { useAsyncData, useNuxtApp, useRequestEvent, useState } from "#imports";
|
|
6
|
+
import { identityToken } from "../auth/auth-identity.js";
|
|
7
|
+
import { ConvexCallError, normalizeConvexError } from "../errors/index.js";
|
|
8
|
+
import { readConvexRuntimeContext } from "../runtime-context.js";
|
|
9
|
+
import { useConvexIdentityState } from "../utils/auth-identity-state.js";
|
|
10
|
+
import {
|
|
11
|
+
fetchAuthToken,
|
|
12
|
+
matchesConvexHydrationIdentity,
|
|
13
|
+
withAuthDimension
|
|
14
|
+
} from "../utils/convex-cache.js";
|
|
15
|
+
import { createConvexQueryKey, getFunctionName } from "../utils/convex-shared.js";
|
|
16
|
+
import { executeQueryHttp } from "../utils/query-execution.js";
|
|
17
|
+
import { createQueryExecutionGate } from "../utils/query-execution-gate.js";
|
|
18
|
+
import { createConvexQueryAuthContext } from "../utils/query-foundation.js";
|
|
19
|
+
import { normalizeConvexReactiveArgs } from "../utils/reactive-args.js";
|
|
20
|
+
import { getConvexRuntimeConfig } from "../utils/runtime-config.js";
|
|
21
|
+
import { isIncompletePaginationPage } from "../utils/ssr-pagination-state.js";
|
|
22
|
+
function asNativeNuxtPromise(state, resolvePromise) {
|
|
23
|
+
const awaitedState = Object.freeze({ ...state });
|
|
24
|
+
const promise = resolvePromise.then(
|
|
25
|
+
() => awaitedState,
|
|
26
|
+
() => awaitedState
|
|
27
|
+
);
|
|
28
|
+
void Object.assign(promise, state);
|
|
29
|
+
void Object.defineProperties(promise, {
|
|
30
|
+
then: { enumerable: true, value: promise.then.bind(promise) },
|
|
31
|
+
catch: { enumerable: true, value: promise.catch.bind(promise) },
|
|
32
|
+
finally: { enumerable: true, value: promise.finally.bind(promise) }
|
|
33
|
+
});
|
|
34
|
+
return promise;
|
|
35
|
+
}
|
|
36
|
+
export function createConvexPaginatedQueryState(query, args, options, resolveImmediately = false) {
|
|
37
|
+
const config = getConvexRuntimeConfig();
|
|
38
|
+
const initialNumItems = options.initialNumItems;
|
|
39
|
+
if (!Number.isSafeInteger(initialNumItems) || initialNumItems < 1) {
|
|
40
|
+
throw new Error("[better-convex-nuxt] initialNumItems must be a positive safe integer");
|
|
41
|
+
}
|
|
42
|
+
const server = options.server ?? true;
|
|
43
|
+
const auth = options.auth ?? "optional";
|
|
44
|
+
if (import.meta.client) {
|
|
45
|
+
const authContext2 = createConvexQueryAuthContext();
|
|
46
|
+
const currentBoundary = computed(() => {
|
|
47
|
+
const currentArgs2 = normalizeConvexReactiveArgs(toValue(args));
|
|
48
|
+
const gate2 = createQueryExecutionGate({
|
|
49
|
+
authStatus: authContext2.status.value,
|
|
50
|
+
authMode: auth,
|
|
51
|
+
identityKey: authContext2.identityKey.value,
|
|
52
|
+
skipped: currentArgs2 === "skip"
|
|
53
|
+
});
|
|
54
|
+
const key2 = gate2.outcome === "execute" ? withAuthDimension(
|
|
55
|
+
createConvexQueryKey(
|
|
56
|
+
query,
|
|
57
|
+
{
|
|
58
|
+
...currentArgs2,
|
|
59
|
+
paginationOpts: { numItems: initialNumItems, cursor: null }
|
|
60
|
+
},
|
|
61
|
+
"convex-paginated"
|
|
62
|
+
),
|
|
63
|
+
auth,
|
|
64
|
+
gate2.cacheIdentity
|
|
65
|
+
) : `convex-paginated:${gate2.outcome}:${getFunctionName(query)}`;
|
|
66
|
+
return { gate: gate2, key: key2 };
|
|
67
|
+
});
|
|
68
|
+
const hydrationBoundary = currentBoundary.value;
|
|
69
|
+
const hydrationKey = hydrationBoundary.key;
|
|
70
|
+
const nuxtApp = useNuxtApp();
|
|
71
|
+
const runtime = readConvexRuntimeContext(nuxtApp);
|
|
72
|
+
const hydrationIdentityMatches = hydrationBoundary.gate.outcome === "execute" && matchesConvexHydrationIdentity(
|
|
73
|
+
auth,
|
|
74
|
+
hydrationBoundary.gate.cacheIdentity,
|
|
75
|
+
runtime?.attachment.identity.snapshot()
|
|
76
|
+
);
|
|
77
|
+
const hydrationRetired = ref(false);
|
|
78
|
+
const matchesHydrationBoundary = () => {
|
|
79
|
+
const boundary = currentBoundary.value;
|
|
80
|
+
return hydrationIdentityMatches && boundary.key === hydrationKey && boundary.gate.outcome === "execute" && matchesConvexHydrationIdentity(
|
|
81
|
+
auth,
|
|
82
|
+
boundary.gate.cacheIdentity,
|
|
83
|
+
runtime?.attachment.identity.snapshot()
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
const hydrationBoundaryMatches = computed(
|
|
87
|
+
() => !hydrationRetired.value && matchesHydrationBoundary()
|
|
88
|
+
);
|
|
89
|
+
const stopHydrationBoundaryRetirement = watch(
|
|
90
|
+
currentBoundary,
|
|
91
|
+
() => {
|
|
92
|
+
if (!matchesHydrationBoundary()) hydrationRetired.value = true;
|
|
93
|
+
},
|
|
94
|
+
{ flush: "sync" }
|
|
95
|
+
);
|
|
96
|
+
const hydrated = hydrationIdentityMatches && Object.hasOwn(nuxtApp.payload.data, hydrationKey) ? nuxtApp.payload.data[hydrationKey] : void 0;
|
|
97
|
+
const hasHydratedPage = hydrated !== null && hydrated !== void 0;
|
|
98
|
+
const hydratedErrors = useState(
|
|
99
|
+
"convex:query-errors",
|
|
100
|
+
() => ({})
|
|
101
|
+
);
|
|
102
|
+
let firstPageSettled = Promise.resolve();
|
|
103
|
+
const result = Reflect.apply(useVuePaginatedQuery, void 0, [
|
|
104
|
+
query,
|
|
105
|
+
args,
|
|
106
|
+
{ initialNumItems, auth, keepPreviousData: options.keepPreviousData },
|
|
107
|
+
{
|
|
108
|
+
initialPage: hasHydratedPage ? hydrated : void 0,
|
|
109
|
+
onFirstPageSettled(promise) {
|
|
110
|
+
firstPageSettled = promise;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
]);
|
|
114
|
+
const clearHydratedError = () => {
|
|
115
|
+
if (!(hydrationKey in hydratedErrors.value)) return;
|
|
116
|
+
const { [hydrationKey]: _removed, ...rest } = hydratedErrors.value;
|
|
117
|
+
hydratedErrors.value = rest;
|
|
118
|
+
};
|
|
119
|
+
const stopHydratedErrorReconciliation = watch(
|
|
120
|
+
[result.error, result.status, hydrationBoundaryMatches],
|
|
121
|
+
([liveError, liveStatus, boundaryMatches]) => {
|
|
122
|
+
if (boundaryMatches && (liveError || liveStatus !== "pending")) clearHydratedError();
|
|
123
|
+
},
|
|
124
|
+
{ flush: "sync" }
|
|
125
|
+
);
|
|
126
|
+
onScopeDispose(() => {
|
|
127
|
+
stopHydrationBoundaryRetirement();
|
|
128
|
+
stopHydratedErrorReconciliation();
|
|
129
|
+
});
|
|
130
|
+
const error2 = computed(
|
|
131
|
+
() => result.error.value ?? (hydrationBoundaryMatches.value ? hydratedErrors.value[hydrationKey] : void 0) ?? void 0
|
|
132
|
+
);
|
|
133
|
+
const status2 = computed(
|
|
134
|
+
() => error2.value ? "error" : result.status.value
|
|
135
|
+
);
|
|
136
|
+
const isLoading = computed(() => status2.value === "pending");
|
|
137
|
+
const resultData2 = Object.freeze({
|
|
138
|
+
...result,
|
|
139
|
+
error: error2,
|
|
140
|
+
status: status2,
|
|
141
|
+
isLoading
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
resultData: resultData2,
|
|
145
|
+
resolvePromise: resolveImmediately || !server || hasHydratedPage || error2.value !== void 0 || status2.value === "idle" ? Promise.resolve() : firstPageSettled
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const authContext = createConvexQueryAuthContext();
|
|
149
|
+
const currentArgs = computed(
|
|
150
|
+
() => normalizeConvexReactiveArgs(toValue(args))
|
|
151
|
+
);
|
|
152
|
+
const gate = computed(
|
|
153
|
+
() => createQueryExecutionGate({
|
|
154
|
+
authStatus: authContext.status.value,
|
|
155
|
+
authMode: auth,
|
|
156
|
+
identityKey: authContext.identityKey.value,
|
|
157
|
+
skipped: currentArgs.value === "skip"
|
|
158
|
+
})
|
|
159
|
+
);
|
|
160
|
+
const key = computed(() => {
|
|
161
|
+
if (gate.value.outcome !== "execute") {
|
|
162
|
+
return `convex-paginated:${gate.value.outcome}:${getFunctionName(query)}`;
|
|
163
|
+
}
|
|
164
|
+
return withAuthDimension(
|
|
165
|
+
createConvexQueryKey(
|
|
166
|
+
query,
|
|
167
|
+
{
|
|
168
|
+
...currentArgs.value,
|
|
169
|
+
paginationOpts: { numItems: initialNumItems, cursor: null }
|
|
170
|
+
},
|
|
171
|
+
"convex-paginated"
|
|
172
|
+
),
|
|
173
|
+
auth,
|
|
174
|
+
gate.value.cacheIdentity
|
|
175
|
+
);
|
|
176
|
+
});
|
|
177
|
+
const errors = useState("convex:query-errors", () => ({}));
|
|
178
|
+
const event = useRequestEvent();
|
|
179
|
+
const identity = useConvexIdentityState();
|
|
180
|
+
const cachedToken = computed(() => identityToken(identity.value));
|
|
181
|
+
const asyncData = useAsyncData(
|
|
182
|
+
key,
|
|
183
|
+
async () => {
|
|
184
|
+
const decision = gate.value;
|
|
185
|
+
if (decision.outcome !== "execute") return null;
|
|
186
|
+
if (!config.url) return null;
|
|
187
|
+
try {
|
|
188
|
+
const token = fetchAuthToken({
|
|
189
|
+
auth,
|
|
190
|
+
cookieHeader: event?.headers.get("cookie") ?? "",
|
|
191
|
+
cachedToken
|
|
192
|
+
});
|
|
193
|
+
if (auth !== "none" && decision.cacheIdentity !== "anonymous" && !token) return null;
|
|
194
|
+
const value = await executeQueryHttp(
|
|
195
|
+
config.url,
|
|
196
|
+
getFunctionName(query),
|
|
197
|
+
{
|
|
198
|
+
...currentArgs.value,
|
|
199
|
+
paginationOpts: { numItems: initialNumItems, cursor: null }
|
|
200
|
+
},
|
|
201
|
+
token,
|
|
202
|
+
event?.web?.request?.signal
|
|
203
|
+
);
|
|
204
|
+
if (isIncompletePaginationPage(value)) {
|
|
205
|
+
throw new ConvexCallError({
|
|
206
|
+
kind: "unknown",
|
|
207
|
+
code: "PAGINATION_SPLIT_REQUIRED",
|
|
208
|
+
message: "Convex pagination page requires a bounded live split"
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
const { [key.value]: _removed, ...rest } = errors.value;
|
|
212
|
+
errors.value = rest;
|
|
213
|
+
return value;
|
|
214
|
+
} catch (error2) {
|
|
215
|
+
errors.value = {
|
|
216
|
+
...errors.value,
|
|
217
|
+
[key.value]: normalizeConvexError(error2)
|
|
218
|
+
};
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
{ server, lazy: resolveImmediately, deep: false }
|
|
223
|
+
);
|
|
224
|
+
const data = computed(() => asyncData.data.value?.page);
|
|
225
|
+
const error = computed(
|
|
226
|
+
() => errors.value[key.value] ?? (gate.value.outcome === "error" ? authContext.error.value ?? normalizeConvexError(new Error("Authentication failed before the query could execute")) : void 0) ?? void 0
|
|
227
|
+
);
|
|
228
|
+
const status = computed(() => {
|
|
229
|
+
if (error.value) return "error";
|
|
230
|
+
if (gate.value.outcome === "idle") return "idle";
|
|
231
|
+
if (gate.value.outcome === "wait" || asyncData.pending.value) return "pending";
|
|
232
|
+
return asyncData.data.value === null ? "pending" : "success";
|
|
233
|
+
});
|
|
234
|
+
const resultData = Object.freeze({
|
|
235
|
+
data,
|
|
236
|
+
status,
|
|
237
|
+
isLoading: computed(() => status.value === "pending"),
|
|
238
|
+
isStale: computed(() => false),
|
|
239
|
+
canLoadMore: computed(
|
|
240
|
+
() => status.value === "success" && asyncData.data.value?.isDone === false
|
|
241
|
+
),
|
|
242
|
+
loadMore: () => {
|
|
243
|
+
},
|
|
244
|
+
error,
|
|
245
|
+
refresh: asyncData.refresh
|
|
246
|
+
});
|
|
247
|
+
return {
|
|
248
|
+
resultData,
|
|
249
|
+
resolvePromise: server && gate.value.outcome !== "idle" ? Promise.resolve(asyncData).then(() => {
|
|
250
|
+
}) : Promise.resolve()
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
export function useConvexPaginatedQuery(query, args, options) {
|
|
254
|
+
const result = createConvexPaginatedQueryState(query, args, options);
|
|
255
|
+
return asNativeNuxtPromise(result.resultData, result.resolvePromise);
|
|
256
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ConvexAuthMode, type UseConvexQueryOptions, type UseConvexQueryParameters, type UseConvexQueryState } from '@lupinum/better-convex-vue';
|
|
2
|
+
import type { FunctionArgs, FunctionReference, FunctionReturnType } from 'convex/server';
|
|
3
|
+
import { type MaybeRefOrGetter } from 'vue';
|
|
4
|
+
import type { ConvexCallStatus } from '../utils/types.js';
|
|
5
|
+
export type { ConvexAuthMode, ConvexCallStatus };
|
|
6
|
+
export type ConvexQuerySkip = 'skip';
|
|
7
|
+
export type ConvexQueryArgs<Args> = Args | ConvexQuerySkip;
|
|
8
|
+
export interface UseNuxtConvexQueryOptions extends UseConvexQueryOptions {
|
|
9
|
+
/** Disable the SSR fetch for a genuinely browser-only query. */
|
|
10
|
+
readonly server?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type { UseConvexQueryOptions, UseConvexQueryParameters, UseConvexQueryState };
|
|
13
|
+
export type NuxtConvexQuery<Data> = UseConvexQueryState<Data> & Promise<UseConvexQueryState<Data>>;
|
|
14
|
+
interface BuildConvexQueryResult<DataT> {
|
|
15
|
+
resultData: UseConvexQueryState<DataT>;
|
|
16
|
+
resolvePromise: Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare function createConvexQueryState<Query extends FunctionReference<'query'>, Args extends ConvexQueryArgs<FunctionArgs<Query>> = FunctionArgs<Query>>(query: Query, args: MaybeRefOrGetter<Args>, options?: UseNuxtConvexQueryOptions): BuildConvexQueryResult<FunctionReturnType<Query>>;
|
|
19
|
+
export declare function useConvexQuery<Query extends FunctionReference<'query'>>(query: Query, ...parameters: UseConvexQueryParameters<Query, UseNuxtConvexQueryOptions>): NuxtConvexQuery<FunctionReturnType<Query>>;
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useConvexQuery as useVueConvexQuery
|
|
3
|
+
} from "@lupinum/better-convex-vue";
|
|
4
|
+
import {
|
|
5
|
+
computed,
|
|
6
|
+
onScopeDispose,
|
|
7
|
+
ref,
|
|
8
|
+
toValue,
|
|
9
|
+
watch
|
|
10
|
+
} from "vue";
|
|
11
|
+
import { useAsyncData, useNuxtApp, useRequestEvent, useState } from "#imports";
|
|
12
|
+
import { identityToken } from "../auth/auth-identity.js";
|
|
13
|
+
import { ConvexCallError, normalizeConvexError } from "../errors/index.js";
|
|
14
|
+
import { readConvexRuntimeContext } from "../runtime-context.js";
|
|
15
|
+
import { useConvexIdentityState } from "../utils/auth-identity-state.js";
|
|
16
|
+
import {
|
|
17
|
+
fetchAuthToken,
|
|
18
|
+
matchesConvexHydrationIdentity,
|
|
19
|
+
withAuthDimension
|
|
20
|
+
} from "../utils/convex-cache.js";
|
|
21
|
+
import { computeQueryStatus, createConvexQueryKey, getFunctionName } from "../utils/convex-shared.js";
|
|
22
|
+
import { executeQueryHttp } from "../utils/query-execution.js";
|
|
23
|
+
import { createQueryExecutionGate } from "../utils/query-execution-gate.js";
|
|
24
|
+
import { createConvexQueryAuthContext } from "../utils/query-foundation.js";
|
|
25
|
+
import { computeConvexQueryPending } from "../utils/query-state.js";
|
|
26
|
+
import { normalizeConvexReactiveArgs } from "../utils/reactive-args.js";
|
|
27
|
+
import { getConvexRuntimeConfig } from "../utils/runtime-config.js";
|
|
28
|
+
function waitForClientTerminal(status) {
|
|
29
|
+
if (status.value !== "pending") return Promise.resolve();
|
|
30
|
+
return new Promise((resolve) => {
|
|
31
|
+
let settled = false;
|
|
32
|
+
let stop = () => {
|
|
33
|
+
};
|
|
34
|
+
const finish = () => {
|
|
35
|
+
if (settled) return;
|
|
36
|
+
settled = true;
|
|
37
|
+
stop();
|
|
38
|
+
resolve();
|
|
39
|
+
};
|
|
40
|
+
stop = watch(
|
|
41
|
+
status,
|
|
42
|
+
(value) => {
|
|
43
|
+
if (value === "pending") return;
|
|
44
|
+
finish();
|
|
45
|
+
},
|
|
46
|
+
{ flush: "sync" }
|
|
47
|
+
);
|
|
48
|
+
onScopeDispose(finish);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function asNuxtConvexQuery(state, initialSettlement) {
|
|
52
|
+
const awaitedState = Object.freeze({ ...state });
|
|
53
|
+
const promise = initialSettlement.then(
|
|
54
|
+
() => awaitedState,
|
|
55
|
+
() => awaitedState
|
|
56
|
+
);
|
|
57
|
+
void Object.assign(promise, state);
|
|
58
|
+
void Object.defineProperties(promise, {
|
|
59
|
+
then: { enumerable: true, value: promise.then.bind(promise) },
|
|
60
|
+
catch: { enumerable: true, value: promise.catch.bind(promise) },
|
|
61
|
+
finally: { enumerable: true, value: promise.finally.bind(promise) }
|
|
62
|
+
});
|
|
63
|
+
return promise;
|
|
64
|
+
}
|
|
65
|
+
export function createConvexQueryState(query, args, options) {
|
|
66
|
+
const config = getConvexRuntimeConfig();
|
|
67
|
+
const server = options?.server ?? true;
|
|
68
|
+
const auth = options?.auth ?? "optional";
|
|
69
|
+
if (import.meta.client) {
|
|
70
|
+
const authContext2 = createConvexQueryAuthContext();
|
|
71
|
+
const currentBoundary = computed(() => {
|
|
72
|
+
const currentArgs2 = normalizeConvexReactiveArgs(toValue(args));
|
|
73
|
+
const gate2 = createQueryExecutionGate({
|
|
74
|
+
authStatus: authContext2.status.value,
|
|
75
|
+
authMode: auth,
|
|
76
|
+
identityKey: authContext2.identityKey.value,
|
|
77
|
+
skipped: currentArgs2 === "skip"
|
|
78
|
+
});
|
|
79
|
+
const key2 = gate2.outcome === "execute" ? withAuthDimension(
|
|
80
|
+
createConvexQueryKey(query, currentArgs2),
|
|
81
|
+
auth,
|
|
82
|
+
gate2.cacheIdentity
|
|
83
|
+
) : `convex:${gate2.outcome}:${getFunctionName(query)}`;
|
|
84
|
+
return { args: currentArgs2, gate: gate2, key: key2 };
|
|
85
|
+
});
|
|
86
|
+
const hydrationBoundary = currentBoundary.value;
|
|
87
|
+
const hydrationKey = hydrationBoundary.key;
|
|
88
|
+
const nuxtApp = useNuxtApp();
|
|
89
|
+
const runtime = readConvexRuntimeContext(nuxtApp);
|
|
90
|
+
const hydrationIdentityMatches = hydrationBoundary.gate.outcome === "execute" && matchesConvexHydrationIdentity(
|
|
91
|
+
auth,
|
|
92
|
+
hydrationBoundary.gate.cacheIdentity,
|
|
93
|
+
runtime?.attachment.identity.snapshot()
|
|
94
|
+
);
|
|
95
|
+
const hydrationRetired = ref(false);
|
|
96
|
+
const matchesHydrationBoundary = () => {
|
|
97
|
+
const boundary = currentBoundary.value;
|
|
98
|
+
return hydrationIdentityMatches && boundary.key === hydrationKey && boundary.gate.outcome === "execute" && matchesConvexHydrationIdentity(
|
|
99
|
+
auth,
|
|
100
|
+
boundary.gate.cacheIdentity,
|
|
101
|
+
runtime?.attachment.identity.snapshot()
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
const hydrationBoundaryMatches = computed(
|
|
105
|
+
() => !hydrationRetired.value && matchesHydrationBoundary()
|
|
106
|
+
);
|
|
107
|
+
const stopHydrationBoundaryRetirement = watch(
|
|
108
|
+
currentBoundary,
|
|
109
|
+
() => {
|
|
110
|
+
if (!matchesHydrationBoundary()) hydrationRetired.value = true;
|
|
111
|
+
},
|
|
112
|
+
{ flush: "sync" }
|
|
113
|
+
);
|
|
114
|
+
const hydratedPayload = nuxtApp.payload.data[hydrationKey];
|
|
115
|
+
const hasHydratedData = hydrationIdentityMatches && hydratedPayload !== null && hydratedPayload !== void 0 && Object.hasOwn(hydratedPayload, "value");
|
|
116
|
+
const hydratedErrors = useState(
|
|
117
|
+
"convex:query-errors",
|
|
118
|
+
() => ({})
|
|
119
|
+
);
|
|
120
|
+
const result = Reflect.apply(useVueConvexQuery, void 0, [
|
|
121
|
+
query,
|
|
122
|
+
args,
|
|
123
|
+
{ auth, keepPreviousData: options?.keepPreviousData },
|
|
124
|
+
hasHydratedData ? { value: hydratedPayload.value } : void 0
|
|
125
|
+
]);
|
|
126
|
+
const clearHydratedError = () => {
|
|
127
|
+
if (!(hydrationKey in hydratedErrors.value)) return;
|
|
128
|
+
const { [hydrationKey]: _removed, ...rest } = hydratedErrors.value;
|
|
129
|
+
hydratedErrors.value = rest;
|
|
130
|
+
};
|
|
131
|
+
const stopHydratedErrorReconciliation = watch(
|
|
132
|
+
[result.error, result.pending, hydrationBoundaryMatches],
|
|
133
|
+
([error3, pending3, boundaryMatches]) => {
|
|
134
|
+
if (boundaryMatches && (error3 || !pending3)) clearHydratedError();
|
|
135
|
+
},
|
|
136
|
+
{ flush: "sync" }
|
|
137
|
+
);
|
|
138
|
+
const error2 = computed(
|
|
139
|
+
() => result.error.value ?? (hydrationBoundaryMatches.value ? hydratedErrors.value[hydrationKey] : void 0)
|
|
140
|
+
);
|
|
141
|
+
const pending2 = computed(() => error2.value ? false : result.pending.value);
|
|
142
|
+
const status2 = computed(
|
|
143
|
+
() => error2.value ? "error" : result.status.value
|
|
144
|
+
);
|
|
145
|
+
const stopDevtools = watch(
|
|
146
|
+
[status2, result.data, error2],
|
|
147
|
+
([currentStatus, data2, currentError]) => {
|
|
148
|
+
runtime?.getDevtoolsSink()?.upsertQuery({
|
|
149
|
+
id: hydrationKey,
|
|
150
|
+
name: getFunctionName(query),
|
|
151
|
+
args: currentBoundary.value.args,
|
|
152
|
+
status: currentStatus,
|
|
153
|
+
data: data2,
|
|
154
|
+
error: currentError?.message,
|
|
155
|
+
options: { immediate: true, server, subscribe: true, auth }
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
{ immediate: true }
|
|
159
|
+
);
|
|
160
|
+
onScopeDispose(() => {
|
|
161
|
+
stopHydrationBoundaryRetirement();
|
|
162
|
+
stopHydratedErrorReconciliation();
|
|
163
|
+
stopDevtools();
|
|
164
|
+
runtime?.getDevtoolsSink()?.removeQuery(hydrationKey);
|
|
165
|
+
});
|
|
166
|
+
return {
|
|
167
|
+
resultData: Object.freeze({
|
|
168
|
+
...result,
|
|
169
|
+
error: error2,
|
|
170
|
+
pending: pending2,
|
|
171
|
+
status: status2
|
|
172
|
+
}),
|
|
173
|
+
resolvePromise: !server || hasHydratedData || error2.value || status2.value !== "pending" ? Promise.resolve() : waitForClientTerminal(status2)
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
const authContext = createConvexQueryAuthContext();
|
|
177
|
+
const currentArgs = computed(() => normalizeConvexReactiveArgs(toValue(args)));
|
|
178
|
+
const skipped = computed(() => currentArgs.value === "skip");
|
|
179
|
+
const gate = computed(
|
|
180
|
+
() => createQueryExecutionGate({
|
|
181
|
+
authStatus: authContext.status.value,
|
|
182
|
+
authMode: auth,
|
|
183
|
+
identityKey: authContext.identityKey.value,
|
|
184
|
+
skipped: skipped.value
|
|
185
|
+
})
|
|
186
|
+
);
|
|
187
|
+
const key = computed(() => {
|
|
188
|
+
if (gate.value.outcome !== "execute") {
|
|
189
|
+
return `convex:${gate.value.outcome}:${getFunctionName(query)}`;
|
|
190
|
+
}
|
|
191
|
+
return withAuthDimension(
|
|
192
|
+
createConvexQueryKey(query, currentArgs.value),
|
|
193
|
+
auth,
|
|
194
|
+
gate.value.cacheIdentity
|
|
195
|
+
);
|
|
196
|
+
});
|
|
197
|
+
const errors = useState(
|
|
198
|
+
"convex:query-errors",
|
|
199
|
+
() => ({})
|
|
200
|
+
);
|
|
201
|
+
const event = useRequestEvent();
|
|
202
|
+
const identity = useConvexIdentityState();
|
|
203
|
+
const cachedToken = computed(() => identityToken(identity.value));
|
|
204
|
+
const asyncData = useAsyncData(
|
|
205
|
+
key,
|
|
206
|
+
async () => {
|
|
207
|
+
const decision = gate.value;
|
|
208
|
+
if (decision.outcome !== "execute") {
|
|
209
|
+
if (decision.outcome === "error") {
|
|
210
|
+
errors.value = {
|
|
211
|
+
...errors.value,
|
|
212
|
+
[key.value]: authContext.error.value ?? new ConvexCallError({
|
|
213
|
+
kind: "authentication",
|
|
214
|
+
message: "Authentication error"
|
|
215
|
+
})
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
const convexUrl = config.url;
|
|
221
|
+
if (!convexUrl) return null;
|
|
222
|
+
try {
|
|
223
|
+
const token = fetchAuthToken({
|
|
224
|
+
auth,
|
|
225
|
+
cookieHeader: event?.headers.get("cookie") ?? "",
|
|
226
|
+
cachedToken
|
|
227
|
+
});
|
|
228
|
+
if (auth !== "none" && decision.cacheIdentity !== "anonymous" && !token) return null;
|
|
229
|
+
const value = await executeQueryHttp(
|
|
230
|
+
convexUrl,
|
|
231
|
+
getFunctionName(query),
|
|
232
|
+
currentArgs.value,
|
|
233
|
+
token,
|
|
234
|
+
event?.web?.request?.signal
|
|
235
|
+
);
|
|
236
|
+
const { [key.value]: _removed, ...rest } = errors.value;
|
|
237
|
+
errors.value = rest;
|
|
238
|
+
return { value };
|
|
239
|
+
} catch (error2) {
|
|
240
|
+
errors.value = {
|
|
241
|
+
...errors.value,
|
|
242
|
+
[key.value]: normalizeConvexError(error2)
|
|
243
|
+
};
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
server,
|
|
249
|
+
deep: false,
|
|
250
|
+
default: () => null
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
const error = computed(() => errors.value[key.value]);
|
|
254
|
+
const pending = computed(
|
|
255
|
+
() => computeConvexQueryPending({
|
|
256
|
+
isSkipped: gate.value.outcome === "idle",
|
|
257
|
+
hasData: asyncData.data.value !== null,
|
|
258
|
+
hasSettled: asyncData.status.value === "success" || asyncData.status.value === "error",
|
|
259
|
+
server,
|
|
260
|
+
resolveImmediately: false,
|
|
261
|
+
isServer: true,
|
|
262
|
+
isClient: false,
|
|
263
|
+
asyncDataPending: asyncData.pending.value,
|
|
264
|
+
isAuthPending: gate.value.outcome === "wait"
|
|
265
|
+
})
|
|
266
|
+
);
|
|
267
|
+
const data = computed(() => {
|
|
268
|
+
const payload = asyncData.data.value;
|
|
269
|
+
return payload === null ? void 0 : payload.value;
|
|
270
|
+
});
|
|
271
|
+
const status = computed(
|
|
272
|
+
() => computeQueryStatus(
|
|
273
|
+
gate.value.outcome === "idle",
|
|
274
|
+
error.value !== void 0,
|
|
275
|
+
pending.value,
|
|
276
|
+
data.value !== void 0
|
|
277
|
+
)
|
|
278
|
+
);
|
|
279
|
+
return {
|
|
280
|
+
resultData: Object.freeze({
|
|
281
|
+
data,
|
|
282
|
+
error,
|
|
283
|
+
pending,
|
|
284
|
+
status,
|
|
285
|
+
isStale: computed(() => false),
|
|
286
|
+
async refresh() {
|
|
287
|
+
await asyncData.refresh().then(
|
|
288
|
+
() => {
|
|
289
|
+
},
|
|
290
|
+
() => {
|
|
291
|
+
}
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
}),
|
|
295
|
+
resolvePromise: gate.value.outcome === "idle" || !server ? Promise.resolve() : asyncData.then(
|
|
296
|
+
() => {
|
|
297
|
+
},
|
|
298
|
+
() => {
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
export function useConvexQuery(query, ...parameters) {
|
|
304
|
+
const [providedArgs, options] = parameters;
|
|
305
|
+
const args = parameters.length === 0 ? {} : providedArgs;
|
|
306
|
+
const result = createConvexQueryState(query, args, options);
|
|
307
|
+
return asNuxtConvexQuery(result.resultData, result.resolvePromise);
|
|
308
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type DBAdapterDebugLogOption } from 'better-auth/adapters';
|
|
2
|
+
import { type GenericDataModel } from 'convex/server';
|
|
3
|
+
import { type AuthCtx } from '../context.js';
|
|
4
|
+
import type { AuthAdapterComponentApi, AuthComponentTriggers, AuthFunctions } from '../types.js';
|
|
5
|
+
interface AdapterOptions<DataModel extends GenericDataModel> {
|
|
6
|
+
authFunctions?: AuthFunctions;
|
|
7
|
+
debugLogs?: DBAdapterDebugLogOption;
|
|
8
|
+
triggers?: AuthComponentTriggers<DataModel>;
|
|
9
|
+
}
|
|
10
|
+
interface IdTokenProtectionOptions {
|
|
11
|
+
account?: {
|
|
12
|
+
encryptOAuthTokens?: boolean;
|
|
13
|
+
fields?: {
|
|
14
|
+
idToken?: string;
|
|
15
|
+
};
|
|
16
|
+
modelName?: string;
|
|
17
|
+
};
|
|
18
|
+
secrets?: Array<{
|
|
19
|
+
value: string;
|
|
20
|
+
version: number;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The pinned Better Auth RC encrypts access/refresh tokens but omits `idToken`
|
|
25
|
+
* at several persistence call sites. Keep that workaround at the one adapter
|
|
26
|
+
* boundary so raw provider ID tokens never enter the component database.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createAccountIdTokenProtector(options: IdTokenProtectionOptions): {
|
|
29
|
+
protect: <T>(model: string, data: T) => Promise<T>;
|
|
30
|
+
reveal: <T>(model: string, data: T) => Promise<T>;
|
|
31
|
+
};
|
|
32
|
+
export declare function createConvexAuthAdapter<DataModel extends GenericDataModel, Api extends AuthAdapterComponentApi>(ctx: AuthCtx<DataModel>, component: Api, adapterOptions?: AdapterOptions<DataModel>): import("better-auth/adapters").AdapterFactory<import("better-auth").BetterAuthOptions>;
|
|
33
|
+
export {};
|