@zapier/zapier-sdk-cli 0.8.4 → 0.10.0
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 +32 -0
- package/README.md +35 -51
- package/dist/cli.cjs +950 -433
- package/dist/cli.mjs +951 -434
- package/dist/index.cjs +729 -336
- package/dist/index.mjs +730 -337
- package/dist/package.json +1 -1
- package/dist/src/plugins/add/ast-generator.d.ts +37 -0
- package/dist/src/plugins/add/ast-generator.js +403 -0
- package/dist/src/plugins/add/index.d.ts +13 -0
- package/dist/src/plugins/add/index.js +120 -0
- package/dist/src/plugins/add/schemas.d.ts +18 -0
- package/dist/src/plugins/add/schemas.js +19 -0
- package/dist/src/plugins/getLoginConfigPath/index.d.ts +15 -0
- package/dist/src/plugins/getLoginConfigPath/index.js +19 -0
- package/dist/src/plugins/getLoginConfigPath/schemas.d.ts +3 -0
- package/dist/src/plugins/getLoginConfigPath/schemas.js +5 -0
- package/dist/src/plugins/index.d.ts +2 -2
- package/dist/src/plugins/index.js +2 -2
- package/dist/src/sdk.js +3 -3
- package/dist/src/utils/cli-generator-utils.d.ts +2 -1
- package/dist/src/utils/cli-generator-utils.js +11 -5
- package/dist/src/utils/cli-generator.js +65 -65
- package/dist/src/utils/parameter-resolver.d.ts +4 -1
- package/dist/src/utils/parameter-resolver.js +92 -15
- package/dist/src/utils/schema-formatter.d.ts +5 -1
- package/dist/src/utils/schema-formatter.js +48 -18
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/plugins/add/ast-generator.ts +777 -0
- package/src/plugins/add/index.test.ts +58 -0
- package/src/plugins/add/index.ts +187 -0
- package/src/plugins/add/schemas.ts +26 -0
- package/src/plugins/getLoginConfigPath/index.ts +45 -0
- package/src/plugins/getLoginConfigPath/schemas.ts +10 -0
- package/src/plugins/index.ts +2 -2
- package/src/sdk.ts +4 -4
- package/src/utils/cli-generator-utils.ts +17 -5
- package/src/utils/cli-generator.ts +90 -79
- package/src/utils/parameter-resolver.ts +155 -21
- package/src/utils/schema-formatter.ts +68 -33
- package/tsup.config.ts +1 -1
- package/dist/src/plugins/generateTypes/index.d.ts +0 -21
- package/dist/src/plugins/generateTypes/index.js +0 -312
- package/dist/src/plugins/generateTypes/schemas.d.ts +0 -18
- package/dist/src/plugins/generateTypes/schemas.js +0 -14
- package/dist/src/plugins/getConfigPath/index.d.ts +0 -15
- package/dist/src/plugins/getConfigPath/index.js +0 -19
- package/dist/src/plugins/getConfigPath/schemas.d.ts +0 -3
- package/dist/src/plugins/getConfigPath/schemas.js +0 -5
- package/src/plugins/generateTypes/index.ts +0 -444
- package/src/plugins/generateTypes/schemas.ts +0 -23
- package/src/plugins/getConfigPath/index.ts +0 -42
- package/src/plugins/getConfigPath/schemas.ts +0 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
+
import util from "util";
|
|
2
3
|
function getFormatMetadata(schema) {
|
|
3
4
|
return schema?._def
|
|
4
5
|
?.formatMeta;
|
|
@@ -7,11 +8,22 @@ function getOutputSchema(schema) {
|
|
|
7
8
|
return schema?._def?.outputSchema;
|
|
8
9
|
}
|
|
9
10
|
// ============================================================================
|
|
11
|
+
// JSON Formatting
|
|
12
|
+
// ============================================================================
|
|
13
|
+
export function formatJsonOutput(data) {
|
|
14
|
+
// Don't print anything for undefined results (commands that just perform actions)
|
|
15
|
+
if (data === undefined) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// Use util.inspect for colored output
|
|
19
|
+
console.log(util.inspect(data, { colors: true, depth: null, breakLength: 80 }));
|
|
20
|
+
}
|
|
21
|
+
// ============================================================================
|
|
10
22
|
// Generic Schema-Driven Formatter
|
|
11
23
|
// ============================================================================
|
|
12
|
-
export function formatItemsFromSchema(
|
|
13
|
-
// Get the output schema
|
|
14
|
-
const outputSchema = getOutputSchema(inputSchema);
|
|
24
|
+
export function formatItemsFromSchema(functionInfo, items, startingNumber = 0) {
|
|
25
|
+
// Get the output schema from function info or fall back to input schema output schema
|
|
26
|
+
const outputSchema = functionInfo.outputSchema || getOutputSchema(functionInfo.inputSchema);
|
|
15
27
|
if (!outputSchema) {
|
|
16
28
|
// Fallback to generic formatting if no output schema
|
|
17
29
|
formatItemsGeneric(items, startingNumber);
|
|
@@ -25,18 +37,31 @@ export function formatItemsFromSchema(inputSchema, items, startingNumber = 0) {
|
|
|
25
37
|
}
|
|
26
38
|
// Format each item using the schema metadata
|
|
27
39
|
items.forEach((item, index) => {
|
|
28
|
-
|
|
40
|
+
const formatted = formatMeta.format(item);
|
|
41
|
+
formatSingleItem(formatted, startingNumber + index);
|
|
29
42
|
});
|
|
30
43
|
}
|
|
31
|
-
function formatSingleItem(
|
|
32
|
-
//
|
|
33
|
-
const formatted = formatMeta.format(item);
|
|
34
|
-
// Build the main title line
|
|
44
|
+
function formatSingleItem(formatted, itemNumber) {
|
|
45
|
+
// Build the main title line with optional subtitle
|
|
35
46
|
let titleLine = `${chalk.gray(`${itemNumber + 1}.`)} ${chalk.cyan(formatted.title)}`;
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
// Generate subtitle from id or key
|
|
48
|
+
if (formatted.id) {
|
|
49
|
+
titleLine += ` ${chalk.gray(`(ID: ${formatted.id})`)}`;
|
|
50
|
+
}
|
|
51
|
+
else if (formatted.key) {
|
|
52
|
+
titleLine += ` ${chalk.gray(`(${formatted.key})`)}`;
|
|
38
53
|
}
|
|
39
54
|
console.log(titleLine);
|
|
55
|
+
// Show description if available
|
|
56
|
+
if (formatted.description) {
|
|
57
|
+
console.log(` ${chalk.dim(formatted.description)}`);
|
|
58
|
+
}
|
|
59
|
+
// If data is provided, use JSON formatting instead of details
|
|
60
|
+
if (formatted.data !== undefined) {
|
|
61
|
+
formatJsonOutput(formatted.data);
|
|
62
|
+
console.log(); // Empty line between items
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
40
65
|
// Format detail lines
|
|
41
66
|
for (const detail of formatted.details) {
|
|
42
67
|
const styledText = applyStyle(detail.text, detail.style);
|
|
@@ -59,15 +84,20 @@ function applyStyle(value, style) {
|
|
|
59
84
|
return chalk.blue(value);
|
|
60
85
|
}
|
|
61
86
|
}
|
|
87
|
+
function convertGenericItemToFormattedItem(item) {
|
|
88
|
+
const itemObj = item;
|
|
89
|
+
return {
|
|
90
|
+
title: itemObj.title || itemObj.name || itemObj.key || itemObj.id || "Item",
|
|
91
|
+
id: itemObj.id,
|
|
92
|
+
key: itemObj.key,
|
|
93
|
+
description: itemObj.description,
|
|
94
|
+
details: [],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
62
97
|
function formatItemsGeneric(items, startingNumber = 0) {
|
|
63
|
-
//
|
|
98
|
+
// Convert generic items to FormattedItem and use formatSingleItem
|
|
64
99
|
items.forEach((item, index) => {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
console.log(`${chalk.gray(`${startingNumber + index + 1}.`)} ${chalk.cyan(name)}`);
|
|
68
|
-
if (itemObj.description) {
|
|
69
|
-
console.log(` ${chalk.dim(itemObj.description)}`);
|
|
70
|
-
}
|
|
71
|
-
console.log();
|
|
100
|
+
const formatted = convertGenericItemToFormattedItem(item);
|
|
101
|
+
formatSingleItem(formatted, startingNumber + index);
|
|
72
102
|
});
|
|
73
103
|
}
|