@zapier/zapier-sdk-cli 0.38.2 → 0.39.1
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 +21 -0
- package/README.md +128 -129
- package/dist/cli.cjs +88 -70
- package/dist/cli.mjs +89 -71
- package/dist/index.cjs +50 -50
- package/dist/index.d.mts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.mjs +50 -50
- package/dist/package.json +1 -1
- package/dist/src/generators/ast-generator.js +4 -8
- package/dist/src/plugins/add/index.js +12 -12
- package/dist/src/plugins/add/schemas.d.ts +2 -2
- package/dist/src/plugins/add/schemas.js +2 -2
- package/dist/src/plugins/buildManifest/index.js +7 -8
- package/dist/src/plugins/buildManifest/schemas.d.ts +6 -6
- package/dist/src/plugins/buildManifest/schemas.js +1 -1
- package/dist/src/plugins/curl/index.js +3 -2
- package/dist/src/plugins/curl/schemas.d.ts +1 -0
- package/dist/src/plugins/curl/schemas.js +6 -1
- package/dist/src/plugins/generateAppTypes/index.js +9 -9
- package/dist/src/plugins/generateAppTypes/schemas.d.ts +7 -7
- package/dist/src/plugins/generateAppTypes/schemas.js +2 -2
- package/dist/src/utils/cli-generator.d.ts +1 -1
- package/dist/src/utils/cli-generator.js +37 -13
- package/dist/src/utils/parameter-resolver.js +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -7,14 +7,14 @@ import { join, resolve } from "path";
|
|
|
7
7
|
import { detectTypesOutputDirectory } from "../../utils/directory-detection";
|
|
8
8
|
export const generateAppTypesPlugin = ({ sdk }) => {
|
|
9
9
|
const generateAppTypes = createFunction(async function generateAppTypes(options) {
|
|
10
|
-
const { appKeys, connectionIds, skipWrite = false, typesOutputDirectory = await detectTypesOutputDirectory(), onProgress, } = options;
|
|
10
|
+
const { apps: appKeys, connections: connectionIds, skipWrite = false, typesOutputDirectory = await detectTypesOutputDirectory(), onProgress, } = options;
|
|
11
11
|
const resolvedTypesOutput = resolve(typesOutputDirectory);
|
|
12
12
|
const result = {
|
|
13
13
|
typeDefinitions: {},
|
|
14
14
|
};
|
|
15
15
|
// Get apps using listApps (which respects existing manifest for version locking)
|
|
16
16
|
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
17
|
-
const appsIterable = sdk.listApps({ appKeys }).items();
|
|
17
|
+
const appsIterable = sdk.listApps({ apps: appKeys }).items();
|
|
18
18
|
const apps = [];
|
|
19
19
|
for await (const app of appsIterable) {
|
|
20
20
|
apps.push(app);
|
|
@@ -32,7 +32,7 @@ export const generateAppTypesPlugin = ({ sdk }) => {
|
|
|
32
32
|
count: connectionIds.length,
|
|
33
33
|
});
|
|
34
34
|
const connectionsIterable = sdk
|
|
35
|
-
.listConnections({ connectionIds })
|
|
35
|
+
.listConnections({ connections: connectionIds })
|
|
36
36
|
.items();
|
|
37
37
|
for await (const connection of connectionsIterable) {
|
|
38
38
|
connections.push(connection);
|
|
@@ -54,7 +54,7 @@ export const generateAppTypesPlugin = ({ sdk }) => {
|
|
|
54
54
|
for (const app of apps) {
|
|
55
55
|
onProgress?.({
|
|
56
56
|
type: "app_processing_start",
|
|
57
|
-
|
|
57
|
+
app: app.key,
|
|
58
58
|
slug: app.slug,
|
|
59
59
|
});
|
|
60
60
|
try {
|
|
@@ -62,7 +62,7 @@ export const generateAppTypesPlugin = ({ sdk }) => {
|
|
|
62
62
|
const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
|
|
63
63
|
onProgress?.({
|
|
64
64
|
type: "app_processing_error",
|
|
65
|
-
|
|
65
|
+
app: app.key,
|
|
66
66
|
error: errorMessage,
|
|
67
67
|
});
|
|
68
68
|
throw new ZapierValidationError(errorMessage, {
|
|
@@ -82,7 +82,7 @@ export const generateAppTypesPlugin = ({ sdk }) => {
|
|
|
82
82
|
connectionId = matchingConnection.id;
|
|
83
83
|
onProgress?.({
|
|
84
84
|
type: "connection_matched",
|
|
85
|
-
|
|
85
|
+
app: app.key,
|
|
86
86
|
connectionId: matchingConnection.id,
|
|
87
87
|
connectionTitle: matchingConnection.title || "",
|
|
88
88
|
});
|
|
@@ -90,7 +90,7 @@ export const generateAppTypesPlugin = ({ sdk }) => {
|
|
|
90
90
|
else {
|
|
91
91
|
onProgress?.({
|
|
92
92
|
type: "connection_not_matched",
|
|
93
|
-
|
|
93
|
+
app: app.key,
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -121,14 +121,14 @@ export const generateAppTypesPlugin = ({ sdk }) => {
|
|
|
121
121
|
}
|
|
122
122
|
onProgress?.({
|
|
123
123
|
type: "app_processing_complete",
|
|
124
|
-
|
|
124
|
+
app: app.key,
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
catch (error) {
|
|
128
128
|
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
129
129
|
onProgress?.({
|
|
130
130
|
type: "app_processing_error",
|
|
131
|
-
|
|
131
|
+
app: app.key,
|
|
132
132
|
error: errorMessage,
|
|
133
133
|
});
|
|
134
134
|
if (error instanceof ZapierValidationError) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { AppItem } from "@zapier/zapier-sdk";
|
|
3
3
|
export declare const GenerateAppTypesSchema: z.ZodObject<{
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
apps: z.ZodArray<z.ZodString>;
|
|
5
|
+
connections: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
6
|
skipWrite: z.ZodOptional<z.ZodBoolean>;
|
|
7
7
|
typesOutputDirectory: z.ZodOptional<z.ZodString>;
|
|
8
8
|
}, z.core.$strip>;
|
|
@@ -26,16 +26,16 @@ export type AppTypesProgressEvent = {
|
|
|
26
26
|
count: number;
|
|
27
27
|
} | {
|
|
28
28
|
type: "app_processing_start";
|
|
29
|
-
|
|
29
|
+
app: string;
|
|
30
30
|
slug?: string;
|
|
31
31
|
} | {
|
|
32
32
|
type: "connection_matched";
|
|
33
|
-
|
|
33
|
+
app: string;
|
|
34
34
|
connectionId: string;
|
|
35
35
|
connectionTitle: string;
|
|
36
36
|
} | {
|
|
37
37
|
type: "connection_not_matched";
|
|
38
|
-
|
|
38
|
+
app: string;
|
|
39
39
|
} | {
|
|
40
40
|
type: "type_generated";
|
|
41
41
|
manifestKey: string;
|
|
@@ -46,10 +46,10 @@ export type AppTypesProgressEvent = {
|
|
|
46
46
|
filePath: string;
|
|
47
47
|
} | {
|
|
48
48
|
type: "app_processing_complete";
|
|
49
|
-
|
|
49
|
+
app: string;
|
|
50
50
|
} | {
|
|
51
51
|
type: "app_processing_error";
|
|
52
|
-
|
|
52
|
+
app: string;
|
|
53
53
|
error: string;
|
|
54
54
|
};
|
|
55
55
|
export interface GenerateAppTypesResult {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export const GenerateAppTypesSchema = z
|
|
3
3
|
.object({
|
|
4
|
-
|
|
4
|
+
apps: z
|
|
5
5
|
.array(z.string().min(1, "App key cannot be empty"))
|
|
6
6
|
.min(1, "At least one app key is required")
|
|
7
7
|
.describe("One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"),
|
|
8
|
-
|
|
8
|
+
connections: z
|
|
9
9
|
.array(z.string())
|
|
10
10
|
.optional()
|
|
11
11
|
.describe("Connection IDs to use for type generation (e.g., ['123', '456'])"),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Command } from "commander";
|
|
2
2
|
import type { ZapierSdk } from "@zapier/zapier-sdk";
|
|
3
3
|
export declare function sanitizeCliArguments(args: string[]): string[];
|
|
4
4
|
export declare function generateCliCommands(program: Command, sdk: ZapierSdk): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Option } from "commander";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { isPositional } from "@zapier/zapier-sdk";
|
|
3
4
|
import { SchemaParameterResolver } from "./parameter-resolver";
|
|
@@ -164,15 +165,17 @@ function analyzeZodSchema(schema, functionInfo) {
|
|
|
164
165
|
return parameters;
|
|
165
166
|
}
|
|
166
167
|
function analyzeZodField(name, schema, functionInfo) {
|
|
167
|
-
// Filter out deprecated parameters
|
|
168
|
-
if (functionInfo?.deprecatedParameters?.includes(name)) {
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
168
|
let baseSchema = schema;
|
|
172
169
|
let required = true;
|
|
173
170
|
let defaultValue = undefined;
|
|
174
|
-
|
|
171
|
+
let isDeprecated = false;
|
|
172
|
+
// Unwrap optional, default, and nullable wrappers - keep unwrapping until we get to the base type.
|
|
173
|
+
// Check .meta()?.deprecated at each level since it doesn't propagate through wrappers.
|
|
175
174
|
while (true) {
|
|
175
|
+
const meta = baseSchema.meta?.();
|
|
176
|
+
if (meta?.deprecated) {
|
|
177
|
+
isDeprecated = true;
|
|
178
|
+
}
|
|
176
179
|
if (baseSchema instanceof z.ZodOptional) {
|
|
177
180
|
required = false;
|
|
178
181
|
baseSchema = baseSchema._zod.def.innerType;
|
|
@@ -247,6 +250,7 @@ function analyzeZodField(name, schema, functionInfo) {
|
|
|
247
250
|
hasResolver: paramHasResolver,
|
|
248
251
|
isPositional: isPositional(schema),
|
|
249
252
|
elementType,
|
|
253
|
+
hidden: isDeprecated,
|
|
250
254
|
};
|
|
251
255
|
}
|
|
252
256
|
/**
|
|
@@ -267,10 +271,6 @@ function analyzeInputParameters(inputParameters, functionInfo) {
|
|
|
267
271
|
// Flatten object properties into individual CLI flags
|
|
268
272
|
const shape = schema.shape;
|
|
269
273
|
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
270
|
-
// Skip deprecated parameters
|
|
271
|
-
if (functionInfo?.deprecatedParameters?.includes(key)) {
|
|
272
|
-
continue;
|
|
273
|
-
}
|
|
274
274
|
const analyzed = analyzeZodField(key, fieldSchema, functionInfo);
|
|
275
275
|
if (analyzed) {
|
|
276
276
|
if (isOptional) {
|
|
@@ -443,6 +443,16 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
|
|
|
443
443
|
hasUserSpecifiedMaxItems,
|
|
444
444
|
});
|
|
445
445
|
const rawParams = convertCliArgsToSdkParams(parameters, args.slice(0, -1), options);
|
|
446
|
+
// Remap aliased parameter names (e.g., authenticationId → connectionId)
|
|
447
|
+
const schemaAliases = schema?.meta?.()?.aliases;
|
|
448
|
+
if (schemaAliases) {
|
|
449
|
+
for (const [oldName, newName] of Object.entries(schemaAliases)) {
|
|
450
|
+
if (oldName in rawParams && !(newName in rawParams)) {
|
|
451
|
+
rawParams[newName] = rawParams[oldName];
|
|
452
|
+
delete rawParams[oldName];
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
446
456
|
if (schema && !usesInputParameters) {
|
|
447
457
|
const resolver = new SchemaParameterResolver();
|
|
448
458
|
resolvedParams = (await resolver.resolveParameters(schema, rawParams, sdk, functionInfo.name, {
|
|
@@ -557,7 +567,7 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
|
|
|
557
567
|
cli_arguments: sanitizeCliArguments(process.argv.slice(2)),
|
|
558
568
|
},
|
|
559
569
|
context: {
|
|
560
|
-
selected_api: resolvedParams.
|
|
570
|
+
selected_api: resolvedParams.app ?? null,
|
|
561
571
|
},
|
|
562
572
|
});
|
|
563
573
|
sdk
|
|
@@ -627,16 +637,30 @@ function addCommand(program, commandName, config) {
|
|
|
627
637
|
}
|
|
628
638
|
flags.push(`--${kebabName}`);
|
|
629
639
|
if (param.type === "boolean") {
|
|
630
|
-
|
|
640
|
+
const opt = new Option(flags.join(", "), param.description);
|
|
641
|
+
if (param.hidden)
|
|
642
|
+
opt.hideHelp();
|
|
643
|
+
command.addOption(opt);
|
|
631
644
|
}
|
|
632
645
|
else if (param.type === "array") {
|
|
633
646
|
// For arrays, use collect pattern for repeatable flags (e.g., -d foo -d bar)
|
|
634
647
|
const flagSignature = flags.join(", ") + ` <value>`;
|
|
635
|
-
|
|
648
|
+
const opt = new Option(flagSignature, param.description || "");
|
|
649
|
+
opt.default([]);
|
|
650
|
+
opt.argParser((value, previous) => (previous || []).concat([value]));
|
|
651
|
+
if (param.hidden)
|
|
652
|
+
opt.hideHelp();
|
|
653
|
+
command.addOption(opt);
|
|
636
654
|
}
|
|
637
655
|
else {
|
|
638
656
|
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
639
|
-
|
|
657
|
+
const opt = new Option(flagSignature, param.description || "");
|
|
658
|
+
if (param.default !== undefined) {
|
|
659
|
+
opt.default(param.default);
|
|
660
|
+
}
|
|
661
|
+
if (param.hidden)
|
|
662
|
+
opt.hideHelp();
|
|
663
|
+
command.addOption(opt);
|
|
640
664
|
}
|
|
641
665
|
}
|
|
642
666
|
});
|
|
@@ -709,11 +709,11 @@ export class SchemaParameterResolver {
|
|
|
709
709
|
: `Fetching choices for ${fieldMeta.title}`);
|
|
710
710
|
this.startSpinner();
|
|
711
711
|
const page = await context.sdk.listInputFieldChoices({
|
|
712
|
-
|
|
713
|
-
|
|
712
|
+
app: context.resolvedParams.app,
|
|
713
|
+
action: context.resolvedParams.action,
|
|
714
714
|
actionType: context.resolvedParams.actionType,
|
|
715
|
-
|
|
716
|
-
|
|
715
|
+
connection: context.resolvedParams.connection,
|
|
716
|
+
inputField: fieldMeta.key,
|
|
717
717
|
inputs,
|
|
718
718
|
...(cursor && { cursor }),
|
|
719
719
|
});
|