@scarn/sdk 0.8.20 → 0.8.22
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/auth/api-token-cache.d.ts +24 -0
- package/dist/auth/api-token-source.d.ts +39 -0
- package/dist/auth/authenticated-fetch.d.ts +10 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.js +19 -0
- package/dist/automations/index.js +14 -17
- package/dist/{chunk-habmdf89.js → chunk-0bwsjn0b.js} +29 -29
- package/dist/{chunk-mzj1j0p5.js → chunk-0w13kxkr.js} +34 -31
- package/dist/{chunk-qgkx89eg.js → chunk-3j5wf2t5.js} +44 -43
- package/dist/{chunk-0y2fy5en.js → chunk-4361gxk0.js} +7 -7
- package/dist/{chunk-n3ywwx7n.js → chunk-52520csz.js} +15 -14
- package/dist/chunk-5dnfgyx8.js +159 -0
- package/dist/{chunk-tr3v83cn.js → chunk-5fa4arn1.js} +18 -11
- package/dist/{chunk-ngy1fdcx.js → chunk-631ffb6r.js} +10 -10
- package/dist/{chunk-01nfqm18.js → chunk-7anj08zc.js} +11 -9
- package/dist/{chunk-yq0sf8sb.js → chunk-7dr4kybf.js} +483 -451
- package/dist/chunk-7mhr5aex.js +171 -0
- package/dist/chunk-7rywbqzz.js +27 -0
- package/dist/{chunk-yf15kdte.js → chunk-9ct3xypr.js} +2636 -3864
- package/dist/chunk-9geh4c3v.js +1034 -0
- package/dist/{chunk-19brnwkp.js → chunk-9qf0eg7m.js} +19 -19
- package/dist/{chunk-y11p1q7r.js → chunk-aqqywy8g.js} +4 -4
- package/dist/chunk-bcvx11fn.js +174 -0
- package/dist/{chunk-z4smq8qd.js → chunk-cyfeaz43.js} +86 -86
- package/dist/chunk-czq37rrt.js +286 -0
- package/dist/chunk-ec5z8bbq.js +126 -0
- package/dist/{chunk-rt9tq4j6.js → chunk-h9yxx0hd.js} +7 -7
- package/dist/{chunk-t1dq2c2s.js → chunk-hma87efq.js} +40 -40
- package/dist/{chunk-5dny5jg1.js → chunk-hpv234hf.js} +11 -11
- package/dist/{chunk-rq5k7m33.js → chunk-k7xnsmp5.js} +182 -97
- package/dist/{chunk-91f5gm5z.js → chunk-kbpkpxcn.js} +22 -21
- package/dist/{chunk-6tra3gw8.js → chunk-kjn1knb9.js} +7 -7
- package/dist/{chunk-g4j5cfpc.js → chunk-p3s7cjfc.js} +17 -16
- package/dist/chunk-pq6hrtnb.js +49 -0
- package/dist/{chunk-mp2rqtcj.js → chunk-ptpy7nnm.js} +8 -8
- package/dist/{chunk-xqfj56m9.js → chunk-vn1rfxma.js} +8 -8
- package/dist/chunk-vyv8kvkv.js +113 -0
- package/dist/{chunk-0c60x3v8.js → chunk-xe2zgyz7.js} +35 -35
- package/dist/chunk-y4dwmhn2.js +14 -0
- package/dist/{chunk-098740f7.js → chunk-yypj3zn0.js} +8 -8
- package/dist/chunk-yzj1mfpr.js +1515 -0
- package/dist/client.d.ts +5 -1
- package/dist/client.js +62 -61
- package/dist/connectors/index.js +36 -37
- package/dist/contracts/artifact-markers.js +11 -12
- package/dist/contracts/artifacts.js +21 -23
- package/dist/contracts/automation-document/index.js +28 -30
- package/dist/contracts/pipeline-document/built-ins.d.ts +1 -1
- package/dist/contracts/pipeline-document/index.js +95 -97
- package/dist/contracts/step-artifact-submissions.js +20 -17
- package/dist/contracts/work-item-changes.js +8 -6
- package/dist/create-api-client.d.ts +11 -0
- package/dist/defaults/index.js +44 -884
- package/dist/defaults/load-push-defaults.d.ts +11 -4
- package/dist/defaults/project-ref.d.ts +2 -4
- package/dist/definitions/automations/automations-client.d.ts +2 -1
- package/dist/definitions/automations/index.js +6 -8
- package/dist/definitions/environments/environments-client.d.ts +2 -1
- package/dist/definitions/environments/index.js +37 -38
- package/dist/definitions/pipelines/index.js +12 -14
- package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +2 -1
- package/dist/definitions/steps/define-mcp.d.ts +2 -2
- package/dist/definitions/steps/index.js +93 -95
- package/dist/definitions/steps/mcp-server-config.d.ts +13 -3
- package/dist/definitions/steps/step-definitions-client.d.ts +20 -1
- package/dist/definitions/validation/index.js +17 -18
- package/dist/devcontainer-config-path.js +9 -11
- package/dist/env-vars.js +37 -39
- package/dist/environment.js +41 -42
- package/dist/eslint.js +0 -2
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/sdk.gen.d.ts +41 -1
- package/dist/generated/types.gen.d.ts +1801 -0
- package/dist/git-url/git-repo-identity.js +0 -2
- package/dist/health-checks.js +15 -17
- package/dist/index.js +364 -358
- package/dist/jsonc.js +7 -8
- package/dist/managed-connections.d.ts +16 -0
- package/dist/managed-connections.js +9 -0
- package/dist/managed-runtimes.js +9 -11
- package/dist/opencode-mcp.d.ts +55 -1
- package/dist/opencode-mcp.js +33 -28
- package/dist/pipelines/index.js +78 -81
- package/dist/push/code-step-lookup.js +9 -10
- package/dist/push/index.d.ts +1 -0
- package/dist/push/index.js +109 -79
- package/dist/push/push-from-directory.d.ts +9 -1
- package/dist/push/pushed-mcp-servers.d.ts +28 -0
- package/dist/repo-config.js +41 -43
- package/dist/resolve-environment.js +14 -15
- package/dist/scarn-config-parser.js +5 -6
- package/dist/task-plane-client.d.ts +143 -1
- package/package.json +11 -3
- package/dist/chunk-46wmsgv7.js +0 -14
- package/dist/chunk-a56zc4s5.js +0 -119
- package/dist/chunk-aemxz9r7.js +0 -107
- package/dist/chunk-b9ja6ss5.js +0 -275
- package/dist/chunk-e0pt5x0e.js +0 -167
- package/dist/chunk-pqtd0hr7.js +0 -96
- package/dist/chunk-rphfy0fj.js +0 -167
- package/dist/chunk-y34zsgsw.js +0 -39
- package/dist/chunk-y64skrwp.js +0 -17
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
string,
|
|
4
|
+
object,
|
|
5
|
+
discriminatedUnion,
|
|
6
|
+
_enum,
|
|
7
|
+
literal
|
|
8
|
+
} from "./chunk-9ct3xypr.js";
|
|
9
|
+
|
|
10
|
+
// src/repo-config.ts
|
|
11
|
+
var MAX_REPO_COMMIT_MESSAGE_LENGTH2 = 500;
|
|
12
|
+
var REPO_COMMIT_MESSAGE_TOKEN_ROOTS2 = [
|
|
13
|
+
"input",
|
|
14
|
+
"result",
|
|
15
|
+
"workItem"
|
|
16
|
+
];
|
|
17
|
+
var REPO_COMMIT_MESSAGE_WORK_ITEM_KEYS2 = [
|
|
18
|
+
"title",
|
|
19
|
+
"platformKey"
|
|
20
|
+
];
|
|
21
|
+
function commitMessageUsesWorkItem2(message) {
|
|
22
|
+
for (const match of message.matchAll(TOKEN_PATTERN)) {
|
|
23
|
+
if ((match[1] ?? "").split(".")[0] === "workItem")
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
var TOKEN_PATTERN = /\{\{([^}]+)\}\}/g;
|
|
29
|
+
function findDisallowedTemplateTokens(template, rules) {
|
|
30
|
+
const disallowed = [];
|
|
31
|
+
for (const match of template.matchAll(TOKEN_PATTERN)) {
|
|
32
|
+
const path = match[1] ?? "";
|
|
33
|
+
const [root = "", ...rest] = path.split(".");
|
|
34
|
+
if (!rules.roots.includes(root)) {
|
|
35
|
+
disallowed.push(root);
|
|
36
|
+
} else if (root === "workItem" && (rest.length !== 1 || !rules.workItemKeys.includes(rest[0] ?? ""))) {
|
|
37
|
+
disallowed.push(path);
|
|
38
|
+
} else if (rules.singleSegmentRoots?.includes(root) && (rest.length !== 1 || rest[0] === "")) {
|
|
39
|
+
disallowed.push(path);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return disallowed;
|
|
43
|
+
}
|
|
44
|
+
function findDisallowedCommitMessageTokenRoots2(message) {
|
|
45
|
+
return findDisallowedTemplateTokens(message, {
|
|
46
|
+
roots: REPO_COMMIT_MESSAGE_TOKEN_ROOTS2,
|
|
47
|
+
workItemKeys: REPO_COMMIT_MESSAGE_WORK_ITEM_KEYS2
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
var MAX_REPO_BASE_BRANCH_LENGTH2 = 255;
|
|
51
|
+
var REPO_BASE_BRANCH_TOKEN_ROOTS2 = [
|
|
52
|
+
"input",
|
|
53
|
+
"env",
|
|
54
|
+
"workItem"
|
|
55
|
+
];
|
|
56
|
+
var REPO_BASE_BRANCH_WORK_ITEM_KEYS2 = [
|
|
57
|
+
"platformKey"
|
|
58
|
+
];
|
|
59
|
+
function findDisallowedBaseBranchTokens2(baseBranch) {
|
|
60
|
+
return findDisallowedTemplateTokens(baseBranch, {
|
|
61
|
+
roots: REPO_BASE_BRANCH_TOKEN_ROOTS2,
|
|
62
|
+
workItemKeys: REPO_BASE_BRANCH_WORK_ITEM_KEYS2,
|
|
63
|
+
singleSegmentRoots: ["env"]
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function findBaseBranchEnvProblems2(baseBranch, vars) {
|
|
67
|
+
const problems = [];
|
|
68
|
+
for (const match of baseBranch.matchAll(TOKEN_PATTERN)) {
|
|
69
|
+
const path = (match[1] ?? "").trim();
|
|
70
|
+
const [root, name, ...rest] = path.split(".");
|
|
71
|
+
if (root !== "env" || name === undefined || rest.length > 0)
|
|
72
|
+
continue;
|
|
73
|
+
const entry = vars.find((candidate) => candidate.name === name);
|
|
74
|
+
if (entry === undefined) {
|
|
75
|
+
problems.push({ token: path, reason: "undeclared" });
|
|
76
|
+
} else if (entry.source === "secret" || entry.secret) {
|
|
77
|
+
problems.push({ token: path, reason: "secret" });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return problems;
|
|
81
|
+
}
|
|
82
|
+
function describeBaseBranchEnvProblem2({
|
|
83
|
+
token,
|
|
84
|
+
reason
|
|
85
|
+
}) {
|
|
86
|
+
return reason === "secret" ? `{{${token}}} names a secret var; branch names end up in logs, git and the UI` : `{{${token}}} names a var the environment does not declare`;
|
|
87
|
+
}
|
|
88
|
+
function isValidGitBranchName2(name) {
|
|
89
|
+
if (name === "" || name === "@")
|
|
90
|
+
return false;
|
|
91
|
+
if (name.startsWith("-") || name.startsWith("/"))
|
|
92
|
+
return false;
|
|
93
|
+
if (name.endsWith("/") || name.endsWith("."))
|
|
94
|
+
return false;
|
|
95
|
+
if (name.includes("..") || name.includes("//") || name.includes("@{")) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
if (/[\x00-\x20\x7f~^:?*[\\]/.test(name))
|
|
99
|
+
return false;
|
|
100
|
+
return name.split("/").every((component) => !component.startsWith(".") && !component.endsWith(".lock"));
|
|
101
|
+
}
|
|
102
|
+
function isValidBaseBranchTemplate2(template) {
|
|
103
|
+
return isValidGitBranchName2(template.replace(TOKEN_PATTERN, "x"));
|
|
104
|
+
}
|
|
105
|
+
var repoBaseBranchSchema2 = string().max(MAX_REPO_BASE_BRANCH_LENGTH2).refine((baseBranch) => !/[\r\n]/.test(baseBranch), {
|
|
106
|
+
message: "must be a single line"
|
|
107
|
+
}).refine((baseBranch) => findDisallowedBaseBranchTokens2(baseBranch).length === 0, {
|
|
108
|
+
message: "may only use {{input.\u2026}}, {{env.NAME}} and {{workItem.platformKey}} tokens"
|
|
109
|
+
}).refine(isValidBaseBranchTemplate2, {
|
|
110
|
+
message: "must be a valid branch name (git check-ref-format --branch)"
|
|
111
|
+
});
|
|
112
|
+
var repoWorkBranchSchema2 = discriminatedUnion("kind", [
|
|
113
|
+
object({ kind: literal("create") }).strict(),
|
|
114
|
+
object({ kind: literal("base") }).strict()
|
|
115
|
+
]);
|
|
116
|
+
var repoCommitMessageSchema2 = string().max(MAX_REPO_COMMIT_MESSAGE_LENGTH2).refine((message) => !/[\r\n]/.test(message), {
|
|
117
|
+
message: "must be a single line"
|
|
118
|
+
}).refine((message) => findDisallowedCommitMessageTokenRoots2(message).length === 0, {
|
|
119
|
+
message: `may only use {{input.\u2026}}, {{result.\u2026}}, {{${REPO_COMMIT_MESSAGE_WORK_ITEM_KEYS2.map((key) => `workItem.${key}`).join("}} and {{")}}} tokens`
|
|
120
|
+
});
|
|
121
|
+
var onPushFailureSchema = _enum(["fail", "warn"]);
|
|
122
|
+
var repoGitCredentialsSchema2 = _enum(["auto", "none"]);
|
|
123
|
+
var repoConfigInputSchema2 = discriminatedUnion("mode", [
|
|
124
|
+
object({
|
|
125
|
+
mode: literal("readOnly"),
|
|
126
|
+
gitCredentials: repoGitCredentialsSchema2.optional(),
|
|
127
|
+
baseBranch: repoBaseBranchSchema2.nullish()
|
|
128
|
+
}).strict(),
|
|
129
|
+
object({
|
|
130
|
+
mode: literal("readWrite"),
|
|
131
|
+
message: repoCommitMessageSchema2.nullish(),
|
|
132
|
+
onPushFailure: onPushFailureSchema.optional(),
|
|
133
|
+
gitCredentials: repoGitCredentialsSchema2.optional(),
|
|
134
|
+
baseBranch: repoBaseBranchSchema2.nullish(),
|
|
135
|
+
workBranch: repoWorkBranchSchema2.optional()
|
|
136
|
+
}).strict()
|
|
137
|
+
]);
|
|
138
|
+
var repoConfigSchema2 = discriminatedUnion("mode", [
|
|
139
|
+
object({
|
|
140
|
+
mode: literal("readOnly"),
|
|
141
|
+
gitCredentials: repoGitCredentialsSchema2,
|
|
142
|
+
baseBranch: repoBaseBranchSchema2.nullable()
|
|
143
|
+
}).strict(),
|
|
144
|
+
object({
|
|
145
|
+
mode: literal("readWrite"),
|
|
146
|
+
message: repoCommitMessageSchema2.nullable(),
|
|
147
|
+
onPushFailure: onPushFailureSchema,
|
|
148
|
+
gitCredentials: repoGitCredentialsSchema2,
|
|
149
|
+
baseBranch: repoBaseBranchSchema2.nullable(),
|
|
150
|
+
workBranch: repoWorkBranchSchema2
|
|
151
|
+
}).strict()
|
|
152
|
+
]);
|
|
153
|
+
function resolveRepoConfig2(input) {
|
|
154
|
+
const mode = input?.mode ?? "readWrite";
|
|
155
|
+
const gitCredentials = (input && "gitCredentials" in input ? input.gitCredentials : undefined) ?? "auto";
|
|
156
|
+
const baseBranch = input?.baseBranch ?? null;
|
|
157
|
+
if (mode === "readOnly") {
|
|
158
|
+
return { mode, gitCredentials, baseBranch };
|
|
159
|
+
}
|
|
160
|
+
const readWrite = input?.mode === "readWrite" ? input : undefined;
|
|
161
|
+
return {
|
|
162
|
+
mode,
|
|
163
|
+
message: readWrite?.message ?? null,
|
|
164
|
+
onPushFailure: readWrite?.onPushFailure ?? "fail",
|
|
165
|
+
gitCredentials,
|
|
166
|
+
baseBranch,
|
|
167
|
+
workBranch: readWrite?.workBranch ?? { kind: "create" }
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export { MAX_REPO_COMMIT_MESSAGE_LENGTH2, REPO_COMMIT_MESSAGE_TOKEN_ROOTS2, REPO_COMMIT_MESSAGE_WORK_ITEM_KEYS2, commitMessageUsesWorkItem2, findDisallowedCommitMessageTokenRoots2, MAX_REPO_BASE_BRANCH_LENGTH2, REPO_BASE_BRANCH_TOKEN_ROOTS2, REPO_BASE_BRANCH_WORK_ITEM_KEYS2, findDisallowedBaseBranchTokens2, findBaseBranchEnvProblems2, describeBaseBranchEnvProblem2, isValidGitBranchName2, isValidBaseBranchTemplate2, repoBaseBranchSchema2, repoWorkBranchSchema2, repoCommitMessageSchema2, repoGitCredentialsSchema2, repoConfigInputSchema2, repoConfigSchema2, resolveRepoConfig2 };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
string
|
|
4
|
+
} from "./chunk-9ct3xypr.js";
|
|
5
|
+
|
|
6
|
+
// src/managed-connections.ts
|
|
7
|
+
var managedConnectionNameSchema2 = string().max(63).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u, {
|
|
8
|
+
message: "must be lowercase kebab-case (letters, digits and hyphens)"
|
|
9
|
+
});
|
|
10
|
+
function normalizeMcpResourceUrl2(url) {
|
|
11
|
+
if (url.includes("?") || url.includes("#"))
|
|
12
|
+
return null;
|
|
13
|
+
let parsed;
|
|
14
|
+
try {
|
|
15
|
+
parsed = new URL(url);
|
|
16
|
+
} catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:")
|
|
20
|
+
return null;
|
|
21
|
+
if (parsed.username !== "" || parsed.password !== "")
|
|
22
|
+
return null;
|
|
23
|
+
const pathname = parsed.pathname.replace(/\/+$/u, "");
|
|
24
|
+
return `${parsed.protocol}//${parsed.host}${pathname}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { managedConnectionNameSchema2, normalizeMcpResourceUrl2 };
|