@supatype/cli 0.9.1 → 0.9.2

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 (359) hide show
  1. package/CHANGELOG.md +303 -91
  2. package/bin/node-version.js +28 -0
  3. package/bin/supatype.js +8 -4
  4. package/dist/app/port-holder.d.ts +33 -0
  5. package/dist/app/port-holder.d.ts.map +1 -0
  6. package/dist/app/port-holder.js +66 -0
  7. package/dist/app/port-holder.js.map +1 -0
  8. package/dist/app/proxy-dev-app.d.ts +21 -3
  9. package/dist/app/proxy-dev-app.d.ts.map +1 -1
  10. package/dist/app/proxy-dev-app.js +84 -46
  11. package/dist/app/proxy-dev-app.js.map +1 -1
  12. package/dist/app/vite-dev-args.d.ts +20 -0
  13. package/dist/app/vite-dev-args.d.ts.map +1 -0
  14. package/dist/app/vite-dev-args.js +65 -0
  15. package/dist/app/vite-dev-args.js.map +1 -0
  16. package/dist/app-config.d.ts +2 -0
  17. package/dist/app-config.d.ts.map +1 -1
  18. package/dist/app-config.js +27 -8
  19. package/dist/app-config.js.map +1 -1
  20. package/dist/augmentation-generator.d.ts +2 -0
  21. package/dist/augmentation-generator.d.ts.map +1 -1
  22. package/dist/augmentation-generator.js +7 -3
  23. package/dist/augmentation-generator.js.map +1 -1
  24. package/dist/binary-download-lock.d.ts.map +1 -1
  25. package/dist/binary-download-lock.js +2 -10
  26. package/dist/binary-download-lock.js.map +1 -1
  27. package/dist/cache-provider.d.ts +17 -2
  28. package/dist/cache-provider.d.ts.map +1 -1
  29. package/dist/cache-provider.js +28 -3
  30. package/dist/cache-provider.js.map +1 -1
  31. package/dist/cli-version-embedded.js +1 -1
  32. package/dist/cli.d.ts +7 -0
  33. package/dist/cli.d.ts.map +1 -1
  34. package/dist/cli.js +10 -1
  35. package/dist/cli.js.map +1 -1
  36. package/dist/commands/admin.js +5 -11
  37. package/dist/commands/admin.js.map +1 -1
  38. package/dist/commands/app.d.ts.map +1 -1
  39. package/dist/commands/app.js +22 -2
  40. package/dist/commands/app.js.map +1 -1
  41. package/dist/commands/dev.d.ts +21 -4
  42. package/dist/commands/dev.d.ts.map +1 -1
  43. package/dist/commands/dev.js +222 -68
  44. package/dist/commands/dev.js.map +1 -1
  45. package/dist/commands/doctor.js +1 -1
  46. package/dist/commands/doctor.js.map +1 -1
  47. package/dist/commands/generate.d.ts.map +1 -1
  48. package/dist/commands/generate.js +3 -0
  49. package/dist/commands/generate.js.map +1 -1
  50. package/dist/commands/init.d.ts +6 -8
  51. package/dist/commands/init.d.ts.map +1 -1
  52. package/dist/commands/init.js +193 -114
  53. package/dist/commands/init.js.map +1 -1
  54. package/dist/commands/link-helpers.js +1 -1
  55. package/dist/commands/link-helpers.js.map +1 -1
  56. package/dist/commands/push.d.ts.map +1 -1
  57. package/dist/commands/push.js +3 -1
  58. package/dist/commands/push.js.map +1 -1
  59. package/dist/commands/self-host.d.ts +3 -3
  60. package/dist/commands/self-host.d.ts.map +1 -1
  61. package/dist/commands/self-host.js +68 -269
  62. package/dist/commands/self-host.js.map +1 -1
  63. package/dist/commands/update.d.ts.map +1 -1
  64. package/dist/commands/update.js +156 -63
  65. package/dist/commands/update.js.map +1 -1
  66. package/dist/compose-db-roles.d.ts.map +1 -1
  67. package/dist/compose-db-roles.js +3 -0
  68. package/dist/compose-db-roles.js.map +1 -1
  69. package/dist/compose-rename.d.ts.map +1 -1
  70. package/dist/compose-rename.js +5 -0
  71. package/dist/compose-rename.js.map +1 -1
  72. package/dist/compose-render-mode.d.ts +8 -3
  73. package/dist/compose-render-mode.d.ts.map +1 -1
  74. package/dist/compose-render-mode.js +13 -5
  75. package/dist/compose-render-mode.js.map +1 -1
  76. package/dist/compose-services.d.ts.map +1 -1
  77. package/dist/compose-services.js +3 -2
  78. package/dist/compose-services.js.map +1 -1
  79. package/dist/config-mailer-env.d.ts +6 -2
  80. package/dist/config-mailer-env.d.ts.map +1 -1
  81. package/dist/config-mailer-env.js +9 -11
  82. package/dist/config-mailer-env.js.map +1 -1
  83. package/dist/config-version-pin.d.ts +42 -0
  84. package/dist/config-version-pin.d.ts.map +1 -0
  85. package/dist/config-version-pin.js +64 -0
  86. package/dist/config-version-pin.js.map +1 -0
  87. package/dist/config.d.ts +4 -0
  88. package/dist/config.d.ts.map +1 -1
  89. package/dist/config.js +6 -2
  90. package/dist/config.js.map +1 -1
  91. package/dist/dev-compose.d.ts +9 -4
  92. package/dist/dev-compose.d.ts.map +1 -1
  93. package/dist/dev-compose.js +87 -53
  94. package/dist/dev-compose.js.map +1 -1
  95. package/dist/dev-initial-push.d.ts.map +1 -1
  96. package/dist/dev-initial-push.js +6 -0
  97. package/dist/dev-initial-push.js.map +1 -1
  98. package/dist/dev-ports.d.ts +7 -2
  99. package/dist/dev-ports.d.ts.map +1 -1
  100. package/dist/dev-ports.js +44 -22
  101. package/dist/dev-ports.js.map +1 -1
  102. package/dist/dev-ready-panel.d.ts +26 -3
  103. package/dist/dev-ready-panel.d.ts.map +1 -1
  104. package/dist/dev-ready-panel.js +37 -5
  105. package/dist/dev-ready-panel.js.map +1 -1
  106. package/dist/dev-self-start.d.ts +16 -0
  107. package/dist/dev-self-start.d.ts.map +1 -0
  108. package/dist/dev-self-start.js +31 -0
  109. package/dist/dev-self-start.js.map +1 -0
  110. package/dist/dev-session-lock.d.ts +66 -2
  111. package/dist/dev-session-lock.d.ts.map +1 -1
  112. package/dist/dev-session-lock.js +104 -5
  113. package/dist/dev-session-lock.js.map +1 -1
  114. package/dist/dev-session.d.ts +6 -1
  115. package/dist/dev-session.d.ts.map +1 -1
  116. package/dist/dev-session.js +9 -3
  117. package/dist/dev-session.js.map +1 -1
  118. package/dist/dev-shutdown.d.ts +11 -2
  119. package/dist/dev-shutdown.d.ts.map +1 -1
  120. package/dist/dev-shutdown.js +23 -9
  121. package/dist/dev-shutdown.js.map +1 -1
  122. package/dist/docker-runtime.d.ts +31 -7
  123. package/dist/docker-runtime.d.ts.map +1 -1
  124. package/dist/docker-runtime.js +104 -36
  125. package/dist/docker-runtime.js.map +1 -1
  126. package/dist/engine-columns.d.ts +26 -0
  127. package/dist/engine-columns.d.ts.map +1 -0
  128. package/dist/engine-columns.js +67 -0
  129. package/dist/engine-columns.js.map +1 -0
  130. package/dist/env-file.d.ts +18 -3
  131. package/dist/env-file.d.ts.map +1 -1
  132. package/dist/env-file.js +23 -7
  133. package/dist/env-file.js.map +1 -1
  134. package/dist/frontend-env.d.ts +3 -2
  135. package/dist/frontend-env.d.ts.map +1 -1
  136. package/dist/frontend-env.js +1 -1
  137. package/dist/frontend-env.js.map +1 -1
  138. package/dist/functions-deno-types.d.ts.map +1 -1
  139. package/dist/functions-deno-types.js +5 -5
  140. package/dist/functions-deno-types.js.map +1 -1
  141. package/dist/functions-worker-files.d.ts.map +1 -1
  142. package/dist/functions-worker-files.js +2 -13
  143. package/dist/functions-worker-files.js.map +1 -1
  144. package/dist/generated/release-images.d.ts +6 -6
  145. package/dist/generated/release-images.js +3 -3
  146. package/dist/gitignore.d.ts +29 -2
  147. package/dist/gitignore.d.ts.map +1 -1
  148. package/dist/gitignore.js +86 -21
  149. package/dist/gitignore.js.map +1 -1
  150. package/dist/hooks-generator.d.ts.map +1 -1
  151. package/dist/hooks-generator.js +4 -2
  152. package/dist/hooks-generator.js.map +1 -1
  153. package/dist/host-database.d.ts +6 -2
  154. package/dist/host-database.d.ts.map +1 -1
  155. package/dist/host-database.js +10 -2
  156. package/dist/host-database.js.map +1 -1
  157. package/dist/init-dependency-versions.d.ts +2 -3
  158. package/dist/init-dependency-versions.d.ts.map +1 -1
  159. package/dist/init-dependency-versions.js +12 -9
  160. package/dist/init-dependency-versions.js.map +1 -1
  161. package/dist/init-example.d.ts.map +1 -1
  162. package/dist/init-example.js +13 -1
  163. package/dist/init-example.js.map +1 -1
  164. package/dist/init-expo-runtime-env.d.ts +25 -0
  165. package/dist/init-expo-runtime-env.d.ts.map +1 -0
  166. package/dist/init-expo-runtime-env.js +112 -0
  167. package/dist/init-expo-runtime-env.js.map +1 -0
  168. package/dist/init-next-runtime-env.d.ts +14 -1
  169. package/dist/init-next-runtime-env.d.ts.map +1 -1
  170. package/dist/init-next-runtime-env.js +116 -35
  171. package/dist/init-next-runtime-env.js.map +1 -1
  172. package/dist/init-package-json.d.ts +11 -3
  173. package/dist/init-package-json.d.ts.map +1 -1
  174. package/dist/init-package-json.js +20 -13
  175. package/dist/init-package-json.js.map +1 -1
  176. package/dist/init-port-registry.d.ts +19 -0
  177. package/dist/init-port-registry.d.ts.map +1 -0
  178. package/dist/init-port-registry.js +57 -0
  179. package/dist/init-port-registry.js.map +1 -0
  180. package/dist/init-project-detect.d.ts +20 -0
  181. package/dist/init-project-detect.d.ts.map +1 -1
  182. package/dist/init-project-detect.js +41 -8
  183. package/dist/init-project-detect.js.map +1 -1
  184. package/dist/init-vite-node.d.ts +21 -0
  185. package/dist/init-vite-node.d.ts.map +1 -0
  186. package/dist/init-vite-node.js +75 -0
  187. package/dist/init-vite-node.js.map +1 -0
  188. package/dist/jsx-first-child.d.ts +18 -0
  189. package/dist/jsx-first-child.d.ts.map +1 -0
  190. package/dist/jsx-first-child.js +53 -0
  191. package/dist/jsx-first-child.js.map +1 -0
  192. package/dist/keyspace-password-file.d.ts +46 -0
  193. package/dist/keyspace-password-file.d.ts.map +1 -0
  194. package/dist/keyspace-password-file.js +128 -0
  195. package/dist/keyspace-password-file.js.map +1 -0
  196. package/dist/kong-config.d.ts +1 -0
  197. package/dist/kong-config.d.ts.map +1 -1
  198. package/dist/kong-config.js +64 -20
  199. package/dist/kong-config.js.map +1 -1
  200. package/dist/local-gateway.d.ts +11 -3
  201. package/dist/local-gateway.d.ts.map +1 -1
  202. package/dist/local-gateway.js +16 -7
  203. package/dist/local-gateway.js.map +1 -1
  204. package/dist/local-secrets.d.ts +10 -0
  205. package/dist/local-secrets.d.ts.map +1 -1
  206. package/dist/local-secrets.js +13 -0
  207. package/dist/local-secrets.js.map +1 -1
  208. package/dist/local-stack-guard.d.ts.map +1 -1
  209. package/dist/local-stack-guard.js +3 -2
  210. package/dist/local-stack-guard.js.map +1 -1
  211. package/dist/local-stack.d.ts.map +1 -1
  212. package/dist/local-stack.js +7 -6
  213. package/dist/local-stack.js.map +1 -1
  214. package/dist/local-storage.d.ts +3 -5
  215. package/dist/local-storage.d.ts.map +1 -1
  216. package/dist/local-storage.js +10 -10
  217. package/dist/local-storage.js.map +1 -1
  218. package/dist/mailer-autoconfirm.d.ts +29 -24
  219. package/dist/mailer-autoconfirm.d.ts.map +1 -1
  220. package/dist/mailer-autoconfirm.js +47 -43
  221. package/dist/mailer-autoconfirm.js.map +1 -1
  222. package/dist/model-hooks.d.ts +4 -4
  223. package/dist/model-hooks.d.ts.map +1 -1
  224. package/dist/model-hooks.js +13 -7
  225. package/dist/model-hooks.js.map +1 -1
  226. package/dist/native-dev-env.d.ts +25 -2
  227. package/dist/native-dev-env.d.ts.map +1 -1
  228. package/dist/native-dev-env.js +39 -4
  229. package/dist/native-dev-env.js.map +1 -1
  230. package/dist/native-keyspace.d.ts +21 -6
  231. package/dist/native-keyspace.d.ts.map +1 -1
  232. package/dist/native-keyspace.js +48 -14
  233. package/dist/native-keyspace.js.map +1 -1
  234. package/dist/native-leftover-postgres.d.ts +23 -0
  235. package/dist/native-leftover-postgres.d.ts.map +1 -0
  236. package/dist/native-leftover-postgres.js +55 -0
  237. package/dist/native-leftover-postgres.js.map +1 -0
  238. package/dist/native-leftover-services.d.ts +17 -0
  239. package/dist/native-leftover-services.d.ts.map +1 -0
  240. package/dist/native-leftover-services.js +93 -0
  241. package/dist/native-leftover-services.js.map +1 -0
  242. package/dist/native-pg-auth.d.ts.map +1 -1
  243. package/dist/native-pg-auth.js +2 -1
  244. package/dist/native-pg-auth.js.map +1 -1
  245. package/dist/native-port-lock.d.ts +37 -0
  246. package/dist/native-port-lock.d.ts.map +1 -0
  247. package/dist/native-port-lock.js +78 -0
  248. package/dist/native-port-lock.js.map +1 -0
  249. package/dist/native-realtime.d.ts +6 -3
  250. package/dist/native-realtime.d.ts.map +1 -1
  251. package/dist/native-realtime.js +65 -24
  252. package/dist/native-realtime.js.map +1 -1
  253. package/dist/native-roles-sql.d.ts.map +1 -1
  254. package/dist/native-roles-sql.js +2 -1
  255. package/dist/native-roles-sql.js.map +1 -1
  256. package/dist/native-storage-import.d.ts.map +1 -1
  257. package/dist/native-storage-import.js +6 -5
  258. package/dist/native-storage-import.js.map +1 -1
  259. package/dist/native-storage.d.ts +42 -7
  260. package/dist/native-storage.d.ts.map +1 -1
  261. package/dist/native-storage.js +196 -50
  262. package/dist/native-storage.js.map +1 -1
  263. package/dist/parent-watch.d.ts.map +1 -1
  264. package/dist/parent-watch.js +4 -8
  265. package/dist/parent-watch.js.map +1 -1
  266. package/dist/postgres-ctl.d.ts +31 -5
  267. package/dist/postgres-ctl.d.ts.map +1 -1
  268. package/dist/postgres-ctl.js +49 -11
  269. package/dist/postgres-ctl.js.map +1 -1
  270. package/dist/postgres-image.d.ts +16 -0
  271. package/dist/postgres-image.d.ts.map +1 -1
  272. package/dist/postgres-image.js +34 -11
  273. package/dist/postgres-image.js.map +1 -1
  274. package/dist/process-info.d.ts +14 -0
  275. package/dist/process-info.d.ts.map +1 -0
  276. package/dist/process-info.js +41 -0
  277. package/dist/process-info.js.map +1 -0
  278. package/dist/process-manager.d.ts +73 -4
  279. package/dist/process-manager.d.ts.map +1 -1
  280. package/dist/process-manager.js +121 -45
  281. package/dist/process-manager.js.map +1 -1
  282. package/dist/process-tree.d.ts +48 -0
  283. package/dist/process-tree.d.ts.map +1 -0
  284. package/dist/process-tree.js +141 -0
  285. package/dist/process-tree.js.map +1 -0
  286. package/dist/project-config.d.ts +33 -4
  287. package/dist/project-config.d.ts.map +1 -1
  288. package/dist/project-config.js +5 -1
  289. package/dist/project-config.js.map +1 -1
  290. package/dist/required-host-components.d.ts.map +1 -1
  291. package/dist/required-host-components.js +3 -5
  292. package/dist/required-host-components.js.map +1 -1
  293. package/dist/route-manifest.d.ts +24 -0
  294. package/dist/route-manifest.d.ts.map +1 -1
  295. package/dist/route-manifest.js +60 -2
  296. package/dist/route-manifest.js.map +1 -1
  297. package/dist/run-captured.d.ts +3 -1
  298. package/dist/run-captured.d.ts.map +1 -1
  299. package/dist/run-captured.js.map +1 -1
  300. package/dist/run-until-stopped.d.ts +3 -0
  301. package/dist/run-until-stopped.d.ts.map +1 -1
  302. package/dist/run-until-stopped.js +25 -11
  303. package/dist/run-until-stopped.js.map +1 -1
  304. package/dist/runtime-routes.d.ts +5 -0
  305. package/dist/runtime-routes.d.ts.map +1 -1
  306. package/dist/runtime-routes.js +5 -1
  307. package/dist/runtime-routes.js.map +1 -1
  308. package/dist/secret-sql.d.ts +13 -0
  309. package/dist/secret-sql.d.ts.map +1 -0
  310. package/dist/secret-sql.js +13 -0
  311. package/dist/secret-sql.js.map +1 -0
  312. package/dist/seed-ir.d.ts +8 -1
  313. package/dist/seed-ir.d.ts.map +1 -1
  314. package/dist/seed-ir.js +92 -6
  315. package/dist/seed-ir.js.map +1 -1
  316. package/dist/seed.d.ts +15 -2
  317. package/dist/seed.d.ts.map +1 -1
  318. package/dist/self-host-compose.d.ts +15 -1
  319. package/dist/self-host-compose.d.ts.map +1 -1
  320. package/dist/self-host-compose.js +216 -51
  321. package/dist/self-host-compose.js.map +1 -1
  322. package/dist/stack-exit-watch.d.ts +15 -0
  323. package/dist/stack-exit-watch.d.ts.map +1 -1
  324. package/dist/stack-exit-watch.js +41 -13
  325. package/dist/stack-exit-watch.js.map +1 -1
  326. package/dist/stack-folder.d.ts +28 -0
  327. package/dist/stack-folder.d.ts.map +1 -0
  328. package/dist/stack-folder.js +123 -0
  329. package/dist/stack-folder.js.map +1 -0
  330. package/dist/stack-setting-warnings.d.ts +2 -1
  331. package/dist/stack-setting-warnings.d.ts.map +1 -1
  332. package/dist/stack-setting-warnings.js +6 -1
  333. package/dist/stack-setting-warnings.js.map +1 -1
  334. package/dist/storage-provision.d.ts +12 -2
  335. package/dist/storage-provision.d.ts.map +1 -1
  336. package/dist/storage-provision.js +36 -11
  337. package/dist/storage-provision.js.map +1 -1
  338. package/dist/type-extractor.d.ts.map +1 -1
  339. package/dist/type-extractor.js +27 -3
  340. package/dist/type-extractor.js.map +1 -1
  341. package/dist/ui/dev/DevReadyPanelView.js +1 -1
  342. package/dist/ui/dev/DevReadyPanelView.js.map +1 -1
  343. package/dist/valkey-sidecar.d.ts +24 -11
  344. package/dist/valkey-sidecar.d.ts.map +1 -1
  345. package/dist/valkey-sidecar.js +45 -25
  346. package/dist/valkey-sidecar.js.map +1 -1
  347. package/dist/windows-processes.d.ts +7 -0
  348. package/dist/windows-processes.d.ts.map +1 -0
  349. package/dist/windows-processes.js +31 -0
  350. package/dist/windows-processes.js.map +1 -0
  351. package/dist/write-if-changed.d.ts +12 -0
  352. package/dist/write-if-changed.d.ts.map +1 -0
  353. package/dist/write-if-changed.js +32 -0
  354. package/dist/write-if-changed.js.map +1 -0
  355. package/package.json +6 -4
  356. package/dist/systemd.d.ts +0 -26
  357. package/dist/systemd.d.ts.map +0 -1
  358. package/dist/systemd.js +0 -117
  359. package/dist/systemd.js.map +0 -1
