@supatype/cli 0.9.1 → 0.10.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 (749) hide show
  1. package/CHANGELOG.md +499 -91
  2. package/bin/node-version.js +28 -0
  3. package/bin/supatype.js +8 -4
  4. package/dist/api-config-cache.d.ts +22 -8
  5. package/dist/api-config-cache.d.ts.map +1 -1
  6. package/dist/api-config-cache.js +82 -19
  7. package/dist/api-config-cache.js.map +1 -1
  8. package/dist/api-config-stack.d.ts +23 -0
  9. package/dist/api-config-stack.d.ts.map +1 -0
  10. package/dist/api-config-stack.js +63 -0
  11. package/dist/api-config-stack.js.map +1 -0
  12. package/dist/api-url.d.ts +12 -0
  13. package/dist/api-url.d.ts.map +1 -0
  14. package/dist/api-url.js +17 -0
  15. package/dist/api-url.js.map +1 -0
  16. package/dist/app/framework.d.ts +18 -2
  17. package/dist/app/framework.d.ts.map +1 -1
  18. package/dist/app/framework.js +26 -3
  19. package/dist/app/framework.js.map +1 -1
  20. package/dist/app/port-holder.d.ts +33 -0
  21. package/dist/app/port-holder.d.ts.map +1 -0
  22. package/dist/app/port-holder.js +66 -0
  23. package/dist/app/port-holder.js.map +1 -0
  24. package/dist/app/proxy-dev-app.d.ts +27 -3
  25. package/dist/app/proxy-dev-app.d.ts.map +1 -1
  26. package/dist/app/proxy-dev-app.js +100 -46
  27. package/dist/app/proxy-dev-app.js.map +1 -1
  28. package/dist/app/vite-dev-args.d.ts +33 -0
  29. package/dist/app/vite-dev-args.d.ts.map +1 -0
  30. package/dist/app/vite-dev-args.js +90 -0
  31. package/dist/app/vite-dev-args.js.map +1 -0
  32. package/dist/app-config.d.ts +2 -0
  33. package/dist/app-config.d.ts.map +1 -1
  34. package/dist/app-config.js +27 -8
  35. package/dist/app-config.js.map +1 -1
  36. package/dist/applied-ast-artifacts.d.ts +7 -2
  37. package/dist/applied-ast-artifacts.d.ts.map +1 -1
  38. package/dist/applied-ast-artifacts.js +8 -3
  39. package/dist/applied-ast-artifacts.js.map +1 -1
  40. package/dist/archive-extract.d.ts +21 -2
  41. package/dist/archive-extract.d.ts.map +1 -1
  42. package/dist/archive-extract.js +30 -11
  43. package/dist/archive-extract.js.map +1 -1
  44. package/dist/augmentation-generator.d.ts +9 -0
  45. package/dist/augmentation-generator.d.ts.map +1 -1
  46. package/dist/augmentation-generator.js +75 -8
  47. package/dist/augmentation-generator.js.map +1 -1
  48. package/dist/auth-answer.d.ts +1 -1
  49. package/dist/auth-answer.js +1 -1
  50. package/dist/auth-config-validate.d.ts +3 -0
  51. package/dist/auth-config-validate.d.ts.map +1 -0
  52. package/dist/auth-config-validate.js +85 -0
  53. package/dist/auth-config-validate.js.map +1 -0
  54. package/dist/auth-groups-env.d.ts +14 -0
  55. package/dist/auth-groups-env.d.ts.map +1 -0
  56. package/dist/auth-groups-env.js +53 -0
  57. package/dist/auth-groups-env.js.map +1 -0
  58. package/dist/auth-providers.d.ts +6 -14
  59. package/dist/auth-providers.d.ts.map +1 -1
  60. package/dist/auth-providers.js +6 -36
  61. package/dist/auth-providers.js.map +1 -1
  62. package/dist/auth-settings-push.d.ts +29 -0
  63. package/dist/auth-settings-push.d.ts.map +1 -0
  64. package/dist/auth-settings-push.js +176 -0
  65. package/dist/auth-settings-push.js.map +1 -0
  66. package/dist/binary-cache.d.ts +4 -1
  67. package/dist/binary-cache.d.ts.map +1 -1
  68. package/dist/binary-cache.js +33 -63
  69. package/dist/binary-cache.js.map +1 -1
  70. package/dist/binary-download-lock.d.ts.map +1 -1
  71. package/dist/binary-download-lock.js +2 -10
  72. package/dist/binary-download-lock.js.map +1 -1
  73. package/dist/browser-login.d.ts +42 -0
  74. package/dist/browser-login.d.ts.map +1 -0
  75. package/dist/browser-login.js +111 -0
  76. package/dist/browser-login.js.map +1 -0
  77. package/dist/build-public-env.d.ts +29 -0
  78. package/dist/build-public-env.d.ts.map +1 -0
  79. package/dist/build-public-env.js +97 -0
  80. package/dist/build-public-env.js.map +1 -0
  81. package/dist/build-refused.d.ts +9 -0
  82. package/dist/build-refused.d.ts.map +1 -0
  83. package/dist/build-refused.js +9 -0
  84. package/dist/build-refused.js.map +1 -0
  85. package/dist/cache-provider.d.ts +17 -2
  86. package/dist/cache-provider.d.ts.map +1 -1
  87. package/dist/cache-provider.js +28 -3
  88. package/dist/cache-provider.js.map +1 -1
  89. package/dist/cdn-fetch.d.ts +36 -0
  90. package/dist/cdn-fetch.d.ts.map +1 -0
  91. package/dist/cdn-fetch.js +175 -0
  92. package/dist/cdn-fetch.js.map +1 -0
  93. package/dist/channel-extractor.d.ts +51 -0
  94. package/dist/channel-extractor.d.ts.map +1 -0
  95. package/dist/channel-extractor.js +485 -0
  96. package/dist/channel-extractor.js.map +1 -0
  97. package/dist/cli-launcher.d.ts.map +1 -1
  98. package/dist/cli-launcher.js +3 -2
  99. package/dist/cli-launcher.js.map +1 -1
  100. package/dist/cli-release-check.d.ts +34 -0
  101. package/dist/cli-release-check.d.ts.map +1 -0
  102. package/dist/cli-release-check.js +79 -0
  103. package/dist/cli-release-check.js.map +1 -0
  104. package/dist/cli-standalone.d.ts +16 -0
  105. package/dist/cli-standalone.d.ts.map +1 -1
  106. package/dist/cli-standalone.js +92 -47
  107. package/dist/cli-standalone.js.map +1 -1
  108. package/dist/cli-version-embedded.d.ts.map +1 -1
  109. package/dist/cli-version-embedded.js +1 -1
  110. package/dist/cli-version-embedded.js.map +1 -1
  111. package/dist/cli.d.ts +7 -0
  112. package/dist/cli.d.ts.map +1 -1
  113. package/dist/cli.js +12 -1
  114. package/dist/cli.js.map +1 -1
  115. package/dist/client-generator.d.ts.map +1 -1
  116. package/dist/client-generator.js +9 -3
  117. package/dist/client-generator.js.map +1 -1
  118. package/dist/cloud-admin.d.ts +55 -0
  119. package/dist/cloud-admin.d.ts.map +1 -0
  120. package/dist/cloud-admin.js +99 -0
  121. package/dist/cloud-admin.js.map +1 -0
  122. package/dist/cloud-credentials.d.ts +24 -9
  123. package/dist/cloud-credentials.d.ts.map +1 -1
  124. package/dist/cloud-credentials.js +57 -47
  125. package/dist/cloud-credentials.js.map +1 -1
  126. package/dist/cloud-saml-key.d.ts +9 -0
  127. package/dist/cloud-saml-key.d.ts.map +1 -0
  128. package/dist/cloud-saml-key.js +44 -0
  129. package/dist/cloud-saml-key.js.map +1 -0
  130. package/dist/commands/admin.d.ts.map +1 -1
  131. package/dist/commands/admin.js +79 -24
  132. package/dist/commands/admin.js.map +1 -1
  133. package/dist/commands/app.d.ts.map +1 -1
  134. package/dist/commands/app.js +22 -2
  135. package/dist/commands/app.js.map +1 -1
  136. package/dist/commands/build.d.ts +3 -2
  137. package/dist/commands/build.d.ts.map +1 -1
  138. package/dist/commands/build.js +10 -13
  139. package/dist/commands/build.js.map +1 -1
  140. package/dist/commands/cache.d.ts.map +1 -1
  141. package/dist/commands/cache.js +16 -5
  142. package/dist/commands/cache.js.map +1 -1
  143. package/dist/commands/cloud.d.ts +2 -0
  144. package/dist/commands/cloud.d.ts.map +1 -1
  145. package/dist/commands/cloud.js +96 -23
  146. package/dist/commands/cloud.js.map +1 -1
  147. package/dist/commands/db.d.ts.map +1 -1
  148. package/dist/commands/db.js +2 -1
  149. package/dist/commands/db.js.map +1 -1
  150. package/dist/commands/deploy.d.ts +21 -2
  151. package/dist/commands/deploy.d.ts.map +1 -1
  152. package/dist/commands/deploy.js +97 -97
  153. package/dist/commands/deploy.js.map +1 -1
  154. package/dist/commands/dev.d.ts +31 -4
  155. package/dist/commands/dev.d.ts.map +1 -1
  156. package/dist/commands/dev.js +261 -77
  157. package/dist/commands/dev.js.map +1 -1
  158. package/dist/commands/diff.d.ts.map +1 -1
  159. package/dist/commands/diff.js +16 -4
  160. package/dist/commands/diff.js.map +1 -1
  161. package/dist/commands/doctor.js +1 -1
  162. package/dist/commands/doctor.js.map +1 -1
  163. package/dist/commands/functions.d.ts.map +1 -1
  164. package/dist/commands/functions.js +163 -54
  165. package/dist/commands/functions.js.map +1 -1
  166. package/dist/commands/generate.d.ts.map +1 -1
  167. package/dist/commands/generate.js +3 -0
  168. package/dist/commands/generate.js.map +1 -1
  169. package/dist/commands/hooks.d.ts.map +1 -1
  170. package/dist/commands/hooks.js +40 -9
  171. package/dist/commands/hooks.js.map +1 -1
  172. package/dist/commands/init.d.ts +20 -8
  173. package/dist/commands/init.d.ts.map +1 -1
  174. package/dist/commands/init.js +358 -137
  175. package/dist/commands/init.js.map +1 -1
  176. package/dist/commands/keys.d.ts +6 -0
  177. package/dist/commands/keys.d.ts.map +1 -1
  178. package/dist/commands/keys.js +17 -10
  179. package/dist/commands/keys.js.map +1 -1
  180. package/dist/commands/link-helpers.d.ts +4 -1
  181. package/dist/commands/link-helpers.d.ts.map +1 -1
  182. package/dist/commands/link-helpers.js +64 -12
  183. package/dist/commands/link-helpers.js.map +1 -1
  184. package/dist/commands/login.d.ts +3 -2
  185. package/dist/commands/login.d.ts.map +1 -1
  186. package/dist/commands/login.js +99 -57
  187. package/dist/commands/login.js.map +1 -1
  188. package/dist/commands/migrate.d.ts +17 -0
  189. package/dist/commands/migrate.d.ts.map +1 -1
  190. package/dist/commands/migrate.js +22 -4
  191. package/dist/commands/migrate.js.map +1 -1
  192. package/dist/commands/push.d.ts +35 -1
  193. package/dist/commands/push.d.ts.map +1 -1
  194. package/dist/commands/push.js +117 -21
  195. package/dist/commands/push.js.map +1 -1
  196. package/dist/commands/seed.d.ts +31 -45
  197. package/dist/commands/seed.d.ts.map +1 -1
  198. package/dist/commands/seed.js +93 -215
  199. package/dist/commands/seed.js.map +1 -1
  200. package/dist/commands/self-host.d.ts +3 -3
  201. package/dist/commands/self-host.d.ts.map +1 -1
  202. package/dist/commands/self-host.js +88 -270
  203. package/dist/commands/self-host.js.map +1 -1
  204. package/dist/commands/site.d.ts +42 -0
  205. package/dist/commands/site.d.ts.map +1 -0
  206. package/dist/commands/site.js +100 -0
  207. package/dist/commands/site.js.map +1 -0
  208. package/dist/commands/sso.d.ts +13 -3
  209. package/dist/commands/sso.d.ts.map +1 -1
  210. package/dist/commands/sso.js +58 -16
  211. package/dist/commands/sso.js.map +1 -1
  212. package/dist/commands/update.d.ts.map +1 -1
  213. package/dist/commands/update.js +161 -68
  214. package/dist/commands/update.js.map +1 -1
  215. package/dist/compose-auth-settings.d.ts +12 -0
  216. package/dist/compose-auth-settings.d.ts.map +1 -0
  217. package/dist/compose-auth-settings.js +39 -0
  218. package/dist/compose-auth-settings.js.map +1 -0
  219. package/dist/compose-db-roles.d.ts.map +1 -1
  220. package/dist/compose-db-roles.js +6 -0
  221. package/dist/compose-db-roles.js.map +1 -1
  222. package/dist/compose-kong.d.ts +5 -1
  223. package/dist/compose-kong.d.ts.map +1 -1
  224. package/dist/compose-kong.js +8 -4
  225. package/dist/compose-kong.js.map +1 -1
  226. package/dist/compose-rename.d.ts.map +1 -1
  227. package/dist/compose-rename.js +5 -0
  228. package/dist/compose-rename.js.map +1 -1
  229. package/dist/compose-render-mode.d.ts +8 -3
  230. package/dist/compose-render-mode.d.ts.map +1 -1
  231. package/dist/compose-render-mode.js +22 -13
  232. package/dist/compose-render-mode.js.map +1 -1
  233. package/dist/compose-services.d.ts.map +1 -1
  234. package/dist/compose-services.js +3 -2
  235. package/dist/compose-services.js.map +1 -1
  236. package/dist/config-mailer-env.d.ts +6 -2
  237. package/dist/config-mailer-env.d.ts.map +1 -1
  238. package/dist/config-mailer-env.js +11 -13
  239. package/dist/config-mailer-env.js.map +1 -1
  240. package/dist/config-version-pin.d.ts +42 -0
  241. package/dist/config-version-pin.d.ts.map +1 -0
  242. package/dist/config-version-pin.js +64 -0
  243. package/dist/config-version-pin.js.map +1 -0
  244. package/dist/config.d.ts +5 -1
  245. package/dist/config.d.ts.map +1 -1
  246. package/dist/config.js +6 -2
  247. package/dist/config.js.map +1 -1
  248. package/dist/cors-origins-push.d.ts +16 -0
  249. package/dist/cors-origins-push.d.ts.map +1 -0
  250. package/dist/cors-origins-push.js +37 -0
  251. package/dist/cors-origins-push.js.map +1 -0
  252. package/dist/database-url-owner.d.ts.map +1 -1
  253. package/dist/database-url-owner.js +2 -1
  254. package/dist/database-url-owner.js.map +1 -1
  255. package/dist/db-port.d.ts +3 -1
  256. package/dist/db-port.d.ts.map +1 -1
  257. package/dist/db-port.js +1 -1
  258. package/dist/db-port.js.map +1 -1
  259. package/dist/destructive-consent.d.ts.map +1 -1
  260. package/dist/destructive-consent.js +23 -1
  261. package/dist/destructive-consent.js.map +1 -1
  262. package/dist/dev-compose.d.ts +9 -4
  263. package/dist/dev-compose.d.ts.map +1 -1
  264. package/dist/dev-compose.js +112 -71
  265. package/dist/dev-compose.js.map +1 -1
  266. package/dist/dev-functions-watch.d.ts +25 -4
  267. package/dist/dev-functions-watch.d.ts.map +1 -1
  268. package/dist/dev-functions-watch.js +78 -13
  269. package/dist/dev-functions-watch.js.map +1 -1
  270. package/dist/dev-initial-push.d.ts.map +1 -1
  271. package/dist/dev-initial-push.js +6 -0
  272. package/dist/dev-initial-push.js.map +1 -1
  273. package/dist/dev-ports.d.ts +7 -2
  274. package/dist/dev-ports.d.ts.map +1 -1
  275. package/dist/dev-ports.js +44 -22
  276. package/dist/dev-ports.js.map +1 -1
  277. package/dist/dev-ready-panel.d.ts +26 -3
  278. package/dist/dev-ready-panel.d.ts.map +1 -1
  279. package/dist/dev-ready-panel.js +37 -5
  280. package/dist/dev-ready-panel.js.map +1 -1
  281. package/dist/dev-schema-watch.d.ts +6 -0
  282. package/dist/dev-schema-watch.d.ts.map +1 -1
  283. package/dist/dev-schema-watch.js +9 -0
  284. package/dist/dev-schema-watch.js.map +1 -1
  285. package/dist/dev-self-start.d.ts +16 -0
  286. package/dist/dev-self-start.d.ts.map +1 -0
  287. package/dist/dev-self-start.js +31 -0
  288. package/dist/dev-self-start.js.map +1 -0
  289. package/dist/dev-session-lock.d.ts +71 -2
  290. package/dist/dev-session-lock.d.ts.map +1 -1
  291. package/dist/dev-session-lock.js +105 -5
  292. package/dist/dev-session-lock.js.map +1 -1
  293. package/dist/dev-session.d.ts +6 -1
  294. package/dist/dev-session.d.ts.map +1 -1
  295. package/dist/dev-session.js +9 -3
  296. package/dist/dev-session.js.map +1 -1
  297. package/dist/dev-shutdown.d.ts +11 -2
  298. package/dist/dev-shutdown.d.ts.map +1 -1
  299. package/dist/dev-shutdown.js +23 -9
  300. package/dist/dev-shutdown.js.map +1 -1
  301. package/dist/diff-access.d.ts.map +1 -1
  302. package/dist/diff-access.js +17 -1
  303. package/dist/diff-access.js.map +1 -1
  304. package/dist/diff-channels.d.ts +14 -0
  305. package/dist/diff-channels.d.ts.map +1 -0
  306. package/dist/diff-channels.js +38 -0
  307. package/dist/diff-channels.js.map +1 -0
  308. package/dist/docker-exec.d.ts +25 -4
  309. package/dist/docker-exec.d.ts.map +1 -1
  310. package/dist/docker-exec.js +88 -8
  311. package/dist/docker-exec.js.map +1 -1
  312. package/dist/docker-postgres.d.ts +11 -0
  313. package/dist/docker-postgres.d.ts.map +1 -1
  314. package/dist/docker-postgres.js +9 -1
  315. package/dist/docker-postgres.js.map +1 -1
  316. package/dist/docker-runtime.d.ts +31 -7
  317. package/dist/docker-runtime.d.ts.map +1 -1
  318. package/dist/docker-runtime.js +104 -36
  319. package/dist/docker-runtime.js.map +1 -1
  320. package/dist/engine-answers.d.ts.map +1 -1
  321. package/dist/engine-answers.js +2 -1
  322. package/dist/engine-answers.js.map +1 -1
  323. package/dist/engine-client.d.ts +28 -0
  324. package/dist/engine-client.d.ts.map +1 -1
  325. package/dist/engine-client.js +4 -4
  326. package/dist/engine-client.js.map +1 -1
  327. package/dist/engine-columns.d.ts +26 -0
  328. package/dist/engine-columns.d.ts.map +1 -0
  329. package/dist/engine-columns.js +67 -0
  330. package/dist/engine-columns.js.map +1 -0
  331. package/dist/engine-floor.d.ts +35 -0
  332. package/dist/engine-floor.d.ts.map +1 -1
  333. package/dist/engine-floor.js +67 -0
  334. package/dist/engine-floor.js.map +1 -1
  335. package/dist/engine-ownership-gate.d.ts +11 -1
  336. package/dist/engine-ownership-gate.d.ts.map +1 -1
  337. package/dist/engine-ownership-gate.js +32 -0
  338. package/dist/engine-ownership-gate.js.map +1 -1
  339. package/dist/engine-push-output.d.ts +12 -4
  340. package/dist/engine-push-output.d.ts.map +1 -1
  341. package/dist/engine-push-output.js.map +1 -1
  342. package/dist/env-file.d.ts +36 -3
  343. package/dist/env-file.d.ts.map +1 -1
  344. package/dist/env-file.js +82 -11
  345. package/dist/env-file.js.map +1 -1
  346. package/dist/env-lines.d.ts +5 -2
  347. package/dist/env-lines.d.ts.map +1 -1
  348. package/dist/env-lines.js +18 -3
  349. package/dist/env-lines.js.map +1 -1
  350. package/dist/env-managed-record.d.ts +20 -0
  351. package/dist/env-managed-record.d.ts.map +1 -0
  352. package/dist/env-managed-record.js +56 -0
  353. package/dist/env-managed-record.js.map +1 -0
  354. package/dist/error-message.d.ts.map +1 -1
  355. package/dist/error-message.js +7 -3
  356. package/dist/error-message.js.map +1 -1
  357. package/dist/frontend-env.d.ts +3 -2
  358. package/dist/frontend-env.d.ts.map +1 -1
  359. package/dist/frontend-env.js +4 -5
  360. package/dist/frontend-env.js.map +1 -1
  361. package/dist/frontend-values-linked.d.ts +3 -0
  362. package/dist/frontend-values-linked.d.ts.map +1 -1
  363. package/dist/frontend-values-linked.js +3 -2
  364. package/dist/frontend-values-linked.js.map +1 -1
  365. package/dist/frontend-values.d.ts +2 -1
  366. package/dist/frontend-values.d.ts.map +1 -1
  367. package/dist/frontend-values.js +2 -1
  368. package/dist/frontend-values.js.map +1 -1
  369. package/dist/functions-context-refresh.d.ts.map +1 -1
  370. package/dist/functions-context-refresh.js +5 -2
  371. package/dist/functions-context-refresh.js.map +1 -1
  372. package/dist/functions-deno-types.d.ts +6 -0
  373. package/dist/functions-deno-types.d.ts.map +1 -1
  374. package/dist/functions-deno-types.js +43 -35
  375. package/dist/functions-deno-types.js.map +1 -1
  376. package/dist/functions-env-local.d.ts +7 -2
  377. package/dist/functions-env-local.d.ts.map +1 -1
  378. package/dist/functions-env-local.js +8 -3
  379. package/dist/functions-env-local.js.map +1 -1
  380. package/dist/functions-worker-files.d.ts.map +1 -1
  381. package/dist/functions-worker-files.js +2 -13
  382. package/dist/functions-worker-files.js.map +1 -1
  383. package/dist/generated/functions-worker-source.d.ts.map +1 -1
  384. package/dist/generated/functions-worker-source.js +6 -3
  385. package/dist/generated/functions-worker-source.js.map +1 -1
  386. package/dist/generated/release-images.d.ts +6 -6
  387. package/dist/generated/release-images.js +3 -3
  388. package/dist/generated-files-engine.d.ts +9 -0
  389. package/dist/generated-files-engine.d.ts.map +1 -1
  390. package/dist/generated-files-engine.js +23 -0
  391. package/dist/generated-files-engine.js.map +1 -1
  392. package/dist/gitignore.d.ts +29 -2
  393. package/dist/gitignore.d.ts.map +1 -1
  394. package/dist/gitignore.js +86 -21
  395. package/dist/gitignore.js.map +1 -1
  396. package/dist/hooks-generator.d.ts.map +1 -1
  397. package/dist/hooks-generator.js +32 -10
  398. package/dist/hooks-generator.js.map +1 -1
  399. package/dist/hooks-worker-reload.d.ts +18 -0
  400. package/dist/hooks-worker-reload.d.ts.map +1 -0
  401. package/dist/hooks-worker-reload.js +19 -0
  402. package/dist/hooks-worker-reload.js.map +1 -0
  403. package/dist/host-database.d.ts +6 -2
  404. package/dist/host-database.d.ts.map +1 -1
  405. package/dist/host-database.js +10 -2
  406. package/dist/host-database.js.map +1 -1
  407. package/dist/index.d.ts +1 -0
  408. package/dist/index.d.ts.map +1 -1
  409. package/dist/index.js.map +1 -1
  410. package/dist/init-dependency-versions.d.ts +2 -3
  411. package/dist/init-dependency-versions.d.ts.map +1 -1
  412. package/dist/init-dependency-versions.js +12 -9
  413. package/dist/init-dependency-versions.js.map +1 -1
  414. package/dist/init-example.d.ts.map +1 -1
  415. package/dist/init-example.js +13 -1
  416. package/dist/init-example.js.map +1 -1
  417. package/dist/init-expo-runtime-env.d.ts +25 -0
  418. package/dist/init-expo-runtime-env.d.ts.map +1 -0
  419. package/dist/init-expo-runtime-env.js +112 -0
  420. package/dist/init-expo-runtime-env.js.map +1 -0
  421. package/dist/init-next-runtime-env.d.ts +14 -1
  422. package/dist/init-next-runtime-env.d.ts.map +1 -1
  423. package/dist/init-next-runtime-env.js +116 -35
  424. package/dist/init-next-runtime-env.js.map +1 -1
  425. package/dist/init-package-json.d.ts +12 -3
  426. package/dist/init-package-json.d.ts.map +1 -1
  427. package/dist/init-package-json.js +35 -15
  428. package/dist/init-package-json.js.map +1 -1
  429. package/dist/init-port-registry.d.ts +19 -0
  430. package/dist/init-port-registry.d.ts.map +1 -0
  431. package/dist/init-port-registry.js +57 -0
  432. package/dist/init-port-registry.js.map +1 -0
  433. package/dist/init-project-detect.d.ts +20 -0
  434. package/dist/init-project-detect.d.ts.map +1 -1
  435. package/dist/init-project-detect.js +41 -8
  436. package/dist/init-project-detect.js.map +1 -1
  437. package/dist/init-setup-steps.d.ts +32 -4
  438. package/dist/init-setup-steps.d.ts.map +1 -1
  439. package/dist/init-setup-steps.js +114 -18
  440. package/dist/init-setup-steps.js.map +1 -1
  441. package/dist/init-vite-node.d.ts +21 -0
  442. package/dist/init-vite-node.d.ts.map +1 -0
  443. package/dist/init-vite-node.js +75 -0
  444. package/dist/init-vite-node.js.map +1 -0
  445. package/dist/jsx-first-child.d.ts +18 -0
  446. package/dist/jsx-first-child.d.ts.map +1 -0
  447. package/dist/jsx-first-child.js +53 -0
  448. package/dist/jsx-first-child.js.map +1 -0
  449. package/dist/keyspace-password-file.d.ts +46 -0
  450. package/dist/keyspace-password-file.d.ts.map +1 -0
  451. package/dist/keyspace-password-file.js +128 -0
  452. package/dist/keyspace-password-file.js.map +1 -0
  453. package/dist/keyspace-port.d.ts +14 -0
  454. package/dist/keyspace-port.d.ts.map +1 -0
  455. package/dist/keyspace-port.js +35 -0
  456. package/dist/keyspace-port.js.map +1 -0
  457. package/dist/kong-config.d.ts +6 -0
  458. package/dist/kong-config.d.ts.map +1 -1
  459. package/dist/kong-config.js +119 -20
  460. package/dist/kong-config.js.map +1 -1
  461. package/dist/link.d.ts +30 -0
  462. package/dist/link.d.ts.map +1 -1
  463. package/dist/link.js +70 -16
  464. package/dist/link.js.map +1 -1
  465. package/dist/local-gateway.d.ts +11 -3
  466. package/dist/local-gateway.d.ts.map +1 -1
  467. package/dist/local-gateway.js +16 -7
  468. package/dist/local-gateway.js.map +1 -1
  469. package/dist/local-secrets.d.ts +22 -0
  470. package/dist/local-secrets.d.ts.map +1 -1
  471. package/dist/local-secrets.js +29 -0
  472. package/dist/local-secrets.js.map +1 -1
  473. package/dist/local-stack-guard.d.ts +8 -0
  474. package/dist/local-stack-guard.d.ts.map +1 -1
  475. package/dist/local-stack-guard.js +44 -3
  476. package/dist/local-stack-guard.js.map +1 -1
  477. package/dist/local-stack.d.ts +2 -0
  478. package/dist/local-stack.d.ts.map +1 -1
  479. package/dist/local-stack.js +14 -8
  480. package/dist/local-stack.js.map +1 -1
  481. package/dist/local-storage.d.ts +3 -5
  482. package/dist/local-storage.d.ts.map +1 -1
  483. package/dist/local-storage.js +10 -10
  484. package/dist/local-storage.js.map +1 -1
  485. package/dist/mailer-autoconfirm.d.ts +29 -24
  486. package/dist/mailer-autoconfirm.d.ts.map +1 -1
  487. package/dist/mailer-autoconfirm.js +47 -43
  488. package/dist/mailer-autoconfirm.js.map +1 -1
  489. package/dist/mailer-env.d.ts +8 -1
  490. package/dist/mailer-env.d.ts.map +1 -1
  491. package/dist/mailer-env.js +52 -8
  492. package/dist/mailer-env.js.map +1 -1
  493. package/dist/model-hooks.d.ts +6 -4
  494. package/dist/model-hooks.d.ts.map +1 -1
  495. package/dist/model-hooks.js +14 -8
  496. package/dist/model-hooks.js.map +1 -1
  497. package/dist/model-versioning.d.ts +6 -0
  498. package/dist/model-versioning.d.ts.map +1 -1
  499. package/dist/model-versioning.js +12 -0
  500. package/dist/model-versioning.js.map +1 -1
  501. package/dist/native-dev-env.d.ts +38 -3
  502. package/dist/native-dev-env.d.ts.map +1 -1
  503. package/dist/native-dev-env.js +98 -7
  504. package/dist/native-dev-env.js.map +1 -1
  505. package/dist/native-keyspace.d.ts +31 -6
  506. package/dist/native-keyspace.d.ts.map +1 -1
  507. package/dist/native-keyspace.js +70 -20
  508. package/dist/native-keyspace.js.map +1 -1
  509. package/dist/native-leftover-postgres.d.ts +23 -0
  510. package/dist/native-leftover-postgres.d.ts.map +1 -0
  511. package/dist/native-leftover-postgres.js +55 -0
  512. package/dist/native-leftover-postgres.js.map +1 -0
  513. package/dist/native-leftover-services.d.ts +17 -0
  514. package/dist/native-leftover-services.d.ts.map +1 -0
  515. package/dist/native-leftover-services.js +93 -0
  516. package/dist/native-leftover-services.js.map +1 -0
  517. package/dist/native-pg-auth.d.ts.map +1 -1
  518. package/dist/native-pg-auth.js +2 -1
  519. package/dist/native-pg-auth.js.map +1 -1
  520. package/dist/native-port-lock.d.ts +37 -0
  521. package/dist/native-port-lock.d.ts.map +1 -0
  522. package/dist/native-port-lock.js +78 -0
  523. package/dist/native-port-lock.js.map +1 -0
  524. package/dist/native-realtime.d.ts +6 -3
  525. package/dist/native-realtime.d.ts.map +1 -1
  526. package/dist/native-realtime.js +65 -24
  527. package/dist/native-realtime.js.map +1 -1
  528. package/dist/native-roles-sql.d.ts.map +1 -1
  529. package/dist/native-roles-sql.js +2 -1
  530. package/dist/native-roles-sql.js.map +1 -1
  531. package/dist/native-stale-session.d.ts +17 -0
  532. package/dist/native-stale-session.d.ts.map +1 -0
  533. package/dist/native-stale-session.js +42 -0
  534. package/dist/native-stale-session.js.map +1 -0
  535. package/dist/native-storage-import.d.ts.map +1 -1
  536. package/dist/native-storage-import.js +6 -5
  537. package/dist/native-storage-import.js.map +1 -1
  538. package/dist/native-storage.d.ts +42 -7
  539. package/dist/native-storage.d.ts.map +1 -1
  540. package/dist/native-storage.js +196 -50
  541. package/dist/native-storage.js.map +1 -1
  542. package/dist/native-worker.d.ts +15 -0
  543. package/dist/native-worker.d.ts.map +1 -1
  544. package/dist/native-worker.js +26 -0
  545. package/dist/native-worker.js.map +1 -1
  546. package/dist/open-browser.d.ts +7 -0
  547. package/dist/open-browser.d.ts.map +1 -0
  548. package/dist/open-browser.js +26 -0
  549. package/dist/open-browser.js.map +1 -0
  550. package/dist/parent-watch.d.ts.map +1 -1
  551. package/dist/parent-watch.js +4 -8
  552. package/dist/parent-watch.js.map +1 -1
  553. package/dist/personal-access-token.d.ts +7 -0
  554. package/dist/personal-access-token.d.ts.map +1 -0
  555. package/dist/personal-access-token.js +11 -0
  556. package/dist/personal-access-token.js.map +1 -0
  557. package/dist/plan-sql.d.ts +30 -0
  558. package/dist/plan-sql.d.ts.map +1 -0
  559. package/dist/plan-sql.js +65 -0
  560. package/dist/plan-sql.js.map +1 -0
  561. package/dist/platform-settings-push.d.ts +15 -0
  562. package/dist/platform-settings-push.d.ts.map +1 -0
  563. package/dist/platform-settings-push.js +100 -0
  564. package/dist/platform-settings-push.js.map +1 -0
  565. package/dist/platform-settings.d.ts +81 -0
  566. package/dist/platform-settings.d.ts.map +1 -0
  567. package/dist/platform-settings.js +164 -0
  568. package/dist/platform-settings.js.map +1 -0
  569. package/dist/postgres-ctl.d.ts +45 -5
  570. package/dist/postgres-ctl.d.ts.map +1 -1
  571. package/dist/postgres-ctl.js +59 -21
  572. package/dist/postgres-ctl.js.map +1 -1
  573. package/dist/postgres-image.d.ts +27 -2
  574. package/dist/postgres-image.d.ts.map +1 -1
  575. package/dist/postgres-image.js +58 -13
  576. package/dist/postgres-image.js.map +1 -1
  577. package/dist/postgrest-release.d.ts +1 -1
  578. package/dist/postgrest-release.d.ts.map +1 -1
  579. package/dist/postgrest-release.js +3 -1
  580. package/dist/postgrest-release.js.map +1 -1
  581. package/dist/process-info.d.ts +14 -0
  582. package/dist/process-info.d.ts.map +1 -0
  583. package/dist/process-info.js +41 -0
  584. package/dist/process-info.js.map +1 -0
  585. package/dist/process-manager.d.ts +78 -4
  586. package/dist/process-manager.d.ts.map +1 -1
  587. package/dist/process-manager.js +128 -46
  588. package/dist/process-manager.js.map +1 -1
  589. package/dist/process-tree.d.ts +48 -0
  590. package/dist/process-tree.d.ts.map +1 -0
  591. package/dist/process-tree.js +141 -0
  592. package/dist/process-tree.js.map +1 -0
  593. package/dist/project-config.d.ts +121 -10
  594. package/dist/project-config.d.ts.map +1 -1
  595. package/dist/project-config.js +62 -1
  596. package/dist/project-config.js.map +1 -1
  597. package/dist/release-images.d.ts +21 -0
  598. package/dist/release-images.d.ts.map +1 -1
  599. package/dist/release-images.js +24 -0
  600. package/dist/release-images.js.map +1 -1
  601. package/dist/required-host-components.d.ts.map +1 -1
  602. package/dist/required-host-components.js +3 -5
  603. package/dist/required-host-components.js.map +1 -1
  604. package/dist/resolve-target.d.ts +42 -2
  605. package/dist/resolve-target.d.ts.map +1 -1
  606. package/dist/resolve-target.js +115 -21
  607. package/dist/resolve-target.js.map +1 -1
  608. package/dist/rest-cache-admin.d.ts +13 -0
  609. package/dist/rest-cache-admin.d.ts.map +1 -1
  610. package/dist/rest-cache-admin.js +36 -1
  611. package/dist/rest-cache-admin.js.map +1 -1
  612. package/dist/rest-ready.d.ts +6 -0
  613. package/dist/rest-ready.d.ts.map +1 -1
  614. package/dist/rest-ready.js +18 -2
  615. package/dist/rest-ready.js.map +1 -1
  616. package/dist/route-manifest.d.ts +24 -0
  617. package/dist/route-manifest.d.ts.map +1 -1
  618. package/dist/route-manifest.js +60 -2
  619. package/dist/route-manifest.js.map +1 -1
  620. package/dist/run-captured.d.ts +3 -1
  621. package/dist/run-captured.d.ts.map +1 -1
  622. package/dist/run-captured.js.map +1 -1
  623. package/dist/run-until-stopped.d.ts +3 -0
  624. package/dist/run-until-stopped.d.ts.map +1 -1
  625. package/dist/run-until-stopped.js +25 -11
  626. package/dist/run-until-stopped.js.map +1 -1
  627. package/dist/runtime-routes.d.ts +5 -0
  628. package/dist/runtime-routes.d.ts.map +1 -1
  629. package/dist/runtime-routes.js +10 -5
  630. package/dist/runtime-routes.js.map +1 -1
  631. package/dist/schema-ast-v2.d.ts +38 -0
  632. package/dist/schema-ast-v2.d.ts.map +1 -1
  633. package/dist/schema-ast-v2.js +2 -0
  634. package/dist/schema-ast-v2.js.map +1 -1
  635. package/dist/schema-reset.d.ts.map +1 -1
  636. package/dist/schema-reset.js +2 -0
  637. package/dist/schema-reset.js.map +1 -1
  638. package/dist/secret-sql.d.ts +13 -0
  639. package/dist/secret-sql.d.ts.map +1 -0
  640. package/dist/secret-sql.js +13 -0
  641. package/dist/secret-sql.js.map +1 -0
  642. package/dist/seed-default-export.d.ts +12 -0
  643. package/dist/seed-default-export.d.ts.map +1 -0
  644. package/dist/seed-default-export.js +44 -0
  645. package/dist/seed-default-export.js.map +1 -0
  646. package/dist/seed-ir.d.ts +8 -1
  647. package/dist/seed-ir.d.ts.map +1 -1
  648. package/dist/seed-ir.js +92 -6
  649. package/dist/seed-ir.js.map +1 -1
  650. package/dist/seed-prepare.d.ts +60 -0
  651. package/dist/seed-prepare.d.ts.map +1 -0
  652. package/dist/seed-prepare.js +115 -0
  653. package/dist/seed-prepare.js.map +1 -0
  654. package/dist/seed-remote.d.ts +22 -0
  655. package/dist/seed-remote.d.ts.map +1 -0
  656. package/dist/seed-remote.js +203 -0
  657. package/dist/seed-remote.js.map +1 -0
  658. package/dist/seed-report.d.ts +65 -0
  659. package/dist/seed-report.d.ts.map +1 -0
  660. package/dist/seed-report.js +98 -0
  661. package/dist/seed-report.js.map +1 -0
  662. package/dist/seed.d.ts +15 -2
  663. package/dist/seed.d.ts.map +1 -1
  664. package/dist/self-host-compose.d.ts +21 -1
  665. package/dist/self-host-compose.d.ts.map +1 -1
  666. package/dist/self-host-compose.js +349 -78
  667. package/dist/self-host-compose.js.map +1 -1
  668. package/dist/site-build-env.d.ts +31 -0
  669. package/dist/site-build-env.d.ts.map +1 -0
  670. package/dist/site-build-env.js +29 -0
  671. package/dist/site-build-env.js.map +1 -0
  672. package/dist/site-deploy.d.ts +52 -0
  673. package/dist/site-deploy.d.ts.map +1 -0
  674. package/dist/site-deploy.js +230 -0
  675. package/dist/site-deploy.js.map +1 -0
  676. package/dist/site-public-env.d.ts +67 -0
  677. package/dist/site-public-env.d.ts.map +1 -0
  678. package/dist/site-public-env.js +124 -0
  679. package/dist/site-public-env.js.map +1 -0
  680. package/dist/sso-admin.d.ts +15 -0
  681. package/dist/sso-admin.d.ts.map +1 -1
  682. package/dist/sso-admin.js +32 -9
  683. package/dist/sso-admin.js.map +1 -1
  684. package/dist/stack-exit-watch.d.ts +15 -0
  685. package/dist/stack-exit-watch.d.ts.map +1 -1
  686. package/dist/stack-exit-watch.js +41 -13
  687. package/dist/stack-exit-watch.js.map +1 -1
  688. package/dist/stack-folder.d.ts +28 -0
  689. package/dist/stack-folder.d.ts.map +1 -0
  690. package/dist/stack-folder.js +123 -0
  691. package/dist/stack-folder.js.map +1 -0
  692. package/dist/stack-running.d.ts +13 -0
  693. package/dist/stack-running.d.ts.map +1 -0
  694. package/dist/stack-running.js +44 -0
  695. package/dist/stack-running.js.map +1 -0
  696. package/dist/stack-setting-warnings.d.ts +8 -1
  697. package/dist/stack-setting-warnings.d.ts.map +1 -1
  698. package/dist/stack-setting-warnings.js +21 -1
  699. package/dist/stack-setting-warnings.js.map +1 -1
  700. package/dist/storage-provision.d.ts +12 -2
  701. package/dist/storage-provision.d.ts.map +1 -1
  702. package/dist/storage-provision.js +36 -11
  703. package/dist/storage-provision.js.map +1 -1
  704. package/dist/studio-admin-roles.d.ts +4 -4
  705. package/dist/studio-admin-roles.d.ts.map +1 -1
  706. package/dist/studio-admin-roles.js +6 -4
  707. package/dist/studio-admin-roles.js.map +1 -1
  708. package/dist/target-client.d.ts +13 -1
  709. package/dist/target-client.d.ts.map +1 -1
  710. package/dist/target-client.js +83 -17
  711. package/dist/target-client.js.map +1 -1
  712. package/dist/target-request.d.ts +5 -0
  713. package/dist/target-request.d.ts.map +1 -1
  714. package/dist/target-request.js +11 -2
  715. package/dist/target-request.js.map +1 -1
  716. package/dist/type-extractor.d.ts.map +1 -1
  717. package/dist/type-extractor.js +102 -10
  718. package/dist/type-extractor.js.map +1 -1
  719. package/dist/ui/clack-api.d.ts +2 -1
  720. package/dist/ui/clack-api.d.ts.map +1 -1
  721. package/dist/ui/clack-api.js +4 -4
  722. package/dist/ui/clack-api.js.map +1 -1
  723. package/dist/ui/clack.d.ts.map +1 -1
  724. package/dist/ui/clack.js +5 -2
  725. package/dist/ui/clack.js.map +1 -1
  726. package/dist/ui/dev/DevReadyPanelView.js +1 -1
  727. package/dist/ui/dev/DevReadyPanelView.js.map +1 -1
  728. package/dist/valkey-sidecar.d.ts +34 -13
  729. package/dist/valkey-sidecar.d.ts.map +1 -1
  730. package/dist/valkey-sidecar.js +65 -39
  731. package/dist/valkey-sidecar.js.map +1 -1
  732. package/dist/windows-processes.d.ts +7 -0
  733. package/dist/windows-processes.d.ts.map +1 -0
  734. package/dist/windows-processes.js +31 -0
  735. package/dist/windows-processes.js.map +1 -0
  736. package/dist/write-if-changed.d.ts +12 -0
  737. package/dist/write-if-changed.d.ts.map +1 -0
  738. package/dist/write-if-changed.js +32 -0
  739. package/dist/write-if-changed.js.map +1 -0
  740. package/package.json +7 -5
  741. package/releases/deno/VERSION +1 -1
  742. package/dist/commands/deploy-types.d.ts +0 -14
  743. package/dist/commands/deploy-types.d.ts.map +0 -1
  744. package/dist/commands/deploy-types.js +0 -38
  745. package/dist/commands/deploy-types.js.map +0 -1
  746. package/dist/systemd.d.ts +0 -26
  747. package/dist/systemd.d.ts.map +0 -1
  748. package/dist/systemd.js +0 -117
  749. package/dist/systemd.js.map +0 -1
