@epilot/automation-client 2.3.0 → 2.5.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/dist/client.d.ts CHANGED
File without changes
package/dist/client.js CHANGED
File without changes
File without changes
File without changes
package/dist/index.d.ts CHANGED
File without changes
package/dist/index.js CHANGED
File without changes
package/dist/openapi.d.ts CHANGED
@@ -226,7 +226,125 @@ declare namespace Components {
226
226
  * }
227
227
  */
228
228
  SendEmailActionConfig | /* Creates an order entity with prices from journey */ CartCheckoutActionConfig | AutomationActionConfig;
229
- export type AnyTrigger = FrontendSubmitTrigger | JourneySubmitTrigger | ApiSubmissionTrigger | EntityOperationTrigger | ActivityTrigger | EntityManualTrigger | ReceivedEmailTrigger;
229
+ export type AnyTrigger = FrontendSubmitTrigger | JourneySubmitTrigger | ApiSubmissionTrigger | /**
230
+ * - If provides filter_config, executes an automation based on the filtered configuration when an entity event occurs.
231
+ * - The conditions on a filter follows the event bridge patterns - `https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html`
232
+ * | Comparison | Example | Rule syntax |
233
+ * |------------------------|-----------------------------------------------------|----------------------------------------------------------|
234
+ * | Null | first_name is null | `"first_name": [ null ]` |
235
+ * | Empty | last_name is empty | `"last_name": [""]` |
236
+ * | Equals | email is "j.doe@email.com" | `"email": [ "j.doe@email.com" ]` |
237
+ * | Equals (ignore case) | first_name is "John" | `"first_name": [ { "equals-ignore-case": "john" } ]` |
238
+ * | And | fist_name is "John" and last_name is "Doe" | `"first_name": [ "John" ], "last_name": ["Doe"]` |
239
+ * | Or | PaymentType is "Invoice" or "SEPA" | `"PaymentType": [ "invoice", "sepa"]` |
240
+ * | Or (multiple fields) | first_name is "John", or last_name is "Doe". | `"$or": [ { "first_name": [ "John" ] }, { "last_name": [ "Doe" ] } ]` |
241
+ * | Not | status is anything but "cancelled" | `"status": [ { "anything-but": [ "cancelled" ] } ]` |
242
+ * | Numeric (equals) | Price is 100 | `"Price": [ { "numeric": [ "=", 100 ] } ]` |
243
+ * | Numeric (range) | Price is more than 10, and less than or equal to 20 | `"Price": [ { "numeric": [ ">", 10, "<=", 20 ] } ]` |
244
+ * | Exists | ProductName exists | `"ProductName": [ { "exists": true } ]` |
245
+ * | Does not exist | ProductName does not exist | `"ProductName": [ { "exists": false } ]` |
246
+ * | Begins with | OpportunityNumber starts with OPP- | `"opportunity_number": [ { "prefix": "OPP-" } ]` |
247
+ * | Ends with | FileName ends with a .png extension | `"filename": [ { "suffix": ".png" } ]` |
248
+ * - To run the execution on all update events
249
+ * ```
250
+ * {
251
+ * "type": "filter_entity_event",
252
+ * "configuration": {
253
+ * "operation": {
254
+ * "operation": ["updateEntity"]
255
+ * }
256
+ * }
257
+ * }
258
+ * ```
259
+ * - To run the execution only when the updates are from a portal user
260
+ * ```
261
+ * {
262
+ * "type": "filter_entity_event",
263
+ * "configuration": {
264
+ * "operation": {
265
+ * "operation": ["updateEntity"]
266
+ * },
267
+ * "activity": {
268
+ * "type": "EntityUpdatedFromPortal"
269
+ * }
270
+ * }
271
+ * }
272
+ * ```
273
+ * - To run the execution only when there is an update on a specific attribute
274
+ * ```
275
+ * Only starts the automation when the email on a contact is changed
276
+ * {
277
+ * "type": "filter_entity_event",
278
+ * "configuration": {
279
+ * "operation": {
280
+ * "operation": ["updateEntity"],
281
+ * "payload": {
282
+ * "_schema": ["contact"]
283
+ * },
284
+ * "diff": {
285
+ * "updated": {
286
+ * "email": [{ "exists": true }]
287
+ * }
288
+ * }
289
+ * }
290
+ * }
291
+ * }
292
+ * ```
293
+ * - To run the execution only when a specific attribute is altered(created/updated/deleted)
294
+ * ```
295
+ * Only starts the automation when a price is altered on a contract
296
+ * {
297
+ * "type": "filter_entity_event",
298
+ * "configuration": {
299
+ * "operation": {
300
+ * "payload": {
301
+ * "_schema": ["contract"]
302
+ * },
303
+ * "diff": {
304
+ * // Whether he first_name has been added, updated, or removed
305
+ * $or: [
306
+ * {
307
+ * 'added.first_name': [{ exists: true }]
308
+ * },
309
+ * {
310
+ * 'updated.first_name': [{ exists: true }]
311
+ * },
312
+ * {
313
+ * 'deleted.first_name': [{ exists: true }]
314
+ * }
315
+ * ]
316
+ * }
317
+ * }
318
+ * }
319
+ * }
320
+ * ```
321
+ * - To run the execution if an attribute is changed from one state to another
322
+ * ```
323
+ * Only starts the automation when the order status changes from `open_for_acceptance` to `placed`
324
+ * {
325
+ * "type": "filter_entity_event",
326
+ * "configuration": {
327
+ * "operation": {
328
+ * "operation": ["updateEntity"],
329
+ * "payload": {
330
+ * "_schema": ["order"],
331
+ * "status": ["placed"]
332
+ * },
333
+ * "diff": {
334
+ * "updated": {
335
+ * "status": ["open_for_acceptance"]
336
+ * }
337
+ * }
338
+ * }
339
+ * }
340
+ * }
341
+ * ```
342
+ *
343
+ */
344
+ EntityOperationTrigger | ActivityTrigger | EntityManualTrigger | ReceivedEmailTrigger;
345
+ export interface AnythingButCondition {
346
+ "anything-but"?: string[];
347
+ }
230
348
  export interface ApiCallerContext {
231
349
  [name: string]: any;
232
350
  EpilotAuth?: {
@@ -247,7 +365,12 @@ declare namespace Components {
247
365
  * "email": "n.ahmad@epilot.cloud"
248
366
  * }
249
367
  */
250
- token?: {
368
+ claims?: {
369
+ /**
370
+ * example:
371
+ * 10006129
372
+ */
373
+ userId?: string;
251
374
  /**
252
375
  * example:
253
376
  * 476e9b48-42f4-4234-a2b0-4668b34626ce
@@ -269,6 +392,21 @@ declare namespace Components {
269
392
  */
270
393
  "custom:ivy_user_id"?: string;
271
394
  };
395
+ /**
396
+ * example:
397
+ * 10006129
398
+ */
399
+ userId?: string;
400
+ /**
401
+ * example:
402
+ * 739224
403
+ */
404
+ organizationId?: string;
405
+ /**
406
+ * example:
407
+ * eyJraWQiOi...
408
+ */
409
+ token?: string;
272
410
  };
273
411
  }
274
412
  export interface ApiSubmissionTrigger {
@@ -717,6 +855,9 @@ declare namespace Components {
717
855
  template_id?: string;
718
856
  filename?: string;
719
857
  }
858
+ export type DiffAdded = FilterConditionOnEvent;
859
+ export type DiffDeleted = FilterConditionOnEvent;
860
+ export type DiffUpdated = FilterConditionOnEvent;
720
861
  /**
721
862
  * example:
722
863
  * e3d3ebac-baab-4395-abf4-50b5bf1f8b74
@@ -748,6 +889,121 @@ declare namespace Components {
748
889
  };
749
890
  }
750
891
  export type EntityOperation = "createEntity" | "updateEntity" | "deleteEntity";
892
+ /**
893
+ * - If provides filter_config, executes an automation based on the filtered configuration when an entity event occurs.
894
+ * - The conditions on a filter follows the event bridge patterns - `https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html`
895
+ * | Comparison | Example | Rule syntax |
896
+ * |------------------------|-----------------------------------------------------|----------------------------------------------------------|
897
+ * | Null | first_name is null | `"first_name": [ null ]` |
898
+ * | Empty | last_name is empty | `"last_name": [""]` |
899
+ * | Equals | email is "j.doe@email.com" | `"email": [ "j.doe@email.com" ]` |
900
+ * | Equals (ignore case) | first_name is "John" | `"first_name": [ { "equals-ignore-case": "john" } ]` |
901
+ * | And | fist_name is "John" and last_name is "Doe" | `"first_name": [ "John" ], "last_name": ["Doe"]` |
902
+ * | Or | PaymentType is "Invoice" or "SEPA" | `"PaymentType": [ "invoice", "sepa"]` |
903
+ * | Or (multiple fields) | first_name is "John", or last_name is "Doe". | `"$or": [ { "first_name": [ "John" ] }, { "last_name": [ "Doe" ] } ]` |
904
+ * | Not | status is anything but "cancelled" | `"status": [ { "anything-but": [ "cancelled" ] } ]` |
905
+ * | Numeric (equals) | Price is 100 | `"Price": [ { "numeric": [ "=", 100 ] } ]` |
906
+ * | Numeric (range) | Price is more than 10, and less than or equal to 20 | `"Price": [ { "numeric": [ ">", 10, "<=", 20 ] } ]` |
907
+ * | Exists | ProductName exists | `"ProductName": [ { "exists": true } ]` |
908
+ * | Does not exist | ProductName does not exist | `"ProductName": [ { "exists": false } ]` |
909
+ * | Begins with | OpportunityNumber starts with OPP- | `"opportunity_number": [ { "prefix": "OPP-" } ]` |
910
+ * | Ends with | FileName ends with a .png extension | `"filename": [ { "suffix": ".png" } ]` |
911
+ * - To run the execution on all update events
912
+ * ```
913
+ * {
914
+ * "type": "filter_entity_event",
915
+ * "configuration": {
916
+ * "operation": {
917
+ * "operation": ["updateEntity"]
918
+ * }
919
+ * }
920
+ * }
921
+ * ```
922
+ * - To run the execution only when the updates are from a portal user
923
+ * ```
924
+ * {
925
+ * "type": "filter_entity_event",
926
+ * "configuration": {
927
+ * "operation": {
928
+ * "operation": ["updateEntity"]
929
+ * },
930
+ * "activity": {
931
+ * "type": "EntityUpdatedFromPortal"
932
+ * }
933
+ * }
934
+ * }
935
+ * ```
936
+ * - To run the execution only when there is an update on a specific attribute
937
+ * ```
938
+ * Only starts the automation when the email on a contact is changed
939
+ * {
940
+ * "type": "filter_entity_event",
941
+ * "configuration": {
942
+ * "operation": {
943
+ * "operation": ["updateEntity"],
944
+ * "payload": {
945
+ * "_schema": ["contact"]
946
+ * },
947
+ * "diff": {
948
+ * "updated": {
949
+ * "email": [{ "exists": true }]
950
+ * }
951
+ * }
952
+ * }
953
+ * }
954
+ * }
955
+ * ```
956
+ * - To run the execution only when a specific attribute is altered(created/updated/deleted)
957
+ * ```
958
+ * Only starts the automation when a price is altered on a contract
959
+ * {
960
+ * "type": "filter_entity_event",
961
+ * "configuration": {
962
+ * "operation": {
963
+ * "payload": {
964
+ * "_schema": ["contract"]
965
+ * },
966
+ * "diff": {
967
+ * // Whether he first_name has been added, updated, or removed
968
+ * $or: [
969
+ * {
970
+ * 'added.first_name': [{ exists: true }]
971
+ * },
972
+ * {
973
+ * 'updated.first_name': [{ exists: true }]
974
+ * },
975
+ * {
976
+ * 'deleted.first_name': [{ exists: true }]
977
+ * }
978
+ * ]
979
+ * }
980
+ * }
981
+ * }
982
+ * }
983
+ * ```
984
+ * - To run the execution if an attribute is changed from one state to another
985
+ * ```
986
+ * Only starts the automation when the order status changes from `open_for_acceptance` to `placed`
987
+ * {
988
+ * "type": "filter_entity_event",
989
+ * "configuration": {
990
+ * "operation": {
991
+ * "operation": ["updateEntity"],
992
+ * "payload": {
993
+ * "_schema": ["order"],
994
+ * "status": ["placed"]
995
+ * },
996
+ * "diff": {
997
+ * "updated": {
998
+ * "status": ["open_for_acceptance"]
999
+ * }
1000
+ * }
1001
+ * }
1002
+ * }
1003
+ * }
1004
+ * ```
1005
+ *
1006
+ */
751
1007
  export interface EntityOperationTrigger {
752
1008
  type: "entity_operation";
753
1009
  configuration: {
@@ -755,21 +1011,83 @@ declare namespace Components {
755
1011
  * example:
756
1012
  * submission
757
1013
  */
758
- schema: string;
759
- operations: [
1014
+ schema?: string;
1015
+ operations?: [
760
1016
  EntityOperation,
761
1017
  ...EntityOperation[]
762
1018
  ];
763
1019
  include_activities?: string[];
764
1020
  exclude_activities?: string[];
1021
+ filter_config?: {
1022
+ operation?: {
1023
+ /**
1024
+ * Filter on operation type. If not specified, all operations will be matched on execution.
1025
+ * Example:
1026
+ * 1. Filter all the createEntity/updateEntity operations
1027
+ * ```
1028
+ * {
1029
+ * "operation":{
1030
+ * "operation": ["createEntity", "updateEntity"]
1031
+ * }
1032
+ * }
1033
+ * ```
1034
+ *
1035
+ */
1036
+ operation?: EntityOperation[];
1037
+ payload?: FilterConditionOnEvent;
1038
+ diff?: OrConditionForDiff | {
1039
+ added?: FilterConditionOnEvent;
1040
+ updated?: FilterConditionOnEvent;
1041
+ deleted?: FilterConditionOnEvent;
1042
+ };
1043
+ };
1044
+ activity?: {
1045
+ /**
1046
+ * Filter on activity type. If not specified, all activities will be matched on execution.
1047
+ * Example:
1048
+ * 1. Filter the events when an entity is updated from portal
1049
+ * ```
1050
+ * {
1051
+ * "activity":{
1052
+ * "type": ["EntityUpdatedFromPortal"]
1053
+ * }
1054
+ * }
1055
+ * ```
1056
+ * 2. Filter the events when either a doc is uploaded/removed on an entity from a portal
1057
+ * ```
1058
+ * {
1059
+ * "activity":{
1060
+ * "type": ["DocUploadedFromPortal", "DocRemovedFromPortal"]
1061
+ * }
1062
+ * }
1063
+ * ```
1064
+ *
1065
+ * example:
1066
+ * [
1067
+ * "EntityUpdatedFromPortal",
1068
+ * "EntityUpdatedFromPortal"
1069
+ * ]
1070
+ */
1071
+ type?: string[];
1072
+ };
1073
+ };
765
1074
  };
766
1075
  }
1076
+ export interface EqualsIgnoreCaseCondition {
1077
+ "equals-ignore-case"?: string;
1078
+ }
767
1079
  export type ErrorCode = "MAPPING_ERROR" | "REFRESH_RELATIONS_ERROR" | "DUPLICATE_ENTITY_ERROR" | "TRIGGER_WORKFLOW_ERROR" | "TIMEOUT_ERROR" | "BAD_CONFIG" | "INTERNAL_ERROR";
768
1080
  export interface ErrorOutput {
769
1081
  error_code: ErrorCode;
770
1082
  error_reason: string;
771
1083
  }
772
1084
  export type ExecutionStatus = "pending" | "in_progress" | "success" | "failed" | "cancelled";
1085
+ export interface ExistsCondition {
1086
+ exists?: boolean;
1087
+ }
1088
+ export type FilterConditionOnEvent = OrCondition | {
1089
+ [name: string]: (string | EqualsIgnoreCaseCondition | AnythingButCondition | NumericCondition | ExistsCondition | PrefixCondition | SuffixCondition)[];
1090
+ };
773
1091
  export interface FrontendSubmitTrigger {
774
1092
  type: "frontend_submission";
775
1093
  configuration: {
@@ -1049,6 +1367,9 @@ declare namespace Components {
1049
1367
  */
1050
1368
  version?: number;
1051
1369
  }
1370
+ export interface NumericCondition {
1371
+ numeric?: (string | number)[];
1372
+ }
1052
1373
  /**
1053
1374
  * Mapping operation nodes are either primitive values or operation node objects
1054
1375
  */
@@ -1071,11 +1392,20 @@ declare namespace Components {
1071
1392
  */
1072
1393
  _copy?: string;
1073
1394
  }
1395
+ export interface OrCondition {
1396
+ $or?: FilterConditionOnEvent[];
1397
+ }
1398
+ export interface OrConditionForDiff {
1399
+ $or?: (FilterConditionOnEvent | FilterConditionOnEvent | FilterConditionOnEvent)[];
1400
+ }
1074
1401
  /**
1075
1402
  * example:
1076
1403
  * e3d3ebac-baab-4395-abf4-50b5bf1f8b74
1077
1404
  */
1078
1405
  export type OrganizationId = string;
1406
+ export interface PrefixCondition {
1407
+ prefix?: string;
1408
+ }
1079
1409
  export type PrimitiveJSONValue = any;
1080
1410
  export interface ReceivedEmailTrigger {
1081
1411
  type: "received_email";
@@ -1292,6 +1622,9 @@ declare namespace Components {
1292
1622
  */
1293
1623
  AutomationFlowId;
1294
1624
  }
1625
+ export interface SuffixCondition {
1626
+ suffix?: string;
1627
+ }
1295
1628
  /**
1296
1629
  * example:
1297
1630
  * {