@antelopejs/dms-antelope-cloud 0.0.0-stage → 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 +447 -2
  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 -3
@@ -0,0 +1,440 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SETUP_ROUTES = void 0;
4
+ exports.setupRoute = setupRoute;
5
+ exports.stepItems = stepItems;
6
+ exports.applyAnswer = applyAnswer;
7
+ exports.stepBanner = stepBanner;
8
+ exports.planItems = planItems;
9
+ exports.newProjectDialog = newProjectDialog;
10
+ exports.stagesDialog = stagesDialog;
11
+ const confirm_dialog_1 = require("@antelopejs/interface-dms/base/confirm-dialog");
12
+ const default_types_1 = require("@antelopejs/interface-dms/base/data-types/default-types");
13
+ const form_1 = require("@antelopejs/interface-dms/base/form");
14
+ const http_1 = require("@antelopejs/interface-dms/base/types/http");
15
+ const page_1 = require("@antelopejs/interface-dms/page");
16
+ const content_1 = require("../connection/content");
17
+ const dockerfile_1 = require("../dashboard/dockerfile");
18
+ const pipeline_1 = require("../environments/pipeline");
19
+ const slugs_1 = require("../pages/slugs");
20
+ const steps_1 = require("./steps");
21
+ const rollout_1 = require("./rollout");
22
+ const storage_1 = require("./storage");
23
+ const store_1 = require("./store");
24
+ /** The routes of the First-run setup page, relative to it. */
25
+ exports.SETUP_ROUTES = {
26
+ steps: "/steps",
27
+ step: "/step",
28
+ state: "/state",
29
+ plan: "/plan",
30
+ remote: "/remote",
31
+ repository: "/repository",
32
+ newProjectDialog: "/new-project-dialog",
33
+ existingProjectDialog: "/existing-project-dialog",
34
+ stagesDialog: "/stages-dialog",
35
+ planNewProject: "/plan/new-project",
36
+ planExistingProject: "/plan/existing-project",
37
+ planStages: "/plan/stages",
38
+ apply: "/apply",
39
+ };
40
+ /** The URL of a First-run setup page route, as a block or a button names it. */
41
+ function setupRoute(route) {
42
+ return (0, page_1.pageRoutePath)(slugs_1.SETUP_PAGE_SLUG, route);
43
+ }
44
+ const STATUSES = {
45
+ done: { value: "Done", tone: "success" },
46
+ current: { value: "Now", tone: "primary" },
47
+ blocked: { value: "Waiting", tone: "neutral" },
48
+ };
49
+ /** The six steps as the page lists them: where each stands, and what it holds. */
50
+ function stepItems(steps) {
51
+ return steps.map(({ id, label, status, summary }, index) => ({
52
+ id,
53
+ label: `${index + 1} · ${label}`,
54
+ type: "status",
55
+ ...STATUSES[status],
56
+ detail: summary,
57
+ }));
58
+ }
59
+ function post(route, successMessage) {
60
+ return {
61
+ type: "api",
62
+ url: setupRoute(route),
63
+ method: "POST",
64
+ successMessage,
65
+ };
66
+ }
67
+ const APPLY = {
68
+ label: "Apply plan",
69
+ icon: "i-ph-check",
70
+ target: {
71
+ type: "modal",
72
+ size: "sm",
73
+ title: "Apply the plan?",
74
+ component: (0, form_1.Form)({
75
+ description: "AntelopeJS Cloud creates what the plan lists. Running it again creates only what is missing.",
76
+ kind: "action",
77
+ submitUrl: setupRoute(exports.SETUP_ROUTES.apply),
78
+ submitUrlMethod: http_1.HttpMethod.post,
79
+ submitLabel: "Apply plan",
80
+ successMessage: "Plan applied",
81
+ redirectOnSuccess: (0, slugs_1.modulePageSlug)("overview"),
82
+ }).serializeSync(),
83
+ },
84
+ };
85
+ const PROJECT_STEP = {
86
+ tone: "primary",
87
+ icon: "i-ph-folder-simple",
88
+ title: "Choose the project",
89
+ description: "Create a project, or link one this workspace has. Nothing is created on AntelopeJS Cloud before you apply the plan.",
90
+ actions: [
91
+ {
92
+ label: "Create a project",
93
+ icon: "i-ph-plus",
94
+ target: post(exports.SETUP_ROUTES.planNewProject, "Project planned"),
95
+ confirm: { from: setupRoute(exports.SETUP_ROUTES.newProjectDialog) },
96
+ },
97
+ {
98
+ label: "Link an existing project",
99
+ icon: "i-ph-link",
100
+ color: "neutral",
101
+ target: post(exports.SETUP_ROUTES.planExistingProject, "Project planned"),
102
+ confirm: { from: setupRoute(exports.SETUP_ROUTES.existingProjectDialog) },
103
+ },
104
+ ],
105
+ };
106
+ const PLAN_STEP = {
107
+ tone: "primary",
108
+ icon: "i-ph-list-checks",
109
+ title: "Review the plan, then apply it",
110
+ description: "Production comes with the project. Add the stages a version goes through before it, then apply.",
111
+ actions: [
112
+ {
113
+ label: "Choose environments",
114
+ icon: "i-ph-stack",
115
+ color: "neutral",
116
+ target: post(exports.SETUP_ROUTES.planStages, "Environments planned"),
117
+ confirm: { from: setupRoute(exports.SETUP_ROUTES.stagesDialog) },
118
+ },
119
+ APPLY,
120
+ ],
121
+ };
122
+ /**
123
+ * The plan step after an apply stopped because AntelopeJS Cloud cannot see
124
+ * the repository: what to do about it, with the plan's two actions.
125
+ */
126
+ function repositoryNotVisibleStep(repository) {
127
+ return {
128
+ tone: "warning",
129
+ icon: "i-ph-warning",
130
+ title: `AntelopeJS Cloud can't see ${repository}`,
131
+ description: "The last apply stopped there and created nothing. In AntelopeJS Cloud, open the workspace settings, then GitHub: install the AntelopeJS Cloud GitHub App on the repository, or add the repository to the installation the workspace has. Then apply the plan again.",
132
+ actions: PLAN_STEP.actions,
133
+ };
134
+ }
135
+ function notOnPlanText(stages) {
136
+ return `${stages.map(pipeline_1.environmentLabel).join(" and ")} ${stages.length === 1 ? "is" : "are"} not on your plan: it includes no more environments. Production receives publishes directly.`;
137
+ }
138
+ const UNOPENED = {
139
+ no_port: {
140
+ value: "No port found",
141
+ detail: "antelope.config.ts gives @antelopejs/api no http server with a port, so the app gets no address. Add one, then apply the plan.",
142
+ note: "The app has no address yet: antelope.config.ts gives @antelopejs/api no http server with a port. Add one and apply the plan again.",
143
+ },
144
+ port_out_of_range: {
145
+ value: "Port out of range",
146
+ detail: "AntelopeJS Cloud runs apps on ports 1024 to 65535, so the app gets no address. Change the API's port in antelope.config.ts, then apply the plan.",
147
+ note: "The app has no address yet: AntelopeJS Cloud runs apps on ports 1024 to 65535. Change the API's port in antelope.config.ts and apply the plan again.",
148
+ },
149
+ };
150
+ function dashboardNote(port) {
151
+ return `The dashboard was not created: ${dockerfile_1.DASHBOARD_DOCKERFILE} exposes port ${port}, and AntelopeJS Cloud runs services on ports 1024 to 65535. Change its EXPOSE and apply the plan again.`;
152
+ }
153
+ /**
154
+ * What an applied plan left out, in sentences: the stages the plan has no
155
+ * room for, why the app has no address, and why the dashboard was not
156
+ * created. `undefined` when it left nothing out.
157
+ */
158
+ function leftOut(notOnPlan, { unopened, dashboardPort, storageNotes = [] }) {
159
+ const notes = [
160
+ ...(notOnPlan.length === 0 ? [] : [notOnPlanText(notOnPlan)]),
161
+ ...(unopened === undefined ? [] : [UNOPENED[unopened].note]),
162
+ ...(dashboardPort === undefined ? [] : [dashboardNote(dashboardPort)]),
163
+ ...storageNotes,
164
+ ];
165
+ return notes.length === 0 ? undefined : notes.join(" ");
166
+ }
167
+ function unreachedOf({ address, dashboard, storage }) {
168
+ return {
169
+ unopened: address === null || address.kind === "public" ? undefined : address.kind,
170
+ dashboardPort: dashboard?.kind === "port_out_of_range" ? dashboard.port : undefined,
171
+ storageNotes: (0, storage_1.plannedNotes)(storage),
172
+ };
173
+ }
174
+ function readyText({ address, dashboard }) {
175
+ if (dashboard?.kind === "public") {
176
+ return "Its environments exist and build from the repository, the app and the dashboard each on their own address. Promote a version from the Environments page.";
177
+ }
178
+ return address === null
179
+ ? "Its environments exist and build from the repository. Promote a version from the Environments page."
180
+ : "Its environments exist and build from the repository, each on its own address. Promote a version from the Environments page.";
181
+ }
182
+ function doneStep(slug, notOnPlan, planned) {
183
+ return {
184
+ tone: "success",
185
+ icon: "i-ph-check-circle",
186
+ title: `${slug} is ready on AntelopeJS Cloud`,
187
+ description: leftOut(notOnPlan, unreachedOf(planned)) ?? readyText(planned),
188
+ actions: [{ label: "Open Overview", to: (0, slugs_1.modulePageSlug)("overview") }],
189
+ };
190
+ }
191
+ /**
192
+ * The apply's answer, with a `warning` when the plan leaves out stages,
193
+ * gives the app no address or creates no dashboard.
194
+ */
195
+ function applyAnswer(checklist) {
196
+ const notOnPlan = checklist.flatMap((item) => item.step === "environment" && item.outcome === "not_on_plan"
197
+ ? [item.name]
198
+ : []);
199
+ const [unopened] = checklist.flatMap((item) => item.step === "address" &&
200
+ (item.outcome === "no_port" || item.outcome === "port_out_of_range")
201
+ ? [item.outcome]
202
+ : []);
203
+ const [dashboardPort] = checklist.flatMap((item) => item.step === "dashboard" && item.outcome === "port_out_of_range"
204
+ ? [item.port]
205
+ : []);
206
+ const storageNotes = (0, storage_1.notesOf)(checklist.flatMap((item) => (item.step === "storage" ? [item] : [])));
207
+ const warning = leftOut(notOnPlan, { unopened, dashboardPort, storageNotes });
208
+ return warning === undefined ? { checklist } : { checklist, warning };
209
+ }
210
+ /**
211
+ * The address and the dashboard a plan gives the project it creates: both
212
+ * `null` for a project it links, which keeps the services it has.
213
+ */
214
+ function plannedOf({ facts, setup, }) {
215
+ const managed = facts.connection.state === "connected" && facts.connection.managed;
216
+ return (0, rollout_1.servicesPlanOf)(setup?.project, managed) === "give"
217
+ ? {
218
+ address: facts.address,
219
+ dashboard: facts.dashboard,
220
+ storage: facts.storage,
221
+ }
222
+ : { address: null, dashboard: null, storage: null };
223
+ }
224
+ /** The call to action of the step to do now, `null` when the page shows it otherwise. */
225
+ function stepBanner({ facts, setup, steps, }) {
226
+ const step = (0, steps_1.currentStep)(steps);
227
+ if (step === "connect")
228
+ return (0, content_1.connectionBanner)(facts.connection, undefined);
229
+ if (step === "project")
230
+ return PROJECT_STEP;
231
+ if (step === "plan") {
232
+ return setup?.repositoryNotVisible
233
+ ? repositoryNotVisibleStep(facts.repository.remote?.label ?? "this repository")
234
+ : PLAN_STEP;
235
+ }
236
+ if (step === "done" && facts.project) {
237
+ return doneStep(facts.project.slug, setup?.notOnPlan ?? [], plannedOf({ facts, setup }));
238
+ }
239
+ return null;
240
+ }
241
+ function addressItem(address) {
242
+ if (address.kind === "public") {
243
+ return {
244
+ id: "address",
245
+ label: "Address",
246
+ value: `Public on port ${address.port}`,
247
+ detail: "The port of the API in antelope.config.ts. The app of each environment answers on its own address, open to the internet.",
248
+ };
249
+ }
250
+ const { value, detail } = UNOPENED[address.kind];
251
+ return {
252
+ id: "address",
253
+ label: "Address",
254
+ value,
255
+ type: "status",
256
+ tone: "warning",
257
+ detail,
258
+ };
259
+ }
260
+ function dashboardItem(dashboard) {
261
+ if (dashboard.kind === "public") {
262
+ return {
263
+ id: "dashboard",
264
+ label: "Dashboard",
265
+ value: `Public on port ${dashboard.port}`,
266
+ detail: `Built by ${dockerfile_1.DASHBOARD_DOCKERFILE} as a second service of each environment, on its own address, open to the internet.`,
267
+ };
268
+ }
269
+ return {
270
+ id: "dashboard",
271
+ label: "Dashboard",
272
+ value: "Port out of range",
273
+ type: "status",
274
+ tone: "warning",
275
+ detail: `${dockerfile_1.DASHBOARD_DOCKERFILE} exposes port ${dashboard.port}. AntelopeJS Cloud runs services on ports 1024 to 65535, so no dashboard is created. Change its EXPOSE, then apply the plan.`,
276
+ };
277
+ }
278
+ function stageItem(stage, notOnPlan) {
279
+ const label = (0, pipeline_1.environmentLabel)(stage);
280
+ if (notOnPlan.includes(stage)) {
281
+ return {
282
+ id: stage,
283
+ label,
284
+ value: "Not on your plan",
285
+ type: "status",
286
+ tone: "warning",
287
+ detail: "Your plan includes no more environments.",
288
+ };
289
+ }
290
+ return {
291
+ id: stage,
292
+ label,
293
+ value: (0, pipeline_1.defaultBranch)(stage),
294
+ type: "mono",
295
+ detail: "A new environment with the services of Production.",
296
+ };
297
+ }
298
+ /** What applying the plan creates or links on AntelopeJS Cloud, in order. */
299
+ function planItems({ facts, setup }) {
300
+ const { project, repository } = facts;
301
+ if (!project)
302
+ return [];
303
+ const remote = repository.remote?.webUrl ? repository.remote : null;
304
+ const { address, dashboard, storage } = plannedOf({ facts, setup });
305
+ return [
306
+ {
307
+ id: "project",
308
+ label: "Project",
309
+ value: project.slug,
310
+ type: "mono",
311
+ detail: project.isNew
312
+ ? `Created in ${project.region ?? "the default region"}.`
313
+ : "Exists on AntelopeJS Cloud.",
314
+ },
315
+ {
316
+ id: "production",
317
+ label: "Production",
318
+ value: project.isNew ? "Created with the project" : "Kept as it is",
319
+ detail: "Protected. Receives the versions you promote.",
320
+ },
321
+ ...(setup?.environments ?? []).map((stage) => stageItem(stage, setup?.notOnPlan ?? [])),
322
+ ...(address === null ? [] : [addressItem(address)]),
323
+ ...(dashboard === null ? [] : [dashboardItem(dashboard)]),
324
+ ...(storage?.kind === "local_disk" ? [(0, storage_1.storageItem)(storage.key)] : []),
325
+ remote
326
+ ? {
327
+ id: "repository",
328
+ label: "Repository",
329
+ value: remote.label,
330
+ type: "mono",
331
+ detail: "Linked to the project: AntelopeJS Cloud builds each environment from its branch.",
332
+ }
333
+ : {
334
+ id: "repository",
335
+ label: "Repository",
336
+ value: "No GitHub remote",
337
+ type: "status",
338
+ tone: "warning",
339
+ },
340
+ ];
341
+ }
342
+ const UNAVAILABLE = {
343
+ revoked: {
344
+ title: "Your AntelopeJS Cloud sign-in was revoked",
345
+ description: "Sign in again on the Connection page.",
346
+ },
347
+ missing: {
348
+ title: "AntelopeJS Cloud did not say where projects go",
349
+ description: "Try again in a moment.",
350
+ },
351
+ forbidden: {
352
+ title: "AntelopeJS Cloud does not allow this token here",
353
+ description: "Its access does not reach where projects go.",
354
+ },
355
+ unreachable: {
356
+ title: "AntelopeJS Cloud did not answer",
357
+ description: "Try again in a moment.",
358
+ },
359
+ };
360
+ /** The dialog that plans a new project: its name, from the folder's, and its region. */
361
+ function newProjectDialog(onboarding, suggestedSlug) {
362
+ if (onboarding === undefined) {
363
+ return (0, confirm_dialog_1.serializeConfirmDialog)({
364
+ title: "Not connected to AntelopeJS Cloud",
365
+ description: "Connect this DMS before you plan a project.",
366
+ blocked: true,
367
+ });
368
+ }
369
+ if (onboarding.kind !== "ok") {
370
+ return (0, confirm_dialog_1.serializeConfirmDialog)({
371
+ ...UNAVAILABLE[onboarding.kind],
372
+ blocked: true,
373
+ });
374
+ }
375
+ const { canCreateProjects, regions, defaultRegion } = onboarding.value;
376
+ if (!canCreateProjects) {
377
+ return (0, confirm_dialog_1.serializeConfirmDialog)({
378
+ title: "This workspace can't create a project",
379
+ description: "Link a project it has instead.",
380
+ blocked: true,
381
+ });
382
+ }
383
+ return (0, confirm_dialog_1.serializeConfirmDialog)({
384
+ title: "Create a project",
385
+ description: "Nothing is created on AntelopeJS Cloud before you apply the plan.",
386
+ icon: "i-ph-plus",
387
+ confirmLabel: "Plan this project",
388
+ fields: [
389
+ {
390
+ id: "slug",
391
+ label: "Project name",
392
+ required: true,
393
+ hint: "From the folder name. Its addresses start with it.",
394
+ type: new default_types_1.DefaultDataTypes.StringType(),
395
+ defaultValue: suggestedSlug,
396
+ },
397
+ {
398
+ id: "region",
399
+ label: "Region",
400
+ required: true,
401
+ hint: "Can't be changed later.",
402
+ type: new default_types_1.DefaultDataTypes.SelectType({
403
+ items: regions.map((region) => ({ label: region, value: region })),
404
+ }),
405
+ defaultValue: defaultRegion,
406
+ },
407
+ ],
408
+ });
409
+ }
410
+ const STAGE_TEXTS = {
411
+ preview: "Receives your publishes first, to try a version.",
412
+ staging: "Checks a version before it reaches Production.",
413
+ };
414
+ /** The dialog that plans the stages beside Production. */
415
+ function stagesDialog(setup) {
416
+ if (!setup) {
417
+ return (0, confirm_dialog_1.serializeConfirmDialog)({
418
+ title: "Choose the project first",
419
+ description: "The environments are planned for a project.",
420
+ blocked: true,
421
+ });
422
+ }
423
+ return (0, confirm_dialog_1.serializeConfirmDialog)({
424
+ title: "Environments",
425
+ description: "Production comes with the project. Each stage you add promotes to the next one.",
426
+ icon: "i-ph-stack",
427
+ confirmLabel: "Save environments",
428
+ fields: store_1.EXTRA_STAGES.map((stage) => ({
429
+ id: stage,
430
+ type: new default_types_1.DefaultDataTypes.BooleanType({
431
+ display: "card",
432
+ icon: "i-ph-git-branch",
433
+ label: `${(0, pipeline_1.environmentLabel)(stage)} · ${(0, pipeline_1.defaultBranch)(stage)}`,
434
+ description: STAGE_TEXTS[stage],
435
+ }),
436
+ defaultValue: setup.environments.includes(stage),
437
+ })),
438
+ });
439
+ }
440
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1,119 @@
1
+ import type { ActiveConnection } from "../connection/current";
2
+ import { type DashboardBuild } from "../dashboard/dockerfile";
3
+ import { type DashboardOutcome } from "../dashboard/service";
4
+ import { type AppAddress, type OpenOutcome } from "../environments/address";
5
+ import { type AppStorage } from "./storage";
6
+ import type { ExtraStage, ProjectDraft } from "./store";
7
+ /**
8
+ * What applying the plan did to an environment, to the address of its app or
9
+ * to its dashboard.
10
+ */
11
+ export type RolloutItem = {
12
+ step: "environment";
13
+ name: string;
14
+ outcome: "created" | "existing" | "not_on_plan";
15
+ } | AddressItem | DashboardItem | StorageItem;
16
+ /**
17
+ * What applying the plan did about the volume the app keeps its files on:
18
+ * for each environment, that its app got one or had one at `mountPath`, or
19
+ * why it has none, `key` being the variable to point at one; or, once for
20
+ * the project, that no `envOverrides` variable feeds the folder the files go
21
+ * to, so the volume has nothing to point at it.
22
+ */
23
+ export type StorageItem = {
24
+ step: "storage";
25
+ name: string;
26
+ outcome: "attached" | "existing";
27
+ mountPath: string;
28
+ } | {
29
+ step: "storage";
30
+ name: string;
31
+ outcome: "not_on_plan" | "not_one_app";
32
+ key: string | null;
33
+ } | {
34
+ step: "storage";
35
+ outcome: "no_variable";
36
+ };
37
+ /**
38
+ * What applying the plan did about the dashboard of the project: for each
39
+ * environment, that its dashboard was created, opened or left as it is, on
40
+ * `port`; or, once for the project, that none was created, its Dockerfile
41
+ * exposing a port AntelopeJS Cloud runs no service on.
42
+ */
43
+ type DashboardItem = {
44
+ step: "dashboard";
45
+ name: string;
46
+ outcome: DashboardOutcome;
47
+ port: number;
48
+ } | {
49
+ step: "dashboard";
50
+ outcome: "port_out_of_range";
51
+ port: number;
52
+ };
53
+ /**
54
+ * What applying the plan did about the address of the app: for each
55
+ * environment, that its app was opened to the internet on `port`, or why it
56
+ * was left as it is; or, once for the project, why no environment was
57
+ * opened, the config naming no usable port.
58
+ */
59
+ type AddressItem = {
60
+ step: "address";
61
+ name: string;
62
+ outcome: "opened";
63
+ port: number;
64
+ } | {
65
+ step: "address";
66
+ name: string;
67
+ outcome: Exclude<OpenOutcome, "opened">;
68
+ } | {
69
+ step: "address";
70
+ outcome: Exclude<AppAddress["kind"], "public">;
71
+ };
72
+ /** What the rollout did, in order, and the chosen stages the plan has no room for. */
73
+ export interface EnvironmentsApplied {
74
+ readonly items: RolloutItem[];
75
+ readonly notOnPlan: ExtraStage[];
76
+ }
77
+ /** What a plan gives the project it creates beside its environments. */
78
+ export interface RolloutPlan {
79
+ /** The address its config lets its app have, `null` for a project the plan links. */
80
+ readonly address: AppAddress | null;
81
+ /** How its dashboard is built and from which repository, `null` without one or for a project the plan links. */
82
+ readonly dashboard: {
83
+ readonly build: DashboardBuild;
84
+ readonly repository: string;
85
+ } | null;
86
+ /** What its app keeps its files on, `null` for a project the plan links. */
87
+ readonly storage: AppStorage | null;
88
+ }
89
+ /**
90
+ * The environments of the plan, their addresses, the app's volume and their
91
+ * dashboard: Production's app is opened on the plan's port first, then gets
92
+ * the volume its files go to when the project keeps them on its disk, then
93
+ * Production gets the dashboard, then each chosen stage is created with the
94
+ * services of Production, their volume declared empty, and a stage still
95
+ * without an address, a volume or a dashboard gets one.
96
+ * With no port to open the apps on, or a dashboard AntelopeJS Cloud cannot
97
+ * run, the rest is done and the reason is reported once; a plan that links a
98
+ * project opens and creates nothing.
99
+ */
100
+ export declare function applyRollout(connection: ActiveConnection, projectId: string, stages: readonly ExtraStage[], plan: RolloutPlan): Promise<EnvironmentsApplied>;
101
+ /**
102
+ * Whether the plan gives Production's services their address and dashboard
103
+ * (`give`), as for a project it creates or the project AntelopeJS Cloud made
104
+ * for a development environment, or leaves the services of a project it
105
+ * links as they are (`keep`).
106
+ */
107
+ export type ServicesPlan = "give" | "keep";
108
+ /**
109
+ * What the plan does with Production's services: it gives them to a project
110
+ * it creates and to the managed project, and keeps those of a project it links.
111
+ */
112
+ export declare function servicesPlanOf(draft: ProjectDraft | undefined, managed: boolean): ServicesPlan;
113
+ /**
114
+ * What the plan gives the project beside its environments: when it gives
115
+ * the services, the address its config allows and the dashboard its work
116
+ * tree builds; nothing when it keeps them.
117
+ */
118
+ export declare function rolloutPlan(services: ServicesPlan, repository: string): Promise<RolloutPlan>;
119
+ export {};