@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/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command, CommanderError, Option } from 'commander';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import {
|
|
4
|
+
import { definePlugin, createPluginMethod, buildApplicationLifecycleEvent, OutputPropertySchema, DEFAULT_CONFIG_PATH, ZapierValidationError, ZapierUnknownError, injectCliLogin, BaseSdkOptionsSchema, isCredentialsObject, batch, toSnakeCase, createZapierSdk, ZapierError, isPositional, runWithTelemetryContext, buildCapabilityMessage, formatErrorMessage, getOsInfo, getPlatformVersions, getCiPlatform, isCi, getReleaseId, getCurrentTimestamp, generateEventId } from '@zapier/zapier-sdk';
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
6
|
import chalk7 from 'chalk';
|
|
7
7
|
import ora from 'ora';
|
|
@@ -9,9 +9,9 @@ import util from 'util';
|
|
|
9
9
|
import wrapAnsi from 'wrap-ansi';
|
|
10
10
|
import Conf from 'conf';
|
|
11
11
|
import * as fs from 'fs';
|
|
12
|
-
import {
|
|
12
|
+
import { promises, createWriteStream, existsSync, readdirSync, rmSync, mkdirSync, writeFileSync, copyFileSync, readFileSync } from 'fs';
|
|
13
13
|
import * as jwt from 'jsonwebtoken';
|
|
14
|
-
import {
|
|
14
|
+
import { getPassword, getKeyring, setPassword, deletePassword } from 'cross-keychain';
|
|
15
15
|
import crypto, { createHash } from 'crypto';
|
|
16
16
|
import * as path from 'path';
|
|
17
17
|
import { resolve, join, dirname, basename, relative, extname } from 'path';
|
|
@@ -1072,7 +1072,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
|
|
|
1072
1072
|
|
|
1073
1073
|
// package.json
|
|
1074
1074
|
var package_default = {
|
|
1075
|
-
version: "0.43.
|
|
1075
|
+
version: "0.43.3"};
|
|
1076
1076
|
|
|
1077
1077
|
// src/telemetry/builders.ts
|
|
1078
1078
|
function createCliBaseEvent(context = {}) {
|
|
@@ -3057,85 +3057,65 @@ function toPkceCredentials(credentials2) {
|
|
|
3057
3057
|
}
|
|
3058
3058
|
return void 0;
|
|
3059
3059
|
}
|
|
3060
|
-
var loginPlugin = (
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
credentials: pkceCredentials
|
|
3071
|
-
});
|
|
3072
|
-
const user = await getLoggedInUser();
|
|
3073
|
-
sdk2.context.eventEmission.emit(
|
|
3074
|
-
"platform.sdk.ApplicationLifecycleEvent",
|
|
3075
|
-
buildApplicationLifecycleEvent(
|
|
3076
|
-
{ lifecycle_event_type: "login_success" },
|
|
3077
|
-
{ customuser_id: user.customUserId, account_id: user.accountId }
|
|
3078
|
-
)
|
|
3079
|
-
);
|
|
3080
|
-
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
3081
|
-
};
|
|
3082
|
-
return {
|
|
3083
|
-
login: loginFn,
|
|
3084
|
-
context: {
|
|
3085
|
-
meta: {
|
|
3086
|
-
login: {
|
|
3087
|
-
categories: ["account"],
|
|
3088
|
-
inputSchema: LoginSchema,
|
|
3089
|
-
supportsJsonOutput: false
|
|
3090
|
-
}
|
|
3060
|
+
var loginPlugin = definePlugin(
|
|
3061
|
+
(sdk2) => createPluginMethod(sdk2, {
|
|
3062
|
+
name: "login",
|
|
3063
|
+
categories: ["account"],
|
|
3064
|
+
inputSchema: LoginSchema,
|
|
3065
|
+
supportsJsonOutput: false,
|
|
3066
|
+
handler: async ({ sdk: sdk3, options }) => {
|
|
3067
|
+
const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
|
|
3068
|
+
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
3069
|
+
throw new Error("Timeout must be a positive number");
|
|
3091
3070
|
}
|
|
3071
|
+
const resolvedCredentials = await sdk3.context.resolveCredentials();
|
|
3072
|
+
const pkceCredentials = toPkceCredentials(resolvedCredentials);
|
|
3073
|
+
await login_default({
|
|
3074
|
+
timeoutMs: timeoutSeconds * 1e3,
|
|
3075
|
+
credentials: pkceCredentials
|
|
3076
|
+
});
|
|
3077
|
+
const user = await getLoggedInUser();
|
|
3078
|
+
sdk3.context.eventEmission.emit(
|
|
3079
|
+
"platform.sdk.ApplicationLifecycleEvent",
|
|
3080
|
+
buildApplicationLifecycleEvent(
|
|
3081
|
+
{ lifecycle_event_type: "login_success" },
|
|
3082
|
+
{ customuser_id: user.customUserId, account_id: user.accountId }
|
|
3083
|
+
)
|
|
3084
|
+
);
|
|
3085
|
+
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
3092
3086
|
}
|
|
3093
|
-
}
|
|
3094
|
-
|
|
3087
|
+
})
|
|
3088
|
+
);
|
|
3095
3089
|
var LogoutSchema = z.object({}).describe("Log out of your Zapier account");
|
|
3096
3090
|
|
|
3097
3091
|
// src/plugins/logout/index.ts
|
|
3098
|
-
var
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
categories: ["account"],
|
|
3108
|
-
inputSchema: LogoutSchema,
|
|
3109
|
-
supportsJsonOutput: false
|
|
3110
|
-
}
|
|
3092
|
+
var logoutPlugin = definePlugin(
|
|
3093
|
+
(sdk2) => createPluginMethod(sdk2, {
|
|
3094
|
+
name: "logout",
|
|
3095
|
+
categories: ["account"],
|
|
3096
|
+
inputSchema: LogoutSchema,
|
|
3097
|
+
supportsJsonOutput: false,
|
|
3098
|
+
handler: async () => {
|
|
3099
|
+
await logout();
|
|
3100
|
+
console.log("\u2705 Successfully logged out");
|
|
3111
3101
|
}
|
|
3112
|
-
}
|
|
3113
|
-
|
|
3102
|
+
})
|
|
3103
|
+
);
|
|
3114
3104
|
var McpSchema = z.object({
|
|
3115
3105
|
port: z.string().optional().describe("Port to listen on (for future HTTP transport)")
|
|
3116
3106
|
}).describe("Start MCP server for Zapier SDK");
|
|
3117
3107
|
|
|
3118
3108
|
// src/plugins/mcp/index.ts
|
|
3119
|
-
var mcpPlugin = (
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
}
|
|
3125
|
-
|
|
3126
|
-
}, McpSchema);
|
|
3127
|
-
return {
|
|
3128
|
-
mcp: mcpWithSdk,
|
|
3129
|
-
context: {
|
|
3130
|
-
meta: {
|
|
3131
|
-
mcp: {
|
|
3132
|
-
categories: ["utility"],
|
|
3133
|
-
inputSchema: McpSchema
|
|
3134
|
-
}
|
|
3135
|
-
}
|
|
3109
|
+
var mcpPlugin = definePlugin(
|
|
3110
|
+
(sdk2) => createPluginMethod(sdk2, {
|
|
3111
|
+
name: "mcp",
|
|
3112
|
+
categories: ["utility"],
|
|
3113
|
+
inputSchema: McpSchema,
|
|
3114
|
+
handler: async ({ sdk: sdk3, options }) => {
|
|
3115
|
+
await startMcpServer({ ...options, debug: sdk3.context.options?.debug });
|
|
3136
3116
|
}
|
|
3137
|
-
}
|
|
3138
|
-
|
|
3117
|
+
})
|
|
3118
|
+
);
|
|
3139
3119
|
var BundleCodeSchema = z.object({
|
|
3140
3120
|
input: z.string().min(1).describe("Input TypeScript file path to bundle"),
|
|
3141
3121
|
output: OutputPropertySchema.optional().describe(
|
|
@@ -3146,22 +3126,14 @@ var BundleCodeSchema = z.object({
|
|
|
3146
3126
|
target: z.string().optional().describe("ECMAScript target version"),
|
|
3147
3127
|
cjs: z.boolean().optional().describe("Output CommonJS format instead of ESM")
|
|
3148
3128
|
}).describe("Bundle TypeScript code into executable JavaScript");
|
|
3149
|
-
var bundleCodePlugin = (
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
bundleCode: {
|
|
3158
|
-
categories: ["utility", "deprecated"],
|
|
3159
|
-
inputSchema: BundleCodeSchema
|
|
3160
|
-
}
|
|
3161
|
-
}
|
|
3162
|
-
}
|
|
3163
|
-
};
|
|
3164
|
-
};
|
|
3129
|
+
var bundleCodePlugin = definePlugin(
|
|
3130
|
+
(sdk2) => createPluginMethod(sdk2, {
|
|
3131
|
+
name: "bundleCode",
|
|
3132
|
+
categories: ["utility", "deprecated"],
|
|
3133
|
+
inputSchema: BundleCodeSchema,
|
|
3134
|
+
handler: async ({ options }) => bundleCode(options)
|
|
3135
|
+
})
|
|
3136
|
+
);
|
|
3165
3137
|
var ZapierBundleError = class extends Error {
|
|
3166
3138
|
constructor(message, details, originalError) {
|
|
3167
3139
|
super(message);
|
|
@@ -3228,25 +3200,14 @@ async function bundleCode(options) {
|
|
|
3228
3200
|
}
|
|
3229
3201
|
}
|
|
3230
3202
|
var GetLoginConfigPathSchema = z.object({}).describe("Show the path to the login configuration file");
|
|
3231
|
-
var getLoginConfigPathPlugin = (
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
)
|
|
3238
|
-
|
|
3239
|
-
getLoginConfigPath: getLoginConfigPathWithSdk,
|
|
3240
|
-
context: {
|
|
3241
|
-
meta: {
|
|
3242
|
-
getLoginConfigPath: {
|
|
3243
|
-
categories: ["utility"],
|
|
3244
|
-
inputSchema: GetLoginConfigPathSchema
|
|
3245
|
-
}
|
|
3246
|
-
}
|
|
3247
|
-
}
|
|
3248
|
-
};
|
|
3249
|
-
};
|
|
3203
|
+
var getLoginConfigPathPlugin = definePlugin(
|
|
3204
|
+
(sdk2) => createPluginMethod(sdk2, {
|
|
3205
|
+
name: "getLoginConfigPath",
|
|
3206
|
+
categories: ["utility"],
|
|
3207
|
+
inputSchema: GetLoginConfigPathSchema,
|
|
3208
|
+
handler: async () => getConfigPath()
|
|
3209
|
+
})
|
|
3210
|
+
);
|
|
3250
3211
|
var AddSchema = z.object({
|
|
3251
3212
|
apps: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
3252
3213
|
"One or more app keys to add (e.g., 'slack', 'github', 'trello')"
|
|
@@ -3274,111 +3235,105 @@ async function detectTypesOutputDirectory() {
|
|
|
3274
3235
|
}
|
|
3275
3236
|
return "./zapier/apps/";
|
|
3276
3237
|
}
|
|
3277
|
-
var addPlugin = (
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
skipWrite: false,
|
|
3352
|
-
configPath,
|
|
3353
|
-
onProgress: handleManifestProgress
|
|
3354
|
-
});
|
|
3355
|
-
const typesResult = await sdk2.generateAppTypes({
|
|
3356
|
-
apps: appKeys,
|
|
3357
|
-
connections: connectionIds,
|
|
3358
|
-
skipWrite: false,
|
|
3359
|
-
typesOutputDirectory: resolvedTypesOutput,
|
|
3360
|
-
onProgress: handleTypesProgress
|
|
3361
|
-
});
|
|
3362
|
-
const results = manifestResult.manifest?.apps || {};
|
|
3363
|
-
const successfulApps = Object.keys(results).filter(
|
|
3364
|
-
(manifestKey) => typesResult.writtenFiles?.[manifestKey]
|
|
3365
|
-
);
|
|
3366
|
-
if (successfulApps.length > 0) {
|
|
3367
|
-
console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
|
|
3368
|
-
}
|
|
3369
|
-
}, AddSchema);
|
|
3370
|
-
return {
|
|
3371
|
-
add,
|
|
3372
|
-
context: {
|
|
3373
|
-
meta: {
|
|
3374
|
-
add: {
|
|
3375
|
-
categories: ["utility"],
|
|
3376
|
-
inputSchema: AddSchema
|
|
3238
|
+
var addPlugin = definePlugin(
|
|
3239
|
+
(sdk2) => createPluginMethod(sdk2, {
|
|
3240
|
+
name: "add",
|
|
3241
|
+
categories: ["utility"],
|
|
3242
|
+
inputSchema: AddSchema,
|
|
3243
|
+
handler: async ({ sdk: sdk3, options }) => {
|
|
3244
|
+
const {
|
|
3245
|
+
apps: appKeys,
|
|
3246
|
+
connections: connectionIds,
|
|
3247
|
+
configPath,
|
|
3248
|
+
typesOutput = await detectTypesOutputDirectory()
|
|
3249
|
+
} = options;
|
|
3250
|
+
const resolvedTypesOutput = resolve(typesOutput);
|
|
3251
|
+
console.log(`\u{1F4E6} Adding ${appKeys.length} app(s)...`);
|
|
3252
|
+
const appSlugAndKeyMap = /* @__PURE__ */ new Map();
|
|
3253
|
+
const handleManifestProgress = (event) => {
|
|
3254
|
+
switch (event.type) {
|
|
3255
|
+
case "apps_lookup_start":
|
|
3256
|
+
console.log(`\u{1F4E6} Looking up ${event.count} app(s)...`);
|
|
3257
|
+
break;
|
|
3258
|
+
case "app_found":
|
|
3259
|
+
const displayName = event.app.slug ? `${event.app.slug} (${event.app.key})` : event.app.key;
|
|
3260
|
+
appSlugAndKeyMap.set(event.app.key, displayName);
|
|
3261
|
+
break;
|
|
3262
|
+
case "apps_lookup_complete":
|
|
3263
|
+
if (event.count === 0) {
|
|
3264
|
+
console.warn("\u26A0\uFE0F No apps found");
|
|
3265
|
+
}
|
|
3266
|
+
break;
|
|
3267
|
+
case "app_processing_start":
|
|
3268
|
+
const appName = event.slug ? `${event.slug} (${event.app})` : event.app;
|
|
3269
|
+
console.log(`\u{1F4E6} Adding ${appName}...`);
|
|
3270
|
+
break;
|
|
3271
|
+
case "manifest_updated":
|
|
3272
|
+
const appDisplay = appSlugAndKeyMap.get(event.app) || event.app;
|
|
3273
|
+
console.log(
|
|
3274
|
+
`\u{1F4DD} Locked ${appDisplay} to ${event.app}@${event.version} using key '${event.manifestKey}'`
|
|
3275
|
+
);
|
|
3276
|
+
break;
|
|
3277
|
+
case "app_processing_error":
|
|
3278
|
+
const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
|
|
3279
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
3280
|
+
break;
|
|
3281
|
+
}
|
|
3282
|
+
};
|
|
3283
|
+
const handleTypesProgress = (event) => {
|
|
3284
|
+
switch (event.type) {
|
|
3285
|
+
case "connections_lookup_start":
|
|
3286
|
+
console.log(`\u{1F510} Looking up ${event.count} connection(s)...`);
|
|
3287
|
+
break;
|
|
3288
|
+
case "connections_lookup_complete":
|
|
3289
|
+
console.log(`\u{1F510} Found ${event.count} connection(s)`);
|
|
3290
|
+
break;
|
|
3291
|
+
case "connection_matched":
|
|
3292
|
+
const appWithConnection = appSlugAndKeyMap.get(event.app) || event.app;
|
|
3293
|
+
console.log(
|
|
3294
|
+
`\u{1F510} Using connection ${event.connectionId} (${event.connectionTitle}) for ${appWithConnection}`
|
|
3295
|
+
);
|
|
3296
|
+
break;
|
|
3297
|
+
case "connection_not_matched":
|
|
3298
|
+
const appWithoutConnection = appSlugAndKeyMap.get(event.app) || event.app;
|
|
3299
|
+
console.warn(
|
|
3300
|
+
`\u26A0\uFE0F No matching connection found for ${appWithoutConnection}`
|
|
3301
|
+
);
|
|
3302
|
+
break;
|
|
3303
|
+
case "file_written":
|
|
3304
|
+
console.log(
|
|
3305
|
+
`\u{1F527} Generated types for ${event.manifestKey} at ${event.filePath}`
|
|
3306
|
+
);
|
|
3307
|
+
break;
|
|
3308
|
+
case "app_processing_error":
|
|
3309
|
+
const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
|
|
3310
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
3311
|
+
break;
|
|
3377
3312
|
}
|
|
3313
|
+
};
|
|
3314
|
+
const manifestResult = await sdk3.buildManifest({
|
|
3315
|
+
apps: appKeys,
|
|
3316
|
+
skipWrite: false,
|
|
3317
|
+
configPath,
|
|
3318
|
+
onProgress: handleManifestProgress
|
|
3319
|
+
});
|
|
3320
|
+
const typesResult = await sdk3.generateAppTypes({
|
|
3321
|
+
apps: appKeys,
|
|
3322
|
+
connections: connectionIds,
|
|
3323
|
+
skipWrite: false,
|
|
3324
|
+
typesOutputDirectory: resolvedTypesOutput,
|
|
3325
|
+
onProgress: handleTypesProgress
|
|
3326
|
+
});
|
|
3327
|
+
const results = manifestResult.manifest?.apps || {};
|
|
3328
|
+
const successfulApps = Object.keys(results).filter(
|
|
3329
|
+
(manifestKey) => typesResult.writtenFiles?.[manifestKey]
|
|
3330
|
+
);
|
|
3331
|
+
if (successfulApps.length > 0) {
|
|
3332
|
+
console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
|
|
3378
3333
|
}
|
|
3379
3334
|
}
|
|
3380
|
-
}
|
|
3381
|
-
|
|
3335
|
+
})
|
|
3336
|
+
);
|
|
3382
3337
|
var GenerateAppTypesSchema = z.object({
|
|
3383
3338
|
apps: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
3384
3339
|
"One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
|
|
@@ -3985,150 +3940,133 @@ function createManifestEntry(app) {
|
|
|
3985
3940
|
version: app.version
|
|
3986
3941
|
};
|
|
3987
3942
|
}
|
|
3988
|
-
var generateAppTypesPlugin = (
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
}
|
|
4012
|
-
const connections = [];
|
|
4013
|
-
if (connectionIds && connectionIds.length > 0) {
|
|
4014
|
-
onProgress?.({
|
|
4015
|
-
type: "connections_lookup_start",
|
|
4016
|
-
count: connectionIds.length
|
|
4017
|
-
});
|
|
4018
|
-
const connectionsIterable = sdk2.listConnections({ connections: connectionIds }).items();
|
|
4019
|
-
for await (const connection of connectionsIterable) {
|
|
4020
|
-
connections.push(connection);
|
|
3943
|
+
var generateAppTypesPlugin = definePlugin(
|
|
3944
|
+
(sdk2) => createPluginMethod(sdk2, {
|
|
3945
|
+
name: "generateAppTypes",
|
|
3946
|
+
categories: ["utility"],
|
|
3947
|
+
// Cast: schema validates JSON fields only; GenerateAppTypesOptions adds
|
|
3948
|
+
// the runtime-only `onProgress` callback (passthrough via createFunction).
|
|
3949
|
+
inputSchema: GenerateAppTypesSchema,
|
|
3950
|
+
handler: async ({ sdk: sdk3, options }) => {
|
|
3951
|
+
const {
|
|
3952
|
+
apps: appKeys,
|
|
3953
|
+
connections: connectionIds,
|
|
3954
|
+
skipWrite = false,
|
|
3955
|
+
typesOutputDirectory = await detectTypesOutputDirectory(),
|
|
3956
|
+
onProgress
|
|
3957
|
+
} = options;
|
|
3958
|
+
const resolvedTypesOutput = resolve(typesOutputDirectory);
|
|
3959
|
+
const result = { typeDefinitions: {} };
|
|
3960
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
3961
|
+
const appsIterable = sdk3.listApps({ apps: appKeys }).items();
|
|
3962
|
+
const apps = [];
|
|
3963
|
+
for await (const app of appsIterable) {
|
|
3964
|
+
apps.push(app);
|
|
3965
|
+
onProgress?.({ type: "app_found", app });
|
|
4021
3966
|
}
|
|
4022
|
-
onProgress?.({
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
}
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
type: "app_processing_start",
|
|
4036
|
-
app: app.key,
|
|
4037
|
-
slug: app.slug
|
|
4038
|
-
});
|
|
4039
|
-
try {
|
|
4040
|
-
if (!app.version) {
|
|
4041
|
-
const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
|
|
4042
|
-
onProgress?.({
|
|
4043
|
-
type: "app_processing_error",
|
|
4044
|
-
app: app.key,
|
|
4045
|
-
error: errorMessage
|
|
4046
|
-
});
|
|
4047
|
-
throw new ZapierValidationError(errorMessage, {
|
|
4048
|
-
details: {
|
|
4049
|
-
appKey: app.key,
|
|
4050
|
-
implementationId: app.implementation_id
|
|
4051
|
-
}
|
|
4052
|
-
});
|
|
3967
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
3968
|
+
if (apps.length === 0) {
|
|
3969
|
+
return result;
|
|
3970
|
+
}
|
|
3971
|
+
const connections = [];
|
|
3972
|
+
if (connectionIds && connectionIds.length > 0) {
|
|
3973
|
+
onProgress?.({
|
|
3974
|
+
type: "connections_lookup_start",
|
|
3975
|
+
count: connectionIds.length
|
|
3976
|
+
});
|
|
3977
|
+
const connectionsIterable = sdk3.listConnections({ connections: connectionIds }).items();
|
|
3978
|
+
for await (const connection of connectionsIterable) {
|
|
3979
|
+
connections.push(connection);
|
|
4053
3980
|
}
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
3981
|
+
onProgress?.({
|
|
3982
|
+
type: "connections_lookup_complete",
|
|
3983
|
+
count: connections.length
|
|
3984
|
+
});
|
|
3985
|
+
}
|
|
3986
|
+
if (!skipWrite && resolvedTypesOutput) {
|
|
3987
|
+
await mkdir(resolvedTypesOutput, { recursive: true });
|
|
3988
|
+
}
|
|
3989
|
+
if (!skipWrite) {
|
|
3990
|
+
result.writtenFiles = {};
|
|
3991
|
+
}
|
|
3992
|
+
for (const app of apps) {
|
|
3993
|
+
onProgress?.({
|
|
3994
|
+
type: "app_processing_start",
|
|
3995
|
+
app: app.key,
|
|
3996
|
+
slug: app.slug
|
|
3997
|
+
});
|
|
3998
|
+
try {
|
|
3999
|
+
if (!app.version) {
|
|
4000
|
+
const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
|
|
4061
4001
|
onProgress?.({
|
|
4062
|
-
type: "
|
|
4002
|
+
type: "app_processing_error",
|
|
4063
4003
|
app: app.key,
|
|
4064
|
-
|
|
4065
|
-
connectionTitle: matchingConnection.title || ""
|
|
4004
|
+
error: errorMessage
|
|
4066
4005
|
});
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4006
|
+
throw new ZapierValidationError(errorMessage, {
|
|
4007
|
+
details: {
|
|
4008
|
+
appKey: app.key,
|
|
4009
|
+
implementationId: app.implementation_id
|
|
4010
|
+
}
|
|
4071
4011
|
});
|
|
4072
4012
|
}
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4013
|
+
let connectionId;
|
|
4014
|
+
if (connections.length > 0) {
|
|
4015
|
+
const matchingConnection = connections.find(
|
|
4016
|
+
(conn) => conn.app_key === app.key
|
|
4017
|
+
);
|
|
4018
|
+
if (matchingConnection) {
|
|
4019
|
+
connectionId = matchingConnection.id;
|
|
4020
|
+
onProgress?.({
|
|
4021
|
+
type: "connection_matched",
|
|
4022
|
+
app: app.key,
|
|
4023
|
+
connectionId: matchingConnection.id,
|
|
4024
|
+
connectionTitle: matchingConnection.title || ""
|
|
4025
|
+
});
|
|
4026
|
+
} else {
|
|
4027
|
+
onProgress?.({
|
|
4028
|
+
type: "connection_not_matched",
|
|
4029
|
+
app: app.key
|
|
4030
|
+
});
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
const manifestKey = getManifestKey(app);
|
|
4034
|
+
const generator = new AstTypeGenerator();
|
|
4035
|
+
const typeDefinitionString = await generator.generateTypes({
|
|
4036
|
+
app,
|
|
4037
|
+
connectionId,
|
|
4038
|
+
sdk: sdk3
|
|
4039
|
+
});
|
|
4040
|
+
result.typeDefinitions[manifestKey] = typeDefinitionString;
|
|
4091
4041
|
onProgress?.({
|
|
4092
|
-
type: "
|
|
4042
|
+
type: "type_generated",
|
|
4093
4043
|
manifestKey,
|
|
4094
|
-
|
|
4044
|
+
sizeBytes: typeDefinitionString.length
|
|
4095
4045
|
});
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
throw error;
|
|
4110
|
-
} else {
|
|
4111
|
-
throw new ZapierUnknownError(errorMessage, {
|
|
4112
|
-
cause: error
|
|
4113
|
-
// Works for both Error and non-Error
|
|
4046
|
+
if (!skipWrite && resolvedTypesOutput && result.writtenFiles) {
|
|
4047
|
+
const filePath = join(resolvedTypesOutput, `${manifestKey}.d.ts`);
|
|
4048
|
+
await writeFile(filePath, typeDefinitionString, "utf8");
|
|
4049
|
+
result.writtenFiles[manifestKey] = filePath;
|
|
4050
|
+
onProgress?.({ type: "file_written", manifestKey, filePath });
|
|
4051
|
+
}
|
|
4052
|
+
onProgress?.({ type: "app_processing_complete", app: app.key });
|
|
4053
|
+
} catch (error) {
|
|
4054
|
+
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
4055
|
+
onProgress?.({
|
|
4056
|
+
type: "app_processing_error",
|
|
4057
|
+
app: app.key,
|
|
4058
|
+
error: errorMessage
|
|
4114
4059
|
});
|
|
4060
|
+
if (error instanceof ZapierValidationError) {
|
|
4061
|
+
throw error;
|
|
4062
|
+
}
|
|
4063
|
+
throw new ZapierUnknownError(errorMessage, { cause: error });
|
|
4115
4064
|
}
|
|
4116
4065
|
}
|
|
4066
|
+
return result;
|
|
4117
4067
|
}
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
return {
|
|
4121
|
-
generateAppTypes,
|
|
4122
|
-
context: {
|
|
4123
|
-
meta: {
|
|
4124
|
-
generateAppTypes: {
|
|
4125
|
-
categories: ["utility"],
|
|
4126
|
-
inputSchema: GenerateAppTypesSchema
|
|
4127
|
-
}
|
|
4128
|
-
}
|
|
4129
|
-
}
|
|
4130
|
-
};
|
|
4131
|
-
};
|
|
4068
|
+
})
|
|
4069
|
+
);
|
|
4132
4070
|
var BuildManifestSchema = z.object({
|
|
4133
4071
|
apps: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
4134
4072
|
"One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello')"
|
|
@@ -4144,86 +4082,80 @@ var BuildManifestSchema = z.object({
|
|
|
4144
4082
|
);
|
|
4145
4083
|
|
|
4146
4084
|
// src/plugins/buildManifest/index.ts
|
|
4147
|
-
var buildManifestPlugin = (
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
type: "manifest_entry_built",
|
|
4177
|
-
app: app.key,
|
|
4178
|
-
manifestKey: manifestEntry.implementationName,
|
|
4179
|
-
version: manifestEntry.version || ""
|
|
4180
|
-
});
|
|
4181
|
-
const { key: updatedManifestKey, manifest } = await sdk2.context.updateManifestEntry({
|
|
4182
|
-
appKey: app.key,
|
|
4183
|
-
entry: manifestEntry,
|
|
4184
|
-
configPath,
|
|
4185
|
-
skipWrite,
|
|
4186
|
-
manifest: updatedManifest
|
|
4187
|
-
});
|
|
4188
|
-
updatedManifest = manifest;
|
|
4189
|
-
onProgress?.({
|
|
4190
|
-
type: "manifest_updated",
|
|
4191
|
-
app: app.key,
|
|
4192
|
-
manifestKey: updatedManifestKey,
|
|
4193
|
-
version: manifestEntry.version || ""
|
|
4194
|
-
});
|
|
4195
|
-
onProgress?.({ type: "app_processing_complete", app: app.key });
|
|
4196
|
-
} catch (error) {
|
|
4197
|
-
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
4085
|
+
var buildManifestPlugin = definePlugin(
|
|
4086
|
+
(sdk2) => createPluginMethod(sdk2, {
|
|
4087
|
+
name: "buildManifest",
|
|
4088
|
+
categories: ["utility"],
|
|
4089
|
+
// Cast: BuildManifestSchema validates JSON-serializable fields only.
|
|
4090
|
+
// BuildManifestOptions adds an `onProgress` callback that rides through
|
|
4091
|
+
// `createFunction`'s passthrough spread at runtime; this widens TInput
|
|
4092
|
+
// so the handler can read it.
|
|
4093
|
+
inputSchema: BuildManifestSchema,
|
|
4094
|
+
handler: async ({ sdk: sdk3, options }) => {
|
|
4095
|
+
const {
|
|
4096
|
+
apps: appKeys,
|
|
4097
|
+
skipWrite = false,
|
|
4098
|
+
configPath,
|
|
4099
|
+
onProgress
|
|
4100
|
+
} = options;
|
|
4101
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
4102
|
+
const appsIterable = sdk3.listApps({ apps: appKeys }).items();
|
|
4103
|
+
const apps = [];
|
|
4104
|
+
for await (const app of appsIterable) {
|
|
4105
|
+
apps.push(app);
|
|
4106
|
+
onProgress?.({ type: "app_found", app });
|
|
4107
|
+
}
|
|
4108
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
4109
|
+
if (apps.length === 0) {
|
|
4110
|
+
return {};
|
|
4111
|
+
}
|
|
4112
|
+
let updatedManifest;
|
|
4113
|
+
for (const app of apps) {
|
|
4198
4114
|
onProgress?.({
|
|
4199
|
-
type: "
|
|
4115
|
+
type: "app_processing_start",
|
|
4200
4116
|
app: app.key,
|
|
4201
|
-
|
|
4117
|
+
slug: app.slug
|
|
4202
4118
|
});
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4119
|
+
try {
|
|
4120
|
+
const manifestEntry = createManifestEntry(app);
|
|
4121
|
+
onProgress?.({
|
|
4122
|
+
type: "manifest_entry_built",
|
|
4123
|
+
app: app.key,
|
|
4124
|
+
manifestKey: manifestEntry.implementationName,
|
|
4125
|
+
version: manifestEntry.version || ""
|
|
4209
4126
|
});
|
|
4127
|
+
const { key: updatedManifestKey, manifest } = await sdk3.context.updateManifestEntry({
|
|
4128
|
+
appKey: app.key,
|
|
4129
|
+
entry: manifestEntry,
|
|
4130
|
+
configPath,
|
|
4131
|
+
skipWrite,
|
|
4132
|
+
manifest: updatedManifest
|
|
4133
|
+
});
|
|
4134
|
+
updatedManifest = manifest;
|
|
4135
|
+
onProgress?.({
|
|
4136
|
+
type: "manifest_updated",
|
|
4137
|
+
app: app.key,
|
|
4138
|
+
manifestKey: updatedManifestKey,
|
|
4139
|
+
version: manifestEntry.version || ""
|
|
4140
|
+
});
|
|
4141
|
+
onProgress?.({ type: "app_processing_complete", app: app.key });
|
|
4142
|
+
} catch (error) {
|
|
4143
|
+
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
4144
|
+
onProgress?.({
|
|
4145
|
+
type: "app_processing_error",
|
|
4146
|
+
app: app.key,
|
|
4147
|
+
error: errorMessage
|
|
4148
|
+
});
|
|
4149
|
+
if (error instanceof ZapierValidationError) {
|
|
4150
|
+
throw error;
|
|
4151
|
+
}
|
|
4152
|
+
throw new ZapierUnknownError(errorMessage, { cause: error });
|
|
4210
4153
|
}
|
|
4211
4154
|
}
|
|
4155
|
+
return { manifest: updatedManifest };
|
|
4212
4156
|
}
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
return {
|
|
4216
|
-
buildManifest,
|
|
4217
|
-
context: {
|
|
4218
|
-
meta: {
|
|
4219
|
-
buildManifest: {
|
|
4220
|
-
categories: ["utility"],
|
|
4221
|
-
inputSchema: BuildManifestSchema
|
|
4222
|
-
}
|
|
4223
|
-
}
|
|
4224
|
-
}
|
|
4225
|
-
};
|
|
4226
|
-
};
|
|
4157
|
+
})
|
|
4158
|
+
);
|
|
4227
4159
|
var FeedbackSchema = z.object({
|
|
4228
4160
|
feedback: z.string().describe(
|
|
4229
4161
|
"Your feedback on the Zapier SDK. Describe what worked well, what was frustrating, or any suggestions."
|
|
@@ -4257,37 +4189,31 @@ async function postWithRetry({
|
|
|
4257
4189
|
}
|
|
4258
4190
|
return response;
|
|
4259
4191
|
}
|
|
4260
|
-
var feedbackPlugin = (
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
feedback: {
|
|
4281
|
-
categories: ["utility"],
|
|
4282
|
-
inputSchema: FeedbackSchema,
|
|
4283
|
-
resolvers: {
|
|
4284
|
-
feedback: feedbackResolver
|
|
4285
|
-
}
|
|
4286
|
-
}
|
|
4192
|
+
var feedbackPlugin = definePlugin(
|
|
4193
|
+
(sdk2) => createPluginMethod(sdk2, {
|
|
4194
|
+
name: "feedback",
|
|
4195
|
+
categories: ["utility"],
|
|
4196
|
+
inputSchema: FeedbackSchema,
|
|
4197
|
+
resolvers: { feedback: feedbackResolver },
|
|
4198
|
+
handler: async ({ sdk: sdk3, options }) => {
|
|
4199
|
+
const user = await getLoggedInUser();
|
|
4200
|
+
const body = JSON.stringify({
|
|
4201
|
+
email: user.email,
|
|
4202
|
+
customuser_id: user.customUserId,
|
|
4203
|
+
feedback: options.feedback
|
|
4204
|
+
});
|
|
4205
|
+
const response = await postWithRetry({
|
|
4206
|
+
body,
|
|
4207
|
+
attemptsLeft: MAX_RETRIES
|
|
4208
|
+
});
|
|
4209
|
+
if (sdk3.context.options?.debug) {
|
|
4210
|
+
const text = await response.text();
|
|
4211
|
+
console.error("[debug] Webhook response:", text);
|
|
4287
4212
|
}
|
|
4213
|
+
return "Thank you for your feedback!";
|
|
4288
4214
|
}
|
|
4289
|
-
}
|
|
4290
|
-
|
|
4215
|
+
})
|
|
4216
|
+
);
|
|
4291
4217
|
var CurlSchema = z.object({
|
|
4292
4218
|
url: z.string().describe("Request URL"),
|
|
4293
4219
|
request: z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional().describe("HTTP method (defaults to GET, or POST if data is provided)"),
|
|
@@ -4463,7 +4389,7 @@ async function buildFormData(formArgs, formStringArgs) {
|
|
|
4463
4389
|
}
|
|
4464
4390
|
|
|
4465
4391
|
// src/plugins/curl/index.ts
|
|
4466
|
-
var curlPlugin = (sdk2) => {
|
|
4392
|
+
var curlPlugin = definePlugin((sdk2) => {
|
|
4467
4393
|
async function curl(options) {
|
|
4468
4394
|
const {
|
|
4469
4395
|
url: rawUrl,
|
|
@@ -4706,30 +4632,25 @@ ${Array.from(
|
|
|
4706
4632
|
}
|
|
4707
4633
|
}
|
|
4708
4634
|
};
|
|
4709
|
-
};
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
...sdk2.context.meta.fetch.categories || [],
|
|
4723
|
-
"deprecated"
|
|
4724
|
-
],
|
|
4725
|
-
deprecation: {
|
|
4726
|
-
message: "This command is deprecated and will be removed soon. Use `curl` instead. Learn more: https://docs.zapier.com/sdk/cli-reference#curl"
|
|
4727
|
-
}
|
|
4635
|
+
});
|
|
4636
|
+
var cliOverridesPlugin = definePlugin(
|
|
4637
|
+
(sdk2) => {
|
|
4638
|
+
const meta = {};
|
|
4639
|
+
if (sdk2.context.meta.fetch) {
|
|
4640
|
+
meta.fetch = {
|
|
4641
|
+
...sdk2.context.meta.fetch,
|
|
4642
|
+
categories: [
|
|
4643
|
+
...sdk2.context.meta.fetch.categories || [],
|
|
4644
|
+
"deprecated"
|
|
4645
|
+
],
|
|
4646
|
+
deprecation: {
|
|
4647
|
+
message: "This command is deprecated and will be removed soon. Use `curl` instead. Learn more: https://docs.zapier.com/sdk/cli-reference#curl"
|
|
4728
4648
|
}
|
|
4729
|
-
}
|
|
4649
|
+
};
|
|
4730
4650
|
}
|
|
4731
|
-
|
|
4732
|
-
}
|
|
4651
|
+
return { context: { meta } };
|
|
4652
|
+
}
|
|
4653
|
+
);
|
|
4733
4654
|
var TEMPLATES = ["basic"];
|
|
4734
4655
|
var InitSchema = z.object({
|
|
4735
4656
|
projectName: z.string().min(1).describe("Name of the project directory to create"),
|
|
@@ -5168,71 +5089,65 @@ function displaySummaryAndNextSteps({
|
|
|
5168
5089
|
}
|
|
5169
5090
|
|
|
5170
5091
|
// src/plugins/init/index.ts
|
|
5171
|
-
var initPlugin = (
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
);
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
}
|
|
5211
|
-
displaySummaryAndNextSteps({
|
|
5212
|
-
projectName,
|
|
5213
|
-
steps,
|
|
5214
|
-
completedSetupStepIds,
|
|
5215
|
-
packageManager
|
|
5216
|
-
});
|
|
5217
|
-
}, InitSchema);
|
|
5218
|
-
return {
|
|
5219
|
-
init,
|
|
5220
|
-
context: {
|
|
5221
|
-
meta: {
|
|
5222
|
-
init: {
|
|
5223
|
-
categories: ["utility"],
|
|
5224
|
-
inputSchema: InitSchema,
|
|
5225
|
-
supportsJsonOutput: false
|
|
5226
|
-
}
|
|
5092
|
+
var initPlugin = definePlugin(
|
|
5093
|
+
(sdk2) => createPluginMethod(sdk2, {
|
|
5094
|
+
name: "init",
|
|
5095
|
+
categories: ["utility"],
|
|
5096
|
+
inputSchema: InitSchema,
|
|
5097
|
+
supportsJsonOutput: false,
|
|
5098
|
+
handler: async ({ options }) => {
|
|
5099
|
+
const { projectName: rawName, skipPrompts = false } = options;
|
|
5100
|
+
const cwd = process.cwd();
|
|
5101
|
+
const { projectName, projectDir } = validateInitOptions({ rawName, cwd });
|
|
5102
|
+
const displayHooks = createConsoleDisplayHooks();
|
|
5103
|
+
const packageManagerInfo = detectPackageManager(cwd);
|
|
5104
|
+
if (packageManagerInfo.name === "unknown") {
|
|
5105
|
+
displayHooks.onWarn(
|
|
5106
|
+
"Could not detect package manager, defaulting to npm."
|
|
5107
|
+
);
|
|
5108
|
+
}
|
|
5109
|
+
const packageManager = packageManagerInfo.name === "unknown" ? "npm" : packageManagerInfo.name;
|
|
5110
|
+
const steps = getInitSteps({
|
|
5111
|
+
projectDir,
|
|
5112
|
+
projectName,
|
|
5113
|
+
packageManager,
|
|
5114
|
+
displayHooks
|
|
5115
|
+
});
|
|
5116
|
+
const completedSetupStepIds = [];
|
|
5117
|
+
for (let i = 0; i < steps.length; i++) {
|
|
5118
|
+
const step = steps[i];
|
|
5119
|
+
const succeeded = await withInterruptCleanup(
|
|
5120
|
+
step.cleanup,
|
|
5121
|
+
() => runStep({
|
|
5122
|
+
step,
|
|
5123
|
+
stepNumber: i + 1,
|
|
5124
|
+
totalSteps: steps.length,
|
|
5125
|
+
skipPrompts,
|
|
5126
|
+
displayHooks
|
|
5127
|
+
})
|
|
5128
|
+
);
|
|
5129
|
+
if (!succeeded) break;
|
|
5130
|
+
completedSetupStepIds.push(step.id);
|
|
5227
5131
|
}
|
|
5132
|
+
if (completedSetupStepIds.length === 0) {
|
|
5133
|
+
throw new ZapierCliExitError(
|
|
5134
|
+
"Project setup failed \u2014 no steps completed."
|
|
5135
|
+
);
|
|
5136
|
+
}
|
|
5137
|
+
displaySummaryAndNextSteps({
|
|
5138
|
+
projectName,
|
|
5139
|
+
steps,
|
|
5140
|
+
completedSetupStepIds,
|
|
5141
|
+
packageManager
|
|
5142
|
+
});
|
|
5228
5143
|
}
|
|
5229
|
-
}
|
|
5230
|
-
|
|
5144
|
+
})
|
|
5145
|
+
);
|
|
5231
5146
|
|
|
5232
5147
|
// package.json with { type: 'json' }
|
|
5233
5148
|
var package_default2 = {
|
|
5234
5149
|
name: "@zapier/zapier-sdk-cli",
|
|
5235
|
-
version: "0.43.
|
|
5150
|
+
version: "0.43.3"};
|
|
5236
5151
|
|
|
5237
5152
|
// src/sdk.ts
|
|
5238
5153
|
injectCliLogin(login_exports);
|