viborm 1.3.3 → 1.4.0

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 (202) hide show
  1. package/dist/{adapter-internals-AGgQRu5t.mjs → adapter-internals-Cy2QEBnH.mjs} +1 -1
  2. package/dist/{adapter-internals-AGgQRu5t.mjs.map → adapter-internals-Cy2QEBnH.mjs.map} +1 -1
  3. package/dist/{adapter-namespace-CWLEmon2.mjs → adapter-namespace-BLejG8FA.mjs} +1 -1
  4. package/dist/{adapter-namespace-CWLEmon2.mjs.map → adapter-namespace-BLejG8FA.mjs.map} +1 -1
  5. package/dist/adapter-result-parser-D6lluSMi.mjs +2 -0
  6. package/dist/adapter-result-parser-D6lluSMi.mjs.map +1 -0
  7. package/dist/adapters.d.mts +1 -1
  8. package/dist/adapters.mjs +1 -1
  9. package/dist/{array-literal-BKdLfNzM.mjs → array-literal-BsbbSLw3.mjs} +1 -1
  10. package/dist/{array-literal-BKdLfNzM.mjs.map → array-literal-BsbbSLw3.mjs.map} +1 -1
  11. package/dist/{batch-refs-DGJPz8-G.mjs → batch-refs-BYCu1JnQ.mjs} +1 -1
  12. package/dist/{batch-refs-DGJPz8-G.mjs.map → batch-refs-BYCu1JnQ.mjs.map} +1 -1
  13. package/dist/bind-parameter-capacity-D6p9HrbB.mjs +2 -0
  14. package/dist/bind-parameter-capacity-D6p9HrbB.mjs.map +1 -0
  15. package/dist/builder-BS8EW4BQ.mjs +2 -0
  16. package/dist/builder-BS8EW4BQ.mjs.map +1 -0
  17. package/dist/bun-sql.d.mts +3 -1
  18. package/dist/bun-sql.mjs +1 -1
  19. package/dist/bun-sql.mjs.map +1 -1
  20. package/dist/bun-sqlite.d.mts +1 -1
  21. package/dist/bun-sqlite.mjs +1 -1
  22. package/dist/cache/cloudflare-kv.d.mts +1 -1
  23. package/dist/cache/cloudflare-kv.mjs +1 -1
  24. package/dist/cache/memory.d.mts +1 -1
  25. package/dist/cache/memory.mjs +1 -1
  26. package/dist/cache.d.mts +1 -1
  27. package/dist/cache.mjs +1 -1
  28. package/dist/{canonical-json-BReb5nFO.mjs → canonical-json-acY4dQNQ.mjs} +2 -2
  29. package/dist/canonical-json-acY4dQNQ.mjs.map +1 -0
  30. package/dist/chain-D5J9hIw-.mjs +2 -0
  31. package/dist/chain-D5J9hIw-.mjs.map +1 -0
  32. package/dist/cli.mjs +1 -1
  33. package/dist/client-Bhl2mWam.mjs +2 -0
  34. package/dist/client-Bhl2mWam.mjs.map +1 -0
  35. package/dist/{client-DR0vYetv.d.mts → client-BzgBm_86.d.mts} +3 -1
  36. package/dist/{client-DjtWangN.mjs → client-aU3YhZ6G.mjs} +16 -16
  37. package/dist/client-aU3YhZ6G.mjs.map +1 -0
  38. package/dist/client.d.mts +1 -1
  39. package/dist/client.mjs +1 -1
  40. package/dist/{clock-YTLtjLFS.mjs → clock-CJotKAxc.mjs} +1 -1
  41. package/dist/{clock-YTLtjLFS.mjs.map → clock-CJotKAxc.mjs.map} +1 -1
  42. package/dist/config.d.mts +1 -1
  43. package/dist/config.mjs +1 -1
  44. package/dist/d1.d.mts +1 -1
  45. package/dist/d1.mjs +1 -1
  46. package/dist/d1.mjs.map +1 -1
  47. package/dist/{datetime-physical-codec-qKxFtI3B.mjs → datetime-physical-codec-lX7IJBlz.mjs} +1 -1
  48. package/dist/{datetime-physical-codec-qKxFtI3B.mjs.map → datetime-physical-codec-lX7IJBlz.mjs.map} +1 -1
  49. package/dist/driver-CQQbCQh9.mjs +2 -0
  50. package/dist/{driver-Bzc0GCQ4.mjs.map → driver-CQQbCQh9.mjs.map} +1 -1
  51. package/dist/{driver-BvP7eW0A.mjs → driver-u2qJicrE.mjs} +2 -2
  52. package/dist/{driver-BvP7eW0A.mjs.map → driver-u2qJicrE.mjs.map} +1 -1
  53. package/dist/driver.d.mts +1 -1
  54. package/dist/driver.mjs +1 -1
  55. package/dist/error-mapping-6op318w6.mjs.map +1 -1
  56. package/dist/every-CzF00eDV.mjs +2 -0
  57. package/dist/{every-WUr3mlvg.mjs.map → every-CzF00eDV.mjs.map} +1 -1
  58. package/dist/{fs-estate-azK36i9V.mjs → fs-estate-N_F2YqYa.mjs} +2 -2
  59. package/dist/{fs-estate-azK36i9V.mjs.map → fs-estate-N_F2YqYa.mjs.map} +1 -1
  60. package/dist/{identifier-conversion-Bs7A2GGU.mjs → identifier-conversion-Dc0Rf4Gi.mjs} +2 -2
  61. package/dist/{identifier-conversion-Bs7A2GGU.mjs.map → identifier-conversion-Dc0Rf4Gi.mjs.map} +1 -1
  62. package/dist/identity-CmRos0Yf.mjs +2 -0
  63. package/dist/identity-CmRos0Yf.mjs.map +1 -0
  64. package/dist/{index-B_jh2oaQ.d.mts → index-B4IWFJfv.d.mts} +1282 -1053
  65. package/dist/index.d.mts +1 -1
  66. package/dist/index.mjs +1 -1
  67. package/dist/instrumentation.d.mts +1 -1
  68. package/dist/instrumentation.mjs +1 -1
  69. package/dist/{invariant-D57gi_yW.mjs → invariant-D_fIjY_z.mjs} +1 -1
  70. package/dist/{invariant-D57gi_yW.mjs.map → invariant-D_fIjY_z.mjs.map} +1 -1
  71. package/dist/{json-number-DvmiNx0n.mjs → json-number-CGXpPu4D.mjs} +1 -1
  72. package/dist/{json-number-DvmiNx0n.mjs.map → json-number-CGXpPu4D.mjs.map} +1 -1
  73. package/dist/{libsql-C8dn4id0.mjs → libsql-CrDXsfpL.mjs} +2 -2
  74. package/dist/{libsql-C8dn4id0.mjs.map → libsql-CrDXsfpL.mjs.map} +1 -1
  75. package/dist/libsql.d.mts +1 -1
  76. package/dist/libsql.mjs +1 -1
  77. package/dist/libsql.mjs.map +1 -1
  78. package/dist/{memory-B7CcHS6I.mjs → memory-TXO4KgBy.mjs} +2 -2
  79. package/dist/{memory-B7CcHS6I.mjs.map → memory-TXO4KgBy.mjs.map} +1 -1
  80. package/dist/migrations/mysql.d.mts +4 -4
  81. package/dist/migrations/mysql.mjs +1 -1
  82. package/dist/migrations/postgres.d.mts +4 -4
  83. package/dist/migrations/postgres.mjs +1 -1
  84. package/dist/migrations/sqlite.d.mts +4 -4
  85. package/dist/migrations/sqlite.mjs +1 -1
  86. package/dist/migrations/storage/durable-object.mjs +1 -1
  87. package/dist/migrations/storage/fs.mjs +1 -1
  88. package/dist/migrations/storage/r2.mjs +1 -1
  89. package/dist/migrations/tenant.d.mts +2 -2
  90. package/dist/migrations/tenant.mjs +1 -1
  91. package/dist/migrations.d.mts +4 -4
  92. package/dist/migrations.mjs +1 -1
  93. package/dist/{mysql-mUmhH9Cf.mjs → mysql-C2vOPcuA.mjs} +2 -2
  94. package/dist/{mysql-mUmhH9Cf.mjs.map → mysql-C2vOPcuA.mjs.map} +1 -1
  95. package/dist/mysql-adapter-C5CMIYRS.mjs +2 -0
  96. package/dist/{mysql-adapter-ABpgFB2N.mjs.map → mysql-adapter-C5CMIYRS.mjs.map} +1 -1
  97. package/dist/mysql2.d.mts +1 -1
  98. package/dist/mysql2.mjs +1 -1
  99. package/dist/mysql2.mjs.map +1 -1
  100. package/dist/neon-http.d.mts +3 -1
  101. package/dist/neon-http.mjs +1 -1
  102. package/dist/neon-http.mjs.map +1 -1
  103. package/dist/normalized-result-BF7gr4_b.mjs +2 -0
  104. package/dist/normalized-result-BF7gr4_b.mjs.map +1 -0
  105. package/dist/{object-store-CZADAv4c.mjs → object-store-WjVilDvN.mjs} +2 -2
  106. package/dist/{object-store-CZADAv4c.mjs.map → object-store-WjVilDvN.mjs.map} +1 -1
  107. package/dist/{object-store-Ds9NKRU6.d.mts → object-store-uRqi0URP.d.mts} +3 -3
  108. package/dist/permissions.d.mts +1 -1
  109. package/dist/pg.d.mts +26 -1
  110. package/dist/pg.mjs +1 -1
  111. package/dist/pg.mjs.map +1 -1
  112. package/dist/pglite.d.mts +3 -1
  113. package/dist/pglite.mjs +1 -1
  114. package/dist/pglite.mjs.map +1 -1
  115. package/dist/{pinned-session-C79aDzOg.mjs → pinned-session-FYOFV_gB.mjs} +2 -2
  116. package/dist/{pinned-session-C79aDzOg.mjs.map → pinned-session-FYOFV_gB.mjs.map} +1 -1
  117. package/dist/planetscale.d.mts +1 -1
  118. package/dist/planetscale.mjs +1 -1
  119. package/dist/planetscale.mjs.map +1 -1
  120. package/dist/{planner-DHZG9Vy7.d.mts → planner-SzkGh-3T.d.mts} +1 -1
  121. package/dist/{postgres-BACQ_wqF.mjs → postgres-BSmy1PYR.mjs} +2 -2
  122. package/dist/{postgres-BACQ_wqF.mjs.map → postgres-BSmy1PYR.mjs.map} +1 -1
  123. package/dist/postgres-adapter-B1RyJlWL.mjs +2 -0
  124. package/dist/{postgres-adapter-DaMvNOkx.mjs.map → postgres-adapter-B1RyJlWL.mjs.map} +1 -1
  125. package/dist/postgres-adapter-BAqRfWl1.mjs +2 -0
  126. package/dist/postgres-adapter-BAqRfWl1.mjs.map +1 -0
  127. package/dist/postgres-result-BCUQf8b_.mjs +2 -0
  128. package/dist/{postgres-result-D403cLyA.mjs.map → postgres-result-BCUQf8b_.mjs.map} +1 -1
  129. package/dist/postgres.d.mts +3 -1
  130. package/dist/postgres.mjs +1 -1
  131. package/dist/postgres.mjs.map +1 -1
  132. package/dist/{provider-limits-DSv2tYFr.mjs → provider-limits-V09frtmK.mjs} +1 -1
  133. package/dist/{provider-limits-DSv2tYFr.mjs.map → provider-limits-V09frtmK.mjs.map} +1 -1
  134. package/dist/relation-bound-BrZLsSke.mjs +2 -0
  135. package/dist/relation-bound-BrZLsSke.mjs.map +1 -0
  136. package/dist/{result-parsing-8wEK3GY1.mjs → result-parsing-CQf_eCl8.mjs} +1 -1
  137. package/dist/{result-parsing-8wEK3GY1.mjs.map → result-parsing-CQf_eCl8.mjs.map} +1 -1
  138. package/dist/result-shape-Fi1-Fvri.mjs +2 -0
  139. package/dist/result-shape-Fi1-Fvri.mjs.map +1 -0
  140. package/dist/{rows-v1VuwOTa.mjs → rows-BiaiswSV.mjs} +2 -2
  141. package/dist/{rows-v1VuwOTa.mjs.map → rows-BiaiswSV.mjs.map} +1 -1
  142. package/dist/schema/json.d.mts +1 -1
  143. package/dist/{schema-introspection-TdJrSaKd.mjs → schema-introspection-C1-XrQP4.mjs} +2 -2
  144. package/dist/{schema-introspection-TdJrSaKd.mjs.map → schema-introspection-C1-XrQP4.mjs.map} +1 -1
  145. package/dist/{schema-D3-ScVH6.mjs → schema-tGtziyCJ.mjs} +1 -1
  146. package/dist/{schema-D3-ScVH6.mjs.map → schema-tGtziyCJ.mjs.map} +1 -1
  147. package/dist/schema.d.mts +1 -1
  148. package/dist/schema.mjs +1 -1
  149. package/dist/select-assembly-BjT_fDbu.mjs +2 -0
  150. package/dist/select-assembly-BjT_fDbu.mjs.map +1 -0
  151. package/dist/{settle-etgtP1WM.mjs → settle-C4w1GfTU.mjs} +2 -2
  152. package/dist/{settle-etgtP1WM.mjs.map → settle-C4w1GfTU.mjs.map} +1 -1
  153. package/dist/{sha256-CEYo7k7R.mjs → sha256-_Nu4s32f.mjs} +1 -1
  154. package/dist/{sha256-CEYo7k7R.mjs.map → sha256-_Nu4s32f.mjs.map} +1 -1
  155. package/dist/soft-delete.d.mts +3 -3
  156. package/dist/{sql-statement-tokens-BW7Q-rF-.mjs → sql-statement-tokens-4J5l5Lyt.mjs} +1 -1
  157. package/dist/{sql-statement-tokens-BW7Q-rF-.mjs.map → sql-statement-tokens-4J5l5Lyt.mjs.map} +1 -1
  158. package/dist/sqlite-adapter-CoDeF2h2.mjs +2 -0
  159. package/dist/sqlite-adapter-CoDeF2h2.mjs.map +1 -0
  160. package/dist/{sqlite-utils-BvSlEs5W.mjs → sqlite-utils-C0TyzOys.mjs} +2 -2
  161. package/dist/{sqlite-utils-BvSlEs5W.mjs.map → sqlite-utils-C0TyzOys.mjs.map} +1 -1
  162. package/dist/sqlite3.d.mts +1 -1
  163. package/dist/sqlite3.mjs +1 -1
  164. package/dist/sqlite3.mjs.map +1 -1
  165. package/dist/{standard-sql-CYdZ_KXH.mjs → standard-sql-DmKF8msN.mjs} +2 -2
  166. package/dist/{standard-sql-CYdZ_KXH.mjs.map → standard-sql-DmKF8msN.mjs.map} +1 -1
  167. package/dist/transaction-operation-CU1zlxiG.mjs.map +1 -1
  168. package/dist/{utils-Qr8ug94X.mjs → utils-DkAxKcDD.mjs} +1 -1
  169. package/dist/{utils-Qr8ug94X.mjs.map → utils-DkAxKcDD.mjs.map} +1 -1
  170. package/dist/{validation-CPnrLcjW.mjs → validation-C7Z6wTJa.mjs} +1 -1
  171. package/dist/{validation-CPnrLcjW.mjs.map → validation-C7Z6wTJa.mjs.map} +1 -1
  172. package/dist/validation.d.mts +1 -1
  173. package/dist/validation.mjs +1 -1
  174. package/dist/version-n393hhwM.mjs +2 -0
  175. package/dist/{version-0RVYpih5.mjs.map → version-n393hhwM.mjs.map} +1 -1
  176. package/package.json +14 -14
  177. package/dist/bind-parameter-capacity-DiwRmZ1h.mjs +0 -2
  178. package/dist/bind-parameter-capacity-DiwRmZ1h.mjs.map +0 -1
  179. package/dist/builder-D6Ug-zjM.mjs +0 -2
  180. package/dist/builder-D6Ug-zjM.mjs.map +0 -1
  181. package/dist/canonical-json-BReb5nFO.mjs.map +0 -1
  182. package/dist/chain-B5IbqLGi.mjs +0 -2
  183. package/dist/chain-B5IbqLGi.mjs.map +0 -1
  184. package/dist/client-BmcHzDBa.mjs +0 -2
  185. package/dist/client-BmcHzDBa.mjs.map +0 -1
  186. package/dist/client-DjtWangN.mjs.map +0 -1
  187. package/dist/driver-Bzc0GCQ4.mjs +0 -2
  188. package/dist/every-WUr3mlvg.mjs +0 -2
  189. package/dist/identity-Bj2EN6Ss.mjs +0 -2
  190. package/dist/identity-Bj2EN6Ss.mjs.map +0 -1
  191. package/dist/mysql-adapter-ABpgFB2N.mjs +0 -2
  192. package/dist/postgres-adapter-Ci07rgh_.mjs +0 -2
  193. package/dist/postgres-adapter-Ci07rgh_.mjs.map +0 -1
  194. package/dist/postgres-adapter-DaMvNOkx.mjs +0 -2
  195. package/dist/postgres-result-D403cLyA.mjs +0 -2
  196. package/dist/result-shape-BKydBCsR.mjs +0 -2
  197. package/dist/result-shape-BKydBCsR.mjs.map +0 -1
  198. package/dist/select-assembly-uZfvbYjz.mjs +0 -2
  199. package/dist/select-assembly-uZfvbYjz.mjs.map +0 -1
  200. package/dist/sqlite-adapter-DPc9T6Lh.mjs +0 -2
  201. package/dist/sqlite-adapter-DPc9T6Lh.mjs.map +0 -1
  202. package/dist/version-0RVYpih5.mjs +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"standard-sql-CYdZ_KXH.mjs","names":["sql"],"sources":["../src/sql/identifiers.ts","../src/adapters/shared/standard-sql.ts"],"sourcesContent":["/**\n * Identifier text primitives.\n *\n * Quoting one name for a dialect, and composing a namespace-qualified object\n * name, are string concerns with no `Sql` involvement: runtime adapters wrap the\n * result in `Sql`, migration drivers splice it into DDL text. Both pass their\n * own quoter — the two differ in escape semantics and null handling — so what is\n * shared here is the composition rule alone, and it has one owner.\n */\n\n/** Quote a single identifier for the dialect: `\"name\"` or `` `name` ``. */\nexport type IdentifierQuoter = (name: string) => string;\n\n/** Build an identifier quoter that doubles embedded quote characters to prevent SQL injection. */\nexport const createIdentifierQuoter =\n (quoteChar: '\"' | \"`\"): IdentifierQuoter =>\n (name: string): string => {\n const escaped =\n name.indexOf(quoteChar) === -1\n ? name\n : name.replaceAll(quoteChar, quoteChar + quoteChar);\n return quoteChar + escaped + quoteChar;\n };\n\n/**\n * The one qualification rule. A present namespace contributes a quoted prefix;\n * an absent one contributes nothing, which is what unbound MySQL and every\n * SQLite adapter mean.\n */\nconst qualifiedPrefix = (\n quoteIdentifier: IdentifierQuoter,\n namespace: string\n): string => `${quoteIdentifier(namespace)}.`;\n\n/**\n * Compose one namespace-qualified object name. The namespace must already be\n * normalized: this primitive validates nothing, holds nothing, and returns text\n * for exactly one object.\n */\nexport const renderQualifiedIdentifier = (\n quoteIdentifier: IdentifierQuoter,\n namespace: string | undefined,\n object: string\n): string =>\n namespace === undefined\n ? quoteIdentifier(object)\n : qualifiedPrefix(quoteIdentifier, namespace) + quoteIdentifier(object);\n\n/**\n * Bind one namespace so its prefix is quoted once per adapter rather than once\n * per rendered statement. The returned function renders exactly what\n * `renderQualifiedIdentifier` would for the same namespace.\n */\nexport const createQualifiedIdentifierRenderer = (\n quoteIdentifier: IdentifierQuoter,\n namespace: string | undefined\n): IdentifierQuoter => {\n if (namespace === undefined) {\n return quoteIdentifier;\n }\n const prefix = qualifiedPrefix(quoteIdentifier, namespace);\n return (object: string): string => prefix + quoteIdentifier(object);\n};\n","import { Sql, sql } from \"@sql\";\nimport {\n createQualifiedIdentifierRenderer,\n type IdentifierQuoter,\n} from \"../../sql/identifiers\";\nimport type { CastType, DatabaseAdapter } from \"../database-adapter\";\n\ntype StandardLiterals = Pick<\n DatabaseAdapter[\"literals\"],\n \"value\" | \"null\" | \"list\"\n>;\n\ntype ComparisonOperators = Pick<\n DatabaseAdapter[\"operators\"],\n \"eq\" | \"neq\" | \"lt\" | \"lte\" | \"gt\" | \"gte\"\n>;\n\ntype NullOperators = Pick<DatabaseAdapter[\"operators\"], \"isNull\" | \"isNotNull\">;\n\ntype RangeOperators = Pick<\n DatabaseAdapter[\"operators\"],\n \"between\" | \"notBetween\"\n>;\n\ntype ExistenceOperators = Pick<\n DatabaseAdapter[\"operators\"],\n \"exists\" | \"notExists\"\n>;\n\ntype DirectionOrderBy = Pick<DatabaseAdapter[\"orderBy\"], \"asc\" | \"desc\">;\n\ntype NumericSetOperations = Pick<\n DatabaseAdapter[\"set\"],\n \"assign\" | \"increment\" | \"decrement\"\n>;\n\ntype MutationCommands = Pick<DatabaseAdapter[\"mutations\"], \"update\" | \"delete\">;\n\nexport const createRawSql = (): DatabaseAdapter[\"raw\"] => {\n return (sqlString: string): Sql => sql.raw(sqlString);\n};\n\n/**\n * JSON-serialize a value for dialects that store lists/JSON as JSON text\n * (MySQL, SQLite). BigInt has no JSON representation, so it serializes as a\n * string; the result parser converts it back via the scalar's bigint type.\n */\nexport const stringifyJson = (value: unknown): string =>\n JSON.stringify(value, (_key, v) =>\n typeof v === \"bigint\" ? v.toString() : v\n );\n\nconst JSON_PATH_ARRAY_INDEX = /^\\d+$/;\n\n/**\n * Build a MySQL/SQLite JSONPath string from path segments: '$' plus `[N]`\n * for integer segments (array indices) and `.\"seg\"` for object keys.\n * Keys are JSON-string-escaped so quotes/dots/backslashes in a segment\n * cannot alter the path structure; the result is bound as a parameter.\n */\nexport const buildJsonPath = (path: string[]): string => {\n let jsonPath = \"$\";\n for (const segment of path) {\n jsonPath += JSON_PATH_ARRAY_INDEX.test(segment)\n ? `[${segment}]`\n : `.${JSON.stringify(segment)}`;\n }\n return jsonPath;\n};\n\nexport const createStandardLiterals = (): StandardLiterals => ({\n value: (v: unknown): Sql => sql`${v}`,\n null: (): Sql => sql.raw(\"NULL\"),\n list: (values: Sql[]): Sql => {\n if (values.length === 0) return sql.raw(\"()\");\n return sql`(${sql.join(values, \", \")})`;\n },\n});\n\nexport const createComparisonOperators = (): ComparisonOperators => ({\n eq: (left: Sql, right: Sql): Sql => sql`${left} = ${right}`,\n neq: (left: Sql, right: Sql): Sql => sql`${left} <> ${right}`,\n lt: (left: Sql, right: Sql): Sql => sql`${left} < ${right}`,\n lte: (left: Sql, right: Sql): Sql => sql`${left} <= ${right}`,\n gt: (left: Sql, right: Sql): Sql => sql`${left} > ${right}`,\n gte: (left: Sql, right: Sql): Sql => sql`${left} >= ${right}`,\n});\n\nexport const createNullOperators = (): NullOperators => ({\n isNull: (expr: Sql): Sql => sql`${expr} IS NULL`,\n isNotNull: (expr: Sql): Sql => sql`${expr} IS NOT NULL`,\n});\n\nexport const createRangeOperators = (): RangeOperators => ({\n between: (column: Sql, min: Sql, max: Sql): Sql =>\n sql`${column} BETWEEN ${min} AND ${max}`,\n notBetween: (column: Sql, min: Sql, max: Sql): Sql =>\n sql`${column} NOT BETWEEN ${min} AND ${max}`,\n});\n\nexport const createExistenceOperators = (): ExistenceOperators => ({\n exists: (subquery: Sql): Sql => sql`EXISTS (${subquery})`,\n notExists: (subquery: Sql): Sql => sql`NOT EXISTS (${subquery})`,\n});\n\ntype StandardAggregates = Omit<\n DatabaseAdapter[\"aggregates\"],\n \"decimalAvg\" | \"decimalSumOperandPrecision\"\n>;\n\n/**\n * The aggregate functions every dialect spells identically. `decimalAvg` is\n * deliberately absent: an exact decimal average is derived from `SUM` and\n * `COUNT` in the column's own physical domain, which is the one thing the three\n * dialects do not agree on, so each adapter states it.\n * `decimalSumOperandPrecision` is absent because each dialect also owns exact\n * admission of an operand compared with a widened sum.\n *\n * `infinity` is the dialect's infinite double literal; MySQL has none.\n */\nexport const createAggregateFunctions = (\n infinity?: string\n): StandardAggregates => ({\n count: (expr?: Sql): Sql =>\n expr ? sql`COUNT(${expr})` : sql.raw(\"COUNT(*)\"),\n countDistinct: (expr: Sql): Sql => sql`COUNT(DISTINCT ${expr})`,\n sum: (expr: Sql): Sql => sql`SUM(${expr})`,\n numberSum: (expr: Sql) => {\n const high = sql`SUM(CASE WHEN ABS(${expr}) >= 1e-288 THEN ${expr} / 4294967296.0 / 4294967296.0 END)`;\n const low = sql`SUM(CASE WHEN ABS(${expr}) < 1e-288 THEN ${expr} END)`;\n // The reader's join in SQL: scaling `high` back by 2^64 is exact below\n // 2^960 and leaves the double range from there, where this multiplies\n // nothing — PostgreSQL and MySQL raise on an overflowing product. Without\n // an infinite double (MySQL) the overflow clamps to the largest finite\n // one, which a `having` operand of exactly that value cannot tell apart,\n // and `high` then sorts an infinite sum past a clamped one.\n const bound = sql.raw(infinity ?? \"1.7976931348623157e308\");\n const value = sql`CASE WHEN ${high} IS NULL THEN ${low} WHEN ABS(${high}) < 9.7453140114e288 THEN ${high} * 4294967296.0 * 4294967296.0 + COALESCE(${low}, 0) WHEN ${high} > 0 THEN ${bound} ELSE -${bound} END`;\n return {\n parts: [high, low] as const,\n value,\n order: infinity ? [value] : [value, high],\n };\n },\n avg: (expr: Sql): Sql => sql`AVG(${expr})`,\n min: (expr: Sql): Sql => sql`MIN(${expr})`,\n max: (expr: Sql): Sql => sql`MAX(${expr})`,\n});\n\n/** The widened precision carried by one trusted coefficient spelling. */\nexport function decimalCoefficientPrecision(coefficient: string): number {\n return coefficient.startsWith(\"-\")\n ? coefficient.length - 1\n : coefficient.length;\n}\n\n/** Exact-decimal aggregate operand admission for precision-bounded dialects. */\nexport function createDecimalSumOperandPrecision(\n maxPrecision: number\n): (coefficient: string) => number | undefined {\n return (coefficient) => {\n const precision = decimalCoefficientPrecision(coefficient);\n return precision <= maxPrecision ? precision : undefined;\n };\n}\n\nexport const createDirectionOrderBy = (): DirectionOrderBy => ({\n asc: (column: Sql): Sql => sql`${column} ASC`,\n desc: (column: Sql): Sql => sql`${column} DESC`,\n});\n\nconst directionKeyword = (direction: \"asc\" | \"desc\"): Sql =>\n direction === \"desc\" ? sql.raw(\"DESC\") : sql.raw(\"ASC\");\n\n/**\n * NULLS FIRST/LAST emulation for dialects without native support\n * (MySQL, SQLite): prepend an IS NULL sort key. IS NULL yields 1 for\n * NULL rows, so DESC puts them first and ASC puts them last.\n */\nexport const createEmulatedNullsOrderBy = (): Pick<\n DatabaseAdapter[\"orderBy\"],\n \"nullsFirst\" | \"nullsLast\"\n> => ({\n nullsFirst: (column: Sql, direction: \"asc\" | \"desc\"): Sql =>\n sql`(${column} IS NULL) DESC, ${column} ${directionKeyword(direction)}`,\n nullsLast: (column: Sql, direction: \"asc\" | \"desc\"): Sql =>\n sql`(${column} IS NULL) ASC, ${column} ${directionKeyword(direction)}`,\n});\n\nexport const createStandardClauses = (): DatabaseAdapter[\"clauses\"] => ({\n select: (columns: Sql): Sql => sql`SELECT ${columns}`,\n selectDistinct: (columns: Sql): Sql => sql`SELECT DISTINCT ${columns}`,\n from: (table: Sql): Sql => sql`FROM ${table}`,\n where: (condition: Sql): Sql => sql`WHERE ${condition}`,\n orderBy: (orders: Sql): Sql => sql`ORDER BY ${orders}`,\n limit: (count: Sql): Sql => sql`LIMIT ${count}`,\n offset: (count: Sql): Sql => sql`OFFSET ${count}`,\n groupBy: (columns: Sql): Sql => sql`GROUP BY ${columns}`,\n having: (condition: Sql): Sql => sql`HAVING ${condition}`,\n});\n\n/**\n * The native arithmetic every dialect shares.\n *\n * `increment`/`decrement` are complete here for EVERY scalar including decimal:\n * addition of two values already in the column's domain — logical decimals on\n * PostgreSQL/MySQL, unscaled coefficients at the same scale on SQLite — creates\n * no digit beyond that domain and therefore never rounds.\n *\n * `multiply` and `divide` do create such digits, so each adapter overrides them\n * to route a decimal target through the shared half-even rule.\n */\nexport const createNumericSetOperations = (): NumericSetOperations => ({\n assign: (column: Sql, value: Sql): Sql => sql`${column} = ${value}`,\n increment: (column: Sql, by: Sql): Sql => sql`${column} = ${column} + ${by}`,\n decrement: (column: Sql, by: Sql): Sql => sql`${column} = ${column} - ${by}`,\n});\n\nexport const createRelationFilters = (): DatabaseAdapter[\"filters\"] => ({\n some: (subquery: Sql): Sql => sql`EXISTS (${subquery})`,\n every: (subquery: Sql): Sql => sql`NOT EXISTS (${subquery})`,\n none: (subquery: Sql): Sql => sql`NOT EXISTS (${subquery})`,\n is: (subquery: Sql): Sql => sql`EXISTS (${subquery})`,\n isNot: (subquery: Sql): Sql => sql`NOT EXISTS (${subquery})`,\n});\n\nexport const createMutationCommands = (): MutationCommands => ({\n update: (table: Sql, sets: Sql, where?: Sql): Sql => {\n if (where) {\n return sql`UPDATE ${table} SET ${sets} WHERE ${where}`;\n }\n return sql`UPDATE ${table} SET ${sets}`;\n },\n delete: (table: Sql, where?: Sql): Sql => {\n if (where) {\n return sql`DELETE FROM ${table} WHERE ${where}`;\n }\n return sql`DELETE FROM ${table}`;\n },\n});\n\ntype TypedRows = DatabaseAdapter[\"setOperations\"][\"typedRows\"];\n\n/** One row's values, in order: `(a, b)`. */\nexport const rowValues = (row: readonly Sql[]): Sql =>\n sql`(${sql.join(row, \", \")})`;\n\n/**\n * `typedRows`' default form: the empty typed read, then one `UNION ALL\n * SELECT` per row, each typed against the arms before it.\n */\nconst unionTypedRows =\n (quoteIdent: IdentifierQuoter): TypedRows =>\n (typed, rows, alias) =>\n sql`(${sql.join(\n [typed.head, ...rows.map((row) => sql`SELECT ${sql.join(row, \", \")}`)],\n \" UNION ALL \"\n )}) AS ${sql.raw(quoteIdent(alias))}`;\n\nexport const createSetOperations = (\n quoteIdent: IdentifierQuoter,\n typedRows: TypedRows = unionTypedRows(quoteIdent)\n): DatabaseAdapter[\"setOperations\"] => ({\n union: (...queries: Sql[]): Sql => sql.join(queries, \" UNION \"),\n unionAll: (...queries: Sql[]): Sql => sql.join(queries, \" UNION ALL \"),\n intersect: (...queries: Sql[]): Sql => sql.join(queries, \" INTERSECT \"),\n except: (left: Sql, right: Sql): Sql => sql`${left} EXCEPT ${right}`,\n typedRows,\n});\n\n// ============================================================\n// Dialect-parameterized factories: identical grammar across\n// adapters, differing only in the identifier quote character.\n// ============================================================\n\n/**\n * Whether `text` is exactly `<one quoted identifier>.<quotedName>`: a column\n * reference through a table alias whose column is the name itself.\n */\nconst isQualifiedColumnNamed = (\n text: string | undefined,\n quotedName: string,\n quote: string\n): boolean => {\n if (text === undefined || !text.endsWith(quotedName)) return false;\n const qualifier = text.slice(0, -quotedName.length - 1);\n return (\n text[qualifier.length] === \".\" &&\n qualifier.length >= 2 &&\n qualifier[0] === quote &&\n qualifier.at(-1) === quote &&\n !qualifier\n .slice(1, -1)\n .replaceAll(quote + quote, \"\")\n .includes(quote)\n );\n};\n\n/**\n * `namespace` is the adapter's prevalidated database namespace, or `undefined`\n * for the unqualified dialects. It is quoted once here, at adapter\n * construction — `table()` runs once per persistent table per compiled\n * statement and must not re-quote it.\n *\n * `namesQualifiedColumns`: the dialect names an unaliased `\"t\".\"c\"` result\n * column `c` (PostgreSQL, MySQL), so `aliased` leaves out an alias that only\n * repeats the column's own name. SQLite promises no name for an unaliased\n * column, so it always states the alias.\n */\nexport const createIdentifiers = (\n quoteIdent: IdentifierQuoter,\n namespace?: string,\n namesQualifiedColumns = false\n): DatabaseAdapter[\"identifiers\"] => {\n const qualify = createQualifiedIdentifierRenderer(quoteIdent, namespace);\n const quote = quoteIdent(\"\")[0]!;\n return {\n escape: (name: string): Sql => sql.raw(quoteIdent(name)),\n\n column: (alias: string, field: string): Sql => {\n const identifier = alias\n ? `${quoteIdent(alias)}.${quoteIdent(field)}`\n : quoteIdent(field);\n return sql.raw(identifier);\n },\n\n table: (tableName: string, alias?: string): Sql => {\n const qualified = qualify(tableName);\n return sql.raw(\n alias === undefined ? qualified : `${qualified} AS ${quoteIdent(alias)}`\n );\n },\n\n aliased: (expression: Sql, alias: string): Sql => {\n const quoted = quoteIdent(alias);\n return namesQualifiedColumns &&\n isQualifiedColumnNamed(Sql.leafText(expression), quoted, quote)\n ? expression\n : new Sql([\"\", ` AS ${quoted}`], [expression]);\n },\n };\n};\n\nexport const createSubqueries = (\n quoteIdent: IdentifierQuoter\n): DatabaseAdapter[\"subqueries\"] => ({\n scalar: (query: Sql): Sql => sql`(${query})`,\n\n correlate: (query: Sql, alias: string): Sql =>\n sql`(${query}) AS ${sql.raw(quoteIdent(alias))}`,\n\n existsCheck: (from: Sql, where: Sql): Sql =>\n sql`SELECT 1 FROM ${from} WHERE ${where}`,\n\n isolated: (condition: Sql): Sql => condition,\n});\n\n/**\n * `inlining` is the dialect's `NOT MATERIALIZED` (PostgreSQL 12+), or nothing\n * where the database never materializes a member on its own account.\n */\nexport const createCteBuilders = (\n quoteIdent: IdentifierQuoter,\n inlining?: Sql\n): DatabaseAdapter[\"cte\"] => ({\n with: (\n definitions: { name: string; query: Sql; inlined?: boolean }[]\n ): Sql => {\n const defs = definitions.map(({ name, query, inlined }) =>\n inlined && inlining\n ? sql`${sql.raw(quoteIdent(name))} AS ${inlining} (${query})`\n : sql`${sql.raw(quoteIdent(name))} AS (${query})`\n );\n return sql`WITH ${sql.join(defs, \", \")}`;\n },\n\n recursive: (\n name: string,\n anchor: Sql,\n recursive: Sql,\n union: \"all\" | \"distinct\" = \"all\"\n ): Sql => {\n const unionKeyword =\n union === \"all\" ? sql.raw(\"UNION ALL\") : sql.raw(\"UNION\");\n return sql`WITH RECURSIVE ${sql.raw(quoteIdent(name))} AS (\n ${anchor}\n ${unionKeyword}\n ${recursive}\n )`;\n },\n});\n\nexport const createInsertStatement =\n (quoteIdent: IdentifierQuoter): DatabaseAdapter[\"mutations\"][\"insert\"] =>\n (\n table: Sql,\n columns: string[],\n source: Sql[][] | { readonly select: Sql },\n prefix?: Sql\n ): Sql => {\n const cols = columns.map((c) => sql.raw(quoteIdent(c)));\n const body = Array.isArray(source)\n ? sql`VALUES ${sql.join(\n source.map((row) => sql`(${sql.join(row, \", \")})`),\n \", \"\n )}`\n : source.select;\n const prefixPart = prefix ? sql`${prefix} ` : sql``;\n return sql`INSERT ${prefixPart}INTO ${table} (${sql.join(\n cols,\n \", \"\n )}) ${body}`;\n };\n\n/**\n * Standard ON CONFLICT grammar shared by PostgreSQL and SQLite.\n * MySQL's ON DUPLICATE KEY UPDATE is a different grammar with different\n * semantics — it stays in the MySQL adapter.\n */\nexport const createOnConflictBuilders = (): Pick<\n DatabaseAdapter[\"mutations\"],\n \"onConflict\" | \"onConflictUpdate\" | \"skipDuplicates\"\n> => ({\n onConflict: (target: Sql | null, action: Sql, targetWhere?: Sql): Sql => {\n if (target) {\n if (targetWhere) {\n // ON CONFLICT (id) WHERE <targetWhere> DO UPDATE ...\n return sql`ON CONFLICT (${target}) WHERE ${targetWhere} DO ${action}`;\n }\n return sql`ON CONFLICT (${target}) DO ${action}`;\n }\n return sql`ON CONFLICT DO ${action}`;\n },\n\n onConflictUpdate: (sets: Sql, setWhere?: Sql): Sql => {\n if (setWhere) {\n // UPDATE SET x = y WHERE <setWhere>\n return sql`UPDATE SET ${sets} WHERE ${setWhere}`;\n }\n return sql`UPDATE SET ${sets}`;\n },\n\n // The UNTARGETED skip, and the only caller left is top-level `createMany`,\n // whose `skipDuplicates: true` means \"any unique constraint\". Junction\n // membership inserts want the opposite — only an exact repeat of the complete\n // membership key — and reach `onConflict` above with that key as the target.\n skipDuplicates: () => ({\n prefix: sql``,\n suffix: sql`ON CONFLICT DO NOTHING`,\n }),\n});\n\nexport const createMembershipOperators = (): Pick<\n DatabaseAdapter[\"operators\"],\n \"in\" | \"notIn\"\n> => ({\n in: (column: Sql, values: Sql): Sql => sql`${column} IN ${values}`,\n notIn: (column: Sql, values: Sql): Sql => sql`${column} NOT IN ${values}`,\n});\n\n/**\n * AND/OR/NOT with vacuous-case literals: the dialect's TRUE for an empty\n * AND and FALSE for an empty OR (pass the adapter's literals.true/false).\n */\nexport const createLogicalOperators = (\n vacuousTrue: () => Sql,\n vacuousFalse: () => Sql\n): Pick<DatabaseAdapter[\"operators\"], \"and\" | \"or\" | \"not\"> => ({\n and: (...conditions: Sql[]): Sql => {\n if (conditions.length === 0) return vacuousTrue();\n if (conditions.length === 1) return conditions[0]!;\n return sql`(${sql.join(conditions, \" AND \")})`;\n },\n\n or: (...conditions: Sql[]): Sql => {\n if (conditions.length === 0) return vacuousFalse();\n if (conditions.length === 1) return conditions[0]!;\n return sql`(${sql.join(conditions, \" OR \")})`;\n },\n\n not: (condition: Sql): Sql => sql`NOT (${condition})`,\n});\n\nexport const createCommonExpressions = (): Pick<\n DatabaseAdapter[\"expressions\"],\n | \"caseWhen\"\n | \"add\"\n | \"subtract\"\n | \"multiply\"\n | \"divide\"\n | \"upper\"\n | \"lower\"\n | \"coalesce\"\n> => ({\n caseWhen: (branches, otherwise): Sql =>\n branches.length === 0\n ? otherwise\n : sql`CASE ${sql.join(\n branches.map(\n (branch) => sql`WHEN ${branch.when} THEN ${branch.then}`\n ),\n \" \"\n )} ELSE ${otherwise} END`,\n add: (left: Sql, right: Sql): Sql => sql`(${left} + ${right})`,\n subtract: (left: Sql, right: Sql): Sql => sql`(${left} - ${right})`,\n multiply: (left: Sql, right: Sql): Sql => sql`(${left} * ${right})`,\n divide: (left: Sql, right: Sql): Sql => sql`(${left} / ${right})`,\n upper: (expr: Sql): Sql => sql`UPPER(${expr})`,\n lower: (expr: Sql): Sql => sql`LOWER(${expr})`,\n coalesce: (...exprs: Sql[]): Sql => sql`COALESCE(${sql.join(exprs, \", \")})`,\n});\n\nexport const createCastExpression =\n (typeMap: Record<CastType, string>): DatabaseAdapter[\"expressions\"][\"cast\"] =>\n (expr: Sql, type: CastType): Sql =>\n sql`CAST(${expr} AS ${sql.raw(typeMap[type])})`;\n\nexport const createCoreJoins = (): Pick<\n DatabaseAdapter[\"joins\"],\n \"inner\" | \"left\" | \"right\" | \"cross\"\n> => ({\n inner: (table: Sql, condition: Sql): Sql =>\n sql`INNER JOIN ${table} ON ${condition}`,\n\n left: (table: Sql, condition: Sql): Sql =>\n sql`LEFT JOIN ${table} ON ${condition}`,\n\n right: (table: Sql, condition: Sql): Sql =>\n sql`RIGHT JOIN ${table} ON ${condition}`,\n\n cross: (table: Sql): Sql => sql`CROSS JOIN ${table}`,\n});\n\nexport const createLateralJoins = (\n quoteIdent: IdentifierQuoter\n): Pick<DatabaseAdapter[\"joins\"], \"lateral\" | \"lateralLeft\"> => ({\n lateral: (subquery: Sql, alias: string): Sql =>\n sql`JOIN LATERAL (${subquery}) AS ${sql.raw(quoteIdent(alias))} ON TRUE`,\n\n lateralLeft: (subquery: Sql, alias: string): Sql =>\n sql`LEFT JOIN LATERAL (${subquery}) AS ${sql.raw(quoteIdent(alias))} ON TRUE`,\n});\n\n/**\n * Escape a user value so a SQL `LIKE` pattern matches it literally.\n *\n * `%`, `_` and the escape character itself become escaped; every other\n * character is left alone. The caller appends its own wildcard and must emit\n * a matching `ESCAPE` clause — backslash is only the escape character because\n * every `ESCAPE` clause in this codebase spells backslash.\n */\nexport const escapeLikeLiteral = (value: string): string =>\n value.replace(/[\\\\%_]/g, (char) => `\\\\${char}`);\n\n/**\n * Escape a user value so a SQLite `GLOB` pattern matches it literally.\n *\n * GLOB has no `ESCAPE` clause, so a metacharacter is quoted by wrapping it in\n * a one-character class: `*` becomes `[*]`. Only `*`, `?` and `[` need it —\n * a `]` outside a class is already literal in SQLite's GLOB, and backslash is\n * not a GLOB met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AAG,IAAI,EAAK,KAAK,EAAM,GAC5D,UAAW,EAAW,IAAoB,CAAG,IAAI,EAAK,KAAK,EAAM,GACjE,UAAW,EAAW,IAAoB,CAAG,IAAI,EAAK,KAAK,EAAM,GACjE,QAAS,EAAW,IAAoB,CAAG,IAAI,EAAK,KAAK,EAAM,GAC/D,MAAQ,GAAmB,CAAG,SAAS,EAAK,GAC5C,MAAQ,GAAmB,CAAG,SAAS,EAAK,GAC5C,UAAW,GAAG,IAAsB,CAAG,YAAYA,EAAI,KAAK,EAAO,KAAK,CAAC,GAC1E,EAEY,qBACV,IACA,EAAW,IACV,CAAG,QAAQ,EAAK,MAAMA,EAAI,IAAI,EAAQ,GAAM,CAAC,GAEpC,qBAGP,CACJ,OAAQ,EAAY,IAClB,CAAG,cAAc,EAAM,MAAM,IAE/B,MAAO,EAAY,IACjB,CAAG,aAAa,EAAM,MAAM,IAE9B,OAAQ,EAAY,IAClB,CAAG,cAAc,EAAM,MAAM,IAE/B,MAAQ,GAAoB,CAAG,cAAc,IAC9C,EAEY,mBACX,IAC+D,CAC/D,SAAU,EAAe,IACvB,CAAG,iBAAiB,EAAS,OAAOA,EAAI,IAAI,EAAW,EAAM,CAAC,CAAC,UAEjE,aAAc,EAAe,IAC3B,CAAG,sBAAsB,EAAS,OAAOA,EAAI,IAAI,EAAW,EAAM,CAAC,CAAC,UACvE,EAUY,kBAAqB,GAChC,EAAM,QAAQ,UAAY,GAAS,KAAK,IAAO,CAUpC,kBAAqB,GAChC,EAAM,QAAQ,SAAW,GAAS,IAAI,EAAK,GAAG"}
