@scarn/sdk 0.8.2 → 0.8.4
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/automations/define-automation.d.ts +20 -0
- package/dist/automations/index.d.ts +8 -0
- package/dist/automations/index.js +21 -0
- package/dist/automations/targets.d.ts +36 -0
- package/dist/automations/types.d.ts +116 -0
- package/dist/{chunk-nb0nkt71.js → chunk-01nfqm18.js} +1 -0
- package/dist/chunk-0vzq22dj.js +73 -0
- package/dist/chunk-11hbmexe.js +250 -0
- package/dist/{chunk-2fn95pdd.js → chunk-3gy0cb5f.js} +5 -1
- package/dist/{chunk-qrasq5xe.js → chunk-43y7tfn4.js} +33 -414
- package/dist/chunk-61jf8b6s.js +53 -0
- package/dist/chunk-76d1bwwz.js +119 -0
- package/dist/chunk-8z1wa3kd.js +109 -0
- package/dist/{chunk-p7yrcmqm.js → chunk-cnxaagfj.js} +2 -52
- package/dist/{chunk-cdanncng.js → chunk-ejzfdm1z.js} +21 -5
- package/dist/{chunk-gds7w7zh.js → chunk-fgfhvsee.js} +1 -4
- package/dist/{chunk-x9788y82.js → chunk-hyaez4ee.js} +145 -16
- package/dist/{chunk-mz53r914.js → chunk-jj9pezwb.js} +22 -119
- package/dist/{chunk-8pyhrdgy.js → chunk-wnfj3wyx.js} +55 -11
- package/dist/chunk-x0hjhqrf.js +416 -0
- package/dist/chunk-y11p1q7r.js +159 -0
- package/dist/client.js +4 -2
- package/dist/contracts/automation-document/index.d.ts +5 -0
- package/dist/contracts/automation-document/index.js +34 -0
- package/dist/contracts/automation-document/schema.d.ts +363 -0
- package/dist/contracts/pipeline-document/built-ins.d.ts +1 -1
- package/dist/contracts/pipeline-document/index.js +9 -7
- package/dist/contracts/pipeline-document/schema.d.ts +3 -3
- package/dist/contracts/work-item-changes.d.ts +6 -4
- package/dist/contracts/work-item-changes.js +2 -2
- package/dist/defaults/index.js +2 -2
- package/dist/definitions/automations/automations-client.d.ts +178 -0
- package/dist/definitions/automations/index.d.ts +1 -0
- package/dist/definitions/automations/index.js +12 -0
- package/dist/definitions/pipelines/index.d.ts +0 -1
- package/dist/definitions/pipelines/index.js +4 -12
- package/dist/definitions/pipelines/work-item-fields.d.ts +11 -22
- package/dist/definitions/steps/define-code-step.d.ts +8 -5
- package/dist/definitions/steps/define-step.d.ts +22 -11
- package/dist/definitions/steps/index.js +13 -6
- package/dist/definitions/steps/repo.d.ts +11 -3
- package/dist/definitions/steps/runtime.d.ts +11 -12
- package/dist/definitions/steps/step-definitions-client.d.ts +105 -3
- package/dist/definitions/steps/step-features.d.ts +89 -6
- package/dist/definitions/steps/step-handle.d.ts +6 -1
- package/dist/definitions/validation/index.js +2 -2
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/sdk.gen.d.ts +38 -6
- package/dist/generated/types.gen.d.ts +3026 -1889
- package/dist/index.d.ts +1 -0
- package/dist/index.js +44 -30
- package/dist/pipelines/define-pipeline.d.ts +7 -7
- package/dist/pipelines/handles.d.ts +0 -5
- package/dist/pipelines/index.js +7 -4
- package/dist/pipelines/types.d.ts +13 -1
- package/dist/push/collect-definitions.d.ts +3 -8
- package/dist/push/collect-pipeline-documents.d.ts +13 -3
- package/dist/push/index.d.ts +2 -2
- package/dist/push/index.js +87 -124
- package/dist/push/push-from-directory.d.ts +10 -6
- package/dist/repo-config.d.ts +14 -4
- package/dist/repo-config.js +5 -1
- package/dist/task-plane-client.d.ts +71 -1
- package/package.json +13 -1
- package/dist/chunk-ra53p0v8.js +0 -256
- package/dist/definitions/pipelines/define-default-pipeline-assignment.d.ts +0 -263
package/dist/push/index.js
CHANGED
|
@@ -1,43 +1,42 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import {
|
|
3
|
-
assertValidDefinitionSpecs
|
|
4
|
-
} from "../chunk-gds7w7zh.js";
|
|
5
2
|
import {
|
|
6
3
|
isStepDefinitionSpec,
|
|
7
4
|
stepsInModule
|
|
8
5
|
} from "../chunk-ar6hcj1r.js";
|
|
9
6
|
import {
|
|
10
|
-
|
|
7
|
+
AutomationsApiError,
|
|
8
|
+
createAutomationsClient
|
|
9
|
+
} from "../chunk-0vzq22dj.js";
|
|
10
|
+
import {
|
|
11
|
+
assertValidDefinitionSpecs
|
|
12
|
+
} from "../chunk-fgfhvsee.js";
|
|
13
|
+
import {
|
|
11
14
|
PipelineDefinitionsApiError,
|
|
12
|
-
createPipelineDefinitionsClient
|
|
13
|
-
|
|
14
|
-
serializeDefaultPipelineAssignment
|
|
15
|
-
} from "../chunk-ra53p0v8.js";
|
|
15
|
+
createPipelineDefinitionsClient
|
|
16
|
+
} from "../chunk-8z1wa3kd.js";
|
|
16
17
|
import {
|
|
17
18
|
createStepDefinitionsClient,
|
|
18
19
|
toStepSpec
|
|
19
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-hyaez4ee.js";
|
|
21
|
+
import"../chunk-e1h021kq.js";
|
|
20
22
|
import"../chunk-63f90zky.js";
|
|
21
|
-
import"../chunk-
|
|
23
|
+
import"../chunk-jj9pezwb.js";
|
|
24
|
+
import"../chunk-y11p1q7r.js";
|
|
22
25
|
import"../chunk-5zsavw98.js";
|
|
23
26
|
import"../chunk-4ggr8af6.js";
|
|
24
27
|
import"../chunk-k4y5qt4y.js";
|
|
25
|
-
import"../chunk-
|
|
26
|
-
import"../chunk-
|
|
27
|
-
import {
|
|
28
|
-
Projects,
|
|
29
|
-
createClient
|
|
30
|
-
} from "../chunk-8pyhrdgy.js";
|
|
28
|
+
import"../chunk-ejzfdm1z.js";
|
|
29
|
+
import"../chunk-wnfj3wyx.js";
|
|
31
30
|
import"../chunk-ngy1fdcx.js";
|
|
32
31
|
import"../chunk-y2pv8d6a.js";
|
|
33
|
-
import"../chunk-
|
|
32
|
+
import"../chunk-01nfqm18.js";
|
|
34
33
|
import {
|
|
35
34
|
exports_external
|
|
36
35
|
} from "../chunk-skzxcba3.js";
|
|
37
36
|
import"../chunk-y64skrwp.js";
|
|
38
37
|
|
|
39
38
|
// src/push/collect-definitions.ts
|
|
40
|
-
import {
|
|
39
|
+
import { readdirSync } from "fs";
|
|
41
40
|
import { join, relative, resolve } from "path";
|
|
42
41
|
import { pathToFileURL } from "url";
|
|
43
42
|
var INTERNAL_SCRIPT_NAMES = new Set([
|
|
@@ -85,7 +84,7 @@ async function importModule(path) {
|
|
|
85
84
|
}
|
|
86
85
|
function listSourceFiles(absDir) {
|
|
87
86
|
const allFiles = readdirSync(absDir).filter((file) => file.endsWith(".ts") || file.endsWith(".js"));
|
|
88
|
-
return allFiles.filter((file) => !INTERNAL_SCRIPT_NAMES.has(file)
|
|
87
|
+
return allFiles.filter((file) => !INTERNAL_SCRIPT_NAMES.has(file));
|
|
89
88
|
}
|
|
90
89
|
function fileNameWithoutExtension(file) {
|
|
91
90
|
return file.replace(/\.(ts|js)$/, "");
|
|
@@ -109,10 +108,7 @@ async function collectDefinitionsFromDirectory(dir) {
|
|
|
109
108
|
for (const file of sourceFiles) {
|
|
110
109
|
await collectFile(join(absDir, file), absDir, state);
|
|
111
110
|
}
|
|
112
|
-
return {
|
|
113
|
-
steps: [...state.stepMap.values()],
|
|
114
|
-
defaultPipelineAssignment: await collectDefaultPipelineAssignment(absDir)
|
|
115
|
-
};
|
|
111
|
+
return { steps: [...state.stepMap.values()] };
|
|
116
112
|
}
|
|
117
113
|
async function collectDefinitionsFromDirectoryTolerant(dir) {
|
|
118
114
|
const absDir = resolve(dir);
|
|
@@ -129,32 +125,11 @@ async function collectDefinitionsFromDirectoryTolerant(dir) {
|
|
|
129
125
|
});
|
|
130
126
|
}
|
|
131
127
|
}
|
|
132
|
-
let defaultPipelineAssignment = null;
|
|
133
|
-
try {
|
|
134
|
-
defaultPipelineAssignment = await collectDefaultPipelineAssignment(absDir);
|
|
135
|
-
} catch (error) {
|
|
136
|
-
brokenPipelines.push({
|
|
137
|
-
key: fileNameWithoutExtension(DEFAULT_PIPELINE_ASSIGNMENT_FILENAME),
|
|
138
|
-
message: error instanceof Error ? error.message : String(error)
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
128
|
return {
|
|
142
129
|
steps: [...state.stepMap.values()],
|
|
143
|
-
defaultPipelineAssignment,
|
|
144
130
|
brokenPipelines
|
|
145
131
|
};
|
|
146
132
|
}
|
|
147
|
-
async function collectDefaultPipelineAssignment(absDir) {
|
|
148
|
-
const path = join(absDir, DEFAULT_PIPELINE_ASSIGNMENT_FILENAME);
|
|
149
|
-
if (!existsSync(path))
|
|
150
|
-
return null;
|
|
151
|
-
const mod = await importModule(path);
|
|
152
|
-
const spec = mod["default"];
|
|
153
|
-
if (!isDefaultPipelineAssignmentSpec(spec)) {
|
|
154
|
-
throw new Error(`${DEFAULT_PIPELINE_ASSIGNMENT_FILENAME} must have a default export produced by defaultPipelineAssignment(({ assign, skip, ... }) => ({ default: ..., rules: [...] })). Got: ${typeof spec}`);
|
|
155
|
-
}
|
|
156
|
-
return spec;
|
|
157
|
-
}
|
|
158
133
|
// src/push/collect-pipeline-documents.ts
|
|
159
134
|
import { readdirSync as readdirSync2, readFileSync } from "fs";
|
|
160
135
|
import { join as join2, resolve as resolve2 } from "path";
|
|
@@ -165,33 +140,58 @@ var NON_PIPELINE_JSON = new Set([
|
|
|
165
140
|
"jsconfig.json",
|
|
166
141
|
"deno.json"
|
|
167
142
|
]);
|
|
143
|
+
var automationDocumentSchema = exports_external.looseObject({
|
|
144
|
+
kind: exports_external.literal("automation")
|
|
145
|
+
});
|
|
168
146
|
var pipelineDocumentSchema = exports_external.looseObject({ nodes: exports_external.unknown() });
|
|
169
147
|
var documentHeaderSchema = exports_external.object({
|
|
170
148
|
key: exports_external.string().min(1),
|
|
171
149
|
title: exports_external.string().optional()
|
|
172
150
|
});
|
|
173
|
-
function
|
|
151
|
+
function documentKind(value) {
|
|
152
|
+
if (automationDocumentSchema.safeParse(value).success)
|
|
153
|
+
return "automation";
|
|
154
|
+
if (pipelineDocumentSchema.safeParse(value).success)
|
|
155
|
+
return "pipeline";
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
function collectBuiltDocuments(dir) {
|
|
174
159
|
const absDir = resolve2(dir);
|
|
175
160
|
const files = readdirSync2(absDir).filter((file) => file.endsWith(".json") && !NON_PIPELINE_JSON.has(file)).sort();
|
|
176
161
|
const byKey = new Map;
|
|
177
162
|
for (const file of files) {
|
|
178
|
-
const parsed =
|
|
179
|
-
|
|
163
|
+
const parsed = parseJsonFile(join2(absDir, file), file);
|
|
164
|
+
const kind = documentKind(parsed);
|
|
165
|
+
if (kind === undefined)
|
|
180
166
|
continue;
|
|
181
|
-
const document = parsed
|
|
167
|
+
const document = parsed;
|
|
182
168
|
const header = documentHeaderSchema.safeParse(document);
|
|
183
169
|
if (!header.success) {
|
|
184
|
-
throw new Error(`${file} has no "key": every
|
|
170
|
+
throw new Error(`${file} has no "key": every ${kind} document names the ${kind} it publishes to.`);
|
|
185
171
|
}
|
|
186
172
|
const { key, title } = header.data;
|
|
187
173
|
const existing = byKey.get(key);
|
|
188
174
|
if (existing) {
|
|
189
|
-
throw new Error(`${existing.file} and ${file} are both
|
|
175
|
+
throw new Error(`${existing.file} and ${file} are both "${key}". Delete the stale one and build again.`);
|
|
190
176
|
}
|
|
191
|
-
byKey.set(key, { file, key, title, document });
|
|
177
|
+
byKey.set(key, { file, kind, key, title, document });
|
|
192
178
|
}
|
|
193
179
|
return [...byKey.values()];
|
|
194
180
|
}
|
|
181
|
+
function withoutKind(file) {
|
|
182
|
+
return {
|
|
183
|
+
file: file.file,
|
|
184
|
+
key: file.key,
|
|
185
|
+
title: file.title,
|
|
186
|
+
document: file.document
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function collectPipelineDocuments(dir) {
|
|
190
|
+
return collectBuiltDocuments(dir).filter((file) => file.kind === "pipeline").map(withoutKind);
|
|
191
|
+
}
|
|
192
|
+
function collectAutomationDocuments(dir) {
|
|
193
|
+
return collectBuiltDocuments(dir).filter((file) => file.kind === "automation").map(withoutKind);
|
|
194
|
+
}
|
|
195
195
|
function parseJsonFile(path, file) {
|
|
196
196
|
try {
|
|
197
197
|
return JSON.parse(readFileSync(path, "utf8"));
|
|
@@ -200,15 +200,17 @@ function parseJsonFile(path, file) {
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
// src/push/push-from-directory.ts
|
|
203
|
+
var latestVersionSchema = exports_external.object({ version: exports_external.number() });
|
|
203
204
|
async function pushFromDirectory(dir, opts) {
|
|
204
205
|
const log = opts.log ?? ((msg) => {
|
|
205
206
|
console.warn(msg);
|
|
206
207
|
});
|
|
207
208
|
const headers = { Authorization: `Bearer ${opts.accessToken}` };
|
|
208
|
-
const
|
|
209
|
-
const
|
|
210
|
-
const documents =
|
|
211
|
-
|
|
209
|
+
const { steps } = await collectDefinitionsFromDirectory(dir);
|
|
210
|
+
const built = collectBuiltDocuments(dir);
|
|
211
|
+
const documents = built.filter((file) => file.kind === "pipeline");
|
|
212
|
+
const automations = built.filter((file) => file.kind === "automation").sort((a, b) => Number(a.document["scope"] === "project") - Number(b.document["scope"] === "project"));
|
|
213
|
+
log(`Found ${String(steps.length)} step(s), ${String(documents.length)} pipeline document(s) and ${String(automations.length)} automation document(s).`);
|
|
212
214
|
assertValidDefinitionSpecs(steps);
|
|
213
215
|
const stepsClient = createStepDefinitionsClient(opts.baseUrl);
|
|
214
216
|
for (const spec of steps) {
|
|
@@ -226,12 +228,19 @@ async function pushFromDirectory(dir, opts) {
|
|
|
226
228
|
(published ? publishedPipelines : unchangedPipelines).push(document.key);
|
|
227
229
|
}
|
|
228
230
|
}
|
|
229
|
-
const
|
|
231
|
+
const automationsClient = createAutomationsClient(opts.baseUrl);
|
|
232
|
+
const publishedAutomations = [];
|
|
233
|
+
const unchangedAutomations = [];
|
|
234
|
+
for (const document of automations) {
|
|
235
|
+
const published = await publishAutomationDocument(document, opts.projectId, headers, automationsClient, log);
|
|
236
|
+
(published ? publishedAutomations : unchangedAutomations).push(document.key);
|
|
237
|
+
}
|
|
230
238
|
return {
|
|
231
239
|
pushedSteps: steps.length,
|
|
232
240
|
publishedPipelines,
|
|
233
241
|
unchangedPipelines,
|
|
234
|
-
|
|
242
|
+
publishedAutomations,
|
|
243
|
+
unchangedAutomations
|
|
235
244
|
};
|
|
236
245
|
}
|
|
237
246
|
async function publishPipelineDocument({ file, key, title, document }, pipelineDefinitionId, projectId, headers, pipelinesClient, log) {
|
|
@@ -246,80 +255,34 @@ async function publishPipelineDocument({ file, key, title, document }, pipelineD
|
|
|
246
255
|
log(result.published ? `\u2713 pipeline ${key} v${version} \u2192 published (${file})` : `\u2713 pipeline ${key} v${version} \u2192 unchanged (${file})`);
|
|
247
256
|
return result.published;
|
|
248
257
|
} catch (error) {
|
|
249
|
-
|
|
250
|
-
const issues = error.issues.map((issue) => issue.hint === undefined ? ` ${issue.path || "/"}: ${issue.message}` : ` ${issue.path || "/"}: ${issue.message}. ${issue.hint}`);
|
|
251
|
-
throw new Error([`Could not publish ${file}: ${error.message}`, ...issues].join(`
|
|
252
|
-
`), { cause: error });
|
|
253
|
-
}
|
|
254
|
-
throw error;
|
|
258
|
+
rethrowPublishError(file, error);
|
|
255
259
|
}
|
|
256
260
|
}
|
|
257
|
-
async function
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
for (const key of referencedKeys) {
|
|
271
|
-
if (!pipelineKeyToId.has(key)) {
|
|
272
|
-
throw new Error(`${DEFAULT_PIPELINE_ASSIGNMENT_FILENAME} references pipeline "${key}", ` + `but no pipeline with that key was found on the server. ` + `Run \`scarn pipelines build\` to write ${key}.json next to its source, then push again.`);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
const pipelineDefinitionId = pipelineKeyToId.get(serialized.pipelineDefinitionKey);
|
|
276
|
-
if (!pipelineDefinitionId) {
|
|
277
|
-
throw new Error(`Pipeline key "${serialized.pipelineDefinitionKey}" was not found on the server.`);
|
|
261
|
+
async function publishAutomationDocument({ file, key, document }, projectId, headers, automationsClient, log) {
|
|
262
|
+
try {
|
|
263
|
+
const result = await automationsClient.publish(projectId, key, document, {
|
|
264
|
+
headers
|
|
265
|
+
});
|
|
266
|
+
const latest = latestVersionSchema.safeParse(result.automation.latestVersion);
|
|
267
|
+
const version = latest.success ? ` v${String(latest.data.version)}` : "";
|
|
268
|
+
log(result.published ? `\u2713 automation ${key}${version} \u2192 published (${file})` : `\u2713 automation ${key}${version} \u2192 unchanged (${file})`);
|
|
269
|
+
return result.published;
|
|
270
|
+
} catch (error) {
|
|
271
|
+
rethrowPublishError(file, error);
|
|
278
272
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
if (!pId) {
|
|
284
|
-
throw new Error(`${DEFAULT_PIPELINE_ASSIGNMENT_FILENAME} assign() references pipeline "${pKey}" ` + `which was not found on the server.`);
|
|
285
|
-
}
|
|
286
|
-
return {
|
|
287
|
-
...rule,
|
|
288
|
-
event: {
|
|
289
|
-
...rule.event,
|
|
290
|
-
params: {
|
|
291
|
-
...rule.event.params,
|
|
292
|
-
pipelineDefinitionId: pId
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
return rule;
|
|
298
|
-
});
|
|
299
|
-
const projectsClient = new Projects({
|
|
300
|
-
client: createClient({ baseUrl: opts.baseUrl })
|
|
301
|
-
});
|
|
302
|
-
const result = await projectsClient.updateProjectDefaultPipelineAssignment({
|
|
303
|
-
path: { projectId: opts.projectId },
|
|
304
|
-
body: {
|
|
305
|
-
defaultPipelineAssignment: {
|
|
306
|
-
pipelineDefinitionId,
|
|
307
|
-
rulesJson: { rules: resolvedRules },
|
|
308
|
-
defaultEventType: serialized.defaultEventType,
|
|
309
|
-
defaultEventParamsJson: serialized.defaultEventParamsJson,
|
|
310
|
-
allowedEventTypes: serialized.allowedEventTypes
|
|
311
|
-
}
|
|
312
|
-
},
|
|
313
|
-
headers
|
|
314
|
-
});
|
|
315
|
-
if (result.error) {
|
|
316
|
-
throw new Error(`Failed to update project default pipeline assignment: ${JSON.stringify(result.error)}`);
|
|
273
|
+
}
|
|
274
|
+
function rethrowPublishError(file, error) {
|
|
275
|
+
if (!(error instanceof PipelineDefinitionsApiError) && !(error instanceof AutomationsApiError)) {
|
|
276
|
+
throw error;
|
|
317
277
|
}
|
|
318
|
-
|
|
319
|
-
|
|
278
|
+
const issues = error.issues.map((issue) => issue.hint === undefined ? ` ${issue.path || "/"}: ${issue.message}` : ` ${issue.path || "/"}: ${issue.message}. ${issue.hint}`);
|
|
279
|
+
throw new Error([`Could not publish ${file}: ${error.message}`, ...issues].join(`
|
|
280
|
+
`), { cause: error });
|
|
320
281
|
}
|
|
321
282
|
export {
|
|
322
283
|
PIPELINE_BUILDER_DIR,
|
|
284
|
+
collectAutomationDocuments,
|
|
285
|
+
collectBuiltDocuments,
|
|
323
286
|
collectDefinitionsFromDirectory,
|
|
324
287
|
collectDefinitionsFromDirectoryTolerant,
|
|
325
288
|
collectPipelineDocuments,
|
|
@@ -11,22 +11,26 @@ export interface PushFromDirectoryResult {
|
|
|
11
11
|
publishedPipelines: string[];
|
|
12
12
|
/** Keys of the pipelines whose document matched their latest version. */
|
|
13
13
|
unchangedPipelines: string[];
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/** Keys of the automations that got a new version. */
|
|
15
|
+
publishedAutomations: string[];
|
|
16
|
+
/** Keys of the automations whose document matched their latest version. */
|
|
17
|
+
unchangedAutomations: string[];
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Pushes a pipeline-builder directory to the server, in three passes:
|
|
19
21
|
*
|
|
20
22
|
* 1. Upserts every step exported from the `.ts`/`.js` files (except the push
|
|
21
|
-
* script itself
|
|
23
|
+
* script itself).
|
|
22
24
|
* 2. Publishes every built pipeline document (`<key>.json`, from
|
|
23
25
|
* `scarn pipelines build`), creating the pipeline when its key is new.
|
|
24
26
|
* The server pins each document to the steps just pushed; a document
|
|
25
27
|
* identical to its latest version publishes nothing.
|
|
26
|
-
* 3.
|
|
27
|
-
*
|
|
28
|
+
* 3. Publishes every built automation document (`<key>.json` with
|
|
29
|
+
* `kind: "automation"`). Work-item automations go first, since a project
|
|
30
|
+
* automation's `attach` targets must already exist. A new automation starts
|
|
31
|
+
* disabled; deleting a source file unpublishes nothing.
|
|
28
32
|
*
|
|
29
|
-
* Collection (`collectDefinitionsFromDirectory`, `
|
|
33
|
+
* Collection (`collectDefinitionsFromDirectory`, `collectBuiltDocuments`)
|
|
30
34
|
* and step validation (`validateDefinitionSpecs`) are offline and run before
|
|
31
35
|
* the first mutating request, so an invalid batch fails without half-pushing.
|
|
32
36
|
*
|
package/dist/repo-config.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ import { z } from "zod";
|
|
|
7
7
|
* - `readOnly`: clones and checks out the base branch, but creates no work
|
|
8
8
|
* branch, commits nothing and pushes nothing.
|
|
9
9
|
* - `readWrite`: creates a work branch, commits and pushes. `message` is the
|
|
10
|
-
* commit message template (`{{input.…}}
|
|
10
|
+
* commit message template (`{{input.…}}`, `{{result.…}}`,
|
|
11
|
+
* `{{workItem.title}}` and `{{workItem.platformKey}}` tokens only) and
|
|
11
12
|
* `onPushFailure` picks whether a failed push fails the step.
|
|
12
13
|
*
|
|
13
14
|
* Two shapes of the same data. `RepoConfigInput` is what an author or API client
|
|
@@ -21,13 +22,22 @@ import { z } from "zod";
|
|
|
21
22
|
*/
|
|
22
23
|
export declare const MAX_REPO_COMMIT_MESSAGE_LENGTH = 500;
|
|
23
24
|
export declare const REPO_COMMIT_MESSAGE_TOKEN_ROOTS: readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* The only `{{workItem.…}}` paths a commit message may use. The worker fills
|
|
27
|
+
* them from a live read of the Task's work item when it commits.
|
|
28
|
+
*/
|
|
29
|
+
export declare const REPO_COMMIT_MESSAGE_WORK_ITEM_KEYS: readonly string[];
|
|
30
|
+
/** Whether `message` has a `{{workItem.…}}` token. */
|
|
31
|
+
export declare function commitMessageUsesWorkItem(message: string): boolean;
|
|
24
32
|
export type RepoMode = "none" | "readOnly" | "readWrite";
|
|
25
33
|
export type RepoOnPushFailure = "fail" | "warn";
|
|
26
34
|
export type RepoExecutionMode = "workspace" | "no_workspace";
|
|
27
35
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* the
|
|
36
|
+
* Every `{{…}}` token in `message` a commit message may not use, in order of
|
|
37
|
+
* appearance: its root when that is not one of
|
|
38
|
+
* `REPO_COMMIT_MESSAGE_TOKEN_ROOTS`, or the whole path for a `workItem` token
|
|
39
|
+
* other than `REPO_COMMIT_MESSAGE_WORK_ITEM_KEYS`. Tokens are parsed the way
|
|
40
|
+
* `renderPromptTemplate` renders them.
|
|
31
41
|
*/
|
|
32
42
|
export declare function findDisallowedCommitMessageTokenRoots(message: string): string[];
|
|
33
43
|
export declare const repoCommitMessageSchema: z.ZodString;
|
package/dist/repo-config.js
CHANGED
|
@@ -2,20 +2,24 @@
|
|
|
2
2
|
import {
|
|
3
3
|
MAX_REPO_COMMIT_MESSAGE_LENGTH,
|
|
4
4
|
REPO_COMMIT_MESSAGE_TOKEN_ROOTS,
|
|
5
|
+
REPO_COMMIT_MESSAGE_WORK_ITEM_KEYS,
|
|
5
6
|
REPO_RUNTIME_SUPPORT,
|
|
7
|
+
commitMessageUsesWorkItem,
|
|
6
8
|
findDisallowedCommitMessageTokenRoots,
|
|
7
9
|
repoCommitMessageSchema,
|
|
8
10
|
repoConfigInputSchema,
|
|
9
11
|
repoConfigSchema,
|
|
10
12
|
repoRuntimeMismatch,
|
|
11
13
|
resolveRepoConfig
|
|
12
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ejzfdm1z.js";
|
|
13
15
|
import"./chunk-skzxcba3.js";
|
|
14
16
|
import"./chunk-y64skrwp.js";
|
|
15
17
|
export {
|
|
16
18
|
MAX_REPO_COMMIT_MESSAGE_LENGTH,
|
|
17
19
|
REPO_COMMIT_MESSAGE_TOKEN_ROOTS,
|
|
20
|
+
REPO_COMMIT_MESSAGE_WORK_ITEM_KEYS,
|
|
18
21
|
REPO_RUNTIME_SUPPORT,
|
|
22
|
+
commitMessageUsesWorkItem,
|
|
19
23
|
findDisallowedCommitMessageTokenRoots,
|
|
20
24
|
repoCommitMessageSchema,
|
|
21
25
|
repoConfigInputSchema,
|
|
@@ -288,6 +288,7 @@ declare const buildTaskPlaneClient: (taskRuns: TaskRuns) => {
|
|
|
288
288
|
claimToken: string;
|
|
289
289
|
}) => Promise<{
|
|
290
290
|
projectId: string;
|
|
291
|
+
projectPath: string | unknown;
|
|
291
292
|
gitUrl: string;
|
|
292
293
|
baseWorkBranch: string | unknown;
|
|
293
294
|
projectOpencodeConfig: {
|
|
@@ -328,7 +329,37 @@ declare const buildTaskPlaneClient: (taskRuns: TaskRuns) => {
|
|
|
328
329
|
} | unknown;
|
|
329
330
|
turnsRemaining: number | unknown;
|
|
330
331
|
workItemId: string;
|
|
331
|
-
|
|
332
|
+
grants: Array<{
|
|
333
|
+
resource: string;
|
|
334
|
+
action: string;
|
|
335
|
+
scope: "self" | "children";
|
|
336
|
+
} | {
|
|
337
|
+
resource: string;
|
|
338
|
+
action: string;
|
|
339
|
+
scope: "self" | "children";
|
|
340
|
+
} | {
|
|
341
|
+
resource: string;
|
|
342
|
+
action: string;
|
|
343
|
+
scope: "self" | "children";
|
|
344
|
+
} | {
|
|
345
|
+
resource: string;
|
|
346
|
+
action: string;
|
|
347
|
+
scope: "self" | "children";
|
|
348
|
+
labels: Array<string>;
|
|
349
|
+
} | {
|
|
350
|
+
resource: string;
|
|
351
|
+
action: string;
|
|
352
|
+
scope: "self" | "children";
|
|
353
|
+
} | {
|
|
354
|
+
resource: string;
|
|
355
|
+
action: string;
|
|
356
|
+
scope: "self" | "children";
|
|
357
|
+
} | {
|
|
358
|
+
resource: string;
|
|
359
|
+
action: string;
|
|
360
|
+
scope: string;
|
|
361
|
+
labels: Array<string>;
|
|
362
|
+
}>;
|
|
332
363
|
};
|
|
333
364
|
runtime: {
|
|
334
365
|
executionMode: "workspace" | "no_workspace";
|
|
@@ -448,6 +479,45 @@ declare const buildTaskPlaneClient: (taskRuns: TaskRuns) => {
|
|
|
448
479
|
message: string;
|
|
449
480
|
} | unknown;
|
|
450
481
|
}>;
|
|
482
|
+
readTaskRunWorkItem: ({ taskRunId, ...body }: TaskRunRef & {
|
|
483
|
+
claimToken: string;
|
|
484
|
+
workItemId: string;
|
|
485
|
+
}) => Promise<{
|
|
486
|
+
id: string;
|
|
487
|
+
title: string;
|
|
488
|
+
labels: Array<string>;
|
|
489
|
+
description: string | unknown;
|
|
490
|
+
descriptionVersion: number;
|
|
491
|
+
fields: {
|
|
492
|
+
[key: string]: unknown;
|
|
493
|
+
};
|
|
494
|
+
platform: "jira" | "github" | "bitbucket" | "linear" | "scarn" | "custom";
|
|
495
|
+
platformKey: string;
|
|
496
|
+
parentWorkItemId: string | unknown;
|
|
497
|
+
state: "open" | "closed";
|
|
498
|
+
closeReason: "completed" | "out_of_scope" | "superseded" | unknown;
|
|
499
|
+
resolution: string | unknown;
|
|
500
|
+
blockers: Array<{
|
|
501
|
+
id: string;
|
|
502
|
+
title: string;
|
|
503
|
+
state: "open" | "closed";
|
|
504
|
+
labels: Array<string>;
|
|
505
|
+
closeReason: "completed" | "out_of_scope" | "superseded" | unknown;
|
|
506
|
+
resolution: string | unknown;
|
|
507
|
+
blockedBy: Array<string>;
|
|
508
|
+
latestTaskStatus: "waiting_for_concurrency_slot" | "waiting_for_work" | "queued" | "running" | "waiting_for_person" | "succeeded" | "failed" | "cancelled" | unknown;
|
|
509
|
+
}>;
|
|
510
|
+
children: Array<{
|
|
511
|
+
id: string;
|
|
512
|
+
title: string;
|
|
513
|
+
state: "open" | "closed";
|
|
514
|
+
labels: Array<string>;
|
|
515
|
+
closeReason: "completed" | "out_of_scope" | "superseded" | unknown;
|
|
516
|
+
resolution: string | unknown;
|
|
517
|
+
blockedBy: Array<string>;
|
|
518
|
+
latestTaskStatus: "waiting_for_concurrency_slot" | "waiting_for_work" | "queued" | "running" | "waiting_for_person" | "succeeded" | "failed" | "cancelled" | unknown;
|
|
519
|
+
}>;
|
|
520
|
+
}>;
|
|
451
521
|
completeTaskRun: ({ taskRunId, ...body }: TaskRunRef & Omit<CompletionBody, "status">) => Promise<void>;
|
|
452
522
|
failTaskRun: ({ taskRunId, ...body }: TaskRunRef & Omit<CompletionBody, "status" | "workBranch" | "createdFromBranch">) => Promise<void>;
|
|
453
523
|
yieldTaskRun: ({ taskRunId, ...body }: TaskRunRef & PostApiTaskRunsByTaskRunIdYieldsData["body"]) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@scarn/sdk",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -40,10 +40,22 @@
|
|
|
40
40
|
"import": "./dist/definitions/pipelines/index.js",
|
|
41
41
|
"types": "./dist/definitions/pipelines/index.d.ts"
|
|
42
42
|
},
|
|
43
|
+
"./definitions/automations": {
|
|
44
|
+
"import": "./dist/definitions/automations/index.js",
|
|
45
|
+
"types": "./dist/definitions/automations/index.d.ts"
|
|
46
|
+
},
|
|
43
47
|
"./pipelines": {
|
|
44
48
|
"import": "./dist/pipelines/index.js",
|
|
45
49
|
"types": "./dist/pipelines/index.d.ts"
|
|
46
50
|
},
|
|
51
|
+
"./automations": {
|
|
52
|
+
"import": "./dist/automations/index.js",
|
|
53
|
+
"types": "./dist/automations/index.d.ts"
|
|
54
|
+
},
|
|
55
|
+
"./contracts/automation-document": {
|
|
56
|
+
"import": "./dist/contracts/automation-document/index.js",
|
|
57
|
+
"types": "./dist/contracts/automation-document/index.d.ts"
|
|
58
|
+
},
|
|
47
59
|
"./eslint": {
|
|
48
60
|
"import": "./dist/eslint.js",
|
|
49
61
|
"types": "./dist/eslint.d.ts"
|