@opensaas/stack-core 0.43.0 → 0.44.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2753 -0
- package/README.md +182 -115
- package/dist/.build-hash +1 -0
- package/dist/access/declared-dependencies.d.ts +102 -88
- package/dist/access/declared-dependencies.d.ts.map +1 -1
- package/dist/access/declared-dependencies.js +83 -71
- package/dist/access/declared-dependencies.js.map +1 -1
- package/dist/access/depth-limits.d.ts +4 -0
- package/dist/access/depth-limits.d.ts.map +1 -1
- package/dist/access/depth-limits.js +4 -0
- package/dist/access/depth-limits.js.map +1 -1
- package/dist/access/engine.d.ts +68 -20
- package/dist/access/engine.d.ts.map +1 -1
- package/dist/access/engine.js +151 -37
- package/dist/access/engine.js.map +1 -1
- package/dist/access/errors.d.ts +33 -48
- package/dist/access/errors.d.ts.map +1 -1
- package/dist/access/errors.js +73 -63
- package/dist/access/errors.js.map +1 -1
- package/dist/access/field-access.d.ts +76 -5
- package/dist/access/field-access.d.ts.map +1 -1
- package/dist/access/field-access.js +235 -61
- package/dist/access/field-access.js.map +1 -1
- package/dist/access/field-visibility.d.ts +50 -4
- package/dist/access/field-visibility.d.ts.map +1 -1
- package/dist/access/field-visibility.js +143 -160
- package/dist/access/field-visibility.js.map +1 -1
- package/dist/access/index.d.ts +5 -12
- package/dist/access/index.d.ts.map +1 -1
- package/dist/access/index.js +6 -19
- package/dist/access/index.js.map +1 -1
- package/dist/access/orm-client.d.ts +19 -0
- package/dist/access/orm-client.d.ts.map +1 -0
- package/dist/access/orm-client.js +37 -0
- package/dist/access/orm-client.js.map +1 -0
- package/dist/access/query-validation.d.ts +7 -129
- package/dist/access/query-validation.d.ts.map +1 -1
- package/dist/access/query-validation.js +12 -314
- package/dist/access/query-validation.js.map +1 -1
- package/dist/access/system-fields.d.ts +2 -0
- package/dist/access/system-fields.d.ts.map +1 -0
- package/dist/access/system-fields.js +7 -0
- package/dist/access/system-fields.js.map +1 -0
- package/dist/access/transaction-registry.d.ts +25 -2
- package/dist/access/transaction-registry.d.ts.map +1 -1
- package/dist/access/transaction-registry.js +34 -17
- package/dist/access/transaction-registry.js.map +1 -1
- package/dist/access/types.d.ts +217 -131
- package/dist/access/types.d.ts.map +1 -1
- package/dist/config/field-kind.d.ts +66 -0
- package/dist/config/field-kind.d.ts.map +1 -0
- package/dist/config/field-kind.js +63 -0
- package/dist/config/field-kind.js.map +1 -0
- package/dist/config/hook-only-fields.d.ts +3 -0
- package/dist/config/hook-only-fields.d.ts.map +1 -0
- package/dist/config/hook-only-fields.js +17 -0
- package/dist/config/hook-only-fields.js.map +1 -0
- package/dist/config/index.d.ts +3 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +6 -3
- package/dist/config/index.js.map +1 -1
- package/dist/config/mcp-tool-names.d.ts +3 -0
- package/dist/config/mcp-tool-names.d.ts.map +1 -0
- package/dist/config/mcp-tool-names.js +25 -0
- package/dist/config/mcp-tool-names.js.map +1 -0
- package/dist/config/nav-count.d.ts.map +1 -1
- package/dist/config/nav-count.js +4 -4
- package/dist/config/nav-count.js.map +1 -1
- package/dist/config/plugin-engine.d.ts +8 -2
- package/dist/config/plugin-engine.d.ts.map +1 -1
- package/dist/config/plugin-engine.js +102 -38
- package/dist/config/plugin-engine.js.map +1 -1
- package/dist/config/types.d.ts +1035 -611
- package/dist/config/types.d.ts.map +1 -1
- package/dist/context/apply-defaults.d.ts +18 -1
- package/dist/context/apply-defaults.d.ts.map +1 -1
- package/dist/context/apply-defaults.js +30 -4
- package/dist/context/apply-defaults.js.map +1 -1
- package/dist/context/engine-context.d.ts +73 -0
- package/dist/context/engine-context.d.ts.map +1 -0
- package/dist/context/engine-context.js +67 -0
- package/dist/context/engine-context.js.map +1 -0
- package/dist/context/hook-pipeline.d.ts +9 -2
- package/dist/context/hook-pipeline.d.ts.map +1 -1
- package/dist/context/hook-pipeline.js +5 -4
- package/dist/context/hook-pipeline.js.map +1 -1
- package/dist/context/index.d.ts +98 -89
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +917 -722
- package/dist/context/index.js.map +1 -1
- package/dist/context/junction.d.ts +59 -0
- package/dist/context/junction.d.ts.map +1 -0
- package/dist/context/junction.js +126 -0
- package/dist/context/junction.js.map +1 -0
- package/dist/context/plugin-field-read.d.ts +33 -0
- package/dist/context/plugin-field-read.d.ts.map +1 -0
- package/dist/context/plugin-field-read.js +41 -0
- package/dist/context/plugin-field-read.js.map +1 -0
- package/dist/context/plugin-field-write.d.ts +104 -0
- package/dist/context/plugin-field-write.d.ts.map +1 -0
- package/dist/context/plugin-field-write.js +184 -0
- package/dist/context/plugin-field-write.js.map +1 -0
- package/dist/context/relationship-input.d.ts +146 -0
- package/dist/context/relationship-input.d.ts.map +1 -0
- package/dist/context/relationship-input.js +453 -0
- package/dist/context/relationship-input.js.map +1 -0
- package/dist/context/transaction-boundary.d.ts +54 -28
- package/dist/context/transaction-boundary.d.ts.map +1 -1
- package/dist/context/transaction-boundary.js +87 -169
- package/dist/context/transaction-boundary.js.map +1 -1
- package/dist/context/write-pipeline.d.ts +33 -51
- package/dist/context/write-pipeline.d.ts.map +1 -1
- package/dist/context/write-pipeline.js +372 -185
- package/dist/context/write-pipeline.js.map +1 -1
- package/dist/contract/dependencies.d.ts +88 -0
- package/dist/contract/dependencies.d.ts.map +1 -0
- package/dist/contract/dependencies.js +237 -0
- package/dist/contract/dependencies.js.map +1 -0
- package/dist/contract/derive.d.ts +49 -0
- package/dist/contract/derive.d.ts.map +1 -0
- package/dist/contract/derive.js +629 -0
- package/dist/contract/derive.js.map +1 -0
- package/dist/contract/fixtures/contract-configs.d.ts +64 -0
- package/dist/contract/fixtures/contract-configs.d.ts.map +1 -0
- package/dist/contract/fixtures/contract-configs.js +345 -0
- package/dist/contract/fixtures/contract-configs.js.map +1 -0
- package/dist/contract/id-boundary.d.ts +53 -0
- package/dist/contract/id-boundary.d.ts.map +1 -0
- package/dist/contract/id-boundary.js +76 -0
- package/dist/contract/id-boundary.js.map +1 -0
- package/dist/contract/index.d.ts +8 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +11 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/prisma.d.ts +58 -0
- package/dist/contract/prisma.d.ts.map +1 -0
- package/dist/contract/prisma.js +294 -0
- package/dist/contract/prisma.js.map +1 -0
- package/dist/contract/relation-graph.d.ts +70 -0
- package/dist/contract/relation-graph.d.ts.map +1 -0
- package/dist/contract/relation-graph.js +113 -0
- package/dist/contract/relation-graph.js.map +1 -0
- package/dist/contract/types.d.ts +153 -0
- package/dist/contract/types.d.ts.map +1 -0
- package/dist/contract/types.js +2 -0
- package/dist/contract/types.js.map +1 -0
- package/dist/db/client.d.ts +55 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +73 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/dev-database.d.ts +124 -0
- package/dist/db/dev-database.d.ts.map +1 -0
- package/dist/db/dev-database.js +291 -0
- package/dist/db/dev-database.js.map +1 -0
- package/dist/db/password-front.d.ts +10 -0
- package/dist/db/password-front.d.ts.map +1 -0
- package/dist/db/password-front.js +147 -0
- package/dist/db/password-front.js.map +1 -0
- package/dist/db/process-identity.d.ts +36 -0
- package/dist/db/process-identity.d.ts.map +1 -0
- package/dist/db/process-identity.js +114 -0
- package/dist/db/process-identity.js.map +1 -0
- package/dist/db/state-file.d.ts +54 -0
- package/dist/db/state-file.d.ts.map +1 -0
- package/dist/db/state-file.js +91 -0
- package/dist/db/state-file.js.map +1 -0
- package/dist/db/url.d.ts +89 -0
- package/dist/db/url.d.ts.map +1 -0
- package/dist/db/url.js +118 -0
- package/dist/db/url.js.map +1 -0
- package/dist/extend.d.ts +13 -2
- package/dist/extend.d.ts.map +1 -1
- package/dist/extend.js +24 -1
- package/dist/extend.js.map +1 -1
- package/dist/fields/index.d.ts +87 -42
- package/dist/fields/index.d.ts.map +1 -1
- package/dist/fields/index.js +462 -678
- package/dist/fields/index.js.map +1 -1
- package/dist/filter/collect.d.ts +3 -4
- package/dist/filter/collect.d.ts.map +1 -1
- package/dist/filter/collect.js +2 -2
- package/dist/filter/collect.js.map +1 -1
- package/dist/filter/index.d.ts +1 -2
- package/dist/filter/index.d.ts.map +1 -1
- package/dist/filter/index.js +0 -1
- package/dist/filter/index.js.map +1 -1
- package/dist/filter/map.d.ts +12 -5
- package/dist/filter/map.d.ts.map +1 -1
- package/dist/filter/map.js +47 -19
- package/dist/filter/map.js.map +1 -1
- package/dist/filter/types.d.ts +10 -24
- package/dist/filter/types.d.ts.map +1 -1
- package/dist/filter/types.js +2 -11
- package/dist/filter/types.js.map +1 -1
- package/dist/hooks/index.d.ts +22 -31
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +33 -37
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/transition-guard.d.ts +61 -0
- package/dist/hooks/transition-guard.d.ts.map +1 -0
- package/dist/hooks/transition-guard.js +93 -0
- package/dist/hooks/transition-guard.js.map +1 -0
- package/dist/index.d.ts +52 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +105 -51
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +4 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +16 -0
- package/dist/internal.js.map +1 -1
- package/dist/lib/case-utils.d.ts +0 -1
- package/dist/lib/case-utils.d.ts.map +1 -1
- package/dist/lib/case-utils.js +0 -3
- package/dist/lib/case-utils.js.map +1 -1
- package/dist/lib/client-safe-error.d.ts +9 -0
- package/dist/lib/client-safe-error.d.ts.map +1 -0
- package/dist/lib/client-safe-error.js +23 -0
- package/dist/lib/client-safe-error.js.map +1 -0
- package/dist/lib/database-errors.d.ts +78 -0
- package/dist/lib/database-errors.d.ts.map +1 -0
- package/dist/lib/database-errors.js +148 -0
- package/dist/lib/database-errors.js.map +1 -0
- package/dist/lib/null-prototype-registry.d.ts +9 -0
- package/dist/lib/null-prototype-registry.d.ts.map +1 -0
- package/dist/lib/null-prototype-registry.js +11 -0
- package/dist/lib/null-prototype-registry.js.map +1 -0
- package/dist/lib/prisma-errors.d.ts +30 -32
- package/dist/lib/prisma-errors.d.ts.map +1 -1
- package/dist/lib/prisma-errors.js +86 -46
- package/dist/lib/prisma-errors.js.map +1 -1
- package/dist/lib/process-global.d.ts +23 -0
- package/dist/lib/process-global.d.ts.map +1 -0
- package/dist/lib/process-global.js +33 -0
- package/dist/lib/process-global.js.map +1 -0
- package/dist/lib/warn-once.d.ts +7 -0
- package/dist/lib/warn-once.d.ts.map +1 -0
- package/dist/lib/warn-once.js +13 -0
- package/dist/lib/warn-once.js.map +1 -0
- package/dist/mcp/advertise.d.ts +16 -0
- package/dist/mcp/advertise.d.ts.map +1 -0
- package/dist/mcp/advertise.js +25 -0
- package/dist/mcp/advertise.js.map +1 -0
- package/dist/mcp/arguments.d.ts +10 -0
- package/dist/mcp/arguments.d.ts.map +1 -0
- package/dist/mcp/arguments.js +143 -0
- package/dist/mcp/arguments.js.map +1 -0
- package/dist/mcp/field-schema.d.ts +50 -5
- package/dist/mcp/field-schema.d.ts.map +1 -1
- package/dist/mcp/field-schema.js +137 -14
- package/dist/mcp/field-schema.js.map +1 -1
- package/dist/mcp/handler.d.ts +16 -5
- package/dist/mcp/handler.d.ts.map +1 -1
- package/dist/mcp/handler.js +404 -126
- package/dist/mcp/handler.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/projection.d.ts +42 -34
- package/dist/mcp/projection.d.ts.map +1 -1
- package/dist/mcp/projection.js +246 -200
- package/dist/mcp/projection.js.map +1 -1
- package/dist/mcp/tool-error.d.ts +8 -0
- package/dist/mcp/tool-error.d.ts.map +1 -0
- package/dist/mcp/tool-error.js +11 -0
- package/dist/mcp/tool-error.js.map +1 -0
- package/dist/mcp/types.d.ts +3 -2
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/where-id-boundary.d.ts +28 -0
- package/dist/mcp/where-id-boundary.d.ts.map +1 -0
- package/dist/mcp/where-id-boundary.js +187 -0
- package/dist/mcp/where-id-boundary.js.map +1 -0
- package/dist/origin.d.ts +147 -0
- package/dist/origin.d.ts.map +1 -0
- package/dist/origin.js +191 -0
- package/dist/origin.js.map +1 -0
- package/dist/query/relationship-options.d.ts +35 -6
- package/dist/query/relationship-options.d.ts.map +1 -1
- package/dist/query/relationship-options.js +33 -23
- package/dist/query/relationship-options.js.map +1 -1
- package/dist/secured/aggregate.d.ts +32 -0
- package/dist/secured/aggregate.d.ts.map +1 -0
- package/dist/secured/aggregate.js +31 -0
- package/dist/secured/aggregate.js.map +1 -0
- package/dist/secured/include.d.ts +320 -0
- package/dist/secured/include.d.ts.map +1 -0
- package/dist/secured/include.js +650 -0
- package/dist/secured/include.js.map +1 -0
- package/dist/secured/lock.d.ts +127 -0
- package/dist/secured/lock.d.ts.map +1 -0
- package/dist/secured/lock.js +275 -0
- package/dist/secured/lock.js.map +1 -0
- package/dist/secured/lower.d.ts +82 -0
- package/dist/secured/lower.d.ts.map +1 -0
- package/dist/secured/lower.js +162 -0
- package/dist/secured/lower.js.map +1 -0
- package/dist/secured/operators.d.ts +7 -0
- package/dist/secured/operators.d.ts.map +1 -0
- package/dist/secured/operators.js +18 -0
- package/dist/secured/operators.js.map +1 -0
- package/dist/secured/read.d.ts +208 -0
- package/dist/secured/read.d.ts.map +1 -0
- package/dist/secured/read.js +1245 -0
- package/dist/secured/read.js.map +1 -0
- package/dist/secured/select.d.ts +87 -0
- package/dist/secured/select.d.ts.map +1 -0
- package/dist/secured/select.js +250 -0
- package/dist/secured/select.js.map +1 -0
- package/dist/secured/vector.d.ts +58 -0
- package/dist/secured/vector.d.ts.map +1 -0
- package/dist/secured/vector.js +113 -0
- package/dist/secured/vector.js.map +1 -0
- package/dist/secured/vocabulary.d.ts +227 -0
- package/dist/secured/vocabulary.d.ts.map +1 -0
- package/dist/secured/vocabulary.js +578 -0
- package/dist/secured/vocabulary.js.map +1 -0
- package/dist/secured/write.d.ts +58 -0
- package/dist/secured/write.d.ts.map +1 -0
- package/dist/secured/write.js +87 -0
- package/dist/secured/write.js.map +1 -0
- package/dist/testing/context.d.ts +236 -0
- package/dist/testing/context.d.ts.map +1 -0
- package/dist/testing/context.js +457 -0
- package/dist/testing/context.js.map +1 -0
- package/dist/testing/escape.d.ts +83 -0
- package/dist/testing/escape.d.ts.map +1 -0
- package/dist/testing/escape.js +148 -0
- package/dist/testing/escape.js.map +1 -0
- package/dist/testing/extensions.d.ts +48 -0
- package/dist/testing/extensions.d.ts.map +1 -0
- package/dist/testing/extensions.js +107 -0
- package/dist/testing/extensions.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +11 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/plans.d.ts +64 -0
- package/dist/testing/plans.d.ts.map +1 -0
- package/dist/testing/plans.js +47 -0
- package/dist/testing/plans.js.map +1 -0
- package/dist/types/context.d.ts +110 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +2 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/contract.d.ts +198 -0
- package/dist/types/contract.d.ts.map +1 -0
- package/dist/types/contract.js +2 -0
- package/dist/types/contract.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/inputs.d.ts +83 -0
- package/dist/types/inputs.d.ts.map +1 -0
- package/dist/types/inputs.js +2 -0
- package/dist/types/inputs.js.map +1 -0
- package/dist/types/rows.d.ts +76 -0
- package/dist/types/rows.d.ts.map +1 -0
- package/dist/types/rows.js +2 -0
- package/dist/types/rows.js.map +1 -0
- package/dist/types/secured-list.d.ts +396 -0
- package/dist/types/secured-list.d.ts.map +1 -0
- package/dist/types/secured-list.js +2 -0
- package/dist/types/secured-list.js.map +1 -0
- package/dist/unsafe.d.ts +162 -0
- package/dist/unsafe.d.ts.map +1 -0
- package/dist/unsafe.js +177 -0
- package/dist/unsafe.js.map +1 -0
- package/dist/validation/config-refusal.d.ts +16 -0
- package/dist/validation/config-refusal.d.ts.map +1 -0
- package/dist/validation/config-refusal.js +2 -0
- package/dist/validation/config-refusal.js.map +1 -0
- package/dist/validation/database-config.d.ts +19 -0
- package/dist/validation/database-config.d.ts.map +1 -0
- package/dist/validation/database-config.js +237 -0
- package/dist/validation/database-config.js.map +1 -0
- package/dist/validation/default-value.d.ts +21 -0
- package/dist/validation/default-value.d.ts.map +1 -0
- package/dist/validation/default-value.js +72 -0
- package/dist/validation/default-value.js.map +1 -0
- package/dist/validation/extension-packs.d.ts +11 -0
- package/dist/validation/extension-packs.d.ts.map +1 -0
- package/dist/validation/extension-packs.js +53 -0
- package/dist/validation/extension-packs.js.map +1 -0
- package/dist/validation/field-config.d.ts +35 -21
- package/dist/validation/field-config.d.ts.map +1 -1
- package/dist/validation/field-config.js +51 -41
- package/dist/validation/field-config.js.map +1 -1
- package/dist/validation/field-names.d.ts +15 -0
- package/dist/validation/field-names.d.ts.map +1 -0
- package/dist/validation/field-names.js +155 -0
- package/dist/validation/field-names.js.map +1 -0
- package/dist/validation/identifier-names.d.ts +4 -0
- package/dist/validation/identifier-names.d.ts.map +1 -0
- package/dist/validation/identifier-names.js +39 -0
- package/dist/validation/identifier-names.js.map +1 -0
- package/dist/validation/needs-closure.d.ts +20 -30
- package/dist/validation/needs-closure.d.ts.map +1 -1
- package/dist/validation/needs-closure.js +29 -105
- package/dist/validation/needs-closure.js.map +1 -1
- package/dist/validation/relations.d.ts +17 -0
- package/dist/validation/relations.d.ts.map +1 -0
- package/dist/validation/relations.js +268 -0
- package/dist/validation/relations.js.map +1 -0
- package/dist/validation/schema.d.ts.map +1 -1
- package/dist/validation/schema.js +1 -3
- package/dist/validation/schema.js.map +1 -1
- package/dist/where/like.d.ts +32 -0
- package/dist/where/like.d.ts.map +1 -0
- package/dist/where/like.js +42 -0
- package/dist/where/like.js.map +1 -0
- package/package.json +70 -8
- package/.turbo/turbo-build.log +0 -4
- package/CLAUDE.md +0 -609
- package/dist/access/access-filter.d.ts +0 -241
- package/dist/access/access-filter.d.ts.map +0 -1
- package/dist/access/access-filter.js +0 -692
- package/dist/access/access-filter.js.map +0 -1
- package/dist/access/access-filter.test.d.ts +0 -2
- package/dist/access/access-filter.test.d.ts.map +0 -1
- package/dist/access/access-filter.test.js +0 -1256
- package/dist/access/access-filter.test.js.map +0 -1
- package/dist/access/declared-dependencies.test.d.ts +0 -2
- package/dist/access/declared-dependencies.test.d.ts.map +0 -1
- package/dist/access/declared-dependencies.test.js +0 -226
- package/dist/access/declared-dependencies.test.js.map +0 -1
- package/dist/access/denied-relation-visibility.test.d.ts +0 -2
- package/dist/access/denied-relation-visibility.test.d.ts.map +0 -1
- package/dist/access/denied-relation-visibility.test.js +0 -114
- package/dist/access/denied-relation-visibility.test.js.map +0 -1
- package/dist/access/engine.test.d.ts +0 -2
- package/dist/access/engine.test.d.ts.map +0 -1
- package/dist/access/engine.test.js +0 -56
- package/dist/access/engine.test.js.map +0 -1
- package/dist/access/field-access.test.d.ts +0 -2
- package/dist/access/field-access.test.d.ts.map +0 -1
- package/dist/access/field-access.test.js +0 -635
- package/dist/access/field-access.test.js.map +0 -1
- package/dist/access/multi-column-read-write.test.d.ts +0 -2
- package/dist/access/multi-column-read-write.test.d.ts.map +0 -1
- package/dist/access/multi-column-read-write.test.js +0 -183
- package/dist/access/multi-column-read-write.test.js.map +0 -1
- package/dist/access/relationship-count.d.ts +0 -98
- package/dist/access/relationship-count.d.ts.map +0 -1
- package/dist/access/relationship-count.js +0 -262
- package/dist/access/relationship-count.js.map +0 -1
- package/dist/access/relationship-count.test.d.ts +0 -2
- package/dist/access/relationship-count.test.d.ts.map +0 -1
- package/dist/access/relationship-count.test.js +0 -247
- package/dist/access/relationship-count.test.js.map +0 -1
- package/dist/access/relationship-label-filter.d.ts +0 -45
- package/dist/access/relationship-label-filter.d.ts.map +0 -1
- package/dist/access/relationship-label-filter.js +0 -22
- package/dist/access/relationship-label-filter.js.map +0 -1
- package/dist/access/relationship-label-filter.test.d.ts +0 -2
- package/dist/access/relationship-label-filter.test.d.ts.map +0 -1
- package/dist/access/relationship-label-filter.test.js +0 -89
- package/dist/access/relationship-label-filter.test.js.map +0 -1
- package/dist/access/synthetic-include-read.test.d.ts +0 -2
- package/dist/access/synthetic-include-read.test.d.ts.map +0 -1
- package/dist/access/synthetic-include-read.test.js +0 -121
- package/dist/access/synthetic-include-read.test.js.map +0 -1
- package/dist/context/nested-operations.d.ts +0 -74
- package/dist/context/nested-operations.d.ts.map +0 -1
- package/dist/context/nested-operations.js +0 -847
- package/dist/context/nested-operations.js.map +0 -1
- package/dist/fields/calendar-day.test.d.ts +0 -2
- package/dist/fields/calendar-day.test.d.ts.map +0 -1
- package/dist/fields/calendar-day.test.js +0 -246
- package/dist/fields/calendar-day.test.js.map +0 -1
- package/dist/fields/format-prisma-default.d.ts +0 -35
- package/dist/fields/format-prisma-default.d.ts.map +0 -1
- package/dist/fields/format-prisma-default.js +0 -49
- package/dist/fields/format-prisma-default.js.map +0 -1
- package/dist/fields/format-prisma-default.test.d.ts +0 -2
- package/dist/fields/format-prisma-default.test.d.ts.map +0 -1
- package/dist/fields/format-prisma-default.test.js +0 -54
- package/dist/fields/format-prisma-default.test.js.map +0 -1
- package/dist/fields/relationship-foreign-key.test.d.ts +0 -2
- package/dist/fields/relationship-foreign-key.test.d.ts.map +0 -1
- package/dist/fields/relationship-foreign-key.test.js +0 -18
- package/dist/fields/relationship-foreign-key.test.js.map +0 -1
- package/dist/fields/select.test.d.ts +0 -2
- package/dist/fields/select.test.d.ts.map +0 -1
- package/dist/fields/select.test.js +0 -279
- package/dist/fields/select.test.js.map +0 -1
- package/dist/fields/text-keystone-compat.test.d.ts +0 -2
- package/dist/fields/text-keystone-compat.test.d.ts.map +0 -1
- package/dist/fields/text-keystone-compat.test.js +0 -93
- package/dist/fields/text-keystone-compat.test.js.map +0 -1
- package/dist/filter/filter.test.d.ts +0 -2
- package/dist/filter/filter.test.d.ts.map +0 -1
- package/dist/filter/filter.test.js +0 -431
- package/dist/filter/filter.test.js.map +0 -1
- package/dist/filter/serialize.test.d.ts +0 -2
- package/dist/filter/serialize.test.d.ts.map +0 -1
- package/dist/filter/serialize.test.js +0 -83
- package/dist/filter/serialize.test.js.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/dist/index.test.js +0 -33
- package/dist/index.test.js.map +0 -1
- package/dist/lib/case-utils.test.d.ts +0 -2
- package/dist/lib/case-utils.test.d.ts.map +0 -1
- package/dist/lib/case-utils.test.js +0 -123
- package/dist/lib/case-utils.test.js.map +0 -1
- package/dist/query/index.d.ts +0 -127
- package/dist/query/index.d.ts.map +0 -1
- package/dist/query/index.js +0 -179
- package/dist/query/index.js.map +0 -1
- package/dist/query/index.test.d.ts +0 -2
- package/dist/query/index.test.d.ts.map +0 -1
- package/dist/query/index.test.js +0 -632
- package/dist/query/index.test.js.map +0 -1
- package/dist/query/relationship-options.test.d.ts +0 -2
- package/dist/query/relationship-options.test.d.ts.map +0 -1
- package/dist/query/relationship-options.test.js +0 -150
- package/dist/query/relationship-options.test.js.map +0 -1
- package/dist/validation/field-config.test.d.ts +0 -2
- package/dist/validation/field-config.test.d.ts.map +0 -1
- package/dist/validation/field-config.test.js +0 -159
- package/dist/validation/field-config.test.js.map +0 -1
- package/dist/validation/schema.test.d.ts +0 -2
- package/dist/validation/schema.test.d.ts.map +0 -1
- package/dist/validation/schema.test.js +0 -409
- package/dist/validation/schema.test.js.map +0 -1
- package/docs/type-distribution-fix.md +0 -136
- package/src/access/access-filter.test.ts +0 -1919
- package/src/access/access-filter.ts +0 -1041
- package/src/access/declared-dependencies.test.ts +0 -277
- package/src/access/declared-dependencies.ts +0 -220
- package/src/access/denied-relation-visibility.test.ts +0 -173
- package/src/access/depth-limits.ts +0 -27
- package/src/access/engine.test.ts +0 -67
- package/src/access/engine.ts +0 -193
- package/src/access/errors.ts +0 -242
- package/src/access/field-access.test.ts +0 -792
- package/src/access/field-access.ts +0 -353
- package/src/access/field-transforms.ts +0 -68
- package/src/access/field-visibility.ts +0 -569
- package/src/access/index.ts +0 -82
- package/src/access/multi-column-read-write.test.ts +0 -305
- package/src/access/query-validation.ts +0 -486
- package/src/access/relationship-count.test.ts +0 -344
- package/src/access/relationship-count.ts +0 -346
- package/src/access/relationship-label-filter.test.ts +0 -128
- package/src/access/relationship-label-filter.ts +0 -63
- package/src/access/synthetic-include-read.test.ts +0 -179
- package/src/access/transaction-registry.ts +0 -58
- package/src/access/types.ts +0 -391
- package/src/config/index.ts +0 -177
- package/src/config/label.ts +0 -51
- package/src/config/nav-count.ts +0 -77
- package/src/config/plugin-engine.ts +0 -261
- package/src/config/types.ts +0 -3270
- package/src/context/apply-defaults.ts +0 -47
- package/src/context/hook-pipeline.ts +0 -137
- package/src/context/index.ts +0 -1737
- package/src/context/nested-operations.ts +0 -1470
- package/src/context/transaction-boundary.ts +0 -485
- package/src/context/write-pipeline.ts +0 -732
- package/src/extend.ts +0 -28
- package/src/fields/calendar-day.test.ts +0 -291
- package/src/fields/format-prisma-default.test.ts +0 -64
- package/src/fields/format-prisma-default.ts +0 -64
- package/src/fields/index.ts +0 -1901
- package/src/fields/relationship-foreign-key.test.ts +0 -29
- package/src/fields/select.test.ts +0 -336
- package/src/fields/text-keystone-compat.test.ts +0 -126
- package/src/filter/collect.ts +0 -108
- package/src/filter/filter.test.ts +0 -538
- package/src/filter/index.ts +0 -26
- package/src/filter/map.ts +0 -63
- package/src/filter/parse.ts +0 -99
- package/src/filter/serialize.test.ts +0 -115
- package/src/filter/serialize.ts +0 -73
- package/src/filter/types.ts +0 -120
- package/src/hooks/index.ts +0 -752
- package/src/index.test.ts +0 -50
- package/src/index.ts +0 -192
- package/src/internal.ts +0 -61
- package/src/lib/case-utils.test.ts +0 -159
- package/src/lib/case-utils.ts +0 -68
- package/src/lib/prisma-errors.ts +0 -86
- package/src/mcp/constants.ts +0 -24
- package/src/mcp/field-schema.ts +0 -84
- package/src/mcp/handler.ts +0 -633
- package/src/mcp/index.ts +0 -7
- package/src/mcp/projection.ts +0 -497
- package/src/mcp/types.ts +0 -18
- package/src/query/index.test.ts +0 -830
- package/src/query/index.ts +0 -352
- package/src/query/relationship-options.test.ts +0 -194
- package/src/query/relationship-options.ts +0 -78
- package/src/utils/password.ts +0 -80
- package/src/validation/field-config.test.ts +0 -199
- package/src/validation/field-config.ts +0 -139
- package/src/validation/needs-closure.ts +0 -188
- package/src/validation/schema.test.ts +0 -487
- package/src/validation/schema.ts +0 -51
- package/tests/access-relationships.test.ts +0 -646
- package/tests/access.test.ts +0 -590
- package/tests/apply-defaults.test.ts +0 -119
- package/tests/bare-read-scalars.test.ts +0 -147
- package/tests/computed-field-selective-evaluation.test.ts +0 -418
- package/tests/config.test.ts +0 -242
- package/tests/context.test.ts +0 -3146
- package/tests/default-value-create.test.ts +0 -299
- package/tests/field-hooks.test.ts +0 -410
- package/tests/field-types.test.ts +0 -1291
- package/tests/hook-context-secured.test.ts +0 -424
- package/tests/hook-pipeline.test.ts +0 -233
- package/tests/hooks.test.ts +0 -481
- package/tests/interactive-transaction.test.ts +0 -444
- package/tests/label.test.ts +0 -135
- package/tests/mcp-fields-projection-access.test.ts +0 -250
- package/tests/mcp-handler.test.ts +0 -1411
- package/tests/multi-column-validation-ordering.test.ts +0 -305
- package/tests/nav-count.test.ts +0 -189
- package/tests/needs-declared-dependencies.test.ts +0 -503
- package/tests/nested-access-and-hooks.test.ts +0 -2566
- package/tests/nested-operation-registry.test.ts +0 -317
- package/tests/nested-write-hooks.test.ts +0 -864
- package/tests/nested-write-synthetic-relation.test.ts +0 -437
- package/tests/password-type-distribution.test.ts +0 -154
- package/tests/password-types.test.ts +0 -174
- package/tests/password.test.ts +0 -263
- package/tests/plugin-engine.test.ts +0 -1155
- package/tests/prisma-errors.test.ts +0 -141
- package/tests/resolve-chain.test.ts +0 -411
- package/tests/singleton.test.ts +0 -421
- package/tests/sudo.test.ts +0 -676
- package/tests/to-one-include-access-filter.test.ts +0 -172
- package/tests/transaction-boundary-hooks.test.ts +0 -710
- package/tests/transaction-boundary-outermost.test.ts +0 -530
- package/tests/virtual-fields.test.ts +0 -421
- package/tests/with-session.test.ts +0 -243
- package/tests/write-pipeline.test.ts +0 -617
- package/tsconfig.json +0 -12
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -69
|
@@ -1,710 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
|
-
import { getContext } from '../src/context/index.js'
|
|
3
|
-
import { config, list } from '../src/config/index.js'
|
|
4
|
-
import { text, relationship } from '../src/fields/index.js'
|
|
5
|
-
import { enumerateInvolvedLists } from '../src/context/transaction-boundary.js'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* #590 / ADR-0010: transaction-boundary hooks (`beforeTransaction` /
|
|
9
|
-
* `afterTransaction`) run OUTSIDE the write's transaction — `beforeTransaction`
|
|
10
|
-
* before it opens, `afterTransaction` after it settles (always, with the
|
|
11
|
-
* commit/rollback outcome). They form a per-list compensation bracket around the
|
|
12
|
-
* atomic write.
|
|
13
|
-
*
|
|
14
|
-
* These tests reuse a transaction-aware in-memory Prisma mock (mirroring
|
|
15
|
-
* nested-write-hooks.test.ts) so they can assert commit/rollback outcomes, the
|
|
16
|
-
* symmetric-bracket always-run rule, per-list firing across nested writes,
|
|
17
|
-
* compensation when an afterTransaction itself throws, field-level variants, and
|
|
18
|
-
* that sudo does not affect these hooks.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
function createTxPrisma(extraTables: string[] = []) {
|
|
22
|
-
const tables: Record<string, Map<string, Record<string, unknown>>> = {
|
|
23
|
-
post: new Map(),
|
|
24
|
-
user: new Map(),
|
|
25
|
-
comment: new Map(),
|
|
26
|
-
}
|
|
27
|
-
for (const table of extraTables) tables[table] = new Map()
|
|
28
|
-
let idCounter = 0
|
|
29
|
-
const nextId = () => `id-${++idCounter}`
|
|
30
|
-
|
|
31
|
-
function applyNested(
|
|
32
|
-
table: string,
|
|
33
|
-
record: Record<string, unknown>,
|
|
34
|
-
data: Record<string, unknown>,
|
|
35
|
-
): Record<string, unknown> {
|
|
36
|
-
const result = { ...record }
|
|
37
|
-
for (const [key, value] of Object.entries(data)) {
|
|
38
|
-
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
39
|
-
const nested = value as Record<string, unknown>
|
|
40
|
-
if (nested.create || nested.update || nested.delete || nested.connect) {
|
|
41
|
-
const relTable = key === 'author' ? 'user' : key === 'comments' ? 'comment' : key
|
|
42
|
-
const linkField = `${key}Link`
|
|
43
|
-
if (nested.create) {
|
|
44
|
-
const created = doCreate(relTable, nested.create as Record<string, unknown>)
|
|
45
|
-
result[linkField] = created.id
|
|
46
|
-
result[key] = created
|
|
47
|
-
}
|
|
48
|
-
if (nested.update) {
|
|
49
|
-
const upd = nested.update as { where: { id: string }; data: Record<string, unknown> }
|
|
50
|
-
const updated = doUpdate(relTable, upd.where, upd.data)
|
|
51
|
-
result[key] = updated
|
|
52
|
-
}
|
|
53
|
-
if (nested.delete) {
|
|
54
|
-
const del = nested.delete as { id: string }
|
|
55
|
-
doDelete(relTable, del)
|
|
56
|
-
result[key] = null
|
|
57
|
-
}
|
|
58
|
-
continue
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
result[key] = value
|
|
62
|
-
}
|
|
63
|
-
return result
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function doCreate(table: string, data: Record<string, unknown>): Record<string, unknown> {
|
|
67
|
-
const id = (data.id as string) ?? nextId()
|
|
68
|
-
let record: Record<string, unknown> = { id }
|
|
69
|
-
record = applyNested(table, record, data)
|
|
70
|
-
tables[table].set(id, record)
|
|
71
|
-
return record
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function doUpdate(
|
|
75
|
-
table: string,
|
|
76
|
-
where: { id: string },
|
|
77
|
-
data: Record<string, unknown>,
|
|
78
|
-
): Record<string, unknown> {
|
|
79
|
-
const existing = tables[table].get(where.id) ?? { id: where.id }
|
|
80
|
-
const updated = applyNested(table, existing, data)
|
|
81
|
-
tables[table].set(where.id, updated)
|
|
82
|
-
return updated
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function doDelete(table: string, where: { id: string }): Record<string, unknown> {
|
|
86
|
-
const existing = tables[table].get(where.id) ?? { id: where.id }
|
|
87
|
-
tables[table].delete(where.id)
|
|
88
|
-
return existing
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function makeModel(table: string) {
|
|
92
|
-
return {
|
|
93
|
-
findUnique: vi.fn(
|
|
94
|
-
async ({ where }: { where: { id: string } }) => tables[table].get(where.id) ?? null,
|
|
95
|
-
),
|
|
96
|
-
findFirst: vi.fn(async ({ where }: { where?: { id?: string } }) => {
|
|
97
|
-
if (where?.id) return tables[table].get(where.id) ?? null
|
|
98
|
-
return tables[table].values().next().value ?? null
|
|
99
|
-
}),
|
|
100
|
-
findMany: vi.fn(async () => Array.from(tables[table].values())),
|
|
101
|
-
count: vi.fn(async () => tables[table].size),
|
|
102
|
-
create: vi.fn(async ({ data }: { data: Record<string, unknown> }) => doCreate(table, data)),
|
|
103
|
-
update: vi.fn(
|
|
104
|
-
async ({ where, data }: { where: { id: string }; data: Record<string, unknown> }) =>
|
|
105
|
-
doUpdate(table, where, data),
|
|
106
|
-
),
|
|
107
|
-
delete: vi.fn(async ({ where }: { where: { id: string } }) => doDelete(table, where)),
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const client: Record<string, unknown> = {
|
|
112
|
-
post: makeModel('post'),
|
|
113
|
-
user: makeModel('user'),
|
|
114
|
-
comment: makeModel('comment'),
|
|
115
|
-
}
|
|
116
|
-
for (const table of extraTables) client[table] = makeModel(table)
|
|
117
|
-
|
|
118
|
-
client.$transaction = async (fn: (tx: unknown) => Promise<unknown>) => {
|
|
119
|
-
const snapshot: Record<string, Map<string, Record<string, unknown>>> = {}
|
|
120
|
-
for (const [name, map] of Object.entries(tables)) {
|
|
121
|
-
snapshot[name] = new Map(map)
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
return await fn(client)
|
|
125
|
-
} catch (err) {
|
|
126
|
-
for (const [name, map] of Object.entries(snapshot)) {
|
|
127
|
-
tables[name] = map
|
|
128
|
-
}
|
|
129
|
-
throw err
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return { client, tables }
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
describe('#590 transaction-boundary hooks', () => {
|
|
137
|
-
let mock: ReturnType<typeof createTxPrisma>
|
|
138
|
-
|
|
139
|
-
beforeEach(() => {
|
|
140
|
-
mock = createTxPrisma()
|
|
141
|
-
vi.clearAllMocks()
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
it('commit path: afterTransaction fires with status committed + the persisted item', async () => {
|
|
145
|
-
const before = vi.fn()
|
|
146
|
-
const after = vi.fn()
|
|
147
|
-
|
|
148
|
-
const testConfig = config({
|
|
149
|
-
db: { provider: 'postgresql', url: 'postgresql://localhost:5432/test' },
|
|
150
|
-
lists: {
|
|
151
|
-
User: list({
|
|
152
|
-
fields: { name: text() },
|
|
153
|
-
access: { operation: { query: () => true, create: () => true } },
|
|
154
|
-
hooks: { beforeTransaction: before, afterTransaction: after },
|
|
155
|
-
}),
|
|
156
|
-
},
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
const context = getContext(await testConfig, mock.client, { userId: '1' })
|
|
160
|
-
const created = await context.db.user.create({ data: { name: 'jane' } })
|
|
161
|
-
|
|
162
|
-
expect(created).toBeTruthy()
|
|
163
|
-
expect(before).toHaveBeenCalledWith(
|
|
164
|
-
expect.objectContaining({ operation: 'create', listKey: 'User' }),
|
|
165
|
-
)
|
|
166
|
-
expect(after).toHaveBeenCalledTimes(1)
|
|
167
|
-
const arg = after.mock.calls[0][0]
|
|
168
|
-
expect(arg.status).toBe('committed')
|
|
169
|
-
expect(arg.item).toEqual(expect.objectContaining({ name: 'jane' }))
|
|
170
|
-
expect(arg.error).toBeUndefined()
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
it('beforeTransaction runs before the transaction opens (no writes yet)', async () => {
|
|
174
|
-
const order: string[] = []
|
|
175
|
-
const testConfig = config({
|
|
176
|
-
db: { provider: 'postgresql', url: 'postgresql://localhost:5432/test' },
|
|
177
|
-
lists: {
|
|
178
|
-
User: list({
|
|
179
|
-
fields: { name: text() },
|
|
180
|
-
access: { operation: { query: () => true, create: () => true } },
|
|
181
|
-
hooks: {
|
|
182
|
-
beforeTransaction: () => {
|
|
183
|
-
// No rows persisted at this point.
|
|
184
|
-
order.push(`before:size=${mock.tables.user.size}`)
|
|
185
|
-
},
|
|
186
|
-
afterTransaction: () => {
|
|
187
|
-
order.push(`after:size=${mock.tables.user.size}`)
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
}),
|
|
191
|
-
},
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
const context = getContext(await testConfig, mock.client, { userId: '1' })
|
|
195
|
-
await context.db.user.create({ data: { name: 'jane' } })
|
|
196
|
-
|
|
197
|
-
expect(order).toEqual(['before:size=0', 'after:size=1'])
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
it('rollback path (thrown afterOperation): afterTransaction fires rolled-back + error + no item', async () => {
|
|
201
|
-
const after = vi.fn()
|
|
202
|
-
|
|
203
|
-
const testConfig = config({
|
|
204
|
-
db: { provider: 'postgresql', url: 'postgresql://localhost:5432/test' },
|
|
205
|
-
lists: {
|
|
206
|
-
User: list({
|
|
207
|
-
fields: { name: text() },
|
|
208
|
-
access: { operation: { query: () => true, create: () => true } },
|
|
209
|
-
hooks: {
|
|
210
|
-
// In-transaction afterOperation throws → the transaction rolls back.
|
|
211
|
-
afterOperation: async () => {
|
|
212
|
-
throw new Error('in-tx boom')
|
|
213
|
-
},
|
|
214
|
-
afterTransaction: after,
|
|
215
|
-
},
|
|
216
|
-
}),
|
|
217
|
-
},
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
const context = getContext(await testConfig, mock.client, { userId: '1' })
|
|
221
|
-
|
|
222
|
-
await expect(context.db.user.create({ data: { name: 'jane' } })).rejects.toThrow('in-tx boom')
|
|
223
|
-
|
|
224
|
-
expect(after).toHaveBeenCalledTimes(1)
|
|
225
|
-
const arg = after.mock.calls[0][0]
|
|
226
|
-
expect(arg.status).toBe('rolled-back')
|
|
227
|
-
expect(arg.error).toBeInstanceOf(Error)
|
|
228
|
-
expect((arg.error as Error).message).toBe('in-tx boom')
|
|
229
|
-
expect(arg.item).toBeUndefined()
|
|
230
|
-
expect(arg.inputData).toEqual(expect.objectContaining({ name: 'jane' }))
|
|
231
|
-
// Nothing persisted.
|
|
232
|
-
expect(mock.tables.user.size).toBe(0)
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
it('a thrown beforeTransaction aborts the write and fires afterTransaction only for already-run lists', async () => {
|
|
236
|
-
const events: string[] = []
|
|
237
|
-
|
|
238
|
-
const testConfig = config({
|
|
239
|
-
db: { provider: 'postgresql', url: 'postgresql://localhost:5432/test' },
|
|
240
|
-
lists: {
|
|
241
|
-
User: list({
|
|
242
|
-
fields: { name: text() },
|
|
243
|
-
access: { operation: { query: () => true, create: () => true } },
|
|
244
|
-
hooks: {
|
|
245
|
-
// The nested User's beforeTransaction throws.
|
|
246
|
-
beforeTransaction: () => {
|
|
247
|
-
events.push('user:before')
|
|
248
|
-
throw new Error('user before boom')
|
|
249
|
-
},
|
|
250
|
-
afterTransaction: ({ status }) => {
|
|
251
|
-
events.push(`user:after:${status}`)
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
}),
|
|
255
|
-
// A list that is NOT involved in the write — must get neither hook.
|
|
256
|
-
Comment: list({
|
|
257
|
-
fields: { body: text() },
|
|
258
|
-
access: { operation: { query: () => true, create: () => true } },
|
|
259
|
-
hooks: {
|
|
260
|
-
beforeTransaction: () => events.push('comment:before'),
|
|
261
|
-
afterTransaction: () => events.push('comment:after'),
|
|
262
|
-
},
|
|
263
|
-
}),
|
|
264
|
-
Post: list({
|
|
265
|
-
fields: {
|
|
266
|
-
title: text(),
|
|
267
|
-
author: relationship({ ref: 'User.posts' }),
|
|
268
|
-
},
|
|
269
|
-
access: { operation: { query: () => true, create: () => true } },
|
|
270
|
-
hooks: {
|
|
271
|
-
beforeTransaction: () => events.push('post:before'),
|
|
272
|
-
afterTransaction: ({ status }) => events.push(`post:after:${status}`),
|
|
273
|
-
},
|
|
274
|
-
}),
|
|
275
|
-
},
|
|
276
|
-
})
|
|
277
|
-
|
|
278
|
-
const context = getContext(await testConfig, mock.client, { userId: '1' })
|
|
279
|
-
|
|
280
|
-
await expect(
|
|
281
|
-
context.db.post.create({ data: { title: 'T', author: { create: { name: 'x' } } } }),
|
|
282
|
-
).rejects.toThrow('user before boom')
|
|
283
|
-
|
|
284
|
-
// Post (top-level) beforeTransaction ran, then User's threw. Both ran-lists
|
|
285
|
-
// get a rolled-back afterTransaction; the unrelated Comment list gets nothing;
|
|
286
|
-
// the transaction was never opened (no persistence).
|
|
287
|
-
expect(events).toContain('post:before')
|
|
288
|
-
expect(events).toContain('user:before')
|
|
289
|
-
expect(events).toContain('post:after:rolled-back')
|
|
290
|
-
expect(events).toContain('user:after:rolled-back')
|
|
291
|
-
expect(events).not.toContain('comment:before')
|
|
292
|
-
expect(events).not.toContain('comment:after')
|
|
293
|
-
expect(mock.tables.post.size).toBe(0)
|
|
294
|
-
expect(mock.tables.user.size).toBe(0)
|
|
295
|
-
})
|
|
296
|
-
|
|
297
|
-
it('fires per list across a nested write (parent + nested list both bracketed)', async () => {
|
|
298
|
-
const userAfter = vi.fn()
|
|
299
|
-
const postAfter = vi.fn()
|
|
300
|
-
|
|
301
|
-
const testConfig = config({
|
|
302
|
-
db: { provider: 'postgresql', url: 'postgresql://localhost:5432/test' },
|
|
303
|
-
lists: {
|
|
304
|
-
User: list({
|
|
305
|
-
fields: { name: text() },
|
|
306
|
-
access: { operation: { query: () => true, create: () => true, update: () => true } },
|
|
307
|
-
hooks: { beforeTransaction: vi.fn(), afterTransaction: userAfter },
|
|
308
|
-
}),
|
|
309
|
-
Post: list({
|
|
310
|
-
fields: { title: text(), author: relationship({ ref: 'User.posts' }) },
|
|
311
|
-
access: { operation: { query: () => true, update: () => true } },
|
|
312
|
-
hooks: { beforeTransaction: vi.fn(), afterTransaction: postAfter },
|
|
313
|
-
}),
|
|
314
|
-
},
|
|
315
|
-
})
|
|
316
|
-
|
|
317
|
-
mock.tables.post.set('p1', { id: 'p1', title: 'Original' })
|
|
318
|
-
|
|
319
|
-
const context = getContext(await testConfig, mock.client, { userId: '1' })
|
|
320
|
-
await context.db.post.update({
|
|
321
|
-
where: { id: 'p1' },
|
|
322
|
-
data: { title: 'Updated', author: { create: { name: 'john' } } },
|
|
323
|
-
})
|
|
324
|
-
|
|
325
|
-
expect(postAfter).toHaveBeenCalledWith(
|
|
326
|
-
expect.objectContaining({ status: 'committed', operation: 'update', listKey: 'Post' }),
|
|
327
|
-
)
|
|
328
|
-
expect(userAfter).toHaveBeenCalledWith(
|
|
329
|
-
expect.objectContaining({ status: 'committed', operation: 'create', listKey: 'User' }),
|
|
330
|
-
)
|
|
331
|
-
|
|
332
|
-
// The committed item/originalItem are surfaced ONLY for the top-level record.
|
|
333
|
-
// The top-level Post (update) gets the persisted item + its originalItem; the
|
|
334
|
-
// nested User (create) gets `item: undefined` — NOT the top-level Post row,
|
|
335
|
-
// which would be the wrong record for the nested list's own item type.
|
|
336
|
-
const postArg = postAfter.mock.calls[0][0]
|
|
337
|
-
expect(postArg.item).toEqual(expect.objectContaining({ id: 'p1', title: 'Updated' }))
|
|
338
|
-
expect(postArg.originalItem).toEqual(expect.objectContaining({ id: 'p1', title: 'Original' }))
|
|
339
|
-
|
|
340
|
-
const userArg = userAfter.mock.calls[0][0]
|
|
341
|
-
expect(userArg.item).toBeUndefined()
|
|
342
|
-
// Nested compensation keys off inputData, not the (unavailable) persisted row.
|
|
343
|
-
expect(userArg.inputData).toEqual(expect.objectContaining({ name: 'john' }))
|
|
344
|
-
})
|
|
345
|
-
|
|
346
|
-
it('a throwing afterTransaction does not prevent the other afterTransaction hooks running', async () => {
|
|
347
|
-
const fired: string[] = []
|
|
348
|
-
|
|
349
|
-
const testConfig = config({
|
|
350
|
-
db: { provider: 'postgresql', url: 'postgresql://localhost:5432/test' },
|
|
351
|
-
lists: {
|
|
352
|
-
User: list({
|
|
353
|
-
fields: { name: text() },
|
|
354
|
-
access: { operation: { query: () => true, create: () => true, update: () => true } },
|
|
355
|
-
hooks: {
|
|
356
|
-
afterTransaction: () => {
|
|
357
|
-
fired.push('user')
|
|
358
|
-
throw new Error('user after boom')
|
|
359
|
-
},
|
|
360
|
-
},
|
|
361
|
-
}),
|
|
362
|
-
Post: list({
|
|
363
|
-
fields: { title: text(), author: relationship({ ref: 'User.posts' }) },
|
|
364
|
-
access: { operation: { query: () => true, update: () => true } },
|
|
365
|
-
hooks: {
|
|
366
|
-
afterTransaction: () => {
|
|
367
|
-
fired.push('post')
|
|
368
|
-
},
|
|
369
|
-
},
|
|
370
|
-
}),
|
|
371
|
-
},
|
|
372
|
-
})
|
|
373
|
-
|
|
374
|
-
mock.tables.post.set('p1', { id: 'p1', title: 'Original' })
|
|
375
|
-
|
|
376
|
-
const context = getContext(await testConfig, mock.client, { userId: '1' })
|
|
377
|
-
|
|
378
|
-
// The write itself committed; surfaced error is the afterTransaction failure.
|
|
379
|
-
await expect(
|
|
380
|
-
context.db.post.update({
|
|
381
|
-
where: { id: 'p1' },
|
|
382
|
-
data: { title: 'Updated', author: { create: { name: 'john' } } },
|
|
383
|
-
}),
|
|
384
|
-
).rejects.toThrow(/afterTransaction hook\(s\) failed/)
|
|
385
|
-
|
|
386
|
-
// Both compensators fired even though one threw.
|
|
387
|
-
expect(fired).toEqual(expect.arrayContaining(['post', 'user']))
|
|
388
|
-
// DB state is final (the write committed).
|
|
389
|
-
expect((mock.tables.post.get('p1') as Record<string, unknown>).title).toBe('Updated')
|
|
390
|
-
})
|
|
391
|
-
|
|
392
|
-
it('field-level beforeTransaction / afterTransaction variants fire', async () => {
|
|
393
|
-
const fieldBefore = vi.fn()
|
|
394
|
-
const fieldAfter = vi.fn()
|
|
395
|
-
|
|
396
|
-
const testConfig = config({
|
|
397
|
-
db: { provider: 'postgresql', url: 'postgresql://localhost:5432/test' },
|
|
398
|
-
lists: {
|
|
399
|
-
User: list({
|
|
400
|
-
fields: {
|
|
401
|
-
name: text({
|
|
402
|
-
hooks: { beforeTransaction: fieldBefore, afterTransaction: fieldAfter },
|
|
403
|
-
}),
|
|
404
|
-
},
|
|
405
|
-
access: { operation: { query: () => true, create: () => true } },
|
|
406
|
-
}),
|
|
407
|
-
},
|
|
408
|
-
})
|
|
409
|
-
|
|
410
|
-
const context = getContext(await testConfig, mock.client, { userId: '1' })
|
|
411
|
-
await context.db.user.create({ data: { name: 'jane' } })
|
|
412
|
-
|
|
413
|
-
expect(fieldBefore).toHaveBeenCalledWith(
|
|
414
|
-
expect.objectContaining({ operation: 'create', fieldKey: 'name' }),
|
|
415
|
-
)
|
|
416
|
-
expect(fieldAfter).toHaveBeenCalledWith(
|
|
417
|
-
expect.objectContaining({ status: 'committed', operation: 'create', fieldKey: 'name' }),
|
|
418
|
-
)
|
|
419
|
-
})
|
|
420
|
-
|
|
421
|
-
it('sudo path still runs transaction-boundary hooks', async () => {
|
|
422
|
-
const before = vi.fn()
|
|
423
|
-
const after = vi.fn()
|
|
424
|
-
|
|
425
|
-
const testConfig = config({
|
|
426
|
-
db: { provider: 'postgresql', url: 'postgresql://localhost:5432/test' },
|
|
427
|
-
lists: {
|
|
428
|
-
User: list({
|
|
429
|
-
fields: { name: text() },
|
|
430
|
-
// create access denies normally; sudo bypasses access only.
|
|
431
|
-
access: { operation: { query: () => true, create: () => false } },
|
|
432
|
-
hooks: { beforeTransaction: before, afterTransaction: after },
|
|
433
|
-
}),
|
|
434
|
-
},
|
|
435
|
-
})
|
|
436
|
-
|
|
437
|
-
const context = getContext(await testConfig, mock.client, { userId: '1' }).sudo()
|
|
438
|
-
const created = await context.db.user.create({ data: { name: 'sudo-made' } })
|
|
439
|
-
|
|
440
|
-
expect(created).toBeTruthy()
|
|
441
|
-
expect(before).toHaveBeenCalledTimes(1)
|
|
442
|
-
expect(after).toHaveBeenCalledWith(expect.objectContaining({ status: 'committed' }))
|
|
443
|
-
})
|
|
444
|
-
|
|
445
|
-
it('access-denied (non-sudo) write fires NEITHER transaction-boundary hook', async () => {
|
|
446
|
-
const before = vi.fn()
|
|
447
|
-
const after = vi.fn()
|
|
448
|
-
|
|
449
|
-
const testConfig = config({
|
|
450
|
-
db: { provider: 'postgresql', url: 'postgresql://localhost:5432/test' },
|
|
451
|
-
lists: {
|
|
452
|
-
User: list({
|
|
453
|
-
fields: { name: text() },
|
|
454
|
-
access: { operation: { query: () => true, create: () => false } },
|
|
455
|
-
hooks: { beforeTransaction: before, afterTransaction: after },
|
|
456
|
-
}),
|
|
457
|
-
},
|
|
458
|
-
})
|
|
459
|
-
|
|
460
|
-
const context = getContext(await testConfig, mock.client, { userId: '1' })
|
|
461
|
-
const created = await context.db.user.create({ data: { name: 'jane' } })
|
|
462
|
-
|
|
463
|
-
// Silent failure: a denied create returns null and takes no external action.
|
|
464
|
-
expect(created).toBeNull()
|
|
465
|
-
expect(before).not.toHaveBeenCalled()
|
|
466
|
-
expect(after).not.toHaveBeenCalled()
|
|
467
|
-
})
|
|
468
|
-
})
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* #835: `enumerateInvolvedLists`'s walk used to stop at a fixed depth cap
|
|
472
|
-
* (`MAX_DEPTH = 5`), so lists reachable only past it never entered the
|
|
473
|
-
* involved-list set and their transaction-boundary hooks silently never fired.
|
|
474
|
-
* The fix replaces the depth cap with a saturation bound computed from the
|
|
475
|
-
* CONFIG's relationship graph reachable from the top-level list: the walk
|
|
476
|
-
* stops once every (list, operation) pair it could ever find has been
|
|
477
|
-
* recorded, regardless of how deep the payload nests.
|
|
478
|
-
*/
|
|
479
|
-
describe('#835 enumerateInvolvedLists — saturation-bound enumeration walk', () => {
|
|
480
|
-
function chainConfigLists(length: number) {
|
|
481
|
-
const lists: Record<string, ReturnType<typeof list>> = {}
|
|
482
|
-
for (let i = 1; i <= length; i++) {
|
|
483
|
-
const name = `L${i}`
|
|
484
|
-
const fields: Record<string, ReturnType<typeof text> | ReturnType<typeof relationship>> = {
|
|
485
|
-
name: text(),
|
|
486
|
-
}
|
|
487
|
-
if (i < length) {
|
|
488
|
-
fields[`l${i + 1}`] = relationship({ ref: `L${i + 1}` })
|
|
489
|
-
}
|
|
490
|
-
lists[name] = list({ fields })
|
|
491
|
-
}
|
|
492
|
-
return lists
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
function chainInputData(length: number): Record<string, unknown> {
|
|
496
|
-
let payload: Record<string, unknown> = { name: `r${length}` }
|
|
497
|
-
for (let i = length - 1; i >= 1; i--) {
|
|
498
|
-
payload = { name: `r${i}`, [`l${i + 1}`]: { create: payload } }
|
|
499
|
-
}
|
|
500
|
-
return payload
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
it('enumerates every list in an 8-list chain, deeper than the old fixed depth cap of 5', async () => {
|
|
504
|
-
const resolvedConfig = await config({
|
|
505
|
-
db: { provider: 'postgresql', url: 'postgresql://localhost:5432/test' },
|
|
506
|
-
lists: chainConfigLists(8),
|
|
507
|
-
})
|
|
508
|
-
|
|
509
|
-
const involved = enumerateInvolvedLists({
|
|
510
|
-
listName: 'L1',
|
|
511
|
-
listConfig: resolvedConfig.lists.L1,
|
|
512
|
-
operation: 'create',
|
|
513
|
-
inputData: chainInputData(8),
|
|
514
|
-
topLevelOriginalItem: undefined,
|
|
515
|
-
config: resolvedConfig,
|
|
516
|
-
})
|
|
517
|
-
|
|
518
|
-
expect(involved.map((i) => i.listKey)).toEqual(['L1', 'L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'L8'])
|
|
519
|
-
expect(involved.map((i) => i.operation)).toEqual(Array(8).fill('create'))
|
|
520
|
-
// The top-level list is first and is the only one marked isTopLevel.
|
|
521
|
-
expect(involved[0].isTopLevel).toBe(true)
|
|
522
|
-
expect(involved.slice(1).every((i) => !i.isTopLevel)).toBe(true)
|
|
523
|
-
})
|
|
524
|
-
|
|
525
|
-
it('dedupes by (list, operation) when a list is nested many times in one payload', async () => {
|
|
526
|
-
const resolvedConfig = await config({
|
|
527
|
-
db: { provider: 'postgresql', url: 'postgresql://localhost:5432/test' },
|
|
528
|
-
lists: {
|
|
529
|
-
Parent: list({
|
|
530
|
-
fields: { name: text(), children: relationship({ ref: 'Child', many: true }) },
|
|
531
|
-
}),
|
|
532
|
-
Child: list({ fields: { name: text() } }),
|
|
533
|
-
},
|
|
534
|
-
})
|
|
535
|
-
|
|
536
|
-
const involved = enumerateInvolvedLists({
|
|
537
|
-
listName: 'Parent',
|
|
538
|
-
listConfig: resolvedConfig.lists.Parent,
|
|
539
|
-
operation: 'create',
|
|
540
|
-
inputData: {
|
|
541
|
-
name: 'p',
|
|
542
|
-
children: { create: [{ name: 'c1' }, { name: 'c2' }, { name: 'c3' }] },
|
|
543
|
-
},
|
|
544
|
-
topLevelOriginalItem: undefined,
|
|
545
|
-
config: resolvedConfig,
|
|
546
|
-
})
|
|
547
|
-
|
|
548
|
-
// Three nested Child creates collapse into a single involvement — the
|
|
549
|
-
// hooks are a per-LIST compensation bracket, not per-record.
|
|
550
|
-
expect(involved.map((i) => `${i.listKey}:${i.operation}`)).toEqual([
|
|
551
|
-
'Parent:create',
|
|
552
|
-
'Child:create',
|
|
553
|
-
])
|
|
554
|
-
})
|
|
555
|
-
|
|
556
|
-
it('stops descending once every reachable (list, operation) pair is recorded, without inspecting payload past that point', async () => {
|
|
557
|
-
// Node self-references, so the reachable closure from Node is just
|
|
558
|
-
// {Node} — the saturation bound is 1 list * 3 operations = 3 pairs.
|
|
559
|
-
// Extra1/Extra2 are unrelated lists in the same config: if the bound were
|
|
560
|
-
// ever computed from the WHOLE config instead of the graph reachable
|
|
561
|
-
// from the write's own top-level list, the bound would be inflated to 9
|
|
562
|
-
// and this test's trap (below) would fire.
|
|
563
|
-
const resolvedConfig = await config({
|
|
564
|
-
db: { provider: 'postgresql', url: 'postgresql://localhost:5432/test' },
|
|
565
|
-
lists: {
|
|
566
|
-
Node: list({
|
|
567
|
-
fields: {
|
|
568
|
-
name: text(),
|
|
569
|
-
childrenA: relationship({ ref: 'Node', many: true }),
|
|
570
|
-
childrenB: relationship({ ref: 'Node', many: true }),
|
|
571
|
-
},
|
|
572
|
-
}),
|
|
573
|
-
Extra1: list({ fields: { name: text() } }),
|
|
574
|
-
Extra2: list({ fields: { name: text() } }),
|
|
575
|
-
},
|
|
576
|
-
})
|
|
577
|
-
|
|
578
|
-
// A payload entry that must NEVER be walked once the walk has saturated —
|
|
579
|
-
// reading its `childrenA` property throws, so any attempt to descend
|
|
580
|
-
// into it fails the test with a thrown error instead of relying on timing.
|
|
581
|
-
const trap: Record<string, unknown> = { name: 'trap' }
|
|
582
|
-
Object.defineProperty(trap, 'childrenA', {
|
|
583
|
-
enumerable: true,
|
|
584
|
-
get(): never {
|
|
585
|
-
throw new Error('walkNested must not descend past the saturation bound')
|
|
586
|
-
},
|
|
587
|
-
})
|
|
588
|
-
|
|
589
|
-
const involved = enumerateInvolvedLists({
|
|
590
|
-
listName: 'Node',
|
|
591
|
-
listConfig: resolvedConfig.lists.Node,
|
|
592
|
-
operation: 'create',
|
|
593
|
-
inputData: {
|
|
594
|
-
name: 'root',
|
|
595
|
-
// Completes the saturation bound: seed (Node:create) + Node:update +
|
|
596
|
-
// Node:delete = 3 pairs = the full reachable closure for Node.
|
|
597
|
-
childrenA: {
|
|
598
|
-
update: [{ where: { id: 'u1' }, data: { name: 'updated' } }],
|
|
599
|
-
delete: [{ id: 'd1' }],
|
|
600
|
-
},
|
|
601
|
-
// Processed after childrenA (insertion order) — by the time the walk
|
|
602
|
-
// reaches it, the bound is already saturated, so `trap` must never
|
|
603
|
-
// be descended into.
|
|
604
|
-
childrenB: { create: [trap] },
|
|
605
|
-
},
|
|
606
|
-
topLevelOriginalItem: undefined,
|
|
607
|
-
config: resolvedConfig,
|
|
608
|
-
})
|
|
609
|
-
|
|
610
|
-
expect(involved.map((i) => `${i.listKey}:${i.operation}`)).toEqual([
|
|
611
|
-
'Node:create',
|
|
612
|
-
'Node:update',
|
|
613
|
-
'Node:delete',
|
|
614
|
-
])
|
|
615
|
-
})
|
|
616
|
-
})
|
|
617
|
-
|
|
618
|
-
/**
|
|
619
|
-
* #835 integration: the enumeration fix must not change the (separately
|
|
620
|
-
* verified, and unrelated) fact that nested writes stay access-checked at
|
|
621
|
-
* every depth — `processNestedOperations`'s own depth guard was already dead
|
|
622
|
-
* code before this fix (neither recursive call site nor the Write Pipeline
|
|
623
|
-
* ever passed a depth), so nested access control was never gated by depth and
|
|
624
|
-
* remains that way.
|
|
625
|
-
*/
|
|
626
|
-
describe('#835 deep nested writes remain access-checked at every depth', () => {
|
|
627
|
-
function chainLists(length: number, denyCreateAt?: number) {
|
|
628
|
-
const lists: Record<string, ReturnType<typeof list>> = {}
|
|
629
|
-
for (let i = 1; i <= length; i++) {
|
|
630
|
-
const name = `L${i}`
|
|
631
|
-
const fields: Record<string, ReturnType<typeof text> | ReturnType<typeof relationship>> = {
|
|
632
|
-
name: text(),
|
|
633
|
-
}
|
|
634
|
-
if (i < length) {
|
|
635
|
-
fields[`l${i + 1}`] = relationship({ ref: `L${i + 1}` })
|
|
636
|
-
}
|
|
637
|
-
lists[name] = list({
|
|
638
|
-
fields,
|
|
639
|
-
access: {
|
|
640
|
-
operation: {
|
|
641
|
-
query: () => true,
|
|
642
|
-
create: () => denyCreateAt !== i,
|
|
643
|
-
update: () => true,
|
|
644
|
-
},
|
|
645
|
-
},
|
|
646
|
-
})
|
|
647
|
-
}
|
|
648
|
-
return lists
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
function chainInputData(length: number): Record<string, unknown> {
|
|
652
|
-
let payload: Record<string, unknown> = { name: `r${length}` }
|
|
653
|
-
for (let i = length - 1; i >= 1; i--) {
|
|
654
|
-
payload = { name: `r${i}`, [`l${i + 1}`]: { create: payload } }
|
|
655
|
-
}
|
|
656
|
-
return payload
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
it('throws when a nested create 6 levels deep is denied, even though 6 is past the old enumeration depth cap', async () => {
|
|
660
|
-
const tables = Array.from({ length: 8 }, (_, i) => `l${i + 1}`)
|
|
661
|
-
const mock = createTxPrisma(tables)
|
|
662
|
-
|
|
663
|
-
const testConfig = config({
|
|
664
|
-
db: { provider: 'postgresql', url: 'postgresql://localhost:5432/test' },
|
|
665
|
-
lists: chainLists(8, 6),
|
|
666
|
-
})
|
|
667
|
-
|
|
668
|
-
const context = getContext(await testConfig, mock.client, { userId: '1' })
|
|
669
|
-
|
|
670
|
-
await expect(context.db.l1.create({ data: chainInputData(8) })).rejects.toThrow(
|
|
671
|
-
/access denied/i,
|
|
672
|
-
)
|
|
673
|
-
|
|
674
|
-
// Nothing was persisted — the whole write was aborted by the denial.
|
|
675
|
-
for (const table of tables) {
|
|
676
|
-
expect(mock.tables[table].size).toBe(0)
|
|
677
|
-
}
|
|
678
|
-
})
|
|
679
|
-
|
|
680
|
-
it('fires beforeTransaction/afterTransaction for every list in an 8-list chain, including the deepest', async () => {
|
|
681
|
-
const tables = Array.from({ length: 8 }, (_, i) => `l${i + 1}`)
|
|
682
|
-
const mock = createTxPrisma(tables)
|
|
683
|
-
|
|
684
|
-
const fired: string[] = []
|
|
685
|
-
const lists = chainLists(8)
|
|
686
|
-
for (const [name, listConfig] of Object.entries(lists)) {
|
|
687
|
-
listConfig.hooks = {
|
|
688
|
-
beforeTransaction: () => {
|
|
689
|
-
fired.push(`before:${name}`)
|
|
690
|
-
},
|
|
691
|
-
afterTransaction: () => {
|
|
692
|
-
fired.push(`after:${name}`)
|
|
693
|
-
},
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
const testConfig = config({
|
|
698
|
-
db: { provider: 'postgresql', url: 'postgresql://localhost:5432/test' },
|
|
699
|
-
lists,
|
|
700
|
-
})
|
|
701
|
-
|
|
702
|
-
const context = getContext(await testConfig, mock.client, { userId: '1' })
|
|
703
|
-
await context.db.l1.create({ data: chainInputData(8) })
|
|
704
|
-
|
|
705
|
-
for (let i = 1; i <= 8; i++) {
|
|
706
|
-
expect(fired).toContain(`before:L${i}`)
|
|
707
|
-
expect(fired).toContain(`after:L${i}`)
|
|
708
|
-
}
|
|
709
|
-
})
|
|
710
|
-
})
|