@opensaas/stack-core 0.44.0-alpha.5 → 0.44.0-alpha.7
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 +1051 -0
- package/dist/.build-hash +1 -1
- package/dist/access/actor.d.ts +56 -0
- package/dist/access/actor.d.ts.map +1 -0
- package/dist/access/actor.js +66 -0
- package/dist/access/actor.js.map +1 -0
- package/dist/access/decide-advertisement.d.ts +55 -0
- package/dist/access/decide-advertisement.d.ts.map +1 -0
- package/dist/access/decide-advertisement.js +125 -0
- package/dist/access/decide-advertisement.js.map +1 -0
- package/dist/access/declared-dependencies.d.ts +4 -89
- package/dist/access/declared-dependencies.d.ts.map +1 -1
- package/dist/access/declared-dependencies.js +14 -84
- package/dist/access/declared-dependencies.js.map +1 -1
- package/dist/access/depth-limits.d.ts +2 -0
- package/dist/access/depth-limits.d.ts.map +1 -1
- package/dist/access/depth-limits.js +2 -0
- package/dist/access/depth-limits.js.map +1 -1
- package/dist/access/engine.d.ts +1 -24
- package/dist/access/engine.d.ts.map +1 -1
- package/dist/access/engine.js +0 -35
- package/dist/access/engine.js.map +1 -1
- package/dist/access/field-access.d.ts +43 -19
- package/dist/access/field-access.d.ts.map +1 -1
- package/dist/access/field-access.js +206 -185
- package/dist/access/field-access.js.map +1 -1
- package/dist/access/index.d.ts +5 -6
- package/dist/access/index.d.ts.map +1 -1
- package/dist/access/index.js +6 -7
- package/dist/access/index.js.map +1 -1
- package/dist/access/rule-item.d.ts +42 -0
- package/dist/access/rule-item.d.ts.map +1 -0
- package/dist/access/rule-item.js +215 -0
- package/dist/access/rule-item.js.map +1 -0
- package/dist/access/session-vocabulary.d.ts +124 -0
- package/dist/access/session-vocabulary.d.ts.map +1 -0
- package/dist/access/session-vocabulary.js +366 -0
- package/dist/access/session-vocabulary.js.map +1 -0
- package/dist/access/transaction-registry.d.ts +6 -0
- package/dist/access/transaction-registry.d.ts.map +1 -1
- package/dist/access/transaction-registry.js +19 -2
- package/dist/access/transaction-registry.js.map +1 -1
- package/dist/access/types.d.ts +66 -0
- package/dist/access/types.d.ts.map +1 -1
- package/dist/access/vocabulary-filter-specs.d.ts +17 -0
- package/dist/access/vocabulary-filter-specs.d.ts.map +1 -0
- package/dist/access/vocabulary-filter-specs.js +27 -0
- package/dist/access/vocabulary-filter-specs.js.map +1 -0
- package/dist/client-safe.d.ts +8 -0
- package/dist/client-safe.d.ts.map +1 -0
- package/dist/client-safe.js +8 -0
- package/dist/client-safe.js.map +1 -0
- package/dist/config/field-kind.d.ts +7 -21
- package/dist/config/field-kind.d.ts.map +1 -1
- package/dist/config/field-kind.js +8 -5
- package/dist/config/field-kind.js.map +1 -1
- package/dist/config/has-access-gate.d.ts +20 -0
- package/dist/config/has-access-gate.d.ts.map +1 -0
- package/dist/config/has-access-gate.js +26 -0
- package/dist/config/has-access-gate.js.map +1 -0
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +8 -2
- package/dist/config/index.js.map +1 -1
- package/dist/config/list-view-keys.d.ts +5 -0
- package/dist/config/list-view-keys.d.ts.map +1 -0
- package/dist/config/list-view-keys.js +18 -0
- package/dist/config/list-view-keys.js.map +1 -0
- package/dist/config/mcp-default-tools.d.ts +3 -0
- package/dist/config/mcp-default-tools.d.ts.map +1 -0
- package/dist/config/mcp-default-tools.js +14 -0
- package/dist/config/mcp-default-tools.js.map +1 -0
- package/dist/config/mcp-tool-names.d.ts +2 -0
- package/dist/config/mcp-tool-names.d.ts.map +1 -1
- package/dist/config/mcp-tool-names.js +17 -5
- package/dist/config/mcp-tool-names.js.map +1 -1
- package/dist/config/nav-count.d.ts +8 -16
- package/dist/config/nav-count.d.ts.map +1 -1
- package/dist/config/nav-count.js +20 -32
- package/dist/config/nav-count.js.map +1 -1
- package/dist/config/plugin-engine.d.ts.map +1 -1
- package/dist/config/plugin-engine.js +6 -0
- package/dist/config/plugin-engine.js.map +1 -1
- package/dist/config/preset-views.d.ts +22 -0
- package/dist/config/preset-views.d.ts.map +1 -0
- package/dist/config/preset-views.js +46 -0
- package/dist/config/preset-views.js.map +1 -0
- package/dist/config/row-action-availability.d.ts +4 -0
- package/dist/config/row-action-availability.d.ts.map +1 -0
- package/dist/config/row-action-availability.js +20 -0
- package/dist/config/row-action-availability.js.map +1 -0
- package/dist/config/types.d.ts +409 -34
- package/dist/config/types.d.ts.map +1 -1
- package/dist/context/engine-context.d.ts +2 -0
- package/dist/context/engine-context.d.ts.map +1 -1
- package/dist/context/engine-context.js +8 -0
- package/dist/context/engine-context.js.map +1 -1
- package/dist/context/hook-pipeline.d.ts +6 -1
- package/dist/context/hook-pipeline.d.ts.map +1 -1
- package/dist/context/hook-pipeline.js +6 -4
- package/dist/context/hook-pipeline.js.map +1 -1
- package/dist/context/index.d.ts +10 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +217 -94
- package/dist/context/index.js.map +1 -1
- package/dist/context/junction.d.ts +28 -21
- package/dist/context/junction.d.ts.map +1 -1
- package/dist/context/junction.js +74 -69
- package/dist/context/junction.js.map +1 -1
- package/dist/context/plugin-field-write.d.ts.map +1 -1
- package/dist/context/plugin-field-write.js +19 -25
- package/dist/context/plugin-field-write.js.map +1 -1
- package/dist/context/process-lifetime.d.ts +8 -0
- package/dist/context/process-lifetime.d.ts.map +1 -0
- package/dist/context/process-lifetime.js +14 -0
- package/dist/context/process-lifetime.js.map +1 -0
- package/dist/context/relationship-input.d.ts +2 -15
- package/dist/context/relationship-input.d.ts.map +1 -1
- package/dist/context/relationship-input.js +44 -85
- package/dist/context/relationship-input.js.map +1 -1
- package/dist/context/transaction-boundary.d.ts +3 -2
- package/dist/context/transaction-boundary.d.ts.map +1 -1
- package/dist/context/transaction-boundary.js +17 -2
- package/dist/context/transaction-boundary.js.map +1 -1
- package/dist/context/write-pipeline.d.ts +5 -19
- package/dist/context/write-pipeline.d.ts.map +1 -1
- package/dist/context/write-pipeline.js +54 -92
- package/dist/context/write-pipeline.js.map +1 -1
- package/dist/context/write-target.d.ts +52 -0
- package/dist/context/write-target.d.ts.map +1 -0
- package/dist/context/write-target.js +118 -0
- package/dist/context/write-target.js.map +1 -0
- package/dist/contract/dependencies.d.ts +24 -10
- package/dist/contract/dependencies.d.ts.map +1 -1
- package/dist/contract/dependencies.js +120 -80
- package/dist/contract/dependencies.js.map +1 -1
- package/dist/contract/derive.d.ts +6 -11
- package/dist/contract/derive.d.ts.map +1 -1
- package/dist/contract/derive.js +256 -211
- package/dist/contract/derive.js.map +1 -1
- package/dist/contract/fixtures/contract-configs.d.ts +5 -0
- package/dist/contract/fixtures/contract-configs.d.ts.map +1 -1
- package/dist/contract/fixtures/contract-configs.js +21 -0
- package/dist/contract/fixtures/contract-configs.js.map +1 -1
- package/dist/contract/id-boundary.js +1 -1
- package/dist/contract/id-boundary.js.map +1 -1
- package/dist/contract/prisma.js +2 -2
- package/dist/contract/prisma.js.map +1 -1
- package/dist/contract/strategy.d.ts +13 -0
- package/dist/contract/strategy.d.ts.map +1 -0
- package/dist/contract/strategy.js +38 -0
- package/dist/contract/strategy.js.map +1 -0
- package/dist/db/client-alias.d.ts +12 -0
- package/dist/db/client-alias.d.ts.map +1 -0
- package/dist/db/client-alias.js +8 -0
- package/dist/db/client-alias.js.map +1 -0
- package/dist/extend.d.ts +2 -2
- package/dist/extend.d.ts.map +1 -1
- package/dist/extend.js.map +1 -1
- package/dist/fields/index.d.ts +12 -14
- package/dist/fields/index.d.ts.map +1 -1
- package/dist/fields/index.js +217 -67
- package/dist/fields/index.js.map +1 -1
- package/dist/filter/collect.d.ts +43 -25
- package/dist/filter/collect.d.ts.map +1 -1
- package/dist/filter/collect.js +107 -38
- package/dist/filter/collect.js.map +1 -1
- package/dist/filter/index.d.ts +7 -5
- package/dist/filter/index.d.ts.map +1 -1
- package/dist/filter/index.js +6 -14
- package/dist/filter/index.js.map +1 -1
- package/dist/filter/map.d.ts +112 -20
- package/dist/filter/map.d.ts.map +1 -1
- package/dist/filter/map.js +271 -52
- package/dist/filter/map.js.map +1 -1
- package/dist/filter/parse.d.ts +70 -26
- package/dist/filter/parse.d.ts.map +1 -1
- package/dist/filter/parse.js +212 -79
- package/dist/filter/parse.js.map +1 -1
- package/dist/filter/record-id.d.ts +19 -0
- package/dist/filter/record-id.d.ts.map +1 -0
- package/dist/filter/record-id.js +37 -0
- package/dist/filter/record-id.js.map +1 -0
- package/dist/filter/serialize.d.ts +45 -19
- package/dist/filter/serialize.d.ts.map +1 -1
- package/dist/filter/serialize.js +146 -50
- package/dist/filter/serialize.js.map +1 -1
- package/dist/filter/types.d.ts +132 -21
- 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 +6 -3
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +38 -8
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +11 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +8 -8
- package/dist/internal.js.map +1 -1
- package/dist/lib/database-errors.d.ts +2 -1
- package/dist/lib/database-errors.d.ts.map +1 -1
- package/dist/lib/database-errors.js +5 -4
- package/dist/lib/database-errors.js.map +1 -1
- package/dist/mcp/advertise.d.ts +5 -13
- package/dist/mcp/advertise.d.ts.map +1 -1
- package/dist/mcp/advertise.js +7 -22
- package/dist/mcp/advertise.js.map +1 -1
- package/dist/mcp/arguments.d.ts.map +1 -1
- package/dist/mcp/arguments.js +8 -11
- package/dist/mcp/arguments.js.map +1 -1
- package/dist/mcp/field-schema.d.ts +4 -15
- package/dist/mcp/field-schema.d.ts.map +1 -1
- package/dist/mcp/field-schema.js +50 -69
- package/dist/mcp/field-schema.js.map +1 -1
- package/dist/mcp/handler.d.ts +111 -18
- package/dist/mcp/handler.d.ts.map +1 -1
- package/dist/mcp/handler.js +231 -87
- package/dist/mcp/handler.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/procedure-tools.d.ts +63 -0
- package/dist/mcp/procedure-tools.d.ts.map +1 -0
- package/dist/mcp/procedure-tools.js +139 -0
- package/dist/mcp/procedure-tools.js.map +1 -0
- package/dist/mcp/projection.d.ts +6 -5
- package/dist/mcp/projection.d.ts.map +1 -1
- package/dist/mcp/projection.js +33 -38
- package/dist/mcp/projection.js.map +1 -1
- package/dist/mcp/reachability.d.ts +13 -0
- package/dist/mcp/reachability.d.ts.map +1 -0
- package/dist/mcp/reachability.js +51 -0
- package/dist/mcp/reachability.js.map +1 -0
- package/dist/mcp/relation-member.d.ts +15 -0
- package/dist/mcp/relation-member.d.ts.map +1 -0
- package/dist/mcp/relation-member.js +50 -0
- package/dist/mcp/relation-member.js.map +1 -0
- package/dist/mcp/types.d.ts +12 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/where-id-boundary.d.ts.map +1 -1
- package/dist/mcp/where-id-boundary.js +12 -24
- package/dist/mcp/where-id-boundary.js.map +1 -1
- package/dist/mcp/where-reachability.d.ts +10 -0
- package/dist/mcp/where-reachability.d.ts.map +1 -0
- package/dist/mcp/where-reachability.js +88 -0
- package/dist/mcp/where-reachability.js.map +1 -0
- package/dist/members/claims.d.ts +71 -0
- package/dist/members/claims.d.ts.map +1 -0
- package/dist/members/claims.js +199 -0
- package/dist/members/claims.js.map +1 -0
- package/dist/members/list-members.d.ts +87 -0
- package/dist/members/list-members.d.ts.map +1 -0
- package/dist/members/list-members.js +250 -0
- package/dist/members/list-members.js.map +1 -0
- package/dist/procedures/client.d.ts +163 -0
- package/dist/procedures/client.d.ts.map +1 -0
- package/dist/procedures/client.js +152 -0
- package/dist/procedures/client.js.map +1 -0
- package/dist/procedures/codes.d.ts +23 -0
- package/dist/procedures/codes.d.ts.map +1 -0
- package/dist/procedures/codes.js +46 -0
- package/dist/procedures/codes.js.map +1 -0
- package/dist/procedures/context-face.d.ts +4 -0
- package/dist/procedures/context-face.d.ts.map +1 -0
- package/dist/procedures/context-face.js +31 -0
- package/dist/procedures/context-face.js.map +1 -0
- package/dist/procedures/failures.d.ts +31 -0
- package/dist/procedures/failures.d.ts.map +1 -0
- package/dist/procedures/failures.js +51 -0
- package/dist/procedures/failures.js.map +1 -0
- package/dist/procedures/http.d.ts +114 -0
- package/dist/procedures/http.d.ts.map +1 -0
- package/dist/procedures/http.js +224 -0
- package/dist/procedures/http.js.map +1 -0
- package/dist/procedures/index.d.ts +7 -0
- package/dist/procedures/index.d.ts.map +1 -0
- package/dist/procedures/index.js +11 -0
- package/dist/procedures/index.js.map +1 -0
- package/dist/procedures/procedure.d.ts +204 -0
- package/dist/procedures/procedure.d.ts.map +1 -0
- package/dist/procedures/procedure.js +123 -0
- package/dist/procedures/procedure.js.map +1 -0
- package/dist/procedures/result.d.ts +42 -0
- package/dist/procedures/result.d.ts.map +1 -0
- package/dist/procedures/result.js +51 -0
- package/dist/procedures/result.js.map +1 -0
- package/dist/procedures/run.d.ts +36 -0
- package/dist/procedures/run.d.ts.map +1 -0
- package/dist/procedures/run.js +76 -0
- package/dist/procedures/run.js.map +1 -0
- package/dist/procedures/server.d.ts +131 -0
- package/dist/procedures/server.d.ts.map +1 -0
- package/dist/procedures/server.js +115 -0
- package/dist/procedures/server.js.map +1 -0
- package/dist/procedures/validate.d.ts +60 -0
- package/dist/procedures/validate.d.ts.map +1 -0
- package/dist/procedures/validate.js +254 -0
- package/dist/procedures/validate.js.map +1 -0
- package/dist/procedures/web-session.d.ts +12 -0
- package/dist/procedures/web-session.d.ts.map +1 -0
- package/dist/procedures/web-session.js +35 -0
- package/dist/procedures/web-session.js.map +1 -0
- package/dist/query/relationship-options.d.ts +8 -0
- package/dist/query/relationship-options.d.ts.map +1 -1
- package/dist/query/relationship-options.js +18 -4
- package/dist/query/relationship-options.js.map +1 -1
- package/dist/secured/binding.d.ts +84 -0
- package/dist/secured/binding.d.ts.map +1 -0
- package/dist/secured/binding.js +52 -0
- package/dist/secured/binding.js.map +1 -0
- package/dist/secured/declared-branch.d.ts +11 -0
- package/dist/secured/declared-branch.d.ts.map +1 -0
- package/dist/secured/declared-branch.js +17 -0
- package/dist/secured/declared-branch.js.map +1 -0
- package/dist/secured/field-visibility.d.ts +56 -0
- package/dist/secured/field-visibility.d.ts.map +1 -0
- package/dist/secured/field-visibility.js +624 -0
- package/dist/secured/field-visibility.js.map +1 -0
- package/dist/secured/include.d.ts +77 -37
- package/dist/secured/include.d.ts.map +1 -1
- package/dist/secured/include.js +228 -122
- package/dist/secured/include.js.map +1 -1
- package/dist/secured/lock.d.ts +8 -2
- package/dist/secured/lock.d.ts.map +1 -1
- package/dist/secured/lock.js +44 -15
- package/dist/secured/lock.js.map +1 -1
- package/dist/secured/lower.d.ts.map +1 -1
- package/dist/secured/lower.js +15 -4
- package/dist/secured/lower.js.map +1 -1
- package/dist/secured/read.d.ts +13 -52
- package/dist/secured/read.d.ts.map +1 -1
- package/dist/secured/read.js +88 -614
- package/dist/secured/read.js.map +1 -1
- package/dist/secured/select.d.ts +0 -24
- package/dist/secured/select.d.ts.map +1 -1
- package/dist/secured/select.js +60 -153
- package/dist/secured/select.js.map +1 -1
- package/dist/secured/vocabulary.d.ts +13 -1
- package/dist/secured/vocabulary.d.ts.map +1 -1
- package/dist/secured/vocabulary.js +173 -83
- package/dist/secured/vocabulary.js.map +1 -1
- package/dist/testing/untyped-rule.d.ts +8 -0
- package/dist/testing/untyped-rule.d.ts.map +1 -0
- package/dist/testing/untyped-rule.js +4 -0
- package/dist/testing/untyped-rule.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rows.d.ts +18 -1
- package/dist/types/rows.d.ts.map +1 -1
- package/dist/validation/config-refusal.d.ts +3 -1
- package/dist/validation/config-refusal.d.ts.map +1 -1
- package/dist/validation/database-config.d.ts +1 -15
- package/dist/validation/database-config.d.ts.map +1 -1
- package/dist/validation/database-config.js +32 -1
- package/dist/validation/database-config.js.map +1 -1
- package/dist/validation/default-value.d.ts.map +1 -1
- package/dist/validation/default-value.js +3 -8
- package/dist/validation/default-value.js.map +1 -1
- package/dist/validation/extension-packs.d.ts.map +1 -1
- package/dist/validation/extension-packs.js +1 -0
- package/dist/validation/extension-packs.js.map +1 -1
- package/dist/validation/field-config.d.ts +3 -2
- package/dist/validation/field-config.d.ts.map +1 -1
- package/dist/validation/field-config.js +3 -1
- package/dist/validation/field-config.js.map +1 -1
- package/dist/validation/field-names.d.ts +2 -1
- package/dist/validation/field-names.d.ts.map +1 -1
- package/dist/validation/field-names.js +76 -63
- package/dist/validation/field-names.js.map +1 -1
- package/dist/validation/identifier-names.d.ts +1 -0
- package/dist/validation/identifier-names.d.ts.map +1 -1
- package/dist/validation/identifier-names.js +17 -9
- package/dist/validation/identifier-names.js.map +1 -1
- package/dist/validation/needs-closure.d.ts +30 -14
- package/dist/validation/needs-closure.d.ts.map +1 -1
- package/dist/validation/needs-closure.js +184 -31
- package/dist/validation/needs-closure.js.map +1 -1
- package/dist/validation/relations.d.ts.map +1 -1
- package/dist/validation/relations.js +11 -0
- package/dist/validation/relations.js.map +1 -1
- package/dist/validation/schema.d.ts +4 -3
- package/dist/validation/schema.d.ts.map +1 -1
- package/dist/validation/schema.js +8 -6
- package/dist/validation/schema.js.map +1 -1
- package/package.json +26 -10
- package/dist/access/field-visibility.d.ts +0 -58
- package/dist/access/field-visibility.d.ts.map +0 -1
- package/dist/access/field-visibility.js +0 -383
- package/dist/access/field-visibility.js.map +0 -1
- package/dist/access/query-validation.d.ts +0 -30
- package/dist/access/query-validation.d.ts.map +0 -1
- package/dist/access/query-validation.js +0 -49
- package/dist/access/query-validation.js.map +0 -1
- package/dist/access/system-fields.d.ts +0 -2
- package/dist/access/system-fields.d.ts.map +0 -1
- package/dist/access/system-fields.js +0 -7
- package/dist/access/system-fields.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fields/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,cAAc,EACd,WAAW,EAQZ,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fields/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,cAAc,EACd,WAAW,EAQZ,MAAM,oBAAoB,CAAA;AAoE3B,YAAY,EACV,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,4BAA4B,EAC5B,eAAe,EACf,0BAA0B,GAC3B,MAAM,oBAAoB,CAAA;AAE3B;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKzD;AAwMD;;GAEG;AACH,wBAAgB,IAAI,CAClB,SAAS,SAAS,OAAO,oBAAoB,EAAE,QAAQ,GAAG,OAAO,oBAAoB,EAAE,QAAQ,EAC/F,IAAI,SAAS,OAAO,oBAAoB,EAAE,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,GACtE,OAAO,oBAAoB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,wBAAgB,OAAO,CACrB,SAAS,SAAS,OAAO,oBAAoB,EAAE,QAAQ,EACvD,IAAI,SAAS,OAAO,oBAAoB,EAAE,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,GACtE,OAAO,oBAAoB,EAAE,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAE7D,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,YAAY,GAAG,MAAM,CAAC,GAAG;IAChF,IAAI,EAAE,OAAO,oBAAoB,EAAE,cAAc,CAAA;CAClD,GACA,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,CAuB/B"}
|
package/dist/fields/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { hashPassword, isHashedPassword, HashedPassword } from '../utils/password.js';
|
|
3
3
|
import { getLabelFieldName } from '../config/label.js';
|
|
4
|
+
import { parseListId } from '../contract/id-boundary.js';
|
|
4
5
|
function quoteStringLiteral(value) {
|
|
5
6
|
const escaped = value
|
|
6
7
|
.replace(/\\/g, '\\\\')
|
|
@@ -13,6 +14,36 @@ function quoteStringLiteral(value) {
|
|
|
13
14
|
}
|
|
14
15
|
/** Operators shared by numeric/date fields' `getFilterSpec`. */
|
|
15
16
|
const COMPARISON_OPERATORS = ['eq', 'gt', 'gte', 'lt', 'lte'];
|
|
17
|
+
const WHOLE_NUMBER = { pattern: '^-?\\d+$', description: 'takes a whole number' };
|
|
18
|
+
const WHOLE_NUMBER_MATCH = new RegExp(WHOLE_NUMBER.pattern);
|
|
19
|
+
const DECIMAL_VALUE = {
|
|
20
|
+
pattern: '^-?\\d+(?:\\.\\d+)?$',
|
|
21
|
+
description: 'takes a number',
|
|
22
|
+
};
|
|
23
|
+
const DECIMAL_VALUE_MATCH = new RegExp(DECIMAL_VALUE.pattern);
|
|
24
|
+
const DATE_VALUE = {
|
|
25
|
+
pattern: '^\\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\\d|3[01])$',
|
|
26
|
+
description: 'takes a date, like 2026-01-31',
|
|
27
|
+
};
|
|
28
|
+
const DATE_VALUE_MATCH = new RegExp(DATE_VALUE.pattern);
|
|
29
|
+
const PRESENCE_COUNT = {
|
|
30
|
+
pattern: '^0$',
|
|
31
|
+
description: 'takes 0: “is 0” finds none, “greater than 0” finds any',
|
|
32
|
+
operators: { gte: { pattern: '^1$', description: 'takes 1 with “at least”, which finds any' } },
|
|
33
|
+
};
|
|
34
|
+
function formatMatcher(format) {
|
|
35
|
+
const base = new RegExp(format.pattern);
|
|
36
|
+
const byOperator = new Map();
|
|
37
|
+
for (const [operator, pattern] of Object.entries(format.operators ?? {})) {
|
|
38
|
+
if (pattern)
|
|
39
|
+
byOperator.set(operator, new RegExp(pattern.pattern));
|
|
40
|
+
}
|
|
41
|
+
return (operator, value) => (byOperator.get(operator) ?? base).test(value);
|
|
42
|
+
}
|
|
43
|
+
const PRESENCE_COUNT_MATCH = formatMatcher(PRESENCE_COUNT);
|
|
44
|
+
function emptyWhenNullable(fieldName, nullable) {
|
|
45
|
+
return nullable ? { [fieldName]: { equals: null } } : undefined;
|
|
46
|
+
}
|
|
16
47
|
function prismaComparisonKey(operator) {
|
|
17
48
|
return operator === 'eq' ? 'equals' : operator;
|
|
18
49
|
}
|
|
@@ -79,9 +110,47 @@ function fitsDecimal(value, precision, scale) {
|
|
|
79
110
|
const parts = decimalParts(text);
|
|
80
111
|
if (parts === null)
|
|
81
112
|
return false;
|
|
82
|
-
const
|
|
83
|
-
|
|
113
|
+
const fraction = parts[3] ?? '';
|
|
114
|
+
let scaled = BigInt(`${parts[2] || '0'}${fraction.slice(0, scale).padEnd(scale, '0')}`);
|
|
115
|
+
if (fraction.length > scale && fraction.charCodeAt(scale) >= 53)
|
|
116
|
+
scaled += 1n;
|
|
117
|
+
return (scaled === 0n ? 1 : scaled.toString().length) <= precision;
|
|
118
|
+
}
|
|
119
|
+
const INT32_MIN = -2147483648;
|
|
120
|
+
const INT32_MAX = 2147483647;
|
|
121
|
+
const INT64_MIN = -(2n ** 63n);
|
|
122
|
+
const INT64_MAX = 2n ** 63n - 1n;
|
|
123
|
+
function integerFilterBounds(nativeType) {
|
|
124
|
+
switch (nativeType?.toLowerCase()) {
|
|
125
|
+
case 'smallint':
|
|
126
|
+
return { min: -32768, max: 32767 };
|
|
127
|
+
case 'bigint':
|
|
128
|
+
return { min: Number.MIN_SAFE_INTEGER, max: Number.MAX_SAFE_INTEGER };
|
|
129
|
+
default:
|
|
130
|
+
return { min: INT32_MIN, max: INT32_MAX };
|
|
131
|
+
}
|
|
84
132
|
}
|
|
133
|
+
const hasNul = (root) => {
|
|
134
|
+
const seen = new Set();
|
|
135
|
+
const pending = [root];
|
|
136
|
+
while (pending.length > 0) {
|
|
137
|
+
const value = pending.pop();
|
|
138
|
+
if (typeof value === 'string') {
|
|
139
|
+
if (value.includes('\u0000'))
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
else if (typeof value === 'object' && value !== null && !seen.has(value)) {
|
|
143
|
+
seen.add(value);
|
|
144
|
+
if (Array.isArray(value))
|
|
145
|
+
pending.push(...value);
|
|
146
|
+
else {
|
|
147
|
+
for (const [key, child] of Object.entries(value))
|
|
148
|
+
pending.push(key, child);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return false;
|
|
153
|
+
};
|
|
85
154
|
function isCalendarDate(value) {
|
|
86
155
|
if (typeof value !== 'string')
|
|
87
156
|
return false;
|
|
@@ -89,6 +158,8 @@ function isCalendarDate(value) {
|
|
|
89
158
|
if (match === null)
|
|
90
159
|
return false;
|
|
91
160
|
const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
161
|
+
if (year < 1)
|
|
162
|
+
return false;
|
|
92
163
|
const date = new Date(0);
|
|
93
164
|
date.setUTCFullYear(year, month - 1, day);
|
|
94
165
|
return (date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day);
|
|
@@ -153,6 +224,7 @@ function scalarColumn(fieldName, column) {
|
|
|
153
224
|
* Text field
|
|
154
225
|
*/
|
|
155
226
|
export function text(options) {
|
|
227
|
+
const nullable = options?.db?.isNullable ?? !options?.validation?.isRequired;
|
|
156
228
|
const zodSchema = (fieldName, operation) => {
|
|
157
229
|
const validation = options?.validation;
|
|
158
230
|
const isRequired = validation?.isRequired;
|
|
@@ -174,17 +246,21 @@ export function text(options) {
|
|
|
174
246
|
message: `${formatFieldName(fieldName)} must be at most ${length.max} characters`,
|
|
175
247
|
})
|
|
176
248
|
: withMin;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
249
|
+
const noNul = withMax.refine((value) => !value.includes('\u0000'), {
|
|
250
|
+
message: `${formatFieldName(fieldName)} must not contain NUL characters`,
|
|
251
|
+
});
|
|
252
|
+
if (isRequired && operation === 'update')
|
|
253
|
+
return noNul.optional();
|
|
254
|
+
if (isRequired)
|
|
255
|
+
return noNul;
|
|
256
|
+
return nullable ? noNul.optional().nullable() : noNul.optional();
|
|
181
257
|
};
|
|
182
258
|
return {
|
|
183
259
|
type: 'text',
|
|
184
260
|
...options,
|
|
261
|
+
nullable,
|
|
185
262
|
getZodSchema: zodSchema,
|
|
186
263
|
getContractField: (fieldName, listKey, config) => {
|
|
187
|
-
const nullable = options?.db?.isNullable ?? !options?.validation?.isRequired;
|
|
188
264
|
// Keystone 6 gives every non-null text column an implicit empty-string
|
|
189
265
|
// default; `db.keystoneCompat` mirrors that so a migrating project
|
|
190
266
|
// reaches parity without hand-setting `defaultValue: ''`.
|
|
@@ -216,6 +292,11 @@ export function text(options) {
|
|
|
216
292
|
operators: ['eq'],
|
|
217
293
|
freeText: true,
|
|
218
294
|
toCondition: (operator, value) => operator === 'eq' ? { [fieldName]: { contains: value } } : null,
|
|
295
|
+
empty: nullable
|
|
296
|
+
? { OR: [{ [fieldName]: { equals: null } }, { [fieldName]: { equals: '' } }] }
|
|
297
|
+
: options?.validation?.isRequired
|
|
298
|
+
? undefined
|
|
299
|
+
: { [fieldName]: { equals: '' } },
|
|
219
300
|
suggestions: { valueSource: { kind: 'none' } },
|
|
220
301
|
}),
|
|
221
302
|
};
|
|
@@ -228,9 +309,18 @@ export function integer(options) {
|
|
|
228
309
|
type: 'integer',
|
|
229
310
|
...options,
|
|
230
311
|
getZodSchema: (fieldName, operation) => {
|
|
231
|
-
const
|
|
232
|
-
message: `${formatFieldName(fieldName)} must be a number
|
|
233
|
-
|
|
312
|
+
const whole = z
|
|
313
|
+
.number({ message: `${formatFieldName(fieldName)} must be a number` })
|
|
314
|
+
.int({ message: `${formatFieldName(fieldName)} must be a whole number` });
|
|
315
|
+
const baseSchema = options?.db?.nativeType === undefined
|
|
316
|
+
? whole
|
|
317
|
+
.min(INT32_MIN, {
|
|
318
|
+
message: `${formatFieldName(fieldName)} is below the 32-bit range`,
|
|
319
|
+
})
|
|
320
|
+
.max(INT32_MAX, {
|
|
321
|
+
message: `${formatFieldName(fieldName)} is above the 32-bit range`,
|
|
322
|
+
})
|
|
323
|
+
: whole;
|
|
234
324
|
const withMin = options?.validation?.min !== undefined
|
|
235
325
|
? baseSchema.min(options.validation.min, {
|
|
236
326
|
message: `${formatFieldName(fieldName)} must be at least ${options.validation.min}`,
|
|
@@ -244,7 +334,11 @@ export function integer(options) {
|
|
|
244
334
|
const isRequired = options?.validation?.isRequired;
|
|
245
335
|
if (isRequired && operation === 'update')
|
|
246
336
|
return withMax.optional();
|
|
247
|
-
|
|
337
|
+
if (isRequired)
|
|
338
|
+
return withMax;
|
|
339
|
+
return (options?.db?.isNullable ?? !isRequired)
|
|
340
|
+
? withMax.optional().nullable()
|
|
341
|
+
: withMax.optional();
|
|
248
342
|
},
|
|
249
343
|
getContractField: (fieldName, listKey) => {
|
|
250
344
|
checkedDefault(options?.defaultValue, listKey, fieldName, 'an integer within the 32-bit range', (value) => typeof value === 'number' &&
|
|
@@ -265,11 +359,16 @@ export function integer(options) {
|
|
|
265
359
|
operators: COMPARISON_OPERATORS,
|
|
266
360
|
toCondition: (operator, value) => {
|
|
267
361
|
const trimmed = value.trim();
|
|
268
|
-
if (
|
|
362
|
+
if (!WHOLE_NUMBER_MATCH.test(trimmed))
|
|
363
|
+
return null;
|
|
364
|
+
const parsed = Number(trimmed);
|
|
365
|
+
const bounds = integerFilterBounds(options?.db?.nativeType);
|
|
366
|
+
if (parsed < bounds.min || parsed > bounds.max)
|
|
269
367
|
return null;
|
|
270
|
-
return { [fieldName]: { [prismaComparisonKey(operator)]:
|
|
368
|
+
return { [fieldName]: { [prismaComparisonKey(operator)]: parsed } };
|
|
271
369
|
},
|
|
272
|
-
|
|
370
|
+
empty: emptyWhenNullable(fieldName, options?.db?.isNullable ?? !options?.validation?.isRequired),
|
|
371
|
+
suggestions: { valueSource: { kind: 'none' }, valueFormat: WHOLE_NUMBER },
|
|
273
372
|
}),
|
|
274
373
|
};
|
|
275
374
|
}
|
|
@@ -338,7 +437,9 @@ export function decimal(options) {
|
|
|
338
437
|
], {
|
|
339
438
|
message: `${formatFieldName(fieldName)} must be a decimal value`,
|
|
340
439
|
});
|
|
341
|
-
let schema = baseSchema
|
|
440
|
+
let schema = baseSchema.refine((val) => fitsDecimal(val, precision, scale), {
|
|
441
|
+
message: `${formatFieldName(fieldName)} must be a finite number with at most ${precision - scale} integer digits`,
|
|
442
|
+
});
|
|
342
443
|
if (options?.validation?.min !== undefined) {
|
|
343
444
|
const minValue = parseFloat(options.validation.min);
|
|
344
445
|
schema = schema.refine((val) => {
|
|
@@ -360,7 +461,11 @@ export function decimal(options) {
|
|
|
360
461
|
const isRequired = options?.validation?.isRequired;
|
|
361
462
|
if (isRequired && operation === 'update')
|
|
362
463
|
return schema.optional();
|
|
363
|
-
|
|
464
|
+
if (isRequired)
|
|
465
|
+
return schema;
|
|
466
|
+
return (options?.db?.isNullable ?? !isRequired)
|
|
467
|
+
? schema.optional().nullable()
|
|
468
|
+
: schema.optional();
|
|
364
469
|
},
|
|
365
470
|
getContractField: (fieldName, listKey) => {
|
|
366
471
|
const size = checkedDecimalSize(options?.precision ?? 18, options?.scale ?? 4, listKey, fieldName);
|
|
@@ -380,11 +485,12 @@ export function decimal(options) {
|
|
|
380
485
|
operators: COMPARISON_OPERATORS,
|
|
381
486
|
toCondition: (operator, value) => {
|
|
382
487
|
const trimmed = value.trim();
|
|
383
|
-
if (
|
|
488
|
+
if (!DECIMAL_VALUE_MATCH.test(trimmed))
|
|
384
489
|
return null;
|
|
385
490
|
return { [fieldName]: { [prismaComparisonKey(operator)]: trimmed } };
|
|
386
491
|
},
|
|
387
|
-
|
|
492
|
+
empty: emptyWhenNullable(fieldName, options?.db?.isNullable ?? !options?.validation?.isRequired),
|
|
493
|
+
suggestions: { valueSource: { kind: 'none' }, valueFormat: DECIMAL_VALUE },
|
|
388
494
|
}),
|
|
389
495
|
};
|
|
390
496
|
}
|
|
@@ -434,7 +540,9 @@ export function bigInt(options) {
|
|
|
434
540
|
}
|
|
435
541
|
return BigInt(trimmed);
|
|
436
542
|
});
|
|
437
|
-
let schema = coerced
|
|
543
|
+
let schema = coerced.refine((val) => val >= INT64_MIN && val <= INT64_MAX, {
|
|
544
|
+
message: `${formatFieldName(fieldName)} is outside the 64-bit range`,
|
|
545
|
+
});
|
|
438
546
|
if (validation?.min !== undefined) {
|
|
439
547
|
const min = validation.min;
|
|
440
548
|
schema = schema.refine((val) => val >= min, {
|
|
@@ -449,7 +557,11 @@ export function bigInt(options) {
|
|
|
449
557
|
}
|
|
450
558
|
if (isRequired && operation === 'update')
|
|
451
559
|
return schema.optional();
|
|
452
|
-
|
|
560
|
+
if (isRequired)
|
|
561
|
+
return schema;
|
|
562
|
+
return (options?.db?.isNullable ?? !isRequired)
|
|
563
|
+
? schema.optional().nullable()
|
|
564
|
+
: schema.optional();
|
|
453
565
|
},
|
|
454
566
|
getContractField: (fieldName, listKey) => {
|
|
455
567
|
const defaultValue = options?.defaultValue;
|
|
@@ -470,11 +582,15 @@ export function bigInt(options) {
|
|
|
470
582
|
operators: COMPARISON_OPERATORS,
|
|
471
583
|
toCondition: (operator, value) => {
|
|
472
584
|
const trimmed = value.trim();
|
|
473
|
-
if (
|
|
585
|
+
if (!WHOLE_NUMBER_MATCH.test(trimmed))
|
|
586
|
+
return null;
|
|
587
|
+
const parsed = BigInt(trimmed);
|
|
588
|
+
if (parsed < INT64_MIN || parsed > INT64_MAX)
|
|
474
589
|
return null;
|
|
475
|
-
return { [fieldName]: { [prismaComparisonKey(operator)]:
|
|
590
|
+
return { [fieldName]: { [prismaComparisonKey(operator)]: parsed } };
|
|
476
591
|
},
|
|
477
|
-
|
|
592
|
+
empty: emptyWhenNullable(fieldName, options?.db?.isNullable ?? !options?.validation?.isRequired),
|
|
593
|
+
suggestions: { valueSource: { kind: 'none' }, valueFormat: WHOLE_NUMBER },
|
|
478
594
|
}),
|
|
479
595
|
};
|
|
480
596
|
}
|
|
@@ -486,8 +602,11 @@ export function checkbox(options) {
|
|
|
486
602
|
type: 'checkbox',
|
|
487
603
|
...options,
|
|
488
604
|
defaultValue: options?.defaultValue ?? false,
|
|
489
|
-
getZodSchema: () => {
|
|
490
|
-
|
|
605
|
+
getZodSchema: (fieldName) => {
|
|
606
|
+
const schema = z
|
|
607
|
+
.boolean({ message: `${formatFieldName(fieldName)} must be true or false` })
|
|
608
|
+
.optional();
|
|
609
|
+
return options?.db?.isNullable === true ? schema.nullable() : schema;
|
|
491
610
|
},
|
|
492
611
|
getContractField: (fieldName, listKey) => {
|
|
493
612
|
checkedDefault(options?.defaultValue, listKey, fieldName, 'a boolean', (value) => typeof value === 'boolean');
|
|
@@ -511,6 +630,7 @@ export function checkbox(options) {
|
|
|
511
630
|
return { [fieldName]: { equals: false } };
|
|
512
631
|
return null;
|
|
513
632
|
},
|
|
633
|
+
empty: emptyWhenNullable(fieldName, options?.db?.isNullable === true),
|
|
514
634
|
suggestions: {
|
|
515
635
|
valueSource: {
|
|
516
636
|
kind: 'enum',
|
|
@@ -523,41 +643,58 @@ export function checkbox(options) {
|
|
|
523
643
|
}),
|
|
524
644
|
};
|
|
525
645
|
}
|
|
646
|
+
export function isZonelessNativeType(nativeType) {
|
|
647
|
+
return nativeType !== undefined && /^timestamp\s*(\(|$)/i.test(nativeType.trim());
|
|
648
|
+
}
|
|
526
649
|
/**
|
|
527
650
|
* Timestamp (DateTime) field
|
|
528
651
|
*/
|
|
529
652
|
export function timestamp(options) {
|
|
653
|
+
const defaultValue = options?.defaultValue;
|
|
654
|
+
const hasDefaultNow = typeof defaultValue === 'object' &&
|
|
655
|
+
defaultValue !== null &&
|
|
656
|
+
'kind' in defaultValue &&
|
|
657
|
+
defaultValue.kind === 'now';
|
|
658
|
+
const nullable = options?.db?.isNullable ?? !hasDefaultNow;
|
|
530
659
|
return {
|
|
531
660
|
type: 'timestamp',
|
|
532
661
|
...options,
|
|
533
|
-
getZodSchema: () => {
|
|
534
|
-
|
|
662
|
+
getZodSchema: (_fieldName, _operation, defaults) => {
|
|
663
|
+
const zoneless = isZonelessNativeType(options?.db?.nativeType ?? defaults?.timestampNativeType);
|
|
664
|
+
return z
|
|
665
|
+
.union([z.date(), z.iso.datetime(zoneless ? { local: true } : undefined)])
|
|
666
|
+
.optional()
|
|
667
|
+
.nullable();
|
|
535
668
|
},
|
|
536
669
|
getContractField: (fieldName) => {
|
|
537
|
-
const defaultValue = options?.defaultValue;
|
|
538
|
-
const hasDefaultNow = typeof defaultValue === 'object' &&
|
|
539
|
-
defaultValue !== null &&
|
|
540
|
-
'kind' in defaultValue &&
|
|
541
|
-
defaultValue.kind === 'now';
|
|
542
670
|
return scalarColumn(fieldName, {
|
|
543
671
|
type: pgType('dateTime'),
|
|
544
|
-
nullable
|
|
672
|
+
nullable,
|
|
545
673
|
nativeType: options?.db?.nativeType,
|
|
546
674
|
map: options?.db?.map,
|
|
547
675
|
isIndexed: options?.isIndexed,
|
|
548
676
|
default: hasDefaultNow ? { kind: 'now' } : undefined,
|
|
549
677
|
});
|
|
550
678
|
},
|
|
551
|
-
// An unparseable date degrades to free text.
|
|
679
|
+
// An unparseable date degrades to free text. `eq` and `lte` on a date-only `YYYY-MM-DD` value cover that whole UTC day.
|
|
552
680
|
getFilterSpec: (fieldName) => ({
|
|
553
681
|
operators: COMPARISON_OPERATORS,
|
|
554
682
|
toCondition: (operator, value) => {
|
|
555
|
-
const
|
|
683
|
+
const typed = value.trim();
|
|
684
|
+
const date = new Date(typed);
|
|
556
685
|
if (Number.isNaN(date.getTime()))
|
|
557
686
|
return null;
|
|
687
|
+
if (DATE_VALUE_MATCH.test(typed) && date.toISOString().startsWith(typed)) {
|
|
688
|
+
const next = new Date(date.getTime() + 86_400_000);
|
|
689
|
+
if (operator === 'eq')
|
|
690
|
+
return { [fieldName]: { gte: date, lt: next } };
|
|
691
|
+
if (operator === 'lte')
|
|
692
|
+
return { [fieldName]: { lt: next } };
|
|
693
|
+
}
|
|
558
694
|
return { [fieldName]: { [prismaComparisonKey(operator)]: date } };
|
|
559
695
|
},
|
|
560
|
-
|
|
696
|
+
empty: emptyWhenNullable(fieldName, nullable),
|
|
697
|
+
suggestions: { valueSource: { kind: 'none' }, datePicker: 'instant' },
|
|
561
698
|
}),
|
|
562
699
|
};
|
|
563
700
|
}
|
|
@@ -638,6 +775,9 @@ export function calendarDay(options) {
|
|
|
638
775
|
})
|
|
639
776
|
.regex(/^\d{4}-\d{2}-\d{2}$/, {
|
|
640
777
|
message: `${formatFieldName(fieldName)} must be in YYYY-MM-DD format`,
|
|
778
|
+
})
|
|
779
|
+
.refine(isCalendarDate, {
|
|
780
|
+
message: `${formatFieldName(fieldName)} must be a real calendar date in YYYY-MM-DD format`,
|
|
641
781
|
});
|
|
642
782
|
if (isRequired && operation === 'create') {
|
|
643
783
|
return dateSchema;
|
|
@@ -646,7 +786,9 @@ export function calendarDay(options) {
|
|
|
646
786
|
return dateSchema.optional();
|
|
647
787
|
}
|
|
648
788
|
else {
|
|
649
|
-
return
|
|
789
|
+
return (options?.db?.isNullable ?? !isRequired)
|
|
790
|
+
? dateSchema.optional().nullable()
|
|
791
|
+
: dateSchema.optional();
|
|
650
792
|
}
|
|
651
793
|
},
|
|
652
794
|
getContractField: (fieldName, listKey) => {
|
|
@@ -663,20 +805,19 @@ export function calendarDay(options) {
|
|
|
663
805
|
// Calendar days compare on the `YYYY-MM-DD` value itself — the column's
|
|
664
806
|
// string codec passes it straight to the driver, so a Date built here
|
|
665
807
|
// would hit the same local-timezone drift the write path had (#1437). A
|
|
666
|
-
// malformed value, including
|
|
667
|
-
//
|
|
808
|
+
// malformed value, including a day the month does not have (e.g.
|
|
809
|
+
// '2025-02-31'), degrades to free text instead of
|
|
668
810
|
// reaching Postgres as an invalid date literal.
|
|
669
811
|
getFilterSpec: (fieldName) => ({
|
|
670
812
|
operators: COMPARISON_OPERATORS,
|
|
671
813
|
toCondition: (operator, value) => {
|
|
672
814
|
const trimmed = value.trim();
|
|
673
|
-
if (
|
|
674
|
-
return null;
|
|
675
|
-
if (Number.isNaN(new Date(`${trimmed}T00:00:00.000Z`).getTime()))
|
|
815
|
+
if (!DATE_VALUE_MATCH.test(trimmed) || !isCalendarDate(trimmed))
|
|
676
816
|
return null;
|
|
677
817
|
return { [fieldName]: { [prismaComparisonKey(operator)]: trimmed } };
|
|
678
818
|
},
|
|
679
|
-
|
|
819
|
+
empty: emptyWhenNullable(fieldName, options?.db?.isNullable ?? !options?.validation?.isRequired),
|
|
820
|
+
suggestions: { valueSource: { kind: 'none' }, valueFormat: DATE_VALUE, datePicker: 'day' },
|
|
680
821
|
}),
|
|
681
822
|
};
|
|
682
823
|
}
|
|
@@ -858,11 +999,14 @@ export function select(options) {
|
|
|
858
999
|
}
|
|
859
1000
|
}
|
|
860
1001
|
const unionType = options.options.map((opt) => quoteStringLiteral(opt.value)).join(' | ');
|
|
1002
|
+
const nullable = options.db?.isNullable ??
|
|
1003
|
+
(!options.validation?.isRequired && options.defaultValue === undefined);
|
|
861
1004
|
return {
|
|
862
1005
|
type: 'select',
|
|
863
1006
|
outputType: unionType,
|
|
864
1007
|
inputType: unionType,
|
|
865
1008
|
...options,
|
|
1009
|
+
nullable,
|
|
866
1010
|
getZodSchema: (fieldName, operation) => {
|
|
867
1011
|
const values = options.options.map((opt) => opt.value);
|
|
868
1012
|
let schema = z.enum(values, {
|
|
@@ -873,13 +1017,11 @@ export function select(options) {
|
|
|
873
1017
|
schema = schema.optional();
|
|
874
1018
|
}
|
|
875
1019
|
else {
|
|
876
|
-
schema = schema.optional().nullable();
|
|
1020
|
+
schema = nullable ? schema.optional().nullable() : schema.optional();
|
|
877
1021
|
}
|
|
878
1022
|
return schema;
|
|
879
1023
|
},
|
|
880
1024
|
getContractField: (fieldName, listName) => {
|
|
881
|
-
const hasDefault = options.defaultValue !== undefined;
|
|
882
|
-
const nullable = options.db?.isNullable ?? (!options.validation?.isRequired && !hasDefault);
|
|
883
1025
|
if (!isNativeEnum) {
|
|
884
1026
|
return scalarColumn(fieldName, {
|
|
885
1027
|
type: pgType('text'),
|
|
@@ -917,6 +1059,7 @@ export function select(options) {
|
|
|
917
1059
|
return null;
|
|
918
1060
|
return { [fieldName]: { equals: match.value } };
|
|
919
1061
|
},
|
|
1062
|
+
empty: emptyWhenNullable(fieldName, nullable),
|
|
920
1063
|
suggestions: {
|
|
921
1064
|
valueSource: {
|
|
922
1065
|
kind: 'enum',
|
|
@@ -1047,9 +1190,6 @@ export function shouldHaveForeignKey(listKey, fieldName, field, config) {
|
|
|
1047
1190
|
* The name Prisma generation synthesizes for the back-relation a list-only
|
|
1048
1191
|
* `ref` (`ref: 'ListName'`, no target field) creates on its target model —
|
|
1049
1192
|
* Prisma requires an opposite field, and the config never declares one.
|
|
1050
|
-
* Exported so runtime nested-write resolution (`resolveSyntheticReverseRelation`
|
|
1051
|
-
* in `access/engine.ts`) can recognise the same name rather than re-deriving
|
|
1052
|
-
* the format by string parsing (#978).
|
|
1053
1193
|
*/
|
|
1054
1194
|
export function getSyntheticFieldName(listKey, fieldName) {
|
|
1055
1195
|
return `from_${listKey}_${fieldName}`;
|
|
@@ -1121,7 +1261,8 @@ export function relationship(options) {
|
|
|
1121
1261
|
// • to-one filters by the related Item's label — `author:"Ada Lovelace"`
|
|
1122
1262
|
// becomes a `some` over the target list's Label field. Prisma 8 has no
|
|
1123
1263
|
// to-one predicate form: every relation predicate is an EXISTS, and its
|
|
1124
|
-
// accessor is the same for both cardinalities.
|
|
1264
|
+
// accessor is the same for both cardinalities. `author:#id` matches the
|
|
1265
|
+
// related record by its id, through the same relation predicate.
|
|
1125
1266
|
// • to-many filters by PRESENCE. Prisma 8 cannot compare a relation count
|
|
1126
1267
|
// in a `where`, so `orders:0` is `none`, `orders:>0`/`orders:>=1` are
|
|
1127
1268
|
// `some`, and any other comparison degrades to free text.
|
|
@@ -1134,21 +1275,18 @@ export function relationship(options) {
|
|
|
1134
1275
|
return undefined;
|
|
1135
1276
|
if (field.many === true) {
|
|
1136
1277
|
return {
|
|
1137
|
-
operators:
|
|
1278
|
+
operators: ['eq', 'gt', 'gte'],
|
|
1138
1279
|
toCondition: (operator, value) => {
|
|
1139
|
-
|
|
1140
|
-
if (!/^-?\d+$/.test(trimmed))
|
|
1280
|
+
if (!PRESENCE_COUNT_MATCH(operator, value.trim()))
|
|
1141
1281
|
return null;
|
|
1142
|
-
|
|
1143
|
-
if (operator === 'eq' && count === 0)
|
|
1282
|
+
if (operator === 'eq')
|
|
1144
1283
|
return { [_fieldName]: { none: {} } };
|
|
1145
|
-
if (operator === 'gt'
|
|
1146
|
-
return { [_fieldName]: { some: {} } };
|
|
1147
|
-
if (operator === 'gte' && count === 1)
|
|
1284
|
+
if (operator === 'gt' || operator === 'gte')
|
|
1148
1285
|
return { [_fieldName]: { some: {} } };
|
|
1149
1286
|
return null;
|
|
1150
1287
|
},
|
|
1151
|
-
|
|
1288
|
+
negation: 'redundant',
|
|
1289
|
+
suggestions: { valueSource: { kind: 'none' }, valueFormat: PRESENCE_COUNT },
|
|
1152
1290
|
};
|
|
1153
1291
|
}
|
|
1154
1292
|
const labelField = getLabelFieldName(relatedListConfig);
|
|
@@ -1161,6 +1299,7 @@ export function relationship(options) {
|
|
|
1161
1299
|
// integer, checkbox, select, etc.). None of these is filterable (#1359).
|
|
1162
1300
|
if (labelFieldConfig?.type !== 'text' || labelFieldConfig.virtual === true)
|
|
1163
1301
|
return undefined;
|
|
1302
|
+
const canBeEmpty = !shouldHaveForeignKey(_listKey, _fieldName, field, config) || field.db?.isNullable !== false;
|
|
1164
1303
|
return {
|
|
1165
1304
|
operators: ['eq'],
|
|
1166
1305
|
toCondition: (operator, value) => {
|
|
@@ -1168,6 +1307,12 @@ export function relationship(options) {
|
|
|
1168
1307
|
return null;
|
|
1169
1308
|
return { [_fieldName]: { some: { [labelField]: { contains: value } } } };
|
|
1170
1309
|
},
|
|
1310
|
+
toIdCondition: (id) => {
|
|
1311
|
+
const parsed = parseListId(config, targetList, id);
|
|
1312
|
+
return parsed.ok ? { [_fieldName]: { some: { id: { equals: parsed.value } } } } : null;
|
|
1313
|
+
},
|
|
1314
|
+
empty: canBeEmpty ? { [_fieldName]: { none: {} } } : undefined,
|
|
1315
|
+
negation: 'includesEmpty',
|
|
1171
1316
|
suggestions: { valueSource: { kind: 'relationship', listKey: targetList, many: false } },
|
|
1172
1317
|
};
|
|
1173
1318
|
};
|
|
@@ -1215,13 +1360,17 @@ export function relationship(options) {
|
|
|
1215
1360
|
* @returns JSON field configuration
|
|
1216
1361
|
*/
|
|
1217
1362
|
export function json(options) {
|
|
1363
|
+
const nullable = options?.db?.isNullable ?? !options?.validation?.isRequired;
|
|
1218
1364
|
return {
|
|
1219
1365
|
type: 'json',
|
|
1220
1366
|
...options,
|
|
1367
|
+
nullable,
|
|
1221
1368
|
getZodSchema: (fieldName, operation) => {
|
|
1222
1369
|
const validation = options?.validation;
|
|
1223
1370
|
const isRequired = validation?.isRequired;
|
|
1224
|
-
const baseSchema = z.unknown()
|
|
1371
|
+
const baseSchema = z.unknown().refine((value) => !hasNul(value), {
|
|
1372
|
+
message: `${formatFieldName(fieldName)} must not contain NUL characters`,
|
|
1373
|
+
});
|
|
1225
1374
|
if (isRequired && operation === 'create') {
|
|
1226
1375
|
// Required in create mode: a value must be provided and it must be
|
|
1227
1376
|
// non-null (issue #604 — a required json field means non-null). A bare
|
|
@@ -1234,12 +1383,13 @@ export function json(options) {
|
|
|
1234
1383
|
message: `${formatFieldName(fieldName)} is required`,
|
|
1235
1384
|
});
|
|
1236
1385
|
}
|
|
1237
|
-
else if (isRequired
|
|
1238
|
-
//
|
|
1239
|
-
//
|
|
1240
|
-
// (issue #604 — required json means non-null).
|
|
1241
|
-
// before `.optional()` short-circuits on undefined:
|
|
1242
|
-
// passes, a present null is rejected, and other present
|
|
1386
|
+
else if (isRequired || !nullable) {
|
|
1387
|
+
// Omitted keys still pass (issue #570 — partial updates may leave the
|
|
1388
|
+
// field untouched, and a NOT NULL column may carry a default), but a
|
|
1389
|
+
// present null is rejected (issue #604 — required json means non-null).
|
|
1390
|
+
// The `.refine()` runs before `.optional()` short-circuits on undefined:
|
|
1391
|
+
// absent/undefined passes, a present null is rejected, and other present
|
|
1392
|
+
// values pass.
|
|
1243
1393
|
return baseSchema
|
|
1244
1394
|
.refine((value) => value !== null, {
|
|
1245
1395
|
message: `${formatFieldName(fieldName)} is required`,
|
|
@@ -1252,7 +1402,7 @@ export function json(options) {
|
|
|
1252
1402
|
},
|
|
1253
1403
|
getContractField: (fieldName, listKey) => scalarColumn(fieldName, {
|
|
1254
1404
|
type: pgType('jsonb'),
|
|
1255
|
-
nullable
|
|
1405
|
+
nullable,
|
|
1256
1406
|
nativeType: options?.db?.nativeType,
|
|
1257
1407
|
map: options?.db?.map,
|
|
1258
1408
|
default: literalDefault(options?.defaultValue, listKey, fieldName),
|