@zapier/zapier-sdk-cli 0.13.4 → 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.
- package/CHANGELOG.md +15 -0
- package/README.md +39 -0
- package/dist/cli.cjs +354 -71
- package/dist/cli.mjs +355 -72
- package/dist/index.cjs +353 -70
- package/dist/index.d.mts +154 -2
- package/dist/index.d.ts +154 -2
- package/dist/index.mjs +354 -71
- package/dist/package.json +2 -2
- 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 +57 -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 +2 -2
- 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/directory-detection.d.ts +5 -0
- package/dist/src/utils/directory-detection.js +21 -0
- package/dist/src/utils/manifest-helpers.d.ts +13 -0
- package/dist/src/utils/manifest-helpers.js +19 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- 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 +61 -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 +23 -20
- package/src/types/sdk.ts +8 -0
- package/src/utils/directory-detection.ts +23 -0
- package/src/utils/manifest-helpers.ts +28 -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/cli.mjs
CHANGED
|
@@ -15,9 +15,9 @@ import { startMcpServerAsProcess } from '@zapier/zapier-sdk-mcp';
|
|
|
15
15
|
import { buildSync } from 'esbuild';
|
|
16
16
|
import * as fs from 'fs';
|
|
17
17
|
import * as path from 'path';
|
|
18
|
-
import {
|
|
19
|
-
import * as ts from 'typescript';
|
|
18
|
+
import { join, resolve } from 'path';
|
|
20
19
|
import { mkdir, writeFile, access } from 'fs/promises';
|
|
20
|
+
import * as ts from 'typescript';
|
|
21
21
|
|
|
22
22
|
function getLocalResolutionOrder(paramName, resolvers, resolved = /* @__PURE__ */ new Set()) {
|
|
23
23
|
const resolver = resolvers[paramName];
|
|
@@ -1374,7 +1374,7 @@ var LoginSchema = z.object({
|
|
|
1374
1374
|
|
|
1375
1375
|
// package.json
|
|
1376
1376
|
var package_default = {
|
|
1377
|
-
version: "0.13.
|
|
1377
|
+
version: "0.13.6"};
|
|
1378
1378
|
|
|
1379
1379
|
// src/telemetry/builders.ts
|
|
1380
1380
|
function createCliBaseEvent(context = {}) {
|
|
@@ -1662,6 +1662,146 @@ var AddSchema = z.object({
|
|
|
1662
1662
|
}).describe(
|
|
1663
1663
|
"Add apps with manifest locking and TypeScript type generation - updates .zapierrc with app versions and generates TypeScript definition files"
|
|
1664
1664
|
);
|
|
1665
|
+
async function detectTypesOutputDirectory() {
|
|
1666
|
+
const candidates = ["src", "lib"];
|
|
1667
|
+
for (const candidate of candidates) {
|
|
1668
|
+
try {
|
|
1669
|
+
await access(candidate);
|
|
1670
|
+
return join(candidate, "zapier", "apps");
|
|
1671
|
+
} catch {
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
return "./zapier/apps/";
|
|
1675
|
+
}
|
|
1676
|
+
var addPlugin = ({ sdk: sdk2 }) => {
|
|
1677
|
+
const add = createFunction(async function add2(options) {
|
|
1678
|
+
const {
|
|
1679
|
+
appKeys,
|
|
1680
|
+
authenticationIds,
|
|
1681
|
+
configPath,
|
|
1682
|
+
typesOutput = await detectTypesOutputDirectory()
|
|
1683
|
+
} = options;
|
|
1684
|
+
const resolvedTypesOutput = resolve(typesOutput);
|
|
1685
|
+
console.log(`\u{1F4E6} Adding ${appKeys.length} app(s)...`);
|
|
1686
|
+
const appSlugAndKeyMap = /* @__PURE__ */ new Map();
|
|
1687
|
+
const handleManifestProgress = (event) => {
|
|
1688
|
+
switch (event.type) {
|
|
1689
|
+
case "apps_lookup_start":
|
|
1690
|
+
console.log(`\u{1F4E6} Looking up ${event.count} app(s)...`);
|
|
1691
|
+
break;
|
|
1692
|
+
case "app_found":
|
|
1693
|
+
const displayName = event.app.slug ? `${event.app.slug} (${event.app.key})` : event.app.key;
|
|
1694
|
+
appSlugAndKeyMap.set(event.app.key, displayName);
|
|
1695
|
+
break;
|
|
1696
|
+
case "apps_lookup_complete":
|
|
1697
|
+
if (event.count === 0) {
|
|
1698
|
+
console.warn("\u26A0\uFE0F No apps found");
|
|
1699
|
+
}
|
|
1700
|
+
break;
|
|
1701
|
+
case "app_processing_start":
|
|
1702
|
+
const appName = event.slug ? `${event.slug} (${event.appKey})` : event.appKey;
|
|
1703
|
+
console.log(`\u{1F4E6} Adding ${appName}...`);
|
|
1704
|
+
break;
|
|
1705
|
+
case "manifest_updated":
|
|
1706
|
+
const appDisplay = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1707
|
+
console.log(
|
|
1708
|
+
`\u{1F4DD} Locked ${appDisplay} to ${event.appKey}@${event.version} using key '${event.manifestKey}'`
|
|
1709
|
+
);
|
|
1710
|
+
break;
|
|
1711
|
+
case "app_processing_error":
|
|
1712
|
+
const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1713
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
1714
|
+
break;
|
|
1715
|
+
}
|
|
1716
|
+
};
|
|
1717
|
+
const handleTypesProgress = (event) => {
|
|
1718
|
+
switch (event.type) {
|
|
1719
|
+
case "authentications_lookup_start":
|
|
1720
|
+
console.log(`\u{1F510} Looking up ${event.count} authentication(s)...`);
|
|
1721
|
+
break;
|
|
1722
|
+
case "authentications_lookup_complete":
|
|
1723
|
+
console.log(`\u{1F510} Found ${event.count} authentication(s)`);
|
|
1724
|
+
break;
|
|
1725
|
+
case "authentication_matched":
|
|
1726
|
+
const appWithAuth = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1727
|
+
console.log(
|
|
1728
|
+
`\u{1F510} Using authentication ${event.authenticationId} (${event.authenticationTitle}) for ${appWithAuth}`
|
|
1729
|
+
);
|
|
1730
|
+
break;
|
|
1731
|
+
case "authentication_not_matched":
|
|
1732
|
+
const appWithoutAuth = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1733
|
+
console.warn(
|
|
1734
|
+
`\u26A0\uFE0F No matching authentication found for ${appWithoutAuth}`
|
|
1735
|
+
);
|
|
1736
|
+
break;
|
|
1737
|
+
case "file_written":
|
|
1738
|
+
console.log(
|
|
1739
|
+
`\u{1F527} Generated types for ${event.manifestKey} at ${event.filePath}`
|
|
1740
|
+
);
|
|
1741
|
+
break;
|
|
1742
|
+
case "app_processing_error":
|
|
1743
|
+
const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1744
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
1745
|
+
break;
|
|
1746
|
+
}
|
|
1747
|
+
};
|
|
1748
|
+
const manifestResult = await sdk2.buildManifest({
|
|
1749
|
+
appKeys,
|
|
1750
|
+
skipWrite: false,
|
|
1751
|
+
configPath,
|
|
1752
|
+
onProgress: handleManifestProgress
|
|
1753
|
+
});
|
|
1754
|
+
const typesResult = await sdk2.generateAppTypes({
|
|
1755
|
+
appKeys,
|
|
1756
|
+
authenticationIds,
|
|
1757
|
+
skipWrite: false,
|
|
1758
|
+
typesOutputDirectory: resolvedTypesOutput,
|
|
1759
|
+
onProgress: handleTypesProgress
|
|
1760
|
+
});
|
|
1761
|
+
const results = manifestResult.manifest?.apps || {};
|
|
1762
|
+
const successfulApps = Object.keys(results).filter(
|
|
1763
|
+
(manifestKey) => typesResult.writtenFiles?.[manifestKey]
|
|
1764
|
+
);
|
|
1765
|
+
if (successfulApps.length > 0) {
|
|
1766
|
+
console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
|
|
1767
|
+
}
|
|
1768
|
+
const allErrors = [...manifestResult.errors, ...typesResult.errors];
|
|
1769
|
+
if (allErrors.length > 0) {
|
|
1770
|
+
console.warn(`
|
|
1771
|
+
\u26A0\uFE0F ${allErrors.length} error(s) occurred:`);
|
|
1772
|
+
allErrors.forEach(({ appKey, error }) => {
|
|
1773
|
+
console.warn(` - ${appKey}: ${error}`);
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
}, AddSchema);
|
|
1777
|
+
return {
|
|
1778
|
+
add,
|
|
1779
|
+
context: {
|
|
1780
|
+
meta: {
|
|
1781
|
+
add: {
|
|
1782
|
+
categories: ["utility"],
|
|
1783
|
+
inputSchema: AddSchema
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
};
|
|
1788
|
+
};
|
|
1789
|
+
var GenerateAppTypesSchema = z.object({
|
|
1790
|
+
appKeys: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
1791
|
+
"One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
|
|
1792
|
+
),
|
|
1793
|
+
authenticationIds: z.array(z.string()).optional().describe(
|
|
1794
|
+
"Authentication IDs to use for type generation (e.g., ['123', '456'])"
|
|
1795
|
+
),
|
|
1796
|
+
skipWrite: z.boolean().optional().describe(
|
|
1797
|
+
"If true, returns type definitions without writing to disk. If false or omitted, writes type files."
|
|
1798
|
+
),
|
|
1799
|
+
typesOutputDirectory: z.string().optional().describe(
|
|
1800
|
+
"Directory for TypeScript type files. Required when skipWrite is false or omitted."
|
|
1801
|
+
)
|
|
1802
|
+
}).describe(
|
|
1803
|
+
"Generate TypeScript type definitions for apps - can optionally write to disk or just return type strings"
|
|
1804
|
+
);
|
|
1665
1805
|
var AstTypeGenerator = class {
|
|
1666
1806
|
constructor() {
|
|
1667
1807
|
this.factory = ts.factory;
|
|
@@ -2230,69 +2370,92 @@ Usage:
|
|
|
2230
2370
|
return Array.from(allKeys);
|
|
2231
2371
|
}
|
|
2232
2372
|
};
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2373
|
+
|
|
2374
|
+
// src/utils/manifest-helpers.ts
|
|
2375
|
+
function getManifestKey(app) {
|
|
2376
|
+
return app.slug || app.key;
|
|
2377
|
+
}
|
|
2378
|
+
function createManifestEntry(app) {
|
|
2379
|
+
if (!app.version) {
|
|
2380
|
+
throw new Error(
|
|
2381
|
+
`App ${app.key} does not have a version. Implementation ID: ${app.implementation_id}`
|
|
2382
|
+
);
|
|
2241
2383
|
}
|
|
2242
|
-
return
|
|
2384
|
+
return {
|
|
2385
|
+
implementationName: app.key,
|
|
2386
|
+
version: app.version
|
|
2387
|
+
};
|
|
2243
2388
|
}
|
|
2244
|
-
var
|
|
2245
|
-
const
|
|
2389
|
+
var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
|
|
2390
|
+
const generateAppTypes = createFunction(async function generateAppTypes2(options) {
|
|
2246
2391
|
const {
|
|
2247
2392
|
appKeys,
|
|
2248
2393
|
authenticationIds,
|
|
2249
|
-
|
|
2250
|
-
|
|
2394
|
+
skipWrite = false,
|
|
2395
|
+
typesOutputDirectory,
|
|
2396
|
+
onProgress
|
|
2251
2397
|
} = options;
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2398
|
+
if (!skipWrite && !typesOutputDirectory) {
|
|
2399
|
+
throw new Error(
|
|
2400
|
+
"typesOutputDirectory is required when skipWrite is false"
|
|
2401
|
+
);
|
|
2402
|
+
}
|
|
2403
|
+
const result = {
|
|
2404
|
+
typeDefinitions: {},
|
|
2405
|
+
errors: []
|
|
2406
|
+
};
|
|
2407
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
2255
2408
|
const appsIterator = sdk2.listApps({ appKeys }).items();
|
|
2256
2409
|
const apps = [];
|
|
2257
2410
|
for await (const app of appsIterator) {
|
|
2258
2411
|
apps.push(app);
|
|
2412
|
+
onProgress?.({ type: "app_found", app });
|
|
2259
2413
|
}
|
|
2414
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
2260
2415
|
if (apps.length === 0) {
|
|
2261
|
-
|
|
2262
|
-
return;
|
|
2416
|
+
return result;
|
|
2263
2417
|
}
|
|
2264
|
-
|
|
2418
|
+
const authentications = [];
|
|
2265
2419
|
if (authenticationIds && authenticationIds.length > 0) {
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2420
|
+
onProgress?.({
|
|
2421
|
+
type: "authentications_lookup_start",
|
|
2422
|
+
count: authenticationIds.length
|
|
2423
|
+
});
|
|
2269
2424
|
const authsIterator = sdk2.listAuthentications({ authenticationIds }).items();
|
|
2270
2425
|
for await (const auth of authsIterator) {
|
|
2271
2426
|
authentications.push(auth);
|
|
2272
2427
|
}
|
|
2273
|
-
|
|
2428
|
+
onProgress?.({
|
|
2429
|
+
type: "authentications_lookup_complete",
|
|
2430
|
+
count: authentications.length
|
|
2431
|
+
});
|
|
2432
|
+
}
|
|
2433
|
+
if (!skipWrite && typesOutputDirectory) {
|
|
2434
|
+
await mkdir(typesOutputDirectory, { recursive: true });
|
|
2435
|
+
}
|
|
2436
|
+
if (!skipWrite) {
|
|
2437
|
+
result.writtenFiles = {};
|
|
2274
2438
|
}
|
|
2275
2439
|
for (const app of apps) {
|
|
2276
|
-
|
|
2277
|
-
|
|
2440
|
+
onProgress?.({
|
|
2441
|
+
type: "app_processing_start",
|
|
2442
|
+
appKey: app.key,
|
|
2443
|
+
slug: app.slug
|
|
2444
|
+
});
|
|
2278
2445
|
try {
|
|
2279
2446
|
if (!app.version) {
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2447
|
+
const error = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
|
|
2448
|
+
result.errors.push({
|
|
2449
|
+
appKey: app.key,
|
|
2450
|
+
error
|
|
2451
|
+
});
|
|
2452
|
+
onProgress?.({
|
|
2453
|
+
type: "app_processing_error",
|
|
2454
|
+
appKey: app.key,
|
|
2455
|
+
error
|
|
2456
|
+
});
|
|
2283
2457
|
continue;
|
|
2284
2458
|
}
|
|
2285
|
-
const [manifestKey] = await context.updateManifestEntry(
|
|
2286
|
-
app.key,
|
|
2287
|
-
{
|
|
2288
|
-
implementationName: app.key,
|
|
2289
|
-
version: app.version
|
|
2290
|
-
},
|
|
2291
|
-
configPath
|
|
2292
|
-
);
|
|
2293
|
-
console.log(
|
|
2294
|
-
`\u{1F4DD} Locked ${appSlugAndKey} to ${app.key}@${app.version} using key '${manifestKey}'`
|
|
2295
|
-
);
|
|
2296
2459
|
let authenticationId;
|
|
2297
2460
|
if (authentications.length > 0) {
|
|
2298
2461
|
const matchingAuth = authentications.find((auth) => {
|
|
@@ -2300,43 +2463,171 @@ var addPlugin = ({ sdk: sdk2, context }) => {
|
|
|
2300
2463
|
});
|
|
2301
2464
|
if (matchingAuth) {
|
|
2302
2465
|
authenticationId = matchingAuth.id;
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2466
|
+
onProgress?.({
|
|
2467
|
+
type: "authentication_matched",
|
|
2468
|
+
appKey: app.key,
|
|
2469
|
+
authenticationId: matchingAuth.id,
|
|
2470
|
+
authenticationTitle: matchingAuth.title || ""
|
|
2471
|
+
});
|
|
2306
2472
|
} else {
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2473
|
+
onProgress?.({
|
|
2474
|
+
type: "authentication_not_matched",
|
|
2475
|
+
appKey: app.key
|
|
2476
|
+
});
|
|
2310
2477
|
}
|
|
2311
2478
|
}
|
|
2312
|
-
const
|
|
2479
|
+
const manifestKey = getManifestKey(app);
|
|
2313
2480
|
try {
|
|
2314
2481
|
const generator = new AstTypeGenerator();
|
|
2315
|
-
const
|
|
2482
|
+
const typeDefinitionString = await generator.generateTypes({
|
|
2316
2483
|
app,
|
|
2317
2484
|
authenticationId,
|
|
2318
2485
|
sdk: sdk2
|
|
2319
2486
|
});
|
|
2320
|
-
|
|
2321
|
-
|
|
2487
|
+
result.typeDefinitions[manifestKey] = typeDefinitionString;
|
|
2488
|
+
onProgress?.({
|
|
2489
|
+
type: "type_generated",
|
|
2490
|
+
manifestKey,
|
|
2491
|
+
sizeBytes: typeDefinitionString.length
|
|
2492
|
+
});
|
|
2493
|
+
if (!skipWrite && typesOutputDirectory && result.writtenFiles) {
|
|
2494
|
+
const filePath = join(typesOutputDirectory, `${manifestKey}.d.ts`);
|
|
2495
|
+
await writeFile(filePath, typeDefinitionString, "utf8");
|
|
2496
|
+
result.writtenFiles[manifestKey] = filePath;
|
|
2497
|
+
onProgress?.({
|
|
2498
|
+
type: "file_written",
|
|
2499
|
+
manifestKey,
|
|
2500
|
+
filePath
|
|
2501
|
+
});
|
|
2502
|
+
}
|
|
2503
|
+
onProgress?.({
|
|
2504
|
+
type: "app_processing_complete",
|
|
2505
|
+
appKey: app.key
|
|
2506
|
+
});
|
|
2322
2507
|
} catch (error) {
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2508
|
+
const errorMessage = `Failed to generate types: ${error}`;
|
|
2509
|
+
result.errors.push({
|
|
2510
|
+
appKey: app.key,
|
|
2511
|
+
error: errorMessage
|
|
2512
|
+
});
|
|
2513
|
+
onProgress?.({
|
|
2514
|
+
type: "app_processing_error",
|
|
2515
|
+
appKey: app.key,
|
|
2516
|
+
error: errorMessage
|
|
2517
|
+
});
|
|
2518
|
+
}
|
|
2519
|
+
} catch (error) {
|
|
2520
|
+
const errorMessage = `Failed to process app: ${error}`;
|
|
2521
|
+
result.errors.push({
|
|
2522
|
+
appKey: app.key,
|
|
2523
|
+
error: errorMessage
|
|
2524
|
+
});
|
|
2525
|
+
onProgress?.({
|
|
2526
|
+
type: "app_processing_error",
|
|
2527
|
+
appKey: app.key,
|
|
2528
|
+
error: errorMessage
|
|
2529
|
+
});
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
return result;
|
|
2533
|
+
}, GenerateAppTypesSchema);
|
|
2534
|
+
return {
|
|
2535
|
+
generateAppTypes,
|
|
2536
|
+
context: {
|
|
2537
|
+
meta: {
|
|
2538
|
+
generateAppTypes: {
|
|
2539
|
+
categories: ["utility"],
|
|
2540
|
+
inputSchema: GenerateAppTypesSchema
|
|
2326
2541
|
}
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
};
|
|
2545
|
+
};
|
|
2546
|
+
var BuildManifestSchema = z.object({
|
|
2547
|
+
appKeys: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
2548
|
+
"One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello')"
|
|
2549
|
+
),
|
|
2550
|
+
skipWrite: z.boolean().optional().describe(
|
|
2551
|
+
"If true, returns manifest entries without writing to disk. If false or omitted, writes to the manifest file."
|
|
2552
|
+
),
|
|
2553
|
+
configPath: z.string().optional().describe(
|
|
2554
|
+
"Path to the manifest file. Only used when skipWrite is false or omitted."
|
|
2555
|
+
)
|
|
2556
|
+
}).describe(
|
|
2557
|
+
"Build manifest entries for apps - can optionally write to disk or just return JSON"
|
|
2558
|
+
);
|
|
2559
|
+
|
|
2560
|
+
// src/plugins/buildManifest/index.ts
|
|
2561
|
+
var buildManifestPlugin = ({ sdk: sdk2, context }) => {
|
|
2562
|
+
const buildManifest = createFunction(async function buildManifest2(options) {
|
|
2563
|
+
const { appKeys, skipWrite = false, configPath, onProgress } = options;
|
|
2564
|
+
const result = {
|
|
2565
|
+
errors: []
|
|
2566
|
+
};
|
|
2567
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
2568
|
+
const appsIterator = sdk2.listApps({ appKeys }).items();
|
|
2569
|
+
const apps = [];
|
|
2570
|
+
for await (const app of appsIterator) {
|
|
2571
|
+
apps.push(app);
|
|
2572
|
+
onProgress?.({ type: "app_found", app });
|
|
2573
|
+
}
|
|
2574
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
2575
|
+
if (apps.length === 0) {
|
|
2576
|
+
return result;
|
|
2577
|
+
}
|
|
2578
|
+
let updatedManifest;
|
|
2579
|
+
for (const app of apps) {
|
|
2580
|
+
onProgress?.({
|
|
2581
|
+
type: "app_processing_start",
|
|
2582
|
+
appKey: app.key,
|
|
2583
|
+
slug: app.slug
|
|
2584
|
+
});
|
|
2585
|
+
try {
|
|
2586
|
+
const manifestEntry = createManifestEntry(app);
|
|
2587
|
+
onProgress?.({
|
|
2588
|
+
type: "manifest_entry_built",
|
|
2589
|
+
appKey: app.key,
|
|
2590
|
+
manifestKey: manifestEntry.implementationName,
|
|
2591
|
+
version: manifestEntry.version
|
|
2592
|
+
});
|
|
2593
|
+
const [updatedManifestKey, , manifest] = await context.updateManifestEntry({
|
|
2594
|
+
appKey: app.key,
|
|
2595
|
+
entry: manifestEntry,
|
|
2596
|
+
configPath,
|
|
2597
|
+
skipWrite,
|
|
2598
|
+
manifest: updatedManifest
|
|
2599
|
+
});
|
|
2600
|
+
updatedManifest = manifest;
|
|
2601
|
+
onProgress?.({
|
|
2602
|
+
type: "manifest_updated",
|
|
2603
|
+
appKey: app.key,
|
|
2604
|
+
manifestKey: updatedManifestKey,
|
|
2605
|
+
version: manifestEntry.version
|
|
2606
|
+
});
|
|
2607
|
+
onProgress?.({ type: "app_processing_complete", appKey: app.key });
|
|
2327
2608
|
} catch (error) {
|
|
2328
|
-
|
|
2609
|
+
const errorMessage = `Failed to process app: ${error}`;
|
|
2610
|
+
result.errors.push({
|
|
2611
|
+
appKey: app.key,
|
|
2612
|
+
error: errorMessage
|
|
2613
|
+
});
|
|
2614
|
+
onProgress?.({
|
|
2615
|
+
type: "app_processing_error",
|
|
2616
|
+
appKey: app.key,
|
|
2617
|
+
error: errorMessage
|
|
2618
|
+
});
|
|
2329
2619
|
}
|
|
2330
2620
|
}
|
|
2331
|
-
|
|
2332
|
-
|
|
2621
|
+
result.manifest = updatedManifest;
|
|
2622
|
+
return result;
|
|
2623
|
+
}, BuildManifestSchema);
|
|
2333
2624
|
return {
|
|
2334
|
-
|
|
2625
|
+
buildManifest,
|
|
2335
2626
|
context: {
|
|
2336
2627
|
meta: {
|
|
2337
|
-
|
|
2628
|
+
buildManifest: {
|
|
2338
2629
|
categories: ["utility"],
|
|
2339
|
-
inputSchema:
|
|
2630
|
+
inputSchema: BuildManifestSchema
|
|
2340
2631
|
}
|
|
2341
2632
|
}
|
|
2342
2633
|
}
|
|
@@ -2345,23 +2636,15 @@ var addPlugin = ({ sdk: sdk2, context }) => {
|
|
|
2345
2636
|
|
|
2346
2637
|
// src/sdk.ts
|
|
2347
2638
|
function createZapierCliSdk(options = {}) {
|
|
2348
|
-
|
|
2639
|
+
return createZapierSdkWithoutRegistry({
|
|
2349
2640
|
debug: options.debug,
|
|
2350
2641
|
eventEmission: options.eventEmission
|
|
2351
|
-
});
|
|
2352
|
-
sdk2 = sdk2.addPlugin(bundleCodePlugin);
|
|
2353
|
-
sdk2 = sdk2.addPlugin(getLoginConfigPathPlugin);
|
|
2354
|
-
sdk2 = sdk2.addPlugin(addPlugin);
|
|
2355
|
-
sdk2 = sdk2.addPlugin(mcpPlugin);
|
|
2356
|
-
sdk2 = sdk2.addPlugin(loginPlugin);
|
|
2357
|
-
sdk2 = sdk2.addPlugin(logoutPlugin);
|
|
2358
|
-
const finalSdk = sdk2.addPlugin(registryPlugin);
|
|
2359
|
-
return finalSdk;
|
|
2642
|
+
}).addPlugin(generateAppTypesPlugin).addPlugin(buildManifestPlugin).addPlugin(bundleCodePlugin).addPlugin(getLoginConfigPathPlugin).addPlugin(addPlugin).addPlugin(mcpPlugin).addPlugin(loginPlugin).addPlugin(logoutPlugin).addPlugin(registryPlugin);
|
|
2360
2643
|
}
|
|
2361
2644
|
|
|
2362
2645
|
// package.json with { type: 'json' }
|
|
2363
2646
|
var package_default2 = {
|
|
2364
|
-
version: "0.13.
|
|
2647
|
+
version: "0.13.6"};
|
|
2365
2648
|
|
|
2366
2649
|
// src/cli.ts
|
|
2367
2650
|
var program = new Command();
|