@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,635 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, expectTypeOf } from 'vitest';
|
|
2
|
-
import { checkFieldAccess, filterWritableFields, isFieldReadableForPredicate, } from './field-access.js';
|
|
3
|
-
import { InvalidFieldAccessResultError } from './errors.js';
|
|
4
|
-
import { ValidationError } from '../hooks/index.js';
|
|
5
|
-
// A non-sudo access context. The cast is localized to test setup (mirrors the
|
|
6
|
-
// existing sudo-context casts in this file): the runtime AccessContext carries
|
|
7
|
-
// Prisma plumbing the unit under test never touches.
|
|
8
|
-
function nonSudoContext() {
|
|
9
|
-
return {
|
|
10
|
-
session: null,
|
|
11
|
-
_isSudo: false,
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function sudoContext() {
|
|
16
|
-
return {
|
|
17
|
-
session: null,
|
|
18
|
-
_isSudo: true,
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
// ── #914: `FieldAccess['read']`'s `item` must type as present, matching what
|
|
23
|
-
// Field Visibility (field-visibility.ts) actually passes ──
|
|
24
|
-
describe("FieldAccess['read'] item typing (issue #914)", () => {
|
|
25
|
-
it('types item as present for a read rule that reads a property off it — no cast, no `any`', () => {
|
|
26
|
-
const fieldAccess = {
|
|
27
|
-
read: ({ session, item }) => item.ownerId === session?.userId,
|
|
28
|
-
};
|
|
29
|
-
expect(typeof fieldAccess.read).toBe('function');
|
|
30
|
-
});
|
|
31
|
-
it('still compiles a read rule that ignores item entirely', () => {
|
|
32
|
-
const fieldAccess = {
|
|
33
|
-
read: () => true,
|
|
34
|
-
};
|
|
35
|
-
expect(typeof fieldAccess.read).toBe('function');
|
|
36
|
-
});
|
|
37
|
-
it('leaves the create branch unchanged — item is still absent, there genuinely is no row yet', () => {
|
|
38
|
-
expectTypeOf().toEqualTypeOf();
|
|
39
|
-
});
|
|
40
|
-
// Type-level pin: `resolveReadableFieldValue` (field-visibility.ts) is the
|
|
41
|
-
// sole caller of `checkFieldAccess` for `operation: 'read'`, and always
|
|
42
|
-
// supplies `item: accessItem` — a full row, never `undefined`. This
|
|
43
|
-
// assertion has no runtime effect (`expectTypeOf` is a no-op outside
|
|
44
|
-
// `vitest --typecheck`); its value is that `pnpm build`/`tsc` fails on this
|
|
45
|
-
// file the moment `FieldAccess['read']`'s `item` type drifts back to
|
|
46
|
-
// optional/absent, so the declared type and the call site cannot silently
|
|
47
|
-
// diverge again.
|
|
48
|
-
it("pins FieldAccess['read']'s item type against the field-visibility.ts call site", () => {
|
|
49
|
-
expectTypeOf().toEqualTypeOf();
|
|
50
|
-
expectTypeOf().toEqualTypeOf();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
// ── #913: a field rule returning a filter must not be granted blanket access ──
|
|
54
|
-
describe('checkFieldAccess', () => {
|
|
55
|
-
it('allows when the rule returns true', async () => {
|
|
56
|
-
const allowed = await checkFieldAccess({ read: () => true }, 'read', {
|
|
57
|
-
session: null,
|
|
58
|
-
item: { ownerId: 'someone-else' },
|
|
59
|
-
context: nonSudoContext(),
|
|
60
|
-
});
|
|
61
|
-
expect(allowed).toBe(true);
|
|
62
|
-
});
|
|
63
|
-
it('denies when the rule returns false', async () => {
|
|
64
|
-
const allowed = await checkFieldAccess({ read: () => false }, 'read', {
|
|
65
|
-
session: null,
|
|
66
|
-
item: { ownerId: 'someone-else' },
|
|
67
|
-
context: nonSudoContext(),
|
|
68
|
-
});
|
|
69
|
-
expect(allowed).toBe(false);
|
|
70
|
-
});
|
|
71
|
-
it('allows when no field access is configured', async () => {
|
|
72
|
-
const allowed = await checkFieldAccess(undefined, 'read', {
|
|
73
|
-
session: null,
|
|
74
|
-
context: nonSudoContext(),
|
|
75
|
-
});
|
|
76
|
-
expect(allowed).toBe(true);
|
|
77
|
-
});
|
|
78
|
-
it('allows when no rule is configured for the operation', async () => {
|
|
79
|
-
const allowed = await checkFieldAccess({ update: () => false }, 'read', {
|
|
80
|
-
session: null,
|
|
81
|
-
context: nonSudoContext(),
|
|
82
|
-
});
|
|
83
|
-
expect(allowed).toBe(true);
|
|
84
|
-
});
|
|
85
|
-
it('throws InvalidFieldAccessResultError, not allow, when a read rule returns a filter', async () => {
|
|
86
|
-
// The exact reproduction from the issue: a rule written to scope a field
|
|
87
|
-
// by row, which the previous fail-open default granted full access to.
|
|
88
|
-
const fieldAccess = {
|
|
89
|
-
read: () => ({ ownerId: { equals: 'someone-else' } }),
|
|
90
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
-
};
|
|
92
|
-
await expect(checkFieldAccess(fieldAccess, 'read', {
|
|
93
|
-
session: null,
|
|
94
|
-
item: { ownerId: 'the-owner' },
|
|
95
|
-
context: nonSudoContext(),
|
|
96
|
-
})).rejects.toThrow(InvalidFieldAccessResultError);
|
|
97
|
-
});
|
|
98
|
-
it('throws for a filter-returning rule on create, where there is no item to test it against', async () => {
|
|
99
|
-
const fieldAccess = {
|
|
100
|
-
create: () => ({ ownerId: { equals: 'someone-else' } }),
|
|
101
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
|
-
};
|
|
103
|
-
await expect(checkFieldAccess(fieldAccess, 'create', {
|
|
104
|
-
session: null,
|
|
105
|
-
context: nonSudoContext(),
|
|
106
|
-
inputData: { ownerId: 'the-owner' },
|
|
107
|
-
})).rejects.toThrow(InvalidFieldAccessResultError);
|
|
108
|
-
});
|
|
109
|
-
it('throws for a filter-returning rule on update', async () => {
|
|
110
|
-
const fieldAccess = {
|
|
111
|
-
update: () => ({ ownerId: { equals: 'someone-else' } }),
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
-
};
|
|
114
|
-
await expect(checkFieldAccess(fieldAccess, 'update', {
|
|
115
|
-
session: null,
|
|
116
|
-
item: { ownerId: 'the-owner' },
|
|
117
|
-
context: nonSudoContext(),
|
|
118
|
-
inputData: { ownerId: 'someone-else' },
|
|
119
|
-
})).rejects.toThrow(InvalidFieldAccessResultError);
|
|
120
|
-
});
|
|
121
|
-
it('throws for a non-boolean, non-filter result too (e.g. undefined)', async () => {
|
|
122
|
-
const fieldAccess = {
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
124
|
-
read: () => undefined,
|
|
125
|
-
};
|
|
126
|
-
await expect(checkFieldAccess(fieldAccess, 'read', {
|
|
127
|
-
session: null,
|
|
128
|
-
item: {},
|
|
129
|
-
context: nonSudoContext(),
|
|
130
|
-
})).rejects.toThrow(InvalidFieldAccessResultError);
|
|
131
|
-
});
|
|
132
|
-
it('throws with a descriptive message for null, and for other primitive results', async () => {
|
|
133
|
-
const nullAccess = {
|
|
134
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
135
|
-
read: () => null,
|
|
136
|
-
};
|
|
137
|
-
await expect(checkFieldAccess(nullAccess, 'read', {
|
|
138
|
-
session: null,
|
|
139
|
-
item: {},
|
|
140
|
-
context: nonSudoContext(),
|
|
141
|
-
})).rejects.toThrow(/returned null, not a boolean/);
|
|
142
|
-
const numberAccess = {
|
|
143
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
144
|
-
read: () => 42,
|
|
145
|
-
};
|
|
146
|
-
await expect(checkFieldAccess(numberAccess, 'read', {
|
|
147
|
-
session: null,
|
|
148
|
-
item: {},
|
|
149
|
-
context: nonSudoContext(),
|
|
150
|
-
})).rejects.toThrow(/returned a number, not a boolean/);
|
|
151
|
-
});
|
|
152
|
-
it('sudo bypasses the rule entirely, so a filter-returning rule never reaches the throw', async () => {
|
|
153
|
-
const fieldAccess = {
|
|
154
|
-
read: () => ({ ownerId: { equals: 'someone-else' } }),
|
|
155
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
156
|
-
};
|
|
157
|
-
const allowed = await checkFieldAccess(fieldAccess, 'read', {
|
|
158
|
-
session: null,
|
|
159
|
-
item: { ownerId: 'the-owner' },
|
|
160
|
-
context: sudoContext(),
|
|
161
|
-
});
|
|
162
|
-
expect(allowed).toBe(true);
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
describe('isFieldReadableForPredicate (#915)', () => {
|
|
166
|
-
it('allows when there is no field access configured', async () => {
|
|
167
|
-
const readable = await isFieldReadableForPredicate(undefined, {
|
|
168
|
-
session: null,
|
|
169
|
-
context: nonSudoContext(),
|
|
170
|
-
});
|
|
171
|
-
expect(readable).toBe(true);
|
|
172
|
-
});
|
|
173
|
-
it('allows when the rule only inspects session (never touches item)', async () => {
|
|
174
|
-
const readable = await isFieldReadableForPredicate({ read: ({ session }) => session?.userId === 'admin' }, { session: { userId: 'admin' }, context: nonSudoContext() });
|
|
175
|
-
expect(readable).toBe(true);
|
|
176
|
-
});
|
|
177
|
-
it('denies when the rule returns false', async () => {
|
|
178
|
-
const readable = await isFieldReadableForPredicate({ read: () => false }, { session: null, context: nonSudoContext() });
|
|
179
|
-
expect(readable).toBe(false);
|
|
180
|
-
});
|
|
181
|
-
it('denies a row-dependent rule that dereferences `item` directly', async () => {
|
|
182
|
-
const readable = await isFieldReadableForPredicate({ read: ({ item, session }) => item.ownerId === session?.userId }, { session: { userId: 'user-1' }, context: nonSudoContext() });
|
|
183
|
-
expect(readable).toBe(false);
|
|
184
|
-
});
|
|
185
|
-
it('denies a row-dependent rule even when it reads `item` via optional chaining', async () => {
|
|
186
|
-
// This is the exact idiom `InvalidFieldAccessResultError`'s own message
|
|
187
|
-
// recommends (`item?.ownerId === session?.userId`) — it must still deny,
|
|
188
|
-
// not silently misevaluate `undefined === session?.userId` against a
|
|
189
|
-
// poisoned `item`.
|
|
190
|
-
const readable = await isFieldReadableForPredicate({ read: ({ item, session }) => item?.ownerId === session?.userId }, { session: null, context: nonSudoContext() });
|
|
191
|
-
expect(readable).toBe(false);
|
|
192
|
-
});
|
|
193
|
-
it('denies a row-dependent rule that only enumerates `item`s keys', async () => {
|
|
194
|
-
const readable = await isFieldReadableForPredicate(
|
|
195
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
196
|
-
{ read: ({ item }) => Object.keys(item).length > 0 }, { session: null, context: nonSudoContext() });
|
|
197
|
-
expect(readable).toBe(false);
|
|
198
|
-
});
|
|
199
|
-
it('propagates InvalidFieldAccessResultError instead of folding it into a denial', async () => {
|
|
200
|
-
const fieldAccess = {
|
|
201
|
-
read: () => ({ ownerId: { equals: 'someone-else' } }),
|
|
202
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
203
|
-
};
|
|
204
|
-
await expect(isFieldReadableForPredicate(fieldAccess, { session: null, context: nonSudoContext() })).rejects.toThrow(InvalidFieldAccessResultError);
|
|
205
|
-
});
|
|
206
|
-
it('propagates a genuine error the rule throws for its own reasons, not just non-boolean results', async () => {
|
|
207
|
-
// The rule never touches `item` — it throws for a reason of its own.
|
|
208
|
-
// This must NOT be folded into an ordinary `false` denial (that would
|
|
209
|
-
// mask a real bug in the rule as "field not readable"), matching how the
|
|
210
|
-
// post-query path (`filterReadableFields`) already lets such a throw
|
|
211
|
-
// propagate unchanged.
|
|
212
|
-
const fieldAccess = {
|
|
213
|
-
read: ({ session }) => {
|
|
214
|
-
if (session === null)
|
|
215
|
-
throw new Error('unexpected anonymous access');
|
|
216
|
-
return true;
|
|
217
|
-
},
|
|
218
|
-
};
|
|
219
|
-
await expect(isFieldReadableForPredicate(fieldAccess, { session: null, context: nonSudoContext() })).rejects.toThrow('unexpected anonymous access');
|
|
220
|
-
});
|
|
221
|
-
it('sudo bypasses the rule entirely, so a row-dependent rule never denies', async () => {
|
|
222
|
-
const readable = await isFieldReadableForPredicate({ read: ({ item, session }) => item.ownerId === session?.userId }, { session: null, context: sudoContext() });
|
|
223
|
-
expect(readable).toBe(true);
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
describe('filterWritableFields', () => {
|
|
227
|
-
it('should filter out foreign key fields when their corresponding relationship field exists', async () => {
|
|
228
|
-
// Setup: Define field configs with a relationship field
|
|
229
|
-
const fieldConfigs = {
|
|
230
|
-
title: {
|
|
231
|
-
type: 'text',
|
|
232
|
-
},
|
|
233
|
-
author: {
|
|
234
|
-
type: 'relationship',
|
|
235
|
-
many: false,
|
|
236
|
-
},
|
|
237
|
-
tags: {
|
|
238
|
-
type: 'relationship',
|
|
239
|
-
many: true, // Many-to-many relationships don't have foreign keys
|
|
240
|
-
},
|
|
241
|
-
};
|
|
242
|
-
// Data that includes both the foreign key (authorId) and other fields
|
|
243
|
-
const data = {
|
|
244
|
-
title: 'Test Post',
|
|
245
|
-
authorId: 'user-123', // This should be filtered out
|
|
246
|
-
tagsId: 'tag-456', // This should NOT be filtered (tags is many:true)
|
|
247
|
-
author: {
|
|
248
|
-
connect: { id: 'user-123' },
|
|
249
|
-
},
|
|
250
|
-
};
|
|
251
|
-
const filtered = await filterWritableFields(data, fieldConfigs, 'create', {
|
|
252
|
-
session: null,
|
|
253
|
-
context: {
|
|
254
|
-
session: null,
|
|
255
|
-
_isSudo: true, // Use sudo to bypass access control checks
|
|
256
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
257
|
-
},
|
|
258
|
-
inputData: data,
|
|
259
|
-
});
|
|
260
|
-
// authorId should be filtered out
|
|
261
|
-
expect(filtered).not.toHaveProperty('authorId');
|
|
262
|
-
// title should remain
|
|
263
|
-
expect(filtered).toHaveProperty('title', 'Test Post');
|
|
264
|
-
// author relationship should remain
|
|
265
|
-
expect(filtered).toHaveProperty('author');
|
|
266
|
-
expect(filtered.author).toEqual({ connect: { id: 'user-123' } });
|
|
267
|
-
// tagsId should remain (tags is many:true, so no foreign key is created)
|
|
268
|
-
expect(filtered).toHaveProperty('tagsId', 'tag-456');
|
|
269
|
-
});
|
|
270
|
-
it('should filter out system fields', async () => {
|
|
271
|
-
const fieldConfigs = {
|
|
272
|
-
title: { type: 'text' },
|
|
273
|
-
};
|
|
274
|
-
const data = {
|
|
275
|
-
id: 'post-123',
|
|
276
|
-
title: 'Test',
|
|
277
|
-
createdAt: new Date(),
|
|
278
|
-
updatedAt: new Date(),
|
|
279
|
-
};
|
|
280
|
-
const filtered = await filterWritableFields(data, fieldConfigs, 'create', {
|
|
281
|
-
session: null,
|
|
282
|
-
context: {
|
|
283
|
-
session: null,
|
|
284
|
-
_isSudo: true,
|
|
285
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
286
|
-
},
|
|
287
|
-
inputData: data,
|
|
288
|
-
});
|
|
289
|
-
// System fields should be filtered out
|
|
290
|
-
expect(filtered).not.toHaveProperty('id');
|
|
291
|
-
expect(filtered).not.toHaveProperty('createdAt');
|
|
292
|
-
expect(filtered).not.toHaveProperty('updatedAt');
|
|
293
|
-
// Regular fields should remain
|
|
294
|
-
expect(filtered).toHaveProperty('title', 'Test');
|
|
295
|
-
});
|
|
296
|
-
it('should handle update operation', async () => {
|
|
297
|
-
const fieldConfigs = {
|
|
298
|
-
title: { type: 'text' },
|
|
299
|
-
author: {
|
|
300
|
-
type: 'relationship',
|
|
301
|
-
many: false,
|
|
302
|
-
},
|
|
303
|
-
};
|
|
304
|
-
const data = {
|
|
305
|
-
title: 'Updated Title',
|
|
306
|
-
authorId: 'user-456', // Should be filtered out
|
|
307
|
-
author: {
|
|
308
|
-
connect: { id: 'user-456' },
|
|
309
|
-
},
|
|
310
|
-
};
|
|
311
|
-
const filtered = await filterWritableFields(data, fieldConfigs, 'update', {
|
|
312
|
-
session: null,
|
|
313
|
-
item: { id: 'post-123' },
|
|
314
|
-
context: {
|
|
315
|
-
session: null,
|
|
316
|
-
_isSudo: true,
|
|
317
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
318
|
-
},
|
|
319
|
-
inputData: data,
|
|
320
|
-
});
|
|
321
|
-
expect(filtered).not.toHaveProperty('authorId');
|
|
322
|
-
expect(filtered).toHaveProperty('title', 'Updated Title');
|
|
323
|
-
expect(filtered).toHaveProperty('author');
|
|
324
|
-
});
|
|
325
|
-
it('should not filter fields that happen to end with "Id" but are not foreign keys', async () => {
|
|
326
|
-
const fieldConfigs = {
|
|
327
|
-
trackingId: { type: 'text' }, // Regular field that happens to end with "Id"
|
|
328
|
-
author: {
|
|
329
|
-
type: 'relationship',
|
|
330
|
-
many: false,
|
|
331
|
-
},
|
|
332
|
-
};
|
|
333
|
-
const data = {
|
|
334
|
-
trackingId: 'track-123', // Should NOT be filtered (it's a regular field)
|
|
335
|
-
authorId: 'user-456', // SHOULD be filtered (it's a foreign key)
|
|
336
|
-
};
|
|
337
|
-
const filtered = await filterWritableFields(data, fieldConfigs, 'create', {
|
|
338
|
-
session: null,
|
|
339
|
-
context: {
|
|
340
|
-
session: null,
|
|
341
|
-
_isSudo: true,
|
|
342
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
343
|
-
},
|
|
344
|
-
inputData: data,
|
|
345
|
-
});
|
|
346
|
-
// trackingId is a defined field, so it should remain
|
|
347
|
-
expect(filtered).toHaveProperty('trackingId', 'track-123');
|
|
348
|
-
// authorId is a foreign key for author relationship, so it should be filtered
|
|
349
|
-
expect(filtered).not.toHaveProperty('authorId');
|
|
350
|
-
});
|
|
351
|
-
// ── #564: undeclared data keys must fail CLOSED (throw) for non-sudo writes ──
|
|
352
|
-
it('throws on an undeclared data key for a non-sudo create', async () => {
|
|
353
|
-
const fieldConfigs = { title: { type: 'text' } };
|
|
354
|
-
const data = {
|
|
355
|
-
title: 'Test',
|
|
356
|
-
// Not a declared field — e.g. a Prisma back-relation the config never
|
|
357
|
-
// exposed (`from_Enrolment_student`). Must be rejected, not passed through.
|
|
358
|
-
from_Enrolment_student: { disconnect: [{ id: 'e1' }] },
|
|
359
|
-
};
|
|
360
|
-
await expect(filterWritableFields(data, fieldConfigs, 'create', {
|
|
361
|
-
session: null,
|
|
362
|
-
context: nonSudoContext(),
|
|
363
|
-
inputData: data,
|
|
364
|
-
})).rejects.toThrow(ValidationError);
|
|
365
|
-
await expect(filterWritableFields(data, fieldConfigs, 'create', {
|
|
366
|
-
session: null,
|
|
367
|
-
context: nonSudoContext(),
|
|
368
|
-
inputData: data,
|
|
369
|
-
})).rejects.toThrow(/from_Enrolment_student/);
|
|
370
|
-
});
|
|
371
|
-
it('throws on an undeclared data key for a non-sudo update', async () => {
|
|
372
|
-
const fieldConfigs = { title: { type: 'text' } };
|
|
373
|
-
const data = {
|
|
374
|
-
title: 'Updated',
|
|
375
|
-
bogusKey: 'value',
|
|
376
|
-
};
|
|
377
|
-
await expect(filterWritableFields(data, fieldConfigs, 'update', {
|
|
378
|
-
session: null,
|
|
379
|
-
item: { id: 'post-1' },
|
|
380
|
-
context: nonSudoContext(),
|
|
381
|
-
inputData: data,
|
|
382
|
-
})).rejects.toThrow(/bogusKey/);
|
|
383
|
-
});
|
|
384
|
-
it('passes undeclared data keys through under sudo (the single trusted bypass)', async () => {
|
|
385
|
-
const fieldConfigs = { title: { type: 'text' } };
|
|
386
|
-
const data = {
|
|
387
|
-
title: 'Test',
|
|
388
|
-
from_Enrolment_student: { disconnect: [{ id: 'e1' }] },
|
|
389
|
-
};
|
|
390
|
-
const filtered = await filterWritableFields(data, fieldConfigs, 'create', {
|
|
391
|
-
session: null,
|
|
392
|
-
context: sudoContext(),
|
|
393
|
-
inputData: data,
|
|
394
|
-
});
|
|
395
|
-
expect(filtered).toHaveProperty('title', 'Test');
|
|
396
|
-
expect(filtered).toHaveProperty('from_Enrolment_student');
|
|
397
|
-
});
|
|
398
|
-
it('still skips system fields and relationship FK fields cleanly for a non-sudo write', async () => {
|
|
399
|
-
const fieldConfigs = {
|
|
400
|
-
title: { type: 'text' },
|
|
401
|
-
author: { type: 'relationship', many: false },
|
|
402
|
-
};
|
|
403
|
-
const data = {
|
|
404
|
-
id: 'post-1',
|
|
405
|
-
createdAt: new Date(),
|
|
406
|
-
updatedAt: new Date(),
|
|
407
|
-
title: 'Test',
|
|
408
|
-
authorId: 'user-1', // FK skipped, not rejected
|
|
409
|
-
};
|
|
410
|
-
const filtered = await filterWritableFields(data, fieldConfigs, 'create', {
|
|
411
|
-
session: null,
|
|
412
|
-
context: nonSudoContext(),
|
|
413
|
-
inputData: data,
|
|
414
|
-
});
|
|
415
|
-
expect(filtered).not.toHaveProperty('id');
|
|
416
|
-
expect(filtered).not.toHaveProperty('createdAt');
|
|
417
|
-
expect(filtered).not.toHaveProperty('updatedAt');
|
|
418
|
-
expect(filtered).not.toHaveProperty('authorId');
|
|
419
|
-
expect(filtered).toHaveProperty('title', 'Test');
|
|
420
|
-
});
|
|
421
|
-
it('passes through raw per-part columns from a multi-column field whose write access ALLOWS (non-sudo)', async () => {
|
|
422
|
-
// Multi-column fields inject raw columns (e.g. m_url/m_size) that are not
|
|
423
|
-
// declared in fieldConfigs; they must not trip the undeclared-key reject.
|
|
424
|
-
// With no field-level access (allow), they pass through.
|
|
425
|
-
const fieldConfigs = {
|
|
426
|
-
media: {
|
|
427
|
-
type: 'image',
|
|
428
|
-
getColumnNames: (fieldName) => [`${fieldName}_url`, `${fieldName}_size`],
|
|
429
|
-
},
|
|
430
|
-
};
|
|
431
|
-
const data = {
|
|
432
|
-
media_url: 'https://x/y.jpg',
|
|
433
|
-
media_size: 99,
|
|
434
|
-
};
|
|
435
|
-
const filtered = await filterWritableFields(data, fieldConfigs, 'create', {
|
|
436
|
-
session: null,
|
|
437
|
-
context: nonSudoContext(),
|
|
438
|
-
inputData: data,
|
|
439
|
-
});
|
|
440
|
-
expect(filtered).toHaveProperty('media_url', 'https://x/y.jpg');
|
|
441
|
-
expect(filtered).toHaveProperty('media_size', 99);
|
|
442
|
-
});
|
|
443
|
-
it('THROWS when raw split columns are supplied for a field whose write access is DENIED (non-sudo)', async () => {
|
|
444
|
-
// Security (#568): a non-sudo caller who supplies the raw per-part columns
|
|
445
|
-
// DIRECTLY must not bypass the owning field's write-access gate. The
|
|
446
|
-
// logical-key gate in the hooks layer never fires here (no `media` key), so
|
|
447
|
-
// this filter is the only enforcement point — it must throw.
|
|
448
|
-
const fieldConfigs = {
|
|
449
|
-
media: {
|
|
450
|
-
type: 'image',
|
|
451
|
-
access: { create: () => false, update: () => false },
|
|
452
|
-
getColumnNames: (fieldName) => [`${fieldName}_url`, `${fieldName}_size`],
|
|
453
|
-
},
|
|
454
|
-
};
|
|
455
|
-
const data = {
|
|
456
|
-
media_url: 'https://evil/x.jpg',
|
|
457
|
-
media_size: 1,
|
|
458
|
-
};
|
|
459
|
-
// Throws ValidationError, and the message names the owning field.
|
|
460
|
-
await expect(filterWritableFields(data, fieldConfigs, 'create', {
|
|
461
|
-
session: null,
|
|
462
|
-
context: nonSudoContext(),
|
|
463
|
-
inputData: data,
|
|
464
|
-
})).rejects.toThrow(ValidationError);
|
|
465
|
-
await expect(filterWritableFields(data, fieldConfigs, 'update', {
|
|
466
|
-
session: null,
|
|
467
|
-
item: { id: 'item-1' },
|
|
468
|
-
context: nonSudoContext(),
|
|
469
|
-
inputData: data,
|
|
470
|
-
})).rejects.toThrow(/media/);
|
|
471
|
-
});
|
|
472
|
-
it('passes raw split columns through under sudo regardless of denied owning-field access', async () => {
|
|
473
|
-
// sudo is the single trusted bypass; `checkFieldAccess` returns true under
|
|
474
|
-
// sudo, so even a would-be-denied multi-column field passes through.
|
|
475
|
-
const fieldConfigs = {
|
|
476
|
-
media: {
|
|
477
|
-
type: 'image',
|
|
478
|
-
access: { create: () => false, update: () => false },
|
|
479
|
-
getColumnNames: (fieldName) => [`${fieldName}_url`, `${fieldName}_size`],
|
|
480
|
-
},
|
|
481
|
-
};
|
|
482
|
-
const data = {
|
|
483
|
-
media_url: 'https://x/y.jpg',
|
|
484
|
-
media_size: 99,
|
|
485
|
-
};
|
|
486
|
-
const filtered = await filterWritableFields(data, fieldConfigs, 'create', {
|
|
487
|
-
session: null,
|
|
488
|
-
context: sudoContext(),
|
|
489
|
-
inputData: data,
|
|
490
|
-
});
|
|
491
|
-
expect(filtered).toHaveProperty('media_url', 'https://x/y.jpg');
|
|
492
|
-
expect(filtered).toHaveProperty('media_size', 99);
|
|
493
|
-
});
|
|
494
|
-
// ── #568: field-access-denied keys must THROW, not be silently stripped ──────
|
|
495
|
-
it('throws when a declared field is denied by field-level access (non-sudo)', async () => {
|
|
496
|
-
const fieldConfigs = {
|
|
497
|
-
title: { type: 'text' },
|
|
498
|
-
status: {
|
|
499
|
-
type: 'text',
|
|
500
|
-
access: { update: () => false, create: () => false },
|
|
501
|
-
},
|
|
502
|
-
};
|
|
503
|
-
const data = { title: 'Test', status: 'published' };
|
|
504
|
-
await expect(filterWritableFields(data, fieldConfigs, 'update', {
|
|
505
|
-
session: null,
|
|
506
|
-
item: { id: 'post-1' },
|
|
507
|
-
context: nonSudoContext(),
|
|
508
|
-
inputData: data,
|
|
509
|
-
})).rejects.toThrow(/status/);
|
|
510
|
-
});
|
|
511
|
-
// ── #913: a field rule returning a filter must not grant blanket write access ──
|
|
512
|
-
it('throws InvalidFieldAccessResultError, not a blanket write, when field access returns a filter (non-sudo)', async () => {
|
|
513
|
-
const fieldConfigs = {
|
|
514
|
-
title: { type: 'text' },
|
|
515
|
-
status: {
|
|
516
|
-
type: 'text',
|
|
517
|
-
access: {
|
|
518
|
-
// Written as a row-scoping rule; field access does not honour filters.
|
|
519
|
-
update: () => ({ status: { equals: 'draft' } }),
|
|
520
|
-
create: () => ({ status: { equals: 'draft' } }),
|
|
521
|
-
},
|
|
522
|
-
},
|
|
523
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
524
|
-
};
|
|
525
|
-
const data = { title: 'Test', status: 'published' };
|
|
526
|
-
await expect(filterWritableFields(data, fieldConfigs, 'update', {
|
|
527
|
-
session: null,
|
|
528
|
-
item: { id: 'post-1', status: 'draft' },
|
|
529
|
-
context: nonSudoContext(),
|
|
530
|
-
inputData: data,
|
|
531
|
-
})).rejects.toThrow(InvalidFieldAccessResultError);
|
|
532
|
-
});
|
|
533
|
-
it('does NOT throw on a would-be-denied field under sudo', async () => {
|
|
534
|
-
const fieldConfigs = {
|
|
535
|
-
title: { type: 'text' },
|
|
536
|
-
status: {
|
|
537
|
-
type: 'text',
|
|
538
|
-
access: { update: () => false, create: () => false },
|
|
539
|
-
},
|
|
540
|
-
};
|
|
541
|
-
const data = { title: 'Test', status: 'published' };
|
|
542
|
-
const filtered = await filterWritableFields(data, fieldConfigs, 'update', {
|
|
543
|
-
session: null,
|
|
544
|
-
item: { id: 'post-1' },
|
|
545
|
-
context: sudoContext(),
|
|
546
|
-
inputData: data,
|
|
547
|
-
});
|
|
548
|
-
expect(filtered).toHaveProperty('title', 'Test');
|
|
549
|
-
expect(filtered).toHaveProperty('status', 'published');
|
|
550
|
-
});
|
|
551
|
-
it('passes a declared relationship field through to nested operations (non-sudo)', async () => {
|
|
552
|
-
const fieldConfigs = {
|
|
553
|
-
title: { type: 'text' },
|
|
554
|
-
author: { type: 'relationship', many: false },
|
|
555
|
-
};
|
|
556
|
-
const data = {
|
|
557
|
-
title: 'Test',
|
|
558
|
-
author: { connect: { id: 'user-1' } },
|
|
559
|
-
};
|
|
560
|
-
const filtered = await filterWritableFields(data, fieldConfigs, 'create', {
|
|
561
|
-
session: null,
|
|
562
|
-
context: nonSudoContext(),
|
|
563
|
-
inputData: data,
|
|
564
|
-
});
|
|
565
|
-
expect(filtered).toHaveProperty('author');
|
|
566
|
-
expect(filtered.author).toEqual({ connect: { id: 'user-1' } });
|
|
567
|
-
});
|
|
568
|
-
});
|
|
569
|
-
// ── #978: under sudo, only a synthetic reverse-relation key is a recognised
|
|
570
|
-
// undeclared key — anything else is refused, even under sudo ──────────────
|
|
571
|
-
describe('filterWritableFields — #978 tightened sudo undeclared-key guard', () => {
|
|
572
|
-
// A minimal config: Account is the target of ChargeRequest's list-only ref
|
|
573
|
-
// (`ref: 'Account'`, no field named on Account), so the generator
|
|
574
|
-
// synthesizes `from_ChargeRequest_account` on Account.
|
|
575
|
-
const config = {
|
|
576
|
-
db: { provider: 'sqlite', url: 'file:./dev.db' },
|
|
577
|
-
lists: {
|
|
578
|
-
Account: { fields: { name: { type: 'text' } } },
|
|
579
|
-
ChargeRequest: {
|
|
580
|
-
fields: {
|
|
581
|
-
kind: { type: 'text' },
|
|
582
|
-
account: { type: 'relationship', ref: 'Account' },
|
|
583
|
-
},
|
|
584
|
-
},
|
|
585
|
-
},
|
|
586
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
587
|
-
};
|
|
588
|
-
it('passes a synthetic reverse-relation key through under sudo, when config/listName are supplied', async () => {
|
|
589
|
-
const fieldConfigs = { name: { type: 'text' } };
|
|
590
|
-
const data = {
|
|
591
|
-
name: 'Acme',
|
|
592
|
-
from_ChargeRequest_account: { create: { kind: 'DEPOSIT' } },
|
|
593
|
-
};
|
|
594
|
-
const filtered = await filterWritableFields(data, fieldConfigs, 'update', {
|
|
595
|
-
session: null,
|
|
596
|
-
item: { id: 'a1' },
|
|
597
|
-
context: sudoContext(),
|
|
598
|
-
inputData: data,
|
|
599
|
-
listName: 'Account',
|
|
600
|
-
config,
|
|
601
|
-
});
|
|
602
|
-
expect(filtered).toHaveProperty('name', 'Acme');
|
|
603
|
-
expect(filtered).toHaveProperty('from_ChargeRequest_account');
|
|
604
|
-
});
|
|
605
|
-
it('throws on a genuinely unknown key under sudo, when config/listName are supplied', async () => {
|
|
606
|
-
const fieldConfigs = { name: { type: 'text' } };
|
|
607
|
-
const data = {
|
|
608
|
-
name: 'Acme',
|
|
609
|
-
totallyBogusKey: 'value',
|
|
610
|
-
};
|
|
611
|
-
await expect(filterWritableFields(data, fieldConfigs, 'update', {
|
|
612
|
-
session: null,
|
|
613
|
-
item: { id: 'a1' },
|
|
614
|
-
context: sudoContext(),
|
|
615
|
-
inputData: data,
|
|
616
|
-
listName: 'Account',
|
|
617
|
-
config,
|
|
618
|
-
})).rejects.toThrow(/totallyBogusKey/);
|
|
619
|
-
});
|
|
620
|
-
it('keeps the pre-#978 blanket sudo passthrough when config/listName are omitted', async () => {
|
|
621
|
-
// Pins the fallback direct unit tests above (e.g. "passes undeclared data
|
|
622
|
-
// keys through under sudo") rely on: with no config to resolve a synthetic
|
|
623
|
-
// key against, any undeclared key still passes through under sudo.
|
|
624
|
-
const fieldConfigs = { name: { type: 'text' } };
|
|
625
|
-
const data = { name: 'Acme', totallyBogusKey: 'value' };
|
|
626
|
-
const filtered = await filterWritableFields(data, fieldConfigs, 'update', {
|
|
627
|
-
session: null,
|
|
628
|
-
item: { id: 'a1' },
|
|
629
|
-
context: sudoContext(),
|
|
630
|
-
inputData: data,
|
|
631
|
-
});
|
|
632
|
-
expect(filtered).toHaveProperty('totallyBogusKey', 'value');
|
|
633
|
-
});
|
|
634
|
-
});
|
|
635
|
-
//# sourceMappingURL=field-access.test.js.map
|