@automate.ax/integration-contracts 0.139.2 → 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,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
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export declare const META_ADS_ID_SCHEMA: z.ZodString;
|
|
3
|
+
export declare const META_ADS_STATUS_SCHEMA: z.ZodEnum<{
|
|
4
|
+
ACTIVE: "ACTIVE";
|
|
5
|
+
ARCHIVED: "ARCHIVED";
|
|
6
|
+
DELETED: "DELETED";
|
|
7
|
+
PAUSED: "PAUSED";
|
|
8
|
+
}>;
|
|
9
|
+
export declare const META_ADS_BUSINESS_SCHEMA: z.ZodObject<{
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
verificationStatus: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
14
|
+
export declare const META_ADS_ACCOUNT_SCHEMA: z.ZodObject<{
|
|
15
|
+
accountId: z.ZodOptional<z.ZodString>;
|
|
16
|
+
amountSpent: z.ZodOptional<z.ZodString>;
|
|
17
|
+
balance: z.ZodOptional<z.ZodString>;
|
|
18
|
+
business: z.ZodOptional<z.ZodObject<{
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
name: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>>;
|
|
22
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
name: z.ZodString;
|
|
25
|
+
timezoneId: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
timezoneName: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
28
|
+
export declare const META_ADS_CAMPAIGN_SCHEMA: z.ZodObject<{
|
|
29
|
+
buyingType: z.ZodOptional<z.ZodString>;
|
|
30
|
+
configuredStatus: z.ZodOptional<z.ZodString>;
|
|
31
|
+
effectiveStatus: z.ZodOptional<z.ZodString>;
|
|
32
|
+
id: z.ZodString;
|
|
33
|
+
name: z.ZodString;
|
|
34
|
+
objective: z.ZodOptional<z.ZodString>;
|
|
35
|
+
specialAdCategories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
|
+
status: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
38
|
+
export declare const META_ADS_AD_SET_SCHEMA: z.ZodObject<{
|
|
39
|
+
bidAmount: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
billingEvent: z.ZodOptional<z.ZodString>;
|
|
41
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
42
|
+
configuredStatus: z.ZodOptional<z.ZodString>;
|
|
43
|
+
dailyBudget: z.ZodOptional<z.ZodString>;
|
|
44
|
+
effectiveStatus: z.ZodOptional<z.ZodString>;
|
|
45
|
+
endTime: z.ZodOptional<z.ZodString>;
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
lifetimeBudget: z.ZodOptional<z.ZodString>;
|
|
48
|
+
name: z.ZodString;
|
|
49
|
+
optimizationGoal: z.ZodOptional<z.ZodString>;
|
|
50
|
+
startTime: z.ZodOptional<z.ZodString>;
|
|
51
|
+
status: z.ZodOptional<z.ZodString>;
|
|
52
|
+
targeting: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
53
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
54
|
+
export declare const META_ADS_AD_SCHEMA: z.ZodObject<{
|
|
55
|
+
adsetId: z.ZodOptional<z.ZodString>;
|
|
56
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
57
|
+
configuredStatus: z.ZodOptional<z.ZodString>;
|
|
58
|
+
creative: z.ZodOptional<z.ZodObject<{
|
|
59
|
+
id: z.ZodString;
|
|
60
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>>;
|
|
61
|
+
effectiveStatus: z.ZodOptional<z.ZodString>;
|
|
62
|
+
id: z.ZodString;
|
|
63
|
+
name: z.ZodString;
|
|
64
|
+
status: z.ZodOptional<z.ZodString>;
|
|
65
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
66
|
+
export declare const META_ADS_CREATIVE_SCHEMA: z.ZodObject<{
|
|
67
|
+
accountId: z.ZodOptional<z.ZodString>;
|
|
68
|
+
body: z.ZodOptional<z.ZodString>;
|
|
69
|
+
effectiveObjectStoryId: z.ZodOptional<z.ZodString>;
|
|
70
|
+
id: z.ZodString;
|
|
71
|
+
name: z.ZodOptional<z.ZodString>;
|
|
72
|
+
objectStoryId: z.ZodOptional<z.ZodString>;
|
|
73
|
+
status: z.ZodOptional<z.ZodString>;
|
|
74
|
+
title: z.ZodOptional<z.ZodString>;
|
|
75
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
76
|
+
export declare const META_ADS_AUDIENCE_SCHEMA: z.ZodObject<{
|
|
77
|
+
accountId: z.ZodOptional<z.ZodString>;
|
|
78
|
+
approximateCountLowerBound: z.ZodOptional<z.ZodNumber>;
|
|
79
|
+
approximateCountUpperBound: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
description: z.ZodOptional<z.ZodString>;
|
|
81
|
+
id: z.ZodString;
|
|
82
|
+
name: z.ZodString;
|
|
83
|
+
subtype: z.ZodOptional<z.ZodString>;
|
|
84
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
85
|
+
export declare const META_ADS_LEAD_FORM_SCHEMA: z.ZodObject<{
|
|
86
|
+
id: z.ZodString;
|
|
87
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
88
|
+
name: z.ZodString;
|
|
89
|
+
status: z.ZodOptional<z.ZodString>;
|
|
90
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
91
|
+
export declare const META_ADS_LEAD_SCHEMA: z.ZodObject<{
|
|
92
|
+
adId: z.ZodOptional<z.ZodString>;
|
|
93
|
+
adName: z.ZodOptional<z.ZodString>;
|
|
94
|
+
adsetId: z.ZodOptional<z.ZodString>;
|
|
95
|
+
adsetName: z.ZodOptional<z.ZodString>;
|
|
96
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
97
|
+
campaignName: z.ZodOptional<z.ZodString>;
|
|
98
|
+
createdTime: z.ZodOptional<z.ZodString>;
|
|
99
|
+
fieldData: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
100
|
+
name: z.ZodString;
|
|
101
|
+
values: z.ZodArray<z.ZodString>;
|
|
102
|
+
}, z.core.$strip>>>;
|
|
103
|
+
formId: z.ZodOptional<z.ZodString>;
|
|
104
|
+
id: z.ZodString;
|
|
105
|
+
isOrganic: z.ZodOptional<z.ZodBoolean>;
|
|
106
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
107
|
+
export declare const META_ADS_PIXEL_SCHEMA: z.ZodObject<{
|
|
108
|
+
code: z.ZodOptional<z.ZodString>;
|
|
109
|
+
id: z.ZodString;
|
|
110
|
+
isUnavailable: z.ZodOptional<z.ZodBoolean>;
|
|
111
|
+
lastFiredTime: z.ZodOptional<z.ZodString>;
|
|
112
|
+
name: z.ZodString;
|
|
113
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
114
|
+
export declare const META_ADS_INSIGHT_SCHEMA: z.ZodObject<{
|
|
115
|
+
accountId: z.ZodOptional<z.ZodString>;
|
|
116
|
+
accountName: z.ZodOptional<z.ZodString>;
|
|
117
|
+
adId: z.ZodOptional<z.ZodString>;
|
|
118
|
+
adName: z.ZodOptional<z.ZodString>;
|
|
119
|
+
adsetId: z.ZodOptional<z.ZodString>;
|
|
120
|
+
adsetName: z.ZodOptional<z.ZodString>;
|
|
121
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
122
|
+
campaignName: z.ZodOptional<z.ZodString>;
|
|
123
|
+
clicks: z.ZodOptional<z.ZodString>;
|
|
124
|
+
cpc: z.ZodOptional<z.ZodString>;
|
|
125
|
+
cpm: z.ZodOptional<z.ZodString>;
|
|
126
|
+
ctr: z.ZodOptional<z.ZodString>;
|
|
127
|
+
dateStart: z.ZodOptional<z.ZodString>;
|
|
128
|
+
dateStop: z.ZodOptional<z.ZodString>;
|
|
129
|
+
impressions: z.ZodOptional<z.ZodString>;
|
|
130
|
+
reach: z.ZodOptional<z.ZodString>;
|
|
131
|
+
spend: z.ZodOptional<z.ZodString>;
|
|
132
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
133
|
+
export declare const META_ADS_SUBSCRIPTION_SCHEMA: z.ZodObject<{
|
|
134
|
+
eventType: z.ZodEnum<{
|
|
135
|
+
INSIGHTS_MILESTONE_REACHED: "INSIGHTS_MILESTONE_REACHED";
|
|
136
|
+
INSIGHTS_UPDATED: "INSIGHTS_UPDATED";
|
|
137
|
+
OBJECT_CREATED: "OBJECT_CREATED";
|
|
138
|
+
OBJECT_UPDATED: "OBJECT_UPDATED";
|
|
139
|
+
}>;
|
|
140
|
+
field: z.ZodOptional<z.ZodString>;
|
|
141
|
+
filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
142
|
+
field: z.ZodString;
|
|
143
|
+
operator: z.ZodString;
|
|
144
|
+
value: z.ZodString;
|
|
145
|
+
}, z.core.$strip>>>;
|
|
146
|
+
operator: z.ZodOptional<z.ZodString>;
|
|
147
|
+
status: z.ZodOptional<z.ZodString>;
|
|
148
|
+
subscriptionId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
149
|
+
value: z.ZodOptional<z.ZodString>;
|
|
150
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
151
|
+
export declare const META_ADS_SUBSCRIPTION_CREATE_RESULT_SCHEMA: z.ZodObject<{
|
|
152
|
+
subscriptionId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
153
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
154
|
+
export declare const META_ADS_MUTATION_RESULT_SCHEMA: z.ZodObject<{
|
|
155
|
+
id: z.ZodOptional<z.ZodString>;
|
|
156
|
+
success: z.ZodOptional<z.ZodBoolean>;
|
|
157
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
158
|
+
export declare const META_ADS_CONVERSION_RESULT_SCHEMA: z.ZodObject<{
|
|
159
|
+
eventsReceived: z.ZodNumber;
|
|
160
|
+
fbtraceId: z.ZodOptional<z.ZodString>;
|
|
161
|
+
messages: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
162
|
+
}, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
|
|
163
|
+
export declare const META_ADS_PAGE_INFO_SCHEMA: z.ZodObject<{
|
|
164
|
+
after: z.ZodOptional<z.ZodString>;
|
|
165
|
+
before: z.ZodOptional<z.ZodString>;
|
|
166
|
+
next: z.ZodOptional<z.ZodString>;
|
|
167
|
+
previous: z.ZodOptional<z.ZodString>;
|
|
168
|
+
}, z.core.$strip>;
|
|
169
|
+
export declare const META_ADS_WEBHOOK_CHANGE_SCHEMA: z.ZodObject<{
|
|
170
|
+
field: z.ZodString;
|
|
171
|
+
value: z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
|
|
172
|
+
}, z.core.$strip>;
|
|
173
|
+
export declare const META_ADS_WEBHOOK_ENVELOPE_SCHEMA: z.ZodObject<{
|
|
174
|
+
entry: z.ZodArray<z.ZodObject<{
|
|
175
|
+
changes: z.ZodArray<z.ZodObject<{
|
|
176
|
+
field: z.ZodString;
|
|
177
|
+
value: z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
|
|
178
|
+
}, z.core.$strip>>;
|
|
179
|
+
id: z.ZodString;
|
|
180
|
+
time: z.ZodNumber;
|
|
181
|
+
}, z.core.$strip>>;
|
|
182
|
+
object: z.ZodString;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
export type MetaAdsWebhookEnvelope = z.output<typeof META_ADS_WEBHOOK_ENVELOPE_SCHEMA>;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { encodableSchema } from "@automate.ax/codec";
|
|
3
|
+
const metaObject = (shape) => z.object(shape).catchall(encodableSchema);
|
|
4
|
+
export const META_ADS_ID_SCHEMA = z.string().trim().min(1);
|
|
5
|
+
export const META_ADS_STATUS_SCHEMA = z.enum([
|
|
6
|
+
"ACTIVE",
|
|
7
|
+
"ARCHIVED",
|
|
8
|
+
"DELETED",
|
|
9
|
+
"PAUSED",
|
|
10
|
+
]);
|
|
11
|
+
export const META_ADS_BUSINESS_SCHEMA = metaObject({
|
|
12
|
+
id: META_ADS_ID_SCHEMA,
|
|
13
|
+
name: z.string(),
|
|
14
|
+
verificationStatus: z.string().optional(),
|
|
15
|
+
});
|
|
16
|
+
export const META_ADS_ACCOUNT_SCHEMA = metaObject({
|
|
17
|
+
accountId: z.string().optional(),
|
|
18
|
+
amountSpent: z.string().optional(),
|
|
19
|
+
balance: z.string().optional(),
|
|
20
|
+
business: metaObject({
|
|
21
|
+
id: z.string(),
|
|
22
|
+
name: z.string().optional(),
|
|
23
|
+
}).optional(),
|
|
24
|
+
currency: z.string().optional(),
|
|
25
|
+
id: META_ADS_ID_SCHEMA,
|
|
26
|
+
name: z.string(),
|
|
27
|
+
timezoneId: z.number().optional(),
|
|
28
|
+
timezoneName: z.string().optional(),
|
|
29
|
+
});
|
|
30
|
+
export const META_ADS_CAMPAIGN_SCHEMA = metaObject({
|
|
31
|
+
buyingType: z.string().optional(),
|
|
32
|
+
configuredStatus: z.string().optional(),
|
|
33
|
+
effectiveStatus: z.string().optional(),
|
|
34
|
+
id: META_ADS_ID_SCHEMA,
|
|
35
|
+
name: z.string(),
|
|
36
|
+
objective: z.string().optional(),
|
|
37
|
+
specialAdCategories: z.string().array().optional(),
|
|
38
|
+
status: z.string().optional(),
|
|
39
|
+
});
|
|
40
|
+
export const META_ADS_AD_SET_SCHEMA = metaObject({
|
|
41
|
+
bidAmount: z.number().optional(),
|
|
42
|
+
billingEvent: z.string().optional(),
|
|
43
|
+
campaignId: META_ADS_ID_SCHEMA.optional(),
|
|
44
|
+
configuredStatus: z.string().optional(),
|
|
45
|
+
dailyBudget: z.string().optional(),
|
|
46
|
+
effectiveStatus: z.string().optional(),
|
|
47
|
+
endTime: z.string().optional(),
|
|
48
|
+
id: META_ADS_ID_SCHEMA,
|
|
49
|
+
lifetimeBudget: z.string().optional(),
|
|
50
|
+
name: z.string(),
|
|
51
|
+
optimizationGoal: z.string().optional(),
|
|
52
|
+
startTime: z.string().optional(),
|
|
53
|
+
status: z.string().optional(),
|
|
54
|
+
targeting: z.record(z.string(), encodableSchema).optional(),
|
|
55
|
+
});
|
|
56
|
+
export const META_ADS_AD_SCHEMA = metaObject({
|
|
57
|
+
adsetId: META_ADS_ID_SCHEMA.optional(),
|
|
58
|
+
campaignId: META_ADS_ID_SCHEMA.optional(),
|
|
59
|
+
configuredStatus: z.string().optional(),
|
|
60
|
+
creative: metaObject({ id: z.string() }).optional(),
|
|
61
|
+
effectiveStatus: z.string().optional(),
|
|
62
|
+
id: META_ADS_ID_SCHEMA,
|
|
63
|
+
name: z.string(),
|
|
64
|
+
status: z.string().optional(),
|
|
65
|
+
});
|
|
66
|
+
export const META_ADS_CREATIVE_SCHEMA = metaObject({
|
|
67
|
+
accountId: z.string().optional(),
|
|
68
|
+
body: z.string().optional(),
|
|
69
|
+
effectiveObjectStoryId: z.string().optional(),
|
|
70
|
+
id: META_ADS_ID_SCHEMA,
|
|
71
|
+
name: z.string().optional(),
|
|
72
|
+
objectStoryId: z.string().optional(),
|
|
73
|
+
status: z.string().optional(),
|
|
74
|
+
title: z.string().optional(),
|
|
75
|
+
});
|
|
76
|
+
export const META_ADS_AUDIENCE_SCHEMA = metaObject({
|
|
77
|
+
accountId: z.string().optional(),
|
|
78
|
+
approximateCountLowerBound: z.number().optional(),
|
|
79
|
+
approximateCountUpperBound: z.number().optional(),
|
|
80
|
+
description: z.string().optional(),
|
|
81
|
+
id: META_ADS_ID_SCHEMA,
|
|
82
|
+
name: z.string(),
|
|
83
|
+
subtype: z.string().optional(),
|
|
84
|
+
});
|
|
85
|
+
export const META_ADS_LEAD_FORM_SCHEMA = metaObject({
|
|
86
|
+
id: META_ADS_ID_SCHEMA,
|
|
87
|
+
locale: z.string().optional(),
|
|
88
|
+
name: z.string(),
|
|
89
|
+
status: z.string().optional(),
|
|
90
|
+
});
|
|
91
|
+
export const META_ADS_LEAD_SCHEMA = metaObject({
|
|
92
|
+
adId: z.string().optional(),
|
|
93
|
+
adName: z.string().optional(),
|
|
94
|
+
adsetId: z.string().optional(),
|
|
95
|
+
adsetName: z.string().optional(),
|
|
96
|
+
campaignId: z.string().optional(),
|
|
97
|
+
campaignName: z.string().optional(),
|
|
98
|
+
createdTime: z.string().optional(),
|
|
99
|
+
fieldData: z
|
|
100
|
+
.object({ name: z.string(), values: z.string().array() })
|
|
101
|
+
.array()
|
|
102
|
+
.optional(),
|
|
103
|
+
formId: z.string().optional(),
|
|
104
|
+
id: META_ADS_ID_SCHEMA,
|
|
105
|
+
isOrganic: z.boolean().optional(),
|
|
106
|
+
});
|
|
107
|
+
export const META_ADS_PIXEL_SCHEMA = metaObject({
|
|
108
|
+
code: z.string().optional(),
|
|
109
|
+
id: META_ADS_ID_SCHEMA,
|
|
110
|
+
isUnavailable: z.boolean().optional(),
|
|
111
|
+
lastFiredTime: z.string().optional(),
|
|
112
|
+
name: z.string(),
|
|
113
|
+
});
|
|
114
|
+
export const META_ADS_INSIGHT_SCHEMA = metaObject({
|
|
115
|
+
accountId: z.string().optional(),
|
|
116
|
+
accountName: z.string().optional(),
|
|
117
|
+
adId: z.string().optional(),
|
|
118
|
+
adName: z.string().optional(),
|
|
119
|
+
adsetId: z.string().optional(),
|
|
120
|
+
adsetName: z.string().optional(),
|
|
121
|
+
campaignId: z.string().optional(),
|
|
122
|
+
campaignName: z.string().optional(),
|
|
123
|
+
clicks: z.string().optional(),
|
|
124
|
+
cpc: z.string().optional(),
|
|
125
|
+
cpm: z.string().optional(),
|
|
126
|
+
ctr: z.string().optional(),
|
|
127
|
+
dateStart: z.string().optional(),
|
|
128
|
+
dateStop: z.string().optional(),
|
|
129
|
+
impressions: z.string().optional(),
|
|
130
|
+
reach: z.string().optional(),
|
|
131
|
+
spend: z.string().optional(),
|
|
132
|
+
});
|
|
133
|
+
export const META_ADS_SUBSCRIPTION_SCHEMA = metaObject({
|
|
134
|
+
eventType: z.enum([
|
|
135
|
+
"INSIGHTS_MILESTONE_REACHED",
|
|
136
|
+
"INSIGHTS_UPDATED",
|
|
137
|
+
"OBJECT_CREATED",
|
|
138
|
+
"OBJECT_UPDATED",
|
|
139
|
+
]),
|
|
140
|
+
field: z.string().optional(),
|
|
141
|
+
filters: z
|
|
142
|
+
.object({ field: z.string(), operator: z.string(), value: z.string() })
|
|
143
|
+
.array()
|
|
144
|
+
.optional(),
|
|
145
|
+
operator: z.string().optional(),
|
|
146
|
+
status: z.string().optional(),
|
|
147
|
+
subscriptionId: z.union([META_ADS_ID_SCHEMA, z.number()]).transform(String),
|
|
148
|
+
value: z.string().optional(),
|
|
149
|
+
});
|
|
150
|
+
export const META_ADS_SUBSCRIPTION_CREATE_RESULT_SCHEMA = metaObject({
|
|
151
|
+
subscriptionId: z.union([META_ADS_ID_SCHEMA, z.number()]).transform(String),
|
|
152
|
+
});
|
|
153
|
+
export const META_ADS_MUTATION_RESULT_SCHEMA = metaObject({
|
|
154
|
+
id: z.string().optional(),
|
|
155
|
+
success: z.boolean().optional(),
|
|
156
|
+
});
|
|
157
|
+
export const META_ADS_CONVERSION_RESULT_SCHEMA = metaObject({
|
|
158
|
+
eventsReceived: z.number().int().nonnegative(),
|
|
159
|
+
fbtraceId: z.string().optional(),
|
|
160
|
+
messages: z.string().array().optional(),
|
|
161
|
+
});
|
|
162
|
+
export const META_ADS_PAGE_INFO_SCHEMA = z.object({
|
|
163
|
+
after: z.string().optional(),
|
|
164
|
+
before: z.string().optional(),
|
|
165
|
+
next: z.string().url().optional(),
|
|
166
|
+
previous: z.string().url().optional(),
|
|
167
|
+
});
|
|
168
|
+
export const META_ADS_WEBHOOK_CHANGE_SCHEMA = z.object({
|
|
169
|
+
field: z.string(),
|
|
170
|
+
value: encodableSchema,
|
|
171
|
+
});
|
|
172
|
+
export const META_ADS_WEBHOOK_ENVELOPE_SCHEMA = z.object({
|
|
173
|
+
entry: z
|
|
174
|
+
.object({
|
|
175
|
+
changes: META_ADS_WEBHOOK_CHANGE_SCHEMA.array(),
|
|
176
|
+
id: z.string(),
|
|
177
|
+
time: z.number(),
|
|
178
|
+
})
|
|
179
|
+
.array(),
|
|
180
|
+
object: z.string(),
|
|
181
|
+
});
|
package/dist/triggers.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import type { googleSheetsTriggerContracts } from "./google-sheets/index.js";
|
|
|
19
19
|
import type { hubspotTriggerContracts } from "./hubspot/index.js";
|
|
20
20
|
import type { linearTriggerContracts } from "./linear/index.js";
|
|
21
21
|
import type { millionVerifierTriggerContracts } from "./millionverifier/index.js";
|
|
22
|
+
import type { metaAdsTriggerContracts } from "./meta-ads/index.js";
|
|
22
23
|
import type { notionTriggerContracts } from "./notion/index.js";
|
|
23
24
|
import type { outlookTriggerContracts } from "./outlook/index.js";
|
|
24
25
|
import type { redditTriggerContracts } from "./reddit/index.js";
|
|
@@ -31,7 +32,7 @@ import type { vercelTriggerContracts } from "./vercel/index.js";
|
|
|
31
32
|
import type { webflowTriggerContracts } from "./webflow/index.js";
|
|
32
33
|
import type { whatsappTriggerContracts } from "./whatsapp/index.js";
|
|
33
34
|
import type { z } from "zod";
|
|
34
|
-
export type TriggerContractMap = typeof airtableTriggerContracts & typeof anthropicTriggerContracts & typeof apifyTriggerContracts & typeof axiomTriggerContracts & typeof automateTriggerContracts & typeof asanaTriggerContracts & typeof brevoTriggerContracts & typeof convexTriggerContracts & typeof discordTriggerContracts & typeof closeTriggerContracts & typeof cloudflareTriggerContracts & typeof githubTriggerContracts & typeof gmailTriggerContracts & typeof googleCalendarTriggerContracts & typeof googleDriveTriggerContracts & typeof googleFormsTriggerContracts & typeof googleMeetTriggerContracts & typeof googleSheetsTriggerContracts & typeof hubspotTriggerContracts & typeof linearTriggerContracts & typeof millionVerifierTriggerContracts & typeof notionTriggerContracts & typeof outlookTriggerContracts & typeof redditTriggerContracts & typeof resendTriggerContracts & typeof slackTriggerContracts & typeof stripeTriggerContracts & typeof teamsTriggerContracts & typeof trelloTriggerContracts & typeof vercelTriggerContracts & typeof webflowTriggerContracts & typeof whatsappTriggerContracts;
|
|
35
|
+
export type TriggerContractMap = typeof airtableTriggerContracts & typeof anthropicTriggerContracts & typeof apifyTriggerContracts & typeof axiomTriggerContracts & typeof automateTriggerContracts & typeof asanaTriggerContracts & typeof brevoTriggerContracts & typeof convexTriggerContracts & typeof discordTriggerContracts & typeof closeTriggerContracts & typeof cloudflareTriggerContracts & typeof githubTriggerContracts & typeof gmailTriggerContracts & typeof googleCalendarTriggerContracts & typeof googleDriveTriggerContracts & typeof googleFormsTriggerContracts & typeof googleMeetTriggerContracts & typeof googleSheetsTriggerContracts & typeof hubspotTriggerContracts & typeof linearTriggerContracts & typeof millionVerifierTriggerContracts & typeof metaAdsTriggerContracts & typeof notionTriggerContracts & typeof outlookTriggerContracts & typeof redditTriggerContracts & typeof resendTriggerContracts & typeof slackTriggerContracts & typeof stripeTriggerContracts & typeof teamsTriggerContracts & typeof trelloTriggerContracts & typeof vercelTriggerContracts & typeof webflowTriggerContracts & typeof whatsappTriggerContracts;
|
|
35
36
|
export type IntegrationTriggerType = keyof TriggerContractMap;
|
|
36
37
|
/** Canonical authoring configuration for one integration trigger type. */
|
|
37
38
|
export type TriggerConfig<TType extends IntegrationTriggerType> = z.input<TriggerContractMap[TType]["configSchema"]> extends Record<string, never> ? object : z.input<TriggerContractMap[TType]["configSchema"]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automate.ax/integration-contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.141.0",
|
|
4
4
|
"description": "Shared integration payload contracts and provider primitives for Automate.ax.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,9 +26,11 @@
|
|
|
26
26
|
"./asana": "./src/asana/index.ts",
|
|
27
27
|
"./brevo": "./src/brevo/index.ts",
|
|
28
28
|
"./cloudflare": "./src/cloudflare/index.ts",
|
|
29
|
+
"./meta-ads": "./src/meta-ads/index.ts",
|
|
29
30
|
"./convex": "./src/convex/index.ts",
|
|
30
31
|
"./discord": "./src/discord/index.ts",
|
|
31
32
|
"./close": "./src/close/index.ts",
|
|
33
|
+
"./closebot": "./src/closebot/index.ts",
|
|
32
34
|
"./gmail": "./src/gmail/index.ts",
|
|
33
35
|
"./google-calendar": "./src/google-calendar/index.ts",
|
|
34
36
|
"./google-drive": "./src/google-drive/index.ts",
|
|
@@ -61,7 +63,7 @@
|
|
|
61
63
|
},
|
|
62
64
|
"dependencies": {
|
|
63
65
|
"@anthropic-ai/sdk": "0.123.0",
|
|
64
|
-
"@automate.ax/codec": "0.
|
|
66
|
+
"@automate.ax/codec": "0.141.0",
|
|
65
67
|
"@cfworker/json-schema": "^4.1.1",
|
|
66
68
|
"@googleapis/calendar": "^16.0.0",
|
|
67
69
|
"@googleapis/forms": "^6.0.1",
|
|
@@ -154,6 +156,11 @@
|
|
|
154
156
|
"types": "./dist/cloudflare/index.d.ts",
|
|
155
157
|
"default": "./dist/cloudflare/index.js"
|
|
156
158
|
},
|
|
159
|
+
"./meta-ads": {
|
|
160
|
+
"bun": "./src/meta-ads/index.ts",
|
|
161
|
+
"types": "./dist/meta-ads/index.d.ts",
|
|
162
|
+
"default": "./dist/meta-ads/index.js"
|
|
163
|
+
},
|
|
157
164
|
"./convex": {
|
|
158
165
|
"bun": "./src/convex/index.ts",
|
|
159
166
|
"types": "./dist/convex/index.d.ts",
|
|
@@ -169,6 +176,11 @@
|
|
|
169
176
|
"types": "./dist/close/index.d.ts",
|
|
170
177
|
"default": "./dist/close/index.js"
|
|
171
178
|
},
|
|
179
|
+
"./closebot": {
|
|
180
|
+
"bun": "./src/closebot/index.ts",
|
|
181
|
+
"types": "./dist/closebot/index.d.ts",
|
|
182
|
+
"default": "./dist/closebot/index.js"
|
|
183
|
+
},
|
|
172
184
|
"./gmail": {
|
|
173
185
|
"bun": "./src/gmail/index.ts",
|
|
174
186
|
"types": "./dist/gmail/index.d.ts",
|