@antelopejs/dms-antelope-cloud 0.0.0 → 0.1.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 (224) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +448 -0
  3. package/dist/cloud-status.d.ts +13 -0
  4. package/dist/cloud-status.js +77 -0
  5. package/dist/config.d.ts +84 -0
  6. package/dist/config.js +104 -0
  7. package/dist/configured.d.ts +16 -0
  8. package/dist/configured.js +26 -0
  9. package/dist/connection/actions.d.ts +40 -0
  10. package/dist/connection/actions.js +120 -0
  11. package/dist/connection/announce.d.ts +8 -0
  12. package/dist/connection/announce.js +20 -0
  13. package/dist/connection/cloud.d.ts +60 -0
  14. package/dist/connection/cloud.js +87 -0
  15. package/dist/connection/content.d.ts +70 -0
  16. package/dist/connection/content.js +462 -0
  17. package/dist/connection/current.d.ts +26 -0
  18. package/dist/connection/current.js +28 -0
  19. package/dist/connection/device-flow.d.ts +16 -0
  20. package/dist/connection/device-flow.js +146 -0
  21. package/dist/connection/refusals.d.ts +51 -0
  22. package/dist/connection/refusals.js +85 -0
  23. package/dist/connection/repository.d.ts +28 -0
  24. package/dist/connection/repository.js +69 -0
  25. package/dist/connection/seal.d.ts +22 -0
  26. package/dist/connection/seal.js +47 -0
  27. package/dist/connection/store.d.ts +294 -0
  28. package/dist/connection/store.js +165 -0
  29. package/dist/connection/view.d.ts +39 -0
  30. package/dist/connection/view.js +39 -0
  31. package/dist/dashboard/actions.d.ts +40 -0
  32. package/dist/dashboard/actions.js +115 -0
  33. package/dist/dashboard/dockerfile.d.ts +34 -0
  34. package/dist/dashboard/dockerfile.js +71 -0
  35. package/dist/dashboard/service.d.ts +61 -0
  36. package/dist/dashboard/service.js +137 -0
  37. package/dist/dashboard/variables.d.ts +30 -0
  38. package/dist/dashboard/variables.js +34 -0
  39. package/dist/deployments/build-log.d.ts +39 -0
  40. package/dist/deployments/build-log.js +57 -0
  41. package/dist/deployments/cloud-steps.d.ts +77 -0
  42. package/dist/deployments/cloud-steps.js +132 -0
  43. package/dist/deployments/content.d.ts +61 -0
  44. package/dist/deployments/content.js +268 -0
  45. package/dist/deployments/deployment.d.ts +96 -0
  46. package/dist/deployments/deployment.js +3 -0
  47. package/dist/deployments/follow.d.ts +18 -0
  48. package/dist/deployments/follow.js +112 -0
  49. package/dist/deployments/ledger.d.ts +23 -0
  50. package/dist/deployments/ledger.js +359 -0
  51. package/dist/deployments/lifecycle.d.ts +123 -0
  52. package/dist/deployments/lifecycle.js +146 -0
  53. package/dist/deployments/live.d.ts +28 -0
  54. package/dist/deployments/live.js +54 -0
  55. package/dist/deployments/publish-read.d.ts +20 -0
  56. package/dist/deployments/publish-read.js +24 -0
  57. package/dist/deployments/refusals.d.ts +13 -0
  58. package/dist/deployments/refusals.js +35 -0
  59. package/dist/environments/actions.d.ts +86 -0
  60. package/dist/environments/actions.js +210 -0
  61. package/dist/environments/address.d.ts +60 -0
  62. package/dist/environments/address.js +149 -0
  63. package/dist/environments/content.d.ts +97 -0
  64. package/dist/environments/content.js +275 -0
  65. package/dist/environments/follower.d.ts +32 -0
  66. package/dist/environments/follower.js +114 -0
  67. package/dist/environments/pipeline.d.ts +58 -0
  68. package/dist/environments/pipeline.js +76 -0
  69. package/dist/environments/publish-targets.d.ts +18 -0
  70. package/dist/environments/publish-targets.js +55 -0
  71. package/dist/environments/roles.d.ts +73 -0
  72. package/dist/environments/roles.js +97 -0
  73. package/dist/frontend-module.d.ts +12 -0
  74. package/dist/frontend-module.js +25 -0
  75. package/dist/git/changed-files.d.ts +30 -0
  76. package/dist/git/changed-files.js +107 -0
  77. package/dist/git/changes.d.ts +89 -0
  78. package/dist/git/changes.js +162 -0
  79. package/dist/git/command.d.ts +51 -0
  80. package/dist/git/command.js +231 -0
  81. package/dist/git/promotion.d.ts +23 -0
  82. package/dist/git/promotion.js +46 -0
  83. package/dist/git/publish-input.d.ts +42 -0
  84. package/dist/git/publish-input.js +62 -0
  85. package/dist/git/publish-job.d.ts +82 -0
  86. package/dist/git/publish-job.js +99 -0
  87. package/dist/git/publish-steps.d.ts +90 -0
  88. package/dist/git/publish-steps.js +205 -0
  89. package/dist/git/publisher.d.ts +23 -0
  90. package/dist/git/publisher.js +206 -0
  91. package/dist/git/refs.d.ts +99 -0
  92. package/dist/git/refs.js +178 -0
  93. package/dist/git/refusal.d.ts +49 -0
  94. package/dist/git/refusal.js +70 -0
  95. package/dist/git/repository.d.ts +101 -0
  96. package/dist/git/repository.js +273 -0
  97. package/dist/git/versions.d.ts +99 -0
  98. package/dist/git/versions.js +174 -0
  99. package/dist/git/write-lock.d.ts +19 -0
  100. package/dist/git/write-lock.js +49 -0
  101. package/dist/index.d.ts +5 -0
  102. package/dist/index.js +59 -0
  103. package/dist/lifecycle.d.ts +8 -0
  104. package/dist/lifecycle.js +78 -0
  105. package/dist/logs/relay.d.ts +25 -0
  106. package/dist/logs/relay.js +138 -0
  107. package/dist/null-prototype.d.ts +7 -0
  108. package/dist/null-prototype.js +3 -0
  109. package/dist/overview/content.d.ts +40 -0
  110. package/dist/overview/content.js +172 -0
  111. package/dist/pages/changes.d.ts +32 -0
  112. package/dist/pages/changes.js +141 -0
  113. package/dist/pages/connection.d.ts +43 -0
  114. package/dist/pages/connection.js +295 -0
  115. package/dist/pages/deployment.d.ts +67 -0
  116. package/dist/pages/deployment.js +261 -0
  117. package/dist/pages/deployments.d.ts +46 -0
  118. package/dist/pages/deployments.js +266 -0
  119. package/dist/pages/environments.d.ts +34 -0
  120. package/dist/pages/environments.js +368 -0
  121. package/dist/pages/logs.d.ts +46 -0
  122. package/dist/pages/logs.js +140 -0
  123. package/dist/pages/navigation.d.ts +61 -0
  124. package/dist/pages/navigation.js +107 -0
  125. package/dist/pages/overview.d.ts +35 -0
  126. package/dist/pages/overview.js +201 -0
  127. package/dist/pages/project-guard.d.ts +32 -0
  128. package/dist/pages/project-guard.js +99 -0
  129. package/dist/pages/query.d.ts +6 -0
  130. package/dist/pages/query.js +14 -0
  131. package/dist/pages/resources.d.ts +37 -0
  132. package/dist/pages/resources.js +211 -0
  133. package/dist/pages/setup.d.ts +40 -0
  134. package/dist/pages/setup.js +271 -0
  135. package/dist/pages/slugs.d.ts +15 -0
  136. package/dist/pages/slugs.js +28 -0
  137. package/dist/pages/variables.d.ts +43 -0
  138. package/dist/pages/variables.js +327 -0
  139. package/dist/pages/version.d.ts +26 -0
  140. package/dist/pages/version.js +214 -0
  141. package/dist/pages/versions.d.ts +20 -0
  142. package/dist/pages/versions.js +115 -0
  143. package/dist/resources/apply.d.ts +15 -0
  144. package/dist/resources/apply.js +127 -0
  145. package/dist/resources/cards.d.ts +41 -0
  146. package/dist/resources/cards.js +211 -0
  147. package/dist/resources/connect.d.ts +66 -0
  148. package/dist/resources/connect.js +78 -0
  149. package/dist/resources/content.d.ts +26 -0
  150. package/dist/resources/content.js +158 -0
  151. package/dist/resources/format.d.ts +10 -0
  152. package/dist/resources/format.js +30 -0
  153. package/dist/resources/guard.d.ts +23 -0
  154. package/dist/resources/guard.js +60 -0
  155. package/dist/resources/modules.d.ts +23 -0
  156. package/dist/resources/modules.js +39 -0
  157. package/dist/resources/plan.d.ts +8 -0
  158. package/dist/resources/plan.js +93 -0
  159. package/dist/resources/read.d.ts +54 -0
  160. package/dist/resources/read.js +69 -0
  161. package/dist/resources/refusals.d.ts +15 -0
  162. package/dist/resources/refusals.js +33 -0
  163. package/dist/resources/routes.d.ts +32 -0
  164. package/dist/resources/routes.js +53 -0
  165. package/dist/setup/actions.d.ts +79 -0
  166. package/dist/setup/actions.js +188 -0
  167. package/dist/setup/apply.d.ts +37 -0
  168. package/dist/setup/apply.js +172 -0
  169. package/dist/setup/content.d.ts +50 -0
  170. package/dist/setup/content.js +440 -0
  171. package/dist/setup/rollout.d.ts +119 -0
  172. package/dist/setup/rollout.js +227 -0
  173. package/dist/setup/steps.d.ts +93 -0
  174. package/dist/setup/steps.js +95 -0
  175. package/dist/setup/storage.d.ts +29 -0
  176. package/dist/setup/storage.js +78 -0
  177. package/dist/setup/store.d.ts +214 -0
  178. package/dist/setup/store.js +174 -0
  179. package/dist/setup/volume.d.ts +31 -0
  180. package/dist/setup/volume.js +52 -0
  181. package/dist/slug.d.ts +7 -0
  182. package/dist/slug.js +26 -0
  183. package/dist/variables/actions.d.ts +76 -0
  184. package/dist/variables/actions.js +185 -0
  185. package/dist/variables/content.d.ts +69 -0
  186. package/dist/variables/content.js +310 -0
  187. package/dist/variables/decide.d.ts +27 -0
  188. package/dist/variables/decide.js +155 -0
  189. package/dist/variables/decided-dialog.d.ts +11 -0
  190. package/dist/variables/decided-dialog.js +129 -0
  191. package/dist/variables/decided.d.ts +80 -0
  192. package/dist/variables/decided.js +240 -0
  193. package/dist/variables/dialogs.d.ts +8 -0
  194. package/dist/variables/dialogs.js +219 -0
  195. package/dist/variables/model.d.ts +106 -0
  196. package/dist/variables/model.js +156 -0
  197. package/dist/variables/project-config.d.ts +117 -0
  198. package/dist/variables/project-config.js +248 -0
  199. package/dist/variables/read.d.ts +33 -0
  200. package/dist/variables/read.js +118 -0
  201. package/dist/web-url.d.ts +9 -0
  202. package/dist/web-url.js +19 -0
  203. package/frontend-vue/app/components/BuildLog.vue +99 -0
  204. package/frontend-vue/app/components/ChangedFiles.vue +165 -0
  205. package/frontend-vue/app/components/DashboardEnvironments.vue +102 -0
  206. package/frontend-vue/app/components/LogLine.vue +33 -0
  207. package/frontend-vue/app/components/LogViewer.vue +314 -0
  208. package/frontend-vue/app/components/PublishChipIcon.vue +39 -0
  209. package/frontend-vue/app/components/PublishForm.vue +505 -0
  210. package/frontend-vue/app/components/PublishPopover.vue +90 -0
  211. package/frontend-vue/app/components/PublishRoute.vue +222 -0
  212. package/frontend-vue/app/composables/usePublishSummary.ts +80 -0
  213. package/frontend-vue/app/plugins/publish-chip.client.ts +44 -0
  214. package/frontend-vue/app/types/publishing.ts +154 -0
  215. package/frontend-vue/app/utils/build-log.ts +96 -0
  216. package/frontend-vue/app/utils/changed-files.ts +142 -0
  217. package/frontend-vue/app/utils/log-line.ts +15 -0
  218. package/frontend-vue/app/utils/log-stream.ts +361 -0
  219. package/frontend-vue/app/utils/publish-state.ts +299 -0
  220. package/frontend-vue/dms.frontend.ts +27 -0
  221. package/frontend-vue/i18n/locales/antelope-cloud-en-GB.json +110 -0
  222. package/frontend-vue/package.json +38 -0
  223. package/frontend-vue/pnpm-lock.yaml +2697 -0
  224. package/package.json +115 -4
