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