@danielfgray/pg-sourcerer 0.2.2 → 0.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 (307) hide show
  1. package/bin/pgsourcerer +2 -0
  2. package/dist/__tests__/fixtures/index.d.ts +15 -0
  3. package/dist/__tests__/fixtures/index.d.ts.map +1 -0
  4. package/dist/__tests__/fixtures/index.js +19 -0
  5. package/dist/__tests__/fixtures/index.js.map +1 -0
  6. package/dist/__tests__/fixtures/introspection.json +40522 -0
  7. package/dist/cli.d.ts +0 -1
  8. package/dist/cli.js +7 -46
  9. package/dist/cli.js.map +1 -1
  10. package/dist/config.d.ts +38 -5
  11. package/dist/config.d.ts.map +1 -1
  12. package/dist/config.js +13 -2
  13. package/dist/config.js.map +1 -1
  14. package/dist/{lib/conjure.d.ts → conjure/index.d.ts} +62 -3
  15. package/dist/conjure/index.d.ts.map +1 -0
  16. package/dist/{lib/conjure.js → conjure/index.js} +124 -3
  17. package/dist/conjure/index.js.map +1 -0
  18. package/dist/conjure/signature.d.ts +85 -0
  19. package/dist/conjure/signature.d.ts.map +1 -0
  20. package/dist/conjure/signature.js +130 -0
  21. package/dist/conjure/signature.js.map +1 -0
  22. package/dist/conjure/types.d.ts +97 -0
  23. package/dist/conjure/types.d.ts.map +1 -0
  24. package/dist/conjure/types.js +206 -0
  25. package/dist/conjure/types.js.map +1 -0
  26. package/dist/errors.d.ts +114 -139
  27. package/dist/errors.d.ts.map +1 -1
  28. package/dist/errors.js +82 -36
  29. package/dist/errors.js.map +1 -1
  30. package/dist/generate.d.ts +45 -46
  31. package/dist/generate.d.ts.map +1 -1
  32. package/dist/generate.js +86 -59
  33. package/dist/generate.js.map +1 -1
  34. package/dist/hex/builder.d.ts +12 -0
  35. package/dist/hex/builder.d.ts.map +1 -0
  36. package/dist/hex/builder.js +64 -0
  37. package/dist/hex/builder.js.map +1 -0
  38. package/dist/hex/ddl.d.ts +53 -0
  39. package/dist/hex/ddl.d.ts.map +1 -0
  40. package/dist/hex/ddl.js +306 -0
  41. package/dist/hex/ddl.js.map +1 -0
  42. package/dist/hex/index.d.ts +105 -0
  43. package/dist/hex/index.d.ts.map +1 -0
  44. package/dist/hex/index.js +81 -0
  45. package/dist/hex/index.js.map +1 -0
  46. package/dist/hex/primitives.d.ts +23 -0
  47. package/dist/hex/primitives.d.ts.map +1 -0
  48. package/dist/hex/primitives.js +38 -0
  49. package/dist/hex/primitives.js.map +1 -0
  50. package/dist/hex/query.d.ts +116 -0
  51. package/dist/hex/query.d.ts.map +1 -0
  52. package/dist/hex/query.js +219 -0
  53. package/dist/hex/query.js.map +1 -0
  54. package/dist/hex/types.d.ts +287 -0
  55. package/dist/hex/types.d.ts.map +1 -0
  56. package/dist/hex/types.js +431 -0
  57. package/dist/hex/types.js.map +1 -0
  58. package/dist/index.d.ts +17 -25
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +33 -44
  61. package/dist/index.js.map +1 -1
  62. package/dist/init.d.ts.map +1 -1
  63. package/dist/init.js +76 -140
  64. package/dist/init.js.map +1 -1
  65. package/dist/ir/extensions/queries.d.ts +6 -6
  66. package/dist/ir/extensions/queries.d.ts.map +1 -1
  67. package/dist/ir/extensions/queries.js +6 -4
  68. package/dist/ir/extensions/queries.js.map +1 -1
  69. package/dist/ir/extensions/schema-builder.d.ts.map +1 -1
  70. package/dist/ir/extensions/schema-builder.js.map +1 -1
  71. package/dist/ir/index.d.ts.map +1 -1
  72. package/dist/ir/index.js.map +1 -1
  73. package/dist/ir/relation-graph.d.ts.map +1 -1
  74. package/dist/ir/relation-graph.js +8 -8
  75. package/dist/ir/relation-graph.js.map +1 -1
  76. package/dist/ir/semantic-ir.d.ts +38 -0
  77. package/dist/ir/semantic-ir.d.ts.map +1 -1
  78. package/dist/ir/semantic-ir.js +50 -2
  79. package/dist/ir/semantic-ir.js.map +1 -1
  80. package/dist/ir/smart-tags.d.ts.map +1 -1
  81. package/dist/ir/smart-tags.js.map +1 -1
  82. package/dist/lib/field-utils.d.ts.map +1 -1
  83. package/dist/lib/field-utils.js +7 -7
  84. package/dist/lib/field-utils.js.map +1 -1
  85. package/dist/lib/join-graph.d.ts +95 -0
  86. package/dist/lib/join-graph.d.ts.map +1 -0
  87. package/dist/lib/join-graph.js +305 -0
  88. package/dist/lib/join-graph.js.map +1 -0
  89. package/dist/lib/picker.d.ts +60 -0
  90. package/dist/lib/picker.d.ts.map +1 -0
  91. package/dist/lib/picker.js +325 -0
  92. package/dist/lib/picker.js.map +1 -0
  93. package/dist/plugins/arktype.d.ts +20 -24
  94. package/dist/plugins/arktype.d.ts.map +1 -1
  95. package/dist/plugins/arktype.js +462 -386
  96. package/dist/plugins/arktype.js.map +1 -1
  97. package/dist/plugins/effect/http.d.ts +7 -0
  98. package/dist/plugins/effect/http.d.ts.map +1 -0
  99. package/dist/plugins/effect/http.js +460 -0
  100. package/dist/plugins/effect/http.js.map +1 -0
  101. package/dist/plugins/effect/index.d.ts +22 -0
  102. package/dist/plugins/effect/index.d.ts.map +1 -0
  103. package/dist/plugins/effect/index.js +65 -0
  104. package/dist/plugins/effect/index.js.map +1 -0
  105. package/dist/plugins/effect/models.d.ts +6 -0
  106. package/dist/plugins/effect/models.d.ts.map +1 -0
  107. package/dist/plugins/effect/models.js +116 -0
  108. package/dist/plugins/effect/models.js.map +1 -0
  109. package/dist/plugins/effect/repos.d.ts +21 -0
  110. package/dist/plugins/effect/repos.d.ts.map +1 -0
  111. package/dist/plugins/effect/repos.js +131 -0
  112. package/dist/plugins/effect/repos.js.map +1 -0
  113. package/dist/plugins/effect/schemas.d.ts +7 -0
  114. package/dist/plugins/effect/schemas.d.ts.map +1 -0
  115. package/dist/plugins/effect/schemas.js +75 -0
  116. package/dist/plugins/effect/schemas.js.map +1 -0
  117. package/dist/plugins/effect/shared.d.ts +116 -0
  118. package/dist/plugins/effect/shared.d.ts.map +1 -0
  119. package/dist/plugins/effect/shared.js +164 -0
  120. package/dist/plugins/effect/shared.js.map +1 -0
  121. package/dist/plugins/http-elysia.d.ts +20 -27
  122. package/dist/plugins/http-elysia.d.ts.map +1 -1
  123. package/dist/plugins/http-elysia.js +350 -475
  124. package/dist/plugins/http-elysia.js.map +1 -1
  125. package/dist/plugins/http-express.d.ts +20 -31
  126. package/dist/plugins/http-express.d.ts.map +1 -1
  127. package/dist/plugins/http-express.js +281 -268
  128. package/dist/plugins/http-express.js.map +1 -1
  129. package/dist/plugins/http-hono.d.ts +17 -33
  130. package/dist/plugins/http-hono.d.ts.map +1 -1
  131. package/dist/plugins/http-hono.js +317 -341
  132. package/dist/plugins/http-hono.js.map +1 -1
  133. package/dist/plugins/http-orpc.d.ts +34 -33
  134. package/dist/plugins/http-orpc.d.ts.map +1 -1
  135. package/dist/plugins/http-orpc.js +345 -257
  136. package/dist/plugins/http-orpc.js.map +1 -1
  137. package/dist/plugins/http-trpc.d.ts +33 -35
  138. package/dist/plugins/http-trpc.d.ts.map +1 -1
  139. package/dist/plugins/http-trpc.js +337 -241
  140. package/dist/plugins/http-trpc.js.map +1 -1
  141. package/dist/plugins/kysely.d.ts +54 -59
  142. package/dist/plugins/kysely.d.ts.map +1 -1
  143. package/dist/plugins/kysely.js +826 -687
  144. package/dist/plugins/kysely.js.map +1 -1
  145. package/dist/plugins/sql-queries.d.ts +38 -44
  146. package/dist/plugins/sql-queries.d.ts.map +1 -1
  147. package/dist/plugins/sql-queries.js +497 -897
  148. package/dist/plugins/sql-queries.js.map +1 -1
  149. package/dist/plugins/types.d.ts +12 -20
  150. package/dist/plugins/types.d.ts.map +1 -1
  151. package/dist/plugins/types.js +84 -227
  152. package/dist/plugins/types.js.map +1 -1
  153. package/dist/plugins/valibot.d.ts +7 -44
  154. package/dist/plugins/valibot.d.ts.map +1 -1
  155. package/dist/plugins/valibot.js +376 -382
  156. package/dist/plugins/valibot.js.map +1 -1
  157. package/dist/plugins/zod.d.ts +20 -24
  158. package/dist/plugins/zod.d.ts.map +1 -1
  159. package/dist/plugins/zod.js +370 -367
  160. package/dist/plugins/zod.js.map +1 -1
  161. package/dist/runtime/emit.d.ts +64 -0
  162. package/dist/runtime/emit.d.ts.map +1 -0
  163. package/dist/runtime/emit.js +445 -0
  164. package/dist/runtime/emit.js.map +1 -0
  165. package/dist/runtime/errors.d.ts +36 -0
  166. package/dist/runtime/errors.d.ts.map +1 -0
  167. package/dist/runtime/errors.js +29 -0
  168. package/dist/runtime/errors.js.map +1 -0
  169. package/dist/runtime/file-assignment.d.ts +161 -0
  170. package/dist/runtime/file-assignment.d.ts.map +1 -0
  171. package/dist/runtime/file-assignment.js +195 -0
  172. package/dist/runtime/file-assignment.js.map +1 -0
  173. package/dist/runtime/orchestrator.d.ts +62 -0
  174. package/dist/runtime/orchestrator.d.ts.map +1 -0
  175. package/dist/runtime/orchestrator.js +99 -0
  176. package/dist/runtime/orchestrator.js.map +1 -0
  177. package/dist/runtime/registry.d.ts +268 -0
  178. package/dist/runtime/registry.d.ts.map +1 -0
  179. package/dist/runtime/registry.js +436 -0
  180. package/dist/runtime/registry.js.map +1 -0
  181. package/dist/runtime/types.d.ts +182 -0
  182. package/dist/runtime/types.d.ts.map +1 -0
  183. package/dist/runtime/types.js +2 -0
  184. package/dist/runtime/types.js.map +1 -0
  185. package/dist/runtime/validation.d.ts +41 -0
  186. package/dist/runtime/validation.d.ts.map +1 -0
  187. package/dist/runtime/validation.js +70 -0
  188. package/dist/runtime/validation.js.map +1 -0
  189. package/dist/services/config-loader.d.ts.map +1 -1
  190. package/dist/services/config-loader.js +15 -6
  191. package/dist/services/config-loader.js.map +1 -1
  192. package/dist/services/config.d.ts +55 -25
  193. package/dist/services/config.d.ts.map +1 -1
  194. package/dist/services/config.js +60 -34
  195. package/dist/services/config.js.map +1 -1
  196. package/dist/services/file-writer.d.ts +3 -3
  197. package/dist/services/file-writer.d.ts.map +1 -1
  198. package/dist/services/file-writer.js +6 -8
  199. package/dist/services/file-writer.js.map +1 -1
  200. package/dist/services/inflection.d.ts +126 -27
  201. package/dist/services/inflection.d.ts.map +1 -1
  202. package/dist/services/inflection.js +300 -72
  203. package/dist/services/inflection.js.map +1 -1
  204. package/dist/services/introspection.d.ts.map +1 -1
  205. package/dist/services/introspection.js +6 -6
  206. package/dist/services/introspection.js.map +1 -1
  207. package/dist/services/ir-builder.d.ts.map +1 -1
  208. package/dist/services/ir-builder.js +73 -77
  209. package/dist/services/ir-builder.js.map +1 -1
  210. package/dist/services/ir.d.ts.map +1 -1
  211. package/dist/services/ir.js.map +1 -1
  212. package/dist/services/pg-types.d.ts.map +1 -1
  213. package/dist/services/pg-types.js +3 -3
  214. package/dist/services/pg-types.js.map +1 -1
  215. package/dist/services/smart-tags-parser.d.ts.map +1 -1
  216. package/dist/services/smart-tags-parser.js +4 -4
  217. package/dist/services/smart-tags-parser.js.map +1 -1
  218. package/dist/services/type-hints.d.ts.map +1 -1
  219. package/dist/services/type-hints.js +1 -1
  220. package/dist/services/type-hints.js.map +1 -1
  221. package/dist/services/user-module-parser.d.ts +46 -0
  222. package/dist/services/user-module-parser.d.ts.map +1 -0
  223. package/dist/services/user-module-parser.js +181 -0
  224. package/dist/services/user-module-parser.js.map +1 -0
  225. package/dist/shared/converters.d.ts +60 -0
  226. package/dist/shared/converters.d.ts.map +1 -0
  227. package/dist/shared/converters.js +168 -0
  228. package/dist/shared/converters.js.map +1 -0
  229. package/dist/shared/query-types.d.ts +95 -0
  230. package/dist/shared/query-types.d.ts.map +1 -0
  231. package/dist/shared/query-types.js +9 -0
  232. package/dist/shared/query-types.js.map +1 -0
  233. package/dist/testing.d.ts +125 -37
  234. package/dist/testing.d.ts.map +1 -1
  235. package/dist/testing.js +134 -42
  236. package/dist/testing.js.map +1 -1
  237. package/dist/user-module.d.ts +86 -0
  238. package/dist/user-module.d.ts.map +1 -0
  239. package/dist/user-module.js +55 -0
  240. package/dist/user-module.js.map +1 -0
  241. package/package.json +10 -6
  242. package/dist/lib/conjure.d.ts.map +0 -1
  243. package/dist/lib/conjure.js.map +0 -1
  244. package/dist/lib/hex.d.ts +0 -119
  245. package/dist/lib/hex.d.ts.map +0 -1
  246. package/dist/lib/hex.js +0 -188
  247. package/dist/lib/hex.js.map +0 -1
  248. package/dist/plugins/effect.d.ts +0 -53
  249. package/dist/plugins/effect.d.ts.map +0 -1
  250. package/dist/plugins/effect.js +0 -1074
  251. package/dist/plugins/effect.js.map +0 -1
  252. package/dist/plugins/kysely/queries.d.ts +0 -92
  253. package/dist/plugins/kysely/queries.d.ts.map +0 -1
  254. package/dist/plugins/kysely/queries.js +0 -1169
  255. package/dist/plugins/kysely/queries.js.map +0 -1
  256. package/dist/plugins/kysely/shared.d.ts +0 -59
  257. package/dist/plugins/kysely/shared.d.ts.map +0 -1
  258. package/dist/plugins/kysely/shared.js +0 -247
  259. package/dist/plugins/kysely/shared.js.map +0 -1
  260. package/dist/plugins/kysely/types.d.ts +0 -22
  261. package/dist/plugins/kysely/types.d.ts.map +0 -1
  262. package/dist/plugins/kysely/types.js +0 -428
  263. package/dist/plugins/kysely/types.js.map +0 -1
  264. package/dist/services/artifact-store.d.ts +0 -65
  265. package/dist/services/artifact-store.d.ts.map +0 -1
  266. package/dist/services/artifact-store.js +0 -57
  267. package/dist/services/artifact-store.js.map +0 -1
  268. package/dist/services/core-providers.d.ts +0 -15
  269. package/dist/services/core-providers.d.ts.map +0 -1
  270. package/dist/services/core-providers.js +0 -23
  271. package/dist/services/core-providers.js.map +0 -1
  272. package/dist/services/emissions.d.ts +0 -103
  273. package/dist/services/emissions.d.ts.map +0 -1
  274. package/dist/services/emissions.js +0 -241
  275. package/dist/services/emissions.js.map +0 -1
  276. package/dist/services/execution.d.ts +0 -35
  277. package/dist/services/execution.d.ts.map +0 -1
  278. package/dist/services/execution.js +0 -86
  279. package/dist/services/execution.js.map +0 -1
  280. package/dist/services/file-builder.d.ts +0 -85
  281. package/dist/services/file-builder.d.ts.map +0 -1
  282. package/dist/services/file-builder.js +0 -112
  283. package/dist/services/file-builder.js.map +0 -1
  284. package/dist/services/plugin-meta.d.ts +0 -33
  285. package/dist/services/plugin-meta.d.ts.map +0 -1
  286. package/dist/services/plugin-meta.js +0 -24
  287. package/dist/services/plugin-meta.js.map +0 -1
  288. package/dist/services/plugin-runner.d.ts +0 -42
  289. package/dist/services/plugin-runner.d.ts.map +0 -1
  290. package/dist/services/plugin-runner.js +0 -84
  291. package/dist/services/plugin-runner.js.map +0 -1
  292. package/dist/services/plugin.d.ts +0 -421
  293. package/dist/services/plugin.d.ts.map +0 -1
  294. package/dist/services/plugin.js +0 -197
  295. package/dist/services/plugin.js.map +0 -1
  296. package/dist/services/resolution.d.ts +0 -38
  297. package/dist/services/resolution.d.ts.map +0 -1
  298. package/dist/services/resolution.js +0 -242
  299. package/dist/services/resolution.js.map +0 -1
  300. package/dist/services/service-registry.d.ts +0 -74
  301. package/dist/services/service-registry.d.ts.map +0 -1
  302. package/dist/services/service-registry.js +0 -61
  303. package/dist/services/service-registry.js.map +0 -1
  304. package/dist/services/symbols.d.ts +0 -144
  305. package/dist/services/symbols.d.ts.map +0 -1
  306. package/dist/services/symbols.js +0 -144
  307. package/dist/services/symbols.js.map +0 -1
