@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.
@@ -170,15 +170,99 @@ export declare const META_ADS_WEBHOOK_CHANGE_SCHEMA: z.ZodObject<{
170
170
  field: z.ZodString;
171
171
  value: z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
172
172
  }, z.core.$strip>;
173
+ /**
174
+ * Meta's shared Webhooks envelope. Field-change objects use `changes`, while
175
+ * Messenger and Instagram messaging use `messaging`; validate each messaging
176
+ * event only after classification so unrelated event kinds never reject the
177
+ * whole delivery.
178
+ */
173
179
  export declare const META_ADS_WEBHOOK_ENVELOPE_SCHEMA: z.ZodObject<{
174
180
  entry: z.ZodArray<z.ZodObject<{
175
- changes: z.ZodArray<z.ZodObject<{
181
+ changes: z.ZodOptional<z.ZodArray<z.ZodObject<{
176
182
  field: z.ZodString;
177
183
  value: z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
178
- }, z.core.$strip>>;
184
+ }, z.core.$strip>>>;
179
185
  id: z.ZodString;
186
+ messaging: z.ZodOptional<z.ZodArray<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
180
187
  time: z.ZodNumber;
181
188
  }, z.core.$strip>>;
182
189
  object: z.ZodString;
183
190
  }, z.core.$strip>;
184
191
  export type MetaAdsWebhookEnvelope = z.output<typeof META_ADS_WEBHOOK_ENVELOPE_SCHEMA>;
