@epilot/automation-client 0.2.1 → 0.4.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.
package/dist/openapi.d.ts CHANGED
@@ -9,47 +9,56 @@ import {
9
9
 
10
10
  declare namespace Components {
11
11
  namespace Schemas {
12
- export type AnyAction = MapEntityAction | TriggerWorkflowAction | TriggerWebhookAction | CreateDocumentAction | SendEmailAction | AutomationAction;
13
- /**
14
- * example:
15
- * [
16
- * {
17
- * "step_name": "Lead Sales",
18
- * "user_ids": [
19
- * 10010729
20
- * ]
21
- * },
22
- * {
23
- * "step_name": "Operations",
24
- * "user_ids": [
25
- * 10010728,
26
- * 10010729
27
- * ]
28
- * }
29
- * ]
30
- */
31
- export interface AssignUsersToStep {
32
- step_name?: string;
33
- user_ids?: number[];
34
- }
35
12
  export interface AutomationAction {
36
13
  id?: AutomationActionId;
14
+ /**
15
+ * example:
16
+ * Create Contact
17
+ */
37
18
  name?: string;
19
+ /**
20
+ * example:
21
+ * entity_mapping
22
+ */
38
23
  type?: string;
39
- config?: {
40
- [name: string]: any;
41
- };
42
- execution_status?: ExecutionStatus;
43
- started_at?: string;
44
- updated_at?: string;
45
24
  /**
46
- * Flag indicating whether the action was created automatically or manually
25
+ * example:
26
+ * {
27
+ * "target_schema": "contact",
28
+ * "mapping_attributes": [
29
+ * {
30
+ * "target": "email",
31
+ * "mode": "upsert_match",
32
+ * "source": "billing_contact.email"
33
+ * },
34
+ * {
35
+ * "target": "first_name",
36
+ * "mode": "copy_if_exists",
37
+ * "source": "billing_contact.first_name"
38
+ * },
39
+ * {
40
+ * "target": "last_name",
41
+ * "mode": "copy_if_exists",
42
+ * "source": "billing_contact.last_name"
43
+ * },
44
+ * {
45
+ * "target": "addresses",
46
+ * "mode": "append_if_exists",
47
+ * "source": "billing_contact",
48
+ * "value_json": "{\n \"street_name\": \"{{billing_contact.street_name}}\",\n \"street_number\": \"{{billing_contact.street_number}}\",\n \"city\": \"{{billing_contact.city}}\",\n \"postal_code\": \"{{billing_contact.postal_code}}\",\n \"country\": \"{{billing_contact.country}}\",\n}"
49
+ * },
50
+ * {
51
+ * "target": "addresses",
52
+ * "mode": "append_if_exists",
53
+ * "source": "delivery_contact",
54
+ * "value_json": "{\n \"street_name\": \"{{delivery_contact.street_name}}\",\n \"street_number\": \"{{delivery_contact.street_number}}\",\n \"city\": \"{{delivery_contact.city}}\",\n \"postal_code\": \"{{delivery_contact.postal_code}}\",\n \"country\": \"{{delivery_contact.country}}\",\n}"
55
+ * }
56
+ * ]
57
+ * }
47
58
  */
48
- created_automatically?: boolean;
49
- outputs?: {
59
+ config?: {
50
60
  [name: string]: any;
51
61
  };
52
- error_output?: ErrorOutput;
53
62
  }
54
63
  /**
55
64
  * example:
@@ -57,15 +66,14 @@ declare namespace Components {
57
66
  */
58
67
  export type AutomationActionId = string;
59
68
  export interface AutomationExecution {
60
- id: AutomationExecutionId;
69
+ id?: AutomationExecutionId;
61
70
  /**
62
71
  * example:
63
72
  * success
64
73
  */
65
- execution_status?: ExecutionStatus;
66
- entity_id: EntityId;
67
- org_id: OrganizationId;
68
- flow_id: AutomationFlowId;
74
+ status?: "pending" | "in_progress" | "success" | "failed" | "cancelled";
75
+ entity_id?: EntityId;
76
+ flow_id?: AutomationFlowId;
69
77
  /**
70
78
  * example:
71
79
  * Handle contact form
@@ -74,7 +82,80 @@ declare namespace Components {
74
82
  created_at?: string; // date-time
75
83
  updated_at?: string; // date-time
76
84
  current_action_id?: AutomationActionId;
77
- actions: AnyAction[];
85
+ actions?: {
86
+ status?: "pending" | "in_progress" | "success" | "failed";
87
+ started_at?: string; // date-time
88
+ updated_at?: string; // date-time
89
+ /**
90
+ * example:
91
+ * {
92
+ * "affected_entities": "cbbf0e83-0f37-4a0c-9801-93877ec0b2c2"
93
+ * }
94
+ */
95
+ outputs?: {
96
+ [name: string]: any;
97
+ };
98
+ /**
99
+ * example:
100
+ * {
101
+ * "email": "$.contact.email",
102
+ * "name": "$.contact.name",
103
+ * "template_id": "6a5b1249-4093-4724-b25a-ae985f7877d6"
104
+ * }
105
+ */
106
+ inputs?: {
107
+ [name: string]: any;
108
+ };
109
+ id?: AutomationActionId;
110
+ /**
111
+ * example:
112
+ * Create Contact
113
+ */
114
+ name?: string;
115
+ /**
116
+ * example:
117
+ * entity_mapping
118
+ */
119
+ type?: string;
120
+ /**
121
+ * example:
122
+ * {
123
+ * "target_schema": "contact",
124
+ * "mapping_attributes": [
125
+ * {
126
+ * "target": "email",
127
+ * "mode": "upsert_match",
128
+ * "source": "billing_contact.email"
129
+ * },
130
+ * {
131
+ * "target": "first_name",
132
+ * "mode": "copy_if_exists",
133
+ * "source": "billing_contact.first_name"
134
+ * },
135
+ * {
136
+ * "target": "last_name",
137
+ * "mode": "copy_if_exists",
138
+ * "source": "billing_contact.last_name"
139
+ * },
140
+ * {
141
+ * "target": "addresses",
142
+ * "mode": "append_if_exists",
143
+ * "source": "billing_contact",
144
+ * "value_json": "{\n \"street_name\": \"{{billing_contact.street_name}}\",\n \"street_number\": \"{{billing_contact.street_number}}\",\n \"city\": \"{{billing_contact.city}}\",\n \"postal_code\": \"{{billing_contact.postal_code}}\",\n \"country\": \"{{billing_contact.country}}\",\n}"
145
+ * },
146
+ * {
147
+ * "target": "addresses",
148
+ * "mode": "append_if_exists",
149
+ * "source": "delivery_contact",
150
+ * "value_json": "{\n \"street_name\": \"{{delivery_contact.street_name}}\",\n \"street_number\": \"{{delivery_contact.street_number}}\",\n \"city\": \"{{delivery_contact.city}}\",\n \"postal_code\": \"{{delivery_contact.postal_code}}\",\n \"country\": \"{{delivery_contact.country}}\",\n}"
151
+ * }
152
+ * ]
153
+ * }
154
+ */
155
+ config?: {
156
+ [name: string]: any;
157
+ };
158
+ }[];
78
159
  }
79
160
  /**
80
161
  * example:
@@ -88,21 +169,19 @@ declare namespace Components {
88
169
  * Handle contact form
89
170
  */
90
171
  flow_name?: string;
91
- /**
92
- * Number of automation executions that ran
93
- * example:
94
- * 7
95
- */
96
- runs?: number;
97
- triggers?: (FrontendSubmitTrigger | JourneySubmitTrigger | EntityOperationTrigger)[];
98
- trigger_conditions?: TriggerCondition[];
99
- /**
100
- * The entity schema
101
- * example:
102
- * submission
103
- */
104
- entity_schema?: string;
105
- actions?: AnyAction[];
172
+ triggers?: {
173
+ on: "entity_create" | "entity_update" | "entity_delete" | "journey_submit" | "frontend_submit";
174
+ /**
175
+ * example:
176
+ * {
177
+ * "entity_schema": "contact"
178
+ * }
179
+ */
180
+ config: {
181
+ [name: string]: any;
182
+ };
183
+ }[];
184
+ actions?: AutomationAction[];
106
185
  created_at?: string; // date-time
107
186
  updated_at?: string; // date-time
108
187
  }
@@ -111,377 +190,11 @@ declare namespace Components {
111
190
  * 7791b04a-16d2-44a2-9af9-2d59c25c512f
112
191
  */
113
192
  export type AutomationFlowId = string;
114
- export type Comparison = "equals" | "any_of" | "not_empty" | "is_empty";
115
- /**
116
- * example:
117
- * {
118
- * "id": "08g988-ojt2jtaga-292h-8978gsaga",
119
- * "name": "Create Document",
120
- * "type": "create-document",
121
- * "config": {
122
- * "template_id": {
123
- * "type": "string",
124
- * "example": "112b08ba-789c-42f2-9940-43b302f641e8\""
125
- * },
126
- * "filename": {
127
- * "type": "string",
128
- * "example": "newsletter.pdf\""
129
- * }
130
- * }
131
- * }
132
- */
133
- export interface CreateDocumentAction {
134
- id?: AutomationActionId;
135
- name?: string;
136
- type?: string;
137
- config?: CreateDocumentConfig;
138
- execution_status?: ExecutionStatus;
139
- started_at?: string;
140
- updated_at?: string;
141
- /**
142
- * Flag indicating whether the action was created automatically or manually
143
- */
144
- created_automatically?: boolean;
145
- outputs?: {
146
- [name: string]: any;
147
- };
148
- error_output?: ErrorOutput;
149
- }
150
- export interface CreateDocumentConfig {
151
- template_id?: string;
152
- filename?: string;
153
- }
154
193
  /**
155
194
  * example:
156
195
  * e3d3ebac-baab-4395-abf4-50b5bf1f8b74
157
196
  */
158
197
  export type EntityId = string;
159
- export interface EntityOperationTrigger {
160
- type: "entity_operation";
161
- configuration: {
162
- /**
163
- * example:
164
- * 210738fe-e1e6-446e-aaef-cce462d7d813
165
- */
166
- source_id?: string;
167
- /**
168
- * example:
169
- * submission
170
- */
171
- schema?: string;
172
- operations?: ("createEntity" | "updateEntity" | "deleteEntity")[];
173
- };
174
- }
175
- export type ErrorCode = "MAPPING_ERROR" | "REFRESH_RELATIONS_ERROR" | "DUPLICATE_ENTITY_ERROR" | "TRIGGER_WORKFLOW_ERROR" | "TIMEOUT_ERROR" | "INTERNAL_ERROR" | "EMAIL_TEMPLATE_MISSING_DATA_ERROR";
176
- export interface ErrorOutput {
177
- error_code: ErrorCode;
178
- error_reason: string;
179
- }
180
- export type ExecutionStatus = "pending" | "in_progress" | "success" | "failed" | "cancelled";
181
- export interface FrontendSubmitTrigger {
182
- type: "frontend_submission";
183
- configuration: {
184
- /**
185
- * example:
186
- * 99
187
- */
188
- source_id?: string;
189
- };
190
- }
191
- export interface GetExecutionsResp {
192
- total: number;
193
- results: AutomationExecution[];
194
- }
195
- export interface JourneySubmitTrigger {
196
- type: "journey_submission";
197
- configuration: {
198
- source_id: string; // uuid
199
- };
200
- }
201
- /**
202
- * example:
203
- * {
204
- * "id": "2520gja-2sgmsaga-0asg-822jgal",
205
- * "name": "Map Entity",
206
- * "type": "map-entity",
207
- * "config": {
208
- * "target_schema": "contact",
209
- * "target_unique": [
210
- * "email.email"
211
- * ],
212
- * "mapping_attributes": [
213
- * {
214
- * "target": "email",
215
- * "mode": "append_if_exists",
216
- * "source": "billing_contact",
217
- * "value_json": "{\n \"email\": \"billing_contact.email\"\n}"
218
- * },
219
- * {
220
- * "target": "_tags",
221
- * "mode": "set_value",
222
- * "value": [
223
- * "primary",
224
- * "payer"
225
- * ]
226
- * },
227
- * {
228
- * "target": "first_name",
229
- * "mode": "copy_if_exists",
230
- * "source": "billing_contact.first_name"
231
- * },
232
- * {
233
- * "target": "last_name",
234
- * "mode": "copy_if_exists",
235
- * "source": "billing_contact.last_name"
236
- * },
237
- * {
238
- * "target": "contact_type",
239
- * "mode": "set_value",
240
- * "value": "customer"
241
- * },
242
- * {
243
- * "target": "addresses",
244
- * "mode": "append_if_exists",
245
- * "source": "billing_contact",
246
- * "value_json": "{\n \"street_name\": \"billing_contact.street_name\",\n \"street_number\": \"billing_contact.street_number\",\n \"city\": \"billing_contact.city\",\n \"postal_code\": \"billing_contact.postal_code\",\n \"country\": \"billing_contact.country\",\n \"_tags\": [\"billing\", \"primary\"]\n}"
247
- * },
248
- * {
249
- * "target": "addresses",
250
- * "mode": "append_if_exists",
251
- * "source": "delivery_contact",
252
- * "value_json": "{\n \"street_name\": \"delivery_contact.street_name\",\n \"street_number\": \"delivery_contact.street_number\",\n \"city\": \"delivery_contact.city\",\n \"postal_code\": \"delivery_contact.postal_code\",\n \"country\": \"delivery_contact.country\",\n \"_tags\": [\"delivery\", \"secondary\"]\n}"
253
- * }
254
- * ]
255
- * }
256
- * }
257
- */
258
- export interface MapEntityAction {
259
- id?: AutomationActionId;
260
- name?: string;
261
- type?: string;
262
- config?: MapEntityActionConfig;
263
- execution_status?: ExecutionStatus;
264
- started_at?: string;
265
- updated_at?: string;
266
- /**
267
- * Flag indicating whether the action was created automatically or manually
268
- */
269
- created_automatically?: boolean;
270
- outputs?: {
271
- [name: string]: any;
272
- };
273
- error_output?: ErrorOutput;
274
- }
275
- export interface MapEntityActionConfig {
276
- target_schema?: string;
277
- target_unique?: string[];
278
- mapping_attributes?: MappingAttribute[];
279
- relation_attributes?: RelationAttribute[];
280
- }
281
- export interface MappingAttribute {
282
- /**
283
- * JSON like target path for the attribute. Eg. last_name
284
- */
285
- target: string;
286
- /**
287
- * - copy_if_exists - it replaces the target attribute with the source value
288
- * - append_if_exists - it currently replaces target attribute with array like values. Useful when you have multiple values to be added into one attribute.
289
- * - set_value - it sets a value to a predefined value. Must be used together with value property.
290
- *
291
- */
292
- mode: "copy_if_exists" | "append_if_exists" | "set_value";
293
- /**
294
- * JSON source path for the value to be extracted from. Eg: steps[1].['Product Info'].price
295
- *
296
- */
297
- source: string;
298
- /**
299
- * To be provided only when mapping json objects into a target attribute. Eg array of addresses.
300
- *
301
- */
302
- value_json?: string;
303
- /**
304
- * Any value to be set: string, number, string[], number[], JSON object, etc. It will override existing values, if any.
305
- *
306
- */
307
- value?: {
308
- };
309
- }
310
- /**
311
- * example:
312
- * e3d3ebac-baab-4395-abf4-50b5bf1f8b74
313
- */
314
- export type OrganizationId = string;
315
- export interface RelationAttribute {
316
- target: string;
317
- target_tags: string[];
318
- related_to: {
319
- schema: string;
320
- tag: string;
321
- };
322
- mode: "append" | "set";
323
- }
324
- export interface SearchAutomationsResp {
325
- total: number;
326
- results: AutomationFlow;
327
- }
328
- /**
329
- * example:
330
- * {
331
- * "id": "25jga0-gkasl26-0asg-908sgaj2",
332
- * "name": "Send Email",
333
- * "type": "send-email",
334
- * "config": {
335
- * "email_template_id": "gasj02-29ug9asgm-29t9gsaghg2g-pkmbhx2",
336
- * "language_code": "de"
337
- * }
338
- * }
339
- */
340
- export interface SendEmailAction {
341
- id?: AutomationActionId;
342
- name?: string;
343
- type?: string;
344
- config?: SendEmailActionConfig;
345
- execution_status?: ExecutionStatus;
346
- started_at?: string;
347
- updated_at?: string;
348
- /**
349
- * Flag indicating whether the action was created automatically or manually
350
- */
351
- created_automatically?: boolean;
352
- outputs?: {
353
- [name: string]: any;
354
- };
355
- error_output?: ErrorOutput;
356
- }
357
- export interface SendEmailActionConfig {
358
- email_template_id?: string;
359
- language_code?: "de" | "en";
360
- }
361
- export interface StartExecutionRequest {
362
- entity_id?: EntityId;
363
- flow_id?: AutomationFlowId;
364
- }
365
- /**
366
- * example:
367
- * {
368
- * "source": "billing_contact.email",
369
- * "comparison": "exists"
370
- * }
371
- */
372
- export interface TriggerCondition {
373
- source: string;
374
- comparison: Comparison;
375
- value?: string | number | string[] | number[];
376
- }
377
- /**
378
- * example:
379
- * {
380
- * "id": "2520gja-2sgmsaga-0asg-822jgal",
381
- * "name": "Trigger Webhook",
382
- * "type": "trigger-webhook",
383
- * "config": {
384
- * "entity_sources": [
385
- * "contact",
386
- * "account"
387
- * ],
388
- * "target_webhook_id": "25jg9ag2ga"
389
- * }
390
- * }
391
- */
392
- export interface TriggerWebhookAction {
393
- id?: AutomationActionId;
394
- name?: string;
395
- type?: string;
396
- config?: TriggerWebhookActionConfig;
397
- execution_status?: ExecutionStatus;
398
- started_at?: string;
399
- updated_at?: string;
400
- /**
401
- * Flag indicating whether the action was created automatically or manually
402
- */
403
- created_automatically?: boolean;
404
- outputs?: {
405
- [name: string]: any;
406
- };
407
- error_output?: ErrorOutput;
408
- }
409
- export interface TriggerWebhookActionConfig {
410
- entity_sources?: string[];
411
- target_webhook_id?: string;
412
- }
413
- /**
414
- * example:
415
- * {
416
- * "id": "08g988-ojt2jtaga-292h-8978gsaga",
417
- * "name": "Trigger Workflow",
418
- * "type": "trigger-workflow",
419
- * "config": {
420
- * "target_workflow": "mfptvUMH",
421
- * "conditions": [
422
- * {
423
- * "schema": "ivy-opportunity",
424
- * "source": "customer.type",
425
- * "comparison": "equals",
426
- * "value": "PRIVATE"
427
- * }
428
- * ],
429
- * "assign_steps": [
430
- * {
431
- * "step_name": "Lead Sales",
432
- * "user_ids": [
433
- * 10010729
434
- * ]
435
- * },
436
- * {
437
- * "step_name": "Operations",
438
- * "user_ids": [
439
- * 10010728,
440
- * 10010729
441
- * ]
442
- * }
443
- * ]
444
- * }
445
- * }
446
- */
447
- export interface TriggerWorkflowAction {
448
- id?: AutomationActionId;
449
- name?: string;
450
- type?: string;
451
- config?: TriggerWorkflowConfig;
452
- execution_status?: ExecutionStatus;
453
- started_at?: string;
454
- updated_at?: string;
455
- /**
456
- * Flag indicating whether the action was created automatically or manually
457
- */
458
- created_automatically?: boolean;
459
- outputs?: {
460
- [name: string]: any;
461
- };
462
- error_output?: ErrorOutput;
463
- }
464
- /**
465
- * example:
466
- * {
467
- * "schema": "contact",
468
- * "source": "billing_contact.email",
469
- * "comparison": "exists",
470
- * "value": "test@epilot.cloud"
471
- * }
472
- */
473
- export interface TriggerWorkflowCondition {
474
- source: string;
475
- comparison: Comparison;
476
- value?: string | number | string[] | number[];
477
- schema: string;
478
- }
479
- export interface TriggerWorkflowConfig {
480
- target_workflow?: string;
481
- conditions?: TriggerWorkflowCondition[];
482
- assignees?: string[];
483
- assign_steps?: AssignUsersToStep[];
484
- }
485
198
  }
486
199
  }
487
200
  declare namespace Paths {
@@ -536,7 +249,7 @@ declare namespace Paths {
536
249
  from?: Parameters.From;
537
250
  }
538
251
  namespace Responses {
539
- export type $200 = Components.Schemas.GetExecutionsResp;
252
+ export type $200 = Components.Schemas.AutomationExecution[];
540
253
  }
541
254
  }
542
255
  namespace GetFlow {
@@ -559,7 +272,7 @@ declare namespace Paths {
559
272
  }
560
273
  export type RequestBody = Components.Schemas.AutomationFlow;
561
274
  namespace Responses {
562
- export type $200 = Components.Schemas.AutomationFlow;
275
+ export type $201 = Components.Schemas.AutomationFlow;
563
276
  }
564
277
  }
565
278
  namespace SearchFlows {
@@ -571,24 +284,28 @@ declare namespace Paths {
571
284
  */
572
285
  export type Schema = string;
573
286
  export type Size = number;
574
- /**
575
- * example:
576
- * 600945fe-212e-4b97-acf7-391d64648384
577
- */
578
- export type TriggerSourceId = string;
579
287
  }
580
288
  export interface QueryParameters {
581
289
  schema?: Parameters.Schema;
582
290
  size?: Parameters.Size;
583
291
  from?: Parameters.From;
584
- trigger_source_id?: Parameters.TriggerSourceId;
585
292
  }
586
293
  namespace Responses {
587
- export type $200 = Components.Schemas.SearchAutomationsResp;
294
+ export interface $200 {
295
+ /**
296
+ * example:
297
+ * 1
298
+ */
299
+ total?: number;
300
+ results?: Components.Schemas.AutomationFlow[];
301
+ }
588
302
  }
589
303
  }
590
304
  namespace StartExecution {
591
- export type RequestBody = Components.Schemas.StartExecutionRequest;
305
+ export interface RequestBody {
306
+ entity_id?: Components.Schemas.EntityId;
307
+ flow_id?: Components.Schemas.AutomationFlowId;
308
+ }
592
309
  namespace Responses {
593
310
  export type $201 = Components.Schemas.AutomationExecution;
594
311
  }
@@ -635,7 +352,7 @@ export interface OperationMethods {
635
352
  parameters?: Parameters<Paths.PutFlow.PathParameters> | null,
636
353
  data?: Paths.PutFlow.RequestBody,
637
354
  config?: AxiosRequestConfig
638
- ): OperationResponse<Paths.PutFlow.Responses.$200>
355
+ ): OperationResponse<Paths.PutFlow.Responses.$201>
639
356
  /**
640
357
  * deleteFlow - deleteFlow
641
358
  *
@@ -686,16 +403,6 @@ export interface OperationMethods {
686
403
  data?: any,
687
404
  config?: AxiosRequestConfig
688
405
  ): OperationResponse<Paths.CancelExecution.Responses.$200>
689
- /**
690
- * retriggerAction - retriggerAction
691
- *
692
- * Retrigger a specific automation execution action
693
- */
694
- 'retriggerAction'(
695
- parameters?: Parameters<UnknownParamsObject> | null,
696
- data?: any,
697
- config?: AxiosRequestConfig
698
- ): OperationResponse<any>
699
406
  }
