@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,95 @@
1
+ /**
2
+ * Query descriptor types for SQL code generation
3
+ *
4
+ * These types describe SQL queries in a way that plugins can consume
5
+ * to generate typed function wrappers. They are produced by `hex` (the SQL
6
+ * template builder) and consumed by query plugins.
7
+ */
8
+ /**
9
+ * Complete description of a generated query.
10
+ *
11
+ * This is the primary type that `hex.build()` produces and query plugins consume.
12
+ */
13
+ export interface QueryDescriptor {
14
+ /** Function name, e.g., "findUserById", "insertUser" */
15
+ readonly name: string;
16
+ /** Entity this query operates on, e.g., "User" */
17
+ readonly entityName: string;
18
+ /** SQL operation type */
19
+ readonly operation: QueryOperation;
20
+ /** Lookup variant, e.g., "byId", "byEmail" (for distinguishing similar queries) */
21
+ readonly variant?: string;
22
+ /** SQL template with positional parameters ($1, $2, etc.) */
23
+ readonly sql: string;
24
+ /** Input parameters */
25
+ readonly params: readonly ParamDescriptor[];
26
+ /** Return type description */
27
+ readonly returns: ReturnDescriptor;
28
+ /** Optional metadata for advanced use cases */
29
+ readonly meta?: QueryMetadata;
30
+ }
31
+ /**
32
+ * Describes a single query parameter.
33
+ */
34
+ export interface ParamDescriptor {
35
+ /** Parameter name, e.g., "id", "email" */
36
+ readonly name: string;
37
+ /** TypeScript type string, e.g., "string", "number", "string | null" */
38
+ readonly tsType: string;
39
+ /** PostgreSQL type, e.g., "uuid", "text", "integer" */
40
+ readonly pgType: string;
41
+ /** Whether the parameter accepts null */
42
+ readonly nullable: boolean;
43
+ /** Whether the parameter has a default value (can be omitted) */
44
+ readonly hasDefault?: boolean;
45
+ }
46
+ /**
47
+ * Describes the return type of a query.
48
+ */
49
+ export interface ReturnDescriptor {
50
+ /** How many rows are expected */
51
+ readonly mode: ReturnMode;
52
+ /** Fields in the return type (empty for 'affected' or 'void') */
53
+ readonly fields: readonly FieldDescriptor[];
54
+ }
55
+ /**
56
+ * Describes a field in the query return type.
57
+ */
58
+ export interface FieldDescriptor {
59
+ /** Column name or alias */
60
+ readonly name: string;
61
+ /** TypeScript type string */
62
+ readonly tsType: string;
63
+ /** PostgreSQL type */
64
+ readonly pgType: string;
65
+ /** Whether the field can be null */
66
+ readonly nullable: boolean;
67
+ /** Whether this is an array type */
68
+ readonly isArray?: boolean;
69
+ }
70
+ /**
71
+ * Optional metadata for advanced query use cases.
72
+ */
73
+ export interface QueryMetadata {
74
+ /** Fully qualified table name (schema.table) */
75
+ readonly table: string;
76
+ /** Indexes used by this query */
77
+ readonly indexes?: readonly string[];
78
+ /** Generated from table/column comments */
79
+ readonly comment?: string;
80
+ }
81
+ /**
82
+ * SQL operation categories.
83
+ */
84
+ export type QueryOperation = "select" | "insert" | "update" | "delete" | "upsert";
85
+ /**
86
+ * Query return cardinality modes.
87
+ *
88
+ * - `one`: Exactly one row expected (throws if 0 or >1)
89
+ * - `oneOrNone`: Zero or one row (returns T | null)
90
+ * - `many`: Zero or more rows (returns T[])
91
+ * - `affected`: Returns affected row count (number)
92
+ * - `void`: Returns nothing
93
+ */
94
+ export type ReturnMode = "one" | "oneOrNone" | "many" | "affected" | "void";
95
+ //# sourceMappingURL=query-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-types.d.ts","sourceRoot":"","sources":["../../src/shared/query-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,kDAAkD;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,yBAAyB;IACzB,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IAEnC,mFAAmF;IACnF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,uBAAuB;IACvB,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;IAE5C,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IAEnC,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC;CAC/B;AAMD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,yCAAyC;IACzC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,iEAAiE;IACjE,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAE1B,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,sBAAsB;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,oCAAoC;IACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,oCAAoC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,iCAAiC;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAErC,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAMD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElF;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Query descriptor types for SQL code generation
3
+ *
4
+ * These types describe SQL queries in a way that plugins can consume
5
+ * to generate typed function wrappers. They are produced by `hex` (the SQL
6
+ * template builder) and consumed by query plugins.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=query-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-types.js","sourceRoot":"","sources":["../../src/shared/query-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
package/dist/testing.d.ts CHANGED
@@ -1,56 +1,144 @@
1
1
  /**
2
2
  * Testing Utilities
3
3
  *
4
- * Provides reusable test layers and helpers for plugin testing.
4
+ * Helpers for testing plugins and the generation pipeline.
5
+ *
6
+ * ## Plugin Testing
7
+ *
8
+ * ```typescript
9
+ * import { testPlugin, testIR, testConfig } from "pg-sourcerer/testing"
10
+ *
11
+ * it.effect("generates types", () =>
12
+ * Effect.gen(function* () {
13
+ * const result = yield* testPlugin(myPlugin, {
14
+ * ir: testIR({ entities: [...] }),
15
+ * })
16
+ * expect(result.declarations).toHaveLength(1)
17
+ * })
18
+ * )
19
+ * ```
20
+ *
21
+ * ## IR Building
22
+ *
23
+ * Use testIRWithEntities with real entities from ir-builder, or create
24
+ * minimal stubs for unit tests that don't need full introspection data.
5
25
  */
