@scarn/sdk 0.0.0-stage → 0.0.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/dist/chunk-4361gxk0.js +166 -0
- package/dist/chunk-4vehh3dq.js +333 -0
- package/dist/chunk-56e4kp0a.js +162 -0
- package/dist/chunk-5mmj03ah.js +1074 -0
- package/dist/chunk-631ffb6r.js +57 -0
- package/dist/chunk-91p9vzcs.js +1453 -0
- package/dist/chunk-9s07v9r1.js +30 -0
- package/dist/chunk-b21233rt.js +78 -0
- package/dist/chunk-dnn39qt4.js +13539 -0
- package/dist/chunk-eg1hcvhb.js +300 -0
- package/dist/chunk-g0rdnn0r.js +95 -0
- package/dist/chunk-h9yxx0hd.js +116 -0
- package/dist/chunk-njd6npf0.js +35 -0
- package/dist/chunk-ny07ncb9.js +330 -0
- package/dist/chunk-p6kc9wq8.js +97 -0
- package/dist/chunk-qpw5wt1p.js +257 -0
- package/dist/chunk-rq3q8vg7.js +1094 -0
- package/dist/chunk-s0gap8r8.js +14 -0
- package/dist/chunk-tfm5hjzm.js +100 -0
- package/dist/chunk-ynk2bjae.js +1686 -0
- package/dist/chunk-zpqyjgb4.js +49 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.js +57 -0
- package/dist/contracts/artifact-markers.d.ts +42 -0
- package/dist/contracts/artifact-markers.js +15 -0
- package/dist/contracts/artifacts.d.ts +67 -0
- package/dist/contracts/artifacts.js +25 -0
- package/dist/contracts/pipeline-document/built-ins.d.ts +23 -0
- package/dist/contracts/pipeline-document/conditions/operators.d.ts +8 -0
- package/dist/contracts/pipeline-document/index.d.ts +11 -0
- package/dist/contracts/pipeline-document/index.js +97 -0
- package/dist/contracts/pipeline-document/json.d.ts +35 -0
- package/dist/contracts/pipeline-document/routes.d.ts +16 -0
- package/dist/contracts/pipeline-document/schema.d.ts +780 -0
- package/dist/contracts/pipeline-document/step-contract.d.ts +11 -0
- package/dist/contracts/step-artifact-submissions.d.ts +71 -0
- package/dist/contracts/step-artifact-submissions.js +174 -0
- package/dist/defaults/atomic-json-file.d.ts +10 -0
- package/dist/defaults/auth-file.d.ts +14 -0
- package/dist/defaults/base-url.d.ts +1 -0
- package/dist/defaults/config-file.d.ts +46 -0
- package/dist/defaults/home-dir.d.ts +3 -0
- package/dist/defaults/index.d.ts +12 -0
- package/dist/defaults/index.js +1239 -0
- package/dist/defaults/legacy-config-migration.d.ts +27 -0
- package/dist/defaults/load-push-defaults.d.ts +25 -0
- package/dist/defaults/project-config.d.ts +32 -0
- package/dist/defaults/project-ref.d.ts +34 -0
- package/dist/definitions/artifacts/artifact.d.ts +62 -0
- package/dist/definitions/artifacts/index.d.ts +1 -0
- package/dist/definitions/pipelines/define-default-pipeline-assignment.d.ts +263 -0
- package/dist/definitions/pipelines/index.d.ts +3 -0
- package/dist/definitions/pipelines/index.js +24 -0
- package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +208 -0
- package/dist/definitions/pipelines/work-item-fields.d.ts +93 -0
- package/dist/definitions/steps/compile-mcps.d.ts +34 -0
- package/dist/definitions/steps/define-code-step.d.ts +84 -0
- package/dist/definitions/steps/define-mcp.d.ts +79 -0
- package/dist/definitions/steps/define-step.d.ts +137 -0
- package/dist/definitions/steps/env.d.ts +136 -0
- package/dist/definitions/steps/index.d.ts +14 -0
- package/dist/definitions/steps/index.js +73 -0
- package/dist/definitions/steps/mcp-server-config.d.ts +102 -0
- package/dist/definitions/steps/prompt-template.d.ts +24 -0
- package/dist/definitions/steps/repo.d.ts +67 -0
- package/dist/definitions/steps/runtime.d.ts +115 -0
- package/dist/definitions/steps/step-definitions-client.d.ts +400 -0
- package/dist/definitions/steps/step-features.d.ts +109 -0
- package/dist/definitions/steps/step-handle.d.ts +25 -0
- package/dist/definitions/steps/step-ref.d.ts +19 -0
- package/dist/definitions/validation/index.d.ts +2 -0
- package/dist/definitions/validation/index.js +17 -0
- package/dist/definitions/validation/validate-artifact-markers.d.ts +3 -0
- package/dist/definitions/validation/validate-artifacts.d.ts +7 -0
- package/dist/definitions/validation/validate-definition-specs.d.ts +16 -0
- package/dist/definitions/validation/validate-env.d.ts +15 -0
- package/dist/definitions/validation/validate-repo.d.ts +13 -0
- package/dist/definitions/validation/validate-runtime.d.ts +12 -0
- package/dist/definitions/validation/validation-issue.d.ts +11 -0
- package/dist/devcontainer-config-path.d.ts +21 -0
- package/dist/devcontainer-config-path.js +13 -0
- package/dist/env-vars.d.ts +136 -0
- package/dist/env-vars.js +35 -0
- package/dist/eslint.d.ts +42 -0
- package/dist/eslint.js +125 -0
- package/dist/generated/client/client.gen.d.ts +2 -0
- package/dist/generated/client/index.d.ts +8 -0
- package/dist/generated/client/types.gen.d.ts +117 -0
- package/dist/generated/client/utils.gen.d.ts +33 -0
- package/dist/generated/client.gen.d.ts +12 -0
- package/dist/generated/core/auth.gen.d.ts +18 -0
- package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
- package/dist/generated/core/params.gen.d.ts +43 -0
- package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/generated/core/types.gen.d.ts +78 -0
- package/dist/generated/core/utils.gen.d.ts +19 -0
- package/dist/generated/index.d.ts +2 -0
- package/dist/generated/sdk.gen.d.ts +302 -0
- package/dist/generated/types.gen.d.ts +18368 -0
- package/dist/git-url/git-remote.d.ts +30 -0
- package/dist/git-url/git-repo-identity.d.ts +44 -0
- package/dist/git-url/git-repo-identity.js +159 -0
- package/dist/git-url/parse-git-host.d.ts +23 -0
- package/dist/health-checks.d.ts +169 -0
- package/dist/health-checks.js +19 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +293 -0
- package/dist/jsonc.d.ts +3 -0
- package/dist/jsonc.js +11 -0
- package/dist/managed-runtimes.d.ts +20 -0
- package/dist/managed-runtimes.js +13 -0
- package/dist/opencode-mcp.d.ts +313 -0
- package/dist/opencode-mcp.js +29 -0
- package/dist/pipelines/chain.d.ts +7 -0
- package/dist/pipelines/compile-args.d.ts +12 -0
- package/dist/pipelines/compile-chain.d.ts +9 -0
- package/dist/pipelines/compile-checks.d.ts +16 -0
- package/dist/pipelines/compile-state.d.ts +30 -0
- package/dist/pipelines/condition-data.d.ts +78 -0
- package/dist/pipelines/conditions.d.ts +47 -0
- package/dist/pipelines/context.d.ts +16 -0
- package/dist/pipelines/define-pipeline.d.ts +32 -0
- package/dist/pipelines/each.d.ts +5 -0
- package/dist/pipelines/errors.d.ts +26 -0
- package/dist/pipelines/handles.d.ts +29 -0
- package/dist/pipelines/index.d.ts +18 -0
- package/dist/pipelines/index.js +80 -0
- package/dist/pipelines/model.d.ts +103 -0
- package/dist/pipelines/nodes.d.ts +54 -0
- package/dist/pipelines/ref-types.d.ts +54 -0
- package/dist/pipelines/refs.d.ts +80 -0
- package/dist/pipelines/registry.d.ts +12 -0
- package/dist/pipelines/source.d.ts +17 -0
- package/dist/pipelines/types.d.ts +160 -0
- package/dist/push/code-step-lookup.d.ts +32 -0
- package/dist/push/code-step-lookup.js +11 -0
- package/dist/push/collect-definitions.d.ts +70 -0
- package/dist/push/collect-pipeline-documents.d.ts +14 -0
- package/dist/push/index.d.ts +6 -0
- package/dist/push/index.js +328 -0
- package/dist/push/push-from-directory.d.ts +37 -0
- package/dist/repo-config.d.ts +80 -0
- package/dist/repo-config.js +23 -0
- package/dist/scarn-config-parser.d.ts +29 -0
- package/dist/scarn-config-parser.js +9 -0
- package/dist/task-plane-client.d.ts +489 -0
- package/dist/z.d.ts +7 -0
- package/package.json +132 -4
- package/README.md +0 -3
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/scarn-config-parser.ts
|
|
3
|
+
import { access, readFile } from "fs/promises";
|
|
4
|
+
import path from "path";
|
|
5
|
+
var SCARN_CONFIG_RELATIVE_PATH2 = ".scarn/scarn.jsonc";
|
|
6
|
+
var stripJsoncComments = (content) => {
|
|
7
|
+
let result = "";
|
|
8
|
+
let inString = false;
|
|
9
|
+
let escapeNextCharacter = false;
|
|
10
|
+
let lineComment = false;
|
|
11
|
+
let blockComment = false;
|
|
12
|
+
for (let index = 0;index < content.length; index += 1) {
|
|
13
|
+
const character = content.charAt(index);
|
|
14
|
+
const nextCharacter = content.charAt(index + 1);
|
|
15
|
+
if (lineComment) {
|
|
16
|
+
if (character === `
|
|
17
|
+
`) {
|
|
18
|
+
lineComment = false;
|
|
19
|
+
result += character;
|
|
20
|
+
}
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (blockComment) {
|
|
24
|
+
if (character === "*" && nextCharacter === "/") {
|
|
25
|
+
blockComment = false;
|
|
26
|
+
index += 1;
|
|
27
|
+
}
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (inString) {
|
|
31
|
+
result += character;
|
|
32
|
+
if (escapeNextCharacter) {
|
|
33
|
+
escapeNextCharacter = false;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (character === "\\") {
|
|
37
|
+
escapeNextCharacter = true;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (character === '"') {
|
|
41
|
+
inString = false;
|
|
42
|
+
}
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (character === '"') {
|
|
46
|
+
inString = true;
|
|
47
|
+
result += character;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (character === "/" && nextCharacter === "/") {
|
|
51
|
+
lineComment = true;
|
|
52
|
+
index += 1;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (character === "/" && nextCharacter === "*") {
|
|
56
|
+
blockComment = true;
|
|
57
|
+
index += 1;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
result += character;
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
};
|
|
64
|
+
var stripTrailingCommas = (content) => {
|
|
65
|
+
let result = "";
|
|
66
|
+
let inString = false;
|
|
67
|
+
let escapeNextCharacter = false;
|
|
68
|
+
for (let index = 0;index < content.length; index += 1) {
|
|
69
|
+
const character = content.charAt(index);
|
|
70
|
+
if (inString) {
|
|
71
|
+
result += character;
|
|
72
|
+
if (escapeNextCharacter) {
|
|
73
|
+
escapeNextCharacter = false;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (character === "\\") {
|
|
77
|
+
escapeNextCharacter = true;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (character === '"') {
|
|
81
|
+
inString = false;
|
|
82
|
+
}
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (character === '"') {
|
|
86
|
+
inString = true;
|
|
87
|
+
result += character;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (character === ",") {
|
|
91
|
+
let lookaheadIndex = index + 1;
|
|
92
|
+
while (lookaheadIndex < content.length) {
|
|
93
|
+
const lookaheadCharacter = content.charAt(lookaheadIndex);
|
|
94
|
+
if (/\s/u.test(lookaheadCharacter)) {
|
|
95
|
+
lookaheadIndex += 1;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (lookaheadCharacter === "}" || lookaheadCharacter === "]") {
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
result += character;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (lookaheadIndex >= content.length) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const lookaheadCharacter = content.charAt(lookaheadIndex);
|
|
108
|
+
if (lookaheadCharacter === "}" || lookaheadCharacter === "]") {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
result += character;
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
};
|
|
117
|
+
var parseJsonc = (content) => JSON.parse(stripTrailingCommas(stripJsoncComments(content)));
|
|
118
|
+
var asString = (value) => typeof value === "string" ? value : null;
|
|
119
|
+
var asNumber = (value) => typeof value === "number" ? value : null;
|
|
120
|
+
var parseCommands = (raw) => {
|
|
121
|
+
if (!raw)
|
|
122
|
+
return [];
|
|
123
|
+
return Object.entries(raw).map(([name, entry]) => ({
|
|
124
|
+
name,
|
|
125
|
+
description: asString(entry.description) ?? "",
|
|
126
|
+
run: asString(entry.run) ?? "",
|
|
127
|
+
cwd: asString(entry.cwd) ?? null
|
|
128
|
+
}));
|
|
129
|
+
};
|
|
130
|
+
var parseServices = (raw) => {
|
|
131
|
+
if (!raw)
|
|
132
|
+
return [];
|
|
133
|
+
return Object.entries(raw).map(([name, entry]) => {
|
|
134
|
+
const expose = entry.expose ?? {};
|
|
135
|
+
const dependsOn = Array.isArray(entry.dependsOn) ? entry.dependsOn.filter((d) => typeof d === "string") : [];
|
|
136
|
+
return {
|
|
137
|
+
name,
|
|
138
|
+
description: asString(entry.description) ?? "",
|
|
139
|
+
run: asString(entry.run) ?? "",
|
|
140
|
+
cwd: asString(entry.cwd) ?? null,
|
|
141
|
+
dependsOn,
|
|
142
|
+
expose: {
|
|
143
|
+
targetPort: asNumber(expose.targetPort) ?? 0,
|
|
144
|
+
protocol: asString(expose.protocol) ?? "http"
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
async function parseScarnConfig2(workspacePath) {
|
|
150
|
+
const filePath = path.join(workspacePath, SCARN_CONFIG_RELATIVE_PATH2);
|
|
151
|
+
const exists = await access(filePath).then(() => true).catch(() => false);
|
|
152
|
+
if (!exists) {
|
|
153
|
+
return { found: false };
|
|
154
|
+
}
|
|
155
|
+
const content = await readFile(filePath, "utf8");
|
|
156
|
+
const raw = parseJsonc(content);
|
|
157
|
+
return {
|
|
158
|
+
found: true,
|
|
159
|
+
config: {
|
|
160
|
+
commands: parseCommands(raw.commands),
|
|
161
|
+
services: parseServices(raw.services)
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export { SCARN_CONFIG_RELATIVE_PATH2, parseScarnConfig2 };
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
toJSONSchema,
|
|
4
|
+
string,
|
|
5
|
+
number,
|
|
6
|
+
int,
|
|
7
|
+
array,
|
|
8
|
+
strictObject,
|
|
9
|
+
union,
|
|
10
|
+
discriminatedUnion,
|
|
11
|
+
record,
|
|
12
|
+
_enum,
|
|
13
|
+
literal,
|
|
14
|
+
json
|
|
15
|
+
} from "./chunk-dnn39qt4.js";
|
|
16
|
+
|
|
17
|
+
// src/contracts/pipeline-document/json.ts
|
|
18
|
+
function isJsonObject2(value) {
|
|
19
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
|
+
}
|
|
21
|
+
function escapePointerSegment(segment) {
|
|
22
|
+
return String(segment).replaceAll("~", "~0").replaceAll("/", "~1");
|
|
23
|
+
}
|
|
24
|
+
function jsonPointer2(segments) {
|
|
25
|
+
return segments.map((segment) => `/${escapePointerSegment(segment)}`).join("");
|
|
26
|
+
}
|
|
27
|
+
function deepEqual2(left, right) {
|
|
28
|
+
if (left === right) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(left)) {
|
|
32
|
+
return Array.isArray(right) && left.length === right.length && left.every((item, index) => deepEqual2(item, right[index]));
|
|
33
|
+
}
|
|
34
|
+
if (isJsonObject2(left) && isJsonObject2(right)) {
|
|
35
|
+
const leftKeys = Object.keys(left);
|
|
36
|
+
const rightKeys = Object.keys(right);
|
|
37
|
+
return leftKeys.length === rightKeys.length && leftKeys.every((key) => Object.hasOwn(right, key) && deepEqual2(left[key], right[key]));
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
// src/contracts/pipeline-document/conditions/operators.ts
|
|
42
|
+
var COMPARISON_OPERATORS2 = [
|
|
43
|
+
"equal",
|
|
44
|
+
"notEqual",
|
|
45
|
+
"lessThan",
|
|
46
|
+
"lessThanInclusive",
|
|
47
|
+
"greaterThan",
|
|
48
|
+
"greaterThanInclusive"
|
|
49
|
+
];
|
|
50
|
+
var CONDITION_OPERATORS2 = [
|
|
51
|
+
...COMPARISON_OPERATORS2,
|
|
52
|
+
"exists",
|
|
53
|
+
"isEmpty",
|
|
54
|
+
"contains",
|
|
55
|
+
"startsWith",
|
|
56
|
+
"endsWith",
|
|
57
|
+
"matches",
|
|
58
|
+
"before",
|
|
59
|
+
"after",
|
|
60
|
+
"some",
|
|
61
|
+
"every",
|
|
62
|
+
"none"
|
|
63
|
+
];
|
|
64
|
+
var COMPUTED_FUNCTIONS2 = [
|
|
65
|
+
"sum",
|
|
66
|
+
"avg",
|
|
67
|
+
"min",
|
|
68
|
+
"max",
|
|
69
|
+
"count"
|
|
70
|
+
];
|
|
71
|
+
var ORDERING_OPERATORS2 = new Set([
|
|
72
|
+
"lessThan",
|
|
73
|
+
"lessThanInclusive",
|
|
74
|
+
"greaterThan",
|
|
75
|
+
"greaterThanInclusive"
|
|
76
|
+
]);
|
|
77
|
+
var STRING_OPERATORS2 = new Set([
|
|
78
|
+
"startsWith",
|
|
79
|
+
"endsWith",
|
|
80
|
+
"matches"
|
|
81
|
+
]);
|
|
82
|
+
var DATE_OPERATORS2 = new Set(["before", "after"]);
|
|
83
|
+
var LIST_OPERATORS2 = new Set(["some", "every", "none"]);
|
|
84
|
+
|
|
85
|
+
// src/contracts/pipeline-document/schema.ts
|
|
86
|
+
var NODE_ID_PATTERN2 = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
87
|
+
var ALIAS_PATTERN2 = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
88
|
+
var nodeIdSchema = string().regex(NODE_ID_PATTERN2, "Node ids may only contain letters, digits, '_' and '-'");
|
|
89
|
+
var jsonValueSchema = json();
|
|
90
|
+
var literalSchema2 = strictObject({ value: jsonValueSchema });
|
|
91
|
+
var scalarArgSchema = union([string().min(1), literalSchema2]);
|
|
92
|
+
var listSchema2 = strictObject({ list: array(scalarArgSchema) });
|
|
93
|
+
var argValueSchema2 = union([
|
|
94
|
+
string().min(1),
|
|
95
|
+
literalSchema2,
|
|
96
|
+
listSchema2
|
|
97
|
+
]);
|
|
98
|
+
var computedSourceSchema2 = union([
|
|
99
|
+
array(string().min(1)).min(1),
|
|
100
|
+
strictObject({
|
|
101
|
+
path: string().min(1),
|
|
102
|
+
field: string().min(1).optional(),
|
|
103
|
+
get where() {
|
|
104
|
+
return conditionSchema2.optional();
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
]);
|
|
108
|
+
var LIST_OPS = new Set(["some", "every", "none"]);
|
|
109
|
+
var UNARY_OPS = new Set(["exists", "isEmpty"]);
|
|
110
|
+
var conditionSchema2 = strictObject({
|
|
111
|
+
get all() {
|
|
112
|
+
return array(conditionSchema2).min(1).optional();
|
|
113
|
+
},
|
|
114
|
+
get any() {
|
|
115
|
+
return array(conditionSchema2).min(1).optional();
|
|
116
|
+
},
|
|
117
|
+
get not() {
|
|
118
|
+
return conditionSchema2.optional();
|
|
119
|
+
},
|
|
120
|
+
path: string().min(1).optional(),
|
|
121
|
+
sum: computedSourceSchema2.optional(),
|
|
122
|
+
avg: computedSourceSchema2.optional(),
|
|
123
|
+
min: computedSourceSchema2.optional(),
|
|
124
|
+
max: computedSourceSchema2.optional(),
|
|
125
|
+
count: computedSourceSchema2.optional(),
|
|
126
|
+
weights: array(number()).min(1).optional(),
|
|
127
|
+
op: _enum(CONDITION_OPERATORS2).optional(),
|
|
128
|
+
value: jsonValueSchema.optional(),
|
|
129
|
+
ref: string().min(1).optional(),
|
|
130
|
+
get where() {
|
|
131
|
+
return conditionSchema2.optional();
|
|
132
|
+
}
|
|
133
|
+
}).superRefine((condition, ctx) => {
|
|
134
|
+
const combinators = ["all", "any", "not"].filter((key) => condition[key] !== undefined);
|
|
135
|
+
const lefts = ["path", ...COMPUTED_FUNCTIONS2].filter((key) => condition[key] !== undefined);
|
|
136
|
+
if (combinators.length > 0) {
|
|
137
|
+
const extras = Object.keys(condition).filter((key) => key !== combinators[0]);
|
|
138
|
+
if (combinators.length > 1 || extras.length > 0) {
|
|
139
|
+
ctx.addIssue({
|
|
140
|
+
code: "custom",
|
|
141
|
+
message: `A condition with "${String(combinators[0])}" can't have other keys (found ${[...combinators.slice(1), ...extras].map((key) => `"${key}"`).join(", ")})`
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (lefts.length !== 1) {
|
|
147
|
+
ctx.addIssue({
|
|
148
|
+
code: "custom",
|
|
149
|
+
message: lefts.length === 0 ? 'A condition needs exactly one of "path", "sum", "avg", "min", "max", "count", or a combinator "all", "any", "not"' : `A condition can have only one of ${lefts.map((key) => `"${key}"`).join(", ")}`
|
|
150
|
+
});
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (condition.op === undefined) {
|
|
154
|
+
ctx.addIssue({
|
|
155
|
+
code: "custom",
|
|
156
|
+
message: 'A condition needs "op"',
|
|
157
|
+
path: ["op"]
|
|
158
|
+
});
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const isList = LIST_OPS.has(condition.op);
|
|
162
|
+
const isUnary = UNARY_OPS.has(condition.op);
|
|
163
|
+
if (isList && condition.where === undefined) {
|
|
164
|
+
ctx.addIssue({
|
|
165
|
+
code: "custom",
|
|
166
|
+
message: `"${condition.op}" needs a "where" condition`,
|
|
167
|
+
path: ["where"]
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
if (!isList && condition.where !== undefined) {
|
|
171
|
+
ctx.addIssue({
|
|
172
|
+
code: "custom",
|
|
173
|
+
message: `"where" is only allowed with "some", "every" or "none", not "${condition.op}"`,
|
|
174
|
+
path: ["where"]
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
const hasValue = condition.value !== undefined;
|
|
178
|
+
const hasRef = condition.ref !== undefined;
|
|
179
|
+
if ((isList || isUnary) && (hasValue || hasRef)) {
|
|
180
|
+
ctx.addIssue({
|
|
181
|
+
code: "custom",
|
|
182
|
+
message: `"${condition.op}" takes no "value" or "ref"`,
|
|
183
|
+
path: [hasValue ? "value" : "ref"]
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
if (!isList && !isUnary && hasValue === hasRef) {
|
|
187
|
+
ctx.addIssue({
|
|
188
|
+
code: "custom",
|
|
189
|
+
message: `"${condition.op}" needs exactly one of "value" or "ref"`
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
if (condition.weights !== undefined && condition.avg === undefined) {
|
|
193
|
+
ctx.addIssue({
|
|
194
|
+
code: "custom",
|
|
195
|
+
message: '"weights" is only allowed with "avg"',
|
|
196
|
+
path: ["weights"]
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
var toleratedFailuresSchema2 = union([
|
|
201
|
+
strictObject({ count: int().nonnegative() }),
|
|
202
|
+
strictObject({ percent: number().min(0).max(100) })
|
|
203
|
+
]);
|
|
204
|
+
var eachSchema2 = strictObject({
|
|
205
|
+
over: string().min(1),
|
|
206
|
+
maxConcurrency: int().positive().optional(),
|
|
207
|
+
toleratedFailures: toleratedFailuresSchema2.optional()
|
|
208
|
+
});
|
|
209
|
+
var routeShape = {
|
|
210
|
+
when: conditionSchema2.optional(),
|
|
211
|
+
to: nodeIdSchema,
|
|
212
|
+
pipeline: string().min(1).optional(),
|
|
213
|
+
args: record(string().min(1), argValueSchema2).optional(),
|
|
214
|
+
each: eachSchema2.optional(),
|
|
215
|
+
partial: literal(true).optional()
|
|
216
|
+
};
|
|
217
|
+
function noPartialWithEach(route, ctx) {
|
|
218
|
+
if (route.each !== undefined && route.partial !== undefined) {
|
|
219
|
+
ctx.addIssue({
|
|
220
|
+
code: "custom",
|
|
221
|
+
message: `A route can't have both "each" and "partial"`,
|
|
222
|
+
path: ["partial"]
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
var routeSchema2 = strictObject(routeShape).superRefine(noPartialWithEach);
|
|
227
|
+
var otherwiseSchema2 = strictObject(routeShape).omit({ when: true }).superRefine(noPartialWithEach);
|
|
228
|
+
var startSchema2 = strictObject(routeShape).omit({ partial: true });
|
|
229
|
+
var MATCH_MODES2 = ["first", "all"];
|
|
230
|
+
var nextSchema2 = strictObject({
|
|
231
|
+
match: _enum(MATCH_MODES2).optional(),
|
|
232
|
+
routes: array(routeSchema2).min(1),
|
|
233
|
+
otherwise: otherwiseSchema2.optional()
|
|
234
|
+
});
|
|
235
|
+
var retrySchema2 = strictObject({
|
|
236
|
+
on: array(string().min(1)).min(1),
|
|
237
|
+
maxAttempts: int().positive(),
|
|
238
|
+
intervalSeconds: number().nonnegative().optional(),
|
|
239
|
+
backoffRate: number().positive().optional(),
|
|
240
|
+
maxDelaySeconds: number().nonnegative().optional()
|
|
241
|
+
});
|
|
242
|
+
var catchSchema2 = strictObject({
|
|
243
|
+
on: array(string().min(1)).min(1),
|
|
244
|
+
to: nodeIdSchema,
|
|
245
|
+
pipeline: string().min(1).optional(),
|
|
246
|
+
args: record(string().min(1), argValueSchema2).optional()
|
|
247
|
+
});
|
|
248
|
+
var stepNodeSchema2 = strictObject({
|
|
249
|
+
kind: literal("step"),
|
|
250
|
+
title: string().optional(),
|
|
251
|
+
step: string().min(1),
|
|
252
|
+
next: nextSchema2.optional(),
|
|
253
|
+
retry: array(retrySchema2).optional(),
|
|
254
|
+
catch: array(catchSchema2).optional(),
|
|
255
|
+
timeoutSeconds: int().positive().optional(),
|
|
256
|
+
heartbeatSeconds: int().positive().optional(),
|
|
257
|
+
maxRuns: int().positive().optional(),
|
|
258
|
+
maxTurns: int().nonnegative().optional()
|
|
259
|
+
});
|
|
260
|
+
var DEFAULT_MAX_TURNS2 = 2;
|
|
261
|
+
var DECISION_BODY_MODES2 = ["optional", "required"];
|
|
262
|
+
var decisionActionSchema2 = strictObject({
|
|
263
|
+
key: string().min(1),
|
|
264
|
+
label: string().min(1),
|
|
265
|
+
body: _enum(DECISION_BODY_MODES2).optional()
|
|
266
|
+
});
|
|
267
|
+
var waitNodeSchema2 = strictObject({
|
|
268
|
+
kind: literal("wait"),
|
|
269
|
+
title: string().optional(),
|
|
270
|
+
for: _enum(["decision", "reply", "event", "timer"]),
|
|
271
|
+
actions: array(decisionActionSchema2).optional(),
|
|
272
|
+
next: nextSchema2.optional(),
|
|
273
|
+
catch: array(catchSchema2).optional(),
|
|
274
|
+
timeoutSeconds: int().positive().optional(),
|
|
275
|
+
maxRuns: int().positive().optional()
|
|
276
|
+
});
|
|
277
|
+
var succeedNodeSchema2 = strictObject({
|
|
278
|
+
kind: literal("succeed"),
|
|
279
|
+
title: string().optional()
|
|
280
|
+
});
|
|
281
|
+
var failNodeSchema2 = strictObject({
|
|
282
|
+
kind: literal("fail"),
|
|
283
|
+
title: string().optional(),
|
|
284
|
+
error: string().min(1).optional(),
|
|
285
|
+
cause: string().optional()
|
|
286
|
+
});
|
|
287
|
+
var nodeSchema2 = discriminatedUnion("kind", [
|
|
288
|
+
stepNodeSchema2,
|
|
289
|
+
waitNodeSchema2,
|
|
290
|
+
succeedNodeSchema2,
|
|
291
|
+
failNodeSchema2
|
|
292
|
+
]);
|
|
293
|
+
var pipelineDocumentSchema2 = strictObject({
|
|
294
|
+
$schema: string().optional(),
|
|
295
|
+
schemaVersion: literal(1),
|
|
296
|
+
key: string().min(1),
|
|
297
|
+
title: string().optional(),
|
|
298
|
+
timeoutSeconds: int().positive().optional(),
|
|
299
|
+
workItemFields: record(string().regex(ALIAS_PATTERN2, "Aliases must be identifiers (letters, digits, '_')"), string().min(1)).optional(),
|
|
300
|
+
start: startSchema2,
|
|
301
|
+
nodes: record(nodeIdSchema, nodeSchema2)
|
|
302
|
+
});
|
|
303
|
+
function pipelineDocumentJsonSchema2() {
|
|
304
|
+
return toJSONSchema(pipelineDocumentSchema2, { io: "input" });
|
|
305
|
+
}
|
|
306
|
+
// src/contracts/pipeline-document/routes.ts
|
|
307
|
+
function routeEntries2(next) {
|
|
308
|
+
if (next === undefined) {
|
|
309
|
+
return [];
|
|
310
|
+
}
|
|
311
|
+
const entries = next.routes.map((route, index) => ({
|
|
312
|
+
kind: "route",
|
|
313
|
+
index,
|
|
314
|
+
route,
|
|
315
|
+
pointer: ["routes", index]
|
|
316
|
+
}));
|
|
317
|
+
if (next.otherwise !== undefined) {
|
|
318
|
+
entries.push({
|
|
319
|
+
kind: "otherwise",
|
|
320
|
+
index: 0,
|
|
321
|
+
route: next.otherwise,
|
|
322
|
+
pointer: ["otherwise"]
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
return entries;
|
|
326
|
+
}
|
|
327
|
+
function routeAt2(next, kind, index) {
|
|
328
|
+
if (next === undefined) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
return kind === "otherwise" ? next.otherwise : next.routes[index];
|
|
332
|
+
}
|
|
333
|
+
export { isJsonObject2, jsonPointer2, deepEqual2, COMPARISON_OPERATORS2, CONDITION_OPERATORS2, COMPUTED_FUNCTIONS2, ORDERING_OPERATORS2, STRING_OPERATORS2, DATE_OPERATORS2, LIST_OPERATORS2, NODE_ID_PATTERN2, ALIAS_PATTERN2, literalSchema2, listSchema2, argValueSchema2, computedSourceSchema2, conditionSchema2, toleratedFailuresSchema2, eachSchema2, routeSchema2, otherwiseSchema2, startSchema2, MATCH_MODES2, nextSchema2, retrySchema2, catchSchema2, stepNodeSchema2, DEFAULT_MAX_TURNS2, DECISION_BODY_MODES2, decisionActionSchema2, waitNodeSchema2, succeedNodeSchema2, failNodeSchema2, nodeSchema2, pipelineDocumentSchema2, pipelineDocumentJsonSchema2, routeEntries2, routeAt2 };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
_enum
|
|
4
|
+
} from "./chunk-dnn39qt4.js";
|
|
5
|
+
|
|
6
|
+
// src/contracts/artifacts.ts
|
|
7
|
+
var artifactKindSchema2 = _enum([
|
|
8
|
+
"generic",
|
|
9
|
+
"playwright-trace",
|
|
10
|
+
"video",
|
|
11
|
+
"image"
|
|
12
|
+
]);
|
|
13
|
+
var ARTIFACT_SCHEMA_KEYWORD2 = "x-scarn-artifact";
|
|
14
|
+
var artifactPlatforms2 = ["github", "jira", "bitbucket"];
|
|
15
|
+
var EMBEDDABLE_ARTIFACT_EXTENSIONS2 = {
|
|
16
|
+
jira: [".png", ".gif", ".mp4", ".webm"],
|
|
17
|
+
github: [],
|
|
18
|
+
bitbucket: []
|
|
19
|
+
};
|
|
20
|
+
function isEmbeddableArtifactExtension2(platform, extension) {
|
|
21
|
+
return EMBEDDABLE_ARTIFACT_EXTENSIONS2[platform].includes(extension.toLowerCase());
|
|
22
|
+
}
|
|
23
|
+
function artifactFileExtension2(fileName) {
|
|
24
|
+
const base = fileName.slice(fileName.lastIndexOf("/") + 1);
|
|
25
|
+
const dot = base.lastIndexOf(".");
|
|
26
|
+
if (dot <= 0)
|
|
27
|
+
return "";
|
|
28
|
+
return base.slice(dot).toLowerCase();
|
|
29
|
+
}
|
|
30
|
+
function artifactAcceptsFile2(accept, fileName) {
|
|
31
|
+
if (accept.length === 0)
|
|
32
|
+
return true;
|
|
33
|
+
return accept.includes(artifactFileExtension2(fileName));
|
|
34
|
+
}
|
|
35
|
+
function asRecord(node) {
|
|
36
|
+
return typeof node === "object" ? node : null;
|
|
37
|
+
}
|
|
38
|
+
function isNullSchema(node) {
|
|
39
|
+
return asRecord(node)?.["type"] === "null";
|
|
40
|
+
}
|
|
41
|
+
function schemaBranches(record, keyword) {
|
|
42
|
+
const value = record[keyword];
|
|
43
|
+
if (!Array.isArray(value))
|
|
44
|
+
return [];
|
|
45
|
+
return value.filter((entry) => typeof entry === "boolean" || typeof entry === "object" && entry !== null && !Array.isArray(entry));
|
|
46
|
+
}
|
|
47
|
+
function readArtifactKeyword2(node) {
|
|
48
|
+
const record = asRecord(node);
|
|
49
|
+
const keyword = asRecord(record?.[ARTIFACT_SCHEMA_KEYWORD2]);
|
|
50
|
+
if (!keyword)
|
|
51
|
+
return null;
|
|
52
|
+
const accept = keyword["accept"];
|
|
53
|
+
return {
|
|
54
|
+
accept: Array.isArray(accept) ? accept.filter((entry) => typeof entry === "string") : []
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function readDescription(node) {
|
|
58
|
+
const description = asRecord(node)?.["description"];
|
|
59
|
+
return typeof description === "string" ? description : null;
|
|
60
|
+
}
|
|
61
|
+
function matchArtifactNode2(node) {
|
|
62
|
+
const direct = readArtifactKeyword2(node);
|
|
63
|
+
if (direct) {
|
|
64
|
+
const types = asRecord(node)?.["type"];
|
|
65
|
+
return {
|
|
66
|
+
...direct,
|
|
67
|
+
nullable: Array.isArray(types) && types.includes("null"),
|
|
68
|
+
description: readDescription(node)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const record = asRecord(node);
|
|
72
|
+
if (!record)
|
|
73
|
+
return null;
|
|
74
|
+
for (const keyword of ["anyOf", "oneOf"]) {
|
|
75
|
+
const branches = schemaBranches(record, keyword);
|
|
76
|
+
const nonNull = branches.filter((branch) => !isNullSchema(branch));
|
|
77
|
+
const [only] = nonNull;
|
|
78
|
+
if (!only || nonNull.length !== 1 || branches.length !== 2)
|
|
79
|
+
continue;
|
|
80
|
+
const inner = readArtifactKeyword2(only);
|
|
81
|
+
if (!inner)
|
|
82
|
+
continue;
|
|
83
|
+
return {
|
|
84
|
+
...inner,
|
|
85
|
+
nullable: true,
|
|
86
|
+
description: readDescription(node) ?? readDescription(only)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
var MAX_REF_HOPS = 16;
|
|
92
|
+
function resolveLocalRef(root, ref) {
|
|
93
|
+
if (!ref.startsWith("#"))
|
|
94
|
+
return null;
|
|
95
|
+
const pointer = ref.slice(1);
|
|
96
|
+
if (pointer === "" || pointer === "/")
|
|
97
|
+
return root;
|
|
98
|
+
let current = root;
|
|
99
|
+
for (const rawToken of pointer.slice(1).split("/")) {
|
|
100
|
+
const token = rawToken.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
101
|
+
if (typeof current !== "object" || current === null)
|
|
102
|
+
return null;
|
|
103
|
+
current = current[token];
|
|
104
|
+
}
|
|
105
|
+
return typeof current === "object" && current !== null ? current : null;
|
|
106
|
+
}
|
|
107
|
+
function findArtifactFields2(schema) {
|
|
108
|
+
if (schema === null || schema === undefined)
|
|
109
|
+
return [];
|
|
110
|
+
const root = schema;
|
|
111
|
+
const fields = new Map;
|
|
112
|
+
const visit = (node, path, inArray, hops) => {
|
|
113
|
+
if (hops > MAX_REF_HOPS)
|
|
114
|
+
return;
|
|
115
|
+
const record = asRecord(node);
|
|
116
|
+
if (!record)
|
|
117
|
+
return;
|
|
118
|
+
const ref = record["$ref"];
|
|
119
|
+
if (typeof ref === "string") {
|
|
120
|
+
const target = resolveLocalRef(root, ref);
|
|
121
|
+
if (target)
|
|
122
|
+
visit(target, path, inArray, hops + 1);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const match = path ? matchArtifactNode2(node) : null;
|
|
126
|
+
if (match) {
|
|
127
|
+
if (!fields.has(path)) {
|
|
128
|
+
fields.set(path, {
|
|
129
|
+
path,
|
|
130
|
+
accept: match.accept,
|
|
131
|
+
nullable: match.nullable,
|
|
132
|
+
description: match.description,
|
|
133
|
+
inArray
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
for (const keyword of ["anyOf", "oneOf", "allOf"]) {
|
|
139
|
+
for (const branch of schemaBranches(record, keyword)) {
|
|
140
|
+
visit(branch, path, inArray, hops + 1);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const properties = asRecord(record["properties"]);
|
|
144
|
+
for (const [key, child] of Object.entries(properties ?? {})) {
|
|
145
|
+
const childNode = child;
|
|
146
|
+
visit(childNode, path ? `${path}.${key}` : key, inArray, hops);
|
|
147
|
+
}
|
|
148
|
+
const items = record["items"];
|
|
149
|
+
if (items !== undefined)
|
|
150
|
+
visit(items, `${path}[]`, true, hops);
|
|
151
|
+
const prefixItems = record["prefixItems"];
|
|
152
|
+
if (Array.isArray(prefixItems)) {
|
|
153
|
+
for (const item of prefixItems) {
|
|
154
|
+
visit(item, `${path}[]`, true, hops);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
visit(schema, "", false, 0);
|
|
159
|
+
return [...fields.values()];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export { artifactKindSchema2, ARTIFACT_SCHEMA_KEYWORD2, artifactPlatforms2, EMBEDDABLE_ARTIFACT_EXTENSIONS2, isEmbeddableArtifactExtension2, artifactFileExtension2, artifactAcceptsFile2, readArtifactKeyword2, matchArtifactNode2, findArtifactFields2 };
|