@zapier/zapier-sdk-cli 0.6.3 → 0.6.4
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 +115 -12
- package/bin/{zapier-sdk.js → zapier-sdk.mjs} +1 -1
- package/dist/cli.cjs +1711 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/{cli.js → cli.mjs} +204 -456
- package/dist/index.cjs +770 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.mjs +739 -0
- package/dist/package.json +67 -0
- package/dist/src/cli.js +8 -14
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -1
- package/dist/src/plugins/bundleCode/index.d.ts +15 -0
- package/dist/src/{commands/bundle-code → plugins/bundleCode}/index.js +19 -1
- package/dist/src/{commands/bundle-code → plugins/bundleCode}/schemas.d.ts +8 -8
- package/dist/src/{commands/bundle-code → plugins/bundleCode}/schemas.js +4 -4
- package/dist/src/plugins/generateTypes/index.d.ts +21 -0
- package/dist/src/{commands/generate-types → plugins/generateTypes}/index.js +18 -0
- package/dist/src/{commands/generate-types → plugins/generateTypes}/schemas.d.ts +0 -3
- package/dist/src/{commands/generate-types → plugins/generateTypes}/schemas.js +1 -2
- package/dist/src/plugins/getConfigPath/index.d.ts +15 -0
- package/dist/src/plugins/getConfigPath/index.js +19 -0
- package/dist/src/plugins/getConfigPath/schemas.d.ts +3 -0
- package/dist/src/plugins/getConfigPath/schemas.js +5 -0
- package/dist/src/plugins/index.d.ts +6 -0
- package/dist/src/plugins/index.js +6 -0
- package/dist/src/plugins/login/index.d.ts +15 -0
- package/dist/src/plugins/login/index.js +26 -0
- package/dist/src/plugins/login/schemas.d.ts +9 -0
- package/dist/src/plugins/login/schemas.js +10 -0
- package/dist/src/plugins/logout/index.d.ts +15 -0
- package/dist/src/plugins/logout/index.js +18 -0
- package/dist/src/plugins/logout/schemas.d.ts +3 -0
- package/dist/src/plugins/logout/schemas.js +5 -0
- package/dist/src/plugins/mcp/index.d.ts +15 -0
- package/dist/src/plugins/mcp/index.js +24 -0
- package/dist/src/plugins/mcp/schemas.d.ts +9 -0
- package/dist/src/plugins/mcp/schemas.js +10 -0
- package/dist/src/sdk.d.ts +9 -0
- package/dist/src/sdk.js +22 -0
- package/dist/src/utils/cli-generator.js +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -8
- package/src/cli.ts +8 -21
- package/src/index.ts +2 -0
- package/src/{commands/bundle-code → plugins/bundleCode}/index.ts +39 -2
- package/src/{commands/bundle-code → plugins/bundleCode}/schemas.ts +4 -4
- package/src/{commands/generate-types → plugins/generateTypes}/index.ts +56 -3
- package/src/{commands/generate-types → plugins/generateTypes}/schemas.ts +0 -4
- package/src/plugins/getConfigPath/index.ts +42 -0
- package/src/plugins/getConfigPath/schemas.ts +8 -0
- package/src/plugins/index.ts +6 -0
- package/src/plugins/login/index.ts +48 -0
- package/src/plugins/login/schemas.ts +13 -0
- package/src/plugins/logout/index.ts +37 -0
- package/src/plugins/logout/schemas.ts +8 -0
- package/src/plugins/mcp/index.ts +43 -0
- package/src/plugins/mcp/schemas.ts +13 -0
- package/src/sdk.ts +43 -0
- package/src/utils/cli-generator.ts +5 -0
- package/tsconfig.build.json +15 -3
- package/tsconfig.json +2 -2
- package/tsup.config.ts +10 -4
- package/bin/zsdk.js +0 -4
- package/dist/index.js +0 -0
- package/dist/src/commands/bundle-code/cli.d.ts +0 -2
- package/dist/src/commands/bundle-code/cli.js +0 -77
- package/dist/src/commands/bundle-code/index.d.ts +0 -5
- package/dist/src/commands/configPath.d.ts +0 -2
- package/dist/src/commands/configPath.js +0 -9
- package/dist/src/commands/generate-types/cli.d.ts +0 -2
- package/dist/src/commands/generate-types/cli.js +0 -84
- package/dist/src/commands/generate-types/index.d.ts +0 -8
- package/dist/src/commands/index.d.ts +0 -6
- package/dist/src/commands/index.js +0 -6
- package/dist/src/commands/login.d.ts +0 -2
- package/dist/src/commands/login.js +0 -25
- package/dist/src/commands/logout.d.ts +0 -2
- package/dist/src/commands/logout.js +0 -16
- package/dist/src/commands/mcp.d.ts +0 -2
- package/dist/src/commands/mcp.js +0 -11
- package/src/commands/bundle-code/cli.ts +0 -118
- package/src/commands/configPath.ts +0 -10
- package/src/commands/generate-types/cli.ts +0 -126
- package/src/commands/index.ts +0 -6
- package/src/commands/login.ts +0 -34
- package/src/commands/logout.ts +0 -19
- package/src/commands/mcp.ts +0 -14
package/dist/{cli.js → cli.mjs}
RENAMED
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { createFunction, OutputPropertySchema, AuthenticationIdPropertySchema, AppKeyPropertySchema, createZapierSdkWithoutRegistry, registryPlugin, ZapierError, formatErrorMessage, isPositional, hasResolver, getResolutionOrderForParams, getResolver } from '@zapier/zapier-sdk';
|
|
5
|
+
import inquirer from 'inquirer';
|
|
6
|
+
import chalk3 from 'chalk';
|
|
7
|
+
import util from 'util';
|
|
8
|
+
import open from 'open';
|
|
9
|
+
import crypto from 'crypto';
|
|
10
|
+
import express from 'express';
|
|
11
|
+
import pkceChallenge from 'pkce-challenge';
|
|
12
|
+
import ora from 'ora';
|
|
13
|
+
import { getLoggedInUser, logout, updateLogin, getConfigPath } from '@zapier/zapier-sdk-cli-login';
|
|
14
|
+
import { startMcpServerAsProcess } from '@zapier/zapier-sdk-mcp';
|
|
15
|
+
import * as fs from 'fs';
|
|
16
|
+
import * as path from 'path';
|
|
17
|
+
import { buildSync } from 'esbuild';
|
|
2
18
|
|
|
3
|
-
// src/cli.ts
|
|
4
|
-
import { Command as Command7 } from "commander";
|
|
5
|
-
import { createZapierSdk as createZapierSdk2 } from "@zapier/zapier-sdk";
|
|
6
|
-
|
|
7
|
-
// src/utils/cli-generator.ts
|
|
8
|
-
import { z as z2 } from "zod";
|
|
9
|
-
import {
|
|
10
|
-
hasResolver as hasResolver2,
|
|
11
|
-
isPositional,
|
|
12
|
-
formatErrorMessage,
|
|
13
|
-
ZapierError
|
|
14
|
-
} from "@zapier/zapier-sdk";
|
|
15
|
-
|
|
16
|
-
// src/utils/parameter-resolver.ts
|
|
17
|
-
import inquirer from "inquirer";
|
|
18
|
-
import chalk from "chalk";
|
|
19
|
-
import { z } from "zod";
|
|
20
|
-
import {
|
|
21
|
-
getResolver,
|
|
22
|
-
hasResolver,
|
|
23
|
-
getResolutionOrderForParams
|
|
24
|
-
} from "@zapier/zapier-sdk";
|
|
25
19
|
var SchemaParameterResolver = class {
|
|
26
20
|
async resolveParameters(schema, providedParams, sdk2) {
|
|
27
21
|
const parseResult = schema.safeParse(providedParams);
|
|
@@ -85,7 +79,7 @@ var SchemaParameterResolver = class {
|
|
|
85
79
|
context.resolvedParams = resolvedParams;
|
|
86
80
|
} catch (error) {
|
|
87
81
|
if (this.isUserCancellation(error)) {
|
|
88
|
-
console.log(
|
|
82
|
+
console.log(chalk3.yellow("\n\nOperation cancelled by user"));
|
|
89
83
|
process.exit(0);
|
|
90
84
|
}
|
|
91
85
|
throw error;
|
|
@@ -116,7 +110,7 @@ var SchemaParameterResolver = class {
|
|
|
116
110
|
context.resolvedParams = resolvedParams;
|
|
117
111
|
} catch (error) {
|
|
118
112
|
if (this.isUserCancellation(error)) {
|
|
119
|
-
console.log(
|
|
113
|
+
console.log(chalk3.yellow("\n\nOperation cancelled by user"));
|
|
120
114
|
process.exit(0);
|
|
121
115
|
}
|
|
122
116
|
throw error;
|
|
@@ -144,7 +138,7 @@ var SchemaParameterResolver = class {
|
|
|
144
138
|
context.resolvedParams = resolvedParams;
|
|
145
139
|
} catch (error) {
|
|
146
140
|
if (this.isUserCancellation(error)) {
|
|
147
|
-
console.log(
|
|
141
|
+
console.log(chalk3.yellow("\n\nOperation cancelled by user"));
|
|
148
142
|
process.exit(0);
|
|
149
143
|
}
|
|
150
144
|
throw error;
|
|
@@ -155,7 +149,7 @@ var SchemaParameterResolver = class {
|
|
|
155
149
|
const finalResult = schema.safeParse(resolvedParams);
|
|
156
150
|
if (!finalResult.success) {
|
|
157
151
|
console.error(
|
|
158
|
-
|
|
152
|
+
chalk3.red("\u274C Parameter validation failed after resolution:")
|
|
159
153
|
);
|
|
160
154
|
throw finalResult.error;
|
|
161
155
|
}
|
|
@@ -203,7 +197,7 @@ var SchemaParameterResolver = class {
|
|
|
203
197
|
if (!resolver) {
|
|
204
198
|
throw new Error(`No resolver found for parameter: ${param.name}`);
|
|
205
199
|
}
|
|
206
|
-
console.log(
|
|
200
|
+
console.log(chalk3.blue(`
|
|
207
201
|
\u{1F50D} Resolving ${param.name}...`));
|
|
208
202
|
const typedResolver = resolver;
|
|
209
203
|
if (typedResolver.type === "static") {
|
|
@@ -220,7 +214,7 @@ var SchemaParameterResolver = class {
|
|
|
220
214
|
} else if (typedResolver.type === "dynamic") {
|
|
221
215
|
try {
|
|
222
216
|
if (param.isRequired && param.name !== "authenticationId") {
|
|
223
|
-
console.log(
|
|
217
|
+
console.log(chalk3.gray(`Fetching options for ${param.name}...`));
|
|
224
218
|
}
|
|
225
219
|
const items = await typedResolver.fetch(
|
|
226
220
|
context.sdk,
|
|
@@ -261,7 +255,7 @@ var SchemaParameterResolver = class {
|
|
|
261
255
|
}
|
|
262
256
|
};
|
|
263
257
|
console.log(
|
|
264
|
-
|
|
258
|
+
chalk3.gray(
|
|
265
259
|
`Fetching input fields for ${param.name}${iteration > 1 ? ` (iteration ${iteration})` : ""}...`
|
|
266
260
|
)
|
|
267
261
|
);
|
|
@@ -272,7 +266,7 @@ var SchemaParameterResolver = class {
|
|
|
272
266
|
if (!fields || fields.length === 0) {
|
|
273
267
|
if (iteration === 1) {
|
|
274
268
|
console.log(
|
|
275
|
-
|
|
269
|
+
chalk3.yellow(`No input fields required for this action.`)
|
|
276
270
|
);
|
|
277
271
|
}
|
|
278
272
|
break;
|
|
@@ -291,7 +285,7 @@ var SchemaParameterResolver = class {
|
|
|
291
285
|
);
|
|
292
286
|
if (newRequiredFields.length > 0) {
|
|
293
287
|
console.log(
|
|
294
|
-
|
|
288
|
+
chalk3.blue(
|
|
295
289
|
`
|
|
296
290
|
\u{1F4DD} Please provide values for the following ${iteration === 1 ? "" : "additional "}input fields:`
|
|
297
291
|
)
|
|
@@ -304,7 +298,7 @@ var SchemaParameterResolver = class {
|
|
|
304
298
|
let shouldConfigureOptional = { configure: false };
|
|
305
299
|
if (newOptionalFields.length > 0) {
|
|
306
300
|
console.log(
|
|
307
|
-
|
|
301
|
+
chalk3.gray(
|
|
308
302
|
`
|
|
309
303
|
There are ${newOptionalFields.length} ${iteration === 1 ? "" : "additional "}optional field(s) available.`
|
|
310
304
|
)
|
|
@@ -320,13 +314,13 @@ There are ${newOptionalFields.length} ${iteration === 1 ? "" : "additional "}opt
|
|
|
320
314
|
]);
|
|
321
315
|
} catch (error) {
|
|
322
316
|
if (this.isUserCancellation(error)) {
|
|
323
|
-
console.log(
|
|
317
|
+
console.log(chalk3.yellow("\n\nOperation cancelled by user"));
|
|
324
318
|
process.exit(0);
|
|
325
319
|
}
|
|
326
320
|
throw error;
|
|
327
321
|
}
|
|
328
322
|
if (shouldConfigureOptional.configure) {
|
|
329
|
-
console.log(
|
|
323
|
+
console.log(chalk3.cyan(`
|
|
330
324
|
Optional fields:`));
|
|
331
325
|
for (const field of newOptionalFields) {
|
|
332
326
|
await this.promptForField(field, inputs);
|
|
@@ -344,7 +338,7 @@ Optional fields:`));
|
|
|
344
338
|
}
|
|
345
339
|
if (iteration >= maxIterations) {
|
|
346
340
|
console.log(
|
|
347
|
-
|
|
341
|
+
chalk3.yellow(
|
|
348
342
|
`
|
|
349
343
|
\u26A0\uFE0F Maximum field resolution iterations reached. Some dynamic fields may not have been discovered.`
|
|
350
344
|
)
|
|
@@ -377,7 +371,7 @@ Optional fields:`));
|
|
|
377
371
|
message: `${fieldObj.label || fieldObj.key}${fieldObj.required ? " (required)" : " (optional)"}:`
|
|
378
372
|
};
|
|
379
373
|
if (fieldObj.helpText) {
|
|
380
|
-
fieldPrompt.prefix =
|
|
374
|
+
fieldPrompt.prefix = chalk3.gray(`\u2139 ${fieldObj.helpText}
|
|
381
375
|
`);
|
|
382
376
|
}
|
|
383
377
|
if (fieldObj.default !== void 0) {
|
|
@@ -404,7 +398,7 @@ Optional fields:`));
|
|
|
404
398
|
}
|
|
405
399
|
} catch (error) {
|
|
406
400
|
if (this.isUserCancellation(error)) {
|
|
407
|
-
console.log(
|
|
401
|
+
console.log(chalk3.yellow("\n\nOperation cancelled by user"));
|
|
408
402
|
process.exit(0);
|
|
409
403
|
}
|
|
410
404
|
throw error;
|
|
@@ -415,9 +409,6 @@ Optional fields:`));
|
|
|
415
409
|
return errorObj?.name === "ExitPromptError" || errorObj?.message?.includes("User force closed") || errorObj?.isTTYError === true;
|
|
416
410
|
}
|
|
417
411
|
};
|
|
418
|
-
|
|
419
|
-
// src/utils/schema-formatter.ts
|
|
420
|
-
import chalk2 from "chalk";
|
|
421
412
|
function getFormatMetadata(schema) {
|
|
422
413
|
return schema?._def?.formatMeta;
|
|
423
414
|
}
|
|
@@ -441,9 +432,9 @@ function formatItemsFromSchema(inputSchema, items) {
|
|
|
441
432
|
}
|
|
442
433
|
function formatSingleItem(item, index, formatMeta) {
|
|
443
434
|
const formatted = formatMeta.format(item);
|
|
444
|
-
let titleLine = `${
|
|
435
|
+
let titleLine = `${chalk3.gray(`${index + 1}.`)} ${chalk3.cyan(formatted.title)}`;
|
|
445
436
|
if (formatted.subtitle) {
|
|
446
|
-
titleLine += ` ${
|
|
437
|
+
titleLine += ` ${chalk3.gray(formatted.subtitle)}`;
|
|
447
438
|
}
|
|
448
439
|
console.log(titleLine);
|
|
449
440
|
for (const detail of formatted.details) {
|
|
@@ -455,35 +446,33 @@ function formatSingleItem(item, index, formatMeta) {
|
|
|
455
446
|
function applyStyle(value, style) {
|
|
456
447
|
switch (style) {
|
|
457
448
|
case "dim":
|
|
458
|
-
return
|
|
449
|
+
return chalk3.dim(value);
|
|
459
450
|
case "accent":
|
|
460
|
-
return
|
|
451
|
+
return chalk3.magenta(value);
|
|
461
452
|
case "warning":
|
|
462
|
-
return
|
|
453
|
+
return chalk3.red(value);
|
|
463
454
|
case "success":
|
|
464
|
-
return
|
|
455
|
+
return chalk3.green(value);
|
|
465
456
|
case "normal":
|
|
466
457
|
default:
|
|
467
|
-
return
|
|
458
|
+
return chalk3.blue(value);
|
|
468
459
|
}
|
|
469
460
|
}
|
|
470
461
|
function formatItemsGeneric(items) {
|
|
471
462
|
items.forEach((item, index) => {
|
|
472
463
|
const itemObj = item;
|
|
473
464
|
const name = itemObj.title || itemObj.name || itemObj.key || itemObj.id || "Item";
|
|
474
|
-
console.log(`${
|
|
465
|
+
console.log(`${chalk3.gray(`${index + 1}.`)} ${chalk3.cyan(name)}`);
|
|
475
466
|
if (itemObj.description) {
|
|
476
|
-
console.log(` ${
|
|
467
|
+
console.log(` ${chalk3.dim(itemObj.description)}`);
|
|
477
468
|
}
|
|
478
469
|
console.log();
|
|
479
470
|
});
|
|
480
471
|
}
|
|
481
|
-
|
|
482
|
-
// src/utils/cli-generator.ts
|
|
483
|
-
import chalk3 from "chalk";
|
|
484
|
-
import util from "util";
|
|
485
|
-
import inquirer2 from "inquirer";
|
|
486
472
|
function formatJsonOutput(data) {
|
|
473
|
+
if (data === void 0) {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
487
476
|
if (data && typeof data === "object" && !Array.isArray(data) && (data.success !== void 0 || data.id || data.status)) {
|
|
488
477
|
console.log(chalk3.green("\u2705 Action completed successfully!\n"));
|
|
489
478
|
}
|
|
@@ -493,7 +482,7 @@ function formatJsonOutput(data) {
|
|
|
493
482
|
}
|
|
494
483
|
function analyzeZodSchema(schema) {
|
|
495
484
|
const parameters = [];
|
|
496
|
-
if (schema instanceof
|
|
485
|
+
if (schema instanceof z.ZodObject) {
|
|
497
486
|
const shape = schema.shape;
|
|
498
487
|
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
499
488
|
const param = analyzeZodField(key, fieldSchema);
|
|
@@ -508,29 +497,29 @@ function analyzeZodField(name, schema) {
|
|
|
508
497
|
let baseSchema = schema;
|
|
509
498
|
let required = true;
|
|
510
499
|
let defaultValue = void 0;
|
|
511
|
-
if (baseSchema instanceof
|
|
500
|
+
if (baseSchema instanceof z.ZodOptional) {
|
|
512
501
|
required = false;
|
|
513
502
|
baseSchema = baseSchema._def.innerType;
|
|
514
503
|
}
|
|
515
|
-
if (baseSchema instanceof
|
|
504
|
+
if (baseSchema instanceof z.ZodDefault) {
|
|
516
505
|
required = false;
|
|
517
506
|
defaultValue = baseSchema._def.defaultValue();
|
|
518
507
|
baseSchema = baseSchema._def.innerType;
|
|
519
508
|
}
|
|
520
509
|
let paramType = "string";
|
|
521
510
|
let choices;
|
|
522
|
-
if (baseSchema instanceof
|
|
511
|
+
if (baseSchema instanceof z.ZodString) {
|
|
523
512
|
paramType = "string";
|
|
524
|
-
} else if (baseSchema instanceof
|
|
513
|
+
} else if (baseSchema instanceof z.ZodNumber) {
|
|
525
514
|
paramType = "number";
|
|
526
|
-
} else if (baseSchema instanceof
|
|
515
|
+
} else if (baseSchema instanceof z.ZodBoolean) {
|
|
527
516
|
paramType = "boolean";
|
|
528
|
-
} else if (baseSchema instanceof
|
|
517
|
+
} else if (baseSchema instanceof z.ZodArray) {
|
|
529
518
|
paramType = "array";
|
|
530
|
-
} else if (baseSchema instanceof
|
|
519
|
+
} else if (baseSchema instanceof z.ZodEnum) {
|
|
531
520
|
paramType = "string";
|
|
532
521
|
choices = baseSchema._def.values;
|
|
533
|
-
} else if (baseSchema instanceof
|
|
522
|
+
} else if (baseSchema instanceof z.ZodRecord) {
|
|
534
523
|
paramType = "string";
|
|
535
524
|
}
|
|
536
525
|
return {
|
|
@@ -540,7 +529,7 @@ function analyzeZodField(name, schema) {
|
|
|
540
529
|
description: schema.description,
|
|
541
530
|
default: defaultValue,
|
|
542
531
|
choices,
|
|
543
|
-
hasResolver:
|
|
532
|
+
hasResolver: hasResolver(name),
|
|
544
533
|
isPositional: isPositional(schema)
|
|
545
534
|
};
|
|
546
535
|
}
|
|
@@ -853,7 +842,7 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
|
|
|
853
842
|
)
|
|
854
843
|
);
|
|
855
844
|
if (page.nextCursor) {
|
|
856
|
-
const { continueReading } = await
|
|
845
|
+
const { continueReading } = await inquirer.prompt([
|
|
857
846
|
{
|
|
858
847
|
type: "confirm",
|
|
859
848
|
name: "continueReading",
|
|
@@ -952,24 +941,12 @@ function getListTitleFromMethod(methodName) {
|
|
|
952
941
|
return `Available ${capitalized}`;
|
|
953
942
|
}
|
|
954
943
|
|
|
955
|
-
// src/commands/login.ts
|
|
956
|
-
import { Command } from "commander";
|
|
957
|
-
|
|
958
|
-
// src/utils/auth/login.ts
|
|
959
|
-
import open from "open";
|
|
960
|
-
import crypto from "crypto";
|
|
961
|
-
import express from "express";
|
|
962
|
-
import pkceChallenge from "pkce-challenge";
|
|
963
|
-
|
|
964
944
|
// src/utils/constants.ts
|
|
965
945
|
var ZAPIER_BASE = "https://zapier.com";
|
|
966
946
|
var LOGIN_CLIENT_ID = "K5eEnRE9TTmSFATdkkWhKF8NOKwoiOnYAyIqJjae";
|
|
967
947
|
var LOGIN_PORTS = [49505, 50575, 52804, 55981, 61010, 63851];
|
|
968
948
|
var LOGIN_TIMEOUT_MS = 3e5;
|
|
969
949
|
var AUTH_MODE_HEADER = "X-Auth";
|
|
970
|
-
|
|
971
|
-
// src/utils/spinner.ts
|
|
972
|
-
import ora from "ora";
|
|
973
950
|
var spinPromise = async (promise, text) => {
|
|
974
951
|
const spinner = ora(text).start();
|
|
975
952
|
try {
|
|
@@ -981,21 +958,18 @@ var spinPromise = async (promise, text) => {
|
|
|
981
958
|
throw error;
|
|
982
959
|
}
|
|
983
960
|
};
|
|
984
|
-
|
|
985
|
-
// src/utils/log.ts
|
|
986
|
-
import chalk4 from "chalk";
|
|
987
961
|
var log = {
|
|
988
962
|
info: (message, ...args) => {
|
|
989
|
-
console.log(
|
|
963
|
+
console.log(chalk3.blue("\u2139"), message, ...args);
|
|
990
964
|
},
|
|
991
965
|
error: (message, ...args) => {
|
|
992
|
-
console.error(
|
|
966
|
+
console.error(chalk3.red("\u2716"), message, ...args);
|
|
993
967
|
},
|
|
994
968
|
success: (message, ...args) => {
|
|
995
|
-
console.log(
|
|
969
|
+
console.log(chalk3.green("\u2713"), message, ...args);
|
|
996
970
|
},
|
|
997
971
|
warn: (message, ...args) => {
|
|
998
|
-
console.log(
|
|
972
|
+
console.log(chalk3.yellow("\u26A0"), message, ...args);
|
|
999
973
|
}
|
|
1000
974
|
};
|
|
1001
975
|
var log_default = log;
|
|
@@ -1046,9 +1020,6 @@ var getCallablePromise = () => {
|
|
|
1046
1020
|
};
|
|
1047
1021
|
};
|
|
1048
1022
|
var getCallablePromise_default = getCallablePromise;
|
|
1049
|
-
|
|
1050
|
-
// src/utils/auth/login.ts
|
|
1051
|
-
import { updateLogin, logout } from "@zapier/zapier-sdk-cli-login";
|
|
1052
1023
|
var findAvailablePort = () => {
|
|
1053
1024
|
return new Promise((resolve2, reject) => {
|
|
1054
1025
|
let portIndex = 0;
|
|
@@ -1179,88 +1150,102 @@ var login = async (timeoutMs = LOGIN_TIMEOUT_MS) => {
|
|
|
1179
1150
|
return data.access_token;
|
|
1180
1151
|
};
|
|
1181
1152
|
var login_default = login;
|
|
1153
|
+
var LoginSchema = z.object({
|
|
1154
|
+
timeout: z.string().optional().describe("Login timeout in seconds (default: 300)")
|
|
1155
|
+
}).describe("Log in to Zapier to access your account");
|
|
1182
1156
|
|
|
1183
|
-
// src/
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
"
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1157
|
+
// src/plugins/login/index.ts
|
|
1158
|
+
var loginWithSdk = createFunction(async function loginWithSdk2(options) {
|
|
1159
|
+
const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
|
|
1160
|
+
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
1161
|
+
throw new Error("Timeout must be a positive number");
|
|
1162
|
+
}
|
|
1163
|
+
await login_default(timeoutSeconds * 1e3);
|
|
1164
|
+
const user = await getLoggedInUser();
|
|
1165
|
+
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
1166
|
+
setTimeout(() => process.exit(0), 100);
|
|
1167
|
+
}, LoginSchema);
|
|
1168
|
+
var loginPlugin = () => ({
|
|
1169
|
+
login: loginWithSdk,
|
|
1170
|
+
context: {
|
|
1171
|
+
meta: {
|
|
1172
|
+
login: {
|
|
1173
|
+
categories: ["account"],
|
|
1174
|
+
inputSchema: LoginSchema
|
|
1195
1175
|
}
|
|
1196
|
-
await login_default(timeoutSeconds * 1e3);
|
|
1197
|
-
const user = await getLoggedInUser();
|
|
1198
|
-
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
1199
|
-
setTimeout(() => process.exit(0), 100);
|
|
1200
|
-
} catch (error) {
|
|
1201
|
-
console.error(
|
|
1202
|
-
"\u274C Login failed:",
|
|
1203
|
-
error instanceof Error ? error.message : "Unknown error"
|
|
1204
|
-
);
|
|
1205
|
-
process.exit(1);
|
|
1206
1176
|
}
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1177
|
+
}
|
|
1178
|
+
});
|
|
1179
|
+
var LogoutSchema = z.object({}).describe("Log out of your Zapier account");
|
|
1209
1180
|
|
|
1210
|
-
// src/
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
process.exit(1);
|
|
1181
|
+
// src/plugins/logout/index.ts
|
|
1182
|
+
var logoutWithSdk = createFunction(async function logoutWithSdk2(_options) {
|
|
1183
|
+
logout();
|
|
1184
|
+
console.log("\u2705 Successfully logged out");
|
|
1185
|
+
}, LogoutSchema);
|
|
1186
|
+
var logoutPlugin = () => ({
|
|
1187
|
+
logout: logoutWithSdk,
|
|
1188
|
+
context: {
|
|
1189
|
+
meta: {
|
|
1190
|
+
logout: {
|
|
1191
|
+
categories: ["account"],
|
|
1192
|
+
inputSchema: LogoutSchema
|
|
1193
|
+
}
|
|
1224
1194
|
}
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
import { getConfigPath } from "@zapier/zapier-sdk-cli-login";
|
|
1231
|
-
function createConfigPathCommand() {
|
|
1232
|
-
return new Command3("get-config-path").description("Show the path to the configuration file").action(async () => {
|
|
1233
|
-
console.log(`Configuration file: ${getConfigPath()}`);
|
|
1234
|
-
});
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
// src/commands/generate-types/cli.ts
|
|
1238
|
-
import { Command as Command4 } from "commander";
|
|
1239
|
-
import { createZapierSdk } from "@zapier/zapier-sdk";
|
|
1195
|
+
}
|
|
1196
|
+
});
|
|
1197
|
+
var McpSchema = z.object({
|
|
1198
|
+
port: z.string().optional().describe("Port to listen on (for future HTTP transport)")
|
|
1199
|
+
}).describe("Start MCP server for Zapier SDK");
|
|
1240
1200
|
|
|
1241
|
-
// src/
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1201
|
+
// src/plugins/mcp/index.ts
|
|
1202
|
+
var mcpPlugin = ({ context }) => {
|
|
1203
|
+
const mcpWithSdk = createFunction(async function mcpWithSdk2(options) {
|
|
1204
|
+
const mcpOptions = {
|
|
1205
|
+
...options,
|
|
1206
|
+
debug: context.options.debug
|
|
1207
|
+
};
|
|
1208
|
+
return await startMcpServerAsProcess(mcpOptions);
|
|
1209
|
+
}, McpSchema);
|
|
1210
|
+
return {
|
|
1211
|
+
mcp: mcpWithSdk,
|
|
1212
|
+
context: {
|
|
1213
|
+
meta: {
|
|
1214
|
+
mcp: {
|
|
1215
|
+
categories: ["utility"],
|
|
1216
|
+
inputSchema: McpSchema
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
};
|
|
1222
|
+
var GenerateTypesSchema = z.object({
|
|
1250
1223
|
appKey: AppKeyPropertySchema.describe("App key to generate SDK code for"),
|
|
1251
1224
|
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
1252
1225
|
output: OutputPropertySchema.optional().describe(
|
|
1253
1226
|
"Output file path (defaults to generated/<appKey>.ts)"
|
|
1254
1227
|
),
|
|
1255
|
-
|
|
1256
|
-
"Enable debug logging during generation"
|
|
1257
|
-
),
|
|
1258
|
-
lockFilePath: z3.string().optional().describe("Path to the .zapierrc lock file (defaults to .zapierrc)")
|
|
1228
|
+
lockFilePath: z.string().optional().describe("Path to the .zapierrc lock file (defaults to .zapierrc)")
|
|
1259
1229
|
}).describe("Generate TypeScript SDK code for a specific app");
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1230
|
+
var generateTypesPlugin = ({ sdk: sdk2 }) => {
|
|
1231
|
+
const generateTypesWithSdk = createFunction(
|
|
1232
|
+
async function generateTypesWithSdk2(options) {
|
|
1233
|
+
return await generateTypes({ ...options, sdk: sdk2 });
|
|
1234
|
+
},
|
|
1235
|
+
GenerateTypesSchema
|
|
1236
|
+
);
|
|
1237
|
+
return {
|
|
1238
|
+
generateTypes: generateTypesWithSdk,
|
|
1239
|
+
context: {
|
|
1240
|
+
meta: {
|
|
1241
|
+
generateTypes: {
|
|
1242
|
+
categories: ["utility"],
|
|
1243
|
+
inputSchema: GenerateTypesSchema
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
};
|
|
1264
1249
|
function generateFetchMethodSignature() {
|
|
1265
1250
|
return ` /** Make authenticated HTTP requests through Zapier's Relay service */
|
|
1266
1251
|
fetch: (options: Omit<z.infer<typeof RelayFetchSchema>, 'authenticationId'>) => Promise<Response>`;
|
|
@@ -1551,216 +1536,32 @@ function mapFieldTypeToTypeScript(field) {
|
|
|
1551
1536
|
return "string | number | boolean";
|
|
1552
1537
|
}
|
|
1553
1538
|
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
parameters.push(param);
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
return parameters;
|
|
1573
|
-
}
|
|
1574
|
-
function analyzeZodField2(name, schema) {
|
|
1575
|
-
let baseSchema = schema;
|
|
1576
|
-
let required = true;
|
|
1577
|
-
let defaultValue = void 0;
|
|
1578
|
-
if (baseSchema instanceof z4.ZodOptional) {
|
|
1579
|
-
required = false;
|
|
1580
|
-
baseSchema = baseSchema._def.innerType;
|
|
1581
|
-
}
|
|
1582
|
-
if (baseSchema instanceof z4.ZodDefault) {
|
|
1583
|
-
required = false;
|
|
1584
|
-
defaultValue = baseSchema._def.defaultValue();
|
|
1585
|
-
baseSchema = baseSchema._def.innerType;
|
|
1586
|
-
}
|
|
1587
|
-
let paramType = "string";
|
|
1588
|
-
let choices;
|
|
1589
|
-
if (baseSchema instanceof z4.ZodString) {
|
|
1590
|
-
paramType = "string";
|
|
1591
|
-
} else if (baseSchema instanceof z4.ZodNumber) {
|
|
1592
|
-
paramType = "number";
|
|
1593
|
-
} else if (baseSchema instanceof z4.ZodBoolean) {
|
|
1594
|
-
paramType = "boolean";
|
|
1595
|
-
} else if (baseSchema instanceof z4.ZodArray) {
|
|
1596
|
-
paramType = "array";
|
|
1597
|
-
} else if (baseSchema instanceof z4.ZodEnum) {
|
|
1598
|
-
paramType = "string";
|
|
1599
|
-
choices = baseSchema._def.values;
|
|
1600
|
-
} else if (baseSchema instanceof z4.ZodRecord) {
|
|
1601
|
-
paramType = "string";
|
|
1602
|
-
}
|
|
1539
|
+
var BundleCodeSchema = z.object({
|
|
1540
|
+
input: z.string().min(1).describe("Input TypeScript file path to bundle"),
|
|
1541
|
+
output: OutputPropertySchema.optional().describe(
|
|
1542
|
+
"Output file path (defaults to input with .js extension)"
|
|
1543
|
+
),
|
|
1544
|
+
string: z.boolean().optional().describe("Return bundled code as string instead of writing to file"),
|
|
1545
|
+
minify: z.boolean().optional().describe("Minify the bundled output"),
|
|
1546
|
+
target: z.string().optional().describe("ECMAScript target version"),
|
|
1547
|
+
cjs: z.boolean().optional().describe("Output CommonJS format instead of ESM")
|
|
1548
|
+
}).describe("Bundle TypeScript code into executable JavaScript");
|
|
1549
|
+
var bundleCodePlugin = () => {
|
|
1550
|
+
const bundleCodeWithSdk = createFunction(async function bundleCodeWithSdk2(options) {
|
|
1551
|
+
return await bundleCode(options);
|
|
1552
|
+
}, BundleCodeSchema);
|
|
1603
1553
|
return {
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
hasResolver: hasResolver3(name),
|
|
1611
|
-
isPositional: isPositional2(schema)
|
|
1612
|
-
};
|
|
1613
|
-
}
|
|
1614
|
-
function convertCliArgsToSdkParams2(parameters, positionalArgs, options) {
|
|
1615
|
-
const sdkParams = {};
|
|
1616
|
-
let argIndex = 0;
|
|
1617
|
-
parameters.forEach((param) => {
|
|
1618
|
-
if ((param.required || param.isPositional) && argIndex < positionalArgs.length) {
|
|
1619
|
-
sdkParams[param.name] = convertValue2(
|
|
1620
|
-
positionalArgs[argIndex],
|
|
1621
|
-
param.type
|
|
1622
|
-
);
|
|
1623
|
-
argIndex++;
|
|
1624
|
-
}
|
|
1625
|
-
});
|
|
1626
|
-
Object.entries(options).forEach(([key, value]) => {
|
|
1627
|
-
const camelKey = key.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
1628
|
-
const param = parameters.find((p) => p.name === camelKey);
|
|
1629
|
-
if (param && value !== void 0) {
|
|
1630
|
-
sdkParams[camelKey] = convertValue2(value, param.type);
|
|
1631
|
-
}
|
|
1632
|
-
});
|
|
1633
|
-
return sdkParams;
|
|
1634
|
-
}
|
|
1635
|
-
function convertValue2(value, type) {
|
|
1636
|
-
switch (type) {
|
|
1637
|
-
case "number":
|
|
1638
|
-
return Number(value);
|
|
1639
|
-
case "boolean":
|
|
1640
|
-
return Boolean(value);
|
|
1641
|
-
case "array":
|
|
1642
|
-
return Array.isArray(value) ? value : [value];
|
|
1643
|
-
case "string":
|
|
1644
|
-
default:
|
|
1645
|
-
if (typeof value === "string" && (value.startsWith("{") || value.startsWith("["))) {
|
|
1646
|
-
try {
|
|
1647
|
-
return JSON.parse(value);
|
|
1648
|
-
} catch {
|
|
1649
|
-
return value;
|
|
1554
|
+
bundleCode: bundleCodeWithSdk,
|
|
1555
|
+
context: {
|
|
1556
|
+
meta: {
|
|
1557
|
+
bundleCode: {
|
|
1558
|
+
categories: ["utility"],
|
|
1559
|
+
inputSchema: BundleCodeSchema
|
|
1650
1560
|
}
|
|
1651
1561
|
}
|
|
1652
|
-
return value;
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
|
|
1656
|
-
// src/commands/generate-types/cli.ts
|
|
1657
|
-
function createGenerateTypesCommand() {
|
|
1658
|
-
const parameters = analyzeZodSchema2(GenerateTypesSchema);
|
|
1659
|
-
const description = GenerateTypesSchema.description || "Generate TypeScript SDK types for a specific app";
|
|
1660
|
-
const command = new Command4("generate-types").description(description);
|
|
1661
|
-
parameters.forEach((param) => {
|
|
1662
|
-
const kebabName = param.name.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
1663
|
-
if (param.hasResolver && param.required) {
|
|
1664
|
-
command.argument(
|
|
1665
|
-
`[${kebabName}]`,
|
|
1666
|
-
param.description || `${kebabName} parameter`
|
|
1667
|
-
);
|
|
1668
|
-
} else if (param.required) {
|
|
1669
|
-
command.argument(
|
|
1670
|
-
`<${kebabName}>`,
|
|
1671
|
-
param.description || `${kebabName} parameter`
|
|
1672
|
-
);
|
|
1673
|
-
} else if (param.isPositional) {
|
|
1674
|
-
command.argument(
|
|
1675
|
-
`[${kebabName}]`,
|
|
1676
|
-
param.description || `${kebabName} parameter`
|
|
1677
|
-
);
|
|
1678
|
-
} else {
|
|
1679
|
-
const flags = [`--${kebabName}`];
|
|
1680
|
-
if (param.type === "boolean") {
|
|
1681
|
-
command.option(flags.join(", "), param.description);
|
|
1682
|
-
} else {
|
|
1683
|
-
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
1684
|
-
command.option(
|
|
1685
|
-
flagSignature,
|
|
1686
|
-
param.description || "",
|
|
1687
|
-
param.default
|
|
1688
|
-
);
|
|
1689
|
-
}
|
|
1690
|
-
}
|
|
1691
|
-
});
|
|
1692
|
-
command.option("--json", "Output raw JSON instead of formatted results");
|
|
1693
|
-
command.action(async (...args) => {
|
|
1694
|
-
try {
|
|
1695
|
-
const commandObj = args[args.length - 1];
|
|
1696
|
-
const options = commandObj.opts();
|
|
1697
|
-
const rawParams = convertCliArgsToSdkParams2(
|
|
1698
|
-
parameters,
|
|
1699
|
-
args.slice(0, -1),
|
|
1700
|
-
options
|
|
1701
|
-
);
|
|
1702
|
-
const sdk2 = createZapierSdk({
|
|
1703
|
-
manifestPath: rawParams.lockFilePath
|
|
1704
|
-
});
|
|
1705
|
-
const resolver = new SchemaParameterResolver();
|
|
1706
|
-
const resolvedParams = await resolver.resolveParameters(
|
|
1707
|
-
GenerateTypesSchema,
|
|
1708
|
-
rawParams,
|
|
1709
|
-
sdk2
|
|
1710
|
-
);
|
|
1711
|
-
const params = resolvedParams;
|
|
1712
|
-
console.log(
|
|
1713
|
-
chalk5.blue(
|
|
1714
|
-
`\u{1F527} Generating TypeScript types for ${params.appKey}...`
|
|
1715
|
-
)
|
|
1716
|
-
);
|
|
1717
|
-
const generateTypesParams = {
|
|
1718
|
-
appKey: params.appKey,
|
|
1719
|
-
debug: params.debug ?? false,
|
|
1720
|
-
authenticationId: params.authenticationId,
|
|
1721
|
-
output: params.output,
|
|
1722
|
-
sdk: sdk2
|
|
1723
|
-
};
|
|
1724
|
-
const result = await generateTypes(generateTypesParams);
|
|
1725
|
-
if (options.json) {
|
|
1726
|
-
console.log(JSON.stringify({ result }, null, 2));
|
|
1727
|
-
} else {
|
|
1728
|
-
const output = params.output || `./types/${params.appKey}.d.ts`;
|
|
1729
|
-
console.log(chalk5.green("\u2705 TypeScript types generated successfully!"));
|
|
1730
|
-
console.log(chalk5.gray(`Output written to: ${output}`));
|
|
1731
|
-
}
|
|
1732
|
-
} catch (error) {
|
|
1733
|
-
console.error(
|
|
1734
|
-
chalk5.red("Error:"),
|
|
1735
|
-
error instanceof Error ? error.message : "Unknown error"
|
|
1736
|
-
);
|
|
1737
|
-
process.exit(1);
|
|
1738
1562
|
}
|
|
1739
|
-
}
|
|
1740
|
-
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
// src/commands/bundle-code/cli.ts
|
|
1744
|
-
import { Command as Command5 } from "commander";
|
|
1745
|
-
|
|
1746
|
-
// src/commands/bundle-code/schemas.ts
|
|
1747
|
-
import { z as z5 } from "zod";
|
|
1748
|
-
import { OutputPropertySchema as OutputPropertySchema2 } from "@zapier/zapier-sdk";
|
|
1749
|
-
var BundleCodeSchema = z5.object({
|
|
1750
|
-
input: z5.string().min(1).describe("Input TypeScript file path to bundle"),
|
|
1751
|
-
output: OutputPropertySchema2.optional().describe(
|
|
1752
|
-
"Output file path (defaults to input with .js extension)"
|
|
1753
|
-
),
|
|
1754
|
-
string: z5.boolean().default(false).describe("Return bundled code as string instead of writing to file"),
|
|
1755
|
-
minify: z5.boolean().default(false).describe("Minify the bundled output"),
|
|
1756
|
-
target: z5.string().default("es2017").describe("ECMAScript target version"),
|
|
1757
|
-
cjs: z5.boolean().default(false).describe("Output CommonJS format instead of ESM")
|
|
1758
|
-
}).describe("Bundle TypeScript code into executable JavaScript");
|
|
1759
|
-
|
|
1760
|
-
// src/commands/bundle-code/index.ts
|
|
1761
|
-
import { buildSync } from "esbuild";
|
|
1762
|
-
import * as fs2 from "fs";
|
|
1763
|
-
import * as path2 from "path";
|
|
1563
|
+
};
|
|
1564
|
+
};
|
|
1764
1565
|
var ZapierBundleError = class extends Error {
|
|
1765
1566
|
constructor(message, details, originalError) {
|
|
1766
1567
|
super(message);
|
|
@@ -1779,7 +1580,7 @@ async function bundleCode(options) {
|
|
|
1779
1580
|
minify = false,
|
|
1780
1581
|
string: returnString = false
|
|
1781
1582
|
} = options;
|
|
1782
|
-
const resolvedInput =
|
|
1583
|
+
const resolvedInput = path.resolve(process.cwd(), input);
|
|
1783
1584
|
try {
|
|
1784
1585
|
const result = buildSync({
|
|
1785
1586
|
entryPoints: [resolvedInput],
|
|
@@ -1811,8 +1612,8 @@ async function bundleCode(options) {
|
|
|
1811
1612
|
finalOutput = JSON.stringify(bundledCode);
|
|
1812
1613
|
}
|
|
1813
1614
|
if (output) {
|
|
1814
|
-
|
|
1815
|
-
|
|
1615
|
+
fs.mkdirSync(path.dirname(output), { recursive: true });
|
|
1616
|
+
fs.writeFileSync(output, finalOutput, "utf8");
|
|
1816
1617
|
}
|
|
1817
1618
|
return finalOutput;
|
|
1818
1619
|
} catch (error) {
|
|
@@ -1826,105 +1627,52 @@ async function bundleCode(options) {
|
|
|
1826
1627
|
);
|
|
1827
1628
|
}
|
|
1828
1629
|
}
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
function
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
`<${kebabName}>`,
|
|
1846
|
-
param.description || `${kebabName} parameter`
|
|
1847
|
-
);
|
|
1848
|
-
} else if (param.isPositional) {
|
|
1849
|
-
command.argument(
|
|
1850
|
-
`[${kebabName}]`,
|
|
1851
|
-
param.description || `${kebabName} parameter`
|
|
1852
|
-
);
|
|
1853
|
-
} else {
|
|
1854
|
-
const flags = [`--${kebabName}`];
|
|
1855
|
-
if (param.type === "boolean") {
|
|
1856
|
-
command.option(flags.join(", "), param.description);
|
|
1857
|
-
} else {
|
|
1858
|
-
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
1859
|
-
command.option(
|
|
1860
|
-
flagSignature,
|
|
1861
|
-
param.description || "",
|
|
1862
|
-
param.default
|
|
1863
|
-
);
|
|
1864
|
-
}
|
|
1865
|
-
}
|
|
1866
|
-
});
|
|
1867
|
-
command.option("--json", "Output raw JSON instead of formatted results");
|
|
1868
|
-
command.action(async (...args) => {
|
|
1869
|
-
try {
|
|
1870
|
-
const commandObj = args[args.length - 1];
|
|
1871
|
-
const options = commandObj.opts();
|
|
1872
|
-
const rawParams = convertCliArgsToSdkParams2(
|
|
1873
|
-
parameters,
|
|
1874
|
-
args.slice(0, -1),
|
|
1875
|
-
options
|
|
1876
|
-
);
|
|
1877
|
-
if (!rawParams.input) {
|
|
1878
|
-
throw new Error("Input file path is required");
|
|
1879
|
-
}
|
|
1880
|
-
console.log(chalk6.blue(`\u{1F4E6} Bundling ${rawParams.input}...`));
|
|
1881
|
-
const result = await bundleCode(
|
|
1882
|
-
rawParams
|
|
1883
|
-
);
|
|
1884
|
-
if (options.json) {
|
|
1885
|
-
console.log(JSON.stringify({ result }, null, 2));
|
|
1886
|
-
} else if (rawParams.output && !rawParams.string) {
|
|
1887
|
-
console.log(chalk6.green("\u2705 Bundle created successfully!"));
|
|
1888
|
-
console.log(chalk6.gray(`Output written to: ${rawParams.output}`));
|
|
1889
|
-
} else if (rawParams.string) {
|
|
1890
|
-
console.log(chalk6.green("\u2705 Bundle generated as string!"));
|
|
1891
|
-
console.log("\n" + result);
|
|
1892
|
-
} else {
|
|
1893
|
-
console.log(chalk6.green("\u2705 Bundle completed!"));
|
|
1894
|
-
console.log("\n" + result);
|
|
1630
|
+
var GetConfigPathSchema = z.object({}).describe("Show the path to the configuration file");
|
|
1631
|
+
var getConfigPathPlugin = () => {
|
|
1632
|
+
const getConfigPathWithSdk = createFunction(
|
|
1633
|
+
async function getConfigPathWithSdk2(_options) {
|
|
1634
|
+
return getConfigPath();
|
|
1635
|
+
},
|
|
1636
|
+
GetConfigPathSchema
|
|
1637
|
+
);
|
|
1638
|
+
return {
|
|
1639
|
+
getConfigPath: getConfigPathWithSdk,
|
|
1640
|
+
context: {
|
|
1641
|
+
meta: {
|
|
1642
|
+
getConfigPath: {
|
|
1643
|
+
categories: ["utility"],
|
|
1644
|
+
inputSchema: GetConfigPathSchema
|
|
1645
|
+
}
|
|
1895
1646
|
}
|
|
1896
|
-
} catch (error) {
|
|
1897
|
-
console.error(
|
|
1898
|
-
chalk6.red("Error:"),
|
|
1899
|
-
error instanceof Error ? error.message : "Unknown error"
|
|
1900
|
-
);
|
|
1901
|
-
process.exit(1);
|
|
1902
1647
|
}
|
|
1648
|
+
};
|
|
1649
|
+
};
|
|
1650
|
+
|
|
1651
|
+
// src/sdk.ts
|
|
1652
|
+
function createZapierCliSdk(options = {}) {
|
|
1653
|
+
let sdk2 = createZapierSdkWithoutRegistry({
|
|
1654
|
+
debug: options.debug
|
|
1903
1655
|
});
|
|
1904
|
-
|
|
1656
|
+
sdk2 = sdk2.addPlugin(generateTypesPlugin);
|
|
1657
|
+
sdk2 = sdk2.addPlugin(bundleCodePlugin);
|
|
1658
|
+
sdk2 = sdk2.addPlugin(getConfigPathPlugin);
|
|
1659
|
+
sdk2 = sdk2.addPlugin(mcpPlugin);
|
|
1660
|
+
sdk2 = sdk2.addPlugin(loginPlugin);
|
|
1661
|
+
sdk2 = sdk2.addPlugin(logoutPlugin);
|
|
1662
|
+
const finalSdk = sdk2.addPlugin(registryPlugin);
|
|
1663
|
+
return finalSdk;
|
|
1905
1664
|
}
|
|
1906
1665
|
|
|
1907
|
-
//
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
function createMcpCommand() {
|
|
1911
|
-
const command = new Command6("mcp");
|
|
1912
|
-
command.description("Start MCP server for Zapier SDK").option("--debug", "Enable debug logging").option("--port <port>", "Port to listen on (for future HTTP transport)").action(startMcpServerAsProcess);
|
|
1913
|
-
return command;
|
|
1914
|
-
}
|
|
1666
|
+
// package.json
|
|
1667
|
+
var package_default = {
|
|
1668
|
+
version: "0.6.4"};
|
|
1915
1669
|
|
|
1916
1670
|
// src/cli.ts
|
|
1917
|
-
var program = new
|
|
1918
|
-
program.name("zapier-sdk").description("CLI for Zapier SDK").version(
|
|
1671
|
+
var program = new Command();
|
|
1672
|
+
program.name("zapier-sdk").description("CLI for Zapier SDK").version(package_default.version, "-v, --version", "display version number").option("--debug", "Enable debug logging");
|
|
1919
1673
|
var isDebugMode = process.env.DEBUG === "true" || process.argv.includes("--debug");
|
|
1920
|
-
var sdk =
|
|
1674
|
+
var sdk = createZapierCliSdk({
|
|
1921
1675
|
debug: isDebugMode
|
|
1922
1676
|
});
|
|
1923
|
-
program.addCommand(createLoginCommand());
|
|
1924
|
-
program.addCommand(createLogoutCommand());
|
|
1925
1677
|
generateCliCommands(program, sdk);
|
|
1926
|
-
program.addCommand(createGenerateTypesCommand());
|
|
1927
|
-
program.addCommand(createBundleCodeCommand());
|
|
1928
|
-
program.addCommand(createConfigPathCommand());
|
|
1929
|
-
program.addCommand(createMcpCommand());
|
|
1930
1678
|
program.parse();
|