6
- import { Layer } from "effect";
7
- import { PluginMeta } from "./services/plugin-meta.js";
8
- import { IR } from "./services/ir.js";
9
- import type { SemanticIR } from "./ir/semantic-ir.js";
26
+ import { Effect } from "effect";
27
+ import type { Plugin } from "./runtime/types.js";
28
+ import { type OrchestratorConfig, type OrchestratorResult } from "./runtime/orchestrator.js";
29
+ import { type EmittedFile } from "./runtime/emit.js";
30
+ import type { SemanticIR, Entity } from "./ir/semantic-ir.js";
31
+ import { type CoreInflection } from "./services/inflection.js";
32
+ import { type TypeHintRegistry } from "./services/type-hints.js";
10
33
  /**
11
- * Base test layers for direct plugin testing.
34
+ * Create a minimal SemanticIR for testing.
12
35
  *
13
- * Provides all shared services except IR and PluginMeta,
14
- * which are test-specific.
36
+ * Most tests just need an empty or partial IR. For tests that don't need
37
+ * real entity structures, use actual IRBuilder or provide entities directly.
38
+ */
39
+ export declare function testIR(overrides?: Partial<SemanticIR>): SemanticIR;
40
+ /**
41
+ * Create a SemanticIR with entities from a map or array.
15
42
  *
16
- * Usage:
43
+ * @example
17
44
  * ```typescript
18
- * const TestLayer = Layer.mergeAll(
19
- * PluginTestLayers,
20
- * Layer.succeed(IR, testIR),
21
- * Layer.succeed(PluginMeta, { name: "test-plugin" }),
45
+ * // From array (uses entity.name as key)
46
+ * const ir = testIRWithEntities([userEntity, postEntity])
47
+ *
48
+ * // From map
49
+ * const ir = testIRWithEntities(new Map([["User", userEntity]]))
50
+ * ```
51
+ */
52
+ export declare function testIRWithEntities(entities: ReadonlyMap<string, Entity> | readonly Entity[]): SemanticIR;
53
+ /**
54
+ * Load introspection fixture and build IR from it.
55
+ *
56
+ * Returns an Effect that loads the pre-captured introspection data
57
+ * and builds IR using the real IR builder service.
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * it.effect("uses fixture data", () =>
62
+ * Effect.gen(function* () {
63
+ * const ir = yield* testIRFromFixture(["app_public"]);
64
+ * const userEntity = ir.entities.get("User");
65
+ * expect(userEntity).toBeDefined();
66
+ * })
22
67
  * )
23
68
  * ```
24
69
  */
