@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.
- package/LICENSE +201 -0
- package/README.md +447 -2
- package/dist/cloud-status.d.ts +13 -0
- package/dist/cloud-status.js +77 -0
- package/dist/config.d.ts +84 -0
- package/dist/config.js +104 -0
- package/dist/configured.d.ts +16 -0
- package/dist/configured.js +26 -0
- package/dist/connection/actions.d.ts +40 -0
- package/dist/connection/actions.js +120 -0
- package/dist/connection/announce.d.ts +8 -0
- package/dist/connection/announce.js +20 -0
- package/dist/connection/cloud.d.ts +60 -0
- package/dist/connection/cloud.js +87 -0
- package/dist/connection/content.d.ts +70 -0
- package/dist/connection/content.js +462 -0
- package/dist/connection/current.d.ts +26 -0
- package/dist/connection/current.js +28 -0
- package/dist/connection/device-flow.d.ts +16 -0
- package/dist/connection/device-flow.js +146 -0
- package/dist/connection/refusals.d.ts +51 -0
- package/dist/connection/refusals.js +85 -0
- package/dist/connection/repository.d.ts +28 -0
- package/dist/connection/repository.js +69 -0
- package/dist/connection/seal.d.ts +22 -0
- package/dist/connection/seal.js +47 -0
- package/dist/connection/store.d.ts +294 -0
- package/dist/connection/store.js +165 -0
- package/dist/connection/view.d.ts +39 -0
- package/dist/connection/view.js +39 -0
- package/dist/dashboard/actions.d.ts +40 -0
- package/dist/dashboard/actions.js +115 -0
- package/dist/dashboard/dockerfile.d.ts +34 -0
- package/dist/dashboard/dockerfile.js +71 -0
- package/dist/dashboard/service.d.ts +61 -0
- package/dist/dashboard/service.js +137 -0
- package/dist/dashboard/variables.d.ts +30 -0
- package/dist/dashboard/variables.js +34 -0
- package/dist/deployments/build-log.d.ts +39 -0
- package/dist/deployments/build-log.js +57 -0
- package/dist/deployments/cloud-steps.d.ts +77 -0
- package/dist/deployments/cloud-steps.js +132 -0
- package/dist/deployments/content.d.ts +61 -0
- package/dist/deployments/content.js +268 -0
- package/dist/deployments/deployment.d.ts +96 -0
- package/dist/deployments/deployment.js +3 -0
- package/dist/deployments/follow.d.ts +18 -0
- package/dist/deployments/follow.js +112 -0
- package/dist/deployments/ledger.d.ts +23 -0
- package/dist/deployments/ledger.js +359 -0
- package/dist/deployments/lifecycle.d.ts +123 -0
- package/dist/deployments/lifecycle.js +146 -0
- package/dist/deployments/live.d.ts +28 -0
- package/dist/deployments/live.js +54 -0
- package/dist/deployments/publish-read.d.ts +20 -0
- package/dist/deployments/publish-read.js +24 -0
- package/dist/deployments/refusals.d.ts +13 -0
- package/dist/deployments/refusals.js +35 -0
- package/dist/environments/actions.d.ts +86 -0
- package/dist/environments/actions.js +210 -0
- package/dist/environments/address.d.ts +60 -0
- package/dist/environments/address.js +149 -0
- package/dist/environments/content.d.ts +97 -0
- package/dist/environments/content.js +275 -0
- package/dist/environments/follower.d.ts +32 -0
- package/dist/environments/follower.js +114 -0
- package/dist/environments/pipeline.d.ts +58 -0
- package/dist/environments/pipeline.js +76 -0
- package/dist/environments/publish-targets.d.ts +18 -0
- package/dist/environments/publish-targets.js +55 -0
- package/dist/environments/roles.d.ts +73 -0
- package/dist/environments/roles.js +97 -0
- package/dist/frontend-module.d.ts +12 -0
- package/dist/frontend-module.js +25 -0
- package/dist/git/changed-files.d.ts +30 -0
- package/dist/git/changed-files.js +107 -0
- package/dist/git/changes.d.ts +89 -0
- package/dist/git/changes.js +162 -0
- package/dist/git/command.d.ts +51 -0
- package/dist/git/command.js +231 -0
- package/dist/git/promotion.d.ts +23 -0
- package/dist/git/promotion.js +46 -0
- package/dist/git/publish-input.d.ts +42 -0
- package/dist/git/publish-input.js +62 -0
- package/dist/git/publish-job.d.ts +82 -0
- package/dist/git/publish-job.js +99 -0
- package/dist/git/publish-steps.d.ts +90 -0
- package/dist/git/publish-steps.js +205 -0
- package/dist/git/publisher.d.ts +23 -0
- package/dist/git/publisher.js +206 -0
- package/dist/git/refs.d.ts +99 -0
- package/dist/git/refs.js +178 -0
- package/dist/git/refusal.d.ts +49 -0
- package/dist/git/refusal.js +70 -0
- package/dist/git/repository.d.ts +101 -0
- package/dist/git/repository.js +273 -0
- package/dist/git/versions.d.ts +99 -0
- package/dist/git/versions.js +174 -0
- package/dist/git/write-lock.d.ts +19 -0
- package/dist/git/write-lock.js +49 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +59 -0
- package/dist/lifecycle.d.ts +8 -0
- package/dist/lifecycle.js +78 -0
- package/dist/logs/relay.d.ts +25 -0
- package/dist/logs/relay.js +138 -0
- package/dist/null-prototype.d.ts +7 -0
- package/dist/null-prototype.js +3 -0
- package/dist/overview/content.d.ts +40 -0
- package/dist/overview/content.js +172 -0
- package/dist/pages/changes.d.ts +32 -0
- package/dist/pages/changes.js +141 -0
- package/dist/pages/connection.d.ts +43 -0
- package/dist/pages/connection.js +295 -0
- package/dist/pages/deployment.d.ts +67 -0
- package/dist/pages/deployment.js +261 -0
- package/dist/pages/deployments.d.ts +46 -0
- package/dist/pages/deployments.js +266 -0
- package/dist/pages/environments.d.ts +34 -0
- package/dist/pages/environments.js +368 -0
- package/dist/pages/logs.d.ts +46 -0
- package/dist/pages/logs.js +140 -0
- package/dist/pages/navigation.d.ts +61 -0
- package/dist/pages/navigation.js +107 -0
- package/dist/pages/overview.d.ts +35 -0
- package/dist/pages/overview.js +201 -0
- package/dist/pages/project-guard.d.ts +32 -0
- package/dist/pages/project-guard.js +99 -0
- package/dist/pages/query.d.ts +6 -0
- package/dist/pages/query.js +14 -0
- package/dist/pages/resources.d.ts +37 -0
- package/dist/pages/resources.js +211 -0
- package/dist/pages/setup.d.ts +40 -0
- package/dist/pages/setup.js +271 -0
- package/dist/pages/slugs.d.ts +15 -0
- package/dist/pages/slugs.js +28 -0
- package/dist/pages/variables.d.ts +43 -0
- package/dist/pages/variables.js +327 -0
- package/dist/pages/version.d.ts +26 -0
- package/dist/pages/version.js +214 -0
- package/dist/pages/versions.d.ts +20 -0
- package/dist/pages/versions.js +115 -0
- package/dist/resources/apply.d.ts +15 -0
- package/dist/resources/apply.js +127 -0
- package/dist/resources/cards.d.ts +41 -0
- package/dist/resources/cards.js +211 -0
- package/dist/resources/connect.d.ts +66 -0
- package/dist/resources/connect.js +78 -0
- package/dist/resources/content.d.ts +26 -0
- package/dist/resources/content.js +158 -0
- package/dist/resources/format.d.ts +10 -0
- package/dist/resources/format.js +30 -0
- package/dist/resources/guard.d.ts +23 -0
- package/dist/resources/guard.js +60 -0
- package/dist/resources/modules.d.ts +23 -0
- package/dist/resources/modules.js +39 -0
- package/dist/resources/plan.d.ts +8 -0
- package/dist/resources/plan.js +93 -0
- package/dist/resources/read.d.ts +54 -0
- package/dist/resources/read.js +69 -0
- package/dist/resources/refusals.d.ts +15 -0
- package/dist/resources/refusals.js +33 -0
- package/dist/resources/routes.d.ts +32 -0
- package/dist/resources/routes.js +53 -0
- package/dist/setup/actions.d.ts +79 -0
- package/dist/setup/actions.js +188 -0
- package/dist/setup/apply.d.ts +37 -0
- package/dist/setup/apply.js +172 -0
- package/dist/setup/content.d.ts +50 -0
- package/dist/setup/content.js +440 -0
- package/dist/setup/rollout.d.ts +119 -0
- package/dist/setup/rollout.js +227 -0
- package/dist/setup/steps.d.ts +93 -0
- package/dist/setup/steps.js +95 -0
- package/dist/setup/storage.d.ts +29 -0
- package/dist/setup/storage.js +78 -0
- package/dist/setup/store.d.ts +214 -0
- package/dist/setup/store.js +174 -0
- package/dist/setup/volume.d.ts +31 -0
- package/dist/setup/volume.js +52 -0
- package/dist/slug.d.ts +7 -0
- package/dist/slug.js +26 -0
- package/dist/variables/actions.d.ts +76 -0
- package/dist/variables/actions.js +185 -0
- package/dist/variables/content.d.ts +69 -0
- package/dist/variables/content.js +310 -0
- package/dist/variables/decide.d.ts +27 -0
- package/dist/variables/decide.js +155 -0
- package/dist/variables/decided-dialog.d.ts +11 -0
- package/dist/variables/decided-dialog.js +129 -0
- package/dist/variables/decided.d.ts +80 -0
- package/dist/variables/decided.js +240 -0
- package/dist/variables/dialogs.d.ts +8 -0
- package/dist/variables/dialogs.js +219 -0
- package/dist/variables/model.d.ts +106 -0
- package/dist/variables/model.js +156 -0
- package/dist/variables/project-config.d.ts +117 -0
- package/dist/variables/project-config.js +248 -0
- package/dist/variables/read.d.ts +33 -0
- package/dist/variables/read.js +118 -0
- package/dist/web-url.d.ts +9 -0
- package/dist/web-url.js +19 -0
- package/frontend-vue/app/components/BuildLog.vue +99 -0
- package/frontend-vue/app/components/ChangedFiles.vue +165 -0
- package/frontend-vue/app/components/DashboardEnvironments.vue +102 -0
- package/frontend-vue/app/components/LogLine.vue +33 -0
- package/frontend-vue/app/components/LogViewer.vue +314 -0
- package/frontend-vue/app/components/PublishChipIcon.vue +39 -0
- package/frontend-vue/app/components/PublishForm.vue +505 -0
- package/frontend-vue/app/components/PublishPopover.vue +90 -0
- package/frontend-vue/app/components/PublishRoute.vue +222 -0
- package/frontend-vue/app/composables/usePublishSummary.ts +80 -0
- package/frontend-vue/app/plugins/publish-chip.client.ts +44 -0
- package/frontend-vue/app/types/publishing.ts +154 -0
- package/frontend-vue/app/utils/build-log.ts +96 -0
- package/frontend-vue/app/utils/changed-files.ts +142 -0
- package/frontend-vue/app/utils/log-line.ts +15 -0
- package/frontend-vue/app/utils/log-stream.ts +361 -0
- package/frontend-vue/app/utils/publish-state.ts +299 -0
- package/frontend-vue/dms.frontend.ts +27 -0
- package/frontend-vue/i18n/locales/antelope-cloud-en-GB.json +110 -0
- package/frontend-vue/package.json +38 -0
- package/frontend-vue/pnpm-lock.yaml +2697 -0
- package/package.json +115 -3
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BUILD_LOG_QUERY = exports.CANCELLED_TITLE = void 0;
|
|
4
|
+
exports.deploymentRow = deploymentRow;
|
|
5
|
+
exports.selectRows = selectRows;
|
|
6
|
+
exports.factItems = factItems;
|
|
7
|
+
exports.stepItems = stepItems;
|
|
8
|
+
exports.failedAt = failedAt;
|
|
9
|
+
exports.failureBanner = failureBanner;
|
|
10
|
+
exports.rollbackBanner = rollbackBanner;
|
|
11
|
+
const lifecycle_1 = require("./lifecycle");
|
|
12
|
+
const SHORT_SHA = 7;
|
|
13
|
+
const MS_PER_SECOND = 1000;
|
|
14
|
+
const TRIGGER_LABELS = {
|
|
15
|
+
push: "Push",
|
|
16
|
+
promotion: "Promotion",
|
|
17
|
+
rollback: "Rollback",
|
|
18
|
+
upload: "Upload",
|
|
19
|
+
restart: "Restart",
|
|
20
|
+
};
|
|
21
|
+
const STEP_LABELS = {
|
|
22
|
+
queued: "Queued",
|
|
23
|
+
build: "Build image",
|
|
24
|
+
check: "Health check",
|
|
25
|
+
switch: "Switch traffic",
|
|
26
|
+
live: "Live",
|
|
27
|
+
};
|
|
28
|
+
const STEP_STATES = {
|
|
29
|
+
done: { label: "Done", tone: "success" },
|
|
30
|
+
current: { label: "In progress", tone: "info" },
|
|
31
|
+
todo: { label: "Waiting", tone: "neutral" },
|
|
32
|
+
failed: { label: "Failed", tone: "error" },
|
|
33
|
+
skipped: { label: "Not attempted", tone: "neutral" },
|
|
34
|
+
};
|
|
35
|
+
function shortSha(commit) {
|
|
36
|
+
return commit.slice(0, SHORT_SHA);
|
|
37
|
+
}
|
|
38
|
+
function nameOf(deployment) {
|
|
39
|
+
return deployment.number === null ? "—" : `#${deployment.number}`;
|
|
40
|
+
}
|
|
41
|
+
function sourceOf({ branch, commit }) {
|
|
42
|
+
if (commit === null)
|
|
43
|
+
return branch;
|
|
44
|
+
return branch === null ? shortSha(commit) : `${branch} @ ${shortSha(commit)}`;
|
|
45
|
+
}
|
|
46
|
+
function durationOf({ startedAt, finishedAt }) {
|
|
47
|
+
if (startedAt === null || finishedAt === null)
|
|
48
|
+
return null;
|
|
49
|
+
return Math.round((finishedAt.getTime() - startedAt.getTime()) / MS_PER_SECOND);
|
|
50
|
+
}
|
|
51
|
+
/** One deployment as a row of the Deployments table. */
|
|
52
|
+
function deploymentRow(deployment, links) {
|
|
53
|
+
const row = lifecycle_1.LIFECYCLE[deployment.phase];
|
|
54
|
+
return {
|
|
55
|
+
id: deployment.id,
|
|
56
|
+
name: nameOf(deployment),
|
|
57
|
+
source: sourceOf(deployment),
|
|
58
|
+
environmentId: deployment.environment.id,
|
|
59
|
+
environment: deployment.environment.name,
|
|
60
|
+
status: row.label,
|
|
61
|
+
statusTone: row.tone,
|
|
62
|
+
stage: row.stage,
|
|
63
|
+
trigger: deployment.trigger === null ? null : TRIGGER_LABELS[deployment.trigger],
|
|
64
|
+
triggerKind: deployment.trigger ?? "unknown",
|
|
65
|
+
startedAt: deployment.startedAt?.toISOString() ?? null,
|
|
66
|
+
durationSeconds: durationOf(deployment),
|
|
67
|
+
href: links.detail(deployment.id),
|
|
68
|
+
logsHref: links.logs(deployment.environment.id),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** The value a `filter_<field>=<mode>:<value>` query parameter compares, as a set of values. */
|
|
72
|
+
function filterValues(raw) {
|
|
73
|
+
if (raw === undefined || raw === "")
|
|
74
|
+
return null;
|
|
75
|
+
const separator = raw.indexOf(":");
|
|
76
|
+
return new Set(raw.slice(separator + 1).split(","));
|
|
77
|
+
}
|
|
78
|
+
/** The rows that pass every filter the table sent; the browser searches, sorts and pages them. */
|
|
79
|
+
function selectRows(rows, filters) {
|
|
80
|
+
const checks = [
|
|
81
|
+
{ field: "stage", values: filterValues(filters.stage) },
|
|
82
|
+
{ field: "environmentId", values: filterValues(filters.environmentId) },
|
|
83
|
+
{ field: "triggerKind", values: filterValues(filters.triggerKind) },
|
|
84
|
+
];
|
|
85
|
+
const results = rows.filter((row) => checks.every(({ field, values }) => values?.has(row[field]) ?? true));
|
|
86
|
+
return { results, total: results.length };
|
|
87
|
+
}
|
|
88
|
+
function servicesLine(detail) {
|
|
89
|
+
return detail.revisions
|
|
90
|
+
.map(({ serviceName, revisionNumber }) => `${serviceName} r${revisionNumber}`)
|
|
91
|
+
.join(" · ");
|
|
92
|
+
}
|
|
93
|
+
/** The facts of one deployment: where, what, when. */
|
|
94
|
+
function factItems(detail) {
|
|
95
|
+
const row = lifecycle_1.LIFECYCLE[detail.phase];
|
|
96
|
+
const items = [
|
|
97
|
+
{ id: "environment", label: "Environment", value: detail.environment.name },
|
|
98
|
+
{
|
|
99
|
+
id: "status",
|
|
100
|
+
label: "Status",
|
|
101
|
+
value: row.label,
|
|
102
|
+
type: "status",
|
|
103
|
+
tone: row.tone,
|
|
104
|
+
},
|
|
105
|
+
{ id: "number", label: "Deployment", value: nameOf(detail) },
|
|
106
|
+
{
|
|
107
|
+
id: "trigger",
|
|
108
|
+
label: "Trigger",
|
|
109
|
+
value: detail.trigger === null ? "—" : TRIGGER_LABELS[detail.trigger],
|
|
110
|
+
},
|
|
111
|
+
detail.commit === null
|
|
112
|
+
? { id: "commit", label: "Commit", value: "—" }
|
|
113
|
+
: {
|
|
114
|
+
id: "commit",
|
|
115
|
+
label: "Commit",
|
|
116
|
+
value: shortSha(detail.commit),
|
|
117
|
+
type: "mono",
|
|
118
|
+
copyValue: detail.commit,
|
|
119
|
+
},
|
|
120
|
+
{ id: "branch", label: "Branch", value: detail.branch ?? "—" },
|
|
121
|
+
{
|
|
122
|
+
id: "started",
|
|
123
|
+
label: "Started",
|
|
124
|
+
value: detail.startedAt?.toISOString() ?? null,
|
|
125
|
+
type: detail.startedAt ? "date" : "text",
|
|
126
|
+
},
|
|
127
|
+
];
|
|
128
|
+
const services = servicesLine(detail);
|
|
129
|
+
if (services !== "") {
|
|
130
|
+
items.push({ id: "services", label: "Services", value: services });
|
|
131
|
+
}
|
|
132
|
+
return items;
|
|
133
|
+
}
|
|
134
|
+
function stepDetail(detail, id, state) {
|
|
135
|
+
if (state === "current" && id === "queued" && detail.queuePosition !== null) {
|
|
136
|
+
return `Position ${detail.queuePosition} in the queue`;
|
|
137
|
+
}
|
|
138
|
+
if (state === "failed")
|
|
139
|
+
return detail.failure?.summary ?? undefined;
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
/** One status row per step of the deployment's route. */
|
|
143
|
+
function stepItems(detail) {
|
|
144
|
+
return (0, lifecycle_1.stepsOf)(detail).map(({ id, state }) => {
|
|
145
|
+
const shown = STEP_STATES[state];
|
|
146
|
+
const item = {
|
|
147
|
+
id,
|
|
148
|
+
label: STEP_LABELS[id],
|
|
149
|
+
value: shown.label,
|
|
150
|
+
type: "status",
|
|
151
|
+
tone: shown.tone,
|
|
152
|
+
};
|
|
153
|
+
const note = stepDetail(detail, id, state);
|
|
154
|
+
if (note !== undefined)
|
|
155
|
+
item.detail = note;
|
|
156
|
+
return item;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/** How a failure names the step a deployment stopped at. */
|
|
160
|
+
const FAILED_STEPS = {
|
|
161
|
+
__proto__: null,
|
|
162
|
+
queued: "the queue",
|
|
163
|
+
build: "the build",
|
|
164
|
+
check: "the health check",
|
|
165
|
+
switch: "the traffic switch",
|
|
166
|
+
live: "going live",
|
|
167
|
+
};
|
|
168
|
+
/** The title of a cancelled deployment. */
|
|
169
|
+
exports.CANCELLED_TITLE = "This deployment was cancelled";
|
|
170
|
+
/** "Failed at the health check": the step a failed deployment stopped at. */
|
|
171
|
+
function failedAt(step) {
|
|
172
|
+
return `Failed at ${FAILED_STEPS[step]}`;
|
|
173
|
+
}
|
|
174
|
+
function stillServing(detail) {
|
|
175
|
+
const environment = detail.environment.name;
|
|
176
|
+
if (detail.serving === null)
|
|
177
|
+
return `${environment} serves no deployment yet.`;
|
|
178
|
+
return `${environment} still serves #${detail.serving.number}.`;
|
|
179
|
+
}
|
|
180
|
+
/** The query that opens the build log on a deployment's page. */
|
|
181
|
+
exports.BUILD_LOG_QUERY = "log=build";
|
|
182
|
+
/**
|
|
183
|
+
* Null unless the deployment failed or was cancelled. It says the step it
|
|
184
|
+
* stopped at, the build's summary, and what the environment still serves.
|
|
185
|
+
* A failed build adds a link that opens its log on the page at `pageHref`.
|
|
186
|
+
*/
|
|
187
|
+
function failureBanner(detail, pageHref) {
|
|
188
|
+
if (detail.phase === "cancelled") {
|
|
189
|
+
return {
|
|
190
|
+
tone: "warning",
|
|
191
|
+
title: exports.CANCELLED_TITLE,
|
|
192
|
+
description: stillServing(detail),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
if (detail.phase !== "failed" || detail.failure === null)
|
|
196
|
+
return null;
|
|
197
|
+
const { step, summary, platform } = detail.failure;
|
|
198
|
+
const retry = platform
|
|
199
|
+
? " AntelopeJS Cloud failed, not your code: deploy the same commit again."
|
|
200
|
+
: "";
|
|
201
|
+
const banner = {
|
|
202
|
+
tone: "error",
|
|
203
|
+
title: failedAt(step),
|
|
204
|
+
description: `${summary === null ? "" : `${summary}. `}${stillServing(detail)}${retry}`,
|
|
205
|
+
};
|
|
206
|
+
if (detail.failure.buildId === null)
|
|
207
|
+
return banner;
|
|
208
|
+
return {
|
|
209
|
+
...banner,
|
|
210
|
+
actions: [
|
|
211
|
+
{
|
|
212
|
+
label: "Build log",
|
|
213
|
+
icon: "i-ph-terminal-window",
|
|
214
|
+
to: `${pageHref}?${exports.BUILD_LOG_QUERY}`,
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function readyBanner(detail, plan, rollbackUrl) {
|
|
220
|
+
const services = plan.moves.map(({ serviceName }) => serviceName).join(", ");
|
|
221
|
+
const name = nameOf(detail);
|
|
222
|
+
const [goBack, revisions] = plan.moves.length === 1
|
|
223
|
+
? ["goes back", "revision"]
|
|
224
|
+
: ["go back", "revisions"];
|
|
225
|
+
return {
|
|
226
|
+
tone: "info",
|
|
227
|
+
icon: "i-ph-arrow-counter-clockwise",
|
|
228
|
+
title: `Roll ${plan.environmentName} back to ${name}`,
|
|
229
|
+
description: `Puts ${services} back on the ${revisions} ${name} shipped.`,
|
|
230
|
+
actions: [
|
|
231
|
+
{
|
|
232
|
+
label: "Roll back",
|
|
233
|
+
icon: "i-ph-arrow-counter-clockwise",
|
|
234
|
+
target: {
|
|
235
|
+
type: "api",
|
|
236
|
+
url: rollbackUrl,
|
|
237
|
+
method: "POST",
|
|
238
|
+
successMessage: `${plan.environmentName} is back on ${name}`,
|
|
239
|
+
},
|
|
240
|
+
confirm: {
|
|
241
|
+
title: `Roll ${plan.environmentName} back to ${name}?`,
|
|
242
|
+
description: `${services} ${goBack} to the ${revisions} of ${name}. The traffic of ${plan.environmentName} switches at once.`,
|
|
243
|
+
icon: "i-ph-arrow-counter-clockwise",
|
|
244
|
+
color: "warning",
|
|
245
|
+
confirmLabel: "Roll back",
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
],
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Null unless the deployment went live and its environment serves another
|
|
253
|
+
* one now. A ready plan gives a Roll back button that confirms first; a
|
|
254
|
+
* refused one says why, with the refusal the button would answer.
|
|
255
|
+
*/
|
|
256
|
+
function rollbackBanner(detail, rollbackUrl) {
|
|
257
|
+
if (detail.phase !== "superseded")
|
|
258
|
+
return null;
|
|
259
|
+
const plan = detail.rollback;
|
|
260
|
+
if (plan.kind === "ready")
|
|
261
|
+
return readyBanner(detail, plan, rollbackUrl);
|
|
262
|
+
return {
|
|
263
|
+
tone: "info",
|
|
264
|
+
title: "No rollback to this deployment",
|
|
265
|
+
description: `$dms_antelope_cloud.errors.${plan.reason}`,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Phase, StepId } from "./lifecycle";
|
|
2
|
+
/** What started a deployment, when the Cloud API says. */
|
|
3
|
+
export type Trigger = "push" | "promotion" | "rollback" | "upload" | "restart";
|
|
4
|
+
/**
|
|
5
|
+
* One deployment AntelopeJS Cloud ran on an environment of the project.
|
|
6
|
+
* `number`, `commit`, `branch`, `trigger` and the times are null when the
|
|
7
|
+
* Cloud API does not say.
|
|
8
|
+
*/
|
|
9
|
+
export interface Deployment {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly environment: {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
};
|
|
15
|
+
readonly phase: Phase;
|
|
16
|
+
/** Counts up within its environment. */
|
|
17
|
+
readonly number: number | null;
|
|
18
|
+
readonly commit: string | null;
|
|
19
|
+
readonly branch: string | null;
|
|
20
|
+
readonly trigger: Trigger | null;
|
|
21
|
+
readonly startedAt: Date | null;
|
|
22
|
+
readonly finishedAt: Date | null;
|
|
23
|
+
}
|
|
24
|
+
/** The revision of one service that a deployment rolled out. */
|
|
25
|
+
export interface ShippedRevision {
|
|
26
|
+
readonly serviceId: string;
|
|
27
|
+
readonly serviceName: string;
|
|
28
|
+
readonly revisionNumber: number;
|
|
29
|
+
}
|
|
30
|
+
/** Why a deployment failed, as its detail page tells it. */
|
|
31
|
+
export interface DeploymentFailure {
|
|
32
|
+
readonly step: StepId;
|
|
33
|
+
/** The build log's summary; null when the Cloud API gives none. */
|
|
34
|
+
readonly summary: string | null;
|
|
35
|
+
/** The platform failed, not the source: deploying the same commit again is the way out. */
|
|
36
|
+
readonly platform: boolean;
|
|
37
|
+
/** The build that failed, whose log says the rest; null when no build did. */
|
|
38
|
+
readonly buildId: string | null;
|
|
39
|
+
}
|
|
40
|
+
/** Why an environment cannot go back to a deployment: a `$dms_antelope_cloud.errors.*` key. */
|
|
41
|
+
type RollbackRefusal = "rollback_not_found" | "rollback_serving" | "rollback_in_progress" | "rollback_missing_revision";
|
|
42
|
+
/** One service to move, and the revision it goes back to. */
|
|
43
|
+
export interface RollbackMove {
|
|
44
|
+
readonly serviceId: string;
|
|
45
|
+
readonly serviceName: string;
|
|
46
|
+
readonly revisionId: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* What rolling an environment back to a deployment does. Services already
|
|
50
|
+
* on their revision of it are left out of `moves`, so a plan made after a
|
|
51
|
+
* half-done rollback moves only what is left.
|
|
52
|
+
*/
|
|
53
|
+
export type RollbackPlan = {
|
|
54
|
+
readonly kind: "ready";
|
|
55
|
+
readonly environmentName: string;
|
|
56
|
+
readonly moves: readonly RollbackMove[];
|
|
57
|
+
} | {
|
|
58
|
+
readonly kind: "refused";
|
|
59
|
+
readonly reason: RollbackRefusal;
|
|
60
|
+
};
|
|
61
|
+
/** A deployment with what its detail page shows beyond the list row. */
|
|
62
|
+
export interface DeploymentDetail extends Deployment {
|
|
63
|
+
readonly revisions: readonly ShippedRevision[];
|
|
64
|
+
readonly reached: StepId;
|
|
65
|
+
readonly queuePosition: number | null;
|
|
66
|
+
readonly failure: DeploymentFailure | null;
|
|
67
|
+
/** What the environment serves now; after a failed deployment, the one before. */
|
|
68
|
+
readonly serving: {
|
|
69
|
+
readonly id: string;
|
|
70
|
+
readonly number: number;
|
|
71
|
+
} | null;
|
|
72
|
+
/** What rolling its environment back to it would do, planned from the same read. */
|
|
73
|
+
readonly rollback: RollbackPlan;
|
|
74
|
+
}
|
|
75
|
+
/** What {@link rollBack} did. */
|
|
76
|
+
export type RollbackOutcome = {
|
|
77
|
+
readonly kind: "done";
|
|
78
|
+
readonly environmentName: string;
|
|
79
|
+
} | {
|
|
80
|
+
readonly kind: "refused";
|
|
81
|
+
readonly reason: RollbackRefusal;
|
|
82
|
+
} | {
|
|
83
|
+
readonly kind: "partial";
|
|
84
|
+
readonly moved: readonly string[];
|
|
85
|
+
readonly left: readonly string[];
|
|
86
|
+
};
|
|
87
|
+
/** Where the deployment of a commit stands on its route. */
|
|
88
|
+
export interface CommitDeployment {
|
|
89
|
+
readonly id: string;
|
|
90
|
+
readonly phase: Phase;
|
|
91
|
+
/** The step it got to, read from its builds when the phase does not say. */
|
|
92
|
+
readonly reached: StepId;
|
|
93
|
+
/** Null unless it failed or was cancelled. */
|
|
94
|
+
readonly failure: DeploymentFailure | null;
|
|
95
|
+
}
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ActiveConnection } from "../connection/current";
|
|
2
|
+
/** The realtime topic the deployment pages' blocks read their routes again on. */
|
|
3
|
+
export declare const DEPLOYMENTS_TOPIC = "antelope-cloud.deployments";
|
|
4
|
+
/** Tells the tenant's open deployment pages to read their routes again. */
|
|
5
|
+
export declare function announceDeployments(tenantId: string): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Follows each deployment in `deploymentIds` that the tenant does not follow
|
|
8
|
+
* yet: holds its Cloud progress stream and publishes {@link DEPLOYMENTS_TOPIC}
|
|
9
|
+
* to the tenant when its status or queue position changes. Idempotent, so
|
|
10
|
+
* every read of a route calls it with the deployments it saw still running.
|
|
11
|
+
* A follower stops once its deployment ended, the sign-in is refused or not
|
|
12
|
+
* allowed to read it, or the deployment is gone, after 2 hours, or on
|
|
13
|
+
* {@link stopFollowing}; a dropped stream is opened again. At most 10 deployments per tenant are followed;
|
|
14
|
+
* the others wait for a later read.
|
|
15
|
+
*/
|
|
16
|
+
export declare function follow(tenantId: string, connection: ActiveConnection, deploymentIds: readonly string[]): void;
|
|
17
|
+
/** Stops the tenant's followers, or every follower without a tenant. */
|
|
18
|
+
export declare function stopFollowing(tenantId?: string): void;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEPLOYMENTS_TOPIC = void 0;
|
|
4
|
+
exports.announceDeployments = announceDeployments;
|
|
5
|
+
exports.follow = follow;
|
|
6
|
+
exports.stopFollowing = stopFollowing;
|
|
7
|
+
const promises_1 = require("node:timers/promises");
|
|
8
|
+
const realtime_1 = require("@antelopejs/interface-dms/realtime");
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
const cloud_1 = require("../connection/cloud");
|
|
11
|
+
const lifecycle_1 = require("./lifecycle");
|
|
12
|
+
/** The realtime topic the deployment pages' blocks read their routes again on. */
|
|
13
|
+
exports.DEPLOYMENTS_TOPIC = "antelope-cloud.deployments";
|
|
14
|
+
const MAX_FOLLOWED_PER_TENANT = 10;
|
|
15
|
+
const MAX_FOLLOW_MS = 2 * 60 * 60 * 1000;
|
|
16
|
+
const RECONNECT_DELAYS_MS = [250, 1_000, 5_000];
|
|
17
|
+
const progressSchema = zod_1.z.object({
|
|
18
|
+
status: zod_1.z.string().optional(),
|
|
19
|
+
position: zod_1.z.number().optional(),
|
|
20
|
+
});
|
|
21
|
+
const FOLLOWERS = new Map();
|
|
22
|
+
/** Tells the tenant's open deployment pages to read their routes again. */
|
|
23
|
+
function announceDeployments(tenantId) {
|
|
24
|
+
return (0, realtime_1.PublishMessage)(exports.DEPLOYMENTS_TOPIC, "changed", { tenantId });
|
|
25
|
+
}
|
|
26
|
+
function followerKey(tenantId, deploymentId) {
|
|
27
|
+
return JSON.stringify([tenantId, deploymentId]);
|
|
28
|
+
}
|
|
29
|
+
function followedBy(tenantId) {
|
|
30
|
+
let count = 0;
|
|
31
|
+
for (const follower of FOLLOWERS.values()) {
|
|
32
|
+
if (follower.tenantId === tenantId)
|
|
33
|
+
count += 1;
|
|
34
|
+
}
|
|
35
|
+
return count;
|
|
36
|
+
}
|
|
37
|
+
function changeOf(progress) {
|
|
38
|
+
if (progress.status !== undefined)
|
|
39
|
+
return `status:${progress.status}`;
|
|
40
|
+
if (progress.position !== undefined)
|
|
41
|
+
return `position:${progress.position}`;
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
async function readProgress(tenantId, events, published) {
|
|
45
|
+
for await (const event of events) {
|
|
46
|
+
const progress = progressSchema.safeParse(event.data).data ?? {};
|
|
47
|
+
const change = changeOf(progress);
|
|
48
|
+
if (change !== null && change !== published.last) {
|
|
49
|
+
published.last = change;
|
|
50
|
+
await announceDeployments(tenantId);
|
|
51
|
+
}
|
|
52
|
+
const { status } = progress;
|
|
53
|
+
if (status !== undefined && (0, lifecycle_1.isTerminal)((0, lifecycle_1.parseStatus)(status))) {
|
|
54
|
+
return "terminal";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return "dropped";
|
|
58
|
+
}
|
|
59
|
+
async function followOne(tenantId, connection, deploymentId, signal) {
|
|
60
|
+
const published = { last: null };
|
|
61
|
+
for (let attempt = 0; !signal.aborted; attempt += 1) {
|
|
62
|
+
const read = await (0, cloud_1.readCloud)(connection, (api) => readProgress(tenantId, api.progress(deploymentId, signal), published), { signal });
|
|
63
|
+
if (read.kind === "revoked" ||
|
|
64
|
+
read.kind === "missing" ||
|
|
65
|
+
read.kind === "forbidden") {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (read.kind === "ok" && read.value === "terminal")
|
|
69
|
+
return;
|
|
70
|
+
const delay = RECONNECT_DELAYS_MS[Math.min(attempt, RECONNECT_DELAYS_MS.length - 1)];
|
|
71
|
+
await (0, promises_1.setTimeout)(delay, undefined, { signal }).catch(() => undefined);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Follows each deployment in `deploymentIds` that the tenant does not follow
|
|
76
|
+
* yet: holds its Cloud progress stream and publishes {@link DEPLOYMENTS_TOPIC}
|
|
77
|
+
* to the tenant when its status or queue position changes. Idempotent, so
|
|
78
|
+
* every read of a route calls it with the deployments it saw still running.
|
|
79
|
+
* A follower stops once its deployment ended, the sign-in is refused or not
|
|
80
|
+
* allowed to read it, or the deployment is gone, after 2 hours, or on
|
|
81
|
+
* {@link stopFollowing}; a dropped stream is opened again. At most 10 deployments per tenant are followed;
|
|
82
|
+
* the others wait for a later read.
|
|
83
|
+
*/
|
|
84
|
+
function follow(tenantId, connection, deploymentIds) {
|
|
85
|
+
for (const deploymentId of deploymentIds) {
|
|
86
|
+
const key = followerKey(tenantId, deploymentId);
|
|
87
|
+
if (FOLLOWERS.has(key) || followedBy(tenantId) >= MAX_FOLLOWED_PER_TENANT) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const controller = new AbortController();
|
|
91
|
+
const lifetime = setTimeout(() => controller.abort(), MAX_FOLLOW_MS);
|
|
92
|
+
lifetime.unref();
|
|
93
|
+
FOLLOWERS.set(key, { tenantId, controller });
|
|
94
|
+
void followOne(tenantId, connection, deploymentId, controller.signal)
|
|
95
|
+
.catch(() => undefined)
|
|
96
|
+
.finally(() => {
|
|
97
|
+
clearTimeout(lifetime);
|
|
98
|
+
if (FOLLOWERS.get(key)?.controller === controller)
|
|
99
|
+
FOLLOWERS.delete(key);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** Stops the tenant's followers, or every follower without a tenant. */
|
|
104
|
+
function stopFollowing(tenantId) {
|
|
105
|
+
for (const [key, follower] of FOLLOWERS) {
|
|
106
|
+
if (tenantId === undefined || follower.tenantId === tenantId) {
|
|
107
|
+
follower.controller.abort();
|
|
108
|
+
FOLLOWERS.delete(key);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=follow.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type CloudApi, type EnvironmentDetail } from "@antelopejs/cloud-sdk";
|
|
2
|
+
import type { CommitDeployment, Deployment, DeploymentDetail, RollbackOutcome } from "./deployment";
|
|
3
|
+
/**
|
|
4
|
+
* Every deployment of the project, newest first. The seam for the Cloud
|
|
5
|
+
* project route: it reads that route, and composes the list from the
|
|
6
|
+
* environments and their services' histories only while it answers 404.
|
|
7
|
+
*/
|
|
8
|
+
export declare function readDeployments(api: CloudApi, projectId: string): Promise<Deployment[]>;
|
|
9
|
+
/** One deployment of the project, or null when no environment of the project ran it. */
|
|
10
|
+
export declare function readDeployment(api: CloudApi, projectId: string, deploymentId: string): Promise<DeploymentDetail | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Rolls the environment holding `deploymentId` back to it: reads the
|
|
13
|
+
* histories again, plans, then calls `api.rollback` service by service. A
|
|
14
|
+
* refusal comes before any write. A failure after the first move answers
|
|
15
|
+
* `partial`, and running it again moves only what is left.
|
|
16
|
+
*/
|
|
17
|
+
export declare function rollBack(api: CloudApi, projectId: string, deploymentId: string): Promise<RollbackOutcome>;
|
|
18
|
+
/**
|
|
19
|
+
* The deployment of `commit` on an environment: its target or serving one,
|
|
20
|
+
* else the newest the project ran of it, a replaced or cancelled one
|
|
21
|
+
* included. Null while the Cloud has run none.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readCommitDeployment(api: CloudApi, projectId: string, environment: EnvironmentDetail, commit: string): Promise<CommitDeployment | null>;
|