@ship.zone/runner 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/.smartconfig.json +48 -0
- package/changelog.md +12 -0
- package/deno.json +41 -0
- package/deno.lock +1843 -0
- package/dist_npm/mod.d.ts +689 -0
- package/dist_npm/mod.js +8980 -0
- package/dist_rust/runnerworkspace_linux_amd64_musl +0 -0
- package/dist_rust/runnerworkspace_linux_arm64_musl +0 -0
- package/license.md +18 -0
- package/mod.ts +8 -0
- package/musl-copyright.md +81 -0
- package/package.json +58 -0
- package/readme.md +274 -0
- package/rust/.cargo/config.toml +5 -0
- package/rust/Cargo.lock +144 -0
- package/rust/Cargo.toml +17 -0
- package/rust/src/lib.rs +1784 -0
- package/rust/src/main.rs +6 -0
- package/third-party-licenses.md +95 -0
- package/ts/00_commitinfo_data.ts +8 -0
- package/ts/api-client.ts +1059 -0
- package/ts/artifact-manager.ts +218 -0
- package/ts/attempt-state.ts +190 -0
- package/ts/cache-manager.ts +431 -0
- package/ts/cli.ts +239 -0
- package/ts/config.ts +724 -0
- package/ts/errors.ts +68 -0
- package/ts/index.ts +13 -0
- package/ts/interfaces.ts +547 -0
- package/ts/log-sender.ts +134 -0
- package/ts/oci-executor.ts +2472 -0
- package/ts/plugins.ts +11 -0
- package/ts/protocol-validator.ts +535 -0
- package/ts/redactor.ts +41 -0
- package/ts/registration-state.ts +253 -0
- package/ts/runner.ts +1036 -0
- package/ts/source-workspace.ts +161 -0
- package/ts/staging-scavenger.ts +62 -0
- package/ts/transfer-archive.ts +1605 -0
- package/ts/validation.ts +77 -0
package/ts/validation.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ConfigurationError, ProtocolError } from './errors.ts';
|
|
2
|
+
|
|
3
|
+
export const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
4
|
+
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
5
|
+
|
|
6
|
+
export const requireString = (
|
|
7
|
+
value: unknown,
|
|
8
|
+
field: string,
|
|
9
|
+
maximumLength = 4096,
|
|
10
|
+
): string => {
|
|
11
|
+
if (typeof value !== 'string' || value.length === 0 || value.length > maximumLength) {
|
|
12
|
+
throw new ProtocolError(`Invalid coordinator field: ${field}`);
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const requireBoolean = (value: unknown, field: string): boolean => {
|
|
18
|
+
if (typeof value !== 'boolean') {
|
|
19
|
+
throw new ProtocolError(`Invalid coordinator field: ${field}`);
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const requireFiniteNumber = (value: unknown, field: string): number => {
|
|
25
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
26
|
+
throw new ProtocolError(`Invalid coordinator field: ${field}`);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const requireIsoDate = (value: unknown, field: string): string => {
|
|
32
|
+
const result = requireString(value, field, 64);
|
|
33
|
+
if (!Number.isFinite(Date.parse(result))) {
|
|
34
|
+
throw new ProtocolError(`Invalid coordinator date: ${field}`);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const validateIdentifier = (value: string, field: string): string => {
|
|
40
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(value)) {
|
|
41
|
+
throw new ProtocolError(`Invalid coordinator identifier: ${field}`);
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const validateEnvironmentName = (value: string): string => {
|
|
47
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(value)) {
|
|
48
|
+
throw new ProtocolError(`Invalid environment variable name: ${value}`);
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const validateHttpUrl = (
|
|
54
|
+
value: string,
|
|
55
|
+
allowInsecureLoopback: boolean,
|
|
56
|
+
field: string,
|
|
57
|
+
): URL => {
|
|
58
|
+
let url: URL;
|
|
59
|
+
try {
|
|
60
|
+
url = new URL(value);
|
|
61
|
+
} catch {
|
|
62
|
+
throw new ConfigurationError(`${field} must be a valid URL`);
|
|
63
|
+
}
|
|
64
|
+
if (url.username || url.password) {
|
|
65
|
+
throw new ConfigurationError(`${field} must not contain credentials`);
|
|
66
|
+
}
|
|
67
|
+
if (url.protocol === 'https:') {
|
|
68
|
+
return url;
|
|
69
|
+
}
|
|
70
|
+
const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
|
|
71
|
+
if (url.protocol === 'http:' && allowInsecureLoopback && loopback) {
|
|
72
|
+
return url;
|
|
73
|
+
}
|
|
74
|
+
throw new ConfigurationError(`${field} must use HTTPS`);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const utf8Length = (value: string): number => new TextEncoder().encode(value).byteLength;
|