25
- export declare const PluginTestLayers: Layer.Layer<import("./index.js").Inflection | import("./testing.js").Symbols | import("./testing.js").Emissions | import("./index.js").TypeHints | import("./index.js").ArtifactStore, never, never>;
70
+ export declare function testIRFromFixture(schemas?: readonly string[]): Effect.Effect<SemanticIR, unknown>;
71
+ /**
72
+ * Options for testConfig.
73
+ */
74
+ export interface TestConfigOptions {
75
+ /** IR to use (defaults to empty testIR) */
76
+ ir?: SemanticIR;
77
+ /** Inflection config */
78
+ inflection?: CoreInflection;
79
+ /** Type hints */
80
+ typeHints?: TypeHintRegistry;
81
+ /** Default file for unmatched symbols */
82
+ defaultFile?: string;
83
+ /** Output directory */
84
+ outputDir?: string;
85
+ }
86
+ /**
87
+ * Create an OrchestratorConfig for testing.
88
+ */
89
+ export declare function testConfig(options?: TestConfigOptions): OrchestratorConfig;
90
+ /**
91
+ * Options for testing a plugin.
92
+ */
93
+ export interface TestPluginOptions {
94
+ /** IR to use (defaults to empty testIR) */
95
+ ir?: SemanticIR;
96
+ /** Inflection config */
97
+ inflection?: CoreInflection;
98
+ /** Type hints */
99
+ typeHints?: TypeHintRegistry;
100
+ /** Default file for unmatched symbols */
101
+ defaultFile?: string;
102
+ /** Output directory */
103
+ outputDir?: string;
104
+ /** Additional plugins to run before this one (for dependencies) */
105
+ dependencies?: readonly Plugin[];
106
+ }
26
107
  /**
27
- * Create a complete test layer for a specific plugin test.
108
+ * Run a single plugin through the orchestrator and return results.
28
109
  *
29
- * @param ir - The SemanticIR to provide
30
- * @param pluginName - The plugin name for PluginMeta
31
- * @returns Layer with all services for plugin testing
110
+ * Useful for unit testing plugins in isolation.
32
111
  *
33
- * Usage:
112
+ * @example
34
113
  * ```typescript
35
- * const testIR = freezeIR(createIRBuilder(["public"]))
36
- * const TestLayer = createPluginTestLayer(testIR, "my-plugin")
37
- *
38
- * layer(TestLayer)("MyPlugin tests", (it) => {
39
- * it.effect("generates types", () =>
40
- * Effect.gen(function* () {
41
- * yield* myPlugin.run(config)
42
- * const emissions = yield* Emissions
43
- * expect(emissions.getAll()).toHaveLength(1)
114
+ * it.effect("declares User type", () =>
115
+ * Effect.gen(function* () {
116
+ * const result = yield* testPlugin(typesPlugin)
117
+ * expect(result.declarations).toContainEqual(
118
+ * expect.objectContaining({ name: "User" })
119
+ * )
120
+ * })
121
+ * )
122
+ * ```
123
+ */
124
+ export declare function testPlugin(plugin: Plugin, options?: TestPluginOptions): Effect.Effect<OrchestratorResult, unknown>;
125
+ /**
126
+ * Run a plugin and emit files, returning both orchestration and emit results.
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * it.effect("generates valid TypeScript", () =>
131
+ * Effect.gen(function* () {
132
+ * const { files } = yield* testPluginEmit(typesPlugin, {
133
+ * ir: testIRWithEntities([...]),
44
134
  * })
45
- * )
46
- * })
135
+ * expect(files[0].content).toContain("export type User")
136
+ * })
137
+ * )
47
138
  * ```
48
139
  */
