@automate.ax/integration-contracts 0.139.1 → 0.141.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/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 +467 -0
- 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/triggers.d.ts +2 -1
- package/package.json +14 -2
- package/src/closebot/api.ts +157 -0
- package/src/closebot/index.ts +2 -0
- package/src/closebot/schemas.ts +517 -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 +2 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { META_ADS_PAGE_INFO_SCHEMA } from "./schemas.js";
|
|
3
|
+
export const META_ADS_GRAPH_API_VERSION = "v26.0";
|
|
4
|
+
const META_ADS_API_BASE_URL = `https://graph.facebook.com/${META_ADS_GRAPH_API_VERSION}/`;
|
|
5
|
+
const META_ADS_API_ORIGIN = new URL(META_ADS_API_BASE_URL).origin;
|
|
6
|
+
export const META_ADS_OAUTH_SECRET_SCHEMA = z.object({
|
|
7
|
+
accessToken: z.string().min(1),
|
|
8
|
+
expiresAt: z.number().nullable(),
|
|
9
|
+
tokenType: z.string(),
|
|
10
|
+
});
|
|
11
|
+
const META_ERROR_SCHEMA = z.looseObject({
|
|
12
|
+
code: z.number().optional(),
|
|
13
|
+
errorSubcode: z.number().optional(),
|
|
14
|
+
errorUserMessage: z.string().optional(),
|
|
15
|
+
fbtraceId: z.string().optional(),
|
|
16
|
+
isTransient: z.boolean().optional(),
|
|
17
|
+
message: z.string(),
|
|
18
|
+
type: z.string().optional(),
|
|
19
|
+
});
|
|
20
|
+
const ERROR_ENVELOPE_SCHEMA = z.looseObject({ error: META_ERROR_SCHEMA });
|
|
21
|
+
const PAGE_SCHEMA = z.looseObject({
|
|
22
|
+
data: z.unknown(),
|
|
23
|
+
paging: z
|
|
24
|
+
.looseObject({
|
|
25
|
+
cursors: z
|
|
26
|
+
.looseObject({
|
|
27
|
+
after: z.string().optional(),
|
|
28
|
+
before: z.string().optional(),
|
|
29
|
+
})
|
|
30
|
+
.optional(),
|
|
31
|
+
next: z.string().optional(),
|
|
32
|
+
previous: z.string().optional(),
|
|
33
|
+
})
|
|
34
|
+
.optional(),
|
|
35
|
+
});
|
|
36
|
+
/** Structured Graph API failure with Meta quota and trace diagnostics. */
|
|
37
|
+
export class MetaAdsApiError extends Error {
|
|
38
|
+
appUsage;
|
|
39
|
+
businessUseCaseUsage;
|
|
40
|
+
code;
|
|
41
|
+
fbtraceId;
|
|
42
|
+
isTransient;
|
|
43
|
+
adAccountUsage;
|
|
44
|
+
errorSubcode;
|
|
45
|
+
retryAfter;
|
|
46
|
+
status;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a structured Meta Ads failure.
|
|
49
|
+
*
|
|
50
|
+
* @param options - Transport, provider, and quota details.
|
|
51
|
+
* @param options.adAccountUsage - Raw ad-account usage header.
|
|
52
|
+
* @param options.appUsage - Raw app usage header.
|
|
53
|
+
* @param options.businessUseCaseUsage - Raw business-use-case usage header.
|
|
54
|
+
* @param options.error - Parsed provider error.
|
|
55
|
+
* @param options.retryAfter - Retry delay in seconds.
|
|
56
|
+
* @param options.status - HTTP response status.
|
|
57
|
+
*/
|
|
58
|
+
constructor(options) {
|
|
59
|
+
const providerError = options.error;
|
|
60
|
+
super(providerError?.message
|
|
61
|
+
? `Meta Ads API error (${providerError.code ?? options.status}): ${providerError.message}`
|
|
62
|
+
: `Meta Ads API request failed with status ${options.status}.`);
|
|
63
|
+
this.name = "MetaAdsApiError";
|
|
64
|
+
this.adAccountUsage = options.adAccountUsage;
|
|
65
|
+
this.appUsage = options.appUsage;
|
|
66
|
+
this.businessUseCaseUsage = options.businessUseCaseUsage;
|
|
67
|
+
this.code = providerError?.code;
|
|
68
|
+
this.errorSubcode = providerError?.errorSubcode;
|
|
69
|
+
this.fbtraceId = providerError?.fbtraceId;
|
|
70
|
+
this.isTransient = providerError?.isTransient ?? false;
|
|
71
|
+
this.retryAfter = options.retryAfter;
|
|
72
|
+
this.status = options.status;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Creates the authenticated Graph API helper used by packaged and custom
|
|
77
|
+
* actions.
|
|
78
|
+
*
|
|
79
|
+
* @param account - Resolved Meta Ads OAuth account.
|
|
80
|
+
* @throws When the connection method or stored credential is invalid.
|
|
81
|
+
*/
|
|
82
|
+
export function getMetaAdsApi(account) {
|
|
83
|
+
if (account.connectionMethodId !== "oauth") {
|
|
84
|
+
throw new Error(`Unsupported Meta Ads connection method: ${account.connectionMethodId}`);
|
|
85
|
+
}
|
|
86
|
+
const { accessToken } = META_ADS_OAUTH_SECRET_SCHEMA.parse(account.secret);
|
|
87
|
+
/**
|
|
88
|
+
* Calls one Graph endpoint and validates its normalized result.
|
|
89
|
+
*
|
|
90
|
+
* @param path - Path relative to the pinned Graph root.
|
|
91
|
+
* @param options - Request options and response schema.
|
|
92
|
+
*/
|
|
93
|
+
async function call(path, options) {
|
|
94
|
+
return options.responseSchema.parse(fromMeta(await rawRequest(path, options)));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Calls one Graph edge and preserves cursor metadata.
|
|
98
|
+
*
|
|
99
|
+
* @param path - Path relative to the pinned Graph root.
|
|
100
|
+
* @param options - Request options and item schema.
|
|
101
|
+
*/
|
|
102
|
+
async function page(path, options) {
|
|
103
|
+
const parsed = PAGE_SCHEMA.parse(await rawRequest(path, options));
|
|
104
|
+
const paging = parsed.paging;
|
|
105
|
+
return {
|
|
106
|
+
items: options.responseSchema.parse(fromMeta(parsed.data)),
|
|
107
|
+
...(paging && {
|
|
108
|
+
pageInfo: META_ADS_PAGE_INFO_SCHEMA.parse({
|
|
109
|
+
after: paging.cursors?.after,
|
|
110
|
+
before: paging.cursors?.before,
|
|
111
|
+
next: paging.next,
|
|
112
|
+
previous: paging.previous,
|
|
113
|
+
}),
|
|
114
|
+
}),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Executes one authenticated request and returns its raw JSON value.
|
|
119
|
+
*
|
|
120
|
+
* @param path - Path relative to the pinned Graph root.
|
|
121
|
+
* @param options - Request method, query, and body.
|
|
122
|
+
*/
|
|
123
|
+
async function rawRequest(path, options) {
|
|
124
|
+
const url = new URL(path.replace(/^\/+/, ""), META_ADS_API_BASE_URL);
|
|
125
|
+
if (url.origin !== META_ADS_API_ORIGIN ||
|
|
126
|
+
!url.pathname.startsWith(`/${META_ADS_GRAPH_API_VERSION}/`)) {
|
|
127
|
+
throw new Error(`Meta Ads API paths must remain under /${META_ADS_GRAPH_API_VERSION}.`);
|
|
128
|
+
}
|
|
129
|
+
for (const [name, value] of Object.entries(options.query ?? {})) {
|
|
130
|
+
if (value !== undefined) {
|
|
131
|
+
url.searchParams.set(toSnakeCase(name), Array.isArray(value) ? value.join(",") : String(value));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const body = options.body === undefined ? undefined : toFormData(options.body);
|
|
135
|
+
const response = await fetch(url, {
|
|
136
|
+
body,
|
|
137
|
+
headers: { Authorization: `Bearer ${accessToken}` },
|
|
138
|
+
method: options.method ?? (body ? "POST" : "GET"),
|
|
139
|
+
});
|
|
140
|
+
const payload = parseJson(await response.text());
|
|
141
|
+
if (!response.ok) {
|
|
142
|
+
const error = ERROR_ENVELOPE_SCHEMA.safeParse(fromMeta(payload));
|
|
143
|
+
throw new MetaAdsApiError({
|
|
144
|
+
adAccountUsage: response.headers.get("X-Ad-Account-Usage") ?? undefined,
|
|
145
|
+
appUsage: response.headers.get("X-App-Usage") ?? undefined,
|
|
146
|
+
businessUseCaseUsage: response.headers.get("X-Business-Use-Case-Usage") ?? undefined,
|
|
147
|
+
error: error.success ? error.data.error : undefined,
|
|
148
|
+
retryAfter: numberOrUndefined(response.headers.get("Retry-After")),
|
|
149
|
+
status: response.status,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return payload;
|
|
153
|
+
}
|
|
154
|
+
return { call, page };
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Encodes one public request body for Graph's form boundary.
|
|
158
|
+
*
|
|
159
|
+
* @param value - Codec-safe public request body.
|
|
160
|
+
* @throws When the body is not an object.
|
|
161
|
+
*/
|
|
162
|
+
function toFormData(value) {
|
|
163
|
+
if (!isRecord(value))
|
|
164
|
+
throw new Error("Meta Ads request bodies must be objects.");
|
|
165
|
+
const form = new URLSearchParams();
|
|
166
|
+
for (const [name, item] of Object.entries(value)) {
|
|
167
|
+
if (item === undefined)
|
|
168
|
+
continue;
|
|
169
|
+
form.set(toSnakeCase(name), typeof item === "string" ||
|
|
170
|
+
typeof item === "number" ||
|
|
171
|
+
typeof item === "boolean"
|
|
172
|
+
? String(item)
|
|
173
|
+
: item instanceof Date
|
|
174
|
+
? item.toISOString()
|
|
175
|
+
: JSON.stringify(toMeta(item)));
|
|
176
|
+
}
|
|
177
|
+
return form;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Converts public camelCase object keys to Meta wire keys recursively.
|
|
181
|
+
*
|
|
182
|
+
* @param value - Codec-safe public value.
|
|
183
|
+
*/
|
|
184
|
+
export function toMeta(value) {
|
|
185
|
+
if (value instanceof Date)
|
|
186
|
+
return value.toISOString();
|
|
187
|
+
if (Array.isArray(value))
|
|
188
|
+
return value.map(toMeta);
|
|
189
|
+
if (!isRecord(value))
|
|
190
|
+
return value;
|
|
191
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
192
|
+
toSnakeCase(key),
|
|
193
|
+
toMeta(item),
|
|
194
|
+
]));
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Converts Meta wire keys to public camelCase keys recursively.
|
|
198
|
+
*
|
|
199
|
+
* @param value - Provider value.
|
|
200
|
+
*/
|
|
201
|
+
export function fromMeta(value) {
|
|
202
|
+
if (Array.isArray(value))
|
|
203
|
+
return value.map(fromMeta);
|
|
204
|
+
if (!isRecord(value))
|
|
205
|
+
return value;
|
|
206
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
207
|
+
toCamelCase(key),
|
|
208
|
+
fromMeta(item),
|
|
209
|
+
]));
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Converts one camelCase key to snake_case.
|
|
213
|
+
*
|
|
214
|
+
* @param value - Public key.
|
|
215
|
+
*/
|
|
216
|
+
function toSnakeCase(value) {
|
|
217
|
+
return value.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Converts one snake_case key to camelCase.
|
|
221
|
+
*
|
|
222
|
+
* @param value - Provider key.
|
|
223
|
+
*/
|
|
224
|
+
function toCamelCase(value) {
|
|
225
|
+
return value.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Parses a response body while retaining non-JSON provider failures.
|
|
229
|
+
*
|
|
230
|
+
* @param text - Raw response body.
|
|
231
|
+
*/
|
|
232
|
+
function parseJson(text) {
|
|
233
|
+
if (text === "")
|
|
234
|
+
return undefined;
|
|
235
|
+
try {
|
|
236
|
+
return JSON.parse(text);
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
return text;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Parses an optional finite numeric header.
|
|
244
|
+
*
|
|
245
|
+
* @param value - Raw header value.
|
|
246
|
+
*/
|
|
247
|
+
function numberOrUndefined(value) {
|
|
248
|
+
if (value === null)
|
|
249
|
+
return undefined;
|
|
250
|
+
const number = Number(value);
|
|
251
|
+
return Number.isFinite(number) ? number : undefined;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Narrows one codec-safe object value.
|
|
255
|
+
*
|
|
256
|
+
* @param value - Unknown value.
|
|
257
|
+
*/
|
|
258
|
+
function isRecord(value) {
|
|
259
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
260
|
+
}
|
|
@@ -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;
|