@@ -0,0 +1,116 @@
1
+ import type { namedTypes as n } from "ast-types";
2
+ import type { TSTypeKind } from "ast-types/lib/gen/kinds.js";
3
+ import type { QueryDescriptor, ParamDescriptor, ReturnDescriptor } from "../shared/query-types.js";
4
+ /**
5
+ * Template parts extracted from parameterized SQL.
6
+ * Used for generating tagged template literals.
7
+ */
8
+ export interface TemplateParts {
9
+ /** String parts between parameters */
10
+ readonly parts: readonly string[];
11
+ /** Parameter names in order */
12
+ readonly paramNames: readonly string[];
13
+ }
14
+ /**
15
+ * Options for toTaggedTemplate()
16
+ */
17
+ export interface TaggedTemplateOptions {
18
+ /** Type parameter for the tag: sql<User>`...` */
19
+ readonly typeParam?: TSTypeKind;
20
+ /** Custom expression for each param. Default: identifier with param name */
21
+ readonly paramExpr?: (name: string) => n.Expression;
22
+ }
23
+ /**
24
+ * Options for toParameterizedCall()
25
+ */
26
+ export interface ParameterizedCallOptions {
27
+ /** Type parameter for the call: pool.query<User>(...) */
28
+ readonly typeParam?: TSTypeKind;
29
+ /** Custom expression for each param. Default: identifier with param name */
30
+ readonly paramExpr?: (name: string) => n.Expression;
31
+ }
32
+ /**
33
+ * Query object - wraps a QueryDescriptor with AST rendering methods.
34
+ *
35
+ * This is the primary interface for plugins working with SQL queries.
36
+ * Use `hex.select()` or `hex.mutate()` to create Query objects.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const query = hex.select(ir, {
41
+ * selects: [{ kind: "star", from: "users" }],
42
+ * from: { kind: "table", table: "users" },
43
+ * where: [{ kind: "equals", column: "users.id", value: { name: "id", pgType: "uuid" } }],
44
+ * })
45
+ *
46
+ * // Access data
47
+ * query.sql // "SELECT users.* FROM users WHERE users.id = $1"
48
+ * query.descriptor // Full QueryDescriptor
49
+ * query.templateParts // { parts: ["SELECT ... WHERE users.id = ", ""], paramNames: ["id"] }
50
+ *
51
+ * // Render to AST
52
+ * query.toTaggedTemplate("sql", { typeParam: types.ref("User") })
53
+ * // → sql<User>`SELECT users.* FROM users WHERE users.id = ${id}`
54
+ * ```
55
+ */
56
+ export declare class Query {
57
+ #private;
58
+ constructor(descriptor: QueryDescriptor);
59
+ /** The parameterized SQL string (with $1, $2, etc.) */
60
+ get sql(): string;
61
+ /** The full QueryDescriptor for advanced access */
62
+ get descriptor(): QueryDescriptor;
63
+ /** Template parts for building tagged templates */
64
+ get templateParts(): TemplateParts;
65
+ /** Parameter descriptors */
66
+ get params(): readonly ParamDescriptor[];
67
+ /** Return descriptor */
68
+ get returns(): ReturnDescriptor;
69
+ /**
70
+ * Render as a tagged template literal: sql<T>`SELECT ... ${id}`
71
+ *
72
+ * @param tag - The tag name (e.g., "sql")
73
+ * @param opts - Optional type parameter and custom param expressions
74
+ *
75
+ * @example
76
+ * query.toTaggedTemplate("sql")
77
+ * // → sql`SELECT * FROM users WHERE id = ${id}`
78
+ *
79
+ * query.toTaggedTemplate("sql", { typeParam: types.ref("User") })
80
+ * // → sql<User>`SELECT * FROM users WHERE id = ${id}`
81
+ *
82
+ * query.toTaggedTemplate("sql", { paramExpr: (name) => conjure.id("params").prop(name).build() })
83
+ * // → sql`SELECT * FROM users WHERE id = ${params.id}`
84
+ */
85
+ toTaggedTemplate(tag: string, opts?: TaggedTemplateOptions): n.TaggedTemplateExpression;
86
+ /**
87
+ * Render as a parameterized call: pool.query<T>("SELECT ...", [id])
88
+ *
89
+ * @param obj - The object to call the method on (e.g., "pool", "db")
90
+ * @param method - The method name (e.g., "query", "execute")
91
+ * @param opts - Optional type parameter and custom param expressions
92
+ *
93
+ * @example
94
+ * query.toParameterizedCall("pool", "query")
95
+ * // → pool.query("SELECT * FROM users WHERE id = $1", [id])
96
+ *
97
+ * query.toParameterizedCall("db", "execute", { typeParam: types.ref("User") })
98
+ * // → db.execute<User>("SELECT * FROM users WHERE id = $1", [id])
99
+ */
100
+ toParameterizedCall(obj: string, method: string, opts?: ParameterizedCallOptions): n.CallExpression;
101
+ /**
102
+ * Build a function type signature for this query.
103
+ *
104
+ * Used in symbol declarations to describe the query function's type.
105
+ *
106
+ * @example
107
+ * query.toSignature()
108
+ * // → (id: string) => Promise<User | null>
109
+ */
110
+ toSignature(): TSTypeKind;
111
+ }
112
+ /**
113
+ * Create a Query object from a QueryDescriptor.
114
+ */
115
+ export declare function createQuery(descriptor: QueryDescriptor): Query;
116
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/hex/query.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,IAAI,CAAC,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,4BAA4B,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAOnG;;;GAGG;AACH,MAAM,WAAW,aAAa;I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AAW,IAAI,UAAU;CA2C1B;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,eAAe,GAAG,KAAK,CAE9D"}
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Hex - Query Object
3
+ *
4
+ * Query class that wraps QueryDescriptor with AST rendering methods.
5
+ */
6
+ import recast from "recast";
7
+ import { conjure, cast } from "../conjure/index.js";
8
+ import { param as sigParam, returns as sigReturns, sig } from "../conjure/signature.js";
9
+ import * as types from "../conjure/types.js";
10
+ const b = recast.types.builders;
11
+ /**
12
+ * Query object - wraps a QueryDescriptor with AST rendering methods.
13
+ *
14
+ * This is the primary interface for plugins working with SQL queries.
15
+ * Use `hex.select()` or `hex.mutate()` to create Query objects.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const query = hex.select(ir, {
20
+ * selects: [{ kind: "star", from: "users" }],
21
+ * from: { kind: "table", table: "users" },
22
+ * where: [{ kind: "equals", column: "users.id", value: { name: "id", pgType: "uuid" } }],
23
+ * })
24
+ *
25
+ * // Access data
26
+ * query.sql // "SELECT users.* FROM users WHERE users.id = $1"
27
+ * query.descriptor // Full QueryDescriptor
28
+ * query.templateParts // { parts: ["SELECT ... WHERE users.id = ", ""], paramNames: ["id"] }
29
+ *
30
+ * // Render to AST
31
+ * query.toTaggedTemplate("sql", { typeParam: types.ref("User") })
32
+ * // → sql<User>`SELECT users.* FROM users WHERE users.id = ${id}`
33
+ * ```
34
+ */
35
+ export class Query {
36
+ #descriptor;
37
+ #templateParts;
38
+ constructor(descriptor) {
39
+ this.#descriptor = descriptor;
40
+ this.#templateParts = this.#extractTemplateParts();
41
+ }
42
+ /** The parameterized SQL string (with $1, $2, etc.) */
43
+ get sql() {
44
+ return this.#descriptor.sql;
45
+ }
46
+ /** The full QueryDescriptor for advanced access */
47
+ get descriptor() {
48
+ return this.#descriptor;
49
+ }
50
+ /** Template parts for building tagged templates */
51
+ get templateParts() {
52
+ return this.#templateParts;
53
+ }
54
+ /** Parameter descriptors */
55
+ get params() {
56
+ return this.#descriptor.params;
57
+ }
58
+ /** Return descriptor */
59
+ get returns() {
60
+ return this.#descriptor.returns;
61
+ }
62
+ /**
63
+ * Extract template parts from parameterized SQL.
64
+ *
65
+ * Converts "SELECT * FROM users WHERE id = $1 AND name = $2"
66
+ * into { parts: ["SELECT * FROM users WHERE id = ", " AND name = ", ""], paramNames: ["id", "name"] }
67
+ */
68
+ #extractTemplateParts() {
69
+ const sql = this.#descriptor.sql;
70
+ const params = this.#descriptor.params;
71
+ // Split on $N placeholders
72
+ const parts = [];
73
+ const paramNames = [];
74
+ // Regex to match $1, $2, etc.
75
+ const regex = /\$(\d+)/g;
76
+ let lastIndex = 0;
77
+ let match;
78
+ while ((match = regex.exec(sql)) !== null) {
79
+ // Add the part before this placeholder
80
+ parts.push(sql.slice(lastIndex, match.index));
81
+ // Get param name by index (1-based)
82
+ const paramIndex = parseInt(match[1], 10) - 1;
83
+ const param = params[paramIndex];
84
+ if (param) {
85
+ paramNames.push(param.name);
86
+ }
87
+ else {
88
+ paramNames.push(`param${paramIndex + 1}`);
89
+ }
90
+ lastIndex = regex.lastIndex;
91
+ }
92
+ // Add the final part after the last placeholder
93
+ parts.push(sql.slice(lastIndex));
94
+ return { parts, paramNames };
95
+ }
96
+ /**
97
+ * Render as a tagged template literal: sql<T>`SELECT ... ${id}`
98
+ *
99
+ * @param tag - The tag name (e.g., "sql")
100
+ * @param opts - Optional type parameter and custom param expressions
101
+ *
102
+ * @example
103
+ * query.toTaggedTemplate("sql")
104
+ * // → sql`SELECT * FROM users WHERE id = ${id}`
105
+ *
106
+ * query.toTaggedTemplate("sql", { typeParam: types.ref("User") })
107
+ * // → sql<User>`SELECT * FROM users WHERE id = ${id}`
108
+ *
109
+ * query.toTaggedTemplate("sql", { paramExpr: (name) => conjure.id("params").prop(name).build() })
110
+ * // → sql`SELECT * FROM users WHERE id = ${params.id}`
111
+ */
112
+ toTaggedTemplate(tag, opts) {
113
+ const { parts, paramNames } = this.#templateParts;
114
+ // Build param expressions
115
+ const expressions = paramNames.map(name => {
116
+ if (opts?.paramExpr) {
117
+ return opts.paramExpr(name);
118
+ }
119
+ return b.identifier(name);
120
+ });
121
+ // Use conjure's taggedTemplate builder
122
+ return conjure.taggedTemplate(tag, parts, expressions, opts?.typeParam ? [opts.typeParam] : undefined);
123
+ }
124
+ /**
125
+ * Render as a parameterized call: pool.query<T>("SELECT ...", [id])
126
+ *
127
+ * @param obj - The object to call the method on (e.g., "pool", "db")
128
+ * @param method - The method name (e.g., "query", "execute")
129
+ * @param opts - Optional type parameter and custom param expressions
130
+ *
131
+ * @example
132
+ * query.toParameterizedCall("pool", "query")
133
+ * // → pool.query("SELECT * FROM users WHERE id = $1", [id])
134
+ *
135
+ * query.toParameterizedCall("db", "execute", { typeParam: types.ref("User") })
136
+ * // → db.execute<User>("SELECT * FROM users WHERE id = $1", [id])
137
+ */
138
+ toParameterizedCall(obj, method, opts) {
139
+ const { paramNames } = this.#templateParts;
140
+ // Build param array expressions
141
+ const paramExprs = paramNames.map(name => {
142
+ if (opts?.paramExpr) {
143
+ return cast.toExpr(opts.paramExpr(name));
144
+ }
145
+ return b.identifier(name);
146
+ });
147
+ // Build the call: obj.method<T>("sql", [params])
148
+ const callee = b.memberExpression(b.identifier(obj), b.identifier(method));
149
+ const args = [
150
+ b.stringLiteral(this.#descriptor.sql),
151
+ b.arrayExpression(paramExprs),
152
+ ];
153
+ const callExpr = b.callExpression(callee, args);
154
+ // Add type parameters if provided
155
+ if (opts?.typeParam) {
156
+ callExpr.typeParameters =
157
+ b.tsTypeParameterInstantiation([opts.typeParam]);
158
+ }
159
+ return callExpr;
160
+ }
161
+ /**
162
+ * Build a function type signature for this query.
163
+ *
164
+ * Used in symbol declarations to describe the query function's type.
165
+ *
166
+ * @example
167
+ * query.toSignature()
168
+ * // → (id: string) => Promise<User | null>
169
+ */
170
+ toSignature() {
171
+ const params = this.#descriptor.params.map(p => {
172
+ const tsType = conjure.ts.fromString(p.tsType);
173
+ const paramType = p.nullable ? types.nullable(tsType) : tsType;
174
+ return sigParam.simple(p.name, paramType);
175
+ });
176
+ // Build return type based on mode
177
+ const { mode, fields } = this.#descriptor.returns;
178
+ let returnType;
179
+ if (mode === "void") {
180
+ returnType = b.tsVoidKeyword();
181
+ }
182
+ else if (mode === "affected") {
183
+ returnType = b.tsNumberKeyword();
184
+ }
185
+ else if (fields.length === 0) {
186
+ returnType = b.tsUnknownKeyword();
187
+ }
188
+ else if (fields.length === 1 && fields[0].name === "*") {
189
+ // SELECT * returns unknown without entity context
190
+ returnType = b.tsUnknownKeyword();
191
+ }
192
+ else {
193
+ // Build object type from fields
194
+ const props = fields.map(f => ({
195
+ name: f.name,
196
+ type: conjure.ts.fromString(f.tsType),
197
+ optional: f.nullable,
198
+ }));
199
+ returnType = conjure.ts.objectType(props);
200
+ }
201
+ // Apply cardinality modifiers
202
+ if (mode === "many") {
203
+ returnType = types.array(returnType);
204
+ }
205
+ else if (mode === "oneOrNone") {
206
+ returnType = types.nullable(returnType);
207
+ }
208
+ // Wrap in Promise for async
209
+ returnType = sigReturns.promise(returnType);
210
+ return sig(params, returnType);
211
+ }
212
+ }
213
+ /**
214
+ * Create a Query object from a QueryDescriptor.
215
+ */
216
+ export function createQuery(descriptor) {
217
+ return new Query(descriptor);
218
+ }
219
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/hex/query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAI5B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,OAAO,IAAI,UAAU,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAC;AAE7C,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,C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8B;QAC9B,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACvC,CAAC;aAAM,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;YAChC,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC1C,CAAC;QAED,4BAA4B;QAC5B,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAE5C,OAAO,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACjC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,UAA2B;IACrD,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,287 @@
1
+ /**
2
+ * Hex - SQL Query Builder Types
3
+ *
4
+ * Type definitions for the declarative query builder API.
5
+ */
6
+ import type { SemanticIR, TableEntity } from "../ir/semantic-ir.js";
7
+ import type { ParamDescriptor, FieldDescriptor } from "../shared/query-types.js";
8
+ export type JoinType = "inner" | "left" | "right" | "full" | "cross" | "cross lateral";
9
+ export interface SelectItem {
10
+ kind: "column" | "expression" | "star" | "lateral";
11
+ from?: string;
12
+ column?: string;
13
+ expr?: string;
14
+ func?: FunctionCall;
15
+ alias?: string;
16
+ }
17
+ export interface FunctionCall {
18
+ name: string;
19
+ args: FunctionArg[];
20
+ filter?: WhereCondition;
21
+ orderBy?: OrderByItem[];
22
+ window?: {
23
+ partitionBy: (string | Expression)[];
24
+ orderBy: OrderByItem[];
25
+ };
26
+ }
27
+ export interface FunctionArg {
28
+ kind: "column" | "star" | "expression" | "all";
29
+ from?: string;
30
+ column?: string;
31
+ expr?: string;
32
+ distinct?: boolean;
33
+ }
34
+ export interface FromItem {
35
+ kind: "table" | "subquery";
36
+ table?: string;
37
+ subquery?: SelectSpec;
38
+ alias?: string;
39
+ }
40
+ export interface JoinItem {
41
+ type: JoinType;
42
+ table: string;
43
+ alias?: string;
44
+ on?: string;
45
+ }
46
+ export interface WhereCondition {
47
+ kind: "equals" | "notEquals" | "greater" | "greaterOrEqual" | "less" | "lessOrEqual" | "isNull" | "isNotNull" | "in" | "notIn" | "like" | "ilike" | "between" | "raw";
48
+ column?: string;
49
+ value?: ParamSpec | string | number | boolean | null;
50
+ values?: (ParamSpec | string | number | boolean)[];
51
+ low?: ParamSpec | string | number;
52
+ high?: ParamSpec | string | number;
53
+ expr?: string;
54
+ subquery?: SelectSpec;
55
+ }
56
+ export interface OrderByItem {
57
+ kind: "column" | "expression" | "param";
58
+ from?: string;
59
+ column?: string;
60
+ expr?: string;
61
+ param?: string;
62
+ direction: "asc" | "desc";
63
+ nulls?: "first" | "last";
64
+ }
65
+ export interface GroupByItem {
66
+ kind: "column" | "expression";
67
+ from?: string;
68
+ column?: string;
69
+ expr?: string;
70
+ }
71
+ export interface HavingCondition {
72
+ kind: "equals" | "notEquals" | "greater" | "greaterOrEqual" | "less" | "lessOrEqual";
73
+ expr: string;
74
+ value: ParamSpec | string | number;
75
+ }
76
+ export interface ParamSpec {
77
+ name: string;
78
+ pgType: string;
79
+ tsType?: string;
80
+ nullable?: boolean;
81
+ }
82
+ export interface CommonTableExpression {
83
+ name: string;
84
+ query: SelectSpec;
85
+ }
86
+ export interface SelectSpec {
87
+ selects: SelectItem[];
88
+ from: FromItem;
89
+ joins?: JoinItem[];
90
+ where?: WhereCondition[];
91
+ orderBy?: OrderByItem[];
92
+ groupBy?: GroupByItem[];
93
+ having?: HavingCondition[];
94
+ limit?: number | ParamSpec;
95
+ offset?: number | ParamSpec;
96
+ with?: CommonTableExpression[];
97
+ }
98
+ export interface MutationSpec {
99
+ kind: "insert" | "update" | "delete" | "upsert";
100
+ table: string;
101
+ alias?: string;
102
+ columns?: {
103
+ column: string;
104
+ value: ParamSpec | Expression | null;
105
+ }[];
106
+ returning?: SelectItem[];
107
+ where?: WhereCondition[];
108
+ }
109
+ export interface Expression {
110
+ kind: "column" | "param" | "value" | "raw" | "subquery";
111
+ from?: string;
112
+ column?: string;
113
+ param?: string;
114
+ value?: string | number | boolean | null;
115
+ expr?: string;
116
+ subquery?: SelectSpec;
117
+ }
118
+ export interface ColumnSpec {
119
+ name: string;
120
+ pgType: string;
121
+ nullable?: boolean;
122
+ hasDefault?: boolean;
123
+ defaultValue?: string;
124
+ isArray?: boolean;
125
+ isIdentity?: boolean;
126
+ generationKind?: "always" | "by default";
127
+ }
128
+ export type IndexMethod = "btree" | "gin" | "gist" | "hash" | "brin" | "spgist";
129
+ export interface IndexSpec {
130
+ name: string;
131
+ columns: string[];
132
+ method?: IndexMethod;
133
+ unique?: boolean;
134
+ isPrimaryKey?: boolean;
135
+ where?: string;
136
+ include?: string[];
137
+ opclass?: Record<string, string>;
138
+ }
139
+ export interface PrimaryKeySpec {
140
+ columns: string[];
141
+ name?: string;
142
+ }
143
+ export interface UniqueConstraintSpec {
144
+ columns: string[];
145
+ name?: string;
146
+ where?: string;
147
+ }
148
+ export interface ExcludeConstraintSpec {
149
+ columns: {
150
+ name: string;
151
+ opclass?: string;
152
+ }[];
153
+ name?: string;
154
+ using?: IndexMethod;
155
+ where?: string;
156
+ }
157
+ export type TableConstraintSpec = {
158
+ kind: "primaryKey";
159
+ columns: string[];
160
+ name?: string;
161
+ } | {
162
+ kind: "unique";
163
+ columns: string[];
164
+ name?: string;
165
+ where?: string;
166
+ } | {
167
+ kind: "exclude";
168
+ elements: {
169
+ column: string;
170
+ opclass?: string;
171
+ }[];
172
+ name?: string;
173
+ };
174
+ export interface ForeignKeySpec {
175
+ columns: string[];
176
+ targetTable: string;
177
+ targetColumns: string[];
178
+ onDelete?: "cascade" | "restrict" | "set null" | "set default";
179
+ onUpdate?: "cascade" | "restrict" | "set null" | "set default";
180
+ name?: string;
181
+ }
182
+ export interface CreateTableSpec {
183
+ table: string;
184
+ schema?: string;
185
+ columns: ColumnSpec[];
186
+ primaryKey?: PrimaryKeySpec;
187
+ constraints?: TableConstraintSpec[];
188
+ indexes?: IndexSpec[];
189
+ foreignKeys?: ForeignKeySpec[];
190
+ ifNotExists?: boolean;
191
+ inherits?: string[];
192
+ like?: {
193
+ table: string;
194
+ including?: string[];
195
+ excluding?: string[];
196
+ };
197
+ }
198
+ export interface AlterTableSpec {
199
+ table: string;
200
+ schema?: string;
201
+ actions: AlterAction[];
202
+ }
203
+ export type AlterAction = {
204
+ kind: "addColumn";
205
+ column: ColumnSpec;
206
+ } | {
207
+ kind: "dropColumn";
208
+ column: string;
209
+ cascade?: boolean;
210
+ } | {
211
+ kind: "alterColumnSetDefault";
212
+ column: string;
213
+ setDefault: string | null;
214
+ } | {
215
+ kind: "alterColumnSetNotNull";
216
+ column: string;
217
+ } | {
218
+ kind: "alterColumnDropNotNull";
219
+ column: string;
220
+ } | {
221
+ kind: "addConstraint";
222
+ constraint: TableConstraintSpec;
223
+ } | {
224
+ kind: "dropConstraint";
225
+ name: string;
226
+ cascade?: boolean;
227
+ } | {
228
+ kind: "addForeignKey";
229
+ foreignKey: ForeignKeySpec;
230
+ } | {
231
+ kind: "dropForeignKey";
232
+ name: string;
233
+ cascade?: boolean;
234
+ } | {
235
+ kind: "renameTo";
236
+ newName: string;
237
+ } | {
238
+ kind: "renameColumn";
239
+ from: string;
240
+ to: string;
241
+ };
242
+ export interface DropSpec {
243
+ kind: "table" | "column" | "constraint" | "index" | "foreignKey" | "schema" | "type" | "function" | "trigger" | "rule";
244
+ name: string;
245
+ schema?: string;
246
+ table?: string;
247
+ ifExists?: boolean;
248
+ cascade?: boolean;
249
+ }
250
+ export interface SchemaInfo {
251
+ schema: string;
252
+ tables: string[];
253
+ enums: string[];
254
+ types: string[];
255
+ functions: string[];
256
+ }
257
+ export interface BuilderState {
258
+ params: ParamDescriptor[];
259
+ paramCounter: number;
260
+ tables: Map<string, TableEntity>;
261
+ enums: Map<string, {
262
+ name: string;
263
+ values: readonly string[];
264
+ }>;
265
+ usedParamNames: Set<string>;
266
+ lateralAliases: Set<string>;
267
+ subqueryAliases: Set<string>;
268
+ }
269
+ export declare function createBuilderState(ir: SemanticIR): BuilderState;
270
+ export declare function resolvePgType(state: BuilderState, column: string, allowLateral?: boolean): string;
271
+ export declare function resolveTsType(state: BuilderState, pgType: string): string;
272
+ export declare function addParam(state: BuilderState, spec: ParamSpec): number;
273
+ export declare function nextPlaceholder(state: BuilderState): string;
274
+ export declare function buildSelectItem(state: BuilderState, item: SelectItem): string;
275
+ export declare function buildFunctionCall(state: BuilderState, call: FunctionCall): string;
276
+ export declare function buildFromClause(state: BuilderState, from: FromItem): string;
277
+ export declare function buildJoinClause(join: JoinItem): string;
278
+ export declare function buildWhereClause(state: BuilderState, conditions: WhereCondition[]): string;
279
+ export declare function buildOrderByClause(orderBy: OrderByItem[]): string;
280
+ export declare function buildGroupByClause(groupBy: GroupByItem[]): string;
281
+ export declare function buildValueOrParam(state: BuilderState, value: ParamSpec | Expression | null): string;
282
+ export declare function buildExpression(state: BuilderState, expr: Expression): string;
283
+ export declare function buildMutationQuery(state: BuilderState, spec: MutationSpec): string;
284
+ export declare function buildSelectQuery(state: BuilderState, spec: SelectSpec): string;
285
+ export declare function inferReturnFields(state: BuilderState, selects: SelectItem[]): FieldDescriptor[];
286
+ export declare function inferExpressionPgType(expr: string): string;
287
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hex/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAEV,eAAe,EAEf,eAAe,EAIhB,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,eAAe,CAAC;AAEvF,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,GAAG,YAAY,GAAG,MAA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