@xeonr/pipelines-sdk 0.0.0-stage → 0.1.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 (102) hide show
  1. package/README.md +267 -2
  2. package/dist/auth.d.ts +72 -0
  3. package/dist/auth.d.ts.map +1 -0
  4. package/dist/auth.js +139 -0
  5. package/dist/auth.js.map +1 -0
  6. package/dist/client.d.ts +118 -0
  7. package/dist/client.d.ts.map +1 -0
  8. package/dist/client.js +101 -0
  9. package/dist/client.js.map +1 -0
  10. package/dist/errors.d.ts +77 -0
  11. package/dist/errors.d.ts.map +1 -0
  12. package/dist/errors.js +72 -0
  13. package/dist/errors.js.map +1 -0
  14. package/dist/gen/buf/validate/validate_pb.d.ts +4828 -0
  15. package/dist/gen/buf/validate/validate_pb.d.ts.map +1 -0
  16. package/dist/gen/buf/validate/validate_pb.js +357 -0
  17. package/dist/gen/buf/validate/validate_pb.js.map +1 -0
  18. package/dist/gen/gnostic/openapi/v3/annotations_pb.d.ts +24 -0
  19. package/dist/gen/gnostic/openapi/v3/annotations_pb.d.ts.map +1 -0
  20. package/dist/gen/gnostic/openapi/v3/annotations_pb.js +37 -0
  21. package/dist/gen/gnostic/openapi/v3/annotations_pb.js.map +1 -0
  22. package/dist/gen/gnostic/openapi/v3/openapiv3_pb.d.ts +2245 -0
  23. package/dist/gen/gnostic/openapi/v3/openapiv3_pb.d.ts.map +1 -0
  24. package/dist/gen/gnostic/openapi/v3/openapiv3_pb.js +410 -0
  25. package/dist/gen/gnostic/openapi/v3/openapiv3_pb.js.map +1 -0
  26. package/dist/gen/xeonr/pipelines/private/v1/attempt_pb.d.ts +1031 -0
  27. package/dist/gen/xeonr/pipelines/private/v1/attempt_pb.d.ts.map +1 -0
  28. package/dist/gen/xeonr/pipelines/private/v1/attempt_pb.js +219 -0
  29. package/dist/gen/xeonr/pipelines/private/v1/attempt_pb.js.map +1 -0
  30. package/dist/gen/xeonr/pipelines/private/v1/runners_pb.d.ts +190 -0
  31. package/dist/gen/xeonr/pipelines/private/v1/runners_pb.d.ts.map +1 -0
  32. package/dist/gen/xeonr/pipelines/private/v1/runners_pb.js +53 -0
  33. package/dist/gen/xeonr/pipelines/private/v1/runners_pb.js.map +1 -0
  34. package/dist/gen/xeonr/pipelines/private/v1/step_local_pb.d.ts +1161 -0
  35. package/dist/gen/xeonr/pipelines/private/v1/step_local_pb.d.ts.map +1 -0
  36. package/dist/gen/xeonr/pipelines/private/v1/step_local_pb.js +269 -0
  37. package/dist/gen/xeonr/pipelines/private/v1/step_local_pb.js.map +1 -0
  38. package/dist/gen/xeonr/pipelines/private/v1/worker_pb.d.ts +915 -0
  39. package/dist/gen/xeonr/pipelines/private/v1/worker_pb.d.ts.map +1 -0
  40. package/dist/gen/xeonr/pipelines/private/v1/worker_pb.js +159 -0
  41. package/dist/gen/xeonr/pipelines/private/v1/worker_pb.js.map +1 -0
  42. package/dist/gen/xeonr/pipelines/v1/common_pb.d.ts +550 -0
  43. package/dist/gen/xeonr/pipelines/v1/common_pb.d.ts.map +1 -0
  44. package/dist/gen/xeonr/pipelines/v1/common_pb.js +453 -0
  45. package/dist/gen/xeonr/pipelines/v1/common_pb.js.map +1 -0
  46. package/dist/gen/xeonr/pipelines/v1/definition_pb.d.ts +760 -0
  47. package/dist/gen/xeonr/pipelines/v1/definition_pb.d.ts.map +1 -0
  48. package/dist/gen/xeonr/pipelines/v1/definition_pb.js +190 -0
  49. package/dist/gen/xeonr/pipelines/v1/definition_pb.js.map +1 -0
  50. package/dist/gen/xeonr/pipelines/v1/pools_pb.d.ts +800 -0
  51. package/dist/gen/xeonr/pipelines/v1/pools_pb.d.ts.map +1 -0
  52. package/dist/gen/xeonr/pipelines/v1/pools_pb.js +247 -0
  53. package/dist/gen/xeonr/pipelines/v1/pools_pb.js.map +1 -0
  54. package/dist/gen/xeonr/pipelines/v1/registry_pb.d.ts +895 -0
  55. package/dist/gen/xeonr/pipelines/v1/registry_pb.d.ts.map +1 -0
  56. package/dist/gen/xeonr/pipelines/v1/registry_pb.js +277 -0
  57. package/dist/gen/xeonr/pipelines/v1/registry_pb.js.map +1 -0
  58. package/dist/gen/xeonr/pipelines/v1/runs_pb.d.ts +1217 -0
  59. package/dist/gen/xeonr/pipelines/v1/runs_pb.d.ts.map +1 -0
  60. package/dist/gen/xeonr/pipelines/v1/runs_pb.js +204 -0
  61. package/dist/gen/xeonr/pipelines/v1/runs_pb.js.map +1 -0
  62. package/dist/gen/xeonr/pipelines/v1/secrets_pb.d.ts +642 -0
  63. package/dist/gen/xeonr/pipelines/v1/secrets_pb.d.ts.map +1 -0
  64. package/dist/gen/xeonr/pipelines/v1/secrets_pb.js +181 -0
  65. package/dist/gen/xeonr/pipelines/v1/secrets_pb.js.map +1 -0
  66. package/dist/gen/xeonr/pipelines/v1/sinks_pb.d.ts +381 -0
  67. package/dist/gen/xeonr/pipelines/v1/sinks_pb.d.ts.map +1 -0
  68. package/dist/gen/xeonr/pipelines/v1/sinks_pb.js +145 -0
  69. package/dist/gen/xeonr/pipelines/v1/sinks_pb.js.map +1 -0
  70. package/dist/gen/xeonr/platform/v1/options_pb.d.ts +313 -0
  71. package/dist/gen/xeonr/platform/v1/options_pb.d.ts.map +1 -0
  72. package/dist/gen/xeonr/platform/v1/options_pb.js +235 -0
  73. package/dist/gen/xeonr/platform/v1/options_pb.js.map +1 -0
  74. package/dist/handler.d.ts +94 -0
  75. package/dist/handler.d.ts.map +1 -0
  76. package/dist/handler.js +18 -0
  77. package/dist/handler.js.map +1 -0
  78. package/dist/index.d.ts +29 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +23 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/internal/time.d.ts +8 -0
  83. package/dist/internal/time.d.ts.map +1 -0
  84. package/dist/internal/time.js +25 -0
  85. package/dist/internal/time.js.map +1 -0
  86. package/dist/logship.d.ts +67 -0
  87. package/dist/logship.d.ts.map +1 -0
  88. package/dist/logship.js +176 -0
  89. package/dist/logship.js.map +1 -0
  90. package/dist/testing/index.d.ts +202 -0
  91. package/dist/testing/index.d.ts.map +1 -0
  92. package/dist/testing/index.js +909 -0
  93. package/dist/testing/index.js.map +1 -0
  94. package/dist/transport.d.ts +43 -0
  95. package/dist/transport.d.ts.map +1 -0
  96. package/dist/transport.js +44 -0
  97. package/dist/transport.js.map +1 -0
  98. package/dist/worker.d.ts +213 -0
  99. package/dist/worker.d.ts.map +1 -0
  100. package/dist/worker.js +664 -0
  101. package/dist/worker.js.map +1 -0
  102. package/package.json +70 -3