@@ -1,23 +1,38 @@
1
1
  import type { SupatypeProjectConfig } from "./project-config.js";
2
+ import { type RespCredentials } from "./valkey-sidecar.js";
2
3
  /** What the native keyspace decision asks of the machine before Postgres starts. */
3
4
  export interface NativeKeyspaceChecks {
4
5
  libraryPresent: (pgBinDir: string | null) => boolean;
5
6
  freePort: () => Promise<number | null>;
6
7
  }
7
8
  /**
8
- * The port native Postgres should serve RESP on, or null for the Valkey sidecar.
9
+ * The port native Postgres should serve RESP on, or null for the Valkey sidecar. `version` is the
10
+ * archive's, as dev resolved it to find the archive; null when it is not known, as for a local build.
9
11
  *
10
12
  * `cache.provider: "valkey"` is honoured here, and this is the only place it could be: without
11
13
  * asking the config, an archive that carries the library would serve RESP anyway and a project
12
14
  * that deliberately kept the sidecar would never get it.
13
15
  */
14
- export declare function nativeKeyspacePort(config: SupatypeProjectConfig, pgBinDir: string | null, checks?: NativeKeyspaceChecks): Promise<number | null>;
16
+ export declare function nativeKeyspacePort(config: SupatypeProjectConfig, pgBinDir: string | null, version: string | null, checks?: NativeKeyspaceChecks): Promise<number | null>;
17
+ /**
18
+ * Writes the project's keyspace password to `<state root>/keyspace/password`, and says where:
19
+ * `pg_keyspace.password_file`, which the extension reads at start and on every reload, giving the
20
+ * `supatype` user that password and refusing every client that has not logged in. Only the path
21
+ * is ever a setting, so the password is in no command line, setting or log.
22
+ *
23
+ * Readable by this user alone: the directory 0700 and the file 0600, put right when an earlier one
24
+ * was wider, since the mode given at creation applies to a new file only. Written at every start,
25
+ * so a password changed in .env is the one the next start reads. No newline is written; the
26
+ * extension would drop one, and anything else would be part of the password.
27
+ */
28
+ export declare function writeKeyspacePasswordFile(stateRoot: string, password: string): string;
15
29
  /**
16
30
  * The address the cache should talk to when Postgres serves RESP, or null for the Valkey sidecar.
17
31
  *
18
- * The probe is not ceremony: shared memory limits, a preload ordering mistake or a port taken
19
- * between the check and the start all leave a Postgres that is running and a keyspace that is
20
- * not, and the difference is a cache that silently never hits.
32
+ * The probe logs in, since the keyspace refuses PING before AUTH, and is not ceremony: shared
33
+ * memory limits, a preload ordering mistake, a password file that could not be read or a port
34
+ * taken between the check and the start all leave a Postgres that is running and a keyspace that
35
+ * is not, and the difference is a cache that silently never hits.
21
36
  */
