@zapier/zapier-sdk-cli 0.43.0 → 0.43.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 +9 -0
- package/dist/cli.cjs +434 -519
- package/dist/cli.mjs +437 -522
- package/dist/index.cjs +436 -521
- package/dist/index.d.mts +395 -23
- package/dist/index.d.ts +395 -23
- package/dist/index.mjs +440 -525
- package/dist/package.json +1 -1
- package/dist/src/plugins/add/index.d.ts +250 -11
- package/dist/src/plugins/add/index.js +8 -16
- package/dist/src/plugins/buildManifest/index.d.ts +116 -9
- package/dist/src/plugins/buildManifest/index.js +14 -23
- package/dist/src/plugins/bundleCode/index.d.ts +19 -10
- package/dist/src/plugins/bundleCode/index.js +7 -17
- package/dist/src/plugins/cliOverrides/index.d.ts +12 -10
- package/dist/src/plugins/cliOverrides/index.js +16 -20
- package/dist/src/plugins/curl/index.d.ts +69 -10
- package/dist/src/plugins/curl/index.js +3 -2
- package/dist/src/plugins/feedback/index.d.ts +18 -13
- package/dist/src/plugins/feedback/index.js +17 -25
- package/dist/src/plugins/generateAppTypes/index.d.ts +261 -9
- package/dist/src/plugins/generateAppTypes/index.js +17 -45
- package/dist/src/plugins/getLoginConfigPath/index.d.ts +12 -10
- package/dist/src/plugins/getLoginConfigPath/index.js +8 -18
- package/dist/src/plugins/init/index.d.ts +15 -11
- package/dist/src/plugins/init/index.js +9 -17
- package/dist/src/plugins/login/index.d.ts +18 -13
- package/dist/src/plugins/login/index.js +9 -17
- package/dist/src/plugins/logout/index.d.ts +12 -11
- package/dist/src/plugins/logout/index.js +10 -16
- package/dist/src/plugins/mcp/index.d.ts +18 -15
- package/dist/src/plugins/mcp/index.js +9 -21
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -938,85 +938,65 @@ function toPkceCredentials(credentials) {
|
|
|
938
938
|
}
|
|
939
939
|
return void 0;
|
|
940
940
|
}
|
|
941
|
-
var loginPlugin = (
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
credentials: pkceCredentials
|
|
952
|
-
});
|
|
953
|
-
const user = await getLoggedInUser();
|
|
954
|
-
sdk.context.eventEmission.emit(
|
|
955
|
-
"platform.sdk.ApplicationLifecycleEvent",
|
|
956
|
-
zapierSdk.buildApplicationLifecycleEvent(
|
|
957
|
-
{ lifecycle_event_type: "login_success" },
|
|
958
|
-
{ customuser_id: user.customUserId, account_id: user.accountId }
|
|
959
|
-
)
|
|
960
|
-
);
|
|
961
|
-
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
962
|
-
};
|
|
963
|
-
return {
|
|
964
|
-
login: loginFn,
|
|
965
|
-
context: {
|
|
966
|
-
meta: {
|
|
967
|
-
login: {
|
|
968
|
-
categories: ["account"],
|
|
969
|
-
inputSchema: LoginSchema,
|
|
970
|
-
supportsJsonOutput: false
|
|
971
|
-
}
|
|
941
|
+
var loginPlugin = zapierSdk.definePlugin(
|
|
942
|
+
(sdk) => zapierSdk.createPluginMethod(sdk, {
|
|
943
|
+
name: "login",
|
|
944
|
+
categories: ["account"],
|
|
945
|
+
inputSchema: LoginSchema,
|
|
946
|
+
supportsJsonOutput: false,
|
|
947
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
948
|
+
const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
|
|
949
|
+
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
950
|
+
throw new Error("Timeout must be a positive number");
|
|
972
951
|
}
|
|
952
|
+
const resolvedCredentials = await sdk2.context.resolveCredentials();
|
|
953
|
+
const pkceCredentials = toPkceCredentials(resolvedCredentials);
|
|
954
|
+
await login_default({
|
|
955
|
+
timeoutMs: timeoutSeconds * 1e3,
|
|
956
|
+
credentials: pkceCredentials
|
|
957
|
+
});
|
|
958
|
+
const user = await getLoggedInUser();
|
|
959
|
+
sdk2.context.eventEmission.emit(
|
|
960
|
+
"platform.sdk.ApplicationLifecycleEvent",
|
|
961
|
+
zapierSdk.buildApplicationLifecycleEvent(
|
|
962
|
+
{ lifecycle_event_type: "login_success" },
|
|
963
|
+
{ customuser_id: user.customUserId, account_id: user.accountId }
|
|
964
|
+
)
|
|
965
|
+
);
|
|
966
|
+
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
973
967
|
}
|
|
974
|
-
}
|
|
975
|
-
|
|
968
|
+
})
|
|
969
|
+
);
|
|
976
970
|
var LogoutSchema = zod.z.object({}).describe("Log out of your Zapier account");
|
|
977
971
|
|
|
978
972
|
// src/plugins/logout/index.ts
|
|
979
|
-
var
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
});
|
|
973
|
+
var logoutPlugin = zapierSdk.definePlugin(
|
|
974
|
+
(sdk) => zapierSdk.createPluginMethod(sdk, {
|
|
975
|
+
name: "logout",
|
|
976
|
+
categories: ["account"],
|
|
977
|
+
inputSchema: LogoutSchema,
|
|
978
|
+
supportsJsonOutput: false,
|
|
979
|
+
handler: async () => {
|
|
980
|
+
await logout();
|
|
981
|
+
console.log("\u2705 Successfully logged out");
|
|
982
|
+
}
|
|
983
|
+
})
|
|
984
|
+
);
|
|
995
985
|
var McpSchema = zod.z.object({
|
|
996
986
|
port: zod.z.string().optional().describe("Port to listen on (for future HTTP transport)")
|
|
997
987
|
}).describe("Start MCP server for Zapier SDK");
|
|
998
988
|
|
|
999
989
|
// src/plugins/mcp/index.ts
|
|
1000
|
-
var mcpPlugin = (
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
context: {
|
|
1011
|
-
meta: {
|
|
1012
|
-
mcp: {
|
|
1013
|
-
categories: ["utility"],
|
|
1014
|
-
inputSchema: McpSchema
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
};
|
|
1019
|
-
};
|
|
990
|
+
var mcpPlugin = zapierSdk.definePlugin(
|
|
991
|
+
(sdk) => zapierSdk.createPluginMethod(sdk, {
|
|
992
|
+
name: "mcp",
|
|
993
|
+
categories: ["utility"],
|
|
994
|
+
inputSchema: McpSchema,
|
|
995
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
996
|
+
await zapierSdkMcp.startMcpServer({ ...options, debug: sdk2.context.options?.debug });
|
|
997
|
+
}
|
|
998
|
+
})
|
|
999
|
+
);
|
|
1020
1000
|
var BundleCodeSchema = zod.z.object({
|
|
1021
1001
|
input: zod.z.string().min(1).describe("Input TypeScript file path to bundle"),
|
|
1022
1002
|
output: zapierSdk.OutputPropertySchema.optional().describe(
|
|
@@ -1027,22 +1007,14 @@ var BundleCodeSchema = zod.z.object({
|
|
|
1027
1007
|
target: zod.z.string().optional().describe("ECMAScript target version"),
|
|
1028
1008
|
cjs: zod.z.boolean().optional().describe("Output CommonJS format instead of ESM")
|
|
1029
1009
|
}).describe("Bundle TypeScript code into executable JavaScript");
|
|
1030
|
-
var bundleCodePlugin = (
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
bundleCode: {
|
|
1039
|
-
categories: ["utility", "deprecated"],
|
|
1040
|
-
inputSchema: BundleCodeSchema
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
};
|
|
1045
|
-
};
|
|
1010
|
+
var bundleCodePlugin = zapierSdk.definePlugin(
|
|
1011
|
+
(sdk) => zapierSdk.createPluginMethod(sdk, {
|
|
1012
|
+
name: "bundleCode",
|
|
1013
|
+
categories: ["utility", "deprecated"],
|
|
1014
|
+
inputSchema: BundleCodeSchema,
|
|
1015
|
+
handler: async ({ options }) => bundleCode(options)
|
|
1016
|
+
})
|
|
1017
|
+
);
|
|
1046
1018
|
var ZapierBundleError = class extends Error {
|
|
1047
1019
|
constructor(message, details, originalError) {
|
|
1048
1020
|
super(message);
|
|
@@ -1109,25 +1081,14 @@ async function bundleCode(options) {
|
|
|
1109
1081
|
}
|
|
1110
1082
|
}
|
|
1111
1083
|
var GetLoginConfigPathSchema = zod.z.object({}).describe("Show the path to the login configuration file");
|
|
1112
|
-
var getLoginConfigPathPlugin = (
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
)
|
|
1119
|
-
|
|
1120
|
-
getLoginConfigPath: getLoginConfigPathWithSdk,
|
|
1121
|
-
context: {
|
|
1122
|
-
meta: {
|
|
1123
|
-
getLoginConfigPath: {
|
|
1124
|
-
categories: ["utility"],
|
|
1125
|
-
inputSchema: GetLoginConfigPathSchema
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
};
|
|
1130
|
-
};
|
|
1084
|
+
var getLoginConfigPathPlugin = zapierSdk.definePlugin(
|
|
1085
|
+
(sdk) => zapierSdk.createPluginMethod(sdk, {
|
|
1086
|
+
name: "getLoginConfigPath",
|
|
1087
|
+
categories: ["utility"],
|
|
1088
|
+
inputSchema: GetLoginConfigPathSchema,
|
|
1089
|
+
handler: async () => getConfigPath()
|
|
1090
|
+
})
|
|
1091
|
+
);
|
|
1131
1092
|
var AddSchema = zod.z.object({
|
|
1132
1093
|
apps: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
1133
1094
|
"One or more app keys to add (e.g., 'slack', 'github', 'trello')"
|
|
@@ -1155,111 +1116,105 @@ async function detectTypesOutputDirectory() {
|
|
|
1155
1116
|
}
|
|
1156
1117
|
return "./zapier/apps/";
|
|
1157
1118
|
}
|
|
1158
|
-
var addPlugin = (
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
skipWrite: false,
|
|
1233
|
-
configPath,
|
|
1234
|
-
onProgress: handleManifestProgress
|
|
1235
|
-
});
|
|
1236
|
-
const typesResult = await sdk.generateAppTypes({
|
|
1237
|
-
apps: appKeys,
|
|
1238
|
-
connections: connectionIds,
|
|
1239
|
-
skipWrite: false,
|
|
1240
|
-
typesOutputDirectory: resolvedTypesOutput,
|
|
1241
|
-
onProgress: handleTypesProgress
|
|
1242
|
-
});
|
|
1243
|
-
const results = manifestResult.manifest?.apps || {};
|
|
1244
|
-
const successfulApps = Object.keys(results).filter(
|
|
1245
|
-
(manifestKey) => typesResult.writtenFiles?.[manifestKey]
|
|
1246
|
-
);
|
|
1247
|
-
if (successfulApps.length > 0) {
|
|
1248
|
-
console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
|
|
1249
|
-
}
|
|
1250
|
-
}, AddSchema);
|
|
1251
|
-
return {
|
|
1252
|
-
add,
|
|
1253
|
-
context: {
|
|
1254
|
-
meta: {
|
|
1255
|
-
add: {
|
|
1256
|
-
categories: ["utility"],
|
|
1257
|
-
inputSchema: AddSchema
|
|
1119
|
+
var addPlugin = zapierSdk.definePlugin(
|
|
1120
|
+
(sdk) => zapierSdk.createPluginMethod(sdk, {
|
|
1121
|
+
name: "add",
|
|
1122
|
+
categories: ["utility"],
|
|
1123
|
+
inputSchema: AddSchema,
|
|
1124
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
1125
|
+
const {
|
|
1126
|
+
apps: appKeys,
|
|
1127
|
+
connections: connectionIds,
|
|
1128
|
+
configPath,
|
|
1129
|
+
typesOutput = await detectTypesOutputDirectory()
|
|
1130
|
+
} = options;
|
|
1131
|
+
const resolvedTypesOutput = path.resolve(typesOutput);
|
|
1132
|
+
console.log(`\u{1F4E6} Adding ${appKeys.length} app(s)...`);
|
|
1133
|
+
const appSlugAndKeyMap = /* @__PURE__ */ new Map();
|
|
1134
|
+
const handleManifestProgress = (event) => {
|
|
1135
|
+
switch (event.type) {
|
|
1136
|
+
case "apps_lookup_start":
|
|
1137
|
+
console.log(`\u{1F4E6} Looking up ${event.count} app(s)...`);
|
|
1138
|
+
break;
|
|
1139
|
+
case "app_found":
|
|
1140
|
+
const displayName = event.app.slug ? `${event.app.slug} (${event.app.key})` : event.app.key;
|
|
1141
|
+
appSlugAndKeyMap.set(event.app.key, displayName);
|
|
1142
|
+
break;
|
|
1143
|
+
case "apps_lookup_complete":
|
|
1144
|
+
if (event.count === 0) {
|
|
1145
|
+
console.warn("\u26A0\uFE0F No apps found");
|
|
1146
|
+
}
|
|
1147
|
+
break;
|
|
1148
|
+
case "app_processing_start":
|
|
1149
|
+
const appName = event.slug ? `${event.slug} (${event.app})` : event.app;
|
|
1150
|
+
console.log(`\u{1F4E6} Adding ${appName}...`);
|
|
1151
|
+
break;
|
|
1152
|
+
case "manifest_updated":
|
|
1153
|
+
const appDisplay = appSlugAndKeyMap.get(event.app) || event.app;
|
|
1154
|
+
console.log(
|
|
1155
|
+
`\u{1F4DD} Locked ${appDisplay} to ${event.app}@${event.version} using key '${event.manifestKey}'`
|
|
1156
|
+
);
|
|
1157
|
+
break;
|
|
1158
|
+
case "app_processing_error":
|
|
1159
|
+
const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
|
|
1160
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
1161
|
+
break;
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
const handleTypesProgress = (event) => {
|
|
1165
|
+
switch (event.type) {
|
|
1166
|
+
case "connections_lookup_start":
|
|
1167
|
+
console.log(`\u{1F510} Looking up ${event.count} connection(s)...`);
|
|
1168
|
+
break;
|
|
1169
|
+
case "connections_lookup_complete":
|
|
1170
|
+
console.log(`\u{1F510} Found ${event.count} connection(s)`);
|
|
1171
|
+
break;
|
|
1172
|
+
case "connection_matched":
|
|
1173
|
+
const appWithConnection = appSlugAndKeyMap.get(event.app) || event.app;
|
|
1174
|
+
console.log(
|
|
1175
|
+
`\u{1F510} Using connection ${event.connectionId} (${event.connectionTitle}) for ${appWithConnection}`
|
|
1176
|
+
);
|
|
1177
|
+
break;
|
|
1178
|
+
case "connection_not_matched":
|
|
1179
|
+
const appWithoutConnection = appSlugAndKeyMap.get(event.app) || event.app;
|
|
1180
|
+
console.warn(
|
|
1181
|
+
`\u26A0\uFE0F No matching connection found for ${appWithoutConnection}`
|
|
1182
|
+
);
|
|
1183
|
+
break;
|
|
1184
|
+
case "file_written":
|
|
1185
|
+
console.log(
|
|
1186
|
+
`\u{1F527} Generated types for ${event.manifestKey} at ${event.filePath}`
|
|
1187
|
+
);
|
|
1188
|
+
break;
|
|
1189
|
+
case "app_processing_error":
|
|
1190
|
+
const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
|
|
1191
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
1192
|
+
break;
|
|
1258
1193
|
}
|
|
1194
|
+
};
|
|
1195
|
+
const manifestResult = await sdk2.buildManifest({
|
|
1196
|
+
apps: appKeys,
|
|
1197
|
+
skipWrite: false,
|
|
1198
|
+
configPath,
|
|
1199
|
+
onProgress: handleManifestProgress
|
|
1200
|
+
});
|
|
1201
|
+
const typesResult = await sdk2.generateAppTypes({
|
|
1202
|
+
apps: appKeys,
|
|
1203
|
+
connections: connectionIds,
|
|
1204
|
+
skipWrite: false,
|
|
1205
|
+
typesOutputDirectory: resolvedTypesOutput,
|
|
1206
|
+
onProgress: handleTypesProgress
|
|
1207
|
+
});
|
|
1208
|
+
const results = manifestResult.manifest?.apps || {};
|
|
1209
|
+
const successfulApps = Object.keys(results).filter(
|
|
1210
|
+
(manifestKey) => typesResult.writtenFiles?.[manifestKey]
|
|
1211
|
+
);
|
|
1212
|
+
if (successfulApps.length > 0) {
|
|
1213
|
+
console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
|
|
1259
1214
|
}
|
|
1260
1215
|
}
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1216
|
+
})
|
|
1217
|
+
);
|
|
1263
1218
|
var GenerateAppTypesSchema = zod.z.object({
|
|
1264
1219
|
apps: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
1265
1220
|
"One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
|
|
@@ -1866,150 +1821,133 @@ function createManifestEntry(app) {
|
|
|
1866
1821
|
version: app.version
|
|
1867
1822
|
};
|
|
1868
1823
|
}
|
|
1869
|
-
var generateAppTypesPlugin = (
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
}
|
|
1893
|
-
const connections = [];
|
|
1894
|
-
if (connectionIds && connectionIds.length > 0) {
|
|
1895
|
-
onProgress?.({
|
|
1896
|
-
type: "connections_lookup_start",
|
|
1897
|
-
count: connectionIds.length
|
|
1898
|
-
});
|
|
1899
|
-
const connectionsIterable = sdk.listConnections({ connections: connectionIds }).items();
|
|
1900
|
-
for await (const connection of connectionsIterable) {
|
|
1901
|
-
connections.push(connection);
|
|
1824
|
+
var generateAppTypesPlugin = zapierSdk.definePlugin(
|
|
1825
|
+
(sdk) => zapierSdk.createPluginMethod(sdk, {
|
|
1826
|
+
name: "generateAppTypes",
|
|
1827
|
+
categories: ["utility"],
|
|
1828
|
+
// Cast: schema validates JSON fields only; GenerateAppTypesOptions adds
|
|
1829
|
+
// the runtime-only `onProgress` callback (passthrough via createFunction).
|
|
1830
|
+
inputSchema: GenerateAppTypesSchema,
|
|
1831
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
1832
|
+
const {
|
|
1833
|
+
apps: appKeys,
|
|
1834
|
+
connections: connectionIds,
|
|
1835
|
+
skipWrite = false,
|
|
1836
|
+
typesOutputDirectory = await detectTypesOutputDirectory(),
|
|
1837
|
+
onProgress
|
|
1838
|
+
} = options;
|
|
1839
|
+
const resolvedTypesOutput = path.resolve(typesOutputDirectory);
|
|
1840
|
+
const result = { typeDefinitions: {} };
|
|
1841
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
1842
|
+
const appsIterable = sdk2.listApps({ apps: appKeys }).items();
|
|
1843
|
+
const apps = [];
|
|
1844
|
+
for await (const app of appsIterable) {
|
|
1845
|
+
apps.push(app);
|
|
1846
|
+
onProgress?.({ type: "app_found", app });
|
|
1902
1847
|
}
|
|
1903
|
-
onProgress?.({
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
}
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
type: "app_processing_start",
|
|
1917
|
-
app: app.key,
|
|
1918
|
-
slug: app.slug
|
|
1919
|
-
});
|
|
1920
|
-
try {
|
|
1921
|
-
if (!app.version) {
|
|
1922
|
-
const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
|
|
1923
|
-
onProgress?.({
|
|
1924
|
-
type: "app_processing_error",
|
|
1925
|
-
app: app.key,
|
|
1926
|
-
error: errorMessage
|
|
1927
|
-
});
|
|
1928
|
-
throw new zapierSdk.ZapierValidationError(errorMessage, {
|
|
1929
|
-
details: {
|
|
1930
|
-
appKey: app.key,
|
|
1931
|
-
implementationId: app.implementation_id
|
|
1932
|
-
}
|
|
1933
|
-
});
|
|
1848
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
1849
|
+
if (apps.length === 0) {
|
|
1850
|
+
return result;
|
|
1851
|
+
}
|
|
1852
|
+
const connections = [];
|
|
1853
|
+
if (connectionIds && connectionIds.length > 0) {
|
|
1854
|
+
onProgress?.({
|
|
1855
|
+
type: "connections_lookup_start",
|
|
1856
|
+
count: connectionIds.length
|
|
1857
|
+
});
|
|
1858
|
+
const connectionsIterable = sdk2.listConnections({ connections: connectionIds }).items();
|
|
1859
|
+
for await (const connection of connectionsIterable) {
|
|
1860
|
+
connections.push(connection);
|
|
1934
1861
|
}
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1862
|
+
onProgress?.({
|
|
1863
|
+
type: "connections_lookup_complete",
|
|
1864
|
+
count: connections.length
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
if (!skipWrite && resolvedTypesOutput) {
|
|
1868
|
+
await promises.mkdir(resolvedTypesOutput, { recursive: true });
|
|
1869
|
+
}
|
|
1870
|
+
if (!skipWrite) {
|
|
1871
|
+
result.writtenFiles = {};
|
|
1872
|
+
}
|
|
1873
|
+
for (const app of apps) {
|
|
1874
|
+
onProgress?.({
|
|
1875
|
+
type: "app_processing_start",
|
|
1876
|
+
app: app.key,
|
|
1877
|
+
slug: app.slug
|
|
1878
|
+
});
|
|
1879
|
+
try {
|
|
1880
|
+
if (!app.version) {
|
|
1881
|
+
const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
|
|
1942
1882
|
onProgress?.({
|
|
1943
|
-
type: "
|
|
1883
|
+
type: "app_processing_error",
|
|
1944
1884
|
app: app.key,
|
|
1945
|
-
|
|
1946
|
-
connectionTitle: matchingConnection.title || ""
|
|
1885
|
+
error: errorMessage
|
|
1947
1886
|
});
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1887
|
+
throw new zapierSdk.ZapierValidationError(errorMessage, {
|
|
1888
|
+
details: {
|
|
1889
|
+
appKey: app.key,
|
|
1890
|
+
implementationId: app.implementation_id
|
|
1891
|
+
}
|
|
1952
1892
|
});
|
|
1953
1893
|
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1894
|
+
let connectionId;
|
|
1895
|
+
if (connections.length > 0) {
|
|
1896
|
+
const matchingConnection = connections.find(
|
|
1897
|
+
(conn) => conn.app_key === app.key
|
|
1898
|
+
);
|
|
1899
|
+
if (matchingConnection) {
|
|
1900
|
+
connectionId = matchingConnection.id;
|
|
1901
|
+
onProgress?.({
|
|
1902
|
+
type: "connection_matched",
|
|
1903
|
+
app: app.key,
|
|
1904
|
+
connectionId: matchingConnection.id,
|
|
1905
|
+
connectionTitle: matchingConnection.title || ""
|
|
1906
|
+
});
|
|
1907
|
+
} else {
|
|
1908
|
+
onProgress?.({
|
|
1909
|
+
type: "connection_not_matched",
|
|
1910
|
+
app: app.key
|
|
1911
|
+
});
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
const manifestKey = getManifestKey(app);
|
|
1915
|
+
const generator = new AstTypeGenerator();
|
|
1916
|
+
const typeDefinitionString = await generator.generateTypes({
|
|
1917
|
+
app,
|
|
1918
|
+
connectionId,
|
|
1919
|
+
sdk: sdk2
|
|
1920
|
+
});
|
|
1921
|
+
result.typeDefinitions[manifestKey] = typeDefinitionString;
|
|
1972
1922
|
onProgress?.({
|
|
1973
|
-
type: "
|
|
1923
|
+
type: "type_generated",
|
|
1974
1924
|
manifestKey,
|
|
1975
|
-
|
|
1925
|
+
sizeBytes: typeDefinitionString.length
|
|
1976
1926
|
});
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
throw error;
|
|
1991
|
-
} else {
|
|
1992
|
-
throw new zapierSdk.ZapierUnknownError(errorMessage, {
|
|
1993
|
-
cause: error
|
|
1994
|
-
// Works for both Error and non-Error
|
|
1927
|
+
if (!skipWrite && resolvedTypesOutput && result.writtenFiles) {
|
|
1928
|
+
const filePath = path.join(resolvedTypesOutput, `${manifestKey}.d.ts`);
|
|
1929
|
+
await promises.writeFile(filePath, typeDefinitionString, "utf8");
|
|
1930
|
+
result.writtenFiles[manifestKey] = filePath;
|
|
1931
|
+
onProgress?.({ type: "file_written", manifestKey, filePath });
|
|
1932
|
+
}
|
|
1933
|
+
onProgress?.({ type: "app_processing_complete", app: app.key });
|
|
1934
|
+
} catch (error) {
|
|
1935
|
+
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
1936
|
+
onProgress?.({
|
|
1937
|
+
type: "app_processing_error",
|
|
1938
|
+
app: app.key,
|
|
1939
|
+
error: errorMessage
|
|
1995
1940
|
});
|
|
1941
|
+
if (error instanceof zapierSdk.ZapierValidationError) {
|
|
1942
|
+
throw error;
|
|
1943
|
+
}
|
|
1944
|
+
throw new zapierSdk.ZapierUnknownError(errorMessage, { cause: error });
|
|
1996
1945
|
}
|
|
1997
1946
|
}
|
|
1947
|
+
return result;
|
|
1998
1948
|
}
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
return {
|
|
2002
|
-
generateAppTypes,
|
|
2003
|
-
context: {
|
|
2004
|
-
meta: {
|
|
2005
|
-
generateAppTypes: {
|
|
2006
|
-
categories: ["utility"],
|
|
2007
|
-
inputSchema: GenerateAppTypesSchema
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
};
|
|
2012
|
-
};
|
|
1949
|
+
})
|
|
1950
|
+
);
|
|
2013
1951
|
var BuildManifestSchema = zod.z.object({
|
|
2014
1952
|
apps: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
2015
1953
|
"One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello')"
|
|
@@ -2025,86 +1963,80 @@ var BuildManifestSchema = zod.z.object({
|
|
|
2025
1963
|
);
|
|
2026
1964
|
|
|
2027
1965
|
// src/plugins/buildManifest/index.ts
|
|
2028
|
-
var buildManifestPlugin = (
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
type: "manifest_entry_built",
|
|
2058
|
-
app: app.key,
|
|
2059
|
-
manifestKey: manifestEntry.implementationName,
|
|
2060
|
-
version: manifestEntry.version || ""
|
|
2061
|
-
});
|
|
2062
|
-
const { key: updatedManifestKey, manifest } = await sdk.context.updateManifestEntry({
|
|
2063
|
-
appKey: app.key,
|
|
2064
|
-
entry: manifestEntry,
|
|
2065
|
-
configPath,
|
|
2066
|
-
skipWrite,
|
|
2067
|
-
manifest: updatedManifest
|
|
2068
|
-
});
|
|
2069
|
-
updatedManifest = manifest;
|
|
2070
|
-
onProgress?.({
|
|
2071
|
-
type: "manifest_updated",
|
|
2072
|
-
app: app.key,
|
|
2073
|
-
manifestKey: updatedManifestKey,
|
|
2074
|
-
version: manifestEntry.version || ""
|
|
2075
|
-
});
|
|
2076
|
-
onProgress?.({ type: "app_processing_complete", app: app.key });
|
|
2077
|
-
} catch (error) {
|
|
2078
|
-
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
1966
|
+
var buildManifestPlugin = zapierSdk.definePlugin(
|
|
1967
|
+
(sdk) => zapierSdk.createPluginMethod(sdk, {
|
|
1968
|
+
name: "buildManifest",
|
|
1969
|
+
categories: ["utility"],
|
|
1970
|
+
// Cast: BuildManifestSchema validates JSON-serializable fields only.
|
|
1971
|
+
// BuildManifestOptions adds an `onProgress` callback that rides through
|
|
1972
|
+
// `createFunction`'s passthrough spread at runtime; this widens TInput
|
|
1973
|
+
// so the handler can read it.
|
|
1974
|
+
inputSchema: BuildManifestSchema,
|
|
1975
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
1976
|
+
const {
|
|
1977
|
+
apps: appKeys,
|
|
1978
|
+
skipWrite = false,
|
|
1979
|
+
configPath,
|
|
1980
|
+
onProgress
|
|
1981
|
+
} = options;
|
|
1982
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
1983
|
+
const appsIterable = sdk2.listApps({ apps: appKeys }).items();
|
|
1984
|
+
const apps = [];
|
|
1985
|
+
for await (const app of appsIterable) {
|
|
1986
|
+
apps.push(app);
|
|
1987
|
+
onProgress?.({ type: "app_found", app });
|
|
1988
|
+
}
|
|
1989
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
1990
|
+
if (apps.length === 0) {
|
|
1991
|
+
return {};
|
|
1992
|
+
}
|
|
1993
|
+
let updatedManifest;
|
|
1994
|
+
for (const app of apps) {
|
|
2079
1995
|
onProgress?.({
|
|
2080
|
-
type: "
|
|
1996
|
+
type: "app_processing_start",
|
|
2081
1997
|
app: app.key,
|
|
2082
|
-
|
|
1998
|
+
slug: app.slug
|
|
2083
1999
|
});
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2000
|
+
try {
|
|
2001
|
+
const manifestEntry = createManifestEntry(app);
|
|
2002
|
+
onProgress?.({
|
|
2003
|
+
type: "manifest_entry_built",
|
|
2004
|
+
app: app.key,
|
|
2005
|
+
manifestKey: manifestEntry.implementationName,
|
|
2006
|
+
version: manifestEntry.version || ""
|
|
2090
2007
|
});
|
|
2008
|
+
const { key: updatedManifestKey, manifest } = await sdk2.context.updateManifestEntry({
|
|
2009
|
+
appKey: app.key,
|
|
2010
|
+
entry: manifestEntry,
|
|
2011
|
+
configPath,
|
|
2012
|
+
skipWrite,
|
|
2013
|
+
manifest: updatedManifest
|
|
2014
|
+
});
|
|
2015
|
+
updatedManifest = manifest;
|
|
2016
|
+
onProgress?.({
|
|
2017
|
+
type: "manifest_updated",
|
|
2018
|
+
app: app.key,
|
|
2019
|
+
manifestKey: updatedManifestKey,
|
|
2020
|
+
version: manifestEntry.version || ""
|
|
2021
|
+
});
|
|
2022
|
+
onProgress?.({ type: "app_processing_complete", app: app.key });
|
|
2023
|
+
} catch (error) {
|
|
2024
|
+
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
2025
|
+
onProgress?.({
|
|
2026
|
+
type: "app_processing_error",
|
|
2027
|
+
app: app.key,
|
|
2028
|
+
error: errorMessage
|
|
2029
|
+
});
|
|
2030
|
+
if (error instanceof zapierSdk.ZapierValidationError) {
|
|
2031
|
+
throw error;
|
|
2032
|
+
}
|
|
2033
|
+
throw new zapierSdk.ZapierUnknownError(errorMessage, { cause: error });
|
|
2091
2034
|
}
|
|
2092
2035
|
}
|
|
2036
|
+
return { manifest: updatedManifest };
|
|
2093
2037
|
}
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
return {
|
|
2097
|
-
buildManifest,
|
|
2098
|
-
context: {
|
|
2099
|
-
meta: {
|
|
2100
|
-
buildManifest: {
|
|
2101
|
-
categories: ["utility"],
|
|
2102
|
-
inputSchema: BuildManifestSchema
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
}
|
|
2106
|
-
};
|
|
2107
|
-
};
|
|
2038
|
+
})
|
|
2039
|
+
);
|
|
2108
2040
|
var FeedbackSchema = zod.z.object({
|
|
2109
2041
|
feedback: zod.z.string().describe(
|
|
2110
2042
|
"Your feedback on the Zapier SDK. Describe what worked well, what was frustrating, or any suggestions."
|
|
@@ -2138,37 +2070,31 @@ async function postWithRetry({
|
|
|
2138
2070
|
}
|
|
2139
2071
|
return response;
|
|
2140
2072
|
}
|
|
2141
|
-
var feedbackPlugin = (
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
feedback: {
|
|
2162
|
-
categories: ["utility"],
|
|
2163
|
-
inputSchema: FeedbackSchema,
|
|
2164
|
-
resolvers: {
|
|
2165
|
-
feedback: feedbackResolver
|
|
2166
|
-
}
|
|
2167
|
-
}
|
|
2073
|
+
var feedbackPlugin = zapierSdk.definePlugin(
|
|
2074
|
+
(sdk) => zapierSdk.createPluginMethod(sdk, {
|
|
2075
|
+
name: "feedback",
|
|
2076
|
+
categories: ["utility"],
|
|
2077
|
+
inputSchema: FeedbackSchema,
|
|
2078
|
+
resolvers: { feedback: feedbackResolver },
|
|
2079
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
2080
|
+
const user = await getLoggedInUser();
|
|
2081
|
+
const body = JSON.stringify({
|
|
2082
|
+
email: user.email,
|
|
2083
|
+
customuser_id: user.customUserId,
|
|
2084
|
+
feedback: options.feedback
|
|
2085
|
+
});
|
|
2086
|
+
const response = await postWithRetry({
|
|
2087
|
+
body,
|
|
2088
|
+
attemptsLeft: MAX_RETRIES
|
|
2089
|
+
});
|
|
2090
|
+
if (sdk2.context.options?.debug) {
|
|
2091
|
+
const text = await response.text();
|
|
2092
|
+
console.error("[debug] Webhook response:", text);
|
|
2168
2093
|
}
|
|
2094
|
+
return "Thank you for your feedback!";
|
|
2169
2095
|
}
|
|
2170
|
-
}
|
|
2171
|
-
|
|
2096
|
+
})
|
|
2097
|
+
);
|
|
2172
2098
|
var CurlSchema = zod.z.object({
|
|
2173
2099
|
url: zod.z.string().describe("Request URL"),
|
|
2174
2100
|
request: zod.z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional().describe("HTTP method (defaults to GET, or POST if data is provided)"),
|
|
@@ -2344,7 +2270,7 @@ async function buildFormData(formArgs, formStringArgs) {
|
|
|
2344
2270
|
}
|
|
2345
2271
|
|
|
2346
2272
|
// src/plugins/curl/index.ts
|
|
2347
|
-
var curlPlugin = (sdk) => {
|
|
2273
|
+
var curlPlugin = zapierSdk.definePlugin((sdk) => {
|
|
2348
2274
|
async function curl(options) {
|
|
2349
2275
|
const {
|
|
2350
2276
|
url: rawUrl,
|
|
@@ -2587,30 +2513,25 @@ ${Array.from(
|
|
|
2587
2513
|
}
|
|
2588
2514
|
}
|
|
2589
2515
|
};
|
|
2590
|
-
};
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
...sdk.context.meta.fetch.categories || [],
|
|
2604
|
-
"deprecated"
|
|
2605
|
-
],
|
|
2606
|
-
deprecation: {
|
|
2607
|
-
message: "This command is deprecated and will be removed soon. Use `curl` instead. Learn more: https://docs.zapier.com/sdk/cli-reference#curl"
|
|
2608
|
-
}
|
|
2516
|
+
});
|
|
2517
|
+
var cliOverridesPlugin = zapierSdk.definePlugin(
|
|
2518
|
+
(sdk) => {
|
|
2519
|
+
const meta = {};
|
|
2520
|
+
if (sdk.context.meta.fetch) {
|
|
2521
|
+
meta.fetch = {
|
|
2522
|
+
...sdk.context.meta.fetch,
|
|
2523
|
+
categories: [
|
|
2524
|
+
...sdk.context.meta.fetch.categories || [],
|
|
2525
|
+
"deprecated"
|
|
2526
|
+
],
|
|
2527
|
+
deprecation: {
|
|
2528
|
+
message: "This command is deprecated and will be removed soon. Use `curl` instead. Learn more: https://docs.zapier.com/sdk/cli-reference#curl"
|
|
2609
2529
|
}
|
|
2610
|
-
}
|
|
2530
|
+
};
|
|
2611
2531
|
}
|
|
2612
|
-
|
|
2613
|
-
}
|
|
2532
|
+
return { context: { meta } };
|
|
2533
|
+
}
|
|
2534
|
+
);
|
|
2614
2535
|
var TEMPLATES = ["basic"];
|
|
2615
2536
|
var InitSchema = zod.z.object({
|
|
2616
2537
|
projectName: zod.z.string().min(1).describe("Name of the project directory to create"),
|
|
@@ -3022,71 +2943,65 @@ function displaySummaryAndNextSteps({
|
|
|
3022
2943
|
}
|
|
3023
2944
|
|
|
3024
2945
|
// src/plugins/init/index.ts
|
|
3025
|
-
var initPlugin = (
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
);
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
}
|
|
3065
|
-
displaySummaryAndNextSteps({
|
|
3066
|
-
projectName,
|
|
3067
|
-
steps,
|
|
3068
|
-
completedSetupStepIds,
|
|
3069
|
-
packageManager
|
|
3070
|
-
});
|
|
3071
|
-
}, InitSchema);
|
|
3072
|
-
return {
|
|
3073
|
-
init,
|
|
3074
|
-
context: {
|
|
3075
|
-
meta: {
|
|
3076
|
-
init: {
|
|
3077
|
-
categories: ["utility"],
|
|
3078
|
-
inputSchema: InitSchema,
|
|
3079
|
-
supportsJsonOutput: false
|
|
3080
|
-
}
|
|
2946
|
+
var initPlugin = zapierSdk.definePlugin(
|
|
2947
|
+
(sdk) => zapierSdk.createPluginMethod(sdk, {
|
|
2948
|
+
name: "init",
|
|
2949
|
+
categories: ["utility"],
|
|
2950
|
+
inputSchema: InitSchema,
|
|
2951
|
+
supportsJsonOutput: false,
|
|
2952
|
+
handler: async ({ options }) => {
|
|
2953
|
+
const { projectName: rawName, skipPrompts = false } = options;
|
|
2954
|
+
const cwd = process.cwd();
|
|
2955
|
+
const { projectName, projectDir } = validateInitOptions({ rawName, cwd });
|
|
2956
|
+
const displayHooks = createConsoleDisplayHooks();
|
|
2957
|
+
const packageManagerInfo = detectPackageManager(cwd);
|
|
2958
|
+
if (packageManagerInfo.name === "unknown") {
|
|
2959
|
+
displayHooks.onWarn(
|
|
2960
|
+
"Could not detect package manager, defaulting to npm."
|
|
2961
|
+
);
|
|
2962
|
+
}
|
|
2963
|
+
const packageManager = packageManagerInfo.name === "unknown" ? "npm" : packageManagerInfo.name;
|
|
2964
|
+
const steps = getInitSteps({
|
|
2965
|
+
projectDir,
|
|
2966
|
+
projectName,
|
|
2967
|
+
packageManager,
|
|
2968
|
+
displayHooks
|
|
2969
|
+
});
|
|
2970
|
+
const completedSetupStepIds = [];
|
|
2971
|
+
for (let i = 0; i < steps.length; i++) {
|
|
2972
|
+
const step = steps[i];
|
|
2973
|
+
const succeeded = await withInterruptCleanup(
|
|
2974
|
+
step.cleanup,
|
|
2975
|
+
() => runStep({
|
|
2976
|
+
step,
|
|
2977
|
+
stepNumber: i + 1,
|
|
2978
|
+
totalSteps: steps.length,
|
|
2979
|
+
skipPrompts,
|
|
2980
|
+
displayHooks
|
|
2981
|
+
})
|
|
2982
|
+
);
|
|
2983
|
+
if (!succeeded) break;
|
|
2984
|
+
completedSetupStepIds.push(step.id);
|
|
3081
2985
|
}
|
|
2986
|
+
if (completedSetupStepIds.length === 0) {
|
|
2987
|
+
throw new ZapierCliExitError(
|
|
2988
|
+
"Project setup failed \u2014 no steps completed."
|
|
2989
|
+
);
|
|
2990
|
+
}
|
|
2991
|
+
displaySummaryAndNextSteps({
|
|
2992
|
+
projectName,
|
|
2993
|
+
steps,
|
|
2994
|
+
completedSetupStepIds,
|
|
2995
|
+
packageManager
|
|
2996
|
+
});
|
|
3082
2997
|
}
|
|
3083
|
-
}
|
|
3084
|
-
|
|
2998
|
+
})
|
|
2999
|
+
);
|
|
3085
3000
|
|
|
3086
3001
|
// package.json with { type: 'json' }
|
|
3087
3002
|
var package_default = {
|
|
3088
3003
|
name: "@zapier/zapier-sdk-cli",
|
|
3089
|
-
version: "0.43.
|
|
3004
|
+
version: "0.43.1"};
|
|
3090
3005
|
|
|
3091
3006
|
// src/sdk.ts
|
|
3092
3007
|
zapierSdk.injectCliLogin(login_exports);
|
|
@@ -3100,7 +3015,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
3100
3015
|
|
|
3101
3016
|
// package.json
|
|
3102
3017
|
var package_default2 = {
|
|
3103
|
-
version: "0.43.
|
|
3018
|
+
version: "0.43.1"};
|
|
3104
3019
|
|
|
3105
3020
|
// src/telemetry/builders.ts
|
|
3106
3021
|
function createCliBaseEvent(context = {}) {
|