package/dist/client.js ADDED
@@ -0,0 +1,101 @@
1
+ import { create } from "@bufbuild/protobuf";
2
+ import { durationFromMs } from "@bufbuild/protobuf/wkt";
3
+ import { createClient } from "@connectrpc/connect";
4
+ import { DefinitionSchema } from "./gen/xeonr/pipelines/v1/definition_pb.js";
5
+ import { RunsService } from "./gen/xeonr/pipelines/v1/runs_pb.js";
6
+ import { transportOf } from "./transport.js";
7
+ /**
8
+ * The public-API client a product uses to start runs and jobs and to read
9
+ * what became of them (`RunsService`). It calls with the product's Auth
10
+ * service-account token (scopes `pipelines:run:edit` and
11
+ * `pipelines:run:read`).
12
+ *
13
+ * Every method is a single RPC; errors are the API's `ConnectError`s,
14
+ * classified by {@link errorKind}.
15
+ */
16
+ export class PipelinesClient {
17
+ /** The generated RunsService client, for anything not wrapped here. */
18
+ runs;
19
+ /** The transport, to build other generated clients on. */
20
+ transport;
21
+ timeoutMs;
22
+ constructor(opts) {
23
+ this.transport = transportOf(opts);
24
+ this.runs = createClient(RunsService, this.transport);
25
+ this.timeoutMs = opts.timeoutMs ?? 30_000;
26
+ }
27
+ /**
28
+ * Creates a run of a definition (`CreateRun`). Worker nodes name a handler
29
+ * (`{ id, action: { case: "handler", value: "acme/resize" } }`); they mix
30
+ * freely with image nodes in one run.
31
+ */
32
+ async createRun(input, signal) {
33
+ const res = await this.runs.createRun({
34
+ idempotencyKey: input.idempotencyKey,
35
+ tenant: input.tenant,
36
+ resource: resource(input.resource),
37
+ source: { case: "inlineDefinition", value: create(DefinitionSchema, input.definition) },
38
+ ...(input.attestedFacts ? { attestedFacts: input.attestedFacts } : {}),
39
+ ...(input.variables ? { variables: input.variables } : {}),
40
+ ...(input.exclusion ? { exclusion: input.exclusion } : {}),
41
+ }, this.opts(signal));
42
+ return { run: required(res.run), deduplicated: res.deduplicated };
43
+ }
44
+ /**
45
+ * Enqueues a job: one run of one worker handler (`CreateJob`, the plan's
46
+ * `EnqueueJob`). With `delayMs` it stays `QUEUED` and is not offered to a
47
+ * worker before the delay has passed.
48
+ */
49
+ async createJob(input, signal) {
50
+ if (input.delayMs !== undefined && (input.delayMs < 0 || !Number.isFinite(input.delayMs))) {
51
+ throw new RangeError("createJob: delayMs must be a finite, non-negative number");
52
+ }
53
+ const res = await this.runs.createJob({
54
+ tenant: input.tenant,
55
+ handler: input.handler,
56
+ idempotencyKey: input.idempotencyKey,
57
+ ...(input.payload ? { payload: input.payload } : {}),
58
+ ...(input.delayMs ? { delay: durationFromMs(input.delayMs) } : {}),
59
+ ...(input.resource ? { resource: resource(input.resource) } : {}),
60
+ }, this.opts(signal));
61
+ return { run: required(res.run), deduplicated: res.deduplicated };
62
+ }
63
+ /** Reads one run (`GetRun`). */
64
+ async getRun(runId, signal) {
65
+ return required((await this.runs.getRun({ runId }, this.opts(signal))).run);
66
+ }
67
+ /** Reads a run with its frozen definition and every node's attempts and outputs (`GetRunGraph`). */
68
+ async getRunGraph(runId, signal) {
69
+ return this.runs.getRunGraph({ runId }, this.opts(signal));
70
+ }
71
+ /** Lists a tenant's runs, newest first (`ListRuns`). */
72
+ async listRuns(input, signal) {
73
+ const res = await this.runs.listRuns({
74
+ tenant: input.tenant,
75
+ ...(input.resource ? { resource: input.resource } : {}),
76
+ ...(input.states ? { states: input.states } : {}),
77
+ ...(input.cursor ? { cursor: input.cursor } : {}),
78
+ ...(input.limit ? { limit: input.limit } : {}),
79
+ }, this.opts(signal));
80
+ return { runs: res.runs, nextCursor: res.nextCursor };
81
+ }
82
+ /**
83
+ * Asks a run to stop (`CancelRun`). Running attempts are told on their next
84
+ * heartbeat; an SDK worker aborts the handler's signal. Idempotent.
85
+ */
86
+ async cancelRun(runId, reason, signal) {
87
+ return required((await this.runs.cancelRun({ runId, ...(reason ? { reason } : {}) }, this.opts(signal))).run);
88
+ }
89
+ opts(signal) {
90
+ return { timeoutMs: this.timeoutMs, ...(signal ? { signal } : {}) };
91
+ }
92
+ }
93
+ function resource(r) {
94
+ return { kind: r.kind, id: r.id, ...(r.json ? { json: r.json } : {}) };
95
+ }
96
+ function required(run) {
97
+ if (!run)
98
+ throw new Error("pipelines-api answered without a run");
99
+ return run;
100
+ }
101
+ //# sourceMappingURL=client.js.map
@@ -0,0 +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;AAInD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA8D7C;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IAC1B,uEAAuE;IAC9D,IAAI,CAA6B;IAC1C,0DAA0D;IACjD,SAAS,CAAY;IACb,SAAS,CAAS;IAEnC,YAAY,IAA4B;QACtC,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,KAAK,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AE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACtE,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,CAAkD;IAClE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACzE,CAAC;AAED,SAAS,QAAQ,CAAC,GAAoB;IACpC,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAClE,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * How the SDK treats an error from pipelines-api, decided by its Connect
3
+ * code. The rules are the API's (WorkerService's comments, and what the api
4
+ * and runner sessions settled):
5
+ *
6
+ * - `lost`: `failed_precondition`. The attempt is no longer this worker's
7
+ * (abandoned, re-offered, completed, or cancelled before it started). Stop
8
+ * work on it and report nothing more.
9
+ * - `final`: `invalid_argument`, `not_found`, `already_exists`,
10
+ * `unimplemented`, `out_of_range`. Repeating the same request cannot
11
+ * succeed; the caller decides what that means for its operation (for
12
+ * `out_of_range` on AppendLogs, it is not fatal to the attempt).
13
+ * - `auth`: `unauthenticated`, `permission_denied`. Not transient: the
14
+ * credential or its scopes are wrong. A worker stops claiming and surfaces
15
+ * it.
16
+ * - `aborted`: the caller's own signal ended the call.
17
+ * - `transient`: everything else (`unavailable`, `deadline_exceeded`,
18
+ * `internal`, `resource_exhausted`, `aborted` from the server, network
19
+ * failures). Retried with backoff.
20
+ */
21
+ export type ErrorKind = "lost" | "final" | "auth" | "aborted" | "transient";
22
+ /** Classifies an error thrown by a pipelines-api call. */
23
+ export declare function errorKind(err: unknown): ErrorKind;
24
+ /**
25
+ * Thrown by a token provider when Auth's token endpoint refuses or cannot be
26
+ * read. It carries the HTTP status and the OAuth error code only, never the
27
+ * response body (log.no-secrets).
28
+ */
29
+ export declare class PipelinesAuthError extends Error {
30
+ /** The HTTP status of the token endpoint, when it answered. */
31
+ readonly status?: number | undefined;
32
+ /** The OAuth `error` code (`invalid_grant`, ...), when one was given. */
33
+ readonly oauthError?: string | undefined;
34
+ readonly name = "PipelinesAuthError";
35
+ constructor(message: string,
36
+ /** The HTTP status of the token endpoint, when it answered. */
37
+ status?: number | undefined,
38
+ /** The OAuth `error` code (`invalid_grant`, ...), when one was given. */
39
+ oauthError?: string | undefined, options?: ErrorOptions);
40
+ }
41
+ /**
42
+ * The reason an attempt's `AbortSignal` fires. Read it from `signal.reason`
43
+ * in a handler to tell why it is being asked to stop.
44
+ */
45
+ export declare class AttemptAbortedError extends Error {
46
+ /**
47
+ * - `cancelled`: a heartbeat answered cancel (the run was cancelled or the
48
+ * attempt superseded). Return or throw promptly; the cancel grace
49
+ * applies.
50
+ * - `deadline`: the attempt's timeout passed.
51
+ * - `lost`: the attempt is no longer this worker's (lease lost). Nothing
52
+ * the handler returns is reported.
53
+ * - `shutdown`: the worker is stopping and its shutdown timeout passed.
54
+ * The attempt is completed as a worker failure, which the platform
55
+ * retries by default.
56
+ */
57
+ readonly cause: "cancelled" | "deadline" | "lost" | "shutdown";
58
+ readonly name = "AttemptAbortedError";
59
+ constructor(
60
+ /**
61
+ * - `cancelled`: a heartbeat answered cancel (the run was cancelled or the
62
+ * attempt superseded). Return or throw promptly; the cancel grace
63
+ * applies.
64
+ * - `deadline`: the attempt's timeout passed.
65
+ * - `lost`: the attempt is no longer this worker's (lease lost). Nothing
66
+ * the handler returns is reported.
67
+ * - `shutdown`: the worker is stopping and its shutdown timeout passed.
68
+ * The attempt is completed as a worker failure, which the platform
69
+ * retries by default.
70
+ */
71
+ cause: "cancelled" | "deadline" | "lost" | "shutdown", message: string);
72
+ }
73
+ /** Thrown by `Worker.start` when the worker cannot boot (registration failed). */
74
+ export declare class WorkerStartError extends Error {
75
+ readonly name = "WorkerStartError";
76
+ }
77
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,CAAC;AAE5E,0DAA0D;AAC1D,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAoBjD;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAIzC,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;IACxB,yEAAyE;IACzE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM;IAN9B,SAAkB,IAAI,wBAAwB;gBAE5C,OAAO,EAAE,MAAM;IACf,+DAA+D;IACtD,MAAM,CAAC,EAAE,MAAM,YAAA;IACxB,yEAAyE;IAChE,UAAU,CAAC,EAAE,MAAM,YAAA,EAC5B,OAAO,CAAC,EAAE,YAAY;CAIzB;AAED;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAG1C;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU;IAbhE,SAAkB,IAAI,yBAAyB;;IAE7C;;;;;;;;;;OAUG;IACM,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,EAC9D,OAAO,EAAE,MAAM;CAIlB;AAED,kFAAkF;AAClF,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAkB,IAAI,sBAAsB;CAC7C"}
package/dist/errors.js ADDED
@@ -0,0 +1,72 @@
1
+ import { Code, ConnectError } from "@connectrpc/connect";
2
+ /** Classifies an error thrown by a pipelines-api call. */
3
+ export function errorKind(err) {
4
+ if (err instanceof PipelinesAuthError)
5
+ return "auth";
6
+ const ce = ConnectError.from(err);
7
+ switch (ce.code) {
8
+ case Code.FailedPrecondition:
9
+ return "lost";
10
+ case Code.InvalidArgument:
11
+ case Code.NotFound:
12
+ case Code.AlreadyExists:
13
+ case Code.Unimplemented:
14
+ case Code.OutOfRange:
15
+ return "final";
16
+ case Code.Unauthenticated:
17
+ case Code.PermissionDenied:
18
+ return "auth";
19
+ case Code.Canceled:
20
+ return "aborted";
21
+ default:
22
+ return "transient";
23
+ }
24
+ }
25
+ /**
26
+ * Thrown by a token provider when Auth's token endpoint refuses or cannot be
27
+ * read. It carries the HTTP status and the OAuth error code only, never the
28
+ * response body (log.no-secrets).
29
+ */
30
+ export class PipelinesAuthError extends Error {
31
+ status;
32
+ oauthError;
33
+ name = "PipelinesAuthError";
34
+ constructor(message,
35
+ /** The HTTP status of the token endpoint, when it answered. */
36
+ status,
37
+ /** The OAuth `error` code (`invalid_grant`, ...), when one was given. */
38
+ oauthError, options) {
39
+ super(message, options);
40
+ this.status = status;
41
+ this.oauthError = oauthError;
42
+ }
43
+ }
44
+ /**
45
+ * The reason an attempt's `AbortSignal` fires. Read it from `signal.reason`
46
+ * in a handler to tell why it is being asked to stop.
47
+ */
48
+ export class AttemptAbortedError extends Error {
49
+ cause;
50
+ name = "AttemptAbortedError";
51
+ constructor(
52
+ /**
53
+ * - `cancelled`: a heartbeat answered cancel (the run was cancelled or the
54
+ * attempt superseded). Return or throw promptly; the cancel grace
55
+ * applies.
56
+ * - `deadline`: the attempt's timeout passed.
57
+ * - `lost`: the attempt is no longer this worker's (lease lost). Nothing
58
+ * the handler returns is reported.
59
+ * - `shutdown`: the worker is stopping and its shutdown timeout passed.
60
+ * The attempt is completed as a worker failure, which the platform
61
+ * retries by default.
62
+ */
63
+ cause, message) {
64
+ super(message);
65
+ this.cause = cause;
66
+ }
67
+ }
68
+ /** Thrown by `Worker.start` when the worker cannot boot (registration failed). */
69
+ export class WorkerStartError extends Error {
70
+ name = "WorkerStartError";
71
+ }
72
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAwBzD,0DAA0D;AAC1D,MAAM,UAAU,SAAS,CAAC,GAAY;IACpC,IAAI,GAAG,YAAY,kBAAkB;QAAE,OAAO,MAAM,CAAC;IACrD,MAAM,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;QAChB,KAAK,IAAI,CAAC,kBAAkB;YAC1B,OAAO,MAAM,CAAC;QAChB,KAAK,IAAI,CAAC,eAAe,CAAC;QAC1B,KAAK,IAAI,CAAC,QAAQ,CAAC;QACnB,KAAK,IAAI,CAAC,aAAa,CAAC;QACxB,KAAK,IAAI,CAAC,aAAa,CAAC;QACxB,KAAK,IAAI,CAAC,UAAU;YAClB,OAAO,OAAO,CAAC;QACjB,KAAK,IAAI,CAAC,eAAe,CAAC;QAC1B,KAAK,IAAI,CAAC,gBAAgB;YACxB,OAAO,MAAM,CAAC;QAChB,KAAK,IAAI,CAAC,QAAQ;YAChB,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,WAAW,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAKhC;IAEA;IANO,IAAI,GAAG,oBAAoB,CAAC;IAC9C,YACE,OAAe;IACf,+DAA+D;IACtD,MAAe;IACxB,yEAAyE;IAChE,UAAmB,EAC5B,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QALf,WAAM,GAAN,MAAM,CAAS;QAEf,eAAU,GAAV,UAAU,CAAS;IAI9B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM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