@automate.ax/integration-contracts 0.125.0 → 0.127.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.
Files changed (49) hide show
  1. package/dist/axiom/api.d.ts +60 -0
  2. package/dist/axiom/api.js +192 -0
  3. package/dist/axiom/events.d.ts +104 -0
  4. package/dist/axiom/events.js +25 -0
  5. package/dist/axiom/index.d.ts +3 -0
  6. package/dist/axiom/index.js +3 -0
  7. package/dist/axiom/schemas.d.ts +1520 -0
  8. package/dist/axiom/schemas.js +580 -0
  9. package/dist/brevo/index.d.ts +2 -2
  10. package/dist/brevo/schemas.d.ts +3 -3
  11. package/dist/close/events.d.ts +9 -9
  12. package/dist/close/schemas.d.ts +3 -3
  13. package/dist/cloudflare/schemas.d.ts +4 -4
  14. package/dist/convex/index.d.ts +8 -8
  15. package/dist/convex/schemas.d.ts +4 -4
  16. package/dist/gmail/schemas.d.ts +3 -3
  17. package/dist/google-calendar/schemas.d.ts +2 -2
  18. package/dist/google-drive/index.d.ts +3 -3
  19. package/dist/google-forms/event-schemas.d.ts +2 -2
  20. package/dist/google-forms/google-forms.d.ts +4 -4
  21. package/dist/google-forms/index.d.ts +2 -2
  22. package/dist/google-forms/schemas.d.ts +7 -7
  23. package/dist/hubspot/events.d.ts +3 -3
  24. package/dist/linear/schemas.d.ts +12 -12
  25. package/dist/notion/schemas.d.ts +6 -6
  26. package/dist/outlook/index.d.ts +9 -9
  27. package/dist/outlook/schemas.d.ts +6 -6
  28. package/dist/reddit/api.d.ts +56 -0
  29. package/dist/reddit/api.js +135 -0
  30. package/dist/reddit/events.d.ts +439 -0
  31. package/dist/reddit/events.js +53 -0
  32. package/dist/reddit/index.d.ts +3 -0
  33. package/dist/reddit/index.js +3 -0
  34. package/dist/reddit/schemas.d.ts +816 -0
  35. package/dist/reddit/schemas.js +398 -0
  36. package/dist/trello/schemas.d.ts +2 -2
  37. package/dist/triggers.d.ts +3 -1
  38. package/dist/whatsapp/index.d.ts +4 -4
  39. package/dist/whatsapp/schemas.d.ts +8 -8
  40. package/package.json +14 -2
  41. package/src/axiom/api.ts +252 -0
  42. package/src/axiom/events.ts +31 -0
  43. package/src/axiom/index.ts +3 -0
  44. package/src/axiom/schemas.ts +614 -0
  45. package/src/reddit/api.ts +183 -0
  46. package/src/reddit/events.ts +68 -0
  47. package/src/reddit/index.ts +3 -0
  48. package/src/reddit/schemas.ts +442 -0
  49. package/src/triggers.ts +4 -0
