@zapier/zapier-sdk-cli 0.15.14 → 0.16.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 +23 -0
- package/dist/cli.cjs +36 -16
- package/dist/cli.mjs +36 -16
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +5 -23
- package/dist/index.d.ts +5 -23
- package/dist/index.mjs +1 -1
- package/dist/package.json +2 -2
- package/dist/src/plugins/add/schemas.d.ts +3 -13
- package/dist/src/plugins/buildManifest/schemas.d.ts +2 -10
- package/dist/src/plugins/bundleCode/schemas.d.ts +1 -15
- package/dist/src/plugins/generateAppTypes/schemas.d.ts +3 -13
- package/dist/src/plugins/getLoginConfigPath/schemas.d.ts +1 -1
- package/dist/src/plugins/login/schemas.d.ts +1 -5
- package/dist/src/plugins/logout/schemas.d.ts +1 -1
- package/dist/src/plugins/mcp/schemas.d.ts +1 -5
- package/dist/src/utils/cli-generator-utils.js +4 -4
- package/dist/src/utils/cli-generator.js +37 -19
- package/dist/src/utils/parameter-resolver.js +2 -2
- package/dist/src/utils/schema-formatter.js +4 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/utils/cli-generator-utils.ts +4 -4
- package/src/utils/cli-generator.test.ts +152 -0
- package/src/utils/cli-generator.ts +49 -27
- package/src/utils/parameter-resolver.ts +2 -2
- package/src/utils/schema-formatter.ts +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @zapier/zapier-sdk-cli
|
|
2
2
|
|
|
3
|
+
## 0.16.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e80d094: Fix CLI to extract JSON body from Response objects instead of showing raw Response representation. Adds error handling for invalid JSON responses with helpful error messages.
|
|
8
|
+
|
|
9
|
+
## 0.16.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 24ae4f0: Upgrade to Zod 4
|
|
14
|
+
- Update all packages to use Zod 4
|
|
15
|
+
- Migrate internal API access from `_def` to `_zod.def`
|
|
16
|
+
- Update `z.record()` calls to include explicit key types
|
|
17
|
+
- Fix schema introspection for documentation generation and CLI
|
|
18
|
+
- Update MCP schema converter for Zod 4 structure
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [24ae4f0]
|
|
23
|
+
- @zapier/zapier-sdk-mcp@0.4.0
|
|
24
|
+
- @zapier/zapier-sdk@0.16.0
|
|
25
|
+
|
|
3
26
|
## 0.15.14
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/cli.cjs
CHANGED
|
@@ -293,11 +293,11 @@ var SchemaParameterResolver = class {
|
|
|
293
293
|
let isRequired = true;
|
|
294
294
|
if (baseSchema instanceof zod.z.ZodOptional) {
|
|
295
295
|
isRequired = false;
|
|
296
|
-
baseSchema = baseSchema.
|
|
296
|
+
baseSchema = baseSchema._zod.def.innerType;
|
|
297
297
|
}
|
|
298
298
|
if (baseSchema instanceof zod.z.ZodDefault) {
|
|
299
299
|
isRequired = false;
|
|
300
|
-
baseSchema = baseSchema.
|
|
300
|
+
baseSchema = baseSchema._zod.def.innerType;
|
|
301
301
|
}
|
|
302
302
|
return this.createResolvableParameter([fieldName], baseSchema, isRequired);
|
|
303
303
|
}
|
|
@@ -786,10 +786,10 @@ Optional fields${pathContext}:`));
|
|
|
786
786
|
}
|
|
787
787
|
};
|
|
788
788
|
function getFormatMetadata(schema) {
|
|
789
|
-
return schema?.
|
|
789
|
+
return schema?._zod?.def?.formatMeta;
|
|
790
790
|
}
|
|
791
791
|
function getOutputSchema(schema) {
|
|
792
|
-
return schema?.
|
|
792
|
+
return schema?._zod?.def?.outputSchema;
|
|
793
793
|
}
|
|
794
794
|
function formatJsonOutput(data) {
|
|
795
795
|
if (data === void 0) {
|
|
@@ -878,9 +878,9 @@ function formatItemsGeneric(items, startingNumber = 0) {
|
|
|
878
878
|
}
|
|
879
879
|
function analyzeZodSchema(schema, functionInfo) {
|
|
880
880
|
const parameters = [];
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
return analyzeZodSchema(
|
|
881
|
+
const schemaDef = schema._zod?.def;
|
|
882
|
+
if (schemaDef?.type === "effect" && schemaDef.innerType) {
|
|
883
|
+
return analyzeZodSchema(schemaDef.innerType, functionInfo);
|
|
884
884
|
}
|
|
885
885
|
if (schema instanceof zod.z.ZodObject) {
|
|
886
886
|
const shape = schema.shape;
|
|
@@ -904,14 +904,17 @@ function analyzeZodField(name, schema, functionInfo) {
|
|
|
904
904
|
while (true) {
|
|
905
905
|
if (baseSchema instanceof zod.z.ZodOptional) {
|
|
906
906
|
required = false;
|
|
907
|
-
baseSchema = baseSchema.
|
|
907
|
+
baseSchema = baseSchema._zod.def.innerType;
|
|
908
908
|
} else if (baseSchema instanceof zod.z.ZodDefault) {
|
|
909
909
|
required = false;
|
|
910
|
-
defaultValue = baseSchema.
|
|
911
|
-
baseSchema = baseSchema.
|
|
912
|
-
} else if (baseSchema._def && baseSchema._def.typeName === "ZodNullable") {
|
|
913
|
-
baseSchema = baseSchema._def.innerType;
|
|
910
|
+
defaultValue = baseSchema._zod.def.defaultValue();
|
|
911
|
+
baseSchema = baseSchema._zod.def.innerType;
|
|
914
912
|
} else {
|
|
913
|
+
const zodDef = baseSchema._zod?.def;
|
|
914
|
+
if (zodDef?.typeName === "ZodNullable" && zodDef.innerType) {
|
|
915
|
+
baseSchema = zodDef.innerType;
|
|
916
|
+
continue;
|
|
917
|
+
}
|
|
915
918
|
break;
|
|
916
919
|
}
|
|
917
920
|
}
|
|
@@ -927,7 +930,7 @@ function analyzeZodField(name, schema, functionInfo) {
|
|
|
927
930
|
paramType = "array";
|
|
928
931
|
} else if (baseSchema instanceof zod.z.ZodEnum) {
|
|
929
932
|
paramType = "string";
|
|
930
|
-
choices = baseSchema.
|
|
933
|
+
choices = baseSchema.options;
|
|
931
934
|
} else if (baseSchema instanceof zod.z.ZodRecord) {
|
|
932
935
|
paramType = "string";
|
|
933
936
|
}
|
|
@@ -1074,7 +1077,24 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
|
|
|
1074
1077
|
return;
|
|
1075
1078
|
}
|
|
1076
1079
|
const sdkObj = sdk2;
|
|
1077
|
-
|
|
1080
|
+
let result = await sdkObj[functionInfo.name](resolvedParams);
|
|
1081
|
+
if (result instanceof Response) {
|
|
1082
|
+
const response = result;
|
|
1083
|
+
let body;
|
|
1084
|
+
try {
|
|
1085
|
+
body = await response.json();
|
|
1086
|
+
} catch {
|
|
1087
|
+
const text = response.bodyUsed ? "[body already consumed]" : await response.text().catch(() => "[unable to read body]");
|
|
1088
|
+
throw new Error(
|
|
1089
|
+
`Failed to parse response as JSON (status: ${response.status}). Body: ${text.slice(0, 200)}`
|
|
1090
|
+
);
|
|
1091
|
+
}
|
|
1092
|
+
result = {
|
|
1093
|
+
statusCode: response.status,
|
|
1094
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
1095
|
+
body
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1078
1098
|
const items = result?.data ? result.data : result;
|
|
1079
1099
|
if (shouldUseJson) {
|
|
1080
1100
|
console.log(JSON.stringify(items, null, 2));
|
|
@@ -1625,7 +1645,7 @@ var LoginSchema = zod.z.object({
|
|
|
1625
1645
|
|
|
1626
1646
|
// package.json
|
|
1627
1647
|
var package_default = {
|
|
1628
|
-
version: "0.
|
|
1648
|
+
version: "0.16.1"};
|
|
1629
1649
|
|
|
1630
1650
|
// src/telemetry/builders.ts
|
|
1631
1651
|
function createCliBaseEvent(context = {}) {
|
|
@@ -2904,7 +2924,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
2904
2924
|
// package.json with { type: 'json' }
|
|
2905
2925
|
var package_default2 = {
|
|
2906
2926
|
name: "@zapier/zapier-sdk-cli",
|
|
2907
|
-
version: "0.
|
|
2927
|
+
version: "0.16.1"};
|
|
2908
2928
|
function detectPackageManager(cwd = process.cwd()) {
|
|
2909
2929
|
const ua = process.env.npm_config_user_agent;
|
|
2910
2930
|
if (ua) {
|
package/dist/cli.mjs
CHANGED
|
@@ -257,11 +257,11 @@ var SchemaParameterResolver = class {
|
|
|
257
257
|
let isRequired = true;
|
|
258
258
|
if (baseSchema instanceof z.ZodOptional) {
|
|
259
259
|
isRequired = false;
|
|
260
|
-
baseSchema = baseSchema.
|
|
260
|
+
baseSchema = baseSchema._zod.def.innerType;
|
|
261
261
|
}
|
|
262
262
|
if (baseSchema instanceof z.ZodDefault) {
|
|
263
263
|
isRequired = false;
|
|
264
|
-
baseSchema = baseSchema.
|
|
264
|
+
baseSchema = baseSchema._zod.def.innerType;
|
|
265
265
|
}
|
|
266
266
|
return this.createResolvableParameter([fieldName], baseSchema, isRequired);
|
|
267
267
|
}
|
|
@@ -750,10 +750,10 @@ Optional fields${pathContext}:`));
|
|
|
750
750
|
}
|
|
751
751
|
};
|
|
752
752
|
function getFormatMetadata(schema) {
|
|
753
|
-
return schema?.
|
|
753
|
+
return schema?._zod?.def?.formatMeta;
|
|
754
754
|
}
|
|
755
755
|
function getOutputSchema(schema) {
|
|
756
|
-
return schema?.
|
|
756
|
+
return schema?._zod?.def?.outputSchema;
|
|
757
757
|
}
|
|
758
758
|
function formatJsonOutput(data) {
|
|
759
759
|
if (data === void 0) {
|
|
@@ -842,9 +842,9 @@ function formatItemsGeneric(items, startingNumber = 0) {
|
|
|
842
842
|
}
|
|
843
843
|
function analyzeZodSchema(schema, functionInfo) {
|
|
844
844
|
const parameters = [];
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
return analyzeZodSchema(
|
|
845
|
+
const schemaDef = schema._zod?.def;
|
|
846
|
+
if (schemaDef?.type === "effect" && schemaDef.innerType) {
|
|
847
|
+
return analyzeZodSchema(schemaDef.innerType, functionInfo);
|
|
848
848
|
}
|
|
849
849
|
if (schema instanceof z.ZodObject) {
|
|
850
850
|
const shape = schema.shape;
|
|
@@ -868,14 +868,17 @@ function analyzeZodField(name, schema, functionInfo) {
|
|
|
868
868
|
while (true) {
|
|
869
869
|
if (baseSchema instanceof z.ZodOptional) {
|
|
870
870
|
required = false;
|
|
871
|
-
baseSchema = baseSchema.
|
|
871
|
+
baseSchema = baseSchema._zod.def.innerType;
|
|
872
872
|
} else if (baseSchema instanceof z.ZodDefault) {
|
|
873
873
|
required = false;
|
|
874
|
-
defaultValue = baseSchema.
|
|
875
|
-
baseSchema = baseSchema.
|
|
876
|
-
} else if (baseSchema._def && baseSchema._def.typeName === "ZodNullable") {
|
|
877
|
-
baseSchema = baseSchema._def.innerType;
|
|
874
|
+
defaultValue = baseSchema._zod.def.defaultValue();
|
|
875
|
+
baseSchema = baseSchema._zod.def.innerType;
|
|
878
876
|
} else {
|
|
877
|
+
const zodDef = baseSchema._zod?.def;
|
|
878
|
+
if (zodDef?.typeName === "ZodNullable" && zodDef.innerType) {
|
|
879
|
+
baseSchema = zodDef.innerType;
|
|
880
|
+
continue;
|
|
881
|
+
}
|
|
879
882
|
break;
|
|
880
883
|
}
|
|
881
884
|
}
|
|
@@ -891,7 +894,7 @@ function analyzeZodField(name, schema, functionInfo) {
|
|
|
891
894
|
paramType = "array";
|
|
892
895
|
} else if (baseSchema instanceof z.ZodEnum) {
|
|
893
896
|
paramType = "string";
|
|
894
|
-
choices = baseSchema.
|
|
897
|
+
choices = baseSchema.options;
|
|
895
898
|
} else if (baseSchema instanceof z.ZodRecord) {
|
|
896
899
|
paramType = "string";
|
|
897
900
|
}
|
|
@@ -1038,7 +1041,24 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
|
|
|
1038
1041
|
return;
|
|
1039
1042
|
}
|
|
1040
1043
|
const sdkObj = sdk2;
|
|
1041
|
-
|
|
1044
|
+
let result = await sdkObj[functionInfo.name](resolvedParams);
|
|
1045
|
+
if (result instanceof Response) {
|
|
1046
|
+
const response = result;
|
|
1047
|
+
let body;
|
|
1048
|
+
try {
|
|
1049
|
+
body = await response.json();
|
|
1050
|
+
} catch {
|
|
1051
|
+
const text = response.bodyUsed ? "[body already consumed]" : await response.text().catch(() => "[unable to read body]");
|
|
1052
|
+
throw new Error(
|
|
1053
|
+
`Failed to parse response as JSON (status: ${response.status}). Body: ${text.slice(0, 200)}`
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
result = {
|
|
1057
|
+
statusCode: response.status,
|
|
1058
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
1059
|
+
body
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1042
1062
|
const items = result?.data ? result.data : result;
|
|
1043
1063
|
if (shouldUseJson) {
|
|
1044
1064
|
console.log(JSON.stringify(items, null, 2));
|
|
@@ -1589,7 +1609,7 @@ var LoginSchema = z.object({
|
|
|
1589
1609
|
|
|
1590
1610
|
// package.json
|
|
1591
1611
|
var package_default = {
|
|
1592
|
-
version: "0.
|
|
1612
|
+
version: "0.16.1"};
|
|
1593
1613
|
|
|
1594
1614
|
// src/telemetry/builders.ts
|
|
1595
1615
|
function createCliBaseEvent(context = {}) {
|
|
@@ -2868,7 +2888,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
2868
2888
|
// package.json with { type: 'json' }
|
|
2869
2889
|
var package_default2 = {
|
|
2870
2890
|
name: "@zapier/zapier-sdk-cli",
|
|
2871
|
-
version: "0.
|
|
2891
|
+
version: "0.16.1"};
|
|
2872
2892
|
function detectPackageManager(cwd = process.cwd()) {
|
|
2873
2893
|
const ua = process.env.npm_config_user_agent;
|
|
2874
2894
|
if (ua) {
|
package/dist/index.cjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -2,18 +2,10 @@ import { AppItem, Manifest, GetSdkType, ZapierSdk, ZapierSdkOptions, BaseEvent }
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
declare const BuildManifestSchema: z.ZodObject<{
|
|
5
|
-
appKeys: z.ZodArray<z.ZodString
|
|
5
|
+
appKeys: z.ZodArray<z.ZodString>;
|
|
6
6
|
skipWrite: z.ZodOptional<z.ZodBoolean>;
|
|
7
7
|
configPath: z.ZodOptional<z.ZodString>;
|
|
8
|
-
},
|
|
9
|
-
appKeys: string[];
|
|
10
|
-
configPath?: string | undefined;
|
|
11
|
-
skipWrite?: boolean | undefined;
|
|
12
|
-
}, {
|
|
13
|
-
appKeys: string[];
|
|
14
|
-
configPath?: string | undefined;
|
|
15
|
-
skipWrite?: boolean | undefined;
|
|
16
|
-
}>;
|
|
8
|
+
}, z.core.$strip>;
|
|
17
9
|
type BuildManifestOptions = z.infer<typeof BuildManifestSchema> & {
|
|
18
10
|
onProgress?: (event: ManifestBuildProgressEvent) => void;
|
|
19
11
|
};
|
|
@@ -64,21 +56,11 @@ interface BuildManifestPluginProvides {
|
|
|
64
56
|
}
|
|
65
57
|
|
|
66
58
|
declare const GenerateAppTypesSchema: z.ZodObject<{
|
|
67
|
-
appKeys: z.ZodArray<z.ZodString
|
|
68
|
-
authenticationIds: z.ZodOptional<z.ZodArray<z.ZodString
|
|
59
|
+
appKeys: z.ZodArray<z.ZodString>;
|
|
60
|
+
authenticationIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
61
|
skipWrite: z.ZodOptional<z.ZodBoolean>;
|
|
70
62
|
typesOutputDirectory: z.ZodOptional<z.ZodString>;
|
|
71
|
-
},
|
|
72
|
-
appKeys: string[];
|
|
73
|
-
authenticationIds?: string[] | undefined;
|
|
74
|
-
skipWrite?: boolean | undefined;
|
|
75
|
-
typesOutputDirectory?: string | undefined;
|
|
76
|
-
}, {
|
|
77
|
-
appKeys: string[];
|
|
78
|
-
authenticationIds?: string[] | undefined;
|
|
79
|
-
skipWrite?: boolean | undefined;
|
|
80
|
-
typesOutputDirectory?: string | undefined;
|
|
81
|
-
}>;
|
|
63
|
+
}, z.core.$strip>;
|
|
82
64
|
type GenerateAppTypesOptions = z.infer<typeof GenerateAppTypesSchema> & {
|
|
83
65
|
onProgress?: (event: AppTypesProgressEvent) => void;
|
|
84
66
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,18 +2,10 @@ import { AppItem, Manifest, GetSdkType, ZapierSdk, ZapierSdkOptions, BaseEvent }
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
declare const BuildManifestSchema: z.ZodObject<{
|
|
5
|
-
appKeys: z.ZodArray<z.ZodString
|
|
5
|
+
appKeys: z.ZodArray<z.ZodString>;
|
|
6
6
|
skipWrite: z.ZodOptional<z.ZodBoolean>;
|
|
7
7
|
configPath: z.ZodOptional<z.ZodString>;
|
|
8
|
-
},
|
|
9
|
-
appKeys: string[];
|
|
10
|
-
configPath?: string | undefined;
|
|
11
|
-
skipWrite?: boolean | undefined;
|
|
12
|
-
}, {
|
|
13
|
-
appKeys: string[];
|
|
14
|
-
configPath?: string | undefined;
|
|
15
|
-
skipWrite?: boolean | undefined;
|
|
16
|
-
}>;
|
|
8
|
+
}, z.core.$strip>;
|
|
17
9
|
type BuildManifestOptions = z.infer<typeof BuildManifestSchema> & {
|
|
18
10
|
onProgress?: (event: ManifestBuildProgressEvent) => void;
|
|
19
11
|
};
|
|
@@ -64,21 +56,11 @@ interface BuildManifestPluginProvides {
|
|
|
64
56
|
}
|
|
65
57
|
|
|
66
58
|
declare const GenerateAppTypesSchema: z.ZodObject<{
|
|
67
|
-
appKeys: z.ZodArray<z.ZodString
|
|
68
|
-
authenticationIds: z.ZodOptional<z.ZodArray<z.ZodString
|
|
59
|
+
appKeys: z.ZodArray<z.ZodString>;
|
|
60
|
+
authenticationIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
61
|
skipWrite: z.ZodOptional<z.ZodBoolean>;
|
|
70
62
|
typesOutputDirectory: z.ZodOptional<z.ZodString>;
|
|
71
|
-
},
|
|
72
|
-
appKeys: string[];
|
|
73
|
-
authenticationIds?: string[] | undefined;
|
|
74
|
-
skipWrite?: boolean | undefined;
|
|
75
|
-
typesOutputDirectory?: string | undefined;
|
|
76
|
-
}, {
|
|
77
|
-
appKeys: string[];
|
|
78
|
-
authenticationIds?: string[] | undefined;
|
|
79
|
-
skipWrite?: boolean | undefined;
|
|
80
|
-
typesOutputDirectory?: string | undefined;
|
|
81
|
-
}>;
|
|
63
|
+
}, z.core.$strip>;
|
|
82
64
|
type GenerateAppTypesOptions = z.infer<typeof GenerateAppTypesSchema> & {
|
|
83
65
|
onProgress?: (event: AppTypesProgressEvent) => void;
|
|
84
66
|
};
|
package/dist/index.mjs
CHANGED
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/zapier-sdk-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "Command line interface for Zapier SDK",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"pkce-challenge": "^5.0.0",
|
|
59
59
|
"semver": "^7.7.3",
|
|
60
60
|
"typescript": "^5.8.3",
|
|
61
|
-
"zod": "
|
|
61
|
+
"zod": "4.2.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@types/express": "^5.0.3",
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const AddSchema: z.ZodObject<{
|
|
3
|
-
appKeys: z.ZodArray<z.ZodString
|
|
4
|
-
authenticationIds: z.ZodOptional<z.ZodArray<z.ZodString
|
|
3
|
+
appKeys: z.ZodArray<z.ZodString>;
|
|
4
|
+
authenticationIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
5
5
|
configPath: z.ZodOptional<z.ZodString>;
|
|
6
6
|
typesOutput: z.ZodOptional<z.ZodString>;
|
|
7
|
-
},
|
|
8
|
-
appKeys: string[];
|
|
9
|
-
authenticationIds?: string[] | undefined;
|
|
10
|
-
configPath?: string | undefined;
|
|
11
|
-
typesOutput?: string | undefined;
|
|
12
|
-
}, {
|
|
13
|
-
appKeys: string[];
|
|
14
|
-
authenticationIds?: string[] | undefined;
|
|
15
|
-
configPath?: string | undefined;
|
|
16
|
-
typesOutput?: string | undefined;
|
|
17
|
-
}>;
|
|
7
|
+
}, z.core.$strip>;
|
|
18
8
|
export type AddOptions = z.infer<typeof AddSchema>;
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { AppItem, Manifest } from "@zapier/zapier-sdk";
|
|
3
3
|
export declare const BuildManifestSchema: z.ZodObject<{
|
|
4
|
-
appKeys: z.ZodArray<z.ZodString
|
|
4
|
+
appKeys: z.ZodArray<z.ZodString>;
|
|
5
5
|
skipWrite: z.ZodOptional<z.ZodBoolean>;
|
|
6
6
|
configPath: z.ZodOptional<z.ZodString>;
|
|
7
|
-
},
|
|
8
|
-
appKeys: string[];
|
|
9
|
-
configPath?: string | undefined;
|
|
10
|
-
skipWrite?: boolean | undefined;
|
|
11
|
-
}, {
|
|
12
|
-
appKeys: string[];
|
|
13
|
-
configPath?: string | undefined;
|
|
14
|
-
skipWrite?: boolean | undefined;
|
|
15
|
-
}>;
|
|
7
|
+
}, z.core.$strip>;
|
|
16
8
|
export type BuildManifestOptions = z.infer<typeof BuildManifestSchema> & {
|
|
17
9
|
onProgress?: (event: ManifestBuildProgressEvent) => void;
|
|
18
10
|
};
|
|
@@ -6,19 +6,5 @@ export declare const BundleCodeSchema: z.ZodObject<{
|
|
|
6
6
|
minify: z.ZodOptional<z.ZodBoolean>;
|
|
7
7
|
target: z.ZodOptional<z.ZodString>;
|
|
8
8
|
cjs: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
-
},
|
|
10
|
-
input: string;
|
|
11
|
-
string?: boolean | undefined;
|
|
12
|
-
output?: string | undefined;
|
|
13
|
-
minify?: boolean | undefined;
|
|
14
|
-
target?: string | undefined;
|
|
15
|
-
cjs?: boolean | undefined;
|
|
16
|
-
}, {
|
|
17
|
-
input: string;
|
|
18
|
-
string?: boolean | undefined;
|
|
19
|
-
output?: string | undefined;
|
|
20
|
-
minify?: boolean | undefined;
|
|
21
|
-
target?: string | undefined;
|
|
22
|
-
cjs?: boolean | undefined;
|
|
23
|
-
}>;
|
|
9
|
+
}, z.core.$strip>;
|
|
24
10
|
export type BundleCodeOptions = z.infer<typeof BundleCodeSchema>;
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { AppItem } from "@zapier/zapier-sdk";
|
|
3
3
|
export declare const GenerateAppTypesSchema: z.ZodObject<{
|
|
4
|
-
appKeys: z.ZodArray<z.ZodString
|
|
5
|
-
authenticationIds: z.ZodOptional<z.ZodArray<z.ZodString
|
|
4
|
+
appKeys: z.ZodArray<z.ZodString>;
|
|
5
|
+
authenticationIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
6
|
skipWrite: z.ZodOptional<z.ZodBoolean>;
|
|
7
7
|
typesOutputDirectory: z.ZodOptional<z.ZodString>;
|
|
8
|
-
},
|
|
9
|
-
appKeys: string[];
|
|
10
|
-
authenticationIds?: string[] | undefined;
|
|
11
|
-
skipWrite?: boolean | undefined;
|
|
12
|
-
typesOutputDirectory?: string | undefined;
|
|
13
|
-
}, {
|
|
14
|
-
appKeys: string[];
|
|
15
|
-
authenticationIds?: string[] | undefined;
|
|
16
|
-
skipWrite?: boolean | undefined;
|
|
17
|
-
typesOutputDirectory?: string | undefined;
|
|
18
|
-
}>;
|
|
8
|
+
}, z.core.$strip>;
|
|
19
9
|
export type GenerateAppTypesOptions = z.infer<typeof GenerateAppTypesSchema> & {
|
|
20
10
|
onProgress?: (event: AppTypesProgressEvent) => void;
|
|
21
11
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const GetLoginConfigPathSchema: z.ZodObject<{},
|
|
2
|
+
export declare const GetLoginConfigPathSchema: z.ZodObject<{}, z.core.$strip>;
|
|
3
3
|
export type GetLoginConfigPathOptions = z.infer<typeof GetLoginConfigPathSchema>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const LoginSchema: z.ZodObject<{
|
|
3
3
|
timeout: z.ZodOptional<z.ZodString>;
|
|
4
|
-
},
|
|
5
|
-
timeout?: string | undefined;
|
|
6
|
-
}, {
|
|
7
|
-
timeout?: string | undefined;
|
|
8
|
-
}>;
|
|
4
|
+
}, z.core.$strip>;
|
|
9
5
|
export type LoginOptions = z.infer<typeof LoginSchema>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const McpSchema: z.ZodObject<{
|
|
3
3
|
port: z.ZodOptional<z.ZodString>;
|
|
4
|
-
},
|
|
5
|
-
port?: string | undefined;
|
|
6
|
-
}, {
|
|
7
|
-
port?: string | undefined;
|
|
8
|
-
}>;
|
|
4
|
+
}, z.core.$strip>;
|
|
9
5
|
export type McpOptions = z.infer<typeof McpSchema>;
|
|
@@ -23,12 +23,12 @@ function analyzeZodField(name, schema, functionInfo) {
|
|
|
23
23
|
// Unwrap optional and default wrappers
|
|
24
24
|
if (baseSchema instanceof z.ZodOptional) {
|
|
25
25
|
required = false;
|
|
26
|
-
baseSchema = baseSchema.
|
|
26
|
+
baseSchema = baseSchema._zod.def.innerType;
|
|
27
27
|
}
|
|
28
28
|
if (baseSchema instanceof z.ZodDefault) {
|
|
29
29
|
required = false;
|
|
30
|
-
defaultValue = baseSchema.
|
|
31
|
-
baseSchema = baseSchema.
|
|
30
|
+
defaultValue = baseSchema._zod.def.defaultValue();
|
|
31
|
+
baseSchema = baseSchema._zod.def.innerType;
|
|
32
32
|
}
|
|
33
33
|
// Determine parameter type
|
|
34
34
|
let paramType = "string";
|
|
@@ -47,7 +47,7 @@ function analyzeZodField(name, schema, functionInfo) {
|
|
|
47
47
|
}
|
|
48
48
|
else if (baseSchema instanceof z.ZodEnum) {
|
|
49
49
|
paramType = "string";
|
|
50
|
-
choices = baseSchema.
|
|
50
|
+
choices = baseSchema.options;
|
|
51
51
|
}
|
|
52
52
|
else if (baseSchema instanceof z.ZodRecord) {
|
|
53
53
|
// Handle Record<string, any> as JSON string input
|
|
@@ -11,13 +11,10 @@ import { ZapierCliError, ZapierCliExitError } from "./errors";
|
|
|
11
11
|
function analyzeZodSchema(schema, functionInfo) {
|
|
12
12
|
const parameters = [];
|
|
13
13
|
// Handle ZodEffects (schemas with .refine(), .transform(), etc.)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const innerSchema = schema
|
|
19
|
-
._def.schema;
|
|
20
|
-
return analyzeZodSchema(innerSchema, functionInfo);
|
|
14
|
+
// In Zod, effects have type "effect" and inner schema is accessed via innerType
|
|
15
|
+
const schemaDef = schema._zod?.def;
|
|
16
|
+
if (schemaDef?.type === "effect" && schemaDef.innerType) {
|
|
17
|
+
return analyzeZodSchema(schemaDef.innerType, functionInfo);
|
|
21
18
|
}
|
|
22
19
|
if (schema instanceof z.ZodObject) {
|
|
23
20
|
const shape = schema.shape;
|
|
@@ -38,21 +35,22 @@ function analyzeZodField(name, schema, functionInfo) {
|
|
|
38
35
|
while (true) {
|
|
39
36
|
if (baseSchema instanceof z.ZodOptional) {
|
|
40
37
|
required = false;
|
|
41
|
-
baseSchema = baseSchema.
|
|
38
|
+
baseSchema = baseSchema._zod.def.innerType;
|
|
42
39
|
}
|
|
43
40
|
else if (baseSchema instanceof z.ZodDefault) {
|
|
44
41
|
required = false;
|
|
45
|
-
defaultValue = baseSchema.
|
|
46
|
-
baseSchema = baseSchema.
|
|
47
|
-
}
|
|
48
|
-
else if (baseSchema._def &&
|
|
49
|
-
baseSchema._def
|
|
50
|
-
.typeName === "ZodNullable") {
|
|
51
|
-
// nullable doesn't affect CLI required status, but we need to unwrap it to get the base type
|
|
52
|
-
baseSchema = baseSchema._def.innerType;
|
|
42
|
+
defaultValue = baseSchema._zod.def.defaultValue();
|
|
43
|
+
baseSchema = baseSchema._zod.def.innerType;
|
|
53
44
|
}
|
|
54
45
|
else {
|
|
55
|
-
|
|
46
|
+
// Check for ZodNullable - nullable doesn't affect CLI required status, but we need to unwrap it to get the base type
|
|
47
|
+
const zodDef = baseSchema._zod?.def;
|
|
48
|
+
if (zodDef?.typeName === "ZodNullable" && zodDef.innerType) {
|
|
49
|
+
baseSchema = zodDef.innerType;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
// No more wrappers to unwrap
|
|
53
|
+
break;
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
// Determine parameter type
|
|
@@ -72,7 +70,7 @@ function analyzeZodField(name, schema, functionInfo) {
|
|
|
72
70
|
}
|
|
73
71
|
else if (baseSchema instanceof z.ZodEnum) {
|
|
74
72
|
paramType = "string";
|
|
75
|
-
choices = baseSchema.
|
|
73
|
+
choices = baseSchema.options;
|
|
76
74
|
}
|
|
77
75
|
else if (baseSchema instanceof z.ZodRecord) {
|
|
78
76
|
// Handle Record<string, any> as JSON string input
|
|
@@ -228,7 +226,27 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
|
|
|
228
226
|
}
|
|
229
227
|
// Call the SDK method and handle non-paginated results
|
|
230
228
|
const sdkObj = sdk;
|
|
231
|
-
|
|
229
|
+
let result = await sdkObj[functionInfo.name](resolvedParams);
|
|
230
|
+
// Handle Response objects by wrapping in a structured envelope
|
|
231
|
+
if (result instanceof Response) {
|
|
232
|
+
const response = result;
|
|
233
|
+
let body;
|
|
234
|
+
try {
|
|
235
|
+
body = await response.json();
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
// If JSON parsing fails, try to get text for error context
|
|
239
|
+
const text = response.bodyUsed
|
|
240
|
+
? "[body already consumed]"
|
|
241
|
+
: await response.text().catch(() => "[unable to read body]");
|
|
242
|
+
throw new Error(`Failed to parse response as JSON (status: ${response.status}). Body: ${text.slice(0, 200)}`);
|
|
243
|
+
}
|
|
244
|
+
result = {
|
|
245
|
+
statusCode: response.status,
|
|
246
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
247
|
+
body,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
232
250
|
const items = result?.data
|
|
233
251
|
? result.data
|
|
234
252
|
: result;
|
|
@@ -234,11 +234,11 @@ export class SchemaParameterResolver {
|
|
|
234
234
|
// Check if field is optional or has default
|
|
235
235
|
if (baseSchema instanceof z.ZodOptional) {
|
|
236
236
|
isRequired = false;
|
|
237
|
-
baseSchema = baseSchema.
|
|
237
|
+
baseSchema = baseSchema._zod.def.innerType;
|
|
238
238
|
}
|
|
239
239
|
if (baseSchema instanceof z.ZodDefault) {
|
|
240
240
|
isRequired = false;
|
|
241
|
-
baseSchema = baseSchema.
|
|
241
|
+
baseSchema = baseSchema._zod.def.innerType;
|
|
242
242
|
}
|
|
243
243
|
return this.createResolvableParameter([fieldName], baseSchema, isRequired);
|
|
244
244
|
}
|
|
@@ -3,11 +3,12 @@ import util from "util";
|
|
|
3
3
|
// These functions are internal to SDK, implementing basic formatting fallback
|
|
4
4
|
// TODO: Consider exposing these utilities or implementing proper CLI formatting
|
|
5
5
|
function getFormatMetadata(schema) {
|
|
6
|
-
return schema?.
|
|
7
|
-
?.formatMeta;
|
|
6
|
+
return schema?._zod
|
|
7
|
+
?.def?.formatMeta;
|
|
8
8
|
}
|
|
9
9
|
function getOutputSchema(schema) {
|
|
10
|
-
return schema?.
|
|
10
|
+
return schema?._zod?.def
|
|
11
|
+
?.outputSchema;
|
|
11
12
|
}
|
|
12
13
|
// ============================================================================
|
|
13
14
|
// JSON Formatting
|