192
+ export declare const META_ADS_PAGE_SCHEMA: z.ZodObject<{
193
+ category: z.ZodOptional<z.ZodString>;
194
+ id: z.ZodString;
195
+ name: z.ZodString;
196
+ tasks: z.ZodOptional<z.ZodArray<z.ZodString>>;
197
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
198
+ export declare const META_ADS_INSTAGRAM_ACCOUNT_PAGE_SCHEMA: z.ZodObject<{
199
+ id: z.ZodString;
200
+ instagramBusinessAccount: z.ZodOptional<z.ZodObject<{
201
+ id: z.ZodString;
202
+ username: z.ZodOptional<z.ZodString>;
203
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>>;
204
+ name: z.ZodString;
205
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
206
+ export declare const META_ADS_PAGE_COMMENT_SCHEMA: z.ZodObject<{
207
+ canComment: z.ZodOptional<z.ZodBoolean>;
208
+ canReplyPrivately: z.ZodOptional<z.ZodBoolean>;
209
+ commentCount: z.ZodOptional<z.ZodNumber>;
210
+ createdTime: z.ZodOptional<z.ZodString>;
211
+ from: z.ZodOptional<z.ZodObject<{
212
+ id: z.ZodString;
213
+ name: z.ZodOptional<z.ZodString>;
214
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>>;
215
+ id: z.ZodString;
216
+ likeCount: z.ZodOptional<z.ZodNumber>;
217
+ message: z.ZodOptional<z.ZodString>;
218
+ parent: z.ZodOptional<z.ZodObject<{
219
+ id: z.ZodString;
220
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>>;
221
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
222
+ export declare const META_ADS_INSTAGRAM_COMMENT_SCHEMA: z.ZodObject<{
223
+ from: z.ZodOptional<z.ZodObject<{
224
+ id: z.ZodString;
225
+ username: z.ZodOptional<z.ZodString>;
226
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>>;
227
+ hidden: z.ZodOptional<z.ZodBoolean>;
228
+ id: z.ZodString;
229
+ likeCount: z.ZodOptional<z.ZodNumber>;
230
+ media: z.ZodOptional<z.ZodObject<{
231
+ id: z.ZodString;
232
+ mediaProductType: z.ZodOptional<z.ZodString>;
233
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>>;
234
+ parentId: z.ZodOptional<z.ZodString>;
235
+ text: z.ZodOptional<z.ZodString>;
236
+ timestamp: z.ZodOptional<z.ZodString>;
237
+ username: z.ZodOptional<z.ZodString>;
238
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
239
+ export declare const META_ADS_CREATED_OBJECT_SCHEMA: z.ZodObject<{
240
+ id: z.ZodString;
241
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
242
+ export declare const META_ADS_SENT_MESSAGE_SCHEMA: z.ZodObject<{
243
+ messageId: z.ZodString;
244
+ recipientId: z.ZodString;
245
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
246
+ export declare const META_ADS_CONVERSATION_SCHEMA: z.ZodObject<{
247
+ id: z.ZodString;
248
+ updatedTime: z.ZodOptional<z.ZodString>;
249
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
250
+ export declare const META_ADS_CONVERSATION_MESSAGE_SCHEMA: z.ZodObject<{
251
+ createdTime: z.ZodOptional<z.ZodString>;
252
+ from: z.ZodOptional<z.ZodObject<{
253
+ email: z.ZodOptional<z.ZodString>;
254
+ id: z.ZodString;
255
+ name: z.ZodOptional<z.ZodString>;
256
+ username: z.ZodOptional<z.ZodString>;
257
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>>;
258
+ id: z.ZodString;
259
+ message: z.ZodOptional<z.ZodString>;
260
+ to: z.ZodOptional<z.ZodObject<{
261
+ data: z.ZodArray<z.ZodObject<{
262
+ email: z.ZodOptional<z.ZodString>;
263
+ id: z.ZodString;
264
+ name: z.ZodOptional<z.ZodString>;
265
+ username: z.ZodOptional<z.ZodString>;
266
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>>;
267
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>>;
268
+ }, z.core.$catchall<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>>;
@@ -169,13 +169,86 @@ export const META_ADS_WEBHOOK_CHANGE_SCHEMA = z.object({
169
169
  field: z.string(),
170
170
  value: encodableSchema,
171
171
  });
172
+ /**
173
+ * Meta's shared Webhooks envelope. Field-change objects use `changes`, while
174
+ * Messenger and Instagram messaging use `messaging`; validate each messaging
175
+ * event only after classification so unrelated event kinds never reject the
176
+ * whole delivery.
177
+ */
172
178
  export const META_ADS_WEBHOOK_ENVELOPE_SCHEMA = z.object({
173
179
  entry: z
174
180
  .object({
175
- changes: META_ADS_WEBHOOK_CHANGE_SCHEMA.array(),
181
+ changes: META_ADS_WEBHOOK_CHANGE_SCHEMA.array().optional(),
176
182
  id: z.string(),
183
+ messaging: encodableSchema.array().optional(),
177
184
  time: z.number(),
178
185
  })
179
186
  .array(),
180
187
  object: z.string(),
181
188
  });
189
+ export const META_ADS_PAGE_SCHEMA = metaObject({
190
+ category: z.string().optional(),
191
+ id: META_ADS_ID_SCHEMA,
192
+ name: z.string(),
193
+ tasks: z.string().array().optional(),
194
+ });
195
+ export const META_ADS_INSTAGRAM_ACCOUNT_PAGE_SCHEMA = metaObject({
196
+ id: META_ADS_ID_SCHEMA,
197
+ instagramBusinessAccount: metaObject({
198
+ id: META_ADS_ID_SCHEMA,
199
+ username: z.string().optional(),
200
+ }).optional(),
201
+ name: z.string(),
202
+ });
203
+ export const META_ADS_PAGE_COMMENT_SCHEMA = metaObject({
204
+ canComment: z.boolean().optional(),
205
+ canReplyPrivately: z.boolean().optional(),
206
+ commentCount: z.number().int().nonnegative().optional(),
207
+ createdTime: z.string().optional(),
208
+ from: metaObject({ id: z.string(), name: z.string().optional() }).optional(),
209
+ id: META_ADS_ID_SCHEMA,
210
+ likeCount: z.number().int().nonnegative().optional(),
211
+ message: z.string().optional(),
212
+ parent: metaObject({ id: z.string() }).optional(),
213
+ });
214
+ export const META_ADS_INSTAGRAM_COMMENT_SCHEMA = metaObject({
215
+ from: metaObject({
216
+ id: z.string(),
217
+ username: z.string().optional(),
218
+ }).optional(),
219
+ hidden: z.boolean().optional(),
220
+ id: META_ADS_ID_SCHEMA,
221
+ likeCount: z.number().int().nonnegative().optional(),
222
+ media: metaObject({
223
+ id: z.string(),
224
+ mediaProductType: z.string().optional(),
225
+ }).optional(),
226
+ parentId: z.string().optional(),
227
+ text: z.string().optional(),
228
+ timestamp: z.string().optional(),
229
+ username: z.string().optional(),
230
+ });
231
+ export const META_ADS_CREATED_OBJECT_SCHEMA = metaObject({
232
+ id: META_ADS_ID_SCHEMA,
233
+ });
234
+ export const META_ADS_SENT_MESSAGE_SCHEMA = metaObject({
235
+ messageId: META_ADS_ID_SCHEMA,
236
+ recipientId: z.string(),
237
+ });
238
+ export const META_ADS_CONVERSATION_SCHEMA = metaObject({
239
+ id: META_ADS_ID_SCHEMA,
240
+ updatedTime: z.string().optional(),
241
+ });
242
+ const META_ADS_MESSAGE_PARTY_SCHEMA = metaObject({
243
+ email: z.string().optional(),
244
+ id: z.string(),
245
+ name: z.string().optional(),
246
+ username: z.string().optional(),
247
+ });
248
+ export const META_ADS_CONVERSATION_MESSAGE_SCHEMA = metaObject({
249
+ createdTime: z.string().optional(),
250
+ from: META_ADS_MESSAGE_PARTY_SCHEMA.optional(),
251
+ id: META_ADS_ID_SCHEMA,
252
+ message: z.string().optional(),
253
+ to: metaObject({ data: META_ADS_MESSAGE_PARTY_SCHEMA.array() }).optional(),
254
+ });
@@ -1,4 +1,21 @@
1
1
  import * as z from "zod";
2
+ /** Structured error returned by a rejected Microsoft Graph request. */
3
+ export declare class OutlookGraphApiError extends Error {
4
+ readonly retryAfter?: string;
5
+ readonly status: number;
6
+ /**
7
+ * Creates an error from one rejected Graph response.
8
+ *
9
+ * @param message - Diagnostic message with Graph's code and message.
10
+ * @param options - Rejected response details.
11
+ * @param options.retryAfter - Raw provider retry timing, when present.
12
+ * @param options.status - HTTP status.
13
+ */
14
+ constructor(message: string, options: {
15
+ retryAfter?: string;
16
+ status: number;
17
+ });
18
+ }
2
19
  /** Options accepted by the authenticated Outlook Graph request helper. */
3
20
  export interface OutlookGraphRequestOptions {
4
21
  /** JSON-serializable request body. */
@@ -12,8 +29,9 @@ export interface OutlookGraphRequestOptions {
12
29
  * Creates a small authenticated Microsoft Graph client for Outlook APIs.
13
30
  *
14
31
  * The raw `fetch` method is an escape hatch for provider features not yet
15
- * represented by a built-in action. `request` parses JSON and reports Graph
16
- * errors with their provider code and message.
32
+ * represented by a built-in action. `request` parses JSON and throws
33
+ * {@link OutlookGraphApiError} with Graph's code, message, status, and
34
+ * `Retry-After` hint.
17
35
  *
18
36
  * @param secret - Refreshed Microsoft OAuth integration secret.
19
37
  */
@@ -11,12 +11,32 @@ const GRAPH_ERROR_SCHEMA = z.looseObject({
11
11
  })
12
12
  .optional(),
13
13
  });
14
+ /** Structured error returned by a rejected Microsoft Graph request. */
15
+ export class OutlookGraphApiError extends Error {
16
+ retryAfter;
17
+ status;
18
+ /**
19
+ * Creates an error from one rejected Graph response.
20
+ *
21
+ * @param message - Diagnostic message with Graph's code and message.
22
+ * @param options - Rejected response details.
23
+ * @param options.retryAfter - Raw provider retry timing, when present.
24
+ * @param options.status - HTTP status.
25
+ */
26
+ constructor(message, options) {
27
+ super(message);
28
+ this.name = "OutlookGraphApiError";
29
+ this.retryAfter = options.retryAfter;
30
+ this.status = options.status;
31
+ }
32
+ }
14
33
  /**
15
34
  * Creates a small authenticated Microsoft Graph client for Outlook APIs.
16
35
  *
17
36
  * The raw `fetch` method is an escape hatch for provider features not yet
18
- * represented by a built-in action. `request` parses JSON and reports Graph
19
- * errors with their provider code and message.
37
+ * represented by a built-in action. `request` parses JSON and throws
38
+ * {@link OutlookGraphApiError} with Graph's code, message, status, and
39
+ * `Retry-After` hint.
20
40
  *
21
41
  * @param secret - Refreshed Microsoft OAuth integration secret.
22
42
  */
@@ -61,7 +81,10 @@ export function getOutlookGraphApi(secret) {
61
81
  const detail = [graphError?.code, graphError?.message]
62
82
  .filter(Boolean)
63
83
  .join(": ");
64
- throw new Error(`Microsoft Graph request failed with ${response.status} ${response.statusText}${detail ? `: ${detail}` : ""}.`);
84
+ throw new OutlookGraphApiError(`Microsoft Graph request failed with ${response.status} ${response.statusText}${detail ? `: ${detail}` : ""}.`, {
85
+ retryAfter: response.headers.get("Retry-After") ?? undefined,
86
+ status: response.status,
87
+ });
65
88
  }
66
89
  if (response.status === 202 || response.status === 204)
67
90
  return undefined;
package/package.json CHANGED
@@ -1,17 +1,9 @@
1
1
  {
2
2
  "name": "@automate.ax/integration-contracts",
3
- "version": "0.161.0",
3
+ "version": "0.163.0",
4
4
  "description": "Shared integration payload contracts and provider primitives for Automate.ax.",
5
5
  "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/zachsents/automate.ax.git",
9
- "directory": "packages/integration-contracts"
10
- },
11
- "homepage": "https://automate.ax",
12
- "bugs": {
13
- "url": "https://github.com/zachsents/automate.ax/issues"
14
- },
6
+ "homepage": "https://docs.automate.ax",
15
7
  "type": "module",
16
8
  "publishConfig": {
17
9
  "access": "public"
@@ -73,7 +65,7 @@
73
65
  },
74
66
  "dependencies": {
75
67
  "@anthropic-ai/sdk": "0.123.0",
76
- "@automate.ax/codec": "0.161.0",
68
+ "@automate.ax/codec": "0.163.0",
77
69
  "@cfworker/json-schema": "^4.1.1",
78
70
  "@googleapis/calendar": "^16.0.0",
79
71
  "@googleapis/forms": "^6.0.1",
@@ -122,7 +114,8 @@
122
114
  },
123
115
  "files": [
124
116
  "dist",
125
- "src"
117
+ "src",
118
+ "LICENSE"
126
119
  ],
127
120
  "main": "./dist/index.js",
128
121
  "module": "./dist/index.js",