@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.
Files changed (115) hide show
  1. package/README.md +231 -22
  2. package/dist/auth.d.ts +1 -1
  3. package/dist/client.d.ts +73 -10
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +47 -4
  6. package/dist/client.js.map +1 -1
  7. package/dist/gen/xeonr/pipelines/private/v1/attempt_pb.d.ts +179 -16
  8. package/dist/gen/xeonr/pipelines/private/v1/attempt_pb.d.ts.map +1 -1
  9. package/dist/gen/xeonr/pipelines/private/v1/attempt_pb.js +45 -28
  10. package/dist/gen/xeonr/pipelines/private/v1/attempt_pb.js.map +1 -1
  11. package/dist/gen/xeonr/pipelines/private/v1/step_local_pb.d.ts +136 -17
  12. package/dist/gen/xeonr/pipelines/private/v1/step_local_pb.d.ts.map +1 -1
  13. package/dist/gen/xeonr/pipelines/private/v1/step_local_pb.js +42 -35
  14. package/dist/gen/xeonr/pipelines/private/v1/step_local_pb.js.map +1 -1
  15. package/dist/gen/xeonr/pipelines/private/v1/worker_pb.d.ts +224 -8
  16. package/dist/gen/xeonr/pipelines/private/v1/worker_pb.d.ts.map +1 -1
  17. package/dist/gen/xeonr/pipelines/private/v1/worker_pb.js +43 -9
  18. package/dist/gen/xeonr/pipelines/private/v1/worker_pb.js.map +1 -1
  19. package/dist/gen/xeonr/pipelines/v1/common_pb.d.ts +64 -8
  20. package/dist/gen/xeonr/pipelines/v1/common_pb.d.ts.map +1 -1
  21. package/dist/gen/xeonr/pipelines/v1/common_pb.js +62 -5
  22. package/dist/gen/xeonr/pipelines/v1/common_pb.js.map +1 -1
  23. package/dist/gen/xeonr/pipelines/v1/definition_pb.d.ts +312 -9
  24. package/dist/gen/xeonr/pipelines/v1/definition_pb.d.ts.map +1 -1
  25. package/dist/gen/xeonr/pipelines/v1/definition_pb.js +100 -7
  26. package/dist/gen/xeonr/pipelines/v1/definition_pb.js.map +1 -1
  27. package/dist/gen/xeonr/pipelines/v1/pipelines_pb.d.ts +1072 -0
  28. package/dist/gen/xeonr/pipelines/v1/pipelines_pb.d.ts.map +1 -0
  29. package/dist/gen/xeonr/pipelines/v1/pipelines_pb.js +299 -0
  30. package/dist/gen/xeonr/pipelines/v1/pipelines_pb.js.map +1 -0
  31. package/dist/gen/xeonr/pipelines/v1/pools_pb.d.ts +103 -8
  32. package/dist/gen/xeonr/pipelines/v1/pools_pb.d.ts.map +1 -1
  33. package/dist/gen/xeonr/pipelines/v1/pools_pb.js +32 -24
  34. package/dist/gen/xeonr/pipelines/v1/pools_pb.js.map +1 -1
  35. package/dist/gen/xeonr/pipelines/v1/queues_pb.d.ts +711 -0
  36. package/dist/gen/xeonr/pipelines/v1/queues_pb.d.ts.map +1 -0
  37. package/dist/gen/xeonr/pipelines/v1/queues_pb.js +185 -0
  38. package/dist/gen/xeonr/pipelines/v1/queues_pb.js.map +1 -0
  39. package/dist/gen/xeonr/pipelines/v1/registry_pb.d.ts +92 -23
  40. package/dist/gen/xeonr/pipelines/v1/registry_pb.d.ts.map +1 -1
  41. package/dist/gen/xeonr/pipelines/v1/registry_pb.js +36 -33
  42. package/dist/gen/xeonr/pipelines/v1/registry_pb.js.map +1 -1
  43. package/dist/gen/xeonr/pipelines/v1/runs_pb.d.ts +1191 -33
  44. package/dist/gen/xeonr/pipelines/v1/runs_pb.d.ts.map +1 -1
  45. package/dist/gen/xeonr/pipelines/v1/runs_pb.js +419 -35
  46. package/dist/gen/xeonr/pipelines/v1/runs_pb.js.map +1 -1
  47. package/dist/gen/xeonr/pipelines/v1/schedule_targets_pb.d.ts +194 -0
  48. package/dist/gen/xeonr/pipelines/v1/schedule_targets_pb.d.ts.map +1 -0
  49. package/dist/gen/xeonr/pipelines/v1/schedule_targets_pb.js +100 -0
  50. package/dist/gen/xeonr/pipelines/v1/schedule_targets_pb.js.map +1 -0
  51. package/dist/gen/xeonr/pipelines/v1/schedules_pb.d.ts +1186 -0
  52. package/dist/gen/xeonr/pipelines/v1/schedules_pb.d.ts.map +1 -0
  53. package/dist/gen/xeonr/pipelines/v1/schedules_pb.js +335 -0
  54. package/dist/gen/xeonr/pipelines/v1/schedules_pb.js.map +1 -0
  55. package/dist/gen/xeonr/pipelines/v1/secrets_pb.d.ts +32 -5
  56. package/dist/gen/xeonr/pipelines/v1/secrets_pb.d.ts.map +1 -1
  57. package/dist/gen/xeonr/pipelines/v1/secrets_pb.js +12 -3
  58. package/dist/gen/xeonr/pipelines/v1/secrets_pb.js.map +1 -1
  59. package/dist/gen/xeonr/pipelines/v1/sinks_pb.d.ts +270 -27
  60. package/dist/gen/xeonr/pipelines/v1/sinks_pb.d.ts.map +1 -1
  61. package/dist/gen/xeonr/pipelines/v1/sinks_pb.js +163 -24
  62. package/dist/gen/xeonr/pipelines/v1/sinks_pb.js.map +1 -1
  63. package/dist/gen/xeonr/pipelines/v1/tenant_policies_pb.d.ts +391 -0
  64. package/dist/gen/xeonr/pipelines/v1/tenant_policies_pb.d.ts.map +1 -0
  65. package/dist/gen/xeonr/pipelines/v1/tenant_policies_pb.js +100 -0
  66. package/dist/gen/xeonr/pipelines/v1/tenant_policies_pb.js.map +1 -0
  67. package/dist/gen/xeonr/platform/v1/options_pb.d.ts +137 -1
  68. package/dist/gen/xeonr/platform/v1/options_pb.d.ts.map +1 -1
  69. package/dist/gen/xeonr/platform/v1/options_pb.js +104 -1
  70. package/dist/gen/xeonr/platform/v1/options_pb.js.map +1 -1
  71. package/dist/handler.d.ts +51 -1
  72. package/dist/handler.d.ts.map +1 -1
  73. package/dist/handler.js +27 -0
  74. package/dist/handler.js.map +1 -1
  75. package/dist/index.d.ts +13 -2
  76. package/dist/index.d.ts.map +1 -1
  77. package/dist/index.js +7 -2
  78. package/dist/index.js.map +1 -1
  79. package/dist/queues.d.ts +158 -0
  80. package/dist/queues.d.ts.map +1 -0
  81. package/dist/queues.js +117 -0
  82. package/dist/queues.js.map +1 -0
  83. package/dist/reporter.d.ts +120 -0
  84. package/dist/reporter.d.ts.map +1 -0
  85. package/dist/reporter.js +323 -0
  86. package/dist/reporter.js.map +1 -0
  87. package/dist/schedules.d.ts +193 -0
  88. package/dist/schedules.d.ts.map +1 -0
  89. package/dist/schedules.js +126 -0
  90. package/dist/schedules.js.map +1 -0
  91. package/dist/testing/cron.d.ts +33 -0
  92. package/dist/testing/cron.d.ts.map +1 -0
  93. package/dist/testing/cron.js +177 -0
  94. package/dist/testing/cron.js.map +1 -0
  95. package/dist/testing/index.d.ts +229 -7
  96. package/dist/testing/index.d.ts.map +1 -1
  97. package/dist/testing/index.js +1304 -103
  98. package/dist/testing/index.js.map +1 -1
  99. package/dist/testing/pipelines.d.ts +99 -0
  100. package/dist/testing/pipelines.d.ts.map +1 -0
  101. package/dist/testing/pipelines.js +445 -0
  102. package/dist/testing/pipelines.js.map +1 -0
  103. package/dist/testing/queues.d.ts +49 -0
  104. package/dist/testing/queues.d.ts.map +1 -0
  105. package/dist/testing/queues.js +72 -0
  106. package/dist/testing/queues.js.map +1 -0
  107. package/dist/testing/schedules.d.ts +125 -0
  108. package/dist/testing/schedules.d.ts.map +1 -0
  109. package/dist/testing/schedules.js +422 -0
  110. package/dist/testing/schedules.js.map +1 -0
  111. package/dist/worker.d.ts +48 -7
  112. package/dist/worker.d.ts.map +1 -1
  113. package/dist/worker.js +59 -9
  114. package/dist/worker.js.map +1 -1
  115. package/package.json +1 -1
