@supatype/cli 0.7.0 → 0.9.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 (671) hide show
  1. package/CHANGELOG.md +314 -0
  2. package/bin/supatype.js +40 -4
  3. package/deno.d.ts +1 -1
  4. package/dist/admin-prompt-state.d.ts +13 -0
  5. package/dist/admin-prompt-state.d.ts.map +1 -0
  6. package/dist/admin-prompt-state.js +30 -0
  7. package/dist/admin-prompt-state.js.map +1 -0
  8. package/dist/adopt-columns.d.ts.map +1 -1
  9. package/dist/adopt-columns.js +13 -17
  10. package/dist/adopt-columns.js.map +1 -1
  11. package/dist/after-hooks-health.d.ts +19 -0
  12. package/dist/after-hooks-health.d.ts.map +1 -0
  13. package/dist/after-hooks-health.js +69 -0
  14. package/dist/after-hooks-health.js.map +1 -0
  15. package/dist/app-config.d.ts +1 -1
  16. package/dist/app-config.d.ts.map +1 -1
  17. package/dist/app-config.js +103 -144
  18. package/dist/app-config.js.map +1 -1
  19. package/dist/app-vite-env.d.ts +5 -1
  20. package/dist/app-vite-env.d.ts.map +1 -1
  21. package/dist/app-vite-env.js +9 -15
  22. package/dist/app-vite-env.js.map +1 -1
  23. package/dist/applied-ast-artifacts.d.ts +16 -0
  24. package/dist/applied-ast-artifacts.d.ts.map +1 -0
  25. package/dist/applied-ast-artifacts.js +37 -0
  26. package/dist/applied-ast-artifacts.js.map +1 -0
  27. package/dist/archive-extract.d.ts +3 -0
  28. package/dist/archive-extract.d.ts.map +1 -0
  29. package/dist/archive-extract.js +19 -0
  30. package/dist/archive-extract.js.map +1 -0
  31. package/dist/augmentation-generator.d.ts +5 -0
  32. package/dist/augmentation-generator.d.ts.map +1 -1
  33. package/dist/augmentation-generator.js +13 -4
  34. package/dist/augmentation-generator.js.map +1 -1
  35. package/dist/binary-cache.d.ts +27 -3
  36. package/dist/binary-cache.d.ts.map +1 -1
  37. package/dist/binary-cache.js +117 -85
  38. package/dist/binary-cache.js.map +1 -1
  39. package/dist/binary-download-lock.d.ts.map +1 -1
  40. package/dist/binary-download-lock.js +1 -3
  41. package/dist/binary-download-lock.js.map +1 -1
  42. package/dist/byo-preflight.d.ts.map +1 -1
  43. package/dist/byo-preflight.js +2 -10
  44. package/dist/byo-preflight.js.map +1 -1
  45. package/dist/byte-size.d.ts +9 -0
  46. package/dist/byte-size.d.ts.map +1 -0
  47. package/dist/byte-size.js +36 -0
  48. package/dist/byte-size.js.map +1 -0
  49. package/dist/cache-clean.d.ts +0 -2
  50. package/dist/cache-clean.d.ts.map +1 -1
  51. package/dist/cache-clean.js +1 -27
  52. package/dist/cache-clean.js.map +1 -1
  53. package/dist/cache-pins.d.ts.map +1 -1
  54. package/dist/cache-pins.js +3 -20
  55. package/dist/cache-pins.js.map +1 -1
  56. package/dist/cache-root.d.ts +7 -0
  57. package/dist/cache-root.d.ts.map +1 -0
  58. package/dist/cache-root.js +11 -0
  59. package/dist/cache-root.js.map +1 -0
  60. package/dist/cli-artifacts.d.ts.map +1 -1
  61. package/dist/cli-artifacts.js +2 -1
  62. package/dist/cli-artifacts.js.map +1 -1
  63. package/dist/cli-install-method.d.ts.map +1 -1
  64. package/dist/cli-install-method.js +7 -1
  65. package/dist/cli-install-method.js.map +1 -1
  66. package/dist/cli-launcher.d.ts +21 -0
  67. package/dist/cli-launcher.d.ts.map +1 -0
  68. package/dist/cli-launcher.js +112 -0
  69. package/dist/cli-launcher.js.map +1 -0
  70. package/dist/cli-old-versions.d.ts +44 -0
  71. package/dist/cli-old-versions.d.ts.map +1 -0
  72. package/dist/cli-old-versions.js +83 -0
  73. package/dist/cli-old-versions.js.map +1 -0
  74. package/dist/cli-program-path.d.ts +20 -0
  75. package/dist/cli-program-path.d.ts.map +1 -0
  76. package/dist/cli-program-path.js +41 -0
  77. package/dist/cli-program-path.js.map +1 -0
  78. package/dist/cli-standalone.d.ts +2 -3
  79. package/dist/cli-standalone.d.ts.map +1 -1
  80. package/dist/cli-standalone.js +51 -24
  81. package/dist/cli-standalone.js.map +1 -1
  82. package/dist/cli-version-embedded.js +1 -1
  83. package/dist/cloud-credentials.d.ts +6 -0
  84. package/dist/cloud-credentials.d.ts.map +1 -1
  85. package/dist/cloud-credentials.js +13 -0
  86. package/dist/cloud-credentials.js.map +1 -1
  87. package/dist/commands/admin.d.ts.map +1 -1
  88. package/dist/commands/admin.js +18 -18
  89. package/dist/commands/admin.js.map +1 -1
  90. package/dist/commands/app.d.ts.map +1 -1
  91. package/dist/commands/app.js +27 -8
  92. package/dist/commands/app.js.map +1 -1
  93. package/dist/commands/cache.d.ts.map +1 -1
  94. package/dist/commands/cache.js +37 -11
  95. package/dist/commands/cache.js.map +1 -1
  96. package/dist/commands/cloud.js +2 -4
  97. package/dist/commands/cloud.js.map +1 -1
  98. package/dist/commands/db.d.ts.map +1 -1
  99. package/dist/commands/db.js +116 -106
  100. package/dist/commands/db.js.map +1 -1
  101. package/dist/commands/deploy.d.ts.map +1 -1
  102. package/dist/commands/deploy.js +3 -3
  103. package/dist/commands/deploy.js.map +1 -1
  104. package/dist/commands/dev.d.ts +50 -4
  105. package/dist/commands/dev.d.ts.map +1 -1
  106. package/dist/commands/dev.js +276 -267
  107. package/dist/commands/dev.js.map +1 -1
  108. package/dist/commands/doctor.d.ts +32 -0
  109. package/dist/commands/doctor.d.ts.map +1 -1
  110. package/dist/commands/doctor.js +66 -1
  111. package/dist/commands/doctor.js.map +1 -1
  112. package/dist/commands/functions.d.ts +30 -0
  113. package/dist/commands/functions.d.ts.map +1 -1
  114. package/dist/commands/functions.js +503 -507
  115. package/dist/commands/functions.js.map +1 -1
  116. package/dist/commands/generate.d.ts.map +1 -1
  117. package/dist/commands/generate.js +11 -8
  118. package/dist/commands/generate.js.map +1 -1
  119. package/dist/commands/hooks.d.ts.map +1 -1
  120. package/dist/commands/hooks.js +46 -23
  121. package/dist/commands/hooks.js.map +1 -1
  122. package/dist/commands/init.d.ts +37 -4
  123. package/dist/commands/init.d.ts.map +1 -1
  124. package/dist/commands/init.js +509 -386
  125. package/dist/commands/init.js.map +1 -1
  126. package/dist/commands/internal.d.ts.map +1 -1
  127. package/dist/commands/internal.js +2 -1
  128. package/dist/commands/internal.js.map +1 -1
  129. package/dist/commands/keys.d.ts +46 -20
  130. package/dist/commands/keys.d.ts.map +1 -1
  131. package/dist/commands/keys.js +196 -156
  132. package/dist/commands/keys.js.map +1 -1
  133. package/dist/commands/link-helpers.d.ts.map +1 -1
  134. package/dist/commands/link-helpers.js +30 -11
  135. package/dist/commands/link-helpers.js.map +1 -1
  136. package/dist/commands/logs.d.ts.map +1 -1
  137. package/dist/commands/logs.js +5 -4
  138. package/dist/commands/logs.js.map +1 -1
  139. package/dist/commands/migrate.js +1 -1
  140. package/dist/commands/migrate.js.map +1 -1
  141. package/dist/commands/pg.js +2 -0
  142. package/dist/commands/pg.js.map +1 -1
  143. package/dist/commands/plugins.d.ts.map +1 -1
  144. package/dist/commands/plugins.js +17 -7
  145. package/dist/commands/plugins.js.map +1 -1
  146. package/dist/commands/push.d.ts +39 -0
  147. package/dist/commands/push.d.ts.map +1 -1
  148. package/dist/commands/push.js +221 -77
  149. package/dist/commands/push.js.map +1 -1
  150. package/dist/commands/seed.d.ts +35 -0
  151. package/dist/commands/seed.d.ts.map +1 -1
  152. package/dist/commands/seed.js +72 -38
  153. package/dist/commands/seed.js.map +1 -1
  154. package/dist/commands/self-host.d.ts.map +1 -1
  155. package/dist/commands/self-host.js +71 -42
  156. package/dist/commands/self-host.js.map +1 -1
  157. package/dist/commands/self-update.d.ts.map +1 -1
  158. package/dist/commands/self-update.js +9 -3
  159. package/dist/commands/self-update.js.map +1 -1
  160. package/dist/commands/status.js +5 -5
  161. package/dist/commands/status.js.map +1 -1
  162. package/dist/commands/types.js +2 -5
  163. package/dist/commands/types.js.map +1 -1
  164. package/dist/commands/update.d.ts.map +1 -1
  165. package/dist/commands/update.js +212 -101
  166. package/dist/commands/update.js.map +1 -1
  167. package/dist/component-launch.d.ts +11 -0
  168. package/dist/component-launch.d.ts.map +1 -0
  169. package/dist/component-launch.js +35 -0
  170. package/dist/component-launch.js.map +1 -0
  171. package/dist/components.d.ts +7 -2
  172. package/dist/components.d.ts.map +1 -1
  173. package/dist/components.js +7 -2
  174. package/dist/components.js.map +1 -1
  175. package/dist/compose-db-roles.d.ts.map +1 -1
  176. package/dist/compose-db-roles.js +5 -14
  177. package/dist/compose-db-roles.js.map +1 -1
  178. package/dist/compose-engine-run.d.ts +6 -5
  179. package/dist/compose-engine-run.d.ts.map +1 -1
  180. package/dist/compose-engine-run.js +44 -37
  181. package/dist/compose-engine-run.js.map +1 -1
  182. package/dist/compose-engine-service.d.ts +10 -0
  183. package/dist/compose-engine-service.d.ts.map +1 -0
  184. package/dist/compose-engine-service.js +16 -0
  185. package/dist/compose-engine-service.js.map +1 -0
  186. package/dist/compose-host-path.d.ts +14 -0
  187. package/dist/compose-host-path.d.ts.map +1 -0
  188. package/dist/compose-host-path.js +18 -0
  189. package/dist/compose-host-path.js.map +1 -0
  190. package/dist/compose-image-pull.d.ts +43 -0
  191. package/dist/compose-image-pull.d.ts.map +1 -0
  192. package/dist/compose-image-pull.js +27 -0
  193. package/dist/compose-image-pull.js.map +1 -0
  194. package/dist/compose-kong.d.ts +4 -0
  195. package/dist/compose-kong.d.ts.map +1 -1
  196. package/dist/compose-kong.js +23 -9
  197. package/dist/compose-kong.js.map +1 -1
  198. package/dist/compose-local-server-image.d.ts.map +1 -1
  199. package/dist/compose-local-server-image.js +7 -3
  200. package/dist/compose-local-server-image.js.map +1 -1
  201. package/dist/compose-render-mode.d.ts.map +1 -1
  202. package/dist/compose-render-mode.js +7 -4
  203. package/dist/compose-render-mode.js.map +1 -1
  204. package/dist/compose-services.d.ts +12 -2
  205. package/dist/compose-services.d.ts.map +1 -1
  206. package/dist/compose-services.js +27 -12
  207. package/dist/compose-services.js.map +1 -1
  208. package/dist/config-snapshot.d.ts +6 -0
  209. package/dist/config-snapshot.d.ts.map +1 -0
  210. package/dist/config-snapshot.js +23 -0
  211. package/dist/config-snapshot.js.map +1 -0
  212. package/dist/config.d.ts +11 -1
  213. package/dist/config.d.ts.map +1 -1
  214. package/dist/config.js +20 -3
  215. package/dist/config.js.map +1 -1
  216. package/dist/database-url-owner.d.ts +59 -0
  217. package/dist/database-url-owner.d.ts.map +1 -0
  218. package/dist/database-url-owner.js +133 -0
  219. package/dist/database-url-owner.js.map +1 -0
  220. package/dist/db-port-offer.d.ts +18 -0
  221. package/dist/db-port-offer.d.ts.map +1 -0
  222. package/dist/db-port-offer.js +68 -0
  223. package/dist/db-port-offer.js.map +1 -0
  224. package/dist/db-port.d.ts +42 -18
  225. package/dist/db-port.d.ts.map +1 -1
  226. package/dist/db-port.js +34 -32
  227. package/dist/db-port.js.map +1 -1
  228. package/dist/db-preflight.d.ts +37 -0
  229. package/dist/db-preflight.d.ts.map +1 -1
  230. package/dist/db-preflight.js +219 -77
  231. package/dist/db-preflight.js.map +1 -1
  232. package/dist/db-rows.d.ts +11 -0
  233. package/dist/db-rows.d.ts.map +1 -1
  234. package/dist/db-rows.js +27 -0
  235. package/dist/db-rows.js.map +1 -1
  236. package/dist/debounce.d.ts +11 -0
  237. package/dist/debounce.d.ts.map +1 -0
  238. package/dist/debounce.js +23 -0
  239. package/dist/debounce.js.map +1 -0
  240. package/dist/dev-api-keys.d.ts +12 -2
  241. package/dist/dev-api-keys.d.ts.map +1 -1
  242. package/dist/dev-api-keys.js +33 -17
  243. package/dist/dev-api-keys.js.map +1 -1
  244. package/dist/dev-compose.d.ts +10 -12
  245. package/dist/dev-compose.d.ts.map +1 -1
  246. package/dist/dev-compose.js +252 -288
  247. package/dist/dev-compose.js.map +1 -1
  248. package/dist/dev-db-ready.d.ts.map +1 -1
  249. package/dist/dev-db-ready.js +2 -1
  250. package/dist/dev-db-ready.js.map +1 -1
  251. package/dist/dev-db-reset.d.ts.map +1 -1
  252. package/dist/dev-db-reset.js +5 -4
  253. package/dist/dev-db-reset.js.map +1 -1
  254. package/dist/dev-functions-watch.d.ts.map +1 -1
  255. package/dist/dev-functions-watch.js +5 -16
  256. package/dist/dev-functions-watch.js.map +1 -1
  257. package/dist/dev-log-bus.d.ts +8 -0
  258. package/dist/dev-log-bus.d.ts.map +1 -1
  259. package/dist/dev-log-bus.js +13 -0
  260. package/dist/dev-log-bus.js.map +1 -1
  261. package/dist/dev-ports.d.ts +27 -7
  262. package/dist/dev-ports.d.ts.map +1 -1
  263. package/dist/dev-ports.js +68 -41
  264. package/dist/dev-ports.js.map +1 -1
  265. package/dist/dev-schema-watch.d.ts.map +1 -1
  266. package/dist/dev-schema-watch.js +7 -12
  267. package/dist/dev-schema-watch.js.map +1 -1
  268. package/dist/dev-session-lock.js +4 -3
  269. package/dist/dev-session-lock.js.map +1 -1
  270. package/dist/dev-session.d.ts +15 -0
  271. package/dist/dev-session.d.ts.map +1 -1
  272. package/dist/dev-session.js +27 -1
  273. package/dist/dev-session.js.map +1 -1
  274. package/dist/dev-shutdown.d.ts +45 -0
  275. package/dist/dev-shutdown.d.ts.map +1 -1
  276. package/dist/dev-shutdown.js +221 -33
  277. package/dist/dev-shutdown.js.map +1 -1
  278. package/dist/diff-output.d.ts +7 -1
  279. package/dist/diff-output.d.ts.map +1 -1
  280. package/dist/diff-output.js +91 -2
  281. package/dist/diff-output.js.map +1 -1
  282. package/dist/docker-address-pool.d.ts +23 -0
  283. package/dist/docker-address-pool.d.ts.map +1 -0
  284. package/dist/docker-address-pool.js +56 -0
  285. package/dist/docker-address-pool.js.map +1 -0
  286. package/dist/docker-exec.d.ts +92 -0
  287. package/dist/docker-exec.d.ts.map +1 -0
  288. package/dist/docker-exec.js +139 -0
  289. package/dist/docker-exec.js.map +1 -0
  290. package/dist/docker-postgres.d.ts +1 -6
  291. package/dist/docker-postgres.d.ts.map +1 -1
  292. package/dist/docker-postgres.js +67 -85
  293. package/dist/docker-postgres.js.map +1 -1
  294. package/dist/docker-runtime.d.ts +14 -1
  295. package/dist/docker-runtime.d.ts.map +1 -1
  296. package/dist/docker-runtime.js +55 -24
  297. package/dist/docker-runtime.js.map +1 -1
  298. package/dist/dotenv-parse.d.ts +22 -0
  299. package/dist/dotenv-parse.d.ts.map +1 -0
  300. package/dist/dotenv-parse.js +63 -0
  301. package/dist/dotenv-parse.js.map +1 -0
  302. package/dist/engine-answers.d.ts +0 -2
  303. package/dist/engine-answers.d.ts.map +1 -1
  304. package/dist/engine-answers.js +4 -3
  305. package/dist/engine-answers.js.map +1 -1
  306. package/dist/engine-client.d.ts.map +1 -1
  307. package/dist/engine-client.js +13 -12
  308. package/dist/engine-client.js.map +1 -1
  309. package/dist/engine-floor.d.ts +29 -0
  310. package/dist/engine-floor.d.ts.map +1 -1
  311. package/dist/engine-floor.js +56 -0
  312. package/dist/engine-floor.js.map +1 -1
  313. package/dist/engine-ownership-gate.d.ts +13 -1
  314. package/dist/engine-ownership-gate.d.ts.map +1 -1
  315. package/dist/engine-ownership-gate.js +36 -6
  316. package/dist/engine-ownership-gate.js.map +1 -1
  317. package/dist/ensure-binary.d.ts +9 -0
  318. package/dist/ensure-binary.d.ts.map +1 -1
  319. package/dist/ensure-binary.js +38 -5
  320. package/dist/ensure-binary.js.map +1 -1
  321. package/dist/ensure-component-binaries.d.ts.map +1 -1
  322. package/dist/ensure-component-binaries.js +2 -1
  323. package/dist/ensure-component-binaries.js.map +1 -1
  324. package/dist/env-file.d.ts +30 -8
  325. package/dist/env-file.d.ts.map +1 -1
  326. package/dist/env-file.js +84 -57
  327. package/dist/env-file.js.map +1 -1
  328. package/dist/env-lines.d.ts +11 -0
  329. package/dist/env-lines.d.ts.map +1 -0
  330. package/dist/env-lines.js +36 -0
  331. package/dist/env-lines.js.map +1 -0
  332. package/dist/error-message.d.ts +34 -1
  333. package/dist/error-message.d.ts.map +1 -1
  334. package/dist/error-message.js +102 -2
  335. package/dist/error-message.js.map +1 -1
  336. package/dist/fetch-within.d.ts +10 -0
  337. package/dist/fetch-within.d.ts.map +1 -0
  338. package/dist/fetch-within.js +12 -0
  339. package/dist/fetch-within.js.map +1 -0
  340. package/dist/field-masking-tier.d.ts.map +1 -1
  341. package/dist/field-masking-tier.js +7 -5
  342. package/dist/field-masking-tier.js.map +1 -1
  343. package/dist/frontend-env.d.ts +43 -0
  344. package/dist/frontend-env.d.ts.map +1 -0
  345. package/dist/frontend-env.js +81 -0
  346. package/dist/frontend-env.js.map +1 -0
  347. package/dist/functions-context-refresh.d.ts +6 -2
  348. package/dist/functions-context-refresh.d.ts.map +1 -1
  349. package/dist/functions-context-refresh.js +11 -3
  350. package/dist/functions-context-refresh.js.map +1 -1
  351. package/dist/functions-deno-types.d.ts.map +1 -1
  352. package/dist/functions-deno-types.js +9 -2
  353. package/dist/functions-deno-types.js.map +1 -1
  354. package/dist/{functions-router-gen.d.ts → functions-discovery.d.ts} +8 -10
  355. package/dist/functions-discovery.d.ts.map +1 -0
  356. package/dist/functions-discovery.js +87 -0
  357. package/dist/functions-discovery.js.map +1 -0
  358. package/dist/functions-template.d.ts.map +1 -1
  359. package/dist/functions-template.js +20 -12
  360. package/dist/functions-template.js.map +1 -1
  361. package/dist/functions-worker-files.d.ts +55 -0
  362. package/dist/functions-worker-files.d.ts.map +1 -0
  363. package/dist/functions-worker-files.js +149 -0
  364. package/dist/functions-worker-files.js.map +1 -0
  365. package/dist/generated/functions-worker-source.d.ts +2 -0
  366. package/dist/generated/functions-worker-source.d.ts.map +1 -0
  367. package/dist/generated/functions-worker-source.js +12 -0
  368. package/dist/generated/functions-worker-source.js.map +1 -0
  369. package/dist/generated/release-images.d.ts +18 -0
  370. package/dist/generated/release-images.d.ts.map +1 -0
  371. package/dist/generated/release-images.js +8 -0
  372. package/dist/generated/release-images.js.map +1 -0
  373. package/dist/generated-files-engine.d.ts +33 -0
  374. package/dist/generated-files-engine.d.ts.map +1 -0
  375. package/dist/generated-files-engine.js +45 -0
  376. package/dist/generated-files-engine.js.map +1 -0
  377. package/dist/hook-actor.d.ts +17 -0
  378. package/dist/hook-actor.d.ts.map +1 -0
  379. package/dist/hook-actor.js +37 -0
  380. package/dist/hook-actor.js.map +1 -0
  381. package/dist/hook-columns.d.ts +30 -0
  382. package/dist/hook-columns.d.ts.map +1 -0
  383. package/dist/hook-columns.js +77 -0
  384. package/dist/hook-columns.js.map +1 -0
  385. package/dist/hook-events.d.ts +11 -0
  386. package/dist/hook-events.d.ts.map +1 -0
  387. package/dist/hook-events.js +11 -0
  388. package/dist/hook-events.js.map +1 -0
  389. package/dist/hook-upload.d.ts +29 -15
  390. package/dist/hook-upload.d.ts.map +1 -1
  391. package/dist/hook-upload.js +88 -59
  392. package/dist/hook-upload.js.map +1 -1
  393. package/dist/hooks-generator.d.ts +5 -0
  394. package/dist/hooks-generator.d.ts.map +1 -1
  395. package/dist/hooks-generator.js +92 -21
  396. package/dist/hooks-generator.js.map +1 -1
  397. package/dist/host-database.d.ts.map +1 -1
  398. package/dist/host-database.js +31 -4
  399. package/dist/host-database.js.map +1 -1
  400. package/dist/init-dependency-versions.d.ts +3 -1
  401. package/dist/init-dependency-versions.d.ts.map +1 -1
  402. package/dist/init-dependency-versions.js +32 -6
  403. package/dist/init-dependency-versions.js.map +1 -1
  404. package/dist/init-example.d.ts +48 -0
  405. package/dist/init-example.d.ts.map +1 -0
  406. package/dist/init-example.js +110 -0
  407. package/dist/init-example.js.map +1 -0
  408. package/dist/init-package-json.d.ts +38 -1
  409. package/dist/init-package-json.d.ts.map +1 -1
  410. package/dist/init-package-json.js +150 -37
  411. package/dist/init-package-json.js.map +1 -1
  412. package/dist/init-setup-steps.d.ts +37 -0
  413. package/dist/init-setup-steps.d.ts.map +1 -0
  414. package/dist/init-setup-steps.js +118 -0
  415. package/dist/init-setup-steps.js.map +1 -0
  416. package/dist/jwt-secret-length.d.ts +5 -13
  417. package/dist/jwt-secret-length.d.ts.map +1 -1
  418. package/dist/jwt-secret-length.js +7 -22
  419. package/dist/jwt-secret-length.js.map +1 -1
  420. package/dist/jwt-secret-rules.d.ts +24 -0
  421. package/dist/jwt-secret-rules.d.ts.map +1 -0
  422. package/dist/jwt-secret-rules.js +46 -0
  423. package/dist/jwt-secret-rules.js.map +1 -0
  424. package/dist/local-gateway.d.ts +3 -6
  425. package/dist/local-gateway.d.ts.map +1 -1
  426. package/dist/local-gateway.js +7 -9
  427. package/dist/local-gateway.js.map +1 -1
  428. package/dist/local-secrets.d.ts +95 -11
  429. package/dist/local-secrets.d.ts.map +1 -1
  430. package/dist/local-secrets.js +153 -18
  431. package/dist/local-secrets.js.map +1 -1
  432. package/dist/local-stack.d.ts.map +1 -1
  433. package/dist/local-stack.js +2 -7
  434. package/dist/local-stack.js.map +1 -1
  435. package/dist/local-storage.d.ts +7 -2
  436. package/dist/local-storage.d.ts.map +1 -1
  437. package/dist/local-storage.js +11 -3
  438. package/dist/local-storage.js.map +1 -1
  439. package/dist/mailer-env.d.ts +37 -0
  440. package/dist/mailer-env.d.ts.map +1 -0
  441. package/dist/mailer-env.js +98 -0
  442. package/dist/mailer-env.js.map +1 -0
  443. package/dist/model-cache.d.ts +4 -8
  444. package/dist/model-cache.d.ts.map +1 -1
  445. package/dist/model-cache.js.map +1 -1
  446. package/dist/model-hooks.d.ts +21 -7
  447. package/dist/model-hooks.d.ts.map +1 -1
  448. package/dist/model-hooks.js +62 -39
  449. package/dist/model-hooks.js.map +1 -1
  450. package/dist/native-dev-env.d.ts +37 -1
  451. package/dist/native-dev-env.d.ts.map +1 -1
  452. package/dist/native-dev-env.js +64 -2
  453. package/dist/native-dev-env.js.map +1 -1
  454. package/dist/native-functions-watch.d.ts +56 -5
  455. package/dist/native-functions-watch.d.ts.map +1 -1
  456. package/dist/native-functions-watch.js +119 -38
  457. package/dist/native-functions-watch.js.map +1 -1
  458. package/dist/native-keyspace.d.ts.map +1 -1
  459. package/dist/native-keyspace.js +2 -2
  460. package/dist/native-keyspace.js.map +1 -1
  461. package/dist/native-realtime.d.ts +11 -3
  462. package/dist/native-realtime.d.ts.map +1 -1
  463. package/dist/native-realtime.js +162 -10
  464. package/dist/native-realtime.js.map +1 -1
  465. package/dist/native-roles-sql.d.ts +14 -0
  466. package/dist/native-roles-sql.d.ts.map +1 -1
  467. package/dist/native-roles-sql.js +82 -1
  468. package/dist/native-roles-sql.js.map +1 -1
  469. package/dist/native-storage-import.d.ts +19 -0
  470. package/dist/native-storage-import.d.ts.map +1 -0
  471. package/dist/native-storage-import.js +327 -0
  472. package/dist/native-storage-import.js.map +1 -0
  473. package/dist/native-storage.d.ts +45 -0
  474. package/dist/native-storage.d.ts.map +1 -0
  475. package/dist/native-storage.js +140 -0
  476. package/dist/native-storage.js.map +1 -0
  477. package/dist/native-worker.d.ts +26 -0
  478. package/dist/native-worker.d.ts.map +1 -0
  479. package/dist/native-worker.js +63 -0
  480. package/dist/native-worker.js.map +1 -0
  481. package/dist/owner-default.d.ts +9 -1
  482. package/dist/owner-default.d.ts.map +1 -1
  483. package/dist/owner-default.js +17 -4
  484. package/dist/owner-default.js.map +1 -1
  485. package/dist/post-apply.d.ts +3 -0
  486. package/dist/post-apply.d.ts.map +1 -0
  487. package/dist/post-apply.js +17 -0
  488. package/dist/post-apply.js.map +1 -0
  489. package/dist/postgres-ctl.d.ts +98 -7
  490. package/dist/postgres-ctl.d.ts.map +1 -1
  491. package/dist/postgres-ctl.js +273 -40
  492. package/dist/postgres-ctl.js.map +1 -1
  493. package/dist/postgres-image.d.ts +15 -3
  494. package/dist/postgres-image.d.ts.map +1 -1
  495. package/dist/postgres-image.js +18 -15
  496. package/dist/postgres-image.js.map +1 -1
  497. package/dist/postgrest-release.d.ts +9 -0
  498. package/dist/postgrest-release.d.ts.map +1 -1
  499. package/dist/postgrest-release.js +23 -0
  500. package/dist/postgrest-release.js.map +1 -1
  501. package/dist/process-manager.d.ts.map +1 -1
  502. package/dist/process-manager.js +3 -1
  503. package/dist/process-manager.js.map +1 -1
  504. package/dist/project-config.d.ts +44 -7
  505. package/dist/project-config.d.ts.map +1 -1
  506. package/dist/project-config.js +48 -4
  507. package/dist/project-config.js.map +1 -1
  508. package/dist/pull-utils.d.ts +15 -0
  509. package/dist/pull-utils.d.ts.map +1 -1
  510. package/dist/pull-utils.js +149 -23
  511. package/dist/pull-utils.js.map +1 -1
  512. package/dist/push-refusal.d.ts.map +1 -1
  513. package/dist/push-refusal.js +3 -2
  514. package/dist/push-refusal.js.map +1 -1
  515. package/dist/realtime-launch.d.ts +2 -5
  516. package/dist/realtime-launch.d.ts.map +1 -1
  517. package/dist/realtime-launch.js +6 -23
  518. package/dist/realtime-launch.js.map +1 -1
  519. package/dist/recorded-field-masking-tier.d.ts.map +1 -1
  520. package/dist/recorded-field-masking-tier.js +4 -3
  521. package/dist/recorded-field-masking-tier.js.map +1 -1
  522. package/dist/release-images.d.ts +31 -0
  523. package/dist/release-images.d.ts.map +1 -0
  524. package/dist/release-images.js +90 -0
  525. package/dist/release-images.js.map +1 -0
  526. package/dist/required-host-components.d.ts.map +1 -1
  527. package/dist/required-host-components.js +4 -0
  528. package/dist/required-host-components.js.map +1 -1
  529. package/dist/resolve-api-url.d.ts +17 -3
  530. package/dist/resolve-api-url.d.ts.map +1 -1
  531. package/dist/resolve-api-url.js +71 -30
  532. package/dist/resolve-api-url.js.map +1 -1
  533. package/dist/resolve-target.d.ts +64 -0
  534. package/dist/resolve-target.d.ts.map +1 -1
  535. package/dist/resolve-target.js +75 -27
  536. package/dist/resolve-target.js.map +1 -1
  537. package/dist/rest-ready.d.ts.map +1 -1
  538. package/dist/rest-ready.js +2 -1
  539. package/dist/rest-ready.js.map +1 -1
  540. package/dist/route-manifest.d.ts +25 -2
  541. package/dist/route-manifest.d.ts.map +1 -1
  542. package/dist/route-manifest.js +48 -4
  543. package/dist/route-manifest.js.map +1 -1
  544. package/dist/run-until-stopped.d.ts +12 -0
  545. package/dist/run-until-stopped.d.ts.map +1 -0
  546. package/dist/run-until-stopped.js +42 -0
  547. package/dist/run-until-stopped.js.map +1 -0
  548. package/dist/schema-ast-v2.d.ts +2 -1
  549. package/dist/schema-ast-v2.d.ts.map +1 -1
  550. package/dist/schema-ast-v2.js.map +1 -1
  551. package/dist/schema-push-lock.d.ts.map +1 -1
  552. package/dist/schema-push-lock.js +59 -46
  553. package/dist/schema-push-lock.js.map +1 -1
  554. package/dist/schema-sources.d.ts +19 -4
  555. package/dist/schema-sources.d.ts.map +1 -1
  556. package/dist/schema-sources.js +56 -35
  557. package/dist/schema-sources.js.map +1 -1
  558. package/dist/seed-auth-connect.d.ts +14 -0
  559. package/dist/seed-auth-connect.d.ts.map +1 -0
  560. package/dist/seed-auth-connect.js +97 -0
  561. package/dist/seed-auth-connect.js.map +1 -0
  562. package/dist/seed-runner.d.ts.map +1 -1
  563. package/dist/seed-runner.js +22 -1
  564. package/dist/seed-runner.js.map +1 -1
  565. package/dist/seed.d.ts +6 -3
  566. package/dist/seed.d.ts.map +1 -1
  567. package/dist/self-host-compose.d.ts +44 -29
  568. package/dist/self-host-compose.d.ts.map +1 -1
  569. package/dist/self-host-compose.js +311 -159
  570. package/dist/self-host-compose.js.map +1 -1
  571. package/dist/service-role-key-file.d.ts +32 -0
  572. package/dist/service-role-key-file.d.ts.map +1 -0
  573. package/dist/service-role-key-file.js +90 -0
  574. package/dist/service-role-key-file.js.map +1 -0
  575. package/dist/shell-ports.d.ts +13 -2
  576. package/dist/shell-ports.d.ts.map +1 -1
  577. package/dist/shell-ports.js +20 -15
  578. package/dist/shell-ports.js.map +1 -1
  579. package/dist/stop-signals.d.ts +7 -0
  580. package/dist/stop-signals.d.ts.map +1 -0
  581. package/dist/stop-signals.js +12 -0
  582. package/dist/stop-signals.js.map +1 -0
  583. package/dist/storage-launch.d.ts +11 -0
  584. package/dist/storage-launch.d.ts.map +1 -0
  585. package/dist/storage-launch.js +41 -0
  586. package/dist/storage-launch.js.map +1 -0
  587. package/dist/storage-provision.d.ts +50 -5
  588. package/dist/storage-provision.d.ts.map +1 -1
  589. package/dist/storage-provision.js +101 -33
  590. package/dist/storage-provision.js.map +1 -1
  591. package/dist/systemd.d.ts +1 -1
  592. package/dist/systemd.d.ts.map +1 -1
  593. package/dist/systemd.js +26 -11
  594. package/dist/systemd.js.map +1 -1
  595. package/dist/tar-reader.d.ts +29 -0
  596. package/dist/tar-reader.d.ts.map +1 -0
  597. package/dist/tar-reader.js +99 -0
  598. package/dist/tar-reader.js.map +1 -0
  599. package/dist/target-client.d.ts +14 -1
  600. package/dist/target-client.d.ts.map +1 -1
  601. package/dist/target-client.js +134 -23
  602. package/dist/target-client.js.map +1 -1
  603. package/dist/target-request.d.ts +25 -0
  604. package/dist/target-request.d.ts.map +1 -0
  605. package/dist/target-request.js +33 -0
  606. package/dist/target-request.js.map +1 -0
  607. package/dist/target-warning.d.ts +7 -0
  608. package/dist/target-warning.d.ts.map +1 -0
  609. package/dist/target-warning.js +12 -0
  610. package/dist/target-warning.js.map +1 -0
  611. package/dist/tsx-runner.d.ts.map +1 -1
  612. package/dist/tsx-runner.js +2 -1
  613. package/dist/tsx-runner.js.map +1 -1
  614. package/dist/type-extractor.d.ts +6 -0
  615. package/dist/type-extractor.d.ts.map +1 -1
  616. package/dist/type-extractor.js +138 -70
  617. package/dist/type-extractor.js.map +1 -1
  618. package/dist/ui/clack.d.ts.map +1 -1
  619. package/dist/ui/clack.js +11 -1
  620. package/dist/ui/clack.js.map +1 -1
  621. package/dist/ui/dev/DevDashboard.d.ts.map +1 -1
  622. package/dist/ui/dev/DevDashboard.js +13 -5
  623. package/dist/ui/dev/DevDashboard.js.map +1 -1
  624. package/dist/ui/fatal.d.ts.map +1 -1
  625. package/dist/ui/fatal.js +6 -7
  626. package/dist/ui/fatal.js.map +1 -1
  627. package/dist/ui/flows/FlowApp.d.ts.map +1 -1
  628. package/dist/ui/flows/FlowApp.js +16 -1
  629. package/dist/ui/flows/FlowApp.js.map +1 -1
  630. package/dist/ui/flows/prompt-fields.d.ts +16 -6
  631. package/dist/ui/flows/prompt-fields.d.ts.map +1 -1
  632. package/dist/ui/flows/prompt-fields.js +19 -9
  633. package/dist/ui/flows/prompt-fields.js.map +1 -1
  634. package/dist/ui/messages.d.ts +6 -0
  635. package/dist/ui/messages.d.ts.map +1 -1
  636. package/dist/ui/messages.js +17 -0
  637. package/dist/ui/messages.js.map +1 -1
  638. package/dist/ui/progress.d.ts +7 -0
  639. package/dist/ui/progress.d.ts.map +1 -1
  640. package/dist/ui/progress.js +22 -8
  641. package/dist/ui/progress.js.map +1 -1
  642. package/dist/ui/runtime/command-chrome.d.ts.map +1 -1
  643. package/dist/ui/runtime/command-chrome.js +2 -0
  644. package/dist/ui/runtime/command-chrome.js.map +1 -1
  645. package/dist/ui/runtime/prompt-interrupt.d.ts +10 -0
  646. package/dist/ui/runtime/prompt-interrupt.d.ts.map +1 -0
  647. package/dist/ui/runtime/prompt-interrupt.js +24 -0
  648. package/dist/ui/runtime/prompt-interrupt.js.map +1 -0
  649. package/dist/ui/runtime/run-clack-flow.d.ts.map +1 -1
  650. package/dist/ui/runtime/run-clack-flow.js +5 -2
  651. package/dist/ui/runtime/run-clack-flow.js.map +1 -1
  652. package/dist/ui/runtime/stdin-after-ink.d.ts +14 -1
  653. package/dist/ui/runtime/stdin-after-ink.d.ts.map +1 -1
  654. package/dist/ui/runtime/stdin-after-ink.js +44 -3
  655. package/dist/ui/runtime/stdin-after-ink.js.map +1 -1
  656. package/dist/url-safe-passwords.d.ts +25 -0
  657. package/dist/url-safe-passwords.d.ts.map +1 -0
  658. package/dist/url-safe-passwords.js +70 -0
  659. package/dist/url-safe-passwords.js.map +1 -0
  660. package/dist/valkey-sidecar.d.ts +33 -6
  661. package/dist/valkey-sidecar.d.ts.map +1 -1
  662. package/dist/valkey-sidecar.js +90 -61
  663. package/dist/valkey-sidecar.js.map +1 -1
  664. package/dist/worker-module-files.d.ts +3 -0
  665. package/dist/worker-module-files.d.ts.map +1 -0
  666. package/dist/worker-module-files.js +18 -0
  667. package/dist/worker-module-files.js.map +1 -0
  668. package/package.json +22 -16
  669. package/dist/functions-router-gen.d.ts.map +0 -1
  670. package/dist/functions-router-gen.js +0 -302
  671. package/dist/functions-router-gen.js.map +0 -1
