@automate.ax/integration-contracts 0.161.0 → 0.163.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/LICENSE +21 -0
- package/dist/meta-ads/events.d.ts +298 -1
- package/dist/meta-ads/events.js +402 -35
- package/dist/meta-ads/index.d.ts +1 -0
- package/dist/meta-ads/index.js +1 -0
- package/dist/meta-ads/pages.d.ts +34 -0
- package/dist/meta-ads/pages.js +79 -0
- package/dist/meta-ads/schemas.d.ts +86 -2
- package/dist/meta-ads/schemas.js +74 -1
- package/dist/outlook/graph.d.ts +20 -2
- package/dist/outlook/graph.js +26 -3
- package/package.json +5 -12
- package/src/meta-ads/events.ts +475 -34
- package/src/meta-ads/index.ts +1 -0
- package/src/meta-ads/pages.ts +98 -0
- package/src/meta-ads/schemas.ts +83 -1
- package/src/outlook/graph.ts +32 -3
package/src/meta-ads/schemas.ts
CHANGED
|
@@ -190,11 +190,18 @@ export const META_ADS_WEBHOOK_CHANGE_SCHEMA = z.object({
|
|
|
190
190
|
value: encodableSchema,
|
|
191
191
|
})
|
|
192
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Meta's shared Webhooks envelope. Field-change objects use `changes`, while
|
|
195
|
+
* Messenger and Instagram messaging use `messaging`; validate each messaging
|
|
196
|
+
* event only after classification so unrelated event kinds never reject the
|
|
197
|
+
* whole delivery.
|
|
198
|
+
*/
|
|
193
199
|
export const META_ADS_WEBHOOK_ENVELOPE_SCHEMA = z.object({
|
|
194
200
|
entry: z
|
|
195
201
|
.object({
|
|
196
|
-
changes: META_ADS_WEBHOOK_CHANGE_SCHEMA.array(),
|
|
202
|
+
changes: META_ADS_WEBHOOK_CHANGE_SCHEMA.array().optional(),
|
|
197
203
|
id: z.string(),
|
|
204
|
+
messaging: encodableSchema.array().optional(),
|
|
198
205
|
time: z.number(),
|
|
199
206
|
})
|
|
200
207
|
.array(),
|
|
@@ -204,3 +211,78 @@ export const META_ADS_WEBHOOK_ENVELOPE_SCHEMA = z.object({
|
|
|
204
211
|
export type MetaAdsWebhookEnvelope = z.output<
|
|
205
212
|
typeof META_ADS_WEBHOOK_ENVELOPE_SCHEMA
|
|
206
213
|
>
|
|
214
|
+
|
|
215
|
+
export const META_ADS_PAGE_SCHEMA = metaObject({
|
|
216
|
+
category: z.string().optional(),
|
|
217
|
+
id: META_ADS_ID_SCHEMA,
|
|
218
|
+
name: z.string(),
|
|
219
|
+
tasks: z.string().array().optional(),
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
export const META_ADS_INSTAGRAM_ACCOUNT_PAGE_SCHEMA = metaObject({
|
|
223
|
+
id: META_ADS_ID_SCHEMA,
|
|
224
|
+
instagramBusinessAccount: metaObject({
|
|
225
|
+
id: META_ADS_ID_SCHEMA,
|
|
226
|
+
username: z.string().optional(),
|
|
227
|
+
}).optional(),
|
|
228
|
+
name: z.string(),
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
export const META_ADS_PAGE_COMMENT_SCHEMA = metaObject({
|
|
232
|
+
canComment: z.boolean().optional(),
|
|
233
|
+
canReplyPrivately: z.boolean().optional(),
|
|
234
|
+
commentCount: z.number().int().nonnegative().optional(),
|
|
235
|
+
createdTime: z.string().optional(),
|
|
236
|
+
from: metaObject({ id: z.string(), name: z.string().optional() }).optional(),
|
|
237
|
+
id: META_ADS_ID_SCHEMA,
|
|
238
|
+
likeCount: z.number().int().nonnegative().optional(),
|
|
239
|
+
message: z.string().optional(),
|
|
240
|
+
parent: metaObject({ id: z.string() }).optional(),
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
export const META_ADS_INSTAGRAM_COMMENT_SCHEMA = metaObject({
|
|
244
|
+
from: metaObject({
|
|
245
|
+
id: z.string(),
|
|
246
|
+
username: z.string().optional(),
|
|
247
|
+
}).optional(),
|
|
248
|
+
hidden: z.boolean().optional(),
|
|
249
|
+
id: META_ADS_ID_SCHEMA,
|
|
250
|
+
likeCount: z.number().int().nonnegative().optional(),
|
|
251
|
+
media: metaObject({
|
|
252
|
+
id: z.string(),
|
|
253
|
+
mediaProductType: z.string().optional(),
|
|
254
|
+
}).optional(),
|
|
255
|
+
parentId: z.string().optional(),
|
|
256
|
+
text: z.string().optional(),
|
|
257
|
+
timestamp: z.string().optional(),
|
|
258
|
+
username: z.string().optional(),
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
export const META_ADS_CREATED_OBJECT_SCHEMA = metaObject({
|
|
262
|
+
id: META_ADS_ID_SCHEMA,
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
export const META_ADS_SENT_MESSAGE_SCHEMA = metaObject({
|
|
266
|
+
messageId: META_ADS_ID_SCHEMA,
|
|
267
|
+
recipientId: z.string(),
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
export const META_ADS_CONVERSATION_SCHEMA = metaObject({
|
|
271
|
+
id: META_ADS_ID_SCHEMA,
|
|
272
|
+
updatedTime: z.string().optional(),
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
const META_ADS_MESSAGE_PARTY_SCHEMA = metaObject({
|
|
276
|
+
email: z.string().optional(),
|
|
277
|
+
id: z.string(),
|
|
278
|
+
name: z.string().optional(),
|
|
279
|
+
username: z.string().optional(),
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
export const META_ADS_CONVERSATION_MESSAGE_SCHEMA = metaObject({
|
|
283
|
+
createdTime: z.string().optional(),
|
|
284
|
+
from: META_ADS_MESSAGE_PARTY_SCHEMA.optional(),
|
|
285
|
+
id: META_ADS_ID_SCHEMA,
|
|
286
|
+
message: z.string().optional(),
|
|
287
|
+
to: metaObject({ data: META_ADS_MESSAGE_PARTY_SCHEMA.array() }).optional(),
|
|
288
|
+
})
|
package/src/outlook/graph.ts
CHANGED
|
@@ -13,6 +13,30 @@ const GRAPH_ERROR_SCHEMA = z.looseObject({
|
|
|
13
13
|
.optional(),
|
|
14
14
|
})
|
|
15
15
|
|
|
16
|
+
/** Structured error returned by a rejected Microsoft Graph request. */
|
|
17
|
+
export class OutlookGraphApiError extends Error {
|
|
18
|
+
readonly retryAfter?: string
|
|
19
|
+
readonly status: number
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Creates an error from one rejected Graph response.
|
|
23
|
+
*
|
|
24
|
+
* @param message - Diagnostic message with Graph's code and message.
|
|
25
|
+
* @param options - Rejected response details.
|
|
26
|
+
* @param options.retryAfter - Raw provider retry timing, when present.
|
|
27
|
+
* @param options.status - HTTP status.
|
|
28
|
+
*/
|
|
29
|
+
constructor(
|
|
30
|
+
message: string,
|
|
31
|
+
options: { retryAfter?: string; status: number },
|
|
32
|
+
) {
|
|
33
|
+
super(message)
|
|
34
|
+
this.name = "OutlookGraphApiError"
|
|
35
|
+
this.retryAfter = options.retryAfter
|
|
36
|
+
this.status = options.status
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
16
40
|
/** Options accepted by the authenticated Outlook Graph request helper. */
|
|
17
41
|
export interface OutlookGraphRequestOptions {
|
|
18
42
|
/** JSON-serializable request body. */
|
|
@@ -29,8 +53,9 @@ export interface OutlookGraphRequestOptions {
|
|
|
29
53
|
* Creates a small authenticated Microsoft Graph client for Outlook APIs.
|
|
30
54
|
*
|
|
31
55
|
* The raw `fetch` method is an escape hatch for provider features not yet
|
|
32
|
-
* represented by a built-in action. `request` parses JSON and
|
|
33
|
-
*
|
|
56
|
+
* represented by a built-in action. `request` parses JSON and throws
|
|
57
|
+
* {@link OutlookGraphApiError} with Graph's code, message, status, and
|
|
58
|
+
* `Retry-After` hint.
|
|
34
59
|
*
|
|
35
60
|
* @param secret - Refreshed Microsoft OAuth integration secret.
|
|
36
61
|
*/
|
|
@@ -83,8 +108,12 @@ export function getOutlookGraphApi(secret: Record<string, unknown>) {
|
|
|
83
108
|
const detail = [graphError?.code, graphError?.message]
|
|
84
109
|
.filter(Boolean)
|
|
85
110
|
.join(": ")
|
|
86
|
-
throw new
|
|
111
|
+
throw new OutlookGraphApiError(
|
|
87
112
|
`Microsoft Graph request failed with ${response.status} ${response.statusText}${detail ? `: ${detail}` : ""}.`,
|
|
113
|
+
{
|
|
114
|
+
retryAfter: response.headers.get("Retry-After") ?? undefined,
|
|
115
|
+
status: response.status,
|
|
116
|
+
},
|
|
88
117
|
)
|
|
89
118
|
}
|
|
90
119
|
|