@opensaas/stack-core 0.43.0 → 0.44.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2720 -0
- package/README.md +182 -115
- package/dist/.build-hash +1 -0
- package/dist/access/declared-dependencies.d.ts +102 -88
- package/dist/access/declared-dependencies.d.ts.map +1 -1
- package/dist/access/declared-dependencies.js +83 -71
- package/dist/access/declared-dependencies.js.map +1 -1
- package/dist/access/depth-limits.d.ts +4 -0
- package/dist/access/depth-limits.d.ts.map +1 -1
- package/dist/access/depth-limits.js +4 -0
- package/dist/access/depth-limits.js.map +1 -1
- package/dist/access/engine.d.ts +68 -20
- package/dist/access/engine.d.ts.map +1 -1
- package/dist/access/engine.js +151 -37
- package/dist/access/engine.js.map +1 -1
- package/dist/access/errors.d.ts +33 -48
- package/dist/access/errors.d.ts.map +1 -1
- package/dist/access/errors.js +73 -63
- package/dist/access/errors.js.map +1 -1
- package/dist/access/field-access.d.ts +76 -5
- package/dist/access/field-access.d.ts.map +1 -1
- package/dist/access/field-access.js +235 -61
- package/dist/access/field-access.js.map +1 -1
- package/dist/access/field-visibility.d.ts +50 -4
- package/dist/access/field-visibility.d.ts.map +1 -1
- package/dist/access/field-visibility.js +143 -160
- package/dist/access/field-visibility.js.map +1 -1
- package/dist/access/index.d.ts +5 -12
- package/dist/access/index.d.ts.map +1 -1
- package/dist/access/index.js +6 -19
- package/dist/access/index.js.map +1 -1
- package/dist/access/orm-client.d.ts +19 -0
- package/dist/access/orm-client.d.ts.map +1 -0
- package/dist/access/orm-client.js +37 -0
- package/dist/access/orm-client.js.map +1 -0
- package/dist/access/query-validation.d.ts +7 -129
- package/dist/access/query-validation.d.ts.map +1 -1
- package/dist/access/query-validation.js +12 -314
- package/dist/access/query-validation.js.map +1 -1
- package/dist/access/system-fields.d.ts +2 -0
- package/dist/access/system-fields.d.ts.map +1 -0
- package/dist/access/system-fields.js +7 -0
- package/dist/access/system-fields.js.map +1 -0
- package/dist/access/transaction-registry.d.ts +25 -2
- package/dist/access/transaction-registry.d.ts.map +1 -1
- package/dist/access/transaction-registry.js +34 -17
- package/dist/access/transaction-registry.js.map +1 -1
- package/dist/access/types.d.ts +217 -131
- package/dist/access/types.d.ts.map +1 -1
- package/dist/config/field-kind.d.ts +66 -0
- package/dist/config/field-kind.d.ts.map +1 -0
- package/dist/config/field-kind.js +63 -0
- package/dist/config/field-kind.js.map +1 -0
- package/dist/config/hook-only-fields.d.ts +3 -0
- package/dist/config/hook-only-fields.d.ts.map +1 -0
- package/dist/config/hook-only-fields.js +17 -0
- package/dist/config/hook-only-fields.js.map +1 -0
- package/dist/config/index.d.ts +3 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +6 -3
- package/dist/config/index.js.map +1 -1
- package/dist/config/mcp-tool-names.d.ts +3 -0
- package/dist/config/mcp-tool-names.d.ts.map +1 -0
- package/dist/config/mcp-tool-names.js +25 -0
- package/dist/config/mcp-tool-names.js.map +1 -0
- package/dist/config/nav-count.d.ts.map +1 -1
- package/dist/config/nav-count.js +4 -4
- package/dist/config/nav-count.js.map +1 -1
- package/dist/config/plugin-engine.d.ts +8 -2
- package/dist/config/plugin-engine.d.ts.map +1 -1
- package/dist/config/plugin-engine.js +102 -38
- package/dist/config/plugin-engine.js.map +1 -1
- package/dist/config/types.d.ts +966 -614
- package/dist/config/types.d.ts.map +1 -1
- package/dist/context/apply-defaults.d.ts +18 -1
- package/dist/context/apply-defaults.d.ts.map +1 -1
- package/dist/context/apply-defaults.js +30 -4
- package/dist/context/apply-defaults.js.map +1 -1
- package/dist/context/engine-context.d.ts +73 -0
- package/dist/context/engine-context.d.ts.map +1 -0
- package/dist/context/engine-context.js +67 -0
- package/dist/context/engine-context.js.map +1 -0
- package/dist/context/hook-pipeline.d.ts +9 -2
- package/dist/context/hook-pipeline.d.ts.map +1 -1
- package/dist/context/hook-pipeline.js +5 -4
- package/dist/context/hook-pipeline.js.map +1 -1
- package/dist/context/index.d.ts +98 -89
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +917 -722
- package/dist/context/index.js.map +1 -1
- package/dist/context/junction.d.ts +59 -0
- package/dist/context/junction.d.ts.map +1 -0
- package/dist/context/junction.js +126 -0
- package/dist/context/junction.js.map +1 -0
- package/dist/context/plugin-field-read.d.ts +33 -0
- package/dist/context/plugin-field-read.d.ts.map +1 -0
- package/dist/context/plugin-field-read.js +41 -0
- package/dist/context/plugin-field-read.js.map +1 -0
- package/dist/context/plugin-field-write.d.ts +104 -0
- package/dist/context/plugin-field-write.d.ts.map +1 -0
- package/dist/context/plugin-field-write.js +184 -0
- package/dist/context/plugin-field-write.js.map +1 -0
- package/dist/context/relationship-input.d.ts +146 -0
- package/dist/context/relationship-input.d.ts.map +1 -0
- package/dist/context/relationship-input.js +453 -0
- package/dist/context/relationship-input.js.map +1 -0
- package/dist/context/transaction-boundary.d.ts +54 -28
- package/dist/context/transaction-boundary.d.ts.map +1 -1
- package/dist/context/transaction-boundary.js +87 -169
- package/dist/context/transaction-boundary.js.map +1 -1
- package/dist/context/write-pipeline.d.ts +33 -51
- package/dist/context/write-pipeline.d.ts.map +1 -1
- package/dist/context/write-pipeline.js +372 -185
- package/dist/context/write-pipeline.js.map +1 -1
- package/dist/contract/dependencies.d.ts +88 -0
- package/dist/contract/dependencies.d.ts.map +1 -0
- package/dist/contract/dependencies.js +237 -0
- package/dist/contract/dependencies.js.map +1 -0
- package/dist/contract/derive.d.ts +49 -0
- package/dist/contract/derive.d.ts.map +1 -0
- package/dist/contract/derive.js +540 -0
- package/dist/contract/derive.js.map +1 -0
- package/dist/contract/fixtures/contract-configs.d.ts +64 -0
- package/dist/contract/fixtures/contract-configs.d.ts.map +1 -0
- package/dist/contract/fixtures/contract-configs.js +345 -0
- package/dist/contract/fixtures/contract-configs.js.map +1 -0
- package/dist/contract/id-boundary.d.ts +53 -0
- package/dist/contract/id-boundary.d.ts.map +1 -0
- package/dist/contract/id-boundary.js +76 -0
- package/dist/contract/id-boundary.js.map +1 -0
- package/dist/contract/index.d.ts +8 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +11 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/prisma.d.ts +58 -0
- package/dist/contract/prisma.d.ts.map +1 -0
- package/dist/contract/prisma.js +282 -0
- package/dist/contract/prisma.js.map +1 -0
- package/dist/contract/relation-graph.d.ts +70 -0
- package/dist/contract/relation-graph.d.ts.map +1 -0
- package/dist/contract/relation-graph.js +113 -0
- package/dist/contract/relation-graph.js.map +1 -0
- package/dist/contract/types.d.ts +135 -0
- package/dist/contract/types.d.ts.map +1 -0
- package/dist/contract/types.js +2 -0
- package/dist/contract/types.js.map +1 -0
- package/dist/db/client.d.ts +55 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +73 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/dev-database.d.ts +124 -0
- package/dist/db/dev-database.d.ts.map +1 -0
- package/dist/db/dev-database.js +291 -0
- package/dist/db/dev-database.js.map +1 -0
- package/dist/db/password-front.d.ts +10 -0
- package/dist/db/password-front.d.ts.map +1 -0
- package/dist/db/password-front.js +147 -0
- package/dist/db/password-front.js.map +1 -0
- package/dist/db/process-identity.d.ts +36 -0
- package/dist/db/process-identity.d.ts.map +1 -0
- package/dist/db/process-identity.js +114 -0
- package/dist/db/process-identity.js.map +1 -0
- package/dist/db/state-file.d.ts +54 -0
- package/dist/db/state-file.d.ts.map +1 -0
- package/dist/db/state-file.js +91 -0
- package/dist/db/state-file.js.map +1 -0
- package/dist/db/url.d.ts +89 -0
- package/dist/db/url.d.ts.map +1 -0
- package/dist/db/url.js +118 -0
- package/dist/db/url.js.map +1 -0
- package/dist/extend.d.ts +13 -2
- package/dist/extend.d.ts.map +1 -1
- package/dist/extend.js +24 -1
- package/dist/extend.js.map +1 -1
- package/dist/fields/index.d.ts +87 -42
- package/dist/fields/index.d.ts.map +1 -1
- package/dist/fields/index.js +457 -677
- package/dist/fields/index.js.map +1 -1
- package/dist/filter/collect.d.ts +3 -4
- package/dist/filter/collect.d.ts.map +1 -1
- package/dist/filter/collect.js +2 -2
- package/dist/filter/collect.js.map +1 -1
- package/dist/filter/index.d.ts +1 -2
- package/dist/filter/index.d.ts.map +1 -1
- package/dist/filter/index.js +0 -1
- package/dist/filter/index.js.map +1 -1
- package/dist/filter/map.d.ts +12 -5
- package/dist/filter/map.d.ts.map +1 -1
- package/dist/filter/map.js +47 -19
- package/dist/filter/map.js.map +1 -1
- package/dist/filter/types.d.ts +10 -24
- package/dist/filter/types.d.ts.map +1 -1
- package/dist/filter/types.js +2 -11
- package/dist/filter/types.js.map +1 -1
- package/dist/hooks/index.d.ts +22 -31
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +33 -37
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/transition-guard.d.ts +61 -0
- package/dist/hooks/transition-guard.d.ts.map +1 -0
- package/dist/hooks/transition-guard.js +93 -0
- package/dist/hooks/transition-guard.js.map +1 -0
- package/dist/index.d.ts +52 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +105 -51
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +4 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +16 -0
- package/dist/internal.js.map +1 -1
- package/dist/lib/case-utils.d.ts +0 -1
- package/dist/lib/case-utils.d.ts.map +1 -1
- package/dist/lib/case-utils.js +0 -3
- package/dist/lib/case-utils.js.map +1 -1
- package/dist/lib/client-safe-error.d.ts +9 -0
- package/dist/lib/client-safe-error.d.ts.map +1 -0
- package/dist/lib/client-safe-error.js +23 -0
- package/dist/lib/client-safe-error.js.map +1 -0
- package/dist/lib/database-errors.d.ts +78 -0
- package/dist/lib/database-errors.d.ts.map +1 -0
- package/dist/lib/database-errors.js +148 -0
- package/dist/lib/database-errors.js.map +1 -0
- package/dist/lib/null-prototype-registry.d.ts +9 -0
- package/dist/lib/null-prototype-registry.d.ts.map +1 -0
- package/dist/lib/null-prototype-registry.js +11 -0
- package/dist/lib/null-prototype-registry.js.map +1 -0
- package/dist/lib/prisma-errors.d.ts +30 -32
- package/dist/lib/prisma-errors.d.ts.map +1 -1
- package/dist/lib/prisma-errors.js +86 -46
- package/dist/lib/prisma-errors.js.map +1 -1
- package/dist/lib/process-global.d.ts +23 -0
- package/dist/lib/process-global.d.ts.map +1 -0
- package/dist/lib/process-global.js +33 -0
- package/dist/lib/process-global.js.map +1 -0
- package/dist/lib/warn-once.d.ts +7 -0
- package/dist/lib/warn-once.d.ts.map +1 -0
- package/dist/lib/warn-once.js +13 -0
- package/dist/lib/warn-once.js.map +1 -0
- package/dist/mcp/advertise.d.ts +16 -0
- package/dist/mcp/advertise.d.ts.map +1 -0
- package/dist/mcp/advertise.js +25 -0
- package/dist/mcp/advertise.js.map +1 -0
- package/dist/mcp/arguments.d.ts +10 -0
- package/dist/mcp/arguments.d.ts.map +1 -0
- package/dist/mcp/arguments.js +143 -0
- package/dist/mcp/arguments.js.map +1 -0
- package/dist/mcp/field-schema.d.ts +50 -5
- package/dist/mcp/field-schema.d.ts.map +1 -1
- package/dist/mcp/field-schema.js +137 -14
- package/dist/mcp/field-schema.js.map +1 -1
- package/dist/mcp/handler.d.ts +16 -5
- package/dist/mcp/handler.d.ts.map +1 -1
- package/dist/mcp/handler.js +404 -126
- package/dist/mcp/handler.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/projection.d.ts +42 -34
- package/dist/mcp/projection.d.ts.map +1 -1
- package/dist/mcp/projection.js +246 -200
- package/dist/mcp/projection.js.map +1 -1
- package/dist/mcp/tool-error.d.ts +8 -0
- package/dist/mcp/tool-error.d.ts.map +1 -0
- package/dist/mcp/tool-error.js +11 -0
- package/dist/mcp/tool-error.js.map +1 -0
- package/dist/mcp/types.d.ts +3 -2
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/where-id-boundary.d.ts +28 -0
- package/dist/mcp/where-id-boundary.d.ts.map +1 -0
- package/dist/mcp/where-id-boundary.js +187 -0
- package/dist/mcp/where-id-boundary.js.map +1 -0
- package/dist/origin.d.ts +147 -0
- package/dist/origin.d.ts.map +1 -0
- package/dist/origin.js +191 -0
- package/dist/origin.js.map +1 -0
- package/dist/query/relationship-options.d.ts +35 -6
- package/dist/query/relationship-options.d.ts.map +1 -1
- package/dist/query/relationship-options.js +33 -23
- package/dist/query/relationship-options.js.map +1 -1
- package/dist/secured/aggregate.d.ts +32 -0
- package/dist/secured/aggregate.d.ts.map +1 -0
- package/dist/secured/aggregate.js +31 -0
- package/dist/secured/aggregate.js.map +1 -0
- package/dist/secured/include.d.ts +320 -0
- package/dist/secured/include.d.ts.map +1 -0
- package/dist/secured/include.js +650 -0
- package/dist/secured/include.js.map +1 -0
- package/dist/secured/lock.d.ts +127 -0
- package/dist/secured/lock.d.ts.map +1 -0
- package/dist/secured/lock.js +275 -0
- package/dist/secured/lock.js.map +1 -0
- package/dist/secured/lower.d.ts +82 -0
- package/dist/secured/lower.d.ts.map +1 -0
- package/dist/secured/lower.js +162 -0
- package/dist/secured/lower.js.map +1 -0
- package/dist/secured/operators.d.ts +7 -0
- package/dist/secured/operators.d.ts.map +1 -0
- package/dist/secured/operators.js +18 -0
- package/dist/secured/operators.js.map +1 -0
- package/dist/secured/read.d.ts +208 -0
- package/dist/secured/read.d.ts.map +1 -0
- package/dist/secured/read.js +1245 -0
- package/dist/secured/read.js.map +1 -0
- package/dist/secured/select.d.ts +87 -0
- package/dist/secured/select.d.ts.map +1 -0
- package/dist/secured/select.js +250 -0
- package/dist/secured/select.js.map +1 -0
- package/dist/secured/vector.d.ts +58 -0
- package/dist/secured/vector.d.ts.map +1 -0
- package/dist/secured/vector.js +113 -0
- package/dist/secured/vector.js.map +1 -0
- package/dist/secured/vocabulary.d.ts +227 -0
- package/dist/secured/vocabulary.d.ts.map +1 -0
- package/dist/secured/vocabulary.js +578 -0
- package/dist/secured/vocabulary.js.map +1 -0
- package/dist/secured/write.d.ts +58 -0
- package/dist/secured/write.d.ts.map +1 -0
- package/dist/secured/write.js +87 -0
- package/dist/secured/write.js.map +1 -0
- package/dist/testing/context.d.ts +236 -0
- package/dist/testing/context.d.ts.map +1 -0
- package/dist/testing/context.js +457 -0
- package/dist/testing/context.js.map +1 -0
- package/dist/testing/escape.d.ts +83 -0
- package/dist/testing/escape.d.ts.map +1 -0
- package/dist/testing/escape.js +148 -0
- package/dist/testing/escape.js.map +1 -0
- package/dist/testing/extensions.d.ts +48 -0
- package/dist/testing/extensions.d.ts.map +1 -0
- package/dist/testing/extensions.js +107 -0
- package/dist/testing/extensions.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +11 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/plans.d.ts +64 -0
- package/dist/testing/plans.d.ts.map +1 -0
- package/dist/testing/plans.js +47 -0
- package/dist/testing/plans.js.map +1 -0
- package/dist/types/context.d.ts +110 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +2 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/contract.d.ts +198 -0
- package/dist/types/contract.d.ts.map +1 -0
- package/dist/types/contract.js +2 -0
- package/dist/types/contract.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/inputs.d.ts +83 -0
- package/dist/types/inputs.d.ts.map +1 -0
- package/dist/types/inputs.js +2 -0
- package/dist/types/inputs.js.map +1 -0
- package/dist/types/rows.d.ts +76 -0
- package/dist/types/rows.d.ts.map +1 -0
- package/dist/types/rows.js +2 -0
- package/dist/types/rows.js.map +1 -0
- package/dist/types/secured-list.d.ts +396 -0
- package/dist/types/secured-list.d.ts.map +1 -0
- package/dist/types/secured-list.js +2 -0
- package/dist/types/secured-list.js.map +1 -0
- package/dist/unsafe.d.ts +162 -0
- package/dist/unsafe.d.ts.map +1 -0
- package/dist/unsafe.js +177 -0
- package/dist/unsafe.js.map +1 -0
- package/dist/validation/config-refusal.d.ts +16 -0
- package/dist/validation/config-refusal.d.ts.map +1 -0
- package/dist/validation/config-refusal.js +2 -0
- package/dist/validation/config-refusal.js.map +1 -0
- package/dist/validation/database-config.d.ts +19 -0
- package/dist/validation/database-config.d.ts.map +1 -0
- package/dist/validation/database-config.js +221 -0
- package/dist/validation/database-config.js.map +1 -0
- package/dist/validation/default-value.d.ts +21 -0
- package/dist/validation/default-value.d.ts.map +1 -0
- package/dist/validation/default-value.js +72 -0
- package/dist/validation/default-value.js.map +1 -0
- package/dist/validation/extension-packs.d.ts +11 -0
- package/dist/validation/extension-packs.d.ts.map +1 -0
- package/dist/validation/extension-packs.js +53 -0
- package/dist/validation/extension-packs.js.map +1 -0
- package/dist/validation/field-config.d.ts +35 -21
- package/dist/validation/field-config.d.ts.map +1 -1
- package/dist/validation/field-config.js +51 -41
- package/dist/validation/field-config.js.map +1 -1
- package/dist/validation/field-names.d.ts +15 -0
- package/dist/validation/field-names.d.ts.map +1 -0
- package/dist/validation/field-names.js +155 -0
- package/dist/validation/field-names.js.map +1 -0
- package/dist/validation/identifier-names.d.ts +4 -0
- package/dist/validation/identifier-names.d.ts.map +1 -0
- package/dist/validation/identifier-names.js +39 -0
- package/dist/validation/identifier-names.js.map +1 -0
- package/dist/validation/needs-closure.d.ts +20 -30
- package/dist/validation/needs-closure.d.ts.map +1 -1
- package/dist/validation/needs-closure.js +29 -105
- package/dist/validation/needs-closure.js.map +1 -1
- package/dist/validation/relations.d.ts +17 -0
- package/dist/validation/relations.d.ts.map +1 -0
- package/dist/validation/relations.js +268 -0
- package/dist/validation/relations.js.map +1 -0
- package/dist/validation/schema.d.ts.map +1 -1
- package/dist/validation/schema.js +1 -3
- package/dist/validation/schema.js.map +1 -1
- package/dist/where/like.d.ts +32 -0
- package/dist/where/like.d.ts.map +1 -0
- package/dist/where/like.js +42 -0
- package/dist/where/like.js.map +1 -0
- package/package.json +70 -8
- package/.turbo/turbo-build.log +0 -4
- package/CLAUDE.md +0 -609
- package/dist/access/access-filter.d.ts +0 -241
- package/dist/access/access-filter.d.ts.map +0 -1
- package/dist/access/access-filter.js +0 -692
- package/dist/access/access-filter.js.map +0 -1
- package/dist/access/access-filter.test.d.ts +0 -2
- package/dist/access/access-filter.test.d.ts.map +0 -1
- package/dist/access/access-filter.test.js +0 -1256
- package/dist/access/access-filter.test.js.map +0 -1
- package/dist/access/declared-dependencies.test.d.ts +0 -2
- package/dist/access/declared-dependencies.test.d.ts.map +0 -1
- package/dist/access/declared-dependencies.test.js +0 -226
- package/dist/access/declared-dependencies.test.js.map +0 -1
- package/dist/access/denied-relation-visibility.test.d.ts +0 -2
- package/dist/access/denied-relation-visibility.test.d.ts.map +0 -1
- package/dist/access/denied-relation-visibility.test.js +0 -114
- package/dist/access/denied-relation-visibility.test.js.map +0 -1
- package/dist/access/engine.test.d.ts +0 -2
- package/dist/access/engine.test.d.ts.map +0 -1
- package/dist/access/engine.test.js +0 -56
- package/dist/access/engine.test.js.map +0 -1
- package/dist/access/field-access.test.d.ts +0 -2
- package/dist/access/field-access.test.d.ts.map +0 -1
- package/dist/access/field-access.test.js +0 -635
- package/dist/access/field-access.test.js.map +0 -1
- package/dist/access/multi-column-read-write.test.d.ts +0 -2
- package/dist/access/multi-column-read-write.test.d.ts.map +0 -1
- package/dist/access/multi-column-read-write.test.js +0 -183
- package/dist/access/multi-column-read-write.test.js.map +0 -1
- package/dist/access/relationship-count.d.ts +0 -98
- package/dist/access/relationship-count.d.ts.map +0 -1
- package/dist/access/relationship-count.js +0 -262
- package/dist/access/relationship-count.js.map +0 -1
- package/dist/access/relationship-count.test.d.ts +0 -2
- package/dist/access/relationship-count.test.d.ts.map +0 -1
- package/dist/access/relationship-count.test.js +0 -247
- package/dist/access/relationship-count.test.js.map +0 -1
- package/dist/access/relationship-label-filter.d.ts +0 -45
- package/dist/access/relationship-label-filter.d.ts.map +0 -1
- package/dist/access/relationship-label-filter.js +0 -22
- package/dist/access/relationship-label-filter.js.map +0 -1
- package/dist/access/relationship-label-filter.test.d.ts +0 -2
- package/dist/access/relationship-label-filter.test.d.ts.map +0 -1
- package/dist/access/relationship-label-filter.test.js +0 -89
- package/dist/access/relationship-label-filter.test.js.map +0 -1
- package/dist/access/synthetic-include-read.test.d.ts +0 -2
- package/dist/access/synthetic-include-read.test.d.ts.map +0 -1
- package/dist/access/synthetic-include-read.test.js +0 -121
- package/dist/access/synthetic-include-read.test.js.map +0 -1
- package/dist/context/nested-operations.d.ts +0 -74
- package/dist/context/nested-operations.d.ts.map +0 -1
- package/dist/context/nested-operations.js +0 -847
- package/dist/context/nested-operations.js.map +0 -1
- package/dist/fields/calendar-day.test.d.ts +0 -2
- package/dist/fields/calendar-day.test.d.ts.map +0 -1
- package/dist/fields/calendar-day.test.js +0 -246
- package/dist/fields/calendar-day.test.js.map +0 -1
- package/dist/fields/format-prisma-default.d.ts +0 -35
- package/dist/fields/format-prisma-default.d.ts.map +0 -1
- package/dist/fields/format-prisma-default.js +0 -49
- package/dist/fields/format-prisma-default.js.map +0 -1
- package/dist/fields/format-prisma-default.test.d.ts +0 -2
- package/dist/fields/format-prisma-default.test.d.ts.map +0 -1
- package/dist/fields/format-prisma-default.test.js +0 -54
- package/dist/fields/format-prisma-default.test.js.map +0 -1
- package/dist/fields/relationship-foreign-key.test.d.ts +0 -2
- package/dist/fields/relationship-foreign-key.test.d.ts.map +0 -1
- package/dist/fields/relationship-foreign-key.test.js +0 -18
- package/dist/fields/relationship-foreign-key.test.js.map +0 -1
- package/dist/fields/select.test.d.ts +0 -2
- package/dist/fields/select.test.d.ts.map +0 -1
- package/dist/fields/select.test.js +0 -279
- package/dist/fields/select.test.js.map +0 -1
- package/dist/fields/text-keystone-compat.test.d.ts +0 -2
- package/dist/fields/text-keystone-compat.test.d.ts.map +0 -1
- package/dist/fields/text-keystone-compat.test.js +0 -93
- package/dist/fields/text-keystone-compat.test.js.map +0 -1
- package/dist/filter/filter.test.d.ts +0 -2
- package/dist/filter/filter.test.d.ts.map +0 -1
- package/dist/filter/filter.test.js +0 -431
- package/dist/filter/filter.test.js.map +0 -1
- package/dist/filter/serialize.test.d.ts +0 -2
- package/dist/filter/serialize.test.d.ts.map +0 -1
- package/dist/filter/serialize.test.js +0 -83
- package/dist/filter/serialize.test.js.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/dist/index.test.js +0 -33
- package/dist/index.test.js.map +0 -1
- package/dist/lib/case-utils.test.d.ts +0 -2
- package/dist/lib/case-utils.test.d.ts.map +0 -1
- package/dist/lib/case-utils.test.js +0 -123
- package/dist/lib/case-utils.test.js.map +0 -1
- package/dist/query/index.d.ts +0 -127
- package/dist/query/index.d.ts.map +0 -1
- package/dist/query/index.js +0 -179
- package/dist/query/index.js.map +0 -1
- package/dist/query/index.test.d.ts +0 -2
- package/dist/query/index.test.d.ts.map +0 -1
- package/dist/query/index.test.js +0 -632
- package/dist/query/index.test.js.map +0 -1
- package/dist/query/relationship-options.test.d.ts +0 -2
- package/dist/query/relationship-options.test.d.ts.map +0 -1
- package/dist/query/relationship-options.test.js +0 -150
- package/dist/query/relationship-options.test.js.map +0 -1
- package/dist/validation/field-config.test.d.ts +0 -2
- package/dist/validation/field-config.test.d.ts.map +0 -1
- package/dist/validation/field-config.test.js +0 -159
- package/dist/validation/field-config.test.js.map +0 -1
- package/dist/validation/schema.test.d.ts +0 -2
- package/dist/validation/schema.test.d.ts.map +0 -1
- package/dist/validation/schema.test.js +0 -409
- package/dist/validation/schema.test.js.map +0 -1
- package/docs/type-distribution-fix.md +0 -136
- package/src/access/access-filter.test.ts +0 -1919
- package/src/access/access-filter.ts +0 -1041
- package/src/access/declared-dependencies.test.ts +0 -277
- package/src/access/declared-dependencies.ts +0 -220
- package/src/access/denied-relation-visibility.test.ts +0 -173
- package/src/access/depth-limits.ts +0 -27
- package/src/access/engine.test.ts +0 -67
- package/src/access/engine.ts +0 -193
- package/src/access/errors.ts +0 -242
- package/src/access/field-access.test.ts +0 -792
- package/src/access/field-access.ts +0 -353
- package/src/access/field-transforms.ts +0 -68
- package/src/access/field-visibility.ts +0 -569
- package/src/access/index.ts +0 -82
- package/src/access/multi-column-read-write.test.ts +0 -305
- package/src/access/query-validation.ts +0 -486
- package/src/access/relationship-count.test.ts +0 -344
- package/src/access/relationship-count.ts +0 -346
- package/src/access/relationship-label-filter.test.ts +0 -128
- package/src/access/relationship-label-filter.ts +0 -63
- package/src/access/synthetic-include-read.test.ts +0 -179
- package/src/access/transaction-registry.ts +0 -58
- package/src/access/types.ts +0 -391
- package/src/config/index.ts +0 -177
- package/src/config/label.ts +0 -51
- package/src/config/nav-count.ts +0 -77
- package/src/config/plugin-engine.ts +0 -261
- package/src/config/types.ts +0 -3270
- package/src/context/apply-defaults.ts +0 -47
- package/src/context/hook-pipeline.ts +0 -137
- package/src/context/index.ts +0 -1737
- package/src/context/nested-operations.ts +0 -1470
- package/src/context/transaction-boundary.ts +0 -485
- package/src/context/write-pipeline.ts +0 -732
- package/src/extend.ts +0 -28
- package/src/fields/calendar-day.test.ts +0 -291
- package/src/fields/format-prisma-default.test.ts +0 -64
- package/src/fields/format-prisma-default.ts +0 -64
- package/src/fields/index.ts +0 -1901
- package/src/fields/relationship-foreign-key.test.ts +0 -29
- package/src/fields/select.test.ts +0 -336
- package/src/fields/text-keystone-compat.test.ts +0 -126
- package/src/filter/collect.ts +0 -108
- package/src/filter/filter.test.ts +0 -538
- package/src/filter/index.ts +0 -26
- package/src/filter/map.ts +0 -63
- package/src/filter/parse.ts +0 -99
- package/src/filter/serialize.test.ts +0 -115
- package/src/filter/serialize.ts +0 -73
- package/src/filter/types.ts +0 -120
- package/src/hooks/index.ts +0 -752
- package/src/index.test.ts +0 -50
- package/src/index.ts +0 -192
- package/src/internal.ts +0 -61
- package/src/lib/case-utils.test.ts +0 -159
- package/src/lib/case-utils.ts +0 -68
- package/src/lib/prisma-errors.ts +0 -86
- package/src/mcp/constants.ts +0 -24
- package/src/mcp/field-schema.ts +0 -84
- package/src/mcp/handler.ts +0 -633
- package/src/mcp/index.ts +0 -7
- package/src/mcp/projection.ts +0 -497
- package/src/mcp/types.ts +0 -18
- package/src/query/index.test.ts +0 -830
- package/src/query/index.ts +0 -352
- package/src/query/relationship-options.test.ts +0 -194
- package/src/query/relationship-options.ts +0 -78
- package/src/utils/password.ts +0 -80
- package/src/validation/field-config.test.ts +0 -199
- package/src/validation/field-config.ts +0 -139
- package/src/validation/needs-closure.ts +0 -188
- package/src/validation/schema.test.ts +0 -487
- package/src/validation/schema.ts +0 -51
- package/tests/access-relationships.test.ts +0 -646
- package/tests/access.test.ts +0 -590
- package/tests/apply-defaults.test.ts +0 -119
- package/tests/bare-read-scalars.test.ts +0 -147
- package/tests/computed-field-selective-evaluation.test.ts +0 -418
- package/tests/config.test.ts +0 -242
- package/tests/context.test.ts +0 -3146
- package/tests/default-value-create.test.ts +0 -299
- package/tests/field-hooks.test.ts +0 -410
- package/tests/field-types.test.ts +0 -1291
- package/tests/hook-context-secured.test.ts +0 -424
- package/tests/hook-pipeline.test.ts +0 -233
- package/tests/hooks.test.ts +0 -481
- package/tests/interactive-transaction.test.ts +0 -444
- package/tests/label.test.ts +0 -135
- package/tests/mcp-fields-projection-access.test.ts +0 -250
- package/tests/mcp-handler.test.ts +0 -1411
- package/tests/multi-column-validation-ordering.test.ts +0 -305
- package/tests/nav-count.test.ts +0 -189
- package/tests/needs-declared-dependencies.test.ts +0 -503
- package/tests/nested-access-and-hooks.test.ts +0 -2566
- package/tests/nested-operation-registry.test.ts +0 -317
- package/tests/nested-write-hooks.test.ts +0 -864
- package/tests/nested-write-synthetic-relation.test.ts +0 -437
- package/tests/password-type-distribution.test.ts +0 -154
- package/tests/password-types.test.ts +0 -174
- package/tests/password.test.ts +0 -263
- package/tests/plugin-engine.test.ts +0 -1155
- package/tests/prisma-errors.test.ts +0 -141
- package/tests/resolve-chain.test.ts +0 -411
- package/tests/singleton.test.ts +0 -421
- package/tests/sudo.test.ts +0 -676
- package/tests/to-one-include-access-filter.test.ts +0 -172
- package/tests/transaction-boundary-hooks.test.ts +0 -710
- package/tests/transaction-boundary-outermost.test.ts +0 -530
- package/tests/virtual-fields.test.ts +0 -421
- package/tests/with-session.test.ts +0 -243
- package/tests/write-pipeline.test.ts +0 -617
- package/tsconfig.json +0 -12
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -69
package/src/hooks/index.ts
DELETED
|
@@ -1,752 +0,0 @@
|
|
|
1
|
-
import type { Hooks } from '../config/types.js'
|
|
2
|
-
import type { AccessContext } from '../access/types.js'
|
|
3
|
-
import type { FieldConfig } from '../config/types.js'
|
|
4
|
-
// #1176: resolveInput/validate/beforeOperation/afterOperation (list AND field
|
|
5
|
-
// level) receive the full secured `StackContext` — sudo()/withSession()/
|
|
6
|
-
// transaction() bound to the write's own transaction client — not the plain
|
|
7
|
-
// `AccessContext`. Transaction-boundary hooks (beforeTransaction/
|
|
8
|
-
// afterTransaction) are unaffected: they stay on `AccessContext`/the base
|
|
9
|
-
// client by ADR-0028 design.
|
|
10
|
-
import type { StackContext } from '../context/index.js'
|
|
11
|
-
import { validateWithZod } from '../validation/schema.js'
|
|
12
|
-
import { checkFieldAccess } from '../access/field-access.js'
|
|
13
|
-
|
|
14
|
-
export class ValidationError extends Error {
|
|
15
|
-
public errors: string[]
|
|
16
|
-
public fieldErrors: Record<string, string>
|
|
17
|
-
|
|
18
|
-
constructor(errors: string[], fieldErrors: Record<string, string> = {}) {
|
|
19
|
-
super(`Validation failed: ${errors.join(', ')}`)
|
|
20
|
-
this.name = 'ValidationError'
|
|
21
|
-
this.errors = errors
|
|
22
|
-
this.fieldErrors = fieldErrors
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** Used for Prisma errors like unique constraint violations. */
|
|
27
|
-
export class DatabaseError extends Error {
|
|
28
|
-
public fieldErrors: Record<string, string>
|
|
29
|
-
public code?: string
|
|
30
|
-
|
|
31
|
-
constructor(message: string, fieldErrors: Record<string, string> = {}, code?: string) {
|
|
32
|
-
super(message)
|
|
33
|
-
this.name = 'DatabaseError'
|
|
34
|
-
this.fieldErrors = fieldErrors
|
|
35
|
-
this.code = code
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export async function executeResolveInput<
|
|
40
|
-
TOutput = Record<string, unknown>,
|
|
41
|
-
TCreateInput = Record<string, unknown>,
|
|
42
|
-
TUpdateInput = Record<string, unknown>,
|
|
43
|
-
>(
|
|
44
|
-
hooks: Hooks<TOutput, TCreateInput, TUpdateInput> | undefined,
|
|
45
|
-
args:
|
|
46
|
-
| {
|
|
47
|
-
listKey: string
|
|
48
|
-
operation: 'create'
|
|
49
|
-
inputData: TCreateInput
|
|
50
|
-
resolvedData: TCreateInput
|
|
51
|
-
item: undefined
|
|
52
|
-
context: StackContext
|
|
53
|
-
}
|
|
54
|
-
| {
|
|
55
|
-
listKey: string
|
|
56
|
-
operation: 'update'
|
|
57
|
-
inputData: TUpdateInput
|
|
58
|
-
resolvedData: TUpdateInput
|
|
59
|
-
item: TOutput
|
|
60
|
-
context: StackContext
|
|
61
|
-
},
|
|
62
|
-
): Promise<TCreateInput | TUpdateInput> {
|
|
63
|
-
if (!hooks?.resolveInput) {
|
|
64
|
-
return args.resolvedData
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const result = await hooks.resolveInput(args)
|
|
68
|
-
return result
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** Supports both `validate` and the deprecated `validateInput` alias for backwards compatibility. */
|
|
72
|
-
export async function executeValidate<
|
|
73
|
-
TOutput = Record<string, unknown>,
|
|
74
|
-
TCreateInput = Record<string, unknown>,
|
|
75
|
-
TUpdateInput = Record<string, unknown>,
|
|
76
|
-
>(
|
|
77
|
-
hooks: Hooks<TOutput, TCreateInput, TUpdateInput> | undefined,
|
|
78
|
-
args:
|
|
79
|
-
| {
|
|
80
|
-
listKey: string
|
|
81
|
-
operation: 'create'
|
|
82
|
-
inputData: TCreateInput
|
|
83
|
-
resolvedData: TCreateInput
|
|
84
|
-
item: undefined
|
|
85
|
-
context: StackContext
|
|
86
|
-
}
|
|
87
|
-
| {
|
|
88
|
-
listKey: string
|
|
89
|
-
operation: 'update'
|
|
90
|
-
inputData: TUpdateInput
|
|
91
|
-
resolvedData: TUpdateInput
|
|
92
|
-
item: TOutput
|
|
93
|
-
context: StackContext
|
|
94
|
-
}
|
|
95
|
-
| {
|
|
96
|
-
listKey: string
|
|
97
|
-
operation: 'delete'
|
|
98
|
-
item: TOutput
|
|
99
|
-
context: StackContext
|
|
100
|
-
},
|
|
101
|
-
): Promise<void> {
|
|
102
|
-
const validateHook = hooks?.validate || hooks?.validateInput
|
|
103
|
-
if (!validateHook) {
|
|
104
|
-
return
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const errors: string[] = []
|
|
108
|
-
|
|
109
|
-
const addValidationError = (msg: string) => {
|
|
110
|
-
errors.push(msg)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
await validateHook({
|
|
114
|
-
...args,
|
|
115
|
-
addValidationError,
|
|
116
|
-
} as Parameters<typeof validateHook>[0])
|
|
117
|
-
|
|
118
|
-
if (errors.length > 0) {
|
|
119
|
-
throw new ValidationError(errors)
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @deprecated Use executeValidate instead. This alias is provided for backwards compatibility.
|
|
125
|
-
*/
|
|
126
|
-
export const executeValidateInput = executeValidate
|
|
127
|
-
|
|
128
|
-
/** Side effects only — cannot modify data before the database write. */
|
|
129
|
-
export async function executeBeforeOperation<
|
|
130
|
-
TOutput = Record<string, unknown>,
|
|
131
|
-
TCreateInput = Record<string, unknown>,
|
|
132
|
-
TUpdateInput = Record<string, unknown>,
|
|
133
|
-
>(
|
|
134
|
-
hooks: Hooks<TOutput, TCreateInput, TUpdateInput> | undefined,
|
|
135
|
-
args:
|
|
136
|
-
| {
|
|
137
|
-
listKey: string
|
|
138
|
-
operation: 'create'
|
|
139
|
-
inputData: TCreateInput
|
|
140
|
-
resolvedData: TCreateInput
|
|
141
|
-
context: StackContext
|
|
142
|
-
}
|
|
143
|
-
| {
|
|
144
|
-
listKey: string
|
|
145
|
-
operation: 'update'
|
|
146
|
-
inputData: TUpdateInput
|
|
147
|
-
item: TOutput
|
|
148
|
-
resolvedData: TUpdateInput
|
|
149
|
-
context: StackContext
|
|
150
|
-
}
|
|
151
|
-
| {
|
|
152
|
-
listKey: string
|
|
153
|
-
operation: 'delete'
|
|
154
|
-
item: TOutput
|
|
155
|
-
context: StackContext
|
|
156
|
-
},
|
|
157
|
-
): Promise<void> {
|
|
158
|
-
if (!hooks?.beforeOperation) {
|
|
159
|
-
return
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
await hooks.beforeOperation(args as Parameters<typeof hooks.beforeOperation>[0])
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export async function executeAfterOperation<
|
|
166
|
-
TOutput = Record<string, unknown>,
|
|
167
|
-
TCreateInput = Record<string, unknown>,
|
|
168
|
-
TUpdateInput = Record<string, unknown>,
|
|
169
|
-
>(
|
|
170
|
-
hooks: Hooks<TOutput, TCreateInput, TUpdateInput> | undefined,
|
|
171
|
-
args:
|
|
172
|
-
| {
|
|
173
|
-
listKey: string
|
|
174
|
-
operation: 'create'
|
|
175
|
-
inputData: TCreateInput
|
|
176
|
-
item: TOutput
|
|
177
|
-
resolvedData: TCreateInput
|
|
178
|
-
context: StackContext
|
|
179
|
-
}
|
|
180
|
-
| {
|
|
181
|
-
listKey: string
|
|
182
|
-
operation: 'update'
|
|
183
|
-
inputData: TUpdateInput
|
|
184
|
-
originalItem: TOutput
|
|
185
|
-
item: TOutput
|
|
186
|
-
resolvedData: TUpdateInput
|
|
187
|
-
context: StackContext
|
|
188
|
-
}
|
|
189
|
-
| {
|
|
190
|
-
listKey: string
|
|
191
|
-
operation: 'delete'
|
|
192
|
-
originalItem: TOutput
|
|
193
|
-
context: StackContext
|
|
194
|
-
},
|
|
195
|
-
): Promise<void> {
|
|
196
|
-
if (!hooks?.afterOperation) {
|
|
197
|
-
return
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
await hooks.afterOperation(args as Parameters<typeof hooks.afterOperation>[0])
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Execute list-level beforeTransaction hook (#590 / ADR-0010).
|
|
205
|
-
*
|
|
206
|
-
* Transaction-boundary hook: runs OUTSIDE the write's transaction, BEFORE it
|
|
207
|
-
* opens. A throw here aborts the write (the transaction never opens). The
|
|
208
|
-
* arguments mirror `beforeOperation` minus `resolvedData` (no input-shaping has
|
|
209
|
-
* run yet at the transaction boundary).
|
|
210
|
-
*/
|
|
211
|
-
export async function executeBeforeTransaction<
|
|
212
|
-
TOutput = Record<string, unknown>,
|
|
213
|
-
TCreateInput = Record<string, unknown>,
|
|
214
|
-
TUpdateInput = Record<string, unknown>,
|
|
215
|
-
>(
|
|
216
|
-
hooks: Hooks<TOutput, TCreateInput, TUpdateInput> | undefined,
|
|
217
|
-
args:
|
|
218
|
-
| {
|
|
219
|
-
listKey: string
|
|
220
|
-
operation: 'create'
|
|
221
|
-
inputData: TCreateInput
|
|
222
|
-
context: AccessContext
|
|
223
|
-
}
|
|
224
|
-
| {
|
|
225
|
-
listKey: string
|
|
226
|
-
operation: 'update'
|
|
227
|
-
inputData: TUpdateInput
|
|
228
|
-
item: TOutput | undefined
|
|
229
|
-
context: AccessContext
|
|
230
|
-
}
|
|
231
|
-
| {
|
|
232
|
-
listKey: string
|
|
233
|
-
operation: 'delete'
|
|
234
|
-
item: TOutput | undefined
|
|
235
|
-
context: AccessContext
|
|
236
|
-
},
|
|
237
|
-
): Promise<void> {
|
|
238
|
-
if (!hooks?.beforeTransaction) {
|
|
239
|
-
return
|
|
240
|
-
}
|
|
241
|
-
await hooks.beforeTransaction(args as Parameters<typeof hooks.beforeTransaction>[0])
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Execute list-level afterTransaction hook (#590 / ADR-0010).
|
|
246
|
-
*
|
|
247
|
-
* Transaction-boundary hook: runs OUTSIDE the write's transaction, AFTER it
|
|
248
|
-
* settles, and ALWAYS runs when the paired `beforeTransaction` ran. The
|
|
249
|
-
* `status` discriminant tells the hook whether the write committed (persisted
|
|
250
|
-
* `item` present) or rolled back (no `item`, `error` present).
|
|
251
|
-
*/
|
|
252
|
-
export async function executeAfterTransaction<
|
|
253
|
-
TOutput = Record<string, unknown>,
|
|
254
|
-
TCreateInput = Record<string, unknown>,
|
|
255
|
-
TUpdateInput = Record<string, unknown>,
|
|
256
|
-
>(
|
|
257
|
-
hooks: Hooks<TOutput, TCreateInput, TUpdateInput> | undefined,
|
|
258
|
-
args:
|
|
259
|
-
| {
|
|
260
|
-
listKey: string
|
|
261
|
-
operation: 'create'
|
|
262
|
-
status: 'committed'
|
|
263
|
-
inputData: TCreateInput
|
|
264
|
-
item: TOutput
|
|
265
|
-
context: AccessContext
|
|
266
|
-
}
|
|
267
|
-
| {
|
|
268
|
-
listKey: string
|
|
269
|
-
operation: 'create'
|
|
270
|
-
status: 'rolled-back'
|
|
271
|
-
inputData: TCreateInput
|
|
272
|
-
error: unknown
|
|
273
|
-
context: AccessContext
|
|
274
|
-
}
|
|
275
|
-
| {
|
|
276
|
-
listKey: string
|
|
277
|
-
operation: 'update'
|
|
278
|
-
status: 'committed'
|
|
279
|
-
inputData: TUpdateInput
|
|
280
|
-
originalItem: TOutput
|
|
281
|
-
item: TOutput
|
|
282
|
-
context: AccessContext
|
|
283
|
-
}
|
|
284
|
-
| {
|
|
285
|
-
listKey: string
|
|
286
|
-
operation: 'update'
|
|
287
|
-
status: 'rolled-back'
|
|
288
|
-
inputData: TUpdateInput
|
|
289
|
-
originalItem: TOutput | undefined
|
|
290
|
-
error: unknown
|
|
291
|
-
context: AccessContext
|
|
292
|
-
}
|
|
293
|
-
| {
|
|
294
|
-
listKey: string
|
|
295
|
-
operation: 'delete'
|
|
296
|
-
status: 'committed'
|
|
297
|
-
originalItem: TOutput
|
|
298
|
-
context: AccessContext
|
|
299
|
-
}
|
|
300
|
-
| {
|
|
301
|
-
listKey: string
|
|
302
|
-
operation: 'delete'
|
|
303
|
-
status: 'rolled-back'
|
|
304
|
-
originalItem: TOutput | undefined
|
|
305
|
-
error: unknown
|
|
306
|
-
context: AccessContext
|
|
307
|
-
},
|
|
308
|
-
): Promise<void> {
|
|
309
|
-
if (!hooks?.afterTransaction) {
|
|
310
|
-
return
|
|
311
|
-
}
|
|
312
|
-
await hooks.afterTransaction(args as Parameters<typeof hooks.afterTransaction>[0])
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Execute field-level beforeTransaction hooks (#590 / ADR-0010).
|
|
317
|
-
*
|
|
318
|
-
* Runs each field's `beforeTransaction` (side effects only). Like the list-level
|
|
319
|
-
* hook, these run OUTSIDE the transaction before it opens; a throw aborts the
|
|
320
|
-
* write. For create/update the field is only invoked when it appears in
|
|
321
|
-
* `inputData` (mirroring the field beforeOperation gate); for delete all fields
|
|
322
|
-
* with the hook run against the existing `item`.
|
|
323
|
-
*/
|
|
324
|
-
export async function executeFieldBeforeTransactionHooks(
|
|
325
|
-
inputData: Record<string, unknown> | undefined,
|
|
326
|
-
fields: Record<string, FieldConfig>,
|
|
327
|
-
operation: 'create' | 'update' | 'delete',
|
|
328
|
-
context: AccessContext,
|
|
329
|
-
listKey: string,
|
|
330
|
-
item?: Record<string, unknown>,
|
|
331
|
-
): Promise<void> {
|
|
332
|
-
for (const [fieldKey, fieldConfig] of Object.entries(fields)) {
|
|
333
|
-
if (!fieldConfig.hooks?.beforeTransaction) continue
|
|
334
|
-
if (operation !== 'delete' && !(inputData && fieldKey in inputData)) continue
|
|
335
|
-
|
|
336
|
-
if (operation === 'delete') {
|
|
337
|
-
await fieldConfig.hooks.beforeTransaction({
|
|
338
|
-
listKey,
|
|
339
|
-
fieldKey,
|
|
340
|
-
operation: 'delete',
|
|
341
|
-
item,
|
|
342
|
-
context,
|
|
343
|
-
} as Parameters<typeof fieldConfig.hooks.beforeTransaction>[0])
|
|
344
|
-
} else if (operation === 'create') {
|
|
345
|
-
await fieldConfig.hooks.beforeTransaction({
|
|
346
|
-
listKey,
|
|
347
|
-
fieldKey,
|
|
348
|
-
operation: 'create',
|
|
349
|
-
inputData,
|
|
350
|
-
context,
|
|
351
|
-
} as Parameters<typeof fieldConfig.hooks.beforeTransaction>[0])
|
|
352
|
-
} else {
|
|
353
|
-
await fieldConfig.hooks.beforeTransaction({
|
|
354
|
-
listKey,
|
|
355
|
-
fieldKey,
|
|
356
|
-
operation: 'update',
|
|
357
|
-
inputData,
|
|
358
|
-
item,
|
|
359
|
-
context,
|
|
360
|
-
} as Parameters<typeof fieldConfig.hooks.beforeTransaction>[0])
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Outcome of a settled write transaction, passed to afterTransaction hooks.
|
|
367
|
-
*
|
|
368
|
-
* - `committed`: the write persisted; the persisted `item` (and, for
|
|
369
|
-
* update/delete, `originalItem`) is available.
|
|
370
|
-
* - `rolled-back`: the write was aborted/rolled back; NO persisted `item` —
|
|
371
|
-
* only `inputData`/`originalItem` and the `error` that caused the rollback,
|
|
372
|
-
* so hooks can compensate.
|
|
373
|
-
*/
|
|
374
|
-
export type TransactionOutcome =
|
|
375
|
-
{ status: 'committed'; item: Record<string, unknown> } | { status: 'rolled-back'; error: unknown }
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Execute field-level afterTransaction hooks (#590 / ADR-0010).
|
|
379
|
-
*
|
|
380
|
-
* Runs each field's `afterTransaction` (side effects only) with the settled
|
|
381
|
-
* transaction outcome. On commit the field receives the persisted `item`/
|
|
382
|
-
* `originalItem` — but ONLY for the top-level list (`isTopLevel`); for nested
|
|
383
|
-
* lists they are `undefined`, since `outcome.item` is the top-level persisted
|
|
384
|
-
* row and handing it to a nested field's hook would be unsound. On rollback the
|
|
385
|
-
* field receives the `error` and NO `item`. Unlike the field `afterOperation`
|
|
386
|
-
* gate, EVERY field with the hook runs (compensation must not depend on the
|
|
387
|
-
* field appearing in the payload).
|
|
388
|
-
*/
|
|
389
|
-
export async function executeFieldAfterTransactionHooks(
|
|
390
|
-
outcome: TransactionOutcome,
|
|
391
|
-
inputData: Record<string, unknown> | undefined,
|
|
392
|
-
fields: Record<string, FieldConfig>,
|
|
393
|
-
operation: 'create' | 'update' | 'delete',
|
|
394
|
-
context: AccessContext,
|
|
395
|
-
listKey: string,
|
|
396
|
-
isTopLevel: boolean,
|
|
397
|
-
originalItem?: Record<string, unknown>,
|
|
398
|
-
): Promise<void> {
|
|
399
|
-
const committedItem = outcome.status === 'committed' && isTopLevel ? outcome.item : undefined
|
|
400
|
-
const committedOriginalItem = isTopLevel ? originalItem : undefined
|
|
401
|
-
|
|
402
|
-
for (const [fieldKey, fieldConfig] of Object.entries(fields)) {
|
|
403
|
-
if (!fieldConfig.hooks?.afterTransaction) continue
|
|
404
|
-
|
|
405
|
-
const base = { listKey, fieldKey, context }
|
|
406
|
-
|
|
407
|
-
if (outcome.status === 'rolled-back') {
|
|
408
|
-
if (operation === 'delete') {
|
|
409
|
-
await fieldConfig.hooks.afterTransaction({
|
|
410
|
-
...base,
|
|
411
|
-
operation: 'delete',
|
|
412
|
-
status: 'rolled-back',
|
|
413
|
-
originalItem,
|
|
414
|
-
error: outcome.error,
|
|
415
|
-
} as Parameters<typeof fieldConfig.hooks.afterTransaction>[0])
|
|
416
|
-
} else if (operation === 'create') {
|
|
417
|
-
await fieldConfig.hooks.afterTransaction({
|
|
418
|
-
...base,
|
|
419
|
-
operation: 'create',
|
|
420
|
-
status: 'rolled-back',
|
|
421
|
-
inputData,
|
|
422
|
-
error: outcome.error,
|
|
423
|
-
} as Parameters<typeof fieldConfig.hooks.afterTransaction>[0])
|
|
424
|
-
} else {
|
|
425
|
-
await fieldConfig.hooks.afterTransaction({
|
|
426
|
-
...base,
|
|
427
|
-
operation: 'update',
|
|
428
|
-
status: 'rolled-back',
|
|
429
|
-
inputData,
|
|
430
|
-
originalItem,
|
|
431
|
-
error: outcome.error,
|
|
432
|
-
} as Parameters<typeof fieldConfig.hooks.afterTransaction>[0])
|
|
433
|
-
}
|
|
434
|
-
continue
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
if (operation === 'delete') {
|
|
438
|
-
await fieldConfig.hooks.afterTransaction({
|
|
439
|
-
...base,
|
|
440
|
-
operation: 'delete',
|
|
441
|
-
status: 'committed',
|
|
442
|
-
originalItem: committedOriginalItem,
|
|
443
|
-
} as Parameters<typeof fieldConfig.hooks.afterTransaction>[0])
|
|
444
|
-
} else if (operation === 'create') {
|
|
445
|
-
await fieldConfig.hooks.afterTransaction({
|
|
446
|
-
...base,
|
|
447
|
-
operation: 'create',
|
|
448
|
-
status: 'committed',
|
|
449
|
-
inputData,
|
|
450
|
-
item: committedItem,
|
|
451
|
-
} as Parameters<typeof fieldConfig.hooks.afterTransaction>[0])
|
|
452
|
-
} else {
|
|
453
|
-
await fieldConfig.hooks.afterTransaction({
|
|
454
|
-
...base,
|
|
455
|
-
operation: 'update',
|
|
456
|
-
status: 'committed',
|
|
457
|
-
inputData,
|
|
458
|
-
originalItem: committedOriginalItem,
|
|
459
|
-
item: committedItem,
|
|
460
|
-
} as Parameters<typeof fieldConfig.hooks.afterTransaction>[0])
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* NOTE (#789): multi-column fields (e.g. storage image()/file() in
|
|
467
|
-
* Keystone-parity mode) are NOT split here. This phase only resolves each
|
|
468
|
-
* field's value under its LOGICAL key, so that phases 2-3 (list/field
|
|
469
|
-
* `validate` → `validateFieldRules`) run against the same shape a
|
|
470
|
-
* single-column field would present — including an unrecognised/invalid value
|
|
471
|
-
* a field's `resolveInput` chose to pass through for validation to catch. The
|
|
472
|
-
* split into physical columns happens strictly AFTER validation passes; see
|
|
473
|
-
* {@link splitMultiColumnFields}.
|
|
474
|
-
*/
|
|
475
|
-
export async function executeFieldResolveInputHooks(
|
|
476
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
477
|
-
inputData: Record<string, any>,
|
|
478
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
479
|
-
resolvedData: Record<string, any>,
|
|
480
|
-
fields: Record<string, FieldConfig>,
|
|
481
|
-
operation: 'create' | 'update',
|
|
482
|
-
context: StackContext,
|
|
483
|
-
listKey: string,
|
|
484
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
485
|
-
item?: any,
|
|
486
|
-
): Promise<Record<string, unknown>> {
|
|
487
|
-
let result = { ...resolvedData }
|
|
488
|
-
|
|
489
|
-
for (const [fieldKey, fieldConfig] of Object.entries(fields)) {
|
|
490
|
-
if (!(fieldKey in result)) continue
|
|
491
|
-
if (!fieldConfig.hooks?.resolveInput) continue
|
|
492
|
-
|
|
493
|
-
// Type assertion is safe here because hooks are typed correctly in field definitions
|
|
494
|
-
// and we're working with runtime values that match those types
|
|
495
|
-
const resolvedValue = await fieldConfig.hooks.resolveInput({
|
|
496
|
-
listKey,
|
|
497
|
-
fieldKey,
|
|
498
|
-
operation,
|
|
499
|
-
inputData,
|
|
500
|
-
item,
|
|
501
|
-
resolvedData: { ...result }, // Pass a copy to avoid mutation affecting recorded args
|
|
502
|
-
context,
|
|
503
|
-
} as Parameters<typeof fieldConfig.hooks.resolveInput>[0])
|
|
504
|
-
|
|
505
|
-
// Create new object with updated field to avoid mutating the passed reference
|
|
506
|
-
result = { ...result, [fieldKey]: resolvedValue }
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
return result
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Split multi-column fields' resolved LOGICAL values into their physical
|
|
514
|
-
* per-part columns (e.g. storage image()/file() in Keystone-parity mode — see
|
|
515
|
-
* ADR-0006).
|
|
516
|
-
*
|
|
517
|
-
* Runs AFTER `validateFieldRules` has passed (#789): a multi-column field's
|
|
518
|
-
* `getZodSchema` gets a genuine chance to reject an unrecognised/invalid
|
|
519
|
-
* logical value BEFORE it is split into `null`/`undefined` physical columns
|
|
520
|
-
* and silently written. Previously this split ran inline inside
|
|
521
|
-
* `executeFieldResolveInputHooks` (Phase 1.5, BEFORE validation), which let an
|
|
522
|
-
* unrecognised value bypass validation entirely.
|
|
523
|
-
*
|
|
524
|
-
* Preserves the field-level write-access gate exactly as before: the raw
|
|
525
|
-
* per-part column keys are not declared in `fieldConfigs`, so
|
|
526
|
-
* `filterWritableFields`'s undeclared-key reject cannot enforce this field's
|
|
527
|
-
* own write access — enforce it HERE, using the canonical field-access
|
|
528
|
-
* evaluator with the same arguments the write pipeline uses. A denied field
|
|
529
|
-
* drops its logical key and contributes NONE of its per-part columns (sudo
|
|
530
|
-
* bypasses via `checkFieldAccess`).
|
|
531
|
-
*/
|
|
532
|
-
export async function splitMultiColumnFields(
|
|
533
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
534
|
-
inputData: Record<string, any>,
|
|
535
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
536
|
-
resolvedData: Record<string, any>,
|
|
537
|
-
fields: Record<string, FieldConfig>,
|
|
538
|
-
operation: 'create' | 'update',
|
|
539
|
-
context: AccessContext,
|
|
540
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
541
|
-
item?: any,
|
|
542
|
-
): Promise<Record<string, unknown>> {
|
|
543
|
-
let result = { ...resolvedData }
|
|
544
|
-
|
|
545
|
-
for (const [fieldKey, fieldConfig] of Object.entries(fields)) {
|
|
546
|
-
if (!fieldConfig.splitColumns) continue
|
|
547
|
-
if (!(fieldKey in result)) continue
|
|
548
|
-
|
|
549
|
-
const resolvedValue = result[fieldKey]
|
|
550
|
-
|
|
551
|
-
const canWrite = await checkFieldAccess(fieldConfig.access, operation, {
|
|
552
|
-
session: context.session,
|
|
553
|
-
item,
|
|
554
|
-
context,
|
|
555
|
-
inputData,
|
|
556
|
-
})
|
|
557
|
-
|
|
558
|
-
// Drop the logical key (it is not a real column) regardless of outcome —
|
|
559
|
-
// a denied field must not leave its logical key behind either.
|
|
560
|
-
const next = { ...result }
|
|
561
|
-
delete next[fieldKey]
|
|
562
|
-
result = next
|
|
563
|
-
|
|
564
|
-
if (!canWrite) {
|
|
565
|
-
// Denied: write none of its per-part columns — exactly as
|
|
566
|
-
// filterWritableFields drops a denied single-column field.
|
|
567
|
-
continue
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
const columns = fieldConfig.splitColumns(fieldKey, resolvedValue)
|
|
571
|
-
result = { ...result, ...columns }
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
return result
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
/** Runs after resolveInput and before the database write. */
|
|
578
|
-
export async function executeFieldValidateHooks(
|
|
579
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
580
|
-
inputData: Record<string, any> | undefined,
|
|
581
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
582
|
-
resolvedData: Record<string, any> | undefined,
|
|
583
|
-
fields: Record<string, FieldConfig>,
|
|
584
|
-
operation: 'create' | 'update' | 'delete',
|
|
585
|
-
context: StackContext,
|
|
586
|
-
listKey: string,
|
|
587
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
588
|
-
item?: any,
|
|
589
|
-
): Promise<void> {
|
|
590
|
-
const errors: string[] = []
|
|
591
|
-
const fieldErrors: Record<string, string> = {}
|
|
592
|
-
|
|
593
|
-
const addValidationError = (fieldKey: string) => (msg: string) => {
|
|
594
|
-
errors.push(msg)
|
|
595
|
-
fieldErrors[fieldKey] = msg
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
for (const [fieldKey, fieldConfig] of Object.entries(fields)) {
|
|
599
|
-
// validate / deprecated validateInput fallback — see executeValidate
|
|
600
|
-
const validateHook = fieldConfig.hooks?.validate ?? fieldConfig.hooks?.validateInput
|
|
601
|
-
if (!validateHook) continue
|
|
602
|
-
|
|
603
|
-
// Type assertion is safe here because hooks are typed correctly in field definitions
|
|
604
|
-
if (operation === 'delete') {
|
|
605
|
-
await validateHook({
|
|
606
|
-
listKey,
|
|
607
|
-
fieldKey,
|
|
608
|
-
operation: 'delete',
|
|
609
|
-
item,
|
|
610
|
-
context,
|
|
611
|
-
addValidationError: addValidationError(fieldKey),
|
|
612
|
-
} as Parameters<typeof validateHook>[0])
|
|
613
|
-
} else if (operation === 'create') {
|
|
614
|
-
await validateHook({
|
|
615
|
-
listKey,
|
|
616
|
-
fieldKey,
|
|
617
|
-
operation: 'create',
|
|
618
|
-
inputData,
|
|
619
|
-
item: undefined,
|
|
620
|
-
resolvedData,
|
|
621
|
-
context,
|
|
622
|
-
addValidationError: addValidationError(fieldKey),
|
|
623
|
-
} as Parameters<typeof validateHook>[0])
|
|
624
|
-
} else {
|
|
625
|
-
await validateHook({
|
|
626
|
-
listKey,
|
|
627
|
-
fieldKey,
|
|
628
|
-
operation: 'update',
|
|
629
|
-
inputData,
|
|
630
|
-
item,
|
|
631
|
-
resolvedData,
|
|
632
|
-
context,
|
|
633
|
-
addValidationError: addValidationError(fieldKey),
|
|
634
|
-
} as Parameters<typeof validateHook>[0])
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
if (errors.length > 0) {
|
|
639
|
-
throw new ValidationError(errors, fieldErrors)
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
export async function executeFieldBeforeOperationHooks(
|
|
644
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
645
|
-
inputData: Record<string, any>,
|
|
646
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
647
|
-
resolvedData: Record<string, any>,
|
|
648
|
-
fields: Record<string, FieldConfig>,
|
|
649
|
-
operation: 'create' | 'update' | 'delete',
|
|
650
|
-
context: StackContext,
|
|
651
|
-
listKey: string,
|
|
652
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
653
|
-
item?: any,
|
|
654
|
-
): Promise<void> {
|
|
655
|
-
for (const [fieldKey, fieldConfig] of Object.entries(fields)) {
|
|
656
|
-
if (!fieldConfig.hooks?.beforeOperation) continue
|
|
657
|
-
if (operation !== 'delete' && !(fieldKey in resolvedData)) continue
|
|
658
|
-
|
|
659
|
-
if (operation === 'delete') {
|
|
660
|
-
await fieldConfig.hooks.beforeOperation({
|
|
661
|
-
listKey,
|
|
662
|
-
fieldKey,
|
|
663
|
-
operation: 'delete',
|
|
664
|
-
item,
|
|
665
|
-
context,
|
|
666
|
-
} as Parameters<typeof fieldConfig.hooks.beforeOperation>[0])
|
|
667
|
-
} else if (operation === 'create') {
|
|
668
|
-
await fieldConfig.hooks.beforeOperation({
|
|
669
|
-
listKey,
|
|
670
|
-
fieldKey,
|
|
671
|
-
operation: 'create',
|
|
672
|
-
inputData,
|
|
673
|
-
resolvedData,
|
|
674
|
-
context,
|
|
675
|
-
} as Parameters<typeof fieldConfig.hooks.beforeOperation>[0])
|
|
676
|
-
} else {
|
|
677
|
-
await fieldConfig.hooks.beforeOperation({
|
|
678
|
-
listKey,
|
|
679
|
-
fieldKey,
|
|
680
|
-
operation: 'update',
|
|
681
|
-
inputData,
|
|
682
|
-
item,
|
|
683
|
-
resolvedData,
|
|
684
|
-
context,
|
|
685
|
-
} as Parameters<typeof fieldConfig.hooks.beforeOperation>[0])
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
export async function executeFieldAfterOperationHooks(
|
|
691
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
692
|
-
item: any,
|
|
693
|
-
inputData: Record<string, unknown> | undefined,
|
|
694
|
-
resolvedData: Record<string, unknown> | undefined,
|
|
695
|
-
fields: Record<string, FieldConfig>,
|
|
696
|
-
operation: 'create' | 'update' | 'delete',
|
|
697
|
-
context: StackContext,
|
|
698
|
-
listKey: string,
|
|
699
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
700
|
-
originalItem?: any,
|
|
701
|
-
): Promise<void> {
|
|
702
|
-
for (const [fieldKey, fieldConfig] of Object.entries(fields)) {
|
|
703
|
-
if (!fieldConfig.hooks?.afterOperation) continue
|
|
704
|
-
|
|
705
|
-
if (operation === 'delete') {
|
|
706
|
-
await fieldConfig.hooks.afterOperation({
|
|
707
|
-
listKey,
|
|
708
|
-
fieldKey,
|
|
709
|
-
operation: 'delete',
|
|
710
|
-
originalItem,
|
|
711
|
-
context,
|
|
712
|
-
} as Parameters<typeof fieldConfig.hooks.afterOperation>[0])
|
|
713
|
-
} else if (operation === 'create') {
|
|
714
|
-
await fieldConfig.hooks.afterOperation({
|
|
715
|
-
listKey,
|
|
716
|
-
fieldKey,
|
|
717
|
-
operation: 'create',
|
|
718
|
-
inputData,
|
|
719
|
-
item,
|
|
720
|
-
resolvedData,
|
|
721
|
-
context,
|
|
722
|
-
} as Parameters<typeof fieldConfig.hooks.afterOperation>[0])
|
|
723
|
-
} else {
|
|
724
|
-
await fieldConfig.hooks.afterOperation({
|
|
725
|
-
listKey,
|
|
726
|
-
fieldKey,
|
|
727
|
-
operation: 'update',
|
|
728
|
-
inputData,
|
|
729
|
-
originalItem,
|
|
730
|
-
item,
|
|
731
|
-
resolvedData,
|
|
732
|
-
context,
|
|
733
|
-
} as Parameters<typeof fieldConfig.hooks.afterOperation>[0])
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
export function validateFieldRules(
|
|
739
|
-
data: Record<string, unknown>,
|
|
740
|
-
fieldConfigs: Record<string, FieldConfig>,
|
|
741
|
-
operation: 'create' | 'update' = 'create',
|
|
742
|
-
): { errors: string[]; fieldErrors: Record<string, string> } {
|
|
743
|
-
const result = validateWithZod(data, fieldConfigs, operation)
|
|
744
|
-
|
|
745
|
-
if (result.success) {
|
|
746
|
-
return { errors: [], fieldErrors: {} }
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
const errors = Object.entries(result.errors).map(([_field, message]) => message)
|
|
750
|
-
|
|
751
|
-
return { errors, fieldErrors: result.errors }
|
|
752
|
-
}
|