22
- export declare function nativeKeyspaceAddr(keyspacePort: number | null, respAnswers?: (port: number) => Promise<boolean>): Promise<string | null>;
37
+ export declare function nativeKeyspaceAddr(keyspacePort: number, credentials: RespCredentials, respAnswers?: (port: number) => Promise<boolean>): Promise<string | null>;
23
38
  //# sourceMappingURL=native-keyspace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"native-keyspace.d.ts","sourceRoot":"","sources":["../src/native-keyspace.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAGhE,oFAAoF;AACpF,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAA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;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,eAAe,EAC5B,WAAW,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAA6E,GAC1H,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAOxB"}
@@ -3,30 +3,45 @@
3
3
  * cache to the Valkey sidecar.
4
4
  *
5
5
  * Two questions, asked at two moments. Before Postgres starts: does the project want the
6
- * keyspace, does the archive carry the library, and is there a port for it. After it starts: does
7
- * that port answer. A no to any of them is the Valkey sidecar, never an error, because a missing
8
- * cache must not become a missing database.
6
+ * keyspace, does the archive carry the library and can it require a password, and is there a port
7
+ * for it. After it starts: does the port answer a client that logs in with the project's password,
8
+ * which the extension reads itself from the file native dev wrote ({@link writeKeyspacePasswordFile}).
9
+ * A no to any of them is the Valkey sidecar, never an error, because a missing cache must not
10
+ * become a missing database.
9
11
  *
