velocious 1.0.576 → 1.0.577
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/README.md +46 -1
- package/build/background-jobs/main.js +13 -2
- package/build/background-jobs/scheduler.js +11 -7
- package/build/background-jobs/store.js +18 -13
- package/build/environment-handlers/node/cli/commands/test.js +2 -0
- package/build/environment-handlers/node/source-peer-package.js +172 -0
- package/build/routes/resolver.js +3 -50
- package/build/src/background-jobs/main.d.ts.map +1 -1
- package/build/src/background-jobs/main.js +13 -3
- package/build/src/background-jobs/scheduler.d.ts +2 -2
- package/build/src/background-jobs/scheduler.d.ts.map +1 -1
- package/build/src/background-jobs/scheduler.js +11 -8
- package/build/src/background-jobs/store.d.ts +5 -4
- package/build/src/background-jobs/store.d.ts.map +1 -1
- package/build/src/background-jobs/store.js +17 -12
- package/build/src/environment-handlers/node/cli/commands/test.d.ts.map +1 -1
- package/build/src/environment-handlers/node/cli/commands/test.js +3 -1
- package/build/src/environment-handlers/node/source-peer-package.d.ts +46 -0
- package/build/src/environment-handlers/node/source-peer-package.d.ts.map +1 -0
- package/build/src/environment-handlers/node/source-peer-package.js +148 -0
- package/build/src/routes/resolver.d.ts.map +1 -1
- package/build/src/routes/resolver.js +4 -45
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/scripts/run-tests.js +61 -20
- package/scripts/test-browser.js +6 -1
- package/src/background-jobs/main.js +13 -2
- package/src/background-jobs/scheduler.js +11 -7
- package/src/background-jobs/store.js +18 -13
- package/src/environment-handlers/node/cli/commands/test.js +2 -0
- package/src/environment-handlers/node/source-peer-package.js +172 -0
- package/src/routes/resolver.js +3 -50
- package/build/deployment-api/controller.js +0 -437
- package/build/deployment-api/index.js +0 -210
- package/build/deployment-api/path-matcher.js +0 -45
- package/build/deployment-api/registry.js +0 -84
- package/build/deployment-api/run-store.js +0 -798
- package/build/deployment-api/sanitize.js +0 -114
- package/build/src/deployment-api/controller.d.ts +0 -117
- package/build/src/deployment-api/controller.d.ts.map +0 -1
- package/build/src/deployment-api/controller.js +0 -384
- package/build/src/deployment-api/index.d.ts +0 -46
- package/build/src/deployment-api/index.d.ts.map +0 -1
- package/build/src/deployment-api/index.js +0 -178
- package/build/src/deployment-api/path-matcher.d.ts +0 -31
- package/build/src/deployment-api/path-matcher.d.ts.map +0 -1
- package/build/src/deployment-api/path-matcher.js +0 -39
- package/build/src/deployment-api/registry.d.ts +0 -106
- package/build/src/deployment-api/registry.d.ts.map +0 -1
- package/build/src/deployment-api/registry.js +0 -74
- package/build/src/deployment-api/run-store.d.ts +0 -402
- package/build/src/deployment-api/run-store.d.ts.map +0 -1
- package/build/src/deployment-api/run-store.js +0 -711
- package/build/src/deployment-api/sanitize.d.ts +0 -27
- package/build/src/deployment-api/sanitize.d.ts.map +0 -1
- package/build/src/deployment-api/sanitize.js +0 -100
- package/src/deployment-api/controller.js +0 -437
- package/src/deployment-api/index.js +0 -210
- package/src/deployment-api/path-matcher.js +0 -45
- package/src/deployment-api/registry.js +0 -84
- package/src/deployment-api/run-store.js +0 -798
- package/src/deployment-api/sanitize.js +0 -114
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
const MAX_STRING_LENGTH = 4000
|
|
4
|
-
const MAX_DEPTH = 20
|
|
5
|
-
const REDACTED = "[redacted]"
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Replaces every occurrence of each configured secret in a string so tokens
|
|
9
|
-
* never leak into persisted run state, audit payloads, or API responses.
|
|
10
|
-
* @param {string} value - Raw string.
|
|
11
|
-
* @param {string[]} secrets - Secret values to redact.
|
|
12
|
-
* @returns {string} - Redacted string.
|
|
13
|
-
*/
|
|
14
|
-
function redactString(value, secrets) {
|
|
15
|
-
let result = value
|
|
16
|
-
|
|
17
|
-
for (const secret of secrets) {
|
|
18
|
-
if (secret.length > 0) result = result.split(secret).join(REDACTED)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (result.length > MAX_STRING_LENGTH) {
|
|
22
|
-
result = `${result.slice(0, MAX_STRING_LENGTH)}…`
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return result
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Converts an integration-owned value (adapter report, live status, audit
|
|
30
|
-
* payload fragment) into a bounded JSON-safe structure: plain objects, arrays,
|
|
31
|
-
* strings, finite numbers, booleans, and null survive; everything else
|
|
32
|
-
* (functions, class instances, undefined) is dropped. String values and object
|
|
33
|
-
* keys are redacted and capped in length; deterministic suffixes preserve every
|
|
34
|
-
* value when redacted keys collide.
|
|
35
|
-
* @param {?} value - Raw value from the integration.
|
|
36
|
-
* @param {string[]} secrets - Secret values to redact.
|
|
37
|
-
* @param {number} [depth] - Current recursion depth.
|
|
38
|
-
* @returns {?} - JSON-safe redacted value, or undefined when the value cannot be represented.
|
|
39
|
-
*/
|
|
40
|
-
export function sanitizeAdapterValue(value, secrets, depth = 0) {
|
|
41
|
-
if (value === null) return null
|
|
42
|
-
if (depth > MAX_DEPTH) return undefined
|
|
43
|
-
|
|
44
|
-
const valueType = typeof value
|
|
45
|
-
|
|
46
|
-
if (valueType === "string") return redactString(value, secrets)
|
|
47
|
-
if (valueType === "number") return Number.isFinite(value) ? value : null
|
|
48
|
-
if (valueType === "boolean") return value
|
|
49
|
-
|
|
50
|
-
if (Array.isArray(value)) {
|
|
51
|
-
/** @type {Array<?>} */
|
|
52
|
-
const result = []
|
|
53
|
-
|
|
54
|
-
for (const entry of value) {
|
|
55
|
-
const sanitized = sanitizeAdapterValue(entry, secrets, depth + 1)
|
|
56
|
-
|
|
57
|
-
if (sanitized !== undefined) result.push(sanitized)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return result
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (valueType === "object") {
|
|
64
|
-
const prototype = Object.getPrototypeOf(value)
|
|
65
|
-
|
|
66
|
-
if (prototype !== Object.prototype && prototype !== null) return undefined
|
|
67
|
-
|
|
68
|
-
/** @type {Record<string, ?>} */
|
|
69
|
-
const result = {}
|
|
70
|
-
|
|
71
|
-
for (const [key, entry] of Object.entries(value)) {
|
|
72
|
-
const sanitized = sanitizeAdapterValue(entry, secrets, depth + 1)
|
|
73
|
-
|
|
74
|
-
if (sanitized === undefined) continue
|
|
75
|
-
|
|
76
|
-
const redactedKey = redactString(key, secrets)
|
|
77
|
-
let availableKey = redactedKey
|
|
78
|
-
let collisionNumber = 2
|
|
79
|
-
|
|
80
|
-
while (Object.hasOwn(result, availableKey)) {
|
|
81
|
-
availableKey = `${redactedKey}#${collisionNumber}`
|
|
82
|
-
collisionNumber++
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
Object.defineProperty(result, availableKey, {
|
|
86
|
-
configurable: true,
|
|
87
|
-
enumerable: true,
|
|
88
|
-
value: sanitized,
|
|
89
|
-
writable: true
|
|
90
|
-
})
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return result
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return undefined
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Builds the sanitized failure payload persisted for a failed run. The message
|
|
101
|
-
* is redacted; an integration-provided plain-object `error.recovery` (e.g.
|
|
102
|
-
* Rampway reporting restoration of the previous release) is included after
|
|
103
|
-
* sanitization.
|
|
104
|
-
* @param {?} error - Thrown error from the adapter.
|
|
105
|
-
* @param {string[]} secrets - Secret values to redact.
|
|
106
|
-
* @returns {{message: string, recovery: (? | undefined)}} - Sanitized failure payload.
|
|
107
|
-
*/
|
|
108
|
-
export function sanitizeErrorPayload(error, secrets) {
|
|
109
|
-
const rawMessage = error instanceof Error ? error.message : String(error)
|
|
110
|
-
const rawRecovery = error instanceof Error ? /** @type {Record<string, ?>} */ (error).recovery : undefined
|
|
111
|
-
const recovery = sanitizeAdapterValue(rawRecovery, secrets)
|
|
112
|
-
|
|
113
|
-
return {message: redactString(rawMessage, secrets), recovery}
|
|
114
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authenticated HTTP API for callable deployments. Mounted by
|
|
3
|
-
* {@link import("./index.js").default} as a route-resolver hook so it can ship
|
|
4
|
-
* inside the velocious package. Every action is gated by a bearer-token check
|
|
5
|
-
* against the configured access tokens; the API exposes only allowlisted
|
|
6
|
-
* project/stage pairs and full immutable revisions, and delegates all
|
|
7
|
-
* execution to the configured adapter. It never accepts commands, paths,
|
|
8
|
-
* arbitrary refs, environment variables, or raw log output.
|
|
9
|
-
*/
|
|
10
|
-
export default class VelociousDeploymentApiController extends Controller {
|
|
11
|
-
/**
|
|
12
|
-
* Runs mount options.
|
|
13
|
-
* @returns {import("./registry.js").DeploymentMountOptions} - Options for the mount that matched this request.
|
|
14
|
-
*/
|
|
15
|
-
_mountOptions(): import("./registry.js").DeploymentMountOptions;
|
|
16
|
-
/**
|
|
17
|
-
* Runs store.
|
|
18
|
-
* @returns {DeploymentRunStore} - Run store scoped to the mount's database.
|
|
19
|
-
*/
|
|
20
|
-
_store(): DeploymentRunStore;
|
|
21
|
-
_deploymentRunStore: DeploymentRunStore | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Reports one internally consumed framework failure on both documented
|
|
24
|
-
* error channels so framework-specific and unified reporters see the same
|
|
25
|
-
* payload.
|
|
26
|
-
* @param {object} args - Options.
|
|
27
|
-
* @param {string} args.context - Deployment API failure context.
|
|
28
|
-
* @param {?} args.error - Consumed error.
|
|
29
|
-
* @returns {void} - No return value.
|
|
30
|
-
*/
|
|
31
|
-
_emitFrameworkError({ context, error }: {
|
|
32
|
-
context: string;
|
|
33
|
-
error: unknown;
|
|
34
|
-
}): void;
|
|
35
|
-
/**
|
|
36
|
-
* Authorizes the request with a constant-time bearer-token comparison and
|
|
37
|
-
* runs the action body only when authorized. Renders a 401 otherwise. The
|
|
38
|
-
* base controller has no before-action halting, so authorization is enforced
|
|
39
|
-
* here per action. Tokens are only accepted through the Authorization header
|
|
40
|
-
* — never through URLs — and are never rendered back.
|
|
41
|
-
* @param {() => Promise<void>} actionFn - Action body.
|
|
42
|
-
* @returns {Promise<void>} - Resolves when complete.
|
|
43
|
-
*/
|
|
44
|
-
_respond(actionFn: () => Promise<void>): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Creates a deployment run for an allowlisted project/stage and a full
|
|
47
|
-
* immutable revision reachable from the approved release branch. Idempotent:
|
|
48
|
-
* a retried idempotency key reads the original run, a reused key with a
|
|
49
|
-
* different payload conflicts, and an active run for the same project/stage
|
|
50
|
-
* returns a bounded conflict.
|
|
51
|
-
* @returns {Promise<void>} - Resolves when complete.
|
|
52
|
-
*/
|
|
53
|
-
create(): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Renders a previously created run for an idempotency-key hit: a replay when
|
|
56
|
-
* the payload matches, a bounded conflict when it doesn't.
|
|
57
|
-
* @param {object} args - Options.
|
|
58
|
-
* @param {import("./run-store.js").DeploymentRunRow} args.existingRun - The stored run.
|
|
59
|
-
* @param {string} args.project - Requested project.
|
|
60
|
-
* @param {string} args.revision - Requested revision.
|
|
61
|
-
* @param {string} args.stage - Requested stage.
|
|
62
|
-
* @returns {Promise<void>} - Resolves when complete.
|
|
63
|
-
*/
|
|
64
|
-
_renderExistingRun({ existingRun, project, revision, stage }: {
|
|
65
|
-
existingRun: import("./run-store.js").DeploymentRunRow;
|
|
66
|
-
project: string;
|
|
67
|
-
revision: string;
|
|
68
|
-
stage: string;
|
|
69
|
-
}): Promise<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Returns the bounded state of a single run, enriched with the adapter's
|
|
72
|
-
* live status when the integration provides one.
|
|
73
|
-
* @returns {Promise<void>} - Resolves when complete.
|
|
74
|
-
*/
|
|
75
|
-
show(): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* Executes a created run asynchronously: registers it as active in this
|
|
78
|
-
* process, marks it running, heartbeats its ownership lease while the
|
|
79
|
-
* adapter deploys, and records the sanitized outcome. A deployment failure
|
|
80
|
-
* is an expected operational result — it is persisted with its sanitized
|
|
81
|
-
* recovery information instead of being raised, so it stays visible through
|
|
82
|
-
* readback and audit rather than crashing the worker.
|
|
83
|
-
* @param {object} args - Options.
|
|
84
|
-
* @param {import("./registry.js").DeploymentMountOptions} args.options - Mount options.
|
|
85
|
-
* @param {import("./run-store.js").DeploymentRunRow} args.run - The created run.
|
|
86
|
-
* @returns {Promise<void>} - Resolves when the outcome is recorded.
|
|
87
|
-
*/
|
|
88
|
-
_executeRun({ options, run }: {
|
|
89
|
-
options: import("./registry.js").DeploymentMountOptions;
|
|
90
|
-
run: import("./run-store.js").DeploymentRunRow;
|
|
91
|
-
}): Promise<void>;
|
|
92
|
-
/**
|
|
93
|
-
* Records a sanitized audit event. Audit persistence must never strand or
|
|
94
|
-
* suppress a deployment, so a failure here is reported on the
|
|
95
|
-
* framework-error and unified all-error channels (where process-level bug
|
|
96
|
-
* reporters capture it), and execution continues.
|
|
97
|
-
* @param {object} args - Options.
|
|
98
|
-
* @param {string} args.event - Event name.
|
|
99
|
-
* @param {Record<string, ?>} args.payload - Payload; sanitized and redacted before persistence.
|
|
100
|
-
* @param {string | null} args.runId - Owning run id.
|
|
101
|
-
* @returns {Promise<void>} - Resolves when recorded or reported.
|
|
102
|
-
*/
|
|
103
|
-
_audit({ event, payload, runId }: {
|
|
104
|
-
event: string;
|
|
105
|
-
payload: Record<string, unknown>;
|
|
106
|
-
runId: string | null;
|
|
107
|
-
}): Promise<void>;
|
|
108
|
-
/**
|
|
109
|
-
* Serializes a run for the API.
|
|
110
|
-
* @param {import("./run-store.js").DeploymentRunRow} run - Run row.
|
|
111
|
-
* @returns {Record<string, ?>} - Serialized run.
|
|
112
|
-
*/
|
|
113
|
-
_serializeRun(run: import("./run-store.js").DeploymentRunRow): Record<string, unknown>;
|
|
114
|
-
}
|
|
115
|
-
import Controller from "../controller.js";
|
|
116
|
-
import DeploymentRunStore from "./run-store.js";
|
|
117
|
-
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/deployment-api/controller.js"],"names":[],"mappings":"AA+BA;;;;;;;;GAQG;AACH;IACE;;;OAGG;IACH,iBAFa,OAAO,eAAe,EAAE,sBAAsB,CAS1D;IAED;;;OAGG;IACH,UAFa,kBAAkB,CAa9B;IATG,oDAKE;IAMN;;;;;;;;OAQG;IACH,wCAJG;QAAqB,OAAO,EAApB,MAAM;QACE,KAAK,EAAb,OAAC;KACT,GAAU,IAAI,CAQhB;IAED;;;;;;;;OAQG;IACH,mBAHW,MAAM,OAAO,CAAC,IAAI,CAAC,GACjB,OAAO,CAAC,IAAI,CAAC,CAqBzB;IAED;;;;;;;OAOG;IACH,UAFa,OAAO,CAAC,IAAI,CAAC,CAsGzB;IAED;;;;;;;;;OASG;IACH,8DANG;QAAwD,WAAW,EAA3D,OAAO,gBAAgB,EAAE,gBAAgB;QAC5B,OAAO,EAApB,MAAM;QACO,QAAQ,EAArB,MAAM;QACO,KAAK,EAAlB,MAAM;KACd,GAAU,OAAO,CAAC,IAAI,CAAC,CAWzB;IAED;;;;OAIG;IACH,QAFa,OAAO,CAAC,IAAI,CAAC,CA2BzB;IAED;;;;;;;;;;;OAWG;IACH,8BAJG;QAA6D,OAAO,EAA5D,OAAO,eAAe,EAAE,sBAAsB;QACE,GAAG,EAAnD,OAAO,gBAAgB,EAAE,gBAAgB;KACjD,GAAU,OAAO,CAAC,IAAI,CAAC,CAsGzB;IAED;;;;;;;;;;OAUG;IACH,kCALG;QAAqB,KAAK,EAAlB,MAAM;QACkB,OAAO,EAA/B,MAAM,CAAC,MAAM,EAAE,OAAC,CAAC;QACG,KAAK,EAAzB,MAAM,GAAG,IAAI;KACrB,GAAU,OAAO,CAAC,IAAI,CAAC,CAUzB;IAED;;;;OAIG;IACH,mBAHW,OAAO,gBAAgB,EAAE,gBAAgB,GACvC,MAAM,CAAC,MAAM,EAAE,OAAC,CAAC,CAgB7B;CACF;uBAlbsB,kBAAkB;+BACoD,gBAAgB"}
|