better-schemic 0.1.0-beta.6 → 0.1.0-beta.8
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/README.md +72 -5
- package/lib/aot.d.ts +2 -3
- package/lib/aot.js +9 -3431
- package/lib/authoring.js +17 -212
- package/lib/chunk-00apd4ns.js +62 -0
- package/lib/chunk-0avev9qc.js +7 -0
- package/lib/chunk-0xecyh0f.js +1060 -0
- package/lib/chunk-14s9y00s.js +31 -0
- package/lib/chunk-2nz25g5r.js +27 -0
- package/lib/chunk-58rf0smz.js +332 -0
- package/lib/chunk-7mav5k1w.js +3 -0
- package/lib/chunk-855b9bex.js +240 -0
- package/lib/chunk-8akck8xw.js +17 -0
- package/lib/chunk-963xgz1s.js +2852 -0
- package/lib/chunk-ap8jd774.js +232 -0
- package/lib/chunk-cvsxxbcx.js +477 -0
- package/lib/chunk-gcmqdtdc.js +23 -0
- package/lib/chunk-h6nk8mve.js +15 -0
- package/lib/chunk-hmbm9mgx.js +54 -0
- package/lib/chunk-jh0sq69g.js +374 -0
- package/lib/chunk-k0k2tyw7.js +19 -0
- package/lib/chunk-k8qpfr1z.js +167 -0
- package/lib/chunk-nr8c9y3r.js +340 -0
- package/lib/chunk-nwxy0jc2.js +79 -0
- package/lib/chunk-pt1ejnc2.js +4839 -0
- package/lib/chunk-qx9yrabp.js +201 -0
- package/lib/chunk-r96r37ts.js +20 -0
- package/lib/chunk-srnezxwj.js +11 -0
- package/lib/chunk-tpkbpbr7.js +9 -0
- package/lib/chunk-v7tc7wtb.js +111 -0
- package/lib/chunk-wnrwcrwb.js +423 -0
- package/lib/chunk-x2enykdk.js +873 -0
- package/lib/chunk-ysdrf8d2.js +8909 -0
- package/lib/chunk-zabx1bky.js +19 -0
- package/lib/cli/action.d.ts +3 -0
- package/lib/cli/compile.d.ts +20 -14
- package/lib/cli/constants.d.ts +6 -0
- package/lib/cli/generate-orm.d.ts +19 -16
- package/lib/cli/generate.d.ts +26 -0
- package/lib/cli/index.js +1125 -10052
- package/lib/cli/init.d.ts +4 -4
- package/lib/cli/inspect.d.ts +4 -4
- package/lib/cli/migrate.d.ts +26 -32
- package/lib/cli/portable-diff.d.ts +1 -1
- package/lib/cli/resolve.d.ts +10 -10
- package/lib/config.js +6 -14777
- package/lib/connection.js +5 -14777
- package/lib/core/authoring.d.ts +20 -20
- package/lib/core/cli-kit/config.d.ts +32 -22
- package/lib/core/cli-kit/diff.d.ts +18 -18
- package/lib/core/cli-kit/filter.d.ts +22 -22
- package/lib/core/cli-kit/generated.d.ts +32 -0
- package/lib/core/cli-kit/json.d.ts +2 -0
- package/lib/core/cli-kit/merge.d.ts +33 -33
- package/lib/core/cli-kit/meta.d.ts +16 -13
- package/lib/core/cli-kit/pager.d.ts +1 -1
- package/lib/core/cli-kit/schema.d.ts +9 -14
- package/lib/core/cli-kit/style.d.ts +6 -6
- package/lib/core/cli-kit/zod-specifier.d.ts +16 -0
- package/lib/core/client-base.d.ts +14 -0
- package/lib/core/client.d.ts +12 -19
- package/lib/core/config.d.ts +92 -21
- package/lib/core/connection.d.ts +29 -29
- package/lib/core/driver/driver.d.ts +135 -135
- package/lib/core/driver/portable-ir.d.ts +19 -19
- package/lib/core/driver/portable.d.ts +33 -33
- package/lib/core/driver/sdk.d.ts +3 -3
- package/lib/core/driver/sdk.js +46 -467
- package/lib/core/index.d.ts +12 -12
- package/lib/core/index.js +148 -1587
- package/lib/core/kind/index.d.ts +1 -1
- package/lib/core/kind/plan.d.ts +15 -15
- package/lib/core/kind/registry.d.ts +81 -75
- package/lib/core/secrets.d.ts +6 -6
- package/lib/core/seed.d.ts +2 -2
- package/lib/core/testing.d.ts +10 -10
- package/lib/driver.d.ts +1 -1
- package/lib/driver.js +45 -9489
- package/lib/index.d.ts +2 -2
- package/lib/index.js +124 -3496
- package/lib/logger.js +6 -1069
- package/lib/orm/index.js +138 -15012
- package/lib/otel/index.d.ts +1 -1
- package/lib/otel/index.js +19 -67
- package/lib/otel/logger.d.ts +18 -18
- package/lib/plugin.d.ts +2 -3
- package/lib/plugin.js +4 -5
- package/lib/plugins/create-only.d.ts +1 -1
- package/lib/plugins/create-only.js +55 -4310
- package/lib/plugins/hard-delete.js +8 -350
- package/lib/plugins/policy.js +42 -570
- package/lib/plugins/rules.js +34 -377
- package/lib/plugins/soft-delete.js +42 -3977
- package/lib/plugins/tenant.js +160 -4391
- package/lib/plugins/timestamps.js +23 -3984
- package/lib/plugins/zod.js +41 -3811
- package/lib/query.js +87 -3634
- package/lib/surreal/checks.d.ts +11 -17
- package/lib/surreal/cli/engine.d.ts +8 -8
- package/lib/surreal/cli/format.d.ts +2 -2
- package/lib/surreal/cli/introspect.d.ts +6 -13
- package/lib/surreal/cli/lower.d.ts +6 -6
- package/lib/surreal/cli/pull.d.ts +5 -6
- package/lib/surreal/cli/struct.d.ts +6 -6
- package/lib/surreal/cli/structure.d.ts +97 -97
- package/lib/surreal/cli/surreal-diff.d.ts +6 -6
- package/lib/surreal/cli/surreal-filter.d.ts +2 -2
- package/lib/surreal/config.d.ts +43 -43
- package/lib/surreal/connection.d.ts +6 -7
- package/lib/surreal/ddl.d.ts +46 -58
- package/lib/surreal/driver.d.ts +1 -1
- package/lib/surreal/fn-name.d.ts +4 -4
- package/lib/surreal/fn.d.ts +82 -73
- package/lib/surreal/frag.d.ts +9 -4
- package/lib/surreal/ident.d.ts +3 -20
- package/lib/surreal/index.d.ts +4 -51
- package/lib/surreal/kinds/explode.d.ts +3 -3
- package/lib/surreal/kinds/portable.d.ts +41 -47
- package/lib/surreal/kinds/registry.d.ts +1 -2
- package/lib/surreal/orm/ai/context.d.ts +3 -0
- package/lib/surreal/orm/ai/index.d.ts +13 -0
- package/lib/surreal/orm/ai/policy.d.ts +8 -0
- package/lib/surreal/orm/ai/query.d.ts +25 -0
- package/lib/surreal/orm/ai/tool.d.ts +15 -0
- package/lib/surreal/orm/ai/types.d.ts +160 -0
- package/lib/surreal/orm/api.d.ts +2 -0
- package/lib/surreal/orm/arithmetic.d.ts +18 -18
- package/lib/surreal/orm/batch.d.ts +8 -0
- package/lib/surreal/orm/client.d.ts +45 -33
- package/lib/surreal/orm/compiler/adjustment.d.ts +15 -15
- package/lib/surreal/orm/compiler/aggregate-entries.d.ts +33 -33
- package/lib/surreal/orm/compiler/aggregate-operand.d.ts +8 -8
- package/lib/surreal/orm/compiler/aggregate-split.d.ts +1 -1
- package/lib/surreal/orm/compiler/aggregate.d.ts +46 -41
- package/lib/surreal/orm/compiler/graph.d.ts +27 -26
- package/lib/surreal/orm/compiler/include/index.d.ts +5 -5
- package/lib/surreal/orm/compiler/include/links.d.ts +1 -1
- package/lib/surreal/orm/compiler/include/projection.d.ts +14 -14
- package/lib/surreal/orm/compiler/include/specs.d.ts +54 -52
- package/lib/surreal/orm/compiler/keyset.d.ts +13 -13
- package/lib/surreal/orm/compiler/mutate.d.ts +6 -6
- package/lib/surreal/orm/compiler/pagination.d.ts +62 -62
- package/lib/surreal/orm/compiler/projection.d.ts +47 -47
- package/lib/surreal/orm/compiler/relate.d.ts +15 -15
- package/lib/surreal/orm/compiler/relations.d.ts +17 -23
- package/lib/surreal/orm/compiler/reserved.d.ts +3 -0
- package/lib/surreal/orm/compiler/select.d.ts +34 -34
- package/lib/surreal/orm/compiler/shared.d.ts +32 -24
- package/lib/surreal/orm/compiler/unique.d.ts +10 -10
- package/lib/surreal/orm/compiler/where.d.ts +21 -21
- package/lib/surreal/orm/compiler/write-shared.d.ts +123 -114
- package/lib/surreal/orm/compiler/write.d.ts +1 -1
- package/lib/surreal/orm/connect.d.ts +9 -9
- package/lib/surreal/orm/context.d.ts +1 -1
- package/lib/surreal/orm/delegate.d.ts +119 -114
- package/lib/surreal/orm/delta.d.ts +6 -6
- package/lib/surreal/orm/describe.d.ts +51 -51
- package/lib/surreal/orm/errors.d.ts +25 -14
- package/lib/surreal/orm/execute.d.ts +59 -45
- package/lib/surreal/orm/fn.d.ts +3 -3
- package/lib/surreal/orm/graph.d.ts +70 -4
- package/lib/surreal/orm/hooks.d.ts +12 -30
- package/lib/surreal/orm/index.d.ts +24 -14
- package/lib/surreal/orm/logger/colors.d.ts +5 -6
- package/lib/surreal/orm/logger/detect-color.d.ts +2 -2
- package/lib/surreal/orm/logger/emit.d.ts +18 -18
- package/lib/surreal/orm/logger/highlight.d.ts +6 -7
- package/lib/surreal/orm/logger/index.d.ts +0 -1
- package/lib/surreal/orm/logger/logger.d.ts +1 -1
- package/lib/surreal/orm/logger/options.d.ts +1 -1
- package/lib/surreal/orm/logger/plan.d.ts +4 -17
- package/lib/surreal/orm/meta.d.ts +62 -62
- package/lib/surreal/orm/operations.d.ts +65 -0
- package/lib/surreal/orm/plugins.d.ts +12 -12
- package/lib/surreal/orm/raw.d.ts +8 -8
- package/lib/surreal/orm/reads.d.ts +49 -1
- package/lib/surreal/orm/results.d.ts +104 -37
- package/lib/surreal/orm/schema.d.ts +3 -3
- package/lib/surreal/orm/search.d.ts +29 -0
- package/lib/surreal/orm/semantic.d.ts +41 -41
- package/lib/surreal/orm/sql-statement.d.ts +5 -0
- package/lib/surreal/orm/text.d.ts +14 -0
- package/lib/surreal/orm/transaction.d.ts +15 -15
- package/lib/surreal/orm/types/admin.d.ts +26 -26
- package/lib/surreal/orm/types/api.d.ts +34 -12
- package/lib/surreal/orm/types/auth.d.ts +8 -8
- package/lib/surreal/orm/types/client.d.ts +72 -65
- package/lib/surreal/orm/types/context.d.ts +11 -11
- package/lib/surreal/orm/types/fn.d.ts +13 -9
- package/lib/surreal/orm/types/hooks.d.ts +71 -81
- package/lib/surreal/orm/types/include.d.ts +35 -33
- package/lib/surreal/orm/types/logger.d.ts +76 -76
- package/lib/surreal/orm/types/plugins.d.ts +43 -44
- package/lib/surreal/orm/types/raw.d.ts +16 -16
- package/lib/surreal/orm/types/relations.d.ts +7 -7
- package/lib/surreal/orm/types/schema.d.ts +16 -16
- package/lib/surreal/orm/types/search.d.ts +60 -0
- package/lib/surreal/orm/types/select.d.ts +197 -170
- package/lib/surreal/orm/types/transaction.d.ts +25 -25
- package/lib/surreal/orm/types/where.d.ts +101 -92
- package/lib/surreal/orm/types/write.d.ts +218 -221
- package/lib/surreal/orm/validate.d.ts +41 -0
- package/lib/surreal/orm/writes.d.ts +27 -4
- package/lib/surreal/plugins/create-only-shared.d.ts +9 -9
- package/lib/surreal/plugins/create-only.d.ts +13 -28
- package/lib/surreal/plugins/hard-delete.d.ts +7 -20
- package/lib/surreal/plugins/policy.d.ts +18 -18
- package/lib/surreal/plugins/rules.d.ts +6 -6
- package/lib/surreal/plugins/soft-delete.d.ts +30 -67
- package/lib/surreal/plugins/tenant-runtime.d.ts +26 -57
- package/lib/surreal/plugins/tenant-shared.d.ts +1 -1
- package/lib/surreal/plugins/tenant.d.ts +34 -36
- package/lib/surreal/plugins/timestamps.d.ts +5 -5
- package/lib/surreal/plugins/zod.d.ts +6 -6
- package/lib/surreal/pure.d.ts +724 -691
- package/lib/surreal/query.d.ts +2 -2
- package/lib/surreal/seed.d.ts +1 -1
- package/lib/surreal/surql/block.d.ts +32 -32
- package/lib/surreal/surql/predicate.d.ts +95 -91
- package/lib/surreal/surql/ref.d.ts +4 -4
- package/lib/surreal/surql/render.d.ts +4 -9
- package/lib/surreal/surql/typed-bound.d.ts +6 -6
- package/lib/surreal/surql-tag.d.ts +54 -0
- package/lib/surreal/wire.d.ts +15 -15
- package/lib/testing.js +28 -373
- package/lib/zod-core.d.ts +7 -0
- package/lib/zod-core.js +5 -0
- package/lib/zod.d.ts +11 -0
- package/lib/zod.js +12 -0
- package/package.json +29 -7
- package/src/aot.ts +11 -10
- package/src/authoring.ts +1 -1
- package/src/cli/action.ts +36 -20
- package/src/cli/compile.ts +150 -91
- package/src/cli/constants.ts +9 -0
- package/src/cli/driver-commands.ts +91 -85
- package/src/cli/generate-orm.ts +111 -76
- package/src/cli/generate.ts +164 -0
- package/src/cli/index.ts +716 -765
- package/src/cli/init.ts +30 -27
- package/src/cli/inspect.ts +124 -152
- package/src/cli/migrate.ts +282 -299
- package/src/cli/portable-diff.ts +26 -34
- package/src/cli/resolve.ts +142 -150
- package/src/config.ts +2 -2
- package/src/connection.ts +1 -1
- package/src/core/authoring.ts +100 -165
- package/src/core/cli-kit/config.ts +156 -107
- package/src/core/cli-kit/diff.ts +166 -167
- package/src/core/cli-kit/filter.ts +69 -68
- package/src/core/cli-kit/generated.ts +314 -0
- package/src/core/cli-kit/json.ts +2 -0
- package/src/core/cli-kit/merge.ts +297 -282
- package/src/core/cli-kit/meta.ts +96 -82
- package/src/core/cli-kit/pager.ts +84 -58
- package/src/core/cli-kit/schema.ts +94 -78
- package/src/core/cli-kit/style.ts +26 -18
- package/src/core/cli-kit/zod-specifier.ts +41 -0
- package/src/core/client-base.ts +19 -0
- package/src/core/client.ts +112 -133
- package/src/core/config.ts +135 -76
- package/src/core/connection.ts +42 -54
- package/src/core/driver/driver.ts +199 -211
- package/src/core/driver/portable-ir.ts +25 -25
- package/src/core/driver/portable.ts +42 -41
- package/src/core/driver/sdk.ts +14 -22
- package/src/core/index.ts +35 -33
- package/src/core/kind/index.ts +4 -3
- package/src/core/kind/plan.ts +276 -292
- package/src/core/kind/registry.ts +127 -119
- package/src/core/secrets.ts +21 -21
- package/src/core/seed.ts +3 -3
- package/src/core/testing.ts +99 -104
- package/src/driver.ts +2 -2
- package/src/index.ts +3 -3
- package/src/logger.ts +1 -1
- package/src/orm/index.ts +1 -1
- package/src/otel/index.ts +2 -2
- package/src/otel/logger.ts +156 -141
- package/src/plugin.ts +6 -8
- package/src/plugins/create-only.ts +2 -2
- package/src/plugins/hard-delete.ts +1 -1
- package/src/plugins/policy.ts +1 -1
- package/src/plugins/rules.ts +1 -1
- package/src/plugins/soft-delete.ts +1 -1
- package/src/plugins/tenant.ts +1 -1
- package/src/plugins/timestamps.ts +1 -1
- package/src/plugins/zod.ts +1 -1
- package/src/query.ts +1 -1
- package/src/surreal/checks.ts +128 -144
- package/src/surreal/cli/engine.ts +199 -145
- package/src/surreal/cli/format.ts +158 -144
- package/src/surreal/cli/introspect.ts +143 -145
- package/src/surreal/cli/lower.ts +301 -277
- package/src/surreal/cli/pull.ts +819 -769
- package/src/surreal/cli/scaffold.ts +20 -20
- package/src/surreal/cli/struct.ts +305 -250
- package/src/surreal/cli/structure.ts +535 -497
- package/src/surreal/cli/surreal-diff.ts +235 -222
- package/src/surreal/cli/surreal-filter.ts +34 -34
- package/src/surreal/commands.ts +298 -299
- package/src/surreal/config.ts +49 -49
- package/src/surreal/connect.ts +110 -108
- package/src/surreal/connection.ts +29 -48
- package/src/surreal/ddl.ts +602 -647
- package/src/surreal/driver/surql-type.ts +73 -66
- package/src/surreal/driver/surreal.ts +226 -240
- package/src/surreal/driver.ts +11 -10
- package/src/surreal/fn-name.ts +8 -7
- package/src/surreal/fn.ts +153 -163
- package/src/surreal/frag.ts +9 -6
- package/src/surreal/ident.ts +48 -23
- package/src/surreal/index.ts +19 -162
- package/src/surreal/kinds/explode.ts +142 -130
- package/src/surreal/kinds/portable.ts +67 -81
- package/src/surreal/kinds/registry.ts +81 -89
- package/src/surreal/logger.ts +2 -2
- package/src/surreal/orm/admin.ts +64 -66
- package/src/surreal/orm/ai/context.ts +158 -0
- package/src/surreal/orm/ai/index.ts +34 -0
- package/src/surreal/orm/ai/policy.ts +47 -0
- package/src/surreal/orm/ai/query.ts +295 -0
- package/src/surreal/orm/ai/tool.ts +161 -0
- package/src/surreal/orm/ai/types.ts +160 -0
- package/src/surreal/orm/api.ts +127 -71
- package/src/surreal/orm/arithmetic.ts +77 -76
- package/src/surreal/orm/auth.ts +33 -34
- package/src/surreal/orm/batch.ts +67 -0
- package/src/surreal/orm/client.ts +326 -349
- package/src/surreal/orm/compiler/adjustment.ts +195 -199
- package/src/surreal/orm/compiler/aggregate-entries.ts +192 -156
- package/src/surreal/orm/compiler/aggregate-operand.ts +85 -68
- package/src/surreal/orm/compiler/aggregate-split.ts +81 -79
- package/src/surreal/orm/compiler/aggregate.ts +127 -135
- package/src/surreal/orm/compiler/graph.ts +208 -231
- package/src/surreal/orm/compiler/include/count.ts +88 -90
- package/src/surreal/orm/compiler/include/edges.ts +148 -175
- package/src/surreal/orm/compiler/include/index.ts +74 -77
- package/src/surreal/orm/compiler/include/links.ts +117 -89
- package/src/surreal/orm/compiler/include/projection.ts +206 -187
- package/src/surreal/orm/compiler/include/specs.ts +80 -82
- package/src/surreal/orm/compiler/keyset.ts +49 -48
- package/src/surreal/orm/compiler/mutate.ts +519 -578
- package/src/surreal/orm/compiler/pagination.ts +226 -232
- package/src/surreal/orm/compiler/projection.ts +374 -388
- package/src/surreal/orm/compiler/relate.ts +159 -168
- package/src/surreal/orm/compiler/relations.ts +176 -163
- package/src/surreal/orm/compiler/reserved.ts +3 -0
- package/src/surreal/orm/compiler/select.ts +342 -226
- package/src/surreal/orm/compiler/shared.ts +290 -256
- package/src/surreal/orm/compiler/unique.ts +80 -102
- package/src/surreal/orm/compiler/where.ts +427 -412
- package/src/surreal/orm/compiler/write-shared.ts +473 -488
- package/src/surreal/orm/compiler/write.ts +99 -114
- package/src/surreal/orm/connect.ts +60 -78
- package/src/surreal/orm/context.ts +50 -53
- package/src/surreal/orm/decode.ts +365 -367
- package/src/surreal/orm/delegate.ts +268 -292
- package/src/surreal/orm/delta.ts +51 -46
- package/src/surreal/orm/describe.ts +150 -151
- package/src/surreal/orm/errors.ts +189 -212
- package/src/surreal/orm/execute.ts +223 -151
- package/src/surreal/orm/fn.ts +109 -75
- package/src/surreal/orm/graph.ts +389 -324
- package/src/surreal/orm/hooks.ts +138 -186
- package/src/surreal/orm/index.ts +103 -57
- package/src/surreal/orm/logger/colors.ts +75 -37
- package/src/surreal/orm/logger/detect-color.ts +14 -13
- package/src/surreal/orm/logger/emit.ts +68 -95
- package/src/surreal/orm/logger/highlight.ts +163 -178
- package/src/surreal/orm/logger/index.ts +1 -16
- package/src/surreal/orm/logger/logger.ts +354 -345
- package/src/surreal/orm/logger/options.ts +25 -18
- package/src/surreal/orm/logger/plan.ts +147 -137
- package/src/surreal/orm/meta.ts +83 -94
- package/src/surreal/orm/operations.ts +81 -0
- package/src/surreal/orm/plugins.ts +137 -137
- package/src/surreal/orm/raw.ts +156 -187
- package/src/surreal/orm/reads.ts +311 -295
- package/src/surreal/orm/results.ts +208 -100
- package/src/surreal/orm/schema.ts +222 -199
- package/src/surreal/orm/search.ts +320 -0
- package/src/surreal/orm/semantic.ts +90 -95
- package/src/surreal/orm/sql-statement.ts +12 -0
- package/src/surreal/orm/text.ts +30 -0
- package/src/surreal/orm/transaction.ts +247 -239
- package/src/surreal/orm/types/admin.ts +53 -53
- package/src/surreal/orm/types/api.ts +55 -14
- package/src/surreal/orm/types/auth.ts +11 -11
- package/src/surreal/orm/types/client.ts +121 -120
- package/src/surreal/orm/types/context.ts +17 -17
- package/src/surreal/orm/types/fn.ts +26 -35
- package/src/surreal/orm/types/hooks.ts +86 -138
- package/src/surreal/orm/types/include.ts +79 -99
- package/src/surreal/orm/types/logger.ts +96 -100
- package/src/surreal/orm/types/plugins.ts +78 -84
- package/src/surreal/orm/types/raw.ts +21 -20
- package/src/surreal/orm/types/relations.ts +40 -51
- package/src/surreal/orm/types/schema.ts +49 -65
- package/src/surreal/orm/types/search.ts +74 -0
- package/src/surreal/orm/types/select.ts +354 -343
- package/src/surreal/orm/types/transaction.ts +39 -48
- package/src/surreal/orm/types/where.ts +158 -179
- package/src/surreal/orm/types/write.ts +348 -407
- package/src/surreal/orm/validate.ts +84 -0
- package/src/surreal/orm/writes.ts +340 -284
- package/src/surreal/plugins/create-only-shared.ts +30 -30
- package/src/surreal/plugins/create-only.ts +107 -128
- package/src/surreal/plugins/hard-delete.ts +27 -24
- package/src/surreal/plugins/policy.ts +117 -128
- package/src/surreal/plugins/rules.ts +74 -80
- package/src/surreal/plugins/soft-delete.ts +88 -65
- package/src/surreal/plugins/tenant-runtime.ts +287 -253
- package/src/surreal/plugins/tenant-shared.ts +9 -17
- package/src/surreal/plugins/tenant.ts +103 -119
- package/src/surreal/plugins/timestamps.ts +40 -39
- package/src/surreal/plugins/zod.ts +70 -48
- package/src/surreal/pure.ts +2629 -2888
- package/src/surreal/query.ts +4 -8
- package/src/surreal/seed.ts +5 -4
- package/src/surreal/surql/block.ts +173 -167
- package/src/surreal/surql/predicate.ts +318 -333
- package/src/surreal/surql/ref.ts +6 -8
- package/src/surreal/surql/render.ts +89 -64
- package/src/surreal/surql/typed-bound.ts +22 -24
- package/src/surreal/surql-tag.ts +142 -0
- package/src/surreal/surql-type-expr.ts +40 -26
- package/src/surreal/wire.ts +202 -215
- package/src/testing.ts +1 -1
- package/src/zod-core.ts +7 -0
- package/src/zod.ts +11 -0
- package/lib/aot.js.map +0 -20
- package/lib/authoring.js.map +0 -12
- package/lib/cli/index.js.map +0 -60
- package/lib/config.js.map +0 -98
- package/lib/connection.js.map +0 -97
- package/lib/core/driver/index.d.ts +0 -5
- package/lib/core/driver/sdk.js.map +0 -15
- package/lib/core/index.js.map +0 -25
- package/lib/driver.js.map +0 -49
- package/lib/index.js.map +0 -22
- package/lib/logger.js.map +0 -17
- package/lib/orm/index.js.map +0 -98
- package/lib/otel/index.js.map +0 -12
- package/lib/plugin.js.map +0 -10
- package/lib/plugins/create-only.js.map +0 -26
- package/lib/plugins/hard-delete.js.map +0 -13
- package/lib/plugins/policy.js.map +0 -15
- package/lib/plugins/rules.js.map +0 -13
- package/lib/plugins/soft-delete.js.map +0 -24
- package/lib/plugins/tenant.js.map +0 -28
- package/lib/plugins/timestamps.js.map +0 -25
- package/lib/plugins/zod.js.map +0 -22
- package/lib/query.js.map +0 -22
- package/lib/testing.js.map +0 -12
- package/src/core/driver/index.ts +0 -31
package/README.md
CHANGED
|
@@ -37,6 +37,8 @@ replay into — `npm i -D @surrealdb/node`).
|
|
|
37
37
|
| `better-schemic/driver` | the engine entry (CLI/engine-only — pulls in the DDL emitter) |
|
|
38
38
|
| `better-schemic/aot` | zod-compiler bridge — field unwrapping + identity-preserving compile markers |
|
|
39
39
|
| `better-schemic/plugin` | the Bun build plugin (`betterSchemic()`) that AOT-compiles plain Zod schemas |
|
|
40
|
+
| `better-schemic/zod` | the same Zod instance (`z`, `config`, `ZodRealError`, `core`) for generated code |
|
|
41
|
+
| `better-schemic/zod/core` | `zod/v4/core` re-export — keeps generated helpers on one Zod copy |
|
|
40
42
|
|
|
41
43
|
## Quick start
|
|
42
44
|
|
|
@@ -744,7 +746,7 @@ the same type (e.g. `tenant_id`) is not a conflict. For helpers over an unresolv
|
|
|
744
746
|
`.useUnchecked(preset)` (skips only the collision check, keeps `Name`/`S`) instead of casting to
|
|
745
747
|
`any`.
|
|
746
748
|
|
|
747
|
-
For the client
|
|
749
|
+
For the client facade, generate STATIC getters from the schema so the AOT compiler sees them in the
|
|
748
750
|
source (the runtime `Object.defineProperty` delegate loop is a slow path):
|
|
749
751
|
|
|
750
752
|
```sh
|
|
@@ -756,7 +758,8 @@ The file ends with `satisfies OrmSurface<typeof schema>`. Also available:
|
|
|
756
758
|
`createOrmClientFactory({ cache: 'weak' })` (per-connection client cache with `peek`/`dispose`),
|
|
757
759
|
`orm(() => conn, { schema })` (lazy connection), `setClientResolver`/`clientRef` (late binding),
|
|
758
760
|
`TypedBoundQuery`/`surqlWith` (typed raw binds + result rows), `selectQuery(from, allowlist)` (fixed
|
|
759
|
-
row keys from a projection), `s.
|
|
761
|
+
row keys from a projection), `s.jsonValue<T>()` (parses JSON into `T`; `s.json<T>()` keeps the legacy
|
|
762
|
+
string semantics), and `s.regex(source: string, flags?)`.
|
|
760
763
|
|
|
761
764
|
## AOT validation with zod-compiler
|
|
762
765
|
|
|
@@ -773,11 +776,34 @@ sc compile
|
|
|
773
776
|
# → .better-schemic/schema.aot.ts (import this instead of your schema module)
|
|
774
777
|
```
|
|
775
778
|
|
|
779
|
+
The generated header imports `config`/`ZodRealError` from `better-schemic/zod` and `zod/v4/core`
|
|
780
|
+
from `better-schemic/zod/core` — both re-export the package's own Zod, so the app needs **no direct
|
|
781
|
+
`zod` dependency**. Use `generated.zodSpecifier: "zod"` to opt out.
|
|
782
|
+
|
|
783
|
+
You can declare both generators in the config and drop all CLI flags, the `@ → src` symlink and the
|
|
784
|
+
handwritten `// @ts-nocheck` headers:
|
|
785
|
+
|
|
776
786
|
```ts
|
|
777
|
-
|
|
778
|
-
|
|
787
|
+
export default defineConfig({
|
|
788
|
+
connections: { /* … */ },
|
|
789
|
+
resolve: { alias: { "@": "./src" } },
|
|
790
|
+
generators: {
|
|
791
|
+
orm: { out: "src/db/generated/orm.generated.ts", schema: "./src/db/schema.ts", provider: "./src/db/orm-provider.ts", client: "getOrmClient" },
|
|
792
|
+
aot: { out: ".better-schemic/schema.aot.ts", importIn: ["src/index.ts"] },
|
|
793
|
+
},
|
|
794
|
+
generated: { tsNocheck: true, eslintDisable: true, knipAutoWrite: true },
|
|
795
|
+
});
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
```sh
|
|
799
|
+
sc generate # runs both; --only orm|aot, --watch, --config available
|
|
779
800
|
```
|
|
780
801
|
|
|
802
|
+
With `generators.aot.installVia: "orm"` (the default) the generated ORM facade imports the AOT
|
|
803
|
+
bootstrap, so there is no manual bootstrap import in the entry point or test setup. Aliases declared
|
|
804
|
+
in `resolve.alias` must also appear in the app's tsconfig `paths` for zod-compiler's own loader;
|
|
805
|
+
`sc compile` says so if it hits one it cannot resolve.
|
|
806
|
+
|
|
781
807
|
Use both halves: `sc compile` for authored `s.*` fields, and `better-schemic/plugin` for plain Zod
|
|
782
808
|
schemas in the app (route contracts, DTOs). The plugin wraps `zod-compiler/bun` and is meant for
|
|
783
809
|
`Bun.build({ plugins: [betterSchemic()] })` — including `bun build --compile --aot`:
|
|
@@ -791,12 +817,53 @@ await Bun.build({
|
|
|
791
817
|
});
|
|
792
818
|
```
|
|
793
819
|
|
|
820
|
+
## ORM API highlights (typed callbacks, prepared reads, hybrid search)
|
|
821
|
+
|
|
822
|
+
```ts
|
|
823
|
+
import { defineSearch, orm, param } from "better-schemic/orm";
|
|
824
|
+
import { defineFn, s, table } from "better-schemic";
|
|
825
|
+
|
|
826
|
+
const client = orm(conn, { schema: { users: User } });
|
|
827
|
+
|
|
828
|
+
// Callbacks run at COMPILE time and emit the same SQL as the object form.
|
|
829
|
+
const adults = await client.users.findMany({
|
|
830
|
+
where: (u) => u.age.gte(18),
|
|
831
|
+
select: (u) => ({ id: u.id, name: u.name }),
|
|
832
|
+
orderBy: (u) => u.age.desc(),
|
|
833
|
+
});
|
|
834
|
+
|
|
835
|
+
// Compile once, replay with fresh named values.
|
|
836
|
+
const byName = client.users
|
|
837
|
+
.findMany({ where: { name: param<string>("name") } })
|
|
838
|
+
.prepare("users.by-name");
|
|
839
|
+
await byName.execute({ name: "Ada" });
|
|
840
|
+
|
|
841
|
+
// Several operations, ONE atomic round-trip, typed tuple result.
|
|
842
|
+
const [rows, total] = await client.batch(
|
|
843
|
+
client.users.findMany({ limit: 10 }),
|
|
844
|
+
client.users.count({ where: { active: true } }),
|
|
845
|
+
);
|
|
846
|
+
|
|
847
|
+
// BM25 + ANN + a custom scorer, fused with SurrealDB's search::rrf.
|
|
848
|
+
const jw = defineFn("jw", { a: s.string(), b: s.string() }, s.string());
|
|
849
|
+
const searchUsers = defineSearch(User, {
|
|
850
|
+
select: ["id", "name"],
|
|
851
|
+
sources: {
|
|
852
|
+
bm25: { kind: "bm25", field: "name" },
|
|
853
|
+
ann: { kind: "ann", field: "embedding", k: 5 },
|
|
854
|
+
fuzzy: { kind: "fuzzy", field: "name", fn: "jw" },
|
|
855
|
+
},
|
|
856
|
+
fuse: { method: "rrf", k: 60 },
|
|
857
|
+
});
|
|
858
|
+
const hits = await searchUsers(client, { query: "Ada", embedding: [0.1, 0.2, 0.3] });
|
|
859
|
+
```
|
|
860
|
+
|
|
794
861
|
## Docs
|
|
795
862
|
|
|
796
863
|
Full guides, concepts, and reference live at
|
|
797
864
|
[docs](https://github.com/NONSTANDARDCODE/better-schemic). Feature maps:
|
|
798
865
|
[docs/COVERAGE.md](docs/COVERAGE.md) (schema/DDL) and
|
|
799
|
-
[docs/ORM-COVERAGE.md](docs/ORM-COVERAGE.md) (runtime ORM surface); the live-verified SurrealQL the
|
|
866
|
+
[docs/ORM-COVERAGE.md](docs/ORM-COVERAGE.md) (runtime ORM surface), [docs/AI-API.md](docs/AI-API.md) (AI context, guarded queries and tools); the live-verified SurrealQL the
|
|
800
867
|
ORM emits is [docs/orm-syntax-map.md](docs/orm-syntax-map.md), and the milestone plan is
|
|
801
868
|
[ROADMAP.md](../../ROADMAP.md). This package is part of the
|
|
802
869
|
[Better-schemic](https://github.com/NONSTANDARDCODE/better-schemic) toolkit.
|
package/lib/aot.d.ts
CHANGED
|
@@ -4,16 +4,15 @@
|
|
|
4
4
|
* `s.*` fields are NOT Zod instances: they are `SField` wrappers holding a Zod schema in
|
|
5
5
|
* `.schema` plus the SurrealQL metadata (`.native`). zod-compiler compiles the UNDERLYING Zod
|
|
6
6
|
* schema in place (identity-preserving), so the wrapper, the DDL metadata, `.shape`, `instanceof`
|
|
7
|
-
* and the ORM all keep working —
|
|
7
|
+
* and the ORM all keep working — validation gets the generated fast path.
|
|
8
8
|
*
|
|
9
9
|
* This module is the public, side-effect-free half. The build-time generation lives in
|
|
10
10
|
* `sc compile` (`src/cli/compile.ts`) and the bundler adapters in `better-schemic/plugin`.
|
|
11
11
|
*/
|
|
12
12
|
import type { z } from "zod";
|
|
13
|
-
import { isCompiledSchema } from "zod-compiler";
|
|
14
13
|
import { type AnyField } from "./surreal";
|
|
15
14
|
export type { CompiledSchema } from "zod-compiler";
|
|
16
|
-
export { isCompiledSchema };
|
|
15
|
+
export { isCompiledSchema } from "zod-compiler";
|
|
17
16
|
/** Unwrap an authored field to the Zod schema that actually validates it. Raw Zod schemas are
|
|
18
17
|
* accepted too — `Shape` allows them alongside `s.*` fields. */
|
|
19
18
|
export declare function fieldSchemaOf(field: AnyField | z.ZodType): z.ZodType;
|