@rcpooley/concord 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 +21 -0
- package/README.md +318 -0
- package/bin/concord.service +69 -0
- package/dist/age.d.ts +20 -0
- package/dist/age.d.ts.map +1 -0
- package/dist/age.js +58 -0
- package/dist/age.js.map +1 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +301 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/daemon.d.ts +4 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +394 -0
- package/dist/daemon.js.map +1 -0
- package/dist/eval-config.d.ts +2 -0
- package/dist/eval-config.d.ts.map +1 -0
- package/dist/eval-config.js +45 -0
- package/dist/eval-config.js.map +1 -0
- package/dist/exec.d.ts +168 -0
- package/dist/exec.d.ts.map +1 -0
- package/dist/exec.js +313 -0
- package/dist/exec.js.map +1 -0
- package/dist/git.d.ts +59 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +265 -0
- package/dist/git.js.map +1 -0
- package/dist/hook.d.ts +37 -0
- package/dist/hook.d.ts.map +1 -0
- package/dist/hook.js +89 -0
- package/dist/hook.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +76 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +236 -0
- package/dist/init.js.map +1 -0
- package/dist/loader.d.ts +35 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +230 -0
- package/dist/loader.js.map +1 -0
- package/dist/module.d.ts +116 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +100 -0
- package/dist/module.js.map +1 -0
- package/dist/modules/apt/index.d.ts +45 -0
- package/dist/modules/apt/index.d.ts.map +1 -0
- package/dist/modules/apt/index.js +249 -0
- package/dist/modules/apt/index.js.map +1 -0
- package/dist/modules/apt/schema.d.ts +63 -0
- package/dist/modules/apt/schema.d.ts.map +1 -0
- package/dist/modules/apt/schema.js +75 -0
- package/dist/modules/apt/schema.js.map +1 -0
- package/dist/modules/checkout/index.d.ts +88 -0
- package/dist/modules/checkout/index.d.ts.map +1 -0
- package/dist/modules/checkout/index.js +382 -0
- package/dist/modules/checkout/index.js.map +1 -0
- package/dist/modules/checkout/schema.d.ts +52 -0
- package/dist/modules/checkout/schema.d.ts.map +1 -0
- package/dist/modules/checkout/schema.js +132 -0
- package/dist/modules/checkout/schema.js.map +1 -0
- package/dist/modules/cloudflare/api.d.ts +64 -0
- package/dist/modules/cloudflare/api.d.ts.map +1 -0
- package/dist/modules/cloudflare/api.js +98 -0
- package/dist/modules/cloudflare/api.js.map +1 -0
- package/dist/modules/cloudflare/index.d.ts +74 -0
- package/dist/modules/cloudflare/index.d.ts.map +1 -0
- package/dist/modules/cloudflare/index.js +374 -0
- package/dist/modules/cloudflare/index.js.map +1 -0
- package/dist/modules/cloudflare/schema.d.ts +62 -0
- package/dist/modules/cloudflare/schema.d.ts.map +1 -0
- package/dist/modules/cloudflare/schema.js +85 -0
- package/dist/modules/cloudflare/schema.js.map +1 -0
- package/dist/modules/docker/index.d.ts +83 -0
- package/dist/modules/docker/index.d.ts.map +1 -0
- package/dist/modules/docker/index.js +470 -0
- package/dist/modules/docker/index.js.map +1 -0
- package/dist/modules/docker/registry.d.ts +35 -0
- package/dist/modules/docker/registry.d.ts.map +1 -0
- package/dist/modules/docker/registry.js +95 -0
- package/dist/modules/docker/registry.js.map +1 -0
- package/dist/modules/docker/render.d.ts +45 -0
- package/dist/modules/docker/render.d.ts.map +1 -0
- package/dist/modules/docker/render.js +162 -0
- package/dist/modules/docker/render.js.map +1 -0
- package/dist/modules/docker/schema.d.ts +231 -0
- package/dist/modules/docker/schema.d.ts.map +1 -0
- package/dist/modules/docker/schema.js +335 -0
- package/dist/modules/docker/schema.js.map +1 -0
- package/dist/modules/docker/sweeper.d.ts +64 -0
- package/dist/modules/docker/sweeper.d.ts.map +1 -0
- package/dist/modules/docker/sweeper.js +94 -0
- package/dist/modules/docker/sweeper.js.map +1 -0
- package/dist/modules/file/index.d.ts +79 -0
- package/dist/modules/file/index.d.ts.map +1 -0
- package/dist/modules/file/index.js +305 -0
- package/dist/modules/file/index.js.map +1 -0
- package/dist/modules/file/schema.d.ts +45 -0
- package/dist/modules/file/schema.d.ts.map +1 -0
- package/dist/modules/file/schema.js +114 -0
- package/dist/modules/file/schema.js.map +1 -0
- package/dist/modules/index.d.ts +20 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +11 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/porkbun/api.d.ts +36 -0
- package/dist/modules/porkbun/api.d.ts.map +1 -0
- package/dist/modules/porkbun/api.js +62 -0
- package/dist/modules/porkbun/api.js.map +1 -0
- package/dist/modules/porkbun/index.d.ts +50 -0
- package/dist/modules/porkbun/index.d.ts.map +1 -0
- package/dist/modules/porkbun/index.js +236 -0
- package/dist/modules/porkbun/index.js.map +1 -0
- package/dist/modules/porkbun/schema.d.ts +38 -0
- package/dist/modules/porkbun/schema.d.ts.map +1 -0
- package/dist/modules/porkbun/schema.js +39 -0
- package/dist/modules/porkbun/schema.js.map +1 -0
- package/dist/modules/script/index.d.ts +43 -0
- package/dist/modules/script/index.d.ts.map +1 -0
- package/dist/modules/script/index.js +116 -0
- package/dist/modules/script/index.js.map +1 -0
- package/dist/modules/script/schema.d.ts +25 -0
- package/dist/modules/script/schema.d.ts.map +1 -0
- package/dist/modules/script/schema.js +63 -0
- package/dist/modules/script/schema.js.map +1 -0
- package/dist/modules/systemd/index.d.ts +93 -0
- package/dist/modules/systemd/index.d.ts.map +1 -0
- package/dist/modules/systemd/index.js +394 -0
- package/dist/modules/systemd/index.js.map +1 -0
- package/dist/modules/systemd/render.d.ts +41 -0
- package/dist/modules/systemd/render.d.ts.map +1 -0
- package/dist/modules/systemd/render.js +252 -0
- package/dist/modules/systemd/render.js.map +1 -0
- package/dist/modules/systemd/schema.d.ts +293 -0
- package/dist/modules/systemd/schema.d.ts.map +1 -0
- package/dist/modules/systemd/schema.js +302 -0
- package/dist/modules/systemd/schema.js.map +1 -0
- package/dist/modules/systemd/sweeper.d.ts +31 -0
- package/dist/modules/systemd/sweeper.d.ts.map +1 -0
- package/dist/modules/systemd/sweeper.js +77 -0
- package/dist/modules/systemd/sweeper.js.map +1 -0
- package/dist/plans.d.ts +132 -0
- package/dist/plans.d.ts.map +1 -0
- package/dist/plans.js +315 -0
- package/dist/plans.js.map +1 -0
- package/dist/records.d.ts +37 -0
- package/dist/records.d.ts.map +1 -0
- package/dist/records.js +100 -0
- package/dist/records.js.map +1 -0
- package/dist/registry.d.ts +38 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +31 -0
- package/dist/registry.js.map +1 -0
- package/dist/runner.d.ts +48 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +150 -0
- package/dist/runner.js.map +1 -0
- package/dist/scheduler.d.ts +36 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +77 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/schema.d.ts +762 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +185 -0
- package/dist/schema.js.map +1 -0
- package/dist/secret.d.ts +24 -0
- package/dist/secret.d.ts.map +1 -0
- package/dist/secret.js +3 -0
- package/dist/secret.js.map +1 -0
- package/dist/ui.d.ts +62 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +288 -0
- package/dist/ui.js.map +1 -0
- package/package.json +57 -0
package/dist/loader.js
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { execFile, execFileSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, mkdirSync, rmSync } from 'node:fs';
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { promisify } from 'node:util';
|
|
6
|
+
import { REGISTRY, instantiate } from './registry.js';
|
|
7
|
+
import { ConcordConfigSchema, SCHEMA_VERSION } from './schema.js';
|
|
8
|
+
/** Root of the running reconciler package (the dir holding package.json). */
|
|
9
|
+
export const RECONCILER_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
10
|
+
function git(cwd, ...args) {
|
|
11
|
+
return execFileSync('git', args, {
|
|
12
|
+
cwd,
|
|
13
|
+
encoding: 'utf8',
|
|
14
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
15
|
+
timeout: 120_000,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/** Clone the config repo if absent, otherwise fast-forward it. Returns the SHA. */
|
|
19
|
+
export function syncConfigRepo(repoUrl, dest) {
|
|
20
|
+
if (!existsSync(join(dest, '.git'))) {
|
|
21
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
22
|
+
rmSync(dest, { recursive: true, force: true });
|
|
23
|
+
execFileSync('git', ['clone', '--depth', '50', repoUrl, dest], {
|
|
24
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
25
|
+
timeout: 300_000,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// A dirty checkout means someone is mid-edit in this tree, and the
|
|
30
|
+
// `reset --hard` below would silently destroy that work — it has. The
|
|
31
|
+
// daemon's own checkout is never dirty, so this guard only ever fires to
|
|
32
|
+
// save a human who pointed CONCORD_CONFIG_DIR at their working tree.
|
|
33
|
+
const dirty = git(dest, 'status', '--porcelain').trim();
|
|
34
|
+
if (dirty) {
|
|
35
|
+
throw new Error(`config checkout at ${dest} has uncommitted changes — refusing to reset it.\n` +
|
|
36
|
+
`Commit or stash them, or point CONCORD_CONFIG_DIR at a clean clone.`);
|
|
37
|
+
}
|
|
38
|
+
git(dest, 'fetch', '--depth', '50', 'origin');
|
|
39
|
+
const branch = git(dest, 'rev-parse', '--abbrev-ref', 'HEAD').trim();
|
|
40
|
+
git(dest, 'reset', '--hard', `origin/${branch}`);
|
|
41
|
+
}
|
|
42
|
+
return git(dest, 'rev-parse', 'HEAD').trim();
|
|
43
|
+
}
|
|
44
|
+
/** Modules that execute ON a host. The rest drive a remote API and take no host. */
|
|
45
|
+
const HOST_SCOPED = new Set(['apt', 'file', 'systemd', 'script', 'docker']);
|
|
46
|
+
const execFileAsync = promisify(execFile);
|
|
47
|
+
/**
|
|
48
|
+
* Evaluate `concord.ts` in a short-lived child and return its default export.
|
|
49
|
+
*
|
|
50
|
+
* Out of process on purpose — see `eval-config.ts`. After this the daemon never
|
|
51
|
+
* loads tsx or esbuild at all, so no long-lived helper can die underneath it.
|
|
52
|
+
*/
|
|
53
|
+
export async function evaluateConfig(configDir, opts = {}) {
|
|
54
|
+
const timeoutMs = opts.timeoutMs ?? 60_000;
|
|
55
|
+
let stdout;
|
|
56
|
+
try {
|
|
57
|
+
;
|
|
58
|
+
({ stdout } = await execFileAsync(process.execPath, [join(RECONCILER_ROOT, 'dist', 'eval-config.js'), configDir], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, timeout: timeoutMs, killSignal: 'SIGKILL' }));
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
const e = err;
|
|
62
|
+
if (e.code === 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER') {
|
|
63
|
+
throw new Error(`config evaluation printed more than 64 MB — concord.ts must be plain data`);
|
|
64
|
+
}
|
|
65
|
+
if (e.killed) {
|
|
66
|
+
throw new Error(`config evaluation timed out after ${timeoutMs / 1000}s — concord.ts must be plain data; ` +
|
|
67
|
+
`nothing in it may wait on the network`);
|
|
68
|
+
}
|
|
69
|
+
if (e.signal)
|
|
70
|
+
throw new Error(`config evaluation killed by ${e.signal}`);
|
|
71
|
+
throw new Error(`config evaluation failed:\n${(e.stderr ?? '').trim() || e.message}`);
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
return JSON.parse(stdout);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
throw new Error(`config evaluation printed something that is not JSON: ${JSON.stringify(stdout.slice(0, 200))}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export async function loadConfig(configDir, opts = {}) {
|
|
81
|
+
const entry = join(configDir, 'concord.ts');
|
|
82
|
+
if (!existsSync(entry)) {
|
|
83
|
+
throw new Error(`Config repo has no concord.ts at ${entry}`);
|
|
84
|
+
}
|
|
85
|
+
const raw = await evaluateConfig(configDir, opts);
|
|
86
|
+
if (raw == null || typeof raw !== 'object') {
|
|
87
|
+
throw new Error(`concord.ts must have a default export: ` +
|
|
88
|
+
`\`export default { schemaVersion, modules } satisfies ConcordConfig\``);
|
|
89
|
+
}
|
|
90
|
+
// Checked before the full parse so the error names the actual problem rather
|
|
91
|
+
// than surfacing as a confusing literal-mismatch deep in a zod report.
|
|
92
|
+
const declared = raw.schemaVersion;
|
|
93
|
+
if (declared !== SCHEMA_VERSION) {
|
|
94
|
+
throw new Error(`Schema version mismatch: the config declares schemaVersion ` +
|
|
95
|
+
`${JSON.stringify(declared)}, this reconciler is schema ${SCHEMA_VERSION}. ` +
|
|
96
|
+
(typeof declared === 'number' && declared > SCHEMA_VERSION
|
|
97
|
+
? `The config was authored against a NEWER concord than is running — ` +
|
|
98
|
+
`the reconciler is stale.`
|
|
99
|
+
: `Update the config to the current schema, or roll the reconciler back.`));
|
|
100
|
+
}
|
|
101
|
+
const parsed = ConcordConfigSchema.safeParse(raw);
|
|
102
|
+
if (!parsed.success) {
|
|
103
|
+
// Report EVERY problem at once — the config is input now, and fixing one
|
|
104
|
+
// error per run is miserable.
|
|
105
|
+
const lines = parsed.error.issues.map((i) => ` • ${i.path.join('.') || '(root)'}: ${i.message}`);
|
|
106
|
+
throw new Error(`Invalid config:\n${lines.join('\n')}`);
|
|
107
|
+
}
|
|
108
|
+
// Identity is `type:id@host`, matching the scope a module reports in plans
|
|
109
|
+
// and logs. The same id on two DIFFERENT hosts is not a collision — one
|
|
110
|
+
// helper expanded per host is how one service (a reverse proxy, say) runs
|
|
111
|
+
// on more than one machine — but two on the SAME host are indistinguishable in a plan.
|
|
112
|
+
const seen = new Set();
|
|
113
|
+
for (const m of parsed.data.modules) {
|
|
114
|
+
const key = m.host ? `${m.type}:${m.id}@${m.host}` : `${m.type}:${m.id}`;
|
|
115
|
+
if (seen.has(key))
|
|
116
|
+
throw new Error(`Duplicate module id ${key}`);
|
|
117
|
+
seen.add(key);
|
|
118
|
+
}
|
|
119
|
+
// Every network a container joins must be declared by SOME docker module on
|
|
120
|
+
// the same host. The rendered compose says `external: true`, so an undeclared
|
|
121
|
+
// network already fails at deploy — this moves that failure to plan time,
|
|
122
|
+
// before a single container is touched, and names the typo instead of
|
|
123
|
+
// reporting a missing network.
|
|
124
|
+
//
|
|
125
|
+
// Cross-MODULE on purpose: one module owns a shared network and others join
|
|
126
|
+
// it, which a per-module schema cannot see. Same category as the duplicate-id
|
|
127
|
+
// and unknown-host checks around it.
|
|
128
|
+
const netProblems = [];
|
|
129
|
+
const declaredNets = new Map();
|
|
130
|
+
for (const m of parsed.data.modules) {
|
|
131
|
+
if (m.type !== 'docker')
|
|
132
|
+
continue;
|
|
133
|
+
const set = declaredNets.get(m.host) ?? new Set();
|
|
134
|
+
for (const n of m.networks ?? [])
|
|
135
|
+
set.add(n.name);
|
|
136
|
+
declaredNets.set(m.host, set);
|
|
137
|
+
}
|
|
138
|
+
for (const m of parsed.data.modules) {
|
|
139
|
+
if (m.type !== 'docker')
|
|
140
|
+
continue;
|
|
141
|
+
const known = declaredNets.get(m.host) ?? new Set();
|
|
142
|
+
for (const c of m.containers ?? []) {
|
|
143
|
+
for (const n of c.networks ?? []) {
|
|
144
|
+
if (!known.has(n.name)) {
|
|
145
|
+
netProblems.push(`docker:${m.id}: container "${c.name}" joins network "${n.name}", ` +
|
|
146
|
+
`which no docker module on ${m.host} declares`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (netProblems.length) {
|
|
152
|
+
throw new Error(`Invalid config:\n${netProblems.map((p) => ` • ${p}`).join('\n')}`);
|
|
153
|
+
}
|
|
154
|
+
// No container may bind-mount, as a single FILE, a path a file module
|
|
155
|
+
// manages on the same host. A file bind pins the inode and the file module
|
|
156
|
+
// replaces the inode on every write, so the container keeps reading the old
|
|
157
|
+
// content until it is recreated — a proxy running on a stale config that
|
|
158
|
+
// way fails every cycle. Cross-module for the same reason as
|
|
159
|
+
// the network check: neither module can see the other's paths.
|
|
160
|
+
const managedFiles = new Map();
|
|
161
|
+
for (const m of parsed.data.modules) {
|
|
162
|
+
if (m.type !== 'file')
|
|
163
|
+
continue;
|
|
164
|
+
const paths = managedFiles.get(m.host) ?? new Map();
|
|
165
|
+
for (const f of m.files ?? [])
|
|
166
|
+
paths.set(f.path, m.id);
|
|
167
|
+
managedFiles.set(m.host, paths);
|
|
168
|
+
}
|
|
169
|
+
const bindProblems = [];
|
|
170
|
+
for (const m of parsed.data.modules) {
|
|
171
|
+
if (m.type !== 'docker')
|
|
172
|
+
continue;
|
|
173
|
+
const managed = managedFiles.get(m.host);
|
|
174
|
+
for (const c of m.containers ?? []) {
|
|
175
|
+
for (const v of c.volumes ?? []) {
|
|
176
|
+
const fileId = v.hostPath ? managed?.get(v.hostPath) : undefined;
|
|
177
|
+
if (!fileId)
|
|
178
|
+
continue;
|
|
179
|
+
bindProblems.push(`docker:${m.id}: container "${c.name}" bind-mounts ${v.hostPath} as a single file, ` +
|
|
180
|
+
`which file:${fileId} manages on ${m.host}. A file bind pins the inode and the file ` +
|
|
181
|
+
`module replaces the inode on every write, so the container would keep serving the ` +
|
|
182
|
+
`old content. Mount the directory that contains it instead.`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (bindProblems.length) {
|
|
187
|
+
throw new Error(`Invalid config:\n${bindProblems.map((p) => ` • ${p}`).join('\n')}`);
|
|
188
|
+
}
|
|
189
|
+
const hosts = parsed.data.hosts;
|
|
190
|
+
// `host` being required is enforced by the schema; this catches the one thing
|
|
191
|
+
// a per-module schema cannot see — whether the named host actually exists.
|
|
192
|
+
// No check for "this module takes no host": every module schema is .strict(),
|
|
193
|
+
// so `host` on `porkbun` is already rejected at the exact path, and an
|
|
194
|
+
// unreachable second check would imply a guarantee that is not there.
|
|
195
|
+
const problems = [];
|
|
196
|
+
parsed.data.modules.forEach((m, i) => {
|
|
197
|
+
if (!HOST_SCOPED.has(m.type))
|
|
198
|
+
return;
|
|
199
|
+
if (!hosts[m.host]) {
|
|
200
|
+
problems.push(`modules.${i} (${m.type}:${m.id}) names host "${m.host}", which is not in the registry ` +
|
|
201
|
+
`(have: ${Object.keys(hosts).join(', ')})`);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
if (problems.length) {
|
|
205
|
+
throw new Error(`Invalid config:\n${problems.map((p) => ` • ${p}`).join('\n')}`);
|
|
206
|
+
}
|
|
207
|
+
const modules = parsed.data.modules.map(instantiate);
|
|
208
|
+
// Host-truth sweepers — a property of the module KIND, not of the config.
|
|
209
|
+
// Each kind that defines one gets an enforcer per registry host, appended at
|
|
210
|
+
// the tail so removals run after every declared module ("array order IS the
|
|
211
|
+
// dependency"). EVERY host, deliberately: deriving the list from hosts that
|
|
212
|
+
// have modules of the kind would switch sweeping off when the last module is
|
|
213
|
+
// deleted — orphaning exactly the units the sweep exists to remove. The
|
|
214
|
+
// keep-set is the union of owned() across the kind's instances on the host;
|
|
215
|
+
// an empty set is valid and means everything tagged goes.
|
|
216
|
+
for (const [kindName, kind] of Object.entries(REGISTRY)) {
|
|
217
|
+
if (!kind.sweeper)
|
|
218
|
+
continue;
|
|
219
|
+
for (const [host, config] of Object.entries(hosts)) {
|
|
220
|
+
const keep = new Set(modules.filter((m) => m.kind === kindName && m.host === host).flatMap((m) => m.owned()));
|
|
221
|
+
modules.push(kind.sweeper(host, keep, config));
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
modules,
|
|
226
|
+
hosts,
|
|
227
|
+
settings: (parsed.data.settings ?? {}),
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CACpC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACvC,IAAI,CACL,CAAA;AAED,SAAS,GAAG,CAAC,GAAW,EAAE,GAAG,IAAc;IACzC,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE;QAC/B,GAAG;QACH,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;QACjC,OAAO,EAAE,OAAO;KACjB,CAAC,CAAA;AACJ,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,IAAY;IAC1D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;QACpC,SAAS,CAAC,OAAO,CAAC,IAAI,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,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IAEpD,0EAA0E;IAC1E,6EAA6E;IAC7E,4EAA4E;IAC5E,4EAA4E;IAC5E,6EAA6E;IAC7E,wEAAwE;IACxE,4EAA4E;IAC5E,0DAA0D;IAC1D,KAAK,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxD,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,SAAQ;QAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACnD,MAAM,IAAI,GAAG,IAAI,GAAG,CAClB,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CACxF,CAAA;YACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO;QACP,KAAK;QACL,QAAQ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAa;KACnD,CAAA;AACH,CAAC"}
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The module contract — the load-bearing interface of the whole system.
|
|
3
|
+
*
|
|
4
|
+
* A module is a driver for exactly one target (a DNS account, a registrar, a
|
|
5
|
+
* host). It never re-implements the service it drives; it reads
|
|
6
|
+
* live state, diffs it against what the config declares, and applies the
|
|
7
|
+
* difference through the service's own API.
|
|
8
|
+
*/
|
|
9
|
+
import type { Exec } from './exec.js';
|
|
10
|
+
import type { Secret } from './secret.js';
|
|
11
|
+
import type { Settings } from './schema.js';
|
|
12
|
+
/**
|
|
13
|
+
* Every operation classifies itself. This is what lets the runner count,
|
|
14
|
+
* render, and (later) gate destructive changes without knowing anything about
|
|
15
|
+
* DNS or containers. `custom` is the escape hatch for a module whose work
|
|
16
|
+
* genuinely doesn't fit CRUD — it should be rare enough to notice.
|
|
17
|
+
*/
|
|
18
|
+
export type OpKind = 'create' | 'update' | 'delete' | 'custom';
|
|
19
|
+
export interface BaseOp {
|
|
20
|
+
kind: OpKind;
|
|
21
|
+
/** Stable identity of the affected object, within this module. */
|
|
22
|
+
id: string;
|
|
23
|
+
/** One line, human- and agent-readable. Shows up in the plan. */
|
|
24
|
+
summary: string;
|
|
25
|
+
}
|
|
26
|
+
/** Injected by the runner. Modules reach it through protected helpers. */
|
|
27
|
+
export interface ModuleRuntime {
|
|
28
|
+
resolveSecret(secret: Secret): Promise<string>;
|
|
29
|
+
log(scope: string, message: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Report something that did NOT converge without failing the run.
|
|
32
|
+
*
|
|
33
|
+
* The only current source is a module whose config declares the failure a
|
|
34
|
+
* warning (`app`'s `failureIsWarning`). Warnings are carried in the run
|
|
35
|
+
* result and reported at the end — never only logged, because a run that
|
|
36
|
+
* drops a failure on the floor is the same mistake as reading an absent
|
|
37
|
+
* answer as a satisfied one.
|
|
38
|
+
*/
|
|
39
|
+
warn(scope: string, message: string): void;
|
|
40
|
+
/** Per-module scratch dir on the reconciler host. NEVER the config repo. */
|
|
41
|
+
stateDir(moduleId: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Root of the checked-out config repo. Lets a module resolve paths declared
|
|
44
|
+
* relative to it — e.g. a file whose content lives beside the config.
|
|
45
|
+
*/
|
|
46
|
+
configDir: string;
|
|
47
|
+
/** Fleet-wide settings from the config. Empty object when none declared. */
|
|
48
|
+
settings: Settings;
|
|
49
|
+
/** Which host this module targets, for log scoping. Undefined means local. */
|
|
50
|
+
hostName?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Host execution for THIS module's target host. The runner builds one per
|
|
53
|
+
* host, so a module never knows or cares whether it is local or over SSH.
|
|
54
|
+
*/
|
|
55
|
+
exec: Exec;
|
|
56
|
+
}
|
|
57
|
+
export declare abstract class Module<State, Op extends BaseOp> {
|
|
58
|
+
#private;
|
|
59
|
+
readonly id: string;
|
|
60
|
+
readonly host?: string | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* @param id Stable identity for this instance. Not the class name — two
|
|
63
|
+
* instances of one module must be distinguishable in plans and logs.
|
|
64
|
+
* Shape is validated by the module's zod schema before we get here.
|
|
65
|
+
* @param host Which host this instance targets. Undefined = API-driving
|
|
66
|
+
* (porkbun). Lives on the instance so the runner never needs
|
|
67
|
+
* side tables indexed by module position. Whether an unreachable
|
|
68
|
+
* host skips or fails is the HOST's property — the runner
|
|
69
|
+
* consults the host registry, not the module.
|
|
70
|
+
*/
|
|
71
|
+
constructor(id: string, host?: string | undefined);
|
|
72
|
+
/**
|
|
73
|
+
* Resource names this instance WRITES on its host, for host-truth
|
|
74
|
+
* accounting: the loader unions these across every instance of a kind on a
|
|
75
|
+
* host to build that host's sweep keep-set. Referenced-but-not-written
|
|
76
|
+
* resources must not appear here — they are not Concord's to remove.
|
|
77
|
+
*/
|
|
78
|
+
owned(): string[];
|
|
79
|
+
/** Human-facing module type, e.g. "porkbun". Used in plan output. */
|
|
80
|
+
abstract readonly kind: string;
|
|
81
|
+
/** Desired state, derived from the config this instance was constructed with. */
|
|
82
|
+
abstract desired(): Promise<State>;
|
|
83
|
+
/** Live state, enumerated from the target. */
|
|
84
|
+
abstract read(): Promise<State>;
|
|
85
|
+
/** Pure. No I/O. */
|
|
86
|
+
abstract diff(actual: State, desired: State): Op[];
|
|
87
|
+
/** Make it so. */
|
|
88
|
+
abstract apply(ops: Op[]): Promise<void>;
|
|
89
|
+
/** @internal — called by the runner before any other method. */
|
|
90
|
+
attachRuntime(runtime: ModuleRuntime): void;
|
|
91
|
+
protected get runtime(): ModuleRuntime;
|
|
92
|
+
/** Decrypt a secret declared in the config repo. Fails closed. */
|
|
93
|
+
protected secret(secret: Secret): Promise<string>;
|
|
94
|
+
/** Something did not converge, but the module is not failing over it. */
|
|
95
|
+
protected warn(message: string): void;
|
|
96
|
+
protected log(message: string): void;
|
|
97
|
+
/** `kind:id`, or `kind:id@host` when the module targets one. */
|
|
98
|
+
get scope(): string;
|
|
99
|
+
/**
|
|
100
|
+
* Local scratch dir for a module that genuinely cannot enumerate its target
|
|
101
|
+
* and must cache what it last applied. A downgrade, not a pattern — a module
|
|
102
|
+
* using this is blind to out-of-band changes.
|
|
103
|
+
*/
|
|
104
|
+
protected get stateDir(): string;
|
|
105
|
+
/** Root of the config repo — for content declared relative to it. */
|
|
106
|
+
/** Host execution for this module's target. Local or SSH — modules cannot tell. */
|
|
107
|
+
protected get exec(): Exec;
|
|
108
|
+
/** Fleet-wide settings — see ConcordConfig.settings. */
|
|
109
|
+
protected get settings(): Settings;
|
|
110
|
+
protected get configDir(): string;
|
|
111
|
+
}
|
|
112
|
+
/** Convenience for `apply()` in read-only phases. */
|
|
113
|
+
export declare class NotImplementedError extends Error {
|
|
114
|
+
constructor(moduleId: string);
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE9D,MAA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E,KAAK,EAAE,OAAO,EAAE,KAAK,GAAG,EAAE,EAAE;IAElD,kBAAkB;IAClB,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAExC,gEAAgE;IAChE,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAI3C,SAAS,KAAK,OAAO,IAAI,aAAa,CAOrC;IAED,kEAAkE;IAClE,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD,yEAAyE;IACzE,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIrC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAOpC,gEAAgE;IAChE,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED;;;;OAIG;IACH,SAAS,KAAK,QAAQ,IAAI,MAAM,CAQ/B;IAED,qEAAqE;IACrE,mFAAmF;IACnF,SAAS,KAAK,IAAI,IAAI,IAAI,CAEzB;IAED,wDAAwD;IACxD,SAAS,KAAK,QAAQ,IAAI,QAAQ,CAEjC;IAED,SAAS,KAAK,SAAS,IAAI,MAAM,CAEhC;CACF;AAED,qDAAqD;AACrD,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,QAAQ,EAAE,MAAM;CAO7B"}
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The module contract — the load-bearing interface of the whole system.
|
|
3
|
+
*
|
|
4
|
+
* A module is a driver for exactly one target (a DNS account, a registrar, a
|
|
5
|
+
* host). It never re-implements the service it drives; it reads
|
|
6
|
+
* live state, diffs it against what the config declares, and applies the
|
|
7
|
+
* difference through the service's own API.
|
|
8
|
+
*/
|
|
9
|
+
export class Module {
|
|
10
|
+
id;
|
|
11
|
+
host;
|
|
12
|
+
#runtime;
|
|
13
|
+
/**
|
|
14
|
+
* @param id Stable identity for this instance. Not the class name — two
|
|
15
|
+
* instances of one module must be distinguishable in plans and logs.
|
|
16
|
+
* Shape is validated by the module's zod schema before we get here.
|
|
17
|
+
* @param host Which host this instance targets. Undefined = API-driving
|
|
18
|
+
* (porkbun). Lives on the instance so the runner never needs
|
|
19
|
+
* side tables indexed by module position. Whether an unreachable
|
|
20
|
+
* host skips or fails is the HOST's property — the runner
|
|
21
|
+
* consults the host registry, not the module.
|
|
22
|
+
*/
|
|
23
|
+
constructor(id, host) {
|
|
24
|
+
this.id = id;
|
|
25
|
+
this.host = host;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resource names this instance WRITES on its host, for host-truth
|
|
29
|
+
* accounting: the loader unions these across every instance of a kind on a
|
|
30
|
+
* host to build that host's sweep keep-set. Referenced-but-not-written
|
|
31
|
+
* resources must not appear here — they are not Concord's to remove.
|
|
32
|
+
*/
|
|
33
|
+
owned() {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
/** @internal — called by the runner before any other method. */
|
|
37
|
+
attachRuntime(runtime) {
|
|
38
|
+
this.#runtime = runtime;
|
|
39
|
+
}
|
|
40
|
+
get runtime() {
|
|
41
|
+
if (!this.#runtime) {
|
|
42
|
+
throw new Error(`Module ${this.id} used before the runner attached its runtime.`);
|
|
43
|
+
}
|
|
44
|
+
return this.#runtime;
|
|
45
|
+
}
|
|
46
|
+
/** Decrypt a secret declared in the config repo. Fails closed. */
|
|
47
|
+
secret(secret) {
|
|
48
|
+
return this.runtime.resolveSecret(secret);
|
|
49
|
+
}
|
|
50
|
+
/** Something did not converge, but the module is not failing over it. */
|
|
51
|
+
warn(message) {
|
|
52
|
+
this.runtime.warn(this.scope, message);
|
|
53
|
+
}
|
|
54
|
+
log(message) {
|
|
55
|
+
// Same scope the runner uses, host suffix included — otherwise a planned
|
|
56
|
+
// line reads `file:x@bare2` and its applied line reads `file:x`, and you
|
|
57
|
+
// cannot tell which machine the work landed on.
|
|
58
|
+
this.runtime.log(this.scope, message);
|
|
59
|
+
}
|
|
60
|
+
/** `kind:id`, or `kind:id@host` when the module targets one. */
|
|
61
|
+
get scope() {
|
|
62
|
+
const base = `${this.kind}:${this.id}`;
|
|
63
|
+
return this.#runtime?.hostName ? `${base}@${this.#runtime.hostName}` : base;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Local scratch dir for a module that genuinely cannot enumerate its target
|
|
67
|
+
* and must cache what it last applied. A downgrade, not a pattern — a module
|
|
68
|
+
* using this is blind to out-of-band changes.
|
|
69
|
+
*/
|
|
70
|
+
get stateDir() {
|
|
71
|
+
// Keyed by id ALONE, while module identity is `type:id@host`. Two modules
|
|
72
|
+
// sharing an id on different hosts would share this directory. Harmless
|
|
73
|
+
// today — only the docker module uses it, for git mirrors, which are
|
|
74
|
+
// host-neutral and benefit from being shared — but it is the one place
|
|
75
|
+
// identity is not host-scoped, and worth remembering before putting
|
|
76
|
+
// anything host-specific here.
|
|
77
|
+
return this.runtime.stateDir(this.id);
|
|
78
|
+
}
|
|
79
|
+
/** Root of the config repo — for content declared relative to it. */
|
|
80
|
+
/** Host execution for this module's target. Local or SSH — modules cannot tell. */
|
|
81
|
+
get exec() {
|
|
82
|
+
return this.runtime.exec;
|
|
83
|
+
}
|
|
84
|
+
/** Fleet-wide settings — see ConcordConfig.settings. */
|
|
85
|
+
get settings() {
|
|
86
|
+
return this.runtime.settings;
|
|
87
|
+
}
|
|
88
|
+
get configDir() {
|
|
89
|
+
return this.runtime.configDir;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** Convenience for `apply()` in read-only phases. */
|
|
93
|
+
export class NotImplementedError extends Error {
|
|
94
|
+
constructor(moduleId) {
|
|
95
|
+
super(`Module ${moduleId} has not implemented apply() yet (read-only phase). ` +
|
|
96
|
+
`Nothing was changed.`);
|
|
97
|
+
this.name = 'NotImplementedError';
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 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,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;IAC7E,CAAC;IAED;;;;OAIG;IACH,IAAc,QAAQ;QACpB,0EAA0E;QAC1E,wEAAwE;QACxE,qEAAqE;QACrE,uEAAuE;QACvE,oEAAoE;QACpE,+BAA+B;QAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACvC,CAAC;IAED,qEAAqE;IACrE,mFAAmF;IACnF,IAAc,IAAI;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAA;IAC1B,CAAC;IAED,wDAAwD;IACxD,IAAc,QAAQ;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAA;IAC9B,CAAC;IAED,IAAc,SAAS;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAA;IAC/B,CAAC;CACF;AAED,qDAAqD;AACrD,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,QAAgB;QAC1B,KAAK,CACH,UAAU,QAAQ,sDAAsD;YACtE,sBAAsB,CACzB,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Module, type BaseOp } from '../../module.js';
|
|
2
|
+
import type { AptConfig, AptRepoConfig } from './schema.js';
|
|
3
|
+
export type { AptConfig } from './schema.js';
|
|
4
|
+
export declare const sourcesPath: (name: string) => string;
|
|
5
|
+
export declare const keyPath: (name: string) => string;
|
|
6
|
+
export interface RepoState {
|
|
7
|
+
name: string;
|
|
8
|
+
/** Rendered deb822 file content. */
|
|
9
|
+
sources: string;
|
|
10
|
+
key: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PackageState {
|
|
13
|
+
name: string;
|
|
14
|
+
installed: boolean;
|
|
15
|
+
/** Only compared when the config PINS a version; undefined means "any". */
|
|
16
|
+
version?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface AptState {
|
|
19
|
+
repos: RepoState[];
|
|
20
|
+
/** ONLY the packages this module declares. The other ~1,100 are none of its business. */
|
|
21
|
+
packages: PackageState[];
|
|
22
|
+
}
|
|
23
|
+
export interface AptOp extends BaseOp {
|
|
24
|
+
entity: 'repo' | 'package';
|
|
25
|
+
repo?: RepoState;
|
|
26
|
+
packageName?: string;
|
|
27
|
+
/** Set only when the config pins one. */
|
|
28
|
+
version?: string;
|
|
29
|
+
before?: unknown;
|
|
30
|
+
}
|
|
31
|
+
/** deb822 — the modern format, preferred by Ubuntu 24.04+. */
|
|
32
|
+
export declare function renderSources(repo: AptRepoConfig, codename: string): string;
|
|
33
|
+
export declare class AptModule extends Module<AptState, AptOp> {
|
|
34
|
+
#private;
|
|
35
|
+
private readonly config;
|
|
36
|
+
readonly kind = "apt";
|
|
37
|
+
constructor(config: AptConfig);
|
|
38
|
+
/** Cached per run — it cannot change under us mid-reconcile. */
|
|
39
|
+
private codename;
|
|
40
|
+
desired(): Promise<AptState>;
|
|
41
|
+
read(): Promise<AptState>;
|
|
42
|
+
diff(actual: AptState, desired: AptState): AptOp[];
|
|
43
|
+
apply(ops: AptOp[]): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/apt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAe,MAAM,aAAa,CAAA;AAExE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAK5C,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,WAAqC,CAAA;AAC7E,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,WAAiC,CAAA;AAI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