@@ -1,47 +1,53 @@
1
1
  /**
2
2
  * `supatype dev` when `provider: docker`, full self-host Compose stack (Kong gateway).
3
3
  */
4
+ import { setTimeout as sleep } from "node:timers/promises";
4
5
  import { projectOutputPaths, writeAstDerivedOutputs, writeSeedBuilder } from "./type-generation.js";
5
6
  import { errorMessage } from "./error-message.js";
7
+ import { warn } from "./ui/messages.js";
8
+ import { FRONTEND_URL_KEYS, frontendEnv, writeFrontendEnv } from "./frontend-env.js";
6
9
  import { withPublishing } from "./model-versioning.js";
7
10
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
8
11
  import { homedir } from "node:os";
9
12
  import { dirname, join } from "node:path";
10
- import { spawnSync } from "node:child_process";
13
+ import { askDocker, askDockerSync, DOCKER_EXEC_TIMEOUT_MS, DOCKER_QUERY_TIMEOUT_MS } from "./docker-exec.js";
11
14
  import { startProxyDevApp, resolveProxyDevScript } from "./app/proxy-dev-app.js";
12
15
  import { loadSchemaAst, projectNameInFile } from "./config.js";
13
16
  import { withComposeSchemaPushLock } from "./schema-push-lock.js";