49
- export declare function createPluginTestLayer(ir: SemanticIR, pluginName: string): Layer.Layer<import("./index.js").Inflection | import("./testing.js").Symbols | import("./testing.js").Emissions | import("./index.js").TypeHints | IR | import("./index.js").ArtifactStore | PluginMeta, never, never>;
50
- export { IR } from "./services/ir.js";
51
- export { PluginMeta } from "./services/plugin-meta.js";
52
- export { Emissions } from "./services/emissions.js";
53
- export { Symbols } from "./services/symbols.js";
54
- export { runPlugins } from "./services/plugin-runner.js";
55
- export { createIRBuilder, freezeIR } from "./ir/semantic-ir.js";
140
+ export declare function testPluginEmit(plugin: Plugin, options?: TestPluginOptions): Effect.Effect<{
141
+ result: OrchestratorResult;
142
+ files: readonly EmittedFile[];
143
+ }, unknown>;
56
144
  //# sourceMappingURL=testing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAM9B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,sMAM5B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,0NAMvE;AAGD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA"}
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC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UAAU,CAAC;IAChB,wBAAwB;IACxB,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,iBAAiB;IACjB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAY5C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAAC,MAAM,CAAC;IAAE,MAAM,EAAE,kBAAkB,CAAC;IAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAA;CAAE,EAAE,OAAO,CAAC,CAOvF"}
package/dist/testing.js CHANGED
@@ -1,63 +1,155 @@
1
1
  /**
2
2
  * Testing Utilities
3
3
  *
4
- * Provides reusable test layers and helpers for plugin testing.
4
+ * Helpers for testing plugins and the generation pipeline.
5
+ *
6
+ * ## Plugin Testing
7
+ *
8
+ * ```typescript
9
+ * import { testPlugin, testIR, testConfig } from "pg-sourcerer/testing"
10
+ *
11
+ * it.effect("generates types", () =>
12
+ * Effect.gen(function* () {
13
+ * const result = yield* testPlugin(myPlugin, {
14
+ * ir: testIR({ entities: [...] }),
15
+ * })
16
+ * expect(result.declarations).toHaveLength(1)
17
+ * })
18
+ * )
19
+ * ```
20
+ *
21
+ * ## IR Building
22
+ *
23
+ * Use testIRWithEntities with real entities from ir-builder, or create
24
+ * minimal stubs for unit tests that don't need full introspection data.
5
25
  */
6
- import { Layer } from "effect";
26
+ import { Effect } from "effect";
27
+ import { runPlugins, } from "./runtime/orchestrator.js";
28
+ import { emitFiles } from "./runtime/emit.js";
29
+ import { defaultInflection } from "./services/inflection.js";
30
+ import { emptyTypeHintRegistry } from "./services/type-hints.js";
31
+ import { createIRBuilderService } from "./services/ir-builder.js";
7
32
  import { InflectionLive } from "./services/inflection.js";
8
- import { EmissionsLive } from "./services/emissions.js";
9
- import { SymbolsLive } from "./services/symbols.js";
10
- import { TypeHintsLive } from "./services/type-hints.js";
11
- import { ArtifactStoreLive } from "./services/artifact-store.js";
12
- import { PluginMeta } from "./services/plugin-meta.js";
13
- import { IR } from "./services/ir.js";
33
+ // =============================================================================
34
+ // Test IR Builders
35
+ // =============================================================================
36
+ /**
37
+ * Create a minimal SemanticIR for testing.
38
+ *
39
+ * Most tests just need an empty or partial IR. For tests that don't need
40
+ * real entity structures, use actual IRBuilder or provide entities directly.
41
+ */
42
+ export function testIR(overrides) {
43
+ return {
44
+ schemas: ["public"],
45
+ entities: new Map(),
46
+ artifacts: new Map(),
47
+ extensions: [],
48
+ introspectedAt: new Date(),
49
+ ...overrides,
50
+ };
51
+ }
52
+ /**
53
+ * Create a SemanticIR with entities from a map or array.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * // From array (uses entity.name as key)
58
+ * const ir = testIRWithEntities([userEntity, postEntity])
59
+ *
60
+ * // From map
61
+ * const ir = testIRWithEntities(new Map([["User", userEntity]]))
62
+ * ```
63
+ */
64
+ export function testIRWithEntities(entities) {
65
+ const entityMap = Array.isArray(entities) ? new Map(entities.map(e => [e.name, e])) : entities;
66
+ return testIR({ entities: entityMap });
67
+ }
14
68
  /**
15
- * Base test layers for direct plugin testing.
69
+ * Load introspection fixture and build IR from it.
16
70
  *
17
- * Provides all shared services except IR and PluginMeta,
18
- * which are test-specific.
71
+ * Returns an Effect that loads the pre-captured introspection data
72
+ * and builds IR using the real IR builder service.
19
73
  *
20
- * Usage:
74
+ * @example
21
75
  * ```typescript
22
- * const TestLayer = Layer.mergeAll(
23
- * PluginTestLayers,
24
- * Layer.succeed(IR, testIR),
25
- * Layer.succeed(PluginMeta, { name: "test-plugin" }),
76
+ * it.effect("uses fixture data", () =>
77
+ * Effect.gen(function* () {
78
+ * const ir = yield* testIRFromFixture(["app_public"]);
79
+ * const userEntity = ir.entities.get("User");
80
+ * expect(userEntity).toBeDefined();
81
+ * })
26
82
  * )
27
83
  * ```
28
84
  */