1
+ {"version":3,"file":"standard-sql-DmKF8msN.mjs","names":["sql"],"sources":["../src/sql/identifiers.ts","../src/adapters/shared/standard-sql.ts"],"sourcesContent":["/**\n * Identifier text primitives.\n *\n * Quoting one name for a dialect, and composing a namespace-qualified object\n * name, are string concerns with no `Sql` involvement: runtime adapters wrap the\n * result in `Sql`, migration drivers splice it into DDL text. Both pass their\n * own quoter — the two differ in escape semantics and null handling — so what is\n * shared here is the composition rule alone, and it has one owner.\n */\n\n/** Quote a single identifier for the dialect: `\"name\"` or `` `name` ``. */\nexport type IdentifierQuoter = (name: string) => string;\n\n/** Build an identifier quoter that doubles embedded quote characters to prevent SQL injection. */\nexport const createIdentifierQuoter =\n (quoteChar: '\"' | \"`\"): IdentifierQuoter =>\n (name: string): string => {\n const escaped =\n name.indexOf(quoteChar) === -1\n ? name\n : name.replaceAll(quoteChar, quoteChar + quoteChar);\n return quoteChar + escaped + quoteChar;\n };\n\n/**\n * The one qualification rule. A present namespace contributes a quoted prefix;\n * an absent one contributes nothing, which is what unbound MySQL and every\n * SQLite adapter mean.\n */\nconst qualifiedPrefix = (\n quoteIdentifier: IdentifierQuoter,\n namespace: string\n): string => `${quoteIdentifier(namespace)}.`;\n\n/**\n * Compose one namespace-qualified object name. The namespace must already be\n * normalized: this primitive validates nothing, holds nothing, and returns text\n * for exactly one object.\n */\nexport const renderQualifiedIdentifier = (\n quoteIdentifier: IdentifierQuoter,\n namespace: string | undefined,\n object: string\n): string =>\n namespace === undefined\n ? quoteIdentifier(object)\n : qualifiedPrefix(quoteIdentifier, namespace) + quoteIdentifier(object);\n\n/**\n * Bind one namespace so its prefix is quoted once per adapter rather than once\n * per rendered statement. The returned function renders exactly what\n * `renderQualifiedIdentifier` would for the same namespace.\n */\nexport const createQualifiedIdentifierRenderer = (\n quoteIdentifier: IdentifierQuoter,\n namespace: string | undefined\n): IdentifierQuoter => {\n if (namespace === undefined) {\n return quoteIdentifier;\n }\n const prefix = qualifiedPrefix(quoteIdentifier, namespace);\n return (object: string): string => prefix + quoteIdentifier(object);\n};\n","import { Sql, sql } from \"@sql\";\nimport {\n createQualifiedIdentifierRenderer,\n type IdentifierQuoter,\n} from \"../../sql/identifiers\";\nimport type { CastType, DatabaseAdapter } from \"../database-adapter\";\n\ntype StandardLiterals = Pick<\n DatabaseAdapter[\"literals\"],\n \"value\" | \"null\" | \"list\"\n>;\n\ntype ComparisonOperators = Pick<\n DatabaseAdapter[\"operators\"],\n \"eq\" | \"neq\" | \"lt\" | \"lte\" | \"gt\" | \"gte\"\n>;\n\ntype NullOperators = Pick<DatabaseAdapter[\"operators\"], \"isNull\" | \"isNotNull\">;\n\ntype RangeOperators = Pick<\n DatabaseAdapter[\"operators\"],\n \"between\" | \"notBetween\"\n>;\n\ntype ExistenceOperators = Pick<\n DatabaseAdapter[\"operators\"],\n \"exists\" | \"notExists\"\n>;\n\ntype DirectionOrderBy = Pick<DatabaseAdapter[\"orderBy\"], \"asc\" | \"desc\">;\n\ntype NumericSetOperations = Pick<\n DatabaseAdapter[\"set\"],\n \"assign\" | \"increment\" | \"decrement\"\n>;\n\ntype MutationCommands = Pick<DatabaseAdapter[\"mutations\"], \"update\" | \"delete\">;\n\nexport const createRawSql = (): DatabaseAdapter[\"raw\"] => {\n return (sqlString: string): Sql => sql.raw(sqlString);\n};\n\n/**\n * JSON-serialize a value for dialects that store lists/JSON as JSON text\n * (MySQL, SQLite). BigInt has no JSON representation, so it serializes as a\n * string; the result parser converts it back via the scalar's bigint type.\n */\nexport const stringifyJson = (value: unknown): string =>\n JSON.stringify(value, (_key, v) =>\n typeof v === \"bigint\" ? v.toString() : v\n );\n\nconst JSON_PATH_ARRAY_INDEX = /^\\d+$/;\n\n/**\n * Build a MySQL/SQLite JSONPath string from path segments: '$' plus `[N]`\n * for integer segments (array indices) and `.\"seg\"` for object keys.\n * Keys are JSON-string-escaped so quotes/dots/backslashes in a segment\n * cannot alter the path structure; the result is bound as a parameter.\n */\nexport const buildJsonPath = (path: string[]): string => {\n let jsonPath = \"$\";\n for (const segment of path) {\n jsonPath += JSON_PATH_ARRAY_INDEX.test(segment)\n ? `[${segment}]`\n : `.${JSON.stringify(segment)}`;\n }\n return jsonPath;\n};\n\nexport const createStandardLiterals = (): StandardLiterals => ({\n value: (v: unknown): Sql => sql`${v}`,\n null: (): Sql => sql.raw(\"NULL\"),\n list: (values: Sql[]): Sql => {\n if (values.length === 0) return sql.raw(\"()\");\n return sql`(${sql.join(values, \", \")})`;\n },\n});\n\nexport const createComparisonOperators = (): ComparisonOperators => ({\n eq: (left: Sql, right: Sql): Sql => sql`${left} = ${right}`,\n neq: (left: Sql, right: Sql): Sql => sql`${left} <> ${right}`,\n lt: (left: Sql, right: Sql): Sql => sql`${left} < ${right}`,\n lte: (left: Sql, right: Sql): Sql => sql`${left} <= ${right}`,\n gt: (left: Sql, right: Sql): Sql => sql`${left} > ${right}`,\n gte: (left: Sql, right: Sql): Sql => sql`${left} >= ${right}`,\n});\n\nexport const createNullOperators = (): NullOperators => ({\n isNull: (expr: Sql): Sql => sql`${expr} IS NULL`,\n isNotNull: (expr: Sql): Sql => sql`${expr} IS NOT NULL`,\n});\n\nexport const createRangeOperators = (): RangeOperators => ({\n between: (column: Sql, min: Sql, max: Sql): Sql =>\n sql`${column} BETWEEN ${min} AND ${max}`,\n notBetween: (column: Sql, min: Sql, max: Sql): Sql =>\n sql`${column} NOT BETWEEN ${min} AND ${max}`,\n});\n\nexport const createExistenceOperators = (): ExistenceOperators => ({\n exists: (subquery: Sql): Sql => sql`EXISTS (${subquery})`,\n notExists: (subquery: Sql): Sql => sql`NOT EXISTS (${subquery})`,\n});\n\ntype StandardAggregates = Omit<\n DatabaseAdapter[\"aggregates\"],\n \"decimalAvg\" | \"decimalSumOperandPrecision\"\n>;\n\n/**\n * The aggregate functions every dialect spells identically. `decimalAvg` is\n * deliberately absent: an exact decimal average is derived from `SUM` and\n * `COUNT` in the column's own physical domain, which is the one thing the three\n * dialects do not agree on, so each adapter states it.\n * `decimalSumOperandPrecision` is absent because each dialect also owns exact\n * admission of an operand compared with a widened sum.\n *\n * `infinity` is the dialect's infinite double literal; MySQL has none.\n */\nexport const createAggregateFunctions = (\n infinity?: string\n): StandardAggregates => ({\n count: (expr?: Sql): Sql =>\n expr ? sql`COUNT(${expr})` : sql.raw(\"COUNT(*)\"),\n countDistinct: (expr: Sql): Sql => sql`COUNT(DISTINCT ${expr})`,\n sum: (expr: Sql): Sql => sql`SUM(${expr})`,\n numberSum: (expr: Sql) => {\n const high = sql`SUM(CASE WHEN ABS(${expr}) >= 1e-288 THEN ${expr} / 4294967296.0 / 4294967296.0 END)`;\n const low = sql`SUM(CASE WHEN ABS(${expr}) < 1e-288 THEN ${expr} END)`;\n // The reader's join in SQL: scaling `high` back by 2^64 is exact below\n // 2^960 and leaves the double range from there, where this multiplies\n // nothing — PostgreSQL and MySQL raise on an overflowing product. Without\n // an infinite double (MySQL) the overflow clamps to the largest finite\n // one, which a `having` operand of exactly that value cannot tell apart,\n // and `high` then sorts an infinite sum past a clamped one.\n const bound = sql.raw(infinity ?? \"1.7976931348623157e308\");\n const value = sql`CASE WHEN ${high} IS NULL THEN ${low} WHEN ABS(${high}) < 9.7453140114e288 THEN ${high} * 4294967296.0 * 4294967296.0 + COALESCE(${low}, 0) WHEN ${high} > 0 THEN ${bound} ELSE -${bound} END`;\n return {\n parts: [high, low] as const,\n value,\n order: infinity ? [value] : [value, high],\n };\n },\n avg: (expr: Sql): Sql => sql`AVG(${expr})`,\n min: (expr: Sql): Sql => sql`MIN(${expr})`,\n max: (expr: Sql): Sql => sql`MAX(${expr})`,\n});\n\n/** The widened precision carried by one trusted coefficient spelling. */\nexport function decimalCoefficientPrecision(coefficient: string): number {\n return coefficient.startsWith(\"-\")\n ? coefficient.length - 1\n : coefficient.length;\n}\n\n/** Exact-decimal aggregate operand admission for precision-bounded dialects. */\nexport function createDecimalSumOperandPrecision(\n maxPrecision: number\n): (coefficient: string) => number | undefined {\n return (coefficient) => {\n const precision = decimalCoefficientPrecision(coefficient);\n return precision <= maxPrecision ? precision : undefined;\n };\n}\n\nexport const createDirectionOrderBy = (): DirectionOrderBy => ({\n asc: (column: Sql): Sql => sql`${column} ASC`,\n desc: (column: Sql): Sql => sql`${column} DESC`,\n});\n\nconst directionKeyword = (direction: \"asc\" | \"desc\"): Sql =>\n direction === \"desc\" ? sql.raw(\"DESC\") : sql.raw(\"ASC\");\n\n/**\n * NULLS FIRST/LAST emulation for dialects without native support\n * (MySQL, SQLite): prepend an IS NULL sort key. IS NULL yields 1 for\n * NULL rows, so DESC puts them first and ASC puts them last.\n */\nexport const createEmulatedNullsOrderBy = (): Pick<\n DatabaseAdapter[\"orderBy\"],\n \"nullsFirst\" | \"nullsLast\"\n> => ({\n nullsFirst: (column: Sql, direction: \"asc\" | \"desc\"): Sql =>\n sql`(${column} IS NULL) DESC, ${column} ${directionKeyword(direction)}`,\n nullsLast: (column: Sql, direction: \"asc\" | \"desc\"): Sql =>\n sql`(${column} IS NULL) ASC, ${column} ${directionKeyword(direction)}`,\n});\n\nexport const createStandardClauses = (): DatabaseAdapter[\"clauses\"] => ({\n select: (columns: Sql): Sql => sql`SELECT ${columns}`,\n selectDistinct: (columns: Sql): Sql => sql`SELECT DISTINCT ${columns}`,\n from: (table: Sql): Sql => sql`FROM ${table}`,\n where: (condition: Sql): Sql => sql`WHERE ${condition}`,\n orderBy: (orders: Sql): Sql => sql`ORDER BY ${orders}`,\n limit: (count: Sql): Sql => sql`LIMIT ${count}`,\n offset: (count: Sql): Sql => sql`OFFSET ${count}`,\n groupBy: (columns: Sql): Sql => sql`GROUP BY ${columns}`,\n having: (condition: Sql): Sql => sql`HAVING ${condition}`,\n});\n\n/**\n * The native arithmetic every dialect shares.\n *\n * `increment`/`decrement` are complete here for EVERY scalar including decimal:\n * addition of two values already in the column's domain — logical decimals on\n * PostgreSQL/MySQL, unscaled coefficients at the same scale on SQLite — creates\n * no digit beyond that domain and therefore never rounds.\n *\n * `multiply` and `divide` do create such digits, so each adapter overrides them\n * to route a decimal target through the shared half-even rule.\n */\nexport const createNumericSetOperations = (): NumericSetOperations => ({\n assign: (column: Sql, value: Sql): Sql => sql`${column} = ${value}`,\n increment: (column: Sql, by: Sql): Sql => sql`${column} = ${column} + ${by}`,\n decrement: (column: Sql, by: Sql): Sql => sql`${column} = ${column} - ${by}`,\n});\n\nexport const createRelationFilters = (): DatabaseAdapter[\"filters\"] => ({\n some: (subquery: Sql): Sql => sql`EXISTS (${subquery})`,\n every: (subquery: Sql): Sql => sql`NOT EXISTS (${subquery})`,\n none: (subquery: Sql): Sql => sql`NOT EXISTS (${subquery})`,\n is: (subquery: Sql): Sql => sql`EXISTS (${subquery})`,\n isNot: (subquery: Sql): Sql => sql`NOT EXISTS (${subquery})`,\n});\n\nexport const createMutationCommands = (): MutationCommands => ({\n update: (table: Sql, sets: Sql, where?: Sql): Sql => {\n if (where) {\n return sql`UPDATE ${table} SET ${sets} WHERE ${where}`;\n }\n return sql`UPDATE ${table} SET ${sets}`;\n },\n delete: (table: Sql, where?: Sql): Sql => {\n if (where) {\n return sql`DELETE FROM ${table} WHERE ${where}`;\n }\n return sql`DELETE FROM ${table}`;\n },\n});\n\ntype TypedRows = DatabaseAdapter[\"setOperations\"][\"typedRows\"];\n\n/** One row's values, in order: `(a, b)`. */\nexport const rowValues = (row: readonly Sql[]): Sql =>\n sql`(${sql.join(row, \", \")})`;\n\n/**\n * `typedRows`' default form: the empty typed read, then one `UNION ALL\n * SELECT` per row, each typed against the arms before it.\n */\nconst unionTypedRows =\n (quoteIdent: IdentifierQuoter): TypedRows =>\n (typed, rows, alias) =>\n sql`(${sql.join(\n [typed.head, ...rows.map((row) => sql`SELECT ${sql.join(row, \", \")}`)],\n \" UNION ALL \"\n )}) AS ${sql.raw(quoteIdent(alias))}`;\n\nexport const createSetOperations = (\n quoteIdent: IdentifierQuoter,\n typedRows: TypedRows = unionTypedRows(quoteIdent)\n): DatabaseAdapter[\"setOperations\"] => ({\n union: (...queries: Sql[]): Sql => sql.join(queries, \" UNION \"),\n unionAll: (...queries: Sql[]): Sql => sql.join(queries, \" UNION ALL \"),\n intersect: (...queries: Sql[]): Sql => sql.join(queries, \" INTERSECT \"),\n except: (left: Sql, right: Sql): Sql => sql`${left} EXCEPT ${right}`,\n typedRows,\n});\n\n// ============================================================\n// Dialect-parameterized factories: identical grammar across\n// adapters, differing only in the identifier quote character.\n// ============================================================\n\n/**\n * Whether `text` is exactly `<one quoted identifier>.<quotedName>`: a column\n * reference through a table alias whose column is the name itself.\n */\nconst isQualifiedColumnNamed = (\n text: string | undefined,\n quotedName: string,\n quote: string\n): boolean => {\n if (text === undefined || !text.endsWith(quotedName)) return false;\n const qualifier = text.slice(0, -quotedName.length - 1);\n return (\n text[qualifier.length] === \".\" &&\n qualifier.length >= 2 &&\n qualifier[0] === quote &&\n qualifier.at(-1) === quote &&\n !qualifier\n .slice(1, -1)\n .replaceAll(quote + quote, \"\")\n .includes(quote)\n );\n};\n\n/**\n * `namespace` is the adapter's prevalidated database namespace, or `undefined`\n * for the unqualified dialects. It is quoted once here, at adapter\n * construction — `table()` runs once per persistent table per compiled\n * statement and must not re-quote it.\n *\n * `namesQualifiedColumns`: the dialect names an unaliased `\"t\".\"c\"` result\n * column `c` (PostgreSQL, MySQL), so `aliased` leaves out an alias that only\n * repeats the column's own name. SQLite promises no name for an unaliased\n * column, so it always states the alias.\n */\nexport const createIdentifiers = (\n quoteIdent: IdentifierQuoter,\n namespace?: string,\n namesQualifiedColumns = false\n): DatabaseAdapter[\"identifiers\"] => {\n const qualify = createQualifiedIdentifierRenderer(quoteIdent, namespace);\n const quote = quoteIdent(\"\")[0]!;\n return {\n escape: (name: string): Sql => sql.raw(quoteIdent(name)),\n\n column: (alias: string, field: string): Sql => {\n const identifier = alias\n ? `${quoteIdent(alias)}.${quoteIdent(field)}`\n : quoteIdent(field);\n return sql.raw(identifier);\n },\n\n table: (tableName: string, alias?: string): Sql => {\n const qualified = qualify(tableName);\n return sql.raw(\n alias === undefined ? qualified : `${qualified} AS ${quoteIdent(alias)}`\n );\n },\n\n aliased: (expression: Sql, alias: string): Sql => {\n const quoted = quoteIdent(alias);\n return namesQualifiedColumns &&\n isQualifiedColumnNamed(Sql.leafText(expression), quoted, quote)\n ? expression\n : new Sql([\"\", ` AS ${quoted}`], [expression]);\n },\n };\n};\n\nexport const createSubqueries = (\n quoteIdent: IdentifierQuoter\n): DatabaseAdapter[\"subqueries\"] => ({\n scalar: (query: Sql): Sql => sql`(${query})`,\n\n correlate: (query: Sql, alias: string): Sql =>\n sql`(${query}) AS ${sql.raw(quoteIdent(alias))}`,\n\n existsCheck: (from: Sql, where: Sql): Sql =>\n sql`SELECT 1 FROM ${from} WHERE ${where}`,\n\n isolated: (condition: Sql): Sql => condition,\n});\n\n/**\n * `hints` spell a member's form where the dialect would otherwise pick the\n * other one: `inlining` is PostgreSQL 12+'s `NOT MATERIALIZED` (it\n * materializes a member read twice), `materializing` SQLite 3.35+'s\n * `MATERIALIZED` (it inlines every member, compiling its body again at each\n * use). Neither, where the database decides alone.\n */\nexport const createCteBuilders = (\n quoteIdent: IdentifierQuoter,\n hints: { readonly inlining?: Sql; readonly materializing?: Sql } = {}\n): DatabaseAdapter[\"cte\"] => ({\n with: (\n definitions: {\n name: string;\n query: Sql;\n inlined?: boolean;\n recursive?: boolean;\n }[]\n ): Sql => {\n const defs = definitions.map(({ name, query, inlined }) => {\n // A member stating no form (`inlined` absent) is left to the database.\n let hint: Sql | undefined;\n if (inlined !== undefined)\n hint = inlined ? hints.inlining : hints.materializing;\n return hint\n ? sql`${sql.raw(quoteIdent(name))} AS ${hint} (${query})`\n : sql`${sql.raw(quoteIdent(name))} AS (${query})`;\n });\n // One recursive member makes the whole list `WITH RECURSIVE`.\n return definitions.some((definition) => definition.recursive)\n ? sql`WITH RECURSIVE ${sql.join(defs, \", \")}`\n : sql`WITH ${sql.join(defs, \", \")}`;\n },\n\n recursive: (\n name: string,\n anchor: Sql,\n recursive: Sql,\n union: \"all\" | \"distinct\" = \"all\"\n ): Sql => {\n const unionKeyword =\n union === \"all\" ? sql.raw(\"UNION ALL\") : sql.raw(\"UNION\");\n return sql`WITH RECURSIVE ${sql.raw(quoteIdent(name))} AS (\n ${anchor}\n ${unionKeyword}\n ${recursive}\n )`;\n },\n});\n\nexport const createInsertStatement =\n (quoteIdent: IdentifierQuoter): DatabaseAdapter[\"mutations\"][\"insert\"] =>\n (\n table: Sql,\n columns: string[],\n source: Sql[][] | { readonly select: Sql },\n prefix?: Sql\n ): Sql => {\n const cols = columns.map((c) => sql.raw(quoteIdent(c)));\n const body = Array.isArray(source)\n ? sql`VALUES ${sql.join(\n source.map((row) => sql`(${sql.join(row, \", \")})`),\n \", \"\n )}`\n : source.select;\n const prefixPart = prefix ? sql`${prefix} ` : sql``;\n return sql`INSERT ${prefixPart}INTO ${table} (${sql.join(\n cols,\n \", \"\n )}) ${body}`;\n };\n\n/**\n * Standard ON CONFLICT grammar shared by PostgreSQL and SQLite.\n * MySQL's ON DUPLICATE KEY UPDATE is a different grammar with different\n * semantics — it stays in the MySQL adapter.\n */\nexport const createOnConflictBuilders = (): Pick<\n DatabaseAdapter[\"mutations\"],\n \"onConflict\" | \"onConflictUpdate\" | \"skipDuplicates\"\n> => ({\n onConflict: (target: Sql | null, action: Sql, targetWhere?: Sql): Sql => {\n if (target) {\n if (targetWhere) {\n // ON CONFLICT (id) WHERE <targetWhere> DO UPDATE ...\n return sql`ON CONFLICT (${target}) WHERE ${targetWhere} DO ${action}`;\n }\n return sql`ON CONFLICT (${target}) DO ${action}`;\n }\n return sql`ON CONFLICT DO ${action}`;\n },\n\n onConflictUpdate: (sets: Sql, setWhere?: Sql): Sql => {\n if (setWhere) {\n // UPDATE SET x = y WHERE <setWhere>\n return sql`UPDATE SET ${sets} WHERE ${setWhere}`;\n }\n return sql`UPDATE SET ${sets}`;\n },\n\n // The UNTARGETED skip, and the only caller left is top-level `createMany`,\n // whose `skipDuplicates: true` means \"any unique constraint\". Junction\n // membership inserts want the opposite — only an exact repeat of the complete\n // membership key — and reach `onConflict` above with that key as the target.\n skipDuplicates: () => ({\n prefix: sql``,\n suffix: sql`ON CONFLICT DO NOTHING`,\n }),\n});\n\nexport const createMembershipOperators = (): Pick<\n DatabaseAdapter[\"operators\"],\n \"in\" | \"notIn\"\n> => ({\n in: (column: Sql, values: Sql): Sql => sql`${column} IN ${values}`,\n notIn: (column: Sql, values: Sql): Sql => sql`${column} NOT IN ${values}`,\n});\n\n/**\n * AND/OR/NOT with vacuous-case literals: the dialect's TRUE for an empty\n * AND and FALSE for an empty OR (pass the adapter's literals.true/false).\n */\nexport const createLogicalOperators = (\n vacuousTrue: () => Sql,\n vacuousFalse: () => Sql\n): Pick<DatabaseAdapter[\"operators\"], \"and\" | \"or\" | \"not\"> => ({\n and: (...conditions: Sql[]): Sql => {\n if (conditions.length === 0) return vacuousTrue();\n if (conditions.length === 1) return conditions[0]!;\n return sql`(${sql.join(conditions, \" AND \")})`;\n },\n\n or: (...conditions: Sql[]): Sql => {\n if (conditions.length === 0) return vacuousFalse();\n if (conditions.length === 1) return conditions[0]!;\n return sql`(${sql.join(conditions, \" OR \")})`;\n },\n\n not: (condition: Sql): Sql => sql`NOT (${condition})`,\n});\n\nexport const createCommonExpressions = (): Pick<\n DatabaseAdapter[\"expressions\"],\n | \"caseWhen\"\n | \"add\"\n | \"subtract\"\n | \"multiply\"\n | \"divide\"\n | \"upper\"\n | \"lower\"\n | \"coalesce\"\n> => ({\n caseWhen: (branches, otherwise): Sql =>\n branches.length === 0\n ? otherwise\n : sql`CASE ${sql.join(\n branches.map(\n (branch) => sql`WHEN ${branch.when} THEN ${branch.then}`\n ),\n \" \"\n )} ELSE ${otherwise} END`,\n add: (left: Sql, right: Sql): Sql => sql`(${left} + ${right})`,\n subtract: (left: Sql, right: Sql): Sql => sql`(${left} - ${right})`,\n multiply: (left: Sql, right: Sql): Sql => sql`(${left} * ${right})`,\n divide: (left: Sql, right: Sql): Sql => sql`(${left} / ${right})`,\n upper: (expr: Sql): Sql => sql`UPPER(${expr})`,\n lower: (expr: Sql): Sql => sql`LOWER(${expr})`,\n coalesce: (...exprs: Sql[]): Sql => sql`COALESCE(${sql.join(exprs, \", \")})`,\n});\n\nexport const createCastExpression =\n (typeMap: Record<CastType, string>): DatabaseAdapter[\"expressions\"][\"cast\"] =>\n (expr: Sql, type: CastType): Sql =>\n sql`CAST(${expr} AS ${sql.raw(typeMap[type])})`;\n\nexport const createCoreJoins = (): Pick<\n DatabaseAdapter[\"joins\"],\n \"inner\" | \"left\" | \"right\" | \"cross\"\n> => ({\n inner: (table: Sql, condition: Sql): Sql =>\n sql`INNER JOIN ${table} ON ${condition}`,\n\n left: (table: Sql, condition: Sql): Sql =>\n sql`LEFT JOIN ${table} ON ${condition}`,\n\n right: (table: Sql, condition: Sql): Sql =>\n sql`RIGHT JOIN ${table} ON ${condition}`,\n\n cross: (table: Sql): Sql => sql`CROSS JOIN ${table}`,\n});\n\nexport const createLateralJoins = (\n quoteIdent: IdentifierQuoter\n): Pick<DatabaseAdapter[\"joins\"], \"lateral\" | \"lateralLeft\"> => ({\n lateral: (subquery: Sql, alias: string): Sql =>\n sql`JOIN LATERAL (${subquery}) AS ${sql.raw(quoteIdent(alias))} ON TRUE`,\n\n lateralLeft: (subquery: Sql, alias: string): Sql =>\n sql`LEFT JOIN LATERAL (${subquery}) AS ${sql.raw(quoteIdent(alias))} ON TRUE`,\n});\n\n/**\n * Escape a user value so a SQL `LIKE` pattern matches it literally.\n *\n * `%`, `_` and the escape character itself become escaped; every other\n * character is left alone. The caller appends its own wildcard and must emit\n * a matching `ESCAPE` clause — backslash is only the escape character because\n * every `ESCAPE` clause in this codebase spells backslash.\n */\nexport const escapeLikeLiteral = (value: string): string =>\n value.replace(/[\\\\%_]/g, (char) => `\\\\${char}`);\n\n/**\n * Escape a user value so a SQLite `GLOB` pattern matches it literally.\n *\n * GLOB has no `ESCAPE` clause, so a metacharacter is quoted by wrapping it in\n * a one-character class: `*` becomes `[*]`. Only `*`, `?` and `[` need it —\n * a `]` outside a class is already literal in SQLite's GLOB, and backslash is\n * not a GLOB metacharacter at all.\n */\nexport const escapeGlobLiteral = (value: string): string =>\n value.replace(/[*?[]/g, (char) => `[${char}]`);\n"],"mappings":"uFAcA,MAAa,uBACV,GACA,GAKQ,GAHL,EAAK,QAAQ,EAAU,GAAK,GACxB,EACA,EAAK,WAAW,EAAW,EAAY,EAAU,EAC1B,EAQ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,UAAW,EAAW,IAAoB,CAAG,IAAI,EAAK,KAAK,EAAM,GACjE,UAAW,EAAW,IAAoB,CAAG,IAAI,EAAK,KAAK,EAAM,GACjE,QAAS,EAAW,IAAoB,CAAG,IAAI,EAAK,KAAK,EAAM,GAC/D,MAAQ,GAAmB,CAAG,SAAS,EAAK,GAC5C,MAAQ,GAAmB,CAAG,SAAS,EAAK,GAC5C,UAAW,GAAG,IAAsB,CAAG,YAAYA,EAAI,KAAK,EAAO,KAAK,CAAC,GAC1E,EAEY,qBACV,IACA,EAAW,IACV,CAAG,QAAQ,EAAK,MAAMA,EAAI,IAAI,EAAQ,GAAM,CAAC,GAEpC,qBAGP,CACJ,OAAQ,EAAY,IAClB,CAAG,cAAc,EAAM,MAAM,IAE/B,MAAO,EAAY,IACjB,CAAG,aAAa,EAAM,MAAM,IAE9B,OAAQ,EAAY,IAClB,CAAG,cAAc,EAAM,MAAM,IAE/B,MAAQ,GAAoB,CAAG,cAAc,IAC9C,EAEY,mBACX,IAC+D,CAC/D,SAAU,EAAe,IACvB,CAAG,iBAAiB,EAAS,OAAOA,EAAI,IAAI,EAAW,EAAM,CAAC,CAAC,UAEjE,aAAc,EAAe,IAC3B,CAAG,sBAAsB,EAAS,OAAOA,EAAI,IAAI,EAAW,EAAM,CAAC,CAAC,UACvE,EAUY,kBAAqB,GAChC,EAAM,QAAQ,UAAY,GAAS,KAAK,IAAO,CAUpC,kBAAqB,GAChC,EAAM,QAAQ,SAAW,GAAS,IAAI,EAAK,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"file":"transaction-operation-CU1zlxiG.mjs","names":[],"sources":["../src/query-engine/transaction-operation.ts"],"sourcesContent":["import type {\n AnyDriver,\n QueryExecutionContext,\n QueryResult,\n} from \"@drivers/exports\";\nimport { InvalidTransactionInputError } from \"@errors\";\nimport type { ObservationCompletionFactsReader } from \"@extensions/observation\";\nimport type {\n QueryInterceptorExecutionControl,\n TransactionWriteOutcomes,\n WriteOutcomeNotifications,\n} from \"@extensions/query\";\nimport type { PreparedBatchOperation, PreparedQuery } from \"./types\";\n\n/** One shared owner table registered once by each genuine operation class. */\nexport interface TransactionOperationOwner<Owner extends object = object> {\n clientId(owner: Owner): symbol;\n scopeId(owner: Owner): symbol;\n model(owner: Owner): string;\n operation(owner: Owner): string;\n context(owner: Owner): QueryExecutionContext;\n requiresInterception(owner: Owner): boolean;\n prepareAdmission(owner: Owner, phase?: \"input\" | \"plan\"): void;\n stagePackageWriteOutcomes(\n owner: Owner,\n outcomes: TransactionWriteOutcomes\n ): void;\n startInterception(\n owner: Owner,\n child: (notifications?: WriteOutcomeNotifications) => Promise<unknown>,\n outcomes: TransactionWriteOutcomes,\n control: QueryInterceptorExecutionControl\n ): Promise<unknown>;\n executeCore(\n owner: Owner,\n driver: AnyDriver,\n notifications?: WriteOutcomeNotifications\n ): Promise<unknown>;\n isWrite(owner: Owner): boolean;\n hasObservation(owner: Owner): boolean;\n observe(\n owner: Owner,\n child: () => Promise<unknown>,\n readCompletionFacts?: ObservationCompletionFactsReader\n ): Promise<unknown>;\n reserveWith(owner: Owner, driver: AnyDriver): void;\n executeWith(owner: Owner, driver: AnyDriver): Promise<unknown>;\n prepare(owner: Owner, driver?: AnyDriver): PreparedQuery | undefined;\n prepareBatch(\n owner: Owner\n ): Promise<PreparedBatchOperation<unknown> | undefined>;\n parseResult(owner: Owner, raw: QueryResult<unknown>): unknown;\n observeBatchPhase<Result>(\n owner: Owner,\n driver: AnyDriver,\n execute: () => Result | Promise<Result>\n ): Promise<Result>;\n}\n\n/** The private authority resolved only while coordinating an array. */\nexport type TransactionOperationCapability = object;\n\ninterface RegisteredTransactionOperationOwner {\n readonly resolve: TransactionOperationResolver;\n}\n\ntype TransactionOperationResolver = (\n value: object\n) => TransactionOperationOwner<TransactionOperationCapability> | undefined;\n\nconst transactionOperationOwners: RegisteredTransactionOperationOwner[] = [];\nconst transactionOperationOwnersByPrototype = new WeakMap<\n object,\n TransactionOperationOwner<TransactionOperationCapability>\n>();\n\n/** Resolve the one class owner after the capability passed admission. */\nexport function transactionOperationOwner(\n operation: TransactionOperationCapability\n): TransactionOperationOwner<TransactionOperationCapability> {\n const prototype = Object.getPrototypeOf(operation);\n const owner = transactionOperationOwnersByPrototype.get(prototype);\n if (owner === undefined) throw new InvalidTransactionInputError();\n return owner;\n}\n\n/** Register one class-owned array authority for its exact private brand. */\nexport function registerTransactionOperationOwner<Owner extends object>(\n prototype: object,\n authenticate: (value: object) => value is Owner,\n owner: TransactionOperationOwner<Owner>\n): void {\n const resolvedOwner: TransactionOperationOwner<TransactionOperationCapability> =\n owner;\n const resolve = (\n value: object\n ): TransactionOperationOwner<TransactionOperationCapability> | undefined =>\n authenticate(value) && Object.getPrototypeOf(value) === prototype\n ? resolvedOwner\n : undefined;\n const registration: RegisteredTransactionOperationOwner = Object.freeze({\n resolve,\n });\n transactionOperationOwners.push(registration);\n transactionOperationOwnersByPrototype.set(prototype, resolvedOwner);\n}\n\n/** Resolve one owner only for an object constructed by its registered class. */\nexport function readTransactionOperation(\n value: object\n): TransactionOperationOwner<TransactionOperationCapability> | undefined {\n for (const registration of transactionOperationOwners) {\n try {\n const owner = registration.resolve(value);\n if (owner !== undefined) return owner;\n } catch {\n // A hostile candidate cannot interrupt the remaining genuine owners.\n }\n }\n return undefined;\n}\n\n/** The static thenable accepted by internal transaction composition. */\nexport interface TransactionOperation<T> extends PromiseLike<T> {}\n"],"mappings":"2RAsEA,MAAM,EAAoE,EAAE,CACtE,EAAwC,IAAI,QAMlD,SAAgB,0BACd,EAC2D,CAC3D,IAAM,EAAY,OAAO,eAAe,EAAU,CAC5C,EAAQ,EAAsC,IAAI,EAAU,CAClE,GAAI,IAAU,IAAA,GAAW,MAAM,IAAI,EACnC,OAAO,EAIT,SAAgB,kCACd,EACA,EACA,EACM,CACN,IAAM,EACJ,EACI,QACJ,GAEA,EAAa,EAAM,EAAI,OAAO,eAAe,EAAM,GAAK,EACpD,EACA,IAAA,GACA,EAAoD,OAAO,OAAO,CACtE,QACD,CAAC,CACF,EAA2B,KAAK,EAAa,CAC7C,EAAsC,IAAI,EAAW,EAAc,CAIrE,SAAgB,yBACd,EACuE,CACvE,IAAK,IAAM,KAAgB,EACzB,GAAI,CACF,IAAM,EAAQ,EAAa,QAAQ,EAAM,CACzC,GAAI,IAAU,IAAA,GAAW,OAAO,OAC1B"}
1
+ {"version":3,"file":"transaction-operation-CU1zlxiG.mjs","names":[],"sources":["../src/query-engine/transaction-operation.ts"],"sourcesContent":["import type {\n AnyDriver,\n QueryExecutionContext,\n QueryResult,\n} from \"@drivers/exports\";\nimport { InvalidTransactionInputError } from \"@errors\";\nimport type { ObservationCompletionFactsReader } from \"@extensions/observation\";\nimport type {\n QueryInterceptorExecutionControl,\n TransactionWriteOutcomes,\n WriteOutcomeNotifications,\n} from \"@extensions/query\";\nimport type { PreparedBatchOperation, PreparedQuery } from \"./types\";\n\n/** One shared owner table registered once by each genuine operation class. */\nexport interface TransactionOperationOwner<Owner extends object = object> {\n clientId(owner: Owner): symbol;\n scopeId(owner: Owner): symbol;\n model(owner: Owner): string;\n operation(owner: Owner): string;\n context(owner: Owner): QueryExecutionContext;\n requiresInterception(owner: Owner): boolean;\n prepareAdmission(owner: Owner, phase?: \"input\" | \"plan\"): void;\n stagePackageWriteOutcomes(\n owner: Owner,\n outcomes: TransactionWriteOutcomes\n ): void;\n startInterception(\n owner: Owner,\n child: (notifications?: WriteOutcomeNotifications) => Promise<unknown>,\n outcomes: TransactionWriteOutcomes,\n control: QueryInterceptorExecutionControl\n ): Promise<unknown>;\n executeCore(\n owner: Owner,\n driver: AnyDriver,\n notifications?: WriteOutcomeNotifications\n ): Promise<unknown>;\n isWrite(owner: Owner): boolean;\n hasObservation(owner: Owner): boolean;\n observe(\n owner: Owner,\n child: () => Promise<unknown>,\n readCompletionFacts?: ObservationCompletionFactsReader\n ): Promise<unknown>;\n reserveWith(owner: Owner, driver: AnyDriver): void;\n executeWith(owner: Owner, driver: AnyDriver): Promise<unknown>;\n /** The member's value as its caller receives it (its computed fields). */\n finishResult?(owner: Owner, value: unknown): unknown;\n prepare(owner: Owner, driver?: AnyDriver): PreparedQuery | undefined;\n prepareBatch(\n owner: Owner\n ): Promise<PreparedBatchOperation<unknown> | undefined>;\n parseResult(owner: Owner, raw: QueryResult<unknown>): unknown;\n observeBatchPhase<Result>(\n owner: Owner,\n driver: AnyDriver,\n execute: () => Result | Promise<Result>\n ): Promise<Result>;\n}\n\n/** The private authority resolved only while coordinating an array. */\nexport type TransactionOperationCapability = object;\n\ninterface RegisteredTransactionOperationOwner {\n readonly resolve: TransactionOperationResolver;\n}\n\ntype TransactionOperationResolver = (\n value: object\n) => TransactionOperationOwner<TransactionOperationCapability> | undefined;\n\nconst transactionOperationOwners: RegisteredTransactionOperationOwner[] = [];\nconst transactionOperationOwnersByPrototype = new WeakMap<\n object,\n TransactionOperationOwner<TransactionOperationCapability>\n>();\n\n/** Resolve the one class owner after the capability passed admission. */\nexport function transactionOperationOwner(\n operation: TransactionOperationCapability\n): TransactionOperationOwner<TransactionOperationCapability> {\n const prototype = Object.getPrototypeOf(operation);\n const owner = transactionOperationOwnersByPrototype.get(prototype);\n if (owner === undefined) throw new InvalidTransactionInputError();\n return owner;\n}\n\n/** Register one class-owned array authority for its exact private brand. */\nexport function registerTransactionOperationOwner<Owner extends object>(\n prototype: object,\n authenticate: (value: object) => value is Owner,\n owner: TransactionOperationOwner<Owner>\n): void {\n const resolvedOwner: TransactionOperationOwner<TransactionOperationCapability> =\n owner;\n const resolve = (\n value: object\n ): TransactionOperationOwner<TransactionOperationCapability> | undefined =>\n authenticate(value) && Object.getPrototypeOf(value) === prototype\n ? resolvedOwner\n : undefined;\n const registration: RegisteredTransactionOperationOwner = Object.freeze({\n resolve,\n });\n transactionOperationOwners.push(registration);\n transactionOperationOwnersByPrototype.set(prototype, resolvedOwner);\n}\n\n/** Resolve one owner only for an object constructed by its registered class. */\nexport function readTransactionOperation(\n value: object\n): TransactionOperationOwner<TransactionOperationCapability> | undefined {\n for (const registration of transactionOperationOwners) {\n try {\n const owner = registration.resolve(value);\n if (owner !== undefined) return owner;\n } catch {\n // A hostile candidate cannot interrupt the remaining genuine owners.\n }\n }\n return undefined;\n}\n\n/** The static thenable accepted by internal transaction composition. */\nexport interface TransactionOperation<T> extends PromiseLike<T> {}\n"],"mappings":"2RAwEA,MAAM,EAAoE,EAAE,CACtE,EAAwC,IAAI,QAMlD,SAAgB,0BACd,EAC2D,CAC3D,IAAM,EAAY,OAAO,eAAe,EAAU,CAC5C,EAAQ,EAAsC,IAAI,EAAU,CAClE,GAAI,IAAU,IAAA,GAAW,MAAM,IAAI,EACnC,OAAO,EAIT,SAAgB,kCACd,EACA,EACA,EACM,CACN,IAAM,EACJ,EACI,QACJ,GAEA,EAAa,EAAM,EAAI,OAAO,eAAe,EAAM,GAAK,EACpD,EACA,IAAA,GACA,EAAoD,OAAO,OAAO,CACtE,QACD,CAAC,CACF,EAA2B,KAAK,EAAa,CAC7C,EAAsC,IAAI,EAAW,EAAc,CAIrE,SAAgB,yBACd,EACuE,CACvE,IAAK,IAAM,KAAgB,EACzB,GAAI,CACF,IAAM,EAAQ,EAAa,QAAQ,EAAM,CACzC,GAAI,IAAU,IAAA,GAAW,OAAO,OAC1B"}
@@ -23,4 +23,4 @@ Searched for:\n${t.map(e=>` - ${e}`).join(`
23
23
  name: s.string(),
24
24
  });
25
25
  `);return e.skipValidation||n(p),{client:u.client,driver:d,models:p,migrations:u.migrations}}function loadCliModule(e){return s(e,{tsconfigPaths:!0,interopDefault:!0}).import(e)}function extractModels(e){let t={};for(let[n,r]of Object.entries(e))isModel(r)&&(t[n]=r);return t}function isModel(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`~`);if(typeof t!=`object`||!t)return!1;let n=Reflect.get(t,`state`);return typeof n==`object`&&!!n&&`scalars`in n}function isValidClient(e){return e===null||typeof e!=`object`&&typeof e!=`function`?!1:Reflect.get(e,`$driver`)!==void 0&&Reflect.get(e,`$schema`)!==void 0}function defineConfig(e){return e}export{runCli as i,loadCliModule as n,printJson as r,defineConfig as t};