14
17
  import { recordDatabaseTier, sameApiSurface } from "./recorded-field-masking-tier.js";
15
- import { connectionString, pgSchema, projectRootFromConfig, resolveRuntimeProvider, hooksPathFromProject, schemaPathFromProject, selfHostTlsEnabled, usesExternalDatabase, } from "./project-config.js";
16
- import { syncManifestHooks, writeHooksModule } from "./model-hooks.js";
17
- import { rowCacheChangeNote, syncRowCacheEnv } from "./model-cache.js";
18
+ import { connectionString, pgSchema, projectRootFromConfig, resolveRuntimeProvider, schemaPathFromProject, selfHostTlsEnabled, usesExternalDatabase, } from "./project-config.js";
19
+ import { rowCacheChangeNote } from "./model-cache.js";
20
+ import { writeAppliedAstArtifacts } from "./applied-ast-artifacts.js";
18
21
  import { anonKeyEnvUpdates } from "./commands/keys.js";
19
22
  import { devApiKeys } from "./dev-api-keys.js";
23
+ import { warnUrlUnsafeComposePasswords } from "./url-safe-passwords.js";
20
24
  import { astRelatesToAuthUsers } from "./byo-preflight.js";
21
25
  import { ensureDevDbPort, ensureKongPort } from "./dev-ports.js";
