@zapier/zapier-sdk 0.9.0 → 0.11.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.
Files changed (187) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +7 -7
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +14 -0
  5. package/dist/api/debug.d.ts +1 -0
  6. package/dist/api/debug.d.ts.map +1 -1
  7. package/dist/api/debug.js +42 -1
  8. package/dist/api/debug.test.d.ts +2 -0
  9. package/dist/api/debug.test.d.ts.map +1 -0
  10. package/dist/api/debug.test.js +59 -0
  11. package/dist/api/schemas.d.ts +451 -251
  12. package/dist/api/schemas.d.ts.map +1 -1
  13. package/dist/api/schemas.js +51 -29
  14. package/dist/index.cjs +968 -582
  15. package/dist/index.d.mts +2537 -2229
  16. package/dist/index.d.ts +2 -3
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +2 -3
  19. package/dist/index.mjs +966 -576
  20. package/dist/plugins/findFirstAuthentication/index.d.ts +1 -1
  21. package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
  22. package/dist/plugins/findFirstAuthentication/index.js +9 -1
  23. package/dist/plugins/findFirstAuthentication/index.test.js +3 -4
  24. package/dist/plugins/findFirstAuthentication/schemas.d.ts +5 -3
  25. package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -1
  26. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
  27. package/dist/plugins/findUniqueAuthentication/index.js +4 -0
  28. package/dist/plugins/findUniqueAuthentication/schemas.d.ts +5 -3
  29. package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -1
  30. package/dist/plugins/getAction/index.d.ts.map +1 -1
  31. package/dist/plugins/getAction/index.js +10 -0
  32. package/dist/plugins/getAction/schemas.d.ts +5 -3
  33. package/dist/plugins/getAction/schemas.d.ts.map +1 -1
  34. package/dist/plugins/getApp/index.d.ts.map +1 -1
  35. package/dist/plugins/getApp/index.js +8 -0
  36. package/dist/plugins/getApp/index.test.js +2 -2
  37. package/dist/plugins/getApp/schemas.d.ts +3 -1
  38. package/dist/plugins/getApp/schemas.d.ts.map +1 -1
  39. package/dist/plugins/getApp/schemas.js +2 -4
  40. package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
  41. package/dist/plugins/getAuthentication/index.js +8 -0
  42. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  43. package/dist/plugins/getProfile/index.js +4 -0
  44. package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
  45. package/dist/plugins/getProfile/schemas.js +4 -3
  46. package/dist/plugins/listActions/index.d.ts.map +1 -1
  47. package/dist/plugins/listActions/index.js +9 -0
  48. package/dist/plugins/listActions/schemas.d.ts +5 -3
  49. package/dist/plugins/listActions/schemas.d.ts.map +1 -1
  50. package/dist/plugins/listActions/schemas.js +2 -4
  51. package/dist/plugins/listApps/index.d.ts.map +1 -1
  52. package/dist/plugins/listApps/index.js +4 -0
  53. package/dist/plugins/listApps/index.test.js +1 -1
  54. package/dist/plugins/listApps/schemas.d.ts.map +1 -1
  55. package/dist/plugins/listApps/schemas.js +3 -9
  56. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  57. package/dist/plugins/listAuthentications/index.js +8 -0
  58. package/dist/plugins/listAuthentications/schemas.d.ts +5 -3
  59. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
  60. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  61. package/dist/plugins/listInputFieldChoices/index.js +14 -2
  62. package/dist/plugins/listInputFieldChoices/schemas.d.ts +5 -3
  63. package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
  64. package/dist/plugins/listInputFieldChoices/schemas.js +10 -19
  65. package/dist/plugins/listInputFields/index.d.ts +4 -4
  66. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  67. package/dist/plugins/listInputFields/index.js +71 -5
  68. package/dist/plugins/listInputFields/index.test.js +5 -9
  69. package/dist/plugins/listInputFields/schemas.d.ts +8 -6
  70. package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
  71. package/dist/plugins/registry/index.d.ts.map +1 -1
  72. package/dist/plugins/registry/index.js +8 -2
  73. package/dist/plugins/request/index.d.ts.map +1 -1
  74. package/dist/plugins/request/index.js +1 -0
  75. package/dist/plugins/runAction/index.d.ts.map +1 -1
  76. package/dist/plugins/runAction/index.js +12 -0
  77. package/dist/plugins/runAction/schemas.d.ts +5 -3
  78. package/dist/plugins/runAction/schemas.d.ts.map +1 -1
  79. package/dist/resolvers/actionKey.d.ts +13 -7
  80. package/dist/resolvers/actionKey.d.ts.map +1 -1
  81. package/dist/resolvers/actionType.d.ts +8 -7
  82. package/dist/resolvers/actionType.d.ts.map +1 -1
  83. package/dist/resolvers/appKey.d.ts +2 -6
  84. package/dist/resolvers/appKey.d.ts.map +1 -1
  85. package/dist/resolvers/authenticationId.d.ts +7 -7
  86. package/dist/resolvers/authenticationId.d.ts.map +1 -1
  87. package/dist/resolvers/authenticationId.js +16 -7
  88. package/dist/resolvers/index.d.ts +3 -35
  89. package/dist/resolvers/index.d.ts.map +1 -1
  90. package/dist/resolvers/index.js +4 -87
  91. package/dist/resolvers/inputFieldKey.d.ts +11 -0
  92. package/dist/resolvers/inputFieldKey.d.ts.map +1 -0
  93. package/dist/resolvers/inputFieldKey.js +47 -0
  94. package/dist/resolvers/inputs.d.ts +13 -4
  95. package/dist/resolvers/inputs.d.ts.map +1 -1
  96. package/dist/resolvers/inputs.js +36 -0
  97. package/dist/schemas/Action.d.ts +8 -8
  98. package/dist/schemas/Action.d.ts.map +1 -1
  99. package/dist/schemas/Action.js +8 -3
  100. package/dist/schemas/App.d.ts +183 -11
  101. package/dist/schemas/App.d.ts.map +1 -1
  102. package/dist/schemas/App.js +7 -9
  103. package/dist/schemas/Auth.d.ts +12 -12
  104. package/dist/schemas/Auth.js +1 -1
  105. package/dist/schemas/Field.d.ts +112 -97
  106. package/dist/schemas/Field.d.ts.map +1 -1
  107. package/dist/schemas/Field.js +63 -52
  108. package/dist/schemas/Run.d.ts +3 -0
  109. package/dist/schemas/Run.d.ts.map +1 -0
  110. package/dist/schemas/Run.js +31 -0
  111. package/dist/schemas/UserProfile.d.ts +11 -11
  112. package/dist/schemas/UserProfile.d.ts.map +1 -1
  113. package/dist/schemas/UserProfile.js +21 -7
  114. package/dist/sdk.d.ts +11 -4
  115. package/dist/sdk.d.ts.map +1 -1
  116. package/dist/types/domain.d.ts +17 -1
  117. package/dist/types/domain.d.ts.map +1 -1
  118. package/dist/types/plugin.d.ts +5 -0
  119. package/dist/types/plugin.d.ts.map +1 -1
  120. package/dist/types/properties.d.ts +3 -1
  121. package/dist/types/properties.d.ts.map +1 -1
  122. package/dist/types/sdk.d.ts +5 -0
  123. package/dist/types/sdk.d.ts.map +1 -1
  124. package/dist/utils/domain-utils.d.ts +1 -16
  125. package/dist/utils/domain-utils.d.ts.map +1 -1
  126. package/dist/utils/domain-utils.js +7 -51
  127. package/dist/utils/schema-utils.d.ts +44 -21
  128. package/dist/utils/schema-utils.d.ts.map +1 -1
  129. package/dist/utils/schema-utils.js +17 -11
  130. package/dist/utils/string-utils.d.ts +12 -0
  131. package/dist/utils/string-utils.d.ts.map +1 -0
  132. package/dist/utils/string-utils.js +23 -0
  133. package/dist/utils/string-utils.test.d.ts +2 -0
  134. package/dist/utils/string-utils.test.d.ts.map +1 -0
  135. package/dist/utils/string-utils.test.js +36 -0
  136. package/package.json +1 -1
  137. package/src/api/client.ts +12 -0
  138. package/src/api/debug.test.ts +76 -0
  139. package/src/api/debug.ts +46 -2
  140. package/src/api/schemas.ts +51 -29
  141. package/src/index.ts +4 -5
  142. package/src/plugins/findFirstAuthentication/index.test.ts +8 -5
  143. package/src/plugins/findFirstAuthentication/index.ts +14 -2
  144. package/src/plugins/findUniqueAuthentication/index.ts +4 -0
  145. package/src/plugins/getAction/index.ts +14 -0
  146. package/src/plugins/getApp/index.test.ts +2 -2
  147. package/src/plugins/getApp/index.ts +8 -0
  148. package/src/plugins/getApp/schemas.ts +7 -12
  149. package/src/plugins/getAuthentication/index.ts +8 -0
  150. package/src/plugins/getProfile/index.ts +4 -0
  151. package/src/plugins/getProfile/schemas.ts +4 -6
  152. package/src/plugins/listActions/index.ts +9 -0
  153. package/src/plugins/listActions/schemas.ts +20 -25
  154. package/src/plugins/listApps/index.test.ts +1 -1
  155. package/src/plugins/listApps/index.ts +4 -0
  156. package/src/plugins/listApps/schemas.ts +17 -26
  157. package/src/plugins/listAuthentications/index.ts +8 -0
  158. package/src/plugins/listInputFieldChoices/index.ts +21 -1
  159. package/src/plugins/listInputFieldChoices/schemas.ts +61 -76
  160. package/src/plugins/listInputFields/index.test.ts +5 -9
  161. package/src/plugins/listInputFields/index.ts +89 -11
  162. package/src/plugins/listInputFields/schemas.ts +6 -3
  163. package/src/plugins/registry/index.ts +8 -2
  164. package/src/plugins/request/index.ts +1 -0
  165. package/src/plugins/runAction/index.ts +18 -0
  166. package/src/resolvers/actionKey.ts +15 -13
  167. package/src/resolvers/actionType.ts +10 -12
  168. package/src/resolvers/appKey.ts +2 -6
  169. package/src/resolvers/authenticationId.ts +25 -19
  170. package/src/resolvers/index.ts +7 -113
  171. package/src/resolvers/inputFieldKey.ts +70 -0
  172. package/src/resolvers/inputs.ts +51 -7
  173. package/src/schemas/Action.ts +8 -3
  174. package/src/schemas/App.ts +7 -9
  175. package/src/schemas/Auth.ts +1 -1
  176. package/src/schemas/Field.ts +97 -60
  177. package/src/schemas/Run.ts +40 -0
  178. package/src/schemas/UserProfile.ts +24 -7
  179. package/src/sdk.ts +17 -7
  180. package/src/types/domain.ts +24 -1
  181. package/src/types/plugin.ts +5 -0
  182. package/src/types/sdk.ts +5 -0
  183. package/src/utils/domain-utils.ts +9 -67
  184. package/src/utils/schema-utils.ts +96 -44
  185. package/src/utils/string-utils.test.ts +45 -0
  186. package/src/utils/string-utils.ts +26 -0
  187. package/tsconfig.tsbuildinfo +1 -1