10
- * The filesystem, port and RESP checks are parameters so the decision can be tested against an
11
- * archive that carries the library and one that does not, without starting anything.
12
+ * 0.9.2 release test (N-RB2): the keyspace listened on 0.0.0.0 and answered every client, so
13
+ * native dev on Linux served an open, writable store to the network. It is served only from an
14
+ * archive at KEYSPACE_AUTH_SINCE or later, on loopback, requiring AUTH (postgres-ctl.ts).
15
+ *
16
+ * The filesystem, version, port and RESP checks are parameters so the decision can be tested
17
+ * against an archive that carries the library and one that does not, without starting anything.
12
18
  */
19
+ import { chmodSync, mkdirSync, writeFileSync } from "node:fs";
20
+ import { join } from "node:path";
13
21
  import { nativeKeyspaceWanted } from "./cache-provider.js";
14
- import { firstFreePort, KEYSPACE_PORT_BASE, KEYSPACE_PORT_SPAN, nativeKeyspaceLibraryPresent, } from "./postgres-ctl.js";
22
+ import { firstFreePort, KEYSPACE_PORT_BASE, KEYSPACE_PORT_SPAN, nativeKeyspaceLibraryPresent } from "./postgres-ctl.js";
23
+ import { archiveHasKeyspaceAuth, KEYSPACE_AUTH_SINCE } from "./postgres-image.js";
15
24
  import { answersPing } from "./valkey-sidecar.js";
16
25
  const machineChecks = {
17
26
  libraryPresent: nativeKeyspaceLibraryPresent,
18
27
  freePort: () => firstFreePort(KEYSPACE_PORT_BASE, KEYSPACE_PORT_SPAN),
19
28
  };
20
29
  /**
21
- * The port native Postgres should serve RESP on, or null for the Valkey sidecar.
30
+ * The port native Postgres should serve RESP on, or null for the Valkey sidecar. `version` is the
31
+ * archive's, as dev resolved it to find the archive; null when it is not known, as for a local build.
22
32
  *
23
33
  * `cache.provider: "valkey"` is honoured here, and this is the only place it could be: without
24
34
  * asking the config, an archive that carries the library would serve RESP anyway and a project
25
35
  * that deliberately kept the sidecar would never get it.
26
36
  */
