@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,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unavailableDialog = unavailableDialog;
|
|
4
|
+
exports.valueDialog = valueDialog;
|
|
5
|
+
exports.removeDialog = removeDialog;
|
|
6
|
+
exports.addDialog = addDialog;
|
|
7
|
+
const confirm_dialog_1 = require("@antelopejs/interface-dms/base/confirm-dialog");
|
|
8
|
+
const default_types_1 = require("@antelopejs/interface-dms/base/data-types/default-types");
|
|
9
|
+
const content_1 = require("./content");
|
|
10
|
+
const model_1 = require("./model");
|
|
11
|
+
const UNAVAILABLE = {
|
|
12
|
+
__proto__: null,
|
|
13
|
+
disconnected: {
|
|
14
|
+
title: "Not connected to AntelopeJS Cloud",
|
|
15
|
+
description: "Connect this DMS on the Connection page first.",
|
|
16
|
+
},
|
|
17
|
+
no_project: {
|
|
18
|
+
title: "No project chosen",
|
|
19
|
+
description: "Choose the project this DMS publishes on the Connection page first.",
|
|
20
|
+
},
|
|
21
|
+
revoked: {
|
|
22
|
+
title: "Your AntelopeJS Cloud sign-in was revoked",
|
|
23
|
+
description: "Sign in again on the Connection page.",
|
|
24
|
+
},
|
|
25
|
+
missing: {
|
|
26
|
+
title: "AntelopeJS Cloud has no such project any more",
|
|
27
|
+
description: "Choose the project this DMS publishes again.",
|
|
28
|
+
},
|
|
29
|
+
forbidden: {
|
|
30
|
+
title: "AntelopeJS Cloud does not allow this token here",
|
|
31
|
+
description: "Its access does not cover the variables of this project.",
|
|
32
|
+
},
|
|
33
|
+
unreachable: {
|
|
34
|
+
title: "AntelopeJS Cloud did not answer",
|
|
35
|
+
description: "Try again in a moment.",
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
const GONE = {
|
|
39
|
+
title: "This variable is gone",
|
|
40
|
+
description: "AntelopeJS Cloud no longer lists it here.",
|
|
41
|
+
};
|
|
42
|
+
function blocked(text) {
|
|
43
|
+
return (0, confirm_dialog_1.serializeConfirmDialog)({ ...text, blocked: true });
|
|
44
|
+
}
|
|
45
|
+
/** The dialog of an action the page cannot run: why it cannot read the project. */
|
|
46
|
+
function unavailableDialog(kind) {
|
|
47
|
+
return blocked(UNAVAILABLE[kind]);
|
|
48
|
+
}
|
|
49
|
+
function where(row) {
|
|
50
|
+
if (row.feeds.length > 0) {
|
|
51
|
+
return `Feeds ${(0, content_1.names)(row.feeds)} on ${row.environmentName}.`;
|
|
52
|
+
}
|
|
53
|
+
if (row.state !== "missing") {
|
|
54
|
+
return `Set on ${row.serviceName} on ${row.environmentName}.`;
|
|
55
|
+
}
|
|
56
|
+
return row.serviceName === undefined
|
|
57
|
+
? `Not set on ${row.environmentName}.`
|
|
58
|
+
: `${row.serviceName} reads it and does not hold it on ${row.environmentName}.`;
|
|
59
|
+
}
|
|
60
|
+
function secretValueField() {
|
|
61
|
+
return {
|
|
62
|
+
id: "value",
|
|
63
|
+
label: "Value",
|
|
64
|
+
required: true,
|
|
65
|
+
type: new default_types_1.DefaultDataTypes.PasswordType(),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function secretFlagField() {
|
|
69
|
+
return {
|
|
70
|
+
id: "secret",
|
|
71
|
+
label: "Secret",
|
|
72
|
+
description: "A secret can be replaced, never read back",
|
|
73
|
+
type: new default_types_1.DefaultDataTypes.BooleanType(),
|
|
74
|
+
defaultValue: true,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function serviceField(services) {
|
|
78
|
+
return {
|
|
79
|
+
id: "serviceId",
|
|
80
|
+
label: "Service",
|
|
81
|
+
required: true,
|
|
82
|
+
type: new default_types_1.DefaultDataTypes.SelectType({ items: [...services] }),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const VALUE_DIALOGS = {
|
|
86
|
+
wired: (row) => ({
|
|
87
|
+
title: `${row.key} follows ${row.publisherName} · ${row.publishedKey}`,
|
|
88
|
+
description: `AntelopeJS Cloud sets it from what ${row.publisherName} publishes. Remove it from ${row.serviceName} to provide a value of your own.`,
|
|
89
|
+
icon: "i-ph-link",
|
|
90
|
+
blocked: true,
|
|
91
|
+
}),
|
|
92
|
+
secret: (row) => ({
|
|
93
|
+
title: `Replace ${row.key}`,
|
|
94
|
+
description: `${where(row)} AntelopeJS Cloud never sends a secret back, so the current value stays hidden.`,
|
|
95
|
+
icon: "i-ph-lock-key",
|
|
96
|
+
confirmLabel: "Save secret",
|
|
97
|
+
fields: [secretValueField()],
|
|
98
|
+
}),
|
|
99
|
+
plain: (row) => ({
|
|
100
|
+
title: `Set ${row.key}`,
|
|
101
|
+
description: where(row),
|
|
102
|
+
icon: "i-ph-pencil-simple",
|
|
103
|
+
confirmLabel: "Save value",
|
|
104
|
+
fields: [
|
|
105
|
+
{
|
|
106
|
+
id: "value",
|
|
107
|
+
label: "Value",
|
|
108
|
+
required: true,
|
|
109
|
+
type: new default_types_1.DefaultDataTypes.StringType(),
|
|
110
|
+
defaultValue: row.value,
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
}),
|
|
114
|
+
missing: (row, read) => {
|
|
115
|
+
if (row.serviceName !== undefined) {
|
|
116
|
+
return {
|
|
117
|
+
title: `Set ${row.key} on ${row.serviceName}`,
|
|
118
|
+
description: where(row),
|
|
119
|
+
icon: "i-ph-lock-key",
|
|
120
|
+
confirmLabel: "Save secret",
|
|
121
|
+
fields: [secretValueField(), secretFlagField()],
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const services = read.environments.find(({ id }) => id === row.environmentId)?.services ??
|
|
125
|
+
[];
|
|
126
|
+
if (services.length === 0) {
|
|
127
|
+
return {
|
|
128
|
+
title: `Set ${row.key}`,
|
|
129
|
+
description: `No service runs on ${row.environmentName} yet.`,
|
|
130
|
+
blocked: true,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
title: `Set ${row.key}`,
|
|
135
|
+
description: where(row),
|
|
136
|
+
icon: "i-ph-lock-key",
|
|
137
|
+
confirmLabel: "Save secret",
|
|
138
|
+
fields: [
|
|
139
|
+
serviceField(services.map(({ id, name }) => ({ label: name, value: id }))),
|
|
140
|
+
secretValueField(),
|
|
141
|
+
secretFlagField(),
|
|
142
|
+
],
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
const REMOVE_WARNINGS = {
|
|
147
|
+
wired: "AntelopeJS Cloud stops wiring it; the service no longer receives the resource's value.",
|
|
148
|
+
secret: "The value cannot be recovered.",
|
|
149
|
+
plain: "The service no longer receives this value.",
|
|
150
|
+
};
|
|
151
|
+
function removal(row) {
|
|
152
|
+
return {
|
|
153
|
+
title: `Remove ${row.key} from ${row.serviceName} on ${row.environmentName}?`,
|
|
154
|
+
description: REMOVE_WARNINGS[row.state],
|
|
155
|
+
icon: "i-ph-trash",
|
|
156
|
+
color: "error",
|
|
157
|
+
confirmLabel: "Remove",
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const REMOVE_DIALOGS = {
|
|
161
|
+
wired: removal,
|
|
162
|
+
secret: removal,
|
|
163
|
+
plain: removal,
|
|
164
|
+
missing: (row) => ({
|
|
165
|
+
title: `${row.key} has no value on ${row.environmentName}`,
|
|
166
|
+
description: "There is nothing to remove.",
|
|
167
|
+
blocked: true,
|
|
168
|
+
}),
|
|
169
|
+
};
|
|
170
|
+
function dialogFor(dialogs, state, row, read) {
|
|
171
|
+
return dialogs[state](row, read);
|
|
172
|
+
}
|
|
173
|
+
function rowDialog(dialogs, read, ref) {
|
|
174
|
+
if (read.kind !== "ok")
|
|
175
|
+
return blocked(UNAVAILABLE[read.kind]);
|
|
176
|
+
const id = ref && (0, model_1.formatRef)(ref);
|
|
177
|
+
const row = read.rows.find((candidate) => candidate.ref === id);
|
|
178
|
+
if (!row)
|
|
179
|
+
return blocked(GONE);
|
|
180
|
+
return (0, confirm_dialog_1.serializeConfirmDialog)(dialogFor(dialogs, row.state, row, read));
|
|
181
|
+
}
|
|
182
|
+
function valueDialog(read, ref) {
|
|
183
|
+
return rowDialog(VALUE_DIALOGS, read, ref);
|
|
184
|
+
}
|
|
185
|
+
function removeDialog(read, ref) {
|
|
186
|
+
return rowDialog(REMOVE_DIALOGS, read, ref);
|
|
187
|
+
}
|
|
188
|
+
function addDialog(read) {
|
|
189
|
+
if (read.kind !== "ok")
|
|
190
|
+
return blocked(UNAVAILABLE[read.kind]);
|
|
191
|
+
const services = read.environments.flatMap(({ name, services: running }) => running.map(({ id, name: service }) => ({
|
|
192
|
+
label: `${name} · ${service}`,
|
|
193
|
+
value: id,
|
|
194
|
+
})));
|
|
195
|
+
if (services.length === 0) {
|
|
196
|
+
return blocked({
|
|
197
|
+
title: "This project runs no service yet",
|
|
198
|
+
description: "A variable is set on a service of an environment.",
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return (0, confirm_dialog_1.serializeConfirmDialog)({
|
|
202
|
+
title: "Add a variable",
|
|
203
|
+
description: "Set it on one service of one environment.",
|
|
204
|
+
icon: "i-ph-plus",
|
|
205
|
+
confirmLabel: "Add variable",
|
|
206
|
+
fields: [
|
|
207
|
+
serviceField(services),
|
|
208
|
+
{
|
|
209
|
+
id: "key",
|
|
210
|
+
label: "Name",
|
|
211
|
+
required: true,
|
|
212
|
+
type: new default_types_1.DefaultDataTypes.StringType(),
|
|
213
|
+
},
|
|
214
|
+
secretValueField(),
|
|
215
|
+
secretFlagField(),
|
|
216
|
+
],
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=dialogs.js.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { EnvironmentVariable } from "@antelopejs/cloud-sdk";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const variableKeySchema: z.ZodString;
|
|
4
|
+
interface CloudService {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CloudEnvironment {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly services: readonly CloudService[];
|
|
12
|
+
}
|
|
13
|
+
/** Which services of an environment run the project's API, and which its dashboard. */
|
|
14
|
+
interface EnvironmentRoles {
|
|
15
|
+
/** The app services, in order: those that are neither a database nor the dashboard. */
|
|
16
|
+
readonly apps: readonly string[];
|
|
17
|
+
/** The dashboard, `null` when the environment runs none. */
|
|
18
|
+
readonly dashboard: string | null;
|
|
19
|
+
}
|
|
20
|
+
export interface EnvironmentVariables {
|
|
21
|
+
readonly environment: CloudEnvironment;
|
|
22
|
+
readonly variables: readonly EnvironmentVariable[];
|
|
23
|
+
/**
|
|
24
|
+
* What its services are. Left out, or without a dashboard, a variable is
|
|
25
|
+
* missing when no service of the environment holds it.
|
|
26
|
+
*/
|
|
27
|
+
readonly roles?: EnvironmentRoles;
|
|
28
|
+
}
|
|
29
|
+
export type RowRef = {
|
|
30
|
+
readonly kind: "service";
|
|
31
|
+
readonly serviceId: string;
|
|
32
|
+
readonly key: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly kind: "environment";
|
|
35
|
+
readonly environmentId: string;
|
|
36
|
+
readonly key: string;
|
|
37
|
+
} | {
|
|
38
|
+
/** A variable one service lacks, which only that service is to hold. */
|
|
39
|
+
readonly kind: "missing";
|
|
40
|
+
readonly serviceId: string;
|
|
41
|
+
readonly key: string;
|
|
42
|
+
};
|
|
43
|
+
/** Reads a row id the browser sent, `undefined` when it is not one. */
|
|
44
|
+
export declare function parseRef(ref: string): RowRef | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* The row id of a ref: `s.<serviceId>.<key>` for a variable a service holds,
|
|
47
|
+
* `e.<environmentId>.<key>` for one no service of the environment holds, and
|
|
48
|
+
* `m.<serviceId>.<key>` for one that service lacks.
|
|
49
|
+
*/
|
|
50
|
+
export declare function formatRef(ref: RowRef): string;
|
|
51
|
+
interface RowBase {
|
|
52
|
+
readonly ref: string;
|
|
53
|
+
readonly environmentId: string;
|
|
54
|
+
readonly environmentName: string;
|
|
55
|
+
readonly key: string;
|
|
56
|
+
readonly feeds: readonly string[];
|
|
57
|
+
}
|
|
58
|
+
interface HeldRow extends RowBase {
|
|
59
|
+
readonly serviceId: string;
|
|
60
|
+
readonly serviceName: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A row of the Variables table. `wired` follows a value another service
|
|
64
|
+
* publishes; `secret` and `plain` were set by hand, `overridden` when another
|
|
65
|
+
* service of the environment holds the same key wired from a resource;
|
|
66
|
+
* `missing` is an `envOverrides` key no service of the environment holds. In
|
|
67
|
+
* an environment that runs a dashboard it is told per service: a key the
|
|
68
|
+
* app lacks, whatever the dashboard holds, or one of the variables a
|
|
69
|
+
* dashboard reads that the dashboard lacks; the row then names the service.
|
|
70
|
+
* A secret row has no value: AntelopeJS Cloud never sends one back. `feeds`
|
|
71
|
+
* are the config paths `envOverrides` maps the key to, none on the
|
|
72
|
+
* dashboard, which reads its variables from its environment.
|
|
73
|
+
*/
|
|
74
|
+
export type VariableRow = (HeldRow & {
|
|
75
|
+
readonly state: "wired";
|
|
76
|
+
readonly publisherName: string;
|
|
77
|
+
readonly publishedKey: string;
|
|
78
|
+
}) | (HeldRow & {
|
|
79
|
+
readonly state: "secret";
|
|
80
|
+
readonly value?: never;
|
|
81
|
+
readonly overridden: boolean;
|
|
82
|
+
}) | (HeldRow & {
|
|
83
|
+
readonly state: "plain";
|
|
84
|
+
readonly value: string;
|
|
85
|
+
readonly overridden: boolean;
|
|
86
|
+
}) | (RowBase & {
|
|
87
|
+
readonly state: "missing";
|
|
88
|
+
/** The one service that is to hold it, when the row is told per service. */
|
|
89
|
+
readonly serviceId?: string;
|
|
90
|
+
readonly serviceName?: string;
|
|
91
|
+
});
|
|
92
|
+
export type RowState = VariableRow["state"];
|
|
93
|
+
export type RowMap = {
|
|
94
|
+
[S in RowState]: Extract<VariableRow, {
|
|
95
|
+
state: S;
|
|
96
|
+
}>;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* The rows of the Variables table: each environment's in the project's
|
|
100
|
+
* order, wired rows first, then those set by hand, then the `envOverrides`
|
|
101
|
+
* keys no service holds.
|
|
102
|
+
*
|
|
103
|
+
* @param feeds The config paths `envOverrides` maps each key to
|
|
104
|
+
*/
|
|
105
|
+
export declare function deriveRows(environments: readonly EnvironmentVariables[], feeds: ReadonlyMap<string, readonly string[]>): VariableRow[];
|
|
106
|
+
export {};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.variableKeySchema = void 0;
|
|
4
|
+
exports.parseRef = parseRef;
|
|
5
|
+
exports.formatRef = formatRef;
|
|
6
|
+
exports.deriveRows = deriveRows;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const variables_1 = require("../dashboard/variables");
|
|
9
|
+
const KEY = "[A-Za-z_][A-Za-z0-9_]*";
|
|
10
|
+
exports.variableKeySchema = zod_1.z.string().regex(new RegExp(`^${KEY}$`));
|
|
11
|
+
const REF_PATTERN = new RegExp(`^([sem])\\.(.+)\\.(${KEY})$`);
|
|
12
|
+
const REF_PREFIXES = { service: "s", environment: "e", missing: "m" };
|
|
13
|
+
const refSchema = zod_1.z.string().transform((ref, context) => {
|
|
14
|
+
const match = REF_PATTERN.exec(ref);
|
|
15
|
+
if (!match) {
|
|
16
|
+
context.addIssue({ code: zod_1.z.ZodIssueCode.custom });
|
|
17
|
+
return zod_1.z.NEVER;
|
|
18
|
+
}
|
|
19
|
+
const [, prefix, owner, key] = match;
|
|
20
|
+
if (prefix === REF_PREFIXES.service) {
|
|
21
|
+
return { kind: "service", serviceId: owner, key };
|
|
22
|
+
}
|
|
23
|
+
return prefix === REF_PREFIXES.missing
|
|
24
|
+
? { kind: "missing", serviceId: owner, key }
|
|
25
|
+
: { kind: "environment", environmentId: owner, key };
|
|
26
|
+
});
|
|
27
|
+
/** Reads a row id the browser sent, `undefined` when it is not one. */
|
|
28
|
+
function parseRef(ref) {
|
|
29
|
+
return refSchema.safeParse(ref).data;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The row id of a ref: `s.<serviceId>.<key>` for a variable a service holds,
|
|
33
|
+
* `e.<environmentId>.<key>` for one no service of the environment holds, and
|
|
34
|
+
* `m.<serviceId>.<key>` for one that service lacks.
|
|
35
|
+
*/
|
|
36
|
+
function formatRef(ref) {
|
|
37
|
+
const owner = ref.kind === "environment" ? ref.environmentId : ref.serviceId;
|
|
38
|
+
return `${REF_PREFIXES[ref.kind]}.${owner}.${ref.key}`;
|
|
39
|
+
}
|
|
40
|
+
const STATE_ORDER = {
|
|
41
|
+
wired: 0,
|
|
42
|
+
plain: 1,
|
|
43
|
+
secret: 1,
|
|
44
|
+
missing: 2,
|
|
45
|
+
};
|
|
46
|
+
function nameOf(environment, serviceId) {
|
|
47
|
+
return (environment.services.find(({ id }) => id === serviceId)?.name ?? serviceId);
|
|
48
|
+
}
|
|
49
|
+
function heldRow(environment, variable, feeds, overridden) {
|
|
50
|
+
const { serviceId, key, origin } = variable;
|
|
51
|
+
const held = {
|
|
52
|
+
ref: formatRef({ kind: "service", serviceId, key }),
|
|
53
|
+
environmentId: environment.id,
|
|
54
|
+
environmentName: environment.name,
|
|
55
|
+
serviceId,
|
|
56
|
+
serviceName: nameOf(environment, serviceId),
|
|
57
|
+
key,
|
|
58
|
+
feeds,
|
|
59
|
+
};
|
|
60
|
+
if (origin.type === "resource") {
|
|
61
|
+
return {
|
|
62
|
+
...held,
|
|
63
|
+
state: "wired",
|
|
64
|
+
publisherName: nameOf(environment, origin.serviceId),
|
|
65
|
+
publishedKey: origin.publishedKey,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (variable.secret || variable.value === null) {
|
|
69
|
+
return { ...held, state: "secret", overridden };
|
|
70
|
+
}
|
|
71
|
+
return { ...held, state: "plain", value: variable.value, overridden };
|
|
72
|
+
}
|
|
73
|
+
function serviceNameOf(row) {
|
|
74
|
+
return row.serviceName ?? "";
|
|
75
|
+
}
|
|
76
|
+
function rowOrder(left, right) {
|
|
77
|
+
return (STATE_ORDER[left.state] - STATE_ORDER[right.state] ||
|
|
78
|
+
left.key.localeCompare(right.key) ||
|
|
79
|
+
serviceNameOf(left).localeCompare(serviceNameOf(right)));
|
|
80
|
+
}
|
|
81
|
+
/** A variable one service lacks. */
|
|
82
|
+
function missingOn(environment, serviceId, key, feeds) {
|
|
83
|
+
return {
|
|
84
|
+
ref: formatRef({ kind: "missing", serviceId, key }),
|
|
85
|
+
state: "missing",
|
|
86
|
+
environmentId: environment.id,
|
|
87
|
+
environmentName: environment.name,
|
|
88
|
+
serviceId,
|
|
89
|
+
serviceName: nameOf(environment, serviceId),
|
|
90
|
+
key,
|
|
91
|
+
feeds,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/** The `envOverrides` keys none of `holders` holds, as rows. */
|
|
95
|
+
function missingOverrides({ environment, variables }, feeds, holders) {
|
|
96
|
+
const heldKeys = new Set(variables
|
|
97
|
+
.filter(({ serviceId }) => holders === undefined || holders.includes(serviceId))
|
|
98
|
+
.map(({ key }) => key));
|
|
99
|
+
const [only] = holders?.length === 1 ? holders : [];
|
|
100
|
+
return [...feeds]
|
|
101
|
+
.filter(([key]) => !heldKeys.has(key) && exports.variableKeySchema.safeParse(key).success)
|
|
102
|
+
.map(([key, paths]) => only === undefined
|
|
103
|
+
? {
|
|
104
|
+
ref: formatRef({
|
|
105
|
+
kind: "environment",
|
|
106
|
+
environmentId: environment.id,
|
|
107
|
+
key,
|
|
108
|
+
}),
|
|
109
|
+
state: "missing",
|
|
110
|
+
environmentId: environment.id,
|
|
111
|
+
environmentName: environment.name,
|
|
112
|
+
key,
|
|
113
|
+
feeds: paths,
|
|
114
|
+
}
|
|
115
|
+
: missingOn(environment, only, key, paths));
|
|
116
|
+
}
|
|
117
|
+
/** The variables a dashboard reads that this one lacks, as rows. */
|
|
118
|
+
function missingOnDashboard({ environment, variables }, dashboard) {
|
|
119
|
+
const held = new Set(variables
|
|
120
|
+
.filter(({ serviceId }) => serviceId === dashboard)
|
|
121
|
+
.map(({ key }) => key));
|
|
122
|
+
return variables_1.DASHBOARD_KEYS.filter((key) => !held.has(key)).map((key) => missingOn(environment, dashboard, key, []));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The missing rows of an environment. Without a dashboard, an `envOverrides`
|
|
126
|
+
* key is missing when no service holds it. With one, it is missing when no
|
|
127
|
+
* app service holds it, on the app when there is one alone, and the
|
|
128
|
+
* dashboard misses each variable a dashboard reads that it does not hold.
|
|
129
|
+
*/
|
|
130
|
+
function missingRows(listed, feeds) {
|
|
131
|
+
const dashboard = listed.roles?.dashboard ?? null;
|
|
132
|
+
if (dashboard === null)
|
|
133
|
+
return missingOverrides(listed, feeds, undefined);
|
|
134
|
+
return [
|
|
135
|
+
...missingOverrides(listed, feeds, listed.roles?.apps ?? []),
|
|
136
|
+
...missingOnDashboard(listed, dashboard),
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
function environmentRows(listed, feeds) {
|
|
140
|
+
const { environment, variables } = listed;
|
|
141
|
+
const dashboard = listed.roles?.dashboard ?? null;
|
|
142
|
+
const wired = variables.filter(({ origin }) => origin.type === "resource");
|
|
143
|
+
const held = variables.map((variable) => heldRow(environment, variable, variable.serviceId === dashboard ? [] : (feeds.get(variable.key) ?? []), wired.some(({ key, serviceId }) => key === variable.key && serviceId !== variable.serviceId)));
|
|
144
|
+
return [...held, ...missingRows(listed, feeds)].sort(rowOrder);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The rows of the Variables table: each environment's in the project's
|
|
148
|
+
* order, wired rows first, then those set by hand, then the `envOverrides`
|
|
149
|
+
* keys no service holds.
|
|
150
|
+
*
|
|
151
|
+
* @param feeds The config paths `envOverrides` maps each key to
|
|
152
|
+
*/
|
|
153
|
+
function deriveRows(environments, feeds) {
|
|
154
|
+
return environments.flatMap((environment) => environmentRows(environment, feeds));
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
type ConfigNode = {
|
|
3
|
+
readonly kind: "text";
|
|
4
|
+
readonly text: string;
|
|
5
|
+
} | {
|
|
6
|
+
readonly kind: "number";
|
|
7
|
+
readonly value: number;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: "branch";
|
|
10
|
+
readonly entries: readonly (readonly [string, ConfigNode])[];
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: "other";
|
|
13
|
+
};
|
|
14
|
+
declare const projectConfigSchema: z.ZodObject<{
|
|
15
|
+
modules: z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodObject<{
|
|
16
|
+
config: z.ZodType<ConfigNode, z.ZodTypeDef, unknown>;
|
|
17
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
package: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
package?: string | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
package?: string | undefined;
|
|
23
|
+
}>>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
config: ConfigNode;
|
|
26
|
+
source?: {
|
|
27
|
+
package?: string | undefined;
|
|
28
|
+
} | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
source?: {
|
|
31
|
+
package?: string | undefined;
|
|
32
|
+
} | undefined;
|
|
33
|
+
config?: unknown;
|
|
34
|
+
}>, {
|
|
35
|
+
config: ConfigNode;
|
|
36
|
+
package: string | null;
|
|
37
|
+
}, {
|
|
38
|
+
source?: {
|
|
39
|
+
package?: string | undefined;
|
|
40
|
+
} | undefined;
|
|
41
|
+
config?: unknown;
|
|
42
|
+
}>>;
|
|
43
|
+
envOverrides: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodEffects<z.ZodString, string[], string>, z.ZodArray<z.ZodString, "many">]>>>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
modules: Record<string, {
|
|
46
|
+
config: ConfigNode;
|
|
47
|
+
package: string | null;
|
|
48
|
+
}>;
|
|
49
|
+
envOverrides: Record<string, string[]>;
|
|
50
|
+
}, {
|
|
51
|
+
modules: Record<string, {
|
|
52
|
+
source?: {
|
|
53
|
+
package?: string | undefined;
|
|
54
|
+
} | undefined;
|
|
55
|
+
config?: unknown;
|
|
56
|
+
}>;
|
|
57
|
+
envOverrides?: Record<string, string | string[]> | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
export type ProjectConfig = z.infer<typeof projectConfigSchema>;
|
|
60
|
+
export interface HardcodedSecret {
|
|
61
|
+
/** Its config path, such as `modules.dms.config.auth.jwtSecret`. */
|
|
62
|
+
readonly path: string;
|
|
63
|
+
/** The `envOverrides` name suggested for it, such as `DMS_JWT_SECRET`. */
|
|
64
|
+
readonly variable: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Reads a project config as `ConfigLoader` loads it, `{ modules, envOverrides }`;
|
|
68
|
+
* one it cannot read is a config without modules nor `envOverrides`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function parseProjectConfig(config: Parameters<typeof projectConfigSchema.parse>[0]): ProjectConfig;
|
|
71
|
+
export declare function feedsOf(envOverrides: ProjectConfig["envOverrides"]): ReadonlyMap<string, readonly string[]>;
|
|
72
|
+
/**
|
|
73
|
+
* The keys of the modules a config loads from the npm package `name`, in the
|
|
74
|
+
* order the file lists them.
|
|
75
|
+
*/
|
|
76
|
+
export declare function moduleKeysOf(config: ProjectConfig, name: string): string[];
|
|
77
|
+
/**
|
|
78
|
+
* The port the project's API answers on: the first `http` server of its
|
|
79
|
+
* `@antelopejs/api` module, as `servers: [{ protocol: "http", port }]`
|
|
80
|
+
* declares it. `null` when the config loads no such module, the module opens
|
|
81
|
+
* no `http` server, or its port is not a number written in the file.
|
|
82
|
+
*/
|
|
83
|
+
export declare function apiHttpPort(config: ProjectConfig): number | null;
|
|
84
|
+
/**
|
|
85
|
+
* The secrets the config file sets for every environment at once: a module
|
|
86
|
+
* config leaf named like a secret, holding a non-empty string that is not a
|
|
87
|
+
* `${@module.KEY}` template, whose path no valid `envOverrides` name feeds. A
|
|
88
|
+
* finding names the path only, never the value.
|
|
89
|
+
*
|
|
90
|
+
* @param config The config as {@link loadFileConfig} reads it, with no
|
|
91
|
+
* environment, so a value read from an environment variable is absent.
|
|
92
|
+
*/
|
|
93
|
+
export declare function hardcodedSecrets(config: ProjectConfig): HardcodedSecret[];
|
|
94
|
+
/**
|
|
95
|
+
* Loads the project config in a child process that sees no environment
|
|
96
|
+
* variable: a value the file reads from one, or from a `.env` file, is
|
|
97
|
+
* absent, so every value left was written in the file. Nothing the config
|
|
98
|
+
* prints is read. Resolves to a config without modules nor `envOverrides`
|
|
99
|
+
* when the file is missing, throws, needs an environment variable to load,
|
|
100
|
+
* or takes longer than 15 s; the child is then killed, and it exits on its
|
|
101
|
+
* own once this process is gone.
|
|
102
|
+
*
|
|
103
|
+
* The one variable the child does see is `JITI_FS_CACHE=false`. Without it
|
|
104
|
+
* the config loader of core 1.23 keeps a transpiled copy of the file under
|
|
105
|
+
* the temporary directory, which the missing environment turns into an
|
|
106
|
+
* `undefined` folder of the project on Windows. The child writes nothing.
|
|
107
|
+
*/
|
|
108
|
+
export declare function loadFileConfig(projectPath: string): Promise<ProjectConfig>;
|
|
109
|
+
/**
|
|
110
|
+
* The running project's config as {@link loadFileConfig} reads it, read
|
|
111
|
+
* again once its file was written since the last read, so a page shows and a
|
|
112
|
+
* write acts on the file as it is, and after 30 s in any case, for what the
|
|
113
|
+
* file loads from elsewhere. A missing or unreadable file reads as a config
|
|
114
|
+
* without modules nor `envOverrides`.
|
|
115
|
+
*/
|
|
116
|
+
export declare function readProjectConfig(): Promise<ProjectConfig>;
|
|
117
|
+
export {};
|