@zapier/zapier-sdk-cli 0.35.0 → 0.36.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 +23 -0
- package/README.md +232 -0
- package/dist/cli.cjs +337 -168
- package/dist/cli.mjs +335 -167
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/package.json +2 -1
- package/dist/src/utils/cli-generator.js +46 -12
- package/dist/src/utils/parameter-resolver.d.ts +11 -0
- package/dist/src/utils/parameter-resolver.js +262 -157
- package/dist/src/utils/schema-formatter.d.ts +6 -1
- package/dist/src/utils/schema-formatter.js +45 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import util from "util";
|
|
3
|
+
import wrapAnsi from "wrap-ansi";
|
|
3
4
|
// These functions are internal to SDK, implementing basic formatting fallback
|
|
4
5
|
// TODO: Consider exposing these utilities or implementing proper CLI formatting
|
|
5
6
|
function getFormatMetadata(schema) {
|
|
@@ -24,7 +25,21 @@ export function formatJsonOutput(data) {
|
|
|
24
25
|
// ============================================================================
|
|
25
26
|
// Generic Schema-Driven Formatter
|
|
26
27
|
// ============================================================================
|
|
27
|
-
export function formatItemsFromSchema(functionInfo, items, startingNumber = 0) {
|
|
28
|
+
export async function formatItemsFromSchema(functionInfo, items, startingNumber = 0, options) {
|
|
29
|
+
// If a registry-level OutputFormatter is provided, use it
|
|
30
|
+
if (options?.formatter) {
|
|
31
|
+
let context;
|
|
32
|
+
if (options.formatter.fetch && options.sdk && options.params) {
|
|
33
|
+
for (const item of items) {
|
|
34
|
+
context = await options.formatter.fetch(options.sdk, options.params, item, context);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
items.forEach((item, index) => {
|
|
38
|
+
const formatted = options.formatter.format(item, context);
|
|
39
|
+
formatSingleItem(formatted, startingNumber + index);
|
|
40
|
+
});
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
28
43
|
// Get the output schema from function info or fall back to input schema output schema
|
|
29
44
|
const outputSchema = functionInfo.outputSchema || getOutputSchema(functionInfo.inputSchema);
|
|
30
45
|
if (!outputSchema) {
|
|
@@ -76,11 +91,38 @@ function formatSingleItem(formatted, itemNumber) {
|
|
|
76
91
|
}
|
|
77
92
|
// Format detail lines
|
|
78
93
|
for (const detail of formatted.details) {
|
|
79
|
-
|
|
80
|
-
|
|
94
|
+
if (detail.label) {
|
|
95
|
+
const isMultiline = detail.text.includes("\n");
|
|
96
|
+
if (isMultiline) {
|
|
97
|
+
console.log(` ${chalk.gray(detail.label + ":")}`);
|
|
98
|
+
const displayText = formatDetailText(detail.text, DETAIL_INDENT + " ");
|
|
99
|
+
const styledText = applyStyle(displayText, detail.style);
|
|
100
|
+
console.log(`${DETAIL_INDENT} ${styledText}`);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const styledValue = applyStyle(detail.text, detail.style);
|
|
104
|
+
console.log(` ${chalk.gray(detail.label + ":")} ${styledValue}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
const displayText = formatDetailText(detail.text, DETAIL_INDENT);
|
|
109
|
+
const styledText = applyStyle(displayText, detail.style);
|
|
110
|
+
console.log(` ${styledText}`);
|
|
111
|
+
}
|
|
81
112
|
}
|
|
82
113
|
console.log(); // Empty line between items
|
|
83
114
|
}
|
|
115
|
+
const DETAIL_INDENT = " ";
|
|
116
|
+
const DETAIL_MAX_LINES = 5;
|
|
117
|
+
function formatDetailText(text, indent = DETAIL_INDENT) {
|
|
118
|
+
const columns = Math.max((process.stdout.columns || 80) - indent.length, 40);
|
|
119
|
+
const wrapped = wrapAnsi(text, columns, { hard: true, trim: false });
|
|
120
|
+
const lines = wrapped.split("\n");
|
|
121
|
+
if (lines.length <= DETAIL_MAX_LINES) {
|
|
122
|
+
return lines.join("\n" + indent);
|
|
123
|
+
}
|
|
124
|
+
return (lines.slice(0, DETAIL_MAX_LINES).join("\n" + indent) + "\n" + indent + "…");
|
|
125
|
+
}
|
|
84
126
|
function applyStyle(value, style) {
|
|
85
127
|
switch (style) {
|
|
86
128
|
case "dim":
|