@zapier/zapier-sdk-cli 0.43.0 → 0.43.3
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 +26 -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 +2 -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 +4 -3
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import Conf from 'conf';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
|
-
import {
|
|
3
|
+
import { promises, createWriteStream, existsSync, readdirSync, rmSync, mkdirSync, writeFileSync, copyFileSync, readFileSync } from 'fs';
|
|
4
4
|
import * as jwt from 'jsonwebtoken';
|
|
5
|
-
import {
|
|
5
|
+
import { getPassword, getKeyring, setPassword, deletePassword } from 'cross-keychain';
|
|
6
6
|
import crypto, { createHash } from 'crypto';
|
|
7
7
|
import * as path from 'path';
|
|
8
|
-
import {
|
|
8
|
+
import { resolve, join, dirname, basename, relative, extname } from 'path';
|
|
9
9
|
import * as lockfile from 'proper-lockfile';
|
|
10
|
-
import {
|
|
10
|
+
import { definePlugin, createPluginMethod, buildApplicationLifecycleEvent, OutputPropertySchema, DEFAULT_CONFIG_PATH, ZapierValidationError, ZapierUnknownError, injectCliLogin, isCredentialsObject, batch, toSnakeCase, ZapierError, createZapierSdk, getOsInfo, getPlatformVersions, getCiPlatform, isCi, getReleaseId, getCurrentTimestamp, generateEventId } from '@zapier/zapier-sdk';
|
|
11
11
|
import open from 'open';
|
|
12
12
|
import express from 'express';
|
|
13
13
|
import pkceChallenge from 'pkce-challenge';
|
|
@@ -902,85 +902,65 @@ function toPkceCredentials(credentials) {
|
|
|
902
902
|
}
|
|
903
903
|
return void 0;
|
|
904
904
|
}
|
|
905
|
-
var loginPlugin = (
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
credentials: pkceCredentials
|
|
916
|
-
});
|
|
917
|
-
const user = await getLoggedInUser();
|
|
918
|
-
sdk.context.eventEmission.emit(
|
|
919
|
-
"platform.sdk.ApplicationLifecycleEvent",
|
|
920
|
-
buildApplicationLifecycleEvent(
|
|
921
|
-
{ lifecycle_event_type: "login_success" },
|
|
922
|
-
{ customuser_id: user.customUserId, account_id: user.accountId }
|
|
923
|
-
)
|
|
924
|
-
);
|
|
925
|
-
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
926
|
-
};
|
|
927
|
-
return {
|
|
928
|
-
login: loginFn,
|
|
929
|
-
context: {
|
|
930
|
-
meta: {
|
|
931
|
-
login: {
|
|
932
|
-
categories: ["account"],
|
|
933
|
-
inputSchema: LoginSchema,
|
|
934
|
-
supportsJsonOutput: false
|
|
935
|
-
}
|
|
905
|
+
var loginPlugin = definePlugin(
|
|
906
|
+
(sdk) => createPluginMethod(sdk, {
|
|
907
|
+
name: "login",
|
|
908
|
+
categories: ["account"],
|
|
909
|
+
inputSchema: LoginSchema,
|
|
910
|
+
supportsJsonOutput: false,
|
|
911
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
912
|
+
const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
|
|
913
|
+
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
914
|
+
throw new Error("Timeout must be a positive number");
|
|
936
915
|
}
|
|
916
|
+
const resolvedCredentials = await sdk2.context.resolveCredentials();
|
|
917
|
+
const pkceCredentials = toPkceCredentials(resolvedCredentials);
|
|
918
|
+
await login_default({
|
|
919
|
+
timeoutMs: timeoutSeconds * 1e3,
|
|
920
|
+
credentials: pkceCredentials
|
|
921
|
+
});
|
|
922
|
+
const user = await getLoggedInUser();
|
|
923
|
+
sdk2.context.eventEmission.emit(
|
|
924
|
+
"platform.sdk.ApplicationLifecycleEvent",
|
|
925
|
+
buildApplicationLifecycleEvent(
|
|
926
|
+
{ lifecycle_event_type: "login_success" },
|
|
927
|
+
{ customuser_id: user.customUserId, account_id: user.accountId }
|
|
928
|
+
)
|
|
929
|
+
);
|
|
930
|
+
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
937
931
|
}
|
|
938
|
-
}
|
|
939
|
-
|
|
932
|
+
})
|
|
933
|
+
);
|
|
940
934
|
var LogoutSchema = z.object({}).describe("Log out of your Zapier account");
|
|
941
935
|
|
|
942
936
|
// src/plugins/logout/index.ts
|
|
943
|
-
var
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
});
|
|
937
|
+
var logoutPlugin = definePlugin(
|
|
938
|
+
(sdk) => createPluginMethod(sdk, {
|
|
939
|
+
name: "logout",
|
|
940
|
+
categories: ["account"],
|
|
941
|
+
inputSchema: LogoutSchema,
|
|
942
|
+
supportsJsonOutput: false,
|
|
943
|
+
handler: async () => {
|
|
944
|
+
await logout();
|
|
945
|
+
console.log("\u2705 Successfully logged out");
|
|
946
|
+
}
|
|
947
|
+
})
|
|
948
|
+
);
|
|
959
949
|
var McpSchema = z.object({
|
|
960
950
|
port: z.string().optional().describe("Port to listen on (for future HTTP transport)")
|
|
961
951
|
}).describe("Start MCP server for Zapier SDK");
|
|
962
952
|
|
|
963
953
|
// src/plugins/mcp/index.ts
|
|
964
|
-
var mcpPlugin = (
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
context: {
|
|
975
|
-
meta: {
|
|
976
|
-
mcp: {
|
|
977
|
-
categories: ["utility"],
|
|
978
|
-
inputSchema: McpSchema
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
};
|
|
983
|
-
};
|
|
954
|
+
var mcpPlugin = definePlugin(
|
|
955
|
+
(sdk) => createPluginMethod(sdk, {
|
|
956
|
+
name: "mcp",
|
|
957
|
+
categories: ["utility"],
|
|
958
|
+
inputSchema: McpSchema,
|
|
959
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
960
|
+
await startMcpServer({ ...options, debug: sdk2.context.options?.debug });
|
|
961
|
+
}
|
|
962
|
+
})
|
|
963
|
+
);
|
|
984
964
|
var BundleCodeSchema = z.object({
|
|
985
965
|
input: z.string().min(1).describe("Input TypeScript file path to bundle"),
|
|
986
966
|
output: OutputPropertySchema.optional().describe(
|
|
@@ -991,22 +971,14 @@ var BundleCodeSchema = z.object({
|
|
|
991
971
|
target: z.string().optional().describe("ECMAScript target version"),
|
|
992
972
|
cjs: z.boolean().optional().describe("Output CommonJS format instead of ESM")
|
|
993
973
|
}).describe("Bundle TypeScript code into executable JavaScript");
|
|
994
|
-
var bundleCodePlugin = (
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
bundleCode: {
|
|
1003
|
-
categories: ["utility", "deprecated"],
|
|
1004
|
-
inputSchema: BundleCodeSchema
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
};
|
|
1009
|
-
};
|
|
974
|
+
var bundleCodePlugin = definePlugin(
|
|
975
|
+
(sdk) => createPluginMethod(sdk, {
|
|
976
|
+
name: "bundleCode",
|
|
977
|
+
categories: ["utility", "deprecated"],
|
|
978
|
+
inputSchema: BundleCodeSchema,
|
|
979
|
+
handler: async ({ options }) => bundleCode(options)
|
|
980
|
+
})
|
|
981
|
+
);
|
|
1010
982
|
var ZapierBundleError = class extends Error {
|
|
1011
983
|
constructor(message, details, originalError) {
|
|
1012
984
|
super(message);
|
|
@@ -1073,25 +1045,14 @@ async function bundleCode(options) {
|
|
|
1073
1045
|
}
|
|
1074
1046
|
}
|
|
1075
1047
|
var GetLoginConfigPathSchema = z.object({}).describe("Show the path to the login configuration file");
|
|
1076
|
-
var getLoginConfigPathPlugin = (
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
)
|
|
1083
|
-
|
|
1084
|
-
getLoginConfigPath: getLoginConfigPathWithSdk,
|
|
1085
|
-
context: {
|
|
1086
|
-
meta: {
|
|
1087
|
-
getLoginConfigPath: {
|
|
1088
|
-
categories: ["utility"],
|
|
1089
|
-
inputSchema: GetLoginConfigPathSchema
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
};
|
|
1094
|
-
};
|
|
1048
|
+
var getLoginConfigPathPlugin = definePlugin(
|
|
1049
|
+
(sdk) => createPluginMethod(sdk, {
|
|
1050
|
+
name: "getLoginConfigPath",
|
|
1051
|
+
categories: ["utility"],
|
|
1052
|
+
inputSchema: GetLoginConfigPathSchema,
|
|
1053
|
+
handler: async () => getConfigPath()
|
|
1054
|
+
})
|
|
1055
|
+
);
|
|
1095
1056
|
var AddSchema = z.object({
|
|
1096
1057
|
apps: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
1097
1058
|
"One or more app keys to add (e.g., 'slack', 'github', 'trello')"
|
|
@@ -1119,111 +1080,105 @@ async function detectTypesOutputDirectory() {
|
|
|
1119
1080
|
}
|
|
1120
1081
|
return "./zapier/apps/";
|
|
1121
1082
|
}
|
|
1122
|
-
var addPlugin = (
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
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
|
-
skipWrite: false,
|
|
1197
|
-
configPath,
|
|
1198
|
-
onProgress: handleManifestProgress
|
|
1199
|
-
});
|
|
1200
|
-
const typesResult = await sdk.generateAppTypes({
|
|
1201
|
-
apps: appKeys,
|
|
1202
|
-
connections: connectionIds,
|
|
1203
|
-
skipWrite: false,
|
|
1204
|
-
typesOutputDirectory: resolvedTypesOutput,
|
|
1205
|
-
onProgress: handleTypesProgress
|
|
1206
|
-
});
|
|
1207
|
-
const results = manifestResult.manifest?.apps || {};
|
|
1208
|
-
const successfulApps = Object.keys(results).filter(
|
|
1209
|
-
(manifestKey) => typesResult.writtenFiles?.[manifestKey]
|
|
1210
|
-
);
|
|
1211
|
-
if (successfulApps.length > 0) {
|
|
1212
|
-
console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
|
|
1213
|
-
}
|
|
1214
|
-
}, AddSchema);
|
|
1215
|
-
return {
|
|
1216
|
-
add,
|
|
1217
|
-
context: {
|
|
1218
|
-
meta: {
|
|
1219
|
-
add: {
|
|
1220
|
-
categories: ["utility"],
|
|
1221
|
-
inputSchema: AddSchema
|
|
1083
|
+
var addPlugin = definePlugin(
|
|
1084
|
+
(sdk) => createPluginMethod(sdk, {
|
|
1085
|
+
name: "add",
|
|
1086
|
+
categories: ["utility"],
|
|
1087
|
+
inputSchema: AddSchema,
|
|
1088
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
1089
|
+
const {
|
|
1090
|
+
apps: appKeys,
|
|
1091
|
+
connections: connectionIds,
|
|
1092
|
+
configPath,
|
|
1093
|
+
typesOutput = await detectTypesOutputDirectory()
|
|
1094
|
+
} = options;
|
|
1095
|
+
const resolvedTypesOutput = resolve(typesOutput);
|
|
1096
|
+
console.log(`\u{1F4E6} Adding ${appKeys.length} app(s)...`);
|
|
1097
|
+
const appSlugAndKeyMap = /* @__PURE__ */ new Map();
|
|
1098
|
+
const handleManifestProgress = (event) => {
|
|
1099
|
+
switch (event.type) {
|
|
1100
|
+
case "apps_lookup_start":
|
|
1101
|
+
console.log(`\u{1F4E6} Looking up ${event.count} app(s)...`);
|
|
1102
|
+
break;
|
|
1103
|
+
case "app_found":
|
|
1104
|
+
const displayName = event.app.slug ? `${event.app.slug} (${event.app.key})` : event.app.key;
|
|
1105
|
+
appSlugAndKeyMap.set(event.app.key, displayName);
|
|
1106
|
+
break;
|
|
1107
|
+
case "apps_lookup_complete":
|
|
1108
|
+
if (event.count === 0) {
|
|
1109
|
+
console.warn("\u26A0\uFE0F No apps found");
|
|
1110
|
+
}
|
|
1111
|
+
break;
|
|
1112
|
+
case "app_processing_start":
|
|
1113
|
+
const appName = event.slug ? `${event.slug} (${event.app})` : event.app;
|
|
1114
|
+
console.log(`\u{1F4E6} Adding ${appName}...`);
|
|
1115
|
+
break;
|
|
1116
|
+
case "manifest_updated":
|
|
1117
|
+
const appDisplay = appSlugAndKeyMap.get(event.app) || event.app;
|
|
1118
|
+
console.log(
|
|
1119
|
+
`\u{1F4DD} Locked ${appDisplay} to ${event.app}@${event.version} using key '${event.manifestKey}'`
|
|
1120
|
+
);
|
|
1121
|
+
break;
|
|
1122
|
+
case "app_processing_error":
|
|
1123
|
+
const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
|
|
1124
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
const handleTypesProgress = (event) => {
|
|
1129
|
+
switch (event.type) {
|
|
1130
|
+
case "connections_lookup_start":
|
|
1131
|
+
console.log(`\u{1F510} Looking up ${event.count} connection(s)...`);
|
|
1132
|
+
break;
|
|
1133
|
+
case "connections_lookup_complete":
|
|
1134
|
+
console.log(`\u{1F510} Found ${event.count} connection(s)`);
|
|
1135
|
+
break;
|
|
1136
|
+
case "connection_matched":
|
|
1137
|
+
const appWithConnection = appSlugAndKeyMap.get(event.app) || event.app;
|
|
1138
|
+
console.log(
|
|
1139
|
+
`\u{1F510} Using connection ${event.connectionId} (${event.connectionTitle}) for ${appWithConnection}`
|
|
1140
|
+
);
|
|
1141
|
+
break;
|
|
1142
|
+
case "connection_not_matched":
|
|
1143
|
+
const appWithoutConnection = appSlugAndKeyMap.get(event.app) || event.app;
|
|
1144
|
+
console.warn(
|
|
1145
|
+
`\u26A0\uFE0F No matching connection found for ${appWithoutConnection}`
|
|
1146
|
+
);
|
|
1147
|
+
break;
|
|
1148
|
+
case "file_written":
|
|
1149
|
+
console.log(
|
|
1150
|
+
`\u{1F527} Generated types for ${event.manifestKey} at ${event.filePath}`
|
|
1151
|
+
);
|
|
1152
|
+
break;
|
|
1153
|
+
case "app_processing_error":
|
|
1154
|
+
const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
|
|
1155
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
1156
|
+
break;
|
|
1222
1157
|
}
|
|
1158
|
+
};
|
|
1159
|
+
const manifestResult = await sdk2.buildManifest({
|
|
1160
|
+
apps: appKeys,
|
|
1161
|
+
skipWrite: false,
|
|
1162
|
+
configPath,
|
|
1163
|
+
onProgress: handleManifestProgress
|
|
1164
|
+
});
|
|
1165
|
+
const typesResult = await sdk2.generateAppTypes({
|
|
1166
|
+
apps: appKeys,
|
|
1167
|
+
connections: connectionIds,
|
|
1168
|
+
skipWrite: false,
|
|
1169
|
+
typesOutputDirectory: resolvedTypesOutput,
|
|
1170
|
+
onProgress: handleTypesProgress
|
|
1171
|
+
});
|
|
1172
|
+
const results = manifestResult.manifest?.apps || {};
|
|
1173
|
+
const successfulApps = Object.keys(results).filter(
|
|
1174
|
+
(manifestKey) => typesResult.writtenFiles?.[manifestKey]
|
|
1175
|
+
);
|
|
1176
|
+
if (successfulApps.length > 0) {
|
|
1177
|
+
console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
|
|
1223
1178
|
}
|
|
1224
1179
|
}
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1180
|
+
})
|
|
1181
|
+
);
|
|
1227
1182
|
var GenerateAppTypesSchema = z.object({
|
|
1228
1183
|
apps: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
1229
1184
|
"One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
|
|
@@ -1830,150 +1785,133 @@ function createManifestEntry(app) {
|
|
|
1830
1785
|
version: app.version
|
|
1831
1786
|
};
|
|
1832
1787
|
}
|
|
1833
|
-
var generateAppTypesPlugin = (
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
}
|
|
1857
|
-
const connections = [];
|
|
1858
|
-
if (connectionIds && connectionIds.length > 0) {
|
|
1859
|
-
onProgress?.({
|
|
1860
|
-
type: "connections_lookup_start",
|
|
1861
|
-
count: connectionIds.length
|
|
1862
|
-
});
|
|
1863
|
-
const connectionsIterable = sdk.listConnections({ connections: connectionIds }).items();
|
|
1864
|
-
for await (const connection of connectionsIterable) {
|
|
1865
|
-
connections.push(connection);
|
|
1788
|
+
var generateAppTypesPlugin = definePlugin(
|
|
1789
|
+
(sdk) => createPluginMethod(sdk, {
|
|
1790
|
+
name: "generateAppTypes",
|
|
1791
|
+
categories: ["utility"],
|
|
1792
|
+
// Cast: schema validates JSON fields only; GenerateAppTypesOptions adds
|
|
1793
|
+
// the runtime-only `onProgress` callback (passthrough via createFunction).
|
|
1794
|
+
inputSchema: GenerateAppTypesSchema,
|
|
1795
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
1796
|
+
const {
|
|
1797
|
+
apps: appKeys,
|
|
1798
|
+
connections: connectionIds,
|
|
1799
|
+
skipWrite = false,
|
|
1800
|
+
typesOutputDirectory = await detectTypesOutputDirectory(),
|
|
1801
|
+
onProgress
|
|
1802
|
+
} = options;
|
|
1803
|
+
const resolvedTypesOutput = resolve(typesOutputDirectory);
|
|
1804
|
+
const result = { typeDefinitions: {} };
|
|
1805
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
1806
|
+
const appsIterable = sdk2.listApps({ apps: appKeys }).items();
|
|
1807
|
+
const apps = [];
|
|
1808
|
+
for await (const app of appsIterable) {
|
|
1809
|
+
apps.push(app);
|
|
1810
|
+
onProgress?.({ type: "app_found", app });
|
|
1866
1811
|
}
|
|
1867
|
-
onProgress?.({
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
}
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
type: "app_processing_start",
|
|
1881
|
-
app: app.key,
|
|
1882
|
-
slug: app.slug
|
|
1883
|
-
});
|
|
1884
|
-
try {
|
|
1885
|
-
if (!app.version) {
|
|
1886
|
-
const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
|
|
1887
|
-
onProgress?.({
|
|
1888
|
-
type: "app_processing_error",
|
|
1889
|
-
app: app.key,
|
|
1890
|
-
error: errorMessage
|
|
1891
|
-
});
|
|
1892
|
-
throw new ZapierValidationError(errorMessage, {
|
|
1893
|
-
details: {
|
|
1894
|
-
appKey: app.key,
|
|
1895
|
-
implementationId: app.implementation_id
|
|
1896
|
-
}
|
|
1897
|
-
});
|
|
1812
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
1813
|
+
if (apps.length === 0) {
|
|
1814
|
+
return result;
|
|
1815
|
+
}
|
|
1816
|
+
const connections = [];
|
|
1817
|
+
if (connectionIds && connectionIds.length > 0) {
|
|
1818
|
+
onProgress?.({
|
|
1819
|
+
type: "connections_lookup_start",
|
|
1820
|
+
count: connectionIds.length
|
|
1821
|
+
});
|
|
1822
|
+
const connectionsIterable = sdk2.listConnections({ connections: connectionIds }).items();
|
|
1823
|
+
for await (const connection of connectionsIterable) {
|
|
1824
|
+
connections.push(connection);
|
|
1898
1825
|
}
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1826
|
+
onProgress?.({
|
|
1827
|
+
type: "connections_lookup_complete",
|
|
1828
|
+
count: connections.length
|
|
1829
|
+
});
|
|
1830
|
+
}
|
|
1831
|
+
if (!skipWrite && resolvedTypesOutput) {
|
|
1832
|
+
await mkdir(resolvedTypesOutput, { recursive: true });
|
|
1833
|
+
}
|
|
1834
|
+
if (!skipWrite) {
|
|
1835
|
+
result.writtenFiles = {};
|
|
1836
|
+
}
|
|
1837
|
+
for (const app of apps) {
|
|
1838
|
+
onProgress?.({
|
|
1839
|
+
type: "app_processing_start",
|
|
1840
|
+
app: app.key,
|
|
1841
|
+
slug: app.slug
|
|
1842
|
+
});
|
|
1843
|
+
try {
|
|
1844
|
+
if (!app.version) {
|
|
1845
|
+
const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
|
|
1906
1846
|
onProgress?.({
|
|
1907
|
-
type: "
|
|
1847
|
+
type: "app_processing_error",
|
|
1908
1848
|
app: app.key,
|
|
1909
|
-
|
|
1910
|
-
connectionTitle: matchingConnection.title || ""
|
|
1849
|
+
error: errorMessage
|
|
1911
1850
|
});
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1851
|
+
throw new ZapierValidationError(errorMessage, {
|
|
1852
|
+
details: {
|
|
1853
|
+
appKey: app.key,
|
|
1854
|
+
implementationId: app.implementation_id
|
|
1855
|
+
}
|
|
1916
1856
|
});
|
|
1917
1857
|
}
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1858
|
+
let connectionId;
|
|
1859
|
+
if (connections.length > 0) {
|
|
1860
|
+
const matchingConnection = connections.find(
|
|
1861
|
+
(conn) => conn.app_key === app.key
|
|
1862
|
+
);
|
|
1863
|
+
if (matchingConnection) {
|
|
1864
|
+
connectionId = matchingConnection.id;
|
|
1865
|
+
onProgress?.({
|
|
1866
|
+
type: "connection_matched",
|
|
1867
|
+
app: app.key,
|
|
1868
|
+
connectionId: matchingConnection.id,
|
|
1869
|
+
connectionTitle: matchingConnection.title || ""
|
|
1870
|
+
});
|
|
1871
|
+
} else {
|
|
1872
|
+
onProgress?.({
|
|
1873
|
+
type: "connection_not_matched",
|
|
1874
|
+
app: app.key
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
const manifestKey = getManifestKey(app);
|
|
1879
|
+
const generator = new AstTypeGenerator();
|
|
1880
|
+
const typeDefinitionString = await generator.generateTypes({
|
|
1881
|
+
app,
|
|
1882
|
+
connectionId,
|
|
1883
|
+
sdk: sdk2
|
|
1884
|
+
});
|
|
1885
|
+
result.typeDefinitions[manifestKey] = typeDefinitionString;
|
|
1936
1886
|
onProgress?.({
|
|
1937
|
-
type: "
|
|
1887
|
+
type: "type_generated",
|
|
1938
1888
|
manifestKey,
|
|
1939
|
-
|
|
1889
|
+
sizeBytes: typeDefinitionString.length
|
|
1940
1890
|
});
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
throw error;
|
|
1955
|
-
} else {
|
|
1956
|
-
throw new ZapierUnknownError(errorMessage, {
|
|
1957
|
-
cause: error
|
|
1958
|
-
// Works for both Error and non-Error
|
|
1891
|
+
if (!skipWrite && resolvedTypesOutput && result.writtenFiles) {
|
|
1892
|
+
const filePath = join(resolvedTypesOutput, `${manifestKey}.d.ts`);
|
|
1893
|
+
await writeFile(filePath, typeDefinitionString, "utf8");
|
|
1894
|
+
result.writtenFiles[manifestKey] = filePath;
|
|
1895
|
+
onProgress?.({ type: "file_written", manifestKey, filePath });
|
|
1896
|
+
}
|
|
1897
|
+
onProgress?.({ type: "app_processing_complete", app: app.key });
|
|
1898
|
+
} catch (error) {
|
|
1899
|
+
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
1900
|
+
onProgress?.({
|
|
1901
|
+
type: "app_processing_error",
|
|
1902
|
+
app: app.key,
|
|
1903
|
+
error: errorMessage
|
|
1959
1904
|
});
|
|
1905
|
+
if (error instanceof ZapierValidationError) {
|
|
1906
|
+
throw error;
|
|
1907
|
+
}
|
|
1908
|
+
throw new ZapierUnknownError(errorMessage, { cause: error });
|
|
1960
1909
|
}
|
|
1961
1910
|
}
|
|
1911
|
+
return result;
|
|
1962
1912
|
}
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
return {
|
|
1966
|
-
generateAppTypes,
|
|
1967
|
-
context: {
|
|
1968
|
-
meta: {
|
|
1969
|
-
generateAppTypes: {
|
|
1970
|
-
categories: ["utility"],
|
|
1971
|
-
inputSchema: GenerateAppTypesSchema
|
|
1972
|
-
}
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
};
|
|
1976
|
-
};
|
|
1913
|
+
})
|
|
1914
|
+
);
|
|
1977
1915
|
var BuildManifestSchema = z.object({
|
|
1978
1916
|
apps: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
1979
1917
|
"One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello')"
|
|
@@ -1989,86 +1927,80 @@ var BuildManifestSchema = z.object({
|
|
|
1989
1927
|
);
|
|
1990
1928
|
|
|
1991
1929
|
// src/plugins/buildManifest/index.ts
|
|
1992
|
-
var buildManifestPlugin = (
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
type: "manifest_entry_built",
|
|
2022
|
-
app: app.key,
|
|
2023
|
-
manifestKey: manifestEntry.implementationName,
|
|
2024
|
-
version: manifestEntry.version || ""
|
|
2025
|
-
});
|
|
2026
|
-
const { key: updatedManifestKey, manifest } = await sdk.context.updateManifestEntry({
|
|
2027
|
-
appKey: app.key,
|
|
2028
|
-
entry: manifestEntry,
|
|
2029
|
-
configPath,
|
|
2030
|
-
skipWrite,
|
|
2031
|
-
manifest: updatedManifest
|
|
2032
|
-
});
|
|
2033
|
-
updatedManifest = manifest;
|
|
2034
|
-
onProgress?.({
|
|
2035
|
-
type: "manifest_updated",
|
|
2036
|
-
app: app.key,
|
|
2037
|
-
manifestKey: updatedManifestKey,
|
|
2038
|
-
version: manifestEntry.version || ""
|
|
2039
|
-
});
|
|
2040
|
-
onProgress?.({ type: "app_processing_complete", app: app.key });
|
|
2041
|
-
} catch (error) {
|
|
2042
|
-
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
1930
|
+
var buildManifestPlugin = definePlugin(
|
|
1931
|
+
(sdk) => createPluginMethod(sdk, {
|
|
1932
|
+
name: "buildManifest",
|
|
1933
|
+
categories: ["utility"],
|
|
1934
|
+
// Cast: BuildManifestSchema validates JSON-serializable fields only.
|
|
1935
|
+
// BuildManifestOptions adds an `onProgress` callback that rides through
|
|
1936
|
+
// `createFunction`'s passthrough spread at runtime; this widens TInput
|
|
1937
|
+
// so the handler can read it.
|
|
1938
|
+
inputSchema: BuildManifestSchema,
|
|
1939
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
1940
|
+
const {
|
|
1941
|
+
apps: appKeys,
|
|
1942
|
+
skipWrite = false,
|
|
1943
|
+
configPath,
|
|
1944
|
+
onProgress
|
|
1945
|
+
} = options;
|
|
1946
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
1947
|
+
const appsIterable = sdk2.listApps({ apps: appKeys }).items();
|
|
1948
|
+
const apps = [];
|
|
1949
|
+
for await (const app of appsIterable) {
|
|
1950
|
+
apps.push(app);
|
|
1951
|
+
onProgress?.({ type: "app_found", app });
|
|
1952
|
+
}
|
|
1953
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
1954
|
+
if (apps.length === 0) {
|
|
1955
|
+
return {};
|
|
1956
|
+
}
|
|
1957
|
+
let updatedManifest;
|
|
1958
|
+
for (const app of apps) {
|
|
2043
1959
|
onProgress?.({
|
|
2044
|
-
type: "
|
|
1960
|
+
type: "app_processing_start",
|
|
2045
1961
|
app: app.key,
|
|
2046
|
-
|
|
1962
|
+
slug: app.slug
|
|
2047
1963
|
});
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
1964
|
+
try {
|
|
1965
|
+
const manifestEntry = createManifestEntry(app);
|
|
1966
|
+
onProgress?.({
|
|
1967
|
+
type: "manifest_entry_built",
|
|
1968
|
+
app: app.key,
|
|
1969
|
+
manifestKey: manifestEntry.implementationName,
|
|
1970
|
+
version: manifestEntry.version || ""
|
|
2054
1971
|
});
|
|
1972
|
+
const { key: updatedManifestKey, manifest } = await sdk2.context.updateManifestEntry({
|
|
1973
|
+
appKey: app.key,
|
|
1974
|
+
entry: manifestEntry,
|
|
1975
|
+
configPath,
|
|
1976
|
+
skipWrite,
|
|
1977
|
+
manifest: updatedManifest
|
|
1978
|
+
});
|
|
1979
|
+
updatedManifest = manifest;
|
|
1980
|
+
onProgress?.({
|
|
1981
|
+
type: "manifest_updated",
|
|
1982
|
+
app: app.key,
|
|
1983
|
+
manifestKey: updatedManifestKey,
|
|
1984
|
+
version: manifestEntry.version || ""
|
|
1985
|
+
});
|
|
1986
|
+
onProgress?.({ type: "app_processing_complete", app: app.key });
|
|
1987
|
+
} catch (error) {
|
|
1988
|
+
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
1989
|
+
onProgress?.({
|
|
1990
|
+
type: "app_processing_error",
|
|
1991
|
+
app: app.key,
|
|
1992
|
+
error: errorMessage
|
|
1993
|
+
});
|
|
1994
|
+
if (error instanceof ZapierValidationError) {
|
|
1995
|
+
throw error;
|
|
1996
|
+
}
|
|
1997
|
+
throw new ZapierUnknownError(errorMessage, { cause: error });
|
|
2055
1998
|
}
|
|
2056
1999
|
}
|
|
2000
|
+
return { manifest: updatedManifest };
|
|
2057
2001
|
}
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
return {
|
|
2061
|
-
buildManifest,
|
|
2062
|
-
context: {
|
|
2063
|
-
meta: {
|
|
2064
|
-
buildManifest: {
|
|
2065
|
-
categories: ["utility"],
|
|
2066
|
-
inputSchema: BuildManifestSchema
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
}
|
|
2070
|
-
};
|
|
2071
|
-
};
|
|
2002
|
+
})
|
|
2003
|
+
);
|
|
2072
2004
|
var FeedbackSchema = z.object({
|
|
2073
2005
|
feedback: z.string().describe(
|
|
2074
2006
|
"Your feedback on the Zapier SDK. Describe what worked well, what was frustrating, or any suggestions."
|
|
@@ -2102,37 +2034,31 @@ async function postWithRetry({
|
|
|
2102
2034
|
}
|
|
2103
2035
|
return response;
|
|
2104
2036
|
}
|
|
2105
|
-
var feedbackPlugin = (
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
feedback: {
|
|
2126
|
-
categories: ["utility"],
|
|
2127
|
-
inputSchema: FeedbackSchema,
|
|
2128
|
-
resolvers: {
|
|
2129
|
-
feedback: feedbackResolver
|
|
2130
|
-
}
|
|
2131
|
-
}
|
|
2037
|
+
var feedbackPlugin = definePlugin(
|
|
2038
|
+
(sdk) => createPluginMethod(sdk, {
|
|
2039
|
+
name: "feedback",
|
|
2040
|
+
categories: ["utility"],
|
|
2041
|
+
inputSchema: FeedbackSchema,
|
|
2042
|
+
resolvers: { feedback: feedbackResolver },
|
|
2043
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
2044
|
+
const user = await getLoggedInUser();
|
|
2045
|
+
const body = JSON.stringify({
|
|
2046
|
+
email: user.email,
|
|
2047
|
+
customuser_id: user.customUserId,
|
|
2048
|
+
feedback: options.feedback
|
|
2049
|
+
});
|
|
2050
|
+
const response = await postWithRetry({
|
|
2051
|
+
body,
|
|
2052
|
+
attemptsLeft: MAX_RETRIES
|
|
2053
|
+
});
|
|
2054
|
+
if (sdk2.context.options?.debug) {
|
|
2055
|
+
const text = await response.text();
|
|
2056
|
+
console.error("[debug] Webhook response:", text);
|
|
2132
2057
|
}
|
|
2058
|
+
return "Thank you for your feedback!";
|
|
2133
2059
|
}
|
|
2134
|
-
}
|
|
2135
|
-
|
|
2060
|
+
})
|
|
2061
|
+
);
|
|
2136
2062
|
var CurlSchema = z.object({
|
|
2137
2063
|
url: z.string().describe("Request URL"),
|
|
2138
2064
|
request: z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional().describe("HTTP method (defaults to GET, or POST if data is provided)"),
|
|
@@ -2308,7 +2234,7 @@ async function buildFormData(formArgs, formStringArgs) {
|
|
|
2308
2234
|
}
|
|
2309
2235
|
|
|
2310
2236
|
// src/plugins/curl/index.ts
|
|
2311
|
-
var curlPlugin = (sdk) => {
|
|
2237
|
+
var curlPlugin = definePlugin((sdk) => {
|
|
2312
2238
|
async function curl(options) {
|
|
2313
2239
|
const {
|
|
2314
2240
|
url: rawUrl,
|
|
@@ -2551,30 +2477,25 @@ ${Array.from(
|
|
|
2551
2477
|
}
|
|
2552
2478
|
}
|
|
2553
2479
|
};
|
|
2554
|
-
};
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
...sdk.context.meta.fetch.categories || [],
|
|
2568
|
-
"deprecated"
|
|
2569
|
-
],
|
|
2570
|
-
deprecation: {
|
|
2571
|
-
message: "This command is deprecated and will be removed soon. Use `curl` instead. Learn more: https://docs.zapier.com/sdk/cli-reference#curl"
|
|
2572
|
-
}
|
|
2480
|
+
});
|
|
2481
|
+
var cliOverridesPlugin = definePlugin(
|
|
2482
|
+
(sdk) => {
|
|
2483
|
+
const meta = {};
|
|
2484
|
+
if (sdk.context.meta.fetch) {
|
|
2485
|
+
meta.fetch = {
|
|
2486
|
+
...sdk.context.meta.fetch,
|
|
2487
|
+
categories: [
|
|
2488
|
+
...sdk.context.meta.fetch.categories || [],
|
|
2489
|
+
"deprecated"
|
|
2490
|
+
],
|
|
2491
|
+
deprecation: {
|
|
2492
|
+
message: "This command is deprecated and will be removed soon. Use `curl` instead. Learn more: https://docs.zapier.com/sdk/cli-reference#curl"
|
|
2573
2493
|
}
|
|
2574
|
-
}
|
|
2494
|
+
};
|
|
2575
2495
|
}
|
|
2576
|
-
|
|
2577
|
-
}
|
|
2496
|
+
return { context: { meta } };
|
|
2497
|
+
}
|
|
2498
|
+
);
|
|
2578
2499
|
var TEMPLATES = ["basic"];
|
|
2579
2500
|
var InitSchema = z.object({
|
|
2580
2501
|
projectName: z.string().min(1).describe("Name of the project directory to create"),
|
|
@@ -2986,71 +2907,65 @@ function displaySummaryAndNextSteps({
|
|
|
2986
2907
|
}
|
|
2987
2908
|
|
|
2988
2909
|
// src/plugins/init/index.ts
|
|
2989
|
-
var initPlugin = (
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
);
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
}
|
|
3029
|
-
displaySummaryAndNextSteps({
|
|
3030
|
-
projectName,
|
|
3031
|
-
steps,
|
|
3032
|
-
completedSetupStepIds,
|
|
3033
|
-
packageManager
|
|
3034
|
-
});
|
|
3035
|
-
}, InitSchema);
|
|
3036
|
-
return {
|
|
3037
|
-
init,
|
|
3038
|
-
context: {
|
|
3039
|
-
meta: {
|
|
3040
|
-
init: {
|
|
3041
|
-
categories: ["utility"],
|
|
3042
|
-
inputSchema: InitSchema,
|
|
3043
|
-
supportsJsonOutput: false
|
|
3044
|
-
}
|
|
2910
|
+
var initPlugin = definePlugin(
|
|
2911
|
+
(sdk) => createPluginMethod(sdk, {
|
|
2912
|
+
name: "init",
|
|
2913
|
+
categories: ["utility"],
|
|
2914
|
+
inputSchema: InitSchema,
|
|
2915
|
+
supportsJsonOutput: false,
|
|
2916
|
+
handler: async ({ options }) => {
|
|
2917
|
+
const { projectName: rawName, skipPrompts = false } = options;
|
|
2918
|
+
const cwd = process.cwd();
|
|
2919
|
+
const { projectName, projectDir } = validateInitOptions({ rawName, cwd });
|
|
2920
|
+
const displayHooks = createConsoleDisplayHooks();
|
|
2921
|
+
const packageManagerInfo = detectPackageManager(cwd);
|
|
2922
|
+
if (packageManagerInfo.name === "unknown") {
|
|
2923
|
+
displayHooks.onWarn(
|
|
2924
|
+
"Could not detect package manager, defaulting to npm."
|
|
2925
|
+
);
|
|
2926
|
+
}
|
|
2927
|
+
const packageManager = packageManagerInfo.name === "unknown" ? "npm" : packageManagerInfo.name;
|
|
2928
|
+
const steps = getInitSteps({
|
|
2929
|
+
projectDir,
|
|
2930
|
+
projectName,
|
|
2931
|
+
packageManager,
|
|
2932
|
+
displayHooks
|
|
2933
|
+
});
|
|
2934
|
+
const completedSetupStepIds = [];
|
|
2935
|
+
for (let i = 0; i < steps.length; i++) {
|
|
2936
|
+
const step = steps[i];
|
|
2937
|
+
const succeeded = await withInterruptCleanup(
|
|
2938
|
+
step.cleanup,
|
|
2939
|
+
() => runStep({
|
|
2940
|
+
step,
|
|
2941
|
+
stepNumber: i + 1,
|
|
2942
|
+
totalSteps: steps.length,
|
|
2943
|
+
skipPrompts,
|
|
2944
|
+
displayHooks
|
|
2945
|
+
})
|
|
2946
|
+
);
|
|
2947
|
+
if (!succeeded) break;
|
|
2948
|
+
completedSetupStepIds.push(step.id);
|
|
3045
2949
|
}
|
|
2950
|
+
if (completedSetupStepIds.length === 0) {
|
|
2951
|
+
throw new ZapierCliExitError(
|
|
2952
|
+
"Project setup failed \u2014 no steps completed."
|
|
2953
|
+
);
|
|
2954
|
+
}
|
|
2955
|
+
displaySummaryAndNextSteps({
|
|
2956
|
+
projectName,
|
|
2957
|
+
steps,
|
|
2958
|
+
completedSetupStepIds,
|
|
2959
|
+
packageManager
|
|
2960
|
+
});
|
|
3046
2961
|
}
|
|
3047
|
-
}
|
|
3048
|
-
|
|
2962
|
+
})
|
|
2963
|
+
);
|
|
3049
2964
|
|
|
3050
2965
|
// package.json with { type: 'json' }
|
|
3051
2966
|
var package_default = {
|
|
3052
2967
|
name: "@zapier/zapier-sdk-cli",
|
|
3053
|
-
version: "0.43.
|
|
2968
|
+
version: "0.43.3"};
|
|
3054
2969
|
|
|
3055
2970
|
// src/sdk.ts
|
|
3056
2971
|
injectCliLogin(login_exports);
|
|
@@ -3064,7 +2979,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
3064
2979
|
|
|
3065
2980
|
// package.json
|
|
3066
2981
|
var package_default2 = {
|
|
3067
|
-
version: "0.43.
|
|
2982
|
+
version: "0.43.3"};
|
|
3068
2983
|
|
|
3069
2984
|
// src/telemetry/builders.ts
|
|
3070
2985
|
function createCliBaseEvent(context = {}) {
|