@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,277 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { foldDeclaredDependencies, emptyDeclaredOnlyTree } from './declared-dependencies.js'
|
|
3
|
-
import type { OpenSaasConfig, FieldConfig } from '../config/types.js'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Unit coverage for `foldDeclaredDependencies` (ADR-0025), focused on the
|
|
7
|
-
* behaviour ADR-0026 requires of it once the read pipeline stopped
|
|
8
|
-
* auto-expanding a named relation's own subtree: a declared dependency no
|
|
9
|
-
* longer rides that expansion "for free" and must be folded recursively —
|
|
10
|
-
* at every level a field is computed, however that level was reached
|
|
11
|
-
* (declaration-added, caller-named bare, or caller-named with its own nested
|
|
12
|
-
* include).
|
|
13
|
-
*
|
|
14
|
-
* End-to-end coverage of the fold feeding an actual read (mocked Prisma, real
|
|
15
|
-
* `resolveOutput` hooks) lives in `tests/needs-declared-dependencies.test.ts`;
|
|
16
|
-
* these tests exercise the fold function directly so a regression here fails
|
|
17
|
-
* fast with a small, precise reproduction.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
function relField(ref: string, many = false): FieldConfig {
|
|
21
|
-
return { type: 'relationship', ref, many } as unknown as FieldConfig
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function virtualNeeds(needs: string[]): FieldConfig {
|
|
25
|
-
return {
|
|
26
|
-
type: 'virtual',
|
|
27
|
-
needs,
|
|
28
|
-
hooks: { resolveOutput: () => 'x' },
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal field config for unit test
|
|
30
|
-
} as any
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
describe('foldDeclaredDependencies', () => {
|
|
34
|
-
it('returns the exact same reference when there is nothing to fold', () => {
|
|
35
|
-
const fields: Record<string, FieldConfig> = { name: { type: 'text' } as FieldConfig }
|
|
36
|
-
const config = { db: { provider: 'sqlite' }, lists: {} } as unknown as OpenSaasConfig
|
|
37
|
-
|
|
38
|
-
const result = foldDeclaredDependencies(undefined, fields, config, 'List')
|
|
39
|
-
expect(result.include).toBeUndefined()
|
|
40
|
-
expect(result.declaredOnly).toEqual(emptyDeclaredOnlyTree())
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('folds a declaration-added bare relation whose own related list has further needs', () => {
|
|
44
|
-
// Order.total needs lineItems (declaration-added, no caller include at
|
|
45
|
-
// all). LineItem.summary needs product. Without recursing into the
|
|
46
|
-
// declaration-added branch, `product` would never be fetched, and
|
|
47
|
-
// LineItem.summary would silently compute over `undefined`.
|
|
48
|
-
const config: OpenSaasConfig = {
|
|
49
|
-
db: { provider: 'sqlite' },
|
|
50
|
-
lists: {
|
|
51
|
-
Order: {
|
|
52
|
-
fields: {
|
|
53
|
-
lineItems: relField('LineItem.order', true),
|
|
54
|
-
total: virtualNeeds(['lineItems']),
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
LineItem: {
|
|
58
|
-
fields: { product: relField('Product'), summary: virtualNeeds(['product']) },
|
|
59
|
-
},
|
|
60
|
-
Product: { fields: { name: { type: 'text' } as FieldConfig } },
|
|
61
|
-
},
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
63
|
-
} as any
|
|
64
|
-
|
|
65
|
-
const result = foldDeclaredDependencies(undefined, config.lists.Order.fields, config, 'Order')
|
|
66
|
-
|
|
67
|
-
expect(result.include).toEqual({ lineItems: { include: { product: true } } })
|
|
68
|
-
// The whole `lineItems` branch is declaration-only at Order's level, so it
|
|
69
|
-
// needs no fine-grained nested tracking — the entire branch is stripped
|
|
70
|
-
// regardless of what's nested inside it.
|
|
71
|
-
expect(result.declaredOnly.keys.has('lineItems')).toBe(true)
|
|
72
|
-
expect(result.declaredOnly.nested.lineItems).toBeUndefined()
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
it('folds a caller-named BARE relation whose related list has its own needs, tracking the addition for fine-grained stripping', () => {
|
|
76
|
-
// The caller explicitly asked for `lineItems` (bare) — NOT declaration-only
|
|
77
|
-
// at Order's level — but LineItem's own `product` still has to be folded
|
|
78
|
-
// in for LineItem.summary's hook. Because the caller DID ask for
|
|
79
|
-
// `lineItems`, `product` must be tracked as declaration-only ONE LEVEL
|
|
80
|
-
// DOWN so it (and only it) gets stripped from each returned line item.
|
|
81
|
-
const config: OpenSaasConfig = {
|
|
82
|
-
db: { provider: 'sqlite' },
|
|
83
|
-
lists: {
|
|
84
|
-
Order: {
|
|
85
|
-
fields: {
|
|
86
|
-
lineItems: relField('LineItem.order', true),
|
|
87
|
-
total: virtualNeeds(['lineItems']),
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
LineItem: {
|
|
91
|
-
fields: {
|
|
92
|
-
product: relField('Product'),
|
|
93
|
-
tag: relField('Tag'),
|
|
94
|
-
summary: virtualNeeds(['product']),
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
Product: { fields: { name: { type: 'text' } as FieldConfig } },
|
|
98
|
-
Tag: { fields: { name: { type: 'text' } as FieldConfig } },
|
|
99
|
-
},
|
|
100
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
101
|
-
} as any
|
|
102
|
-
|
|
103
|
-
const result = foldDeclaredDependencies(
|
|
104
|
-
{ lineItems: true },
|
|
105
|
-
config.lists.Order.fields,
|
|
106
|
-
config,
|
|
107
|
-
'Order',
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
expect(result.include).toEqual({ lineItems: { include: { product: true } } })
|
|
111
|
-
// `lineItems` itself is caller-named, not declaration-only...
|
|
112
|
-
expect(result.declaredOnly.keys.has('lineItems')).toBe(false)
|
|
113
|
-
// ...but `product`, nested beneath it, IS — so it gets stripped from each
|
|
114
|
-
// line item while `lineItems` (and its other fields, e.g. `tag`) survive.
|
|
115
|
-
expect(result.declaredOnly.nested.lineItems?.keys.has('product')).toBe(true)
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
it("recurses into an explicit caller-nested include so the nested list's own needs are satisfied there too", () => {
|
|
119
|
-
const config: OpenSaasConfig = {
|
|
120
|
-
db: { provider: 'sqlite' },
|
|
121
|
-
lists: {
|
|
122
|
-
Order: { fields: { lineItems: relField('LineItem.order', true) } },
|
|
123
|
-
LineItem: {
|
|
124
|
-
fields: {
|
|
125
|
-
product: relField('Product'),
|
|
126
|
-
tag: relField('Tag'),
|
|
127
|
-
summary: virtualNeeds(['product']),
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
Product: { fields: { name: { type: 'text' } as FieldConfig } },
|
|
131
|
-
Tag: { fields: { name: { type: 'text' } as FieldConfig } },
|
|
132
|
-
},
|
|
133
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
134
|
-
} as any
|
|
135
|
-
|
|
136
|
-
const result = foldDeclaredDependencies(
|
|
137
|
-
{ lineItems: { include: { tag: true } } },
|
|
138
|
-
config.lists.Order.fields,
|
|
139
|
-
config,
|
|
140
|
-
'Order',
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
expect(result.include).toEqual({ lineItems: { include: { tag: true, product: true } } })
|
|
144
|
-
expect(result.declaredOnly.nested.lineItems?.keys.has('product')).toBe(true)
|
|
145
|
-
expect(result.declaredOnly.nested.lineItems?.keys.has('tag')).toBe(false)
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
it('does not fold anything beneath a relation whose related list has no needs of its own', () => {
|
|
149
|
-
const config: OpenSaasConfig = {
|
|
150
|
-
db: { provider: 'sqlite' },
|
|
151
|
-
lists: {
|
|
152
|
-
Order: { fields: { customer: relField('Customer') } },
|
|
153
|
-
Customer: { fields: { name: { type: 'text' } as FieldConfig } },
|
|
154
|
-
},
|
|
155
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
156
|
-
} as any
|
|
157
|
-
|
|
158
|
-
const result = foldDeclaredDependencies(
|
|
159
|
-
{ customer: true },
|
|
160
|
-
config.lists.Order.fields,
|
|
161
|
-
config,
|
|
162
|
-
'Order',
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
// Untouched — no needs anywhere in reach, so the bare relation stays bare.
|
|
166
|
-
expect(result.include).toEqual({ customer: true })
|
|
167
|
-
expect(result.declaredOnly).toEqual(emptyDeclaredOnlyTree())
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
it("folds a revisited list's own needs beneath a relation the request named", () => {
|
|
171
|
-
// The request names Post → author → posts, revisiting Post. Nothing here
|
|
172
|
-
// can loop — the include is a finite literal the caller wrote out — so the
|
|
173
|
-
// fold must keep going and satisfy Post.blurb's `needs` at THAT level too.
|
|
174
|
-
// Guarding a caller-named edge on list identity would stop the fold at
|
|
175
|
-
// `posts` and leave `blurb` computing over an undefined `tags`.
|
|
176
|
-
const config: OpenSaasConfig = {
|
|
177
|
-
db: { provider: 'sqlite' },
|
|
178
|
-
lists: {
|
|
179
|
-
Post: {
|
|
180
|
-
fields: {
|
|
181
|
-
author: relField('User.posts'),
|
|
182
|
-
comments: relField('Comment', true),
|
|
183
|
-
tags: relField('Tag', true),
|
|
184
|
-
blurb: virtualNeeds(['tags']),
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
User: { fields: { posts: relField('Post.author', true) } },
|
|
188
|
-
Comment: { fields: { body: { type: 'text' } as FieldConfig } },
|
|
189
|
-
Tag: { fields: { label: { type: 'text' } as FieldConfig } },
|
|
190
|
-
},
|
|
191
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
192
|
-
} as any
|
|
193
|
-
|
|
194
|
-
const result = foldDeclaredDependencies(
|
|
195
|
-
{ author: { include: { posts: { include: { comments: true } } } } },
|
|
196
|
-
config.lists.Post.fields,
|
|
197
|
-
config,
|
|
198
|
-
'Post',
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
expect(result.include).toEqual({
|
|
202
|
-
tags: true,
|
|
203
|
-
author: { include: { posts: { include: { comments: true, tags: true } } } },
|
|
204
|
-
})
|
|
205
|
-
// Only the nested `tags` needs fine-grained tracking: the root-level one is
|
|
206
|
-
// declaration-only at this level (stripped wholesale), while the nested one
|
|
207
|
-
// sits inside branches the caller named and must be stripped individually.
|
|
208
|
-
expect(result.declaredOnly.keys.has('tags')).toBe(true)
|
|
209
|
-
expect(result.declaredOnly.nested.author?.nested.posts?.keys.has('tags')).toBe(true)
|
|
210
|
-
expect(result.declaredOnly.nested.author?.nested.posts?.keys.has('comments')).toBe(false)
|
|
211
|
-
})
|
|
212
|
-
|
|
213
|
-
it("folds a self-referential relation's own needs when the request names it", () => {
|
|
214
|
-
// `parent` points back at Category itself. The request named it, so the
|
|
215
|
-
// fold must satisfy Category's own `needs` beneath it — `depth` is computed
|
|
216
|
-
// on the parent row too.
|
|
217
|
-
const config: OpenSaasConfig = {
|
|
218
|
-
db: { provider: 'sqlite' },
|
|
219
|
-
lists: {
|
|
220
|
-
Category: {
|
|
221
|
-
fields: {
|
|
222
|
-
parent: relField('Category.children'),
|
|
223
|
-
children: relField('Category.parent', true),
|
|
224
|
-
depth: virtualNeeds(['children']),
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
229
|
-
} as any
|
|
230
|
-
|
|
231
|
-
const result = foldDeclaredDependencies(
|
|
232
|
-
{ parent: true },
|
|
233
|
-
config.lists.Category.fields,
|
|
234
|
-
config,
|
|
235
|
-
'Category',
|
|
236
|
-
)
|
|
237
|
-
|
|
238
|
-
// `children` folds in at the root AND beneath the caller-named `parent`.
|
|
239
|
-
// The fold beneath `parent` stops there: `children` is declaration-added,
|
|
240
|
-
// so the guard applies to its own onward edge back into Category.
|
|
241
|
-
expect(result.include).toEqual({
|
|
242
|
-
parent: { include: { children: true } },
|
|
243
|
-
children: true,
|
|
244
|
-
})
|
|
245
|
-
expect(result.declaredOnly.keys.has('children')).toBe(true)
|
|
246
|
-
expect(result.declaredOnly.nested.parent?.keys.has('children')).toBe(true)
|
|
247
|
-
})
|
|
248
|
-
|
|
249
|
-
it('defensively terminates a two-list mutual `needs` cycle instead of recursing without bound', () => {
|
|
250
|
-
// Order.total needs lineItems; LineItem.orderRef needs order — a cycle
|
|
251
|
-
// `validateNeedsClosureDepth` (needs-closure.ts) rejects at generate time.
|
|
252
|
-
// This constructs it directly to exercise the fold's OWN defensive guard,
|
|
253
|
-
// independent of that generate-time backstop.
|
|
254
|
-
const config: OpenSaasConfig = {
|
|
255
|
-
db: { provider: 'sqlite' },
|
|
256
|
-
lists: {
|
|
257
|
-
Order: {
|
|
258
|
-
fields: {
|
|
259
|
-
lineItems: relField('LineItem.order', true),
|
|
260
|
-
total: virtualNeeds(['lineItems']),
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
LineItem: {
|
|
264
|
-
fields: { order: relField('Order.lineItems'), orderRef: virtualNeeds(['order']) },
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
268
|
-
} as any
|
|
269
|
-
|
|
270
|
-
const result = foldDeclaredDependencies(undefined, config.lists.Order.fields, config, 'Order')
|
|
271
|
-
|
|
272
|
-
// Terminates (would hang/stack-overflow without the guard) and still
|
|
273
|
-
// produces a usable, finite include: `lineItems` folds in, but `order`
|
|
274
|
-
// beneath it stops at a flat fetch rather than looping back to `lineItems` again.
|
|
275
|
-
expect(result.include).toEqual({ lineItems: { include: { order: true } } })
|
|
276
|
-
})
|
|
277
|
-
})
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import type { FieldConfig, OpenSaasConfig } from '../config/types.js'
|
|
2
|
-
import { getRelatedListConfig } from './engine.js'
|
|
3
|
-
import type { FieldSelectionScope } from '../query/index.js'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Declared Dependencies — folding a computed field's `needs` into a read's
|
|
7
|
-
* `include` without widening what the caller receives (ADR-0025).
|
|
8
|
-
*
|
|
9
|
-
* A field's `needs` declares immediate sibling relations its `resolveOutput`
|
|
10
|
-
* hook cannot compute without. This module folds those relations into
|
|
11
|
-
* whatever `include` a read is already building (caller-supplied, fragment-
|
|
12
|
-
* derived, or none at all) BEFORE it reaches the access-scoping pipeline
|
|
13
|
-
* (`buildAccessScopedInclude` in `access-filter.ts`) — a declared relation is
|
|
14
|
-
* scoped exactly like a caller-named one, never a bypass.
|
|
15
|
-
*
|
|
16
|
-
* The fold also tracks provenance: which relation keys, at which nesting
|
|
17
|
-
* level, were added ONLY to satisfy a declaration (as opposed to being named
|
|
18
|
-
* by the caller). `field-visibility.ts` uses that tree to strip those keys
|
|
19
|
-
* from the result after `resolveOutput` hooks have had a chance to read them
|
|
20
|
-
* — a declared dependency is private plumbing, not an implicit `include`.
|
|
21
|
-
*
|
|
22
|
-
* **Every relation this module reaches is folded recursively**, whether it
|
|
23
|
-
* was added purely to satisfy a declaration or is already present for another
|
|
24
|
-
* reason (caller/fragment-named, bare or not). Since ADR-0026 removed the
|
|
25
|
-
* auto-expansion that used to carry a chain of declarations "for free" —
|
|
26
|
-
* naming a relation now fetches its own columns and stops — a field computed
|
|
27
|
-
* one hop down would otherwise lose its own declared dependencies the moment
|
|
28
|
-
* its list is reached any way OTHER than an explicit nested caller `include`.
|
|
29
|
-
* Declarations fold in "at every level a field is computed" (ADR-0025), not
|
|
30
|
-
* only where the caller happened to write one out.
|
|
31
|
-
*
|
|
32
|
-
* A branch added purely by this fold (`declaredOnly.keys`) is stripped
|
|
33
|
-
* wholesale by `filterReadableFields` regardless of what's nested inside it,
|
|
34
|
-
* so its own nested declared-only keys need no individual tracking — only a
|
|
35
|
-
* branch present for another reason (caller/fragment-named) needs the
|
|
36
|
-
* fine-grained `declaredOnly.nested` tracking, so a declaration folded
|
|
37
|
-
* beneath IT can be stripped without removing the caller's own data.
|
|
38
|
-
*
|
|
39
|
-
* **Cycle guard, re-pointed (ADR-0026).** A caller-supplied `include` is
|
|
40
|
-
* always a finite literal and cannot cycle. Recursively following declared
|
|
41
|
-
* dependencies across lists CAN — list A declaring `needs` on a relation to
|
|
42
|
-
* list B, whose own field declares `needs` back to A — so `visitedLists`
|
|
43
|
-
* carries the list names already on this fold's own path and stops rather
|
|
44
|
-
* than recursing without bound. `pnpm generate`'s `validateNeedsClosureDepth`
|
|
45
|
-
* (`needs-closure.ts`) is the primary backstop — a cyclic `needs` closure
|
|
46
|
-
* fails generation and should never reach this code at runtime — this guard
|
|
47
|
-
* is defense in depth, not the mechanism relied on for correctness.
|
|
48
|
-
*
|
|
49
|
-
* The guard applies to DECLARATION-ADDED edges only, which is exactly where
|
|
50
|
-
* the unbounded recursion can come from: a branch added by this fold carries
|
|
51
|
-
* no caller include of its own, so everything beneath it is declaration-added
|
|
52
|
-
* too, and each such edge either reaches a list not yet on the path or stops
|
|
53
|
-
* — bounding that suffix by the number of lists. An edge the request itself
|
|
54
|
-
* named is bounded by the request's own finite literal instead. Applying the
|
|
55
|
-
* guard to those as well would stop the fold at a path that merely revisits a
|
|
56
|
-
* list (`Post → author → posts`, or a self-referential `parent`), silently
|
|
57
|
-
* leaving the revisited list's own declared dependencies unsatisfied — the
|
|
58
|
-
* `undefined`-compute ADR-0025 exists to prevent, at every level a field is
|
|
59
|
-
* computed.
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
/** Which relation keys, at which nesting level, exist only to satisfy a `needs` declaration. */
|
|
63
|
-
export type DeclaredOnlyTree = {
|
|
64
|
-
/** Keys at THIS level whose entire branch was added purely by the fold. */
|
|
65
|
-
keys: Set<string>
|
|
66
|
-
/** Per-key trees for relations present in the include for other reasons (caller-named), whose OWN nested include may still contain declaration-only keys. */
|
|
67
|
-
nested: Record<string, DeclaredOnlyTree>
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function emptyDeclaredOnlyTree(): DeclaredOnlyTree {
|
|
71
|
-
return { keys: new Set(), nested: {} }
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function isDeclaredOnlyTreeEmpty(tree: DeclaredOnlyTree): boolean {
|
|
75
|
-
return tree.keys.size === 0 && Object.keys(tree.nested).length === 0
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function isRelationshipFieldConfig(
|
|
79
|
-
fieldConfig: FieldConfig | undefined,
|
|
80
|
-
): fieldConfig is FieldConfig & { type: 'relationship'; ref: string } {
|
|
81
|
-
return (
|
|
82
|
-
!!fieldConfig &&
|
|
83
|
-
fieldConfig.type === 'relationship' &&
|
|
84
|
-
'ref' in fieldConfig &&
|
|
85
|
-
!!fieldConfig.ref
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** A plain object — excludes `null` and arrays, which `typeof x === 'object'` alone would admit. */
|
|
90
|
-
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
91
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** The explicit nested `include` on an include entry, if the entry is a structured object naming one. */
|
|
95
|
-
function getExplicitInclude(value: unknown): Record<string, unknown> | undefined {
|
|
96
|
-
if (!isPlainObject(value)) return undefined
|
|
97
|
-
const { include } = value
|
|
98
|
-
return isPlainObject(include) ? include : undefined
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The deduped set of relation names declared via `needs` by fields on this
|
|
103
|
-
* list that have a `resolveOutput` hook. A `needs` entry on a field without
|
|
104
|
-
* one is inert — there is no hook to feed it to — so it contributes nothing
|
|
105
|
-
* to fetch.
|
|
106
|
-
*
|
|
107
|
-
* `selectedFields`, when given, restricts the union to fields the read is
|
|
108
|
-
* actually going to return (ADR-0027) — a field a fragment did not select is
|
|
109
|
-
* never computed, so its declared relation is never fetched for it either.
|
|
110
|
-
* `undefined` means unrestricted: every field with a hook contributes,
|
|
111
|
-
* matching a bare or `include`-based read, which always returns every
|
|
112
|
-
* computed field on the list.
|
|
113
|
-
*/
|
|
114
|
-
export function getDeclaredRelationNames(
|
|
115
|
-
fieldConfigs: Record<string, FieldConfig>,
|
|
116
|
-
selectedFields?: ReadonlySet<string>,
|
|
117
|
-
): string[] {
|
|
118
|
-
const names = new Set<string>()
|
|
119
|
-
for (const [fieldName, fieldConfig] of Object.entries(fieldConfigs)) {
|
|
120
|
-
if (!fieldConfig?.hooks?.resolveOutput) continue
|
|
121
|
-
if (selectedFields && !selectedFields.has(fieldName)) continue
|
|
122
|
-
for (const name of fieldConfig.needs ?? []) {
|
|
123
|
-
names.add(name)
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return [...names]
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Fold this list's declared dependencies into `rawInclude`, recursing into
|
|
131
|
-
* EVERY relation reached from here — whether it was just added to satisfy a
|
|
132
|
-
* declaration or was already present for another reason — so that list's own
|
|
133
|
-
* declared dependencies are satisfied too, wherever it's reached (see module
|
|
134
|
-
* doc comment).
|
|
135
|
-
*
|
|
136
|
-
* Returns `rawInclude` itself (same reference) when there is nothing to
|
|
137
|
-
* fold, so a list with no `needs` fields and no caller include stays on the
|
|
138
|
-
* exact bare-read path (ADR-0024) — untouched, not merely equivalent.
|
|
139
|
-
*
|
|
140
|
-
* `listKey` seeds the cycle guard at the root of a read; recursive calls
|
|
141
|
-
* extend it with each related list reached along THIS fold's own path.
|
|
142
|
-
*
|
|
143
|
-
* `selection`, when given, is the fragment scope this level was reached
|
|
144
|
-
* under (ADR-0027) — only fields it names contribute their `needs` (see
|
|
145
|
-
* `getDeclaredRelationNames`). It is `undefined` for a bare/`include`-based
|
|
146
|
-
* read (unrestricted: every field's `needs` folds in, unchanged from before
|
|
147
|
-
* ADR-0027) and for any branch reached only to satisfy a declaration — a
|
|
148
|
-
* relation added purely by this fold has no fragment scope of its own, so
|
|
149
|
-
* its own list folds unrestricted, exactly as it did before selectivity
|
|
150
|
-
* existed.
|
|
151
|
-
*/
|
|
152
|
-
export function foldDeclaredDependencies(
|
|
153
|
-
rawInclude: Record<string, unknown> | undefined,
|
|
154
|
-
fieldConfigs: Record<string, FieldConfig>,
|
|
155
|
-
config: OpenSaasConfig,
|
|
156
|
-
listKey: string,
|
|
157
|
-
visitedLists: readonly string[] = [listKey],
|
|
158
|
-
selection?: FieldSelectionScope,
|
|
159
|
-
): { include: Record<string, unknown> | undefined; declaredOnly: DeclaredOnlyTree } {
|
|
160
|
-
const declaredNames = getDeclaredRelationNames(fieldConfigs, selection?.fields)
|
|
161
|
-
|
|
162
|
-
if (declaredNames.length === 0 && !rawInclude) {
|
|
163
|
-
return { include: rawInclude, declaredOnly: emptyDeclaredOnlyTree() }
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const declaredOnly = emptyDeclaredOnlyTree()
|
|
167
|
-
const merged: Record<string, unknown> = { ...(rawInclude ?? {}) }
|
|
168
|
-
|
|
169
|
-
for (const name of declaredNames) {
|
|
170
|
-
if (name in merged) continue // caller (or fragment) already asked for it — not declaration-only
|
|
171
|
-
if (!isRelationshipFieldConfig(fieldConfigs[name])) continue // invalid `needs` entry; caught by generate-time validation
|
|
172
|
-
merged[name] = true
|
|
173
|
-
declaredOnly.keys.add(name)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
for (const [key, value] of Object.entries(merged)) {
|
|
177
|
-
const fieldConfig = fieldConfigs[key]
|
|
178
|
-
if (!isRelationshipFieldConfig(fieldConfig)) continue
|
|
179
|
-
|
|
180
|
-
const relatedConfig = getRelatedListConfig(fieldConfig.ref, config)
|
|
181
|
-
if (!relatedConfig) continue
|
|
182
|
-
// Defensive cycle guard (see module doc comment) — a DECLARATION-ADDED
|
|
183
|
-
// edge into a list already on this path stops here; the value at `key`
|
|
184
|
-
// is left exactly as-is.
|
|
185
|
-
if (declaredOnly.keys.has(key) && visitedLists.includes(relatedConfig.listName)) continue
|
|
186
|
-
|
|
187
|
-
// A branch added purely by the fold has no fragment scope of its own —
|
|
188
|
-
// it folds unrestricted, as before ADR-0027. A branch the request itself
|
|
189
|
-
// named (caller include or fragment) carries that name's own nested
|
|
190
|
-
// scope, if the fragment gave it one (a bare `true` selector leaves it
|
|
191
|
-
// `undefined` — also unrestricted, since the caller asked for
|
|
192
|
-
// "everything" there).
|
|
193
|
-
const nestedSelection = declaredOnly.keys.has(key) ? undefined : selection?.nested[key]
|
|
194
|
-
|
|
195
|
-
const explicitNested = getExplicitInclude(value)
|
|
196
|
-
const nested = foldDeclaredDependencies(
|
|
197
|
-
explicitNested,
|
|
198
|
-
relatedConfig.listConfig.fields,
|
|
199
|
-
config,
|
|
200
|
-
relatedConfig.listName,
|
|
201
|
-
[...visitedLists, relatedConfig.listName],
|
|
202
|
-
nestedSelection,
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
if (nested.include) {
|
|
206
|
-
merged[key] = {
|
|
207
|
-
...(typeof value === 'object' && value ? value : {}),
|
|
208
|
-
include: nested.include,
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// Declaration-added branches need no nested tracking of their own (see
|
|
213
|
-
// module doc comment) — only caller/fragment-named branches do.
|
|
214
|
-
if (!declaredOnly.keys.has(key) && !isDeclaredOnlyTreeEmpty(nested.declaredOnly)) {
|
|
215
|
-
declaredOnly.nested[key] = nested.declaredOnly
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return { include: merged, declaredOnly }
|
|
220
|
-
}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { filterReadableFields } from './field-visibility.js'
|
|
3
|
-
import { emptyDeclaredOnlyTree } from './declared-dependencies.js'
|
|
4
|
-
import type { ToOneAccessVisibilityTree } from './access-filter.js'
|
|
5
|
-
import type { OpenSaasConfig, FieldConfig } from '../config/types.js'
|
|
6
|
-
import type { AccessContext } from './types.js'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Regression coverage for the `filterReadableFields` half of issue #1103: a
|
|
10
|
-
* relation `buildAccessScopedInclude` denied outright is absent from the raw
|
|
11
|
-
* row (Prisma never fetched it), so the main per-field loop — which only
|
|
12
|
-
* ever visits keys `Object.entries(workingItem)` contains — never sees it.
|
|
13
|
-
* The dedicated post-query pass this file exercises is what forces the key
|
|
14
|
-
* present anyway: `null` for a to-one relation (issue #974, pre-existing),
|
|
15
|
-
* `[]` for a to-many one (issue #1103, this fix) — never a silently absent
|
|
16
|
-
* key, which is what previously broke the fragment API's typed contract
|
|
17
|
-
* (`ResultOf` types a to-many relation as an array).
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
function rel(ref: string, many = false): FieldConfig {
|
|
21
|
-
return { type: 'relationship', ref, many } as unknown as FieldConfig
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function makeContext(): AccessContext {
|
|
25
|
-
return {
|
|
26
|
-
session: null,
|
|
27
|
-
_isSudo: false,
|
|
28
|
-
_resolveOutputChain: [],
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal context for unit test
|
|
30
|
-
} as any
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function config(): OpenSaasConfig {
|
|
34
|
-
return {
|
|
35
|
-
db: { provider: 'sqlite' },
|
|
36
|
-
lists: {
|
|
37
|
-
Author: {
|
|
38
|
-
fields: {
|
|
39
|
-
name: { type: 'text' } as FieldConfig,
|
|
40
|
-
secrets: rel('Secret.author', true),
|
|
41
|
-
profile: rel('Profile.author', false),
|
|
42
|
-
hiddenSecrets: {
|
|
43
|
-
...rel('Secret.author', true),
|
|
44
|
-
access: { read: () => false },
|
|
45
|
-
} as unknown as FieldConfig,
|
|
46
|
-
},
|
|
47
|
-
access: { operation: { query: () => true } },
|
|
48
|
-
},
|
|
49
|
-
Secret: {
|
|
50
|
-
fields: { value: { type: 'text' } as FieldConfig },
|
|
51
|
-
access: { operation: { query: () => false } },
|
|
52
|
-
},
|
|
53
|
-
Profile: {
|
|
54
|
-
fields: { bio: { type: 'text' } as FieldConfig },
|
|
55
|
-
access: { operation: { query: () => false } },
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
59
|
-
} as any as OpenSaasConfig
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Term ← Bill.term (list-only ref, no field on Term) — the synthetic
|
|
63
|
-
// back-relation case, always to-many (#1082).
|
|
64
|
-
function syntheticConfig(): OpenSaasConfig {
|
|
65
|
-
return {
|
|
66
|
-
db: { provider: 'sqlite' },
|
|
67
|
-
lists: {
|
|
68
|
-
Term: {
|
|
69
|
-
fields: { name: { type: 'text' } as FieldConfig },
|
|
70
|
-
access: { operation: { query: () => true } },
|
|
71
|
-
},
|
|
72
|
-
Bill: {
|
|
73
|
-
fields: { amount: { type: 'integer' } as FieldConfig, term: rel('Term') },
|
|
74
|
-
access: { operation: { query: () => false } },
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
78
|
-
} as any as OpenSaasConfig
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
describe('filterReadableFields — denied relations forced present (issues #974 / #1103)', () => {
|
|
82
|
-
it('forces a denied to-many relation to [], not an absent key', async () => {
|
|
83
|
-
const cfg = config()
|
|
84
|
-
const authorRow = { id: 'a1', name: 'A' } // `secrets` absent — never fetched by Prisma
|
|
85
|
-
const toOneVisibility: ToOneAccessVisibilityTree = {
|
|
86
|
-
filters: { secrets: { kind: 'denied' } },
|
|
87
|
-
nested: {},
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const result = await filterReadableFields(
|
|
91
|
-
authorRow,
|
|
92
|
-
cfg.lists.Author.fields,
|
|
93
|
-
{ session: null, context: makeContext() },
|
|
94
|
-
cfg,
|
|
95
|
-
0,
|
|
96
|
-
'Author',
|
|
97
|
-
emptyDeclaredOnlyTree(),
|
|
98
|
-
undefined,
|
|
99
|
-
toOneVisibility,
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
expect((result as Record<string, unknown>).secrets).toEqual([])
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
it('still forces a denied to-one relation to null (regression check, issue #974)', async () => {
|
|
106
|
-
const cfg = config()
|
|
107
|
-
const authorRow = { id: 'a1', name: 'A' } // `profile` absent — never fetched by Prisma
|
|
108
|
-
const toOneVisibility: ToOneAccessVisibilityTree = {
|
|
109
|
-
filters: { profile: { kind: 'denied' } },
|
|
110
|
-
nested: {},
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const result = await filterReadableFields(
|
|
114
|
-
authorRow,
|
|
115
|
-
cfg.lists.Author.fields,
|
|
116
|
-
{ session: null, context: makeContext() },
|
|
117
|
-
cfg,
|
|
118
|
-
0,
|
|
119
|
-
'Author',
|
|
120
|
-
emptyDeclaredOnlyTree(),
|
|
121
|
-
undefined,
|
|
122
|
-
toOneVisibility,
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
expect((result as Record<string, unknown>).profile).toBeNull()
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
it('forces a denied synthetic back-relation to [] — always to-many (#1082 interaction)', async () => {
|
|
129
|
-
const cfg = syntheticConfig()
|
|
130
|
-
const termRow = { id: 't1', name: 'Term 1' } // `from_Bill_term` absent — never fetched
|
|
131
|
-
const toOneVisibility: ToOneAccessVisibilityTree = {
|
|
132
|
-
filters: { from_Bill_term: { kind: 'denied' } },
|
|
133
|
-
nested: {},
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const result = await filterReadableFields(
|
|
137
|
-
termRow,
|
|
138
|
-
cfg.lists.Term.fields,
|
|
139
|
-
{ session: null, context: makeContext() },
|
|
140
|
-
cfg,
|
|
141
|
-
0,
|
|
142
|
-
'Term',
|
|
143
|
-
emptyDeclaredOnlyTree(),
|
|
144
|
-
undefined,
|
|
145
|
-
toOneVisibility,
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
expect((result as Record<string, unknown>).from_Bill_term).toEqual([])
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
it('omits a denied relation entirely when field-level read access also denies it, rather than forcing []', async () => {
|
|
152
|
-
const cfg = config()
|
|
153
|
-
const authorRow = { id: 'a1', name: 'A' }
|
|
154
|
-
const toOneVisibility: ToOneAccessVisibilityTree = {
|
|
155
|
-
filters: { hiddenSecrets: { kind: 'denied' } },
|
|
156
|
-
nested: {},
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const result = await filterReadableFields(
|
|
160
|
-
authorRow,
|
|
161
|
-
cfg.lists.Author.fields,
|
|
162
|
-
{ session: null, context: makeContext() },
|
|
163
|
-
cfg,
|
|
164
|
-
0,
|
|
165
|
-
'Author',
|
|
166
|
-
emptyDeclaredOnlyTree(),
|
|
167
|
-
undefined,
|
|
168
|
-
toOneVisibility,
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
expect('hiddenSecrets' in result).toBe(false)
|
|
172
|
-
})
|
|
173
|
-
})
|