@zapier/zapier-sdk-cli 0.13.10 → 0.13.12
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 +20 -0
- package/dist/cli.cjs +106 -56
- package/dist/cli.mjs +108 -58
- package/dist/index.cjs +84 -52
- package/dist/index.mjs +86 -54
- package/dist/package.json +1 -1
- package/dist/src/cli.js +23 -3
- package/dist/src/generators/ast-generator.js +33 -29
- package/dist/src/plugins/login/index.js +17 -5
- package/dist/src/utils/auth/login.d.ts +7 -1
- package/dist/src/utils/auth/login.js +10 -7
- package/dist/src/utils/constants.d.ts +1 -1
- package/dist/src/utils/constants.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/cli.test.ts +10 -0
- package/src/cli.ts +35 -3
- package/src/generators/ast-generator.test.ts +908 -0
- package/src/generators/ast-generator.ts +54 -46
- package/src/plugins/login/index.ts +33 -14
- package/src/utils/auth/login.ts +27 -8
- package/src/utils/constants.ts +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @zapier/zapier-sdk-cli
|
|
2
2
|
|
|
3
|
+
## 0.13.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 492e2f9: - Add new `batch` utility method to handle concurency limits, retries, timeouts and exponential backoffs.
|
|
8
|
+
- Refactor `generateAppTypes` in CLI to use the new `batch` utility
|
|
9
|
+
- Updated dependencies [492e2f9]
|
|
10
|
+
- @zapier/zapier-sdk@0.13.9
|
|
11
|
+
- @zapier/zapier-sdk-mcp@0.3.22
|
|
12
|
+
|
|
13
|
+
## 0.13.11
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 6de89a9: Allow overriding ZAPIER_BASE_URL with env vars, and also add new ZAPIER_TRACKING_BASE_URL, ZAPIER_AUTH_BASE_URL, and ZAPIER_AUTH_CLIENT_ID env vars and parameters.
|
|
18
|
+
- Updated dependencies [6de89a9]
|
|
19
|
+
- @zapier/zapier-sdk-cli-login@0.3.4
|
|
20
|
+
- @zapier/zapier-sdk@0.13.8
|
|
21
|
+
- @zapier/zapier-sdk-mcp@0.3.21
|
|
22
|
+
|
|
3
23
|
## 0.13.10
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/cli.cjs
CHANGED
|
@@ -1305,7 +1305,15 @@ var generateRandomString = () => {
|
|
|
1305
1305
|
(dec) => ("0" + dec.toString(16)).substring(-2)
|
|
1306
1306
|
).join("");
|
|
1307
1307
|
};
|
|
1308
|
-
var login = async (
|
|
1308
|
+
var login = async ({
|
|
1309
|
+
timeoutMs = LOGIN_TIMEOUT_MS,
|
|
1310
|
+
baseUrl: baseUrl2,
|
|
1311
|
+
authBaseUrl: authBaseUrl2,
|
|
1312
|
+
authClientId: authClientId2
|
|
1313
|
+
}) => {
|
|
1314
|
+
const authOptions = { baseUrl: baseUrl2, authBaseUrl: authBaseUrl2 };
|
|
1315
|
+
const tokenUrl = zapierSdkCliLogin.getAuthTokenUrl(authOptions);
|
|
1316
|
+
const authorizeUrl = zapierSdkCliLogin.getAuthAuthorizeUrl(authOptions);
|
|
1309
1317
|
zapierSdkCliLogin.logout();
|
|
1310
1318
|
const availablePort = await findAvailablePort();
|
|
1311
1319
|
const redirectUri = `http://localhost:${availablePort}/oauth`;
|
|
@@ -1331,9 +1339,9 @@ var login = async (timeoutMs = LOGIN_TIMEOUT_MS) => {
|
|
|
1331
1339
|
process.on("SIGINT", cleanup);
|
|
1332
1340
|
process.on("SIGTERM", cleanup);
|
|
1333
1341
|
const { code_verifier: codeVerifier, code_challenge: codeChallenge } = await pkceChallenge__default.default();
|
|
1334
|
-
const authUrl = `${
|
|
1342
|
+
const authUrl = `${authorizeUrl}?${new URLSearchParams({
|
|
1335
1343
|
response_type: "code",
|
|
1336
|
-
client_id: zapierSdkCliLogin.
|
|
1344
|
+
client_id: authClientId2 || zapierSdkCliLogin.ZAPIER_AUTH_CLIENT_ID,
|
|
1337
1345
|
redirect_uri: redirectUri,
|
|
1338
1346
|
scope: "internal offline_access",
|
|
1339
1347
|
state: generateRandomString(),
|
|
@@ -1376,12 +1384,12 @@ var login = async (timeoutMs = LOGIN_TIMEOUT_MS) => {
|
|
|
1376
1384
|
}
|
|
1377
1385
|
log_default.info("Exchanging authorization code for tokens...");
|
|
1378
1386
|
const { data } = await client_default.post(
|
|
1379
|
-
|
|
1387
|
+
tokenUrl,
|
|
1380
1388
|
{
|
|
1381
1389
|
grant_type: "authorization_code",
|
|
1382
1390
|
code: await promisedCode,
|
|
1383
1391
|
redirect_uri: redirectUri,
|
|
1384
|
-
client_id: zapierSdkCliLogin.
|
|
1392
|
+
client_id: authClientId2 || zapierSdkCliLogin.ZAPIER_AUTH_CLIENT_ID,
|
|
1385
1393
|
code_verifier: codeVerifier
|
|
1386
1394
|
},
|
|
1387
1395
|
{
|
|
@@ -1402,7 +1410,7 @@ var LoginSchema = zod.z.object({
|
|
|
1402
1410
|
|
|
1403
1411
|
// package.json
|
|
1404
1412
|
var package_default = {
|
|
1405
|
-
version: "0.13.
|
|
1413
|
+
version: "0.13.12"};
|
|
1406
1414
|
|
|
1407
1415
|
// src/telemetry/builders.ts
|
|
1408
1416
|
function createCliBaseEvent(context = {}) {
|
|
@@ -1460,23 +1468,35 @@ function buildCliCommandExecutedEvent({
|
|
|
1460
1468
|
|
|
1461
1469
|
// src/plugins/login/index.ts
|
|
1462
1470
|
var CLI_COMMAND_EXECUTED_EVENT_SUBJECT = "platform.sdk.CliCommandExecutedEvent";
|
|
1463
|
-
var loginWithSdk = zapierSdk.createFunction(
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1471
|
+
var loginWithSdk = zapierSdk.createFunction(
|
|
1472
|
+
async (options) => {
|
|
1473
|
+
const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
|
|
1474
|
+
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
1475
|
+
throw new Error("Timeout must be a positive number");
|
|
1476
|
+
}
|
|
1477
|
+
await login_default({
|
|
1478
|
+
timeoutMs: timeoutSeconds * 1e3,
|
|
1479
|
+
baseUrl: options.baseUrl,
|
|
1480
|
+
authBaseUrl: options.authBaseUrl,
|
|
1481
|
+
authClientId: options.authClientId
|
|
1482
|
+
});
|
|
1483
|
+
const user = await zapierSdkCliLogin.getLoggedInUser();
|
|
1484
|
+
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
1485
|
+
setTimeout(() => process.exit(0), 100);
|
|
1486
|
+
}
|
|
1487
|
+
);
|
|
1473
1488
|
var loginPlugin = ({ context }) => {
|
|
1474
1489
|
const loginWithTelemetry = async (options) => {
|
|
1475
1490
|
const startTime = Date.now();
|
|
1476
1491
|
let success = false;
|
|
1477
1492
|
let errorMessage = null;
|
|
1478
1493
|
try {
|
|
1479
|
-
await loginWithSdk(
|
|
1494
|
+
await loginWithSdk({
|
|
1495
|
+
...options,
|
|
1496
|
+
baseUrl: context.options?.baseUrl,
|
|
1497
|
+
authBaseUrl: context.options?.authBaseUrl,
|
|
1498
|
+
authClientId: context.options?.authClientId
|
|
1499
|
+
});
|
|
1480
1500
|
success = true;
|
|
1481
1501
|
} catch (error) {
|
|
1482
1502
|
success = false;
|
|
@@ -1841,44 +1861,56 @@ var AstTypeGenerator = class {
|
|
|
1841
1861
|
});
|
|
1842
1862
|
const actions = actionsResult.data;
|
|
1843
1863
|
const actionsWithFields = [];
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1864
|
+
const inputFieldsTasks = actions.map(
|
|
1865
|
+
(action) => () => sdk2.listInputFields({
|
|
1866
|
+
appKey: app.implementation_id,
|
|
1867
|
+
actionKey: action.key,
|
|
1868
|
+
actionType: action.action_type,
|
|
1869
|
+
authenticationId
|
|
1870
|
+
})
|
|
1871
|
+
);
|
|
1872
|
+
const results = await zapierSdk.batch(inputFieldsTasks, {
|
|
1873
|
+
concurrency: 50,
|
|
1874
|
+
// Limit to 50 concurrent requests
|
|
1875
|
+
retry: true,
|
|
1876
|
+
// Automatically retry transient failures
|
|
1877
|
+
timeoutMs: 18e4,
|
|
1878
|
+
// 3 minute overall timeout
|
|
1879
|
+
taskTimeoutMs: 3e4
|
|
1880
|
+
// 30 seconds per-task timeout (API calls shouldn't take longer)
|
|
1881
|
+
});
|
|
1882
|
+
const failedActions = [];
|
|
1883
|
+
results.forEach((result, i) => {
|
|
1884
|
+
const action = actions[i];
|
|
1885
|
+
if (result.status === "fulfilled") {
|
|
1886
|
+
actionsWithFields.push({
|
|
1887
|
+
...action,
|
|
1888
|
+
inputFields: result.value.data,
|
|
1889
|
+
name: action.title || action.key
|
|
1890
|
+
});
|
|
1891
|
+
} else {
|
|
1892
|
+
failedActions.push(
|
|
1893
|
+
`${action.key} (${action.action_type}): ${result.reason?.message || "Unknown error"}`
|
|
1894
|
+
);
|
|
1895
|
+
actionsWithFields.push({
|
|
1896
|
+
...action,
|
|
1897
|
+
inputFields: [],
|
|
1898
|
+
name: action.title || action.key,
|
|
1899
|
+
app_key: action.app_key || app.implementation_id,
|
|
1900
|
+
action_type: action.action_type || "write",
|
|
1901
|
+
title: action.title || action.key,
|
|
1902
|
+
type: "action",
|
|
1903
|
+
description: action.description || ""
|
|
1904
|
+
});
|
|
1866
1905
|
}
|
|
1867
|
-
}
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
...action,
|
|
1872
|
-
inputFields: [],
|
|
1873
|
-
name: action.title || action.key,
|
|
1874
|
-
app_key: action.app_key || app.implementation_id,
|
|
1875
|
-
action_type: action.action_type || "write",
|
|
1876
|
-
title: action.title || action.key,
|
|
1877
|
-
type: "action",
|
|
1878
|
-
description: action.description || ""
|
|
1879
|
-
});
|
|
1880
|
-
}
|
|
1906
|
+
});
|
|
1907
|
+
if (failedActions.length > 0) {
|
|
1908
|
+
console.warn(
|
|
1909
|
+
`Failed to fetch input fields for ${failedActions.length} action(s):`
|
|
1881
1910
|
);
|
|
1911
|
+
failedActions.forEach((failedAction) => {
|
|
1912
|
+
console.warn(` - ${failedAction}`);
|
|
1913
|
+
});
|
|
1882
1914
|
}
|
|
1883
1915
|
const sourceFile = this.createSourceFile(app, actionsWithFields);
|
|
1884
1916
|
return this.printer.printFile(sourceFile);
|
|
@@ -2650,14 +2682,32 @@ function createZapierCliSdk(options = {}) {
|
|
|
2650
2682
|
|
|
2651
2683
|
// package.json with { type: 'json' }
|
|
2652
2684
|
var package_default2 = {
|
|
2653
|
-
version: "0.13.
|
|
2685
|
+
version: "0.13.12"};
|
|
2654
2686
|
|
|
2655
2687
|
// src/cli.ts
|
|
2656
2688
|
var program = new commander.Command();
|
|
2657
|
-
program.name("zapier-sdk").description("CLI for Zapier SDK").version(package_default2.version, "-v, --version", "display version number").option("--debug", "Enable debug logging")
|
|
2689
|
+
program.name("zapier-sdk").description("CLI for Zapier SDK").version(package_default2.version, "-v, --version", "display version number").option("--debug", "Enable debug logging").option("--base-url <url>", "Base URL for Zapier API endpoints").option(
|
|
2690
|
+
"--auth-base-url <url>",
|
|
2691
|
+
"Base URL for Zapier authentication endpoints"
|
|
2692
|
+
).option("--auth-client-id <id>", "OAuth client ID for Zapier authentication").option(
|
|
2693
|
+
"--tracking-base-url <url>",
|
|
2694
|
+
"Base URL for Zapier tracking endpoints"
|
|
2695
|
+
);
|
|
2658
2696
|
var isDebugMode = process.env.DEBUG === "true" || process.argv.includes("--debug");
|
|
2697
|
+
var baseUrlIndex = process.argv.indexOf("--base-url");
|
|
2698
|
+
var authBaseUrlIndex = process.argv.indexOf("--auth-base-url");
|
|
2699
|
+
var authClientIdIndex = process.argv.indexOf("--auth-client-id");
|
|
2700
|
+
var trackingBaseUrlIndex = process.argv.indexOf("--tracking-base-url");
|
|
2701
|
+
var baseUrl = baseUrlIndex !== -1 ? process.argv[baseUrlIndex + 1] : void 0;
|
|
2702
|
+
var authBaseUrl = authBaseUrlIndex !== -1 ? process.argv[authBaseUrlIndex + 1] : void 0;
|
|
2703
|
+
var authClientId = authClientIdIndex !== -1 ? process.argv[authClientIdIndex + 1] : void 0;
|
|
2704
|
+
var trackingBaseUrl = trackingBaseUrlIndex !== -1 ? process.argv[trackingBaseUrlIndex + 1] : void 0;
|
|
2659
2705
|
var sdk = createZapierCliSdk({
|
|
2660
|
-
debug: isDebugMode
|
|
2706
|
+
debug: isDebugMode,
|
|
2707
|
+
baseUrl,
|
|
2708
|
+
authBaseUrl,
|
|
2709
|
+
authClientId,
|
|
2710
|
+
trackingBaseUrl
|
|
2661
2711
|
});
|
|
2662
2712
|
generateCliCommands(program, sdk);
|
|
2663
2713
|
program.parse();
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, createZapierSdkWithoutRegistry, registryPlugin, ZapierValidationError, ZapierUnknownError, toSnakeCase, ZapierError, formatErrorMessage, getOsInfo, getPlatformVersions, getCiPlatform, isCi, isPositional, getReleaseId, getCurrentTimestamp, generateEventId } from '@zapier/zapier-sdk';
|
|
4
|
+
import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, createZapierSdkWithoutRegistry, registryPlugin, ZapierValidationError, ZapierUnknownError, batch, toSnakeCase, ZapierError, formatErrorMessage, getOsInfo, getPlatformVersions, getCiPlatform, isCi, isPositional, getReleaseId, getCurrentTimestamp, generateEventId } from '@zapier/zapier-sdk';
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
6
|
import chalk3 from 'chalk';
|
|
7
7
|
import util from 'util';
|
|
@@ -9,7 +9,7 @@ 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,
|
|
12
|
+
import { getLoggedInUser, logout, getAuthTokenUrl, getAuthAuthorizeUrl, ZAPIER_AUTH_CLIENT_ID, AUTH_MODE_HEADER, updateLogin, getConfigPath } from '@zapier/zapier-sdk-cli-login';
|
|
13
13
|
import ora from 'ora';
|
|
14
14
|
import { startMcpServerAsProcess } from '@zapier/zapier-sdk-mcp';
|
|
15
15
|
import { buildSync } from 'esbuild';
|
|
@@ -1272,7 +1272,15 @@ var generateRandomString = () => {
|
|
|
1272
1272
|
(dec) => ("0" + dec.toString(16)).substring(-2)
|
|
1273
1273
|
).join("");
|
|
1274
1274
|
};
|
|
1275
|
-
var login = async (
|
|
1275
|
+
var login = async ({
|
|
1276
|
+
timeoutMs = LOGIN_TIMEOUT_MS,
|
|
1277
|
+
baseUrl: baseUrl2,
|
|
1278
|
+
authBaseUrl: authBaseUrl2,
|
|
1279
|
+
authClientId: authClientId2
|
|
1280
|
+
}) => {
|
|
1281
|
+
const authOptions = { baseUrl: baseUrl2, authBaseUrl: authBaseUrl2 };
|
|
1282
|
+
const tokenUrl = getAuthTokenUrl(authOptions);
|
|
1283
|
+
const authorizeUrl = getAuthAuthorizeUrl(authOptions);
|
|
1276
1284
|
logout();
|
|
1277
1285
|
const availablePort = await findAvailablePort();
|
|
1278
1286
|
const redirectUri = `http://localhost:${availablePort}/oauth`;
|
|
@@ -1298,9 +1306,9 @@ var login = async (timeoutMs = LOGIN_TIMEOUT_MS) => {
|
|
|
1298
1306
|
process.on("SIGINT", cleanup);
|
|
1299
1307
|
process.on("SIGTERM", cleanup);
|
|
1300
1308
|
const { code_verifier: codeVerifier, code_challenge: codeChallenge } = await pkceChallenge();
|
|
1301
|
-
const authUrl = `${
|
|
1309
|
+
const authUrl = `${authorizeUrl}?${new URLSearchParams({
|
|
1302
1310
|
response_type: "code",
|
|
1303
|
-
client_id:
|
|
1311
|
+
client_id: authClientId2 || ZAPIER_AUTH_CLIENT_ID,
|
|
1304
1312
|
redirect_uri: redirectUri,
|
|
1305
1313
|
scope: "internal offline_access",
|
|
1306
1314
|
state: generateRandomString(),
|
|
@@ -1343,12 +1351,12 @@ var login = async (timeoutMs = LOGIN_TIMEOUT_MS) => {
|
|
|
1343
1351
|
}
|
|
1344
1352
|
log_default.info("Exchanging authorization code for tokens...");
|
|
1345
1353
|
const { data } = await client_default.post(
|
|
1346
|
-
|
|
1354
|
+
tokenUrl,
|
|
1347
1355
|
{
|
|
1348
1356
|
grant_type: "authorization_code",
|
|
1349
1357
|
code: await promisedCode,
|
|
1350
1358
|
redirect_uri: redirectUri,
|
|
1351
|
-
client_id:
|
|
1359
|
+
client_id: authClientId2 || ZAPIER_AUTH_CLIENT_ID,
|
|
1352
1360
|
code_verifier: codeVerifier
|
|
1353
1361
|
},
|
|
1354
1362
|
{
|
|
@@ -1369,7 +1377,7 @@ var LoginSchema = z.object({
|
|
|
1369
1377
|
|
|
1370
1378
|
// package.json
|
|
1371
1379
|
var package_default = {
|
|
1372
|
-
version: "0.13.
|
|
1380
|
+
version: "0.13.12"};
|
|
1373
1381
|
|
|
1374
1382
|
// src/telemetry/builders.ts
|
|
1375
1383
|
function createCliBaseEvent(context = {}) {
|
|
@@ -1427,23 +1435,35 @@ function buildCliCommandExecutedEvent({
|
|
|
1427
1435
|
|
|
1428
1436
|
// src/plugins/login/index.ts
|
|
1429
1437
|
var CLI_COMMAND_EXECUTED_EVENT_SUBJECT = "platform.sdk.CliCommandExecutedEvent";
|
|
1430
|
-
var loginWithSdk = createFunction(
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1438
|
+
var loginWithSdk = createFunction(
|
|
1439
|
+
async (options) => {
|
|
1440
|
+
const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
|
|
1441
|
+
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
1442
|
+
throw new Error("Timeout must be a positive number");
|
|
1443
|
+
}
|
|
1444
|
+
await login_default({
|
|
1445
|
+
timeoutMs: timeoutSeconds * 1e3,
|
|
1446
|
+
baseUrl: options.baseUrl,
|
|
1447
|
+
authBaseUrl: options.authBaseUrl,
|
|
1448
|
+
authClientId: options.authClientId
|
|
1449
|
+
});
|
|
1450
|
+
const user = await getLoggedInUser();
|
|
1451
|
+
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
1452
|
+
setTimeout(() => process.exit(0), 100);
|
|
1453
|
+
}
|
|
1454
|
+
);
|
|
1440
1455
|
var loginPlugin = ({ context }) => {
|
|
1441
1456
|
const loginWithTelemetry = async (options) => {
|
|
1442
1457
|
const startTime = Date.now();
|
|
1443
1458
|
let success = false;
|
|
1444
1459
|
let errorMessage = null;
|
|
1445
1460
|
try {
|
|
1446
|
-
await loginWithSdk(
|
|
1461
|
+
await loginWithSdk({
|
|
1462
|
+
...options,
|
|
1463
|
+
baseUrl: context.options?.baseUrl,
|
|
1464
|
+
authBaseUrl: context.options?.authBaseUrl,
|
|
1465
|
+
authClientId: context.options?.authClientId
|
|
1466
|
+
});
|
|
1447
1467
|
success = true;
|
|
1448
1468
|
} catch (error) {
|
|
1449
1469
|
success = false;
|
|
@@ -1808,44 +1828,56 @@ var AstTypeGenerator = class {
|
|
|
1808
1828
|
});
|
|
1809
1829
|
const actions = actionsResult.data;
|
|
1810
1830
|
const actionsWithFields = [];
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1831
|
+
const inputFieldsTasks = actions.map(
|
|
1832
|
+
(action) => () => sdk2.listInputFields({
|
|
1833
|
+
appKey: app.implementation_id,
|
|
1834
|
+
actionKey: action.key,
|
|
1835
|
+
actionType: action.action_type,
|
|
1836
|
+
authenticationId
|
|
1837
|
+
})
|
|
1838
|
+
);
|
|
1839
|
+
const results = await batch(inputFieldsTasks, {
|
|
1840
|
+
concurrency: 50,
|
|
1841
|
+
// Limit to 50 concurrent requests
|
|
1842
|
+
retry: true,
|
|
1843
|
+
// Automatically retry transient failures
|
|
1844
|
+
timeoutMs: 18e4,
|
|
1845
|
+
// 3 minute overall timeout
|
|
1846
|
+
taskTimeoutMs: 3e4
|
|
1847
|
+
// 30 seconds per-task timeout (API calls shouldn't take longer)
|
|
1848
|
+
});
|
|
1849
|
+
const failedActions = [];
|
|
1850
|
+
results.forEach((result, i) => {
|
|
1851
|
+
const action = actions[i];
|
|
1852
|
+
if (result.status === "fulfilled") {
|
|
1853
|
+
actionsWithFields.push({
|
|
1854
|
+
...action,
|
|
1855
|
+
inputFields: result.value.data,
|
|
1856
|
+
name: action.title || action.key
|
|
1857
|
+
});
|
|
1858
|
+
} else {
|
|
1859
|
+
failedActions.push(
|
|
1860
|
+
`${action.key} (${action.action_type}): ${result.reason?.message || "Unknown error"}`
|
|
1861
|
+
);
|
|
1862
|
+
actionsWithFields.push({
|
|
1863
|
+
...action,
|
|
1864
|
+
inputFields: [],
|
|
1865
|
+
name: action.title || action.key,
|
|
1866
|
+
app_key: action.app_key || app.implementation_id,
|
|
1867
|
+
action_type: action.action_type || "write",
|
|
1868
|
+
title: action.title || action.key,
|
|
1869
|
+
type: "action",
|
|
1870
|
+
description: action.description || ""
|
|
1871
|
+
});
|
|
1833
1872
|
}
|
|
1834
|
-
}
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
...action,
|
|
1839
|
-
inputFields: [],
|
|
1840
|
-
name: action.title || action.key,
|
|
1841
|
-
app_key: action.app_key || app.implementation_id,
|
|
1842
|
-
action_type: action.action_type || "write",
|
|
1843
|
-
title: action.title || action.key,
|
|
1844
|
-
type: "action",
|
|
1845
|
-
description: action.description || ""
|
|
1846
|
-
});
|
|
1847
|
-
}
|
|
1873
|
+
});
|
|
1874
|
+
if (failedActions.length > 0) {
|
|
1875
|
+
console.warn(
|
|
1876
|
+
`Failed to fetch input fields for ${failedActions.length} action(s):`
|
|
1848
1877
|
);
|
|
1878
|
+
failedActions.forEach((failedAction) => {
|
|
1879
|
+
console.warn(` - ${failedAction}`);
|
|
1880
|
+
});
|
|
1849
1881
|
}
|
|
1850
1882
|
const sourceFile = this.createSourceFile(app, actionsWithFields);
|
|
1851
1883
|
return this.printer.printFile(sourceFile);
|
|
@@ -2617,14 +2649,32 @@ function createZapierCliSdk(options = {}) {
|
|
|
2617
2649
|
|
|
2618
2650
|
// package.json with { type: 'json' }
|
|
2619
2651
|
var package_default2 = {
|
|
2620
|
-
version: "0.13.
|
|
2652
|
+
version: "0.13.12"};
|
|
2621
2653
|
|
|
2622
2654
|
// src/cli.ts
|
|
2623
2655
|
var program = new Command();
|
|
2624
|
-
program.name("zapier-sdk").description("CLI for Zapier SDK").version(package_default2.version, "-v, --version", "display version number").option("--debug", "Enable debug logging")
|
|
2656
|
+
program.name("zapier-sdk").description("CLI for Zapier SDK").version(package_default2.version, "-v, --version", "display version number").option("--debug", "Enable debug logging").option("--base-url <url>", "Base URL for Zapier API endpoints").option(
|
|
2657
|
+
"--auth-base-url <url>",
|
|
2658
|
+
"Base URL for Zapier authentication endpoints"
|
|
2659
|
+
).option("--auth-client-id <id>", "OAuth client ID for Zapier authentication").option(
|
|
2660
|
+
"--tracking-base-url <url>",
|
|
2661
|
+
"Base URL for Zapier tracking endpoints"
|
|
2662
|
+
);
|
|
2625
2663
|
var isDebugMode = process.env.DEBUG === "true" || process.argv.includes("--debug");
|
|
2664
|
+
var baseUrlIndex = process.argv.indexOf("--base-url");
|
|
2665
|
+
var authBaseUrlIndex = process.argv.indexOf("--auth-base-url");
|
|
2666
|
+
var authClientIdIndex = process.argv.indexOf("--auth-client-id");
|
|
2667
|
+
var trackingBaseUrlIndex = process.argv.indexOf("--tracking-base-url");
|
|
2668
|
+
var baseUrl = baseUrlIndex !== -1 ? process.argv[baseUrlIndex + 1] : void 0;
|
|
2669
|
+
var authBaseUrl = authBaseUrlIndex !== -1 ? process.argv[authBaseUrlIndex + 1] : void 0;
|
|
2670
|
+
var authClientId = authClientIdIndex !== -1 ? process.argv[authClientIdIndex + 1] : void 0;
|
|
2671
|
+
var trackingBaseUrl = trackingBaseUrlIndex !== -1 ? process.argv[trackingBaseUrlIndex + 1] : void 0;
|
|
2626
2672
|
var sdk = createZapierCliSdk({
|
|
2627
|
-
debug: isDebugMode
|
|
2673
|
+
debug: isDebugMode,
|
|
2674
|
+
baseUrl,
|
|
2675
|
+
authBaseUrl,
|
|
2676
|
+
authClientId,
|
|
2677
|
+
trackingBaseUrl
|
|
2628
2678
|
});
|
|
2629
2679
|
generateCliCommands(program, sdk);
|
|
2630
2680
|
program.parse();
|