cvx-kit 0.2.0 → 2.0.0-beta.0
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/README.md +556 -99
- package/dist/agent-tools.d.mts +39 -26
- package/dist/agent-tools.mjs +1 -1
- package/dist/agent-tools.mjs.map +1 -1
- package/dist/auth.d.mts +120 -308
- package/dist/auth.mjs +1 -1
- package/dist/auth.mjs.map +1 -1
- package/dist/components/approvals/_generated/api.d.mts +7 -9
- package/dist/components/approvals/_generated/api.mjs.map +1 -1
- package/dist/components/approvals/_generated/component.d.mts +1 -4
- package/dist/components/approvals/_generated/dataModel.d.mts +5 -8
- package/dist/components/approvals/_generated/server.d.mts +12 -15
- package/dist/components/approvals/_generated/server.mjs.map +1 -1
- package/dist/components/approvals/audit.d.mts +8 -9
- package/dist/components/approvals/audit.mjs +1 -1
- package/dist/components/approvals/audit.mjs.map +1 -1
- package/dist/components/approvals/client.d.mts +11 -12
- package/dist/components/approvals/client.mjs +1 -1
- package/dist/components/approvals/client.mjs.map +1 -1
- package/dist/components/approvals/constants.d.mts +30 -31
- package/dist/components/approvals/constants.mjs.map +1 -1
- package/dist/components/approvals/convex.config.d.mts +0 -2
- package/dist/components/approvals/convex.config.mjs.map +1 -1
- package/dist/components/approvals/decisions.d.mts +13 -17
- package/dist/components/approvals/decisions.mjs +1 -1
- package/dist/components/approvals/decisions.mjs.map +1 -1
- package/dist/components/approvals/functions.d.mts +3 -4
- package/dist/components/approvals/functions.mjs +1 -1
- package/dist/components/approvals/functions.mjs.map +1 -1
- package/dist/components/approvals/health.d.mts +2 -3
- package/dist/components/approvals/health.mjs.map +1 -1
- package/dist/components/approvals/requests.d.mts +114 -131
- package/dist/components/approvals/requests.mjs +1 -1
- package/dist/components/approvals/requests.mjs.map +1 -1
- package/dist/components/approvals/schema.d.ts +106 -315
- package/dist/components/approvals/schema.js +1 -1
- package/dist/components/approvals/validators.d.mts +323 -395
- package/dist/components/approvals/validators.mjs +1 -1
- package/dist/components/approvals/validators.mjs.map +1 -1
- package/dist/components/approvals/workflow.d.mts +4 -5
- package/dist/components/approvals/workflow.mjs +1 -1
- package/dist/components/approvals/workflow.mjs.map +1 -1
- package/dist/components/approvals/workflow_steps.d.mts +16 -17
- package/dist/components/approvals/workflow_steps.mjs +1 -1
- package/dist/components/approvals/workflow_steps.mjs.map +1 -1
- package/dist/components/foundation/_generated/api.d.mts +6 -8
- package/dist/components/foundation/_generated/api.mjs.map +1 -1
- package/dist/components/foundation/_generated/component.d.mts +1 -4
- package/dist/components/foundation/_generated/dataModel.d.mts +5 -8
- package/dist/components/foundation/_generated/server.d.mts +12 -15
- package/dist/components/foundation/_generated/server.mjs.map +1 -1
- package/dist/components/foundation/client.d.mts +45 -38
- package/dist/components/foundation/client.mjs +1 -1
- package/dist/components/foundation/client.mjs.map +1 -1
- package/dist/components/foundation/convex.config.d.mts +0 -2
- package/dist/components/foundation/convex.config.mjs.map +1 -1
- package/dist/components/foundation/functions.d.mts +2 -3
- package/dist/components/foundation/functions.mjs.map +1 -1
- package/dist/components/foundation/modules/command/command.d.mts +65 -17
- package/dist/components/foundation/modules/command/command.mjs +1 -1
- package/dist/components/foundation/modules/command/command.mjs.map +1 -1
- package/dist/components/foundation/modules/command/lifecycle.d.mts +78 -0
- package/dist/components/foundation/modules/command/lifecycle.mjs +2 -0
- package/dist/components/foundation/modules/command/lifecycle.mjs.map +1 -0
- package/dist/components/foundation/modules/observability/observability.d.mts +13 -6
- package/dist/components/foundation/modules/observability/observability.mjs +1 -1
- package/dist/components/foundation/modules/observability/observability.mjs.map +1 -1
- package/dist/components/foundation/modules/query/query.d.mts +11 -12
- package/dist/components/foundation/modules/query/query.mjs +1 -1
- package/dist/components/foundation/modules/query/query.mjs.map +1 -1
- package/dist/components/foundation/operation.d.mts +72 -0
- package/dist/components/foundation/operation.mjs +2 -0
- package/dist/components/foundation/operation.mjs.map +1 -0
- package/dist/components/foundation/result.d.mts +7 -8
- package/dist/components/foundation/result.mjs.map +1 -1
- package/dist/components/foundation/schema.d.ts +0 -2
- package/dist/components/foundation/telemetry.d.mts +2 -3
- package/dist/components/foundation/telemetry.mjs +1 -1
- package/dist/components/foundation/telemetry.mjs.map +1 -1
- package/dist/contracts.d.mts +5 -0
- package/dist/contracts.mjs +1 -0
- package/dist/crud.d.mts +185 -27
- package/dist/crud.mjs +1 -1
- package/dist/crud.mjs.map +1 -1
- package/dist/effect.d.mts +16 -0
- package/dist/effect.mjs +1 -0
- package/dist/errors.d.mts +6 -6
- package/dist/errors.mjs +1 -1
- package/dist/errors.mjs.map +1 -1
- package/dist/filters.d.mts +4 -0
- package/dist/filters.mjs +1 -0
- package/dist/idempotency.d.mts +2 -0
- package/dist/idempotency.mjs +1 -0
- package/dist/index.d.mts +14 -7
- package/dist/index.mjs +1 -1
- package/dist/json-schema.d.mts +40 -0
- package/dist/json-schema.mjs +2 -0
- package/dist/json-schema.mjs.map +1 -0
- package/dist/k/compile.d.mts +17 -0
- package/dist/k/compile.mjs +2 -0
- package/dist/k/compile.mjs.map +1 -0
- package/dist/k/dates.d.mts +23 -0
- package/dist/k/dates.mjs +2 -0
- package/dist/k/dates.mjs.map +1 -0
- package/dist/k/formats.d.mts +24 -0
- package/dist/k/formats.mjs +2 -0
- package/dist/k/formats.mjs.map +1 -0
- package/dist/k/index.d.mts +32 -0
- package/dist/k/index.mjs +2 -0
- package/dist/k/index.mjs.map +1 -0
- package/dist/k/issues.d.mts +31 -0
- package/dist/k/issues.mjs +2 -0
- package/dist/k/issues.mjs.map +1 -0
- package/dist/k/kinds.d.mts +81 -0
- package/dist/k/kinds.mjs +2 -0
- package/dist/k/kinds.mjs.map +1 -0
- package/dist/k/object.d.mts +43 -0
- package/dist/k/object.mjs +2 -0
- package/dist/k/object.mjs.map +1 -0
- package/dist/k/parse.d.mts +29 -0
- package/dist/k/parse.mjs +2 -0
- package/dist/k/parse.mjs.map +1 -0
- package/dist/k/schema.d.mts +100 -0
- package/dist/k/schema.mjs +2 -0
- package/dist/k/schema.mjs.map +1 -0
- package/dist/k/standard.d.mts +8 -0
- package/dist/k/standard.mjs +2 -0
- package/dist/k/standard.mjs.map +1 -0
- package/dist/k/types.d.mts +64 -0
- package/dist/k/types.mjs +1 -0
- package/dist/k.d.mts +8 -0
- package/dist/k.mjs +1 -0
- package/dist/middleware.d.mts +8 -11
- package/dist/middleware.mjs +1 -1
- package/dist/middleware.mjs.map +1 -1
- package/dist/modules/contracts/binding.d.mts +23 -0
- package/dist/modules/contracts/binding.mjs +2 -0
- package/dist/modules/contracts/binding.mjs.map +1 -0
- package/dist/modules/contracts/contract.d.mts +67 -0
- package/dist/modules/contracts/contract.mjs +2 -0
- package/dist/modules/contracts/contract.mjs.map +1 -0
- package/dist/modules/contracts/convex.d.mts +18 -0
- package/dist/modules/contracts/convex.mjs +2 -0
- package/dist/modules/contracts/convex.mjs.map +1 -0
- package/dist/modules/contracts/domain.d.mts +62 -0
- package/dist/modules/contracts/domain.mjs +2 -0
- package/dist/modules/contracts/domain.mjs.map +1 -0
- package/dist/modules/contracts/errors.d.mts +737 -0
- package/dist/modules/contracts/errors.mjs +2 -0
- package/dist/modules/contracts/errors.mjs.map +1 -0
- package/dist/modules/contracts/exposure.d.mts +103 -0
- package/dist/modules/contracts/exposure.mjs +2 -0
- package/dist/modules/contracts/exposure.mjs.map +1 -0
- package/dist/modules/contracts/idempotency.d.mts +85 -0
- package/dist/modules/contracts/idempotency.mjs +2 -0
- package/dist/modules/contracts/idempotency.mjs.map +1 -0
- package/dist/modules/contracts/lazy.d.mts +6 -0
- package/dist/modules/contracts/lazy.mjs +2 -0
- package/dist/modules/contracts/lazy.mjs.map +1 -0
- package/dist/modules/contracts/standard.d.mts +17 -0
- package/dist/modules/contracts/standard.mjs +2 -0
- package/dist/modules/contracts/standard.mjs.map +1 -0
- package/dist/modules/contracts/workflow.d.mts +165 -0
- package/dist/modules/contracts/workflow.mjs +2 -0
- package/dist/modules/contracts/workflow.mjs.map +1 -0
- package/dist/modules/effect/action.d.mts +63 -0
- package/dist/modules/effect/action.mjs +2 -0
- package/dist/modules/effect/action.mjs.map +1 -0
- package/dist/modules/effect/agent-tools.d.mts +2 -0
- package/dist/modules/effect/agent-tools.mjs +1 -0
- package/dist/modules/effect/api-runtime.d.mts +36 -0
- package/dist/modules/effect/api-runtime.mjs +2 -0
- package/dist/modules/effect/api-runtime.mjs.map +1 -0
- package/dist/modules/effect/api.d.mts +46 -0
- package/dist/modules/effect/api.mjs +2 -0
- package/dist/modules/effect/api.mjs.map +1 -0
- package/dist/modules/effect/auth.d.mts +46 -0
- package/dist/modules/effect/auth.mjs +2 -0
- package/dist/modules/effect/auth.mjs.map +1 -0
- package/dist/modules/effect/client.d.mts +15 -0
- package/dist/modules/effect/client.mjs +1 -0
- package/dist/modules/effect/command.d.mts +108 -0
- package/dist/modules/effect/command.mjs +2 -0
- package/dist/modules/effect/command.mjs.map +1 -0
- package/dist/modules/effect/crud.d.mts +885 -0
- package/dist/modules/effect/crud.mjs +2 -0
- package/dist/modules/effect/crud.mjs.map +1 -0
- package/dist/modules/effect/domain.d.mts +82 -0
- package/dist/modules/effect/domain.mjs +2 -0
- package/dist/modules/effect/domain.mjs.map +1 -0
- package/dist/modules/effect/errors.d.mts +13 -0
- package/dist/modules/effect/errors.mjs +2 -0
- package/dist/modules/effect/errors.mjs.map +1 -0
- package/dist/modules/effect/failure-audit.d.mts +48 -0
- package/dist/modules/effect/failure-audit.mjs +2 -0
- package/dist/modules/effect/failure-audit.mjs.map +1 -0
- package/dist/modules/effect/failures.d.mts +21 -0
- package/dist/modules/effect/failures.mjs +2 -0
- package/dist/modules/effect/failures.mjs.map +1 -0
- package/dist/modules/effect/foundation.d.mts +23 -0
- package/dist/modules/effect/foundation.mjs +2 -0
- package/dist/modules/effect/foundation.mjs.map +1 -0
- package/dist/modules/effect/idempotency.d.mts +29 -0
- package/dist/modules/effect/idempotency.mjs +2 -0
- package/dist/modules/effect/idempotency.mjs.map +1 -0
- package/dist/modules/effect/input.d.mts +10 -0
- package/dist/modules/effect/input.mjs +2 -0
- package/dist/modules/effect/input.mjs.map +1 -0
- package/dist/modules/effect/normalize.d.mts +7 -0
- package/dist/modules/effect/normalize.mjs +2 -0
- package/dist/modules/effect/normalize.mjs.map +1 -0
- package/dist/modules/effect/operation.d.mts +148 -0
- package/dist/modules/effect/operation.mjs +2 -0
- package/dist/modules/effect/operation.mjs.map +1 -0
- package/dist/modules/effect/query.d.mts +90 -0
- package/dist/modules/effect/query.mjs +2 -0
- package/dist/modules/effect/query.mjs.map +1 -0
- package/dist/modules/effect/schema.d.mts +30 -0
- package/dist/modules/effect/schema.mjs +2 -0
- package/dist/modules/effect/schema.mjs.map +1 -0
- package/dist/modules/effect/scope.d.mts +25 -0
- package/dist/modules/effect/scope.mjs +2 -0
- package/dist/modules/effect/scope.mjs.map +1 -0
- package/dist/modules/effect/workflow.d.mts +75 -0
- package/dist/modules/effect/workflow.mjs +2 -0
- package/dist/modules/effect/workflow.mjs.map +1 -0
- package/dist/modules/foundation/foundation.d.mts +108 -0
- package/dist/modules/foundation/foundation.mjs +2 -0
- package/dist/modules/foundation/foundation.mjs.map +1 -0
- package/dist/modules/foundation/operation.d.mts +139 -0
- package/dist/modules/foundation/operation.mjs +2 -0
- package/dist/modules/foundation/operation.mjs.map +1 -0
- package/dist/namespace.d.mts +104 -0
- package/dist/namespace.mjs +2 -0
- package/dist/namespace.mjs.map +1 -0
- package/dist/oxlint/architecture.d.mts +23 -0
- package/dist/oxlint/architecture.mjs +2 -0
- package/dist/oxlint/architecture.mjs.map +1 -0
- package/dist/oxlint/ast.d.mts +51 -0
- package/dist/oxlint/ast.mjs +2 -0
- package/dist/oxlint/ast.mjs.map +1 -0
- package/dist/oxlint/components.d.mts +4 -0
- package/dist/oxlint/components.mjs +2 -0
- package/dist/oxlint/components.mjs.map +1 -0
- package/dist/oxlint/ownership.d.mts +59 -0
- package/dist/oxlint/ownership.mjs +2 -0
- package/dist/oxlint/ownership.mjs.map +1 -0
- package/dist/oxlint/reserved-files.d.mts +4 -0
- package/dist/oxlint/reserved-files.mjs +2 -0
- package/dist/oxlint/reserved-files.mjs.map +1 -0
- package/dist/oxlint.d.mts +9 -0
- package/dist/oxlint.mjs +2 -0
- package/dist/oxlint.mjs.map +1 -0
- package/dist/querying/cursors.d.mts +94 -0
- package/dist/querying/cursors.mjs +2 -0
- package/dist/querying/cursors.mjs.map +1 -0
- package/dist/querying/execution.d.mts +40 -0
- package/dist/querying/execution.mjs +2 -0
- package/dist/querying/execution.mjs.map +1 -0
- package/dist/querying/failures.d.mts +11 -0
- package/dist/querying/failures.mjs +2 -0
- package/dist/querying/failures.mjs.map +1 -0
- package/dist/querying/filter-boundary.d.mts +25 -0
- package/dist/querying/filter-boundary.mjs +2 -0
- package/dist/querying/filter-boundary.mjs.map +1 -0
- package/dist/querying/filters.d.mts +180 -0
- package/dist/querying/filters.mjs +2 -0
- package/dist/querying/filters.mjs.map +1 -0
- package/dist/querying/planner.d.mts +61 -0
- package/dist/querying/planner.mjs +2 -0
- package/dist/querying/planner.mjs.map +1 -0
- package/dist/querying/relationships.d.mts +58 -0
- package/dist/querying/relationships.mjs +2 -0
- package/dist/querying/relationships.mjs.map +1 -0
- package/dist/querying/search.d.mts +69 -0
- package/dist/querying/search.mjs +2 -0
- package/dist/querying/search.mjs.map +1 -0
- package/dist/querying/security.d.mts +123 -0
- package/dist/querying/security.mjs +2 -0
- package/dist/querying/security.mjs.map +1 -0
- package/dist/querying/shared/ast.d.mts +26 -0
- package/dist/querying/shared/ast.mjs +2 -0
- package/dist/querying/shared/ast.mjs.map +1 -0
- package/dist/querying/shared/contract.d.mts +98 -0
- package/dist/querying/shared/contract.mjs +2 -0
- package/dist/querying/shared/contract.mjs.map +1 -0
- package/dist/querying/shared/evaluate.d.mts +5 -0
- package/dist/querying/shared/evaluate.mjs +2 -0
- package/dist/querying/shared/evaluate.mjs.map +1 -0
- package/dist/querying/shared/filters.d.mts +65 -0
- package/dist/querying/shared/filters.mjs +2 -0
- package/dist/querying/shared/filters.mjs.map +1 -0
- package/dist/querying/shared/native-json.d.mts +7 -0
- package/dist/querying/shared/native-json.mjs +2 -0
- package/dist/querying/shared/native-json.mjs.map +1 -0
- package/dist/querying/shared/page.d.mts +20 -0
- package/dist/querying/shared/page.mjs +2 -0
- package/dist/querying/shared/page.mjs.map +1 -0
- package/dist/querying.d.mts +82 -0
- package/dist/querying.mjs +2 -0
- package/dist/querying.mjs.map +1 -0
- package/dist/react/failures.d.mts +24 -0
- package/dist/react/failures.mjs +2 -0
- package/dist/react/failures.mjs.map +1 -0
- package/dist/react/optimistic.d.mts +46 -0
- package/dist/react/optimistic.mjs +2 -0
- package/dist/react/optimistic.mjs.map +1 -0
- package/dist/react/pagination-state.d.mts +39 -0
- package/dist/react/pagination-state.mjs +2 -0
- package/dist/react/pagination-state.mjs.map +1 -0
- package/dist/react/use-command.d.mts +22 -0
- package/dist/react/use-command.mjs +2 -0
- package/dist/react/use-command.mjs.map +1 -0
- package/dist/react/use-paginated-list.d.mts +34 -0
- package/dist/react/use-paginated-list.mjs +2 -0
- package/dist/react/use-paginated-list.mjs.map +1 -0
- package/dist/react.d.mts +6 -0
- package/dist/react.mjs +1 -0
- package/dist/registration.d.mts +65 -0
- package/dist/registration.mjs +2 -0
- package/dist/registration.mjs.map +1 -0
- package/dist/relations-public.d.mts +2 -0
- package/dist/relations-public.mjs +1 -0
- package/dist/relations.d.mts +274 -0
- package/dist/relations.mjs +2 -0
- package/dist/relations.mjs.map +1 -0
- package/dist/state-machine.d.mts +1 -4
- package/dist/state-machine.mjs.map +1 -1
- package/dist/table.d.mts +222 -0
- package/dist/table.mjs +2 -0
- package/dist/table.mjs.map +1 -0
- package/dist/tenancy.d.mts +6 -8
- package/dist/tenancy.mjs +1 -1
- package/dist/tenancy.mjs.map +1 -1
- package/dist/triggers.d.mts +12 -10
- package/dist/triggers.mjs +1 -1
- package/dist/triggers.mjs.map +1 -1
- package/dist/webhooks.d.mts +22 -112
- package/dist/webhooks.mjs +1 -1
- package/dist/webhooks.mjs.map +1 -1
- package/dist/workflow.d.mts +2 -0
- package/dist/workflow.mjs +1 -0
- package/dist/zod.d.mts +30 -0
- package/dist/zod.mjs +2 -0
- package/dist/zod.mjs.map +1 -0
- package/package.json +145 -33
- package/src/test.ts +9 -17
- package/CHANGELOG.md +0 -145
- package/ROADMAP.md +0 -126
- package/dist/zod-table.d.mts +0 -175
- package/dist/zod-table.mjs +0 -2
- package/dist/zod-table.mjs.map +0 -1
- package/docs/agent-tools.md +0 -41
- package/docs/approvals.md +0 -200
- package/docs/architecture.md +0 -124
- package/docs/auth.md +0 -218
- package/docs/commands.md +0 -278
- package/docs/conventions.md +0 -291
- package/docs/crud.md +0 -62
- package/docs/llms.md +0 -220
- package/docs/maintainability.md +0 -124
- package/docs/migration.md +0 -351
- package/docs/plans/2026-08-14-001-feat-v0.1.0-feature-set-plan.md +0 -461
- package/docs/plans/2026-08-21-0930-feat-resolve-organization-hook-plan.md +0 -178
- package/docs/tenancy.md +0 -179
- package/docs/triggers.md +0 -75
- package/docs/upgrading.md +0 -175
- package/docs/webhooks.md +0 -58
- package/docs/zod-table.md +0 -173
- package/scripts/convex-config-bridge.mjs +0 -55
- package/scripts/extract-changelog.mjs +0 -29
- package/scripts/smoke-packed-components.mjs +0 -374
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Pure interval controller. Keys include the epoch so late subscription results cannot enter a reset. */
|
|
2
|
+
export type ListPage = {
|
|
3
|
+
page: unknown[];
|
|
4
|
+
continueCursor: string;
|
|
5
|
+
isDone: boolean;
|
|
6
|
+
completeness?: string;
|
|
7
|
+
splitCursor?: string | null;
|
|
8
|
+
pageStatus?: 'SplitRecommended' | 'SplitRequired' | null;
|
|
9
|
+
paginationMode?: 'native-search';
|
|
10
|
+
};
|
|
11
|
+
type Interval<Page extends ListPage> = {
|
|
12
|
+
cursor: string | null;
|
|
13
|
+
endCursor?: string;
|
|
14
|
+
value?: Page;
|
|
15
|
+
children?: [string, string];
|
|
16
|
+
};
|
|
17
|
+
export type PaginationState<Page extends ListPage> = {
|
|
18
|
+
epoch: number;
|
|
19
|
+
identity: string;
|
|
20
|
+
restarted: boolean;
|
|
21
|
+
next: number;
|
|
22
|
+
order: string[];
|
|
23
|
+
intervals: Record<string, Interval<Page>>;
|
|
24
|
+
mode?: 'browse' | 'native-search';
|
|
25
|
+
error?: Error;
|
|
26
|
+
};
|
|
27
|
+
export declare function initialPagination<Page extends ListPage>(identity: string, epoch: number, skip: boolean, restarted?: boolean): PaginationState<Page>;
|
|
28
|
+
export declare function failPagination<Page extends ListPage>(state: PaginationState<Page>, error: Error): PaginationState<Page>;
|
|
29
|
+
export declare function reconcilePagination<Page extends ListPage>(state: PaginationState<Page>, results: Record<string, Page | Error | undefined>): PaginationState<Page>;
|
|
30
|
+
export declare function paginationView<Page extends ListPage>(state: PaginationState<Page>): {
|
|
31
|
+
rows: Page["page"][number][];
|
|
32
|
+
completeness: string | undefined;
|
|
33
|
+
isLoading: boolean;
|
|
34
|
+
isFetchingNextPage: boolean;
|
|
35
|
+
hasNextPage: boolean;
|
|
36
|
+
};
|
|
37
|
+
export declare function nextPagination<Page extends ListPage>(state: PaginationState<Page>): PaginationState<Page>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=pagination-state.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,t,n,r=!1){let i=`${t}:0`;return{identity:e,epoch:t,restarted:r,next:1,order:n?[]:[i],intervals:n?{}:{[i]:{cursor:null}}}}function t(e,t){return{...e,order:[],intervals:{},error:t}}function n(e,n){if(e.error)return e;let r=!1,i={...e.intervals};for(let a of Object.keys(i)){let o=n[a];if(o instanceof Error)return t(e,o);o!==void 0&&o!==i[a].value&&(i[a]={...i[a],value:o},r=!0)}let a=i[e.order[0]]?.value,o=e.mode??(a?a.paginationMode??`browse`:void 0);for(let n of Object.values(i)){let r=n.value;if(r&&(r.paginationMode!==void 0&&r.paginationMode!==`native-search`||o!==void 0&&(r.paginationMode??`browse`)!==o||r.completeness===`searchSplitRequired`||o===`native-search`&&(r.pageStatus!=null||r.splitCursor!=null)))return t(e,/* @__PURE__ */ Error(`Invalid pagination protocol`))}let s=e.order,c=e.next;for(let n of e.order){let a=i[n],o=a.value;if(o){if(a.children)a.children.every(e=>i[e].value!==void 0)&&(s=s.flatMap(e=>e===n?a.children:[e]),delete i[n],r=!0);else if(o.pageStatus===`SplitRecommended`||o.pageStatus===`SplitRequired`){let s=o.splitCursor;if(!s||s===a.cursor||s===o.continueCursor||s===a.endCursor||o.continueCursor===a.cursor)return t(e,/* @__PURE__ */ Error(`Non-progressing pagination split`));let l=[`${e.epoch}:${c++}`,`${e.epoch}:${c++}`];i[n]={...a,children:l},i[l[0]]={cursor:a.cursor,endCursor:s},i[l[1]]={cursor:s,endCursor:a.endCursor??o.continueCursor},r=!0}else if(!o.isDone&&(!o.continueCursor||o.continueCursor===a.cursor))return t(e,/* @__PURE__ */ Error(`Non-progressing pagination cursor`))}}return r?{...e,mode:o,next:c,order:s,intervals:i}:e}function r(e){let t=[],n,r=!1;for(let i of e.order){let a=e.intervals[i];if(!a.value){r=!0;break}t.push(...a.value.page),n=a.value}let i=Object.values(e.intervals).some(e=>e.children!==void 0);return{rows:t,completeness:n?.completeness,isLoading:!e.error&&r&&n===void 0,isFetchingNextPage:!e.error&&(r&&n!==void 0||i),hasNextPage:!e.error&&!r&&!i&&n!==void 0&&!n.isDone}}function i(e){if(!r(e).hasNextPage)return e;let t=e.order[e.order.length-1],n=e.intervals[t],i=n.endCursor??n.value.continueCursor,a=`${e.epoch}:${e.next}`;return{...e,next:e.next+1,order:[...e.order,a],intervals:{...e.intervals,[t]:e.mode===`native-search`?n:{...n,endCursor:i},[a]:{cursor:i}}}}export{t as failPagination,e as initialPagination,i as nextPagination,r as paginationView,n as reconcilePagination};
|
|
2
|
+
//# sourceMappingURL=pagination-state.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination-state.mjs","names":["initialPagination","key","epoch","skip","failPagination","state","reconcilePagination","changed","intervals","value","results","first","mode","interval","order","next","child","item","split","children","paginationView","rows","latest","loading","splitting","nextPagination","lastKey","last","endCursor"],"sources":["../../src/react/pagination-state.ts"],"sourcesContent":["/** Pure interval controller. Keys include the epoch so late subscription results cannot enter a reset. */\nexport type ListPage = {\n\tpage: unknown[]\n\tcontinueCursor: string\n\tisDone: boolean\n\tcompleteness?: string\n\tsplitCursor?: string | null\n\tpageStatus?: 'SplitRecommended' | 'SplitRequired' | null\n\tpaginationMode?: 'native-search'\n}\ntype Interval<Page extends ListPage> = {\n\tcursor: string | null\n\tendCursor?: string\n\tvalue?: Page\n\tchildren?: [string, string]\n}\nexport type PaginationState<Page extends ListPage> = {\n\tepoch: number\n\tidentity: string\n\trestarted: boolean\n\tnext: number\n\torder: string[]\n\tintervals: Record<string, Interval<Page>>\n\tmode?: 'browse' | 'native-search'\n\terror?: Error\n}\nexport function initialPagination<Page extends ListPage>(\n\tidentity: string,\n\tepoch: number,\n\tskip: boolean,\n\trestarted = false,\n): PaginationState<Page> {\n\tconst key = `${epoch}:0`\n\treturn {\n\t\tidentity,\n\t\tepoch,\n\t\trestarted,\n\t\tnext: 1,\n\t\torder: skip ? [] : [key],\n\t\tintervals: skip ? {} : { [key]: { cursor: null } },\n\t}\n}\nexport function failPagination<Page extends ListPage>(\n\tstate: PaginationState<Page>,\n\terror: Error,\n): PaginationState<Page> {\n\treturn { ...state, order: [], intervals: {}, error }\n}\nexport function reconcilePagination<Page extends ListPage>(\n\tstate: PaginationState<Page>,\n\tresults: Record<string, Page | Error | undefined>,\n): PaginationState<Page> {\n\tif (state.error) return state\n\tlet changed = false\n\tconst intervals = { ...state.intervals }\n\tfor (const key of Object.keys(intervals)) {\n\t\tconst value = results[key]\n\t\tif (value instanceof Error) return failPagination(state, value)\n\t\tif (value !== undefined && value !== intervals[key].value) {\n\t\t\tintervals[key] = { ...intervals[key], value }\n\t\t\tchanged = true\n\t\t}\n\t}\n\t// The first result chooses the protocol for this epoch, including on reactive reruns.\n\tconst first = intervals[state.order[0]]?.value\n\tconst mode = state.mode ?? (first ? (first.paginationMode ?? 'browse') : undefined)\n\tfor (const interval of Object.values(intervals)) {\n\t\tconst value = interval.value\n\t\tif (!value) continue\n\t\tif (\n\t\t\t(value.paginationMode !== undefined && value.paginationMode !== 'native-search') ||\n\t\t\t(mode !== undefined && (value.paginationMode ?? 'browse') !== mode) ||\n\t\t\tvalue.completeness === 'searchSplitRequired' ||\n\t\t\t(mode === 'native-search' && (value.pageStatus != null || value.splitCursor != null))\n\t\t)\n\t\t\treturn failPagination(state, new Error('Invalid pagination protocol'))\n\t}\n\tlet order = state.order,\n\t\tnext = state.next\n\tfor (const key of state.order) {\n\t\tconst interval = intervals[key],\n\t\t\tvalue = interval.value\n\t\tif (!value) continue\n\t\tif (interval.children) {\n\t\t\tif (interval.children.every((child) => intervals[child].value !== undefined)) {\n\t\t\t\torder = order.flatMap((item) => (item === key ? interval.children! : [item]))\n\t\t\t\tdelete intervals[key]\n\t\t\t\tchanged = true\n\t\t\t}\n\t\t} else if (value.pageStatus === 'SplitRecommended' || value.pageStatus === 'SplitRequired') {\n\t\t\tconst split = value.splitCursor\n\t\t\tif (\n\t\t\t\t!split ||\n\t\t\t\tsplit === interval.cursor ||\n\t\t\t\tsplit === value.continueCursor ||\n\t\t\t\tsplit === interval.endCursor ||\n\t\t\t\tvalue.continueCursor === interval.cursor\n\t\t\t)\n\t\t\t\treturn failPagination(state, new Error('Non-progressing pagination split'))\n\t\t\tconst children: [string, string] = [`${state.epoch}:${next++}`, `${state.epoch}:${next++}`]\n\t\t\tintervals[key] = { ...interval, children }\n\t\t\tintervals[children[0]] = { cursor: interval.cursor, endCursor: split }\n\t\t\tintervals[children[1]] = {\n\t\t\t\tcursor: split,\n\t\t\t\tendCursor: interval.endCursor ?? value.continueCursor,\n\t\t\t}\n\t\t\tchanged = true\n\t\t} else if (\n\t\t\t!value.isDone &&\n\t\t\t(!value.continueCursor || value.continueCursor === interval.cursor)\n\t\t) {\n\t\t\treturn failPagination(state, new Error('Non-progressing pagination cursor'))\n\t\t}\n\t}\n\treturn changed ? { ...state, mode, next, order, intervals } : state\n}\nexport function paginationView<Page extends ListPage>(state: PaginationState<Page>) {\n\tconst rows: Page['page'][number][] = []\n\tlet latest: Page | undefined\n\tlet loading = false\n\tfor (const key of state.order) {\n\t\tconst interval = state.intervals[key]\n\t\tif (!interval.value) {\n\t\t\tloading = true\n\t\t\tbreak\n\t\t}\n\t\trows.push(...interval.value.page)\n\t\tlatest = interval.value\n\t}\n\tconst splitting = Object.values(state.intervals).some(\n\t\t(interval) => interval.children !== undefined,\n\t)\n\treturn {\n\t\trows,\n\t\tcompleteness: latest?.completeness,\n\t\tisLoading: !state.error && loading && latest === undefined,\n\t\tisFetchingNextPage: !state.error && ((loading && latest !== undefined) || splitting),\n\t\thasNextPage: !state.error && !loading && !splitting && latest !== undefined && !latest.isDone,\n\t}\n}\nexport function nextPagination<Page extends ListPage>(\n\tstate: PaginationState<Page>,\n): PaginationState<Page> {\n\tif (!paginationView(state).hasNextPage) return state\n\tconst lastKey = state.order[state.order.length - 1]\n\tconst last = state.intervals[lastKey]\n\tconst endCursor = last.endCursor ?? last.value!.continueCursor\n\tconst key = `${state.epoch}:${state.next}`\n\treturn {\n\t\t...state,\n\t\tnext: state.next + 1,\n\t\torder: [...state.order, key],\n\t\tintervals: {\n\t\t\t...state.intervals,\n\t\t\t// Fixed adjacent ranges keep reactive inserts/deletes from moving rows across a loaded boundary.\n\t\t\t// Native search windows are maintained by SDK journals; their original inputs stay immutable.\n\t\t\t[lastKey]: state.mode === 'native-search' ? last : { ...last, endCursor },\n\t\t\t[key]: { cursor: endCursor },\n\t\t},\n\t}\n}\n"],"mappings":"AA0BA,SAAgBA,EACf,EACA,EACA,EACA,EAAY,GACY,CACxB,IAAMC,EAAM,GAAGC,EAAM,IACrB,MAAO,CACN,WACA,QACA,YACA,KAAM,E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AAS,CAAC,CAAC,KAC/C,GAAaQ,EAAS,WAAa,IAAA,EACrC,EACA,MAAO,CACN,OACA,aAAcS,GAAQ,aACtB,UAAW,CAACjB,EAAM,OAASkB,GAAWD,IAAW,IAAA,GACjD,mBAAoB,CAACjB,EAAM,QAAWkB,GAAWD,IAAW,IAAA,IAAcE,GAC1E,YAAa,CAACnB,EAAM,OAAS,CAACkB,GAAW,CAACC,GAAaF,IAAW,IAAA,IAAa,CAACA,EAAO,MACxF,CACD,CACA,SAAgBG,EACf,EACwB,CACxB,GAAI,CAACL,EAAef,CAAK,CAAC,CAAC,YAAa,OAAOA,EAC/C,IAAMqB,EAAUrB,EAAM,MAAMA,EAAM,MAAM,OAAS,GAC3CsB,EAAOtB,EAAM,UAAUqB,GACvBE,EAAYD,EAAK,WAAaA,EAAK,MAAO,eAC1C1B,EAAM,GAAGI,EAAM,MAAM,GAAGA,EAAM,OACpC,MAAO,CACN,GAAGA,EACH,KAAMA,EAAM,KAAO,EACnB,MAAO,CAAC,GAAGA,EAAM,MAAOJ,CAAG,EAC3B,UAAW,CACV,GAAGI,EAAM,WAGRqB,GAAUrB,EAAM,OAAS,gBAAkBsB,EAAO,CAAE,GAAGA,EAAM,WAAU,GACvE1B,GAAM,CAAE,OAAQ2B,CAAU,CAC5B,CACD,CACD,C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FailureContract, FailureOf } from "../modules/contracts/errors.mjs";
|
|
2
|
+
import "./failures.mjs";
|
|
3
|
+
import { FunctionArgs, FunctionReference, FunctionReturnType, OptionalRestArgs } from "convex/server";
|
|
4
|
+
import { OptimisticUpdate } from "convex/browser";
|
|
5
|
+
export type CommandResult<Result, Contract extends FailureContract> = Readonly<{
|
|
6
|
+
ok: true;
|
|
7
|
+
value: Result;
|
|
8
|
+
}> | Readonly<{
|
|
9
|
+
ok: false;
|
|
10
|
+
failure: FailureOf<Contract>;
|
|
11
|
+
}>;
|
|
12
|
+
export type Command<Mutation extends FunctionReference<'mutation'>, Contract extends FailureContract> = ((...args: OptionalRestArgs<Mutation>) => Promise<CommandResult<FunctionReturnType<Mutation>, Contract>>) & {
|
|
13
|
+
readonly isPending: boolean;
|
|
14
|
+
/** The latest invocation's settled result; older concurrent completions cannot overwrite it. */
|
|
15
|
+
readonly result: CommandResult<FunctionReturnType<Mutation>, Contract> | undefined;
|
|
16
|
+
};
|
|
17
|
+
/** Explicit failures plus Convex-owned optimistic execution, replay and rollback. */
|
|
18
|
+
export declare function useCommand<Mutation extends FunctionReference<'mutation'>, Contract extends FailureContract, Update extends OptimisticUpdate<FunctionArgs<Mutation>> = OptimisticUpdate<FunctionArgs<Mutation>>>(reference: Mutation, options: {
|
|
19
|
+
errors: Contract;
|
|
20
|
+
optimisticUpdate?: Update & (ReturnType<Update> extends Promise<any> ? 'Optimistic update handlers must be synchronous' : {});
|
|
21
|
+
}): Command<Mutation, Contract>;
|
|
22
|
+
//# sourceMappingURL=use-command.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{decodeFailure as e}from"../modules/contracts/errors.mjs";import{useCallback as t,useMemo as n,useRef as r,useState as i}from"react";import{useMutation as a}from"convex/react";function o(o,s){let c=a(o),{errors:l,optimisticUpdate:u}=s,d=n(()=>u?c.withOptimisticUpdate(u):c,[c,u]),[f,p]=i(0),[m,h]=i(),g=r(0),_=t(async(...t)=>{let n=++g.current;p(e=>e+1);let r;try{r={ok:!0,value:await d(...t)}}catch(t){r={ok:!1,failure:e(t,l)}}return p(e=>e-1),g.current===n&&h(r),r},[d,l]);return n(()=>Object.assign((...e)=>_(...e),{isPending:f>0,result:m}),[_,f,m])}export{o as useCommand};
|
|
2
|
+
//# sourceMappingURL=use-command.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-command.mjs","names":["useCommand","mutation","useMutation","reference","options","run","useMemo","optimisticUpdate","pending","setPending","useState","result","setResult","latest","useRef","execute","useCallback","args","invocation","count","settled","error","decodeFailure","errors"],"sources":["../../src/react/use-command.ts"],"sourcesContent":["import { useCallback, useMemo, useRef, useState } from 'react'\nimport { useMutation } from 'convex/react'\nimport type { OptimisticUpdate } from 'convex/browser'\nimport type {\n\tFunctionArgs,\n\tFunctionReference,\n\tFunctionReturnType,\n\tOptionalRestArgs,\n} from 'convex/server'\nimport { decodeFailure, type FailureContract, type FailureOf } from './failures'\n\nexport type CommandResult<Result, Contract extends FailureContract> =\n\t| Readonly<{ ok: true; value: Result }>\n\t| Readonly<{ ok: false; failure: FailureOf<Contract> }>\nexport type Command<\n\tMutation extends FunctionReference<'mutation'>,\n\tContract extends FailureContract,\n> = ((\n\t...args: OptionalRestArgs<Mutation>\n) => Promise<CommandResult<FunctionReturnType<Mutation>, Contract>>) & {\n\treadonly isPending: boolean\n\t/** The latest invocation's settled result; older concurrent completions cannot overwrite it. */\n\treadonly result: CommandResult<FunctionReturnType<Mutation>, Contract> | undefined\n}\n\n/** Explicit failures plus Convex-owned optimistic execution, replay and rollback. */\nexport function useCommand<\n\tMutation extends FunctionReference<'mutation'>,\n\tContract extends FailureContract,\n\tUpdate extends OptimisticUpdate<FunctionArgs<Mutation>> = OptimisticUpdate<\n\t\tFunctionArgs<Mutation>\n\t>,\n>(\n\treference: Mutation,\n\toptions: {\n\t\terrors: Contract\n\t\toptimisticUpdate?: Update &\n\t\t\t(ReturnType<Update> extends Promise<any>\n\t\t\t\t? 'Optimistic update handlers must be synchronous'\n\t\t\t\t: {})\n\t},\n): Command<Mutation, Contract> {\n\tconst mutation = useMutation(reference)\n\tconst { errors, optimisticUpdate } = options\n\t// Attach once per mutation/callback identity. Convex may invoke this callback repeatedly while pending.\n\tconst run = useMemo(\n\t\t() => (optimisticUpdate ? mutation.withOptimisticUpdate<Update>(optimisticUpdate) : mutation),\n\t\t[mutation, optimisticUpdate],\n\t)\n\tconst [pending, setPending] = useState(0)\n\tconst [result, setResult] = useState<CommandResult<FunctionReturnType<Mutation>, Contract>>()\n\tconst latest = useRef(0)\n\tconst execute = useCallback(\n\t\tasync (...args: OptionalRestArgs<Mutation>) => {\n\t\t\tconst invocation = ++latest.current\n\t\t\tsetPending((count) => count + 1)\n\t\t\tlet settled: CommandResult<FunctionReturnType<Mutation>, Contract>\n\t\t\ttry {\n\t\t\t\tsettled = { ok: true, value: await run(...args) }\n\t\t\t} catch (error) {\n\t\t\t\tsettled = { ok: false, failure: decodeFailure(error, errors) }\n\t\t\t}\n\t\t\tsetPending((count) => count - 1)\n\t\t\tif (latest.current === invocation) setResult(settled)\n\t\t\treturn settled\n\t\t},\n\t\t[run, errors],\n\t)\n\treturn useMemo(\n\t\t() =>\n\t\t\tObject.assign((...args: OptionalRestArgs<Mutation>) => execute(...args), {\n\t\t\t\tisPending: pending > 0,\n\t\t\t\tresult,\n\t\t\t}),\n\t\t[execute, pending, result],\n\t)\n}\n"],"mappings":"A,sLA0BA,SAAgBA,EAOf,EACA,EAO8B,CAC9B,IAAMC,EAAWC,EAAYC,CAAS,EAChC,CAAE,SAAQ,oBAAqBC,EAE/BC,EAAMC,MACJC,EAAmBN,EAAS,qBAA6BM,CAAgB,EAAIN,EACpF,CAACA,EAAUM,CAAgB,CAC5B,EACM,CAACC,EAASC,GAAcC,EAAS,CAAC,EAClC,CAACC,EAAQC,GAAaF,EAAgE,EACtFG,EAASC,EAAO,CAAC,EACjBC,EAAUC,EACf,MAAO,GAAGC,IAAqC,CAC9C,IAAMC,EAAa,EAAEL,EAAO,QAC5BJ,EAAY,GAAUU,EAAQ,CAAC,EAC/B,IAAIC,EACJ,GAAI,CACH,EAAU,CAAE,GAAI,GAAM,MAAO,MAAMf,EAAI,GAAGY,CAAI,CAAE,CACjD,OAASI,EAAO,CACf,EAAU,CAAE,GAAI,GAAO,QAASC,EAAcD,EAAOE,CAAM,CAAE,CAC9D,CAGA,OAFAd,EAAY,GAAUU,EAAQ,CAAC,EAC3BN,EAAO,UAAYK,GAAYN,EAAUQ,CAAO,EAC7CA,CACR,EACA,CAACf,EAAKkB,CAAM,CACb,EACA,OAAOjB,MAEL,OAAO,QAAQ,GAAGW,IAAqCF,EAAQ,GAAGE,CAAI,EAAG,CACxE,UAAWT,EAAU,EACrB,QACD,CAAC,EACF,CAACO,EAASP,EAASG,CAAM,CAC1B,CACD,C"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FailureContract, FailureOf, queryErrors } from "../modules/contracts/errors.mjs";
|
|
2
|
+
import "./failures.mjs";
|
|
3
|
+
import { ListPage } from "./pagination-state.mjs";
|
|
4
|
+
import { Value } from "convex/values";
|
|
5
|
+
import { FunctionArgs, FunctionReference, FunctionReturnType, PaginationOptions } from "convex/server";
|
|
6
|
+
export type ListQueryReference = FunctionReference<'query', 'public', {
|
|
7
|
+
paginationOpts: PaginationOptions;
|
|
8
|
+
}, ListPage>;
|
|
9
|
+
export type PaginatedList<Query extends ListQueryReference, Contract extends FailureContract = typeof queryErrors> = {
|
|
10
|
+
rows: FunctionReturnType<Query>['page'];
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
hasNextPage: boolean;
|
|
13
|
+
isFetchingNextPage: boolean;
|
|
14
|
+
fetchNextPage: () => void;
|
|
15
|
+
resetKey: string;
|
|
16
|
+
completeness: FunctionReturnType<Query>['completeness'] | undefined;
|
|
17
|
+
failure: FailureOf<Contract> | undefined;
|
|
18
|
+
/** Original subscription error, without decoding or mutation. */
|
|
19
|
+
error: Error | undefined;
|
|
20
|
+
};
|
|
21
|
+
export type PaginatedListOptions<Contract extends FailureContract = typeof queryErrors> = {
|
|
22
|
+
/** Integer 1..100. Initial target for native search; browse uses fixed adjacent pages. */
|
|
23
|
+
pageSize: number;
|
|
24
|
+
onInvalidCursor?: 'restart' | 'throw';
|
|
25
|
+
/** Keep failures in state (default), or throw the original error to a React boundary. */
|
|
26
|
+
onFailure?: 'state' | 'throw';
|
|
27
|
+
/** Explicit server contract; generated references do not carry error metadata. Defaults to queryErrors. */
|
|
28
|
+
errors?: Contract;
|
|
29
|
+
/** Convex value identifying the current auth/scope/reset generation. Never a credential. */
|
|
30
|
+
resetIdentity?: Value;
|
|
31
|
+
};
|
|
32
|
+
/** Reactive engine-backed list: fixed browse ranges or SDK-journal search windows. Empty pages advance manually. */
|
|
33
|
+
export declare function usePaginatedList<Query extends ListQueryReference, Contract extends FailureContract = typeof queryErrors>(query: Query, args: Omit<FunctionArgs<Query>, 'paginationOpts'> | 'skip', options: PaginatedListOptions<Contract>): PaginatedList<Query, Contract>;
|
|
34
|
+
//# sourceMappingURL=use-paginated-list.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{decodeFailure as e,queryErrors as t}from"../modules/contracts/errors.mjs";import{initialPagination as n,nextPagination as r,paginationView as i,reconcilePagination as a}from"./pagination-state.mjs";import{convexToJson as o}from"convex/values";import{getFunctionName as s}from"convex/server";import{useMemo as c,useState as l}from"react";import{useQueries as u}from"convex/react";let d=0;function f(f,p,m){let{pageSize:h}=m;if(!Number.isInteger(h)||h<1||h>100)throw Error(`pageSize must be an integer from 1 to 100`);let g=p===`skip`,_=g?{}:p,v=JSON.stringify([s(f),o(_),o(m.resetIdentity??null),h,g]),[y,b]=l(()=>n(v,++d,g)),x=y;x.identity!==v&&(x=n(v,++d,g));let S=c(()=>Object.fromEntries(Object.entries(x.intervals).map(([e,t])=>{let n={numItems:h,cursor:t.cursor,id:x.epoch};return t.endCursor!==void 0&&(n.endCursor=t.endCursor),[e,{query:f,args:{..._,paginationOpts:n}}]})),[x.intervals,x.epoch,v]),C=u(S);x=a(x,C);let w=m.errors??t,T=x.error?e(x.error,w):void 0,E=x.error?e(x.error,t):void 0,D=x.error&&T?._tag===`DeclaredFailure`&&T.code===`invalid-cursor`&&E?._tag===`DeclaredFailure`&&E.code===`invalid-cursor`;if(D&&m.onInvalidCursor!==`throw`&&!x.restarted&&(x=n(v,++d,g,!0),T=void 0),x!==y&&b(x),x.error&&(m.onFailure===`throw`||D&&m.onInvalidCursor===`throw`))throw x.error;let O=i(x),k=x.epoch;return{...O,rows:O.rows,completeness:O.completeness,failure:T,error:x.error,resetKey:`${v}:${+!!x.restarted}`,fetchNextPage:()=>b(e=>e.epoch===k&&e.identity===v?r(e):e)}}export{f as usePaginatedList};
|
|
2
|
+
//# sourceMappingURL=use-paginated-list.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-paginated-list.mjs","names":["epoch","usePaginatedList","options","pageSize","skip","args","effectiveArgs","identity","getFunctionName","query","convexToJson","stored","setState","useState","initialPagination","state","queries","useMemo","key","interval","paginationOpts","results","useQueries","reconcilePagination","errors","queryErrors","failure","decodeFailure","queryFailure","invalid","view","paginationView","currentEpoch","previous","nextPagination"],"sources":["../../src/react/use-paginated-list.ts"],"sourcesContent":["import { useMemo, useState } from 'react'\nimport { useQueries } from 'convex/react'\nimport {\n\tgetFunctionName,\n\ttype FunctionArgs,\n\ttype FunctionReference,\n\ttype FunctionReturnType,\n\ttype PaginationOptions,\n} from 'convex/server'\nimport { convexToJson, type Value } from 'convex/values'\nimport { queryErrors } from '../modules/contracts/errors'\nimport { decodeFailure, type FailureContract, type FailureOf } from './failures'\nimport {\n\tinitialPagination,\n\treconcilePagination,\n\tnextPagination,\n\tpaginationView,\n\ttype ListPage,\n} from './pagination-state'\n\nexport type ListQueryReference = FunctionReference<\n\t'query',\n\t'public',\n\t{ paginationOpts: PaginationOptions },\n\tListPage\n>\nexport type PaginatedList<\n\tQuery extends ListQueryReference,\n\tContract extends FailureContract = typeof queryErrors,\n> = {\n\trows: FunctionReturnType<Query>['page']\n\tisLoading: boolean\n\thasNextPage: boolean\n\tisFetchingNextPage: boolean\n\tfetchNextPage: () => void\n\tresetKey: string\n\tcompleteness: FunctionReturnType<Query>['completeness'] | undefined\n\tfailure: FailureOf<Contract> | undefined\n\t/** Original subscription error, without decoding or mutation. */\n\terror: Error | undefined\n}\nexport type PaginatedListOptions<Contract extends FailureContract = typeof queryErrors> = {\n\t/** Integer 1..100. Initial target for native search; browse uses fixed adjacent pages. */\n\tpageSize: number\n\tonInvalidCursor?: 'restart' | 'throw'\n\t/** Keep failures in state (default), or throw the original error to a React boundary. */\n\tonFailure?: 'state' | 'throw'\n\t/** Explicit server contract; generated references do not carry error metadata. Defaults to queryErrors. */\n\terrors?: Contract\n\t/** Convex value identifying the current auth/scope/reset generation. Never a credential. */\n\tresetIdentity?: Value\n}\ntype IntervalPagination = {\n\tnumItems: number\n\tcursor: string | null\n\tid: number\n\tendCursor?: string\n}\nlet epoch = 0\n/** Reactive engine-backed list: fixed browse ranges or SDK-journal search windows. Empty pages advance manually. */\nexport function usePaginatedList<\n\tQuery extends ListQueryReference,\n\tContract extends FailureContract = typeof queryErrors,\n>(\n\tquery: Query,\n\targs: Omit<FunctionArgs<Query>, 'paginationOpts'> | 'skip',\n\toptions: PaginatedListOptions<Contract>,\n): PaginatedList<Query, Contract> {\n\tconst { pageSize } = options\n\tif (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 100)\n\t\tthrow new Error('pageSize must be an integer from 1 to 100')\n\tconst skip = args === 'skip'\n\t// Convex's public encoder sorts object keys recursively and preserves array order, IDs, bytes and int64.\n\t// SAFETY: FunctionArgs are Convex values; pagination transport is owned exclusively by this hook.\n\tconst effectiveArgs = skip ? {} : (args as Record<string, Value>)\n\tconst identity = JSON.stringify([\n\t\tgetFunctionName(query),\n\t\tconvexToJson(effectiveArgs),\n\t\tconvexToJson(options.resetIdentity ?? null),\n\t\tpageSize,\n\t\tskip,\n\t])\n\tconst [stored, setState] = useState(() =>\n\t\tinitialPagination<FunctionReturnType<Query>>(identity, ++epoch, skip),\n\t)\n\tlet state = stored\n\tif (state.identity !== identity) state = initialPagination(identity, ++epoch, skip)\n\tconst queries = useMemo(\n\t\t() =>\n\t\t\tObject.fromEntries(\n\t\t\t\tObject.entries(state.intervals).map(([key, interval]) => {\n\t\t\t\t\tconst paginationOpts: IntervalPagination = {\n\t\t\t\t\t\tnumItems: pageSize,\n\t\t\t\t\t\tcursor: interval.cursor,\n\t\t\t\t\t\tid: state.epoch,\n\t\t\t\t\t}\n\t\t\t\t\tif (interval.endCursor !== undefined) paginationOpts.endCursor = interval.endCursor\n\t\t\t\t\treturn [key, { query, args: { ...effectiveArgs, paginationOpts } }]\n\t\t\t\t}),\n\t\t\t),\n\t\t// Equivalent args/references must keep subscriptions stable; identity encodes their effective values.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[state.intervals, state.epoch, identity],\n\t)\n\t// SAFETY: useQueries returns each complete endpoint result or an Error for the keyed subscription.\n\tconst results = useQueries(queries) as Record<\n\t\tstring,\n\t\tFunctionReturnType<Query> | Error | undefined\n\t>\n\tstate = reconcilePagination(state, results)\n\tconst errors = options.errors ?? queryErrors\n\tlet failure = state.error ? decodeFailure(state.error, errors) : undefined\n\t// Both the explicit decoder and the fixed query contract must validate the actual transported envelope.\n\tconst queryFailure = state.error ? decodeFailure(state.error, queryErrors) : undefined\n\tconst invalid =\n\t\tstate.error &&\n\t\tfailure?._tag === 'DeclaredFailure' &&\n\t\tfailure.code === 'invalid-cursor' &&\n\t\tqueryFailure?._tag === 'DeclaredFailure' &&\n\t\tqueryFailure.code === 'invalid-cursor'\n\tif (invalid && options.onInvalidCursor !== 'throw' && !state.restarted) {\n\t\tstate = initialPagination(identity, ++epoch, skip, true)\n\t\tfailure = undefined\n\t}\n\tif (state !== stored) setState(state)\n\t// Recovery runs first. A boundary unmount releases useQueries subscriptions even\n\t// when the render-phase state update above cannot commit because this render throws.\n\tif (\n\t\tstate.error &&\n\t\t(options.onFailure === 'throw' || (invalid && options.onInvalidCursor === 'throw'))\n\t)\n\t\tthrow state.error\n\tconst view = paginationView(state)\n\tconst currentEpoch = state.epoch\n\treturn {\n\t\t...view,\n\t\t// SAFETY: the controller concatenates unmodified elements from this query's validated page DTOs.\n\t\trows: view.rows as FunctionReturnType<Query>['page'],\n\t\tcompleteness: view.completeness,\n\t\t// SAFETY: omitted errors selects the default Contract parameter; an explicit contract owns its decoder.\n\t\tfailure: failure as FailureOf<Contract> | undefined,\n\t\terror: state.error,\n\t\tresetKey: `${identity}:${state.restarted ? 1 : 0}`,\n\t\tfetchNextPage: () =>\n\t\t\tsetState((previous) =>\n\t\t\t\tprevious.epoch === currentEpoch && previous.identity === identity\n\t\t\t\t\t? nextPagination(previous)\n\t\t\t\t\t: previous,\n\t\t\t),\n\t}\n}\n"],"mappings":"A,kYA0DA,IAAIA,EAAQ,EAEZ,SAAgBC,EAIf,EACA,EACA,EACiC,CACjC,GAAM,CAAE,YAAaC,EACrB,GAAI,CAAC,OAAO,UAAUC,CAAQ,GAAKA,EAAW,GAAKA,EAAW,IAC7D,MAAU,MAAM,2CAA2C,EAC5D,IAAMC,EAAOC,IAAS,OAGhBC,EAAgBF,EAAO,CAAC,EAAKC,EAC7BE,EAAW,KAAK,UAAU,CAC/BC,EAAgBC,CAAK,EACrBC,EAAaJ,CAAa,EAC1BI,EAAaR,EAAQ,eAAiB,IAAI,EAC1CC,EACAC,CACD,CAAC,EACK,CAACO,EAAQC,GAAYC,MAC1BC,EAA6CP,EAAU,EAAEP,EAAOI,CAAI,CACrE,EACIW,EAAQJ,EACRI,EAAM,WAAaR,IAAU,EAAQO,EAAkBP,EAAU,EAAEP,EAAOI,CAAI,GAClF,IAAMY,EAAUC,MAEd,OAAO,YACN,OAAO,QAAQF,EAAM,SAAS,CAAC,CAAC,KAAK,CAACG,EAAKC,KAAc,CACxD,IAAMC,EAAqC,CAC1C,SAAUjB,EACV,OAAQgB,EAAS,OACjB,GAAIJ,EAAM,KACX,EAEA,OADII,EAAS,YAAc,IAAA,KAAW,EAAe,UAAYA,EAAS,WACnE,CAACD,EAAK,CAAE,QAAO,KAAM,CAAE,GAAGZ,EAAe,gBAAe,CAAE,CAAC,CACnE,CAAC,CACF,EAGD,CAACS,EAAM,UAAWA,EAAM,MAAOR,CAAQ,CACxC,EAEMc,EAAUC,EAAWN,CAAO,EAIlC,EAAQO,EAAoBR,EAAOM,CAAO,EAC1C,IAAMG,EAAStB,EAAQ,QAAUuB,EAC7BC,EAAUX,EAAM,MAAQY,EAAcZ,EAAM,MAAOS,CAAM,EAAI,IAAA,GAE3DI,EAAeb,EAAM,MAAQY,EAAcZ,EAAM,MAAOU,CAAW,EAAI,IAAA,GACvEI,EACLd,EAAM,OACNW,GAAS,OAAS,mBAClBA,EAAQ,OAAS,kBACjBE,GAAc,OAAS,mBACvBA,EAAa,OAAS,iBAQvB,GAPIC,GAAW3B,EAAQ,kBAAoB,SAAW,CAACa,EAAM,YAC5D,EAAQD,EAAkBP,EAAU,EAAEP,EAAOI,EAAM,EAAI,EACvD,EAAU,IAAA,IAEPW,IAAUJ,GAAQC,EAASG,CAAK,EAInCA,EAAM,QACLb,EAAQ,YAAc,SAAY2B,GAAW3B,EAAQ,kBAAoB,SAE1E,MAAMa,EAAM,MACb,IAAMe,EAAOC,EAAehB,CAAK,EAC3BiB,EAAejB,EAAM,MAC3B,MAAO,CACN,GAAGe,EAEH,KAAMA,EAAK,KACX,aAAcA,EAAK,aAEV,UACT,MAAOf,EAAM,MACb,SAAU,GAAGR,EAAS,GAAG,KAAM,YAC/B,kBACCK,EAAU,GACTqB,EAAS,QAAUD,GAAgBC,EAAS,WAAa1B,EACtD2B,EAAeD,CAAQ,EACvBA,CACJ,CACF,CACD,C"}
|
package/dist/react.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FailureHandlers, failureOf, isFailure, matchFailure } from "./react/failures.mjs";
|
|
2
|
+
import { Command, CommandResult, useCommand } from "./react/use-command.mjs";
|
|
3
|
+
import { DeclaredFailure, DecodedFailure, ErrorContract, UnknownFailure, combineErrorContracts, decodeFailure, queryErrors } from "./modules/contracts/errors.mjs";
|
|
4
|
+
import { ListQueryReference, PaginatedList, PaginatedListOptions, usePaginatedList } from "./react/use-paginated-list.mjs";
|
|
5
|
+
import { OptimisticInterval, OptimisticList, OptimisticListDescriptor, OptimisticOrder, defineOptimisticList } from "./react/optimistic.mjs";
|
|
6
|
+
export { type Command, type CommandResult, type DeclaredFailure, type DecodedFailure, type ErrorContract, type FailureHandlers, type ListQueryReference, type OptimisticInterval, type OptimisticList, type OptimisticListDescriptor, type OptimisticOrder, type PaginatedList, type PaginatedListOptions, type UnknownFailure, combineErrorContracts, decodeFailure, defineOptimisticList, failureOf, isFailure, matchFailure, queryErrors, useCommand, usePaginatedList };
|
package/dist/react.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{failureOf as e,isFailure as t,matchFailure as n}from"./react/failures.mjs";import{useCommand as r}from"./react/use-command.mjs";import{combineErrorContracts as i,decodeFailure as a,queryErrors as o}from"./modules/contracts/errors.mjs";import{usePaginatedList as s}from"./react/use-paginated-list.mjs";import{defineOptimisticList as c}from"./react/optimistic.mjs";export{i as combineErrorContracts,a as decodeFailure,c as defineOptimisticList,e as failureOf,t as isFailure,n as matchFailure,o as queryErrors,r as useCommand,s as usePaginatedList};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ArgumentFailurePolicy } from "./modules/contracts/errors.mjs";
|
|
2
|
+
import { KObject } from "./k/object.mjs";
|
|
3
|
+
import { KType, OutputNativeOf } from "./k/types.mjs";
|
|
4
|
+
import { GenericValidator, Infer, ObjectType, PropertyValidators, VObject } from "convex/values";
|
|
5
|
+
import { ActionBuilder, ArgsArrayToObject, DefaultFunctionArgs, FunctionVisibility, GenericActionCtx, GenericDataModel, GenericMutationCtx, GenericQueryCtx, MutationBuilder, QueryBuilder, ValidatorTypeToReturnType } from "convex/server";
|
|
6
|
+
import { Customization, Registration } from "convex-helpers/server/customFunctions";
|
|
7
|
+
/** One declared argument: a `k` schema or a native Convex validator. */
|
|
8
|
+
export type KArgField = KType | GenericValidator;
|
|
9
|
+
/** A plain object of argument fields; `k` and native fields may be mixed. */
|
|
10
|
+
export type KArgFields = Readonly<Record<string, KArgField>>;
|
|
11
|
+
/** What `args` accepts: a field object, a `k.object(...)` or a native `v.object(...)`. */
|
|
12
|
+
export type KArgs = KArgFields | KObject<any> | VObject<any, any, 'required'>;
|
|
13
|
+
/** What `returns` accepts: a `k` schema (its output side is exported) or a native validator. */
|
|
14
|
+
export type KReturns = KType | GenericValidator;
|
|
15
|
+
type InputFields<A extends KArgFields> = { [Key in keyof A]: A[Key] extends KType ? A[Key]['validator'] : A[Key]; };
|
|
16
|
+
type OutputFields<A extends KArgFields> = { [Key in keyof A]: A[Key] extends KType ? OutputNativeOf<A[Key]> : A[Key]; };
|
|
17
|
+
type Props<T> = T extends PropertyValidators ? T : never;
|
|
18
|
+
/** Caller-facing args of an `args` declaration: a defaulted `k` field is optional, a transformed one has its input type. */
|
|
19
|
+
export type KArgsInput<A> = [A] extends [KObject<infer F>] ? keyof F extends never ? {} : A['_input'] : [A] extends [VObject<any, any, any>] ? A['type'] : [A] extends [KArgFields] ? ObjectType<Props<InputFields<A>>> : DefaultFunctionArgs;
|
|
20
|
+
/** Handler-facing args of an `args` declaration: defaults filled and transforms applied. */
|
|
21
|
+
export type KArgsOutput<A> = [A] extends [KObject<any>] ? A['_output'] : [A] extends [VObject<any, any, any>] ? A['type'] : [A] extends [KArgFields] ? ObjectType<Props<OutputFields<A>>> : DefaultFunctionArgs;
|
|
22
|
+
type ReturnValueFor<R> = [R] extends [KType] ? ValidatorTypeToReturnType<R['_output']> : [R] extends [GenericValidator] ? ValidatorTypeToReturnType<Infer<R>> : any;
|
|
23
|
+
type Expand<T> = { [Key in keyof T]: T[Key]; };
|
|
24
|
+
type Overwrite<T, U> = keyof U extends never ? T : Omit<T, keyof U> & U;
|
|
25
|
+
type ArgsForHandlerType<OneOrZeroArgs extends [] | [Record<string, any>], CustomMadeArgs extends Record<string, any>> = CustomMadeArgs extends Record<string, never> ? OneOrZeroArgs : OneOrZeroArgs extends [infer A] ? [Expand<A & CustomMadeArgs>] : [CustomMadeArgs];
|
|
26
|
+
type ReservedKey = 'args' | 'returns' | 'handler' | 'skipConvexValidation';
|
|
27
|
+
/**
|
|
28
|
+
* A builder returned by `kCustomQuery`/`kCustomMutation`/`kCustomAction`. The handler receives the
|
|
29
|
+
* output type of `args`; the registered function's reference exposes their input type.
|
|
30
|
+
*/
|
|
31
|
+
export type KCustomBuilder<FuncType extends 'query' | 'mutation' | 'action', CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, InputCtx, Visibility extends FunctionVisibility, ExtraArgs extends Record<string, any>> = {
|
|
32
|
+
<ArgsValidator extends KArgs | void = void, ReturnsValidator extends KReturns | void = void, ReturnValue extends ReturnValueFor<ReturnsValidator> = any>(func: ({
|
|
33
|
+
args?: ArgsValidator;
|
|
34
|
+
returns?: ReturnsValidator;
|
|
35
|
+
/** Export no validators to Convex; the kit then parses args fully itself. */
|
|
36
|
+
skipConvexValidation?: boolean;
|
|
37
|
+
handler: (ctx: Overwrite<InputCtx, CustomCtx>, ...args: ArgsForHandlerType<[KArgsOutput<ArgsValidator>], CustomMadeArgs>) => ReturnValue;
|
|
38
|
+
} & { [Key in keyof ExtraArgs as Key extends ReservedKey ? never : Key]: ExtraArgs[Key]; }) | ((ctx: Overwrite<InputCtx, CustomCtx>, ...args: ArgsForHandlerType<[KArgsOutput<ArgsValidator>], CustomMadeArgs>) => ReturnValue)): Registration<FuncType, Visibility, ArgsArrayToObject<CustomArgsValidator extends Record<string, never> ? [KArgsInput<ArgsValidator>] : [Expand<KArgsInput<ArgsValidator> & ObjectType<CustomArgsValidator>>]>, ReturnValue>;
|
|
39
|
+
};
|
|
40
|
+
export declare function kCustomQuery<CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Visibility extends FunctionVisibility, DataModel extends GenericDataModel, ExtraArgs extends Record<string, any> = object>(query: QueryBuilder<DataModel, Visibility>, customization: Customization<GenericQueryCtx<DataModel>, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): KCustomBuilder<'query', CustomArgsValidator, CustomCtx, CustomMadeArgs, GenericQueryCtx<DataModel>, Visibility, ExtraArgs>;
|
|
41
|
+
export declare function kCustomMutation<CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Visibility extends FunctionVisibility, DataModel extends GenericDataModel, ExtraArgs extends Record<string, any> = object>(mutation: MutationBuilder<DataModel, Visibility>, customization: Customization<GenericMutationCtx<DataModel>, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): KCustomBuilder<'mutation', CustomArgsValidator, CustomCtx, CustomMadeArgs, GenericMutationCtx<DataModel>, Visibility, ExtraArgs>;
|
|
42
|
+
export declare function kCustomAction<CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Visibility extends FunctionVisibility, DataModel extends GenericDataModel, ExtraArgs extends Record<string, any> = object>(action: ActionBuilder<DataModel, Visibility>, customization: Customization<GenericActionCtx<DataModel>, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): KCustomBuilder<'action', CustomArgsValidator, CustomCtx, CustomMadeArgs, GenericActionCtx<DataModel>, Visibility, ExtraArgs>;
|
|
43
|
+
/** The kCustom* builders, with signatures identical to the module-level exports. */
|
|
44
|
+
export type KCustomFunctionBuilders = Readonly<{
|
|
45
|
+
kCustomQuery: typeof kCustomQuery;
|
|
46
|
+
kCustomMutation: typeof kCustomMutation;
|
|
47
|
+
kCustomAction: typeof kCustomAction;
|
|
48
|
+
}>;
|
|
49
|
+
/** Registration options beyond the customization. */
|
|
50
|
+
export type KCustomFunctionOptions = Readonly<{
|
|
51
|
+
/** How rejected arguments are thrown; defaults to `'validation'` (`KValidationError`). */
|
|
52
|
+
argumentFailure?: ArgumentFailurePolicy;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* The kCustom* builders bound to registration options, e.g. an argument failure policy.
|
|
56
|
+
* Signatures are identical to the module-level builders.
|
|
57
|
+
*/
|
|
58
|
+
export declare function kCustomFunctions(options?: KCustomFunctionOptions): KCustomFunctionBuilders;
|
|
59
|
+
/**
|
|
60
|
+
* The raw arguments of the invocation that produced `ctx`, before the kit applied declared behaviour.
|
|
61
|
+
* Available inside a customization `input` callback; empty for unknown contexts.
|
|
62
|
+
*/
|
|
63
|
+
export declare function rawFunctionArgs<DataModel extends GenericDataModel>(ctx: GenericQueryCtx<DataModel> | GenericMutationCtx<DataModel> | GenericActionCtx<DataModel>): DefaultFunctionArgs;
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=registration.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{KValidationError as e}from"./k/issues.mjs";import{argumentErrors as t,sanitizeArgumentIssues as n}from"./modules/contracts/errors.mjs";import{KObject as r,object as i}from"./k/object.mjs";import{containsTransform as a,hasDeclaredBehaviour as o,runDeclared as s}from"./k/parse.mjs";import{KSchema as c}from"./k/schema.mjs";import{memoize as l}from"./modules/contracts/lazy.mjs";import{compactArgumentBoundary as u}from"./querying/filter-boundary.mjs";import{v as d}from"convex/values";import{pick as f}from"convex-helpers";import{NoOp as p}from"convex-helpers/server/customFunctions";import{addFieldsToValidator as m,validate as h}from"convex-helpers/validators";function g(e,t){return U(e,t,void 0)}function _(e,t){return U(e,t,void 0)}function v(e,t){return U(e,t,void 0)}function y(e){let t=W(e?.argumentFailure);return t===void 0?{kCustomQuery:g,kCustomMutation:_,kCustomAction:v}:{kCustomQuery:((e,n)=>U(e,n,t)),kCustomMutation:((e,n)=>U(e,n,t)),kCustomAction:((e,n)=>U(e,n,t))}}const b=/* @__PURE__ */ new WeakMap;function x(e){return b.get(e)??{}}function S(e,t){for(let n=e;n;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e}}function C(e,t){let n=S(e,t);if(!n)return{present:!1,data:!1,read:()=>void 0};if(!(`value`in n))return{present:!0,data:!1,read:()=>Reflect.get(e,t)};let r=n.value;return{present:!!r,data:!0,read:()=>r}}const w=/* @__PURE__ */ new Set([`args`,`returns`,`handler`,`skipConvexValidation`]);function T(e){let t={};for(let n of Reflect.ownKeys(e))!w.has(n)&&Object.prototype.propertyIsEnumerable.call(e,n)&&Object.defineProperty(t,n,{value:Reflect.get(e,n),enumerable:!0,writable:!0,configurable:!0});return t}function E(e){return typeof e==`object`&&!!e&&`isConvexValidator`in e&&e.isConvexValidator===!0}function D(e){if(e instanceof r)return{schema:e,native:void 0,fields:void 0};if(E(e)){if(e.kind!==`object`||e.isOptional!==`required`)throw Error(`Unsupported args validator: v.${e.kind}; use an object`);return{schema:void 0,native:e,fields:void 0}}if(e instanceof c)throw Error(`Unsupported args schema: k.${k(e)} chain; use a required k.object`);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Unsupported args validator: expected an object of fields`);let t={};for(let[n,r]of Object.entries(e)){if(!(r instanceof c)&&!E(r))throw Error(`Unsupported args field '${n}': expected a k schema or a native validator`);t[n]=r}return{schema:void 0,native:void 0,fields:t}}function O(e){if(e.native)return;let t=e.schema?e.schema.shape:F(e.fields??{}).kFields;return u(t,()=>N(e))}function k(e){let t=e;for(;t.prev!==null;)t=t.prev;return t.op}function A(e){return e.schema?Object.keys(e.schema.shape):e.native?Object.keys(M(e.native)):Object.keys(e.fields??{})}function j(e){return e}function M(e){return j(e).fields}function N(e){if(e.schema)return e.schema.validator;if(e.native)return j(e.native);let t={};for(let[n,r]of Object.entries(e.fields??{}))t[n]=r instanceof c?r.validator:P(r);return d.object(t)}function P(e){return e}function F(e){let t={},n=!1;for(let[r,i]of Object.entries(e))i instanceof c?t[r]=i:n=!0;return{kFields:t,mixed:n}}function I(e){if(e.schema){let t=e.schema;return o(t)?e=>B(s(t,e)):void 0}if(!e.fields)return;let{kFields:t,mixed:n}=F(e.fields),r=i(t);if(!o(r))return;if(!n)return e=>B(s(r,e));let a=Object.keys(t);return e=>z(e,B(s(r,e)),a)}function L(t){if(t.schema){let e=t.schema;return t=>B(e.parse(t))}if(t.native){let n=t.native;return t=>{if(!h(n,t))throw new e([R([],n)]);return t}}let n=t.fields??{},{kFields:r,mixed:a}=F(n),o=i(r);if(!a)return e=>B(o.parse(e));let s=Object.keys(r);return t=>{let r={},i=[];for(let e of Object.keys(t)){let a=n[e];a===void 0?i.push({path:[e],code:`unrecognized_key`,message:`Unrecognized key: ${JSON.stringify(e)}`}):a instanceof c?r[e]=t[e]:h(P(a),t[e])||i.push(R([e],P(a)))}for(let[e,r]of Object.entries(n))r instanceof c||Object.hasOwn(t,e)||h(P(r),void 0)||i.push(R([e],P(r)));let a=o.safeParse(r);if(a.success||i.push(...a.issues),i.length>0||!a.success)throw new e(i);return z(t,B(a.data),s)}}function R(e,t){return{path:e,code:`invalid_type`,message:`Invalid input: expected ${t.kind}`}}function z(e,t,n){if(t===e)return e;let r={...e};for(let e of n)Object.hasOwn(t,e)?r[e]=t[e]:delete r[e];return r}function B(e){return e}function V(e){if(e instanceof c){if(a(e))throw Error(`A returns schema cannot transform: the kit does not run return transforms`);return e.outputValidator}if(E(e))return e;throw Error(`Unsupported returns validator: expected a k schema or a native validator`)}function H(e){return e!==void 0&&Object.keys(e).length>0}function U(e,t,n){let r=t.input??p.input,i=t.args??p.args,a=Object.keys(i);return function(t){let o=t.handler===void 0?t:t.handler,s=t.skipConvexValidation!==void 0&&t.skipConvexValidation,c=typeof t==`object`&&t?T(t):{},u=C(t,`args`),d=C(t,`returns`),p=l(()=>V(d.read())),h=e=>{let t={};return d.present&&!s&&Object.defineProperty(t,"returns",{enumerable:!0,get:p}),t.handler=e,t},g=async(e,t,n)=>{let r={...e,...n.ctx},i=H(n.args)?{...t,...n.args}:t,a=await o(r,i);return n.onSuccess&&await n.onSuccess({ctx:e,args:t,result:a}),a};if(u.present){let t=u.data?D(u.read()):void 0,o=l(()=>t??D(u.read())),d=l(()=>{let e=o();return{keys:A(e),run:s?L(e):I(e),boundary:s?void 0:O(e)}}),p=l(()=>{let e=d().boundary;return m(e?.validator??N(o()),i)}),_=s&&a.length>0?l(()=>L({schema:void 0,native:void 0,fields:i})):void 0,v=h(async(e,t)=>{let{keys:i,run:o,boundary:s}=d();s&&G(n,`filter`,()=>s.preflight(t)),b.set(e,t);let l=a.length===0?{}:f(t,a),u=await r(e,_===void 0?l:G(n,`arguments`,()=>_()(l)),c),p=a.length===0?t:f(t,i);return g(e,o===void 0?p:G(n,`arguments`,()=>o(p)),u)});return s?v.args=void 0:Object.defineProperty(v,"args",{enumerable:!0,get:p}),e(v)}if(s&&a.length>0)throw Error(`If you're using a custom function with arguments for the input customization, you cannot skip convex validation.`);return e(h(async(e,t)=>(b.set(e,t),g(e,t,await r(e,t,c)))))}}function W(e){if(e===void 0||e===`validation`)return;let r=e===`declared`?e=>t.toConvexError(`INVALID_ARGUMENTS`,{issues:[...e.issues]}):e;return(e,t)=>r(Object.freeze({source:e,issues:n(t)}))}function G(t,n,r){if(t===void 0)return r();try{return r()}catch(r){throw r instanceof e?t(n,r.data.issues):r}}export{v as kCustomAction,y as kCustomFunctions,_ as kCustomMutation,g as kCustomQuery,x as rawFunctionArgs};
|
|
2
|
+
//# sourceMappingURL=registration.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration.mjs","names":["kCustomQuery","customFnBuilder","query","customization","kCustomMutation","mutation","kCustomAction","action","kCustomFunctions","reject","argumentRejecter","options","rawArguments","rawFunctionArgs","ctx","declared","target","definition","descriptor","key","presence","value","reserved","extraOptions","extra","isNative","captureArgs","args","KObject","KSchema","rootOp","fields","field","filterBoundary","kFieldsOf","compactArgumentBoundary","nativeArgs","root","schema","keysOf","nativeFields","nativeObject","native","nativeOf","v","kFields","mixed","declaredRun","hasDeclaredBehaviour","asArgs","runDeclared","object","kKeys","merged","fullRun","validate","KValidationError","structuralIssue","kValues","issues","parsed","out","nativeReturns","returns","containsTransform","hasFields","customInput","NoOp","inputArgs","inputKeys","handler","fn","skipConvexValidation","declaredArgs","declaredReturns","returnsValidator","memoize","nativeDefinition","handle","finish","finalCtx","added","finalArgs","result","captured","declaration","argsState","current","argsValidator","boundary","addFieldsToValidator","customRun","rejecting","allArgs","customArgs","pick","declaredValues","keys","run","builder","policy","toThrown","argumentErrors","failure","sanitizeArgumentIssues","step","error","source"],"sources":["../src/registration.ts"],"sourcesContent":["// cvx-kit 2 function registration: custom query/mutation/action builders over `k` schemas and native\n// Convex validators. Same customization contract as convex-helpers' customQuery.\n//\n// What Convex reads, and when:\n// - At registration (`query(definition)`): only `handler`. `exportArgs`/`exportReturns` are closures.\n// - At deploy analysis (first `exportArgs()`/`exportReturns()`): the `args`/`returns` getters on the\n// native definition, which build the native validators once (input side for args, output side for\n// returns) and memoise them.\n// - Per call: nothing from the definition. The kit runs a schema's declared behaviour (KTD3) and only\n// when the args declare any; the decision is made on the first call and cached.\nimport { pick } from 'convex-helpers'\nimport { NoOp, type Customization, type Registration } from 'convex-helpers/server/customFunctions'\nimport { addFieldsToValidator, validate } from 'convex-helpers/validators'\nimport type {\n\tActionBuilder,\n\tArgsArrayToObject,\n\tDefaultFunctionArgs,\n\tFunctionVisibility,\n\tGenericActionCtx,\n\tGenericDataModel,\n\tGenericMutationCtx,\n\tGenericQueryCtx,\n\tMutationBuilder,\n\tQueryBuilder,\n\tValidatorTypeToReturnType,\n} from 'convex/server'\nimport {\n\tv,\n\ttype GenericValidator,\n\ttype Infer,\n\ttype ObjectType,\n\ttype PropertyValidators,\n\ttype VObject,\n} from 'convex/values'\nimport { KValidationError, type KIssue } from './k/issues'\nimport {\n\targumentErrors,\n\tsanitizeArgumentIssues,\n\ttype ArgumentFailure,\n\ttype ArgumentFailurePolicy,\n} from './modules/contracts/errors'\nimport { KObject, object } from './k/object'\nimport { containsTransform, hasDeclaredBehaviour, runDeclared } from './k/parse'\nimport { KSchema } from './k/schema'\nimport type { KFields, KNode, KType, OutputNativeOf } from './k/types'\nimport { memoize } from './modules/contracts/lazy'\nimport { compactArgumentBoundary } from './querying/filter-boundary'\n\n/** One declared argument: a `k` schema or a native Convex validator. */\nexport type KArgField = KType | GenericValidator\n\n/** A plain object of argument fields; `k` and native fields may be mixed. */\nexport type KArgFields = Readonly<Record<string, KArgField>>\n\n/** What `args` accepts: a field object, a `k.object(...)` or a native `v.object(...)`. */\nexport type KArgs = KArgFields | KObject<any> | VObject<any, any, 'required'>\n\n/** What `returns` accepts: a `k` schema (its output side is exported) or a native validator. */\nexport type KReturns = KType | GenericValidator\n\ntype InputFields<A extends KArgFields> = {\n\t[Key in keyof A]: A[Key] extends KType ? A[Key]['validator'] : A[Key]\n}\ntype OutputFields<A extends KArgFields> = {\n\t[Key in keyof A]: A[Key] extends KType ? OutputNativeOf<A[Key]> : A[Key]\n}\ntype Props<T> = T extends PropertyValidators ? T : never\n\n/** Caller-facing args of an `args` declaration: a defaulted `k` field is optional, a transformed one has its input type. */\nexport type KArgsInput<A> = [A] extends [KObject<infer F>]\n\t? keyof F extends never\n\t\t? {}\n\t\t: A['_input']\n\t: [A] extends [VObject<any, any, any>]\n\t\t? A['type']\n\t\t: [A] extends [KArgFields]\n\t\t\t? ObjectType<Props<InputFields<A>>>\n\t\t\t: DefaultFunctionArgs\n\n/** Handler-facing args of an `args` declaration: defaults filled and transforms applied. */\nexport type KArgsOutput<A> = [A] extends [KObject<any>]\n\t? A['_output']\n\t: [A] extends [VObject<any, any, any>]\n\t\t? A['type']\n\t\t: [A] extends [KArgFields]\n\t\t\t? ObjectType<Props<OutputFields<A>>>\n\t\t\t: DefaultFunctionArgs\n\ntype ReturnValueFor<R> = [R] extends [KType]\n\t? ValidatorTypeToReturnType<R['_output']>\n\t: [R] extends [GenericValidator]\n\t\t? ValidatorTypeToReturnType<Infer<R>>\n\t\t: any\n\ntype Expand<T> = { [Key in keyof T]: T[Key] }\ntype Overwrite<T, U> = keyof U extends never ? T : Omit<T, keyof U> & U\ntype ArgsForHandlerType<\n\tOneOrZeroArgs extends [] | [Record<string, any>],\n\tCustomMadeArgs extends Record<string, any>,\n> =\n\tCustomMadeArgs extends Record<string, never>\n\t\t? OneOrZeroArgs\n\t\t: OneOrZeroArgs extends [infer A]\n\t\t\t? [Expand<A & CustomMadeArgs>]\n\t\t\t: [CustomMadeArgs]\n\ntype ReservedKey = 'args' | 'returns' | 'handler' | 'skipConvexValidation'\n\n/**\n * A builder returned by `kCustomQuery`/`kCustomMutation`/`kCustomAction`. The handler receives the\n * output type of `args`; the registered function's reference exposes their input type.\n */\nexport type KCustomBuilder<\n\tFuncType extends 'query' | 'mutation' | 'action',\n\tCustomArgsValidator extends PropertyValidators,\n\tCustomCtx extends Record<string, any>,\n\tCustomMadeArgs extends Record<string, any>,\n\tInputCtx,\n\tVisibility extends FunctionVisibility,\n\tExtraArgs extends Record<string, any>,\n> = {\n\t<\n\t\tArgsValidator extends KArgs | void = void,\n\t\tReturnsValidator extends KReturns | void = void,\n\t\tReturnValue extends ReturnValueFor<ReturnsValidator> = any,\n\t>(\n\t\tfunc:\n\t\t\t| ({\n\t\t\t\t\targs?: ArgsValidator\n\t\t\t\t\treturns?: ReturnsValidator\n\t\t\t\t\t/** Export no validators to Convex; the kit then parses args fully itself. */\n\t\t\t\t\tskipConvexValidation?: boolean\n\t\t\t\t\thandler: (\n\t\t\t\t\t\tctx: Overwrite<InputCtx, CustomCtx>,\n\t\t\t\t\t\t...args: ArgsForHandlerType<[KArgsOutput<ArgsValidator>], CustomMadeArgs>\n\t\t\t\t\t) => ReturnValue\n\t\t\t } & {\n\t\t\t\t\t[Key in keyof ExtraArgs as Key extends ReservedKey ? never : Key]: ExtraArgs[Key]\n\t\t\t })\n\t\t\t| ((\n\t\t\t\t\tctx: Overwrite<InputCtx, CustomCtx>,\n\t\t\t\t\t...args: ArgsForHandlerType<[KArgsOutput<ArgsValidator>], CustomMadeArgs>\n\t\t\t ) => ReturnValue),\n\t): Registration<\n\t\tFuncType,\n\t\tVisibility,\n\t\tArgsArrayToObject<\n\t\t\tCustomArgsValidator extends Record<string, never>\n\t\t\t\t? [KArgsInput<ArgsValidator>]\n\t\t\t\t: [Expand<KArgsInput<ArgsValidator> & ObjectType<CustomArgsValidator>>]\n\t\t>,\n\t\tReturnValue\n\t>\n}\n\nexport function kCustomQuery<\n\tCustomArgsValidator extends PropertyValidators,\n\tCustomCtx extends Record<string, any>,\n\tCustomMadeArgs extends Record<string, any>,\n\tVisibility extends FunctionVisibility,\n\tDataModel extends GenericDataModel,\n\tExtraArgs extends Record<string, any> = object,\n>(\n\tquery: QueryBuilder<DataModel, Visibility>,\n\tcustomization: Customization<\n\t\tGenericQueryCtx<DataModel>,\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tExtraArgs\n\t>,\n) {\n\t// SAFETY: the untyped builder implements exactly the contract KCustomBuilder declares.\n\treturn customFnBuilder(query, customization, undefined) as KCustomBuilder<\n\t\t'query',\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tGenericQueryCtx<DataModel>,\n\t\tVisibility,\n\t\tExtraArgs\n\t>\n}\n\nexport function kCustomMutation<\n\tCustomArgsValidator extends PropertyValidators,\n\tCustomCtx extends Record<string, any>,\n\tCustomMadeArgs extends Record<string, any>,\n\tVisibility extends FunctionVisibility,\n\tDataModel extends GenericDataModel,\n\tExtraArgs extends Record<string, any> = object,\n>(\n\tmutation: MutationBuilder<DataModel, Visibility>,\n\tcustomization: Customization<\n\t\tGenericMutationCtx<DataModel>,\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tExtraArgs\n\t>,\n) {\n\t// SAFETY: the untyped builder implements exactly the contract KCustomBuilder declares.\n\treturn customFnBuilder(mutation, customization, undefined) as KCustomBuilder<\n\t\t'mutation',\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tGenericMutationCtx<DataModel>,\n\t\tVisibility,\n\t\tExtraArgs\n\t>\n}\n\nexport function kCustomAction<\n\tCustomArgsValidator extends PropertyValidators,\n\tCustomCtx extends Record<string, any>,\n\tCustomMadeArgs extends Record<string, any>,\n\tVisibility extends FunctionVisibility,\n\tDataModel extends GenericDataModel,\n\tExtraArgs extends Record<string, any> = object,\n>(\n\taction: ActionBuilder<DataModel, Visibility>,\n\tcustomization: Customization<\n\t\tGenericActionCtx<DataModel>,\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tExtraArgs\n\t>,\n) {\n\t// SAFETY: the untyped builder implements exactly the contract KCustomBuilder declares.\n\treturn customFnBuilder(action, customization, undefined) as KCustomBuilder<\n\t\t'action',\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tGenericActionCtx<DataModel>,\n\t\tVisibility,\n\t\tExtraArgs\n\t>\n}\n\n/** The kCustom* builders, with signatures identical to the module-level exports. */\nexport type KCustomFunctionBuilders = Readonly<{\n\tkCustomQuery: typeof kCustomQuery\n\tkCustomMutation: typeof kCustomMutation\n\tkCustomAction: typeof kCustomAction\n}>\n\n/** Registration options beyond the customization. */\nexport type KCustomFunctionOptions = Readonly<{\n\t/** How rejected arguments are thrown; defaults to `'validation'` (`KValidationError`). */\n\targumentFailure?: ArgumentFailurePolicy\n}>\n\n/**\n * The kCustom* builders bound to registration options, e.g. an argument failure policy.\n * Signatures are identical to the module-level builders.\n */\nexport function kCustomFunctions(options?: KCustomFunctionOptions): KCustomFunctionBuilders {\n\tconst reject = argumentRejecter(options?.argumentFailure)\n\tif (reject === undefined) return { kCustomQuery, kCustomMutation, kCustomAction }\n\t// SAFETY: identical boundary assertions as the module-level builders, with a bound rejecter.\n\treturn {\n\t\tkCustomQuery: ((query: any, customization: any) =>\n\t\t\tcustomFnBuilder(query, customization, reject)) as typeof kCustomQuery,\n\t\tkCustomMutation: ((mutation: any, customization: any) =>\n\t\t\tcustomFnBuilder(mutation, customization, reject)) as typeof kCustomMutation,\n\t\tkCustomAction: ((action: any, customization: any) =>\n\t\t\tcustomFnBuilder(action, customization, reject)) as typeof kCustomAction,\n\t}\n}\n\n/** Raw function arguments, keyed by the native ctx of one invocation. */\nconst rawArguments = new WeakMap<object, DefaultFunctionArgs>()\n\n/**\n * The raw arguments of the invocation that produced `ctx`, before the kit applied declared behaviour.\n * Available inside a customization `input` callback; empty for unknown contexts.\n */\nexport function rawFunctionArgs<DataModel extends GenericDataModel>(\n\tctx: GenericQueryCtx<DataModel> | GenericMutationCtx<DataModel> | GenericActionCtx<DataModel>,\n): DefaultFunctionArgs {\n\treturn rawArguments.get(ctx) ?? {}\n}\n\n/* oxlint-disable anti-slop/no-object-parameters, anti-slop/no-reflect-get, anti-slop/no-unsafe-dictionary-type, anti-slop/no-known-value-widening, anti-slop/no-unknown-parameters -- Registration reads arbitrary user definition records by descriptor so declared accessors stay unread, and classifies undecoded user declarations. */\n/** Descriptor lookup that never invokes an accessor; follows the chain like destructuring does. */\nfunction declared(definition: object, key: PropertyKey): PropertyDescriptor | undefined {\n\tfor (let target: object | null = definition; target; target = Object.getPrototypeOf(target)) {\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(target, key)\n\t\tif (descriptor) return descriptor\n\t}\n\treturn undefined\n}\n\n/** Present means the destructured value would select the declared branch; accessors always do. */\nfunction presence(definition: object, key: PropertyKey) {\n\tconst descriptor = declared(definition, key)\n\tif (!descriptor) return { present: false, data: false, read: () => undefined }\n\tif (!('value' in descriptor))\n\t\treturn { present: true, data: false, read: () => Reflect.get(definition, key) }\n\tconst value = descriptor.value\n\treturn { present: Boolean(value), data: true, read: () => value }\n}\n\nconst reserved = new Set<PropertyKey>(['args', 'returns', 'handler', 'skipConvexValidation'])\n\n/** Object-rest equivalent that skips the lazily read keys. */\nfunction extraOptions(definition: object): Record<PropertyKey, unknown> {\n\tconst extra: Record<PropertyKey, unknown> = {}\n\tfor (const key of Reflect.ownKeys(definition)) {\n\t\tif (reserved.has(key) || !Object.prototype.propertyIsEnumerable.call(definition, key)) continue\n\t\t// Define rather than assign, as object rest does, so a `__proto__` key stays an own property.\n\t\tObject.defineProperty(extra, key, {\n\t\t\tvalue: Reflect.get(definition, key),\n\t\t\tenumerable: true,\n\t\t\twritable: true,\n\t\t\tconfigurable: true,\n\t\t})\n\t}\n\treturn extra\n}\n\nfunction isNative(value: unknown): value is GenericValidator {\n\treturn (\n\t\tvalue !== null &&\n\t\t// oxlint-disable-next-line anti-slop/no-runtime-typeof -- Declarations are classified by representation.\n\t\ttypeof value === 'object' &&\n\t\t'isConvexValidator' in value &&\n\t\tvalue.isConvexValidator === true\n\t)\n}\n\n/**\n * Classify a declared `args` value without building anything: a `k.object`, a native object validator,\n * or a field object whose every value is a `k` schema or a native validator.\n */\nfunction captureArgs(args: unknown): DeclaredArgs {\n\tif (args instanceof KObject) return { schema: args, native: undefined, fields: undefined }\n\tif (isNative(args)) {\n\t\tif (args.kind !== 'object' || args.isOptional !== 'required')\n\t\t\tthrow new Error(`Unsupported args validator: v.${args.kind}; use an object`)\n\t\treturn { schema: undefined, native: args, fields: undefined }\n\t}\n\tif (args instanceof KSchema)\n\t\tthrow new Error(`Unsupported args schema: k.${rootOp(args)} chain; use a required k.object`)\n\t// oxlint-disable-next-line anti-slop/no-runtime-typeof -- Declarations are classified by representation.\n\tif (args === null || typeof args !== 'object' || Array.isArray(args))\n\t\tthrow new Error('Unsupported args validator: expected an object of fields')\n\tconst fields: Record<string, KArgField> = {}\n\tfor (const [key, field] of Object.entries(args)) {\n\t\tif (!(field instanceof KSchema) && !isNative(field))\n\t\t\tthrow new Error(`Unsupported args field '${key}': expected a k schema or a native validator`)\n\t\tfields[key] = field\n\t}\n\treturn { schema: undefined, native: undefined, fields }\n}\n/* oxlint-enable anti-slop/no-object-parameters, anti-slop/no-reflect-get, anti-slop/no-unsafe-dictionary-type, anti-slop/no-known-value-widening, anti-slop/no-unknown-parameters */\n\n/** Exactly one member is set. */\ntype DeclaredArgs = {\n\treadonly schema: KObject<KFields> | undefined\n\treadonly native: GenericValidator | undefined\n\treadonly fields: Readonly<Record<string, KArgField>> | undefined\n}\n\ntype ArgsRun = (args: DefaultFunctionArgs) => DefaultFunctionArgs\n\n/** The per-function argument state, built once on first use. */\ntype ArgsState = {\n\treadonly keys: string[]\n\t/** Undefined when nothing is declared: the call path then does no validation work at all (R19). */\n\treadonly run: ArgsRun | undefined\n\treadonly boundary: FilterBoundary | undefined\n}\n\n/**\n * The compact filter boundary (U23): it replaces the exported args validator with one whose compact\n * filters are projected, and preflights raw args before customization. A projected filter is seen by\n * Convex as `any` below depth 1, so the preflight runs the full structural walker on it (KTD3).\n */\ntype FilterBoundary = {\n\treadonly validator: ObjectValidator\n\tpreflight(args: DefaultFunctionArgs): void\n}\n\nfunction filterBoundary(declared: DeclaredArgs): FilterBoundary | undefined {\n\tif (declared.native) return undefined\n\tconst fields = declared.schema ? declared.schema.shape : kFieldsOf(declared.fields ?? {}).kFields\n\treturn compactArgumentBoundary(fields, () => nativeArgs(declared))\n}\n\nfunction rootOp(schema: KNode): string {\n\tlet root = schema\n\twhile (root.prev !== null) root = root.prev\n\treturn root.op\n}\n\nfunction keysOf(declared: DeclaredArgs): string[] {\n\tif (declared.schema) return Object.keys(declared.schema.shape)\n\tif (declared.native) return Object.keys(nativeFields(declared.native))\n\treturn Object.keys(declared.fields ?? {})\n}\n\ntype ObjectValidator = VObject<any, PropertyValidators, 'required'>\n\nfunction nativeObject(native: GenericValidator): ObjectValidator {\n\t// SAFETY: captureArgs only accepts required native validators of kind 'object'.\n\treturn native as ObjectValidator\n}\n\nfunction nativeFields(native: GenericValidator): PropertyValidators {\n\treturn nativeObject(native).fields\n}\n\n/** The input-side native validator Convex receives for the declared args. */\nfunction nativeArgs(declared: DeclaredArgs): ObjectValidator {\n\tif (declared.schema) return declared.schema.validator\n\tif (declared.native) return nativeObject(declared.native)\n\tconst fields: Record<string, GenericValidator> = {}\n\tfor (const [key, field] of Object.entries(declared.fields ?? {}))\n\t\tfields[key] = field instanceof KSchema ? field.validator : nativeOf(field)\n\treturn v.object(fields)\n}\n\nfunction nativeOf(field: KArgField): GenericValidator {\n\t// SAFETY: a field that is not a KSchema passed captureArgs as a native validator.\n\treturn field as GenericValidator\n}\n\n/** The `k` fields of a field object, and whether native fields sit beside them. */\nfunction kFieldsOf(fields: Readonly<Record<string, KArgField>>) {\n\tconst kFields: Record<string, KType> = {}\n\tlet mixed = false\n\tfor (const [key, field] of Object.entries(fields)) {\n\t\tif (field instanceof KSchema) kFields[key] = field\n\t\telse mixed = true\n\t}\n\treturn { kFields, mixed }\n}\n\n/** Plan-only run (KTD3): Convex already validated the structure, so only declared behaviour runs. */\nfunction declaredRun(declared: DeclaredArgs): ArgsRun | undefined {\n\tif (declared.schema) {\n\t\tconst schema = declared.schema\n\t\treturn hasDeclaredBehaviour(schema) ? (args) => asArgs(runDeclared(schema, args)) : undefined\n\t}\n\tif (!declared.fields) return undefined\n\tconst { kFields, mixed } = kFieldsOf(declared.fields)\n\tconst schema = object(kFields)\n\tif (!hasDeclaredBehaviour(schema)) return undefined\n\tif (!mixed) return (args) => asArgs(runDeclared(schema, args))\n\tconst kKeys = Object.keys(kFields)\n\treturn (args) => merged(args, asArgs(runDeclared(schema, args)), kKeys)\n}\n\n/** Full run for `skipConvexValidation`: Convex validated nothing, so structure is checked here too. */\nfunction fullRun(declared: DeclaredArgs): ArgsRun {\n\tif (declared.schema) {\n\t\tconst schema = declared.schema\n\t\treturn (args) => asArgs(schema.parse(args))\n\t}\n\tif (declared.native) {\n\t\tconst native = declared.native\n\t\treturn (args) => {\n\t\t\tif (!validate(native, args)) throw new KValidationError([structuralIssue([], native)])\n\t\t\treturn args\n\t\t}\n\t}\n\tconst fields = declared.fields ?? {}\n\tconst { kFields, mixed } = kFieldsOf(fields)\n\tconst schema = object(kFields)\n\tif (!mixed) return (args) => asArgs(schema.parse(args))\n\tconst kKeys = Object.keys(kFields)\n\treturn (args) => {\n\t\tconst kValues: DefaultFunctionArgs = {}\n\t\tconst issues: KIssue[] = []\n\t\tfor (const key of Object.keys(args)) {\n\t\t\tconst field = fields[key]\n\t\t\tif (field === undefined)\n\t\t\t\tissues.push({\n\t\t\t\t\tpath: [key],\n\t\t\t\t\tcode: 'unrecognized_key',\n\t\t\t\t\tmessage: `Unrecognized key: ${JSON.stringify(key)}`,\n\t\t\t\t})\n\t\t\telse if (field instanceof KSchema) kValues[key] = args[key]\n\t\t\telse if (!validate(nativeOf(field), args[key]))\n\t\t\t\tissues.push(structuralIssue([key], nativeOf(field)))\n\t\t}\n\t\tfor (const [key, field] of Object.entries(fields)) {\n\t\t\tif (field instanceof KSchema || Object.hasOwn(args, key)) continue\n\t\t\tif (!validate(nativeOf(field), undefined))\n\t\t\t\tissues.push(structuralIssue([key], nativeOf(field)))\n\t\t}\n\t\tconst parsed = schema.safeParse(kValues)\n\t\tif (!parsed.success) issues.push(...parsed.issues)\n\t\tif (issues.length > 0 || !parsed.success) throw new KValidationError(issues)\n\t\treturn merged(args, asArgs(parsed.data), kKeys)\n\t}\n}\n\nfunction structuralIssue(path: (string | number)[], native: GenericValidator): KIssue {\n\treturn { path, code: 'invalid_type', message: `Invalid input: expected ${native.kind}` }\n}\n\n/** Replace the `k` fields of `args` with their parsed values, keeping native fields untouched. */\nfunction merged(\n\targs: DefaultFunctionArgs,\n\tparsed: DefaultFunctionArgs,\n\tkKeys: readonly string[],\n): DefaultFunctionArgs {\n\tif (parsed === args) return args\n\tconst out: DefaultFunctionArgs = { ...args }\n\tfor (const key of kKeys) {\n\t\tif (Object.hasOwn(parsed, key)) out[key] = parsed[key]\n\t\telse delete out[key]\n\t}\n\treturn out\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- The walker hands back the parsed args object it was given.\nfunction asArgs(value: unknown): DefaultFunctionArgs {\n\t// SAFETY: an object schema's parse of an args object yields an args object.\n\treturn value as DefaultFunctionArgs\n}\n\n/** The native `returns` validator Convex receives: the output side of a `k` schema. */\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Declarations are classified by representation.\nfunction nativeReturns(returns: unknown): GenericValidator {\n\tif (returns instanceof KSchema) {\n\t\tif (containsTransform(returns))\n\t\t\tthrow new Error('A returns schema cannot transform: the kit does not run return transforms')\n\t\treturn returns.outputValidator\n\t}\n\tif (isNative(returns)) return returns\n\tthrow new Error('Unsupported returns validator: expected a k schema or a native validator')\n}\n\nfunction hasFields(value: DefaultFunctionArgs | undefined): boolean {\n\treturn value !== undefined && Object.keys(value).length > 0\n}\n\nfunction customFnBuilder(\n\tbuilder: (args: any) => any,\n\tcustomization: Customization<any, any, any, any, any>,\n\treject: ArgumentRejecter | undefined,\n) {\n\tconst customInput: Customization<any, any, any, any, any>['input'] =\n\t\tcustomization.input ?? NoOp.input\n\tconst inputArgs: PropertyValidators = customization.args ?? NoOp.args\n\tconst inputKeys = Object.keys(inputArgs)\n\treturn function customBuilder(fn: any): any {\n\t\t// Descriptor reads keep getter-declared args/returns unread until Convex or a call needs them.\n\t\tconst handler = fn.handler === undefined ? fn : fn.handler\n\t\tconst skipConvexValidation =\n\t\t\tfn.skipConvexValidation === undefined ? false : fn.skipConvexValidation\n\t\t// oxlint-disable-next-line anti-slop/no-runtime-typeof -- Builders accept a bare handler function or a definition object.\n\t\tconst extra = typeof fn === 'object' && fn !== null ? extraOptions(fn) : {}\n\t\tconst declaredArgs = presence(fn, 'args')\n\t\tconst declaredReturns = presence(fn, 'returns')\n\t\tconst returnsValidator = memoize(() => nativeReturns(declaredReturns.read()))\n\n\t\tconst nativeDefinition = (handle: (ctx: any, args: any) => Promise<any>) => {\n\t\t\t// oxlint-disable-next-line anti-slop/no-unsafe-dictionary-type -- The native definition carries opaque validators and the handler.\n\t\t\tconst native: Record<string, unknown> = {}\n\t\t\tif (declaredReturns.present && !skipConvexValidation)\n\t\t\t\tObject.defineProperty(native, 'returns', { enumerable: true, get: returnsValidator })\n\t\t\tnative.handler = handle\n\t\t\treturn native\n\t\t}\n\n\t\tconst finish = async (ctx: any, args: any, added: any) => {\n\t\t\tconst finalCtx = { ...ctx, ...added.ctx }\n\t\t\t// No made args: the handler receives the args object itself, untouched.\n\t\t\tconst finalArgs = hasFields(added.args) ? { ...args, ...added.args } : args\n\t\t\tconst result = await handler(finalCtx, finalArgs)\n\t\t\tif (added.onSuccess) await added.onSuccess({ ctx, args, result })\n\t\t\treturn result\n\t\t}\n\n\t\tif (declaredArgs.present) {\n\t\t\t// Data-declared args are classified now, as registration always did; nothing is built.\n\t\t\tconst captured = declaredArgs.data ? captureArgs(declaredArgs.read()) : undefined\n\t\t\tconst declaration = memoize(() => captured ?? captureArgs(declaredArgs.read()))\n\t\t\tconst argsState = memoize((): ArgsState => {\n\t\t\t\tconst current = declaration()\n\t\t\t\treturn {\n\t\t\t\t\tkeys: keysOf(current),\n\t\t\t\t\trun: skipConvexValidation ? fullRun(current) : declaredRun(current),\n\t\t\t\t\tboundary: skipConvexValidation ? undefined : filterBoundary(current),\n\t\t\t\t}\n\t\t\t})\n\t\t\tconst argsValidator = memoize(() => {\n\t\t\t\tconst boundary = argsState().boundary\n\t\t\t\treturn addFieldsToValidator(boundary?.validator ?? nativeArgs(declaration()), inputArgs)\n\t\t\t})\n\t\t\t// Convex validates nothing when skipped, so customization args are checked before input runs.\n\t\t\tconst customRun =\n\t\t\t\tskipConvexValidation && inputKeys.length > 0\n\t\t\t\t\t? memoize(() => fullRun({ schema: undefined, native: undefined, fields: inputArgs }))\n\t\t\t\t\t: undefined\n\t\t\tconst native = nativeDefinition(async (ctx: any, allArgs: any) => {\n\t\t\t\tconst { keys, run, boundary } = argsState()\n\t\t\t\tif (boundary) rejecting(reject, 'filter', () => boundary.preflight(allArgs))\n\t\t\t\trawArguments.set(ctx, allArgs)\n\t\t\t\tconst customArgs = inputKeys.length === 0 ? {} : pick(allArgs, inputKeys)\n\t\t\t\tconst added = await customInput(\n\t\t\t\t\tctx,\n\t\t\t\t\tcustomRun === undefined\n\t\t\t\t\t\t? customArgs\n\t\t\t\t\t\t: rejecting(reject, 'arguments', () => customRun()(customArgs)),\n\t\t\t\t\textra,\n\t\t\t\t)\n\t\t\t\tconst declaredValues = inputKeys.length === 0 ? allArgs : pick(allArgs, keys)\n\t\t\t\treturn finish(\n\t\t\t\t\tctx,\n\t\t\t\t\trun === undefined\n\t\t\t\t\t\t? declaredValues\n\t\t\t\t\t\t: rejecting(reject, 'arguments', () => run(declaredValues)),\n\t\t\t\t\tadded,\n\t\t\t\t)\n\t\t\t})\n\t\t\tif (skipConvexValidation) native.args = undefined\n\t\t\telse Object.defineProperty(native, 'args', { enumerable: true, get: argsValidator })\n\t\t\treturn builder(native)\n\t\t}\n\t\tif (skipConvexValidation && inputKeys.length > 0) {\n\t\t\tthrow new Error(\n\t\t\t\t\"If you're using a custom function with arguments for the input \" +\n\t\t\t\t\t'customization, you cannot skip convex validation.',\n\t\t\t)\n\t\t}\n\t\treturn builder(\n\t\t\tnativeDefinition(async (ctx: any, args: any) => {\n\t\t\t\trawArguments.set(ctx, args)\n\t\t\t\treturn finish(ctx, args, await customInput(ctx, args, extra))\n\t\t\t}),\n\t\t)\n\t}\n}\n\n/** Maps a kit validation failure to what the app's argument failure policy throws. */\n// oxlint-disable-next-line anti-slop/no-unknown-returns -- The app hook returns an arbitrary throwable.\ntype ArgumentRejecter = (source: ArgumentFailure['source'], issues: readonly KIssue[]) => unknown\n\n/** Resolved once per builder family; undefined keeps `KValidationError` and adds nothing to a call. */\nfunction argumentRejecter(policy: ArgumentFailurePolicy | undefined): ArgumentRejecter | undefined {\n\tif (policy === undefined || policy === 'validation') return undefined\n\t// oxlint-disable-next-line anti-slop/no-unknown-returns -- The app hook returns an arbitrary throwable.\n\tconst toThrown: (failure: ArgumentFailure) => unknown =\n\t\tpolicy === 'declared'\n\t\t\t? (failure) =>\n\t\t\t\t\targumentErrors.toConvexError('INVALID_ARGUMENTS', { issues: [...failure.issues] })\n\t\t\t: policy\n\treturn (source, issues) => toThrown(Object.freeze({ source, issues: sanitizeArgumentIssues(issues) }))\n}\n\n/** Run one validation step; with a policy, a `KValidationError` it raises is rethrown as the policy's value. */\nfunction rejecting<T>(\n\treject: ArgumentRejecter | undefined,\n\tsource: ArgumentFailure['source'],\n\tstep: () => T,\n): T {\n\tif (reject === undefined) return step()\n\ttry {\n\t\treturn step()\n\t} catch (error) {\n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EAC5E,OAAOlB,EACNjE,EACAoF,IAAQ,IAAA,GACLF,EACAJ,EAAUnF,EAAQ,gBAAmByF,EAAIF,CAAc,CAAC,EAC3Df,CACD,CACD,CAAC,EAGD,OAFIT,EAAsB,EAAO,KAAO,IAAA,GACnC,OAAO,eAAe9B,EAAQ,OAAQ,CAAE,WAAY,GAAM,IAAK8C,CAAc,CAAC,EAC5EW,EAAQzD,CAAM,CACtB,CACA,GAAI8B,GAAwBH,EAAU,OAAS,EAC9C,MAAU,MACT,kHAED,EAED,OAAO8B,EACNtB,EAAiB,MAAO,EAAU,KACjCjE,EAAa,IAAIE,EAAKa,CAAI,EACnBoD,EAAOjE,EAAKa,EAAM,MAAMuC,EAAYpD,EAAKa,EAAMH,CAAK,CAAC,EAC5D,CACF,CACD,CACD,CAOA,SAASd,EAAiB,EAAyE,CAClG,GAAI0F,IAAW,IAAA,IAAaA,IAAW,aAAc,OAErD,IAAMC,EACLD,IAAW,WACP,GACDE,EAAe,cAAc,oBAAqB,CAAE,OAAQ,CAAC,GAAGC,EAAQ,MAAM,CAAE,CAAC,EACjFH,EACJ,OAAQ,EAAQ,IAAWC,EAAS,OAAO,OAAO,CAAE,SAAQ,OAAQG,EAAuB7C,CAAM,CAAE,CAAC,CAAC,CACtG,CAGA,SAASiC,EACR,EACA,EACA,EACI,CACJ,GAAInF,IAAW,IAAA,GAAW,OAAOgG,EAAK,EACtC,GAAI,CACH,OAAOA,EAAK,CACb,OAASC,EAAO,CAEf,MADIA,aAAiBlD,EAAwB/C,EAAOkG,EAAQD,EAAM,KAAK,MAAM,EACvEA,CACP,CACD,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { BranchBuilder, FieldGroupMode, FieldGroupRequest, FieldReference, PaginationFiltersInput, RelationBuilder, RelationDeclarations, RelationEdge, RelationFilterSelection, RelationFilters, RelationGroupSelection, RelationRegistry, RelationRegistryIdentity, RelationRow, RelationSelection, RelationTable, RelationTableHelpers, RelationTables, ThroughReference, defineRelations, verifyRelations, withFieldGroups } from "./relations.mjs";
|
|
2
|
+
export { type BranchBuilder, type FieldGroupMode, type FieldGroupRequest, type FieldReference, type PaginationFiltersInput, type RelationBuilder, type RelationDeclarations, type RelationEdge, type RelationFilterSelection, type RelationFilters, type RelationGroupSelection, type RelationRegistry, type RelationRegistryIdentity, type RelationRow, type RelationSelection, type RelationTable, type RelationTableHelpers, type RelationTables, type ThroughReference, defineRelations, verifyRelations, withFieldGroups };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{defineRelations,verifyRelations,withFieldGroups}from"./relations.mjs";
|