@automate.ax/integration-contracts 0.139.2 → 0.142.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/clickup/api.d.ts +76 -0
- package/dist/clickup/api.js +195 -0
- package/dist/clickup/index.d.ts +1921 -0
- package/dist/clickup/index.js +91 -0
- package/dist/clickup/schemas.d.ts +477 -0
- package/dist/clickup/schemas.js +286 -0
- package/dist/closebot/api.d.ts +39 -0
- package/dist/closebot/api.js +117 -0
- package/dist/closebot/index.d.ts +2 -0
- package/dist/closebot/index.js +2 -0
- package/dist/closebot/schemas.d.ts +775 -0
- package/dist/closebot/schemas.js +469 -0
- package/dist/google-ads/api.d.ts +40 -0
- package/dist/google-ads/api.js +109 -0
- package/dist/google-ads/events.d.ts +1155 -0
- package/dist/google-ads/events.js +96 -0
- package/dist/google-ads/index.d.ts +3 -0
- package/dist/google-ads/index.js +3 -0
- package/dist/google-ads/schemas.d.ts +756 -0
- package/dist/google-ads/schemas.js +249 -0
- package/dist/google-drive/index.d.ts +6 -6
- package/dist/linear/schemas.d.ts +3 -3
- package/dist/meta-ads/api.d.ts +90 -0
- package/dist/meta-ads/api.js +260 -0
- package/dist/meta-ads/events.d.ts +391 -0
- package/dist/meta-ads/events.js +193 -0
- package/dist/meta-ads/index.d.ts +3 -0
- package/dist/meta-ads/index.js +3 -0
- package/dist/meta-ads/schemas.d.ts +184 -0
- package/dist/meta-ads/schemas.js +181 -0
- package/dist/notion/schemas.d.ts +84 -84
- package/dist/teams/index.d.ts +20 -20
- package/dist/teams/schemas.d.ts +5 -5
- package/dist/triggers.d.ts +4 -1
- package/package.json +27 -3
- package/src/clickup/api.ts +270 -0
- package/src/clickup/index.ts +108 -0
- package/src/clickup/schemas.ts +324 -0
- package/src/closebot/api.ts +157 -0
- package/src/closebot/index.ts +2 -0
- package/src/closebot/schemas.ts +521 -0
- package/src/google-ads/api.ts +151 -0
- package/src/google-ads/events.ts +131 -0
- package/src/google-ads/index.ts +3 -0
- package/src/google-ads/schemas.ts +270 -0
- package/src/meta-ads/api.ts +327 -0
- package/src/meta-ads/events.ts +218 -0
- package/src/meta-ads/index.ts +3 -0
- package/src/meta-ads/schemas.ts +206 -0
- package/src/triggers.ts +6 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export declare const META_ADS_AD_ACCOUNT_FIELDS: readonly ["ad_recommendations", "creative_fatigue", "effective_status", "in_process_ad_objects", "subscriptions", "with_issues_ad_objects"];
|
|
3
|
+
export declare const META_ADS_EVENT_SCHEMA: z.ZodObject<{
|
|
4
|
+
accountId: z.ZodString;
|
|
5
|
+
field: z.ZodString;
|
|
6
|
+
occurredAt: z.ZodNumber;
|
|
7
|
+
value: z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare const META_ADS_EFFECTIVE_STATUS_EVENT_SCHEMA: z.ZodObject<{
|
|
10
|
+
accountId: z.ZodString;
|
|
11
|
+
occurredAt: z.ZodNumber;
|
|
12
|
+
field: z.ZodLiteral<"field_changed">;
|
|
13
|
+
value: z.ZodObject<{
|
|
14
|
+
changedFields: z.ZodArray<z.ZodLiteral<"effective_status">>;
|
|
15
|
+
objectId: z.ZodString;
|
|
16
|
+
objectType: z.ZodEnum<{
|
|
17
|
+
ad: "ad";
|
|
18
|
+
adset: "adset";
|
|
19
|
+
campaign: "campaign";
|
|
20
|
+
}>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export declare const META_ADS_SUBSCRIPTION_EVENT_SCHEMA: z.ZodObject<{
|
|
24
|
+
accountId: z.ZodString;
|
|
25
|
+
occurredAt: z.ZodNumber;
|
|
26
|
+
field: z.ZodLiteral<"subscriptions">;
|
|
27
|
+
value: z.ZodObject<{
|
|
28
|
+
accountId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
29
|
+
currentValue: z.ZodOptional<z.ZodString>;
|
|
30
|
+
field: z.ZodOptional<z.ZodString>;
|
|
31
|
+
objectId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
32
|
+
objectType: z.ZodEnum<{
|
|
33
|
+
ad: "ad";
|
|
34
|
+
adset: "adset";
|
|
35
|
+
campaign: "campaign";
|
|
36
|
+
}>;
|
|
37
|
+
subscriptionId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export declare const META_ADS_CREATIVE_FATIGUE_EVENT_SCHEMA: z.ZodObject<{
|
|
41
|
+
accountId: z.ZodString;
|
|
42
|
+
occurredAt: z.ZodNumber;
|
|
43
|
+
field: z.ZodLiteral<"creative_fatigue">;
|
|
44
|
+
value: z.ZodObject<{
|
|
45
|
+
adAccountId: z.ZodString;
|
|
46
|
+
adgroupId: z.ZodString;
|
|
47
|
+
creativeFatigueLevel: z.ZodEnum<{
|
|
48
|
+
HIGH: "HIGH";
|
|
49
|
+
LOW: "LOW";
|
|
50
|
+
MEDIUM: "MEDIUM";
|
|
51
|
+
}>;
|
|
52
|
+
creativeFatigueMessage: z.ZodString;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
export declare const META_ADS_RECOMMENDATION_EVENT_SCHEMA: z.ZodObject<{
|
|
56
|
+
accountId: z.ZodString;
|
|
57
|
+
occurredAt: z.ZodNumber;
|
|
58
|
+
field: z.ZodLiteral<"ad_recommendations">;
|
|
59
|
+
value: z.ZodObject<{
|
|
60
|
+
adAccountId: z.ZodString;
|
|
61
|
+
adObjectIds: z.ZodArray<z.ZodString>;
|
|
62
|
+
recommendationHash: z.ZodString;
|
|
63
|
+
recommendationMessage: z.ZodString;
|
|
64
|
+
recommendationSignature: z.ZodString;
|
|
65
|
+
recommendationStage: z.ZodString;
|
|
66
|
+
recommendationType: z.ZodString;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
export declare const META_ADS_PROCESSING_EVENT_SCHEMA: z.ZodObject<{
|
|
70
|
+
accountId: z.ZodString;
|
|
71
|
+
occurredAt: z.ZodNumber;
|
|
72
|
+
field: z.ZodLiteral<"in_process_ad_objects">;
|
|
73
|
+
value: z.ZodObject<{
|
|
74
|
+
id: z.ZodString;
|
|
75
|
+
level: z.ZodEnum<{
|
|
76
|
+
AD: "AD";
|
|
77
|
+
AD_SET: "AD_SET";
|
|
78
|
+
CAMPAIGN: "CAMPAIGN";
|
|
79
|
+
CREATIVE: "CREATIVE";
|
|
80
|
+
}>;
|
|
81
|
+
statusName: z.ZodString;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
export declare const META_ADS_ISSUES_EVENT_SCHEMA: z.ZodObject<{
|
|
85
|
+
accountId: z.ZodString;
|
|
86
|
+
occurredAt: z.ZodNumber;
|
|
87
|
+
field: z.ZodLiteral<"with_issues_ad_objects">;
|
|
88
|
+
value: z.ZodObject<{
|
|
89
|
+
errorCode: z.ZodString;
|
|
90
|
+
errorMessage: z.ZodString;
|
|
91
|
+
errorSummary: z.ZodString;
|
|
92
|
+
id: z.ZodString;
|
|
93
|
+
level: z.ZodEnum<{
|
|
94
|
+
AD: "AD";
|
|
95
|
+
AD_SET: "AD_SET";
|
|
96
|
+
CAMPAIGN: "CAMPAIGN";
|
|
97
|
+
CREATIVE: "CREATIVE";
|
|
98
|
+
}>;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
}, z.core.$strip>;
|
|
101
|
+
export declare const META_ADS_LEAD_CREATED_EVENT_SCHEMA: z.ZodObject<{
|
|
102
|
+
adId: z.ZodOptional<z.ZodString>;
|
|
103
|
+
adgroupId: z.ZodOptional<z.ZodString>;
|
|
104
|
+
createdTime: z.ZodNumber;
|
|
105
|
+
formId: z.ZodString;
|
|
106
|
+
leadgenId: z.ZodString;
|
|
107
|
+
pageId: z.ZodString;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
export declare const META_ADS_TRIGGER_CONFIG_SCHEMA: z.ZodObject<{
|
|
110
|
+
account: z.ZodOptional<z.ZodString>;
|
|
111
|
+
adAccountId: z.ZodString;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
export declare const META_ADS_LEAD_TRIGGER_CONFIG_SCHEMA: z.ZodObject<{
|
|
114
|
+
account: z.ZodOptional<z.ZodString>;
|
|
115
|
+
pageId: z.ZodString;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
export interface NormalizedMetaAdsWebhook {
|
|
118
|
+
adAccountEvents: z.output<typeof META_ADS_EVENT_SCHEMA>[];
|
|
119
|
+
leadEvents: z.output<typeof META_ADS_LEAD_CREATED_EVENT_SCHEMA>[];
|
|
120
|
+
}
|
|
121
|
+
export declare const metaAdsTriggerContracts: {
|
|
122
|
+
readonly "meta-ads.ad.effectiveStatusChanged": {
|
|
123
|
+
readonly configSchema: z.ZodObject<{
|
|
124
|
+
account: z.ZodOptional<z.ZodString>;
|
|
125
|
+
adAccountId: z.ZodString;
|
|
126
|
+
}, z.core.$strip>;
|
|
127
|
+
readonly eventSchema: z.ZodObject<{
|
|
128
|
+
accountId: z.ZodString;
|
|
129
|
+
occurredAt: z.ZodNumber;
|
|
130
|
+
field: z.ZodLiteral<"field_changed">;
|
|
131
|
+
value: z.ZodObject<{
|
|
132
|
+
changedFields: z.ZodArray<z.ZodLiteral<"effective_status">>;
|
|
133
|
+
objectId: z.ZodString;
|
|
134
|
+
objectType: z.ZodEnum<{
|
|
135
|
+
ad: "ad";
|
|
136
|
+
adset: "adset";
|
|
137
|
+
campaign: "campaign";
|
|
138
|
+
}>;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
};
|
|
142
|
+
readonly "meta-ads.ad.recommendation": {
|
|
143
|
+
readonly configSchema: z.ZodObject<{
|
|
144
|
+
account: z.ZodOptional<z.ZodString>;
|
|
145
|
+
adAccountId: z.ZodString;
|
|
146
|
+
}, z.core.$strip>;
|
|
147
|
+
readonly eventSchema: z.ZodObject<{
|
|
148
|
+
accountId: z.ZodString;
|
|
149
|
+
occurredAt: z.ZodNumber;
|
|
150
|
+
field: z.ZodLiteral<"ad_recommendations">;
|
|
151
|
+
value: z.ZodObject<{
|
|
152
|
+
adAccountId: z.ZodString;
|
|
153
|
+
adObjectIds: z.ZodArray<z.ZodString>;
|
|
154
|
+
recommendationHash: z.ZodString;
|
|
155
|
+
recommendationMessage: z.ZodString;
|
|
156
|
+
recommendationSignature: z.ZodString;
|
|
157
|
+
recommendationStage: z.ZodString;
|
|
158
|
+
recommendationType: z.ZodString;
|
|
159
|
+
}, z.core.$strip>;
|
|
160
|
+
}, z.core.$strip>;
|
|
161
|
+
};
|
|
162
|
+
readonly "meta-ads.adObject.issuesChanged": {
|
|
163
|
+
readonly configSchema: z.ZodObject<{
|
|
164
|
+
account: z.ZodOptional<z.ZodString>;
|
|
165
|
+
adAccountId: z.ZodString;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
readonly eventSchema: z.ZodObject<{
|
|
168
|
+
accountId: z.ZodString;
|
|
169
|
+
occurredAt: z.ZodNumber;
|
|
170
|
+
field: z.ZodLiteral<"with_issues_ad_objects">;
|
|
171
|
+
value: z.ZodObject<{
|
|
172
|
+
errorCode: z.ZodString;
|
|
173
|
+
errorMessage: z.ZodString;
|
|
174
|
+
errorSummary: z.ZodString;
|
|
175
|
+
id: z.ZodString;
|
|
176
|
+
level: z.ZodEnum<{
|
|
177
|
+
AD: "AD";
|
|
178
|
+
AD_SET: "AD_SET";
|
|
179
|
+
CAMPAIGN: "CAMPAIGN";
|
|
180
|
+
CREATIVE: "CREATIVE";
|
|
181
|
+
}>;
|
|
182
|
+
}, z.core.$strip>;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
};
|
|
185
|
+
readonly "meta-ads.adObject.processingCompleted": {
|
|
186
|
+
readonly configSchema: z.ZodObject<{
|
|
187
|
+
account: z.ZodOptional<z.ZodString>;
|
|
188
|
+
adAccountId: z.ZodString;
|
|
189
|
+
}, z.core.$strip>;
|
|
190
|
+
readonly eventSchema: z.ZodObject<{
|
|
191
|
+
accountId: z.ZodString;
|
|
192
|
+
occurredAt: z.ZodNumber;
|
|
193
|
+
field: z.ZodLiteral<"in_process_ad_objects">;
|
|
194
|
+
value: z.ZodObject<{
|
|
195
|
+
id: z.ZodString;
|
|
196
|
+
level: z.ZodEnum<{
|
|
197
|
+
AD: "AD";
|
|
198
|
+
AD_SET: "AD_SET";
|
|
199
|
+
CAMPAIGN: "CAMPAIGN";
|
|
200
|
+
CREATIVE: "CREATIVE";
|
|
201
|
+
}>;
|
|
202
|
+
statusName: z.ZodString;
|
|
203
|
+
}, z.core.$strip>;
|
|
204
|
+
}, z.core.$strip>;
|
|
205
|
+
};
|
|
206
|
+
readonly "meta-ads.adSet.effectiveStatusChanged": {
|
|
207
|
+
readonly configSchema: z.ZodObject<{
|
|
208
|
+
account: z.ZodOptional<z.ZodString>;
|
|
209
|
+
adAccountId: z.ZodString;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
readonly eventSchema: z.ZodObject<{
|
|
212
|
+
accountId: z.ZodString;
|
|
213
|
+
occurredAt: z.ZodNumber;
|
|
214
|
+
field: z.ZodLiteral<"field_changed">;
|
|
215
|
+
value: z.ZodObject<{
|
|
216
|
+
changedFields: z.ZodArray<z.ZodLiteral<"effective_status">>;
|
|
217
|
+
objectId: z.ZodString;
|
|
218
|
+
objectType: z.ZodEnum<{
|
|
219
|
+
ad: "ad";
|
|
220
|
+
adset: "adset";
|
|
221
|
+
campaign: "campaign";
|
|
222
|
+
}>;
|
|
223
|
+
}, z.core.$strip>;
|
|
224
|
+
}, z.core.$strip>;
|
|
225
|
+
};
|
|
226
|
+
readonly "meta-ads.campaign.effectiveStatusChanged": {
|
|
227
|
+
readonly configSchema: z.ZodObject<{
|
|
228
|
+
account: z.ZodOptional<z.ZodString>;
|
|
229
|
+
adAccountId: z.ZodString;
|
|
230
|
+
}, z.core.$strip>;
|
|
231
|
+
readonly eventSchema: z.ZodObject<{
|
|
232
|
+
accountId: z.ZodString;
|
|
233
|
+
occurredAt: z.ZodNumber;
|
|
234
|
+
field: z.ZodLiteral<"field_changed">;
|
|
235
|
+
value: z.ZodObject<{
|
|
236
|
+
changedFields: z.ZodArray<z.ZodLiteral<"effective_status">>;
|
|
237
|
+
objectId: z.ZodString;
|
|
238
|
+
objectType: z.ZodEnum<{
|
|
239
|
+
ad: "ad";
|
|
240
|
+
adset: "adset";
|
|
241
|
+
campaign: "campaign";
|
|
242
|
+
}>;
|
|
243
|
+
}, z.core.$strip>;
|
|
244
|
+
}, z.core.$strip>;
|
|
245
|
+
};
|
|
246
|
+
readonly "meta-ads.creativeFatigue.changed": {
|
|
247
|
+
readonly configSchema: z.ZodObject<{
|
|
248
|
+
account: z.ZodOptional<z.ZodString>;
|
|
249
|
+
adAccountId: z.ZodString;
|
|
250
|
+
}, z.core.$strip>;
|
|
251
|
+
readonly eventSchema: z.ZodObject<{
|
|
252
|
+
accountId: z.ZodString;
|
|
253
|
+
occurredAt: z.ZodNumber;
|
|
254
|
+
field: z.ZodLiteral<"creative_fatigue">;
|
|
255
|
+
value: z.ZodObject<{
|
|
256
|
+
adAccountId: z.ZodString;
|
|
257
|
+
adgroupId: z.ZodString;
|
|
258
|
+
creativeFatigueLevel: z.ZodEnum<{
|
|
259
|
+
HIGH: "HIGH";
|
|
260
|
+
LOW: "LOW";
|
|
261
|
+
MEDIUM: "MEDIUM";
|
|
262
|
+
}>;
|
|
263
|
+
creativeFatigueMessage: z.ZodString;
|
|
264
|
+
}, z.core.$strip>;
|
|
265
|
+
}, z.core.$strip>;
|
|
266
|
+
};
|
|
267
|
+
readonly "meta-ads.event": {
|
|
268
|
+
readonly configSchema: z.ZodObject<{
|
|
269
|
+
account: z.ZodOptional<z.ZodString>;
|
|
270
|
+
adAccountId: z.ZodString;
|
|
271
|
+
}, z.core.$strip>;
|
|
272
|
+
readonly eventSchema: z.ZodObject<{
|
|
273
|
+
accountId: z.ZodString;
|
|
274
|
+
field: z.ZodString;
|
|
275
|
+
occurredAt: z.ZodNumber;
|
|
276
|
+
value: z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
|
|
277
|
+
}, z.core.$strip>;
|
|
278
|
+
};
|
|
279
|
+
readonly "meta-ads.insights.milestoneReached": {
|
|
280
|
+
readonly configSchema: z.ZodObject<{
|
|
281
|
+
account: z.ZodOptional<z.ZodString>;
|
|
282
|
+
adAccountId: z.ZodString;
|
|
283
|
+
}, z.core.$strip>;
|
|
284
|
+
readonly eventSchema: z.ZodObject<{
|
|
285
|
+
accountId: z.ZodString;
|
|
286
|
+
occurredAt: z.ZodNumber;
|
|
287
|
+
field: z.ZodLiteral<"subscriptions">;
|
|
288
|
+
value: z.ZodObject<{
|
|
289
|
+
accountId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
290
|
+
currentValue: z.ZodOptional<z.ZodString>;
|
|
291
|
+
field: z.ZodOptional<z.ZodString>;
|
|
292
|
+
objectId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
293
|
+
objectType: z.ZodEnum<{
|
|
294
|
+
ad: "ad";
|
|
295
|
+
adset: "adset";
|
|
296
|
+
campaign: "campaign";
|
|
297
|
+
}>;
|
|
298
|
+
subscriptionId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
299
|
+
}, z.core.$strip>;
|
|
300
|
+
}, z.core.$strip>;
|
|
301
|
+
};
|
|
302
|
+
readonly "meta-ads.insights.updated": {
|
|
303
|
+
readonly configSchema: z.ZodObject<{
|
|
304
|
+
account: z.ZodOptional<z.ZodString>;
|
|
305
|
+
adAccountId: z.ZodString;
|
|
306
|
+
}, z.core.$strip>;
|
|
307
|
+
readonly eventSchema: z.ZodObject<{
|
|
308
|
+
accountId: z.ZodString;
|
|
309
|
+
occurredAt: z.ZodNumber;
|
|
310
|
+
field: z.ZodLiteral<"subscriptions">;
|
|
311
|
+
value: z.ZodObject<{
|
|
312
|
+
accountId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
313
|
+
currentValue: z.ZodOptional<z.ZodString>;
|
|
314
|
+
field: z.ZodOptional<z.ZodString>;
|
|
315
|
+
objectId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
316
|
+
objectType: z.ZodEnum<{
|
|
317
|
+
ad: "ad";
|
|
318
|
+
adset: "adset";
|
|
319
|
+
campaign: "campaign";
|
|
320
|
+
}>;
|
|
321
|
+
subscriptionId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
322
|
+
}, z.core.$strip>;
|
|
323
|
+
}, z.core.$strip>;
|
|
324
|
+
};
|
|
325
|
+
readonly "meta-ads.lead.created": {
|
|
326
|
+
readonly configSchema: z.ZodObject<{
|
|
327
|
+
account: z.ZodOptional<z.ZodString>;
|
|
328
|
+
pageId: z.ZodString;
|
|
329
|
+
}, z.core.$strip>;
|
|
330
|
+
readonly eventSchema: z.ZodObject<{
|
|
331
|
+
adId: z.ZodOptional<z.ZodString>;
|
|
332
|
+
adgroupId: z.ZodOptional<z.ZodString>;
|
|
333
|
+
createdTime: z.ZodNumber;
|
|
334
|
+
formId: z.ZodString;
|
|
335
|
+
leadgenId: z.ZodString;
|
|
336
|
+
pageId: z.ZodString;
|
|
337
|
+
}, z.core.$strip>;
|
|
338
|
+
};
|
|
339
|
+
readonly "meta-ads.object.created": {
|
|
340
|
+
readonly configSchema: z.ZodObject<{
|
|
341
|
+
account: z.ZodOptional<z.ZodString>;
|
|
342
|
+
adAccountId: z.ZodString;
|
|
343
|
+
}, z.core.$strip>;
|
|
344
|
+
readonly eventSchema: z.ZodObject<{
|
|
345
|
+
accountId: z.ZodString;
|
|
346
|
+
occurredAt: z.ZodNumber;
|
|
347
|
+
field: z.ZodLiteral<"subscriptions">;
|
|
348
|
+
value: z.ZodObject<{
|
|
349
|
+
accountId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
350
|
+
currentValue: z.ZodOptional<z.ZodString>;
|
|
351
|
+
field: z.ZodOptional<z.ZodString>;
|
|
352
|
+
objectId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
353
|
+
objectType: z.ZodEnum<{
|
|
354
|
+
ad: "ad";
|
|
355
|
+
adset: "adset";
|
|
356
|
+
campaign: "campaign";
|
|
357
|
+
}>;
|
|
358
|
+
subscriptionId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
359
|
+
}, z.core.$strip>;
|
|
360
|
+
}, z.core.$strip>;
|
|
361
|
+
};
|
|
362
|
+
readonly "meta-ads.object.updated": {
|
|
363
|
+
readonly configSchema: z.ZodObject<{
|
|
364
|
+
account: z.ZodOptional<z.ZodString>;
|
|
365
|
+
adAccountId: z.ZodString;
|
|
366
|
+
}, z.core.$strip>;
|
|
367
|
+
readonly eventSchema: z.ZodObject<{
|
|
368
|
+
accountId: z.ZodString;
|
|
369
|
+
occurredAt: z.ZodNumber;
|
|
370
|
+
field: z.ZodLiteral<"subscriptions">;
|
|
371
|
+
value: z.ZodObject<{
|
|
372
|
+
accountId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
373
|
+
currentValue: z.ZodOptional<z.ZodString>;
|
|
374
|
+
field: z.ZodOptional<z.ZodString>;
|
|
375
|
+
objectId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
376
|
+
objectType: z.ZodEnum<{
|
|
377
|
+
ad: "ad";
|
|
378
|
+
adset: "adset";
|
|
379
|
+
campaign: "campaign";
|
|
380
|
+
}>;
|
|
381
|
+
subscriptionId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
382
|
+
}, z.core.$strip>;
|
|
383
|
+
}, z.core.$strip>;
|
|
384
|
+
};
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* Normalizes Meta's Page and ad-account envelopes into stable public events.
|
|
388
|
+
*
|
|
389
|
+
* @param input - Untrusted provider webhook envelope.
|
|
390
|
+
*/
|
|
391
|
+
export declare function normalizeMetaAdsWebhook(input: unknown): NormalizedMetaAdsWebhook;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { encodableSchema } from "@automate.ax/codec";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import { fromMeta } from "./api.js";
|
|
4
|
+
import { META_ADS_ID_SCHEMA, META_ADS_WEBHOOK_ENVELOPE_SCHEMA } from "./schemas.js";
|
|
5
|
+
export const META_ADS_AD_ACCOUNT_FIELDS = [
|
|
6
|
+
"ad_recommendations",
|
|
7
|
+
"creative_fatigue",
|
|
8
|
+
"effective_status",
|
|
9
|
+
"in_process_ad_objects",
|
|
10
|
+
"subscriptions",
|
|
11
|
+
"with_issues_ad_objects",
|
|
12
|
+
];
|
|
13
|
+
const META_ADS_EVENT_BASE_SCHEMA = z.object({
|
|
14
|
+
accountId: META_ADS_ID_SCHEMA,
|
|
15
|
+
field: z.string(),
|
|
16
|
+
occurredAt: z.number().int().nonnegative(),
|
|
17
|
+
});
|
|
18
|
+
export const META_ADS_EVENT_SCHEMA = META_ADS_EVENT_BASE_SCHEMA.extend({
|
|
19
|
+
value: encodableSchema,
|
|
20
|
+
});
|
|
21
|
+
export const META_ADS_EFFECTIVE_STATUS_EVENT_SCHEMA = META_ADS_EVENT_BASE_SCHEMA.extend({
|
|
22
|
+
field: z.literal("field_changed"),
|
|
23
|
+
value: z.object({
|
|
24
|
+
changedFields: z.literal("effective_status").array(),
|
|
25
|
+
objectId: META_ADS_ID_SCHEMA,
|
|
26
|
+
objectType: z.enum(["ad", "adset", "campaign"]),
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
export const META_ADS_SUBSCRIPTION_EVENT_SCHEMA = META_ADS_EVENT_BASE_SCHEMA.extend({
|
|
30
|
+
field: z.literal("subscriptions"),
|
|
31
|
+
value: z.object({
|
|
32
|
+
accountId: z.union([META_ADS_ID_SCHEMA, z.number()]).transform(String),
|
|
33
|
+
currentValue: z.string().optional(),
|
|
34
|
+
field: z.string().optional(),
|
|
35
|
+
objectId: z.union([META_ADS_ID_SCHEMA, z.number()]).transform(String),
|
|
36
|
+
objectType: z.enum(["ad", "adset", "campaign"]),
|
|
37
|
+
subscriptionId: z
|
|
38
|
+
.union([META_ADS_ID_SCHEMA, z.number()])
|
|
39
|
+
.transform(String),
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
export const META_ADS_CREATIVE_FATIGUE_EVENT_SCHEMA = META_ADS_EVENT_BASE_SCHEMA.extend({
|
|
43
|
+
field: z.literal("creative_fatigue"),
|
|
44
|
+
value: z.object({
|
|
45
|
+
adAccountId: META_ADS_ID_SCHEMA,
|
|
46
|
+
adgroupId: META_ADS_ID_SCHEMA,
|
|
47
|
+
creativeFatigueLevel: z.enum(["HIGH", "LOW", "MEDIUM"]),
|
|
48
|
+
creativeFatigueMessage: z.string(),
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
export const META_ADS_RECOMMENDATION_EVENT_SCHEMA = META_ADS_EVENT_BASE_SCHEMA.extend({
|
|
52
|
+
field: z.literal("ad_recommendations"),
|
|
53
|
+
value: z.object({
|
|
54
|
+
adAccountId: META_ADS_ID_SCHEMA,
|
|
55
|
+
adObjectIds: META_ADS_ID_SCHEMA.array(),
|
|
56
|
+
recommendationHash: z.string(),
|
|
57
|
+
recommendationMessage: z.string(),
|
|
58
|
+
recommendationSignature: z.string(),
|
|
59
|
+
recommendationStage: z.string(),
|
|
60
|
+
recommendationType: z.string(),
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
export const META_ADS_PROCESSING_EVENT_SCHEMA = META_ADS_EVENT_BASE_SCHEMA.extend({
|
|
64
|
+
field: z.literal("in_process_ad_objects"),
|
|
65
|
+
value: z.object({
|
|
66
|
+
id: META_ADS_ID_SCHEMA,
|
|
67
|
+
level: z.enum(["AD", "AD_SET", "CAMPAIGN", "CREATIVE"]),
|
|
68
|
+
statusName: z.string(),
|
|
69
|
+
}),
|
|
70
|
+
});
|
|
71
|
+
export const META_ADS_ISSUES_EVENT_SCHEMA = META_ADS_EVENT_BASE_SCHEMA.extend({
|
|
72
|
+
field: z.literal("with_issues_ad_objects"),
|
|
73
|
+
value: z.object({
|
|
74
|
+
errorCode: z.string(),
|
|
75
|
+
errorMessage: z.string(),
|
|
76
|
+
errorSummary: z.string(),
|
|
77
|
+
id: META_ADS_ID_SCHEMA,
|
|
78
|
+
level: z.enum(["AD", "AD_SET", "CAMPAIGN", "CREATIVE"]),
|
|
79
|
+
}),
|
|
80
|
+
});
|
|
81
|
+
export const META_ADS_LEAD_CREATED_EVENT_SCHEMA = z.object({
|
|
82
|
+
adId: z.string().optional(),
|
|
83
|
+
adgroupId: z.string().optional(),
|
|
84
|
+
createdTime: z.number().int().nonnegative(),
|
|
85
|
+
formId: META_ADS_ID_SCHEMA,
|
|
86
|
+
leadgenId: META_ADS_ID_SCHEMA,
|
|
87
|
+
pageId: META_ADS_ID_SCHEMA,
|
|
88
|
+
});
|
|
89
|
+
export const META_ADS_TRIGGER_CONFIG_SCHEMA = z.object({
|
|
90
|
+
account: z.string().optional(),
|
|
91
|
+
adAccountId: META_ADS_ID_SCHEMA,
|
|
92
|
+
});
|
|
93
|
+
export const META_ADS_LEAD_TRIGGER_CONFIG_SCHEMA = z.object({
|
|
94
|
+
account: z.string().optional(),
|
|
95
|
+
pageId: META_ADS_ID_SCHEMA,
|
|
96
|
+
});
|
|
97
|
+
export const metaAdsTriggerContracts = {
|
|
98
|
+
"meta-ads.ad.effectiveStatusChanged": {
|
|
99
|
+
configSchema: META_ADS_TRIGGER_CONFIG_SCHEMA,
|
|
100
|
+
eventSchema: META_ADS_EFFECTIVE_STATUS_EVENT_SCHEMA,
|
|
101
|
+
},
|
|
102
|
+
"meta-ads.ad.recommendation": {
|
|
103
|
+
configSchema: META_ADS_TRIGGER_CONFIG_SCHEMA,
|
|
104
|
+
eventSchema: META_ADS_RECOMMENDATION_EVENT_SCHEMA,
|
|
105
|
+
},
|
|
106
|
+
"meta-ads.adObject.issuesChanged": {
|
|
107
|
+
configSchema: META_ADS_TRIGGER_CONFIG_SCHEMA,
|
|
108
|
+
eventSchema: META_ADS_ISSUES_EVENT_SCHEMA,
|
|
109
|
+
},
|
|
110
|
+
"meta-ads.adObject.processingCompleted": {
|
|
111
|
+
configSchema: META_ADS_TRIGGER_CONFIG_SCHEMA,
|
|
112
|
+
eventSchema: META_ADS_PROCESSING_EVENT_SCHEMA,
|
|
113
|
+
},
|
|
114
|
+
"meta-ads.adSet.effectiveStatusChanged": {
|
|
115
|
+
configSchema: META_ADS_TRIGGER_CONFIG_SCHEMA,
|
|
116
|
+
eventSchema: META_ADS_EFFECTIVE_STATUS_EVENT_SCHEMA,
|
|
117
|
+
},
|
|
118
|
+
"meta-ads.campaign.effectiveStatusChanged": {
|
|
119
|
+
configSchema: META_ADS_TRIGGER_CONFIG_SCHEMA,
|
|
120
|
+
eventSchema: META_ADS_EFFECTIVE_STATUS_EVENT_SCHEMA,
|
|
121
|
+
},
|
|
122
|
+
"meta-ads.creativeFatigue.changed": {
|
|
123
|
+
configSchema: META_ADS_TRIGGER_CONFIG_SCHEMA,
|
|
124
|
+
eventSchema: META_ADS_CREATIVE_FATIGUE_EVENT_SCHEMA,
|
|
125
|
+
},
|
|
126
|
+
"meta-ads.event": {
|
|
127
|
+
configSchema: META_ADS_TRIGGER_CONFIG_SCHEMA,
|
|
128
|
+
eventSchema: META_ADS_EVENT_SCHEMA,
|
|
129
|
+
},
|
|
130
|
+
"meta-ads.insights.milestoneReached": {
|
|
131
|
+
configSchema: META_ADS_TRIGGER_CONFIG_SCHEMA,
|
|
132
|
+
eventSchema: META_ADS_SUBSCRIPTION_EVENT_SCHEMA,
|
|
133
|
+
},
|
|
134
|
+
"meta-ads.insights.updated": {
|
|
135
|
+
configSchema: META_ADS_TRIGGER_CONFIG_SCHEMA,
|
|
136
|
+
eventSchema: META_ADS_SUBSCRIPTION_EVENT_SCHEMA,
|
|
137
|
+
},
|
|
138
|
+
"meta-ads.lead.created": {
|
|
139
|
+
configSchema: META_ADS_LEAD_TRIGGER_CONFIG_SCHEMA,
|
|
140
|
+
eventSchema: META_ADS_LEAD_CREATED_EVENT_SCHEMA,
|
|
141
|
+
},
|
|
142
|
+
"meta-ads.object.created": {
|
|
143
|
+
configSchema: META_ADS_TRIGGER_CONFIG_SCHEMA,
|
|
144
|
+
eventSchema: META_ADS_SUBSCRIPTION_EVENT_SCHEMA,
|
|
145
|
+
},
|
|
146
|
+
"meta-ads.object.updated": {
|
|
147
|
+
configSchema: META_ADS_TRIGGER_CONFIG_SCHEMA,
|
|
148
|
+
eventSchema: META_ADS_SUBSCRIPTION_EVENT_SCHEMA,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Normalizes Meta's Page and ad-account envelopes into stable public events.
|
|
153
|
+
*
|
|
154
|
+
* @param input - Untrusted provider webhook envelope.
|
|
155
|
+
*/
|
|
156
|
+
export function normalizeMetaAdsWebhook(input) {
|
|
157
|
+
const envelope = META_ADS_WEBHOOK_ENVELOPE_SCHEMA.parse(input);
|
|
158
|
+
const adAccountEvents = [];
|
|
159
|
+
const leadEvents = [];
|
|
160
|
+
for (const entry of envelope.entry) {
|
|
161
|
+
for (const change of entry.changes) {
|
|
162
|
+
if (envelope.object === "page" && change.field === "leadgen") {
|
|
163
|
+
const value = z
|
|
164
|
+
.object({
|
|
165
|
+
ad_id: z.string().optional(),
|
|
166
|
+
adgroup_id: z.string().optional(),
|
|
167
|
+
created_time: z.number().int().nonnegative(),
|
|
168
|
+
form_id: z.string(),
|
|
169
|
+
leadgen_id: z.string(),
|
|
170
|
+
page_id: z.string(),
|
|
171
|
+
})
|
|
172
|
+
.parse(change.value);
|
|
173
|
+
leadEvents.push({
|
|
174
|
+
adId: value.ad_id,
|
|
175
|
+
adgroupId: value.adgroup_id,
|
|
176
|
+
createdTime: value.created_time,
|
|
177
|
+
formId: value.form_id,
|
|
178
|
+
leadgenId: value.leadgen_id,
|
|
179
|
+
pageId: value.page_id,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
else if (envelope.object === "ad_account") {
|
|
183
|
+
adAccountEvents.push({
|
|
184
|
+
accountId: entry.id,
|
|
185
|
+
field: change.field,
|
|
186
|
+
occurredAt: entry.time,
|
|
187
|
+
value: encodableSchema.parse(fromMeta(change.value)),
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return { adAccountEvents, leadEvents };
|
|
193
|
+
}
|