@opensaas/stack-core 0.43.0 → 0.44.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2753 -0
- package/README.md +182 -115
- package/dist/.build-hash +1 -0
- package/dist/access/declared-dependencies.d.ts +102 -88
- package/dist/access/declared-dependencies.d.ts.map +1 -1
- package/dist/access/declared-dependencies.js +83 -71
- package/dist/access/declared-dependencies.js.map +1 -1
- package/dist/access/depth-limits.d.ts +4 -0
- package/dist/access/depth-limits.d.ts.map +1 -1
- package/dist/access/depth-limits.js +4 -0
- package/dist/access/depth-limits.js.map +1 -1
- package/dist/access/engine.d.ts +68 -20
- package/dist/access/engine.d.ts.map +1 -1
- package/dist/access/engine.js +151 -37
- package/dist/access/engine.js.map +1 -1
- package/dist/access/errors.d.ts +33 -48
- package/dist/access/errors.d.ts.map +1 -1
- package/dist/access/errors.js +73 -63
- package/dist/access/errors.js.map +1 -1
- package/dist/access/field-access.d.ts +76 -5
- package/dist/access/field-access.d.ts.map +1 -1
- package/dist/access/field-access.js +235 -61
- package/dist/access/field-access.js.map +1 -1
- package/dist/access/field-visibility.d.ts +50 -4
- package/dist/access/field-visibility.d.ts.map +1 -1
- package/dist/access/field-visibility.js +143 -160
- package/dist/access/field-visibility.js.map +1 -1
- package/dist/access/index.d.ts +5 -12
- package/dist/access/index.d.ts.map +1 -1
- package/dist/access/index.js +6 -19
- package/dist/access/index.js.map +1 -1
- package/dist/access/orm-client.d.ts +19 -0
- package/dist/access/orm-client.d.ts.map +1 -0
- package/dist/access/orm-client.js +37 -0
- package/dist/access/orm-client.js.map +1 -0
- package/dist/access/query-validation.d.ts +7 -129
- package/dist/access/query-validation.d.ts.map +1 -1
- package/dist/access/query-validation.js +12 -314
- package/dist/access/query-validation.js.map +1 -1
- package/dist/access/system-fields.d.ts +2 -0
- package/dist/access/system-fields.d.ts.map +1 -0
- package/dist/access/system-fields.js +7 -0
- package/dist/access/system-fields.js.map +1 -0
- package/dist/access/transaction-registry.d.ts +25 -2
- package/dist/access/transaction-registry.d.ts.map +1 -1
- package/dist/access/transaction-registry.js +34 -17
- package/dist/access/transaction-registry.js.map +1 -1
- package/dist/access/types.d.ts +217 -131
- package/dist/access/types.d.ts.map +1 -1
- package/dist/config/field-kind.d.ts +66 -0
- package/dist/config/field-kind.d.ts.map +1 -0
- package/dist/config/field-kind.js +63 -0
- package/dist/config/field-kind.js.map +1 -0
- package/dist/config/hook-only-fields.d.ts +3 -0
- package/dist/config/hook-only-fields.d.ts.map +1 -0
- package/dist/config/hook-only-fields.js +17 -0
- package/dist/config/hook-only-fields.js.map +1 -0
- package/dist/config/index.d.ts +3 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +6 -3
- package/dist/config/index.js.map +1 -1
- package/dist/config/mcp-tool-names.d.ts +3 -0
- package/dist/config/mcp-tool-names.d.ts.map +1 -0
- package/dist/config/mcp-tool-names.js +25 -0
- package/dist/config/mcp-tool-names.js.map +1 -0
- package/dist/config/nav-count.d.ts.map +1 -1
- package/dist/config/nav-count.js +4 -4
- package/dist/config/nav-count.js.map +1 -1
- package/dist/config/plugin-engine.d.ts +8 -2
- package/dist/config/plugin-engine.d.ts.map +1 -1
- package/dist/config/plugin-engine.js +102 -38
- package/dist/config/plugin-engine.js.map +1 -1
- package/dist/config/types.d.ts +1035 -611
- package/dist/config/types.d.ts.map +1 -1
- package/dist/context/apply-defaults.d.ts +18 -1
- package/dist/context/apply-defaults.d.ts.map +1 -1
- package/dist/context/apply-defaults.js +30 -4
- package/dist/context/apply-defaults.js.map +1 -1
- package/dist/context/engine-context.d.ts +73 -0
- package/dist/context/engine-context.d.ts.map +1 -0
- package/dist/context/engine-context.js +67 -0
- package/dist/context/engine-context.js.map +1 -0
- package/dist/context/hook-pipeline.d.ts +9 -2
- package/dist/context/hook-pipeline.d.ts.map +1 -1
- package/dist/context/hook-pipeline.js +5 -4
- package/dist/context/hook-pipeline.js.map +1 -1
- package/dist/context/index.d.ts +98 -89
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +917 -722
- package/dist/context/index.js.map +1 -1
- package/dist/context/junction.d.ts +59 -0
- package/dist/context/junction.d.ts.map +1 -0
- package/dist/context/junction.js +126 -0
- package/dist/context/junction.js.map +1 -0
- package/dist/context/plugin-field-read.d.ts +33 -0
- package/dist/context/plugin-field-read.d.ts.map +1 -0
- package/dist/context/plugin-field-read.js +41 -0
- package/dist/context/plugin-field-read.js.map +1 -0
- package/dist/context/plugin-field-write.d.ts +104 -0
- package/dist/context/plugin-field-write.d.ts.map +1 -0
- package/dist/context/plugin-field-write.js +184 -0
- package/dist/context/plugin-field-write.js.map +1 -0
- package/dist/context/relationship-input.d.ts +146 -0
- package/dist/context/relationship-input.d.ts.map +1 -0
- package/dist/context/relationship-input.js +453 -0
- package/dist/context/relationship-input.js.map +1 -0
- package/dist/context/transaction-boundary.d.ts +54 -28
- package/dist/context/transaction-boundary.d.ts.map +1 -1
- package/dist/context/transaction-boundary.js +87 -169
- package/dist/context/transaction-boundary.js.map +1 -1
- package/dist/context/write-pipeline.d.ts +33 -51
- package/dist/context/write-pipeline.d.ts.map +1 -1
- package/dist/context/write-pipeline.js +372 -185
- package/dist/context/write-pipeline.js.map +1 -1
- package/dist/contract/dependencies.d.ts +88 -0
- package/dist/contract/dependencies.d.ts.map +1 -0
- package/dist/contract/dependencies.js +237 -0
- package/dist/contract/dependencies.js.map +1 -0
- package/dist/contract/derive.d.ts +49 -0
- package/dist/contract/derive.d.ts.map +1 -0
- package/dist/contract/derive.js +629 -0
- package/dist/contract/derive.js.map +1 -0
- package/dist/contract/fixtures/contract-configs.d.ts +64 -0
- package/dist/contract/fixtures/contract-configs.d.ts.map +1 -0
- package/dist/contract/fixtures/contract-configs.js +345 -0
- package/dist/contract/fixtures/contract-configs.js.map +1 -0
- package/dist/contract/id-boundary.d.ts +53 -0
- package/dist/contract/id-boundary.d.ts.map +1 -0
- package/dist/contract/id-boundary.js +76 -0
- package/dist/contract/id-boundary.js.map +1 -0
- package/dist/contract/index.d.ts +8 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +11 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/prisma.d.ts +58 -0
- package/dist/contract/prisma.d.ts.map +1 -0
- package/dist/contract/prisma.js +294 -0
- package/dist/contract/prisma.js.map +1 -0
- package/dist/contract/relation-graph.d.ts +70 -0
- package/dist/contract/relation-graph.d.ts.map +1 -0
- package/dist/contract/relation-graph.js +113 -0
- package/dist/contract/relation-graph.js.map +1 -0
- package/dist/contract/types.d.ts +153 -0
- package/dist/contract/types.d.ts.map +1 -0
- package/dist/contract/types.js +2 -0
- package/dist/contract/types.js.map +1 -0
- package/dist/db/client.d.ts +55 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +73 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/dev-database.d.ts +124 -0
- package/dist/db/dev-database.d.ts.map +1 -0
- package/dist/db/dev-database.js +291 -0
- package/dist/db/dev-database.js.map +1 -0
- package/dist/db/password-front.d.ts +10 -0
- package/dist/db/password-front.d.ts.map +1 -0
- package/dist/db/password-front.js +147 -0
- package/dist/db/password-front.js.map +1 -0
- package/dist/db/process-identity.d.ts +36 -0
- package/dist/db/process-identity.d.ts.map +1 -0
- package/dist/db/process-identity.js +114 -0
- package/dist/db/process-identity.js.map +1 -0
- package/dist/db/state-file.d.ts +54 -0
- package/dist/db/state-file.d.ts.map +1 -0
- package/dist/db/state-file.js +91 -0
- package/dist/db/state-file.js.map +1 -0
- package/dist/db/url.d.ts +89 -0
- package/dist/db/url.d.ts.map +1 -0
- package/dist/db/url.js +118 -0
- package/dist/db/url.js.map +1 -0
- package/dist/extend.d.ts +13 -2
- package/dist/extend.d.ts.map +1 -1
- package/dist/extend.js +24 -1
- package/dist/extend.js.map +1 -1
- package/dist/fields/index.d.ts +87 -42
- package/dist/fields/index.d.ts.map +1 -1
- package/dist/fields/index.js +462 -678
- package/dist/fields/index.js.map +1 -1
- package/dist/filter/collect.d.ts +3 -4
- package/dist/filter/collect.d.ts.map +1 -1
- package/dist/filter/collect.js +2 -2
- package/dist/filter/collect.js.map +1 -1
- package/dist/filter/index.d.ts +1 -2
- package/dist/filter/index.d.ts.map +1 -1
- package/dist/filter/index.js +0 -1
- package/dist/filter/index.js.map +1 -1
- package/dist/filter/map.d.ts +12 -5
- package/dist/filter/map.d.ts.map +1 -1
- package/dist/filter/map.js +47 -19
- package/dist/filter/map.js.map +1 -1
- package/dist/filter/types.d.ts +10 -24
- package/dist/filter/types.d.ts.map +1 -1
- package/dist/filter/types.js +2 -11
- package/dist/filter/types.js.map +1 -1
- package/dist/hooks/index.d.ts +22 -31
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +33 -37
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/transition-guard.d.ts +61 -0
- package/dist/hooks/transition-guard.d.ts.map +1 -0
- package/dist/hooks/transition-guard.js +93 -0
- package/dist/hooks/transition-guard.js.map +1 -0
- package/dist/index.d.ts +52 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +105 -51
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +4 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +16 -0
- package/dist/internal.js.map +1 -1
- package/dist/lib/case-utils.d.ts +0 -1
- package/dist/lib/case-utils.d.ts.map +1 -1
- package/dist/lib/case-utils.js +0 -3
- package/dist/lib/case-utils.js.map +1 -1
- package/dist/lib/client-safe-error.d.ts +9 -0
- package/dist/lib/client-safe-error.d.ts.map +1 -0
- package/dist/lib/client-safe-error.js +23 -0
- package/dist/lib/client-safe-error.js.map +1 -0
- package/dist/lib/database-errors.d.ts +78 -0
- package/dist/lib/database-errors.d.ts.map +1 -0
- package/dist/lib/database-errors.js +148 -0
- package/dist/lib/database-errors.js.map +1 -0
- package/dist/lib/null-prototype-registry.d.ts +9 -0
- package/dist/lib/null-prototype-registry.d.ts.map +1 -0
- package/dist/lib/null-prototype-registry.js +11 -0
- package/dist/lib/null-prototype-registry.js.map +1 -0
- package/dist/lib/prisma-errors.d.ts +30 -32
- package/dist/lib/prisma-errors.d.ts.map +1 -1
- package/dist/lib/prisma-errors.js +86 -46
- package/dist/lib/prisma-errors.js.map +1 -1
- package/dist/lib/process-global.d.ts +23 -0
- package/dist/lib/process-global.d.ts.map +1 -0
- package/dist/lib/process-global.js +33 -0
- package/dist/lib/process-global.js.map +1 -0
- package/dist/lib/warn-once.d.ts +7 -0
- package/dist/lib/warn-once.d.ts.map +1 -0
- package/dist/lib/warn-once.js +13 -0
- package/dist/lib/warn-once.js.map +1 -0
- package/dist/mcp/advertise.d.ts +16 -0
- package/dist/mcp/advertise.d.ts.map +1 -0
- package/dist/mcp/advertise.js +25 -0
- package/dist/mcp/advertise.js.map +1 -0
- package/dist/mcp/arguments.d.ts +10 -0
- package/dist/mcp/arguments.d.ts.map +1 -0
- package/dist/mcp/arguments.js +143 -0
- package/dist/mcp/arguments.js.map +1 -0
- package/dist/mcp/field-schema.d.ts +50 -5
- package/dist/mcp/field-schema.d.ts.map +1 -1
- package/dist/mcp/field-schema.js +137 -14
- package/dist/mcp/field-schema.js.map +1 -1
- package/dist/mcp/handler.d.ts +16 -5
- package/dist/mcp/handler.d.ts.map +1 -1
- package/dist/mcp/handler.js +404 -126
- package/dist/mcp/handler.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/projection.d.ts +42 -34
- package/dist/mcp/projection.d.ts.map +1 -1
- package/dist/mcp/projection.js +246 -200
- package/dist/mcp/projection.js.map +1 -1
- package/dist/mcp/tool-error.d.ts +8 -0
- package/dist/mcp/tool-error.d.ts.map +1 -0
- package/dist/mcp/tool-error.js +11 -0
- package/dist/mcp/tool-error.js.map +1 -0
- package/dist/mcp/types.d.ts +3 -2
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/where-id-boundary.d.ts +28 -0
- package/dist/mcp/where-id-boundary.d.ts.map +1 -0
- package/dist/mcp/where-id-boundary.js +187 -0
- package/dist/mcp/where-id-boundary.js.map +1 -0
- package/dist/origin.d.ts +147 -0
- package/dist/origin.d.ts.map +1 -0
- package/dist/origin.js +191 -0
- package/dist/origin.js.map +1 -0
- package/dist/query/relationship-options.d.ts +35 -6
- package/dist/query/relationship-options.d.ts.map +1 -1
- package/dist/query/relationship-options.js +33 -23
- package/dist/query/relationship-options.js.map +1 -1
- package/dist/secured/aggregate.d.ts +32 -0
- package/dist/secured/aggregate.d.ts.map +1 -0
- package/dist/secured/aggregate.js +31 -0
- package/dist/secured/aggregate.js.map +1 -0
- package/dist/secured/include.d.ts +320 -0
- package/dist/secured/include.d.ts.map +1 -0
- package/dist/secured/include.js +650 -0
- package/dist/secured/include.js.map +1 -0
- package/dist/secured/lock.d.ts +127 -0
- package/dist/secured/lock.d.ts.map +1 -0
- package/dist/secured/lock.js +275 -0
- package/dist/secured/lock.js.map +1 -0
- package/dist/secured/lower.d.ts +82 -0
- package/dist/secured/lower.d.ts.map +1 -0
- package/dist/secured/lower.js +162 -0
- package/dist/secured/lower.js.map +1 -0
- package/dist/secured/operators.d.ts +7 -0
- package/dist/secured/operators.d.ts.map +1 -0
- package/dist/secured/operators.js +18 -0
- package/dist/secured/operators.js.map +1 -0
- package/dist/secured/read.d.ts +208 -0
- package/dist/secured/read.d.ts.map +1 -0
- package/dist/secured/read.js +1245 -0
- package/dist/secured/read.js.map +1 -0
- package/dist/secured/select.d.ts +87 -0
- package/dist/secured/select.d.ts.map +1 -0
- package/dist/secured/select.js +250 -0
- package/dist/secured/select.js.map +1 -0
- package/dist/secured/vector.d.ts +58 -0
- package/dist/secured/vector.d.ts.map +1 -0
- package/dist/secured/vector.js +113 -0
- package/dist/secured/vector.js.map +1 -0
- package/dist/secured/vocabulary.d.ts +227 -0
- package/dist/secured/vocabulary.d.ts.map +1 -0
- package/dist/secured/vocabulary.js +578 -0
- package/dist/secured/vocabulary.js.map +1 -0
- package/dist/secured/write.d.ts +58 -0
- package/dist/secured/write.d.ts.map +1 -0
- package/dist/secured/write.js +87 -0
- package/dist/secured/write.js.map +1 -0
- package/dist/testing/context.d.ts +236 -0
- package/dist/testing/context.d.ts.map +1 -0
- package/dist/testing/context.js +457 -0
- package/dist/testing/context.js.map +1 -0
- package/dist/testing/escape.d.ts +83 -0
- package/dist/testing/escape.d.ts.map +1 -0
- package/dist/testing/escape.js +148 -0
- package/dist/testing/escape.js.map +1 -0
- package/dist/testing/extensions.d.ts +48 -0
- package/dist/testing/extensions.d.ts.map +1 -0
- package/dist/testing/extensions.js +107 -0
- package/dist/testing/extensions.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +11 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/plans.d.ts +64 -0
- package/dist/testing/plans.d.ts.map +1 -0
- package/dist/testing/plans.js +47 -0
- package/dist/testing/plans.js.map +1 -0
- package/dist/types/context.d.ts +110 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +2 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/contract.d.ts +198 -0
- package/dist/types/contract.d.ts.map +1 -0
- package/dist/types/contract.js +2 -0
- package/dist/types/contract.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/inputs.d.ts +83 -0
- package/dist/types/inputs.d.ts.map +1 -0
- package/dist/types/inputs.js +2 -0
- package/dist/types/inputs.js.map +1 -0
- package/dist/types/rows.d.ts +76 -0
- package/dist/types/rows.d.ts.map +1 -0
- package/dist/types/rows.js +2 -0
- package/dist/types/rows.js.map +1 -0
- package/dist/types/secured-list.d.ts +396 -0
- package/dist/types/secured-list.d.ts.map +1 -0
- package/dist/types/secured-list.js +2 -0
- package/dist/types/secured-list.js.map +1 -0
- package/dist/unsafe.d.ts +162 -0
- package/dist/unsafe.d.ts.map +1 -0
- package/dist/unsafe.js +177 -0
- package/dist/unsafe.js.map +1 -0
- package/dist/validation/config-refusal.d.ts +16 -0
- package/dist/validation/config-refusal.d.ts.map +1 -0
- package/dist/validation/config-refusal.js +2 -0
- package/dist/validation/config-refusal.js.map +1 -0
- package/dist/validation/database-config.d.ts +19 -0
- package/dist/validation/database-config.d.ts.map +1 -0
- package/dist/validation/database-config.js +237 -0
- package/dist/validation/database-config.js.map +1 -0
- package/dist/validation/default-value.d.ts +21 -0
- package/dist/validation/default-value.d.ts.map +1 -0
- package/dist/validation/default-value.js +72 -0
- package/dist/validation/default-value.js.map +1 -0
- package/dist/validation/extension-packs.d.ts +11 -0
- package/dist/validation/extension-packs.d.ts.map +1 -0
- package/dist/validation/extension-packs.js +53 -0
- package/dist/validation/extension-packs.js.map +1 -0
- package/dist/validation/field-config.d.ts +35 -21
- package/dist/validation/field-config.d.ts.map +1 -1
- package/dist/validation/field-config.js +51 -41
- package/dist/validation/field-config.js.map +1 -1
- package/dist/validation/field-names.d.ts +15 -0
- package/dist/validation/field-names.d.ts.map +1 -0
- package/dist/validation/field-names.js +155 -0
- package/dist/validation/field-names.js.map +1 -0
- package/dist/validation/identifier-names.d.ts +4 -0
- package/dist/validation/identifier-names.d.ts.map +1 -0
- package/dist/validation/identifier-names.js +39 -0
- package/dist/validation/identifier-names.js.map +1 -0
- package/dist/validation/needs-closure.d.ts +20 -30
- package/dist/validation/needs-closure.d.ts.map +1 -1
- package/dist/validation/needs-closure.js +29 -105
- package/dist/validation/needs-closure.js.map +1 -1
- package/dist/validation/relations.d.ts +17 -0
- package/dist/validation/relations.d.ts.map +1 -0
- package/dist/validation/relations.js +268 -0
- package/dist/validation/relations.js.map +1 -0
- package/dist/validation/schema.d.ts.map +1 -1
- package/dist/validation/schema.js +1 -3
- package/dist/validation/schema.js.map +1 -1
- package/dist/where/like.d.ts +32 -0
- package/dist/where/like.d.ts.map +1 -0
- package/dist/where/like.js +42 -0
- package/dist/where/like.js.map +1 -0
- package/package.json +70 -8
- package/.turbo/turbo-build.log +0 -4
- package/CLAUDE.md +0 -609
- package/dist/access/access-filter.d.ts +0 -241
- package/dist/access/access-filter.d.ts.map +0 -1
- package/dist/access/access-filter.js +0 -692
- package/dist/access/access-filter.js.map +0 -1
- package/dist/access/access-filter.test.d.ts +0 -2
- package/dist/access/access-filter.test.d.ts.map +0 -1
- package/dist/access/access-filter.test.js +0 -1256
- package/dist/access/access-filter.test.js.map +0 -1
- package/dist/access/declared-dependencies.test.d.ts +0 -2
- package/dist/access/declared-dependencies.test.d.ts.map +0 -1
- package/dist/access/declared-dependencies.test.js +0 -226
- package/dist/access/declared-dependencies.test.js.map +0 -1
- package/dist/access/denied-relation-visibility.test.d.ts +0 -2
- package/dist/access/denied-relation-visibility.test.d.ts.map +0 -1
- package/dist/access/denied-relation-visibility.test.js +0 -114
- package/dist/access/denied-relation-visibility.test.js.map +0 -1
- package/dist/access/engine.test.d.ts +0 -2
- package/dist/access/engine.test.d.ts.map +0 -1
- package/dist/access/engine.test.js +0 -56
- package/dist/access/engine.test.js.map +0 -1
- package/dist/access/field-access.test.d.ts +0 -2
- package/dist/access/field-access.test.d.ts.map +0 -1
- package/dist/access/field-access.test.js +0 -635
- package/dist/access/field-access.test.js.map +0 -1
- package/dist/access/multi-column-read-write.test.d.ts +0 -2
- package/dist/access/multi-column-read-write.test.d.ts.map +0 -1
- package/dist/access/multi-column-read-write.test.js +0 -183
- package/dist/access/multi-column-read-write.test.js.map +0 -1
- package/dist/access/relationship-count.d.ts +0 -98
- package/dist/access/relationship-count.d.ts.map +0 -1
- package/dist/access/relationship-count.js +0 -262
- package/dist/access/relationship-count.js.map +0 -1
- package/dist/access/relationship-count.test.d.ts +0 -2
- package/dist/access/relationship-count.test.d.ts.map +0 -1
- package/dist/access/relationship-count.test.js +0 -247
- package/dist/access/relationship-count.test.js.map +0 -1
- package/dist/access/relationship-label-filter.d.ts +0 -45
- package/dist/access/relationship-label-filter.d.ts.map +0 -1
- package/dist/access/relationship-label-filter.js +0 -22
- package/dist/access/relationship-label-filter.js.map +0 -1
- package/dist/access/relationship-label-filter.test.d.ts +0 -2
- package/dist/access/relationship-label-filter.test.d.ts.map +0 -1
- package/dist/access/relationship-label-filter.test.js +0 -89
- package/dist/access/relationship-label-filter.test.js.map +0 -1
- package/dist/access/synthetic-include-read.test.d.ts +0 -2
- package/dist/access/synthetic-include-read.test.d.ts.map +0 -1
- package/dist/access/synthetic-include-read.test.js +0 -121
- package/dist/access/synthetic-include-read.test.js.map +0 -1
- package/dist/context/nested-operations.d.ts +0 -74
- package/dist/context/nested-operations.d.ts.map +0 -1
- package/dist/context/nested-operations.js +0 -847
- package/dist/context/nested-operations.js.map +0 -1
- package/dist/fields/calendar-day.test.d.ts +0 -2
- package/dist/fields/calendar-day.test.d.ts.map +0 -1
- package/dist/fields/calendar-day.test.js +0 -246
- package/dist/fields/calendar-day.test.js.map +0 -1
- package/dist/fields/format-prisma-default.d.ts +0 -35
- package/dist/fields/format-prisma-default.d.ts.map +0 -1
- package/dist/fields/format-prisma-default.js +0 -49
- package/dist/fields/format-prisma-default.js.map +0 -1
- package/dist/fields/format-prisma-default.test.d.ts +0 -2
- package/dist/fields/format-prisma-default.test.d.ts.map +0 -1
- package/dist/fields/format-prisma-default.test.js +0 -54
- package/dist/fields/format-prisma-default.test.js.map +0 -1
- package/dist/fields/relationship-foreign-key.test.d.ts +0 -2
- package/dist/fields/relationship-foreign-key.test.d.ts.map +0 -1
- package/dist/fields/relationship-foreign-key.test.js +0 -18
- package/dist/fields/relationship-foreign-key.test.js.map +0 -1
- package/dist/fields/select.test.d.ts +0 -2
- package/dist/fields/select.test.d.ts.map +0 -1
- package/dist/fields/select.test.js +0 -279
- package/dist/fields/select.test.js.map +0 -1
- package/dist/fields/text-keystone-compat.test.d.ts +0 -2
- package/dist/fields/text-keystone-compat.test.d.ts.map +0 -1
- package/dist/fields/text-keystone-compat.test.js +0 -93
- package/dist/fields/text-keystone-compat.test.js.map +0 -1
- package/dist/filter/filter.test.d.ts +0 -2
- package/dist/filter/filter.test.d.ts.map +0 -1
- package/dist/filter/filter.test.js +0 -431
- package/dist/filter/filter.test.js.map +0 -1
- package/dist/filter/serialize.test.d.ts +0 -2
- package/dist/filter/serialize.test.d.ts.map +0 -1
- package/dist/filter/serialize.test.js +0 -83
- package/dist/filter/serialize.test.js.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/dist/index.test.js +0 -33
- package/dist/index.test.js.map +0 -1
- package/dist/lib/case-utils.test.d.ts +0 -2
- package/dist/lib/case-utils.test.d.ts.map +0 -1
- package/dist/lib/case-utils.test.js +0 -123
- package/dist/lib/case-utils.test.js.map +0 -1
- package/dist/query/index.d.ts +0 -127
- package/dist/query/index.d.ts.map +0 -1
- package/dist/query/index.js +0 -179
- package/dist/query/index.js.map +0 -1
- package/dist/query/index.test.d.ts +0 -2
- package/dist/query/index.test.d.ts.map +0 -1
- package/dist/query/index.test.js +0 -632
- package/dist/query/index.test.js.map +0 -1
- package/dist/query/relationship-options.test.d.ts +0 -2
- package/dist/query/relationship-options.test.d.ts.map +0 -1
- package/dist/query/relationship-options.test.js +0 -150
- package/dist/query/relationship-options.test.js.map +0 -1
- package/dist/validation/field-config.test.d.ts +0 -2
- package/dist/validation/field-config.test.d.ts.map +0 -1
- package/dist/validation/field-config.test.js +0 -159
- package/dist/validation/field-config.test.js.map +0 -1
- package/dist/validation/schema.test.d.ts +0 -2
- package/dist/validation/schema.test.d.ts.map +0 -1
- package/dist/validation/schema.test.js +0 -409
- package/dist/validation/schema.test.js.map +0 -1
- package/docs/type-distribution-fix.md +0 -136
- package/src/access/access-filter.test.ts +0 -1919
- package/src/access/access-filter.ts +0 -1041
- package/src/access/declared-dependencies.test.ts +0 -277
- package/src/access/declared-dependencies.ts +0 -220
- package/src/access/denied-relation-visibility.test.ts +0 -173
- package/src/access/depth-limits.ts +0 -27
- package/src/access/engine.test.ts +0 -67
- package/src/access/engine.ts +0 -193
- package/src/access/errors.ts +0 -242
- package/src/access/field-access.test.ts +0 -792
- package/src/access/field-access.ts +0 -353
- package/src/access/field-transforms.ts +0 -68
- package/src/access/field-visibility.ts +0 -569
- package/src/access/index.ts +0 -82
- package/src/access/multi-column-read-write.test.ts +0 -305
- package/src/access/query-validation.ts +0 -486
- package/src/access/relationship-count.test.ts +0 -344
- package/src/access/relationship-count.ts +0 -346
- package/src/access/relationship-label-filter.test.ts +0 -128
- package/src/access/relationship-label-filter.ts +0 -63
- package/src/access/synthetic-include-read.test.ts +0 -179
- package/src/access/transaction-registry.ts +0 -58
- package/src/access/types.ts +0 -391
- package/src/config/index.ts +0 -177
- package/src/config/label.ts +0 -51
- package/src/config/nav-count.ts +0 -77
- package/src/config/plugin-engine.ts +0 -261
- package/src/config/types.ts +0 -3270
- package/src/context/apply-defaults.ts +0 -47
- package/src/context/hook-pipeline.ts +0 -137
- package/src/context/index.ts +0 -1737
- package/src/context/nested-operations.ts +0 -1470
- package/src/context/transaction-boundary.ts +0 -485
- package/src/context/write-pipeline.ts +0 -732
- package/src/extend.ts +0 -28
- package/src/fields/calendar-day.test.ts +0 -291
- package/src/fields/format-prisma-default.test.ts +0 -64
- package/src/fields/format-prisma-default.ts +0 -64
- package/src/fields/index.ts +0 -1901
- package/src/fields/relationship-foreign-key.test.ts +0 -29
- package/src/fields/select.test.ts +0 -336
- package/src/fields/text-keystone-compat.test.ts +0 -126
- package/src/filter/collect.ts +0 -108
- package/src/filter/filter.test.ts +0 -538
- package/src/filter/index.ts +0 -26
- package/src/filter/map.ts +0 -63
- package/src/filter/parse.ts +0 -99
- package/src/filter/serialize.test.ts +0 -115
- package/src/filter/serialize.ts +0 -73
- package/src/filter/types.ts +0 -120
- package/src/hooks/index.ts +0 -752
- package/src/index.test.ts +0 -50
- package/src/index.ts +0 -192
- package/src/internal.ts +0 -61
- package/src/lib/case-utils.test.ts +0 -159
- package/src/lib/case-utils.ts +0 -68
- package/src/lib/prisma-errors.ts +0 -86
- package/src/mcp/constants.ts +0 -24
- package/src/mcp/field-schema.ts +0 -84
- package/src/mcp/handler.ts +0 -633
- package/src/mcp/index.ts +0 -7
- package/src/mcp/projection.ts +0 -497
- package/src/mcp/types.ts +0 -18
- package/src/query/index.test.ts +0 -830
- package/src/query/index.ts +0 -352
- package/src/query/relationship-options.test.ts +0 -194
- package/src/query/relationship-options.ts +0 -78
- package/src/utils/password.ts +0 -80
- package/src/validation/field-config.test.ts +0 -199
- package/src/validation/field-config.ts +0 -139
- package/src/validation/needs-closure.ts +0 -188
- package/src/validation/schema.test.ts +0 -487
- package/src/validation/schema.ts +0 -51
- package/tests/access-relationships.test.ts +0 -646
- package/tests/access.test.ts +0 -590
- package/tests/apply-defaults.test.ts +0 -119
- package/tests/bare-read-scalars.test.ts +0 -147
- package/tests/computed-field-selective-evaluation.test.ts +0 -418
- package/tests/config.test.ts +0 -242
- package/tests/context.test.ts +0 -3146
- package/tests/default-value-create.test.ts +0 -299
- package/tests/field-hooks.test.ts +0 -410
- package/tests/field-types.test.ts +0 -1291
- package/tests/hook-context-secured.test.ts +0 -424
- package/tests/hook-pipeline.test.ts +0 -233
- package/tests/hooks.test.ts +0 -481
- package/tests/interactive-transaction.test.ts +0 -444
- package/tests/label.test.ts +0 -135
- package/tests/mcp-fields-projection-access.test.ts +0 -250
- package/tests/mcp-handler.test.ts +0 -1411
- package/tests/multi-column-validation-ordering.test.ts +0 -305
- package/tests/nav-count.test.ts +0 -189
- package/tests/needs-declared-dependencies.test.ts +0 -503
- package/tests/nested-access-and-hooks.test.ts +0 -2566
- package/tests/nested-operation-registry.test.ts +0 -317
- package/tests/nested-write-hooks.test.ts +0 -864
- package/tests/nested-write-synthetic-relation.test.ts +0 -437
- package/tests/password-type-distribution.test.ts +0 -154
- package/tests/password-types.test.ts +0 -174
- package/tests/password.test.ts +0 -263
- package/tests/plugin-engine.test.ts +0 -1155
- package/tests/prisma-errors.test.ts +0 -141
- package/tests/resolve-chain.test.ts +0 -411
- package/tests/singleton.test.ts +0 -421
- package/tests/sudo.test.ts +0 -676
- package/tests/to-one-include-access-filter.test.ts +0 -172
- package/tests/transaction-boundary-hooks.test.ts +0 -710
- package/tests/transaction-boundary-outermost.test.ts +0 -530
- package/tests/virtual-fields.test.ts +0 -421
- package/tests/with-session.test.ts +0 -243
- package/tests/write-pipeline.test.ts +0 -617
- package/tsconfig.json +0 -12
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -69
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relationship-count.test.d.ts","sourceRoot":"","sources":["../../src/access/relationship-count.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { list } from '../config/index.js';
|
|
3
|
-
import { text, relationship, integer } from '../fields/index.js';
|
|
4
|
-
import { buildRelationshipCountSelect, resolveRelationshipCountFilters, isToManyRelationshipField, } from './relationship-count.js';
|
|
5
|
-
import { RELATIONSHIP_COUNT_FILTER_KEY } from '../filter/types.js';
|
|
6
|
-
/**
|
|
7
|
-
* Access-scoped to-many relationship counts (issue #732). Verifies:
|
|
8
|
-
* • the filtered `_count` select folds in the related list's query access,
|
|
9
|
-
* • a denied related list is omitted (its count renders as 0, never a leak),
|
|
10
|
-
* • count-filter markers resolve to access-scoped `{ id: { in } }` via a single
|
|
11
|
-
* secured read (never a per-row query), including the fully-denied case.
|
|
12
|
-
*/
|
|
13
|
-
// User (published-only for anon via a filter), plus a Widget list that is fully
|
|
14
|
-
// closed by default (no query access) to prove the denied path.
|
|
15
|
-
function makeConfig() {
|
|
16
|
-
return {
|
|
17
|
-
db: { provider: 'sqlite', prismaClientConstructor: () => null },
|
|
18
|
-
lists: {
|
|
19
|
-
User: list({
|
|
20
|
-
fields: {
|
|
21
|
-
name: text(),
|
|
22
|
-
posts: relationship({ ref: 'Post.author', many: true }),
|
|
23
|
-
widgets: relationship({ ref: 'Widget', many: true }),
|
|
24
|
-
manager: relationship({ ref: 'User' }), // to-one — never counted
|
|
25
|
-
},
|
|
26
|
-
access: { operation: { query: () => true } },
|
|
27
|
-
}),
|
|
28
|
-
Post: list({
|
|
29
|
-
fields: { title: text(), views: integer(), author: relationship({ ref: 'User.posts' }) },
|
|
30
|
-
// Only published posts are visible → the count must be access-scoped.
|
|
31
|
-
access: { operation: { query: () => ({ status: { equals: 'published' } }) } },
|
|
32
|
-
}),
|
|
33
|
-
// Widget ships closed (no access block) → query denied by default.
|
|
34
|
-
Widget: list({ fields: { name: text() } }),
|
|
35
|
-
},
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function makeContext(findMany) {
|
|
40
|
-
return {
|
|
41
|
-
session: null,
|
|
42
|
-
_isSudo: false,
|
|
43
|
-
_resolveOutputChain: [],
|
|
44
|
-
db: findMany ? { user: { findMany } } : {},
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal context for unit test
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
describe('isToManyRelationshipField', () => {
|
|
49
|
-
const config = makeConfig();
|
|
50
|
-
const userFields = config.lists.User.fields;
|
|
51
|
-
it('is true only for a to-many relationship', () => {
|
|
52
|
-
expect(isToManyRelationshipField(userFields.posts)).toBe(true);
|
|
53
|
-
expect(isToManyRelationshipField(userFields.widgets)).toBe(true);
|
|
54
|
-
expect(isToManyRelationshipField(userFields.manager)).toBe(false);
|
|
55
|
-
expect(isToManyRelationshipField(userFields.name)).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
describe('buildRelationshipCountSelect', () => {
|
|
59
|
-
it("folds the related list's query filter into each to-many count and omits denied/to-one", async () => {
|
|
60
|
-
const config = makeConfig();
|
|
61
|
-
const select = await buildRelationshipCountSelect(config.lists.User, { session: null, context: makeContext() }, config);
|
|
62
|
-
// `posts` → access-scoped where; `widgets` → denied (omitted); `manager` →
|
|
63
|
-
// to-one (never counted).
|
|
64
|
-
expect(select).toEqual({ posts: { where: { status: { equals: 'published' } } } });
|
|
65
|
-
});
|
|
66
|
-
it('uses a bare `true` when the related list is fully readable', async () => {
|
|
67
|
-
const config = {
|
|
68
|
-
db: { provider: 'sqlite', prismaClientConstructor: () => null },
|
|
69
|
-
lists: {
|
|
70
|
-
Tag: list({ fields: { name: text() }, access: { operation: { query: () => true } } }),
|
|
71
|
-
Post: list({ fields: { title: text(), tags: relationship({ ref: 'Tag', many: true }) } }),
|
|
72
|
-
},
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
74
|
-
};
|
|
75
|
-
const select = await buildRelationshipCountSelect(config.lists.Post, { session: null, context: makeContext() }, config);
|
|
76
|
-
expect(select).toEqual({ tags: true });
|
|
77
|
-
});
|
|
78
|
-
it('returns undefined when there are no countable to-many relationships', async () => {
|
|
79
|
-
const config = {
|
|
80
|
-
db: { provider: 'sqlite', prismaClientConstructor: () => null },
|
|
81
|
-
lists: { Post: list({ fields: { title: text() } }) },
|
|
82
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
83
|
-
};
|
|
84
|
-
const select = await buildRelationshipCountSelect(config.lists.Post, { session: null, context: makeContext() }, config);
|
|
85
|
-
expect(select).toBeUndefined();
|
|
86
|
-
});
|
|
87
|
-
// Issue #1111: a relationship hidden via field-level `read` access must not
|
|
88
|
-
// leak its true count, even when the related list's rows are otherwise
|
|
89
|
-
// fully readable — the same denial an ordinary `include` of that field
|
|
90
|
-
// already gets from `filterReadableFields`'s `checkFieldAccess` call.
|
|
91
|
-
it('omits a relation whose field-level `read` access denies it, even though the related list is fully readable', async () => {
|
|
92
|
-
const config = {
|
|
93
|
-
db: { provider: 'sqlite', prismaClientConstructor: () => null },
|
|
94
|
-
lists: {
|
|
95
|
-
User: list({
|
|
96
|
-
fields: {
|
|
97
|
-
name: text(),
|
|
98
|
-
posts: relationship({
|
|
99
|
-
ref: 'Post.author',
|
|
100
|
-
many: true,
|
|
101
|
-
access: { read: () => false },
|
|
102
|
-
}),
|
|
103
|
-
},
|
|
104
|
-
access: { operation: { query: () => true } },
|
|
105
|
-
}),
|
|
106
|
-
Post: list({
|
|
107
|
-
fields: { title: text(), author: relationship({ ref: 'User.posts' }) },
|
|
108
|
-
access: { operation: { query: () => true } },
|
|
109
|
-
}),
|
|
110
|
-
},
|
|
111
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
112
|
-
};
|
|
113
|
-
const select = await buildRelationshipCountSelect(config.lists.User, { session: null, context: makeContext() }, config);
|
|
114
|
-
expect(select).toBeUndefined();
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
describe('resolveRelationshipCountFilters', () => {
|
|
118
|
-
const marker = (operator, value) => ({
|
|
119
|
-
posts: { [RELATIONSHIP_COUNT_FILTER_KEY]: { operator, value } },
|
|
120
|
-
});
|
|
121
|
-
it('returns the where unchanged when there are no count markers', async () => {
|
|
122
|
-
const config = makeConfig();
|
|
123
|
-
const where = { name: { contains: 'ada' } };
|
|
124
|
-
const resolved = await resolveRelationshipCountFilters(where, config.lists.User, 'User', { session: null, context: makeContext() }, config);
|
|
125
|
-
expect(resolved).toBe(where);
|
|
126
|
-
});
|
|
127
|
-
it('resolves a count marker to an access-scoped { id: { in } } via a single secured read', async () => {
|
|
128
|
-
const config = makeConfig();
|
|
129
|
-
// Two users; the secured read returns each with its access-scoped `_count`.
|
|
130
|
-
const findMany = vi.fn(async () => [
|
|
131
|
-
{ id: 'u1', _count: { posts: 3 } },
|
|
132
|
-
{ id: 'u2', _count: { posts: 7 } },
|
|
133
|
-
]);
|
|
134
|
-
const resolved = await resolveRelationshipCountFilters(marker('gt', 5), config.lists.User, 'User', { session: null, context: makeContext(findMany) }, config);
|
|
135
|
-
// Only u2 (7 > 5) matches; the read was access-scoped (published-only count).
|
|
136
|
-
expect(resolved).toEqual({ id: { in: ['u2'] } });
|
|
137
|
-
expect(findMany).toHaveBeenCalledTimes(1);
|
|
138
|
-
expect(findMany).toHaveBeenCalledWith({
|
|
139
|
-
include: { _count: { select: { posts: { where: { status: { equals: 'published' } } } } } },
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
it('includes zero-count rows for comparisons that admit zero (no complement bug)', async () => {
|
|
143
|
-
const config = makeConfig();
|
|
144
|
-
const findMany = vi.fn(async () => [
|
|
145
|
-
{ id: 'u1', _count: { posts: 0 } },
|
|
146
|
-
{ id: 'u2', _count: { posts: 4 } },
|
|
147
|
-
]);
|
|
148
|
-
const resolved = await resolveRelationshipCountFilters(marker('lt', 1), // count < 1 → only the zero-count user
|
|
149
|
-
config.lists.User, 'User', { session: null, context: makeContext(findMany) }, config);
|
|
150
|
-
expect(resolved).toEqual({ id: { in: ['u1'] } });
|
|
151
|
-
});
|
|
152
|
-
it('resolves a denied related list without any query: count is always 0', async () => {
|
|
153
|
-
const config = makeConfig();
|
|
154
|
-
const findMany = vi.fn(async () => []);
|
|
155
|
-
// `widgets`' related list (Widget) is fully denied → every count is 0.
|
|
156
|
-
const where = { widgets: { [RELATIONSHIP_COUNT_FILTER_KEY]: { operator: 'gt', value: 5 } } };
|
|
157
|
-
const resolved = await resolveRelationshipCountFilters(where, config.lists.User, 'User', { session: null, context: makeContext(findMany) }, config);
|
|
158
|
-
// 0 is not > 5 → nothing matches, and no read was issued.
|
|
159
|
-
expect(resolved).toEqual({ id: { in: [] } });
|
|
160
|
-
expect(findMany).not.toHaveBeenCalled();
|
|
161
|
-
});
|
|
162
|
-
// Issue #1111: a relationship denied at the FIELD level (as opposed to the
|
|
163
|
-
// related list's operation-level `query` access, covered above) must also
|
|
164
|
-
// resolve to "always 0, no query needed" — the related list here (Post) is
|
|
165
|
-
// otherwise fully readable, so only the field-level check on `posts` itself
|
|
166
|
-
// can be what's denying it.
|
|
167
|
-
it('resolves a field-level-denied relationship without any query: count is always 0', async () => {
|
|
168
|
-
const config = {
|
|
169
|
-
db: { provider: 'sqlite', prismaClientConstructor: () => null },
|
|
170
|
-
lists: {
|
|
171
|
-
User: list({
|
|
172
|
-
fields: {
|
|
173
|
-
name: text(),
|
|
174
|
-
posts: relationship({
|
|
175
|
-
ref: 'Post.author',
|
|
176
|
-
many: true,
|
|
177
|
-
access: { read: () => false },
|
|
178
|
-
}),
|
|
179
|
-
},
|
|
180
|
-
access: { operation: { query: () => true } },
|
|
181
|
-
}),
|
|
182
|
-
Post: list({
|
|
183
|
-
fields: { title: text(), author: relationship({ ref: 'User.posts' }) },
|
|
184
|
-
access: { operation: { query: () => true } },
|
|
185
|
-
}),
|
|
186
|
-
},
|
|
187
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
188
|
-
};
|
|
189
|
-
const findMany = vi.fn(async () => []);
|
|
190
|
-
const where = { posts: { [RELATIONSHIP_COUNT_FILTER_KEY]: { operator: 'gt', value: 0 } } };
|
|
191
|
-
const resolved = await resolveRelationshipCountFilters(where, config.lists.User, 'User', { session: null, context: makeContext(findMany) }, config);
|
|
192
|
-
expect(resolved).toEqual({ id: { in: [] } });
|
|
193
|
-
expect(findMany).not.toHaveBeenCalled();
|
|
194
|
-
});
|
|
195
|
-
it('preserves sibling conditions, ANDing the resolved id constraint', async () => {
|
|
196
|
-
const config = makeConfig();
|
|
197
|
-
const findMany = vi.fn(async () => [{ id: 'u2', _count: { posts: 7 } }]);
|
|
198
|
-
const where = { AND: [{ name: { contains: 'ada' } }, marker('gte', 1)] };
|
|
199
|
-
const resolved = await resolveRelationshipCountFilters(where, config.lists.User, 'User', { session: null, context: makeContext(findMany) }, config);
|
|
200
|
-
expect(resolved).toEqual({ AND: [{ name: { contains: 'ada' } }, { id: { in: ['u2'] } }] });
|
|
201
|
-
});
|
|
202
|
-
it('reads with only the filtered `_count` include — no over-fetching `select` projection', async () => {
|
|
203
|
-
const config = makeConfig();
|
|
204
|
-
const findMany = vi.fn((_args) => Promise.resolve([{ id: 'u2', _count: { posts: 7 } }]));
|
|
205
|
-
await resolveRelationshipCountFilters(marker('gt', 5), config.lists.User, 'User', { session: null, context: makeContext(findMany) }, config);
|
|
206
|
-
// The secured read is issued with the access-scoped `_count` include and NO
|
|
207
|
-
// `select` — the secured findMany does not honour `select`, so forcing one
|
|
208
|
-
// would be an ignored no-op. Access-scoping lives entirely in `_count.where`.
|
|
209
|
-
expect(findMany).toHaveBeenCalledTimes(1);
|
|
210
|
-
const callArg = findMany.mock.calls[0][0];
|
|
211
|
-
expect(callArg).not.toHaveProperty('select');
|
|
212
|
-
expect(callArg).toEqual({
|
|
213
|
-
include: { _count: { select: { posts: { where: { status: { equals: 'published' } } } } } },
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
it('preserves a sibling condition co-present in the same member as the marker', async () => {
|
|
217
|
-
const config = makeConfig();
|
|
218
|
-
const findMany = vi.fn(async () => [{ id: 'u2', _count: { posts: 7 } }]);
|
|
219
|
-
// A single AND-member carrying BOTH a scalar condition and the count marker.
|
|
220
|
-
// The marker resolution must keep the co-present sibling, not replace the
|
|
221
|
-
// member wholesale (guards against a future filter-engine change that merges
|
|
222
|
-
// conditions into one member).
|
|
223
|
-
const where = {
|
|
224
|
-
AND: [
|
|
225
|
-
{
|
|
226
|
-
name: { contains: 'ada' },
|
|
227
|
-
posts: { [RELATIONSHIP_COUNT_FILTER_KEY]: { operator: 'gt', value: 5 } },
|
|
228
|
-
},
|
|
229
|
-
],
|
|
230
|
-
};
|
|
231
|
-
const resolved = await resolveRelationshipCountFilters(where, config.lists.User, 'User', { session: null, context: makeContext(findMany) }, config);
|
|
232
|
-
expect(resolved).toEqual({ name: { contains: 'ada' }, id: { in: ['u2'] } });
|
|
233
|
-
});
|
|
234
|
-
it('ANDs the resolved id constraint with a co-present sibling id condition (no silent drop)', async () => {
|
|
235
|
-
const config = makeConfig();
|
|
236
|
-
const findMany = vi.fn(async () => [{ id: 'u2', _count: { posts: 7 } }]);
|
|
237
|
-
// Contrived: a member carrying its own `id` condition alongside the marker.
|
|
238
|
-
// Spreading would let one `id` overwrite the other; instead both are ANDed.
|
|
239
|
-
const where = {
|
|
240
|
-
id: { in: ['u1', 'u2'] },
|
|
241
|
-
posts: { [RELATIONSHIP_COUNT_FILTER_KEY]: { operator: 'gt', value: 5 } },
|
|
242
|
-
};
|
|
243
|
-
const resolved = await resolveRelationshipCountFilters(where, config.lists.User, 'User', { session: null, context: makeContext(findMany) }, config);
|
|
244
|
-
expect(resolved).toEqual({ AND: [{ id: { in: ['u1', 'u2'] } }, { id: { in: ['u2'] } }] });
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
//# sourceMappingURL=relationship-count.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relationship-count.test.js","sourceRoot":"","sources":["../../src/access/relationship-count.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAGhE,OAAO,EACL,4BAA4B,EAC5B,+BAA+B,EAC/B,yBAAyB,GAC1B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAA;AAElE;;;;;;GAMG;AAEH,gFAAgF;AAChF,gEAAgE;AAChE,SAAS,UAAU;IACjB,OAAO;QACL,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,uBAAuB,EAAE,GAAG,EAAE,CAAC,IAAa,EAAE;QACxE,KAAK,EAAE;YACL,IAAI,EAAE,IAAI,CAAC;gBACT,MAAM,EAAE;oBACN,IAAI,EA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AE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAA;IAC3F,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { Session, AccessContext } from './types.js';
|
|
2
|
-
import type { OpenSaasConfig, ListConfig, FieldConfig } from '../config/types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Access-scoped to-one relationship label filters for the admin list view
|
|
5
|
-
* (issue #749) — NOW A PASS-THROUGH.
|
|
6
|
-
*
|
|
7
|
-
* A to-one relationship's Filter spec (`author:Ada` → `{ author: { is: { name:
|
|
8
|
-
* { contains: 'Ada' } } } }`) produces exactly the `{ is: {...} }` shape a
|
|
9
|
-
* relation filter uses. Before #916, the engine did not scope relation
|
|
10
|
-
* filters in `where` at all, so this module was the only place the related
|
|
11
|
-
* list's `query` access was folded into that nested `is` clause (mirroring
|
|
12
|
-
* `relationship-count.ts`'s `_count` folding) — otherwise a session could
|
|
13
|
-
* distinguish parent rows by a related field it could not itself read (e.g.
|
|
14
|
-
* binary-searching `author:A`, `author:Ad`, `author:Ada` against a `User`
|
|
15
|
-
* list it cannot query).
|
|
16
|
-
*
|
|
17
|
-
* #916 closed that gap in the engine itself: `context.db.*.findMany`/`count`
|
|
18
|
-
* now scope every relation filter in `where` — including this exact `is`
|
|
19
|
-
* shape — via `buildAccessScopedWhere` (`access-filter.ts`), applied
|
|
20
|
-
* automatically to whatever `where` this module's caller (`ListView.tsx`)
|
|
21
|
-
* hands to the secured context. Folding the same access filter here as well
|
|
22
|
-
* would be redundant work producing an identical result (the engine ANDs the
|
|
23
|
-
* same filter in a second time), so this module's own fold was removed —
|
|
24
|
-
* `resolveRelationshipLabelFilters` now returns `where` unchanged. The
|
|
25
|
-
* exported functions are kept, unchanged in shape, only because they remain
|
|
26
|
-
* part of `@opensaas/stack-core`'s public surface; removing them outright
|
|
27
|
-
* would be a breaking change this fix does not need to make.
|
|
28
|
-
*/
|
|
29
|
-
type LabelFilterArgs = {
|
|
30
|
-
session: Session | null;
|
|
31
|
-
context: AccessContext;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Whether a field is a to-one relationship — the only field kind whose Filter
|
|
35
|
-
* spec emits a nested `{ is: {...} } }` condition against the related list's
|
|
36
|
-
* label field.
|
|
37
|
-
*/
|
|
38
|
-
export declare function isToOneRelationshipField(field: FieldConfig | undefined): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* No longer folds access into label filters — see the module doc above.
|
|
41
|
-
* Returns `where` unchanged.
|
|
42
|
-
*/
|
|
43
|
-
export declare function resolveRelationshipLabelFilters(where: Record<string, unknown> | undefined, _listConfig: ListConfig<any>, _args: LabelFilterArgs, _config: OpenSaasConfig): Promise<Record<string, unknown> | undefined>;
|
|
44
|
-
export {};
|
|
45
|
-
//# sourceMappingURL=relationship-label-filter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relationship-label-filter.d.ts","sourceRoot":"","sources":["../../src/access/relationship-label-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;IACvB,OAAO,EAAE,aAAa,CAAA;CACvB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,CAQhF;AAED;;;GAGG;AACH,wBAAsB,+BAA+B,CACnD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAE1C,WAAW,EAAE,UAAU,CAAC,GAAG,CAAC,EAC5B,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAE9C"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Whether a field is a to-one relationship — the only field kind whose Filter
|
|
3
|
-
* spec emits a nested `{ is: {...} } }` condition against the related list's
|
|
4
|
-
* label field.
|
|
5
|
-
*/
|
|
6
|
-
export function isToOneRelationshipField(field) {
|
|
7
|
-
return (field?.type === 'relationship' &&
|
|
8
|
-
!('many' in field && field.many === true) &&
|
|
9
|
-
'ref' in field &&
|
|
10
|
-
typeof field.ref === 'string' &&
|
|
11
|
-
field.ref.length > 0);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* No longer folds access into label filters — see the module doc above.
|
|
15
|
-
* Returns `where` unchanged.
|
|
16
|
-
*/
|
|
17
|
-
export async function resolveRelationshipLabelFilters(where,
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo, kept for API compatibility (see module doc)
|
|
19
|
-
_listConfig, _args, _config) {
|
|
20
|
-
return where;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=relationship-label-filter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relationship-label-filter.js","sourceRoot":"","sources":["../../src/access/relationship-label-filter.ts"],"names":[],"mappings":"AAmCA;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAA8B;IACrE,OAAO,CACL,KAAK,EAAE,IAAI,KAAK,cAAc;QAC9B,CAAC,CAAC,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;QACzC,KAAK,IAAI,KAAK;QACd,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ;QAC7B,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CACrB,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,KAA0C;AAC1C,kJAAkJ;AAClJ,WAA4B,EAC5B,KAAsB,EACtB,OAAuB;IAEvB,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relationship-label-filter.test.d.ts","sourceRoot":"","sources":["../../src/access/relationship-label-filter.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { list } from '../config/index.js';
|
|
3
|
-
import { text, relationship, integer } from '../fields/index.js';
|
|
4
|
-
import { resolveRelationshipLabelFilters, isToOneRelationshipField, } from './relationship-label-filter.js';
|
|
5
|
-
/**
|
|
6
|
-
* `resolveRelationshipLabelFilters` used to fold the related list's `query`
|
|
7
|
-
* access into a to-one relationship label filter's nested `is` clause
|
|
8
|
-
* (issue #749). Since #916, the engine itself scopes every relation filter in
|
|
9
|
-
* `where` (`buildAccessScopedWhere`), including this exact `{ is: {...} } }`
|
|
10
|
-
* shape, so this resolver's own fold is redundant and has been removed — it
|
|
11
|
-
* is now a pass-through, kept exported only for API compatibility. These
|
|
12
|
-
* tests pin that pass-through behavior; `access-filter.test.ts` and
|
|
13
|
-
* `context.test.ts` cover the actual access-scoping this resolver used to do.
|
|
14
|
-
*/
|
|
15
|
-
function makeConfig() {
|
|
16
|
-
return {
|
|
17
|
-
db: { provider: 'sqlite', prismaClientConstructor: () => null },
|
|
18
|
-
lists: {
|
|
19
|
-
User: list({
|
|
20
|
-
fields: { name: text(), active: integer() },
|
|
21
|
-
access: { operation: { query: () => ({ active: { equals: 1 } }) } },
|
|
22
|
-
}),
|
|
23
|
-
Post: list({
|
|
24
|
-
fields: {
|
|
25
|
-
title: text(),
|
|
26
|
-
views: integer(),
|
|
27
|
-
author: relationship({ ref: 'User.posts' }),
|
|
28
|
-
widget: relationship({ ref: 'Widget' }),
|
|
29
|
-
},
|
|
30
|
-
access: { operation: { query: () => true } },
|
|
31
|
-
}),
|
|
32
|
-
// Widget ships closed (no access block) → query denied by default.
|
|
33
|
-
Widget: list({ fields: { name: text() } }),
|
|
34
|
-
},
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function makeContext() {
|
|
39
|
-
return {
|
|
40
|
-
session: null,
|
|
41
|
-
_isSudo: false,
|
|
42
|
-
_resolveOutputChain: [],
|
|
43
|
-
db: {},
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal context for unit test
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
describe('isToOneRelationshipField', () => {
|
|
48
|
-
const config = makeConfig();
|
|
49
|
-
const postFields = config.lists.Post.fields;
|
|
50
|
-
it('is true only for a to-one relationship', () => {
|
|
51
|
-
expect(isToOneRelationshipField(postFields.author)).toBe(true);
|
|
52
|
-
expect(isToOneRelationshipField(postFields.widget)).toBe(true);
|
|
53
|
-
expect(isToOneRelationshipField(postFields.title)).toBe(false);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
describe('resolveRelationshipLabelFilters (pass-through since #916)', () => {
|
|
57
|
-
it('returns a plain where unchanged', async () => {
|
|
58
|
-
const config = makeConfig();
|
|
59
|
-
const where = { title: { contains: 'hello' } };
|
|
60
|
-
const resolved = await resolveRelationshipLabelFilters(where, config.lists.Post, { session: null, context: makeContext() }, config);
|
|
61
|
-
expect(resolved).toBe(where);
|
|
62
|
-
});
|
|
63
|
-
it('returns a to-one label-filter `is` clause unchanged — the engine scopes it now', async () => {
|
|
64
|
-
const config = makeConfig();
|
|
65
|
-
const where = { author: { is: { name: { contains: 'Ada' } } } };
|
|
66
|
-
const resolved = await resolveRelationshipLabelFilters(where, config.lists.Post, { session: null, context: makeContext() }, config);
|
|
67
|
-
expect(resolved).toBe(where);
|
|
68
|
-
});
|
|
69
|
-
it('returns a label filter against a fully denied related list unchanged too', async () => {
|
|
70
|
-
const config = makeConfig();
|
|
71
|
-
const where = { widget: { is: { name: { contains: 'Gadget' } } } };
|
|
72
|
-
const resolved = await resolveRelationshipLabelFilters(where, config.lists.Post, { session: null, context: makeContext() }, config);
|
|
73
|
-
expect(resolved).toBe(where);
|
|
74
|
-
});
|
|
75
|
-
it('returns a where with nested AND/label-filter members unchanged', async () => {
|
|
76
|
-
const config = makeConfig();
|
|
77
|
-
const where = {
|
|
78
|
-
AND: [{ title: { contains: 'hello' } }, { author: { is: { name: { contains: 'Ada' } } } }],
|
|
79
|
-
};
|
|
80
|
-
const resolved = await resolveRelationshipLabelFilters(where, config.lists.Post, { session: null, context: makeContext() }, config);
|
|
81
|
-
expect(resolved).toBe(where);
|
|
82
|
-
});
|
|
83
|
-
it('returns undefined unchanged when there is no where at all', async () => {
|
|
84
|
-
const config = makeConfig();
|
|
85
|
-
const resolved = await resolveRelationshipLabelFilters(undefined, config.lists.Post, { session: null, context: makeContext() }, config);
|
|
86
|
-
expect(resolved).toBeUndefined();
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
//# sourceMappingURL=relationship-label-filter.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relationship-label-filter.test.js","sourceRoot":"","sources":["../../src/access/relationship-label-filter.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAGhE,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,GACzB,MAAM,gCAAgC,CAAA;AAEvC;;;;;;;;;GASG;AAEH,SAAS,UAAU;IACjB,OAAO;QACL,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAA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zE,MAAM,MAAM,GAAG,UAAU,EAAE,CAAA;QAC3B,MAAM,QAAQ,GAAG,MAAM,+BAA+B,CACpD,SAAS,EACT,MAAM,CAAC,KAAK,CAAC,IAAI,EACjB,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EACzC,MAAM,CACP,CAAA;QACD,MAAM,CAAC,QAAQ,CAAC,CAAC,aAAa,EAAE,CAAA;IAClC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"synthetic-include-read.test.d.ts","sourceRoot":"","sources":["../../src/access/synthetic-include-read.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { filterReadableFields } from './field-visibility.js';
|
|
3
|
-
/**
|
|
4
|
-
* Regression coverage for issue #1082, Field Visibility half.
|
|
5
|
-
*
|
|
6
|
-
* `access-filter.test.ts` covers the pre-query scoping of a synthetic
|
|
7
|
-
* back-relation (`buildAccessScopedInclude`); these tests cover what happens
|
|
8
|
-
* to the rows it fetches. Before this fix, `filterReadableFields` recognised
|
|
9
|
-
* only a DECLARED relationship field (`fieldConfig?.type === 'relationship'`)
|
|
10
|
-
* as something to recurse into — a synthetic key has no declared field on the
|
|
11
|
-
* list it's fetched through, so it fell to the generic non-relationship
|
|
12
|
-
* branch and was copied into the result verbatim: no field-level `read` gate
|
|
13
|
-
* on the related rows, and no virtual field computed on them.
|
|
14
|
-
*/
|
|
15
|
-
// A relationship field pointing at another list.
|
|
16
|
-
function rel(ref, many = false) {
|
|
17
|
-
return { type: 'relationship', ref, many };
|
|
18
|
-
}
|
|
19
|
-
// A virtual field computed via resolveOutput.
|
|
20
|
-
function virtualField(resolveOutput) {
|
|
21
|
-
return {
|
|
22
|
-
type: 'virtual',
|
|
23
|
-
virtual: true,
|
|
24
|
-
hooks: { resolveOutput },
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal field config for unit test
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function makeContext() {
|
|
29
|
-
return {
|
|
30
|
-
session: null,
|
|
31
|
-
_isSudo: false,
|
|
32
|
-
_resolveOutputChain: [],
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal context for unit test
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
// Term ← Bill.term (list-only ref, no field on Term) — schema generation
|
|
37
|
-
// synthesizes `from_Bill_term` on Term, which no list config declares.
|
|
38
|
-
function syntheticConfig() {
|
|
39
|
-
return {
|
|
40
|
-
db: { provider: 'sqlite' },
|
|
41
|
-
lists: {
|
|
42
|
-
Term: {
|
|
43
|
-
fields: { name: { type: 'text' } },
|
|
44
|
-
access: { operation: { query: () => true } },
|
|
45
|
-
},
|
|
46
|
-
Bill: {
|
|
47
|
-
fields: {
|
|
48
|
-
amount: { type: 'integer' },
|
|
49
|
-
term: rel('Term'),
|
|
50
|
-
internalNotes: {
|
|
51
|
-
type: 'text',
|
|
52
|
-
access: { read: () => false },
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal field config for unit test
|
|
54
|
-
},
|
|
55
|
-
label: virtualField(({ item }) => `Bill #${item.amount}`),
|
|
56
|
-
},
|
|
57
|
-
access: { operation: { query: () => true } },
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
describe('filterReadableFields — synthetic back-relation (#1082)', () => {
|
|
64
|
-
it('applies the owning list field-level read access to rows fetched through a synthetic key', async () => {
|
|
65
|
-
const config = syntheticConfig();
|
|
66
|
-
const termRow = {
|
|
67
|
-
id: 't1',
|
|
68
|
-
name: 'Term 1',
|
|
69
|
-
from_Bill_term: [{ id: 'b1', amount: 5, internalNotes: 'secret' }],
|
|
70
|
-
};
|
|
71
|
-
const result = await filterReadableFields(termRow, config.lists.Term.fields, { session: null, context: makeContext() }, config, 0, 'Term');
|
|
72
|
-
const bills = result.from_Bill_term;
|
|
73
|
-
expect(bills).toHaveLength(1);
|
|
74
|
-
expect(bills[0].amount).toBe(5);
|
|
75
|
-
expect('internalNotes' in bills[0]).toBe(false);
|
|
76
|
-
});
|
|
77
|
-
it('computes a virtual field on rows fetched through a synthetic key', async () => {
|
|
78
|
-
const config = syntheticConfig();
|
|
79
|
-
const termRow = {
|
|
80
|
-
id: 't1',
|
|
81
|
-
name: 'Term 1',
|
|
82
|
-
from_Bill_term: [{ id: 'b1', amount: 5 }],
|
|
83
|
-
};
|
|
84
|
-
const result = await filterReadableFields(termRow, config.lists.Term.fields, { session: null, context: makeContext() }, config, 0, 'Term');
|
|
85
|
-
const bills = result.from_Bill_term;
|
|
86
|
-
expect(bills[0].label).toBe('Bill #5');
|
|
87
|
-
});
|
|
88
|
-
it('recurses through a to-one value fetched through a synthetic key the same as a to-many', async () => {
|
|
89
|
-
const config = syntheticConfig();
|
|
90
|
-
const termRow = {
|
|
91
|
-
id: 't1',
|
|
92
|
-
name: 'Term 1',
|
|
93
|
-
from_Bill_term: { id: 'b1', amount: 5, internalNotes: 'secret' },
|
|
94
|
-
};
|
|
95
|
-
const result = await filterReadableFields(termRow, config.lists.Term.fields, { session: null, context: makeContext() }, config, 0, 'Term');
|
|
96
|
-
const bill = result.from_Bill_term;
|
|
97
|
-
expect(bill.amount).toBe(5);
|
|
98
|
-
expect(bill.label).toBe('Bill #5');
|
|
99
|
-
expect('internalNotes' in bill).toBe(false);
|
|
100
|
-
});
|
|
101
|
-
it('leaves a declared, non-relationship field on the row untouched by the synthetic path', async () => {
|
|
102
|
-
// `name` is a declared scalar field on Term itself — the synthetic
|
|
103
|
-
// fallback only ever applies to a key ABSENT from `fieldConfigs`, so it
|
|
104
|
-
// must never interfere with the list's own ordinary fields.
|
|
105
|
-
const config = syntheticConfig();
|
|
106
|
-
const termRow = { id: 't1', name: 'Term 1' };
|
|
107
|
-
const result = await filterReadableFields(termRow, config.lists.Term.fields, { session: null, context: makeContext() }, config, 0, 'Term');
|
|
108
|
-
expect(result).toEqual({ id: 't1', name: 'Term 1' });
|
|
109
|
-
});
|
|
110
|
-
it('leaves an undeclared, non-synthetic key untouched (no config supplied)', async () => {
|
|
111
|
-
// Mirrors the pre-#1082 narrow-unit-test contract: without `config`
|
|
112
|
-
// there is nothing to resolve a synthetic key against, so the field
|
|
113
|
-
// passes through as a plain value — the same fallback
|
|
114
|
-
// `filterWritableFields` documents for its own `config`-less callers.
|
|
115
|
-
const config = syntheticConfig();
|
|
116
|
-
const termRow = { id: 't1', name: 'Term 1', from_Bill_term: [{ id: 'b1', amount: 5 }] };
|
|
117
|
-
const result = await filterReadableFields(termRow, config.lists.Term.fields, { session: null, context: makeContext() }, undefined, 0, 'Term');
|
|
118
|
-
expect(result.from_Bill_term).toEqual([{ id: 'b1', amount: 5 }]);
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
//# sourceMappingURL=synthetic-include-read.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"synthetic-include-read.test.js","sourceRoot":"","sources":["../../src/access/synthetic-include-read.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAI5D;;;;;;;;;;;GAWG;AAEH,iDAAiD;AACjD,SAAS,GAAG,CAAC,GAAW,EAAE,IAAI,GAAG,KAAK;IACpC,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,IAAI,EAA4B,CAAA;AACtE,CAAC;AAED,8CAA8C;AAC9C,SAAS,YAAY,CACnB,aAAmE;IAEnE,OAAO;QACL,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,IAAI;QACb,KAAK,EAAE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