@jini-ai/devops 0.6.20 → 0.7.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/CHANGELOG.md +21 -0
- package/dist/checks/coverage/disk.js +2 -2
- package/dist/checks/coverage/floors.js +2 -2
- package/dist/checks/coverage/lcov.d.ts +15 -1
- package/dist/checks/coverage/lcov.js +77 -7
- package/dist/core/deploy-types.d.ts +15 -0
- package/dist/core/export-failure-summary.d.ts +9 -2
- package/dist/deploy/config-contracts.d.ts +82 -0
- package/dist/deploy/config-contracts.js +7 -0
- package/dist/deploy/config-descriptors.d.ts +47 -0
- package/dist/deploy/config-descriptors.js +92 -0
- package/dist/deploy/index.d.ts +13 -0
- package/dist/deploy/index.js +13 -0
- package/dist/deploy/ops-contracts.d.ts +168 -0
- package/dist/deploy/ops-contracts.js +2 -0
- package/dist/deploy/ops-descriptors.d.ts +23 -0
- package/dist/deploy/ops-descriptors.js +77 -0
- package/dist/deploy/ops-registry.d.ts +7 -0
- package/dist/deploy/ops-registry.js +15 -0
- package/dist/deploy/ops-runner.d.ts +103 -0
- package/dist/deploy/ops-runner.js +343 -0
- package/dist/deploy/ops-secret-card.d.ts +13 -0
- package/dist/deploy/ops-secret-card.js +62 -0
- package/dist/deploy/ops-secrets.d.ts +74 -0
- package/dist/deploy/ops-secrets.js +221 -0
- package/dist/deploy/ops-tool-contracts.d.ts +223 -0
- package/dist/deploy/ops-tool-contracts.js +2 -0
- package/dist/deploy/ops-tools.d.ts +8 -0
- package/dist/deploy/ops-tools.js +117 -0
- package/dist/deploy/publish-jobs.d.ts +72 -0
- package/dist/deploy/publish-jobs.js +75 -0
- package/dist/deploy/target-contracts.d.ts +231 -0
- package/dist/deploy/target-contracts.js +2 -0
- package/dist/deploy/target-descriptors.d.ts +23 -0
- package/dist/deploy/target-descriptors.js +273 -0
- package/dist/local-dev/node-runtime.d.ts +3 -1
- package/dist/local-dev/node-runtime.js +4 -4
- package/dist/static-export/contracts.d.ts +3 -0
- package/dist/static-export/runner.js +2 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @jini-ai/devops
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8fe045b: `@jini-ai/devops/deploy` exports the deploy contribution contracts: the parsers `parseDeployTargetsFile`, `parseDeployOpsFile` and `parseDeployConfigsFile`, the module validators `asDeployTargetModule`, `asDeployOpsModule` and `asDeployConfigGeneratorModule`, `isContainedDeployConfigPath`, and the descriptor, registry and module types for deploy targets, deploy ops and deploy config generators. The installed deploy-target ABI types carry a `Plugin` prefix (`PluginDeployTargetModule`, `PluginDeployHostKit`, ...) so they do not collide with the package's own port names.
|
|
8
|
+
- afbe5a2: Expose deployment tool orchestration through explicit host ports, preserving bounded I/O, secret custody, approval ordering and accepted-dispatch history.
|
|
9
|
+
- Updated dependencies [8fe045b]
|
|
10
|
+
- Updated dependencies [c393010]
|
|
11
|
+
- Updated dependencies [41ff2ff]
|
|
12
|
+
- Updated dependencies [a266ba8]
|
|
13
|
+
- Updated dependencies [27063ef]
|
|
14
|
+
- Updated dependencies [6ab1d81]
|
|
15
|
+
- Updated dependencies [699b478]
|
|
16
|
+
- Updated dependencies [39cf677]
|
|
17
|
+
- @jini-ai/core@0.7.0
|
|
18
|
+
- @jini-ai/platform@0.7.0
|
|
19
|
+
|
|
20
|
+
## 0.6.22
|
|
21
|
+
|
|
22
|
+
- Static publish runs as a background job with progress (`deploy/publish-jobs`); a failed provider build is reported as failed and timeouts report what is known.
|
|
23
|
+
|
|
3
24
|
## 0.6.20
|
|
4
25
|
|
|
5
26
|
- `electron` is a classified opt-in peer (`jini.optionalPeers`): only `@jini-ai/devops/local-dev`'s `selectNodeRuntime` loads it. A host that packages a server importing `local-dev` (listen/retirement helpers) no longer fails its staged-closure audit on that dev-only runtime picker (Tovu desktop 0.1.27).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// evaluateArea and formatArea in the preserved rationale below are now evaluateDiskArea and
|
|
2
2
|
// formatDiskArea; scripts/check-coverage.ts and coverage-floors.json are host-owned consumers.
|
|
3
|
-
import { pct } from './lcov.js';
|
|
3
|
+
import { pct, withoutTrailingSlashes } from './lcov.js';
|
|
4
4
|
/** Exclude test and declaration filenames from a production-source inventory. */
|
|
5
5
|
export function isMeasurableSource({ file: relPath }) {
|
|
6
6
|
if (/\.(test|spec)\.(js|cjs|mjs|ts|tsx|mts)$/.test(relPath))
|
|
@@ -17,7 +17,7 @@ export function isMeasurableSource({ file: relPath }) {
|
|
|
17
17
|
* @complexity O(d) in excluded directories. */
|
|
18
18
|
export function isInExcludedDir({ file: relPath, excludeDirs }) {
|
|
19
19
|
return excludeDirs.some((dir) => {
|
|
20
|
-
const base =
|
|
20
|
+
const base = withoutTrailingSlashes({ path: dir });
|
|
21
21
|
return relPath === base || relPath.startsWith(`${base}/`);
|
|
22
22
|
});
|
|
23
23
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pct } from './lcov.js';
|
|
1
|
+
import { pct, withoutTrailingSlashes } from './lcov.js';
|
|
2
2
|
/** Aggregate counters before comparing percentages; an empty measurable scope always fails. */
|
|
3
3
|
export function evaluateFloor({ files, floors }) {
|
|
4
4
|
for (const value of Object.values(floors))
|
|
@@ -17,7 +17,7 @@ export function evaluateFloor({ files, floors }) {
|
|
|
17
17
|
}
|
|
18
18
|
/** Evaluate one declared area with a host classifier; the prefix must match whole directories. */
|
|
19
19
|
export function evaluateArea({ area, all, isMeasurable }) {
|
|
20
|
-
const prefix = `${area.prefix
|
|
20
|
+
const prefix = `${withoutTrailingSlashes({ path: area.prefix })}/`;
|
|
21
21
|
const files = all.filter((record) => record.file.startsWith(prefix) && isMeasurable({ file: record.file }));
|
|
22
22
|
return { area, ...evaluateFloor({ files, floors: { line: area.line, branch: area.branch, funcs: area.funcs } }) };
|
|
23
23
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { SourceReaderPort } from '../ports.js';
|
|
2
|
+
interface CoverageEntries {
|
|
3
|
+
line: ReadonlyMap<string, number>;
|
|
4
|
+
branch: ReadonlyMap<string, number>;
|
|
5
|
+
funcs: ReadonlyMap<string, number> | undefined;
|
|
6
|
+
}
|
|
2
7
|
export interface FileCoverage {
|
|
3
8
|
file: string;
|
|
4
9
|
lf: number;
|
|
@@ -7,6 +12,7 @@ export interface FileCoverage {
|
|
|
7
12
|
brh: number;
|
|
8
13
|
fnf: number;
|
|
9
14
|
fnh: number;
|
|
15
|
+
entries?: CoverageEntries;
|
|
10
16
|
}
|
|
11
17
|
export interface SourceClassificationRules {
|
|
12
18
|
prefixes: readonly string[];
|
|
@@ -27,6 +33,11 @@ export declare function pct({ hit, found }: {
|
|
|
27
33
|
hit: number;
|
|
28
34
|
found: number;
|
|
29
35
|
}): number;
|
|
36
|
+
/** Strip a path's trailing separators in one backward pass, including all-separator paths.
|
|
37
|
+
* @complexity O(path length) time, O(path length) for the returned slice. */
|
|
38
|
+
export declare function withoutTrailingSlashes({ path }: {
|
|
39
|
+
path: string;
|
|
40
|
+
}, _options?: Record<string, never>): string;
|
|
30
41
|
/** Normalize paths with a directory boundary check, including Windows paths on non-Windows hosts. */
|
|
31
42
|
export declare function toRepoRelative({ sourceFile, repoRoot }: {
|
|
32
43
|
sourceFile: string;
|
|
@@ -61,9 +72,12 @@ export declare function loadRouteCoverage({ lcovPath, repoRoot, reader, isMeasur
|
|
|
61
72
|
reader: SourceReaderPort;
|
|
62
73
|
isMeasurable: SourceClassifier;
|
|
63
74
|
}): FileCoverage[];
|
|
64
|
-
/**
|
|
75
|
+
/** Union separate reports by line, branch and function identity without double counting.
|
|
76
|
+
* @throws If duplicate records cannot be unioned from matching entry-level evidence.
|
|
77
|
+
* @complexity O(e) time and space in supplied entries. */
|
|
65
78
|
export declare function mergeCoverage({ reports, isMeasurable }: {
|
|
66
79
|
reports: readonly (readonly FileCoverage[])[];
|
|
67
80
|
isMeasurable: SourceClassifier;
|
|
68
81
|
}): ReadonlyMap<string, FileCoverage>;
|
|
82
|
+
export {};
|
|
69
83
|
//# sourceMappingURL=lcov.d.ts.map
|
|
@@ -5,10 +5,18 @@
|
|
|
5
5
|
* @complexity O(1). */
|
|
6
6
|
// evaluateArea is the disk inventory owner, now evaluateDiskArea in ./disk.ts.
|
|
7
7
|
export function pct({ hit, found }) { return found === 0 ? 100 : 100 * hit / found; }
|
|
8
|
+
/** Strip a path's trailing separators in one backward pass, including all-separator paths.
|
|
9
|
+
* @complexity O(path length) time, O(path length) for the returned slice. */
|
|
10
|
+
export function withoutTrailingSlashes({ path }, _options = {}) {
|
|
11
|
+
let end = path.length;
|
|
12
|
+
while (end > 0 && path[end - 1] === '/')
|
|
13
|
+
end--;
|
|
14
|
+
return path.slice(0, end);
|
|
15
|
+
}
|
|
8
16
|
/** Normalize paths with a directory boundary check, including Windows paths on non-Windows hosts. */
|
|
9
17
|
export function toRepoRelative({ sourceFile, repoRoot }) {
|
|
10
18
|
const file = sourceFile.trim().replace(/\\/g, '/');
|
|
11
|
-
const root = repoRoot.replace(/\\/g, '/')
|
|
19
|
+
const root = withoutTrailingSlashes({ path: repoRoot.replace(/\\/g, '/') });
|
|
12
20
|
if (file === root)
|
|
13
21
|
return '';
|
|
14
22
|
if (file.startsWith(`${root}/`))
|
|
@@ -18,12 +26,12 @@ export function toRepoRelative({ sourceFile, repoRoot }) {
|
|
|
18
26
|
/** Match caller-supplied integration suffixes and directory segments. */
|
|
19
27
|
export function isIntegrationTestFile({ file, suffixes, directories }) {
|
|
20
28
|
const normalized = file.replace(/\\/g, '/');
|
|
21
|
-
return suffixes.some((suffix) => normalized.endsWith(suffix)) || directories.some((dir) => `/${normalized}`.includes(`/${dir.replace(
|
|
29
|
+
return suffixes.some((suffix) => normalized.endsWith(suffix)) || directories.some((dir) => `/${normalized}`.includes(`/${withoutTrailingSlashes({ path: dir.replace(/^\/+/, '') })}/`));
|
|
22
30
|
}
|
|
23
31
|
/** Match source roots on directory boundaries and apply host-defined exclusions. */
|
|
24
32
|
export function isMeasurableSourceFile({ file, rules }) {
|
|
25
33
|
const normalized = file.replace(/\\/g, '/');
|
|
26
|
-
if (!rules.prefixes.some((prefix) => normalized.startsWith(`${
|
|
34
|
+
if (!rules.prefixes.some((prefix) => normalized.startsWith(`${withoutTrailingSlashes({ path: prefix })}/`)))
|
|
27
35
|
return false;
|
|
28
36
|
if (!rules.sourceExtensions.some((extension) => normalized.endsWith(extension)))
|
|
29
37
|
return false;
|
|
@@ -36,6 +44,42 @@ export function isMeasurableSourceFile({ file, rules }) {
|
|
|
36
44
|
return !new RegExp(rules.testPattern.source, rules.testPattern.flags.replace(/[gy]/g, '')).test(normalized);
|
|
37
45
|
}
|
|
38
46
|
function field(record, name) { return Number(record.match(new RegExp(`^${name}:(\\d+)$`, 'm'))?.[1] ?? 0); }
|
|
47
|
+
/** Preserve entry identities for exact unions; ambiguous function declarations retain summaries only.
|
|
48
|
+
* @complexity O(n) time and space in record entries. */
|
|
49
|
+
function readEntries(record) {
|
|
50
|
+
if (!/^(?:DA|BRDA|FNDA|FN):/m.test(record))
|
|
51
|
+
return undefined;
|
|
52
|
+
const line = new Map();
|
|
53
|
+
const branch = new Map();
|
|
54
|
+
for (const match of record.matchAll(/^DA:(\d+),(\d+)/gm))
|
|
55
|
+
line.set(match[1], Number(match[2]));
|
|
56
|
+
for (const match of record.matchAll(/^BRDA:(\d+,[^,\n]+,[^,\n]+),(\d+|-)$/gm))
|
|
57
|
+
branch.set(match[1], Number(match[2]) || 0);
|
|
58
|
+
return { line, branch, funcs: readFunctionEntries(record) };
|
|
59
|
+
}
|
|
60
|
+
/** Classic FNDA names do not disambiguate duplicate declarations; never infer their hit locations.
|
|
61
|
+
* @complexity O(n) time and space in function declarations and counts. */
|
|
62
|
+
function readFunctionEntries(record) {
|
|
63
|
+
const declared = new Map();
|
|
64
|
+
const entries = new Map();
|
|
65
|
+
for (const match of record.matchAll(/^FN:(\d+),(?:(\d+),)?(.+)$/gm)) {
|
|
66
|
+
const name = match[3];
|
|
67
|
+
if (declared.has(name))
|
|
68
|
+
return undefined;
|
|
69
|
+
const key = JSON.stringify([Number(match[1]), match[2], name]);
|
|
70
|
+
declared.set(name, key);
|
|
71
|
+
entries.set(key, 0);
|
|
72
|
+
}
|
|
73
|
+
const counted = new Set();
|
|
74
|
+
for (const match of record.matchAll(/^FNDA:(\d+),(.+)$/gm)) {
|
|
75
|
+
const key = declared.get(match[2]);
|
|
76
|
+
if (!key || counted.has(key))
|
|
77
|
+
return undefined;
|
|
78
|
+
counted.add(key);
|
|
79
|
+
entries.set(key, Number(match[1]));
|
|
80
|
+
}
|
|
81
|
+
return entries;
|
|
82
|
+
}
|
|
39
83
|
/** Parse LCOV summaries without filtering source or accessing a filesystem. */
|
|
40
84
|
export function parseLcov({ text, repoRoot }) {
|
|
41
85
|
const out = [];
|
|
@@ -43,7 +87,8 @@ export function parseLcov({ text, repoRoot }) {
|
|
|
43
87
|
const source = record.match(/^SF:(.+)$/m)?.[1];
|
|
44
88
|
if (!source)
|
|
45
89
|
continue;
|
|
46
|
-
|
|
90
|
+
const entries = readEntries(record);
|
|
91
|
+
out.push({ ...(entries ? { entries } : {}), file: toRepoRelative({ sourceFile: source, repoRoot }), lf: field(record, 'LF'), lh: field(record, 'LH'), brf: field(record, 'BRF'), brh: field(record, 'BRH'), fnf: field(record, 'FNF'), fnh: field(record, 'FNH') });
|
|
47
92
|
}
|
|
48
93
|
return out;
|
|
49
94
|
}
|
|
@@ -53,7 +98,33 @@ export function loadLcov({ lcovPath, repoRoot, reader }) {
|
|
|
53
98
|
}
|
|
54
99
|
/** Load and classify coverage without repository-specific route knowledge. */
|
|
55
100
|
export function loadRouteCoverage({ lcovPath, repoRoot, reader, isMeasurable }) { return loadLcov({ lcovPath, repoRoot, reader }).filter((record) => isMeasurable({ file: record.file })); }
|
|
56
|
-
/**
|
|
101
|
+
/** Union matching instrumentation; summaries alone cannot identify overlapping hits.
|
|
102
|
+
* @throws When reports lack entries or use incompatible instrumentation.
|
|
103
|
+
* @complexity O(e) time and space in entries. */
|
|
104
|
+
function unionEntries(a, b, found, axis) {
|
|
105
|
+
if (found === 0)
|
|
106
|
+
return new Map();
|
|
107
|
+
if (!a || !b)
|
|
108
|
+
throw new Error(axis === 'function' ? 'Cannot union function coverage without unambiguous LCOV declarations' : `Cannot union ${axis} coverage without LCOV entries`);
|
|
109
|
+
if (a.size !== found || b.size !== found || [...a.keys()].some((key) => !b.has(key)))
|
|
110
|
+
throw new Error(`Incompatible ${axis} coverage layouts`);
|
|
111
|
+
const merged = new Map(a);
|
|
112
|
+
for (const [key, count] of b)
|
|
113
|
+
merged.set(key, Math.max(merged.get(key), count));
|
|
114
|
+
return merged;
|
|
115
|
+
}
|
|
116
|
+
function unionRecords(a, b) {
|
|
117
|
+
if (a.lf !== b.lf || a.brf !== b.brf || a.fnf !== b.fnf)
|
|
118
|
+
throw new Error('Incompatible line, branch or function coverage totals');
|
|
119
|
+
const line = unionEntries(a.entries?.line, b.entries?.line, a.lf, 'line');
|
|
120
|
+
const branch = unionEntries(a.entries?.branch, b.entries?.branch, a.brf, 'branch');
|
|
121
|
+
const funcs = unionEntries(a.entries?.funcs, b.entries?.funcs, a.fnf, 'function');
|
|
122
|
+
const hit = (entries) => [...entries.values()].filter((count) => count > 0).length;
|
|
123
|
+
return { file: a.file, lf: line.size, lh: hit(line), brf: branch.size, brh: hit(branch), fnf: funcs.size, fnh: hit(funcs), entries: { line, branch, funcs } };
|
|
124
|
+
}
|
|
125
|
+
/** Union separate reports by line, branch and function identity without double counting.
|
|
126
|
+
* @throws If duplicate records cannot be unioned from matching entry-level evidence.
|
|
127
|
+
* @complexity O(e) time and space in supplied entries. */
|
|
57
128
|
export function mergeCoverage({ reports, isMeasurable }) {
|
|
58
129
|
const byFile = new Map();
|
|
59
130
|
for (const report of reports)
|
|
@@ -61,8 +132,7 @@ export function mergeCoverage({ reports, isMeasurable }) {
|
|
|
61
132
|
if (!isMeasurable({ file: record.file }))
|
|
62
133
|
continue;
|
|
63
134
|
const previous = byFile.get(record.file);
|
|
64
|
-
|
|
65
|
-
byFile.set(record.file, { ...record });
|
|
135
|
+
byFile.set(record.file, previous ? unionRecords(previous, record) : { ...record });
|
|
66
136
|
}
|
|
67
137
|
return byFile;
|
|
68
138
|
}
|
|
@@ -53,8 +53,23 @@ export interface DeployPublishInput {
|
|
|
53
53
|
files: DeployFile[];
|
|
54
54
|
projectName: string;
|
|
55
55
|
}
|
|
56
|
+
/** Confirmed provider facts only: unknown creation/remote file counts stay explicit.
|
|
57
|
+
* Uploaded/reused counts refer to distinct content hashes, not duplicate paths.
|
|
58
|
+
*/
|
|
59
|
+
export interface DeployPublishProgress {
|
|
60
|
+
readonly phase: 'exporting' | 'uploading' | 'creating' | 'polling' | 'checking';
|
|
61
|
+
readonly deploymentCreated?: boolean | 'unknown';
|
|
62
|
+
readonly totalFiles?: number;
|
|
63
|
+
readonly uploadedFiles?: number;
|
|
64
|
+
readonly reusedFiles?: number;
|
|
65
|
+
readonly deploymentId?: string;
|
|
66
|
+
readonly url?: string;
|
|
67
|
+
readonly providerStatus?: string;
|
|
68
|
+
}
|
|
56
69
|
/** Optional publish settings, passed separately from the file set and project name. */
|
|
57
70
|
export interface DeployPublishOptions {
|
|
71
|
+
/** Synchronous credential-free snapshots; the caller owns storage/transport frequency. */
|
|
72
|
+
onProgress?: (progress: DeployPublishProgress) => void;
|
|
58
73
|
metadata?: UnknownRecord;
|
|
59
74
|
responseHeaders?: ResponseHeaderSet;
|
|
60
75
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FailedAsset, FailedRoute } from '../static-export/contracts.js';
|
|
2
2
|
export interface ExportFailureSummary {
|
|
3
3
|
kind: 'route' | 'asset';
|
|
4
4
|
identifier: string;
|
|
@@ -7,6 +7,13 @@ export interface ExportFailureSummary {
|
|
|
7
7
|
}
|
|
8
8
|
/** Runtime-leaf check of routes AND assets. Routes take precedence; the count is per collection. */
|
|
9
9
|
export declare function firstExportFailure(required: {
|
|
10
|
-
report:
|
|
10
|
+
report: {
|
|
11
|
+
routes: {
|
|
12
|
+
failed: readonly Pick<FailedRoute, 'path' | 'reason'>[];
|
|
13
|
+
};
|
|
14
|
+
assets: {
|
|
15
|
+
failed: readonly Pick<FailedAsset, 'url' | 'reason'>[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
11
18
|
}, _optional?: {}): ExportFailureSummary | undefined;
|
|
12
19
|
//# sourceMappingURL=export-failure-summary.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The deploy-config generator module contract: the one deployment descriptor every platform
|
|
3
|
+
* config generator is a thin, pure function over, the options a render takes, what it returns, and
|
|
4
|
+
* the kit a host passes in because a plugin module has no dependencies of its own.
|
|
5
|
+
*/
|
|
6
|
+
/** One env var a production host deployment needs set through the platform's OWN secret
|
|
7
|
+
* mechanism — a NAME only. No renderer in this module ever holds, and none may ever emit, a
|
|
8
|
+
* VALUE for any of these. */
|
|
9
|
+
export interface DeploymentSecret {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/**
|
|
12
|
+
* "boot-blocking" — the production readiness gate refuses to start without a real value.
|
|
13
|
+
* "recommended" — boot succeeds either way (the boot gate at most warns); without it a real
|
|
14
|
+
* production feature fails closed (`503 SECRET_STORE_UNCONFIGURED`) or runs on a weaker derived
|
|
15
|
+
* default until it's set. Each entry's own note in {@link REQUIRED_SECRETS}'s doc says which.
|
|
16
|
+
*/
|
|
17
|
+
readonly requirement: "boot-blocking" | "recommended";
|
|
18
|
+
}
|
|
19
|
+
export interface DeploymentDescriptor {
|
|
20
|
+
/** Default deployment name from package.json's name. Deployment callers may supply their own
|
|
21
|
+
* descriptor when the platform resource has a different name. */
|
|
22
|
+
readonly appName: string;
|
|
23
|
+
/** The container port the process listens on. Derived from `Dockerfile`'s `EXPOSE` line. */
|
|
24
|
+
readonly port: number;
|
|
25
|
+
/** Repo-relative Dockerfile path, the same root file the deployment editor owns. */
|
|
26
|
+
readonly dockerfilePath: string;
|
|
27
|
+
/** The one persistent volume's mount path INSIDE the container — every site's `content.db`,
|
|
28
|
+
* `uploads/`, `themes/`. Derived from Dockerfile's VOLUME declaration. A wrong
|
|
29
|
+
* value here is silent data loss on the next deploy, not a startup error. */
|
|
30
|
+
readonly volumeMountPath: string;
|
|
31
|
+
/** Default volume name: <package name>_sites. Callers targeting an existing volume supply its
|
|
32
|
+
* actual name in their descriptor; never rename a persisted volume by changing this default. */
|
|
33
|
+
readonly volumeName: string;
|
|
34
|
+
/** HTTP path the platform should poll to learn whether the host app is actually ready to serve traffic
|
|
35
|
+
* (503 until migrations/seeding finish) — not `/health`, which only proves the process is
|
|
36
|
+
* alive. Derived from the real registered route (`registerReadyzRoute`). */
|
|
37
|
+
readonly healthCheckPath: string;
|
|
38
|
+
/** Env vars every renderer must declare by NAME on its platform. See {@link REQUIRED_SECRETS}'s
|
|
39
|
+
* own doc for exactly how each entry here was decided. */
|
|
40
|
+
readonly secrets: readonly DeploymentSecret[];
|
|
41
|
+
}
|
|
42
|
+
/** What a render function actually needs from its caller beyond the descriptor: the ONE fact that
|
|
43
|
+
* can never be derived from this repo, because it names something about the TARGET DEPLOYMENT,
|
|
44
|
+
* not about the host app itself. No renderer may default this — see each renderer's own validation. */
|
|
45
|
+
export interface RenderDeployConfigOptions {
|
|
46
|
+
readonly region: string;
|
|
47
|
+
/** Explicit non-secret runtime values (a host CLI stamps its site id). Every generator must carry
|
|
48
|
+
* them: in its environment block, or as an operator step in `notes` when the file has none. */
|
|
49
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
50
|
+
/** Explicit non-secret image build arguments. Secret values belong in the platform secret store. */
|
|
51
|
+
readonly buildArgs?: Readonly<Record<string, string>>;
|
|
52
|
+
}
|
|
53
|
+
/** One platform's generated config, plus whatever it could NOT express inside the file itself
|
|
54
|
+
* (creating a volume out of band, prompting for a secret's real value through the platform's own
|
|
55
|
+
* UI/CLI) — every generator returns this same shape so `cli/commands/deploy-config.ts` needs no
|
|
56
|
+
* per-platform branch beyond picking which generator to call. */
|
|
57
|
+
export interface RenderedDeployConfig {
|
|
58
|
+
/** The filename this platform expects at its own conventional location (repo root). */
|
|
59
|
+
readonly filename: string;
|
|
60
|
+
/** The full file contents. Never contains a secret VALUE — only names, when a platform's own
|
|
61
|
+
* format has a way to declare "this key exists, prompt for it"; formats with no such field put
|
|
62
|
+
* their secrets only in `notes`. */
|
|
63
|
+
readonly contents: string;
|
|
64
|
+
/** Human-readable follow-up steps the file itself cannot express — volume creation, where to go
|
|
65
|
+
* set each secret's real value. Printed by the CLI, not written into any generated file. */
|
|
66
|
+
readonly notes: readonly string[];
|
|
67
|
+
}
|
|
68
|
+
/** What the host passes a generator module, because a plugin module has no dependencies of its own:
|
|
69
|
+
* the shared injection guard, a constructor for the host's own `ValidationError` (so a bad
|
|
70
|
+
* `--region` surfaces exactly as it did when the generators lived in core), and the shared
|
|
71
|
+
* migrations note every generator prints. */
|
|
72
|
+
export interface DeployConfigKit {
|
|
73
|
+
readonly assertNoConfigInjection: (fieldLabel: string, value: string) => void;
|
|
74
|
+
readonly validationError: (message: string) => Error;
|
|
75
|
+
readonly migrationsNote: string;
|
|
76
|
+
}
|
|
77
|
+
/** A plugin generator module's default export. `render` is pure: no I/O, throws the kit's
|
|
78
|
+
* `validationError` for a bad option. */
|
|
79
|
+
export interface DeployConfigGeneratorModule {
|
|
80
|
+
render(descriptor: DeploymentDescriptor, options: RenderDeployConfigOptions, kit: DeployConfigKit): RenderedDeployConfig;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=config-contracts.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The deploy-config generator module contract: the one deployment descriptor every platform
|
|
3
|
+
* config generator is a thin, pure function over, the options a render takes, what it returns, and
|
|
4
|
+
* the kit a host passes in because a plugin module has no dependencies of its own.
|
|
5
|
+
*/
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=config-contracts.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { DeployConfigGeneratorModule } from './config-contracts.js';
|
|
2
|
+
/** One entry of a plugin's {@link DEPLOY_CONFIGS_FILENAME}. */
|
|
3
|
+
export interface DeployConfigGeneratorDescriptor {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly module: string;
|
|
7
|
+
readonly candidatePaths?: readonly {
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly order: number;
|
|
10
|
+
}[];
|
|
11
|
+
readonly workflowFile?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface LoadedDeployConfigGenerator {
|
|
14
|
+
readonly descriptor: DeployConfigGeneratorDescriptor;
|
|
15
|
+
readonly pluginId: string;
|
|
16
|
+
readonly module: DeployConfigGeneratorModule;
|
|
17
|
+
}
|
|
18
|
+
export interface DeployConfigGeneratorRegistry {
|
|
19
|
+
get(id: string): LoadedDeployConfigGenerator | undefined;
|
|
20
|
+
/** Declared order. */
|
|
21
|
+
list(): readonly LoadedDeployConfigGenerator[];
|
|
22
|
+
readonly refusals: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
/** The export as a generator module, or the refusal reason. @complexity O(1). */
|
|
25
|
+
export declare function asDeployConfigGeneratorModule({ exported: candidate }: {
|
|
26
|
+
readonly exported: unknown;
|
|
27
|
+
}, _optional?: Record<string, never>): DeployConfigGeneratorModule | string;
|
|
28
|
+
/**
|
|
29
|
+
* Parses a plugin's {@link DEPLOY_CONFIGS_FILENAME}. Pure (exported for its own tests). Unknown keys
|
|
30
|
+
* are ignored.
|
|
31
|
+
*
|
|
32
|
+
* @complexity O(g) in the declared generator count.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseDeployConfigsFile({ raw }: {
|
|
35
|
+
readonly raw: string;
|
|
36
|
+
}, _optional?: Record<string, never>): {
|
|
37
|
+
readonly ok: true;
|
|
38
|
+
readonly descriptors: readonly DeployConfigGeneratorDescriptor[];
|
|
39
|
+
} | {
|
|
40
|
+
readonly ok: false;
|
|
41
|
+
readonly reason: string;
|
|
42
|
+
};
|
|
43
|
+
/** Repo-relative declaration paths never escape to another drive or parent directory. */
|
|
44
|
+
export declare function isContainedDeployConfigPath({ value }: {
|
|
45
|
+
readonly value: unknown;
|
|
46
|
+
}, _optional?: {}): boolean;
|
|
47
|
+
//# sourceMappingURL=config-descriptors.d.ts.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
/**
|
|
3
|
+
* @file The pure parser for a plugin's `deploy-configs` contribution file, and the module contract
|
|
4
|
+
* each declared generator's default export must meet. No filesystem access and no import.
|
|
5
|
+
*/
|
|
6
|
+
const GENERATOR_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
7
|
+
const MAX_ID_LENGTH = 64;
|
|
8
|
+
const MAX_LABEL_LENGTH = 100;
|
|
9
|
+
/** The export as a generator module, or the refusal reason. @complexity O(1). */
|
|
10
|
+
export function asDeployConfigGeneratorModule({ exported: candidate }, _optional = {}) {
|
|
11
|
+
if (!isPlainObject(candidate) || typeof candidate.render !== "function")
|
|
12
|
+
return "its module has no render() function";
|
|
13
|
+
return candidate;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parses a plugin's {@link DEPLOY_CONFIGS_FILENAME}. Pure (exported for its own tests). Unknown keys
|
|
17
|
+
* are ignored.
|
|
18
|
+
*
|
|
19
|
+
* @complexity O(g) in the declared generator count.
|
|
20
|
+
*/
|
|
21
|
+
export function parseDeployConfigsFile({ raw }, _optional = {}) {
|
|
22
|
+
let value;
|
|
23
|
+
try {
|
|
24
|
+
value = JSON.parse(raw);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return { ok: false, reason: "not valid JSON" };
|
|
28
|
+
}
|
|
29
|
+
if (!isPlainObject(value) || value.schemaVersion !== 1)
|
|
30
|
+
return { ok: false, reason: "schemaVersion must be 1" };
|
|
31
|
+
if (!Array.isArray(value.generators))
|
|
32
|
+
return { ok: false, reason: "generators must be an array" };
|
|
33
|
+
const descriptors = [];
|
|
34
|
+
for (const [index, entry] of value.generators.entries()) {
|
|
35
|
+
const descriptor = parseDescriptor({ entry, at: `generators[${index}]` });
|
|
36
|
+
if (typeof descriptor === "string")
|
|
37
|
+
return { ok: false, reason: descriptor };
|
|
38
|
+
if (descriptors.some((seen) => seen.id === descriptor.id))
|
|
39
|
+
return { ok: false, reason: `generators[${index}].id '${descriptor.id}' is declared twice` };
|
|
40
|
+
descriptors.push(descriptor);
|
|
41
|
+
}
|
|
42
|
+
return { ok: true, descriptors };
|
|
43
|
+
}
|
|
44
|
+
/** One generator entry, or the reason it is invalid. @complexity O(1). */
|
|
45
|
+
function parseDescriptor({ entry, at }, _optional = {}) {
|
|
46
|
+
if (!isPlainObject(entry))
|
|
47
|
+
return `${at} must be an object`;
|
|
48
|
+
const { id, module } = entry;
|
|
49
|
+
if (!validGeneratorId({ id }))
|
|
50
|
+
return `${at}.id must be a lowercase hyphenated id`;
|
|
51
|
+
const label = readGeneratorLabel({ label: entry.label });
|
|
52
|
+
if (label === undefined)
|
|
53
|
+
return `${at}.label must be a non-empty string`;
|
|
54
|
+
if (!validGeneratorModulePath({ module }))
|
|
55
|
+
return `${at}.module must be a relative path ending in .mjs`;
|
|
56
|
+
const metadata = readPublishMetadata({ entry });
|
|
57
|
+
if (typeof metadata === "string")
|
|
58
|
+
return `${at}.${metadata}`;
|
|
59
|
+
return { id: id, label, module: module, ...metadata };
|
|
60
|
+
}
|
|
61
|
+
/** Keep label bounds and blank detection together without normalizing the stored label. */
|
|
62
|
+
function readGeneratorLabel({ label }, _options = {}) {
|
|
63
|
+
return typeof label === "string" && label.trim() !== "" && label.length <= MAX_LABEL_LENGTH ? label : undefined;
|
|
64
|
+
}
|
|
65
|
+
function isPlainObject(value) {
|
|
66
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
67
|
+
}
|
|
68
|
+
/** Repo-relative declaration paths never escape to another drive or parent directory. */
|
|
69
|
+
export function isContainedDeployConfigPath({ value }, _optional = {}) {
|
|
70
|
+
return typeof value === "string" && value.length <= 512 && /^[a-zA-Z0-9_./-]+$/.test(value)
|
|
71
|
+
&& !value.split("/").some(segment => segment === ".." || segment === "." || segment === "");
|
|
72
|
+
}
|
|
73
|
+
/** Optional publish hints remain plain data; no generator executes during discovery. */
|
|
74
|
+
function readPublishMetadata({ entry }, _optional = {}) {
|
|
75
|
+
const { candidatePaths, workflowFile } = entry;
|
|
76
|
+
if (candidatePaths !== undefined && (!Array.isArray(candidatePaths) || !candidatePaths.every(validCandidatePath)))
|
|
77
|
+
return "candidatePaths must contain repo-relative paths and finite orders";
|
|
78
|
+
if (workflowFile !== undefined && (typeof workflowFile !== "string" || !/^[a-zA-Z0-9_-]+\.ya?ml$/.test(workflowFile)))
|
|
79
|
+
return "workflowFile must be a workflow filename";
|
|
80
|
+
return { ...(candidatePaths === undefined ? {} : { candidatePaths: candidatePaths }), ...(workflowFile === undefined ? {} : { workflowFile: workflowFile }) };
|
|
81
|
+
}
|
|
82
|
+
function validCandidatePath(value) {
|
|
83
|
+
return isPlainObject(value) && isContainedDeployConfigPath({ value: value.path }) && typeof value.order === "number" && Number.isFinite(value.order);
|
|
84
|
+
}
|
|
85
|
+
/** Keep identity and module path clauses separate from descriptor assembly. O(length). */
|
|
86
|
+
function validGeneratorId({ id }, _options = {}) {
|
|
87
|
+
return typeof id === "string" && id.length <= MAX_ID_LENGTH && GENERATOR_ID_PATTERN.test(id);
|
|
88
|
+
}
|
|
89
|
+
function validGeneratorModulePath({ module }, _options = {}) {
|
|
90
|
+
return typeof module === "string" && module.endsWith(".mjs") && !path.posix.isAbsolute(module);
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=config-descriptors.js.map
|
package/dist/deploy/index.d.ts
CHANGED
|
@@ -6,4 +6,17 @@ export * from '../core/redirect-guard.js';
|
|
|
6
6
|
export * from './host-kit.js';
|
|
7
7
|
export * from './tokens.js';
|
|
8
8
|
export * from './tool.js';
|
|
9
|
+
export * from './publish-jobs.js';
|
|
10
|
+
export * from './target-contracts.js';
|
|
11
|
+
export * from './target-descriptors.js';
|
|
12
|
+
export * from './ops-contracts.js';
|
|
13
|
+
export * from './ops-descriptors.js';
|
|
14
|
+
export * from './config-contracts.js';
|
|
15
|
+
export * from './config-descriptors.js';
|
|
16
|
+
export * from './ops-tool-contracts.js';
|
|
17
|
+
export * from './ops-runner.js';
|
|
18
|
+
export * from './ops-secrets.js';
|
|
19
|
+
export * from './ops-secret-card.js';
|
|
20
|
+
export * from './ops-tools.js';
|
|
21
|
+
export * from './ops-registry.js';
|
|
9
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/deploy/index.js
CHANGED
|
@@ -5,4 +5,17 @@ export * from '../core/redirect-guard.js';
|
|
|
5
5
|
export * from './host-kit.js';
|
|
6
6
|
export * from './tokens.js';
|
|
7
7
|
export * from './tool.js';
|
|
8
|
+
export * from './publish-jobs.js';
|
|
9
|
+
export * from './target-contracts.js';
|
|
10
|
+
export * from './target-descriptors.js';
|
|
11
|
+
export * from './ops-contracts.js';
|
|
12
|
+
export * from './ops-descriptors.js';
|
|
13
|
+
export * from './config-contracts.js';
|
|
14
|
+
export * from './config-descriptors.js';
|
|
15
|
+
export * from './ops-tool-contracts.js';
|
|
16
|
+
export * from './ops-runner.js';
|
|
17
|
+
export * from './ops-secrets.js';
|
|
18
|
+
export * from './ops-secret-card.js';
|
|
19
|
+
export * from './ops-tools.js';
|
|
20
|
+
export * from './ops-registry.js';
|
|
8
21
|
//# sourceMappingURL=index.js.map
|