@supatype/cli 0.7.0 → 0.8.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 (587) hide show
  1. package/CHANGELOG.md +259 -0
  2. package/bin/supatype.js +25 -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/app-config.d.ts +1 -1
  12. package/dist/app-config.d.ts.map +1 -1
  13. package/dist/app-config.js +103 -144
  14. package/dist/app-config.js.map +1 -1
  15. package/dist/applied-ast-artifacts.d.ts +16 -0
  16. package/dist/applied-ast-artifacts.d.ts.map +1 -0
  17. package/dist/applied-ast-artifacts.js +37 -0
  18. package/dist/applied-ast-artifacts.js.map +1 -0
  19. package/dist/archive-extract.d.ts +3 -0
  20. package/dist/archive-extract.d.ts.map +1 -0
  21. package/dist/archive-extract.js +19 -0
  22. package/dist/archive-extract.js.map +1 -0
  23. package/dist/binary-cache.d.ts +25 -2
  24. package/dist/binary-cache.d.ts.map +1 -1
  25. package/dist/binary-cache.js +115 -81
  26. package/dist/binary-cache.js.map +1 -1
  27. package/dist/binary-download-lock.d.ts.map +1 -1
  28. package/dist/binary-download-lock.js +1 -3
  29. package/dist/binary-download-lock.js.map +1 -1
  30. package/dist/byo-preflight.d.ts.map +1 -1
  31. package/dist/byo-preflight.js +2 -10
  32. package/dist/byo-preflight.js.map +1 -1
  33. package/dist/cache-pins.d.ts.map +1 -1
  34. package/dist/cache-pins.js +2 -2
  35. package/dist/cache-pins.js.map +1 -1
  36. package/dist/cli-version-embedded.js +1 -1
  37. package/dist/cloud-credentials.d.ts +6 -0
  38. package/dist/cloud-credentials.d.ts.map +1 -1
  39. package/dist/cloud-credentials.js +13 -0
  40. package/dist/cloud-credentials.js.map +1 -1
  41. package/dist/commands/admin.d.ts.map +1 -1
  42. package/dist/commands/admin.js +18 -18
  43. package/dist/commands/admin.js.map +1 -1
  44. package/dist/commands/app.d.ts.map +1 -1
  45. package/dist/commands/app.js +27 -8
  46. package/dist/commands/app.js.map +1 -1
  47. package/dist/commands/cache.d.ts.map +1 -1
  48. package/dist/commands/cache.js +5 -4
  49. package/dist/commands/cache.js.map +1 -1
  50. package/dist/commands/cloud.js +2 -4
  51. package/dist/commands/cloud.js.map +1 -1
  52. package/dist/commands/db.d.ts.map +1 -1
  53. package/dist/commands/db.js +116 -106
  54. package/dist/commands/db.js.map +1 -1
  55. package/dist/commands/deploy.d.ts.map +1 -1
  56. package/dist/commands/deploy.js +2 -2
  57. package/dist/commands/deploy.js.map +1 -1
  58. package/dist/commands/dev.d.ts +50 -4
  59. package/dist/commands/dev.d.ts.map +1 -1
  60. package/dist/commands/dev.js +262 -266
  61. package/dist/commands/dev.js.map +1 -1
  62. package/dist/commands/functions.d.ts +30 -0
  63. package/dist/commands/functions.d.ts.map +1 -1
  64. package/dist/commands/functions.js +503 -507
  65. package/dist/commands/functions.js.map +1 -1
  66. package/dist/commands/generate.d.ts.map +1 -1
  67. package/dist/commands/generate.js +11 -8
  68. package/dist/commands/generate.js.map +1 -1
  69. package/dist/commands/hooks.js +26 -11
  70. package/dist/commands/hooks.js.map +1 -1
  71. package/dist/commands/init.d.ts +16 -2
  72. package/dist/commands/init.d.ts.map +1 -1
  73. package/dist/commands/init.js +237 -143
  74. package/dist/commands/init.js.map +1 -1
  75. package/dist/commands/internal.d.ts.map +1 -1
  76. package/dist/commands/internal.js +2 -1
  77. package/dist/commands/internal.js.map +1 -1
  78. package/dist/commands/keys.d.ts +36 -10
  79. package/dist/commands/keys.d.ts.map +1 -1
  80. package/dist/commands/keys.js +168 -128
  81. package/dist/commands/keys.js.map +1 -1
  82. package/dist/commands/link-helpers.d.ts.map +1 -1
  83. package/dist/commands/link-helpers.js +30 -9
  84. package/dist/commands/link-helpers.js.map +1 -1
  85. package/dist/commands/logs.d.ts.map +1 -1
  86. package/dist/commands/logs.js +5 -4
  87. package/dist/commands/logs.js.map +1 -1
  88. package/dist/commands/migrate.js +1 -1
  89. package/dist/commands/migrate.js.map +1 -1
  90. package/dist/commands/pg.js +2 -0
  91. package/dist/commands/pg.js.map +1 -1
  92. package/dist/commands/plugins.d.ts.map +1 -1
  93. package/dist/commands/plugins.js +17 -7
  94. package/dist/commands/plugins.js.map +1 -1
  95. package/dist/commands/push.d.ts +37 -0
  96. package/dist/commands/push.d.ts.map +1 -1
  97. package/dist/commands/push.js +188 -73
  98. package/dist/commands/push.js.map +1 -1
  99. package/dist/commands/seed.d.ts +35 -0
  100. package/dist/commands/seed.d.ts.map +1 -1
  101. package/dist/commands/seed.js +72 -38
  102. package/dist/commands/seed.js.map +1 -1
  103. package/dist/commands/self-host.d.ts.map +1 -1
  104. package/dist/commands/self-host.js +61 -29
  105. package/dist/commands/self-host.js.map +1 -1
  106. package/dist/commands/status.js +5 -5
  107. package/dist/commands/status.js.map +1 -1
  108. package/dist/commands/types.js +2 -5
  109. package/dist/commands/types.js.map +1 -1
  110. package/dist/commands/update.d.ts.map +1 -1
  111. package/dist/commands/update.js +212 -101
  112. package/dist/commands/update.js.map +1 -1
  113. package/dist/component-launch.d.ts +11 -0
  114. package/dist/component-launch.d.ts.map +1 -0
  115. package/dist/component-launch.js +35 -0
  116. package/dist/component-launch.js.map +1 -0
  117. package/dist/components.d.ts +7 -2
  118. package/dist/components.d.ts.map +1 -1
  119. package/dist/components.js +7 -2
  120. package/dist/components.js.map +1 -1
  121. package/dist/compose-db-roles.d.ts.map +1 -1
  122. package/dist/compose-db-roles.js +5 -14
  123. package/dist/compose-db-roles.js.map +1 -1
  124. package/dist/compose-engine-run.d.ts +6 -5
  125. package/dist/compose-engine-run.d.ts.map +1 -1
  126. package/dist/compose-engine-run.js +44 -37
  127. package/dist/compose-engine-run.js.map +1 -1
  128. package/dist/compose-engine-service.d.ts +10 -0
  129. package/dist/compose-engine-service.d.ts.map +1 -0
  130. package/dist/compose-engine-service.js +16 -0
  131. package/dist/compose-engine-service.js.map +1 -0
  132. package/dist/compose-host-path.d.ts +14 -0
  133. package/dist/compose-host-path.d.ts.map +1 -0
  134. package/dist/compose-host-path.js +18 -0
  135. package/dist/compose-host-path.js.map +1 -0
  136. package/dist/compose-image-pull.d.ts +43 -0
  137. package/dist/compose-image-pull.d.ts.map +1 -0
  138. package/dist/compose-image-pull.js +27 -0
  139. package/dist/compose-image-pull.js.map +1 -0
  140. package/dist/compose-kong.d.ts.map +1 -1
  141. package/dist/compose-kong.js +10 -6
  142. package/dist/compose-kong.js.map +1 -1
  143. package/dist/compose-local-server-image.d.ts.map +1 -1
  144. package/dist/compose-local-server-image.js +7 -3
  145. package/dist/compose-local-server-image.js.map +1 -1
  146. package/dist/compose-render-mode.d.ts.map +1 -1
  147. package/dist/compose-render-mode.js +7 -4
  148. package/dist/compose-render-mode.js.map +1 -1
  149. package/dist/compose-services.d.ts +12 -2
  150. package/dist/compose-services.d.ts.map +1 -1
  151. package/dist/compose-services.js +27 -12
  152. package/dist/compose-services.js.map +1 -1
  153. package/dist/config-snapshot.d.ts +6 -0
  154. package/dist/config-snapshot.d.ts.map +1 -0
  155. package/dist/config-snapshot.js +23 -0
  156. package/dist/config-snapshot.js.map +1 -0
  157. package/dist/config.d.ts +2 -0
  158. package/dist/config.d.ts.map +1 -1
  159. package/dist/config.js +2 -0
  160. package/dist/config.js.map +1 -1
  161. package/dist/database-url-owner.d.ts +57 -0
  162. package/dist/database-url-owner.d.ts.map +1 -0
  163. package/dist/database-url-owner.js +130 -0
  164. package/dist/database-url-owner.js.map +1 -0
  165. package/dist/db-port-offer.d.ts +18 -0
  166. package/dist/db-port-offer.d.ts.map +1 -0
  167. package/dist/db-port-offer.js +68 -0
  168. package/dist/db-port-offer.js.map +1 -0
  169. package/dist/db-port.d.ts +40 -18
  170. package/dist/db-port.d.ts.map +1 -1
  171. package/dist/db-port.js +33 -31
  172. package/dist/db-port.js.map +1 -1
  173. package/dist/db-preflight.d.ts +8 -0
  174. package/dist/db-preflight.d.ts.map +1 -1
  175. package/dist/db-preflight.js +18 -1
  176. package/dist/db-preflight.js.map +1 -1
  177. package/dist/db-rows.d.ts +11 -0
  178. package/dist/db-rows.d.ts.map +1 -1
  179. package/dist/db-rows.js +27 -0
  180. package/dist/db-rows.js.map +1 -1
  181. package/dist/debounce.d.ts +11 -0
  182. package/dist/debounce.d.ts.map +1 -0
  183. package/dist/debounce.js +23 -0
  184. package/dist/debounce.js.map +1 -0
  185. package/dist/dev-api-keys.d.ts +12 -2
  186. package/dist/dev-api-keys.d.ts.map +1 -1
  187. package/dist/dev-api-keys.js +33 -17
  188. package/dist/dev-api-keys.js.map +1 -1
  189. package/dist/dev-compose.d.ts +5 -12
  190. package/dist/dev-compose.d.ts.map +1 -1
  191. package/dist/dev-compose.js +153 -245
  192. package/dist/dev-compose.js.map +1 -1
  193. package/dist/dev-db-ready.d.ts.map +1 -1
  194. package/dist/dev-db-ready.js +2 -1
  195. package/dist/dev-db-ready.js.map +1 -1
  196. package/dist/dev-db-reset.d.ts.map +1 -1
  197. package/dist/dev-db-reset.js +5 -4
  198. package/dist/dev-db-reset.js.map +1 -1
  199. package/dist/dev-functions-watch.d.ts.map +1 -1
  200. package/dist/dev-functions-watch.js +5 -16
  201. package/dist/dev-functions-watch.js.map +1 -1
  202. package/dist/dev-ports.d.ts +22 -7
  203. package/dist/dev-ports.d.ts.map +1 -1
  204. package/dist/dev-ports.js +61 -38
  205. package/dist/dev-ports.js.map +1 -1
  206. package/dist/dev-schema-watch.d.ts.map +1 -1
  207. package/dist/dev-schema-watch.js +7 -12
  208. package/dist/dev-schema-watch.js.map +1 -1
  209. package/dist/dev-session-lock.js +4 -3
  210. package/dist/dev-session-lock.js.map +1 -1
  211. package/dist/dev-session.d.ts.map +1 -1
  212. package/dist/dev-session.js +3 -0
  213. package/dist/dev-session.js.map +1 -1
  214. package/dist/dev-shutdown.d.ts +45 -0
  215. package/dist/dev-shutdown.d.ts.map +1 -1
  216. package/dist/dev-shutdown.js +206 -31
  217. package/dist/dev-shutdown.js.map +1 -1
  218. package/dist/docker-address-pool.d.ts +23 -0
  219. package/dist/docker-address-pool.d.ts.map +1 -0
  220. package/dist/docker-address-pool.js +56 -0
  221. package/dist/docker-address-pool.js.map +1 -0
  222. package/dist/docker-exec.d.ts +92 -0
  223. package/dist/docker-exec.d.ts.map +1 -0
  224. package/dist/docker-exec.js +139 -0
  225. package/dist/docker-exec.js.map +1 -0
  226. package/dist/docker-postgres.d.ts +1 -6
  227. package/dist/docker-postgres.d.ts.map +1 -1
  228. package/dist/docker-postgres.js +67 -85
  229. package/dist/docker-postgres.js.map +1 -1
  230. package/dist/docker-runtime.d.ts +12 -1
  231. package/dist/docker-runtime.d.ts.map +1 -1
  232. package/dist/docker-runtime.js +48 -23
  233. package/dist/docker-runtime.js.map +1 -1
  234. package/dist/dotenv-parse.d.ts +22 -0
  235. package/dist/dotenv-parse.d.ts.map +1 -0
  236. package/dist/dotenv-parse.js +63 -0
  237. package/dist/dotenv-parse.js.map +1 -0
  238. package/dist/engine-answers.d.ts +0 -2
  239. package/dist/engine-answers.d.ts.map +1 -1
  240. package/dist/engine-answers.js +4 -3
  241. package/dist/engine-answers.js.map +1 -1
  242. package/dist/engine-client.d.ts.map +1 -1
  243. package/dist/engine-client.js +10 -12
  244. package/dist/engine-client.js.map +1 -1
  245. package/dist/engine-floor.d.ts +29 -0
  246. package/dist/engine-floor.d.ts.map +1 -1
  247. package/dist/engine-floor.js +56 -0
  248. package/dist/engine-floor.js.map +1 -1
  249. package/dist/engine-ownership-gate.d.ts +10 -0
  250. package/dist/engine-ownership-gate.d.ts.map +1 -1
  251. package/dist/engine-ownership-gate.js +31 -6
  252. package/dist/engine-ownership-gate.js.map +1 -1
  253. package/dist/ensure-binary.d.ts +9 -0
  254. package/dist/ensure-binary.d.ts.map +1 -1
  255. package/dist/ensure-binary.js +38 -5
  256. package/dist/ensure-binary.js.map +1 -1
  257. package/dist/ensure-component-binaries.d.ts.map +1 -1
  258. package/dist/ensure-component-binaries.js +2 -1
  259. package/dist/ensure-component-binaries.js.map +1 -1
  260. package/dist/env-file.d.ts +28 -8
  261. package/dist/env-file.d.ts.map +1 -1
  262. package/dist/env-file.js +80 -53
  263. package/dist/env-file.js.map +1 -1
  264. package/dist/env-lines.d.ts +11 -0
  265. package/dist/env-lines.d.ts.map +1 -0
  266. package/dist/env-lines.js +36 -0
  267. package/dist/env-lines.js.map +1 -0
  268. package/dist/error-message.d.ts +34 -1
  269. package/dist/error-message.d.ts.map +1 -1
  270. package/dist/error-message.js +102 -2
  271. package/dist/error-message.js.map +1 -1
  272. package/dist/fetch-within.d.ts +10 -0
  273. package/dist/fetch-within.d.ts.map +1 -0
  274. package/dist/fetch-within.js +12 -0
  275. package/dist/fetch-within.js.map +1 -0
  276. package/dist/field-masking-tier.d.ts.map +1 -1
  277. package/dist/field-masking-tier.js +7 -5
  278. package/dist/field-masking-tier.js.map +1 -1
  279. package/dist/functions-context-refresh.d.ts +6 -2
  280. package/dist/functions-context-refresh.d.ts.map +1 -1
  281. package/dist/functions-context-refresh.js +11 -3
  282. package/dist/functions-context-refresh.js.map +1 -1
  283. package/dist/functions-deno-types.d.ts.map +1 -1
  284. package/dist/functions-deno-types.js +9 -2
  285. package/dist/functions-deno-types.js.map +1 -1
  286. package/dist/{functions-router-gen.d.ts → functions-discovery.d.ts} +8 -10
  287. package/dist/functions-discovery.d.ts.map +1 -0
  288. package/dist/functions-discovery.js +87 -0
  289. package/dist/functions-discovery.js.map +1 -0
  290. package/dist/functions-template.d.ts.map +1 -1
  291. package/dist/functions-template.js +20 -12
  292. package/dist/functions-template.js.map +1 -1
  293. package/dist/functions-worker-files.d.ts +55 -0
  294. package/dist/functions-worker-files.d.ts.map +1 -0
  295. package/dist/functions-worker-files.js +149 -0
  296. package/dist/functions-worker-files.js.map +1 -0
  297. package/dist/generated/functions-worker-source.d.ts +2 -0
  298. package/dist/generated/functions-worker-source.d.ts.map +1 -0
  299. package/dist/generated/functions-worker-source.js +12 -0
  300. package/dist/generated/functions-worker-source.js.map +1 -0
  301. package/dist/generated/release-images.d.ts +18 -0
  302. package/dist/generated/release-images.d.ts.map +1 -0
  303. package/dist/generated/release-images.js +8 -0
  304. package/dist/generated/release-images.js.map +1 -0
  305. package/dist/generated-files-engine.d.ts +33 -0
  306. package/dist/generated-files-engine.d.ts.map +1 -0
  307. package/dist/generated-files-engine.js +45 -0
  308. package/dist/generated-files-engine.js.map +1 -0
  309. package/dist/hook-upload.d.ts +29 -15
  310. package/dist/hook-upload.d.ts.map +1 -1
  311. package/dist/hook-upload.js +88 -59
  312. package/dist/hook-upload.js.map +1 -1
  313. package/dist/hooks-generator.d.ts +5 -0
  314. package/dist/hooks-generator.d.ts.map +1 -1
  315. package/dist/hooks-generator.js +7 -2
  316. package/dist/hooks-generator.js.map +1 -1
  317. package/dist/host-database.d.ts.map +1 -1
  318. package/dist/host-database.js +31 -4
  319. package/dist/host-database.js.map +1 -1
  320. package/dist/init-dependency-versions.d.ts +3 -1
  321. package/dist/init-dependency-versions.d.ts.map +1 -1
  322. package/dist/init-dependency-versions.js +22 -6
  323. package/dist/init-dependency-versions.js.map +1 -1
  324. package/dist/init-example.d.ts +48 -0
  325. package/dist/init-example.d.ts.map +1 -0
  326. package/dist/init-example.js +110 -0
  327. package/dist/init-example.js.map +1 -0
  328. package/dist/init-package-json.d.ts.map +1 -1
  329. package/dist/init-package-json.js +2 -0
  330. package/dist/init-package-json.js.map +1 -1
  331. package/dist/init-setup-steps.d.ts +37 -0
  332. package/dist/init-setup-steps.d.ts.map +1 -0
  333. package/dist/init-setup-steps.js +118 -0
  334. package/dist/init-setup-steps.js.map +1 -0
  335. package/dist/jwt-secret-length.d.ts +5 -13
  336. package/dist/jwt-secret-length.d.ts.map +1 -1
  337. package/dist/jwt-secret-length.js +7 -22
  338. package/dist/jwt-secret-length.js.map +1 -1
  339. package/dist/jwt-secret-rules.d.ts +24 -0
  340. package/dist/jwt-secret-rules.d.ts.map +1 -0
  341. package/dist/jwt-secret-rules.js +46 -0
  342. package/dist/jwt-secret-rules.js.map +1 -0
  343. package/dist/local-gateway.d.ts +3 -6
  344. package/dist/local-gateway.d.ts.map +1 -1
  345. package/dist/local-gateway.js +7 -9
  346. package/dist/local-gateway.js.map +1 -1
  347. package/dist/local-secrets.d.ts +95 -11
  348. package/dist/local-secrets.d.ts.map +1 -1
  349. package/dist/local-secrets.js +153 -18
  350. package/dist/local-secrets.js.map +1 -1
  351. package/dist/local-stack.d.ts.map +1 -1
  352. package/dist/local-stack.js +2 -7
  353. package/dist/local-stack.js.map +1 -1
  354. package/dist/local-storage.d.ts +7 -2
  355. package/dist/local-storage.d.ts.map +1 -1
  356. package/dist/local-storage.js +11 -3
  357. package/dist/local-storage.js.map +1 -1
  358. package/dist/mailer-env.d.ts +37 -0
  359. package/dist/mailer-env.d.ts.map +1 -0
  360. package/dist/mailer-env.js +98 -0
  361. package/dist/mailer-env.js.map +1 -0
  362. package/dist/model-cache.d.ts +4 -8
  363. package/dist/model-cache.d.ts.map +1 -1
  364. package/dist/model-cache.js.map +1 -1
  365. package/dist/model-hooks.d.ts +17 -7
  366. package/dist/model-hooks.d.ts.map +1 -1
  367. package/dist/model-hooks.js +52 -39
  368. package/dist/model-hooks.js.map +1 -1
  369. package/dist/native-dev-env.d.ts +37 -1
  370. package/dist/native-dev-env.d.ts.map +1 -1
  371. package/dist/native-dev-env.js +64 -2
  372. package/dist/native-dev-env.js.map +1 -1
  373. package/dist/native-functions-watch.d.ts +56 -5
  374. package/dist/native-functions-watch.d.ts.map +1 -1
  375. package/dist/native-functions-watch.js +119 -38
  376. package/dist/native-functions-watch.js.map +1 -1
  377. package/dist/native-keyspace.d.ts.map +1 -1
  378. package/dist/native-keyspace.js +2 -2
  379. package/dist/native-keyspace.js.map +1 -1
  380. package/dist/native-realtime.d.ts +11 -3
  381. package/dist/native-realtime.d.ts.map +1 -1
  382. package/dist/native-realtime.js +162 -10
  383. package/dist/native-realtime.js.map +1 -1
  384. package/dist/native-roles-sql.d.ts +14 -0
  385. package/dist/native-roles-sql.d.ts.map +1 -1
  386. package/dist/native-roles-sql.js +82 -1
  387. package/dist/native-roles-sql.js.map +1 -1
  388. package/dist/native-storage-import.d.ts +19 -0
  389. package/dist/native-storage-import.d.ts.map +1 -0
  390. package/dist/native-storage-import.js +327 -0
  391. package/dist/native-storage-import.js.map +1 -0
  392. package/dist/native-storage.d.ts +45 -0
  393. package/dist/native-storage.d.ts.map +1 -0
  394. package/dist/native-storage.js +140 -0
  395. package/dist/native-storage.js.map +1 -0
  396. package/dist/native-worker.d.ts +26 -0
  397. package/dist/native-worker.d.ts.map +1 -0
  398. package/dist/native-worker.js +63 -0
  399. package/dist/native-worker.js.map +1 -0
  400. package/dist/owner-default.d.ts +9 -1
  401. package/dist/owner-default.d.ts.map +1 -1
  402. package/dist/owner-default.js +17 -4
  403. package/dist/owner-default.js.map +1 -1
  404. package/dist/post-apply.d.ts +3 -0
  405. package/dist/post-apply.d.ts.map +1 -0
  406. package/dist/post-apply.js +17 -0
  407. package/dist/post-apply.js.map +1 -0
  408. package/dist/postgres-ctl.d.ts +98 -7
  409. package/dist/postgres-ctl.d.ts.map +1 -1
  410. package/dist/postgres-ctl.js +273 -40
  411. package/dist/postgres-ctl.js.map +1 -1
  412. package/dist/postgres-image.d.ts +15 -3
  413. package/dist/postgres-image.d.ts.map +1 -1
  414. package/dist/postgres-image.js +18 -15
  415. package/dist/postgres-image.js.map +1 -1
  416. package/dist/postgrest-release.d.ts +9 -0
  417. package/dist/postgrest-release.d.ts.map +1 -1
  418. package/dist/postgrest-release.js +23 -0
  419. package/dist/postgrest-release.js.map +1 -1
  420. package/dist/process-manager.d.ts.map +1 -1
  421. package/dist/process-manager.js +3 -1
  422. package/dist/process-manager.js.map +1 -1
  423. package/dist/project-config.d.ts +40 -7
  424. package/dist/project-config.d.ts.map +1 -1
  425. package/dist/project-config.js +42 -4
  426. package/dist/project-config.js.map +1 -1
  427. package/dist/pull-utils.d.ts +15 -0
  428. package/dist/pull-utils.d.ts.map +1 -1
  429. package/dist/pull-utils.js +149 -23
  430. package/dist/pull-utils.js.map +1 -1
  431. package/dist/push-refusal.d.ts.map +1 -1
  432. package/dist/push-refusal.js +3 -2
  433. package/dist/push-refusal.js.map +1 -1
  434. package/dist/realtime-launch.d.ts +2 -5
  435. package/dist/realtime-launch.d.ts.map +1 -1
  436. package/dist/realtime-launch.js +6 -23
  437. package/dist/realtime-launch.js.map +1 -1
  438. package/dist/recorded-field-masking-tier.d.ts.map +1 -1
  439. package/dist/recorded-field-masking-tier.js +4 -3
  440. package/dist/recorded-field-masking-tier.js.map +1 -1
  441. package/dist/release-images.d.ts +31 -0
  442. package/dist/release-images.d.ts.map +1 -0
  443. package/dist/release-images.js +90 -0
  444. package/dist/release-images.js.map +1 -0
  445. package/dist/required-host-components.d.ts.map +1 -1
  446. package/dist/required-host-components.js +4 -0
  447. package/dist/required-host-components.js.map +1 -1
  448. package/dist/resolve-api-url.d.ts +17 -3
  449. package/dist/resolve-api-url.d.ts.map +1 -1
  450. package/dist/resolve-api-url.js +71 -30
  451. package/dist/resolve-api-url.js.map +1 -1
  452. package/dist/resolve-target.d.ts +62 -0
  453. package/dist/resolve-target.d.ts.map +1 -1
  454. package/dist/resolve-target.js +68 -23
  455. package/dist/resolve-target.js.map +1 -1
  456. package/dist/rest-ready.d.ts.map +1 -1
  457. package/dist/rest-ready.js +2 -1
  458. package/dist/rest-ready.js.map +1 -1
  459. package/dist/route-manifest.d.ts +25 -2
  460. package/dist/route-manifest.d.ts.map +1 -1
  461. package/dist/route-manifest.js +48 -4
  462. package/dist/route-manifest.js.map +1 -1
  463. package/dist/run-until-stopped.d.ts +12 -0
  464. package/dist/run-until-stopped.d.ts.map +1 -0
  465. package/dist/run-until-stopped.js +42 -0
  466. package/dist/run-until-stopped.js.map +1 -0
  467. package/dist/schema-ast-v2.d.ts +2 -1
  468. package/dist/schema-ast-v2.d.ts.map +1 -1
  469. package/dist/schema-ast-v2.js.map +1 -1
  470. package/dist/schema-push-lock.d.ts.map +1 -1
  471. package/dist/schema-push-lock.js +59 -46
  472. package/dist/schema-push-lock.js.map +1 -1
  473. package/dist/schema-sources.d.ts +19 -4
  474. package/dist/schema-sources.d.ts.map +1 -1
  475. package/dist/schema-sources.js +56 -35
  476. package/dist/schema-sources.js.map +1 -1
  477. package/dist/seed-auth-connect.d.ts +14 -0
  478. package/dist/seed-auth-connect.d.ts.map +1 -0
  479. package/dist/seed-auth-connect.js +97 -0
  480. package/dist/seed-auth-connect.js.map +1 -0
  481. package/dist/seed-runner.d.ts.map +1 -1
  482. package/dist/seed-runner.js +22 -1
  483. package/dist/seed-runner.js.map +1 -1
  484. package/dist/seed.d.ts +6 -3
  485. package/dist/seed.d.ts.map +1 -1
  486. package/dist/self-host-compose.d.ts +32 -30
  487. package/dist/self-host-compose.d.ts.map +1 -1
  488. package/dist/self-host-compose.js +252 -152
  489. package/dist/self-host-compose.js.map +1 -1
  490. package/dist/service-role-key-file.d.ts +32 -0
  491. package/dist/service-role-key-file.d.ts.map +1 -0
  492. package/dist/service-role-key-file.js +90 -0
  493. package/dist/service-role-key-file.js.map +1 -0
  494. package/dist/shell-ports.d.ts +13 -2
  495. package/dist/shell-ports.d.ts.map +1 -1
  496. package/dist/shell-ports.js +18 -7
  497. package/dist/shell-ports.js.map +1 -1
  498. package/dist/stop-signals.d.ts +7 -0
  499. package/dist/stop-signals.d.ts.map +1 -0
  500. package/dist/stop-signals.js +12 -0
  501. package/dist/stop-signals.js.map +1 -0
  502. package/dist/storage-launch.d.ts +11 -0
  503. package/dist/storage-launch.d.ts.map +1 -0
  504. package/dist/storage-launch.js +41 -0
  505. package/dist/storage-launch.js.map +1 -0
  506. package/dist/storage-provision.d.ts +50 -5
  507. package/dist/storage-provision.d.ts.map +1 -1
  508. package/dist/storage-provision.js +101 -33
  509. package/dist/storage-provision.js.map +1 -1
  510. package/dist/systemd.d.ts +1 -1
  511. package/dist/systemd.d.ts.map +1 -1
  512. package/dist/systemd.js +26 -11
  513. package/dist/systemd.js.map +1 -1
  514. package/dist/tar-reader.d.ts +29 -0
  515. package/dist/tar-reader.d.ts.map +1 -0
  516. package/dist/tar-reader.js +99 -0
  517. package/dist/tar-reader.js.map +1 -0
  518. package/dist/target-client.d.ts +14 -1
  519. package/dist/target-client.d.ts.map +1 -1
  520. package/dist/target-client.js +134 -23
  521. package/dist/target-client.js.map +1 -1
  522. package/dist/target-request.d.ts +25 -0
  523. package/dist/target-request.d.ts.map +1 -0
  524. package/dist/target-request.js +33 -0
  525. package/dist/target-request.js.map +1 -0
  526. package/dist/target-warning.d.ts +7 -0
  527. package/dist/target-warning.d.ts.map +1 -0
  528. package/dist/target-warning.js +12 -0
  529. package/dist/target-warning.js.map +1 -0
  530. package/dist/type-extractor.d.ts +6 -0
  531. package/dist/type-extractor.d.ts.map +1 -1
  532. package/dist/type-extractor.js +118 -59
  533. package/dist/type-extractor.js.map +1 -1
  534. package/dist/ui/clack.d.ts.map +1 -1
  535. package/dist/ui/clack.js +11 -1
  536. package/dist/ui/clack.js.map +1 -1
  537. package/dist/ui/dev/DevDashboard.d.ts.map +1 -1
  538. package/dist/ui/dev/DevDashboard.js +4 -2
  539. package/dist/ui/dev/DevDashboard.js.map +1 -1
  540. package/dist/ui/fatal.d.ts.map +1 -1
  541. package/dist/ui/fatal.js +6 -7
  542. package/dist/ui/fatal.js.map +1 -1
  543. package/dist/ui/flows/FlowApp.d.ts.map +1 -1
  544. package/dist/ui/flows/FlowApp.js +16 -1
  545. package/dist/ui/flows/FlowApp.js.map +1 -1
  546. package/dist/ui/flows/prompt-fields.d.ts +5 -0
  547. package/dist/ui/flows/prompt-fields.d.ts.map +1 -1
  548. package/dist/ui/flows/prompt-fields.js +8 -1
  549. package/dist/ui/flows/prompt-fields.js.map +1 -1
  550. package/dist/ui/messages.d.ts +6 -0
  551. package/dist/ui/messages.d.ts.map +1 -1
  552. package/dist/ui/messages.js +17 -0
  553. package/dist/ui/messages.js.map +1 -1
  554. package/dist/ui/progress.d.ts +7 -0
  555. package/dist/ui/progress.d.ts.map +1 -1
  556. package/dist/ui/progress.js +22 -8
  557. package/dist/ui/progress.js.map +1 -1
  558. package/dist/ui/runtime/command-chrome.d.ts.map +1 -1
  559. package/dist/ui/runtime/command-chrome.js +2 -0
  560. package/dist/ui/runtime/command-chrome.js.map +1 -1
  561. package/dist/ui/runtime/prompt-interrupt.d.ts +10 -0
  562. package/dist/ui/runtime/prompt-interrupt.d.ts.map +1 -0
  563. package/dist/ui/runtime/prompt-interrupt.js +24 -0
  564. package/dist/ui/runtime/prompt-interrupt.js.map +1 -0
  565. package/dist/ui/runtime/run-clack-flow.d.ts.map +1 -1
  566. package/dist/ui/runtime/run-clack-flow.js +5 -2
  567. package/dist/ui/runtime/run-clack-flow.js.map +1 -1
  568. package/dist/ui/runtime/stdin-after-ink.d.ts +14 -1
  569. package/dist/ui/runtime/stdin-after-ink.d.ts.map +1 -1
  570. package/dist/ui/runtime/stdin-after-ink.js +44 -3
  571. package/dist/ui/runtime/stdin-after-ink.js.map +1 -1
  572. package/dist/url-safe-passwords.d.ts +25 -0
  573. package/dist/url-safe-passwords.d.ts.map +1 -0
  574. package/dist/url-safe-passwords.js +70 -0
  575. package/dist/url-safe-passwords.js.map +1 -0
  576. package/dist/valkey-sidecar.d.ts +33 -6
  577. package/dist/valkey-sidecar.d.ts.map +1 -1
  578. package/dist/valkey-sidecar.js +90 -61
  579. package/dist/valkey-sidecar.js.map +1 -1
  580. package/dist/worker-module-files.d.ts +3 -0
  581. package/dist/worker-module-files.d.ts.map +1 -0
  582. package/dist/worker-module-files.js +18 -0
  583. package/dist/worker-module-files.js.map +1 -0
  584. package/package.json +9 -6
  585. package/dist/functions-router-gen.d.ts.map +0 -1
  586. package/dist/functions-router-gen.js +0 -302
  587. package/dist/functions-router-gen.js.map +0 -1
