@zapier/zapier-sdk-cli 0.28.0 → 0.29.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 +12 -0
- package/CLAUDE.md +15 -15
- package/README.md +142 -142
- package/dist/cli.cjs +61 -55
- package/dist/cli.mjs +61 -55
- package/dist/index.cjs +49 -49
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +49 -49
- package/dist/package.json +1 -1
- package/dist/src/generators/ast-generator.d.ts +1 -1
- package/dist/src/generators/ast-generator.js +7 -7
- package/dist/src/plugins/add/index.d.ts +2 -2
- package/dist/src/plugins/add/index.js +12 -12
- package/dist/src/plugins/add/schemas.d.ts +1 -1
- package/dist/src/plugins/add/schemas.js +2 -2
- package/dist/src/plugins/buildManifest/index.js +2 -2
- package/dist/src/plugins/generateAppTypes/index.d.ts +2 -2
- package/dist/src/plugins/generateAppTypes/index.js +26 -26
- 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.js +10 -2
- package/dist/src/utils/parameter-resolver.js +8 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
package/dist/cli.cjs
CHANGED
|
@@ -133,7 +133,7 @@ var SchemaParameterResolver = class {
|
|
|
133
133
|
});
|
|
134
134
|
const alwaysPrompt = missingResolvable.filter((param) => {
|
|
135
135
|
if (functionallyRequired.includes(param)) return false;
|
|
136
|
-
if (param.name === "
|
|
136
|
+
if (param.name === "connectionId") {
|
|
137
137
|
return true;
|
|
138
138
|
}
|
|
139
139
|
return false;
|
|
@@ -333,7 +333,7 @@ var SchemaParameterResolver = class {
|
|
|
333
333
|
return answers[param.name];
|
|
334
334
|
} else if (typedResolver.type === "dynamic") {
|
|
335
335
|
try {
|
|
336
|
-
if (param.isRequired && param.name !== "
|
|
336
|
+
if (param.isRequired && param.name !== "connectionId") {
|
|
337
337
|
console.log(chalk3__default.default.gray(`Fetching options for ${param.name}...`));
|
|
338
338
|
}
|
|
339
339
|
const items = await typedResolver.fetch(
|
|
@@ -577,7 +577,7 @@ Optional fields${pathContext}:`));
|
|
|
577
577
|
appKey: context.resolvedParams.appKey,
|
|
578
578
|
actionKey: context.resolvedParams.actionKey,
|
|
579
579
|
actionType: context.resolvedParams.actionType,
|
|
580
|
-
|
|
580
|
+
connectionId: context.resolvedParams.connectionId,
|
|
581
581
|
inputFieldKey: fieldMeta.key,
|
|
582
582
|
inputs,
|
|
583
583
|
...cursor && { cursor }
|
|
@@ -925,6 +925,9 @@ function analyzeZodSchema(schema, functionInfo) {
|
|
|
925
925
|
return parameters;
|
|
926
926
|
}
|
|
927
927
|
function analyzeZodField(name, schema, functionInfo) {
|
|
928
|
+
if (functionInfo?.deprecatedParameters?.includes(name)) {
|
|
929
|
+
return null;
|
|
930
|
+
}
|
|
928
931
|
let baseSchema = schema;
|
|
929
932
|
let required = true;
|
|
930
933
|
let defaultValue = void 0;
|
|
@@ -989,6 +992,9 @@ function analyzeInputParameters(inputParameters, functionInfo) {
|
|
|
989
992
|
if (schema instanceof zod.z.ZodObject) {
|
|
990
993
|
const shape = schema.shape;
|
|
991
994
|
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
995
|
+
if (functionInfo?.deprecatedParameters?.includes(key)) {
|
|
996
|
+
continue;
|
|
997
|
+
}
|
|
992
998
|
const analyzed = analyzeZodField(
|
|
993
999
|
key,
|
|
994
1000
|
fieldSchema,
|
|
@@ -1162,10 +1168,10 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
|
|
|
1162
1168
|
}
|
|
1163
1169
|
if (isListCommand && hasPaginationParams && !shouldUseJson && !hasUserSpecifiedMaxItems) {
|
|
1164
1170
|
const sdkObj = sdk2;
|
|
1165
|
-
const
|
|
1171
|
+
const sdkIterable = sdkObj[functionInfo.name](resolvedParams);
|
|
1166
1172
|
await handlePaginatedListWithAsyncIteration(
|
|
1167
1173
|
functionInfo.name,
|
|
1168
|
-
|
|
1174
|
+
sdkIterable,
|
|
1169
1175
|
functionInfo
|
|
1170
1176
|
);
|
|
1171
1177
|
} else {
|
|
@@ -1774,7 +1780,7 @@ var LoginSchema = zod.z.object({
|
|
|
1774
1780
|
|
|
1775
1781
|
// package.json
|
|
1776
1782
|
var package_default = {
|
|
1777
|
-
version: "0.
|
|
1783
|
+
version: "0.29.0"};
|
|
1778
1784
|
|
|
1779
1785
|
// src/telemetry/builders.ts
|
|
1780
1786
|
function createCliBaseEvent(context = {}) {
|
|
@@ -2067,8 +2073,8 @@ var AddSchema = zod.z.object({
|
|
|
2067
2073
|
appKeys: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
2068
2074
|
"One or more app keys to add (e.g., 'slack', 'github', 'trello')"
|
|
2069
2075
|
),
|
|
2070
|
-
|
|
2071
|
-
"
|
|
2076
|
+
connectionIds: zod.z.array(zod.z.string()).optional().describe(
|
|
2077
|
+
"Connection IDs to use for type generation (e.g., ['123', '456'])"
|
|
2072
2078
|
),
|
|
2073
2079
|
configPath: zod.z.string().optional().describe(
|
|
2074
2080
|
`Path to Zapier config file (defaults to '${zapierSdk.DEFAULT_CONFIG_PATH}', e.g., './custom/.zapierrc')`
|
|
@@ -2094,7 +2100,7 @@ var addPlugin = ({ sdk: sdk2 }) => {
|
|
|
2094
2100
|
const add = zapierSdk.createFunction(async function add2(options) {
|
|
2095
2101
|
const {
|
|
2096
2102
|
appKeys,
|
|
2097
|
-
|
|
2103
|
+
connectionIds,
|
|
2098
2104
|
configPath,
|
|
2099
2105
|
typesOutput = await detectTypesOutputDirectory()
|
|
2100
2106
|
} = options;
|
|
@@ -2133,22 +2139,22 @@ var addPlugin = ({ sdk: sdk2 }) => {
|
|
|
2133
2139
|
};
|
|
2134
2140
|
const handleTypesProgress = (event) => {
|
|
2135
2141
|
switch (event.type) {
|
|
2136
|
-
case "
|
|
2137
|
-
console.log(`\u{1F510} Looking up ${event.count}
|
|
2142
|
+
case "connections_lookup_start":
|
|
2143
|
+
console.log(`\u{1F510} Looking up ${event.count} connection(s)...`);
|
|
2138
2144
|
break;
|
|
2139
|
-
case "
|
|
2140
|
-
console.log(`\u{1F510} Found ${event.count}
|
|
2145
|
+
case "connections_lookup_complete":
|
|
2146
|
+
console.log(`\u{1F510} Found ${event.count} connection(s)`);
|
|
2141
2147
|
break;
|
|
2142
|
-
case "
|
|
2143
|
-
const
|
|
2148
|
+
case "connection_matched":
|
|
2149
|
+
const appWithConnection = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
2144
2150
|
console.log(
|
|
2145
|
-
`\u{1F510} Using
|
|
2151
|
+
`\u{1F510} Using connection ${event.connectionId} (${event.connectionTitle}) for ${appWithConnection}`
|
|
2146
2152
|
);
|
|
2147
2153
|
break;
|
|
2148
|
-
case "
|
|
2149
|
-
const
|
|
2154
|
+
case "connection_not_matched":
|
|
2155
|
+
const appWithoutConnection = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
2150
2156
|
console.warn(
|
|
2151
|
-
`\u26A0\uFE0F No matching
|
|
2157
|
+
`\u26A0\uFE0F No matching connection found for ${appWithoutConnection}`
|
|
2152
2158
|
);
|
|
2153
2159
|
break;
|
|
2154
2160
|
case "file_written":
|
|
@@ -2170,7 +2176,7 @@ var addPlugin = ({ sdk: sdk2 }) => {
|
|
|
2170
2176
|
});
|
|
2171
2177
|
const typesResult = await sdk2.generateAppTypes({
|
|
2172
2178
|
appKeys,
|
|
2173
|
-
|
|
2179
|
+
connectionIds,
|
|
2174
2180
|
skipWrite: false,
|
|
2175
2181
|
typesOutputDirectory: resolvedTypesOutput,
|
|
2176
2182
|
onProgress: handleTypesProgress
|
|
@@ -2199,8 +2205,8 @@ var GenerateAppTypesSchema = zod.z.object({
|
|
|
2199
2205
|
appKeys: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
2200
2206
|
"One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
|
|
2201
2207
|
),
|
|
2202
|
-
|
|
2203
|
-
"
|
|
2208
|
+
connectionIds: zod.z.array(zod.z.string()).optional().describe(
|
|
2209
|
+
"Connection IDs to use for type generation (e.g., ['123', '456'])"
|
|
2204
2210
|
),
|
|
2205
2211
|
skipWrite: zod.z.boolean().optional().describe(
|
|
2206
2212
|
"If true, returns type definitions without writing to disk. If false or omitted, writes type files."
|
|
@@ -2224,7 +2230,7 @@ var AstTypeGenerator = class {
|
|
|
2224
2230
|
* Generate TypeScript types using AST for a specific app
|
|
2225
2231
|
*/
|
|
2226
2232
|
async generateTypes(options) {
|
|
2227
|
-
const { app,
|
|
2233
|
+
const { app, connectionId, sdk: sdk2 } = options;
|
|
2228
2234
|
const actionsResult = await sdk2.listActions({
|
|
2229
2235
|
appKey: app.implementation_id
|
|
2230
2236
|
});
|
|
@@ -2235,7 +2241,7 @@ var AstTypeGenerator = class {
|
|
|
2235
2241
|
appKey: app.implementation_id,
|
|
2236
2242
|
actionKey: action.key,
|
|
2237
2243
|
actionType: action.action_type,
|
|
2238
|
-
|
|
2244
|
+
connectionId
|
|
2239
2245
|
})
|
|
2240
2246
|
);
|
|
2241
2247
|
const results = await zapierSdk.batch(inputFieldsTasks, {
|
|
@@ -2301,10 +2307,10 @@ Usage:
|
|
|
2301
2307
|
|
|
2302
2308
|
const zapier = createZapierSdk();
|
|
2303
2309
|
// Types are automatically available:
|
|
2304
|
-
await zapier.apps.${preferredKey}.search.user_by_email({
|
|
2305
|
-
|
|
2306
|
-
// Factory usage (pinned
|
|
2307
|
-
const ${myVariableName} = zapier.apps.${preferredKey}({
|
|
2310
|
+
await zapier.apps.${preferredKey}.search.user_by_email({ connectionId: 123, inputs: { email } })
|
|
2311
|
+
|
|
2312
|
+
// Factory usage (pinned connection):
|
|
2313
|
+
const ${myVariableName} = zapier.apps.${preferredKey}({ connectionId: 123 })
|
|
2308
2314
|
await ${myVariableName}.search.user_by_email({ inputs: { email } })`;
|
|
2309
2315
|
const statements = [
|
|
2310
2316
|
// Import the SDK to activate module augmentation
|
|
@@ -2642,7 +2648,7 @@ Usage:
|
|
|
2642
2648
|
this.factory.createTypeLiteralNode([
|
|
2643
2649
|
this.factory.createPropertySignature(
|
|
2644
2650
|
void 0,
|
|
2645
|
-
"
|
|
2651
|
+
"connectionId",
|
|
2646
2652
|
void 0,
|
|
2647
2653
|
this.factory.createUnionTypeNode([
|
|
2648
2654
|
this.factory.createKeywordTypeNode(ts__namespace.SyntaxKind.StringKeyword),
|
|
@@ -2814,7 +2820,7 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
|
|
|
2814
2820
|
const generateAppTypes = zapierSdk.createFunction(async function generateAppTypes2(options) {
|
|
2815
2821
|
const {
|
|
2816
2822
|
appKeys,
|
|
2817
|
-
|
|
2823
|
+
connectionIds,
|
|
2818
2824
|
skipWrite = false,
|
|
2819
2825
|
typesOutputDirectory = await detectTypesOutputDirectory(),
|
|
2820
2826
|
onProgress
|
|
@@ -2824,9 +2830,9 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
|
|
|
2824
2830
|
typeDefinitions: {}
|
|
2825
2831
|
};
|
|
2826
2832
|
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
2827
|
-
const
|
|
2833
|
+
const appsIterable = sdk2.listApps({ appKeys }).items();
|
|
2828
2834
|
const apps = [];
|
|
2829
|
-
for await (const app of
|
|
2835
|
+
for await (const app of appsIterable) {
|
|
2830
2836
|
apps.push(app);
|
|
2831
2837
|
onProgress?.({ type: "app_found", app });
|
|
2832
2838
|
}
|
|
@@ -2834,19 +2840,19 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
|
|
|
2834
2840
|
if (apps.length === 0) {
|
|
2835
2841
|
return result;
|
|
2836
2842
|
}
|
|
2837
|
-
const
|
|
2838
|
-
if (
|
|
2843
|
+
const connections = [];
|
|
2844
|
+
if (connectionIds && connectionIds.length > 0) {
|
|
2839
2845
|
onProgress?.({
|
|
2840
|
-
type: "
|
|
2841
|
-
count:
|
|
2846
|
+
type: "connections_lookup_start",
|
|
2847
|
+
count: connectionIds.length
|
|
2842
2848
|
});
|
|
2843
|
-
const
|
|
2844
|
-
for await (const
|
|
2845
|
-
|
|
2849
|
+
const connectionsIterable = sdk2.listConnections({ connectionIds }).items();
|
|
2850
|
+
for await (const connection of connectionsIterable) {
|
|
2851
|
+
connections.push(connection);
|
|
2846
2852
|
}
|
|
2847
2853
|
onProgress?.({
|
|
2848
|
-
type: "
|
|
2849
|
-
count:
|
|
2854
|
+
type: "connections_lookup_complete",
|
|
2855
|
+
count: connections.length
|
|
2850
2856
|
});
|
|
2851
2857
|
}
|
|
2852
2858
|
if (!skipWrite && resolvedTypesOutput) {
|
|
@@ -2876,22 +2882,22 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
|
|
|
2876
2882
|
}
|
|
2877
2883
|
});
|
|
2878
2884
|
}
|
|
2879
|
-
let
|
|
2880
|
-
if (
|
|
2881
|
-
const
|
|
2882
|
-
return
|
|
2885
|
+
let connectionId;
|
|
2886
|
+
if (connections.length > 0) {
|
|
2887
|
+
const matchingConnection = connections.find((conn) => {
|
|
2888
|
+
return conn.app_key === app.key;
|
|
2883
2889
|
});
|
|
2884
|
-
if (
|
|
2885
|
-
|
|
2890
|
+
if (matchingConnection) {
|
|
2891
|
+
connectionId = matchingConnection.id;
|
|
2886
2892
|
onProgress?.({
|
|
2887
|
-
type: "
|
|
2893
|
+
type: "connection_matched",
|
|
2888
2894
|
appKey: app.key,
|
|
2889
|
-
|
|
2890
|
-
|
|
2895
|
+
connectionId: matchingConnection.id,
|
|
2896
|
+
connectionTitle: matchingConnection.title || ""
|
|
2891
2897
|
});
|
|
2892
2898
|
} else {
|
|
2893
2899
|
onProgress?.({
|
|
2894
|
-
type: "
|
|
2900
|
+
type: "connection_not_matched",
|
|
2895
2901
|
appKey: app.key
|
|
2896
2902
|
});
|
|
2897
2903
|
}
|
|
@@ -2900,7 +2906,7 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
|
|
|
2900
2906
|
const generator = new AstTypeGenerator();
|
|
2901
2907
|
const typeDefinitionString = await generator.generateTypes({
|
|
2902
2908
|
app,
|
|
2903
|
-
|
|
2909
|
+
connectionId,
|
|
2904
2910
|
sdk: sdk2
|
|
2905
2911
|
});
|
|
2906
2912
|
result.typeDefinitions[manifestKey] = typeDefinitionString;
|
|
@@ -2973,9 +2979,9 @@ var buildManifestPlugin = ({ sdk: sdk2, context }) => {
|
|
|
2973
2979
|
const buildManifest = zapierSdk.createFunction(async function buildManifest2(options) {
|
|
2974
2980
|
const { appKeys, skipWrite = false, configPath, onProgress } = options;
|
|
2975
2981
|
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
2976
|
-
const
|
|
2982
|
+
const appsIterable = sdk2.listApps({ appKeys }).items();
|
|
2977
2983
|
const apps = [];
|
|
2978
|
-
for await (const app of
|
|
2984
|
+
for await (const app of appsIterable) {
|
|
2979
2985
|
apps.push(app);
|
|
2980
2986
|
onProgress?.({ type: "app_found", app });
|
|
2981
2987
|
}
|
|
@@ -3117,7 +3123,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
3117
3123
|
// package.json with { type: 'json' }
|
|
3118
3124
|
var package_default2 = {
|
|
3119
3125
|
name: "@zapier/zapier-sdk-cli",
|
|
3120
|
-
version: "0.
|
|
3126
|
+
version: "0.29.0"};
|
|
3121
3127
|
function detectPackageManager(cwd = process.cwd()) {
|
|
3122
3128
|
const ua = process.env.npm_config_user_agent;
|
|
3123
3129
|
if (ua) {
|
package/dist/cli.mjs
CHANGED
|
@@ -97,7 +97,7 @@ var SchemaParameterResolver = class {
|
|
|
97
97
|
});
|
|
98
98
|
const alwaysPrompt = missingResolvable.filter((param) => {
|
|
99
99
|
if (functionallyRequired.includes(param)) return false;
|
|
100
|
-
if (param.name === "
|
|
100
|
+
if (param.name === "connectionId") {
|
|
101
101
|
return true;
|
|
102
102
|
}
|
|
103
103
|
return false;
|
|
@@ -297,7 +297,7 @@ var SchemaParameterResolver = class {
|
|
|
297
297
|
return answers[param.name];
|
|
298
298
|
} else if (typedResolver.type === "dynamic") {
|
|
299
299
|
try {
|
|
300
|
-
if (param.isRequired && param.name !== "
|
|
300
|
+
if (param.isRequired && param.name !== "connectionId") {
|
|
301
301
|
console.log(chalk3.gray(`Fetching options for ${param.name}...`));
|
|
302
302
|
}
|
|
303
303
|
const items = await typedResolver.fetch(
|
|
@@ -541,7 +541,7 @@ Optional fields${pathContext}:`));
|
|
|
541
541
|
appKey: context.resolvedParams.appKey,
|
|
542
542
|
actionKey: context.resolvedParams.actionKey,
|
|
543
543
|
actionType: context.resolvedParams.actionType,
|
|
544
|
-
|
|
544
|
+
connectionId: context.resolvedParams.connectionId,
|
|
545
545
|
inputFieldKey: fieldMeta.key,
|
|
546
546
|
inputs,
|
|
547
547
|
...cursor && { cursor }
|
|
@@ -889,6 +889,9 @@ function analyzeZodSchema(schema, functionInfo) {
|
|
|
889
889
|
return parameters;
|
|
890
890
|
}
|
|
891
891
|
function analyzeZodField(name, schema, functionInfo) {
|
|
892
|
+
if (functionInfo?.deprecatedParameters?.includes(name)) {
|
|
893
|
+
return null;
|
|
894
|
+
}
|
|
892
895
|
let baseSchema = schema;
|
|
893
896
|
let required = true;
|
|
894
897
|
let defaultValue = void 0;
|
|
@@ -953,6 +956,9 @@ function analyzeInputParameters(inputParameters, functionInfo) {
|
|
|
953
956
|
if (schema instanceof z.ZodObject) {
|
|
954
957
|
const shape = schema.shape;
|
|
955
958
|
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
959
|
+
if (functionInfo?.deprecatedParameters?.includes(key)) {
|
|
960
|
+
continue;
|
|
961
|
+
}
|
|
956
962
|
const analyzed = analyzeZodField(
|
|
957
963
|
key,
|
|
958
964
|
fieldSchema,
|
|
@@ -1126,10 +1132,10 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
|
|
|
1126
1132
|
}
|
|
1127
1133
|
if (isListCommand && hasPaginationParams && !shouldUseJson && !hasUserSpecifiedMaxItems) {
|
|
1128
1134
|
const sdkObj = sdk2;
|
|
1129
|
-
const
|
|
1135
|
+
const sdkIterable = sdkObj[functionInfo.name](resolvedParams);
|
|
1130
1136
|
await handlePaginatedListWithAsyncIteration(
|
|
1131
1137
|
functionInfo.name,
|
|
1132
|
-
|
|
1138
|
+
sdkIterable,
|
|
1133
1139
|
functionInfo
|
|
1134
1140
|
);
|
|
1135
1141
|
} else {
|
|
@@ -1738,7 +1744,7 @@ var LoginSchema = z.object({
|
|
|
1738
1744
|
|
|
1739
1745
|
// package.json
|
|
1740
1746
|
var package_default = {
|
|
1741
|
-
version: "0.
|
|
1747
|
+
version: "0.29.0"};
|
|
1742
1748
|
|
|
1743
1749
|
// src/telemetry/builders.ts
|
|
1744
1750
|
function createCliBaseEvent(context = {}) {
|
|
@@ -2031,8 +2037,8 @@ var AddSchema = z.object({
|
|
|
2031
2037
|
appKeys: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
2032
2038
|
"One or more app keys to add (e.g., 'slack', 'github', 'trello')"
|
|
2033
2039
|
),
|
|
2034
|
-
|
|
2035
|
-
"
|
|
2040
|
+
connectionIds: z.array(z.string()).optional().describe(
|
|
2041
|
+
"Connection IDs to use for type generation (e.g., ['123', '456'])"
|
|
2036
2042
|
),
|
|
2037
2043
|
configPath: z.string().optional().describe(
|
|
2038
2044
|
`Path to Zapier config file (defaults to '${DEFAULT_CONFIG_PATH}', e.g., './custom/.zapierrc')`
|
|
@@ -2058,7 +2064,7 @@ var addPlugin = ({ sdk: sdk2 }) => {
|
|
|
2058
2064
|
const add = createFunction(async function add2(options) {
|
|
2059
2065
|
const {
|
|
2060
2066
|
appKeys,
|
|
2061
|
-
|
|
2067
|
+
connectionIds,
|
|
2062
2068
|
configPath,
|
|
2063
2069
|
typesOutput = await detectTypesOutputDirectory()
|
|
2064
2070
|
} = options;
|
|
@@ -2097,22 +2103,22 @@ var addPlugin = ({ sdk: sdk2 }) => {
|
|
|
2097
2103
|
};
|
|
2098
2104
|
const handleTypesProgress = (event) => {
|
|
2099
2105
|
switch (event.type) {
|
|
2100
|
-
case "
|
|
2101
|
-
console.log(`\u{1F510} Looking up ${event.count}
|
|
2106
|
+
case "connections_lookup_start":
|
|
2107
|
+
console.log(`\u{1F510} Looking up ${event.count} connection(s)...`);
|
|
2102
2108
|
break;
|
|
2103
|
-
case "
|
|
2104
|
-
console.log(`\u{1F510} Found ${event.count}
|
|
2109
|
+
case "connections_lookup_complete":
|
|
2110
|
+
console.log(`\u{1F510} Found ${event.count} connection(s)`);
|
|
2105
2111
|
break;
|
|
2106
|
-
case "
|
|
2107
|
-
const
|
|
2112
|
+
case "connection_matched":
|
|
2113
|
+
const appWithConnection = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
2108
2114
|
console.log(
|
|
2109
|
-
`\u{1F510} Using
|
|
2115
|
+
`\u{1F510} Using connection ${event.connectionId} (${event.connectionTitle}) for ${appWithConnection}`
|
|
2110
2116
|
);
|
|
2111
2117
|
break;
|
|
2112
|
-
case "
|
|
2113
|
-
const
|
|
2118
|
+
case "connection_not_matched":
|
|
2119
|
+
const appWithoutConnection = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
2114
2120
|
console.warn(
|
|
2115
|
-
`\u26A0\uFE0F No matching
|
|
2121
|
+
`\u26A0\uFE0F No matching connection found for ${appWithoutConnection}`
|
|
2116
2122
|
);
|
|
2117
2123
|
break;
|
|
2118
2124
|
case "file_written":
|
|
@@ -2134,7 +2140,7 @@ var addPlugin = ({ sdk: sdk2 }) => {
|
|
|
2134
2140
|
});
|
|
2135
2141
|
const typesResult = await sdk2.generateAppTypes({
|
|
2136
2142
|
appKeys,
|
|
2137
|
-
|
|
2143
|
+
connectionIds,
|
|
2138
2144
|
skipWrite: false,
|
|
2139
2145
|
typesOutputDirectory: resolvedTypesOutput,
|
|
2140
2146
|
onProgress: handleTypesProgress
|
|
@@ -2163,8 +2169,8 @@ var GenerateAppTypesSchema = z.object({
|
|
|
2163
2169
|
appKeys: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
2164
2170
|
"One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
|
|
2165
2171
|
),
|
|
2166
|
-
|
|
2167
|
-
"
|
|
2172
|
+
connectionIds: z.array(z.string()).optional().describe(
|
|
2173
|
+
"Connection IDs to use for type generation (e.g., ['123', '456'])"
|
|
2168
2174
|
),
|
|
2169
2175
|
skipWrite: z.boolean().optional().describe(
|
|
2170
2176
|
"If true, returns type definitions without writing to disk. If false or omitted, writes type files."
|
|
@@ -2188,7 +2194,7 @@ var AstTypeGenerator = class {
|
|
|
2188
2194
|
* Generate TypeScript types using AST for a specific app
|
|
2189
2195
|
*/
|
|
2190
2196
|
async generateTypes(options) {
|
|
2191
|
-
const { app,
|
|
2197
|
+
const { app, connectionId, sdk: sdk2 } = options;
|
|
2192
2198
|
const actionsResult = await sdk2.listActions({
|
|
2193
2199
|
appKey: app.implementation_id
|
|
2194
2200
|
});
|
|
@@ -2199,7 +2205,7 @@ var AstTypeGenerator = class {
|
|
|
2199
2205
|
appKey: app.implementation_id,
|
|
2200
2206
|
actionKey: action.key,
|
|
2201
2207
|
actionType: action.action_type,
|
|
2202
|
-
|
|
2208
|
+
connectionId
|
|
2203
2209
|
})
|
|
2204
2210
|
);
|
|
2205
2211
|
const results = await batch(inputFieldsTasks, {
|
|
@@ -2265,10 +2271,10 @@ Usage:
|
|
|
2265
2271
|
|
|
2266
2272
|
const zapier = createZapierSdk();
|
|
2267
2273
|
// Types are automatically available:
|
|
2268
|
-
await zapier.apps.${preferredKey}.search.user_by_email({
|
|
2269
|
-
|
|
2270
|
-
// Factory usage (pinned
|
|
2271
|
-
const ${myVariableName} = zapier.apps.${preferredKey}({
|
|
2274
|
+
await zapier.apps.${preferredKey}.search.user_by_email({ connectionId: 123, inputs: { email } })
|
|
2275
|
+
|
|
2276
|
+
// Factory usage (pinned connection):
|
|
2277
|
+
const ${myVariableName} = zapier.apps.${preferredKey}({ connectionId: 123 })
|
|
2272
2278
|
await ${myVariableName}.search.user_by_email({ inputs: { email } })`;
|
|
2273
2279
|
const statements = [
|
|
2274
2280
|
// Import the SDK to activate module augmentation
|
|
@@ -2606,7 +2612,7 @@ Usage:
|
|
|
2606
2612
|
this.factory.createTypeLiteralNode([
|
|
2607
2613
|
this.factory.createPropertySignature(
|
|
2608
2614
|
void 0,
|
|
2609
|
-
"
|
|
2615
|
+
"connectionId",
|
|
2610
2616
|
void 0,
|
|
2611
2617
|
this.factory.createUnionTypeNode([
|
|
2612
2618
|
this.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
|
|
@@ -2778,7 +2784,7 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
|
|
|
2778
2784
|
const generateAppTypes = createFunction(async function generateAppTypes2(options) {
|
|
2779
2785
|
const {
|
|
2780
2786
|
appKeys,
|
|
2781
|
-
|
|
2787
|
+
connectionIds,
|
|
2782
2788
|
skipWrite = false,
|
|
2783
2789
|
typesOutputDirectory = await detectTypesOutputDirectory(),
|
|
2784
2790
|
onProgress
|
|
@@ -2788,9 +2794,9 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
|
|
|
2788
2794
|
typeDefinitions: {}
|
|
2789
2795
|
};
|
|
2790
2796
|
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
2791
|
-
const
|
|
2797
|
+
const appsIterable = sdk2.listApps({ appKeys }).items();
|
|
2792
2798
|
const apps = [];
|
|
2793
|
-
for await (const app of
|
|
2799
|
+
for await (const app of appsIterable) {
|
|
2794
2800
|
apps.push(app);
|
|
2795
2801
|
onProgress?.({ type: "app_found", app });
|
|
2796
2802
|
}
|
|
@@ -2798,19 +2804,19 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
|
|
|
2798
2804
|
if (apps.length === 0) {
|
|
2799
2805
|
return result;
|
|
2800
2806
|
}
|
|
2801
|
-
const
|
|
2802
|
-
if (
|
|
2807
|
+
const connections = [];
|
|
2808
|
+
if (connectionIds && connectionIds.length > 0) {
|
|
2803
2809
|
onProgress?.({
|
|
2804
|
-
type: "
|
|
2805
|
-
count:
|
|
2810
|
+
type: "connections_lookup_start",
|
|
2811
|
+
count: connectionIds.length
|
|
2806
2812
|
});
|
|
2807
|
-
const
|
|
2808
|
-
for await (const
|
|
2809
|
-
|
|
2813
|
+
const connectionsIterable = sdk2.listConnections({ connectionIds }).items();
|
|
2814
|
+
for await (const connection of connectionsIterable) {
|
|
2815
|
+
connections.push(connection);
|
|
2810
2816
|
}
|
|
2811
2817
|
onProgress?.({
|
|
2812
|
-
type: "
|
|
2813
|
-
count:
|
|
2818
|
+
type: "connections_lookup_complete",
|
|
2819
|
+
count: connections.length
|
|
2814
2820
|
});
|
|
2815
2821
|
}
|
|
2816
2822
|
if (!skipWrite && resolvedTypesOutput) {
|
|
@@ -2840,22 +2846,22 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
|
|
|
2840
2846
|
}
|
|
2841
2847
|
});
|
|
2842
2848
|
}
|
|
2843
|
-
let
|
|
2844
|
-
if (
|
|
2845
|
-
const
|
|
2846
|
-
return
|
|
2849
|
+
let connectionId;
|
|
2850
|
+
if (connections.length > 0) {
|
|
2851
|
+
const matchingConnection = connections.find((conn) => {
|
|
2852
|
+
return conn.app_key === app.key;
|
|
2847
2853
|
});
|
|
2848
|
-
if (
|
|
2849
|
-
|
|
2854
|
+
if (matchingConnection) {
|
|
2855
|
+
connectionId = matchingConnection.id;
|
|
2850
2856
|
onProgress?.({
|
|
2851
|
-
type: "
|
|
2857
|
+
type: "connection_matched",
|
|
2852
2858
|
appKey: app.key,
|
|
2853
|
-
|
|
2854
|
-
|
|
2859
|
+
connectionId: matchingConnection.id,
|
|
2860
|
+
connectionTitle: matchingConnection.title || ""
|
|
2855
2861
|
});
|
|
2856
2862
|
} else {
|
|
2857
2863
|
onProgress?.({
|
|
2858
|
-
type: "
|
|
2864
|
+
type: "connection_not_matched",
|
|
2859
2865
|
appKey: app.key
|
|
2860
2866
|
});
|
|
2861
2867
|
}
|
|
@@ -2864,7 +2870,7 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
|
|
|
2864
2870
|
const generator = new AstTypeGenerator();
|
|
2865
2871
|
const typeDefinitionString = await generator.generateTypes({
|
|
2866
2872
|
app,
|
|
2867
|
-
|
|
2873
|
+
connectionId,
|
|
2868
2874
|
sdk: sdk2
|
|
2869
2875
|
});
|
|
2870
2876
|
result.typeDefinitions[manifestKey] = typeDefinitionString;
|
|
@@ -2937,9 +2943,9 @@ var buildManifestPlugin = ({ sdk: sdk2, context }) => {
|
|
|
2937
2943
|
const buildManifest = createFunction(async function buildManifest2(options) {
|
|
2938
2944
|
const { appKeys, skipWrite = false, configPath, onProgress } = options;
|
|
2939
2945
|
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
2940
|
-
const
|
|
2946
|
+
const appsIterable = sdk2.listApps({ appKeys }).items();
|
|
2941
2947
|
const apps = [];
|
|
2942
|
-
for await (const app of
|
|
2948
|
+
for await (const app of appsIterable) {
|
|
2943
2949
|
apps.push(app);
|
|
2944
2950
|
onProgress?.({ type: "app_found", app });
|
|
2945
2951
|
}
|
|
@@ -3081,7 +3087,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
3081
3087
|
// package.json with { type: 'json' }
|
|
3082
3088
|
var package_default2 = {
|
|
3083
3089
|
name: "@zapier/zapier-sdk-cli",
|
|
3084
|
-
version: "0.
|
|
3090
|
+
version: "0.29.0"};
|
|
3085
3091
|
function detectPackageManager(cwd = process.cwd()) {
|
|
3086
3092
|
const ua = process.env.npm_config_user_agent;
|
|
3087
3093
|
if (ua) {
|