@scarn/sdk 0.8.19 → 0.8.21
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 +20 -0
- package/dist/automations/index.js +6 -6
- package/dist/{chunk-pqtd0hr7.js → chunk-08gcnrzh.js} +2 -2
- package/dist/{chunk-2tmrw253.js → chunk-0he2dx5n.js} +5 -5
- package/dist/{chunk-aknfw08j.js → chunk-59arcerk.js} +16 -13
- package/dist/{chunk-61jf8b6s.js → chunk-5dny5jg1.js} +11 -1
- package/dist/{chunk-46wmsgv7.js → chunk-5say64w8.js} +1 -1
- package/dist/{chunk-9we3vqsv.js → chunk-6p340dd4.js} +2 -2
- package/dist/{chunk-19brnwkp.js → chunk-8hsk6f6b.js} +1 -1
- package/dist/{chunk-098740f7.js → chunk-8kzaxz52.js} +1 -1
- package/dist/{chunk-mmy80pec.js → chunk-8tmsvkmj.js} +5 -5
- package/dist/{chunk-e0pt5x0e.js → chunk-aph2js2v.js} +5 -5
- package/dist/chunk-azss2d1n.js +1036 -0
- package/dist/{chunk-t1dq2c2s.js → chunk-gasw078g.js} +5 -5
- package/dist/{chunk-0c60x3v8.js → chunk-h1v6w1fh.js} +5 -5
- package/dist/{chunk-tvjcfh6s.js → chunk-k57h6qke.js} +8 -5
- package/dist/{chunk-x0hjhqrf.js → chunk-mp2rqtcj.js} +1 -1
- package/dist/{chunk-aemxz9r7.js → chunk-mrzn5tq4.js} +1 -1
- package/dist/{chunk-qgkx89eg.js → chunk-nkm31g10.js} +3 -3
- package/dist/{chunk-833ef6dg.js → chunk-p74r4y6j.js} +14 -14
- package/dist/{chunk-p1fs73bd.js → chunk-pwyj6qf3.js} +2 -2
- package/dist/{chunk-evb3hw48.js → chunk-qt81x1pm.js} +7 -4
- package/dist/{chunk-mzj1j0p5.js → chunk-r3sbp2wn.js} +3 -3
- package/dist/{chunk-rphfy0fj.js → chunk-vsp708vw.js} +1 -1
- package/dist/{chunk-yf15kdte.js → chunk-xhpp6qz8.js} +96 -96
- package/dist/{chunk-jj9pezwb.js → chunk-xqfj56m9.js} +43 -3
- package/dist/{chunk-y34zsgsw.js → chunk-y7ac1t9c.js} +1 -1
- package/dist/{chunk-3zp2qtf8.js → chunk-y81cr6tp.js} +38 -14
- package/dist/{chunk-ymywp5ht.js → chunk-zxzvketc.js} +5 -5
- package/dist/client.d.ts +5 -1
- package/dist/client.js +2 -2
- package/dist/connectors/index.js +4 -4
- package/dist/contracts/artifacts.js +2 -2
- package/dist/contracts/automation-document/index.js +3 -3
- package/dist/contracts/pipeline-document/index.js +5 -3
- package/dist/contracts/pipeline-document/routes.d.ts +9 -0
- package/dist/contracts/pipeline-document/schema.d.ts +40 -1
- package/dist/contracts/step-artifact-submissions.js +2 -2
- package/dist/contracts/work-item-changes.js +1 -1
- package/dist/create-api-client.d.ts +11 -0
- package/dist/defaults/index.js +32 -871
- 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 +3 -3
- package/dist/definitions/environments/environments-client.d.ts +2 -1
- package/dist/definitions/environments/index.js +10 -10
- package/dist/definitions/pipelines/index.js +3 -3
- package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +2 -1
- package/dist/definitions/steps/index.js +14 -14
- package/dist/definitions/steps/step-definitions-client.d.ts +2 -1
- package/dist/definitions/validation/index.js +10 -10
- package/dist/devcontainer-config-path.js +2 -2
- package/dist/env-vars.js +2 -2
- package/dist/environment.js +7 -7
- package/dist/generated/index.d.ts +1 -1
- package/dist/generated/sdk.gen.d.ts +5 -1
- package/dist/generated/types.gen.d.ts +298 -0
- package/dist/health-checks.js +2 -2
- package/dist/index.js +23 -23
- package/dist/managed-runtimes.js +2 -2
- package/dist/opencode-mcp.js +3 -3
- package/dist/pipelines/index.d.ts +1 -1
- package/dist/pipelines/index.js +6 -6
- package/dist/pipelines/model.d.ts +10 -4
- package/dist/pipelines/types.d.ts +13 -1
- package/dist/push/index.js +43 -42
- package/dist/push/push-from-directory.d.ts +6 -1
- package/dist/repo-config.js +2 -2
- package/dist/resolve-environment.js +8 -8
- package/dist/task-plane-client.d.ts +6 -0
- package/package.json +6 -2
package/dist/push/index.js
CHANGED
|
@@ -2,46 +2,46 @@
|
|
|
2
2
|
import {
|
|
3
3
|
EnvironmentsApiError,
|
|
4
4
|
createEnvironmentsClient
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-8tmsvkmj.js";
|
|
6
6
|
import {
|
|
7
7
|
AutomationsApiError,
|
|
8
8
|
createAutomationsClient
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-0he2dx5n.js";
|
|
10
10
|
import {
|
|
11
11
|
assertValidDefinitionSpecs
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-h1v6w1fh.js";
|
|
13
13
|
import {
|
|
14
14
|
PipelineDefinitionsApiError,
|
|
15
15
|
createPipelineDefinitionsClient
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-zxzvketc.js";
|
|
17
17
|
import {
|
|
18
18
|
createStepDefinitionsClient,
|
|
19
19
|
stepEnvironmentHandle,
|
|
20
20
|
toStepSpec
|
|
21
|
-
} from "../chunk-
|
|
22
|
-
import"../chunk-
|
|
23
|
-
import"../chunk-
|
|
21
|
+
} from "../chunk-p74r4y6j.js";
|
|
22
|
+
import"../chunk-y7ac1t9c.js";
|
|
23
|
+
import"../chunk-gasw078g.js";
|
|
24
24
|
import {
|
|
25
25
|
isEnvironmentHandle,
|
|
26
26
|
isStepDefinitionSpec,
|
|
27
27
|
stepsInModule
|
|
28
28
|
} from "../chunk-6tra3gw8.js";
|
|
29
|
-
import"../chunk-
|
|
29
|
+
import"../chunk-xqfj56m9.js";
|
|
30
30
|
import"../chunk-y11p1q7r.js";
|
|
31
|
-
import"../chunk-
|
|
32
|
-
import"../chunk-
|
|
33
|
-
import"../chunk-
|
|
34
|
-
import"../chunk-
|
|
35
|
-
import"../chunk-
|
|
36
|
-
import"../chunk-
|
|
37
|
-
import"../chunk-
|
|
38
|
-
import"../chunk-
|
|
31
|
+
import"../chunk-vsp708vw.js";
|
|
32
|
+
import"../chunk-aph2js2v.js";
|
|
33
|
+
import"../chunk-8kzaxz52.js";
|
|
34
|
+
import"../chunk-5say64w8.js";
|
|
35
|
+
import"../chunk-nkm31g10.js";
|
|
36
|
+
import"../chunk-08gcnrzh.js";
|
|
37
|
+
import"../chunk-mrzn5tq4.js";
|
|
38
|
+
import"../chunk-y81cr6tp.js";
|
|
39
39
|
import"../chunk-ngy1fdcx.js";
|
|
40
|
-
import"../chunk-
|
|
40
|
+
import"../chunk-8hsk6f6b.js";
|
|
41
41
|
import"../chunk-01nfqm18.js";
|
|
42
42
|
import {
|
|
43
43
|
exports_external
|
|
44
|
-
} from "../chunk-
|
|
44
|
+
} from "../chunk-xhpp6qz8.js";
|
|
45
45
|
import"../chunk-y64skrwp.js";
|
|
46
46
|
|
|
47
47
|
// src/push/collect-definitions.ts
|
|
@@ -261,42 +261,42 @@ async function pushFromDirectory(dir, opts) {
|
|
|
261
261
|
const log = opts.log ?? ((msg) => {
|
|
262
262
|
console.warn(msg);
|
|
263
263
|
});
|
|
264
|
-
const
|
|
264
|
+
const clientOptions = { fetch: opts.fetch };
|
|
265
265
|
const { steps, environments } = await collectDefinitionsFromDirectory(dir);
|
|
266
266
|
const built = collectBuiltDocuments(dir);
|
|
267
267
|
const documents = built.filter((file) => file.kind === "pipeline");
|
|
268
268
|
const automations = built.filter((file) => file.kind === "automation").sort((a, b) => Number(a.document["scope"] === "project") - Number(b.document["scope"] === "project"));
|
|
269
269
|
log(`Found ${String(environments.length)} environment(s), ${String(steps.length)} step(s), ${String(documents.length)} pipeline document(s) and ${String(automations.length)} automation document(s).`);
|
|
270
270
|
assertValidDefinitionSpecs(steps);
|
|
271
|
-
const environmentsClient = createEnvironmentsClient(opts.baseUrl);
|
|
272
|
-
await assertNamedEnvironmentsExist(steps, environments, opts.projectId,
|
|
271
|
+
const environmentsClient = createEnvironmentsClient(opts.baseUrl, clientOptions);
|
|
272
|
+
await assertNamedEnvironmentsExist(steps, environments, opts.projectId, environmentsClient);
|
|
273
273
|
const publishedEnvironments = [];
|
|
274
274
|
const unchangedEnvironments = [];
|
|
275
275
|
for (const environment of environments) {
|
|
276
|
-
const published = await publishEnvironment(environment, opts.projectId,
|
|
276
|
+
const published = await publishEnvironment(environment, opts.projectId, environmentsClient, log);
|
|
277
277
|
(published ? publishedEnvironments : unchangedEnvironments).push(environment.name);
|
|
278
278
|
}
|
|
279
|
-
const stepsClient = createStepDefinitionsClient(opts.baseUrl);
|
|
279
|
+
const stepsClient = createStepDefinitionsClient(opts.baseUrl, clientOptions);
|
|
280
280
|
for (const spec of steps) {
|
|
281
|
-
await stepsClient.upsertFromSpec(opts.projectId, spec
|
|
281
|
+
await stepsClient.upsertFromSpec(opts.projectId, spec);
|
|
282
282
|
log(`\u2713 step ${spec.key} v${String(spec.version)} \u2192 upserted`);
|
|
283
283
|
}
|
|
284
|
-
const pipelinesClient = createPipelineDefinitionsClient(opts.baseUrl);
|
|
284
|
+
const pipelinesClient = createPipelineDefinitionsClient(opts.baseUrl, clientOptions);
|
|
285
285
|
const publishedPipelines = [];
|
|
286
286
|
const unchangedPipelines = [];
|
|
287
287
|
if (documents.length > 0) {
|
|
288
|
-
const serverPipelines = await pipelinesClient.listByProjectId(opts.projectId
|
|
288
|
+
const serverPipelines = await pipelinesClient.listByProjectId(opts.projectId);
|
|
289
289
|
const idByKey = new Map(serverPipelines.map((p) => [p.key, p.id]));
|
|
290
290
|
for (const document of documents) {
|
|
291
|
-
const published = await publishPipelineDocument(document, idByKey.get(document.key), opts.projectId,
|
|
291
|
+
const published = await publishPipelineDocument(document, idByKey.get(document.key), opts.projectId, pipelinesClient, log);
|
|
292
292
|
(published ? publishedPipelines : unchangedPipelines).push(document.key);
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
const automationsClient = createAutomationsClient(opts.baseUrl);
|
|
295
|
+
const automationsClient = createAutomationsClient(opts.baseUrl, clientOptions);
|
|
296
296
|
const publishedAutomations = [];
|
|
297
297
|
const unchangedAutomations = [];
|
|
298
298
|
for (const document of automations) {
|
|
299
|
-
const published = await publishAutomationDocument(document, opts.projectId,
|
|
299
|
+
const published = await publishAutomationDocument(document, opts.projectId, automationsClient, log);
|
|
300
300
|
(published ? publishedAutomations : unchangedAutomations).push(document.key);
|
|
301
301
|
}
|
|
302
302
|
return {
|
|
@@ -309,7 +309,7 @@ async function pushFromDirectory(dir, opts) {
|
|
|
309
309
|
unchangedAutomations
|
|
310
310
|
};
|
|
311
311
|
}
|
|
312
|
-
async function assertNamedEnvironmentsExist(steps, environments, projectId,
|
|
312
|
+
async function assertNamedEnvironmentsExist(steps, environments, projectId, environmentsClient) {
|
|
313
313
|
const local = new Set(environments.map((environment) => environment.name));
|
|
314
314
|
const stepsByMissingName = new Map;
|
|
315
315
|
for (const step of steps) {
|
|
@@ -325,7 +325,7 @@ async function assertNamedEnvironmentsExist(steps, environments, projectId, head
|
|
|
325
325
|
}
|
|
326
326
|
if (stepsByMissingName.size === 0)
|
|
327
327
|
return;
|
|
328
|
-
const onServer = new Set((await environmentsClient.listByProjectId(projectId
|
|
328
|
+
const onServer = new Set((await environmentsClient.listByProjectId(projectId)).map((environment) => environment.name));
|
|
329
329
|
const unknown = [...stepsByMissingName].filter(([name]) => !onServer.has(name));
|
|
330
330
|
if (unknown.length === 0)
|
|
331
331
|
return;
|
|
@@ -336,11 +336,9 @@ async function assertNamedEnvironmentsExist(steps, environments, projectId, head
|
|
|
336
336
|
].join(`
|
|
337
337
|
`));
|
|
338
338
|
}
|
|
339
|
-
async function publishEnvironment({ name, content, sourceFile }, projectId,
|
|
339
|
+
async function publishEnvironment({ name, content, sourceFile }, projectId, environmentsClient, log) {
|
|
340
340
|
try {
|
|
341
|
-
const result = await environmentsClient.publish(projectId, name, content
|
|
342
|
-
headers
|
|
343
|
-
});
|
|
341
|
+
const result = await environmentsClient.publish(projectId, name, content);
|
|
344
342
|
const version = String(result.version.version);
|
|
345
343
|
log(result.published ? `\u2713 environment ${name} v${version} \u2192 published (${sourceFile})` : `\u2713 environment ${name} v${version} \u2192 unchanged (${sourceFile})`);
|
|
346
344
|
return result.published;
|
|
@@ -355,14 +353,19 @@ async function publishEnvironment({ name, content, sourceFile }, projectId, head
|
|
|
355
353
|
`), { cause: error });
|
|
356
354
|
}
|
|
357
355
|
}
|
|
358
|
-
async function publishPipelineDocument({ file, key, title, document }, pipelineDefinitionId, projectId,
|
|
356
|
+
async function publishPipelineDocument({ file, key, title, document }, pipelineDefinitionId, projectId, pipelinesClient, log) {
|
|
359
357
|
try {
|
|
360
358
|
if (pipelineDefinitionId === undefined) {
|
|
361
|
-
await pipelinesClient.create({
|
|
359
|
+
await pipelinesClient.create({
|
|
360
|
+
projectId,
|
|
361
|
+
key,
|
|
362
|
+
name: title ?? key,
|
|
363
|
+
document
|
|
364
|
+
});
|
|
362
365
|
log(`\u2713 pipeline ${key} \u2192 created and published (${file})`);
|
|
363
366
|
return true;
|
|
364
367
|
}
|
|
365
|
-
const result = await pipelinesClient.publishVersion(pipelineDefinitionId, document
|
|
368
|
+
const result = await pipelinesClient.publishVersion(pipelineDefinitionId, document);
|
|
366
369
|
const version = String(result.version.version);
|
|
367
370
|
log(result.published ? `\u2713 pipeline ${key} v${version} \u2192 published (${file})` : `\u2713 pipeline ${key} v${version} \u2192 unchanged (${file})`);
|
|
368
371
|
return result.published;
|
|
@@ -370,11 +373,9 @@ async function publishPipelineDocument({ file, key, title, document }, pipelineD
|
|
|
370
373
|
rethrowPublishError(file, error);
|
|
371
374
|
}
|
|
372
375
|
}
|
|
373
|
-
async function publishAutomationDocument({ file, key, document }, projectId,
|
|
376
|
+
async function publishAutomationDocument({ file, key, document }, projectId, automationsClient, log) {
|
|
374
377
|
try {
|
|
375
|
-
const result = await automationsClient.publish(projectId, key, document
|
|
376
|
-
headers
|
|
377
|
-
});
|
|
378
|
+
const result = await automationsClient.publish(projectId, key, document);
|
|
378
379
|
const latest = latestVersionSchema.safeParse(result.automation.latestVersion);
|
|
379
380
|
const version = latest.success ? ` v${String(latest.data.version)}` : "";
|
|
380
381
|
log(result.published ? `\u2713 automation ${key}${version} \u2192 published (${file})` : `\u2713 automation ${key}${version} \u2192 unchanged (${file})`);
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import type { FetchLike } from "../auth";
|
|
1
2
|
export interface PushFromDirectoryOptions {
|
|
2
3
|
baseUrl: string;
|
|
3
4
|
projectId: string;
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Authenticates every request, e.g. the `fetch` from `loadPushDefaults` or
|
|
7
|
+
* one from `createAuthenticatedFetch`.
|
|
8
|
+
*/
|
|
9
|
+
fetch: FetchLike;
|
|
5
10
|
/** Override the logger; defaults to console.log. */
|
|
6
11
|
log?: (message: string) => void;
|
|
7
12
|
}
|
package/dist/repo-config.js
CHANGED
|
@@ -20,8 +20,8 @@ import {
|
|
|
20
20
|
repoGitCredentialsSchema,
|
|
21
21
|
repoWorkBranchSchema,
|
|
22
22
|
resolveRepoConfig
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import"./chunk-
|
|
23
|
+
} from "./chunk-vsp708vw.js";
|
|
24
|
+
import"./chunk-xhpp6qz8.js";
|
|
25
25
|
import"./chunk-y64skrwp.js";
|
|
26
26
|
export {
|
|
27
27
|
MAX_REPO_BASE_BRANCH_LENGTH,
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
readEnvironmentDefinition,
|
|
4
4
|
resolveEnvironment,
|
|
5
5
|
resolveEnvironmentDefinition
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import"./chunk-
|
|
8
|
-
import"./chunk-
|
|
9
|
-
import"./chunk-
|
|
10
|
-
import"./chunk-
|
|
11
|
-
import"./chunk-
|
|
12
|
-
import"./chunk-
|
|
13
|
-
import"./chunk-
|
|
6
|
+
} from "./chunk-r3sbp2wn.js";
|
|
7
|
+
import"./chunk-aph2js2v.js";
|
|
8
|
+
import"./chunk-8kzaxz52.js";
|
|
9
|
+
import"./chunk-5say64w8.js";
|
|
10
|
+
import"./chunk-nkm31g10.js";
|
|
11
|
+
import"./chunk-08gcnrzh.js";
|
|
12
|
+
import"./chunk-mrzn5tq4.js";
|
|
13
|
+
import"./chunk-xhpp6qz8.js";
|
|
14
14
|
import"./chunk-y64skrwp.js";
|
|
15
15
|
export {
|
|
16
16
|
readEnvironmentDefinition,
|
|
@@ -13,6 +13,12 @@ export type TaskPlaneClientOptions = {
|
|
|
13
13
|
requestHeaders?: (() => Promise<Record<string, string>> | Record<string, string>) | undefined;
|
|
14
14
|
/** Sees every response before it is parsed; throwing fails the call. */
|
|
15
15
|
onResponse?: ((response: Response) => Promise<void> | void) | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Replaces `fetch` for every request, e.g. one from `createAuthenticatedFetch`.
|
|
18
|
+
* An error it throws (a failed token mint, a network error) fails the call
|
|
19
|
+
* as is.
|
|
20
|
+
*/
|
|
21
|
+
fetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined;
|
|
16
22
|
};
|
|
17
23
|
/**
|
|
18
24
|
* Worker-facing client for the task-run plane (`/api/task-runs/...`): claiming,
|
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.21",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -72,6 +72,10 @@
|
|
|
72
72
|
"import": "./dist/defaults/index.js",
|
|
73
73
|
"types": "./dist/defaults/index.d.ts"
|
|
74
74
|
},
|
|
75
|
+
"./auth": {
|
|
76
|
+
"import": "./dist/auth/index.js",
|
|
77
|
+
"types": "./dist/auth/index.d.ts"
|
|
78
|
+
},
|
|
75
79
|
"./push": {
|
|
76
80
|
"import": "./dist/push/index.js",
|
|
77
81
|
"types": "./dist/push/index.d.ts"
|
|
@@ -161,6 +165,6 @@
|
|
|
161
165
|
"@hey-api/openapi-ts": "^0.90.10",
|
|
162
166
|
"@opencode/client": "2.1.4",
|
|
163
167
|
"bun-types": "^1.4.0",
|
|
164
|
-
"zod": "^4.
|
|
168
|
+
"zod": "^4.6.7"
|
|
165
169
|
}
|
|
166
170
|
}
|