@zapier/zapier-sdk-cli 0.13.5 → 0.13.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +39 -0
  3. package/dist/cli.cjs +354 -71
  4. package/dist/cli.mjs +355 -72
  5. package/dist/index.cjs +353 -70
  6. package/dist/index.d.mts +154 -2
  7. package/dist/index.d.ts +154 -2
  8. package/dist/index.mjs +354 -71
  9. package/dist/package.json +1 -1
  10. package/dist/src/plugins/add/index.d.ts +4 -2
  11. package/dist/src/plugins/add/index.js +89 -98
  12. package/dist/src/plugins/buildManifest/index.d.ts +13 -0
  13. package/dist/src/plugins/buildManifest/index.js +81 -0
  14. package/dist/src/plugins/buildManifest/schemas.d.ts +57 -0
  15. package/dist/src/plugins/buildManifest/schemas.js +17 -0
  16. package/dist/src/plugins/generateAppTypes/index.d.ts +13 -0
  17. package/dist/src/plugins/generateAppTypes/index.js +169 -0
  18. package/dist/src/plugins/generateAppTypes/schemas.d.ts +72 -0
  19. package/dist/src/plugins/generateAppTypes/schemas.js +21 -0
  20. package/dist/src/plugins/index.d.ts +2 -0
  21. package/dist/src/plugins/index.js +2 -0
  22. package/dist/src/sdk.d.ts +2 -2
  23. package/dist/src/sdk.js +16 -14
  24. package/dist/src/types/sdk.d.ts +5 -0
  25. package/dist/src/types/sdk.js +1 -0
  26. package/dist/src/utils/directory-detection.d.ts +5 -0
  27. package/dist/src/utils/directory-detection.js +21 -0
  28. package/dist/src/utils/manifest-helpers.d.ts +13 -0
  29. package/dist/src/utils/manifest-helpers.js +19 -0
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +3 -3
  32. package/src/plugins/add/index.ts +123 -125
  33. package/src/plugins/buildManifest/index.test.ts +612 -0
  34. package/src/plugins/buildManifest/index.ts +128 -0
  35. package/src/plugins/buildManifest/schemas.ts +61 -0
  36. package/src/plugins/generateAppTypes/index.ts +235 -0
  37. package/src/plugins/generateAppTypes/schemas.ts +65 -0
  38. package/src/plugins/index.ts +2 -0
  39. package/src/sdk.ts +23 -20
  40. package/src/types/sdk.ts +8 -0
  41. package/src/utils/directory-detection.ts +23 -0
  42. package/src/utils/manifest-helpers.ts +28 -0
  43. /package/dist/src/{plugins/add → generators}/ast-generator.d.ts +0 -0
  44. /package/dist/src/{plugins/add → generators}/ast-generator.js +0 -0
  45. /package/src/{plugins/add → generators}/ast-generator.ts +0 -0
package/dist/index.cjs CHANGED
@@ -13,8 +13,8 @@ var zapierSdkMcp = require('@zapier/zapier-sdk-mcp');
13
13
  var esbuild = require('esbuild');
14
14
  var fs = require('fs');
15
15
  var path = require('path');
16
- var ts = require('typescript');
17
16
  var promises = require('fs/promises');
17
+ var ts = require('typescript');
18
18
 
19
19
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
20
20
 
