@xeonr/pipelines-sdk 0.2.0 → 0.4.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/README.md +231 -22
- package/dist/auth.d.ts +1 -1
- package/dist/client.d.ts +73 -10
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +47 -4
- package/dist/client.js.map +1 -1
- package/dist/gen/xeonr/pipelines/private/v1/attempt_pb.d.ts +179 -16
- package/dist/gen/xeonr/pipelines/private/v1/attempt_pb.d.ts.map +1 -1
- package/dist/gen/xeonr/pipelines/private/v1/attempt_pb.js +45 -28
- package/dist/gen/xeonr/pipelines/private/v1/attempt_pb.js.map +1 -1
- package/dist/gen/xeonr/pipelines/private/v1/step_local_pb.d.ts +136 -17
- package/dist/gen/xeonr/pipelines/private/v1/step_local_pb.d.ts.map +1 -1
- package/dist/gen/xeonr/pipelines/private/v1/step_local_pb.js +42 -35
- package/dist/gen/xeonr/pipelines/private/v1/step_local_pb.js.map +1 -1
- package/dist/gen/xeonr/pipelines/private/v1/worker_pb.d.ts +224 -8
- package/dist/gen/xeonr/pipelines/private/v1/worker_pb.d.ts.map +1 -1
- package/dist/gen/xeonr/pipelines/private/v1/worker_pb.js +43 -9
- package/dist/gen/xeonr/pipelines/private/v1/worker_pb.js.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/common_pb.d.ts +64 -8
- package/dist/gen/xeonr/pipelines/v1/common_pb.d.ts.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/common_pb.js +62 -5
- package/dist/gen/xeonr/pipelines/v1/common_pb.js.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/definition_pb.d.ts +312 -9
- package/dist/gen/xeonr/pipelines/v1/definition_pb.d.ts.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/definition_pb.js +100 -7
- package/dist/gen/xeonr/pipelines/v1/definition_pb.js.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/pipelines_pb.d.ts +1072 -0
- package/dist/gen/xeonr/pipelines/v1/pipelines_pb.d.ts.map +1 -0
- package/dist/gen/xeonr/pipelines/v1/pipelines_pb.js +299 -0
- package/dist/gen/xeonr/pipelines/v1/pipelines_pb.js.map +1 -0
- package/dist/gen/xeonr/pipelines/v1/pools_pb.d.ts +103 -8
- package/dist/gen/xeonr/pipelines/v1/pools_pb.d.ts.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/pools_pb.js +32 -24
- package/dist/gen/xeonr/pipelines/v1/pools_pb.js.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/queues_pb.d.ts +711 -0
- package/dist/gen/xeonr/pipelines/v1/queues_pb.d.ts.map +1 -0
- package/dist/gen/xeonr/pipelines/v1/queues_pb.js +185 -0
- package/dist/gen/xeonr/pipelines/v1/queues_pb.js.map +1 -0
- package/dist/gen/xeonr/pipelines/v1/registry_pb.d.ts +92 -23
- package/dist/gen/xeonr/pipelines/v1/registry_pb.d.ts.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/registry_pb.js +36 -33
- package/dist/gen/xeonr/pipelines/v1/registry_pb.js.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/runs_pb.d.ts +1191 -33
- package/dist/gen/xeonr/pipelines/v1/runs_pb.d.ts.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/runs_pb.js +419 -35
- package/dist/gen/xeonr/pipelines/v1/runs_pb.js.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/schedule_targets_pb.d.ts +194 -0
- package/dist/gen/xeonr/pipelines/v1/schedule_targets_pb.d.ts.map +1 -0
- package/dist/gen/xeonr/pipelines/v1/schedule_targets_pb.js +100 -0
- package/dist/gen/xeonr/pipelines/v1/schedule_targets_pb.js.map +1 -0
- package/dist/gen/xeonr/pipelines/v1/schedules_pb.d.ts +1186 -0
- package/dist/gen/xeonr/pipelines/v1/schedules_pb.d.ts.map +1 -0
- package/dist/gen/xeonr/pipelines/v1/schedules_pb.js +335 -0
- package/dist/gen/xeonr/pipelines/v1/schedules_pb.js.map +1 -0
- package/dist/gen/xeonr/pipelines/v1/secrets_pb.d.ts +32 -5
- package/dist/gen/xeonr/pipelines/v1/secrets_pb.d.ts.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/secrets_pb.js +12 -3
- package/dist/gen/xeonr/pipelines/v1/secrets_pb.js.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/sinks_pb.d.ts +270 -27
- package/dist/gen/xeonr/pipelines/v1/sinks_pb.d.ts.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/sinks_pb.js +163 -24
- package/dist/gen/xeonr/pipelines/v1/sinks_pb.js.map +1 -1
- package/dist/gen/xeonr/pipelines/v1/tenant_policies_pb.d.ts +391 -0
- package/dist/gen/xeonr/pipelines/v1/tenant_policies_pb.d.ts.map +1 -0
- package/dist/gen/xeonr/pipelines/v1/tenant_policies_pb.js +100 -0
- package/dist/gen/xeonr/pipelines/v1/tenant_policies_pb.js.map +1 -0
- package/dist/gen/xeonr/platform/v1/options_pb.d.ts +137 -1
- package/dist/gen/xeonr/platform/v1/options_pb.d.ts.map +1 -1
- package/dist/gen/xeonr/platform/v1/options_pb.js +104 -1
- package/dist/gen/xeonr/platform/v1/options_pb.js.map +1 -1
- package/dist/handler.d.ts +51 -1
- package/dist/handler.d.ts.map +1 -1
- package/dist/handler.js +27 -0
- package/dist/handler.js.map +1 -1
- package/dist/index.d.ts +13 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/queues.d.ts +158 -0
- package/dist/queues.d.ts.map +1 -0
- package/dist/queues.js +117 -0
- package/dist/queues.js.map +1 -0
- package/dist/reporter.d.ts +120 -0
- package/dist/reporter.d.ts.map +1 -0
- package/dist/reporter.js +323 -0
- package/dist/reporter.js.map +1 -0
- package/dist/schedules.d.ts +193 -0
- package/dist/schedules.d.ts.map +1 -0
- package/dist/schedules.js +126 -0
- package/dist/schedules.js.map +1 -0
- package/dist/testing/cron.d.ts +33 -0
- package/dist/testing/cron.d.ts.map +1 -0
- package/dist/testing/cron.js +177 -0
- package/dist/testing/cron.js.map +1 -0
- package/dist/testing/index.d.ts +229 -7
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1304 -103
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/pipelines.d.ts +99 -0
- package/dist/testing/pipelines.d.ts.map +1 -0
- package/dist/testing/pipelines.js +445 -0
- package/dist/testing/pipelines.js.map +1 -0
- package/dist/testing/queues.d.ts +49 -0
- package/dist/testing/queues.d.ts.map +1 -0
- package/dist/testing/queues.js +72 -0
- package/dist/testing/queues.js.map +1 -0
- package/dist/testing/schedules.d.ts +125 -0
- package/dist/testing/schedules.d.ts.map +1 -0
- package/dist/testing/schedules.js +422 -0
- package/dist/testing/schedules.js.map +1 -0
- package/dist/worker.d.ts +48 -7
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +59 -9
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,13 +4,20 @@ The TypeScript SDK for xeonr pipelines (Trellis PIPE-5). It does two things:
|
|
|
4
4
|
|
|
5
5
|
- **Client**: start runs and enqueue jobs on the public API (`CreateRun`,
|
|
6
6
|
`CreateJob`), read them and cancel them.
|
|
7
|
-
- **Worker**: run your
|
|
7
|
+
- **Worker**: run your service's handlers inside your own Node.js process.
|
|
8
8
|
The worker claims your handlers' attempts from pipelines-api, and the
|
|
9
9
|
platform handles retries, delays, timeouts, leases, cancel, logs and the
|
|
10
10
|
console. You run no runner, no image and no container-platform.
|
|
11
11
|
|
|
12
12
|
This is not the step SDK (`@xeonr/runner-sdk`, `defineStep` inside an image).
|
|
13
13
|
|
|
14
|
+
Pipelines is a platform service for consuming services; end users never use
|
|
15
|
+
it. A **tenant** is a consuming service: the one platform team it runs all of
|
|
16
|
+
its pipelines under (the forge's is team `forge`). The SDK calls as that
|
|
17
|
+
service's Auth service account, a member of the tenant's team, and every write
|
|
18
|
+
(jobs, runs, queues, schedules, pools, packages) is for a tenant the service
|
|
19
|
+
account is a member of.
|
|
20
|
+
|
|
14
21
|
**Runtime:** Node.js 20, 22 and 24, ESM only. CI runs on 24. The smoke test of
|
|
15
22
|
the built package also passes on 20 and 22.
|
|
16
23
|
|
|
@@ -22,7 +29,7 @@ pnpm add @xeonr/pipelines-sdk @bufbuild/protobuf @connectrpc/connect
|
|
|
22
29
|
|
|
23
30
|
## Auth
|
|
24
31
|
|
|
25
|
-
Calls carry an Auth access token for your
|
|
32
|
+
Calls carry an Auth access token for your service's service account. The
|
|
26
33
|
token comes from the `jwt-bearer` grant (`auth.service-to-service`), the same
|
|
27
34
|
exchange as go-platform's `authn.NewTokenSource`. `jwtBearer` caches the token
|
|
28
35
|
and refreshes it single-flight, 30 s before it expires. If a refresh fails
|
|
@@ -124,7 +131,7 @@ Pass `register: false` and `pool.id` if something else does that.
|
|
|
124
131
|
| Still running at its deadline | `TIMED_OUT` | `TIMEOUT` |
|
|
125
132
|
| Stopped after a cancel | `CANCELLED` | `CANCELLED` |
|
|
126
133
|
| Aborted by `stop()` past its timeout | `INTERRUPTED` | `INTERRUPTED` |
|
|
127
|
-
| Lease lost | nothing reported | `ABANDONED`, decided by the platform |
|
|
134
|
+
| Lease lost | nothing reported | `ABANDONED`, decided by the platform; run again automatically only on an `interruptible` node or job |
|
|
128
135
|
|
|
129
136
|
The platform picks the failure class and decides whether to retry, using the
|
|
130
137
|
node's `retry.when`. By default it retries only transient classes:
|
|
@@ -189,6 +196,128 @@ The worker reads each error by its Connect code (`errorKind`):
|
|
|
189
196
|
default. On a node marked `interruptible`, the retry does not count
|
|
190
197
|
against `retry.max`.
|
|
191
198
|
|
|
199
|
+
### Stages, progress, issues and spans
|
|
200
|
+
|
|
201
|
+
A handler can tell the console how far it has got, and what went wrong with
|
|
202
|
+
individual items, without failing:
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
export const scanLibrary = defineHandler<{ libraryId: string }>({
|
|
206
|
+
name: "acme/scan-library",
|
|
207
|
+
version: "2.0.0",
|
|
208
|
+
title: "Scan library",
|
|
209
|
+
// Published in the manifest, so a console draws every stage before the attempt starts.
|
|
210
|
+
stages: [
|
|
211
|
+
{ key: "read", name: "Reading folders" },
|
|
212
|
+
{ key: "probe", name: "Probing files", weight: 4 }, // dominates the overall bar
|
|
213
|
+
],
|
|
214
|
+
async run(ctx) {
|
|
215
|
+
ctx.stage("read");
|
|
216
|
+
const files = await listFiles(ctx.input.libraryId);
|
|
217
|
+
ctx.stage("probe"); // finishes "read"
|
|
218
|
+
for (const [i, f] of files.entries()) {
|
|
219
|
+
await ctx.span("probe", async (span) => {
|
|
220
|
+
span.setAttribute("file", f.path);
|
|
221
|
+
try {
|
|
222
|
+
await probe(f);
|
|
223
|
+
} catch (err) {
|
|
224
|
+
ctx.issue({ severity: "warning", subject: f.path, subjectKind: "media.file", subjectId: f.id, message: `${f.path} could not be probed` });
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
ctx.progress({ processed: i + 1, total: files.length });
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
- **`ctx.stage(key)`** enters a stage and finishes the one before it. The
|
|
234
|
+
last stage is finished as `SUCCEEDED` when the handler returns, or
|
|
235
|
+
`FAILED` when it fails. A key the handler does not declare is added at run
|
|
236
|
+
time with weight 0. The calls are `WorkerService.SetProgress` with `stage`.
|
|
237
|
+
- **`ctx.progress({ processed, total, failed, fraction, message })`** is
|
|
238
|
+
coalesced: the latest value about once a second (`reportIntervalMs`), and
|
|
239
|
+
a forced final report before the attempt completes.
|
|
240
|
+
- **`ctx.issue({ severity, subject, subjectKind, subjectId, message, detail })`**
|
|
241
|
+
is batched, up to 100 per `AppendIssues`. The run carries the counts by
|
|
242
|
+
severity, and `client.listIssues(runId)` reads them.
|
|
243
|
+
- **`ctx.span(name, fn, attributes?)`** records an OpenTelemetry-shaped span
|
|
244
|
+
of the attempt's trace (`ReportSpans`). Spans nest with `span.span(...)`,
|
|
245
|
+
and a throw marks a span `error`. `client.getRunTrace(runId)` reads the
|
|
246
|
+
whole trace.
|
|
247
|
+
|
|
248
|
+
None of this can fail a handler. Every error sending progress, issues or
|
|
249
|
+
spans is logged at debug and dropped.
|
|
250
|
+
|
|
251
|
+
## Queues
|
|
252
|
+
|
|
253
|
+
Jobs are admitted through queues: each belongs to one tenant, with limits and
|
|
254
|
+
fairness between the tenant's lanes (its jobs' fairness keys). A queue is not
|
|
255
|
+
where work runs; pools and workers are. A job with no `queue` goes to the
|
|
256
|
+
tenant's `default` queue, which has no limits until the tenant sets one.
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
const worker = new Worker({
|
|
260
|
+
baseUrl, token, tenant: TEAM, pool: { name: "acme-app" },
|
|
261
|
+
// Declared at start with SetQueue, every writable field replaced; a pause survives.
|
|
262
|
+
queues: [
|
|
263
|
+
{ name: "emails", maxConcurrency: 20, maxConcurrencyPerTenant: 5, rateLimit: { limit: 100, windowMs: 60_000 } },
|
|
264
|
+
{ name: "imports", maxConcurrency: 2, defaultRetry: { max: 3, when: [FailureClass.HANDLER_ERROR] }, defaultTimeoutMs: 30 * 60_000 },
|
|
265
|
+
],
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
await pipelines.createJob({ tenant: TEAM, handler: "acme/send-email", idempotencyKey: "welcome:4821", queue: "emails" });
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
- An unknown queue name is `not_found`. A `retry` or `timeoutMs` over the
|
|
272
|
+
queue's `defaultRetry` / `defaultTimeoutMs` is `invalid_argument`. When
|
|
273
|
+
unset, the queue's defaults apply.
|
|
274
|
+
- **`QueuesClient`** has `setQueue`, `getQueue`, `listQueues`, `pauseQueue`,
|
|
275
|
+
`resumeQueue`, `getQueueStats`, `listQueueJobs`, `deleteQueue` and
|
|
276
|
+
`requeueJob`. `declareQueues(client, decls)` is the helper the worker uses.
|
|
277
|
+
A `QueuesClient` is for one tenant (`new QueuesClient({ baseUrl, token,
|
|
278
|
+
tenant })`); the worker declares its queues for its own `tenant`.
|
|
279
|
+
- **Dead letters.** `listQueueJobs(id, { states: [RunState.FAILED] })` lists
|
|
280
|
+
them, and `requeueJob(runId)` (`RetryNode` on node `job`) offers one again on
|
|
281
|
+
its queue.
|
|
282
|
+
- **Fairness.** The next claim goes to the eligible lane (no fairness key, or
|
|
283
|
+
one key) with the fewest running attempts in the queue; ties go to the
|
|
284
|
+
longest-waiting job. `maxConcurrencyPerTenant` caps each lane.
|
|
285
|
+
|
|
286
|
+
`createJob` also takes `interruptible: true` for a handler that is safe to
|
|
287
|
+
run again from the start. A worker shutting down then spends no retry on it,
|
|
288
|
+
and a worker that vanished (`ABANDONED`) gets it run again. The platform
|
|
289
|
+
re-runs an abandoned attempt only for an interruptible node.
|
|
290
|
+
|
|
291
|
+
## Schedules
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
const worker = new Worker({
|
|
295
|
+
baseUrl, token, tenant: TEAM, pool: { name: "acme-app" },
|
|
296
|
+
schedules: [
|
|
297
|
+
// Each occurrence of the cron, in its time zone, starts a job to one of this worker's handlers.
|
|
298
|
+
{ name: "reports.daily", cron: "0 4 * * *", cronLabel: "Every day at 4am", timeZone: "Europe/London", job: { handler: "acme/report" } },
|
|
299
|
+
// Fan out: the enumeration handler returns the targets at each occurrence.
|
|
300
|
+
{ name: "servers.backup", cron: "*/30 * * * *", job: { handler: "acme/backup" }, enumerate: { handler: "acme/list-servers" } },
|
|
301
|
+
],
|
|
302
|
+
});
|
|
303
|
+
worker.handle(report).handle(backup).handle(
|
|
304
|
+
defineEnumerator({ name: "acme/list-servers", version: "1.0.0", run: async () => (await servers()).map((s) => ({ key: `server:${s.id}`, args: { id: s.id } })) }),
|
|
305
|
+
);
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
- A schedule whose job or enumeration handler the worker does not register
|
|
309
|
+
is refused at `start()`, before anything is published.
|
|
310
|
+
- The platform's rules: one run per occurrence and target, however many
|
|
311
|
+
replicas evaluate it. After an outage, only the latest missed occurrence
|
|
312
|
+
within `catchupWindowMs` fires (`misfire`). A target with a run still
|
|
313
|
+
pending is skipped unless `queueWhilePending`. An owner's override of the
|
|
314
|
+
cron or enabled flag survives redeclaration.
|
|
315
|
+
- **`SchedulesClient`** has `setSchedule`, `getSchedule`, `listSchedules`,
|
|
316
|
+
`setScheduleOverride`, `pauseSchedule`, `resumeSchedule`, `deleteSchedule`,
|
|
317
|
+
`runScheduleNow` and `listScheduleOccurrences`; like `QueuesClient` it is
|
|
318
|
+
for one `tenant`, and the worker declares schedules for its own.
|
|
319
|
+
`declareSchedules` is the helper.
|
|
320
|
+
|
|
192
321
|
## Enqueue jobs and start runs
|
|
193
322
|
|
|
194
323
|
```ts
|
|
@@ -196,13 +325,14 @@ import { FailureClass, PipelinesClient } from "@xeonr/pipelines-sdk";
|
|
|
196
325
|
|
|
197
326
|
const pipelines = new PipelinesClient({ baseUrl: "https://pipelines.xeonr.io", token });
|
|
198
327
|
|
|
199
|
-
// One handler, run once: CreateJob (the plan's EnqueueJob). Idempotent per
|
|
328
|
+
// One handler, run once: CreateJob (the plan's EnqueueJob). Idempotent per tenant.
|
|
200
329
|
const { run } = await pipelines.createJob({
|
|
201
330
|
tenant: TEAM,
|
|
202
331
|
handler: "acme/send-email",
|
|
203
332
|
payload: { to: "ada@example.com", template: "welcome" },
|
|
204
333
|
idempotencyKey: "welcome-email:user-4821",
|
|
205
334
|
delayMs: 10 * 60_000, // not offered to a worker before ten minutes have passed
|
|
335
|
+
queue: "emails", // admitted through this tenant queue (see Queues)
|
|
206
336
|
retry: { max: 3, when: [FailureClass.HANDLER_ERROR] }, // the job's node policy; unset is the platform default
|
|
207
337
|
timeoutMs: 5 * 60_000, // bounds one attempt
|
|
208
338
|
});
|
|
@@ -226,6 +356,15 @@ await pipelines.createRun({
|
|
|
226
356
|
},
|
|
227
357
|
});
|
|
228
358
|
|
|
359
|
+
// A published version of a stored pipeline instead of an inline definition.
|
|
360
|
+
await pipelines.createRun({
|
|
361
|
+
idempotencyKey: "nightly:2026-11-12",
|
|
362
|
+
tenant: TEAM,
|
|
363
|
+
resource: { kind: "acme.library", id: "lib-7" },
|
|
364
|
+
pipeline: { name: "nightly-scan", scope: { kind: "acme.library", id: "lib-7" } }, // version 0: the latest
|
|
365
|
+
variables: { depth: 2 },
|
|
366
|
+
});
|
|
367
|
+
|
|
229
368
|
await pipelines.getRun(run.id);
|
|
230
369
|
await pipelines.cancelRun(run.id, "superseded");
|
|
231
370
|
```
|
|
@@ -273,37 +412,107 @@ The fake models:
|
|
|
273
412
|
- external (image) nodes you settle with `completeNode`;
|
|
274
413
|
- error injection (`inject("Heartbeat", Code.Unavailable, 2)`).
|
|
275
414
|
|
|
276
|
-
It
|
|
415
|
+
It also models queues (limits, pause, rate limits, fairness, dead letters),
|
|
416
|
+
issues, staged progress, spans and the run trace, and schedules on a clock
|
|
417
|
+
you control:
|
|
418
|
+
|
|
419
|
+
```ts
|
|
420
|
+
fake.clock.set(new Date("2026-11-12T03:59:30Z"));
|
|
421
|
+
fake.clock.advance(60_000); // fires the 04:00 occurrence
|
|
422
|
+
fake.schedules.occurrences(scheduleId); // what fired, skipped or was refused
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
Like the api, the fake refuses payload keys the handler's manifest does not
|
|
426
|
+
declare as inputs. It retries an `ABANDONED` attempt only on an
|
|
427
|
+
interruptible node.
|
|
428
|
+
|
|
429
|
+
It serves `PipelinesService` too, so code that starts stored pipelines can be
|
|
430
|
+
tested without a server. Use the generated client against it:
|
|
431
|
+
|
|
432
|
+
```ts
|
|
433
|
+
import { createClient } from "@connectrpc/connect";
|
|
434
|
+
import { PipelinesService } from "@xeonr/pipelines-sdk/gen/xeonr/pipelines/v1/pipelines_pb";
|
|
435
|
+
|
|
436
|
+
const stored = createClient(PipelinesService, fake.transport());
|
|
437
|
+
const scope = { kind: "acme.library", id: "lib-7" };
|
|
438
|
+
const { pipeline } = await stored.setPipeline({ pipeline: { tenant: FAKE_TENANT, scope, name: "nightly-scan", draft: { definition } } });
|
|
439
|
+
await stored.publishPipeline({ pipelineId: pipeline!.id }); // version 1
|
|
440
|
+
const { run } = await client.createRun({ idempotencyKey: "n1", tenant: FAKE_TENANT, resource: scope, pipeline: { id: pipeline!.id } });
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
What it models of them, as pipelines-api does:
|
|
444
|
+
|
|
445
|
+
- **Stored pipelines**: drafts saved as given, guarded by
|
|
446
|
+
`expected_draft_revision` and narrowed by `update_mask`; publish checks
|
|
447
|
+
the draft as `CreateRun` would and freezes version N+1 (or answers
|
|
448
|
+
`unchanged`), filling nodes' retry and timeout from the policy; archive.
|
|
449
|
+
A run of a version (by id, by name, or `snapshot_id`) has origin
|
|
450
|
+
`PUBLISHED`, its variables checked and defaulted, and its resource held to
|
|
451
|
+
the pipeline's scope or `resource_kinds`. `max_concurrent_runs` holds
|
|
452
|
+
further runs `QUEUED`. A schedule's pipeline target starts a version.
|
|
453
|
+
- **Sub-pipeline nodes**: pinned to a version when the snapshot is made
|
|
454
|
+
(a cycle, nesting over three deep, another tenant's or an unpublished
|
|
455
|
+
pipeline, an unknown variable or output node are `invalid_argument`). Each
|
|
456
|
+
attempt is one child run (`RUN_TRIGGER_PARENT`, `parent_run_id`) about the
|
|
457
|
+
parent's resource; its outputs map back to the node. A failed child fails
|
|
458
|
+
the attempt as `DOWNSTREAM_FAILED`, and a cancel of the parent cancels it.
|
|
459
|
+
- **`for_each` nodes**, on handler and sub-pipeline nodes: the list from a
|
|
460
|
+
literal, a variable or an upstream kv output; `${{ item }}`,
|
|
461
|
+
`${{ item.<path> }}` and `${{ item_index }}` in `with`; `max_items`,
|
|
462
|
+
`max_parallel` and the three `on_failure` policies; each element retried
|
|
463
|
+
on its own; outputs as lists in element order (null for a failed
|
|
464
|
+
element); `RetryNode` runs only the failed elements again.
|
|
465
|
+
|
|
466
|
+
It does not model secrets, blobs, tiers, routing between pools,
|
|
467
|
+
exclusions, `for_each` on an external (image) node, or a variable schema
|
|
468
|
+
beyond its top-level `type`. `ValidateDefinition` answers the first problem
|
|
469
|
+
it finds, where the api lists every one.
|
|
277
470
|
|
|
278
471
|
## Conformance suite
|
|
279
472
|
|
|
280
473
|
`src/conformance/suite.ts` holds the cases both SDKs must pass against
|
|
281
|
-
pipelines-api
|
|
282
|
-
`CONFORMANCE.md`):
|
|
283
|
-
|
|
284
|
-
1. enqueue
|
|
285
|
-
2. delayed job
|
|
286
|
-
3. retry by class
|
|
287
|
-
4. permanent failure
|
|
288
|
-
5. cancel
|
|
289
|
-
6. lease loss
|
|
290
|
-
7. release on shutdown
|
|
291
|
-
8. another owner's handler unclaimable
|
|
474
|
+
pipelines-api, with the ids, steps and expectations of the Go SDK's
|
|
475
|
+
`CONFORMANCE.md` (`xeonr/pipelines/sdk-go`), which is the canonical list:
|
|
292
476
|
|
|
293
|
-
|
|
294
|
-
|
|
477
|
+
| Id | Case |
|
|
478
|
+
|---|---|
|
|
479
|
+
| C1 | Enqueue runs a job in-process (idempotent, kv output, log line) |
|
|
480
|
+
| C2 | A delayed job does not start early |
|
|
481
|
+
| C3 | Retry by class (transient-marked, unmarked, listed) |
|
|
482
|
+
| C4 | A permanent failure is not retried |
|
|
483
|
+
| C5 | A cancel stops the handler |
|
|
484
|
+
| C6 | A lost lease is retried on another replica (an interruptible job) |
|
|
485
|
+
| C7 | Shutdown releases unstarted attempts |
|
|
486
|
+
| C8 | Another owner's handlers are unclaimable |
|
|
487
|
+
| C9 | A job goes through its queue (and one naming none, `default`) |
|
|
488
|
+
| C10 | An unknown queue is `not_found` |
|
|
489
|
+
| C11 | A job over its queue's ceiling is refused (`invalid_argument`) |
|
|
490
|
+
| C12 | `max_concurrency` holds across workers |
|
|
491
|
+
| C13 | Pause, then resume |
|
|
492
|
+
| C14 | A dead letter is requeued |
|
|
493
|
+
| C15 | A handler's reports (stages, progress, issues, a span) reach the run |
|
|
494
|
+
|
|
495
|
+
The cases run against the fake in every `pnpm test`, as sdk-go's CI runs its
|
|
496
|
+
suite against its own fake. That checks the cases hold together, not that
|
|
497
|
+
pipelines-api conforms. To run them against a real pipelines-api, set these
|
|
498
|
+
variables (otherwise the suite is skipped):
|
|
295
499
|
|
|
296
500
|
| Variable | Value |
|
|
297
501
|
|---|---|
|
|
298
502
|
| `PIPELINES_API_URL` | the api's base URL |
|
|
299
503
|
| `PIPELINES_TOKEN` | an access token; or `PIPELINES_SA_ASSERTION` with `PIPELINES_TOKEN_URL` |
|
|
300
|
-
| `PIPELINES_TENANT` | the owner's team URN |
|
|
301
|
-
| `PIPELINES_NAMESPACE` | a registry namespace
|
|
302
|
-
| `PIPELINES_OTHER_TOKEN`, `PIPELINES_OTHER_TENANT` | optional:
|
|
504
|
+
| `PIPELINES_TENANT` | the owner's team URN, which owns the queues |
|
|
505
|
+
| `PIPELINES_NAMESPACE` | optional: a registry namespace the team owns or may claim, default `sdkconf` |
|
|
506
|
+
| `PIPELINES_OTHER_TOKEN`, `PIPELINES_OTHER_TENANT` | optional: another team's service account, for C8 |
|
|
303
507
|
| `PIPELINES_LEASE_MS` | optional: the server's lease, default 60000 |
|
|
304
508
|
|
|
509
|
+
The service accounts need `pipelines:worker:edit`, `pipelines:package:edit`,
|
|
510
|
+
`pipelines:pool:edit`, `pipelines:run:edit`, `pipelines:run:read`,
|
|
511
|
+
`pipelines:queue:read` and `pipelines:queue:edit`, and must be members of
|
|
512
|
+
their tenant's team.
|
|
513
|
+
|
|
305
514
|
```sh
|
|
306
|
-
PIPELINES_API_URL=... PIPELINES_TOKEN=... PIPELINES_TENANT=...
|
|
515
|
+
PIPELINES_API_URL=... PIPELINES_TOKEN=... PIPELINES_TENANT=... pnpm vitest run src/conformance/api.test.ts
|
|
307
516
|
```
|
|
308
517
|
|
|
309
518
|
## Dependencies
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Supplies the bearer token every pipelines-api call carries: an Auth access
|
|
3
|
-
* token for the
|
|
3
|
+
* token for the service's service account, holding the scopes the calls need
|
|
4
4
|
* (`pipelines:run:edit` to start runs and jobs, `pipelines:worker:edit` for a
|
|
5
5
|
* worker, `pipelines:package:edit` and `pipelines:pool:edit` for a worker
|
|
6
6
|
* that registers itself at boot).
|
package/dist/client.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { JsonObject, MessageInitShape } from "@bufbuild/protobuf";
|
|
2
2
|
import type { Client, Transport } from "@connectrpc/connect";
|
|
3
3
|
import type { RunState } from "./gen/xeonr/pipelines/v1/common_pb.js";
|
|
4
|
+
import type { IssueSeverity } from "./gen/xeonr/pipelines/v1/runs_pb.js";
|
|
4
5
|
import type { Definition } from "./gen/xeonr/pipelines/v1/definition_pb.js";
|
|
5
6
|
import { DefinitionSchema } from "./gen/xeonr/pipelines/v1/definition_pb.js";
|
|
6
7
|
import type { RetrySchema } from "./gen/xeonr/pipelines/v1/definition_pb.js";
|
|
7
8
|
import { RunsService } from "./gen/xeonr/pipelines/v1/runs_pb.js";
|
|
8
|
-
import type { Exclusion, ExclusionSchema, GetRunGraphResponse, Run } from "./gen/xeonr/pipelines/v1/runs_pb.js";
|
|
9
|
+
import type { Exclusion, ExclusionSchema, GetRunGraphResponse, GetRunTraceResponse, Run, RunIssue } from "./gen/xeonr/pipelines/v1/runs_pb.js";
|
|
9
10
|
import type { Connection } from "./transport.js";
|
|
10
11
|
/** Options for {@link PipelinesClient}: how to reach pipelines-api. */
|
|
11
12
|
export type PipelinesClientOptions = Connection & {
|
|
@@ -15,7 +16,7 @@ export type PipelinesClientOptions = Connection & {
|
|
|
15
16
|
/** What {@link PipelinesClient.createRun} takes. */
|
|
16
17
|
export interface CreateRunInput {
|
|
17
18
|
/**
|
|
18
|
-
* Makes the create safe to repeat, per
|
|
19
|
+
* Makes the create safe to repeat, per tenant: a repeat returns
|
|
19
20
|
* the first run with `deduplicated` set.
|
|
20
21
|
*/
|
|
21
22
|
idempotencyKey: string;
|
|
@@ -27,9 +28,29 @@ export interface CreateRunInput {
|
|
|
27
28
|
id: string;
|
|
28
29
|
json?: JsonObject;
|
|
29
30
|
};
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The definition to run, as a message or its init shape. Give this or
|
|
33
|
+
* `pipeline`.
|
|
34
|
+
*/
|
|
35
|
+
definition?: Definition | MessageInitShape<typeof DefinitionSchema>;
|
|
36
|
+
/**
|
|
37
|
+
* A published version of a stored pipeline (PipelinesService) to run
|
|
38
|
+
* instead of an inline definition: by id, or by its tenant, scope and
|
|
39
|
+
* name; `version` 0 (the default) runs the latest. Its declared variables
|
|
40
|
+
* are checked and defaulted by the platform.
|
|
41
|
+
*/
|
|
42
|
+
pipeline?: {
|
|
43
|
+
id: string;
|
|
44
|
+
version?: number;
|
|
45
|
+
} | {
|
|
46
|
+
name: string;
|
|
47
|
+
scope: {
|
|
48
|
+
kind: string;
|
|
49
|
+
id: string;
|
|
50
|
+
};
|
|
51
|
+
version?: number;
|
|
52
|
+
};
|
|
53
|
+
/** Facts about the run the tenant's service vouches for (tiers and secret policies read them). */
|
|
33
54
|
attestedFacts?: JsonObject;
|
|
34
55
|
/** Per-run values, read as `${{ variables.<name> }}`. Never secrets. */
|
|
35
56
|
variables?: JsonObject;
|
|
@@ -46,7 +67,7 @@ export interface CreateJobInput {
|
|
|
46
67
|
payload?: JsonObject;
|
|
47
68
|
/** Holds the job back: it is not offered to a worker earlier. At most a year. */
|
|
48
69
|
delayMs?: number;
|
|
49
|
-
/** Makes the create safe to repeat, per
|
|
70
|
+
/** Makes the create safe to repeat, per tenant. */
|
|
50
71
|
idempotencyKey: string;
|
|
51
72
|
/** What the job is about, if anything. */
|
|
52
73
|
resource?: {
|
|
@@ -62,8 +83,25 @@ export interface CreateJobInput {
|
|
|
62
83
|
* `PermanentError` is still never retried. `max` is at most 10.
|
|
63
84
|
*/
|
|
64
85
|
retry?: MessageInitShape<typeof RetrySchema>;
|
|
65
|
-
/** Bounds one attempt from its start. Unset is the
|
|
86
|
+
/** Bounds one attempt from its start. Unset is the queue's default, then the platform's. */
|
|
66
87
|
timeoutMs?: number;
|
|
88
|
+
/**
|
|
89
|
+
* The queue the job is admitted through, among the tenant's queues. Unset
|
|
90
|
+
* is the tenant's `default` queue. An unknown name is `not_found`; a `retry` or
|
|
91
|
+
* `timeoutMs` over the queue's ceiling is `invalid_argument`.
|
|
92
|
+
*/
|
|
93
|
+
queue?: string;
|
|
94
|
+
/**
|
|
95
|
+
* The handler is safe to run again from the start: an attempt its worker
|
|
96
|
+
* stops by shutting down is offered again without spending a retry.
|
|
97
|
+
*/
|
|
98
|
+
interruptible?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* What the job's queue is fair by and caps per, in place of the tenant
|
|
101
|
+
* (for example the customer or group the job is for). Unset is the
|
|
102
|
+
* tenant's one lane. At most 128 printable ASCII characters, no spaces.
|
|
103
|
+
*/
|
|
104
|
+
fairnessKey?: string;
|
|
67
105
|
}
|
|
68
106
|
/** A created run, and whether the idempotency key had been seen. */
|
|
69
107
|
export interface CreatedRun {
|
|
@@ -83,9 +121,9 @@ export interface ListRunsInput {
|
|
|
83
121
|
limit?: number;
|
|
84
122
|
}
|
|
85
123
|
/**
|
|
86
|
-
* The public-API client a
|
|
87
|
-
* what became of them (`RunsService`). It calls with the
|
|
88
|
-
* service-account token (scopes `pipelines:run:edit` and
|
|
124
|
+
* The public-API client a consuming service uses to start runs and jobs and
|
|
125
|
+
* to read what became of them (`RunsService`). It calls with the service's
|
|
126
|
+
* Auth service-account token, a member of the tenant's team (scopes `pipelines:run:edit` and
|
|
89
127
|
* `pipelines:run:read`).
|
|
90
128
|
*
|
|
91
129
|
* Every method is a single RPC; errors are the API's `ConnectError`s,
|
|
@@ -123,6 +161,31 @@ export declare class PipelinesClient {
|
|
|
123
161
|
* Asks a run to stop (`CancelRun`). Running attempts are told on their next
|
|
124
162
|
* heartbeat; an SDK worker aborts the handler's signal. Idempotent.
|
|
125
163
|
*/
|
|
164
|
+
/**
|
|
165
|
+
* Lists a run's issues (`ListIssues`): the non-fatal problems its steps
|
|
166
|
+
* reported, oldest first, optionally narrowed to a node, an attempt or a
|
|
167
|
+
* least severity. `Run` carries their counts.
|
|
168
|
+
*/
|
|
169
|
+
listIssues(runId: string, input?: {
|
|
170
|
+
nodeId?: string;
|
|
171
|
+
attemptId?: string;
|
|
172
|
+
minSeverity?: IssueSeverity;
|
|
173
|
+
cursor?: string;
|
|
174
|
+
limit?: number;
|
|
175
|
+
}, signal?: AbortSignal): Promise<{
|
|
176
|
+
issues: RunIssue[];
|
|
177
|
+
nextCursor: string;
|
|
178
|
+
}>;
|
|
179
|
+
/** Reads a run's trace (`GetRunTrace`): the platform's spans and those steps and handlers reported. */
|
|
180
|
+
getRunTrace(runId: string, input?: {
|
|
181
|
+
nodeId?: string;
|
|
182
|
+
attemptId?: string;
|
|
183
|
+
}, signal?: AbortSignal): Promise<GetRunTraceResponse>;
|
|
184
|
+
/**
|
|
185
|
+
* Runs one node of a finished run again (`RetryNode`). On a job (node
|
|
186
|
+
* `job`) this requeues a dead letter on its queue.
|
|
187
|
+
*/
|
|
188
|
+
retryNode(runId: string, nodeId: string, signal?: AbortSignal): Promise<Run>;
|
|
126
189
|
cancelRun(runId: string, reason?: string, signal?: AbortSignal): Promise<Run>;
|
|
127
190
|
private opts;
|
|
128
191
|
}
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGvE,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAkB,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,KAAK,EAAE,UAAU,EAAE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ionSchema } from "./gen/xeonr/pipelines/v1/definition_pb.js";
|
|
|
5
5
|
import { RunsService } from "./gen/xeonr/pipelines/v1/runs_pb.js";
|
|
6
6
|
import { transportOf } from "./transport.js";
|
|
7
7
|
/**
|
|
8
|
-
* The public-API client a
|
|
9
|
-
* what became of them (`RunsService`). It calls with the
|
|
10
|
-
* service-account token (scopes `pipelines:run:edit` and
|
|
8
|
+
* The public-API client a consuming service uses to start runs and jobs and
|
|
9
|
+
* to read what became of them (`RunsService`). It calls with the service's
|
|
10
|
+
* Auth service-account token, a member of the tenant's team (scopes `pipelines:run:edit` and
|
|
11
11
|
* `pipelines:run:read`).
|
|
12
12
|
*
|
|
13
13
|
* Every method is a single RPC; errors are the API's `ConnectError`s,
|
|
@@ -34,7 +34,7 @@ export class PipelinesClient {
|
|
|
34
34
|
idempotencyKey: input.idempotencyKey,
|
|
35
35
|
tenant: input.tenant,
|
|
36
36
|
resource: resource(input.resource),
|
|
37
|
-
source:
|
|
37
|
+
source: runSource(input),
|
|
38
38
|
...(input.attestedFacts ? { attestedFacts: input.attestedFacts } : {}),
|
|
39
39
|
...(input.variables ? { variables: input.variables } : {}),
|
|
40
40
|
...(input.exclusion ? { exclusion: input.exclusion } : {}),
|
|
@@ -61,6 +61,9 @@ export class PipelinesClient {
|
|
|
61
61
|
...(input.delayMs ? { delay: durationFromMs(input.delayMs) } : {}),
|
|
62
62
|
...(input.resource ? { resource: resource(input.resource) } : {}),
|
|
63
63
|
...(input.retry ? { retry: input.retry } : {}),
|
|
64
|
+
...(input.queue ? { queue: input.queue } : {}),
|
|
65
|
+
...(input.interruptible ? { interruptible: true } : {}),
|
|
66
|
+
...(input.fairnessKey ? { fairnessKey: input.fairnessKey } : {}),
|
|
64
67
|
...(input.timeoutMs ? { timeout: durationFromMs(input.timeoutMs) } : {}),
|
|
65
68
|
}, this.opts(signal));
|
|
66
69
|
return { run: required(res.run), deduplicated: res.deduplicated };
|
|
@@ -88,6 +91,33 @@ export class PipelinesClient {
|
|
|
88
91
|
* Asks a run to stop (`CancelRun`). Running attempts are told on their next
|
|
89
92
|
* heartbeat; an SDK worker aborts the handler's signal. Idempotent.
|
|
90
93
|
*/
|
|
94
|
+
/**
|
|
95
|
+
* Lists a run's issues (`ListIssues`): the non-fatal problems its steps
|
|
96
|
+
* reported, oldest first, optionally narrowed to a node, an attempt or a
|
|
97
|
+
* least severity. `Run` carries their counts.
|
|
98
|
+
*/
|
|
99
|
+
async listIssues(runId, input = {}, signal) {
|
|
100
|
+
const res = await this.runs.listIssues({
|
|
101
|
+
runId,
|
|
102
|
+
nodeId: input.nodeId ?? "",
|
|
103
|
+
attemptId: input.attemptId ?? "",
|
|
104
|
+
minSeverity: input.minSeverity ?? 0,
|
|
105
|
+
cursor: input.cursor ?? "",
|
|
106
|
+
limit: input.limit ?? 0,
|
|
107
|
+
}, this.opts(signal));
|
|
108
|
+
return { issues: res.issues, nextCursor: res.nextCursor };
|
|
109
|
+
}
|
|
110
|
+
/** Reads a run's trace (`GetRunTrace`): the platform's spans and those steps and handlers reported. */
|
|
111
|
+
async getRunTrace(runId, input = {}, signal) {
|
|
112
|
+
return this.runs.getRunTrace({ runId, nodeId: input.nodeId ?? "", attemptId: input.attemptId ?? "" }, this.opts(signal));
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Runs one node of a finished run again (`RetryNode`). On a job (node
|
|
116
|
+
* `job`) this requeues a dead letter on its queue.
|
|
117
|
+
*/
|
|
118
|
+
async retryNode(runId, nodeId, signal) {
|
|
119
|
+
return required((await this.runs.retryNode({ runId, nodeId }, this.opts(signal))).run);
|
|
120
|
+
}
|
|
91
121
|
async cancelRun(runId, reason, signal) {
|
|
92
122
|
return required((await this.runs.cancelRun({ runId, ...(reason ? { reason } : {}) }, this.opts(signal))).run);
|
|
93
123
|
}
|
|
@@ -103,4 +133,17 @@ function required(run) {
|
|
|
103
133
|
throw new Error("pipelines-api answered without a run");
|
|
104
134
|
return run;
|
|
105
135
|
}
|
|
136
|
+
function runSource(input) {
|
|
137
|
+
if (input.definition && input.pipeline)
|
|
138
|
+
throw new TypeError("createRun: give definition or pipeline, not both");
|
|
139
|
+
if (input.definition)
|
|
140
|
+
return { case: "inlineDefinition", value: create(DefinitionSchema, input.definition) };
|
|
141
|
+
const p = input.pipeline;
|
|
142
|
+
if (!p)
|
|
143
|
+
throw new TypeError("createRun: definition or pipeline is required");
|
|
144
|
+
const pipeline = "id" in p
|
|
145
|
+
? { case: "pipelineId", value: p.id }
|
|
146
|
+
: { case: "byName", value: { tenant: input.tenant, scope: p.scope, name: p.name } };
|
|
147
|
+
return { case: "pipeline", value: { pipeline, version: p.version ?? 0 } };
|
|
148
|
+
}
|
|
106
149
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAmG7C;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IAC1B,uEAAuE;IAC9D,IAAI,CAA6B;IAC1C,0DAA0D;IACjD,SAAS,CAAY;IACb,SAAS,CAAS;I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