22
26
  import { applyForThisRun, splitShellPortUpdates } from "./shell-ports.js";
23
27
  import { handleComposeProjectRename } from "./compose-rename.js";
24
28
  import { devSessionLockFor, recoverStaleDevSession, writeDevSessionLock } from "./dev-session-lock.js";
25
- import { endDevSession, startDevSession } from "./dev-session.js";
29
+ import { endDevSession, showDevStep, startDevSession } from "./dev-session.js";
26
30
  import { ensureDevApiConfig } from "./ensure-dev-api-config.js";
27
31
  import { cacheSeedingNotes } from "./api-config-cache.js";
28
- import { refreshFunctionsContext } from "./functions-context-refresh.js";
29
32
  import { restartComposeFunctionsWorker, watchFunctionSources } from "./dev-functions-watch.js";
30
33
  import { watchDevSchema } from "./dev-schema-watch.js";
31
- import { databaseUrlSyncMessage, syncDatabaseUrlPort } from "./db-port.js";
34
+ import { offerToSaveShellDbPort } from "./db-port-offer.js";
35
+ import { databaseUrlSyncMessage } from "./db-port.js";
36
+ import { databaseUrlState, setCliDatabaseUrlForRun, syncDatabaseUrlPort, warnIfHandWrittenUrlSilent, writeCliDatabaseUrl, } from "./database-url-owner.js";
32
37
  import { degraded } from "./strict.js";
38
+ import { ENGINE_FALLBACK, generatedFilesEngine } from "./generated-files-engine.js";
33
39
  import { DEV_DESTRUCTIVE_POLICY, consentDepsFromDiff, pushConsentingToDestructive } from "./destructive-consent.js";
34
40
  import { auditFlags, auditWhenSupported } from "./push-audit.js";
35
41
  import { consentRefusal, reportDevPushFailure } from "./push-refusal.js";
36
- import { COMPOSE_PINNED_IMAGE_ENV_KEYS, composeDockerImageEnv, composeProjectName, exitComposeFailed, publishesDbToHost, runDockerCompose, schemaEngineImageForPush, writeSelfHostCompose, composeFieldMaskingTier, selfHostComposePaths, } from "./self-host-compose.js";
42
+ import { COMPOSE_PINNED_IMAGE_ENV_KEYS, composeDockerImageEnv, composeProjectName, exitComposeFailed, noteUnpinnedImages, publishesDbToHost, runDockerCompose, runDockerComposeQuietly, settleComposeRuns, schemaEngineImageForPush, writeSelfHostCompose, composeFieldMaskingTier, selfHostComposePaths, } from "./self-host-compose.js";
37
43
  import { composeServiceIsRunning } from "./compose-kong.js";
38
44
  import { hasEngineOverride } from "./binary-cache.js";
39
45
  import { STUDIO_DEV_PORT, startStudioViteDevServer } from "./studio-dev-server.js";
40
46
  import { ensureLocalServerDockerImage, usesLocalServerImage, LOCAL_SERVER_DOCKER_IMAGE, } from "./compose-local-server-image.js";
41
47
  import { ensureEngine, enginePush, engineRequest } from "./engine-client.js";
42
- import { isAdoptOutcome, isAnyAnswer, isDiffResult, isEnginePushResult, isGenerateAnswer, isObjectAnswer, } from "./engine-answers.js";
48
+ import { isAdoptOutcome, isAnyAnswer, isDiffResult, isEnginePushResult, isGenerateAnswer, } from "./engine-answers.js";
43
49
  import { writeSchemaSourcePushArtifacts } from "./schema-sources.js";
44
- import { readEnvValue, upsertEnvFile } from "./env-file.js";
50
+ import { readEnvFile, readEnvValue, upsertEnvFile } from "./env-file.js";
45
51
  import { warnProjectAuthProviderSecrets } from "./auth-providers.js";
46
52
  import { devDatabaseIdentity, devDatabaseUrl, seedMissingDatabaseIdentity, seedMissingLocalSecrets, } from "./local-secrets.js";
47
53
  import { writeLocalEnvironment } from "./link.js";
@@ -49,13 +55,13 @@ import { registerDevShutdown, waitForDevShutdown } from "./dev-shutdown.js";
49
55
  import { filterComposeNoise, parseEngineJsonOutput, parseEnginePushOutput, reportAppliedPush, } from "./engine-push-output.js";
50
56
  import { withAdminRoles } from "./studio-admin-roles.js";
51
57
  import { restoreSystemRelationTargets } from "./restore-system-relation-targets.js";
52
- import { provisionBucketsFromAst } from "./storage-provision.js";
58
+ import { provisionBucketsFromAst, unprovisionedBuckets } from "./storage-provision.js";
53
59
  import { ensureFirstAdminUserForProject } from "./commands/admin.js";
54
60
  import { demoDataHint, publishDevReady } from "./dev-ready-panel.js";
55
61
  import { pushInitialSchema, settleInitialPush } from "./dev-initial-push.js";
56
62
  import { offerAdoption, targetAdoptionSteps } from "./adopt-walkthrough.js";
57
63
  import { resetDevDatabase } from "./dev-db-reset.js";
58
- import { adoptKeysNeed, assertSupported, engineCapabilities, identityColumnsNeed, OVERWRITE_DRIFT_NEED, probeCapabilities, } from "./engine-ownership-gate.js";
64
+ import { adoptKeysNeed, assertSupported, engineCapabilities, identityColumnsNeed, OVERWRITE_DRIFT_NEED, checkedCapabilities, } from "./engine-ownership-gate.js";
59
65
  import { devPushConsentingToDrift } from "./drift-consent.js";
60
66
  import { capabilitiesCache, rememberCapabilitiesSync } from "@supatype/shared";
61
67
  import { waitForDatabaseAfterUp } from "./dev-db-ready.js";
@@ -66,9 +72,24 @@ import { spawnComposeEngine } from "./compose-engine-run.js";
66
72
  import { waitForRestReady } from "./rest-ready.js";
67
73
  import { claimDevRenderMode, composeRenderMode, composeRenderOptions } from "./compose-render-mode.js";
68
74
  import { devMailerAutoconfirmUpdate, MAILER_AUTOCONFIRM_ENV } from "./mailer-autoconfirm.js";
75
+ import { mailerProviderEnv } from "./mailer-env.js";
76
+ import { fetchWithin } from "./fetch-within.js";
77
+ import { assertEngineVersionSupported, engineImageVersion } from "./engine-floor.js";
78
+ /**
79
+ * The image pins config asks for, once the engine's is known not to be older than this CLI needs.
80
+ * Checked before `.env` is written: a push refused the engine after writing its pin there as a
81
+ * managed line, and `.env` stayed pinned to the refused engine (local test round 6).
82
+ */
83
+ function checkedImagePins(config) {
84
+ const pins = composeDockerImageEnv(config);
85
+ const engine = pins["SUPATYPE_ENGINE_IMAGE"];
86
+ if (engine !== undefined)
87
+ assertEngineVersionSupported(engineImageVersion(engine), "versions.engine in supatype.config.ts", "image");
88
+ return pins;
89
+ }
69
90
  /** Sync optional Docker image pins from config into `.env` (no JWT rotation). */
70
91
  export function syncComposeImagePins(cwd, config) {
71
- const imagePins = composeDockerImageEnv(config);
92
+ const imagePins = checkedImagePins(config);
72
93
  // Clean up only what a previous run wrote from config. A hand-written image tag in `.env` is the
73
94
  // documented way to run a local build, and this used to delete it on every compose run.
74
95
  const removeImageKeys = COMPOSE_PINNED_IMAGE_ENV_KEYS.filter((key) => !(key in imagePins));
@@ -170,39 +191,6 @@ export async function projectComposeEngine(cwd, config) {
170
191
  capabilities: () => dockerEngineCapabilities(cwd, config),
171
192
  };
172
193
  }