package/README.md ADDED
@@ -0,0 +1,448 @@
1
+ <a href="https://github.com/AntelopeJS/dms"><img data-illustration src="./.github/readme/strip.svg" width="100%" alt="DMS ANTELOPEJS CLOUD: part of AntelopeJS DMS, the open-source back office. A glowing button reads Star AntelopeJS DMS."></a>
2
+
3
+ <div align="center">
4
+
5
+ # `@antelopejs/dms-antelope-cloud`
6
+
7
+ <a href="https://www.npmjs.com/package/@antelopejs/dms-antelope-cloud"><img alt="npm" src="https://img.shields.io/npm/v/@antelopejs/dms-antelope-cloud?style=for-the-badge&labelColor=000000&color=000000" data-illustration></a> <a href="./LICENSE"><img alt="License" src="https://img.shields.io/npm/l/@antelopejs/dms-antelope-cloud?style=for-the-badge&labelColor=000000&color=000000" data-illustration></a> <a href="https://discord.gg/g4pFt6eXqu"><img alt="Discord" src="https://img.shields.io/badge/Discord-18181B?logo=discord&style=for-the-badge&color=000000" data-illustration></a> <a href="https://github.com/AntelopeJS/dms"><img data-illustration alt="Star AntelopeJS DMS" src="https://img.shields.io/github/stars/AntelopeJS/dms?label=Star%20AntelopeJS%20DMS&style=for-the-badge&labelColor=000000&color=000000&logo=github"></a>
8
+
9
+ **Connect an [AntelopeJS DMS](https://github.com/AntelopeJS/dms) project to AntelopeJS Cloud and publish it.**
10
+
11
+ [All modules](https://github.com/AntelopeJS/dms#modules)
12
+
13
+ </div>
14
+
15
+ `@antelopejs/dms-antelope-cloud` is the DMS module that connects a DMS project to AntelopeJS Cloud and publishes it. It adds an **AntelopeJS Cloud** entry to the DMS sidebar, under `/modules/antelope-cloud`.
16
+
17
+ The sidebar has the pages of the Publishing design, grouped as Release, Environments and AntelopeJS Cloud. These pages work:
18
+
19
+ - **Unpublished changes, Versions and each version's page.** They publish the project's git repository and list its versions, as [Publishing](#publishing) describes.
20
+ - **Connection.** The owner signs the DMS workspace in to AntelopeJS Cloud with a device code, chooses the cloud project it publishes, sees the GitHub repository it builds from, and disconnects the project or signs out. In an AntelopeJS Cloud development environment the connection is given by the `managed` option instead, and the page only shows it. The page also shows the AntelopeJS Cloud API the module talks to and whether that API answers its health check.
21
+ - **First-run setup.** Six steps put the project online: connect, project, repository, plan, apply, done. The sidebar does not list it: while this DMS has no project, the Overview, Environments and Connection pages lead to it, and once the plan is applied the owner lands on the Overview. The owner plans a new project, named after the repository's folder and placed in a region AntelopeJS Cloud offers, or links one the workspace has, then picks the stages to add beside Production. Nothing is created on AntelopeJS Cloud before the plan is applied. When AntelopeJS Cloud refuses the apply because it cannot see the repository, the page keeps a notice that says how to give it access, until the project is planned again or an apply gets past the repository. Applying it creates the project, whose Production builds `env/production` of the GitHub repository of the `origin` remote, links the project to that repository and creates each chosen stage with the services of Production. Each part reads what exists first, so applying again after a failure creates only what is missing. The apply never takes over a project the plan did not create. After an answer AntelopeJS Cloud lost, or under a name another run of the plan asked for without a refusal, it publishes the project with the planned name only when that project is in the planned region and builds from this repository, and refuses any other. Once AntelopeJS Cloud refused every run that asked for it, or once the connection publishes a project or stops publishing one, the plan no longer counts that project as its own, so a project someone else then creates under the name is refused too. A run whose creation is refused for its name while another run of the plan published that very project publishes it too. A project the plan creates also gets its address: the app of Production, then of each stage, listens on the port of the first `http` server `antelope.config.ts` gives `@antelopejs/api`, and is opened to the internet. An environment that has an address is left as it is, and so is every environment of a project the plan links. When the file names no such port, or one outside 1024 to 65535, the plan says so, applies everything else and opens nothing.
22
+ - **Environments.** Each environment is a branch AntelopeJS Cloud builds and serves. The page lists the release pipeline first, Preview, Staging then Production, with what each one serves and a build that failed while the previous version kept the traffic, then the other environments. The owner promotes the version a stage serves to the next stage, as [The release pipeline](#the-release-pipeline) describes, creates an environment and deletes one that is not protected. An environment without an address offers **Give it an address**, which sets that same port on its one app service and opens it to the internet after a dialog says so; an environment that runs several app services is left to AntelopeJS Cloud. The dashboard of the project is not an app service: the page shows its address in a column of its own, and an environment that runs none offers **Add the dashboard** when the repository has a `frontend.Dockerfile`, as [The dashboard](#the-dashboard) describes.
23
+ - **Overview.** It shows the workspace, the project, its region and the repository it builds from, what each stage of the pipeline serves, and the git commands that add a GitHub remote when the repository the module publishes has none. A project with one environment gets a hint to add Staging.
24
+ - **Resources.** The owner sees what AntelopeJS Cloud runs for each environment of the chosen project, derived from the modules in the running project's `antelope.config.ts`: the databases that run, the ones the plan creates, and the needs Cloud cannot provide, each with the figures the Cloud API gives. A banner tells how many dependencies are not running yet, and **Review plan** opens the plan as Cloud computes it, with its cost, its limits and every refusal. The plan can be applied only when Cloud accepts it, and the backend applies it with the stored token. The page also answers, for an environment name, what the next version would add there, as a banner the publish form can show. Applying the plan also connects the app to its databases: each app service of the environment, which leaves out its databases and the dashboard, gets the variable the project's `envOverrides` feed the module's `config.url` from, following the connection variable the database publishes, so its value never reaches this server. A service that holds a variable of that name keeps it. A database the app is not connected to shows a banner with a **Connect** action, and a database no `envOverrides` entry reaches shows the line to add.
25
+ - **Variables.** The owner lists and edits the variables of each environment, and has AntelopeJS Cloud set the ones it can decide, as [The variables](#the-variables) describes.
26
+ - **Deployments.** Every deployment AntelopeJS Cloud ran for the project, newest first: its environment, status, trigger, start and duration, with In progress, Failed and Rollbacks tabs. A deployment that still runs updates on screen without a reload. Opening one shows its route from Queued to Live, where a failed one stopped and what its environment still serves, and offers to roll the environment back to it. A deployment whose build failed links that build's log: followed, the link shows the end of the log on the same page, read from AntelopeJS Cloud at that moment, 300 lines at most. The page opens with the [What's live widget](#whats-live-widget).
27
+ - **Logs.** What a service of an environment prints, streamed live, with a search and a level filter. The page says when the environment sleeps, and when the stream dropped and is resuming; it replays the lines it missed.
28
+
29
+ The sign-in runs on the DMS backend: the browser only shows the code to confirm and the link to confirm it at. The backend keeps one AntelopeJS Cloud token per DMS workspace, encrypted with the `secretKey` option in the module's MongoDB collection, and never sends it to the browser.
30
+
31
+ Every call to AntelopeJS Cloud runs on the DMS backend with that token, the log stream included: the browser reads the Logs page's own stream route, which relays the Cloud's. The Deployments list reads the Cloud's project deployments route; while the Cloud answers it with 404, the list is composed from each environment's serving and target deployments and its services' histories, and a deployment only those histories name shows `—` for its number.
32
+
33
+ Module pages are for the platform owner only, like every DMS module page.
34
+
35
+ ## The release pipeline
36
+
37
+ An environment named `preview`, `staging` or `production` is a stage of the release pipeline, in that order. Pull-request previews take no part in it. A promotion puts the commit an environment serves on the next stage the project has, and git carries it, as it carries a publish:
38
+
39
+ - The next stage tracks its own `env/<name>` branch, and no other environment tracks it. From the repository at `repositoryPath`, the module pushes the commit to that branch alone, as `<commit>:refs/heads/env/<name>` with `--force-with-lease` against the commit origin held when the promotion read it. The local `env/<name>` branch stays where it is, checked out or not. The push makes AntelopeJS Cloud deploy the commit, and the module asks it nothing more, so the commit is built once.
40
+ - Origin's `env/<name>` holds the commit already, as after a promotion whose build failed or whose answer was lost. A push would start no build, so the module reads the next stage again. It refuses when the stage serves the commit already, answers with the deployment of the commit when one is queued, building, checking or switching, and otherwise asks AntelopeJS Cloud to deploy the commit with `environments.promote`. When AntelopeJS Cloud has not yet listed the deployment of the push, as on a second click right after the first, the commit is built twice, and the newer deployment supersedes the older.
41
+ - The next stage tracks no branch, as an environment the CLI deploys or a Production created without a repository. The module asks AntelopeJS Cloud to deploy the commit with `environments.promote`, and writes nothing in git.
42
+ - The next stage tracks another branch: one that is not an `env/*` branch, the `env/` branch of another environment, or a branch another environment tracks too, which the push would deploy as well. The module refuses the promotion.
43
+
44
+ The version the next stage serves keeps the traffic until the new one passes its health check. The route answers 202 once the push or the request is done. The module then reads the next stage every 5 seconds, for at most 10 minutes, until it serves the commit or its build fails, and the open Environments and Overview pages show the deployment build, then serve or fail, without a reload. A restart of the server stops following, and a reload still shows where the deployment stands.
45
+
46
+ The module also refuses a promotion from the last stage, from an environment outside the pipeline, and from one that serves nothing or a version without a commit, such as a CLI upload. Before a push, it refuses while a publish runs, when `repositoryPath` is not the root of a work tree or has no origin that answers, and when the repository lacks the commit, which a fetch of origin brings. When origin refuses the push, because the branch moved since the module read it or because the server may not push there, the promotion stops and AntelopeJS Cloud is asked nothing.
47
+
48
+ Promotions that push take their turn one after the other in the server, so a second click waits for the first, then finds origin holding the commit and answers 202. A publish refuses to begin while a promotion runs or waits for its turn, and a promotion refuses while a publish runs, so no `env/*` branch moves under a running publish.
49
+
50
+ AntelopeJS Cloud refuses an environment past the plan's allowance. The module says so in the words of `environment_limit`, and guesses no plan on its own.
51
+
52
+ ## The dashboard
53
+
54
+ A DMS is two services on AntelopeJS Cloud: the API, built by the AntelopeJS recipe, and the dashboard, built by the `frontend.Dockerfile` at the root of the repository, as the DMS starter ships it. The module puts both online from the one repository.
55
+
56
+ - **Where it comes from.** The project has a dashboard when the work tree the module publishes has `frontend.Dockerfile` at its root. Its port is the first port of the last `EXPOSE` of that file, 3000 when it states none. A port outside 1024 to 65535 is one AntelopeJS Cloud runs no service on: the plan says so and creates no dashboard.
57
+ - **First-run setup.** For a project the plan creates, the plan lists a **Dashboard** line, and the apply creates the service `dashboard` in Production once the app has its address and before the stages, so that each stage AntelopeJS Cloud creates with the services of Production gets its own. The service builds the same repository with `frontend.Dockerfile`, listens on its port and is open to the internet on an address of its own. A project the plan links keeps the services it has.
58
+ - **A project set up before.** On the Environments page, an environment that runs no dashboard offers **Add the dashboard**, which does the same for that environment after a dialog says so.
59
+ - **Running it again.** An environment that runs a dashboard keeps it: one without an address gets its port and its address, one with an address is left as it is.
60
+ - **Which service is which.** One service that is not a database is the app. Of several, the dashboard is the one whose settings on AntelopeJS Cloud name a Dockerfile; when AntelopeJS Cloud does not say what builds a service, the one named `dashboard`. Everything the module says of "the app", its port, its address and the database connections, means the API service.
61
+ - **What it needs.** An AntelopeJS Cloud that knows the Dockerfile of a repository service, and the `@antelopejs/cloud-sdk` release that creates such a service.
62
+
63
+ ## The variables
64
+
65
+ The Variables page lists, for each environment of the project, the variables its services hold and the ones they lack.
66
+
67
+ - **What is listed.** A variable a resource wires, one the owner set, plain or secret, and a missing one. A secret is write-only: AntelopeJS Cloud never sends its value back, and no answer of the page carries one.
68
+ - **What is missing.** In an environment without a dashboard, an `envOverrides` key of the running project's `antelope.config.ts` that no service holds. In an environment that runs a dashboard, it is told per service: an `envOverrides` key the app lacks, whatever the dashboard holds, and each variable a dashboard cannot start without that the dashboard lacks: `DMS_API_BASE_URL`, `DMS_CLIENT_BASE_URL`, `DMS_SESSION_SECRET` and `DMS_BOOTSTRAP_SECRET`. The row names the service, and **Set value** sets it there.
69
+ - **What AntelopeJS Cloud can decide.** The banner offers one action per environment, **Set N values on** the environment, for an environment that runs one app service. A dialog lists first each variable it sets, on which service, and each missing one it leaves, with the reason. It decides from the config path an `envOverrides` key feeds, by the npm package of the module:
70
+ - the app's address for `publicBaseUrl` of `@antelopejs/api`, and for the dashboard's `DMS_API_BASE_URL`;
71
+ - the dashboard's address for `clientBaseUrl` of `@antelopejs/dms`, and for the dashboard's `DMS_CLIENT_BASE_URL`;
72
+ - `X-Client-IP`, the header AntelopeJS Cloud's gateway overwrites with the client's address, for `auth.clientIpHeader` of `@antelopejs/dms`, and for the dashboard's `DMS_CLIENT_IP_HEADER`;
73
+ - a generated secret for the signing secrets the project owns: `auth.jwtSecret` and `htmlRender.serviceSecret` of `@antelopejs/dms`, `secret` of `@antelopejs/auth-jwt`, and the dashboard's `DMS_SESSION_SECRET`;
74
+ - one generated secret, the same on both, for `frontend.bootstrapSecret` of `@antelopejs/dms` on the app and `DMS_BOOTSTRAP_SECRET` on the dashboard;
75
+ - `DMS_SETUP_TOKEN` on the app of a project that loads `@antelopejs/dms`: the token the first owner of the deployed instance registers with.
76
+ - **What it leaves.** Everything else: an SMTP password, a storage path, a database name, an API key of another service, whatever its name. A database's connection string is left to the Resources page. An address is left while the service it names has none. The shared secret is generated for the app and the dashboard together or not at all, since nobody can read a secret back: when one of them holds it, when the dashboard does not run yet, or when no `envOverrides` entry hands it to the app, it stays with the owner.
77
+ - **What it never does.** It replaces no value a service holds: the plan is computed again when the action runs, from what the services hold then. It sets nothing for the module itself: the deployed instance does not run this module, so no service gets `ANTELOPE_CLOUD_SECRET_KEY`.
78
+ - **The secrets.** Each is 32 random bytes from `crypto.randomBytes`, in hex, generated on the DMS backend when the action runs and sent to AntelopeJS Cloud as a secret variable. The module does not log it, store it, nor answer it, with one exception: the answer of the action that generated the setup token carries it, once, and the page copies it to the clipboard. No later answer has it; an owner who lost it removes `DMS_SETUP_TOKEN` and runs the action again. When AntelopeJS Cloud refuses the shared secret on one of the two services, the action takes it back from the other.
79
+
80
+ ## Layout
81
+
82
+ ```text
83
+ src/
84
+ ├── index.ts # lifecycle: parses the options, and loads the rest only when a secretKey is set
85
+ ├── lifecycle.ts # the configured module: registers pages, the table and the frontend
86
+ ├── configured.ts # whether the project set a secretKey, and what the module prints when it did not
87
+ ├── config.ts # the apiUrl, secretKey and repositoryPath options
88
+ ├── cloud-status.ts # the health probe and the rows the Connection page shows
89
+ ├── connection/ # the stored sign-in, its encryption, the device-flow poller, the refusals, the page's content
90
+ ├── environments/ # the release pipeline, promotion, creation and deletion, the app's address, what each service is, the Environments page's content
91
+ ├── dashboard/ # the dashboard service: its Dockerfile, its creation, its address, the repair action
92
+ ├── variables/ # the Variables rows, the project config read, the values AntelopeJS Cloud can decide, the page's content, dialogs and writes
93
+ ├── git/ # the repository: changes, versions, environments and the publish
94
+ ├── overview/ # the Overview page's content
95
+ ├── setup/ # the stored plan, the six steps, the apply and its rollout, the First-run setup page's content
96
+ ├── deployments/ # the deployment lifecycle table, the Cloud reads, the follower, rollback, the blocks' content
97
+ ├── logs/relay.ts # the Logs page's stream: one Cloud log stream relayed as server-sent events
98
+ ├── pages/navigation.ts # the sidebar table: groups, pages, stub texts
99
+ ├── pages/slugs.ts # the URL slugs of the module's pages
100
+ ├── pages/*.ts # one file per built page: its blocks and its routes
101
+ ├── resources/ # the project's modules, the one read of an environment, the plan, the apply, the database connections, the page's content
102
+ └── test/ # backend tests, the mock cloud API, the test harness
103
+ frontend-vue/ # the module's Vue frontend package: the Publishing components, the navbar chip, the log viewer, the English texts
104
+ playground/ # the development project that runs the module
105
+ e2e/ # the e2e suite: its config, one feature file and one journeys module per feature, and the e2e kit's Playwright config
106
+ scripts/check-leaks.mts # the leak check
107
+ scripts/check-product-name.mts # the product-name check
108
+ ```
109
+
110
+ ## Install
111
+
112
+ A project names the module in the `modules` of its `antelope.config.ts`. From the npm registry, once a version is published as [Package release](#package-release) describes:
113
+
114
+ ```typescript fragment
115
+ modules: {
116
+ "antelope-cloud": {
117
+ source: {
118
+ type: "package",
119
+ package: "@antelopejs/dms-antelope-cloud",
120
+ version: ">=0.0.1 <0.1.0",
121
+ },
122
+ config: { secretKey: process.env.ANTELOPE_CLOUD_SECRET_KEY },
123
+ },
124
+ }
125
+ ```
126
+
127
+ Use the version npm lists. This is the form a project that AntelopeJS Cloud builds needs: its build installs the module like any other package, and the deployed instance, which has no `secretKey`, leaves it out, as [Where the module runs](#where-the-module-runs) describes.
128
+
129
+ From this repository:
130
+
131
+ ```typescript fragment
132
+ modules: {
133
+ "antelope-cloud": {
134
+ source: {
135
+ type: "git",
136
+ remote: "https://github.com/AntelopeJS/dms-antelope-cloud.git",
137
+ branch: "main",
138
+ installCommand: ["pnpm install --frozen-lockfile", "pnpm build"],
139
+ },
140
+ config: { secretKey: process.env.ANTELOPE_CLOUD_SECRET_KEY },
141
+ },
142
+ }
143
+ ```
144
+
145
+ The git form needs read access to this repository and git credentials on every machine that installs the project, and it builds the module at each install. A build on AntelopeJS Cloud has no credentials for the repository, so a project that uses the git form cannot build there.
146
+
147
+ ## Configure the module
148
+
149
+ The module reads five options from the project's `antelope.config.ts`. [Publishing](#publishing) describes what `repositoryPath` is used for.
150
+
151
+ | Option | Default | What it does |
152
+ | --- | --- | --- |
153
+ | `apiUrl` | `https://api.antelopejs.cloud` | Base URL of the AntelopeJS Cloud API. The Connection page asks `GET <apiUrl>/api/cloud/health`, and the sign-in and project reads go there too. |
154
+ | `secretKey` | none | The secret the stored AntelopeJS Cloud tokens are encrypted with, at least 32 characters. The module derives an AES-256-GCM key from it with HKDF-SHA256. Changing it makes the stored tokens unreadable: each workspace then signs in again. Without it the module does not run, as [Where the module runs](#where-the-module-runs) describes. |
155
+ | `repositoryPath` | the folder the process runs in | Root of the project's git work tree. Publishing commits, tags and pushes it, a promotion pushes commits from it to origin's `env/<name>` branches, and the Overview, First-run setup and Connection pages show its origin and branch. A relative path resolves against the folder the process runs in. |
156
+ | `promotionFollow` | `{ intervalMs: 5000, limitMs: 600000 }` | How often and for how long, in milliseconds, the module reads an environment after a promotion to it, so that open pages show its deployment. |
157
+ | `managed` | none | `{ token, projectId }`: what an AntelopeJS Cloud development environment gives this instance, as [Where the module runs](#where-the-module-runs) describes. Both set, the module is connected to that project from its first start. Both left out or empty, as unset variables read, the owner signs in with a device code. |
158
+
159
+ `apiUrl` must be an absolute `http` or `https` URL, a `secretKey` that is set a string of at least 32 characters, the `promotionFollow` values positive whole numbers, and `managed` either both its `token` and its `projectId` or neither. The module refuses to start otherwise, and the error names the option.
160
+
161
+ ```typescript fragment
162
+ modules: {
163
+ "antelope-cloud": {
164
+ source: { type: "local", path: "../dms-antelope-cloud" },
165
+ config: {
166
+ apiUrl: "https://api.antelopejs.cloud",
167
+ secretKey: process.env.ANTELOPE_CLOUD_SECRET_KEY,
168
+ },
169
+ },
170
+ }
171
+ ```
172
+
173
+ ### Where the module runs
174
+
175
+ The module runs where the project is published from: a developer's checkout, or the one server that holds the project's git work tree. It does not belong on an instance AntelopeJS Cloud deployed. That instance has no git work tree, so there is nothing for it to publish. And the module stores an AntelopeJS Cloud token that can deploy the project, change its variables and read its logs: on the public instance, that token would let whoever takes over the instance redeploy it.
176
+
177
+ So the `secretKey` decides. Set it where you publish from, and leave it unset on the deployed services: do not add `ANTELOPE_CLOUD_SECRET_KEY` to the variables of a service on AntelopeJS Cloud. With no `secretKey`, or an empty one as an unset variable reads, the module stays out of the instance:
178
+
179
+ - it registers no page and no route, so the sidebar has no AntelopeJS Cloud entry and `/dms/pages/modules/antelope-cloud/...` answers 404;
180
+ - it declares no table and stores nothing;
181
+ - it gives the dashboard no frontend: `ajs dms dev`, `build` and `start` read the same option, so a dashboard built without the key does not bundle the module's components;
182
+ - it prints one line at startup, on the `antelope-cloud` log channel, saying that it is not running and that a deployed instance is meant to run without it.
183
+
184
+ A project whose build can install the module then keeps it in its `antelope.config.ts` with no condition around it: the same configuration starts the module in the checkout that has the key and leaves it out of the deployment that does not.
185
+
186
+ #### In an AntelopeJS Cloud development environment
187
+
188
+ A development environment that AntelopeJS Cloud runs for a project has nobody to approve a device code, so Cloud hands the module its connection through the `managed` option: a token limited to that one project, which can deploy and observe it, and the project's id. The starter passes both, read from `ANTELOPE_CLOUD_TOKEN` and `ANTELOPE_CLOUD_PROJECT_ID`, beside the `secretKey`, which the module still needs to run:
189
+
190
+ ```typescript fragment
191
+ config: {
192
+ secretKey: process.env.ANTELOPE_CLOUD_SECRET_KEY,
193
+ managed: {
194
+ token: process.env.ANTELOPE_CLOUD_TOKEN,
195
+ projectId: process.env.ANTELOPE_CLOUD_PROJECT_ID,
196
+ },
197
+ },
198
+ ```
199
+
200
+ The module is then connected from its first start:
201
+
202
+ - The connection is read from the options, never stored: it writes nothing to the `connections` collection, and the token never reaches the browser or any answer of a route. The Connection page reads connected, with the project and "Managed by AntelopeJS Cloud" for the account and the credentials, and offers no Connect, Choose project, Disconnect or Sign out. Their routes refuse with `managed_connection`, and the module starts no device sign-in.
203
+ - The token reaches its project only. The workspace's endpoints, which list or create projects and read onboarding, answer it 403, so the module never calls them: the first-run setup treats Connect and Project as done, reads the project, and opens at Plan once `origin` is on GitHub. The Overview offers it until the plan is applied. Applying the plan creates no project. It links the repository, then gives Production what a created project gets, the address of its app and its dashboard, and creates the stages you chose with the services of Production.
204
+ - A request AntelopeJS Cloud refuses with a 403 shows `cloud_forbidden` ("AntelopeJS Cloud does not allow this token here") and leaves the connection connected: only a 401 reads as a revoked sign-in, which on a managed connection asks for a restart of the environment and never to sign in again.
205
+
206
+ The playground sets `apiUrl` from the `ANTELOPE_CLOUD_API_URL` environment variable. When the variable is unset or empty, the playground talks to the production API. It sets `secretKey` from `ANTELOPE_CLOUD_SECRET_KEY`, and falls back to a development-only key when the variable is unset or empty. It sets `managed` from `ANTELOPE_CLOUD_TOKEN` and `ANTELOPE_CLOUD_PROJECT_ID`: with both unset or empty the playground signs in with a device code, and the mock cloud API accepts the token `mock-managed-token` for the project `prj-acme-shop` to try the managed connection.
207
+
208
+ ## Run the playground
209
+
210
+ Use the Node.js version that `.nvmrc` names, pnpm and Docker Compose, which supplies MongoDB and a local mail inbox.
211
+
212
+ ```bash
213
+ pnpm install
214
+ pnpm services:up
215
+ pnpm dev
216
+ ```
217
+
218
+ In a second terminal, once the backend prints its API address, start the dashboard:
219
+
220
+ ```bash
221
+ pnpm frontend:dev
222
+ ```
223
+
224
+ Open the URL the dashboard prints, complete onboarding to create the owner, then open **Modules → AntelopeJS Cloud**. The backend listens on port 5010 and the dashboard on port 3001.
225
+
226
+ To run the playground against the mock cloud API instead of the production API, build it with `pnpm build:test`, start it with `node dist-test/test/mock-cloud-cli.js --port 4010`, and start the backend with `ANTELOPE_CLOUD_API_URL=http://127.0.0.1:4010 pnpm dev`.
227
+
228
+ ## Test it
229
+
230
+ | Command | What it runs |
231
+ | --- | --- |
232
+ | `pnpm run checks` | Typecheck, lint, format, knip, `pnpm test`, size, suppression and sync checks |
233
+ | `pnpm test` | The Vitest suite of `frontend-vue/` |
234
+ | `pnpm test:backend` | Builds the module and `src/test/`, then `ajs module test` boots the module with the playground's providers on an in-memory MongoDB |
235
+ | `pnpm test:backend:shard <index> <total>` | The same build, then shard `<index>` of `<total>` of the backend test files, split by the seconds `scripts/backend-shard-times.json` records per file. CI runs the backend tests as three shards. `node scripts/backend-shard.mts <index> <total> --list` prints a shard's files |
236
+ | `pnpm backend-shard:test` | The `node:test` suite of the shard split |
237
+ | `pnpm e2e` | Builds the mock cloud API, then runs `playwright test -c e2e` through the `@antelopejs/dms/e2e` kit: Playwright starts the mock cloud API, the kit starts one run of the playground with its own MongoDB, ports and built dashboard, and each journey of `e2e/journeys/` drives the dashboard in Chromium on a fresh database. `pnpm e2e --grep @smoke` runs the set a pull request runs |
238
+ | `pnpm leaks` | The leak check |
239
+ | `pnpm leaks:test` | The `node:test` suite of the leak check |
240
+ | `pnpm product-name` | Fails on any tracked text that names the product other than "AntelopeJS Cloud". `pnpm lint` runs it |
241
+ | `pnpm product-name:test` | The `node:test` suite of the product-name check |
242
+ | `pnpm build` | Compiles the published module to `dist/`, without the tests |
243
+ | `pnpm frontend:verify` | Builds and type-checks the frontend against the installed DMS |
244
+
245
+ Before the first `pnpm e2e`, install Chromium with `pnpm exec playwright install chromium`. The run takes free ports of its own, so it runs beside `pnpm dev` and `pnpm frontend:dev`; only its mock cloud API listens on the fixed port 4010, so stop a mock you started there. The first run builds the dashboard, which takes a few minutes; a later run reuses that build from `~/.cache/dms-e2e/frontend` while its inputs are unchanged. Each journey records its checks and a screenshot of each step under `evidence/<feature>/<journey>/` of the run's folder, in `DMS_E2E_RUNS` (the system temp folder's `dms-e2e/` by default), along with the run's logs.
246
+
247
+ CI picks the journeys by event. A pull request runs the `@smoke` journeys, or all of them once it carries the `ci:full` label; the merge queue, a manual dispatch and a push to `main` run all of them. Every run splits its journeys across two jobs with Playwright's `--shard`, and the nightly run merges the shards' reports.
248
+
249
+ The journeys build their repositories with a bare repository as origin. A journey that needs a GitHub remote names origin `https://github.com/acme/acme-shop.git` and maps that URL to the bare repository with `url.<bare>.insteadOf`, so the pages read a GitHub remote while every push stays on the machine. The mock cannot see a push, so a journey delivers one with `POST /__mock/push`.
250
+
251
+ No test calls a real AntelopeJS Cloud. The backend tests and the e2e run talk to a mock API, `src/test/mock-cloud.ts`, which records the method and path of every request it receives. Unknown routes answer 404 with `{ "error": "not_found" }`. It answers these Cloud API routes:
252
+
253
+ | Route | What it does |
254
+ | --- | --- |
255
+ | `GET /api/cloud/health` | Answers the health answer the tests set, `{ "status": "ok", "revision": "mock-revision" }` at start |
256
+ | `POST /api/cloud/cli/device` | Issues a new device code with the user code `MOCK-CODE`, a 1 s polling interval and a 15 min expiry |
257
+ | `POST /api/cloud/cli/token` | Answers 400 `authorization_pending` until the device code is decided, then a token for the workspace `Acme` once, `access_denied` or `expired_token`. A code traded already, or unknown, answers 400 `invalid_grant` |
258
+ | `GET /api/cloud/projects/` | Lists the workspace's projects, `acme-shop` at start, to a token it issued, and answers 401 to any other |
259
+ | `GET /api/cloud/projects/{id}` | Answers one project with the environments and services the environment routes answer, a service `running` once it runs a revision and `pending` before, or 404, to a token it issued, and answers 401 to any other |
260
+ | `GET /api/cloud/projects/{id}/environments/{environmentId}/resources` | Answers the databases the environment runs, `[]` at start. 404 for an unknown project or environment, 401 for a token it did not issue |
261
+ | `POST /api/cloud/projects/{id}/environments/{environmentId}/resource-plan` | Takes `{ "modules": [...] }` and answers the plan: what it would create, what already runs, what it cannot provide, the cost, the limits and the refusals of the workspace's tier. It knows the modules of its catalog (see `src/test/mock-cloud-resources.ts`) and ignores the others |
262
+ | `POST /api/cloud/projects/{id}/environments/{environmentId}/resource-plan/apply` | Creates what the plan lists, adds each database to the environment as a service no deployment ships a revision to, and answers `{ created, plan }`. Answers 409 with the error key of the plan's first refusal, such as `cloud.errors.resources.over_service_limit`, before any write, and 503 with `Retry-After` while it is set busy |
263
+ | `GET /api/cloud/projects/{id}/environments/{env}/variables` | Lists the variables of the environment's services. A secret's value is null, and so is the value of a variable that follows a published secret |
264
+ | `PUT /api/cloud/projects/{id}/environments/{env}/services/{svc}/variables/{key}` | Sets `{ value, secret? }`: 400 `invalid_value` for an empty value, 409 `variable_wired` for a variable that follows a resource, 422 `variable_refused` for the name the control route refuses. A new key is a secret unless `secret` is `false`; a held key keeps its kind |
265
+ | `DELETE /api/cloud/projects/{id}/environments/{env}/services/{svc}/variables/{key}` | Removes the variable, or answers 404 |
266
+ | `GET /api/cloud/projects/{id}/deployments` | Lists the project's deployments, newest first, filtered by `environmentId` and `status`. Answers 404 after `setProjectRoute(false)`, as the Cloud does until it ships the route |
267
+ | `GET /api/cloud/projects/{id}/environments` | Lists the project's environments. Each serves the last of its deployments that went live and targets its latest one. Its state is `sleep` while a service sleeps, `build` while its latest deployment rolls out, `waiting` before its first deployment, `live` while it serves one, and `failed` otherwise. `acme-shop` has `preview` and a protected `production` at start, each building `env/<name>` from `acme/acme-shop` |
268
+ | `GET /api/cloud/projects/{id}/environments/{environmentId}` | Answers one environment as the list does, or 404 |
269
+ | `GET /api/cloud/projects/{id}/environments/{environmentId}/health` | Answers each service's runtime as `running`, or `sleeping` after `setSleeping` |
270
+ | `GET /api/cloud/services/{id}/deployments` | Answers the service's active builds and revisions, each with its build's branch and commit |
271
+ | `POST /api/cloud/services/{id}/deployments/{revisionId}/rollback` | Moves the service back to the revision. Once every service of the environment runs one earlier deployment's revisions, it records a `rollback` deployment that serves them. Answers 409 for a revision it cannot go back to |
272
+ | `GET /api/cloud/services/{id}/logs` | Streams the service's lines as server-sent events from the line after `Last-Event-ID`, then each new one. Answers `not_deployed` for a service that runs no revision |
273
+ | `GET /api/cloud/deployments/{id}` | Answers one deployment, its builds and why it failed |
274
+ | `GET /api/cloud/deployments/{id}/progress` | Streams the deployment's status as server-sent events until it ends |
275
+ | `GET /api/cloud/builds/{id}/logs` | Streams the end of a build's log as server-sent events: the line naming the recipe, the newest `limit` lines oldest first, then `end`. A build is `build-<deployment id>`. Answers 404 for a build no deployment has and after `deployments.buildLogs.forget(id)`, and an `error` event during a log outage |
276
+ | `GET /api/cloud/onboarding/` | Answers that the workspace can create projects in `eu-central` or `us-east`, `eu-central` by default |
277
+ | `POST /api/cloud/projects/` | Creates a project `prj-<slug>` with a protected `production` environment. With a `repository` and a `branch`, Production builds that branch and has one service, `app`, building from the repository; without them it builds no branch and has no service. Answers 400 `cloud.errors.projects.invalid_slug` for a slug shorter than 2 characters or not a DNS label, 403 `cloud.errors.projects.repository_not_granted` for a repository the GitHub installation does not grant, and 409 `cloud.errors.projects.slug_taken` for a slug the workspace has |
278
+ | `GET /api/cloud/projects/{id}/repository` | Answers the repository the project links, else the one most of its services build from: `acme/acme-shop` for `acme-shop` at start |
279
+ | `PUT /api/cloud/projects/{id}/repository` | Links a repository the GitHub installation grants, `acme/acme-shop` at start. Answers 403 `cloud.errors.projects.repository_not_granted` for any other |
280
+ | `POST /api/cloud/projects/{id}/environments` | Creates an environment with the services of `cloneFrom`. Answers 400 `cloud.errors.project.invalid_branch` for a branch git rejects, then 409 `cloud.errors.limits.environments_per_project` past the plan's allowance, which has no limit at start, before it checks the name is free |
281
+ | `POST /api/cloud/projects/{id}/environments/{envId}/promotion` | Records a deployment of the commit sent, or of a branch tip, that ships a revision to each service building from the project's repository, and serves it unless the build was told to fail. Answers 409 `cloud.errors.promotion.no_repository` when the project builds from no repository, and 409 `cloud.errors.promotion.no_target_services` when no service of the environment builds from it |
282
+ | `POST /api/cloud/projects/{id}/environments/{envId}/deletion` | Deletes the environment. Answers 409 `cloud.errors.project.environment_protected` for a protected one |
283
+
284
+ At start, on `production`, the `web` service follows the `MONGO_URL` secret the `worker` service publishes as `MONGODB_URL`, and holds a plain `STRIPE_PUBLISHABLE_KEY` and a secret `STRIPE_SECRET_KEY`; `worker` holds a plain `MONGODB_URL` of its own. On `preview`, `web` holds a secret `STRIPE_SECRET_KEY`. The variables routes answer 401 to a token the mock did not issue, and 404 for a project, environment or service it does not have.
285
+
286
+ The mock holds each project's environments in one place, and every route that answers an environment reads them there. What an environment serves and targets follows from its deployments. At start those come from one story, `src/test/mock-cloud-story.ts`: on preview, #3 failed its build, #4 serves and #5 builds; on production, #2 served before #3, which serves, and #4 failed its health check. The log answers come from the same story. As on AntelopeJS Cloud, deployment numbers count up within each environment: a promotion, a push or a rollback takes the number after the environment's last deployment.
287
+
288
+ Every route below `/api/cloud/projects/` and the onboarding route answer 401 to a token the mock did not issue.
289
+
290
+ The mock also accepts `mock-managed-token` from the start, as the token of an AntelopeJS Cloud development environment. It reaches the project `prj-acme-shop` and what sits below it, and the services, deployments and builds, which are addressed by id. It answers 403 `cloud.errors.access.forbidden` on the list and creation of projects, on the onboarding route and on any other project. `POST /__mock/revoke` refuses it with 401 like every other token. The backend tests that run the module in a development environment call `withManagedConnection()` (`src/test/helpers/managed.ts`), which starts the module's options parser again with `managed` for the suite, and the `managed-development-environment` journey starts the playground's backend with `ANTELOPE_CLOUD_TOKEN` and `ANTELOPE_CLOUD_PROJECT_ID`.
291
+
292
+ The backend tests drive it in process. The e2e run starts it as its own process, `src/test/mock-cloud-cli.ts`, and drives it over HTTP:
293
+
294
+ | Route | What it does |
295
+ | --- | --- |
296
+ | `GET /__mock/requests` | Answers `{ "requests": ["GET /api/cloud/health"] }`, the requests received so far |
297
+ | `POST /__mock/health` | Sets the health answer to `{ "kind": "ok", "revision": "abc123" }` or to `{ "kind": "error", "status": 503 }` |
298
+ | `POST /__mock/device` | Decides the last device code: `{ "decision": "approve" }`, `"deny"` or `"expire"` |
299
+ | `POST /__mock/projects` | Sets the workspace's projects, each as `GET /api/cloud/projects/{id}` answers it: `{ "projects": [...] }`. Their environments build `env/<name>`, `production` is protected, and their services build from `acme/acme-shop` |
300
+ | `POST /__mock/slow-down` | Answers the next token trades with 429 `slow_down`: `{ "times": 1 }` for one |
301
+ | `POST /__mock/revoke` | Answers 401 to every token issued so far, the managed token included |
302
+ | `POST /__mock/managed-project` | Limits the managed token to another project: `{ "projectId": "prj-other" }` makes it answer 403 on `prj-acme-shop` |
303
+ | `POST /__mock/resources` | Sets the databases an environment runs: `{ "environmentId": "env-production", "resources": [...] }` |
304
+ | `POST /__mock/tier` | Sets the tier of the workspace's plan, `"pro"` at start: `{ "tier": "free" }` makes a preview environment, a third service and a second database refuse as the Free plan does |
305
+ | `POST /__mock/catalog` | Replaces the catalog of modules that need a database: `{ "entries": [...] }`. At start it holds `@antelopejs/mongodb`, `@antelopejs/redis` (from the Hobby tier), `@antelopejs/mysql` (from Pro) and `@antelopejs/postgres`, which it does not offer |
306
+ | `POST /__mock/apply-busy` | Makes the apply answer 503, as when another apply holds the lock: `{ "busy": true }` |
307
+ | `GET /__mock/variables` | Answers `{ variables, published, revealSecrets, refusedKey }`, secret values included |
308
+ | `POST /__mock/variables` | Replaces the variables state. `revealSecrets: true` makes the variables list answer secret values, as a cloud breaking its contract would. `refusedKey` names a variable every write of is refused, `null` for none |
309
+ | `POST /__mock/deployments/advance` | Moves a deployment to a status: `{ "deploymentId": "dep-preview-5", "status": "succeeded" }` |
310
+ | `POST /__mock/deployments/commit` | Starts a queued deployment of a pushed commit and answers `{ "deploymentId" }`: `{ "environmentId": "env-preview", "commit": "<sha>" }`. With `"buildFailure": "<summary>"` its build fails with that summary once it is advanced to `failed`; without it, it fails at the health check, or with `"failureKey": "<key>"`, such as `cloud.errors.builds.missing_port`, which the Cloud ends a deployment with after a build that succeeded. `advance` moves it on |
311
+ | `POST /__mock/deployments/log` | Appends a line to a service's logs: `{ "serviceId": "svc-production-web", "level": "error", "message": "…" }` |
312
+ | `POST /__mock/deployments/end-logs` | Ends a service's log streams for good: `{ "serviceId": "…" }` |
313
+ | `POST /__mock/deployments/drop` | Ends every open stream as a network drop would; `{ "outage": true }` also answers 503 to log reads until `restore` |
314
+ | `POST /__mock/deployments/restore` | Answers log reads again after an outage |
315
+ | `POST /__mock/deployments/sleep` | Scales a service to zero or wakes it: `{ "serviceId": "…", "sleeping": true }` |
316
+ | `POST /__mock/deployments/busy` | Answers the next log reads with 429 and `Retry-After: 30`: `{ "times": 1 }` |
317
+ | `POST /__mock/deployments/fail-rollbacks` | Answers a service's next rollbacks with 500: `{ "serviceId": "…", "times": 1 }` |
318
+ | `POST /__mock/deployments/project-route` | Serves the project deployments route, or answers it with 404: `{ "available": false }` |
319
+ | `POST /__mock/environments` | Sets a project's environments and replaces their deployments: `{ "projectId": "prj-acme-shop", "environments": [{ "id": "env-production", "name": "production", "serving": { "number": 2, "commit": "<sha>" }, "services": ["web"] }] }`. Each serves `serving` and targets `target`, `serving` unless it names another, such as `{ "number": 3, "commit": "<sha>", "status": "building" }`. Their services build from `acme/acme-shop` unless an environment names another `repository`, or `null` for none |
320
+ | `POST /__mock/plan` | Sets how many environments a project may hold: `{ "environmentsPerProject": 1 }` as on Free, `null` for no limit |
321
+ | `POST /__mock/github` | Sets the repositories the GitHub installation grants: `{ "repositories": ["acme/acme-shop"] }` |
322
+ | `POST /__mock/fail-next-build` | Fails the build of the next promotion or push: its deployment fails and the environment keeps serving what it served |
323
+ | `POST /__mock/push` | Takes `{ branch, commit }` and stands in for GitHub's push webhook: deploys the commit on every environment that tracks the branch |
324
+ | `POST /__mock/reset` | Forgets the requests, codes and tokens, and restores the default health answer, projects, resources, tier, catalog, variables, deployments, environments, plan, GitHub grants and answers |
325
+
326
+ The backend tests of the Resources page need modules to plan for. `ajs module test` takes the module's folder as the project folder and reads the project's modules from the `antelope.config.ts` it finds there, so those suites write one before each test and remove it after (`src/test/helpers/project.ts`). The file is ignored by git. The e2e run reads the playground's own `antelope.config.ts`.
327
+
328
+ The backend tests can also hold answers back in process, with `setLatency({ device, token })`: the device route's answer, and the answer that hands out a token, arrive that many milliseconds after the mock decided them. In process, `setEnvironments`, `setEnvironmentAllowance`, `grantRepositories` and `failNextBuild` do what the control routes do, `loseAnswers(count)` makes the next `count` Cloud API requests answer 502 once the mock acted on them, and `environmentsOf`, `linkedRepository` and `servicesOf` read what the mock holds. Each environment the mock lists builds `env/<name>` and answers on `https://<name>.acme-shop.example.test`. They read the variables the mock holds, secret values included, from its `variables` property. In process, `deployments` holds the same controls as `/__mock/deployments/*` (`deployCommit` for `commit`), plus `set(deployments)` to replace every deployment and `setLaterPages(mode)` to make the project route refuse, repeat, empty or ignore the cursor of the pages after the first, and records `rollbacks`, `logReads` and the `openStreams`.
329
+
330
+ ## Keep non-production hosts out
331
+
332
+ The repository will become public. `pnpm leaks` fails when the working tree, the `pnpm pack` tarball, or any commit message or added line reachable from `HEAD` names one of these hosts:
333
+
334
+ - a host with `staging` in its name;
335
+ - a Kubernetes in-cluster service host: under the cluster-local domain, or a URL host ending in `.svc`;
336
+ - an `antelopejs.cloud` subdomain other than `api.antelopejs.cloud`.
337
+
338
+ A host is the host of a URL, or a dotted name without a scheme under `antelopejs.cloud`, `antelopejs.com`, `antelopejs.io` or the cluster domain. Any other dotted name without a scheme may be code or a file name (`environments.staging.app`, `vite.config.staging.ts`), so the check skips it: write a third-party host as a URL to have it checked. The bare `antelopejs.cloud` passes, and so does the word `staging` alone, as in `env/staging`. The check prints one line per finding, with the file, the line and the host, and prints nothing when it passes. `scripts/check-leaks.mts` and its test name forbidden hosts on purpose, so the scan skips those two files and no other.
339
+
340
+ ### Known limits
341
+
342
+ - A third-party staging host written without a scheme passes (`staging.acme.dev`). Its URL form fails.
343
+ - A code property chain that ends with the cluster-local domain's two labels fails, because every name under that domain is a host to the check.
344
+ - A name whose last label is `svc` is checked only as a URL host. Without a scheme it may be code, such as a `svc` property.
345
+ - The scan skips its own script and test file entirely, so a real host added to either one passes.
346
+
347
+ ## Build a stubbed page
348
+
349
+ `src/pages/navigation.ts` holds the sidebar as one table. An entry with a `stub` text is registered as an empty state. To build one of those pages:
350
+
351
+ 1. Remove the `stub` field of its entry in `src/pages/navigation.ts`.
352
+ 2. Add `src/pages/<id>.ts`, with a page class that extends `PageController("<id>", navigationEntry("<id>"))`.
353
+ 3. Import the new file in `construct()` in `src/index.ts`.
354
+
355
+ `navigationEntry` accepts only the ids of entries without a `stub`, so the compiler rejects a page file for an entry that is still a stub. The entry keeps the page's label, icon, group and position.
356
+
357
+ ## Publishing
358
+
359
+ Unpublished changes lists the files of the working copy that differ from the latest version: tracked and untracked files, without the ignored ones. It reads them through a copy of the user's index, so it never stages anything and git hashes only the files that changed. Its form publishes them as the next version. Versions lists every published version, and a version's page shows its release notes, its files and commits since the published version before it, and the environments it is on.
360
+
361
+ A version counts as published once origin holds its `release/v<N>` tag, the same tag object as the local one. The latest version is the newest published one. A local release tag that origin lacks, such as the one a refused push leaves, is pending: its commits stay unpublished, and the Changes page and the navbar panel say that the tag is saved locally and has not reached origin. Versions does not list it, and its page answers 404, as for a version that does not exist. While origin does not answer, every local version counts as published.
362
+
363
+ Publishing works on the git repository that one option names:
364
+
365
+ | Option | Default | What it does |
366
+ | --- | --- | --- |
367
+ | `repositoryPath` | The folder the process runs in | Root of the project's git work tree. A relative path resolves against the process's folder. |
368
+
369
+ The folder must be the root of a work tree, with an `origin` remote that answers, and HEAD must be on a branch other than an `env/*` one. Otherwise the page says why, and a publish is refused. The playground sets the option from `ANTELOPE_CLOUD_REPOSITORY`, else to `playground/.antelope/sandbox-repo`, which is no repository, so the playground never pushes to this module's origin.
370
+
371
+ A publish checks the repository and reads origin's refs, then runs four steps:
372
+
373
+ 1. Commit: `git add --all`, then `git commit` as the signed-in DMS user. The step is skipped when the working copy has nothing to commit.
374
+ 2. Tag: an annotated `release/v<N>` tag, N one more than the highest release tag, local or on origin. The tag message is the version name, "Version <N>" when left empty, then the release notes. The step is skipped when the publish pushes a pending version again.
375
+ 3. Move: `git branch -f env/<name>` to the commit.
376
+ 4. Push: the branch, the tag and `env/<name>` to origin in one `git push --atomic`.
377
+
378
+ AntelopeJS Cloud builds what `env/<name>` points to. One publish runs at a time, and none while a promotion pushes.
379
+
380
+ The environments a publish may move come from the project this DMS publishes: each durable environment that alone builds its own `env/<name>` branch, the release pipeline's stages first and in their order, so the form proposes the first stage the project has. Production only receives promoted versions once the project has a stage before it; a project with no Preview and no Staging publishes to Production. A publish to an environment the project does not have is refused before anything is written, and when no environment builds an `env/` branch the page says a publish would deploy nothing. A DMS that publishes no project, or whose project AntelopeJS Cloud does not answer for, offers the repository's own `env/*` branches except `env/production`, and Preview when it has none.
381
+
382
+ The publish names its commit, the SHA it pushes, once the commit step ended. The form shows, above **Deploy to**, what the version adds to the chosen environment, as the Resources page's `publish-note` route answers it: "This version adds a dependency: Redis", and a link to review the plan.
383
+
384
+ After the push, the publish dialog follows the four AntelopeJS Cloud steps (provision, build, health check, switch traffic) of the commit on the Cloud environment that builds `env/<name>`. It reads the Deployments page's `publish-steps?environment=<name>&commit=<sha>` route every 2 s until the deployment is live or failed, for 20 minutes at most, and stops after 5 failed reads in a row with a link to Deployments. It keeps reading while the dialog is closed. A failed deployment says the step it stopped at, with the build's summary, and what visitors see: "Visitors still see v15 on Preview: AntelopeJS Cloud kept it serving.", naming the serving deployment by the published version tagged on its commit, else by its number. The route says in words when no Cloud environment builds the branch, or the DMS is not connected. A publish that had ended before the page opened is not followed.
385
+
386
+ After a refused push, the next publish picks its version from where HEAD stands:
387
+
388
+ - HEAD is the pending version's commit and the working copy is clean: the publish skips the commit and the tag, then moves `env/<name>` and pushes that version's existing tag. The request needs no commit message, and its version name and release notes are not used: the form asks only for the environment. Any other publish needs a commit message.
389
+ - HEAD moved, for example after `git pull` merged origin's commits, or the working copy has edits: the publish commits them if any, then tags HEAD as a new version, numbered past every release tag, local or on origin. The pending tag stays in the local repository as it is and is never pushed, moved or deleted.
390
+
391
+ The pending tag names a commit without the commits origin added, so pushing it as the version an environment runs would ship a commit that is not HEAD. A tag is never moved, so the pulled HEAD takes the next number.
392
+
393
+ These rules hold:
394
+
395
+ - Only an `env/*` branch moves past a non-fast-forward, through `--force-with-lease` against the commit origin held when the publish began. No refspec carries `+`, since git lets `+` override the lease.
396
+ - A tag is never forced or replaced. The tag step fails when `release/v<N>` exists locally or on origin.
397
+ - A refused push changes nothing on origin, since it is atomic. The publish then says, for each ref, whether origin holds what it pushed. The commit and the tag stay in the local repository.
398
+ - When origin refuses the work branch because it holds commits this copy lacks, the failure says so: "origin has commits on develop that this copy does not have. Pull them, then publish again." Any other failure names the step and git's first error line, as in "The push failed: refs/heads/env/preview [rejected] (stale info)". The step's log keeps git's whole output.
399
+ - The pages list origin's branches and release tags only, and reuse them for 30 s per repository. They list them again as soon as origin's URL changes. A publish lists them afresh before it starts and after a refused push, and the next page read after a publish lists them again.
400
+ - Git runs with no shell and no terminal prompt. On Linux and macOS, git runs without the DMS's terminal, and ssh may not open a password dialog unless `SSH_ASKPASS_REQUIRE` says otherwise, so ssh fails rather than ask for a passphrase or a host key. The ssh the user configures (`core.sshCommand`, `GIT_SSH_COMMAND`, `~/.ssh/config`, an agent) still applies. A git call past its time limit is asked to stop, so it can remove its lock files, and killed 5 s later; git calls still running when the DMS exits are stopped too. A push may run for 15 minutes; any other git call is stopped after 60 s. Logs hide the user and password a URL carries.
401
+
402
+ The backend tests publish to a working repository with a bare repository as its origin, both rebuilt for each test.
403
+
404
+ ## What's live widget
405
+
406
+ `AntelopeCloudDashboardEnvironments` shows each environment of the connected AntelopeJS Cloud project in one row: its name, the version it serves (`v15`, else the deployment number), its state and its address, with a link to Deployments. It reads the Deployments page's `/environments` route on mount and every 15 s while the page shows. The Deployments page puts it first. Any DMS dashboard page can place it the same way:
407
+
408
+ ```typescript fragment
409
+ import { CustomComponent } from "@antelopejs/interface-dms/base/custom";
410
+
411
+ static live = CustomComponent("AntelopeCloudDashboardEnvironments").options({
412
+ fetchUrl: "/dms/pages/modules/antelope-cloud/deployments/environments",
413
+ deploymentsUrl: "/modules/antelope-cloud/deployments",
414
+ });
415
+ ```
416
+
417
+ ## Package release
418
+
419
+ The package is published to npm as `@antelopejs/dms-antelope-cloud`, public and with provenance, by `.github/workflows/release.yml`: a run by hand from `main` publishes a stable version, exact or the automatic increment, a push to `main` publishes a preview, and a pull request that carries the `preview` label publishes a `pr-<n>` preview on each push. It runs the organisation's public release workflow, which publishes through npm trusted publishing (OIDC): the repository holds no npm token. `release-it` bumps the version, writes `CHANGELOG.md` from the commits since the last `v*` tag, tags the release and creates the GitHub release.
420
+
421
+ The first version cannot go through the workflow: npm configures a trusted publisher on a package that exists. An owner of the `@antelopejs` scope does these once:
422
+
423
+ 1. Publish the first version by hand from a clean checkout of `main`: `pnpm install --frozen-lockfile`, then `npm publish --access public --provenance=false`. A provenance statement can only be produced in CI, so that one publish goes without, and the flag is what overrides `publishConfig`.
424
+ 2. Tag that commit `v<version>` and push the tag: the workflow reads the changelog from the last `v*` tag.
425
+ 3. In the package's settings on npm, add the trusted publisher: repository `AntelopeJS/dms-antelope-cloud`, workflow `release.yml`, environment `npm-publish`.
426
+ 4. Give the repository the `RELEASE_APP_ID` and `RELEASE_APP_PRIVATE_KEY` secrets the release workflow pushes its commit and tag with.
427
+
428
+ What a release ships is the `files` list of `package.json`: `dist/` and the sources of the Vue frontend. `pnpm leaks` unpacks the `pnpm pack` tarball and fails on a non-production host in it, on every pull request.
429
+
430
+ ## License
431
+
432
+ [Apache-2.0](./LICENSE)
433
+
434
+ ## Compatibility
435
+
436
+ <!-- antelopejs-docs-compat:start -->
437
+
438
+ | Package | Supported | Tested with |
439
+ | ------------------------------------------- | ------------------ | ----------- |
440
+ | `@antelopejs/cloud-sdk` | `>=0.1.9 <0.2.0` | `0.1.9` |
441
+ | `@antelopejs/core` | `~1.24.0` | `1.24.9` |
442
+ | `@antelopejs/interface-api` | `>=0.3.4 <0.4.0` | `0.3.5` |
443
+ | `@antelopejs/interface-core` | `>=0.5.3 <0.6.0` | `0.5.3` |
444
+ | `@antelopejs/interface-database` | `>=0.4.5 <0.5.0` | `0.4.5` |
445
+ | `@antelopejs/interface-database-decorators` | `>=0.5.4 <0.6.0` | `0.5.4` |
446
+ | `@antelopejs/interface-dms` | `>=0.17.3 <0.18.0` | `0.17.3` |
447
+
448
+ <!-- antelopejs-docs-compat:end -->
@@ -0,0 +1,13 @@
1
+ import type { KeyValueListItem } from "@antelopejs/interface-dms/base/key-value-list";
2
+ /** What a probe of the AntelopeJS Cloud API found. */
3
+ export type CloudStatus = {
4
+ state: "online";
5
+ revision: string | null;
6
+ } | {
7
+ state: "unreachable";
8
+ reason: string;
9
+ };
10
+ /** Asks the health route of the AntelopeJS Cloud API whether the API is up. */
11
+ export declare function probeCloud(apiUrl: URL): Promise<CloudStatus>;
12
+ /** The rows the Connection page shows for an API and the status of its probe. */
13
+ export declare function connectionItems(apiUrl: URL, status: CloudStatus): KeyValueListItem[];
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.probeCloud = probeCloud;
4
+ exports.connectionItems = connectionItems;
5
+ const zod_1 = require("zod");
6
+ const HEALTH_PATH = "api/cloud/health";
7
+ const PROBE_TIMEOUT_MS = 3_000;
8
+ const TIMEOUT_ERROR = "TimeoutError";
9
+ const healthSchema = zod_1.z.object({
10
+ status: zod_1.z.literal("ok"),
11
+ revision: zod_1.z.string().nullable(),
12
+ });
13
+ /** Asks the health route of the AntelopeJS Cloud API whether the API is up. */
14
+ async function probeCloud(apiUrl) {
15
+ let response;
16
+ try {
17
+ response = await fetch(new URL(HEALTH_PATH, apiUrl), {
18
+ signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),
19
+ });
20
+ }
21
+ catch (error) {
22
+ const timedOut = error instanceof Error && error.name === TIMEOUT_ERROR;
23
+ const reason = timedOut
24
+ ? `No answer within ${PROBE_TIMEOUT_MS / 1_000} s`
25
+ : "Could not connect";
26
+ return { state: "unreachable", reason };
27
+ }
28
+ if (!response.ok) {
29
+ await response.body?.cancel();
30
+ return { state: "unreachable", reason: `HTTP ${response.status}` };
31
+ }
32
+ const health = healthSchema.safeParse(await response.json().catch(() => null));
33
+ if (!health.success) {
34
+ return {
35
+ state: "unreachable",
36
+ reason: "Not an AntelopeJS Cloud health answer",
37
+ };
38
+ }
39
+ return { state: "online", revision: health.data.revision };
40
+ }
41
+ /** The rows the Connection page shows for an API and the status of its probe. */
42
+ function connectionItems(apiUrl, status) {
43
+ const host = {
44
+ id: "host",
45
+ label: "API host",
46
+ value: apiUrl.host,
47
+ type: "mono",
48
+ };
49
+ if (status.state === "unreachable") {
50
+ return [
51
+ host,
52
+ {
53
+ id: "status",
54
+ label: "Status",
55
+ value: "Unreachable",
56
+ type: "status",
57
+ tone: "error",
58
+ detail: status.reason,
59
+ },
60
+ ];
61
+ }
62
+ const online = {
63
+ id: "status",
64
+ label: "Status",
65
+ value: "Online",
66
+ type: "status",
67
+ tone: "success",
68
+ };
69
+ if (status.revision === null)
70
+ return [host, online];
71
+ return [
72
+ host,
73
+ online,
74
+ { id: "revision", label: "Revision", value: status.revision, type: "mono" },
75
+ ];
76
+ }
77
+ //# sourceMappingURL=cloud-status.js.map