@zapier/zapier-sdk-cli 0.12.1 → 0.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk-cli",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "description": "Command line interface for Zapier SDK",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -42,9 +42,9 @@
42
42
  "ora": "^8.2.0",
43
43
  "pkce-challenge": "^5.0.0",
44
44
  "zod": "^3.25.67",
45
- "@zapier/zapier-sdk-mcp": "0.3.12",
45
+ "@zapier/zapier-sdk": "0.13.0",
46
46
  "@zapier/zapier-sdk-cli-login": "0.3.2",
47
- "@zapier/zapier-sdk": "0.12.1"
47
+ "@zapier/zapier-sdk-mcp": "0.3.13"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/express": "^5.0.3",
@@ -1,15 +1,15 @@
1
1
  import * as ts from "typescript";
2
2
  import type {
3
3
  Action,
4
- ActionField,
4
+ InputFieldItem,
5
5
  GetSdkType,
6
6
  ListActionsPluginProvides,
7
7
  ListInputFieldsPluginProvides,
8
8
  ManifestPluginProvides,
9
9
  } from "@zapier/zapier-sdk";
10
10
 
11
- interface ActionWithActionFields extends Omit<Action, "inputFields" | "type"> {
12
- inputFields: ActionField[];
11
+ interface ActionWithInputFields extends Omit<Action, "inputFields" | "type"> {
12
+ inputFields: InputFieldItem[];
13
13
  app_key: string;
14
14
  action_type: Action["type"];
15
15
  title: string;
@@ -61,7 +61,7 @@ export class AstTypeGenerator {
61
61
  }
62
62
 
63
63
  // Fetch input fields for each action
64
- const actionsWithFields: ActionWithActionFields[] = [];
64
+ const actionsWithFields: ActionWithInputFields[] = [];
65
65
 
66
66
  if (authenticationId) {
67
67
  for (const action of actions) {
@@ -73,19 +73,7 @@ export class AstTypeGenerator {
73
73
  authenticationId: authenticationId,
74
74
  });
75
75
 
76
- const fields = fieldsResult.data.map(
77
- (field: unknown): ActionField => {
78
- const fieldObj = field as {
79
- is_required?: boolean;
80
- required?: boolean;
81
- [key: string]: unknown;
82
- };
83
- return {
84
- ...fieldObj,
85
- required: fieldObj.is_required || fieldObj.required || false,
86
- } as ActionField;
87
- },
88
- );
76
+ const fields = fieldsResult.data as InputFieldItem[];
89
77
  actionsWithFields.push({
90
78
  ...action,
91
79
  inputFields: fields,
@@ -144,7 +132,7 @@ export class AstTypeGenerator {
144
132
 
145
133
  private createSourceFile(
146
134
  appKey: string,
147
- actions: ActionWithActionFields[],
135
+ actions: ActionWithInputFields[],
148
136
  version?: string,
149
137
  ): ts.SourceFile {
150
138
  const appName = this.capitalize(appKey);
@@ -329,31 +317,31 @@ Usage:
329
317
  }
330
318
 
331
319
  private groupActionsByType(
332
- actions: ActionWithActionFields[],
333
- ): Record<string, ActionWithActionFields[]> {
320
+ actions: ActionWithInputFields[],
321
+ ): Record<string, ActionWithInputFields[]> {
334
322
  return actions.reduce(
335
- (acc, action) => {
323
+ (acc: Record<string, ActionWithInputFields[]>, action) => {
336
324
  if (!acc[action.action_type]) {
337
325
  acc[action.action_type] = [];
338
326
  }
339
327
  acc[action.action_type].push(action);
340
328
  return acc;
341
329
  },
342
- {} as Record<string, ActionWithActionFields[]>,
330
+ {} as Record<string, ActionWithInputFields[]>,
343
331
  );
344
332
  }
345
333
 
346
334
  private createInputInterface(
347
335
  appName: string,
348
- action: ActionWithActionFields,
336
+ action: ActionWithInputFields,
349
337
  ): ts.InterfaceDeclaration {
350
338
  const inputTypeName = `${appName}${this.capitalize(action.action_type)}${this.capitalize(
351
339
  this.sanitizeActionName(action.key),
352
340
  )}Inputs`;
353
341
 
354
- const properties = action.inputFields.map((field) => {
342
+ const properties = action.inputFields.map((field: InputFieldItem) => {
355
343
  const fieldType = this.mapFieldTypeToTypeNode(field);
356
- const isOptional = !field.required;
344
+ const isOptional = !field.is_required;
357
345
 
358
346
  let property = this.factory.createPropertySignature(
359
347
  undefined,
@@ -364,12 +352,12 @@ Usage:
364
352
  fieldType,
365
353
  );
366
354
 
367
- // Add JSDoc comment if helpText exists
368
- if (field.helpText) {
355
+ // Add JSDoc comment if description exists
356
+ if (field.description) {
369
357
  property = ts.addSyntheticLeadingComment(
370
358
  property,
371
359
  ts.SyntaxKind.MultiLineCommentTrivia,
372
- `* ${this.escapeComment(field.helpText)} `,
360
+ `* ${this.escapeComment(field.description)} `,
373
361
  true,
374
362
  );
375
363
  }
@@ -389,7 +377,7 @@ Usage:
389
377
  private createActionInterface(
390
378
  appName: string,
391
379
  actionType: string,
392
- typeActions: ActionWithActionFields[],
380
+ typeActions: ActionWithInputFields[],
393
381
  ): ts.InterfaceDeclaration {
394
382
  const typeName = `${appName}${this.capitalize(actionType)}Actions`;
395
383
 
@@ -506,7 +494,7 @@ Usage:
506
494
 
507
495
  private createAppProxyInterface(
508
496
  appName: string,
509
- actionsByType: Record<string, ActionWithActionFields[]>,
497
+ actionsByType: Record<string, ActionWithInputFields[]>,
510
498
  ): ts.InterfaceDeclaration {
511
499
  const properties = [
512
500
  ...Object.keys(actionsByType).map((actionType) =>
@@ -646,33 +634,12 @@ Usage:
646
634
  );
647
635
  }
648
636
 
649
- private mapFieldTypeToTypeNode(field: ActionField): ts.TypeNode {
650
- // Handle choices (enum-like fields)
651
- if (field.choices && field.choices.length > 0) {
652
- const choiceValues = field.choices
653
- .filter(
654
- (choice) =>
655
- choice.value !== undefined &&
656
- choice.value !== null &&
657
- choice.value !== "",
658
- )
659
- .map((choice) =>
660
- typeof choice.value === "string"
661
- ? this.factory.createLiteralTypeNode(
662
- this.factory.createStringLiteral(choice.value),
663
- )
664
- : this.factory.createLiteralTypeNode(
665
- this.factory.createNumericLiteral(String(choice.value)),
666
- ),
667
- );
668
-
669
- if (choiceValues.length > 0) {
670
- return this.factory.createUnionTypeNode(choiceValues);
671
- }
672
- }
637
+ private mapFieldTypeToTypeNode(field: InputFieldItem): ts.TypeNode {
638
+ // TODO: Handle choices when needed - choices are handled separately through listInputFieldChoices
673
639
 
674
640
  // Map Zapier field types to TypeScript types
675
- switch (field.type?.toLowerCase()) {
641
+ // Handle the new enum types from InputFieldItem.value_type
642
+ switch (field.value_type?.toLowerCase()) {
676
643
  case "string":
677
644
  case "text":
678
645
  case "email":
@@ -1,25 +1,10 @@
1
1
  import chalk from "chalk";
2
2
  import type { z } from "zod";
3
3
  import util from "util";
4
+ import type { FormattedItem, FormatMetadata } from "@zapier/zapier-sdk";
4
5
  // These functions are internal to SDK, implementing basic formatting fallback
5
6
  // TODO: Consider exposing these utilities or implementing proper CLI formatting
6
7
 
7
- interface FormattedItem {
8
- title: string;
9
- id?: string;
10
- key?: string;
11
- description?: string;
12
- data?: unknown; // Optional: if provided, use formatJsonOutput instead of details
13
- details: Array<{
14
- text: string;
15
- style: "normal" | "dim" | "accent" | "warning" | "success";
16
- }>;
17
- }
18
-
19
- interface FormatMetadata {
20
- format: (item: unknown) => FormattedItem;
21
- }
22
-
23
8
  function getFormatMetadata(schema: unknown): FormatMetadata | undefined {
24
9
  return (schema as { _def?: { formatMeta?: FormatMetadata } })?._def
25
10
  ?.formatMeta;
@@ -84,6 +69,8 @@ function formatSingleItem(formatted: FormattedItem, itemNumber: number): void {
84
69
  // Generate subtitle from id or key
85
70
  if (formatted.id) {
86
71
  titleLine += ` ${chalk.gray(`(ID: ${formatted.id})`)}`;
72
+ } else if (formatted.keys) {
73
+ titleLine += ` ${chalk.gray(`(${formatted.keys.join(", ")})`)}`;
87
74
  } else if (formatted.key) {
88
75
  titleLine += ` ${chalk.gray(`(${formatted.key})`)}`;
89
76
  }