29
- export const PluginTestLayers = Layer.mergeAll(InflectionLive, EmissionsLive, SymbolsLive, TypeHintsLive([]), ArtifactStoreLive);
85
+ export function testIRFromFixture(schemas = ["app_public"]) {
86
+ const builder = createIRBuilderService();
87
+ return Effect.gen(function* () {
88
+ const { loadIntrospectionFixture } = yield* Effect.promise(() => import("./__tests__/fixtures/index.js").then(m => ({ loadIntrospectionFixture: m.loadIntrospectionFixture })));
89
+ const introspection = loadIntrospectionFixture();
90
+ return yield* builder.build(introspection, { schemas });
91
+ }).pipe(Effect.provide(InflectionLive));
92
+ }
93
+ /**
94
+ * Create an OrchestratorConfig for testing.
95
+ */
96
+ export function testConfig(options = {}) {
97
+ return {
98
+ plugins: [],
99
+ ir: options.ir ?? testIR(),
100
+ inflection: options.inflection ?? defaultInflection,
101
+ typeHints: options.typeHints ?? emptyTypeHintRegistry,
102
+ defaultFile: options.defaultFile ?? "index.ts",
103
+ outputDir: options.outputDir ?? "src/generated",
104
+ };
105
+ }
30
106
  /**
31
- * Create a complete test layer for a specific plugin test.
107
+ * Run a single plugin through the orchestrator and return results.
32
108
  *
33
- * @param ir - The SemanticIR to provide
34
- * @param pluginName - The plugin name for PluginMeta
35
- * @returns Layer with all services for plugin testing
109
+ * Useful for unit testing plugins in isolation.
36
110
  *
37
- * Usage:
111
+ * @example
38
112
  * ```typescript
39
- * const testIR = freezeIR(createIRBuilder(["public"]))
40
- * const TestLayer = createPluginTestLayer(testIR, "my-plugin")
41
- *
42
- * layer(TestLayer)("MyPlugin tests", (it) => {
43
- * it.effect("generates types", () =>
44
- * Effect.gen(function* () {
45
- * yield* myPlugin.run(config)
46
- * const emissions = yield* Emissions
47
- * expect(emissions.getAll()).toHaveLength(1)
113
+ * it.effect("declares User type", () =>
114
+ * Effect.gen(function* () {
115
+ * const result = yield* testPlugin(typesPlugin)
116
+ * expect(result.declarations).toContainEqual(
117
+ * expect.objectContaining({ name: "User" })
118
+ * )
119
+ * })
120
+ * )
121
+ * ```
122
+ */
123
+ export function testPlugin(plugin, options = {}) {
124
+ const config = testConfig({
125
+ ir: options.ir,
126
+ inflection: options.inflection,
127
+ typeHints: options.typeHints,
128
+ defaultFile: options.defaultFile,
129
+ outputDir: options.outputDir,
130
+ });
131
+ const allPlugins = [...(options.dependencies ?? []), plugin];
132
+ return runPlugins({ ...config, plugins: allPlugins });
133
+ }
134
+ /**
135
+ * Run a plugin and emit files, returning both orchestration and emit results.
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * it.effect("generates valid TypeScript", () =>
140
+ * Effect.gen(function* () {
141
+ * const { files } = yield* testPluginEmit(typesPlugin, {
142
+ * ir: testIRWithEntities([...]),
48
143
  * })
49
- * )
50
- * })
144
+ * expect(files[0].content).toContain("export type User")
145
+ * })
146
+ * )
51
147
  * ```
52
148
  */
