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/README.md
CHANGED
|
@@ -3,18 +3,24 @@
|
|
|
3
3
|
[](https://github.com/ImRLopezAG/cvx-kit/actions/workflows/ci.yml)
|
|
4
4
|
[](https://www.npmjs.com/package/cvx-kit)
|
|
5
5
|
|
|
6
|
-
Reusable Convex application kit:
|
|
7
|
-
|
|
8
|
-
per-app role vocabularies, an
|
|
9
|
-
command protocol.
|
|
6
|
+
Reusable Convex application kit: `k` validators built on native Convex
|
|
7
|
+
validators, table boundaries, foundation kernels, a generic approvals
|
|
8
|
+
component, auth-aware function constructors with per-app role vocabularies, an
|
|
9
|
+
application trigger registry, and an audited command protocol.
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
bun add cvx-kit
|
|
13
13
|
# or: npm install cvx-kit
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
Supported versions: Convex `^1.
|
|
17
|
-
`24+` with npm `11+`. The library runtime is ESM-only.
|
|
16
|
+
Supported versions: Convex `^1.46.0`, convex-helpers `>=0.1.130 <0.2.0`, Bun
|
|
17
|
+
`1.3+`, and Node.js `24+` with npm `11+`. The library runtime is ESM-only.
|
|
18
|
+
Zod is not required. Install `zod` (`^4.6.7`) only to use the optional
|
|
19
|
+
`cvx-kit/zod` interop entry; install `effect` (`>=4.0.1 <5`) for
|
|
20
|
+
`cvx-kit/effect`.
|
|
21
|
+
|
|
22
|
+
To upgrade from cvx-kit 0.1.x (Zod), follow the
|
|
23
|
+
[2.0 migration guide](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/migration-v2.md).
|
|
18
24
|
|
|
19
25
|
## Toolchain
|
|
20
26
|
|
|
@@ -28,58 +34,381 @@ Supported versions: Convex `^1.43.0`, Zod `^4.0.0`, Bun `1.3+`, and Node.js
|
|
|
28
34
|
|
|
29
35
|
## Documentation
|
|
30
36
|
|
|
31
|
-
Full docs
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
Full docs live on [GitHub](https://github.com/ImRLopezAG/cvx-kit/tree/main/skills/cvx-kit/references)
|
|
38
|
+
and are bundled with the repository's [agent skill](https://github.com/ImRLopezAG/cvx-kit/tree/main/skills/cvx-kit).
|
|
39
|
+
The npm package includes this README; full docs and skills are installed separately.
|
|
40
|
+
|
|
41
|
+
If you use a coding agent, install the cvx-kit skill from your application directory:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npx skills add ImRLopezAG/cvx-kit --skill cvx-kit
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The [skills CLI](https://www.skills.sh/docs) lets you choose your agent. Installation
|
|
48
|
+
is project-scoped by default; add `--global` only for a user-wide install. Public
|
|
49
|
+
GitHub installation needs no login. Preview available skills with
|
|
50
|
+
`npx skills add ImRLopezAG/cvx-kit --list`.
|
|
51
|
+
The skill reads the guides needed for each task instead of loading all docs.
|
|
52
|
+
Check your installed package version against the skill's source revision before
|
|
53
|
+
using newer APIs. For a release containing the skill, use its GitHub tag URL
|
|
54
|
+
(`https://github.com/ImRLopezAG/cvx-kit/tree/<tag>/skills/cvx-kit`) as the install source.
|
|
55
|
+
|
|
56
|
+
Maintainers edit `skills/cvx-kit/references/` directly. CI verifies that relative
|
|
57
|
+
links remain inside the installed skill with `bun run skills:check`.
|
|
58
|
+
|
|
59
|
+
Guides:
|
|
60
|
+
|
|
61
|
+
- [`native-id-relations.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/native-id-relations.md) — native-ID union links, authorized inverse pages, and migration
|
|
62
|
+
|
|
63
|
+
- [`architecture.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/architecture.md) — the layered application shape the kit encodes
|
|
64
|
+
- [`conventions.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/conventions.md) — the doctrine: folder structure, file anatomy, naming grammar, import rules
|
|
65
|
+
- [`k.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/k.md) — the `k` validators: factories, chains, parse and issues, dates, JSON Schema, Zod interop
|
|
66
|
+
- [`table.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/table.md) — one field object per entity, masked into every boundary
|
|
67
|
+
- [`migration-v2.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/migration-v2.md) — moving an app from cvx-kit 0.1.x (Zod) to 2.0
|
|
68
|
+
- [`auth.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/auth.md) — auth-aware function constructors from injected policy
|
|
69
|
+
- [`commands.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/commands.md) — Effect command declarations, lifecycle, and migration
|
|
70
|
+
- [`effect.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/effect.md) — opt-in Effect v4 registries, injected services, and shared API builders
|
|
71
|
+
- [`domain-operations.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/domain-operations.md) — server domain/API examples, contracts, errors, receipts, workflow steps, and selected tools
|
|
72
|
+
- [`triggers.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/triggers.md) — trigger registry, timestamps/append-only/no-delete
|
|
73
|
+
- [`approvals.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/approvals.md) — declarative approval workflows
|
|
74
|
+
- [`tenancy.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/tenancy.md) — row-level security (roles) with opt-in multi-tenant isolation
|
|
75
|
+
- [`crud.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/crud.md) — the CRUD command factory
|
|
76
|
+
- [`webhooks.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/webhooks.md) — the sanctioned webhook boundary
|
|
77
|
+
- [`agent-tools.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/agent-tools.md) — agent tools that are audited commands
|
|
78
|
+
- [`upgrading.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/upgrading.md) — upgrades within 0.1.x, old way → new way
|
|
79
|
+
- [`maintainability.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/maintainability.md) — keeping a Convex app maintainable long-term
|
|
80
|
+
- [`migration.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/migration.md) — restructuring an existing raw Convex project into this architecture
|
|
81
|
+
- [`llms.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/llms.md) — optional condensed reference for coding agents
|
|
82
|
+
|
|
83
|
+
## Per-request import cost
|
|
84
|
+
|
|
85
|
+
Convex evaluates a function's whole static import graph on every request, and queries and mutations cannot use dynamic `import()`. Whatever a module builds at import is paid on every call. The kit builders do not convert validators at registration. Convex reads them when it exports function metadata at push, and the handler builds its parse state on first call. To keep a module from building schemas for functions it is not serving, declare them lazily:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
export const listPayments = authQuery({
|
|
89
|
+
get args() {
|
|
90
|
+
return financeContract.queries.listPayments.input
|
|
91
|
+
},
|
|
92
|
+
get returns() {
|
|
93
|
+
return financeContract.queries.listPayments.result
|
|
94
|
+
},
|
|
95
|
+
handler: (ctx, args) => ctx.queries.finance.exec('listPayments', args),
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
With `args: contract.queries.x.input`, the property read builds the schema at import. A getter defers it, which makes the getter form the recommended one: on the benchmark app (about 30 tables, 14 functions) module load drops from 8.43 ms to 6.30 ms. The property form stays supported, and the v2 codemod writes getters unless given `--no-getters`. Declare contract operations as getters too (see the [domain contracts guide](./skills/cvx-kit/references/domain-contracts.md)), so that reading or executing one operation builds and binds only that operation. Keep the trigger registry out of query modules with `createAuthReaders` (see `cvx-kit/auth` below). Validation is identical in every form.
|
|
100
|
+
|
|
101
|
+
Two more things keep the deferral intact. First, a `paginationOpts(...)` or `pageDto(...)` call at module scope outside a contract still builds at import, so put it behind a getter or inside the operation that uses it. Second, pass Convex's generated builders (`query`, `mutation`, ...) to the kit constructors. A wrapper that spreads or copies the definition reads its getters at registration.
|
|
49
102
|
|
|
50
103
|
## Modules
|
|
51
104
|
|
|
52
|
-
### `cvx-kit/
|
|
105
|
+
### `cvx-kit/k`
|
|
106
|
+
|
|
107
|
+
Schemas are written with `k`. Each `k` schema carries a plain native Convex
|
|
108
|
+
validator, which is what Convex receives for args, returns and tables. The kit
|
|
109
|
+
runs checks, defaults, normalisers, refinements and transforms only where a
|
|
110
|
+
schema declares them; a function with none does no validation work of its own.
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
import { k } from 'cvx-kit/k'
|
|
114
|
+
|
|
115
|
+
const renameArgs = k.object({
|
|
116
|
+
id: k.id('documents'),
|
|
117
|
+
title: k.string().trim().min(1).max(200),
|
|
118
|
+
})
|
|
119
|
+
type RenameArgs = k.input<typeof renameArgs>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Failed declared checks throw a `ConvexError` with data
|
|
123
|
+
`{ code: 'VALIDATION', issues: [{ path, code, message }] }`. `k` schemas
|
|
124
|
+
implement Standard Schema v1; `toJsonSchema` (`cvx-kit/json-schema`) and
|
|
125
|
+
`toZod` (`cvx-kit/zod`) convert them for agent tools and Zod-only libraries.
|
|
126
|
+
See the [`k` guide](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/k.md).
|
|
53
127
|
|
|
54
|
-
|
|
128
|
+
### `cvx-kit/table`
|
|
129
|
+
|
|
130
|
+
One field object per entity, masked into every boundary it crosses:
|
|
55
131
|
|
|
56
132
|
```ts
|
|
57
|
-
import {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
133
|
+
import { k } from 'cvx-kit/k'
|
|
134
|
+
import { kTable } from 'cvx-kit/table'
|
|
135
|
+
|
|
136
|
+
export const documents = kTable(
|
|
137
|
+
'documents',
|
|
138
|
+
{
|
|
139
|
+
title: k.string(),
|
|
140
|
+
ownerId: k.id('users'),
|
|
141
|
+
secretNote: k.string(),
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
commandFields: ['title'], // what a command may say
|
|
145
|
+
publicFields: ['title', 'ownerId'], // the DTO allowlist
|
|
146
|
+
},
|
|
70
147
|
)
|
|
71
148
|
// documents.table → defineTable(...) for schema.ts
|
|
72
|
-
// documents.toPublicDto(row) → projects AND re-
|
|
149
|
+
// documents.toPublicDto(row) → projects AND re-checks (runtime redaction)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
For fields shared across tables, create a reusable declaration function:
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import { createTable } from 'cvx-kit/table'
|
|
156
|
+
|
|
157
|
+
const customTable = createTable({ ref: k.string(), nextActivity: k.string() })
|
|
158
|
+
const tasks = customTable('tasks', { title: k.string() })
|
|
159
|
+
const projects = customTable('projects', { name: k.string() })
|
|
73
160
|
```
|
|
74
161
|
|
|
162
|
+
It accepts the same arguments and returns the same boundary as `kTable`.
|
|
163
|
+
Table-specific fields cannot repeat shared field names. See the
|
|
164
|
+
[`table` guide](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/table.md)
|
|
165
|
+
for field masks and examples.
|
|
166
|
+
|
|
75
167
|
Every table gets `createdAt`, `updatedAt`, and `archivedAt` baked in —
|
|
76
168
|
opinionated, server-owned, always excluded from inserts and commands
|
|
77
169
|
(expose them via `publicFields` when a DTO needs them). Register the
|
|
78
170
|
`timestamps` trigger once and they maintain themselves; `archivedAt` stays
|
|
79
171
|
under application control.
|
|
80
172
|
|
|
81
|
-
`
|
|
82
|
-
|
|
173
|
+
`kVariantTable` covers discriminated-union tables. Tool masks keep `k.id(...)`;
|
|
174
|
+
`toJsonSchema` renders ids as strings while the `Id<...>` type is preserved.
|
|
175
|
+
|
|
176
|
+
### `cvx-kit/relations` and `cvx-kit/querying`
|
|
177
|
+
|
|
178
|
+
See the [querying guide](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/querying.md),
|
|
179
|
+
[DTO parameters](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/table.md#public-dto-parameters), and
|
|
180
|
+
[consumer rule reference](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/oxlint.md#dto-and-pagination-diagnostics).
|
|
181
|
+
|
|
182
|
+
Declare relationships once in `convex/relations.ts`, then configure the engine
|
|
183
|
+
once in `convex/querying.ts`. Both factories are also available from the package
|
|
184
|
+
root. The relations subpath exposes declarations and public types; executor
|
|
185
|
+
metadata and managed reader capabilities are internal.
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
// convex/relations.ts
|
|
189
|
+
import { defineRelations } from 'cvx-kit/relations'
|
|
190
|
+
import './domain/tasks/table' // Establish native indexes before compiling the registry.
|
|
191
|
+
import { tasks, labels, edges } from './domain/tasks/schema'
|
|
192
|
+
|
|
193
|
+
export const relations = defineRelations({ tasks, labels, edges }, (r) => ({
|
|
194
|
+
tasks: {
|
|
195
|
+
referenceTask: r.one.tasks({ from: r.tasks.reference, to: r.tasks._id }),
|
|
196
|
+
labels: r.many.labels({
|
|
197
|
+
from: r.tasks._id.through(r.edges.task),
|
|
198
|
+
to: r.labels._id.through(r.edges.label),
|
|
199
|
+
}),
|
|
200
|
+
},
|
|
201
|
+
}))
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
The tables can be `kTable`, `createTable`, `tenantTable`, or three-argument `kVariantTable` boundaries, with
|
|
205
|
+
indexes supporting each declared lookup. Names can distinguish multiple edges
|
|
206
|
+
to the same table; references can point to the same table. A one edge returns a
|
|
207
|
+
public DTO or `null`. A many edge returns a bounded native page. Junction output
|
|
208
|
+
preserves duplicate edge occurrences, even when target reads are memoized.
|
|
209
|
+
Missing and unreadable targets have the same public result.
|
|
210
|
+
|
|
211
|
+
`defineRelations` checks table names, native table ownership and the structure
|
|
212
|
+
of relation declarations. Variant tables also run their native table preflight
|
|
213
|
+
then, to expose common-field references. It captures each table's stored field semantics,
|
|
214
|
+
public DTO validation, variants and active indexes on that table's first use:
|
|
215
|
+
its schema helpers, an engine read, or a selected relation that reaches it. Each
|
|
216
|
+
edge's field types and indexes are checked when the edge is first read. Invalid
|
|
217
|
+
tables and edges throw on first use instead of at registration. Complete schema
|
|
218
|
+
and index configuration before calling `defineRelations`. Later changes to
|
|
219
|
+
source declarations do not affect a table after its first use. Create a new
|
|
220
|
+
registry to adopt changes. Caller-owned declarations remain mutable.
|
|
221
|
+
|
|
222
|
+
Call `verifyRelations(relations)` from a test to run every deferred check, so CI
|
|
223
|
+
fails on an invalid registry:
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
import { verifyRelations } from 'cvx-kit/relations'
|
|
227
|
+
import { relations } from '../convex/relations'
|
|
228
|
+
|
|
229
|
+
test('relation registry is valid', () => verifyRelations(relations))
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Relation DTOs only validate; they never transform stored values. Refinement
|
|
233
|
+
closures still observe application state.
|
|
234
|
+
|
|
235
|
+
Variant tables keep their discriminated public unions. Use the relation callback's
|
|
236
|
+
second argument, `branch('payments', 'creditor_payment').creditorId`, for a
|
|
237
|
+
branch-specific reference; its tag is checked before lookup. See the
|
|
238
|
+
[variant querying guide](skills/cvx-kit/references/variant-querying.md) for the
|
|
239
|
+
complete authenticated flow and branch filter syntax.
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
// convex/querying.ts
|
|
243
|
+
import { createQueryEngine } from 'cvx-kit/querying'
|
|
244
|
+
import schema from './schema'
|
|
245
|
+
import { relations } from './relations'
|
|
246
|
+
|
|
247
|
+
export const querying = createQueryEngine({ schema, relations })
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
One engine serves every registered table. Cursor keys load internally on first
|
|
251
|
+
pagination from server environment variables `CVX_QUERY_CURSOR_KEYS_JSON`
|
|
252
|
+
(key IDs mapped to 128-character hex secrets) and `CVX_QUERY_CURSOR_CURRENT_KEY_ID`.
|
|
253
|
+
Keep key material out of arguments, client code, and logs. Optional overrides
|
|
254
|
+
belong in a separate second argument; see [querying](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/querying.md). The default codec
|
|
255
|
+
uses authenticated AES-SIV encryption without a plaintext fallback; identical
|
|
256
|
+
payloads under the same binding reveal equality. Tokens bind filters, selected
|
|
257
|
+
output, index, order, relation ancestry, principal/tenant/security scope, and
|
|
258
|
+
registry/policy/engine versions. Page-size changes alone remain valid. Retain
|
|
259
|
+
old keys during rotation when existing cursors should continue working.
|
|
260
|
+
|
|
261
|
+
Private DTO schemas are built on a table's first projection, and helper schemas
|
|
262
|
+
are memoised. See [registry capture](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/querying.md#registry-capture-and-private-dtos).
|
|
263
|
+
|
|
264
|
+
Use the registry's validators in domain contracts and an authenticated Query
|
|
265
|
+
registry handler:
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
const options = relations.tables.tasks.paginationOpts({
|
|
269
|
+
department: true,
|
|
270
|
+
status: true,
|
|
271
|
+
labels: { name: true },
|
|
272
|
+
})
|
|
273
|
+
const result = relations.tables.tasks.pageDto({ labels: true })
|
|
274
|
+
|
|
275
|
+
// In the Query operation's handler, ctx comes from createAuthFunctions.authQuery.
|
|
276
|
+
const page = await querying(ctx)
|
|
277
|
+
.tasks.where({ tenant: ctx.tenant })
|
|
278
|
+
.with({ labels: true })
|
|
279
|
+
.paginate(args)
|
|
280
|
+
|
|
281
|
+
// A separate authenticated child endpoint validates parent with tasks.schema.shape._id.
|
|
282
|
+
const nextLabels = await querying(ctx)
|
|
283
|
+
.tasks.relation(parent, 'labels')
|
|
284
|
+
.paginate({ numItems: 25, cursor: page.page[0].labels.continueCursor })
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Select filterable stored fields explicitly, including server-owned fields when
|
|
288
|
+
needed. Public DTO fields do not determine filter eligibility. Scalar predicates
|
|
289
|
+
support equality, ranges, `and`, `or`, and `not`; many predicates use `some` or
|
|
290
|
+
`none`. Eligibility and composed read authorization run before parents fill a
|
|
291
|
+
page. Parent, junction, target, and continuation reads all recheck authorization.
|
|
292
|
+
`include` and `paginated(dto)` retain their existing behavior independently.
|
|
293
|
+
|
|
294
|
+
For large generated static APIs, opt into compact argument validators with
|
|
295
|
+
`paginationOpts(selection, { validator: 'compact' })` on a table or relation.
|
|
296
|
+
Use the resulting schema with cvx-kit's authenticated builders. Common filters
|
|
297
|
+
remain precisely typed; deeper generated filter branches become opaque where
|
|
298
|
+
native ID checks allow it. Full depth, node, membership, and value validation
|
|
299
|
+
still runs before customization or handler work. Use `PaginationFiltersInput`
|
|
300
|
+
from `cvx-kit/relations` to check deeper filter literals. See the
|
|
301
|
+
[compact filter guide](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/querying.md#compact-generated-filter-validators)
|
|
302
|
+
for registration requirements and ID-heavy size limits.
|
|
303
|
+
|
|
304
|
+
Chain `.when(value, 'index_name')` to choose the first present condition: `false`,
|
|
305
|
+
`0`, and `''` are present; `null` and `undefined` are absent. The gate does not
|
|
306
|
+
bind an index field; validated filters and server `.where(...)` constraints do.
|
|
307
|
+
An incompatible explicit choice fails. Automatic selection uses the longest
|
|
308
|
+
usable equality prefix, then stable index-name order, with creation-time fallback.
|
|
309
|
+
`order: 'desc'` reverses the chosen native index order. Native continuation,
|
|
310
|
+
split/end cursors, and page status are preserved, with external tokens protected.
|
|
311
|
+
|
|
312
|
+
Browse page sizes are positive integers up to 100; central `maxPageSize` may lower that
|
|
313
|
+
ceiling. Central budgets bound read operations, index ranges, raw candidates,
|
|
314
|
+
observed/reserved document bytes, fan-out, depth, and memo entries across a
|
|
315
|
+
request, including policy reads. Native request read limits may lower ceilings.
|
|
316
|
+
An incomplete eligibility proof throws `MANAGED_READ_BUDGET`; it is never an
|
|
317
|
+
empty exhausted page or a negative predicate. Output relationship depth is at
|
|
318
|
+
most four. Traversal executes in the caller's query transaction and may require
|
|
319
|
+
many reads. Application/helper accounting does not measure physical platform I/O.
|
|
320
|
+
|
|
321
|
+
Kit auth query contexts carry the engine's private read capability. Unknown
|
|
322
|
+
contexts fail closed unless a centrally configured trusted adapter attests their
|
|
323
|
+
query reader, effective policy, and security scope. Mutation/action contexts,
|
|
324
|
+
vector search, arbitrary predicates/projections,
|
|
325
|
+
and custom sorts are outside this API.
|
|
326
|
+
|
|
327
|
+
Root full-text search uses a declared native search index and keeps native relevance order:
|
|
328
|
+
|
|
329
|
+
```ts
|
|
330
|
+
const page = await querying(ctx)
|
|
331
|
+
.tasks.search('search_text', input.text)
|
|
332
|
+
.where({ status: 'open' })
|
|
333
|
+
.include({ finance: 'if-permitted' })
|
|
334
|
+
.with({ labels: true })
|
|
335
|
+
.paginate({ numItems: 25, cursor: input.cursor, scanLimit: 250 })
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Declare `search_text` on the exact native table registered in `relations`.
|
|
339
|
+
Search supports the existing root filters, field groups and nested output;
|
|
340
|
+
direct `.relation(...).search(...)` is unsupported. Nested relationship pages
|
|
341
|
+
remain ordinary browse pages. Root search returns `paginationMode: 'native-search'`,
|
|
342
|
+
null split metadata, and no caller-pinned `endCursor`, custom order or refill.
|
|
343
|
+
A short or denied-empty page can still have `isDone: false`: continue manually
|
|
344
|
+
with its `continueCursor` (or `usePaginatedList().fetchNextPage()`).
|
|
345
|
+
|
|
346
|
+
Search `numItems` requests a positive integer initial native target, clamped by
|
|
347
|
+
central limits and the remaining branch threshold. Live windows can return more raw rows.
|
|
348
|
+
`scanLimit` is a cursor-branch admission threshold: all raw candidates, including
|
|
349
|
+
denied rows, count in authenticated `seen` state. A whole window can overshoot
|
|
350
|
+
(e.g. seen 6 + 5 rows with limit 9 returns all authorized rows, then stops with
|
|
351
|
+
`result-cap`). Replaying a cursor repeats that branch; this is no global quota.
|
|
352
|
+
Root search payload accounting is separate from shared policy/relationship read,
|
|
353
|
+
byte, depth and fan-out budgets. Any unfinished nested read, policy exception or
|
|
354
|
+
DTO failure aborts the whole page and mints no new continuation.
|
|
355
|
+
|
|
356
|
+
Project errors explicitly at registered endpoint boundaries: ordinary `authQuery`
|
|
357
|
+
handlers catch and throw `new ConvexError(queryFailureContract.project(error))`
|
|
358
|
+
from `cvx-kit/querying`. Effect constructors configure
|
|
359
|
+
`query: { errors: queryFailureContract }` and wrap the promise in
|
|
360
|
+
`Effect.tryPromise({ try: () => /* search page */, catch: error => error })`.
|
|
361
|
+
The declared contract sanitizes unknown failures; do not transport raw exceptions.
|
|
362
|
+
See the [search contract](skills/cvx-kit/references/querying.md#root-full-text-search)
|
|
363
|
+
and [React list protocol](skills/cvx-kit/references/client-list.md).
|
|
364
|
+
|
|
365
|
+
Argument and compact-filter validation failures throw `KValidationError`
|
|
366
|
+
(`ConvexError({ code: 'VALIDATION', issues })`) by default. Pass `argumentFailure: 'declared'`
|
|
367
|
+
to `createAuthFunctions` / `createAuthReaders` to throw the built-in
|
|
368
|
+
`argumentErrors` `INVALID_ARGUMENTS` envelope instead (bounded `{ path, code, message }`
|
|
369
|
+
issues, never the input), or a function returning the value to throw. Decode it
|
|
370
|
+
with `combineErrorContracts(appErrors, argumentErrors)` from `cvx-kit/errors`; see
|
|
371
|
+
[client failures](skills/cvx-kit/references/client-failures.md#argument-validation-failures).
|
|
372
|
+
|
|
373
|
+
Set `argumentFailure` on `createEffectFoundation` for Effect command and query
|
|
374
|
+
`input` validation, including direct `exec` calls. The default preserves the
|
|
375
|
+
decoder failure (`UnknownFailure` at endpoints with declared error projection).
|
|
376
|
+
Opt in to `'declared'` or supply a hook that receives
|
|
377
|
+
`{ source: 'arguments', issues }` and returns the value to throw.
|
|
378
|
+
|
|
379
|
+
For manual projection, `tasks.toPublicDto(row)` still omits IDs and unselected
|
|
380
|
+
storage fields. `tasks.toPublicDto(row, true)` or `{ _id: true }` adds the branded
|
|
381
|
+
ID only. Computed extensions use matching schemas:
|
|
382
|
+
|
|
383
|
+
```ts
|
|
384
|
+
const extend = { url: k.string() }
|
|
385
|
+
const dto = tasks.toPublicDto(row, {
|
|
386
|
+
_id: true,
|
|
387
|
+
extend,
|
|
388
|
+
values: { url: `https://example.test/tasks/${row._id}` },
|
|
389
|
+
})
|
|
390
|
+
const returnSchema = tasks.dto({ _id: true, extend })
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
To migrate, replace manual ID spreads with the shorthand and copied pagination
|
|
394
|
+
objects with `paginationOpts`. Move eligibility filters before bounded reads by
|
|
395
|
+
expressing them in the engine. Replace recognized unbounded relationship
|
|
396
|
+
collections with declared many pages and authenticated continuation endpoints.
|
|
397
|
+
Consumer diagnostics identify these patterns when kit/native provenance is known;
|
|
398
|
+
predicate movement has no automatic fix. Keep declarations in root
|
|
399
|
+
`relations.ts`/`querying.ts` and contracts and Query registries in their domain.
|
|
400
|
+
|
|
401
|
+
The [packed executable example](./test/fixture-packed-querying/convex/) includes
|
|
402
|
+
domain tables, contracts, authenticated API adapters, one/self/named/many/junction
|
|
403
|
+
edges, and child continuation. Its `.template` files become ordinary TypeScript
|
|
404
|
+
in isolated consumers; `bun run test:package:querying` installs the tarball on
|
|
405
|
+
installed and minimum peers, checks strict declarations and consumer rules, and
|
|
406
|
+
runs the full independent stress oracle and focused tie, output, replay, and
|
|
407
|
+
authorization-revocation probes. For a bounded anonymous local native proof,
|
|
408
|
+
run `node scripts/smoke-packed-querying.mjs <retained-packed-proof-directory>`
|
|
409
|
+
after the package check. It uses the same tarball and central default budgets.
|
|
410
|
+
Package publishing and application
|
|
411
|
+
migration remain separate work.
|
|
83
412
|
|
|
84
413
|
### `cvx-kit/auth`
|
|
85
414
|
|
|
@@ -90,20 +419,35 @@ policy — nothing in the kit imports your app's singletons:
|
|
|
90
419
|
import { createAuthFunctions } from 'cvx-kit/auth'
|
|
91
420
|
import { action, internalAction, internalMutation, mutation, query } from './_generated/server'
|
|
92
421
|
|
|
93
|
-
export const {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
422
|
+
export const {
|
|
423
|
+
authQuery,
|
|
424
|
+
authMutation,
|
|
425
|
+
authAction,
|
|
426
|
+
adminQuery,
|
|
427
|
+
adminMutation,
|
|
428
|
+
adminAction,
|
|
429
|
+
systemMutation,
|
|
430
|
+
systemAction,
|
|
431
|
+
include,
|
|
432
|
+
} = createAuthFunctions<DataModel>({
|
|
433
|
+
query,
|
|
434
|
+
mutation,
|
|
435
|
+
action,
|
|
436
|
+
internalMutation,
|
|
437
|
+
internalAction,
|
|
438
|
+
getAuthUser: (ctx) => authKit.getAuthUser(ctx),
|
|
439
|
+
verifyMembership: async ({ userId, organizationId }) => {
|
|
440
|
+
const memberships = await authKit.workos.userManagement.listOrganizationMemberships({
|
|
441
|
+
organizationId,
|
|
442
|
+
userId,
|
|
443
|
+
statuses: ['active'],
|
|
444
|
+
})
|
|
445
|
+
const m = memberships.data.find((c) => c.userId === userId)
|
|
446
|
+
return m ? { organizationId: m.organizationId, roleSlug: m.role.slug } : null
|
|
447
|
+
},
|
|
448
|
+
// resolveOrganization: async ({ ctx, user }) => { /* org+role from app tables */ },
|
|
449
|
+
wrapDB: (ctx) => triggers.wrapDB(ctx),
|
|
450
|
+
})
|
|
107
451
|
```
|
|
108
452
|
|
|
109
453
|
Actions re-verify membership live and fail closed; mutations get the trigger
|
|
@@ -111,50 +455,99 @@ registry structurally; `include()` bounds every read (default 100 rows).
|
|
|
111
455
|
`resolveOrganization` derives org and role from your own tables, enabling
|
|
112
456
|
identity providers whose tokens carry no org claims.
|
|
113
457
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
separate command import.
|
|
458
|
+
Convex evaluates a function's whole static import graph on every request, and
|
|
459
|
+
queries and mutations cannot use dynamic `import()`. Passing `triggers` here
|
|
460
|
+
makes every module that imports these constructors, queries included, load
|
|
461
|
+
every domain the trigger registry imports. Split the constructors:
|
|
119
462
|
|
|
120
463
|
```ts
|
|
121
|
-
// convex/
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
464
|
+
// convex/functions/base.ts — no trigger import
|
|
465
|
+
export const base = {
|
|
466
|
+
query,
|
|
467
|
+
action,
|
|
468
|
+
internalQuery,
|
|
469
|
+
internalAction,
|
|
470
|
+
getAuthUser,
|
|
471
|
+
mapRole,
|
|
472
|
+
adminRoles,
|
|
473
|
+
}
|
|
474
|
+
// convex/functions/read.ts — never imports the trigger registry
|
|
475
|
+
export const { authQuery, adminQuery, authAction, include } = createAuthReaders<DataModel>(base)
|
|
476
|
+
// convex/functions/write.ts
|
|
477
|
+
export const { authMutation, systemMutation } = createAuthFunctions<DataModel>({
|
|
478
|
+
...base,
|
|
479
|
+
mutation,
|
|
480
|
+
internalMutation,
|
|
481
|
+
triggers,
|
|
482
|
+
})
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
Query and action modules import only from `read.ts`. `createAuthReaders`
|
|
486
|
+
shares the implementation, so identity, tenancy, rules, and role gates match;
|
|
487
|
+
it has no mutation constructors. `createEffectAuthFunctions` has no reader
|
|
488
|
+
variant yet.
|
|
137
489
|
|
|
138
|
-
|
|
139
|
-
import { Command } from '../foundation'
|
|
490
|
+
### `cvx-kit/effect` — commands and queries
|
|
140
491
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
492
|
+
Use the Effect API for new commands. Install Effect `>=4.0.1 <5`, bind host
|
|
493
|
+
policies once with `createEffectFoundation`, and declare each handler inside
|
|
494
|
+
`command({...})` beside its schemas and audit policy.
|
|
495
|
+
|
|
496
|
+
<!-- packed-effect-example -->
|
|
497
|
+
|
|
498
|
+
```ts
|
|
499
|
+
import { createEffectFoundation } from 'cvx-kit/effect'
|
|
500
|
+
import type { AuditEntryInput } from 'cvx-kit/components/foundation'
|
|
501
|
+
import { k } from 'cvx-kit/k'
|
|
502
|
+
|
|
503
|
+
type Host = {
|
|
504
|
+
actorId: string
|
|
505
|
+
rename: (id: string, title: string) => Promise<void>
|
|
506
|
+
appendAudit: (entry: AuditEntryInput) => Promise<void>
|
|
507
|
+
}
|
|
508
|
+
const { Command } = createEffectFoundation({
|
|
509
|
+
observability: {
|
|
510
|
+
enabled: false,
|
|
511
|
+
classifyError: () => ({ outcome: 'failed', errorCode: 'RENAME_FAILED' }),
|
|
512
|
+
},
|
|
513
|
+
writeAudit: (host: Host, entry) => host.appendAudit(entry),
|
|
148
514
|
})
|
|
149
|
-
|
|
515
|
+
const renameInput = k.object({ id: k.string(), title: k.string() })
|
|
516
|
+
export const commands = Command({
|
|
517
|
+
context: (host: Host) => host,
|
|
518
|
+
operations: ({ command }) => ({
|
|
519
|
+
'documents.rename': command({
|
|
520
|
+
input: renameInput,
|
|
521
|
+
result: k.object({ ok: k.literal(true) }),
|
|
522
|
+
classification: 'business',
|
|
523
|
+
handler: async (input, context) => {
|
|
524
|
+
await context.rename(input.id, input.title)
|
|
525
|
+
return { ok: true as const }
|
|
526
|
+
},
|
|
527
|
+
audit: ({ command }, context) => ({
|
|
528
|
+
operation: 'documents.rename',
|
|
529
|
+
actorId: context.actorId,
|
|
530
|
+
aggregate: { type: 'document', id: command.id },
|
|
531
|
+
}),
|
|
532
|
+
}),
|
|
533
|
+
}),
|
|
534
|
+
})
|
|
535
|
+
export const executeRename = (input: k.input<typeof renameInput>, host: Host) =>
|
|
536
|
+
commands.exec('documents.rename', input, host)
|
|
150
537
|
```
|
|
151
538
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
539
|
+
`exec` returns a lazy Effect even for ordinary async handlers. Shared
|
|
540
|
+
`effectApiBuilder` constructors provide invocation-local
|
|
541
|
+
services and execute it; domain code can compose `Effect.gen` and `Effect.fn`
|
|
542
|
+
without starting another runner. Commands validate inputs and results, enforce
|
|
543
|
+
permissions and guards, and write audit entries in the mutation transaction.
|
|
544
|
+
See [commands](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/commands.md), [complete Effect wiring](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/effect.md),
|
|
545
|
+
and [authenticated builders](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/auth.md).
|
|
546
|
+
|
|
547
|
+
The old `Foundation.Command` Promise facade is **deprecated** and retained for
|
|
548
|
+
existing consumers. Its separate executor handler options are covered only in
|
|
549
|
+
the [compatibility reference](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/commands-legacy.md). The Foundation
|
|
550
|
+
component and its transaction result helpers remain available.
|
|
158
551
|
|
|
159
552
|
### `cvx-kit/components/approvals` (component)
|
|
160
553
|
|
|
@@ -170,6 +563,64 @@ import approvals from 'cvx-kit/components/approvals/convex.config'
|
|
|
170
563
|
app.use(approvals)
|
|
171
564
|
```
|
|
172
565
|
|
|
566
|
+
## Application lint rules
|
|
567
|
+
|
|
568
|
+
The TypeScript plugin `cvx-kit/oxlint` checks applications using the kit against
|
|
569
|
+
[`conventions.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/conventions.md). It targets `convex/`, including
|
|
570
|
+
public adapters, domain modules, root facades, and locally authored components.
|
|
571
|
+
Load it in your application's `.oxlintrc.json` and select rules:
|
|
572
|
+
|
|
573
|
+
```json
|
|
574
|
+
{
|
|
575
|
+
"jsPlugins": [{ "name": "cvx", "specifier": "cvx-kit/oxlint" }],
|
|
576
|
+
"rules": {
|
|
577
|
+
"cvx/project-structure": "error",
|
|
578
|
+
"cvx/root-wiring-only": "error",
|
|
579
|
+
"cvx/application-orchestration": "error",
|
|
580
|
+
"cvx/internal-function-ownership": "error",
|
|
581
|
+
"cvx/domain-file-responsibilities": "error",
|
|
582
|
+
"cvx/reserved-domain-file-anatomy": "error",
|
|
583
|
+
"cvx/no-raw-builders": "error",
|
|
584
|
+
"cvx/no-handwritten-references": "error",
|
|
585
|
+
"cvx/domain-import-boundaries": "error",
|
|
586
|
+
"cvx/public-functions-in-api": "error",
|
|
587
|
+
"cvx/thin-api-adapters": "error",
|
|
588
|
+
"cvx/root-facade-ownership": "error",
|
|
589
|
+
"cvx/no-inline-enums": "error",
|
|
590
|
+
"cvx/no-unbounded-reads": "error",
|
|
591
|
+
"cvx/no-manual-timestamps": "error",
|
|
592
|
+
"cvx/component-boundaries": "error",
|
|
593
|
+
"cvx/no-component-env": "error",
|
|
594
|
+
"cvx/schema-file-boundaries": "error",
|
|
595
|
+
"cvx/no-internal-reexports": "error",
|
|
596
|
+
"cvx/public-api-first": "error",
|
|
597
|
+
"cvx/named-private-helpers": "error"
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
With Vite+, put those fields under `lint` in `vite.config.ts`. Each rule accepts
|
|
603
|
+
`{ "convexDir": "path/to/convex" }` when your backend directory differs from
|
|
604
|
+
`convex/`. Generated files and tests are excluded from source-code rules. `project-structure`
|
|
605
|
+
inspects the whole backend for directory ownership, colocated runnable tests, and
|
|
606
|
+
module cycles. Run Oxlint on the whole backend, including `convex.config.ts`;
|
|
607
|
+
changed-file-only lint cannot guarantee a project scan. No application-owned
|
|
608
|
+
architecture test framework is required. The plugin also exports `checkArchitecture()`
|
|
609
|
+
for tools that need project diagnostics directly, named `rules`, and `RuleName`. Verified with
|
|
610
|
+
Oxlint 1.87.0 and Vite+ 1.1.0. See [rule coverage and limitations](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/oxlint.md)
|
|
611
|
+
and the [migration from the initial 0.1.4 plugin](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/upgrading.md).
|
|
612
|
+
|
|
613
|
+
Table-derived schemas are built on first access. Effect Query and Command registries
|
|
614
|
+
build on their first execution or `expose()` call; tests can force validation with
|
|
615
|
+
`checkArchitecture({ registries: [queries, commands] })`. For expensive contract
|
|
616
|
+
declarations, `defineDomainContract(() => ({ ... }))` builds once on first read,
|
|
617
|
+
preserving the same inferred types as the object form.
|
|
618
|
+
|
|
619
|
+
Repository checks and the enforced library rules are documented in
|
|
620
|
+
[`tools/oxlint/README.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/tools/oxlint/README.md). Run `bun run lint` for
|
|
621
|
+
anti-slop and architecture checks, `bun run test:lint` to test the custom
|
|
622
|
+
rules, and `bun run check` for the full Vite+ lint and formatting check.
|
|
623
|
+
|
|
173
624
|
## Component authoring conventions
|
|
174
625
|
|
|
175
626
|
This package follows the official Convex component template
|
|
@@ -197,7 +648,7 @@ registerApprovals(t)
|
|
|
197
648
|
## Releasing
|
|
198
649
|
|
|
199
650
|
Every release also creates a GitHub Release whose notes are the matching
|
|
200
|
-
[CHANGELOG](
|
|
651
|
+
[CHANGELOG](https://github.com/ImRLopezAG/cvx-kit/blob/main/CHANGELOG.md) section (extracted by
|
|
201
652
|
`scripts/extract-changelog.mjs` in the release workflow).
|
|
202
653
|
|
|
203
654
|
### OIDC setup
|
|
@@ -206,10 +657,10 @@ Publishing uses [npm Trusted Publishing](https://docs.npmjs.com/trusted-publishe
|
|
|
206
657
|
(OIDC) — no tokens stored anywhere. The release workflow authenticates via
|
|
207
658
|
GitHub's OIDC and npm generates provenance attestations automatically.
|
|
208
659
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
660
|
+
Merge the version bump and changelog into `main`, then wait for successful CI
|
|
661
|
+
on that exact commit before pushing its `v<version>` tag. The tag triggers
|
|
662
|
+
`.github/workflows/release.yml`, which checks the main CI result, builds and
|
|
663
|
+
validates the package and skill documentation, and publishes to npm.
|
|
213
664
|
|
|
214
665
|
One-time setup (already-published package required first):
|
|
215
666
|
|
|
@@ -221,4 +672,10 @@ One-time setup (already-published package required first):
|
|
|
221
672
|
|
|
222
673
|
## Roadmap
|
|
223
674
|
|
|
224
|
-
See [ROADMAP.md](
|
|
675
|
+
See [ROADMAP.md](https://github.com/ImRLopezAG/cvx-kit/blob/main/ROADMAP.md) for milestones.
|
|
676
|
+
|
|
677
|
+
Optional request context can be added through the existing Effect API adapter's
|
|
678
|
+
`context` callback. Bind selected registries with `commands.withContext(value)`
|
|
679
|
+
and consume `ctx.commands.exec(name, input)` through the application's existing
|
|
680
|
+
function helper names. Keep dependencies local to each feature; explicit execution
|
|
681
|
+
and input-only command handlers remain supported. See [optional context injection](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/command-context.md).
|