houdini 2.0.0-next.4 → 2.0.0-next.41

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 (433) hide show
  1. package/build/adapter/index.d.ts +2 -2
  2. package/build/adapter/index.js +6 -0
  3. package/build/cmd/generate.d.ts +5 -0
  4. package/build/cmd/generate.js +77 -0
  5. package/build/cmd/index.js +32 -0
  6. package/build/cmd/init.js +565 -0
  7. package/build/cmd/pullSchema.js +21 -0
  8. package/build/lib/ast.js +71 -0
  9. package/build/lib/codegen.d.ts +57 -0
  10. package/build/lib/codegen.js +591 -0
  11. package/build/lib/config.d.ts +221 -177
  12. package/build/lib/config.js +135 -0
  13. package/build/lib/constants.js +14 -0
  14. package/build/lib/database.d.ts +6 -0
  15. package/build/lib/database.js +599 -0
  16. package/build/lib/db.d.ts +13 -0
  17. package/build/lib/db.js +134 -0
  18. package/build/lib/deepMerge.js +23 -0
  19. package/build/lib/error.d.ts +16 -0
  20. package/build/lib/error.js +115 -0
  21. package/build/lib/fs.d.ts +9 -11
  22. package/build/lib/fs.js +245 -0
  23. package/build/lib/graphql.d.ts +5 -32
  24. package/build/lib/graphql.js +36 -0
  25. package/build/lib/imports.d.ts +29 -14
  26. package/build/lib/imports.js +66 -0
  27. package/build/lib/index.d.ts +17 -24
  28. package/build/lib/index.js +21 -0
  29. package/build/lib/logger.d.ts +12 -0
  30. package/build/lib/logger.js +45 -0
  31. package/build/lib/parse.d.ts +1 -2
  32. package/build/lib/parse.js +32 -0
  33. package/build/lib/path.d.ts +0 -1
  34. package/build/lib/path.js +44 -0
  35. package/build/lib/pipeline.d.ts +1 -1
  36. package/build/lib/pipeline.js +8 -0
  37. package/build/lib/plugins.d.ts +4 -0
  38. package/build/lib/plugins.js +88 -0
  39. package/build/lib/project.d.ts +17 -0
  40. package/build/lib/project.js +187 -0
  41. package/build/lib/schema.d.ts +1 -0
  42. package/build/lib/schema.js +61 -0
  43. package/build/lib/sleep.d.ts +1 -0
  44. package/build/lib/sleep.js +8 -0
  45. package/build/lib/types.d.ts +92 -303
  46. package/build/lib/types.js +37 -0
  47. package/build/lib/walk.d.ts +11 -6
  48. package/build/lib/walk.js +138 -0
  49. package/build/node/index.d.ts +44 -0
  50. package/build/node/index.js +402 -0
  51. package/build/package.json +197 -0
  52. package/build/{lib/router → router}/conventions.d.ts +10 -1
  53. package/build/router/conventions.js +165 -0
  54. package/build/{runtime-esm/router → router}/cookies.d.ts +9 -9
  55. package/build/{runtime-esm/router → router}/cookies.js +22 -22
  56. package/build/{runtime-esm/router → router}/jwt.js +8 -6
  57. package/build/{lib/router → router}/manifest.d.ts +2 -2
  58. package/build/router/manifest.js +279 -0
  59. package/build/{runtime/router → router}/match.d.ts +9 -7
  60. package/build/{runtime-esm/router → router}/match.js +73 -10
  61. package/build/router/server.d.ts +43 -0
  62. package/build/router/server.js +133 -0
  63. package/build/{runtime-esm/router → router}/session.d.ts +2 -1
  64. package/build/{runtime-esm/router → router}/session.js +7 -3
  65. package/build/{runtime-cjs/router → router}/types.d.ts +5 -4
  66. package/build/runtime/cache/benchmarks/cache.bench.d.ts +1 -0
  67. package/build/runtime/cache/benchmarks/cache.bench.js +943 -0
  68. package/build/runtime/cache/gc.d.ts +2 -1
  69. package/build/{runtime-esm → runtime}/cache/gc.js +4 -1
  70. package/build/runtime/cache/index.d.ts +173 -3
  71. package/build/{runtime-esm/cache/cache.js → runtime/cache/index.js} +189 -70
  72. package/build/runtime/cache/lists.d.ts +9 -4
  73. package/build/{runtime-esm → runtime}/cache/lists.js +116 -27
  74. package/build/runtime/cache/staleManager.d.ts +2 -1
  75. package/build/{runtime-esm → runtime}/cache/staleManager.js +6 -2
  76. package/build/runtime/cache/storage.d.ts +4 -1
  77. package/build/{runtime-esm → runtime}/cache/storage.js +125 -54
  78. package/build/{runtime-esm → runtime}/cache/stuff.js +4 -3
  79. package/build/runtime/cache/subscription.d.ts +22 -9
  80. package/build/{runtime-esm → runtime}/cache/subscription.js +103 -65
  81. package/build/runtime/{client/index.d.ts → client.d.ts} +15 -22
  82. package/build/runtime/client.js +88 -0
  83. package/build/runtime/config.d.ts +7 -0
  84. package/build/{runtime-esm/lib → runtime}/config.js +6 -19
  85. package/build/runtime/{lib/constants.d.ts → constants.d.ts} +1 -1
  86. package/build/runtime/{client/documentStore.d.ts → documentStore.d.ts} +18 -11
  87. package/build/{runtime-esm/client → runtime}/documentStore.js +46 -51
  88. package/build/{runtime-cjs/lib → runtime}/flatten.d.ts +1 -1
  89. package/build/runtime/index.d.ts +12 -8
  90. package/build/runtime/index.js +30 -0
  91. package/build/{runtime-cjs/lib → runtime}/key.d.ts +1 -1
  92. package/build/{runtime-esm/lib → runtime}/key.js +4 -4
  93. package/build/{runtime-esm/lib → runtime}/log.js +3 -3
  94. package/build/{runtime-cjs/lib → runtime}/pageInfo.d.ts +3 -3
  95. package/build/{runtime-esm/lib → runtime}/pageInfo.js +2 -2
  96. package/build/{runtime-cjs/lib → runtime}/pagination.d.ts +10 -8
  97. package/build/{runtime-esm/lib → runtime}/pagination.js +122 -20
  98. package/build/{runtime-cjs/lib → runtime}/scalars.d.ts +6 -6
  99. package/build/{runtime-esm/lib → runtime}/scalars.js +10 -43
  100. package/build/{runtime-cjs/lib → runtime}/selection.d.ts +1 -1
  101. package/build/{runtime-esm/lib → runtime}/selection.js +17 -2
  102. package/build/runtime/{lib/store.d.ts → store.d.ts} +1 -1
  103. package/build/{runtime-esm/lib → runtime}/store.js +2 -3
  104. package/build/{runtime-esm/lib → runtime}/types.d.ts +83 -102
  105. package/build/{runtime-esm/lib → runtime}/types.js +9 -14
  106. package/build/test/index.d.ts +6 -25
  107. package/build/test/index.js +329 -0
  108. package/build/vite/hmr.d.ts +26 -5
  109. package/build/vite/hmr.js +431 -0
  110. package/build/vite/houdini.d.ts +4 -10
  111. package/build/vite/houdini.js +134 -0
  112. package/build/vite/index.d.ts +13 -7
  113. package/build/vite/index.js +104 -0
  114. package/build/vite/package.json +1 -0
  115. package/build/vite/schema.d.ts +5 -3
  116. package/build/vite/schema.js +193 -0
  117. package/package.json +134 -57
  118. package/build/adapter-cjs/index.js +0 -33
  119. package/build/adapter-cjs/package.json +0 -1
  120. package/build/adapter-esm/index.js +0 -9
  121. package/build/cmd-cjs/index.js +0 -89277
  122. package/build/cmd-cjs/package.json +0 -1
  123. package/build/cmd-esm/index.js +0 -89281
  124. package/build/codegen/generators/artifacts/fieldKey.d.ts +0 -3
  125. package/build/codegen/generators/artifacts/index.d.ts +0 -17
  126. package/build/codegen/generators/artifacts/indexFile.d.ts +0 -2
  127. package/build/codegen/generators/artifacts/inputs.d.ts +0 -4
  128. package/build/codegen/generators/artifacts/operations.d.ts +0 -11
  129. package/build/codegen/generators/artifacts/selection.d.ts +0 -20
  130. package/build/codegen/generators/artifacts/utils.d.ts +0 -8
  131. package/build/codegen/generators/comments/jsdoc.d.ts +0 -2
  132. package/build/codegen/generators/definitions/enums.d.ts +0 -2
  133. package/build/codegen/generators/definitions/index.d.ts +0 -2
  134. package/build/codegen/generators/index.d.ts +0 -6
  135. package/build/codegen/generators/indexFile/index.d.ts +0 -2
  136. package/build/codegen/generators/persistedQueries/index.d.ts +0 -2
  137. package/build/codegen/generators/runtime/graphqlFunction.d.ts +0 -2
  138. package/build/codegen/generators/runtime/index.d.ts +0 -3
  139. package/build/codegen/generators/runtime/injectPlugins.d.ts +0 -7
  140. package/build/codegen/generators/runtime/pluginIndex.d.ts +0 -5
  141. package/build/codegen/generators/runtime/pluginRuntime.d.ts +0 -15
  142. package/build/codegen/generators/runtime/runtimeConfig.d.ts +0 -7
  143. package/build/codegen/generators/typescript/addReferencedInputTypes.d.ts +0 -4
  144. package/build/codegen/generators/typescript/documentTypes.d.ts +0 -2
  145. package/build/codegen/generators/typescript/imperativeTypeDef.d.ts +0 -2
  146. package/build/codegen/generators/typescript/index.d.ts +0 -2
  147. package/build/codegen/generators/typescript/inlineType.d.ts +0 -28
  148. package/build/codegen/generators/typescript/loadingState.d.ts +0 -8
  149. package/build/codegen/index.d.ts +0 -8
  150. package/build/codegen/transforms/addFields.d.ts +0 -2
  151. package/build/codegen/transforms/collectDefinitions.d.ts +0 -9
  152. package/build/codegen/transforms/componentFields.d.ts +0 -8
  153. package/build/codegen/transforms/fragmentVariables.d.ts +0 -17
  154. package/build/codegen/transforms/index.d.ts +0 -9
  155. package/build/codegen/transforms/list.d.ts +0 -9
  156. package/build/codegen/transforms/paginate.d.ts +0 -4
  157. package/build/codegen/transforms/runtimeScalars.d.ts +0 -2
  158. package/build/codegen/transforms/schema.d.ts +0 -2
  159. package/build/codegen/transforms/typename.d.ts +0 -2
  160. package/build/codegen/utils/commonjs.d.ts +0 -5
  161. package/build/codegen/utils/flattenSelections.d.ts +0 -11
  162. package/build/codegen/utils/index.d.ts +0 -4
  163. package/build/codegen/utils/moduleExport.d.ts +0 -4
  164. package/build/codegen/utils/murmur.d.ts +0 -9
  165. package/build/codegen/utils/objectIdentificationSelection.d.ts +0 -3
  166. package/build/codegen/utils/stripLoc.d.ts +0 -3
  167. package/build/codegen/validators/componentFields.d.ts +0 -2
  168. package/build/codegen/validators/index.d.ts +0 -5
  169. package/build/codegen/validators/noIDAlias.d.ts +0 -2
  170. package/build/codegen/validators/plugins.d.ts +0 -3
  171. package/build/codegen/validators/typeCheck.d.ts +0 -5
  172. package/build/codegen/validators/uniqueNames.d.ts +0 -2
  173. package/build/codegen-cjs/index.js +0 -74633
  174. package/build/codegen-cjs/package.json +0 -1
  175. package/build/codegen-esm/index.js +0 -74632
  176. package/build/lib/cleanupFiles.d.ts +0 -1
  177. package/build/lib/detectTools.d.ts +0 -16
  178. package/build/lib/introspection.d.ts +0 -3
  179. package/build/lib/plugin.d.ts +0 -2
  180. package/build/lib/router/index.d.ts +0 -9
  181. package/build/lib/router/server.d.ts +0 -7
  182. package/build/lib/router/types.d.ts +0 -23
  183. package/build/lib/typescript.d.ts +0 -20
  184. package/build/lib/watchAndRun.d.ts +0 -61
  185. package/build/lib-cjs/index.js +0 -79731
  186. package/build/lib-cjs/package.json +0 -1
  187. package/build/lib-esm/index.js +0 -79640
  188. package/build/runtime/cache/cache.d.ts +0 -169
  189. package/build/runtime/client/plugins/cache.d.ts +0 -9
  190. package/build/runtime/client/plugins/fetch.d.ts +0 -38
  191. package/build/runtime/client/plugins/fetchParams.d.ts +0 -9
  192. package/build/runtime/client/plugins/fragment.d.ts +0 -2
  193. package/build/runtime/client/plugins/index.d.ts +0 -9
  194. package/build/runtime/client/plugins/injectedPlugins.d.ts +0 -4
  195. package/build/runtime/client/plugins/mutation.d.ts +0 -2
  196. package/build/runtime/client/plugins/optimisticKeys.d.ts +0 -7
  197. package/build/runtime/client/plugins/query.d.ts +0 -2
  198. package/build/runtime/client/plugins/subscription.d.ts +0 -20
  199. package/build/runtime/client/plugins/test.d.ts +0 -15
  200. package/build/runtime/client/plugins/throwOnError.d.ts +0 -8
  201. package/build/runtime/client/utils/documentPlugins.d.ts +0 -3
  202. package/build/runtime/client/utils/index.d.ts +0 -1
  203. package/build/runtime/generated.d.ts +0 -5
  204. package/build/runtime/imports/config.d.ts +0 -3
  205. package/build/runtime/imports/pluginConfig.d.ts +0 -3
  206. package/build/runtime/lib/config.d.ts +0 -216
  207. package/build/runtime/lib/deepEquals.d.ts +0 -1
  208. package/build/runtime/lib/flatten.d.ts +0 -2
  209. package/build/runtime/lib/index.d.ts +0 -10
  210. package/build/runtime/lib/key.d.ts +0 -6
  211. package/build/runtime/lib/log.d.ts +0 -6
  212. package/build/runtime/lib/lru.d.ts +0 -52
  213. package/build/runtime/lib/pageInfo.d.ts +0 -7
  214. package/build/runtime/lib/pagination.d.ts +0 -27
  215. package/build/runtime/lib/scalars.d.ts +0 -14
  216. package/build/runtime/lib/selection.d.ts +0 -2
  217. package/build/runtime/lib/types.d.ts +0 -417
  218. package/build/runtime/public/cache.d.ts +0 -43
  219. package/build/runtime/public/index.d.ts +0 -1
  220. package/build/runtime/public/list.d.ts +0 -18
  221. package/build/runtime/public/record.d.ts +0 -40
  222. package/build/runtime/public/tests/test.d.ts +0 -156
  223. package/build/runtime/public/types.d.ts +0 -62
  224. package/build/runtime/router/cookies.d.ts +0 -41
  225. package/build/runtime/router/jwt.d.ts +0 -117
  226. package/build/runtime/router/server.d.ts +0 -24
  227. package/build/runtime/router/session.d.ts +0 -21
  228. package/build/runtime/router/types.d.ts +0 -26
  229. package/build/runtime-cjs/cache/cache.d.ts +0 -169
  230. package/build/runtime-cjs/cache/cache.js +0 -1077
  231. package/build/runtime-cjs/cache/constants.d.ts +0 -1
  232. package/build/runtime-cjs/cache/constants.js +0 -28
  233. package/build/runtime-cjs/cache/gc.d.ts +0 -10
  234. package/build/runtime-cjs/cache/gc.js +0 -74
  235. package/build/runtime-cjs/cache/index.d.ts +0 -3
  236. package/build/runtime-cjs/cache/index.js +0 -25
  237. package/build/runtime-cjs/cache/lists.d.ts +0 -89
  238. package/build/runtime-cjs/cache/lists.js +0 -467
  239. package/build/runtime-cjs/cache/staleManager.d.ts +0 -31
  240. package/build/runtime-cjs/cache/staleManager.js +0 -123
  241. package/build/runtime-cjs/cache/storage.d.ts +0 -110
  242. package/build/runtime-cjs/cache/storage.js +0 -451
  243. package/build/runtime-cjs/cache/stuff.d.ts +0 -2
  244. package/build/runtime-cjs/cache/stuff.js +0 -56
  245. package/build/runtime-cjs/cache/subscription.d.ts +0 -52
  246. package/build/runtime-cjs/cache/subscription.js +0 -349
  247. package/build/runtime-cjs/client/documentStore.d.ts +0 -107
  248. package/build/runtime-cjs/client/documentStore.js +0 -487
  249. package/build/runtime-cjs/client/index.d.ts +0 -50
  250. package/build/runtime-cjs/client/index.js +0 -162
  251. package/build/runtime-cjs/client/plugins/cache.d.ts +0 -9
  252. package/build/runtime-cjs/client/plugins/cache.js +0 -138
  253. package/build/runtime-cjs/client/plugins/fetch.d.ts +0 -38
  254. package/build/runtime-cjs/client/plugins/fetch.js +0 -210
  255. package/build/runtime-cjs/client/plugins/fetchParams.d.ts +0 -9
  256. package/build/runtime-cjs/client/plugins/fetchParams.js +0 -47
  257. package/build/runtime-cjs/client/plugins/fragment.d.ts +0 -2
  258. package/build/runtime-cjs/client/plugins/fragment.js +0 -77
  259. package/build/runtime-cjs/client/plugins/index.d.ts +0 -9
  260. package/build/runtime-cjs/client/plugins/index.js +0 -45
  261. package/build/runtime-cjs/client/plugins/injectedPlugins.d.ts +0 -4
  262. package/build/runtime-cjs/client/plugins/injectedPlugins.js +0 -25
  263. package/build/runtime-cjs/client/plugins/mutation.d.ts +0 -2
  264. package/build/runtime-cjs/client/plugins/mutation.js +0 -89
  265. package/build/runtime-cjs/client/plugins/optimisticKeys.d.ts +0 -7
  266. package/build/runtime-cjs/client/plugins/optimisticKeys.js +0 -324
  267. package/build/runtime-cjs/client/plugins/query.d.ts +0 -2
  268. package/build/runtime-cjs/client/plugins/query.js +0 -93
  269. package/build/runtime-cjs/client/plugins/subscription.d.ts +0 -20
  270. package/build/runtime-cjs/client/plugins/subscription.js +0 -114
  271. package/build/runtime-cjs/client/plugins/test.d.ts +0 -15
  272. package/build/runtime-cjs/client/plugins/test.js +0 -118
  273. package/build/runtime-cjs/client/plugins/throwOnError.d.ts +0 -8
  274. package/build/runtime-cjs/client/plugins/throwOnError.js +0 -47
  275. package/build/runtime-cjs/client/utils/documentPlugins.d.ts +0 -3
  276. package/build/runtime-cjs/client/utils/documentPlugins.js +0 -57
  277. package/build/runtime-cjs/client/utils/index.d.ts +0 -1
  278. package/build/runtime-cjs/client/utils/index.js +0 -22
  279. package/build/runtime-cjs/generated.d.ts +0 -5
  280. package/build/runtime-cjs/generated.js +0 -16
  281. package/build/runtime-cjs/imports/config.d.ts +0 -3
  282. package/build/runtime-cjs/imports/config.js +0 -24
  283. package/build/runtime-cjs/imports/pluginConfig.d.ts +0 -3
  284. package/build/runtime-cjs/imports/pluginConfig.js +0 -25
  285. package/build/runtime-cjs/index.d.ts +0 -8
  286. package/build/runtime-cjs/index.js +0 -61
  287. package/build/runtime-cjs/lib/config.d.ts +0 -216
  288. package/build/runtime-cjs/lib/config.js +0 -110
  289. package/build/runtime-cjs/lib/constants.d.ts +0 -6
  290. package/build/runtime-cjs/lib/constants.js +0 -38
  291. package/build/runtime-cjs/lib/deepEquals.js +0 -52
  292. package/build/runtime-cjs/lib/flatten.js +0 -41
  293. package/build/runtime-cjs/lib/index.d.ts +0 -10
  294. package/build/runtime-cjs/lib/index.js +0 -40
  295. package/build/runtime-cjs/lib/key.js +0 -41
  296. package/build/runtime-cjs/lib/log.js +0 -72
  297. package/build/runtime-cjs/lib/lru.js +0 -73
  298. package/build/runtime-cjs/lib/pageInfo.js +0 -79
  299. package/build/runtime-cjs/lib/pagination.js +0 -240
  300. package/build/runtime-cjs/lib/scalars.js +0 -147
  301. package/build/runtime-cjs/lib/selection.js +0 -66
  302. package/build/runtime-cjs/lib/store.d.ts +0 -19
  303. package/build/runtime-cjs/lib/store.js +0 -81
  304. package/build/runtime-cjs/lib/types.d.ts +0 -417
  305. package/build/runtime-cjs/lib/types.js +0 -104
  306. package/build/runtime-cjs/package.json +0 -1
  307. package/build/runtime-cjs/public/cache.d.ts +0 -43
  308. package/build/runtime-cjs/public/cache.js +0 -112
  309. package/build/runtime-cjs/public/index.d.ts +0 -1
  310. package/build/runtime-cjs/public/index.js +0 -28
  311. package/build/runtime-cjs/public/list.d.ts +0 -18
  312. package/build/runtime-cjs/public/list.js +0 -151
  313. package/build/runtime-cjs/public/record.d.ts +0 -40
  314. package/build/runtime-cjs/public/record.js +0 -94
  315. package/build/runtime-cjs/public/tests/test.d.ts +0 -156
  316. package/build/runtime-cjs/public/tests/test.js +0 -60
  317. package/build/runtime-cjs/public/types.d.ts +0 -62
  318. package/build/runtime-cjs/public/types.js +0 -16
  319. package/build/runtime-cjs/router/cookies.d.ts +0 -41
  320. package/build/runtime-cjs/router/cookies.js +0 -168
  321. package/build/runtime-cjs/router/jwt.js +0 -168
  322. package/build/runtime-cjs/router/match.d.ts +0 -39
  323. package/build/runtime-cjs/router/match.js +0 -158
  324. package/build/runtime-cjs/router/server.d.ts +0 -24
  325. package/build/runtime-cjs/router/server.js +0 -102
  326. package/build/runtime-cjs/router/session.d.ts +0 -21
  327. package/build/runtime-cjs/router/session.js +0 -95
  328. package/build/runtime-cjs/router/types.js +0 -16
  329. package/build/runtime-esm/cache/cache.d.ts +0 -169
  330. package/build/runtime-esm/cache/constants.d.ts +0 -1
  331. package/build/runtime-esm/cache/gc.d.ts +0 -10
  332. package/build/runtime-esm/cache/index.d.ts +0 -3
  333. package/build/runtime-esm/cache/index.js +0 -5
  334. package/build/runtime-esm/cache/lists.d.ts +0 -89
  335. package/build/runtime-esm/cache/staleManager.d.ts +0 -31
  336. package/build/runtime-esm/cache/storage.d.ts +0 -110
  337. package/build/runtime-esm/cache/stuff.d.ts +0 -2
  338. package/build/runtime-esm/cache/subscription.d.ts +0 -52
  339. package/build/runtime-esm/client/documentStore.d.ts +0 -107
  340. package/build/runtime-esm/client/index.d.ts +0 -50
  341. package/build/runtime-esm/client/index.js +0 -130
  342. package/build/runtime-esm/client/plugins/cache.d.ts +0 -9
  343. package/build/runtime-esm/client/plugins/cache.js +0 -104
  344. package/build/runtime-esm/client/plugins/fetch.d.ts +0 -38
  345. package/build/runtime-esm/client/plugins/fetch.js +0 -184
  346. package/build/runtime-esm/client/plugins/fetchParams.d.ts +0 -9
  347. package/build/runtime-esm/client/plugins/fetchParams.js +0 -23
  348. package/build/runtime-esm/client/plugins/fragment.d.ts +0 -2
  349. package/build/runtime-esm/client/plugins/fragment.js +0 -53
  350. package/build/runtime-esm/client/plugins/index.d.ts +0 -9
  351. package/build/runtime-esm/client/plugins/index.js +0 -12
  352. package/build/runtime-esm/client/plugins/injectedPlugins.d.ts +0 -4
  353. package/build/runtime-esm/client/plugins/injectedPlugins.js +0 -5
  354. package/build/runtime-esm/client/plugins/mutation.d.ts +0 -2
  355. package/build/runtime-esm/client/plugins/mutation.js +0 -65
  356. package/build/runtime-esm/client/plugins/optimisticKeys.d.ts +0 -7
  357. package/build/runtime-esm/client/plugins/optimisticKeys.js +0 -290
  358. package/build/runtime-esm/client/plugins/query.d.ts +0 -2
  359. package/build/runtime-esm/client/plugins/query.js +0 -69
  360. package/build/runtime-esm/client/plugins/subscription.d.ts +0 -20
  361. package/build/runtime-esm/client/plugins/subscription.js +0 -90
  362. package/build/runtime-esm/client/plugins/test.d.ts +0 -15
  363. package/build/runtime-esm/client/plugins/test.js +0 -93
  364. package/build/runtime-esm/client/plugins/throwOnError.d.ts +0 -8
  365. package/build/runtime-esm/client/plugins/throwOnError.js +0 -23
  366. package/build/runtime-esm/client/utils/documentPlugins.d.ts +0 -3
  367. package/build/runtime-esm/client/utils/documentPlugins.js +0 -33
  368. package/build/runtime-esm/client/utils/index.d.ts +0 -1
  369. package/build/runtime-esm/client/utils/index.js +0 -1
  370. package/build/runtime-esm/generated.d.ts +0 -5
  371. package/build/runtime-esm/generated.js +0 -0
  372. package/build/runtime-esm/imports/config.d.ts +0 -3
  373. package/build/runtime-esm/imports/config.js +0 -4
  374. package/build/runtime-esm/imports/pluginConfig.d.ts +0 -3
  375. package/build/runtime-esm/imports/pluginConfig.js +0 -5
  376. package/build/runtime-esm/index.d.ts +0 -8
  377. package/build/runtime-esm/index.js +0 -22
  378. package/build/runtime-esm/lib/config.d.ts +0 -216
  379. package/build/runtime-esm/lib/constants.d.ts +0 -6
  380. package/build/runtime-esm/lib/deepEquals.d.ts +0 -1
  381. package/build/runtime-esm/lib/flatten.d.ts +0 -2
  382. package/build/runtime-esm/lib/index.d.ts +0 -10
  383. package/build/runtime-esm/lib/index.js +0 -10
  384. package/build/runtime-esm/lib/key.d.ts +0 -6
  385. package/build/runtime-esm/lib/log.d.ts +0 -6
  386. package/build/runtime-esm/lib/lru.d.ts +0 -52
  387. package/build/runtime-esm/lib/pageInfo.d.ts +0 -7
  388. package/build/runtime-esm/lib/pagination.d.ts +0 -27
  389. package/build/runtime-esm/lib/scalars.d.ts +0 -14
  390. package/build/runtime-esm/lib/selection.d.ts +0 -2
  391. package/build/runtime-esm/lib/store.d.ts +0 -19
  392. package/build/runtime-esm/public/cache.d.ts +0 -43
  393. package/build/runtime-esm/public/cache.js +0 -88
  394. package/build/runtime-esm/public/index.d.ts +0 -1
  395. package/build/runtime-esm/public/index.js +0 -4
  396. package/build/runtime-esm/public/list.d.ts +0 -18
  397. package/build/runtime-esm/public/list.js +0 -127
  398. package/build/runtime-esm/public/record.d.ts +0 -40
  399. package/build/runtime-esm/public/record.js +0 -70
  400. package/build/runtime-esm/public/tests/test.d.ts +0 -156
  401. package/build/runtime-esm/public/tests/test.js +0 -36
  402. package/build/runtime-esm/public/types.d.ts +0 -62
  403. package/build/runtime-esm/router/jwt.d.ts +0 -117
  404. package/build/runtime-esm/router/match.d.ts +0 -39
  405. package/build/runtime-esm/router/server.d.ts +0 -24
  406. package/build/runtime-esm/router/server.js +0 -77
  407. package/build/runtime-esm/router/types.d.ts +0 -26
  408. package/build/runtime-esm/router/types.js +0 -0
  409. package/build/test-cjs/index.js +0 -75227
  410. package/build/test-cjs/package.json +0 -1
  411. package/build/test-esm/index.js +0 -75222
  412. package/build/vite/imports.d.ts +0 -40
  413. package/build/vite-cjs/index.js +0 -86255
  414. package/build/vite-cjs/package.json +0 -1
  415. package/build/vite-esm/index.js +0 -86247
  416. /package/build/{adapter-esm → adapter}/package.json +0 -0
  417. /package/build/{cmd-esm → cmd}/package.json +0 -0
  418. /package/build/{vite → lib}/ast.d.ts +0 -0
  419. /package/build/{codegen-esm → lib}/package.json +0 -0
  420. /package/build/{lib-esm → node}/package.json +0 -0
  421. /package/build/{runtime-cjs/router → router}/jwt.d.ts +0 -0
  422. /package/build/{runtime-esm → router}/package.json +0 -0
  423. /package/build/{runtime-esm/public → router}/types.js +0 -0
  424. /package/build/{runtime-esm → runtime}/cache/constants.js +0 -0
  425. /package/build/{runtime-esm/lib → runtime}/constants.js +0 -0
  426. /package/build/{runtime-cjs/lib → runtime}/deepEquals.d.ts +0 -0
  427. /package/build/{runtime-esm/lib → runtime}/deepEquals.js +0 -0
  428. /package/build/{runtime-esm/lib → runtime}/flatten.js +0 -0
  429. /package/build/{runtime-cjs/lib → runtime}/log.d.ts +0 -0
  430. /package/build/{runtime-cjs/lib → runtime}/lru.d.ts +0 -0
  431. /package/build/{runtime-esm/lib → runtime}/lru.js +0 -0
  432. /package/build/{test-esm → runtime}/package.json +0 -0
  433. /package/build/{vite-esm → test}/package.json +0 -0