53
- export function createPluginTestLayer(ir, pluginName) {
54
- return Layer.mergeAll(PluginTestLayers, Layer.succeed(IR, ir), Layer.succeed(PluginMeta, { name: pluginName }));
149
+ export function testPluginEmit(plugin, options = {}) {
150
+ return testPlugin(plugin, options).pipe(Effect.map(result => ({
151
+ result,
152
+ files: emitFiles(result),
153
+ })));
55
154
  }
56
- // Re-export commonly needed items for tests
57
- export { IR } from "./services/ir.js";
58
- export { PluginMeta } from "./services/plugin-meta.js";
59
- export { Emissions } from "./services/emissions.js";
60
- export { Symbols } from "./services/symbols.js";
61
- export { runPlugins } from "./services/plugin-runner.js";
62
- export { createIRBuilder, freezeIR } from "./ir/semantic-ir.js";
63
155
  //# sourceMappingURL=testing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"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C,WAAW;QAChC,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAE7D,OAAO,UAAU,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;AACxD,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAc,EACd,UAA6B,EAAE;IAE/B,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CACrC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,MAAM;QACN,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC;KACzB,CAAC,CAAC,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * User Module Reference
3
+ *
4
+ * Provides a structured way to import user-defined modules in generated code.
5
+ * Paths are relative to the config file, and the system computes correct
6
+ * relative imports for each output file at emit time.
7
+ */
8
+ /**
9
+ * Reference to a user-defined module for import in generated code.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * // In pgsourcerer.config.ts
14
+ * import { userModule } from "pg-sourcerer";
15
+ *
16
+ * kysely({
17
+ * dbImport: userModule("./db.ts", { named: ["db"] }),
18
+ * })
19
+ * ```
20
+ */
21
+ export interface UserModuleRef {
22
+ readonly _tag: "UserModuleRef";
23
+ /** Path to the module, relative to the config file */
24
+ readonly path: string;
25
+ /** Named exports to import: import { foo, bar } from "..." */
26
+ readonly named?: readonly string[];
27
+ /** Default import binding: import db from "..." */
28
+ readonly default?: string;
29
+ /** Namespace import binding: import * as Db from "..." */
30
+ readonly namespace?: string;
31
+ /**
32
+ * Whether to validate that the requested exports exist in the module.
33
+ * @default true
34
+ */
35
+ readonly validate?: boolean;
36
+ }
37
+ /**
38
+ * Options for creating a user module reference.
39
+ */
40
+ export interface UserModuleOptions {
41
+ /** Named exports to import: import { foo, bar } from "..." */
42
+ readonly named?: readonly string[];
43
+ /** Default import binding: import db from "..." */
44
+ readonly default?: string;
45
+ /** Namespace import binding: import * as Db from "..." */
46
+ readonly namespace?: string;
47
+ /**
48
+ * Whether to validate that the requested exports exist in the module.
49
+ * @default true
50
+ */
51
+ readonly validate?: boolean;
52
+ }
53
+ /**
54
+ * Create a reference to a user module for import in generated code.
55
+ *
56
+ * The path is relative to the config file location. At emit time, the system
57
+ * computes the correct relative import path for each generated file.
58
+ *
59
+ * @param path - Path to the module, relative to the config file
60
+ * @param options - Import options (what to import from the module)
61
+ * @returns A UserModuleRef that can be passed to plugin config
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * // Named imports
66
+ * userModule("./db.ts", { named: ["db", "Kysely"] })
67
+ * // Generates: import { db, Kysely } from "../db.js"
68
+ *
69
+ * // Default import
70
+ * userModule("./db.ts", { default: "db" })
71
+ * // Generates: import db from "../db.js"
72
+ *
73
+ * // Namespace import
74
+ * userModule("./db.ts", { namespace: "Db" })
75
+ * // Generates: import * as Db from "../db.js"
76
+ *
77
+ * // Skip validation (not recommended)
78
+ * userModule("./db.ts", { named: ["db"], validate: false })
79
+ * ```
80
+ */
81
+ export declare function userModule(path: string, options: UserModuleOptions): UserModuleRef;
82
+ /**
83
+ * Type guard to check if a value is a UserModuleRef.
84
+ */
85
+ export declare function isUserModuleRef(value: unknown): value is UserModuleRef;
86
+ //# sourceMappingURL=user-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-module.d.ts","sourceRoot":"","sources":["../src/user-module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,mDAAmD;IACnD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,mDAAmD;IACnD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,aAAa,CASlF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAOtE"}