package/dist/index.mjs CHANGED
@@ -3,19 +3,22 @@ import { setTimeout } from 'timers/promises';
3
3
 
4
4
  // src/types/properties.ts
5
5
  function withFormatter(schema, formatMeta) {
6
- schema._def.formatMeta = formatMeta;
6
+ Object.assign(schema._def, {
7
+ formatMeta
8
+ });
7
9
  return schema;
8
10
  }
9
- function withOutputSchema(inputSchema, outputSchema) {
10
- inputSchema._def.outputSchema = outputSchema;
11
- return inputSchema;
12
- }
13
11
  function withPositional(schema) {
14
- schema._def.positionalMeta = { positional: true };
12
+ Object.assign(schema._def, {
13
+ positionalMeta: { positional: true }
14
+ });
15
15
  return schema;
16
16
  }
17
+ function schemaHasPositionalMeta(schema) {
18
+ return "positionalMeta" in schema._def;
19
+ }
17
20
  function isPositional(schema) {
18
- if (schema._def.positionalMeta?.positional) {
21
+ if (schemaHasPositionalMeta(schema) && schema._def.positionalMeta?.positional) {
19
22
  return true;
20
23
  }
21
24
  if (schema instanceof z.ZodOptional) {
@@ -602,243 +605,14 @@ function createPaginatedFunction(coreFn, schema) {
602
605
  };
603
606
  return namedFunctions[functionName];
604
607
  }
605
- var AppItemSchema = withFormatter(
606
- z.object({
607
- // Essential properties only
608
- title: z.string(),
609
- // Mapped from name
610
- key: z.string(),
611
- // Mapped from selected_api
612
- current_implementation_id: z.string(),
613
- // From id, keeps the full version
614
- version: z.string().optional(),
615
- // Extracted from implementation ID
616
- description: z.string().optional(),
617
- slug: z.string().optional()
618
- }),
619
- {
620
- format: (item) => {
621
- return {
622
- title: item.title,
623
- subtitle: `(${item.key})`,
624
- details: []
625
- };
626
- }
627
- }
628
- );
629
-
630
- // src/plugins/listApps/schemas.ts
631
- var ListAppsSchema = withOutputSchema(
632
- z.object({
633
- appKeys: z.array(z.string()).optional().describe(
634
- "Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"
635
- ),
636
- search: z.string().optional().describe("Search for apps by name"),
637
- pageSize: z.number().min(1).optional().describe("Number of apps per page"),
638
- maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
639
- }).describe("List all available apps with optional filtering"),
640
- AppItemSchema
641
- );
642
-
643
- // src/utils/domain-utils.ts
644
- function splitVersionedKey(versionedKey) {
645
- const parts = versionedKey.split("@");
646
- if (parts.length >= 2) {
647
- const baseKey = parts[0];
648
- const version = parts.slice(1).join("@");
649
- return [baseKey, version];
650
- }
651
- return [versionedKey, void 0];
652
- }
653
- function normalizeImplementationMetaToAppItem(implementationMeta) {
654
- const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
655
- return {
656
- title: implementationMeta.name,
657
- key: selectedApi,
658
- current_implementation_id: implementationMeta.id,
659
- // Keep the full versioned ID
660
- version: appVersion,
661
- // Extract version separately
662
- slug: implementationMeta.slug
663
- };
664
- }
665
- function normalizeAuthenticationItem(auth, options = {}) {
666
- let appKey = options.app_key;
667
- let version = options.version;
668
- if (auth.selected_api) {
669
- const [extractedAppKey, extractedVersion] = splitVersionedKey(
670
- auth.selected_api
671
- );
672
- if (!appKey) {
673
- appKey = extractedAppKey;
674
- }
675
- if (!version) {
676
- version = extractedVersion;
677
- }
678
- }
679
- const {
680
- selected_api: selectedApi,
681
- customuser_id: userId,
682
- ...restOfAuth
683
- } = auth;
684
- return {
685
- ...restOfAuth,
686
- // Pass through all other API response fields except selected_api
687
- implementation_id: selectedApi,
688
- // Rename selected_api to implementation_id
689
- title: auth.title || auth.label || void 0,
690
- // Coerce title from label if missing
691
- is_expired: auth.is_stale,
692
- // Map is_stale to is_expired
693
- expired_at: auth.marked_stale_at,
694
- // Map marked_stale_at to expired_at
695
- app_key: appKey,
696
- // App key from implementations endpoint or parsed from selected_api
697
- version,
698
- // Version from selected_api or provided
699
- user_id: userId
700
- // Map customuser_id to user_id
701
- };
702
- }
703
- function normalizeActionItem(action) {
704
- const { name, type, selected_api: appKey, ...restOfAction } = action;
705
- return {
706
- ...restOfAction,
707
- app_key: appKey || "",
708
- action_type: type,
709
- title: name,
710
- // Map name to title
711
- type: "action"
712
- };
713
- }
714
- function isSlug(slug) {
715
- return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
716
- }
717
- function isSnakeCasedSlug(slug) {
718
- if (slug.match(/^_[0-9]/)) {
719
- slug = slug.slice(1);
720
- }
721
- return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
722
- }
723
- function dashifySnakeCasedSlug(slug) {
724
- if (!isSnakeCasedSlug(slug)) {
725
- return slug;
726
- }
727
- if (slug.startsWith("_")) {
728
- slug = slug.slice(1);
729
- }
730
- return slug.replace(/_/g, "-");
731
- }
732
- function isUuid(appKey) {
733
- return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
734
- appKey
735
- );
736
- }
737
- function toAppLocator(appKey) {
738
- const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
739
- if (isUuid(appKeyWithoutVersion)) {
740
- throw new Error(
741
- `UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`
742
- );
743
- }
744
- const slug = isSlug(appKeyWithoutVersion) ? appKeyWithoutVersion : isSnakeCasedSlug(appKeyWithoutVersion) ? dashifySnakeCasedSlug(appKeyWithoutVersion) : void 0;
745
- return {
746
- lookupAppKey: appKeyWithoutVersion,
747
- slug,
748
- implementationName: slug ? void 0 : appKeyWithoutVersion,
749
- version
750
- };
751
- }
752
- function isResolvedAppLocator(appLocator) {
753
- return !!appLocator.implementationName;
754
- }
755
- function toImplementationId(appLocator) {
756
- return `${appLocator.implementationName}@${appLocator.version || "latest"}`;
757
- }
758
-
759
- // src/plugins/listApps/index.ts
760
- var listAppsPlugin = ({ context }) => {
761
- const listApps = createPaginatedFunction(async function listAppsPage(options) {
762
- const api = context.api;
763
- const opts = options;
764
- const appLocators = await context.resolveAppKeys({
765
- appKeys: [...opts.appKeys ?? []]
766
- });
767
- const implementationNameToLocator = {};
768
- for (const locator of appLocators) {
769
- implementationNameToLocator[locator.implementationName] = [
770
- ...implementationNameToLocator[locator.implementationName] ?? [],
771
- locator
772
- ];
773
- }
774
- const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
775
- if (duplicatedLookupAppKeys.length > 0) {
776
- throw new Error(
777
- `Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
778
- );
779
- }
780
- if (opts.search) {
781
- const searchParams2 = {};
782
- searchParams2.term = opts.search;
783
- const searchEnvelope = await api.get(
784
- "/api/v4/implementations-meta/search/",
785
- {
786
- searchParams: searchParams2
787
- }
788
- );
789
- const implementations = searchEnvelope.results.map(
790
- normalizeImplementationMetaToAppItem
791
- );
792
- const implementationNameSet = new Set(
793
- appLocators.map((locator) => locator.implementationName)
794
- );
795
- for (const implementation of implementations) {
796
- const [implementationName] = splitVersionedKey(implementation.key);
797
- if (!implementationNameSet.has(implementationName)) {
798
- implementationNameSet.add(implementationName);
799
- appLocators.push({
800
- ...toAppLocator(implementation.key),
801
- implementationName
802
- });
803
- }
804
- }
805
- }
806
- const searchParams = {};
807
- if (opts.pageSize) {
808
- searchParams.limit = opts.pageSize.toString();
809
- }
810
- if (appLocators.length === 0) {
811
- searchParams.latest_only = "true";
812
- }
813
- if (opts.cursor) {
814
- searchParams.offset = opts.cursor;
815
- }
816
- searchParams.selected_apis = appLocators.map((locator) => toImplementationId(locator)).join(",");
817
- const implementationsEnvelope = await api.get(
818
- "/api/v4/implementations-meta/lookup/",
819
- {
820
- searchParams
821
- }
822
- );
823
- return {
824
- data: implementationsEnvelope.results.map(
825
- normalizeImplementationMetaToAppItem
826
- ),
827
- nextCursor: extractCursor(implementationsEnvelope)
828
- };
829
- }, ListAppsSchema);
830
- return {
831
- listApps,
832
- context: {
833
- meta: {
834
- listApps: {
835
- categories: ["app"],
836
- inputSchema: ListAppsSchema
837
- }
838
- }
839
- }
840
- };
841
- };
608
+ var ListAppsSchema = z.object({
609
+ appKeys: z.array(z.string()).optional().describe(
610
+ "Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"
611
+ ),
612
+ search: z.string().optional().describe("Search for apps by name"),
613
+ pageSize: z.number().min(1).optional().describe("Number of apps per page"),
614
+ maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
615
+ }).describe("List all available apps with optional filtering");
842
616
  var NeedChoicesSchema = z.object({
843
617
  key: z.string().optional(),
844
618
  label: z.string().optional(),
@@ -938,7 +712,7 @@ z.object({
938
712
  choices: z.array(ChoiceSchema).optional()
939
713
  });
940
714
  z.object({
941
- data: z.array(z.any())
715
+ data: z.array(z.unknown())
942
716
  });
943
717
  var ActionFieldChoiceSchema = z.object({
944
718
  value: z.union([z.string(), z.number()]),
@@ -1028,9 +802,9 @@ var UserProfileSchema = z.object({
1028
802
  enable_totp_2fa: z.boolean(),
1029
803
  viewed_help: z.record(z.boolean()),
1030
804
  show_editor_migration_mesaging: z.boolean(),
1031
- switches: z.record(z.any()),
1032
- organizations: z.array(z.any().nullable()),
1033
- primary_organization: z.any().nullable(),
805
+ switches: z.record(z.unknown()),
806
+ organizations: z.array(z.record(z.unknown()).nullable()),
807
+ primary_organization: z.record(z.unknown()).nullable(),
1034
808
  has_active_zaps: z.boolean(),
1035
809
  has_google_sso: z.boolean(),
1036
810
  auth_realm: z.string(),
@@ -1046,8 +820,8 @@ z.object({
1046
820
  api_docs_url: z.string().nullable().optional(),
1047
821
  app_profile_url: z.string(),
1048
822
  banner: z.string().optional(),
1049
- categories: z.array(z.any()).optional(),
1050
- // TODO: Define proper service_category type
823
+ categories: z.array(z.string()).optional(),
824
+ // Service category names
1051
825
  canonical_id: z.string().optional(),
1052
826
  current_implementation_id: z.string(),
1053
827
  days_since_last_update: z.string().optional(),
@@ -1098,7 +872,7 @@ z.object({
1098
872
  action: z.string(),
1099
873
  type_of: z.string(),
1100
874
  authentication_id: z.number().optional(),
1101
- params: z.record(z.any()).optional()
875
+ params: z.record(z.unknown()).optional()
1102
876
  });
1103
877
  z.object({
1104
878
  success: z.boolean(),
@@ -1134,18 +908,11 @@ z.object({
1134
908
  });
1135
909
  var ImplementationMetaSchema = z.object({
1136
910
  id: z.string(),
1137
- // e.g. "ZapierFormatterCLIAPI@1.0.7"
911
+ // e.g. "100HiresCLIAPI@1.2.1"
1138
912
  name: z.string(),
1139
913
  slug: z.string(),
1140
- images: z.object({
1141
- url_16x16: z.string().optional(),
1142
- url_32x32: z.string().optional(),
1143
- url_64x64: z.string().optional(),
1144
- url_128x128: z.string().optional()
1145
- }).optional(),
1146
- // Include other fields for completeness but we'll only use what we need
1147
- ageInDays: z.union([z.string(), z.number()]).optional(),
1148
- authType: z.string().nullable().optional(),
914
+ age_in_days: z.number().optional(),
915
+ auth_type: z.string().optional(),
1149
916
  banner: z.string().optional(),
1150
917
  categories: z.array(
1151
918
  z.object({
@@ -1154,18 +921,45 @@ var ImplementationMetaSchema = z.object({
1154
921
  slug: z.string()
1155
922
  })
1156
923
  ).optional(),
1157
- isBeta: z.boolean().optional(),
1158
- isBuiltIn: z.boolean().optional(),
1159
- isDeprecated: z.boolean().optional(),
1160
- isFeatured: z.boolean().optional(),
1161
- isHidden: z.boolean().optional(),
1162
- isInvite: z.boolean().optional(),
1163
- isPremium: z.boolean().optional(),
1164
- isPublic: z.boolean().optional(),
1165
- isUpcoming: z.boolean().optional(),
924
+ images: z.object({
925
+ url_16x16: z.string().optional(),
926
+ url_32x32: z.string().optional(),
927
+ url_64x64: z.string().optional(),
928
+ url_128x128: z.string().optional()
929
+ }).optional(),
1166
930
  popularity: z.number().optional(),
1167
- apiDocsUrl: z.string().optional(),
1168
- classification: z.string().optional()
931
+ has_filters: z.boolean().optional(),
932
+ has_reads: z.boolean().optional(),
933
+ has_searches: z.boolean().optional(),
934
+ has_searches_or_writes: z.boolean().optional(),
935
+ has_upfront_fields: z.boolean().optional(),
936
+ has_writes: z.boolean().optional(),
937
+ is_beta: z.boolean().optional(),
938
+ is_built_in: z.boolean().optional(),
939
+ is_deprecated: z.boolean().optional(),
940
+ is_featured: z.boolean().optional(),
941
+ is_hidden: z.boolean().optional(),
942
+ is_invite: z.boolean().optional(),
943
+ is_premium: z.boolean().optional(),
944
+ is_public: z.boolean().optional(),
945
+ is_upcoming: z.boolean().optional(),
946
+ version: z.string().optional(),
947
+ visibility: z.string().optional(),
948
+ actions: z.object({
949
+ read: z.number().optional(),
950
+ read_bulk: z.number().optional(),
951
+ write: z.number().optional(),
952
+ search: z.number().optional(),
953
+ search_or_write: z.number().optional(),
954
+ search_and_write: z.number().optional(),
955
+ filter: z.number().optional()
956
+ }).optional(),
957
+ description: z.string().optional(),
958
+ primary_color: z.string().optional(),
959
+ secondary_color: z.string().optional(),
960
+ classification: z.string().optional(),
961
+ api_docs_url: z.string().optional(),
962
+ image: z.string().optional()
1169
963
  });
1170
964
  z.object({
1171
965
  count: z.number(),
@@ -1187,7 +981,7 @@ z.object({
1187
981
  authentication_id: z.number().optional().describe(
1188
982
  "If the app needs auth, provide an `authentication_id` that has the `selected_api` of the app you want to run. Can be any auth visible to the user (including shared)."
1189
983
  ),
1190
- params: z.record(z.any()).optional().describe(
984
+ params: z.record(z.unknown()).optional().describe(
1191
985
  "Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action."
1192
986
  ),
1193
987
  page: z.number().optional().default(0),
@@ -1210,25 +1004,261 @@ z.object({
1210
1004
  links: NeedChoicesResponseLinksSchema.optional()
1211
1005
  });
1212
1006
 
1213
- // src/schemas/Action.ts
1214
- var ActionItemSchema = withFormatter(
1215
- ActionSchema.omit({ type: true, name: true }).extend({
1216
- app_key: z.string(),
1217
- // Mapped from selected_api
1218
- action_type: ActionSchema.shape.type,
1219
- // Mapped from original 'type' field
1007
+ // src/schemas/App.ts
1008
+ var AppItemSchema = withFormatter(
1009
+ ImplementationMetaSchema.omit({ name: true, id: true }).extend({
1220
1010
  title: z.string(),
1221
- // Mapped from original 'name' field
1222
- type: z.literal("action")
1223
- // Fixed type identifier
1011
+ // Mapped from name
1012
+ key: z.string(),
1013
+ // Extracted from id (base part without version)
1014
+ implementation_id: z.string()
1015
+ // Mapped from id (full versioned ID)
1224
1016
  }),
1225
1017
  {
1226
1018
  format: (item) => {
1227
- const details = [];
1228
- details.push({
1229
- text: `Type: ${item.action_type}`,
1230
- style: "accent"
1231
- });
1019
+ return {
1020
+ title: item.title,
1021
+ key: item.key,
1022
+ description: item.description,
1023
+ details: []
1024
+ };
1025
+ }
1026
+ }
1027
+ );
1028
+
1029
+ // src/utils/domain-utils.ts
1030
+ function splitVersionedKey(versionedKey) {
1031
+ const parts = versionedKey.split("@");
1032
+ if (parts.length >= 2) {
1033
+ const baseKey = parts[0];
1034
+ const version = parts.slice(1).join("@");
1035
+ return [baseKey, version];
1036
+ }
1037
+ return [versionedKey, void 0];
1038
+ }
1039
+ function normalizeImplementationMetaToAppItem(implementationMeta) {
1040
+ const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
1041
+ const { id, name, ...restOfImplementationMeta } = implementationMeta;
1042
+ return {
1043
+ // Pass through all ImplementationMeta fields except id and name
1044
+ ...restOfImplementationMeta,
1045
+ // Transform key fields
1046
+ title: name,
1047
+ key: selectedApi,
1048
+ implementation_id: id,
1049
+ // Keep the full versioned ID
1050
+ version: appVersion
1051
+ // Extract version separately
1052
+ };
1053
+ }
1054
+ function normalizeAuthenticationItem(auth, options = {}) {
1055
+ let appKey = options.app_key;
1056
+ let version = options.version;
1057
+ if (auth.selected_api) {
1058
+ const [extractedAppKey, extractedVersion] = splitVersionedKey(
1059
+ auth.selected_api
1060
+ );
1061
+ if (!appKey) {
1062
+ appKey = extractedAppKey;
1063
+ }
1064
+ if (!version) {
1065
+ version = extractedVersion;
1066
+ }
1067
+ }
1068
+ const {
1069
+ selected_api: selectedApi,
1070
+ customuser_id: userId,
1071
+ ...restOfAuth
1072
+ } = auth;
1073
+ return {
1074
+ ...restOfAuth,
1075
+ // Pass through all other API response fields except selected_api
1076
+ implementation_id: selectedApi,
1077
+ // Rename selected_api to implementation_id
1078
+ title: auth.title || auth.label || void 0,
1079
+ // Coerce title from label if missing
1080
+ is_expired: auth.is_stale,
1081
+ // Map is_stale to is_expired
1082
+ expired_at: auth.marked_stale_at,
1083
+ // Map marked_stale_at to expired_at
1084
+ app_key: appKey,
1085
+ // App key from implementations endpoint or parsed from selected_api
1086
+ version,
1087
+ // Version from selected_api or provided
1088
+ user_id: userId
1089
+ // Map customuser_id to user_id
1090
+ };
1091
+ }
1092
+ function normalizeActionItem(action) {
1093
+ const { name, type, selected_api: appKey, ...restOfAction } = action;
1094
+ return {
1095
+ ...restOfAction,
1096
+ app_key: appKey || "",
1097
+ action_type: type,
1098
+ title: name,
1099
+ // Map name to title
1100
+ type: "action"
1101
+ };
1102
+ }
1103
+ function isSlug(slug) {
1104
+ return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
1105
+ }
1106
+ function isSnakeCasedSlug(slug) {
1107
+ if (slug.match(/^_[0-9]/)) {
1108
+ slug = slug.slice(1);
1109
+ }
1110
+ return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
1111
+ }
1112
+ function dashifySnakeCasedSlug(slug) {
1113
+ if (!isSnakeCasedSlug(slug)) {
1114
+ return slug;
1115
+ }
1116
+ if (slug.startsWith("_")) {
1117
+ slug = slug.slice(1);
1118
+ }
1119
+ return slug.replace(/_/g, "-");
1120
+ }
1121
+ function isUuid(appKey) {
1122
+ return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
1123
+ appKey
1124
+ );
1125
+ }
1126
+ function toAppLocator(appKey) {
1127
+ const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
1128
+ if (isUuid(appKeyWithoutVersion)) {
1129
+ throw new Error(
1130
+ `UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`
1131
+ );
1132
+ }
1133
+ const slug = isSlug(appKeyWithoutVersion) ? appKeyWithoutVersion : isSnakeCasedSlug(appKeyWithoutVersion) ? dashifySnakeCasedSlug(appKeyWithoutVersion) : void 0;
1134
+ return {
1135
+ lookupAppKey: appKeyWithoutVersion,
1136
+ slug,
1137
+ implementationName: slug ? void 0 : appKeyWithoutVersion,
1138
+ version
1139
+ };
1140
+ }
1141
+ function isResolvedAppLocator(appLocator) {
1142
+ return !!appLocator.implementationName;
1143
+ }
1144
+ function toImplementationId(appLocator) {
1145
+ return `${appLocator.implementationName}@${appLocator.version || "latest"}`;
1146
+ }
1147
+
1148
+ // src/plugins/listApps/index.ts
1149
+ var listAppsPlugin = ({ context }) => {
1150
+ const listApps = createPaginatedFunction(async function listAppsPage(options) {
1151
+ const api = context.api;
1152
+ const opts = options;
1153
+ const appLocators = await context.resolveAppKeys({
1154
+ appKeys: [...opts.appKeys ?? []]
1155
+ });
1156
+ const implementationNameToLocator = {};
1157
+ for (const locator of appLocators) {
1158
+ implementationNameToLocator[locator.implementationName] = [
1159
+ ...implementationNameToLocator[locator.implementationName] ?? [],
1160
+ locator
1161
+ ];
1162
+ }
1163
+ const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
1164
+ if (duplicatedLookupAppKeys.length > 0) {
1165
+ throw new Error(
1166
+ `Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
1167
+ );
1168
+ }
1169
+ if (opts.search) {
1170
+ const searchParams2 = {};
1171
+ searchParams2.term = opts.search;
1172
+ const searchEnvelope = await api.get(
1173
+ "/api/v4/implementations-meta/search/",
1174
+ {
1175
+ searchParams: searchParams2
1176
+ }
1177
+ );
1178
+ const implementations = searchEnvelope.results.map(
1179
+ normalizeImplementationMetaToAppItem
1180
+ );
1181
+ const implementationNameSet = new Set(
1182
+ appLocators.map((locator) => locator.implementationName)
1183
+ );
1184
+ for (const implementation of implementations) {
1185
+ const [implementationName] = splitVersionedKey(implementation.key);
1186
+ if (!implementationNameSet.has(implementationName)) {
1187
+ implementationNameSet.add(implementationName);
1188
+ appLocators.push({
1189
+ ...toAppLocator(implementation.key),
1190
+ implementationName
1191
+ });
1192
+ }
1193
+ }
1194
+ }
1195
+ const searchParams = {};
1196
+ if (opts.pageSize) {
1197
+ searchParams.limit = opts.pageSize.toString();
1198
+ }
1199
+ if (appLocators.length === 0) {
1200
+ searchParams.latest_only = "true";
1201
+ }
1202
+ if (opts.cursor) {
1203
+ searchParams.offset = opts.cursor;
1204
+ }
1205
+ searchParams.selected_apis = appLocators.map((locator) => toImplementationId(locator)).join(",");
1206
+ const implementationsEnvelope = await api.get(
1207
+ "/api/v4/implementations-meta/lookup/",
1208
+ {
1209
+ searchParams
1210
+ }
1211
+ );
1212
+ return {
1213
+ data: implementationsEnvelope.results.map(
1214
+ normalizeImplementationMetaToAppItem
1215
+ ),
1216
+ nextCursor: extractCursor(implementationsEnvelope)
1217
+ };
1218
+ }, ListAppsSchema);
1219
+ return {
1220
+ listApps,
1221
+ context: {
1222
+ meta: {
1223
+ listApps: {
1224
+ categories: ["app"],
1225
+ type: "list",
1226
+ itemType: "App",
1227
+ inputSchema: ListAppsSchema,
1228
+ outputSchema: AppItemSchema
1229
+ }
1230
+ }
1231
+ }
1232
+ };
1233
+ };
1234
+ var ListActionsSchema = z.object({
1235
+ appKey: AppKeyPropertySchema.describe(
1236
+ "App key of actions to list (e.g., 'SlackCLIAPI')"
1237
+ ),
1238
+ actionType: ActionTypePropertySchema.optional().describe(
1239
+ "Filter actions by type"
1240
+ ),
1241
+ pageSize: z.number().min(1).optional().describe("Number of actions per page"),
1242
+ maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
1243
+ }).describe("List all actions for a specific app");
1244
+ var ActionItemSchema = withFormatter(
1245
+ ActionSchema.omit({ type: true, name: true }).extend({
1246
+ app_key: z.string(),
1247
+ // Mapped from selected_api
1248
+ action_type: ActionSchema.shape.type,
1249
+ // Mapped from original 'type' field
1250
+ title: z.string(),
1251
+ // Mapped from original 'name' field
1252
+ type: z.literal("action")
1253
+ // Fixed type identifier
1254
+ }),
1255
+ {
1256
+ format: (item) => {
1257
+ const details = [];
1258
+ details.push({
1259
+ text: `Type: ${item.action_type}`,
1260
+ style: "accent"
1261
+ });
1232
1262
  if (item.app_key) {
1233
1263
  details.push({
1234
1264
  text: `App: ${item.app_key}`,
@@ -1236,31 +1266,208 @@ var ActionItemSchema = withFormatter(
1236
1266
  });
1237
1267
  }
1238
1268
  if (item.description) {
1239
- details.push({ text: item.description, style: "dim" });
1269
+ details.push({
1270
+ text: item.description,
1271
+ style: "dim"
1272
+ });
1240
1273
  }
1241
1274
  return {
1242
- title: item.title || item.name || item.key,
1243
- subtitle: `(${item.key})`,
1275
+ title: item.title || item.key,
1276
+ id: item.id,
1277
+ key: item.key,
1278
+ description: item.description,
1244
1279
  details
1245
1280
  };
1246
1281
  }
1247
1282
  }
1248
1283
  );
1249
1284
 
1250
- // src/plugins/listActions/schemas.ts
1251
- var ListActionsSchema = withOutputSchema(
1252
- z.object({
1253
- appKey: AppKeyPropertySchema.describe(
1254
- "App key of actions to list (e.g., 'SlackCLIAPI')"
1255
- ),
1256
- actionType: ActionTypePropertySchema.optional().describe(
1257
- "Filter actions by type"
1258
- ),
1259
- pageSize: z.number().min(1).optional().describe("Number of actions per page"),
1260
- maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
1261
- }).describe("List all actions for a specific app"),
1262
- ActionItemSchema
1263
- );
1285
+ // src/resolvers/appKey.ts
1286
+ var appKeyResolver = {
1287
+ type: "static",
1288
+ inputType: "text",
1289
+ placeholder: "Enter app key (e.g., 'SlackCLIAPI' or slug like 'github')"
1290
+ };
1291
+
1292
+ // src/resolvers/actionType.ts
1293
+ var actionTypeResolver = {
1294
+ type: "dynamic",
1295
+ depends: ["appKey"],
1296
+ fetch: async (sdk, resolvedParams) => {
1297
+ const actionsResponse = await sdk.listActions({
1298
+ appKey: resolvedParams.appKey
1299
+ });
1300
+ const types = [
1301
+ ...new Set(actionsResponse.data.map((action) => action.action_type))
1302
+ ];
1303
+ return types.map((type) => ({ key: type, name: type }));
1304
+ },
1305
+ prompt: (types) => ({
1306
+ type: "list",
1307
+ name: "actionType",
1308
+ message: "Select action type:",
1309
+ choices: types.map((type) => ({
1310
+ name: type.name,
1311
+ value: type.key
1312
+ }))
1313
+ })
1314
+ };
1315
+
1316
+ // src/resolvers/actionKey.ts
1317
+ var actionKeyResolver = {
1318
+ type: "dynamic",
1319
+ depends: ["appKey", "actionType"],
1320
+ fetch: async (sdk, resolvedParams) => {
1321
+ const actionsResponse = await sdk.listActions({
1322
+ appKey: resolvedParams.appKey
1323
+ });
1324
+ return actionsResponse.data.filter(
1325
+ (action) => action.action_type === resolvedParams.actionType
1326
+ );
1327
+ },
1328
+ prompt: (actions) => ({
1329
+ type: "list",
1330
+ name: "actionKey",
1331
+ message: "Select action:",
1332
+ choices: actions.map((action) => ({
1333
+ name: `${action.title || action.name || action.key} - ${action.description || "No description"}`,
1334
+ value: action.key
1335
+ }))
1336
+ })
1337
+ };
1338
+
1339
+ // src/resolvers/authenticationId.ts
1340
+ var authenticationIdResolver = {
1341
+ type: "dynamic",
1342
+ depends: ["appKey"],
1343
+ fetch: async (sdk, resolvedParams) => {
1344
+ const listOptions = {
1345
+ maxItems: 1e3
1346
+ };
1347
+ if (resolvedParams.appKey) {
1348
+ listOptions.appKey = resolvedParams.appKey;
1349
+ }
1350
+ const myAuths = await sdk.listAuthentications({
1351
+ ...listOptions,
1352
+ owner: "me"
1353
+ });
1354
+ const allAuths = await sdk.listAuthentications(listOptions);
1355
+ const otherAuths = allAuths.data.filter(
1356
+ (auth) => !myAuths.data.some((myAuth) => myAuth.id === auth.id)
1357
+ );
1358
+ return [...myAuths.data, ...otherAuths];
1359
+ },
1360
+ prompt: (auths, params) => ({
1361
+ type: "list",
1362
+ name: "authenticationId",
1363
+ message: params.appKey ? `Select authentication for ${params.appKey}:` : "Select authentication:",
1364
+ choices: [
1365
+ ...auths.map((auth) => ({
1366
+ name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
1367
+ value: auth.id
1368
+ })),
1369
+ {
1370
+ name: "\u2197 Skip authentication (may fail)",
1371
+ value: null
1372
+ }
1373
+ ]
1374
+ })
1375
+ };
1376
+ var authenticationIdGenericResolver = {
1377
+ ...authenticationIdResolver,
1378
+ depends: []
1379
+ };
1380
+
1381
+ // src/resolvers/inputs.ts
1382
+ function makeFieldsOptional(fields) {
1383
+ return fields.map((field) => {
1384
+ if (field.type === "input_field") {
1385
+ return {
1386
+ ...field,
1387
+ is_required: false
1388
+ };
1389
+ } else if (field.type === "fieldset") {
1390
+ return {
1391
+ ...field,
1392
+ fields: makeFieldsOptional(field.fields)
1393
+ };
1394
+ } else {
1395
+ return field;
1396
+ }
1397
+ });
1398
+ }
1399
+ var inputsResolver = {
1400
+ type: "fields",
1401
+ depends: ["appKey", "actionKey", "actionType", "authenticationId"],
1402
+ fetch: async (sdk, resolvedParams) => {
1403
+ const fieldsResponse = await sdk.listInputFields({
1404
+ appKey: resolvedParams.appKey,
1405
+ actionKey: resolvedParams.actionKey,
1406
+ actionType: resolvedParams.actionType,
1407
+ authenticationId: resolvedParams.authenticationId,
1408
+ inputs: resolvedParams.inputs
1409
+ // Pass along currently resolved inputs
1410
+ });
1411
+ return fieldsResponse.data;
1412
+ }
1413
+ };
1414
+ var inputsAllOptionalResolver = {
1415
+ type: "fields",
1416
+ depends: ["appKey", "actionKey", "actionType", "authenticationId"],
1417
+ fetch: async (sdk, resolvedParams) => {
1418
+ const fieldsResponse = await sdk.listInputFields({
1419
+ appKey: resolvedParams.appKey,
1420
+ actionKey: resolvedParams.actionKey,
1421
+ actionType: resolvedParams.actionType,
1422
+ authenticationId: resolvedParams.authenticationId,
1423
+ inputs: resolvedParams.inputs
1424
+ // Pass along currently resolved inputs
1425
+ });
1426
+ return makeFieldsOptional(fieldsResponse.data);
1427
+ }
1428
+ };
1429
+
1430
+ // src/resolvers/inputFieldKey.ts
1431
+ function flattenRootFieldset(rootFieldset) {
1432
+ const result = [];
1433
+ function processItem(item) {
1434
+ if (item.type === "input_field") {
1435
+ result.push(item);
1436
+ } else if (item.type === "fieldset") {
1437
+ for (const field of item.fields) {
1438
+ processItem(field);
1439
+ }
1440
+ }
1441
+ }
1442
+ for (const item of rootFieldset) {
1443
+ processItem(item);
1444
+ }
1445
+ return result;
1446
+ }
1447
+ var inputFieldKeyResolver = {
1448
+ type: "dynamic",
1449
+ depends: ["appKey", "actionKey", "actionType", "authenticationId"],
1450
+ fetch: async (sdk, resolvedParams) => {
1451
+ const fieldsResponse = await sdk.listInputFields({
1452
+ appKey: resolvedParams.appKey,
1453
+ actionKey: resolvedParams.actionKey,
1454
+ actionType: resolvedParams.actionType,
1455
+ authenticationId: resolvedParams.authenticationId,
1456
+ inputs: resolvedParams.inputs
1457
+ // Pass along currently resolved inputs
1458
+ });
1459
+ return flattenRootFieldset(fieldsResponse.data);
1460
+ },
1461
+ prompt: (fields) => ({
1462
+ type: "list",
1463
+ name: "inputFieldKey",
1464
+ message: "Select input field:",
1465
+ choices: fields.map((field) => ({
1466
+ name: `${field.title || field.key} - ${field.value_type || "No type"} ${field.is_required ? "(required)" : "(optional)"}`,
1467
+ value: field.key
1468
+ }))
1469
+ })
1470
+ };
1264
1471
 
1265
1472
  // src/plugins/listActions/index.ts
1266
1473
  var listActionsPlugin = ({ context }) => {
@@ -1327,23 +1534,152 @@ var listActionsPlugin = ({ context }) => {
1327
1534
  meta: {
1328
1535
  listActions: {
1329
1536
  categories: ["action"],
1330
- inputSchema: ListActionsSchema
1537
+ type: "list",
1538
+ itemType: "Action",
1539
+ inputSchema: ListActionsSchema,
1540
+ outputSchema: ActionItemSchema,
1541
+ resolvers: {
1542
+ appKey: appKeyResolver,
1543
+ actionType: actionTypeResolver
1544
+ }
1331
1545
  }
1332
1546
  }
1333
1547
  }
1334
- };
1335
- };
1336
- var ListInputFieldsSchema = z.object({
1337
- appKey: AppKeyPropertySchema,
1338
- actionType: ActionTypePropertySchema,
1339
- actionKey: ActionKeyPropertySchema,
1340
- authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
1341
- inputs: InputsPropertySchema.optional().describe(
1342
- "Current input values that may affect available fields"
1343
- ),
1344
- pageSize: z.number().min(1).optional().describe("Number of input fields per page"),
1345
- maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
1346
- }).describe("Get the input fields required for a specific action");
1548
+ };
1549
+ };
1550
+ var ListInputFieldsSchema = z.object({
1551
+ appKey: AppKeyPropertySchema,
1552
+ actionType: ActionTypePropertySchema,
1553
+ actionKey: ActionKeyPropertySchema,
1554
+ authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
1555
+ inputs: InputsPropertySchema.optional().describe(
1556
+ "Current input values that may affect available fields"
1557
+ ),
1558
+ pageSize: z.number().min(1).optional().describe("Number of input fields per page"),
1559
+ maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
1560
+ }).describe("Get the input fields required for a specific action");
1561
+ var BaseFieldItemSchema = z.object({
1562
+ type: z.string(),
1563
+ // "input_field", "info_field", or "fieldset"
1564
+ key: z.string()
1565
+ // From need.key
1566
+ });
1567
+ var InputFieldItemSchema = withFormatter(
1568
+ BaseFieldItemSchema.extend({
1569
+ type: z.literal("input_field"),
1570
+ default_value: z.string(),
1571
+ // Mapped from 'default' with fallback to ""
1572
+ depends_on: z.array(z.string()),
1573
+ // Mapped from 'depends_on' with fallback to []
1574
+ description: z.string(),
1575
+ // Mapped from 'help_text' with fallback to ""
1576
+ invalidates_input_fields: z.boolean(),
1577
+ // Mapped from 'alters_custom_fields' with fallback to false
1578
+ is_required: z.boolean(),
1579
+ // Mapped from 'required' with fallback to false
1580
+ placeholder: z.string(),
1581
+ // Mapped from 'placeholder' with fallback to ""
1582
+ title: z.string(),
1583
+ // Mapped from 'label' with fallback to ""
1584
+ value_type: z.string(),
1585
+ // Computed from InputFieldType enum
1586
+ format: z.string().optional(),
1587
+ // Computed from InputFieldFormat enum (optional)
1588
+ items: z.object({ type: z.string() }).optional()
1589
+ // Computed from ItemsType enum (optional, only for arrays)
1590
+ }),
1591
+ {
1592
+ format: (item) => {
1593
+ const details = [];
1594
+ const typeInfo = [
1595
+ item.value_type && `Type: ${item.value_type}`,
1596
+ `Required: ${item.is_required ? "Yes" : "No"}`
1597
+ ].filter(Boolean).join(" | ");
1598
+ if (typeInfo) {
1599
+ details.push({ text: typeInfo, style: "dim" });
1600
+ }
1601
+ if (item.description) {
1602
+ details.push({
1603
+ text: item.description,
1604
+ style: "normal"
1605
+ });
1606
+ }
1607
+ if (item.default_value) {
1608
+ details.push({
1609
+ text: `Default: ${item.default_value}`,
1610
+ style: "accent"
1611
+ });
1612
+ }
1613
+ if (item.placeholder) {
1614
+ details.push({
1615
+ text: `Placeholder: ${item.placeholder}`,
1616
+ style: "dim"
1617
+ });
1618
+ }
1619
+ if (item.depends_on && item.depends_on.length > 0) {
1620
+ details.push({
1621
+ text: `Depends on: ${item.depends_on.join(", ")}`,
1622
+ style: "warning"
1623
+ });
1624
+ }
1625
+ if (item.format) {
1626
+ details.push({ text: `Format: ${item.format}`, style: "dim" });
1627
+ }
1628
+ if (item.items) {
1629
+ details.push({
1630
+ text: `Items type: ${item.items.type}`,
1631
+ style: "dim"
1632
+ });
1633
+ }
1634
+ return {
1635
+ title: item.title || item.key,
1636
+ key: item.key,
1637
+ description: item.description,
1638
+ details
1639
+ };
1640
+ }
1641
+ }
1642
+ );
1643
+ var InfoFieldItemSchema = withFormatter(
1644
+ BaseFieldItemSchema.extend({
1645
+ type: z.literal("info_field"),
1646
+ description: z.string(),
1647
+ // From need.help_text
1648
+ title: z.string().optional()
1649
+ // Optional title
1650
+ }),
1651
+ {
1652
+ format: (item) => ({
1653
+ title: item.title || "Info",
1654
+ key: item.key,
1655
+ description: item.description,
1656
+ details: [{ text: item.description, style: "normal" }]
1657
+ })
1658
+ }
1659
+ );
1660
+ var FieldsetItemSchema = BaseFieldItemSchema.extend({
1661
+ type: z.literal("fieldset"),
1662
+ title: z.string(),
1663
+ fields: z.lazy(
1664
+ () => z.array(
1665
+ z.union([
1666
+ InputFieldItemSchema,
1667
+ InfoFieldItemSchema,
1668
+ FieldsetItemSchema
1669
+ ])
1670
+ )
1671
+ )
1672
+ });
1673
+ var RootFieldItemSchema = z.union([
1674
+ InputFieldItemSchema,
1675
+ InfoFieldItemSchema,
1676
+ FieldsetItemSchema
1677
+ ]);
1678
+
1679
+ // src/utils/string-utils.ts
1680
+ function toTitleCase(input) {
1681
+ return input.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-]+/g, " ").replace(/\s+/g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
1682
+ }
1347
1683
 