@@ -5,30 +5,15 @@
5
5
  * accepts one, so without this check the stack comes up whole except for the REST API, which
6
6
  * restarts in a loop and gives its reason only in its own log.
7
7
  *
8
- * Kept out of `local-secrets.ts` on purpose: that module is imported widely, and the fatal error
9
- * below brings in the terminal UI.
8
+ * The rules themselves are in `jwt-secret-rules.ts`, which has no terminal UI so that
9
+ * `local-secrets.ts` can use them; this module adds the refusal.
10
10
  */
11
+ import { JWT_SECRET_REMEDY, jwtSecretTooShort } from "./jwt-secret-rules.js";
11
12
  import { fatalError } from "./ui/fatal.js";
12
- /** The shortest JWT secret PostgREST will start with. */
13
- export const MIN_JWT_SECRET_LENGTH = 32;
14
- /** Why `secret` cannot sign this stack's tokens, or null when it can. */
15
- export function jwtSecretTooShort(secret) {
16
- if (secret.length >= MIN_JWT_SECRET_LENGTH)
17
- return null;
18
- return (`JWT_SECRET in .env is ${secret.length} characters, and the REST API needs at least ` +
19
- `${MIN_JWT_SECRET_LENGTH}.`);
20
- }
21
- /**
22
- * What to do about a short secret. `--force`, because the keys already in .env were signed with
23
- * the old secret and `keys --write` on its own only fills blank ones.
24
- */
25
- export const JWT_SECRET_REMEDY = [
26
- "Generate a longer one, for example with `openssl rand -base64 48`, and put it in .env as JWT_SECRET.",
27
- "Then run `supatype keys --write --force` to sign ANON_KEY and SERVICE_ROLE_KEY with it again.",
28
- ];
29
- /** Stop before starting a stack whose REST API could not start with `secret`. */
30
- export function requireUsableJwtSecret(secret) {
31
- const problem = jwtSecretTooShort(secret);
13
+ export { JWT_SECRET_REMEDY, MIN_JWT_SECRET_LENGTH, jwtSecretTooShort } from "./jwt-secret-rules.js";
14
+ /** Stop before starting a stack whose REST API could not start with `secret`, named by `where`. */
15
+ export function requireUsableJwtSecret(secret, where) {
16
+ const problem = jwtSecretTooShort(secret, where);
32
17
  if (problem === null)
33
18
  return;
34
19
  fatalError(problem, [...JWT_SECRET_REMEDY]);
@@ -1 +1 @@
1
- {"version":3,"file":"jwt-secret-length.js","sourceRoot":"","sources":["../src/jwt-secret-length.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,yDAAyD;AACzD,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAEvC,yEAAyE;AACzE,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,IAAI,MAAM,CAAC,MAAM,IAAI,qBAAqB;QAAE,OAAO,IAAI,CAAA;IACvD,OAAO,CACL,yBAAyB,MAAM,CAAC,MAAM,+CAA+C;QACrF,GAAG,qBAAqB,GAAG,CAC5B,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IAClD,sGAAsG;IACtG,+FAA+F;CAChG,CAAA;AAED,iFAAiF;AACjF,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACnD,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAA;IACzC,IAAI,OAAO,KAAK,IAAI;QAAE,OAAM;IAC5B,UAAU,CAAC,OAAO,EAAE,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAA;AAC7C,CAAC"}
1
+ {"version":3,"file":"jwt-secret-length.js","sourceRoot":"","sources":["../src/jwt-secret-length.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAEnG,mGAAmG;AACnG,MAAM,UAAU,sBAAsB,CAAC,MAAc,EAAE,KAAc;IACnE,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAChD,IAAI,OAAO,KAAK,IAAI;QAAE,OAAM;IAC5B,UAAU,CAAC,OAAO,EAAE,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAA;AAC7C,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * What a JWT secret has to be before the CLI signs keys with it or writes it into `.env`.
3
+ *
4
+ * Pure checks with no terminal UI, so `local-secrets.ts`, which is imported widely, can apply them
5
+ * before it writes a secret. `jwt-secret-length.ts` turns them into a refusal.
6
+ */
7
+ /** The shortest JWT secret PostgREST will start with. */
8
+ export declare const MIN_JWT_SECRET_LENGTH = 32;
9
+ /**
10
+ * Why `secret` cannot sign this stack's tokens, or null when it can. PostgREST 13 and later refuse
11
+ * a secret shorter than 32 characters, so the stack would come up whole except for the REST API.
12
+ * `where` names the secret in the message.
13
+ */
14
+ export declare function jwtSecretTooShort(secret: string, where?: string): string | null;
15
+ /** Why `secret`, named by `where`, cannot be written into `.env` and signed with, or null. */
16
+ export declare function jwtSecretUnwritable(secret: string, where: string): string | null;
17
+ /**
18
+ * What to do about a short secret in `.env`. `--force`, because the keys already in .env were
19
+ * signed with the old secret and `keys --write` on its own only fills blank ones.
20
+ */
21
+ export declare const JWT_SECRET_REMEDY: readonly string[];
22
+ /** What to do about a given secret that cannot be written into `.env`. */
23
+ export declare const GIVEN_JWT_SECRET_REMEDY: readonly string[];
24
+ //# sourceMappingURL=jwt-secret-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-secret-rules.d.ts","sourceRoot":"","sources":["../src/jwt-secret-rules.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,KAAK,CAAA;AAEvC;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,SAAuB,GAAG,MAAM,GAAG,IAAI,CAG7F;AAQD,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKhF;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAG9C,CAAA;AAED,0EAA0E;AAC1E,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAGpD,CAAA"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * What a JWT secret has to be before the CLI signs keys with it or writes it into `.env`.
3
+ *
4
+ * Pure checks with no terminal UI, so `local-secrets.ts`, which is imported widely, can apply them
5
+ * before it writes a secret. `jwt-secret-length.ts` turns them into a refusal.
6
+ */
7
+ /** The shortest JWT secret PostgREST will start with. */
8
+ export const MIN_JWT_SECRET_LENGTH = 32;
9
+ /**
10
+ * Why `secret` cannot sign this stack's tokens, or null when it can. PostgREST 13 and later refuse
11
+ * a secret shorter than 32 characters, so the stack would come up whole except for the REST API.
12
+ * `where` names the secret in the message.
13
+ */
14
+ export function jwtSecretTooShort(secret, where = "JWT_SECRET in .env") {
15
+ if (secret.length >= MIN_JWT_SECRET_LENGTH)
16
+ return null;
17
+ return `${where} is ${secret.length} characters, and the REST API needs at least ${MIN_JWT_SECRET_LENGTH}.`;
18
+ }
19
+ /**
20
+ * What changes an unquoted `.env` value: whitespace ends or is trimmed from it, `#` starts a
21
+ * comment, and a quote starts a quoted value. The CLI writes the secret unquoted.
22
+ */
23
+ const BREAKS_UNQUOTED_ENV_VALUE = /[\s#"'`]/;
24
+ /** Why `secret`, named by `where`, cannot be written into `.env` and signed with, or null. */
25
+ export function jwtSecretUnwritable(secret, where) {
26
+ const short = jwtSecretTooShort(secret, where);
27
+ if (short !== null)
28
+ return short;
29
+ if (!BREAKS_UNQUOTED_ENV_VALUE.test(secret))
30
+ return null;
31
+ return `${where} contains whitespace, a # or a quote, which a value in .env cannot hold unquoted.`;
32
+ }
33
+ /**
34
+ * What to do about a short secret in `.env`. `--force`, because the keys already in .env were
35
+ * signed with the old secret and `keys --write` on its own only fills blank ones.
36
+ */
37
+ export const JWT_SECRET_REMEDY = [
38
+ "Generate a longer one, for example with `openssl rand -base64 48`, and put it in .env as JWT_SECRET.",
39
+ "Then run `supatype keys --write --force` to sign ANON_KEY and SERVICE_ROLE_KEY with it again.",
40
+ ];
41
+ /** What to do about a given secret that cannot be written into `.env`. */
42
+ export const GIVEN_JWT_SECRET_REMEDY = [
43
+ "Use one of at least 32 characters with no whitespace, # or quotes, for example from " +
44
+ "`openssl rand -base64 48`, or leave JWT_SECRET unset to have one generated.",
45
+ ];
46
+ //# sourceMappingURL=jwt-secret-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-secret-rules.js","sourceRoot":"","sources":["../src/jwt-secret-rules.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yDAAyD;AACzD,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAEvC;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,KAAK,GAAG,oBAAoB;IAC5E,IAAI,MAAM,CAAC,MAAM,IAAI,qBAAqB;QAAE,OAAO,IAAI,CAAA;IACvD,OAAO,GAAG,KAAK,OAAO,MAAM,CAAC,MAAM,gDAAgD,qBAAqB,GAAG,CAAA;AAC7G,CAAC;AAED;;;GAGG;AACH,MAAM,yBAAyB,GAAG,UAAU,CAAA;AAE5C,8FAA8F;AAC9F,MAAM,UAAU,mBAAmB,CAAC,MAAc,EAAE,KAAa;IAC/D,MAAM,KAAK,GAAG,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAC9C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAChC,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAA;IACxD,OAAO,GAAG,KAAK,mFAAmF,CAAA;AACpG,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IAClD,sGAAsG;IACtG,+FAA+F;CAChG,CAAA;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,uBAAuB,GAAsB;IACxD,sFAAsF;QACpF,6EAA6E;CAChF,CAAA"}
@@ -1,9 +1,4 @@
1
- /**
2
- * Host port published for Kong in local Docker Compose. Kong still listens on
3
- * 8000 inside the container; this avoids clashing with other tools on :8000.
4
- */
5
- export declare const LOCAL_KONG_HOST_PORT = 18473;
6
- export declare function localKongBaseUrl(): string;
1
+ import { type SupatypeProjectConfig } from "./project-config.js";
7
2
  /**
8
3
  * The local stack's public address, without a trailing slash: `.env`'s API_EXTERNAL_URL, the value
9
4
  * compose hands the server and the functions worker as their public address, else the gateway's
@@ -13,4 +8,6 @@ export declare function localKongBaseUrl(): string;
13
8
  * address the running stack answers on rather than the default port.
14
9
  */
15
10
  export declare function localPublicApiUrl(cwd: string): string;
11
+ /** What `link`'s field is called: the server's URL for native dev, which has no gateway (local test 3b). */
12
+ export declare function localLinkLabel(config: SupatypeProjectConfig): string;
16
13
  //# sourceMappingURL=local-gateway.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"local-gateway.d.ts","sourceRoot":"","sources":["../src/local-gateway.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAAQ,CAAA;AAEzC,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKrD"}
1
+ {"version":3,"file":"local-gateway.d.ts","sourceRoot":"","sources":["../src/local-gateway.ts"],"names":[],"mappings":"AACA,OAAO,EAAiD,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE/G;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMrD;AAED,4GAA4G;AAC5G,wBAAgB,cAAc,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,CAEpE"}
@@ -1,12 +1,5 @@
1
1
  import { readComposeEnvInt, readEnvValue } from "./env-file.js";
2
- /**
3
- * Host port published for Kong in local Docker Compose. Kong still listens on
4
- * 8000 inside the container; this avoids clashing with other tools on :8000.
5
- */
6
- export const LOCAL_KONG_HOST_PORT = 18473;
7
- export function localKongBaseUrl() {
8
- return `http://localhost:${LOCAL_KONG_HOST_PORT}`;
9
- }
2
+ import { COMPOSE_DEV_KONG_PORT, resolveRuntimeProvider } from "./project-config.js";
10
3
  /**
11
4
  * The local stack's public address, without a trailing slash: `.env`'s API_EXTERNAL_URL, the value
12
5
  * compose hands the server and the functions worker as their public address, else the gateway's
@@ -19,7 +12,12 @@ export function localPublicApiUrl(cwd) {
19
12
  const external = readEnvValue(cwd, "API_EXTERNAL_URL", "").replace(/\/+$/, "");
20
13
  if (external !== "")
21
14
  return external;
22
- const port = readComposeEnvInt(cwd, "SUPATYPE_KONG_PORT") ?? LOCAL_KONG_HOST_PORT;
15
+ // The port compose binds when SUPATYPE_KONG_PORT is unset: one definition with every other caller.
16
+ const port = readComposeEnvInt(cwd, "SUPATYPE_KONG_PORT") ?? COMPOSE_DEV_KONG_PORT;
23
17
  return `http://localhost:${port}`;
24
18
  }
19
+ /** What `link`'s field is called: the server's URL for native dev, which has no gateway (local test 3b). */
20
+ export function localLinkLabel(config) {
21
+ return resolveRuntimeProvider(config) === "native" ? "Server URL" : "Kong gateway URL";
22
+ }
25
23
  //# sourceMappingURL=local-gateway.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"local-gateway.js","sourceRoot":"","sources":["../src/local-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAA;AAEzC,MAAM,UAAU,gBAAgB;IAC9B,OAAO,oBAAoB,oBAAoB,EAAE,CAAA;AACnD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAC9E,IAAI,QAAQ,KAAK,EAAE;QAAE,OAAO,QAAQ,CAAA;IACpC,MAAM,IAAI,GAAG,iBAAiB,CAAC,GAAG,EAAE,oBAAoB,CAAC,IAAI,oBAAoB,CAAA;IACjF,OAAO,oBAAoB,IAAI,EAAE,CAAA;AACnC,CAAC"}
1
+ {"version":3,"file":"local-gateway.js","sourceRoot":"","sources":["../src/local-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAA8B,MAAM,qBAAqB,CAAA;AAE/G;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAC9E,IAAI,QAAQ,KAAK,EAAE;QAAE,OAAO,QAAQ,CAAA;IACpC,mGAAmG;IACnG,MAAM,IAAI,GAAG,iBAAiB,CAAC,GAAG,EAAE,oBAAoB,CAAC,IAAI,qBAAqB,CAAA;IAClF,OAAO,oBAAoB,IAAI,EAAE,CAAA;AACnC,CAAC;AAED,4GAA4G;AAC5G,MAAM,UAAU,cAAc,CAAC,MAA6B;IAC1D,OAAO,sBAAsB,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,kBAAkB,CAAA;AACxF,CAAC"}
@@ -36,13 +36,8 @@ export declare function generateControlPlaneSecret(): string;
36
36
  * because their environment changed.
37
37
  */
38
38
  export declare function ensureControlPlaneSecret(cwd: string): void;
39
- /**
40
- * Fallback JWT signing secret for a project that has none.
41
- *
42
- * Published, therefore worthless as a secret, anyone can mint a token for a stack still using
43
- * it. That is precisely why `init` generates one instead of relying on this.
44
- */
45
- export declare const FALLBACK_JWT_SECRET = "super-secret-jwt-token-with-at-least-32-characters-long";
39
+ /** A new JWT signing secret: 48 random bytes, base64url, so 64 characters. */
40
+ export declare function generateJwtSecret(): string;
46
41
  /** Fallback Postgres superuser password for a project that has none. */
47
42
  export declare const FALLBACK_POSTGRES_PASSWORD = "postgres";
48
43
  /** Fallback password for the role PostgREST connects as. */
@@ -56,8 +51,79 @@ export declare const SQL_EDITOR_PASSWORD_ENV = "SUPATYPE_SQL_EDITOR_PASSWORD";
56
51
  * role, so it is not a choice the project gets to make, and not a value read from `.env`.
57
52
  */
58
53
  export declare const BUNDLED_DB_USER = "supatype_admin";
59
- /** The secret the local stack signs and validates tokens with. */
54
+ /**
55
+ * The secret the local stack signs and validates tokens with: `.env`'s, or one written there first.
56
+ *
57
+ * Generated rather than defaulted. A published fallback let anyone mint a token for a stack using
58
+ * it, and the docker dev path wrote it into the same `.env` a server reads. A secret a project
59
+ * already has is kept, whatever it is, because replacing it invalidates every token issued. A
60
+ * `.env` without one gets the shell's when it is usable, as everywhere else ({@link newJwtSecret}).
61
+ */
60
62
  export declare function devJwtSecret(cwd: string): string;
63
+ /**
64
+ * The names compose would take from the shell ahead of `--env-file`, where the CLI wants `.env`'s:
65
+ * the keys in `.env` are signed with its JWT_SECRET, so a different one from the shell would start
66
+ * the stack verifying with a secret those keys do not match, and refuse every request.
67
+ */
68
+ export declare const ENV_FILE_OVER_SHELL: readonly ["JWT_SECRET", "ANON_KEY", "SERVICE_ROLE_KEY"];
69
+ /**
70
+ * The claims of `key` when the stack would accept it as `role`: signed with `secret`, for that role,
71
+ * and not expiring within `validForSeconds`. Null otherwise. The issuer is not checked, since
72
+ * nothing in the stack checks it.
73
+ */
74
+ export declare function usableKeyClaims(key: string, role: string, secret: string, validForSeconds?: number): Record<string, unknown> | null;
75
+ /**
76
+ * Whether compose runs without the shell's `shellValue` for `name`, so the stack gets `.env`'s.
77
+ * Always when `.env` defines the name. For a key `.env` leaves blank, only when `.env` holds a
78
+ * JWT_SECRET and the shell's key is not one the stack would accept under it ({@link usableKeyClaims}):
79
+ * a usable one is kept, since the compose file requires SERVICE_ROLE_KEY to be set at all.
80
+ */
81
+ export declare function envFileOverridesShell(env: Record<string, string>, name: (typeof ENV_FILE_OVER_SHELL)[number], shellValue: string | undefined): boolean;
82
+ /** A JWT secret given to a run rather than read from `.env`, with where it came from. */
83
+ export interface GivenJwtSecret {
84
+ value: string;
85
+ source: string;
86
+ /** Passed as `--secret`, which is refused rather than overridden when `.env` holds another. */
87
+ fromFlag: boolean;
88
+ }
89
+ /** `--secret` when one was passed, else the shell's JWT_SECRET, which compose reads ahead of `.env`. */
90
+ export declare function givenJwtSecret(flag?: string): GivenJwtSecret | undefined;
91
+ /**
92
+ * The secret for a `.env` that has none: `given` when `.env` can hold it and the stack can use it,
93
+ * else a generated one, with why `given` was passed over. For the callers that carry on regardless
94
+ * (`init`, `dev`), where a refusal would strand a half-made project or a starting session.
95
+ */
96
+ export declare function newJwtSecret(given?: GivenJwtSecret): {
97
+ secret: string;
98
+ problem?: string;
99
+ };
100
+ /** The JWT_SECRET keys written into `.env` are signed with, or why there is none to use. */
101
+ export type EnvJwtSecret = {
102
+ ok: true;
103
+ secret: string;
104
+ /** The JWT_SECRET to upsert beside the keys: empty when `.env` already holds it. */
105
+ write: Record<string, string>;
106
+ /** Where a newly written secret came from. Its keys have to be signed again. */
107
+ note?: string;
108
+ /** A given secret differing from `.env`'s, which is not used. */
109
+ warning?: string;
110
+ } | {
111
+ ok: false;
112
+ problem: string;
113
+ hints: readonly string[];
114
+ };
115
+ /**
116
+ * The one resolver for the secret that keys written into `.env` are signed with. `.env`'s always
117
+ * wins, since `.env` is what every later run of the stack reads, and compose is run without the
118
+ * shell's copy when `.env` has one (self-host-compose.ts). A `given` secret is written into a `.env`
119
+ * that has none, else one is generated; a `given` one that differs from `.env`'s earns a warning.
120
+ *
121
+ * Checked before anything is written, so keys are never signed with a secret the stack then
122
+ * refuses. A `--secret` that differs from `.env`'s is refused by `keys` before it gets here.
123
+ */
124
+ export declare function resolveEnvJwtSecret(env: Record<string, string>, given?: GivenJwtSecret): EnvJwtSecret;
125
+ /** The one line said when `given` differs from `.env`'s JWT_SECRET, which is used instead. */
126
+ export declare function ignoredJwtSecretWarning(inFile: string, given: GivenJwtSecret | undefined): string | undefined;
61
127
  /** The password for the Postgres superuser the engine and server connect as. */
62
128
  export declare function devPostgresPassword(cwd: string): string;
63
129
  /**
@@ -98,11 +164,13 @@ export declare function devSqlEditorPassword(cwd: string): string;
98
164
  * `supatype init` writing them.
99
165
  *
100
166
  * **Fills with the fallback, does not generate.** Preserving the value such a project has been
101
- * running with is the point: generating a new `JWT_SECRET` would invalidate tokens already
102
- * issued, and a new `POSTGRES_PASSWORD` would not match the password baked into an existing
103
- * Postgres volume, which `initdb` only sets once. New projects get generated values from
167
+ * running with is the point: a new `POSTGRES_PASSWORD` would not match the password baked into an
168
+ * existing Postgres volume, which `initdb` only sets once. New projects get generated values from
104
169
  * `init`; existing ones keep working and are no worse off than before.
105
170
  *
171
+ * Not `JWT_SECRET`: {@link devJwtSecret} generates that one, and every caller signs its keys
172
+ * through it before this runs.
173
+ *
106
174
  * `POSTGRES_PASSWORD` only for the bundled database. An external one is reached through the
107
175
  * operator's `DATABASE_URL`, and a fallback password beside it describes a credential that does
108
176
  * not exist.
@@ -141,6 +209,22 @@ export interface DevDatabaseIdentity {
141
209
  * through here, so a project's own credentials cannot be read by one path and assumed by another.
142
210
  */
143
211
  export declare function devDatabaseIdentity(cwd: string): DevDatabaseIdentity;
212
+ /** {@link devDatabaseIdentity} from `.env` values already read. */
213
+ export declare function devDatabaseIdentityOf(env: Readonly<Record<string, string>>): DevDatabaseIdentity;
214
+ /** What else a URL must match to name the local database, beyond this machine and its name. */
215
+ export interface DevDatabaseMatch {
216
+ /** The host port it must name; any when absent. */
217
+ port?: number;
218
+ /** Its user and password must be the identity's: the URL the CLI itself writes. */
219
+ credentials?: true;
220
+ }
221
+ /**
222
+ * The one definition of "this project's own local database": a URL naming this machine and the
223
+ * identity's database, and, as asked, the port the stack publishes or the identity's credentials.
224
+ * `push` asks with the port, to know a target is the stack it runs; `.env`'s owner asks with the
225
+ * credentials, to know a URL is the one the CLI writes (database-url-owner.ts).
226
+ */
227
+ export declare function isDevDatabaseUrl(value: string, identity: DevDatabaseIdentity, match?: DevDatabaseMatch): boolean;
144
228
  /** A connection string to the local database at `hostPort`, `db:5432` inside the network. */
145
229
  export declare function devDatabaseUrl(cwd: string, hostPort: string): string;
146
230
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"local-secrets.d.ts","sourceRoot":"","sources":["../src/local-secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAwB,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAEtF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,kCAAkC,CAAA;AAEvE,gFAAgF;AAChF,wBAAgB,0BAA0B,IAAI,MAAM,CAEnD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAG1D;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,4DAA4D,CAAA;AAE5F,wEAAwE;AACxE,eAAO,MAAM,0BAA0B,aAAa,CAAA;AAEpD,4DAA4D;AAC5D,eAAO,MAAM,+BAA+B,wBAAwB,CAAA;AAEpE,6FAA6F;AAC7F,eAAO,MAAM,4BAA4B,qBAAqB,CAAA;AAE9D,6DAA6D;AAC7D,eAAO,MAAM,uBAAuB,iCAAiC,CAAA;AAErE;;;GAGG;AACH,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAE/C,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD;AA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
13
13
  import { randomBytes } from "node:crypto";
14
- import { hasEnvValue, readEnvValue, upsertEnvFile } from "./env-file.js";
14
+ import { hasEnvValue, readEnvFile, readEnvValue, upsertEnvFile } from "./env-file.js";
15
+ import { databaseUrlHostPort, localDatabaseUrl } from "./db-port.js";
16
+ import { verifyJwt } from "./jwt.js";
17
+ import { GIVEN_JWT_SECRET_REMEDY, JWT_SECRET_REMEDY, jwtSecretTooShort, jwtSecretUnwritable, } from "./jwt-secret-rules.js";
15
18
  import { usesExternalDatabase } from "./project-config.js";
16
19
  /**
17
20
  * The secret the gateway presents to the control plane, and the only thing the control plane
@@ -44,13 +47,10 @@ export function ensureControlPlaneSecret(cwd) {
44
47
  return;
45
48
  upsertEnvFile(cwd, { [CONTROL_PLANE_SECRET_ENV]: generateControlPlaneSecret() });
46
49
  }
47
- /**
48
- * Fallback JWT signing secret for a project that has none.
49
- *
50
- * Published, therefore worthless as a secret, anyone can mint a token for a stack still using
51
- * it. That is precisely why `init` generates one instead of relying on this.
52
- */
53
- export const FALLBACK_JWT_SECRET = "super-secret-jwt-token-with-at-least-32-characters-long";
50
+ /** A new JWT signing secret: 48 random bytes, base64url, so 64 characters. */
51
+ export function generateJwtSecret() {
52
+ return randomBytes(48).toString("base64url");
53
+ }
54
54
  /** Fallback Postgres superuser password for a project that has none. */
55
55
  export const FALLBACK_POSTGRES_PASSWORD = "postgres";
56
56
  /** Fallback password for the role PostgREST connects as. */
@@ -64,9 +64,113 @@ export const SQL_EDITOR_PASSWORD_ENV = "SUPATYPE_SQL_EDITOR_PASSWORD";
64
64
  * role, so it is not a choice the project gets to make, and not a value read from `.env`.
65
65
  */
66
66
  export const BUNDLED_DB_USER = "supatype_admin";
67
- /** The secret the local stack signs and validates tokens with. */
67
+ /**
68
+ * The secret the local stack signs and validates tokens with: `.env`'s, or one written there first.
69
+ *
70
+ * Generated rather than defaulted. A published fallback let anyone mint a token for a stack using
71
+ * it, and the docker dev path wrote it into the same `.env` a server reads. A secret a project
72
+ * already has is kept, whatever it is, because replacing it invalidates every token issued. A
73
+ * `.env` without one gets the shell's when it is usable, as everywhere else ({@link newJwtSecret}).
74
+ */
68
75
  export function devJwtSecret(cwd) {
69
- return readEnvValue(cwd, "JWT_SECRET", FALLBACK_JWT_SECRET);
76
+ const inFile = readEnvValue(cwd, "JWT_SECRET", "");
77
+ if (inFile !== "")
78
+ return inFile;
79
+ const { secret, problem } = newJwtSecret(givenJwtSecret());
80
+ if (problem !== undefined)
81
+ console.warn(`[supatype] ${problem} Generated a JWT_SECRET for .env instead.`);
82
+ upsertEnvFile(cwd, { JWT_SECRET: secret });
83
+ return secret;
84
+ }
85
+ /**
86
+ * The names compose would take from the shell ahead of `--env-file`, where the CLI wants `.env`'s:
87
+ * the keys in `.env` are signed with its JWT_SECRET, so a different one from the shell would start
88
+ * the stack verifying with a secret those keys do not match, and refuse every request.
89
+ */
90
+ export const ENV_FILE_OVER_SHELL = ["JWT_SECRET", "ANON_KEY", "SERVICE_ROLE_KEY"];
91
+ /** The role a key under each name has to carry. */
92
+ const KEY_ROLES = { ANON_KEY: "anon", SERVICE_ROLE_KEY: "service_role" };
93
+ /**
94
+ * The claims of `key` when the stack would accept it as `role`: signed with `secret`, for that role,
95
+ * and not expiring within `validForSeconds`. Null otherwise. The issuer is not checked, since
96
+ * nothing in the stack checks it.
97
+ */
98
+ export function usableKeyClaims(key, role, secret, validForSeconds = 0) {
99
+ const claims = key === "" ? null : verifyJwt(key, secret);
100
+ if (claims === null || claims["role"] !== role)
101
+ return null;
102
+ const expiry = claims["exp"];
103
+ const live = typeof expiry !== "number" || expiry > Math.floor(Date.now() / 1000) + validForSeconds;
104
+ return live ? claims : null;
105
+ }
106
+ /**
107
+ * Whether compose runs without the shell's `shellValue` for `name`, so the stack gets `.env`'s.
108
+ * Always when `.env` defines the name. For a key `.env` leaves blank, only when `.env` holds a
109
+ * JWT_SECRET and the shell's key is not one the stack would accept under it ({@link usableKeyClaims}):
110
+ * a usable one is kept, since the compose file requires SERVICE_ROLE_KEY to be set at all.
111
+ */
112
+ export function envFileOverridesShell(env, name, shellValue) {
113
+ if ((env[name] ?? "") !== "")
114
+ return true;
115
+ const secret = env["JWT_SECRET"] ?? "";
116
+ if (name === "JWT_SECRET" || secret === "" || shellValue === undefined || shellValue === "")
117
+ return false;
118
+ return usableKeyClaims(shellValue, KEY_ROLES[name], secret) === null;
119
+ }
120
+ /** `--secret` when one was passed, else the shell's JWT_SECRET, which compose reads ahead of `.env`. */
121
+ export function givenJwtSecret(flag) {
122
+ if (flag !== undefined)
123
+ return { value: flag, source: "--secret", fromFlag: true };
124
+ const fromShell = process.env["JWT_SECRET"];
125
+ if (!fromShell)
126
+ return undefined;
127
+ return { value: fromShell, source: "the JWT_SECRET environment variable", fromFlag: false };
128
+ }
129
+ /**
130
+ * The secret for a `.env` that has none: `given` when `.env` can hold it and the stack can use it,
131
+ * else a generated one, with why `given` was passed over. For the callers that carry on regardless
132
+ * (`init`, `dev`), where a refusal would strand a half-made project or a starting session.
133
+ */
134
+ export function newJwtSecret(given) {
135
+ if (given === undefined)
136
+ return { secret: generateJwtSecret() };
137
+ const problem = jwtSecretUnwritable(given.value, given.source);
138
+ return problem === null ? { secret: given.value } : { secret: generateJwtSecret(), problem };
139
+ }
140
+ /**
141
+ * The one resolver for the secret that keys written into `.env` are signed with. `.env`'s always
142
+ * wins, since `.env` is what every later run of the stack reads, and compose is run without the
143
+ * shell's copy when `.env` has one (self-host-compose.ts). A `given` secret is written into a `.env`
144
+ * that has none, else one is generated; a `given` one that differs from `.env`'s earns a warning.
145
+ *
146
+ * Checked before anything is written, so keys are never signed with a secret the stack then
147
+ * refuses. A `--secret` that differs from `.env`'s is refused by `keys` before it gets here.
148
+ */
149
+ export function resolveEnvJwtSecret(env, given) {
150
+ const inFile = env["JWT_SECRET"] ?? "";
151
+ if (inFile === "")
152
+ return writtenEnvJwtSecret(given);
153
+ const short = jwtSecretTooShort(inFile);
154
+ if (short !== null)
155
+ return { ok: false, problem: short, hints: JWT_SECRET_REMEDY };
156
+ const warning = ignoredJwtSecretWarning(inFile, given);
157
+ return { ok: true, secret: inFile, write: {}, ...(warning !== undefined && { warning }) };
158
+ }
159
+ /** The one line said when `given` differs from `.env`'s JWT_SECRET, which is used instead. */
160
+ export function ignoredJwtSecretWarning(inFile, given) {
161
+ if (given === undefined || given.value === inFile)
162
+ return undefined;
163
+ return `${given.source} differs from the JWT_SECRET in .env, so this run uses the one in .env.`;
164
+ }
165
+ function writtenEnvJwtSecret(given) {
166
+ const secret = given?.value ?? generateJwtSecret();
167
+ const problem = given === undefined ? null : jwtSecretUnwritable(secret, given.source);
168
+ if (problem !== null)
169
+ return { ok: false, problem, hints: GIVEN_JWT_SECRET_REMEDY };
170
+ const from = given === undefined ? "Generated a JWT_SECRET in .env" : `Wrote JWT_SECRET into .env from ${given.source}`;
171
+ const note = `${from}, since .env had none, and signed ANON_KEY and SERVICE_ROLE_KEY with it, ` +
172
+ "replacing any keys .env held.";
173
+ return { ok: true, secret, write: { JWT_SECRET: secret }, note };
70
174
  }
71
175
  /** The password for the Postgres superuser the engine and server connect as. */
72
176
  export function devPostgresPassword(cwd) {
@@ -124,19 +228,19 @@ export function devSqlEditorPassword(cwd) {
124
228
  * `supatype init` writing them.
125
229
  *
126
230
  * **Fills with the fallback, does not generate.** Preserving the value such a project has been
127
- * running with is the point: generating a new `JWT_SECRET` would invalidate tokens already
128
- * issued, and a new `POSTGRES_PASSWORD` would not match the password baked into an existing
129
- * Postgres volume, which `initdb` only sets once. New projects get generated values from
231
+ * running with is the point: a new `POSTGRES_PASSWORD` would not match the password baked into an
232
+ * existing Postgres volume, which `initdb` only sets once. New projects get generated values from
130
233
  * `init`; existing ones keep working and are no worse off than before.
131
234
  *
235
+ * Not `JWT_SECRET`: {@link devJwtSecret} generates that one, and every caller signs its keys
236
+ * through it before this runs.
237
+ *
132
238
  * `POSTGRES_PASSWORD` only for the bundled database. An external one is reached through the
133
239
  * operator's `DATABASE_URL`, and a fallback password beside it describes a credential that does
134
240
  * not exist.
135
241
  */
136
242
  export function seedMissingLocalSecrets(cwd, config) {
137
243
  const out = {};
138
- if (!hasEnvValue(cwd, "JWT_SECRET"))
139
- out.JWT_SECRET = FALLBACK_JWT_SECRET;
140
244
  if (!usesExternalDatabase(config) && !hasEnvValue(cwd, "POSTGRES_PASSWORD")) {
141
245
  out.POSTGRES_PASSWORD = FALLBACK_POSTGRES_PASSWORD;
142
246
  }
@@ -184,16 +288,47 @@ export function seedMissingDatabaseIdentity(cwd, config) {
184
288
  * through here, so a project's own credentials cannot be read by one path and assumed by another.
185
289
  */
186
290
  export function devDatabaseIdentity(cwd) {
291
+ return devDatabaseIdentityOf(readEnvFile(cwd));
292
+ }
293
+ /** {@link devDatabaseIdentity} from `.env` values already read. */
294
+ export function devDatabaseIdentityOf(env) {
187
295
  return {
188
296
  user: BUNDLED_DB_USER,
189
- password: devPostgresPassword(cwd),
190
- database: readEnvValue(cwd, "POSTGRES_DB", "supatype"),
297
+ password: env["POSTGRES_PASSWORD"] || FALLBACK_POSTGRES_PASSWORD,
298
+ database: env["POSTGRES_DB"] || "supatype",
191
299
  };
192
300
  }
301
+ /**
302
+ * The one definition of "this project's own local database": a URL naming this machine and the
303
+ * identity's database, and, as asked, the port the stack publishes or the identity's credentials.
304
+ * `push` asks with the port, to know a target is the stack it runs; `.env`'s owner asks with the
305
+ * credentials, to know a URL is the one the CLI writes (database-url-owner.ts).
306
+ */
307
+ export function isDevDatabaseUrl(value, identity, match = {}) {
308
+ const url = localDatabaseUrl(value);
309
+ if (url === null || url.pathname.replace(/^\//, "") !== identity.database)
310
+ return false;
311
+ if (match.port !== undefined && databaseUrlHostPort(value)?.port !== match.port)
312
+ return false;
313
+ return (match.credentials !== true ||
314
+ (decodedOrUndefined(url.username) === identity.user && decodedOrUndefined(url.password) === identity.password));
315
+ }
316
+ /**
317
+ * A URL component percent-decoded, or undefined when it is not valid percent-encoding (a `%` that
318
+ * starts no escape). The CLI writes what it can decode, so such a URL is the developer's own.
319
+ */
320
+ function decodedOrUndefined(component) {
321
+ try {
322
+ return decodeURIComponent(component);
323
+ }
324
+ catch {
325
+ return undefined;
326
+ }
327
+ }
193
328
  /** A connection string to the local database at `hostPort`, `db:5432` inside the network. */
194
329
  export function devDatabaseUrl(cwd, hostPort) {
195
330
  const { user, password, database } = devDatabaseIdentity(cwd);
196
- return `postgresql://${user}:${password}@${hostPort}/${database}?sslmode=disable`;
331
+ return `postgresql://${user}:${encodeURIComponent(password)}@${hostPort}/${database}?sslmode=disable`;
197
332
  }
198
333
  /**
199
334
  * A short, non-reversible tag for a secret, safe to print.
@@ -1 +1 @@
1
- {"version":3,"file":"local-secrets.js","sourceRoot":"","sources":["../src/local-secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACxE,OAAO,EAAE,oBAAoB,EAA8B,MAAM,qBAAqB,CAAA;AAEtF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,+BAA+B,CAAA;AAEvE,gFAAgF;AAChF,MAAM,UAAU,0BAA0B;IACxC,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AAC9C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAW;IAClD,IAAI,WAAW,CAAC,GAAG,EAAE,wBAAwB,CAAC;QAAE,OAAM;IACtD,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,wBAAwB,CAAC,EAAE,0BAA0B,EAAE,EAAE,CAAC,CAAA;AAClF,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,yDAAyD,CAAA;AAE5F,wEAAwE;AACxE,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAAA;AAEpD,4D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d.ts","sourceRoot":"","sources":["../src/local-stack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,OAAO,EAKL,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAA;AAE5B;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,qBAAqB,EAC7B,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,OAAO,CAMT;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,qBAAqB,EAC7B,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,MAAM,GAAG,SAAS,CAOpB;AAED,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,mHAAmH;AACnH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,qBAAqB,EAC7B,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,MAAM,GAAG,SAAS,CAGpB"}
@@ -11,11 +11,10 @@
11
11
  import { readComposeEnvInt } from "./env-file.js";
12
12
  import { composeDbHostPort } from "./host-database.js";
13
13
  import { composeRenderMode } from "./compose-render-mode.js";
14
- import { devDatabaseIdentity } from "./local-secrets.js";
14
+ import { devDatabaseIdentity, isDevDatabaseUrl } from "./local-secrets.js";
15
15
  import { portHeldByComposeProject } from "./dev-ports.js";
16
16
  import { composeProjectName } from "./self-host-compose.js";
17
17
  import { connectionString, resolveRuntimeProvider, serverBaseUrl, usesExternalDatabase, } from "./project-config.js";
18
- const LOOPBACK = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
19
18
  /**
20
19
  * True when `databaseUrl` is the database this project runs for itself: the docker project's
21
20
  * published compose database, or a native project's own. Undefined means "the project's own", as
@@ -29,11 +28,7 @@ export function isProjectDatabase(cwd, config, databaseUrl) {
29
28
  if (resolveRuntimeProvider(config) !== "docker")
30
29
  return sameDatabase(databaseUrl, connectionString(config, undefined, cwd));
31
30
  const port = composeDbHostPort(cwd, composeRenderMode(cwd, config.project.name));
32
- const own = parse(databaseUrl);
33
- return (own !== null &&
34
- LOOPBACK.has(own.hostname) &&
35
- Number(own.port || 5432) === port &&
36
- own.pathname.replace(/^\//, "") === devDatabaseIdentity(cwd).database);
31
+ return isDevDatabaseUrl(databaseUrl, devDatabaseIdentity(cwd), { port });
37
32
  }
38
33
  /**
39
34
  * The project's own running stack's API address, when `databaseUrl` is its database and the stack