@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,538 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { parseFilterQuery } from './parse.js'
|
|
3
|
-
import { buildFilterWhere } from './map.js'
|
|
4
|
-
import {
|
|
5
|
-
buildListFilterWhere,
|
|
6
|
-
collectFilterSpecs,
|
|
7
|
-
collectFilterSuggestions,
|
|
8
|
-
type FilterAccessArgs,
|
|
9
|
-
} from './collect.js'
|
|
10
|
-
import type { FilterSpec } from './types.js'
|
|
11
|
-
import { list } from '../config/index.js'
|
|
12
|
-
import {
|
|
13
|
-
text,
|
|
14
|
-
integer,
|
|
15
|
-
bigInt,
|
|
16
|
-
select,
|
|
17
|
-
checkbox,
|
|
18
|
-
timestamp,
|
|
19
|
-
relationship,
|
|
20
|
-
} from '../fields/index.js'
|
|
21
|
-
import type { OpenSaasConfig } from '../config/types.js'
|
|
22
|
-
import type { AccessContext } from '../access/types.js'
|
|
23
|
-
|
|
24
|
-
// A permissive session/context — no field on any list under test declares
|
|
25
|
-
// field-level `read` access unless a test says so, so every field is
|
|
26
|
-
// filterable/sortable by default (matching `checkFieldAccess`'s own
|
|
27
|
-
// allow-by-default for a field with no rule).
|
|
28
|
-
const noAccessArgs: FilterAccessArgs = {
|
|
29
|
-
session: null,
|
|
30
|
-
context: { _isSudo: false } as unknown as AccessContext,
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// ─────────────────────────────────────────────────────────────
|
|
34
|
-
// parseFilterQuery — the pure query-string → tokens boundary (ADR-0017)
|
|
35
|
-
// ─────────────────────────────────────────────────────────────
|
|
36
|
-
|
|
37
|
-
describe('parseFilterQuery', () => {
|
|
38
|
-
it('parses a bare word as a free-text token (field: null)', () => {
|
|
39
|
-
expect(parseFilterQuery('beta')).toEqual([
|
|
40
|
-
{ field: null, operator: 'eq', value: 'beta', raw: 'beta' },
|
|
41
|
-
])
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it('parses a field:value token with the default eq operator', () => {
|
|
45
|
-
expect(parseFilterQuery('role:Editor')).toEqual([
|
|
46
|
-
{ field: 'role', operator: 'eq', value: 'Editor', raw: 'role:Editor' },
|
|
47
|
-
])
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('parses comparison operators on a field token', () => {
|
|
51
|
-
expect(parseFilterQuery('orders:>5')).toEqual([
|
|
52
|
-
{ field: 'orders', operator: 'gt', value: '5', raw: 'orders:>5' },
|
|
53
|
-
])
|
|
54
|
-
expect(parseFilterQuery('orders:>=5')[0].operator).toBe('gte')
|
|
55
|
-
expect(parseFilterQuery('orders:<5')[0].operator).toBe('lt')
|
|
56
|
-
expect(parseFilterQuery('orders:<=5')[0].operator).toBe('lte')
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('keeps spaces inside a quoted value', () => {
|
|
60
|
-
expect(parseFilterQuery('name:"Ada Lovelace"')).toEqual([
|
|
61
|
-
{ field: 'name', operator: 'eq', value: 'Ada Lovelace', raw: 'name:"Ada Lovelace"' },
|
|
62
|
-
])
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('parses a bare quoted phrase as a single free-text token', () => {
|
|
66
|
-
expect(parseFilterQuery('"multi word"')).toEqual([
|
|
67
|
-
{ field: null, operator: 'eq', value: 'multi word', raw: '"multi word"' },
|
|
68
|
-
])
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it('parses implicit-AND: multiple whitespace-separated tokens', () => {
|
|
72
|
-
const tokens = parseFilterQuery('role:Editor status:Active orders:>5 name:"Ada Lovelace" beta')
|
|
73
|
-
expect(tokens.map((t) => ({ field: t.field, operator: t.operator, value: t.value }))).toEqual([
|
|
74
|
-
{ field: 'role', operator: 'eq', value: 'Editor' },
|
|
75
|
-
{ field: 'status', operator: 'eq', value: 'Active' },
|
|
76
|
-
{ field: 'orders', operator: 'gt', value: '5' },
|
|
77
|
-
{ field: 'name', operator: 'eq', value: 'Ada Lovelace' },
|
|
78
|
-
{ field: null, operator: 'eq', value: 'beta' },
|
|
79
|
-
])
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
it('collapses surrounding / repeated whitespace', () => {
|
|
83
|
-
expect(parseFilterQuery(' a b ').map((t) => t.value)).toEqual(['a', 'b'])
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('returns no tokens for an empty query', () => {
|
|
87
|
-
expect(parseFilterQuery('')).toEqual([])
|
|
88
|
-
expect(parseFilterQuery(' ')).toEqual([])
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it('never throws on odd input — a leading comparison on a bare word stays free text', () => {
|
|
92
|
-
expect(parseFilterQuery('>5')).toEqual([
|
|
93
|
-
{ field: null, operator: 'eq', value: '>5', raw: '>5' },
|
|
94
|
-
])
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
it('treats a URL scheme (`http://…`) as whole free text, not a field prefix', () => {
|
|
98
|
-
// `http:` must NOT be parsed as a `field:` prefix — the `//` after the
|
|
99
|
-
// colon marks a URL scheme, so the entire URL stays a free-text token.
|
|
100
|
-
expect(() => parseFilterQuery('http://x')).not.toThrow()
|
|
101
|
-
expect(parseFilterQuery('http://x')).toEqual([
|
|
102
|
-
{ field: null, operator: 'eq', value: 'http://x', raw: 'http://x' },
|
|
103
|
-
])
|
|
104
|
-
expect(parseFilterQuery('https://example.com/path?q=1')).toEqual([
|
|
105
|
-
{
|
|
106
|
-
field: null,
|
|
107
|
-
operator: 'eq',
|
|
108
|
-
value: 'https://example.com/path?q=1',
|
|
109
|
-
raw: 'https://example.com/path?q=1',
|
|
110
|
-
},
|
|
111
|
-
])
|
|
112
|
-
})
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
// ─────────────────────────────────────────────────────────────
|
|
116
|
-
// buildFilterWhere — tokens + specs → Prisma where (the mapping seam)
|
|
117
|
-
// ─────────────────────────────────────────────────────────────
|
|
118
|
-
|
|
119
|
-
// Small hand-rolled specs so the mapping is tested independently of the field
|
|
120
|
-
// builders.
|
|
121
|
-
const nameSpec: FilterSpec = {
|
|
122
|
-
operators: ['eq'],
|
|
123
|
-
freeText: true,
|
|
124
|
-
toCondition: (op, value) => (op === 'eq' ? { name: { contains: value } } : null),
|
|
125
|
-
suggestions: { valueSource: { kind: 'none' } },
|
|
126
|
-
}
|
|
127
|
-
const ordersSpec: FilterSpec = {
|
|
128
|
-
operators: ['eq', 'gt', 'gte', 'lt', 'lte'],
|
|
129
|
-
toCondition: (op, value) => {
|
|
130
|
-
if (!/^-?\d+$/.test(value)) return null
|
|
131
|
-
return { orders: { [op === 'eq' ? 'equals' : op]: Number(value) } }
|
|
132
|
-
},
|
|
133
|
-
suggestions: { valueSource: { kind: 'none' } },
|
|
134
|
-
}
|
|
135
|
-
const statusSpec: FilterSpec = {
|
|
136
|
-
operators: ['eq'],
|
|
137
|
-
toCondition: (op, value) =>
|
|
138
|
-
op === 'eq' && ['active', 'inactive'].includes(value.toLowerCase())
|
|
139
|
-
? { status: { equals: value.toLowerCase() } }
|
|
140
|
-
: null,
|
|
141
|
-
suggestions: {
|
|
142
|
-
valueSource: {
|
|
143
|
-
kind: 'enum',
|
|
144
|
-
options: [
|
|
145
|
-
{ value: 'active', label: 'Active' },
|
|
146
|
-
{ value: 'inactive', label: 'Inactive' },
|
|
147
|
-
],
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
}
|
|
151
|
-
const specs = { name: nameSpec, orders: ordersSpec, status: statusSpec }
|
|
152
|
-
|
|
153
|
-
describe('buildFilterWhere', () => {
|
|
154
|
-
it('returns undefined when nothing filters', () => {
|
|
155
|
-
expect(buildFilterWhere([], specs)).toBeUndefined()
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
it('maps a single field token to its condition (no AND wrapper)', () => {
|
|
159
|
-
expect(buildFilterWhere(parseFilterQuery('orders:>5'), specs)).toEqual({
|
|
160
|
-
orders: { gt: 5 },
|
|
161
|
-
})
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
it('maps eq on a numeric field to `equals`', () => {
|
|
165
|
-
expect(buildFilterWhere(parseFilterQuery('orders:5'), specs)).toEqual({
|
|
166
|
-
orders: { equals: 5 },
|
|
167
|
-
})
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
it('ANDs multiple field tokens (implicit AND)', () => {
|
|
171
|
-
expect(buildFilterWhere(parseFilterQuery('status:Active orders:>5'), specs)).toEqual({
|
|
172
|
-
AND: [{ status: { equals: 'active' } }, { orders: { gt: 5 } }],
|
|
173
|
-
})
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
it('maps a bare word to an OR across free-text fields', () => {
|
|
177
|
-
// Only `name` is free-text here.
|
|
178
|
-
expect(buildFilterWhere(parseFilterQuery('beta'), specs)).toEqual({
|
|
179
|
-
name: { contains: 'beta' },
|
|
180
|
-
})
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
it('ANDs multiple bare words (each word must match)', () => {
|
|
184
|
-
const multiFreeText = {
|
|
185
|
-
name: nameSpec,
|
|
186
|
-
title: {
|
|
187
|
-
...nameSpec,
|
|
188
|
-
toCondition: (op: 'eq' | 'gt' | 'gte' | 'lt' | 'lte', v: string) =>
|
|
189
|
-
op === 'eq' ? { title: { contains: v } } : null,
|
|
190
|
-
} as FilterSpec,
|
|
191
|
-
}
|
|
192
|
-
expect(buildFilterWhere(parseFilterQuery('beta gamma'), multiFreeText)).toEqual({
|
|
193
|
-
AND: [
|
|
194
|
-
{ OR: [{ name: { contains: 'beta' } }, { title: { contains: 'beta' } }] },
|
|
195
|
-
{ OR: [{ name: { contains: 'gamma' } }, { title: { contains: 'gamma' } }] },
|
|
196
|
-
],
|
|
197
|
-
})
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
// ─── Graceful degradation (ADR-0017): unknown syntax → free text, never error
|
|
201
|
-
it('degrades an unknown field to free text', () => {
|
|
202
|
-
// `role` has no spec → search "Editor" across free-text fields.
|
|
203
|
-
expect(buildFilterWhere(parseFilterQuery('role:Editor'), specs)).toEqual({
|
|
204
|
-
name: { contains: 'Editor' },
|
|
205
|
-
})
|
|
206
|
-
})
|
|
207
|
-
|
|
208
|
-
it('degrades an unsupported operator to free text', () => {
|
|
209
|
-
// `status` supports only eq → `status:>x` degrades, searching "x".
|
|
210
|
-
expect(buildFilterWhere(parseFilterQuery('status:>x'), specs)).toEqual({
|
|
211
|
-
name: { contains: 'x' },
|
|
212
|
-
})
|
|
213
|
-
})
|
|
214
|
-
|
|
215
|
-
it('degrades an unmappable value (non-numeric on a numeric field) to free text', () => {
|
|
216
|
-
expect(buildFilterWhere(parseFilterQuery('orders:abc'), specs)).toEqual({
|
|
217
|
-
name: { contains: 'abc' },
|
|
218
|
-
})
|
|
219
|
-
})
|
|
220
|
-
|
|
221
|
-
it('degrades an unknown enum value to free text', () => {
|
|
222
|
-
expect(buildFilterWhere(parseFilterQuery('status:pending'), specs)).toEqual({
|
|
223
|
-
name: { contains: 'pending' },
|
|
224
|
-
})
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
it('drops a degraded token entirely when there are no free-text fields', () => {
|
|
228
|
-
const noFreeText = { orders: ordersSpec }
|
|
229
|
-
expect(buildFilterWhere(parseFilterQuery('role:Editor'), noFreeText)).toBeUndefined()
|
|
230
|
-
})
|
|
231
|
-
|
|
232
|
-
it('searches a pasted URL as whole free text (scheme not dropped)', () => {
|
|
233
|
-
// `http://x` must be searched in full, not mangled to `//x` by a spurious
|
|
234
|
-
// `http:` field prefix.
|
|
235
|
-
expect(buildFilterWhere(parseFilterQuery('http://x'), specs)).toEqual({
|
|
236
|
-
name: { contains: 'http://x' },
|
|
237
|
-
})
|
|
238
|
-
expect(buildFilterWhere(parseFilterQuery('https://example.com'), specs)).toEqual({
|
|
239
|
-
name: { contains: 'https://example.com' },
|
|
240
|
-
})
|
|
241
|
-
})
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
// ─────────────────────────────────────────────────────────────
|
|
245
|
-
// Field-builder Filter specs + collect helpers (config-aware layer)
|
|
246
|
-
// ─────────────────────────────────────────────────────────────
|
|
247
|
-
|
|
248
|
-
function makeConfig(): OpenSaasConfig {
|
|
249
|
-
return {
|
|
250
|
-
db: { provider: 'sqlite', prismaClientConstructor: () => null as never },
|
|
251
|
-
lists: {
|
|
252
|
-
User: list({ fields: { name: text() } }),
|
|
253
|
-
Post: list({
|
|
254
|
-
fields: {
|
|
255
|
-
title: text(),
|
|
256
|
-
views: integer(),
|
|
257
|
-
occurredAtMs: bigInt(),
|
|
258
|
-
status: select({
|
|
259
|
-
options: [
|
|
260
|
-
{ label: 'Draft', value: 'draft' },
|
|
261
|
-
{ label: 'Published', value: 'published' },
|
|
262
|
-
],
|
|
263
|
-
}),
|
|
264
|
-
featured: checkbox(),
|
|
265
|
-
publishedAt: timestamp(),
|
|
266
|
-
author: relationship({ ref: 'User.posts' }),
|
|
267
|
-
},
|
|
268
|
-
}),
|
|
269
|
-
},
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
describe('core field Filter specs', () => {
|
|
274
|
-
const config = makeConfig()
|
|
275
|
-
const postConfig = config.lists.Post
|
|
276
|
-
|
|
277
|
-
it('collectFilterSpecs resolves a spec for every filterable core field', async () => {
|
|
278
|
-
const collected = await collectFilterSpecs(postConfig, 'Post', config, noAccessArgs)
|
|
279
|
-
expect(Object.keys(collected).sort()).toEqual(
|
|
280
|
-
['author', 'featured', 'occurredAtMs', 'publishedAt', 'status', 'title', 'views'].sort(),
|
|
281
|
-
)
|
|
282
|
-
})
|
|
283
|
-
|
|
284
|
-
it('text is free-text and maps to contains', () => {
|
|
285
|
-
const spec = postConfig.fields.title.getFilterSpec!('title', 'Post', config)!
|
|
286
|
-
expect(spec.freeText).toBe(true)
|
|
287
|
-
expect(spec.toCondition('eq', 'hello')).toEqual({ title: { contains: 'hello' } })
|
|
288
|
-
})
|
|
289
|
-
|
|
290
|
-
it('integer supports comparisons and rejects non-integers', () => {
|
|
291
|
-
const spec = postConfig.fields.views.getFilterSpec!('views', 'Post', config)!
|
|
292
|
-
expect(spec.toCondition('gt', '5')).toEqual({ views: { gt: 5 } })
|
|
293
|
-
expect(spec.toCondition('eq', '5')).toEqual({ views: { equals: 5 } })
|
|
294
|
-
expect(spec.toCondition('eq', 'abc')).toBeNull()
|
|
295
|
-
})
|
|
296
|
-
|
|
297
|
-
it('bigInt supports comparisons, emits a bigint condition, and rejects non-integers', () => {
|
|
298
|
-
const spec = postConfig.fields.occurredAtMs.getFilterSpec!('occurredAtMs', 'Post', config)!
|
|
299
|
-
expect(spec.toCondition('gt', '9007199254740993')).toEqual({
|
|
300
|
-
occurredAtMs: { gt: 9007199254740993n },
|
|
301
|
-
})
|
|
302
|
-
expect(spec.toCondition('eq', '5')).toEqual({ occurredAtMs: { equals: 5n } })
|
|
303
|
-
expect(spec.toCondition('eq', 'abc')).toBeNull()
|
|
304
|
-
expect(spec.toCondition('eq', '1.5')).toBeNull()
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
it('select matches by value or label and resolves to the stored value', () => {
|
|
308
|
-
const spec = postConfig.fields.status.getFilterSpec!('status', 'Post', config)!
|
|
309
|
-
expect(spec.toCondition('eq', 'Published')).toEqual({ status: { equals: 'published' } })
|
|
310
|
-
expect(spec.toCondition('eq', 'published')).toEqual({ status: { equals: 'published' } })
|
|
311
|
-
expect(spec.toCondition('eq', 'archived')).toBeNull()
|
|
312
|
-
expect(spec.suggestions.valueSource).toEqual({
|
|
313
|
-
kind: 'enum',
|
|
314
|
-
options: [
|
|
315
|
-
{ value: 'draft', label: 'Draft' },
|
|
316
|
-
{ value: 'published', label: 'Published' },
|
|
317
|
-
],
|
|
318
|
-
})
|
|
319
|
-
})
|
|
320
|
-
|
|
321
|
-
it('checkbox maps true/false and rejects anything else', () => {
|
|
322
|
-
const spec = postConfig.fields.featured.getFilterSpec!('featured', 'Post', config)!
|
|
323
|
-
expect(spec.toCondition('eq', 'true')).toEqual({ featured: { equals: true } })
|
|
324
|
-
expect(spec.toCondition('eq', 'False')).toEqual({ featured: { equals: false } })
|
|
325
|
-
expect(spec.toCondition('eq', 'yes')).toBeNull()
|
|
326
|
-
})
|
|
327
|
-
|
|
328
|
-
it('timestamp compares parsed dates and rejects unparseable values', () => {
|
|
329
|
-
const spec = postConfig.fields.publishedAt.getFilterSpec!('publishedAt', 'Post', config)!
|
|
330
|
-
const condition = spec.toCondition('gt', '2024-01-01') as { publishedAt: { gt: Date } }
|
|
331
|
-
expect(condition.publishedAt.gt).toBeInstanceOf(Date)
|
|
332
|
-
expect(spec.toCondition('gt', 'not-a-date')).toBeNull()
|
|
333
|
-
})
|
|
334
|
-
|
|
335
|
-
it('relationship maps to a nested label filter (is for to-one)', () => {
|
|
336
|
-
const spec = postConfig.fields.author.getFilterSpec!('author', 'Post', config)!
|
|
337
|
-
// User's label field falls back to `name`.
|
|
338
|
-
expect(spec.toCondition('eq', 'Ada')).toEqual({ author: { is: { name: { contains: 'Ada' } } } })
|
|
339
|
-
expect(spec.suggestions.valueSource).toEqual({
|
|
340
|
-
kind: 'relationship',
|
|
341
|
-
listKey: 'User',
|
|
342
|
-
many: false,
|
|
343
|
-
})
|
|
344
|
-
})
|
|
345
|
-
|
|
346
|
-
it('does not produce specs for password/json/virtual (absence degrades gracefully)', async () => {
|
|
347
|
-
// A list of non-filterable fields yields no specs at all.
|
|
348
|
-
const specsForUser = await collectFilterSpecs(config.lists.User, 'User', config, noAccessArgs)
|
|
349
|
-
// User only has `name` (text) → exactly one spec, proving non-text absence.
|
|
350
|
-
expect(Object.keys(specsForUser)).toEqual(['name'])
|
|
351
|
-
})
|
|
352
|
-
|
|
353
|
-
it('excludes a field the session cannot read (#915)', async () => {
|
|
354
|
-
const gatedConfig: OpenSaasConfig = {
|
|
355
|
-
db: { provider: 'sqlite', prismaClientConstructor: () => null as never },
|
|
356
|
-
lists: {
|
|
357
|
-
Organisation: list({
|
|
358
|
-
fields: {
|
|
359
|
-
name: text(),
|
|
360
|
-
billingAddress: text({ access: { read: () => false } }),
|
|
361
|
-
},
|
|
362
|
-
}),
|
|
363
|
-
},
|
|
364
|
-
}
|
|
365
|
-
const collected = await collectFilterSpecs(
|
|
366
|
-
gatedConfig.lists.Organisation,
|
|
367
|
-
'Organisation',
|
|
368
|
-
gatedConfig,
|
|
369
|
-
noAccessArgs,
|
|
370
|
-
)
|
|
371
|
-
expect(Object.keys(collected)).toEqual(['name'])
|
|
372
|
-
})
|
|
373
|
-
|
|
374
|
-
it('excludes a row-dependent read rule too — no row exists at predicate time (#915)', async () => {
|
|
375
|
-
const gatedConfig: OpenSaasConfig = {
|
|
376
|
-
db: { provider: 'sqlite', prismaClientConstructor: () => null as never },
|
|
377
|
-
lists: {
|
|
378
|
-
Organisation: list({
|
|
379
|
-
fields: {
|
|
380
|
-
name: text(),
|
|
381
|
-
billingAddress: text({
|
|
382
|
-
access: { read: ({ item, session }) => item.ownerId === session?.userId },
|
|
383
|
-
}),
|
|
384
|
-
},
|
|
385
|
-
}),
|
|
386
|
-
},
|
|
387
|
-
}
|
|
388
|
-
const collected = await collectFilterSpecs(
|
|
389
|
-
gatedConfig.lists.Organisation,
|
|
390
|
-
'Organisation',
|
|
391
|
-
gatedConfig,
|
|
392
|
-
noAccessArgs,
|
|
393
|
-
)
|
|
394
|
-
expect(Object.keys(collected)).toEqual(['name'])
|
|
395
|
-
})
|
|
396
|
-
})
|
|
397
|
-
|
|
398
|
-
describe('buildListFilterWhere (end-to-end over a real list config)', () => {
|
|
399
|
-
const config = makeConfig()
|
|
400
|
-
|
|
401
|
-
it('composes parse + specs into a merged where', async () => {
|
|
402
|
-
const where = await buildListFilterWhere(
|
|
403
|
-
'status:Published views:>10 author:"Ada" hello',
|
|
404
|
-
config.lists.Post,
|
|
405
|
-
'Post',
|
|
406
|
-
config,
|
|
407
|
-
noAccessArgs,
|
|
408
|
-
)
|
|
409
|
-
expect(where).toEqual({
|
|
410
|
-
AND: [
|
|
411
|
-
{ status: { equals: 'published' } },
|
|
412
|
-
{ views: { gt: 10 } },
|
|
413
|
-
{ author: { is: { name: { contains: 'Ada' } } } },
|
|
414
|
-
// `hello` is free text over the two text fields (title only — status is
|
|
415
|
-
// not free-text) → but title is the only free-text field here.
|
|
416
|
-
{ title: { contains: 'hello' } },
|
|
417
|
-
],
|
|
418
|
-
})
|
|
419
|
-
})
|
|
420
|
-
|
|
421
|
-
it('returns undefined for an all-whitespace query', async () => {
|
|
422
|
-
expect(
|
|
423
|
-
await buildListFilterWhere(' ', config.lists.Post, 'Post', config, noAccessArgs),
|
|
424
|
-
).toBeUndefined()
|
|
425
|
-
})
|
|
426
|
-
|
|
427
|
-
it('a read-denied field degrades to free text instead of reaching the engine (#915)', async () => {
|
|
428
|
-
const gatedConfig: OpenSaasConfig = {
|
|
429
|
-
db: { provider: 'sqlite', prismaClientConstructor: () => null as never },
|
|
430
|
-
lists: {
|
|
431
|
-
Organisation: list({
|
|
432
|
-
fields: {
|
|
433
|
-
name: text(),
|
|
434
|
-
billingAddress: text({ access: { read: () => false } }),
|
|
435
|
-
},
|
|
436
|
-
}),
|
|
437
|
-
},
|
|
438
|
-
}
|
|
439
|
-
// `billingAddress:12` never produces `{ billingAddress: { contains: '12' } }`
|
|
440
|
-
// — the spec is excluded, so the token degrades to a free-text search for
|
|
441
|
-
// "12" across `name` (the only remaining free-text field) instead.
|
|
442
|
-
const where = await buildListFilterWhere(
|
|
443
|
-
'billingAddress:12',
|
|
444
|
-
gatedConfig.lists.Organisation,
|
|
445
|
-
'Organisation',
|
|
446
|
-
gatedConfig,
|
|
447
|
-
noAccessArgs,
|
|
448
|
-
)
|
|
449
|
-
expect(where).toEqual({ name: { contains: '12' } })
|
|
450
|
-
})
|
|
451
|
-
})
|
|
452
|
-
|
|
453
|
-
describe('to-many relationship Filter spec (count comparisons — issue #732)', () => {
|
|
454
|
-
function countConfig(): OpenSaasConfig {
|
|
455
|
-
return {
|
|
456
|
-
db: { provider: 'sqlite', prismaClientConstructor: () => null as never },
|
|
457
|
-
lists: {
|
|
458
|
-
User: list({
|
|
459
|
-
fields: {
|
|
460
|
-
name: text(),
|
|
461
|
-
posts: relationship({ ref: 'Post.author', many: true }),
|
|
462
|
-
},
|
|
463
|
-
}),
|
|
464
|
-
Post: list({
|
|
465
|
-
fields: { title: text(), author: relationship({ ref: 'User.posts' }) },
|
|
466
|
-
}),
|
|
467
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- minimal config for unit test
|
|
468
|
-
} as any,
|
|
469
|
-
} as OpenSaasConfig
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
it('supports numeric comparisons and emits a count marker (not a label filter)', () => {
|
|
473
|
-
const config = countConfig()
|
|
474
|
-
const spec = config.lists.User.fields.posts.getFilterSpec!('posts', 'User', config)!
|
|
475
|
-
expect(spec.operators).toEqual(['eq', 'gt', 'gte', 'lt', 'lte'])
|
|
476
|
-
expect(spec.toCondition('gt', '5')).toEqual({
|
|
477
|
-
posts: { _countFilter: { operator: 'gt', value: 5 } },
|
|
478
|
-
})
|
|
479
|
-
expect(spec.toCondition('eq', '0')).toEqual({
|
|
480
|
-
posts: { _countFilter: { operator: 'eq', value: 0 } },
|
|
481
|
-
})
|
|
482
|
-
// A non-integer count degrades to free text (like an integer field).
|
|
483
|
-
expect(spec.toCondition('gt', 'lots')).toBeNull()
|
|
484
|
-
// No enumerated value source — a count is a plain numeric compare.
|
|
485
|
-
expect(spec.suggestions.valueSource).toEqual({ kind: 'none' })
|
|
486
|
-
})
|
|
487
|
-
|
|
488
|
-
it('end-to-end: buildListFilterWhere carries a count marker for `posts:>5`', async () => {
|
|
489
|
-
const config = countConfig()
|
|
490
|
-
const where = await buildListFilterWhere(
|
|
491
|
-
'posts:>5',
|
|
492
|
-
config.lists.User,
|
|
493
|
-
'User',
|
|
494
|
-
config,
|
|
495
|
-
noAccessArgs,
|
|
496
|
-
)
|
|
497
|
-
expect(where).toEqual({ posts: { _countFilter: { operator: 'gt', value: 5 } } })
|
|
498
|
-
})
|
|
499
|
-
})
|
|
500
|
-
|
|
501
|
-
describe('collectFilterSuggestions', () => {
|
|
502
|
-
it('returns serializable, function-free suggestion metadata', async () => {
|
|
503
|
-
const config = makeConfig()
|
|
504
|
-
const suggestions = await collectFilterSuggestions(
|
|
505
|
-
config.lists.Post,
|
|
506
|
-
'Post',
|
|
507
|
-
config,
|
|
508
|
-
noAccessArgs,
|
|
509
|
-
)
|
|
510
|
-
// No functions anywhere → JSON round-trips cleanly.
|
|
511
|
-
expect(JSON.parse(JSON.stringify(suggestions))).toEqual(suggestions)
|
|
512
|
-
const status = suggestions.find((s) => s.field === 'status')!
|
|
513
|
-
expect(status.valueSource.kind).toBe('enum')
|
|
514
|
-
const author = suggestions.find((s) => s.field === 'author')!
|
|
515
|
-
expect(author.valueSource).toEqual({ kind: 'relationship', listKey: 'User', many: false })
|
|
516
|
-
})
|
|
517
|
-
|
|
518
|
-
it('excludes a read-denied field from the suggestion metadata (#915)', async () => {
|
|
519
|
-
const gatedConfig: OpenSaasConfig = {
|
|
520
|
-
db: { provider: 'sqlite', prismaClientConstructor: () => null as never },
|
|
521
|
-
lists: {
|
|
522
|
-
Organisation: list({
|
|
523
|
-
fields: {
|
|
524
|
-
name: text(),
|
|
525
|
-
billingAddress: text({ access: { read: () => false } }),
|
|
526
|
-
},
|
|
527
|
-
}),
|
|
528
|
-
},
|
|
529
|
-
}
|
|
530
|
-
const suggestions = await collectFilterSuggestions(
|
|
531
|
-
gatedConfig.lists.Organisation,
|
|
532
|
-
'Organisation',
|
|
533
|
-
gatedConfig,
|
|
534
|
-
noAccessArgs,
|
|
535
|
-
)
|
|
536
|
-
expect(suggestions.map((s) => s.field)).toEqual(['name'])
|
|
537
|
-
})
|
|
538
|
-
})
|
package/src/filter/index.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// ───────────────────────────────────────────────────────────────
|
|
2
|
-
// Filter engine (ADR-0017)
|
|
3
|
-
//
|
|
4
|
-
// The pure boundary behind the admin UI's Filter builder:
|
|
5
|
-
// • parseFilterQuery — query string → Filter tokens
|
|
6
|
-
// • buildFilterWhere — tokens + Filter specs → Prisma where fragment
|
|
7
|
-
// plus config-aware helpers that collect each field's Filter spec and compose
|
|
8
|
-
// the two steps for a list. All of this stays free of DB/Prisma imports so the
|
|
9
|
-
// grammar contract (including graceful degradation) is unit-testable.
|
|
10
|
-
// ───────────────────────────────────────────────────────────────
|
|
11
|
-
|
|
12
|
-
export { parseFilterQuery } from './parse.js'
|
|
13
|
-
export { serializeFilterQuery } from './serialize.js'
|
|
14
|
-
export { buildFilterWhere } from './map.js'
|
|
15
|
-
export { collectFilterSpecs, buildListFilterWhere, collectFilterSuggestions } from './collect.js'
|
|
16
|
-
export type { FilterAccessArgs } from './collect.js'
|
|
17
|
-
export { RELATIONSHIP_COUNT_FILTER_KEY } from './types.js'
|
|
18
|
-
export type {
|
|
19
|
-
FilterOperator,
|
|
20
|
-
FilterToken,
|
|
21
|
-
FilterCondition,
|
|
22
|
-
FilterSpec,
|
|
23
|
-
FilterValueSource,
|
|
24
|
-
FilterFieldSuggestion,
|
|
25
|
-
RelationshipCountFilterMarker,
|
|
26
|
-
} from './types.js'
|
package/src/filter/map.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { FilterCondition, FilterSpec, FilterToken } from './types.js'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Map parsed {@link FilterToken}s to a single Prisma `where` fragment, given the
|
|
5
|
-
* fields' {@link FilterSpec}s (ADR-0017).
|
|
6
|
-
*
|
|
7
|
-
* Pure — no DB/Prisma imports. This is the unit-tested half of the filter seam.
|
|
8
|
-
* Tokens combine with implicit AND. A token degrades to free text (never an
|
|
9
|
-
* error) when its field is unknown, has no spec, uses an unsupported operator,
|
|
10
|
-
* has an empty value, or maps to `null`. Bare words (and degraded tokens) are
|
|
11
|
-
* OR-matched across every free-text field, and each such word is ANDed with the
|
|
12
|
-
* rest — so `beta gamma` requires both.
|
|
13
|
-
*
|
|
14
|
-
* @param tokens Parsed tokens from {@link parseFilterQuery}.
|
|
15
|
-
* @param specs Field-name → Filter spec (from {@link collectFilterSpecs}).
|
|
16
|
-
* @returns A Prisma `where` fragment, or `undefined` when nothing filters.
|
|
17
|
-
*/
|
|
18
|
-
export function buildFilterWhere(
|
|
19
|
-
tokens: FilterToken[],
|
|
20
|
-
specs: Record<string, FilterSpec>,
|
|
21
|
-
): FilterCondition | undefined {
|
|
22
|
-
const andConditions: FilterCondition[] = []
|
|
23
|
-
const freeTextWords: string[] = []
|
|
24
|
-
|
|
25
|
-
const freeTextFields = Object.keys(specs).filter((field) => specs[field].freeText)
|
|
26
|
-
|
|
27
|
-
for (const token of tokens) {
|
|
28
|
-
if (token.field === null) {
|
|
29
|
-
if (token.value) freeTextWords.push(token.value)
|
|
30
|
-
continue
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const spec = specs[token.field]
|
|
34
|
-
|
|
35
|
-
if (!spec || !spec.operators.includes(token.operator) || token.value === '') {
|
|
36
|
-
if (token.value) freeTextWords.push(token.value)
|
|
37
|
-
continue
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const condition = spec.toCondition(token.operator, token.value)
|
|
41
|
-
if (condition === null) {
|
|
42
|
-
freeTextWords.push(token.value)
|
|
43
|
-
continue
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
andConditions.push(condition)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (freeTextFields.length > 0) {
|
|
50
|
-
for (const word of freeTextWords) {
|
|
51
|
-
const orConditions = freeTextFields
|
|
52
|
-
.map((field) => specs[field].toCondition('eq', word))
|
|
53
|
-
.filter((condition): condition is FilterCondition => condition !== null)
|
|
54
|
-
if (orConditions.length > 0) {
|
|
55
|
-
andConditions.push(orConditions.length === 1 ? orConditions[0] : { OR: orConditions })
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (andConditions.length === 0) return undefined
|
|
61
|
-
if (andConditions.length === 1) return andConditions[0]
|
|
62
|
-
return { AND: andConditions }
|
|
63
|
-
}
|