@zapier/zapier-sdk-cli 0.13.5 → 0.13.7
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/CHANGELOG.md +21 -0
- package/README.md +39 -0
- package/dist/cli.cjs +360 -82
- package/dist/cli.mjs +356 -78
- package/dist/index.cjs +359 -81
- package/dist/index.d.mts +155 -3
- package/dist/index.d.ts +155 -3
- package/dist/index.mjs +355 -77
- package/dist/package.json +1 -1
- package/dist/src/plugins/add/index.d.ts +4 -2
- package/dist/src/plugins/add/index.js +89 -98
- package/dist/src/plugins/buildManifest/index.d.ts +13 -0
- package/dist/src/plugins/buildManifest/index.js +81 -0
- package/dist/src/plugins/buildManifest/schemas.d.ts +56 -0
- package/dist/src/plugins/buildManifest/schemas.js +17 -0
- package/dist/src/plugins/generateAppTypes/index.d.ts +13 -0
- package/dist/src/plugins/generateAppTypes/index.js +169 -0
- package/dist/src/plugins/generateAppTypes/schemas.d.ts +72 -0
- package/dist/src/plugins/generateAppTypes/schemas.js +21 -0
- package/dist/src/plugins/index.d.ts +2 -0
- package/dist/src/plugins/index.js +2 -0
- package/dist/src/sdk.d.ts +4 -3
- package/dist/src/sdk.js +16 -14
- package/dist/src/types/sdk.d.ts +5 -0
- package/dist/src/types/sdk.js +1 -0
- package/dist/src/utils/constants.d.ts +1 -3
- package/dist/src/utils/constants.js +3 -4
- package/dist/src/utils/directory-detection.d.ts +5 -0
- package/dist/src/utils/directory-detection.js +21 -0
- package/dist/src/utils/manifest-helpers.d.ts +10 -0
- package/dist/src/utils/manifest-helpers.js +19 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/plugins/add/index.ts +123 -125
- package/src/plugins/buildManifest/index.test.ts +612 -0
- package/src/plugins/buildManifest/index.ts +128 -0
- package/src/plugins/buildManifest/schemas.ts +59 -0
- package/src/plugins/generateAppTypes/index.ts +235 -0
- package/src/plugins/generateAppTypes/schemas.ts +65 -0
- package/src/plugins/index.ts +2 -0
- package/src/sdk.ts +25 -21
- package/src/types/sdk.ts +8 -0
- package/src/utils/constants.ts +7 -6
- package/src/utils/directory-detection.ts +23 -0
- package/src/utils/manifest-helpers.ts +25 -0
- /package/dist/src/{plugins/add → generators}/ast-generator.d.ts +0 -0
- /package/dist/src/{plugins/add → generators}/ast-generator.js +0 -0
- /package/src/{plugins/add → generators}/ast-generator.ts +0 -0
package/dist/index.mjs
CHANGED
|
@@ -3,26 +3,21 @@ import open from 'open';
|
|
|
3
3
|
import crypto from 'crypto';
|
|
4
4
|
import express from 'express';
|
|
5
5
|
import pkceChallenge from 'pkce-challenge';
|
|
6
|
+
import { getLoggedInUser, logout, ZAPIER_BASE, LOGIN_CLIENT_ID, AUTH_MODE_HEADER, updateLogin, getConfigPath } from '@zapier/zapier-sdk-cli-login';
|
|
6
7
|
import ora from 'ora';
|
|
7
8
|
import chalk from 'chalk';
|
|
8
|
-
import { getLoggedInUser, logout, updateLogin, getConfigPath } from '@zapier/zapier-sdk-cli-login';
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
import { startMcpServerAsProcess } from '@zapier/zapier-sdk-mcp';
|
|
11
11
|
import { buildSync } from 'esbuild';
|
|
12
12
|
import * as fs from 'fs';
|
|
13
13
|
import * as path from 'path';
|
|
14
|
-
import {
|
|
15
|
-
import * as ts from 'typescript';
|
|
14
|
+
import { join, resolve } from 'path';
|
|
16
15
|
import { mkdir, writeFile, access } from 'fs/promises';
|
|
16
|
+
import * as ts from 'typescript';
|
|
17
17
|
|
|
18
18
|
// src/sdk.ts
|
|
19
|
-
|
|
20
|
-
// src/utils/constants.ts
|
|
21
|
-
var ZAPIER_BASE = "https://zapier.com";
|
|
22
|
-
var LOGIN_CLIENT_ID = "K5eEnRE9TTmSFATdkkWhKF8NOKwoiOnYAyIqJjae";
|
|
23
19
|
var LOGIN_PORTS = [49505, 50575, 52804, 55981, 61010, 63851];
|
|
24
20
|
var LOGIN_TIMEOUT_MS = 3e5;
|
|
25
|
-
var AUTH_MODE_HEADER = "X-Auth";
|
|
26
21
|
var spinPromise = async (promise, text) => {
|
|
27
22
|
const spinner = ora(text).start();
|
|
28
23
|
try {
|
|
@@ -232,7 +227,7 @@ var LoginSchema = z.object({
|
|
|
232
227
|
|
|
233
228
|
// package.json
|
|
234
229
|
var package_default = {
|
|
235
|
-
version: "0.13.
|
|
230
|
+
version: "0.13.7"};
|
|
236
231
|
|
|
237
232
|
// src/telemetry/builders.ts
|
|
238
233
|
function createCliBaseEvent(context = {}) {
|
|
@@ -520,6 +515,146 @@ var AddSchema = z.object({
|
|
|
520
515
|
}).describe(
|
|
521
516
|
"Add apps with manifest locking and TypeScript type generation - updates .zapierrc with app versions and generates TypeScript definition files"
|
|
522
517
|
);
|
|
518
|
+
async function detectTypesOutputDirectory() {
|
|
519
|
+
const candidates = ["src", "lib"];
|
|
520
|
+
for (const candidate of candidates) {
|
|
521
|
+
try {
|
|
522
|
+
await access(candidate);
|
|
523
|
+
return join(candidate, "zapier", "apps");
|
|
524
|
+
} catch {
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return "./zapier/apps/";
|
|
528
|
+
}
|
|
529
|
+
var addPlugin = ({ sdk }) => {
|
|
530
|
+
const add = createFunction(async function add2(options) {
|
|
531
|
+
const {
|
|
532
|
+
appKeys,
|
|
533
|
+
authenticationIds,
|
|
534
|
+
configPath,
|
|
535
|
+
typesOutput = await detectTypesOutputDirectory()
|
|
536
|
+
} = options;
|
|
537
|
+
const resolvedTypesOutput = resolve(typesOutput);
|
|
538
|
+
console.log(`\u{1F4E6} Adding ${appKeys.length} app(s)...`);
|
|
539
|
+
const appSlugAndKeyMap = /* @__PURE__ */ new Map();
|
|
540
|
+
const handleManifestProgress = (event) => {
|
|
541
|
+
switch (event.type) {
|
|
542
|
+
case "apps_lookup_start":
|
|
543
|
+
console.log(`\u{1F4E6} Looking up ${event.count} app(s)...`);
|
|
544
|
+
break;
|
|
545
|
+
case "app_found":
|
|
546
|
+
const displayName = event.app.slug ? `${event.app.slug} (${event.app.key})` : event.app.key;
|
|
547
|
+
appSlugAndKeyMap.set(event.app.key, displayName);
|
|
548
|
+
break;
|
|
549
|
+
case "apps_lookup_complete":
|
|
550
|
+
if (event.count === 0) {
|
|
551
|
+
console.warn("\u26A0\uFE0F No apps found");
|
|
552
|
+
}
|
|
553
|
+
break;
|
|
554
|
+
case "app_processing_start":
|
|
555
|
+
const appName = event.slug ? `${event.slug} (${event.appKey})` : event.appKey;
|
|
556
|
+
console.log(`\u{1F4E6} Adding ${appName}...`);
|
|
557
|
+
break;
|
|
558
|
+
case "manifest_updated":
|
|
559
|
+
const appDisplay = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
560
|
+
console.log(
|
|
561
|
+
`\u{1F4DD} Locked ${appDisplay} to ${event.appKey}@${event.version} using key '${event.manifestKey}'`
|
|
562
|
+
);
|
|
563
|
+
break;
|
|
564
|
+
case "app_processing_error":
|
|
565
|
+
const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
566
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
const handleTypesProgress = (event) => {
|
|
571
|
+
switch (event.type) {
|
|
572
|
+
case "authentications_lookup_start":
|
|
573
|
+
console.log(`\u{1F510} Looking up ${event.count} authentication(s)...`);
|
|
574
|
+
break;
|
|
575
|
+
case "authentications_lookup_complete":
|
|
576
|
+
console.log(`\u{1F510} Found ${event.count} authentication(s)`);
|
|
577
|
+
break;
|
|
578
|
+
case "authentication_matched":
|
|
579
|
+
const appWithAuth = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
580
|
+
console.log(
|
|
581
|
+
`\u{1F510} Using authentication ${event.authenticationId} (${event.authenticationTitle}) for ${appWithAuth}`
|
|
582
|
+
);
|
|
583
|
+
break;
|
|
584
|
+
case "authentication_not_matched":
|
|
585
|
+
const appWithoutAuth = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
586
|
+
console.warn(
|
|
587
|
+
`\u26A0\uFE0F No matching authentication found for ${appWithoutAuth}`
|
|
588
|
+
);
|
|
589
|
+
break;
|
|
590
|
+
case "file_written":
|
|
591
|
+
console.log(
|
|
592
|
+
`\u{1F527} Generated types for ${event.manifestKey} at ${event.filePath}`
|
|
593
|
+
);
|
|
594
|
+
break;
|
|
595
|
+
case "app_processing_error":
|
|
596
|
+
const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
597
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
const manifestResult = await sdk.buildManifest({
|
|
602
|
+
appKeys,
|
|
603
|
+
skipWrite: false,
|
|
604
|
+
configPath,
|
|
605
|
+
onProgress: handleManifestProgress
|
|
606
|
+
});
|
|
607
|
+
const typesResult = await sdk.generateAppTypes({
|
|
608
|
+
appKeys,
|
|
609
|
+
authenticationIds,
|
|
610
|
+
skipWrite: false,
|
|
611
|
+
typesOutputDirectory: resolvedTypesOutput,
|
|
612
|
+
onProgress: handleTypesProgress
|
|
613
|
+
});
|
|
614
|
+
const results = manifestResult.manifest?.apps || {};
|
|
615
|
+
const successfulApps = Object.keys(results).filter(
|
|
616
|
+
(manifestKey) => typesResult.writtenFiles?.[manifestKey]
|
|
617
|
+
);
|
|
618
|
+
if (successfulApps.length > 0) {
|
|
619
|
+
console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
|
|
620
|
+
}
|
|
621
|
+
const allErrors = [...manifestResult.errors, ...typesResult.errors];
|
|
622
|
+
if (allErrors.length > 0) {
|
|
623
|
+
console.warn(`
|
|
624
|
+
\u26A0\uFE0F ${allErrors.length} error(s) occurred:`);
|
|
625
|
+
allErrors.forEach(({ appKey, error }) => {
|
|
626
|
+
console.warn(` - ${appKey}: ${error}`);
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
}, AddSchema);
|
|
630
|
+
return {
|
|
631
|
+
add,
|
|
632
|
+
context: {
|
|
633
|
+
meta: {
|
|
634
|
+
add: {
|
|
635
|
+
categories: ["utility"],
|
|
636
|
+
inputSchema: AddSchema
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
};
|
|
642
|
+
var GenerateAppTypesSchema = z.object({
|
|
643
|
+
appKeys: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
644
|
+
"One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
|
|
645
|
+
),
|
|
646
|
+
authenticationIds: z.array(z.string()).optional().describe(
|
|
647
|
+
"Authentication IDs to use for type generation (e.g., ['123', '456'])"
|
|
648
|
+
),
|
|
649
|
+
skipWrite: z.boolean().optional().describe(
|
|
650
|
+
"If true, returns type definitions without writing to disk. If false or omitted, writes type files."
|
|
651
|
+
),
|
|
652
|
+
typesOutputDirectory: z.string().optional().describe(
|
|
653
|
+
"Directory for TypeScript type files. Required when skipWrite is false or omitted."
|
|
654
|
+
)
|
|
655
|
+
}).describe(
|
|
656
|
+
"Generate TypeScript type definitions for apps - can optionally write to disk or just return type strings"
|
|
657
|
+
);
|
|
523
658
|
var AstTypeGenerator = class {
|
|
524
659
|
constructor() {
|
|
525
660
|
this.factory = ts.factory;
|
|
@@ -1088,69 +1223,92 @@ Usage:
|
|
|
1088
1223
|
return Array.from(allKeys);
|
|
1089
1224
|
}
|
|
1090
1225
|
};
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1226
|
+
|
|
1227
|
+
// src/utils/manifest-helpers.ts
|
|
1228
|
+
function getManifestKey(app) {
|
|
1229
|
+
return app.slug || app.key;
|
|
1230
|
+
}
|
|
1231
|
+
function createManifestEntry(app) {
|
|
1232
|
+
if (!app.version) {
|
|
1233
|
+
throw new Error(
|
|
1234
|
+
`App ${app.key} does not have a version. Implementation ID: ${app.implementation_id}`
|
|
1235
|
+
);
|
|
1099
1236
|
}
|
|
1100
|
-
return
|
|
1237
|
+
return {
|
|
1238
|
+
implementationName: app.key,
|
|
1239
|
+
version: app.version
|
|
1240
|
+
};
|
|
1101
1241
|
}
|
|
1102
|
-
var
|
|
1103
|
-
const
|
|
1242
|
+
var generateAppTypesPlugin = ({ sdk }) => {
|
|
1243
|
+
const generateAppTypes = createFunction(async function generateAppTypes2(options) {
|
|
1104
1244
|
const {
|
|
1105
1245
|
appKeys,
|
|
1106
1246
|
authenticationIds,
|
|
1107
|
-
|
|
1108
|
-
|
|
1247
|
+
skipWrite = false,
|
|
1248
|
+
typesOutputDirectory,
|
|
1249
|
+
onProgress
|
|
1109
1250
|
} = options;
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1251
|
+
if (!skipWrite && !typesOutputDirectory) {
|
|
1252
|
+
throw new Error(
|
|
1253
|
+
"typesOutputDirectory is required when skipWrite is false"
|
|
1254
|
+
);
|
|
1255
|
+
}
|
|
1256
|
+
const result = {
|
|
1257
|
+
typeDefinitions: {},
|
|
1258
|
+
errors: []
|
|
1259
|
+
};
|
|
1260
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
1113
1261
|
const appsIterator = sdk.listApps({ appKeys }).items();
|
|
1114
1262
|
const apps = [];
|
|
1115
1263
|
for await (const app of appsIterator) {
|
|
1116
1264
|
apps.push(app);
|
|
1265
|
+
onProgress?.({ type: "app_found", app });
|
|
1117
1266
|
}
|
|
1267
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
1118
1268
|
if (apps.length === 0) {
|
|
1119
|
-
|
|
1120
|
-
return;
|
|
1269
|
+
return result;
|
|
1121
1270
|
}
|
|
1122
|
-
|
|
1271
|
+
const authentications = [];
|
|
1123
1272
|
if (authenticationIds && authenticationIds.length > 0) {
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1273
|
+
onProgress?.({
|
|
1274
|
+
type: "authentications_lookup_start",
|
|
1275
|
+
count: authenticationIds.length
|
|
1276
|
+
});
|
|
1127
1277
|
const authsIterator = sdk.listAuthentications({ authenticationIds }).items();
|
|
1128
1278
|
for await (const auth of authsIterator) {
|
|
1129
1279
|
authentications.push(auth);
|
|
1130
1280
|
}
|
|
1131
|
-
|
|
1281
|
+
onProgress?.({
|
|
1282
|
+
type: "authentications_lookup_complete",
|
|
1283
|
+
count: authentications.length
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
if (!skipWrite && typesOutputDirectory) {
|
|
1287
|
+
await mkdir(typesOutputDirectory, { recursive: true });
|
|
1288
|
+
}
|
|
1289
|
+
if (!skipWrite) {
|
|
1290
|
+
result.writtenFiles = {};
|
|
1132
1291
|
}
|
|
1133
1292
|
for (const app of apps) {
|
|
1134
|
-
|
|
1135
|
-
|
|
1293
|
+
onProgress?.({
|
|
1294
|
+
type: "app_processing_start",
|
|
1295
|
+
appKey: app.key,
|
|
1296
|
+
slug: app.slug
|
|
1297
|
+
});
|
|
1136
1298
|
try {
|
|
1137
1299
|
if (!app.version) {
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1300
|
+
const error = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
|
|
1301
|
+
result.errors.push({
|
|
1302
|
+
appKey: app.key,
|
|
1303
|
+
error
|
|
1304
|
+
});
|
|
1305
|
+
onProgress?.({
|
|
1306
|
+
type: "app_processing_error",
|
|
1307
|
+
appKey: app.key,
|
|
1308
|
+
error
|
|
1309
|
+
});
|
|
1141
1310
|
continue;
|
|
1142
1311
|
}
|
|
1143
|
-
const [manifestKey] = await context.updateManifestEntry(
|
|
1144
|
-
app.key,
|
|
1145
|
-
{
|
|
1146
|
-
implementationName: app.key,
|
|
1147
|
-
version: app.version
|
|
1148
|
-
},
|
|
1149
|
-
configPath
|
|
1150
|
-
);
|
|
1151
|
-
console.log(
|
|
1152
|
-
`\u{1F4DD} Locked ${appSlugAndKey} to ${app.key}@${app.version} using key '${manifestKey}'`
|
|
1153
|
-
);
|
|
1154
1312
|
let authenticationId;
|
|
1155
1313
|
if (authentications.length > 0) {
|
|
1156
1314
|
const matchingAuth = authentications.find((auth) => {
|
|
@@ -1158,43 +1316,171 @@ var addPlugin = ({ sdk, context }) => {
|
|
|
1158
1316
|
});
|
|
1159
1317
|
if (matchingAuth) {
|
|
1160
1318
|
authenticationId = matchingAuth.id;
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1319
|
+
onProgress?.({
|
|
1320
|
+
type: "authentication_matched",
|
|
1321
|
+
appKey: app.key,
|
|
1322
|
+
authenticationId: matchingAuth.id,
|
|
1323
|
+
authenticationTitle: matchingAuth.title || ""
|
|
1324
|
+
});
|
|
1164
1325
|
} else {
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1326
|
+
onProgress?.({
|
|
1327
|
+
type: "authentication_not_matched",
|
|
1328
|
+
appKey: app.key
|
|
1329
|
+
});
|
|
1168
1330
|
}
|
|
1169
1331
|
}
|
|
1170
|
-
const
|
|
1332
|
+
const manifestKey = getManifestKey(app);
|
|
1171
1333
|
try {
|
|
1172
1334
|
const generator = new AstTypeGenerator();
|
|
1173
|
-
const
|
|
1335
|
+
const typeDefinitionString = await generator.generateTypes({
|
|
1174
1336
|
app,
|
|
1175
1337
|
authenticationId,
|
|
1176
1338
|
sdk
|
|
1177
1339
|
});
|
|
1178
|
-
|
|
1179
|
-
|
|
1340
|
+
result.typeDefinitions[manifestKey] = typeDefinitionString;
|
|
1341
|
+
onProgress?.({
|
|
1342
|
+
type: "type_generated",
|
|
1343
|
+
manifestKey,
|
|
1344
|
+
sizeBytes: typeDefinitionString.length
|
|
1345
|
+
});
|
|
1346
|
+
if (!skipWrite && typesOutputDirectory && result.writtenFiles) {
|
|
1347
|
+
const filePath = join(typesOutputDirectory, `${manifestKey}.d.ts`);
|
|
1348
|
+
await writeFile(filePath, typeDefinitionString, "utf8");
|
|
1349
|
+
result.writtenFiles[manifestKey] = filePath;
|
|
1350
|
+
onProgress?.({
|
|
1351
|
+
type: "file_written",
|
|
1352
|
+
manifestKey,
|
|
1353
|
+
filePath
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
onProgress?.({
|
|
1357
|
+
type: "app_processing_complete",
|
|
1358
|
+
appKey: app.key
|
|
1359
|
+
});
|
|
1180
1360
|
} catch (error) {
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1361
|
+
const errorMessage = `Failed to generate types: ${error}`;
|
|
1362
|
+
result.errors.push({
|
|
1363
|
+
appKey: app.key,
|
|
1364
|
+
error: errorMessage
|
|
1365
|
+
});
|
|
1366
|
+
onProgress?.({
|
|
1367
|
+
type: "app_processing_error",
|
|
1368
|
+
appKey: app.key,
|
|
1369
|
+
error: errorMessage
|
|
1370
|
+
});
|
|
1184
1371
|
}
|
|
1185
1372
|
} catch (error) {
|
|
1186
|
-
|
|
1373
|
+
const errorMessage = `Failed to process app: ${error}`;
|
|
1374
|
+
result.errors.push({
|
|
1375
|
+
appKey: app.key,
|
|
1376
|
+
error: errorMessage
|
|
1377
|
+
});
|
|
1378
|
+
onProgress?.({
|
|
1379
|
+
type: "app_processing_error",
|
|
1380
|
+
appKey: app.key,
|
|
1381
|
+
error: errorMessage
|
|
1382
|
+
});
|
|
1187
1383
|
}
|
|
1188
1384
|
}
|
|
1189
|
-
|
|
1190
|
-
},
|
|
1385
|
+
return result;
|
|
1386
|
+
}, GenerateAppTypesSchema);
|
|
1191
1387
|
return {
|
|
1192
|
-
|
|
1388
|
+
generateAppTypes,
|
|
1193
1389
|
context: {
|
|
1194
1390
|
meta: {
|
|
1195
|
-
|
|
1391
|
+
generateAppTypes: {
|
|
1196
1392
|
categories: ["utility"],
|
|
1197
|
-
inputSchema:
|
|
1393
|
+
inputSchema: GenerateAppTypesSchema
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
};
|
|
1398
|
+
};
|
|
1399
|
+
var BuildManifestSchema = z.object({
|
|
1400
|
+
appKeys: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
1401
|
+
"One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello')"
|
|
1402
|
+
),
|
|
1403
|
+
skipWrite: z.boolean().optional().describe(
|
|
1404
|
+
"If true, returns manifest entries without writing to disk. If false or omitted, writes to the manifest file."
|
|
1405
|
+
),
|
|
1406
|
+
configPath: z.string().optional().describe(
|
|
1407
|
+
"Path to the manifest file. Only used when skipWrite is false or omitted."
|
|
1408
|
+
)
|
|
1409
|
+
}).describe(
|
|
1410
|
+
"Build manifest entries for apps - can optionally write to disk or just return JSON"
|
|
1411
|
+
);
|
|
1412
|
+
|
|
1413
|
+
// src/plugins/buildManifest/index.ts
|
|
1414
|
+
var buildManifestPlugin = ({ sdk, context }) => {
|
|
1415
|
+
const buildManifest = createFunction(async function buildManifest2(options) {
|
|
1416
|
+
const { appKeys, skipWrite = false, configPath, onProgress } = options;
|
|
1417
|
+
const result = {
|
|
1418
|
+
errors: []
|
|
1419
|
+
};
|
|
1420
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
1421
|
+
const appsIterator = sdk.listApps({ appKeys }).items();
|
|
1422
|
+
const apps = [];
|
|
1423
|
+
for await (const app of appsIterator) {
|
|
1424
|
+
apps.push(app);
|
|
1425
|
+
onProgress?.({ type: "app_found", app });
|
|
1426
|
+
}
|
|
1427
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
1428
|
+
if (apps.length === 0) {
|
|
1429
|
+
return result;
|
|
1430
|
+
}
|
|
1431
|
+
let updatedManifest;
|
|
1432
|
+
for (const app of apps) {
|
|
1433
|
+
onProgress?.({
|
|
1434
|
+
type: "app_processing_start",
|
|
1435
|
+
appKey: app.key,
|
|
1436
|
+
slug: app.slug
|
|
1437
|
+
});
|
|
1438
|
+
try {
|
|
1439
|
+
const manifestEntry = createManifestEntry(app);
|
|
1440
|
+
onProgress?.({
|
|
1441
|
+
type: "manifest_entry_built",
|
|
1442
|
+
appKey: app.key,
|
|
1443
|
+
manifestKey: manifestEntry.implementationName,
|
|
1444
|
+
version: manifestEntry.version || ""
|
|
1445
|
+
});
|
|
1446
|
+
const [updatedManifestKey, , manifest] = await context.updateManifestEntry({
|
|
1447
|
+
appKey: app.key,
|
|
1448
|
+
entry: manifestEntry,
|
|
1449
|
+
configPath,
|
|
1450
|
+
skipWrite,
|
|
1451
|
+
manifest: updatedManifest
|
|
1452
|
+
});
|
|
1453
|
+
updatedManifest = manifest;
|
|
1454
|
+
onProgress?.({
|
|
1455
|
+
type: "manifest_updated",
|
|
1456
|
+
appKey: app.key,
|
|
1457
|
+
manifestKey: updatedManifestKey,
|
|
1458
|
+
version: manifestEntry.version || ""
|
|
1459
|
+
});
|
|
1460
|
+
onProgress?.({ type: "app_processing_complete", appKey: app.key });
|
|
1461
|
+
} catch (error) {
|
|
1462
|
+
const errorMessage = `Failed to process app: ${error}`;
|
|
1463
|
+
result.errors.push({
|
|
1464
|
+
appKey: app.key,
|
|
1465
|
+
error: errorMessage
|
|
1466
|
+
});
|
|
1467
|
+
onProgress?.({
|
|
1468
|
+
type: "app_processing_error",
|
|
1469
|
+
appKey: app.key,
|
|
1470
|
+
error: errorMessage
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
result.manifest = updatedManifest;
|
|
1475
|
+
return result;
|
|
1476
|
+
}, BuildManifestSchema);
|
|
1477
|
+
return {
|
|
1478
|
+
buildManifest,
|
|
1479
|
+
context: {
|
|
1480
|
+
meta: {
|
|
1481
|
+
buildManifest: {
|
|
1482
|
+
categories: ["utility"],
|
|
1483
|
+
inputSchema: BuildManifestSchema
|
|
1198
1484
|
}
|
|
1199
1485
|
}
|
|
1200
1486
|
}
|
|
@@ -1203,18 +1489,10 @@ var addPlugin = ({ sdk, context }) => {
|
|
|
1203
1489
|
|
|
1204
1490
|
// src/sdk.ts
|
|
1205
1491
|
function createZapierCliSdk(options = {}) {
|
|
1206
|
-
|
|
1492
|
+
return createZapierSdkWithoutRegistry({
|
|
1207
1493
|
debug: options.debug,
|
|
1208
1494
|
eventEmission: options.eventEmission
|
|
1209
|
-
});
|
|
1210
|
-
sdk = sdk.addPlugin(bundleCodePlugin);
|
|
1211
|
-
sdk = sdk.addPlugin(getLoginConfigPathPlugin);
|
|
1212
|
-
sdk = sdk.addPlugin(addPlugin);
|
|
1213
|
-
sdk = sdk.addPlugin(mcpPlugin);
|
|
1214
|
-
sdk = sdk.addPlugin(loginPlugin);
|
|
1215
|
-
sdk = sdk.addPlugin(logoutPlugin);
|
|
1216
|
-
const finalSdk = sdk.addPlugin(registryPlugin);
|
|
1217
|
-
return finalSdk;
|
|
1495
|
+
}).addPlugin(generateAppTypesPlugin).addPlugin(buildManifestPlugin).addPlugin(bundleCodePlugin).addPlugin(getLoginConfigPathPlugin).addPlugin(addPlugin).addPlugin(mcpPlugin).addPlugin(loginPlugin).addPlugin(logoutPlugin).addPlugin(registryPlugin);
|
|
1218
1496
|
}
|
|
1219
1497
|
|
|
1220
1498
|
export { buildCliCommandExecutedEvent, createZapierCliSdk };
|
package/dist/package.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { Plugin, GetSdkType,
|
|
1
|
+
import type { Plugin, GetSdkType, ListActionsPluginProvides, ListAppsPluginProvides, ListInputFieldsPluginProvides, ListAuthenticationsPluginProvides } from "@zapier/zapier-sdk";
|
|
2
2
|
import { AddSchema, type AddOptions } from "./schemas";
|
|
3
|
+
import { type GenerateAppTypesPluginProvides } from "../generateAppTypes";
|
|
4
|
+
import { type BuildManifestPluginProvides } from "../buildManifest";
|
|
3
5
|
export interface AddPluginProvides {
|
|
4
6
|
add: (options: AddOptions) => Promise<void>;
|
|
5
7
|
context: {
|
|
@@ -10,4 +12,4 @@ export interface AddPluginProvides {
|
|
|
10
12
|
};
|
|
11
13
|
};
|
|
12
14
|
}
|
|
13
|
-
export declare const addPlugin: Plugin<GetSdkType<ListAppsPluginProvides & ListActionsPluginProvides & ListInputFieldsPluginProvides & ListAuthenticationsPluginProvides &
|
|
15
|
+
export declare const addPlugin: Plugin<GetSdkType<ListAppsPluginProvides & ListActionsPluginProvides & ListInputFieldsPluginProvides & ListAuthenticationsPluginProvides & BuildManifestPluginProvides & GenerateAppTypesPluginProvides>, {}, AddPluginProvides>;
|