@opensaas/stack-core 0.42.3 → 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 +2745 -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 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +105 -44
- 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 -47
- package/dist/context/nested-operations.d.ts.map +0 -1
- package/dist/context/nested-operations.js +0 -731
- 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 -1325
- 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 -184
- 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 -3141
- 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 -231
- 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,108 +1,122 @@
|
|
|
1
1
|
import type { FieldConfig, OpenSaasConfig } from '../config/types.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DependencyTable, ListDependencies } from '../contract/dependencies.js';
|
|
3
3
|
/**
|
|
4
|
-
* Declared Dependencies —
|
|
5
|
-
*
|
|
4
|
+
* Declared Dependencies — widening a read for the `needs` of the computed
|
|
5
|
+
* fields it is about to return, without widening what the caller receives
|
|
6
|
+
* (ADR-0025, ADR-0051).
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* scoped exactly like a caller-named one, never a bypass.
|
|
8
|
+
* The sets are an emitted fact, not a walk: `pnpm generate` resolves every
|
|
9
|
+
* `(list, field)` into its one-hop set and the generated context hands the
|
|
10
|
+
* table to the runtime through `config._tables`. A config reached without
|
|
11
|
+
* generation — a test, a tool — gets the same table from the same
|
|
12
|
+
* computation, memoised per config rather than recomputed per read.
|
|
13
13
|
*
|
|
14
|
-
* The
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
* The set is one hop and non-transitive. A branch added purely to satisfy a
|
|
15
|
+
* declaration delivers its rows' stored columns and nothing else: no computed
|
|
16
|
+
* field runs on it, so nothing on it declares anything, so the widening never
|
|
17
|
+
* recurses. Recursion is therefore bounded by the caller's own finite
|
|
18
|
+
* `include` literal, and the `visitedLists` cycle guard the recursive fold
|
|
19
|
+
* needed is deleted along with `validateNeedsClosureDepth` (ADR-0051).
|
|
19
20
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* auto-expansion that used to carry a chain of declarations "for free" —
|
|
24
|
-
* naming a relation now fetches its own columns and stops — a field computed
|
|
25
|
-
* one hop down would otherwise lose its own declared dependencies the moment
|
|
26
|
-
* its list is reached any way OTHER than an explicit nested caller `include`.
|
|
27
|
-
* Declarations fold in "at every level a field is computed" (ADR-0025), not
|
|
28
|
-
* only where the caller happened to write one out.
|
|
21
|
+
* A branch the caller named IS returned, so ADR-0027 has its
|
|
22
|
+
* computed fields run and this module widens at that level too — which is why
|
|
23
|
+
* it still descends into caller-named keys.
|
|
29
24
|
*
|
|
30
|
-
* A
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* branch present for another reason (caller/fragment-named) needs the
|
|
34
|
-
* fine-grained `declaredOnly.nested` tracking, so a declaration folded
|
|
35
|
-
* beneath IT can be stripped without removing the caller's own data.
|
|
36
|
-
*
|
|
37
|
-
* **Cycle guard, re-pointed (ADR-0026).** A caller-supplied `include` is
|
|
38
|
-
* always a finite literal and cannot cycle. Recursively following declared
|
|
39
|
-
* dependencies across lists CAN — list A declaring `needs` on a relation to
|
|
40
|
-
* list B, whose own field declares `needs` back to A — so `visitedLists`
|
|
41
|
-
* carries the list names already on this fold's own path and stops rather
|
|
42
|
-
* than recursing without bound. `pnpm generate`'s `validateNeedsClosureDepth`
|
|
43
|
-
* (`needs-closure.ts`) is the primary backstop — a cyclic `needs` closure
|
|
44
|
-
* fails generation and should never reach this code at runtime — this guard
|
|
45
|
-
* is defense in depth, not the mechanism relied on for correctness.
|
|
46
|
-
*
|
|
47
|
-
* The guard applies to DECLARATION-ADDED edges only, which is exactly where
|
|
48
|
-
* the unbounded recursion can come from: a branch added by this fold carries
|
|
49
|
-
* no caller include of its own, so everything beneath it is declaration-added
|
|
50
|
-
* too, and each such edge either reaches a list not yet on the path or stops
|
|
51
|
-
* — bounding that suffix by the number of lists. An edge the request itself
|
|
52
|
-
* named is bounded by the request's own finite literal instead. Applying the
|
|
53
|
-
* guard to those as well would stop the fold at a path that merely revisits a
|
|
54
|
-
* list (`Post → author → posts`, or a self-referential `parent`), silently
|
|
55
|
-
* leaving the revisited list's own declared dependencies unsatisfied — the
|
|
56
|
-
* `undefined`-compute ADR-0025 exists to prevent, at every level a field is
|
|
57
|
-
* computed.
|
|
25
|
+
* A declared column needs no widening: every read already carries the row's
|
|
26
|
+
* stored columns, and `field-visibility.ts` keeps a declared one on the hook's
|
|
27
|
+
* `item` when the caller's projection left it out.
|
|
58
28
|
*/
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
29
|
+
/**
|
|
30
|
+
* The relation keys, at each nesting level, that only the widening added.
|
|
31
|
+
* `field-visibility.ts` strips them from the result once `resolveOutput` has
|
|
32
|
+
* had its chance to read them — a declared dependency is private plumbing,
|
|
33
|
+
* not an implicit `include`.
|
|
34
|
+
*/
|
|
35
|
+
export type DependencyAdditions = {
|
|
36
|
+
/** Keys at THIS level whose entire branch the widening added. */
|
|
62
37
|
keys: Set<string>;
|
|
63
|
-
/** Per-key
|
|
64
|
-
nested: Record<string,
|
|
38
|
+
/** Per-key additions beneath a relation the caller named for its own reasons. */
|
|
39
|
+
nested: Record<string, DependencyAdditions>;
|
|
65
40
|
};
|
|
66
|
-
export declare function emptyDeclaredOnlyTree(): DeclaredOnlyTree;
|
|
67
41
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* to fetch.
|
|
42
|
+
* Which field names a level of a read is going to return, and the same tree
|
|
43
|
+
* one level down for every relation it reaches. `fields: undefined` means
|
|
44
|
+
* unrestricted — what a read that named no projection at that level means.
|
|
72
45
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* computed field on the list.
|
|
46
|
+
* It is what makes computation projection-aware (ADR-0027): a field a level
|
|
47
|
+
* does not return is never computed, its read access is never evaluated and
|
|
48
|
+
* its declared dependencies are never fetched. It is also the caller half of
|
|
49
|
+
* the widen-and-strip difference (ADR-0041) — anything the engine added for
|
|
50
|
+
* its own reasons is outside it, and Field Visibility strips it back out.
|
|
79
51
|
*/
|
|
80
|
-
export
|
|
52
|
+
export type FieldSelectionScope = {
|
|
53
|
+
readonly fields: ReadonlySet<string> | undefined;
|
|
54
|
+
readonly nested: Readonly<Record<string, FieldSelectionScope>>;
|
|
55
|
+
};
|
|
56
|
+
export declare function noDependencyAdditions(): DependencyAdditions;
|
|
81
57
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
58
|
+
* Relation keys, at each nesting level, whose fetched value is a declared-
|
|
59
|
+
* dependency rows stand-in rather than what the caller asked to see: a
|
|
60
|
+
* relation that is both reduced (`.count()`/`.combine()`) and a live declared
|
|
61
|
+
* dependency of a computed field returned alongside it (`IncludePlan.declaredRows`
|
|
62
|
+
* in `secured/include.ts`). Field Visibility treats each one as a raw
|
|
63
|
+
* pass-through — no recursion, no computed field runs on it, matching an
|
|
64
|
+
* ordinary declared branch (ADR-0051) — and leaves the key in the result for
|
|
65
|
+
* `restoreReductions` (`secured/read.ts`) to overwrite with the reduction's
|
|
66
|
+
* own value. Unlike {@link DependencyAdditions}, a key here is never stripped:
|
|
67
|
+
* the caller named the relation, so something is owed back under it.
|
|
68
|
+
*/
|
|
69
|
+
export type ReducedDeclaredKeys = {
|
|
70
|
+
/** Keys at THIS level carrying a declared-rows stand-in rather than their own value. */
|
|
71
|
+
keys: ReadonlySet<string>;
|
|
72
|
+
/** The same tree one level down for a relation reached via a caller-named branch. */
|
|
73
|
+
nested: Readonly<Record<string, ReducedDeclaredKeys>>;
|
|
74
|
+
};
|
|
75
|
+
export declare function noReducedDeclaredKeys(): ReducedDeclaredKeys;
|
|
76
|
+
/**
|
|
77
|
+
* The dependency-set table for `config`: the one `pnpm generate` emitted when
|
|
78
|
+
* the generated context supplied it, otherwise the same computation.
|
|
79
|
+
*/
|
|
80
|
+
export declare function getDependencyTable(config: OpenSaasConfig): DependencyTable;
|
|
81
|
+
/**
|
|
82
|
+
* One list's row in the table.
|
|
87
83
|
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
84
|
+
* A list the emitted table does not describe is a bundle older than the config
|
|
85
|
+
* — a list added without regenerating. Answering with an empty row would be
|
|
86
|
+
* silently wrong in two directions at once: the list's declared columns would
|
|
87
|
+
* stop reaching their hooks, and its timestamps would stop being exempt from
|
|
88
|
+
* field access. So the row is derived from the config instead. The emitted
|
|
89
|
+
* table stays authoritative everywhere it speaks, and a stale one degrades to
|
|
90
|
+
* the behaviour that predated emission rather than to silence.
|
|
91
91
|
*
|
|
92
|
-
* `
|
|
93
|
-
*
|
|
92
|
+
* The `id`-only row survives for a list key the config does not have either,
|
|
93
|
+
* where there is genuinely nothing to say.
|
|
94
|
+
*/
|
|
95
|
+
export declare function getListDependencies(config: OpenSaasConfig, listKey: string): ListDependencies;
|
|
96
|
+
/**
|
|
97
|
+
* The union of the dependency sets of the computed fields this read will
|
|
98
|
+
* return (ADR-0027). `selectedFields`, when given, is the read's own
|
|
99
|
+
* projection — a field it did not select is never computed, so its
|
|
100
|
+
* declarations are not paid for. `undefined` means unrestricted, matching a
|
|
101
|
+
* read that named no projection, which returns every computed field.
|
|
102
|
+
*/
|
|
103
|
+
export declare function resolveDeclaredDependencies(config: OpenSaasConfig, listKey: string, selectedFields?: ReadonlySet<string>): {
|
|
104
|
+
columns: Set<string>;
|
|
105
|
+
relations: Set<string>;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Widen `rawInclude` with the declared relations of the computed fields this
|
|
109
|
+
* read returns, and report which keys the widening added so they can be
|
|
110
|
+
* stripped afterwards.
|
|
94
111
|
*
|
|
95
|
-
* `
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* relation added purely by this fold has no fragment scope of its own, so
|
|
101
|
-
* its own list folds unrestricted, exactly as it did before selectivity
|
|
102
|
-
* existed.
|
|
112
|
+
* Returns `rawInclude` itself (same reference) when there is nothing to
|
|
113
|
+
* widen, so a list with no declarations and no caller include stays on the
|
|
114
|
+
* exact bare-read path (ADR-0024) — untouched, not merely equivalent. A list
|
|
115
|
+
* whose declarations name columns alone stays there too: a column is already
|
|
116
|
+
* on the row.
|
|
103
117
|
*/
|
|
104
|
-
export declare function
|
|
118
|
+
export declare function widenIncludeForDependencies(rawInclude: Record<string, unknown> | undefined, fieldConfigs: Record<string, FieldConfig>, config: OpenSaasConfig, listKey: string, selection?: FieldSelectionScope): {
|
|
105
119
|
include: Record<string, unknown> | undefined;
|
|
106
|
-
|
|
120
|
+
additions: DependencyAdditions;
|
|
107
121
|
};
|
|
108
122
|
//# sourceMappingURL=declared-dependencies.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declared-dependencies.d.ts","sourceRoot":"","sources":["../../src/access/declared-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"declared-dependencies.d.ts","sourceRoot":"","sources":["../../src/access/declared-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAIpF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,iEAAiE;IACjE,IAAI,EAAE,GAAG,CAAC,MAA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CAAC,MAAM,EAAE,WAAW,CAAC,EACzC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,mBAAmB,GAC9B;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAAC,SAAS,EAAE,mBAAmB,CAAA;CAAE,CAmDlF"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { deriveDependencyTable } from '../contract/dependencies.js';
|
|
1
2
|
import { getRelatedListConfig } from './engine.js';
|
|
2
|
-
export function
|
|
3
|
+
export function noDependencyAdditions() {
|
|
3
4
|
return { keys: new Set(), nested: {} };
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
const EMPTY_REDUCED_DECLARED_KEYS = { keys: new Set(), nested: {} };
|
|
7
|
+
export function noReducedDeclaredKeys() {
|
|
8
|
+
return EMPTY_REDUCED_DECLARED_KEYS;
|
|
9
|
+
}
|
|
10
|
+
function isEmpty(additions) {
|
|
11
|
+
return additions.keys.size === 0 && Object.keys(additions.nested).length === 0;
|
|
7
12
|
}
|
|
8
13
|
function isRelationshipFieldConfig(fieldConfig) {
|
|
9
14
|
return (!!fieldConfig &&
|
|
@@ -22,103 +27,110 @@ function getExplicitInclude(value) {
|
|
|
22
27
|
const { include } = value;
|
|
23
28
|
return isPlainObject(include) ? include : undefined;
|
|
24
29
|
}
|
|
30
|
+
const derived = new WeakMap();
|
|
31
|
+
/** The table `config` derives, computed once and memoised rather than per read. */
|
|
32
|
+
function deriveOnce(config) {
|
|
33
|
+
const cached = derived.get(config);
|
|
34
|
+
if (cached)
|
|
35
|
+
return cached;
|
|
36
|
+
const table = deriveDependencyTable(config);
|
|
37
|
+
derived.set(config, table);
|
|
38
|
+
return table;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The dependency-set table for `config`: the one `pnpm generate` emitted when
|
|
42
|
+
* the generated context supplied it, otherwise the same computation.
|
|
43
|
+
*/
|
|
44
|
+
export function getDependencyTable(config) {
|
|
45
|
+
return config._tables?.dependencies ?? deriveOnce(config);
|
|
46
|
+
}
|
|
47
|
+
const EMPTY_LIST_DEPENDENCIES = { systemFields: ['id'], fields: {} };
|
|
25
48
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
49
|
+
* One list's row in the table.
|
|
50
|
+
*
|
|
51
|
+
* A list the emitted table does not describe is a bundle older than the config
|
|
52
|
+
* — a list added without regenerating. Answering with an empty row would be
|
|
53
|
+
* silently wrong in two directions at once: the list's declared columns would
|
|
54
|
+
* stop reaching their hooks, and its timestamps would stop being exempt from
|
|
55
|
+
* field access. So the row is derived from the config instead. The emitted
|
|
56
|
+
* table stays authoritative everywhere it speaks, and a stale one degrades to
|
|
57
|
+
* the behaviour that predated emission rather than to silence.
|
|
30
58
|
*
|
|
31
|
-
* `
|
|
32
|
-
*
|
|
33
|
-
* never computed, so its declared relation is never fetched for it either.
|
|
34
|
-
* `undefined` means unrestricted: every field with a hook contributes,
|
|
35
|
-
* matching a bare or `include`-based read, which always returns every
|
|
36
|
-
* computed field on the list.
|
|
59
|
+
* The `id`-only row survives for a list key the config does not have either,
|
|
60
|
+
* where there is genuinely nothing to say.
|
|
37
61
|
*/
|
|
38
|
-
export function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
62
|
+
export function getListDependencies(config, listKey) {
|
|
63
|
+
return (getDependencyTable(config)[listKey] ?? deriveOnce(config)[listKey] ?? EMPTY_LIST_DEPENDENCIES);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The union of the dependency sets of the computed fields this read will
|
|
67
|
+
* return (ADR-0027). `selectedFields`, when given, is the read's own
|
|
68
|
+
* projection — a field it did not select is never computed, so its
|
|
69
|
+
* declarations are not paid for. `undefined` means unrestricted, matching a
|
|
70
|
+
* read that named no projection, which returns every computed field.
|
|
71
|
+
*/
|
|
72
|
+
export function resolveDeclaredDependencies(config, listKey, selectedFields) {
|
|
73
|
+
const columns = new Set();
|
|
74
|
+
const relations = new Set();
|
|
75
|
+
for (const [fieldKey, set] of Object.entries(getListDependencies(config, listKey).fields)) {
|
|
76
|
+
if (selectedFields && !selectedFields.has(fieldKey))
|
|
44
77
|
continue;
|
|
45
|
-
for (const
|
|
46
|
-
|
|
47
|
-
|
|
78
|
+
for (const column of set.columns)
|
|
79
|
+
columns.add(column);
|
|
80
|
+
for (const relation of set.relations)
|
|
81
|
+
relations.add(relation);
|
|
48
82
|
}
|
|
49
|
-
return
|
|
83
|
+
return { columns, relations };
|
|
50
84
|
}
|
|
51
85
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* declared dependencies are satisfied too, wherever it's reached (see module
|
|
56
|
-
* doc comment).
|
|
86
|
+
* Widen `rawInclude` with the declared relations of the computed fields this
|
|
87
|
+
* read returns, and report which keys the widening added so they can be
|
|
88
|
+
* stripped afterwards.
|
|
57
89
|
*
|
|
58
90
|
* Returns `rawInclude` itself (same reference) when there is nothing to
|
|
59
|
-
*
|
|
60
|
-
* exact bare-read path (ADR-0024) — untouched, not merely equivalent.
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* extend it with each related list reached along THIS fold's own path.
|
|
64
|
-
*
|
|
65
|
-
* `selection`, when given, is the fragment scope this level was reached
|
|
66
|
-
* under (ADR-0027) — only fields it names contribute their `needs` (see
|
|
67
|
-
* `getDeclaredRelationNames`). It is `undefined` for a bare/`include`-based
|
|
68
|
-
* read (unrestricted: every field's `needs` folds in, unchanged from before
|
|
69
|
-
* ADR-0027) and for any branch reached only to satisfy a declaration — a
|
|
70
|
-
* relation added purely by this fold has no fragment scope of its own, so
|
|
71
|
-
* its own list folds unrestricted, exactly as it did before selectivity
|
|
72
|
-
* existed.
|
|
91
|
+
* widen, so a list with no declarations and no caller include stays on the
|
|
92
|
+
* exact bare-read path (ADR-0024) — untouched, not merely equivalent. A list
|
|
93
|
+
* whose declarations name columns alone stays there too: a column is already
|
|
94
|
+
* on the row.
|
|
73
95
|
*/
|
|
74
|
-
export function
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
96
|
+
export function widenIncludeForDependencies(rawInclude, fieldConfigs, config, listKey, selection) {
|
|
97
|
+
const declared = [
|
|
98
|
+
...resolveDeclaredDependencies(config, listKey, selection?.fields).relations,
|
|
99
|
+
].filter((name) => isRelationshipFieldConfig(fieldConfigs[name]));
|
|
100
|
+
if (declared.length === 0 && !rawInclude) {
|
|
101
|
+
return { include: rawInclude, additions: noDependencyAdditions() };
|
|
78
102
|
}
|
|
79
|
-
const
|
|
103
|
+
const additions = noDependencyAdditions();
|
|
80
104
|
const merged = { ...(rawInclude ?? {}) };
|
|
81
|
-
for (const name of
|
|
105
|
+
for (const name of declared) {
|
|
82
106
|
if (name in merged)
|
|
83
|
-
continue; // caller
|
|
84
|
-
if (!isRelationshipFieldConfig(fieldConfigs[name]))
|
|
85
|
-
continue; // invalid `needs` entry; caught by generate-time validation
|
|
107
|
+
continue; // the caller asked for it — not an addition
|
|
86
108
|
merged[name] = true;
|
|
87
|
-
|
|
109
|
+
additions.keys.add(name);
|
|
88
110
|
}
|
|
89
111
|
for (const [key, value] of Object.entries(merged)) {
|
|
112
|
+
// A branch the widening added carries no caller include of its own and
|
|
113
|
+
// returns to nobody, so nothing on it computes and nothing on it declares
|
|
114
|
+
// (ADR-0051). Only the caller's own tree descends.
|
|
115
|
+
if (additions.keys.has(key))
|
|
116
|
+
continue;
|
|
90
117
|
const fieldConfig = fieldConfigs[key];
|
|
91
118
|
if (!isRelationshipFieldConfig(fieldConfig))
|
|
92
119
|
continue;
|
|
93
120
|
const relatedConfig = getRelatedListConfig(fieldConfig.ref, config);
|
|
94
121
|
if (!relatedConfig)
|
|
95
122
|
continue;
|
|
96
|
-
|
|
97
|
-
// edge into a list already on this path stops here; the value at `key`
|
|
98
|
-
// is left exactly as-is.
|
|
99
|
-
if (declaredOnly.keys.has(key) && visitedLists.includes(relatedConfig.listName))
|
|
100
|
-
continue;
|
|
101
|
-
// A branch added purely by the fold has no fragment scope of its own —
|
|
102
|
-
// it folds unrestricted, as before ADR-0027. A branch the request itself
|
|
103
|
-
// named (caller include or fragment) carries that name's own nested
|
|
104
|
-
// scope, if the fragment gave it one (a bare `true` selector leaves it
|
|
105
|
-
// `undefined` — also unrestricted, since the caller asked for
|
|
106
|
-
// "everything" there).
|
|
107
|
-
const nestedSelection = declaredOnly.keys.has(key) ? undefined : selection?.nested[key];
|
|
108
|
-
const explicitNested = getExplicitInclude(value);
|
|
109
|
-
const nested = foldDeclaredDependencies(explicitNested, relatedConfig.listConfig.fields, config, relatedConfig.listName, [...visitedLists, relatedConfig.listName], nestedSelection);
|
|
123
|
+
const nested = widenIncludeForDependencies(getExplicitInclude(value), relatedConfig.listConfig.fields, config, relatedConfig.listName, selection?.nested[key]);
|
|
110
124
|
if (nested.include) {
|
|
111
125
|
merged[key] = {
|
|
112
126
|
...(typeof value === 'object' && value ? value : {}),
|
|
113
127
|
include: nested.include,
|
|
114
128
|
};
|
|
115
129
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (!declaredOnly.keys.has(key) && !isDeclaredOnlyTreeEmpty(nested.declaredOnly)) {
|
|
119
|
-
declaredOnly.nested[key] = nested.declaredOnly;
|
|
130
|
+
if (!isEmpty(nested.additions)) {
|
|
131
|
+
additions.nested[key] = nested.additions;
|
|
120
132
|
}
|
|
121
133
|
}
|
|
122
|
-
return { include: merged,
|
|
134
|
+
return { include: merged, additions };
|
|
123
135
|
}
|
|
124
136
|
//# sourceMappingURL=declared-dependencies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declared-dependencies.js","sourceRoot":"","sources":["../../src/access/declared-dependencies.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"declared-dependencies.js","sourceRoot":"","sources":["../../src/access/declared-dependencies.ts"],"names":[],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AC1E,mDAAmD;QACnD,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAQ;QAErC,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,CAAA;QACrC,IAAI,CAAC,yBAAyB,CAAC,WAAW,CAAC;YAAE,SAAQ;QAErD,MAAM,aAAa,GAAG,oBAAoB,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACnE,IAAI,CAAC,aAAa;YAAE,SAAQ;QAE5B,MAAM,MAAM,GAAG,2BAA2B,CACxC,kBAAkB,CAAC,KAAK,CAAC,EACzB,aAAa,CAAC,UAAU,CAAC,MAAM,EAC/B,MAAM,EACN,aAAa,CAAC,QAAQ,EACtB,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,CACvB,CAAA;QAED,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,CAAC,GAAG,CAAC,GAAG;gBACZ,GAAG,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpD,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB,CAAA;QACH,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YAC/B,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,SAAS,CAAA;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA;AACvC,CAAC"}
|
|
@@ -24,4 +24,8 @@ export declare const READ_INCLUDE_MAX_DEPTH = 5;
|
|
|
24
24
|
* regardless of this cap. See ADR-0023.
|
|
25
25
|
*/
|
|
26
26
|
export declare const RESOLVE_CHAIN_MAX_LENGTH = 5;
|
|
27
|
+
/** Maximum relation-quantifier nesting depth of a caller `where`. */
|
|
28
|
+
export declare const WHERE_RELATION_MAX_DEPTH = 5;
|
|
29
|
+
/** Maximum number of predicate entries in one caller `where`. */
|
|
30
|
+
export declare const WHERE_MAX_NODES = 256;
|
|
27
31
|
//# sourceMappingURL=depth-limits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depth-limits.d.ts","sourceRoot":"","sources":["../../src/access/depth-limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAEvC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAA"}
|
|
1
|
+
{"version":3,"file":"depth-limits.d.ts","sourceRoot":"","sources":["../../src/access/depth-limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAEvC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAA;AAEzC,qEAAqE;AACrE,eAAO,MAAM,wBAAwB,IAAyB,CAAA;AAE9D,iEAAiE;AACjE,eAAO,MAAM,eAAe,MAAM,CAAA"}
|
|
@@ -24,4 +24,8 @@ export const READ_INCLUDE_MAX_DEPTH = 5;
|
|
|
24
24
|
* regardless of this cap. See ADR-0023.
|
|
25
25
|
*/
|
|
26
26
|
export const RESOLVE_CHAIN_MAX_LENGTH = 5;
|
|
27
|
+
/** Maximum relation-quantifier nesting depth of a caller `where`. */
|
|
28
|
+
export const WHERE_RELATION_MAX_DEPTH = READ_INCLUDE_MAX_DEPTH;
|
|
29
|
+
/** Maximum number of predicate entries in one caller `where`. */
|
|
30
|
+
export const WHERE_MAX_NODES = 256;
|
|
27
31
|
//# sourceMappingURL=depth-limits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depth-limits.js","sourceRoot":"","sources":["../../src/access/depth-limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEvC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"depth-limits.js","sourceRoot":"","sources":["../../src/access/depth-limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEvC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAA;AAEzC,qEAAqE;AACrE,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAA;AAE9D,iEAAiE;AACjE,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA"}
|
package/dist/access/engine.d.ts
CHANGED
|
@@ -4,11 +4,9 @@ import type { OpenSaasConfig, ListConfig, RelationshipField } from '../config/ty
|
|
|
4
4
|
* Access engine — operation-level access control and shared helpers.
|
|
5
5
|
*
|
|
6
6
|
* This module holds the *operation-level* (list-level) access primitives and
|
|
7
|
-
* the ref-parsing helper
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* - Phase 2, Field Visibility (post-query field stripping + resolveOutput +
|
|
11
|
-
* virtual fields): `field-visibility.ts`
|
|
7
|
+
* the ref-parsing helper the pre-query row/relation scoping (`secured/
|
|
8
|
+
* vocabulary.ts`) and the post-query Field Visibility phase (`field-
|
|
9
|
+
* visibility.ts`) both build on.
|
|
12
10
|
*
|
|
13
11
|
* Field-level access evaluation is centralized in `field-access.ts`
|
|
14
12
|
* (`checkFieldAccess`). See `docs/adr/0001-access-control-is-a-two-phase-read.md`
|
|
@@ -32,29 +30,36 @@ export interface SyntheticReverseRelation {
|
|
|
32
30
|
* `ref` (`ref: 'ListName'`, no target field) generates on its target model —
|
|
33
31
|
* Prisma requires an opposite field there, but the config never declares one,
|
|
34
32
|
* so it never appears in `parentListName`'s own `fields`. Reuses
|
|
35
|
-
* `getSyntheticFieldName` (the same construction `
|
|
33
|
+
* `getSyntheticFieldName` (the same construction `getContractField` reports the
|
|
36
34
|
* schema with) rather than re-deriving the `from_<List>_<field>` format by
|
|
37
35
|
* string parsing, so the two cannot drift (#978).
|
|
38
36
|
*
|
|
39
|
-
* Returns the declared relationship field that owns the relation
|
|
40
|
-
* pipeline treats a resolved synthetic key exactly like
|
|
41
|
-
*
|
|
42
|
-
* relationship field gets. Returns `null` when `fieldName` isn't one of these
|
|
37
|
+
* Returns the declared relationship field that owns the relation, so the write
|
|
38
|
+
* pipeline treats a resolved synthetic key exactly like that declared field.
|
|
39
|
+
* Returns `null` when `fieldName` isn't one of these
|
|
43
40
|
* on `parentListName` (a genuinely unknown key, or a bidirectional relation's
|
|
44
41
|
* ref, which never synthesizes a back-relation).
|
|
45
42
|
*/
|
|
46
43
|
export declare function resolveSyntheticReverseRelation(fieldName: string, parentListName: string, config: OpenSaasConfig): SyntheticReverseRelation | null;
|
|
47
44
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* `
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
|
|
45
|
+
* Evaluate one operation-level access rule (`query`, `update` or `delete`).
|
|
46
|
+
*
|
|
47
|
+
* Returns what the rule returned: `true` (allow every row), `false` (deny), or
|
|
48
|
+
* a `PrismaFilter` scoping which rows the session may reach. An **absent** rule
|
|
49
|
+
* denies — access is opt-in, so a list that declares nothing is closed rather
|
|
50
|
+
* than open. A rule that returns `null` or `undefined` (`session && {…}` for an
|
|
51
|
+
* anonymous session) denies the same way.
|
|
52
|
+
*
|
|
53
|
+
* A filter result is not a decision on its own: the read composes it into the
|
|
54
|
+
* query as the engine-owned predicate. Only a boolean is a decision.
|
|
55
|
+
* Gate a `create` with {@link checkCreateAccess} instead: create has no row to
|
|
56
|
+
* test a filter against, so a rule that returns one must be refused rather than
|
|
57
|
+
* read as an allow (ADR-0030). `checkCreateAccess` calls this and enforces that.
|
|
58
|
+
*
|
|
59
|
+
* @param accessControl - The rule from `access.operation[...]`, or `undefined`.
|
|
60
|
+
* @param args - The session, the existing row (update/delete), and the context
|
|
61
|
+
* the rule may read through.
|
|
62
|
+
* */
|
|
58
63
|
export declare function checkAccess<T = Record<string, unknown>>(accessControl: AccessControl<T> | undefined, args: {
|
|
59
64
|
session: Session | null;
|
|
60
65
|
item?: T;
|
|
@@ -78,5 +83,48 @@ export declare function checkCreateAccess<T = Record<string, unknown>>(listKey:
|
|
|
78
83
|
session: Session | null;
|
|
79
84
|
context: AccessContext;
|
|
80
85
|
}): Promise<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
* Refuses an Access Filter that constrains nothing at any depth. The caller's
|
|
88
|
+
* own `where` is never passed through this.
|
|
89
|
+
*
|
|
90
|
+
* @throws VacuousAccessFilterError
|
|
91
|
+
*/
|
|
92
|
+
export declare function assertAccessFilterConstrains(filter: PrismaFilter): void;
|
|
93
|
+
/**
|
|
94
|
+
* Fold a {@link checkAccess} result into a caller's `where`, producing the
|
|
95
|
+
* clause to hand the database — or `null` when access is denied.
|
|
96
|
+
*
|
|
97
|
+
* `null` is the Silent failure signal, not an empty filter: a caller that
|
|
98
|
+
* receives it returns `null`/`[]` without querying, so a denial is
|
|
99
|
+
* indistinguishable from a miss and leaks no existence information. An empty
|
|
100
|
+
* object (`{}`) is refused with {@link VacuousAccessFilterError}; `true` allows every row.
|
|
101
|
+
*
|
|
102
|
+
* The two filters are combined with `AND`, never merged key-by-key, so the
|
|
103
|
+
* access filter can only ever narrow what the caller asked for. A caller
|
|
104
|
+
* cannot widen its own visibility by naming the same field.
|
|
105
|
+
*
|
|
106
|
+
* Deliberately not generic, where {@link checkAccess} is: `checkAccess`'s `T`
|
|
107
|
+
* types the row a rule inspects (`item`), while this returns a clause in Prisma
|
|
108
|
+
* *operator* space — `AND` is not a `keyof T`, so `PrismaFilter<T>` cannot
|
|
109
|
+
* describe the result. Typing it as one would be a claim the value does not
|
|
110
|
+
* satisfy. A `PrismaFilter<Post>` from `checkAccess<Post>` is accepted here
|
|
111
|
+
* unchanged; only the merged clause is untyped.
|
|
112
|
+
*
|
|
113
|
+
* An access filter carrying an `undefined` condition anywhere throws
|
|
114
|
+
* {@link UndefinedAccessFilterError} rather than being handed on: the ORM
|
|
115
|
+
* reads `undefined` as "no constraint", so passing it through widens the read
|
|
116
|
+
* to every row. This is the same total-lowering rule the secured builder's
|
|
117
|
+
* Where vocabulary applies, so the guarantee holds on the legacy
|
|
118
|
+
* `findMany`/`count`/`delete` paths too. The caller's own
|
|
119
|
+
* `userFilter` is left alone — it can only ever be narrowed by this clause,
|
|
120
|
+
* and `undefined` there is the caller's own optional key, not a scoping rule
|
|
121
|
+
* that failed to resolve.
|
|
122
|
+
*
|
|
123
|
+
* @param userFilter - The caller's own `where`, if any.
|
|
124
|
+
* @param accessFilter - What {@link checkAccess} returned.
|
|
125
|
+
* @returns The clause to query with, or `null` when denied.
|
|
126
|
+
* @throws UndefinedAccessFilterError when the access filter has an
|
|
127
|
+
* `undefined` condition.
|
|
128
|
+
*/
|
|
81
129
|
export declare function mergeFilters(userFilter: PrismaFilter | undefined, accessFilter: boolean | PrismaFilter): PrismaFilter | null;
|
|
82
130
|
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/access/engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/access/engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACrF,OA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