26
- //# sourceMappingURL=utils-Qr8ug94X.mjs.map
26
+ //# sourceMappingURL=utils-DkAxKcDD.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils-Qr8ug94X.mjs","names":[],"sources":["../src/cli/utils.ts"],"sourcesContent":["/**\n * CLI Utilities\n *\n * Configuration loading and other CLI utilities.\n *\n * Config file pattern similar to:\n * - drizzle.config.ts\n * - prisma (uses schema.prisma but we use TS)\n */\n\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { loadEnvFile } from \"node:process\";\nimport { createJiti } from \"jiti\";\nimport type { AnyDriver } from \"../drivers/driver\";\nimport { withSuppressedFailure } from \"../drivers/shared/suppressed-failure\";\nimport { isVibORMError } from \"../errors\";\nimport type { MigrationClient } from \"../migrations/push/planner\";\nimport type { MigrationStorageWriter } from \"../migrations/storage/contract\";\nimport type { ResolveCallback } from \"../migrations/types\";\nimport type { AnyModel } from \"../schema/model\";\nimport { validateSchemaOrThrow } from \"../schema/validation\";\n\n// =============================================================================\n// CONFIG TYPES\n// =============================================================================\n\n/**\n * Migration configuration options.\n */\nexport interface MigrationConfig {\n /** Estate directory (default: \"./migrations\") */\n dir?: string;\n /** Immutable exact physical table scope; include junctions and rename destinations. */\n tables?: readonly string[];\n /** Explicit rename, destructive-change and enum-value decisions for CLI planning. */\n resolve?: ResolveCallback;\n /**\n * Estate storage writer. Defaults to filesystem storage at `dir`.\n *\n * @example\n * ```ts\n * import { createFsStorageWriter } from \"viborm/migrations/storage/fs\";\n *\n * migrations: {\n * storage: createFsStorageWriter(\"./migrations\"),\n * }\n * ```\n */\n storage?: MigrationStorageWriter;\n}\n\n/**\n * VibORM configuration file format.\n *\n * Example viborm.config.ts:\n * ```ts\n * import { defineConfig } from \"viborm/config\";\n * import { client } from \"./src/db\";\n *\n * export default defineConfig({\n * client,\n * });\n * ```\n */\nexport interface VibORMConfig {\n /** VibORM client instance */\n client: MigrationClient & { $disconnect(): Promise<void> };\n /** Optional: Migration configuration */\n migrations?: MigrationConfig;\n}\n\nexport interface LoadConfigOptions {\n /** Path to config file (default: ./viborm.config.ts) */\n config?: string;\n /** Leave validation to the caller (`viborm check` reports every issue). */\n skipValidation?: boolean;\n}\n\nexport interface LoadedConfig {\n client: VibORMConfig[\"client\"];\n driver: AnyDriver;\n models: Record<string, AnyModel>;\n migrations?: MigrationConfig;\n}\n\n// =============================================================================\n// CONFIG FILE DISCOVERY\n// =============================================================================\n\nconst CONFIG_FILES = [\n \"viborm.config.ts\",\n \"viborm.config.mts\",\n \"viborm.config.js\",\n \"viborm.config.mjs\",\n];\n\n/**\n * Finds the first existing file from a list of candidates.\n */\nfunction findFile(cwd: string, candidates: string[]): string | null {\n for (const candidate of candidates) {\n const fullPath = resolve(cwd, candidate);\n if (existsSync(fullPath)) {\n return fullPath;\n }\n }\n return null;\n}\n\n// =============================================================================\n// CONFIG LOADING\n// =============================================================================\n\n/**\n * Loads VibORM configuration from viborm.config.ts file.\n *\n * The config file should export a default configuration object with:\n * - client: VibORM client instance created with createClient()\n */\nexport function failCli(error: unknown, json = false): never {\n const trusted = isVibORMError(error);\n const message =\n error instanceof Error\n ? error.message\n : typeof error === \"string\"\n ? error\n : \"CLI operation failed\";\n const code = trusted ? error.code : undefined;\n const exitCode = code?.startsWith(\"V11\")\n ? Number(code.slice(1)) - 11_000 + 10\n : trusted\n ? 2\n : 1;\n process.stderr.write(\n json\n ? `${JSON.stringify({ error: trusted ? error.toJSON() : { name: error instanceof Error ? error.name : \"Error\", message }, exitCode })}\\n`\n : `${code ? `[${code}] ` : \"\"}${message}\\n`\n );\n process.exit(exitCode);\n}\n\n/** Await owned CLI cleanup before reporting either the primary or cleanup failure. */\nexport async function finishCli(\n client: { $disconnect(): Promise<void> } | undefined,\n failure: { value: unknown } | undefined,\n json = false\n): Promise<void> {\n let outcome = failure;\n try {\n await client?.$disconnect();\n } catch (cleanup) {\n outcome = {\n value: failure ? withSuppressedFailure(failure.value, cleanup) : cleanup,\n };\n }\n if (outcome) {\n if (json) failCli(outcome.value, true);\n else failCli(outcome.value);\n }\n}\n\n/** Every command's frame: load the config, own its client, report through {@link finishCli}. */\nexport async function runCli(\n load: LoadConfigOptions,\n json: boolean | undefined,\n body: (config: LoadedConfig) => Promise<void>\n): Promise<void> {\n let client: { $disconnect(): Promise<void> } | undefined;\n let failure: { value: unknown } | undefined;\n try {\n const config = await loadConfig(load);\n client = config.client;\n await body(config);\n } catch (error) {\n failure = { value: error };\n } finally {\n await finishCli(client, failure, json);\n }\n}\n\n/** JSON for `--json`, else an indented outline of the same value. */\nexport function printJson(value: unknown, json: boolean): void {\n if (json) {\n process.stdout.write(`${JSON.stringify(value, null, 2)}\\n`);\n return;\n }\n const lines: string[] = [];\n const render = (item: unknown, indent = \"\") => {\n if (Array.isArray(item)) {\n for (const entry of item) {\n lines.push(`${indent}-`);\n render(entry, `${indent} `);\n }\n if (item.length === 0) lines.push(`${indent}(none)`);\n } else if (item !== null && typeof item === \"object\") {\n for (const [key, entry] of Object.entries(item)) {\n if (entry !== null && typeof entry === \"object\") {\n lines.push(`${indent}${key}:`);\n render(entry, `${indent} `);\n } else lines.push(`${indent}${key}: ${String(entry)}`);\n }\n } else lines.push(`${indent}${String(item)}`);\n };\n render(value);\n process.stdout.write(`${lines.join(\"\\n\")}\\n`);\n}\n\nexport async function loadConfig(\n options: LoadConfigOptions = {}\n): Promise<LoadedConfig> {\n const cwd = process.cwd();\n const envPath = resolve(cwd, \".env\");\n if (existsSync(envPath)) loadEnvFile(envPath);\n\n // Find config file\n const configPath = options.config\n ? resolve(cwd, options.config)\n : findFile(cwd, CONFIG_FILES);\n\n if (!(configPath && existsSync(configPath))) {\n const searchedPaths = options.config ? [options.config] : CONFIG_FILES;\n\n throw new Error(\n \"Could not find VibORM configuration file.\\n\\n\" +\n `Searched for:\\n${searchedPaths.map((f) => ` - ${f}`).join(\"\\n\")}\\n\\n` +\n \"Create a viborm.config.ts file:\\n\\n\" +\n ` import { defineConfig } from \"viborm/config\";\\n` +\n ` import { client } from \"./src/db\";\\n\\n` +\n \" export default defineConfig({\\n\" +\n \" client,\\n\" +\n \" });\\n\"\n );\n }\n\n // Load the config file\n const configModule = await loadCliModule<\n VibORMConfig & { default?: VibORMConfig; config?: VibORMConfig }\n >(configPath);\n\n // Extract config (handle both default export and named export)\n const config: VibORMConfig =\n (Object.hasOwn(configModule, \"default\") && configModule.default) ||\n configModule.config ||\n configModule;\n\n // Validate client\n if (!config.client) {\n throw new Error(\n `Missing \"client\" in ${configPath}.\\n\\n` +\n \"Your config should include a VibORM client:\\n\\n\" +\n ` import { createClient } from \"viborm\";\\n` +\n \" const client = createClient({ driver, schema });\\n\\n\" +\n \" export default defineConfig({\\n\" +\n \" client,\\n\" +\n \" });\\n\"\n );\n }\n\n if (!isValidClient(config.client)) {\n throw new Error(\n `Invalid \"client\" in ${configPath}.\\n\\n` +\n \"The client must be created with createClient().\\n\"\n );\n }\n\n // Extract driver and schema from client\n const driver = config.client.$driver;\n const schemaInput = config.client.$schema;\n\n // Extract models from schema (filter out non-model exports)\n const models = extractModels(schemaInput);\n\n if (Object.keys(models).length === 0) {\n throw new Error(\n `No models found in client schema from ${configPath}.\\n\\n` +\n \"Make sure your client was created with schema models:\\n\\n\" +\n \" // src/schema.ts\\n\" +\n ` import { s } from \"viborm\";\\n\\n` +\n \" export const user = s.model({\\n\" +\n \" id: s.string().id(),\\n\" +\n \" name: s.string(),\\n\" +\n \" });\\n\"\n );\n }\n\n // Validate schema before proceeding\n if (!options.skipValidation) validateSchemaOrThrow(models);\n\n return {\n client: config.client,\n driver,\n models,\n migrations: config.migrations,\n };\n}\n\n/**\n * Dynamically imports a TypeScript/JavaScript module.\n */\nexport function loadCliModule<T>(filePath: string): Promise<T> {\n // Dependency imports need CJS interop; consumers select only authored defaults.\n return createJiti(filePath, {\n tsconfigPaths: true,\n interopDefault: true,\n }).import<T>(filePath);\n}\n\n/**\n * Extracts model objects from a module by checking for Model instances.\n */\nfunction extractModels(\n schema: Record<string, unknown>\n): Record<string, AnyModel> {\n const models: Record<string, AnyModel> = {};\n\n for (const [key, value] of Object.entries(schema)) {\n if (isModel(value)) {\n models[key] = value;\n }\n }\n\n return models;\n}\n\n/**\n * Checks if a value is a VibORM Model instance.\n */\nfunction isModel(value: unknown): value is AnyModel {\n if (value === null || typeof value !== \"object\") return false;\n const metadata = Reflect.get(value, \"~\");\n if (metadata === null || typeof metadata !== \"object\") return false;\n const state = Reflect.get(metadata, \"state\");\n // Model state exposes `scalars`/`relations` (never `fields`); the rest of\n // the codebase discriminates models the same way (see serializer).\n return state !== null && typeof state === \"object\" && \"scalars\" in state;\n}\n\n/**\n * Checks if a value is a valid VibORM client instance.\n */\nfunction isValidClient(value: unknown): boolean {\n // The client is a Proxy whose only trap is `get`, so `\"$driver\" in value`\n // (which triggers the `has` trap / falls back to the bare target) is always\n // false. Probe via property access instead.\n // `typeof null === \"object\"`, so null has to be refused here: Reflect.get\n // throws on it rather than answering undefined.\n if (\n value === null ||\n (typeof value !== \"object\" && typeof value !== \"function\")\n ) {\n return false;\n }\n return (\n Reflect.get(value, \"$driver\") !== undefined &&\n Reflect.get(value, \"$schema\") !== undefined\n );\n}\n\n// =============================================================================\n// DEFINE CONFIG HELPER\n// =============================================================================\n\n/**\n * Helper function for defining VibORM configuration with type safety.\n *\n * @example\n * ```ts\n * // viborm.config.ts\n * import { defineConfig } from \"viborm/config\";\n * import { client } from \"./src/db\";\n *\n * export default defineConfig({\n * client,\n * });\n * ```\n */\nexport function defineConfig<const C extends VibORMConfig>(\n config: C &\n Record<Exclude<keyof C, keyof VibORMConfig>, never> &\n (C extends { migrations: infer M }\n ? {\n migrations: M &\n Record<Exclude<keyof M, keyof MigrationConfig>, never>;\n }\n : unknown)\n): C {\n return config;\n}\n"],"mappings":"0UA0FA,MAAM,EAAe,CACnB,mBACA,oBACA,mBACA,oBACD,CAKD,SAAS,SAAS,EAAa,EAAqC,CACl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U,MACR,uBAAuB,EAAW;EAEnC,CAIH,IAAM,EAAS,EAAO,OAAO,QACvB,EAAc,EAAO,OAAO,QAG5B,EAAS,cAAc,EAAY,CAEzC,GAAI,OAAO,KAAK,EAAO,CAAC,SAAW,EACjC,MAAU,MACR,yCAAyC,EAAW;;;;;;;EAQrD,CAMH,OAFK,EAAQ,gBAAgB,EAAsB,EAAO,CAEnD,CACL,OAAQ,EAAO,OACf,SACA,SACA,WAAY,EAAO,WACpB,CAMH,SAAgB,cAAiB,EAA8B,CAE7D,OAAO,EAAW,EAAU,CAC1B,cAAe,GACf,eAAgB,GACjB,CAAC,CAAC,OAAU,EAAS,CAMxB,SAAS,cACP,EAC0B,CAC1B,IAAM,EAAmC,EAAE,CAE3C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAO,CAC3C,QAAQ,EAAM,GAChB,EAAO,GAAO,GAIlB,OAAO,EAMT,SAAS,QAAQ,EAAmC,CAClD,GAAsB,OAAO,GAAU,WAAnC,EAA6C,MAAO,GACxD,IAAM,EAAW,QAAQ,IAAI,EAAO,IAAI,CACxC,GAAyB,OAAO,GAAa,WAAzC,EAAmD,MAAO,GAC9D,IAAM,EAAQ,QAAQ,IAAI,EAAU,QAAQ,CAG5C,OAAyB,OAAO,GAAU,YAAnC,GAA+C,YAAa,EAMrE,SAAS,cAAc,EAAyB,CAY9C,OALE,IAAU,MACT,OAAO,GAAU,UAAY,OAAO,GAAU,WAExC,GAGP,QAAQ,IAAI,EAAO,UAAU,GAAK,IAAA,IAClC,QAAQ,IAAI,EAAO,UAAU,GAAK,IAAA,GAsBtC,SAAgB,aACd,EAQG,CACH,OAAO"}
1
+ {"version":3,"file":"utils-DkAxKcDD.mjs","names":[],"sources":["../src/cli/utils.ts"],"sourcesContent":["/**\n * CLI Utilities\n *\n * Configuration loading and other CLI utilities.\n *\n * Config file pattern similar to:\n * - drizzle.config.ts\n * - prisma (uses schema.prisma but we use TS)\n */\n\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { loadEnvFile } from \"node:process\";\nimport { createJiti } from \"jiti\";\nimport type { AnyDriver } from \"../drivers/driver\";\nimport { withSuppressedFailure } from \"../drivers/shared/suppressed-failure\";\nimport { isVibORMError } from \"../errors\";\nimport type { MigrationClient } from \"../migrations/push/planner\";\nimport type { MigrationStorageWriter } from \"../migrations/storage/contract\";\nimport type { ResolveCallback } from \"../migrations/types\";\nimport type { AnyModel } from \"../schema/model\";\nimport { validateSchemaOrThrow } from \"../schema/validation\";\n\n// =============================================================================\n// CONFIG TYPES\n// =============================================================================\n\n/**\n * Migration configuration options.\n */\nexport interface MigrationConfig {\n /** Estate directory (default: \"./migrations\") */\n dir?: string;\n /** Immutable exact physical table scope; include junctions and rename destinations. */\n tables?: readonly string[];\n /** Explicit rename, destructive-change and enum-value decisions for CLI planning. */\n resolve?: ResolveCallback;\n /**\n * Estate storage writer. Defaults to filesystem storage at `dir`.\n *\n * @example\n * ```ts\n * import { createFsStorageWriter } from \"viborm/migrations/storage/fs\";\n *\n * migrations: {\n * storage: createFsStorageWriter(\"./migrations\"),\n * }\n * ```\n */\n storage?: MigrationStorageWriter;\n}\n\n/**\n * VibORM configuration file format.\n *\n * Example viborm.config.ts:\n * ```ts\n * import { defineConfig } from \"viborm/config\";\n * import { client } from \"./src/db\";\n *\n * export default defineConfig({\n * client,\n * });\n * ```\n */\nexport interface VibORMConfig {\n /** VibORM client instance */\n client: MigrationClient & { $disconnect(): Promise<void> };\n /** Optional: Migration configuration */\n migrations?: MigrationConfig;\n}\n\nexport interface LoadConfigOptions {\n /** Path to config file (default: ./viborm.config.ts) */\n config?: string;\n /** Leave validation to the caller (`viborm check` reports every issue). */\n skipValidation?: boolean;\n}\n\nexport interface LoadedConfig {\n client: VibORMConfig[\"client\"];\n driver: AnyDriver;\n models: Record<string, AnyModel>;\n migrations?: MigrationConfig;\n}\n\n// =============================================================================\n// CONFIG FILE DISCOVERY\n// =============================================================================\n\nconst CONFIG_FILES = [\n \"viborm.config.ts\",\n \"viborm.config.mts\",\n \"viborm.config.js\",\n \"viborm.config.mjs\",\n];\n\n/**\n * Finds the first existing file from a list of candidates.\n */\nfunction findFile(cwd: string, candidates: string[]): string | null {\n for (const candidate of candidates) {\n const fullPath = resolve(cwd, candidate);\n if (existsSync(fullPath)) {\n return fullPath;\n }\n }\n return null;\n}\n\n// =============================================================================\n// CONFIG LOADING\n// =============================================================================\n\n/**\n * Loads VibORM configuration from viborm.config.ts file.\n *\n * The config file should export a default configuration object with:\n * - client: VibORM client instance created with createClient()\n */\nexport function failCli(error: unknown, json = false): never {\n const trusted = isVibORMError(error);\n const message =\n error instanceof Error\n ? error.message\n : typeof error === \"string\"\n ? error\n : \"CLI operation failed\";\n const code = trusted ? error.code : undefined;\n const exitCode = code?.startsWith(\"V11\")\n ? Number(code.slice(1)) - 11_000 + 10\n : trusted\n ? 2\n : 1;\n process.stderr.write(\n json\n ? `${JSON.stringify({ error: trusted ? error.toJSON() : { name: error instanceof Error ? error.name : \"Error\", message }, exitCode })}\\n`\n : `${code ? `[${code}] ` : \"\"}${message}\\n`\n );\n process.exit(exitCode);\n}\n\n/** Await owned CLI cleanup before reporting either the primary or cleanup failure. */\nexport async function finishCli(\n client: { $disconnect(): Promise<void> } | undefined,\n failure: { value: unknown } | undefined,\n json = false\n): Promise<void> {\n let outcome = failure;\n try {\n await client?.$disconnect();\n } catch (cleanup) {\n outcome = {\n value: failure ? withSuppressedFailure(failure.value, cleanup) : cleanup,\n };\n }\n if (outcome) {\n if (json) failCli(outcome.value, true);\n else failCli(outcome.value);\n }\n}\n\n/** Every command's frame: load the config, own its client, report through {@link finishCli}. */\nexport async function runCli(\n load: LoadConfigOptions,\n json: boolean | undefined,\n body: (config: LoadedConfig) => Promise<void>\n): Promise<void> {\n let client: { $disconnect(): Promise<void> } | undefined;\n let failure: { value: unknown } | undefined;\n try {\n const config = await loadConfig(load);\n client = config.client;\n await body(config);\n } catch (error) {\n failure = { value: error };\n } finally {\n await finishCli(client, failure, json);\n }\n}\n\n/** JSON for `--json`, else an indented outline of the same value. */\nexport function printJson(value: unknown, json: boolean): void {\n if (json) {\n process.stdout.write(`${JSON.stringify(value, null, 2)}\\n`);\n return;\n }\n const lines: string[] = [];\n const render = (item: unknown, indent = \"\") => {\n if (Array.isArray(item)) {\n for (const entry of item) {\n lines.push(`${indent}-`);\n render(entry, `${indent} `);\n }\n if (item.length === 0) lines.push(`${indent}(none)`);\n } else if (item !== null && typeof item === \"object\") {\n for (const [key, entry] of Object.entries(item)) {\n if (entry !== null && typeof entry === \"object\") {\n lines.push(`${indent}${key}:`);\n render(entry, `${indent} `);\n } else lines.push(`${indent}${key}: ${String(entry)}`);\n }\n } else lines.push(`${indent}${String(item)}`);\n };\n render(value);\n process.stdout.write(`${lines.join(\"\\n\")}\\n`);\n}\n\nexport async function loadConfig(\n options: LoadConfigOptions = {}\n): Promise<LoadedConfig> {\n const cwd = process.cwd();\n const envPath = resolve(cwd, \".env\");\n if (existsSync(envPath)) loadEnvFile(envPath);\n\n // Find config file\n const configPath = options.config\n ? resolve(cwd, options.config)\n : findFile(cwd, CONFIG_FILES);\n\n if (!(configPath && existsSync(configPath))) {\n const searchedPaths = options.config ? [options.config] : CONFIG_FILES;\n\n throw new Error(\n \"Could not find VibORM configuration file.\\n\\n\" +\n `Searched for:\\n${searchedPaths.map((f) => ` - ${f}`).join(\"\\n\")}\\n\\n` +\n \"Create a viborm.config.ts file:\\n\\n\" +\n ` import { defineConfig } from \"viborm/config\";\\n` +\n ` import { client } from \"./src/db\";\\n\\n` +\n \" export default defineConfig({\\n\" +\n \" client,\\n\" +\n \" });\\n\"\n );\n }\n\n // Load the config file\n const configModule = await loadCliModule<\n VibORMConfig & { default?: VibORMConfig; config?: VibORMConfig }\n >(configPath);\n\n // Extract config (handle both default export and named export)\n const config: VibORMConfig =\n (Object.hasOwn(configModule, \"default\") && configModule.default) ||\n configModule.config ||\n configModule;\n\n // Validate client\n if (!config.client) {\n throw new Error(\n `Missing \"client\" in ${configPath}.\\n\\n` +\n \"Your config should include a VibORM client:\\n\\n\" +\n ` import { createClient } from \"viborm\";\\n` +\n \" const client = createClient({ driver, schema });\\n\\n\" +\n \" export default defineConfig({\\n\" +\n \" client,\\n\" +\n \" });\\n\"\n );\n }\n\n if (!isValidClient(config.client)) {\n throw new Error(\n `Invalid \"client\" in ${configPath}.\\n\\n` +\n \"The client must be created with createClient().\\n\"\n );\n }\n\n // Extract driver and schema from client\n const driver = config.client.$driver;\n const schemaInput = config.client.$schema;\n\n // Extract models from schema (filter out non-model exports)\n const models = extractModels(schemaInput);\n\n if (Object.keys(models).length === 0) {\n throw new Error(\n `No models found in client schema from ${configPath}.\\n\\n` +\n \"Make sure your client was created with schema models:\\n\\n\" +\n \" // src/schema.ts\\n\" +\n ` import { s } from \"viborm\";\\n\\n` +\n \" export const user = s.model({\\n\" +\n \" id: s.string().id(),\\n\" +\n \" name: s.string(),\\n\" +\n \" });\\n\"\n );\n }\n\n // Validate schema before proceeding\n if (!options.skipValidation) validateSchemaOrThrow(models);\n\n return {\n client: config.client,\n driver,\n models,\n migrations: config.migrations,\n };\n}\n\n/**\n * Dynamically imports a TypeScript/JavaScript module.\n */\nexport function loadCliModule<T>(filePath: string): Promise<T> {\n // Dependency imports need CJS interop; consumers select only authored defaults.\n return createJiti(filePath, {\n tsconfigPaths: true,\n interopDefault: true,\n }).import<T>(filePath);\n}\n\n/**\n * Extracts model objects from a module by checking for Model instances.\n */\nfunction extractModels(\n schema: Record<string, unknown>\n): Record<string, AnyModel> {\n const models: Record<string, AnyModel> = {};\n\n for (const [key, value] of Object.entries(schema)) {\n if (isModel(value)) {\n models[key] = value;\n }\n }\n\n return models;\n}\n\n/**\n * Checks if a value is a VibORM Model instance.\n */\nfunction isModel(value: unknown): value is AnyModel {\n if (value === null || typeof value !== \"object\") return false;\n const metadata = Reflect.get(value, \"~\");\n if (metadata === null || typeof metadata !== \"object\") return false;\n const state = Reflect.get(metadata, \"state\");\n // Model state exposes `scalars`/`relations` (never `fields`); the rest of\n // the codebase discriminates models the same way (see serializer).\n return state !== null && typeof state === \"object\" && \"scalars\" in state;\n}\n\n/**\n * Checks if a value is a valid VibORM client instance.\n */\nfunction isValidClient(value: unknown): boolean {\n // The client is a Proxy whose only trap is `get`, so `\"$driver\" in value`\n // (which triggers the `has` trap / falls back to the bare target) is always\n // false. Probe via property access instead.\n // `typeof null === \"object\"`, so null has to be refused here: Reflect.get\n // throws on it rather than answering undefined.\n if (\n value === null ||\n (typeof value !== \"object\" && typeof value !== \"function\")\n ) {\n return false;\n }\n return (\n Reflect.get(value, \"$driver\") !== undefined &&\n Reflect.get(value, \"$schema\") !== undefined\n );\n}\n\n// =============================================================================\n// DEFINE CONFIG HELPER\n// =============================================================================\n\n/**\n * Helper function for defining VibORM configuration with type safety.\n *\n * @example\n * ```ts\n * // viborm.config.ts\n * import { defineConfig } from \"viborm/config\";\n * import { client } from \"./src/db\";\n *\n * export default defineConfig({\n * client,\n * });\n * ```\n */\nexport function defineConfig<const C extends VibORMConfig>(\n config: C &\n Record<Exclude<keyof C, keyof VibORMConfig>, never> &\n (C extends { migrations: infer M }\n ? {\n migrations: M &\n Record<Exclude<keyof M, keyof MigrationConfig>, never>;\n }\n : unknown)\n): C {\n return config;\n}\n"],"mappings":"0UA0FA,MAAM,EAAe,CACnB,mBACA,oBACA,mBACA,oBACD,CAKD,SAAS,SAAS,EAAa,EAAqC,CAClE,IAAK,IAAM,KAAa,EAAY,CAClC,IAAM,EAAW,EAAQ,EAAK,EAAU,CACxC,GAAI,EAAW,EAAS,CACtB,OAAO,EAGX,OAAO,KAaT,SAAgB,QAAQ,EAAgB,EAAO,GAAc,CAC3D,IAAM,EAAU,EAAc,EAAM,CAC9B,EACJ,aAAiB,MACb,EAAM,QACN,OAAO,GAAU,SACf,EACA,uBACF,EAAO,EAAU,EAAM,KAAO,IAAA,GAC9B,EAAW,GAAM,WAAW,MAAM,CACpC,OAAO,EAAK,MAAM,EAAE,CAAC,CA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U,CAC1B,cAAe,GACf,eAAgB,GACjB,CAAC,CAAC,OAAU,EAAS,CAMxB,SAAS,cACP,EAC0B,CAC1B,IAAM,EAAmC,EAAE,CAE3C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAO,CAC3C,QAAQ,EAAM,GAChB,EAAO,GAAO,GAIlB,OAAO,EAMT,SAAS,QAAQ,EAAmC,CAClD,GAAsB,OAAO,GAAU,WAAnC,EAA6C,MAAO,GACxD,IAAM,EAAW,QAAQ,IAAI,EAAO,IAAI,CACxC,GAAyB,OAAO,GAAa,WAAzC,EAAmD,MAAO,GAC9D,IAAM,EAAQ,QAAQ,IAAI,EAAU,QAAQ,CAG5C,OAAyB,OAAO,GAAU,YAAnC,GAA+C,YAAa,EAMrE,SAAS,cAAc,EAAyB,CAY9C,OALE,IAAU,MACT,OAAO,GAAU,UAAY,OAAO,GAAU,WAExC,GAGP,QAAQ,IAAI,EAAO,UAAU,GAAK,IAAA,IAClC,QAAQ,IAAI,EAAO,UAAU,GAAK,IAAA,GAsBtC,SAAgB,aACd,EAQG,CACH,OAAO"}
@@ -1,2 +1,2 @@
1
1
  import{n as e}from"./chunk-BuuaeEvq.mjs";import{i as t,o as n}from"./value-guards-CK9guf2Z.mjs";import{Nt as r,et as i,jt as a}from"./geo-point-codec-D95uXgDF.mjs";const o=` vibInferred`,isPromiseLike=e=>n(e)&&`then`in e&&t(e.then),s={issues:[{message:`Async validation is not supported`}]},c={issues:[{message:`Schema returned a malformed validation result`}]};function parse(e,t,o){try{let r=i(o?.allIssues===!0,()=>e[`~standard`].validate(t));if(isPromiseLike(r))return a(r),s;if(!n(r))return c;let l=Reflect.get(r,`issues`);return l===void 0?`value`in r?{value:Reflect.get(r,`value`)}:c:Array.isArray(l)?{issues:l}:c}catch(e){return r(e)}}export{o as n,parse as t};