27
- export async function nativeKeyspacePort(config, pgBinDir, checks = machineChecks) {
37
+ export async function nativeKeyspacePort(config, pgBinDir, version, checks = machineChecks) {
28
38
  if (!nativeKeyspaceWanted(config) || !checks.libraryPresent(pgBinDir))
29
39
  return null;
40
+ if (!archiveHasKeyspaceAuth(version)) {
41
+ console.log(`[supatype] This Postgres archive (${version ?? "a local build"}) cannot require a keyspace password ` +
42
+ `(${KEYSPACE_AUTH_SINCE} or later can), so the cache uses the Valkey sidecar.`);
43
+ return null;
44
+ }
30
45
  const port = await checks.freePort();
31
46
  if (port === null) {
32
47
  console.warn(`[supatype] ⚠ No free port in ${KEYSPACE_PORT_BASE}-${KEYSPACE_PORT_BASE + KEYSPACE_PORT_SPAN - 1} ` +
@@ -34,16 +49,35 @@ export async function nativeKeyspacePort(config, pgBinDir, checks = machineCheck
34
49
  }
35
50
  return port;
36
51
  }
52
+ /**
53
+ * Writes the project's keyspace password to `<state root>/keyspace/password`, and says where:
54
+ * `pg_keyspace.password_file`, which the extension reads at start and on every reload, giving the
55
+ * `supatype` user that password and refusing every client that has not logged in. Only the path
56
+ * is ever a setting, so the password is in no command line, setting or log.
57
+ *
58
+ * Readable by this user alone: the directory 0700 and the file 0600, put right when an earlier one
59
+ * was wider, since the mode given at creation applies to a new file only. Written at every start,
60
+ * so a password changed in .env is the one the next start reads. No newline is written; the
61
+ * extension would drop one, and anything else would be part of the password.
62
+ */
63
+ export function writeKeyspacePasswordFile(stateRoot, password) {
64
+ const dir = join(stateRoot, "keyspace");
65
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
66
+ chmodSync(dir, 0o700);
67
+ const file = join(dir, "password");
68
+ writeFileSync(file, password, { mode: 0o600 });
69
+ chmodSync(file, 0o600);
70
+ return file;
71
+ }
37
72
  /**
38
73
  * The address the cache should talk to when Postgres serves RESP, or null for the Valkey sidecar.
39
74
  *
40
- * The probe is not ceremony: shared memory limits, a preload ordering mistake or a port taken
41
- * between the check and the start all leave a Postgres that is running and a keyspace that is
42
- * not, and the difference is a cache that silently never hits.
75
+ * The probe logs in, since the keyspace refuses PING before AUTH, and is not ceremony: shared
76
+ * memory limits, a preload ordering mistake, a password file that could not be read or a port
77
+ * taken between the check and the start all leave a Postgres that is running and a keyspace that
78
+ * is not, and the difference is a cache that silently never hits.
43
79
  */
44
- export async function nativeKeyspaceAddr(keyspacePort, respAnswers = (port) => answersPing("127.0.0.1", port)) {
45
- if (keyspacePort === null)
46
- return null;
80
+ export async function nativeKeyspaceAddr(keyspacePort, credentials, respAnswers = (port) => answersPing("127.0.0.1", port, { timeoutMs: 800, credentials })) {
47
81
  if (await respAnswers(keyspacePort))
48
82
  return `127.0.0.1:${keyspacePort}`;
49
83
  console.warn(`[supatype] ⚠ Postgres has pg_keyspace but is not serving RESP on :${keyspacePort}. ` +
@@ -1 +1 @@
1
- {"version":3,"file":"native-keyspace.js","sourceRoot":"","sources":["../src/native-keyspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,4BAA4B,GAC7B,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAA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,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;IACvC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IAChD,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACrB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;IAClC,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IAC9C,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACtB,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,YAAoB,EACpB,WAA4B,EAC5B,cAAkD,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;IAE3H,IAAI,MAAM,WAAW,CAAC,YAAY,CAAC;QAAE,OAAO,aAAa,YAAY,EAAE,CAAA;IACvE,OAAO,CAAC,IAAI,CACV,sEAAsE,YAAY,IAAI;QACpF,4DAA4D,CAC/D,CAAA;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,23 @@
1
+ /** Where a project's native Postgres keeps its data, and where native dev records its own pid. */
2
+ export interface NativeDevState {
3
+ dataDir: string;
4
+ pidDir: string;
5
+ }
6
+ /** The label of the pid file a running native dev keeps in its pid directory. */
7
+ export declare const DEV_PID_LABEL = "dev";
8
+ /**
9
+ * The pid of this project's own Postgres on `port`, left running by a dev that is gone; null when
10
+ * there is none. Its `postmaster.pid` has to name this data directory, this port and a live
11
+ * process, so a data directory copied from another project, or a server moved to another port, is
12
+ * never taken for it. A dev of this project that is still running (its pid file names a live
13
+ * process) keeps its Postgres: a second dev started beside it is refused on the port, as before.
14
+ */
15
+ export declare function leftoverOwnPostgres(state: NativeDevState, port: number, alive?: (pid: number) => boolean): number | null;
16
+ /** True when a native dev of this project other than this one is still running. */
17
+ export declare function otherDevRunning(pidDir: string, alive?: (pid: number) => boolean): boolean;
18
+ /**
19
+ * Records this process as the project's running native dev, so another dev started meanwhile never
20
+ * takes its Postgres for a leftover. Returns the removal, for the shutdown.
21
+ */
22
+ export declare function recordNativeDevPid(pidDir: string): () => void;
23
+ //# sourceMappingURL=native-leftover-postgres.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-leftover-postgres.d.ts","sourceRoot":"","sources":["../src/native-leftover-postgres.ts"],"names":[],"mappings":"AAoBA,kGAAkG;AAClG,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf;AAED,iFAAiF;AACjF,eAAO,MAAM,aAAa,QAAQ,CAAA;AAElC;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAkB,GAAG,MAAM,GAAG,IAAI,CAOlI;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAkB,GAAG,OAAO,CAGnG;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,CAK7D"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * This project's own native Postgres, left running by a `supatype dev` that did not stop cleanly.
3
+ *
4
+ * 0.9.2 release test (FF12 remainder): a forced stop of native dev (Windows `taskkill /F` of the CLI,
5
+ * Linux closing its terminal) ends every service but Postgres, which pg_ctl started detached. The
6
+ * next dev refused "Port 54341 is already in use. Another Postgres instance may be running." about
7
+ * its own database, and only `supatype pg stop` got past it.
8
+ *
9
+ * The next dev stops that Postgres and starts it fresh rather than adopting it, as dev already does
10
+ * with everything it runs: it starts Postgres with this run's settings and stops it when it ends, and
11
+ * the Docker provider's own recovery (`recoverStaleDevSession`) stops a stale session's stack before
12
+ * starting again. An adopted server would keep whatever settings the earlier CLI gave it.
13
+ */
14
+ import { mkdirSync, rmSync, writeFileSync } from "node:fs";
15
+ import { join } from "node:path";
16
+ import { comparablePath } from "./dev-session-lock.js";
17
+ import { pidAlive } from "./parent-watch.js";
18
+ import { readPostmasterPid } from "./postgres-ctl.js";
19
+ import { readPid } from "./process-manager.js";
20
+ /** The label of the pid file a running native dev keeps in its pid directory. */
21
+ export const DEV_PID_LABEL = "dev";
22
+ /**
23
+ * The pid of this project's own Postgres on `port`, left running by a dev that is gone; null when
24
+ * there is none. Its `postmaster.pid` has to name this data directory, this port and a live
25
+ * process, so a data directory copied from another project, or a server moved to another port, is
26
+ * never taken for it. A dev of this project that is still running (its pid file names a live
27
+ * process) keeps its Postgres: a second dev started beside it is refused on the port, as before.
28
+ */
29
+ export function leftoverOwnPostgres(state, port, alive = pidAlive) {
30
+ const postmaster = readPostmasterPid(state.dataDir);
31
+ if (postmaster === null || postmaster.pid <= 0 || postmaster.port !== port)
32
+ return null;
33
+ // Links followed: one data directory has more than one spelling (macOS's /var is /private/var).
34
+ if (comparablePath(postmaster.dataDir) !== comparablePath(state.dataDir) || !alive(postmaster.pid))
35
+ return null;
36
+ if (otherDevRunning(state.pidDir, alive))
37
+ return null;
38
+ return postmaster.pid;
39
+ }
40
+ /** True when a native dev of this project other than this one is still running. */
41
+ export function otherDevRunning(pidDir, alive = pidAlive) {
42
+ const dev = readPid(pidDir, DEV_PID_LABEL);
43
+ return dev !== null && dev !== process.pid && alive(dev);
44
+ }
45
+ /**
46
+ * Records this process as the project's running native dev, so another dev started meanwhile never
47
+ * takes its Postgres for a leftover. Returns the removal, for the shutdown.
48
+ */
49
+ export function recordNativeDevPid(pidDir) {
50
+ mkdirSync(pidDir, { recursive: true });
51
+ const file = join(pidDir, `${DEV_PID_LABEL}.pid`);
52
+ writeFileSync(file, String(process.pid));
53
+ return () => rmSync(file, { force: true });
54
+ }
55
+ //# sourceMappingURL=native-leftover-postgres.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-leftover-postgres.js","sourceRoot":"","sources":["../src/native-leftover-postgres.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAQ9C,iFAAiF;AACjF,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAA;AAElC;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAqB,EAAE,IAAY,EAAE,QAAkC,QAAQ;IACjH,MAAM,UAAU,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACnD,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,CAAC,GAAG,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAA;IACvF,gGAAgG;IAChG,IAAI,cAAc,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAA;IAC/G,IAAI,eAAe,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACrD,OAAO,UAAU,CAAC,GAAG,CAAA;AACvB,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,eAAe,CAAC,MAAc,EAAE,QAAkC,QAAQ;IACxF,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC1C,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,OAAO,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;AAC1D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACtC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,aAAa,MAAM,CAAC,CAAA;IACjD,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;IACxC,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AAC5C,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { type NativeDevState } from "./native-leftover-postgres.js";
2
+ import { type PidRecord } from "./process-manager.js";
3
+ /** A service's pid file and what it names. */
4
+ interface ServicePid extends PidRecord {
5
+ label: string;
6
+ signature: string;
7
+ }
8
+ /** The recorded services a killed dev of this project left running (see the file's header). */
9
+ export declare function leftoverOwnServices(state: NativeDevState): Promise<ServicePid[]>;
10
+ /**
11
+ * Stops each service a killed dev of this project left running, saying so, and removes its pid file.
12
+ * Returns once each has ended: a signal is sent, not waited on, and the port checks that follow saw
13
+ * the port still held on Linux (0.9.2 release test round 6, S-5).
14
+ */
15
+ export declare function stopLeftoverServices(state: NativeDevState): Promise<void>;
16
+ export {};
17
+ //# sourceMappingURL=native-leftover-services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-leftover-services.d.ts","sourceRoot":"","sources":["../src/native-leftover-services.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAkC,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAGnG,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAMpE,8CAA8C;AAC9C,UAAU,UAAW,SAAQ,SAAS;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;CAClB;AAyBD,+FAA+F;AAC/F,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAWtF;AAiBD;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAW/E"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * This project's native services, left running by a `supatype dev` that was killed.
3
+ *
4
+ * 0.9.2 release test round 2 (FF12 remainder, Linux): a SIGKILL of the dev CLI left every service
5
+ * running. Each leads a process group of its own (process-tree.ts), and nothing runs in a process
6
+ * that is killed, so nothing stopped them, and the next dev refused their ports. Native dev already
7
+ * stops its own leftover Postgres (native-leftover-postgres.ts); the services get the same.
8
+ *
9
+ * A pid file names a pid and the program that ran under it. A process is stopped only when all of
10
+ * these hold, so a pid the system has since given to something else is never taken for a service:
11
+ * - no dev of this project is still running;
12
+ * - its command line names the program its pid file records;
13
+ * - the process that started it is not a running `supatype` (another project's dev, whose own
14
+ * service took a pid this project's file still names).
15
+ */
16
+ import { readdirSync, rmSync } from "node:fs";
17
+ import { join } from "node:path";
18
+ import { comparable } from "./app/port-holder.js";
19
+ import { DEV_PID_LABEL, otherDevRunning } from "./native-leftover-postgres.js";
20
+ import { pidAlive } from "./parent-watch.js";
21
+ import { commandLines, processInfo } from "./process-info.js";
22
+ import { readPidRecord } from "./process-manager.js";
23
+ import { killPidTree } from "./process-tree.js";
24
+ /** Pid files the services' sweep leaves alone: dev's own, and the app, which proxy-dev-app.ts checks. */
25
+ const NOT_SERVICES = new Set([DEV_PID_LABEL, "app"]);
26
+ /** The services' pid files in `pidDir` that name a running process and the program it ran. */
27
+ function recordedServices(pidDir) {
28
+ let files;
29
+ try {
30
+ files = readdirSync(pidDir);
31
+ }
32
+ catch {
33
+ return [];
34
+ }
35
+ return files.flatMap((file) => {
36
+ const label = file.endsWith(".pid") ? file.slice(0, -".pid".length) : "";
37
+ if (label === "" || NOT_SERVICES.has(label))
38
+ return [];
39
+ const record = readPidRecord(pidDir, label);
40
+ if (record?.signature === undefined || !pidAlive(record.pid))
41
+ return [];
42
+ return [{ label, pid: record.pid, signature: record.signature }];
43
+ });
44
+ }
45
+ /** True when `commandLine` names `path`, compared as the platform compares paths. */
46
+ function names(commandLine, path) {
47
+ const win32 = process.platform === "win32";
48
+ return comparable(commandLine, win32).includes(comparable(path, win32));
49
+ }
50
+ /** The recorded services a killed dev of this project left running (see the file's header). */
51
+ export async function leftoverOwnServices(state) {
52
+ if (otherDevRunning(state.pidDir))
53
+ return [];
54
+ const recorded = recordedServices(state.pidDir);
55
+ if (recorded.length === 0)
56
+ return [];
57
+ const running = await processInfo(recorded.map((service) => service.pid));
58
+ const named = recorded.filter((service) => {
59
+ const info = running.get(service.pid);
60
+ return info !== undefined && names(info.commandLine, service.signature);
61
+ });
62
+ const parents = await commandLines(named.flatMap((service) => running.get(service.pid)?.ppid ?? []));
63
+ return named.filter((service) => !startedBySupatype(running.get(service.pid), parents));
64
+ }
65
+ /**
66
+ * A command line running `supatype dev`: the installed program, or the CLI's script under node.
67
+ * Not any process whose path names a folder called supatype, such as an editor in a checkout.
68
+ */
69
+ const SUPATYPE_DEV = /supatype(?:\.exe|\.js)?["']?\s+dev(?:\s|$)/i;
70
+ /** True when the process that started the one `info` describes is a running `supatype dev`. */
71
+ function startedBySupatype(info, parents) {
72
+ const parent = info === undefined ? undefined : parents.get(info.ppid);
73
+ return parent !== undefined && SUPATYPE_DEV.test(parent);
74
+ }
75
+ /** How long a stopped service is given to end, and let go of its port, before the port checks run. */
76
+ const SERVICE_END_WAIT_MS = 3_000;
77
+ /**
78
+ * Stops each service a killed dev of this project left running, saying so, and removes its pid file.
79
+ * Returns once each has ended: a signal is sent, not waited on, and the port checks that follow saw
80
+ * the port still held on Linux (0.9.2 release test round 6, S-5).
81
+ */
82
+ export async function stopLeftoverServices(state) {
83
+ const leftovers = await leftoverOwnServices(state);
84
+ const deadline = Date.now() + SERVICE_END_WAIT_MS;
85
+ await Promise.all(leftovers.map(async ({ label, pid }) => {
86
+ console.log(`[supatype] This project's ${label} (pid ${pid}) was still running from a dev that did not stop cleanly; stopping it.`);
87
+ await killPidTree(pid);
88
+ while (pidAlive(pid) && Date.now() < deadline)
89
+ await new Promise((resolve) => setTimeout(resolve, 50));
90
+ rmSync(join(state.pidDir, `${label}.pid`), { force: true });
91
+ }));
92
+ }
93
+ //# sourceMappingURL=native-leftover-services.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-leftover-services.js","sourceRoot":"","sources":["../src/native-leftover-services.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAuB,MAAM,+BAA+B,CAAA;AACnG,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAoB,MAAM,mBAAmB,CAAA;AAC/E,OAAO,EAAE,aAAa,EAAkB,MAAM,sBAAsB,CAAA;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,yGAAyG;AACzG,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,CAAA;AAQpD,8FAA8F;AAC9F,SAAS,gBAAgB,CAAC,MAAc;IACtC,IAAI,KAAe,C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E,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI3E;AAED,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,qFAAqF;AACrF,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAEjF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAOvF"}
@@ -14,6 +14,7 @@ import { join } from "node:path";
14
14
  import { NATIVE_AUTH_METHOD, pgBin, pgSpawnEnv, reload } from "./postgres-ctl.js";
15
15
  import { hasEnvValue } from "./env-file.js";
16
16
  import { fatalError } from "./ui/fatal.js";
17
+ import { QUIET_SECRET_SQL } from "./secret-sql.js";
17
18
  const SUPERUSER_PASSWORD_ENV = "SUPATYPE_SUPERUSER_PASSWORD";
18
19
  /** The `.env` key holding the native superuser's password. */
19
20
  const SUPERUSER_PASSWORD_KEY = "POSTGRES_PASSWORD";
@@ -94,7 +95,7 @@ export function requirePasswordAuth(opts, superuserPassword) {
94
95
  }
95
96
  function setSuperuserPassword(opts, password) {
96
97
  // Through psql's environment, never its arguments, so the password is not on a command line.
97
- const sql = `\\getenv pw ${SUPERUSER_PASSWORD_ENV}\nALTER ROLE postgres PASSWORD :'pw';\n`;
98
+ const sql = `${QUIET_SECRET_SQL}\\getenv pw ${SUPERUSER_PASSWORD_ENV}\nALTER ROLE postgres PASSWORD :'pw';\n`;
98
99
  const result = spawnSync(pgBin(opts.pgBinDir, "psql"), ["-h", "127.0.0.1", "-p", String(opts.port), "-U", "postgres", "-d", "postgres", "-X", "-q", "-v", "ON_ERROR_STOP=1", "-f", "-"], {
99
100
  input: sql,
100
101
  encoding: "utf8",
@@ -1 +1 @@
1
- {"version":3,"file":"native-pg-auth.js","sourceRoot":"","sources":["../src/native-pg-auth.ts"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AI,EAAE,EAAE,CAAC,CAAA;IAC5F,CAAC;AACH,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * A port native dev binds, claimed in a file every other native dev's start reads, for as long as
3
+ * the dev that claimed it runs.
4
+ *
5
+ * 0.9.2 release test (N-FF12): two projects started 10 s apart both passed the port check, which
6
+ * runs about 20 s before PostgREST binds, and both PostgRESTs listened on 127.0.0.1:3001. PostgREST
7
+ * binds with SO_REUSEADDR, which on Windows lets a second listener share a port the first holds, so
8
+ * neither failed.
9
+ *
10
+ * Round 2 (R2-RB1): the first fix claimed the port by listening on it. The installed CLI is a Bun
11
+ * program, and on Windows Bun gives every process it starts a copy of its open sockets. Postgres
12
+ * and the server, started while the port was held, kept it open after the CLI closed its own, so
13
+ * PostgREST's port was taken on every native start. A file gives a child process nothing to keep.
14
+ *
15
+ * `~/.supatype/ports/<port>.lock` holds the claiming dev's process id. A claim whose process is
16
+ * gone, from a dev that crashed, is taken over.
17
+ */
18
+ /** A claimed port, until released. */
19
+ export interface PortLock {
20
+ release: () => void;
21
+ }
22
+ /** The claim another running process holds on a port: its process id and the file that says so. */
23
+ export interface PortClaimHeld {
24
+ holder: number;
25
+ path: string;
26
+ }
27
+ /** Where the claim on `port` lives. Read at each call, so a test's own home is used. */
28
+ export declare function portLockPath(port: number): string;
29
+ /** True when the claim was taken, not refused. */
30
+ export declare function isPortLock(claim: PortLock | PortClaimHeld): claim is PortLock;
31
+ /**
32
+ * Claims `port` for this process, or names the running process that holds it. A home folder that
33
+ * cannot be written leaves the port unclaimed rather than refusing to start: the port checks still
34
+ * run, as before claims.
35
+ */
36
+ export declare function claimPortLock(port: number): PortLock | PortClaimHeld;
37
+ //# sourceMappingURL=native-port-lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-port-lock.d.ts","sourceRoot":"","sources":["../src/native-port-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAQH,sCAAsC;AACtC,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAED,mGAAmG;AACnG,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb;AAED,wFAAwF;AACxF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAYD,kDAAkD;AAClD,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,aAAa,GAAG,KAAK,IAAI,QAAQ,CAE7E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,CA0BpE"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * A port native dev binds, claimed in a file every other native dev's start reads, for as long as
3
+ * the dev that claimed it runs.
4
+ *
5
+ * 0.9.2 release test (N-FF12): two projects started 10 s apart both passed the port check, which
6
+ * runs about 20 s before PostgREST binds, and both PostgRESTs listened on 127.0.0.1:3001. PostgREST
7
+ * binds with SO_REUSEADDR, which on Windows lets a second listener share a port the first holds, so
8
+ * neither failed.
9
+ *
10
+ * Round 2 (R2-RB1): the first fix claimed the port by listening on it. The installed CLI is a Bun
11
+ * program, and on Windows Bun gives every process it starts a copy of its open sockets. Postgres
12
+ * and the server, started while the port was held, kept it open after the CLI closed its own, so
13
+ * PostgREST's port was taken on every native start. A file gives a child process nothing to keep.
14
+ *
15
+ * `~/.supatype/ports/<port>.lock` holds the claiming dev's process id. A claim whose process is
16
+ * gone, from a dev that crashed, is taken over.
17
+ */
18
+ import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
19
+ import { homedir } from "node:os";
20
+ import { dirname, join } from "node:path";
21
+ import { errorCode } from "./error-message.js";
22
+ import { pidAlive } from "./parent-watch.js";
23
+ /** Where the claim on `port` lives. Read at each call, so a test's own home is used. */
24
+ export function portLockPath(port) {
25
+ return join(homedir(), ".supatype", "ports", `${port}.lock`);
26
+ }
27
+ /** The process id a claim names, or null when it names none. */
28
+ function claimHolder(path) {
29
+ try {
30
+ const pid = Number.parseInt(readFileSync(path, "utf8").trim(), 10);
31
+ return Number.isInteger(pid) && pid > 0 ? pid : null;
32
+ }
33
+ catch {
34
+ return null;
35
+ }
36
+ }
37
+ /** True when the claim was taken, not refused. */
38
+ export function isPortLock(claim) {
39
+ return "release" in claim;
40
+ }
41
+ /**
42
+ * Claims `port` for this process, or names the running process that holds it. A home folder that
43
+ * cannot be written leaves the port unclaimed rather than refusing to start: the port checks still
44
+ * run, as before claims.
45
+ */
46
+ export function claimPortLock(port) {
47
+ const path = portLockPath(port);
48
+ const unclaimed = { release: () => undefined };
49
+ try {
50
+ mkdirSync(dirname(path), { recursive: true });
51
+ }
52
+ catch {
53
+ return unclaimed;
54
+ }
55
+ // Twice: once more after removing a claim whose process is gone.
56
+ for (let attempt = 0; attempt < 2; attempt++) {
57
+ try {
58
+ writeFileSync(path, `${process.pid}\n`, { flag: "wx" });
59
+ }
60
+ catch (err) {
61
+ if (errorCode(err) !== "EEXIST")
62
+ return unclaimed;
63
+ const holder = claimHolder(path);
64
+ if (holder !== null && pidAlive(holder))
65
+ return { holder, path };
66
+ rmSync(path, { force: true });
67
+ continue;
68
+ }
69
+ // Two starts that both removed the same dead claim can both write one. The file names the last.
70
+ const holder = claimHolder(path);
71
+ if (holder !== process.pid && holder !== null)
72
+ return { holder, path };
73
+ return { release: () => rmSync(path, { force: true }) };
74
+ }
75
+ // A claim that came back dead after it was removed: start unclaimed, as before claims.
76
+ return unclaimed;
77
+ }
78
+ //# sourceMappingURL=native-port-lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-port-lock.js","sourceRoot":"","sources":["../src/native-port-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM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,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC;QAC7C,IAAI,CAAC;YACH,aAAa,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QACzD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,QAAQ;gBAAE,OAAO,SAAS,CAAA;YACjD,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAA;YAChC,IAAI,MAAM,KAAK,IAAI,IAAI,QAAQ,CAAC,MAAM,CAAC;gBAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;YAChE,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;YAC7B,SAAQ;QACV,CAAC;QACD,gGAAgG;QAChG,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAA;QAChC,IAAI,MAAM,KAAK,OAAO,CAAC,GAAG,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;QACtE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;IACzD,CAAC;IACD,uFAAuF;IACvF,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { ProcessManager } from "./process-manager.js";
1
+ import { ProcessManager, type SupervisionOptions } from "./process-manager.js";
2
2
  import type { SupatypeProjectConfig } from "./project-config.js";
3
3
  import type { ComponentLaunchSpec } from "./component-launch.js";
4
4
  export interface NativeRealtimeOptions {
@@ -11,8 +11,9 @@ export interface NativeRealtimeOptions {
11
11
  port: string;
12
12
  databaseUrl: string;
13
13
  jwtSecret: string;
14
- /** How long realtime has to answer before it is reported not running. */
14
+ /** How long realtime has to answer before it is switched off at the gateway until it does. */
15
15
  readyTimeoutMs?: number;
16
+ supervision?: SupervisionOptions;
16
17
  }
17
18
  type ResolveLaunch = (config: SupatypeProjectConfig, cwd: string) => Promise<ComponentLaunchSpec>;
18
19
  /** Why the database cannot give realtime logical decoding, or undefined (db-preflight.ts). */
@@ -27,7 +28,9 @@ type CheckDecoding = (databaseUrl: string) => Promise<string | undefined>;
27
28
  *
28
29
  * Running means answering. Dev used to enable realtime and print its URL the moment the process
29
30
  * was spawned, so a realtime that exited at once, or disabled its database changes for want of
30
- * logical decoding, was announced as running all the same (local test N3).
31
+ * logical decoding, was announced as running all the same (local test N3). One that has not
32
+ * answered by the deadline is switched off at the gateway but left running, with the crash-loop
33
+ * supervisor, and switched back on once it answers (0.9.2 release test N-FF2).
31
34
  */
32
35
  export declare function startNativeRealtime(opts: NativeRealtimeOptions, resolveLaunch?: ResolveLaunch, checkDecoding?: CheckDecoding): Promise<ProcessManager | null>;
33
36
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"native-realtime.d.ts","sourceRoot":"","sources":["../src/native-realtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAGrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAKhE,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,qBAAqB,CAAA;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,yEAAyE;IACzE,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,KAAK,aAAa,GAA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