@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,353 +0,0 @@
|
|
|
1
|
-
import type { Session, AccessContext } from './types.js'
|
|
2
|
-
import type { FieldAccess, FieldAccessControl } from './types.js'
|
|
3
|
-
import type { OpenSaasConfig } from '../config/types.js'
|
|
4
|
-
// `ValidationError` is referenced only inside function bodies (call-time), never
|
|
5
|
-
// at module-evaluation time, so the field-access ⇄ hooks import cycle is safe
|
|
6
|
-
// under ESM live bindings.
|
|
7
|
-
import { ValidationError } from '../hooks/index.js'
|
|
8
|
-
import { InvalidFieldAccessResultError } from './errors.js'
|
|
9
|
-
import { resolveSyntheticReverseRelation } from './engine.js'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Marks a throw caused by touching {@link createPoisonedItem}'s `item`, as
|
|
13
|
-
* opposed to some other error a field rule legitimately raises. Not exported
|
|
14
|
-
* — callers only ever see its effect (a `false` from
|
|
15
|
-
* `isFieldReadableForPredicate`), never the class itself.
|
|
16
|
-
*/
|
|
17
|
-
class PredicateTimeItemAccessError extends Error {}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* An `item` that throws {@link PredicateTimeItemAccessError} on ANY attempt to
|
|
21
|
-
* read a property off it — including via optional chaining (`item?.x`),
|
|
22
|
-
* since the Proxy itself is a truthy object and optional chaining still
|
|
23
|
-
* performs the property read once its base is non-nullish. Used by
|
|
24
|
-
* `isFieldReadableForPredicate` to detect a read rule that depends on the
|
|
25
|
-
* fetched row: there is no row yet at predicate-evaluation time (see that
|
|
26
|
-
* function's doc), so any rule that reaches into `item` at all cannot be
|
|
27
|
-
* answered here.
|
|
28
|
-
*/
|
|
29
|
-
function createPoisonedItem(): Record<string, unknown> {
|
|
30
|
-
return new Proxy(
|
|
31
|
-
{},
|
|
32
|
-
{
|
|
33
|
-
get(_target, prop) {
|
|
34
|
-
throw new PredicateTimeItemAccessError(String(prop))
|
|
35
|
-
},
|
|
36
|
-
has(_target, prop) {
|
|
37
|
-
throw new PredicateTimeItemAccessError(String(prop))
|
|
38
|
-
},
|
|
39
|
-
ownKeys() {
|
|
40
|
-
throw new PredicateTimeItemAccessError('ownKeys')
|
|
41
|
-
},
|
|
42
|
-
getOwnPropertyDescriptor(_target, prop) {
|
|
43
|
-
throw new PredicateTimeItemAccessError(String(prop))
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
) as Record<string, unknown>
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Shared field-level access evaluation.
|
|
51
|
-
*
|
|
52
|
-
* This module is the single, canonical home for field-level access checks. Both
|
|
53
|
-
* read-time (Field Visibility, see `field-visibility.ts`) and write-time paths
|
|
54
|
-
* evaluate field access through `checkFieldAccess` — there is intentionally no
|
|
55
|
-
* second, parallel field-access evaluator. See
|
|
56
|
-
* `docs/adr/0001-access-control-is-a-two-phase-read.md` and the access-control
|
|
57
|
-
* glossary in `CONTEXT.md` for the two-phase read model that motivates this.
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Check field-level access for a specific operation.
|
|
62
|
-
*
|
|
63
|
-
* This is the canonical field-access evaluator. Its signature is deliberate:
|
|
64
|
-
* field access can depend on the `operation`, on the already-fetched `item`
|
|
65
|
-
* (read/update/delete), and on the `inputData` being written (create/update),
|
|
66
|
-
* so all of those are accepted. Do not introduce a parallel evaluator with a
|
|
67
|
-
* narrower signature.
|
|
68
|
-
*
|
|
69
|
-
* Returns a strict boolean, never a filter: a rule that returns anything else
|
|
70
|
-
* throws `InvalidFieldAccessResultError` rather than defaulting to allow (see
|
|
71
|
-
* that error's doc, ADR-0001, and ADR-0030).
|
|
72
|
-
*/
|
|
73
|
-
export async function checkFieldAccess(
|
|
74
|
-
fieldAccess: FieldAccess | undefined,
|
|
75
|
-
operation: 'read' | 'create' | 'update',
|
|
76
|
-
args: {
|
|
77
|
-
session: Session | null
|
|
78
|
-
item?: Record<string, unknown>
|
|
79
|
-
context: AccessContext & { _isSudo?: boolean }
|
|
80
|
-
inputData?: Record<string, unknown>
|
|
81
|
-
},
|
|
82
|
-
): Promise<boolean> {
|
|
83
|
-
if (args.context._isSudo) {
|
|
84
|
-
return true
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (!fieldAccess) {
|
|
88
|
-
return true
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// `FieldAccess['read']` is narrower than `FieldAccess['create'/'update']` (it
|
|
92
|
-
// only accepts the single `operation: 'read'` call shape, see `types.ts`),
|
|
93
|
-
// so indexing by a not-yet-narrowed `operation` union produces a callable
|
|
94
|
-
// whose effective parameter type collapses to an intersection TypeScript
|
|
95
|
-
// can't satisfy generically here. Widen back to the general
|
|
96
|
-
// `FieldAccessControl` — the same shape this function has always built and
|
|
97
|
-
// passed below — since by construction the args object always matches
|
|
98
|
-
// whichever operation is actually requested.
|
|
99
|
-
const accessControl = fieldAccess[operation] as FieldAccessControl | undefined
|
|
100
|
-
if (!accessControl) {
|
|
101
|
-
return true
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const result = await accessControl({
|
|
105
|
-
session: args.session,
|
|
106
|
-
item: args.item,
|
|
107
|
-
context: args.context,
|
|
108
|
-
inputData: args.inputData,
|
|
109
|
-
operation,
|
|
110
|
-
} as Parameters<typeof accessControl>[0])
|
|
111
|
-
|
|
112
|
-
if (result === false) {
|
|
113
|
-
return false
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (result === true) {
|
|
117
|
-
return true
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// `FieldAccessControl` is typed to return `boolean` only — field access is a
|
|
121
|
-
// per-field visibility decision, not a row filter (ADR-0001, ADR-0030). A
|
|
122
|
-
// well-typed rule can never reach this line; getting here means a caller
|
|
123
|
-
// bypassed the type (most notably by returning a Prisma filter, the shape
|
|
124
|
-
// operation-level `AccessControl` accepts but this does not). Fail loudly
|
|
125
|
-
// and closed — this operation applies identically whether or not `item` is
|
|
126
|
-
// available, so `create` (which has no `item` to evaluate a filter against)
|
|
127
|
-
// needs no separate answer: neither operation ever honours a non-boolean.
|
|
128
|
-
throw new InvalidFieldAccessResultError(operation, result)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Whether a field's `read` access allows it to be NAMED in a `where`/`orderBy`
|
|
133
|
-
* predicate, evaluated BEFORE the query runs (#915).
|
|
134
|
-
*
|
|
135
|
-
* Field-level `read` access has always been a post-query check (Field
|
|
136
|
-
* Visibility, `field-visibility.ts`): it strips a denied key from a row that
|
|
137
|
-
* has already been fetched. That leaves the predicate itself unconstrained —
|
|
138
|
-
* a caller can still filter or sort by a field whose value they could never
|
|
139
|
-
* read, and recover it (or its relative order) by probing. This function is
|
|
140
|
-
* the pre-query counterpart, called from `query-validation.ts`'s `where`/
|
|
141
|
-
* `orderBy` walk for every key that resolves to a declared field.
|
|
142
|
-
*
|
|
143
|
-
* It delegates to the same evaluator Field Visibility uses (`checkFieldAccess`),
|
|
144
|
-
* per this module's canonical-evaluator rule above. The one difference is the
|
|
145
|
-
* `item` it hands the rule: there is no fetched row
|
|
146
|
-
* yet, so a rule that depends on one (the shape `FieldAccess['read']`
|
|
147
|
-
* documents as the norm, e.g. `item?.ownerId === session?.userId`) cannot be
|
|
148
|
-
* answered here. Rather than skip the check for such a rule — which would
|
|
149
|
-
* reopen exactly the hole this closes for the fields most likely to be
|
|
150
|
-
* sensitive — it is handed a poisoned `item` that throws on any property
|
|
151
|
-
* read, and that throw is caught and resolved to `false`: a row-dependent
|
|
152
|
-
* `read` rule always denies at predicate time, documented and deliberate
|
|
153
|
-
* (see docs/adr/0031). A rule that never touches `item` (checking only
|
|
154
|
-
* `session`, the common case for a field meant to be filterable/sortable at
|
|
155
|
-
* all) evaluates normally and returns its real answer.
|
|
156
|
-
*
|
|
157
|
-
* A rule that returns a non-boolean is a distinct, louder failure (#913,
|
|
158
|
-
* ADR-0030) — `InvalidFieldAccessResultError` — and is deliberately NOT
|
|
159
|
-
* folded into the `false` here; it propagates so the config bug it signals is
|
|
160
|
-
* never mistaken for an ordinary field-level denial.
|
|
161
|
-
*/
|
|
162
|
-
export async function isFieldReadableForPredicate(
|
|
163
|
-
fieldAccess: FieldAccess | undefined,
|
|
164
|
-
args: {
|
|
165
|
-
session: Session | null
|
|
166
|
-
context: AccessContext & { _isSudo?: boolean }
|
|
167
|
-
},
|
|
168
|
-
): Promise<boolean> {
|
|
169
|
-
try {
|
|
170
|
-
return await checkFieldAccess(fieldAccess, 'read', {
|
|
171
|
-
session: args.session,
|
|
172
|
-
context: args.context,
|
|
173
|
-
item: createPoisonedItem(),
|
|
174
|
-
})
|
|
175
|
-
} catch (err) {
|
|
176
|
-
// Only the poisoned-item signal means "row-dependent, deny". Anything
|
|
177
|
-
// else — including `InvalidFieldAccessResultError` and a genuine bug in
|
|
178
|
-
// the rule itself — propagates unchanged rather than being silently
|
|
179
|
-
// folded into an ordinary denial (found in review of #925).
|
|
180
|
-
if (err instanceof PredicateTimeItemAccessError) return false
|
|
181
|
-
throw err
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export async function filterWritableFields<T extends Record<string, unknown>>(
|
|
186
|
-
data: T,
|
|
187
|
-
fieldConfigs: Record<
|
|
188
|
-
string,
|
|
189
|
-
{
|
|
190
|
-
access?: FieldAccess
|
|
191
|
-
type?: string
|
|
192
|
-
getColumnNames?: (fieldName: string) => string[]
|
|
193
|
-
}
|
|
194
|
-
>,
|
|
195
|
-
operation: 'create' | 'update',
|
|
196
|
-
args: {
|
|
197
|
-
session: Session | null
|
|
198
|
-
item?: Record<string, unknown>
|
|
199
|
-
context: AccessContext & { _isSudo?: boolean }
|
|
200
|
-
inputData?: Record<string, unknown>
|
|
201
|
-
/**
|
|
202
|
-
* The list being written and the full config — used ONLY to recognise a
|
|
203
|
-
* synthetic reverse-relation key (`from_<List>_<field>`, #978) among the
|
|
204
|
-
* undeclared keys sudo would otherwise pass through unchecked. Both
|
|
205
|
-
* production call sites (the write pipeline, nested-operations) supply
|
|
206
|
-
* these; a direct unit test that omits them keeps the pre-#978 sudo
|
|
207
|
-
* behaviour of passing any undeclared key through, since it has no config
|
|
208
|
-
* to resolve a synthetic key against.
|
|
209
|
-
*/
|
|
210
|
-
listName?: string
|
|
211
|
-
config?: OpenSaasConfig
|
|
212
|
-
},
|
|
213
|
-
): Promise<Partial<T>> {
|
|
214
|
-
const filtered: Record<string, unknown> = {}
|
|
215
|
-
|
|
216
|
-
// Foreign keys must not appear in `data` when using Prisma's relation syntax.
|
|
217
|
-
const foreignKeyFields = new Set<string>()
|
|
218
|
-
// Map each raw per-part column name contributed by a multi-column field
|
|
219
|
-
// (e.g. storage image()/file() in Keystone-parity mode) back to its OWNING
|
|
220
|
-
// declared field. These columns are injected into the write payload by the
|
|
221
|
-
// field's `splitColumns`, AFTER validation (#789), and are intentionally NOT
|
|
222
|
-
// declared as their own entries in `fieldConfigs`, so without this map they
|
|
223
|
-
// would trip the #564 undeclared-key reject below.
|
|
224
|
-
//
|
|
225
|
-
// SECURITY (#568): a raw column must NOT be blanket-passed through. The hooks
|
|
226
|
-
// layer (`splitMultiColumnFields`) only gates the owning field when the
|
|
227
|
-
// LOGICAL key (e.g. `media`) is present, because it iterates declared fields,
|
|
228
|
-
// not data keys. A non-sudo caller who supplies the raw columns DIRECTLY
|
|
229
|
-
// (`data: { media_url, media_size }`) never produces that logical key, so that
|
|
230
|
-
// gate never fires. We therefore gate each raw column HERE by its owning
|
|
231
|
-
// field's write access — denied (non-sudo) throws, allowed (or sudo) passes
|
|
232
|
-
// through — so the legitimate multi-column write path is preserved while the
|
|
233
|
-
// direct-raw-column bypass is closed.
|
|
234
|
-
const splitColumnOwners = new Map<string, { fieldName: string; access?: FieldAccess }>()
|
|
235
|
-
for (const [fieldName, fieldConfig] of Object.entries(fieldConfigs)) {
|
|
236
|
-
if (fieldConfig.type === 'relationship') {
|
|
237
|
-
// For non-many relationships, Prisma creates a foreign key field named `${fieldName}Id`
|
|
238
|
-
const relConfig = fieldConfig as { many?: boolean }
|
|
239
|
-
if (!relConfig.many) {
|
|
240
|
-
foreignKeyFields.add(`${fieldName}Id`)
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if (typeof fieldConfig.getColumnNames === 'function') {
|
|
244
|
-
for (const column of fieldConfig.getColumnNames(fieldName)) {
|
|
245
|
-
splitColumnOwners.set(column, { fieldName, access: fieldConfig.access })
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const isSudo = args.context._isSudo === true
|
|
251
|
-
|
|
252
|
-
for (const [fieldName, value] of Object.entries(data)) {
|
|
253
|
-
const fieldConfig = fieldConfigs[fieldName]
|
|
254
|
-
|
|
255
|
-
if (['id', 'createdAt', 'updatedAt'].includes(fieldName)) {
|
|
256
|
-
continue
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// Virtual fields don't store in the database — skipped here, but their
|
|
260
|
-
// resolveInput hooks still run as a separate side-effect step.
|
|
261
|
-
if (fieldConfig && 'virtual' in fieldConfig && fieldConfig.virtual) {
|
|
262
|
-
continue
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// Prevents conflicts with Prisma's relation syntax (e.g.,
|
|
266
|
-
// `author: { connect: { id } }`).
|
|
267
|
-
if (foreignKeyFields.has(fieldName)) {
|
|
268
|
-
continue
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// Raw per-part columns produced by a multi-column field's `splitColumns`.
|
|
272
|
-
// They are undeclared by design, so they must not trip the #564 reject — but
|
|
273
|
-
// they must NOT be blanket-passed through either: gate each one by its
|
|
274
|
-
// OWNING field's write access (see the SECURITY note where the map is built).
|
|
275
|
-
// This is the real gate for callers who supply the raw columns directly,
|
|
276
|
-
// because the logical-key gate in `splitMultiColumnFields` never fires for
|
|
277
|
-
// them. Denied (non-sudo) throws — same fail-loud behaviour as a denied
|
|
278
|
-
// declared field (#568); allowed (or sudo, via `checkFieldAccess`) passes
|
|
279
|
-
// through, preserving the legitimate multi-column write path.
|
|
280
|
-
const splitColumnOwner = splitColumnOwners.get(fieldName)
|
|
281
|
-
if (splitColumnOwner) {
|
|
282
|
-
const canWrite = await checkFieldAccess(splitColumnOwner.access, operation, {
|
|
283
|
-
...args,
|
|
284
|
-
inputData: args.inputData,
|
|
285
|
-
})
|
|
286
|
-
if (!canWrite) {
|
|
287
|
-
throw new ValidationError([
|
|
288
|
-
`Cannot ${operation} "${splitColumnOwner.fieldName}" (via column "${fieldName}"): ` +
|
|
289
|
-
`field-level access denied.`,
|
|
290
|
-
])
|
|
291
|
-
}
|
|
292
|
-
filtered[fieldName] = value
|
|
293
|
-
continue
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// #564 — undeclared data keys must fail CLOSED.
|
|
297
|
-
// A key with no entry in `fieldConfigs` is not a field the list config
|
|
298
|
-
// exposes. The generated Prisma model has MORE fields than the config
|
|
299
|
-
// declares (e.g. back-relations like `from_Enrolment_student`), so allowing
|
|
300
|
-
// an undeclared key to pass through lets a non-sudo caller drive ungated
|
|
301
|
-
// nested writes on undeclared back-relations. Mirror Keystone's
|
|
302
|
-
// GraphQL-schema behaviour and reject it.
|
|
303
|
-
if (!fieldConfig) {
|
|
304
|
-
if (isSudo) {
|
|
305
|
-
// #978 — sudo bypasses ACCESS CONTROL, not the hooks/validation a
|
|
306
|
-
// recognised relation is entitled to. A synthetic reverse-relation key
|
|
307
|
-
// (a list-only ref's back-relation) is handed to the caller unchanged
|
|
308
|
-
// so processNestedOperations can run its target list's full pipeline,
|
|
309
|
-
// exactly as it would for a declared relationship field. Any other
|
|
310
|
-
// undeclared key has no such route to hooks — passing it straight to
|
|
311
|
-
// Prisma is the same silent-bypass shape this issue closed for
|
|
312
|
-
// relations, so it is refused even under sudo. `listName`/`config`
|
|
313
|
-
// are omitted only by direct unit tests of this function, which keep
|
|
314
|
-
// the pre-#978 blanket sudo passthrough since they have no config to
|
|
315
|
-
// resolve a synthetic key against.
|
|
316
|
-
if (args.listName && args.config) {
|
|
317
|
-
const synthetic = resolveSyntheticReverseRelation(fieldName, args.listName, args.config)
|
|
318
|
-
if (!synthetic) {
|
|
319
|
-
throw new ValidationError([
|
|
320
|
-
`Cannot ${operation} "${fieldName}": it is not a field of this list. ` +
|
|
321
|
-
`Undeclared data keys are rejected, even under sudo.`,
|
|
322
|
-
])
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
filtered[fieldName] = value
|
|
326
|
-
continue
|
|
327
|
-
}
|
|
328
|
-
throw new ValidationError([
|
|
329
|
-
`Cannot ${operation} "${fieldName}": it is not a field of this list. ` +
|
|
330
|
-
`Undeclared data keys are rejected (use sudo to bypass).`,
|
|
331
|
-
])
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// #568 — fields denied by field-level access must THROW, not be silently
|
|
335
|
-
// dropped. Keystone threw a GraphQL access error for the same situation;
|
|
336
|
-
// silently stripping the field lets a write "succeed" while doing less than
|
|
337
|
-
// asked (and skips any hook side effects gated on that field).
|
|
338
|
-
// `checkFieldAccess` already returns `true` under sudo, so sudo writes never
|
|
339
|
-
// reach the throw below — no parallel sudo path is needed here.
|
|
340
|
-
const canWrite = await checkFieldAccess(fieldConfig.access, operation, {
|
|
341
|
-
...args,
|
|
342
|
-
inputData: args.inputData,
|
|
343
|
-
})
|
|
344
|
-
|
|
345
|
-
if (!canWrite) {
|
|
346
|
-
throw new ValidationError([`Cannot ${operation} "${fieldName}": field-level access denied.`])
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
filtered[fieldName] = value
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
return filtered as Partial<T>
|
|
353
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { OpenSaasConfig, FieldConfig } from '../config/types.js'
|
|
2
|
-
import type { HashedPassword } from '../utils/password.js'
|
|
3
|
-
|
|
4
|
-
export type InferFieldReadType<TField extends FieldConfig, TOriginal> = TField extends {
|
|
5
|
-
// Uses `any` here so TypeScript's conditional type inference can pick up the
|
|
6
|
-
// exact return type `R` from a hook of any signature.
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
-
hooks?: { afterOperation?: (...args: any[]) => infer R }
|
|
9
|
-
}
|
|
10
|
-
? R extends never
|
|
11
|
-
? TOriginal
|
|
12
|
-
: R
|
|
13
|
-
: TOriginal
|
|
14
|
-
|
|
15
|
-
export type TransformModelFields<
|
|
16
|
-
// Uses `any` so this constraint accepts Prisma's generated model types, which are
|
|
17
|
-
// indexed by string keys.
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
-
TModel extends Record<string, any>,
|
|
20
|
-
TFields extends Record<string, FieldConfig>,
|
|
21
|
-
> = {
|
|
22
|
-
[K in keyof TModel]: K extends keyof TFields
|
|
23
|
-
? InferFieldReadType<TFields[K], TModel[K]>
|
|
24
|
-
: TModel[K]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export type GetListFields<
|
|
28
|
-
TConfig extends OpenSaasConfig,
|
|
29
|
-
TListKey extends keyof TConfig['lists'],
|
|
30
|
-
> = TConfig['lists'][TListKey]['fields']
|
|
31
|
-
|
|
32
|
-
export type TransformResult<
|
|
33
|
-
TConfig extends OpenSaasConfig,
|
|
34
|
-
TListKey extends keyof TConfig['lists'],
|
|
35
|
-
TResult,
|
|
36
|
-
> =
|
|
37
|
-
// Uses `any` to check whether TResult is an object type that can be transformed.
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
-
TResult extends Record<string, any>
|
|
40
|
-
? TransformModelFields<TResult, GetListFields<TConfig, TListKey>>
|
|
41
|
-
: TResult
|
|
42
|
-
|
|
43
|
-
export type TransformOperationResult<
|
|
44
|
-
TConfig extends OpenSaasConfig,
|
|
45
|
-
TListKey extends keyof TConfig['lists'],
|
|
46
|
-
TResult,
|
|
47
|
-
> =
|
|
48
|
-
TResult extends Promise<infer R>
|
|
49
|
-
? Promise<
|
|
50
|
-
R extends Array<infer Item>
|
|
51
|
-
? Array<TransformResult<TConfig, TListKey, Item>>
|
|
52
|
-
: R extends null
|
|
53
|
-
? null
|
|
54
|
-
: TransformResult<TConfig, TListKey, R>
|
|
55
|
-
>
|
|
56
|
-
: never
|
|
57
|
-
|
|
58
|
-
export interface FieldTypeTransforms {
|
|
59
|
-
password: HashedPassword
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export type InferFieldTypeTransform<TField extends FieldConfig> = TField extends {
|
|
63
|
-
type: infer TType
|
|
64
|
-
}
|
|
65
|
-
? TType extends keyof FieldTypeTransforms
|
|
66
|
-
? FieldTypeTransforms[TType]
|
|
67
|
-
: never
|
|
68
|
-
: never
|