@wix/automations 1.0.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.
@@ -0,0 +1,775 @@
1
+ interface Activation {
2
+ /** Activation ID */
3
+ _id?: string;
4
+ /** Activation automation */
5
+ automation?: Automation;
6
+ }
7
+ /** Automation */
8
+ interface Automation extends AutomationOriginInfoOneOf {
9
+ /** Application info */
10
+ applicationInfo?: ApplicationOrigin;
11
+ /** Preinstalled info */
12
+ preinstalledInfo?: PreinstalledOrigin;
13
+ /**
14
+ * Automation ID.
15
+ * @readonly
16
+ */
17
+ _id?: string | null;
18
+ /**
19
+ * Revision number, which increments by 1 each time the Automation is updated.
20
+ * To prevent conflicting changes,
21
+ * the current revision must be passed when updating the Automation.
22
+ *
23
+ * Ignored when creating an Automation.
24
+ * @readonly
25
+ */
26
+ revision?: string | null;
27
+ /**
28
+ * information about the creator of the automation
29
+ * @readonly
30
+ */
31
+ createdBy?: AuditInfo;
32
+ /**
33
+ * Date and time the Automation was created.
34
+ * @readonly
35
+ */
36
+ _createdDate?: Date;
37
+ /**
38
+ * information about who updated of the automation
39
+ * @readonly
40
+ */
41
+ updatedBy?: AuditInfo;
42
+ /**
43
+ * Date and time the Automation was last updated.
44
+ * @readonly
45
+ */
46
+ _updatedDate?: Date;
47
+ /** Automation name */
48
+ name?: string;
49
+ /** Automation description */
50
+ description?: string | null;
51
+ /** Automation runtime configuration */
52
+ configuration?: AutomationConfiguration;
53
+ /** Origin type */
54
+ origin?: Origin;
55
+ /** Automation settings */
56
+ settings?: AutomationSettings;
57
+ }
58
+ /** @oneof */
59
+ interface AutomationOriginInfoOneOf {
60
+ /** Application info */
61
+ applicationInfo?: ApplicationOrigin;
62
+ /** Preinstalled info */
63
+ preinstalledInfo?: PreinstalledOrigin;
64
+ }
65
+ interface ActionSettings {
66
+ /** list of permanent action ids of actions that cannot be deleted (default - empty, all actions are deletable by default) */
67
+ permanentActionIds?: string[];
68
+ /** list of readonly action ids, (default - empty, all actions are editable by default) */
69
+ readonlyActionIds?: string[];
70
+ /** sets if adding a delay action is disabled for this automation */
71
+ disableDelayAddition?: boolean;
72
+ /** sets if adding a condition action is disabled for this automation */
73
+ disableConditionAddition?: boolean;
74
+ }
75
+ interface AuditInfo extends AuditInfoIdOneOf {
76
+ /** user identifier */
77
+ userId?: string;
78
+ /** application identifier */
79
+ appId?: string;
80
+ }
81
+ /** @oneof */
82
+ interface AuditInfoIdOneOf {
83
+ /** user identifier */
84
+ userId?: string;
85
+ /** application identifier */
86
+ appId?: string;
87
+ }
88
+ /** Automation runtime configuration */
89
+ interface AutomationConfiguration {
90
+ /** Automation's Status */
91
+ status?: AutomationConfigurationStatus;
92
+ /** Trigger configuration */
93
+ trigger?: Trigger;
94
+ /** actions that run in parallel after the trigger */
95
+ rootActionIds?: string[];
96
+ /**
97
+ * map of all actions by actionId
98
+ * The key is the actionId of the action, and the value is the action configuration
99
+ */
100
+ actions?: Record<string, AutomationConfigurationAction>;
101
+ }
102
+ declare enum TimeUnit {
103
+ UNDEFINED = "UNDEFINED",
104
+ MINUTES = "MINUTES",
105
+ HOURS = "HOURS",
106
+ DAYS = "DAYS",
107
+ WEEKS = "WEEKS",
108
+ MONTHS = "MONTHS"
109
+ }
110
+ interface Filter {
111
+ /** the filter identifier */
112
+ _id?: string;
113
+ /** the field key from the schema, for example "formId" */
114
+ fieldKey?: string;
115
+ /** filter expression that evaluates to a boolean, for example - {{ contains(["guid1","guid2"];formId) }} */
116
+ filterExpression?: string;
117
+ }
118
+ interface FutureDateActivationOffset {
119
+ /**
120
+ * expression of offset before the trigger's time (in selected time unit), when the Automation should run
121
+ * only allows negative offset from the trigger's date (before the trigger), positive offset should be achieved via offset delay action
122
+ * preScheduledEventOffsetExpression: "{{5}}" + timeUnit: Days - to run the Automation 5 days before the trigger's date
123
+ * or, preScheduledEventOffsetExpression: "{{ someNumberField }}" + timeUnit: Minutes, to run the Automation someNumberField's value in minutes before the trigger's date
124
+ */
125
+ preScheduledEventOffsetExpression?: string;
126
+ /** Time unit for the scheduled event offset */
127
+ scheduledEventOffsetTimeUnit?: TimeUnit;
128
+ }
129
+ interface ConditionExpressionGroup {
130
+ /** expression group operator */
131
+ operator?: Operator;
132
+ /**
133
+ * list of boolean expressions to be evaluated with the given operator
134
+ * examples - {{ true }}, {{ someBooleanField }}, {{ contains(["guid1...","guid2..."];formId) }}
135
+ */
136
+ booleanExpressions?: string[];
137
+ }
138
+ declare enum Operator {
139
+ UNKNOWN_OPERATOR = "UNKNOWN_OPERATOR",
140
+ OR = "OR",
141
+ AND = "AND"
142
+ }
143
+ declare enum Type {
144
+ /** Automation will be triggered according to the trigger configuration */
145
+ UNKNOWN_ACTION_TYPE = "UNKNOWN_ACTION_TYPE",
146
+ /** App defined Action */
147
+ APP_DEFINED = "APP_DEFINED",
148
+ /** Condition Action */
149
+ CONDITION = "CONDITION",
150
+ /** Delay Action */
151
+ DELAY = "DELAY",
152
+ /** RateLimit Action */
153
+ RATE_LIMIT = "RATE_LIMIT",
154
+ /** Output Action */
155
+ OUTPUT = "OUTPUT"
156
+ }
157
+ interface AppDefinedAction {
158
+ /** Action app id */
159
+ appId?: string;
160
+ /** Action key */
161
+ actionKey?: string;
162
+ /**
163
+ * Action input mapping, example:
164
+ * {
165
+ * "to": "{{ var(contact.email) }}",
166
+ * "subject": "Your registration to {{ var(eventName) }} is Confirmed",
167
+ * "body": "Hi {{ var(contact.name) }}, you are confirmed for the event"
168
+ * }
169
+ */
170
+ inputMapping?: Record<string, any> | null;
171
+ /**
172
+ * optional skip condition configuration - if this action should be skipped when the automation runs (following actions of a skipped action will still run)
173
+ * the action will be skipped if either of the expression groups evaluate to `true`
174
+ * the relation between the expression groups is an OR relation.
175
+ */
176
+ skipConditionOrExpressionGroups?: ConditionExpressionGroup[];
177
+ /** actions to run in parallel after this action finishes */
178
+ postActionIds?: string[];
179
+ }
180
+ interface ConditionAction {
181
+ /**
182
+ * the condition evaluates to `true` if either of the expression groups evaluate to `true`
183
+ * the relation between the expression groups is an OR relation.
184
+ */
185
+ orExpressionGroups?: ConditionExpressionGroup[];
186
+ /** actions to run when the entire condition is evaluated to `true` */
187
+ truePostActionIds?: string[];
188
+ /** actions to run when the entire condition is evaluated to `false` */
189
+ falsePostActionIds?: string[];
190
+ }
191
+ interface DelayAction {
192
+ /**
193
+ * optional - expression for amount of time to wait (in selected time unit) - from a specific date or from the time the action is executed
194
+ * offsetExpression: "{{5}}" + timeUnit: Days - to wait for 5 days from the time the delay was invoked
195
+ * or, offsetExpression: "{{5}}" + timeUnit: Days + dueDateEpochExpression: "{{someDateField}}" - to wait for 5 days from the time date in "someDateField" field in the payload
196
+ * or, offsetExpression: "{{ someNumberField }}" + timeUnit: Minutes, to wait for someNumberField's value in minutes
197
+ */
198
+ offsetExpression?: string | null;
199
+ /** Time unit for delay offset */
200
+ offsetTimeUnit?: TimeUnit;
201
+ /**
202
+ * optional - expression of the due date to wait until, if an offset was defined, it will be calculated from this date
203
+ * number of milliseconds since the Unix Epoch (1 January, 1970 UTC)
204
+ * for example - "{{ 18238348023423 }}", or "{{ someEpochFromPayloadField }}" / "{{ contact.birthdate }}"
205
+ */
206
+ dueDateEpochExpression?: string | null;
207
+ /** actions to run in parallel after this action finishes */
208
+ postActionIds?: string[];
209
+ }
210
+ interface RateLimitAction {
211
+ /**
212
+ * Maximum number of activations expression. the expression will need to be parsed to Int on runtime
213
+ * for example - "{{ 1 }}" to set max activations to 1, or "{{ var(someNumberField) }}" to set max activations as the value of "someNumberField" from the payload
214
+ */
215
+ maxActivationsExpression?: string;
216
+ /**
217
+ * Duration of the rate limiting window (in selected time unit) expression for rate limiter, if empty then no time limit. the expression will need to be parsed to Int on runtime
218
+ * for example - "{{ 10 }}" to set timeframe to be 10 minutes, or {{ var(someNumberField) }} to set timeframe in minutes as the value of "someNumberField" from the payload
219
+ */
220
+ rateLimitDurationExpression?: string | null;
221
+ /** Time unit for the rate limit duration */
222
+ rateLimitDurationTimeUnit?: TimeUnit;
223
+ /**
224
+ * Unique identifier of each activation by which rate limiter will count activations, expected return type is string
225
+ * for example - {{ var(contact.id) }} to set the unique identifier as the value of "contact.id" from the payload
226
+ */
227
+ uniqueIdentifierExpression?: string | null;
228
+ /** actions to run in parallel after this action finishes */
229
+ postActionIds?: string[];
230
+ }
231
+ declare enum AutomationConfigurationStatus {
232
+ /** unused */
233
+ UNKNOWN_STATUS = "UNKNOWN_STATUS",
234
+ /** Automation will be triggered according to the trigger configuration */
235
+ ACTIVE = "ACTIVE",
236
+ /** Automation will not be triggered */
237
+ INACTIVE = "INACTIVE"
238
+ }
239
+ interface Trigger {
240
+ /** Trigger Application id */
241
+ appId?: string;
242
+ /** Trigger key */
243
+ triggerKey?: string;
244
+ /**
245
+ * optional - list of filters on schema fields
246
+ * the relation between the filter expressions is an AND relation.
247
+ * all filter expressions must be evaluated to `true` for a given payload in order for the automation to be executed
248
+ */
249
+ filters?: Filter[];
250
+ /** optional - future date trigger activation offset */
251
+ scheduledEventOffset?: FutureDateActivationOffset;
252
+ }
253
+ interface AutomationConfigurationAction extends AutomationConfigurationActionInfoOneOf {
254
+ /** App defined Action (via RPC, HTTP or Velo) */
255
+ appDefinedInfo?: AppDefinedAction;
256
+ /** Condition action */
257
+ conditionInfo?: ConditionAction;
258
+ /** Delay action */
259
+ delayInfo?: DelayAction;
260
+ /** Rate limiting action */
261
+ rateLimitInfo?: RateLimitAction;
262
+ /** Action id, if not specified, will be generated */
263
+ _id?: string | null;
264
+ /** Type of the action */
265
+ type?: Type;
266
+ /**
267
+ * Human readable name for the action (may only contain alphanumeric characters and underscores) to differentiate from other actions of the same kind.
268
+ * if the action has output, the output will be available in the payload under this name, otherwise it will be concatenated to the payload as is
269
+ * without namespaces (or in case of exact same namespaces), if the user has multiple actions of the same kind (appId+actionKey), the output will be overwritten.
270
+ *
271
+ * for example, given:
272
+ * - if the action output looks like this - { "message": "hello" }
273
+ * - the namespace is "action_1"
274
+ * - the trigger payload looks like this - { "someField": "50", "someBoolean": true }
275
+ *
276
+ * the payload will look like this:
277
+ * {
278
+ * "someField": "50",
279
+ * "someBoolean": true,
280
+ * "action_1": {
281
+ * "message": "hello"
282
+ * }
283
+ * }
284
+ *
285
+ * given the following Automation configuration:
286
+ *
287
+ * (Trigger A)
288
+ * |
289
+ * (Action B) // namespace = "action_b_1"
290
+ * |
291
+ * (Action B) // namespace = "action_b_2"
292
+ * |
293
+ * (Action C)
294
+ *
295
+ *
296
+ * the available fields that Action C will be able to use to map to it's input fields will be:
297
+ * {
298
+ * "someField": "50",
299
+ * "someBoolean": true,
300
+ * "action_b_1": {
301
+ * "message": "hello"
302
+ * },
303
+ * "action_b_2": {
304
+ * "message": "hello"
305
+ * }
306
+ * }
307
+ * so the user can select which specific action output to use (action_b_1.message or action_b_2.message, in the case above)
308
+ */
309
+ namespace?: string | null;
310
+ }
311
+ /** @oneof */
312
+ interface AutomationConfigurationActionInfoOneOf {
313
+ /** App defined Action (via RPC, HTTP or Velo) */
314
+ appDefinedInfo?: AppDefinedAction;
315
+ /** Condition action */
316
+ conditionInfo?: ConditionAction;
317
+ /** Delay action */
318
+ delayInfo?: DelayAction;
319
+ /** Rate limiting action */
320
+ rateLimitInfo?: RateLimitAction;
321
+ }
322
+ declare enum Origin {
323
+ /** default value. this is unused */
324
+ UNKNOWN_ORIGIN = "UNKNOWN_ORIGIN",
325
+ /** user created automation */
326
+ USER = "USER",
327
+ /** automation created by application (site specific) */
328
+ APPLICATION = "APPLICATION",
329
+ /** preinstalled application automation */
330
+ PREINSTALLED = "PREINSTALLED"
331
+ }
332
+ interface ApplicationOrigin {
333
+ /** identifier for the application */
334
+ appId?: string;
335
+ }
336
+ interface PreinstalledOrigin {
337
+ /** identifier for the application */
338
+ appId?: string;
339
+ /** application component ID */
340
+ componentId?: string;
341
+ /** application component Version */
342
+ componentVersion?: number;
343
+ /**
344
+ * is this a user modified preinstalled automation (on a specific site) or the original one
345
+ * @readonly
346
+ */
347
+ override?: boolean | null;
348
+ }
349
+ interface AutomationSettings {
350
+ /** sets if the automation is hidden from users */
351
+ hidden?: boolean;
352
+ /** sets if the automation is readonly */
353
+ readonly?: boolean;
354
+ /** sets if deleting the automation is disabled */
355
+ disableDelete?: boolean;
356
+ /** sets if changing the automation status is disabled (from active to inactive and vice versa) */
357
+ disableStatusChange?: boolean;
358
+ /** Automation's action settings */
359
+ actionSettings?: ActionSettings;
360
+ }
361
+ interface ActivationStatusChanged extends ActivationStatusChangedStatusInfoOneOf {
362
+ /** Initiated status information */
363
+ initiatedInfo?: InitiatedStatusInfo;
364
+ /** Scheduled status information */
365
+ scheduledInfo?: ScheduledStatusInfo;
366
+ /** Cancelled status information */
367
+ cancelledInfo?: CancelledStatusInfo;
368
+ /** Failed status information */
369
+ failedInfo?: ActivationStatusChangedFailedStatusInfo;
370
+ /** Activation */
371
+ activation?: Activation;
372
+ /** Activation status */
373
+ status?: ActivationStatusChangedStatus;
374
+ /** Change event created date */
375
+ statusChangedDate?: Date;
376
+ }
377
+ /** @oneof */
378
+ interface ActivationStatusChangedStatusInfoOneOf {
379
+ /** Initiated status information */
380
+ initiatedInfo?: InitiatedStatusInfo;
381
+ /** Scheduled status information */
382
+ scheduledInfo?: ScheduledStatusInfo;
383
+ /** Cancelled status information */
384
+ cancelledInfo?: CancelledStatusInfo;
385
+ /** Failed status information */
386
+ failedInfo?: ActivationStatusChangedFailedStatusInfo;
387
+ }
388
+ declare enum Target {
389
+ UNKNOWN_TARGET = "UNKNOWN_TARGET",
390
+ SCHEDULE = "SCHEDULE",
391
+ IMMEDIATE = "IMMEDIATE"
392
+ }
393
+ declare enum CancellationReason {
394
+ UNKNOWN_CANCELLATION_REASON = "UNKNOWN_CANCELLATION_REASON",
395
+ /** Indicating that the activation was cancelled directly */
396
+ EVENT_CANCELLED = "EVENT_CANCELLED",
397
+ /** Indicating that the activation is cancelled because the automation was deactivated */
398
+ AUTOMATION_DEACTIVATED = "AUTOMATION_DEACTIVATED",
399
+ /** Indicating that the activation is cancelled because the automation was deleted */
400
+ AUTOMATION_DELETED = "AUTOMATION_DELETED"
401
+ }
402
+ interface Identity {
403
+ /** User ID */
404
+ userId?: string | null;
405
+ /** App ID */
406
+ appId?: string | null;
407
+ }
408
+ declare enum ActivationStatusChangedStatus {
409
+ UNKNOWN_STATUS = "UNKNOWN_STATUS",
410
+ /** This indicates activation is not started yet (no action has run yet) */
411
+ INITIATED = "INITIATED",
412
+ /** The activation is in scheduled status when the automation has future date or debounce defined and we're in the waiting stage (no action has run yet) */
413
+ SCHEDULED = "SCHEDULED",
414
+ /** This indicates the automation activation has started and currently in progress */
415
+ STARTED = "STARTED",
416
+ /** This indicates all the automation actions were handled either by invoking them, skipping them etc. */
417
+ ENDED = "ENDED",
418
+ /** This indicates the activation was cancelled */
419
+ CANCELLED = "CANCELLED",
420
+ /**
421
+ * This indicates the activation failed to start
422
+ * Note that failure in the activation of a single action will not result a failure in activation of the entire automation
423
+ */
424
+ FAILED = "FAILED"
425
+ }
426
+ interface InitiatedStatusInfo {
427
+ /** Activation target */
428
+ target?: Target;
429
+ /** Event payload */
430
+ payload?: Record<string, any> | null;
431
+ /** External entity ID */
432
+ externalEntityId?: string | null;
433
+ /** Unique identifier for the request that initiated the automation */
434
+ requestId?: string;
435
+ }
436
+ interface ScheduledStatusInfo {
437
+ /** Schedule identifier */
438
+ scheduleId?: string;
439
+ /** Indicating when the activation should start */
440
+ date?: Date;
441
+ }
442
+ interface CancelledStatusInfo {
443
+ /** Cancellation reason */
444
+ reason?: CancellationReason;
445
+ /** The identity (such as user, app etc.) that caused the cancellation */
446
+ initiator?: Identity;
447
+ }
448
+ interface ActivationStatusChangedFailedStatusInfo {
449
+ /**
450
+ * Error description
451
+ * @readonly
452
+ */
453
+ errorDescription?: string;
454
+ /**
455
+ * Error code
456
+ * @readonly
457
+ */
458
+ errorCode?: string | null;
459
+ }
460
+ interface IdentificationData extends IdentificationDataIdOneOf {
461
+ /** ID of a site visitor that has not logged in to the site. */
462
+ anonymousVisitorId?: string;
463
+ /** ID of a site visitor that has logged in to the site. */
464
+ memberId?: string;
465
+ /** ID of a Wix user (site owner, contributor, etc.). */
466
+ wixUserId?: string;
467
+ /** ID of an app. */
468
+ appId?: string;
469
+ /** @readonly */
470
+ identityType?: WebhookIdentityType;
471
+ }
472
+ /** @oneof */
473
+ interface IdentificationDataIdOneOf {
474
+ /** ID of a site visitor that has not logged in to the site. */
475
+ anonymousVisitorId?: string;
476
+ /** ID of a site visitor that has logged in to the site. */
477
+ memberId?: string;
478
+ /** ID of a Wix user (site owner, contributor, etc.). */
479
+ wixUserId?: string;
480
+ /** ID of an app. */
481
+ appId?: string;
482
+ }
483
+ declare enum WebhookIdentityType {
484
+ UNKNOWN = "UNKNOWN",
485
+ ANONYMOUS_VISITOR = "ANONYMOUS_VISITOR",
486
+ MEMBER = "MEMBER",
487
+ WIX_USER = "WIX_USER",
488
+ APP = "APP"
489
+ }
490
+ interface Idempotency {
491
+ /**
492
+ * A unique identifier for the event.
493
+ * If you send the same idempotency key in multiple report event requests, for the same trigger key and app id,
494
+ * consecutive requests will be ignored after the first one. Note that the idempotency key is kept for a week before it expires.
495
+ */
496
+ key?: string;
497
+ /** Optional. The time to live (TTL) in milliseconds before the key will expire. Default is a week. */
498
+ ttlInMilliseconds?: string | null;
499
+ }
500
+ interface ReportEventResponse {
501
+ /** The activation IDs of triggered ReportEvents. */
502
+ activationIds?: string[];
503
+ }
504
+ interface EventInfo {
505
+ /**
506
+ * Event payload, formatted as key:value pairs.
507
+ * Must comply with the payload schema
508
+ * if you provided one when configuring your trigger.
509
+ */
510
+ payload?: Record<string, any> | null;
511
+ /** ID of the related resource in GUID format. */
512
+ externalEntityId?: string | null;
513
+ /** Idempotency information for the event */
514
+ idempotency?: Idempotency;
515
+ }
516
+ interface BulkReportEventResponse {
517
+ /** Trigger key associated with the event */
518
+ triggerKey?: string;
519
+ /** List of results for each item in the bulk report event request */
520
+ results?: BulkReportEventResult[];
521
+ /** Metadata for the overall bulk action, including success and failure counts */
522
+ bulkActionMetadata?: BulkActionMetadata;
523
+ }
524
+ interface BulkReportEventResult {
525
+ /** Metadata for the individual item in the request */
526
+ itemMetadata?: ItemMetadata;
527
+ /** Event details for the item in the request */
528
+ eventInfo?: EventInfo;
529
+ /** The activation IDs of triggered ReportEvents. */
530
+ activationIds?: string[];
531
+ }
532
+ interface ItemMetadata {
533
+ /** Item ID. Should always be available, unless it's impossible (for example, when failing to create an item). */
534
+ _id?: string | null;
535
+ /** Index of the item within the request array. Allows for correlation between request and response items. */
536
+ originalIndex?: number;
537
+ /** Whether the requested action was successful for this item. When `false`, the `error` field is populated. */
538
+ success?: boolean;
539
+ /** Details about the error in case of failure. */
540
+ error?: ApplicationError;
541
+ }
542
+ interface ApplicationError {
543
+ /** Error code. */
544
+ code?: string;
545
+ /** Description of the error. */
546
+ description?: string;
547
+ /** Data related to the error. */
548
+ data?: Record<string, any> | null;
549
+ }
550
+ interface BulkActionMetadata {
551
+ /** Number of items that were successfully processed. */
552
+ totalSuccesses?: number;
553
+ /** Number of items that couldn't be processed. */
554
+ totalFailures?: number;
555
+ /** Number of failures without details because detailed failure threshold was exceeded. */
556
+ undetailedFailures?: number;
557
+ }
558
+ interface BulkCancelEventResponse {
559
+ /** Trigger key related to the cancelled event */
560
+ triggerKey?: string;
561
+ /** List of results for each item in the bulk cancel event request */
562
+ results?: BulkCancelEventResult[];
563
+ /** Metadata for the overall bulk action, including success and failure counts */
564
+ bulkActionMetadata?: BulkActionMetadata;
565
+ }
566
+ interface BulkCancelEventResult {
567
+ /** Metadata of the item, including its ID and success or failure status */
568
+ itemMetadata?: ItemMetadata;
569
+ /** ID of the related resource in GUID format */
570
+ externalEntityId?: string;
571
+ }
572
+ interface ReportEventResponseNonNullableFields {
573
+ activationIds: string[];
574
+ }
575
+ interface BulkReportEventResponseNonNullableFields {
576
+ triggerKey: string;
577
+ results: {
578
+ itemMetadata?: {
579
+ originalIndex: number;
580
+ success: boolean;
581
+ error?: {
582
+ code: string;
583
+ description: string;
584
+ };
585
+ };
586
+ eventInfo?: {
587
+ idempotency?: {
588
+ key: string;
589
+ };
590
+ };
591
+ activationIds: string[];
592
+ }[];
593
+ bulkActionMetadata?: {
594
+ totalSuccesses: number;
595
+ totalFailures: number;
596
+ undetailedFailures: number;
597
+ };
598
+ }
599
+ interface BulkCancelEventResponseNonNullableFields {
600
+ triggerKey: string;
601
+ results: {
602
+ itemMetadata?: {
603
+ originalIndex: number;
604
+ success: boolean;
605
+ error?: {
606
+ code: string;
607
+ description: string;
608
+ };
609
+ };
610
+ externalEntityId: string;
611
+ }[];
612
+ bulkActionMetadata?: {
613
+ totalSuccesses: number;
614
+ totalFailures: number;
615
+ undetailedFailures: number;
616
+ };
617
+ }
618
+ interface BaseEventMetadata {
619
+ /** App instance ID. */
620
+ instanceId?: string | null;
621
+ /** Event type. */
622
+ eventType?: string;
623
+ /** The identification type and identity data. */
624
+ identity?: IdentificationData;
625
+ }
626
+ interface EventMetadata extends BaseEventMetadata {
627
+ /**
628
+ * Unique event ID.
629
+ * Allows clients to ignore duplicate webhooks.
630
+ */
631
+ _id?: string;
632
+ /**
633
+ * Assumes actions are also always typed to an entity_type
634
+ * Example: wix.stores.catalog.product, wix.bookings.session, wix.payments.transaction
635
+ */
636
+ entityFqdn?: string;
637
+ /**
638
+ * This is top level to ease client code dispatching of messages (switch on entity_fqdn+slug)
639
+ * This is although the created/updated/deleted notion is duplication of the oneof types
640
+ * Example: created/updated/deleted/started/completed/email_opened
641
+ */
642
+ slug?: string;
643
+ /** ID of the entity associated with the event. */
644
+ entityId?: string;
645
+ /** Event timestamp. */
646
+ eventTime?: Date;
647
+ /**
648
+ * Whether the event was triggered as a result of a privacy regulation application
649
+ * (for example, GDPR).
650
+ */
651
+ triggeredByAnonymizeRequest?: boolean | null;
652
+ /** If present, indicates the action that triggered the event. */
653
+ originatedFrom?: string | null;
654
+ /**
655
+ * A sequence number defining the order of updates to the underlying entity.
656
+ * For example, given that some entity was updated at 16:00 and than again at 16:01,
657
+ * it is guaranteed that the sequence number of the second update is strictly higher than the first.
658
+ * As the consumer, you can use this value to ensure that you handle messages in the correct order.
659
+ * To do so, you will need to persist this number on your end, and compare the sequence number from the
660
+ * message against the one you have stored. Given that the stored number is higher, you should ignore the message.
661
+ */
662
+ entityEventSequence?: string | null;
663
+ }
664
+ interface ActivationStatusChangedEnvelope {
665
+ data: ActivationStatusChanged;
666
+ metadata: EventMetadata;
667
+ }
668
+ interface ReportEventOptions {
669
+ /**
670
+ * Event payload, formatted as key:value pairs.
671
+ * Must comply with the payload schema
672
+ * if you provided one when configuring your trigger.
673
+ *
674
+ * Key names can include only alphanumeric characters or underscores
675
+ * (`A-Z`, `a-z`, `0-9`, `_`).
676
+ * They cannot start with an underscore.
677
+ *
678
+ * Values can be strings, numbers, integers, booleans, or arrays.
679
+ * If a value is an array, the array items must be objects,
680
+ * and nested object properties must be
681
+ * strings, numbers, integers, or booleans only.
682
+ */
683
+ payload?: Record<string, any> | null;
684
+ /**
685
+ * ID of the related resource in GUID format.
686
+ * For example, `fc81a355-3429-50fc-a4c7-def486e828f3`.
687
+ *
688
+ * Required if your app needs to
689
+ * [cancel the event](https://dev.wix.com/docs/rest/business-management/automations/triggered-events/cancel-event)
690
+ * if the automation becomes no longer relevant.
691
+ *
692
+ * Typically, this ID is defined in your system,
693
+ * but you can also use any Wix resource GUID,
694
+ * such as contact ID, member ID, or invoice ID.
695
+ * See
696
+ * [Choose the right `externalEntityId`](https://dev.wix.com/docs/rest/business-management/automations/triggered-events/reporting-and-canceling-events#about-canceling-events)
697
+ * for more information.
698
+ */
699
+ externalEntityId?: string | null;
700
+ /** Idempotency information for the event */
701
+ idempotency?: Idempotency;
702
+ }
703
+ interface BulkReportEventOptions {
704
+ /** Repeated list of event details for bulk reporting */
705
+ eventsInfo: EventInfo[];
706
+ }
707
+ interface BulkCancelEventOptions {
708
+ /** Repeated list of external_entity_id, representing the related resources' IDs */
709
+ externalEntityIds: string[];
710
+ }
711
+ interface CancelEventOptions {
712
+ /**
713
+ * Trigger key whose event you want to cancel.
714
+ * For example, `form_submitted` or `invoice_due`.
715
+ */
716
+ triggerKey: string;
717
+ }
718
+
719
+ type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
720
+ interface HttpClient {
721
+ request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
722
+ }
723
+ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
724
+ type HttpResponse<T = any> = {
725
+ data: T;
726
+ status: number;
727
+ statusText: string;
728
+ headers: any;
729
+ request?: any;
730
+ };
731
+ type RequestOptions<_TResponse = any, Data = any> = {
732
+ method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
733
+ url: string;
734
+ data?: Data;
735
+ params?: URLSearchParams;
736
+ } & APIMetadata;
737
+ type APIMetadata = {
738
+ methodFqn?: string;
739
+ entityFqdn?: string;
740
+ packageName?: string;
741
+ };
742
+ type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
743
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
744
+ __type: 'event-definition';
745
+ type: Type;
746
+ isDomainEvent?: boolean;
747
+ transformations?: unknown;
748
+ __payload: Payload;
749
+ };
750
+ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, _transformations?: unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
751
+ type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
752
+ type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
753
+
754
+ declare function reportEvent$1(httpClient: HttpClient): (triggerKey: string, options?: ReportEventOptions) => Promise<ReportEventResponse & ReportEventResponseNonNullableFields>;
755
+ declare function bulkReportEvent$1(httpClient: HttpClient): (triggerKey: string, options: BulkReportEventOptions) => Promise<BulkReportEventResponse & BulkReportEventResponseNonNullableFields>;
756
+ declare function bulkCancelEvent$1(httpClient: HttpClient): (triggerKey: string, options: BulkCancelEventOptions) => Promise<BulkCancelEventResponse & BulkCancelEventResponseNonNullableFields>;
757
+ declare function cancelEvent$1(httpClient: HttpClient): (externalEntityId: string, options: CancelEventOptions) => Promise<void>;
758
+ declare const onActivationStatusChanged$1: EventDefinition<ActivationStatusChangedEnvelope, "wix.automations.v2.activation_activation_status_changed">;
759
+
760
+ declare const reportEvent: BuildRESTFunction<typeof reportEvent$1>;
761
+ declare const bulkReportEvent: BuildRESTFunction<typeof bulkReportEvent$1>;
762
+ declare const bulkCancelEvent: BuildRESTFunction<typeof bulkCancelEvent$1>;
763
+ declare const cancelEvent: BuildRESTFunction<typeof cancelEvent$1>;
764
+ declare const onActivationStatusChanged: BuildEventDefinition<typeof onActivationStatusChanged$1>;
765
+
766
+ declare const context_bulkCancelEvent: typeof bulkCancelEvent;
767
+ declare const context_bulkReportEvent: typeof bulkReportEvent;
768
+ declare const context_cancelEvent: typeof cancelEvent;
769
+ declare const context_onActivationStatusChanged: typeof onActivationStatusChanged;
770
+ declare const context_reportEvent: typeof reportEvent;
771
+ declare namespace context {
772
+ export { context_bulkCancelEvent as bulkCancelEvent, context_bulkReportEvent as bulkReportEvent, context_cancelEvent as cancelEvent, context_onActivationStatusChanged as onActivationStatusChanged, context_reportEvent as reportEvent };
773
+ }
774
+
775
+ export { context as activations };