@zapier/zapier-sdk-cli 0.43.4 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -135,14 +135,14 @@ var SchemaParameterResolver = class {
135
135
  this.spinner = null;
136
136
  }
137
137
  }
138
- async resolveParameters(schema, providedParams, sdk2, functionName, options) {
138
+ async resolveParameters(schema, providedParams, sdk, functionName, options) {
139
139
  return runWithTelemetryContext(async () => {
140
140
  this.debug = options?.debug ?? false;
141
141
  const interactiveMode = (options?.interactiveMode ?? true) && !!process.stdin.isTTY;
142
142
  const parseResult = schema.safeParse(providedParams);
143
143
  const allParams = this.extractParametersFromSchema(schema);
144
144
  const resolvableParams = allParams.filter(
145
- (param) => this.hasResolver(param.name, sdk2, functionName)
145
+ (param) => this.hasResolver(param.name, sdk, functionName)
146
146
  );
147
147
  const missingResolvable = resolvableParams.filter((param) => {
148
148
  const hasValue = this.getNestedValue(providedParams, param.path) !== void 0;
@@ -167,12 +167,12 @@ var SchemaParameterResolver = class {
167
167
  }
168
168
  const resolvedParams = { ...providedParams };
169
169
  const context = {
170
- sdk: sdk2,
170
+ sdk,
171
171
  currentParams: providedParams,
172
172
  resolvedParams,
173
173
  functionName
174
174
  };
175
- const localResolvers = this.getLocalResolvers(sdk2, functionName);
175
+ const localResolvers = this.getLocalResolvers(sdk, functionName);
176
176
  if (required.length > 0) {
177
177
  const requiredParamNames = required.map((p) => p.name);
178
178
  const requiredResolutionOrder = getLocalResolutionOrderForParams(
@@ -1006,9 +1006,9 @@ Optional fields${pathContext}:`));
1006
1006
  const errorObj = error;
1007
1007
  return errorObj?.name === "ExitPromptError" || errorObj?.message?.includes("User force closed") || errorObj?.isTTYError === true;
1008
1008
  }
1009
- hasResolver(paramName, sdk2, functionName) {
1010
- if (functionName && typeof sdk2.getRegistry === "function") {
1011
- const registry = sdk2.getRegistry({ package: "cli" });
1009
+ hasResolver(paramName, sdk, functionName) {
1010
+ if (functionName && typeof sdk.getRegistry === "function") {
1011
+ const registry = sdk.getRegistry({ package: "cli" });
1012
1012
  const functionInfo = registry.functions.find(
1013
1013
  (f) => f.name === functionName
1014
1014
  );
@@ -1018,9 +1018,9 @@ Optional fields${pathContext}:`));
1018
1018
  }
1019
1019
  return false;
1020
1020
  }
1021
- getResolver(paramName, sdk2, functionName) {
1022
- if (functionName && typeof sdk2.getRegistry === "function") {
1023
- const registry = sdk2.getRegistry({ package: "cli" });
1021
+ getResolver(paramName, sdk, functionName) {
1022
+ if (functionName && typeof sdk.getRegistry === "function") {
1023
+ const registry = sdk.getRegistry({ package: "cli" });
1024
1024
  const functionInfo = registry.functions.find(
1025
1025
  (f) => f.name === functionName
1026
1026
  );
@@ -1030,11 +1030,11 @@ Optional fields${pathContext}:`));
1030
1030
  }
1031
1031
  return null;
1032
1032
  }
1033
- getLocalResolvers(sdk2, functionName) {
1034
- if (!functionName || typeof sdk2.getRegistry !== "function") {
1033
+ getLocalResolvers(sdk, functionName) {
1034
+ if (!functionName || typeof sdk.getRegistry !== "function") {
1035
1035
  return {};
1036
1036
  }
1037
- const registry = sdk2.getRegistry();
1037
+ const registry = sdk.getRegistry();
1038
1038
  const functionInfo = registry.functions.find(
1039
1039
  (f) => f.name === functionName
1040
1040
  );
@@ -1072,7 +1072,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
1072
1072
 
1073
1073
  // package.json
1074
1074
  var package_default = {
1075
- version: "0.43.4"};
1075
+ version: "0.44.0"};
1076
1076
 
1077
1077
  // src/telemetry/builders.ts
1078
1078
  function createCliBaseEvent(context = {}) {
@@ -1790,19 +1790,19 @@ function reconstructPositionalArgs(inputParameters, flatParams) {
1790
1790
  function methodNameToCliCommand(methodName) {
1791
1791
  return toKebabCase(methodName);
1792
1792
  }
1793
- function generateCliCommands(program2, sdk2) {
1794
- if (typeof sdk2.getRegistry !== "function") {
1793
+ function generateCliCommands(program2, sdk) {
1794
+ if (typeof sdk.getRegistry !== "function") {
1795
1795
  console.error("SDK registry not available");
1796
1796
  return;
1797
1797
  }
1798
- const registry = sdk2.getRegistry({ package: "cli" });
1798
+ const registry = sdk.getRegistry({ package: "cli" });
1799
1799
  registry.functions.forEach((fnInfo) => {
1800
1800
  if (!fnInfo.inputSchema && !fnInfo.inputParameters) {
1801
1801
  console.warn(`Schema not found for ${fnInfo.name}`);
1802
1802
  return;
1803
1803
  }
1804
1804
  const cliCommandName = methodNameToCliCommand(fnInfo.name);
1805
- const config2 = createCommandConfig(cliCommandName, fnInfo, sdk2);
1805
+ const config2 = createCommandConfig(cliCommandName, fnInfo, sdk);
1806
1806
  addCommand(program2, cliCommandName, config2);
1807
1807
  });
1808
1808
  program2.configureHelp({
@@ -1866,7 +1866,7 @@ function generateCliCommands(program2, sdk2) {
1866
1866
  }
1867
1867
  });
1868
1868
  }
1869
- function createCommandConfig(cliCommandName, functionInfo, sdk2) {
1869
+ function createCommandConfig(cliCommandName, functionInfo, sdk) {
1870
1870
  const usesInputParameters = !functionInfo.inputSchema && !!functionInfo.inputParameters;
1871
1871
  const schema = functionInfo.inputSchema;
1872
1872
  const parameters = usesInputParameters ? analyzeInputParameters(functionInfo.inputParameters, functionInfo) : analyzeZodSchema(schema, functionInfo);
@@ -1924,7 +1924,7 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
1924
1924
  resolvedParams = await resolver.resolveParameters(
1925
1925
  schema,
1926
1926
  rawParams,
1927
- sdk2,
1927
+ sdk,
1928
1928
  functionInfo.name,
1929
1929
  {
1930
1930
  interactiveMode,
@@ -1947,7 +1947,7 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
1947
1947
  }
1948
1948
  confirmMessageAfter = confirmResult.messageAfter;
1949
1949
  }
1950
- const sdkMethod = sdk2[functionInfo.name];
1950
+ const sdkMethod = sdk[functionInfo.name];
1951
1951
  switch (outputMode) {
1952
1952
  case "paginate": {
1953
1953
  const source = sdkMethod(resolvedParams);
@@ -2039,7 +2039,7 @@ ${confirmMessageAfter}`));
2039
2039
  selected_api: resolvedParams.app ?? null
2040
2040
  }
2041
2041
  });
2042
- sdk2.context.eventEmission.emit(
2042
+ sdk.context.eventEmission.emit(
2043
2043
  CLI_COMMAND_EXECUTED_EVENT_SUBJECT,
2044
2044
  event
2045
2045
  );
@@ -3058,24 +3058,24 @@ function toPkceCredentials(credentials2) {
3058
3058
  return void 0;
3059
3059
  }
3060
3060
  var loginPlugin = definePlugin(
3061
- (sdk2) => createPluginMethod(sdk2, {
3061
+ (sdk) => createPluginMethod(sdk, {
3062
3062
  name: "login",
3063
3063
  categories: ["account"],
3064
3064
  inputSchema: LoginSchema,
3065
3065
  supportsJsonOutput: false,
3066
- handler: async ({ sdk: sdk3, options }) => {
3066
+ handler: async ({ sdk: sdk2, options }) => {
3067
3067
  const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
3068
3068
  if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
3069
3069
  throw new Error("Timeout must be a positive number");
3070
3070
  }
3071
- const resolvedCredentials = await sdk3.context.resolveCredentials();
3071
+ const resolvedCredentials = await sdk2.context.resolveCredentials();
3072
3072
  const pkceCredentials = toPkceCredentials(resolvedCredentials);
3073
3073
  await login_default({
3074
3074
  timeoutMs: timeoutSeconds * 1e3,
3075
3075
  credentials: pkceCredentials
3076
3076
  });
3077
3077
  const user = await getLoggedInUser();
3078
- sdk3.context.eventEmission.emit(
3078
+ sdk2.context.eventEmission.emit(
3079
3079
  "platform.sdk.ApplicationLifecycleEvent",
3080
3080
  buildApplicationLifecycleEvent(
3081
3081
  { lifecycle_event_type: "login_success" },
@@ -3090,7 +3090,7 @@ var LogoutSchema = z.object({}).describe("Log out of your Zapier account");
3090
3090
 
3091
3091
  // src/plugins/logout/index.ts
3092
3092
  var logoutPlugin = definePlugin(
3093
- (sdk2) => createPluginMethod(sdk2, {
3093
+ (sdk) => createPluginMethod(sdk, {
3094
3094
  name: "logout",
3095
3095
  categories: ["account"],
3096
3096
  inputSchema: LogoutSchema,
@@ -3107,12 +3107,16 @@ var McpSchema = z.object({
3107
3107
 
3108
3108
  // src/plugins/mcp/index.ts
3109
3109
  var mcpPlugin = definePlugin(
3110
- (sdk2) => createPluginMethod(sdk2, {
3110
+ (sdk) => createPluginMethod(sdk, {
3111
3111
  name: "mcp",
3112
3112
  categories: ["utility"],
3113
3113
  inputSchema: McpSchema,
3114
- handler: async ({ sdk: sdk3, options }) => {
3115
- await startMcpServer({ ...options, debug: sdk3.context.options?.debug });
3114
+ handler: async ({ sdk: sdk2, options }) => {
3115
+ await startMcpServer({
3116
+ ...options,
3117
+ debug: sdk2.context.options?.debug,
3118
+ extensions: sdk2.context.extensions
3119
+ });
3116
3120
  }
3117
3121
  })
3118
3122
  );
@@ -3127,7 +3131,7 @@ var BundleCodeSchema = z.object({
3127
3131
  cjs: z.boolean().optional().describe("Output CommonJS format instead of ESM")
3128
3132
  }).describe("Bundle TypeScript code into executable JavaScript");
3129
3133
  var bundleCodePlugin = definePlugin(
3130
- (sdk2) => createPluginMethod(sdk2, {
3134
+ (sdk) => createPluginMethod(sdk, {
3131
3135
  name: "bundleCode",
3132
3136
  categories: ["utility", "deprecated"],
3133
3137
  inputSchema: BundleCodeSchema,
@@ -3201,7 +3205,7 @@ async function bundleCode(options) {
3201
3205
  }
3202
3206
  var GetLoginConfigPathSchema = z.object({}).describe("Show the path to the login configuration file");
3203
3207
  var getLoginConfigPathPlugin = definePlugin(
3204
- (sdk2) => createPluginMethod(sdk2, {
3208
+ (sdk) => createPluginMethod(sdk, {
3205
3209
  name: "getLoginConfigPath",
3206
3210
  categories: ["utility"],
3207
3211
  inputSchema: GetLoginConfigPathSchema,
@@ -3236,11 +3240,11 @@ async function detectTypesOutputDirectory() {
3236
3240
  return "./zapier/apps/";
3237
3241
  }
3238
3242
  var addPlugin = definePlugin(
3239
- (sdk2) => createPluginMethod(sdk2, {
3243
+ (sdk) => createPluginMethod(sdk, {
3240
3244
  name: "add",
3241
3245
  categories: ["utility"],
3242
3246
  inputSchema: AddSchema,
3243
- handler: async ({ sdk: sdk3, options }) => {
3247
+ handler: async ({ sdk: sdk2, options }) => {
3244
3248
  const {
3245
3249
  apps: appKeys,
3246
3250
  connections: connectionIds,
@@ -3311,13 +3315,13 @@ var addPlugin = definePlugin(
3311
3315
  break;
3312
3316
  }
3313
3317
  };
3314
- const manifestResult = await sdk3.buildManifest({
3318
+ const manifestResult = await sdk2.buildManifest({
3315
3319
  apps: appKeys,
3316
3320
  skipWrite: false,
3317
3321
  configPath,
3318
3322
  onProgress: handleManifestProgress
3319
3323
  });
3320
- const typesResult = await sdk3.generateAppTypes({
3324
+ const typesResult = await sdk2.generateAppTypes({
3321
3325
  apps: appKeys,
3322
3326
  connections: connectionIds,
3323
3327
  skipWrite: false,
@@ -3363,14 +3367,14 @@ var AstTypeGenerator = class {
3363
3367
  * Generate TypeScript types using AST for a specific app
3364
3368
  */
3365
3369
  async generateTypes(options) {
3366
- const { app, connectionId, sdk: sdk2 } = options;
3367
- const actionsResult = await sdk2.listActions({
3370
+ const { app, connectionId, sdk } = options;
3371
+ const actionsResult = await sdk.listActions({
3368
3372
  appKey: app.implementation_id
3369
3373
  });
3370
3374
  const actions = actionsResult.data;
3371
3375
  const actionsWithFields = [];
3372
3376
  const inputFieldsTasks = actions.map(
3373
- (action) => () => sdk2.listInputFields({
3377
+ (action) => () => sdk.listInputFields({
3374
3378
  appKey: app.implementation_id,
3375
3379
  actionKey: action.key,
3376
3380
  actionType: action.action_type,
@@ -3941,13 +3945,13 @@ function createManifestEntry(app) {
3941
3945
  };
3942
3946
  }
3943
3947
  var generateAppTypesPlugin = definePlugin(
3944
- (sdk2) => createPluginMethod(sdk2, {
3948
+ (sdk) => createPluginMethod(sdk, {
3945
3949
  name: "generateAppTypes",
3946
3950
  categories: ["utility"],
3947
3951
  // Cast: schema validates JSON fields only; GenerateAppTypesOptions adds
3948
3952
  // the runtime-only `onProgress` callback (passthrough via createFunction).
3949
3953
  inputSchema: GenerateAppTypesSchema,
3950
- handler: async ({ sdk: sdk3, options }) => {
3954
+ handler: async ({ sdk: sdk2, options }) => {
3951
3955
  const {
3952
3956
  apps: appKeys,
3953
3957
  connections: connectionIds,
@@ -3958,7 +3962,7 @@ var generateAppTypesPlugin = definePlugin(
3958
3962
  const resolvedTypesOutput = resolve(typesOutputDirectory);
3959
3963
  const result = { typeDefinitions: {} };
3960
3964
  onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
3961
- const appsIterable = sdk3.listApps({ apps: appKeys }).items();
3965
+ const appsIterable = sdk2.listApps({ apps: appKeys }).items();
3962
3966
  const apps = [];
3963
3967
  for await (const app of appsIterable) {
3964
3968
  apps.push(app);
@@ -3974,7 +3978,7 @@ var generateAppTypesPlugin = definePlugin(
3974
3978
  type: "connections_lookup_start",
3975
3979
  count: connectionIds.length
3976
3980
  });
3977
- const connectionsIterable = sdk3.listConnections({ connections: connectionIds }).items();
3981
+ const connectionsIterable = sdk2.listConnections({ connections: connectionIds }).items();
3978
3982
  for await (const connection of connectionsIterable) {
3979
3983
  connections.push(connection);
3980
3984
  }
@@ -4035,7 +4039,7 @@ var generateAppTypesPlugin = definePlugin(
4035
4039
  const typeDefinitionString = await generator.generateTypes({
4036
4040
  app,
4037
4041
  connectionId,
4038
- sdk: sdk3
4042
+ sdk: sdk2
4039
4043
  });
4040
4044
  result.typeDefinitions[manifestKey] = typeDefinitionString;
4041
4045
  onProgress?.({
@@ -4083,7 +4087,7 @@ var BuildManifestSchema = z.object({
4083
4087
 
4084
4088
  // src/plugins/buildManifest/index.ts
4085
4089
  var buildManifestPlugin = definePlugin(
4086
- (sdk2) => createPluginMethod(sdk2, {
4090
+ (sdk) => createPluginMethod(sdk, {
4087
4091
  name: "buildManifest",
4088
4092
  categories: ["utility"],
4089
4093
  // Cast: BuildManifestSchema validates JSON-serializable fields only.
@@ -4091,7 +4095,7 @@ var buildManifestPlugin = definePlugin(
4091
4095
  // `createFunction`'s passthrough spread at runtime; this widens TInput
4092
4096
  // so the handler can read it.
4093
4097
  inputSchema: BuildManifestSchema,
4094
- handler: async ({ sdk: sdk3, options }) => {
4098
+ handler: async ({ sdk: sdk2, options }) => {
4095
4099
  const {
4096
4100
  apps: appKeys,
4097
4101
  skipWrite = false,
@@ -4099,7 +4103,7 @@ var buildManifestPlugin = definePlugin(
4099
4103
  onProgress
4100
4104
  } = options;
4101
4105
  onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
4102
- const appsIterable = sdk3.listApps({ apps: appKeys }).items();
4106
+ const appsIterable = sdk2.listApps({ apps: appKeys }).items();
4103
4107
  const apps = [];
4104
4108
  for await (const app of appsIterable) {
4105
4109
  apps.push(app);
@@ -4124,7 +4128,7 @@ var buildManifestPlugin = definePlugin(
4124
4128
  manifestKey: manifestEntry.implementationName,
4125
4129
  version: manifestEntry.version || ""
4126
4130
  });
4127
- const { key: updatedManifestKey, manifest } = await sdk3.context.updateManifestEntry({
4131
+ const { key: updatedManifestKey, manifest } = await sdk2.context.updateManifestEntry({
4128
4132
  appKey: app.key,
4129
4133
  entry: manifestEntry,
4130
4134
  configPath,
@@ -4190,12 +4194,12 @@ async function postWithRetry({
4190
4194
  return response;
4191
4195
  }
4192
4196
  var feedbackPlugin = definePlugin(
4193
- (sdk2) => createPluginMethod(sdk2, {
4197
+ (sdk) => createPluginMethod(sdk, {
4194
4198
  name: "feedback",
4195
4199
  categories: ["utility"],
4196
4200
  inputSchema: FeedbackSchema,
4197
4201
  resolvers: { feedback: feedbackResolver },
4198
- handler: async ({ sdk: sdk3, options }) => {
4202
+ handler: async ({ sdk: sdk2, options }) => {
4199
4203
  const user = await getLoggedInUser();
4200
4204
  const body = JSON.stringify({
4201
4205
  email: user.email,
@@ -4206,7 +4210,7 @@ var feedbackPlugin = definePlugin(
4206
4210
  body,
4207
4211
  attemptsLeft: MAX_RETRIES
4208
4212
  });
4209
- if (sdk3.context.options?.debug) {
4213
+ if (sdk2.context.options?.debug) {
4210
4214
  const text = await response.text();
4211
4215
  console.error("[debug] Webhook response:", text);
4212
4216
  }
@@ -4389,7 +4393,7 @@ async function buildFormData(formArgs, formStringArgs) {
4389
4393
  }
4390
4394
 
4391
4395
  // src/plugins/curl/index.ts
4392
- var curlPlugin = definePlugin((sdk2) => {
4396
+ var curlPlugin = definePlugin((sdk) => {
4393
4397
  async function curl(options) {
4394
4398
  const {
4395
4399
  url: rawUrl,
@@ -4522,7 +4526,7 @@ var curlPlugin = definePlugin((sdk2) => {
4522
4526
  process.stderr.write(">\n");
4523
4527
  }
4524
4528
  const start = performance.now();
4525
- const response = await sdk2.fetch(effectiveUrl.toString(), {
4529
+ const response = await sdk.fetch(effectiveUrl.toString(), {
4526
4530
  method,
4527
4531
  headers,
4528
4532
  body,
@@ -4634,13 +4638,13 @@ ${Array.from(
4634
4638
  };
4635
4639
  });
4636
4640
  var cliOverridesPlugin = definePlugin(
4637
- (sdk2) => {
4641
+ (sdk) => {
4638
4642
  const meta = {};
4639
- if (sdk2.context.meta.fetch) {
4643
+ if (sdk.context.meta.fetch) {
4640
4644
  meta.fetch = {
4641
- ...sdk2.context.meta.fetch,
4645
+ ...sdk.context.meta.fetch,
4642
4646
  categories: [
4643
- ...sdk2.context.meta.fetch.categories || [],
4647
+ ...sdk.context.meta.fetch.categories || [],
4644
4648
  "deprecated"
4645
4649
  ],
4646
4650
  deprecation: {
@@ -5090,7 +5094,7 @@ function displaySummaryAndNextSteps({
5090
5094
 
5091
5095
  // src/plugins/init/index.ts
5092
5096
  var initPlugin = definePlugin(
5093
- (sdk2) => createPluginMethod(sdk2, {
5097
+ (sdk) => createPluginMethod(sdk, {
5094
5098
  name: "init",
5095
5099
  categories: ["utility"],
5096
5100
  inputSchema: InitSchema,
@@ -5147,16 +5151,78 @@ var initPlugin = definePlugin(
5147
5151
  // package.json with { type: 'json' }
5148
5152
  var package_default2 = {
5149
5153
  name: "@zapier/zapier-sdk-cli",
5150
- version: "0.43.4"};
5154
+ version: "0.44.0"};
5151
5155
 
5152
5156
  // src/sdk.ts
5153
5157
  injectCliLogin(login_exports);
5154
5158
  function createZapierCliSdk(options = {}) {
5155
- return createZapierSdk({
5156
- ...options,
5157
- eventEmission: { ...options.eventEmission, callContext: "cli" },
5159
+ const { extensions = [], ...sdkOptions } = options;
5160
+ const extensionsContextPlugin = () => ({
5161
+ context: { extensions }
5162
+ });
5163
+ let chain = createZapierSdk({
5164
+ ...sdkOptions,
5165
+ eventEmission: { ...sdkOptions.eventEmission, callContext: "cli" },
5158
5166
  callerPackage: { name: package_default2.name, version: package_default2.version }
5159
- }).addPlugin(generateAppTypesPlugin).addPlugin(buildManifestPlugin).addPlugin(bundleCodePlugin).addPlugin(getLoginConfigPathPlugin).addPlugin(addPlugin).addPlugin(feedbackPlugin).addPlugin(curlPlugin).addPlugin(initPlugin).addPlugin(mcpPlugin).addPlugin(loginPlugin).addPlugin(logoutPlugin).addPlugin(cliOverridesPlugin);
5167
+ }).addPlugin(extensionsContextPlugin).addPlugin(generateAppTypesPlugin).addPlugin(buildManifestPlugin).addPlugin(bundleCodePlugin).addPlugin(getLoginConfigPathPlugin).addPlugin(addPlugin).addPlugin(feedbackPlugin).addPlugin(curlPlugin).addPlugin(initPlugin).addPlugin(mcpPlugin).addPlugin(loginPlugin).addPlugin(logoutPlugin).addPlugin(cliOverridesPlugin);
5168
+ for (const ext of extensions) {
5169
+ try {
5170
+ chain = chain.addPlugin(ext);
5171
+ } catch (err) {
5172
+ console.warn(
5173
+ `Extension plugin failed to construct: ${err.message}; skipping.`
5174
+ );
5175
+ }
5176
+ }
5177
+ return chain;
5178
+ }
5179
+
5180
+ // src/utils/extensions.ts
5181
+ var ENV_VAR = "ZAPIER_SDK_EXTENSIONS";
5182
+ async function resolveExtensions() {
5183
+ const seen = /* @__PURE__ */ new Set();
5184
+ const specs = readEnvSpecs().filter((spec) => {
5185
+ if (seen.has(spec)) return false;
5186
+ seen.add(spec);
5187
+ return true;
5188
+ });
5189
+ const plugins = [];
5190
+ for (const spec of specs) {
5191
+ try {
5192
+ const mod = await import(spec);
5193
+ const exported = mod.default ?? mod;
5194
+ const got = normalizeExtension(exported);
5195
+ if (got) {
5196
+ plugins.push(...got);
5197
+ } else {
5198
+ console.warn(
5199
+ `Extension '${spec}': unrecognized default export shape; skipping.`
5200
+ );
5201
+ }
5202
+ } catch (err) {
5203
+ console.warn(
5204
+ `Extension '${spec}' failed to load: ${err.message}`
5205
+ );
5206
+ }
5207
+ }
5208
+ return plugins;
5209
+ }
5210
+ function normalizeExtension(exported) {
5211
+ if (typeof exported === "function") {
5212
+ return [exported];
5213
+ }
5214
+ if (Array.isArray(exported)) {
5215
+ if (exported.every((e) => typeof e === "function")) {
5216
+ return exported;
5217
+ }
5218
+ return null;
5219
+ }
5220
+ return null;
5221
+ }
5222
+ function readEnvSpecs() {
5223
+ const raw = process.env[ENV_VAR];
5224
+ if (!raw) return [];
5225
+ return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
5160
5226
  }
5161
5227
  var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
5162
5228
  var CACHE_RESET_INTERVAL_MS = (() => {
@@ -5387,19 +5453,21 @@ for (const { camelName, kebabFlag } of booleanFlags) {
5387
5453
  flagOverrides[camelName] = true;
5388
5454
  }
5389
5455
  }
5390
- var sdk = createZapierCliSdk({
5391
- debug: isDebugMode,
5392
- credentials,
5393
- baseUrl,
5394
- trackingBaseUrl,
5395
- maxNetworkRetries,
5396
- maxNetworkRetryDelayMs,
5397
- ...flagOverrides
5398
- });
5399
- generateCliCommands(program, sdk);
5400
5456
  program.exitOverride();
5401
5457
  (async () => {
5402
5458
  let exitCode = 0;
5459
+ const extensions = await resolveExtensions();
5460
+ const sdk = createZapierCliSdk({
5461
+ debug: isDebugMode,
5462
+ credentials,
5463
+ baseUrl,
5464
+ trackingBaseUrl,
5465
+ maxNetworkRetries,
5466
+ maxNetworkRetryDelayMs,
5467
+ ...flagOverrides,
5468
+ extensions
5469
+ });
5470
+ generateCliCommands(program, sdk);
5403
5471
  const versionCheckPromise = checkAndNotifyUpdates({
5404
5472
  packageName: package_default2.name,
5405
5473
  currentVersion: package_default2.version
package/dist/index.cjs CHANGED
@@ -993,7 +993,11 @@ var mcpPlugin = zapierSdk.definePlugin(
993
993
  categories: ["utility"],
994
994
  inputSchema: McpSchema,
995
995
  handler: async ({ sdk: sdk2, options }) => {
996
- await zapierSdkMcp.startMcpServer({ ...options, debug: sdk2.context.options?.debug });
996
+ await zapierSdkMcp.startMcpServer({
997
+ ...options,
998
+ debug: sdk2.context.options?.debug,
999
+ extensions: sdk2.context.extensions
1000
+ });
997
1001
  }
998
1002
  })
999
1003
  );
@@ -3001,21 +3005,35 @@ var initPlugin = zapierSdk.definePlugin(
3001
3005
  // package.json with { type: 'json' }
3002
3006
  var package_default = {
3003
3007
  name: "@zapier/zapier-sdk-cli",
3004
- version: "0.43.4"};
3008
+ version: "0.44.0"};
3005
3009
 
3006
3010
  // src/sdk.ts
3007
3011
  zapierSdk.injectCliLogin(login_exports);
3008
3012
  function createZapierCliSdk(options = {}) {
3009
- return zapierSdk.createZapierSdk({
3010
- ...options,
3011
- eventEmission: { ...options.eventEmission, callContext: "cli" },
3013
+ const { extensions = [], ...sdkOptions } = options;
3014
+ const extensionsContextPlugin = () => ({
3015
+ context: { extensions }
3016
+ });
3017
+ let chain = zapierSdk.createZapierSdk({
3018
+ ...sdkOptions,
3019
+ eventEmission: { ...sdkOptions.eventEmission, callContext: "cli" },
3012
3020
  callerPackage: { name: package_default.name, version: package_default.version }
3013
- }).addPlugin(generateAppTypesPlugin).addPlugin(buildManifestPlugin).addPlugin(bundleCodePlugin).addPlugin(getLoginConfigPathPlugin).addPlugin(addPlugin).addPlugin(feedbackPlugin).addPlugin(curlPlugin).addPlugin(initPlugin).addPlugin(mcpPlugin).addPlugin(loginPlugin).addPlugin(logoutPlugin).addPlugin(cliOverridesPlugin);
3021
+ }).addPlugin(extensionsContextPlugin).addPlugin(generateAppTypesPlugin).addPlugin(buildManifestPlugin).addPlugin(bundleCodePlugin).addPlugin(getLoginConfigPathPlugin).addPlugin(addPlugin).addPlugin(feedbackPlugin).addPlugin(curlPlugin).addPlugin(initPlugin).addPlugin(mcpPlugin).addPlugin(loginPlugin).addPlugin(logoutPlugin).addPlugin(cliOverridesPlugin);
3022
+ for (const ext of extensions) {
3023
+ try {
3024
+ chain = chain.addPlugin(ext);
3025
+ } catch (err) {
3026
+ console.warn(
3027
+ `Extension plugin failed to construct: ${err.message}; skipping.`
3028
+ );
3029
+ }
3030
+ }
3031
+ return chain;
3014
3032
  }
3015
3033
 
3016
3034
  // package.json
3017
3035
  var package_default2 = {
3018
- version: "0.43.4"};
3036
+ version: "0.44.0"};
3019
3037
 
3020
3038
  // src/telemetry/builders.ts
3021
3039
  function createCliBaseEvent(context = {}) {
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _zapier_zapier_sdk from '@zapier/zapier-sdk';
2
- import { AppItem, Manifest, ZapierSdk, ZapierSdkOptions, BaseEvent } from '@zapier/zapier-sdk';
2
+ import { AppItem, Manifest, ZapierSdk, ZapierSdkOptions, Plugin, PluginProvides, BaseEvent } from '@zapier/zapier-sdk';
3
3
  import { z } from 'zod';
4
4
 
5
5
  declare const BuildManifestSchema: z.ZodObject<{
@@ -514,6 +514,14 @@ type GenerateAppTypesPluginProvides = ReturnType<typeof generateAppTypesPlugin>;
514
514
  type ZapierSdkCli = ZapierSdk & BuildManifestPluginProvides & FeedbackPluginProvides & GenerateAppTypesPluginProvides;
515
515
 
516
516
  interface ZapierCliSdkOptions extends ZapierSdkOptions {
517
+ /**
518
+ * Extra plugins discovered from `@zapier/zapier-sdk` extension packages.
519
+ * Pre-resolved by `cli.ts` (`utils/extensions.ts`) so this factory stays
520
+ * synchronous. Each plugin is layered onto the chain after all built-in
521
+ * CLI plugins, so its functions appear in `getRegistry({ package: "cli" })`
522
+ * automatically.
523
+ */
524
+ extensions?: Plugin<unknown, PluginProvides>[];
517
525
  }
518
526
  /**
519
527
  * Create a Zapier SDK instance configured specifically for the CLI
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _zapier_zapier_sdk from '@zapier/zapier-sdk';
2
- import { AppItem, Manifest, ZapierSdk, ZapierSdkOptions, BaseEvent } from '@zapier/zapier-sdk';
2
+ import { AppItem, Manifest, ZapierSdk, ZapierSdkOptions, Plugin, PluginProvides, BaseEvent } from '@zapier/zapier-sdk';
3
3
  import { z } from 'zod';
4
4
 
5
5
  declare const BuildManifestSchema: z.ZodObject<{
@@ -514,6 +514,14 @@ type GenerateAppTypesPluginProvides = ReturnType<typeof generateAppTypesPlugin>;
514
514
  type ZapierSdkCli = ZapierSdk & BuildManifestPluginProvides & FeedbackPluginProvides & GenerateAppTypesPluginProvides;
515
515
 
516
516
  interface ZapierCliSdkOptions extends ZapierSdkOptions {
517
+ /**
518
+ * Extra plugins discovered from `@zapier/zapier-sdk` extension packages.
519
+ * Pre-resolved by `cli.ts` (`utils/extensions.ts`) so this factory stays
520
+ * synchronous. Each plugin is layered onto the chain after all built-in
521
+ * CLI plugins, so its functions appear in `getRegistry({ package: "cli" })`
522
+ * automatically.
523
+ */
524
+ extensions?: Plugin<unknown, PluginProvides>[];
517
525
  }
518
526
  /**
519
527
  * Create a Zapier SDK instance configured specifically for the CLI
package/dist/index.mjs CHANGED
@@ -957,7 +957,11 @@ var mcpPlugin = definePlugin(
957
957
  categories: ["utility"],
958
958
  inputSchema: McpSchema,
959
959
  handler: async ({ sdk: sdk2, options }) => {
960
- await startMcpServer({ ...options, debug: sdk2.context.options?.debug });
960
+ await startMcpServer({
961
+ ...options,
962
+ debug: sdk2.context.options?.debug,
963
+ extensions: sdk2.context.extensions
964
+ });
961
965
  }
962
966
  })
963
967
  );
@@ -2965,21 +2969,35 @@ var initPlugin = definePlugin(
2965
2969
  // package.json with { type: 'json' }
2966
2970
  var package_default = {
2967
2971
  name: "@zapier/zapier-sdk-cli",
2968
- version: "0.43.4"};
2972
+ version: "0.44.0"};
2969
2973
 
2970
2974
  // src/sdk.ts
2971
2975
  injectCliLogin(login_exports);
2972
2976
  function createZapierCliSdk(options = {}) {
2973
- return createZapierSdk({
2974
- ...options,
2975
- eventEmission: { ...options.eventEmission, callContext: "cli" },
2977
+ const { extensions = [], ...sdkOptions } = options;
2978
+ const extensionsContextPlugin = () => ({
2979
+ context: { extensions }
2980
+ });
2981
+ let chain = createZapierSdk({
2982
+ ...sdkOptions,
2983
+ eventEmission: { ...sdkOptions.eventEmission, callContext: "cli" },
2976
2984
  callerPackage: { name: package_default.name, version: package_default.version }
2977
- }).addPlugin(generateAppTypesPlugin).addPlugin(buildManifestPlugin).addPlugin(bundleCodePlugin).addPlugin(getLoginConfigPathPlugin).addPlugin(addPlugin).addPlugin(feedbackPlugin).addPlugin(curlPlugin).addPlugin(initPlugin).addPlugin(mcpPlugin).addPlugin(loginPlugin).addPlugin(logoutPlugin).addPlugin(cliOverridesPlugin);
2985
+ }).addPlugin(extensionsContextPlugin).addPlugin(generateAppTypesPlugin).addPlugin(buildManifestPlugin).addPlugin(bundleCodePlugin).addPlugin(getLoginConfigPathPlugin).addPlugin(addPlugin).addPlugin(feedbackPlugin).addPlugin(curlPlugin).addPlugin(initPlugin).addPlugin(mcpPlugin).addPlugin(loginPlugin).addPlugin(logoutPlugin).addPlugin(cliOverridesPlugin);
2986
+ for (const ext of extensions) {
2987
+ try {
2988
+ chain = chain.addPlugin(ext);
2989
+ } catch (err) {
2990
+ console.warn(
2991
+ `Extension plugin failed to construct: ${err.message}; skipping.`
2992
+ );
2993
+ }
2994
+ }
2995
+ return chain;
2978
2996
  }
2979
2997
 
2980
2998
  // package.json
2981
2999
  var package_default2 = {
2982
- version: "0.43.4"};
3000
+ version: "0.44.0"};
2983
3001
 
2984
3002
  // src/telemetry/builders.ts
2985
3003
  function createCliBaseEvent(context = {}) {