@zapier/zapier-sdk-cli 0.9.0 ā 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 +20 -0
- package/dist/cli.cjs +213 -100
- package/dist/cli.mjs +214 -101
- package/dist/index.cjs +15 -12
- package/dist/index.mjs +15 -12
- package/dist/package.json +1 -1
- package/dist/src/plugins/add/index.js +11 -13
- 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 +50 -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 +3 -3
- package/src/plugins/add/index.ts +15 -15
- package/src/utils/cli-generator-utils.ts +17 -5
- package/src/utils/cli-generator.ts +68 -79
- package/src/utils/parameter-resolver.ts +155 -21
- package/src/utils/schema-formatter.ts +68 -33
package/dist/index.mjs
CHANGED
|
@@ -1044,26 +1044,25 @@ var addPlugin = ({ sdk, context }) => {
|
|
|
1044
1044
|
console.log(`\u{1F510} Found ${authentications.length} authentication(s)`);
|
|
1045
1045
|
}
|
|
1046
1046
|
for (const app of apps) {
|
|
1047
|
-
|
|
1047
|
+
const appSlugAndKey = app.slug ? `${app.slug} (${app.key})` : app.key;
|
|
1048
|
+
console.log(`\u{1F4E6} Adding ${appSlugAndKey}...`);
|
|
1048
1049
|
try {
|
|
1049
|
-
|
|
1050
|
-
const [implementationName, version] = currentImplementationId.split("@");
|
|
1051
|
-
if (!implementationName || !version) {
|
|
1050
|
+
if (!app.version) {
|
|
1052
1051
|
console.warn(
|
|
1053
|
-
`\u26A0\uFE0F Invalid implementation ID format for '${
|
|
1052
|
+
`\u26A0\uFE0F Invalid implementation ID format for '${appSlugAndKey}': ${app.implementation_id}. Expected format: <implementationName>@<version>. Skipping...`
|
|
1054
1053
|
);
|
|
1055
1054
|
continue;
|
|
1056
1055
|
}
|
|
1057
1056
|
const [manifestKey] = await context.updateManifestEntry(
|
|
1058
1057
|
app.key,
|
|
1059
1058
|
{
|
|
1060
|
-
implementationName,
|
|
1061
|
-
version
|
|
1059
|
+
implementationName: app.key,
|
|
1060
|
+
version: app.version
|
|
1062
1061
|
},
|
|
1063
1062
|
configPath
|
|
1064
1063
|
);
|
|
1065
1064
|
console.log(
|
|
1066
|
-
`\u{1F4DD} Locked ${
|
|
1065
|
+
`\u{1F4DD} Locked ${appSlugAndKey} to ${app.key}@${app.version} using key '${manifestKey}'`
|
|
1067
1066
|
);
|
|
1068
1067
|
let authenticationId;
|
|
1069
1068
|
if (authentications.length > 0) {
|
|
@@ -1073,10 +1072,12 @@ var addPlugin = ({ sdk, context }) => {
|
|
|
1073
1072
|
if (matchingAuth) {
|
|
1074
1073
|
authenticationId = matchingAuth.id;
|
|
1075
1074
|
console.log(
|
|
1076
|
-
`\u{1F510} Using authentication ${authenticationId} (${matchingAuth.title}) for ${
|
|
1075
|
+
`\u{1F510} Using authentication ${authenticationId} (${matchingAuth.title}) for ${appSlugAndKey}`
|
|
1077
1076
|
);
|
|
1078
1077
|
} else {
|
|
1079
|
-
console.warn(
|
|
1078
|
+
console.warn(
|
|
1079
|
+
`\u26A0\uFE0F No matching authentication found for ${appSlugAndKey}`
|
|
1080
|
+
);
|
|
1080
1081
|
}
|
|
1081
1082
|
}
|
|
1082
1083
|
const typesPath = join(resolvedTypesOutput, `${manifestKey}.d.ts`);
|
|
@@ -1090,10 +1091,12 @@ var addPlugin = ({ sdk, context }) => {
|
|
|
1090
1091
|
await writeFile(typesPath, typeDefinitions, "utf8");
|
|
1091
1092
|
console.log(`\u{1F527} Generated types for ${manifestKey} at ${typesPath}`);
|
|
1092
1093
|
} catch (error) {
|
|
1093
|
-
console.warn(
|
|
1094
|
+
console.warn(
|
|
1095
|
+
`\u26A0\uFE0F Failed to generate types for ${appSlugAndKey}: ${error}`
|
|
1096
|
+
);
|
|
1094
1097
|
}
|
|
1095
1098
|
} catch (error) {
|
|
1096
|
-
console.warn(`\u26A0\uFE0F Failed to process ${
|
|
1099
|
+
console.warn(`\u26A0\uFE0F Failed to process ${appSlugAndKey}: ${error}`);
|
|
1097
1100
|
}
|
|
1098
1101
|
}
|
|
1099
1102
|
console.log(`\u2705 Added ${apps.length} app(s) to manifest`);
|
package/dist/package.json
CHANGED
|
@@ -53,21 +53,19 @@ export const addPlugin = ({ sdk, context }) => {
|
|
|
53
53
|
}
|
|
54
54
|
// Process each app
|
|
55
55
|
for (const app of apps) {
|
|
56
|
-
|
|
56
|
+
const appSlugAndKey = app.slug ? `${app.slug} (${app.key})` : app.key;
|
|
57
|
+
console.log(`š¦ Adding ${appSlugAndKey}...`);
|
|
57
58
|
try {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const [implementationName, version] = currentImplementationId.split("@");
|
|
61
|
-
if (!implementationName || !version) {
|
|
62
|
-
console.warn(`ā ļø Invalid implementation ID format for '${app.key}': ${currentImplementationId}. Expected format: <implementationName>@<version>. Skipping...`);
|
|
59
|
+
if (!app.version) {
|
|
60
|
+
console.warn(`ā ļø Invalid implementation ID format for '${appSlugAndKey}': ${app.implementation_id}. Expected format: <implementationName>@<version>. Skipping...`);
|
|
63
61
|
continue;
|
|
64
62
|
}
|
|
65
63
|
// Update manifest using manifest plugin's function
|
|
66
64
|
const [manifestKey] = await context.updateManifestEntry(app.key, {
|
|
67
|
-
implementationName,
|
|
68
|
-
version,
|
|
65
|
+
implementationName: app.key,
|
|
66
|
+
version: app.version,
|
|
69
67
|
}, configPath);
|
|
70
|
-
console.log(`š Locked ${
|
|
68
|
+
console.log(`š Locked ${appSlugAndKey} to ${app.key}@${app.version} using key '${manifestKey}'`);
|
|
71
69
|
// Find matching authentication for this app if authentications were provided
|
|
72
70
|
let authenticationId;
|
|
73
71
|
if (authentications.length > 0) {
|
|
@@ -77,10 +75,10 @@ export const addPlugin = ({ sdk, context }) => {
|
|
|
77
75
|
});
|
|
78
76
|
if (matchingAuth) {
|
|
79
77
|
authenticationId = matchingAuth.id;
|
|
80
|
-
console.log(`š Using authentication ${authenticationId} (${matchingAuth.title}) for ${
|
|
78
|
+
console.log(`š Using authentication ${authenticationId} (${matchingAuth.title}) for ${appSlugAndKey}`);
|
|
81
79
|
}
|
|
82
80
|
else {
|
|
83
|
-
console.warn(`ā ļø No matching authentication found for ${
|
|
81
|
+
console.warn(`ā ļø No matching authentication found for ${appSlugAndKey}`);
|
|
84
82
|
}
|
|
85
83
|
}
|
|
86
84
|
// Generate types using the manifest key for consistency
|
|
@@ -98,12 +96,12 @@ export const addPlugin = ({ sdk, context }) => {
|
|
|
98
96
|
console.log(`š§ Generated types for ${manifestKey} at ${typesPath}`);
|
|
99
97
|
}
|
|
100
98
|
catch (error) {
|
|
101
|
-
console.warn(`ā ļø Failed to generate types for ${
|
|
99
|
+
console.warn(`ā ļø Failed to generate types for ${appSlugAndKey}: ${error}`);
|
|
102
100
|
// Continue even if type generation fails
|
|
103
101
|
}
|
|
104
102
|
}
|
|
105
103
|
catch (error) {
|
|
106
|
-
console.warn(`ā ļø Failed to process ${
|
|
104
|
+
console.warn(`ā ļø Failed to process ${appSlugAndKey}: ${error}`);
|
|
107
105
|
}
|
|
108
106
|
}
|
|
109
107
|
console.log(`ā
Added ${apps.length} app(s) to manifest`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { type FunctionRegistryEntry } from "@zapier/zapier-sdk";
|
|
2
3
|
export interface CliParameter {
|
|
3
4
|
name: string;
|
|
4
5
|
type: "string" | "number" | "boolean" | "array";
|
|
@@ -9,5 +10,5 @@ export interface CliParameter {
|
|
|
9
10
|
hasResolver?: boolean;
|
|
10
11
|
isPositional?: boolean;
|
|
11
12
|
}
|
|
12
|
-
export declare function analyzeZodSchema(schema: z.ZodSchema): CliParameter[];
|
|
13
|
+
export declare function analyzeZodSchema(schema: z.ZodSchema, functionInfo?: FunctionRegistryEntry): CliParameter[];
|
|
13
14
|
export declare function convertCliArgsToSdkParams(parameters: CliParameter[], positionalArgs: unknown[], options: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { isPositional } from "@zapier/zapier-sdk";
|
|
3
3
|
// ============================================================================
|
|
4
4
|
// Schema Analysis
|
|
5
5
|
// ============================================================================
|
|
6
|
-
export function analyzeZodSchema(schema) {
|
|
6
|
+
export function analyzeZodSchema(schema, functionInfo) {
|
|
7
7
|
const parameters = [];
|
|
8
8
|
if (schema instanceof z.ZodObject) {
|
|
9
9
|
const shape = schema.shape;
|
|
10
10
|
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
11
|
-
const param = analyzeZodField(key, fieldSchema);
|
|
11
|
+
const param = analyzeZodField(key, fieldSchema, functionInfo);
|
|
12
12
|
if (param) {
|
|
13
13
|
parameters.push(param);
|
|
14
14
|
}
|
|
@@ -16,7 +16,7 @@ export function analyzeZodSchema(schema) {
|
|
|
16
16
|
}
|
|
17
17
|
return parameters;
|
|
18
18
|
}
|
|
19
|
-
function analyzeZodField(name, schema) {
|
|
19
|
+
function analyzeZodField(name, schema, functionInfo) {
|
|
20
20
|
let baseSchema = schema;
|
|
21
21
|
let required = true;
|
|
22
22
|
let defaultValue = undefined;
|
|
@@ -53,6 +53,12 @@ function analyzeZodField(name, schema) {
|
|
|
53
53
|
// Handle Record<string, any> as JSON string input
|
|
54
54
|
paramType = "string";
|
|
55
55
|
}
|
|
56
|
+
// Check if this parameter has a resolver
|
|
57
|
+
let paramHasResolver = false;
|
|
58
|
+
// Check function-specific resolvers first
|
|
59
|
+
if (functionInfo?.resolvers?.[name]) {
|
|
60
|
+
paramHasResolver = true;
|
|
61
|
+
}
|
|
56
62
|
// Extract resolver metadata
|
|
57
63
|
return {
|
|
58
64
|
name,
|
|
@@ -61,7 +67,7 @@ function analyzeZodField(name, schema) {
|
|
|
61
67
|
description: schema.description,
|
|
62
68
|
default: defaultValue,
|
|
63
69
|
choices,
|
|
64
|
-
hasResolver:
|
|
70
|
+
hasResolver: paramHasResolver,
|
|
65
71
|
isPositional: isPositional(schema),
|
|
66
72
|
};
|
|
67
73
|
}
|
|
@@ -1,34 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { isPositional, formatErrorMessage, ZapierError, } from "@zapier/zapier-sdk";
|
|
3
3
|
import { SchemaParameterResolver } from "./parameter-resolver";
|
|
4
|
-
import { formatItemsFromSchema } from "./schema-formatter";
|
|
4
|
+
import { formatItemsFromSchema, formatJsonOutput } from "./schema-formatter";
|
|
5
5
|
import chalk from "chalk";
|
|
6
|
-
import util from "util";
|
|
7
6
|
import inquirer from "inquirer";
|
|
8
7
|
// ============================================================================
|
|
9
|
-
// JSON Formatting
|
|
10
|
-
// ============================================================================
|
|
11
|
-
function formatJsonOutput(data) {
|
|
12
|
-
// Don't print anything for undefined results (commands that just perform actions)
|
|
13
|
-
if (data === undefined) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
// Show success message for action results
|
|
17
|
-
if (data &&
|
|
18
|
-
typeof data === "object" &&
|
|
19
|
-
!Array.isArray(data) &&
|
|
20
|
-
(data.success !== undefined ||
|
|
21
|
-
data.id ||
|
|
22
|
-
data.status)) {
|
|
23
|
-
console.log(chalk.green("ā
Action completed successfully!\n"));
|
|
24
|
-
}
|
|
25
|
-
// Use util.inspect for colored output
|
|
26
|
-
console.log(util.inspect(data, { colors: true, depth: null, breakLength: 80 }));
|
|
27
|
-
}
|
|
28
|
-
// ============================================================================
|
|
29
8
|
// Schema Analysis
|
|
30
9
|
// ============================================================================
|
|
31
|
-
function analyzeZodSchema(schema) {
|
|
10
|
+
function analyzeZodSchema(schema, functionInfo) {
|
|
32
11
|
const parameters = [];
|
|
33
12
|
// Handle ZodEffects (schemas with .refine(), .transform(), etc.)
|
|
34
13
|
if (schema._def &&
|
|
@@ -37,12 +16,12 @@ function analyzeZodSchema(schema) {
|
|
|
37
16
|
// Get the underlying schema
|
|
38
17
|
const innerSchema = schema
|
|
39
18
|
._def.schema;
|
|
40
|
-
return analyzeZodSchema(innerSchema);
|
|
19
|
+
return analyzeZodSchema(innerSchema, functionInfo);
|
|
41
20
|
}
|
|
42
21
|
if (schema instanceof z.ZodObject) {
|
|
43
22
|
const shape = schema.shape;
|
|
44
23
|
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
45
|
-
const param = analyzeZodField(key, fieldSchema);
|
|
24
|
+
const param = analyzeZodField(key, fieldSchema, functionInfo);
|
|
46
25
|
if (param) {
|
|
47
26
|
parameters.push(param);
|
|
48
27
|
}
|
|
@@ -50,7 +29,7 @@ function analyzeZodSchema(schema) {
|
|
|
50
29
|
}
|
|
51
30
|
return parameters;
|
|
52
31
|
}
|
|
53
|
-
function analyzeZodField(name, schema) {
|
|
32
|
+
function analyzeZodField(name, schema, functionInfo) {
|
|
54
33
|
let baseSchema = schema;
|
|
55
34
|
let required = true;
|
|
56
35
|
let defaultValue = undefined;
|
|
@@ -98,6 +77,12 @@ function analyzeZodField(name, schema) {
|
|
|
98
77
|
// Handle Record<string, any> as JSON string input
|
|
99
78
|
paramType = "string";
|
|
100
79
|
}
|
|
80
|
+
// Check if this parameter has a resolver
|
|
81
|
+
let paramHasResolver = false;
|
|
82
|
+
// Check function-specific resolvers first
|
|
83
|
+
if (functionInfo?.resolvers?.[name]) {
|
|
84
|
+
paramHasResolver = true;
|
|
85
|
+
}
|
|
101
86
|
// Extract resolver metadata
|
|
102
87
|
return {
|
|
103
88
|
name,
|
|
@@ -106,7 +91,7 @@ function analyzeZodField(name, schema) {
|
|
|
106
91
|
description: schema.description,
|
|
107
92
|
default: defaultValue,
|
|
108
93
|
choices,
|
|
109
|
-
hasResolver:
|
|
94
|
+
hasResolver: paramHasResolver,
|
|
110
95
|
isPositional: isPositional(schema),
|
|
111
96
|
};
|
|
112
97
|
}
|
|
@@ -145,7 +130,7 @@ export function generateCliCommands(program, sdk) {
|
|
|
145
130
|
}
|
|
146
131
|
// Convert methodName to kebab-case CLI command
|
|
147
132
|
const cliCommandName = methodNameToCliCommand(fnInfo.name);
|
|
148
|
-
const config = createCommandConfig(cliCommandName, fnInfo
|
|
133
|
+
const config = createCommandConfig(cliCommandName, fnInfo, sdk);
|
|
149
134
|
addCommand(program, cliCommandName, config);
|
|
150
135
|
});
|
|
151
136
|
// Override the help display to show commands grouped by category
|
|
@@ -200,8 +185,9 @@ export function generateCliCommands(program, sdk) {
|
|
|
200
185
|
},
|
|
201
186
|
});
|
|
202
187
|
}
|
|
203
|
-
function createCommandConfig(cliCommandName,
|
|
204
|
-
const
|
|
188
|
+
function createCommandConfig(cliCommandName, functionInfo, sdk) {
|
|
189
|
+
const schema = functionInfo.inputSchema;
|
|
190
|
+
const parameters = analyzeZodSchema(schema, functionInfo);
|
|
205
191
|
const description = schema.description || `${cliCommandName} command`;
|
|
206
192
|
const handler = async (...args) => {
|
|
207
193
|
try {
|
|
@@ -209,7 +195,7 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk) {
|
|
|
209
195
|
const commandObj = args[args.length - 1];
|
|
210
196
|
const options = commandObj.opts();
|
|
211
197
|
// Check if this is a list command for pagination
|
|
212
|
-
const isListCommand =
|
|
198
|
+
const isListCommand = functionInfo.type === "list";
|
|
213
199
|
const hasPaginationParams = parameters.some((p) => p.name === "maxItems" || p.name === "pageSize");
|
|
214
200
|
const hasUserSpecifiedMaxItems = "maxItems" in options && options.maxItems !== undefined;
|
|
215
201
|
const shouldUseJson = options.json;
|
|
@@ -217,7 +203,7 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk) {
|
|
|
217
203
|
const rawParams = convertCliArgsToSdkParams(parameters, args.slice(0, -1), options);
|
|
218
204
|
// Resolve missing parameters interactively using schema metadata
|
|
219
205
|
const resolver = new SchemaParameterResolver();
|
|
220
|
-
const resolvedParams = await resolver.resolveParameters(schema, rawParams, sdk);
|
|
206
|
+
const resolvedParams = await resolver.resolveParameters(schema, rawParams, sdk, functionInfo.name);
|
|
221
207
|
// Handle paginated list commands with async iteration
|
|
222
208
|
if (isListCommand &&
|
|
223
209
|
hasPaginationParams &&
|
|
@@ -225,8 +211,8 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk) {
|
|
|
225
211
|
!hasUserSpecifiedMaxItems) {
|
|
226
212
|
// Get the async iterable directly from the SDK method call (don't await it! that breaks the next page behavior)
|
|
227
213
|
const sdkObj = sdk;
|
|
228
|
-
const sdkIterator = sdkObj[
|
|
229
|
-
await handlePaginatedListWithAsyncIteration(
|
|
214
|
+
const sdkIterator = sdkObj[functionInfo.name](resolvedParams);
|
|
215
|
+
await handlePaginatedListWithAsyncIteration(functionInfo.name, sdkIterator, functionInfo);
|
|
230
216
|
}
|
|
231
217
|
else {
|
|
232
218
|
// Special handling for commands that write to files
|
|
@@ -234,14 +220,14 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk) {
|
|
|
234
220
|
if (hasOutputFile) {
|
|
235
221
|
// Call the SDK method for file output commands
|
|
236
222
|
const sdkObj = sdk;
|
|
237
|
-
await sdkObj[
|
|
223
|
+
await sdkObj[functionInfo.name](resolvedParams);
|
|
238
224
|
console.log(chalk.green(`ā
${cliCommandName} completed successfully!`));
|
|
239
225
|
console.log(chalk.gray(`Output written to: ${hasOutputFile}`));
|
|
240
226
|
return;
|
|
241
227
|
}
|
|
242
228
|
// Call the SDK method and handle non-paginated results
|
|
243
229
|
const sdkObj = sdk;
|
|
244
|
-
const result = await sdkObj[
|
|
230
|
+
const result = await sdkObj[functionInfo.name](resolvedParams);
|
|
245
231
|
const items = result?.data
|
|
246
232
|
? result.data
|
|
247
233
|
: result;
|
|
@@ -249,7 +235,7 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk) {
|
|
|
249
235
|
console.log(JSON.stringify(items, null, 2));
|
|
250
236
|
}
|
|
251
237
|
else if (isListCommand) {
|
|
252
|
-
formatNonPaginatedResults(items, resolvedParams.maxItems, hasUserSpecifiedMaxItems, shouldUseJson,
|
|
238
|
+
formatNonPaginatedResults(items, resolvedParams.maxItems, hasUserSpecifiedMaxItems, shouldUseJson, functionInfo);
|
|
253
239
|
}
|
|
254
240
|
else {
|
|
255
241
|
formatJsonOutput(items);
|
|
@@ -373,6 +359,10 @@ function convertCliArgsToSdkParams(parameters, positionalArgs, options) {
|
|
|
373
359
|
return sdkParams;
|
|
374
360
|
}
|
|
375
361
|
function convertValue(value, type) {
|
|
362
|
+
// Don't convert undefined values - let the resolver system handle them
|
|
363
|
+
if (value === undefined) {
|
|
364
|
+
return undefined;
|
|
365
|
+
}
|
|
376
366
|
switch (type) {
|
|
377
367
|
case "number":
|
|
378
368
|
return Number(value);
|
|
@@ -398,11 +388,11 @@ function convertValue(value, type) {
|
|
|
398
388
|
// ============================================================================
|
|
399
389
|
// Pagination Handlers
|
|
400
390
|
// ============================================================================
|
|
401
|
-
async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult,
|
|
402
|
-
const itemName = getItemNameFromMethod(
|
|
391
|
+
async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, functionInfo) {
|
|
392
|
+
const itemName = getItemNameFromMethod(functionInfo);
|
|
403
393
|
let totalShown = 0;
|
|
404
394
|
let pageCount = 0;
|
|
405
|
-
console.log(chalk.blue(`š ${getListTitleFromMethod(sdkMethodName)}\n`));
|
|
395
|
+
console.log(chalk.blue(`š ${getListTitleFromMethod(sdkMethodName, functionInfo)}\n`));
|
|
406
396
|
try {
|
|
407
397
|
// Use async iteration to go through pages
|
|
408
398
|
for await (const page of sdkResult) {
|
|
@@ -422,11 +412,11 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
|
|
|
422
412
|
// Clear screen for subsequent pages (not the first)
|
|
423
413
|
if (pageCount > 1) {
|
|
424
414
|
console.clear();
|
|
425
|
-
console.log(chalk.blue(`š ${getListTitleFromMethod(sdkMethodName)}\n`));
|
|
415
|
+
console.log(chalk.blue(`š ${getListTitleFromMethod(sdkMethodName, functionInfo)}\n`));
|
|
426
416
|
}
|
|
427
|
-
// Format and display items using
|
|
428
|
-
if (
|
|
429
|
-
formatItemsFromSchema(
|
|
417
|
+
// Format and display items using function info
|
|
418
|
+
if (functionInfo) {
|
|
419
|
+
formatItemsFromSchema(functionInfo, items, totalShown);
|
|
430
420
|
}
|
|
431
421
|
else {
|
|
432
422
|
formatItemsGeneric(items, totalShown);
|
|
@@ -462,8 +452,8 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
|
|
|
462
452
|
console.log(chalk.yellow(`No ${itemName} found.`));
|
|
463
453
|
return;
|
|
464
454
|
}
|
|
465
|
-
if (
|
|
466
|
-
formatItemsFromSchema(
|
|
455
|
+
if (functionInfo) {
|
|
456
|
+
formatItemsFromSchema(functionInfo, items, 0);
|
|
467
457
|
}
|
|
468
458
|
else {
|
|
469
459
|
formatItemsGeneric(items, 0);
|
|
@@ -475,7 +465,7 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
|
|
|
475
465
|
}
|
|
476
466
|
}
|
|
477
467
|
}
|
|
478
|
-
function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxItems, useRawJson,
|
|
468
|
+
function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxItems, useRawJson, functionInfo) {
|
|
479
469
|
if (!Array.isArray(result)) {
|
|
480
470
|
if (useRawJson) {
|
|
481
471
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -489,15 +479,15 @@ function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxIt
|
|
|
489
479
|
console.log(JSON.stringify(result, null, 2));
|
|
490
480
|
return;
|
|
491
481
|
}
|
|
492
|
-
const itemName =
|
|
482
|
+
const itemName = functionInfo ? getItemNameFromMethod(functionInfo) : "items";
|
|
493
483
|
if (result.length === 0) {
|
|
494
484
|
console.log(chalk.yellow(`No ${itemName} found.`));
|
|
495
485
|
return;
|
|
496
486
|
}
|
|
497
487
|
console.log(chalk.green(`\nā
Found ${result.length} ${itemName}:\n`));
|
|
498
|
-
// Use
|
|
499
|
-
if (
|
|
500
|
-
formatItemsFromSchema(
|
|
488
|
+
// Use function info for formatting
|
|
489
|
+
if (functionInfo) {
|
|
490
|
+
formatItemsFromSchema(functionInfo, result);
|
|
501
491
|
}
|
|
502
492
|
else {
|
|
503
493
|
// Fallback to generic formatting
|
|
@@ -524,20 +514,15 @@ function formatItemsGeneric(items, startingNumber = 0) {
|
|
|
524
514
|
});
|
|
525
515
|
}
|
|
526
516
|
// Generic helper functions that infer from schema description or method name
|
|
527
|
-
function getItemNameFromMethod(
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
if (listMatch) {
|
|
531
|
-
return listMatch[1].toLowerCase();
|
|
517
|
+
function getItemNameFromMethod(functionInfo) {
|
|
518
|
+
if (functionInfo.itemType) {
|
|
519
|
+
return `${functionInfo.itemType} items`;
|
|
532
520
|
}
|
|
533
|
-
// Fallback to generic
|
|
534
521
|
return "items";
|
|
535
522
|
}
|
|
536
|
-
function getListTitleFromMethod(methodName) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
const capitalized = itemName.charAt(0).toUpperCase() + itemName.slice(1);
|
|
542
|
-
return `Available ${capitalized}`;
|
|
523
|
+
function getListTitleFromMethod(methodName, functionInfo) {
|
|
524
|
+
if (functionInfo.itemType) {
|
|
525
|
+
return `Available ${functionInfo.itemType} items`;
|
|
526
|
+
}
|
|
527
|
+
return `${methodName} items`;
|
|
543
528
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { ZapierSdk } from "@zapier/zapier-sdk";
|
|
3
3
|
export declare class SchemaParameterResolver {
|
|
4
|
-
resolveParameters(schema: z.ZodSchema, providedParams: unknown, sdk: ZapierSdk): Promise<unknown>;
|
|
4
|
+
resolveParameters(schema: z.ZodSchema, providedParams: unknown, sdk: ZapierSdk, functionName?: string): Promise<unknown>;
|
|
5
5
|
private extractParametersFromSchema;
|
|
6
6
|
private analyzeFieldSchema;
|
|
7
7
|
private createResolvableParameter;
|
|
@@ -11,4 +11,7 @@ export declare class SchemaParameterResolver {
|
|
|
11
11
|
private setNestedValue;
|
|
12
12
|
private promptForField;
|
|
13
13
|
private isUserCancellation;
|
|
14
|
+
private hasResolver;
|
|
15
|
+
private getResolver;
|
|
16
|
+
private getLocalResolvers;
|
|
14
17
|
}
|