@@ -53,8 +53,8 @@ export declare const OUTLOOK_MESSAGE_CREATED_EVENT_SCHEMA: z.ZodObject<{
53
53
  internetMessageId: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
54
54
  importance: z.ZodPrefault<z.ZodEnum<{
55
55
  high: "high";
56
- normal: "normal";
57
56
  low: "low";
57
+ normal: "normal";
58
58
  }>>;
59
59
  inferenceClassification: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
60
60
  focused: "focused";
@@ -164,8 +164,8 @@ export declare const OUTLOOK_MESSAGE_UPDATED_EVENT_SCHEMA: z.ZodObject<{
164
164
  internetMessageId: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
165
165
  importance: z.ZodPrefault<z.ZodEnum<{
166
166
  high: "high";
167
- normal: "normal";
168
167
  low: "low";
168
+ normal: "normal";
169
169
  }>>;
170
170
  inferenceClassification: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
171
171
  focused: "focused";
@@ -280,8 +280,8 @@ export declare const OUTLOOK_MESSAGE_CHANGE_EVENT_SCHEMA: z.ZodDiscriminatedUnio
280
280
  internetMessageId: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
281
281
  importance: z.ZodPrefault<z.ZodEnum<{
282
282
  high: "high";
283
- normal: "normal";
284
283
  low: "low";
284
+ normal: "normal";
285
285
  }>>;
286
286
  inferenceClassification: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
287
287
  focused: "focused";
@@ -390,8 +390,8 @@ export declare const OUTLOOK_MESSAGE_CHANGE_EVENT_SCHEMA: z.ZodDiscriminatedUnio
390
390
  internetMessageId: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
391
391
  importance: z.ZodPrefault<z.ZodEnum<{
392
392
  high: "high";
393
- normal: "normal";
394
393
  low: "low";
394
+ normal: "normal";
395
395
  }>>;
396
396
  inferenceClassification: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
397
397
  focused: "focused";
@@ -506,8 +506,8 @@ export declare const outlookTriggerContracts: {
506
506
  internetMessageId: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
507
507
  importance: z.ZodPrefault<z.ZodEnum<{
508
508
  high: "high";
509
- normal: "normal";
510
509
  low: "low";
510
+ normal: "normal";
511
511
  }>>;
512
512
  inferenceClassification: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
513
513
  focused: "focused";
@@ -619,8 +619,8 @@ export declare const outlookTriggerContracts: {
619
619
  internetMessageId: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
620
620
  importance: z.ZodPrefault<z.ZodEnum<{
621
621
  high: "high";
622
- normal: "normal";
623
622
  low: "low";
623
+ normal: "normal";
624
624
  }>>;
625
625
  inferenceClassification: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
626
626
  focused: "focused";
@@ -729,8 +729,8 @@ export declare const outlookTriggerContracts: {
729
729
  internetMessageId: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
730
730
  importance: z.ZodPrefault<z.ZodEnum<{
731
731
  high: "high";
732
- normal: "normal";
733
732
  low: "low";
733
+ normal: "normal";
734
734
  }>>;
735
735
  inferenceClassification: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
736
736
  focused: "focused";
@@ -849,8 +849,8 @@ export declare const outlookTriggerContracts: {
849
849
  internetMessageId: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
850
850
  importance: z.ZodPrefault<z.ZodEnum<{
851
851
  high: "high";
852
- normal: "normal";
853
852
  low: "low";
853
+ normal: "normal";
854
854
  }>>;
855
855
  inferenceClassification: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
856
856
  focused: "focused";
@@ -965,8 +965,8 @@ export declare const outlookTriggerContracts: {
965
965
  internetMessageId: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
966
966
  importance: z.ZodPrefault<z.ZodEnum<{
967
967
  high: "high";
968
- normal: "normal";
969
968
  low: "low";
969
+ normal: "normal";
970
970
  }>>;
971
971
  inferenceClassification: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
972
972
  focused: "focused";
@@ -5,8 +5,8 @@ export declare const OUTLOOK_BODY_TYPE_SCHEMA: z.ZodEnum<{
5
5
  }>;
6
6
  export declare const OUTLOOK_IMPORTANCE_SCHEMA: z.ZodEnum<{
7
7
  high: "high";
8
- normal: "normal";
9
8
  low: "low";
9
+ normal: "normal";
10
10
  }>;
11
11
  export declare const OUTLOOK_FLAG_STATUS_SCHEMA: z.ZodEnum<{
12
12
  complete: "complete";
@@ -84,8 +84,8 @@ export declare const OUTLOOK_MESSAGE_SCHEMA: z.ZodObject<{
84
84
  internetMessageId: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
85
85
  importance: z.ZodPrefault<z.ZodEnum<{
86
86
  high: "high";
87
- normal: "normal";
88
87
  low: "low";
88
+ normal: "normal";
89
89
  }>>;
90
90
  inferenceClassification: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
91
91
  focused: "focused";
@@ -197,8 +197,8 @@ export declare const GRAPH_MESSAGE_SCHEMA: z.ZodPipe<z.ZodObject<{
197
197
  id: z.ZodString;
198
198
  importance: z.ZodOptional<z.ZodEnum<{
199
199
  high: "high";
200
- normal: "normal";
201
200
  low: "low";
201
+ normal: "normal";
202
202
  }>>;
203
203
  inferenceClassification: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
204
204
  focused: "focused";
@@ -242,7 +242,7 @@ export declare const GRAPH_MESSAGE_SCHEMA: z.ZodPipe<z.ZodObject<{
242
242
  hasAttachments: boolean;
243
243
  messageId: string;
244
244
  internetMessageId: string | undefined;
245
- importance: "high" | "normal" | "low";
245
+ importance: "high" | "low" | "normal";
246
246
  inferenceClassification: "focused" | "other" | undefined;
247
247
  isDraft: boolean;
248
248
  isRead: boolean;
@@ -331,7 +331,7 @@ export declare const GRAPH_MESSAGE_SCHEMA: z.ZodPipe<z.ZodObject<{
331
331
  };
332
332
  } | null | undefined;
333
333
  hasAttachments?: boolean | undefined;
334
- importance?: "high" | "normal" | "low" | undefined;
334
+ importance?: "high" | "low" | "normal" | undefined;
335
335
  inferenceClassification?: "focused" | "other" | null | undefined;
336
336
  internetMessageId?: string | null | undefined;
337
337
  isDraft?: boolean | undefined;
@@ -377,7 +377,7 @@ export declare function normalizeOutlookMessage(payload: unknown): {
377
377
  hasAttachments: boolean;
378
378
  messageId: string;
379
379
  internetMessageId: string | undefined;
380
- importance: "high" | "normal" | "low";
380
+ importance: "high" | "low" | "normal";
381
381
  inferenceClassification: "focused" | "other" | undefined;
382
382
  isDraft: boolean;
383
383
  isRead: boolean;
@@ -0,0 +1,56 @@
1
+ import * as z from "zod";
2
+ export declare const REDDIT_OAUTH_SECRET_SCHEMA: z.ZodObject<{
3
+ accessToken: z.ZodString;
4
+ expiresAt: z.ZodNumber;
5
+ refreshToken: z.ZodString;
6
+ tokenType: z.ZodString;
7
+ userAgent: z.ZodString;
8
+ }, z.core.$strip>;
9
+ export declare const REDDIT_ERROR_TUPLE_SCHEMA: z.ZodTuple<[z.ZodString, z.ZodString, z.ZodNullable<z.ZodString>], null>;
10
+ export declare const REDDIT_JSON_STATUS_SCHEMA: z.ZodObject<{
11
+ json: z.ZodObject<{
12
+ errors: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString, z.ZodNullable<z.ZodString>], null>>;
13
+ }, z.core.$strip>;
14
+ }, z.core.$strip>;
15
+ export interface RedditRequestOptions<TSchema extends z.ZodType> {
16
+ body?: Record<string, boolean | number | string | undefined>;
17
+ method?: "DELETE" | "GET" | "POST" | "PUT";
18
+ query?: Record<string, boolean | number | string | readonly string[] | null | undefined>;
19
+ responseSchema: TSchema;
20
+ }
21
+ /** Error returned by a rejected Reddit Data API request. */
22
+ export declare class RedditApiError extends Error {
23
+ readonly details: {
24
+ error?: number;
25
+ message?: string;
26
+ reason?: string;
27
+ } | {
28
+ errors: [string, string, null | string][];
29
+ } | {
30
+ response: string;
31
+ };
32
+ readonly retryAfter?: string;
33
+ readonly status: number;
34
+ /**
35
+ * Creates an error from a rejected Reddit response.
36
+ *
37
+ * @param status - HTTP response status.
38
+ * @param details - Parsed Reddit failure details.
39
+ * @param retryAfter - Provider retry delay in seconds, when present.
40
+ */
41
+ constructor(status: number, details: RedditApiError["details"], retryAfter?: string);
42
+ }
43
+ /**
44
+ * Creates an authenticated Reddit Data API client.
45
+ *
46
+ * @param secret - Stored Reddit OAuth credentials and registered User-Agent.
47
+ */
48
+ export declare function getRedditApi(secret: unknown): {
49
+ /**
50
+ * Sends one request below Reddit's OAuth API origin.
51
+ *
52
+ * @param path - Relative Reddit API path.
53
+ * @param options - Request method, parameters, and response contract.
54
+ */
55
+ request<TSchema extends z.ZodType>(path: string, options: RedditRequestOptions<TSchema>): Promise<z.output<TSchema>>;
56
+ };
@@ -0,0 +1,135 @@
1
+ import * as z from "zod";
2
+ const REDDIT_API_ORIGIN = "https://oauth.reddit.com/";
3
+ const REDDIT_API_URL = new URL(REDDIT_API_ORIGIN);
4
+ export const REDDIT_OAUTH_SECRET_SCHEMA = z.object({
5
+ accessToken: z.string().min(1),
6
+ expiresAt: z.number().int().positive(),
7
+ refreshToken: z.string().min(1),
8
+ tokenType: z.string().min(1),
9
+ userAgent: z.string().min(1),
10
+ });
11
+ const REDDIT_API_ERROR_SCHEMA = z.looseObject({
12
+ error: z.number().int().optional(),
13
+ message: z.string().optional(),
14
+ reason: z.string().optional(),
15
+ });
16
+ export const REDDIT_ERROR_TUPLE_SCHEMA = z.tuple([
17
+ z.string(),
18
+ z.string(),
19
+ z.string().nullable(),
20
+ ]);
21
+ const REDDIT_JSON_ERRORS_SCHEMA = z.looseObject({
22
+ json: z.object({
23
+ errors: REDDIT_ERROR_TUPLE_SCHEMA.array(),
24
+ }),
25
+ });
26
+ export const REDDIT_JSON_STATUS_SCHEMA = z.object({
27
+ json: z.object({ errors: REDDIT_ERROR_TUPLE_SCHEMA.array() }),
28
+ });
29
+ /** Error returned by a rejected Reddit Data API request. */
30
+ export class RedditApiError extends Error {
31
+ details;
32
+ retryAfter;
33
+ status;
34
+ /**
35
+ * Creates an error from a rejected Reddit response.
36
+ *
37
+ * @param status - HTTP response status.
38
+ * @param details - Parsed Reddit failure details.
39
+ * @param retryAfter - Provider retry delay in seconds, when present.
40
+ */
41
+ constructor(status, details, retryAfter) {
42
+ const jsonError = "errors" in details ? details.errors[0]?.[1] : undefined;
43
+ super(("message" in details
44
+ ? (details.message ?? details.reason)
45
+ : undefined) ??
46
+ jsonError ??
47
+ `Reddit API request failed (${status}).`);
48
+ this.name = "RedditApiError";
49
+ this.details = details;
50
+ this.retryAfter = retryAfter;
51
+ this.status = status;
52
+ }
53
+ }
54
+ /**
55
+ * Creates an authenticated Reddit Data API client.
56
+ *
57
+ * @param secret - Stored Reddit OAuth credentials and registered User-Agent.
58
+ */
59
+ export function getRedditApi(secret) {
60
+ const credentials = REDDIT_OAUTH_SECRET_SCHEMA.parse(secret);
61
+ return {
62
+ /**
63
+ * Sends one request below Reddit's OAuth API origin.
64
+ *
65
+ * @param path - Relative Reddit API path.
66
+ * @param options - Request method, parameters, and response contract.
67
+ */
68
+ async request(path, options) {
69
+ const normalizedPath = path.replace(/^\/+/, "");
70
+ if (!normalizedPath ||
71
+ normalizedPath.includes("://") ||
72
+ normalizedPath.includes("\\")) {
73
+ throw new TypeError("Reddit API paths must be relative.");
74
+ }
75
+ const url = new URL(normalizedPath, REDDIT_API_ORIGIN);
76
+ if (url.origin !== REDDIT_API_URL.origin) {
77
+ throw new TypeError("Reddit API paths must remain on oauth.reddit.com.");
78
+ }
79
+ url.searchParams.set("raw_json", "1");
80
+ for (const [key, value] of Object.entries(options.query ?? {})) {
81
+ if (value == null)
82
+ continue;
83
+ url.searchParams.set(key, Array.isArray(value) ? value.join(",") : String(value));
84
+ }
85
+ const headers = new Headers({
86
+ Accept: "application/json",
87
+ Authorization: `${credentials.tokenType} ${credentials.accessToken}`,
88
+ "User-Agent": credentials.userAgent,
89
+ });
90
+ const body = options.body
91
+ ? new URLSearchParams(Object.entries(options.body).flatMap(([key, value]) => value === undefined
92
+ ? []
93
+ : [[key, String(value)]]))
94
+ : undefined;
95
+ if (body) {
96
+ headers.set("Content-Type", "application/x-www-form-urlencoded");
97
+ }
98
+ const response = await fetch(url, {
99
+ body,
100
+ headers,
101
+ method: options.method ?? "GET",
102
+ });
103
+ const text = await response.text();
104
+ const parsed = parseJson(text);
105
+ const jsonErrors = REDDIT_JSON_ERRORS_SCHEMA.safeParse(parsed);
106
+ const retryAfter = response.headers.get("Retry-After") ??
107
+ response.headers.get("X-Ratelimit-Reset") ??
108
+ undefined;
109
+ if (jsonErrors.success && jsonErrors.data.json.errors.length > 0) {
110
+ throw new RedditApiError(response.ok ? 400 : response.status, { errors: jsonErrors.data.json.errors }, retryAfter);
111
+ }
112
+ if (!response.ok) {
113
+ const error = REDDIT_API_ERROR_SCHEMA.safeParse(parsed);
114
+ throw new RedditApiError(response.status, error.success ? error.data : { response: text }, retryAfter);
115
+ }
116
+ const result = options.responseSchema.safeParse(parsed);
117
+ if (!result.success) {
118
+ throw new RedditApiError(response.status, { response: text });
119
+ }
120
+ return result.data;
121
+ },
122
+ };
123
+ }
124
+ /** Parses a provider body while preserving non-JSON failure text. */
125
+ /** @param value - Raw provider response body. */
126
+ function parseJson(value) {
127
+ if (!value)
128
+ return undefined;
129
+ try {
130
+ return JSON.parse(value);
131
+ }
132
+ catch {
133
+ return value;
134
+ }
135
+ }