@opensaas/stack-core 0.43.0 → 0.44.0-alpha.2
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/CHANGELOG.md +2753 -0
- package/README.md +182 -115
- package/dist/.build-hash +1 -0
- package/dist/access/declared-dependencies.d.ts +102 -88
- package/dist/access/declared-dependencies.d.ts.map +1 -1
- package/dist/access/declared-dependencies.js +83 -71
- package/dist/access/declared-dependencies.js.map +1 -1
- package/dist/access/depth-limits.d.ts +4 -0
- package/dist/access/depth-limits.d.ts.map +1 -1
- package/dist/access/depth-limits.js +4 -0
- package/dist/access/depth-limits.js.map +1 -1
- package/dist/access/engine.d.ts +68 -20
- package/dist/access/engine.d.ts.map +1 -1
- package/dist/access/engine.js +151 -37
- package/dist/access/engine.js.map +1 -1
- package/dist/access/errors.d.ts +33 -48
- package/dist/access/errors.d.ts.map +1 -1
- package/dist/access/errors.js +73 -63
- package/dist/access/errors.js.map +1 -1
- package/dist/access/field-access.d.ts +76 -5
- package/dist/access/field-access.d.ts.map +1 -1
- package/dist/access/field-access.js +235 -61
- package/dist/access/field-access.js.map +1 -1
- package/dist/access/field-visibility.d.ts +50 -4
- package/dist/access/field-visibility.d.ts.map +1 -1
- package/dist/access/field-visibility.js +143 -160
- package/dist/access/field-visibility.js.map +1 -1
- package/dist/access/index.d.ts +5 -12
- package/dist/access/index.d.ts.map +1 -1
- package/dist/access/index.js +6 -19
- package/dist/access/index.js.map +1 -1
- package/dist/access/orm-client.d.ts +19 -0
- package/dist/access/orm-client.d.ts.map +1 -0
- package/dist/access/orm-client.js +37 -0
- package/dist/access/orm-client.js.map +1 -0
- package/dist/access/query-validation.d.ts +7 -129
- package/dist/access/query-validation.d.ts.map +1 -1
- package/dist/access/query-validation.js +12 -314
- package/dist/access/query-validation.js.map +1 -1
- package/dist/access/system-fields.d.ts +2 -0
- package/dist/access/system-fields.d.ts.map +1 -0
- package/dist/access/system-fields.js +7 -0
- package/dist/access/system-fields.js.map +1 -0
- package/dist/access/transaction-registry.d.ts +25 -2
- package/dist/access/transaction-registry.d.ts.map +1 -1
- package/dist/access/transaction-registry.js +34 -17
- package/dist/access/transaction-registry.js.map +1 -1
- package/dist/access/types.d.ts +217 -131
- package/dist/access/types.d.ts.map +1 -1
- package/dist/config/field-kind.d.ts +66 -0
- package/dist/config/field-kind.d.ts.map +1 -0
- package/dist/config/field-kind.js +63 -0
- package/dist/config/field-kind.js.map +1 -0
- package/dist/config/hook-only-fields.d.ts +3 -0
- package/dist/config/hook-only-fields.d.ts.map +1 -0
- package/dist/config/hook-only-fields.js +17 -0
- package/dist/config/hook-only-fields.js.map +1 -0
- package/dist/config/index.d.ts +3 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +6 -3
- package/dist/config/index.js.map +1 -1
- package/dist/config/mcp-tool-names.d.ts +3 -0
- package/dist/config/mcp-tool-names.d.ts.map +1 -0
- package/dist/config/mcp-tool-names.js +25 -0
- package/dist/config/mcp-tool-names.js.map +1 -0
- package/dist/config/nav-count.d.ts.map +1 -1
- package/dist/config/nav-count.js +4 -4
- package/dist/config/nav-count.js.map +1 -1
- package/dist/config/plugin-engine.d.ts +8 -2
- package/dist/config/plugin-engine.d.ts.map +1 -1
- package/dist/config/plugin-engine.js +102 -38
- package/dist/config/plugin-engine.js.map +1 -1
- package/dist/config/types.d.ts +1035 -611
- package/dist/config/types.d.ts.map +1 -1
- package/dist/context/apply-defaults.d.ts +18 -1
- package/dist/context/apply-defaults.d.ts.map +1 -1
- package/dist/context/apply-defaults.js +30 -4
- package/dist/context/apply-defaults.js.map +1 -1
- package/dist/context/engine-context.d.ts +73 -0
- package/dist/context/engine-context.d.ts.map +1 -0
- package/dist/context/engine-context.js +67 -0
- package/dist/context/engine-context.js.map +1 -0
- package/dist/context/hook-pipeline.d.ts +9 -2
- package/dist/context/hook-pipeline.d.ts.map +1 -1
- package/dist/context/hook-pipeline.js +5 -4
- package/dist/context/hook-pipeline.js.map +1 -1
- package/dist/context/index.d.ts +98 -89
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +917 -722
- package/dist/context/index.js.map +1 -1
- package/dist/context/junction.d.ts +59 -0
- package/dist/context/junction.d.ts.map +1 -0
- package/dist/context/junction.js +126 -0
- package/dist/context/junction.js.map +1 -0
- package/dist/context/plugin-field-read.d.ts +33 -0
- package/dist/context/plugin-field-read.d.ts.map +1 -0
- package/dist/context/plugin-field-read.js +41 -0
- package/dist/context/plugin-field-read.js.map +1 -0
- package/dist/context/plugin-field-write.d.ts +104 -0
- package/dist/context/plugin-field-write.d.ts.map +1 -0
- package/dist/context/plugin-field-write.js +184 -0
- package/dist/context/plugin-field-write.js.map +1 -0
- package/dist/context/relationship-input.d.ts +146 -0
- package/dist/context/relationship-input.d.ts.map +1 -0
- package/dist/context/relationship-input.js +453 -0
- package/dist/context/relationship-input.js.map +1 -0
- package/dist/context/transaction-boundary.d.ts +54 -28
- package/dist/context/transaction-boundary.d.ts.map +1 -1
- package/dist/context/transaction-boundary.js +87 -169
- package/dist/context/transaction-boundary.js.map +1 -1
- package/dist/context/write-pipeline.d.ts +33 -51
- package/dist/context/write-pipeline.d.ts.map +1 -1
- package/dist/context/write-pipeline.js +372 -185
- package/dist/context/write-pipeline.js.map +1 -1
- package/dist/contract/dependencies.d.ts +88 -0
- package/dist/contract/dependencies.d.ts.map +1 -0
- package/dist/contract/dependencies.js +237 -0
- package/dist/contract/dependencies.js.map +1 -0
- package/dist/contract/derive.d.ts +49 -0
- package/dist/contract/derive.d.ts.map +1 -0
- package/dist/contract/derive.js +629 -0
- package/dist/contract/derive.js.map +1 -0
- package/dist/contract/fixtures/contract-configs.d.ts +64 -0
- package/dist/contract/fixtures/contract-configs.d.ts.map +1 -0
- package/dist/contract/fixtures/contract-configs.js +345 -0
- package/dist/contract/fixtures/contract-configs.js.map +1 -0
- package/dist/contract/id-boundary.d.ts +53 -0
- package/dist/contract/id-boundary.d.ts.map +1 -0
- package/dist/contract/id-boundary.js +76 -0
- package/dist/contract/id-boundary.js.map +1 -0
- package/dist/contract/index.d.ts +8 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +11 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/prisma.d.ts +58 -0
- package/dist/contract/prisma.d.ts.map +1 -0
- package/dist/contract/prisma.js +294 -0
- package/dist/contract/prisma.js.map +1 -0
- package/dist/contract/relation-graph.d.ts +70 -0
- package/dist/contract/relation-graph.d.ts.map +1 -0
- package/dist/contract/relation-graph.js +113 -0
- package/dist/contract/relation-graph.js.map +1 -0
- package/dist/contract/types.d.ts +153 -0
- package/dist/contract/types.d.ts.map +1 -0
- package/dist/contract/types.js +2 -0
- package/dist/contract/types.js.map +1 -0
- package/dist/db/client.d.ts +55 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +73 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/dev-database.d.ts +124 -0
- package/dist/db/dev-database.d.ts.map +1 -0
- package/dist/db/dev-database.js +291 -0
- package/dist/db/dev-database.js.map +1 -0
- package/dist/db/password-front.d.ts +10 -0
- package/dist/db/password-front.d.ts.map +1 -0
- package/dist/db/password-front.js +147 -0
- package/dist/db/password-front.js.map +1 -0
- package/dist/db/process-identity.d.ts +36 -0
- package/dist/db/process-identity.d.ts.map +1 -0
- package/dist/db/process-identity.js +114 -0
- package/dist/db/process-identity.js.map +1 -0
- package/dist/db/state-file.d.ts +54 -0
- package/dist/db/state-file.d.ts.map +1 -0
- package/dist/db/state-file.js +91 -0
- package/dist/db/state-file.js.map +1 -0
- package/dist/db/url.d.ts +89 -0
- package/dist/db/url.d.ts.map +1 -0
- package/dist/db/url.js +118 -0
- package/dist/db/url.js.map +1 -0
- package/dist/extend.d.ts +13 -2
- package/dist/extend.d.ts.map +1 -1
- package/dist/extend.js +24 -1
- package/dist/extend.js.map +1 -1
- package/dist/fields/index.d.ts +87 -42
- package/dist/fields/index.d.ts.map +1 -1
- package/dist/fields/index.js +462 -678
- package/dist/fields/index.js.map +1 -1
- package/dist/filter/collect.d.ts +3 -4
- package/dist/filter/collect.d.ts.map +1 -1
- package/dist/filter/collect.js +2 -2
- package/dist/filter/collect.js.map +1 -1
- package/dist/filter/index.d.ts +1 -2
- package/dist/filter/index.d.ts.map +1 -1
- package/dist/filter/index.js +0 -1
- package/dist/filter/index.js.map +1 -1
- package/dist/filter/map.d.ts +12 -5
- package/dist/filter/map.d.ts.map +1 -1
- package/dist/filter/map.js +47 -19
- package/dist/filter/map.js.map +1 -1
- package/dist/filter/types.d.ts +10 -24
- package/dist/filter/types.d.ts.map +1 -1
- package/dist/filter/types.js +2 -11
- package/dist/filter/types.js.map +1 -1
- package/dist/hooks/index.d.ts +22 -31
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +33 -37
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/transition-guard.d.ts +61 -0
- package/dist/hooks/transition-guard.d.ts.map +1 -0
- package/dist/hooks/transition-guard.js +93 -0
- package/dist/hooks/transition-guard.js.map +1 -0
- package/dist/index.d.ts +52 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +105 -51
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +4 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +16 -0
- package/dist/internal.js.map +1 -1
- package/dist/lib/case-utils.d.ts +0 -1
- package/dist/lib/case-utils.d.ts.map +1 -1
- package/dist/lib/case-utils.js +0 -3
- package/dist/lib/case-utils.js.map +1 -1
- package/dist/lib/client-safe-error.d.ts +9 -0
- package/dist/lib/client-safe-error.d.ts.map +1 -0
- package/dist/lib/client-safe-error.js +23 -0
- package/dist/lib/client-safe-error.js.map +1 -0
- package/dist/lib/database-errors.d.ts +78 -0
- package/dist/lib/database-errors.d.ts.map +1 -0
- package/dist/lib/database-errors.js +148 -0
- package/dist/lib/database-errors.js.map +1 -0
- package/dist/lib/null-prototype-registry.d.ts +9 -0
- package/dist/lib/null-prototype-registry.d.ts.map +1 -0
- package/dist/lib/null-prototype-registry.js +11 -0
- package/dist/lib/null-prototype-registry.js.map +1 -0
- package/dist/lib/prisma-errors.d.ts +30 -32
- package/dist/lib/prisma-errors.d.ts.map +1 -1
- package/dist/lib/prisma-errors.js +86 -46
- package/dist/lib/prisma-errors.js.map +1 -1
- package/dist/lib/process-global.d.ts +23 -0
- package/dist/lib/process-global.d.ts.map +1 -0
- package/dist/lib/process-global.js +33 -0
- package/dist/lib/process-global.js.map +1 -0
- package/dist/lib/warn-once.d.ts +7 -0
- package/dist/lib/warn-once.d.ts.map +1 -0
- package/dist/lib/warn-once.js +13 -0
- package/dist/lib/warn-once.js.map +1 -0
- package/dist/mcp/advertise.d.ts +16 -0
- package/dist/mcp/advertise.d.ts.map +1 -0
- package/dist/mcp/advertise.js +25 -0
- package/dist/mcp/advertise.js.map +1 -0
- package/dist/mcp/arguments.d.ts +10 -0
- package/dist/mcp/arguments.d.ts.map +1 -0
- package/dist/mcp/arguments.js +143 -0
- package/dist/mcp/arguments.js.map +1 -0
- package/dist/mcp/field-schema.d.ts +50 -5
- package/dist/mcp/field-schema.d.ts.map +1 -1
- package/dist/mcp/field-schema.js +137 -14
- package/dist/mcp/field-schema.js.map +1 -1
- package/dist/mcp/handler.d.ts +16 -5
- package/dist/mcp/handler.d.ts.map +1 -1
- package/dist/mcp/handler.js +404 -126
- package/dist/mcp/handler.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/projection.d.ts +42 -34
- package/dist/mcp/projection.d.ts.map +1 -1
- package/dist/mcp/projection.js +246 -200
- package/dist/mcp/projection.js.map +1 -1
- package/dist/mcp/tool-error.d.ts +8 -0
- package/dist/mcp/tool-error.d.ts.map +1 -0
- package/dist/mcp/tool-error.js +11 -0
- package/dist/mcp/tool-error.js.map +1 -0
- package/dist/mcp/types.d.ts +3 -2
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/where-id-boundary.d.ts +28 -0
- package/dist/mcp/where-id-boundary.d.ts.map +1 -0
- package/dist/mcp/where-id-boundary.js +187 -0
- package/dist/mcp/where-id-boundary.js.map +1 -0
- package/dist/origin.d.ts +147 -0
- package/dist/origin.d.ts.map +1 -0
- package/dist/origin.js +191 -0
- package/dist/origin.js.map +1 -0
- package/dist/query/relationship-options.d.ts +35 -6
- package/dist/query/relationship-options.d.ts.map +1 -1
- package/dist/query/relationship-options.js +33 -23
- package/dist/query/relationship-options.js.map +1 -1
- package/dist/secured/aggregate.d.ts +32 -0
- package/dist/secured/aggregate.d.ts.map +1 -0
- package/dist/secured/aggregate.js +31 -0
- package/dist/secured/aggregate.js.map +1 -0
- package/dist/secured/include.d.ts +320 -0
- package/dist/secured/include.d.ts.map +1 -0
- package/dist/secured/include.js +650 -0
- package/dist/secured/include.js.map +1 -0
- package/dist/secured/lock.d.ts +127 -0
- package/dist/secured/lock.d.ts.map +1 -0
- package/dist/secured/lock.js +275 -0
- package/dist/secured/lock.js.map +1 -0
- package/dist/secured/lower.d.ts +82 -0
- package/dist/secured/lower.d.ts.map +1 -0
- package/dist/secured/lower.js +162 -0
- package/dist/secured/lower.js.map +1 -0
- package/dist/secured/operators.d.ts +7 -0
- package/dist/secured/operators.d.ts.map +1 -0
- package/dist/secured/operators.js +18 -0
- package/dist/secured/operators.js.map +1 -0
- package/dist/secured/read.d.ts +208 -0
- package/dist/secured/read.d.ts.map +1 -0
- package/dist/secured/read.js +1245 -0
- package/dist/secured/read.js.map +1 -0
- package/dist/secured/select.d.ts +87 -0
- package/dist/secured/select.d.ts.map +1 -0
- package/dist/secured/select.js +250 -0
- package/dist/secured/select.js.map +1 -0
- package/dist/secured/vector.d.ts +58 -0
- package/dist/secured/vector.d.ts.map +1 -0
- package/dist/secured/vector.js +113 -0
- package/dist/secured/vector.js.map +1 -0
- package/dist/secured/vocabulary.d.ts +227 -0
- package/dist/secured/vocabulary.d.ts.map +1 -0
- package/dist/secured/vocabulary.js +578 -0
- package/dist/secured/vocabulary.js.map +1 -0
- package/dist/secured/write.d.ts +58 -0
- package/dist/secured/write.d.ts.map +1 -0
- package/dist/secured/write.js +87 -0
- package/dist/secured/write.js.map +1 -0
- package/dist/testing/context.d.ts +236 -0
- package/dist/testing/context.d.ts.map +1 -0
- package/dist/testing/context.js +457 -0
- package/dist/testing/context.js.map +1 -0
- package/dist/testing/escape.d.ts +83 -0
- package/dist/testing/escape.d.ts.map +1 -0
- package/dist/testing/escape.js +148 -0
- package/dist/testing/escape.js.map +1 -0
- package/dist/testing/extensions.d.ts +48 -0
- package/dist/testing/extensions.d.ts.map +1 -0
- package/dist/testing/extensions.js +107 -0
- package/dist/testing/extensions.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +11 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/plans.d.ts +64 -0
- package/dist/testing/plans.d.ts.map +1 -0
- package/dist/testing/plans.js +47 -0
- package/dist/testing/plans.js.map +1 -0
- package/dist/types/context.d.ts +110 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +2 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/contract.d.ts +198 -0
- package/dist/types/contract.d.ts.map +1 -0
- package/dist/types/contract.js +2 -0
- package/dist/types/contract.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/inputs.d.ts +83 -0
- package/dist/types/inputs.d.ts.map +1 -0
- package/dist/types/inputs.js +2 -0
- package/dist/types/inputs.js.map +1 -0
- package/dist/types/rows.d.ts +76 -0
- package/dist/types/rows.d.ts.map +1 -0
- package/dist/types/rows.js +2 -0
- package/dist/types/rows.js.map +1 -0
- package/dist/types/secured-list.d.ts +396 -0
- package/dist/types/secured-list.d.ts.map +1 -0
- package/dist/types/secured-list.js +2 -0
- package/dist/types/secured-list.js.map +1 -0
- package/dist/unsafe.d.ts +162 -0
- package/dist/unsafe.d.ts.map +1 -0
- package/dist/unsafe.js +177 -0
- package/dist/unsafe.js.map +1 -0
- package/dist/validation/config-refusal.d.ts +16 -0
- package/dist/validation/config-refusal.d.ts.map +1 -0
- package/dist/validation/config-refusal.js +2 -0
- package/dist/validation/config-refusal.js.map +1 -0
- package/dist/validation/database-config.d.ts +19 -0
- package/dist/validation/database-config.d.ts.map +1 -0
- package/dist/validation/database-config.js +237 -0
- package/dist/validation/database-config.js.map +1 -0
- package/dist/validation/default-value.d.ts +21 -0
- package/dist/validation/default-value.d.ts.map +1 -0
- package/dist/validation/default-value.js +72 -0
- package/dist/validation/default-value.js.map +1 -0
- package/dist/validation/extension-packs.d.ts +11 -0
- package/dist/validation/extension-packs.d.ts.map +1 -0
- package/dist/validation/extension-packs.js +53 -0
- package/dist/validation/extension-packs.js.map +1 -0
- package/dist/validation/field-config.d.ts +35 -21
- package/dist/validation/field-config.d.ts.map +1 -1
- package/dist/validation/field-config.js +51 -41
- package/dist/validation/field-config.js.map +1 -1
- package/dist/validation/field-names.d.ts +15 -0
- package/dist/validation/field-names.d.ts.map +1 -0
- package/dist/validation/field-names.js +155 -0
- package/dist/validation/field-names.js.map +1 -0
- package/dist/validation/identifier-names.d.ts +4 -0
- package/dist/validation/identifier-names.d.ts.map +1 -0
- package/dist/validation/identifier-names.js +39 -0
- package/dist/validation/identifier-names.js.map +1 -0
- package/dist/validation/needs-closure.d.ts +20 -30
- package/dist/validation/needs-closure.d.ts.map +1 -1
- package/dist/validation/needs-closure.js +29 -105
- package/dist/validation/needs-closure.js.map +1 -1
- package/dist/validation/relations.d.ts +17 -0
- package/dist/validation/relations.d.ts.map +1 -0
- package/dist/validation/relations.js +268 -0
- package/dist/validation/relations.js.map +1 -0
- package/dist/validation/schema.d.ts.map +1 -1
- package/dist/validation/schema.js +1 -3
- package/dist/validation/schema.js.map +1 -1
- package/dist/where/like.d.ts +32 -0
- package/dist/where/like.d.ts.map +1 -0
- package/dist/where/like.js +42 -0
- package/dist/where/like.js.map +1 -0
- package/package.json +70 -8
- package/.turbo/turbo-build.log +0 -4
- package/CLAUDE.md +0 -609
- package/dist/access/access-filter.d.ts +0 -241
- package/dist/access/access-filter.d.ts.map +0 -1
- package/dist/access/access-filter.js +0 -692
- package/dist/access/access-filter.js.map +0 -1
- package/dist/access/access-filter.test.d.ts +0 -2
- package/dist/access/access-filter.test.d.ts.map +0 -1
- package/dist/access/access-filter.test.js +0 -1256
- package/dist/access/access-filter.test.js.map +0 -1
- package/dist/access/declared-dependencies.test.d.ts +0 -2
- package/dist/access/declared-dependencies.test.d.ts.map +0 -1
- package/dist/access/declared-dependencies.test.js +0 -226
- package/dist/access/declared-dependencies.test.js.map +0 -1
- package/dist/access/denied-relation-visibility.test.d.ts +0 -2
- package/dist/access/denied-relation-visibility.test.d.ts.map +0 -1
- package/dist/access/denied-relation-visibility.test.js +0 -114
- package/dist/access/denied-relation-visibility.test.js.map +0 -1
- package/dist/access/engine.test.d.ts +0 -2
- package/dist/access/engine.test.d.ts.map +0 -1
- package/dist/access/engine.test.js +0 -56
- package/dist/access/engine.test.js.map +0 -1
- package/dist/access/field-access.test.d.ts +0 -2
- package/dist/access/field-access.test.d.ts.map +0 -1
- package/dist/access/field-access.test.js +0 -635
- package/dist/access/field-access.test.js.map +0 -1
- package/dist/access/multi-column-read-write.test.d.ts +0 -2
- package/dist/access/multi-column-read-write.test.d.ts.map +0 -1
- package/dist/access/multi-column-read-write.test.js +0 -183
- package/dist/access/multi-column-read-write.test.js.map +0 -1
- package/dist/access/relationship-count.d.ts +0 -98
- package/dist/access/relationship-count.d.ts.map +0 -1
- package/dist/access/relationship-count.js +0 -262
- package/dist/access/relationship-count.js.map +0 -1
- package/dist/access/relationship-count.test.d.ts +0 -2
- package/dist/access/relationship-count.test.d.ts.map +0 -1
- package/dist/access/relationship-count.test.js +0 -247
- package/dist/access/relationship-count.test.js.map +0 -1
- package/dist/access/relationship-label-filter.d.ts +0 -45
- package/dist/access/relationship-label-filter.d.ts.map +0 -1
- package/dist/access/relationship-label-filter.js +0 -22
- package/dist/access/relationship-label-filter.js.map +0 -1
- package/dist/access/relationship-label-filter.test.d.ts +0 -2
- package/dist/access/relationship-label-filter.test.d.ts.map +0 -1
- package/dist/access/relationship-label-filter.test.js +0 -89
- package/dist/access/relationship-label-filter.test.js.map +0 -1
- package/dist/access/synthetic-include-read.test.d.ts +0 -2
- package/dist/access/synthetic-include-read.test.d.ts.map +0 -1
- package/dist/access/synthetic-include-read.test.js +0 -121
- package/dist/access/synthetic-include-read.test.js.map +0 -1
- package/dist/context/nested-operations.d.ts +0 -74
- package/dist/context/nested-operations.d.ts.map +0 -1
- package/dist/context/nested-operations.js +0 -847
- package/dist/context/nested-operations.js.map +0 -1
- package/dist/fields/calendar-day.test.d.ts +0 -2
- package/dist/fields/calendar-day.test.d.ts.map +0 -1
- package/dist/fields/calendar-day.test.js +0 -246
- package/dist/fields/calendar-day.test.js.map +0 -1
- package/dist/fields/format-prisma-default.d.ts +0 -35
- package/dist/fields/format-prisma-default.d.ts.map +0 -1
- package/dist/fields/format-prisma-default.js +0 -49
- package/dist/fields/format-prisma-default.js.map +0 -1
- package/dist/fields/format-prisma-default.test.d.ts +0 -2
- package/dist/fields/format-prisma-default.test.d.ts.map +0 -1
- package/dist/fields/format-prisma-default.test.js +0 -54
- package/dist/fields/format-prisma-default.test.js.map +0 -1
- package/dist/fields/relationship-foreign-key.test.d.ts +0 -2
- package/dist/fields/relationship-foreign-key.test.d.ts.map +0 -1
- package/dist/fields/relationship-foreign-key.test.js +0 -18
- package/dist/fields/relationship-foreign-key.test.js.map +0 -1
- package/dist/fields/select.test.d.ts +0 -2
- package/dist/fields/select.test.d.ts.map +0 -1
- package/dist/fields/select.test.js +0 -279
- package/dist/fields/select.test.js.map +0 -1
- package/dist/fields/text-keystone-compat.test.d.ts +0 -2
- package/dist/fields/text-keystone-compat.test.d.ts.map +0 -1
- package/dist/fields/text-keystone-compat.test.js +0 -93
- package/dist/fields/text-keystone-compat.test.js.map +0 -1
- package/dist/filter/filter.test.d.ts +0 -2
- package/dist/filter/filter.test.d.ts.map +0 -1
- package/dist/filter/filter.test.js +0 -431
- package/dist/filter/filter.test.js.map +0 -1
- package/dist/filter/serialize.test.d.ts +0 -2
- package/dist/filter/serialize.test.d.ts.map +0 -1
- package/dist/filter/serialize.test.js +0 -83
- package/dist/filter/serialize.test.js.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/dist/index.test.js +0 -33
- package/dist/index.test.js.map +0 -1
- package/dist/lib/case-utils.test.d.ts +0 -2
- package/dist/lib/case-utils.test.d.ts.map +0 -1
- package/dist/lib/case-utils.test.js +0 -123
- package/dist/lib/case-utils.test.js.map +0 -1
- package/dist/query/index.d.ts +0 -127
- package/dist/query/index.d.ts.map +0 -1
- package/dist/query/index.js +0 -179
- package/dist/query/index.js.map +0 -1
- package/dist/query/index.test.d.ts +0 -2
- package/dist/query/index.test.d.ts.map +0 -1
- package/dist/query/index.test.js +0 -632
- package/dist/query/index.test.js.map +0 -1
- package/dist/query/relationship-options.test.d.ts +0 -2
- package/dist/query/relationship-options.test.d.ts.map +0 -1
- package/dist/query/relationship-options.test.js +0 -150
- package/dist/query/relationship-options.test.js.map +0 -1
- package/dist/validation/field-config.test.d.ts +0 -2
- package/dist/validation/field-config.test.d.ts.map +0 -1
- package/dist/validation/field-config.test.js +0 -159
- package/dist/validation/field-config.test.js.map +0 -1
- package/dist/validation/schema.test.d.ts +0 -2
- package/dist/validation/schema.test.d.ts.map +0 -1
- package/dist/validation/schema.test.js +0 -409
- package/dist/validation/schema.test.js.map +0 -1
- package/docs/type-distribution-fix.md +0 -136
- package/src/access/access-filter.test.ts +0 -1919
- package/src/access/access-filter.ts +0 -1041
- package/src/access/declared-dependencies.test.ts +0 -277
- package/src/access/declared-dependencies.ts +0 -220
- package/src/access/denied-relation-visibility.test.ts +0 -173
- package/src/access/depth-limits.ts +0 -27
- package/src/access/engine.test.ts +0 -67
- package/src/access/engine.ts +0 -193
- package/src/access/errors.ts +0 -242
- package/src/access/field-access.test.ts +0 -792
- package/src/access/field-access.ts +0 -353
- package/src/access/field-transforms.ts +0 -68
- package/src/access/field-visibility.ts +0 -569
- package/src/access/index.ts +0 -82
- package/src/access/multi-column-read-write.test.ts +0 -305
- package/src/access/query-validation.ts +0 -486
- package/src/access/relationship-count.test.ts +0 -344
- package/src/access/relationship-count.ts +0 -346
- package/src/access/relationship-label-filter.test.ts +0 -128
- package/src/access/relationship-label-filter.ts +0 -63
- package/src/access/synthetic-include-read.test.ts +0 -179
- package/src/access/transaction-registry.ts +0 -58
- package/src/access/types.ts +0 -391
- package/src/config/index.ts +0 -177
- package/src/config/label.ts +0 -51
- package/src/config/nav-count.ts +0 -77
- package/src/config/plugin-engine.ts +0 -261
- package/src/config/types.ts +0 -3270
- package/src/context/apply-defaults.ts +0 -47
- package/src/context/hook-pipeline.ts +0 -137
- package/src/context/index.ts +0 -1737
- package/src/context/nested-operations.ts +0 -1470
- package/src/context/transaction-boundary.ts +0 -485
- package/src/context/write-pipeline.ts +0 -732
- package/src/extend.ts +0 -28
- package/src/fields/calendar-day.test.ts +0 -291
- package/src/fields/format-prisma-default.test.ts +0 -64
- package/src/fields/format-prisma-default.ts +0 -64
- package/src/fields/index.ts +0 -1901
- package/src/fields/relationship-foreign-key.test.ts +0 -29
- package/src/fields/select.test.ts +0 -336
- package/src/fields/text-keystone-compat.test.ts +0 -126
- package/src/filter/collect.ts +0 -108
- package/src/filter/filter.test.ts +0 -538
- package/src/filter/index.ts +0 -26
- package/src/filter/map.ts +0 -63
- package/src/filter/parse.ts +0 -99
- package/src/filter/serialize.test.ts +0 -115
- package/src/filter/serialize.ts +0 -73
- package/src/filter/types.ts +0 -120
- package/src/hooks/index.ts +0 -752
- package/src/index.test.ts +0 -50
- package/src/index.ts +0 -192
- package/src/internal.ts +0 -61
- package/src/lib/case-utils.test.ts +0 -159
- package/src/lib/case-utils.ts +0 -68
- package/src/lib/prisma-errors.ts +0 -86
- package/src/mcp/constants.ts +0 -24
- package/src/mcp/field-schema.ts +0 -84
- package/src/mcp/handler.ts +0 -633
- package/src/mcp/index.ts +0 -7
- package/src/mcp/projection.ts +0 -497
- package/src/mcp/types.ts +0 -18
- package/src/query/index.test.ts +0 -830
- package/src/query/index.ts +0 -352
- package/src/query/relationship-options.test.ts +0 -194
- package/src/query/relationship-options.ts +0 -78
- package/src/utils/password.ts +0 -80
- package/src/validation/field-config.test.ts +0 -199
- package/src/validation/field-config.ts +0 -139
- package/src/validation/needs-closure.ts +0 -188
- package/src/validation/schema.test.ts +0 -487
- package/src/validation/schema.ts +0 -51
- package/tests/access-relationships.test.ts +0 -646
- package/tests/access.test.ts +0 -590
- package/tests/apply-defaults.test.ts +0 -119
- package/tests/bare-read-scalars.test.ts +0 -147
- package/tests/computed-field-selective-evaluation.test.ts +0 -418
- package/tests/config.test.ts +0 -242
- package/tests/context.test.ts +0 -3146
- package/tests/default-value-create.test.ts +0 -299
- package/tests/field-hooks.test.ts +0 -410
- package/tests/field-types.test.ts +0 -1291
- package/tests/hook-context-secured.test.ts +0 -424
- package/tests/hook-pipeline.test.ts +0 -233
- package/tests/hooks.test.ts +0 -481
- package/tests/interactive-transaction.test.ts +0 -444
- package/tests/label.test.ts +0 -135
- package/tests/mcp-fields-projection-access.test.ts +0 -250
- package/tests/mcp-handler.test.ts +0 -1411
- package/tests/multi-column-validation-ordering.test.ts +0 -305
- package/tests/nav-count.test.ts +0 -189
- package/tests/needs-declared-dependencies.test.ts +0 -503
- package/tests/nested-access-and-hooks.test.ts +0 -2566
- package/tests/nested-operation-registry.test.ts +0 -317
- package/tests/nested-write-hooks.test.ts +0 -864
- package/tests/nested-write-synthetic-relation.test.ts +0 -437
- package/tests/password-type-distribution.test.ts +0 -154
- package/tests/password-types.test.ts +0 -174
- package/tests/password.test.ts +0 -263
- package/tests/plugin-engine.test.ts +0 -1155
- package/tests/prisma-errors.test.ts +0 -141
- package/tests/resolve-chain.test.ts +0 -411
- package/tests/singleton.test.ts +0 -421
- package/tests/sudo.test.ts +0 -676
- package/tests/to-one-include-access-filter.test.ts +0 -172
- package/tests/transaction-boundary-hooks.test.ts +0 -710
- package/tests/transaction-boundary-outermost.test.ts +0 -530
- package/tests/virtual-fields.test.ts +0 -421
- package/tests/with-session.test.ts +0 -243
- package/tests/write-pipeline.test.ts +0 -617
- package/tsconfig.json +0 -12
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -69
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { ColumnTypeDescriptor, ContractColumnDescriptor, ExtensionDescriptor, IdFieldStrategy, ReferentialAction } from '../config/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* How a model's `id` is minted: one of the config's {@link IdFieldStrategy}
|
|
4
|
+
* values, or `'singleton'` for a list declared `isSingleton` — an integer id
|
|
5
|
+
* defaulting to `1`, regardless of `db.idField` (ADR-0048).
|
|
6
|
+
*/
|
|
7
|
+
export type ContractIdStrategy = IdFieldStrategy | 'singleton';
|
|
8
|
+
/**
|
|
9
|
+
* A model's primary-key column. `type` is the column type a foreign key
|
|
10
|
+
* referencing this model must also carry.
|
|
11
|
+
*/
|
|
12
|
+
export type ContractIdColumn = {
|
|
13
|
+
strategy: ContractIdStrategy;
|
|
14
|
+
type: ColumnTypeDescriptor;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* One stored column of a model. The same shape a field builder describes
|
|
18
|
+
* ({@link ContractColumnDescriptor}) with any `db.nativeType` override already
|
|
19
|
+
* folded into {@link ColumnTypeDescriptor}, so `type` is the single source of
|
|
20
|
+
* the column's constructor. A foreign-key column appears here too, typed by
|
|
21
|
+
* the referenced model's id.
|
|
22
|
+
*/
|
|
23
|
+
export type ContractColumn = Omit<ContractColumnDescriptor, 'nativeType'>;
|
|
24
|
+
/**
|
|
25
|
+
* A foreign-key constraint from one of the model's columns to another model's
|
|
26
|
+
* `id`. `onDelete`/`onUpdate` are the relationship's `db` options; absent
|
|
27
|
+
* means the target's default action.
|
|
28
|
+
*/
|
|
29
|
+
export type ContractForeignKey = {
|
|
30
|
+
column: string;
|
|
31
|
+
references: {
|
|
32
|
+
model: string;
|
|
33
|
+
column: 'id';
|
|
34
|
+
};
|
|
35
|
+
/** The constraint's exact physical name, set under `db.indexNaming`. */
|
|
36
|
+
name?: string;
|
|
37
|
+
onDelete?: ReferentialAction;
|
|
38
|
+
onUpdate?: ReferentialAction;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* A table-level foreign key from `db.foreignKeys`, with every field resolved
|
|
42
|
+
* to its column. It carries no relation: nothing is included or connected
|
|
43
|
+
* through it.
|
|
44
|
+
*/
|
|
45
|
+
export type ContractCompositeForeignKey = {
|
|
46
|
+
columns: string[];
|
|
47
|
+
references: {
|
|
48
|
+
model: string;
|
|
49
|
+
columns: string[];
|
|
50
|
+
};
|
|
51
|
+
onDelete?: ReferentialAction;
|
|
52
|
+
onUpdate?: ReferentialAction;
|
|
53
|
+
name?: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* A model-level index or unique constraint from `db.indexes`, with every field
|
|
57
|
+
* name resolved to its column (a scalar's own name, or a relationship's
|
|
58
|
+
* `<field>Id`). `name` is the entry's declared name, adopted as the
|
|
59
|
+
* constraint's exact physical name (ADR-0040) — the option Prisma's builder
|
|
60
|
+
* spells `name:` on a unique and `map:` on an index at rc.8, where an index's
|
|
61
|
+
* `name:` is a wire-name prefix that gains a content hash.
|
|
62
|
+
*
|
|
63
|
+
* A single-field unique entry on the owning column of a one-to-one names the
|
|
64
|
+
* constraint that column carries implicitly (ADR-0064) instead of adding a
|
|
65
|
+
* second one; the column's own `unique` is then cleared.
|
|
66
|
+
*/
|
|
67
|
+
export type ContractIndex = {
|
|
68
|
+
columns: string[];
|
|
69
|
+
unique: boolean;
|
|
70
|
+
name?: string;
|
|
71
|
+
where?: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The relation builder a model-side relation lowers to (ADR-0064): the
|
|
75
|
+
* foreign-key owner is `belongsTo`; the other side is `hasMany` for a
|
|
76
|
+
* one-to-many and `hasOne` for a one-to-one.
|
|
77
|
+
*/
|
|
78
|
+
export type ContractRelationKind = 'belongsTo' | 'hasOne' | 'hasMany';
|
|
79
|
+
/**
|
|
80
|
+
* One relation on a model. `column` is the foreign-key column the relation is
|
|
81
|
+
* keyed by — on this model for `belongsTo` (`from`), on `target` for `hasOne`
|
|
82
|
+
* and `hasMany` (`by`). `oneToOne` is known from the config alone: Prisma's
|
|
83
|
+
* emitted cardinality is `N:1` on the owning side of a one-to-one, and the
|
|
84
|
+
* unique constraint on the owning column is what makes it one-to-one.
|
|
85
|
+
*/
|
|
86
|
+
export type ContractRelation = {
|
|
87
|
+
name: string;
|
|
88
|
+
target: string;
|
|
89
|
+
kind: ContractRelationKind;
|
|
90
|
+
column: string;
|
|
91
|
+
oneToOne: boolean;
|
|
92
|
+
/** A `from_<List>_<field>` back-relation synthesised for a list-only `ref`. */
|
|
93
|
+
synthetic: boolean;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Which auto-timestamp columns the model carries (`db.timestamps`, per list
|
|
97
|
+
* over the config default, off by default). `createdAt` takes a database
|
|
98
|
+
* `now()` default; `updatedAt` is maintained application-side with no
|
|
99
|
+
* database backstop (ADR-0048).
|
|
100
|
+
*/
|
|
101
|
+
export type ContractTimestamps = {
|
|
102
|
+
createdAt: boolean;
|
|
103
|
+
updatedAt: boolean;
|
|
104
|
+
};
|
|
105
|
+
/** A native enum type the contract declares once and enum columns reference. */
|
|
106
|
+
export type ContractEnum = {
|
|
107
|
+
name: string;
|
|
108
|
+
values: string[];
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* One list, as a contract model.
|
|
112
|
+
*/
|
|
113
|
+
export type ContractModel = {
|
|
114
|
+
/** The list key, which is also the model name. */
|
|
115
|
+
name: string;
|
|
116
|
+
/** The physical table name (`db.map`), when it differs from {@link name}. */
|
|
117
|
+
table?: string;
|
|
118
|
+
/** The Postgres schema the table lives in (`db.schema`); the default namespace when absent. */
|
|
119
|
+
namespace?: string;
|
|
120
|
+
singleton: boolean;
|
|
121
|
+
id: ContractIdColumn;
|
|
122
|
+
/** Stored columns in declaration order, excluding `id` and the auto-timestamps. */
|
|
123
|
+
columns: ContractColumn[];
|
|
124
|
+
/** The column type the auto-timestamps take, set only by `db.defaults.timestamp`. */
|
|
125
|
+
timestampType?: ColumnTypeDescriptor;
|
|
126
|
+
foreignKeys: ContractForeignKey[];
|
|
127
|
+
compositeForeignKeys?: ContractCompositeForeignKey[];
|
|
128
|
+
indexes: ContractIndex[];
|
|
129
|
+
relations: ContractRelation[];
|
|
130
|
+
timestamps: ContractTimestamps;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* The contract a config derives to (ADR-0057): plain, JSON-serialisable data
|
|
134
|
+
* that the CLI renders into the standalone Contract module and that
|
|
135
|
+
* `buildPrismaContract` feeds straight into Prisma's contract builder
|
|
136
|
+
* in-process. Nothing here is a function, a class instance or a `Date`, so
|
|
137
|
+
* the rendered module is fully literal by construction (ADR-0040).
|
|
138
|
+
*/
|
|
139
|
+
export type ContractData = {
|
|
140
|
+
/** Models in config list order. */
|
|
141
|
+
models: ContractModel[];
|
|
142
|
+
/**
|
|
143
|
+
* The Postgres schemas the contract declares beyond the default `public`:
|
|
144
|
+
* `db.schemas`, unioned with every `db.schema` a list uses. Prisma resolves
|
|
145
|
+
* a model's `namespace` against this list.
|
|
146
|
+
*/
|
|
147
|
+
namespaces: string[];
|
|
148
|
+
/** Native enums, deduplicated by name. */
|
|
149
|
+
enums: ContractEnum[];
|
|
150
|
+
/** The extension packs the contract declares (`db.extensions`, plus any a plugin added), deduplicated by name. */
|
|
151
|
+
extensions: ExtensionDescriptor[];
|
|
152
|
+
};
|
|
153
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/contract/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EAClB,MAAM,oBAAoB,CAAA;AAE3B;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG,WAAW,CAAA;AAE9D;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,IAAI,EAAE,oBAAoB,CAAA;CAC3B,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,wBAAwB,EAAE,YAAY,CAAC,CAAA;AAEzE;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,IAAI,CAAA;KAAE,CAAA;IAC3C,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,iBAAiB,CAAA;IAC5B,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC7B,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;IAChD,QAAQ,CAAC,EAAE,iBAAiB,CAAA;IAC5B,QAAQ,CAAC,EAAE,iBAAiB,CAAA;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAA;AAErE;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,oBAAoB,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,OAAO,CAAA;IACjB,+EAA+E;IAC/E,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,gFAAgF;AAChF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,+FAA+F;IAC/F,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,EAAE,EAAE,gBAAgB,CAAA;IACpB,mFAAmF;IACnF,OAAO,EAAE,cAAc,EAAE,CAAA;IACzB,qFAAqF;IACrF,aAAa,CAAC,EAAE,oBAAoB,CAAA;IACpC,WAAW,EAAE,kBAAkB,EAAE,CAAA;IACjC,oBAAoB,CAAC,EAAE,2BAA2B,EAAE,CAAA;IACpD,OAAO,EAAE,aAAa,EAAE,CAAA;IACxB,SAAS,EAAE,gBAAgB,EAAE,CAAA;IAC7B,UAAU,EAAE,kBAAkB,CAAA;CAC/B,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,mCAAmC;IACnC,MAAM,EAAE,aAAa,EAAE,CAAA;IACvB;;;;OAIG;IACH,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,0CAA0C;IAC1C,KAAK,EAAE,YAAY,EAAE,CAAA;IACrB,kHAAkH;IAClH,UAAU,EAAE,mBAAmB,EAAE,CAAA;CAClC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/contract/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PostgresOptionsBase, PostgresOptions } from '@prisma/orm-postgres/runtime';
|
|
2
|
+
import type { DatabaseClientConfig } from '../config/types.js';
|
|
3
|
+
import { type DatabaseUrlLookupOptions } from './url.js';
|
|
4
|
+
type PostgresBindingOptions = PostgresOptions<never>;
|
|
5
|
+
/**
|
|
6
|
+
* The connection half of the runtime client's construction options — what the
|
|
7
|
+
* generated context spreads into `postgres()` beside the contract, the
|
|
8
|
+
* extensions and the tripwire. Exactly one of `pg` and `url` is ever present.
|
|
9
|
+
*/
|
|
10
|
+
export interface RuntimeConnectionOptions {
|
|
11
|
+
/** A pool or client the runtime binds to instead of dialling `url` itself. */
|
|
12
|
+
readonly pg?: NonNullable<PostgresBindingOptions['pg']>;
|
|
13
|
+
/** The connection string, when the runtime opens its own pool. */
|
|
14
|
+
readonly url?: string;
|
|
15
|
+
/** Timeouts handed to the runtime's own pool, from `db.client.poolOptions`. */
|
|
16
|
+
readonly poolOptions?: PostgresOptionsBase['poolOptions'];
|
|
17
|
+
/** Present, and `false`, only on the Dev database (ADR-0063). */
|
|
18
|
+
readonly verifyMarker?: PostgresOptionsBase['verifyMarker'];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Choose how the generated runtime client connects, from the app's
|
|
22
|
+
* `db.client` binding and the stack's URL lookup (ADR-0049, ADR-0063).
|
|
23
|
+
*
|
|
24
|
+
* Three branches, in order:
|
|
25
|
+
*
|
|
26
|
+
* 1. `db.client.pg` — the app owns the pool. The factory is called here, and
|
|
27
|
+
* nowhere else, so a config load that never reaches the runtime opens no
|
|
28
|
+
* connection. Call this once per process, under the client singleton. An
|
|
29
|
+
* explicit pool wins outright, so it also displaces branch 2: a pool
|
|
30
|
+
* supplied while the Dev database is running gets neither workaround
|
|
31
|
+
* ADR-0063 requires, and is warned about rather than silently rebound.
|
|
32
|
+
* 2. Dev-database provenance — a single-connection pool with the contract
|
|
33
|
+
* marker check off.
|
|
34
|
+
* 3. An env URL — the connection string and Prisma's defaults.
|
|
35
|
+
*
|
|
36
|
+
* The pool built on branch 2 is not owned by anything: rc.8 installs
|
|
37
|
+
* `ownedDispose` for `kind: 'url'` bindings only, so nothing ends it. The dev
|
|
38
|
+
* loop's database is ephemeral and goes with the process, which is why that is
|
|
39
|
+
* survivable here and not on branch 1.
|
|
40
|
+
*
|
|
41
|
+
* @throws {DatabaseUrlUnresolvedError} on branch 2/3 when neither
|
|
42
|
+
* `DATABASE_URL` nor a running dev database supplies a connection.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* postgres<Contract>({
|
|
47
|
+
* contractJson,
|
|
48
|
+
* middleware: [originTripwire],
|
|
49
|
+
* ...resolveRuntimeConnection(config.db.client),
|
|
50
|
+
* })
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveRuntimeConnection(client?: DatabaseClientConfig, options?: DatabaseUrlLookupOptions): RuntimeConnectionOptions;
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/db/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACxF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAA8C,KAAK,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAUpG,KAAK,sBAAsB,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;AAEpD;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAA;IACvD,kEAAkE;IAClE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,+EAA+E;IAC/E,QAAQ,CAAC,WAAW,CAAC,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAA;IACzD,iEAAiE;IACjE,QAAQ,CAAC,YAAY,CAAC,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAA;CAC5D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,CAAC,EAAE,oBAAoB,EAC7B,OAAO,GAAE,wBAA6B,GACrC,wBAAwB,CAkC1B"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Pool } from 'pg';
|
|
2
|
+
import { findDatabaseConnection, resolveDatabaseUrl } from './url.js';
|
|
3
|
+
/**
|
|
4
|
+
* Prisma's own pool waits 20 s for a connection; pg's default is `0` — wait
|
|
5
|
+
* forever. A hand-built pool is not covered by rc.8's `poolOptions`, which
|
|
6
|
+
* `toRuntimeBinding()` applies to `kind: 'url'` bindings only, so the ceiling
|
|
7
|
+
* has to be set here or a stuck checkout wedges the single connection silently.
|
|
8
|
+
*/
|
|
9
|
+
const DEV_CONNECTION_TIMEOUT_MS = 20_000;
|
|
10
|
+
/**
|
|
11
|
+
* Choose how the generated runtime client connects, from the app's
|
|
12
|
+
* `db.client` binding and the stack's URL lookup (ADR-0049, ADR-0063).
|
|
13
|
+
*
|
|
14
|
+
* Three branches, in order:
|
|
15
|
+
*
|
|
16
|
+
* 1. `db.client.pg` — the app owns the pool. The factory is called here, and
|
|
17
|
+
* nowhere else, so a config load that never reaches the runtime opens no
|
|
18
|
+
* connection. Call this once per process, under the client singleton. An
|
|
19
|
+
* explicit pool wins outright, so it also displaces branch 2: a pool
|
|
20
|
+
* supplied while the Dev database is running gets neither workaround
|
|
21
|
+
* ADR-0063 requires, and is warned about rather than silently rebound.
|
|
22
|
+
* 2. Dev-database provenance — a single-connection pool with the contract
|
|
23
|
+
* marker check off.
|
|
24
|
+
* 3. An env URL — the connection string and Prisma's defaults.
|
|
25
|
+
*
|
|
26
|
+
* The pool built on branch 2 is not owned by anything: rc.8 installs
|
|
27
|
+
* `ownedDispose` for `kind: 'url'` bindings only, so nothing ends it. The dev
|
|
28
|
+
* loop's database is ephemeral and goes with the process, which is why that is
|
|
29
|
+
* survivable here and not on branch 1.
|
|
30
|
+
*
|
|
31
|
+
* @throws {DatabaseUrlUnresolvedError} on branch 2/3 when neither
|
|
32
|
+
* `DATABASE_URL` nor a running dev database supplies a connection.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* postgres<Contract>({
|
|
37
|
+
* contractJson,
|
|
38
|
+
* middleware: [originTripwire],
|
|
39
|
+
* ...resolveRuntimeConnection(config.db.client),
|
|
40
|
+
* })
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export function resolveRuntimeConnection(client, options = {}) {
|
|
44
|
+
const pg = client?.pg?.();
|
|
45
|
+
if (pg !== undefined) {
|
|
46
|
+
if (findDatabaseConnection(options)?.provenance === 'dev-database') {
|
|
47
|
+
console.warn('opensaas: db.client.pg is bound while the dev database is running, so this pool ' +
|
|
48
|
+
'replaces the single-connection binding that database needs (ADR-0063). Expect ' +
|
|
49
|
+
'corrupted session state and a deadlock on the contract marker; unset db.client.pg ' +
|
|
50
|
+
'to run against `opensaas dev`, or point DATABASE_URL at your own Postgres.');
|
|
51
|
+
}
|
|
52
|
+
return { pg };
|
|
53
|
+
}
|
|
54
|
+
const { url, provenance } = resolveDatabaseUrl(options);
|
|
55
|
+
if (provenance === 'dev-database') {
|
|
56
|
+
// `pglite-socket` multiplexes every connection onto one PGlite session, so
|
|
57
|
+
// a client spreading work across a pool corrupts its own session state,
|
|
58
|
+
// and the marker's first-use read deadlocks a request that opens a
|
|
59
|
+
// transaction. Both are properties of the Dev database, not of Postgres:
|
|
60
|
+
// do not lift either to the `url` branch, and do not drop them here
|
|
61
|
+
// (ADR-0063).
|
|
62
|
+
return {
|
|
63
|
+
pg: new Pool({
|
|
64
|
+
connectionString: url,
|
|
65
|
+
max: 1,
|
|
66
|
+
connectionTimeoutMillis: DEV_CONNECTION_TIMEOUT_MS,
|
|
67
|
+
}),
|
|
68
|
+
verifyMarker: false,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return client?.poolOptions !== undefined ? { url, poolOptions: client.poolOptions } : { url };
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/db/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AAGzB,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAiC,MAAM,UAAU,CAAA;AAEpG;;;;;GAKG;AACH,MAAM,yBAAyB,GAAG,MAAM,CAAA;AAoBxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAA6B,EAC7B,OAAO,GAA6B,EAAE;IAEtC,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,CAAA;IACzB,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,IAAI,sBAAsB,CAAC,OAAO,CAAC,EAAE,UAAU,KAAK,cAAc,EAAE,CAAC;YACnE,OAAO,CAAC,IAAI,CACV,kFAAkF;gBAChF,gFAAgF;gBAChF,oFAAoF;gBACpF,4EAA4E,CAC/E,CAAA;QACH,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,CAAA;IACf,CAAC;IAED,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAA;IAEvD,IAAI,UAAU,KAAK,cAAc,EAAE,CAAC;QAClC,2EAA2E;QAC3E,wEAAwE;QACxE,mEAAmE;QACnE,yEAAyE;QACzE,oEAAoE;QACpE,cAAc;QACd,OAAO;YACL,EAAE,EAAE,IAAI,IAAI,CAAC;gBACX,gBAAgB,EAAE,GAAG;gBACrB,GAAG,EAAE,CAAC;gBACN,uBAAuB,EAAE,yBAAyB;aACnD,CAAC;YACF,YAAY,EAAE,KAAK;SACpB,CAAA;IACH,CAAC;IAED,OAAO,MAAM,EAAE,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAA;AAC/F,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Dev database: an in-process PGlite the stack runs itself (ADR-0063).
|
|
3
|
+
*
|
|
4
|
+
* Known limits of this primitive:
|
|
5
|
+
*
|
|
6
|
+
* - Every TCP connection is multiplexed onto **one** PGlite session, so a
|
|
7
|
+
* client with a multi-connection pool corrupts its own session state.
|
|
8
|
+
* Clients bind a single connection; `maxConnections` only buys headroom for
|
|
9
|
+
* the several single-connection clients that share one sidecar. That
|
|
10
|
+
* headroom counts distinct PROCESSES (the app, the CLI, a seed, a `psql`) —
|
|
11
|
+
* the generated context's own client is one process-wide singleton
|
|
12
|
+
* regardless of how many times a bundler duplicates its module (ADR-0070),
|
|
13
|
+
* so one running app never claims more than one of these slots on its own.
|
|
14
|
+
* - A connection holding an open transaction holds the whole query queue.
|
|
15
|
+
* - PGlite opens a data directory in one process at a time. `startDevDatabase`
|
|
16
|
+
* enforces this against itself — a second call against the same `dataDir`
|
|
17
|
+
* fails naming the first — but the guard is a lock file inside that
|
|
18
|
+
* directory: a bare `new PGlite({ dataDir })` bypassing this primitive, or
|
|
19
|
+
* the lock file being deleted out from under a running sidecar, is not
|
|
20
|
+
* caught.
|
|
21
|
+
* - There is no daemon, registry or cross-process lookup: the database dies
|
|
22
|
+
* with the process that started it, and other processes find it through the
|
|
23
|
+
* state file.
|
|
24
|
+
* - Stale-sidecar detection (the state file's pid, and the `dataDir` lock's)
|
|
25
|
+
* compares process start times to tell a live pid from an unrelated process
|
|
26
|
+
* that inherited it after a reboot or pid wrap. The comparison is
|
|
27
|
+
* approximate — Linux assumes a 100 Hz clock, macOS's `ps` only carries
|
|
28
|
+
* one-second resolution — and unavailable on any other platform, where a
|
|
29
|
+
* live pid is trusted outright exactly as it was before this check existed.
|
|
30
|
+
* - An IPv6 `host` is bracketed into the published URL, which is the RFC 3986
|
|
31
|
+
* form; node-postgres does not strip those brackets when it parses a
|
|
32
|
+
* connection string, so such a client takes `host` and `port` off the handle
|
|
33
|
+
* instead of the URL.
|
|
34
|
+
* - PGlite is served on a unix socket in a 0700 temp directory; the TCP port
|
|
35
|
+
* is a cleartext-password front carrying a per-boot password in the URL.
|
|
36
|
+
* Platforms without unix-domain sockets are not supported.
|
|
37
|
+
*/
|
|
38
|
+
/** Extensions this primitive can make available on the started instance. */
|
|
39
|
+
export type DevDatabaseExtension = 'vector';
|
|
40
|
+
/** Options for {@link startDevDatabase}. */
|
|
41
|
+
export interface StartDevDatabaseOptions {
|
|
42
|
+
/**
|
|
43
|
+
* The PGlite data directory. Omitted, the database is in-memory and nothing
|
|
44
|
+
* survives the process — which is what the test harness wants and the dev
|
|
45
|
+
* loop does not.
|
|
46
|
+
*
|
|
47
|
+
* Resolved against `cwd` (or `process.cwd()`, absent that) when relative —
|
|
48
|
+
* the same root the state file resolves against — so a relative `dataDir`
|
|
49
|
+
* and an explicit `cwd` never disagree about where the data directory is.
|
|
50
|
+
*/
|
|
51
|
+
dataDir?: string;
|
|
52
|
+
/** Extensions loaded into the instance, ready for `CREATE EXTENSION`. */
|
|
53
|
+
extensions?: readonly DevDatabaseExtension[];
|
|
54
|
+
/**
|
|
55
|
+
* The socket server's connection ceiling. Defaults to
|
|
56
|
+
* {@link DEFAULT_MAX_CONNECTIONS} — headroom for the several
|
|
57
|
+
* single-connection clients that share one sidecar (the app, the CLI, a
|
|
58
|
+
* seed, a `psql`), not licence for any one of them to open a pool.
|
|
59
|
+
*/
|
|
60
|
+
maxConnections?: number;
|
|
61
|
+
/** The loopback address to bind. Defaults to `127.0.0.1`. */
|
|
62
|
+
host?: string;
|
|
63
|
+
/** The project root whose Generated bundle receives the state file. */
|
|
64
|
+
cwd?: string;
|
|
65
|
+
/** An explicit state file path, bypassing `cwd` and the bundle directory. */
|
|
66
|
+
stateFile?: string;
|
|
67
|
+
}
|
|
68
|
+
/** A running Dev database. */
|
|
69
|
+
export interface DevDatabase {
|
|
70
|
+
/** The connection string written to the state file. */
|
|
71
|
+
readonly url: string;
|
|
72
|
+
readonly host: string;
|
|
73
|
+
readonly port: number;
|
|
74
|
+
/** The absolute data directory, or `undefined` when the instance is in-memory. */
|
|
75
|
+
readonly dataDir: string | undefined;
|
|
76
|
+
/** Absolute path to the state file this instance wrote. */
|
|
77
|
+
readonly stateFile: string;
|
|
78
|
+
/**
|
|
79
|
+
* Stops the socket server, closes PGlite, then drops this instance's state
|
|
80
|
+
* file. Idempotent: a second call resolves without touching anything.
|
|
81
|
+
*/
|
|
82
|
+
stop(): Promise<void>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Headroom for the several single-connection clients that share one sidecar
|
|
86
|
+
* (ADR-0063).
|
|
87
|
+
*/
|
|
88
|
+
export declare const DEFAULT_MAX_CONNECTIONS = 20;
|
|
89
|
+
/** Thrown by {@link startDevDatabase} when another sidecar already holds `dataDir`. */
|
|
90
|
+
export declare class DevDatabaseInUseError extends Error {
|
|
91
|
+
constructor(dataDir: string, pid: number);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Starts an in-process PGlite behind a socket server on a free loopback TCP
|
|
95
|
+
* port and publishes it in the Generated bundle's state file, so that every
|
|
96
|
+
* other process — the app, `db update` in a second terminal, a seed script —
|
|
97
|
+
* finds it through `resolveDatabaseUrl()` rather than an injected variable
|
|
98
|
+
* (ADR-0063).
|
|
99
|
+
*
|
|
100
|
+
* The state file is rewritten on every boot; a record left behind by a crashed
|
|
101
|
+
* sidecar is ignored on its pid.
|
|
102
|
+
*
|
|
103
|
+
* PGlite and its socket and pgvector packages are optional peers of core,
|
|
104
|
+
* imported only here, only when called — a production install carries no WASM
|
|
105
|
+
* Postgres.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* import { startDevDatabase } from '@opensaas/stack-core/dev-database'
|
|
110
|
+
*
|
|
111
|
+
* const database = await startDevDatabase({
|
|
112
|
+
* dataDir: '.opensaas/dev-db',
|
|
113
|
+
* extensions: ['vector'],
|
|
114
|
+
* })
|
|
115
|
+
* try {
|
|
116
|
+
* // `resolveDatabaseUrl()` now reports provenance 'dev-database' here
|
|
117
|
+
* // and in every child process.
|
|
118
|
+
* } finally {
|
|
119
|
+
* await database.stop()
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export declare function startDevDatabase(options?: StartDevDatabaseOptions): Promise<DevDatabase>;
|
|
124
|
+
//# sourceMappingURL=dev-database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-database.d.ts","sourceRoot":"","sources":["../../src/db/dev-database.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAqBH,4EAA4E;AAC5E,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAA;AAE3C,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,yEAAyE;IACzE,UAAU,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAA;IAC5C;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uEAAuE;IACvE,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,8BAA8B;AAC9B,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,kFAAkF;IAClF,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IACpC,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAA;AAqDzC,uFAAuF;AACvF,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAQvC;CACF;AA+GD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,WAAW,CAAC,CAiEtB"}
|