@opensaas/stack-core 0.42.3 → 0.44.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2745 -0
- package/README.md +182 -115
- package/dist/.build-hash +1 -0
- package/dist/access/declared-dependencies.d.ts +102 -88
- package/dist/access/declared-dependencies.d.ts.map +1 -1
- package/dist/access/declared-dependencies.js +83 -71
- package/dist/access/declared-dependencies.js.map +1 -1
- package/dist/access/depth-limits.d.ts +4 -0
- package/dist/access/depth-limits.d.ts.map +1 -1
- package/dist/access/depth-limits.js +4 -0
- package/dist/access/depth-limits.js.map +1 -1
- package/dist/access/engine.d.ts +68 -20
- package/dist/access/engine.d.ts.map +1 -1
- package/dist/access/engine.js +151 -37
- package/dist/access/engine.js.map +1 -1
- package/dist/access/errors.d.ts +33 -48
- package/dist/access/errors.d.ts.map +1 -1
- package/dist/access/errors.js +73 -63
- package/dist/access/errors.js.map +1 -1
- package/dist/access/field-access.d.ts +76 -5
- package/dist/access/field-access.d.ts.map +1 -1
- package/dist/access/field-access.js +235 -61
- package/dist/access/field-access.js.map +1 -1
- package/dist/access/field-visibility.d.ts +50 -4
- package/dist/access/field-visibility.d.ts.map +1 -1
- package/dist/access/field-visibility.js +143 -160
- package/dist/access/field-visibility.js.map +1 -1
- package/dist/access/index.d.ts +5 -12
- package/dist/access/index.d.ts.map +1 -1
- package/dist/access/index.js +6 -19
- package/dist/access/index.js.map +1 -1
- package/dist/access/orm-client.d.ts +19 -0
- package/dist/access/orm-client.d.ts.map +1 -0
- package/dist/access/orm-client.js +37 -0
- package/dist/access/orm-client.js.map +1 -0
- package/dist/access/query-validation.d.ts +7 -129
- package/dist/access/query-validation.d.ts.map +1 -1
- package/dist/access/query-validation.js +12 -314
- package/dist/access/query-validation.js.map +1 -1
- package/dist/access/system-fields.d.ts +2 -0
- package/dist/access/system-fields.d.ts.map +1 -0
- package/dist/access/system-fields.js +7 -0
- package/dist/access/system-fields.js.map +1 -0
- package/dist/access/transaction-registry.d.ts +25 -2
- package/dist/access/transaction-registry.d.ts.map +1 -1
- package/dist/access/transaction-registry.js +34 -17
- package/dist/access/transaction-registry.js.map +1 -1
- package/dist/access/types.d.ts +217 -131
- package/dist/access/types.d.ts.map +1 -1
- package/dist/config/field-kind.d.ts +66 -0
- package/dist/config/field-kind.d.ts.map +1 -0
- package/dist/config/field-kind.js +63 -0
- package/dist/config/field-kind.js.map +1 -0
- package/dist/config/hook-only-fields.d.ts +3 -0
- package/dist/config/hook-only-fields.d.ts.map +1 -0
- package/dist/config/hook-only-fields.js +17 -0
- package/dist/config/hook-only-fields.js.map +1 -0
- package/dist/config/index.d.ts +3 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +6 -3
- package/dist/config/index.js.map +1 -1
- package/dist/config/mcp-tool-names.d.ts +3 -0
- package/dist/config/mcp-tool-names.d.ts.map +1 -0
- package/dist/config/mcp-tool-names.js +25 -0
- package/dist/config/mcp-tool-names.js.map +1 -0
- package/dist/config/nav-count.d.ts.map +1 -1
- package/dist/config/nav-count.js +4 -4
- package/dist/config/nav-count.js.map +1 -1
- package/dist/config/plugin-engine.d.ts +8 -2
- package/dist/config/plugin-engine.d.ts.map +1 -1
- package/dist/config/plugin-engine.js +102 -38
- package/dist/config/plugin-engine.js.map +1 -1
- package/dist/config/types.d.ts +966 -614
- package/dist/config/types.d.ts.map +1 -1
- package/dist/context/apply-defaults.d.ts +18 -1
- package/dist/context/apply-defaults.d.ts.map +1 -1
- package/dist/context/apply-defaults.js +30 -4
- package/dist/context/apply-defaults.js.map +1 -1
- package/dist/context/engine-context.d.ts +73 -0
- package/dist/context/engine-context.d.ts.map +1 -0
- package/dist/context/engine-context.js +67 -0
- package/dist/context/engine-context.js.map +1 -0
- package/dist/context/hook-pipeline.d.ts +9 -2
- package/dist/context/hook-pipeline.d.ts.map +1 -1
- package/dist/context/hook-pipeline.js +5 -4
- package/dist/context/hook-pipeline.js.map +1 -1
- package/dist/context/index.d.ts +98 -89
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +917 -722
- package/dist/context/index.js.map +1 -1
- package/dist/context/junction.d.ts +59 -0
- package/dist/context/junction.d.ts.map +1 -0
- package/dist/context/junction.js +126 -0
- package/dist/context/junction.js.map +1 -0
- package/dist/context/plugin-field-read.d.ts +33 -0
- package/dist/context/plugin-field-read.d.ts.map +1 -0
- package/dist/context/plugin-field-read.js +41 -0
- package/dist/context/plugin-field-read.js.map +1 -0
- package/dist/context/plugin-field-write.d.ts +104 -0
- package/dist/context/plugin-field-write.d.ts.map +1 -0
- package/dist/context/plugin-field-write.js +184 -0
- package/dist/context/plugin-field-write.js.map +1 -0
- package/dist/context/relationship-input.d.ts +146 -0
- package/dist/context/relationship-input.d.ts.map +1 -0
- package/dist/context/relationship-input.js +453 -0
- package/dist/context/relationship-input.js.map +1 -0
- package/dist/context/transaction-boundary.d.ts +54 -28
- package/dist/context/transaction-boundary.d.ts.map +1 -1
- package/dist/context/transaction-boundary.js +87 -169
- package/dist/context/transaction-boundary.js.map +1 -1
- package/dist/context/write-pipeline.d.ts +33 -51
- package/dist/context/write-pipeline.d.ts.map +1 -1
- package/dist/context/write-pipeline.js +372 -185
- package/dist/context/write-pipeline.js.map +1 -1
- package/dist/contract/dependencies.d.ts +88 -0
- package/dist/contract/dependencies.d.ts.map +1 -0
- package/dist/contract/dependencies.js +237 -0
- package/dist/contract/dependencies.js.map +1 -0
- package/dist/contract/derive.d.ts +49 -0
- package/dist/contract/derive.d.ts.map +1 -0
- package/dist/contract/derive.js +540 -0
- package/dist/contract/derive.js.map +1 -0
- package/dist/contract/fixtures/contract-configs.d.ts +64 -0
- package/dist/contract/fixtures/contract-configs.d.ts.map +1 -0
- package/dist/contract/fixtures/contract-configs.js +345 -0
- package/dist/contract/fixtures/contract-configs.js.map +1 -0
- package/dist/contract/id-boundary.d.ts +53 -0
- package/dist/contract/id-boundary.d.ts.map +1 -0
- package/dist/contract/id-boundary.js +76 -0
- package/dist/contract/id-boundary.js.map +1 -0
- package/dist/contract/index.d.ts +8 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +11 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/prisma.d.ts +58 -0
- package/dist/contract/prisma.d.ts.map +1 -0
- package/dist/contract/prisma.js +282 -0
- package/dist/contract/prisma.js.map +1 -0
- package/dist/contract/relation-graph.d.ts +70 -0
- package/dist/contract/relation-graph.d.ts.map +1 -0
- package/dist/contract/relation-graph.js +113 -0
- package/dist/contract/relation-graph.js.map +1 -0
- package/dist/contract/types.d.ts +135 -0
- package/dist/contract/types.d.ts.map +1 -0
- package/dist/contract/types.js +2 -0
- package/dist/contract/types.js.map +1 -0
- package/dist/db/client.d.ts +55 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +73 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/dev-database.d.ts +124 -0
- package/dist/db/dev-database.d.ts.map +1 -0
- package/dist/db/dev-database.js +291 -0
- package/dist/db/dev-database.js.map +1 -0
- package/dist/db/password-front.d.ts +10 -0
- package/dist/db/password-front.d.ts.map +1 -0
- package/dist/db/password-front.js +147 -0
- package/dist/db/password-front.js.map +1 -0
- package/dist/db/process-identity.d.ts +36 -0
- package/dist/db/process-identity.d.ts.map +1 -0
- package/dist/db/process-identity.js +114 -0
- package/dist/db/process-identity.js.map +1 -0
- package/dist/db/state-file.d.ts +54 -0
- package/dist/db/state-file.d.ts.map +1 -0
- package/dist/db/state-file.js +91 -0
- package/dist/db/state-file.js.map +1 -0
- package/dist/db/url.d.ts +89 -0
- package/dist/db/url.d.ts.map +1 -0
- package/dist/db/url.js +118 -0
- package/dist/db/url.js.map +1 -0
- package/dist/extend.d.ts +13 -2
- package/dist/extend.d.ts.map +1 -1
- package/dist/extend.js +24 -1
- package/dist/extend.js.map +1 -1
- package/dist/fields/index.d.ts +87 -42
- package/dist/fields/index.d.ts.map +1 -1
- package/dist/fields/index.js +457 -677
- package/dist/fields/index.js.map +1 -1
- package/dist/filter/collect.d.ts +3 -4
- package/dist/filter/collect.d.ts.map +1 -1
- package/dist/filter/collect.js +2 -2
- package/dist/filter/collect.js.map +1 -1
- package/dist/filter/index.d.ts +1 -2
- package/dist/filter/index.d.ts.map +1 -1
- package/dist/filter/index.js +0 -1
- package/dist/filter/index.js.map +1 -1
- package/dist/filter/map.d.ts +12 -5
- package/dist/filter/map.d.ts.map +1 -1
- package/dist/filter/map.js +47 -19
- package/dist/filter/map.js.map +1 -1
- package/dist/filter/types.d.ts +10 -24
- package/dist/filter/types.d.ts.map +1 -1
- package/dist/filter/types.js +2 -11
- package/dist/filter/types.js.map +1 -1
- package/dist/hooks/index.d.ts +22 -31
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +33 -37
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/transition-guard.d.ts +61 -0
- package/dist/hooks/transition-guard.d.ts.map +1 -0
- package/dist/hooks/transition-guard.js +93 -0
- package/dist/hooks/transition-guard.js.map +1 -0
- package/dist/index.d.ts +52 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +105 -44
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +4 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +16 -0
- package/dist/internal.js.map +1 -1
- package/dist/lib/case-utils.d.ts +0 -1
- package/dist/lib/case-utils.d.ts.map +1 -1
- package/dist/lib/case-utils.js +0 -3
- package/dist/lib/case-utils.js.map +1 -1
- package/dist/lib/client-safe-error.d.ts +9 -0
- package/dist/lib/client-safe-error.d.ts.map +1 -0
- package/dist/lib/client-safe-error.js +23 -0
- package/dist/lib/client-safe-error.js.map +1 -0
- package/dist/lib/database-errors.d.ts +78 -0
- package/dist/lib/database-errors.d.ts.map +1 -0
- package/dist/lib/database-errors.js +148 -0
- package/dist/lib/database-errors.js.map +1 -0
- package/dist/lib/null-prototype-registry.d.ts +9 -0
- package/dist/lib/null-prototype-registry.d.ts.map +1 -0
- package/dist/lib/null-prototype-registry.js +11 -0
- package/dist/lib/null-prototype-registry.js.map +1 -0
- package/dist/lib/prisma-errors.d.ts +30 -32
- package/dist/lib/prisma-errors.d.ts.map +1 -1
- package/dist/lib/prisma-errors.js +86 -46
- package/dist/lib/prisma-errors.js.map +1 -1
- package/dist/lib/process-global.d.ts +23 -0
- package/dist/lib/process-global.d.ts.map +1 -0
- package/dist/lib/process-global.js +33 -0
- package/dist/lib/process-global.js.map +1 -0
- package/dist/lib/warn-once.d.ts +7 -0
- package/dist/lib/warn-once.d.ts.map +1 -0
- package/dist/lib/warn-once.js +13 -0
- package/dist/lib/warn-once.js.map +1 -0
- package/dist/mcp/advertise.d.ts +16 -0
- package/dist/mcp/advertise.d.ts.map +1 -0
- package/dist/mcp/advertise.js +25 -0
- package/dist/mcp/advertise.js.map +1 -0
- package/dist/mcp/arguments.d.ts +10 -0
- package/dist/mcp/arguments.d.ts.map +1 -0
- package/dist/mcp/arguments.js +143 -0
- package/dist/mcp/arguments.js.map +1 -0
- package/dist/mcp/field-schema.d.ts +50 -5
- package/dist/mcp/field-schema.d.ts.map +1 -1
- package/dist/mcp/field-schema.js +137 -14
- package/dist/mcp/field-schema.js.map +1 -1
- package/dist/mcp/handler.d.ts +16 -5
- package/dist/mcp/handler.d.ts.map +1 -1
- package/dist/mcp/handler.js +404 -126
- package/dist/mcp/handler.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/projection.d.ts +42 -34
- package/dist/mcp/projection.d.ts.map +1 -1
- package/dist/mcp/projection.js +246 -200
- package/dist/mcp/projection.js.map +1 -1
- package/dist/mcp/tool-error.d.ts +8 -0
- package/dist/mcp/tool-error.d.ts.map +1 -0
- package/dist/mcp/tool-error.js +11 -0
- package/dist/mcp/tool-error.js.map +1 -0
- package/dist/mcp/types.d.ts +3 -2
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/where-id-boundary.d.ts +28 -0
- package/dist/mcp/where-id-boundary.d.ts.map +1 -0
- package/dist/mcp/where-id-boundary.js +187 -0
- package/dist/mcp/where-id-boundary.js.map +1 -0
- package/dist/origin.d.ts +147 -0
- package/dist/origin.d.ts.map +1 -0
- package/dist/origin.js +191 -0
- package/dist/origin.js.map +1 -0
- package/dist/query/relationship-options.d.ts +35 -6
- package/dist/query/relationship-options.d.ts.map +1 -1
- package/dist/query/relationship-options.js +33 -23
- package/dist/query/relationship-options.js.map +1 -1
- package/dist/secured/aggregate.d.ts +32 -0
- package/dist/secured/aggregate.d.ts.map +1 -0
- package/dist/secured/aggregate.js +31 -0
- package/dist/secured/aggregate.js.map +1 -0
- package/dist/secured/include.d.ts +320 -0
- package/dist/secured/include.d.ts.map +1 -0
- package/dist/secured/include.js +650 -0
- package/dist/secured/include.js.map +1 -0
- package/dist/secured/lock.d.ts +127 -0
- package/dist/secured/lock.d.ts.map +1 -0
- package/dist/secured/lock.js +275 -0
- package/dist/secured/lock.js.map +1 -0
- package/dist/secured/lower.d.ts +82 -0
- package/dist/secured/lower.d.ts.map +1 -0
- package/dist/secured/lower.js +162 -0
- package/dist/secured/lower.js.map +1 -0
- package/dist/secured/operators.d.ts +7 -0
- package/dist/secured/operators.d.ts.map +1 -0
- package/dist/secured/operators.js +18 -0
- package/dist/secured/operators.js.map +1 -0
- package/dist/secured/read.d.ts +208 -0
- package/dist/secured/read.d.ts.map +1 -0
- package/dist/secured/read.js +1245 -0
- package/dist/secured/read.js.map +1 -0
- package/dist/secured/select.d.ts +87 -0
- package/dist/secured/select.d.ts.map +1 -0
- package/dist/secured/select.js +250 -0
- package/dist/secured/select.js.map +1 -0
- package/dist/secured/vector.d.ts +58 -0
- package/dist/secured/vector.d.ts.map +1 -0
- package/dist/secured/vector.js +113 -0
- package/dist/secured/vector.js.map +1 -0
- package/dist/secured/vocabulary.d.ts +227 -0
- package/dist/secured/vocabulary.d.ts.map +1 -0
- package/dist/secured/vocabulary.js +578 -0
- package/dist/secured/vocabulary.js.map +1 -0
- package/dist/secured/write.d.ts +58 -0
- package/dist/secured/write.d.ts.map +1 -0
- package/dist/secured/write.js +87 -0
- package/dist/secured/write.js.map +1 -0
- package/dist/testing/context.d.ts +236 -0
- package/dist/testing/context.d.ts.map +1 -0
- package/dist/testing/context.js +457 -0
- package/dist/testing/context.js.map +1 -0
- package/dist/testing/escape.d.ts +83 -0
- package/dist/testing/escape.d.ts.map +1 -0
- package/dist/testing/escape.js +148 -0
- package/dist/testing/escape.js.map +1 -0
- package/dist/testing/extensions.d.ts +48 -0
- package/dist/testing/extensions.d.ts.map +1 -0
- package/dist/testing/extensions.js +107 -0
- package/dist/testing/extensions.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +11 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/plans.d.ts +64 -0
- package/dist/testing/plans.d.ts.map +1 -0
- package/dist/testing/plans.js +47 -0
- package/dist/testing/plans.js.map +1 -0
- package/dist/types/context.d.ts +110 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +2 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/contract.d.ts +198 -0
- package/dist/types/contract.d.ts.map +1 -0
- package/dist/types/contract.js +2 -0
- package/dist/types/contract.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/inputs.d.ts +83 -0
- package/dist/types/inputs.d.ts.map +1 -0
- package/dist/types/inputs.js +2 -0
- package/dist/types/inputs.js.map +1 -0
- package/dist/types/rows.d.ts +76 -0
- package/dist/types/rows.d.ts.map +1 -0
- package/dist/types/rows.js +2 -0
- package/dist/types/rows.js.map +1 -0
- package/dist/types/secured-list.d.ts +396 -0
- package/dist/types/secured-list.d.ts.map +1 -0
- package/dist/types/secured-list.js +2 -0
- package/dist/types/secured-list.js.map +1 -0
- package/dist/unsafe.d.ts +162 -0
- package/dist/unsafe.d.ts.map +1 -0
- package/dist/unsafe.js +177 -0
- package/dist/unsafe.js.map +1 -0
- package/dist/validation/config-refusal.d.ts +16 -0
- package/dist/validation/config-refusal.d.ts.map +1 -0
- package/dist/validation/config-refusal.js +2 -0
- package/dist/validation/config-refusal.js.map +1 -0
- package/dist/validation/database-config.d.ts +19 -0
- package/dist/validation/database-config.d.ts.map +1 -0
- package/dist/validation/database-config.js +221 -0
- package/dist/validation/database-config.js.map +1 -0
- package/dist/validation/default-value.d.ts +21 -0
- package/dist/validation/default-value.d.ts.map +1 -0
- package/dist/validation/default-value.js +72 -0
- package/dist/validation/default-value.js.map +1 -0
- package/dist/validation/extension-packs.d.ts +11 -0
- package/dist/validation/extension-packs.d.ts.map +1 -0
- package/dist/validation/extension-packs.js +53 -0
- package/dist/validation/extension-packs.js.map +1 -0
- package/dist/validation/field-config.d.ts +35 -21
- package/dist/validation/field-config.d.ts.map +1 -1
- package/dist/validation/field-config.js +51 -41
- package/dist/validation/field-config.js.map +1 -1
- package/dist/validation/field-names.d.ts +15 -0
- package/dist/validation/field-names.d.ts.map +1 -0
- package/dist/validation/field-names.js +155 -0
- package/dist/validation/field-names.js.map +1 -0
- package/dist/validation/identifier-names.d.ts +4 -0
- package/dist/validation/identifier-names.d.ts.map +1 -0
- package/dist/validation/identifier-names.js +39 -0
- package/dist/validation/identifier-names.js.map +1 -0
- package/dist/validation/needs-closure.d.ts +20 -30
- package/dist/validation/needs-closure.d.ts.map +1 -1
- package/dist/validation/needs-closure.js +29 -105
- package/dist/validation/needs-closure.js.map +1 -1
- package/dist/validation/relations.d.ts +17 -0
- package/dist/validation/relations.d.ts.map +1 -0
- package/dist/validation/relations.js +268 -0
- package/dist/validation/relations.js.map +1 -0
- package/dist/validation/schema.d.ts.map +1 -1
- package/dist/validation/schema.js +1 -3
- package/dist/validation/schema.js.map +1 -1
- package/dist/where/like.d.ts +32 -0
- package/dist/where/like.d.ts.map +1 -0
- package/dist/where/like.js +42 -0
- package/dist/where/like.js.map +1 -0
- package/package.json +70 -8
- package/.turbo/turbo-build.log +0 -4
- package/CLAUDE.md +0 -609
- package/dist/access/access-filter.d.ts +0 -241
- package/dist/access/access-filter.d.ts.map +0 -1
- package/dist/access/access-filter.js +0 -692
- package/dist/access/access-filter.js.map +0 -1
- package/dist/access/access-filter.test.d.ts +0 -2
- package/dist/access/access-filter.test.d.ts.map +0 -1
- package/dist/access/access-filter.test.js +0 -1256
- package/dist/access/access-filter.test.js.map +0 -1
- package/dist/access/declared-dependencies.test.d.ts +0 -2
- package/dist/access/declared-dependencies.test.d.ts.map +0 -1
- package/dist/access/declared-dependencies.test.js +0 -226
- package/dist/access/declared-dependencies.test.js.map +0 -1
- package/dist/access/denied-relation-visibility.test.d.ts +0 -2
- package/dist/access/denied-relation-visibility.test.d.ts.map +0 -1
- package/dist/access/denied-relation-visibility.test.js +0 -114
- package/dist/access/denied-relation-visibility.test.js.map +0 -1
- package/dist/access/engine.test.d.ts +0 -2
- package/dist/access/engine.test.d.ts.map +0 -1
- package/dist/access/engine.test.js +0 -56
- package/dist/access/engine.test.js.map +0 -1
- package/dist/access/field-access.test.d.ts +0 -2
- package/dist/access/field-access.test.d.ts.map +0 -1
- package/dist/access/field-access.test.js +0 -635
- package/dist/access/field-access.test.js.map +0 -1
- package/dist/access/multi-column-read-write.test.d.ts +0 -2
- package/dist/access/multi-column-read-write.test.d.ts.map +0 -1
- package/dist/access/multi-column-read-write.test.js +0 -183
- package/dist/access/multi-column-read-write.test.js.map +0 -1
- package/dist/access/relationship-count.d.ts +0 -98
- package/dist/access/relationship-count.d.ts.map +0 -1
- package/dist/access/relationship-count.js +0 -262
- package/dist/access/relationship-count.js.map +0 -1
- package/dist/access/relationship-count.test.d.ts +0 -2
- package/dist/access/relationship-count.test.d.ts.map +0 -1
- package/dist/access/relationship-count.test.js +0 -247
- package/dist/access/relationship-count.test.js.map +0 -1
- package/dist/access/relationship-label-filter.d.ts +0 -45
- package/dist/access/relationship-label-filter.d.ts.map +0 -1
- package/dist/access/relationship-label-filter.js +0 -22
- package/dist/access/relationship-label-filter.js.map +0 -1
- package/dist/access/relationship-label-filter.test.d.ts +0 -2
- package/dist/access/relationship-label-filter.test.d.ts.map +0 -1
- package/dist/access/relationship-label-filter.test.js +0 -89
- package/dist/access/relationship-label-filter.test.js.map +0 -1
- package/dist/access/synthetic-include-read.test.d.ts +0 -2
- package/dist/access/synthetic-include-read.test.d.ts.map +0 -1
- package/dist/access/synthetic-include-read.test.js +0 -121
- package/dist/access/synthetic-include-read.test.js.map +0 -1
- package/dist/context/nested-operations.d.ts +0 -47
- package/dist/context/nested-operations.d.ts.map +0 -1
- package/dist/context/nested-operations.js +0 -731
- package/dist/context/nested-operations.js.map +0 -1
- package/dist/fields/calendar-day.test.d.ts +0 -2
- package/dist/fields/calendar-day.test.d.ts.map +0 -1
- package/dist/fields/calendar-day.test.js +0 -246
- package/dist/fields/calendar-day.test.js.map +0 -1
- package/dist/fields/format-prisma-default.d.ts +0 -35
- package/dist/fields/format-prisma-default.d.ts.map +0 -1
- package/dist/fields/format-prisma-default.js +0 -49
- package/dist/fields/format-prisma-default.js.map +0 -1
- package/dist/fields/format-prisma-default.test.d.ts +0 -2
- package/dist/fields/format-prisma-default.test.d.ts.map +0 -1
- package/dist/fields/format-prisma-default.test.js +0 -54
- package/dist/fields/format-prisma-default.test.js.map +0 -1
- package/dist/fields/relationship-foreign-key.test.d.ts +0 -2
- package/dist/fields/relationship-foreign-key.test.d.ts.map +0 -1
- package/dist/fields/relationship-foreign-key.test.js +0 -18
- package/dist/fields/relationship-foreign-key.test.js.map +0 -1
- package/dist/fields/select.test.d.ts +0 -2
- package/dist/fields/select.test.d.ts.map +0 -1
- package/dist/fields/select.test.js +0 -279
- package/dist/fields/select.test.js.map +0 -1
- package/dist/fields/text-keystone-compat.test.d.ts +0 -2
- package/dist/fields/text-keystone-compat.test.d.ts.map +0 -1
- package/dist/fields/text-keystone-compat.test.js +0 -93
- package/dist/fields/text-keystone-compat.test.js.map +0 -1
- package/dist/filter/filter.test.d.ts +0 -2
- package/dist/filter/filter.test.d.ts.map +0 -1
- package/dist/filter/filter.test.js +0 -431
- package/dist/filter/filter.test.js.map +0 -1
- package/dist/filter/serialize.test.d.ts +0 -2
- package/dist/filter/serialize.test.d.ts.map +0 -1
- package/dist/filter/serialize.test.js +0 -83
- package/dist/filter/serialize.test.js.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/dist/index.test.js +0 -33
- package/dist/index.test.js.map +0 -1
- package/dist/lib/case-utils.test.d.ts +0 -2
- package/dist/lib/case-utils.test.d.ts.map +0 -1
- package/dist/lib/case-utils.test.js +0 -123
- package/dist/lib/case-utils.test.js.map +0 -1
- package/dist/query/index.d.ts +0 -127
- package/dist/query/index.d.ts.map +0 -1
- package/dist/query/index.js +0 -179
- package/dist/query/index.js.map +0 -1
- package/dist/query/index.test.d.ts +0 -2
- package/dist/query/index.test.d.ts.map +0 -1
- package/dist/query/index.test.js +0 -632
- package/dist/query/index.test.js.map +0 -1
- package/dist/query/relationship-options.test.d.ts +0 -2
- package/dist/query/relationship-options.test.d.ts.map +0 -1
- package/dist/query/relationship-options.test.js +0 -150
- package/dist/query/relationship-options.test.js.map +0 -1
- package/dist/validation/field-config.test.d.ts +0 -2
- package/dist/validation/field-config.test.d.ts.map +0 -1
- package/dist/validation/field-config.test.js +0 -159
- package/dist/validation/field-config.test.js.map +0 -1
- package/dist/validation/schema.test.d.ts +0 -2
- package/dist/validation/schema.test.d.ts.map +0 -1
- package/dist/validation/schema.test.js +0 -409
- package/dist/validation/schema.test.js.map +0 -1
- package/docs/type-distribution-fix.md +0 -136
- package/src/access/access-filter.test.ts +0 -1919
- package/src/access/access-filter.ts +0 -1041
- package/src/access/declared-dependencies.test.ts +0 -277
- package/src/access/declared-dependencies.ts +0 -220
- package/src/access/denied-relation-visibility.test.ts +0 -173
- package/src/access/depth-limits.ts +0 -27
- package/src/access/engine.test.ts +0 -67
- package/src/access/engine.ts +0 -193
- package/src/access/errors.ts +0 -242
- package/src/access/field-access.test.ts +0 -792
- package/src/access/field-access.ts +0 -353
- package/src/access/field-transforms.ts +0 -68
- package/src/access/field-visibility.ts +0 -569
- package/src/access/index.ts +0 -82
- package/src/access/multi-column-read-write.test.ts +0 -305
- package/src/access/query-validation.ts +0 -486
- package/src/access/relationship-count.test.ts +0 -344
- package/src/access/relationship-count.ts +0 -346
- package/src/access/relationship-label-filter.test.ts +0 -128
- package/src/access/relationship-label-filter.ts +0 -63
- package/src/access/synthetic-include-read.test.ts +0 -179
- package/src/access/transaction-registry.ts +0 -58
- package/src/access/types.ts +0 -391
- package/src/config/index.ts +0 -177
- package/src/config/label.ts +0 -51
- package/src/config/nav-count.ts +0 -77
- package/src/config/plugin-engine.ts +0 -261
- package/src/config/types.ts +0 -3270
- package/src/context/apply-defaults.ts +0 -47
- package/src/context/hook-pipeline.ts +0 -137
- package/src/context/index.ts +0 -1737
- package/src/context/nested-operations.ts +0 -1325
- package/src/context/transaction-boundary.ts +0 -485
- package/src/context/write-pipeline.ts +0 -732
- package/src/extend.ts +0 -28
- package/src/fields/calendar-day.test.ts +0 -291
- package/src/fields/format-prisma-default.test.ts +0 -64
- package/src/fields/format-prisma-default.ts +0 -64
- package/src/fields/index.ts +0 -1901
- package/src/fields/relationship-foreign-key.test.ts +0 -29
- package/src/fields/select.test.ts +0 -336
- package/src/fields/text-keystone-compat.test.ts +0 -126
- package/src/filter/collect.ts +0 -108
- package/src/filter/filter.test.ts +0 -538
- package/src/filter/index.ts +0 -26
- package/src/filter/map.ts +0 -63
- package/src/filter/parse.ts +0 -99
- package/src/filter/serialize.test.ts +0 -115
- package/src/filter/serialize.ts +0 -73
- package/src/filter/types.ts +0 -120
- package/src/hooks/index.ts +0 -752
- package/src/index.test.ts +0 -50
- package/src/index.ts +0 -184
- package/src/internal.ts +0 -61
- package/src/lib/case-utils.test.ts +0 -159
- package/src/lib/case-utils.ts +0 -68
- package/src/lib/prisma-errors.ts +0 -86
- package/src/mcp/constants.ts +0 -24
- package/src/mcp/field-schema.ts +0 -84
- package/src/mcp/handler.ts +0 -633
- package/src/mcp/index.ts +0 -7
- package/src/mcp/projection.ts +0 -497
- package/src/mcp/types.ts +0 -18
- package/src/query/index.test.ts +0 -830
- package/src/query/index.ts +0 -352
- package/src/query/relationship-options.test.ts +0 -194
- package/src/query/relationship-options.ts +0 -78
- package/src/utils/password.ts +0 -80
- package/src/validation/field-config.test.ts +0 -199
- package/src/validation/field-config.ts +0 -139
- package/src/validation/needs-closure.ts +0 -188
- package/src/validation/schema.test.ts +0 -487
- package/src/validation/schema.ts +0 -51
- package/tests/access-relationships.test.ts +0 -646
- package/tests/access.test.ts +0 -590
- package/tests/apply-defaults.test.ts +0 -119
- package/tests/bare-read-scalars.test.ts +0 -147
- package/tests/computed-field-selective-evaluation.test.ts +0 -418
- package/tests/config.test.ts +0 -242
- package/tests/context.test.ts +0 -3141
- package/tests/default-value-create.test.ts +0 -299
- package/tests/field-hooks.test.ts +0 -410
- package/tests/field-types.test.ts +0 -1291
- package/tests/hook-context-secured.test.ts +0 -424
- package/tests/hook-pipeline.test.ts +0 -233
- package/tests/hooks.test.ts +0 -481
- package/tests/interactive-transaction.test.ts +0 -444
- package/tests/label.test.ts +0 -135
- package/tests/mcp-fields-projection-access.test.ts +0 -250
- package/tests/mcp-handler.test.ts +0 -1411
- package/tests/multi-column-validation-ordering.test.ts +0 -305
- package/tests/nav-count.test.ts +0 -189
- package/tests/needs-declared-dependencies.test.ts +0 -503
- package/tests/nested-access-and-hooks.test.ts +0 -2566
- package/tests/nested-operation-registry.test.ts +0 -231
- package/tests/nested-write-hooks.test.ts +0 -864
- package/tests/nested-write-synthetic-relation.test.ts +0 -437
- package/tests/password-type-distribution.test.ts +0 -154
- package/tests/password-types.test.ts +0 -174
- package/tests/password.test.ts +0 -263
- package/tests/plugin-engine.test.ts +0 -1155
- package/tests/prisma-errors.test.ts +0 -141
- package/tests/resolve-chain.test.ts +0 -411
- package/tests/singleton.test.ts +0 -421
- package/tests/sudo.test.ts +0 -676
- package/tests/to-one-include-access-filter.test.ts +0 -172
- package/tests/transaction-boundary-hooks.test.ts +0 -710
- package/tests/transaction-boundary-outermost.test.ts +0 -530
- package/tests/virtual-fields.test.ts +0 -421
- package/tests/with-session.test.ts +0 -243
- package/tests/write-pipeline.test.ts +0 -617
- package/tsconfig.json +0 -12
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -69
|
@@ -1,486 +0,0 @@
|
|
|
1
|
-
import type { ListConfig, OpenSaasConfig } from '../config/types.js'
|
|
2
|
-
import type { Session, AccessContext } from './types.js'
|
|
3
|
-
import { getRelatedListConfig } from './engine.js'
|
|
4
|
-
import { isFieldReadableForPredicate } from './field-access.js'
|
|
5
|
-
import { ValidationError } from '../hooks/index.js'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* #912 — read-path key validation.
|
|
9
|
-
*
|
|
10
|
-
* The write path settled #564: an undeclared key in `data` throws, because the
|
|
11
|
-
* generated Prisma model has strictly more fields than the config declares (most
|
|
12
|
-
* notably back-relations — Prisma emits one for every inbound foreign key, whether
|
|
13
|
-
* or not the list config declares the reverse relationship). Reads had no
|
|
14
|
-
* equivalent — a caller's `where`/`orderBy` reached Prisma unchanged, so an
|
|
15
|
-
* anonymous caller could filter or order by a relation the config never exposed.
|
|
16
|
-
*
|
|
17
|
-
* This module is the read-path counterpart: every key named in a caller's `where`
|
|
18
|
-
* or `orderBy` is resolved against the list config before the query runs. A key
|
|
19
|
-
* with no entry in the config throws, naming the list and the key. `sudo` is the
|
|
20
|
-
* single trusted bypass, mirroring the write path.
|
|
21
|
-
*
|
|
22
|
-
* Deliberately NOT walked: the access filter produced by the list's own `query`
|
|
23
|
-
* access control. That filter is trusted config authored by the same person who
|
|
24
|
-
* declares the fields — walking it would make this an access-control decision
|
|
25
|
-
* (that's #915/#916), not the key-existence seam this ticket establishes.
|
|
26
|
-
*
|
|
27
|
-
* `validateQueryFieldReadAccess` below is that access-control decision for
|
|
28
|
-
* #915: it re-walks `where`/`orderBy` (reusing `resolveQueryField`) and checks
|
|
29
|
-
* each resolved field's `read` access via the canonical evaluator, so a field
|
|
30
|
-
* the session cannot read cannot be named in a predicate either. It runs
|
|
31
|
-
* strictly after this module's key-existence check — an undeclared key is
|
|
32
|
-
* #912's rejection, not a field-access decision — and stays scoped to the
|
|
33
|
-
* CURRENT list, deliberately not recursing into a related list's fields
|
|
34
|
-
* nested inside a relation filter itself (that recursion is #916's job, not
|
|
35
|
-
* this module's — see below).
|
|
36
|
-
*
|
|
37
|
-
* #916 — the relation-filter counterpart — scopes a relation filter itself
|
|
38
|
-
* (`some`/`every`/`none`/`is`/`isNot`) by the RELATED list's own `query`
|
|
39
|
-
* access, folding it into the nested clause exactly like
|
|
40
|
-
* `buildAccessScopedInclude` folds it into `include` (`access-filter.ts`).
|
|
41
|
-
* It reuses this module's shape-recognition (`resolveQueryField`,
|
|
42
|
-
* `LOGICAL_OPERATORS`, `RELATION_QUANTIFIERS`, exported below) and calls
|
|
43
|
-
* `walkWhereReadAccess` once per hop — against the RELATED list's own
|
|
44
|
-
* config — for the field-read half of the same job this module's
|
|
45
|
-
* `validateQueryFieldReadAccess` already does for the CURRENT list. There is
|
|
46
|
-
* deliberately no second copy of either the shape-recognition or the
|
|
47
|
-
* field-read check: `access-filter.ts` supplies the RELATED list at each
|
|
48
|
-
* hop and calls back into the same primitives this module already owns.
|
|
49
|
-
*
|
|
50
|
-
* #1092 — `validateQueryKeys` is also the include-nested counterpart: a
|
|
51
|
-
* `where`/`orderBy` a caller nests inside an `include` entry gets the same
|
|
52
|
-
* #912 check, called by `buildAccessScopedInclude` against the RELATED list
|
|
53
|
-
* instead of the current one — no second key-existence walker for that
|
|
54
|
-
* position. `validateQueryFieldReadAccess` needs no equivalent call there:
|
|
55
|
-
* `checkKeyReadableOrThrow` already treats a key `resolveQueryField` cannot
|
|
56
|
-
* resolve as "already handled elsewhere" and skips it, which is exactly the
|
|
57
|
-
* synthetic-back-relation tolerance below needs — nothing to change. The one
|
|
58
|
-
* thing this position needs that the top-level `where`/`orderBy` never did:
|
|
59
|
-
* a key neither call resolves is tried against the optional
|
|
60
|
-
* `resolveSyntheticRelation` hook before being rejected, because a synthetic
|
|
61
|
-
* back-relation (#1082) is nameable in a nested predicate too. Every
|
|
62
|
-
* existing caller omits the hook, so top-level behavior is unchanged.
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
// Prisma's logical combinators for a WHERE clause — never field names.
|
|
66
|
-
export const LOGICAL_OPERATORS = new Set(['AND', 'OR', 'NOT'])
|
|
67
|
-
|
|
68
|
-
// Prisma's relation quantifiers. The value nested under one of these is itself a
|
|
69
|
-
// WHERE clause for the RELATED list, and is walked against that list's fields.
|
|
70
|
-
export const RELATION_QUANTIFIERS = new Set(['some', 'every', 'none', 'is', 'isNot'])
|
|
71
|
-
|
|
72
|
-
// Always present, never declared in a list's `fields` — the write path
|
|
73
|
-
// (`filterWritableFields`) excludes the same three names from `fieldConfigs`.
|
|
74
|
-
const SYSTEM_FIELDS = new Set(['id', 'createdAt', 'updatedAt'])
|
|
75
|
-
|
|
76
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- field configs are heterogeneous across field types
|
|
77
|
-
type FieldConfigMap = Record<string, any>
|
|
78
|
-
|
|
79
|
-
export interface ResolvedQueryField {
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- field configs are heterogeneous across field types
|
|
81
|
-
fieldConfig: any
|
|
82
|
-
isRelationship: boolean
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Where an unresolved key's nested predicate should recurse when it turns out
|
|
87
|
-
* to name a synthetic back-relation (#1082) rather than a declared field —
|
|
88
|
-
* the source list the back-relation stands for, NOT `getRelatedListConfig`'s
|
|
89
|
-
* target (a synthetic field carries no `ref` of its own to follow).
|
|
90
|
-
*/
|
|
91
|
-
export interface SyntheticRelationTarget {
|
|
92
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
|
|
93
|
-
listConfig: ListConfig<any>
|
|
94
|
-
listName: string
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export type ResolveSyntheticRelation = (
|
|
98
|
-
key: string,
|
|
99
|
-
listName: string,
|
|
100
|
-
) => SyntheticRelationTarget | null
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Resolve a `where`/`orderBy` key against a list's declared fields.
|
|
104
|
-
*
|
|
105
|
-
* A key is valid when it is:
|
|
106
|
-
* - a system field (`id`, `createdAt`, `updatedAt`) — always present, and never
|
|
107
|
-
* declared in `fields` (the write path excludes them from `fieldConfigs` the
|
|
108
|
-
* same way), or
|
|
109
|
-
* - a field declared directly in the list config, or
|
|
110
|
-
* - the foreign-key scalar a to-one `relationship` field implies (e.g. `authorId`
|
|
111
|
-
* for `author: relationship(...)`) — the config never names this column
|
|
112
|
-
* directly, but Prisma always generates it, and the write path
|
|
113
|
-
* (`filterWritableFields`) grants it the same pass, or
|
|
114
|
-
* - a raw per-part column a multi-column field's `splitColumns` contributes (e.g.
|
|
115
|
-
* storage `image()`/`file()` in Keystone-parity mode) — undeclared by design,
|
|
116
|
-
* mirroring the write path's `splitColumnOwners` allowance (#568/#789).
|
|
117
|
-
*
|
|
118
|
-
* Anything else — most importantly a Prisma-generated back-relation the config
|
|
119
|
-
* never declares — resolves to `undefined` and is rejected by the caller.
|
|
120
|
-
*/
|
|
121
|
-
export function resolveQueryField(
|
|
122
|
-
key: string,
|
|
123
|
-
fields: FieldConfigMap,
|
|
124
|
-
): ResolvedQueryField | undefined {
|
|
125
|
-
if (SYSTEM_FIELDS.has(key)) {
|
|
126
|
-
return { fieldConfig: undefined, isRelationship: false }
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const fieldConfig = fields[key]
|
|
130
|
-
if (fieldConfig) {
|
|
131
|
-
return { fieldConfig, isRelationship: fieldConfig.type === 'relationship' }
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (key.endsWith('Id')) {
|
|
135
|
-
const baseField = fields[key.slice(0, -2)]
|
|
136
|
-
if (baseField && baseField.type === 'relationship' && !baseField.many) {
|
|
137
|
-
return { fieldConfig: baseField, isRelationship: false }
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
for (const [ownerName, owner] of Object.entries(fields)) {
|
|
142
|
-
if (owner && typeof owner.getColumnNames === 'function') {
|
|
143
|
-
const columns: string[] = owner.getColumnNames(ownerName)
|
|
144
|
-
if (columns.includes(key)) {
|
|
145
|
-
return { fieldConfig: owner, isRelationship: false }
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return undefined
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function rejectUndeclaredKey(listName: string, key: string, kind: 'where' | 'orderBy'): never {
|
|
154
|
-
throw new ValidationError([
|
|
155
|
-
`Cannot query "${listName}" — "${key}" is not a field of this list. ` +
|
|
156
|
-
`Undeclared ${kind} keys are rejected (use sudo to bypass).`,
|
|
157
|
-
])
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function walkWhere(
|
|
161
|
-
where: unknown,
|
|
162
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
|
|
163
|
-
listConfig: ListConfig<any>,
|
|
164
|
-
listName: string,
|
|
165
|
-
config: OpenSaasConfig,
|
|
166
|
-
isSudo: boolean,
|
|
167
|
-
resolveSyntheticRelation?: ResolveSyntheticRelation,
|
|
168
|
-
): void {
|
|
169
|
-
if (where === null || typeof where !== 'object') return
|
|
170
|
-
|
|
171
|
-
if (Array.isArray(where)) {
|
|
172
|
-
for (const entry of where) {
|
|
173
|
-
walkWhere(entry, listConfig, listName, config, isSudo, resolveSyntheticRelation)
|
|
174
|
-
}
|
|
175
|
-
return
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
for (const [key, value] of Object.entries(where as Record<string, unknown>)) {
|
|
179
|
-
if (LOGICAL_OPERATORS.has(key)) {
|
|
180
|
-
walkWhere(value, listConfig, listName, config, isSudo, resolveSyntheticRelation)
|
|
181
|
-
continue
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const resolved = resolveQueryField(key, listConfig.fields)
|
|
185
|
-
if (!resolved) {
|
|
186
|
-
const synthetic = resolveSyntheticRelation?.(key, listName)
|
|
187
|
-
if (synthetic) {
|
|
188
|
-
// A synthetic back-relation is always to-many (#1082's own
|
|
189
|
-
// construction site has no arity branch), so its nested value takes
|
|
190
|
-
// the same two shapes a declared to-many relationship's filter does
|
|
191
|
-
// — walk it exactly like the resolved-relationship branch below,
|
|
192
|
-
// against the synthetic's source list instead of `getRelatedListConfig`.
|
|
193
|
-
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
194
|
-
const syntheticEntries = Object.entries(value as Record<string, unknown>)
|
|
195
|
-
const syntheticHasQuantifier = syntheticEntries.some(([k]) => RELATION_QUANTIFIERS.has(k))
|
|
196
|
-
if (syntheticHasQuantifier) {
|
|
197
|
-
for (const [quantifier, quantifierValue] of syntheticEntries) {
|
|
198
|
-
if (RELATION_QUANTIFIERS.has(quantifier)) {
|
|
199
|
-
walkWhere(
|
|
200
|
-
quantifierValue,
|
|
201
|
-
synthetic.listConfig,
|
|
202
|
-
synthetic.listName,
|
|
203
|
-
config,
|
|
204
|
-
isSudo,
|
|
205
|
-
resolveSyntheticRelation,
|
|
206
|
-
)
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
} else {
|
|
210
|
-
walkWhere(
|
|
211
|
-
value,
|
|
212
|
-
synthetic.listConfig,
|
|
213
|
-
synthetic.listName,
|
|
214
|
-
config,
|
|
215
|
-
isSudo,
|
|
216
|
-
resolveSyntheticRelation,
|
|
217
|
-
)
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
continue
|
|
221
|
-
}
|
|
222
|
-
if (isSudo) continue
|
|
223
|
-
rejectUndeclaredKey(listName, key, 'where')
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// Scalar field filters use Prisma's own operator vocabulary (`equals`,
|
|
227
|
-
// `contains`, `in`, …) and never nest another field name — trusted as-is,
|
|
228
|
-
// no further walk needed. Only a relationship field's filter nests a
|
|
229
|
-
// WHERE clause for another list.
|
|
230
|
-
if (
|
|
231
|
-
resolved.isRelationship &&
|
|
232
|
-
value !== null &&
|
|
233
|
-
typeof value === 'object' &&
|
|
234
|
-
!Array.isArray(value)
|
|
235
|
-
) {
|
|
236
|
-
const related = getRelatedListConfig(resolved.fieldConfig.ref, config)
|
|
237
|
-
if (!related) continue
|
|
238
|
-
|
|
239
|
-
const relationEntries = Object.entries(value as Record<string, unknown>)
|
|
240
|
-
const hasQuantifier = relationEntries.some(([k]) => RELATION_QUANTIFIERS.has(k))
|
|
241
|
-
|
|
242
|
-
if (hasQuantifier) {
|
|
243
|
-
// Wrapped form: `{ author: { is: {...} } }` / `{ posts: { some: {...} } }`.
|
|
244
|
-
// Only the quantifier's own value is a nested WHERE clause for the
|
|
245
|
-
// related list.
|
|
246
|
-
for (const [quantifier, quantifierValue] of relationEntries) {
|
|
247
|
-
if (RELATION_QUANTIFIERS.has(quantifier)) {
|
|
248
|
-
walkWhere(
|
|
249
|
-
quantifierValue,
|
|
250
|
-
related.listConfig,
|
|
251
|
-
related.listName,
|
|
252
|
-
config,
|
|
253
|
-
isSudo,
|
|
254
|
-
resolveSyntheticRelation,
|
|
255
|
-
)
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
} else {
|
|
259
|
-
// Direct-nesting form: Prisma's documented default for a to-one
|
|
260
|
-
// relation filter nests the related list's own fields with no `is`
|
|
261
|
-
// wrapper at all (`{ author: { email: { contains: '...' } } }`). The
|
|
262
|
-
// whole value object IS the nested WHERE clause here — walk it
|
|
263
|
-
// directly, or an undeclared key reached exactly this way (one hop
|
|
264
|
-
// through a to-one relation) would pass through unchecked.
|
|
265
|
-
walkWhere(
|
|
266
|
-
value,
|
|
267
|
-
related.listConfig,
|
|
268
|
-
related.listName,
|
|
269
|
-
config,
|
|
270
|
-
isSudo,
|
|
271
|
-
resolveSyntheticRelation,
|
|
272
|
-
)
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function walkOrderBy(
|
|
279
|
-
orderBy: unknown,
|
|
280
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
|
|
281
|
-
listConfig: ListConfig<any>,
|
|
282
|
-
listName: string,
|
|
283
|
-
config: OpenSaasConfig,
|
|
284
|
-
isSudo: boolean,
|
|
285
|
-
resolveSyntheticRelation?: ResolveSyntheticRelation,
|
|
286
|
-
): void {
|
|
287
|
-
if (orderBy === null || typeof orderBy !== 'object') return
|
|
288
|
-
|
|
289
|
-
if (Array.isArray(orderBy)) {
|
|
290
|
-
for (const entry of orderBy) {
|
|
291
|
-
walkOrderBy(entry, listConfig, listName, config, isSudo, resolveSyntheticRelation)
|
|
292
|
-
}
|
|
293
|
-
return
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
for (const [key, value] of Object.entries(orderBy as Record<string, unknown>)) {
|
|
297
|
-
const resolved = resolveQueryField(key, listConfig.fields)
|
|
298
|
-
if (!resolved) {
|
|
299
|
-
const synthetic = resolveSyntheticRelation?.(key, listName)
|
|
300
|
-
if (synthetic) {
|
|
301
|
-
// `{ relation: { _count: 'asc' } }` orders by an aggregate — no
|
|
302
|
-
// nested field name to resolve, matching the declared-relationship
|
|
303
|
-
// branch below.
|
|
304
|
-
if (
|
|
305
|
-
value !== null &&
|
|
306
|
-
typeof value === 'object' &&
|
|
307
|
-
!('_count' in (value as Record<string, unknown>))
|
|
308
|
-
) {
|
|
309
|
-
walkOrderBy(
|
|
310
|
-
value,
|
|
311
|
-
synthetic.listConfig,
|
|
312
|
-
synthetic.listName,
|
|
313
|
-
config,
|
|
314
|
-
isSudo,
|
|
315
|
-
resolveSyntheticRelation,
|
|
316
|
-
)
|
|
317
|
-
}
|
|
318
|
-
continue
|
|
319
|
-
}
|
|
320
|
-
if (isSudo) continue
|
|
321
|
-
rejectUndeclaredKey(listName, key, 'orderBy')
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (resolved.isRelationship && value !== null && typeof value === 'object') {
|
|
325
|
-
// `{ relation: { _count: 'asc' } }` orders by an aggregate — no nested
|
|
326
|
-
// field name to resolve. `{ relation: { name: 'asc' } }` orders by a
|
|
327
|
-
// field on a to-one related list — walk it against that list's fields.
|
|
328
|
-
if ('_count' in (value as Record<string, unknown>)) continue
|
|
329
|
-
|
|
330
|
-
const related = getRelatedListConfig(resolved.fieldConfig.ref, config)
|
|
331
|
-
if (related) {
|
|
332
|
-
walkOrderBy(
|
|
333
|
-
value,
|
|
334
|
-
related.listConfig,
|
|
335
|
-
related.listName,
|
|
336
|
-
config,
|
|
337
|
-
isSudo,
|
|
338
|
-
resolveSyntheticRelation,
|
|
339
|
-
)
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Validate a caller-supplied `where`/`orderBy` against the list config,
|
|
347
|
-
* recursing into logical operators (`AND`/`OR`/`NOT`) and relation filters.
|
|
348
|
-
* Throws a `ValidationError` naming the list and the offending key on the
|
|
349
|
-
* first undeclared key found. `isSudo` bypasses the check entirely, matching
|
|
350
|
-
* the write path's `sudo` escape hatch.
|
|
351
|
-
*
|
|
352
|
-
* `resolveSyntheticRelation` is the include-nested position's own addition
|
|
353
|
-
* (#1092, see module doc comment) — omit it (every top-level `where`/`orderBy`
|
|
354
|
-
* caller does) and a key `resolveQueryField` can't resolve rejects exactly as
|
|
355
|
-
* before.
|
|
356
|
-
*/
|
|
357
|
-
export function validateQueryKeys(args: {
|
|
358
|
-
where?: unknown
|
|
359
|
-
orderBy?: unknown
|
|
360
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
|
|
361
|
-
listConfig: ListConfig<any>
|
|
362
|
-
listName: string
|
|
363
|
-
config: OpenSaasConfig
|
|
364
|
-
isSudo: boolean
|
|
365
|
-
resolveSyntheticRelation?: ResolveSyntheticRelation
|
|
366
|
-
}): void {
|
|
367
|
-
const { where, orderBy, listConfig, listName, config, isSudo, resolveSyntheticRelation } = args
|
|
368
|
-
if (where !== undefined) {
|
|
369
|
-
walkWhere(where, listConfig, listName, config, isSudo, resolveSyntheticRelation)
|
|
370
|
-
}
|
|
371
|
-
if (orderBy !== undefined) {
|
|
372
|
-
walkOrderBy(orderBy, listConfig, listName, config, isSudo, resolveSyntheticRelation)
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* #915 — the predicate-time counterpart to `checkFieldAccess`'s post-query
|
|
378
|
-
* check: reject a `where`/`orderBy` key that names a field the session cannot
|
|
379
|
-
* read, BEFORE the query runs. See this module's top doc comment for how this
|
|
380
|
-
* relates to `validateQueryKeys` (#912) and `isFieldReadableForPredicate`'s
|
|
381
|
-
* doc (in `field-access.ts`) for how a row-dependent `read` rule is handled.
|
|
382
|
-
*
|
|
383
|
-
* A key `resolveQueryField` cannot resolve is skipped here — #912 has already
|
|
384
|
-
* rejected it (or, under `sudo`, deliberately let it through) by the time
|
|
385
|
-
* this runs. A system field (`id`/`createdAt`/`updatedAt`) resolves with no
|
|
386
|
-
* `fieldConfig` and carries no field-level access control, so it is always
|
|
387
|
-
* readable and skipped too.
|
|
388
|
-
*/
|
|
389
|
-
async function checkKeyReadableOrThrow(
|
|
390
|
-
key: string,
|
|
391
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
|
|
392
|
-
listConfig: ListConfig<any>,
|
|
393
|
-
listName: string,
|
|
394
|
-
args: { session: Session | null; context: AccessContext & { _isSudo?: boolean } },
|
|
395
|
-
kind: 'where' | 'orderBy',
|
|
396
|
-
): Promise<void> {
|
|
397
|
-
const resolved = resolveQueryField(key, listConfig.fields)
|
|
398
|
-
if (!resolved || resolved.fieldConfig === undefined) return
|
|
399
|
-
|
|
400
|
-
const readable = await isFieldReadableForPredicate(resolved.fieldConfig.access, args)
|
|
401
|
-
if (!readable) {
|
|
402
|
-
throw new ValidationError([
|
|
403
|
-
`Cannot query "${listName}" — "${key}" is denied by field-level read access. ` +
|
|
404
|
-
`A field the session cannot read cannot be named in a ${kind} (use sudo to bypass).`,
|
|
405
|
-
])
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* Check field-level `read` access for every key at ONE level of a `where`
|
|
411
|
-
* clause, recursing only into logical operators (`AND`/`OR`/`NOT`) — never
|
|
412
|
-
* into a relationship field's own nested value. Exported for `access-filter.ts`'s
|
|
413
|
-
* #916 reuse (see module doc comment above) — called once per hop against the
|
|
414
|
-
* RELATED list's own config.
|
|
415
|
-
*/
|
|
416
|
-
export async function walkWhereReadAccess(
|
|
417
|
-
where: unknown,
|
|
418
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
|
|
419
|
-
listConfig: ListConfig<any>,
|
|
420
|
-
listName: string,
|
|
421
|
-
args: { session: Session | null; context: AccessContext & { _isSudo?: boolean } },
|
|
422
|
-
): Promise<void> {
|
|
423
|
-
if (where === null || typeof where !== 'object') return
|
|
424
|
-
|
|
425
|
-
if (Array.isArray(where)) {
|
|
426
|
-
for (const entry of where) await walkWhereReadAccess(entry, listConfig, listName, args)
|
|
427
|
-
return
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
for (const [key, value] of Object.entries(where as Record<string, unknown>)) {
|
|
431
|
-
if (LOGICAL_OPERATORS.has(key)) {
|
|
432
|
-
await walkWhereReadAccess(value, listConfig, listName, args)
|
|
433
|
-
continue
|
|
434
|
-
}
|
|
435
|
-
// Deliberately does not recurse into a relationship field's own nested
|
|
436
|
-
// value: it checks whether THIS list's relationship field may be named
|
|
437
|
-
// (its own `read` access) — a field on the RELATED list nested inside it
|
|
438
|
-
// is checked by the CALLER re-invoking this function against the related
|
|
439
|
-
// list's config (see #916 in the module doc comment above).
|
|
440
|
-
await checkKeyReadableOrThrow(key, listConfig, listName, args, 'where')
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
async function walkOrderByReadAccess(
|
|
445
|
-
orderBy: unknown,
|
|
446
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
|
|
447
|
-
listConfig: ListConfig<any>,
|
|
448
|
-
listName: string,
|
|
449
|
-
args: { session: Session | null; context: AccessContext & { _isSudo?: boolean } },
|
|
450
|
-
): Promise<void> {
|
|
451
|
-
if (orderBy === null || typeof orderBy !== 'object') return
|
|
452
|
-
|
|
453
|
-
if (Array.isArray(orderBy)) {
|
|
454
|
-
for (const entry of orderBy) await walkOrderByReadAccess(entry, listConfig, listName, args)
|
|
455
|
-
return
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
for (const key of Object.keys(orderBy as Record<string, unknown>)) {
|
|
459
|
-
await checkKeyReadableOrThrow(key, listConfig, listName, args, 'orderBy')
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
/**
|
|
464
|
-
* Validate a caller-supplied `where`/`orderBy` against field-level `read`
|
|
465
|
-
* access, recursing into logical operators (`AND`/`OR`/`NOT`) the same way
|
|
466
|
-
* `validateQueryKeys` does. Throws a `ValidationError` naming the list and
|
|
467
|
-
* the offending key on the first read-denied field found. `isSudo` bypasses
|
|
468
|
-
* the check entirely, matching `validateQueryKeys` and the write path's
|
|
469
|
-
* `sudo` escape hatch.
|
|
470
|
-
*/
|
|
471
|
-
export async function validateQueryFieldReadAccess(args: {
|
|
472
|
-
where?: unknown
|
|
473
|
-
orderBy?: unknown
|
|
474
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
|
|
475
|
-
listConfig: ListConfig<any>
|
|
476
|
-
listName: string
|
|
477
|
-
session: Session | null
|
|
478
|
-
context: AccessContext & { _isSudo?: boolean }
|
|
479
|
-
isSudo: boolean
|
|
480
|
-
}): Promise<void> {
|
|
481
|
-
const { where, orderBy, listConfig, listName, session, context, isSudo } = args
|
|
482
|
-
if (isSudo) return
|
|
483
|
-
const evalArgs = { session, context }
|
|
484
|
-
if (where !== undefined) await walkWhereReadAccess(where, listConfig, listName, evalArgs)
|
|
485
|
-
if (orderBy !== undefined) await walkOrderByReadAccess(orderBy, listConfig, listName, evalArgs)
|
|
486
|
-
}
|