@agentuity/schedule 3.0.10 → 3.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.
- package/AGENTS.md +1 -1
- package/dist/api-reference.d.ts +351 -0
- package/dist/api-reference.d.ts.map +1 -0
- package/dist/api-reference.js +215 -0
- package/dist/api-reference.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -17
- package/dist/index.js.map +1 -1
- package/dist/service.d.ts +444 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +717 -0
- package/dist/service.js.map +1 -0
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +20 -0
- package/dist/types.js.map +1 -0
- package/package.json +4 -3
- package/src/api-reference.ts +228 -0
- package/src/index.ts +21 -48
- package/src/service.ts +833 -0
- package/src/types.ts +26 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAE3B,OAAO,EACN,eAAe,GAUf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACN,oBAAoB,EACpB,QAAQ,EACR,aAAa,EACb,aAAa,EACb,iBAAiB,GAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;IACpE,GAAG,EAAE,C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AC3B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,UAAkB,EAAE,MAA4B;QAC5D,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC9B,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,iBAAiB,CACtB,UAAkB,EAClB,MAAuC;QAEvC,OAAO,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,aAAqB;QAC5C,OAAO,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,cAAc,CACnB,UAAkB,EAClB,MAA4C;QAE5C,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;CACD"}
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import { FetchAdapter } from '@agentuity/adapter';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* A scheduled job that fires at intervals defined by a cron expression.
|
|
5
|
+
*
|
|
6
|
+
* Schedules are the top-level resource. Each schedule has one or more
|
|
7
|
+
* {@link ScheduleDestination | destinations} that receive HTTP callbacks
|
|
8
|
+
* when the schedule fires.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ScheduleSchema: z.ZodObject<{
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
created_at: z.ZodString;
|
|
13
|
+
updated_at: z.ZodString;
|
|
14
|
+
created_by: z.ZodString;
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
description: z.ZodNullable<z.ZodString>;
|
|
17
|
+
expression: z.ZodString;
|
|
18
|
+
due_date: z.ZodString;
|
|
19
|
+
internal: z.ZodBoolean;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export type Schedule = z.infer<typeof ScheduleSchema>;
|
|
22
|
+
/**
|
|
23
|
+
* A delivery target for a scheduled job.
|
|
24
|
+
*
|
|
25
|
+
* When the schedule fires, an HTTP request is sent to each of its destinations.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ScheduleDestinationSchema: z.ZodObject<{
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
schedule_id: z.ZodString;
|
|
30
|
+
created_at: z.ZodString;
|
|
31
|
+
updated_at: z.ZodString;
|
|
32
|
+
created_by: z.ZodString;
|
|
33
|
+
type: z.ZodEnum<{
|
|
34
|
+
sandbox: "sandbox";
|
|
35
|
+
url: "url";
|
|
36
|
+
}>;
|
|
37
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
export type ScheduleDestination = z.infer<typeof ScheduleDestinationSchema>;
|
|
40
|
+
/**
|
|
41
|
+
* A record of a single delivery attempt for a scheduled execution.
|
|
42
|
+
*
|
|
43
|
+
* Each time a schedule fires, one delivery record is created per destination.
|
|
44
|
+
* Failed deliveries may be retried automatically.
|
|
45
|
+
*/
|
|
46
|
+
export declare const ScheduleDeliverySchema: z.ZodObject<{
|
|
47
|
+
id: z.ZodString;
|
|
48
|
+
date: z.ZodString;
|
|
49
|
+
schedule_id: z.ZodString;
|
|
50
|
+
schedule_destination_id: z.ZodString;
|
|
51
|
+
status: z.ZodEnum<{
|
|
52
|
+
failed: "failed";
|
|
53
|
+
pending: "pending";
|
|
54
|
+
success: "success";
|
|
55
|
+
}>;
|
|
56
|
+
retries: z.ZodNumber;
|
|
57
|
+
error: z.ZodNullable<z.ZodString>;
|
|
58
|
+
response: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
export type ScheduleDelivery = z.infer<typeof ScheduleDeliverySchema>;
|
|
61
|
+
/**
|
|
62
|
+
* Parameters for creating a new schedule.
|
|
63
|
+
*/
|
|
64
|
+
export declare const CreateScheduleParamsSchema: z.ZodObject<{
|
|
65
|
+
name: z.ZodString;
|
|
66
|
+
description: z.ZodOptional<z.ZodString>;
|
|
67
|
+
expression: z.ZodString;
|
|
68
|
+
internal: z.ZodOptional<z.ZodBoolean>;
|
|
69
|
+
destinations: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
|
|
70
|
+
type: z.ZodEnum<{
|
|
71
|
+
sandbox: "sandbox";
|
|
72
|
+
url: "url";
|
|
73
|
+
}>;
|
|
74
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
75
|
+
}, z.core.$strip>>>>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
export type CreateScheduleParams = z.infer<typeof CreateScheduleParamsSchema>;
|
|
78
|
+
/**
|
|
79
|
+
* Parameters for creating a new destination on a schedule.
|
|
80
|
+
*/
|
|
81
|
+
export declare const CreateScheduleDestinationParamsSchema: z.ZodObject<{
|
|
82
|
+
type: z.ZodEnum<{
|
|
83
|
+
sandbox: "sandbox";
|
|
84
|
+
url: "url";
|
|
85
|
+
}>;
|
|
86
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
export type CreateScheduleDestinationParams = z.infer<typeof CreateScheduleDestinationParamsSchema>;
|
|
89
|
+
/**
|
|
90
|
+
* Parameters for updating an existing schedule.
|
|
91
|
+
*
|
|
92
|
+
* All fields are optional; only provided fields are updated.
|
|
93
|
+
*/
|
|
94
|
+
export declare const UpdateScheduleParamsSchema: z.ZodObject<{
|
|
95
|
+
name: z.ZodOptional<z.ZodString>;
|
|
96
|
+
description: z.ZodOptional<z.ZodString>;
|
|
97
|
+
expression: z.ZodOptional<z.ZodString>;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
export type UpdateScheduleParams = z.infer<typeof UpdateScheduleParamsSchema>;
|
|
100
|
+
/**
|
|
101
|
+
* Paginated list of schedules.
|
|
102
|
+
*/
|
|
103
|
+
export declare const ScheduleListResultSchema: z.ZodObject<{
|
|
104
|
+
schedules: z.ZodArray<z.ZodObject<{
|
|
105
|
+
id: z.ZodString;
|
|
106
|
+
created_at: z.ZodString;
|
|
107
|
+
updated_at: z.ZodString;
|
|
108
|
+
created_by: z.ZodString;
|
|
109
|
+
name: z.ZodString;
|
|
110
|
+
description: z.ZodNullable<z.ZodString>;
|
|
111
|
+
expression: z.ZodString;
|
|
112
|
+
due_date: z.ZodString;
|
|
113
|
+
internal: z.ZodBoolean;
|
|
114
|
+
}, z.core.$strip>>;
|
|
115
|
+
total: z.ZodNumber;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
export type ScheduleListResult = z.infer<typeof ScheduleListResultSchema>;
|
|
118
|
+
/**
|
|
119
|
+
* A schedule with its associated destinations.
|
|
120
|
+
*/
|
|
121
|
+
export declare const ScheduleGetResultSchema: z.ZodObject<{
|
|
122
|
+
schedule: z.ZodObject<{
|
|
123
|
+
id: z.ZodString;
|
|
124
|
+
created_at: z.ZodString;
|
|
125
|
+
updated_at: z.ZodString;
|
|
126
|
+
created_by: z.ZodString;
|
|
127
|
+
name: z.ZodString;
|
|
128
|
+
description: z.ZodNullable<z.ZodString>;
|
|
129
|
+
expression: z.ZodString;
|
|
130
|
+
due_date: z.ZodString;
|
|
131
|
+
internal: z.ZodBoolean;
|
|
132
|
+
}, z.core.$strip>;
|
|
133
|
+
destinations: z.ZodArray<z.ZodObject<{
|
|
134
|
+
id: z.ZodString;
|
|
135
|
+
schedule_id: z.ZodString;
|
|
136
|
+
created_at: z.ZodString;
|
|
137
|
+
updated_at: z.ZodString;
|
|
138
|
+
created_by: z.ZodString;
|
|
139
|
+
type: z.ZodEnum<{
|
|
140
|
+
sandbox: "sandbox";
|
|
141
|
+
url: "url";
|
|
142
|
+
}>;
|
|
143
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
144
|
+
}, z.core.$strip>>;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
export type ScheduleGetResult = z.infer<typeof ScheduleGetResultSchema>;
|
|
147
|
+
/**
|
|
148
|
+
* Result of creating a schedule, including any destinations created atomically.
|
|
149
|
+
*/
|
|
150
|
+
export declare const ScheduleCreateResultSchema: z.ZodObject<{
|
|
151
|
+
schedule: z.ZodObject<{
|
|
152
|
+
id: z.ZodString;
|
|
153
|
+
created_at: z.ZodString;
|
|
154
|
+
updated_at: z.ZodString;
|
|
155
|
+
created_by: z.ZodString;
|
|
156
|
+
name: z.ZodString;
|
|
157
|
+
description: z.ZodNullable<z.ZodString>;
|
|
158
|
+
expression: z.ZodString;
|
|
159
|
+
due_date: z.ZodString;
|
|
160
|
+
internal: z.ZodBoolean;
|
|
161
|
+
}, z.core.$strip>;
|
|
162
|
+
destinations: z.ZodArray<z.ZodObject<{
|
|
163
|
+
id: z.ZodString;
|
|
164
|
+
schedule_id: z.ZodString;
|
|
165
|
+
created_at: z.ZodString;
|
|
166
|
+
updated_at: z.ZodString;
|
|
167
|
+
created_by: z.ZodString;
|
|
168
|
+
type: z.ZodEnum<{
|
|
169
|
+
sandbox: "sandbox";
|
|
170
|
+
url: "url";
|
|
171
|
+
}>;
|
|
172
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
173
|
+
}, z.core.$strip>>;
|
|
174
|
+
}, z.core.$strip>;
|
|
175
|
+
export type ScheduleCreateResult = z.infer<typeof ScheduleCreateResultSchema>;
|
|
176
|
+
/**
|
|
177
|
+
* List of delivery attempts for a schedule.
|
|
178
|
+
*/
|
|
179
|
+
export declare const ScheduleDeliveryListResultSchema: z.ZodObject<{
|
|
180
|
+
deliveries: z.ZodArray<z.ZodObject<{
|
|
181
|
+
id: z.ZodString;
|
|
182
|
+
date: z.ZodString;
|
|
183
|
+
schedule_id: z.ZodString;
|
|
184
|
+
schedule_destination_id: z.ZodString;
|
|
185
|
+
status: z.ZodEnum<{
|
|
186
|
+
failed: "failed";
|
|
187
|
+
pending: "pending";
|
|
188
|
+
success: "success";
|
|
189
|
+
}>;
|
|
190
|
+
retries: z.ZodNumber;
|
|
191
|
+
error: z.ZodNullable<z.ZodString>;
|
|
192
|
+
response: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
193
|
+
}, z.core.$strip>>;
|
|
194
|
+
}, z.core.$strip>;
|
|
195
|
+
export type ScheduleDeliveryListResult = z.infer<typeof ScheduleDeliveryListResultSchema>;
|
|
196
|
+
/**
|
|
197
|
+
* Client for the Agentuity Schedule service.
|
|
198
|
+
*
|
|
199
|
+
* Provides methods for creating, managing, and monitoring cron-based scheduled jobs.
|
|
200
|
+
* Schedules fire at intervals defined by cron expressions and deliver HTTP requests
|
|
201
|
+
* to configured destinations (URLs or sandboxes).
|
|
202
|
+
*
|
|
203
|
+
* The service supports:
|
|
204
|
+
* - CRUD operations on schedules and their destinations
|
|
205
|
+
* - Cron expression validation
|
|
206
|
+
* - Delivery history and monitoring
|
|
207
|
+
* - Automatic due date computation from cron expressions
|
|
208
|
+
*
|
|
209
|
+
* All methods are instrumented with OpenTelemetry spans for observability.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const schedules = new ScheduleService(baseUrl, adapter);
|
|
214
|
+
*
|
|
215
|
+
* // Create a schedule that fires every hour
|
|
216
|
+
* const result = await schedules.create({
|
|
217
|
+
* name: 'Hourly Sync',
|
|
218
|
+
* expression: '0 * * * *',
|
|
219
|
+
* destinations: [{ type: 'url', config: { url: 'https://example.com/sync' } }],
|
|
220
|
+
* });
|
|
221
|
+
*
|
|
222
|
+
* // List all schedules
|
|
223
|
+
* const { schedules: list, total } = await schedules.list();
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
export declare class ScheduleService {
|
|
227
|
+
#private;
|
|
228
|
+
/**
|
|
229
|
+
* Create a new ScheduleService instance.
|
|
230
|
+
*
|
|
231
|
+
* @param baseUrl - The base URL for the Agentuity Schedule API (e.g., `https://api.agentuity.com`)
|
|
232
|
+
* @param adapter - The HTTP fetch adapter used for making API requests
|
|
233
|
+
*/
|
|
234
|
+
constructor(baseUrl: string, adapter: FetchAdapter);
|
|
235
|
+
/**
|
|
236
|
+
* Create a new schedule with optional destinations.
|
|
237
|
+
*
|
|
238
|
+
* The schedule and its destinations are created atomically — if any validation
|
|
239
|
+
* fails, the entire operation is rolled back.
|
|
240
|
+
*
|
|
241
|
+
* @param params - The schedule creation parameters including name, cron expression, and optional destinations
|
|
242
|
+
* @returns The created schedule and its destinations
|
|
243
|
+
* @throws ServiceException on API errors (e.g., invalid cron expression, invalid destination URL)
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* const result = await schedules.create({
|
|
248
|
+
* name: 'Daily Report',
|
|
249
|
+
* description: 'Generate and send daily reports',
|
|
250
|
+
* expression: '0 9 * * *',
|
|
251
|
+
* destinations: [
|
|
252
|
+
* { type: 'url', config: { url: 'https://example.com/reports' } },
|
|
253
|
+
* ],
|
|
254
|
+
* });
|
|
255
|
+
* console.log('Created schedule:', result.schedule.id);
|
|
256
|
+
* console.log('Next run:', result.schedule.due_date);
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
create(params: CreateScheduleParams): Promise<ScheduleCreateResult>;
|
|
260
|
+
/**
|
|
261
|
+
* List all schedules with optional pagination.
|
|
262
|
+
*
|
|
263
|
+
* @param params - Optional pagination parameters
|
|
264
|
+
* @param params.limit - Maximum number of schedules to return (max 500)
|
|
265
|
+
* @param params.offset - Number of schedules to skip for pagination
|
|
266
|
+
* @returns A paginated list of schedules with the total count
|
|
267
|
+
* @throws ServiceException on API errors
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```typescript
|
|
271
|
+
* // List first page
|
|
272
|
+
* const { schedules, total } = await service.list({ limit: 20 });
|
|
273
|
+
* console.log(`Showing ${schedules.length} of ${total} schedules`);
|
|
274
|
+
*
|
|
275
|
+
* // Paginate through all schedules
|
|
276
|
+
* const page2 = await service.list({ limit: 20, offset: 20 });
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
list(params?: {
|
|
280
|
+
limit?: number;
|
|
281
|
+
offset?: number;
|
|
282
|
+
}): Promise<ScheduleListResult>;
|
|
283
|
+
/**
|
|
284
|
+
* Get a schedule by its ID, including all configured destinations.
|
|
285
|
+
*
|
|
286
|
+
* @param scheduleId - The schedule ID (prefixed with `sch_`)
|
|
287
|
+
* @returns The schedule record and its array of destinations
|
|
288
|
+
* @throws ServiceException on API errors (including 404 if not found)
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```typescript
|
|
292
|
+
* const { schedule, destinations } = await service.get('sch_abc123');
|
|
293
|
+
* console.log('Schedule:', schedule.name);
|
|
294
|
+
* console.log('Next run:', schedule.due_date);
|
|
295
|
+
* console.log('Destinations:', destinations.length);
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
get(scheduleId: string): Promise<ScheduleGetResult>;
|
|
299
|
+
/**
|
|
300
|
+
* Update an existing schedule. Only the provided fields are modified.
|
|
301
|
+
*
|
|
302
|
+
* @remarks If the `expression` field is changed, the `due_date` is automatically
|
|
303
|
+
* recomputed based on the new cron expression.
|
|
304
|
+
*
|
|
305
|
+
* @param scheduleId - The schedule ID (prefixed with `sch_`)
|
|
306
|
+
* @param params - The fields to update (all optional)
|
|
307
|
+
* @returns The updated schedule record
|
|
308
|
+
* @throws ServiceException on API errors (e.g., invalid cron expression, schedule not found)
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```typescript
|
|
312
|
+
* // Update the name and expression
|
|
313
|
+
* const { schedule } = await service.update('sch_abc123', {
|
|
314
|
+
* name: 'Daily Midnight Sync',
|
|
315
|
+
* expression: '0 0 * * *',
|
|
316
|
+
* });
|
|
317
|
+
* console.log('Updated. Next run:', schedule.due_date);
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
update(scheduleId: string, params: UpdateScheduleParams): Promise<{
|
|
321
|
+
schedule: Schedule;
|
|
322
|
+
}>;
|
|
323
|
+
/**
|
|
324
|
+
* Delete a schedule and all of its destinations and delivery history.
|
|
325
|
+
*
|
|
326
|
+
* @param scheduleId - The schedule ID (prefixed with `sch_`)
|
|
327
|
+
* @throws ServiceException on API errors (e.g., schedule not found)
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```typescript
|
|
331
|
+
* await service.delete('sch_abc123');
|
|
332
|
+
* console.log('Schedule deleted');
|
|
333
|
+
* ```
|
|
334
|
+
*/
|
|
335
|
+
delete(scheduleId: string): Promise<void>;
|
|
336
|
+
/**
|
|
337
|
+
* Create a new destination on an existing schedule.
|
|
338
|
+
*
|
|
339
|
+
* @param scheduleId - The schedule ID (prefixed with `sch_`)
|
|
340
|
+
* @param params - The destination configuration including type and type-specific config
|
|
341
|
+
* @returns The newly created destination record
|
|
342
|
+
* @throws ServiceException on API errors (e.g., invalid URL, schedule not found)
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* ```typescript
|
|
346
|
+
* const { destination } = await service.createDestination('sch_abc123', {
|
|
347
|
+
* type: 'url',
|
|
348
|
+
* config: {
|
|
349
|
+
* url: 'https://example.com/webhook',
|
|
350
|
+
* headers: { 'Authorization': 'Bearer token' },
|
|
351
|
+
* },
|
|
352
|
+
* });
|
|
353
|
+
* console.log('Destination created:', destination.id);
|
|
354
|
+
* ```
|
|
355
|
+
*/
|
|
356
|
+
createDestination(scheduleId: string, params: CreateScheduleDestinationParams): Promise<{
|
|
357
|
+
destination: ScheduleDestination;
|
|
358
|
+
}>;
|
|
359
|
+
/**
|
|
360
|
+
* Delete a destination from a schedule.
|
|
361
|
+
*
|
|
362
|
+
* @param destinationId - The destination ID (prefixed with `sdst_`)
|
|
363
|
+
* @throws ServiceException on API errors (e.g., destination not found)
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```typescript
|
|
367
|
+
* await service.deleteDestination('sdst_xyz789');
|
|
368
|
+
* console.log('Destination removed');
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
deleteDestination(destinationId: string): Promise<void>;
|
|
372
|
+
/**
|
|
373
|
+
* List delivery attempts for a schedule with optional pagination.
|
|
374
|
+
*
|
|
375
|
+
* @param scheduleId - The schedule ID (prefixed with `sch_`)
|
|
376
|
+
* @param params - Optional pagination parameters
|
|
377
|
+
* @param params.limit - Maximum number of deliveries to return
|
|
378
|
+
* @param params.offset - Number of deliveries to skip for pagination
|
|
379
|
+
* @returns A list of delivery attempt records
|
|
380
|
+
* @throws ServiceException on API errors (including 404 if schedule not found)
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ```typescript
|
|
384
|
+
* const { deliveries } = await service.listDeliveries('sch_abc123');
|
|
385
|
+
* for (const d of deliveries) {
|
|
386
|
+
* console.log(`${d.date}: ${d.status} (retries: ${d.retries})`);
|
|
387
|
+
* if (d.error) {
|
|
388
|
+
* console.error(' Error:', d.error);
|
|
389
|
+
* }
|
|
390
|
+
* }
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
listDeliveries(scheduleId: string, params?: {
|
|
394
|
+
limit?: number;
|
|
395
|
+
offset?: number;
|
|
396
|
+
}): Promise<ScheduleDeliveryListResult>;
|
|
397
|
+
/**
|
|
398
|
+
* Get a specific destination for a schedule by its ID.
|
|
399
|
+
*
|
|
400
|
+
* @remarks This is a convenience method that fetches the schedule and filters
|
|
401
|
+
* its destinations client-side. For large destination lists, prefer using
|
|
402
|
+
* {@link get} directly.
|
|
403
|
+
*
|
|
404
|
+
* @param scheduleId - The schedule ID (prefixed with `sch_`)
|
|
405
|
+
* @param destinationId - The destination ID (prefixed with `sdst_`)
|
|
406
|
+
* @returns The matching destination record
|
|
407
|
+
* @throws Error if the destination is not found within the schedule
|
|
408
|
+
* @throws ServiceException on API errors when fetching the schedule
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```typescript
|
|
412
|
+
* const dest = await service.getDestination('sch_abc123', 'sdst_xyz789');
|
|
413
|
+
* console.log('Destination type:', dest.type);
|
|
414
|
+
* console.log('Config:', dest.config);
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
getDestination(scheduleId: string, destinationId: string): Promise<ScheduleDestination>;
|
|
418
|
+
/**
|
|
419
|
+
* Get a specific delivery record by its ID.
|
|
420
|
+
*
|
|
421
|
+
* @remarks This is a convenience method that lists deliveries and filters
|
|
422
|
+
* client-side. Use the optional `params` to control the search window if
|
|
423
|
+
* the delivery may not be in the first page of results.
|
|
424
|
+
*
|
|
425
|
+
* @param scheduleId - The schedule ID (prefixed with `sch_`)
|
|
426
|
+
* @param deliveryId - The delivery ID to find
|
|
427
|
+
* @param params - Optional pagination parameters to control the search window
|
|
428
|
+
* @returns The matching delivery record
|
|
429
|
+
* @throws Error if the delivery is not found in the result set
|
|
430
|
+
* @throws ServiceException on API errors when listing deliveries
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```typescript
|
|
434
|
+
* const delivery = await service.getDelivery('sch_abc123', 'del_xyz789');
|
|
435
|
+
* console.log('Status:', delivery.status);
|
|
436
|
+
* console.log('Retries:', delivery.retries);
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
439
|
+
getDelivery(scheduleId: string, deliveryId: string, params?: {
|
|
440
|
+
limit?: number;
|
|
441
|
+
offset?: number;
|
|
442
|
+
}): Promise<ScheduleDelivery>;
|
|
443
|
+
}
|
|
444
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgC,MA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