@@ -1,12 +1,15 @@
1
1
  // Generated from packages/functions-worker/*.ts by scripts/functions-worker-source.mjs. Do not
2
2
  // edit: the CLI's build regenerates it, and native dev and `functions serve` run these files.
3
3
  export const FUNCTIONS_WORKER_SOURCE = {
4
- "deno.d.ts": "/**\n * Ambient types for IDE / tsserver (runtime is Deno in Docker).\n * Kept in sync with `@supatype/cli` edge-function ambient (`packages/cli/deno.d.ts`).\n */\n\ninterface DenoEnv {\n get(key: string): string | undefined\n set(key: string, value: string): void\n delete(key: string): void\n has(key: string): boolean\n toObject(): { [key: string]: string }\n}\n\ndeclare namespace Deno {\n const env: DenoEnv\n\n namespace errors {\n class NotFound extends Error {}\n class PermissionDenied extends Error {}\n }\n\n interface DirEntry {\n name: string\n isFile: boolean\n isDirectory: boolean\n isSymlink: boolean\n }\n\n interface FileInfo {\n isFile: boolean\n isDirectory: boolean\n isSymlink: boolean\n size: number\n mtime: Date | null\n }\n\n function readDir(path: string): AsyncIterable<DirEntry>\n function stat(path: string): Promise<FileInfo>\n function utime(path: string, atime: Date | number, mtime: Date | number): Promise<void>\n function readTextFile(path: string | URL): Promise<string>\n\n /** What `serve` returns: stopping it (stop.ts) waits for the requests in flight. */\n interface HttpServer {\n /** Stops taking connections; resolves once the requests in flight have finished. */\n shutdown(): Promise<void>\n /** Resolves when the server has closed. */\n readonly finished: Promise<void>\n }\n\n function serve(\n options: { port: number; hostname?: string; onListen?: (params: { hostname: string; port: number }) => void },\n handler: (req: Request) => Response | Promise<Response>,\n ): HttpServer\n\n // What stop.ts uses to exit on a stop signal.\n const build: { readonly os: \"darwin\" | \"linux\" | \"android\" | \"windows\" | \"freebsd\" | \"netbsd\" | \"aix\" | \"solaris\" | \"illumos\" }\n function addSignalListener(signal: \"SIGTERM\" | \"SIGINT\", handler: () => void): void\n function exit(code?: number): never\n\n // What tests/ uses to start the worker as a child process and give it a functions directory.\n function test(name: string, fn: () => void | Promise<void>): void\n function execPath(): string\n function makeTempDir(options?: { prefix?: string }): Promise<string>\n function makeTempFile(options?: { prefix?: string; suffix?: string }): Promise<string>\n function mkdir(path: string, options?: { recursive?: boolean }): Promise<void>\n function writeTextFile(path: string, data: string): Promise<void>\n function remove(path: string, options?: { recursive?: boolean }): Promise<void>\n\n interface CommandOptions {\n args?: string[]\n env?: Record<string, string>\n clearEnv?: boolean\n stdout?: \"piped\" | \"inherit\" | \"null\"\n stderr?: \"piped\" | \"inherit\" | \"null\"\n }\n\n interface ChildProcess {\n readonly stdout: ReadableStream<Uint8Array>\n readonly status: Promise<{ success: boolean; code: number }>\n kill(signal?: \"SIGTERM\" | \"SIGKILL\"): void\n }\n\n class Command {\n constructor(command: string, options?: CommandOptions)\n spawn(): ChildProcess\n }\n}\n\n/**\n * The slice of Node's `async_hooks` the worker uses. Deno provides the module at runtime; tsc has no\n * `@types/node` here, and without this the import resolved to nothing and `store` was untyped.\n */\ndeclare module \"node:async_hooks\" {\n export class AsyncLocalStorage<T> {\n getStore(): T | undefined\n run<R>(store: T, callback: () => R): R\n }\n}\n",
4
+ "deno.d.ts": "/**\n * Ambient types for IDE / tsserver (runtime is Deno in Docker).\n * Kept in sync with `@supatype/cli` edge-function ambient (`packages/cli/deno.d.ts`).\n */\n\ninterface DenoEnv {\n get(key: string): string | undefined\n set(key: string, value: string): void\n delete(key: string): void\n has(key: string): boolean\n toObject(): { [key: string]: string }\n}\n\ndeclare namespace Deno {\n const env: DenoEnv\n\n namespace errors {\n class NotFound extends Error {}\n class PermissionDenied extends Error {}\n }\n\n interface DirEntry {\n name: string\n isFile: boolean\n isDirectory: boolean\n isSymlink: boolean\n }\n\n interface FileInfo {\n isFile: boolean\n isDirectory: boolean\n isSymlink: boolean\n size: number\n mtime: Date | null\n }\n\n function readDir(path: string): AsyncIterable<DirEntry>\n function stat(path: string): Promise<FileInfo>\n function utime(path: string, atime: Date | number, mtime: Date | number): Promise<void>\n function realPath(path: string): Promise<string>\n function symlink(target: string, path: string, options?: { type?: \"dir\" | \"file\" }): Promise<void>\n function readTextFile(path: string | URL): Promise<string>\n\n /** What `serve` returns: stopping it (stop.ts) waits for the requests in flight. */\n interface HttpServer {\n /** Stops taking connections; resolves once the requests in flight have finished. */\n shutdown(): Promise<void>\n /** Resolves when the server has closed. */\n readonly finished: Promise<void>\n /** Where it listens, which is how a test finds a port it asked for with 0. */\n readonly addr: { hostname: string; port: number }\n }\n\n function serve(\n options: { port: number; hostname?: string; onListen?: (params: { hostname: string; port: number }) => void },\n handler: (req: Request) => Response | Promise<Response>,\n ): HttpServer\n\n // What stop.ts uses to exit on a stop signal.\n const build: { readonly os: \"darwin\" | \"linux\" | \"android\" | \"windows\" | \"freebsd\" | \"netbsd\" | \"aix\" | \"solaris\" | \"illumos\" }\n function addSignalListener(signal: \"SIGTERM\" | \"SIGINT\", handler: () => void): void\n function exit(code?: number): never\n\n // What tests/ uses to start the worker as a child process and give it a functions directory.\n function test(name: string, fn: () => void | Promise<void>): void\n function execPath(): string\n function makeTempDir(options?: { prefix?: string }): Promise<string>\n function makeTempFile(options?: { prefix?: string; suffix?: string }): Promise<string>\n function mkdir(path: string, options?: { recursive?: boolean }): Promise<void>\n function writeTextFile(path: string, data: string): Promise<void>\n function remove(path: string, options?: { recursive?: boolean }): Promise<void>\n\n interface CommandOptions {\n args?: string[]\n env?: Record<string, string>\n clearEnv?: boolean\n stdout?: \"piped\" | \"inherit\" | \"null\"\n stderr?: \"piped\" | \"inherit\" | \"null\"\n }\n\n interface ChildProcess {\n readonly stdout: ReadableStream<Uint8Array>\n readonly stderr: ReadableStream<Uint8Array>\n readonly status: Promise<{ success: boolean; code: number }>\n kill(signal?: \"SIGTERM\" | \"SIGKILL\"): void\n }\n\n class Command {\n constructor(command: string, options?: CommandOptions)\n spawn(): ChildProcess\n }\n}\n\n/** The slice of `@std/assert` the tests use; Deno resolves the specifier at runtime and tsc cannot. */\ndeclare module \"jsr:@std/assert@1\" {\n export function assertEquals(actual: unknown, expected: unknown, msg?: string): void\n}\n\n/**\n * The slice of Node's `async_hooks` the worker uses. Deno provides the module at runtime; tsc has no\n * `@types/node` here, and without this the import resolved to nothing and `store` was untyped.\n */\ndeclare module \"node:async_hooks\" {\n export class AsyncLocalStorage<T> {\n getStore(): T | undefined\n run<R>(store: T, callback: () => R): R\n }\n}\n",
5
+ "discover.ts": "/**\n * Finding the functions under a root directory.\n *\n * Kept out of main.ts, which starts a server when imported, so a test can call it on a temporary\n * directory.\n */\n\nimport { FUNCTION_ENTRY_FILE, functionRouteName } from \"./routes.ts\"\n\nexport interface DiscoveredRoute {\n name: string\n entrypoint: string\n}\n\nfunction normalize(path: string): string {\n return path.replace(/\\\\/g, \"/\").replace(/\\/+$/, \"\")\n}\n\nfunction isInside(root: string, path: string): boolean {\n const base = normalize(root)\n const target = normalize(path)\n return target === base || target.startsWith(`${base}/`)\n}\n\n/**\n * The real path of `path` when it stays inside `realRoot`, otherwise undefined.\n *\n * A Kubernetes ConfigMap volume makes every entry a symlink (`name` -> `..data/name`, `..data` ->\n * `..<timestamp>`), so the scan has to follow links. Following them blindly would let a link\n * planted in the functions directory hand the worker any file it can read, so a target that\n * resolves outside the root is refused. A link loop, a dangling link and an unreadable target make\n * `realPath` throw, and all three mean \"not a function here\".\n */\nasync function contained(realRoot: string, path: string): Promise<string | undefined> {\n try {\n const real = await Deno.realPath(path)\n return isInside(realRoot, real) ? real : undefined\n } catch {\n return undefined\n }\n}\n\nasync function entryKind(path: string): Promise<\"dir\" | \"file\" | undefined> {\n try {\n const info = await Deno.stat(path)\n return info.isDirectory ? \"dir\" : info.isFile ? \"file\" : undefined\n } catch {\n return undefined\n }\n}\n\nasync function routeFor(realRoot: string, root: string, entry: string): Promise<DiscoveredRoute | undefined> {\n const fullPath = `${root}/${entry}`\n if ((await contained(realRoot, fullPath)) === undefined) return undefined\n const kind = await entryKind(fullPath)\n if (kind === undefined) return undefined\n // routes.ts is the rule a self-hosted control plane lists functions by too.\n const name = functionRouteName(entry, kind === \"dir\" ? \"directory\" : \"file\")\n if (name === undefined) return undefined\n if (kind === \"file\") return { name, entrypoint: fullPath }\n const entrypoint = `${fullPath}/${FUNCTION_ENTRY_FILE}`\n // A directory with no entry module is not a route.\n return (await contained(realRoot, entrypoint)) === undefined ? undefined : { name, entrypoint }\n}\n\nexport async function discoverRoutes(root: string, single?: string): Promise<DiscoveredRoute[]> {\n const out: DiscoveredRoute[] = []\n\n // The catch has to wrap the *iteration*: `Deno.readDir` returns its iterable without touching the\n // filesystem, so a missing directory raises NotFound on the first `next()`, not here. A root that\n // does not exist is ordinary, a project with functions but no hooks has no hooks directory, and\n // letting it throw would fail startup and take that project's working functions down with it.\n try {\n const realRoot = await Deno.realPath(root)\n for await (const entry of Deno.readDir(root)) {\n // Hidden entries include the `..data` and `..<timestamp>` a ConfigMap mount adds beside the\n // links; both hold the same functions the links already reach, so loading them doubles every one.\n if (entry.name.startsWith(\"_\") || entry.name.startsWith(\".\")) continue\n // A worker pinned to one route reads the filesystem for that entry only: `<name>` or `<name>.ts`.\n if (single && entry.name !== single && entry.name !== `${single}.ts`) continue\n const route = await routeFor(realRoot, root, entry.name)\n if (route !== undefined && (!single || route.name === single)) out.push(route)\n }\n } catch (err) {\n if (!(err instanceof Deno.errors.NotFound)) throw err\n }\n\n return out.sort((a, b) => a.name.localeCompare(b.name))\n}\n",
5
6
  "dotenv.ts": "// Generated from packages/cli/src/dotenv-parse.ts by scripts/functions-worker-source.mjs. Do not\n// edit: change that file and run the script, so the CLI and the worker read .env files alike.\n/**\n * The dotenv parser: one for every reader of a `.env` file, the CLI's and the functions worker's.\n *\n * No imports and no runtime APIs, so the same file runs under Node and Deno. The functions worker\n * carries an exact copy (packages/functions-worker/dotenv.ts), written from this one by\n * scripts/functions-worker-source.mjs and checked in CI, so a function's `ctx.env` reads a value\n * the way the CLI and compose do.\n */\n\n/** `KEY` and the text after its `=` for an assignment line, or null for anything else. */\nexport function splitAssignment(line: string): { key: string; rest: string } | null {\n const trimmed = line.trim().replace(/^export\\s+/, \"\")\n if (trimmed.startsWith(\"#\")) return null\n const eq = trimmed.indexOf(\"=\")\n if (eq <= 0) return null\n const key = trimmed.slice(0, eq).trim()\n return /^[A-Za-z_][A-Za-z0-9_]*$/.test(key) ? { key, rest: trimmed.slice(eq + 1) } : null\n}\n\n/** Index of the quote closing `value`'s opening one, skipping escaped quotes, or -1. */\nfunction closingQuote(value: string, quote: string): number {\n for (let i = 1; i < value.length; i++) {\n if (value[i] === quote && value[i - 1] !== \"\\\\\") return i\n }\n return -1\n}\n\n/**\n * The value of one assignment, read the way Docker Compose's dotenv parser reads it.\n *\n * A quoted value runs to its closing quote and keeps any `#` inside; text after the quote is\n * ignored. An unquoted value ends at the first space followed by `#`, and trailing whitespace is\n * dropped, so `KEY=x # note` is `x` while `KEY=x#y` is `x#y`. Reading ` # note` into the value\n * signed tokens with a secret the stack, reading the same line through compose, did not have.\n */\nfunction envValueOf(rest: string): string {\n const value = rest.trim()\n const quote = value[0]\n if (quote === '\"' || quote === \"'\") {\n const close = closingQuote(value, quote)\n if (close > 0) return value.slice(1, close)\n }\n const comment = value.indexOf(\" #\")\n return (comment === -1 ? value : value.slice(0, comment)).trimEnd()\n}\n\n/**\n * Parse `.env` text into key/value pairs, the one parser every reader of `.env` goes through.\n *\n * Follows Compose on what it shares with it: `#` comments, an optional `export `, quotes, inline\n * comments, and the last assignment of a key winning. Not interpolation or escape sequences in\n * double quotes, which nothing the CLI writes or reads relies on.\n */\nexport function parseEnvText(text: string): Record<string, string> {\n const out: Record<string, string> = {}\n for (const line of text.split(/\\r?\\n/)) {\n const assignment = splitAssignment(line)\n if (assignment !== null) out[assignment.key] = envValueOf(assignment.rest)\n }\n return out\n}\n",
6
- "invocation.ts": "import { AsyncLocalStorage } from \"node:async_hooks\"\n\n/**\n * What a function is told about the call it is serving, and the store that carries it.\n *\n * # Why this exists at all\n *\n * The worker used to deliver this through `Deno.env`: it set `SUPATYPE_SERVICE_ROLE_KEY` and the\n * rest before calling the handler and restored them afterwards. `Deno.env` is process-global, so\n * two concurrent invocations would read each other's values, a service-role key granted to one\n * route and not the other among them. The defence was a lock held across the *whole* handler, so the\n * worker executed exactly one invocation at a time.\n *\n * That is a throughput property nobody chose: a function waiting two seconds on a third-party API\n * blocked every other function in the project for two seconds, and on cloud there is one worker per\n * project. It was invisible because `supatype dev` generates a router with the same lock, so local\n * behaved exactly like production.\n *\n * Nothing per-invocation goes into the environment now. It is passed to the handler as a second\n * argument and carried here for the things a handler cannot be handed directly, so there is no\n * global to protect and no reason to serialise.\n *\n * # What is *not* here\n *\n * `SUPATYPE_URL`, `SUPATYPE_ANON_KEY` and the other invariants. Those are set once by compose or by\n * the deployment and never differ between invocations, so they stay in the environment where they\n * already are. The old code read each one out of the environment and set it straight back, which\n * looked like scoping and achieved nothing.\n */\nexport interface FunctionContext {\n /** Unique to this invocation. Every log line it writes carries the same value. */\n readonly executionId: string\n /** The function or hook route being served. */\n readonly functionName: string\n /**\n * The project's API base URL, reachable from inside this container: for calling the API from the\n * function. Under compose it is `http://kong:8000`, a name nothing outside the stack resolves.\n */\n readonly url: string\n /**\n * The project's public address, the gateway URL a browser or an app uses: for links you give to\n * people (an email, a redirect, a URL in a response). Falls back to `url` when the deployment did\n * not set `SUPATYPE_PUBLIC_URL`, and the worker warns once at start when it does.\n */\n readonly publicUrl: string\n readonly anonKey: string\n /**\n * Present only for a route the project granted it.\n *\n * Withheld from the process environment before any handler is imported, so a function that was\n * not granted it cannot reach it by reading `Deno.env` either.\n */\n readonly serviceRoleKey?: string\n /**\n * A raw Postgres connection URL. Off by default: present only when the operator sets\n * `SUPATYPE_FUNCTIONS_DB_URL`, which compose hands this worker as `SUPATYPE_DB_URL` (and joins it\n * to the `functions-db` network when the URL names the stack's `db`).\n *\n * It connects as whatever role the URL names and is not a request through the API, so row rules\n * and field masking do not apply to it. The operator should give it a least-privilege role\n * granted only what the functions need, never the admin URL. A credential: never returned or\n * logged.\n */\n readonly dbUrl?: string\n readonly region: string\n /**\n * Values from the functions directory's `.env.local` (or `SUPATYPE_SHARED_ENV_FILE`), then those\n * `functions env set` gave a self-hosted project (`SUPATYPE_FUNCTION_ENV_FILE`), then\n * `.env.<function>.local`, which wins. Per route, and read again on every call.\n *\n * They are here, never in `Deno.env`: that is the worker's one process environment, shared by\n * every call running at once, so a value put there for one function would reach every other.\n */\n readonly env: Readonly<Record<string, string>>\n}\n\n/** The parts the worker needs internally but a handler has no use for. */\ninterface InvocationStore {\n readonly context: FunctionContext\n /**\n * The hook-depth header to carry onto outbound calls, when this invocation is a hook.\n *\n * Here rather than patched onto `globalThis.fetch` per call. That patch was the second global\n * mutation the lock was protecting: two concurrent hooks would patch over each other, and the\n * first to finish would restore the other's patch.\n */\n readonly hookDepth: string | null\n}\n\nconst store = new AsyncLocalStorage<InvocationStore>()\n\n/** Run an invocation with its context available to everything it calls. */\nexport function runInvocation<T>(\n context: FunctionContext,\n hookDepth: string | null,\n run: () => Promise<T>,\n): Promise<T> {\n return store.run({ context, hookDepth }, run)\n}\n\n/** The invocation being served on this call stack, or undefined outside one. */\nexport function currentInvocation(): FunctionContext | undefined {\n return store.getStore()?.context\n}\n\n/** The hook depth to propagate, or null when this is not a hook call. */\nexport function currentHookDepth(): string | null {\n return store.getStore()?.hookDepth ?? null\n}\n",
7
+ "env-allowlist.ts": "/**\n * The process environment function code may see, and the scrub that enforces it.\n *\n * `Deno.env` is the worker's one process environment, and a function imported here reads it. Native\n * `supatype dev` started the worker with the server's whole environment, which held the stack's JWT\n * secret, the database URL and everything in the developer's shell (e2e 2026-11-21, RB-2). Deleting\n * the variables off this list before the first function is imported means a launcher that passes\n * too much no longer decides what a function can read. The server applies the same list when it\n * starts Deno (supatype-auth `internal/deno/allowlist.go`), so the two are kept in step by hand.\n *\n * A function's own values arrive in `ctx.env` from the env files, never through here.\n */\n\n/** What Deno itself and the operating system need to run, fetch and resolve modules. */\nconst RUNTIME_NAMES = [\n \"PATH\", \"PATHEXT\", \"HOME\", \"USER\", \"USERNAME\", \"LOGNAME\", \"TMPDIR\", \"TEMP\", \"TMP\", \"TZ\", \"LANG\",\n \"LC_ALL\", \"LC_CTYPE\", \"XDG_CACHE_HOME\", \"XDG_CONFIG_HOME\", \"NO_COLOR\",\n // Windows: the profile and cache directories, and what its networking and process APIs read.\n \"USERPROFILE\", \"APPDATA\", \"LOCALAPPDATA\", \"SYSTEMROOT\", \"WINDIR\", \"SYSTEMDRIVE\", \"COMSPEC\",\n \"PROGRAMDATA\", \"HOMEDRIVE\", \"HOMEPATH\",\n // Deno honours these for fetch and for npm: and jsr: imports.\n \"HTTP_PROXY\", \"HTTPS_PROXY\", \"NO_PROXY\", \"NPM_CONFIG_REGISTRY\",\n]\n\n/** What this worker reads (main.ts, logging.ts, stop.ts), and what it hands a function as ctx fields. */\nconst WORKER_NAMES = [\n \"PORT\", \"SUPATYPE_FUNCTIONS_ROOT\", \"SUPATYPE_DENO_FUNCTIONS_DIR\", \"SUPATYPE_HOOKS_ROOT\",\n \"SUPATYPE_FUNCTION_NAME\", \"SUPATYPE_FUNCTIONS_HOST\", \"SUPATYPE_FUNCTIONS_DRAIN_MS\",\n \"SUPATYPE_SERVICE_ROLE_ROUTES\", \"SUPATYPE_SERVICE_ROLE_ROUTES_FILE\", \"SUPATYPE_SERVICE_ROLE_KEY_FILE\",\n \"SUPATYPE_MANIFEST_PATH\", \"SUPATYPE_SHARED_ENV_FILE\", \"SUPATYPE_FUNCTION_ENV_FILE\",\n \"SUPATYPE_LOG_TAIL_BUFFER\", \"SUPATYPE_PROJECT_REF\", \"SUPATYPE_MANAGED_PROJECT_REF\",\n \"DEDICATED_PROJECT_REF\", \"SUPATYPE_URL\", \"SUPATYPE_INTERNAL_URL\", \"SUPATYPE_PUBLIC_URL\",\n \"SUPATYPE_ANON_KEY\", \"SUPATYPE_REGION\", \"SUPATYPE_DB_URL\",\n]\n\n/**\n * What self-host compose lists for the worker container on purpose, and documents as passed to it\n * (self-hosting/configuration.mdx). Only a deployment that names them sets them.\n */\nconst DEPLOYMENT_NAMES = [\"STRIPE_SECRET_KEY\", \"STRIPE_WEBHOOK_SECRET\", \"SITE_URL\"]\n\n/** Deno's own settings: its cache directory, certificate store and registry tokens. */\nconst ALLOWED_PREFIXES = [\"DENO_\"]\n\nconst ALLOWED_NAMES = new Set([...RUNTIME_NAMES, ...WORKER_NAMES, ...DEPLOYMENT_NAMES])\n\n/**\n * Whether function code may see `name`. Case-insensitive: Windows spells `PATH` as `Path`, and its\n * environment does not tell the two apart.\n */\nexport function envNameAllowed(name: string): boolean {\n const upper = name.toUpperCase()\n return ALLOWED_NAMES.has(upper) || ALLOWED_PREFIXES.some((prefix) => upper.startsWith(prefix))\n}\n\n/**\n * Whether Deno can delete `name`. Windows keeps each drive's working directory as a hidden `=D:`\n * variable, which `toObject` lists and `delete` refuses (\"Key contains invalid characters\"), so\n * trying stopped the worker starting. It holds a path, never a secret.\n */\nfunction deletable(name: string): boolean {\n return name !== \"\" && !name.includes(\"=\") && !name.includes(\"\\0\")\n}\n\n/** Deletes every variable off the allowlist from this process's environment. */\nexport function scrubProcessEnv(): void {\n for (const name of Object.keys(Deno.env.toObject())) {\n if (deletable(name) && !envNameAllowed(name)) Deno.env.delete(name)\n }\n}\n",
8
+ "invocation.ts": "import { AsyncLocalStorage } from \"node:async_hooks\"\n\n/**\n * What a function is told about the call it is serving, and the store that carries it.\n *\n * # Why this exists at all\n *\n * The worker used to deliver this through `Deno.env`: it set `SUPATYPE_SERVICE_ROLE_KEY` and the\n * rest before calling the handler and restored them afterwards. `Deno.env` is process-global, so\n * two concurrent invocations would read each other's values, a service-role key granted to one\n * route and not the other among them. The defence was a lock held across the *whole* handler, so the\n * worker executed exactly one invocation at a time.\n *\n * That is a throughput property nobody chose: a function waiting two seconds on a third-party API\n * blocked every other function in the project for two seconds, and on cloud there is one worker per\n * project. It was invisible because `supatype dev` generates a router with the same lock, so local\n * behaved exactly like production.\n *\n * Nothing per-invocation goes into the environment now. It is passed to the handler as a second\n * argument and carried here for the things a handler cannot be handed directly, so there is no\n * global to protect and no reason to serialise.\n *\n * # What is *not* here\n *\n * `SUPATYPE_URL`, `SUPATYPE_ANON_KEY` and the other invariants. Those are set once by compose or by\n * the deployment and never differ between invocations, so they stay in the environment where they\n * already are. The old code read each one out of the environment and set it straight back, which\n * looked like scoping and achieved nothing.\n */\nexport interface FunctionContext {\n /** Unique to this invocation. Every log line it writes carries the same value. */\n readonly executionId: string\n /** The function or hook route being served. */\n readonly functionName: string\n /**\n * The project's API base URL, reachable from inside this container: for calling the API from the\n * function. Under compose it is `http://kong:8100`, Kong's worker listener, a name nothing outside the stack resolves.\n */\n readonly url: string\n /**\n * The project's public address, the gateway URL a browser or an app uses: for links you give to\n * people (an email, a redirect, a URL in a response). Falls back to `url` when the deployment did\n * not set `SUPATYPE_PUBLIC_URL`, and the worker warns once at start when it does.\n */\n readonly publicUrl: string\n readonly anonKey: string\n /**\n * Present only for a route the project granted it.\n *\n * Withheld from the process environment before any handler is imported, so a function that was\n * not granted it cannot reach it by reading `Deno.env` either.\n */\n readonly serviceRoleKey?: string\n /**\n * A raw Postgres connection URL. Off by default: present only when the operator sets\n * `SUPATYPE_FUNCTIONS_DB_URL`, which compose hands this worker as `SUPATYPE_DB_URL` (and joins it\n * to the `functions-db` network when the URL names the stack's `db`).\n *\n * It connects as whatever role the URL names and is not a request through the API, so model\n * hooks do not run. Row rules and field masking apply for that role: a superuser or BYPASSRLS\n * role (the admin role, service_role) skips both. The operator should give it a least-privilege\n * login role that is neither, granted only what the functions need, never the admin URL. A\n * credential: never returned or logged.\n */\n readonly dbUrl?: string\n readonly region: string\n /**\n * Values from the functions directory's `.env.local` (or `SUPATYPE_SHARED_ENV_FILE`), then those\n * `functions env set` gave a self-hosted project (`SUPATYPE_FUNCTION_ENV_FILE`), then\n * `.env.<function>.local`, then the function's own managed values (`fn.<function>.json` beside the managed\n * file, which Supatype Cloud writes), which win over all of those. Per route, and read again on every call.\n *\n * They are here, never in `Deno.env`: that is the worker's one process environment, shared by\n * every call running at once, so a value put there for one function would reach every other.\n */\n readonly env: Readonly<Record<string, string>>\n}\n\n/**\n * What the request that started an invocation says, which its calls back into the stack carry on.\n *\n * Here rather than patched onto `globalThis.fetch` per call. That patch was the second global\n * mutation the lock was protecting: two concurrent hooks would patch over each other, and the\n * first to finish would restore the other's patch.\n */\nexport interface InboundCall {\n /** The hook-depth header to carry onto outbound calls, when this invocation is a hook. */\n readonly hookDepth: string | null\n /** The end user's address (`St-Forwarded-For`, else `X-Real-IP`), or null when the request had none. */\n readonly clientAddress: string | null\n}\n\n/** The parts the worker needs internally but a handler has no use for. */\ninterface InvocationStore extends InboundCall {\n readonly context: FunctionContext\n}\n\nconst store = new AsyncLocalStorage<InvocationStore>()\n\n/** Run an invocation with its context available to everything it calls. */\nexport function runInvocation<T>(\n context: FunctionContext,\n inbound: InboundCall,\n run: () => Promise<T>,\n): Promise<T> {\n return store.run({ context, ...inbound }, run)\n}\n\n/** The invocation being served on this call stack, or undefined outside one. */\nexport function currentInvocation(): FunctionContext | undefined {\n return store.getStore()?.context\n}\n\n/** What the request being served says, or undefined outside an invocation. */\nexport function currentCall(): InboundCall | undefined {\n const current = store.getStore()\n return current === undefined ? undefined : { hookDepth: current.hookDepth, clientAddress: current.clientAddress }\n}\n",
7
9
  "logging.ts": "import { currentInvocation } from \"./invocation.ts\"\n\n/**\n * Structured invocation logging, and a live tail over it.\n *\n * # Why structured, and why this exact shape\n *\n * The worker used to write `GET /functions/v1/foo → 200 (12ms)` to its own stdout and nothing else.\n * On cloud, `infra/k8s/platform/logging.yaml` runs Promtail into Loki with a pipeline that parses\n * each line as JSON and labels on `project_ref`, `service` and `level`, taking the timestamp from a\n * `timestamp` field in Go's `2006-01-02T15:04:05.000Z` layout. A plain-text line survives none of\n * that: it is collected, matches no expression, and is indexed under no project.\n *\n * So the fields below are not a taste; they are the contract that pipeline already expects.\n * `toISOString()` produces exactly three fractional digits and a `Z`, which is that layout.\n *\n * # Why a tail rather than a store\n *\n * Cloud has Loki, with retention per tier. Self-host has eleven services and no log store, and\n * adding one changes the footprint of every self-hosted deployment, so for release the self-host\n * answer is a live tail: attach, see what happens while attached, detach. Nothing is written down,\n * nothing lands in the project's own Postgres, and no service is added.\n *\n * The ring buffer exists only so that attaching does not start from an empty screen.\n *\n * # Why the context comes from AsyncLocalStorage\n *\n * `console` is global and invocations now genuinely run concurrently, so a captured line has to be\n * attributed to the invocation that wrote it rather than to whichever one happens to be current. A\n * module-level \"current request\" would mis-attribute every interleaved line.\n *\n * The store is `invocation.ts`, shared with the context a handler is passed, so a log line and the\n * function that wrote it cannot disagree about which call they belong to.\n */\n\n/** What every line carries, whether the worker wrote it or a function did. */\nexport interface LogLine {\n timestamp: string\n level: \"debug\" | \"info\" | \"warn\" | \"error\"\n service: \"functions-worker\"\n project_ref: string\n /** The invocation, or absent for a line the worker wrote outside one. */\n request_id?: string\n /** The function or hook route, when there is one. */\n function?: string\n message: string\n /** Present on the line that completes an invocation. */\n duration_ms?: number\n status?: number\n}\n\n/**\n * The real console methods, captured before anything is patched.\n *\n * Emitting through the patched `console` would call the patch again, which is an unbounded\n * recursion that takes the worker down on its first log line.\n */\nconst realConsole = {\n debug: console.debug.bind(console),\n info: console.info.bind(console),\n log: console.log.bind(console),\n warn: console.warn.bind(console),\n error: console.error.bind(console),\n}\n\nfunction projectRef(): string {\n const env = (key: string): string => Deno.env.get(key)?.trim() ?? \"\"\n // Self-host sets the first; cloud's templates use the managed and dedicated spellings. Falling\n // back to \"unknown\" rather than \"\" keeps the Loki label present, since a line with no\n // `project_ref` is indexed under no project and is effectively lost.\n return env(\"SUPATYPE_PROJECT_REF\") || env(\"SUPATYPE_MANAGED_PROJECT_REF\") || env(\"DEDICATED_PROJECT_REF\") || \"unknown\"\n}\n\nconst TAIL_BUFFER_LINES = Math.max(\n 0,\n parseInt(Deno.env.get(\"SUPATYPE_LOG_TAIL_BUFFER\") ?? \"500\", 10) || 500,\n)\n\nconst buffer: LogLine[] = []\nconst subscribers = new Set<(line: LogLine) => void>()\n/** How to end each open tail, so a stopping worker is not held by a stream that never ends. */\nconst openTails = new Set<() => void>()\n\n/** Ends every open tail; a tailing client reconnects to the worker that replaces this one. */\nexport function closeTails(): void {\n for (const close of [...openTails]) close()\n}\n\nfunction record(line: LogLine): void {\n if (TAIL_BUFFER_LINES > 0) {\n buffer.push(line)\n if (buffer.length > TAIL_BUFFER_LINES) buffer.shift()\n }\n for (const send of subscribers) {\n try {\n send(line)\n } catch {\n // A subscriber whose stream has gone is removed when its cancel handler runs. Throwing here\n // would lose the line for everybody else, and drop it from stdout too.\n }\n }\n}\n\n/** Everything except the message, so a caller only has to supply what it knows. */\nfunction baseLine(level: LogLine[\"level\"]): Omit<LogLine, \"message\"> {\n const current = currentInvocation()\n return {\n timestamp: new Date().toISOString(),\n level,\n service: \"functions-worker\",\n project_ref: projectRef(),\n ...(current !== undefined && {\n request_id: current.executionId,\n function: current.functionName,\n }),\n }\n}\n\n/** Write one line as JSON on stdout, and give it to anybody tailing. */\nexport function emit(line: LogLine): void {\n record(line)\n const write = line.level === \"error\" ? realConsole.error : realConsole.log\n write(JSON.stringify(line))\n}\n\n/** A line the worker itself is writing, at this level, inside whatever invocation is current. */\nexport function log(level: LogLine[\"level\"], message: string, extra: Partial<LogLine> = {}): void {\n emit({ ...baseLine(level), message, ...extra })\n}\n\n/**\n * Replace `console` so that a function's own output is structured and attributable.\n *\n * A function author writes `console.log(\"saved\", id)` and expects it to appear. It used to reach the\n * container's stdout unstructured and unlabelled, so on cloud it was dropped by the pipeline and on\n * self-host it was mixed in with every other invocation's output with nothing to tell them apart.\n *\n * Arguments are formatted the way a console does rather than JSON-stringified: `console.error(err)`\n * on an `Error` should say what went wrong, not `{}`.\n */\nexport function installStructuredLogging(): void {\n const levels: Array<[keyof typeof realConsole, LogLine[\"level\"]]> = [\n [\"debug\", \"debug\"],\n [\"info\", \"info\"],\n [\"log\", \"info\"],\n [\"warn\", \"warn\"],\n [\"error\", \"error\"],\n ]\n for (const [method, level] of levels) {\n console[method] = (...args: unknown[]): void => {\n emit({ ...baseLine(level), message: args.map(format).join(\" \") })\n }\n }\n}\n\nfunction format(value: unknown): string {\n if (typeof value === \"string\") return value\n if (value instanceof Error) return value.stack ?? `${value.name}: ${value.message}`\n try {\n return JSON.stringify(value) ?? String(value)\n } catch {\n // Circular, or a BigInt. Neither is a reason to lose the line.\n return String(value)\n }\n}\n\n/**\n * The live tail, as server-sent events.\n *\n * Replays the buffer first so attaching does not start blank, then streams. `retry` is set so a\n * dropped connection reconnects on its own; a tail that silently stops is worse than no tail.\n */\nexport function tailResponse(): Response {\n const encoder = new TextEncoder()\n let unsubscribe = (): void => {}\n\n const stream = new ReadableStream<Uint8Array>({\n start(controller) {\n const send = (line: LogLine): void => {\n controller.enqueue(encoder.encode(`data: ${JSON.stringify(line)}\\n\\n`))\n }\n controller.enqueue(encoder.encode(\"retry: 2000\\n\\n\"))\n for (const line of buffer) send(line)\n\n const close = (): void => {\n unsubscribe()\n controller.close()\n }\n subscribers.add(send)\n openTails.add(close)\n unsubscribe = () => {\n subscribers.delete(send)\n openTails.delete(close)\n }\n },\n cancel() {\n unsubscribe()\n },\n })\n\n return new Response(stream, {\n headers: {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n Connection: \"keep-alive\",\n // Nothing between here and the reader may buffer a stream whose whole purpose is to arrive as\n // it happens.\n \"X-Accel-Buffering\": \"no\",\n },\n })\n}\n\n/** For tests: what is currently in the replay buffer. */\nexport function bufferedLines(): readonly LogLine[] {\n return buffer\n}\n",
8
- "main.ts": "/**\n * Standalone edge-functions worker (per-project or per-function).\n * The image runs it, and so do native `supatype dev` and `supatype functions serve`, from the copy\n * the CLI carries (scripts/functions-worker-source.mjs), so a function behaves the same in each.\n */\n\nimport { parseEnvText } from \"./dotenv.ts\"\nimport { FUNCTION_ENTRY_FILE, functionRouteName, isHookName } from \"./routes.ts\"\nimport { exitOnStop } from \"./stop.ts\"\nimport {\n currentHookDepth,\n runInvocation,\n type FunctionContext,\n} from \"./invocation.ts\"\nimport {\n closeTails,\n installStructuredLogging,\n log,\n tailResponse,\n} from \"./logging.ts\"\n\ninstallStructuredLogging()\n// Once, at startup. Hook depth then comes from the invocation store rather than from a patch\n// applied and reverted around every call.\ninstallHookDepthPropagation()\n\n/**\n * Route names the worker answers itself.\n *\n * Underscore-prefixed, the convention Deno Deploy and Supabase both use, so a reserved route cannot\n * collide with a function somebody has already deployed. Discovery warns if one is shadowed rather\n * than silently winning.\n */\nconst RESERVED_ROUTES = new Set([\"_logs\"])\n\ntype Handler = (req: Request, ctx: FunctionContext) => Response | Promise<Response>\n\ninterface DiscoveredRoute {\n name: string\n entrypoint: string\n}\n\n/**\n * Root for public functions, or \"\" when this worker serves none.\n *\n * Empty is a real configuration, not a mistake: a per-hook worker mounts a hooks root and nothing else,\n * and its pod has no functions directory to point at. Requiring this one made such a pod crashloop,\n * which the API server sees as the hook refusing to answer, failing every write to its table. Startup\n * still fails when *both* roots are empty, since a worker with no source at all is a misconfiguration.\n */\nfunction functionsRoot(): string {\n const root = (\n Deno.env.get(\"SUPATYPE_FUNCTIONS_ROOT\") ??\n Deno.env.get(\"SUPATYPE_DENO_FUNCTIONS_DIR\") ??\n \"\"\n ).trim()\n if (!root) return \"\"\n return root.endsWith(\"/\") ? root.slice(0, -1) : root\n}\n\n/**\n * Root for **model hooks**, served under a `hooks/` route prefix.\n *\n * Hooks are procedural: the API server calls them around a write, while everything under the\n * functions root is a public endpoint anyone holding the anon key can invoke. Keeping them in one\n * worker rather than two costs a project no extra pod; keeping them under a route prefix is what lets\n * the gateway refuse them from outside, so the separation is structural rather than a deny-list that\n * a stale manifest could empty.\n */\nfunction hooksRoot(): string {\n const root = (Deno.env.get(\"SUPATYPE_HOOKS_ROOT\") ?? \"\").trim()\n if (!root) return \"\"\n return root.endsWith(\"/\") ? root.slice(0, -1) : root\n}\n\n/** Route prefix for hook handlers. The gateway refuses this prefix on the public path. */\nconst HOOKS_ROUTE_PREFIX = \"hooks/\"\n\n/** A comma-separated route list as a set, empty entries dropped. */\nfunction parseRoutes(text: string): Set<string> {\n return new Set(\n text\n .split(\",\")\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0),\n )\n}\n\n/** The routes file as last read: kept while its modification time and size are unchanged. */\nlet routesFileRead: { mtime: number; size: number; routes: Set<string> } | null = null\n\n/**\n * The routes in `file`, read again only when its modification time or size changed: one stat a\n * call. Undefined when it has not been written (the environment's list applies); none when it is\n * there but cannot be read.\n */\nasync function routesFromFile(file: string): Promise<Set<string> | undefined> {\n let info: Deno.FileInfo\n try {\n info = await Deno.stat(file)\n } catch (err) {\n return err instanceof Deno.errors.NotFound ? undefined : new Set()\n }\n const mtime = info.mtime?.getTime() ?? -1\n if (routesFileRead !== null && routesFileRead.mtime === mtime && routesFileRead.size === info.size) return routesFileRead.routes\n try {\n routesFileRead = { mtime, size: info.size, routes: parseRoutes(await Deno.readTextFile(file)) }\n } catch {\n routesFileRead = null\n return new Set()\n }\n return routesFileRead.routes\n}\n\n/**\n * Public function routes allowed to see `SUPATYPE_SERVICE_ROLE_KEY`, looked up on every call: from\n * the file `SUPATYPE_SERVICE_ROLE_ROUTES_FILE` names once it is written, else\n * `SUPATYPE_SERVICE_ROLE_ROUTES`. Native dev writes the file when `functions.serviceRole` changes,\n * and a self-hosted control plane on every deploy, so a route taken off the list loses the key on its\n * next call, with no restart; the environment is fixed when the worker starts. A routes file that is\n * there but cannot be read grants nothing.\n *\n * Hooks do not appear here: they get the key by default (see serviceRoleGranted). This list is for\n * the public surface, where the default is nothing.\n */\nasync function serviceRoleRoutes(): Promise<Set<string>> {\n const file = Deno.env.get(\"SUPATYPE_SERVICE_ROLE_ROUTES_FILE\")\n const fromFile = file ? await routesFromFile(file) : undefined\n return fromFile ?? parseRoutes(Deno.env.get(\"SUPATYPE_SERVICE_ROLE_ROUTES\") ?? \"\")\n}\n\n/** The function every entry of a hook or validator map names (table, then event or column, then the entry). */\nfunction functionsNamed(map: unknown): string[] {\n if (typeof map !== \"object\" || map === null) return []\n return Object.values(map).flatMap((entries: unknown) =>\n typeof entries !== \"object\" || entries === null\n ? []\n : Object.values(entries).flatMap((entry: unknown) =>\n typeof entry === \"object\" && entry !== null && \"function\" in entry && typeof entry.function === \"string\" ? [entry.function] : [],\n ),\n )\n}\n\n/**\n * The hooks the stack's manifest maps (its `hooks` and `validators`), from the file\n * `SUPATYPE_MANIFEST_PATH` names, the one the server reads; read on each call, which only a hook\n * route with no code makes. Null when no manifest is named (Cloud's worker), or the one named cannot\n * be read or parsed (caught mid-rewrite, say): the caller then fails closed.\n */\nasync function mappedHookNames(): Promise<Set<string> | null> {\n const path = (Deno.env.get(\"SUPATYPE_MANIFEST_PATH\") ?? \"\").trim()\n if (!path) return null\n let parsed: unknown\n try {\n parsed = JSON.parse(await Deno.readTextFile(path))\n } catch {\n return null\n }\n if (typeof parsed !== \"object\" || parsed === null) return null\n const maps = [\"hooks\" in parsed ? parsed.hooks : undefined, \"validators\" in parsed ? parsed.validators : undefined]\n return new Set(maps.flatMap(functionsNamed))\n}\n\n/**\n * Whether a hook route the worker has no code for answers 503 (the hook cannot be reached, and the\n * server refuses the write for it) rather than 404 (no such hook). With the manifest's map, only a\n * name it maps. Without one, every name that passes the hook-name rule: it fails closed, since a 404\n * is read by the server as the hook rejecting the write.\n */\nasync function unreachableHook(name: string): Promise<boolean> {\n const mapped = await mappedHookNames()\n if (mapped !== null) return mapped.has(name)\n return isHookName(name)\n}\n\n/**\n * Whether a route may see the service-role key.\n *\n * **Hooks: yes.** A hook is procedural, only the API server calls it, around a write the caller was\n * already permitted to make, and the gateway refuses its route from outside, so it is not reachable\n * by anyone who could choose to invoke it. Requiring each one to be listed would be friction with no\n * attacker to stop, and it is the same trust a trigger or a migration already has.\n *\n * **Public functions: only if named.** Those *are* invocable by anyone holding the anon key, so an\n * ambient admin credential there is read and write access past every access rule in the schema,\n * handed to code the internet can call.\n */\nasync function serviceRoleGranted(route: string): Promise<boolean> {\n if (route.startsWith(HOOKS_ROUTE_PREFIX)) return true\n return (await serviceRoleRoutes()).has(route)\n}\n\n/**\n * Take the service-role key out of the process environment, returning it for scoped re-injection.\n *\n * **Before handlers are imported**, which is the whole point: a handler's module body runs at import\n * time, so a key still in `Deno.env` then is a key any handler can copy and keep. Withholding it\n * afterwards would be theatre.\n *\n * The default is now \"no admin credential\". A function is a public endpoint, anyone holding the anon\n * key can invoke one, and an ambient service-role key made every one of them able to read and write\n * past every access rule in the schema. Opting in is a line in `supatype.config.ts`, which is\n * reviewable; ambient privilege is not.\n */\nasync function withholdServiceRoleKey(): Promise<string> {\n const key = Deno.env.get(\"SUPATYPE_SERVICE_ROLE_KEY\") ?? \"\"\n if (key) Deno.env.delete(\"SUPATYPE_SERVICE_ROLE_KEY\")\n const keyFile = (Deno.env.get(\"SUPATYPE_SERVICE_ROLE_KEY_FILE\") ?? \"\").trim()\n return keyFile ? await readServiceRoleKeyFile(keyFile) : key\n}\n\n/**\n * The service-role key from `path`, or \"\" (no function is given it) when the file cannot be read.\n *\n * For a worker run under `deno run --watch`, as native `supatype dev` and `supatype functions serve`\n * run it. A reload evaluates this module again in the same process, whose environment the first\n * evaluation already took the key out of, so a key from the environment is there once only. The\n * file is still there however the earlier evaluation ended. Its path stays in the environment: a\n * function able to read the disk can read the file whether or not it is told where it is, and the\n * key a function is handed is still decided by serviceRoleGranted alone.\n */\nasync function readServiceRoleKeyFile(path: string): Promise<string> {\n try {\n return (await Deno.readTextFile(path)).trim()\n } catch (err) {\n log(\"error\", `No function is given the service-role key: could not read ${path} (${errorText(err)})`)\n return \"\"\n }\n}\n\nasync function discoverRoutes(root: string): Promise<DiscoveredRoute[]> {\n const single = Deno.env.get(\"SUPATYPE_FUNCTION_NAME\")?.trim()\n const out: DiscoveredRoute[] = []\n\n // The catch has to wrap the *iteration*: `Deno.readDir` returns its iterable without touching the\n // filesystem, so a missing directory raises NotFound on the first `next()`, not here. A root that\n // does not exist is ordinary, a project with functions but no hooks has no hooks directory, and\n // letting it throw would fail startup and take that project's working functions down with it.\n try {\n // routes.ts is the rule a self-hosted control plane lists functions by too.\n for await (const entry of Deno.readDir(root)) {\n const fullPath = `${root}/${entry.name}`\n const name = entry.isDirectory || entry.isFile ? functionRouteName(entry.name, entry.isDirectory ? \"directory\" : \"file\") : undefined\n if (name === undefined || (single && name !== single)) continue\n const entrypoint = entry.isDirectory ? `${fullPath}/${FUNCTION_ENTRY_FILE}` : fullPath\n try {\n await Deno.stat(entrypoint)\n out.push({ name, entrypoint })\n } catch {\n // A directory with no entry module is not a route.\n }\n }\n } catch (err) {\n if (!(err instanceof Deno.errors.NotFound)) throw err\n }\n\n return out.sort((a, b) => a.name.localeCompare(b.name))\n}\n\nfunction entrypointImportUrl(entrypoint: string): string {\n const normalized = entrypoint.replace(/\\\\/g, \"/\")\n if (normalized.startsWith(\"file://\")) return normalized\n // A Windows absolute path is not a URL: `new URL(\"C:/x\")` reads the drive letter as the scheme, and\n // Deno then refuses to import scheme \"c\". Invisible in a Linux container, where every root starts\n // with \"/\", and fatal the moment this worker runs on a developer's machine.\n if (/^[A-Za-z]:\\//.test(normalized)) return `file:///${normalized}`\n if (normalized.startsWith(\"/\")) return `file://${normalized}`\n return new URL(normalized, import.meta.url).href\n}\n\n/**\n * A function's exported handler. A boundary: what can be checked is that it is a function; what it\n * takes and returns is the function author's contract with the worker, which only calling it tests.\n */\nfunction isHandler(value: unknown): value is Handler {\n return typeof value === \"function\"\n}\n\n/** The module's `default` export, else its `handler` export. */\nfunction exportedHandler(mod: unknown): unknown {\n if (typeof mod !== \"object\" || mod === null) return undefined\n const fallback = \"handler\" in mod ? mod.handler : undefined\n return (\"default\" in mod ? mod.default : undefined) ?? fallback\n}\n\nasync function loadHandlers(routes: DiscoveredRoute[]): Promise<Record<string, Handler>> {\n const handlers: Record<string, Handler> = {}\n\n for (const route of routes) {\n // The reserved route wins, because the worker answers it before the handler lookup. Say so\n // rather than leaving an author wondering why their function returns an event stream.\n if (RESERVED_ROUTES.has(route.name)) {\n log(\"warn\", `Function \"${route.name}\" is shadowed: the worker reserves that route`, {\n function: route.name,\n })\n continue\n }\n handlers[route.name] = await loadHandler(route)\n }\n\n return handlers\n}\n\n/**\n * The route's handler, or, when its module fails to import or exports no handler, one that answers\n * the route with a 500 saying why. The first such module used to stop the worker starting, so one\n * broken function took every function in the project down with it. The message goes out as JSON,\n * so the escape codes come out of it: a client has no terminal to colour.\n */\nasync function loadHandler(route: DiscoveredRoute): Promise<Handler> {\n try {\n // A module loaded by URL is typed `any`; read its exports as unknown until checked.\n const mod: unknown = await import(entrypointImportUrl(route.entrypoint))\n const handler = exportedHandler(mod)\n if (!isHandler(handler)) throw new Error('it has neither a default export nor a named \"handler\" export')\n return handler\n } catch (err) {\n const message = `Function \"${route.name}\" failed to load: ${errorText(err)}`\n log(\"error\", message, { function: route.name })\n return () => jsonError(\"function_load_failed\", message, 500)\n }\n}\n\n/**\n * Terminal escape codes. Deno colours a missing module's location in its message, piped or not,\n * and a handler's own error can carry them too.\n */\nconst TERMINAL_ESCAPES = /\\u001b\\[[0-9;?]*[A-Za-z]/g\n\n/**\n * What a thrown value says: an Error's message, anything else as a string, without escape codes,\n * since it goes out as JSON and a client has no terminal to colour.\n */\nfunction errorText(err: unknown): string {\n return (err instanceof Error ? err.message : String(err)).replace(TERMINAL_ESCAPES, \"\")\n}\n\n/** A JSON error answer, `{ error: code, message, ...extra }`, as every route of the worker gives one. */\nfunction jsonError(code: string, message: string, status: number, extra: Record<string, unknown> = {}): Response {\n return new Response(JSON.stringify({ error: code, message, ...extra }), {\n status,\n headers: { \"Content-Type\": \"application/json\" },\n })\n}\n\nconst port = parseInt(Deno.env.get(\"PORT\") ?? \"8001\", 10)\n// Order matters: withhold, then import. See withholdServiceRoleKey.\nconst serviceRoleKey = await withholdServiceRoleKey()\nconst root = functionsRoot()\nconst routes = root ? await discoverRoutes(root) : []\nconst handlers = await loadHandlers(routes)\n\n// Hooks are namespaced so one worker can serve both without a name in `hooks/` ever shadowing, or\n// being reachable as: a public function of the same name.\nconst hooksDir = hooksRoot()\nif (!root && !hooksDir) {\n throw new Error(\n \"SUPATYPE_FUNCTIONS_ROOT or SUPATYPE_HOOKS_ROOT is required (a worker with neither serves nothing)\",\n )\n}\nif (hooksDir) {\n const hookRoutes = await discoverRoutes(hooksDir)\n const hookHandlers = await loadHandlers(hookRoutes)\n for (const [name, handler] of Object.entries(hookHandlers)) {\n handlers[HOOKS_ROUTE_PREFIX + name] = handler\n }\n}\n\n// A worker pinned to one route still has to find it, and with two roots \"absent from this one\" is not\n// \"absent everywhere\": a per-hook pod names its hook and has no functions directory at all. Checked\n// once, after both roots, so the failure means what it says, and it stays a failure, because a pod\n// serving nothing would answer 404 to the API server, which reads as the hook refusing to answer and\n// fails every write to its table.\nconst single = Deno.env.get(\"SUPATYPE_FUNCTION_NAME\")?.trim()\nif (single && Object.keys(handlers).length === 0) {\n throw new Error(\n `Handler \"${single}\" not found under ${root}` + (hooksDir ? ` or ${hooksDir}` : \"\"),\n )\n}\n\nconsole.log(\n `[functions-worker] ${Object.keys(handlers).length} handler(s) on :${port}` +\n (Deno.env.get(\"SUPATYPE_FUNCTION_NAME\") ? ` (single: ${Deno.env.get(\"SUPATYPE_FUNCTION_NAME\")})` : \"\"),\n)\n\n// Falls back to the hooks root: a per-hook worker has no functions directory, and the shared env file\n// is looked for beside whichever source this worker actually has.\nconst normalizedFunctionsDir = root || hooksDir\nconst sharedEnvPath =\n Deno.env.get(\"SUPATYPE_SHARED_ENV_FILE\") ?? `${normalizedFunctionsDir}/.env.local`\n\n\n\n/** The variables in the env file at `path`, read as the CLI and compose read one; none if it is absent. */\nasync function readEnvFile(path: string): Promise<Record<string, string>> {\n if (!path) return {}\n try {\n return parseEnvText(await Deno.readTextFile(path))\n } catch {\n return {}\n }\n}\n\n/**\n * The values `functions env set` gave a self-hosted project: the control plane's JSON map, which\n * compose names here. Without it a value set through the control plane never reached a function.\n * Read on every call, like the env files, so a set or unset is seen without a restart.\n */\nconst managedEnvPath = (Deno.env.get(\"SUPATYPE_FUNCTION_ENV_FILE\") ?? \"\").trim()\n\nasync function readManagedEnv(): Promise<Record<string, string>> {\n if (!managedEnvPath) return {}\n let parsed: unknown\n try {\n parsed = JSON.parse(await Deno.readTextFile(managedEnvPath))\n } catch {\n return {}\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return {}\n return Object.fromEntries(Object.entries(parsed).filter((entry): entry is [string, string] => typeof entry[1] === \"string\"))\n}\n\n/**\n * The shared env file, then the managed values, then the function's own file, which wins. The three\n * are read together: every call waits for them.\n */\nasync function scopedEnvForFunction(fnName: string): Promise<Record<string, string>> {\n const [shared, managed, fnVars] = await Promise.all([\n readEnvFile(sharedEnvPath),\n readManagedEnv(),\n readEnvFile(`${normalizedFunctionsDir}/.env.${fnName}.local`),\n ])\n return { ...shared, ...managed, ...fnVars }\n}\n\nconst HOOK_DEPTH_HEADER = \"x-supatype-hook-depth\"\n\n/**\n * Carry the hook-depth header onto calls a hook makes back into the stack.\n *\n * Patched once, at startup, rather than per invocation. The old version replaced `globalThis.fetch`\n * for the duration of a call and restored it afterwards, which is only safe while exactly one\n * invocation runs at a time: two concurrent hooks would patch over each other, and the first to\n * finish would restore the other's patch. That mutation was half the reason for the lock.\n *\n * Depth comes from the invocation store, so this closure holds no per-call state at all.\n */\nfunction installHookDepthPropagation(): void {\n const original = globalThis.fetch\n globalThis.fetch = (input: Request | URL | string, init?: RequestInit): Promise<Response> => {\n const depth = currentHookDepth()\n const stack = stackOrigin()\n if (depth === null || stack === null) return original(input, init)\n\n const url = input instanceof Request ? input.url : String(input)\n if (!url.startsWith(stack)) return original(input, init)\n\n const request = new Request(input, init)\n request.headers.set(HOOK_DEPTH_HEADER, depth)\n return original(request)\n }\n}\n\n/**\n * The database URL a function may use, when the deployment gave the worker one: off unless the\n * operator set SUPATYPE_FUNCTIONS_DB_URL (see `FunctionContext.dbUrl`).\n */\nfunction dbUrlForFunctions(): string | undefined {\n const raw = Deno.env.get(\"SUPATYPE_DB_URL\") ?? Deno.env.get(\"DATABASE_URL\")\n return raw === undefined || raw.trim() === \"\" ? undefined : raw\n}\n\n/** The stack's own origin, or null when this worker was not told how to reach it. */\nfunction stackOrigin(): string | null {\n const raw = Deno.env.get(\"SUPATYPE_INTERNAL_URL\") ?? Deno.env.get(\"SUPATYPE_URL\")\n if (raw === undefined || raw.trim() === \"\") return null\n try {\n return new URL(raw).origin\n } catch {\n return null\n }\n}\n\n/**\n * The project's public address, handed to every function as `ctx.publicUrl` (see FunctionContext).\n *\n * Read once, at start: it never differs between invocations, and a deployment that left it unset\n * should be told once rather than on every call. The fallback is `ctx.url`, which under compose is\n * an in-stack name, so a link built from it would reach nobody; the warning says so.\n */\nfunction resolvePublicUrl(): string {\n const configured = (Deno.env.get(\"SUPATYPE_PUBLIC_URL\") ?? \"\").trim()\n if (configured !== \"\") return configured\n const internal = Deno.env.get(\"SUPATYPE_URL\") ?? \"\"\n log(\n \"warn\",\n \"SUPATYPE_PUBLIC_URL is not set, so ctx.publicUrl falls back to ctx.url \" +\n `(${internal || \"unset\"}), which may be an address only this stack can reach`,\n )\n return internal\n}\n\nconst publicUrl = resolvePublicUrl()\n\n\n// `onListen` is supplied so Deno does not print its own \"Listening on …\" line. That line goes to\n// stderr, which this worker's patched console reports as `level: \"error\"`, and on cloud `level` is\n// a Loki label, so every startup would appear in the dashboards as an error.\n// Every address in its container; `functions serve` and native dev name 127.0.0.1.\nconst hostname = Deno.env.get(\"SUPATYPE_FUNCTIONS_HOST\") ?? \"0.0.0.0\"\nconst server = Deno.serve({\n hostname,\n port,\n onListen: ({ hostname, port: bound }) => {\n log(\"info\", `functions-worker listening on http://${hostname}:${bound}`)\n },\n}, async (req: Request): Promise<Response> => {\n const url = new URL(req.url)\n const pathParts = url.pathname.replace(/^\\/functions\\/v1\\/?/, \"\").split(\"/\").filter(Boolean)\n // A hook is addressed as `hooks/<name>`, so the first segment alone is not the handler key. With no\n // second segment no hook name is built: the path is looked up as the plain route \"hooks\", a 404\n // unless a function has that name, so `hooks/<name>` always carries a name the request sent.\n const fnName =\n pathParts[0] === \"hooks\" && pathParts[1]\n ? HOOKS_ROUTE_PREFIX + pathParts[1]\n : pathParts[0] ?? \"\"\n\n // Answered by the worker itself, before the handler lookup, so a project with no functions at all\n // still has a tail.\n if (RESERVED_ROUTES.has(fnName)) {\n if (fnName === \"_logs\") return tailResponse()\n }\n\n // A hook the map names with no code here (a new hook whose deploy failed) cannot be reached: 503,\n // which the server's hook dispatch treats as unavailable and refuses the write for. A 404 read as\n // the hook rejecting the write, with a \"not found\" message. Any other name stays a 404\n // (unreachableHook).\n if (fnName.startsWith(HOOKS_ROUTE_PREFIX) && !handlers[fnName]) {\n const hook = fnName.slice(HOOKS_ROUTE_PREFIX.length)\n if (await unreachableHook(hook)) return jsonError(\"hook_unavailable\", `Hook \"${hook}\" is not deployed`, 503)\n }\n if (!fnName || !handlers[fnName]) {\n const message = fnName ? `Function \"${fnName}\" not found` : \"No function specified\"\n return jsonError(\"not_found\", message, 404, { available: Object.keys(handlers) })\n }\n\n // Nothing goes into the process environment, so nothing has to be taken back out and nothing has\n // to be serialised. This used to hold a lock across the whole handler, which meant the worker ran\n // one invocation at a time: a function waiting on a third-party API blocked every other function\n // in the project for as long as it waited.\n const dbUrl = dbUrlForFunctions()\n const context: FunctionContext = {\n executionId: crypto.randomUUID(),\n functionName: fnName,\n url: Deno.env.get(\"SUPATYPE_URL\") ?? \"\",\n publicUrl,\n anonKey: Deno.env.get(\"SUPATYPE_ANON_KEY\") ?? \"\",\n // From the closure, not the environment: the key was withheld before any handler was imported,\n // and only a route the project granted it receives it here.\n ...(serviceRoleKey && (await serviceRoleGranted(fnName)) && { serviceRoleKey }),\n ...(dbUrl !== undefined && { dbUrl }),\n region: Deno.env.get(\"SUPATYPE_REGION\") ?? \"local\",\n env: await scopedEnvForFunction(fnName),\n }\n\n const start = performance.now()\n\n try {\n const response = await runInvocation(context, req.headers.get(HOOK_DEPTH_HEADER), async () =>\n handlers[fnName]!(req, context),\n )\n log(\"info\", `${req.method} /functions/v1/${fnName} → ${response.status}`, {\n request_id: context.executionId,\n function: fnName,\n status: response.status,\n duration_ms: Number((performance.now() - start).toFixed(1)),\n })\n return response\n } catch (err) {\n const message = errorText(err)\n log(\"error\", message, {\n request_id: context.executionId,\n function: fnName,\n status: 500,\n duration_ms: Number((performance.now() - start).toFixed(1)),\n })\n return jsonError(\"function_error\", message, 500)\n }\n})\n// A restart of its container waited out the stop timeout without this, and must not cut off the\n// requests in flight (stop.ts). A log tail never ends on its own, so it is closed first.\nexitOnStop(() => {\n closeTails()\n return server.shutdown()\n})\n",
10
+ "main.ts": "/**\n * Standalone edge-functions worker (per-project or per-function).\n * The image runs it, and so do native `supatype dev` and `supatype functions serve`, from the copy\n * the CLI carries (scripts/functions-worker-source.mjs), so a function behaves the same in each.\n */\n\nimport { parseEnvText } from \"./dotenv.ts\"\nimport { scrubProcessEnv } from \"./env-allowlist.ts\"\nimport { isHookName } from \"./routes.ts\"\nimport { exitOnStop } from \"./stop.ts\"\nimport {\n runInvocation,\n type FunctionContext,\n} from \"./invocation.ts\"\nimport { endUserAddress, HOOK_DEPTH_HEADER, installStackFetch } from \"./stack-fetch.ts\"\nimport { discoverRoutes, type DiscoveredRoute } from \"./discover.ts\"\nimport {\n closeTails,\n installStructuredLogging,\n log,\n tailResponse,\n} from \"./logging.ts\"\n\ninstallStructuredLogging()\n// The forwarding secret leaves the environment now, before any handler is imported, so user code\n// cannot read it; only the patch below holds it.\nconst forwardingSecret = withholdForwardingSecret()\n// Once, at startup. Hook depth and the end user's address then come from the invocation store rather\n// than from a patch applied and reverted around every call.\ninstallStackFetch({ origin: stackOrigin, forwardingSecret })\n\n/**\n * Route names the worker answers itself.\n *\n * Underscore-prefixed, the convention Deno Deploy and Supabase both use, so a reserved route cannot\n * collide with a function somebody has already deployed. Discovery warns if one is shadowed rather\n * than silently winning.\n */\nconst RESERVED_ROUTES = new Set([\"_logs\", \"_functions\"])\n\n/**\n * The public functions this worker serves, by name: what the server's function list asks for, and\n * what a 404 offers as `available`. A hook is procedural and the gateway refuses its route from\n * outside, so it is neither listed nor suggested.\n */\nfunction publicFunctionNames(handlers: Record<string, Handler>): string[] {\n return Object.keys(handlers)\n .filter((name) => !name.startsWith(HOOKS_ROUTE_PREFIX))\n .sort()\n}\n\n/**\n * The answer to `GET /functions/v1/_functions`, in the shape Studio's Edge Functions page reads. The\n * worker keeps no call statistics, so the counts are zero rather than absent: a missing number is a\n * page that cannot render the row.\n */\nfunction functionListResponse(handlers: Record<string, Handler>): Response {\n const data = publicFunctionNames(handlers).map((name) => ({ name, invocations24h: 0, avgDurationMs: 0 }))\n return new Response(JSON.stringify({ data }), { headers: { \"Content-Type\": \"application/json\" } })\n}\n\ntype Handler = (req: Request, ctx: FunctionContext) => Response | Promise<Response>\n\n/**\n * Root for public functions, or \"\" when this worker serves none.\n *\n * Empty is a real configuration, not a mistake: a per-hook worker mounts a hooks root and nothing else,\n * and its pod has no functions directory to point at. Requiring this one made such a pod crashloop,\n * which the API server sees as the hook refusing to answer, failing every write to its table. Startup\n * still fails when *both* roots are empty, since a worker with no source at all is a misconfiguration.\n */\nfunction functionsRoot(): string {\n const root = (\n Deno.env.get(\"SUPATYPE_FUNCTIONS_ROOT\") ??\n Deno.env.get(\"SUPATYPE_DENO_FUNCTIONS_DIR\") ??\n \"\"\n ).trim()\n if (!root) return \"\"\n return root.endsWith(\"/\") ? root.slice(0, -1) : root\n}\n\n/**\n * Root for **model hooks**, served under a `hooks/` route prefix.\n *\n * Hooks are procedural: the API server calls them around a write, while everything under the\n * functions root is a public endpoint anyone holding the anon key can invoke. Keeping them in one\n * worker rather than two costs a project no extra pod; keeping them under a route prefix is what lets\n * the gateway refuse them from outside, so the separation is structural rather than a deny-list that\n * a stale manifest could empty.\n */\nfunction hooksRoot(): string {\n const root = (Deno.env.get(\"SUPATYPE_HOOKS_ROOT\") ?? \"\").trim()\n if (!root) return \"\"\n return root.endsWith(\"/\") ? root.slice(0, -1) : root\n}\n\n/** Route prefix for hook handlers. The gateway refuses this prefix on the public path. */\nconst HOOKS_ROUTE_PREFIX = \"hooks/\"\n\n/** A comma-separated route list as a set, empty entries dropped. */\nfunction parseRoutes(text: string): Set<string> {\n return new Set(\n text\n .split(\",\")\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0),\n )\n}\n\n/** The routes file as last read: kept while its modification time and size are unchanged. */\nlet routesFileRead: { mtime: number; size: number; routes: Set<string> } | null = null\n\n/**\n * The routes in `file`, read again only when its modification time or size changed: one stat a\n * call. Undefined when it has not been written (the environment's list applies); none when it is\n * there but cannot be read.\n */\nasync function routesFromFile(file: string): Promise<Set<string> | undefined> {\n let info: Deno.FileInfo\n try {\n info = await Deno.stat(file)\n } catch (err) {\n return err instanceof Deno.errors.NotFound ? undefined : new Set()\n }\n const mtime = info.mtime?.getTime() ?? -1\n if (routesFileRead !== null && routesFileRead.mtime === mtime && routesFileRead.size === info.size) return routesFileRead.routes\n try {\n routesFileRead = { mtime, size: info.size, routes: parseRoutes(await Deno.readTextFile(file)) }\n } catch {\n routesFileRead = null\n return new Set()\n }\n return routesFileRead.routes\n}\n\n/**\n * Public function routes allowed to see `SUPATYPE_SERVICE_ROLE_KEY`, looked up on every call: from\n * the file `SUPATYPE_SERVICE_ROLE_ROUTES_FILE` names once it is written, else\n * `SUPATYPE_SERVICE_ROLE_ROUTES`. Native dev writes the file when `functions.serviceRole` changes,\n * and a self-hosted control plane on every deploy, so a route taken off the list loses the key on its\n * next call, with no restart; the environment is fixed when the worker starts. A routes file that is\n * there but cannot be read grants nothing.\n *\n * Hooks do not appear here: they get the key by default (see serviceRoleGranted). This list is for\n * the public surface, where the default is nothing.\n */\nasync function serviceRoleRoutes(): Promise<Set<string>> {\n const file = Deno.env.get(\"SUPATYPE_SERVICE_ROLE_ROUTES_FILE\")\n const fromFile = file ? await routesFromFile(file) : undefined\n return fromFile ?? parseRoutes(Deno.env.get(\"SUPATYPE_SERVICE_ROLE_ROUTES\") ?? \"\")\n}\n\n/** The function every entry of a hook or validator map names (table, then event or column, then the entry). */\nfunction functionsNamed(map: unknown): string[] {\n if (typeof map !== \"object\" || map === null) return []\n return Object.values(map).flatMap((entries: unknown) =>\n typeof entries !== \"object\" || entries === null\n ? []\n : Object.values(entries).flatMap((entry: unknown) =>\n typeof entry === \"object\" && entry !== null && \"function\" in entry && typeof entry.function === \"string\" ? [entry.function] : [],\n ),\n )\n}\n\n/**\n * The hooks the stack's manifest maps (its `hooks` and `validators`), from the file\n * `SUPATYPE_MANIFEST_PATH` names, the one the server reads; read on each call, which only a hook\n * route with no code makes. Null when no manifest is named (Cloud's worker), or the one named cannot\n * be read or parsed (caught mid-rewrite, say): the caller then fails closed.\n */\nasync function mappedHookNames(): Promise<Set<string> | null> {\n const path = (Deno.env.get(\"SUPATYPE_MANIFEST_PATH\") ?? \"\").trim()\n if (!path) return null\n let parsed: unknown\n try {\n parsed = JSON.parse(await Deno.readTextFile(path))\n } catch {\n return null\n }\n if (typeof parsed !== \"object\" || parsed === null) return null\n const maps = [\"hooks\" in parsed ? parsed.hooks : undefined, \"validators\" in parsed ? parsed.validators : undefined]\n return new Set(maps.flatMap(functionsNamed))\n}\n\n/**\n * Whether a hook route the worker has no code for answers 503 (the hook cannot be reached, and the\n * server refuses the write for it) rather than 404 (no such hook). With the manifest's map, only a\n * name it maps. Without one, every name that passes the hook-name rule: it fails closed, since a 404\n * is read by the server as the hook rejecting the write.\n */\nasync function unreachableHook(name: string): Promise<boolean> {\n const mapped = await mappedHookNames()\n if (mapped !== null) return mapped.has(name)\n return isHookName(name)\n}\n\n/**\n * Whether a route may see the service-role key.\n *\n * **Hooks: yes.** A hook is procedural, only the API server calls it, around a write the caller was\n * already permitted to make, and the gateway refuses its route from outside, so it is not reachable\n * by anyone who could choose to invoke it. Requiring each one to be listed would be friction with no\n * attacker to stop, and it is the same trust a trigger or a migration already has.\n *\n * **Public functions: only if named.** Those *are* invocable by anyone holding the anon key, so an\n * ambient admin credential there is read and write access past every access rule in the schema,\n * handed to code the internet can call.\n */\nasync function serviceRoleGranted(route: string): Promise<boolean> {\n if (route.startsWith(HOOKS_ROUTE_PREFIX)) return true\n return (await serviceRoleRoutes()).has(route)\n}\n\n/**\n * Take the service-role key out of the process environment, returning it for scoped re-injection.\n *\n * **Before handlers are imported**, which is the whole point: a handler's module body runs at import\n * time, so a key still in `Deno.env` then is a key any handler can copy and keep. Withholding it\n * afterwards would be theatre.\n *\n * The default is now \"no admin credential\". A function is a public endpoint, anyone holding the anon\n * key can invoke one, and an ambient service-role key made every one of them able to read and write\n * past every access rule in the schema. Opting in is a line in `supatype.config.ts`, which is\n * reviewable; ambient privilege is not.\n */\nasync function withholdServiceRoleKey(): Promise<string> {\n const key = Deno.env.get(\"SUPATYPE_SERVICE_ROLE_KEY\") ?? \"\"\n if (key) Deno.env.delete(\"SUPATYPE_SERVICE_ROLE_KEY\")\n const keyFile = (Deno.env.get(\"SUPATYPE_SERVICE_ROLE_KEY_FILE\") ?? \"\").trim()\n return keyFile ? await readServiceRoleKeyFile(keyFile) : key\n}\n\n/**\n * The forwarding secret from the environment, or \"\" when the project has none, taken out of it.\n *\n * Like the service-role key above, and for the same reason: it is what makes the auth server believe\n * an address a request passes on, so a function able to read it could claim any address. Withheld\n * before any handler is imported, and handed to nothing but the patch on `fetch` that adds it to\n * calls to the stack's own address.\n */\nfunction withholdForwardingSecret(): string {\n const secret = (Deno.env.get(\"SUPATYPE_FORWARDING_SECRET\") ?? \"\").trim()\n Deno.env.delete(\"SUPATYPE_FORWARDING_SECRET\")\n return secret\n}\n\n/**\n * The service-role key from `path`, or \"\" (no function is given it) when the file cannot be read.\n *\n * For a worker run under `deno run --watch`, as native `supatype dev` and `supatype functions serve`\n * run it. A reload evaluates this module again in the same process, whose environment the first\n * evaluation already took the key out of, so a key from the environment is there once only. The\n * file is still there however the earlier evaluation ended. Its path stays in the environment: a\n * function able to read the disk can read the file whether or not it is told where it is, and the\n * key a function is handed is still decided by serviceRoleGranted alone.\n */\nasync function readServiceRoleKeyFile(path: string): Promise<string> {\n try {\n return (await Deno.readTextFile(path)).trim()\n } catch (err) {\n log(\"error\", `No function is given the service-role key: could not read ${path} (${errorText(err)})`)\n return \"\"\n }\n}\n\nfunction entrypointImportUrl(entrypoint: string): string {\n const normalized = entrypoint.replace(/\\\\/g, \"/\")\n if (normalized.startsWith(\"file://\")) return normalized\n // A Windows absolute path is not a URL: `new URL(\"C:/x\")` reads the drive letter as the scheme, and\n // Deno then refuses to import scheme \"c\". Invisible in a Linux container, where every root starts\n // with \"/\", and fatal the moment this worker runs on a developer's machine.\n if (/^[A-Za-z]:\\//.test(normalized)) return `file:///${normalized}`\n if (normalized.startsWith(\"/\")) return `file://${normalized}`\n return new URL(normalized, import.meta.url).href\n}\n\n/**\n * A function's exported handler. A boundary: what can be checked is that it is a function; what it\n * takes and returns is the function author's contract with the worker, which only calling it tests.\n */\nfunction isHandler(value: unknown): value is Handler {\n return typeof value === \"function\"\n}\n\n/** The module's `default` export, else its `handler` export. */\nfunction exportedHandler(mod: unknown): unknown {\n if (typeof mod !== \"object\" || mod === null) return undefined\n const fallback = \"handler\" in mod ? mod.handler : undefined\n return (\"default\" in mod ? mod.default : undefined) ?? fallback\n}\n\nasync function loadHandlers(routes: DiscoveredRoute[]): Promise<Record<string, Handler>> {\n const handlers: Record<string, Handler> = {}\n\n for (const route of routes) {\n // The reserved route wins, because the worker answers it before the handler lookup. Say so\n // rather than leaving an author wondering why their function returns an event stream.\n if (RESERVED_ROUTES.has(route.name)) {\n log(\"warn\", `Function \"${route.name}\" is shadowed: the worker reserves that route`, {\n function: route.name,\n })\n continue\n }\n handlers[route.name] = await loadHandler(route)\n }\n\n return handlers\n}\n\n/**\n * The route's handler, or, when its module fails to import or exports no handler, one that answers\n * the route with a 500 saying why. The first such module used to stop the worker starting, so one\n * broken function took every function in the project down with it. The message goes out as JSON,\n * so the escape codes come out of it: a client has no terminal to colour.\n */\nasync function loadHandler(route: DiscoveredRoute): Promise<Handler> {\n try {\n // A module loaded by URL is typed `any`; read its exports as unknown until checked.\n const mod: unknown = await import(entrypointImportUrl(route.entrypoint))\n const handler = exportedHandler(mod)\n if (!isHandler(handler)) throw new Error('it has neither a default export nor a named \"handler\" export')\n return handler\n } catch (err) {\n const message = `Function \"${route.name}\" failed to load: ${errorText(err)}`\n log(\"error\", message, { function: route.name })\n return () => jsonError(\"function_load_failed\", message, 500)\n }\n}\n\n/**\n * Terminal escape codes. Deno colours a missing module's location in its message, piped or not,\n * and a handler's own error can carry them too.\n */\nconst TERMINAL_ESCAPES = /\\u001b\\[[0-9;?]*[A-Za-z]/g\n\n/**\n * What a thrown value says: an Error's message, anything else as a string, without escape codes,\n * since it goes out as JSON and a client has no terminal to colour.\n */\nfunction errorText(err: unknown): string {\n return (err instanceof Error ? err.message : String(err)).replace(TERMINAL_ESCAPES, \"\")\n}\n\n/** A JSON error answer, `{ error: code, message, ...extra }`, as every route of the worker gives one. */\nfunction jsonError(code: string, message: string, status: number, extra: Record<string, unknown> = {}): Response {\n return new Response(JSON.stringify({ error: code, message, ...extra }), {\n status,\n headers: { \"Content-Type\": \"application/json\" },\n })\n}\n\n/** The one route a pinned worker serves (a per-function or per-hook pod), or undefined. */\nfunction singleFunction(): string | undefined {\n return Deno.env.get(\"SUPATYPE_FUNCTION_NAME\")?.trim()\n}\n\nconst port = parseInt(Deno.env.get(\"PORT\") ?? \"8001\", 10)\n// Order matters: withhold and scrub, then import. See withholdServiceRoleKey and env-allowlist.ts.\nconst serviceRoleKey = await withholdServiceRoleKey()\nscrubProcessEnv()\nconst root = functionsRoot()\nconst routes = root ? await discoverRoutes(root, singleFunction()) : []\nconst handlers = await loadHandlers(routes)\n\n// Hooks are namespaced so one worker can serve both without a name in `hooks/` ever shadowing, or\n// being reachable as: a public function of the same name.\nconst hooksDir = hooksRoot()\nif (!root && !hooksDir) {\n throw new Error(\n \"SUPATYPE_FUNCTIONS_ROOT or SUPATYPE_HOOKS_ROOT is required (a worker with neither serves nothing)\",\n )\n}\nif (hooksDir) {\n const hookRoutes = await discoverRoutes(hooksDir, singleFunction())\n const hookHandlers = await loadHandlers(hookRoutes)\n for (const [name, handler] of Object.entries(hookHandlers)) {\n handlers[HOOKS_ROUTE_PREFIX + name] = handler\n }\n}\n\n// A worker pinned to one route still has to find it, and with two roots \"absent from this one\" is not\n// \"absent everywhere\": a per-hook pod names its hook and has no functions directory at all. Checked\n// once, after both roots, so the failure means what it says, and it stays a failure, because a pod\n// serving nothing would answer 404 to the API server, which reads as the hook refusing to answer and\n// fails every write to its table.\nconst single = singleFunction()\nif (single && Object.keys(handlers).length === 0) {\n throw new Error(\n `Handler \"${single}\" not found under ${root}` + (hooksDir ? ` or ${hooksDir}` : \"\"),\n )\n}\n\nconsole.log(\n `[functions-worker] ${Object.keys(handlers).length} handler(s) on :${port}` +\n (Deno.env.get(\"SUPATYPE_FUNCTION_NAME\") ? ` (single: ${Deno.env.get(\"SUPATYPE_FUNCTION_NAME\")})` : \"\"),\n)\n\n// Falls back to the hooks root: a per-hook worker has no functions directory, and the shared env file\n// is looked for beside whichever source this worker actually has.\nconst normalizedFunctionsDir = root || hooksDir\nconst sharedEnvPath =\n Deno.env.get(\"SUPATYPE_SHARED_ENV_FILE\") ?? `${normalizedFunctionsDir}/.env.local`\n\n\n\n/** The variables in the env file at `path`, read as the CLI and compose read one; none if it is absent. */\nasync function readEnvFile(path: string): Promise<Record<string, string>> {\n if (!path) return {}\n try {\n return parseEnvText(await Deno.readTextFile(path))\n } catch {\n return {}\n }\n}\n\n/**\n * The values `functions env set` gave a self-hosted project: the control plane's JSON map, which\n * compose names here. Without it a value set through the control plane never reached a function.\n * Read on every call, like the env files, so a set or unset is seen without a restart.\n */\nconst managedEnvPath = (Deno.env.get(\"SUPATYPE_FUNCTION_ENV_FILE\") ?? \"\").trim()\n\nasync function readManagedEnv(path: string = managedEnvPath): Promise<Record<string, string>> {\n if (!path) return {}\n let parsed: unknown\n try {\n parsed = JSON.parse(await Deno.readTextFile(path))\n } catch {\n return {}\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return {}\n return Object.fromEntries(Object.entries(parsed).filter((entry): entry is [string, string] => typeof entry[1] === \"string\"))\n}\n\n/**\n * The file of one function's own managed values: `fn.<name>.json`, in the directory of the managed\n * file, in the same JSON shape. Supatype Cloud writes one per function that has secrets of its own\n * (self-host keeps them in `.env.<name>.local`). Empty when there is no managed file, or when the name\n * is not a plain function name, so a route name can never reach outside that directory.\n */\nfunction functionManagedEnvPath(fnName: string): string {\n if (!managedEnvPath || !/^[A-Za-z0-9_-]+$/.test(fnName)) return \"\"\n const slash = Math.max(managedEnvPath.lastIndexOf(\"/\"), managedEnvPath.lastIndexOf(\"\\\\\"))\n return `${managedEnvPath.slice(0, slash + 1)}fn.${fnName}.json`\n}\n\n/**\n * The shared env file, then the managed values, then the function's own file, which wins, then the\n * function's own managed values, which win over all of those. They are read together: every call waits\n * for them.\n */\nasync function scopedEnvForFunction(fnName: string): Promise<Record<string, string>> {\n const [shared, managed, fnVars, fnManaged] = await Promise.all([\n readEnvFile(sharedEnvPath),\n readManagedEnv(),\n readEnvFile(`${normalizedFunctionsDir}/.env.${fnName}.local`),\n readManagedEnv(functionManagedEnvPath(fnName)),\n ])\n return { ...shared, ...managed, ...fnVars, ...fnManaged }\n}\n\n/**\n * The database URL a function may use, when the deployment gave the worker one: off unless the\n * operator set SUPATYPE_FUNCTIONS_DB_URL (see `FunctionContext.dbUrl`). Never `DATABASE_URL`: that\n * is the stack's own connection, and the scrub removes it before any function loads.\n */\nfunction dbUrlForFunctions(): string | undefined {\n const raw = Deno.env.get(\"SUPATYPE_DB_URL\")\n return raw === undefined || raw.trim() === \"\" ? undefined : raw\n}\n\n/** The stack's own origin, or null when this worker was not told how to reach it. */\nfunction stackOrigin(): string | null {\n const raw = Deno.env.get(\"SUPATYPE_INTERNAL_URL\") ?? Deno.env.get(\"SUPATYPE_URL\")\n if (raw === undefined || raw.trim() === \"\") return null\n try {\n return new URL(raw).origin\n } catch {\n return null\n }\n}\n\n/**\n * The project's public address, handed to every function as `ctx.publicUrl` (see FunctionContext).\n *\n * Read once, at start: it never differs between invocations, and a deployment that left it unset\n * should be told once rather than on every call. The fallback is `ctx.url`, which under compose is\n * an in-stack name, so a link built from it would reach nobody; the warning says so.\n */\nfunction resolvePublicUrl(): string {\n const configured = (Deno.env.get(\"SUPATYPE_PUBLIC_URL\") ?? \"\").trim()\n if (configured !== \"\") return configured\n const internal = Deno.env.get(\"SUPATYPE_URL\") ?? \"\"\n log(\n \"warn\",\n \"SUPATYPE_PUBLIC_URL is not set, so ctx.publicUrl falls back to ctx.url \" +\n `(${internal || \"unset\"}), which may be an address only this stack can reach`,\n )\n return internal\n}\n\nconst publicUrl = resolvePublicUrl()\n\n\n// `onListen` is supplied so Deno does not print its own \"Listening on …\" line. That line goes to\n// stderr, which this worker's patched console reports as `level: \"error\"`, and on cloud `level` is\n// a Loki label, so every startup would appear in the dashboards as an error.\n// Every address in its container; `functions serve` and native dev name 127.0.0.1.\nconst hostname = Deno.env.get(\"SUPATYPE_FUNCTIONS_HOST\") ?? \"0.0.0.0\"\nconst server = Deno.serve({\n hostname,\n port,\n onListen: ({ hostname, port: bound }) => {\n log(\"info\", `functions-worker listening on http://${hostname}:${bound}`)\n },\n}, async (req: Request): Promise<Response> => {\n const url = new URL(req.url)\n const pathParts = url.pathname.replace(/^\\/functions\\/v1\\/?/, \"\").split(\"/\").filter(Boolean)\n // A hook is addressed as `hooks/<name>`, so the first segment alone is not the handler key. With no\n // second segment no hook name is built: the path is looked up as the plain route \"hooks\", a 404\n // unless a function has that name, so `hooks/<name>` always carries a name the request sent.\n const fnName =\n pathParts[0] === \"hooks\" && pathParts[1]\n ? HOOKS_ROUTE_PREFIX + pathParts[1]\n : pathParts[0] ?? \"\"\n\n // Answered by the worker itself, before the handler lookup, so a project with no functions at all\n // still has a tail.\n if (RESERVED_ROUTES.has(fnName)) {\n if (fnName === \"_logs\") return tailResponse()\n if (fnName === \"_functions\") return functionListResponse(handlers)\n }\n\n // A hook the map names with no code here (a new hook whose deploy failed) cannot be reached: 503,\n // which the server's hook dispatch treats as unavailable and refuses the write for. A 404 read as\n // the hook rejecting the write, with a \"not found\" message. Any other name stays a 404\n // (unreachableHook).\n if (fnName.startsWith(HOOKS_ROUTE_PREFIX) && !handlers[fnName]) {\n const hook = fnName.slice(HOOKS_ROUTE_PREFIX.length)\n if (await unreachableHook(hook)) return jsonError(\"hook_unavailable\", `Hook \"${hook}\" is not deployed`, 503)\n }\n if (!fnName || !handlers[fnName]) {\n const message = fnName ? `Function \"${fnName}\" not found` : \"No function specified\"\n return jsonError(\"not_found\", message, 404, { available: publicFunctionNames(handlers) })\n }\n\n // Nothing goes into the process environment, so nothing has to be taken back out and nothing has\n // to be serialised. This used to hold a lock across the whole handler, which meant the worker ran\n // one invocation at a time: a function waiting on a third-party API blocked every other function\n // in the project for as long as it waited.\n const dbUrl = dbUrlForFunctions()\n const context: FunctionContext = {\n executionId: crypto.randomUUID(),\n functionName: fnName,\n url: Deno.env.get(\"SUPATYPE_URL\") ?? \"\",\n publicUrl,\n anonKey: Deno.env.get(\"SUPATYPE_ANON_KEY\") ?? \"\",\n // From the closure, not the environment: the key was withheld before any handler was imported,\n // and only a route the project granted it receives it here.\n ...(serviceRoleKey && (await serviceRoleGranted(fnName)) && { serviceRoleKey }),\n ...(dbUrl !== undefined && { dbUrl }),\n region: Deno.env.get(\"SUPATYPE_REGION\") ?? \"local\",\n env: await scopedEnvForFunction(fnName),\n }\n\n const start = performance.now()\n\n try {\n const inbound = { hookDepth: req.headers.get(HOOK_DEPTH_HEADER), clientAddress: endUserAddress(req.headers) }\n const response = await runInvocation(context, inbound, async () => handlers[fnName]!(req, context))\n log(\"info\", `${req.method} /functions/v1/${fnName} → ${response.status}`, {\n request_id: context.executionId,\n function: fnName,\n status: response.status,\n duration_ms: Number((performance.now() - start).toFixed(1)),\n })\n return response\n } catch (err) {\n const message = errorText(err)\n log(\"error\", message, {\n request_id: context.executionId,\n function: fnName,\n status: 500,\n duration_ms: Number((performance.now() - start).toFixed(1)),\n })\n return jsonError(\"function_error\", message, 500)\n }\n})\n// A restart of its container waited out the stop timeout without this, and must not cut off the\n// requests in flight (stop.ts). A log tail never ends on its own, so it is closed first.\nexitOnStop(() => {\n closeTails()\n return server.shutdown()\n})\n",
9
11
  "routes.ts": "// Generated from packages/shared/src/function-routes.ts by scripts/functions-worker-source.mjs. Do\n// not edit: change that file and run the script, so the worker and the control plane agree.\n/**\n * Which entries of a functions or hooks directory the functions worker serves, and by what route\n * name. The worker discovers its routes by this rule and a self-hosted control plane lists them by\n * it, so the list names exactly what answers. The worker cannot import this package: the generator\n * (scripts/functions-worker-source.mjs) copies this file into it as routes.ts, so it must import\n * nothing.\n */\n\n/** The module a directory route runs; a directory without one is not a route. */\nexport const FUNCTION_ENTRY_FILE = \"index.ts\"\n\n/**\n * The route the worker serves for `entry`, or undefined for an entry it skips. `_` and `.` prefixed\n * entries are never routes (`_shared`, `.git`). A directory is the route of its name, when it holds\n * {@link FUNCTION_ENTRY_FILE}, which the caller checks. A file is the route of its name without\n * `.ts`; a declaration file (`.d.ts`) and anything else is not one.\n */\nexport function functionRouteName(entry: string, kind: \"directory\" | \"file\"): string | undefined {\n if (entry.startsWith(\"_\") || entry.startsWith(\".\")) return undefined\n if (kind === \"directory\") return entry\n return entry.endsWith(\".ts\") && !entry.endsWith(\".d.ts\") ? entry.slice(0, -\".ts\".length) : undefined\n}\n\n/**\n * A hook name: letters of either case, digits, `-` and `_`, starting with a letter or digit. Wider\n * than a function name, because the CLI and Cloud take a hook's name from the schema and its folder\n * as written (`onUserCreate`): Cloud stores it as a ConfigMap key, and the worker skips a name that\n * starts with `_` or `.`. Still one path segment: nothing in it can name a parent, a separator or a\n * hidden entry.\n */\nexport const HOOK_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/\n\n/** The hook rule, said for a person. */\nexport const HOOK_NAME_RULE = 'use letters, digits, \"-\" and \"_\", starting with a letter or digit'\n\n/** Whether `name` passes the hook-name rule. */\nexport function isHookName(name: unknown): name is string {\n return typeof name === \"string\" && HOOK_NAME.test(name)\n}\n",
12
+ "stack-fetch.ts": "import { currentCall, type InboundCall } from \"./invocation.ts\"\n\n/** The hook-depth header a hook's calls back into the stack carry. */\nexport const HOOK_DEPTH_HEADER = \"x-supatype-hook-depth\"\n\n/** The end user's address, and the proof it comes from the project's own components (D14 option 2b). */\nexport const FORWARDED_FOR_HEADER = \"St-Forwarded-For\"\nexport const FORWARDING_SECRET_HEADER = \"St-Forwarding-Secret\"\n\nconst MAX_REDIRECTS = 20\nconst REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308])\n\n/**\n * The end user's address for a call this worker is serving: the `St-Forwarded-For` the server's proxy\n * or hook dispatch set, else the `X-Real-IP` the gateway wrote. The first value of either, or null.\n */\nexport function endUserAddress(headers: Headers): string | null {\n for (const name of [FORWARDED_FOR_HEADER, \"x-real-ip\"]) {\n const first = headers.get(name)?.split(\",\")[0]?.trim()\n if (first) return first\n }\n return null\n}\n\nexport interface StackFetchOptions {\n /** The stack's own origin, or null when this worker was not told how to reach it. Read per call. */\n origin(): string | null\n /** The forwarding secret, \"\" when the project has none. Held here, never in the environment. */\n forwardingSecret: string\n}\n\n/** The origin of `url`, or null when it is not an absolute URL. */\nfunction originOf(url: string): string | null {\n try {\n return new URL(url).origin\n } catch {\n return null\n }\n}\n\n/** What a call to the stack carries for the invocation making it: nothing, when there is nothing to say. */\nfunction stackHeaders(call: InboundCall, secret: string): Array<[string, string]> {\n const carried: Array<[string, string]> = []\n if (call.hookDepth !== null) carried.push([HOOK_DEPTH_HEADER, call.hookDepth])\n if (secret !== \"\" && call.clientAddress !== null) {\n carried.push([FORWARDED_FOR_HEADER, call.clientAddress], [FORWARDING_SECRET_HEADER, secret])\n }\n return carried\n}\n\n/**\n * Carry the hook-depth header, the end user's address and the forwarding secret onto calls a function\n * or hook makes back into the stack, and onto those calls only.\n *\n * Patched once, at startup, with no per-call state of its own: what a call carries comes from the\n * invocation store, so concurrent invocations cannot see each other's.\n *\n * \"The stack\" is an exact origin match, not a prefix: `http://kong:8100.example.com` starts with\n * `http://kong:8100` and is somebody else's host. And a redirect is followed here, a hop at a time,\n * rather than by `fetch`: a stack endpoint can redirect to another origin (a storage download goes\n * to a signed URL), and `fetch` keeps custom headers across origins, which would hand the secret to\n * whoever the stack redirects to. A hop that stays on the stack carries them again; one that leaves\n * it carries neither, nor `authorization`, as `fetch` itself would drop.\n */\nexport function installStackFetch(options: StackFetchOptions): void {\n const original = globalThis.fetch\n globalThis.fetch = (input: Request | URL | string, init?: RequestInit): Promise<Response> =>\n stackFetch(original, options, input, init, 0)\n}\n\nasync function stackFetch(\n original: typeof fetch,\n options: StackFetchOptions,\n input: Request | URL | string,\n init: RequestInit | undefined,\n hops: number,\n): Promise<Response> {\n const call = currentCall()\n const stack = options.origin()\n const url = input instanceof Request ? input.url : String(input)\n const carried = call === undefined ? [] : stackHeaders(call, options.forwardingSecret)\n if (stack === null || originOf(url) !== stack || carried.length === 0) return original(input, init)\n const request = new Request(input, init)\n for (const [name, value] of carried) request.headers.set(name, value)\n if (request.redirect !== \"follow\") return original(request)\n\n const replay = request.clone()\n const response = await original(new Request(request, { redirect: \"manual\" }))\n const location = response.headers.get(\"location\")\n if (!REDIRECT_STATUSES.has(response.status) || location === null) return response\n if (hops >= MAX_REDIRECTS) throw new TypeError(`too many redirects fetching ${url}`)\n await response.body?.cancel()\n return stackFetch(original, options, ...redirected(replay, response.status, new URL(location, url), stack), hops + 1)\n}\n\n/** The next hop of a redirect, as `fetch` would make it: a 303, or a POST after 301 or 302, becomes a GET. */\nfunction redirected(\n previous: Request,\n status: number,\n next: URL,\n stack: string,\n): [string, RequestInit] {\n const toGet = status === 303 ? previous.method !== \"HEAD\" : (status === 301 || status === 302) && previous.method === \"POST\"\n const headers = new Headers(previous.headers)\n if (next.origin !== stack) {\n for (const name of [FORWARDED_FOR_HEADER, FORWARDING_SECRET_HEADER, HOOK_DEPTH_HEADER, \"authorization\"]) headers.delete(name)\n }\n if (toGet) for (const name of [\"content-type\", \"content-length\", \"content-encoding\", \"content-language\", \"content-location\"]) headers.delete(name)\n return [\n next.href,\n {\n method: toGet ? \"GET\" : previous.method,\n headers,\n redirect: \"follow\",\n signal: previous.signal,\n ...(!toGet && previous.body !== null && { body: previous.body, duplex: \"half\" }),\n } as RequestInit,\n ]\n}\n",
10
13
  "stop.ts": "/**\n * The worker stops when it is told to. In its container it runs as PID 1, and PID 1 gets no default\n * action for SIGTERM or SIGINT: with no handler, `docker restart` and `docker stop` waited out the\n * whole stop timeout (10 s) before killing it, so every self-host deploy that restarted the worker\n * took more than ten seconds. The compose file also gives it an init (`init: true`).\n *\n * On SIGTERM it does not exit mid-request: a deploy restarts the worker, and exiting at once cut off\n * every invocation in flight. It stops taking requests, lets those it has finish, then exits; bounded\n * by {@link drainGraceMs}. SIGINT (Ctrl+C in dev or `functions serve`) and a second signal while\n * draining exit at once: someone at a terminal is not kept waiting.\n */\n\n/**\n * How long in-flight requests get to finish when nothing says otherwise: under the 5 s the dev\n * process manager waits before it kills the worker, so a stop in dev is never slower than a kill.\n */\nexport const DRAIN_GRACE_MS = 4_000\n\n/** The longest drain the environment may ask for; more would outlast any stop timeout in use. */\nexport const MAX_DRAIN_GRACE_MS = 60_000\n\n/**\n * The drain grace `SUPATYPE_FUNCTIONS_DRAIN_MS` asks for, in whole milliseconds, capped at\n * {@link MAX_DRAIN_GRACE_MS}; {@link DRAIN_GRACE_MS} when it is unset or not a whole number. The\n * self-host compose sets it under its stop_grace_period: there Docker allows 10 s, and a 4 s drain\n * cut off every function with more left at each restart (round 6b, N29).\n */\nexport function drainGraceMs(value: string | undefined): number {\n const text = value?.trim() ?? \"\"\n if (!/^\\d+$/.test(text)) return DRAIN_GRACE_MS\n return Math.min(Number(text), MAX_DRAIN_GRACE_MS)\n}\n\n/** What stopping needs of Deno, replaceable in tests. */\nexport interface StopHooks {\n os: string\n addSignalListener(signal: \"SIGTERM\" | \"SIGINT\", handler: () => void): void\n exit(code: number): void\n}\n\nconst DENO_HOOKS: StopHooks = {\n os: Deno.build.os,\n addSignalListener: (signal, handler) => Deno.addSignalListener(signal, handler),\n exit: (code) => Deno.exit(code),\n}\n\n/** `drain()`, or `graceMs`, whichever ends first; the timer is cleared either way. */\nasync function drainWithin(drain: () => Promise<void>, graceMs: number): Promise<void> {\n let timer: ReturnType<typeof setTimeout> | undefined\n const grace = new Promise<void>((done) => (timer = setTimeout(done, graceMs)))\n try {\n await Promise.race([drain().catch(() => undefined), grace])\n } finally {\n clearTimeout(timer)\n }\n}\n\n/**\n * On SIGTERM, drains with `drain` (closing the log tails and the server's `shutdown()`, which stops\n * taking requests and resolves once those in flight have finished) for at most `graceMs`, then exits\n * 0. SIGINT, and any signal while draining, exits at once. Not on Windows, where Deno takes no SIGTERM\n * listener and a process is stopped some other way.\n */\nexport function exitOnStop(\n drain: () => Promise<void>,\n hooks: StopHooks = DENO_HOOKS,\n graceMs = drainGraceMs(Deno.env.get(\"SUPATYPE_FUNCTIONS_DRAIN_MS\")),\n): void {\n if (hooks.os === \"windows\") return\n let draining = false\n const exitNow = (): void => hooks.exit(0)\n hooks.addSignalListener(\"SIGINT\", exitNow)\n hooks.addSignalListener(\"SIGTERM\", () => {\n if (draining) return exitNow()\n draining = true\n void drainWithin(drain, graceMs).then(exitNow)\n })\n}\n",
11
14
  };
