@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
@@ -0,0 +1,266 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.DeploymentsPage = exports.DEPLOYMENTS_ROUTES = void 0;
16
+ const interface_api_1 = require("@antelopejs/interface-api");
17
+ const custom_1 = require("@antelopejs/interface-dms/base/custom");
18
+ const default_types_1 = require("@antelopejs/interface-dms/base/data-types/default-types");
19
+ const page_toolbar_1 = require("@antelopejs/interface-dms/base/page-toolbar");
20
+ const table_view_1 = require("@antelopejs/interface-dms/base/table-view");
21
+ const page_1 = require("@antelopejs/interface-dms/page");
22
+ const config_1 = require("../config");
23
+ const cloud_1 = require("../connection/cloud");
24
+ const cloud_steps_1 = require("../deployments/cloud-steps");
25
+ const content_1 = require("../deployments/content");
26
+ const follow_1 = require("../deployments/follow");
27
+ const ledger_1 = require("../deployments/ledger");
28
+ const lifecycle_1 = require("../deployments/lifecycle");
29
+ const live_1 = require("../deployments/live");
30
+ const publish_read_1 = require("../deployments/publish-read");
31
+ const repository_1 = require("../git/repository");
32
+ const versions_1 = require("../git/versions");
33
+ const navigation_1 = require("./navigation");
34
+ const query_1 = require("./query");
35
+ const slugs_1 = require("./slugs");
36
+ const project_guard_1 = require("./project-guard");
37
+ /** The routes of the Deployments page, relative to it. */
38
+ exports.DEPLOYMENTS_ROUTES = {
39
+ gate: "/gate",
40
+ list: "/list",
41
+ publishSteps: "/publish-steps",
42
+ environments: "/environments",
43
+ };
44
+ /** What the Cloud has nothing to show for after a read of the project gave no value. */
45
+ const READ_GAPS = {
46
+ revoked: "not_connected",
47
+ missing: "no_project",
48
+ forbidden: "forbidden",
49
+ unreachable: "unreachable",
50
+ };
51
+ const LIVE_MAX_RATE_S = 2;
52
+ const NO_ROWS = { results: [], total: 0 };
53
+ const RUNNING_LABELS = Object.values(lifecycle_1.LIFECYCLE)
54
+ .filter(({ stage }) => stage === "active")
55
+ .map(({ label }) => label);
56
+ function route(path) {
57
+ return (0, page_1.pageRoutePath)((0, slugs_1.modulePageSlug)("deployments"), path);
58
+ }
59
+ const LINKS = {
60
+ detail: slugs_1.deploymentPageSlug,
61
+ logs: (environmentId) => `${(0, slugs_1.modulePageSlug)("logs")}?environment=${encodeURIComponent(environmentId)}`,
62
+ };
63
+ const NO_RELEASE = () => null;
64
+ /** Names a commit by the published version tagged on it, read from the repository; none when it cannot be read. */
65
+ async function readReleaseLookup() {
66
+ const read = await (0, repository_1.readRepository)((0, config_1.cloudSettings)().repositoryPath, "recent").catch(() => null);
67
+ if (read?.kind !== "read")
68
+ return NO_RELEASE;
69
+ return (commit) => (0, versions_1.publishedVersionOf)(read.snapshot, commit);
70
+ }
71
+ function missingParameters() {
72
+ return new interface_api_1.HTTPResult(400, {
73
+ message: "$dms_antelope_cloud.errors.publish_parameters_missing",
74
+ });
75
+ }
76
+ function text(name, order) {
77
+ return { name, type: new default_types_1.DefaultDataTypes.StringType(), order };
78
+ }
79
+ function hidden(name, order) {
80
+ return { ...text(name, order), isVisible: false, filterable: true };
81
+ }
82
+ function tab(id, label, accessorKey, value) {
83
+ return { id, label, filter: { accessorKey, mode: "is", value } };
84
+ }
85
+ /**
86
+ * Every deployment AntelopeJS Cloud ran for the connected project, newest
87
+ * first, live while one runs: In progress, Failed and Rollbacks tabs, an
88
+ * environment filter from `?environment=`, and a search.
89
+ */
90
+ let DeploymentsPage = class DeploymentsPage extends (0, page_1.PageController)("deployments", {
91
+ ...(0, navigation_1.navigationEntry)("deployments"),
92
+ live: { maxRate: LIVE_MAX_RATE_S },
93
+ }) {
94
+ static toolbar = (0, page_toolbar_1.pageToolbar)({ period: false });
95
+ static live = (0, custom_1.CustomComponent)("AntelopeCloudDashboardEnvironments")
96
+ .options({
97
+ fetchUrl: route(exports.DEPLOYMENTS_ROUTES.environments),
98
+ deploymentsUrl: (0, slugs_1.modulePageSlug)("deployments"),
99
+ })
100
+ .meta({
101
+ name: "$dms_antelope_cloud.dashboard_environments.name",
102
+ description: "$dms_antelope_cloud.dashboard_environments.description",
103
+ icon: "i-ph-rocket-launch",
104
+ });
105
+ static deployments = (0, project_guard_1.projectGuard)(route(exports.DEPLOYMENTS_ROUTES.gate)).child("table", table_view_1.TableView.fromSource({
106
+ fetchUrl: route(exports.DEPLOYMENTS_ROUTES.list),
107
+ rowIdKey: "id",
108
+ rowClick: "single",
109
+ realtimeTopic: follow_1.DEPLOYMENTS_TOPIC,
110
+ searchPlaceholder: "Search deployments",
111
+ capabilities: { filter: true },
112
+ columns: {
113
+ name: {
114
+ ...text("Deployment", 0),
115
+ display: new table_view_1.DefaultDisplays.TwoLineDisplay({ subField: "source" }),
116
+ },
117
+ environment: text("Environment", 1),
118
+ status: {
119
+ ...text("Status", 2),
120
+ display: new table_view_1.DefaultDisplays.StatusPillDisplay({
121
+ toneField: "statusTone",
122
+ liveValues: RUNNING_LABELS,
123
+ }),
124
+ },
125
+ trigger: text("Trigger", 3),
126
+ startedAt: {
127
+ name: "Started",
128
+ type: new default_types_1.DefaultDataTypes.DateType(),
129
+ order: 4,
130
+ sortable: true,
131
+ },
132
+ durationSeconds: {
133
+ name: "Duration",
134
+ type: new default_types_1.DefaultDataTypes.NumberType(),
135
+ display: new table_view_1.DefaultDisplays.DurationDisplay({ unit: "s" }),
136
+ order: 5,
137
+ },
138
+ stage: hidden("Stage", 6),
139
+ environmentId: hidden("Environment id", 7),
140
+ triggerKind: hidden("Trigger kind", 8),
141
+ },
142
+ tabs: [
143
+ tab("active", "In progress", "stage", "active"),
144
+ tab("failed", "Failed", "stage", "failed"),
145
+ tab("rollbacks", "Rollbacks", "triggerKind", "rollback"),
146
+ ],
147
+ queryParamFilters: {
148
+ environment: { field: "environmentId", visible: true },
149
+ },
150
+ rowActions: {
151
+ custom: [
152
+ {
153
+ label: "Open {name}",
154
+ icon: "i-ph-arrow-right",
155
+ target: { type: "page", url: "{{row.href}}" },
156
+ isDefault: true,
157
+ },
158
+ {
159
+ label: "View logs",
160
+ icon: "i-ph-terminal-window",
161
+ target: { type: "page", url: "{{row.logsHref}}" },
162
+ },
163
+ ],
164
+ },
165
+ emptyStates: {
166
+ firstRun: {
167
+ title: "No deployment yet",
168
+ description: "AntelopeJS Cloud lists here each deployment of this project once an environment builds.",
169
+ icon: "i-ph-cloud-arrow-up",
170
+ },
171
+ },
172
+ }));
173
+ async gate() {
174
+ return (0, project_guard_1.readProjectGate)(this.tenantId);
175
+ }
176
+ /**
177
+ * The rows the table's filters let through. Following the deployments
178
+ * still running keeps the page live; a failed read answers no row, and
179
+ * the Connection page says why.
180
+ */
181
+ async list(stage, environmentId, triggerKind) {
182
+ const access = await (0, project_guard_1.projectAccess)(this.tenantId);
183
+ if (!access)
184
+ return NO_ROWS;
185
+ const read = await (0, cloud_1.readCloud)(access.connection, (api) => (0, ledger_1.readDeployments)(api, access.projectId));
186
+ if (read.kind !== "ok")
187
+ return NO_ROWS;
188
+ (0, follow_1.follow)(this.tenantId, access.connection, read.value
189
+ .filter(({ phase }) => !lifecycle_1.LIFECYCLE[phase].terminal)
190
+ .map(({ id }) => id));
191
+ const rows = read.value.map((one) => (0, content_1.deploymentRow)(one, LINKS));
192
+ return (0, content_1.selectRows)(rows, {
193
+ stage: (0, query_1.queryText)(stage),
194
+ environmentId: (0, query_1.queryText)(environmentId),
195
+ triggerKind: (0, query_1.queryText)(triggerKind),
196
+ });
197
+ }
198
+ /**
199
+ * The four Cloud steps of a publish that pushed `commit` to the branch of
200
+ * the environment named `environment`: why they cannot be followed,
201
+ * `waiting` until the Cloud runs a deployment of the commit, then that
202
+ * deployment's steps, and what visitors see once it failed.
203
+ */
204
+ async readPublishSteps(environment, commit) {
205
+ const name = (0, query_1.queryText)(environment);
206
+ const sha = (0, query_1.queryText)(commit);
207
+ if (!name || !sha)
208
+ throw missingParameters();
209
+ const access = await (0, project_guard_1.projectAccess)(this.tenantId);
210
+ if (!access)
211
+ return (0, cloud_steps_1.unavailableSteps)("not_connected");
212
+ const read = await (0, cloud_1.readCloud)(access.connection, (api) => (0, publish_read_1.readPublish)(api, access.projectId, name, sha));
213
+ if (read.kind !== "ok")
214
+ return (0, cloud_steps_1.unavailableSteps)(READ_GAPS[read.kind]);
215
+ const found = read.value;
216
+ if (found.kind === "untracked")
217
+ return (0, cloud_steps_1.untrackedSteps)(found.branch);
218
+ if (found.kind === "waiting")
219
+ return (0, cloud_steps_1.waitingSteps)();
220
+ return (0, cloud_steps_1.followingSteps)(found.followed, LINKS.detail(found.followed.deployment.id), readReleaseLookup);
221
+ }
222
+ /** Each environment of the project with the version it serves, for the "What's live" widget. */
223
+ async readEnvironments() {
224
+ const access = await (0, project_guard_1.projectAccess)(this.tenantId);
225
+ if (!access)
226
+ return (0, live_1.environmentsUnavailable)("not_connected");
227
+ const read = await (0, cloud_1.readCloud)(access.connection, (api) => api.environments.list(access.projectId));
228
+ if (read.kind !== "ok")
229
+ return (0, live_1.environmentsUnavailable)(READ_GAPS[read.kind]);
230
+ return (0, live_1.environmentsLive)(read.value, await readReleaseLookup(), LINKS.logs);
231
+ }
232
+ };
233
+ exports.DeploymentsPage = DeploymentsPage;
234
+ __decorate([
235
+ (0, interface_api_1.Get)(exports.DEPLOYMENTS_ROUTES.gate),
236
+ __metadata("design:type", Function),
237
+ __metadata("design:paramtypes", []),
238
+ __metadata("design:returntype", Promise)
239
+ ], DeploymentsPage.prototype, "gate", null);
240
+ __decorate([
241
+ (0, interface_api_1.Get)(exports.DEPLOYMENTS_ROUTES.list),
242
+ __param(0, (0, interface_api_1.Parameter)("filter_stage", "query")),
243
+ __param(1, (0, interface_api_1.Parameter)("filter_environmentId", "query")),
244
+ __param(2, (0, interface_api_1.Parameter)("filter_triggerKind", "query")),
245
+ __metadata("design:type", Function),
246
+ __metadata("design:paramtypes", [Object, Object, Object]),
247
+ __metadata("design:returntype", Promise)
248
+ ], DeploymentsPage.prototype, "list", null);
249
+ __decorate([
250
+ (0, interface_api_1.Get)(exports.DEPLOYMENTS_ROUTES.publishSteps),
251
+ __param(0, (0, interface_api_1.Parameter)("environment", "query")),
252
+ __param(1, (0, interface_api_1.Parameter)("commit", "query")),
253
+ __metadata("design:type", Function),
254
+ __metadata("design:paramtypes", [Object, Object]),
255
+ __metadata("design:returntype", Promise)
256
+ ], DeploymentsPage.prototype, "readPublishSteps", null);
257
+ __decorate([
258
+ (0, interface_api_1.Get)(exports.DEPLOYMENTS_ROUTES.environments),
259
+ __metadata("design:type", Function),
260
+ __metadata("design:paramtypes", []),
261
+ __metadata("design:returntype", Promise)
262
+ ], DeploymentsPage.prototype, "readEnvironments", null);
263
+ exports.DeploymentsPage = DeploymentsPage = __decorate([
264
+ (0, page_1.RegisterPage)()
265
+ ], DeploymentsPage);
266
+ //# sourceMappingURL=deployments.js.map
@@ -0,0 +1,34 @@
1
+ import { HTTPResult } from "@antelopejs/interface-api";
2
+ import { type BannerContent } from "@antelopejs/interface-dms/base/banner";
3
+ import type { ConfirmDialogSerialized } from "@antelopejs/interface-dms/base/types/confirm-dialog";
4
+ import { type EnvironmentList, type ReadyAnswer } from "../environments/content";
5
+ declare const EnvironmentsPage_base: {
6
+ new (...args: any[]): {};
7
+ extend: <T extends import("@antelopejs/interface-api").ControllerClass>(this: T, location: string) => T;
8
+ location: string;
9
+ };
10
+ /**
11
+ * The project's environments: each a branch AntelopeJS Cloud builds and
12
+ * serves. The pipeline's stages come first, in order, each promoting to the
13
+ * next; the owner creates and deletes environments here.
14
+ */
15
+ export declare class EnvironmentsPage extends EnvironmentsPage_base {
16
+ static banner: import("@antelopejs/interface-dms").ComponentBuilder<import("@antelopejs/interface-dms/base").BannerProps>;
17
+ static project: import("@antelopejs/interface-dms").ComponentBuilder<import("@antelopejs/interface-dms/base").GuardOptions>;
18
+ /** The DMS workspace of the request, bound by the page's registration. */
19
+ tenantId: string;
20
+ private stored;
21
+ readState(): Promise<ReadyAnswer>;
22
+ readBanner(): Promise<BannerContent | null>;
23
+ readRows(): Promise<EnvironmentList>;
24
+ readPromoteDialog(environmentId: unknown): Promise<ConfirmDialogSerialized>;
25
+ readNewDialog(): Promise<ConfirmDialogSerialized>;
26
+ readAddressDialog(environmentId: unknown): Promise<ConfirmDialogSerialized>;
27
+ giveAddress(environmentId: unknown): Promise<object>;
28
+ readDashboardDialog(environmentId: unknown): Promise<ConfirmDialogSerialized>;
29
+ addDashboard(environmentId: unknown): Promise<object>;
30
+ promote(environmentId: unknown): Promise<HTTPResult>;
31
+ create(body: unknown): Promise<object>;
32
+ delete(environmentId: unknown): Promise<object>;
33
+ }
34
+ export {};
@@ -0,0 +1,368 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
45
+ return function (target, key) { decorator(target, key, paramIndex); }
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.EnvironmentsPage = void 0;
49
+ const interface_api_1 = require("@antelopejs/interface-api");
50
+ const banner_1 = require("@antelopejs/interface-dms/base/banner");
51
+ const default_types_1 = require("@antelopejs/interface-dms/base/data-types/default-types");
52
+ const guard_1 = require("@antelopejs/interface-dms/base/guard");
53
+ const layouts_1 = require("@antelopejs/interface-dms/base/layouts");
54
+ const table_view_1 = require("@antelopejs/interface-dms/base/table-view");
55
+ const page_1 = require("@antelopejs/interface-dms/page");
56
+ const announce_1 = require("../connection/announce");
57
+ const current_1 = require("../connection/current");
58
+ const view_1 = require("../connection/view");
59
+ const actions_1 = require("../dashboard/actions");
60
+ const dockerfile_1 = require("../dashboard/dockerfile");
61
+ const actions = __importStar(require("../environments/actions"));
62
+ const address_1 = require("../environments/address");
63
+ const content_1 = require("../environments/content");
64
+ const project_config_1 = require("../variables/project-config");
65
+ const navigation_1 = require("./navigation");
66
+ const slugs_1 = require("./slugs");
67
+ const ROW_ID = "{{row._id}}";
68
+ function rowRoute(route) {
69
+ return `${(0, content_1.environmentsRoute)(route)}?environment=${ROW_ID}`;
70
+ }
71
+ const text = new default_types_1.DefaultDataTypes.StringType();
72
+ const ENVIRONMENTS_TABLE = (0, table_view_1.tableViewFromSource)({
73
+ fetchUrl: (0, content_1.environmentsRoute)(content_1.ENVIRONMENTS_ROUTES.rows),
74
+ realtimeTopic: announce_1.PROJECT_TOPICS,
75
+ labelKey: "label",
76
+ columns: {
77
+ order: { name: "#", type: text, order: 0, size: 56 },
78
+ label: {
79
+ name: "Environment",
80
+ type: text,
81
+ order: 1,
82
+ display: new table_view_1.DefaultDisplays.TwoLineDisplay({ subField: "branch" }),
83
+ },
84
+ address: {
85
+ name: "Address",
86
+ type: new default_types_1.DefaultDataTypes.UrlType(),
87
+ order: 2,
88
+ },
89
+ dashboard: {
90
+ name: "Dashboard",
91
+ type: new default_types_1.DefaultDataTypes.UrlType(),
92
+ order: 3,
93
+ },
94
+ serving: {
95
+ name: "Serving",
96
+ type: text,
97
+ order: 4,
98
+ display: new table_view_1.DefaultDisplays.TwoLineDisplay({
99
+ subField: "servingSince",
100
+ emptyLabel: "Nothing yet",
101
+ }),
102
+ },
103
+ state: {
104
+ name: "State",
105
+ type: text,
106
+ order: 5,
107
+ display: new table_view_1.DefaultDisplays.StatusPillDisplay({
108
+ toneField: "stateTone",
109
+ subField: "stateDetail",
110
+ }),
111
+ },
112
+ promotesTo: { name: "Promotes to", type: text, order: 6 },
113
+ },
114
+ rowActions: {
115
+ menuLabel: "Actions for {label}",
116
+ custom: [
117
+ {
118
+ id: "promote",
119
+ label: "Promote to {promotesTo}",
120
+ icon: "i-ph-arrow-fat-lines-up",
121
+ isVisible: true,
122
+ showLabel: true,
123
+ rule: { field: "promotesTo", notEquals: null },
124
+ target: {
125
+ type: "api",
126
+ url: rowRoute(content_1.ENVIRONMENTS_ROUTES.promote),
127
+ method: "POST",
128
+ successMessage: "Promotion started",
129
+ },
130
+ confirm: { from: rowRoute(content_1.ENVIRONMENTS_ROUTES.promoteDialog) },
131
+ },
132
+ {
133
+ id: "address",
134
+ label: "Give it an address",
135
+ icon: "i-ph-globe",
136
+ rule: { field: "address", equals: null },
137
+ target: {
138
+ type: "api",
139
+ url: rowRoute(content_1.ENVIRONMENTS_ROUTES.address),
140
+ method: "POST",
141
+ successMessage: "The environment has its address",
142
+ },
143
+ confirm: { from: rowRoute(content_1.ENVIRONMENTS_ROUTES.addressDialog) },
144
+ },
145
+ {
146
+ id: "dashboard",
147
+ label: "Add the dashboard",
148
+ icon: "i-ph-layout",
149
+ rule: { field: "canAddDashboard", equals: true },
150
+ target: {
151
+ type: "api",
152
+ url: rowRoute(content_1.ENVIRONMENTS_ROUTES.dashboard),
153
+ method: "POST",
154
+ successMessage: "The environment has its dashboard",
155
+ },
156
+ confirm: { from: rowRoute(content_1.ENVIRONMENTS_ROUTES.dashboardDialog) },
157
+ },
158
+ {
159
+ id: "delete",
160
+ label: "Delete",
161
+ icon: "i-ph-trash",
162
+ color: "error",
163
+ rule: { field: "isProtected", equals: false },
164
+ target: {
165
+ type: "api",
166
+ url: rowRoute(content_1.ENVIRONMENTS_ROUTES.delete),
167
+ method: "POST",
168
+ successMessage: "Environment deleted",
169
+ },
170
+ confirm: {
171
+ title: "Delete {label}?",
172
+ description: "The environment, its services and its address are removed from AntelopeJS Cloud. Its branch stays in the repository.",
173
+ icon: "i-ph-trash",
174
+ color: "error",
175
+ confirmLabel: "Delete environment",
176
+ confirmText: "{name}",
177
+ },
178
+ },
179
+ ],
180
+ },
181
+ emptyStates: {
182
+ error: {
183
+ title: "AntelopeJS Cloud did not list the environments",
184
+ description: "The banner above says why.",
185
+ },
186
+ },
187
+ footer: {
188
+ hint: "Environments live in AntelopeJS Cloud: the console and this page show the same list.",
189
+ },
190
+ });
191
+ const NEW_ENVIRONMENT = {
192
+ label: "New environment",
193
+ icon: "i-ph-plus",
194
+ target: {
195
+ type: "api",
196
+ url: (0, content_1.environmentsRoute)(content_1.ENVIRONMENTS_ROUTES.create),
197
+ method: "POST",
198
+ successMessage: "Environment created",
199
+ },
200
+ confirm: { from: (0, content_1.environmentsRoute)(content_1.ENVIRONMENTS_ROUTES.newDialog) },
201
+ availability: async ({ tenantId }) => {
202
+ const view = (0, view_1.toView)(await (0, current_1.readConnection)(tenantId), new Date());
203
+ return (0, content_1.projectReadiness)(view).ready ? undefined : { hidden: true };
204
+ },
205
+ };
206
+ /**
207
+ * The project's environments: each a branch AntelopeJS Cloud builds and
208
+ * serves. The pipeline's stages come first, in order, each promoting to the
209
+ * next; the owner creates and deletes environments here.
210
+ */
211
+ let EnvironmentsPage = class EnvironmentsPage extends (0, page_1.PageController)("environments", (0, navigation_1.navigationEntry)("environments"), (0, layouts_1.DefaultLayout)({ headerActions: [NEW_ENVIRONMENT] })) {
212
+ static banner = (0, banner_1.Banner)({
213
+ fetchUrl: (0, content_1.environmentsRoute)(content_1.ENVIRONMENTS_ROUTES.banner),
214
+ realtimeTopic: announce_1.PROJECT_TOPICS,
215
+ });
216
+ static project = (0, guard_1.Guard)({
217
+ fetchUrl: (0, content_1.environmentsRoute)(content_1.ENVIRONMENTS_ROUTES.state),
218
+ realtimeTopic: announce_1.PROJECT_TOPICS,
219
+ field: "ready",
220
+ fallback: {
221
+ title: "Not connected to AntelopeJS Cloud",
222
+ description: "Connect this DMS and choose its project to manage its environments.",
223
+ icon: "i-ph-stack",
224
+ actions: [{ label: "Open first-run setup", to: slugs_1.SETUP_PAGE_SLUG }],
225
+ },
226
+ }).child("environments", ENVIRONMENTS_TABLE);
227
+ stored() {
228
+ return (0, current_1.readConnection)(this.tenantId);
229
+ }
230
+ async readState() {
231
+ return (0, content_1.projectReadiness)((0, view_1.toView)(await this.stored(), new Date()));
232
+ }
233
+ async readBanner() {
234
+ return (0, content_1.environmentsBanner)(await actions.readEnvironments(await this.stored()));
235
+ }
236
+ async readRows() {
237
+ const environments = await actions.listEnvironments(this.tenantId);
238
+ const results = (0, content_1.environmentRows)(environments, await (0, actions_1.readDashboards)(this.tenantId, environments));
239
+ return { results, total: results.length };
240
+ }
241
+ async readPromoteDialog(environmentId) {
242
+ return (0, content_1.promoteDialog)(await actions.readEnvironments(await this.stored()), actions.parseEnvironmentId(environmentId));
243
+ }
244
+ async readNewDialog() {
245
+ return (0, content_1.newEnvironmentDialog)(await actions.readEnvironments(await this.stored()));
246
+ }
247
+ async readAddressDialog(environmentId) {
248
+ const id = actions.parseEnvironmentId(environmentId);
249
+ const [environments, config] = await Promise.all([
250
+ actions.listEnvironments(this.tenantId),
251
+ (0, project_config_1.readProjectConfig)(),
252
+ ]);
253
+ return (0, address_1.addressDialog)(environments.find((environment) => environment.id === id)?.name, (0, address_1.appAddressOf)(config));
254
+ }
255
+ async giveAddress(environmentId) {
256
+ await (0, address_1.giveAddress)(this.tenantId, actions.parseEnvironmentId(environmentId));
257
+ return {};
258
+ }
259
+ async readDashboardDialog(environmentId) {
260
+ const id = actions.parseEnvironmentId(environmentId);
261
+ const [environments, build] = await Promise.all([
262
+ actions.listEnvironments(this.tenantId),
263
+ (0, dockerfile_1.readDashboardBuild)(),
264
+ ]);
265
+ return (0, actions_1.dashboardDialog)(environments.find((environment) => environment.id === id)?.name, build);
266
+ }
267
+ async addDashboard(environmentId) {
268
+ await (0, actions_1.addDashboard)(this.tenantId, actions.parseEnvironmentId(environmentId));
269
+ return {};
270
+ }
271
+ async promote(environmentId) {
272
+ const started = await actions.promote(this.tenantId, actions.parseEnvironmentId(environmentId));
273
+ return new interface_api_1.HTTPResult(202, started);
274
+ }
275
+ async create(body) {
276
+ await actions.createEnvironment(this.tenantId, actions.parseNewEnvironment(body));
277
+ return {};
278
+ }
279
+ async delete(environmentId) {
280
+ await actions.deleteEnvironment(this.tenantId, actions.parseEnvironmentId(environmentId));
281
+ return {};
282
+ }
283
+ };
284
+ exports.EnvironmentsPage = EnvironmentsPage;
285
+ __decorate([
286
+ (0, interface_api_1.Get)(content_1.ENVIRONMENTS_ROUTES.state),
287
+ __metadata("design:type", Function),
288
+ __metadata("design:paramtypes", []),
289
+ __metadata("design:returntype", Promise)
290
+ ], EnvironmentsPage.prototype, "readState", null);
291
+ __decorate([
292
+ (0, interface_api_1.Get)(content_1.ENVIRONMENTS_ROUTES.banner),
293
+ __metadata("design:type", Function),
294
+ __metadata("design:paramtypes", []),
295
+ __metadata("design:returntype", Promise)
296
+ ], EnvironmentsPage.prototype, "readBanner", null);
297
+ __decorate([
298
+ (0, interface_api_1.Get)(content_1.ENVIRONMENTS_ROUTES.rows),
299
+ __metadata("design:type", Function),
300
+ __metadata("design:paramtypes", []),
301
+ __metadata("design:returntype", Promise)
302
+ ], EnvironmentsPage.prototype, "readRows", null);
303
+ __decorate([
304
+ (0, interface_api_1.Get)(content_1.ENVIRONMENTS_ROUTES.promoteDialog),
305
+ __param(0, (0, interface_api_1.Parameter)("environment", "query")),
306
+ __metadata("design:type", Function),
307
+ __metadata("design:paramtypes", [Object]),
308
+ __metadata("design:returntype", Promise)
309
+ ], EnvironmentsPage.prototype, "readPromoteDialog", null);
310
+ __decorate([
311
+ (0, interface_api_1.Get)(content_1.ENVIRONMENTS_ROUTES.newDialog),
312
+ __metadata("design:type", Function),
313
+ __metadata("design:paramtypes", []),
314
+ __metadata("design:returntype", Promise)
315
+ ], EnvironmentsPage.prototype, "readNewDialog", null);
316
+ __decorate([
317
+ (0, interface_api_1.Get)(content_1.ENVIRONMENTS_ROUTES.addressDialog),
318
+ __param(0, (0, interface_api_1.Parameter)("environment", "query")),
319
+ __metadata("design:type", Function),
320
+ __metadata("design:paramtypes", [Object]),
321
+ __metadata("design:returntype", Promise)
322
+ ], EnvironmentsPage.prototype, "readAddressDialog", null);
323
+ __decorate([
324
+ (0, interface_api_1.Post)(content_1.ENVIRONMENTS_ROUTES.address),
325
+ __param(0, (0, interface_api_1.Parameter)("environment", "query")),
326
+ __metadata("design:type", Function),
327
+ __metadata("design:paramtypes", [Object]),
328
+ __metadata("design:returntype", Promise)
329
+ ], EnvironmentsPage.prototype, "giveAddress", null);
330
+ __decorate([
331
+ (0, interface_api_1.Get)(content_1.ENVIRONMENTS_ROUTES.dashboardDialog),
332
+ __param(0, (0, interface_api_1.Parameter)("environment", "query")),
333
+ __metadata("design:type", Function),
334
+ __metadata("design:paramtypes", [Object]),
335
+ __metadata("design:returntype", Promise)
336
+ ], EnvironmentsPage.prototype, "readDashboardDialog", null);
337
+ __decorate([
338
+ (0, interface_api_1.Post)(content_1.ENVIRONMENTS_ROUTES.dashboard),
339
+ __param(0, (0, interface_api_1.Parameter)("environment", "query")),
340
+ __metadata("design:type", Function),
341
+ __metadata("design:paramtypes", [Object]),
342
+ __metadata("design:returntype", Promise)
343
+ ], EnvironmentsPage.prototype, "addDashboard", null);
344
+ __decorate([
345
+ (0, interface_api_1.Post)(content_1.ENVIRONMENTS_ROUTES.promote),
346
+ __param(0, (0, interface_api_1.Parameter)("environment", "query")),
347
+ __metadata("design:type", Function),
348
+ __metadata("design:paramtypes", [Object]),
349
+ __metadata("design:returntype", Promise)
350
+ ], EnvironmentsPage.prototype, "promote", null);
351
+ __decorate([
352
+ (0, interface_api_1.Post)(content_1.ENVIRONMENTS_ROUTES.create),
353
+ __param(0, (0, interface_api_1.JSONBody)()),
354
+ __metadata("design:type", Function),
355
+ __metadata("design:paramtypes", [Object]),
356
+ __metadata("design:returntype", Promise)
357
+ ], EnvironmentsPage.prototype, "create", null);
358
+ __decorate([
359
+ (0, interface_api_1.Post)(content_1.ENVIRONMENTS_ROUTES.delete),
360
+ __param(0, (0, interface_api_1.Parameter)("environment", "query")),
361
+ __metadata("design:type", Function),
362
+ __metadata("design:paramtypes", [Object]),
363
+ __metadata("design:returntype", Promise)
364
+ ], EnvironmentsPage.prototype, "delete", null);
365
+ exports.EnvironmentsPage = EnvironmentsPage = __decorate([
366
+ (0, page_1.RegisterPage)()
367
+ ], EnvironmentsPage);
368
+ //# sourceMappingURL=environments.js.map