@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @zapier/zapier-sdk-cli
|
|
2
2
|
|
|
3
|
+
## 0.13.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9b7a954: Change OAuth client ID.
|
|
8
|
+
- a563cda: Extend ZapierCliSdkOptions with the base ZapierSdkOptions so we can see the token and other properties when initializing with createZapierSdkCli
|
|
9
|
+
- Updated dependencies [9b7a954]
|
|
10
|
+
- Updated dependencies [a563cda]
|
|
11
|
+
- @zapier/zapier-sdk-cli-login@0.3.3
|
|
12
|
+
- @zapier/zapier-sdk@0.13.6
|
|
13
|
+
- @zapier/zapier-sdk-mcp@0.3.19
|
|
14
|
+
|
|
15
|
+
## 0.13.6
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 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
|
|
20
|
+
- Updated dependencies [05ce6f7]
|
|
21
|
+
- @zapier/zapier-sdk@0.13.5
|
|
22
|
+
- @zapier/zapier-sdk-mcp@0.3.18
|
|
23
|
+
|
|
3
24
|
## 0.13.5
|
|
4
25
|
|
|
5
26
|
### 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
|
@@ -11,14 +11,14 @@ var open = require('open');
|
|
|
11
11
|
var crypto = require('crypto');
|
|
12
12
|
var express = require('express');
|
|
13
13
|
var pkceChallenge = require('pkce-challenge');
|
|
14
|
-
var ora = require('ora');
|
|
15
14
|
var zapierSdkCliLogin = require('@zapier/zapier-sdk-cli-login');
|
|
15
|
+
var ora = require('ora');
|
|
16
16
|
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
|
|
|
@@ -1191,13 +1191,8 @@ function getListTitleFromMethod(methodName, functionInfo) {
|
|
|
1191
1191
|
}
|
|
1192
1192
|
return `${methodName} items`;
|
|
1193
1193
|
}
|
|
1194
|
-
|
|
1195
|
-
// src/utils/constants.ts
|
|
1196
|
-
var ZAPIER_BASE = "https://zapier.com";
|
|
1197
|
-
var LOGIN_CLIENT_ID = "K5eEnRE9TTmSFATdkkWhKF8NOKwoiOnYAyIqJjae";
|
|
1198
1194
|
var LOGIN_PORTS = [49505, 50575, 52804, 55981, 61010, 63851];
|
|
1199
1195
|
var LOGIN_TIMEOUT_MS = 3e5;
|
|
1200
|
-
var AUTH_MODE_HEADER = "X-Auth";
|
|
1201
1196
|
var spinPromise = async (promise, text) => {
|
|
1202
1197
|
const spinner = ora__default.default(text).start();
|
|
1203
1198
|
try {
|
|
@@ -1336,9 +1331,9 @@ var login = async (timeoutMs = LOGIN_TIMEOUT_MS) => {
|
|
|
1336
1331
|
process.on("SIGINT", cleanup);
|
|
1337
1332
|
process.on("SIGTERM", cleanup);
|
|
1338
1333
|
const { code_verifier: codeVerifier, code_challenge: codeChallenge } = await pkceChallenge__default.default();
|
|
1339
|
-
const authUrl = `${ZAPIER_BASE}/oauth/authorize/?${new URLSearchParams({
|
|
1334
|
+
const authUrl = `${zapierSdkCliLogin.ZAPIER_BASE}/oauth/authorize/?${new URLSearchParams({
|
|
1340
1335
|
response_type: "code",
|
|
1341
|
-
client_id: LOGIN_CLIENT_ID,
|
|
1336
|
+
client_id: zapierSdkCliLogin.LOGIN_CLIENT_ID,
|
|
1342
1337
|
redirect_uri: redirectUri,
|
|
1343
1338
|
scope: "internal offline_access",
|
|
1344
1339
|
state: generateRandomString(),
|
|
@@ -1381,17 +1376,17 @@ var login = async (timeoutMs = LOGIN_TIMEOUT_MS) => {
|
|
|
1381
1376
|
}
|
|
1382
1377
|
log_default.info("Exchanging authorization code for tokens...");
|
|
1383
1378
|
const { data } = await client_default.post(
|
|
1384
|
-
`${ZAPIER_BASE}/oauth/token/`,
|
|
1379
|
+
`${zapierSdkCliLogin.ZAPIER_BASE}/oauth/token/`,
|
|
1385
1380
|
{
|
|
1386
1381
|
grant_type: "authorization_code",
|
|
1387
1382
|
code: await promisedCode,
|
|
1388
1383
|
redirect_uri: redirectUri,
|
|
1389
|
-
client_id: LOGIN_CLIENT_ID,
|
|
1384
|
+
client_id: zapierSdkCliLogin.LOGIN_CLIENT_ID,
|
|
1390
1385
|
code_verifier: codeVerifier
|
|
1391
1386
|
},
|
|
1392
1387
|
{
|
|
1393
1388
|
headers: {
|
|
1394
|
-
[AUTH_MODE_HEADER]: "no",
|
|
1389
|
+
[zapierSdkCliLogin.AUTH_MODE_HEADER]: "no",
|
|
1395
1390
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
1396
1391
|
}
|
|
1397
1392
|
}
|
|
@@ -1407,7 +1402,7 @@ var LoginSchema = zod.z.object({
|
|
|
1407
1402
|
|
|
1408
1403
|
// package.json
|
|
1409
1404
|
var package_default = {
|
|
1410
|
-
version: "0.13.
|
|
1405
|
+
version: "0.13.7"};
|
|
1411
1406
|
|
|
1412
1407
|
// src/telemetry/builders.ts
|
|
1413
1408
|
function createCliBaseEvent(context = {}) {
|
|
@@ -1695,6 +1690,146 @@ var AddSchema = zod.z.object({
|
|
|
1695
1690
|
}).describe(
|
|
1696
1691
|
"Add apps with manifest locking and TypeScript type generation - updates .zapierrc with app versions and generates TypeScript definition files"
|
|
1697
1692
|
);
|
|
1693
|
+
async function detectTypesOutputDirectory() {
|
|
1694
|
+
const candidates = ["src", "lib"];
|
|
1695
|
+
for (const candidate of candidates) {
|
|
1696
|
+
try {
|
|
1697
|
+
await promises.access(candidate);
|
|
1698
|
+
return path.join(candidate, "zapier", "apps");
|
|
1699
|
+
} catch {
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
return "./zapier/apps/";
|
|
1703
|
+
}
|
|
1704
|
+
var addPlugin = ({ sdk: sdk2 }) => {
|
|
1705
|
+
const add = zapierSdk.createFunction(async function add2(options) {
|
|
1706
|
+
const {
|
|
1707
|
+
appKeys,
|
|
1708
|
+
authenticationIds,
|
|
1709
|
+
configPath,
|
|
1710
|
+
typesOutput = await detectTypesOutputDirectory()
|
|
1711
|
+
} = options;
|
|
1712
|
+
const resolvedTypesOutput = path.resolve(typesOutput);
|
|
1713
|
+
console.log(`\u{1F4E6} Adding ${appKeys.length} app(s)...`);
|
|
1714
|
+
const appSlugAndKeyMap = /* @__PURE__ */ new Map();
|
|
1715
|
+
const handleManifestProgress = (event) => {
|
|
1716
|
+
switch (event.type) {
|
|
1717
|
+
case "apps_lookup_start":
|
|
1718
|
+
console.log(`\u{1F4E6} Looking up ${event.count} app(s)...`);
|
|
1719
|
+
break;
|
|
1720
|
+
case "app_found":
|
|
1721
|
+
const displayName = event.app.slug ? `${event.app.slug} (${event.app.key})` : event.app.key;
|
|
1722
|
+
appSlugAndKeyMap.set(event.app.key, displayName);
|
|
1723
|
+
break;
|
|
1724
|
+
case "apps_lookup_complete":
|
|
1725
|
+
if (event.count === 0) {
|
|
1726
|
+
console.warn("\u26A0\uFE0F No apps found");
|
|
1727
|
+
}
|
|
1728
|
+
break;
|
|
1729
|
+
case "app_processing_start":
|
|
1730
|
+
const appName = event.slug ? `${event.slug} (${event.appKey})` : event.appKey;
|
|
1731
|
+
console.log(`\u{1F4E6} Adding ${appName}...`);
|
|
1732
|
+
break;
|
|
1733
|
+
case "manifest_updated":
|
|
1734
|
+
const appDisplay = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1735
|
+
console.log(
|
|
1736
|
+
`\u{1F4DD} Locked ${appDisplay} to ${event.appKey}@${event.version} using key '${event.manifestKey}'`
|
|
1737
|
+
);
|
|
1738
|
+
break;
|
|
1739
|
+
case "app_processing_error":
|
|
1740
|
+
const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1741
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
1742
|
+
break;
|
|
1743
|
+
}
|
|
1744
|
+
};
|
|
1745
|
+
const handleTypesProgress = (event) => {
|
|
1746
|
+
switch (event.type) {
|
|
1747
|
+
case "authentications_lookup_start":
|
|
1748
|
+
console.log(`\u{1F510} Looking up ${event.count} authentication(s)...`);
|
|
1749
|
+
break;
|
|
1750
|
+
case "authentications_lookup_complete":
|
|
1751
|
+
console.log(`\u{1F510} Found ${event.count} authentication(s)`);
|
|
1752
|
+
break;
|
|
1753
|
+
case "authentication_matched":
|
|
1754
|
+
const appWithAuth = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1755
|
+
console.log(
|
|
1756
|
+
`\u{1F510} Using authentication ${event.authenticationId} (${event.authenticationTitle}) for ${appWithAuth}`
|
|
1757
|
+
);
|
|
1758
|
+
break;
|
|
1759
|
+
case "authentication_not_matched":
|
|
1760
|
+
const appWithoutAuth = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1761
|
+
console.warn(
|
|
1762
|
+
`\u26A0\uFE0F No matching authentication found for ${appWithoutAuth}`
|
|
1763
|
+
);
|
|
1764
|
+
break;
|
|
1765
|
+
case "file_written":
|
|
1766
|
+
console.log(
|
|
1767
|
+
`\u{1F527} Generated types for ${event.manifestKey} at ${event.filePath}`
|
|
1768
|
+
);
|
|
1769
|
+
break;
|
|
1770
|
+
case "app_processing_error":
|
|
1771
|
+
const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
1772
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
1773
|
+
break;
|
|
1774
|
+
}
|
|
1775
|
+
};
|
|
1776
|
+
const manifestResult = await sdk2.buildManifest({
|
|
1777
|
+
appKeys,
|
|
1778
|
+
skipWrite: false,
|
|
1779
|
+
configPath,
|
|
1780
|
+
onProgress: handleManifestProgress
|
|
1781
|
+
});
|
|
1782
|
+
const typesResult = await sdk2.generateAppTypes({
|
|
1783
|
+
appKeys,
|
|
1784
|
+
authenticationIds,
|
|
1785
|
+
skipWrite: false,
|
|
1786
|
+
typesOutputDirectory: resolvedTypesOutput,
|
|
1787
|
+
onProgress: handleTypesProgress
|
|
1788
|
+
});
|
|
1789
|
+
const results = manifestResult.manifest?.apps || {};
|
|
1790
|
+
const successfulApps = Object.keys(results).filter(
|
|
1791
|
+
(manifestKey) => typesResult.writtenFiles?.[manifestKey]
|
|
1792
|
+
);
|
|
1793
|
+
if (successfulApps.length > 0) {
|
|
1794
|
+
console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
|
|
1795
|
+
}
|
|
1796
|
+
const allErrors = [...manifestResult.errors, ...typesResult.errors];
|
|
1797
|
+
if (allErrors.length > 0) {
|
|
1798
|
+
console.warn(`
|
|
1799
|
+
\u26A0\uFE0F ${allErrors.length} error(s) occurred:`);
|
|
1800
|
+
allErrors.forEach(({ appKey, error }) => {
|
|
1801
|
+
console.warn(` - ${appKey}: ${error}`);
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
}, AddSchema);
|
|
1805
|
+
return {
|
|
1806
|
+
add,
|
|
1807
|
+
context: {
|
|
1808
|
+
meta: {
|
|
1809
|
+
add: {
|
|
1810
|
+
categories: ["utility"],
|
|
1811
|
+
inputSchema: AddSchema
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
};
|
|
1816
|
+
};
|
|
1817
|
+
var GenerateAppTypesSchema = zod.z.object({
|
|
1818
|
+
appKeys: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
1819
|
+
"One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
|
|
1820
|
+
),
|
|
1821
|
+
authenticationIds: zod.z.array(zod.z.string()).optional().describe(
|
|
1822
|
+
"Authentication IDs to use for type generation (e.g., ['123', '456'])"
|
|
1823
|
+
),
|
|
1824
|
+
skipWrite: zod.z.boolean().optional().describe(
|
|
1825
|
+
"If true, returns type definitions without writing to disk. If false or omitted, writes type files."
|
|
1826
|
+
),
|
|
1827
|
+
typesOutputDirectory: zod.z.string().optional().describe(
|
|
1828
|
+
"Directory for TypeScript type files. Required when skipWrite is false or omitted."
|
|
1829
|
+
)
|
|
1830
|
+
}).describe(
|
|
1831
|
+
"Generate TypeScript type definitions for apps - can optionally write to disk or just return type strings"
|
|
1832
|
+
);
|
|
1698
1833
|
var AstTypeGenerator = class {
|
|
1699
1834
|
constructor() {
|
|
1700
1835
|
this.factory = ts__namespace.factory;
|
|
@@ -2263,69 +2398,92 @@ Usage:
|
|
|
2263
2398
|
return Array.from(allKeys);
|
|
2264
2399
|
}
|
|
2265
2400
|
};
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2401
|
+
|
|
2402
|
+
// src/utils/manifest-helpers.ts
|
|
2403
|
+
function getManifestKey(app) {
|
|
2404
|
+
return app.slug || app.key;
|
|
2405
|
+
}
|
|
2406
|
+
function createManifestEntry(app) {
|
|
2407
|
+
if (!app.version) {
|
|
2408
|
+
throw new Error(
|
|
2409
|
+
`App ${app.key} does not have a version. Implementation ID: ${app.implementation_id}`
|
|
2410
|
+
);
|
|
2274
2411
|
}
|
|
2275
|
-
return
|
|
2412
|
+
return {
|
|
2413
|
+
implementationName: app.key,
|
|
2414
|
+
version: app.version
|
|
2415
|
+
};
|
|
2276
2416
|
}
|
|
2277
|
-
var
|
|
2278
|
-
const
|
|
2417
|
+
var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
|
|
2418
|
+
const generateAppTypes = zapierSdk.createFunction(async function generateAppTypes2(options) {
|
|
2279
2419
|
const {
|
|
2280
2420
|
appKeys,
|
|
2281
2421
|
authenticationIds,
|
|
2282
|
-
|
|
2283
|
-
|
|
2422
|
+
skipWrite = false,
|
|
2423
|
+
typesOutputDirectory,
|
|
2424
|
+
onProgress
|
|
2284
2425
|
} = options;
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2426
|
+
if (!skipWrite && !typesOutputDirectory) {
|
|
2427
|
+
throw new Error(
|
|
2428
|
+
"typesOutputDirectory is required when skipWrite is false"
|
|
2429
|
+
);
|
|
2430
|
+
}
|
|
2431
|
+
const result = {
|
|
2432
|
+
typeDefinitions: {},
|
|
2433
|
+
errors: []
|
|
2434
|
+
};
|
|
2435
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
2288
2436
|
const appsIterator = sdk2.listApps({ appKeys }).items();
|
|
2289
2437
|
const apps = [];
|
|
2290
2438
|
for await (const app of appsIterator) {
|
|
2291
2439
|
apps.push(app);
|
|
2440
|
+
onProgress?.({ type: "app_found", app });
|
|
2292
2441
|
}
|
|
2442
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
2293
2443
|
if (apps.length === 0) {
|
|
2294
|
-
|
|
2295
|
-
return;
|
|
2444
|
+
return result;
|
|
2296
2445
|
}
|
|
2297
|
-
|
|
2446
|
+
const authentications = [];
|
|
2298
2447
|
if (authenticationIds && authenticationIds.length > 0) {
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2448
|
+
onProgress?.({
|
|
2449
|
+
type: "authentications_lookup_start",
|
|
2450
|
+
count: authenticationIds.length
|
|
2451
|
+
});
|
|
2302
2452
|
const authsIterator = sdk2.listAuthentications({ authenticationIds }).items();
|
|
2303
2453
|
for await (const auth of authsIterator) {
|
|
2304
2454
|
authentications.push(auth);
|
|
2305
2455
|
}
|
|
2306
|
-
|
|
2456
|
+
onProgress?.({
|
|
2457
|
+
type: "authentications_lookup_complete",
|
|
2458
|
+
count: authentications.length
|
|
2459
|
+
});
|
|
2460
|
+
}
|
|
2461
|
+
if (!skipWrite && typesOutputDirectory) {
|
|
2462
|
+
await promises.mkdir(typesOutputDirectory, { recursive: true });
|
|
2463
|
+
}
|
|
2464
|
+
if (!skipWrite) {
|
|
2465
|
+
result.writtenFiles = {};
|
|
2307
2466
|
}
|
|
2308
2467
|
for (const app of apps) {
|
|
2309
|
-
|
|
2310
|
-
|
|
2468
|
+
onProgress?.({
|
|
2469
|
+
type: "app_processing_start",
|
|
2470
|
+
appKey: app.key,
|
|
2471
|
+
slug: app.slug
|
|
2472
|
+
});
|
|
2311
2473
|
try {
|
|
2312
2474
|
if (!app.version) {
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2475
|
+
const error = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
|
|
2476
|
+
result.errors.push({
|
|
2477
|
+
appKey: app.key,
|
|
2478
|
+
error
|
|
2479
|
+
});
|
|
2480
|
+
onProgress?.({
|
|
2481
|
+
type: "app_processing_error",
|
|
2482
|
+
appKey: app.key,
|
|
2483
|
+
error
|
|
2484
|
+
});
|
|
2316
2485
|
continue;
|
|
2317
2486
|
}
|
|
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
2487
|
let authenticationId;
|
|
2330
2488
|
if (authentications.length > 0) {
|
|
2331
2489
|
const matchingAuth = authentications.find((auth) => {
|
|
@@ -2333,43 +2491,171 @@ var addPlugin = ({ sdk: sdk2, context }) => {
|
|
|
2333
2491
|
});
|
|
2334
2492
|
if (matchingAuth) {
|
|
2335
2493
|
authenticationId = matchingAuth.id;
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2494
|
+
onProgress?.({
|
|
2495
|
+
type: "authentication_matched",
|
|
2496
|
+
appKey: app.key,
|
|
2497
|
+
authenticationId: matchingAuth.id,
|
|
2498
|
+
authenticationTitle: matchingAuth.title || ""
|
|
2499
|
+
});
|
|
2339
2500
|
} else {
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2501
|
+
onProgress?.({
|
|
2502
|
+
type: "authentication_not_matched",
|
|
2503
|
+
appKey: app.key
|
|
2504
|
+
});
|
|
2343
2505
|
}
|
|
2344
2506
|
}
|
|
2345
|
-
const
|
|
2507
|
+
const manifestKey = getManifestKey(app);
|
|
2346
2508
|
try {
|
|
2347
2509
|
const generator = new AstTypeGenerator();
|
|
2348
|
-
const
|
|
2510
|
+
const typeDefinitionString = await generator.generateTypes({
|
|
2349
2511
|
app,
|
|
2350
2512
|
authenticationId,
|
|
2351
2513
|
sdk: sdk2
|
|
2352
2514
|
});
|
|
2353
|
-
|
|
2354
|
-
|
|
2515
|
+
result.typeDefinitions[manifestKey] = typeDefinitionString;
|
|
2516
|
+
onProgress?.({
|
|
2517
|
+
type: "type_generated",
|
|
2518
|
+
manifestKey,
|
|
2519
|
+
sizeBytes: typeDefinitionString.length
|
|
2520
|
+
});
|
|
2521
|
+
if (!skipWrite && typesOutputDirectory && result.writtenFiles) {
|
|
2522
|
+
const filePath = path.join(typesOutputDirectory, `${manifestKey}.d.ts`);
|
|
2523
|
+
await promises.writeFile(filePath, typeDefinitionString, "utf8");
|
|
2524
|
+
result.writtenFiles[manifestKey] = filePath;
|
|
2525
|
+
onProgress?.({
|
|
2526
|
+
type: "file_written",
|
|
2527
|
+
manifestKey,
|
|
2528
|
+
filePath
|
|
2529
|
+
});
|
|
2530
|
+
}
|
|
2531
|
+
onProgress?.({
|
|
2532
|
+
type: "app_processing_complete",
|
|
2533
|
+
appKey: app.key
|
|
2534
|
+
});
|
|
2355
2535
|
} catch (error) {
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2536
|
+
const errorMessage = `Failed to generate types: ${error}`;
|
|
2537
|
+
result.errors.push({
|
|
2538
|
+
appKey: app.key,
|
|
2539
|
+
error: errorMessage
|
|
2540
|
+
});
|
|
2541
|
+
onProgress?.({
|
|
2542
|
+
type: "app_processing_error",
|
|
2543
|
+
appKey: app.key,
|
|
2544
|
+
error: errorMessage
|
|
2545
|
+
});
|
|
2359
2546
|
}
|
|
2360
2547
|
} catch (error) {
|
|
2361
|
-
|
|
2548
|
+
const errorMessage = `Failed to process app: ${error}`;
|
|
2549
|
+
result.errors.push({
|
|
2550
|
+
appKey: app.key,
|
|
2551
|
+
error: errorMessage
|
|
2552
|
+
});
|
|
2553
|
+
onProgress?.({
|
|
2554
|
+
type: "app_processing_error",
|
|
2555
|
+
appKey: app.key,
|
|
2556
|
+
error: errorMessage
|
|
2557
|
+
});
|
|
2362
2558
|
}
|
|
2363
2559
|
}
|
|
2364
|
-
|
|
2365
|
-
},
|
|
2560
|
+
return result;
|
|
2561
|
+
}, GenerateAppTypesSchema);
|
|
2366
2562
|
return {
|
|
2367
|
-
|
|
2563
|
+
generateAppTypes,
|
|
2368
2564
|
context: {
|
|
2369
2565
|
meta: {
|
|
2370
|
-
|
|
2566
|
+
generateAppTypes: {
|
|
2371
2567
|
categories: ["utility"],
|
|
2372
|
-
inputSchema:
|
|
2568
|
+
inputSchema: GenerateAppTypesSchema
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
};
|
|
2573
|
+
};
|
|
2574
|
+
var BuildManifestSchema = zod.z.object({
|
|
2575
|
+
appKeys: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
2576
|
+
"One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello')"
|
|
2577
|
+
),
|
|
2578
|
+
skipWrite: zod.z.boolean().optional().describe(
|
|
2579
|
+
"If true, returns manifest entries without writing to disk. If false or omitted, writes to the manifest file."
|
|
2580
|
+
),
|
|
2581
|
+
configPath: zod.z.string().optional().describe(
|
|
2582
|
+
"Path to the manifest file. Only used when skipWrite is false or omitted."
|
|
2583
|
+
)
|
|
2584
|
+
}).describe(
|
|
2585
|
+
"Build manifest entries for apps - can optionally write to disk or just return JSON"
|
|
2586
|
+
);
|
|
2587
|
+
|
|
2588
|
+
// src/plugins/buildManifest/index.ts
|
|
2589
|
+
var buildManifestPlugin = ({ sdk: sdk2, context }) => {
|
|
2590
|
+
const buildManifest = zapierSdk.createFunction(async function buildManifest2(options) {
|
|
2591
|
+
const { appKeys, skipWrite = false, configPath, onProgress } = options;
|
|
2592
|
+
const result = {
|
|
2593
|
+
errors: []
|
|
2594
|
+
};
|
|
2595
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
2596
|
+
const appsIterator = sdk2.listApps({ appKeys }).items();
|
|
2597
|
+
const apps = [];
|
|
2598
|
+
for await (const app of appsIterator) {
|
|
2599
|
+
apps.push(app);
|
|
2600
|
+
onProgress?.({ type: "app_found", app });
|
|
2601
|
+
}
|
|
2602
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
2603
|
+
if (apps.length === 0) {
|
|
2604
|
+
return result;
|
|
2605
|
+
}
|
|
2606
|
+
let updatedManifest;
|
|
2607
|
+
for (const app of apps) {
|
|
2608
|
+
onProgress?.({
|
|
2609
|
+
type: "app_processing_start",
|
|
2610
|
+
appKey: app.key,
|
|
2611
|
+
slug: app.slug
|
|
2612
|
+
});
|
|
2613
|
+
try {
|
|
2614
|
+
const manifestEntry = createManifestEntry(app);
|
|
2615
|
+
onProgress?.({
|
|
2616
|
+
type: "manifest_entry_built",
|
|
2617
|
+
appKey: app.key,
|
|
2618
|
+
manifestKey: manifestEntry.implementationName,
|
|
2619
|
+
version: manifestEntry.version || ""
|
|
2620
|
+
});
|
|
2621
|
+
const [updatedManifestKey, , manifest] = await context.updateManifestEntry({
|
|
2622
|
+
appKey: app.key,
|
|
2623
|
+
entry: manifestEntry,
|
|
2624
|
+
configPath,
|
|
2625
|
+
skipWrite,
|
|
2626
|
+
manifest: updatedManifest
|
|
2627
|
+
});
|
|
2628
|
+
updatedManifest = manifest;
|
|
2629
|
+
onProgress?.({
|
|
2630
|
+
type: "manifest_updated",
|
|
2631
|
+
appKey: app.key,
|
|
2632
|
+
manifestKey: updatedManifestKey,
|
|
2633
|
+
version: manifestEntry.version || ""
|
|
2634
|
+
});
|
|
2635
|
+
onProgress?.({ type: "app_processing_complete", appKey: app.key });
|
|
2636
|
+
} catch (error) {
|
|
2637
|
+
const errorMessage = `Failed to process app: ${error}`;
|
|
2638
|
+
result.errors.push({
|
|
2639
|
+
appKey: app.key,
|
|
2640
|
+
error: errorMessage
|
|
2641
|
+
});
|
|
2642
|
+
onProgress?.({
|
|
2643
|
+
type: "app_processing_error",
|
|
2644
|
+
appKey: app.key,
|
|
2645
|
+
error: errorMessage
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
result.manifest = updatedManifest;
|
|
2650
|
+
return result;
|
|
2651
|
+
}, BuildManifestSchema);
|
|
2652
|
+
return {
|
|
2653
|
+
buildManifest,
|
|
2654
|
+
context: {
|
|
2655
|
+
meta: {
|
|
2656
|
+
buildManifest: {
|
|
2657
|
+
categories: ["utility"],
|
|
2658
|
+
inputSchema: BuildManifestSchema
|
|
2373
2659
|
}
|
|
2374
2660
|
}
|
|
2375
2661
|
}
|
|
@@ -2378,23 +2664,15 @@ var addPlugin = ({ sdk: sdk2, context }) => {
|
|
|
2378
2664
|
|
|
2379
2665
|
// src/sdk.ts
|
|
2380
2666
|
function createZapierCliSdk(options = {}) {
|
|
2381
|
-
|
|
2667
|
+
return zapierSdk.createZapierSdkWithoutRegistry({
|
|
2382
2668
|
debug: options.debug,
|
|
2383
2669
|
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;
|
|
2670
|
+
}).addPlugin(generateAppTypesPlugin).addPlugin(buildManifestPlugin).addPlugin(bundleCodePlugin).addPlugin(getLoginConfigPathPlugin).addPlugin(addPlugin).addPlugin(mcpPlugin).addPlugin(loginPlugin).addPlugin(logoutPlugin).addPlugin(zapierSdk.registryPlugin);
|
|
2393
2671
|
}
|
|
2394
2672
|
|
|
2395
2673
|
// package.json with { type: 'json' }
|
|
2396
2674
|
var package_default2 = {
|
|
2397
|
-
version: "0.13.
|
|
2675
|
+
version: "0.13.7"};
|
|
2398
2676
|
|
|
2399
2677
|
// src/cli.ts
|
|
2400
2678
|
var program = new commander.Command();
|