@@ -0,0 +1,323 @@
1
+ import { randomBytes } from "node:crypto";
2
+ import { timestampFromMs } from "@bufbuild/protobuf/wkt";
3
+ import { errorKind } from "./errors.js";
4
+ import { IssueSeverity } from "./gen/xeonr/pipelines/private/v1/attempt_pb.js";
5
+ import { StageState } from "./gen/xeonr/pipelines/v1/runs_pb.js";
6
+ const STAGE_KEY = /^[a-z][a-z0-9_.-]{0,63}$/;
7
+ const SUBJECT_KIND = /^[a-z0-9][a-z0-9._-]*$/;
8
+ const MAX_COUNT = 1_000_000_000_000;
9
+ const encoder = new TextEncoder();
10
+ /**
11
+ * Reports an attempt's progress, issues and spans on the worker surface
12
+ * (`SetProgress`, `AppendIssues`, `ReportSpans`).
13
+ *
14
+ * - Progress is coalesced: the latest value about once a second, and the
15
+ * last one before the attempt completes ({@link finish}). A stage change is
16
+ * sent at once, in order.
17
+ * - Issues are batched (up to 100 a call) and spans too (up to 1000).
18
+ * - Nothing here can fail the handler: every error is logged at debug and
19
+ * dropped. `failed_precondition` (the attempt is no longer this worker's)
20
+ * stops all reporting; the heartbeat deals with the attempt itself.
21
+ */
22
+ export class AttemptReporter {
23
+ api;
24
+ ref;
25
+ declared;
26
+ interval;
27
+ debug;
28
+ stopped = false;
29
+ chain = Promise.resolve();
30
+ stageKey = "";
31
+ stageName = "";
32
+ progressState = {
33
+ processed: 0,
34
+ total: 0,
35
+ failed: 0,
36
+ fraction: undefined,
37
+ message: "",
38
+ };
39
+ reported = false;
40
+ dirty = false;
41
+ lastSent = 0;
42
+ progressTimer;
43
+ issues = [];
44
+ spans = [];
45
+ batchTimer;
46
+ traceId = randomBytes(16).toString("hex");
47
+ constructor(deps) {
48
+ this.api = deps.api;
49
+ this.ref = deps.ref;
50
+ this.declared = new Map(deps.stages.map((s) => [s.key, s]));
51
+ this.interval = deps.intervalMs ?? 1_000;
52
+ this.debug = deps.debug;
53
+ }
54
+ /** The stage the attempt is in, or "" before any. */
55
+ get stage() {
56
+ return this.stageKey;
57
+ }
58
+ /**
59
+ * Enters a stage (finishing the one before), or moves the current one to
60
+ * `state`. A key the manifest does not declare is added at run time with
61
+ * weight 0, named `name` (default the key).
62
+ */
63
+ setStage(key, opts = {}) {
64
+ if (!STAGE_KEY.test(key)) {
65
+ this.debug("ignored a stage with an invalid key", { key });
66
+ return;
67
+ }
68
+ // A stage move is sent at once, after anything pending for the stage
69
+ // being left, so no coalesced update of it is lost.
70
+ this.flushProgress();
71
+ if (key !== this.stageKey) {
72
+ this.stageKey = key;
73
+ this.stageName = this.declared.has(key) ? "" : clip(opts.name ?? key, 128);
74
+ this.progressState = { processed: 0, total: 0, failed: 0, fraction: undefined, message: "" };
75
+ }
76
+ if (opts.message !== undefined)
77
+ this.progressState.message = clip(opts.message, 255);
78
+ this.send(this.progressRequest(stageState(opts.state)));
79
+ }
80
+ /** Reports progress within the current stage (or the attempt). Coalesced. */
81
+ progress(update) {
82
+ if (this.stopped)
83
+ return;
84
+ const p = this.progressState;
85
+ if (update.processed !== undefined)
86
+ p.processed = count(update.processed);
87
+ if (update.total !== undefined)
88
+ p.total = count(update.total);
89
+ if (update.failed !== undefined)
90
+ p.failed = count(update.failed);
91
+ if (update.fraction !== undefined)
92
+ p.fraction = Number.isFinite(update.fraction) ? Math.min(1, Math.max(0, update.fraction)) : undefined;
93
+ if (update.message !== undefined)
94
+ p.message = clip(update.message, 255);
95
+ this.dirty = true;
96
+ this.reported = true;
97
+ if (this.progressTimer)
98
+ return;
99
+ const wait = this.lastSent + this.interval - Date.now();
100
+ if (wait <= 0) {
101
+ this.flushProgress();
102
+ }
103
+ else {
104
+ this.progressTimer = setTimeout(() => {
105
+ this.progressTimer = undefined;
106
+ this.flushProgress();
107
+ }, wait);
108
+ this.progressTimer.unref?.();
109
+ }
110
+ }
111
+ /** Queues an issue. Batched. */
112
+ issue(input) {
113
+ if (this.stopped)
114
+ return;
115
+ const message = clip(String(input.message ?? "").trim(), 4096);
116
+ if (!message) {
117
+ this.debug("ignored an issue with no message");
118
+ return;
119
+ }
120
+ const kind = (input.subjectKind ?? "").toLowerCase().slice(0, 100);
121
+ const detail = input.detail && jsonSize(input.detail) <= 16 << 10 ? input.detail : undefined;
122
+ if (input.detail && !detail)
123
+ this.debug("dropped an issue's detail over 16 KiB");
124
+ this.issues.push({
125
+ severity: severity(input.severity),
126
+ subject: clip(input.subject ?? "", 512),
127
+ subjectKind: kind === "" || SUBJECT_KIND.test(kind) ? kind : "",
128
+ subjectId: clip((input.subjectId ?? "").replaceAll("\0", ""), 1024),
129
+ message,
130
+ ...(detail ? { detail } : {}),
131
+ stage: this.stageKey,
132
+ });
133
+ if (this.issues.length >= 100)
134
+ this.flushBatches();
135
+ else
136
+ this.armBatches();
137
+ }
138
+ /** Runs `fn` inside a span of this attempt's trace. */
139
+ span(name, fn, attributes, parent = "") {
140
+ const spanId = randomBytes(8).toString("hex");
141
+ const attrs = { ...(attributes ?? {}) };
142
+ const handle = {
143
+ traceId: this.traceId,
144
+ spanId,
145
+ setAttribute: (k, v) => {
146
+ attrs[k] = v;
147
+ },
148
+ span: (n, f, a) => this.span(n, f, a, spanId),
149
+ };
150
+ const startedAt = Date.now();
151
+ const end = (status, statusMessage = "") => {
152
+ if (this.stopped)
153
+ return;
154
+ this.spans.push({
155
+ traceId: this.traceId,
156
+ spanId,
157
+ parentSpanId: parent,
158
+ name: clip(name || "span", 255),
159
+ startedAt: timestampFromMs(startedAt),
160
+ endedAt: timestampFromMs(Math.max(Date.now(), startedAt)),
161
+ status,
162
+ statusMessage: clip(statusMessage, 1024),
163
+ ...(jsonSize(attrs) <= 16 << 10 && Object.keys(attrs).length > 0 ? { attributes: attrs } : {}),
164
+ });
165
+ if (this.spans.length >= 1000)
166
+ this.flushBatches();
167
+ else
168
+ this.armBatches();
169
+ };
170
+ return (async () => {
171
+ try {
172
+ const out = await fn(handle);
173
+ end("ok");
174
+ return out;
175
+ }
176
+ catch (err) {
177
+ end("error", err instanceof Error ? err.message : String(err));
178
+ throw err;
179
+ }
180
+ })();
181
+ }
182
+ /**
183
+ * The last reports before CompleteAttempt: the current stage finished as
184
+ * `outcome`, pending progress, issues and spans, waiting at most
185
+ * `timeoutMs`. Never throws.
186
+ */
187
+ async finish(outcome, timeoutMs) {
188
+ if (this.stopped)
189
+ return;
190
+ if (this.progressTimer)
191
+ clearTimeout(this.progressTimer);
192
+ this.progressTimer = undefined;
193
+ if (this.stageKey) {
194
+ if (outcome === "succeeded" && this.progressState.fraction === undefined && this.progressState.total === 0)
195
+ this.progressState.fraction = 1;
196
+ this.send(this.progressRequest(outcome === "succeeded" ? StageState.SUCCEEDED : StageState.FAILED));
197
+ this.dirty = false;
198
+ }
199
+ else if (this.dirty || (outcome === "succeeded" && this.reported)) {
200
+ if (outcome === "succeeded" && this.progressState.fraction === undefined && this.progressState.total === 0)
201
+ this.progressState.fraction = 1;
202
+ this.send(this.progressRequest(StageState.UNSPECIFIED));
203
+ this.dirty = false;
204
+ }
205
+ this.flushBatches();
206
+ let timer;
207
+ await Promise.race([this.chain, new Promise((r) => (timer = setTimeout(r, timeoutMs)))]);
208
+ clearTimeout(timer);
209
+ this.stop();
210
+ }
211
+ /** Stops reporting; nothing more is sent. */
212
+ stop() {
213
+ this.stopped = true;
214
+ if (this.progressTimer)
215
+ clearTimeout(this.progressTimer);
216
+ if (this.batchTimer)
217
+ clearTimeout(this.batchTimer);
218
+ this.progressTimer = this.batchTimer = undefined;
219
+ this.issues = [];
220
+ this.spans = [];
221
+ }
222
+ flushProgress() {
223
+ if (!this.dirty)
224
+ return;
225
+ this.dirty = false;
226
+ this.send(this.progressRequest(StageState.UNSPECIFIED));
227
+ }
228
+ progressRequest(state) {
229
+ const p = this.progressState;
230
+ const fraction = p.fraction ?? (p.total > 0 ? Math.min(1, p.processed / p.total) : 0);
231
+ return {
232
+ ref: this.ref,
233
+ fraction,
234
+ processed: BigInt(p.processed),
235
+ total: BigInt(p.total),
236
+ failed: BigInt(p.failed),
237
+ message: p.message,
238
+ stage: this.stageKey,
239
+ stageName: this.stageName,
240
+ stageState: state,
241
+ };
242
+ }
243
+ armBatches() {
244
+ if (this.batchTimer)
245
+ return;
246
+ this.batchTimer = setTimeout(() => {
247
+ this.batchTimer = undefined;
248
+ this.flushBatches();
249
+ }, this.interval);
250
+ this.batchTimer.unref?.();
251
+ }
252
+ flushBatches() {
253
+ if (this.batchTimer)
254
+ clearTimeout(this.batchTimer);
255
+ this.batchTimer = undefined;
256
+ while (this.issues.length > 0) {
257
+ const issues = this.issues.splice(0, 100);
258
+ this.enqueue("AppendIssues", () => this.api.appendIssues({ ref: this.ref, issues }, { timeoutMs: 10_000 }));
259
+ }
260
+ while (this.spans.length > 0) {
261
+ const spans = this.spans.splice(0, 1000);
262
+ this.enqueue("ReportSpans", () => this.api.reportSpans({ ref: this.ref, spans }, { timeoutMs: 10_000 }));
263
+ }
264
+ }
265
+ send(req) {
266
+ this.lastSent = Date.now();
267
+ this.enqueue("SetProgress", () => this.api.setProgress(req, { timeoutMs: 10_000 }));
268
+ }
269
+ /** Sends in order, one call at a time; failures are dropped. */
270
+ enqueue(what, call) {
271
+ if (this.stopped)
272
+ return;
273
+ this.chain = this.chain.then(async () => {
274
+ if (this.stopped)
275
+ return;
276
+ try {
277
+ await call();
278
+ }
279
+ catch (err) {
280
+ if (errorKind(err) === "lost")
281
+ this.stop();
282
+ this.debug(`${what} failed; dropped`, { error: err instanceof Error ? err.message : String(err) });
283
+ }
284
+ });
285
+ }
286
+ }
287
+ function stageState(s) {
288
+ switch (s) {
289
+ case "succeeded":
290
+ return StageState.SUCCEEDED;
291
+ case "failed":
292
+ return StageState.FAILED;
293
+ case "skipped":
294
+ return StageState.SKIPPED;
295
+ default:
296
+ return StageState.RUNNING;
297
+ }
298
+ }
299
+ function severity(s) {
300
+ switch (s) {
301
+ case "info":
302
+ return IssueSeverity.INFO;
303
+ case "error":
304
+ return IssueSeverity.ERROR;
305
+ default:
306
+ return IssueSeverity.WARNING;
307
+ }
308
+ }
309
+ function count(n) {
310
+ return Number.isFinite(n) ? Math.min(MAX_COUNT, Math.max(0, Math.floor(n))) : 0;
311
+ }
312
+ function clip(s, max) {
313
+ return s.length > max ? s.slice(0, max) : s;
314
+ }
315
+ function jsonSize(v) {
316
+ try {
317
+ return encoder.encode(JSON.stringify(v)).length;
318
+ }
319
+ catch {
320
+ return Infinity;
321
+ }
322
+ }
323
+ //# sourceMappingURL=reporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporter.js","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,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
+ import type { JsonObject, MessageInitShape } from "@bufbuild/protobuf";
2
+ import type { Client } from "@connectrpc/connect";
3
+ import type { ResourceSchema } from "./gen/xeonr/pipelines/v1/common_pb.js";
4
+ import type { RetrySchema } from "./gen/xeonr/pipelines/v1/definition_pb.js";
5
+ import type { Run } from "./gen/xeonr/pipelines/v1/runs_pb.js";
6
+ import { MisfirePolicy, SchedulesService } from "./gen/xeonr/pipelines/v1/schedules_pb.js";
7
+ import type { ListScheduleOccurrencesResponse, Schedule } from "./gen/xeonr/pipelines/v1/schedules_pb.js";
8
+ import type { Connection } from "./transport.js";
9
+ /** Options for {@link SchedulesClient}. */
10
+ export type SchedulesClientOptions = Connection & {
11
+ /** The tenant (team URN) whose schedules these are: a team the calling service account is a member of. */
12
+ tenant: string;
13
+ /** Bound on each call. Default 30 s. */
14
+ timeoutMs?: number;
15
+ };
16
+ /** One target of an occurrence, in the JSON form an enumeration handler returns. */
17
+ export interface ScheduleTargetJson {
18
+ /** Identifies the target across occurrences ("server:42"). Unique in a list. */
19
+ key: string;
20
+ /** What the target's run is about. */
21
+ resource?: {
22
+ kind: string;
23
+ id: string;
24
+ json?: JsonObject;
25
+ };
26
+ /** Merged over the job's payload. At most 16 KiB. */
27
+ args?: JsonObject;
28
+ }
29
+ /** A job a schedule starts: as `createJob`, to one of the tenant's handlers. */
30
+ export interface ScheduleJobDecl {
31
+ handler: string;
32
+ payload?: JsonObject;
33
+ queue?: string;
34
+ retry?: MessageInitShape<typeof RetrySchema>;
35
+ timeoutMs?: number;
36
+ interruptible?: boolean;
37
+ }
38
+ /**
39
+ * A schedule as a service declares it for its tenant at start. Each occurrence of `cron`
40
+ * (read in `timeZone`) starts `job` once per target: one target by default,
41
+ * the stored `enumerate.targets`, or the list the `enumerate.handler`
42
+ * returns at each occurrence (its kv output `targets`; see
43
+ * {@link defineEnumerator}).
44
+ */
45
+ export interface ScheduleDecl {
46
+ /** Unique per tenant and never renamed; convention `<area>.<verb>`. */
47
+ name: string;
48
+ description?: string;
49
+ /** Five-field cron or a descriptor (`@hourly`, `@daily`). Empty is run-now only. */
50
+ cron: string;
51
+ /** The expression in plain words, shown while the declared one applies. */
52
+ cronLabel?: string;
53
+ /** IANA time zone; empty is UTC. */
54
+ timeZone?: string;
55
+ /** Default true. */
56
+ enabled?: boolean;
57
+ job: ScheduleJobDecl;
58
+ enumerate?: {
59
+ handler: string;
60
+ maxTargets?: number;
61
+ } | {
62
+ targets: ScheduleTargetJson[];
63
+ maxTargets?: number;
64
+ };
65
+ /** Default LATEST: after an outage, fire only the most recent missed occurrence within `catchupWindowMs`. */
66
+ misfire?: MisfirePolicy;
67
+ catchupWindowMs?: number;
68
+ /** Fire although a run of the same schedule and target is still pending. Default off. */
69
+ queueWhilePending?: boolean;
70
+ /** Housekeeping whose clean runs a console hides. */
71
+ routine?: boolean;
72
+ }
73
+ /**
74
+ * The client for `SchedulesService`: cron schedules that start jobs (or
75
+ * stored pipelines) at each occurrence, once per target. Needs
76
+ * `pipelines:schedule:edit` / `pipelines:schedule:read`.
77
+ */
78
+ export declare class SchedulesClient {
79
+ /** The generated client, for anything not wrapped here. */
80
+ readonly schedules: Client<typeof SchedulesService>;
81
+ readonly tenant: string;
82
+ private readonly timeoutMs;
83
+ constructor(opts: SchedulesClientOptions);
84
+ /** Sets a schedule (`SetSchedule`), replacing every writable field; an owner's override is kept. */
85
+ setSchedule(decl: ScheduleDecl, signal?: AbortSignal): Promise<{
86
+ schedule: Schedule;
87
+ created: boolean;
88
+ }>;
89
+ /** Reads one schedule (`GetSchedule`), with its next occurrence computed now. */
90
+ getSchedule(ref: {
91
+ id: string;
92
+ } | {
93
+ name: string;
94
+ }, signal?: AbortSignal): Promise<Schedule>;
95
+ /** Lists the tenant's schedules (`ListSchedules`). */
96
+ listSchedules(input?: {
97
+ cursor?: string;
98
+ limit?: number;
99
+ }, signal?: AbortSignal): Promise<{
100
+ schedules: Schedule[];
101
+ nextCursor: string;
102
+ }>;
103
+ /** Overrides a schedule's cron and/or enabled flag (`SetScheduleOverride`); neither clears it. */
104
+ setScheduleOverride(scheduleId: string, override: {
105
+ cron?: string;
106
+ enabled?: boolean;
107
+ }, signal?: AbortSignal): Promise<Schedule>;
108
+ /** Pauses a schedule (`MarkSchedulePaused`). Run-now still works. */
109
+ pauseSchedule(scheduleId: string, signal?: AbortSignal): Promise<Schedule>;
110
+ /** Resumes a paused schedule (`MarkScheduleResumed`). */
111
+ resumeSchedule(scheduleId: string, signal?: AbortSignal): Promise<Schedule>;
112
+ /** Deletes a schedule (`DeleteSchedule`). Idempotent. */
113
+ deleteSchedule(scheduleId: string, signal?: AbortSignal): Promise<void>;
114
+ /** Runs a schedule now (`CreateScheduleRun`), for every target or one. */
115
+ runScheduleNow(scheduleId: string, input?: {
116
+ targetKey?: string;
117
+ force?: boolean;
118
+ }, signal?: AbortSignal): Promise<{
119
+ runs: Run[];
120
+ skipped: number;
121
+ }>;
122
+ /** A schedule's recent and upcoming occurrences (`ListScheduleOccurrences`). */
123
+ listScheduleOccurrences(scheduleId: string, input?: {
124
+ upcoming?: number;
125
+ cursor?: string;
126
+ limit?: number;
127
+ }, signal?: AbortSignal): Promise<ListScheduleOccurrencesResponse>;
128
+ private opts;
129
+ }
130
+ /** Declares a tenant's schedules, typically at start: `SetSchedule` for each. */
131
+ export declare function declareSchedules(client: SchedulesClient, decls: readonly ScheduleDecl[], signal?: AbortSignal): Promise<Schedule[]>;
132
+ /** The SetSchedule message for a declaration. */
133
+ export declare function scheduleInit(tenant: string, d: ScheduleDecl): {
134
+ queueWhilePending: boolean;
135
+ routine: boolean;
136
+ catchupWindow?: import("@bufbuild/protobuf/wkt").Duration;
137
+ misfire: MisfirePolicy;
138
+ enumerate?: {
139
+ maxTargets: number;
140
+ source: {
141
+ case: "handler";
142
+ value: string;
143
+ } | {
144
+ case: "list";
145
+ value: {
146
+ targets: {
147
+ args?: JsonObject;
148
+ resource?: MessageInitShape<typeof ResourceSchema>;
149
+ key: string;
150
+ }[];
151
+ };
152
+ };
153
+ };
154
+ owner: {
155
+ tenant: string;
156
+ };
157
+ name: string;
158
+ description: string;
159
+ cron: string;
160
+ cronLabel: string;
161
+ timeZone: string;
162
+ enabled: boolean;
163
+ target: {
164
+ case: "job";
165
+ value: {
166
+ interruptible: boolean;
167
+ timeout?: import("@bufbuild/protobuf/wkt").Duration;
168
+ retry?: import("./gen/xeonr/pipelines/v1/definition_pb.js").Retry | {
169
+ readonly $typeName?: never;
170
+ max?: number;
171
+ when?: import("./gen/xeonr/pipelines/v1/common_pb.js").FailureClass[];
172
+ backoff?: (import("./gen/xeonr/pipelines/v1/definition_pb.js").Backoff | {
173
+ readonly $typeName?: never;
174
+ initial?: (import("@bufbuild/protobuf/wkt").Duration | {
175
+ readonly $typeName?: never;
176
+ seconds?: bigint;
177
+ nanos?: number;
178
+ }) | undefined;
179
+ max?: (import("@bufbuild/protobuf/wkt").Duration | {
180
+ readonly $typeName?: never;
181
+ seconds?: bigint;
182
+ nanos?: number;
183
+ }) | undefined;
184
+ multiplier?: number;
185
+ }) | undefined;
186
+ };
187
+ queue: string;
188
+ payload?: JsonObject;
189
+ handler: string;
190
+ };
191
+ };
192
+ };
193
+ //# sourceMappingURL=schedules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedules.d.ts","sourceRoot":"","sources":["../src/schedules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGvE,OAAO,KAAK,EAAE,MAAM,EAAa,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC3F,OAAO,KAAK,EAAE,+BAA+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,CAAC,CAIzI;AAED,iDAAiD;AACjD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,YAAY;;;;;;;;;;;;;;;+BA0Cb,gBAAgB,CAAC,OAAO,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EALrF"}
@@ -0,0 +1,126 @@
1
+ import { durationFromMs } from "@bufbuild/protobuf/wkt";
2
+ import { createClient } from "@connectrpc/connect";
3
+ import { MisfirePolicy, SchedulesService } from "./gen/xeonr/pipelines/v1/schedules_pb.js";
4
+ import { transportOf } from "./transport.js";
5
+ /**
6
+ * The client for `SchedulesService`: cron schedules that start jobs (or
7
+ * stored pipelines) at each occurrence, once per target. Needs
8
+ * `pipelines:schedule:edit` / `pipelines:schedule:read`.
9
+ */
10
+ export class SchedulesClient {
11
+ /** The generated client, for anything not wrapped here. */
12
+ schedules;
13
+ tenant;
14
+ timeoutMs;
15
+ constructor(opts) {
16
+ const transport = transportOf(opts);
17
+ this.schedules = createClient(SchedulesService, transport);
18
+ if (!opts.tenant)
19
+ throw new TypeError("SchedulesClient: tenant is required");
20
+ this.tenant = opts.tenant;
21
+ this.timeoutMs = opts.timeoutMs ?? 30_000;
22
+ }
23
+ /** Sets a schedule (`SetSchedule`), replacing every writable field; an owner's override is kept. */
24
+ async setSchedule(decl, signal) {
25
+ const res = await this.schedules.setSchedule({ schedule: scheduleInit(this.tenant, decl) }, this.opts(signal));
26
+ return { schedule: required(res.schedule), created: res.created };
27
+ }
28
+ /** Reads one schedule (`GetSchedule`), with its next occurrence computed now. */
29
+ async getSchedule(ref, signal) {
30
+ const schedule = "id" in ref
31
+ ? { case: "scheduleId", value: ref.id }
32
+ : { case: "byName", value: { owner: { tenant: this.tenant }, name: ref.name } };
33
+ return required((await this.schedules.getSchedule({ schedule }, this.opts(signal))).schedule);
34
+ }
35
+ /** Lists the tenant's schedules (`ListSchedules`). */
36
+ async listSchedules(input = {}, signal) {
37
+ const res = await this.schedules.listSchedules({ tenant: this.tenant, cursor: input.cursor ?? "", limit: input.limit ?? 0 }, this.opts(signal));
38
+ return { schedules: res.schedules, nextCursor: res.nextCursor };
39
+ }
40
+ /** Overrides a schedule's cron and/or enabled flag (`SetScheduleOverride`); neither clears it. */
41
+ async setScheduleOverride(scheduleId, override, signal) {
42
+ return required((await this.schedules.setScheduleOverride({ scheduleId, ...(override.cron !== undefined ? { cron: override.cron } : {}), ...(override.enabled !== undefined ? { enabled: override.enabled } : {}) }, this.opts(signal))).schedule);
43
+ }
44
+ /** Pauses a schedule (`MarkSchedulePaused`). Run-now still works. */
45
+ async pauseSchedule(scheduleId, signal) {
46
+ return required((await this.schedules.markSchedulePaused({ scheduleId }, this.opts(signal))).schedule);
47
+ }
48
+ /** Resumes a paused schedule (`MarkScheduleResumed`). */
49
+ async resumeSchedule(scheduleId, signal) {
50
+ return required((await this.schedules.markScheduleResumed({ scheduleId }, this.opts(signal))).schedule);
51
+ }
52
+ /** Deletes a schedule (`DeleteSchedule`). Idempotent. */
53
+ async deleteSchedule(scheduleId, signal) {
54
+ await this.schedules.deleteSchedule({ scheduleId }, this.opts(signal));
55
+ }
56
+ /** Runs a schedule now (`CreateScheduleRun`), for every target or one. */
57
+ async runScheduleNow(scheduleId, input = {}, signal) {
58
+ const res = await this.schedules.createScheduleRun({ scheduleId, targetKey: input.targetKey ?? "", force: input.force ?? false }, this.opts(signal));
59
+ return { runs: res.runs, skipped: res.skipped };
60
+ }
61
+ /** A schedule's recent and upcoming occurrences (`ListScheduleOccurrences`). */
62
+ async listScheduleOccurrences(scheduleId, input = {}, signal) {
63
+ return this.schedules.listScheduleOccurrences({ scheduleId, upcoming: input.upcoming ?? 0, cursor: input.cursor ?? "", limit: input.limit ?? 0 }, this.opts(signal));
64
+ }
65
+ opts(signal) {
66
+ return { timeoutMs: this.timeoutMs, ...(signal ? { signal } : {}) };
67
+ }
68
+ }
69
+ /** Declares a tenant's schedules, typically at start: `SetSchedule` for each. */
70
+ export async function declareSchedules(client, decls, signal) {
71
+ const out = [];
72
+ for (const d of decls)
73
+ out.push((await client.setSchedule(d, signal)).schedule);
74
+ return out;
75
+ }
76
+ /** The SetSchedule message for a declaration. */
77
+ export function scheduleInit(tenant, d) {
78
+ const job = d.job;
79
+ return {
80
+ owner: { tenant },
81
+ name: d.name,
82
+ description: d.description ?? "",
83
+ cron: d.cron,
84
+ cronLabel: d.cronLabel ?? "",
85
+ timeZone: d.timeZone ?? "",
86
+ enabled: d.enabled ?? true,
87
+ target: {
88
+ case: "job",
89
+ value: {
90
+ handler: job.handler,
91
+ ...(job.payload ? { payload: job.payload } : {}),
92
+ queue: job.queue ?? "",
93
+ ...(job.retry ? { retry: job.retry } : {}),
94
+ ...(job.timeoutMs ? { timeout: durationFromMs(job.timeoutMs) } : {}),
95
+ interruptible: job.interruptible ?? false,
96
+ },
97
+ },
98
+ ...(d.enumerate
99
+ ? {
100
+ enumerate: {
101
+ maxTargets: d.enumerate.maxTargets ?? 0,
102
+ source: "handler" in d.enumerate
103
+ ? { case: "handler", value: d.enumerate.handler }
104
+ : { case: "list", value: { targets: d.enumerate.targets.map(targetInit) } },
105
+ },
106
+ }
107
+ : {}),
108
+ misfire: d.misfire ?? MisfirePolicy.UNSPECIFIED,
109
+ ...(d.catchupWindowMs ? { catchupWindow: durationFromMs(d.catchupWindowMs) } : {}),
110
+ queueWhilePending: d.queueWhilePending ?? false,
111
+ routine: d.routine ?? false,
112
+ };
113
+ }
114
+ function targetInit(t) {
115
+ return {
116
+ key: t.key,
117
+ ...(t.resource ? { resource: t.resource } : {}),
118
+ ...(t.args ? { args: t.args } : {}),
119
+ };
120
+ }
121
+ function required(v) {
122
+ if (v === undefined)
123
+ throw new Error("pipelines-api answered without the schedule");
124
+ return v;
125
+ }
126
+ //# sourceMappingURL=schedules.js.map