1348
1684
  // src/plugins/listInputFields/index.ts
1349
1685
  function getInputFieldTypeFromNeed(need) {
@@ -1388,9 +1724,8 @@ function getItemsTypeFromNeed(need) {
1388
1724
  function transformNeedToInputFieldItem(need) {
1389
1725
  const itemsType = getItemsTypeFromNeed(need);
1390
1726
  return {
1391
- ...need,
1392
- // Pass through all original Need fields
1393
- id: need.key,
1727
+ type: "input_field",
1728
+ key: need.key,
1394
1729
  default_value: need.default || "",
1395
1730
  depends_on: need.depends_on || [],
1396
1731
  description: need.help_text || "",
@@ -1403,6 +1738,48 @@ function transformNeedToInputFieldItem(need) {
1403
1738
  items: itemsType ? { type: itemsType } : void 0
1404
1739
  };
1405
1740
  }
1741
+ function transformNeedToInfoFieldItem(need) {
1742
+ return {
1743
+ type: "info_field",
1744
+ key: need.key,
1745
+ description: need.help_text || "",
1746
+ title: need.label
1747
+ };
1748
+ }
1749
+ function transformNeedsToFields(needs) {
1750
+ const rootFields = [];
1751
+ const fieldsetMap = /* @__PURE__ */ new Map();
1752
+ for (const need of needs) {
1753
+ if (need.computed) {
1754
+ continue;
1755
+ }
1756
+ if (need.parent_key) {
1757
+ let fieldset = fieldsetMap.get(need.parent_key);
1758
+ if (!fieldset) {
1759
+ fieldset = {
1760
+ type: "fieldset",
1761
+ key: need.parent_key,
1762
+ title: toTitleCase(need.parent_key),
1763
+ fields: []
1764
+ };
1765
+ fieldsetMap.set(need.parent_key, fieldset);
1766
+ rootFields.push(fieldset);
1767
+ }
1768
+ if (need.type === "copy" && need.help_text) {
1769
+ fieldset.fields.push(transformNeedToInfoFieldItem(need));
1770
+ } else {
1771
+ fieldset.fields.push(transformNeedToInputFieldItem(need));
1772
+ }
1773
+ } else {
1774
+ if (need.type === "copy" && need.help_text) {
1775
+ rootFields.push(transformNeedToInfoFieldItem(need));
1776
+ } else {
1777
+ rootFields.push(transformNeedToInputFieldItem(need));
1778
+ }
1779
+ }
1780
+ }
1781
+ return rootFields;
1782
+ }
1406
1783
  var listInputFieldsPlugin = ({ context }) => {
1407
1784
  const listInputFields = createPaginatedFunction(
1408
1785
  async function listInputFieldsPage(options) {
@@ -1433,11 +1810,9 @@ var listInputFieldsPlugin = ({ context }) => {
1433
1810
  `Failed to get action fields: ${needsData.errors?.join(", ") || "Unknown error"}`
1434
1811
  );
1435
1812
  }
1436
- const inputFields = (needsData.needs || []).map(
1437
- transformNeedToInputFieldItem
1438
- );
1813
+ const rootFieldset = transformNeedsToFields(needsData.needs || []);
1439
1814
  return {
1440
- data: inputFields,
1815
+ data: rootFieldset,
1441
1816
  nextCursor: void 0
1442
1817
  // No pagination needed since we return all input fields
1443
1818
  };
@@ -1450,7 +1825,17 @@ var listInputFieldsPlugin = ({ context }) => {
1450
1825
  meta: {
1451
1826
  listInputFields: {
1452
1827
  categories: ["action"],
1453
- inputSchema: ListInputFieldsSchema
1828
+ type: "list",
1829
+ itemType: "RootFieldItem",
1830
+ inputSchema: ListInputFieldsSchema,
1831
+ outputSchema: RootFieldItemSchema,
1832
+ resolvers: {
1833
+ appKey: appKeyResolver,
1834
+ actionType: actionTypeResolver,
1835
+ actionKey: actionKeyResolver,
1836
+ authenticationId: authenticationIdResolver,
1837
+ inputs: inputsAllOptionalResolver
1838
+ }
1454
1839
  }
1455
1840
  }
1456
1841
  }
@@ -1468,6 +1853,49 @@ var ListAuthenticationsSchema = z.object({
1468
1853
  pageSize: z.number().min(1).optional().describe("Number of authentications per page"),
1469
1854
  maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
1470
1855
  }).describe("List available authentications with optional filtering");
1856
+ var AuthenticationItemSchema = withFormatter(
1857
+ AuthenticationSchema.omit({ selected_api: true, customuser_id: true }).extend(
1858
+ {
1859
+ implementation_id: z.string().optional(),
1860
+ // Renamed from selected_api
1861
+ is_expired: z.string().optional(),
1862
+ // Mapped from is_stale
1863
+ expired_at: z.string().nullable().optional(),
1864
+ // Mapped from marked_stale_at
1865
+ app_key: z.string().optional(),
1866
+ // App key from implementations endpoint
1867
+ version: z.string().optional(),
1868
+ // Version extracted from implementation_id
1869
+ user_id: z.number().optional()
1870
+ }
1871
+ ),
1872
+ {
1873
+ format: (item) => {
1874
+ const details = [];
1875
+ if (item.identifier) {
1876
+ details.push({
1877
+ text: `Identifier: ${item.identifier}`,
1878
+ style: "accent"
1879
+ });
1880
+ }
1881
+ details.push({
1882
+ text: `Account: ${item.account_id} | Private: ${item.is_private} | Shared: ${item.shared_with_all}`,
1883
+ style: "dim"
1884
+ });
1885
+ if (item.marked_stale_at) {
1886
+ details.push({
1887
+ text: `\u26A0\uFE0F Marked stale: ${new Date(item.marked_stale_at).toLocaleDateString()}`,
1888
+ style: "warning"
1889
+ });
1890
+ }
1891
+ return {
1892
+ title: item.title || `Authentication ${item.id}`,
1893
+ id: item.id?.toString(),
1894
+ details
1895
+ };
1896
+ }
1897
+ }
1898
+ );
1471
1899
 
1472
1900
  // src/plugins/listAuthentications/index.ts
1473
1901
  var listAuthenticationsPlugin = ({ context }) => {
@@ -1543,20 +1971,23 @@ var listAuthenticationsPlugin = ({ context }) => {
1543
1971
  meta: {
1544
1972
  listAuthentications: {
1545
1973
  categories: ["authentication"],
1546
- inputSchema: ListAuthenticationsSchema
1974
+ type: "list",
1975
+ itemType: "Authentication",
1976
+ inputSchema: ListAuthenticationsSchema,
1977
+ outputSchema: AuthenticationItemSchema,
1978
+ resolvers: {
1979
+ appKey: appKeyResolver
1980
+ }
1547
1981
  }
1548
1982
  }
1549
1983
  }
1550
1984
  };
1551
1985
  };
1552
- var GetAppSchema = withOutputSchema(
1553
- z.object({
1554
- appKey: AppKeyPropertySchema.describe(
1555
- "App key of app to fetch (e.g., 'SlackCLIAPI')"
1556
- )
1557
- }).describe("Get detailed information about a specific app"),
1558
- AppItemSchema
1559
- );
1986
+ var GetAppSchema = z.object({
1987
+ appKey: AppKeyPropertySchema.describe(
1988
+ "App key of app to fetch (e.g., 'SlackCLIAPI')"
1989
+ )
1990
+ }).describe("Get detailed information about a specific app");
1560
1991
 
1561
1992
  // src/plugins/getApp/index.ts
1562
1993
  var getAppPlugin = ({ sdk }) => {
@@ -1577,7 +2008,13 @@ var getAppPlugin = ({ sdk }) => {
1577
2008
  meta: {
1578
2009
  getApp: {
1579
2010
  categories: ["app"],
1580
- inputSchema: GetAppSchema
2011
+ type: "item",
2012
+ itemType: "App",
2013
+ inputSchema: GetAppSchema,
2014
+ outputSchema: AppItemSchema,
2015
+ resolvers: {
2016
+ appKey: appKeyResolver
2017
+ }
1581
2018
  }
1582
2019
  }
1583
2020
  }
@@ -1610,7 +2047,15 @@ var getActionPlugin = ({ sdk }) => {
1610
2047
  meta: {
1611
2048
  getAction: {
1612
2049
  categories: ["action"],
1613
- inputSchema: GetActionSchema
2050
+ type: "item",
2051
+ itemType: "Action",
2052
+ inputSchema: GetActionSchema,
2053
+ outputSchema: ActionItemSchema,
2054
+ resolvers: {
2055
+ appKey: appKeyResolver,
2056
+ actionType: actionTypeResolver,
2057
+ actionKey: actionKeyResolver
2058
+ }
1614
2059
  }
1615
2060
  }
1616
2061
  }
@@ -1665,7 +2110,13 @@ var getAuthenticationPlugin = ({ context }) => {
1665
2110
  meta: {
1666
2111
  getAuthentication: {
1667
2112
  categories: ["authentication"],
1668
- inputSchema: GetAuthenticationSchema
2113
+ type: "item",
2114
+ itemType: "Authentication",
2115
+ inputSchema: GetAuthenticationSchema,
2116
+ outputSchema: AuthenticationItemSchema,
2117
+ resolvers: {
2118
+ authenticationId: authenticationIdGenericResolver
2119
+ }
1669
2120
  }
1670
2121
  }
1671
2122
  }
@@ -1689,8 +2140,14 @@ var findFirstAuthenticationPlugin = ({ sdk }) => {
1689
2140
  ...options,
1690
2141
  maxItems: 1
1691
2142
  });
2143
+ if (authsResponse.data.length === 0) {
2144
+ throw new ZapierResourceNotFoundError(
2145
+ "No authentication found matching the specified criteria",
2146
+ { resourceType: "Authentication" }
2147
+ );
2148
+ }
1692
2149
  return {
1693
- data: authsResponse.data.length > 0 ? authsResponse.data[0] : null
2150
+ data: authsResponse.data[0]
1694
2151
  };
1695
2152
  },
1696
2153
  FindFirstAuthenticationSchema
@@ -1701,7 +2158,10 @@ var findFirstAuthenticationPlugin = ({ sdk }) => {
1701
2158
  meta: {
1702
2159
  findFirstAuthentication: {
1703
2160
  categories: ["authentication"],
1704
- inputSchema: FindFirstAuthenticationSchema
2161
+ type: "item",
2162
+ itemType: "Authentication",
2163
+ inputSchema: FindFirstAuthenticationSchema,
2164
+ outputSchema: AuthenticationItemSchema
1705
2165
  }
1706
2166
  }
1707
2167
  }
@@ -1749,7 +2209,10 @@ var findUniqueAuthenticationPlugin = ({ sdk }) => {
1749
2209
  meta: {
1750
2210
  findUniqueAuthentication: {
1751
2211
  categories: ["authentication"],
1752
- inputSchema: FindUniqueAuthenticationSchema
2212
+ type: "item",
2213
+ itemType: "Authentication",
2214
+ inputSchema: FindUniqueAuthenticationSchema,
2215
+ outputSchema: AuthenticationItemSchema
1753
2216
  }
1754
2217
  }
1755
2218
  }
@@ -1766,6 +2229,31 @@ var RunActionSchema = z.object({
1766
2229
  pageSize: z.number().min(1).optional().describe("Number of results per page"),
1767
2230
  maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
1768
2231
  }).describe("Execute an action with the given inputs");
2232
+ function getStringProperty(obj, key) {
2233
+ if (typeof obj === "object" && obj !== null && key in obj) {
2234
+ const value = obj[key];
2235
+ return typeof value === "string" ? value : void 0;
2236
+ }
2237
+ return void 0;
2238
+ }
2239
+ function formatActionResult(item) {
2240
+ const obj = typeof item === "object" && item !== null ? item : {};
2241
+ const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
2242
+ return {
2243
+ title,
2244
+ id: getStringProperty(obj, "id"),
2245
+ key: getStringProperty(obj, "key"),
2246
+ description: getStringProperty(obj, "description"),
2247
+ data: item,
2248
+ // Let formatJsonOutput handle the JSON rendering
2249
+ details: []
2250
+ // Not used when data is provided
2251
+ };
2252
+ }
2253
+ var ActionResultItemSchema = withFormatter(
2254
+ z.unknown().describe("Action execution result"),
2255
+ { format: formatActionResult }
2256
+ );
1769
2257
 
1770
2258
  // src/plugins/runAction/index.ts
1771
2259
  async function executeAction(actionOptions) {
@@ -1857,7 +2345,17 @@ var runActionPlugin = ({ sdk, context }) => {
1857
2345
  meta: {
1858
2346
  runAction: {
1859
2347
  categories: ["action"],
1860
- inputSchema: RunActionSchema
2348
+ type: "list",
2349
+ itemType: "ActionResult",
2350
+ inputSchema: RunActionSchema,
2351
+ outputSchema: ActionResultItemSchema,
2352
+ resolvers: {
2353
+ appKey: appKeyResolver,
2354
+ actionType: actionTypeResolver,
2355
+ actionKey: actionKeyResolver,
2356
+ authenticationId: authenticationIdResolver,
2357
+ inputs: inputsResolver
2358
+ }
1861
2359
  }
1862
2360
  }
1863
2361
  }
@@ -1929,6 +2427,7 @@ var requestPlugin = ({ context }) => {
1929
2427
  meta: {
1930
2428
  request: {
1931
2429
  categories: ["http"],
2430
+ returnType: "Response",
1932
2431
  inputSchema: RelayRequestSchema
1933
2432
  }
1934
2433
  }
@@ -2276,6 +2775,7 @@ var manifestPlugin = (params) => {
2276
2775
  }
2277
2776
  };
2278
2777
  };
2778
+ var GetProfileSchema = z.object({}).optional().describe("Get current user's profile information");
2279
2779
  var UserProfileItemSchema = withFormatter(
2280
2780
  UserProfileSchema.omit({ user_id: true }).extend({
2281
2781
  full_name: z.string()
@@ -2284,32 +2784,37 @@ var UserProfileItemSchema = withFormatter(
2284
2784
  {
2285
2785
  format: (item) => {
2286
2786
  const details = [];
2287
- details.push({ text: item.email, style: "dim" });
2288
- if (item.timezone) {
2787
+ if (item == null || typeof item !== "object" || !("full_name" in item) || !("username" in item)) {
2788
+ return {
2789
+ title: "User Profile",
2790
+ subtitle: "Malformatted result item",
2791
+ details: []
2792
+ };
2793
+ }
2794
+ if ("email" in item) {
2795
+ details.push({ text: item.email, style: "dim" });
2796
+ }
2797
+ if ("timezone" in item && item.timezone) {
2289
2798
  details.push({
2290
2799
  text: `Timezone: ${item.timezone}`,
2291
2800
  style: "accent"
2292
2801
  });
2293
2802
  }
2294
- details.push({
2295
- text: `Member since: ${item.since_signup}`,
2296
- style: "dim"
2297
- });
2803
+ if ("since_signup" in item && item.since_signup) {
2804
+ details.push({
2805
+ text: `Member since: ${item.since_signup}`,
2806
+ style: "dim"
2807
+ });
2808
+ }
2298
2809
  return {
2299
2810
  title: item.full_name,
2300
- subtitle: `@${item.username}`,
2811
+ id: item.id.toString(),
2301
2812
  details
2302
2813
  };
2303
2814
  }
2304
2815
  }
2305
2816
  );
2306
2817
 
2307
- // src/plugins/getProfile/schemas.ts
2308
- var GetProfileSchema = withOutputSchema(
2309
- z.object({}).optional().describe("Get current user's profile information"),
2310
- UserProfileItemSchema
2311
- );
2312
-
2313
2818
  // src/plugins/getProfile/index.ts
2314
2819
  var getProfilePlugin = ({ context }) => {
2315
2820
  const getProfile = createFunction(async function getProfile2() {
@@ -2332,7 +2837,10 @@ var getProfilePlugin = ({ context }) => {
2332
2837
  meta: {
2333
2838
  getProfile: {
2334
2839
  categories: ["account"],
2335
- inputSchema: GetProfileSchema
2840
+ type: "item",
2841
+ itemType: "Profile",
2842
+ inputSchema: GetProfileSchema,
2843
+ outputSchema: UserProfileItemSchema
2336
2844
  }
2337
2845
  }
2338
2846
  }
@@ -2365,6 +2873,38 @@ function createDebugLogger(enabled) {
2365
2873
  console.log(`[Zapier SDK] ${message}`, data || "");
2366
2874
  };
2367
2875
  }
2876
+ function censorHeaders(headers) {
2877
+ if (!headers) return headers;
2878
+ const headersObj = new Headers(headers);
2879
+ const authKeys = ["authorization", "x-api-key"];
2880
+ for (const [key, value] of headersObj.entries()) {
2881
+ if (authKeys.some((authKey) => key.toLowerCase() === authKey)) {
2882
+ const spaceIndex = value.indexOf(" ");
2883
+ if (spaceIndex > 0 && spaceIndex < value.length - 1) {
2884
+ const prefix = value.substring(0, spaceIndex + 1);
2885
+ const token = value.substring(spaceIndex + 1);
2886
+ if (token.length > 12) {
2887
+ const start = token.substring(0, 4);
2888
+ const end = token.substring(token.length - 4);
2889
+ headersObj.set(key, `${prefix}${start}...${end}`);
2890
+ } else {
2891
+ const firstChar = token.charAt(0);
2892
+ headersObj.set(key, `${prefix}${firstChar}...`);
2893
+ }
2894
+ } else {
2895
+ if (value.length > 12) {
2896
+ const start = value.substring(0, 4);
2897
+ const end = value.substring(value.length - 4);
2898
+ headersObj.set(key, `${start}...${end}`);
2899
+ } else {
2900
+ const firstChar = value.charAt(0);
2901
+ headersObj.set(key, `${firstChar}...`);
2902
+ }
2903
+ }
2904
+ }
2905
+ }
2906
+ return Object.fromEntries(headersObj);
2907
+ }
2368
2908
  function createDebugFetch(options) {
2369
2909
  const { originalFetch, debugLog } = options;
2370
2910
  return async (input, options2) => {
@@ -2372,7 +2912,7 @@ function createDebugFetch(options) {
2372
2912
  const url = typeof input === "string" ? input : input.toString();
2373
2913
  const method = options2?.method || "GET";
2374
2914
  debugLog(`\u2192 ${method} ${url}`, {
2375
- headers: options2?.headers,
2915
+ headers: censorHeaders(options2?.headers),
2376
2916
  body: options2?.body && typeof options2.body === "string" ? (() => {
2377
2917
  try {
2378
2918
  return JSON.parse(options2.body);
@@ -2723,6 +3263,16 @@ var ZapierApiClient = class {
2723
3263
  if ("errors" in data && Array.isArray(data.errors)) {
2724
3264
  if (this.isApiErrorArray(data.errors)) {
2725
3265
  return data.errors[0].detail || data.errors[0].title;
3266
+ } else if (data.errors.length > 0) {
3267
+ const firstError = data.errors[0];
3268
+ if (typeof firstError === "string") {
3269
+ return firstError;
3270
+ }
3271
+ try {
3272
+ return JSON.stringify(firstError);
3273
+ } catch {
3274
+ return String(firstError);
3275
+ }
2726
3276
  }
2727
3277
  }
2728
3278
  }
@@ -2907,174 +3457,6 @@ var apiPlugin = (params) => {
2907
3457
  };
2908
3458
  };
2909
3459
 
2910
- // src/resolvers/appKey.ts
2911
- var appKeyResolver = {
2912
- type: "static",
2913
- inputType: "text",
2914
- placeholder: "Enter app key (e.g., 'SlackCLIAPI' or slug like 'github')"
2915
- };
2916
-
2917
- // src/resolvers/actionType.ts
2918
- var actionTypeResolver = {
2919
- type: "dynamic",
2920
- depends: ["appKey"],
2921
- fetch: async (sdk, resolvedParams) => {
2922
- const actionsResponse = await sdk.listActions({
2923
- appKey: resolvedParams.appKey
2924
- });
2925
- const types = [
2926
- ...new Set(actionsResponse.data.map((action) => action.action_type))
2927
- ];
2928
- return types.map((type) => ({ key: type, name: type }));
2929
- },
2930
- prompt: (types) => ({
2931
- type: "list",
2932
- name: "actionType",
2933
- message: "Select action type:",
2934
- choices: types.map((type) => ({
2935
- name: type.name,
2936
- value: type.key
2937
- }))
2938
- })
2939
- };
2940
-
2941
- // src/resolvers/actionKey.ts
2942
- var actionKeyResolver = {
2943
- type: "dynamic",
2944
- depends: ["appKey", "actionType"],
2945
- fetch: async (sdk, resolvedParams) => {
2946
- const actionsResponse = await sdk.listActions({
2947
- appKey: resolvedParams.appKey
2948
- });
2949
- return actionsResponse.data.filter(
2950
- (action) => action.action_type === resolvedParams.actionType
2951
- );
2952
- },
2953
- prompt: (actions) => ({
2954
- type: "list",
2955
- name: "actionKey",
2956
- message: "Select action:",
2957
- choices: actions.map((action) => ({
2958
- name: `${action.title || action.name || action.key} - ${action.description || "No description"}`,
2959
- value: action.key
2960
- }))
2961
- })
2962
- };
2963
-
2964
- // src/resolvers/authenticationId.ts
2965
- var authenticationIdResolver = {
2966
- type: "dynamic",
2967
- depends: ["appKey"],
2968
- fetch: async (sdk, resolvedParams) => {
2969
- const myAuths = await sdk.listAuthentications({
2970
- appKey: resolvedParams.appKey,
2971
- maxItems: 1e3,
2972
- owner: "me"
2973
- });
2974
- const allAuths = await sdk.listAuthentications({
2975
- appKey: resolvedParams.appKey,
2976
- maxItems: 1e3
2977
- });
2978
- const otherAuths = allAuths.data.filter(
2979
- (auth) => !myAuths.data.some((myAuth) => myAuth.id === auth.id)
2980
- );
2981
- return [...myAuths.data, ...otherAuths];
2982
- },
2983
- prompt: (auths, params) => ({
2984
- type: "list",
2985
- name: "authenticationId",
2986
- message: `Select authentication for ${params.appKey}:`,
2987
- choices: [
2988
- ...auths.map((auth) => ({
2989
- name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
2990
- value: auth.id
2991
- })),
2992
- {
2993
- name: "\u2197 Skip authentication (may fail)",
2994
- value: null
2995
- }
2996
- ]
2997
- })
2998
- };
2999
-
3000
- // src/resolvers/inputs.ts
3001
- var inputsResolver = {
3002
- type: "fields",
3003
- depends: ["appKey", "actionKey", "actionType", "authenticationId"],
3004
- fetch: async (sdk, resolvedParams) => {
3005
- const fieldsResponse = await sdk.listInputFields({
3006
- appKey: resolvedParams.appKey,
3007
- actionKey: resolvedParams.actionKey,
3008
- actionType: resolvedParams.actionType,
3009
- authenticationId: resolvedParams.authenticationId,
3010
- inputs: resolvedParams.inputs
3011
- // Pass along currently resolved inputs
3012
- });
3013
- return fieldsResponse.data;
3014
- }
3015
- };
3016
-
3017
- // src/resolvers/index.ts
3018
- var resolverRegistry = {
3019
- appKey: appKeyResolver,
3020
- actionType: actionTypeResolver,
3021
- actionKey: actionKeyResolver,
3022
- authenticationId: authenticationIdResolver,
3023
- inputs: inputsResolver
3024
- };
3025
- function getResolver(name) {
3026
- return resolverRegistry[name];
3027
- }
3028
- function getResolversForMissingParams(missingParams) {
3029
- const resolvers = {};
3030
- for (const param of missingParams) {
3031
- const resolver = resolverRegistry[param];
3032
- if (resolver) {
3033
- resolvers[param] = resolver;
3034
- }
3035
- }
3036
- return resolvers;
3037
- }
3038
- function hasResolver(paramName) {
3039
- return paramName in resolverRegistry;
3040
- }
3041
- function getResolvableParams() {
3042
- return Object.keys(resolverRegistry);
3043
- }
3044
- function getResolutionOrder(paramName, resolved = /* @__PURE__ */ new Set()) {
3045
- const resolver = getResolver(paramName);
3046
- if (!resolver || resolver.type === "static") {
3047
- return [paramName];
3048
- }
3049
- const order = [];
3050
- if ("depends" in resolver && resolver.depends) {
3051
- for (const dependency of resolver.depends) {
3052
- if (!resolved.has(dependency)) {
3053
- order.push(...getResolutionOrder(dependency, resolved));
3054
- resolved.add(dependency);
3055
- }
3056
- }
3057
- }
3058
- if (!resolved.has(paramName)) {
3059
- order.push(paramName);
3060
- resolved.add(paramName);
3061
- }
3062
- return order;
3063
- }
3064
- function getResolutionOrderForParams(paramNames) {
3065
- const resolved = /* @__PURE__ */ new Set();
3066
- const order = [];
3067
- for (const paramName of paramNames) {
3068
- const paramOrder = getResolutionOrder(paramName, resolved);
3069
- for (const param of paramOrder) {
3070
- if (!order.includes(param)) {
3071
- order.push(param);
3072
- }
3073
- }
3074
- }
3075
- return order;
3076
- }
3077
-
3078
3460
  // src/plugins/registry/index.ts
3079
3461
  var registryPlugin = ({ sdk, context }) => {
3080
3462
  const metaKeys = Object.keys(context.meta || {});
@@ -3104,10 +3486,16 @@ var registryPlugin = ({ sdk, context }) => {
3104
3486
  }
3105
3487
  };
3106
3488
  const functions = metaKeys.filter((key) => typeof sdk[key] === "function").map((key) => {
3489
+ const meta = context.meta[key];
3107
3490
  return {
3108
- ...context.meta[key],
3109
- categories: context.meta[key].categories || [],
3110
- name: key
3491
+ name: key,
3492
+ type: meta.type,
3493
+ itemType: meta.itemType,
3494
+ returnType: meta.returnType,
3495
+ inputSchema: meta.inputSchema,
3496
+ outputSchema: meta.outputSchema,
3497
+ categories: meta.categories || [],
3498
+ resolvers: meta.resolvers
3111
3499
  };
3112
3500
  }).sort((a, b) => a.name.localeCompare(b.name));
3113
3501
  const knownCategories = Object.keys(categoryDefinitions);
@@ -3141,52 +3529,43 @@ var registryPlugin = ({ sdk, context }) => {
3141
3529
  getRegistry
3142
3530
  };
3143
3531
  };
3144
- var InputFieldChoiceItemSchema = withFormatter(
3145
- z.object({
3146
- key: z.string().optional().describe("Unique key/value for the choice"),
3147
- label: z.string().optional().describe("Human readable label for the choice"),
3148
- sample: z.string().optional().describe("Sample value for the choice"),
3149
- value: z.string().optional().describe("Value to be submitted when selected")
3150
- }),
3151
- {
3152
- format: (item) => {
3153
- const title = item.label || item.key || "Choice";
3154
- const subtitle = item.label && item.key && item.label !== item.key ? `(${item.key})` : void 0;
3155
- const details = [];
3156
- if (item.sample && item.sample !== item.key) {
3157
- details.push({ text: `Sample: ${item.sample}`, style: "dim" });
3158
- }
3159
- if (item.value && item.value !== item.key) {
3160
- details.push({ text: `Value: ${item.value}`, style: "normal" });
3161
- }
3162
- return {
3163
- title,
3164
- subtitle,
3165
- details
3166
- };
3532
+ var InputFieldChoiceItemSchema = withFormatter(NeedChoicesSchema, {
3533
+ format: (item) => {
3534
+ const title = item.label || item.key || "Choice";
3535
+ const details = [];
3536
+ if (item.label && item.key && item.label !== item.key) {
3537
+ details.push({ text: `Key: ${item.key}`, style: "dim" });
3538
+ }
3539
+ if (item.sample && item.sample !== item.key) {
3540
+ details.push({ text: `Sample: ${item.sample}`, style: "dim" });
3167
3541
  }
3542
+ if (item.value && item.value !== item.key) {
3543
+ details.push({ text: `Value: ${item.value}`, style: "normal" });
3544
+ }
3545
+ return {
3546
+ title,
3547
+ key: item.key,
3548
+ details
3549
+ };
3168
3550
  }
3169
- );
3170
- var ListInputFieldChoicesSchema = withOutputSchema(
3171
- z.object({
3172
- // Required action identification
3173
- appKey: AppKeyPropertySchema,
3174
- actionType: ActionTypePropertySchema,
3175
- actionKey: ActionKeyPropertySchema,
3176
- // Input field specification
3177
- inputFieldKey: z.string().min(1).describe("Input field key to get choices for."),
3178
- // Common parameters
3179
- authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
3180
- inputs: InputsPropertySchema.optional().describe(
3181
- "Current input values that may affect available choices"
3182
- ),
3183
- page: z.number().int().min(0).optional().describe("Page number for paginated results"),
3184
- // Pagination options (SDK-level)
3185
- pageSize: z.number().min(1).optional().describe("Number of choices per page"),
3186
- maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
3187
- }).describe("Get the available choices for a dynamic dropdown input field"),
3188
- InputFieldChoiceItemSchema
3189
- );
3551
+ });
3552
+ var ListInputFieldChoicesSchema = z.object({
3553
+ // Required action identification
3554
+ appKey: AppKeyPropertySchema,
3555
+ actionType: ActionTypePropertySchema,
3556
+ actionKey: ActionKeyPropertySchema,
3557
+ // Input field specification
3558
+ inputFieldKey: z.string().min(1).describe("Input field key to get choices for."),
3559
+ // Common parameters
3560
+ authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
3561
+ inputs: InputsPropertySchema.optional().describe(
3562
+ "Current input values that may affect available choices"
3563
+ ),
3564
+ page: z.number().int().min(0).optional().describe("Page number for paginated results"),
3565
+ // Pagination options (SDK-level)
3566
+ pageSize: z.number().min(1).optional().describe("Number of choices per page"),
3567
+ maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
3568
+ }).describe("Get the available choices for a dynamic dropdown input field");
3190
3569
 
3191
3570
  // src/plugins/listInputFieldChoices/index.ts
3192
3571
  function transformNeedChoicesToInputFieldChoiceItem(choice) {
@@ -3240,7 +3619,7 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
3240
3619
  transformNeedChoicesToInputFieldChoiceItem
3241
3620
  );
3242
3621
  let nextCursor;
3243
- if (choicesData.next_page !== void 0) {
3622
+ if (choicesData.next_page != null) {
3244
3623
  nextCursor = choicesData.next_page.toString();
3245
3624
  } else if (choicesData.links?.next) {
3246
3625
  try {
@@ -3264,7 +3643,18 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
3264
3643
  meta: {
3265
3644
  listInputFieldChoices: {
3266
3645
  categories: ["action"],
3267
- inputSchema: ListInputFieldChoicesSchema
3646
+ type: "list",
3647
+ itemType: "InputFieldChoice",
3648
+ inputSchema: ListInputFieldChoicesSchema,
3649
+ outputSchema: InputFieldChoiceItemSchema,
3650
+ resolvers: {
3651
+ appKey: appKeyResolver,
3652
+ actionType: actionTypeResolver,
3653
+ actionKey: actionKeyResolver,
3654
+ authenticationId: authenticationIdResolver,
3655
+ inputFieldKey: inputFieldKeyResolver,
3656
+ inputs: inputsAllOptionalResolver
3657
+ }
3268
3658
  }
3269
3659
  }
3270
3660
  }
@@ -3326,4 +3716,4 @@ function createZapierSdk(options = {}) {
3326
3716
  return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
3327
3717
  }
3328
3718
 
3329
- export { ActionKeyPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, RelayFetchSchema, RelayRequestSchema, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdResolver, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getPreferredManifestEntryKey, getProfilePlugin, getResolutionOrder, getResolutionOrderForParams, getResolvableParams, getResolver, getResolversForMissingParams, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, hasResolver, inputsResolver, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resolverRegistry, runActionPlugin };
3719
+ export { ActionKeyPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, RelayFetchSchema, RelayRequestSchema, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getPreferredManifestEntryKey, getProfilePlugin, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, runActionPlugin };