@@ -263,7 +263,7 @@ var LoginSchema = zod.z.object({
263
263
 
264
264
  // package.json
265
265
  var package_default = {
266
- version: "0.13.5"};
266
+ version: "0.13.6"};
267
267
 
268
268
  // src/telemetry/builders.ts
269
269
  function createCliBaseEvent(context = {}) {
@@ -551,6 +551,146 @@ var AddSchema = zod.z.object({
551
551
  }).describe(
552
552
  "Add apps with manifest locking and TypeScript type generation - updates .zapierrc with app versions and generates TypeScript definition files"
553
553
  );
554
+ async function detectTypesOutputDirectory() {
555
+ const candidates = ["src", "lib"];
556
+ for (const candidate of candidates) {
557
+ try {
558
+ await promises.access(candidate);
559
+ return path.join(candidate, "zapier", "apps");
560
+ } catch {
561
+ }
562
+ }
563
+ return "./zapier/apps/";
564
+ }
565
+ var addPlugin = ({ sdk }) => {
566
+ const add = zapierSdk.createFunction(async function add2(options) {
567
+ const {
568
+ appKeys,
569
+ authenticationIds,
570
+ configPath,
571
+ typesOutput = await detectTypesOutputDirectory()
572
+ } = options;
573
+ const resolvedTypesOutput = path.resolve(typesOutput);
574
+ console.log(`\u{1F4E6} Adding ${appKeys.length} app(s)...`);
575
+ const appSlugAndKeyMap = /* @__PURE__ */ new Map();
576
+ const handleManifestProgress = (event) => {
577
+ switch (event.type) {
578
+ case "apps_lookup_start":
579
+ console.log(`\u{1F4E6} Looking up ${event.count} app(s)...`);
580
+ break;
581
+ case "app_found":
582
+ const displayName = event.app.slug ? `${event.app.slug} (${event.app.key})` : event.app.key;
583
+ appSlugAndKeyMap.set(event.app.key, displayName);
584
+ break;
585
+ case "apps_lookup_complete":
586
+ if (event.count === 0) {
587
+ console.warn("\u26A0\uFE0F No apps found");
588
+ }
589
+ break;
590
+ case "app_processing_start":
591
+ const appName = event.slug ? `${event.slug} (${event.appKey})` : event.appKey;
592
+ console.log(`\u{1F4E6} Adding ${appName}...`);
593
+ break;
594
+ case "manifest_updated":
595
+ const appDisplay = appSlugAndKeyMap.get(event.appKey) || event.appKey;
596
+ console.log(
597
+ `\u{1F4DD} Locked ${appDisplay} to ${event.appKey}@${event.version} using key '${event.manifestKey}'`
598
+ );
599
+ break;
600
+ case "app_processing_error":
601
+ const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
602
+ console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
603
+ break;
604
+ }
605
+ };
606
+ const handleTypesProgress = (event) => {
607
+ switch (event.type) {
608
+ case "authentications_lookup_start":
609
+ console.log(`\u{1F510} Looking up ${event.count} authentication(s)...`);
610
+ break;
611
+ case "authentications_lookup_complete":
612
+ console.log(`\u{1F510} Found ${event.count} authentication(s)`);
613
+ break;
614
+ case "authentication_matched":
615
+ const appWithAuth = appSlugAndKeyMap.get(event.appKey) || event.appKey;
616
+ console.log(
617
+ `\u{1F510} Using authentication ${event.authenticationId} (${event.authenticationTitle}) for ${appWithAuth}`
618
+ );
619
+ break;
620
+ case "authentication_not_matched":
621
+ const appWithoutAuth = appSlugAndKeyMap.get(event.appKey) || event.appKey;
622
+ console.warn(
623
+ `\u26A0\uFE0F No matching authentication found for ${appWithoutAuth}`
624
+ );
625
+ break;
626
+ case "file_written":
627
+ console.log(
628
+ `\u{1F527} Generated types for ${event.manifestKey} at ${event.filePath}`
629
+ );
630
+ break;
631
+ case "app_processing_error":
632
+ const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
633
+ console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
634
+ break;
635
+ }
636
+ };
637
+ const manifestResult = await sdk.buildManifest({
638
+ appKeys,
639
+ skipWrite: false,
640
+ configPath,
641
+ onProgress: handleManifestProgress
642
+ });
643
+ const typesResult = await sdk.generateAppTypes({
644
+ appKeys,
645
+ authenticationIds,
646
+ skipWrite: false,
647
+ typesOutputDirectory: resolvedTypesOutput,
648
+ onProgress: handleTypesProgress
649
+ });
650
+ const results = manifestResult.manifest?.apps || {};
651
+ const successfulApps = Object.keys(results).filter(
652
+ (manifestKey) => typesResult.writtenFiles?.[manifestKey]
653
+ );
654
+ if (successfulApps.length > 0) {
655
+ console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
656
+ }
657
+ const allErrors = [...manifestResult.errors, ...typesResult.errors];
658
+ if (allErrors.length > 0) {
659
+ console.warn(`
660
+ \u26A0\uFE0F ${allErrors.length} error(s) occurred:`);
661
+ allErrors.forEach(({ appKey, error }) => {
662
+ console.warn(` - ${appKey}: ${error}`);
663
+ });
664
+ }
665
+ }, AddSchema);
666
+ return {
667
+ add,
668
+ context: {
669
+ meta: {
670
+ add: {
671
+ categories: ["utility"],
672
+ inputSchema: AddSchema
673
+ }
674
+ }
675
+ }
676
+ };
677
+ };
678
+ var GenerateAppTypesSchema = zod.z.object({
679
+ appKeys: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
680
+ "One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
681
+ ),
682
+ authenticationIds: zod.z.array(zod.z.string()).optional().describe(
683
+ "Authentication IDs to use for type generation (e.g., ['123', '456'])"
684
+ ),
685
+ skipWrite: zod.z.boolean().optional().describe(
686
+ "If true, returns type definitions without writing to disk. If false or omitted, writes type files."
687
+ ),
688
+ typesOutputDirectory: zod.z.string().optional().describe(
689
+ "Directory for TypeScript type files. Required when skipWrite is false or omitted."
690
+ )
691
+ }).describe(
692
+ "Generate TypeScript type definitions for apps - can optionally write to disk or just return type strings"
693
+ );
554
694
  var AstTypeGenerator = class {
555
695
  constructor() {
556
696
  this.factory = ts__namespace.factory;
@@ -1119,69 +1259,92 @@ Usage:
1119
1259
  return Array.from(allKeys);
1120
1260
  }
1121
1261
  };
1122
- async function detectTypesOutputDirectory() {
1123
- const candidates = ["src", "lib"];
1124
- for (const candidate of candidates) {
1125
- try {
1126
- await promises.access(candidate);
1127
- return path.join(candidate, "zapier", "apps");
1128
- } catch {
1129
- }
1262
+
1263
+ // src/utils/manifest-helpers.ts
1264
+ function getManifestKey(app) {
1265
+ return app.slug || app.key;
1266
+ }
1267
+ function createManifestEntry(app) {
1268
+ if (!app.version) {
1269
+ throw new Error(
1270
+ `App ${app.key} does not have a version. Implementation ID: ${app.implementation_id}`
1271
+ );
1130
1272
  }
1131
- return "./zapier/apps/";
1273
+ return {
1274
+ implementationName: app.key,
1275
+ version: app.version
1276
+ };
1132
1277
  }
1133
- var addPlugin = ({ sdk, context }) => {
1134
- const add = zapierSdk.createFunction(async function add2(options) {
1278
+ var generateAppTypesPlugin = ({ sdk }) => {
1279
+ const generateAppTypes = zapierSdk.createFunction(async function generateAppTypes2(options) {
1135
1280
  const {
1136
1281
  appKeys,
1137
1282
  authenticationIds,
1138
- configPath,
1139
- typesOutput = await detectTypesOutputDirectory()
1283
+ skipWrite = false,
1284
+ typesOutputDirectory,
1285
+ onProgress
1140
1286
  } = options;
1141
- const resolvedTypesOutput = path.resolve(typesOutput);
1142
- await promises.mkdir(resolvedTypesOutput, { recursive: true });
1143
- console.log(`\u{1F4E6} Looking up ${appKeys.length} app(s)...`);
1287
+ if (!skipWrite && !typesOutputDirectory) {
1288
+ throw new Error(
1289
+ "typesOutputDirectory is required when skipWrite is false"
1290
+ );
1291
+ }
1292
+ const result = {
1293
+ typeDefinitions: {},
1294
+ errors: []
1295
+ };
1296
+ onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
1144
1297
  const appsIterator = sdk.listApps({ appKeys }).items();
1145
1298
  const apps = [];
1146
1299
  for await (const app of appsIterator) {
1147
1300
  apps.push(app);
1301
+ onProgress?.({ type: "app_found", app });
1148
1302
  }
1303
+ onProgress?.({ type: "apps_lookup_complete", count: apps.length });
1149
1304
  if (apps.length === 0) {
1150
- console.warn("\u26A0\uFE0F No apps found");
1151
- return;
1305
+ return result;
1152
1306
  }
1153
- let authentications = [];
1307
+ const authentications = [];
1154
1308
  if (authenticationIds && authenticationIds.length > 0) {
1155
- console.log(
1156
- `\u{1F510} Looking up ${authenticationIds.length} authentication(s)...`
1157
- );
1309
+ onProgress?.({
1310
+ type: "authentications_lookup_start",
1311
+ count: authenticationIds.length
1312
+ });
1158
1313
  const authsIterator = sdk.listAuthentications({ authenticationIds }).items();
1159
1314
  for await (const auth of authsIterator) {
1160
1315
  authentications.push(auth);
1161
1316
  }
1162
- console.log(`\u{1F510} Found ${authentications.length} authentication(s)`);
1317
+ onProgress?.({
1318
+ type: "authentications_lookup_complete",
1319
+ count: authentications.length
1320
+ });
1321
+ }
1322
+ if (!skipWrite && typesOutputDirectory) {
1323
+ await promises.mkdir(typesOutputDirectory, { recursive: true });
1324
+ }
1325
+ if (!skipWrite) {
1326
+ result.writtenFiles = {};
1163
1327
  }
1164
1328
  for (const app of apps) {
1165
- const appSlugAndKey = app.slug ? `${app.slug} (${app.key})` : app.key;
1166
- console.log(`\u{1F4E6} Adding ${appSlugAndKey}...`);
1329
+ onProgress?.({
1330
+ type: "app_processing_start",
1331
+ appKey: app.key,
1332
+ slug: app.slug
1333
+ });
1167
1334
  try {
1168
1335
  if (!app.version) {
1169
- console.warn(
1170
- `\u26A0\uFE0F Invalid implementation ID format for '${appSlugAndKey}': ${app.implementation_id}. Expected format: <implementationName>@<version>. Skipping...`
1171
- );
1336
+ const error = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
1337
+ result.errors.push({
1338
+ appKey: app.key,
1339
+ error
1340
+ });
1341
+ onProgress?.({
1342
+ type: "app_processing_error",
1343
+ appKey: app.key,
1344
+ error
1345
+ });
1172
1346
  continue;
1173
1347
  }
1174
- const [manifestKey] = await context.updateManifestEntry(
1175
- app.key,
1176
- {
1177
- implementationName: app.key,
1178
- version: app.version
1179
- },
1180
- configPath
1181
- );
1182
- console.log(
1183
- `\u{1F4DD} Locked ${appSlugAndKey} to ${app.key}@${app.version} using key '${manifestKey}'`
1184
- );
1185
1348
  let authenticationId;
1186
1349
  if (authentications.length > 0) {
1187
1350
  const matchingAuth = authentications.find((auth) => {
@@ -1189,43 +1352,171 @@ var addPlugin = ({ sdk, context }) => {
1189
1352
  });
1190
1353
  if (matchingAuth) {
1191
1354
  authenticationId = matchingAuth.id;
1192
- console.log(
1193
- `\u{1F510} Using authentication ${authenticationId} (${matchingAuth.title}) for ${appSlugAndKey}`
1194
- );
1355
+ onProgress?.({
1356
+ type: "authentication_matched",
1357
+ appKey: app.key,
1358
+ authenticationId: matchingAuth.id,
1359
+ authenticationTitle: matchingAuth.title || ""
1360
+ });
1195
1361
  } else {
1196
- console.warn(
1197
- `\u26A0\uFE0F No matching authentication found for ${appSlugAndKey}`
1198
- );
1362
+ onProgress?.({
1363
+ type: "authentication_not_matched",
1364
+ appKey: app.key
1365
+ });
1199
1366
  }
1200
1367
  }
1201
- const typesPath = path.join(resolvedTypesOutput, `${manifestKey}.d.ts`);
1368
+ const manifestKey = getManifestKey(app);
1202
1369
  try {
1203
1370
  const generator = new AstTypeGenerator();
1204
- const typeDefinitions = await generator.generateTypes({
1371
+ const typeDefinitionString = await generator.generateTypes({
1205
1372
  app,
1206
1373
  authenticationId,
1207
1374
  sdk
1208
1375
  });
1209
- await promises.writeFile(typesPath, typeDefinitions, "utf8");
1210
- console.log(`\u{1F527} Generated types for ${manifestKey} at ${typesPath}`);
1376
+ result.typeDefinitions[manifestKey] = typeDefinitionString;
1377
+ onProgress?.({
1378
+ type: "type_generated",
1379
+ manifestKey,
1380
+ sizeBytes: typeDefinitionString.length
1381
+ });
1382
+ if (!skipWrite && typesOutputDirectory && result.writtenFiles) {
1383
+ const filePath = path.join(typesOutputDirectory, `${manifestKey}.d.ts`);
1384
+ await promises.writeFile(filePath, typeDefinitionString, "utf8");
1385
+ result.writtenFiles[manifestKey] = filePath;
1386
+ onProgress?.({
1387
+ type: "file_written",
1388
+ manifestKey,
1389
+ filePath
1390
+ });
1391
+ }
1392
+ onProgress?.({
1393
+ type: "app_processing_complete",
1394
+ appKey: app.key
1395
+ });
1211
1396
  } catch (error) {
1212
- console.warn(
1213
- `\u26A0\uFE0F Failed to generate types for ${appSlugAndKey}: ${error}`
1214
- );
1397
+ const errorMessage = `Failed to generate types: ${error}`;
1398
+ result.errors.push({
1399
+ appKey: app.key,
1400
+ error: errorMessage
1401
+ });
1402
+ onProgress?.({
1403
+ type: "app_processing_error",
1404
+ appKey: app.key,
1405
+ error: errorMessage
1406
+ });
1215
1407
  }
1216
1408
  } catch (error) {
1217
- console.warn(`\u26A0\uFE0F Failed to process ${appSlugAndKey}: ${error}`);
1409
+ const errorMessage = `Failed to process app: ${error}`;
1410
+ result.errors.push({
1411
+ appKey: app.key,
1412
+ error: errorMessage
1413
+ });
1414
+ onProgress?.({
1415
+ type: "app_processing_error",
1416
+ appKey: app.key,
1417
+ error: errorMessage
1418
+ });
1218
1419
  }
1219
1420
  }
1220
- console.log(`\u2705 Added ${apps.length} app(s) to manifest`);
1221
- }, AddSchema);
1421
+ return result;
1422
+ }, GenerateAppTypesSchema);
1222
1423
  return {
1223
- add,
1424
+ generateAppTypes,
1224
1425
  context: {
1225
1426
  meta: {
1226
- add: {
1427
+ generateAppTypes: {
1227
1428
  categories: ["utility"],
1228
- inputSchema: AddSchema
1429
+ inputSchema: GenerateAppTypesSchema
1430
+ }
1431
+ }
1432
+ }
1433
+ };
1434
+ };
1435
+ var BuildManifestSchema = zod.z.object({
1436
+ appKeys: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
1437
+ "One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello')"
1438
+ ),
1439
+ skipWrite: zod.z.boolean().optional().describe(
1440
+ "If true, returns manifest entries without writing to disk. If false or omitted, writes to the manifest file."
1441
+ ),
1442
+ configPath: zod.z.string().optional().describe(
1443
+ "Path to the manifest file. Only used when skipWrite is false or omitted."
1444
+ )
1445
+ }).describe(
1446
+ "Build manifest entries for apps - can optionally write to disk or just return JSON"
1447
+ );
1448
+
1449
+ // src/plugins/buildManifest/index.ts
1450
+ var buildManifestPlugin = ({ sdk, context }) => {
1451
+ const buildManifest = zapierSdk.createFunction(async function buildManifest2(options) {
1452
+ const { appKeys, skipWrite = false, configPath, onProgress } = options;
1453
+ const result = {
1454
+ errors: []
1455
+ };
1456
+ onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
1457
+ const appsIterator = sdk.listApps({ appKeys }).items();
1458
+ const apps = [];
1459
+ for await (const app of appsIterator) {
1460
+ apps.push(app);
1461
+ onProgress?.({ type: "app_found", app });
1462
+ }
1463
+ onProgress?.({ type: "apps_lookup_complete", count: apps.length });
1464
+ if (apps.length === 0) {
1465
+ return result;
1466
+ }
1467
+ let updatedManifest;
1468
+ for (const app of apps) {
1469
+ onProgress?.({
1470
+ type: "app_processing_start",
1471
+ appKey: app.key,
1472
+ slug: app.slug
1473
+ });
1474
+ try {
1475
+ const manifestEntry = createManifestEntry(app);
1476
+ onProgress?.({
1477
+ type: "manifest_entry_built",
1478
+ appKey: app.key,
1479
+ manifestKey: manifestEntry.implementationName,
1480
+ version: manifestEntry.version
1481
+ });
1482
+ const [updatedManifestKey, , manifest] = await context.updateManifestEntry({
1483
+ appKey: app.key,
1484
+ entry: manifestEntry,
1485
+ configPath,
1486
+ skipWrite,
1487
+ manifest: updatedManifest
1488
+ });
1489
+ updatedManifest = manifest;
1490
+ onProgress?.({
1491
+ type: "manifest_updated",
1492
+ appKey: app.key,
1493
+ manifestKey: updatedManifestKey,
1494
+ version: manifestEntry.version
1495
+ });
1496
+ onProgress?.({ type: "app_processing_complete", appKey: app.key });
1497
+ } catch (error) {
1498
+ const errorMessage = `Failed to process app: ${error}`;
1499
+ result.errors.push({
1500
+ appKey: app.key,
1501
+ error: errorMessage
1502
+ });
1503
+ onProgress?.({
1504
+ type: "app_processing_error",
1505
+ appKey: app.key,
1506
+ error: errorMessage
1507
+ });
1508
+ }
1509
+ }
1510
+ result.manifest = updatedManifest;
1511
+ return result;
1512
+ }, BuildManifestSchema);
1513
+ return {
1514
+ buildManifest,
1515
+ context: {
1516
+ meta: {
1517
+ buildManifest: {
1518
+ categories: ["utility"],
1519
+ inputSchema: BuildManifestSchema
1229
1520
  }
1230
1521
  }
1231
1522
  }
@@ -1234,18 +1525,10 @@ var addPlugin = ({ sdk, context }) => {
1234
1525
 
1235
1526
  // src/sdk.ts
1236
1527
  function createZapierCliSdk(options = {}) {
1237
- let sdk = zapierSdk.createZapierSdkWithoutRegistry({
1528
+ return zapierSdk.createZapierSdkWithoutRegistry({
1238
1529
  debug: options.debug,
1239
1530
  eventEmission: options.eventEmission
1240
- });
1241
- sdk = sdk.addPlugin(bundleCodePlugin);
1242
- sdk = sdk.addPlugin(getLoginConfigPathPlugin);
1243
- sdk = sdk.addPlugin(addPlugin);
1244
- sdk = sdk.addPlugin(mcpPlugin);
1245
- sdk = sdk.addPlugin(loginPlugin);
1246
- sdk = sdk.addPlugin(logoutPlugin);
1247
- const finalSdk = sdk.addPlugin(zapierSdk.registryPlugin);
1248
- return finalSdk;
1531
+ }).addPlugin(generateAppTypesPlugin).addPlugin(buildManifestPlugin).addPlugin(bundleCodePlugin).addPlugin(getLoginConfigPathPlugin).addPlugin(addPlugin).addPlugin(mcpPlugin).addPlugin(loginPlugin).addPlugin(logoutPlugin).addPlugin(zapierSdk.registryPlugin);
1249
1532
  }
1250
1533
 
1251
1534
  exports.buildCliCommandExecutedEvent = buildCliCommandExecutedEvent;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,156 @@
1
- import { ZapierSdk, BaseEvent } from '@zapier/zapier-sdk';
1
+ import { AppItem, Manifest, GetSdkType, ZapierSdk, BaseEvent } from '@zapier/zapier-sdk';
2
+ import { z } from 'zod';
3
+
4
+ declare const BuildManifestSchema: z.ZodObject<{
5
+ appKeys: z.ZodArray<z.ZodString, "many">;
6
+ skipWrite: z.ZodOptional<z.ZodBoolean>;
7
+ configPath: z.ZodOptional<z.ZodString>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ appKeys: string[];
10
+ configPath?: string | undefined;
11
+ skipWrite?: boolean | undefined;
12
+ }, {
13
+ appKeys: string[];
14
+ configPath?: string | undefined;
15
+ skipWrite?: boolean | undefined;
16
+ }>;
17
+ type BuildManifestOptions = z.infer<typeof BuildManifestSchema> & {
18
+ onProgress?: (event: ManifestBuildProgressEvent) => void;
19
+ };
20
+ type ManifestBuildProgressEvent = {
21
+ type: "apps_lookup_start";
22
+ count: number;
23
+ } | {
24
+ type: "app_found";
25
+ app: AppItem;
26
+ } | {
27
+ type: "apps_lookup_complete";
28
+ count: number;
29
+ } | {
30
+ type: "app_processing_start";
31
+ appKey: string;
32
+ slug?: string;
33
+ } | {
34
+ type: "manifest_entry_built";
35
+ appKey: string;
36
+ manifestKey: string;
37
+ version: string;
38
+ } | {
39
+ type: "manifest_updated";
40
+ appKey: string;
41
+ manifestKey: string;
42
+ version: string;
43
+ } | {
44
+ type: "app_processing_complete";
45
+ appKey: string;
46
+ } | {
47
+ type: "app_processing_error";
48
+ appKey: string;
49
+ error: string;
50
+ };
51
+ interface BuildManifestResult {
52
+ manifest?: Manifest;
53
+ errors: Array<{
54
+ appKey: string;
55
+ error: string;
56
+ }>;
57
+ }
58
+
59
+ interface BuildManifestPluginProvides {
60
+ buildManifest: (options: BuildManifestOptions) => Promise<BuildManifestResult>;
61
+ context: {
62
+ meta: {
63
+ buildManifest: {
64
+ inputSchema: typeof BuildManifestSchema;
65
+ };
66
+ };
67
+ };
68
+ }
69
+
70
+ declare const GenerateAppTypesSchema: z.ZodObject<{
71
+ appKeys: z.ZodArray<z.ZodString, "many">;
72
+ authenticationIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
73
+ skipWrite: z.ZodOptional<z.ZodBoolean>;
74
+ typesOutputDirectory: z.ZodOptional<z.ZodString>;
75
+ }, "strip", z.ZodTypeAny, {
76
+ appKeys: string[];
77
+ authenticationIds?: string[] | undefined;
78
+ skipWrite?: boolean | undefined;
79
+ typesOutputDirectory?: string | undefined;
80
+ }, {
81
+ appKeys: string[];
82
+ authenticationIds?: string[] | undefined;
83
+ skipWrite?: boolean | undefined;
84
+ typesOutputDirectory?: string | undefined;
85
+ }>;
86
+ type GenerateAppTypesOptions = z.infer<typeof GenerateAppTypesSchema> & {
87
+ onProgress?: (event: AppTypesProgressEvent) => void;
88
+ };
89
+ type AppTypesProgressEvent = {
90
+ type: "apps_lookup_start";
91
+ count: number;
92
+ } | {
93
+ type: "app_found";
94
+ app: AppItem;
95
+ } | {
96
+ type: "apps_lookup_complete";
97
+ count: number;
98
+ } | {
99
+ type: "authentications_lookup_start";
100
+ count: number;
101
+ } | {
102
+ type: "authentications_lookup_complete";
103
+ count: number;
104
+ } | {
105
+ type: "app_processing_start";
106
+ appKey: string;
107
+ slug?: string;
108
+ } | {
109
+ type: "authentication_matched";
110
+ appKey: string;
111
+ authenticationId: number;
112
+ authenticationTitle: string;
113
+ } | {
114
+ type: "authentication_not_matched";
115
+ appKey: string;
116
+ } | {
117
+ type: "type_generated";
118
+ manifestKey: string;
119
+ sizeBytes: number;
120
+ } | {
121
+ type: "file_written";
122
+ manifestKey: string;
123
+ filePath: string;
124
+ } | {
125
+ type: "app_processing_complete";
126
+ appKey: string;
127
+ } | {
128
+ type: "app_processing_error";
129
+ appKey: string;
130
+ error: string;
131
+ };
132
+ interface GenerateAppTypesResult {
133
+ typeDefinitions: Record<string, string>;
134
+ writtenFiles?: Record<string, string>;
135
+ errors: Array<{
136
+ appKey: string;
137
+ error: string;
138
+ }>;
139
+ }
140
+
141
+ interface GenerateAppTypesPluginProvides {
142
+ generateAppTypes: (options: GenerateAppTypesOptions) => Promise<GenerateAppTypesResult>;
143
+ context: {
144
+ meta: {
145
+ generateAppTypes: {
146
+ inputSchema: typeof GenerateAppTypesSchema;
147
+ };
148
+ };
149
+ };
150
+ }
151
+
152
+ interface ZapierSdkCli extends GetSdkType<ZapierSdk & BuildManifestPluginProvides & GenerateAppTypesPluginProvides> {
153
+ }
2
154
 
3
155
  interface ZapierCliSdkOptions {
4
156
  debug?: boolean;
@@ -15,7 +167,7 @@ interface ZapierCliSdkOptions {
15
167
  * Create a Zapier SDK instance configured specifically for the CLI
16
168
  * Includes all CLI-specific plugins in addition to the standard SDK functionality
17
169
  */
18
- declare function createZapierCliSdk(options?: ZapierCliSdkOptions): ZapierSdk;
170
+ declare function createZapierCliSdk(options?: ZapierCliSdkOptions): ZapierSdkCli;
19
171
 
20
172
  /**
21
173
  * CLI-specific telemetry event definitions