@@ -0,0 +1,591 @@
1
+ import { spawn } from "node:child_process";
2
+ import { writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import path from "node:path";
5
+ import { createInterface } from "node:readline";
6
+ import { WebSocket } from "ws";
7
+ const wasiRunnerPath = path.join(tmpdir(), "houdini-wasi-runner.mjs");
8
+ writeFileSync(
9
+ wasiRunnerPath,
10
+ `import{WASI}from'node:wasi';
11
+ import{readFileSync}from'node:fs';
12
+ import{Worker,isMainThread,workerData,MessageChannel,receiveMessageOnPort}from'worker_threads';
13
+ const[,,w,...r]=process.argv;
14
+ if(isMainThread){
15
+ const{port1:p1,port2:p2}=new MessageChannel();
16
+ const sb=new Int32Array(new SharedArrayBuffer(4));
17
+ process.stdin.on('error',()=>{});
18
+ process.stdin.on('data',d=>{p1.postMessage(d);Atomics.add(sb,0,1);Atomics.notify(sb,0);});
19
+ process.stdin.on('end',()=>{p1.postMessage(null);Atomics.add(sb,0,1);Atomics.notify(sb,0);});
20
+ const wk=new Worker(new URL(import.meta.url),{workerData:{w,r,p:p2,sb},transferList:[p2]});
21
+ wk.on('exit',c=>process.exit(c??0));
22
+ }else{
23
+ const{w:wb,r:args,p:port,sb}=workerData;
24
+ const wasi=new WASI({version:'preview1',args:[wb,...args],env:process.env,preopens:{'/':'/'}});
25
+ let mem=null;
26
+ const io=wasi.getImportObject();
27
+ const rfr=io.wasi_snapshot_preview1.fd_read;
28
+ io.wasi_snapshot_preview1.fd_read=(fd,iovs,il,nr)=>{
29
+ if(fd!==0||!mem)return rfr(fd,iovs,il,nr);
30
+ while(Atomics.load(sb,0)===0)Atomics.wait(sb,0,0);
31
+ const m=receiveMessageOnPort(port);
32
+ Atomics.sub(sb,0,1);
33
+ const v=new DataView(mem.buffer);
34
+ if(!m||m.message===null){v.setUint32(nr,0,true);return 0;}
35
+ const b=Buffer.isBuffer(m.message)?m.message:Buffer.from(m.message);
36
+ let wn=0;
37
+ for(let i=0;i<il;i++){
38
+ const p=v.getUint32(iovs+i*8,true),l=v.getUint32(iovs+i*8+4,true);
39
+ const n=Math.min(l,b.length-wn);
40
+ if(n<=0)break;
41
+ new Uint8Array(mem.buffer,p,n).set(b.subarray(wn,wn+n));
42
+ wn+=n;}
43
+ v.setUint32(nr,wn,true);
44
+ return 0;};
45
+ const mod=new WebAssembly.Module(readFileSync(wb));
46
+ const inst=new WebAssembly.Instance(mod,io);
47
+ mem=inst.exports.memory;
48
+ wasi.start(inst);
49
+ process.exit(0);}
50
+ `
51
+ );
52
+ import * as conventions from "../router/conventions.js";
53
+ import { create_schema, write_config } from "./database.js";
54
+ import { openDb } from "./db.js";
55
+ import { format_hook_error } from "./error.js";
56
+ import * as fs from "./fs.js";
57
+ import { Logger } from "./logger.js";
58
+ import { LogLevel } from "./types.js";
59
+ async function connect_db(config) {
60
+ const filepath = conventions.db_path(config);
61
+ const db = await openDb(filepath);
62
+ db.exec(create_schema);
63
+ db.flush();
64
+ return [db, filepath];
65
+ }
66
+ async function init_db(config, preserve) {
67
+ const db_file = conventions.db_path(config);
68
+ if (!preserve) {
69
+ try {
70
+ await fs.remove(db_file);
71
+ } catch (_e) {
72
+ }
73
+ try {
74
+ await fs.remove(`${db_file}-shm`);
75
+ } catch (_e) {
76
+ }
77
+ try {
78
+ await fs.remove(`${db_file}-wal`);
79
+ } catch (_e) {
80
+ }
81
+ }
82
+ return connect_db(config);
83
+ }
84
+ function plugin_db_key(name) {
85
+ if (!name.startsWith("./") && !name.startsWith("../") && !path.isAbsolute(name)) {
86
+ return name;
87
+ }
88
+ return name.replace(/\./g, "_").replace(/\//g, "__");
89
+ }
90
+ async function codegen_setup(config, mode, db, db_file) {
91
+ const _db = db;
92
+ const logger = new Logger(config.config_file.logLevel ?? LogLevel.ShortSummary);
93
+ await fs.mkdirpSync(conventions.houdini_root(config));
94
+ const rawTransport = config.config_file.pluginTransport ?? "websocket";
95
+ const resolvedTransport = rawTransport.startsWith("env:") ? process.env[rawTransport.slice("env:".length)] ?? "websocket" : rawTransport;
96
+ const useStdio = resolvedTransport === "stdio";
97
+ const plugins = {};
98
+ const plugin_specs = [];
99
+ const spec_results = {};
100
+ const stdioStdin = /* @__PURE__ */ new Map();
101
+ const triggerHookRef = { fn: null };
102
+ const pendingRequests = /* @__PURE__ */ new Map();
103
+ const wait_for_plugin_db = async (configKey, dbKey) => {
104
+ const pollDb = await openDb(db_file);
105
+ return new Promise((resolve, reject) => {
106
+ const interval = setInterval(() => {
107
+ pollDb.reload();
108
+ const row = pollDb.get("SELECT * FROM plugins WHERE name = ?", [dbKey]);
109
+ if (row) {
110
+ clearInterval(interval);
111
+ clearTimeout(timeout);
112
+ pollDb.run("UPDATE plugins SET config = ? WHERE name = ?", [
113
+ JSON.stringify(
114
+ config.plugins.find((p) => p.name === configKey)?.config ?? {}
115
+ ),
116
+ dbKey
117
+ ]);
118
+ pollDb.flush();
119
+ pollDb.close();
120
+ const spec = {
121
+ name: row.name,
122
+ port: row.port,
123
+ hooks: new Set(JSON.parse(row.hooks)),
124
+ order: row.plugin_order,
125
+ directory: config.plugins.find((p) => p.name === configKey)?.directory || ""
126
+ };
127
+ spec_results[configKey] = spec;
128
+ if (row.config_module) {
129
+ import(row.config_module).then((module) => {
130
+ if (module && typeof module.default === "function") {
131
+ config.config_file = module.default(config.config_file);
132
+ }
133
+ resolve(spec);
134
+ });
135
+ } else {
136
+ resolve(spec);
137
+ }
138
+ }
139
+ }, 10);
140
+ const timeout = setTimeout(() => {
141
+ clearInterval(interval);
142
+ pollDb.close();
143
+ reject(new Error(`Timeout waiting for plugin ${configKey} to register`));
144
+ }, 1e4);
145
+ });
146
+ };
147
+ const wait_for_plugin_stdio = (name, child) => new Promise((resolve, reject) => {
148
+ const timeout = setTimeout(() => {
149
+ reject(new Error(`Timeout waiting for plugin ${name} to register`));
150
+ }, 1e4);
151
+ const rl = createInterface({ input: child.stdout });
152
+ let registered = false;
153
+ rl.on("line", (line) => {
154
+ try {
155
+ const msg = JSON.parse(line);
156
+ if (!registered) {
157
+ if (msg.type !== "register") {
158
+ clearTimeout(timeout);
159
+ reject(new Error(`Plugin ${name} sent ${msg.type} before registering`));
160
+ return;
161
+ }
162
+ registered = true;
163
+ clearTimeout(timeout);
164
+ const spec = {
165
+ name: msg.name ?? plugin_db_key(name),
166
+ port: msg.port ?? 0,
167
+ hooks: new Set(msg.hooks ?? []),
168
+ order: msg.order,
169
+ directory: config.plugins.find((p) => p.name === name)?.directory || ""
170
+ };
171
+ spec_results[name] = spec;
172
+ _db.run(
173
+ `INSERT OR IGNORE INTO plugins (name, hooks, port, plugin_order, include_runtime, include_static_runtime, config_module, client_plugins)
174
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
175
+ [
176
+ spec.name,
177
+ JSON.stringify([...spec.hooks]),
178
+ spec.port,
179
+ spec.order,
180
+ msg.includeRuntime ?? null,
181
+ msg.includeStaticRuntime ?? null,
182
+ msg.configModule ?? null,
183
+ msg.clientPlugins ?? null
184
+ ]
185
+ );
186
+ _db.run("UPDATE plugins SET config = ? WHERE name = ?", [
187
+ JSON.stringify(
188
+ config.plugins.find((p) => p.name === name)?.config ?? {}
189
+ ),
190
+ spec.name
191
+ ]);
192
+ _db.flush();
193
+ if (msg.configModule) {
194
+ import(msg.configModule).then((module) => {
195
+ if (module && typeof module.default === "function") {
196
+ config.config_file = module.default(config.config_file);
197
+ }
198
+ resolve(spec);
199
+ }).catch((err) => {
200
+ reject(
201
+ new Error(
202
+ `Failed to load configModule for ${name}: ${err.message}`
203
+ )
204
+ );
205
+ });
206
+ } else {
207
+ resolve(spec);
208
+ }
209
+ return;
210
+ }
211
+ if (msg.type === "response") {
212
+ const pending = pendingRequests.get(msg.id);
213
+ if (!pending) return;
214
+ clearTimeout(pending.timeout);
215
+ pendingRequests.delete(msg.id);
216
+ if (msg.error) {
217
+ const errors = Array.isArray(msg.error) ? msg.error : [msg.error];
218
+ errors.forEach((error) => {
219
+ format_hook_error(config.root_dir, error, name, pending.hook);
220
+ });
221
+ pending.reject(new Error(`Failed to call ${name}`));
222
+ } else {
223
+ pending.resolve(msg.result);
224
+ }
225
+ } else if (msg.type === "invoke") {
226
+ if (!triggerHookRef.fn) {
227
+ const reply = `${JSON.stringify({
228
+ id: msg.id,
229
+ type: "invoke_result",
230
+ error: { message: "orchestrator not ready" }
231
+ })}
232
+ `;
233
+ child.stdin?.write(reply);
234
+ return;
235
+ }
236
+ triggerHookRef.fn(msg.hook, {
237
+ parallel_safe: msg.parallel,
238
+ payload: msg.payload,
239
+ task_id: msg.taskId
240
+ }).then((result) => {
241
+ const reply = JSON.stringify({ id: msg.id, type: "invoke_result", result }) + "\n";
242
+ child.stdin?.write(reply);
243
+ }).catch((err) => {
244
+ const reply = `${JSON.stringify({
245
+ id: msg.id,
246
+ type: "invoke_result",
247
+ error: { message: err.message }
248
+ })}
249
+ `;
250
+ child.stdin?.write(reply);
251
+ });
252
+ }
253
+ } catch (err) {
254
+ if (!registered) {
255
+ reject(err instanceof Error ? err : new Error(String(err)));
256
+ }
257
+ }
258
+ });
259
+ rl.on("close", () => {
260
+ if (!registered) {
261
+ clearTimeout(timeout);
262
+ reject(new Error(`Plugin ${name} stdout closed before registering`));
263
+ } else {
264
+ for (const [id, pending] of pendingRequests.entries()) {
265
+ if (pending.plugin !== name) continue;
266
+ clearTimeout(pending.timeout);
267
+ pendingRequests.delete(id);
268
+ pending.reject(new Error(`Plugin ${name} closed unexpectedly`));
269
+ }
270
+ }
271
+ });
272
+ });
273
+ _db.run("DELETE FROM plugins");
274
+ _db.flush();
275
+ logger.time("Start Plugins");
276
+ await Promise.all(
277
+ config.plugins.map(async (plugin) => {
278
+ let executable = plugin.executable;
279
+ const args = ["--database", db_file];
280
+ const jsExtensions = [".js", ".mjs", ".cjs"];
281
+ if (jsExtensions.includes(path.extname(plugin.executable))) {
282
+ executable = "node";
283
+ args.unshift(plugin.executable);
284
+ } else if (path.extname(plugin.executable) === ".wasm") {
285
+ executable = "node";
286
+ args.unshift(wasiRunnerPath, plugin.executable);
287
+ }
288
+ const dbKey = plugin_db_key(plugin.name);
289
+ args.push("--plugin-key", dbKey);
290
+ const pluginUsesStdio = useStdio || path.extname(plugin.executable) === ".wasm";
291
+ if (pluginUsesStdio) {
292
+ args.push("--transport", "stdio");
293
+ }
294
+ logger.time(`Spawn ${plugin.name}`);
295
+ const child = spawn(executable, args, {
296
+ stdio: ["pipe", "pipe", "inherit"],
297
+ detached: process.platform !== "win32"
298
+ });
299
+ if (pluginUsesStdio) {
300
+ stdioStdin.set(dbKey, child.stdin);
301
+ child.stdin.on("error", (err) => {
302
+ if (err.code !== "EPIPE") {
303
+ console.error(`[${plugin.name}] stdin error:`, err.message);
304
+ }
305
+ });
306
+ }
307
+ plugins[plugin.name] = {
308
+ process: child,
309
+ ...await (pluginUsesStdio ? wait_for_plugin_stdio(plugin.name, child) : wait_for_plugin_db(plugin.name, dbKey))
310
+ };
311
+ logger.timeEnd(`Spawn ${plugin.name}`, LogLevel.Verbose);
312
+ })
313
+ );
314
+ for (const plugin of config.plugins) {
315
+ plugin_specs.push(spec_results[plugin.name]);
316
+ }
317
+ logger.timeEnd("Start Plugins", LogLevel.Summary);
318
+ const wsConnections = /* @__PURE__ */ new Map();
319
+ let messageCounter = 0;
320
+ async function getOrCreateWS(name, port) {
321
+ const existing = wsConnections.get(name);
322
+ if (existing && existing.readyState === WebSocket.OPEN) {
323
+ return existing;
324
+ }
325
+ return new Promise((resolve, reject) => {
326
+ const wsUrl = `ws://localhost:${port}/ws`;
327
+ const ws = new WebSocket(wsUrl);
328
+ ws.on("open", () => {
329
+ wsConnections.set(name, ws);
330
+ return resolve(ws);
331
+ });
332
+ ws.on("message", (data) => {
333
+ try {
334
+ const response = JSON.parse(data.toString());
335
+ const pending = pendingRequests.get(response.id);
336
+ if (!pending) return;
337
+ clearTimeout(pending.timeout);
338
+ pendingRequests.delete(response.id);
339
+ switch (response.type) {
340
+ case "error":
341
+ console.error(`! [${name}] ${response.error}`);
342
+ pending.reject(new Error(`${name}: ${response.error}`));
343
+ break;
344
+ case "response":
345
+ if (response.error) {
346
+ const errors = Array.isArray(response.error) ? response.error : [response.error];
347
+ errors.forEach((error) => {
348
+ format_hook_error(config.root_dir, error, name, pending.hook);
349
+ });
350
+ pending.reject(new Error(`Failed to call ${name}`));
351
+ } else {
352
+ pending.resolve(response.result);
353
+ }
354
+ break;
355
+ default:
356
+ console.warn(`[${name}] Unknown message type: ${response.type}`);
357
+ pending.reject(new Error(`Unknown message type: ${response.type}`));
358
+ }
359
+ } catch (err) {
360
+ console.error(`Error processing WebSocket message for ${name}:`, err);
361
+ }
362
+ });
363
+ ws.on("error", (err) => {
364
+ console.error(`WebSocket error for ${name}:`, err);
365
+ wsConnections.delete(name);
366
+ reject(new Error(`WebSocket error for ${name}: ${err}`));
367
+ });
368
+ ws.on("close", () => {
369
+ wsConnections.delete(name);
370
+ });
371
+ });
372
+ }
373
+ const invoke_hook = async (name, hook, payload = {}, task_id) => {
374
+ const plugin = plugin_specs.find((spec) => spec.name === name);
375
+ if (!plugin) {
376
+ throw new Error(`unknown plugin: ${name}`);
377
+ }
378
+ const { port, directory } = plugin;
379
+ const messageId = String(++messageCounter);
380
+ const message = {
381
+ id: messageId,
382
+ type: "request",
383
+ hook,
384
+ payload,
385
+ taskId: task_id,
386
+ pluginDirectory: directory
387
+ };
388
+ if (useStdio) {
389
+ const stdin = stdioStdin.get(name);
390
+ if (!stdin) {
391
+ throw new Error(`No stdio channel for plugin ${name}`);
392
+ }
393
+ return new Promise((resolve, reject) => {
394
+ const timeout = setTimeout(() => {
395
+ pendingRequests.delete(messageId);
396
+ reject(new Error(`Request timeout for ${name}/${hook}`));
397
+ }, 3e4);
398
+ pendingRequests.set(messageId, { resolve, reject, timeout, hook, plugin: name });
399
+ stdin.write(`${JSON.stringify(message)}
400
+ `);
401
+ });
402
+ } else {
403
+ const ws = await getOrCreateWS(name, port);
404
+ return new Promise((resolve, reject) => {
405
+ const timeout = setTimeout(() => {
406
+ pendingRequests.delete(messageId);
407
+ reject(new Error(`WebSocket request timeout for ${name}/${hook}`));
408
+ }, 3e4);
409
+ pendingRequests.set(messageId, { resolve, reject, timeout, hook, plugin: name });
410
+ ws.send(JSON.stringify(message));
411
+ });
412
+ }
413
+ };
414
+ _db.reload();
415
+ const _fireHook = async (hook, {
416
+ parallel_safe,
417
+ payload,
418
+ task_id
419
+ } = {}) => {
420
+ const timeName = hook + (task_id ? ` (${task_id})` : "");
421
+ logger.time(timeName);
422
+ const plugins2 = plugin_specs.filter(({ hooks }) => hooks.has(hook));
423
+ const result = {};
424
+ try {
425
+ if (parallel_safe) {
426
+ await Promise.all(
427
+ plugins2.map(async (plugin) => {
428
+ result[plugin.name] = await invoke_hook(plugin.name, hook, payload, task_id);
429
+ })
430
+ );
431
+ } else {
432
+ for (const { name } of plugins2) {
433
+ result[name] = await invoke_hook(name, hook, payload, task_id);
434
+ }
435
+ }
436
+ } finally {
437
+ logger.timeEnd(timeName, task_id ? LogLevel.Verbose : LogLevel.Summary);
438
+ }
439
+ return result;
440
+ };
441
+ const trigger_hook = async (hook, opts) => {
442
+ _db.flush();
443
+ const result = await _fireHook(hook, opts);
444
+ _db.reload();
445
+ return result;
446
+ };
447
+ triggerHookRef.fn = trigger_hook;
448
+ await write_config(_db, config, invoke_hook, plugin_specs, mode, logger);
449
+ _db.flush();
450
+ await trigger_hook("Config");
451
+ await trigger_hook("AfterLoad");
452
+ await trigger_hook("Schema");
453
+ let pipelineQueue = Promise.resolve();
454
+ return {
455
+ database_path: db_file,
456
+ trigger_hook,
457
+ run_pipeline: (options) => run_pipeline(trigger_hook, options),
458
+ pipeline_lock: (fn) => {
459
+ const result = pipelineQueue.then(fn);
460
+ pipelineQueue = result.then(
461
+ () => {
462
+ },
463
+ () => {
464
+ }
465
+ );
466
+ return result;
467
+ },
468
+ close: async () => {
469
+ for (const [name, ws] of wsConnections.entries()) {
470
+ try {
471
+ if (ws.readyState === WebSocket.OPEN) {
472
+ ws.close(1001, "shutdown");
473
+ }
474
+ } catch (err) {
475
+ console.error(`Error closing WebSocket for ${name}:`, err);
476
+ }
477
+ }
478
+ wsConnections.clear();
479
+ for (const [, stdin] of stdioStdin.entries()) {
480
+ try {
481
+ stdin.end();
482
+ } catch {
483
+ }
484
+ }
485
+ stdioStdin.clear();
486
+ for (const [, { timeout, reject }] of pendingRequests.entries()) {
487
+ clearTimeout(timeout);
488
+ reject(new Error("codegen closed"));
489
+ }
490
+ pendingRequests.clear();
491
+ await new Promise((resolve) => setTimeout(resolve, 100));
492
+ try {
493
+ db.close();
494
+ } catch {
495
+ }
496
+ await Promise.all(
497
+ Object.entries(plugins).map(async ([, plugin]) => {
498
+ if (plugin.process.pid) {
499
+ if (process.platform === "win32") {
500
+ try {
501
+ spawn("taskkill", [
502
+ "/pid",
503
+ plugin.process.pid.toString(),
504
+ "/f",
505
+ "/t"
506
+ ]);
507
+ } catch (_err) {
508
+ }
509
+ } else {
510
+ try {
511
+ process.kill(plugin.process.pid, 0);
512
+ process.kill(-plugin.process.pid, "SIGINT");
513
+ } catch {
514
+ }
515
+ }
516
+ }
517
+ })
518
+ );
519
+ }
520
+ };
521
+ }
522
+ const PIPELINE_HOOKS = [
523
+ "Config",
524
+ "AfterLoad",
525
+ "Schema",
526
+ "ExtractDocuments",
527
+ "AfterExtract",
528
+ "BeforeValidate",
529
+ "Validate",
530
+ "AfterValidate",
531
+ "BeforeGenerate",
532
+ "GenerateDocuments",
533
+ "GenerateRuntime",
534
+ "AfterGenerate"
535
+ ];
536
+ async function run_pipeline(trigger_hook, options = {}) {
537
+ const { task_id, after, start, through } = options;
538
+ const results = {};
539
+ let startIndex = 0;
540
+ let endIndex = PIPELINE_HOOKS.length - 1;
541
+ if (after) {
542
+ const afterIndex = PIPELINE_HOOKS.indexOf(after);
543
+ if (afterIndex === -1) {
544
+ throw new Error(`Unknown hook: ${after}`);
545
+ }
546
+ startIndex = afterIndex + 1;
547
+ }
548
+ if (start) {
549
+ const index = PIPELINE_HOOKS.indexOf(start);
550
+ if (index === -1) {
551
+ throw new Error(`Unknown hook: ${after}`);
552
+ }
553
+ startIndex = index;
554
+ }
555
+ if (through) {
556
+ endIndex = PIPELINE_HOOKS.indexOf(through);
557
+ if (endIndex === -1) {
558
+ throw new Error(`Unknown hook: ${through}`);
559
+ }
560
+ }
561
+ if (startIndex > endIndex) {
562
+ return results;
563
+ }
564
+ for (let i = startIndex; i <= endIndex; i++) {
565
+ const hook = PIPELINE_HOOKS[i];
566
+ const opts = { task_id };
567
+ if (hook === "Validate" || hook === "GenerateDocuments") {
568
+ opts.parallel_safe = true;
569
+ }
570
+ if (hook === "GenerateDocuments" && i + 1 <= endIndex && PIPELINE_HOOKS[i + 1] === "GenerateRuntime") {
571
+ const [gdResult, grResult] = await Promise.all([
572
+ trigger_hook("GenerateDocuments", { task_id, parallel_safe: true }),
573
+ trigger_hook("GenerateRuntime", { task_id })
574
+ ]);
575
+ results.GenerateDocuments = gdResult;
576
+ results.GenerateRuntime = grResult;
577
+ i++;
578
+ continue;
579
+ }
580
+ results[hook] = await trigger_hook(hook, opts);
581
+ }
582
+ return results;
583
+ }
584
+ export {
585
+ PIPELINE_HOOKS,
586
+ codegen_setup,
587
+ connect_db,
588
+ init_db,
589
+ plugin_db_key,
590
+ run_pipeline
591
+ };