2
- //# sourceMappingURL=validation-CPnrLcjW.mjs.map
2
+ //# sourceMappingURL=validation-C7Z6wTJa.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation-CPnrLcjW.mjs","names":[],"sources":["../src/validation/inferred.ts","../src/validation/index.ts"],"sourcesContent":["/**\n * Branded key for type inference.\n *\n * KEY INSIGHT: ArkType uses a STRING, not a unique symbol.\n * This is: export declare const inferred: \" arkInferred\";\n *\n * Using a string literal allows TypeScript's pattern matching\n * to work correctly during circular reference resolution.\n */\nexport const inferred = \" vibInferred\" as const;\nexport type inferred = typeof inferred;\n","// =============================================================================\n// VibORM Validation Library\n// =============================================================================\n//\n// A minimal, StandardSchema-compliant validation library with:\n// - Recursive type support (thunks for circular references)\n// - Fail-fast validation (throws on first error)\n// - Options-based API (optional, nullable, array, transform, default)\n// - Strict objects by default\n//\n// =============================================================================\n\nexport { createSchemaRegistry } from \"./builder\";\nexport type { inferred as inferredType } from \"./inferred\";\n// Branded type symbol\nexport { inferred } from \"./inferred\";\n// JSON Schema conversion (StandardJSONSchemaV1)\nexport type { JsonSchema } from \"./json-schema\";\nexport { createJsonSchemaConverter, toJsonSchema } from \"./json-schema\";\nexport type {\n ArgsSchemas,\n CoreSchemas,\n ModelArgsSchemas,\n ModelCoreInput,\n ModelCoreSchemas,\n ModelOperationInput,\n ModelRelationNestedInput,\n ModelSchemas,\n ModelStateSchemas,\n ScalarSchemas,\n} from \"./model\";\nexport type { BaseBigIntSchema } from \"./primitives/bigint\";\nexport type { BaseBlobSchema } from \"./primitives/blob\";\nexport type { BaseBooleanSchema } from \"./primitives/boolean\";\nexport type { BaseEnumSchema } from \"./primitives/enum\";\nexport type {\n GeoArea,\n GeoBounds,\n GeoPolygon,\n} from \"./primitives/geo-area-codec\";\nexport type { GeoPoint } from \"./primitives/geo-point-codec\";\nexport type {\n BaseIsoDateSchema,\n BaseIsoTimeSchema,\n BaseIsoTimestampSchema,\n} from \"./primitives/iso\";\nexport type {\n BaseJsonSchema,\n InputJsonValue,\n JsonValue,\n} from \"./primitives/json\";\nexport type { BaseIntegerSchema, BaseNumberSchema } from \"./primitives/number\";\nexport type { ObjectSchema } from \"./primitives/object\";\nexport type { BasePointSchema } from \"./primitives/point\";\n// V Namespace - Type-level schema mirrors for explicit type annotations\n// Convenience namespace (v.string(), v.number(), etc.)\nexport { type V, v, v as default } from \"./primitives/v\";\nexport type { BaseVectorSchema } from \"./primitives/vector\";\nexport type {\n InferInput,\n InferOutput,\n ParseResult,\n Prettify,\n SchemaRegistryLookup,\n SchemaRegistryOperation,\n VibSchema,\n} from \"./types\";\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport {\n discardAsyncValidationResult,\n validationFailureFromThrown,\n} from \"./parse-failure\";\nimport { reportingAllIssues } from \"./primitives/helpers\";\nimport type { ParseResult, ValidationFailure } from \"./types\";\nimport { isFunction, isRecord } from \"./value-guards\";\n\nconst isPromiseLike = (value: unknown): value is PromiseLike<unknown> => {\n return isRecord(value) && \"then\" in value && isFunction(value.then);\n};\n\nconst asyncValidationFailure: ValidationFailure = {\n issues: [{ message: \"Async validation is not supported\" }],\n};\n\nconst malformedValidationFailure: ValidationFailure = {\n issues: [{ message: \"Schema returned a malformed validation result\" }],\n};\n\n/**\n * Validate `value` against `schema`. `allIssues: true` reports every issue of\n * the value — each object member, each list item, every unknown or missing\n * key — instead of stopping at the first.\n */\nexport function parse<const S extends StandardSchemaV1>(\n schema: S,\n value: unknown,\n options?: { readonly allIssues?: boolean | undefined }\n): ParseResult<S>;\nexport function parse(\n schema: StandardSchemaV1,\n value: unknown,\n options?: { readonly allIssues?: boolean | undefined }\n): StandardSchemaV1.Result<unknown> {\n try {\n const result = reportingAllIssues(options?.allIssues === true, () =>\n schema[\"~standard\"].validate(value)\n );\n if (isPromiseLike(result)) {\n discardAsyncValidationResult(result);\n return asyncValidationFailure;\n }\n if (!isRecord(result)) return malformedValidationFailure;\n\n const issues = Reflect.get(result, \"issues\");\n if (issues !== undefined) {\n return Array.isArray(issues) ? { issues } : malformedValidationFailure;\n }\n if (!(\"value\" in result)) return malformedValidationFailure;\n return { value: Reflect.get(result, \"value\") };\n } catch (cause) {\n return validationFailureFromThrown(cause);\n }\n}\n"],"mappings":"oKASA,MAAa,EAAW,eCoElB,cAAiB,GACd,EAAS,EAAM,EAAI,SAAU,GAAS,EAAW,EAAM,KAAK,CAG/D,EAA4C,CAChD,OAAQ,CAAC,CAAE,QAAS,oCAAqC,CAAC,CAC3D,CAEK,EAAgD,CACpD,OAAQ,CAAC,CAAE,QAAS,gDAAiD,CAAC,CACvE,CAYD,SAAgB,MACd,EACA,EACA,EACkC,CAClC,GAAI,CACF,IAAM,EAAS,EAAmB,GAAS,YAAc,OACvD,EAAO,aAAa,SAAS,EAAM,CACpC,CACD,GAAI,cAAc,EAAO,CAEvB,OADA,EAA6B,EAAO,CAC7B,EAET,GAAI,CAAC,EAAS,EAAO,CAAE,OAAO,EAE9B,IAAM,EAAS,QAAQ,IAAI,EAAQ,SAAS,CAK5C,OAJI,IAAW,IAAA,GAGT,UAAW,EACV,CAAE,MAAO,QAAQ,IAAI,EAAQ,QAAQ,CAAE,CADb,EAFxB,MAAM,QAAQ,EAAO,CAAG,CAAE,SAAQ,CAAG,QAIvC,EAAO,CACd,OAAO,EAA4B,EAAM"}
1
+ {"version":3,"file":"validation-C7Z6wTJa.mjs","names":[],"sources":["../src/validation/inferred.ts","../src/validation/index.ts"],"sourcesContent":["/**\n * Branded key for type inference.\n *\n * KEY INSIGHT: ArkType uses a STRING, not a unique symbol.\n * This is: export declare const inferred: \" arkInferred\";\n *\n * Using a string literal allows TypeScript's pattern matching\n * to work correctly during circular reference resolution.\n */\nexport const inferred = \" vibInferred\" as const;\nexport type inferred = typeof inferred;\n","// =============================================================================\n// VibORM Validation Library\n// =============================================================================\n//\n// A minimal, StandardSchema-compliant validation library with:\n// - Recursive type support (thunks for circular references)\n// - Fail-fast validation (throws on first error)\n// - Options-based API (optional, nullable, array, transform, default)\n// - Strict objects by default\n//\n// =============================================================================\n\nexport { createSchemaRegistry } from \"./builder\";\nexport type { inferred as inferredType } from \"./inferred\";\n// Branded type symbol\nexport { inferred } from \"./inferred\";\n// JSON Schema conversion (StandardJSONSchemaV1)\nexport type { JsonSchema } from \"./json-schema\";\nexport { createJsonSchemaConverter, toJsonSchema } from \"./json-schema\";\nexport type {\n ArgsSchemas,\n CoreSchemas,\n ModelArgsSchemas,\n ModelCoreInput,\n ModelCoreSchemas,\n ModelOperationInput,\n ModelRelationNestedInput,\n ModelSchemas,\n ModelStateSchemas,\n ScalarSchemas,\n} from \"./model\";\nexport type { BaseBigIntSchema } from \"./primitives/bigint\";\nexport type { BaseBlobSchema } from \"./primitives/blob\";\nexport type { BaseBooleanSchema } from \"./primitives/boolean\";\nexport type { BaseEnumSchema } from \"./primitives/enum\";\nexport type {\n GeoArea,\n GeoBounds,\n GeoPolygon,\n} from \"./primitives/geo-area-codec\";\nexport type { GeoPoint } from \"./primitives/geo-point-codec\";\nexport type {\n BaseIsoDateSchema,\n BaseIsoTimeSchema,\n BaseIsoTimestampSchema,\n} from \"./primitives/iso\";\nexport type {\n BaseJsonSchema,\n InputJsonValue,\n JsonValue,\n} from \"./primitives/json\";\nexport type { BaseIntegerSchema, BaseNumberSchema } from \"./primitives/number\";\nexport type { ObjectSchema } from \"./primitives/object\";\nexport type { BasePointSchema } from \"./primitives/point\";\n// V Namespace - Type-level schema mirrors for explicit type annotations\n// Convenience namespace (v.string(), v.number(), etc.)\nexport { type V, v, v as default } from \"./primitives/v\";\nexport type { BaseVectorSchema } from \"./primitives/vector\";\nexport type {\n InferInput,\n InferOutput,\n ParseResult,\n Prettify,\n SchemaRegistryLookup,\n SchemaRegistryOperation,\n VibSchema,\n} from \"./types\";\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport {\n discardAsyncValidationResult,\n validationFailureFromThrown,\n} from \"./parse-failure\";\nimport { reportingAllIssues } from \"./primitives/helpers\";\nimport type { ParseResult, ValidationFailure } from \"./types\";\nimport { isFunction, isRecord } from \"./value-guards\";\n\nconst isPromiseLike = (value: unknown): value is PromiseLike<unknown> => {\n return isRecord(value) && \"then\" in value && isFunction(value.then);\n};\n\nconst asyncValidationFailure: ValidationFailure = {\n issues: [{ message: \"Async validation is not supported\" }],\n};\n\nconst malformedValidationFailure: ValidationFailure = {\n issues: [{ message: \"Schema returned a malformed validation result\" }],\n};\n\n/**\n * Validate `value` against `schema`. `allIssues: true` reports every issue of\n * the value — each object member, each list item, every unknown or missing\n * key — instead of stopping at the first.\n */\nexport function parse<const S extends StandardSchemaV1>(\n schema: S,\n value: unknown,\n options?: { readonly allIssues?: boolean | undefined }\n): ParseResult<S>;\nexport function parse(\n schema: StandardSchemaV1,\n value: unknown,\n options?: { readonly allIssues?: boolean | undefined }\n): StandardSchemaV1.Result<unknown> {\n try {\n const result = reportingAllIssues(options?.allIssues === true, () =>\n schema[\"~standard\"].validate(value)\n );\n if (isPromiseLike(result)) {\n discardAsyncValidationResult(result);\n return asyncValidationFailure;\n }\n if (!isRecord(result)) return malformedValidationFailure;\n\n const issues = Reflect.get(result, \"issues\");\n if (issues !== undefined) {\n return Array.isArray(issues) ? { issues } : malformedValidationFailure;\n }\n if (!(\"value\" in result)) return malformedValidationFailure;\n return { value: Reflect.get(result, \"value\") };\n } catch (cause) {\n return validationFailureFromThrown(cause);\n }\n}\n"],"mappings":"oKASA,MAAa,EAAW,eCoElB,cAAiB,GACd,EAAS,EAAM,EAAI,SAAU,GAAS,EAAW,EAAM,KAAK,CAG/D,EAA4C,CAChD,OAAQ,CAAC,CAAE,QAAS,oCAAqC,CAAC,CAC3D,CAEK,EAAgD,CACpD,OAAQ,CAAC,CAAE,QAAS,gDAAiD,CAAC,CACvE,CAYD,SAAgB,MACd,EACA,EACA,EACkC,CAClC,GAAI,CACF,IAAM,EAAS,EAAmB,GAAS,YAAc,OACvD,EAAO,aAAa,SAAS,EAAM,CACpC,CACD,GAAI,cAAc,EAAO,CAEvB,OADA,EAA6B,EAAO,CAC7B,EAET,GAAI,CAAC,EAAS,EAAO,CAAE,OAAO,EAE9B,IAAM,EAAS,QAAQ,IAAI,EAAQ,SAAS,CAK5C,OAJI,IAAW,IAAA,GAGT,UAAW,EACV,CAAE,MAAO,QAAQ,IAAI,EAAQ,QAAQ,CAAE,CADb,EAFxB,MAAM,QAAQ,EAAO,CAAG,CAAE,SAAQ,CAAG,QAIvC,EAAO,CACd,OAAO,EAA4B,EAAM"}
@@ -1,2 +1,2 @@
1
- import { $ as ModelOperationInput, Ar as BaseBlobSchema, Er as BaseEnumSchema, Fn as V, Fr as toJsonSchema, G as ParseResult, Gi as GeoPolygon, Gr as inferred, Hi as GeoArea, In as v, Ir as createSchemaRegistry, J as SchemaRegistryOperation, K as Prettify, Mr as BaseBigIntSchema, Or as BaseBooleanSchema, Pr as createJsonSchemaConverter, Q as ModelCoreSchemas, Sr as BaseIsoTimestampSchema, U as InferInput, Ui as GeoBounds, W as InferOutput, Wi as GeoPoint, Wr as JsonSchema, X as ModelArgsSchemas, Y as VibSchema, Z as ModelCoreInput, _r as InputJsonValue, at as CoreSchemas, br as BaseIsoDateSchema, dr as ObjectSchema, et as ModelRelationNestedInput, fr as BaseIntegerSchema, gr as BaseJsonSchema, it as ArgsSchemas, lr as BasePointSchema, nt as ModelStateSchemas, or as parse, pr as BaseNumberSchema, q as SchemaRegistryLookup, rt as ScalarSchemas, sr as BaseVectorSchema, tt as ModelSchemas, xr as BaseIsoTimeSchema, yr as JsonValue } from "./index-B_jh2oaQ.mjs";
1
+ import { $ as ModelOperationInput, Ar as BaseBlobSchema, Er as BaseEnumSchema, Fn as V, Fr as toJsonSchema, G as ParseResult, Gi as GeoPolygon, Gr as inferred, Hi as GeoArea, In as v, Ir as createSchemaRegistry, J as SchemaRegistryOperation, K as Prettify, Mr as BaseBigIntSchema, Or as BaseBooleanSchema, Pr as createJsonSchemaConverter, Q as ModelCoreSchemas, Sr as BaseIsoTimestampSchema, U as InferInput, Ui as GeoBounds, W as InferOutput, Wi as GeoPoint, Wr as JsonSchema, X as ModelArgsSchemas, Y as VibSchema, Z as ModelCoreInput, _r as InputJsonValue, at as CoreSchemas, br as BaseIsoDateSchema, dr as ObjectSchema, et as ModelRelationNestedInput, fr as BaseIntegerSchema, gr as BaseJsonSchema, it as ArgsSchemas, lr as BasePointSchema, nt as ModelStateSchemas, or as parse, pr as BaseNumberSchema, q as SchemaRegistryLookup, rt as ScalarSchemas, sr as BaseVectorSchema, tt as ModelSchemas, xr as BaseIsoTimeSchema, yr as JsonValue } from "./index-B4IWFJfv.mjs";
2
2
  export { type ArgsSchemas, type BaseBigIntSchema, type BaseBlobSchema, type BaseBooleanSchema, type BaseEnumSchema, type BaseIntegerSchema, type BaseIsoDateSchema, type BaseIsoTimeSchema, type BaseIsoTimestampSchema, type BaseJsonSchema, type BaseNumberSchema, type BasePointSchema, type BaseVectorSchema, type CoreSchemas, type GeoArea, type GeoBounds, type GeoPoint, type GeoPolygon, type InferInput, type InferOutput, type InputJsonValue, type JsonSchema, type JsonValue, type ModelArgsSchemas, type ModelCoreInput, type ModelCoreSchemas, type ModelOperationInput, type ModelRelationNestedInput, type ModelSchemas, type ModelStateSchemas, type ObjectSchema, type ParseResult, type Prettify, type ScalarSchemas, type SchemaRegistryLookup, type SchemaRegistryOperation, type V, type VibSchema, createJsonSchemaConverter, createSchemaRegistry, v as default, v, inferred, type inferred as inferredType, parse, toJsonSchema };
