@knocklabs/node 1.30.0 → 1.31.1

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.
@@ -0,0 +1,255 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as RecipientsAPI from './recipients/recipients';
5
+ import { APIPromise } from '../core/api-promise';
6
+ import { ItemsCursor, type ItemsCursorParams, PagePromise } from '../core/pagination';
7
+ import { RequestOptions } from '../internal/request-options';
8
+ import { path } from '../internal/utils/path';
9
+
10
+ /**
11
+ * A workflow run represents an individual execution of a workflow for a specific recipient.
12
+ */
13
+ export class WorkflowRecipientRuns extends APIResource {
14
+ /**
15
+ * Returns a paginated list of workflow recipient runs for the current environment.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * // Automatically fetches more pages as needed.
20
+ * for await (const workflowRecipientRun of client.workflowRecipientRuns.list()) {
21
+ * // ...
22
+ * }
23
+ * ```
24
+ */
25
+ list(
26
+ query: WorkflowRecipientRunListParams | null | undefined = {},
27
+ options?: RequestOptions,
28
+ ): PagePromise<WorkflowRecipientRunsItemsCursor, WorkflowRecipientRun> {
29
+ return this._client.getAPIList('/v1/workflow_recipient_runs', ItemsCursor<WorkflowRecipientRun>, {
30
+ query,
31
+ ...options,
32
+ });
33
+ }
34
+
35
+ /**
36
+ * Returns a single workflow recipient run with its associated events.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const workflowRecipientRunDetail =
41
+ * await client.workflowRecipientRuns.get('id');
42
+ * ```
43
+ */
44
+ get(id: string, options?: RequestOptions): APIPromise<WorkflowRecipientRunDetail> {
45
+ return this._client.get(path`/v1/workflow_recipient_runs/${id}`, options);
46
+ }
47
+ }
48
+
49
+ export type WorkflowRecipientRunsItemsCursor = ItemsCursor<WorkflowRecipientRun>;
50
+
51
+ /**
52
+ * A workflow recipient run represents an individual execution of a workflow for a
53
+ * specific recipient.
54
+ */
55
+ export interface WorkflowRecipientRun {
56
+ /**
57
+ * The unique identifier for the workflow recipient run (per-recipient).
58
+ */
59
+ id: string;
60
+
61
+ /**
62
+ * The typename of the schema.
63
+ */
64
+ __typename: string;
65
+
66
+ /**
67
+ * Timestamp when the resource was created.
68
+ */
69
+ inserted_at: string;
70
+
71
+ /**
72
+ * A reference to a recipient, either a user identifier (string) or an object
73
+ * reference (ID, collection).
74
+ */
75
+ recipient: RecipientsAPI.RecipientReference;
76
+
77
+ /**
78
+ * The current status of the workflow recipient run. One of `queued`, `processing`,
79
+ * `paused`, `completed`, or `cancelled`.
80
+ */
81
+ status: 'queued' | 'processing' | 'paused' | 'completed' | 'cancelled';
82
+
83
+ /**
84
+ * Describes how the workflow was triggered.
85
+ */
86
+ trigger_source: WorkflowRecipientRun.TriggerSource;
87
+
88
+ /**
89
+ * The timestamp when the resource was last updated.
90
+ */
91
+ updated_at: string;
92
+
93
+ /**
94
+ * The key of the workflow that was executed.
95
+ */
96
+ workflow: string;
97
+
98
+ /**
99
+ * The identifier for the top-level workflow run shared across all recipients in a
100
+ * single trigger.
101
+ */
102
+ workflow_run_id: string;
103
+
104
+ /**
105
+ * A recipient of a notification, which is either a user or an object.
106
+ */
107
+ actor?: RecipientsAPI.Recipient | null;
108
+
109
+ /**
110
+ * The number of errors encountered during the workflow recipient run.
111
+ */
112
+ error_count?: number;
113
+
114
+ /**
115
+ * The tenant associated with the workflow recipient run.
116
+ */
117
+ tenant?: string | null;
118
+ }
119
+
120
+ export namespace WorkflowRecipientRun {
121
+ /**
122
+ * Describes how the workflow was triggered.
123
+ */
124
+ export interface TriggerSource {
125
+ /**
126
+ * The type of trigger source. One of `api`, `audience`, `schedule`, `broadcast`,
127
+ * `workflow_step`, `integration`, or `rehearsal`.
128
+ */
129
+ type: 'api' | 'audience' | 'schedule' | 'broadcast' | 'workflow_step' | 'integration' | 'rehearsal';
130
+
131
+ /**
132
+ * The key of the audience that triggered the workflow.
133
+ */
134
+ audience_key?: string | null;
135
+
136
+ /**
137
+ * The cancellation key provided when the workflow was triggered via the API.
138
+ */
139
+ cancellation_key?: string | null;
140
+
141
+ /**
142
+ * The ID of the schedule that triggered the workflow.
143
+ */
144
+ schedule_id?: string | null;
145
+ }
146
+ }
147
+
148
+ /**
149
+ * A single workflow recipient run with its events.
150
+ */
151
+ export interface WorkflowRecipientRunDetail extends WorkflowRecipientRun {
152
+ /**
153
+ * A list of events that occurred during the workflow recipient run.
154
+ */
155
+ events: Array<WorkflowRecipientRunEvent>;
156
+ }
157
+
158
+ /**
159
+ * An event that occurred during a workflow recipient run.
160
+ */
161
+ export interface WorkflowRecipientRunEvent {
162
+ /**
163
+ * The unique identifier for the event.
164
+ */
165
+ id: string;
166
+
167
+ /**
168
+ * The typename of the schema.
169
+ */
170
+ __typename: string;
171
+
172
+ /**
173
+ * The type of event that occurred.
174
+ */
175
+ event: string;
176
+
177
+ /**
178
+ * Timestamp when the resource was created.
179
+ */
180
+ inserted_at: string;
181
+
182
+ /**
183
+ * Whether the event represents a successful or error state.
184
+ */
185
+ status: 'ok' | 'error';
186
+
187
+ /**
188
+ * The attempt number of the workflow recipient run event. Increments for each
189
+ * retry.
190
+ */
191
+ attempt?: number;
192
+
193
+ /**
194
+ * Event-specific data associated with the event.
195
+ */
196
+ data?: { [key: string]: unknown } | null;
197
+
198
+ /**
199
+ * The reference of the workflow step associated with this event.
200
+ */
201
+ step_ref?: string | null;
202
+
203
+ /**
204
+ * The type of workflow step associated with this event.
205
+ */
206
+ step_type?: string | null;
207
+ }
208
+
209
+ export interface WorkflowRecipientRunListParams extends ItemsCursorParams {
210
+ /**
211
+ * Limits the results to workflow recipient runs started before the given date.
212
+ */
213
+ ending_at?: string;
214
+
215
+ /**
216
+ * Limits the results to workflow recipient runs that have errors.
217
+ */
218
+ has_errors?: boolean;
219
+
220
+ /**
221
+ * Limits the results to workflow recipient runs for the given recipient. Accepts a
222
+ * user ID string or an object reference with `id` and `collection`.
223
+ */
224
+ recipient?: RecipientsAPI.RecipientReference;
225
+
226
+ /**
227
+ * Limits the results to workflow recipient runs started after the given date.
228
+ */
229
+ starting_at?: string;
230
+
231
+ /**
232
+ * Limits the results to workflow recipient runs with the given status.
233
+ */
234
+ status?: Array<'queued' | 'processing' | 'paused' | 'completed' | 'cancelled'>;
235
+
236
+ /**
237
+ * Limits the results to workflow recipient runs for the given tenant.
238
+ */
239
+ tenant?: string;
240
+
241
+ /**
242
+ * Limits the results to workflow recipient runs for the given workflow key.
243
+ */
244
+ workflow?: string;
245
+ }
246
+
247
+ export declare namespace WorkflowRecipientRuns {
248
+ export {
249
+ type WorkflowRecipientRun as WorkflowRecipientRun,
250
+ type WorkflowRecipientRunDetail as WorkflowRecipientRunDetail,
251
+ type WorkflowRecipientRunEvent as WorkflowRecipientRunEvent,
252
+ type WorkflowRecipientRunsItemsCursor as WorkflowRecipientRunsItemsCursor,
253
+ type WorkflowRecipientRunListParams as WorkflowRecipientRunListParams,
254
+ };
255
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.30.0'; // x-release-please-version
1
+ export const VERSION = '1.31.1'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.30.0";
1
+ export declare const VERSION = "1.31.1";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.30.0";
1
+ export declare const VERSION = "1.31.1";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '1.30.0'; // x-release-please-version
4
+ exports.VERSION = '1.31.1'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '1.30.0'; // x-release-please-version
1
+ export const VERSION = '1.31.1'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map