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.
Files changed (456) hide show
  1. package/README.md +72 -5
  2. package/lib/aot.d.ts +2 -3
  3. package/lib/aot.js +9 -3431
  4. package/lib/authoring.js +17 -212
  5. package/lib/chunk-00apd4ns.js +62 -0
  6. package/lib/chunk-0avev9qc.js +7 -0
  7. package/lib/chunk-0xecyh0f.js +1060 -0
  8. package/lib/chunk-14s9y00s.js +31 -0
  9. package/lib/chunk-2nz25g5r.js +27 -0
  10. package/lib/chunk-58rf0smz.js +332 -0
  11. package/lib/chunk-7mav5k1w.js +3 -0
  12. package/lib/chunk-855b9bex.js +240 -0
  13. package/lib/chunk-8akck8xw.js +17 -0
  14. package/lib/chunk-963xgz1s.js +2852 -0
  15. package/lib/chunk-ap8jd774.js +232 -0
  16. package/lib/chunk-cvsxxbcx.js +477 -0
  17. package/lib/chunk-gcmqdtdc.js +23 -0
  18. package/lib/chunk-h6nk8mve.js +15 -0
  19. package/lib/chunk-hmbm9mgx.js +54 -0
  20. package/lib/chunk-jh0sq69g.js +374 -0
  21. package/lib/chunk-k0k2tyw7.js +19 -0
  22. package/lib/chunk-k8qpfr1z.js +167 -0
  23. package/lib/chunk-nr8c9y3r.js +340 -0
  24. package/lib/chunk-nwxy0jc2.js +79 -0
  25. package/lib/chunk-pt1ejnc2.js +4839 -0
  26. package/lib/chunk-qx9yrabp.js +201 -0
  27. package/lib/chunk-r96r37ts.js +20 -0
  28. package/lib/chunk-srnezxwj.js +11 -0
  29. package/lib/chunk-tpkbpbr7.js +9 -0
  30. package/lib/chunk-v7tc7wtb.js +111 -0
  31. package/lib/chunk-wnrwcrwb.js +423 -0
  32. package/lib/chunk-x2enykdk.js +873 -0
  33. package/lib/chunk-ysdrf8d2.js +8909 -0
  34. package/lib/chunk-zabx1bky.js +19 -0
  35. package/lib/cli/action.d.ts +3 -0
  36. package/lib/cli/compile.d.ts +20 -14
  37. package/lib/cli/constants.d.ts +6 -0
  38. package/lib/cli/generate-orm.d.ts +19 -16
  39. package/lib/cli/generate.d.ts +26 -0
  40. package/lib/cli/index.js +1125 -10052
  41. package/lib/cli/init.d.ts +4 -4
  42. package/lib/cli/inspect.d.ts +4 -4
  43. package/lib/cli/migrate.d.ts +26 -32
  44. package/lib/cli/portable-diff.d.ts +1 -1
  45. package/lib/cli/resolve.d.ts +10 -10
  46. package/lib/config.js +6 -14777
  47. package/lib/connection.js +5 -14777
  48. package/lib/core/authoring.d.ts +20 -20
  49. package/lib/core/cli-kit/config.d.ts +32 -22
  50. package/lib/core/cli-kit/diff.d.ts +18 -18
  51. package/lib/core/cli-kit/filter.d.ts +22 -22
  52. package/lib/core/cli-kit/generated.d.ts +32 -0
  53. package/lib/core/cli-kit/json.d.ts +2 -0
  54. package/lib/core/cli-kit/merge.d.ts +33 -33
  55. package/lib/core/cli-kit/meta.d.ts +16 -13
  56. package/lib/core/cli-kit/pager.d.ts +1 -1
  57. package/lib/core/cli-kit/schema.d.ts +9 -14
  58. package/lib/core/cli-kit/style.d.ts +6 -6
  59. package/lib/core/cli-kit/zod-specifier.d.ts +16 -0
  60. package/lib/core/client-base.d.ts +14 -0
  61. package/lib/core/client.d.ts +12 -19
  62. package/lib/core/config.d.ts +92 -21
  63. package/lib/core/connection.d.ts +29 -29
  64. package/lib/core/driver/driver.d.ts +135 -135
  65. package/lib/core/driver/portable-ir.d.ts +19 -19
  66. package/lib/core/driver/portable.d.ts +33 -33
  67. package/lib/core/driver/sdk.d.ts +3 -3
  68. package/lib/core/driver/sdk.js +46 -467
  69. package/lib/core/index.d.ts +12 -12
  70. package/lib/core/index.js +148 -1587
  71. package/lib/core/kind/index.d.ts +1 -1
  72. package/lib/core/kind/plan.d.ts +15 -15
  73. package/lib/core/kind/registry.d.ts +81 -75
  74. package/lib/core/secrets.d.ts +6 -6
  75. package/lib/core/seed.d.ts +2 -2
  76. package/lib/core/testing.d.ts +10 -10
  77. package/lib/driver.d.ts +1 -1
  78. package/lib/driver.js +45 -9489
  79. package/lib/index.d.ts +2 -2
  80. package/lib/index.js +124 -3496
  81. package/lib/logger.js +6 -1069
  82. package/lib/orm/index.js +138 -15012
  83. package/lib/otel/index.d.ts +1 -1
  84. package/lib/otel/index.js +19 -67
  85. package/lib/otel/logger.d.ts +18 -18
  86. package/lib/plugin.d.ts +2 -3
  87. package/lib/plugin.js +4 -5
  88. package/lib/plugins/create-only.d.ts +1 -1
  89. package/lib/plugins/create-only.js +55 -4310
  90. package/lib/plugins/hard-delete.js +8 -350
  91. package/lib/plugins/policy.js +42 -570
  92. package/lib/plugins/rules.js +34 -377
  93. package/lib/plugins/soft-delete.js +42 -3977
  94. package/lib/plugins/tenant.js +160 -4391
  95. package/lib/plugins/timestamps.js +23 -3984
  96. package/lib/plugins/zod.js +41 -3811
  97. package/lib/query.js +87 -3634
  98. package/lib/surreal/checks.d.ts +11 -17
  99. package/lib/surreal/cli/engine.d.ts +8 -8
  100. package/lib/surreal/cli/format.d.ts +2 -2
  101. package/lib/surreal/cli/introspect.d.ts +6 -13
  102. package/lib/surreal/cli/lower.d.ts +6 -6
  103. package/lib/surreal/cli/pull.d.ts +5 -6
  104. package/lib/surreal/cli/struct.d.ts +6 -6
  105. package/lib/surreal/cli/structure.d.ts +97 -97
  106. package/lib/surreal/cli/surreal-diff.d.ts +6 -6
  107. package/lib/surreal/cli/surreal-filter.d.ts +2 -2
  108. package/lib/surreal/config.d.ts +43 -43
  109. package/lib/surreal/connection.d.ts +6 -7
  110. package/lib/surreal/ddl.d.ts +46 -58
  111. package/lib/surreal/driver.d.ts +1 -1
  112. package/lib/surreal/fn-name.d.ts +4 -4
  113. package/lib/surreal/fn.d.ts +82 -73
  114. package/lib/surreal/frag.d.ts +9 -4
  115. package/lib/surreal/ident.d.ts +3 -20
  116. package/lib/surreal/index.d.ts +4 -51
  117. package/lib/surreal/kinds/explode.d.ts +3 -3
  118. package/lib/surreal/kinds/portable.d.ts +41 -47
  119. package/lib/surreal/kinds/registry.d.ts +1 -2
  120. package/lib/surreal/orm/ai/context.d.ts +3 -0
  121. package/lib/surreal/orm/ai/index.d.ts +13 -0
  122. package/lib/surreal/orm/ai/policy.d.ts +8 -0
  123. package/lib/surreal/orm/ai/query.d.ts +25 -0
  124. package/lib/surreal/orm/ai/tool.d.ts +15 -0
  125. package/lib/surreal/orm/ai/types.d.ts +160 -0
  126. package/lib/surreal/orm/api.d.ts +2 -0
  127. package/lib/surreal/orm/arithmetic.d.ts +18 -18
  128. package/lib/surreal/orm/batch.d.ts +8 -0
  129. package/lib/surreal/orm/client.d.ts +45 -33
  130. package/lib/surreal/orm/compiler/adjustment.d.ts +15 -15
  131. package/lib/surreal/orm/compiler/aggregate-entries.d.ts +33 -33
  132. package/lib/surreal/orm/compiler/aggregate-operand.d.ts +8 -8
  133. package/lib/surreal/orm/compiler/aggregate-split.d.ts +1 -1
  134. package/lib/surreal/orm/compiler/aggregate.d.ts +46 -41
  135. package/lib/surreal/orm/compiler/graph.d.ts +27 -26
  136. package/lib/surreal/orm/compiler/include/index.d.ts +5 -5
  137. package/lib/surreal/orm/compiler/include/links.d.ts +1 -1
  138. package/lib/surreal/orm/compiler/include/projection.d.ts +14 -14
  139. package/lib/surreal/orm/compiler/include/specs.d.ts +54 -52
  140. package/lib/surreal/orm/compiler/keyset.d.ts +13 -13
  141. package/lib/surreal/orm/compiler/mutate.d.ts +6 -6
  142. package/lib/surreal/orm/compiler/pagination.d.ts +62 -62
  143. package/lib/surreal/orm/compiler/projection.d.ts +47 -47
  144. package/lib/surreal/orm/compiler/relate.d.ts +15 -15
  145. package/lib/surreal/orm/compiler/relations.d.ts +17 -23
  146. package/lib/surreal/orm/compiler/reserved.d.ts +3 -0
  147. package/lib/surreal/orm/compiler/select.d.ts +34 -34
  148. package/lib/surreal/orm/compiler/shared.d.ts +32 -24
  149. package/lib/surreal/orm/compiler/unique.d.ts +10 -10
  150. package/lib/surreal/orm/compiler/where.d.ts +21 -21
  151. package/lib/surreal/orm/compiler/write-shared.d.ts +123 -114
  152. package/lib/surreal/orm/compiler/write.d.ts +1 -1
  153. package/lib/surreal/orm/connect.d.ts +9 -9
  154. package/lib/surreal/orm/context.d.ts +1 -1
  155. package/lib/surreal/orm/delegate.d.ts +119 -114
  156. package/lib/surreal/orm/delta.d.ts +6 -6
  157. package/lib/surreal/orm/describe.d.ts +51 -51
  158. package/lib/surreal/orm/errors.d.ts +25 -14
  159. package/lib/surreal/orm/execute.d.ts +59 -45
  160. package/lib/surreal/orm/fn.d.ts +3 -3
  161. package/lib/surreal/orm/graph.d.ts +70 -4
  162. package/lib/surreal/orm/hooks.d.ts +12 -30
  163. package/lib/surreal/orm/index.d.ts +24 -14
  164. package/lib/surreal/orm/logger/colors.d.ts +5 -6
  165. package/lib/surreal/orm/logger/detect-color.d.ts +2 -2
  166. package/lib/surreal/orm/logger/emit.d.ts +18 -18
  167. package/lib/surreal/orm/logger/highlight.d.ts +6 -7
  168. package/lib/surreal/orm/logger/index.d.ts +0 -1
  169. package/lib/surreal/orm/logger/logger.d.ts +1 -1
  170. package/lib/surreal/orm/logger/options.d.ts +1 -1
  171. package/lib/surreal/orm/logger/plan.d.ts +4 -17
  172. package/lib/surreal/orm/meta.d.ts +62 -62
  173. package/lib/surreal/orm/operations.d.ts +65 -0
  174. package/lib/surreal/orm/plugins.d.ts +12 -12
  175. package/lib/surreal/orm/raw.d.ts +8 -8
  176. package/lib/surreal/orm/reads.d.ts +49 -1
  177. package/lib/surreal/orm/results.d.ts +104 -37
  178. package/lib/surreal/orm/schema.d.ts +3 -3
  179. package/lib/surreal/orm/search.d.ts +29 -0
  180. package/lib/surreal/orm/semantic.d.ts +41 -41
  181. package/lib/surreal/orm/sql-statement.d.ts +5 -0
  182. package/lib/surreal/orm/text.d.ts +14 -0
  183. package/lib/surreal/orm/transaction.d.ts +15 -15
  184. package/lib/surreal/orm/types/admin.d.ts +26 -26
  185. package/lib/surreal/orm/types/api.d.ts +34 -12
  186. package/lib/surreal/orm/types/auth.d.ts +8 -8
  187. package/lib/surreal/orm/types/client.d.ts +72 -65
  188. package/lib/surreal/orm/types/context.d.ts +11 -11
  189. package/lib/surreal/orm/types/fn.d.ts +13 -9
  190. package/lib/surreal/orm/types/hooks.d.ts +71 -81
  191. package/lib/surreal/orm/types/include.d.ts +35 -33
  192. package/lib/surreal/orm/types/logger.d.ts +76 -76
  193. package/lib/surreal/orm/types/plugins.d.ts +43 -44
  194. package/lib/surreal/orm/types/raw.d.ts +16 -16
  195. package/lib/surreal/orm/types/relations.d.ts +7 -7
  196. package/lib/surreal/orm/types/schema.d.ts +16 -16
  197. package/lib/surreal/orm/types/search.d.ts +60 -0
  198. package/lib/surreal/orm/types/select.d.ts +197 -170
  199. package/lib/surreal/orm/types/transaction.d.ts +25 -25
  200. package/lib/surreal/orm/types/where.d.ts +101 -92
  201. package/lib/surreal/orm/types/write.d.ts +218 -221
  202. package/lib/surreal/orm/validate.d.ts +41 -0
  203. package/lib/surreal/orm/writes.d.ts +27 -4
  204. package/lib/surreal/plugins/create-only-shared.d.ts +9 -9
  205. package/lib/surreal/plugins/create-only.d.ts +13 -28
  206. package/lib/surreal/plugins/hard-delete.d.ts +7 -20
  207. package/lib/surreal/plugins/policy.d.ts +18 -18
  208. package/lib/surreal/plugins/rules.d.ts +6 -6
  209. package/lib/surreal/plugins/soft-delete.d.ts +30 -67
  210. package/lib/surreal/plugins/tenant-runtime.d.ts +26 -57
  211. package/lib/surreal/plugins/tenant-shared.d.ts +1 -1
  212. package/lib/surreal/plugins/tenant.d.ts +34 -36
  213. package/lib/surreal/plugins/timestamps.d.ts +5 -5
  214. package/lib/surreal/plugins/zod.d.ts +6 -6
  215. package/lib/surreal/pure.d.ts +724 -691
  216. package/lib/surreal/query.d.ts +2 -2
  217. package/lib/surreal/seed.d.ts +1 -1
  218. package/lib/surreal/surql/block.d.ts +32 -32
  219. package/lib/surreal/surql/predicate.d.ts +95 -91
  220. package/lib/surreal/surql/ref.d.ts +4 -4
  221. package/lib/surreal/surql/render.d.ts +4 -9
  222. package/lib/surreal/surql/typed-bound.d.ts +6 -6
  223. package/lib/surreal/surql-tag.d.ts +54 -0
  224. package/lib/surreal/wire.d.ts +15 -15
  225. package/lib/testing.js +28 -373
  226. package/lib/zod-core.d.ts +7 -0
  227. package/lib/zod-core.js +5 -0
  228. package/lib/zod.d.ts +11 -0
  229. package/lib/zod.js +12 -0
  230. package/package.json +29 -7
  231. package/src/aot.ts +11 -10
  232. package/src/authoring.ts +1 -1
  233. package/src/cli/action.ts +36 -20
  234. package/src/cli/compile.ts +150 -91
  235. package/src/cli/constants.ts +9 -0
  236. package/src/cli/driver-commands.ts +91 -85
  237. package/src/cli/generate-orm.ts +111 -76
  238. package/src/cli/generate.ts +164 -0
  239. package/src/cli/index.ts +716 -765
  240. package/src/cli/init.ts +30 -27
  241. package/src/cli/inspect.ts +124 -152
  242. package/src/cli/migrate.ts +282 -299
  243. package/src/cli/portable-diff.ts +26 -34
  244. package/src/cli/resolve.ts +142 -150
  245. package/src/config.ts +2 -2
  246. package/src/connection.ts +1 -1
  247. package/src/core/authoring.ts +100 -165
  248. package/src/core/cli-kit/config.ts +156 -107
  249. package/src/core/cli-kit/diff.ts +166 -167
  250. package/src/core/cli-kit/filter.ts +69 -68
  251. package/src/core/cli-kit/generated.ts +314 -0
  252. package/src/core/cli-kit/json.ts +2 -0
  253. package/src/core/cli-kit/merge.ts +297 -282
  254. package/src/core/cli-kit/meta.ts +96 -82
  255. package/src/core/cli-kit/pager.ts +84 -58
  256. package/src/core/cli-kit/schema.ts +94 -78
  257. package/src/core/cli-kit/style.ts +26 -18
  258. package/src/core/cli-kit/zod-specifier.ts +41 -0
  259. package/src/core/client-base.ts +19 -0
  260. package/src/core/client.ts +112 -133
  261. package/src/core/config.ts +135 -76
  262. package/src/core/connection.ts +42 -54
  263. package/src/core/driver/driver.ts +199 -211
  264. package/src/core/driver/portable-ir.ts +25 -25
  265. package/src/core/driver/portable.ts +42 -41
  266. package/src/core/driver/sdk.ts +14 -22
  267. package/src/core/index.ts +35 -33
  268. package/src/core/kind/index.ts +4 -3
  269. package/src/core/kind/plan.ts +276 -292
  270. package/src/core/kind/registry.ts +127 -119
  271. package/src/core/secrets.ts +21 -21
  272. package/src/core/seed.ts +3 -3
  273. package/src/core/testing.ts +99 -104
  274. package/src/driver.ts +2 -2
  275. package/src/index.ts +3 -3
  276. package/src/logger.ts +1 -1
  277. package/src/orm/index.ts +1 -1
  278. package/src/otel/index.ts +2 -2
  279. package/src/otel/logger.ts +156 -141
  280. package/src/plugin.ts +6 -8
  281. package/src/plugins/create-only.ts +2 -2
  282. package/src/plugins/hard-delete.ts +1 -1
  283. package/src/plugins/policy.ts +1 -1
  284. package/src/plugins/rules.ts +1 -1
  285. package/src/plugins/soft-delete.ts +1 -1
  286. package/src/plugins/tenant.ts +1 -1
  287. package/src/plugins/timestamps.ts +1 -1
  288. package/src/plugins/zod.ts +1 -1
  289. package/src/query.ts +1 -1
  290. package/src/surreal/checks.ts +128 -144
  291. package/src/surreal/cli/engine.ts +199 -145
  292. package/src/surreal/cli/format.ts +158 -144
  293. package/src/surreal/cli/introspect.ts +143 -145
  294. package/src/surreal/cli/lower.ts +301 -277
  295. package/src/surreal/cli/pull.ts +819 -769
  296. package/src/surreal/cli/scaffold.ts +20 -20
  297. package/src/surreal/cli/struct.ts +305 -250
  298. package/src/surreal/cli/structure.ts +535 -497
  299. package/src/surreal/cli/surreal-diff.ts +235 -222
  300. package/src/surreal/cli/surreal-filter.ts +34 -34
  301. package/src/surreal/commands.ts +298 -299
  302. package/src/surreal/config.ts +49 -49
  303. package/src/surreal/connect.ts +110 -108
  304. package/src/surreal/connection.ts +29 -48
  305. package/src/surreal/ddl.ts +602 -647
  306. package/src/surreal/driver/surql-type.ts +73 -66
  307. package/src/surreal/driver/surreal.ts +226 -240
  308. package/src/surreal/driver.ts +11 -10
  309. package/src/surreal/fn-name.ts +8 -7
  310. package/src/surreal/fn.ts +153 -163
  311. package/src/surreal/frag.ts +9 -6
  312. package/src/surreal/ident.ts +48 -23
  313. package/src/surreal/index.ts +19 -162
  314. package/src/surreal/kinds/explode.ts +142 -130
  315. package/src/surreal/kinds/portable.ts +67 -81
  316. package/src/surreal/kinds/registry.ts +81 -89
  317. package/src/surreal/logger.ts +2 -2
  318. package/src/surreal/orm/admin.ts +64 -66
  319. package/src/surreal/orm/ai/context.ts +158 -0
  320. package/src/surreal/orm/ai/index.ts +34 -0
  321. package/src/surreal/orm/ai/policy.ts +47 -0
  322. package/src/surreal/orm/ai/query.ts +295 -0
  323. package/src/surreal/orm/ai/tool.ts +161 -0
  324. package/src/surreal/orm/ai/types.ts +160 -0
  325. package/src/surreal/orm/api.ts +127 -71
  326. package/src/surreal/orm/arithmetic.ts +77 -76
  327. package/src/surreal/orm/auth.ts +33 -34
  328. package/src/surreal/orm/batch.ts +67 -0
  329. package/src/surreal/orm/client.ts +326 -349
  330. package/src/surreal/orm/compiler/adjustment.ts +195 -199
  331. package/src/surreal/orm/compiler/aggregate-entries.ts +192 -156
  332. package/src/surreal/orm/compiler/aggregate-operand.ts +85 -68
  333. package/src/surreal/orm/compiler/aggregate-split.ts +81 -79
  334. package/src/surreal/orm/compiler/aggregate.ts +127 -135
  335. package/src/surreal/orm/compiler/graph.ts +208 -231
  336. package/src/surreal/orm/compiler/include/count.ts +88 -90
  337. package/src/surreal/orm/compiler/include/edges.ts +148 -175
  338. package/src/surreal/orm/compiler/include/index.ts +74 -77
  339. package/src/surreal/orm/compiler/include/links.ts +117 -89
  340. package/src/surreal/orm/compiler/include/projection.ts +206 -187
  341. package/src/surreal/orm/compiler/include/specs.ts +80 -82
  342. package/src/surreal/orm/compiler/keyset.ts +49 -48
  343. package/src/surreal/orm/compiler/mutate.ts +519 -578
  344. package/src/surreal/orm/compiler/pagination.ts +226 -232
  345. package/src/surreal/orm/compiler/projection.ts +374 -388
  346. package/src/surreal/orm/compiler/relate.ts +159 -168
  347. package/src/surreal/orm/compiler/relations.ts +176 -163
  348. package/src/surreal/orm/compiler/reserved.ts +3 -0
  349. package/src/surreal/orm/compiler/select.ts +342 -226
  350. package/src/surreal/orm/compiler/shared.ts +290 -256
  351. package/src/surreal/orm/compiler/unique.ts +80 -102
  352. package/src/surreal/orm/compiler/where.ts +427 -412
  353. package/src/surreal/orm/compiler/write-shared.ts +473 -488
  354. package/src/surreal/orm/compiler/write.ts +99 -114
  355. package/src/surreal/orm/connect.ts +60 -78
  356. package/src/surreal/orm/context.ts +50 -53
  357. package/src/surreal/orm/decode.ts +365 -367
  358. package/src/surreal/orm/delegate.ts +268 -292
  359. package/src/surreal/orm/delta.ts +51 -46
  360. package/src/surreal/orm/describe.ts +150 -151
  361. package/src/surreal/orm/errors.ts +189 -212
  362. package/src/surreal/orm/execute.ts +223 -151
  363. package/src/surreal/orm/fn.ts +109 -75
  364. package/src/surreal/orm/graph.ts +389 -324
  365. package/src/surreal/orm/hooks.ts +138 -186
  366. package/src/surreal/orm/index.ts +103 -57
  367. package/src/surreal/orm/logger/colors.ts +75 -37
  368. package/src/surreal/orm/logger/detect-color.ts +14 -13
  369. package/src/surreal/orm/logger/emit.ts +68 -95
  370. package/src/surreal/orm/logger/highlight.ts +163 -178
  371. package/src/surreal/orm/logger/index.ts +1 -16
  372. package/src/surreal/orm/logger/logger.ts +354 -345
  373. package/src/surreal/orm/logger/options.ts +25 -18
  374. package/src/surreal/orm/logger/plan.ts +147 -137
  375. package/src/surreal/orm/meta.ts +83 -94
  376. package/src/surreal/orm/operations.ts +81 -0
  377. package/src/surreal/orm/plugins.ts +137 -137
  378. package/src/surreal/orm/raw.ts +156 -187
  379. package/src/surreal/orm/reads.ts +311 -295
  380. package/src/surreal/orm/results.ts +208 -100
  381. package/src/surreal/orm/schema.ts +222 -199
  382. package/src/surreal/orm/search.ts +320 -0
  383. package/src/surreal/orm/semantic.ts +90 -95
  384. package/src/surreal/orm/sql-statement.ts +12 -0
  385. package/src/surreal/orm/text.ts +30 -0
  386. package/src/surreal/orm/transaction.ts +247 -239
  387. package/src/surreal/orm/types/admin.ts +53 -53
  388. package/src/surreal/orm/types/api.ts +55 -14
  389. package/src/surreal/orm/types/auth.ts +11 -11
  390. package/src/surreal/orm/types/client.ts +121 -120
  391. package/src/surreal/orm/types/context.ts +17 -17
  392. package/src/surreal/orm/types/fn.ts +26 -35
  393. package/src/surreal/orm/types/hooks.ts +86 -138
  394. package/src/surreal/orm/types/include.ts +79 -99
  395. package/src/surreal/orm/types/logger.ts +96 -100
  396. package/src/surreal/orm/types/plugins.ts +78 -84
  397. package/src/surreal/orm/types/raw.ts +21 -20
  398. package/src/surreal/orm/types/relations.ts +40 -51
  399. package/src/surreal/orm/types/schema.ts +49 -65
  400. package/src/surreal/orm/types/search.ts +74 -0
  401. package/src/surreal/orm/types/select.ts +354 -343
  402. package/src/surreal/orm/types/transaction.ts +39 -48
  403. package/src/surreal/orm/types/where.ts +158 -179
  404. package/src/surreal/orm/types/write.ts +348 -407
  405. package/src/surreal/orm/validate.ts +84 -0
  406. package/src/surreal/orm/writes.ts +340 -284
  407. package/src/surreal/plugins/create-only-shared.ts +30 -30
  408. package/src/surreal/plugins/create-only.ts +107 -128
  409. package/src/surreal/plugins/hard-delete.ts +27 -24
  410. package/src/surreal/plugins/policy.ts +117 -128
  411. package/src/surreal/plugins/rules.ts +74 -80
  412. package/src/surreal/plugins/soft-delete.ts +88 -65
  413. package/src/surreal/plugins/tenant-runtime.ts +287 -253
  414. package/src/surreal/plugins/tenant-shared.ts +9 -17
  415. package/src/surreal/plugins/tenant.ts +103 -119
  416. package/src/surreal/plugins/timestamps.ts +40 -39
  417. package/src/surreal/plugins/zod.ts +70 -48
  418. package/src/surreal/pure.ts +2629 -2888
  419. package/src/surreal/query.ts +4 -8
  420. package/src/surreal/seed.ts +5 -4
  421. package/src/surreal/surql/block.ts +173 -167
  422. package/src/surreal/surql/predicate.ts +318 -333
  423. package/src/surreal/surql/ref.ts +6 -8
  424. package/src/surreal/surql/render.ts +89 -64
  425. package/src/surreal/surql/typed-bound.ts +22 -24
  426. package/src/surreal/surql-tag.ts +142 -0
  427. package/src/surreal/surql-type-expr.ts +40 -26
  428. package/src/surreal/wire.ts +202 -215
  429. package/src/testing.ts +1 -1
  430. package/src/zod-core.ts +7 -0
  431. package/src/zod.ts +11 -0
  432. package/lib/aot.js.map +0 -20
  433. package/lib/authoring.js.map +0 -12
  434. package/lib/cli/index.js.map +0 -60
  435. package/lib/config.js.map +0 -98
  436. package/lib/connection.js.map +0 -97
  437. package/lib/core/driver/index.d.ts +0 -5
  438. package/lib/core/driver/sdk.js.map +0 -15
  439. package/lib/core/index.js.map +0 -25
  440. package/lib/driver.js.map +0 -49
  441. package/lib/index.js.map +0 -22
  442. package/lib/logger.js.map +0 -17
  443. package/lib/orm/index.js.map +0 -98
  444. package/lib/otel/index.js.map +0 -12
  445. package/lib/plugin.js.map +0 -10
  446. package/lib/plugins/create-only.js.map +0 -26
  447. package/lib/plugins/hard-delete.js.map +0 -13
  448. package/lib/plugins/policy.js.map +0 -15
  449. package/lib/plugins/rules.js.map +0 -13
  450. package/lib/plugins/soft-delete.js.map +0 -24
  451. package/lib/plugins/tenant.js.map +0 -28
  452. package/lib/plugins/timestamps.js.map +0 -25
  453. package/lib/plugins/zod.js.map +0 -22
  454. package/lib/query.js.map +0 -22
  455. package/lib/testing.js.map +0 -12
  456. 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 façade, generate STATIC getters from the schema so the AOT compiler sees them in the
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.json<T>()` and `s.regex(source: string, flags?)`.
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
- import { Customer } from "./.better-schemic/schema.aot"; // compiled validators installed
778
- await Customer.decode(row); // DDL/schema unchanged
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 — only validation gets the generated fast path.
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;