terse-cli 0.1.17 → 0.1.19
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/README.md +4 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +6 -9
- package/dist/api.js.map +1 -1
- package/dist/assertProjectRoot.d.ts.map +1 -1
- package/dist/assertProjectRoot.js +1 -1
- package/dist/assertProjectRoot.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +4 -4
- package/dist/auth.js.map +1 -1
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +15 -11
- package/dist/deploy.js.map +1 -1
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +47 -22
- package/dist/generate.js.map +1 -1
- package/dist/index.js +2 -5
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +3 -3
- package/dist/init.js.map +1 -1
- package/dist/integrate.d.ts.map +1 -1
- package/dist/integrate.js +8 -12
- package/dist/integrate.js.map +1 -1
- package/dist/integrationApi.d.ts +2 -2
- package/dist/integrationApi.d.ts.map +1 -1
- package/dist/integrationApi.js.map +1 -1
- package/dist/loadJob.d.ts.map +1 -1
- package/dist/loadJob.js +2 -2
- package/dist/loadJob.js.map +1 -1
- package/dist/providers/LanguageProvider.d.ts +2 -2
- package/dist/providers/LanguageProvider.d.ts.map +1 -1
- package/dist/providers/codegenTypes.d.ts +1 -12
- package/dist/providers/codegenTypes.d.ts.map +1 -1
- package/dist/providers/python/PythonProvider.d.ts +1 -1
- package/dist/providers/python/PythonProvider.d.ts.map +1 -1
- package/dist/providers/python/PythonProvider.js +19 -26
- package/dist/providers/python/PythonProvider.js.map +1 -1
- package/dist/providers/python/preparePythonCodegenData.d.ts +16 -0
- package/dist/providers/python/preparePythonCodegenData.d.ts.map +1 -1
- package/dist/providers/python/preparePythonCodegenData.js +76 -55
- package/dist/providers/python/preparePythonCodegenData.js.map +1 -1
- package/dist/providers/python/pythonTemplateEngine.d.ts.map +1 -1
- package/dist/providers/python/pythonTemplateEngine.js +2 -2
- package/dist/providers/python/pythonTemplateEngine.js.map +1 -1
- package/dist/providers/resolveProvider.d.ts.map +1 -1
- package/dist/providers/resolveProvider.js +1 -1
- package/dist/providers/resolveProvider.js.map +1 -1
- package/dist/providers/shared/sessionStream.d.ts +1 -1
- package/dist/providers/shared/sessionStream.d.ts.map +1 -1
- package/dist/providers/shared/sessionStream.js +8 -10
- package/dist/providers/shared/sessionStream.js.map +1 -1
- package/dist/providers/shared/shellUtils.d.ts.map +1 -1
- package/dist/providers/shared/shellUtils.js +3 -4
- package/dist/providers/shared/shellUtils.js.map +1 -1
- package/dist/providers/templateUtils.d.ts.map +1 -1
- package/dist/providers/templateUtils.js +1 -1
- package/dist/providers/templateUtils.js.map +1 -1
- package/dist/providers/typescript/TypeScriptProvider.d.ts +1 -1
- package/dist/providers/typescript/TypeScriptProvider.d.ts.map +1 -1
- package/dist/providers/typescript/TypeScriptProvider.js +8 -10
- package/dist/providers/typescript/TypeScriptProvider.js.map +1 -1
- package/dist/providers/typescript/prepareCodegenData.d.ts +1 -2
- package/dist/providers/typescript/prepareCodegenData.d.ts.map +1 -1
- package/dist/providers/typescript/prepareCodegenData.js +169 -252
- package/dist/providers/typescript/prepareCodegenData.js.map +1 -1
- package/dist/providers/typescript/templateEngine.d.ts.map +1 -1
- package/dist/providers/typescript/templateEngine.js +2 -2
- package/dist/providers/typescript/templateEngine.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +2 -2
- package/dist/run.js.map +1 -1
- package/dist/shared/ToolDisplayUtils.d.ts.map +1 -1
- package/dist/shared/ToolDisplayUtils.js +13 -1
- package/dist/shared/ToolDisplayUtils.js.map +1 -1
- package/dist/shared/types.d.ts +13 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/test.d.ts.map +1 -1
- package/dist/test.js +18 -8
- package/dist/test.js.map +1 -1
- package/dist/util.d.ts +1 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js.map +1 -1
- package/package.json +12 -8
- package/templates/python/codegen/generated.hbs +1 -0
- package/templates/python/codegen/partials/attio-section.hbs +4 -5
- package/templates/python/codegen/partials/attio-upsert-record-method.hbs +3 -3
- package/templates/python/codegen/partials/deterministic-tools-section.hbs +115 -1
- package/templates/python/codegen/partials/slack-section.hbs +178 -0
- package/templates/python/codegen/partials/tool-name-types.hbs +3 -0
- package/templates/python/init/README.md.hbs +5 -3
- package/templates/typescript/codegen/partials/slack-section.hbs +5 -6
- package/templates/typescript/codegen/partials/system-section.hbs +9 -0
- package/templates/typescript/codegen/partials/tools-section.hbs +2 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toolsWithIntegrationId } from "terse-types";
|
|
1
2
|
export function toPascalCase(value) {
|
|
2
3
|
return value
|
|
3
4
|
.replace(/[^a-zA-Z0-9]+/g, " ")
|
|
@@ -23,12 +24,13 @@ function toCamelCase(value) {
|
|
|
23
24
|
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
24
25
|
}
|
|
25
26
|
function toolNameToInterfaceName(name) {
|
|
26
|
-
return name
|
|
27
|
+
return (name
|
|
28
|
+
.split("_")
|
|
29
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
30
|
+
.join("") + "Params");
|
|
27
31
|
}
|
|
28
32
|
function buildResourceClassContext(className, fields, staticNameField, items) {
|
|
29
|
-
const constructorParams = fields
|
|
30
|
-
.map(field => `public readonly ${field.classField}: ${field.type}`)
|
|
31
|
-
.join(", ");
|
|
33
|
+
const constructorParams = fields.map(field => `public readonly ${field.classField}: ${field.type}`).join(", ");
|
|
32
34
|
const entries = [];
|
|
33
35
|
const usedNames = new Set();
|
|
34
36
|
for (const item of items) {
|
|
@@ -39,21 +41,23 @@ function buildResourceClassContext(className, fields, staticNameField, items) {
|
|
|
39
41
|
while (usedNames.has(name))
|
|
40
42
|
name += "_";
|
|
41
43
|
usedNames.add(name);
|
|
42
|
-
const argsText = fields
|
|
44
|
+
const argsText = fields
|
|
45
|
+
.map(field => {
|
|
43
46
|
const value = source[field.sourceField];
|
|
44
47
|
if (typeof value === "number")
|
|
45
48
|
return String(value);
|
|
46
49
|
return `"${escapeString(String(value ?? ""))}"`;
|
|
47
|
-
})
|
|
50
|
+
})
|
|
51
|
+
.join(", ");
|
|
48
52
|
entries.push({
|
|
49
53
|
staticName: name,
|
|
50
|
-
argsText
|
|
54
|
+
argsText
|
|
51
55
|
});
|
|
52
56
|
}
|
|
53
57
|
return {
|
|
54
58
|
className,
|
|
55
59
|
constructorParams,
|
|
56
|
-
items: entries
|
|
60
|
+
items: entries
|
|
57
61
|
};
|
|
58
62
|
}
|
|
59
63
|
function sectionData(imports, data) {
|
|
@@ -95,11 +99,7 @@ export function attioAttributeBaseType(attr) {
|
|
|
95
99
|
type.includes("name")) {
|
|
96
100
|
return "string";
|
|
97
101
|
}
|
|
98
|
-
if (type.includes("location") ||
|
|
99
|
-
type.includes("address") ||
|
|
100
|
-
type.includes("reference") ||
|
|
101
|
-
type.includes("record") ||
|
|
102
|
-
type.includes("actor")) {
|
|
102
|
+
if (type.includes("location") || type.includes("address") || type.includes("reference") || type.includes("record") || type.includes("actor")) {
|
|
103
103
|
return "Record<string, unknown>";
|
|
104
104
|
}
|
|
105
105
|
if (slug === "email_addresses" || slug === "domains" || slug === "phone_numbers" || slug === "name") {
|
|
@@ -150,67 +150,11 @@ export function buildSkillToolTypeForIntegration(tools, integrationType) {
|
|
|
150
150
|
.sort();
|
|
151
151
|
return renderStringLiteralUnion(toolNames);
|
|
152
152
|
}
|
|
153
|
-
export function jsonSchemaToTs(schema, indent) {
|
|
154
|
-
if (!schema)
|
|
155
|
-
return "unknown";
|
|
156
|
-
if (schema.enum) {
|
|
157
|
-
return schema.enum.map(value => typeof value === "string" ? `"${escapeString(value)}"` : String(value)).join(" | ");
|
|
158
|
-
}
|
|
159
|
-
if (schema.anyOf) {
|
|
160
|
-
const nonNull = schema.anyOf.filter(child => child.type !== "null");
|
|
161
|
-
const hasNull = schema.anyOf.some(child => child.type === "null");
|
|
162
|
-
if (nonNull.length === 1 && hasNull) {
|
|
163
|
-
return `${jsonSchemaToTs(nonNull[0], indent)} | null`;
|
|
164
|
-
}
|
|
165
|
-
return schema.anyOf.map(child => jsonSchemaToTs(child, indent)).join(" | ");
|
|
166
|
-
}
|
|
167
|
-
switch (schema.type) {
|
|
168
|
-
case "string":
|
|
169
|
-
return "string";
|
|
170
|
-
case "number":
|
|
171
|
-
case "integer":
|
|
172
|
-
return "number";
|
|
173
|
-
case "boolean":
|
|
174
|
-
return "boolean";
|
|
175
|
-
case "array":
|
|
176
|
-
if (schema.items) {
|
|
177
|
-
const itemType = jsonSchemaToTs(schema.items, indent);
|
|
178
|
-
return itemType.includes("|") ? `(${itemType})[]` : `${itemType}[]`;
|
|
179
|
-
}
|
|
180
|
-
return "unknown[]";
|
|
181
|
-
case "object": {
|
|
182
|
-
if (!schema.properties || Object.keys(schema.properties).length === 0) {
|
|
183
|
-
return "Record<string, unknown>";
|
|
184
|
-
}
|
|
185
|
-
const requiredSet = new Set(schema.required || []);
|
|
186
|
-
const pad = " ".repeat(indent);
|
|
187
|
-
const innerPad = " ".repeat(indent + 4);
|
|
188
|
-
const entries = Object.entries(schema.properties).map(([key, prop]) => {
|
|
189
|
-
const isNullableAnyOf = Array.isArray(prop.anyOf) && prop.anyOf.some(child => child.type === "null");
|
|
190
|
-
const optional = requiredSet.has(key) && !isNullableAnyOf ? "" : "?";
|
|
191
|
-
const tsType = jsonSchemaToTs(prop, indent + 4);
|
|
192
|
-
const desc = prop.description ? ` /** ${prop.description} */\n${innerPad}` : "";
|
|
193
|
-
return `${desc}${key}${optional}: ${tsType}`;
|
|
194
|
-
});
|
|
195
|
-
return `{\n${innerPad}${entries.join(`\n${innerPad}`)}\n${pad}}`;
|
|
196
|
-
}
|
|
197
|
-
default:
|
|
198
|
-
return "unknown";
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
153
|
function prepareGitHubSection(instances, tools) {
|
|
202
154
|
if (instances.length === 0)
|
|
203
155
|
return sectionData([]);
|
|
204
156
|
const inst = instances[0];
|
|
205
|
-
const imports = [
|
|
206
|
-
"GitHubConfig",
|
|
207
|
-
"GitHubEventType",
|
|
208
|
-
"TypedTrigger",
|
|
209
|
-
"TypedSkill",
|
|
210
|
-
"GithubPRInputEvent",
|
|
211
|
-
"GithubPushInputEvent",
|
|
212
|
-
"GithubInputEvent",
|
|
213
|
-
];
|
|
157
|
+
const imports = ["GitHubConfig", "GitHubEventType", "TypedTrigger", "TypedSkill", "GithubPRInputEvent", "GithubPushInputEvent", "GithubInputEvent"];
|
|
214
158
|
const skillToolType = buildSkillToolTypeForIntegration(tools, "github");
|
|
215
159
|
const repositoriesWithFullName = inst.repositories.map(repo => {
|
|
216
160
|
const owner = repo.owner || "UnknownOwner";
|
|
@@ -231,7 +175,7 @@ function prepareGitHubSection(instances, tools) {
|
|
|
231
175
|
}
|
|
232
176
|
const owners = Array.from(ownerEntries.entries()).map(([name, data]) => ({
|
|
233
177
|
name,
|
|
234
|
-
staticName: data.staticName
|
|
178
|
+
staticName: data.staticName
|
|
235
179
|
}));
|
|
236
180
|
const repoGroups = Array.from(ownerEntries.values()).map(group => {
|
|
237
181
|
const usedRepoNames = new Set();
|
|
@@ -246,16 +190,16 @@ function prepareGitHubSection(instances, tools) {
|
|
|
246
190
|
id: repo.id,
|
|
247
191
|
name: repo.name,
|
|
248
192
|
fullName: repo.fullName,
|
|
249
|
-
staticName
|
|
193
|
+
staticName
|
|
250
194
|
};
|
|
251
|
-
})
|
|
195
|
+
})
|
|
252
196
|
};
|
|
253
197
|
});
|
|
254
198
|
return sectionData(imports, {
|
|
255
199
|
id: inst.integration.id,
|
|
256
200
|
skillToolType,
|
|
257
201
|
owners,
|
|
258
|
-
repoGroups
|
|
202
|
+
repoGroups
|
|
259
203
|
});
|
|
260
204
|
}
|
|
261
205
|
function prepareGmailSection(instances, tools) {
|
|
@@ -263,20 +207,20 @@ function prepareGmailSection(instances, tools) {
|
|
|
263
207
|
return sectionData([]);
|
|
264
208
|
return sectionData(["GmailConfig", "GmailOutputConfig", "GmailDraftOutputConfig", "TypedSkill", "GmailEventType"], {
|
|
265
209
|
id: instances[0].id,
|
|
266
|
-
skillToolType: buildSkillToolTypeForIntegration(tools, "gmail")
|
|
210
|
+
skillToolType: buildSkillToolTypeForIntegration(tools, "gmail")
|
|
267
211
|
});
|
|
268
212
|
}
|
|
269
213
|
function prepareSlackSection(instances, tools) {
|
|
270
214
|
if (instances.length === 0)
|
|
271
215
|
return sectionData([]);
|
|
272
216
|
const inst = instances[0];
|
|
273
|
-
return sectionData(["SlackConfig", "SlackOutputConfig", "TypedSkill", "SlackEventType"], {
|
|
217
|
+
return sectionData(["SlackConfig", "SlackOutputConfig", "TypedSkill", "SlackEventType", "TypedTrigger", "SlackMessageEvent"], {
|
|
274
218
|
id: inst.id,
|
|
275
219
|
skillToolType: buildSkillToolTypeForIntegration(tools, "slack"),
|
|
276
220
|
channelClass: buildResourceClassContext("SlackChannel", [
|
|
277
221
|
{ classField: "channelId", type: "string", sourceField: "id" },
|
|
278
|
-
{ classField: "name", type: "string", sourceField: "name" }
|
|
279
|
-
], "name", inst.channels)
|
|
222
|
+
{ classField: "name", type: "string", sourceField: "name" }
|
|
223
|
+
], "name", inst.channels)
|
|
280
224
|
});
|
|
281
225
|
}
|
|
282
226
|
function prepareFigmaSection(instances) {
|
|
@@ -294,8 +238,8 @@ function prepareLinearSection(instances, tools) {
|
|
|
294
238
|
teamClass: buildResourceClassContext("LinearTeam", [
|
|
295
239
|
{ classField: "teamId", type: "string", sourceField: "id" },
|
|
296
240
|
{ classField: "name", type: "string", sourceField: "name" },
|
|
297
|
-
{ classField: "key", type: "string", sourceField: "key" }
|
|
298
|
-
], "name", inst.teams)
|
|
241
|
+
{ classField: "key", type: "string", sourceField: "key" }
|
|
242
|
+
], "name", inst.teams)
|
|
299
243
|
});
|
|
300
244
|
}
|
|
301
245
|
function prepareAtlassianSection(instances, tools) {
|
|
@@ -308,14 +252,14 @@ function prepareAtlassianSection(instances, tools) {
|
|
|
308
252
|
jiraProjectClass: buildResourceClassContext("JiraProject", [
|
|
309
253
|
{ classField: "projectKey", type: "string", sourceField: "key" },
|
|
310
254
|
{ classField: "projectId", type: "string", sourceField: "id" },
|
|
311
|
-
{ classField: "name", type: "string", sourceField: "name" }
|
|
255
|
+
{ classField: "name", type: "string", sourceField: "name" }
|
|
312
256
|
], "name", inst.jiraProjects),
|
|
313
257
|
confluencePageClass: buildResourceClassContext("ConfluencePage", [
|
|
314
258
|
{ classField: "pageId", type: "string", sourceField: "id" },
|
|
315
259
|
{ classField: "title", type: "string", sourceField: "title" },
|
|
316
260
|
{ classField: "spaceId", type: "string", sourceField: "spaceId" },
|
|
317
|
-
{ classField: "spaceName", type: "string", sourceField: "spaceName" }
|
|
318
|
-
], "title", inst.confluencePages)
|
|
261
|
+
{ classField: "spaceName", type: "string", sourceField: "spaceName" }
|
|
262
|
+
], "title", inst.confluencePages)
|
|
319
263
|
});
|
|
320
264
|
}
|
|
321
265
|
function prepareNotionSection(instances, tools) {
|
|
@@ -327,12 +271,12 @@ function prepareNotionSection(instances, tools) {
|
|
|
327
271
|
skillToolType: buildSkillToolTypeForIntegration(tools, "notion"),
|
|
328
272
|
databaseClass: buildResourceClassContext("NotionDatabase", [
|
|
329
273
|
{ classField: "databaseId", type: "string", sourceField: "id" },
|
|
330
|
-
{ classField: "title", type: "string", sourceField: "title" }
|
|
274
|
+
{ classField: "title", type: "string", sourceField: "title" }
|
|
331
275
|
], "title", inst.databases),
|
|
332
276
|
pageClass: buildResourceClassContext("NotionPage", [
|
|
333
277
|
{ classField: "pageId", type: "string", sourceField: "id" },
|
|
334
|
-
{ classField: "title", type: "string", sourceField: "title" }
|
|
335
|
-
], "title", inst.pages)
|
|
278
|
+
{ classField: "title", type: "string", sourceField: "title" }
|
|
279
|
+
], "title", inst.pages)
|
|
336
280
|
});
|
|
337
281
|
}
|
|
338
282
|
function preparePosthogSection(instances, tools) {
|
|
@@ -344,8 +288,8 @@ function preparePosthogSection(instances, tools) {
|
|
|
344
288
|
skillToolType: buildSkillToolTypeForIntegration(tools, "posthog"),
|
|
345
289
|
projectClass: buildResourceClassContext("PosthogProject", [
|
|
346
290
|
{ classField: "projectId", type: "string", sourceField: "id" },
|
|
347
|
-
{ classField: "name", type: "string", sourceField: "name" }
|
|
348
|
-
], "name", inst.projects)
|
|
291
|
+
{ classField: "name", type: "string", sourceField: "name" }
|
|
292
|
+
], "name", inst.projects)
|
|
349
293
|
});
|
|
350
294
|
}
|
|
351
295
|
function prepareDatadogSection(instances, tools) {
|
|
@@ -355,7 +299,7 @@ function prepareDatadogSection(instances, tools) {
|
|
|
355
299
|
return sectionData(["DatadogConfig", "TypedSkill"], {
|
|
356
300
|
id: inst.id,
|
|
357
301
|
skillToolType: buildSkillToolTypeForIntegration(tools, "datadog"),
|
|
358
|
-
indexClass: buildResourceClassContext("DatadogIndex", [{ classField: "name", type: "string", sourceField: "name" }], "name", inst.indexes)
|
|
302
|
+
indexClass: buildResourceClassContext("DatadogIndex", [{ classField: "name", type: "string", sourceField: "name" }], "name", inst.indexes)
|
|
359
303
|
});
|
|
360
304
|
}
|
|
361
305
|
function prepareLaunchDarklySection(instances, tools) {
|
|
@@ -367,8 +311,8 @@ function prepareLaunchDarklySection(instances, tools) {
|
|
|
367
311
|
skillToolType: buildSkillToolTypeForIntegration(tools, "launchdarkly"),
|
|
368
312
|
projectClass: buildResourceClassContext("LaunchDarklyProject", [
|
|
369
313
|
{ classField: "projectKey", type: "string", sourceField: "key" },
|
|
370
|
-
{ classField: "name", type: "string", sourceField: "name" }
|
|
371
|
-
], "name", inst.projects)
|
|
314
|
+
{ classField: "name", type: "string", sourceField: "name" }
|
|
315
|
+
], "name", inst.projects)
|
|
372
316
|
});
|
|
373
317
|
}
|
|
374
318
|
function prepareWorkOSSection(instances, tools) {
|
|
@@ -384,10 +328,10 @@ function prepareWorkOSSection(instances, tools) {
|
|
|
384
328
|
"WorkOSUserInputEvent",
|
|
385
329
|
"WorkOSMembershipInputEvent",
|
|
386
330
|
"WorkOSInvitationInputEvent",
|
|
387
|
-
"WorkOSOrganizationInputEvent"
|
|
331
|
+
"WorkOSOrganizationInputEvent"
|
|
388
332
|
], {
|
|
389
333
|
id: instances[0].id,
|
|
390
|
-
skillToolType: buildSkillToolTypeForIntegration(tools, "workos")
|
|
334
|
+
skillToolType: buildSkillToolTypeForIntegration(tools, "workos")
|
|
391
335
|
});
|
|
392
336
|
}
|
|
393
337
|
function buildGeneratedAttioObjects(instances) {
|
|
@@ -401,16 +345,20 @@ function buildGeneratedAttioObjects(instances) {
|
|
|
401
345
|
const attributes = (object.attributes || []).filter((attr) => !!attr.api_slug);
|
|
402
346
|
const attributeSource = attributes.length === 0
|
|
403
347
|
? "[]"
|
|
404
|
-
: `[\n${attributes
|
|
348
|
+
: `[\n${attributes
|
|
349
|
+
.map(attr => {
|
|
405
350
|
const fields = [
|
|
406
351
|
`apiSlug: "${escapeString(attr.api_slug)}"`,
|
|
407
352
|
attr.title ? `title: "${escapeString(attr.title)}"` : undefined,
|
|
408
353
|
attr.type ? `type: "${escapeString(attr.type)}"` : undefined,
|
|
409
354
|
attr.is_required !== undefined ? `isRequired: ${attr.is_required ? "true" : "false"}` : undefined,
|
|
410
|
-
attr.is_unique !== undefined ? `isUnique: ${attr.is_unique ? "true" : "false"}` : undefined
|
|
411
|
-
]
|
|
355
|
+
attr.is_unique !== undefined ? `isUnique: ${attr.is_unique ? "true" : "false"}` : undefined
|
|
356
|
+
]
|
|
357
|
+
.filter(Boolean)
|
|
358
|
+
.join(", ");
|
|
412
359
|
return ` { ${fields} }`;
|
|
413
|
-
})
|
|
360
|
+
})
|
|
361
|
+
.join(",\n")}\n ]`;
|
|
414
362
|
return {
|
|
415
363
|
staticName,
|
|
416
364
|
apiSlug: object.api_slug,
|
|
@@ -418,7 +366,7 @@ function buildGeneratedAttioObjects(instances) {
|
|
|
418
366
|
attributeSource,
|
|
419
367
|
recordValuesType: renderAttioObjectValueShape(attributes, "record"),
|
|
420
368
|
inputValuesType: renderAttioObjectValueShape(attributes, "input"),
|
|
421
|
-
attributes
|
|
369
|
+
attributes
|
|
422
370
|
};
|
|
423
371
|
});
|
|
424
372
|
}
|
|
@@ -428,7 +376,7 @@ function prepareAttioSection(instances, tools) {
|
|
|
428
376
|
return sectionData(["AttioOutputConfig", "TypedSkill"], {
|
|
429
377
|
id: instances[0].id,
|
|
430
378
|
skillToolType: buildSkillToolTypeForIntegration(tools, "attio"),
|
|
431
|
-
objects: buildGeneratedAttioObjects(instances)
|
|
379
|
+
objects: buildGeneratedAttioObjects(instances)
|
|
432
380
|
});
|
|
433
381
|
}
|
|
434
382
|
function prepareSnowflakeSection(instances, tools) {
|
|
@@ -436,13 +384,13 @@ function prepareSnowflakeSection(instances, tools) {
|
|
|
436
384
|
return sectionData([]);
|
|
437
385
|
return sectionData(["SnowflakeOutputConfig", "TypedSkill"], {
|
|
438
386
|
id: instances[0].id,
|
|
439
|
-
skillToolType: buildSkillToolTypeForIntegration(tools, "snowflake")
|
|
387
|
+
skillToolType: buildSkillToolTypeForIntegration(tools, "snowflake")
|
|
440
388
|
});
|
|
441
389
|
}
|
|
442
390
|
function prepareToolsSection(tools, input) {
|
|
443
391
|
if (tools.length === 0)
|
|
444
392
|
return sectionData([]);
|
|
445
|
-
const imports = new Set(["TerseAgent", "ToolOutputByName"]);
|
|
393
|
+
const imports = new Set(["TerseAgent", "ToolInputByName", "ToolOutputByName"]);
|
|
446
394
|
const attioPreludeLines = [];
|
|
447
395
|
const instanceMap = new Map();
|
|
448
396
|
instanceMap.set("slack", input.slack.map(inst => ({ id: inst.id, displayName: inst.displayName })));
|
|
@@ -467,17 +415,7 @@ function prepareToolsSection(tools, input) {
|
|
|
467
415
|
byIntegration.set(key, []);
|
|
468
416
|
byIntegration.get(key).push(tool);
|
|
469
417
|
}
|
|
470
|
-
const hasAutoFillId = (tool) => tool.
|
|
471
|
-
const omitIntegrationId = (schema) => {
|
|
472
|
-
const cloned = { ...schema };
|
|
473
|
-
if (cloned.properties) {
|
|
474
|
-
cloned.properties = Object.fromEntries(Object.entries(cloned.properties).filter(([key]) => key !== "integrationId"));
|
|
475
|
-
}
|
|
476
|
-
if (cloned.required) {
|
|
477
|
-
cloned.required = cloned.required.filter(required => required !== "integrationId");
|
|
478
|
-
}
|
|
479
|
-
return cloned;
|
|
480
|
-
};
|
|
418
|
+
const hasAutoFillId = (tool) => toolsWithIntegrationId.has(tool.name);
|
|
481
419
|
const normalizeGitHubReposParams = (toolName) => {
|
|
482
420
|
switch (toolName) {
|
|
483
421
|
case "readGitHubFile":
|
|
@@ -496,78 +434,74 @@ function prepareToolsSection(tools, input) {
|
|
|
496
434
|
const isAttioTool = (tool) => tool.integration.toLowerCase() === "attio";
|
|
497
435
|
const attioGeneratedObjects = buildGeneratedAttioObjects(input.attio);
|
|
498
436
|
if (tools.some(isAttioTool)) {
|
|
499
|
-
attioPreludeLines.push(
|
|
500
|
-
attioPreludeLines.push(
|
|
501
|
-
attioPreludeLines.push(
|
|
502
|
-
attioPreludeLines.push(
|
|
503
|
-
attioPreludeLines.push(
|
|
504
|
-
attioPreludeLines.push(
|
|
437
|
+
attioPreludeLines.push("type __AttioPrimitive = string | number | boolean | null");
|
|
438
|
+
attioPreludeLines.push("type __AttioStructuredValue = Record<string, unknown>");
|
|
439
|
+
attioPreludeLines.push("type __AttioValue = __AttioPrimitive | __AttioStructuredValue | (__AttioPrimitive | __AttioStructuredValue)[]");
|
|
440
|
+
attioPreludeLines.push("type __AttioFilterShorthand<T> = T extends (infer U)[] ? U | T : T");
|
|
441
|
+
attioPreludeLines.push("type __AttioFilterValue<T> = __AttioFilterShorthand<T> | { $eq?: __AttioFilterShorthand<T>; $contains?: string; $starts_with?: string; $ends_with?: string } | Record<string, unknown>");
|
|
442
|
+
attioPreludeLines.push("type __AttioFilterExpression<TValues extends Record<string, unknown>> = Partial<{ [K in keyof TValues]: __AttioFilterValue<TValues[K]> }> & { $and?: Array<__AttioFilterExpression<TValues>>; $or?: Array<__AttioFilterExpression<TValues>> }");
|
|
505
443
|
attioPreludeLines.push('type __AttioRecordBase = NonNullable<NonNullable<ToolOutputByName["attio_upsert_record"]["records"]>[number]>');
|
|
506
444
|
attioPreludeLines.push('type __AttioRecordWithValues<TValues extends Record<string, unknown>> = Omit<__AttioRecordBase, "values"> & TValues & { values: TValues; attributes: TValues }');
|
|
507
|
-
attioPreludeLines.push(
|
|
445
|
+
attioPreludeLines.push("");
|
|
508
446
|
if (attioGeneratedObjects.length > 0) {
|
|
509
|
-
attioPreludeLines.push(
|
|
447
|
+
attioPreludeLines.push("export type GeneratedAttioObject =");
|
|
510
448
|
for (const object of attioGeneratedObjects) {
|
|
511
449
|
attioPreludeLines.push(` | typeof AttioObject.${object.staticName}`);
|
|
512
450
|
}
|
|
513
|
-
attioPreludeLines.push(
|
|
514
|
-
attioPreludeLines.push(
|
|
451
|
+
attioPreludeLines.push("");
|
|
452
|
+
attioPreludeLines.push("export type AttioInputValuesByObject = {");
|
|
515
453
|
for (const object of attioGeneratedObjects) {
|
|
516
|
-
const inputShape = object.attributes.length === 0
|
|
517
|
-
? 'Record<string, __AttioValue>'
|
|
518
|
-
: renderAttioObjectValueShape(object.attributes, "input");
|
|
454
|
+
const inputShape = object.attributes.length === 0 ? "Record<string, __AttioValue>" : renderAttioObjectValueShape(object.attributes, "input");
|
|
519
455
|
attioPreludeLines.push(` "${escapeString(object.apiSlug)}": ${inputShape}`);
|
|
520
456
|
}
|
|
521
|
-
attioPreludeLines.push(
|
|
522
|
-
attioPreludeLines.push(
|
|
523
|
-
attioPreludeLines.push(
|
|
457
|
+
attioPreludeLines.push("}");
|
|
458
|
+
attioPreludeLines.push("");
|
|
459
|
+
attioPreludeLines.push("export type AttioRecordValuesByObject = {");
|
|
524
460
|
for (const object of attioGeneratedObjects) {
|
|
525
|
-
const recordShape = object.attributes.length === 0
|
|
526
|
-
? 'Record<string, __AttioValue>'
|
|
527
|
-
: renderAttioObjectValueShape(object.attributes, "record");
|
|
461
|
+
const recordShape = object.attributes.length === 0 ? "Record<string, __AttioValue>" : renderAttioObjectValueShape(object.attributes, "record");
|
|
528
462
|
attioPreludeLines.push(` "${escapeString(object.apiSlug)}": ${recordShape}`);
|
|
529
463
|
}
|
|
530
|
-
attioPreludeLines.push(
|
|
531
|
-
attioPreludeLines.push(
|
|
532
|
-
attioPreludeLines.push(
|
|
464
|
+
attioPreludeLines.push("}");
|
|
465
|
+
attioPreludeLines.push("");
|
|
466
|
+
attioPreludeLines.push("export type AttioFilterByObject = {");
|
|
533
467
|
for (const object of attioGeneratedObjects) {
|
|
534
468
|
attioPreludeLines.push(` "${escapeString(object.apiSlug)}": __AttioFilterExpression<AttioRecordValuesByObject["${escapeString(object.apiSlug)}"]>`);
|
|
535
469
|
}
|
|
536
|
-
attioPreludeLines.push(
|
|
537
|
-
attioPreludeLines.push(
|
|
538
|
-
attioPreludeLines.push(
|
|
470
|
+
attioPreludeLines.push("}");
|
|
471
|
+
attioPreludeLines.push("");
|
|
472
|
+
attioPreludeLines.push("export type AttioRecordByObject = {");
|
|
539
473
|
for (const object of attioGeneratedObjects) {
|
|
540
474
|
attioPreludeLines.push(` "${escapeString(object.apiSlug)}": __AttioRecordWithValues<AttioRecordValuesByObject["${escapeString(object.apiSlug)}"]>`);
|
|
541
475
|
}
|
|
542
|
-
attioPreludeLines.push(
|
|
476
|
+
attioPreludeLines.push("}");
|
|
543
477
|
}
|
|
544
478
|
else {
|
|
545
|
-
attioPreludeLines.push(
|
|
546
|
-
attioPreludeLines.push(
|
|
547
|
-
attioPreludeLines.push(
|
|
548
|
-
attioPreludeLines.push(
|
|
549
|
-
attioPreludeLines.push(
|
|
479
|
+
attioPreludeLines.push("export type GeneratedAttioObject = AttioObject<string, Record<string, __AttioValue>, Record<string, __AttioValue>>");
|
|
480
|
+
attioPreludeLines.push("export type AttioInputValuesByObject = Record<string, Record<string, __AttioValue>>");
|
|
481
|
+
attioPreludeLines.push("export type AttioRecordValuesByObject = Record<string, Record<string, __AttioValue>>");
|
|
482
|
+
attioPreludeLines.push("export type AttioFilterByObject = Record<string, __AttioFilterExpression<Record<string, __AttioValue>>>");
|
|
483
|
+
attioPreludeLines.push("export type AttioRecordByObject = Record<string, __AttioRecordWithValues<Record<string, __AttioValue>>>");
|
|
550
484
|
}
|
|
551
|
-
attioPreludeLines.push(
|
|
485
|
+
attioPreludeLines.push("");
|
|
552
486
|
attioPreludeLines.push('export type AttioValuesFor<TObject extends GeneratedAttioObject = GeneratedAttioObject> = TObject extends { __inputValues: infer TInputValues } ? TInputValues : AttioInputValuesByObject[TObject["apiSlug"]]');
|
|
553
487
|
attioPreludeLines.push('export type AttioRecordValuesFor<TObject extends GeneratedAttioObject = GeneratedAttioObject> = TObject extends { __recordValues: infer TRecordValues } ? TRecordValues : AttioRecordValuesByObject[TObject["apiSlug"]]');
|
|
554
|
-
attioPreludeLines.push(
|
|
555
|
-
attioPreludeLines.push(
|
|
556
|
-
attioPreludeLines.push(
|
|
557
|
-
attioPreludeLines.push(
|
|
558
|
-
attioPreludeLines.push(
|
|
559
|
-
attioPreludeLines.push(
|
|
488
|
+
attioPreludeLines.push("export type AttioAttributeSlug<TObject extends GeneratedAttioObject = GeneratedAttioObject> = Extract<keyof AttioValuesFor<TObject>, string>");
|
|
489
|
+
attioPreludeLines.push("export type AttioFilterFor<TObject extends GeneratedAttioObject = GeneratedAttioObject> = __AttioFilterExpression<AttioRecordValuesFor<TObject>>");
|
|
490
|
+
attioPreludeLines.push("export type AttioRecordFor<TObject extends GeneratedAttioObject = GeneratedAttioObject> = __AttioRecordWithValues<AttioRecordValuesFor<TObject>>");
|
|
491
|
+
attioPreludeLines.push("export type AttioQueryRecordsParams<TObject extends GeneratedAttioObject = GeneratedAttioObject> = { object: TObject; filter?: AttioFilterFor<TObject> | null; limit?: number | null }");
|
|
492
|
+
attioPreludeLines.push("export type AttioUpsertRecordParams<TObject extends GeneratedAttioObject = GeneratedAttioObject> = { object: TObject; matchingAttribute: AttioAttributeSlug<TObject>; records: AttioValuesFor<TObject>[] }");
|
|
493
|
+
attioPreludeLines.push("export type AttioListObjectsParams = Record<string, never>");
|
|
560
494
|
attioPreludeLines.push('export type AttioQueryRecordsResult<TObject extends GeneratedAttioObject = GeneratedAttioObject> = Omit<ToolOutputByName["attio_query_records"], "records"> & { records: Array<AttioRecordFor<TObject>> }');
|
|
561
495
|
attioPreludeLines.push('export type AttioUpsertRecordResult<TObject extends GeneratedAttioObject = GeneratedAttioObject> = Omit<ToolOutputByName["attio_upsert_record"], "records"> & { records?: Array<AttioRecordFor<TObject>> }');
|
|
562
|
-
attioPreludeLines.push(
|
|
563
|
-
attioPreludeLines.push(
|
|
496
|
+
attioPreludeLines.push("");
|
|
497
|
+
attioPreludeLines.push("const __attioMetadataKeys = new Set([");
|
|
564
498
|
attioPreludeLines.push(' "active_from",');
|
|
565
499
|
attioPreludeLines.push(' "active_until",');
|
|
566
500
|
attioPreludeLines.push(' "attribute_type",');
|
|
567
501
|
attioPreludeLines.push(' "created_by_actor",');
|
|
568
|
-
attioPreludeLines.push(
|
|
569
|
-
attioPreludeLines.push(
|
|
570
|
-
attioPreludeLines.push(
|
|
502
|
+
attioPreludeLines.push("])");
|
|
503
|
+
attioPreludeLines.push("");
|
|
504
|
+
attioPreludeLines.push("const __attioMultiValueAttributeSlugsByObject: Record<string, readonly string[]> = {");
|
|
571
505
|
for (const object of attioGeneratedObjects) {
|
|
572
506
|
const multiValueSlugs = object.attributes
|
|
573
507
|
.filter(isProbablyAttioMultiValue)
|
|
@@ -575,94 +509,95 @@ function prepareToolsSection(tools, input) {
|
|
|
575
509
|
.join(", ");
|
|
576
510
|
attioPreludeLines.push(` "${escapeString(object.apiSlug)}": [${multiValueSlugs}],`);
|
|
577
511
|
}
|
|
578
|
-
attioPreludeLines.push(
|
|
579
|
-
attioPreludeLines.push(
|
|
580
|
-
attioPreludeLines.push(
|
|
512
|
+
attioPreludeLines.push("}");
|
|
513
|
+
attioPreludeLines.push("");
|
|
514
|
+
attioPreludeLines.push("function __normalizeAttioObjectSlug(object: unknown): string {");
|
|
581
515
|
attioPreludeLines.push(' if (object && typeof object === "object" && "apiSlug" in (object as Record<string, unknown>)) {');
|
|
582
|
-
attioPreludeLines.push(
|
|
516
|
+
attioPreludeLines.push(" const apiSlug = (object as { apiSlug?: unknown }).apiSlug");
|
|
583
517
|
attioPreludeLines.push(' if (typeof apiSlug === "string" && apiSlug.length > 0) return apiSlug');
|
|
584
|
-
attioPreludeLines.push(
|
|
518
|
+
attioPreludeLines.push(" }");
|
|
585
519
|
attioPreludeLines.push(' return typeof object === "string" ? object : ""');
|
|
586
|
-
attioPreludeLines.push(
|
|
587
|
-
attioPreludeLines.push(
|
|
588
|
-
attioPreludeLines.push(
|
|
589
|
-
attioPreludeLines.push(
|
|
590
|
-
attioPreludeLines.push(
|
|
591
|
-
attioPreludeLines.push(
|
|
592
|
-
attioPreludeLines.push(
|
|
593
|
-
attioPreludeLines.push(
|
|
594
|
-
attioPreludeLines.push(
|
|
520
|
+
attioPreludeLines.push("}");
|
|
521
|
+
attioPreludeLines.push("");
|
|
522
|
+
attioPreludeLines.push("function __serializeAttioFilter(filter: unknown): string | null {");
|
|
523
|
+
attioPreludeLines.push(" if (filter === undefined || filter === null) return null");
|
|
524
|
+
attioPreludeLines.push(" return JSON.stringify(filter)");
|
|
525
|
+
attioPreludeLines.push("}");
|
|
526
|
+
attioPreludeLines.push("");
|
|
527
|
+
attioPreludeLines.push("function __serializeAttioRecords(records: unknown): string {");
|
|
528
|
+
attioPreludeLines.push(" if (!Array.isArray(records)) return JSON.stringify([])");
|
|
595
529
|
attioPreludeLines.push(' return JSON.stringify(records.filter((record): record is Record<string, unknown> => typeof record === "object" && record !== null && !Array.isArray(record)))');
|
|
596
|
-
attioPreludeLines.push(
|
|
597
|
-
attioPreludeLines.push(
|
|
598
|
-
attioPreludeLines.push(
|
|
599
|
-
attioPreludeLines.push(
|
|
600
|
-
attioPreludeLines.push(
|
|
601
|
-
attioPreludeLines.push(
|
|
602
|
-
attioPreludeLines.push(
|
|
603
|
-
attioPreludeLines.push(
|
|
604
|
-
attioPreludeLines.push(
|
|
530
|
+
attioPreludeLines.push("}");
|
|
531
|
+
attioPreludeLines.push("");
|
|
532
|
+
attioPreludeLines.push("function __isAttioMultiValueAttribute(objectSlug: string, attributeSlug: string): boolean {");
|
|
533
|
+
attioPreludeLines.push(" return (__attioMultiValueAttributeSlugsByObject[objectSlug] || []).includes(attributeSlug)");
|
|
534
|
+
attioPreludeLines.push("}");
|
|
535
|
+
attioPreludeLines.push("");
|
|
536
|
+
attioPreludeLines.push("function __flattenAttioLeafValue(value: unknown): unknown {");
|
|
537
|
+
attioPreludeLines.push(" if (value === null || value === undefined) return value");
|
|
538
|
+
attioPreludeLines.push(" if (Array.isArray(value)) return value.map(entry => __flattenAttioLeafValue(entry))");
|
|
605
539
|
attioPreludeLines.push(' if (typeof value !== "object") return value');
|
|
606
|
-
attioPreludeLines.push(
|
|
540
|
+
attioPreludeLines.push(" const rawObject = value as Record<string, unknown>");
|
|
607
541
|
attioPreludeLines.push(' if (typeof rawObject.full_name === "string") return rawObject.full_name');
|
|
608
542
|
attioPreludeLines.push(' if (typeof rawObject.email_address === "string") return rawObject.email_address');
|
|
609
543
|
attioPreludeLines.push(' if (typeof rawObject.domain === "string") return rawObject.domain');
|
|
610
544
|
attioPreludeLines.push(' if (typeof rawObject.phone_number === "string") return rawObject.phone_number');
|
|
611
545
|
attioPreludeLines.push(' if ("value" in rawObject) return __flattenAttioLeafValue(rawObject.value)');
|
|
612
|
-
attioPreludeLines.push(
|
|
613
|
-
attioPreludeLines.push(
|
|
614
|
-
attioPreludeLines.push(
|
|
615
|
-
attioPreludeLines.push(
|
|
616
|
-
attioPreludeLines.push(
|
|
617
|
-
attioPreludeLines.push(
|
|
618
|
-
attioPreludeLines.push(
|
|
619
|
-
attioPreludeLines.push(
|
|
620
|
-
attioPreludeLines.push(
|
|
621
|
-
attioPreludeLines.push(
|
|
622
|
-
attioPreludeLines.push(
|
|
623
|
-
attioPreludeLines.push(
|
|
624
|
-
attioPreludeLines.push(
|
|
625
|
-
attioPreludeLines.push(
|
|
626
|
-
attioPreludeLines.push(
|
|
546
|
+
attioPreludeLines.push(" const dataEntries = Object.entries(rawObject).filter(([key]) => !__attioMetadataKeys.has(key))");
|
|
547
|
+
attioPreludeLines.push(" if (dataEntries.length === 0) return rawObject");
|
|
548
|
+
attioPreludeLines.push(" if (dataEntries.length === 1) return __flattenAttioLeafValue(dataEntries[0][1])");
|
|
549
|
+
attioPreludeLines.push(" return Object.fromEntries(dataEntries.map(([key, entryValue]) => [key, __flattenAttioLeafValue(entryValue)]))");
|
|
550
|
+
attioPreludeLines.push("}");
|
|
551
|
+
attioPreludeLines.push("");
|
|
552
|
+
attioPreludeLines.push("function __flattenAttioAttributeValue(rawValue: unknown, preferArray: boolean): unknown {");
|
|
553
|
+
attioPreludeLines.push(" if (!Array.isArray(rawValue)) return __flattenAttioLeafValue(rawValue)");
|
|
554
|
+
attioPreludeLines.push(" const flattened = rawValue");
|
|
555
|
+
attioPreludeLines.push(" .map(entry => __flattenAttioLeafValue(entry))");
|
|
556
|
+
attioPreludeLines.push(" .filter(entry => entry !== undefined)");
|
|
557
|
+
attioPreludeLines.push(" return preferArray ? flattened : flattened[0]");
|
|
558
|
+
attioPreludeLines.push("}");
|
|
559
|
+
attioPreludeLines.push("");
|
|
560
|
+
attioPreludeLines.push("function __getAttioRecordValues<TValues extends Record<string, unknown>>(objectSlug: string, record: unknown): TValues {");
|
|
627
561
|
attioPreludeLines.push(' const rawValues = record && typeof record === "object" ? (record as { values?: unknown }).values : undefined');
|
|
628
562
|
attioPreludeLines.push(' if (!rawValues || typeof rawValues !== "object" || Array.isArray(rawValues)) return {} as TValues');
|
|
629
|
-
attioPreludeLines.push(
|
|
630
|
-
attioPreludeLines.push(
|
|
631
|
-
attioPreludeLines.push(
|
|
632
|
-
attioPreludeLines.push(
|
|
633
|
-
attioPreludeLines.push(
|
|
634
|
-
attioPreludeLines.push(
|
|
635
|
-
attioPreludeLines.push(
|
|
636
|
-
attioPreludeLines.push(
|
|
563
|
+
attioPreludeLines.push(" const flattenedValues: Record<string, unknown> = {}");
|
|
564
|
+
attioPreludeLines.push(" for (const [attributeSlug, rawValue] of Object.entries(rawValues)) {");
|
|
565
|
+
attioPreludeLines.push(" flattenedValues[attributeSlug] = __flattenAttioAttributeValue(rawValue, __isAttioMultiValueAttribute(objectSlug, attributeSlug))");
|
|
566
|
+
attioPreludeLines.push(" }");
|
|
567
|
+
attioPreludeLines.push(" return flattenedValues as TValues");
|
|
568
|
+
attioPreludeLines.push("}");
|
|
569
|
+
attioPreludeLines.push("");
|
|
570
|
+
attioPreludeLines.push("function __enhanceAttioRecord<TObject extends GeneratedAttioObject>(object: TObject, record: unknown): __AttioRecordWithValues<AttioRecordValuesFor<TObject>> | undefined {");
|
|
637
571
|
attioPreludeLines.push(' if (!record || typeof record !== "object") return undefined');
|
|
638
|
-
attioPreludeLines.push(
|
|
639
|
-
attioPreludeLines.push(
|
|
640
|
-
attioPreludeLines.push(
|
|
641
|
-
attioPreludeLines.push(
|
|
572
|
+
attioPreludeLines.push(" const values = __getAttioRecordValues<AttioRecordValuesFor<TObject>>(__normalizeAttioObjectSlug(object), record)");
|
|
573
|
+
attioPreludeLines.push(" return { ...values, ...(record as __AttioRecordBase), values, attributes: values } as __AttioRecordWithValues<AttioRecordValuesFor<TObject>>");
|
|
574
|
+
attioPreludeLines.push("}");
|
|
575
|
+
attioPreludeLines.push("");
|
|
642
576
|
attioPreludeLines.push('function __enhanceAttioQueryResult<TObject extends GeneratedAttioObject>(object: TObject, result: ToolOutputByName["attio_query_records"]): AttioQueryRecordsResult<TObject> {');
|
|
643
|
-
attioPreludeLines.push(
|
|
644
|
-
attioPreludeLines.push(
|
|
645
|
-
attioPreludeLines.push(
|
|
646
|
-
attioPreludeLines.push(
|
|
647
|
-
attioPreludeLines.push(
|
|
648
|
-
attioPreludeLines.push(
|
|
577
|
+
attioPreludeLines.push(" return {");
|
|
578
|
+
attioPreludeLines.push(" ...result,");
|
|
579
|
+
attioPreludeLines.push(" records: (result.records || []).map(record => __enhanceAttioRecord(object, record)).filter(Boolean) as Array<AttioRecordFor<TObject>>,");
|
|
580
|
+
attioPreludeLines.push(" }");
|
|
581
|
+
attioPreludeLines.push("}");
|
|
582
|
+
attioPreludeLines.push("");
|
|
649
583
|
attioPreludeLines.push('function __enhanceAttioUpsertResult<TObject extends GeneratedAttioObject>(object: TObject, result: ToolOutputByName["attio_upsert_record"]): AttioUpsertRecordResult<TObject> {');
|
|
650
|
-
attioPreludeLines.push(
|
|
651
|
-
attioPreludeLines.push(
|
|
652
|
-
attioPreludeLines.push(
|
|
653
|
-
attioPreludeLines.push(
|
|
654
|
-
attioPreludeLines.push(
|
|
655
|
-
attioPreludeLines.push(
|
|
584
|
+
attioPreludeLines.push(" return {");
|
|
585
|
+
attioPreludeLines.push(" ...result,");
|
|
586
|
+
attioPreludeLines.push(" records: (result.records || []).map(record => __enhanceAttioRecord(object, record)).filter(Boolean) as Array<AttioRecordFor<TObject>>,");
|
|
587
|
+
attioPreludeLines.push(" }");
|
|
588
|
+
attioPreludeLines.push("}");
|
|
589
|
+
attioPreludeLines.push("");
|
|
656
590
|
}
|
|
657
591
|
const paramTypes = [];
|
|
658
592
|
for (const tool of tools) {
|
|
659
593
|
if (isAttioTool(tool))
|
|
660
594
|
continue;
|
|
661
|
-
const
|
|
595
|
+
const key = `"${escapeString(tool.name)}"`;
|
|
596
|
+
const tsType = hasAutoFillId(tool) ? `Omit<ToolInputByName[${key}], "integrationId">` : `ToolInputByName[${key}]`;
|
|
662
597
|
paramTypes.push({
|
|
663
598
|
description: tool.description || undefined,
|
|
664
599
|
typeName: toolNameToInterfaceName(tool.name),
|
|
665
|
-
tsType
|
|
600
|
+
tsType
|
|
666
601
|
});
|
|
667
602
|
}
|
|
668
603
|
const rawGroups = [];
|
|
@@ -681,9 +616,7 @@ function prepareToolsSection(tools, input) {
|
|
|
681
616
|
rawGroups.sort((a, b) => a.key.localeCompare(b.key));
|
|
682
617
|
const githubRepoMappings = [];
|
|
683
618
|
if (rawGroups.some(group => group.integration === "github")) {
|
|
684
|
-
const githubRepoFullNames = Array.from(new Set(input.github.flatMap(inst => inst.repositories
|
|
685
|
-
.map(repo => (repo.owner && repo.name ? `${repo.owner}/${repo.name}` : repo.name).trim())
|
|
686
|
-
.filter(Boolean))));
|
|
619
|
+
const githubRepoFullNames = Array.from(new Set(input.github.flatMap(inst => inst.repositories.map(repo => (repo.owner && repo.name ? `${repo.owner}/${repo.name}` : repo.name).trim()).filter(Boolean))));
|
|
687
620
|
const nameToFullName = new Map();
|
|
688
621
|
const ambiguousNames = new Set();
|
|
689
622
|
for (const fullName of githubRepoFullNames) {
|
|
@@ -724,39 +657,39 @@ function prepareToolsSection(tools, input) {
|
|
|
724
657
|
if (group.integration === "attio" && tool.name === "attio_query_records" && group.integrationId) {
|
|
725
658
|
runtimeLines = [
|
|
726
659
|
`${methodName}: <TObject extends GeneratedAttioObject>(params: AttioQueryRecordsParams<TObject>) =>`,
|
|
727
|
-
` agent.executeTool<ToolOutputByName["${escapeString(tool.name)}"]>("${escapeString(tool.name)}", { objectSlug: __normalizeAttioObjectSlug(params.object), filter: __serializeAttioFilter(params.filter), limit: params.limit ?? null, integrationId: "${escapeString(group.integrationId)}" }).then(result => __enhanceAttioQueryResult(params.object, result))
|
|
660
|
+
` agent.executeTool<ToolOutputByName["${escapeString(tool.name)}"]>("${escapeString(tool.name)}", { objectSlug: __normalizeAttioObjectSlug(params.object), filter: __serializeAttioFilter(params.filter), limit: params.limit ?? null, integrationId: "${escapeString(group.integrationId)}" }).then(result => __enhanceAttioQueryResult(params.object, result)),`
|
|
728
661
|
];
|
|
729
662
|
}
|
|
730
663
|
else if (group.integration === "attio" && tool.name === "attio_upsert_record" && group.integrationId) {
|
|
731
664
|
runtimeLines = [
|
|
732
665
|
`${methodName}: <TObject extends GeneratedAttioObject>(params: AttioUpsertRecordParams<TObject>) =>`,
|
|
733
|
-
` agent.executeTool<ToolOutputByName["${escapeString(tool.name)}"]>("${escapeString(tool.name)}", { objectSlug: __normalizeAttioObjectSlug(params.object), matchingAttribute: params.matchingAttribute, records: __serializeAttioRecords(params.records), integrationId: "${escapeString(group.integrationId)}" }).then(result => __enhanceAttioUpsertResult(params.object, result))
|
|
666
|
+
` agent.executeTool<ToolOutputByName["${escapeString(tool.name)}"]>("${escapeString(tool.name)}", { objectSlug: __normalizeAttioObjectSlug(params.object), matchingAttribute: params.matchingAttribute, records: __serializeAttioRecords(params.records), integrationId: "${escapeString(group.integrationId)}" }).then(result => __enhanceAttioUpsertResult(params.object, result)),`
|
|
734
667
|
];
|
|
735
668
|
}
|
|
736
669
|
else if (group.integration === "attio" && tool.name === "attio_list_objects" && group.integrationId) {
|
|
737
670
|
runtimeLines = [
|
|
738
671
|
`${methodName}: (params: AttioListObjectsParams = {}) =>`,
|
|
739
|
-
` agent.executeTool<ToolOutputByName["${escapeString(tool.name)}"]>("${escapeString(tool.name)}", { ...params, integrationId: "${escapeString(group.integrationId)}" })
|
|
672
|
+
` agent.executeTool<ToolOutputByName["${escapeString(tool.name)}"]>("${escapeString(tool.name)}", { ...params, integrationId: "${escapeString(group.integrationId)}" }),`
|
|
740
673
|
];
|
|
741
674
|
}
|
|
742
675
|
else if (group.integrationId && hasAutoFillId(tool)) {
|
|
743
676
|
runtimeLines = [
|
|
744
677
|
`${methodName}: (params: ${paramsType}) =>`,
|
|
745
|
-
` agent.executeTool<ToolOutputByName["${escapeString(tool.name)}"]>("${escapeString(tool.name)}", { ...(${normalizedParamsExpr}), integrationId: "${escapeString(group.integrationId)}" })
|
|
678
|
+
` agent.executeTool<ToolOutputByName["${escapeString(tool.name)}"]>("${escapeString(tool.name)}", { ...(${normalizedParamsExpr}), integrationId: "${escapeString(group.integrationId)}" }),`
|
|
746
679
|
];
|
|
747
680
|
}
|
|
748
681
|
else {
|
|
749
682
|
runtimeLines = [
|
|
750
683
|
`${methodName}: (params: ${paramsType}) =>`,
|
|
751
|
-
` agent.executeTool<ToolOutputByName["${escapeString(tool.name)}"]>("${escapeString(tool.name)}", ${normalizedParamsExpr})
|
|
684
|
+
` agent.executeTool<ToolOutputByName["${escapeString(tool.name)}"]>("${escapeString(tool.name)}", ${normalizedParamsExpr}),`
|
|
752
685
|
];
|
|
753
686
|
}
|
|
754
687
|
return {
|
|
755
688
|
description: tool.description || undefined,
|
|
756
689
|
generatedSignature,
|
|
757
|
-
runtimeLines
|
|
690
|
+
runtimeLines
|
|
758
691
|
};
|
|
759
|
-
})
|
|
692
|
+
})
|
|
760
693
|
}));
|
|
761
694
|
return {
|
|
762
695
|
imports,
|
|
@@ -764,13 +697,13 @@ function prepareToolsSection(tools, input) {
|
|
|
764
697
|
attioPreludeLines,
|
|
765
698
|
paramTypes,
|
|
766
699
|
githubRepoMappings,
|
|
767
|
-
groups
|
|
768
|
-
}
|
|
700
|
+
groups
|
|
701
|
+
}
|
|
769
702
|
};
|
|
770
703
|
}
|
|
771
704
|
function prepareSystemSection(tools) {
|
|
772
|
-
return sectionData(["TimeTriggerConfig", "TerseConfig", "TypedSkill"], {
|
|
773
|
-
skillToolType: buildSkillToolTypeForIntegration(tools, "terse")
|
|
705
|
+
return sectionData(["TimeTriggerConfig", "TerseConfig", "TypedSkill", "WebhookInputConfig", "WebhookInputEvent", "TypedTrigger"], {
|
|
706
|
+
skillToolType: buildSkillToolTypeForIntegration(tools, "terse")
|
|
774
707
|
});
|
|
775
708
|
}
|
|
776
709
|
export function prepareTemplateContext(input) {
|
|
@@ -790,23 +723,7 @@ export function prepareTemplateContext(input) {
|
|
|
790
723
|
const snowflake = prepareSnowflakeSection(input.snowflake, input.tools);
|
|
791
724
|
const tools = prepareToolsSection(input.tools, input);
|
|
792
725
|
const system = prepareSystemSection(input.tools);
|
|
793
|
-
const sections = [
|
|
794
|
-
github,
|
|
795
|
-
gmail,
|
|
796
|
-
slack,
|
|
797
|
-
figma,
|
|
798
|
-
linear,
|
|
799
|
-
atlassian,
|
|
800
|
-
notion,
|
|
801
|
-
posthog,
|
|
802
|
-
datadog,
|
|
803
|
-
launchdarkly,
|
|
804
|
-
workos,
|
|
805
|
-
attio,
|
|
806
|
-
snowflake,
|
|
807
|
-
tools,
|
|
808
|
-
system,
|
|
809
|
-
];
|
|
726
|
+
const sections = [github, gmail, slack, figma, linear, atlassian, notion, posthog, datadog, launchdarkly, workos, attio, snowflake, tools, system];
|
|
810
727
|
for (const section of sections) {
|
|
811
728
|
section.imports.forEach(value => allImports.add(value));
|
|
812
729
|
}
|
|
@@ -828,7 +745,7 @@ export function prepareTemplateContext(input) {
|
|
|
828
745
|
attio: attio.data,
|
|
829
746
|
snowflake: snowflake.data,
|
|
830
747
|
tools: tools.data,
|
|
831
|
-
system: system.data
|
|
748
|
+
system: system.data
|
|
832
749
|
};
|
|
833
750
|
}
|
|
834
751
|
//# sourceMappingURL=prepareCodegenData.js.map
|