@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
package/src/utils/password.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import bcrypt from 'bcryptjs'
|
|
2
|
-
|
|
3
|
-
// Bcrypt cost factor: higher is slower but more resistant to brute force.
|
|
4
|
-
const DEFAULT_COST_FACTOR = 10
|
|
5
|
-
|
|
6
|
-
export async function hashPassword(
|
|
7
|
-
plainPassword: string,
|
|
8
|
-
costFactor: number = DEFAULT_COST_FACTOR,
|
|
9
|
-
): Promise<string> {
|
|
10
|
-
if (typeof plainPassword !== 'string' || plainPassword.length === 0) {
|
|
11
|
-
throw new Error('Password must be a non-empty string')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return bcrypt.hash(plainPassword, costFactor)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function comparePassword(
|
|
18
|
-
plainPassword: string,
|
|
19
|
-
hashedPassword: string,
|
|
20
|
-
): Promise<boolean> {
|
|
21
|
-
if (typeof plainPassword !== 'string' || typeof hashedPassword !== 'string') {
|
|
22
|
-
return false
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (plainPassword.length === 0 || hashedPassword.length === 0) {
|
|
26
|
-
return false
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
return await bcrypt.compare(plainPassword, hashedPassword)
|
|
31
|
-
} catch (error) {
|
|
32
|
-
// Fail closed on a malformed hash or other bcrypt error, rather than
|
|
33
|
-
// letting it propagate as an authentication-bypassing exception.
|
|
34
|
-
console.error('Password comparison failed:', error)
|
|
35
|
-
return false
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function isHashedPassword(value: string): boolean {
|
|
40
|
-
if (typeof value !== 'string') return false
|
|
41
|
-
|
|
42
|
-
return /^\$2[aby]\$\d{2}\$.{53}$/.test(value)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Wraps a bcrypt hash so a password field's value can still be used as a
|
|
46
|
-
// plain string while also exposing compare() for authentication.
|
|
47
|
-
export class HashedPassword {
|
|
48
|
-
constructor(private readonly hash: string) {
|
|
49
|
-
if (!hash || typeof hash !== 'string') {
|
|
50
|
-
throw new Error('HashedPassword requires a non-empty hash string')
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async compare(plainPassword: string): Promise<boolean> {
|
|
55
|
-
return comparePassword(plainPassword, this.hash)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
toString(): string {
|
|
59
|
-
return this.hash
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Implicit coercion (template literals, string concatenation) resolves here.
|
|
63
|
-
[Symbol.toPrimitive](hint: string): string {
|
|
64
|
-
if (hint === 'string' || hint === 'default') {
|
|
65
|
-
return this.hash
|
|
66
|
-
}
|
|
67
|
-
return this.hash
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// JSON.stringify calls this when present, so this is the serialize-for-output
|
|
71
|
-
// redaction point — never return the hash here. toString()/valueOf()/
|
|
72
|
-
// Symbol.toPrimitive stay unredacted for internal string/compare use.
|
|
73
|
-
toJSON(): { isSet: boolean } {
|
|
74
|
-
return { isSet: !!this.hash }
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
valueOf(): string {
|
|
78
|
-
return this.hash
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { validateFieldConfig, validateConfigFields } from './field-config.js'
|
|
3
|
-
import {
|
|
4
|
-
text,
|
|
5
|
-
integer,
|
|
6
|
-
checkbox,
|
|
7
|
-
timestamp,
|
|
8
|
-
password,
|
|
9
|
-
select,
|
|
10
|
-
json,
|
|
11
|
-
relationship,
|
|
12
|
-
virtual,
|
|
13
|
-
} from '../fields/index.js'
|
|
14
|
-
import type { FieldConfig, OpenSaasConfig } from '../config/types.js'
|
|
15
|
-
|
|
16
|
-
describe('validateFieldConfig', () => {
|
|
17
|
-
describe('well-formed fields pass', () => {
|
|
18
|
-
it.each([
|
|
19
|
-
['text', text()],
|
|
20
|
-
['integer', integer()],
|
|
21
|
-
['checkbox', checkbox()],
|
|
22
|
-
['timestamp', timestamp()],
|
|
23
|
-
['password', password()],
|
|
24
|
-
['select', select({ options: [{ label: 'A', value: 'a' }] })],
|
|
25
|
-
['json', json()],
|
|
26
|
-
])('a built-in %s field is self-contained', (_name, field) => {
|
|
27
|
-
expect(validateFieldConfig(field as FieldConfig, 'myField', 'MyList')).toEqual([])
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('a relationship field is self-contained via getPrismaRelation', () => {
|
|
31
|
-
const field = relationship({ ref: 'User.posts' })
|
|
32
|
-
expect(validateFieldConfig(field as FieldConfig, 'author', 'Post')).toEqual([])
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('a virtual field is self-contained without getPrismaType', () => {
|
|
36
|
-
const field = virtual({
|
|
37
|
-
type: 'string',
|
|
38
|
-
hooks: { resolveOutput: () => 'x' },
|
|
39
|
-
})
|
|
40
|
-
expect(validateFieldConfig(field as FieldConfig, 'fullName', 'User')).toEqual([])
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
describe('missing scalar contract methods fail', () => {
|
|
45
|
-
it('reports a missing getPrismaType naming the list, field, and method', () => {
|
|
46
|
-
const field = text()
|
|
47
|
-
delete field.getPrismaType
|
|
48
|
-
|
|
49
|
-
const errors = validateFieldConfig(field as FieldConfig, 'title', 'Post')
|
|
50
|
-
|
|
51
|
-
expect(errors).toHaveLength(1)
|
|
52
|
-
expect(errors[0]).toMatchObject({
|
|
53
|
-
listKey: 'Post',
|
|
54
|
-
fieldKey: 'title',
|
|
55
|
-
fieldType: 'text',
|
|
56
|
-
missingMethod: 'getPrismaType',
|
|
57
|
-
})
|
|
58
|
-
expect(errors[0].message).toContain('Post.title')
|
|
59
|
-
expect(errors[0].message).toContain('getPrismaType')
|
|
60
|
-
expect(errors[0].message).toContain('not self-contained')
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it('reports a missing getTypeScriptType naming the method', () => {
|
|
64
|
-
const field = text()
|
|
65
|
-
delete field.getTypeScriptType
|
|
66
|
-
|
|
67
|
-
const errors = validateFieldConfig(field as FieldConfig, 'title', 'Post')
|
|
68
|
-
|
|
69
|
-
expect(errors).toHaveLength(1)
|
|
70
|
-
expect(errors[0].missingMethod).toBe('getTypeScriptType')
|
|
71
|
-
expect(errors[0].message).toContain('getTypeScriptType')
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('reports a missing getZodSchema naming the method', () => {
|
|
75
|
-
const field = text()
|
|
76
|
-
delete field.getZodSchema
|
|
77
|
-
|
|
78
|
-
const errors = validateFieldConfig(field as FieldConfig, 'title', 'Post')
|
|
79
|
-
|
|
80
|
-
expect(errors).toHaveLength(1)
|
|
81
|
-
expect(errors[0].missingMethod).toBe('getZodSchema')
|
|
82
|
-
expect(errors[0].message).toContain('getZodSchema')
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
it('reports every missing method when a field implements none', () => {
|
|
86
|
-
const field: FieldConfig = { type: 'custom' }
|
|
87
|
-
|
|
88
|
-
const errors = validateFieldConfig(field, 'mystery', 'Widget')
|
|
89
|
-
|
|
90
|
-
expect(errors.map((e) => e.missingMethod).sort()).toEqual([
|
|
91
|
-
'getPrismaType',
|
|
92
|
-
'getTypeScriptType',
|
|
93
|
-
'getZodSchema',
|
|
94
|
-
])
|
|
95
|
-
for (const error of errors) {
|
|
96
|
-
expect(error.message).toContain('Widget.mystery')
|
|
97
|
-
expect(error.message).toContain('custom')
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
it('works without a listKey (bare field validation)', () => {
|
|
102
|
-
const field: FieldConfig = { type: 'custom' }
|
|
103
|
-
const errors = validateFieldConfig(field, 'mystery')
|
|
104
|
-
expect(errors).toHaveLength(3)
|
|
105
|
-
expect(errors[0].listKey).toBeUndefined()
|
|
106
|
-
expect(errors[0].message).toContain('Field "mystery"')
|
|
107
|
-
})
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
describe('relationship and virtual variants', () => {
|
|
111
|
-
it('reports a relationship missing getPrismaRelation', () => {
|
|
112
|
-
const field: FieldConfig = { type: 'relationship' }
|
|
113
|
-
|
|
114
|
-
const errors = validateFieldConfig(field, 'author', 'Post')
|
|
115
|
-
|
|
116
|
-
expect(errors).toHaveLength(1)
|
|
117
|
-
expect(errors[0].missingMethod).toBe('getPrismaRelation')
|
|
118
|
-
expect(errors[0].message).toContain('Post.author')
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
it('reports a virtual field missing getTypeScriptType and getZodSchema', () => {
|
|
122
|
-
const field: FieldConfig = { type: 'virtual', virtual: true }
|
|
123
|
-
|
|
124
|
-
const errors = validateFieldConfig(field, 'fullName', 'User')
|
|
125
|
-
|
|
126
|
-
expect(errors.map((e) => e.missingMethod).sort()).toEqual([
|
|
127
|
-
'getTypeScriptType',
|
|
128
|
-
'getZodSchema',
|
|
129
|
-
])
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
it('does not require getPrismaType for virtual fields', () => {
|
|
133
|
-
const field: FieldConfig = { type: 'virtual', virtual: true }
|
|
134
|
-
const errors = validateFieldConfig(field, 'fullName', 'User')
|
|
135
|
-
expect(errors.some((e) => e.missingMethod === 'getPrismaType')).toBe(false)
|
|
136
|
-
})
|
|
137
|
-
})
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
describe('validateConfigFields', () => {
|
|
141
|
-
it('returns no errors for a fully compliant config', () => {
|
|
142
|
-
const config: OpenSaasConfig = {
|
|
143
|
-
db: {
|
|
144
|
-
provider: 'sqlite',
|
|
145
|
-
prismaClientConstructor: () => null as never,
|
|
146
|
-
},
|
|
147
|
-
lists: {
|
|
148
|
-
User: {
|
|
149
|
-
fields: {
|
|
150
|
-
name: text({ validation: { isRequired: true } }),
|
|
151
|
-
posts: relationship({ ref: 'Post.author', many: true }),
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
Post: {
|
|
155
|
-
fields: {
|
|
156
|
-
title: text(),
|
|
157
|
-
author: relationship({ ref: 'User.posts' }),
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
expect(validateConfigFields(config)).toEqual([])
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
it('collects per-field errors across every list and names each location', () => {
|
|
167
|
-
const brokenTitle = text()
|
|
168
|
-
delete brokenTitle.getPrismaType
|
|
169
|
-
|
|
170
|
-
const brokenName = text()
|
|
171
|
-
delete brokenName.getZodSchema
|
|
172
|
-
|
|
173
|
-
const config: OpenSaasConfig = {
|
|
174
|
-
db: {
|
|
175
|
-
provider: 'sqlite',
|
|
176
|
-
prismaClientConstructor: () => null as never,
|
|
177
|
-
},
|
|
178
|
-
lists: {
|
|
179
|
-
User: {
|
|
180
|
-
fields: {
|
|
181
|
-
name: brokenName,
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
Post: {
|
|
185
|
-
fields: {
|
|
186
|
-
title: brokenTitle,
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const errors = validateConfigFields(config)
|
|
193
|
-
|
|
194
|
-
expect(errors).toHaveLength(2)
|
|
195
|
-
const byField = Object.fromEntries(errors.map((e) => [`${e.listKey}.${e.fieldKey}`, e]))
|
|
196
|
-
expect(byField['User.name'].missingMethod).toBe('getZodSchema')
|
|
197
|
-
expect(byField['Post.title'].missingMethod).toBe('getPrismaType')
|
|
198
|
-
})
|
|
199
|
-
})
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import type { FieldConfig, OpenSaasConfig } from '../config/types.js'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A single self-containment violation found on a field.
|
|
5
|
-
*
|
|
6
|
-
* Field builders advertise a self-containment contract: every field provides
|
|
7
|
-
* the generation hooks the schema/type generators delegate to. When a field
|
|
8
|
-
* (often a third-party one) fails to implement a required method, the
|
|
9
|
-
* generators historically threw deep inside generation with an opaque stack
|
|
10
|
-
* trace. This structured error lets the contract be checked up front and
|
|
11
|
-
* reported per-field with enough context to act on.
|
|
12
|
-
*/
|
|
13
|
-
export interface FieldConfigValidationError {
|
|
14
|
-
/** The list the offending field belongs to (`undefined` when validating a bare field). */
|
|
15
|
-
listKey?: string
|
|
16
|
-
/** The field key (property name) within the list. */
|
|
17
|
-
fieldKey: string
|
|
18
|
-
/** The field's declared `type` discriminator (e.g. `'text'`, `'virtual'`). */
|
|
19
|
-
fieldType: string
|
|
20
|
-
/** The contract method that is missing. */
|
|
21
|
-
missingMethod: 'getPrismaType' | 'getTypeScriptType' | 'getZodSchema' | 'getPrismaRelation'
|
|
22
|
-
/** A human-readable, ready-to-print message naming the list, field, and method. */
|
|
23
|
-
message: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Describe a field for an error message. Falls back to a literal when a
|
|
28
|
-
* `type`-less value slips through (e.g. a malformed third-party field).
|
|
29
|
-
*/
|
|
30
|
-
function describeFieldType(field: FieldConfig): string {
|
|
31
|
-
return typeof field.type === 'string' && field.type.length > 0 ? field.type : 'unknown'
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Type-safe probe for a function-valued property on a field config.
|
|
36
|
-
*
|
|
37
|
-
* The three scalar contract methods live on `BaseFieldConfig` and are checked
|
|
38
|
-
* directly. `getPrismaRelation` only exists on the relationship field variant,
|
|
39
|
-
* so it is probed structurally here without widening the public type or
|
|
40
|
-
* reaching for a cast.
|
|
41
|
-
*/
|
|
42
|
-
function hasFieldMethod(field: FieldConfig, method: string): boolean {
|
|
43
|
-
const value: unknown = Reflect.get(field, method)
|
|
44
|
-
return typeof value === 'function'
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function buildMessage(
|
|
48
|
-
fieldType: string,
|
|
49
|
-
method: FieldConfigValidationError['missingMethod'],
|
|
50
|
-
fieldKey: string,
|
|
51
|
-
listKey?: string,
|
|
52
|
-
): string {
|
|
53
|
-
const location = listKey ? `Field "${listKey}.${fieldKey}"` : `Field "${fieldKey}"`
|
|
54
|
-
return (
|
|
55
|
-
`${location} (type "${fieldType}") is not self-contained: it does not implement ` +
|
|
56
|
-
`${method}(). Field builders must provide this method so the generator can ` +
|
|
57
|
-
`produce schema and types without inspecting field internals.`
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Validate a single field against the self-containment contract.
|
|
63
|
-
*
|
|
64
|
-
* The contract is conditional on field kind, mirroring exactly where the
|
|
65
|
-
* generators delegate:
|
|
66
|
-
*
|
|
67
|
-
* - `relationship` fields contribute schema via `getPrismaRelation` and are
|
|
68
|
-
* skipped by the scalar Prisma/TypeScript/Zod paths, so only
|
|
69
|
-
* `getPrismaRelation` is required.
|
|
70
|
-
* - `virtual` fields are not stored in the database, so `getPrismaType` is
|
|
71
|
-
* legitimately absent; they must still provide `getTypeScriptType` and
|
|
72
|
-
* `getZodSchema`.
|
|
73
|
-
* - every other (stored scalar) field must provide `getPrismaType`,
|
|
74
|
-
* `getTypeScriptType`, and `getZodSchema`.
|
|
75
|
-
*
|
|
76
|
-
* @param field - The field config produced by a field builder.
|
|
77
|
-
* @param fieldKey - The field's key within its list (for messages).
|
|
78
|
-
* @param listKey - The owning list's key (optional, for messages).
|
|
79
|
-
* @returns Zero or more structured errors; empty means the field is compliant.
|
|
80
|
-
*/
|
|
81
|
-
export function validateFieldConfig(
|
|
82
|
-
field: FieldConfig,
|
|
83
|
-
fieldKey: string,
|
|
84
|
-
listKey?: string,
|
|
85
|
-
): FieldConfigValidationError[] {
|
|
86
|
-
const errors: FieldConfigValidationError[] = []
|
|
87
|
-
const fieldType = describeFieldType(field)
|
|
88
|
-
|
|
89
|
-
const requireMethod = (method: FieldConfigValidationError['missingMethod']): void => {
|
|
90
|
-
if (!hasFieldMethod(field, method)) {
|
|
91
|
-
errors.push({
|
|
92
|
-
listKey,
|
|
93
|
-
fieldKey,
|
|
94
|
-
fieldType,
|
|
95
|
-
missingMethod: method,
|
|
96
|
-
message: buildMessage(fieldType, method, fieldKey, listKey),
|
|
97
|
-
})
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (field.type === 'relationship') {
|
|
102
|
-
requireMethod('getPrismaRelation')
|
|
103
|
-
return errors
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (field.virtual === true || field.type === 'virtual') {
|
|
107
|
-
requireMethod('getTypeScriptType')
|
|
108
|
-
requireMethod('getZodSchema')
|
|
109
|
-
return errors
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
requireMethod('getPrismaType')
|
|
113
|
-
requireMethod('getTypeScriptType')
|
|
114
|
-
requireMethod('getZodSchema')
|
|
115
|
-
|
|
116
|
-
return errors
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Validate every field across every list in a config.
|
|
121
|
-
*
|
|
122
|
-
* Intended to run once, before any generation, so a misimplemented field
|
|
123
|
-
* surfaces a clear per-field message instead of a deep generator stack trace.
|
|
124
|
-
*
|
|
125
|
-
* @param config - The fully resolved OpenSaas config.
|
|
126
|
-
* @returns All self-containment violations, flattened across lists and fields.
|
|
127
|
-
*/
|
|
128
|
-
export function validateConfigFields(config: OpenSaasConfig): FieldConfigValidationError[] {
|
|
129
|
-
const errors: FieldConfigValidationError[] = []
|
|
130
|
-
|
|
131
|
-
for (const [listKey, listConfig] of Object.entries(config.lists)) {
|
|
132
|
-
if (!listConfig?.fields) continue
|
|
133
|
-
for (const [fieldKey, fieldConfig] of Object.entries(listConfig.fields)) {
|
|
134
|
-
errors.push(...validateFieldConfig(fieldConfig, fieldKey, listKey))
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return errors
|
|
139
|
-
}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import type { FieldConfig, OpenSaasConfig } from '../config/types.js'
|
|
2
|
-
import { getRelatedListConfig } from '../access/engine.js'
|
|
3
|
-
import { READ_INCLUDE_MAX_DEPTH } from '../access/depth-limits.js'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A field's `needs` declaration (ADR-0025) whose closure — the recursive
|
|
7
|
-
* fold of its own dependencies, and THEIR dependencies, and so on — cannot
|
|
8
|
-
* be satisfied by the read pipeline, independent of where any caller starts
|
|
9
|
-
* a read.
|
|
10
|
-
*
|
|
11
|
-
* Two distinct refusals, both fail-closed rather than silently truncated
|
|
12
|
-
* (ADR-0022): `'cycle'` means the chain never terminates (e.g. `Order.total`
|
|
13
|
-
* needs `lineItems`, `LineItem.orderRef` needs `order`); `'depth'` means it
|
|
14
|
-
* terminates but reaches deeper than `READ_INCLUDE_MAX_DEPTH` even when
|
|
15
|
-
* evaluated starting AT the declaring field's own list — the most
|
|
16
|
-
* favourable starting point available, so no caller could ever do better.
|
|
17
|
-
*/
|
|
18
|
-
export interface NeedsClosureError {
|
|
19
|
-
/** The list whose field declares the (transitively) unsatisfiable `needs`. */
|
|
20
|
-
listKey: string
|
|
21
|
-
/** The field key within that list. */
|
|
22
|
-
fieldKey: string
|
|
23
|
-
/** The list keys on the offending chain, starting at `listKey`. */
|
|
24
|
-
chain: string[]
|
|
25
|
-
reason: 'cycle' | 'depth' | 'invalid-relation'
|
|
26
|
-
message: string
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function isRelationshipFieldConfig(
|
|
30
|
-
fieldConfig: FieldConfig | undefined,
|
|
31
|
-
): fieldConfig is FieldConfig & { type: 'relationship'; ref: string } {
|
|
32
|
-
return (
|
|
33
|
-
!!fieldConfig &&
|
|
34
|
-
fieldConfig.type === 'relationship' &&
|
|
35
|
-
'ref' in fieldConfig &&
|
|
36
|
-
!!fieldConfig.ref
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
type ListClosureResult = { depth: number; chain: string[] } | { cycle: string[] }
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The deepest needs-chain reachable from `listKey`, considering EVERY field
|
|
44
|
-
* on every list along the way that declares `needs` — not only the field
|
|
45
|
-
* that triggered the walk. A computed field runs wherever its list's rows
|
|
46
|
-
* are fetched, so once a list is reached, ALL of its own declared
|
|
47
|
-
* dependencies must be satisfiable too (ADR-0025's "at every level a field
|
|
48
|
-
* is computed").
|
|
49
|
-
*
|
|
50
|
-
* `path` is the list keys already on this DFS branch, root-first, used to
|
|
51
|
-
* detect a cycle (a chain that can never terminate).
|
|
52
|
-
*/
|
|
53
|
-
function listClosureDepth(
|
|
54
|
-
listKey: string,
|
|
55
|
-
config: OpenSaasConfig,
|
|
56
|
-
path: readonly string[],
|
|
57
|
-
): ListClosureResult {
|
|
58
|
-
const listConfig = config.lists[listKey]
|
|
59
|
-
if (!listConfig?.fields) return { depth: 0, chain: [listKey] }
|
|
60
|
-
|
|
61
|
-
let maxDepth = 0
|
|
62
|
-
let maxChain = [listKey]
|
|
63
|
-
|
|
64
|
-
for (const fieldConfig of Object.values(listConfig.fields)) {
|
|
65
|
-
if (!fieldConfig?.hooks?.resolveOutput) continue
|
|
66
|
-
|
|
67
|
-
for (const relationName of fieldConfig.needs ?? []) {
|
|
68
|
-
const relatedField = listConfig.fields[relationName]
|
|
69
|
-
if (!isRelationshipFieldConfig(relatedField)) continue
|
|
70
|
-
|
|
71
|
-
const relatedConfig = getRelatedListConfig(relatedField.ref, config)
|
|
72
|
-
if (!relatedConfig) continue
|
|
73
|
-
const relatedListKey = relatedConfig.listName
|
|
74
|
-
|
|
75
|
-
if (path.includes(relatedListKey)) {
|
|
76
|
-
return { cycle: [...path, relatedListKey] }
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const sub = listClosureDepth(relatedListKey, config, [...path, relatedListKey])
|
|
80
|
-
if ('cycle' in sub) return sub
|
|
81
|
-
|
|
82
|
-
if (1 + sub.depth > maxDepth) {
|
|
83
|
-
maxDepth = 1 + sub.depth
|
|
84
|
-
maxChain = [listKey, ...sub.chain]
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return { depth: maxDepth, chain: maxChain }
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Validate that every `needs` entry names an immediate relationship field
|
|
94
|
-
* declared on the SAME list. The generated `Lists.<List>.TypeInfo` already
|
|
95
|
-
* makes a misspelled or non-relation entry a compile error for a config
|
|
96
|
-
* annotated with it (`list<Lists.X.TypeInfo>({...})`, the documented
|
|
97
|
-
* pattern) — this is the runtime backstop for configs that aren't, or that
|
|
98
|
-
* are authored in plain JS.
|
|
99
|
-
*
|
|
100
|
-
* @param config - The fully resolved OpenSaas config.
|
|
101
|
-
* @returns All invalid `needs` entries, flattened across lists and fields.
|
|
102
|
-
*/
|
|
103
|
-
export function validateNeedsDeclarations(config: OpenSaasConfig): NeedsClosureError[] {
|
|
104
|
-
const errors: NeedsClosureError[] = []
|
|
105
|
-
|
|
106
|
-
for (const [listKey, listConfig] of Object.entries(config.lists)) {
|
|
107
|
-
if (!listConfig?.fields) continue
|
|
108
|
-
|
|
109
|
-
for (const [fieldKey, fieldConfig] of Object.entries(listConfig.fields)) {
|
|
110
|
-
for (const relationName of fieldConfig?.needs ?? []) {
|
|
111
|
-
if (isRelationshipFieldConfig(listConfig.fields[relationName])) continue
|
|
112
|
-
|
|
113
|
-
const exists = relationName in listConfig.fields
|
|
114
|
-
errors.push({
|
|
115
|
-
listKey,
|
|
116
|
-
fieldKey,
|
|
117
|
-
chain: [listKey],
|
|
118
|
-
reason: 'invalid-relation',
|
|
119
|
-
message: exists
|
|
120
|
-
? `"${listKey}.${fieldKey}" declares needs: ['${relationName}'], but "${relationName}" ` +
|
|
121
|
-
`is not a relationship field on "${listKey}". \`needs\` may only name immediate ` +
|
|
122
|
-
`relationship fields declared on the same list.`
|
|
123
|
-
: `"${listKey}.${fieldKey}" declares needs: ['${relationName}'], but "${listKey}" has ` +
|
|
124
|
-
`no field named "${relationName}".`,
|
|
125
|
-
})
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return errors
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Validate that every field's `needs` closure fits within
|
|
135
|
-
* `READ_INCLUDE_MAX_DEPTH` when evaluated starting at the declaring field's
|
|
136
|
-
* own list — the most favourable starting point a caller could ever give it.
|
|
137
|
-
* Intended to run once, before generation, exactly like
|
|
138
|
-
* {@link validateConfigFields} — a config whose closure cannot fit must not
|
|
139
|
-
* generate, per ADR-0025's "Depth" section.
|
|
140
|
-
*
|
|
141
|
-
* @param config - The fully resolved OpenSaas config.
|
|
142
|
-
* @returns All unsatisfiable-closure violations, flattened across lists and fields.
|
|
143
|
-
*/
|
|
144
|
-
export function validateNeedsClosureDepth(config: OpenSaasConfig): NeedsClosureError[] {
|
|
145
|
-
const errors: NeedsClosureError[] = []
|
|
146
|
-
|
|
147
|
-
for (const [listKey, listConfig] of Object.entries(config.lists)) {
|
|
148
|
-
if (!listConfig?.fields) continue
|
|
149
|
-
|
|
150
|
-
for (const [fieldKey, fieldConfig] of Object.entries(listConfig.fields)) {
|
|
151
|
-
if (!fieldConfig?.hooks?.resolveOutput || !fieldConfig.needs?.length) continue
|
|
152
|
-
|
|
153
|
-
const result = listClosureDepth(listKey, config, [listKey])
|
|
154
|
-
|
|
155
|
-
if ('cycle' in result) {
|
|
156
|
-
errors.push({
|
|
157
|
-
listKey,
|
|
158
|
-
fieldKey,
|
|
159
|
-
chain: result.cycle,
|
|
160
|
-
reason: 'cycle',
|
|
161
|
-
message:
|
|
162
|
-
`"${listKey}.${fieldKey}"'s needs declaration never terminates: ` +
|
|
163
|
-
`${result.cycle.join(' → ')} → … . A chain of \`needs\` across these lists cycles back ` +
|
|
164
|
-
`on itself, so no read could ever satisfy it. Break the cycle by removing one of the ` +
|
|
165
|
-
`\`needs\` entries on this chain, or compute the value without it.`,
|
|
166
|
-
})
|
|
167
|
-
continue
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (result.depth >= READ_INCLUDE_MAX_DEPTH) {
|
|
171
|
-
errors.push({
|
|
172
|
-
listKey,
|
|
173
|
-
fieldKey,
|
|
174
|
-
chain: result.chain,
|
|
175
|
-
reason: 'depth',
|
|
176
|
-
message:
|
|
177
|
-
`"${listKey}.${fieldKey}"'s needs declaration requires a closure ${result.depth} ` +
|
|
178
|
-
`relations deep even starting at "${listKey}" itself: ${result.chain.join(' → ')}. ` +
|
|
179
|
-
`This exceeds the Access Filter's maximum read-include depth ` +
|
|
180
|
-
`(${READ_INCLUDE_MAX_DEPTH}), so no caller — however they start the read — could ever ` +
|
|
181
|
-
`have this closure satisfied. Shorten the \`needs\` chain across these lists.`,
|
|
182
|
-
})
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return errors
|
|
188
|
-
}
|