@cosmicdrift/kumiko-framework 0.328.0 → 0.328.1
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/dist/api/anonymous-cookie.d.ts +8 -0
- package/dist/api/anonymous-cookie.js +40 -0
- package/dist/api/api-constants.d.ts +47 -0
- package/dist/api/api-constants.js +136 -0
- package/dist/api/auth-middleware.d.ts +42 -0
- package/dist/api/auth-middleware.js +450 -0
- package/dist/api/auth-routes.d.ts +83 -0
- package/dist/api/auth-routes.js +1003 -0
- package/dist/api/client-ip.d.ts +15 -0
- package/dist/api/client-ip.js +101 -0
- package/dist/api/csrf-middleware.d.ts +9 -0
- package/dist/api/csrf-middleware.js +67 -0
- package/dist/api/extra-route.d.ts +99 -0
- package/dist/api/extra-route.js +48 -0
- package/dist/api/http-cache.d.ts +31 -0
- package/dist/api/http-cache.js +102 -0
- package/dist/api/index.d.ts +32 -0
- package/dist/api/index.js +20 -0
- package/dist/api/jwt.d.ts +22 -0
- package/dist/api/jwt.js +199 -0
- package/dist/api/observability-middleware.d.ts +8 -0
- package/dist/api/observability-middleware.js +68 -0
- package/dist/api/origin-middleware.d.ts +12 -0
- package/dist/api/origin-middleware.js +120 -0
- package/dist/api/pat-route-guard.d.ts +2 -0
- package/dist/api/pat-route-guard.js +43 -0
- package/dist/api/pat-scope.d.ts +2 -0
- package/dist/api/pat-scope.js +13 -0
- package/dist/api/pii-leak-guard.d.ts +2 -0
- package/dist/api/pii-leak-guard.js +40 -0
- package/dist/api/post-auth-landing.d.ts +14 -0
- package/dist/api/post-auth-landing.js +92 -0
- package/dist/api/readiness.d.ts +23 -0
- package/dist/api/readiness.js +98 -0
- package/dist/api/redis-sse-broker.d.ts +13 -0
- package/dist/api/redis-sse-broker.js +138 -0
- package/dist/api/request-context.d.ts +34 -0
- package/dist/api/request-context.js +60 -0
- package/dist/api/request-id-middleware.d.ts +37 -0
- package/dist/api/request-id-middleware.js +112 -0
- package/dist/api/route-registrars.d.ts +24 -0
- package/dist/api/route-registrars.js +133 -0
- package/dist/api/routes.d.ts +20 -0
- package/dist/api/routes.js +373 -0
- package/dist/api/server.d.ts +81 -0
- package/dist/api/server.js +1068 -0
- package/dist/api/sse-broker.d.ts +36 -0
- package/dist/api/sse-broker.js +112 -0
- package/dist/api/sse-route.d.ts +24 -0
- package/dist/api/sse-route.js +61 -0
- package/dist/api/tokens.d.ts +1 -0
- package/dist/api/tokens.js +15 -0
- package/dist/api/websocket-route.d.ts +59 -0
- package/dist/api/websocket-route.js +239 -0
- package/dist/arg-parser.d.ts +8 -0
- package/dist/arg-parser.js +59 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/roles.d.ts +16 -0
- package/dist/auth/roles.js +35 -0
- package/dist/bun-db/connection.d.ts +16 -0
- package/dist/bun-db/connection.js +54 -0
- package/dist/bun-db/index.d.ts +4 -0
- package/dist/bun-db/index.js +4 -0
- package/dist/bun-db/query.d.ts +64 -0
- package/dist/bun-db/query.js +1145 -0
- package/dist/compliance/duration-spec.d.ts +7 -0
- package/dist/compliance/duration-spec.js +37 -0
- package/dist/compliance/index.d.ts +6 -0
- package/dist/compliance/index.js +7 -0
- package/dist/compliance/override-schema.d.ts +78 -0
- package/dist/compliance/override-schema.js +124 -0
- package/dist/compliance/profiles.d.ts +125 -0
- package/dist/compliance/profiles.js +284 -0
- package/dist/compliance/sub-processors.d.ts +69 -0
- package/dist/compliance/sub-processors.js +109 -0
- package/dist/consumer-cli.d.ts +5 -0
- package/dist/consumer-cli.js +116 -0
- package/dist/crypto/blind-index.d.ts +10 -0
- package/dist/crypto/blind-index.js +97 -0
- package/dist/crypto/ciphertext-pattern.d.ts +3 -0
- package/dist/crypto/ciphertext-pattern.js +16 -0
- package/dist/crypto/event-pii.d.ts +8 -0
- package/dist/crypto/event-pii.js +79 -0
- package/dist/crypto/in-memory-kms-adapter.d.ts +11 -0
- package/dist/crypto/in-memory-kms-adapter.js +33 -0
- package/dist/crypto/index.d.ts +11 -0
- package/dist/crypto/index.js +11 -0
- package/dist/crypto/is-self-pii-field.d.ts +5 -0
- package/dist/crypto/is-self-pii-field.js +4 -0
- package/dist/crypto/kek-source.d.ts +23 -0
- package/dist/crypto/kek-source.js +122 -0
- package/dist/crypto/kms-adapter.d.ts +26 -0
- package/dist/crypto/kms-adapter.js +46 -0
- package/dist/crypto/kms-wiring.d.ts +67 -0
- package/dist/crypto/kms-wiring.js +125 -0
- package/dist/crypto/pg-kms-adapter.d.ts +55 -0
- package/dist/crypto/pg-kms-adapter.js +232 -0
- package/dist/crypto/pii-field-encryption.d.ts +20 -0
- package/dist/crypto/pii-field-encryption.js +201 -0
- package/dist/crypto/request-kms-cache.d.ts +8 -0
- package/dist/crypto/request-kms-cache.js +21 -0
- package/dist/crypto/subject-resolver.d.ts +30 -0
- package/dist/crypto/subject-resolver.js +153 -0
- package/dist/crypto/system-event-pii.d.ts +4 -0
- package/dist/crypto/system-event-pii.js +37 -0
- package/dist/db/api.d.ts +18 -0
- package/dist/db/api.js +23 -0
- package/dist/db/apply-entity-event.d.ts +21 -0
- package/dist/db/apply-entity-event.js +175 -0
- package/dist/db/assert-exists-in.d.ts +23 -0
- package/dist/db/assert-exists-in.js +34 -0
- package/dist/db/blind-index-cleanup.d.ts +5 -0
- package/dist/db/blind-index-cleanup.js +112 -0
- package/dist/db/bun-provider.d.ts +2 -0
- package/dist/db/bun-provider.js +37 -0
- package/dist/db/collect-table-metas.d.ts +3 -0
- package/dist/db/collect-table-metas.js +76 -0
- package/dist/db/compound-types.d.ts +9 -0
- package/dist/db/compound-types.js +31 -0
- package/dist/db/config-seed.d.ts +19 -0
- package/dist/db/config-seed.js +75 -0
- package/dist/db/connection.d.ts +10 -0
- package/dist/db/connection.js +35 -0
- package/dist/db/cursor.d.ts +9 -0
- package/dist/db/cursor.js +39 -0
- package/dist/db/dialect.d.ts +100 -0
- package/dist/db/dialect.js +386 -0
- package/dist/db/eagerload.d.ts +18 -0
- package/dist/db/eagerload.js +191 -0
- package/dist/db/entity-field-encryption.d.ts +15 -0
- package/dist/db/entity-field-encryption.js +127 -0
- package/dist/db/entity-table-from-registry.d.ts +4 -0
- package/dist/db/entity-table-from-registry.js +25 -0
- package/dist/db/entity-table-meta-types.d.ts +1 -0
- package/dist/db/entity-table-meta-types.js +1 -0
- package/dist/db/entity-table-meta.d.ts +30 -0
- package/dist/db/entity-table-meta.js +423 -0
- package/dist/db/event-store-executor-context.d.ts +49 -0
- package/dist/db/event-store-executor-context.js +368 -0
- package/dist/db/event-store-executor-read.d.ts +10 -0
- package/dist/db/event-store-executor-read.js +683 -0
- package/dist/db/event-store-executor-write.d.ts +3 -0
- package/dist/db/event-store-executor-write.js +705 -0
- package/dist/db/event-store-executor.d.ts +20 -0
- package/dist/db/event-store-executor.js +11 -0
- package/dist/db/feature-table-sources.d.ts +6 -0
- package/dist/db/feature-table-sources.js +24 -0
- package/dist/db/index.d.ts +37 -0
- package/dist/db/index.js +29 -0
- package/dist/db/located-timestamp.d.ts +22 -0
- package/dist/db/located-timestamp.js +100 -0
- package/dist/db/migrate-generator.d.ts +81 -0
- package/dist/db/migrate-generator.js +428 -0
- package/dist/db/migrate-runner.d.ts +30 -0
- package/dist/db/migrate-runner.js +273 -0
- package/dist/db/money.d.ts +30 -0
- package/dist/db/money.js +153 -0
- package/dist/db/parent-ref-clause.d.ts +10 -0
- package/dist/db/parent-ref-clause.js +124 -0
- package/dist/db/pg-error.d.ts +10 -0
- package/dist/db/pg-error.js +63 -0
- package/dist/db/postgres-provider.d.ts +2 -0
- package/dist/db/postgres-provider.js +21 -0
- package/dist/db/queries/advisory-lock.d.ts +3 -0
- package/dist/db/queries/advisory-lock.js +5 -0
- package/dist/db/queries/backfill-pii.d.ts +38 -0
- package/dist/db/queries/backfill-pii.js +433 -0
- package/dist/db/queries/ddl.d.ts +4 -0
- package/dist/db/queries/ddl.js +22 -0
- package/dist/db/queries/entity-read.d.ts +2 -0
- package/dist/db/queries/entity-read.js +5 -0
- package/dist/db/queries/es-ops.d.ts +5 -0
- package/dist/db/queries/es-ops.js +10 -0
- package/dist/db/queries/event-consumer.d.ts +36 -0
- package/dist/db/queries/event-consumer.js +261 -0
- package/dist/db/queries/event-store-admin.d.ts +24 -0
- package/dist/db/queries/event-store-admin.js +71 -0
- package/dist/db/queries/event-store-transfer.d.ts +20 -0
- package/dist/db/queries/event-store-transfer.js +31 -0
- package/dist/db/queries/event-store.d.ts +54 -0
- package/dist/db/queries/event-store.js +231 -0
- package/dist/db/queries/pii-backfill-state.d.ts +7 -0
- package/dist/db/queries/pii-backfill-state.js +14 -0
- package/dist/db/queries/projection-rebuild.d.ts +6 -0
- package/dist/db/queries/projection-rebuild.js +65 -0
- package/dist/db/queries/raw-sql.d.ts +9 -0
- package/dist/db/queries/raw-sql.js +16 -0
- package/dist/db/queries/seed-context.d.ts +20 -0
- package/dist/db/queries/seed-context.js +25 -0
- package/dist/db/queries/shadow-swap.d.ts +18 -0
- package/dist/db/queries/shadow-swap.js +307 -0
- package/dist/db/queries/table-ops.d.ts +4 -0
- package/dist/db/queries/table-ops.js +8 -0
- package/dist/db/queries/test-stack.d.ts +6 -0
- package/dist/db/queries/test-stack.js +20 -0
- package/dist/db/query-api.d.ts +2 -0
- package/dist/db/query-api.js +6 -0
- package/dist/db/query.d.ts +1 -0
- package/dist/db/query.js +3 -0
- package/dist/db/rebuild-marker.d.ts +4 -0
- package/dist/db/rebuild-marker.js +96 -0
- package/dist/db/reference-data.d.ts +14 -0
- package/dist/db/reference-data.js +66 -0
- package/dist/db/render-ddl.d.ts +4 -0
- package/dist/db/render-ddl.js +55 -0
- package/dist/db/replay-migration-sql.d.ts +12 -0
- package/dist/db/replay-migration-sql.js +223 -0
- package/dist/db/schema-inspection.d.ts +3 -0
- package/dist/db/schema-inspection.js +60 -0
- package/dist/db/table-builder.d.ts +194 -0
- package/dist/db/table-builder.js +430 -0
- package/dist/db/tenant-db-runner.d.ts +4 -0
- package/dist/db/tenant-db-runner.js +17 -0
- package/dist/db/tenant-db.d.ts +32 -0
- package/dist/db/tenant-db.js +501 -0
- package/dist/derivatives/delete-stored-file.d.ts +6 -0
- package/dist/derivatives/delete-stored-file.js +70 -0
- package/dist/derivatives/derivatives-context.d.ts +21 -0
- package/dist/derivatives/derivatives-context.js +212 -0
- package/dist/derivatives/field-variants.d.ts +3 -0
- package/dist/derivatives/field-variants.js +16 -0
- package/dist/derivatives/index.d.ts +6 -0
- package/dist/derivatives/index.js +4 -0
- package/dist/derivatives/variant-key.d.ts +10 -0
- package/dist/derivatives/variant-key.js +100 -0
- package/dist/engine/access.d.ts +2 -0
- package/dist/engine/access.js +25 -0
- package/dist/engine/active-membership.d.ts +26 -0
- package/dist/engine/active-membership.js +25 -0
- package/dist/engine/boot-validator/access-declarations.d.ts +2 -0
- package/dist/engine/boot-validator/access-declarations.js +148 -0
- package/dist/engine/boot-validator/access-roles.d.ts +2 -0
- package/dist/engine/boot-validator/access-roles.js +76 -0
- package/dist/engine/boot-validator/action-wiring.d.ts +3 -0
- package/dist/engine/boot-validator/action-wiring.js +104 -0
- package/dist/engine/boot-validator/api-ext.d.ts +3 -0
- package/dist/engine/boot-validator/api-ext.js +54 -0
- package/dist/engine/boot-validator/boot-check.d.ts +2 -0
- package/dist/engine/boot-validator/boot-check.js +20 -0
- package/dist/engine/boot-validator/config-deps.d.ts +10 -0
- package/dist/engine/boot-validator/config-deps.js +180 -0
- package/dist/engine/boot-validator/custom-screen-write-qns.d.ts +8 -0
- package/dist/engine/boot-validator/custom-screen-write-qns.js +75 -0
- package/dist/engine/boot-validator/detail-screens.d.ts +6 -0
- package/dist/engine/boot-validator/detail-screens.js +31 -0
- package/dist/engine/boot-validator/entity-handler.d.ts +23 -0
- package/dist/engine/boot-validator/entity-handler.js +754 -0
- package/dist/engine/boot-validator/entity-list-screens.d.ts +4 -0
- package/dist/engine/boot-validator/entity-list-screens.js +75 -0
- package/dist/engine/boot-validator/gdpr-storage.d.ts +2 -0
- package/dist/engine/boot-validator/gdpr-storage.js +48 -0
- package/dist/engine/boot-validator/global-tenancy.d.ts +2 -0
- package/dist/engine/boot-validator/global-tenancy.js +24 -0
- package/dist/engine/boot-validator/i18n-keys.d.ts +2 -0
- package/dist/engine/boot-validator/i18n-keys.js +88 -0
- package/dist/engine/boot-validator/index.d.ts +34 -0
- package/dist/engine/boot-validator/index.js +196 -0
- package/dist/engine/boot-validator/nav.d.ts +20 -0
- package/dist/engine/boot-validator/nav.js +202 -0
- package/dist/engine/boot-validator/ownership.d.ts +36 -0
- package/dist/engine/boot-validator/ownership.js +268 -0
- package/dist/engine/boot-validator/parent-ref.d.ts +3 -0
- package/dist/engine/boot-validator/parent-ref.js +73 -0
- package/dist/engine/boot-validator/pii-retention.d.ts +2 -0
- package/dist/engine/boot-validator/pii-retention.js +204 -0
- package/dist/engine/boot-validator/projection-list-screens.d.ts +4 -0
- package/dist/engine/boot-validator/projection-list-screens.js +219 -0
- package/dist/engine/boot-validator/query-output-columns.d.ts +2 -0
- package/dist/engine/boot-validator/query-output-columns.js +160 -0
- package/dist/engine/boot-validator/query-refs.d.ts +2 -0
- package/dist/engine/boot-validator/query-refs.js +72 -0
- package/dist/engine/boot-validator/record-owned.d.ts +2 -0
- package/dist/engine/boot-validator/record-owned.js +16 -0
- package/dist/engine/boot-validator/screens.d.ts +34 -0
- package/dist/engine/boot-validator/screens.js +1665 -0
- package/dist/engine/boot-validator/security-baseline.d.ts +3 -0
- package/dist/engine/boot-validator/security-baseline.js +18 -0
- package/dist/engine/boot-validator/transfer-graph.d.ts +3 -0
- package/dist/engine/boot-validator/transfer-graph.js +120 -0
- package/dist/engine/boot-validator/url-prefill-fields.d.ts +2 -0
- package/dist/engine/boot-validator/url-prefill-fields.js +106 -0
- package/dist/engine/boot-validator/workspaces.d.ts +20 -0
- package/dist/engine/boot-validator/workspaces.js +81 -0
- package/dist/engine/boot-validator/zod-shape.d.ts +5 -0
- package/dist/engine/boot-validator/zod-shape.js +110 -0
- package/dist/engine/boot-validator.d.ts +1 -0
- package/dist/engine/boot-validator.js +1 -0
- package/dist/engine/build-app-schema.d.ts +14 -0
- package/dist/engine/build-app-schema.js +494 -0
- package/dist/engine/build-config-feature-schema.d.ts +15 -0
- package/dist/engine/build-config-feature-schema.js +582 -0
- package/dist/engine/build-target.d.ts +28 -0
- package/dist/engine/build-target.js +43 -0
- package/dist/engine/changeset-changes.d.ts +12 -0
- package/dist/engine/changeset-changes.js +104 -0
- package/dist/engine/codemod/index.d.ts +2 -0
- package/dist/engine/codemod/index.js +1 -0
- package/dist/engine/codemod/pipeline-codemod.d.ts +50 -0
- package/dist/engine/codemod/pipeline-codemod.js +529 -0
- package/dist/engine/config-helpers.d.ts +42 -0
- package/dist/engine/config-helpers.js +115 -0
- package/dist/engine/constants.d.ts +52 -0
- package/dist/engine/constants.js +79 -0
- package/dist/engine/create-app.d.ts +17 -0
- package/dist/engine/create-app.js +119 -0
- package/dist/engine/cross-tenant.d.ts +3 -0
- package/dist/engine/cross-tenant.js +18 -0
- package/dist/engine/dedupe-features.d.ts +2 -0
- package/dist/engine/dedupe-features.js +36 -0
- package/dist/engine/define-feature.d.ts +7 -0
- package/dist/engine/define-feature.js +143 -0
- package/dist/engine/define-handler.d.ts +21 -0
- package/dist/engine/define-handler.js +117 -0
- package/dist/engine/define-roles.d.ts +5 -0
- package/dist/engine/define-roles.js +14 -0
- package/dist/engine/define-step.d.ts +4 -0
- package/dist/engine/define-step.js +22 -0
- package/dist/engine/define-workflow.d.ts +89 -0
- package/dist/engine/define-workflow.js +70 -0
- package/dist/engine/effective-features.d.ts +6 -0
- package/dist/engine/effective-features.js +73 -0
- package/dist/engine/embedded-derived.d.ts +29 -0
- package/dist/engine/embedded-derived.js +82 -0
- package/dist/engine/entity-handlers.d.ts +67 -0
- package/dist/engine/entity-handlers.js +567 -0
- package/dist/engine/escape-hatch-declaration.d.ts +2 -0
- package/dist/engine/escape-hatch-declaration.js +5 -0
- package/dist/engine/event-helpers.d.ts +11 -0
- package/dist/engine/event-helpers.js +47 -0
- package/dist/engine/extension-names.d.ts +164 -0
- package/dist/engine/extension-names.js +172 -0
- package/dist/engine/extension-selector-plugins.d.ts +5 -0
- package/dist/engine/extension-selector-plugins.js +14 -0
- package/dist/engine/extensions/escape-hatch-usage.d.ts +2 -0
- package/dist/engine/extensions/escape-hatch-usage.js +12 -0
- package/dist/engine/extensions/storage-provider.d.ts +4 -0
- package/dist/engine/extensions/storage-provider.js +1 -0
- package/dist/engine/extensions/tenant-data.d.ts +15 -0
- package/dist/engine/extensions/tenant-data.js +7 -0
- package/dist/engine/extensions/tenant-resource.d.ts +14 -0
- package/dist/engine/extensions/tenant-resource.js +6 -0
- package/dist/engine/extensions/user-data.d.ts +152 -0
- package/dist/engine/extensions/user-data.js +12 -0
- package/dist/engine/factories.d.ts +195 -0
- package/dist/engine/factories.js +387 -0
- package/dist/engine/feature-ast/entity-field-types.d.ts +13 -0
- package/dist/engine/feature-ast/entity-field-types.js +35 -0
- package/dist/engine/feature-ast/extractors/ai-steps.d.ts +6 -0
- package/dist/engine/feature-ast/extractors/ai-steps.js +254 -0
- package/dist/engine/feature-ast/extractors/events.d.ts +5 -0
- package/dist/engine/feature-ast/extractors/events.js +262 -0
- package/dist/engine/feature-ast/extractors/handlers.d.ts +23 -0
- package/dist/engine/feature-ast/extractors/handlers.js +319 -0
- package/dist/engine/feature-ast/extractors/hooks.d.ts +23 -0
- package/dist/engine/feature-ast/extractors/hooks.js +228 -0
- package/dist/engine/feature-ast/extractors/index.d.ts +14 -0
- package/dist/engine/feature-ast/extractors/index.js +13 -0
- package/dist/engine/feature-ast/extractors/jobs-routes.d.ts +7 -0
- package/dist/engine/feature-ast/extractors/jobs-routes.js +141 -0
- package/dist/engine/feature-ast/extractors/projections-screens.d.ts +10 -0
- package/dist/engine/feature-ast/extractors/projections-screens.js +195 -0
- package/dist/engine/feature-ast/extractors/resolve-import.d.ts +14 -0
- package/dist/engine/feature-ast/extractors/resolve-import.js +152 -0
- package/dist/engine/feature-ast/extractors/round1.d.ts +10 -0
- package/dist/engine/feature-ast/extractors/round1.js +81 -0
- package/dist/engine/feature-ast/extractors/round2.d.ts +7 -0
- package/dist/engine/feature-ast/extractors/round2.js +158 -0
- package/dist/engine/feature-ast/extractors/round3.d.ts +22 -0
- package/dist/engine/feature-ast/extractors/round3.js +280 -0
- package/dist/engine/feature-ast/extractors/round5.d.ts +8 -0
- package/dist/engine/feature-ast/extractors/round5.js +63 -0
- package/dist/engine/feature-ast/extractors/round6.d.ts +4 -0
- package/dist/engine/feature-ast/extractors/round6.js +17 -0
- package/dist/engine/feature-ast/extractors/shared.d.ts +85 -0
- package/dist/engine/feature-ast/extractors/shared.js +326 -0
- package/dist/engine/feature-ast/index.d.ts +16 -0
- package/dist/engine/feature-ast/index.js +10 -0
- package/dist/engine/feature-ast/parse.d.ts +30 -0
- package/dist/engine/feature-ast/parse.js +464 -0
- package/dist/engine/feature-ast/patch.d.ts +207 -0
- package/dist/engine/feature-ast/patch.js +771 -0
- package/dist/engine/feature-ast/patcher.d.ts +211 -0
- package/dist/engine/feature-ast/patcher.js +277 -0
- package/dist/engine/feature-ast/pattern-change-schema.d.ts +670 -0
- package/dist/engine/feature-ast/pattern-change-schema.js +1196 -0
- package/dist/engine/feature-ast/patterns.d.ts +302 -0
- package/dist/engine/feature-ast/patterns.js +113 -0
- package/dist/engine/feature-ast/render.d.ts +47 -0
- package/dist/engine/feature-ast/render.js +681 -0
- package/dist/engine/feature-ast/source-location.d.ts +17 -0
- package/dist/engine/feature-ast/source-location.js +27 -0
- package/dist/engine/feature-builder-state.d.ts +69 -0
- package/dist/engine/feature-builder-state.js +64 -0
- package/dist/engine/feature-changelog.d.ts +21 -0
- package/dist/engine/feature-changelog.js +76 -0
- package/dist/engine/feature-config-events-jobs.d.ts +58 -0
- package/dist/engine/feature-config-events-jobs.js +318 -0
- package/dist/engine/feature-entity-handlers.d.ts +38 -0
- package/dist/engine/feature-entity-handlers.js +185 -0
- package/dist/engine/feature-manifest.d.ts +73 -0
- package/dist/engine/feature-manifest.js +87 -0
- package/dist/engine/feature-ui-extensions.d.ts +68 -0
- package/dist/engine/feature-ui-extensions.js +488 -0
- package/dist/engine/field-access.d.ts +4 -0
- package/dist/engine/field-access.js +119 -0
- package/dist/engine/field-helpers.d.ts +4 -0
- package/dist/engine/field-helpers.js +28 -0
- package/dist/engine/handler-helpers.d.ts +19 -0
- package/dist/engine/handler-helpers.js +24 -0
- package/dist/engine/hook-helpers.d.ts +4 -0
- package/dist/engine/hook-helpers.js +13 -0
- package/dist/engine/i18n-key.d.ts +2 -0
- package/dist/engine/i18n-key.js +10 -0
- package/dist/engine/index.d.ts +77 -0
- package/dist/engine/index.js +70 -0
- package/dist/engine/instruction-fields.d.ts +2 -0
- package/dist/engine/instruction-fields.js +9 -0
- package/dist/engine/membership-roles.d.ts +5 -0
- package/dist/engine/membership-roles.js +48 -0
- package/dist/engine/object-form.d.ts +4 -0
- package/dist/engine/object-form.js +21 -0
- package/dist/engine/ownership.d.ts +12 -0
- package/dist/engine/ownership.js +339 -0
- package/dist/engine/parse-ref-target.d.ts +6 -0
- package/dist/engine/parse-ref-target.js +21 -0
- package/dist/engine/pattern-library/index.d.ts +2 -0
- package/dist/engine/pattern-library/index.js +3 -0
- package/dist/engine/pattern-library/library.d.ts +14 -0
- package/dist/engine/pattern-library/library.js +92 -0
- package/dist/engine/pattern-library/mixed-schemas.d.ts +16 -0
- package/dist/engine/pattern-library/mixed-schemas.js +569 -0
- package/dist/engine/pattern-library/opaque-schemas.d.ts +7 -0
- package/dist/engine/pattern-library/opaque-schemas.js +115 -0
- package/dist/engine/pattern-library/shared-fields.d.ts +120 -0
- package/dist/engine/pattern-library/shared-fields.js +71 -0
- package/dist/engine/pattern-library/static-schemas.d.ts +19 -0
- package/dist/engine/pattern-library/static-schemas.js +435 -0
- package/dist/engine/pattern-library/types.d.ts +158 -0
- package/dist/engine/pattern-library/types.js +36 -0
- package/dist/engine/personal-data-fields.d.ts +5 -0
- package/dist/engine/personal-data-fields.js +56 -0
- package/dist/engine/pipeline.d.ts +4 -0
- package/dist/engine/pipeline.js +87 -0
- package/dist/engine/project-app-schema-for-roles.d.ts +2 -0
- package/dist/engine/project-app-schema-for-roles.js +679 -0
- package/dist/engine/projection-helpers.d.ts +7 -0
- package/dist/engine/projection-helpers.js +61 -0
- package/dist/engine/qualified-name.d.ts +27 -0
- package/dist/engine/qualified-name.js +137 -0
- package/dist/engine/read-claim.d.ts +2 -0
- package/dist/engine/read-claim.js +28 -0
- package/dist/engine/registry-facade.d.ts +3 -0
- package/dist/engine/registry-facade.js +231 -0
- package/dist/engine/registry-ingest.d.ts +14 -0
- package/dist/engine/registry-ingest.js +415 -0
- package/dist/engine/registry-state.d.ts +93 -0
- package/dist/engine/registry-state.js +233 -0
- package/dist/engine/registry-validate.d.ts +25 -0
- package/dist/engine/registry-validate.js +669 -0
- package/dist/engine/registry.d.ts +2 -0
- package/dist/engine/registry.js +52 -0
- package/dist/engine/resolve-config-or-param.d.ts +18 -0
- package/dist/engine/resolve-config-or-param.js +76 -0
- package/dist/engine/role-assignment.d.ts +1 -0
- package/dist/engine/role-assignment.js +58 -0
- package/dist/engine/run-in.d.ts +2 -0
- package/dist/engine/run-in.js +28 -0
- package/dist/engine/run-pipeline.d.ts +25 -0
- package/dist/engine/run-pipeline.js +111 -0
- package/dist/engine/schema-builder.d.ts +8 -0
- package/dist/engine/schema-builder.js +406 -0
- package/dist/engine/screen-filter-ops.d.ts +3 -0
- package/dist/engine/screen-filter-ops.js +55 -0
- package/dist/engine/screen-helpers.d.ts +27 -0
- package/dist/engine/screen-helpers.js +100 -0
- package/dist/engine/soft-delete-cleanup.d.ts +10 -0
- package/dist/engine/soft-delete-cleanup.js +114 -0
- package/dist/engine/state-machine.d.ts +34 -0
- package/dist/engine/state-machine.js +44 -0
- package/dist/engine/steps/_duration-utils.d.ts +1 -0
- package/dist/engine/steps/_duration-utils.js +28 -0
- package/dist/engine/steps/_event-match.d.ts +2 -0
- package/dist/engine/steps/_event-match.js +88 -0
- package/dist/engine/steps/_no-return-guard.d.ts +2 -0
- package/dist/engine/steps/_no-return-guard.js +16 -0
- package/dist/engine/steps/_read-source.d.ts +6 -0
- package/dist/engine/steps/_read-source.js +7 -0
- package/dist/engine/steps/_resolver-utils.d.ts +11 -0
- package/dist/engine/steps/_resolver-utils.js +36 -0
- package/dist/engine/steps/_step-dispatch-constants.d.ts +13 -0
- package/dist/engine/steps/_step-dispatch-constants.js +32 -0
- package/dist/engine/steps/aggregate-append-event.d.ts +10 -0
- package/dist/engine/steps/aggregate-append-event.js +43 -0
- package/dist/engine/steps/aggregate-create.d.ts +6 -0
- package/dist/engine/steps/aggregate-create.js +38 -0
- package/dist/engine/steps/aggregate-update.d.ts +10 -0
- package/dist/engine/steps/aggregate-update.js +38 -0
- package/dist/engine/steps/branch.d.ts +8 -0
- package/dist/engine/steps/branch.js +66 -0
- package/dist/engine/steps/call-feature.d.ts +7 -0
- package/dist/engine/steps/call-feature.js +30 -0
- package/dist/engine/steps/compute.d.ts +2 -0
- package/dist/engine/steps/compute.js +29 -0
- package/dist/engine/steps/describe-workflow-step-error.d.ts +1 -0
- package/dist/engine/steps/describe-workflow-step-error.js +6 -0
- package/dist/engine/steps/for-each.d.ts +9 -0
- package/dist/engine/steps/for-each.js +88 -0
- package/dist/engine/steps/mail-send.d.ts +10 -0
- package/dist/engine/steps/mail-send.js +33 -0
- package/dist/engine/steps/read-find-many.d.ts +10 -0
- package/dist/engine/steps/read-find-many.js +32 -0
- package/dist/engine/steps/read-find-one.d.ts +9 -0
- package/dist/engine/steps/read-find-one.js +41 -0
- package/dist/engine/steps/retry.d.ts +9 -0
- package/dist/engine/steps/retry.js +76 -0
- package/dist/engine/steps/return.d.ts +4 -0
- package/dist/engine/steps/return.js +25 -0
- package/dist/engine/steps/unsafe-projection-delete.d.ts +8 -0
- package/dist/engine/steps/unsafe-projection-delete.js +35 -0
- package/dist/engine/steps/unsafe-projection-upsert.d.ts +8 -0
- package/dist/engine/steps/unsafe-projection-upsert.js +73 -0
- package/dist/engine/steps/wait-for-event.d.ts +8 -0
- package/dist/engine/steps/wait-for-event.js +63 -0
- package/dist/engine/steps/wait.d.ts +6 -0
- package/dist/engine/steps/wait.js +50 -0
- package/dist/engine/steps/webhook-send.d.ts +24 -0
- package/dist/engine/steps/webhook-send.js +38 -0
- package/dist/engine/system-user.d.ts +8 -0
- package/dist/engine/system-user.js +29 -0
- package/dist/engine/tier-resolver-extension.d.ts +62 -0
- package/dist/engine/tier-resolver-extension.js +55 -0
- package/dist/engine/types/config.d.ts +1 -0
- package/dist/engine/types/config.js +1 -0
- package/dist/engine/types/define-handler.d.ts +1 -0
- package/dist/engine/types/define-handler.js +1 -0
- package/dist/engine/types/entity-handlers.d.ts +1 -0
- package/dist/engine/types/entity-handlers.js +1 -0
- package/dist/engine/types/event-type-map.js +1 -0
- package/dist/engine/types/extension-options-map.js +1 -0
- package/dist/engine/types/feature.d.ts +1 -0
- package/dist/engine/types/feature.js +1 -0
- package/dist/engine/types/fields.d.ts +1 -0
- package/dist/engine/types/fields.js +1 -0
- package/dist/engine/types/handlers.d.ts +2 -0
- package/dist/engine/types/handlers.js +1 -0
- package/dist/engine/types/hooks.d.ts +1 -0
- package/dist/engine/types/hooks.js +1 -0
- package/dist/engine/types/http-route.js +1 -0
- package/dist/engine/types/identifiers.js +1 -0
- package/dist/engine/types/index.d.ts +30 -0
- package/dist/engine/types/index.js +10 -0
- package/dist/engine/types/nav.d.ts +1 -0
- package/dist/engine/types/nav.js +1 -0
- package/dist/engine/types/ownership.d.ts +1 -0
- package/dist/engine/types/ownership.js +1 -0
- package/dist/engine/types/projection.d.ts +1 -0
- package/dist/engine/types/projection.js +1 -0
- package/dist/engine/types/relations.js +1 -0
- package/dist/engine/types/screen.d.ts +2 -0
- package/dist/engine/types/screen.js +1 -0
- package/dist/engine/types/step.d.ts +1 -0
- package/dist/engine/types/step.js +1 -0
- package/dist/engine/types/target-ref.js +1 -0
- package/dist/engine/types/tree-node.js +1 -0
- package/dist/engine/types/workspace.d.ts +1 -0
- package/dist/engine/types/workspace.js +1 -0
- package/dist/engine/validate-projection-allowlist.d.ts +10 -0
- package/dist/engine/validate-projection-allowlist.js +164 -0
- package/dist/engine/validation.d.ts +3 -0
- package/dist/engine/validation.js +23 -0
- package/dist/engine/where-rule-lint.d.ts +2 -0
- package/dist/engine/where-rule-lint.js +171 -0
- package/dist/engine/write-handler-qn-extract.d.ts +15 -0
- package/dist/engine/write-handler-qn-extract.js +36 -0
- package/dist/entrypoint/index.d.ts +83 -0
- package/dist/entrypoint/index.js +312 -0
- package/dist/env/_zod-introspect.d.ts +17 -0
- package/dist/env/_zod-introspect.js +35 -0
- package/dist/env/dry-run.d.ts +13 -0
- package/dist/env/dry-run.js +158 -0
- package/dist/env/index.d.ts +98 -0
- package/dist/env/index.js +313 -0
- package/dist/errors/classes.d.ts +109 -0
- package/dist/errors/classes.js +190 -0
- package/dist/errors/field-issue.d.ts +6 -0
- package/dist/errors/field-issue.js +1 -0
- package/dist/errors/index.d.ts +15 -0
- package/dist/errors/index.js +9 -0
- package/dist/errors/kumiko-error.d.ts +25 -0
- package/dist/errors/kumiko-error.js +43 -0
- package/dist/errors/member-resolution.d.ts +2 -0
- package/dist/errors/member-resolution.js +10 -0
- package/dist/errors/reasons.d.ts +23 -0
- package/dist/errors/reasons.js +81 -0
- package/dist/errors/serialize.d.ts +32 -0
- package/dist/errors/serialize.js +76 -0
- package/dist/errors/to-kumiko-error.d.ts +2 -0
- package/dist/errors/to-kumiko-error.js +9 -0
- package/dist/errors/transition-details.d.ts +7 -0
- package/dist/errors/transition-details.js +16 -0
- package/dist/errors/write-error-info.d.ts +20 -0
- package/dist/errors/write-error-info.js +99 -0
- package/dist/errors/zod-bridge.d.ts +3 -0
- package/dist/errors/zod-bridge.js +58 -0
- package/dist/es-ops/context.d.ts +19 -0
- package/dist/es-ops/context.js +70 -0
- package/dist/es-ops/index.d.ts +4 -0
- package/dist/es-ops/index.js +14 -0
- package/dist/es-ops/operations-schema.d.ts +5 -0
- package/dist/es-ops/operations-schema.js +40 -0
- package/dist/es-ops/runner.d.ts +29 -0
- package/dist/es-ops/runner.js +195 -0
- package/dist/es-ops/types.d.ts +92 -0
- package/dist/es-ops/types.js +14 -0
- package/dist/event-store/admin-api.d.ts +17 -0
- package/dist/event-store/admin-api.js +173 -0
- package/dist/event-store/archive.d.ts +14 -0
- package/dist/event-store/archive.js +55 -0
- package/dist/event-store/errors.d.ts +15 -0
- package/dist/event-store/errors.js +49 -0
- package/dist/event-store/event-store.d.ts +38 -0
- package/dist/event-store/event-store.js +310 -0
- package/dist/event-store/events-schema.d.ts +3 -0
- package/dist/event-store/events-schema.js +66 -0
- package/dist/event-store/index.d.ts +12 -0
- package/dist/event-store/index.js +12 -0
- package/dist/event-store/provenance-append.d.ts +13 -0
- package/dist/event-store/provenance-append.js +49 -0
- package/dist/event-store/rebuild-dead-letter.d.ts +25 -0
- package/dist/event-store/rebuild-dead-letter.js +71 -0
- package/dist/event-store/row-to-stored-event.d.ts +17 -0
- package/dist/event-store/row-to-stored-event.js +15 -0
- package/dist/event-store/snapshot.d.ts +26 -0
- package/dist/event-store/snapshot.js +155 -0
- package/dist/event-store/transfer.d.ts +13 -0
- package/dist/event-store/transfer.js +62 -0
- package/dist/event-store/types.d.ts +1 -0
- package/dist/event-store/types.js +1 -0
- package/dist/event-store/upcaster-dead-letter.d.ts +27 -0
- package/dist/event-store/upcaster-dead-letter.js +76 -0
- package/dist/event-store/upcaster.d.ts +14 -0
- package/dist/event-store/upcaster.js +86 -0
- package/dist/files/content-disposition.d.ts +3 -0
- package/dist/files/content-disposition.js +50 -0
- package/dist/files/feature.d.ts +9 -0
- package/dist/files/feature.js +26 -0
- package/dist/files/file-handle.d.ts +7 -0
- package/dist/files/file-handle.js +71 -0
- package/dist/files/file-ref-entity.d.ts +134 -0
- package/dist/files/file-ref-entity.js +32 -0
- package/dist/files/file-ref-table.d.ts +134 -0
- package/dist/files/file-ref-table.js +12 -0
- package/dist/files/file-routes.d.ts +34 -0
- package/dist/files/file-routes.js +433 -0
- package/dist/files/in-memory-provider.d.ts +7 -0
- package/dist/files/in-memory-provider.js +82 -0
- package/dist/files/index.d.ts +17 -0
- package/dist/files/index.js +13 -0
- package/dist/files/local-provider.d.ts +2 -0
- package/dist/files/local-provider.js +128 -0
- package/dist/files/provider-resolver.d.ts +58 -0
- package/dist/files/provider-resolver.js +87 -0
- package/dist/files/storage-tracking.d.ts +20 -0
- package/dist/files/storage-tracking.js +179 -0
- package/dist/files/types.d.ts +59 -0
- package/dist/files/types.js +276 -0
- package/dist/files/zip-stream.d.ts +31 -0
- package/dist/files/zip-stream.js +207 -0
- package/dist/http/index.d.ts +2 -0
- package/dist/http/index.js +1 -0
- package/dist/i18n/index.d.ts +12 -0
- package/dist/i18n/index.js +27 -0
- package/dist/i18n/mail-registry.d.ts +7 -0
- package/dist/i18n/mail-registry.js +34 -0
- package/dist/i18n/request-locale.d.ts +22 -0
- package/dist/i18n/request-locale.js +62 -0
- package/dist/i18n/required-surface-keys.d.ts +33 -0
- package/dist/i18n/required-surface-keys.js +416 -0
- package/dist/i18n/settings-hub-keys.d.ts +14 -0
- package/dist/i18n/settings-hub-keys.js +29 -0
- package/dist/jobs/index.d.ts +2 -0
- package/dist/jobs/index.js +1 -0
- package/dist/jobs/job-runner.d.ts +54 -0
- package/dist/jobs/job-runner.js +1110 -0
- package/dist/lifecycle/index.d.ts +2 -0
- package/dist/lifecycle/index.js +2 -0
- package/dist/lifecycle/lifecycle.d.ts +23 -0
- package/dist/lifecycle/lifecycle.js +111 -0
- package/dist/lifecycle/signal-handlers.d.ts +10 -0
- package/dist/lifecycle/signal-handlers.js +40 -0
- package/dist/logging/index.d.ts +4 -0
- package/dist/logging/index.js +2 -0
- package/dist/logging/pino-logger.d.ts +9 -0
- package/dist/logging/pino-logger.js +61 -0
- package/dist/logging/types.js +1 -0
- package/dist/logging/utils.d.ts +8 -0
- package/dist/logging/utils.js +41 -0
- package/dist/migrations/index.d.ts +4 -0
- package/dist/migrations/index.js +8 -0
- package/dist/migrations/kumiko-drift.d.ts +26 -0
- package/dist/migrations/kumiko-drift.js +151 -0
- package/dist/migrations/pending-rebuilds.d.ts +81 -0
- package/dist/migrations/pending-rebuilds.js +163 -0
- package/dist/migrations/pii-event-backfill.d.ts +40 -0
- package/dist/migrations/pii-event-backfill.js +275 -0
- package/dist/migrations/projection-table-index.d.ts +5 -0
- package/dist/migrations/projection-table-index.js +21 -0
- package/dist/observability/console-provider.d.ts +10 -0
- package/dist/observability/console-provider.js +101 -0
- package/dist/observability/context.d.ts +10 -0
- package/dist/observability/context.js +13 -0
- package/dist/observability/escape-hatch-report.d.ts +23 -0
- package/dist/observability/escape-hatch-report.js +92 -0
- package/dist/observability/fallback.d.ts +4 -0
- package/dist/observability/fallback.js +28 -0
- package/dist/observability/ids.d.ts +2 -0
- package/dist/observability/ids.js +22 -0
- package/dist/observability/index.d.ts +15 -0
- package/dist/observability/index.js +15 -0
- package/dist/observability/metric-validator.d.ts +4 -0
- package/dist/observability/metric-validator.js +73 -0
- package/dist/observability/metrics-handle.d.ts +5 -0
- package/dist/observability/metrics-handle.js +102 -0
- package/dist/observability/metrics-wiring.d.ts +18 -0
- package/dist/observability/metrics-wiring.js +21 -0
- package/dist/observability/noop-provider.d.ts +2 -0
- package/dist/observability/noop-provider.js +105 -0
- package/dist/observability/prometheus-meter.d.ts +26 -0
- package/dist/observability/prometheus-meter.js +257 -0
- package/dist/observability/recording-meter.d.ts +31 -0
- package/dist/observability/recording-meter.js +127 -0
- package/dist/observability/recording-tracer.d.ts +32 -0
- package/dist/observability/recording-tracer.js +135 -0
- package/dist/observability/redis-wrapper.d.ts +3 -0
- package/dist/observability/redis-wrapper.js +121 -0
- package/dist/observability/sensitive-filter.d.ts +9 -0
- package/dist/observability/sensitive-filter.js +92 -0
- package/dist/observability/standard-metrics.d.ts +41 -0
- package/dist/observability/standard-metrics.js +237 -0
- package/dist/observability/types/index.js +1 -0
- package/dist/observability/types/metric.js +1 -0
- package/dist/observability/types/provider.js +1 -0
- package/dist/observability/types/span.js +1 -0
- package/dist/pipeline/active-membership.d.ts +12 -0
- package/dist/pipeline/active-membership.js +124 -0
- package/dist/pipeline/append-event-core.d.ts +12 -0
- package/dist/pipeline/append-event-core.js +84 -0
- package/dist/pipeline/auth-claims-resolver.d.ts +9 -0
- package/dist/pipeline/auth-claims-resolver.js +76 -0
- package/dist/pipeline/cascade-handler.d.ts +6 -0
- package/dist/pipeline/cascade-handler.js +85 -0
- package/dist/pipeline/dispatch-batch.d.ts +5 -0
- package/dist/pipeline/dispatch-batch.js +217 -0
- package/dist/pipeline/dispatch-query.d.ts +4 -0
- package/dist/pipeline/dispatch-query.js +141 -0
- package/dist/pipeline/dispatch-shared.d.ts +58 -0
- package/dist/pipeline/dispatch-shared.js +924 -0
- package/dist/pipeline/dispatch-stream.d.ts +3 -0
- package/dist/pipeline/dispatch-stream.js +89 -0
- package/dist/pipeline/dispatch-write.d.ts +6 -0
- package/dist/pipeline/dispatch-write.js +428 -0
- package/dist/pipeline/dispatcher-utils.d.ts +36 -0
- package/dist/pipeline/dispatcher-utils.js +139 -0
- package/dist/pipeline/dispatcher.d.ts +30 -0
- package/dist/pipeline/dispatcher.js +131 -0
- package/dist/pipeline/distributed-lock.d.ts +13 -0
- package/dist/pipeline/distributed-lock.js +42 -0
- package/dist/pipeline/entity-cache.d.ts +7 -0
- package/dist/pipeline/entity-cache.js +68 -0
- package/dist/pipeline/event-consumer-state.d.ts +16 -0
- package/dist/pipeline/event-consumer-state.js +96 -0
- package/dist/pipeline/event-dedup.d.ts +11 -0
- package/dist/pipeline/event-dedup.js +12 -0
- package/dist/pipeline/event-dispatcher-admin.d.ts +46 -0
- package/dist/pipeline/event-dispatcher-admin.js +196 -0
- package/dist/pipeline/event-dispatcher-delivery.d.ts +68 -0
- package/dist/pipeline/event-dispatcher-delivery.js +310 -0
- package/dist/pipeline/event-dispatcher.d.ts +52 -0
- package/dist/pipeline/event-dispatcher.js +523 -0
- package/dist/pipeline/event-retention.d.ts +20 -0
- package/dist/pipeline/event-retention.js +78 -0
- package/dist/pipeline/idempotency.d.ts +19 -0
- package/dist/pipeline/idempotency.js +115 -0
- package/dist/pipeline/index.d.ts +34 -0
- package/dist/pipeline/index.js +19 -0
- package/dist/pipeline/irreversible-operation-gate.d.ts +4 -0
- package/dist/pipeline/irreversible-operation-gate.js +57 -0
- package/dist/pipeline/lifecycle-pipeline.d.ts +29 -0
- package/dist/pipeline/lifecycle-pipeline.js +266 -0
- package/dist/pipeline/member-read-only-transaction.d.ts +3 -0
- package/dist/pipeline/member-read-only-transaction.js +68 -0
- package/dist/pipeline/member-reader.d.ts +7 -0
- package/dist/pipeline/member-reader.js +87 -0
- package/dist/pipeline/msp-rebuild.d.ts +12 -0
- package/dist/pipeline/msp-rebuild.js +163 -0
- package/dist/pipeline/multi-stream-apply-context.d.ts +18 -0
- package/dist/pipeline/multi-stream-apply-context.js +40 -0
- package/dist/pipeline/pending-gap-ranges.d.ts +12 -0
- package/dist/pipeline/pending-gap-ranges.js +99 -0
- package/dist/pipeline/projection-rebuild.d.ts +55 -0
- package/dist/pipeline/projection-rebuild.js +285 -0
- package/dist/pipeline/projection-state.d.ts +9 -0
- package/dist/pipeline/projection-state.js +51 -0
- package/dist/pipeline/projections-runner.d.ts +5 -0
- package/dist/pipeline/projections-runner.js +57 -0
- package/dist/pipeline/redis-keys.d.ts +8 -0
- package/dist/pipeline/redis-keys.js +10 -0
- package/dist/pipeline/system-hooks.d.ts +25 -0
- package/dist/pipeline/system-hooks.js +590 -0
- package/dist/pipeline/system-identity-switch.d.ts +30 -0
- package/dist/pipeline/system-identity-switch.js +248 -0
- package/dist/pipeline/tenant-timezone-cache.d.ts +17 -0
- package/dist/pipeline/tenant-timezone-cache.js +55 -0
- package/dist/pipeline/write-origin.d.ts +10 -0
- package/dist/pipeline/write-origin.js +110 -0
- package/dist/random/generate.d.ts +56 -0
- package/dist/random/generate.js +92 -0
- package/dist/random/index.d.ts +2 -0
- package/dist/random/index.js +2 -0
- package/dist/random/words.d.ts +2 -0
- package/dist/random/words.js +391 -0
- package/dist/rate-limit/bucket.d.ts +14 -0
- package/dist/rate-limit/bucket.js +20 -0
- package/dist/rate-limit/index.d.ts +3 -0
- package/dist/rate-limit/index.js +3 -0
- package/dist/rate-limit/middleware.d.ts +24 -0
- package/dist/rate-limit/middleware.js +101 -0
- package/dist/rate-limit/resolver.d.ts +9 -0
- package/dist/rate-limit/resolver.js +177 -0
- package/dist/redis/client.d.ts +9 -0
- package/dist/redis/client.js +44 -0
- package/dist/redis/index.d.ts +4 -0
- package/dist/redis/index.js +2 -0
- package/dist/redis/pubsub-signal.d.ts +11 -0
- package/dist/redis/pubsub-signal.js +79 -0
- package/dist/schema-cli.d.ts +21 -0
- package/dist/schema-cli.js +438 -0
- package/dist/scripts/codemod/crypto-shredding-testing-move.d.ts +2 -0
- package/dist/scripts/codemod/crypto-shredding-testing-move.js +109 -0
- package/dist/scripts/codemod/migrate-cross-tenant.d.ts +19 -0
- package/dist/scripts/codemod/migrate-cross-tenant.js +266 -0
- package/dist/scripts/codemod/migrate-db-raw.d.ts +23 -0
- package/dist/scripts/codemod/migrate-db-raw.js +345 -0
- package/dist/scripts/codemod/migrate-open-to-all.d.ts +22 -0
- package/dist/scripts/codemod/migrate-open-to-all.js +194 -0
- package/dist/scripts/codemod/pii-personal-migration.d.ts +11 -0
- package/dist/scripts/codemod/pii-personal-migration.js +615 -0
- package/dist/scripts/codemod/unprocessable-error-details-reason.d.ts +2 -0
- package/dist/scripts/codemod/unprocessable-error-details-reason.js +235 -0
- package/dist/search/derive-search-adapter-config.d.ts +3 -0
- package/dist/search/derive-search-adapter-config.js +23 -0
- package/dist/search/in-memory-adapter.d.ts +2 -0
- package/dist/search/in-memory-adapter.js +96 -0
- package/dist/search/index.d.ts +6 -0
- package/dist/search/index.js +8 -0
- package/dist/search/meilisearch-adapter.d.ts +10 -0
- package/dist/search/meilisearch-adapter.js +175 -0
- package/dist/search/purge-subject.d.ts +7 -0
- package/dist/search/purge-subject.js +178 -0
- package/dist/search/reindex-entity.d.ts +18 -0
- package/dist/search/reindex-entity.js +139 -0
- package/dist/search/types.js +1 -0
- package/dist/secrets/dek-cache.d.ts +13 -0
- package/dist/secrets/dek-cache.js +97 -0
- package/dist/secrets/derive-purpose-secret.d.ts +1 -0
- package/dist/secrets/derive-purpose-secret.js +16 -0
- package/dist/secrets/env-master-key-provider.d.ts +6 -0
- package/dist/secrets/env-master-key-provider.js +134 -0
- package/dist/secrets/envelope-cipher.d.ts +8 -0
- package/dist/secrets/envelope-cipher.js +36 -0
- package/dist/secrets/envelope.d.ts +3 -0
- package/dist/secrets/envelope.js +44 -0
- package/dist/secrets/index.d.ts +9 -0
- package/dist/secrets/index.js +9 -0
- package/dist/secrets/leak-guard.d.ts +1 -0
- package/dist/secrets/leak-guard.js +79 -0
- package/dist/secrets/rotation.d.ts +2 -0
- package/dist/secrets/rotation.js +29 -0
- package/dist/secrets/stored-envelope.d.ts +11 -0
- package/dist/secrets/stored-envelope.js +32 -0
- package/dist/secrets/types.d.ts +1 -0
- package/dist/seeding/entity-seed.d.ts +19 -0
- package/dist/seeding/entity-seed.js +12 -0
- package/dist/seeding/index.d.ts +2 -0
- package/dist/seeding/index.js +2 -0
- package/dist/seeding/types.d.ts +7 -0
- package/dist/seeding/types.js +1 -0
- package/dist/stack/db.d.ts +19 -0
- package/dist/stack/db.js +61 -0
- package/dist/stack/drain-event-consumers.d.ts +4 -0
- package/dist/stack/drain-event-consumers.js +48 -0
- package/dist/stack/drain-jobs.d.ts +20 -0
- package/dist/stack/drain-jobs.js +99 -0
- package/dist/stack/event-collector.d.ts +9 -0
- package/dist/stack/event-collector.js +12 -0
- package/dist/stack/index.d.ts +9 -0
- package/dist/stack/index.js +19 -0
- package/dist/stack/push-entity-projection-tables.d.ts +24 -0
- package/dist/stack/push-entity-projection-tables.js +73 -0
- package/dist/stack/redis.d.ts +11 -0
- package/dist/stack/redis.js +38 -0
- package/dist/stack/request-helper.d.ts +35 -0
- package/dist/stack/request-helper.js +144 -0
- package/dist/stack/table-helpers.d.ts +32 -0
- package/dist/stack/table-helpers.js +138 -0
- package/dist/stack/test-stack.d.ts +161 -0
- package/dist/stack/test-stack.js +398 -0
- package/dist/stack/test-users.d.ts +33 -0
- package/dist/stack/test-users.js +29 -0
- package/dist/testing/access-assertions.d.ts +2 -0
- package/dist/testing/access-assertions.js +13 -0
- package/dist/testing/assertions.d.ts +10 -0
- package/dist/testing/assertions.js +22 -0
- package/dist/testing/boot-validator-fixture.d.ts +3 -0
- package/dist/testing/boot-validator-fixture.js +101 -0
- package/dist/testing/closed-connection-error.d.ts +7 -0
- package/dist/testing/closed-connection-error.js +47 -0
- package/dist/testing/db-cleanup.d.ts +9 -0
- package/dist/testing/db-cleanup.js +31 -0
- package/dist/testing/e2e-generator.d.ts +49 -0
- package/dist/testing/e2e-generator.js +377 -0
- package/dist/testing/expect-error.d.ts +2 -0
- package/dist/testing/expect-error.js +22 -0
- package/dist/testing/file-provider-contract.d.ts +2 -0
- package/dist/testing/file-provider-contract.js +102 -0
- package/dist/testing/handler-context.d.ts +4 -0
- package/dist/testing/handler-context.js +72 -0
- package/dist/testing/http-cookies.d.ts +7 -0
- package/dist/testing/http-cookies.js +47 -0
- package/dist/testing/index.d.ts +24 -0
- package/dist/testing/index.js +32 -0
- package/dist/testing/late-bound.d.ts +9 -0
- package/dist/testing/late-bound.js +31 -0
- package/dist/testing/multipart-helper.d.ts +22 -0
- package/dist/testing/multipart-helper.js +77 -0
- package/dist/testing/mutable-master-key-provider.d.ts +7 -0
- package/dist/testing/mutable-master-key-provider.js +35 -0
- package/dist/testing/observability-recorder.d.ts +9 -0
- package/dist/testing/observability-recorder.js +29 -0
- package/dist/testing/real-providers.d.ts +3 -0
- package/dist/testing/real-providers.js +21 -0
- package/dist/testing/seed.d.ts +9 -0
- package/dist/testing/seed.js +21 -0
- package/dist/testing/shared-entities.d.ts +256 -0
- package/dist/testing/shared-entities.js +56 -0
- package/dist/testing/utils.d.ts +1 -0
- package/dist/testing/utils.js +1 -0
- package/dist/testing/wait-for.d.ts +20 -0
- package/dist/testing/wait-for.js +46 -0
- package/dist/testing/without-ambient-temporal.d.ts +5 -0
- package/dist/testing/without-ambient-temporal.js +17 -0
- package/dist/time/boot-tz-warning.d.ts +5 -0
- package/dist/time/boot-tz-warning.js +24 -0
- package/dist/time/geo-tz.js +1 -0
- package/dist/time/iana.d.ts +1 -0
- package/dist/time/iana.js +18 -0
- package/dist/time/index.d.ts +6 -0
- package/dist/time/index.js +15 -0
- package/dist/time/legacy-date.d.ts +5 -0
- package/dist/time/legacy-date.js +15 -0
- package/dist/time/polyfill.d.ts +9 -0
- package/dist/time/polyfill.js +52 -0
- package/dist/time/tz-context.d.ts +13 -0
- package/dist/time/tz-context.js +80 -0
- package/dist/ui-types/app-schema.d.ts +26 -0
- package/dist/ui-types/app-schema.js +9 -0
- package/dist/ui-types/formality.d.ts +2 -0
- package/dist/ui-types/formality.js +5 -0
- package/dist/ui-types/index.d.ts +22 -0
- package/dist/ui-types/index.js +31 -0
- package/dist/ui-types/list-row-meta.d.ts +18 -0
- package/dist/ui-types/list-row-meta.js +65 -0
- package/dist/ui-types/plural.d.ts +12 -0
- package/dist/ui-types/plural.js +57 -0
- package/dist/upgrade-cli.d.ts +11 -0
- package/dist/upgrade-cli.js +532 -0
- package/dist/utils/assert.d.ts +1 -0
- package/dist/utils/assert.js +18 -0
- package/dist/utils/case.d.ts +1 -0
- package/dist/utils/case.js +6 -0
- package/dist/utils/compare.d.ts +1 -0
- package/dist/utils/compare.js +10 -0
- package/dist/utils/env-parse.d.ts +1 -0
- package/dist/utils/env-parse.js +13 -0
- package/dist/utils/ids.d.ts +2 -0
- package/dist/utils/ids.js +23 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/is-plain-object.d.ts +2 -0
- package/dist/utils/is-plain-object.js +4 -0
- package/dist/utils/parse-string-array-json.d.ts +2 -0
- package/dist/utils/parse-string-array-json.js +11 -0
- package/dist/utils/safe-json.d.ts +17 -0
- package/dist/utils/safe-json.js +47 -0
- package/dist/utils/serialization.d.ts +1 -0
- package/dist/utils/serialization.js +13 -0
- package/package.json +274 -93
- package/src/changes.json +6 -0
- package/src/scripts/codemod/pii-personal-migration.ts +5 -5
- package/src/__tests__/anonymous-access.integration.test.ts +0 -513
- package/src/__tests__/consumer-cli.integration.test.ts +0 -172
- package/src/__tests__/derived-fields.integration.test.ts +0 -126
- package/src/__tests__/entity-list-limits.integration.test.ts +0 -84
- package/src/__tests__/entity-permalink-open.integration.test.ts +0 -99
- package/src/__tests__/error-contract.integration.test.ts +0 -436
- package/src/__tests__/field-access.integration.test.ts +0 -273
- package/src/__tests__/fixtures/migrate-cross-tenant/manual-only.expected.ts +0 -44
- package/src/__tests__/fixtures/migrate-cross-tenant/manual-only.input.ts +0 -44
- package/src/__tests__/fixtures/migrate-cross-tenant/rewrite.expected.ts +0 -41
- package/src/__tests__/fixtures/migrate-cross-tenant/rewrite.input.ts +0 -41
- package/src/__tests__/fixtures/migrate-db-raw/global-fetch.expected.ts +0 -9
- package/src/__tests__/fixtures/migrate-db-raw/global-fetch.input.ts +0 -10
- package/src/__tests__/fixtures/migrate-db-raw/global-select.expected.ts +0 -6
- package/src/__tests__/fixtures/migrate-db-raw/global-select.input.ts +0 -12
- package/src/__tests__/fixtures/migrate-db-raw/import-pruning.expected.ts +0 -12
- package/src/__tests__/fixtures/migrate-db-raw/import-pruning.input.ts +0 -12
- package/src/__tests__/fixtures/migrate-db-raw/manual-only.expected.ts +0 -26
- package/src/__tests__/fixtures/migrate-db-raw/manual-only.input.ts +0 -26
- package/src/__tests__/fixtures/migrate-db-raw/own-tenant-const-shorthand.expected.ts +0 -10
- package/src/__tests__/fixtures/migrate-db-raw/own-tenant-const-shorthand.input.ts +0 -11
- package/src/__tests__/fixtures/migrate-db-raw/own-tenant-event.expected.ts +0 -9
- package/src/__tests__/fixtures/migrate-db-raw/own-tenant-event.input.ts +0 -15
- package/src/__tests__/fixtures/migrate-open-to-all/manual-only.expected.ts +0 -16
- package/src/__tests__/fixtures/migrate-open-to-all/manual-only.input.ts +0 -16
- package/src/__tests__/fixtures/migrate-open-to-all/test-nested-shorthand.expected.ts +0 -12
- package/src/__tests__/fixtures/migrate-open-to-all/test-nested-shorthand.input.ts +0 -12
- package/src/__tests__/fixtures/migrate-open-to-all/test-simple.expected.ts +0 -7
- package/src/__tests__/fixtures/migrate-open-to-all/test-simple.input.ts +0 -7
- package/src/__tests__/full-stack.integration.test.ts +0 -924
- package/src/__tests__/migrate-cross-tenant-codemod.test.ts +0 -106
- package/src/__tests__/migrate-db-raw-codemod.test.ts +0 -132
- package/src/__tests__/migrate-open-to-all-codemod.test.ts +0 -84
- package/src/__tests__/ownership-where-write-path.integration.test.ts +0 -147
- package/src/__tests__/ownership.integration.test.ts +0 -454
- package/src/__tests__/pii-personal-migration-report-codemod.test.ts +0 -160
- package/src/__tests__/reference-data.integration.test.ts +0 -243
- package/src/__tests__/related-list-parent-filter.integration.test.ts +0 -103
- package/src/__tests__/schema-cli-kms-slots.integration.test.ts +0 -172
- package/src/__tests__/schema-cli-rebuild.integration.test.ts +0 -189
- package/src/__tests__/schema-cli-status.integration.test.ts +0 -96
- package/src/__tests__/schema-cli-temporal-polyfill.test.ts +0 -48
- package/src/__tests__/schema-cli.integration.test.ts +0 -485
- package/src/__tests__/store-table.integration.test.ts +0 -94
- package/src/__tests__/transition-guard.integration.test.ts +0 -342
- package/src/__tests__/unprocessable-error-details-reason-codemod.test.ts +0 -205
- package/src/__tests__/upgrade-cli.test.ts +0 -723
- package/src/api/__tests__/api-constants-completeness.test.ts +0 -63
- package/src/api/__tests__/api.test.ts +0 -869
- package/src/api/__tests__/auth-middleware-anonymous-access-boot.test.ts +0 -40
- package/src/api/__tests__/auth-middleware-transport.test.ts +0 -102
- package/src/api/__tests__/auth-routes-cookie.test.ts +0 -330
- package/src/api/__tests__/auth-routes-invalid-body-invite.test.ts +0 -263
- package/src/api/__tests__/auth-routes-mfa-preauth-confirm.test.ts +0 -230
- package/src/api/__tests__/auth-routes-mfa-preauth-enable-start.test.ts +0 -263
- package/src/api/__tests__/auth-routes-mfa-verify.test.ts +0 -221
- package/src/api/__tests__/auth-routes-trusted-proxy.test.ts +0 -164
- package/src/api/__tests__/batch.integration.test.ts +0 -548
- package/src/api/__tests__/body-limit.test.ts +0 -184
- package/src/api/__tests__/client-ip.test.ts +0 -184
- package/src/api/__tests__/csrf-constants-sync.test.ts +0 -20
- package/src/api/__tests__/csrf-middleware.test.ts +0 -97
- package/src/api/__tests__/dispatcher-live.integration.test.ts +0 -292
- package/src/api/__tests__/extra-route-rejection.test.ts +0 -38
- package/src/api/__tests__/extra-routes.integration.test.ts +0 -663
- package/src/api/__tests__/http-cache.test.ts +0 -173
- package/src/api/__tests__/http-route-entry.integration.test.ts +0 -114
- package/src/api/__tests__/http-route-rate-limit.integration.test.ts +0 -148
- package/src/api/__tests__/jwt.test.ts +0 -316
- package/src/api/__tests__/login-rate-limiter-sweep.test.ts +0 -50
- package/src/api/__tests__/metrics-endpoint.test.ts +0 -132
- package/src/api/__tests__/nested-write-ownership.integration.test.ts +0 -268
- package/src/api/__tests__/nested-write.integration.test.ts +0 -210
- package/src/api/__tests__/origin-middleware.integration.test.ts +0 -273
- package/src/api/__tests__/origin-middleware.test.ts +0 -279
- package/src/api/__tests__/pat-route-guard.integration.test.ts +0 -126
- package/src/api/__tests__/pat-scope.test.ts +0 -36
- package/src/api/__tests__/pii-leak-guard.integration.test.ts +0 -112
- package/src/api/__tests__/post-auth-landing.test.ts +0 -100
- package/src/api/__tests__/readiness.test.ts +0 -76
- package/src/api/__tests__/redis-login-rate-limiter.integration.test.ts +0 -138
- package/src/api/__tests__/redis-sse-broker.integration.test.ts +0 -321
- package/src/api/__tests__/request-id-middleware.test.ts +0 -229
- package/src/api/__tests__/request-locale.integration.test.ts +0 -146
- package/src/api/__tests__/schema-route.integration.test.ts +0 -157
- package/src/api/__tests__/server-boot-guards.test.ts +0 -308
- package/src/api/__tests__/server-error-logging.test.ts +0 -342
- package/src/api/__tests__/server-jwt-ttl.test.ts +0 -58
- package/src/api/__tests__/sse-broker.test.ts +0 -267
- package/src/api/__tests__/sse-route.test.ts +0 -245
- package/src/api/__tests__/stream-escape-hatch.integration.test.ts +0 -203
- package/src/api/__tests__/websocket-route.test.ts +0 -552
- package/src/api/anonymous-cookie.ts +0 -61
- package/src/api/api-constants.ts +0 -153
- package/src/api/auth-middleware.ts +0 -694
- package/src/api/auth-routes.ts +0 -1590
- package/src/api/client-ip.ts +0 -131
- package/src/api/csrf-middleware.ts +0 -74
- package/src/api/extra-route.ts +0 -178
- package/src/api/http-cache.ts +0 -122
- package/src/api/index.ts +0 -117
- package/src/api/jwt.ts +0 -277
- package/src/api/observability-middleware.ts +0 -89
- package/src/api/origin-middleware.ts +0 -137
- package/src/api/pat-route-guard.ts +0 -51
- package/src/api/pat-scope.ts +0 -14
- package/src/api/pii-leak-guard.ts +0 -46
- package/src/api/post-auth-landing.ts +0 -105
- package/src/api/readiness.ts +0 -132
- package/src/api/redis-sse-broker.ts +0 -171
- package/src/api/request-context.ts +0 -137
- package/src/api/request-id-middleware.ts +0 -138
- package/src/api/route-registrars.ts +0 -193
- package/src/api/routes.ts +0 -432
- package/src/api/server.ts +0 -1550
- package/src/api/sse-broker.ts +0 -175
- package/src/api/sse-route.ts +0 -74
- package/src/api/tokens.ts +0 -16
- package/src/api/websocket-route.ts +0 -327
- package/src/arg-parser.ts +0 -66
- package/src/auth/__tests__/roles.test.ts +0 -24
- package/src/auth/index.ts +0 -7
- package/src/auth/roles.ts +0 -42
- package/src/bun-db/__tests__/PATTERN.md +0 -72
- package/src/bun-db/__tests__/_helpers.ts +0 -104
- package/src/bun-db/__tests__/batch-methods.integration.test.ts +0 -143
- package/src/bun-db/__tests__/batch-methods.test.ts +0 -21
- package/src/bun-db/__tests__/bun-test-db.ts +0 -19
- package/src/bun-db/__tests__/closed-connection-retry.integration.test.ts +0 -252
- package/src/bun-db/__tests__/coerce-row-plain-date.test.ts +0 -70
- package/src/bun-db/__tests__/coerce-row-temporal.test.ts +0 -41
- package/src/bun-db/__tests__/column-types.integration.test.ts +0 -132
- package/src/bun-db/__tests__/compound-types.integration.test.ts +0 -134
- package/src/bun-db/__tests__/decimal-field.integration.test.ts +0 -81
- package/src/bun-db/__tests__/extract-table-info.test.ts +0 -71
- package/src/bun-db/__tests__/jsonb-edge-cases.integration.test.ts +0 -235
- package/src/bun-db/__tests__/postgres-closed-socket-write.integration.test.ts +0 -87
- package/src/bun-db/__tests__/query-guards.test.ts +0 -111
- package/src/bun-db/__tests__/run-in-savepoint-if-supported.integration.test.ts +0 -47
- package/src/bun-db/__tests__/select-many-retry.integration.test.ts +0 -138
- package/src/bun-db/__tests__/smoke.integration.test.ts +0 -43
- package/src/bun-db/__tests__/sql-expr-brand.test.ts +0 -115
- package/src/bun-db/__tests__/sql-methods.integration.test.ts +0 -231
- package/src/bun-db/__tests__/where-patterns.integration.test.ts +0 -213
- package/src/bun-db/__tests__/write-brand.test.ts +0 -72
- package/src/bun-db/connection.ts +0 -87
- package/src/bun-db/index.ts +0 -36
- package/src/bun-db/query.ts +0 -1394
- package/src/compliance/__tests__/duration-spec.test.ts +0 -72
- package/src/compliance/__tests__/profiles.test.ts +0 -308
- package/src/compliance/__tests__/sub-processors.test.ts +0 -149
- package/src/compliance/duration-spec.ts +0 -44
- package/src/compliance/index.ts +0 -31
- package/src/compliance/override-schema.ts +0 -136
- package/src/compliance/profiles.ts +0 -424
- package/src/compliance/sub-processors.ts +0 -165
- package/src/consumer-cli.ts +0 -134
- package/src/crypto/__tests__/blind-index.test.ts +0 -132
- package/src/crypto/__tests__/event-pii.test.ts +0 -417
- package/src/crypto/__tests__/kek-rotation.integration.test.ts +0 -180
- package/src/crypto/__tests__/kek-source.test.ts +0 -441
- package/src/crypto/__tests__/kms-adapter-contract.ts +0 -134
- package/src/crypto/__tests__/kms-adapter.contract.test.ts +0 -4
- package/src/crypto/__tests__/kms-wiring.test.ts +0 -203
- package/src/crypto/__tests__/pg-kms-adapter.integration.test.ts +0 -154
- package/src/crypto/__tests__/pii-field-encryption.test.ts +0 -403
- package/src/crypto/__tests__/request-kms-cache.test.ts +0 -74
- package/src/crypto/__tests__/subject-id-schema.test.ts +0 -60
- package/src/crypto/__tests__/subject-key-record.test.ts +0 -109
- package/src/crypto/__tests__/subject-resolver.test.ts +0 -250
- package/src/crypto/__tests__/system-event-pii.test.ts +0 -77
- package/src/crypto/blind-index.ts +0 -118
- package/src/crypto/ciphertext-pattern.ts +0 -19
- package/src/crypto/event-pii.ts +0 -99
- package/src/crypto/in-memory-kms-adapter.ts +0 -50
- package/src/crypto/index.ts +0 -84
- package/src/crypto/is-self-pii-field.ts +0 -8
- package/src/crypto/kek-source.ts +0 -180
- package/src/crypto/kms-adapter.ts +0 -51
- package/src/crypto/kms-wiring.ts +0 -208
- package/src/crypto/pg-kms-adapter.ts +0 -303
- package/src/crypto/pii-field-encryption.ts +0 -266
- package/src/crypto/request-kms-cache.ts +0 -38
- package/src/crypto/subject-resolver.ts +0 -232
- package/src/crypto/system-event-pii.ts +0 -57
- package/src/db/__tests__/apply-entity-event-removed-column.integration.test.ts +0 -109
- package/src/db/__tests__/apply-entity-event-tenant.integration.test.ts +0 -159
- package/src/db/__tests__/assert-exists-in.integration.test.ts +0 -120
- package/src/db/__tests__/assert-no-unreachable-live-rows.integration.test.ts +0 -190
- package/src/db/__tests__/big-int-field.test.ts +0 -132
- package/src/db/__tests__/blind-index.integration.test.ts +0 -280
- package/src/db/__tests__/build-filter-where.test.ts +0 -50
- package/src/db/__tests__/collect-table-metas.test.ts +0 -188
- package/src/db/__tests__/column-ddl.integration.test.ts +0 -122
- package/src/db/__tests__/compound-types.test.ts +0 -126
- package/src/db/__tests__/config-seed.integration.test.ts +0 -292
- package/src/db/__tests__/connection-close-outage.integration.test.ts +0 -110
- package/src/db/__tests__/connection-options.test.ts +0 -68
- package/src/db/__tests__/cursor.test.ts +0 -42
- package/src/db/__tests__/decimal-field.test.ts +0 -109
- package/src/db/__tests__/dialect-instant.test.ts +0 -47
- package/src/db/__tests__/eagerload.integration.test.ts +0 -374
- package/src/db/__tests__/entity-field-encryption.test.ts +0 -74
- package/src/db/__tests__/entity-table-from-registry.test.ts +0 -79
- package/src/db/__tests__/entity-table-meta-source.test.ts +0 -92
- package/src/db/__tests__/entity-table-types.test.ts +0 -162
- package/src/db/__tests__/event-store-executor-context.pii-roundtrip.test.ts +0 -67
- package/src/db/__tests__/event-store-executor-global-tenancy.integration.test.ts +0 -73
- package/src/db/__tests__/event-store-executor-list.integration.test.ts +0 -791
- package/src/db/__tests__/event-store-executor-money-rehydrate.integration.test.ts +0 -153
- package/src/db/__tests__/event-store-executor-reference-search.integration.test.ts +0 -643
- package/src/db/__tests__/event-store-executor-reference-sort.integration.test.ts +0 -256
- package/src/db/__tests__/event-store-executor-write-verbs.integration.test.ts +0 -788
- package/src/db/__tests__/event-store-executor.integration.test.ts +0 -844
- package/src/db/__tests__/event-store-system-stream.integration.test.ts +0 -96
- package/src/db/__tests__/feature-table-sources.test.ts +0 -34
- package/src/db/__tests__/implicit-projection-equivalence.integration.test.ts +0 -393
- package/src/db/__tests__/instant-to-driver-temporal.test.ts +0 -21
- package/src/db/__tests__/list-filter-field-access.integration.test.ts +0 -218
- package/src/db/__tests__/list-pagination.test.ts +0 -28
- package/src/db/__tests__/list-row-meta-drift.test.ts +0 -15
- package/src/db/__tests__/located-timestamp.test.ts +0 -203
- package/src/db/__tests__/managed-recreate.integration.test.ts +0 -78
- package/src/db/__tests__/migrate-generator.test.ts +0 -383
- package/src/db/__tests__/migrate-runner.test.ts +0 -118
- package/src/db/__tests__/money.test.ts +0 -291
- package/src/db/__tests__/multi-row-insert.integration.test.ts +0 -88
- package/src/db/__tests__/number-field-fractional.integration.test.ts +0 -58
- package/src/db/__tests__/parent-ref-clause.test.ts +0 -213
- package/src/db/__tests__/parse-auto-verb.test.ts +0 -70
- package/src/db/__tests__/pg-error.test.ts +0 -57
- package/src/db/__tests__/rebuild-marker.test.ts +0 -180
- package/src/db/__tests__/replay-migration-sql.test.ts +0 -401
- package/src/db/__tests__/required-not-null-migration-safety.integration.test.ts +0 -109
- package/src/db/__tests__/run-in-own-transaction.integration.test.ts +0 -166
- package/src/db/__tests__/schema-inspection.test.ts +0 -27
- package/src/db/__tests__/schema-migration.integration.test.ts +0 -354
- package/src/db/__tests__/source-shadow-create.integration.test.ts +0 -59
- package/src/db/__tests__/system-db-view-export.test.ts +0 -107
- package/src/db/__tests__/table-builder-indexes.test.ts +0 -189
- package/src/db/__tests__/table-builder-meta-lockstep.test.ts +0 -224
- package/src/db/__tests__/table-builder-required.test.ts +0 -214
- package/src/db/__tests__/tenant-db-convention-cross-tenant.test.ts +0 -72
- package/src/db/__tests__/tenant-db-count.integration.test.ts +0 -92
- package/src/db/__tests__/tenant-db-declared-unsafe-raw.test.ts +0 -163
- package/src/db/__tests__/tenant-db-global.integration.test.ts +0 -134
- package/src/db/__tests__/tenant-db-global.test.ts +0 -352
- package/src/db/__tests__/tenant-db-no-raw.test.ts +0 -85
- package/src/db/__tests__/tenant-db-where-merge.integration.test.ts +0 -123
- package/src/db/__tests__/tenant-db-where-merge.test.ts +0 -164
- package/src/db/__tests__/tenant-db.integration.test.ts +0 -575
- package/src/db/__tests__/unchecked-system-db.test.ts +0 -259
- package/src/db/__tests__/unique-violation-mapping.integration.test.ts +0 -200
- package/src/db/__tests__/with-systemdb-unsafe-raw-grant.test.ts +0 -71
- package/src/db/api.ts +0 -52
- package/src/db/apply-entity-event.ts +0 -211
- package/src/db/assert-exists-in.ts +0 -52
- package/src/db/blind-index-cleanup.ts +0 -145
- package/src/db/bun-provider.ts +0 -42
- package/src/db/collect-table-metas.ts +0 -98
- package/src/db/compound-types.ts +0 -47
- package/src/db/config-seed.ts +0 -104
- package/src/db/connection.ts +0 -57
- package/src/db/cursor.ts +0 -47
- package/src/db/dialect.ts +0 -544
- package/src/db/eagerload.ts +0 -260
- package/src/db/entity-field-encryption.ts +0 -158
- package/src/db/entity-table-from-registry.ts +0 -31
- package/src/db/entity-table-meta-types.ts +0 -2
- package/src/db/entity-table-meta.ts +0 -491
- package/src/db/event-store-executor-context.ts +0 -510
- package/src/db/event-store-executor-read.ts +0 -916
- package/src/db/event-store-executor-write.ts +0 -920
- package/src/db/event-store-executor.ts +0 -50
- package/src/db/feature-table-sources.ts +0 -35
- package/src/db/index.ts +0 -162
- package/src/db/located-timestamp.ts +0 -118
- package/src/db/migrate-generator.ts +0 -549
- package/src/db/migrate-runner.ts +0 -348
- package/src/db/money.ts +0 -211
- package/src/db/parent-ref-clause.ts +0 -182
- package/src/db/pg-error.ts +0 -74
- package/src/db/postgres-provider.ts +0 -28
- package/src/db/queries/__tests__/event-store-idempotency-index.integration.test.ts +0 -78
- package/src/db/queries/__tests__/shadow-swap.test.ts +0 -43
- package/src/db/queries/__tests__/unsafe-read-retrying.integration.test.ts +0 -115
- package/src/db/queries/advisory-lock.ts +0 -11
- package/src/db/queries/backfill-pii.ts +0 -578
- package/src/db/queries/ddl.ts +0 -45
- package/src/db/queries/entity-read.ts +0 -15
- package/src/db/queries/es-ops.ts +0 -17
- package/src/db/queries/event-consumer.ts +0 -418
- package/src/db/queries/event-store-admin.ts +0 -130
- package/src/db/queries/event-store-transfer.ts +0 -73
- package/src/db/queries/event-store.ts +0 -354
- package/src/db/queries/pii-backfill-state.ts +0 -33
- package/src/db/queries/projection-rebuild.ts +0 -104
- package/src/db/queries/raw-sql.ts +0 -28
- package/src/db/queries/seed-context.ts +0 -62
- package/src/db/queries/shadow-swap.ts +0 -378
- package/src/db/queries/table-ops.ts +0 -11
- package/src/db/queries/test-stack.ts +0 -32
- package/src/db/query-api.ts +0 -24
- package/src/db/query.ts +0 -35
- package/src/db/rebuild-marker.ts +0 -103
- package/src/db/reference-data.ts +0 -73
- package/src/db/render-ddl.ts +0 -57
- package/src/db/replay-migration-sql.ts +0 -257
- package/src/db/schema-inspection.ts +0 -81
- package/src/db/table-builder.ts +0 -692
- package/src/db/tenant-db-runner.ts +0 -23
- package/src/db/tenant-db.ts +0 -727
- package/src/derivatives/__tests__/derivatives-context.integration.test.ts +0 -231
- package/src/derivatives/__tests__/derivatives-context.test.ts +0 -369
- package/src/derivatives/__tests__/field-variants.test.ts +0 -62
- package/src/derivatives/__tests__/variant-key.test.ts +0 -183
- package/src/derivatives/__tests__/variant-route.integration.test.ts +0 -268
- package/src/derivatives/delete-stored-file.ts +0 -86
- package/src/derivatives/derivatives-context.ts +0 -314
- package/src/derivatives/field-variants.ts +0 -20
- package/src/derivatives/index.ts +0 -14
- package/src/derivatives/variant-key.ts +0 -108
- package/src/engine/__tests__/_pipeline-test-utils.ts +0 -23
- package/src/engine/__tests__/auth-claims-registrar.test.ts +0 -74
- package/src/engine/__tests__/boot-validator-action-wiring.test.ts +0 -362
- package/src/engine/__tests__/boot-validator-api-exposure.test.ts +0 -142
- package/src/engine/__tests__/boot-validator-boot-check.test.ts +0 -104
- package/src/engine/__tests__/boot-validator-dashboard.test.ts +0 -381
- package/src/engine/__tests__/boot-validator-detail-for.test.ts +0 -106
- package/src/engine/__tests__/boot-validator-entity-list.test.ts +0 -120
- package/src/engine/__tests__/boot-validator-gdpr-storage.test.ts +0 -85
- package/src/engine/__tests__/boot-validator-i18n-keys.test.ts +0 -153
- package/src/engine/__tests__/boot-validator-located-timestamps.test.ts +0 -92
- package/src/engine/__tests__/boot-validator-nav-area.test.ts +0 -116
- package/src/engine/__tests__/boot-validator-pii-retention.test.ts +0 -994
- package/src/engine/__tests__/boot-validator-projection-list.test.ts +0 -629
- package/src/engine/__tests__/boot-validator-query-output-schema.test.ts +0 -578
- package/src/engine/__tests__/boot-validator-query-refs.test.ts +0 -151
- package/src/engine/__tests__/boot-validator-ref-entity.test.ts +0 -196
- package/src/engine/__tests__/boot-validator-s0-integration.test.ts +0 -172
- package/src/engine/__tests__/boot-validator.test.ts +0 -5984
- package/src/engine/__tests__/build-app-schema-settings-hub.test.ts +0 -246
- package/src/engine/__tests__/build-app-schema-url-prefill.test.ts +0 -222
- package/src/engine/__tests__/build-app-schema.test.ts +0 -1167
- package/src/engine/__tests__/build-config-feature-schema-extension-selector.test.ts +0 -395
- package/src/engine/__tests__/build-config-feature-schema-secrets.test.ts +0 -188
- package/src/engine/__tests__/build-config-feature-schema.test.ts +0 -511
- package/src/engine/__tests__/build-target.test.ts +0 -127
- package/src/engine/__tests__/changeset-changes.test.ts +0 -64
- package/src/engine/__tests__/claim-keys.test.ts +0 -274
- package/src/engine/__tests__/codemod-pipeline.test.ts +0 -682
- package/src/engine/__tests__/config-helpers.test.ts +0 -309
- package/src/engine/__tests__/content-collection.test.ts +0 -307
- package/src/engine/__tests__/decimal-field.test.ts +0 -59
- package/src/engine/__tests__/dedupe-features.test.ts +0 -85
- package/src/engine/__tests__/define-feature-entity-mapping.test.ts +0 -53
- package/src/engine/__tests__/define-roles.test.ts +0 -21
- package/src/engine/__tests__/define-workflow.test.ts +0 -79
- package/src/engine/__tests__/describe-workflow-step-error.test.ts +0 -17
- package/src/engine/__tests__/duration-utils.test.ts +0 -16
- package/src/engine/__tests__/effective-features.test.ts +0 -86
- package/src/engine/__tests__/embedded-derived.test.ts +0 -35
- package/src/engine/__tests__/engine.test.ts +0 -2406
- package/src/engine/__tests__/entity-create-caller-id.integration.test.ts +0 -87
- package/src/engine/__tests__/entity-exclude-fields.integration.test.ts +0 -134
- package/src/engine/__tests__/entity-handlers-escape-hatch.test.ts +0 -91
- package/src/engine/__tests__/entity-handlers.test.ts +0 -562
- package/src/engine/__tests__/entity-presave-wiring.integration.test.ts +0 -153
- package/src/engine/__tests__/entity-restore-tenant-isolation.integration.test.ts +0 -168
- package/src/engine/__tests__/entity-write-crosstenant.integration.test.ts +0 -317
- package/src/engine/__tests__/event-helpers.test.ts +0 -68
- package/src/engine/__tests__/event-migration-declarative.test.ts +0 -67
- package/src/engine/__tests__/event-type-map-augmentation.test.ts +0 -24
- package/src/engine/__tests__/extend-entity-projection.test.ts +0 -133
- package/src/engine/__tests__/extends-registrar.test.ts +0 -279
- package/src/engine/__tests__/factories-long-text.test.ts +0 -95
- package/src/engine/__tests__/factories-number-unit.test.ts +0 -23
- package/src/engine/__tests__/factories-personal.test.ts +0 -216
- package/src/engine/__tests__/factories-time.test.ts +0 -94
- package/src/engine/__tests__/feature-crud-shorthand.test.ts +0 -73
- package/src/engine/__tests__/feature-crud-verb-access.integration.test.ts +0 -83
- package/src/engine/__tests__/feature-manifest.test.ts +0 -137
- package/src/engine/__tests__/field-access.test.ts +0 -65
- package/src/engine/__tests__/field-predicates.test.ts +0 -48
- package/src/engine/__tests__/form-money-currency-types.test.ts +0 -90
- package/src/engine/__tests__/hook-identity-switch-grant.test.ts +0 -188
- package/src/engine/__tests__/hook-phases.test.ts +0 -172
- package/src/engine/__tests__/http-route-anonymous-required.test.ts +0 -43
- package/src/engine/__tests__/identifiers.test.ts +0 -35
- package/src/engine/__tests__/lifecycle-hooks.test.ts +0 -243
- package/src/engine/__tests__/membership-roles.test.ts +0 -67
- package/src/engine/__tests__/metric-navigate-tab.test.ts +0 -167
- package/src/engine/__tests__/multiselect-filter.integration.test.ts +0 -141
- package/src/engine/__tests__/nav.test.ts +0 -497
- package/src/engine/__tests__/no-return-guard.test.ts +0 -17
- package/src/engine/__tests__/ownership.test.ts +0 -475
- package/src/engine/__tests__/parse-ref-target.test.ts +0 -43
- package/src/engine/__tests__/pipeline-engine.test.ts +0 -215
- package/src/engine/__tests__/pipeline-handler.integration.test.ts +0 -880
- package/src/engine/__tests__/pipeline-observability.integration.test.ts +0 -142
- package/src/engine/__tests__/pipeline-performance.integration.test.ts +0 -152
- package/src/engine/__tests__/pipeline-sub-pipelines.test.ts +0 -288
- package/src/engine/__tests__/post-query-hook.test.ts +0 -144
- package/src/engine/__tests__/project-app-schema-for-roles.test.ts +0 -500
- package/src/engine/__tests__/projection-detail-actions.test.ts +0 -145
- package/src/engine/__tests__/projection-detail-singleton.test.ts +0 -86
- package/src/engine/__tests__/projection-detail-tabs.test.ts +0 -314
- package/src/engine/__tests__/projection-helpers.test.ts +0 -75
- package/src/engine/__tests__/projection-list-filter.integration.test.ts +0 -115
- package/src/engine/__tests__/projection.test.ts +0 -191
- package/src/engine/__tests__/qualified-name.test.ts +0 -306
- package/src/engine/__tests__/read-steps-tenant-filter.integration.test.ts +0 -215
- package/src/engine/__tests__/registrar-object-form.test.ts +0 -141
- package/src/engine/__tests__/registry.test.ts +0 -326
- package/src/engine/__tests__/required-surface-keys.test.ts +0 -477
- package/src/engine/__tests__/resolve-config-or-param.test.ts +0 -315
- package/src/engine/__tests__/role-assignment.test.ts +0 -71
- package/src/engine/__tests__/row-action-navigate-tab.test.ts +0 -107
- package/src/engine/__tests__/run-in.test.ts +0 -38
- package/src/engine/__tests__/schema-builder-date-bounds.test.ts +0 -47
- package/src/engine/__tests__/schema-builder.test.ts +0 -1211
- package/src/engine/__tests__/screen-definition-exports.test.ts +0 -102
- package/src/engine/__tests__/screen-filter-ops.test.ts +0 -31
- package/src/engine/__tests__/screen-helpers.test.ts +0 -52
- package/src/engine/__tests__/screen.test.ts +0 -1684
- package/src/engine/__tests__/search-payload-extension.test.ts +0 -288
- package/src/engine/__tests__/soft-delete-cleanup-job-tenant-db.integration.test.ts +0 -82
- package/src/engine/__tests__/soft-delete-cleanup.test.ts +0 -167
- package/src/engine/__tests__/state-machine.test.ts +0 -148
- package/src/engine/__tests__/steps-aggregate-append-event.test.ts +0 -115
- package/src/engine/__tests__/steps-aggregate-create.test.ts +0 -92
- package/src/engine/__tests__/steps-aggregate-update.test.ts +0 -127
- package/src/engine/__tests__/steps-call-feature.test.ts +0 -123
- package/src/engine/__tests__/steps-mail-send.test.ts +0 -137
- package/src/engine/__tests__/steps-read.test.ts +0 -332
- package/src/engine/__tests__/steps-resolver-utils.test.ts +0 -50
- package/src/engine/__tests__/steps-unsafe-projection-delete.test.ts +0 -77
- package/src/engine/__tests__/steps-unsafe-projection-upsert.test.ts +0 -131
- package/src/engine/__tests__/steps-webhook-send.test.ts +0 -143
- package/src/engine/__tests__/steps-workflow.test.ts +0 -353
- package/src/engine/__tests__/store-table.test.ts +0 -247
- package/src/engine/__tests__/system-user.test.ts +0 -57
- package/src/engine/__tests__/tier-resolver-extension.test.ts +0 -69
- package/src/engine/__tests__/toolbar-navigate-tab.test.ts +0 -233
- package/src/engine/__tests__/tree-actions-patterns.test.ts +0 -163
- package/src/engine/__tests__/validate-custom-screen-write-qns.test.ts +0 -43
- package/src/engine/__tests__/validate-projection-allowlist.test.ts +0 -498
- package/src/engine/__tests__/validation-hooks.test.ts +0 -77
- package/src/engine/__tests__/where-rule-lint.test.ts +0 -79
- package/src/engine/__tests__/write-handler-qn-extract.test.ts +0 -50
- package/src/engine/access.ts +0 -27
- package/src/engine/active-membership.ts +0 -70
- package/src/engine/boot-validator/__tests__/access-declarations.test.ts +0 -707
- package/src/engine/boot-validator/__tests__/access-roles.test.ts +0 -84
- package/src/engine/boot-validator/__tests__/action-icon.test.ts +0 -81
- package/src/engine/boot-validator/__tests__/anonymous-rate-limit-required.test.ts +0 -63
- package/src/engine/boot-validator/__tests__/config-deps.test.ts +0 -92
- package/src/engine/boot-validator/__tests__/global-tenancy.test.ts +0 -73
- package/src/engine/boot-validator/__tests__/i18n-keys.test.ts +0 -340
- package/src/engine/boot-validator/__tests__/nav.test.ts +0 -290
- package/src/engine/boot-validator/__tests__/no-all-role-in-handler-access.test.ts +0 -77
- package/src/engine/boot-validator/__tests__/ownership.test.ts +0 -87
- package/src/engine/boot-validator/__tests__/parent-ref.test.ts +0 -161
- package/src/engine/boot-validator/__tests__/rate-limit-disabled-reason.test.ts +0 -45
- package/src/engine/boot-validator/__tests__/record-owned.test.ts +0 -65
- package/src/engine/boot-validator/__tests__/security-baseline.test.ts +0 -107
- package/src/engine/boot-validator/__tests__/transfer-graph.test.ts +0 -138
- package/src/engine/boot-validator/access-declarations.ts +0 -211
- package/src/engine/boot-validator/access-roles.ts +0 -85
- package/src/engine/boot-validator/action-wiring.ts +0 -163
- package/src/engine/boot-validator/api-ext.ts +0 -81
- package/src/engine/boot-validator/boot-check.ts +0 -21
- package/src/engine/boot-validator/config-deps.ts +0 -246
- package/src/engine/boot-validator/custom-screen-write-qns.ts +0 -87
- package/src/engine/boot-validator/detail-screens.ts +0 -49
- package/src/engine/boot-validator/entity-handler.ts +0 -1011
- package/src/engine/boot-validator/entity-list-screens.ts +0 -100
- package/src/engine/boot-validator/gdpr-storage.ts +0 -59
- package/src/engine/boot-validator/global-tenancy.ts +0 -29
- package/src/engine/boot-validator/i18n-keys.ts +0 -101
- package/src/engine/boot-validator/index.ts +0 -301
- package/src/engine/boot-validator/nav.ts +0 -241
- package/src/engine/boot-validator/ownership.ts +0 -352
- package/src/engine/boot-validator/parent-ref.ts +0 -96
- package/src/engine/boot-validator/pii-retention.ts +0 -272
- package/src/engine/boot-validator/projection-list-screens.ts +0 -293
- package/src/engine/boot-validator/query-output-columns.ts +0 -273
- package/src/engine/boot-validator/query-refs.ts +0 -141
- package/src/engine/boot-validator/record-owned.ts +0 -21
- package/src/engine/boot-validator/screens.ts +0 -2604
- package/src/engine/boot-validator/security-baseline.ts +0 -26
- package/src/engine/boot-validator/transfer-graph.ts +0 -135
- package/src/engine/boot-validator/url-prefill-fields.ts +0 -178
- package/src/engine/boot-validator/workspaces.ts +0 -106
- package/src/engine/boot-validator/zod-shape.ts +0 -142
- package/src/engine/boot-validator.ts +0 -8
- package/src/engine/build-app-schema.ts +0 -542
- package/src/engine/build-config-feature-schema.ts +0 -815
- package/src/engine/build-target.ts +0 -99
- package/src/engine/changeset-changes.ts +0 -117
- package/src/engine/codemod/index.ts +0 -15
- package/src/engine/codemod/pipeline-codemod.ts +0 -641
- package/src/engine/config-helpers.ts +0 -217
- package/src/engine/constants.ts +0 -117
- package/src/engine/create-app.ts +0 -177
- package/src/engine/cross-tenant.test.ts +0 -32
- package/src/engine/cross-tenant.ts +0 -22
- package/src/engine/dedupe-features.ts +0 -46
- package/src/engine/define-feature.ts +0 -169
- package/src/engine/define-handler.ts +0 -194
- package/src/engine/define-roles.ts +0 -19
- package/src/engine/define-step.ts +0 -28
- package/src/engine/define-workflow.ts +0 -147
- package/src/engine/effective-features.ts +0 -97
- package/src/engine/embedded-derived.ts +0 -93
- package/src/engine/entity-handlers.ts +0 -782
- package/src/engine/escape-hatch-declaration.ts +0 -7
- package/src/engine/event-helpers.ts +0 -73
- package/src/engine/extension-names.ts +0 -242
- package/src/engine/extension-selector-plugins.ts +0 -24
- package/src/engine/extensions/__tests__/hook-ctx-db-tenant-scoped.test.ts +0 -76
- package/src/engine/extensions/escape-hatch-usage.ts +0 -16
- package/src/engine/extensions/storage-provider.ts +0 -16
- package/src/engine/extensions/tenant-data.ts +0 -34
- package/src/engine/extensions/tenant-resource.ts +0 -40
- package/src/engine/extensions/user-data.ts +0 -181
- package/src/engine/factories.ts +0 -559
- package/src/engine/feature-ast/__tests__/canonical-form.test.ts +0 -416
- package/src/engine/feature-ast/__tests__/fixtures/cross-file-name-const/constants.ts +0 -1
- package/src/engine/feature-ast/__tests__/fixtures/cross-file-name-const/feature.ts +0 -8
- package/src/engine/feature-ast/__tests__/fixtures/cross-file-patch-const/constants.ts +0 -2
- package/src/engine/feature-ast/__tests__/fixtures/cross-file-patch-const/feature.ts +0 -8
- package/src/engine/feature-ast/__tests__/fixtures/cross-file-registrar/feature.ts +0 -9
- package/src/engine/feature-ast/__tests__/fixtures/cross-file-registrar/screens.ts +0 -4
- package/src/engine/feature-ast/__tests__/fixtures/resolve-import/alias-reexport.ts +0 -1
- package/src/engine/feature-ast/__tests__/fixtures/resolve-import/cycle-a.ts +0 -1
- package/src/engine/feature-ast/__tests__/fixtures/resolve-import/cycle-b.ts +0 -1
- package/src/engine/feature-ast/__tests__/fixtures/resolve-import/entry.ts +0 -3
- package/src/engine/feature-ast/__tests__/fixtures/resolve-import/local-rebind.ts +0 -3
- package/src/engine/feature-ast/__tests__/fixtures/resolve-import/origin.ts +0 -1
- package/src/engine/feature-ast/__tests__/fixtures/resolve-import/star-barrel.ts +0 -1
- package/src/engine/feature-ast/__tests__/handler-header-roundtrip.test.ts +0 -669
- package/src/engine/feature-ast/__tests__/parse-happy-path.test.ts +0 -196
- package/src/engine/feature-ast/__tests__/parse-real-features.test.ts +0 -138
- package/src/engine/feature-ast/__tests__/parse.test.ts +0 -2841
- package/src/engine/feature-ast/__tests__/patch-update.test.ts +0 -718
- package/src/engine/feature-ast/__tests__/patch.test.ts +0 -780
- package/src/engine/feature-ast/__tests__/patcher.test.ts +0 -468
- package/src/engine/feature-ast/__tests__/pattern-change-schema.test.ts +0 -819
- package/src/engine/feature-ast/__tests__/read-optional-access-rule.test.ts +0 -42
- package/src/engine/feature-ast/__tests__/render-roundtrip.test.ts +0 -947
- package/src/engine/feature-ast/__tests__/resolve-import.test.ts +0 -138
- package/src/engine/feature-ast/entity-field-types.ts +0 -41
- package/src/engine/feature-ast/extractors/ai-steps.ts +0 -352
- package/src/engine/feature-ast/extractors/events.ts +0 -349
- package/src/engine/feature-ast/extractors/handlers.ts +0 -459
- package/src/engine/feature-ast/extractors/hooks.ts +0 -331
- package/src/engine/feature-ast/extractors/index.ts +0 -92
- package/src/engine/feature-ast/extractors/jobs-routes.ts +0 -225
- package/src/engine/feature-ast/extractors/projections-screens.ts +0 -269
- package/src/engine/feature-ast/extractors/resolve-import.ts +0 -187
- package/src/engine/feature-ast/extractors/round1.ts +0 -150
- package/src/engine/feature-ast/extractors/round2.ts +0 -276
- package/src/engine/feature-ast/extractors/round3.ts +0 -474
- package/src/engine/feature-ast/extractors/round5.ts +0 -114
- package/src/engine/feature-ast/extractors/round6.ts +0 -32
- package/src/engine/feature-ast/extractors/shared.ts +0 -356
- package/src/engine/feature-ast/index.ts +0 -113
- package/src/engine/feature-ast/parse.ts +0 -615
- package/src/engine/feature-ast/patch.ts +0 -979
- package/src/engine/feature-ast/patcher.ts +0 -546
- package/src/engine/feature-ast/pattern-change-schema.ts +0 -1411
- package/src/engine/feature-ast/patterns.ts +0 -803
- package/src/engine/feature-ast/render.ts +0 -767
- package/src/engine/feature-ast/source-location.ts +0 -45
- package/src/engine/feature-builder-state.ts +0 -174
- package/src/engine/feature-changelog.ts +0 -95
- package/src/engine/feature-config-events-jobs.ts +0 -472
- package/src/engine/feature-entity-handlers.ts +0 -269
- package/src/engine/feature-manifest.ts +0 -173
- package/src/engine/feature-ui-extensions.ts +0 -648
- package/src/engine/field-access.ts +0 -140
- package/src/engine/field-helpers.ts +0 -35
- package/src/engine/handler-helpers.ts +0 -26
- package/src/engine/hook-helpers.ts +0 -16
- package/src/engine/i18n-key.ts +0 -12
- package/src/engine/index.ts +0 -585
- package/src/engine/instruction-fields.ts +0 -11
- package/src/engine/membership-roles.ts +0 -61
- package/src/engine/object-form.ts +0 -27
- package/src/engine/ownership.ts +0 -404
- package/src/engine/parse-ref-target.ts +0 -28
- package/src/engine/pattern-library/__tests__/library.test.ts +0 -399
- package/src/engine/pattern-library/index.ts +0 -24
- package/src/engine/pattern-library/library.ts +0 -140
- package/src/engine/pattern-library/mixed-schemas.ts +0 -588
- package/src/engine/pattern-library/opaque-schemas.ts +0 -124
- package/src/engine/pattern-library/shared-fields.ts +0 -79
- package/src/engine/pattern-library/static-schemas.ts +0 -456
- package/src/engine/pattern-library/types.ts +0 -255
- package/src/engine/personal-data-fields.ts +0 -66
- package/src/engine/pipeline.ts +0 -111
- package/src/engine/project-app-schema-for-roles.ts +0 -950
- package/src/engine/projection-helpers.ts +0 -79
- package/src/engine/qualified-name.ts +0 -165
- package/src/engine/read-claim.ts +0 -31
- package/src/engine/registry-facade.ts +0 -381
- package/src/engine/registry-ingest.ts +0 -479
- package/src/engine/registry-state.ts +0 -410
- package/src/engine/registry-validate.ts +0 -810
- package/src/engine/registry.ts +0 -94
- package/src/engine/resolve-config-or-param.ts +0 -157
- package/src/engine/role-assignment.ts +0 -63
- package/src/engine/run-in.ts +0 -29
- package/src/engine/run-pipeline.ts +0 -162
- package/src/engine/schema-builder.ts +0 -428
- package/src/engine/screen-filter-ops.ts +0 -60
- package/src/engine/screen-helpers.ts +0 -161
- package/src/engine/soft-delete-cleanup.ts +0 -126
- package/src/engine/state-machine.ts +0 -71
- package/src/engine/steps/__tests__/duration-utils.test.ts +0 -20
- package/src/engine/steps/_duration-utils.ts +0 -35
- package/src/engine/steps/_event-match.ts +0 -98
- package/src/engine/steps/_no-return-guard.ts +0 -21
- package/src/engine/steps/_read-source.ts +0 -12
- package/src/engine/steps/_resolver-utils.ts +0 -42
- package/src/engine/steps/_step-dispatch-constants.ts +0 -38
- package/src/engine/steps/aggregate-append-event.ts +0 -56
- package/src/engine/steps/aggregate-create.ts +0 -56
- package/src/engine/steps/aggregate-update.ts +0 -68
- package/src/engine/steps/branch.ts +0 -84
- package/src/engine/steps/call-feature.ts +0 -49
- package/src/engine/steps/compute.ts +0 -41
- package/src/engine/steps/describe-workflow-step-error.ts +0 -6
- package/src/engine/steps/for-each.ts +0 -111
- package/src/engine/steps/mail-send.ts +0 -48
- package/src/engine/steps/read-find-many.ts +0 -57
- package/src/engine/steps/read-find-one.ts +0 -59
- package/src/engine/steps/retry.ts +0 -99
- package/src/engine/steps/return.ts +0 -35
- package/src/engine/steps/unsafe-projection-delete.ts +0 -50
- package/src/engine/steps/unsafe-projection-upsert.ts +0 -88
- package/src/engine/steps/wait-for-event.ts +0 -90
- package/src/engine/steps/wait.ts +0 -69
- package/src/engine/steps/webhook-send.ts +0 -63
- package/src/engine/system-user.ts +0 -38
- package/src/engine/tier-resolver-extension.ts +0 -107
- package/src/engine/types/config.ts +0 -2
- package/src/engine/types/define-handler.ts +0 -2
- package/src/engine/types/entity-handlers.ts +0 -2
- package/src/engine/types/feature.ts +0 -2
- package/src/engine/types/fields.ts +0 -2
- package/src/engine/types/handlers.ts +0 -3
- package/src/engine/types/hooks.ts +0 -2
- package/src/engine/types/index.ts +0 -394
- package/src/engine/types/nav.ts +0 -2
- package/src/engine/types/ownership.ts +0 -2
- package/src/engine/types/projection.ts +0 -2
- package/src/engine/types/screen.ts +0 -3
- package/src/engine/types/step.ts +0 -2
- package/src/engine/types/workspace.ts +0 -2
- package/src/engine/validate-projection-allowlist.ts +0 -191
- package/src/engine/validation.ts +0 -33
- package/src/engine/where-rule-lint.ts +0 -196
- package/src/engine/write-handler-qn-extract.ts +0 -47
- package/src/entrypoint/__tests__/entrypoint-attach-dispatcher.integration.test.ts +0 -140
- package/src/entrypoint/__tests__/entrypoint-job-wiring.integration.test.ts +0 -292
- package/src/entrypoint/__tests__/split-deploy.integration.test.ts +0 -467
- package/src/entrypoint/index.ts +0 -541
- package/src/env/__tests__/compose-env-schema.test.ts +0 -410
- package/src/env/__tests__/dry-run.test.ts +0 -161
- package/src/env/__tests__/parse-env-dry-run.test.ts +0 -40
- package/src/env/_zod-introspect.ts +0 -51
- package/src/env/dry-run.ts +0 -204
- package/src/env/index.ts +0 -435
- package/src/errors/__tests__/classes.test.ts +0 -442
- package/src/errors/__tests__/error-helpers.test.ts +0 -58
- package/src/errors/__tests__/reason-i18n.test.ts +0 -46
- package/src/errors/__tests__/write-failures.test.ts +0 -167
- package/src/errors/classes.ts +0 -311
- package/src/errors/field-issue.ts +0 -8
- package/src/errors/i18n/de.yaml +0 -244
- package/src/errors/i18n/en.yaml +0 -234
- package/src/errors/index.ts +0 -47
- package/src/errors/kumiko-error.ts +0 -67
- package/src/errors/member-resolution.ts +0 -12
- package/src/errors/reasons.ts +0 -102
- package/src/errors/serialize.ts +0 -136
- package/src/errors/to-kumiko-error.ts +0 -8
- package/src/errors/transition-details.ts +0 -30
- package/src/errors/write-error-info.ts +0 -124
- package/src/errors/zod-bridge.ts +0 -62
- package/src/es-ops/README.md +0 -179
- package/src/es-ops/__tests__/context.integration.test.ts +0 -378
- package/src/es-ops/__tests__/runner.integration.test.ts +0 -483
- package/src/es-ops/__tests__/runner.test.ts +0 -202
- package/src/es-ops/context.ts +0 -98
- package/src/es-ops/index.ts +0 -34
- package/src/es-ops/operations-schema.ts +0 -57
- package/src/es-ops/runner.ts +0 -253
- package/src/es-ops/types.ts +0 -124
- package/src/event-store/__tests__/admin-api.integration.test.ts +0 -412
- package/src/event-store/__tests__/backfill-pii.integration.test.ts +0 -880
- package/src/event-store/__tests__/event-attribution.integration.test.ts +0 -236
- package/src/event-store/__tests__/event-store.integration.test.ts +0 -932
- package/src/event-store/__tests__/get-stream-version-perf.integration.test.ts +0 -87
- package/src/event-store/__tests__/perf.integration.test.ts +0 -283
- package/src/event-store/__tests__/provenance-append.integration.test.ts +0 -140
- package/src/event-store/__tests__/row-to-stored-event.test.ts +0 -68
- package/src/event-store/__tests__/snapshot.integration.test.ts +0 -328
- package/src/event-store/__tests__/transfer.integration.test.ts +0 -236
- package/src/event-store/__tests__/unscoped-stream-primitives.guard.test.ts +0 -62
- package/src/event-store/__tests__/upcaster-dead-letter.integration.test.ts +0 -202
- package/src/event-store/__tests__/upcaster.integration.test.ts +0 -491
- package/src/event-store/admin-api.ts +0 -241
- package/src/event-store/archive.ts +0 -83
- package/src/event-store/errors.ts +0 -58
- package/src/event-store/event-store.ts +0 -449
- package/src/event-store/events-schema.ts +0 -89
- package/src/event-store/index.ts +0 -80
- package/src/event-store/provenance-append.ts +0 -67
- package/src/event-store/rebuild-dead-letter.ts +0 -111
- package/src/event-store/row-to-stored-event.ts +0 -34
- package/src/event-store/snapshot.ts +0 -235
- package/src/event-store/transfer.ts +0 -84
- package/src/event-store/types.ts +0 -2
- package/src/event-store/upcaster-dead-letter.ts +0 -120
- package/src/event-store/upcaster.ts +0 -147
- package/src/files/__tests__/build-storage-key.test.ts +0 -28
- package/src/files/__tests__/content-disposition.test.ts +0 -123
- package/src/files/__tests__/file-field-pipeline.integration.test.ts +0 -229
- package/src/files/__tests__/file-handle.test.ts +0 -175
- package/src/files/__tests__/file-ref-entity.test.ts +0 -42
- package/src/files/__tests__/files.integration.test.ts +0 -1749
- package/src/files/__tests__/in-memory-provider.contract.test.ts +0 -4
- package/src/files/__tests__/in-memory-provider.test.ts +0 -94
- package/src/files/__tests__/local-provider.contract.test.ts +0 -14
- package/src/files/__tests__/local-provider.test.ts +0 -31
- package/src/files/__tests__/provider-resolver.test.ts +0 -70
- package/src/files/__tests__/read-stream.test.ts +0 -105
- package/src/files/__tests__/storage-tracking.integration.test.ts +0 -238
- package/src/files/__tests__/storage-tracking.test.ts +0 -46
- package/src/files/__tests__/write-stream.test.ts +0 -250
- package/src/files/__tests__/zip-stream.test.ts +0 -357
- package/src/files/content-disposition.ts +0 -55
- package/src/files/feature.ts +0 -44
- package/src/files/file-handle.ts +0 -83
- package/src/files/file-ref-entity.ts +0 -33
- package/src/files/file-ref-table.ts +0 -13
- package/src/files/file-routes.ts +0 -579
- package/src/files/in-memory-provider.ts +0 -113
- package/src/files/index.ts +0 -57
- package/src/files/local-provider.ts +0 -132
- package/src/files/provider-resolver.ts +0 -176
- package/src/files/storage-tracking.ts +0 -245
- package/src/files/types.ts +0 -336
- package/src/files/zip-stream.ts +0 -251
- package/src/http/index.ts +0 -10
- package/src/i18n/__tests__/i18n.test.ts +0 -113
- package/src/i18n/__tests__/mail-registry.test.ts +0 -54
- package/src/i18n/__tests__/request-locale.test.ts +0 -19
- package/src/i18n/__tests__/required-surface-keys.test.ts +0 -17
- package/src/i18n/index.ts +0 -51
- package/src/i18n/mail-registry.ts +0 -42
- package/src/i18n/request-locale.ts +0 -72
- package/src/i18n/required-surface-keys.ts +0 -459
- package/src/i18n/settings-hub-keys.ts +0 -31
- package/src/jobs/__tests__/job-attempt-context.integration.test.ts +0 -76
- package/src/jobs/__tests__/job-backoff.integration.test.ts +0 -147
- package/src/jobs/__tests__/job-event-trigger.integration.test.ts +0 -175
- package/src/jobs/__tests__/job-last-success.integration.test.ts +0 -135
- package/src/jobs/__tests__/job-multi-trigger.integration.test.ts +0 -147
- package/src/jobs/__tests__/job-public-intake-origin.integration.test.ts +0 -536
- package/src/jobs/__tests__/job-queue-depth.integration.test.ts +0 -82
- package/src/jobs/__tests__/job-retention.integration.test.ts +0 -316
- package/src/jobs/__tests__/job-retry-enqueue-paths.integration.test.ts +0 -309
- package/src/jobs/__tests__/job-runner-boot-timeout.test.ts +0 -55
- package/src/jobs/__tests__/job-systemdb.integration.test.ts +0 -153
- package/src/jobs/__tests__/job-tenant-db.integration.test.ts +0 -162
- package/src/jobs/__tests__/job-write-as.integration.test.ts +0 -251
- package/src/jobs/__tests__/jobs.integration.test.ts +0 -1563
- package/src/jobs/__tests__/scheduler-id.test.ts +0 -30
- package/src/jobs/index.ts +0 -8
- package/src/jobs/job-runner.ts +0 -1390
- package/src/lifecycle/__tests__/create-test-lifecycle.ts +0 -19
- package/src/lifecycle/__tests__/lifecycle-server.integration.test.ts +0 -108
- package/src/lifecycle/__tests__/lifecycle.test.ts +0 -212
- package/src/lifecycle/__tests__/signal-handlers.test.ts +0 -98
- package/src/lifecycle/index.ts +0 -13
- package/src/lifecycle/lifecycle.ts +0 -157
- package/src/lifecycle/signal-handlers.ts +0 -64
- package/src/logging/__tests__/fallback-logger.test.ts +0 -90
- package/src/logging/__tests__/pino-trace-bridge.test.ts +0 -50
- package/src/logging/index.ts +0 -4
- package/src/logging/pino-logger.ts +0 -68
- package/src/logging/utils.ts +0 -50
- package/src/migrations/__tests__/kumiko-drift.integration.test.ts +0 -238
- package/src/migrations/__tests__/kumiko-drift.report.test.ts +0 -105
- package/src/migrations/__tests__/pending-rebuilds.integration.test.ts +0 -412
- package/src/migrations/__tests__/pii-event-backfill.integration.test.ts +0 -457
- package/src/migrations/index.ts +0 -36
- package/src/migrations/kumiko-drift.ts +0 -187
- package/src/migrations/pending-rebuilds.ts +0 -251
- package/src/migrations/pii-event-backfill.ts +0 -422
- package/src/migrations/projection-table-index.ts +0 -23
- package/src/observability/__tests__/console-provider.test.ts +0 -67
- package/src/observability/__tests__/escape-hatch-report.test.ts +0 -149
- package/src/observability/__tests__/metric-validator.test.ts +0 -95
- package/src/observability/__tests__/metrics-handle.test.ts +0 -30
- package/src/observability/__tests__/metrics-wiring.test.ts +0 -61
- package/src/observability/__tests__/noop-provider.test.ts +0 -82
- package/src/observability/__tests__/observability.integration.test.ts +0 -639
- package/src/observability/__tests__/prometheus-meter.test.ts +0 -144
- package/src/observability/__tests__/recording-meter.test.ts +0 -101
- package/src/observability/__tests__/recording-tracer.test.ts +0 -112
- package/src/observability/__tests__/sensitive-filter.test.ts +0 -98
- package/src/observability/console-provider.ts +0 -130
- package/src/observability/context.ts +0 -26
- package/src/observability/escape-hatch-report.ts +0 -129
- package/src/observability/fallback.ts +0 -34
- package/src/observability/ids.ts +0 -25
- package/src/observability/index.ts +0 -88
- package/src/observability/metric-validator.ts +0 -98
- package/src/observability/metrics-handle.ts +0 -105
- package/src/observability/metrics-wiring.ts +0 -32
- package/src/observability/noop-provider.ts +0 -137
- package/src/observability/prometheus-meter.ts +0 -286
- package/src/observability/recording-meter.ts +0 -156
- package/src/observability/recording-tracer.ts +0 -186
- package/src/observability/redis-wrapper.ts +0 -132
- package/src/observability/sensitive-filter.ts +0 -108
- package/src/observability/standard-metrics.ts +0 -295
- package/src/pipeline/__tests__/archive-stream.integration.test.ts +0 -299
- package/src/pipeline/__tests__/auth-claims-resolver.test.ts +0 -279
- package/src/pipeline/__tests__/blind-index-rebuild-guard.integration.test.ts +0 -94
- package/src/pipeline/__tests__/cascade-handler.integration.test.ts +0 -435
- package/src/pipeline/__tests__/cascade-handler.test.ts +0 -67
- package/src/pipeline/__tests__/causation-chain.integration.test.ts +0 -207
- package/src/pipeline/__tests__/ctx-bridge.integration.test.ts +0 -507
- package/src/pipeline/__tests__/ctx-systemdb.integration.test.ts +0 -120
- package/src/pipeline/__tests__/dispatcher-utils.test.ts +0 -132
- package/src/pipeline/__tests__/dispatcher.test.ts +0 -1091
- package/src/pipeline/__tests__/distributed-lock.integration.test.ts +0 -110
- package/src/pipeline/__tests__/domain-events-projections.integration.test.ts +0 -323
- package/src/pipeline/__tests__/escape-hatch-audit.integration.test.ts +0 -254
- package/src/pipeline/__tests__/escape-hatch.integration.test.ts +0 -90
- package/src/pipeline/__tests__/event-consumer-state.integration.test.ts +0 -81
- package/src/pipeline/__tests__/event-dedup.integration.test.ts +0 -153
- package/src/pipeline/__tests__/event-define-event-strict.integration.test.ts +0 -196
- package/src/pipeline/__tests__/event-dispatcher-batch-delivery.test.ts +0 -178
- package/src/pipeline/__tests__/event-dispatcher-batch-handler.integration.test.ts +0 -143
- package/src/pipeline/__tests__/event-dispatcher-commit-order.integration.test.ts +0 -278
- package/src/pipeline/__tests__/event-dispatcher-db-outage.integration.test.ts +0 -224
- package/src/pipeline/__tests__/event-dispatcher-delivery-max-attempts.test.ts +0 -127
- package/src/pipeline/__tests__/event-dispatcher-idle.integration.test.ts +0 -94
- package/src/pipeline/__tests__/event-dispatcher-lifecycle.integration.test.ts +0 -209
- package/src/pipeline/__tests__/event-dispatcher-multi-instance.integration.test.ts +0 -424
- package/src/pipeline/__tests__/event-dispatcher-pass-failure.integration.test.ts +0 -266
- package/src/pipeline/__tests__/event-dispatcher-per-consumer-turns.integration.test.ts +0 -126
- package/src/pipeline/__tests__/event-dispatcher-pg-listen.integration.test.ts +0 -106
- package/src/pipeline/__tests__/event-dispatcher-rearm.integration.test.ts +0 -263
- package/src/pipeline/__tests__/event-dispatcher-recovery.integration.test.ts +0 -202
- package/src/pipeline/__tests__/event-dispatcher-second-audit.integration.test.ts +0 -282
- package/src/pipeline/__tests__/event-dispatcher-start-from.integration.test.ts +0 -276
- package/src/pipeline/__tests__/event-dispatcher-strict.test.ts +0 -67
- package/src/pipeline/__tests__/event-dispatcher.integration.test.ts +0 -290
- package/src/pipeline/__tests__/event-retention.integration.test.ts +0 -242
- package/src/pipeline/__tests__/fetch-for-writing.integration.test.ts +0 -364
- package/src/pipeline/__tests__/hook-systemdb-escape-hatch.integration.test.ts +0 -246
- package/src/pipeline/__tests__/idempotency-transient-failure.integration.test.ts +0 -198
- package/src/pipeline/__tests__/instruction-field-gate.integration.test.ts +0 -213
- package/src/pipeline/__tests__/irreversible-operation-gate.integration.test.ts +0 -249
- package/src/pipeline/__tests__/job-trigger-consumer.integration.test.ts +0 -235
- package/src/pipeline/__tests__/lifecycle-pipeline.test.ts +0 -800
- package/src/pipeline/__tests__/load-aggregate-query.integration.test.ts +0 -281
- package/src/pipeline/__tests__/member-resolution-read-only.test.ts +0 -79
- package/src/pipeline/__tests__/msp-error-mode.integration.test.ts +0 -149
- package/src/pipeline/__tests__/msp-multi-hop.integration.test.ts +0 -231
- package/src/pipeline/__tests__/msp-rebuild.integration.test.ts +0 -510
- package/src/pipeline/__tests__/multi-stream-projection.integration.test.ts +0 -313
- package/src/pipeline/__tests__/pending-gap-ranges.test.ts +0 -94
- package/src/pipeline/__tests__/perf-rebuild.integration.test.ts +0 -147
- package/src/pipeline/__tests__/post-query-hook.integration.test.ts +0 -165
- package/src/pipeline/__tests__/projection-rebuild.integration.test.ts +0 -1033
- package/src/pipeline/__tests__/projections-runner-systemscope.integration.test.ts +0 -101
- package/src/pipeline/__tests__/public-intake-runtime-gate.integration.test.ts +0 -684
- package/src/pipeline/__tests__/query-projection.integration.test.ts +0 -357
- package/src/pipeline/__tests__/rate-limit-default.integration.test.ts +0 -118
- package/src/pipeline/__tests__/rate-limit-default.test.ts +0 -117
- package/src/pipeline/__tests__/rebuild-poison-quarantine.integration.test.ts +0 -275
- package/src/pipeline/__tests__/redis-keys.test.ts +0 -12
- package/src/pipeline/__tests__/redis-pipeline.integration.test.ts +0 -490
- package/src/pipeline/__tests__/search-consumer-named-events.integration.test.ts +0 -274
- package/src/pipeline/__tests__/system-identity-switch.integration.test.ts +0 -583
- package/src/pipeline/__tests__/system-identity-switch.test.ts +0 -645
- package/src/pipeline/__tests__/tenant-timezone-cache.test.ts +0 -89
- package/src/pipeline/__tests__/try-append-event.integration.test.ts +0 -168
- package/src/pipeline/__tests__/unsafe-raw-escape-hatch.integration.test.ts +0 -103
- package/src/pipeline/active-membership.ts +0 -190
- package/src/pipeline/append-event-core.ts +0 -117
- package/src/pipeline/auth-claims-resolver.ts +0 -103
- package/src/pipeline/cascade-handler.ts +0 -109
- package/src/pipeline/dispatch-batch.ts +0 -269
- package/src/pipeline/dispatch-query.ts +0 -195
- package/src/pipeline/dispatch-shared.ts +0 -1242
- package/src/pipeline/dispatch-stream.ts +0 -129
- package/src/pipeline/dispatch-write.ts +0 -599
- package/src/pipeline/dispatcher-utils.ts +0 -199
- package/src/pipeline/dispatcher.ts +0 -278
- package/src/pipeline/distributed-lock.ts +0 -66
- package/src/pipeline/entity-cache.ts +0 -82
- package/src/pipeline/event-consumer-state.ts +0 -190
- package/src/pipeline/event-dedup.ts +0 -23
- package/src/pipeline/event-dispatcher-admin.ts +0 -320
- package/src/pipeline/event-dispatcher-delivery.ts +0 -499
- package/src/pipeline/event-dispatcher.ts +0 -817
- package/src/pipeline/event-retention.ts +0 -144
- package/src/pipeline/idempotency.ts +0 -158
- package/src/pipeline/index.ts +0 -83
- package/src/pipeline/irreversible-operation-gate.ts +0 -76
- package/src/pipeline/lifecycle-pipeline.ts +0 -421
- package/src/pipeline/member-read-only-transaction.ts +0 -71
- package/src/pipeline/member-reader.ts +0 -110
- package/src/pipeline/msp-rebuild.ts +0 -312
- package/src/pipeline/multi-stream-apply-context.ts +0 -85
- package/src/pipeline/pending-gap-ranges.ts +0 -120
- package/src/pipeline/projection-rebuild.ts +0 -539
- package/src/pipeline/projection-state.ts +0 -60
- package/src/pipeline/projections-runner.ts +0 -66
- package/src/pipeline/redis-keys.ts +0 -11
- package/src/pipeline/system-hooks.ts +0 -695
- package/src/pipeline/system-identity-switch.ts +0 -401
- package/src/pipeline/tenant-timezone-cache.ts +0 -92
- package/src/pipeline/write-origin.ts +0 -128
- package/src/random/__tests__/generate.test.ts +0 -149
- package/src/random/__tests__/words.test.ts +0 -44
- package/src/random/generate.ts +0 -141
- package/src/random/index.ts +0 -8
- package/src/random/words.ts +0 -393
- package/src/rate-limit/__tests__/dispatcher-l3.integration.test.ts +0 -111
- package/src/rate-limit/__tests__/middleware.integration.test.ts +0 -246
- package/src/rate-limit/__tests__/resolver.integration.test.ts +0 -211
- package/src/rate-limit/bucket.ts +0 -36
- package/src/rate-limit/index.ts +0 -14
- package/src/rate-limit/middleware.ts +0 -179
- package/src/rate-limit/resolver.ts +0 -251
- package/src/redis/__tests__/redis-options.test.ts +0 -54
- package/src/redis/client.ts +0 -77
- package/src/redis/index.ts +0 -4
- package/src/redis/pubsub-signal.ts +0 -107
- package/src/schema-cli.ts +0 -510
- package/src/search/__tests__/derive-search-adapter-config.test.ts +0 -65
- package/src/search/__tests__/meilisearch-adapter.integration.test.ts +0 -413
- package/src/search/__tests__/meilisearch-ids.test.ts +0 -30
- package/src/search/__tests__/reindex-entity.integration.test.ts +0 -243
- package/src/search/__tests__/search-adapter.test.ts +0 -271
- package/src/search/__tests__/search-consumer-batch.integration.test.ts +0 -306
- package/src/search/__tests__/search-pii-derived-index.integration.test.ts +0 -208
- package/src/search/derive-search-adapter-config.ts +0 -27
- package/src/search/in-memory-adapter.ts +0 -129
- package/src/search/index.ts +0 -20
- package/src/search/meilisearch-adapter.ts +0 -213
- package/src/search/purge-subject.ts +0 -253
- package/src/search/reindex-entity.ts +0 -190
- package/src/secrets/__tests__/contains-secret.test.ts +0 -108
- package/src/secrets/__tests__/dek-cache.test.ts +0 -211
- package/src/secrets/__tests__/derive-purpose-secret.test.ts +0 -52
- package/src/secrets/__tests__/env-master-key-provider.test.ts +0 -119
- package/src/secrets/__tests__/envelope-cipher.test.ts +0 -59
- package/src/secrets/__tests__/envelope.test.ts +0 -74
- package/src/secrets/__tests__/leak-guard.test.ts +0 -104
- package/src/secrets/__tests__/rotation.test.ts +0 -149
- package/src/secrets/dek-cache.ts +0 -137
- package/src/secrets/derive-purpose-secret.ts +0 -17
- package/src/secrets/env-master-key-provider.ts +0 -162
- package/src/secrets/envelope-cipher.ts +0 -53
- package/src/secrets/envelope.ts +0 -57
- package/src/secrets/index.ts +0 -33
- package/src/secrets/leak-guard.ts +0 -87
- package/src/secrets/rotation.ts +0 -34
- package/src/secrets/stored-envelope.ts +0 -46
- package/src/seeding/__tests__/entity-seed.test.ts +0 -70
- package/src/seeding/entity-seed.ts +0 -31
- package/src/seeding/index.ts +0 -6
- package/src/seeding/types.ts +0 -8
- package/src/stack/__tests__/drain-event-consumers.integration.test.ts +0 -166
- package/src/stack/__tests__/drain-jobs.integration.test.ts +0 -159
- package/src/stack/__tests__/event-collector.test.ts +0 -42
- package/src/stack/__tests__/ownership-boot-guard.integration.test.ts +0 -108
- package/src/stack/__tests__/push-entity-projection-tables-column-sync.integration.test.ts +0 -107
- package/src/stack/__tests__/request-helper.integration.test.ts +0 -140
- package/src/stack/__tests__/request-helper.test.ts +0 -159
- package/src/stack/__tests__/setup-test-stack-entity-tables.integration.test.ts +0 -65
- package/src/stack/__tests__/setup-test-stack-jobs.integration.test.ts +0 -185
- package/src/stack/__tests__/setup-test-stack-metrics.integration.test.ts +0 -79
- package/src/stack/db.ts +0 -82
- package/src/stack/drain-event-consumers.ts +0 -74
- package/src/stack/drain-jobs.ts +0 -129
- package/src/stack/event-collector.ts +0 -23
- package/src/stack/index.ts +0 -34
- package/src/stack/push-entity-projection-tables.ts +0 -95
- package/src/stack/redis.ts +0 -55
- package/src/stack/request-helper.ts +0 -298
- package/src/stack/table-helpers.ts +0 -175
- package/src/stack/test-stack.ts +0 -620
- package/src/stack/test-users.ts +0 -37
- package/src/testing/__tests__/db-cleanup.test.ts +0 -40
- package/src/testing/__tests__/e2e-generator.test.ts +0 -349
- package/src/testing/__tests__/ensure-entity-table.integration.test.ts +0 -52
- package/src/testing/__tests__/late-bound.test.ts +0 -32
- package/src/testing/__tests__/multipart-helper.test.ts +0 -49
- package/src/testing/__tests__/real-providers.test.ts +0 -62
- package/src/testing/__tests__/wait-for.test.ts +0 -104
- package/src/testing/access-assertions.ts +0 -15
- package/src/testing/assertions.ts +0 -35
- package/src/testing/boot-validator-fixture.ts +0 -124
- package/src/testing/closed-connection-error.ts +0 -62
- package/src/testing/db-cleanup.ts +0 -45
- package/src/testing/e2e-generator.ts +0 -494
- package/src/testing/expect-error.ts +0 -25
- package/src/testing/file-provider-contract.ts +0 -123
- package/src/testing/handler-context.ts +0 -143
- package/src/testing/http-cookies.ts +0 -52
- package/src/testing/index.ts +0 -60
- package/src/testing/late-bound.ts +0 -41
- package/src/testing/multipart-helper.ts +0 -94
- package/src/testing/mutable-master-key-provider.ts +0 -57
- package/src/testing/observability-recorder.ts +0 -54
- package/src/testing/real-providers.ts +0 -30
- package/src/testing/seed.ts +0 -50
- package/src/testing/shared-entities.ts +0 -65
- package/src/testing/utils.ts +0 -1
- package/src/testing/wait-for.ts +0 -49
- package/src/testing/without-ambient-temporal.ts +0 -14
- package/src/time/__tests__/boot-tz-warning.test.ts +0 -46
- package/src/time/__tests__/geo-tz.test.ts +0 -71
- package/src/time/__tests__/iana.test.ts +0 -35
- package/src/time/__tests__/polyfill-reinstall.test.ts +0 -17
- package/src/time/__tests__/polyfill.test.ts +0 -73
- package/src/time/__tests__/tz-context.test.ts +0 -121
- package/src/time/__tests__/tz-dateline.test.ts +0 -34
- package/src/time/boot-tz-warning.ts +0 -30
- package/src/time/iana.ts +0 -19
- package/src/time/index.ts +0 -23
- package/src/time/legacy-date.ts +0 -18
- package/src/time/polyfill.ts +0 -59
- package/src/time/tz-context.ts +0 -100
- package/src/ui-types/__tests__/plural.test.ts +0 -108
- package/src/ui-types/app-schema.ts +0 -91
- package/src/ui-types/formality.ts +0 -7
- package/src/ui-types/index.ts +0 -159
- package/src/ui-types/list-row-meta.ts +0 -87
- package/src/ui-types/plural.ts +0 -69
- package/src/upgrade-cli.ts +0 -651
- package/src/utils/__tests__/assert.test.ts +0 -17
- package/src/utils/__tests__/case.test.ts +0 -16
- package/src/utils/__tests__/compare.test.ts +0 -20
- package/src/utils/__tests__/env-parse.test.ts +0 -54
- package/src/utils/__tests__/ids.test.ts +0 -52
- package/src/utils/__tests__/is-plain-object.test.ts +0 -16
- package/src/utils/__tests__/parse-string-array-json.test.ts +0 -16
- package/src/utils/__tests__/safe-json-temporal.test.ts +0 -28
- package/src/utils/__tests__/safe-json.test.ts +0 -22
- package/src/utils/__tests__/serialization.test.ts +0 -30
- package/src/utils/assert.ts +0 -18
- package/src/utils/case.ts +0 -6
- package/src/utils/compare.ts +0 -10
- package/src/utils/env-parse.ts +0 -16
- package/src/utils/ids.ts +0 -26
- package/src/utils/index.ts +0 -9
- package/src/utils/is-plain-object.ts +0 -4
- package/src/utils/parse-string-array-json.ts +0 -14
- package/src/utils/safe-json.ts +0 -50
- package/src/utils/serialization.ts +0 -14
- /package/{src/engine/types/event-type-map.ts → dist/engine/types/event-type-map.d.ts} +0 -0
- /package/{src/engine/types/extension-options-map.ts → dist/engine/types/extension-options-map.d.ts} +0 -0
- /package/{src/engine/types/http-route.ts → dist/engine/types/http-route.d.ts} +0 -0
- /package/{src/engine/types/identifiers.ts → dist/engine/types/identifiers.d.ts} +0 -0
- /package/{src/engine/types/relations.ts → dist/engine/types/relations.d.ts} +0 -0
- /package/{src/engine/types/target-ref.ts → dist/engine/types/target-ref.d.ts} +0 -0
- /package/{src/engine/types/tree-node.ts → dist/engine/types/tree-node.d.ts} +0 -0
- /package/{src/logging/types.ts → dist/logging/types.d.ts} +0 -0
- /package/{src/observability/types/index.ts → dist/observability/types/index.d.ts} +0 -0
- /package/{src/observability/types/metric.ts → dist/observability/types/metric.d.ts} +0 -0
- /package/{src/observability/types/provider.ts → dist/observability/types/provider.d.ts} +0 -0
- /package/{src/observability/types/span.ts → dist/observability/types/span.d.ts} +0 -0
- /package/{src/search/types.ts → dist/search/types.d.ts} +0 -0
- /package/{src/secrets/types.ts → dist/secrets/types.js} +0 -0
- /package/{src/time/geo-tz.ts → dist/time/geo-tz.d.ts} +0 -0
|
@@ -0,0 +1,1145 @@
|
|
|
1
|
+
// Typed query API over Bun.sql. No drizzle internally. Same signature as the
|
|
2
|
+
// legacy `db/query-api.ts` — app-code migration is just an import-path swap,
|
|
3
|
+
// not a call-site refactor.
|
|
4
|
+
//
|
|
5
|
+
// API:
|
|
6
|
+
// selectMany<T>(db, table, where?, opts?) → readonly T[]
|
|
7
|
+
// fetchOne<T>(db, table, where) → T | undefined
|
|
8
|
+
// insertOne<T>(db, table, values) → T | undefined
|
|
9
|
+
// updateMany<T>(db, table, set, where) → readonly T[]
|
|
10
|
+
// deleteMany(db, table, where) → void
|
|
11
|
+
// countWhere(db, table, where?) → number
|
|
12
|
+
// upsertByPk / upsertOnConflict / incrementCounter
|
|
13
|
+
// deleteManyBatched(db, table, where, { limit }) → { deleted, batches }
|
|
14
|
+
// transaction<T>(db, fn) → T
|
|
15
|
+
//
|
|
16
|
+
// `table` can be either:
|
|
17
|
+
// - EntityTableMeta (preferred, plain data)
|
|
18
|
+
// - drizzle pgTable (legacy, has Symbol-based tableName) — extracted via
|
|
19
|
+
// drizzle's getTableName + getTableColumns (drizzle kept only as a type
|
|
20
|
+
// reference, never as a runtime API call)
|
|
21
|
+
import { KUMIKO_META_SYMBOL } from "@cosmicdrift/kumiko-types/schema-table-types";
|
|
22
|
+
// Static polyfill import (not getTemporal()): coercion results stay on one
|
|
23
|
+
// Temporal implementation repo-wide, even when Bun exposes a global (#1480).
|
|
24
|
+
import { Temporal } from "temporal-polyfill";
|
|
25
|
+
import { requestContext } from "../api/request-context.js";
|
|
26
|
+
import { computeBlindIndex, configuredBlindIndexKey } from "../crypto/blind-index.js";
|
|
27
|
+
import { SQL_EXPR_BRAND } from "../db/dialect.js";
|
|
28
|
+
import { extractPgError } from "../db/pg-error.js";
|
|
29
|
+
import { toSnakeCase } from "../db/table-builder.js";
|
|
30
|
+
import { camelCase as envCamelCase } from "../env/index.js";
|
|
31
|
+
import { InternalError } from "../errors/index.js";
|
|
32
|
+
import { createFallbackLogger } from "../logging/index.js";
|
|
33
|
+
import { parseJsonSafe } from "../utils/safe-json.js";
|
|
34
|
+
// Idempotent snake_case → camelCase. `env.camelCase` always lowercases first
|
|
35
|
+
// (designed for SHOUT_CASE input) — for already-camelCase keys (mock rows
|
|
36
|
+
// in tests, projection-aliased columns) it would silently produce "tenantid"
|
|
37
|
+
// instead of leaving "tenantId" alone. Guard with an underscore check so
|
|
38
|
+
// the conversion only fires when the key is actually snake-shaped.
|
|
39
|
+
function snakeToCamel(key) {
|
|
40
|
+
if (!key.includes("_"))
|
|
41
|
+
return key;
|
|
42
|
+
return envCamelCase(key);
|
|
43
|
+
}
|
|
44
|
+
// Drizzle pgTable inspection via raw Symbol access (no drizzle-orm import).
|
|
45
|
+
// table() (dialect) stores the canonical, shadow-proof EntityTableMeta under
|
|
46
|
+
// `Symbol.for("kumiko:schema:Meta")`. The column handles on the table object are
|
|
47
|
+
// enumerable props, so an entity field named `source`/`columns`/`tableName`/…
|
|
48
|
+
// would overwrite the matching meta key — reading the meta from the symbol is
|
|
49
|
+
// the only collision-safe path.
|
|
50
|
+
function isEntityTableMeta(v) {
|
|
51
|
+
return (v !== null &&
|
|
52
|
+
typeof v === "object" &&
|
|
53
|
+
typeof v.tableName === "string" &&
|
|
54
|
+
Array.isArray(v.columns) &&
|
|
55
|
+
Array.isArray(v.indexes) &&
|
|
56
|
+
(v.source === "managed" || v.source === "unmanaged"));
|
|
57
|
+
}
|
|
58
|
+
// Resolve any framework table input to its canonical EntityTableMeta:
|
|
59
|
+
// - table()/buildEntityTable outputs carry it under KUMIKO_META_SYMBOL, immune
|
|
60
|
+
// to a column-handle shadowing a meta key.
|
|
61
|
+
// - deriveEntityTableMeta / defineUnmanagedTable return a plain meta with no
|
|
62
|
+
// handle-spread, so its structural shape is itself unshadowable.
|
|
63
|
+
export function asEntityTableMeta(table) {
|
|
64
|
+
if (table === null || typeof table !== "object")
|
|
65
|
+
return undefined;
|
|
66
|
+
const fromSymbol = table[KUMIKO_META_SYMBOL];
|
|
67
|
+
if (isEntityTableMeta(fromSymbol))
|
|
68
|
+
return fromSymbol;
|
|
69
|
+
return isEntityTableMeta(table) ? table : undefined;
|
|
70
|
+
}
|
|
71
|
+
export function asRawClient(db) {
|
|
72
|
+
const dbAny = db;
|
|
73
|
+
// Direct: Bun.SQL / postgres-js Sql / postgres-js TransactionSql. All three
|
|
74
|
+
// expose `.unsafe`; only Sql/Bun.SQL have `.begin` — TransactionSql uses
|
|
75
|
+
// `.savepoint` for nested-tx. We only require `.unsafe` here; callers that
|
|
76
|
+
// need `.begin` (e.g. `transaction()`) verify it themselves.
|
|
77
|
+
if (typeof dbAny["unsafe"] === "function") {
|
|
78
|
+
return dbAny;
|
|
79
|
+
}
|
|
80
|
+
// TenantDb (ctx.db) has no unfiltered escape via asRawClient anymore — fail
|
|
81
|
+
// closed instead of silently unwrapping a tenant-scoped handle.
|
|
82
|
+
if (isTenantDbShape(db)) {
|
|
83
|
+
throw new Error("asRawClient: received a tenant-scoped TenantDb (ctx.db). Raw SQL helpers do not apply the " +
|
|
84
|
+
"tenant filter — use a ctx.db.<method>, or ctx.db.unsafeRaw(reason) with escapeHatch: " +
|
|
85
|
+
"{ reason } on the handler/hook (r.systemScope() features: ctx.systemDb.unsafeRaw(reason)).");
|
|
86
|
+
}
|
|
87
|
+
// Drizzle DbConnection (legacy compat): $client = postgres-js Sql.
|
|
88
|
+
const $client = dbAny["$client"];
|
|
89
|
+
if ($client && typeof $client["unsafe"] === "function") {
|
|
90
|
+
return $client;
|
|
91
|
+
}
|
|
92
|
+
// Drizzle pg-transaction (legacy compat): session.client = postgres-js Sql.
|
|
93
|
+
const session = dbAny["session"];
|
|
94
|
+
const sessionClient = session?.["client"];
|
|
95
|
+
if (sessionClient && typeof sessionClient["unsafe"] === "function") {
|
|
96
|
+
return sessionClient;
|
|
97
|
+
}
|
|
98
|
+
throw new Error("bun-db: db argument has no .unsafe() — pass Bun.SQL, postgres-js Sql, or a transaction handle.");
|
|
99
|
+
}
|
|
100
|
+
// postgres.js / Bun.SQL reject the WHOLE begin() when any statement inside
|
|
101
|
+
// it errored — even if the JS error was caught (the driver tracks per-block
|
|
102
|
+
// query failures). Error confinement therefore must go through the driver's
|
|
103
|
+
// own savepoint(), not manual SAVEPOINT statements. The callback receives
|
|
104
|
+
// the savepoint-scoped tx; run every confined statement on THAT handle.
|
|
105
|
+
export async function runInSavepoint(tx, fn) {
|
|
106
|
+
const raw = asRawClient(tx);
|
|
107
|
+
if (typeof raw.savepoint !== "function") {
|
|
108
|
+
throw new Error("runInSavepoint: transaction handle has no savepoint() — pass the driver tx (postgres.js TransactionSql / Bun.SQL).");
|
|
109
|
+
}
|
|
110
|
+
return raw.savepoint(fn);
|
|
111
|
+
}
|
|
112
|
+
// Same error-confinement as runInSavepoint, but for call sites that don't
|
|
113
|
+
// know whether `db` is a bare pool connection or an active transaction
|
|
114
|
+
// (e.g. the CRUD executor, invoked both from a dispatcher tx and directly
|
|
115
|
+
// against the pool by seeds/tests). A pool connection has no savepoint() —
|
|
116
|
+
// and doesn't need one, since each statement there is its own auto-committed
|
|
117
|
+
// unit and a failed statement can't poison anything downstream.
|
|
118
|
+
//
|
|
119
|
+
// `.savepoint` being present isn't proof the transaction is still open: a
|
|
120
|
+
// committed TransactionSql-shaped db still exposes `.savepoint`, and calling
|
|
121
|
+
// it fails with PG 25P01 ("no active sql transaction") since there's no
|
|
122
|
+
// BEGIN left to nest into. That is now a programming error, not something
|
|
123
|
+
// to paper over by re-running `fn` without the savepoint's isolation.
|
|
124
|
+
export async function runInSavepointIfSupported(db, fn) {
|
|
125
|
+
const raw = asRawClient(db);
|
|
126
|
+
// @cast-boundary driver savepoint handle → DbRunner at the single seam
|
|
127
|
+
const asRunner = (sp) => sp;
|
|
128
|
+
if (typeof raw.savepoint !== "function")
|
|
129
|
+
return fn(asRunner(db));
|
|
130
|
+
try {
|
|
131
|
+
return await raw.savepoint((sp) => fn(asRunner(sp)));
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
if (extractPgError(e)?.code === "25P01") {
|
|
135
|
+
throw new InternalError({
|
|
136
|
+
message: "runInSavepointIfSupported: savepoint on a transaction that has already committed — " +
|
|
137
|
+
"this is almost always database work in an afterCommit hook. afterCommit is the default " +
|
|
138
|
+
"phase of r.hook/postSave/postDelete. Use HookPhases.inTransaction for writes that must " +
|
|
139
|
+
"roll back with the trigger, or ctx.dbOutsideTransaction for work that must survive a rollback.",
|
|
140
|
+
cause: e instanceof Error ? e : undefined,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
throw e;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Duck-types TenantDb: five scoped methods + tenantId, no `.unsafe` of its own.
|
|
147
|
+
// A throwing systemScope guard Proxy fails closed here too — intended, not a bug.
|
|
148
|
+
function isTenantDbShape(db) {
|
|
149
|
+
if (typeof db !== "object" || db === null)
|
|
150
|
+
return false;
|
|
151
|
+
const d = db;
|
|
152
|
+
if (typeof d["unsafe"] === "function")
|
|
153
|
+
return false;
|
|
154
|
+
return (typeof d["selectMany"] === "function" &&
|
|
155
|
+
typeof d["fetchOne"] === "function" &&
|
|
156
|
+
typeof d["insertOne"] === "function" &&
|
|
157
|
+
typeof d["updateMany"] === "function" &&
|
|
158
|
+
typeof d["deleteMany"] === "function" &&
|
|
159
|
+
"tenantId" in d);
|
|
160
|
+
}
|
|
161
|
+
function tenantDbDelegate(db) {
|
|
162
|
+
return isTenantDbShape(db) ? db : undefined;
|
|
163
|
+
}
|
|
164
|
+
// Fails loudly for helpers that don't delegate to TenantDb (upsert/increment/insertMany) —
|
|
165
|
+
// passing one here would otherwise reach asRawClient and throw with a less specific message.
|
|
166
|
+
// @wrapper-known semantic-alias
|
|
167
|
+
function assertNotTenantScoped(db, fnName) {
|
|
168
|
+
if (tenantDbDelegate(db) !== undefined) {
|
|
169
|
+
throw new Error(`${fnName}: received a tenant-scoped db but this helper does not apply the tenant filter. ` +
|
|
170
|
+
"Pass ctx.db.unsafeRaw(reason) (with escapeHatch: { reason } on the handler/hook) for an " +
|
|
171
|
+
"explicit cross-tenant op, or use a scoped TenantDb method.");
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const WHERE_OPERATOR_KEYS = ["gt", "gte", "lt", "lte", "ne", "in", "like"];
|
|
175
|
+
const _whereOperatorKeysExhaustive = true;
|
|
176
|
+
void _whereOperatorKeysExhaustive;
|
|
177
|
+
function isWhereOperator(v) {
|
|
178
|
+
if (v === null || typeof v !== "object" || Array.isArray(v))
|
|
179
|
+
return false;
|
|
180
|
+
// Don't false-positive on Date / Temporal / other domain-objects.
|
|
181
|
+
// WhereOperator is plain object literal with at most these keys.
|
|
182
|
+
const keys = Object.keys(v);
|
|
183
|
+
if (keys.length === 0)
|
|
184
|
+
return false;
|
|
185
|
+
return keys.every((k) => WHERE_OPERATOR_KEYS.includes(k));
|
|
186
|
+
}
|
|
187
|
+
export function extractTableInfo(table) {
|
|
188
|
+
const meta = asEntityTableMeta(table);
|
|
189
|
+
if (!meta) {
|
|
190
|
+
throw new Error("bun-db.extractTableInfo: table is not a kumiko EntityTableMeta — " +
|
|
191
|
+
"build it via buildEntityTable / deriveEntityTableMeta / table().");
|
|
192
|
+
}
|
|
193
|
+
const colByField = new Map();
|
|
194
|
+
const fieldByCol = new Map();
|
|
195
|
+
const typeByCol = new Map();
|
|
196
|
+
const bigintModeByCol = new Map();
|
|
197
|
+
for (const c of meta.columns) {
|
|
198
|
+
typeByCol.set(c.name, c.pgType);
|
|
199
|
+
if (c.bigintJsMode !== undefined)
|
|
200
|
+
bigintModeByCol.set(c.name, c.bigintJsMode);
|
|
201
|
+
// EntityTableMeta column names are snake_case. Map snake → snake AND
|
|
202
|
+
// derive a camelCase JS field-name so result rows can be renamed back
|
|
203
|
+
// to the API shape (`aggregate_id` → `aggregateId`).
|
|
204
|
+
colByField.set(c.name, c.name);
|
|
205
|
+
const camel = snakeToCamel(c.name);
|
|
206
|
+
if (camel !== c.name)
|
|
207
|
+
colByField.set(camel, c.name);
|
|
208
|
+
fieldByCol.set(c.name, camel === c.name ? c.name : camel);
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
name: meta.tableName,
|
|
212
|
+
columnOf: (field) => colByField.get(field) ?? toSnakeCase(field),
|
|
213
|
+
pgTypeOf: (col) => typeByCol.get(col),
|
|
214
|
+
bigintJsModeOf: (col) => bigintModeByCol.get(col),
|
|
215
|
+
fieldOf: (col) => fieldByCol.get(col) ?? snakeToCamel(col),
|
|
216
|
+
hasColumn: (fieldOrColumn) => colByField.has(fieldOrColumn) || fieldByCol.has(fieldOrColumn),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function quoteIdent(name) {
|
|
220
|
+
return `"${name.replace(/"/g, '""')}"`;
|
|
221
|
+
}
|
|
222
|
+
// --- Value coercion at the driver boundary ------------------------------
|
|
223
|
+
//
|
|
224
|
+
// postgres-js returns timestamptz as JS Date (or ISO string depending on
|
|
225
|
+
// driver config). Framework contract says timestamptz surfaces as
|
|
226
|
+
// Temporal.Instant — without coercion every read hands callers a Date and
|
|
227
|
+
// downstream code that does .epochMilliseconds / .add(...) crashes.
|
|
228
|
+
//
|
|
229
|
+
// Symmetric on write: Temporal.Instant doesn't bind directly into postgres-js
|
|
230
|
+
// params — convert to ISO string when the column pgType is timestamptz.
|
|
231
|
+
function isTemporalInstant(v) {
|
|
232
|
+
return (typeof v === "object" &&
|
|
233
|
+
v !== null &&
|
|
234
|
+
v[Symbol.toStringTag] === "Temporal.Instant");
|
|
235
|
+
}
|
|
236
|
+
// Postgres bigint → JS: safe integers become `number` (matches createBigIntField /
|
|
237
|
+
// drizzle mode:"number"); values outside ±2^53 stay `bigint` (money cents, raw
|
|
238
|
+
// unmanaged columns). Uses BigInt equality check so 9007199254740993n never
|
|
239
|
+
// silently rounds to a safe integer.
|
|
240
|
+
function coerceBigIntFromDriver(value) {
|
|
241
|
+
let bi;
|
|
242
|
+
if (typeof value === "string") {
|
|
243
|
+
try {
|
|
244
|
+
bi = BigInt(value);
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
return value;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
bi = value;
|
|
252
|
+
}
|
|
253
|
+
const min = BigInt(Number.MIN_SAFE_INTEGER);
|
|
254
|
+
const max = BigInt(Number.MAX_SAFE_INTEGER);
|
|
255
|
+
if (bi >= min && bi <= max) {
|
|
256
|
+
const n = Number(bi);
|
|
257
|
+
if (BigInt(n) === bi)
|
|
258
|
+
return n;
|
|
259
|
+
}
|
|
260
|
+
return bi;
|
|
261
|
+
}
|
|
262
|
+
function instantFromDriver(value) {
|
|
263
|
+
if (value === null || value === undefined)
|
|
264
|
+
return null;
|
|
265
|
+
if (isTemporalInstant(value))
|
|
266
|
+
return value;
|
|
267
|
+
// Number coercion via +date — equivalent to .getTime() without a Date-API
|
|
268
|
+
// method (guard-no-date-api). Date → epoch milliseconds, then to Temporal.Instant.
|
|
269
|
+
if (value instanceof Date)
|
|
270
|
+
return Temporal.Instant.fromEpochMilliseconds(+value);
|
|
271
|
+
if (typeof value === "string") {
|
|
272
|
+
try {
|
|
273
|
+
return Temporal.Instant.from(value);
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (typeof value === "number")
|
|
280
|
+
return Temporal.Instant.fromEpochMilliseconds(value);
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
function isTemporalPlainDate(v) {
|
|
284
|
+
return (typeof v === "object" &&
|
|
285
|
+
v !== null &&
|
|
286
|
+
v[Symbol.toStringTag] === "Temporal.PlainDate");
|
|
287
|
+
}
|
|
288
|
+
function isTemporalPlainDateTimeLike(v) {
|
|
289
|
+
return (typeof v === "object" &&
|
|
290
|
+
v !== null &&
|
|
291
|
+
(v[Symbol.toStringTag] === "Temporal.PlainDateTime" ||
|
|
292
|
+
v[Symbol.toStringTag] === "Temporal.ZonedDateTime") &&
|
|
293
|
+
typeof v.toPlainDate === "function");
|
|
294
|
+
}
|
|
295
|
+
// Verified empirically against Bun.SQL (kumiko-framework#1924): a `date`
|
|
296
|
+
// column comes back as a native JS Date, but ALWAYS anchored at UTC
|
|
297
|
+
// midnight regardless of process TZ — epochMilliseconds is stable across
|
|
298
|
+
// zones, only the local wall-clock read of that Date would drift the day
|
|
299
|
+
// (e.g. America/Los_Angeles reads back the 14th for a stored 15th). Routing
|
|
300
|
+
// through Instant→ZonedDateTimeISO("UTC")→PlainDate reads the calendar day
|
|
301
|
+
// back deterministically without ever touching a local Date getter — the
|
|
302
|
+
// same +value idiom instantFromDriver uses (guard-no-date-api: no
|
|
303
|
+
// `.getTime()`), just anchored to a fixed zone instead of process-local.
|
|
304
|
+
function plainDateFromDriver(value) {
|
|
305
|
+
if (value === null || value === undefined)
|
|
306
|
+
return null;
|
|
307
|
+
if (isTemporalPlainDate(value))
|
|
308
|
+
return value;
|
|
309
|
+
if (typeof value === "string") {
|
|
310
|
+
const isoDay = /^\d{4}-\d{2}-\d{2}/.exec(value)?.[0];
|
|
311
|
+
if (isoDay === undefined)
|
|
312
|
+
return null;
|
|
313
|
+
try {
|
|
314
|
+
return Temporal.PlainDate.from(isoDay);
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (value instanceof Date) {
|
|
321
|
+
return Temporal.Instant.fromEpochMilliseconds(+value).toZonedDateTimeISO("UTC").toPlainDate();
|
|
322
|
+
}
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
// Walk the driver-row, applying three boundary-conversions per known column:
|
|
326
|
+
// - rename key snake_case → camelCase JS field-name (drizzle did this
|
|
327
|
+
// invisibly via its column-mapper; native dialect rebuild lost it)
|
|
328
|
+
// - parse jsonb string → object (postgres-js returns jsonb as text by
|
|
329
|
+
// default, not parsed JSON)
|
|
330
|
+
// - coerce timestamptz Date/string → Temporal.Instant
|
|
331
|
+
//
|
|
332
|
+
// Unknown columns (computed/aliased) pass through unchanged.
|
|
333
|
+
export function coerceRow(row, info) {
|
|
334
|
+
const out = {};
|
|
335
|
+
let changed = false;
|
|
336
|
+
for (const key of Object.keys(row)) {
|
|
337
|
+
// Blind-index columns (#818) are pure lookup artifacts — the
|
|
338
|
+
// deterministic HMAC must never leak into caller/API responses.
|
|
339
|
+
if ((key.endsWith("_bidx") || key.endsWith("Bidx")) && info.hasColumn(key)) {
|
|
340
|
+
changed = true;
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
const pgType = info.pgTypeOf(key);
|
|
344
|
+
const value = row[key];
|
|
345
|
+
let coerced = value;
|
|
346
|
+
if (pgType === "timestamptz" || pgType === "timestamptz(3)") {
|
|
347
|
+
const t = instantFromDriver(value);
|
|
348
|
+
if (t !== null)
|
|
349
|
+
coerced = t;
|
|
350
|
+
}
|
|
351
|
+
else if (pgType === "date") {
|
|
352
|
+
const d = plainDateFromDriver(value);
|
|
353
|
+
if (d !== null)
|
|
354
|
+
coerced = d;
|
|
355
|
+
}
|
|
356
|
+
else if (pgType === "jsonb" && typeof value === "string") {
|
|
357
|
+
coerced = parseJsonSafe(value, value);
|
|
358
|
+
}
|
|
359
|
+
else if ((pgType === "bigint" || pgType === "bigserial") &&
|
|
360
|
+
(typeof value === "string" || typeof value === "bigint")) {
|
|
361
|
+
const jsMode = info.bigintJsModeOf(key);
|
|
362
|
+
if (jsMode === "number") {
|
|
363
|
+
coerced = coerceBigIntFromDriver(value);
|
|
364
|
+
}
|
|
365
|
+
else if (typeof value === "string") {
|
|
366
|
+
try {
|
|
367
|
+
coerced = BigInt(value);
|
|
368
|
+
}
|
|
369
|
+
catch {
|
|
370
|
+
// leave as string on parse error
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
coerced = value;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
else if ((pgType === "integer" || pgType === "int4" || pgType === "smallint" || pgType === "int2") &&
|
|
378
|
+
(typeof value === "bigint" || typeof value === "string")) {
|
|
379
|
+
// Bun.SQL / some drivers return int4 as bigint or numeric string.
|
|
380
|
+
// Drizzle coerced to number for numberField columns — match that.
|
|
381
|
+
const n = Number(value);
|
|
382
|
+
if (!Number.isNaN(n))
|
|
383
|
+
coerced = n;
|
|
384
|
+
}
|
|
385
|
+
else if (typeof pgType === "string" &&
|
|
386
|
+
pgType.startsWith("numeric") &&
|
|
387
|
+
(typeof value === "string" || typeof value === "bigint")) {
|
|
388
|
+
// pg returns numeric(p,s) as a string to preserve precision; the
|
|
389
|
+
// decimal-field contract surfaces it as JS number (safe ≤ 2^53). A
|
|
390
|
+
// non-numeric string would be DB corruption — leave it untouched so it
|
|
391
|
+
// surfaces loud downstream rather than becoming a silent NaN.
|
|
392
|
+
const n = Number(value);
|
|
393
|
+
if (!Number.isNaN(n))
|
|
394
|
+
coerced = n;
|
|
395
|
+
}
|
|
396
|
+
const fieldName = info.fieldOf(key);
|
|
397
|
+
if (fieldName !== key)
|
|
398
|
+
changed = true;
|
|
399
|
+
if (coerced !== value)
|
|
400
|
+
changed = true;
|
|
401
|
+
out[fieldName] = coerced;
|
|
402
|
+
}
|
|
403
|
+
return (changed ? out : row);
|
|
404
|
+
}
|
|
405
|
+
function coerceRows(rows, info) {
|
|
406
|
+
return rows.map((r) => coerceRow(r, info));
|
|
407
|
+
}
|
|
408
|
+
// Checks the brand Symbol, not the `kind` string — a client-supplied jsonb
|
|
409
|
+
// value can fake `kind: "sql-expr"` over JSON but can never carry a Symbol,
|
|
410
|
+
// so request data can't be smuggled in as a raw SQL literal.
|
|
411
|
+
function isSqlExpression(v) {
|
|
412
|
+
return typeof v === "object" && v !== null && SQL_EXPR_BRAND in v;
|
|
413
|
+
}
|
|
414
|
+
// A `date` column takes a plain "yyyy-mm-dd" string (or PlainDate.toString())
|
|
415
|
+
// as-is — no Instant detour. Postgres parses a DATE literal without ever
|
|
416
|
+
// consulting the session timezone, so this is TZ-independent by construction
|
|
417
|
+
// (verified empirically — see plainDateFromDriver above for the read side).
|
|
418
|
+
// Compat cushion: pre-#1924 code (this field used to be an Instant) may still
|
|
419
|
+
// hand a Temporal.Instant into a where-filter or write on a `date` column —
|
|
420
|
+
// same UTC anchor as plainDateFromDriver's read side, so a filter built with
|
|
421
|
+
// `Temporal.Now.instant()` keeps working instead of binding a raw Instant the
|
|
422
|
+
// driver can't serialize.
|
|
423
|
+
function prepareDateValue(value) {
|
|
424
|
+
if (isTemporalPlainDate(value)) {
|
|
425
|
+
return { kind: "param", sql: "", bound: value.toString() };
|
|
426
|
+
}
|
|
427
|
+
if (isTemporalPlainDateTimeLike(value)) {
|
|
428
|
+
return { kind: "param", sql: "", bound: value.toPlainDate().toString() };
|
|
429
|
+
}
|
|
430
|
+
if (isTemporalInstant(value)) {
|
|
431
|
+
const day = value.toZonedDateTimeISO("UTC").toPlainDate();
|
|
432
|
+
return { kind: "param", sql: "", bound: day.toString() };
|
|
433
|
+
}
|
|
434
|
+
return undefined;
|
|
435
|
+
}
|
|
436
|
+
// structured values bind directly with an ::jsonb cast; JSON.stringify first
|
|
437
|
+
// would produce a JSON-string scalar instead of the structured value.
|
|
438
|
+
function prepareJsonbValue(value) {
|
|
439
|
+
if (typeof value === "boolean") {
|
|
440
|
+
return { kind: "param", sql: "::text::jsonb", bound: JSON.stringify(value) };
|
|
441
|
+
}
|
|
442
|
+
if (typeof value !== "object" || isTemporalInstant(value)) {
|
|
443
|
+
return undefined;
|
|
444
|
+
}
|
|
445
|
+
if (!Array.isArray(value)) {
|
|
446
|
+
return { kind: "param", sql: "::jsonb", bound: value };
|
|
447
|
+
}
|
|
448
|
+
// All-boolean arrays are inferred as boolean[] by postgres-js; route via text::jsonb.
|
|
449
|
+
if (value.length > 0 && value.every((entry) => typeof entry === "boolean")) {
|
|
450
|
+
return { kind: "param", sql: "::text::jsonb", bound: JSON.stringify(value) };
|
|
451
|
+
}
|
|
452
|
+
return { kind: "param", sql: "::jsonb", bound: value };
|
|
453
|
+
}
|
|
454
|
+
function prepareValue(value, pgType) {
|
|
455
|
+
if (isSqlExpression(value)) {
|
|
456
|
+
return { kind: "literal", literal: value.text };
|
|
457
|
+
}
|
|
458
|
+
if (pgType === "jsonb" && value !== null) {
|
|
459
|
+
const prepared = prepareJsonbValue(value);
|
|
460
|
+
if (prepared)
|
|
461
|
+
return prepared;
|
|
462
|
+
}
|
|
463
|
+
if ((pgType === "timestamptz" || pgType === "timestamptz(3)") && isTemporalInstant(value)) {
|
|
464
|
+
return { kind: "param", sql: "", bound: value.toString() };
|
|
465
|
+
}
|
|
466
|
+
if (pgType === "date") {
|
|
467
|
+
const prepared = prepareDateValue(value);
|
|
468
|
+
if (prepared)
|
|
469
|
+
return prepared;
|
|
470
|
+
}
|
|
471
|
+
return { kind: "param", sql: "", bound: value };
|
|
472
|
+
}
|
|
473
|
+
function buildWhereClause(info, where, startIndex) {
|
|
474
|
+
const conditions = [];
|
|
475
|
+
const values = [];
|
|
476
|
+
let idx = startIndex;
|
|
477
|
+
// multiSelect (and any other jsonb-array-of-scalars column) stores an
|
|
478
|
+
// array — a filter value is one option, not the whole array, so eq/ne/in
|
|
479
|
+
// must check array containment (`@>`) instead of scalar `=`/`<>`/`IN`
|
|
480
|
+
// against the jsonb column, which Postgres rejects outright (fw#2490).
|
|
481
|
+
// Mirrors event-store-executor-read.ts's applyFilter — keep in lock-step.
|
|
482
|
+
function jsonbContainsAny(col, candidates) {
|
|
483
|
+
if (candidates.length === 0)
|
|
484
|
+
return "FALSE";
|
|
485
|
+
const parts = [];
|
|
486
|
+
for (const v of candidates) {
|
|
487
|
+
const p = prepareJsonbValue([v]);
|
|
488
|
+
// prepareJsonbValue never returns kind:"literal" (only prepareValue's
|
|
489
|
+
// isSqlExpression branch does) — narrow anyway, PreparedValue is a union.
|
|
490
|
+
if (p && p.kind === "param") {
|
|
491
|
+
parts.push(`${quoteIdent(col)} @> $${idx++}${p.sql}`);
|
|
492
|
+
values.push(p.bound);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return parts.length > 0 ? `(${parts.join(" OR ")})` : "FALSE";
|
|
496
|
+
}
|
|
497
|
+
function isJsonbScalar(value) {
|
|
498
|
+
return value !== null && typeof value !== "object";
|
|
499
|
+
}
|
|
500
|
+
for (const [field, value] of Object.entries(where)) {
|
|
501
|
+
const col = info.columnOf(field);
|
|
502
|
+
const pgType = info.pgTypeOf(col);
|
|
503
|
+
if (value === null) {
|
|
504
|
+
conditions.push(`${quoteIdent(col)} IS NULL`);
|
|
505
|
+
}
|
|
506
|
+
else if (Array.isArray(value)) {
|
|
507
|
+
if (value.length === 0) {
|
|
508
|
+
conditions.push("FALSE");
|
|
509
|
+
}
|
|
510
|
+
else if (pgType === "jsonb") {
|
|
511
|
+
conditions.push(jsonbContainsAny(col, value));
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
const parts = [];
|
|
515
|
+
for (const v of value) {
|
|
516
|
+
const p = prepareValue(v, pgType);
|
|
517
|
+
if (p.kind === "literal") {
|
|
518
|
+
parts.push(p.literal);
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
parts.push(`$${idx++}${p.sql}`);
|
|
522
|
+
values.push(p.bound);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
conditions.push(`${quoteIdent(col)} IN (${parts.join(", ")})`);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
else if (isWhereOperator(value)) {
|
|
529
|
+
if (value.ne === null && Object.keys(value).length === 1) {
|
|
530
|
+
conditions.push(`${quoteIdent(col)} IS NOT NULL`);
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
const opMap = {
|
|
534
|
+
gt: ">",
|
|
535
|
+
gte: ">=",
|
|
536
|
+
lt: "<",
|
|
537
|
+
lte: "<=",
|
|
538
|
+
ne: "<>",
|
|
539
|
+
like: "LIKE",
|
|
540
|
+
};
|
|
541
|
+
for (const [opKey, opSym] of Object.entries(opMap)) {
|
|
542
|
+
const opVal = value[opKey];
|
|
543
|
+
if (opVal === undefined)
|
|
544
|
+
continue;
|
|
545
|
+
if (opKey === "ne" && pgType === "jsonb" && isJsonbScalar(opVal)) {
|
|
546
|
+
const p = prepareJsonbValue([opVal]);
|
|
547
|
+
if (p && p.kind === "param") {
|
|
548
|
+
conditions.push(`NOT (${quoteIdent(col)} @> $${idx++}${p.sql})`);
|
|
549
|
+
values.push(p.bound);
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
const p = prepareValue(opVal, pgType);
|
|
554
|
+
if (p.kind === "literal") {
|
|
555
|
+
conditions.push(`${quoteIdent(col)} ${opSym} ${p.literal}`);
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
conditions.push(`${quoteIdent(col)} ${opSym} $${idx++}${p.sql}`);
|
|
559
|
+
values.push(p.bound);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
const inVal = value["in"];
|
|
563
|
+
if (Array.isArray(inVal)) {
|
|
564
|
+
if (pgType === "jsonb") {
|
|
565
|
+
conditions.push(jsonbContainsAny(col, inVal));
|
|
566
|
+
}
|
|
567
|
+
else if (inVal.length === 0) {
|
|
568
|
+
conditions.push("FALSE");
|
|
569
|
+
}
|
|
570
|
+
else {
|
|
571
|
+
const parts = [];
|
|
572
|
+
for (const v of inVal) {
|
|
573
|
+
const p = prepareValue(v, pgType);
|
|
574
|
+
if (p.kind === "literal") {
|
|
575
|
+
parts.push(p.literal);
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
parts.push(`$${idx++}${p.sql}`);
|
|
579
|
+
values.push(p.bound);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
conditions.push(`${quoteIdent(col)} IN (${parts.join(", ")})`);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
else if (pgType === "jsonb" && isJsonbScalar(value)) {
|
|
587
|
+
conditions.push(jsonbContainsAny(col, [value]));
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
const p = prepareValue(value, pgType);
|
|
591
|
+
if (p.kind === "literal") {
|
|
592
|
+
conditions.push(`${quoteIdent(col)} = ${p.literal}`);
|
|
593
|
+
}
|
|
594
|
+
else {
|
|
595
|
+
// Blind-index OR rewrite (#818): if the column has a bidx
|
|
596
|
+
// counterpart (suffix convention `<col>_bidx`, framework-reserved)
|
|
597
|
+
// and a key is configured, equality matches both arms —
|
|
598
|
+
// plaintext legacy rows via the plaintext arm, encrypted rows
|
|
599
|
+
// via the HMAC. The `kumiko-pii:` prefix on ciphertexts makes
|
|
600
|
+
// a random match on the plaintext arm practically impossible.
|
|
601
|
+
const bidxKey = configuredBlindIndexKey();
|
|
602
|
+
const bidxCol = `${col}_bidx`;
|
|
603
|
+
if (bidxKey !== undefined &&
|
|
604
|
+
typeof value === "string" &&
|
|
605
|
+
!col.endsWith("_bidx") &&
|
|
606
|
+
info.hasColumn(bidxCol)) {
|
|
607
|
+
conditions.push(`(${quoteIdent(col)} = $${idx++} OR ${quoteIdent(bidxCol)} = $${idx++})`);
|
|
608
|
+
values.push(p.bound, computeBlindIndex(bidxKey, value));
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
conditions.push(`${quoteIdent(col)} = $${idx++}${p.sql}`);
|
|
612
|
+
values.push(p.bound);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return { sqlText: conditions.join(" AND "), values };
|
|
618
|
+
}
|
|
619
|
+
// A pool can briefly keep handing out connections the server just closed.
|
|
620
|
+
// Each failed attempt discards one, so retries are bounded by pool size.
|
|
621
|
+
const CLOSED_CONNECTION_CODES = new Set([
|
|
622
|
+
"CONNECTION_CLOSED", // postgres-js
|
|
623
|
+
"ERR_POSTGRES_CONNECTION_CLOSED", // Bun.SQL
|
|
624
|
+
"57P01", // PG SQLSTATE: admin_shutdown / terminated backend
|
|
625
|
+
]);
|
|
626
|
+
export function isClosedConnectionError(err) {
|
|
627
|
+
const code = extractPgError(err)?.code;
|
|
628
|
+
return code !== undefined && CLOSED_CONNECTION_CODES.has(code);
|
|
629
|
+
}
|
|
630
|
+
// Tx/reserved handles are pinned to one physical connection — a retry there
|
|
631
|
+
// would run on the same dead connection, not swap in a fresh one.
|
|
632
|
+
function isPooledClient(raw) {
|
|
633
|
+
if (raw === null || (typeof raw !== "object" && typeof raw !== "function"))
|
|
634
|
+
return false;
|
|
635
|
+
// @cast-boundary driver handle shape — begin/savepoint/release are optional across drivers
|
|
636
|
+
const r = raw;
|
|
637
|
+
return (typeof r.begin === "function" &&
|
|
638
|
+
typeof r.savepoint !== "function" &&
|
|
639
|
+
typeof r.release !== "function");
|
|
640
|
+
}
|
|
641
|
+
const closedConnectionLog = createFallbackLogger("bun-db");
|
|
642
|
+
// The driver rejects in-flight queries with this AbortError (no code) when the
|
|
643
|
+
// pool closes under them, so isClosedConnectionError can't see it.
|
|
644
|
+
const DRIVER_CLOSED_ABORT_MESSAGE = "The connection was closed.";
|
|
645
|
+
function isDriverClosedAbort(err) {
|
|
646
|
+
return (err instanceof Error && err.name === "AbortError" && err.message === DRIVER_CLOSED_ABORT_MESSAGE);
|
|
647
|
+
}
|
|
648
|
+
function isHandleLike(raw) {
|
|
649
|
+
return raw !== null && (typeof raw === "object" || typeof raw === "function");
|
|
650
|
+
}
|
|
651
|
+
// Bun.SQL is not instanceof-checkable (Bun.SQL.prototype is invalid) and its tx
|
|
652
|
+
// handles are plain function objects, so discriminate by members only one driver
|
|
653
|
+
// has: `flush` on Bun.SQL (pool and tx), `typed` on postgres-js (pool and tx).
|
|
654
|
+
function driverOf(raw) {
|
|
655
|
+
if (!isHandleLike(raw))
|
|
656
|
+
return "unknown";
|
|
657
|
+
if (typeof raw["flush"] === "function")
|
|
658
|
+
return "bun-sql";
|
|
659
|
+
if (typeof raw["typed"] === "function")
|
|
660
|
+
return "postgres-js";
|
|
661
|
+
return "unknown";
|
|
662
|
+
}
|
|
663
|
+
function positiveNumber(v) {
|
|
664
|
+
return typeof v === "number" && Number.isFinite(v) && v > 0 ? v : undefined;
|
|
665
|
+
}
|
|
666
|
+
// postgres-js configures timeouts in seconds, Bun.SQL in milliseconds.
|
|
667
|
+
function timeoutOptionMs(options, driver, bunName, postgresJsName) {
|
|
668
|
+
if (driver === "postgres-js") {
|
|
669
|
+
const seconds = positiveNumber(options[postgresJsName]);
|
|
670
|
+
return seconds === undefined ? undefined : seconds * 1000;
|
|
671
|
+
}
|
|
672
|
+
return positiveNumber(options[bunName]);
|
|
673
|
+
}
|
|
674
|
+
function errorProp(err, name) {
|
|
675
|
+
return isHandleLike(err) ? err[name] : undefined;
|
|
676
|
+
}
|
|
677
|
+
// Deliberately excludes SQL text and parameters: app SQL can carry PII.
|
|
678
|
+
export function describeClosedConnectionFailure(raw, err, attempts) {
|
|
679
|
+
if (!isClosedConnectionError(err) && !isDriverClosedAbort(err))
|
|
680
|
+
return undefined;
|
|
681
|
+
const driver = driverOf(raw);
|
|
682
|
+
const rawOptions = isHandleLike(raw) ? raw["options"] : undefined;
|
|
683
|
+
const options = isHandleLike(rawOptions) ? rawOptions : {};
|
|
684
|
+
return {
|
|
685
|
+
driver,
|
|
686
|
+
pooled: isPooledClient(raw),
|
|
687
|
+
attempts,
|
|
688
|
+
poolMax: positiveNumber(options["max"]),
|
|
689
|
+
idleTimeoutMs: timeoutOptionMs(options, driver, "idleTimeout", "idle_timeout"),
|
|
690
|
+
maxLifetimeMs: timeoutOptionMs(options, driver, "maxLifetime", "max_lifetime"),
|
|
691
|
+
connectionTimeoutMs: timeoutOptionMs(options, driver, "connectionTimeout", "connect_timeout"),
|
|
692
|
+
errorName: errorProp(err, "name"),
|
|
693
|
+
errorCode: extractPgError(err)?.code ?? errorProp(err, "code"),
|
|
694
|
+
errorErrno: errorProp(err, "errno"),
|
|
695
|
+
errorMessage: errorProp(err, "message"),
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
function logClosedConnection(raw, err, attempts, context) {
|
|
699
|
+
const failure = describeClosedConnectionFailure(raw, err, attempts);
|
|
700
|
+
// skip: not a closed-connection error, nothing to diagnose
|
|
701
|
+
if (!failure)
|
|
702
|
+
return;
|
|
703
|
+
// Request identity lets this line be joined to the route's `handler failed` log.
|
|
704
|
+
const request = requestContext.get();
|
|
705
|
+
closedConnectionLog.warn("closed connection surfaced", {
|
|
706
|
+
...failure,
|
|
707
|
+
...context,
|
|
708
|
+
requestId: request?.requestId,
|
|
709
|
+
correlationId: request?.correlationId,
|
|
710
|
+
handler: request?.handler,
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
// Write and other non-retried paths: log when a closed-connection error leaves
|
|
714
|
+
// bun-db, rethrow unchanged.
|
|
715
|
+
async function unsafeLoggingClosedConnection(db, sqlText, params, context) {
|
|
716
|
+
const raw = asRawClient(db);
|
|
717
|
+
try {
|
|
718
|
+
return await raw.unsafe(sqlText, params);
|
|
719
|
+
}
|
|
720
|
+
catch (err) {
|
|
721
|
+
logClosedConnection(raw, err, 1, context);
|
|
722
|
+
throw err;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
function poolMaxOf(raw) {
|
|
726
|
+
// @cast-boundary driver pool options — both postgres-js and Bun.SQL expose options.max
|
|
727
|
+
const max = raw.options?.max;
|
|
728
|
+
return typeof max === "number" && Number.isInteger(max) && max > 0 ? max : 10;
|
|
729
|
+
}
|
|
730
|
+
// Exported so raw-SQL query modules outside bun-db (e.g. bundled-features'
|
|
731
|
+
// db/queries/*.ts) can opt into the same closed-connection retry instead of
|
|
732
|
+
// calling asRawClient(db).unsafe(...) directly and losing it.
|
|
733
|
+
// READS ONLY — retry re-executes the statement; never pass INSERT/UPDATE/DELETE.
|
|
734
|
+
export async function unsafeReadRetrying(db, sqlText, params) {
|
|
735
|
+
const raw = asRawClient(db);
|
|
736
|
+
try {
|
|
737
|
+
return (await raw.unsafe(sqlText, params));
|
|
738
|
+
}
|
|
739
|
+
catch (err) {
|
|
740
|
+
if (!isPooledClient(raw) || !isClosedConnectionError(err)) {
|
|
741
|
+
logClosedConnection(raw, err, 1);
|
|
742
|
+
throw err;
|
|
743
|
+
}
|
|
744
|
+
const maxAttempts = poolMaxOf(raw) + 1;
|
|
745
|
+
let lastErr = err;
|
|
746
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
747
|
+
try {
|
|
748
|
+
return (await raw.unsafe(sqlText, params));
|
|
749
|
+
}
|
|
750
|
+
catch (retryErr) {
|
|
751
|
+
lastErr = retryErr;
|
|
752
|
+
if (!isClosedConnectionError(retryErr)) {
|
|
753
|
+
logClosedConnection(raw, retryErr, attempt + 2);
|
|
754
|
+
throw retryErr;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
logClosedConnection(raw, lastErr, maxAttempts + 1);
|
|
759
|
+
throw lastErr;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
// biome-ignore lint/suspicious/noExplicitAny: opt-in default loosens row type for unannotated test fixtures
|
|
763
|
+
export async function selectMany(db, table, where, options) {
|
|
764
|
+
const scoped = tenantDbDelegate(db);
|
|
765
|
+
if (scoped) {
|
|
766
|
+
return scoped.selectMany(table, where, options);
|
|
767
|
+
}
|
|
768
|
+
const info = extractTableInfo(table);
|
|
769
|
+
let sqlText = `SELECT * FROM ${quoteIdent(info.name)}`;
|
|
770
|
+
let values = [];
|
|
771
|
+
if (where && Object.keys(where).length > 0) {
|
|
772
|
+
const w = buildWhereClause(info, where, 1);
|
|
773
|
+
sqlText += ` WHERE ${w.sqlText}`;
|
|
774
|
+
values = w.values;
|
|
775
|
+
}
|
|
776
|
+
if (options?.orderBy) {
|
|
777
|
+
const clauses = Array.isArray(options.orderBy) ? options.orderBy : [options.orderBy];
|
|
778
|
+
const parts = clauses.map((c) => {
|
|
779
|
+
const col = info.columnOf(c.col);
|
|
780
|
+
const dir = c.direction === "desc" ? "DESC" : "ASC";
|
|
781
|
+
return `${quoteIdent(col)} ${dir}`;
|
|
782
|
+
});
|
|
783
|
+
if (parts.length > 0)
|
|
784
|
+
sqlText += ` ORDER BY ${parts.join(", ")}`;
|
|
785
|
+
}
|
|
786
|
+
if (options?.limit !== undefined) {
|
|
787
|
+
// Interpolated, not bound — guard against a non-integer slipping in via an
|
|
788
|
+
// `any`-typed call site and injecting SQL.
|
|
789
|
+
if (!Number.isInteger(options.limit) || options.limit < 0) {
|
|
790
|
+
throw new Error(`selectMany: limit must be a non-negative integer, got ${options.limit}`);
|
|
791
|
+
}
|
|
792
|
+
sqlText += ` LIMIT ${options.limit}`;
|
|
793
|
+
}
|
|
794
|
+
const raw = (await unsafeReadRetrying(db, sqlText, values));
|
|
795
|
+
return coerceRows(raw, info);
|
|
796
|
+
}
|
|
797
|
+
// biome-ignore lint/suspicious/noExplicitAny: see selectMany default
|
|
798
|
+
export async function fetchOne(db, table, where) {
|
|
799
|
+
const rows = await selectMany(db, table, where, { limit: 1 });
|
|
800
|
+
return rows[0];
|
|
801
|
+
}
|
|
802
|
+
// Bulk INSERT — same shape as insertOne but takes an array of rows and
|
|
803
|
+
// produces one multi-VALUES statement. Mirrors drizzle's
|
|
804
|
+
// `db.insert(t).values(rows[])`. Empty input is a no-op.
|
|
805
|
+
// biome-ignore lint/suspicious/noExplicitAny: see selectMany default
|
|
806
|
+
export async function insertMany(db, table, rows) {
|
|
807
|
+
if (rows.length === 0)
|
|
808
|
+
return [];
|
|
809
|
+
assertNotTenantScoped(db, "insertMany");
|
|
810
|
+
const info = extractTableInfo(table);
|
|
811
|
+
// Use the column-set from the first row; assume all rows share keys.
|
|
812
|
+
const firstRow = rows[0];
|
|
813
|
+
if (firstRow === undefined)
|
|
814
|
+
return [];
|
|
815
|
+
// Filter out fields that don't exist as columns in the table (like drizzle did implicitly)
|
|
816
|
+
const fields = Object.keys(firstRow).filter((k) => info.hasColumn(k));
|
|
817
|
+
if (fields.length === 0)
|
|
818
|
+
throw new Error("insertMany: empty row object");
|
|
819
|
+
const cols = fields.map((k) => quoteIdent(info.columnOf(k))).join(", ");
|
|
820
|
+
const params = [];
|
|
821
|
+
const valuesClauses = [];
|
|
822
|
+
for (const row of rows) {
|
|
823
|
+
const placeholders = [];
|
|
824
|
+
for (const f of fields) {
|
|
825
|
+
const col = info.columnOf(f);
|
|
826
|
+
const pgType = info.pgTypeOf(col);
|
|
827
|
+
const p = prepareValue(row[f], pgType);
|
|
828
|
+
if (p.kind === "literal") {
|
|
829
|
+
placeholders.push(p.literal);
|
|
830
|
+
}
|
|
831
|
+
else {
|
|
832
|
+
params.push(p.bound);
|
|
833
|
+
placeholders.push(`$${params.length}${p.sql}`);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
valuesClauses.push(`(${placeholders.join(", ")})`);
|
|
837
|
+
}
|
|
838
|
+
const sqlText = `INSERT INTO ${quoteIdent(info.name)} (${cols}) VALUES ${valuesClauses.join(", ")} RETURNING *`;
|
|
839
|
+
const raw = (await unsafeLoggingClosedConnection(db, sqlText, params, {
|
|
840
|
+
operation: "insertMany",
|
|
841
|
+
table: info.name,
|
|
842
|
+
}));
|
|
843
|
+
return coerceRows(raw, info);
|
|
844
|
+
}
|
|
845
|
+
// biome-ignore lint/suspicious/noExplicitAny: see selectMany default
|
|
846
|
+
export async function insertOne(db, table, values) {
|
|
847
|
+
const scoped = tenantDbDelegate(db);
|
|
848
|
+
if (scoped) {
|
|
849
|
+
return scoped.insertOne(table, values);
|
|
850
|
+
}
|
|
851
|
+
const info = extractTableInfo(table);
|
|
852
|
+
const entries = Object.entries(values)
|
|
853
|
+
.filter(([k]) => info.hasColumn(k))
|
|
854
|
+
.map(([k, v]) => {
|
|
855
|
+
const col = info.columnOf(k);
|
|
856
|
+
const pgType = info.pgTypeOf(col);
|
|
857
|
+
return { col, prepared: prepareValue(v, pgType) };
|
|
858
|
+
});
|
|
859
|
+
if (entries.length === 0)
|
|
860
|
+
throw new Error("insertOne: empty values object");
|
|
861
|
+
const cols = entries.map((e) => quoteIdent(e.col)).join(", ");
|
|
862
|
+
const params = [];
|
|
863
|
+
const placeholders = entries
|
|
864
|
+
.map((e) => {
|
|
865
|
+
if (e.prepared.kind === "literal")
|
|
866
|
+
return e.prepared.literal;
|
|
867
|
+
params.push(e.prepared.bound);
|
|
868
|
+
return `$${params.length}${e.prepared.sql}`;
|
|
869
|
+
})
|
|
870
|
+
.join(", ");
|
|
871
|
+
const sqlText = `INSERT INTO ${quoteIdent(info.name)} (${cols}) VALUES (${placeholders}) RETURNING *`;
|
|
872
|
+
const rows = (await unsafeLoggingClosedConnection(db, sqlText, params, {
|
|
873
|
+
operation: "insertOne",
|
|
874
|
+
table: info.name,
|
|
875
|
+
}));
|
|
876
|
+
const first = rows[0];
|
|
877
|
+
if (!first)
|
|
878
|
+
return undefined;
|
|
879
|
+
return coerceRow(first, info);
|
|
880
|
+
}
|
|
881
|
+
// biome-ignore lint/suspicious/noExplicitAny: see selectMany default
|
|
882
|
+
export async function updateMany(db, table, set, where) {
|
|
883
|
+
const scoped = tenantDbDelegate(db);
|
|
884
|
+
if (scoped) {
|
|
885
|
+
return scoped.updateMany(table, set, where);
|
|
886
|
+
}
|
|
887
|
+
const info = extractTableInfo(table);
|
|
888
|
+
const setEntries = Object.entries(set)
|
|
889
|
+
.filter(([k]) => info.hasColumn(k))
|
|
890
|
+
.map(([k, v]) => {
|
|
891
|
+
const col = info.columnOf(k);
|
|
892
|
+
const pgType = info.pgTypeOf(col);
|
|
893
|
+
return { col, prepared: prepareValue(v, pgType) };
|
|
894
|
+
});
|
|
895
|
+
if (setEntries.length === 0)
|
|
896
|
+
throw new Error("updateMany: empty set object");
|
|
897
|
+
const values = [];
|
|
898
|
+
let idx = 1;
|
|
899
|
+
const setParts = [];
|
|
900
|
+
for (const e of setEntries) {
|
|
901
|
+
if (e.prepared.kind === "literal") {
|
|
902
|
+
setParts.push(`${quoteIdent(e.col)} = ${e.prepared.literal}`);
|
|
903
|
+
}
|
|
904
|
+
else {
|
|
905
|
+
setParts.push(`${quoteIdent(e.col)} = $${idx++}${e.prepared.sql}`);
|
|
906
|
+
values.push(e.prepared.bound);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
const w = buildWhereClause(info, where, idx);
|
|
910
|
+
let sqlText = `UPDATE ${quoteIdent(info.name)} SET ${setParts.join(", ")}`;
|
|
911
|
+
if (w.sqlText) {
|
|
912
|
+
sqlText += ` WHERE ${w.sqlText}`;
|
|
913
|
+
for (const v of w.values)
|
|
914
|
+
values.push(v);
|
|
915
|
+
}
|
|
916
|
+
sqlText += " RETURNING *";
|
|
917
|
+
const raw = (await unsafeLoggingClosedConnection(db, sqlText, values, {
|
|
918
|
+
operation: "updateMany",
|
|
919
|
+
table: info.name,
|
|
920
|
+
}));
|
|
921
|
+
return coerceRows(raw, info);
|
|
922
|
+
}
|
|
923
|
+
export async function deleteMany(db, table, where) {
|
|
924
|
+
const scoped = tenantDbDelegate(db);
|
|
925
|
+
if (scoped) {
|
|
926
|
+
return scoped.deleteMany(table, where);
|
|
927
|
+
}
|
|
928
|
+
const info = extractTableInfo(table);
|
|
929
|
+
const w = buildWhereClause(info, where, 1);
|
|
930
|
+
let sqlText = `DELETE FROM ${quoteIdent(info.name)}`;
|
|
931
|
+
if (w.sqlText)
|
|
932
|
+
sqlText += ` WHERE ${w.sqlText}`;
|
|
933
|
+
await unsafeLoggingClosedConnection(db, sqlText, w.values, {
|
|
934
|
+
operation: "deleteMany",
|
|
935
|
+
table: info.name,
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
function insertEntries(info, values) {
|
|
939
|
+
return Object.entries(values)
|
|
940
|
+
.filter(([k]) => info.hasColumn(k))
|
|
941
|
+
.map(([k, v]) => {
|
|
942
|
+
const col = info.columnOf(k);
|
|
943
|
+
return { field: k, col, prepared: prepareValue(v, info.pgTypeOf(col)) };
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
// Exported for the shadow-proof regression test — `table.columns` would be the
|
|
947
|
+
// drizzle handle (not the PK list) when an entity has a field named `columns`.
|
|
948
|
+
export function resolveConflictColumns(table, info, conflictKeys) {
|
|
949
|
+
if (conflictKeys !== undefined && conflictKeys.length > 0) {
|
|
950
|
+
return conflictKeys.map((field) => info.columnOf(field));
|
|
951
|
+
}
|
|
952
|
+
// Read the shadow-proof meta — `table.columns` directly would be the handle
|
|
953
|
+
// object when an entity has a field named `columns`.
|
|
954
|
+
const meta = asEntityTableMeta(table);
|
|
955
|
+
if (meta) {
|
|
956
|
+
const pks = meta.columns.filter((c) => c.primaryKey).map((c) => c.name);
|
|
957
|
+
if (pks.length > 0)
|
|
958
|
+
return pks;
|
|
959
|
+
}
|
|
960
|
+
if (info.hasColumn("id"))
|
|
961
|
+
return [info.columnOf("id")];
|
|
962
|
+
throw new Error("upsert: cannot infer conflict keys — pass conflictKeys explicitly");
|
|
963
|
+
}
|
|
964
|
+
function buildInsertSql(info, entries) {
|
|
965
|
+
if (entries.length === 0)
|
|
966
|
+
throw new Error("insert: empty values object");
|
|
967
|
+
const cols = entries.map((e) => quoteIdent(e.col)).join(", ");
|
|
968
|
+
const params = [];
|
|
969
|
+
const placeholders = entries
|
|
970
|
+
.map((e) => {
|
|
971
|
+
if (e.prepared.kind === "literal")
|
|
972
|
+
return e.prepared.literal;
|
|
973
|
+
params.push(e.prepared.bound);
|
|
974
|
+
return `$${params.length}${e.prepared.sql}`;
|
|
975
|
+
})
|
|
976
|
+
.join(", ");
|
|
977
|
+
const sqlPrefix = `INSERT INTO ${quoteIdent(info.name)} (${cols}) VALUES (${placeholders})`;
|
|
978
|
+
return { sqlPrefix, params };
|
|
979
|
+
}
|
|
980
|
+
export async function countWhere(db, table, where = {}) {
|
|
981
|
+
const info = extractTableInfo(table);
|
|
982
|
+
let sqlText = `SELECT COUNT(*)::int AS count FROM ${quoteIdent(info.name)}`;
|
|
983
|
+
let values = [];
|
|
984
|
+
if (Object.keys(where).length > 0) {
|
|
985
|
+
const w = buildWhereClause(info, where, 1);
|
|
986
|
+
sqlText += ` WHERE ${w.sqlText}`;
|
|
987
|
+
values = w.values;
|
|
988
|
+
}
|
|
989
|
+
const rows = (await unsafeReadRetrying(db, sqlText, values));
|
|
990
|
+
return rows[0]?.count ?? 0;
|
|
991
|
+
}
|
|
992
|
+
// biome-ignore lint/suspicious/noExplicitAny: see selectMany default
|
|
993
|
+
export async function upsertOnConflict(db, table, values, options) {
|
|
994
|
+
assertNotTenantScoped(db, "upsertOnConflict");
|
|
995
|
+
const info = extractTableInfo(table);
|
|
996
|
+
const entries = insertEntries(info, values);
|
|
997
|
+
const conflictCols = resolveConflictColumns(table, info, options.conflictKeys);
|
|
998
|
+
const conflictSet = new Set(conflictCols);
|
|
999
|
+
const { sqlPrefix, params } = buildInsertSql(info, entries);
|
|
1000
|
+
const updateParts = [];
|
|
1001
|
+
let idx = params.length + 1;
|
|
1002
|
+
if (options.update !== undefined) {
|
|
1003
|
+
for (const [field, value] of Object.entries(options.update)) {
|
|
1004
|
+
const col = info.columnOf(field);
|
|
1005
|
+
const p = prepareValue(value, info.pgTypeOf(col));
|
|
1006
|
+
if (p.kind === "literal") {
|
|
1007
|
+
updateParts.push(`${quoteIdent(col)} = ${p.literal}`);
|
|
1008
|
+
}
|
|
1009
|
+
else {
|
|
1010
|
+
updateParts.push(`${quoteIdent(col)} = $${idx++}${p.sql}`);
|
|
1011
|
+
params.push(p.bound);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
else {
|
|
1016
|
+
for (const e of entries) {
|
|
1017
|
+
if (conflictSet.has(e.col))
|
|
1018
|
+
continue;
|
|
1019
|
+
updateParts.push(`${quoteIdent(e.col)} = EXCLUDED.${quoteIdent(e.col)}`);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
if (updateParts.length === 0) {
|
|
1023
|
+
throw new Error("upsertOnConflict: nothing to update on conflict");
|
|
1024
|
+
}
|
|
1025
|
+
const conflictList = conflictCols.map((c) => quoteIdent(c)).join(", ");
|
|
1026
|
+
const sqlText = `${sqlPrefix} ON CONFLICT (${conflictList}) DO UPDATE SET ${updateParts.join(", ")} RETURNING *`;
|
|
1027
|
+
const rows = (await unsafeLoggingClosedConnection(db, sqlText, params, {
|
|
1028
|
+
operation: "upsertOnConflict",
|
|
1029
|
+
table: info.name,
|
|
1030
|
+
}));
|
|
1031
|
+
const first = rows[0];
|
|
1032
|
+
if (!first)
|
|
1033
|
+
return undefined;
|
|
1034
|
+
return coerceRow(first, info);
|
|
1035
|
+
}
|
|
1036
|
+
// biome-ignore lint/suspicious/noExplicitAny: see selectMany default
|
|
1037
|
+
export async function upsertByPk(db, table, values, updateOnConflict) {
|
|
1038
|
+
const info = extractTableInfo(table);
|
|
1039
|
+
const conflictKeys = resolveConflictColumns(table, info, undefined);
|
|
1040
|
+
const fieldKeys = conflictKeys.map((col) => info.fieldOf(col));
|
|
1041
|
+
return upsertOnConflict(db, table, values, {
|
|
1042
|
+
conflictKeys: fieldKeys,
|
|
1043
|
+
...(updateOnConflict !== undefined ? { update: updateOnConflict } : {}),
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
// biome-ignore lint/suspicious/noExplicitAny: see selectMany default
|
|
1047
|
+
export async function incrementCounter(db, table, values, increments, options = {}) {
|
|
1048
|
+
assertNotTenantScoped(db, "incrementCounter");
|
|
1049
|
+
const info = extractTableInfo(table);
|
|
1050
|
+
const entries = insertEntries(info, values);
|
|
1051
|
+
const conflictCols = resolveConflictColumns(table, info, options.conflictKeys);
|
|
1052
|
+
const conflictSet = new Set(conflictCols);
|
|
1053
|
+
const { sqlPrefix, params } = buildInsertSql(info, entries);
|
|
1054
|
+
const tableQ = quoteIdent(info.name);
|
|
1055
|
+
const updateParts = [];
|
|
1056
|
+
let idx = params.length + 1;
|
|
1057
|
+
for (const [field, delta] of Object.entries(increments)) {
|
|
1058
|
+
const col = info.columnOf(field);
|
|
1059
|
+
updateParts.push(`${quoteIdent(col)} = ${tableQ}.${quoteIdent(col)} + $${idx++}`);
|
|
1060
|
+
params.push(delta);
|
|
1061
|
+
}
|
|
1062
|
+
if (options.set !== undefined) {
|
|
1063
|
+
for (const [field, value] of Object.entries(options.set)) {
|
|
1064
|
+
const col = info.columnOf(field);
|
|
1065
|
+
const p = prepareValue(value, info.pgTypeOf(col));
|
|
1066
|
+
if (p.kind === "literal") {
|
|
1067
|
+
updateParts.push(`${quoteIdent(col)} = ${p.literal}`);
|
|
1068
|
+
}
|
|
1069
|
+
else {
|
|
1070
|
+
updateParts.push(`${quoteIdent(col)} = $${idx++}${p.sql}`);
|
|
1071
|
+
params.push(p.bound);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
for (const e of entries) {
|
|
1076
|
+
if (conflictSet.has(e.col))
|
|
1077
|
+
continue;
|
|
1078
|
+
if (Object.hasOwn(increments, e.field))
|
|
1079
|
+
continue;
|
|
1080
|
+
if (options.set !== undefined && Object.hasOwn(options.set, e.field))
|
|
1081
|
+
continue;
|
|
1082
|
+
updateParts.push(`${quoteIdent(e.col)} = EXCLUDED.${quoteIdent(e.col)}`);
|
|
1083
|
+
}
|
|
1084
|
+
if (updateParts.length === 0) {
|
|
1085
|
+
throw new Error("incrementCounter: nothing to update on conflict");
|
|
1086
|
+
}
|
|
1087
|
+
const conflictList = conflictCols.map((c) => quoteIdent(c)).join(", ");
|
|
1088
|
+
const sqlText = `${sqlPrefix} ON CONFLICT (${conflictList}) DO UPDATE SET ${updateParts.join(", ")} RETURNING *`;
|
|
1089
|
+
const rows = (await unsafeLoggingClosedConnection(db, sqlText, params, {
|
|
1090
|
+
operation: "incrementCounter",
|
|
1091
|
+
table: info.name,
|
|
1092
|
+
}));
|
|
1093
|
+
const first = rows[0];
|
|
1094
|
+
if (!first)
|
|
1095
|
+
return undefined;
|
|
1096
|
+
return coerceRow(first, info);
|
|
1097
|
+
}
|
|
1098
|
+
export async function deleteManyBatched(db, table, where, options) {
|
|
1099
|
+
const info = extractTableInfo(table);
|
|
1100
|
+
const w = buildWhereClause(info, where, 1);
|
|
1101
|
+
if (!w.sqlText) {
|
|
1102
|
+
throw new Error("deleteManyBatched: where clause required — refusing unbounded batch delete");
|
|
1103
|
+
}
|
|
1104
|
+
const limit = options.limit;
|
|
1105
|
+
if (!Number.isFinite(limit) || limit <= 0) {
|
|
1106
|
+
throw new Error("deleteManyBatched: limit must be a positive number");
|
|
1107
|
+
}
|
|
1108
|
+
const idField = options.idColumn ?? "id";
|
|
1109
|
+
const idCol = info.columnOf(idField);
|
|
1110
|
+
const tableQ = quoteIdent(info.name);
|
|
1111
|
+
const idQ = quoteIdent(idCol);
|
|
1112
|
+
const maxBatches = options.maxBatches ?? Number.POSITIVE_INFINITY;
|
|
1113
|
+
let deleted = 0;
|
|
1114
|
+
let batches = 0;
|
|
1115
|
+
while (batches < maxBatches) {
|
|
1116
|
+
const limitIdx = w.values.length + 1;
|
|
1117
|
+
const params = [...w.values, limit];
|
|
1118
|
+
const sqlText = `DELETE FROM ${tableQ} WHERE ${idQ} IN (
|
|
1119
|
+
SELECT ${idQ} FROM ${tableQ} WHERE ${w.sqlText} LIMIT $${limitIdx}
|
|
1120
|
+
) RETURNING ${idQ}`;
|
|
1121
|
+
const rows = (await unsafeLoggingClosedConnection(db, sqlText, params, {
|
|
1122
|
+
operation: "deleteManyBatched",
|
|
1123
|
+
table: info.name,
|
|
1124
|
+
}));
|
|
1125
|
+
batches++;
|
|
1126
|
+
deleted += rows.length;
|
|
1127
|
+
if (rows.length < limit)
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
return { deleted, batches };
|
|
1131
|
+
}
|
|
1132
|
+
export async function transaction(db, fn) {
|
|
1133
|
+
return (await asRawClient(db).begin(async (tx) => fn(tx)));
|
|
1134
|
+
}
|
|
1135
|
+
// A tx/savepoint handle has no begin(); fail closed instead of nesting silently or TypeError-ing.
|
|
1136
|
+
export async function runInNewTransaction(db, fn) {
|
|
1137
|
+
const raw = asRawClient(db);
|
|
1138
|
+
if (typeof raw.begin !== "function") {
|
|
1139
|
+
throw new InternalError({
|
|
1140
|
+
message: "runInNewTransaction: runner has no begin() — already inside a transaction or savepoint.",
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
// @cast-boundary driver tx handle → DbRunner at the single seam
|
|
1144
|
+
return raw.begin((tx) => fn(tx));
|
|
1145
|
+
}
|