@@ -1 +1 @@
1
- import{t as e}from"./v-514RME2X.mjs";import{H as t,V as n}from"./geo-point-codec-D95uXgDF.mjs";import{n as r}from"./builder-D6Ug-zjM.mjs";import{n as i,t as a}from"./validation-CPnrLcjW.mjs";export{n as createJsonSchemaConverter,r as createSchemaRegistry,e as default,e as v,i as inferred,a as parse,t as toJsonSchema};
1
+ import{t as e}from"./v-514RME2X.mjs";import{H as t,V as n}from"./geo-point-codec-D95uXgDF.mjs";import{n as r}from"./builder-BS8EW4BQ.mjs";import{n as i,t as a}from"./validation-C7Z6wTJa.mjs";export{n as createJsonSchemaConverter,r as createSchemaRegistry,e as default,e as v,i as inferred,a as parse,t as toJsonSchema};
@@ -0,0 +1,2 @@
1
+ const e=`1.4.0`;export{e as t};
2
+ //# sourceMappingURL=version-n393hhwM.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"version-0RVYpih5.mjs","names":["packageMetadata.version"],"sources":["../package.json","../src/version.ts"],"sourcesContent":["","import packageMetadata from \"../package.json\";\n\n/** Package version shared by runtime surfaces and bundled from package.json. */\nexport const VIBORM_VERSION = packageMetadata.version;\n"],"mappings":"ACGA,MAAa"}
1
+ {"version":3,"file":"version-n393hhwM.mjs","names":["packageMetadata.version"],"sources":["../package.json","../src/version.ts"],"sourcesContent":["","import packageMetadata from \"../package.json\";\n\n/** Package version shared by runtime surfaces and bundled from package.json. */\nexport const VIBORM_VERSION = packageMetadata.version;\n"],"mappings":"ACGA,MAAa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viborm",
3
- "version": "1.3.3",
3
+ "version": "1.4.0",
4
4
  "description": "Type-safe ORM for PostgreSQL, MySQL, and SQLite with a Prisma-inspired API",
5
5
  "repository": {
6
6
  "type": "git",
@@ -330,7 +330,7 @@
330
330
  "valibot": "^1.2.0",
331
331
  "vitest": "^3.1.4",
332
332
  "wrangler": "4.44.0",
333
- "zod": "^4.6.5"
333
+ "zod": "^4.6.7"
334
334
  },
335
335
  "engines": {
336
336
  "node": ">=22"
@@ -390,29 +390,29 @@
390
390
  "name": "D1 Worker (viborm/d1)",
391
391
  "path": "node_modules/.cache/viborm-size/d1-worker.mjs",
392
392
  "gzip": true,
393
- "limit": "183.6 kB",
394
- "message": "Raised 170 → 171.9 kB by the measured +1,868 B of RBAC M1 wave 1 (OD-17): rows predicates admitted, layered and parameterized, numbered binds, bound views. Raised 171.9 → 177.6 kB by the measured +5,630 B (177.29 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 177.6 → 179 kB by the measured +1,355 B (178.65 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 179 → 179.7 kB by the measured 179.37 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated) (OD-17, measured rounded up to 0.1 kB + 0.3 kB). Permissions application reuse (2026-10-18) measures 179,947 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 182,905 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.3 (2026-10-19) measures 183,229 B: to-one relation ordering through one LEFT JOIN, the mixed-direction cursor bound, outer-reference chains joined into one EXISTS, merged quantifiers, shared bodies in located lookups, the NOT MATERIALIZED spelling, the upsert refusal's cause; schema validation rules no longer kept (-1.65 kB). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
393
+ "limit": "194.5 kB",
394
+ "message": "Raised 170 → 171.9 kB by the measured +1,868 B of RBAC M1 wave 1 (OD-17): rows predicates admitted, layered and parameterized, numbered binds, bound views. Raised 171.9 → 177.6 kB by the measured +5,630 B (177.29 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 177.6 → 179 kB by the measured +1,355 B (178.65 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 179 → 179.7 kB by the measured 179.37 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated) (OD-17, measured rounded up to 0.1 kB + 0.3 kB). Permissions application reuse (2026-10-18) measures 179,947 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 182,905 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.3 (2026-10-19) measures 183,229 B: to-one relation ordering through one LEFT JOIN, the mixed-direction cursor bound, outer-reference chains joined into one EXISTS, merged quantifiers, shared bodies in located lookups, the NOT MATERIALIZED spelling, the upsert refusal's cause; schema validation rules no longer kept (-1.65 kB). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.4.0 (2026-10-20) measures 187,904 B: writes answering relation projections in their own statement, findUnique batching (+1.75 kB), the undefined bulk-where refusal and $extends result computed fields (+2.2 kB), SQLite AS MATERIALIZED nested bodies, single-window distinct, junction-joined many-to-many filters on SQLite. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Neki relation budget (2026-10-21) measures 191,623 B: recursive walks carrying the columns their next hop reads, and past 256 relations a statement's repeated walks as one reaching set and rows joined to the key sets they test, one-column sets held as PostgreSQL arrays (relationsPerStatement: stated, or 256 where a PostgreSQL driver reads Neki from its first connection's startup or first refusal; D1 256). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Nested-write round trips (2026-10-22) measures 192,646 B: a nested write answering its result out of its root statement, a nested root update locating its row in its own UPDATE, and an upsert probe holding the row it finds on PostgreSQL (locksMissingKeys). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. To-many targets read together (2026-10-22) measures 193,276 B: a to-many connect or set reading its targets in one statement and linking them in one INSERT (Selection.rows, linkMany). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Shared connect UPDATEs and batched planning reads (2026-10-23) measure 194,142 B: reference-side connect and set targets moved by one UPDATE (updateRows), and on D1 and Neon HTTP a nested write’s planning lookups read in one read-only batch (readTogether). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
395
395
  },
396
396
  {
397
397
  "name": "pg + migrations Worker (viborm/pg + viborm/migrations/postgres)",
398
398
  "path": "node_modules/.cache/viborm-size/pg-migrations-worker.mjs",
399
399
  "gzip": true,
400
- "limit": "287 kB",
401
- "message": "Raised 273 → 274.4 kB by the measured +1,392 B of RBAC M1 wave 2 (K3, OD-17): rows verbs, written fields, write judgements and the clear premise; it held wave 1's +1,819 B inside its headroom. Raised 274.4 → 279.5 kB by the measured +5,720 B (279.12 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 279.5 → 280.8 kB by the measured +1,340 B (280.46 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 280.8 → 281.6 kB by the measured 281.27 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated), and createClient forwarding sharedRelationBodies (ENG-5) (OD-17, measured rounded up to 0.1 kB + 0.3 kB). Permissions application reuse (2026-10-18) measures 281,876 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 284,679 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.3 (2026-10-19) measures 286,646 B: to-one relation ordering through one LEFT JOIN, the mixed-direction cursor bound, outer-reference chains joined into one EXISTS, merged quantifiers, shared bodies in located lookups, the NOT MATERIALIZED spelling, the upsert refusal's cause. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
400
+ "limit": "300.3 kB",
401
+ "message": "Raised 273 → 274.4 kB by the measured +1,392 B of RBAC M1 wave 2 (K3, OD-17): rows verbs, written fields, write judgements and the clear premise; it held wave 1's +1,819 B inside its headroom. Raised 274.4 → 279.5 kB by the measured +5,720 B (279.12 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 279.5 → 280.8 kB by the measured +1,340 B (280.46 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 280.8 → 281.6 kB by the measured 281.27 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated), and createClient forwarding sharedRelationBodies (ENG-5) (OD-17, measured rounded up to 0.1 kB + 0.3 kB). Permissions application reuse (2026-10-18) measures 281,876 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 284,679 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.3 (2026-10-19) measures 286,646 B: to-one relation ordering through one LEFT JOIN, the mixed-direction cursor bound, outer-reference chains joined into one EXISTS, merged quantifiers, shared bodies in located lookups, the NOT MATERIALIZED spelling, the upsert refusal's cause. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.4.0 (2026-10-20) measures 291,400 B: writes answering relation projections in their own statement, findUnique batching (+1.75 kB), the undefined bulk-where refusal and $extends result computed fields (+2.2 kB), SQLite AS MATERIALIZED nested bodies, single-window distinct, junction-joined many-to-many filters on SQLite. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Neki relation budget (2026-10-21) measures 295,514 B: recursive walks carrying the columns their next hop reads, and past 256 relations a statement's repeated walks as one reaching set and rows joined to the key sets they test, one-column sets held as PostgreSQL arrays (relationsPerStatement: stated, or 256 where a PostgreSQL driver reads Neki from its first connection's startup or first refusal; D1 256). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Nested-write round trips (2026-10-22) measures 296,563 B: a nested write answering its result out of its root statement, a nested root update locating its row in its own UPDATE, and an upsert probe holding the row it finds on PostgreSQL (locksMissingKeys). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. To-many targets read together (2026-10-22) measures 297,199 B: a to-many connect or set reading its targets in one statement and linking them in one INSERT (Selection.rows, linkMany). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Incremental snapshot artifacts (2026-10-22) measure 298,985 B after two bundle-reduction reviews. Owner-approved limit follows rounding up to 0.1 kB plus 0.3 kB headroom; other resource and coverage limits are unchanged. Final prune-review fixes measure 299,039 B and remain within that approved limit. Shared connect UPDATEs and batched planning reads (2026-10-23) measure 298,088 B: reference-side connect and set targets moved by one UPDATE (updateRows), and on D1 and Neon HTTP a nested write’s planning lookups read in one read-only batch (readTogether). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Incremental snapshot artifacts merged with shared connect UPDATEs and batched planning reads (2026-10-23) measure 299,920 B together. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
402
402
  },
403
403
  {
404
404
  "name": "pg application (viborm/pg)",
405
405
  "path": "node_modules/.cache/viborm-size/pg-representative.mjs",
406
406
  "gzip": true,
407
- "limit": "184.1 kB",
408
- "message": "Raised 170 → 171.9 kB by the measured +1,900 B of RBAC M1 wave 1 (OD-17): rows predicates admitted, layered and parameterized, numbered binds, bound views. Raised 171.9 → 173.34 kB by the measured +1,440 B of RBAC M1 wave 2 (K3, OD-17): rows verbs, written fields, write judgements and the clear premise. Raised 173.34 → 178.2 kB by the measured +5,650 B (177.84 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 178.2 → 179.5 kB by the measured +1,278 B (179.12 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 179.5 → 180.3 kB by the measured 179.99 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated), and createClient forwarding sharedRelationBodies (ENG-5) (OD-17, measured rounded up to 0.1 kB + 0.3 kB). Permissions application reuse (2026-10-18) measures 180,567 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 183,392 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.3 (2026-10-19) measures 183,719 B: to-one relation ordering through one LEFT JOIN, the mixed-direction cursor bound, outer-reference chains joined into one EXISTS, merged quantifiers, shared bodies in located lookups, the NOT MATERIALIZED spelling, the upsert refusal's cause; schema validation rules no longer kept (-1.65 kB). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
407
+ "limit": "195.4 kB",
408
+ "message": "Raised 170 → 171.9 kB by the measured +1,900 B of RBAC M1 wave 1 (OD-17): rows predicates admitted, layered and parameterized, numbered binds, bound views. Raised 171.9 → 173.34 kB by the measured +1,440 B of RBAC M1 wave 2 (K3, OD-17): rows verbs, written fields, write judgements and the clear premise. Raised 173.34 → 178.2 kB by the measured +5,650 B (177.84 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 178.2 → 179.5 kB by the measured +1,278 B (179.12 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 179.5 → 180.3 kB by the measured 179.99 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated), and createClient forwarding sharedRelationBodies (ENG-5) (OD-17, measured rounded up to 0.1 kB + 0.3 kB). Permissions application reuse (2026-10-18) measures 180,567 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 183,392 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.3 (2026-10-19) measures 183,719 B: to-one relation ordering through one LEFT JOIN, the mixed-direction cursor bound, outer-reference chains joined into one EXISTS, merged quantifiers, shared bodies in located lookups, the NOT MATERIALIZED spelling, the upsert refusal's cause; schema validation rules no longer kept (-1.65 kB). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.4.0 (2026-10-20) measures 188,385 B: writes answering relation projections in their own statement, findUnique batching (+1.75 kB), the undefined bulk-where refusal and $extends result computed fields (+2.2 kB), SQLite AS MATERIALIZED nested bodies, single-window distinct, junction-joined many-to-many filters on SQLite. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Neki relation budget (2026-10-21) measures 192,547 B: recursive walks carrying the columns their next hop reads, and past 256 relations a statement's repeated walks as one reaching set and rows joined to the key sets they test, one-column sets held as PostgreSQL arrays (relationsPerStatement: stated, or 256 where a PostgreSQL driver reads Neki from its first connection's startup or first refusal; D1 256). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Nested-write round trips (2026-10-22) measures 193,572 B: a nested write answering its result out of its root statement, a nested root update locating its row in its own UPDATE, and an upsert probe holding the row it finds on PostgreSQL (locksMissingKeys). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. To-many targets read together (2026-10-22) measures 194,198 B: a to-many connect or set reading its targets in one statement and linking them in one INSERT (Selection.rows, linkMany). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Shared connect UPDATEs and batched planning reads (2026-10-23) measure 195,084 B: reference-side connect and set targets moved by one UPDATE (updateRows), and on D1 and Neon HTTP a nested write’s planning lookups read in one read-only batch (readTogether). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
409
409
  },
410
410
  {
411
411
  "name": "pg application + soft delete",
412
412
  "path": "node_modules/.cache/viborm-size/pg-soft-delete.mjs",
413
413
  "gzip": true,
414
- "limit": "184.5 kB",
415
- "message": "Raised 173.5 → 178.6 kB by the measured +5,670 B (178.24 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 178.6 → 179.9 kB by the measured +1,270 B (179.51 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 179.9 → 180.7 kB by the measured 180.39 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated), createClient forwarding sharedRelationBodies (ENG-5), and soft delete's module-level steps (COST-1, COST-2) (OD-17, measured rounded up to 0.1 kB + 0.3 kB). Permissions application reuse (2026-10-18) measures 180,978 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 183,799 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.3 (2026-10-19) measures 184,116 B: to-one relation ordering through one LEFT JOIN, the mixed-direction cursor bound, outer-reference chains joined into one EXISTS, merged quantifiers, shared bodies in located lookups, the NOT MATERIALIZED spelling, the upsert refusal's cause; schema validation rules no longer kept (-1.65 kB). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
414
+ "limit": "195.8 kB",
415
+ "message": "Raised 173.5 → 178.6 kB by the measured +5,670 B (178.24 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 178.6 → 179.9 kB by the measured +1,270 B (179.51 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 179.9 → 180.7 kB by the measured 180.39 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated), createClient forwarding sharedRelationBodies (ENG-5), and soft delete's module-level steps (COST-1, COST-2) (OD-17, measured rounded up to 0.1 kB + 0.3 kB). Permissions application reuse (2026-10-18) measures 180,978 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 183,799 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.3 (2026-10-19) measures 184,116 B: to-one relation ordering through one LEFT JOIN, the mixed-direction cursor bound, outer-reference chains joined into one EXISTS, merged quantifiers, shared bodies in located lookups, the NOT MATERIALIZED spelling, the upsert refusal's cause; schema validation rules no longer kept (-1.65 kB). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.4.0 (2026-10-20) measures 188,764 B: writes answering relation projections in their own statement, findUnique batching (+1.75 kB), the undefined bulk-where refusal and $extends result computed fields (+2.2 kB), SQLite AS MATERIALIZED nested bodies, single-window distinct, junction-joined many-to-many filters on SQLite. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Neki relation budget (2026-10-21) measures 192,936 B: recursive walks carrying the columns their next hop reads, and past 256 relations a statement's repeated walks as one reaching set and rows joined to the key sets they test, one-column sets held as PostgreSQL arrays (relationsPerStatement: stated, or 256 where a PostgreSQL driver reads Neki from its first connection's startup or first refusal; D1 256). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Nested-write round trips (2026-10-22) measures 193,977 B: a nested write answering its result out of its root statement, a nested root update locating its row in its own UPDATE, and an upsert probe holding the row it finds on PostgreSQL (locksMissingKeys). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. To-many targets read together (2026-10-22) measures 194,609 B: a to-many connect or set reading its targets in one statement and linking them in one INSERT (Selection.rows, linkMany). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Shared connect UPDATEs and batched planning reads (2026-10-23) measure 195,500 B: reference-side connect and set targets moved by one UPDATE (updateRows), and on D1 and Neon HTTP a nested write’s planning lookups read in one read-only batch (readTogether). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
416
416
  },
417
417
  {
418
418
  "name": "soft-delete extension entry",
@@ -425,8 +425,8 @@
425
425
  "name": "pg application + permissions",
426
426
  "path": "node_modules/.cache/viborm-size/pg-permissions.mjs",
427
427
  "gzip": true,
428
- "limit": "197 kB",
429
- "message": "The pg application with viborm/permissions applied (the guide's blog policy: an actor schema, an explicit authorId predicate and an actor condition, $as per request, one read, one create, one can): measured 184,652 B at the M2 exit (wave 5), +5,534 B over the pg application row (the entry's compiler with placement, moves, acyclic relations and evidence, can/assert through $access). First measured 181,404 B at c7d1951cd (U10). Limit = measured rounded up to 0.1 kB + 0.3 kB (OD-17). Raised 185 → 185.8 kB by the measured +488 B (185.49 kB) of the independent review's fixes (2026-10-16): refusals of unknown policy, model and field-entry keys, mistyped declaration keys, keyLimit models and undeclared ceilings; can/assert over findUnique with one ask per level; the prover's structural equality and R6 safeguard (OD-17). Comma-separated action keys measure 185,861 B (2026-10-16): normalized bindings and rejection of empty, repeated, overlapping and reserved members. Limit 186.2 kB follows the same rounding plus 0.3 kB rule (OD-17). CRUD permissions and complementary credential scopes measure 186,347 B (2026-10-17); limit 186.7 kB follows the approved measured rounding plus 0.3 kB rule (OD-17). Conditional parameter-read preservation and the permissions rename measure 187,685 B (2026-10-17), +1,338 B from the last recorded application measurement; limit 188 kB follows OD-17 rounding plus 0.3 kB. The simplifier preserves missing/null and whole-list refusals while retaining compact inherited predicates. Raised by the second review's fixes (2026-10-17: typed VALUES rows for judged inserts, caller-text runs in shared-body keys, isolated nesting levels on D1), measured 188.19 kB after the permissions rename; limit = measured rounded up to 0.1 kB + 0.3 kB (OD-17). Actor admission and polymorphic projection consistency (2026-10-18) measure 189,787 B: required native actor validation, per-grant availability and variant projection admission. Limit follows OD-17 rounding to 0.1 kB plus 0.3 kB. Permissions application reuse (2026-10-18) measures 190,939 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Cold compilation sharing (2026-10-18) measures 191,498 B: compilation-local structural keys and shared guards in the policy simplifier, and admission that parses and walks each shared sub-predicate once. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 196,216 B: per-model compilation (the policy compiler, the declaration snapshot, frozen lazy entries), $exists and { $row, up } in rules, and the refusal of field references and empty actor conditions. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.3 (2026-10-19) measures 196,634 B: to-one relation ordering through one LEFT JOIN, the mixed-direction cursor bound, outer-reference chains joined into one EXISTS, merged quantifiers, shared bodies in located lookups, the NOT MATERIALIZED spelling, the upsert refusal's cause; schema validation rules no longer kept (-1.65 kB). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
428
+ "limit": "208.4 kB",
429
+ "message": "The pg application with viborm/permissions applied (the guide's blog policy: an actor schema, an explicit authorId predicate and an actor condition, $as per request, one read, one create, one can): measured 184,652 B at the M2 exit (wave 5), +5,534 B over the pg application row (the entry's compiler with placement, moves, acyclic relations and evidence, can/assert through $access). First measured 181,404 B at c7d1951cd (U10). Limit = measured rounded up to 0.1 kB + 0.3 kB (OD-17). Raised 185 → 185.8 kB by the measured +488 B (185.49 kB) of the independent review's fixes (2026-10-16): refusals of unknown policy, model and field-entry keys, mistyped declaration keys, keyLimit models and undeclared ceilings; can/assert over findUnique with one ask per level; the prover's structural equality and R6 safeguard (OD-17). Comma-separated action keys measure 185,861 B (2026-10-16): normalized bindings and rejection of empty, repeated, overlapping and reserved members. Limit 186.2 kB follows the same rounding plus 0.3 kB rule (OD-17). CRUD permissions and complementary credential scopes measure 186,347 B (2026-10-17); limit 186.7 kB follows the approved measured rounding plus 0.3 kB rule (OD-17). Conditional parameter-read preservation and the permissions rename measure 187,685 B (2026-10-17), +1,338 B from the last recorded application measurement; limit 188 kB follows OD-17 rounding plus 0.3 kB. The simplifier preserves missing/null and whole-list refusals while retaining compact inherited predicates. Raised by the second review's fixes (2026-10-17: typed VALUES rows for judged inserts, caller-text runs in shared-body keys, isolated nesting levels on D1), measured 188.19 kB after the permissions rename; limit = measured rounded up to 0.1 kB + 0.3 kB (OD-17). Actor admission and polymorphic projection consistency (2026-10-18) measure 189,787 B: required native actor validation, per-grant availability and variant projection admission. Limit follows OD-17 rounding to 0.1 kB plus 0.3 kB. Permissions application reuse (2026-10-18) measures 190,939 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Cold compilation sharing (2026-10-18) measures 191,498 B: compilation-local structural keys and shared guards in the policy simplifier, and admission that parses and walks each shared sub-predicate once. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 196,216 B: per-model compilation (the policy compiler, the declaration snapshot, frozen lazy entries), $exists and { $row, up } in rules, and the refusal of field references and empty actor conditions. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.3 (2026-10-19) measures 196,634 B: to-one relation ordering through one LEFT JOIN, the mixed-direction cursor bound, outer-reference chains joined into one EXISTS, merged quantifiers, shared bodies in located lookups, the NOT MATERIALIZED spelling, the upsert refusal's cause; schema validation rules no longer kept (-1.65 kB). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.4.0 (2026-10-20) measures 201,329 B: writes answering relation projections in their own statement, findUnique batching (+1.75 kB), the undefined bulk-where refusal and $extends result computed fields (+2.2 kB), SQLite AS MATERIALIZED nested bodies, single-window distinct, junction-joined many-to-many filters on SQLite. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Neki relation budget (2026-10-21) measures 205,450 B: recursive walks carrying the columns their next hop reads, and past 256 relations a statement's repeated walks as one reaching set and rows joined to the key sets they test, one-column sets held as PostgreSQL arrays (relationsPerStatement: stated, or 256 where a PostgreSQL driver reads Neki from its first connection's startup or first refusal; D1 256). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Nested-write round trips (2026-10-22) measures 206,535 B: a nested write answering its result out of its root statement, a nested root update locating its row in its own UPDATE, and an upsert probe holding the row it finds on PostgreSQL (locksMissingKeys). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. To-many targets read together (2026-10-22) measures 207,162 B: a to-many connect or set reading its targets in one statement and linking them in one INSERT (Selection.rows, linkMany). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Shared connect UPDATEs and batched planning reads (2026-10-23) measure 208,063 B: reference-side connect and set targets moved by one UPDATE (updateRows), and on D1 and Neon HTTP a nested write’s planning lookups read in one read-only batch (readTogether). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
430
430
  },
431
431
  {
432
432
  "name": "permissions extension entry",
@@ -451,8 +451,8 @@
451
451
  "name": "every public entry",
452
452
  "path": "node_modules/.cache/viborm-size/full.mjs",
453
453
  "gzip": true,
454
- "limit": "418.4 kB",
455
- "message": "Raised 394 → 398.1 kB by the measured +5,700 B (397.74 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 398.1 → 405.9 kB by the measured +7,818 B (405.56 kB) of RBAC M2 wave 5: the fixture now exports viborm/rbac (U10), the entry's placement, moves and evidence (U9), and the core growth of E5 and OD-10 (OD-17, measured + 0.3 kB headroom). Raised 405.9 → 406.9 kB by the measured +692 B (406.59 kB) of the independent review's fixes (2026-10-16): the rbac entry's refusals and prover fixes, and the marker judgement in core (OD-17). The permissions rename and conditional-read simplification fixes measure 407,193 B (2026-10-17); limit 407.5 kB follows OD-17 rounding plus 0.3 kB. Raised by the second review's fixes (2026-10-17: typed VALUES rows for judged inserts, caller-text runs in shared-body keys, isolated nesting levels on D1), measured 407.81 kB after the permissions rename; limit = measured rounded up to 0.1 kB + 0.3 kB (OD-17). Actor admission and polymorphic projection consistency (2026-10-18) measure 409,474 B; limit follows OD-17 rounding to 0.1 kB plus 0.3 kB. Permissions application reuse (2026-10-18) measures 410,754 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Cold compilation sharing (2026-10-18) measures 411,254 B: compilation-local structural keys and shared guards in the policy simplifier, and admission that parses and walks each shared sub-predicate once. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 415,968 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.3 (2026-10-19) measures 418,009 B: to-one relation ordering through one LEFT JOIN, the mixed-direction cursor bound, outer-reference chains joined into one EXISTS, merged quantifiers, shared bodies in located lookups, the NOT MATERIALIZED spelling, the upsert refusal's cause; schema validation rules no longer kept (-1.65 kB). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
454
+ "limit": "431.8 kB",
455
+ "message": "Raised 394 → 398.1 kB by the measured +5,700 B (397.74 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 398.1 → 405.9 kB by the measured +7,818 B (405.56 kB) of RBAC M2 wave 5: the fixture now exports viborm/rbac (U10), the entry's placement, moves and evidence (U9), and the core growth of E5 and OD-10 (OD-17, measured + 0.3 kB headroom). Raised 405.9 → 406.9 kB by the measured +692 B (406.59 kB) of the independent review's fixes (2026-10-16): the rbac entry's refusals and prover fixes, and the marker judgement in core (OD-17). The permissions rename and conditional-read simplification fixes measure 407,193 B (2026-10-17); limit 407.5 kB follows OD-17 rounding plus 0.3 kB. Raised by the second review's fixes (2026-10-17: typed VALUES rows for judged inserts, caller-text runs in shared-body keys, isolated nesting levels on D1), measured 407.81 kB after the permissions rename; limit = measured rounded up to 0.1 kB + 0.3 kB (OD-17). Actor admission and polymorphic projection consistency (2026-10-18) measure 409,474 B; limit follows OD-17 rounding to 0.1 kB plus 0.3 kB. Permissions application reuse (2026-10-18) measures 410,754 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Cold compilation sharing (2026-10-18) measures 411,254 B: compilation-local structural keys and shared guards in the policy simplifier, and admission that parses and walks each shared sub-predicate once. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 415,968 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.3 (2026-10-19) measures 418,009 B: to-one relation ordering through one LEFT JOIN, the mixed-direction cursor bound, outer-reference chains joined into one EXISTS, merged quantifiers, shared bodies in located lookups, the NOT MATERIALIZED spelling, the upsert refusal's cause; schema validation rules no longer kept (-1.65 kB). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.4.0 (2026-10-20) measures 422,953 B: writes answering relation projections in their own statement, findUnique batching (+1.75 kB), the undefined bulk-where refusal and $extends result computed fields (+2.2 kB), SQLite AS MATERIALIZED nested bodies, single-window distinct, junction-joined many-to-many filters on SQLite. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Neki relation budget (2026-10-21) measures 427,195 B: recursive walks carrying the columns their next hop reads, and past 256 relations a statement's repeated walks as one reaching set and rows joined to the key sets they test, one-column sets held as PostgreSQL arrays (relationsPerStatement: stated, or 256 where a PostgreSQL driver reads Neki from its first connection's startup or first refusal; D1 256). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Nested-write round trips (2026-10-22) measures 428,233 B: a nested write answering its result out of its root statement, a nested root update locating its row in its own UPDATE, and an upsert probe holding the row it finds on PostgreSQL (locksMissingKeys). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. To-many targets read together (2026-10-22) measures 428,889 B: a to-many connect or set reading its targets in one statement and linking them in one INSERT (Selection.rows, linkMany). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Incremental snapshot artifacts (2026-10-22) measure 430,540 B after two bundle-reduction reviews. Owner-approved limit follows rounding up to 0.1 kB plus 0.3 kB headroom; other resource and coverage limits are unchanged. Final prune-review fixes measure 430,609 B and remain within that approved limit. Shared connect UPDATEs and batched planning reads (2026-10-23) measure 429,766 B: reference-side connect and set targets moved by one UPDATE (updateRows), and on D1 and Neon HTTP a nested write’s planning lookups read in one read-only batch (readTogether). Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Incremental snapshot artifacts merged with shared connect UPDATEs and batched planning reads (2026-10-23) measure 431,468 B together. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
456
456
  }
457
457
  ]