173
- /**
174
- * `email.provider` and `email.smtp` for the compose server service.
175
- *
176
- * The native dev path has mapped these since it existed; the compose path never
177
- * did, so a project that asked for smtp got the auth service's noop client and
178
- * no message at all. Console is the documented default, and it at least says
179
- * that a message would have been sent.
180
- */
181
- function composeMailerEnv(config) {
182
- const email = config.email;
183
- const out = {
184
- // Mailer.MailerProvider, so the doubled word is the real name.
185
- SUPATYPE_MAILER_MAILER_PROVIDER: email?.provider ?? "console",
186
- };
187
- const smtp = email?.smtp;
188
- if (email?.provider !== "smtp" || smtp === undefined)
189
- return out;
190
- if (smtp.host !== undefined && smtp.host !== "")
191
- out.SUPATYPE_SMTP_HOST = smtp.host;
192
- if (smtp.port !== undefined)
193
- out.SUPATYPE_SMTP_PORT = String(smtp.port);
194
- if (smtp.user !== undefined && smtp.user !== "")
195
- out.SUPATYPE_SMTP_USER = smtp.user;
196
- if (smtp.pass !== undefined && smtp.pass !== "")
197
- out.SUPATYPE_SMTP_PASS = smtp.pass;
198
- if (smtp.admin_email !== undefined && smtp.admin_email !== "") {
199
- out.SUPATYPE_SMTP_ADMIN_EMAIL = smtp.admin_email;
200
- }
201
- if (smtp.sender_name !== undefined && smtp.sender_name !== "") {
202
- out.SUPATYPE_SMTP_SENDER_NAME = smtp.sender_name;
203
- }
204
- return out;
205
- }
206
194
  async function resolveKongPort(cwd, composeProject) {
207
195
  // The compose project is passed so an already-running stack of *this* project counts as
208
196
  // available rather than as a collision.
@@ -215,14 +203,16 @@ async function resolveKongPort(cwd, composeProject) {
215
203
  * already running, and its readiness is the operator's, `supatype db check` is what reports on it.
216
204
  * Four call sites did this inline, so an external project hit `compose up -d db` against a compose
217
205
  * file that deliberately has no `db`.
206
+ *
207
+ * Warns rather than refuses about a URL-unsafe password. dev has refused before it gets here, and
208
+ * push and diff are not stopped over a database that starts either way: the warning names the
209
+ * cause before any connection failure it leads to.
218
210
  */
219
211
  async function startComposeDatabase(config, paths, cwd, project, brand, timeoutMs = 120_000, onFailure) {
220
212
  if (usesExternalDatabase(config))
221
213
  return;
222
- const up = runDockerCompose(paths.composePath, ["up", "-d", "db"], cwd, project, {
223
- quiet: true,
224
- ...(brand !== undefined && { brand }),
225
- });
214
+ warnUrlUnsafeComposePasswords(cwd, config);
215
+ const up = await runDockerComposeQuietly(paths.composePath, ["up", "-d", "db"], cwd, project, brand);
226
216
  if (up !== 0) {
227
217
  onFailure?.();
228
218
  exitComposeFailed(up, "Could not start Postgres (compose db service).", brand);
@@ -231,7 +221,7 @@ async function startComposeDatabase(config, paths, cwd, project, brand, timeoutM
231
221
  }
232
222
  export function upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPort, devDbPort) {
233
223
  const apiUrl = `http://localhost:${kongPort}`;
234
- const imagePins = composeDockerImageEnv(config);
224
+ const imagePins = checkedImagePins(config);
235
225
  // `POSTGRES_PASSWORD` and `JWT_SECRET` are deliberately absent.
236
226
  //
237
227
  // They used to be pinned here to published constants on every `dev` run, against the same
@@ -251,19 +241,18 @@ export function upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPo
251
241
  ...seedMissingLocalSecrets(cwd, config),
252
242
  // Project configuration, seeded not overwritten, see seedMissingDatabaseIdentity.
253
243
  ...seedMissingDatabaseIdentity(cwd, config),
254
- // Shared with `supatype keys --write`, so a front end's prefix cannot be written by one and
255
- // forgotten by the other. See `anonKeyEnvUpdates`.
256
- //
257
- // This list used to live here as well, and the two had already drifted: `dev` wrote
258
- // PUBLIC_ and EXPO_PUBLIC_ URLs and no VITE_SUPATYPE_URL, so a Vite app whose `.env` had only
259
- // ever been touched by `supatype dev` built against an empty string.
260
- ...anonKeyEnvUpdates(anonKey, serviceRoleKey, apiUrl),
244
+ // Shared with `supatype keys --write`, so a name cannot be written by one and forgotten by the
245
+ // other. See `anonKeyEnvUpdates`. The front end's copies are written below, not here.
246
+ ...anonKeyEnvUpdates(anonKey, serviceRoleKey),
261
247
  SUPATYPE_KONG_PORT: String(kongPort),
262
248
  API_EXTERNAL_URL: apiUrl,
263
249
  SITE_URL: apiUrl,
264
250
  // From auth.email.enableConfirmations, unless the developer set their own in .env.
265
251
  ...devMailerAutoconfirmUpdate(cwd, config),
266
- ...composeMailerEnv(config),
252
+ // email.provider and its settings, which the compose file passes to the server. The compose
253
+ // path used to carry none of them, so a project that asked for smtp, Resend or SES got the auth
254
+ // service's noop client and no message at all.
255
+ ...mailerProviderEnv(config.email),
267
256
  ...imagePins,
268
257
  };
269
258
  // Never for an external database: this URL describes the `db` container, which that project does
@@ -271,13 +260,8 @@ export function upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPo
271
260
  // every CLI command reads, with a DSN pointing at a database that does not exist. Found by
272
261
  // rehearsing a push against a real external Postgres, where the compose guard then refused to
273
262
  // proceed because .env and the config disagreed. They disagreed because of this line.
274
- if (devDbPort !== undefined && !usesExternalDatabase(config)) {
263
+ if (devDbPort !== undefined && !usesExternalDatabase(config))
275
264
  updates.SUPATYPE_DEV_DB_PORT = String(devDbPort);
276
- // User and database from the project, not hardcoded, same reason as
277
- // `seedMissingDatabaseIdentity`: a project not named "supatype" had this URL pointing at a
278
- // database that does not exist.
279
- updates.DATABASE_URL = hostComposeDbUrl(cwd, devDbPort);
280
- }
281
265
  // `SUPATYPE_SERVER_IMAGE` is written here, not passed in, and it is deliberately *not* marked
282
266
  // managed. The managed marker means "this value came from `versions` in the config and is mine to
283
267
  // clean up when the pin goes away". The locally built image comes from `overrides`, so removing
@@ -294,21 +278,52 @@ export function upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPo
294
278
  // write is removed: an operator's own GOTRUE_ variable is theirs, and the server's error names it
295
279
  // and its replacement precisely enough to fix by hand.
296
280
  const retiredKeys = ["GOTRUE_MAILER_AUTOCONFIRM"];
297
- // A port the shell gave for this run is the run's, not the project's (DR9).
298
- const { persist, runOnly } = splitShellPortUpdates(updates);
281
+ // A port the shell gave for this run is the run's, not the project's (DR9), unless `.env` holds it too.
282
+ const dotEnv = readEnvFile(cwd);
283
+ const { persist, runOnly } = splitShellPortUpdates({ ...updates, ...frontendEnv({ apiUrl }) }, process.env, dotEnv);
299
284
  applyForThisRun(runOnly);
300
- upsertEnvFile(cwd, persist, {
285
+ const { urlsKept, rest } = takeFrontendUrls(persist);
286
+ upsertEnvFile(cwd, rest, {
301
287
  removeManaged: removeImageKeys,
302
288
  managed: [...managedImageKeys, MAILER_AUTOCONFIRM_ENV],
303
- // A local image left in `.env` after the project stopped asking for one would keep pointing
304
- // compose at a stale build, and it carries no marker for `removeManaged` to act on.
305
- remove: [
306
- ...retiredKeys,
307
- ...(!wantsLocalServer && !("SUPATYPE_SERVER_IMAGE" in imagePins)
308
- ? ["SUPATYPE_SERVER_IMAGE"]
309
- : []),
310
- ],
289
+ remove: [...retiredKeys, ...staleLocalServerImage(dotEnv["SUPATYPE_SERVER_IMAGE"], wantsLocalServer, imagePins)],
311
290
  });
291
+ // The front end's copies go where a development build reads them, not .env, which a production
292
+ // build reads (frontend-env.ts). The URL only when it is the project's port, not the shell's.
293
+ writeFrontendEnv(cwd, { anonKey, ...(urlsKept && { apiUrl }) }, { local: true });
294
+ if (devDbPort !== undefined && !usesExternalDatabase(config)) {
295
+ writeDevStackDatabaseUrl(cwd, devDbPort, runOnly.SUPATYPE_DEV_DB_PORT !== undefined);
296
+ }
297
+ }
298
+ /** `persist` less the front-end URL names, and whether they were among what is kept. */
299
+ function takeFrontendUrls(persist) {
300
+ const names = new Set(FRONTEND_URL_KEYS);
301
+ const rest = Object.fromEntries(Object.entries(persist).filter(([key]) => !names.has(key)));
302
+ return { urlsKept: FRONTEND_URL_KEYS.every((key) => key in persist), rest };
303
+ }
304
+ /**
305
+ * `SUPATYPE_SERVER_IMAGE` to remove from `.env`: the local-dev image this CLI wrote, once the project
306
+ * stops asking for a local build and pins no server. It carries no marker for `removeManaged` to act
307
+ * on, and left behind it would keep pointing compose at a stale build. Any other value was set by
308
+ * hand, `supatype/server:it-r3` for instance, and is kept (local test round 3, N1).
309
+ */
310
+ function staleLocalServerImage(current, wantsLocalServer, imagePins) {
311
+ if (wantsLocalServer || "SUPATYPE_SERVER_IMAGE" in imagePins)
312
+ return [];
313
+ return current?.trim() === LOCAL_SERVER_DOCKER_IMAGE ? ["SUPATYPE_SERVER_IMAGE"] : [];
314
+ }
315
+ /**
316
+ * Docker dev's DATABASE_URL: the stack's database at `devDbPort`, with the project's own user and
317
+ * database, not hardcoded ones, which on a project not named "supatype" named a database that does
318
+ * not exist. Written over a URL the CLI owns, for this run only when the port is the shell's; one
319
+ * that is yours always wins (database-url-owner.ts).
320
+ */
321
+ function writeDevStackDatabaseUrl(cwd, devDbPort, runOnly) {
322
+ const url = hostComposeDbUrl(cwd, devDbPort);
323
+ if (runOnly)
324
+ setCliDatabaseUrlForRun(databaseUrlState(cwd), url);
325
+ else
326
+ writeCliDatabaseUrl(cwd, url);
312
327
  }
313
328
  /** Keep compose + Studio on the same freshly signed dev JWTs; sync optional image pins from config. */
314
329
  function ensureDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPort, devDbPort) {
@@ -339,7 +354,7 @@ async function waitComposeHealthy(paths, cwd, maxMs, composeProject) {
339
354
  baseArgs.push("--env-file", envFile);
340
355
  const deadline = Date.now() + maxMs;
341
356
  while (Date.now() < deadline) {
342
- const ready = spawnSync("docker",
357
+ const ready = await askDocker(
343
358
  // Over TCP, deliberately, not the Unix socket.
344
359
  //
345
360
  // On a first run the Postgres entrypoint starts a temporary server with `listen_addresses=''`
@@ -352,10 +367,10 @@ async function waitComposeHealthy(paths, cwd, maxMs, composeProject) {
352
367
  [
353
368
  ...baseArgs, "exec", "-T", "db",
354
369
  "pg_isready", "-h", "127.0.0.1", "-U", devDatabaseIdentity(cwd).user,
355
- ], { cwd: composeDir, encoding: "utf8" });
370
+ ], { cwd: composeDir, timeoutMs: DOCKER_EXEC_TIMEOUT_MS });
356
371
  if (ready.status === 0)
357
372
  return;
358
- await new Promise((r) => setTimeout(r, 2000));
373
+ await sleep(2000);
359
374
  }
360
375
  throw new Error("Compose db service did not become healthy in time");
361
376
  }
@@ -373,12 +388,9 @@ function dumpComposeDbLogs(paths, cwd, composeProject, reason) {
373
388
  if (existsSync(envFile))
374
389
  args.push("--env-file", envFile);
375
390
  args.push("logs", "--no-color", "--timestamps", "--tail", "800", "db");
376
- const result = spawnSync("docker", args, {
377
- cwd,
378
- encoding: "utf8",
379
- maxBuffer: 10 * 1024 * 1024,
380
- });
381
- const body = `${result.stdout ?? ""}${result.stderr ?? ""}`.trim();
391
+ // Synchronous: called from the failure paths that then exit.
392
+ const result = askDockerSync(args, { cwd, timeoutMs: DOCKER_QUERY_TIMEOUT_MS });
393
+ const body = `${result.stdout}${result.stderr}`.trim();
382
394
  const content = body || `(empty, docker compose logs db exit ${result.status ?? "?"})\n`;
383
395
  try {
384
396
  writeFileSync(logPath, content);
@@ -405,17 +417,6 @@ function dumpComposeDbLogs(paths, cwd, composeProject, reason) {
405
417
  function loopbackBase(port) {
406
418
  return `http://127.0.0.1:${port}`;
407
419
  }
408
- /**
409
- * `fetch` with a deadline, because the built-in has none.
410
- *
411
- * A poll loop bounded by `maxSec` iterations is only bounded if each attempt can end. Against a
412
- * socket that accepts and never responds, an un-timed `fetch` never settles, the loop never reaches
413
- * its second iteration, and a wait advertised as 120 seconds runs until someone kills it. That is
414
- * how `supatype push` came to hang indefinitely after reporting the schema applied.
415
- */
416
- async function fetchWithin(url, ms, init) {
417
- return await fetch(url, { ...init, signal: AbortSignal.timeout(ms) });
418
- }
419
420
  /**
420
421
  * Print what the stack is doing when the gateway never comes up.
421
422
  *
@@ -424,21 +425,19 @@ async function fetchWithin(url, ms, init) {
424
425
  * That sends people to look at Kong, which is almost never the problem, and in
425
426
  * CI the containers are gone by the time anything else can inspect them.
426
427
  */
427
- function reportUnhealthyStack(composePath, cwd, project) {
428
- const capture = (args) => {
429
- const result = spawnSync("docker", ["compose", "-p", project, "--project-directory", cwd, "-f", composePath, ...args], {
430
- encoding: "utf8",
431
- cwd,
432
- });
433
- return `${result.stdout ?? ""}${result.stderr ?? ""}`.trim();
428
+ async function reportUnhealthyStack(composePath, cwd, project) {
429
+ const capture = async (args) => {
430
+ const call = { cwd, timeoutMs: DOCKER_QUERY_TIMEOUT_MS };
431
+ const result = await askDocker(["compose", "-p", project, "--project-directory", cwd, "-f", composePath, ...args], call);
432
+ return `${result.stdout}${result.stderr}`.trim();
434
433
  };
435
434
  console.error("");
436
435
  console.error("[supatype] The gateway is up but a service behind it is not. Container state:");
437
- const state = capture(["ps", "-a"]);
436
+ const state = await capture(["ps", "-a"]);
438
437
  console.error(state === "" ? " (no containers)" : state);
439
438
  // The two the gateway health check depends on, and db because both need it.
440
439
  for (const service of ["server", "realtime", "db"]) {
441
- const logs = capture(["logs", "--no-color", "--tail", "40", service]);
440
+ const logs = await capture(["logs", "--no-color", "--tail", "40", service]);
442
441
  if (logs === "")
443
442
  continue;
444
443
  console.error("");
@@ -466,12 +465,12 @@ async function waitKongReady(kongPort, maxSec, stack) {
466
465
  return;
467
466
  }
468
467
  catch (err) {
469
- lastAuth = lastRealtime = err instanceof Error ? err.message : String(err);
468
+ lastAuth = lastRealtime = errorMessage(err);
470
469
  }
471
- await new Promise((r) => setTimeout(r, 1000));
470
+ await sleep(1000);
472
471
  }
473
472
  if (stack !== undefined) {
474
- reportUnhealthyStack(stack.composePath, stack.cwd, stack.project);
473
+ await reportUnhealthyStack(stack.composePath, stack.cwd, stack.project);
475
474
  }
476
475
  throw new Error(`Gateway at ${base} did not become ready within ${maxSec}s ` +
477
476
  `(auth/v1/health: ${lastAuth}, realtime/v1/health: ${lastRealtime})`);
@@ -495,12 +494,19 @@ async function waitStorageApiReady(kongPort, serviceRoleKey, maxSec) {
495
494
  catch {
496
495
  /* retry */
497
496
  }
498
- await new Promise((r) => setTimeout(r, 1000));
497
+ await sleep(1000);
499
498
  }
500
499
  console.warn(`[supatype] Storage API at ${url} did not become ready within ${maxSec}s, bucket provisioning may fail.`);
501
500
  }
501
+ /**
502
+ * The schema's buckets on the dev stack. One the service did not take is said in one line, with what
503
+ * it means: dev carries on, and only uploads to that bucket fail. They were dropped without a word
504
+ * past each bucket's own warning.
505
+ */
502
506
  async function provisionDockerStorageBuckets(ast, kongPort, serviceRoleKey) {
503
- await provisionBucketsFromAst(ast, `${loopbackBase(kongPort)}/storage/v1`, serviceRoleKey);
507
+ const left = unprovisionedBuckets(await provisionBucketsFromAst(ast, `${loopbackBase(kongPort)}/storage/v1`, serviceRoleKey));
508
+ if (left !== null)
509
+ console.warn(`[supatype] ⚠ ${left}; uploads to them fail until a later push takes them.`);
504
510
  }
505
511
  let _lastPushedAst = null;
506
512
  let _lastFailedAst = null;
@@ -511,24 +517,25 @@ let _composePushQueued = false;
511
517
  /**
512
518
  * Regenerate everything derived from the schema once a push has applied it: the AST-derived files,
513
519
  * then the types and admin config from the engine. Never called for a push that was refused or
514
- * failed. A docker project with no `overrides.engine` uses its own engine image, the one that
515
- * pushed (A5-N3); otherwise the host binary, falling back to the image when the binary cannot be
516
- * fetched.
520
+ * failed. The engine is the one `supatype generate` uses, the host program, with the project's
521
+ * image only when that cannot be fetched (generated-files-engine.ts).
517
522
  */
518
523
  async function refreshSchemaArtifacts(cwd, config, ast) {
519
524
  writeAstDerivedArtifacts(cwd, config, ast);
520
- const adminConfigPath = join(cwd, ".supatype", "admin-config.json");
521
- let engine;
525
+ // The client and augmentation need no engine, so no engine problem keeps them from being written.
526
+ writeDevAstOutputs(cwd, ast, config, "");
527
+ let choice;
522
528
  try {
523
- engine = await projectComposeEngine(cwd, config);
529
+ choice = await generatedFilesEngine(cwd, config);
524
530
  }
525
531
  catch (err) {
526
- degraded("The project's engine image could not be resolved, admin config and types not refreshed", errorMessage(err));
532
+ degraded("No engine could write the admin config and types, so they were not refreshed", errorMessage(err));
527
533
  return;
528
534
  }
529
- if (engine === undefined && !(await hostEngineOrComposeFallback(cwd, config, ast, adminConfigPath)))
530
- return;
531
- await writeEngineArtifacts(cwd, config, ast, adminConfigPath, engine);
535
+ await writeEngineArtifacts(cwd, config, ast, join(cwd, ".supatype", "admin-config.json"), choice.engine);
536
+ // Said after writing, so SUPATYPE_STRICT fails the run with the files written and the true reason.
537
+ if (choice.fellBack !== undefined)
538
+ degraded(ENGINE_FALLBACK, choice.fellBack);
532
539
  }
533
540
  /** The files read straight off the applied AST, written whatever happens with the generator afterwards. */
534
541
  function writeAstDerivedArtifacts(cwd, config, ast) {
@@ -540,21 +547,11 @@ function writeAstDerivedArtifacts(cwd, config, ast) {
540
547
  // Every project running on Compose therefore had a manifest with no `hooks` and no `validators`
541
548
  // key, and the server, having nothing to call, ran neither. A hook silently not firing is bad; a
542
549
  // validator silently not firing means a write the schema says is checked is accepted with a 201.
543
- const hooksModule = writeHooksModule(cwd, hooksPathFromProject(config, cwd), ast);
544
- if (hooksModule !== null)
545
- console.log(`[supatype] Hook handler types written to ${hooksModule}`);
546
- // And the context module, on the same terms. `init` and `functions new` wrote it and nothing
547
- // else did, so a project that already had functions when the two-argument contract landed never
548
- // received one: its handlers had no `FunctionContext` to import.
549
- if (refreshFunctionsContext(cwd, config)) {
550
- console.log("[supatype] Function context type written to functions/_shared/context.ts");
551
- }
552
- if (syncManifestHooks(cwd, ast)) {
553
- console.log("[supatype] Hook and validator maps written to .supatype/manifest.json");
554
- }
555
- // Written before the stack comes up, so a first run with a row cache declared starts with it on
556
- // rather than needing a second `supatype dev`.
557
- const rowCache = syncRowCacheEnv(cwd, ast);
550
+ // The row cache is written before the stack comes up, so a first run with a row cache declared
551
+ // starts with it on rather than needing a second `supatype dev`.
552
+ const { lines, rowCache } = writeAppliedAstArtifacts(cwd, config, ast, { rowCacheEnv: true });
553
+ for (const line of lines)
554
+ console.log(`[supatype] ${line}`);
558
555
  if (rowCache !== null) {
559
556
  console.log(`[supatype] ${rowCacheChangeNote(rowCache)}`);
560
557
  }
@@ -575,50 +572,14 @@ function writeAstDerivedArtifacts(cwd, config, ast) {
575
572
  * on `npm run seed` with ECONNREFUSED against a port nothing was listening on. The layout is the
576
573
  * stack's own (dev while a dev session holds it, otherwise self-host), so a self-host push in a
577
574
  * project that once ran dev keeps the self-host port, and the message names the variable it read.
575
+ * Only a URL the CLI owns moves: one that is yours is left as it is, for this run too.
578
576
  */
579
577
  function syncDatabaseUrlToStack(cwd, config) {
580
- const dbPort = syncDatabaseUrlPort(cwd, composeRenderMode(cwd, config.project.name) === "dev");
581
- if (dbPort === null)
582
- return;
583
- console.log(`[supatype] ${databaseUrlSyncMessage(dbPort)}`);
578
+ const sync = syncDatabaseUrlPort(cwd, composeRenderMode(cwd, config.project.name) === "dev");
579
+ if (sync !== null)
580
+ console.log(`[supatype] ${databaseUrlSyncMessage(sync)}`);
584
581
  }
585
- /**
586
- * True when the host engine binary is ready. When it is not, the in-compose engine writes the
587
- * admin config and types instead and this answers false, having said which happened.
588
- */
589
- async function hostEngineOrComposeFallback(cwd, config, ast, adminConfigPath) {
590
- try {
591
- await ensureEngine();
592
- return true;
593
- }
594
- catch (err) {
595
- // A project that named its engine gets that engine or an error, never a stand-in.
596
- if (hasEngineOverride(config)) {
597
- degraded("overrides.engine could not be used, admin config and types not refreshed", errorMessage(err));
598
- return false;
599
- }
600
- // The host engine is a CDN download and this machine could not complete it. The schema is
601
- // already applied, so fall back to the engine in compose rather than giving up: without
602
- // admin-config.json Studio reports "No schema has been pushed yet" on a stack whose schema is
603
- // entirely live, which reads as a failed push rather than a missing binary.
604
- const paths = selfHostComposePaths(cwd);
605
- const composeProject = composeProjectName(config.project.name);
606
- const wrote = await generateViaComposeEngine(paths, cwd, composeProject, config, ast, adminConfigPath)
607
- .catch(() => false);
608
- // Reported through `degraded` rather than warned, so a run that takes this path says so where
609
- // CI looks, rather than in a line that scrolls past.
610
- const message = errorMessage(err);
611
- if (wrote) {
612
- degraded("Host engine unavailable, used the in-compose engine instead", message);
613
- }
614
- else {
615
- degraded("Host engine unavailable, admin config and types not refreshed", `${message}\n[supatype] Studio will report no schema until this succeeds, even though the ` +
616
- "schema is applied. Retry with the stack up, or run `supatype push`.");
617
- }
618
- return false;
619
- }
620
- }
621
- /** The types, the AST outputs and the admin config, from `engine` (the host binary when undefined). */
582
+ /** The types, the seed builder and the admin config, from `engine` (the host binary when undefined). */
622
583
  async function writeEngineArtifacts(cwd, config, ast, adminConfigPath, engine) {
623
584
  // At the default paths when `output` is not set, which is every project `init` made before it
624
585
  // wrote one: gated on `output.types`, a renamed field left the typed client on the old name.
@@ -635,7 +596,6 @@ async function writeEngineArtifacts(cwd, config, ast, adminConfigPath, engine) {
635
596
  catch (err) {
636
597
  console.warn(`[supatype] Type generation failed: ${errorMessage(err)}`);
637
598
  }
638
- writeDevAstOutputs(cwd, ast, config, "");
639
599
  await writeDevSeedBuilder(cwd, config, ast, engine);
640
600
  try {
641
601
  const admin = withAdminRoles(await engineRequest("/admin", { ast }, isAnyAnswer, engine), config);
@@ -765,13 +725,14 @@ function writeSchemaAstFile(cwd, astJson) {
765
725
  */
766
726
  async function applyViaHostEngine(cwd, config, ast, opts) {
767
727
  await ensureEngine();
768
- const sources = writeSchemaSourcePushArtifacts(cwd);
728
+ const sources = writeSchemaSourcePushArtifacts(cwd, opts.snapshotOptional === true);
769
729
  const body = {
770
730
  ast,
771
731
  database_url: projectDatabaseUrl(cwd, config),
772
732
  schema: pgSchema(config),
773
733
  force: opts.force === true,
774
734
  ...(opts.overwriteDrift === true && { overwrite_drift: true }),
735
+ ...(opts.runHooks === true && { run_hooks: true }),
775
736
  ...(sources !== null && {
776
737
  schema_sources_gz_base64: sources.payload.dataBase64,
777
738
  schema_sources_manifest: sources.payload.manifest,
@@ -782,7 +743,7 @@ async function applyViaHostEngine(cwd, config, ast, opts) {
782
743
  /** Apply the AST on disk with the stack's schema-engine container. Throws when it is not applied. */
783
744
  async function applyViaComposeEngine(cwd, config, stack, opts) {
784
745
  const { paths, composeProject } = stack;
785
- const sources = writeSchemaSourcePushArtifacts(cwd);
746
+ const sources = writeSchemaSourcePushArtifacts(cwd, opts.snapshotOptional === true);
786
747
  const audit = opts.audit ?? (await composeAuditArgs(cwd, config));
787
748
  const pushOnce = () => runComposeEnginePush(paths, cwd, composeProject, config, sources, { ...opts, audit });
788
749
  const runPush = async () => {
@@ -791,7 +752,7 @@ async function applyViaComposeEngine(cwd, config, stack, opts) {
791
752
  // engine's considered answer, not a lagging mount, and running it again only repeats it.
792
753
  if (first.status === 0 || consentRefusal(first.output) !== null)
793
754
  return first;
794
- await new Promise((r) => setTimeout(r, 250));
755
+ await sleep(250);
795
756
  return pushOnce();
796
757
  };
797
758
  // B: only hold the advisory lock when realtime is already decoding, first-boot
@@ -857,7 +818,13 @@ export function followRecordedTier(cwd, config, opts) {
857
818
  */
858
819
  async function runDevSchemaPush(cwd, config, paths, schemaPath, composeProject, opts) {
859
820
  const audit = opts.audit ?? (hasEngineOverride(config) ? [] : await composeAuditArgs(cwd, config));
860
- const once = (overwriteDrift) => pushConsentingToDestructive((force) => runComposeSchemaPush(cwd, config, paths, schemaPath, composeProject, { ...opts, audit, overwriteDrift, force }), DEV_DESTRUCTIVE_POLICY, consentDepsFromDiff(cwd, () => dockerDiff(cwd, config)));
821
+ const once = (overwriteDrift) => pushConsentingToDestructive((force) => runComposeSchemaPush(cwd, config, paths, schemaPath, composeProject, {
822
+ ...opts,
823
+ audit,
824
+ overwriteDrift,
825
+ force,
826
+ snapshotOptional: true,
827
+ }), DEV_DESTRUCTIVE_POLICY, consentDepsFromDiff(cwd, () => dockerDiff(cwd, config)));
861
828
  return devPushConsentingToDrift(once, opts.overwriteDrift === true, {
862
829
  beforeOverwrite: () => requireDockerFeatures(cwd, config, [OVERWRITE_DRIFT_NEED]),
863
830
  });
@@ -911,12 +878,12 @@ export async function dockerEngineCapabilities(cwd, config) {
911
878
  const probe = () => {
912
879
  const paths = writeSelfHostCompose(cwd, config, composeRenderOptions(cwd, config.project.name));
913
880
  const target = { cwd, project: composeProjectName(config.project.name), composePath: paths.composePath, engineImage };
914
- return probeCapabilities((args) => {
881
+ return checkedCapabilities((args) => {
915
882
  const run = spawnComposeEngine(target, args, { runFlags: ["--no-deps"] });
916
- return { status: run.status, stdout: run.stdout ?? "", stderr: run.error?.message ?? run.stderr ?? "" };
883
+ return { status: run.status, stdout: run.stdout, stderr: run.error ?? run.stderr };
917
884
  });
918
885
  };
919
- const imageId = engineImage === undefined ? "compose-default" : localImageId(engineImage);
886
+ const imageId = engineImage === undefined ? "compose-default" : await localImageId(engineImage);
920
887
  // Not pulled yet: the probe pulls it, and the next call keys on the ID it then has.
921
888
  if (imageId === undefined)
922
889
  return probe();
@@ -926,8 +893,8 @@ export async function dockerEngineCapabilities(cwd, config) {
926
893
  * The local image's ID, or undefined when Docker does not have it. The answer is keyed on it, so
927
894
  * a tag that now names another image (a pull, a rebuild) is asked again, and nothing else is.
928
895
  */
929
- function localImageId(image) {
930
- const inspect = spawnSync("docker", ["image", "inspect", "--format", "{{.Id}}", image], { encoding: "utf8" });
896
+ async function localImageId(image) {
897
+ const inspect = await askDocker(["image", "inspect", "--format", "{{.Id}}", image], { timeoutMs: DOCKER_QUERY_TIMEOUT_MS });
931
898
  const id = inspect.status === 0 ? inspect.stdout.trim() : "";
932
899
  return id === "" ? undefined : id;
933
900
  }
@@ -953,6 +920,8 @@ export function composeEnginePushArgs(sources, opts = {}) {
953
920
  // Only when asked: an engine older than the ledger rejects the flag.
954
921
  if (opts.overwriteDrift === true)
955
922
  args.push("--overwrite-drift");
923
+ if (opts.runHooks === true)
924
+ args.push("--run-hooks");
956
925
  if (sources) {
957
926
  args.push("--schema-sources-gz", sources.dockerGzPath, "--schema-sources-manifest", sources.dockerManifestPath);
958
927
  }
@@ -1059,57 +1028,98 @@ export async function adoptSchemaDocker(cwd, config, yes, keys) {
1059
1028
  * `supatype diff` when `provider: docker`. Uses in-compose schema-engine unless
1060
1029
  * `overrides.engine` is set: then Postgres is published to the host and diff runs
1061
1030
  * through the local engine binary.
1031
+ *
1032
+ * A dry run leaves the machine as it found it: a database the diff had to start is stopped again
1033
+ * afterwards. It used to be left running.
1062
1034
  */
1063
1035
  export async function diffSchemaDocker(cwd, config) {
1064
1036
  if (resolveRuntimeProvider(config) !== "docker") {
1065
1037
  throw new Error("diffSchemaDocker requires provider: docker");
1066
1038
  }
1067
1039
  const project = composeProjectName(config.project.name);
1040
+ const brand = { intro: "Schema diff" };
1068
1041
  if (hasEngineOverride(config)) {
1069
- const brand = { intro: "Schema diff" };
1070
- await ensureDockerDbPublishedForHostEngine(cwd, config, brand);
1071
- const schemaPath = schemaPathFromProject(config, cwd);
1072
- const ast = withPublishing(loadSchemaAst(schemaPath, cwd), config);
1073
- await ensureEngine();
1074
- return engineRequest("/diff", { ast, database_url: projectDatabaseUrl(cwd, config), schema: pgSchema(config) }, isDiffResult);
1042
+ return withComposeDatabaseStarted(cwd, config, project, () => ensureDockerDbPublishedForHostEngine(cwd, config, brand), () => diffWithHostEngine(cwd, config));
1075
1043
  }
1076
- // A diff of a standalone stack must not write dev values over the operator's .env (SH1).
1044
+ // A diff of a standalone stack must not write dev values over the operator's .env (SH1). A dev
1045
+ // stack's is brought up to date as push does: compose interpolates the whole file, so a project
1046
+ // that has not yet run `dev` can lack values `up -d db` needs.
1077
1047
  const mode = composeRenderMode(cwd, config.project.name);
1078
1048
  if (mode === "dev") {
1079
1049
  const { anonKey, serviceRoleKey } = devApiKeys(cwd);
1080
1050
  ensureDevComposeEnv(cwd, config, anonKey, serviceRoleKey, await resolveKongPort(cwd, project), undefined);
1081
1051
  }
1082
1052
  const paths = writeSelfHostCompose(cwd, config, { devLocal: mode === "dev" });
1083
- const diffBrand = { intro: "Schema diff" };
1084
- await startComposeDatabase(config, paths, cwd, project, diffBrand);
1085
- const schemaPath = schemaPathFromProject(config, cwd);
1086
- const ast = withPublishing(loadSchemaAst(schemaPath, cwd), config);
1053
+ return withComposeDatabaseStarted(cwd, config, project, () => startComposeDatabase(config, paths, cwd, project, brand), () => diffWithComposeEngine(cwd, config, paths, project));
1054
+ }
1055
+ /**
1056
+ * `run` with the stack's database up, `start` bringing it up, then stopped again when it was not
1057
+ * running before. One that a `supatype dev` session or a running stack is using is left as it was.
1058
+ */
1059
+ async function withComposeDatabaseStarted(cwd, config, project, start, run) {
1060
+ const stack = { project, composePath: selfHostComposePaths(cwd).composePath };
1061
+ // An external database is not the stack's to start or stop.
1062
+ const wasStopped = !usesExternalDatabase(config) && !composeServiceIsRunning(cwd, stack, "db");
1063
+ let started = false;
1064
+ try {
1065
+ await start();
1066
+ started = true;
1067
+ return await run();
1068
+ }
1069
+ finally {
1070
+ // A start that failed after `up -d db` (its health wait, the host publish) has still brought
1071
+ // the container up; one refused before it (no stack running) has started nothing to stop.
1072
+ if (wasStopped && (started || composeServiceIsRunning(cwd, stack, "db")))
1073
+ stopComposeDatabase(cwd, stack);
1074
+ }
1075
+ }
1076
+ /** Stop the stack's database, saying so rather than failing the command whose result is already in hand. */
1077
+ function stopComposeDatabase(cwd, stack) {
1078
+ try {
1079
+ const status = runDockerCompose(stack.composePath, ["stop", "db"], cwd, stack.project, { quiet: true });
1080
+ if (status !== 0)
1081
+ warn("Could not stop the Postgres container this command started. Stop it with `supatype self-host compose stop db`.");
1082
+ }
1083
+ catch (err) {
1084
+ warn(`Could not stop the Postgres container this command started: ${errorMessage(err)}`);
1085
+ }
1086
+ }
1087
+ /** The diff from the host engine binary, against the database published to the host. */
1088
+ async function diffWithHostEngine(cwd, config) {
1089
+ const ast = withPublishing(loadSchemaAst(schemaPathFromProject(config, cwd), cwd), config);
1090
+ await ensureEngine();
1091
+ return engineRequest("/diff", { ast, database_url: projectDatabaseUrl(cwd, config), schema: pgSchema(config) }, isDiffResult);
1092
+ }
1093
+ /** The diff from the compose schema-engine, which reads the AST written beside the compose file. */
1094
+ async function diffWithComposeEngine(cwd, config, paths, project) {
1095
+ const ast = withPublishing(loadSchemaAst(schemaPathFromProject(config, cwd), cwd), config);
1087
1096
  await requireDockerFeatures(cwd, config, identityColumnsNeed(ast));
1088
1097
  const supatypeDir = join(cwd, ".supatype");
1089
1098
  mkdirSync(supatypeDir, { recursive: true });
1090
- const astPath = join(supatypeDir, "schema.ast.json");
1091
- writeFileSync(astPath, JSON.stringify(ast));
1099
+ writeFileSync(join(supatypeDir, "schema.ast.json"), JSON.stringify(ast));
1092
1100
  let result = await runComposeEngineDiff(paths, cwd, project, config);
1093
1101
  // Windows Docker bind mounts can lag briefly after the host write.
1094
1102
  if (result.status !== 0) {
1095
- await new Promise((r) => setTimeout(r, 250));
1103
+ await sleep(250);
1096
1104
  result = await runComposeEngineDiff(paths, cwd, project, config);
1097
1105
  }
1098
1106
  if (result.status !== 0) {
1099
1107
  const detail = filterComposeNoise(result.output) || result.output;
1100
1108
  throw new Error(detail || `Engine schema diff failed (exit ${result.status})`);
1101
1109
  }
1102
- if (!result.diff) {
1103
- // The engine exited 0 and produced nothing this could parse, which is a different failure from
1104
- // the engine exiting non-zero and is the harder one to act on. "Engine diff returned no result"
1105
- // named only the symptom, and running the same compose command by hand gave a clear error in
1106
- // one go, so the message was the only thing standing between the reader and the answer.
1107
- const output = (filterComposeNoise(result.output) || result.output || "").trim();
1108
- throw new Error(output === ""
1109
- ? "The schema engine exited 0 and printed nothing. Run `supatype self-host compose run --rm schema-engine diff` to see what it does."
1110
- : `The schema engine exited 0 but its output could not be parsed as a diff:\n${output}`);
1111
- }
1112
- return result.diff;
1110
+ return result.diff ?? unparsedDiffError(result.output);
1111
+ }
1112
+ /**
1113
+ * The engine exited 0 and produced nothing this could parse, which is a different failure from the
1114
+ * engine exiting non-zero and is the harder one to act on. "Engine diff returned no result" named
1115
+ * only the symptom, and running the same compose command by hand gave a clear error in one go, so
1116
+ * the message was the only thing standing between the reader and the answer.
1117
+ */
1118
+ function unparsedDiffError(rawOutput) {
1119
+ const output = (filterComposeNoise(rawOutput) || rawOutput || "").trim();
1120
+ throw new Error(output === ""
1121
+ ? "The schema engine exited 0 and printed nothing. Run `supatype self-host compose run --rm schema-engine diff` to see what it does."
1122
+ : `The schema engine exited 0 but its output could not be parsed as a diff:\n${output}`);
1113
1123
  }
1114
1124
  /**
1115
1125
  * `supatype push` when `provider: docker`. Uses in-compose schema-engine unless
@@ -1187,7 +1197,7 @@ async function applyInitialSchema(cwd, config, paths, schemaPath, project, brand
1187
1197
  push: () => runDevSchemaPush(cwd, config, paths, schemaPath, project, opts),
1188
1198
  recoverDatabase: () => startComposeDatabase(config, paths, cwd, project, brand, undefined, endDevSession),
1189
1199
  dumpLogs: (reason) => dumpComposeDbLogs(paths, cwd, project, reason),
1190
- sleep: (ms) => new Promise((r) => setTimeout(r, ms)),
1200
+ sleep: (ms) => sleep(ms),
1191
1201
  };
1192
1202
  const outcome = await adoptingOnRefusal(await pushInitialSchema(steps), steps, cwd, config);
1193
1203
  // Ending the session before an exit, so its message reaches the real terminal rather than a TUI
@@ -1208,6 +1218,18 @@ async function adoptingOnRefusal(outcome, steps, cwd, config) {
1208
1218
  });
1209
1219
  return adopted === "adopted" ? pushInitialSchema(steps) : outcome;
1210
1220
  }
1221
+ /**
1222
+ * The dev stack's database port, moved off one something else holds, or undefined for an external
1223
+ * database. A port only the shell gives is offered to `.env` before anything else reads the URL
1224
+ * (db-port-offer.ts), so a yes is what the rest of the run sees.
1225
+ */
1226
+ async function devStackDbPort(cwd, config, project) {
1227
+ if (!publishesDbToHost(config))
1228
+ return undefined;
1229
+ const port = await ensureDevDbPort(cwd, { composeProject: project, mayMove: true });
1230
+ await offerToSaveShellDbPort(cwd);
1231
+ return port;
1232
+ }
1211
1233
  export async function runDevCompose(cwd, config, opts) {
1212
1234
  if (resolveRuntimeProvider(config) !== "docker") {
1213
1235
  throw new Error("runDevCompose requires provider: docker");
@@ -1226,15 +1248,15 @@ export async function runDevCompose(cwd, config, opts) {
1226
1248
  // `overrides.engine` while the compose file published unconditionally is what left a project
1227
1249
  // with a database on 54329 and a URL still saying 5432.
1228
1250
  // Only dev moves the port off something else that holds it.
1229
- const devDbPort = publishesDbToHost(config)
1230
- ? await ensureDevDbPort(cwd, { composeProject: project, mayMove: true })
1231
- : undefined;
1251
+ const devDbPort = await devStackDbPort(cwd, config, project);
1232
1252
  const { anonKey, serviceRoleKey } = devApiKeys(cwd);
1233
1253
  const devBrand = { intro: "Local development" };
1234
1254
  const localServerImage = await ensureLocalServerDockerImage(cwd, config, devBrand);
1235
1255
  ensureDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPort, devDbPort);
1236
1256
  warnProjectAuthProviderSecrets(cwd, config);
1237
1257
  console.log(`[supatype] provider docker, starting self-host Compose stack (project ${project}, gateway :${kongPort})...`);
1258
+ await showDevStep("Preparing the Docker stack");
1259
+ noteUnpinnedImages(cwd);
1238
1260
  const paths = writeSelfHostCompose(cwd, config, composeRenderOptions(cwd, config.project.name));
1239
1261
  if (ensureDevApiConfig(cwd)) {
1240
1262
  console.log("[supatype] API config written to .supatype/api-config.json");
@@ -1253,6 +1275,7 @@ export async function runDevCompose(cwd, config, opts) {
1253
1275
  console.log("[supatype] Shutting down compose...");
1254
1276
  await shutdownState.studioProc?.stop();
1255
1277
  await shutdownState.appProc?.stop();
1278
+ await settleComposeRuns();
1256
1279
  const downStatus = runDockerCompose(paths.composePath, ["down"], cwd, project, { quiet: true });
1257
1280
  if (downStatus === 0) {
1258
1281
  console.log("[supatype] Compose stack stopped.");
@@ -1279,10 +1302,13 @@ export async function runDevCompose(cwd, config, opts) {
1279
1302
  }
1280
1303
  if (!usesExternalDatabase(config)) {
1281
1304
  console.log("[supatype] Bringing up Postgres (compose db)...");
1305
+ await showDevStep("Starting Postgres");
1282
1306
  }
1283
1307
  await startComposeDatabase(config, paths, cwd, project, devBrand, 180_000, endDevSession);
1284
1308
  // Settle before DDL: pg_isready can pass slightly before the instance is stable.
1285
- await new Promise((r) => setTimeout(r, 3000));
1309
+ await sleep(3000);
1310
+ // With the stack's database up, so a hand-written URL naming it is not reported as silent.
1311
+ await warnIfHandWrittenUrlSilent(cwd);
1286
1312
  if (!usesExternalDatabase(config)) {
1287
1313
  reconcileAuthenticatorPassword(paths, cwd, project);
1288
1314
  reconcileSqlEditorPassword(paths, cwd, project);
@@ -1292,21 +1318,21 @@ export async function runDevCompose(cwd, config, opts) {
1292
1318
  const schemaPath = schemaPathFromProject(config, cwd);
1293
1319
  // `dev --overwrite-drift`, already checked against this engine before the session began.
1294
1320
  const pushOptions = { overwriteDrift: opts.overwriteDrift === true };
1321
+ await showDevStep("Applying the schema");
1295
1322
  const schemaApplied = await applyInitialSchema(cwd, config, paths, schemaPath, project, devBrand, pushOptions);
1296
1323
  // Before the stack starts, so PostgREST comes up on the tier the push actually produced.
1297
1324
  followRecordedTier(cwd, config, { recreate: false });
1298
1325
  console.log("[supatype] Bringing up Docker Compose services...");
1299
- const upStatus = runDockerCompose(paths.composePath, ["up", "-d"], cwd, project, {
1300
- quiet: true,
1301
- brand: devBrand,
1302
- });
1326
+ await showDevStep("Starting services (the first start downloads their images)");
1327
+ const upStatus = await runDockerComposeQuietly(paths.composePath, ["up", "-d"], cwd, project, devBrand);
1303
1328
  if (upStatus !== 0) {
1304
1329
  endDevSession();
1305
1330
  exitComposeFailed(upStatus, "Could not start the local Compose stack.", devBrand);
1306
1331
  }
1307
1332
  if (localServerImage !== undefined) {
1308
1333
  console.log("[supatype] Recreating server with local image...");
1309
- const recreateStatus = runDockerCompose(paths.composePath, ["up", "-d", "--force-recreate", "--no-deps", "server"], cwd, project, { quiet: true, brand: devBrand });
1334
+ await showDevStep("Recreating the server");
1335
+ const recreateStatus = await runDockerComposeQuietly(paths.composePath, ["up", "-d", "--force-recreate", "--no-deps", "server"], cwd, project, devBrand);
1310
1336
  if (recreateStatus !== 0) {
1311
1337
  endDevSession();
1312
1338
  exitComposeFailed(recreateStatus, "Could not recreate the server container with the local image.", devBrand);
@@ -1323,7 +1349,8 @@ export async function runDevCompose(cwd, config, opts) {
1323
1349
  if (readEnvValue(cwd, variable, "").trim() === "")
1324
1350
  continue;
1325
1351
  console.log(`[supatype] Recreating ${service} with pinned image...`);
1326
- const status = runDockerCompose(paths.composePath, ["up", "-d", "--force-recreate", "--no-deps", service], cwd, project, { quiet: true, brand: devBrand });
1352
+ await showDevStep(`Recreating ${service}`);
1353
+ const status = await runDockerComposeQuietly(paths.composePath, ["up", "-d", "--force-recreate", "--no-deps", service], cwd, project, devBrand);
1327
1354
  if (status !== 0) {
1328
1355
  endDevSession();
1329
1356
  exitComposeFailed(status, `Could not recreate the ${service} container.`, devBrand);
@@ -1343,9 +1370,12 @@ export async function runDevCompose(cwd, config, opts) {
1343
1370
  });
1344
1371
  }
1345
1372
  console.log("[supatype] Waiting for API gateway...");
1373
+ await showDevStep("Waiting for the API gateway");
1346
1374
  await waitKongReady(kongPort, 120, { composePath: paths.composePath, cwd, project });
1347
1375
  console.log("[supatype] Waiting for storage API...");
1376
+ await showDevStep("Waiting for storage");
1348
1377
  await waitStorageApiReady(kongPort, serviceRoleKey, 90);
1378
+ await showDevStep("Checking for an admin user");
1349
1379
  await ensureFirstAdminUserForProject(cwd, config, {
1350
1380
  compose: { project, composePath: paths.composePath },
1351
1381
  });
@@ -1433,70 +1463,4 @@ export async function runDevCompose(cwd, config, opts) {
1433
1463
  // Until Ctrl+C or a signal: the shutdown hook takes the stack down and exits.
1434
1464
  await waitForDevShutdown();
1435
1465
  }
1436
- /**
1437
- * Run one read-only generator in the in-compose schema-engine and return its stdout.
1438
- *
1439
- * The same image and the same bind mount the push just used, so if the schema could be applied
1440
- * this can run. It exists because the host engine is a separate binary fetched from a CDN, and a
1441
- * machine that cannot fetch it is not a machine that cannot generate: the schema is already
1442
- * applied, the AST is already on disk, and the container that did it is one `docker compose run`
1443
- * away.
1444
- */
1445
- async function runComposeEngineGenerator(paths, cwd, composeProject, config, args) {
1446
- const engineImage = await schemaEngineImageForPush(config, cwd);
1447
- const target = { cwd, project: composeProject, composePath: paths.composePath, engineImage };
1448
- const result = spawnComposeEngine(target, [...args, "-i", COMPOSE_SCHEMA_AST], {
1449
- runFlags: ["-T"],
1450
- maxBuffer: 20 * 1024 * 1024,
1451
- });
1452
- if ((result.status ?? 1) !== 0)
1453
- return null;
1454
- return String(result.stdout ?? "");
1455
- }
1456
- /**
1457
- * The in-compose engine as {@link engineRequest} takes it, for generating only. No database URL:
1458
- * `/generate` reads the AST alone and runs without starting the database.
1459
- */
1460
- async function composeGeneratorEngine(paths, cwd, composeProject, config) {
1461
- const engineImage = await schemaEngineImageForPush(config, cwd);
1462
- return {
1463
- target: { cwd, project: composeProject, composePath: paths.composePath, engineImage },
1464
- databaseUrl: "",
1465
- capabilities: () => dockerEngineCapabilities(cwd, config),
1466
- };
1467
- }
1468
- /**
1469
- * Write `admin-config.json` and the generated types using the in-compose engine.
1470
- *
1471
- * The fallback for a host engine that could not be fetched. Without it, a `supatype dev` that
1472
- * applied the schema perfectly well still left no `admin-config.json`, and Studio reads that file
1473
- * to decide whether a schema exists: the stack came up, every table was live, the API served them,
1474
- * and Studio said **"No schema has been pushed yet."** The warning that preceded it named the
1475
- * download, not the consequence, so nothing connected the two.
1476
- *
1477
- * Returns true when the admin config was written, which is the file Studio actually needs.
1478
- */
1479
- export async function generateViaComposeEngine(paths, cwd, composeProject, config, ast, adminConfigPath) {
1480
- const { typesPath } = projectOutputPaths(config.output);
1481
- const out = await runComposeEngineGenerator(paths, cwd, composeProject, config, ["generate"]);
1482
- if (writeEngineTypes(cwd, typesPath, out ?? undefined)) {
1483
- console.log(`[supatype] Types written to ${typesPath} (in-compose engine).`);
1484
- }
1485
- // The same AST-derived files as the host path. This is the fallback used when the host engine
1486
- // could not be fetched, and these need no engine at all, so there is no reason for a project on
1487
- // this path to end up with fewer generated files than one on the other.
1488
- writeDevAstOutputs(cwd, ast, config, " (in-compose engine).");
1489
- await writeDevSeedBuilder(cwd, config, ast, await composeGeneratorEngine(paths, cwd, composeProject, config));
1490
- const adminOut = await runComposeEngineGenerator(paths, cwd, composeProject, config, ["admin"]);
1491
- if (!adminOut)
1492
- return false;
1493
- const parsed = parseEngineJsonOutput(adminOut, isObjectAnswer);
1494
- if (parsed === null)
1495
- return false;
1496
- const admin = withAdminRoles(parsed, config);
1497
- restoreSystemRelationTargets(admin, ast);
1498
- writeFileSync(adminConfigPath, `${JSON.stringify(admin, null, 2)}\n`);
1499
- console.log("[supatype] Admin config written to .supatype/admin-config.json (in-compose engine).");
1500
- return true;
1501
- }
1502
1466
  //# sourceMappingURL=dev-compose.js.map