12
15
  //# sourceMappingURL=functions-worker-source.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"functions-worker-source.js","sourceRoot":"","sources":["../../src/generated/functions-worker-source.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,8FAA8F;AAC9F,MAAM,CAAC,MAAM,uBAAuB,GAAqC;IACvE,WAAW,EAAE,62GAA62G;IAC13G,WAAW,EAAE,m4FAAm4F;IACh5F,eAAe,EAAE,0iKAA0iK;IAC3jK,YAAY,EAAE,+iQAA+iQ;IAC7jQ,SAAS,EAAE,69zBAA69zB;IACx+zB,WAAW,EAAE,ovEAAovE;IACjwE,SAAS,EAAE,w5GAAw5G;CACp6G,CAAA"}
1
+ {"version":3,"file":"functions-worker-source.js","sourceRoot":"","sources":["../../src/generated/functions-worker-source.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,8FAA8F;AAC9F,MAAM,CAAC,MAAM,uBAAuB,GAAqC;IACvE,WAAW,EAAE,q7HAAq7H;IACl8H,aAAa,EAAE,k1HAAk1H;IACj2H,WAAW,EAAE,m4FAAm4F;IACh5F,kBAAkB,EAAE,kwHAAkwH;IACtxH,eAAe,EAAE,wuLAAwuL;IACzvL,YAAY,EAAE,+iQAA+iQ;IAC7jQ,SAAS,EAAE,sr1BAAsr1B;IACjs1B,WAAW,EAAE,ovEAAovE;IACjwE,gBAAgB,EAAE,i0KAAi0K;IACn1K,SAAS,EAAE,w5GAAw5G;CACp6G,CAAA"}
@@ -1,18 +1,18 @@
1
1
  export declare const PINNED_IMAGES: {
2
2
  readonly engine: {
3
3
  readonly image: "supatype/schema-engine";
4
- readonly tag: "v0.10.0";
5
- readonly commit: "ae7b0f5c9df621b386fda6c36abce7ae114e16fb";
4
+ readonly tag: "v0.11.2";
5
+ readonly commit: "50ca56852398d6ed0346c44782f68273af7cd049";
6
6
  };
7
7
  readonly server: {
8
8
  readonly image: "supatype/server";
9
- readonly tag: "v2.4.0";
10
- readonly commit: "dfb9ad608ee84f29b27ec9965f21f6eb83cd8a11";
9
+ readonly tag: "v2.6.1";
10
+ readonly commit: "decc8f9cdc48cba7755e5e32250e21705786d5c5";
11
11
  };
12
12
  readonly postgres: {
13
13
  readonly image: "supatype/postgres";
14
- readonly tag: "17.2.12";
15
- readonly commit: "ab9020f7691dced4875634dc88dfe500968faa5a";
14
+ readonly tag: "17.2.16";
15
+ readonly commit: "ff4a061e5bc49eebbf8b881812d028b4774d474b";
16
16
  };
17
17
  };
18
18
  //# sourceMappingURL=release-images.d.ts.map
@@ -1,8 +1,8 @@
1
1
  // Generated from release/images.json by scripts/release-images.mjs. Do not edit: run
2
2
  // `bash scripts/pin.sh set <engine|server|postgres> <tag>`, which rewrites both.
3
3
  export const PINNED_IMAGES = {
4
- engine: { image: "supatype/schema-engine", tag: "v0.10.0", commit: "ae7b0f5c9df621b386fda6c36abce7ae114e16fb" },
5
- server: { image: "supatype/server", tag: "v2.4.0", commit: "dfb9ad608ee84f29b27ec9965f21f6eb83cd8a11" },
6
- postgres: { image: "supatype/postgres", tag: "17.2.12", commit: "ab9020f7691dced4875634dc88dfe500968faa5a" },
4
+ engine: { image: "supatype/schema-engine", tag: "v0.11.2", commit: "50ca56852398d6ed0346c44782f68273af7cd049" },
5
+ server: { image: "supatype/server", tag: "v2.6.1", commit: "decc8f9cdc48cba7755e5e32250e21705786d5c5" },
6
+ postgres: { image: "supatype/postgres", tag: "17.2.16", commit: "ff4a061e5bc49eebbf8b881812d028b4774d474b" },
7
7
  };
8
8
  //# sourceMappingURL=release-images.js.map
@@ -13,6 +13,10 @@
13
13
  * engine image. A refusal, an engine too old, or a config error is the answer as it is. A failed
14
14
  * fetch is remembered for the process, so an offline dev session does not try the download again
15
15
  * on every save, and the caller is told why once, after it has written with the image.
16
+ *
17
+ * A Docker project that names its engine image in `SUPATYPE_ENGINE_IMAGE` (shell or `.env`) pushes
18
+ * with that image, so it writes the generated files too (owner, 2026-11-15): a cached host engine
19
+ * older than the image refused a schema the image had just pushed. Unnamed, round 3 stands.
16
20
  */
17
21
  import type { ComposeEngine } from "./engine-client.js";
18
22
  import { type SupatypeProjectConfig } from "./project-config.js";
@@ -20,6 +24,11 @@ import { type SupatypeProjectConfig } from "./project-config.js";
20
24
  export interface GeneratedFilesEngineDeps {
21
25
  hostEngine: () => Promise<void>;
22
26
  composeEngine: (cwd: string, config: SupatypeProjectConfig) => Promise<ComposeEngine | undefined>;
27
+ /**
28
+ * SUPATYPE_ENGINE_IMAGE from the shell, else `.env`, or undefined when neither names one or it is
29
+ * only the line the CLI writes from `versions.engine`, which the host engine already matches.
30
+ */
31
+ namedImage: (cwd: string, config: SupatypeProjectConfig) => Promise<string | undefined>;
23
32
  }
24
33
  /** The engine to write with (undefined: the host program) and, the first time it fell back, why. */
25
34
  export interface EngineChoice {
@@ -1 +1 @@
1
- {"version":3,"file":"generated-files-engine.d.ts","sourceRoot":"","sources":["../src/generated-files-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAIvD,OAAO,EAA0B,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAExF,qDAAqD;AACrD,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/B,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAAA;CAClG;AAOD,oGAAoG;AACpG,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,aAAa,GAAG,SAAS,CAAA;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,kFAAkF;AAClF,eAAO,MAAM,eAAe,qGAAqG,CAAA;AAKjI,wEAAwE;AACxE,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,qBAAqB,EAC7B,IAAI,GAAE,OAAO,CAAC,wBAAwB,CAAM,GAC3C,OAAO,CAAC,YAAY,CAAC,CAavB"}
1
+ {"version":3,"file":"generated-files-engine.d.ts","sourceRoot":"","sources":["../src/generated-files-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAKvD,OAAO,EAA0B,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAExF,qDAAqD;AACrD,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/B,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAAA;IACjG;;;OAGG;IACH,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CACxF;AAcD,oGAAoG;AACpG,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,aAAa,GAAG,SAAS,CAAA;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,kFAAkF;AAClF,eAAO,MAAM,eAAe,qGAAqG,CAAA;AAKjI,wEAAwE;AACxE,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,qBAAqB,EAC7B,IAAI,GAAE,OAAO,CAAC,wBAAwB,CAAM,GAC3C,OAAO,CAAC,YAAY,CAAC,CAcvB"}
@@ -1,10 +1,19 @@
1
1
  import { hasEngineOverride, pinnedVersion } from "./binary-cache.js";
2
2
  import { BinaryUnavailable } from "./ensure-binary.js";
3
+ import { readEnvFile } from "./env-file.js";
3
4
  import { errorMessage } from "./error-message.js";
4
5
  import { resolveRuntimeProvider } from "./project-config.js";
5
6
  const DEFAULT_DEPS = {
6
7
  hostEngine: async () => (await import("./engine-client.js")).ensureEngine(),
7
8
  composeEngine: async (cwd, config) => (await import("./dev-compose.js")).projectComposeEngine(cwd, config),
9
+ namedImage: async (cwd, config) => {
10
+ const named = process.env["SUPATYPE_ENGINE_IMAGE"]?.trim() || readEnvFile(cwd)["SUPATYPE_ENGINE_IMAGE"]?.trim();
11
+ if (named === undefined || named === "")
12
+ return undefined;
13
+ // Loaded only here: the compose module is large, and `generate` on a native project never needs it.
14
+ const { composeDockerImageEnv } = await import("./self-host-compose.js");
15
+ return named === composeDockerImageEnv(config)["SUPATYPE_ENGINE_IMAGE"] ? undefined : named;
16
+ },
8
17
  };
9
18
  /** What a caller says, once it has written with the image, about the fallback. */
10
19
  export const ENGINE_FALLBACK = "The engine program could not be fetched, so the project's engine image wrote the generated files";
@@ -13,6 +22,8 @@ const unavailable = new Set();
13
22
  /** The engine to write generated files with: see the file's comment. */
14
23
  export async function generatedFilesEngine(cwd, config, deps = {}) {
15
24
  const use = { ...DEFAULT_DEPS, ...deps };
25
+ if (await pushesWithNamedImage(cwd, config, use))
26
+ return { engine: await namedImageEngine(cwd, config, use) };
16
27
  const version = pinnedVersion("engine", config) ?? "this build's";
17
28
  if (unavailable.has(version))
18
29
  return { engine: await imageOrThrow(cwd, config, use, undefined) };
@@ -28,6 +39,18 @@ export async function generatedFilesEngine(cwd, config, deps = {}) {
28
39
  return { engine, fellBack: errorMessage(err) };
29
40
  }
30
41
  }
42
+ async function pushesWithNamedImage(cwd, config, use) {
43
+ if (resolveRuntimeProvider(config) !== "docker" || hasEngineOverride(config))
44
+ return false;
45
+ return (await use.namedImage(cwd, config)) !== undefined;
46
+ }
47
+ /** The image SUPATYPE_ENGINE_IMAGE names, as compose runs it for a push. */
48
+ async function namedImageEngine(cwd, config, use) {
49
+ const image = await use.composeEngine(cwd, config);
50
+ if (image === undefined)
51
+ throw new Error("SUPATYPE_ENGINE_IMAGE names an engine image, but the project has no compose engine to run it");
52
+ return image;
53
+ }
31
54
  /** The project's engine image, or an error that keeps the host program's reason beside the image's. */
32
55
  async function imageOrThrow(cwd, config, use, hostError) {
33
56
  const host = hostError === undefined ? "the engine program could not be fetched earlier" : errorMessage(hostError);
@@ -1 +1 @@
1
- {"version":3,"file":"generated-files-engine.js","sourceRoot":"","sources":["../src/generated-files-engine.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,sBAAsB,EAA8B,MAAM,qBAAqB,CAAA;AAQxF,MAAM,YAAY,GAA6B;IAC7C,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,YAAY,EAAE;IAC3E,aAAa,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC;CAC3G,CAAA;AAQD,kFAAkF;AAClF,MAAM,CAAC,MAAM,eAAe,GAAG,kGAAkG,CAAA;AAEjI,+EAA+E;AAC/E,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAA;AAErC,wEAAwE;AACxE,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,GAAW,EACX,MAA6B,EAC7B,OAA0C,EAAE;IAE5C,MAAM,GAAG,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,IAAI,EAAE,CAAA;IACxC,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,cAAc,CAAA;IACjE,IAAI,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,CAAA;IAChG,IAAI,CAAC;QACH,MAAM,GAAG,CAAC,UAAU,EAAE,CAAA;QACtB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA;IAC9B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,CAAC,GAAG,YAAY,iBAAiB,CAAC,IAAI,sBAAsB,CAAC,MAAM,CAAC,KAAK,QAAQ,IAAI,iBAAiB,CAAC,MAAM,CAAC;YAAE,MAAM,GAAG,CAAA;QAC9H,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;QACxD,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACxB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,CAAA;IAChD,CAAC;AACH,CAAC;AAED,uGAAuG;AACvG,KAAK,UAAU,YAAY,CACzB,GAAW,EACX,MAA6B,EAC7B,GAA6B,EAC7B,SAAkB;IAElB,MAAM,IAAI,GAAG,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,iDAAiD,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;IAClH,IAAI,KAAgC,CAAA;IACpC,IAAI,CAAC;QACH,KAAK,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAC9C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,0DAA0D,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACvH,CAAC;IACD,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,SAAS,YAAY,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAA;IACvF,OAAO,KAAK,CAAA;AACd,CAAC"}
1
+ {"version":3,"file":"generated-files-engine.js","sourceRoot":"","sources":["../src/generated-files-engine.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,sBAAsB,EAA8B,MAAM,qBAAqB,CAAA;AAaxF,MAAM,YAAY,GAA6B;IAC7C,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,YAAY,EAAE;IAC3E,aAAa,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC;IAC1G,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE;QAChC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAAE,IAAI,EAAE,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC,uBAAuB,CAAC,EAAE,IAAI,EAAE,CAAA;QAC/G,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE;YAAE,OAAO,SAAS,CAAA;QACzD,oGAAoG;QACpG,MAAM,EAAE,qBAAqB,EAAE,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAA;QACxE,OAAO,KAAK,KAAK,qBAAqB,CAAC,MAAM,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAA;IAC7F,CAAC;CACF,CAAA;AAQD,kFAAkF;AAClF,MAAM,CAAC,MAAM,eAAe,GAAG,kGAAkG,CAAA;AAEjI,+EAA+E;AAC/E,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAA;AAErC,wEAAwE;AACxE,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,GAAW,EACX,MAA6B,EAC7B,OAA0C,EAAE;IAE5C,MAAM,GAAG,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,IAAI,EAAE,CAAA;IACxC,IAAI,MAAM,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAAA;IAC7G,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,cAAc,CAAA;IACjE,IAAI,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,CAAA;IAChG,IAAI,CAAC;QACH,MAAM,GAAG,CAAC,UAAU,EAAE,CAAA;QACtB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA;IAC9B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,CAAC,GAAG,YAAY,iBAAiB,CAAC,IAAI,sBAAsB,CAAC,MAAM,CAAC,KAAK,QAAQ,IAAI,iBAAiB,CAAC,MAAM,CAAC;YAAE,MAAM,GAAG,CAAA;QAC9H,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;QACxD,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACxB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,CAAA;IAChD,CAAC;AACH,CAAC;AAED,KAAK,UAAU,oBAAoB,CAAC,GAAW,EAAE,MAA6B,EAAE,GAA6B;IAC3G,IAAI,sBAAsB,CAAC,MAAM,CAAC,KAAK,QAAQ,IAAI,iBAAiB,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAA;IAC1F,OAAO,CAAC,MAAM,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,KAAK,SAAS,CAAA;AAC1D,CAAC;AAED,4EAA4E;AAC5E,KAAK,UAAU,gBAAgB,CAAC,GAAW,EAAE,MAA6B,EAAE,GAA6B;IACvG,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAClD,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,8FAA8F,CAAC,CAAA;IACxI,OAAO,KAAK,CAAA;AACd,CAAC;AAED,uGAAuG;AACvG,KAAK,UAAU,YAAY,CACzB,GAAW,EACX,MAA6B,EAC7B,GAA6B,EAC7B,SAAkB;IAElB,MAAM,IAAI,GAAG,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,iDAAiD,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;IAClH,IAAI,KAAgC,CAAA;IACpC,IAAI,CAAC;QACH,KAAK,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAC9C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,0DAA0D,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACvH,CAAC;IACD,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,SAAS,YAAY,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAA;IACvF,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -1,10 +1,37 @@
1
- export declare const SUPATYPE_GITIGNORE_MARKER = "# Supatype, local runtime (contains secrets in link.json)";
1
+ export declare const SUPATYPE_GITIGNORE_MARKER = "# Supatype: secrets (.env, .supatype/link.json) and local or generated files";
2
2
  /** The paths above, for a scaffold that composes its own `.gitignore` around them. */
3
3
  export declare const SUPATYPE_GITIGNORE_PATHS: readonly string[];
4
4
  export declare const SUPATYPE_GITIGNORE_BLOCK: string;
5
- export declare function isSupatypeGitignored(cwd: string): boolean;
5
+ /** Each of {@link SUPATYPE_GITIGNORE_PATHS} that a `.gitignore` holding `content` does not ignore yet. */
6
+ export declare function missingSupatypeIgnores(content: string): string[];
7
+ /**
8
+ * The line to print when some of `missing` are un-ignored by a `!` line in the `.gitignore` holding
9
+ * `content`; undefined when none are. Adding them overrides a choice the developer made, which keeps
10
+ * the secrets out of git but must not happen silently.
11
+ *
12
+ * 0.9.2 release test round 2 (R2-S6): init appended `.env` after a user's `!.env` and printed only
13
+ * "updated .gitignore (added Supatype's local files)".
14
+ */
15
+ export declare function negationOverrideNotice(content: string, missing: readonly string[]): string | undefined;
16
+ /**
17
+ * `content` with every one of Supatype's paths it does not already ignore added at the end, under
18
+ * the marker; unchanged when it ignores them all. The one way init and `link --fix-gitignore` add to
19
+ * a `.gitignore` the developer already has.
20
+ *
21
+ * 0.9.2 release test (N-RB1): init's merge had a short list of its own (`.supatype/` and
22
+ * `.env.*.local`) and this module's returned as soon as `.supatype/` was present, so in an existing
23
+ * create-vite or create-expo-app app `.env`, which holds the service role key, was not ignored.
24
+ * `missing` is {@link missingSupatypeIgnores} of `content`, for a caller that has it already.
25
+ */
26
+ export declare function withSupatypeIgnores(content: string, missing?: string[]): string;
6
27
  export declare function ensureSupatypeGitignore(cwd: string, opts?: {
7
28
  silent?: boolean;
8
29
  }): boolean;
30
+ /**
31
+ * One line when the project's `.gitignore` leaves out any path `link --fix-gitignore` would add.
32
+ *
33
+ * 0.9.2 release test round 2 (R2-S7): this checked only `.supatype/`, so `link` said nothing about a
34
+ * `.env`, which holds the service role key, that git would commit.
35
+ */
9
36
  export declare function warnIfLinkNotGitignored(cwd: string): void;
10
37
  //# sourceMappingURL=gitignore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gitignore.d.ts","sourceRoot":"","sources":["../src/gitignore.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,yBAAyB,8DAA8D,CAAA;AAgCpG,sFAAsF;AACtF,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAA2B,CAAA;AAEjF,eAAO,MAAM,wBAAwB,QAEpC,CAAA;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAKzD;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAkBzF;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAMzD"}
1
+ {"version":3,"file":"gitignore.d.ts","sourceRoot":"","sources":["../src/gitignore.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,yBAAyB,iFAAiF,CAAA;AAgCvH,sFAAsF;AACtF,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAA2B,CAAA;AAEjF,eAAO,MAAM,wBAAwB,QAEpC,CAAA;AAwBD,0GAA0G;AAC1G,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAGhE;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAKtG;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,WAAkC,GAAG,MAAM,CAMtG;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAkBzF;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAQzD"}