duron 0.3.0-beta.10 → 0.3.0-beta.12
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/action-job.d.ts +33 -2
- package/dist/action-job.d.ts.map +1 -1
- package/dist/action-job.js +87 -22
- package/dist/action-manager.d.ts +44 -2
- package/dist/action-manager.d.ts.map +1 -1
- package/dist/action-manager.js +64 -3
- package/dist/action.d.ts +146 -3
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +131 -0
- package/dist/adapters/adapter.d.ts +365 -8
- package/dist/adapters/adapter.d.ts.map +1 -1
- package/dist/adapters/adapter.js +221 -15
- package/dist/adapters/postgres/base.d.ts +174 -5
- package/dist/adapters/postgres/base.d.ts.map +1 -1
- package/dist/adapters/postgres/base.js +349 -66
- package/dist/adapters/postgres/pglite.d.ts +37 -0
- package/dist/adapters/postgres/pglite.d.ts.map +1 -1
- package/dist/adapters/postgres/pglite.js +38 -0
- package/dist/adapters/postgres/postgres.d.ts +35 -0
- package/dist/adapters/postgres/postgres.d.ts.map +1 -1
- package/dist/adapters/postgres/postgres.js +42 -0
- package/dist/adapters/postgres/schema.d.ts +118 -35
- package/dist/adapters/postgres/schema.d.ts.map +1 -1
- package/dist/adapters/postgres/schema.default.d.ts +119 -36
- package/dist/adapters/postgres/schema.default.d.ts.map +1 -1
- package/dist/adapters/postgres/schema.default.js +2 -2
- package/dist/adapters/postgres/schema.js +55 -22
- package/dist/adapters/schemas.d.ts +107 -80
- package/dist/adapters/schemas.d.ts.map +1 -1
- package/dist/adapters/schemas.js +131 -26
- package/dist/client.d.ts +315 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +391 -21
- package/dist/constants.js +6 -0
- package/dist/errors.d.ts +119 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +111 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/server.d.ts +91 -37
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +81 -25
- package/dist/step-manager.d.ts +111 -4
- package/dist/step-manager.d.ts.map +1 -1
- package/dist/step-manager.js +340 -69
- package/dist/telemetry/adapter.d.ts +322 -0
- package/dist/telemetry/adapter.d.ts.map +1 -1
- package/dist/telemetry/adapter.js +145 -0
- package/dist/telemetry/index.d.ts +1 -4
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +2 -4
- package/dist/telemetry/local-span-exporter.d.ts +56 -0
- package/dist/telemetry/local-span-exporter.d.ts.map +1 -0
- package/dist/telemetry/local-span-exporter.js +118 -0
- package/dist/telemetry/local.d.ts +48 -0
- package/dist/telemetry/local.d.ts.map +1 -1
- package/dist/telemetry/local.js +102 -0
- package/dist/telemetry/noop.d.ts +10 -0
- package/dist/telemetry/noop.d.ts.map +1 -1
- package/dist/telemetry/noop.js +43 -0
- package/dist/telemetry/opentelemetry.d.ts +23 -0
- package/dist/telemetry/opentelemetry.d.ts.map +1 -1
- package/dist/telemetry/opentelemetry.js +39 -0
- package/dist/utils/p-retry.d.ts +5 -0
- package/dist/utils/p-retry.d.ts.map +1 -1
- package/dist/utils/p-retry.js +8 -0
- package/dist/utils/wait-for-abort.d.ts +1 -0
- package/dist/utils/wait-for-abort.d.ts.map +1 -1
- package/dist/utils/wait-for-abort.js +1 -0
- package/migrations/postgres/{20260119153838_flimsy_thor_girl → 20260120154151_mean_magdalene}/migration.sql +27 -19
- package/migrations/postgres/{20260119153838_flimsy_thor_girl → 20260120154151_mean_magdalene}/snapshot.json +172 -65
- package/package.json +7 -2
- package/src/action-job.ts +32 -28
- package/src/action-manager.ts +5 -5
- package/src/action.ts +7 -7
- package/src/adapters/adapter.ts +54 -54
- package/src/adapters/postgres/base.ts +140 -77
- package/src/adapters/postgres/schema.default.ts +2 -2
- package/src/adapters/postgres/schema.ts +47 -23
- package/src/adapters/schemas.ts +83 -36
- package/src/client.ts +195 -42
- package/src/index.ts +1 -0
- package/src/server.ts +37 -37
- package/src/step-manager.ts +170 -86
- package/src/telemetry/index.ts +2 -20
- package/src/telemetry/local-span-exporter.ts +148 -0
- package/src/telemetry/adapter.ts +0 -642
- package/src/telemetry/local.ts +0 -429
- package/src/telemetry/noop.ts +0 -141
- package/src/telemetry/opentelemetry.ts +0 -453
package/dist/client.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import { type Span, type Tracer } from '@opentelemetry/api';
|
|
2
|
+
import { type SpanExporter, type SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
1
3
|
import pino, { type Logger } from 'pino';
|
|
2
4
|
import * as z from 'zod';
|
|
3
5
|
import type { Action } from './action.js';
|
|
4
|
-
import type { Adapter, GetActionsResult, GetJobStepsOptions, GetJobStepsResult, GetJobsOptions, GetJobsResult,
|
|
6
|
+
import type { Adapter, GetActionsResult, GetJobStepsOptions, GetJobStepsResult, GetJobsOptions, GetJobsResult, GetSpansOptions, GetSpansResult, Job, JobStep } from './adapters/adapter.js';
|
|
5
7
|
import type { JobStatusResult, JobStepStatusResult } from './adapters/schemas.js';
|
|
6
8
|
import { type JobStatus } from './constants.js';
|
|
7
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Extracts the inferred type from an action's input/output schema.
|
|
11
|
+
* Handles the case where the schema might be undefined.
|
|
12
|
+
*/
|
|
8
13
|
type InferActionSchema<T> = T extends z.ZodTypeAny ? z.infer<T> : Record<string, unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* Result returned from waitForJob with untyped input and output.
|
|
16
|
+
*/
|
|
9
17
|
export interface JobResult {
|
|
10
|
-
|
|
18
|
+
id: string;
|
|
11
19
|
actionName: string;
|
|
12
20
|
status: JobStatus;
|
|
13
21
|
groupKey: string;
|
|
@@ -15,8 +23,11 @@ export interface JobResult {
|
|
|
15
23
|
output: unknown;
|
|
16
24
|
error: Job['error'];
|
|
17
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Result returned from runActionAndWait with typed input and output based on the action's Zod schemas.
|
|
28
|
+
*/
|
|
18
29
|
export interface TypedJobResult<TAction extends Action<any, any, any>> {
|
|
19
|
-
|
|
30
|
+
id: string;
|
|
20
31
|
actionName: string;
|
|
21
32
|
status: JobStatus;
|
|
22
33
|
groupKey: string;
|
|
@@ -24,6 +35,71 @@ export interface TypedJobResult<TAction extends Action<any, any, any>> {
|
|
|
24
35
|
output: InferActionSchema<NonNullable<TAction['output']>>;
|
|
25
36
|
error: Job['error'];
|
|
26
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Telemetry context provided to action and step handlers.
|
|
40
|
+
* Provides access to OpenTelemetry APIs for recording traces and metrics.
|
|
41
|
+
*/
|
|
42
|
+
export interface TelemetryContext {
|
|
43
|
+
/**
|
|
44
|
+
* Get the active OpenTelemetry span for the current job/step.
|
|
45
|
+
* Use standard OTel Span methods: setAttribute, addEvent, recordException, etc.
|
|
46
|
+
*/
|
|
47
|
+
getActiveSpan(): Span;
|
|
48
|
+
/**
|
|
49
|
+
* Get an OpenTelemetry tracer for creating custom spans.
|
|
50
|
+
*
|
|
51
|
+
* @param name - The name of the tracer (typically your service or library name)
|
|
52
|
+
*/
|
|
53
|
+
getTracer(name: string): Tracer;
|
|
54
|
+
/**
|
|
55
|
+
* Record a custom metric as a span event.
|
|
56
|
+
* This is a convenience method that stores metrics as span events
|
|
57
|
+
* which can be queried from the local database when telemetry.local is enabled.
|
|
58
|
+
*
|
|
59
|
+
* @param name - The metric name (e.g., 'tokens.input', 'latency.ms')
|
|
60
|
+
* @param value - The metric value
|
|
61
|
+
* @param attributes - Optional attributes for the metric
|
|
62
|
+
*/
|
|
63
|
+
recordMetric(name: string, value: number, attributes?: Record<string, any>): void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Options for local telemetry storage.
|
|
67
|
+
*/
|
|
68
|
+
export interface LocalTelemetryOptions {
|
|
69
|
+
/**
|
|
70
|
+
* Delay in milliseconds before flushing spans to the database.
|
|
71
|
+
* Uses BatchSpanProcessor with this delay.
|
|
72
|
+
* @default 5000
|
|
73
|
+
*/
|
|
74
|
+
flushDelayMs?: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Telemetry configuration options.
|
|
78
|
+
* Uses OpenTelemetry SDK for tracing.
|
|
79
|
+
*/
|
|
80
|
+
export interface TelemetryOptions {
|
|
81
|
+
/**
|
|
82
|
+
* Enable local span storage in the database.
|
|
83
|
+
* When enabled, spans are stored in the database and can be queried via getSpans().
|
|
84
|
+
* Set to true for default options, or provide LocalTelemetryOptions for custom config.
|
|
85
|
+
*/
|
|
86
|
+
local?: LocalTelemetryOptions | boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Additional span processors to add to the tracer provider.
|
|
89
|
+
* These are merged with the local processor (if enabled).
|
|
90
|
+
*/
|
|
91
|
+
spanProcessors?: SpanProcessor[];
|
|
92
|
+
/**
|
|
93
|
+
* Additional span exporter to use.
|
|
94
|
+
* Will be wrapped in a BatchSpanProcessor and merged with other processors.
|
|
95
|
+
*/
|
|
96
|
+
traceExporter?: SpanExporter;
|
|
97
|
+
/**
|
|
98
|
+
* Service name for OpenTelemetry resource.
|
|
99
|
+
* @default 'duron'
|
|
100
|
+
*/
|
|
101
|
+
serviceName?: string;
|
|
102
|
+
}
|
|
27
103
|
declare const BaseOptionsSchema: z.ZodObject<{
|
|
28
104
|
id: z.ZodOptional<z.ZodString>;
|
|
29
105
|
syncPattern: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"pull">, z.ZodLiteral<"push">, z.ZodLiteral<"hybrid">, z.ZodLiteral<false>]>>;
|
|
@@ -36,23 +112,98 @@ declare const BaseOptionsSchema: z.ZodObject<{
|
|
|
36
112
|
multiProcessMode: z.ZodDefault<z.ZodBoolean>;
|
|
37
113
|
processTimeout: z.ZodDefault<z.ZodNumber>;
|
|
38
114
|
}, z.core.$strip>;
|
|
115
|
+
/**
|
|
116
|
+
* Options for configuring a Duron instance.
|
|
117
|
+
*
|
|
118
|
+
* @template TActions - Record of action definitions keyed by action name
|
|
119
|
+
* @template TVariables - Type of variables available to actions
|
|
120
|
+
*/
|
|
39
121
|
export interface ClientOptions<TActions extends Record<string, Action<any, any, TVariables>>, TVariables = Record<string, unknown>> extends z.input<typeof BaseOptionsSchema> {
|
|
122
|
+
/**
|
|
123
|
+
* The database adapter to use for storing jobs and steps.
|
|
124
|
+
* Required.
|
|
125
|
+
*/
|
|
40
126
|
database: Adapter;
|
|
127
|
+
/**
|
|
128
|
+
* A record of action definitions, where each key is the action name.
|
|
129
|
+
* Required.
|
|
130
|
+
*/
|
|
41
131
|
actions?: TActions;
|
|
132
|
+
/**
|
|
133
|
+
* Logger instance or log level for logging events and errors.
|
|
134
|
+
* Can be a pino Logger instance or a log level string ('fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent').
|
|
135
|
+
* If not provided, defaults to 'error' level.
|
|
136
|
+
*/
|
|
42
137
|
logger?: Logger | 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent';
|
|
138
|
+
/**
|
|
139
|
+
* Variables available to all actions via the context.
|
|
140
|
+
* These can be accessed in action handlers using `ctx.var`.
|
|
141
|
+
*/
|
|
43
142
|
variables?: TVariables;
|
|
44
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Optional telemetry configuration for observability.
|
|
145
|
+
* Uses OpenTelemetry SDK for tracing.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* // Enable local span storage (stored in the database)
|
|
150
|
+
* telemetry: { local: true }
|
|
151
|
+
*
|
|
152
|
+
* // Enable local storage with custom flush delay
|
|
153
|
+
* telemetry: { local: { flushDelayMs: 10000 } }
|
|
154
|
+
*
|
|
155
|
+
* // Export to external systems (e.g., OTLP)
|
|
156
|
+
* telemetry: { traceExporter: new OTLPTraceExporter() }
|
|
157
|
+
*
|
|
158
|
+
* // Both local storage and external export
|
|
159
|
+
* telemetry: { local: true, traceExporter: new OTLPTraceExporter() }
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
telemetry?: TelemetryOptions;
|
|
45
163
|
}
|
|
46
164
|
interface FetchOptions {
|
|
47
165
|
batchSize?: number;
|
|
48
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Client is the main entry point for Duron.
|
|
169
|
+
* Manages job execution, action handling, and database operations.
|
|
170
|
+
*
|
|
171
|
+
* @template TActions - Record of action definitions keyed by action name
|
|
172
|
+
* @template TVariables - Type of variables available to actions
|
|
173
|
+
*/
|
|
49
174
|
export declare class Client<TActions extends Record<string, Action<any, any, TVariables>>, TVariables = Record<string, unknown>> {
|
|
50
175
|
#private;
|
|
176
|
+
/**
|
|
177
|
+
* Create a new Duron Client instance.
|
|
178
|
+
*
|
|
179
|
+
* @param options - Configuration options for the client
|
|
180
|
+
*/
|
|
51
181
|
constructor(options: ClientOptions<TActions, TVariables>);
|
|
52
182
|
get logger(): pino.Logger;
|
|
53
|
-
|
|
183
|
+
/**
|
|
184
|
+
* Get the OpenTelemetry tracer for creating custom spans.
|
|
185
|
+
* Always returns a tracer - it's a no-op tracer when no SDK is configured.
|
|
186
|
+
*/
|
|
187
|
+
get tracer(): Tracer;
|
|
188
|
+
/**
|
|
189
|
+
* Get the database adapter instance.
|
|
190
|
+
*/
|
|
54
191
|
get database(): Adapter;
|
|
55
|
-
|
|
192
|
+
/**
|
|
193
|
+
* Check if local span storage is enabled.
|
|
194
|
+
* Returns true if telemetry.local is enabled.
|
|
195
|
+
*/
|
|
196
|
+
get spansEnabled(): boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Force flush any pending telemetry data.
|
|
199
|
+
* Useful in tests or when you need to ensure spans are exported before querying.
|
|
200
|
+
*/
|
|
201
|
+
flushTelemetry(): Promise<void>;
|
|
202
|
+
/**
|
|
203
|
+
* Get the current configuration of this Duron instance.
|
|
204
|
+
*
|
|
205
|
+
* @returns Configuration object including options, actions, and variables
|
|
206
|
+
*/
|
|
56
207
|
getConfig(): {
|
|
57
208
|
actions: TActions | null;
|
|
58
209
|
variables: Record<string, unknown>;
|
|
@@ -67,12 +218,43 @@ export declare class Client<TActions extends Record<string, Action<any, any, TVa
|
|
|
67
218
|
processTimeout: number;
|
|
68
219
|
id?: string | undefined;
|
|
69
220
|
};
|
|
221
|
+
/**
|
|
222
|
+
* Run an action by creating a new job.
|
|
223
|
+
*
|
|
224
|
+
* @param actionName - Name of the action to run
|
|
225
|
+
* @param input - Input data for the action (validated against action's input schema if provided)
|
|
226
|
+
* @returns Promise resolving to the created job ID
|
|
227
|
+
* @throws Error if action is not found or job creation fails
|
|
228
|
+
*/
|
|
70
229
|
runAction<TActionName extends keyof TActions>(actionName: TActionName, input?: NonNullable<TActions[TActionName]['input']> extends z.ZodObject ? z.input<NonNullable<TActions[TActionName]['input']>> : never): Promise<string>;
|
|
230
|
+
/**
|
|
231
|
+
* Run an action and wait for its completion.
|
|
232
|
+
* This is a convenience method that combines `runAction` and `waitForJob`.
|
|
233
|
+
*
|
|
234
|
+
* @param actionName - Name of the action to run
|
|
235
|
+
* @param input - Input data for the action (validated against action's input schema if provided)
|
|
236
|
+
* @param options - Options including abort signal and timeout
|
|
237
|
+
* @returns Promise resolving to the job result with typed input and output
|
|
238
|
+
* @throws Error if action is not found, job creation fails, job is cancelled, or operation is aborted
|
|
239
|
+
*/
|
|
71
240
|
runActionAndWait<TActionName extends keyof TActions>(actionName: TActionName, input?: NonNullable<TActions[TActionName]['input']> extends z.ZodObject ? z.input<NonNullable<TActions[TActionName]['input']>> : never, options?: {
|
|
241
|
+
/**
|
|
242
|
+
* AbortSignal to cancel the operation. If aborted, the job will be cancelled and the promise will reject.
|
|
243
|
+
*/
|
|
72
244
|
signal?: AbortSignal;
|
|
245
|
+
/**
|
|
246
|
+
* Timeout in milliseconds. If the job doesn't complete within this time, the job will be cancelled and the promise will reject.
|
|
247
|
+
*/
|
|
73
248
|
timeout?: number;
|
|
74
249
|
}): Promise<TypedJobResult<TActions[TActionName]>>;
|
|
75
|
-
|
|
250
|
+
/**
|
|
251
|
+
* Fetch and process jobs from the database.
|
|
252
|
+
* Concurrency limits are determined from the latest job created for each groupKey.
|
|
253
|
+
*
|
|
254
|
+
* @param [options.batchSize] - Maximum number of jobs to fetch in this batch (defaults to `batchSize` from client options)
|
|
255
|
+
* @returns Promise resolving to the array of fetched jobs
|
|
256
|
+
*/
|
|
257
|
+
fetch(options?: FetchOptions): Promise<{
|
|
76
258
|
id: string;
|
|
77
259
|
actionName: string;
|
|
78
260
|
groupKey: string;
|
|
@@ -87,30 +269,154 @@ export declare class Client<TActions extends Record<string, Action<any, any, TVa
|
|
|
87
269
|
createdAt: Date;
|
|
88
270
|
updatedAt: Date;
|
|
89
271
|
concurrencyLimit: number;
|
|
272
|
+
durationMs: number | null;
|
|
90
273
|
clientId?: string | null | undefined;
|
|
91
274
|
}[]>;
|
|
275
|
+
/**
|
|
276
|
+
* Cancel a job by its ID.
|
|
277
|
+
* If the job is currently being processed, it will be cancelled immediately.
|
|
278
|
+
* Otherwise, it will be cancelled in the database.
|
|
279
|
+
*
|
|
280
|
+
* @param jobId - The ID of the job to cancel
|
|
281
|
+
* @returns Promise resolving to `true` if cancelled, `false` otherwise
|
|
282
|
+
*/
|
|
92
283
|
cancelJob(jobId: string): Promise<boolean>;
|
|
284
|
+
/**
|
|
285
|
+
* Retry a failed job by creating a copy of it with status 'created' and cleared output/error.
|
|
286
|
+
*
|
|
287
|
+
* @param jobId - The ID of the job to retry
|
|
288
|
+
* @returns Promise resolving to the new job ID, or `null` if retry failed
|
|
289
|
+
*/
|
|
93
290
|
retryJob(jobId: string): Promise<string | null>;
|
|
291
|
+
/**
|
|
292
|
+
* Time travel a job to restart from a specific step.
|
|
293
|
+
* The job must be in completed, failed, or cancelled status.
|
|
294
|
+
* Resets the job and ancestor steps to active status, deletes subsequent steps,
|
|
295
|
+
* and preserves completed parallel siblings.
|
|
296
|
+
*
|
|
297
|
+
* @param jobId - The ID of the job to time travel
|
|
298
|
+
* @param stepId - The ID of the step to restart from
|
|
299
|
+
* @returns Promise resolving to `true` if time travel succeeded, `false` otherwise
|
|
300
|
+
*/
|
|
94
301
|
timeTravelJob(jobId: string, stepId: string): Promise<boolean>;
|
|
302
|
+
/**
|
|
303
|
+
* Delete a job by its ID.
|
|
304
|
+
* Active jobs cannot be deleted.
|
|
305
|
+
*
|
|
306
|
+
* @param jobId - The ID of the job to delete
|
|
307
|
+
* @returns Promise resolving to `true` if deleted, `false` otherwise
|
|
308
|
+
*/
|
|
95
309
|
deleteJob(jobId: string): Promise<boolean>;
|
|
310
|
+
/**
|
|
311
|
+
* Delete multiple jobs using the same filters as getJobs.
|
|
312
|
+
* Active jobs cannot be deleted and will be excluded from deletion.
|
|
313
|
+
*
|
|
314
|
+
* @param options - Query options including filters (same as getJobs)
|
|
315
|
+
* @returns Promise resolving to the number of jobs deleted
|
|
316
|
+
*/
|
|
96
317
|
deleteJobs(options?: GetJobsOptions): Promise<number>;
|
|
318
|
+
/**
|
|
319
|
+
* Get a job by its ID. Does not include step information.
|
|
320
|
+
*
|
|
321
|
+
* @param jobId - The ID of the job to retrieve
|
|
322
|
+
* @returns Promise resolving to the job, or `null` if not found
|
|
323
|
+
*/
|
|
97
324
|
getJobById(jobId: string): Promise<Job | null>;
|
|
325
|
+
/**
|
|
326
|
+
* Get steps for a job with pagination and fuzzy search.
|
|
327
|
+
* Steps are always ordered by created_at ASC.
|
|
328
|
+
* Steps do not include output data.
|
|
329
|
+
*
|
|
330
|
+
* @param options - Query options including jobId, pagination, and search
|
|
331
|
+
* @returns Promise resolving to steps result with pagination info
|
|
332
|
+
*/
|
|
98
333
|
getJobSteps(options: GetJobStepsOptions): Promise<GetJobStepsResult>;
|
|
334
|
+
/**
|
|
335
|
+
* Get jobs with pagination, filtering, and sorting.
|
|
336
|
+
* Does not include step information or job output.
|
|
337
|
+
*
|
|
338
|
+
* @param options - Query options including pagination, filters, and sort
|
|
339
|
+
* @returns Promise resolving to jobs result with pagination info
|
|
340
|
+
*/
|
|
99
341
|
getJobs(options?: GetJobsOptions): Promise<GetJobsResult>;
|
|
342
|
+
/**
|
|
343
|
+
* Get a step by its ID with all information.
|
|
344
|
+
*
|
|
345
|
+
* @param stepId - The ID of the step to retrieve
|
|
346
|
+
* @returns Promise resolving to the step, or `null` if not found
|
|
347
|
+
*/
|
|
100
348
|
getJobStepById(stepId: string): Promise<JobStep | null>;
|
|
349
|
+
/**
|
|
350
|
+
* Get job status and updatedAt timestamp.
|
|
351
|
+
*
|
|
352
|
+
* @param jobId - The ID of the job
|
|
353
|
+
* @returns Promise resolving to job status result, or `null` if not found
|
|
354
|
+
*/
|
|
101
355
|
getJobStatus(jobId: string): Promise<JobStatusResult | null>;
|
|
356
|
+
/**
|
|
357
|
+
* Get job step status and updatedAt timestamp.
|
|
358
|
+
*
|
|
359
|
+
* @param stepId - The ID of the step
|
|
360
|
+
* @returns Promise resolving to step status result, or `null` if not found
|
|
361
|
+
*/
|
|
102
362
|
getJobStepStatus(stepId: string): Promise<JobStepStatusResult | null>;
|
|
363
|
+
/**
|
|
364
|
+
* Wait for a job to change status by subscribing to job-status-changed events.
|
|
365
|
+
* When the job status changes, the job result is returned.
|
|
366
|
+
*
|
|
367
|
+
* @param jobId - The ID of the job to wait for
|
|
368
|
+
* @param options - Optional configuration including timeout
|
|
369
|
+
* @returns Promise resolving to the job result when its status changes, or `null` if timeout
|
|
370
|
+
*/
|
|
103
371
|
waitForJob(jobId: string, options?: {
|
|
372
|
+
/**
|
|
373
|
+
* Timeout in milliseconds. If the job status doesn't change within this time, the promise resolves to `null`.
|
|
374
|
+
* Defaults to no timeout (waits indefinitely).
|
|
375
|
+
*/
|
|
104
376
|
timeout?: number;
|
|
377
|
+
/**
|
|
378
|
+
* AbortSignal to cancel waiting. If aborted, the promise resolves to `null`.
|
|
379
|
+
*/
|
|
105
380
|
signal?: AbortSignal;
|
|
106
381
|
}): Promise<JobResult | null>;
|
|
382
|
+
/**
|
|
383
|
+
* Get action statistics including counts and last job created date.
|
|
384
|
+
*
|
|
385
|
+
* @returns Promise resolving to action statistics
|
|
386
|
+
*/
|
|
107
387
|
getActions(): Promise<GetActionsResult>;
|
|
108
|
-
|
|
388
|
+
/**
|
|
389
|
+
* Get spans for a job or step.
|
|
390
|
+
* Only available when telemetry.local is enabled.
|
|
391
|
+
*
|
|
392
|
+
* @param options - Query options including jobId/stepId, filters, and sort
|
|
393
|
+
* @returns Promise resolving to spans result
|
|
394
|
+
* @throws Error if local telemetry is not enabled
|
|
395
|
+
*/
|
|
396
|
+
getSpans(options: GetSpansOptions): Promise<GetSpansResult>;
|
|
397
|
+
/**
|
|
398
|
+
* Get action metadata including input schemas and mock data.
|
|
399
|
+
* This is useful for generating UI forms or mock data.
|
|
400
|
+
*
|
|
401
|
+
* @returns Promise resolving to action metadata
|
|
402
|
+
*/
|
|
109
403
|
getActionsMetadata(): Promise<Array<{
|
|
110
404
|
name: string;
|
|
111
405
|
mockInput: any;
|
|
112
406
|
}>>;
|
|
407
|
+
/**
|
|
408
|
+
* Start the Duron instance.
|
|
409
|
+
* Initializes the database, recovers stuck jobs, and sets up sync patterns.
|
|
410
|
+
*
|
|
411
|
+
* @returns Promise resolving to `true` if started successfully, `false` otherwise
|
|
412
|
+
*/
|
|
113
413
|
start(): Promise<boolean>;
|
|
414
|
+
/**
|
|
415
|
+
* Stop the Duron instance.
|
|
416
|
+
* Stops the pull loop, aborts all running jobs, waits for queues to drain, and stops the database.
|
|
417
|
+
*
|
|
418
|
+
* @returns Promise resolving to `true` if stopped successfully, `false` otherwise
|
|
419
|
+
*/
|
|
114
420
|
stop(): Promise<boolean>;
|
|
115
421
|
}
|
|
116
422
|
export {};
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,KAAK,MAAM,EAAE,MAAM,MAAM,CAAA;AAExC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,KAA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