@automate.ax/integration-contracts 0.141.0 → 0.143.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/clickup/api.d.ts +76 -0
- package/dist/clickup/api.js +195 -0
- package/dist/clickup/index.d.ts +1921 -0
- package/dist/clickup/index.js +91 -0
- package/dist/clickup/schemas.d.ts +505 -0
- package/dist/clickup/schemas.js +286 -0
- package/dist/closebot/schemas.d.ts +10 -2
- package/dist/closebot/schemas.js +13 -3
- package/dist/google-ads/api.d.ts +40 -0
- package/dist/google-ads/api.js +109 -0
- package/dist/google-ads/events.d.ts +1155 -0
- package/dist/google-ads/events.js +96 -0
- package/dist/google-ads/index.d.ts +3 -0
- package/dist/google-ads/index.js +3 -0
- package/dist/google-ads/schemas.d.ts +756 -0
- package/dist/google-ads/schemas.js +249 -0
- package/dist/google-drive/index.d.ts +6 -6
- package/dist/linear/schemas.d.ts +3 -3
- package/dist/notion/schemas.d.ts +84 -84
- package/dist/teams/index.d.ts +20 -20
- package/dist/teams/schemas.d.ts +5 -5
- package/dist/triggers.d.ts +3 -1
- package/package.json +15 -3
- package/src/clickup/api.ts +270 -0
- package/src/clickup/index.ts +108 -0
- package/src/clickup/schemas.ts +324 -0
- package/src/closebot/schemas.ts +17 -3
- package/src/google-ads/api.ts +151 -0
- package/src/google-ads/events.ts +131 -0
- package/src/google-ads/index.ts +3 -0
- package/src/google-ads/schemas.ts +270 -0
- package/src/triggers.ts +4 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export const CLICKUP_USER_SCHEMA = z.object({
|
|
3
|
+
color: z.string().nullable().optional(),
|
|
4
|
+
email: z.email().optional(),
|
|
5
|
+
id: z.number().int(),
|
|
6
|
+
initials: z.string().optional(),
|
|
7
|
+
profilePicture: z.url().nullable().optional(),
|
|
8
|
+
role: z.number().int().optional(),
|
|
9
|
+
username: z.string(),
|
|
10
|
+
});
|
|
11
|
+
export const CLICKUP_WORKSPACE_SCHEMA = z.object({
|
|
12
|
+
avatar: z.url().nullable().optional(),
|
|
13
|
+
color: z.string().nullable().optional(),
|
|
14
|
+
id: z.string(),
|
|
15
|
+
members: z.object({ user: CLICKUP_USER_SCHEMA }).array().prefault([]),
|
|
16
|
+
name: z.string(),
|
|
17
|
+
});
|
|
18
|
+
export const CLICKUP_STATUS_SCHEMA = z.object({
|
|
19
|
+
color: z.string().optional(),
|
|
20
|
+
orderindex: z.number().optional(),
|
|
21
|
+
status: z.string(),
|
|
22
|
+
type: z.string().optional(),
|
|
23
|
+
});
|
|
24
|
+
export const CLICKUP_SPACE_SCHEMA = z.object({
|
|
25
|
+
archived: z.boolean().prefault(false),
|
|
26
|
+
color: z.string().nullable().optional(),
|
|
27
|
+
id: z.string(),
|
|
28
|
+
multipleAssignees: z.boolean().optional(),
|
|
29
|
+
name: z.string(),
|
|
30
|
+
private: z.boolean().optional(),
|
|
31
|
+
statuses: CLICKUP_STATUS_SCHEMA.array().prefault([]),
|
|
32
|
+
});
|
|
33
|
+
export const CLICKUP_FOLDER_SCHEMA = z.object({
|
|
34
|
+
folders: z.lazy(() => CLICKUP_FOLDER_SCHEMA.array()).prefault([]),
|
|
35
|
+
hidden: z.boolean().optional(),
|
|
36
|
+
id: z.string(),
|
|
37
|
+
lists: z.lazy(() => CLICKUP_LIST_SCHEMA.array()).prefault([]),
|
|
38
|
+
name: z.string(),
|
|
39
|
+
orderindex: z.number().optional(),
|
|
40
|
+
overrideStatuses: z.boolean().optional(),
|
|
41
|
+
parentFolder: z.string().optional(),
|
|
42
|
+
space: z.object({ id: z.string(), name: z.string().optional() }).optional(),
|
|
43
|
+
taskCount: z
|
|
44
|
+
.string()
|
|
45
|
+
.nullable()
|
|
46
|
+
.optional()
|
|
47
|
+
.transform((value) => value ?? undefined),
|
|
48
|
+
});
|
|
49
|
+
export const CLICKUP_LIST_SCHEMA = z.object({
|
|
50
|
+
archived: z.boolean().optional(),
|
|
51
|
+
content: z.string().optional(),
|
|
52
|
+
dueDate: z.string().nullable().optional(),
|
|
53
|
+
dueDateTime: z.boolean().optional(),
|
|
54
|
+
folder: z
|
|
55
|
+
.object({
|
|
56
|
+
hidden: z.boolean().optional(),
|
|
57
|
+
id: z.string(),
|
|
58
|
+
name: z.string().optional(),
|
|
59
|
+
})
|
|
60
|
+
.optional(),
|
|
61
|
+
id: z.string(),
|
|
62
|
+
name: z.string(),
|
|
63
|
+
orderindex: z.number().optional(),
|
|
64
|
+
space: z.object({ id: z.string(), name: z.string().optional() }).optional(),
|
|
65
|
+
statuses: CLICKUP_STATUS_SCHEMA.array().prefault([]),
|
|
66
|
+
taskCount: z.string().nullable().optional(),
|
|
67
|
+
});
|
|
68
|
+
export const CLICKUP_CUSTOM_FIELD_SCHEMA = z.object({
|
|
69
|
+
id: z.string(),
|
|
70
|
+
name: z.string(),
|
|
71
|
+
required: z.boolean().optional(),
|
|
72
|
+
type: z.string(),
|
|
73
|
+
typeConfig: z.json().optional(),
|
|
74
|
+
value: z.json().optional(),
|
|
75
|
+
});
|
|
76
|
+
const CLICKUP_TASK_BASE_SCHEMA = z.object({
|
|
77
|
+
archived: z.boolean().prefault(false),
|
|
78
|
+
assignees: CLICKUP_USER_SCHEMA.array().prefault([]),
|
|
79
|
+
creator: CLICKUP_USER_SCHEMA.optional(),
|
|
80
|
+
customFields: CLICKUP_CUSTOM_FIELD_SCHEMA.array().prefault([]),
|
|
81
|
+
dateClosed: z.string().nullable().optional(),
|
|
82
|
+
dateCreated: z.string().optional(),
|
|
83
|
+
dateDone: z.string().nullable().optional(),
|
|
84
|
+
dateUpdated: z.string().optional(),
|
|
85
|
+
description: z.string().optional(),
|
|
86
|
+
dueDate: z.string().nullable().optional(),
|
|
87
|
+
id: z.string(),
|
|
88
|
+
list: z.object({ id: z.string(), name: z.string().optional() }).optional(),
|
|
89
|
+
name: z.string(),
|
|
90
|
+
parent: z.string().nullable().optional(),
|
|
91
|
+
priority: z
|
|
92
|
+
.object({
|
|
93
|
+
color: z.string().optional(),
|
|
94
|
+
id: z.string().optional(),
|
|
95
|
+
orderindex: z.string().optional(),
|
|
96
|
+
priority: z.string(),
|
|
97
|
+
})
|
|
98
|
+
.nullable()
|
|
99
|
+
.optional(),
|
|
100
|
+
space: z.object({ id: z.string() }).optional(),
|
|
101
|
+
startDate: z.string().nullable().optional(),
|
|
102
|
+
status: CLICKUP_STATUS_SCHEMA.optional(),
|
|
103
|
+
tags: z
|
|
104
|
+
.object({
|
|
105
|
+
name: z.string(),
|
|
106
|
+
tagBg: z.string().optional(),
|
|
107
|
+
tagFg: z.string().optional(),
|
|
108
|
+
})
|
|
109
|
+
.array()
|
|
110
|
+
.prefault([]),
|
|
111
|
+
textContent: z.string().optional(),
|
|
112
|
+
timeEstimate: z.coerce.number().nullable().optional(),
|
|
113
|
+
timeSpent: z.number().optional(),
|
|
114
|
+
url: z.url().optional(),
|
|
115
|
+
watchers: CLICKUP_USER_SCHEMA.array().prefault([]),
|
|
116
|
+
});
|
|
117
|
+
export const CLICKUP_TASK_SCHEMA = CLICKUP_TASK_BASE_SCHEMA.extend({
|
|
118
|
+
subtasks: z.lazy(() => CLICKUP_TASK_SCHEMA.array()).prefault([]),
|
|
119
|
+
});
|
|
120
|
+
export const CLICKUP_COMMENT_SCHEMA = z.object({
|
|
121
|
+
assignee: CLICKUP_USER_SCHEMA.optional(),
|
|
122
|
+
comment: z.json().array().prefault([]),
|
|
123
|
+
commentText: z.string().optional(),
|
|
124
|
+
date: z.string(),
|
|
125
|
+
id: z.string(),
|
|
126
|
+
resolved: z.boolean().optional(),
|
|
127
|
+
user: CLICKUP_USER_SCHEMA,
|
|
128
|
+
});
|
|
129
|
+
export const CLICKUP_TIME_ENTRY_SCHEMA = z.object({
|
|
130
|
+
at: z.coerce.string().optional(),
|
|
131
|
+
billable: z.boolean().optional(),
|
|
132
|
+
description: z.string().optional(),
|
|
133
|
+
duration: z.coerce.string(),
|
|
134
|
+
end: z.coerce.string().optional(),
|
|
135
|
+
id: z.string(),
|
|
136
|
+
start: z.coerce.string(),
|
|
137
|
+
task: z
|
|
138
|
+
.object({ id: z.string(), name: z.string().optional() })
|
|
139
|
+
.nullable()
|
|
140
|
+
.optional(),
|
|
141
|
+
source: z.string().optional(),
|
|
142
|
+
tags: z.json().array().prefault([]),
|
|
143
|
+
taskLocation: z
|
|
144
|
+
.object({
|
|
145
|
+
folderId: z.union([z.number(), z.string()]).transform(String),
|
|
146
|
+
folderName: z.string(),
|
|
147
|
+
listId: z.union([z.number(), z.string()]).transform(String),
|
|
148
|
+
listName: z.string(),
|
|
149
|
+
spaceId: z.union([z.number(), z.string()]).transform(String),
|
|
150
|
+
spaceName: z.string(),
|
|
151
|
+
})
|
|
152
|
+
.optional(),
|
|
153
|
+
taskTags: z
|
|
154
|
+
.object({
|
|
155
|
+
creator: z.number().int().optional(),
|
|
156
|
+
name: z.string(),
|
|
157
|
+
tagBg: z.string().optional(),
|
|
158
|
+
tagFg: z.string().optional(),
|
|
159
|
+
})
|
|
160
|
+
.array()
|
|
161
|
+
.prefault([]),
|
|
162
|
+
taskUrl: z.url().optional(),
|
|
163
|
+
user: CLICKUP_USER_SCHEMA.optional(),
|
|
164
|
+
wid: z.string().optional(),
|
|
165
|
+
});
|
|
166
|
+
export const CLICKUP_KEY_RESULT_SCHEMA = z.object({
|
|
167
|
+
completed: z.boolean().optional(),
|
|
168
|
+
creator: z.number().int().optional(),
|
|
169
|
+
current: z.number().optional(),
|
|
170
|
+
dateCreated: z.string().optional(),
|
|
171
|
+
goalId: z.string().optional(),
|
|
172
|
+
goalPrettyId: z.string().optional(),
|
|
173
|
+
id: z.string(),
|
|
174
|
+
lastAction: z.json().optional(),
|
|
175
|
+
name: z.string(),
|
|
176
|
+
owners: CLICKUP_USER_SCHEMA.array().prefault([]),
|
|
177
|
+
percentCompleted: z.coerce.number().nullable().optional(),
|
|
178
|
+
subcategoryIds: z.string().array().prefault([]),
|
|
179
|
+
stepsCurrent: z.number().nullable().optional(),
|
|
180
|
+
stepsEnd: z.number().optional(),
|
|
181
|
+
stepsStart: z.number().optional(),
|
|
182
|
+
taskIds: z.string().array().prefault([]),
|
|
183
|
+
target: z.number().optional(),
|
|
184
|
+
type: z.string().optional(),
|
|
185
|
+
unit: z.string().optional(),
|
|
186
|
+
});
|
|
187
|
+
const CLICKUP_GOAL_BASE_SCHEMA = z.object({
|
|
188
|
+
archived: z.boolean().optional(),
|
|
189
|
+
color: z.string().optional(),
|
|
190
|
+
dateCreated: z.string().optional(),
|
|
191
|
+
description: z.string().optional(),
|
|
192
|
+
dueDate: z.string().nullable().optional(),
|
|
193
|
+
id: z.string(),
|
|
194
|
+
multipleOwners: z.boolean().optional(),
|
|
195
|
+
name: z.string(),
|
|
196
|
+
percentCompleted: z.number().optional(),
|
|
197
|
+
private: z.boolean().optional(),
|
|
198
|
+
teamId: z.string().optional(),
|
|
199
|
+
});
|
|
200
|
+
/** Goal shape returned by the Workspace Goal listing endpoint. */
|
|
201
|
+
export const CLICKUP_GOAL_LIST_ITEM_SCHEMA = CLICKUP_GOAL_BASE_SCHEMA.extend({
|
|
202
|
+
keyResults: z.string().array().prefault([]),
|
|
203
|
+
owners: z.string().array().prefault([]),
|
|
204
|
+
});
|
|
205
|
+
/** Goal shape returned by get, create, and update endpoints. */
|
|
206
|
+
export const CLICKUP_GOAL_SCHEMA = CLICKUP_GOAL_BASE_SCHEMA.extend({
|
|
207
|
+
keyResults: CLICKUP_KEY_RESULT_SCHEMA.array().prefault([]),
|
|
208
|
+
owners: CLICKUP_USER_SCHEMA.array().prefault([]),
|
|
209
|
+
});
|
|
210
|
+
export const CLICKUP_HISTORY_ITEM_SCHEMA = z.object({
|
|
211
|
+
after: z.json().optional(),
|
|
212
|
+
before: z.json().optional(),
|
|
213
|
+
comment: z
|
|
214
|
+
.object({
|
|
215
|
+
comment: z.json().array().prefault([]),
|
|
216
|
+
date: z.string(),
|
|
217
|
+
id: z.string(),
|
|
218
|
+
parent: z.string().optional(),
|
|
219
|
+
textContent: z.string().optional(),
|
|
220
|
+
type: z.number().int().optional(),
|
|
221
|
+
user: CLICKUP_USER_SCHEMA,
|
|
222
|
+
})
|
|
223
|
+
.catchall(z.json())
|
|
224
|
+
.optional(),
|
|
225
|
+
customField: CLICKUP_CUSTOM_FIELD_SCHEMA.optional(),
|
|
226
|
+
data: z.json().optional(),
|
|
227
|
+
date: z.string(),
|
|
228
|
+
field: z.string().optional(),
|
|
229
|
+
id: z.string(),
|
|
230
|
+
parentId: z.string().optional(),
|
|
231
|
+
source: z.json().optional(),
|
|
232
|
+
type: z.number().int(),
|
|
233
|
+
user: CLICKUP_USER_SCHEMA.optional(),
|
|
234
|
+
});
|
|
235
|
+
export const CLICKUP_WEBHOOK_EVENT_NAMES = [
|
|
236
|
+
"taskCreated",
|
|
237
|
+
"taskUpdated",
|
|
238
|
+
"taskDeleted",
|
|
239
|
+
"taskPriorityUpdated",
|
|
240
|
+
"taskStatusUpdated",
|
|
241
|
+
"taskAssigneeUpdated",
|
|
242
|
+
"taskDueDateUpdated",
|
|
243
|
+
"taskTagUpdated",
|
|
244
|
+
"taskMoved",
|
|
245
|
+
"taskCommentPosted",
|
|
246
|
+
"taskCommentUpdated",
|
|
247
|
+
"taskTimeEstimateUpdated",
|
|
248
|
+
"taskTimeTrackedUpdated",
|
|
249
|
+
"listCreated",
|
|
250
|
+
"listUpdated",
|
|
251
|
+
"listDeleted",
|
|
252
|
+
"folderCreated",
|
|
253
|
+
"folderUpdated",
|
|
254
|
+
"folderDeleted",
|
|
255
|
+
"spaceCreated",
|
|
256
|
+
"spaceUpdated",
|
|
257
|
+
"spaceDeleted",
|
|
258
|
+
"goalCreated",
|
|
259
|
+
"goalUpdated",
|
|
260
|
+
"goalDeleted",
|
|
261
|
+
"keyResultCreated",
|
|
262
|
+
"keyResultUpdated",
|
|
263
|
+
"keyResultDeleted",
|
|
264
|
+
];
|
|
265
|
+
export const CLICKUP_WEBHOOK_EVENT_NAME_SCHEMA = z.enum(CLICKUP_WEBHOOK_EVENT_NAMES);
|
|
266
|
+
export const CLICKUP_WEBHOOK_EVENT_SCHEMA = z.object({
|
|
267
|
+
data: z
|
|
268
|
+
.object({
|
|
269
|
+
description: z.string().optional(),
|
|
270
|
+
intervalId: z.string().optional(),
|
|
271
|
+
})
|
|
272
|
+
.catchall(z.json())
|
|
273
|
+
.optional(),
|
|
274
|
+
event: CLICKUP_WEBHOOK_EVENT_NAME_SCHEMA,
|
|
275
|
+
folderId: z.string().optional(),
|
|
276
|
+
goalId: z.string().optional(),
|
|
277
|
+
historyItems: CLICKUP_HISTORY_ITEM_SCHEMA.array().prefault([]),
|
|
278
|
+
keyResultId: z.string().optional(),
|
|
279
|
+
listId: z.string().optional(),
|
|
280
|
+
spaceId: z.string().optional(),
|
|
281
|
+
taskId: z.string().optional(),
|
|
282
|
+
webhookId: z.string(),
|
|
283
|
+
});
|
|
284
|
+
export const CLICKUP_TRIGGER_CONFIG_SCHEMA = z.object({
|
|
285
|
+
workspaceId: z.string().min(1),
|
|
286
|
+
});
|
|
@@ -212,7 +212,7 @@ export declare const CLOSEBOT_BOT_SCHEMA: z.ZodObject<{
|
|
|
212
212
|
modifiedBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
213
213
|
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
214
214
|
personaIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
215
|
-
personaSplitTest: z.ZodOptional<z.ZodObject<{
|
|
215
|
+
personaSplitTest: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
216
216
|
endedAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodUnion<readonly [z.ZodDate, z.ZodISODateTime]>, z.ZodTransform<Date, string | Date>>>>;
|
|
217
217
|
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
218
218
|
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -238,7 +238,7 @@ export declare const CLOSEBOT_BOT_SCHEMA: z.ZodObject<{
|
|
|
238
238
|
weight: z.ZodOptional<z.ZodNumber>;
|
|
239
239
|
}, z.core.$strip>>>>;
|
|
240
240
|
startedAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodUnion<readonly [z.ZodDate, z.ZodISODateTime]>, z.ZodTransform<Date, string | Date>>>>;
|
|
241
|
-
}, z.core.$strip
|
|
241
|
+
}, z.core.$strip>>>;
|
|
242
242
|
personaWeights: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>>;
|
|
243
243
|
reschedulingEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
244
244
|
smartFollowUp: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -714,6 +714,9 @@ export declare const CLOSEBOT_LIBRARY_FILE_SCHEMA: z.ZodObject<{
|
|
|
714
714
|
uri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
715
715
|
uses: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
716
716
|
}, z.core.$strip>;
|
|
717
|
+
export declare const CLOSEBOT_LIBRARY_FILE_CREATED_SCHEMA: z.ZodObject<{
|
|
718
|
+
id: z.ZodString;
|
|
719
|
+
}, z.core.$strip>;
|
|
717
720
|
export declare const CLOSEBOT_LIBRARY_FILE_PREVIEW_SCHEMA: z.ZodObject<{
|
|
718
721
|
chunks: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
719
722
|
chunkIndex: z.ZodOptional<z.ZodNumber>;
|
|
@@ -733,6 +736,11 @@ export declare const CLOSEBOT_WEB_SCRAPE_PAGE_SCHEMA: z.ZodObject<{
|
|
|
733
736
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
734
737
|
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
735
738
|
}, z.core.$strip>;
|
|
739
|
+
export declare const CLOSEBOT_WEB_SCRAPE_CREATED_SCHEMA: z.ZodObject<{
|
|
740
|
+
id: z.ZodString;
|
|
741
|
+
message: z.ZodString;
|
|
742
|
+
totalSize: z.ZodNumber;
|
|
743
|
+
}, z.core.$strip>;
|
|
736
744
|
export declare const CLOSEBOT_BOT_VARIABLE_SCHEMA: z.ZodObject<{
|
|
737
745
|
id: z.ZodNullable<z.ZodString>;
|
|
738
746
|
name: z.ZodNullable<z.ZodString>;
|
package/dist/closebot/schemas.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
export const CLOSEBOT_ID_SCHEMA = z.string().trim().min(1);
|
|
3
3
|
export const CLOSEBOT_DATE_SCHEMA = z
|
|
4
|
-
.union([z.date(), z.iso.datetime({ offset: true })])
|
|
5
|
-
.transform((value) =>
|
|
4
|
+
.union([z.date(), z.iso.datetime({ local: true, offset: true })])
|
|
5
|
+
.transform((value) => value instanceof Date
|
|
6
|
+
? value
|
|
7
|
+
: new Date(/(?:Z|[+-]\d{2}:\d{2})$/.test(value) ? value : `${value}Z`));
|
|
6
8
|
const OPTIONAL_STRING = z.string().nullable().optional();
|
|
7
9
|
const OPTIONAL_BOOLEAN = z.boolean().optional();
|
|
8
10
|
const OPTIONAL_INTEGER = z.number().int().optional();
|
|
@@ -168,7 +170,7 @@ export const CLOSEBOT_BOT_SCHEMA = z.object({
|
|
|
168
170
|
modifiedBy: OPTIONAL_STRING,
|
|
169
171
|
name: OPTIONAL_STRING,
|
|
170
172
|
personaIds: z.string().array().nullable().optional(),
|
|
171
|
-
personaSplitTest: CLOSEBOT_PERSONA_SPLIT_TEST_SCHEMA.optional(),
|
|
173
|
+
personaSplitTest: CLOSEBOT_PERSONA_SPLIT_TEST_SCHEMA.nullable().optional(),
|
|
172
174
|
personaWeights: z.record(z.string(), z.number().int()).nullable().optional(),
|
|
173
175
|
reschedulingEnabled: OPTIONAL_BOOLEAN,
|
|
174
176
|
smartFollowUp: OPTIONAL_BOOLEAN,
|
|
@@ -401,6 +403,9 @@ export const CLOSEBOT_LIBRARY_FILE_SCHEMA = z.object({
|
|
|
401
403
|
uri: OPTIONAL_STRING,
|
|
402
404
|
uses: z.number().int().nullable().optional(),
|
|
403
405
|
});
|
|
406
|
+
export const CLOSEBOT_LIBRARY_FILE_CREATED_SCHEMA = z.object({
|
|
407
|
+
id: CLOSEBOT_ID_SCHEMA,
|
|
408
|
+
});
|
|
404
409
|
export const CLOSEBOT_LIBRARY_FILE_PREVIEW_SCHEMA = z.object({
|
|
405
410
|
chunks: z
|
|
406
411
|
.object({ chunkIndex: OPTIONAL_INTEGER, content: OPTIONAL_STRING })
|
|
@@ -421,6 +426,11 @@ export const CLOSEBOT_WEB_SCRAPE_PAGE_SCHEMA = z.object({
|
|
|
421
426
|
enabled: OPTIONAL_BOOLEAN,
|
|
422
427
|
url: OPTIONAL_STRING,
|
|
423
428
|
});
|
|
429
|
+
export const CLOSEBOT_WEB_SCRAPE_CREATED_SCHEMA = z.object({
|
|
430
|
+
id: CLOSEBOT_ID_SCHEMA,
|
|
431
|
+
message: z.string(),
|
|
432
|
+
totalSize: z.number().int().nonnegative(),
|
|
433
|
+
});
|
|
424
434
|
export const CLOSEBOT_BOT_VARIABLE_SCHEMA = z.object({
|
|
425
435
|
id: z.string().nullable(),
|
|
426
436
|
name: z.string().nullable(),
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export declare const GOOGLE_ADS_CUSTOMER_ID_SCHEMA: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
3
|
+
export declare const GOOGLE_ADS_RESOURCE_NAME_SCHEMA: z.ZodString;
|
|
4
|
+
export declare const GOOGLE_ADS_SECRET_SCHEMA: z.ZodObject<{
|
|
5
|
+
accessToken: z.ZodString;
|
|
6
|
+
developerToken: z.ZodString;
|
|
7
|
+
tokenType: z.ZodString;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export interface GoogleAdsRequestOptions<TSchema extends z.ZodType> {
|
|
10
|
+
body?: z.input<ReturnType<typeof z.json>>;
|
|
11
|
+
loginCustomerId?: string;
|
|
12
|
+
method?: "GET" | "POST";
|
|
13
|
+
responseSchema: TSchema;
|
|
14
|
+
}
|
|
15
|
+
interface GoogleAdsApiErrorOptions {
|
|
16
|
+
message?: string;
|
|
17
|
+
providerStatus?: string;
|
|
18
|
+
requestId?: string;
|
|
19
|
+
retryAfter?: string;
|
|
20
|
+
status: number;
|
|
21
|
+
}
|
|
22
|
+
/** Structured Google Ads REST failure with correlation metadata. */
|
|
23
|
+
export declare class GoogleAdsApiError extends Error {
|
|
24
|
+
readonly providerStatus?: string;
|
|
25
|
+
readonly requestId?: string;
|
|
26
|
+
readonly retryAfter?: string;
|
|
27
|
+
readonly status: number;
|
|
28
|
+
/** Creates a structured failure from one provider response. */
|
|
29
|
+
/** @param options - HTTP and Google Ads error metadata. */
|
|
30
|
+
constructor(options: GoogleAdsApiErrorOptions);
|
|
31
|
+
}
|
|
32
|
+
/** Creates an authenticated Google Ads v25 REST client. */
|
|
33
|
+
/** @param secret - Resolved Google OAuth and platform developer credentials. */
|
|
34
|
+
export declare function getGoogleAdsApi(secret: unknown): {
|
|
35
|
+
request<TSchema extends z.ZodType>(path: string, options: GoogleAdsRequestOptions<TSchema>): Promise<z.output<TSchema>>;
|
|
36
|
+
};
|
|
37
|
+
/** Normalizes a Google Ads customer ID for paths and headers. */
|
|
38
|
+
/** @param value - Dashed or compact 10-digit customer ID. */
|
|
39
|
+
export declare function normalizeGoogleAdsCustomerId(value: string): string;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
const GOOGLE_ADS_API_ORIGIN = "https://googleads.googleapis.com";
|
|
3
|
+
const GOOGLE_ADS_API_VERSION = "v25";
|
|
4
|
+
export const GOOGLE_ADS_CUSTOMER_ID_SCHEMA = z
|
|
5
|
+
.string()
|
|
6
|
+
.trim()
|
|
7
|
+
.regex(/^(?:\d{3}-?\d{3}-?\d{4})$/, "Enter a 10-digit customer ID.")
|
|
8
|
+
.transform((value) => value.replaceAll("-", ""));
|
|
9
|
+
export const GOOGLE_ADS_RESOURCE_NAME_SCHEMA = z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^customers\/\d{10}\/[A-Za-z][A-Za-z0-9]*(?:\/[^/]+)+$/);
|
|
12
|
+
export const GOOGLE_ADS_SECRET_SCHEMA = z.object({
|
|
13
|
+
accessToken: z.string().min(1),
|
|
14
|
+
developerToken: z.string().min(1),
|
|
15
|
+
tokenType: z.string().min(1),
|
|
16
|
+
});
|
|
17
|
+
const GOOGLE_ADS_FAILURE_SCHEMA = z.looseObject({
|
|
18
|
+
error: z
|
|
19
|
+
.looseObject({
|
|
20
|
+
code: z.number().int().optional(),
|
|
21
|
+
message: z.string().optional(),
|
|
22
|
+
status: z.string().optional(),
|
|
23
|
+
})
|
|
24
|
+
.optional(),
|
|
25
|
+
});
|
|
26
|
+
/** Structured Google Ads REST failure with correlation metadata. */
|
|
27
|
+
export class GoogleAdsApiError extends Error {
|
|
28
|
+
providerStatus;
|
|
29
|
+
requestId;
|
|
30
|
+
retryAfter;
|
|
31
|
+
status;
|
|
32
|
+
/** Creates a structured failure from one provider response. */
|
|
33
|
+
/** @param options - HTTP and Google Ads error metadata. */
|
|
34
|
+
constructor(options) {
|
|
35
|
+
super(options.message ??
|
|
36
|
+
`Google Ads API request failed with status ${options.status}.`);
|
|
37
|
+
this.name = "GoogleAdsApiError";
|
|
38
|
+
this.providerStatus = options.providerStatus;
|
|
39
|
+
this.requestId = options.requestId;
|
|
40
|
+
this.retryAfter = options.retryAfter;
|
|
41
|
+
this.status = options.status;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Creates an authenticated Google Ads v25 REST client. */
|
|
45
|
+
/** @param secret - Resolved Google OAuth and platform developer credentials. */
|
|
46
|
+
export function getGoogleAdsApi(secret) {
|
|
47
|
+
const credentials = GOOGLE_ADS_SECRET_SCHEMA.parse(secret);
|
|
48
|
+
return {
|
|
49
|
+
async request(path, options) {
|
|
50
|
+
const normalizedPath = path.replace(/^\/+/, "");
|
|
51
|
+
if (!normalizedPath ||
|
|
52
|
+
normalizedPath.includes("://") ||
|
|
53
|
+
normalizedPath.includes("\\")) {
|
|
54
|
+
throw new TypeError("Google Ads API paths must be relative.");
|
|
55
|
+
}
|
|
56
|
+
const url = new URL(`${GOOGLE_ADS_API_VERSION}/${normalizedPath}`, `${GOOGLE_ADS_API_ORIGIN}/`);
|
|
57
|
+
if (url.origin !== GOOGLE_ADS_API_ORIGIN) {
|
|
58
|
+
throw new TypeError("Google Ads API paths must remain on googleads.googleapis.com.");
|
|
59
|
+
}
|
|
60
|
+
const headers = new Headers({
|
|
61
|
+
Accept: "application/json",
|
|
62
|
+
Authorization: `${credentials.tokenType} ${credentials.accessToken}`,
|
|
63
|
+
"developer-token": credentials.developerToken,
|
|
64
|
+
});
|
|
65
|
+
if (options.loginCustomerId) {
|
|
66
|
+
headers.set("login-customer-id", GOOGLE_ADS_CUSTOMER_ID_SCHEMA.parse(options.loginCustomerId));
|
|
67
|
+
}
|
|
68
|
+
if (options.body !== undefined) {
|
|
69
|
+
headers.set("Content-Type", "application/json");
|
|
70
|
+
}
|
|
71
|
+
const response = await fetch(url, {
|
|
72
|
+
body: options.body === undefined ? undefined : JSON.stringify(options.body),
|
|
73
|
+
headers,
|
|
74
|
+
method: options.method ?? (options.body === undefined ? "GET" : "POST"),
|
|
75
|
+
});
|
|
76
|
+
const payload = parseGoogleAdsJson(await response.text());
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
const failure = GOOGLE_ADS_FAILURE_SCHEMA.safeParse(payload);
|
|
79
|
+
throw new GoogleAdsApiError({
|
|
80
|
+
message: failure.success ? failure.data.error?.message : undefined,
|
|
81
|
+
providerStatus: failure.success
|
|
82
|
+
? failure.data.error?.status
|
|
83
|
+
: undefined,
|
|
84
|
+
requestId: response.headers.get("request-id") ?? undefined,
|
|
85
|
+
retryAfter: response.headers.get("retry-after") ?? undefined,
|
|
86
|
+
status: response.status,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return options.responseSchema.parse(payload);
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Normalizes a Google Ads customer ID for paths and headers. */
|
|
94
|
+
/** @param value - Dashed or compact 10-digit customer ID. */
|
|
95
|
+
export function normalizeGoogleAdsCustomerId(value) {
|
|
96
|
+
return GOOGLE_ADS_CUSTOMER_ID_SCHEMA.parse(value);
|
|
97
|
+
}
|
|
98
|
+
/** Parses an optional Google Ads JSON response body. */
|
|
99
|
+
/** @param value - Raw response body. */
|
|
100
|
+
function parseGoogleAdsJson(value) {
|
|
101
|
+
if (!value)
|
|
102
|
+
return undefined;
|
|
103
|
+
try {
|
|
104
|
+
return JSON.parse(value);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
}
|