458
458
  }
@@ -1,2 +0,0 @@
1
- import{n as e}from"./chunk-BuuaeEvq.mjs";import{r as t}from"./value-guards-CK9guf2Z.mjs";import{n}from"./base-D3m1S7Uc.mjs";import{m as r,p as i}from"./validation-gwZYm3Yn.mjs";import{t as a}from"./sql-BvHwL73I.mjs";const o=typeof Symbol.asyncDispose==`symbol`?Symbol.asyncDispose:void 0,s=Symbol(`viborm.verbatimBatchQuery`);function markVerbatimBatchQuery(e){return Object.defineProperty(e,s,{configurable:!1,enumerable:!1,value:!0,writable:!1}),e}function isVerbatimBatchQuery(e){return Reflect.get(e,s)===!0}const c=new WeakMap;function registerPreparedStatement(e,t){c.set(e,t)}function transferPreparedStatement(e,t){let n=c.get(e);return n!==void 0&&c.set(t,n),t}function snapshotPreparedStatement(e,t,n){let r=c.get(e);return r!==void 0&&c.set(t,new a([...r.strings],[...n])),t}function readPreparedStatement(e){return c.get(e)}const l=/^(?:0|[1-9]\d*)$/;function captureBuiltinPrototype(e){let t=[];for(let n of Reflect.ownKeys(e)){let r=Object.getOwnPropertyDescriptor(e,n);r&&t.push({descriptor:r,key:n})}return Object.freeze(t)}const u=captureBuiltinPrototype(Object.prototype),d=captureBuiltinPrototype(Array.prototype);function isArrayIndex(e){if(typeof e!=`string`||!l.test(e))return!1;let t=Number(e);return t<=4294967294&&String(t)===e}function functionSource(e){if(typeof e==`function`)try{return Function.prototype.toString.call(e)}catch{return}}function sameInertRecord(e,t){if(e===null||t===null||typeof e!=`object`||typeof t!=`object`)return Object.is(e,t);try{if(Object.getPrototypeOf(e)!==null||Object.getPrototypeOf(t)!==null)return!1;let n=Reflect.ownKeys(e),r=Reflect.ownKeys(t);if(n.length!==r.length)return!1;for(let i=0;i<r.length;i+=1){let a=n[i],o=r[i];if(a!==o||o===void 0)return!1;let s=Object.getOwnPropertyDescriptor(e,o),c=Object.getOwnPropertyDescriptor(t,o);if(s===void 0||c===void 0||!(`value`in s)||!(`value`in c)||s.configurable!==c.configurable||s.enumerable!==c.enumerable||s.writable!==c.writable||!Object.is(s.value,c.value))return!1}return!0}catch{return!1}}function sameBuiltinDescriptor(e,t){if(e.configurable!==t.configurable||e.enumerable!==t.enumerable||`value`in e!=`value`in t)return!1;if(`value`in e&&`value`in t){if(e.writable!==t.writable)return!1;let n=functionSource(t.value);return n===void 0?sameInertRecord(e.value,t.value):functionSource(e.value)===n}return functionSource(e.get)===functionSource(t.get)&&functionSource(e.set)===functionSource(t.set)}function hasBuiltinPrototypeShape(e,t){try{let n=Reflect.ownKeys(e);if(n.length!==t.length)return!1;for(let r=0;r<t.length;r+=1){let i=t[r];if(i===void 0||n[r]!==i.key)return!1;let a=Object.getOwnPropertyDescriptor(e,i.key);if(a===void 0||!sameBuiltinDescriptor(a,i.descriptor))return!1}return!0}catch{return!1}}function isObjectPrototype(e){try{return Object.getPrototypeOf(e)===null&&hasBuiltinPrototypeShape(e,u)}catch{return!1}}function isArrayPrototype(e){try{let t=Object.getPrototypeOf(e);return t!==null&&isObjectPrototype(t)&&hasBuiltinPrototypeShape(e,d)}catch{return!1}}function rawParameterNodeShape(e){let t=!1;try{t=Array.isArray(e);let n=Object.getPrototypeOf(e);if(t&&n!==null&&!isArrayPrototype(n)||!t&&n!==null&&!isObjectPrototype(n))return{kind:t?`unsupported-array`:`opaque`};let r=[],i=[];for(let n of Reflect.ownKeys(e)){let a=Object.getOwnPropertyDescriptor(e,n);if(a!==void 0&&(i.push({descriptor:a,key:n}),t?isArrayIndex(n):a.enumerable&&typeof n==`string`)){if(!(`value`in a))return{kind:t?`unsupported-array`:`opaque`};r.push({descriptor:a,key:n,value:a.value})}}let a=i.find(e=>e.key===`toJSON`);return a&&(!(`value`in a.descriptor)||typeof a.descriptor.value==`function`)?{kind:t?`unsupported-array`:`opaque`}:{kind:`node`,shape:{edges:r,isArray:t,properties:i,prototype:n}}}catch{return{kind:t?`unsupported-array`:`opaque`}}}function rawDateTime(e,n,r){if(!t(e))return;let i=Date.prototype.getTime.call(e);if(Number.isNaN(i))throw r(n);return i}function analyzeRawParameterGraph(e,t){let n=new WeakMap,r=new WeakMap,i=[],a=Array(e.length),discover=(e,a)=>{let o=rawDateTime(e,a,t.invalidDate);if(o!==void 0&&typeof e==`object`&&e){r.set(e,o);return}if(typeof e!=`object`||!e)return;let s=n.get(e);if(s)return s;let c=rawParameterNodeShape(e);if(c.kind===`unsupported-array`)throw t.unsupportedArray(a);if(c.kind===`opaque`)return;let l={...c.shape,source:e};return n.set(e,l),i.push(l),l};for(let n=0;n<e.length;n++){if(!Object.hasOwn(e,n))continue;let o=e[n];a[n]=o;let s=rawDateTime(o,n,t.invalidDate);if(s!==void 0&&typeof o==`object`&&o){r.set(o,s);continue}let c=discover(o,n);if(!c)continue;let l=[c],u=0;for(;u<l.length;){let e=l[u];if(u+=1,e)for(let t of e.edges){let e=i.length,r=discover(t.value,n);r&&i.length>e&&l.push(r)}}}return{dateTimes:r,nodes:i,roots:a}}function validateRawParameters(e,t){analyzeRawParameterGraph(e,t)}function snapshotRawParameterGraph(e,t){let n=analyzeRawParameterGraph(e,t),r=new WeakMap,i=new WeakMap;for(let e of n.nodes){let t=e.isArray?[]:{};e.prototype===null&&Object.setPrototypeOf(t,null),r.set(e.source,t)}let copiedValue=e=>{if(typeof e!=`object`||!e)return e;let t=n.dateTimes.get(e);if(t!==void 0){let n=i.get(e);if(n)return n;let r=new Date(t);return i.set(e,r),r}return r.get(e)??e};for(let e of n.nodes){let t=r.get(e.source);if(t){for(let n of e.properties){if(e.isArray&&n.key===`length`)continue;let r=n.descriptor;Object.defineProperty(t,n.key,`value`in r&&(e.isArray?isArrayIndex(n.key):r.enumerable&&typeof n.key==`string`)?{...r,value:copiedValue(r.value)}:r)}if(e.isArray){let n=e.properties.find(e=>e.key===`length`);n&&Object.defineProperty(t,`length`,n.descriptor)}}}let a=Array(n.roots.length);for(let e=0;e<n.roots.length;e++)Object.hasOwn(n.roots,e)&&(a[e]=copiedValue(n.roots[e]));return a}function invalidProviderDateError(e,t){return new i(`Operation "${e.operation??`statement`}" received an invalid Date as bound parameter ${t}. An invalid Date names no instant, so a provider either refuses the statement after dispatch or binds it as null.`,{code:n.INVALID_INPUT,meta:{parameterIndex:t,model:e.model,operation:e.operation,correlationId:e.correlationId}})}function unsupportedProviderArrayError(e,t){return new i(`Operation "${e.operation??`statement`}" received raw array parameter ${t} with custom inherited or accessor behavior. VibORM cannot validate that behavior without invoking caller code before dispatch.`,{code:n.INVALID_INPUT,meta:{parameterIndex:t,model:e.model,operation:e.operation,correlationId:e.correlationId}})}function snapshotProviderParameters(e,t){return t.model===`$raw`?snapshotRawParameterGraph(e,{invalidDate:e=>invalidProviderDateError(t,e),unsupportedArray:e=>unsupportedProviderArrayError(t,e)}):[...e]}function createNormalizedResultMeta(e){return{driver:e.provider,operation:e.operation,...e.model?{model:e.model}:{},...e.correlationId?{correlationId:e.correlationId}:{}}}const f=/^(?:0|[1-9]\d*)$/;function normalizeProviderRowCount(e,t,n){let r=e===null?n?.nullValue:e;if(n?.allowDecimalString===!0&&typeof r==`string`&&f.test(r)&&(r=Number(r)),typeof r!=`number`||!Number.isSafeInteger(r)||r<0)throw new i(`Driver "${t.provider}" returned a malformed row count for operation "${t.operation}".`,{meta:createNormalizedResultMeta(t)});return r}function normalizeProviderInsertId(e,t,n){if(typeof e==`string`){if(!f.test(e))throw malformedInsertId(t);return e===`0`?void 0:BigInt(e)}if(n?.allowNumber===!0&&typeof e==`number`){if(!Number.isSafeInteger(e)||e<0)throw malformedInsertId(t);return e===0?void 0:e}throw malformedInsertId(t)}function malformedInsertId(e){return new i(`Driver "${e.provider}" returned a malformed insert id for operation "${e.operation}".`,{meta:createNormalizedResultMeta(e)})}function malformedNormalizedResult(e,t){let n=t===void 0?``:` at batch result index ${t}`;return new i(`Driver "${e.provider}" returned a malformed normalized result for operation "${e.operation}"${n}; expected { rows: object[], rowCount: safe non-negative integer }.`,{meta:{...createNormalizedResultMeta(e),...t===void 0?{}:{resultIndex:t}}})}function isNormalizedResultRow(e){return typeof e==`object`&&!!e&&Object.prototype.toString.call(e)===`[object Object]`}function hasNormalizedRows(e){if(!Array.isArray(e))return!1;for(let t=0;t<e.length;t+=1)if(!(Object.hasOwn(e,t)&&isNormalizedResultRow(e[t])))return!1;return!0}function assertNormalizedQueryResult(e,t,n){let r=e?.insertId===void 0||typeof e.insertId==`bigint`&&e.insertId>=0n||typeof e.insertId==`number`&&Number.isFinite(e.insertId)&&Number.isSafeInteger(e.insertId)&&e.insertId>=0;if(!(isNormalizedResultRow(e)&&hasNormalizedRows(e.rows))||typeof e.rowCount!=`number`||!Number.isFinite(e.rowCount)||!Number.isSafeInteger(e.rowCount)||e.rowCount<0||!r)throw malformedNormalizedResult(t,n)}function assertNormalizedBatchResults(e,t,n){if(!Array.isArray(e)||e.length!==t){let r=Array.isArray(e)?e.length:0;throw new i(`Driver "${n.provider}" returned ${r} results for operation "${n.operation}"; expected ${t}, one per statement.`,{meta:{...createNormalizedResultMeta(n),expectedStatementCount:t,actualResultCount:r}})}for(let t=0;t<e.length;t+=1)assertNormalizedQueryResult(e[t],n,t)}function normalizedBindParameterLimit(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:void 0}function assertStatementBindParameterCapacity(e,t,n,i){if(!(n===void 0||e.values.length<=n))throw new r(`Driver '${t}' cannot execute this ${i} because one indivisible statement needs ${e.values.length} bound values, above the verified limit of ${n}.`)}export{o as _,createNormalizedResultMeta as a,normalizeProviderRowCount as c,readPreparedStatement as d,registerPreparedStatement as f,markVerbatimBatchQuery as g,isVerbatimBatchQuery as h,assertNormalizedQueryResult as i,snapshotProviderParameters as l,transferPreparedStatement as m,normalizedBindParameterLimit as n,isNormalizedResultRow as o,snapshotPreparedStatement as p,assertNormalizedBatchResults as r,normalizeProviderInsertId as s,assertStatementBindParameterCapacity as t,validateRawParameters as u};
2
- //# sourceMappingURL=bind-parameter-capacity-DiwRmZ1h.mjs.map