@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.
- package/CHANGELOG.md +9 -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 +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 +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 +3 -3
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @zapier/zapier-sdk-cli
|
|
2
2
|
|
|
3
|
+
## 0.13.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 05ce6f7: 1. Extracted manifest creation and type generation into flexible base plugins that can be used by other consumers. 2. Updated updateManifestEntry function from base SDK to allow manipulating manifest as file or as JSON
|
|
8
|
+
- Updated dependencies [05ce6f7]
|
|
9
|
+
- @zapier/zapier-sdk@0.13.5
|
|
10
|
+
- @zapier/zapier-sdk-mcp@0.3.18
|
|
11
|
+
|
|
3
12
|
## 0.13.5
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
- [`request`](#request)
|
|
29
29
|
- [Utilities](#utilities)
|
|
30
30
|
- [`add`](#add)
|
|
31
|
+
- [`build-manifest`](#build-manifest)
|
|
31
32
|
- [`bundle-code`](#bundle-code)
|
|
33
|
+
- [`generate-app-types`](#generate-app-types)
|
|
32
34
|
- [`get-login-config-path`](#get-login-config-path)
|
|
33
35
|
- [`mcp`](#mcp)
|
|
34
36
|
|
|
@@ -384,6 +386,24 @@ Add apps with manifest locking and TypeScript type generation - updates .zapierr
|
|
|
384
386
|
npx zapier-sdk add <app-keys> [--authentication-ids] [--config-path] [--types-output]
|
|
385
387
|
```
|
|
386
388
|
|
|
389
|
+
#### `build-manifest`
|
|
390
|
+
|
|
391
|
+
Build manifest entries for apps - can optionally write to disk or just return JSON
|
|
392
|
+
|
|
393
|
+
**Options:**
|
|
394
|
+
|
|
395
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
396
|
+
| --------------- | --------- | -------- | ------- | --------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
397
|
+
| `<app-keys>` | `array` | ✅ | — | — | One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello') |
|
|
398
|
+
| `--skip-write` | `boolean` | ❌ | — | — | If true, returns manifest entries without writing to disk. If false or omitted, writes to the manifest file. |
|
|
399
|
+
| `--config-path` | `string` | ❌ | — | — | Path to the manifest file. Only used when skipWrite is false or omitted. |
|
|
400
|
+
|
|
401
|
+
**Usage:**
|
|
402
|
+
|
|
403
|
+
```bash
|
|
404
|
+
npx zapier-sdk build-manifest <app-keys> [--skip-write] [--config-path]
|
|
405
|
+
```
|
|
406
|
+
|
|
387
407
|
#### `bundle-code`
|
|
388
408
|
|
|
389
409
|
Bundle TypeScript code into executable JavaScript
|
|
@@ -405,6 +425,25 @@ Bundle TypeScript code into executable JavaScript
|
|
|
405
425
|
npx zapier-sdk bundle-code <input> [--output] [--string] [--minify] [--target] [--cjs]
|
|
406
426
|
```
|
|
407
427
|
|
|
428
|
+
#### `generate-app-types`
|
|
429
|
+
|
|
430
|
+
Generate TypeScript type definitions for apps - can optionally write to disk or just return type strings
|
|
431
|
+
|
|
432
|
+
**Options:**
|
|
433
|
+
|
|
434
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
435
|
+
| -------------------------- | --------- | -------- | ------- | --------------- | -------------------------------------------------------------------------------------------------- |
|
|
436
|
+
| `<app-keys>` | `array` | ✅ | — | — | One or more app keys to generate types for (e.g., 'slack', 'github', 'trello') |
|
|
437
|
+
| `--authentication-ids` | `array` | ❌ | — | — | Authentication IDs to use for type generation (e.g., ['123', '456']) |
|
|
438
|
+
| `--skip-write` | `boolean` | ❌ | — | — | If true, returns type definitions without writing to disk. If false or omitted, writes type files. |
|
|
439
|
+
| `--types-output-directory` | `string` | ❌ | — | — | Directory for TypeScript type files. Required when skipWrite is false or omitted. |
|
|
440
|
+
|
|
441
|
+
**Usage:**
|
|
442
|
+
|
|
443
|
+
```bash
|
|
444
|
+
npx zapier-sdk generate-app-types <app-keys> [--authentication-ids] [--skip-write] [--types-output-directory]
|
|
445
|
+
```
|
|
446
|
+
|
|
408
447
|
#### `get-login-config-path`
|
|
409
448
|
|
|
410
449
|
Show the path to the login configuration file
|
package/dist/cli.cjs
CHANGED
|
@@ -17,8 +17,8 @@ var zapierSdkMcp = require('@zapier/zapier-sdk-mcp');
|
|
|
17
17
|
var esbuild = require('esbuild');
|
|
18
18
|
var fs = require('fs');
|
|
19
19
|
var path = require('path');
|
|
20
|
-
var ts = require('typescript');
|
|
21
20
|
var promises = require('fs/promises');
|
|
21
|
+
var ts = require('typescript');
|
|
22
22
|
|
|
23
23
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
24
|
|
|
@@ -1407,7 +1407,7 @@ var LoginSchema = zod.z.object({
|
|
|
1407
1407
|
|
|
1408
1408
|
// package.json
|
|
1409
1409
|
var package_default = {
|
|
1410
|
-
version: "0.13.
|
|
1410
|
+
version: "0.13.6"};
|
|
1411
1411
|
|
|
1412
1412
|
// src/telemetry/builders.ts
|
|
1413
1413
|
function createCliBaseEvent(context = {}) {
|
|
@@ -1695,6 +1695,146 @@ var AddSchema = zod.z.object({
|
|
|
1695
1695
|
}).describe(
|
|
1696
1696
|
"Add apps with manifest locking and TypeScript type generation - updates .zapierrc with app versions and generates TypeScript definition files"
|
|
1697
1697
|
);
|
|
1698
|
+
async function detectTypesOutputDirectory() {
|
|
1699
|
+
const candidates = ["src", "lib"];
|
|
1700
|
+
for (const candidate of candidates) {
|
|
1701
|
+
try {
|
|
1702
|
+
await promises.access(candidate);
|
|
1703
|
+
return path.join(candidate, "zapier", "apps");
|
|
1704
|
+
} catch {
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
return "./zapier/apps/";
|
|
1708
|
+
}
|
|
1709
|
+
var addPlugin = ({ sdk: sdk2 }) => {
|
|
1710
|
+
const add = zapierSdk.createFunction(async function add2(options) {
|
|
1711
|
+
const {
|
|
1712
|
+
appKeys,
|
|
1713
|
+
authenticationIds,
|
|
1714
|
+
configPath,
|
|
1715
|
+
typesOutput = await detectTypesOutputDirectory()
|
|
1716
|
+
} = options;
|
|
1717
|
+
const resolvedTypesOutput = path.resolve(typesOutput);
|
|
1718
|
+
console.log(`\u{1F4E6} Adding ${appKeys.length} app(s)...`);
|
|
1719
|
+
const appSlugAndKeyMap = /* @__PURE__ */ new Map();
|
|
1720
|
+
const handleManifestProgress = (event) => {
|
|
1721
|
+
switch (event.type) {
|
|
1722
|
+
case "apps_lookup_start":
|
|
1723
|
+
console.log(`\u{1F4E6} Looking up ${event.count} app(s)...`);
|
|
1724
|
+
break;
|
|
1725
|
+
case "app_found":
|
|
1726
|
+
const displayName = event.app.slug ? `${event.app.slug} (${event.app.key})` : event.app.key;
|
|
1727
|
+
appSlugAndKeyMap.set(event.app.key, displayName);
|
|
1728
|
+
break;
|
|
1729
|
+
case "apps_lookup_complete":
|
|
1730
|
+
if (event.count === 0) {
|
|
1731
|
+
console.warn("\u26A0\uFE0F No apps found");
|
|
1732
|
+
}
|
|
1733
|
+
break;
|
|
1734
|
+
case "app_processing_start":
|
|
1735
|
+
const appName = event.slug ? `${event.slug} (${event.appKey})` : event.appKey;
|
|
1736
|
+
console.log(`\u{1F4E6} Adding ${appName}...`);
|
|
1737
|
+
break;
|
|
1738
|
+
case "manifest_updated":
|
|
1739
|
+
const appDisplay = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1740
|
+
console.log(
|
|
1741
|
+
`\u{1F4DD} Locked ${appDisplay} to ${event.appKey}@${event.version} using key '${event.manifestKey}'`
|
|
1742
|
+
);
|
|
1743
|
+
break;
|
|
1744
|
+
case "app_processing_error":
|
|
1745
|
+
const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1746
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
1747
|
+
break;
|
|
1748
|
+
}
|
|
1749
|
+
};
|
|
1750
|
+
const handleTypesProgress = (event) => {
|
|
1751
|
+
switch (event.type) {
|
|
1752
|
+
case "authentications_lookup_start":
|
|
1753
|
+
console.log(`\u{1F510} Looking up ${event.count} authentication(s)...`);
|
|
1754
|
+
break;
|
|
1755
|
+
case "authentications_lookup_complete":
|
|
1756
|
+
console.log(`\u{1F510} Found ${event.count} authentication(s)`);
|
|
1757
|
+
break;
|
|
1758
|
+
case "authentication_matched":
|
|
1759
|
+
const appWithAuth = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1760
|
+
console.log(
|
|
1761
|
+
`\u{1F510} Using authentication ${event.authenticationId} (${event.authenticationTitle}) for ${appWithAuth}`
|
|
1762
|
+
);
|
|
1763
|
+
break;
|
|
1764
|
+
case "authentication_not_matched":
|
|
1765
|
+
const appWithoutAuth = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1766
|
+
console.warn(
|
|
1767
|
+
`\u26A0\uFE0F No matching authentication found for ${appWithoutAuth}`
|
|
1768
|
+
);
|
|
1769
|
+
break;
|
|
1770
|
+
case "file_written":
|
|
1771
|
+
console.log(
|
|
1772
|
+
`\u{1F527} Generated types for ${event.manifestKey} at ${event.filePath}`
|
|
1773
|
+
);
|
|
1774
|
+
break;
|
|
1775
|
+
case "app_processing_error":
|
|
1776
|
+
const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1777
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
1778
|
+
break;
|
|
1779
|
+
}
|
|
1780
|
+
};
|
|
1781
|
+
const manifestResult = await sdk2.buildManifest({
|
|
1782
|
+
appKeys,
|
|
1783
|
+
skipWrite: false,
|
|
1784
|
+
configPath,
|
|
1785
|
+
onProgress: handleManifestProgress
|
|
1786
|
+
});
|
|
1787
|
+
const typesResult = await sdk2.generateAppTypes({
|
|
1788
|
+
appKeys,
|
|
1789
|
+
authenticationIds,
|
|
1790
|
+
skipWrite: false,
|
|
1791
|
+
typesOutputDirectory: resolvedTypesOutput,
|
|
1792
|
+
onProgress: handleTypesProgress
|
|
1793
|
+
});
|
|
1794
|
+
const results = manifestResult.manifest?.apps || {};
|
|
1795
|
+
const successfulApps = Object.keys(results).filter(
|
|
1796
|
+
(manifestKey) => typesResult.writtenFiles?.[manifestKey]
|
|
1797
|
+
);
|
|
1798
|
+
if (successfulApps.length > 0) {
|
|
1799
|
+
console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
|
|
1800
|
+
}
|
|
1801
|
+
const allErrors = [...manifestResult.errors, ...typesResult.errors];
|
|
1802
|
+
if (allErrors.length > 0) {
|
|
1803
|
+
console.warn(`
|
|
1804
|
+
\u26A0\uFE0F ${allErrors.length} error(s) occurred:`);
|
|
1805
|
+
allErrors.forEach(({ appKey, error }) => {
|
|
1806
|
+
console.warn(` - ${appKey}: ${error}`);
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
}, AddSchema);
|
|
1810
|
+
return {
|
|
1811
|
+
add,
|
|
1812
|
+
context: {
|
|
1813
|
+
meta: {
|
|
1814
|
+
add: {
|
|
1815
|
+
categories: ["utility"],
|
|
1816
|
+
inputSchema: AddSchema
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
};
|
|
1821
|
+
};
|
|
1822
|
+
var GenerateAppTypesSchema = zod.z.object({
|
|
1823
|
+
appKeys: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
1824
|
+
"One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
|
|
1825
|
+
),
|
|
1826
|
+
authenticationIds: zod.z.array(zod.z.string()).optional().describe(
|
|
1827
|
+
"Authentication IDs to use for type generation (e.g., ['123', '456'])"
|
|
1828
|
+
),
|
|
1829
|
+
skipWrite: zod.z.boolean().optional().describe(
|
|
1830
|
+
"If true, returns type definitions without writing to disk. If false or omitted, writes type files."
|
|
1831
|
+
),
|
|
1832
|
+
typesOutputDirectory: zod.z.string().optional().describe(
|
|
1833
|
+
"Directory for TypeScript type files. Required when skipWrite is false or omitted."
|
|
1834
|
+
)
|
|
1835
|
+
}).describe(
|
|
1836
|
+
"Generate TypeScript type definitions for apps - can optionally write to disk or just return type strings"
|
|
1837
|
+
);
|
|
1698
1838
|
var AstTypeGenerator = class {
|
|
1699
1839
|
constructor() {
|
|
1700
1840
|
this.factory = ts__namespace.factory;
|
|
@@ -2263,69 +2403,92 @@ Usage:
|
|
|
2263
2403
|
return Array.from(allKeys);
|
|
2264
2404
|
}
|
|
2265
2405
|
};
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2406
|
+
|
|
2407
|
+
// src/utils/manifest-helpers.ts
|
|
2408
|
+
function getManifestKey(app) {
|
|
2409
|
+
return app.slug || app.key;
|
|
2410
|
+
}
|
|
2411
|
+
function createManifestEntry(app) {
|
|
2412
|
+
if (!app.version) {
|
|
2413
|
+
throw new Error(
|
|
2414
|
+
`App ${app.key} does not have a version. Implementation ID: ${app.implementation_id}`
|
|
2415
|
+
);
|
|
2274
2416
|
}
|
|
2275
|
-
return
|
|
2417
|
+
return {
|
|
2418
|
+
implementationName: app.key,
|
|
2419
|
+
version: app.version
|
|
2420
|
+
};
|
|
2276
2421
|
}
|
|
2277
|
-
var
|
|
2278
|
-
const
|
|
2422
|
+
var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
|
|
2423
|
+
const generateAppTypes = zapierSdk.createFunction(async function generateAppTypes2(options) {
|
|
2279
2424
|
const {
|
|
2280
2425
|
appKeys,
|
|
2281
2426
|
authenticationIds,
|
|
2282
|
-
|
|
2283
|
-
|
|
2427
|
+
skipWrite = false,
|
|
2428
|
+
typesOutputDirectory,
|
|
2429
|
+
onProgress
|
|
2284
2430
|
} = options;
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2431
|
+
if (!skipWrite && !typesOutputDirectory) {
|
|
2432
|
+
throw new Error(
|
|
2433
|
+
"typesOutputDirectory is required when skipWrite is false"
|
|
2434
|
+
);
|
|
2435
|
+
}
|
|
2436
|
+
const result = {
|
|
2437
|
+
typeDefinitions: {},
|
|
2438
|
+
errors: []
|
|
2439
|
+
};
|
|
2440
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
2288
2441
|
const appsIterator = sdk2.listApps({ appKeys }).items();
|
|
2289
2442
|
const apps = [];
|
|
2290
2443
|
for await (const app of appsIterator) {
|
|
2291
2444
|
apps.push(app);
|
|
2445
|
+
onProgress?.({ type: "app_found", app });
|
|
2292
2446
|
}
|
|
2447
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
2293
2448
|
if (apps.length === 0) {
|
|
2294
|
-
|
|
2295
|
-
return;
|
|
2449
|
+
return result;
|
|
2296
2450
|
}
|
|
2297
|
-
|
|
2451
|
+
const authentications = [];
|
|
2298
2452
|
if (authenticationIds && authenticationIds.length > 0) {
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2453
|
+
onProgress?.({
|
|
2454
|
+
type: "authentications_lookup_start",
|
|
2455
|
+
count: authenticationIds.length
|
|
2456
|
+
});
|
|
2302
2457
|
const authsIterator = sdk2.listAuthentications({ authenticationIds }).items();
|
|
2303
2458
|
for await (const auth of authsIterator) {
|
|
2304
2459
|
authentications.push(auth);
|
|
2305
2460
|
}
|
|
2306
|
-
|
|
2461
|
+
onProgress?.({
|
|
2462
|
+
type: "authentications_lookup_complete",
|
|
2463
|
+
count: authentications.length
|
|
2464
|
+
});
|
|
2465
|
+
}
|
|
2466
|
+
if (!skipWrite && typesOutputDirectory) {
|
|
2467
|
+
await promises.mkdir(typesOutputDirectory, { recursive: true });
|
|
2468
|
+
}
|
|
2469
|
+
if (!skipWrite) {
|
|
2470
|
+
result.writtenFiles = {};
|
|
2307
2471
|
}
|
|
2308
2472
|
for (const app of apps) {
|
|
2309
|
-
|
|
2310
|
-
|
|
2473
|
+
onProgress?.({
|
|
2474
|
+
type: "app_processing_start",
|
|
2475
|
+
appKey: app.key,
|
|
2476
|
+
slug: app.slug
|
|
2477
|
+
});
|
|
2311
2478
|
try {
|
|
2312
2479
|
if (!app.version) {
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2480
|
+
const error = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
|
|
2481
|
+
result.errors.push({
|
|
2482
|
+
appKey: app.key,
|
|
2483
|
+
error
|
|
2484
|
+
});
|
|
2485
|
+
onProgress?.({
|
|
2486
|
+
type: "app_processing_error",
|
|
2487
|
+
appKey: app.key,
|
|
2488
|
+
error
|
|
2489
|
+
});
|
|
2316
2490
|
continue;
|
|
2317
2491
|
}
|
|
2318
|
-
const [manifestKey] = await context.updateManifestEntry(
|
|
2319
|
-
app.key,
|
|
2320
|
-
{
|
|
2321
|
-
implementationName: app.key,
|
|
2322
|
-
version: app.version
|
|
2323
|
-
},
|
|
2324
|
-
configPath
|
|
2325
|
-
);
|
|
2326
|
-
console.log(
|
|
2327
|
-
`\u{1F4DD} Locked ${appSlugAndKey} to ${app.key}@${app.version} using key '${manifestKey}'`
|
|
2328
|
-
);
|
|
2329
2492
|
let authenticationId;
|
|
2330
2493
|
if (authentications.length > 0) {
|
|
2331
2494
|
const matchingAuth = authentications.find((auth) => {
|
|
@@ -2333,43 +2496,171 @@ var addPlugin = ({ sdk: sdk2, context }) => {
|
|
|
2333
2496
|
});
|
|
2334
2497
|
if (matchingAuth) {
|
|
2335
2498
|
authenticationId = matchingAuth.id;
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2499
|
+
onProgress?.({
|
|
2500
|
+
type: "authentication_matched",
|
|
2501
|
+
appKey: app.key,
|
|
2502
|
+
authenticationId: matchingAuth.id,
|
|
2503
|
+
authenticationTitle: matchingAuth.title || ""
|
|
2504
|
+
});
|
|
2339
2505
|
} else {
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2506
|
+
onProgress?.({
|
|
2507
|
+
type: "authentication_not_matched",
|
|
2508
|
+
appKey: app.key
|
|
2509
|
+
});
|
|
2343
2510
|
}
|
|
2344
2511
|
}
|
|
2345
|
-
const
|
|
2512
|
+
const manifestKey = getManifestKey(app);
|
|
2346
2513
|
try {
|
|
2347
2514
|
const generator = new AstTypeGenerator();
|
|
2348
|
-
const
|
|
2515
|
+
const typeDefinitionString = await generator.generateTypes({
|
|
2349
2516
|
app,
|
|
2350
2517
|
authenticationId,
|
|
2351
2518
|
sdk: sdk2
|
|
2352
2519
|
});
|
|
2353
|
-
|
|
2354
|
-
|
|
2520
|
+
result.typeDefinitions[manifestKey] = typeDefinitionString;
|
|
2521
|
+
onProgress?.({
|
|
2522
|
+
type: "type_generated",
|
|
2523
|
+
manifestKey,
|
|
2524
|
+
sizeBytes: typeDefinitionString.length
|
|
2525
|
+
});
|
|
2526
|
+
if (!skipWrite && typesOutputDirectory && result.writtenFiles) {
|
|
2527
|
+
const filePath = path.join(typesOutputDirectory, `${manifestKey}.d.ts`);
|
|
2528
|
+
await promises.writeFile(filePath, typeDefinitionString, "utf8");
|
|
2529
|
+
result.writtenFiles[manifestKey] = filePath;
|
|
2530
|
+
onProgress?.({
|
|
2531
|
+
type: "file_written",
|
|
2532
|
+
manifestKey,
|
|
2533
|
+
filePath
|
|
2534
|
+
});
|
|
2535
|
+
}
|
|
2536
|
+
onProgress?.({
|
|
2537
|
+
type: "app_processing_complete",
|
|
2538
|
+
appKey: app.key
|
|
2539
|
+
});
|
|
2355
2540
|
} catch (error) {
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2541
|
+
const errorMessage = `Failed to generate types: ${error}`;
|
|
2542
|
+
result.errors.push({
|
|
2543
|
+
appKey: app.key,
|
|
2544
|
+
error: errorMessage
|
|
2545
|
+
});
|
|
2546
|
+
onProgress?.({
|
|
2547
|
+
type: "app_processing_error",
|
|
2548
|
+
appKey: app.key,
|
|
2549
|
+
error: errorMessage
|
|
2550
|
+
});
|
|
2551
|
+
}
|
|
2552
|
+
} catch (error) {
|
|
2553
|
+
const errorMessage = `Failed to process app: ${error}`;
|
|
2554
|
+
result.errors.push({
|
|
2555
|
+
appKey: app.key,
|
|
2556
|
+
error: errorMessage
|
|
2557
|
+
});
|
|
2558
|
+
onProgress?.({
|
|
2559
|
+
type: "app_processing_error",
|
|
2560
|
+
appKey: app.key,
|
|
2561
|
+
error: errorMessage
|
|
2562
|
+
});
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
return result;
|
|
2566
|
+
}, GenerateAppTypesSchema);
|
|
2567
|
+
return {
|
|
2568
|
+
generateAppTypes,
|
|
2569
|
+
context: {
|
|
2570
|
+
meta: {
|
|
2571
|
+
generateAppTypes: {
|
|
2572
|
+
categories: ["utility"],
|
|
2573
|
+
inputSchema: GenerateAppTypesSchema
|
|
2359
2574
|
}
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
};
|
|
2578
|
+
};
|
|
2579
|
+
var BuildManifestSchema = zod.z.object({
|
|
2580
|
+
appKeys: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
2581
|
+
"One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello')"
|
|
2582
|
+
),
|
|
2583
|
+
skipWrite: zod.z.boolean().optional().describe(
|
|
2584
|
+
"If true, returns manifest entries without writing to disk. If false or omitted, writes to the manifest file."
|
|
2585
|
+
),
|
|
2586
|
+
configPath: zod.z.string().optional().describe(
|
|
2587
|
+
"Path to the manifest file. Only used when skipWrite is false or omitted."
|
|
2588
|
+
)
|
|
2589
|
+
}).describe(
|
|
2590
|
+
"Build manifest entries for apps - can optionally write to disk or just return JSON"
|
|
2591
|
+
);
|
|
2592
|
+
|
|
2593
|
+
// src/plugins/buildManifest/index.ts
|
|
2594
|
+
var buildManifestPlugin = ({ sdk: sdk2, context }) => {
|
|
2595
|
+
const buildManifest = zapierSdk.createFunction(async function buildManifest2(options) {
|
|
2596
|
+
const { appKeys, skipWrite = false, configPath, onProgress } = options;
|
|
2597
|
+
const result = {
|
|
2598
|
+
errors: []
|
|
2599
|
+
};
|
|
2600
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
2601
|
+
const appsIterator = sdk2.listApps({ appKeys }).items();
|
|
2602
|
+
const apps = [];
|
|
2603
|
+
for await (const app of appsIterator) {
|
|
2604
|
+
apps.push(app);
|
|
2605
|
+
onProgress?.({ type: "app_found", app });
|
|
2606
|
+
}
|
|
2607
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
2608
|
+
if (apps.length === 0) {
|
|
2609
|
+
return result;
|
|
2610
|
+
}
|
|
2611
|
+
let updatedManifest;
|
|
2612
|
+
for (const app of apps) {
|
|
2613
|
+
onProgress?.({
|
|
2614
|
+
type: "app_processing_start",
|
|
2615
|
+
appKey: app.key,
|
|
2616
|
+
slug: app.slug
|
|
2617
|
+
});
|
|
2618
|
+
try {
|
|
2619
|
+
const manifestEntry = createManifestEntry(app);
|
|
2620
|
+
onProgress?.({
|
|
2621
|
+
type: "manifest_entry_built",
|
|
2622
|
+
appKey: app.key,
|
|
2623
|
+
manifestKey: manifestEntry.implementationName,
|
|
2624
|
+
version: manifestEntry.version
|
|
2625
|
+
});
|
|
2626
|
+
const [updatedManifestKey, , manifest] = await context.updateManifestEntry({
|
|
2627
|
+
appKey: app.key,
|
|
2628
|
+
entry: manifestEntry,
|
|
2629
|
+
configPath,
|
|
2630
|
+
skipWrite,
|
|
2631
|
+
manifest: updatedManifest
|
|
2632
|
+
});
|
|
2633
|
+
updatedManifest = manifest;
|
|
2634
|
+
onProgress?.({
|
|
2635
|
+
type: "manifest_updated",
|
|
2636
|
+
appKey: app.key,
|
|
2637
|
+
manifestKey: updatedManifestKey,
|
|
2638
|
+
version: manifestEntry.version
|
|
2639
|
+
});
|
|
2640
|
+
onProgress?.({ type: "app_processing_complete", appKey: app.key });
|
|
2360
2641
|
} catch (error) {
|
|
2361
|
-
|
|
2642
|
+
const errorMessage = `Failed to process app: ${error}`;
|
|
2643
|
+
result.errors.push({
|
|
2644
|
+
appKey: app.key,
|
|
2645
|
+
error: errorMessage
|
|
2646
|
+
});
|
|
2647
|
+
onProgress?.({
|
|
2648
|
+
type: "app_processing_error",
|
|
2649
|
+
appKey: app.key,
|
|
2650
|
+
error: errorMessage
|
|
2651
|
+
});
|
|
2362
2652
|
}
|
|
2363
2653
|
}
|
|
2364
|
-
|
|
2365
|
-
|
|
2654
|
+
result.manifest = updatedManifest;
|
|
2655
|
+
return result;
|
|
2656
|
+
}, BuildManifestSchema);
|
|
2366
2657
|
return {
|
|
2367
|
-
|
|
2658
|
+
buildManifest,
|
|
2368
2659
|
context: {
|
|
2369
2660
|
meta: {
|
|
2370
|
-
|
|
2661
|
+
buildManifest: {
|
|
2371
2662
|
categories: ["utility"],
|
|
2372
|
-
inputSchema:
|
|
2663
|
+
inputSchema: BuildManifestSchema
|
|
2373
2664
|
}
|
|
2374
2665
|
}
|
|
2375
2666
|
}
|
|
@@ -2378,23 +2669,15 @@ var addPlugin = ({ sdk: sdk2, context }) => {
|
|
|
2378
2669
|
|
|
2379
2670
|
// src/sdk.ts
|
|
2380
2671
|
function createZapierCliSdk(options = {}) {
|
|
2381
|
-
|
|
2672
|
+
return zapierSdk.createZapierSdkWithoutRegistry({
|
|
2382
2673
|
debug: options.debug,
|
|
2383
2674
|
eventEmission: options.eventEmission
|
|
2384
|
-
});
|
|
2385
|
-
sdk2 = sdk2.addPlugin(bundleCodePlugin);
|
|
2386
|
-
sdk2 = sdk2.addPlugin(getLoginConfigPathPlugin);
|
|
2387
|
-
sdk2 = sdk2.addPlugin(addPlugin);
|
|
2388
|
-
sdk2 = sdk2.addPlugin(mcpPlugin);
|
|
2389
|
-
sdk2 = sdk2.addPlugin(loginPlugin);
|
|
2390
|
-
sdk2 = sdk2.addPlugin(logoutPlugin);
|
|
2391
|
-
const finalSdk = sdk2.addPlugin(zapierSdk.registryPlugin);
|
|
2392
|
-
return finalSdk;
|
|
2675
|
+
}).addPlugin(generateAppTypesPlugin).addPlugin(buildManifestPlugin).addPlugin(bundleCodePlugin).addPlugin(getLoginConfigPathPlugin).addPlugin(addPlugin).addPlugin(mcpPlugin).addPlugin(loginPlugin).addPlugin(logoutPlugin).addPlugin(zapierSdk.registryPlugin);
|
|
2393
2676
|
}
|
|
2394
2677
|
|
|
2395
2678
|
// package.json with { type: 'json' }
|
|
2396
2679
|
var package_default2 = {
|
|
2397
|
-
version: "0.13.
|
|
2680
|
+
version: "0.13.6"};
|
|
2398
2681
|
|
|
2399
2682
|
// src/cli.ts
|
|
2400
2683
|
var program = new commander.Command();
|