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
package/CHANGELOG.md
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to cvx-kit are documented here. The format follows
|
|
4
|
-
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
-
|
|
6
|
-
**Semver contract (from 0.1.0):** while on 0.x, breaking changes land only on
|
|
7
|
-
minor bumps; patches are additive or fixes. The breaking window formally
|
|
8
|
-
closes at the follow-up consolidation release (package-name decision + full
|
|
9
|
-
export-name API audit) — until then, the six 0.1.0 helper surfaces may still
|
|
10
|
-
be renamed in a minor. Every release tag gets a GitHub Release whose notes
|
|
11
|
-
are this file's matching section.
|
|
12
|
-
|
|
13
|
-
## [Unreleased]
|
|
14
|
-
|
|
15
|
-
## [0.2.0] - 2026-08-21
|
|
16
|
-
|
|
17
|
-
### Added
|
|
18
|
-
|
|
19
|
-
- `resolveOrganization` hook on `createAuthFunctions`: identity providers
|
|
20
|
-
whose tokens carry no org claims (custom credentials, magic codes,
|
|
21
|
-
memberships in app tables) can resolve organization and role from the
|
|
22
|
-
database. When configured, the hook overrides claim-based resolution and
|
|
23
|
-
fails closed — `null` or an error rejects with `FORBIDDEN`; its `roleSlug`
|
|
24
|
-
still passes `mapRole`, tenancy derives from the hook's organization, and
|
|
25
|
-
`verifyMembership` for actions is unchanged. Hook-less configurations are
|
|
26
|
-
unaffected. ([#8](https://github.com/ImRLopezAG/cvx-kit/issues/8))
|
|
27
|
-
|
|
28
|
-
## [0.1.1] - 2026-08-17
|
|
29
|
-
|
|
30
|
-
### Fixed
|
|
31
|
-
|
|
32
|
-
- Package Convex component schemas exclusively as discoverable `schema.js` and
|
|
33
|
-
`schema.d.ts` files. This restores the approvals tables and the
|
|
34
|
-
`approvalDecisions.by_runId_and_decidedAt` and
|
|
35
|
-
`approvalDecisions.by_runId_and_stepKey_and_actor_actorRef` indexes without
|
|
36
|
-
consumer `patchedDependencies` workarounds or canonicalization conflicts.
|
|
37
|
-
- Keep compiled component imports aligned with the discoverable `schema.js`
|
|
38
|
-
filename when runtime functions use the schema directly.
|
|
39
|
-
- Include `stepKey` in the public approval callback evidence contract and
|
|
40
|
-
export canonical Zod and Convex callback validators for strict consumers.
|
|
41
|
-
- Use component-safe cursor pagination for approval request lists instead of
|
|
42
|
-
Convex's app-only built-in `.paginate()` implementation.
|
|
43
|
-
|
|
44
|
-
### Added
|
|
45
|
-
|
|
46
|
-
- Packed-tarball content checks and clean anonymous-deployment smoke tests for
|
|
47
|
-
every bundled component under both Bun and npm installation.
|
|
48
|
-
- `components.approvals.health.check`, which verifies the approvals schema
|
|
49
|
-
version and required decision indexes with an actionable failure diagnostic.
|
|
50
|
-
- Supported Convex, Zod, Bun, Node.js, and npm versions plus an approvals
|
|
51
|
-
packaging migration note.
|
|
52
|
-
- Packed callback and paginated-list smoke coverage through real host wrappers.
|
|
53
|
-
|
|
54
|
-
## [0.1.0] - 2026-08-14
|
|
55
|
-
|
|
56
|
-
The big one: the full helper surface, in one release.
|
|
57
|
-
|
|
58
|
-
### Added
|
|
59
|
-
|
|
60
|
-
- **Pagination bridge** — `paginated(dto)` boundary schemas
|
|
61
|
-
(`cvx-kit/zod-table`) and an `include(...).paginate(opts, transform?)`
|
|
62
|
-
terminal (`cvx-kit/auth`): cursor pagination bounded by the same maxRows
|
|
63
|
-
policy as `execute`. Under row-level security, pages may be shorter than
|
|
64
|
-
`numItems` (filtered rows); cursors remain correct.
|
|
65
|
-
- **CRUD command factory** — `createCrudCommands` (`cvx-kit/crud`):
|
|
66
|
-
create/update/archive operations generated from a zodTable, fully inside
|
|
67
|
-
the audited command pipeline; soft-delete only; `enrich` is required for
|
|
68
|
-
tenantTables (fails fast with `CRUD_ENRICH_REQUIRED`).
|
|
69
|
-
- **State-machine helper** — `createStateMachine` (`cvx-kit/state-machine`):
|
|
70
|
-
typed transition legality from constants tuples; `assert` throws
|
|
71
|
-
`INVALID_TRANSITION` via the injected ErrorFactory, dropping straight into
|
|
72
|
-
command guards.
|
|
73
|
-
- **Rate-limit middleware** — `rateLimit` (`cvx-kit/middleware`): the first
|
|
74
|
-
packaged middleware, over an injected `@convex-dev/rate-limiter` instance
|
|
75
|
-
(structural typing — zero new kit dependencies). Keyed by `ctx.tenant` by
|
|
76
|
-
default; a missing key is a configuration error
|
|
77
|
-
(`RATE_LIMIT_KEY_MISSING`), never a silent shared bucket.
|
|
78
|
-
- **Webhook boundary** — `createWebhookBoundary`, `recordWebhookEvent`,
|
|
79
|
-
`webhookEventsTable` (`cvx-kit/webhooks`): raw-body signature verification
|
|
80
|
-
(fail closed), natural-key dedup transactional inside the target internal
|
|
81
|
-
mutation, host-owned dedup table.
|
|
82
|
-
- **Agent tool generator** — `createAgentTools` (`cvx-kit/agent-tools`):
|
|
83
|
-
tool records from the table tool masks, shape-compatible with
|
|
84
|
-
`@convex-dev/agent`'s `createTool` without depending on it; mutation
|
|
85
|
-
handlers route through command executors so agents get audited commands.
|
|
86
|
-
- **Typed middleware context** — `Command.middleware<Ctx, Extension>` /
|
|
87
|
-
`Query.middleware<Ctx, Extension>`: `next({ context })` is typed against
|
|
88
|
-
the declared extension; registries and operations accept typed middleware
|
|
89
|
-
without casts (`AnyCommandMiddleware`/`AnyQueryMiddleware` variance seam).
|
|
90
|
-
- **Upgrade guide** — `docs/upgrading.md` ships in the package: old way →
|
|
91
|
-
new way per feature for consumers on 0.0.x.
|
|
92
|
-
|
|
93
|
-
### Changed
|
|
94
|
-
|
|
95
|
-
- `tools.update` / `tools.id` masks now use `jsonSafeZid` instead of `zid`,
|
|
96
|
-
so ids present as plain strings in generated JSON schemas (compile-time
|
|
97
|
-
`Id<...>` types preserved).
|
|
98
|
-
- Release workflow now creates a GitHub Release with this file's section as
|
|
99
|
-
notes, and action pins are updated past the Node 20 deprecation.
|
|
100
|
-
|
|
101
|
-
## [0.0.8] - 2026-08-14
|
|
102
|
-
|
|
103
|
-
- Composable next()-based middleware for Command and Query kernels, inside
|
|
104
|
-
pipeline invariants (registry-wide + per-operation, context enrichment,
|
|
105
|
-
result re-parse).
|
|
106
|
-
|
|
107
|
-
## [0.0.7] - 2026-08-14
|
|
108
|
-
|
|
109
|
-
- `systemQuery` constructor: internal, include-equipped, RLS-unwrapped.
|
|
110
|
-
BREAKING: `createAuthFunctions` config requires the `internalQuery` builder.
|
|
111
|
-
|
|
112
|
-
## [0.0.6] - 2026-08-14
|
|
113
|
-
|
|
114
|
-
- Materialized `convex.config.js` bridges (Convex CLI discovers components by
|
|
115
|
-
that literal filename). BREAKING: mount via
|
|
116
|
-
`cvx-kit/components/<name>/convex.config`; client facades no longer
|
|
117
|
-
default-export the component config.
|
|
118
|
-
|
|
119
|
-
## [0.0.5] - 2026-08-14
|
|
120
|
-
|
|
121
|
-
- BREAKING: the Foundation facade is the only runtime surface — kernel
|
|
122
|
-
classes and execution utilities destructure from the instance.
|
|
123
|
-
|
|
124
|
-
## [0.0.4] - 2026-08-14
|
|
125
|
-
|
|
126
|
-
- Tarball ships only `dist`, `docs`, and the source test helper
|
|
127
|
-
(`.npmignore`); `cvx-kit/test` registers compiled dist modules.
|
|
128
|
-
|
|
129
|
-
## [0.0.3] - 2026-08-14
|
|
130
|
-
|
|
131
|
-
- Opt-in tenancy and security controls: `tenantTable`, `createModule`,
|
|
132
|
-
`security` config on `createAuthFunctions` (role rules + tenant RLS),
|
|
133
|
-
`ctx.tenant`, `cvx-kit/tenancy`, `tenantOwnership` trigger. Command
|
|
134
|
-
guards, permission checks, and the aggregate allowlist.
|
|
135
|
-
|
|
136
|
-
## [0.0.2] - 2026-08-13
|
|
137
|
-
|
|
138
|
-
- Shipped package documentation (architecture, conventions, migration,
|
|
139
|
-
llms) at `docs/`; opinionated timestamps on every table; single-path
|
|
140
|
-
component mounts.
|
|
141
|
-
|
|
142
|
-
## [0.0.1] - 2026-08-13
|
|
143
|
-
|
|
144
|
-
- Initial release: foundation + approvals components, zod-table boundaries,
|
|
145
|
-
auth constructors, triggers, audited command protocol.
|
package/ROADMAP.md
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
# Roadmap to 1.0.0
|
|
2
|
-
|
|
3
|
-
Where cvx-kit is going and what "stable" will mean. Tracked with checkboxes;
|
|
4
|
-
each milestone ships as one minor version. From `0.1.0` on, **breaking
|
|
5
|
-
changes only land on minor bumps** (0.x semver: minor = breaking, patch =
|
|
6
|
-
fix/additive) and every release gets a CHANGELOG entry.
|
|
7
|
-
|
|
8
|
-
## 0.1.0 — the big one: API consolidation + the feature set
|
|
9
|
-
|
|
10
|
-
Goal: one release that both closes the breaking window AND ships the full
|
|
11
|
-
helper surface, so consumers adopt a complete kit once instead of chasing
|
|
12
|
-
minors. Everything here may still rename freely — that's why the features
|
|
13
|
-
belong in this milestone: they land already conforming to the frozen names.
|
|
14
|
-
|
|
15
|
-
### Consolidation (the last breaking pass)
|
|
16
|
-
|
|
17
|
-
- [ ] Decide the published name (`cvx-kit` is a working title) and, if it
|
|
18
|
-
changes, publish under the final name with `cvx-kit` deprecated.
|
|
19
|
-
- [ ] API audit: review every exported name, option key, and error code
|
|
20
|
-
against `conventions.md`'s own naming grammar; freeze the error-code
|
|
21
|
-
taxonomy (`KitError` codes) as a documented tuple.
|
|
22
|
-
- [x] Typed middleware context accumulation: `next({ context })` currently
|
|
23
|
-
merges loosely; tighten so enrichment widens the downstream ctx type
|
|
24
|
-
(TanStack-style), without breaking the loose form.
|
|
25
|
-
- [x] Introduce `CHANGELOG.md` + release notes on the GitHub tag; adopt the
|
|
26
|
-
0.x semver contract above. (GitHub Releases automated in release.yml.)
|
|
27
|
-
- [ ] CI hardening: add `--dry-run` pack + `attw` (Are The Types Wrong) next
|
|
28
|
-
to publint; bump the deprecated actions pins.
|
|
29
|
-
|
|
30
|
-
### Features
|
|
31
|
-
|
|
32
|
-
- [x] **Pagination bridge** — `paginated(table.publicDto)` arg/return
|
|
33
|
-
helpers over Convex's pagination validators, and an
|
|
34
|
-
`include(...).paginate(opts)` terminal next to `.execute(limit)`:
|
|
35
|
-
cursors, not just bounded `take`.
|
|
36
|
-
- [x] **CRUD command factory** — `createCrudCommands(table, policy)`
|
|
37
|
-
generating the standard create/update/archive operations from a
|
|
38
|
-
zodTable's masks: command input from `commandFields`, audit derivation
|
|
39
|
-
from the aggregate, timestamps/tenant already structural. The single
|
|
40
|
-
biggest remaining per-entity boilerplate.
|
|
41
|
-
- [x] **State-machine helper** — `createStateMachine(STATES, transitions)`
|
|
42
|
-
typed against the constants tuple, returning `isTransitionLegal` /
|
|
43
|
-
`assertTransition` that drop straight into a command `guard`.
|
|
44
|
-
- [x] **Rate-limit middleware factory** — the first official middleware:
|
|
45
|
-
`rateLimit({ key: (ctx) => ctx.tenant, ... })` over
|
|
46
|
-
`@convex-dev/rate-limiter`, packaged as `Command.middleware` /
|
|
47
|
-
`Query.middleware` and the template for future middleware.
|
|
48
|
-
- [x] **Webhook boundary helper** — signature verification + event dedup by
|
|
49
|
-
natural key (`${event}:${id}:${updatedAt}`) + delegation to a
|
|
50
|
-
`system*` function: the one boundary that genuinely needs dedup, as a
|
|
51
|
-
first-class helper.
|
|
52
|
-
- [x] **Agent tool generator** — `createAgentTools(table, executors)`
|
|
53
|
-
emitting `@convex-dev/agent` tool definitions from the existing
|
|
54
|
-
`tools.*` masks + `jsonSafeZid`, with handlers routed through the
|
|
55
|
-
command protocol — agents get audited commands, never raw db access.
|
|
56
|
-
|
|
57
|
-
Each feature ships with its own doc page (or section), tests on the real
|
|
58
|
-
Convex runtime where applicable, and an `llms.md` entry.
|
|
59
|
-
|
|
60
|
-
## 0.2.0 — guardrails as a product
|
|
61
|
-
|
|
62
|
-
Goal: the conventions the docs prescribe become importable tests, so a
|
|
63
|
-
consumer gets the origin app's discipline on day one — enforced against the
|
|
64
|
-
by-then-frozen 0.1.0 names.
|
|
65
|
-
|
|
66
|
-
- [ ] `createArchitectureTest(rules)` — glob-based rule runner with the
|
|
67
|
-
standard rules built in (no raw builders outside functions.ts, no
|
|
68
|
-
inline tables/enums, no sibling-domain imports, no deep component
|
|
69
|
-
imports, facades mount once), each rule fixture-proved, extensible
|
|
70
|
-
with app-specific rules.
|
|
71
|
-
- [ ] Tenancy exhaustiveness helper: assert every `tenantTable` is in the
|
|
72
|
-
registry and vice versa; assert internal builders accept no tenant arg.
|
|
73
|
-
- [ ] `llms.md` conformance check: an automated test that every export in
|
|
74
|
-
its tables exists with that signature (also an rc gate — build it here).
|
|
75
|
-
- [ ] Port the approvals copyability test (cp -r + tsc) into this repo's
|
|
76
|
-
suite as the permanent portability guarantee for both components.
|
|
77
|
-
|
|
78
|
-
## 0.3.0 — scaffolding
|
|
79
|
-
|
|
80
|
-
Goal: the first hour of a new app is generated, not hand-written.
|
|
81
|
-
|
|
82
|
-
- [ ] WorkOS scaffold generator: `auth.ts`, `auth.config.ts`, `http.ts`,
|
|
83
|
-
`functions.ts`, `foundation.ts`, `triggers.ts` from one command.
|
|
84
|
-
- [ ] Audit facade helpers over any `convex-audit-log` instance:
|
|
85
|
-
fingerprinted cursors, bounded windows, admin readers.
|
|
86
|
-
- [ ] Decide on the optional idempotency/replay component (deferred from
|
|
87
|
-
0.0.x — only if a consumer demonstrates the need beyond Convex's
|
|
88
|
-
exactly-once mutation delivery).
|
|
89
|
-
|
|
90
|
-
## 1.0.0-rc — proving it
|
|
91
|
-
|
|
92
|
-
Entry gates, not work items. The rc ships when all are true:
|
|
93
|
-
|
|
94
|
-
- [ ] Two real applications run the latest kit in production-like use for
|
|
95
|
-
several weeks (the multi-tenant integration and one more).
|
|
96
|
-
- [ ] One full minor cycle with zero breaking changes needed.
|
|
97
|
-
- [ ] Docs complete and verified: the `llms.md` conformance check (built in
|
|
98
|
-
0.2.0) green in CI.
|
|
99
|
-
- [ ] CI matrix: bun + node LTS, convex peer-range min and latest.
|
|
100
|
-
- [ ] Public-API test coverage: every exported runtime symbol exercised by
|
|
101
|
-
at least one test.
|
|
102
|
-
|
|
103
|
-
## 1.0.0
|
|
104
|
-
|
|
105
|
-
- [ ] Freeze the export surface; document the semver contract (what counts
|
|
106
|
-
as breaking, deprecation policy of one minor with warnings).
|
|
107
|
-
- [ ] `MIGRATING.md` from 0.x.
|
|
108
|
-
- [ ] Provenance, README badges, and a docs site or expanded README landing.
|
|
109
|
-
|
|
110
|
-
## Candidates (recorded, not committed)
|
|
111
|
-
|
|
112
|
-
- Observability sink adapters: OTel/Axiom-shaped formatters for the
|
|
113
|
-
injectable `emit`, so `command.execution` events land in real telemetry
|
|
114
|
-
without per-consumer mapping.
|
|
115
|
-
- Migration companion: a thin `@convex-dev/migrations` wrapper aligned with
|
|
116
|
-
zodTable epochs ("make optional field required after backfill" as a
|
|
117
|
-
declared step), closing the loop with `migration.md`.
|
|
118
|
-
|
|
119
|
-
## Explicitly out of scope for 1.0
|
|
120
|
-
|
|
121
|
-
- General idempotency store (platform already covers single-call
|
|
122
|
-
exactly-once; boundary dedup is the webhook helper's job).
|
|
123
|
-
- Frontend helpers/React bindings.
|
|
124
|
-
- Multi-provider auth abstractions beyond the injected-policy seam
|
|
125
|
-
(`createAuthFunctions` already accepts any provider via `getAuthUser`/
|
|
126
|
-
`mapRole`/`verifyMembership`).
|
package/dist/zod-table.d.mts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { ConvexValidatorFromZod, zid } from "convex-helpers/server/zod4";
|
|
2
|
-
import { TableDefinition } from "convex/server";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { GenericId } from "convex/values";
|
|
5
|
-
//#region src/zod-table.d.ts
|
|
6
|
-
type Shape = Record<string, z.ZodType>;
|
|
7
|
-
type ShapeKey<Fields extends Shape> = Extract<keyof Fields, string>;
|
|
8
|
-
/**
|
|
9
|
-
* Opinionated lifecycle timestamps — every table has them, server-owned,
|
|
10
|
-
* always excluded from insert/command boundaries. Maintained by the
|
|
11
|
-
* `timestamps` trigger helper (see cvx-kit/triggers).
|
|
12
|
-
*/
|
|
13
|
-
declare const timestampShape: {
|
|
14
|
-
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
15
|
-
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
16
|
-
archivedAt: z.ZodOptional<z.ZodNumber>;
|
|
17
|
-
};
|
|
18
|
-
type TimestampShape = typeof timestampShape;
|
|
19
|
-
declare const TIMESTAMP_FIELDS: readonly ['createdAt', 'updatedAt', 'archivedAt'];
|
|
20
|
-
type TableBoundaryOptions<Fields extends Shape, ServerFields extends readonly ShapeKey<Fields>[], CommandFields extends readonly ShapeKey<Fields>[], PublicFields extends readonly ShapeKey<Fields & TimestampShape>[]> = {
|
|
21
|
-
serverFields?: ServerFields;
|
|
22
|
-
commandFields?: CommandFields;
|
|
23
|
-
publicFields?: PublicFields;
|
|
24
|
-
};
|
|
25
|
-
/** Defines one table and derives its storage, document, write, and DTO boundaries. */
|
|
26
|
-
declare function zodTable<Table extends string, Fields extends Shape, const ServerFields extends readonly ShapeKey<Fields>[] = readonly [], const CommandFields extends readonly ShapeKey<Fields>[] = readonly [], const PublicFields extends readonly ShapeKey<Fields & TimestampShape>[] = readonly []>(tableName: Table, fields: (id: typeof zid) => Fields, options?: TableBoundaryOptions<Fields, ServerFields, CommandFields, PublicFields>): {
|
|
27
|
-
tableName: Table;
|
|
28
|
-
schema: z.ZodObject<((keyof Fields & "_creationTime") | (keyof Fields & "_id") extends never ? (Fields & {
|
|
29
|
-
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
30
|
-
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
31
|
-
archivedAt: z.ZodOptional<z.ZodNumber>;
|
|
32
|
-
} extends (infer T_1) ? { -readonly [P in keyof T_1]: T_1[P]; } : never) & {
|
|
33
|
-
_id: import("convex-helpers/server/zod4").Zid<Table>;
|
|
34
|
-
_creationTime: z.ZodNumber;
|
|
35
|
-
} : ((Fields & {
|
|
36
|
-
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
37
|
-
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
38
|
-
archivedAt: z.ZodOptional<z.ZodNumber>;
|
|
39
|
-
} extends (infer T_1) ? { -readonly [P in keyof T_1]: T_1[P]; } : never) extends (infer T_2 extends z.util.SomeObject) ? { [K in keyof T_2 as K extends "_creationTime" | "_id" ? never : K]: T_2[K]; } : never) & {
|
|
40
|
-
_id: import("convex-helpers/server/zod4").Zid<Table>;
|
|
41
|
-
_creationTime: z.ZodNumber;
|
|
42
|
-
}) extends (infer T) ? { [k in keyof T]: T[k]; } : never, z.core.$strict>;
|
|
43
|
-
storage: z.ZodObject<Fields & {
|
|
44
|
-
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
45
|
-
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
46
|
-
archivedAt: z.ZodOptional<z.ZodNumber>;
|
|
47
|
-
} extends (infer T_1) ? { -readonly [P in keyof T_1]: T_1[P]; } : never, z.core.$strict>;
|
|
48
|
-
insertSchema: z.ZodObject<Omit<Fields, "archivedAt" | "createdAt" | "updatedAt" | ServerFields[number]>, z.core.$strip>;
|
|
49
|
-
updateSchema: z.ZodObject<Omit<Fields, "archivedAt" | "createdAt" | "updatedAt" | ServerFields[number]> extends (infer T_3 extends Readonly<{
|
|
50
|
-
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
51
|
-
}>) ? { -readonly [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.core.$strip>;
|
|
52
|
-
commandInput: z.ZodObject<Pick<Fields & {
|
|
53
|
-
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
54
|
-
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
55
|
-
archivedAt: z.ZodOptional<z.ZodNumber>;
|
|
56
|
-
}, CommandFields[number]> extends (infer T_4) ? { -readonly [P in keyof T_4]: T_4[P]; } : never, z.core.$strict>;
|
|
57
|
-
publicDto: z.ZodObject<Pick<Fields & {
|
|
58
|
-
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
59
|
-
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
60
|
-
archivedAt: z.ZodOptional<z.ZodNumber>;
|
|
61
|
-
}, PublicFields[number]> extends (infer T_5) ? { -readonly [P in keyof T_5]: T_5[P]; } : never, z.core.$strict>;
|
|
62
|
-
toPublicDto: (row: z.input<z.ZodObject<Fields & {
|
|
63
|
-
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
64
|
-
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
65
|
-
archivedAt: z.ZodOptional<z.ZodNumber>;
|
|
66
|
-
} extends (infer T_1) ? { -readonly [P in keyof T_1]: T_1[P]; } : never, z.core.$strict>>) => z.core.$InferObjectOutput<Pick<Fields & {
|
|
67
|
-
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
68
|
-
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
69
|
-
archivedAt: z.ZodOptional<z.ZodNumber>;
|
|
70
|
-
}, PublicFields[number]> extends (infer T_5) ? { -readonly [P in keyof T_5]: T_5[P]; } : never, {}>;
|
|
71
|
-
table: TableDefinition<ConvexValidatorFromZod<z.ZodObject<Fields & {
|
|
72
|
-
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
73
|
-
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
74
|
-
archivedAt: z.ZodOptional<z.ZodNumber>;
|
|
75
|
-
} extends (infer T_1) ? { -readonly [P in keyof T_1]: T_1[P]; } : never, z.core.$strict>, 'required'>>;
|
|
76
|
-
insert: {
|
|
77
|
-
(): z.ZodObject<Omit<Fields, "archivedAt" | "createdAt" | "updatedAt" | ServerFields[number]>, z.core.$strip>;
|
|
78
|
-
<OmitMask extends z.util.Mask<Exclude<keyof Fields, "archivedAt" | "createdAt" | "updatedAt" | ServerFields[number]>>>(omit: OmitMask): ZodObjectOmit<z.ZodObject<Omit<Fields, "archivedAt" | "createdAt" | "updatedAt" | ServerFields[number]>, z.core.$strip>, OmitMask>;
|
|
79
|
-
};
|
|
80
|
-
update: {
|
|
81
|
-
(): z.ZodObject<Omit<Fields, "archivedAt" | "createdAt" | "updatedAt" | ServerFields[number]> extends (infer T_3 extends Readonly<{
|
|
82
|
-
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
83
|
-
}>) ? { -readonly [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.core.$strip>;
|
|
84
|
-
<OmitMask extends z.util.Mask<Exclude<keyof Fields, "archivedAt" | "createdAt" | "updatedAt" | ServerFields[number]>>>(omit: OmitMask): ZodObjectOmit<z.ZodObject<Omit<Fields, "archivedAt" | "createdAt" | "updatedAt" | ServerFields[number]> extends (infer T_3 extends Readonly<{
|
|
85
|
-
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
86
|
-
}>) ? { -readonly [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.core.$strip>, OmitMask>;
|
|
87
|
-
};
|
|
88
|
-
tools: {
|
|
89
|
-
insert: z.ZodObject<Pick<Fields & {
|
|
90
|
-
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
91
|
-
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
92
|
-
archivedAt: z.ZodOptional<z.ZodNumber>;
|
|
93
|
-
}, CommandFields[number]> extends (infer T_4) ? { -readonly [P in keyof T_4]: T_4[P]; } : never, z.core.$strict>;
|
|
94
|
-
update: z.ZodObject<{
|
|
95
|
-
data: z.ZodObject<(Pick<Fields & {
|
|
96
|
-
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
97
|
-
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
98
|
-
archivedAt: z.ZodOptional<z.ZodNumber>;
|
|
99
|
-
}, CommandFields[number]> extends (infer T_4) ? { -readonly [P in keyof T_4]: T_4[P]; } : never) extends (infer T_6 extends Readonly<{
|
|
100
|
-
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
101
|
-
}>) ? { -readonly [k in keyof T_6]: z.ZodOptional<T_6[k]>; } : never, z.core.$strict>;
|
|
102
|
-
id: z.ZodType<GenericId<Table>, string, z.core.$ZodTypeInternals<GenericId<Table>, string>>;
|
|
103
|
-
}, z.core.$strict>;
|
|
104
|
-
id: z.ZodObject<{
|
|
105
|
-
id: z.ZodType<GenericId<Table>, string, z.core.$ZodTypeInternals<GenericId<Table>, string>>;
|
|
106
|
-
}, z.core.$strict>;
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
declare const tenantShape: {
|
|
110
|
-
tenant: z.ZodString;
|
|
111
|
-
};
|
|
112
|
-
type TenantShape = typeof tenantShape;
|
|
113
|
-
/**
|
|
114
|
-
* A zodTable whose rows are tenant-owned: injects the server-owned `tenant`
|
|
115
|
-
* field (the tenancy boundary — see cvx-kit/tenancy). Like timestamps, it is
|
|
116
|
-
* excluded from insert/update/command boundaries; handlers stamp it from
|
|
117
|
-
* ctx.tenant, row-level security matches on it, and the tenantOwnership
|
|
118
|
-
* trigger forbids reassigning it. Expose it via publicFields only when a DTO
|
|
119
|
-
* genuinely needs it.
|
|
120
|
-
*/
|
|
121
|
-
declare function tenantTable<Table extends string, Fields extends Shape, const ServerFields extends readonly ShapeKey<Fields>[] = readonly [], const CommandFields extends readonly ShapeKey<Fields>[] = readonly [], const PublicFields extends readonly ShapeKey<Fields & TenantShape & TimestampShape>[] = readonly []>(tableName: Table, fields: (id: typeof zid) => Fields, options?: TableBoundaryOptions<Fields & TenantShape, readonly (ServerFields[number] | 'tenant')[], CommandFields, PublicFields>): ReturnType<typeof zodTable<Table, Fields & TenantShape, readonly (ServerFields[number] | 'tenant')[], CommandFields, PublicFields>>;
|
|
122
|
-
/**
|
|
123
|
-
* Merges per-module table maps into the application schema map, rejecting
|
|
124
|
-
* duplicate table names across modules — the module-registry combinator for
|
|
125
|
-
* domain/table.ts: `defineSchema(createModule(catalogTables, salesTables))`.
|
|
126
|
-
*/
|
|
127
|
-
declare function createModule<const Maps extends readonly Record<string, TableDefinition<any>>[]>(...maps: Maps): UnionToIntersection<Maps[number]>;
|
|
128
|
-
type UnionToIntersection<Union> = (Union extends unknown ? (member: Union) => void : never) extends ((member: infer Intersection) => void) ? Intersection : never;
|
|
129
|
-
/**
|
|
130
|
-
* Cursor-pagination boundary schemas bridged from Convex's own validators:
|
|
131
|
-
* `args.paginationOpts` for function args, `result` for the page shape.
|
|
132
|
-
* Pair with `include(...).paginate(opts)` (cvx-kit/auth). The result object
|
|
133
|
-
* is deliberately non-strict — Convex may attach engine fields (splitCursor,
|
|
134
|
-
* pageStatus); the page items themselves are validated against the dto.
|
|
135
|
-
* Note: under row-level security, pages may be SHORTER than numItems when
|
|
136
|
-
* rules reject rows mid-page; cursors remain correct.
|
|
137
|
-
*/
|
|
138
|
-
declare function paginated<Dto extends z.ZodType>(dto: Dto): {
|
|
139
|
-
args: {
|
|
140
|
-
paginationOpts: z.ZodObject<{
|
|
141
|
-
numItems: z.ZodNumber;
|
|
142
|
-
cursor: z.ZodUnion<readonly [z.ZodString, z.ZodNull]>;
|
|
143
|
-
endCursor: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
|
|
144
|
-
id: z.ZodOptional<z.ZodNumber>;
|
|
145
|
-
maximumRowsRead: z.ZodOptional<z.ZodNumber>;
|
|
146
|
-
maximumBytesRead: z.ZodOptional<z.ZodNumber>;
|
|
147
|
-
}, z.core.$strict>;
|
|
148
|
-
};
|
|
149
|
-
result: z.ZodObject<{
|
|
150
|
-
page: z.ZodArray<Dto>;
|
|
151
|
-
isDone: z.ZodBoolean;
|
|
152
|
-
continueCursor: z.ZodString;
|
|
153
|
-
splitCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
154
|
-
pageStatus: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
155
|
-
SplitRecommended: "SplitRecommended";
|
|
156
|
-
SplitRequired: "SplitRequired";
|
|
157
|
-
}>>>;
|
|
158
|
-
}, z.core.$strip>;
|
|
159
|
-
};
|
|
160
|
-
/** Preserves discriminated-union storage while retaining the same table owner. */
|
|
161
|
-
declare function zodVariantTable<Table extends string, Schema extends z.ZodType>(tableName: Table, storage: Schema): {
|
|
162
|
-
tableName: Table;
|
|
163
|
-
storage: Schema;
|
|
164
|
-
insertSchema: Schema;
|
|
165
|
-
table: TableDefinition<ConvexValidatorFromZod<Schema, "required">, {}, {}, {}>;
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* A zid that presents as a plain string in generated JSON schemas so
|
|
169
|
-
* LLM-tool inputs stay primitive, while keeping the Id type at compile time.
|
|
170
|
-
*/
|
|
171
|
-
declare function jsonSafeZid<Table extends string>(tableName: Table): z.ZodType<GenericId<Table>, string>;
|
|
172
|
-
type ZodObjectOmit<Schema extends z.ZodObject<any, any>, OmitMask extends z.util.Mask<keyof Schema['shape']>> = Schema extends z.ZodObject<infer ObjectShape, infer Config> ? z.ZodObject<z.util.Flatten<Omit<ObjectShape, Extract<keyof ObjectShape, keyof OmitMask>>>, Config> : never;
|
|
173
|
-
//#endregion
|
|
174
|
-
export { TIMESTAMP_FIELDS, TableBoundaryOptions, createModule, jsonSafeZid, paginated, tenantTable, zodTable, zodVariantTable };
|
|
175
|
-
//# sourceMappingURL=zod-table.d.mts.map
|
package/dist/zod-table.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{convexToZod as e,zid as t,zodToConvex as n}from"convex-helpers/server/zod4";import{defineTable as r,paginationOptsValidator as i}from"convex/server";import{z as a}from"zod";const o={createdAt:a.number().optional(),updatedAt:a.number().optional(),archivedAt:a.number().optional()},s=[`createdAt`,`updatedAt`,`archivedAt`];function c(e,i,c={}){let l={...i(t),...o},u=a.object(l).strict(),d=u.extend({_id:t(e),_creationTime:a.number()}),f=a.object(g(l,[...s,...c.serverFields??[]])).strict(),p=f.partial(),_=a.object(h(l,c.commandFields??[])).strict(),v=a.object(h(l,c.publicFields??[])).strict(),y=e=>v.parse(Object.fromEntries(Object.keys(v.shape).map(t=>[t,e[t]])));function b(e){return e?f.omit(e):f}function x(e){return e?p.omit(e):p}return{tableName:e,schema:d,storage:u,insertSchema:f,updateSchema:p,commandInput:_,publicDto:v,toPublicDto:y,table:r(n(u)),insert:b,update:x,tools:{insert:_,update:a.object({data:_.partial(),id:m(e)}).strict(),id:a.object({id:m(e)}).strict()}}}const l={tenant:a.string().min(1)};function u(e,t,n={}){return c(e,e=>({...t(e),...l}),{...n,serverFields:[...n.serverFields??[],`tenant`]})}function d(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){if(e in t)throw Error(`Table "${e}" is declared by more than one module`);t[e]=r}return t}function f(t){return{args:{paginationOpts:e(i)},result:a.object({page:a.array(t),isDone:a.boolean(),continueCursor:a.string(),splitCursor:a.string().nullable().optional(),pageStatus:a.enum([`SplitRecommended`,`SplitRequired`]).nullable().optional()})}}function p(e,t){return{tableName:e,storage:t,insertSchema:t,table:r(n(t))}}function m(e){return a.string().describe(`Convex document id for table "${e}"`)}function h(e,t){return Object.fromEntries(t.map(t=>[t,e[t]]))}function g(e,t){let n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([e])=>!n.has(e)))}export{s as TIMESTAMP_FIELDS,d as createModule,m as jsonSafeZid,f as paginated,u as tenantTable,c as zodTable,p as zodVariantTable};
|
|
2
|
-
//# sourceMappingURL=zod-table.mjs.map
|
package/dist/zod-table.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zod-table.mjs","names":[],"sources":["../src/zod-table.ts"],"sourcesContent":["import {\n\ttype ConvexValidatorFromZod,\n\tconvexToZod,\n\tzid,\n\tzodToConvex,\n} from 'convex-helpers/server/zod4'\nimport {\n\tdefineTable,\n\tpaginationOptsValidator,\n\ttype TableDefinition,\n} from 'convex/server'\nimport type { GenericId } from 'convex/values'\nimport { z } from 'zod'\n\ntype Shape = Record<string, z.ZodType>\ntype ShapeKey<Fields extends Shape> = Extract<keyof Fields, string>\n\n/**\n * Opinionated lifecycle timestamps — every table has them, server-owned,\n * always excluded from insert/command boundaries. Maintained by the\n * `timestamps` trigger helper (see cvx-kit/triggers).\n */\nconst timestampShape = {\n\tcreatedAt: z.number().optional(),\n\tupdatedAt: z.number().optional(),\n\tarchivedAt: z.number().optional(),\n} satisfies Shape\n\ntype TimestampShape = typeof timestampShape\n\nexport const TIMESTAMP_FIELDS = [\n\t'createdAt',\n\t'updatedAt',\n\t'archivedAt',\n] as const\n\nexport type TableBoundaryOptions<\n\tFields extends Shape,\n\tServerFields extends readonly ShapeKey<Fields>[],\n\tCommandFields extends readonly ShapeKey<Fields>[],\n\tPublicFields extends readonly ShapeKey<Fields & TimestampShape>[],\n> = {\n\tserverFields?: ServerFields\n\tcommandFields?: CommandFields\n\tpublicFields?: PublicFields\n}\n\n/** Defines one table and derives its storage, document, write, and DTO boundaries. */\nexport function zodTable<\n\tTable extends string,\n\tFields extends Shape,\n\tconst ServerFields extends readonly ShapeKey<Fields>[] = readonly [],\n\tconst CommandFields extends readonly ShapeKey<Fields>[] = readonly [],\n\tconst PublicFields extends readonly ShapeKey<\n\t\tFields & TimestampShape\n\t>[] = readonly [],\n>(\n\ttableName: Table,\n\tfields: (id: typeof zid) => Fields,\n\toptions: TableBoundaryOptions<\n\t\tFields,\n\t\tServerFields,\n\t\tCommandFields,\n\t\tPublicFields\n\t> = {},\n) {\n\tconst shape = { ...fields(zid), ...timestampShape } as Fields &\n\t\tTimestampShape\n\tconst storage = z.object(shape).strict()\n\tconst schema = storage.extend({\n\t\t_id: zid(tableName),\n\t\t_creationTime: z.number(),\n\t})\n\tconst insertSchema = z\n\t\t.object(\n\t\t\tomitShape(shape, [\n\t\t\t\t...TIMESTAMP_FIELDS,\n\t\t\t\t...(options.serverFields ?? ([] as never)),\n\t\t\t] as never),\n\t\t)\n\t\t.strict() as z.ZodObject<\n\t\tOmit<Fields, ServerFields[number] | (typeof TIMESTAMP_FIELDS)[number]>\n\t>\n\tconst updateSchema = insertSchema.partial()\n\tconst commandInput = z\n\t\t.object(pickShape(shape, options.commandFields ?? ([] as never)))\n\t\t.strict()\n\tconst publicDto = z\n\t\t.object(pickShape(shape, options.publicFields ?? ([] as never)))\n\t\t.strict()\n\tconst toPublicDto = (row: z.input<typeof storage>) =>\n\t\tpublicDto.parse(\n\t\t\tObject.fromEntries(\n\t\t\t\tObject.keys(publicDto.shape).map((key) => [\n\t\t\t\t\tkey,\n\t\t\t\t\t(row as Record<string, unknown>)[key],\n\t\t\t\t]),\n\t\t\t),\n\t\t)\n\n\ttype InsertSchema = typeof insertSchema\n\ttype UpdateSchema = typeof updateSchema\n\ttype InsertMask = z.util.Mask<keyof InsertSchema['shape']>\n\ttype UpdateMask = z.util.Mask<keyof UpdateSchema['shape']>\n\n\tfunction insert(): InsertSchema\n\tfunction insert<OmitMask extends InsertMask>(\n\t\tomit: OmitMask,\n\t): ZodObjectOmit<InsertSchema, OmitMask>\n\tfunction insert(omit?: InsertMask) {\n\t\treturn omit ? insertSchema.omit(omit as never) : insertSchema\n\t}\n\n\tfunction update(): UpdateSchema\n\tfunction update<OmitMask extends UpdateMask>(\n\t\tomit: OmitMask,\n\t): ZodObjectOmit<UpdateSchema, OmitMask>\n\tfunction update(omit?: UpdateMask) {\n\t\treturn omit ? updateSchema.omit(omit as never) : updateSchema\n\t}\n\n\treturn {\n\t\ttableName,\n\t\tschema,\n\t\tstorage,\n\t\tinsertSchema,\n\t\tupdateSchema,\n\t\tcommandInput,\n\t\tpublicDto,\n\t\ttoPublicDto,\n\t\ttable: defineTable(zodToConvex(storage)) as TableDefinition<\n\t\t\tConvexValidatorFromZod<typeof storage, 'required'>\n\t\t>,\n\t\tinsert,\n\t\tupdate,\n\t\ttools: {\n\t\t\t// jsonSafeZid (not zid): tool masks feed generated JSON schemas, so\n\t\t\t// ids must present as plain strings while keeping the Id<...> type.\n\t\t\tinsert: commandInput,\n\t\t\tupdate: z\n\t\t\t\t.object({ data: commandInput.partial(), id: jsonSafeZid(tableName) })\n\t\t\t\t.strict(),\n\t\t\tid: z.object({ id: jsonSafeZid(tableName) }).strict(),\n\t\t},\n\t}\n}\n\nconst tenantShape = {\n\ttenant: z.string().min(1),\n} satisfies Shape\n\ntype TenantShape = typeof tenantShape\n\n/**\n * A zodTable whose rows are tenant-owned: injects the server-owned `tenant`\n * field (the tenancy boundary — see cvx-kit/tenancy). Like timestamps, it is\n * excluded from insert/update/command boundaries; handlers stamp it from\n * ctx.tenant, row-level security matches on it, and the tenantOwnership\n * trigger forbids reassigning it. Expose it via publicFields only when a DTO\n * genuinely needs it.\n */\nexport function tenantTable<\n\tTable extends string,\n\tFields extends Shape,\n\tconst ServerFields extends readonly ShapeKey<Fields>[] = readonly [],\n\tconst CommandFields extends readonly ShapeKey<Fields>[] = readonly [],\n\tconst PublicFields extends readonly ShapeKey<\n\t\tFields & TenantShape & TimestampShape\n\t>[] = readonly [],\n>(\n\ttableName: Table,\n\tfields: (id: typeof zid) => Fields,\n\toptions: TableBoundaryOptions<\n\t\tFields & TenantShape,\n\t\treadonly (ServerFields[number] | 'tenant')[],\n\t\tCommandFields,\n\t\tPublicFields\n\t> = {},\n) {\n\treturn zodTable(\n\t\ttableName,\n\t\t(id) => ({ ...fields(id), ...tenantShape }),\n\t\t{\n\t\t\t...options,\n\t\t\tserverFields: [\n\t\t\t\t...((options.serverFields ?? []) as readonly (\n\t\t\t\t\t| ServerFields[number]\n\t\t\t\t\t| 'tenant'\n\t\t\t\t)[]),\n\t\t\t\t'tenant',\n\t\t\t] as never,\n\t\t} as never,\n\t) as ReturnType<\n\t\ttypeof zodTable<\n\t\t\tTable,\n\t\t\tFields & TenantShape,\n\t\t\treadonly (ServerFields[number] | 'tenant')[],\n\t\t\tCommandFields,\n\t\t\tPublicFields\n\t\t>\n\t>\n}\n\n/**\n * Merges per-module table maps into the application schema map, rejecting\n * duplicate table names across modules — the module-registry combinator for\n * domain/table.ts: `defineSchema(createModule(catalogTables, salesTables))`.\n */\nexport function createModule<\n\tconst Maps extends readonly Record<string, TableDefinition<any>>[],\n>(...maps: Maps): UnionToIntersection<Maps[number]> {\n\tconst combined: Record<string, TableDefinition<any>> = {}\n\tfor (const map of maps) {\n\t\tfor (const [tableName, definition] of Object.entries(map)) {\n\t\t\tif (tableName in combined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Table \"${tableName}\" is declared by more than one module`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tcombined[tableName] = definition\n\t\t}\n\t}\n\treturn combined as UnionToIntersection<Maps[number]>\n}\n\ntype UnionToIntersection<Union> = (\n\tUnion extends unknown\n\t\t? (member: Union) => void\n\t\t: never\n) extends (member: infer Intersection) => void\n\t? Intersection\n\t: never\n\n/**\n * Cursor-pagination boundary schemas bridged from Convex's own validators:\n * `args.paginationOpts` for function args, `result` for the page shape.\n * Pair with `include(...).paginate(opts)` (cvx-kit/auth). The result object\n * is deliberately non-strict — Convex may attach engine fields (splitCursor,\n * pageStatus); the page items themselves are validated against the dto.\n * Note: under row-level security, pages may be SHORTER than numItems when\n * rules reject rows mid-page; cursors remain correct.\n */\nexport function paginated<Dto extends z.ZodType>(dto: Dto) {\n\treturn {\n\t\targs: { paginationOpts: convexToZod(paginationOptsValidator) },\n\t\tresult: z.object({\n\t\t\tpage: z.array(dto),\n\t\t\tisDone: z.boolean(),\n\t\t\tcontinueCursor: z.string(),\n\t\t\tsplitCursor: z.string().nullable().optional(),\n\t\t\tpageStatus: z\n\t\t\t\t.enum(['SplitRecommended', 'SplitRequired'])\n\t\t\t\t.nullable()\n\t\t\t\t.optional(),\n\t\t}),\n\t}\n}\n\n/** Preserves discriminated-union storage while retaining the same table owner. */\nexport function zodVariantTable<Table extends string, Schema extends z.ZodType>(\n\ttableName: Table,\n\tstorage: Schema,\n) {\n\treturn {\n\t\ttableName,\n\t\tstorage,\n\t\tinsertSchema: storage,\n\t\ttable: defineTable(zodToConvex(storage)),\n\t}\n}\n\n/**\n * A zid that presents as a plain string in generated JSON schemas so\n * LLM-tool inputs stay primitive, while keeping the Id type at compile time.\n */\nexport function jsonSafeZid<Table extends string>(tableName: Table) {\n\treturn z\n\t\t.string()\n\t\t.describe(\n\t\t\t`Convex document id for table \"${tableName}\"`,\n\t\t) as unknown as z.ZodType<GenericId<Table>, string>\n}\n\ntype ZodObjectOmit<\n\tSchema extends z.ZodObject<any, any>,\n\tOmitMask extends z.util.Mask<keyof Schema['shape']>,\n> =\n\tSchema extends z.ZodObject<infer ObjectShape, infer Config>\n\t\t? z.ZodObject<\n\t\t\t\tz.util.Flatten<\n\t\t\t\t\tOmit<ObjectShape, Extract<keyof ObjectShape, keyof OmitMask>>\n\t\t\t\t>,\n\t\t\t\tConfig\n\t\t\t>\n\t\t: never\n\nfunction pickShape<\n\tFields extends Shape,\n\tconst Keys extends readonly ShapeKey<Fields>[],\n>(fields: Fields, keys: Keys) {\n\treturn Object.fromEntries(keys.map((key) => [key, fields[key]])) as Pick<\n\t\tFields,\n\t\tKeys[number]\n\t>\n}\n\nfunction omitShape<\n\tFields extends Shape,\n\tconst Keys extends readonly ShapeKey<Fields>[],\n>(fields: Fields, keys: Keys) {\n\tconst omitted = new Set<string>(keys)\n\treturn Object.fromEntries(\n\t\tObject.entries(fields).filter(([key]) => !omitted.has(key)),\n\t) as Omit<Fields, Keys[number]>\n}\n"],"mappings":"oLAsBA,MAAM,EAAiB,CACtB,UAAW,EAAE,OAAO,CAAC,CAAC,SAAS,EAC/B,UAAW,EAAE,OAAO,CAAC,CAAC,SAAS,EAC/B,WAAY,EAAE,OAAO,CAAC,CAAC,SAAS,CACjC,EAIa,EAAmB,CAC/B,YACA,YACA,YACD,EAcA,SAAgB,EASf,EACA,EACA,EAKI,CAAC,EACJ,CACD,IAAM,EAAQ,CAAE,GAAG,EAAO,CAAG,EAAG,GAAG,CAAe,EAE5C,EAAU,EAAE,OAAO,CAAK,CAAC,CAAC,OAAO,EACjC,EAAS,EAAQ,OAAO,CAC7B,IAAK,EAAI,CAAS,EAClB,cAAe,EAAE,OAAO,CACzB,CAAC,EACK,EAAe,EACnB,OACA,EAAU,EAAO,CAChB,GAAG,EACH,GAAI,EAAQ,cAAiB,CAAC,CAC/B,CAAU,CACX,CAAC,CACA,OAAO,EAGH,EAAe,EAAa,QAAQ,EACpC,EAAe,EACnB,OAAO,EAAU,EAAO,EAAQ,eAAkB,CAAC,CAAW,CAAC,CAAC,CAChE,OAAO,EACH,EAAY,EAChB,OAAO,EAAU,EAAO,EAAQ,cAAiB,CAAC,CAAW,CAAC,CAAC,CAC/D,OAAO,EACH,EAAe,GACpB,EAAU,MACT,OAAO,YACN,OAAO,KAAK,EAAU,KAAK,CAAC,CAAC,IAAK,GAAQ,CACzC,EACC,EAAgC,EAClC,CAAC,CACF,CACD,EAWD,SAAS,EAAO,EAAmB,CAClC,OAAO,EAAO,EAAa,KAAK,CAAa,EAAI,CAClD,CAMA,SAAS,EAAO,EAAmB,CAClC,OAAO,EAAO,EAAa,KAAK,CAAa,EAAI,CAClD,CAEA,MAAO,CACN,YACA,SACA,UACA,eACA,eACA,eACA,YACA,cACA,MAAO,EAAY,EAAY,CAAO,CAAC,EAGvC,SACA,SACA,MAAO,CAGN,OAAQ,EACR,OAAQ,EACN,OAAO,CAAE,KAAM,EAAa,QAAQ,EAAG,GAAI,EAAY,CAAS,CAAE,CAAC,CAAC,CACpE,OAAO,EACT,GAAI,EAAE,OAAO,CAAE,GAAI,EAAY,CAAS,CAAE,CAAC,CAAC,CAAC,OAAO,CACrD,CACD,CACD,CAEA,MAAM,EAAc,CACnB,OAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CACzB,EAYA,SAAgB,EASf,EACA,EACA,EAKI,CAAC,EACJ,CACD,OAAO,EACN,EACC,IAAQ,CAAE,GAAG,EAAO,CAAE,EAAG,GAAG,CAAY,GACzC,CACC,GAAG,EACH,aAAc,CACb,GAAK,EAAQ,cAAgB,CAAC,EAI9B,QACD,CACD,CACD,CASD,CAOA,SAAgB,EAEd,GAAG,EAA+C,CACnD,IAAM,EAAiD,CAAC,EACxD,IAAK,IAAM,KAAO,EACjB,IAAK,GAAM,CAAC,EAAW,KAAe,OAAO,QAAQ,CAAG,EAAG,CAC1D,GAAI,KAAa,EAChB,MAAU,MACT,UAAU,EAAU,sCACrB,EAED,EAAS,GAAa,CACvB,CAED,OAAO,CACR,CAmBA,SAAgB,EAAiC,EAAU,CAC1D,MAAO,CACN,KAAM,CAAE,eAAgB,EAAY,CAAuB,CAAE,EAC7D,OAAQ,EAAE,OAAO,CAChB,KAAM,EAAE,MAAM,CAAG,EACjB,OAAQ,EAAE,QAAQ,EAClB,eAAgB,EAAE,OAAO,EACzB,YAAa,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,EAC5C,WAAY,EACV,KAAK,CAAC,mBAAoB,eAAe,CAAC,CAAC,CAC3C,SAAS,CAAC,CACV,SAAS,CACZ,CAAC,CACF,CACD,CAGA,SAAgB,EACf,EACA,EACC,CACD,MAAO,CACN,YACA,UACA,aAAc,EACd,MAAO,EAAY,EAAY,CAAO,CAAC,CACxC,CACD,CAMA,SAAgB,EAAkC,EAAkB,CACnE,OAAO,EACL,OAAO,CAAC,CACR,SACA,iCAAiC,EAAU,EAC5C,CACF,CAeA,SAAS,EAGP,EAAgB,EAAY,CAC7B,OAAO,OAAO,YAAY,EAAK,IAAK,GAAQ,CAAC,EAAK,EAAO,EAAI,CAAC,CAAC,CAIhE,CAEA,SAAS,EAGP,EAAgB,EAAY,CAC7B,IAAM,EAAU,IAAI,IAAY,CAAI,EACpC,OAAO,OAAO,YACb,OAAO,QAAQ,CAAM,CAAC,CAAC,QAAQ,CAAC,KAAS,CAAC,EAAQ,IAAI,CAAG,CAAC,CAC3D,CACD"}
|
package/docs/agent-tools.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# `cvx-kit/agent-tools` — agents get audited commands
|
|
2
|
-
|
|
3
|
-
`createAgentTools` turns a table's tool masks into framework-agnostic tool
|
|
4
|
-
records `{ name, description, args, handler }` — directly spreadable into
|
|
5
|
-
`@convex-dev/agent`'s `createTool`, adaptable to ai-sdk `tool()`, and the
|
|
6
|
-
kit depends on neither (shape checked against `@convex-dev/agent@0.6.x`;
|
|
7
|
-
re-verify at install).
|
|
8
|
-
|
|
9
|
-
The point is the routing, not the shape: **mutation handlers go through
|
|
10
|
-
command executors**, so every agent action is validated, guarded, audited,
|
|
11
|
-
and observed. An agent never gets raw db access.
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
import { createAgentTools } from 'cvx-kit/agent-tools'
|
|
15
|
-
|
|
16
|
-
const tools = createAgentTools(<entities>, {
|
|
17
|
-
// mutations — audited commands (createCrudCommands executors fit exactly):
|
|
18
|
-
create: (ctx, input) => crud.executeCreate(ctx, input),
|
|
19
|
-
update: (ctx, input) => crud.executeUpdate(ctx, input),
|
|
20
|
-
archive: (ctx, input) => crud.executeArchive(ctx, input),
|
|
21
|
-
// reads — caller-supplied query handlers (reads don't route through commands):
|
|
22
|
-
get: (ctx, { id }) => loadDto(ctx, id),
|
|
23
|
-
list: (ctx, { paginationOpts }) => listPage(ctx, paginationOpts),
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
// host-side, with @convex-dev/agent:
|
|
27
|
-
// const agentTools = Object.fromEntries(Object.values(tools).map((t) =>
|
|
28
|
-
// [t.name, createTool({ description: t.description, args: t.args, handler: t.handler })]))
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Contracts
|
|
32
|
-
|
|
33
|
-
- **Args are the table masks, no drift**: `create` = `tools.insert`
|
|
34
|
-
(`commandFields`), `update` = `tools.update`, `archive`/`get` = `tools.id`,
|
|
35
|
-
`list` = the pagination opts boundary. Ids present as plain strings in
|
|
36
|
-
generated JSON schemas (`jsonSafeZid`) while keeping `Id<...>` types.
|
|
37
|
-
- **Only the kinds you supply handlers for are emitted**; names are
|
|
38
|
-
`<tableName>_<verb>`; descriptions are derived and overridable via
|
|
39
|
-
`options.descriptions`.
|
|
40
|
-
- DTO discipline applies to reads: `get`/`list` handlers should return
|
|
41
|
-
`toPublicDto`-projected data, same as any public query.
|