@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
package/src/filter/parse.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import type { FilterOperator, FilterToken } from './types.js'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A field prefix is an identifier (letter/underscore, then word chars)
|
|
5
|
-
* immediately followed by a colon, e.g. `role:` or `orders:`.
|
|
6
|
-
*/
|
|
7
|
-
const FIELD_PREFIX_RE = /^([A-Za-z_][A-Za-z0-9_]*):/
|
|
8
|
-
|
|
9
|
-
function isWhitespace(ch: string): boolean {
|
|
10
|
-
return ch === ' ' || ch === '\t' || ch === '\n' || ch === '\r'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Parse a filter query string into {@link FilterToken}s (ADR-0017 grammar).
|
|
15
|
-
*
|
|
16
|
-
* Pure and field-agnostic: it recognises the *syntax* (field prefix, comparison
|
|
17
|
-
* operator, quoted value, bare word) but never validates field names or values
|
|
18
|
-
* — that is the mapping step's job, where unknown/unmappable tokens degrade to
|
|
19
|
-
* free text. This parser therefore never throws; malformed input simply parses
|
|
20
|
-
* as bare free-text words.
|
|
21
|
-
*
|
|
22
|
-
* Grammar:
|
|
23
|
-
* - `field:value` → a field token with the `eq` operator.
|
|
24
|
-
* - `field:>value`, `field:>=value`, `field:<value`, `field:<=value` →
|
|
25
|
-
* comparison operators.
|
|
26
|
-
* - `field:"multi word"` / bare `"multi word"` → quoted values keep spaces.
|
|
27
|
-
* - anything else (`beta`, `>5`) → a bare free-text token (`field: null`).
|
|
28
|
-
*
|
|
29
|
-
* A `word:` is *not* treated as a field prefix when the colon is immediately
|
|
30
|
-
* followed by `//` (a URL scheme like `http://x` or `https://…`); the whole
|
|
31
|
-
* token stays free text so a pasted URL is searched verbatim rather than
|
|
32
|
-
* mangled into `{ field: 'http', value: '//x' }`.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* parseFilterQuery('role:Editor orders:>5 name:"Ada Lovelace" beta')
|
|
36
|
-
* // [
|
|
37
|
-
* // { field: 'role', operator: 'eq', value: 'Editor', raw: 'role:Editor' },
|
|
38
|
-
* // { field: 'orders', operator: 'gt', value: '5', raw: 'orders:>5' },
|
|
39
|
-
* // { field: 'name', operator: 'eq', value: 'Ada Lovelace', raw: 'name:"Ada Lovelace"' },
|
|
40
|
-
* // { field: null, operator: 'eq', value: 'beta', raw: 'beta' },
|
|
41
|
-
* // ]
|
|
42
|
-
*/
|
|
43
|
-
export function parseFilterQuery(query: string): FilterToken[] {
|
|
44
|
-
const tokens: FilterToken[] = []
|
|
45
|
-
if (!query) return tokens
|
|
46
|
-
|
|
47
|
-
const n = query.length
|
|
48
|
-
let i = 0
|
|
49
|
-
|
|
50
|
-
while (i < n) {
|
|
51
|
-
while (i < n && isWhitespace(query[i])) i++
|
|
52
|
-
if (i >= n) break
|
|
53
|
-
|
|
54
|
-
const start = i
|
|
55
|
-
|
|
56
|
-
let field: string | null = null
|
|
57
|
-
const prefixMatch = FIELD_PREFIX_RE.exec(query.slice(i))
|
|
58
|
-
if (prefixMatch && !query.startsWith('//', i + prefixMatch[0].length)) {
|
|
59
|
-
field = prefixMatch[1]
|
|
60
|
-
i += prefixMatch[0].length
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
let operator: FilterOperator = 'eq'
|
|
64
|
-
if (field) {
|
|
65
|
-
if (query.startsWith('>=', i)) {
|
|
66
|
-
operator = 'gte'
|
|
67
|
-
i += 2
|
|
68
|
-
} else if (query.startsWith('<=', i)) {
|
|
69
|
-
operator = 'lte'
|
|
70
|
-
i += 2
|
|
71
|
-
} else if (query[i] === '>') {
|
|
72
|
-
operator = 'gt'
|
|
73
|
-
i += 1
|
|
74
|
-
} else if (query[i] === '<') {
|
|
75
|
-
operator = 'lt'
|
|
76
|
-
i += 1
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
let value = ''
|
|
81
|
-
if (query[i] === '"') {
|
|
82
|
-
i++
|
|
83
|
-
while (i < n && query[i] !== '"') {
|
|
84
|
-
value += query[i]
|
|
85
|
-
i++
|
|
86
|
-
}
|
|
87
|
-
if (i < n) i++
|
|
88
|
-
} else {
|
|
89
|
-
while (i < n && !isWhitespace(query[i])) {
|
|
90
|
-
value += query[i]
|
|
91
|
-
i++
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
tokens.push({ field, operator, value, raw: query.slice(start, i) })
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return tokens
|
|
99
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { parseFilterQuery } from './parse.js'
|
|
3
|
-
import { serializeFilterQuery } from './serialize.js'
|
|
4
|
-
import type { FilterToken } from './types.js'
|
|
5
|
-
|
|
6
|
-
// ─────────────────────────────────────────────────────────────
|
|
7
|
-
// serializeFilterQuery — the pure tokens → query-string boundary
|
|
8
|
-
// (ADR-0017). The exact inverse of parseFilterQuery; this is the
|
|
9
|
-
// grammar the Filter builder UI produces into the `?search=` param.
|
|
10
|
-
// ─────────────────────────────────────────────────────────────
|
|
11
|
-
|
|
12
|
-
const token = (partial: Partial<FilterToken>): FilterToken => ({
|
|
13
|
-
field: null,
|
|
14
|
-
operator: 'eq',
|
|
15
|
-
value: '',
|
|
16
|
-
raw: '',
|
|
17
|
-
...partial,
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
describe('serializeFilterQuery', () => {
|
|
21
|
-
it('serialises a bare free-text word', () => {
|
|
22
|
-
expect(serializeFilterQuery([token({ field: null, value: 'beta' })])).toBe('beta')
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
it('serialises a field:value token with the default eq operator', () => {
|
|
26
|
-
expect(serializeFilterQuery([token({ field: 'role', value: 'Editor' })])).toBe('role:Editor')
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('serialises each comparison operator as its prefix', () => {
|
|
30
|
-
expect(serializeFilterQuery([token({ field: 'orders', operator: 'gt', value: '5' })])).toBe(
|
|
31
|
-
'orders:>5',
|
|
32
|
-
)
|
|
33
|
-
expect(serializeFilterQuery([token({ field: 'orders', operator: 'gte', value: '5' })])).toBe(
|
|
34
|
-
'orders:>=5',
|
|
35
|
-
)
|
|
36
|
-
expect(serializeFilterQuery([token({ field: 'orders', operator: 'lt', value: '5' })])).toBe(
|
|
37
|
-
'orders:<5',
|
|
38
|
-
)
|
|
39
|
-
expect(serializeFilterQuery([token({ field: 'orders', operator: 'lte', value: '5' })])).toBe(
|
|
40
|
-
'orders:<=5',
|
|
41
|
-
)
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it('quotes a field value containing whitespace', () => {
|
|
45
|
-
expect(serializeFilterQuery([token({ field: 'name', value: 'Ada Lovelace' })])).toBe(
|
|
46
|
-
'name:"Ada Lovelace"',
|
|
47
|
-
)
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('quotes a bare word containing whitespace', () => {
|
|
51
|
-
expect(serializeFilterQuery([token({ field: null, value: 'multi word' })])).toBe('"multi word"')
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('quotes an eq value that would otherwise read as a comparison operator', () => {
|
|
55
|
-
// Without the guard, `field:>5` would re-parse as gt, not eq of ">5".
|
|
56
|
-
expect(serializeFilterQuery([token({ field: 'note', operator: 'eq', value: '>5' })])).toBe(
|
|
57
|
-
'note:">5"',
|
|
58
|
-
)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it('does NOT quote a leading > on a bare word (parser keeps it literal)', () => {
|
|
62
|
-
expect(serializeFilterQuery([token({ field: null, value: '>5' })])).toBe('>5')
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('joins tokens with the grammar implicit AND (a single space)', () => {
|
|
66
|
-
expect(
|
|
67
|
-
serializeFilterQuery([
|
|
68
|
-
token({ field: 'role', value: 'Editor' }),
|
|
69
|
-
token({ field: 'orders', operator: 'gt', value: '5' }),
|
|
70
|
-
token({ field: null, value: 'beta' }),
|
|
71
|
-
]),
|
|
72
|
-
).toBe('role:Editor orders:>5 beta')
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
it('omits tokens with an empty value (no dangling field: or stray quotes)', () => {
|
|
76
|
-
expect(
|
|
77
|
-
serializeFilterQuery([
|
|
78
|
-
token({ field: 'role', value: '' }),
|
|
79
|
-
token({ field: null, value: '' }),
|
|
80
|
-
token({ field: 'name', value: 'Ada' }),
|
|
81
|
-
]),
|
|
82
|
-
).toBe('name:Ada')
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
// ─────────────────────────────────────────────────────────────
|
|
87
|
-
// Round-trip: parse ∘ serialize is stable, and serialize ∘ parse
|
|
88
|
-
// reproduces the meaning the engine assigns.
|
|
89
|
-
// ─────────────────────────────────────────────────────────────
|
|
90
|
-
|
|
91
|
-
describe('parse/serialize round-trip', () => {
|
|
92
|
-
const queries = [
|
|
93
|
-
'beta',
|
|
94
|
-
'role:Editor',
|
|
95
|
-
'orders:>5',
|
|
96
|
-
'orders:>=5',
|
|
97
|
-
'orders:<10',
|
|
98
|
-
'name:"Ada Lovelace"',
|
|
99
|
-
'role:Editor orders:>5 name:"Ada Lovelace" beta',
|
|
100
|
-
'"multi word" gamma',
|
|
101
|
-
]
|
|
102
|
-
|
|
103
|
-
it.each(queries)('serialize(parse(%s)) reproduces the query', (query) => {
|
|
104
|
-
expect(serializeFilterQuery(parseFilterQuery(query))).toBe(query)
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
it.each(queries)('parse is idempotent through a serialize round-trip: %s', (query) => {
|
|
108
|
-
const once = parseFilterQuery(query)
|
|
109
|
-
const twice = parseFilterQuery(serializeFilterQuery(once))
|
|
110
|
-
// Compare on the semantic fields (raw differs after re-serialisation).
|
|
111
|
-
const strip = (tokens: FilterToken[]) =>
|
|
112
|
-
tokens.map(({ field, operator, value }) => ({ field, operator, value }))
|
|
113
|
-
expect(strip(twice)).toEqual(strip(once))
|
|
114
|
-
})
|
|
115
|
-
})
|
package/src/filter/serialize.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { FilterOperator, FilterToken } from './types.js'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The comparison-operator prefix each {@link FilterOperator} serialises to. The
|
|
5
|
-
* exact inverse of the prefixes {@link parseFilterQuery} recognises (`eq` has no
|
|
6
|
-
* prefix — a plain `field:value`).
|
|
7
|
-
*/
|
|
8
|
-
const OPERATOR_PREFIX: Record<FilterOperator, string> = {
|
|
9
|
-
eq: '',
|
|
10
|
-
gt: '>',
|
|
11
|
-
gte: '>=',
|
|
12
|
-
lt: '<',
|
|
13
|
-
lte: '<=',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Whether a value must be wrapped in double quotes to survive re-parsing.
|
|
18
|
-
*
|
|
19
|
-
* A value is quoted when it contains whitespace (so `parseFilterQuery` keeps it
|
|
20
|
-
* as one token) or an embedded quote. When `guardOperatorChars` is set (an `eq`
|
|
21
|
-
* field token, where a leading `>`/`<` would otherwise be read as a comparison
|
|
22
|
-
* operator), a value starting with `<`/`>` is also quoted so it round-trips as a
|
|
23
|
-
* literal value rather than an operator.
|
|
24
|
-
*/
|
|
25
|
-
function quoteIfNeeded(value: string, guardOperatorChars: boolean): string {
|
|
26
|
-
const needsQuote =
|
|
27
|
-
/\s/.test(value) ||
|
|
28
|
-
value.includes('"') ||
|
|
29
|
-
(guardOperatorChars && (value.startsWith('>') || value.startsWith('<')))
|
|
30
|
-
return needsQuote ? `"${value}"` : value
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Serialise {@link FilterToken}s back into a filter query string — the exact
|
|
35
|
-
* inverse of {@link parseFilterQuery} (ADR-0017). This is the grammar-producing
|
|
36
|
-
* half the Filter builder UI relies on: the builder turns UI state into tokens
|
|
37
|
-
* and serialises them into the `?search=` URL param the engine already consumes,
|
|
38
|
-
* so the same quoting and operator-prefix rules live next to the parser and can
|
|
39
|
-
* never drift.
|
|
40
|
-
*
|
|
41
|
-
* Pure and field-agnostic (no DB/Prisma imports). Tokens are joined with the
|
|
42
|
-
* grammar's implicit AND (a single space). A token with an empty value carries
|
|
43
|
-
* no filter and is omitted, so `serializeFilterQuery` never emits a dangling
|
|
44
|
-
* `field:` or a stray quote pair.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* serializeFilterQuery([
|
|
48
|
-
* { field: 'role', operator: 'eq', value: 'Editor', raw: '' },
|
|
49
|
-
* { field: 'orders', operator: 'gt', value: '5', raw: '' },
|
|
50
|
-
* { field: 'name', operator: 'eq', value: 'Ada Lovelace', raw: '' },
|
|
51
|
-
* { field: null, operator: 'eq', value: 'beta', raw: '' },
|
|
52
|
-
* ])
|
|
53
|
-
* // 'role:Editor orders:>5 name:"Ada Lovelace" beta'
|
|
54
|
-
*/
|
|
55
|
-
export function serializeFilterQuery(tokens: FilterToken[]): string {
|
|
56
|
-
const parts: string[] = []
|
|
57
|
-
|
|
58
|
-
for (const token of tokens) {
|
|
59
|
-
if (token.value === '') continue
|
|
60
|
-
|
|
61
|
-
if (token.field === null) {
|
|
62
|
-
// A leading `>`/`<` stays literal for a bare word (the parser only
|
|
63
|
-
// treats them as operators after a `field:`), so no operator guard here.
|
|
64
|
-
parts.push(quoteIfNeeded(token.value, false))
|
|
65
|
-
continue
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const prefix = OPERATOR_PREFIX[token.operator]
|
|
69
|
-
parts.push(`${token.field}:${prefix}${quoteIfNeeded(token.value, prefix === '')}`)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return parts.join(' ')
|
|
73
|
-
}
|
package/src/filter/types.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Filter engine types (ADR-0017).
|
|
3
|
-
*
|
|
4
|
-
* The admin UI's Filter builder turns a URL query string into scoped,
|
|
5
|
-
* server-executed filtering. The grammar is an AND-only URL contract:
|
|
6
|
-
* implicit-AND tokens, quoted multi-word values, comparison operators on
|
|
7
|
-
* numeric/date fields, and bare words as free text. Fields participate by
|
|
8
|
-
* declaring a {@link FilterSpec} (a self-contained field-builder method, peer
|
|
9
|
-
* of `getPrismaType` et al.); a field without one is not filterable.
|
|
10
|
-
*
|
|
11
|
-
* These types are the pure boundary — no Prisma / DB imports — so the
|
|
12
|
-
* `parse → tokens` and `tokens + specs → conditions` seam is unit-testable.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A Filter operator. `eq` is the default operator for a plain `field:value`
|
|
17
|
-
* token (each field's spec decides what equality means — `contains` for text,
|
|
18
|
-
* `equals` for a select); the comparisons are produced by the `>`/`>=`/`<`/`<=`
|
|
19
|
-
* prefixes on numeric and date tokens.
|
|
20
|
-
*/
|
|
21
|
-
export type FilterOperator = 'eq' | 'gt' | 'gte' | 'lt' | 'lte'
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* One parsed unit of a filter query — a field, an operator, and a value.
|
|
25
|
-
*
|
|
26
|
-
* A bare free-text word parses to a token with `field: null`. `raw` is the
|
|
27
|
-
* original source substring, retained so a token that can't map to a condition
|
|
28
|
-
* degrades to free text without re-tokenising.
|
|
29
|
-
*/
|
|
30
|
-
export interface FilterToken {
|
|
31
|
-
/** Field key the token targets, or `null` for a bare free-text word. */
|
|
32
|
-
field: string | null
|
|
33
|
-
/** The operator; `eq` for a plain `field:value`, comparisons for prefixed values. */
|
|
34
|
-
operator: FilterOperator
|
|
35
|
-
/** The unquoted value. */
|
|
36
|
-
value: string
|
|
37
|
-
/** The original source substring for this token (used when degrading to free text). */
|
|
38
|
-
raw: string
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* A Prisma `where` fragment produced by a Filter spec's `toCondition` mapper.
|
|
43
|
-
* Kept as an opaque record so this module carries no Prisma type dependency;
|
|
44
|
-
* the secured context ANDs it with the access filter when the fragment reaches
|
|
45
|
-
* `context.db.*`.
|
|
46
|
-
*/
|
|
47
|
-
export type FilterCondition = Record<string, unknown>
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Serializable description of what the suggestion dropdown may offer for a
|
|
51
|
-
* field's values. Structure only — never data-derived values for unbounded
|
|
52
|
-
* fields (ADR-0017): `none` for text/number/date, enumerated `options` for
|
|
53
|
-
* select/checkbox, and `relationship` for label search via the existing
|
|
54
|
-
* access-controlled lookup.
|
|
55
|
-
*/
|
|
56
|
-
export type FilterValueSource =
|
|
57
|
-
| { kind: 'none' }
|
|
58
|
-
| { kind: 'enum'; options: Array<{ value: string; label: string }> }
|
|
59
|
-
| { kind: 'relationship'; listKey: string; many: boolean }
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Marker key a to-many relationship's Filter spec emits for a count comparison
|
|
63
|
-
* (`orders:>5`). Prisma cannot express a relation-count comparison in a `where`
|
|
64
|
-
* (there is no `{ orders: { _count: { gt: 5 } } }`), so the pure spec can only
|
|
65
|
-
* emit a structured marker; `resolveRelationshipCountFilters` later turns each
|
|
66
|
-
* marker into an access-scoped `{ id: { in | notIn } }` before the query runs.
|
|
67
|
-
* Kept here (the pure boundary) so the field builder and the resolver agree on
|
|
68
|
-
* the shape without depending on each other.
|
|
69
|
-
*/
|
|
70
|
-
export const RELATIONSHIP_COUNT_FILTER_KEY = '_countFilter' as const
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* The payload a {@link RELATIONSHIP_COUNT_FILTER_KEY} marker carries: the
|
|
74
|
-
* numeric comparison to apply to a to-many relationship's access-visible count.
|
|
75
|
-
*/
|
|
76
|
-
export interface RelationshipCountFilterMarker {
|
|
77
|
-
operator: FilterOperator
|
|
78
|
-
value: number
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* A field's self-declared filtering capability. Returned by the optional
|
|
83
|
-
* `getFilterSpec` field-builder method.
|
|
84
|
-
*/
|
|
85
|
-
export interface FilterSpec {
|
|
86
|
-
/** Operators this field supports. A token using any other operator degrades to free text. */
|
|
87
|
-
operators: FilterOperator[]
|
|
88
|
-
/**
|
|
89
|
-
* Whether this field participates in bare-word free-text search. Bare words
|
|
90
|
-
* are OR-matched across every free-text field via each field's `eq` mapping.
|
|
91
|
-
*/
|
|
92
|
-
freeText?: boolean
|
|
93
|
-
/**
|
|
94
|
-
* Pure map from a supported `(operator, value)` to a Prisma `where` fragment,
|
|
95
|
-
* or `null` when the value can't be interpreted (e.g. a non-numeric value on
|
|
96
|
-
* a numeric field, or an unknown select option) — in which case the token
|
|
97
|
-
* degrades to free text. MUST stay free of DB/Prisma imports.
|
|
98
|
-
*/
|
|
99
|
-
toCondition: (operator: FilterOperator, value: string) => FilterCondition | null
|
|
100
|
-
/** Serializable suggestion metadata for the client. */
|
|
101
|
-
suggestions: {
|
|
102
|
-
valueSource: FilterValueSource
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Collected, client-serializable suggestion metadata for one filterable field.
|
|
108
|
-
* The union of every list field's Filter spec suggestions; carries no
|
|
109
|
-
* functions, so it crosses the server/client boundary.
|
|
110
|
-
*/
|
|
111
|
-
export interface FilterFieldSuggestion {
|
|
112
|
-
/** The field key. */
|
|
113
|
-
field: string
|
|
114
|
-
/** Operators the field supports. */
|
|
115
|
-
operators: FilterOperator[]
|
|
116
|
-
/** Whether the field participates in bare-word free-text search. */
|
|
117
|
-
freeText: boolean
|
|
118
|
-
/** How the suggestion dropdown may offer values for this field. */
|
|
119
|
-
valueSource: FilterValueSource
|
|
120
|
-
}
|