700
407
 
701
408
  export interface PathsDictionary {
@@ -741,7 +448,7 @@ export interface PathsDictionary {
741
448
  parameters?: Parameters<Paths.PutFlow.PathParameters> | null,
742
449
  data?: Paths.PutFlow.RequestBody,
743
450
  config?: AxiosRequestConfig
744
- ): OperationResponse<Paths.PutFlow.Responses.$200>
451
+ ): OperationResponse<Paths.PutFlow.Responses.$201>
745
452
  /**
746
453
  * deleteFlow - deleteFlow
747
454
  *
@@ -797,18 +504,6 @@ export interface PathsDictionary {
797
504
  config?: AxiosRequestConfig
798
505
  ): OperationResponse<Paths.CancelExecution.Responses.$200>
799
506
  }
800
- ['/v1/automation/executions/{execution_id}/{action_id}/retrigger']: {
801
- /**
802
- * retriggerAction - retriggerAction
803
- *
804
- * Retrigger a specific automation execution action
805
- */
806
- 'post'(
807
- parameters?: Parameters<UnknownParamsObject> | null,
808
- data?: any,
809
- config?: AxiosRequestConfig
810
- ): OperationResponse<any>
811
- }
812
507
  }
813
508
 
814
509
  export type Client = OpenAPIClient<OperationMethods, PathsDictionary>