@opensaas/stack-core 0.43.0 → 0.44.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2720 -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 +966 -614
- 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 +540 -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 +282 -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 +135 -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 +457 -677
- 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 +221 -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
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Maximum nesting depth of relation `include`s the Access Filter
|
|
3
|
-
* (`buildAccessScopedInclude`) will scope on a read.
|
|
4
|
-
*
|
|
5
|
-
* Since ADR-0026 made the read pipeline caller-directed, this is a COST
|
|
6
|
-
* limit, not an access-control boundary: nothing walks the relationship
|
|
7
|
-
* graph unprompted anymore, so there is no unscoped tree to fail open on. A
|
|
8
|
-
* request naming a relation at or beyond this depth still throws
|
|
9
|
-
* `AccessScopeDepthExceededError` (ADR-0022, issue #830) — the engine
|
|
10
|
-
* declines to serve a tree this expensive, not because it cannot scope one.
|
|
11
|
-
*/
|
|
12
|
-
export const READ_INCLUDE_MAX_DEPTH = 5
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Maximum length of the resolve chain — the ordered sequence of `resolveOutput`
|
|
16
|
-
* hooks a read has entered, each entry extended by a hook that issues its own
|
|
17
|
-
* read (see `_resolveOutputChain` on `AccessContext`).
|
|
18
|
-
*
|
|
19
|
-
* This is a COST limit, not an access-control boundary: an acyclic chain
|
|
20
|
-
* genuinely can exceed it and still be correct (e.g. a virtual `Order.total`
|
|
21
|
-
* reading a virtual `LineItem.subtotal` reading further virtuals), so
|
|
22
|
-
* exceeding it omits the field and emits a single `console.warn` rather than
|
|
23
|
-
* throwing. Termination itself is guaranteed by the separate cycle guard,
|
|
24
|
-
* which refuses to re-enter a `(list, field)` pair already on the chain
|
|
25
|
-
* regardless of this cap. See ADR-0023.
|
|
26
|
-
*/
|
|
27
|
-
export const RESOLVE_CHAIN_MAX_LENGTH = 5
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { resolveSyntheticReverseRelation } from './engine.js'
|
|
3
|
-
import type { OpenSaasConfig, FieldConfig } from '../config/types.js'
|
|
4
|
-
|
|
5
|
-
// A relationship field pointing at another list.
|
|
6
|
-
function rel(ref: string, many = false): FieldConfig {
|
|
7
|
-
return { type: 'relationship', ref, many } as unknown as FieldConfig
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* #978: a list-only `ref` (`ref: 'ListName'`, no target field) generates a
|
|
12
|
-
* synthetic back-relation on its target — `from_<SourceList>_<sourceField>`
|
|
13
|
-
* (see `getSyntheticFieldName` in fields/index.ts). `resolveSyntheticReverseRelation`
|
|
14
|
-
* is the runtime counterpart that recognises the same name and resolves it
|
|
15
|
-
* back to the declared field that owns it, so a nested write addressed to it
|
|
16
|
-
* gets the same hook pipeline a declared relationship field gets.
|
|
17
|
-
*/
|
|
18
|
-
describe('resolveSyntheticReverseRelation', () => {
|
|
19
|
-
const config: OpenSaasConfig = {
|
|
20
|
-
db: { provider: 'sqlite', url: 'file:./dev.db' },
|
|
21
|
-
lists: {
|
|
22
|
-
Account: { fields: { name: { type: 'text' } as unknown as FieldConfig } },
|
|
23
|
-
ChargeRequest: {
|
|
24
|
-
fields: {
|
|
25
|
-
kind: { type: 'text' } as unknown as FieldConfig,
|
|
26
|
-
// List-only ref — no field named on Account, so a back-relation is
|
|
27
|
-
// synthesized on it as `from_ChargeRequest_account`.
|
|
28
|
-
account: rel('Account'),
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
// A bidirectional relationship — Post.author names User.posts directly,
|
|
32
|
-
// so no back-relation is synthesized anywhere for it.
|
|
33
|
-
User: { fields: { posts: rel('Post.author', true) } },
|
|
34
|
-
Post: { fields: { author: rel('User.posts') } },
|
|
35
|
-
},
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
} as any
|
|
38
|
-
|
|
39
|
-
it('resolves the synthetic back-relation name to its owning field', () => {
|
|
40
|
-
const result = resolveSyntheticReverseRelation('from_ChargeRequest_account', 'Account', config)
|
|
41
|
-
expect(result).not.toBeNull()
|
|
42
|
-
expect(result?.sourceListName).toBe('ChargeRequest')
|
|
43
|
-
expect(result?.sourceFieldName).toBe('account')
|
|
44
|
-
expect(result?.sourceFieldConfig.ref).toBe('Account')
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('returns null for a name that does not match the synthetic construction', () => {
|
|
48
|
-
expect(
|
|
49
|
-
resolveSyntheticReverseRelation('from_ChargeRequest_amount', 'Account', config),
|
|
50
|
-
).toBeNull()
|
|
51
|
-
expect(resolveSyntheticReverseRelation('chargeRequests', 'Account', config)).toBeNull()
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('returns null on the wrong parent list', () => {
|
|
55
|
-
expect(
|
|
56
|
-
resolveSyntheticReverseRelation('from_ChargeRequest_account', 'ChargeRequest', config),
|
|
57
|
-
).toBeNull()
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('returns null for a bidirectional ref — its other side is a real declared field, not a synthetic one', () => {
|
|
61
|
-
expect(resolveSyntheticReverseRelation('from_Post_author', 'User', config)).toBeNull()
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
it('returns null for a genuinely unknown key', () => {
|
|
65
|
-
expect(resolveSyntheticReverseRelation('totallyBogusKey', 'Account', config)).toBeNull()
|
|
66
|
-
})
|
|
67
|
-
})
|
package/src/access/engine.ts
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import type { AccessControl, Session, AccessContext, PrismaFilter } from './types.js'
|
|
2
|
-
import type { OpenSaasConfig, ListConfig, RelationshipField } from '../config/types.js'
|
|
3
|
-
import { getSyntheticFieldName } from '../fields/index.js'
|
|
4
|
-
import { InvalidCreateAccessResultError } from './errors.js'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Access engine — operation-level access control and shared helpers.
|
|
8
|
-
*
|
|
9
|
-
* This module holds the *operation-level* (list-level) access primitives and
|
|
10
|
-
* the ref-parsing helper shared across both phases of the two-phase read:
|
|
11
|
-
*
|
|
12
|
-
* - Phase 1, Access Filter (pre-query row/relation scoping): `access-filter.ts`
|
|
13
|
-
* - Phase 2, Field Visibility (post-query field stripping + resolveOutput +
|
|
14
|
-
* virtual fields): `field-visibility.ts`
|
|
15
|
-
*
|
|
16
|
-
* Field-level access evaluation is centralized in `field-access.ts`
|
|
17
|
-
* (`checkFieldAccess`). See `docs/adr/0001-access-control-is-a-two-phase-read.md`
|
|
18
|
-
* and the access-control glossary in `CONTEXT.md`.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
export function isBoolean(value: unknown): value is boolean {
|
|
22
|
-
return typeof value === 'boolean'
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function isPrismaFilter(value: unknown): value is PrismaFilter {
|
|
26
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function getRelatedListConfig(
|
|
30
|
-
relationshipRef: string,
|
|
31
|
-
config: OpenSaasConfig,
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
-
): { listName: string; listConfig: ListConfig<any> } | null {
|
|
34
|
-
// Parse ref format: "ListName.fieldName" or "ListName"
|
|
35
|
-
const parts = relationshipRef.split('.')
|
|
36
|
-
if (parts.length !== 1 && parts.length !== 2) {
|
|
37
|
-
return null
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const listName = parts[0]
|
|
41
|
-
const listConfig = config.lists[listName]
|
|
42
|
-
|
|
43
|
-
if (!listConfig) {
|
|
44
|
-
return null
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return { listName, listConfig }
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** A synthetic reverse relation, resolved back to the declared field that owns it. */
|
|
51
|
-
export interface SyntheticReverseRelation {
|
|
52
|
-
sourceListName: string
|
|
53
|
-
sourceFieldName: string
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- RelationshipField must accept any TypeInfo
|
|
55
|
-
sourceFieldConfig: RelationshipField<any>
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
|
|
57
|
-
sourceListConfig: ListConfig<any>
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Resolve a candidate data key as the synthetic back-relation a list-only
|
|
62
|
-
* `ref` (`ref: 'ListName'`, no target field) generates on its target model —
|
|
63
|
-
* Prisma requires an opposite field there, but the config never declares one,
|
|
64
|
-
* so it never appears in `parentListName`'s own `fields`. Reuses
|
|
65
|
-
* `getSyntheticFieldName` (the same construction `getPrismaRelation` emits the
|
|
66
|
-
* schema with) rather than re-deriving the `from_<List>_<field>` format by
|
|
67
|
-
* string parsing, so the two cannot drift (#978).
|
|
68
|
-
*
|
|
69
|
-
* Returns the declared relationship field that owns the relation — the write
|
|
70
|
-
* pipeline treats a resolved synthetic key exactly like a nested write through
|
|
71
|
-
* that field, so it runs the same hooks/access/recovery machinery a declared
|
|
72
|
-
* relationship field gets. Returns `null` when `fieldName` isn't one of these
|
|
73
|
-
* on `parentListName` (a genuinely unknown key, or a bidirectional relation's
|
|
74
|
-
* ref, which never synthesizes a back-relation).
|
|
75
|
-
*/
|
|
76
|
-
export function resolveSyntheticReverseRelation(
|
|
77
|
-
fieldName: string,
|
|
78
|
-
parentListName: string,
|
|
79
|
-
config: OpenSaasConfig,
|
|
80
|
-
): SyntheticReverseRelation | null {
|
|
81
|
-
for (const [sourceListName, sourceListConfig] of Object.entries(config.lists)) {
|
|
82
|
-
for (const [sourceFieldName, sourceFieldConfig] of Object.entries(sourceListConfig.fields)) {
|
|
83
|
-
if (sourceFieldConfig.type !== 'relationship') continue
|
|
84
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- RelationshipField must accept any TypeInfo
|
|
85
|
-
const rel = sourceFieldConfig as RelationshipField<any>
|
|
86
|
-
// Only a list-only ref ('ListName', no '.fieldName') synthesizes a
|
|
87
|
-
// back-relation — a bidirectional ref's other side is a real field.
|
|
88
|
-
const refParts = rel.ref.split('.')
|
|
89
|
-
if (refParts.length !== 1 || refParts[0] !== parentListName) continue
|
|
90
|
-
if (getSyntheticFieldName(sourceListName, sourceFieldName) !== fieldName) continue
|
|
91
|
-
return { sourceListName, sourceFieldName, sourceFieldConfig: rel, sourceListConfig }
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return null
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Enumerate every synthetic back-relation name a list-only `ref` elsewhere in
|
|
99
|
-
* the config synthesizes onto `parentListName` — the same relations
|
|
100
|
-
* `resolveSyntheticReverseRelation` resolves one at a time given a candidate
|
|
101
|
-
* key, returned here as the full set for a caller that instead needs "every
|
|
102
|
-
* relation this list carries" with no candidate to check (e.g. `_count:
|
|
103
|
-
* true`'s "count every relation" expansion in `access-filter.ts`, issue
|
|
104
|
-
* #1087 — a bare `_count: true` must include a synthetic back-relation's
|
|
105
|
-
* count exactly as it always has, not only a caller-named one).
|
|
106
|
-
*/
|
|
107
|
-
export function listSyntheticReverseRelationNames(
|
|
108
|
-
parentListName: string,
|
|
109
|
-
config: OpenSaasConfig,
|
|
110
|
-
): string[] {
|
|
111
|
-
const names: string[] = []
|
|
112
|
-
for (const [sourceListName, sourceListConfig] of Object.entries(config.lists)) {
|
|
113
|
-
for (const [sourceFieldName, sourceFieldConfig] of Object.entries(sourceListConfig.fields)) {
|
|
114
|
-
if (sourceFieldConfig.type !== 'relationship') continue
|
|
115
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- RelationshipField must accept any TypeInfo
|
|
116
|
-
const rel = sourceFieldConfig as RelationshipField<any>
|
|
117
|
-
const refParts = rel.ref.split('.')
|
|
118
|
-
if (refParts.length !== 1 || refParts[0] !== parentListName) continue
|
|
119
|
-
names.push(getSyntheticFieldName(sourceListName, sourceFieldName))
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return names
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export async function checkAccess<T = Record<string, unknown>>(
|
|
126
|
-
accessControl: AccessControl<T> | undefined,
|
|
127
|
-
args: {
|
|
128
|
-
session: Session | null
|
|
129
|
-
item?: T
|
|
130
|
-
context: AccessContext
|
|
131
|
-
},
|
|
132
|
-
): Promise<boolean | PrismaFilter<T>> {
|
|
133
|
-
// No access control means deny by default
|
|
134
|
-
if (!accessControl) {
|
|
135
|
-
return false
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const result = await accessControl(args)
|
|
139
|
-
|
|
140
|
-
return result
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Evaluate operation-level `create` access. The single evaluator shared by the
|
|
145
|
-
* write pipeline's top-level create and the nested-create path — both must
|
|
146
|
-
* reject the same way, or the two drift again (#1009).
|
|
147
|
-
*
|
|
148
|
-
* Unlike `checkAccess` (which `query`/`update`/`delete` call directly and which
|
|
149
|
-
* legitimately returns a filter for them to re-check against a row), create
|
|
150
|
-
* has no existing row and no way to test a filter against input data. A rule
|
|
151
|
-
* that returns anything other than a strict boolean — most notably a filter,
|
|
152
|
-
* which type-checks against the shared `AccessControl` signature and reads as
|
|
153
|
-
* though it scopes the create — throws `InvalidCreateAccessResultError`
|
|
154
|
-
* rather than being silently treated as an allow. See that error's doc,
|
|
155
|
-
* ADR-0022, and ADR-0030.
|
|
156
|
-
*/
|
|
157
|
-
export async function checkCreateAccess<T = Record<string, unknown>>(
|
|
158
|
-
listKey: string,
|
|
159
|
-
accessControl: AccessControl<T> | undefined,
|
|
160
|
-
args: {
|
|
161
|
-
session: Session | null
|
|
162
|
-
context: AccessContext
|
|
163
|
-
},
|
|
164
|
-
): Promise<boolean> {
|
|
165
|
-
const result = await checkAccess(accessControl, args)
|
|
166
|
-
|
|
167
|
-
if (isBoolean(result)) {
|
|
168
|
-
return result
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
throw new InvalidCreateAccessResultError(listKey, result)
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export function mergeFilters(
|
|
175
|
-
userFilter: PrismaFilter | undefined,
|
|
176
|
-
accessFilter: boolean | PrismaFilter,
|
|
177
|
-
): PrismaFilter | null {
|
|
178
|
-
if (accessFilter === false) {
|
|
179
|
-
return null
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (accessFilter === true) {
|
|
183
|
-
return userFilter || {}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (!userFilter) {
|
|
187
|
-
return accessFilter
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return {
|
|
191
|
-
AND: [accessFilter, userFilter],
|
|
192
|
-
}
|
|
193
|
-
}
|
package/src/access/errors.ts
DELETED
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import { READ_INCLUDE_MAX_DEPTH } from './depth-limits.js'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Thrown when a caller-supplied `include` names a relation nested deeper than
|
|
5
|
-
* `READ_INCLUDE_MAX_DEPTH`. Deliberately distinct from `ValidationError`: this
|
|
6
|
-
* is not bad user input, it is the engine declining to serve a tree this
|
|
7
|
-
* expensive. Code that catches `ValidationError` to report form errors must
|
|
8
|
-
* not silently swallow this.
|
|
9
|
-
*
|
|
10
|
-
* Only an explicit request naming something at or past the cap triggers this
|
|
11
|
-
* — a read that simply doesn't reach this deep never throws. Before
|
|
12
|
-
* ADR-0026 made the read pipeline caller-directed, this cap was the engine's
|
|
13
|
-
* last line of defense against returning a relation it could not prove was
|
|
14
|
-
* row/field scoped (ADR-0022, issue #830); a request naming anything at this
|
|
15
|
-
* depth is now scoped exactly like every other named relation; the cap
|
|
16
|
-
* exists solely to bound how deep a request may cost the engine to serve. See
|
|
17
|
-
* ADR-0026 and `docs/adr/0022-access-control-fails-closed-when-it-cannot-scope.md`.
|
|
18
|
-
*/
|
|
19
|
-
export class AccessScopeDepthExceededError extends Error {
|
|
20
|
-
public listKey: string
|
|
21
|
-
public fieldKey: string
|
|
22
|
-
public depth: number
|
|
23
|
-
|
|
24
|
-
constructor(listKey: string, fieldKey: string, depth: number) {
|
|
25
|
-
super(
|
|
26
|
-
`Cannot include "${listKey}.${fieldKey}" at include depth ${depth}: this exceeds the read ` +
|
|
27
|
-
`pipeline's maximum include depth (${READ_INCLUDE_MAX_DEPTH}). This is a cost limit, not an ` +
|
|
28
|
-
`inability to scope — the engine declines to serve a tree this deep rather than returning ` +
|
|
29
|
-
`it. Restructure the query to fetch this relation separately.`,
|
|
30
|
-
)
|
|
31
|
-
this.name = 'AccessScopeDepthExceededError'
|
|
32
|
-
this.listKey = listKey
|
|
33
|
-
this.fieldKey = fieldKey
|
|
34
|
-
this.depth = depth
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Thrown when a `resolveOutput` hook re-enters a `(list, field)` pair already
|
|
40
|
-
* on its own resolve chain — a hook whose own read (directly or transitively)
|
|
41
|
-
* comes back around to itself. Deliberately distinct from `ValidationError`
|
|
42
|
-
* (same reasoning as `AccessScopeDepthExceededError`): this is not bad user
|
|
43
|
-
* input, it is the engine refusing to run a hook chain that cannot terminate.
|
|
44
|
-
*
|
|
45
|
-
* This is a loud failure, not a Silent one, on purpose: a repeated pair never
|
|
46
|
-
* terminated before this guard existed, so no working application can depend
|
|
47
|
-
* on the old (hanging) behaviour, and staying silent here would return
|
|
48
|
-
* `undefined` for a field with nothing in the logs to explain why. Contrast
|
|
49
|
-
* with exceeding `RESOLVE_CHAIN_MAX_LENGTH`, which can happen on a chain that
|
|
50
|
-
* would otherwise terminate correctly and therefore only warns. See ADR-0023.
|
|
51
|
-
*/
|
|
52
|
-
export class ResolveOutputCycleError extends Error {
|
|
53
|
-
public chain: readonly { listKey: string; fieldKey: string }[]
|
|
54
|
-
|
|
55
|
-
constructor(chain: readonly { listKey: string; fieldKey: string }[]) {
|
|
56
|
-
const path = chain.map((link) => `${link.listKey}.${link.fieldKey}`).join(' → ')
|
|
57
|
-
super(
|
|
58
|
-
`resolveOutput cycle detected: ${path}. A hook that re-enters a (list, field) pair ` +
|
|
59
|
-
`already on its own resolve chain cannot terminate, so the read is refused rather than ` +
|
|
60
|
-
`left to recurse until the process runs out of memory. Restructure the hooks so the read ` +
|
|
61
|
-
`does not loop back into itself.`,
|
|
62
|
-
)
|
|
63
|
-
this.name = 'ResolveOutputCycleError'
|
|
64
|
-
this.chain = chain
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Thrown when a relation filter in a caller's `where` (`some`/`every`/`none`/
|
|
70
|
-
* `is`/`isNot`) names a relationship whose related list denies operation-level
|
|
71
|
-
* `query` access outright (`=== false`). Deliberately a loud failure, not a
|
|
72
|
-
* silently narrowed `{ id: { in: [] } }` or a pass-through: ADR-0022 requires
|
|
73
|
-
* an engine that cannot compute a scope to deny, never pass through, and here
|
|
74
|
-
* the engine CAN compute the scope (denied) — passing that through as a
|
|
75
|
-
* silently-empty match would itself be a distinguishable signal for a caller
|
|
76
|
-
* probing which relations they may filter on. `include`'s equivalent case
|
|
77
|
-
* (`buildAccessScopedInclude`) drops the relation silently instead, because a
|
|
78
|
-
* `null`/missing key in a response is indistinguishable from "not requested";
|
|
79
|
-
* a `where` predicate has no such neutral outcome, so a relation filter on a
|
|
80
|
-
* fully denied relation is refused instead. `sudo` bypasses this check
|
|
81
|
-
* entirely, matching every other access-control escape hatch. See #916 and
|
|
82
|
-
* `docs/adr/0022-access-control-fails-closed-when-it-cannot-scope.md`.
|
|
83
|
-
*/
|
|
84
|
-
export class RelationFilterAccessDeniedError extends Error {
|
|
85
|
-
public listKey: string
|
|
86
|
-
public fieldKey: string
|
|
87
|
-
public relatedListKey: string
|
|
88
|
-
|
|
89
|
-
constructor(listKey: string, fieldKey: string, relatedListKey: string) {
|
|
90
|
-
super(
|
|
91
|
-
`Cannot filter "${listKey}.${fieldKey}" — the related list "${relatedListKey}" denies ` +
|
|
92
|
-
`query access to this session, so this relation filter cannot be scoped. Denial is loud ` +
|
|
93
|
-
`rather than silently narrowed to match nothing (ADR-0022). Use sudo to bypass.`,
|
|
94
|
-
)
|
|
95
|
-
this.name = 'RelationFilterAccessDeniedError'
|
|
96
|
-
this.listKey = listKey
|
|
97
|
-
this.fieldKey = fieldKey
|
|
98
|
-
this.relatedListKey = relatedListKey
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Thrown when a caller-supplied `include` names a key that resolves to
|
|
104
|
-
* neither a declared relationship, a synthetic back-relation (a list-only
|
|
105
|
-
* `ref`'s ORM-required opposite field, which no list config declares — see
|
|
106
|
-
* `resolveSyntheticReverseRelation`), nor `_count`. Before this,
|
|
107
|
-
* `buildAccessScopedInclude`'s scoping walk passed an unrecognised key
|
|
108
|
-
* straight through unscoped — the one surface among `data`/`where`/`orderBy`/
|
|
109
|
-
* `include` that failed open rather than closed (issue #1082). `sudo` never
|
|
110
|
-
* reaches this: it skips `buildAccessScopedInclude` entirely (see
|
|
111
|
-
* `resolveReadInclude` in `context/index.ts`), matching every other
|
|
112
|
-
* access-control escape hatch.
|
|
113
|
-
*/
|
|
114
|
-
export class UndeclaredIncludeKeyError extends Error {
|
|
115
|
-
public listKey: string
|
|
116
|
-
public fieldKey: string
|
|
117
|
-
|
|
118
|
-
constructor(listKey: string, fieldKey: string) {
|
|
119
|
-
super(
|
|
120
|
-
`Cannot include "${listKey}.${fieldKey}" — it is not a field of this list. ` +
|
|
121
|
-
`Undeclared include keys are rejected, matching data/where/orderBy keys.`,
|
|
122
|
-
)
|
|
123
|
-
this.name = 'UndeclaredIncludeKeyError'
|
|
124
|
-
this.listKey = listKey
|
|
125
|
-
this.fieldKey = fieldKey
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Thrown when a caller-supplied `_count.select` in `include` names a key that
|
|
131
|
-
* is not a countable to-many relation — undeclared, a scalar, a virtual, or a
|
|
132
|
-
* to-one relationship. Mirrors `UndeclaredIncludeKeyError`'s rejection for the
|
|
133
|
-
* ordinary `include` walk, for the one key shape that was allowlisted through
|
|
134
|
-
* unscoped rather than rejected (#1082's "Out of scope", closed here by
|
|
135
|
-
* #1087). A key naming a synthetic back-relation (#1082) is NOT rejected — it
|
|
136
|
-
* is a genuine countable to-many, resolved the same way the ordinary
|
|
137
|
-
* `include` walk resolves it. `sudo` never reaches this: it skips
|
|
138
|
-
* `buildAccessScopedInclude` entirely (see `resolveReadInclude` in
|
|
139
|
-
* `context/index.ts`), matching every other access-control escape hatch.
|
|
140
|
-
*/
|
|
141
|
-
export class UndeclaredCountKeyError extends Error {
|
|
142
|
-
public listKey: string
|
|
143
|
-
public fieldKey: string
|
|
144
|
-
|
|
145
|
-
constructor(listKey: string, fieldKey: string) {
|
|
146
|
-
super(
|
|
147
|
-
`Cannot count "${listKey}.${fieldKey}" — it is not a countable to-many relationship on this ` +
|
|
148
|
-
`list. A \`_count.select\` key must name a declared to-many relationship or a synthetic ` +
|
|
149
|
-
`back-relation, matching the ordinary include keys this list accepts.`,
|
|
150
|
-
)
|
|
151
|
-
this.name = 'UndeclaredCountKeyError'
|
|
152
|
-
this.listKey = listKey
|
|
153
|
-
this.fieldKey = fieldKey
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function describeAccessResult(result: unknown): string {
|
|
158
|
-
if (result === null) return 'null'
|
|
159
|
-
if (result === undefined) return 'undefined'
|
|
160
|
-
if (typeof result === 'object') return 'an object (e.g. a Prisma filter)'
|
|
161
|
-
return `a ${typeof result}`
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Thrown when a field-level access control function returns anything other
|
|
166
|
-
* than a strict `boolean`. `FieldAccessControl` is typed to return `boolean`
|
|
167
|
-
* only: field access is a single per-field visibility decision, not a row
|
|
168
|
-
* filter, and a denied field is removed rather than used to scope rows (see
|
|
169
|
-
* the "Field-level access" glossary entry in `CONTEXT.md`, ADR-0001, and
|
|
170
|
-
* ADR-0030).
|
|
171
|
-
*
|
|
172
|
-
* A rule that type-checks can never reach this — the only way here is a
|
|
173
|
-
* caller that bypasses the type (an untyped JS config, or a value forced past
|
|
174
|
-
* the checker), most notably a Prisma filter, which is the shape
|
|
175
|
-
* operation-level `AccessControl` accepts but `FieldAccessControl` does not.
|
|
176
|
-
* Before #913 this fell through to an unconditional `return true`, silently
|
|
177
|
-
* granting the field blanket access; it now fails loudly and closed instead,
|
|
178
|
-
* for `read`, `create`, and `update` alike.
|
|
179
|
-
*
|
|
180
|
-
* Deliberately does not expose the offending result as a public field: unlike
|
|
181
|
-
* `AccessScopeDepthExceededError`/`ResolveOutputCycleError`'s fields, there is
|
|
182
|
-
* no concretely-typed shape to give it (the whole problem is that it isn't
|
|
183
|
-
* the `boolean` the caller's rule promised), and the root CLAUDE.md forbids
|
|
184
|
-
* exposing `unknown`/`any` as part of a package's external API. A description
|
|
185
|
-
* of what was returned instead is folded into the message text.
|
|
186
|
-
*/
|
|
187
|
-
export class InvalidFieldAccessResultError extends Error {
|
|
188
|
-
public operation: 'read' | 'create' | 'update'
|
|
189
|
-
|
|
190
|
-
constructor(operation: 'read' | 'create' | 'update', result: unknown) {
|
|
191
|
-
super(
|
|
192
|
-
`Field-level access control for operation "${operation}" returned ` +
|
|
193
|
-
`${describeAccessResult(result)}, not a boolean. Field access is a per-field ` +
|
|
194
|
-
`visibility decision — it must return true or false, and (unlike operation-level access) ` +
|
|
195
|
-
`cannot scope which rows are affected. If you meant to restrict access based on the row or ` +
|
|
196
|
-
`the write payload, evaluate the condition yourself and return a boolean, e.g. ` +
|
|
197
|
-
`\`({ item, session }) => item?.ownerId === session?.userId\`.`,
|
|
198
|
-
)
|
|
199
|
-
this.name = 'InvalidFieldAccessResultError'
|
|
200
|
-
this.operation = operation
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Thrown when operation-level `create` access control returns anything other
|
|
206
|
-
* than a strict `boolean`. `OperationAccess['create']` is typed as
|
|
207
|
-
* `AccessControl`, which also accepts a `PrismaFilter` — the shape
|
|
208
|
-
* `query`/`update`/`delete` legitimately use to scope which rows an
|
|
209
|
-
* operation may touch (see ADR-0001). Create has none of that to scope: there
|
|
210
|
-
* is no existing row, and — unlike update/delete, which re-check a returned
|
|
211
|
-
* filter against the target via `findFirst` — no equivalent re-check is
|
|
212
|
-
* possible against data that doesn't exist in the database yet.
|
|
213
|
-
*
|
|
214
|
-
* A filter-returning `create` rule type-checks (the shared `AccessControl`
|
|
215
|
-
* type admits it) and reads as though it scopes the create. Before this it
|
|
216
|
-
* fell through a check that only tested `=== false` and was silently treated
|
|
217
|
-
* as a full allow. This is the same defect shape ADR-0030 closed for
|
|
218
|
-
* field-level access, resolved the same way per ADR-0022 (an engine that
|
|
219
|
-
* cannot compute a scope must deny, never pass through) — a loud, distinct
|
|
220
|
-
* failure rather than a wider `null`/`[]` Silent failure, because this is a
|
|
221
|
-
* config bug, not an access denial.
|
|
222
|
-
*
|
|
223
|
-
* Deliberately does not expose the offending result as a public field, for
|
|
224
|
-
* the same reason as `InvalidFieldAccessResultError`: there is no
|
|
225
|
-
* concretely-typed shape to give it, and the root CLAUDE.md forbids exposing
|
|
226
|
-
* `unknown`/`any` as part of a package's external API.
|
|
227
|
-
*/
|
|
228
|
-
export class InvalidCreateAccessResultError extends Error {
|
|
229
|
-
public listKey: string
|
|
230
|
-
|
|
231
|
-
constructor(listKey: string, result: unknown) {
|
|
232
|
-
super(
|
|
233
|
-
`Operation-level "create" access control for "${listKey}" returned ` +
|
|
234
|
-
`${describeAccessResult(result)}, not a boolean. Create cannot be row-scoped — there is no ` +
|
|
235
|
-
`existing row, and no input data is available to test a filter against here. Return a ` +
|
|
236
|
-
`boolean from create access, or move the ownership check into a \`resolveInput\` or ` +
|
|
237
|
-
`\`validate\` hook, where the input data is in scope.`,
|
|
238
|
-
)
|
|
239
|
-
this.name = 'InvalidCreateAccessResultError'
|
|
240
|
-
this.listKey = listKey
|
|
241
|
-
}
|
|
242
|
-
}
|