@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.cjs
CHANGED
|
@@ -1113,7 +1113,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
|
|
|
1113
1113
|
|
|
1114
1114
|
// package.json
|
|
1115
1115
|
var package_default = {
|
|
1116
|
-
version: "0.43.
|
|
1116
|
+
version: "0.43.3"};
|
|
1117
1117
|
|
|
1118
1118
|
// src/telemetry/builders.ts
|
|
1119
1119
|
function createCliBaseEvent(context = {}) {
|
|
@@ -3098,85 +3098,65 @@ function toPkceCredentials(credentials2) {
|
|
|
3098
3098
|
}
|
|
3099
3099
|
return void 0;
|
|
3100
3100
|
}
|
|
3101
|
-
var loginPlugin = (
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
credentials: pkceCredentials
|
|
3112
|
-
});
|
|
3113
|
-
const user = await getLoggedInUser();
|
|
3114
|
-
sdk2.context.eventEmission.emit(
|
|
3115
|
-
"platform.sdk.ApplicationLifecycleEvent",
|
|
3116
|
-
zapierSdk.buildApplicationLifecycleEvent(
|
|
3117
|
-
{ lifecycle_event_type: "login_success" },
|
|
3118
|
-
{ customuser_id: user.customUserId, account_id: user.accountId }
|
|
3119
|
-
)
|
|
3120
|
-
);
|
|
3121
|
-
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
3122
|
-
};
|
|
3123
|
-
return {
|
|
3124
|
-
login: loginFn,
|
|
3125
|
-
context: {
|
|
3126
|
-
meta: {
|
|
3127
|
-
login: {
|
|
3128
|
-
categories: ["account"],
|
|
3129
|
-
inputSchema: LoginSchema,
|
|
3130
|
-
supportsJsonOutput: false
|
|
3131
|
-
}
|
|
3101
|
+
var loginPlugin = zapierSdk.definePlugin(
|
|
3102
|
+
(sdk2) => zapierSdk.createPluginMethod(sdk2, {
|
|
3103
|
+
name: "login",
|
|
3104
|
+
categories: ["account"],
|
|
3105
|
+
inputSchema: LoginSchema,
|
|
3106
|
+
supportsJsonOutput: false,
|
|
3107
|
+
handler: async ({ sdk: sdk3, options }) => {
|
|
3108
|
+
const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
|
|
3109
|
+
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
3110
|
+
throw new Error("Timeout must be a positive number");
|
|
3132
3111
|
}
|
|
3112
|
+
const resolvedCredentials = await sdk3.context.resolveCredentials();
|
|
3113
|
+
const pkceCredentials = toPkceCredentials(resolvedCredentials);
|
|
3114
|
+
await login_default({
|
|
3115
|
+
timeoutMs: timeoutSeconds * 1e3,
|
|
3116
|
+
credentials: pkceCredentials
|
|
3117
|
+
});
|
|
3118
|
+
const user = await getLoggedInUser();
|
|
3119
|
+
sdk3.context.eventEmission.emit(
|
|
3120
|
+
"platform.sdk.ApplicationLifecycleEvent",
|
|
3121
|
+
zapierSdk.buildApplicationLifecycleEvent(
|
|
3122
|
+
{ lifecycle_event_type: "login_success" },
|
|
3123
|
+
{ customuser_id: user.customUserId, account_id: user.accountId }
|
|
3124
|
+
)
|
|
3125
|
+
);
|
|
3126
|
+
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
3133
3127
|
}
|
|
3134
|
-
}
|
|
3135
|
-
|
|
3128
|
+
})
|
|
3129
|
+
);
|
|
3136
3130
|
var LogoutSchema = zod.z.object({}).describe("Log out of your Zapier account");
|
|
3137
3131
|
|
|
3138
3132
|
// src/plugins/logout/index.ts
|
|
3139
|
-
var
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
categories: ["account"],
|
|
3149
|
-
inputSchema: LogoutSchema,
|
|
3150
|
-
supportsJsonOutput: false
|
|
3151
|
-
}
|
|
3133
|
+
var logoutPlugin = zapierSdk.definePlugin(
|
|
3134
|
+
(sdk2) => zapierSdk.createPluginMethod(sdk2, {
|
|
3135
|
+
name: "logout",
|
|
3136
|
+
categories: ["account"],
|
|
3137
|
+
inputSchema: LogoutSchema,
|
|
3138
|
+
supportsJsonOutput: false,
|
|
3139
|
+
handler: async () => {
|
|
3140
|
+
await logout();
|
|
3141
|
+
console.log("\u2705 Successfully logged out");
|
|
3152
3142
|
}
|
|
3153
|
-
}
|
|
3154
|
-
|
|
3143
|
+
})
|
|
3144
|
+
);
|
|
3155
3145
|
var McpSchema = zod.z.object({
|
|
3156
3146
|
port: zod.z.string().optional().describe("Port to listen on (for future HTTP transport)")
|
|
3157
3147
|
}).describe("Start MCP server for Zapier SDK");
|
|
3158
3148
|
|
|
3159
3149
|
// src/plugins/mcp/index.ts
|
|
3160
|
-
var mcpPlugin = (
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
}
|
|
3166
|
-
|
|
3167
|
-
}, McpSchema);
|
|
3168
|
-
return {
|
|
3169
|
-
mcp: mcpWithSdk,
|
|
3170
|
-
context: {
|
|
3171
|
-
meta: {
|
|
3172
|
-
mcp: {
|
|
3173
|
-
categories: ["utility"],
|
|
3174
|
-
inputSchema: McpSchema
|
|
3175
|
-
}
|
|
3176
|
-
}
|
|
3150
|
+
var mcpPlugin = zapierSdk.definePlugin(
|
|
3151
|
+
(sdk2) => zapierSdk.createPluginMethod(sdk2, {
|
|
3152
|
+
name: "mcp",
|
|
3153
|
+
categories: ["utility"],
|
|
3154
|
+
inputSchema: McpSchema,
|
|
3155
|
+
handler: async ({ sdk: sdk3, options }) => {
|
|
3156
|
+
await zapierSdkMcp.startMcpServer({ ...options, debug: sdk3.context.options?.debug });
|
|
3177
3157
|
}
|
|
3178
|
-
}
|
|
3179
|
-
|
|
3158
|
+
})
|
|
3159
|
+
);
|
|
3180
3160
|
var BundleCodeSchema = zod.z.object({
|
|
3181
3161
|
input: zod.z.string().min(1).describe("Input TypeScript file path to bundle"),
|
|
3182
3162
|
output: zapierSdk.OutputPropertySchema.optional().describe(
|
|
@@ -3187,22 +3167,14 @@ var BundleCodeSchema = zod.z.object({
|
|
|
3187
3167
|
target: zod.z.string().optional().describe("ECMAScript target version"),
|
|
3188
3168
|
cjs: zod.z.boolean().optional().describe("Output CommonJS format instead of ESM")
|
|
3189
3169
|
}).describe("Bundle TypeScript code into executable JavaScript");
|
|
3190
|
-
var bundleCodePlugin = (
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
bundleCode: {
|
|
3199
|
-
categories: ["utility", "deprecated"],
|
|
3200
|
-
inputSchema: BundleCodeSchema
|
|
3201
|
-
}
|
|
3202
|
-
}
|
|
3203
|
-
}
|
|
3204
|
-
};
|
|
3205
|
-
};
|
|
3170
|
+
var bundleCodePlugin = zapierSdk.definePlugin(
|
|
3171
|
+
(sdk2) => zapierSdk.createPluginMethod(sdk2, {
|
|
3172
|
+
name: "bundleCode",
|
|
3173
|
+
categories: ["utility", "deprecated"],
|
|
3174
|
+
inputSchema: BundleCodeSchema,
|
|
3175
|
+
handler: async ({ options }) => bundleCode(options)
|
|
3176
|
+
})
|
|
3177
|
+
);
|
|
3206
3178
|
var ZapierBundleError = class extends Error {
|
|
3207
3179
|
constructor(message, details, originalError) {
|
|
3208
3180
|
super(message);
|
|
@@ -3269,25 +3241,14 @@ async function bundleCode(options) {
|
|
|
3269
3241
|
}
|
|
3270
3242
|
}
|
|
3271
3243
|
var GetLoginConfigPathSchema = zod.z.object({}).describe("Show the path to the login configuration file");
|
|
3272
|
-
var getLoginConfigPathPlugin = (
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
)
|
|
3279
|
-
|
|
3280
|
-
getLoginConfigPath: getLoginConfigPathWithSdk,
|
|
3281
|
-
context: {
|
|
3282
|
-
meta: {
|
|
3283
|
-
getLoginConfigPath: {
|
|
3284
|
-
categories: ["utility"],
|
|
3285
|
-
inputSchema: GetLoginConfigPathSchema
|
|
3286
|
-
}
|
|
3287
|
-
}
|
|
3288
|
-
}
|
|
3289
|
-
};
|
|
3290
|
-
};
|
|
3244
|
+
var getLoginConfigPathPlugin = zapierSdk.definePlugin(
|
|
3245
|
+
(sdk2) => zapierSdk.createPluginMethod(sdk2, {
|
|
3246
|
+
name: "getLoginConfigPath",
|
|
3247
|
+
categories: ["utility"],
|
|
3248
|
+
inputSchema: GetLoginConfigPathSchema,
|
|
3249
|
+
handler: async () => getConfigPath()
|
|
3250
|
+
})
|
|
3251
|
+
);
|
|
3291
3252
|
var AddSchema = zod.z.object({
|
|
3292
3253
|
apps: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
3293
3254
|
"One or more app keys to add (e.g., 'slack', 'github', 'trello')"
|
|
@@ -3315,111 +3276,105 @@ async function detectTypesOutputDirectory() {
|
|
|
3315
3276
|
}
|
|
3316
3277
|
return "./zapier/apps/";
|
|
3317
3278
|
}
|
|
3318
|
-
var addPlugin = (
|
|
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
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
skipWrite: false,
|
|
3393
|
-
configPath,
|
|
3394
|
-
onProgress: handleManifestProgress
|
|
3395
|
-
});
|
|
3396
|
-
const typesResult = await sdk2.generateAppTypes({
|
|
3397
|
-
apps: appKeys,
|
|
3398
|
-
connections: connectionIds,
|
|
3399
|
-
skipWrite: false,
|
|
3400
|
-
typesOutputDirectory: resolvedTypesOutput,
|
|
3401
|
-
onProgress: handleTypesProgress
|
|
3402
|
-
});
|
|
3403
|
-
const results = manifestResult.manifest?.apps || {};
|
|
3404
|
-
const successfulApps = Object.keys(results).filter(
|
|
3405
|
-
(manifestKey) => typesResult.writtenFiles?.[manifestKey]
|
|
3406
|
-
);
|
|
3407
|
-
if (successfulApps.length > 0) {
|
|
3408
|
-
console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
|
|
3409
|
-
}
|
|
3410
|
-
}, AddSchema);
|
|
3411
|
-
return {
|
|
3412
|
-
add,
|
|
3413
|
-
context: {
|
|
3414
|
-
meta: {
|
|
3415
|
-
add: {
|
|
3416
|
-
categories: ["utility"],
|
|
3417
|
-
inputSchema: AddSchema
|
|
3279
|
+
var addPlugin = zapierSdk.definePlugin(
|
|
3280
|
+
(sdk2) => zapierSdk.createPluginMethod(sdk2, {
|
|
3281
|
+
name: "add",
|
|
3282
|
+
categories: ["utility"],
|
|
3283
|
+
inputSchema: AddSchema,
|
|
3284
|
+
handler: async ({ sdk: sdk3, options }) => {
|
|
3285
|
+
const {
|
|
3286
|
+
apps: appKeys,
|
|
3287
|
+
connections: connectionIds,
|
|
3288
|
+
configPath,
|
|
3289
|
+
typesOutput = await detectTypesOutputDirectory()
|
|
3290
|
+
} = options;
|
|
3291
|
+
const resolvedTypesOutput = path.resolve(typesOutput);
|
|
3292
|
+
console.log(`\u{1F4E6} Adding ${appKeys.length} app(s)...`);
|
|
3293
|
+
const appSlugAndKeyMap = /* @__PURE__ */ new Map();
|
|
3294
|
+
const handleManifestProgress = (event) => {
|
|
3295
|
+
switch (event.type) {
|
|
3296
|
+
case "apps_lookup_start":
|
|
3297
|
+
console.log(`\u{1F4E6} Looking up ${event.count} app(s)...`);
|
|
3298
|
+
break;
|
|
3299
|
+
case "app_found":
|
|
3300
|
+
const displayName = event.app.slug ? `${event.app.slug} (${event.app.key})` : event.app.key;
|
|
3301
|
+
appSlugAndKeyMap.set(event.app.key, displayName);
|
|
3302
|
+
break;
|
|
3303
|
+
case "apps_lookup_complete":
|
|
3304
|
+
if (event.count === 0) {
|
|
3305
|
+
console.warn("\u26A0\uFE0F No apps found");
|
|
3306
|
+
}
|
|
3307
|
+
break;
|
|
3308
|
+
case "app_processing_start":
|
|
3309
|
+
const appName = event.slug ? `${event.slug} (${event.app})` : event.app;
|
|
3310
|
+
console.log(`\u{1F4E6} Adding ${appName}...`);
|
|
3311
|
+
break;
|
|
3312
|
+
case "manifest_updated":
|
|
3313
|
+
const appDisplay = appSlugAndKeyMap.get(event.app) || event.app;
|
|
3314
|
+
console.log(
|
|
3315
|
+
`\u{1F4DD} Locked ${appDisplay} to ${event.app}@${event.version} using key '${event.manifestKey}'`
|
|
3316
|
+
);
|
|
3317
|
+
break;
|
|
3318
|
+
case "app_processing_error":
|
|
3319
|
+
const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
|
|
3320
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
3321
|
+
break;
|
|
3322
|
+
}
|
|
3323
|
+
};
|
|
3324
|
+
const handleTypesProgress = (event) => {
|
|
3325
|
+
switch (event.type) {
|
|
3326
|
+
case "connections_lookup_start":
|
|
3327
|
+
console.log(`\u{1F510} Looking up ${event.count} connection(s)...`);
|
|
3328
|
+
break;
|
|
3329
|
+
case "connections_lookup_complete":
|
|
3330
|
+
console.log(`\u{1F510} Found ${event.count} connection(s)`);
|
|
3331
|
+
break;
|
|
3332
|
+
case "connection_matched":
|
|
3333
|
+
const appWithConnection = appSlugAndKeyMap.get(event.app) || event.app;
|
|
3334
|
+
console.log(
|
|
3335
|
+
`\u{1F510} Using connection ${event.connectionId} (${event.connectionTitle}) for ${appWithConnection}`
|
|
3336
|
+
);
|
|
3337
|
+
break;
|
|
3338
|
+
case "connection_not_matched":
|
|
3339
|
+
const appWithoutConnection = appSlugAndKeyMap.get(event.app) || event.app;
|
|
3340
|
+
console.warn(
|
|
3341
|
+
`\u26A0\uFE0F No matching connection found for ${appWithoutConnection}`
|
|
3342
|
+
);
|
|
3343
|
+
break;
|
|
3344
|
+
case "file_written":
|
|
3345
|
+
console.log(
|
|
3346
|
+
`\u{1F527} Generated types for ${event.manifestKey} at ${event.filePath}`
|
|
3347
|
+
);
|
|
3348
|
+
break;
|
|
3349
|
+
case "app_processing_error":
|
|
3350
|
+
const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
|
|
3351
|
+
console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
|
|
3352
|
+
break;
|
|
3418
3353
|
}
|
|
3354
|
+
};
|
|
3355
|
+
const manifestResult = await sdk3.buildManifest({
|
|
3356
|
+
apps: appKeys,
|
|
3357
|
+
skipWrite: false,
|
|
3358
|
+
configPath,
|
|
3359
|
+
onProgress: handleManifestProgress
|
|
3360
|
+
});
|
|
3361
|
+
const typesResult = await sdk3.generateAppTypes({
|
|
3362
|
+
apps: appKeys,
|
|
3363
|
+
connections: connectionIds,
|
|
3364
|
+
skipWrite: false,
|
|
3365
|
+
typesOutputDirectory: resolvedTypesOutput,
|
|
3366
|
+
onProgress: handleTypesProgress
|
|
3367
|
+
});
|
|
3368
|
+
const results = manifestResult.manifest?.apps || {};
|
|
3369
|
+
const successfulApps = Object.keys(results).filter(
|
|
3370
|
+
(manifestKey) => typesResult.writtenFiles?.[manifestKey]
|
|
3371
|
+
);
|
|
3372
|
+
if (successfulApps.length > 0) {
|
|
3373
|
+
console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
|
|
3419
3374
|
}
|
|
3420
3375
|
}
|
|
3421
|
-
}
|
|
3422
|
-
|
|
3376
|
+
})
|
|
3377
|
+
);
|
|
3423
3378
|
var GenerateAppTypesSchema = zod.z.object({
|
|
3424
3379
|
apps: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
3425
3380
|
"One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
|
|
@@ -4026,150 +3981,133 @@ function createManifestEntry(app) {
|
|
|
4026
3981
|
version: app.version
|
|
4027
3982
|
};
|
|
4028
3983
|
}
|
|
4029
|
-
var generateAppTypesPlugin = (
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
}
|
|
4053
|
-
const connections = [];
|
|
4054
|
-
if (connectionIds && connectionIds.length > 0) {
|
|
4055
|
-
onProgress?.({
|
|
4056
|
-
type: "connections_lookup_start",
|
|
4057
|
-
count: connectionIds.length
|
|
4058
|
-
});
|
|
4059
|
-
const connectionsIterable = sdk2.listConnections({ connections: connectionIds }).items();
|
|
4060
|
-
for await (const connection of connectionsIterable) {
|
|
4061
|
-
connections.push(connection);
|
|
3984
|
+
var generateAppTypesPlugin = zapierSdk.definePlugin(
|
|
3985
|
+
(sdk2) => zapierSdk.createPluginMethod(sdk2, {
|
|
3986
|
+
name: "generateAppTypes",
|
|
3987
|
+
categories: ["utility"],
|
|
3988
|
+
// Cast: schema validates JSON fields only; GenerateAppTypesOptions adds
|
|
3989
|
+
// the runtime-only `onProgress` callback (passthrough via createFunction).
|
|
3990
|
+
inputSchema: GenerateAppTypesSchema,
|
|
3991
|
+
handler: async ({ sdk: sdk3, options }) => {
|
|
3992
|
+
const {
|
|
3993
|
+
apps: appKeys,
|
|
3994
|
+
connections: connectionIds,
|
|
3995
|
+
skipWrite = false,
|
|
3996
|
+
typesOutputDirectory = await detectTypesOutputDirectory(),
|
|
3997
|
+
onProgress
|
|
3998
|
+
} = options;
|
|
3999
|
+
const resolvedTypesOutput = path.resolve(typesOutputDirectory);
|
|
4000
|
+
const result = { typeDefinitions: {} };
|
|
4001
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
4002
|
+
const appsIterable = sdk3.listApps({ apps: appKeys }).items();
|
|
4003
|
+
const apps = [];
|
|
4004
|
+
for await (const app of appsIterable) {
|
|
4005
|
+
apps.push(app);
|
|
4006
|
+
onProgress?.({ type: "app_found", app });
|
|
4062
4007
|
}
|
|
4063
|
-
onProgress?.({
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
}
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
type: "app_processing_start",
|
|
4077
|
-
app: app.key,
|
|
4078
|
-
slug: app.slug
|
|
4079
|
-
});
|
|
4080
|
-
try {
|
|
4081
|
-
if (!app.version) {
|
|
4082
|
-
const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
|
|
4083
|
-
onProgress?.({
|
|
4084
|
-
type: "app_processing_error",
|
|
4085
|
-
app: app.key,
|
|
4086
|
-
error: errorMessage
|
|
4087
|
-
});
|
|
4088
|
-
throw new zapierSdk.ZapierValidationError(errorMessage, {
|
|
4089
|
-
details: {
|
|
4090
|
-
appKey: app.key,
|
|
4091
|
-
implementationId: app.implementation_id
|
|
4092
|
-
}
|
|
4093
|
-
});
|
|
4008
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
4009
|
+
if (apps.length === 0) {
|
|
4010
|
+
return result;
|
|
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 = sdk3.listConnections({ connections: connectionIds }).items();
|
|
4019
|
+
for await (const connection of connectionsIterable) {
|
|
4020
|
+
connections.push(connection);
|
|
4094
4021
|
}
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4022
|
+
onProgress?.({
|
|
4023
|
+
type: "connections_lookup_complete",
|
|
4024
|
+
count: connections.length
|
|
4025
|
+
});
|
|
4026
|
+
}
|
|
4027
|
+
if (!skipWrite && resolvedTypesOutput) {
|
|
4028
|
+
await promises.mkdir(resolvedTypesOutput, { recursive: true });
|
|
4029
|
+
}
|
|
4030
|
+
if (!skipWrite) {
|
|
4031
|
+
result.writtenFiles = {};
|
|
4032
|
+
}
|
|
4033
|
+
for (const app of apps) {
|
|
4034
|
+
onProgress?.({
|
|
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>`;
|
|
4102
4042
|
onProgress?.({
|
|
4103
|
-
type: "
|
|
4043
|
+
type: "app_processing_error",
|
|
4104
4044
|
app: app.key,
|
|
4105
|
-
|
|
4106
|
-
connectionTitle: matchingConnection.title || ""
|
|
4045
|
+
error: errorMessage
|
|
4107
4046
|
});
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4047
|
+
throw new zapierSdk.ZapierValidationError(errorMessage, {
|
|
4048
|
+
details: {
|
|
4049
|
+
appKey: app.key,
|
|
4050
|
+
implementationId: app.implementation_id
|
|
4051
|
+
}
|
|
4112
4052
|
});
|
|
4113
4053
|
}
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4054
|
+
let connectionId;
|
|
4055
|
+
if (connections.length > 0) {
|
|
4056
|
+
const matchingConnection = connections.find(
|
|
4057
|
+
(conn) => conn.app_key === app.key
|
|
4058
|
+
);
|
|
4059
|
+
if (matchingConnection) {
|
|
4060
|
+
connectionId = matchingConnection.id;
|
|
4061
|
+
onProgress?.({
|
|
4062
|
+
type: "connection_matched",
|
|
4063
|
+
app: app.key,
|
|
4064
|
+
connectionId: matchingConnection.id,
|
|
4065
|
+
connectionTitle: matchingConnection.title || ""
|
|
4066
|
+
});
|
|
4067
|
+
} else {
|
|
4068
|
+
onProgress?.({
|
|
4069
|
+
type: "connection_not_matched",
|
|
4070
|
+
app: app.key
|
|
4071
|
+
});
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
const manifestKey = getManifestKey(app);
|
|
4075
|
+
const generator = new AstTypeGenerator();
|
|
4076
|
+
const typeDefinitionString = await generator.generateTypes({
|
|
4077
|
+
app,
|
|
4078
|
+
connectionId,
|
|
4079
|
+
sdk: sdk3
|
|
4080
|
+
});
|
|
4081
|
+
result.typeDefinitions[manifestKey] = typeDefinitionString;
|
|
4132
4082
|
onProgress?.({
|
|
4133
|
-
type: "
|
|
4083
|
+
type: "type_generated",
|
|
4134
4084
|
manifestKey,
|
|
4135
|
-
|
|
4085
|
+
sizeBytes: typeDefinitionString.length
|
|
4136
4086
|
});
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
throw error;
|
|
4151
|
-
} else {
|
|
4152
|
-
throw new zapierSdk.ZapierUnknownError(errorMessage, {
|
|
4153
|
-
cause: error
|
|
4154
|
-
// Works for both Error and non-Error
|
|
4087
|
+
if (!skipWrite && resolvedTypesOutput && result.writtenFiles) {
|
|
4088
|
+
const filePath = path.join(resolvedTypesOutput, `${manifestKey}.d.ts`);
|
|
4089
|
+
await promises.writeFile(filePath, typeDefinitionString, "utf8");
|
|
4090
|
+
result.writtenFiles[manifestKey] = filePath;
|
|
4091
|
+
onProgress?.({ type: "file_written", manifestKey, filePath });
|
|
4092
|
+
}
|
|
4093
|
+
onProgress?.({ type: "app_processing_complete", app: app.key });
|
|
4094
|
+
} catch (error) {
|
|
4095
|
+
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
4096
|
+
onProgress?.({
|
|
4097
|
+
type: "app_processing_error",
|
|
4098
|
+
app: app.key,
|
|
4099
|
+
error: errorMessage
|
|
4155
4100
|
});
|
|
4101
|
+
if (error instanceof zapierSdk.ZapierValidationError) {
|
|
4102
|
+
throw error;
|
|
4103
|
+
}
|
|
4104
|
+
throw new zapierSdk.ZapierUnknownError(errorMessage, { cause: error });
|
|
4156
4105
|
}
|
|
4157
4106
|
}
|
|
4107
|
+
return result;
|
|
4158
4108
|
}
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
return {
|
|
4162
|
-
generateAppTypes,
|
|
4163
|
-
context: {
|
|
4164
|
-
meta: {
|
|
4165
|
-
generateAppTypes: {
|
|
4166
|
-
categories: ["utility"],
|
|
4167
|
-
inputSchema: GenerateAppTypesSchema
|
|
4168
|
-
}
|
|
4169
|
-
}
|
|
4170
|
-
}
|
|
4171
|
-
};
|
|
4172
|
-
};
|
|
4109
|
+
})
|
|
4110
|
+
);
|
|
4173
4111
|
var BuildManifestSchema = zod.z.object({
|
|
4174
4112
|
apps: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
4175
4113
|
"One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello')"
|
|
@@ -4185,86 +4123,80 @@ var BuildManifestSchema = zod.z.object({
|
|
|
4185
4123
|
);
|
|
4186
4124
|
|
|
4187
4125
|
// src/plugins/buildManifest/index.ts
|
|
4188
|
-
var buildManifestPlugin = (
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
type: "manifest_entry_built",
|
|
4218
|
-
app: app.key,
|
|
4219
|
-
manifestKey: manifestEntry.implementationName,
|
|
4220
|
-
version: manifestEntry.version || ""
|
|
4221
|
-
});
|
|
4222
|
-
const { key: updatedManifestKey, manifest } = await sdk2.context.updateManifestEntry({
|
|
4223
|
-
appKey: app.key,
|
|
4224
|
-
entry: manifestEntry,
|
|
4225
|
-
configPath,
|
|
4226
|
-
skipWrite,
|
|
4227
|
-
manifest: updatedManifest
|
|
4228
|
-
});
|
|
4229
|
-
updatedManifest = manifest;
|
|
4230
|
-
onProgress?.({
|
|
4231
|
-
type: "manifest_updated",
|
|
4232
|
-
app: app.key,
|
|
4233
|
-
manifestKey: updatedManifestKey,
|
|
4234
|
-
version: manifestEntry.version || ""
|
|
4235
|
-
});
|
|
4236
|
-
onProgress?.({ type: "app_processing_complete", app: app.key });
|
|
4237
|
-
} catch (error) {
|
|
4238
|
-
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
4126
|
+
var buildManifestPlugin = zapierSdk.definePlugin(
|
|
4127
|
+
(sdk2) => zapierSdk.createPluginMethod(sdk2, {
|
|
4128
|
+
name: "buildManifest",
|
|
4129
|
+
categories: ["utility"],
|
|
4130
|
+
// Cast: BuildManifestSchema validates JSON-serializable fields only.
|
|
4131
|
+
// BuildManifestOptions adds an `onProgress` callback that rides through
|
|
4132
|
+
// `createFunction`'s passthrough spread at runtime; this widens TInput
|
|
4133
|
+
// so the handler can read it.
|
|
4134
|
+
inputSchema: BuildManifestSchema,
|
|
4135
|
+
handler: async ({ sdk: sdk3, options }) => {
|
|
4136
|
+
const {
|
|
4137
|
+
apps: appKeys,
|
|
4138
|
+
skipWrite = false,
|
|
4139
|
+
configPath,
|
|
4140
|
+
onProgress
|
|
4141
|
+
} = options;
|
|
4142
|
+
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
4143
|
+
const appsIterable = sdk3.listApps({ apps: appKeys }).items();
|
|
4144
|
+
const apps = [];
|
|
4145
|
+
for await (const app of appsIterable) {
|
|
4146
|
+
apps.push(app);
|
|
4147
|
+
onProgress?.({ type: "app_found", app });
|
|
4148
|
+
}
|
|
4149
|
+
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
4150
|
+
if (apps.length === 0) {
|
|
4151
|
+
return {};
|
|
4152
|
+
}
|
|
4153
|
+
let updatedManifest;
|
|
4154
|
+
for (const app of apps) {
|
|
4239
4155
|
onProgress?.({
|
|
4240
|
-
type: "
|
|
4156
|
+
type: "app_processing_start",
|
|
4241
4157
|
app: app.key,
|
|
4242
|
-
|
|
4158
|
+
slug: app.slug
|
|
4243
4159
|
});
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4160
|
+
try {
|
|
4161
|
+
const manifestEntry = createManifestEntry(app);
|
|
4162
|
+
onProgress?.({
|
|
4163
|
+
type: "manifest_entry_built",
|
|
4164
|
+
app: app.key,
|
|
4165
|
+
manifestKey: manifestEntry.implementationName,
|
|
4166
|
+
version: manifestEntry.version || ""
|
|
4250
4167
|
});
|
|
4168
|
+
const { key: updatedManifestKey, manifest } = await sdk3.context.updateManifestEntry({
|
|
4169
|
+
appKey: app.key,
|
|
4170
|
+
entry: manifestEntry,
|
|
4171
|
+
configPath,
|
|
4172
|
+
skipWrite,
|
|
4173
|
+
manifest: updatedManifest
|
|
4174
|
+
});
|
|
4175
|
+
updatedManifest = manifest;
|
|
4176
|
+
onProgress?.({
|
|
4177
|
+
type: "manifest_updated",
|
|
4178
|
+
app: app.key,
|
|
4179
|
+
manifestKey: updatedManifestKey,
|
|
4180
|
+
version: manifestEntry.version || ""
|
|
4181
|
+
});
|
|
4182
|
+
onProgress?.({ type: "app_processing_complete", app: app.key });
|
|
4183
|
+
} catch (error) {
|
|
4184
|
+
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
4185
|
+
onProgress?.({
|
|
4186
|
+
type: "app_processing_error",
|
|
4187
|
+
app: app.key,
|
|
4188
|
+
error: errorMessage
|
|
4189
|
+
});
|
|
4190
|
+
if (error instanceof zapierSdk.ZapierValidationError) {
|
|
4191
|
+
throw error;
|
|
4192
|
+
}
|
|
4193
|
+
throw new zapierSdk.ZapierUnknownError(errorMessage, { cause: error });
|
|
4251
4194
|
}
|
|
4252
4195
|
}
|
|
4196
|
+
return { manifest: updatedManifest };
|
|
4253
4197
|
}
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
return {
|
|
4257
|
-
buildManifest,
|
|
4258
|
-
context: {
|
|
4259
|
-
meta: {
|
|
4260
|
-
buildManifest: {
|
|
4261
|
-
categories: ["utility"],
|
|
4262
|
-
inputSchema: BuildManifestSchema
|
|
4263
|
-
}
|
|
4264
|
-
}
|
|
4265
|
-
}
|
|
4266
|
-
};
|
|
4267
|
-
};
|
|
4198
|
+
})
|
|
4199
|
+
);
|
|
4268
4200
|
var FeedbackSchema = zod.z.object({
|
|
4269
4201
|
feedback: zod.z.string().describe(
|
|
4270
4202
|
"Your feedback on the Zapier SDK. Describe what worked well, what was frustrating, or any suggestions."
|
|
@@ -4298,37 +4230,31 @@ async function postWithRetry({
|
|
|
4298
4230
|
}
|
|
4299
4231
|
return response;
|
|
4300
4232
|
}
|
|
4301
|
-
var feedbackPlugin = (
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
feedback: {
|
|
4322
|
-
categories: ["utility"],
|
|
4323
|
-
inputSchema: FeedbackSchema,
|
|
4324
|
-
resolvers: {
|
|
4325
|
-
feedback: feedbackResolver
|
|
4326
|
-
}
|
|
4327
|
-
}
|
|
4233
|
+
var feedbackPlugin = zapierSdk.definePlugin(
|
|
4234
|
+
(sdk2) => zapierSdk.createPluginMethod(sdk2, {
|
|
4235
|
+
name: "feedback",
|
|
4236
|
+
categories: ["utility"],
|
|
4237
|
+
inputSchema: FeedbackSchema,
|
|
4238
|
+
resolvers: { feedback: feedbackResolver },
|
|
4239
|
+
handler: async ({ sdk: sdk3, options }) => {
|
|
4240
|
+
const user = await getLoggedInUser();
|
|
4241
|
+
const body = JSON.stringify({
|
|
4242
|
+
email: user.email,
|
|
4243
|
+
customuser_id: user.customUserId,
|
|
4244
|
+
feedback: options.feedback
|
|
4245
|
+
});
|
|
4246
|
+
const response = await postWithRetry({
|
|
4247
|
+
body,
|
|
4248
|
+
attemptsLeft: MAX_RETRIES
|
|
4249
|
+
});
|
|
4250
|
+
if (sdk3.context.options?.debug) {
|
|
4251
|
+
const text = await response.text();
|
|
4252
|
+
console.error("[debug] Webhook response:", text);
|
|
4328
4253
|
}
|
|
4254
|
+
return "Thank you for your feedback!";
|
|
4329
4255
|
}
|
|
4330
|
-
}
|
|
4331
|
-
|
|
4256
|
+
})
|
|
4257
|
+
);
|
|
4332
4258
|
var CurlSchema = zod.z.object({
|
|
4333
4259
|
url: zod.z.string().describe("Request URL"),
|
|
4334
4260
|
request: zod.z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional().describe("HTTP method (defaults to GET, or POST if data is provided)"),
|
|
@@ -4504,7 +4430,7 @@ async function buildFormData(formArgs, formStringArgs) {
|
|
|
4504
4430
|
}
|
|
4505
4431
|
|
|
4506
4432
|
// src/plugins/curl/index.ts
|
|
4507
|
-
var curlPlugin = (sdk2) => {
|
|
4433
|
+
var curlPlugin = zapierSdk.definePlugin((sdk2) => {
|
|
4508
4434
|
async function curl(options) {
|
|
4509
4435
|
const {
|
|
4510
4436
|
url: rawUrl,
|
|
@@ -4747,30 +4673,25 @@ ${Array.from(
|
|
|
4747
4673
|
}
|
|
4748
4674
|
}
|
|
4749
4675
|
};
|
|
4750
|
-
};
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
...sdk2.context.meta.fetch.categories || [],
|
|
4764
|
-
"deprecated"
|
|
4765
|
-
],
|
|
4766
|
-
deprecation: {
|
|
4767
|
-
message: "This command is deprecated and will be removed soon. Use `curl` instead. Learn more: https://docs.zapier.com/sdk/cli-reference#curl"
|
|
4768
|
-
}
|
|
4676
|
+
});
|
|
4677
|
+
var cliOverridesPlugin = zapierSdk.definePlugin(
|
|
4678
|
+
(sdk2) => {
|
|
4679
|
+
const meta = {};
|
|
4680
|
+
if (sdk2.context.meta.fetch) {
|
|
4681
|
+
meta.fetch = {
|
|
4682
|
+
...sdk2.context.meta.fetch,
|
|
4683
|
+
categories: [
|
|
4684
|
+
...sdk2.context.meta.fetch.categories || [],
|
|
4685
|
+
"deprecated"
|
|
4686
|
+
],
|
|
4687
|
+
deprecation: {
|
|
4688
|
+
message: "This command is deprecated and will be removed soon. Use `curl` instead. Learn more: https://docs.zapier.com/sdk/cli-reference#curl"
|
|
4769
4689
|
}
|
|
4770
|
-
}
|
|
4690
|
+
};
|
|
4771
4691
|
}
|
|
4772
|
-
|
|
4773
|
-
}
|
|
4692
|
+
return { context: { meta } };
|
|
4693
|
+
}
|
|
4694
|
+
);
|
|
4774
4695
|
var TEMPLATES = ["basic"];
|
|
4775
4696
|
var InitSchema = zod.z.object({
|
|
4776
4697
|
projectName: zod.z.string().min(1).describe("Name of the project directory to create"),
|
|
@@ -5209,71 +5130,65 @@ function displaySummaryAndNextSteps({
|
|
|
5209
5130
|
}
|
|
5210
5131
|
|
|
5211
5132
|
// src/plugins/init/index.ts
|
|
5212
|
-
var initPlugin = (
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
);
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
}
|
|
5252
|
-
displaySummaryAndNextSteps({
|
|
5253
|
-
projectName,
|
|
5254
|
-
steps,
|
|
5255
|
-
completedSetupStepIds,
|
|
5256
|
-
packageManager
|
|
5257
|
-
});
|
|
5258
|
-
}, InitSchema);
|
|
5259
|
-
return {
|
|
5260
|
-
init,
|
|
5261
|
-
context: {
|
|
5262
|
-
meta: {
|
|
5263
|
-
init: {
|
|
5264
|
-
categories: ["utility"],
|
|
5265
|
-
inputSchema: InitSchema,
|
|
5266
|
-
supportsJsonOutput: false
|
|
5267
|
-
}
|
|
5133
|
+
var initPlugin = zapierSdk.definePlugin(
|
|
5134
|
+
(sdk2) => zapierSdk.createPluginMethod(sdk2, {
|
|
5135
|
+
name: "init",
|
|
5136
|
+
categories: ["utility"],
|
|
5137
|
+
inputSchema: InitSchema,
|
|
5138
|
+
supportsJsonOutput: false,
|
|
5139
|
+
handler: async ({ options }) => {
|
|
5140
|
+
const { projectName: rawName, skipPrompts = false } = options;
|
|
5141
|
+
const cwd = process.cwd();
|
|
5142
|
+
const { projectName, projectDir } = validateInitOptions({ rawName, cwd });
|
|
5143
|
+
const displayHooks = createConsoleDisplayHooks();
|
|
5144
|
+
const packageManagerInfo = detectPackageManager(cwd);
|
|
5145
|
+
if (packageManagerInfo.name === "unknown") {
|
|
5146
|
+
displayHooks.onWarn(
|
|
5147
|
+
"Could not detect package manager, defaulting to npm."
|
|
5148
|
+
);
|
|
5149
|
+
}
|
|
5150
|
+
const packageManager = packageManagerInfo.name === "unknown" ? "npm" : packageManagerInfo.name;
|
|
5151
|
+
const steps = getInitSteps({
|
|
5152
|
+
projectDir,
|
|
5153
|
+
projectName,
|
|
5154
|
+
packageManager,
|
|
5155
|
+
displayHooks
|
|
5156
|
+
});
|
|
5157
|
+
const completedSetupStepIds = [];
|
|
5158
|
+
for (let i = 0; i < steps.length; i++) {
|
|
5159
|
+
const step = steps[i];
|
|
5160
|
+
const succeeded = await withInterruptCleanup(
|
|
5161
|
+
step.cleanup,
|
|
5162
|
+
() => runStep({
|
|
5163
|
+
step,
|
|
5164
|
+
stepNumber: i + 1,
|
|
5165
|
+
totalSteps: steps.length,
|
|
5166
|
+
skipPrompts,
|
|
5167
|
+
displayHooks
|
|
5168
|
+
})
|
|
5169
|
+
);
|
|
5170
|
+
if (!succeeded) break;
|
|
5171
|
+
completedSetupStepIds.push(step.id);
|
|
5268
5172
|
}
|
|
5173
|
+
if (completedSetupStepIds.length === 0) {
|
|
5174
|
+
throw new ZapierCliExitError(
|
|
5175
|
+
"Project setup failed \u2014 no steps completed."
|
|
5176
|
+
);
|
|
5177
|
+
}
|
|
5178
|
+
displaySummaryAndNextSteps({
|
|
5179
|
+
projectName,
|
|
5180
|
+
steps,
|
|
5181
|
+
completedSetupStepIds,
|
|
5182
|
+
packageManager
|
|
5183
|
+
});
|
|
5269
5184
|
}
|
|
5270
|
-
}
|
|
5271
|
-
|
|
5185
|
+
})
|
|
5186
|
+
);
|
|
5272
5187
|
|
|
5273
5188
|
// package.json with { type: 'json' }
|
|
5274
5189
|
var package_default2 = {
|
|
5275
5190
|
name: "@zapier/zapier-sdk-cli",
|
|
5276
|
-
version: "0.43.
|
|
5191
|
+
version: "0.43.3"};
|
|
5277
5192
|
|
|
5278
5193
|
// src/sdk.ts
|
|
5279
5194
|
zapierSdk.injectCliLogin(login_exports);
|