@zapier/zapier-sdk 0.8.3 → 0.10.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 (222) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +17 -40
  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 +1149 -751
  15. package/dist/index.d.mts +2359 -2161
  16. package/dist/index.d.ts +3 -5
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +2 -4
  19. package/dist/index.mjs +1143 -743
  20. package/dist/plugins/apps/index.d.ts +4 -0
  21. package/dist/plugins/apps/index.d.ts.map +1 -1
  22. package/dist/plugins/findFirstAuthentication/index.d.ts +1 -1
  23. package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
  24. package/dist/plugins/findFirstAuthentication/index.js +9 -1
  25. package/dist/plugins/findFirstAuthentication/index.test.js +3 -4
  26. package/dist/plugins/findFirstAuthentication/schemas.d.ts +5 -3
  27. package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -1
  28. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
  29. package/dist/plugins/findUniqueAuthentication/index.js +4 -0
  30. package/dist/plugins/findUniqueAuthentication/schemas.d.ts +5 -3
  31. package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -1
  32. package/dist/plugins/getAction/index.d.ts.map +1 -1
  33. package/dist/plugins/getAction/index.js +10 -0
  34. package/dist/plugins/getAction/schemas.d.ts +5 -3
  35. package/dist/plugins/getAction/schemas.d.ts.map +1 -1
  36. package/dist/plugins/getApp/index.d.ts +2 -7
  37. package/dist/plugins/getApp/index.d.ts.map +1 -1
  38. package/dist/plugins/getApp/index.js +17 -9
  39. package/dist/plugins/getApp/index.test.js +3 -3
  40. package/dist/plugins/getApp/schemas.d.ts +3 -1
  41. package/dist/plugins/getApp/schemas.d.ts.map +1 -1
  42. package/dist/plugins/getApp/schemas.js +2 -4
  43. package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
  44. package/dist/plugins/getAuthentication/index.js +8 -0
  45. package/dist/plugins/getAuthentication/index.test.js +1 -1
  46. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  47. package/dist/plugins/getProfile/index.js +4 -0
  48. package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
  49. package/dist/plugins/getProfile/schemas.js +4 -3
  50. package/dist/plugins/listActions/index.d.ts +2 -4
  51. package/dist/plugins/listActions/index.d.ts.map +1 -1
  52. package/dist/plugins/listActions/index.js +10 -1
  53. package/dist/plugins/listActions/index.test.js +4 -4
  54. package/dist/plugins/listActions/schemas.d.ts +5 -3
  55. package/dist/plugins/listActions/schemas.d.ts.map +1 -1
  56. package/dist/plugins/listActions/schemas.js +2 -4
  57. package/dist/plugins/listApps/index.d.ts +4 -7
  58. package/dist/plugins/listApps/index.d.ts.map +1 -1
  59. package/dist/plugins/listApps/index.js +37 -17
  60. package/dist/plugins/listApps/index.test.js +23 -3
  61. package/dist/plugins/listApps/schemas.d.ts.map +1 -1
  62. package/dist/plugins/listApps/schemas.js +3 -9
  63. package/dist/plugins/listAuthentications/index.d.ts +2 -4
  64. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  65. package/dist/plugins/listAuthentications/index.js +12 -0
  66. package/dist/plugins/listAuthentications/index.test.js +39 -13
  67. package/dist/plugins/listAuthentications/schemas.d.ts +8 -3
  68. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
  69. package/dist/plugins/listAuthentications/schemas.js +4 -0
  70. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  71. package/dist/plugins/listInputFieldChoices/index.js +14 -2
  72. package/dist/plugins/listInputFieldChoices/schemas.d.ts +5 -3
  73. package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
  74. package/dist/plugins/listInputFieldChoices/schemas.js +10 -19
  75. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  76. package/dist/plugins/listInputFields/index.js +14 -2
  77. package/dist/plugins/listInputFields/index.test.js +5 -9
  78. package/dist/plugins/listInputFields/schemas.d.ts +5 -3
  79. package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
  80. package/dist/plugins/manifest/index.d.ts +25 -9
  81. package/dist/plugins/manifest/index.d.ts.map +1 -1
  82. package/dist/plugins/manifest/index.js +239 -67
  83. package/dist/plugins/manifest/index.test.js +426 -171
  84. package/dist/plugins/manifest/schemas.d.ts +5 -1
  85. package/dist/plugins/manifest/schemas.d.ts.map +1 -1
  86. package/dist/plugins/manifest/schemas.js +1 -0
  87. package/dist/plugins/registry/index.d.ts.map +1 -1
  88. package/dist/plugins/registry/index.js +8 -2
  89. package/dist/plugins/request/index.d.ts.map +1 -1
  90. package/dist/plugins/request/index.js +1 -0
  91. package/dist/plugins/runAction/index.d.ts.map +1 -1
  92. package/dist/plugins/runAction/index.js +12 -0
  93. package/dist/plugins/runAction/schemas.d.ts +5 -3
  94. package/dist/plugins/runAction/schemas.d.ts.map +1 -1
  95. package/dist/resolvers/actionKey.d.ts +13 -7
  96. package/dist/resolvers/actionKey.d.ts.map +1 -1
  97. package/dist/resolvers/actionType.d.ts +8 -7
  98. package/dist/resolvers/actionType.d.ts.map +1 -1
  99. package/dist/resolvers/appKey.d.ts +2 -6
  100. package/dist/resolvers/appKey.d.ts.map +1 -1
  101. package/dist/resolvers/authenticationId.d.ts +7 -7
  102. package/dist/resolvers/authenticationId.d.ts.map +1 -1
  103. package/dist/resolvers/authenticationId.js +16 -7
  104. package/dist/resolvers/index.d.ts +3 -35
  105. package/dist/resolvers/index.d.ts.map +1 -1
  106. package/dist/resolvers/index.js +4 -87
  107. package/dist/resolvers/inputFieldKey.d.ts +11 -0
  108. package/dist/resolvers/inputFieldKey.d.ts.map +1 -0
  109. package/dist/resolvers/inputFieldKey.js +23 -0
  110. package/dist/resolvers/inputs.d.ts +11 -6
  111. package/dist/resolvers/inputs.d.ts.map +1 -1
  112. package/dist/resolvers/inputs.js +17 -0
  113. package/dist/schemas/Action.d.ts +8 -8
  114. package/dist/schemas/Action.d.ts.map +1 -1
  115. package/dist/schemas/Action.js +8 -3
  116. package/dist/schemas/App.d.ts +183 -11
  117. package/dist/schemas/App.d.ts.map +1 -1
  118. package/dist/schemas/App.js +7 -9
  119. package/dist/schemas/Auth.d.ts +12 -12
  120. package/dist/schemas/Auth.js +1 -1
  121. package/dist/schemas/Field.d.ts +5 -98
  122. package/dist/schemas/Field.d.ts.map +1 -1
  123. package/dist/schemas/Field.js +24 -52
  124. package/dist/schemas/Run.d.ts +3 -0
  125. package/dist/schemas/Run.d.ts.map +1 -0
  126. package/dist/schemas/Run.js +31 -0
  127. package/dist/schemas/UserProfile.d.ts +11 -11
  128. package/dist/schemas/UserProfile.d.ts.map +1 -1
  129. package/dist/schemas/UserProfile.js +21 -7
  130. package/dist/sdk.d.ts +15 -14
  131. package/dist/sdk.d.ts.map +1 -1
  132. package/dist/sdk.js +1 -4
  133. package/dist/types/plugin.d.ts +6 -0
  134. package/dist/types/plugin.d.ts.map +1 -1
  135. package/dist/types/properties.d.ts +3 -1
  136. package/dist/types/properties.d.ts.map +1 -1
  137. package/dist/types/sdk.d.ts +11 -3
  138. package/dist/types/sdk.d.ts.map +1 -1
  139. package/dist/utils/domain-utils.d.ts +17 -16
  140. package/dist/utils/domain-utils.d.ts.map +1 -1
  141. package/dist/utils/domain-utils.js +53 -78
  142. package/dist/utils/domain-utils.test.js +157 -3
  143. package/dist/utils/file-utils.d.ts +4 -0
  144. package/dist/utils/file-utils.d.ts.map +1 -0
  145. package/dist/utils/file-utils.js +74 -0
  146. package/dist/utils/file-utils.test.d.ts +2 -0
  147. package/dist/utils/file-utils.test.d.ts.map +1 -0
  148. package/dist/utils/file-utils.test.js +51 -0
  149. package/dist/utils/schema-utils.d.ts +44 -21
  150. package/dist/utils/schema-utils.d.ts.map +1 -1
  151. package/dist/utils/schema-utils.js +17 -11
  152. package/package.json +1 -1
  153. package/src/api/client.ts +12 -0
  154. package/src/api/debug.test.ts +76 -0
  155. package/src/api/debug.ts +46 -2
  156. package/src/api/schemas.ts +51 -29
  157. package/src/index.ts +5 -6
  158. package/src/plugins/apps/index.ts +9 -2
  159. package/src/plugins/findFirstAuthentication/index.test.ts +8 -5
  160. package/src/plugins/findFirstAuthentication/index.ts +14 -2
  161. package/src/plugins/findUniqueAuthentication/index.ts +4 -0
  162. package/src/plugins/getAction/index.ts +14 -0
  163. package/src/plugins/getApp/index.test.ts +3 -3
  164. package/src/plugins/getApp/index.ts +20 -14
  165. package/src/plugins/getApp/schemas.ts +7 -12
  166. package/src/plugins/getAuthentication/index.test.ts +1 -1
  167. package/src/plugins/getAuthentication/index.ts +8 -0
  168. package/src/plugins/getProfile/index.ts +4 -0
  169. package/src/plugins/getProfile/schemas.ts +4 -6
  170. package/src/plugins/listActions/index.test.ts +8 -7
  171. package/src/plugins/listActions/index.ts +12 -3
  172. package/src/plugins/listActions/schemas.ts +20 -25
  173. package/src/plugins/listApps/index.test.ts +24 -3
  174. package/src/plugins/listApps/index.ts +50 -25
  175. package/src/plugins/listApps/schemas.ts +17 -26
  176. package/src/plugins/listAuthentications/index.test.ts +52 -15
  177. package/src/plugins/listAuthentications/index.ts +15 -2
  178. package/src/plugins/listAuthentications/schemas.ts +4 -0
  179. package/src/plugins/listInputFieldChoices/index.ts +21 -1
  180. package/src/plugins/listInputFieldChoices/schemas.ts +61 -76
  181. package/src/plugins/listInputFields/index.test.ts +5 -9
  182. package/src/plugins/listInputFields/index.ts +20 -2
  183. package/src/plugins/manifest/index.test.ts +503 -197
  184. package/src/plugins/manifest/index.ts +338 -82
  185. package/src/plugins/manifest/schemas.ts +9 -2
  186. package/src/plugins/registry/index.ts +8 -2
  187. package/src/plugins/request/index.ts +1 -0
  188. package/src/plugins/runAction/index.ts +18 -0
  189. package/src/resolvers/actionKey.ts +15 -13
  190. package/src/resolvers/actionType.ts +10 -12
  191. package/src/resolvers/appKey.ts +2 -6
  192. package/src/resolvers/authenticationId.ts +25 -19
  193. package/src/resolvers/index.ts +7 -113
  194. package/src/resolvers/inputFieldKey.ts +38 -0
  195. package/src/resolvers/inputs.ts +28 -10
  196. package/src/schemas/Action.ts +8 -3
  197. package/src/schemas/App.ts +7 -9
  198. package/src/schemas/Auth.ts +1 -1
  199. package/src/schemas/Field.ts +24 -57
  200. package/src/schemas/Run.ts +40 -0
  201. package/src/schemas/UserProfile.ts +24 -7
  202. package/src/sdk.ts +18 -12
  203. package/src/types/plugin.ts +8 -0
  204. package/src/types/sdk.ts +31 -21
  205. package/src/utils/domain-utils.test.ts +196 -2
  206. package/src/utils/domain-utils.ts +77 -102
  207. package/src/utils/file-utils.test.ts +73 -0
  208. package/src/utils/file-utils.ts +94 -0
  209. package/src/utils/schema-utils.ts +96 -44
  210. package/tsconfig.tsbuildinfo +1 -1
  211. package/dist/plugins/lockVersion/index.d.ts +0 -24
  212. package/dist/plugins/lockVersion/index.d.ts.map +0 -1
  213. package/dist/plugins/lockVersion/index.js +0 -72
  214. package/dist/plugins/lockVersion/index.test.d.ts +0 -2
  215. package/dist/plugins/lockVersion/index.test.d.ts.map +0 -1
  216. package/dist/plugins/lockVersion/index.test.js +0 -129
  217. package/dist/plugins/lockVersion/schemas.d.ts +0 -10
  218. package/dist/plugins/lockVersion/schemas.d.ts.map +0 -1
  219. package/dist/plugins/lockVersion/schemas.js +0 -6
  220. package/src/plugins/lockVersion/index.test.ts +0 -176
  221. package/src/plugins/lockVersion/index.ts +0 -112
  222. package/src/plugins/lockVersion/schemas.ts +0 -9
package/dist/index.mjs CHANGED
@@ -1,23 +1,24 @@
1
1
  import { z } from 'zod';
2
- import { readFileSync, existsSync, writeFileSync } from 'fs';
3
- import { resolve } from 'path';
4
2
  import { setTimeout } from 'timers/promises';
5
3
 
6
4
  // src/types/properties.ts
7
5
  function withFormatter(schema, formatMeta) {
8
- schema._def.formatMeta = formatMeta;
6
+ Object.assign(schema._def, {
7
+ formatMeta
8
+ });
9
9
  return schema;
10
10
  }
11
- function withOutputSchema(inputSchema, outputSchema) {
12
- inputSchema._def.outputSchema = outputSchema;
13
- return inputSchema;
14
- }
15
11
  function withPositional(schema) {
16
- schema._def.positionalMeta = { positional: true };
12
+ Object.assign(schema._def, {
13
+ positionalMeta: { positional: true }
14
+ });
17
15
  return schema;
18
16
  }
17
+ function schemaHasPositionalMeta(schema) {
18
+ return "positionalMeta" in schema._def;
19
+ }
19
20
  function isPositional(schema) {
20
- if (schema._def.positionalMeta?.positional) {
21
+ if (schemaHasPositionalMeta(schema) && schema._def.positionalMeta?.positional) {
21
22
  return true;
22
23
  }
23
24
  if (schema instanceof z.ZodOptional) {
@@ -604,256 +605,14 @@ function createPaginatedFunction(coreFn, schema) {
604
605
  };
605
606
  return namedFunctions[functionName];
606
607
  }
607
- var AppItemSchema = withFormatter(
608
- z.object({
609
- // Essential properties only
610
- title: z.string(),
611
- // Mapped from name
612
- key: z.string(),
613
- // Mapped from selected_api
614
- current_implementation_id: z.string(),
615
- // From id, keeps the full version
616
- version: z.string().optional(),
617
- // Extracted from implementation ID
618
- description: z.string().optional(),
619
- slug: z.string().optional()
620
- }),
621
- {
622
- format: (item) => {
623
- return {
624
- title: item.title,
625
- subtitle: `(${item.key})`,
626
- details: []
627
- };
628
- }
629
- }
630
- );
631
-
632
- // src/plugins/listApps/schemas.ts
633
- var ListAppsSchema = withOutputSchema(
634
- z.object({
635
- appKeys: z.array(z.string()).optional().describe(
636
- "Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"
637
- ),
638
- search: z.string().optional().describe("Search for apps by name"),
639
- pageSize: z.number().min(1).optional().describe("Number of apps per page"),
640
- maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
641
- }).describe("List all available apps with optional filtering"),
642
- AppItemSchema
643
- );
644
-
645
- // src/utils/domain-utils.ts
646
- function splitVersionedKey(versionedKey) {
647
- const parts = versionedKey.split("@");
648
- if (parts.length >= 2) {
649
- const baseKey = parts[0];
650
- const version = parts.slice(1).join("@");
651
- return [baseKey, version];
652
- }
653
- return [versionedKey, void 0];
654
- }
655
- function normalizeImplementationToAppItem(implementation) {
656
- const [selectedApi, appVersion] = implementation.selected_api ? splitVersionedKey(implementation.selected_api) : [implementation.selected_api || "", void 0];
657
- return {
658
- title: implementation.name || selectedApi,
659
- key: selectedApi,
660
- current_implementation_id: implementation.selected_api || "",
661
- version: appVersion
662
- // Extract version separately
663
- };
664
- }
665
- function normalizeImplementationMetaToAppItem(implementationMeta) {
666
- const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
667
- return {
668
- title: implementationMeta.name,
669
- key: selectedApi,
670
- current_implementation_id: implementationMeta.id,
671
- // Keep the full versioned ID
672
- version: appVersion,
673
- // Extract version separately
674
- slug: implementationMeta.slug
675
- };
676
- }
677
- function normalizeAuthenticationItem(auth, options = {}) {
678
- let appKey = options.app_key;
679
- let version = options.version;
680
- if (auth.selected_api) {
681
- const [extractedAppKey, extractedVersion] = splitVersionedKey(
682
- auth.selected_api
683
- );
684
- if (!appKey) {
685
- appKey = extractedAppKey;
686
- }
687
- if (!version) {
688
- version = extractedVersion;
689
- }
690
- }
691
- const {
692
- selected_api: selectedApi,
693
- customuser_id: userId,
694
- ...restOfAuth
695
- } = auth;
696
- return {
697
- ...restOfAuth,
698
- // Pass through all other API response fields except selected_api
699
- implementation_id: selectedApi,
700
- // Rename selected_api to implementation_id
701
- title: auth.title || auth.label || void 0,
702
- // Coerce title from label if missing
703
- is_expired: auth.is_stale,
704
- // Map is_stale to is_expired
705
- expired_at: auth.marked_stale_at,
706
- // Map marked_stale_at to expired_at
707
- app_key: appKey,
708
- // App key from implementations endpoint or parsed from selected_api
709
- version,
710
- // Version from selected_api or provided
711
- user_id: userId
712
- // Map customuser_id to user_id
713
- };
714
- }
715
- function normalizeActionItem(action) {
716
- const { name, type, selected_api: appKey, ...restOfAction } = action;
717
- return {
718
- ...restOfAction,
719
- app_key: appKey || "",
720
- action_type: type,
721
- title: name,
722
- // Map name to title
723
- type: "action"
724
- };
725
- }
726
- function groupVersionedAppKeysByType(appKeys) {
727
- const result = {
728
- selectedApi: [],
729
- slug: []
730
- };
731
- const seenSelectedApi = /* @__PURE__ */ new Set();
732
- const seenSlugs = /* @__PURE__ */ new Set();
733
- for (const key of appKeys) {
734
- const [keyWithoutVersion, version] = splitVersionedKey(key);
735
- const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
736
- if (uuidRegex.test(keyWithoutVersion)) {
737
- throw new Error(
738
- `UUID app keys are not supported. Use app slug or implementation ID instead of: ${key}`
739
- );
740
- }
741
- if (isSnakeCasedSlug(keyWithoutVersion)) {
742
- const dashified = dashifySnakeCasedSlug(keyWithoutVersion);
743
- const slugWithVersion = version ? `${dashified}@${version}` : dashified;
744
- if (!seenSlugs.has(slugWithVersion)) {
745
- seenSlugs.add(slugWithVersion);
746
- result.slug.push(slugWithVersion);
747
- }
748
- continue;
749
- }
750
- if (keyWithoutVersion.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)) {
751
- seenSlugs.add(key);
752
- result.slug.push(key);
753
- continue;
754
- }
755
- if (!seenSelectedApi.has(key)) {
756
- seenSelectedApi.add(key);
757
- result.selectedApi.push(key);
758
- }
759
- }
760
- return result;
761
- }
762
- function groupAppKeysByType(appKeys) {
763
- const grouped = groupVersionedAppKeysByType(appKeys);
764
- return {
765
- selectedApi: [
766
- ...new Set(grouped.selectedApi.map((key) => key.split("@")[0]))
767
- ],
768
- slug: [...new Set(grouped.slug.map((key) => key.split("@")[0]))]
769
- };
770
- }
771
- function isSnakeCasedSlug(slug) {
772
- if (slug.match(/^_[0-9]/)) {
773
- slug = slug.slice(1);
774
- }
775
- return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
776
- }
777
- function dashifySnakeCasedSlug(slug) {
778
- if (!isSnakeCasedSlug(slug)) {
779
- return slug;
780
- }
781
- if (slug.startsWith("_")) {
782
- slug = slug.slice(1);
783
- }
784
- return slug.replace(/_/g, "-");
785
- }
786
-
787
- // src/plugins/listApps/index.ts
788
- var listAppsPlugin = ({ context }) => {
789
- const listApps = createPaginatedFunction(async function listAppsPage(options) {
790
- const api = context.api;
791
- const opts = options;
792
- const appKeys = [...opts.appKeys ?? []].map(
793
- (key) => splitVersionedKey(key)[0]
794
- );
795
- if (opts.search) {
796
- const searchParams2 = {};
797
- searchParams2.term = opts.search;
798
- const searchEnvelope = await api.get(
799
- "/api/v4/implementations-meta/search/",
800
- {
801
- searchParams: searchParams2
802
- }
803
- );
804
- const implementations = searchEnvelope.results.map(
805
- normalizeImplementationMetaToAppItem
806
- );
807
- const appKeysSet = new Set(appKeys);
808
- for (const implementation of implementations) {
809
- if (!appKeysSet.has(implementation.key)) {
810
- appKeysSet.add(implementation.key);
811
- appKeys.push(implementation.key);
812
- }
813
- }
814
- }
815
- const searchParams = {};
816
- if (opts.pageSize) {
817
- searchParams.limit = opts.pageSize.toString();
818
- }
819
- searchParams.latest_only = "true";
820
- if (opts.cursor) {
821
- searchParams.offset = opts.cursor;
822
- }
823
- if (appKeys.length > 0) {
824
- const groupedAppKeys = groupAppKeysByType(appKeys);
825
- if (groupedAppKeys.selectedApi.length > 0) {
826
- searchParams.selected_apis = groupedAppKeys.selectedApi.join(",");
827
- }
828
- if (groupedAppKeys.slug.length > 0) {
829
- searchParams.slugs = groupedAppKeys.slug.join(",");
830
- }
831
- }
832
- const implementationsEnvelope = await api.get(
833
- "/api/v4/implementations-meta/lookup/",
834
- {
835
- searchParams
836
- }
837
- );
838
- return {
839
- data: implementationsEnvelope.results.map(
840
- normalizeImplementationMetaToAppItem
841
- ),
842
- nextCursor: extractCursor(implementationsEnvelope)
843
- };
844
- }, ListAppsSchema);
845
- return {
846
- listApps,
847
- context: {
848
- meta: {
849
- listApps: {
850
- categories: ["app"],
851
- inputSchema: ListAppsSchema
852
- }
853
- }
854
- }
855
- };
856
- };
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");
857
616
  var NeedChoicesSchema = z.object({
858
617
  key: z.string().optional(),
859
618
  label: z.string().optional(),
@@ -953,7 +712,7 @@ z.object({
953
712
  choices: z.array(ChoiceSchema).optional()
954
713
  });
955
714
  z.object({
956
- data: z.array(z.any())
715
+ data: z.array(z.unknown())
957
716
  });
958
717
  var ActionFieldChoiceSchema = z.object({
959
718
  value: z.union([z.string(), z.number()]),
@@ -1043,9 +802,9 @@ var UserProfileSchema = z.object({
1043
802
  enable_totp_2fa: z.boolean(),
1044
803
  viewed_help: z.record(z.boolean()),
1045
804
  show_editor_migration_mesaging: z.boolean(),
1046
- switches: z.record(z.any()),
1047
- organizations: z.array(z.any().nullable()),
1048
- 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(),
1049
808
  has_active_zaps: z.boolean(),
1050
809
  has_google_sso: z.boolean(),
1051
810
  auth_realm: z.string(),
@@ -1061,8 +820,8 @@ z.object({
1061
820
  api_docs_url: z.string().nullable().optional(),
1062
821
  app_profile_url: z.string(),
1063
822
  banner: z.string().optional(),
1064
- categories: z.array(z.any()).optional(),
1065
- // TODO: Define proper service_category type
823
+ categories: z.array(z.string()).optional(),
824
+ // Service category names
1066
825
  canonical_id: z.string().optional(),
1067
826
  current_implementation_id: z.string(),
1068
827
  days_since_last_update: z.string().optional(),
@@ -1113,7 +872,7 @@ z.object({
1113
872
  action: z.string(),
1114
873
  type_of: z.string(),
1115
874
  authentication_id: z.number().optional(),
1116
- params: z.record(z.any()).optional()
875
+ params: z.record(z.unknown()).optional()
1117
876
  });
1118
877
  z.object({
1119
878
  success: z.boolean(),
@@ -1149,18 +908,11 @@ z.object({
1149
908
  });
1150
909
  var ImplementationMetaSchema = z.object({
1151
910
  id: z.string(),
1152
- // e.g. "ZapierFormatterCLIAPI@1.0.7"
911
+ // e.g. "100HiresCLIAPI@1.2.1"
1153
912
  name: z.string(),
1154
913
  slug: z.string(),
1155
- images: z.object({
1156
- url_16x16: z.string().optional(),
1157
- url_32x32: z.string().optional(),
1158
- url_64x64: z.string().optional(),
1159
- url_128x128: z.string().optional()
1160
- }).optional(),
1161
- // Include other fields for completeness but we'll only use what we need
1162
- ageInDays: z.union([z.string(), z.number()]).optional(),
1163
- authType: z.string().nullable().optional(),
914
+ age_in_days: z.number().optional(),
915
+ auth_type: z.string().optional(),
1164
916
  banner: z.string().optional(),
1165
917
  categories: z.array(
1166
918
  z.object({
@@ -1169,18 +921,45 @@ var ImplementationMetaSchema = z.object({
1169
921
  slug: z.string()
1170
922
  })
1171
923
  ).optional(),
1172
- isBeta: z.boolean().optional(),
1173
- isBuiltIn: z.boolean().optional(),
1174
- isDeprecated: z.boolean().optional(),
1175
- isFeatured: z.boolean().optional(),
1176
- isHidden: z.boolean().optional(),
1177
- isInvite: z.boolean().optional(),
1178
- isPremium: z.boolean().optional(),
1179
- isPublic: z.boolean().optional(),
1180
- 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(),
1181
930
  popularity: z.number().optional(),
1182
- apiDocsUrl: z.string().optional(),
1183
- 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()
1184
963
  });
1185
964
  z.object({
1186
965
  count: z.number(),
@@ -1202,7 +981,7 @@ z.object({
1202
981
  authentication_id: z.number().optional().describe(
1203
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)."
1204
983
  ),
1205
- params: z.record(z.any()).optional().describe(
984
+ params: z.record(z.unknown()).optional().describe(
1206
985
  "Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action."
1207
986
  ),
1208
987
  page: z.number().optional().default(0),
@@ -1225,73 +1004,456 @@ z.object({
1225
1004
  links: NeedChoicesResponseLinksSchema.optional()
1226
1005
  });
1227
1006
 
1228
- // src/schemas/Action.ts
1229
- var ActionItemSchema = withFormatter(
1230
- ActionSchema.omit({ type: true, name: true }).extend({
1231
- app_key: z.string(),
1232
- // Mapped from selected_api
1233
- action_type: ActionSchema.shape.type,
1234
- // Mapped from original 'type' field
1007
+ // src/schemas/App.ts
1008
+ var AppItemSchema = withFormatter(
1009
+ ImplementationMetaSchema.omit({ name: true, id: true }).extend({
1235
1010
  title: z.string(),
1236
- // Mapped from original 'name' field
1237
- type: z.literal("action")
1238
- // 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)
1239
1016
  }),
1240
1017
  {
1241
1018
  format: (item) => {
1242
- const details = [];
1243
- details.push({
1244
- text: `Type: ${item.action_type}`,
1245
- style: "accent"
1246
- });
1247
- if (item.app_key) {
1248
- details.push({
1249
- text: `App: ${item.app_key}`,
1250
- style: "normal"
1251
- });
1252
- }
1253
- if (item.description) {
1254
- details.push({ text: item.description, style: "dim" });
1255
- }
1256
1019
  return {
1257
- title: item.title || item.name || item.key,
1258
- subtitle: `(${item.key})`,
1259
- details
1020
+ title: item.title,
1021
+ key: item.key,
1022
+ description: item.description,
1023
+ details: []
1260
1024
  };
1261
1025
  }
1262
1026
  }
1263
1027
  );
1264
1028
 
1265
- // src/plugins/listActions/schemas.ts
1266
- var ListActionsSchema = withOutputSchema(
1267
- z.object({
1268
- appKey: AppKeyPropertySchema.describe(
1269
- "App key of actions to list (e.g., 'SlackCLIAPI')"
1270
- ),
1271
- actionType: ActionTypePropertySchema.optional().describe(
1272
- "Filter actions by type"
1273
- ),
1274
- pageSize: z.number().min(1).optional().describe("Number of actions per page"),
1275
- maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
1276
- }).describe("List all actions for a specific app"),
1277
- ActionItemSchema
1278
- );
1279
-
1280
- // src/plugins/listActions/index.ts
1281
- var listActionsPlugin = ({ context }) => {
1282
- const listActions = createPaginatedFunction(async function listActionsPage(options) {
1283
- const { api, getVersionedImplementationId } = context;
1284
- const selectedApi = await getVersionedImplementationId(options.appKey);
1285
- if (!selectedApi) {
1286
- throw new ZapierConfigurationError(
1287
- "No current_implementation_id found for app",
1288
- { configType: "current_implementation_id" }
1289
- );
1290
- }
1291
- const searchParams = {
1292
- global: "true",
1293
- public_only: "true",
1294
- selected_apis: selectedApi
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
+ });
1262
+ if (item.app_key) {
1263
+ details.push({
1264
+ text: `App: ${item.app_key}`,
1265
+ style: "normal"
1266
+ });
1267
+ }
1268
+ if (item.description) {
1269
+ details.push({
1270
+ text: item.description,
1271
+ style: "dim"
1272
+ });
1273
+ }
1274
+ return {
1275
+ title: item.title || item.key,
1276
+ id: item.id,
1277
+ key: item.key,
1278
+ description: item.description,
1279
+ details
1280
+ };
1281
+ }
1282
+ }
1283
+ );
1284
+
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
+ var inputsResolver = {
1383
+ type: "fields",
1384
+ depends: ["appKey", "actionKey", "actionType", "authenticationId"],
1385
+ fetch: async (sdk, resolvedParams) => {
1386
+ const fieldsResponse = await sdk.listInputFields({
1387
+ appKey: resolvedParams.appKey,
1388
+ actionKey: resolvedParams.actionKey,
1389
+ actionType: resolvedParams.actionType,
1390
+ authenticationId: resolvedParams.authenticationId,
1391
+ inputs: resolvedParams.inputs
1392
+ // Pass along currently resolved inputs
1393
+ });
1394
+ return fieldsResponse.data;
1395
+ }
1396
+ };
1397
+ var inputsAllOptionalResolver = {
1398
+ type: "fields",
1399
+ depends: ["appKey", "actionKey", "actionType", "authenticationId"],
1400
+ fetch: async (sdk, resolvedParams) => {
1401
+ const fieldsResponse = await sdk.listInputFields({
1402
+ appKey: resolvedParams.appKey,
1403
+ actionKey: resolvedParams.actionKey,
1404
+ actionType: resolvedParams.actionType,
1405
+ authenticationId: resolvedParams.authenticationId,
1406
+ inputs: resolvedParams.inputs
1407
+ // Pass along currently resolved inputs
1408
+ });
1409
+ return fieldsResponse.data.map((field) => ({
1410
+ ...field,
1411
+ is_required: false
1412
+ }));
1413
+ }
1414
+ };
1415
+
1416
+ // src/resolvers/inputFieldKey.ts
1417
+ var inputFieldKeyResolver = {
1418
+ type: "dynamic",
1419
+ depends: ["appKey", "actionKey", "actionType", "authenticationId"],
1420
+ fetch: async (sdk, resolvedParams) => {
1421
+ const fieldsResponse = await sdk.listInputFields({
1422
+ appKey: resolvedParams.appKey,
1423
+ actionKey: resolvedParams.actionKey,
1424
+ actionType: resolvedParams.actionType,
1425
+ authenticationId: resolvedParams.authenticationId,
1426
+ inputs: resolvedParams.inputs
1427
+ // Pass along currently resolved inputs
1428
+ });
1429
+ return fieldsResponse.data;
1430
+ },
1431
+ prompt: (fields) => ({
1432
+ type: "list",
1433
+ name: "inputFieldKey",
1434
+ message: "Select input field:",
1435
+ choices: fields.map((field) => ({
1436
+ name: `${field.title || field.key} - ${field.value_type || "No type"} ${field.is_required ? "(required)" : "(optional)"}`,
1437
+ value: field.key
1438
+ }))
1439
+ })
1440
+ };
1441
+
1442
+ // src/plugins/listActions/index.ts
1443
+ var listActionsPlugin = ({ context }) => {
1444
+ const listActions = createPaginatedFunction(async function listActionsPage(options) {
1445
+ const { api, getVersionedImplementationId } = context;
1446
+ const selectedApi = await getVersionedImplementationId(options.appKey);
1447
+ if (!selectedApi) {
1448
+ throw new ZapierConfigurationError(
1449
+ "No current_implementation_id found for app",
1450
+ { configType: "current_implementation_id" }
1451
+ );
1452
+ }
1453
+ const searchParams = {
1454
+ global: "true",
1455
+ public_only: "true",
1456
+ selected_apis: selectedApi
1295
1457
  };
1296
1458
  const data = await api.get(
1297
1459
  "/api/v4/implementations/",
@@ -1342,7 +1504,14 @@ var listActionsPlugin = ({ context }) => {
1342
1504
  meta: {
1343
1505
  listActions: {
1344
1506
  categories: ["action"],
1345
- inputSchema: ListActionsSchema
1507
+ type: "list",
1508
+ itemType: "Action",
1509
+ inputSchema: ListActionsSchema,
1510
+ outputSchema: ActionItemSchema,
1511
+ resolvers: {
1512
+ appKey: appKeyResolver,
1513
+ actionType: actionTypeResolver
1514
+ }
1346
1515
  }
1347
1516
  }
1348
1517
  }
@@ -1359,6 +1528,83 @@ var ListInputFieldsSchema = z.object({
1359
1528
  pageSize: z.number().min(1).optional().describe("Number of input fields per page"),
1360
1529
  maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
1361
1530
  }).describe("Get the input fields required for a specific action");
1531
+ var InputFieldItemSchema = withFormatter(
1532
+ z.object({
1533
+ key: z.string(),
1534
+ // From need.key
1535
+ default_value: z.string(),
1536
+ // Mapped from 'default' with fallback to ""
1537
+ depends_on: z.array(z.string()),
1538
+ // Mapped from 'depends_on' with fallback to []
1539
+ description: z.string(),
1540
+ // Mapped from 'help_text' with fallback to ""
1541
+ invalidates_input_fields: z.boolean(),
1542
+ // Mapped from 'alters_custom_fields' with fallback to false
1543
+ is_required: z.boolean(),
1544
+ // Mapped from 'required' with fallback to false
1545
+ placeholder: z.string(),
1546
+ // Mapped from 'placeholder' with fallback to ""
1547
+ title: z.string(),
1548
+ // Mapped from 'label' with fallback to ""
1549
+ value_type: z.string(),
1550
+ // Computed from InputFieldType enum
1551
+ format: z.string().optional(),
1552
+ // Computed from InputFieldFormat enum (optional)
1553
+ items: z.object({ type: z.string() }).optional()
1554
+ // Computed from ItemsType enum (optional, only for arrays)
1555
+ }),
1556
+ {
1557
+ format: (item) => {
1558
+ const details = [];
1559
+ const typeInfo = [
1560
+ item.value_type && `Type: ${item.value_type}`,
1561
+ `Required: ${item.is_required ? "Yes" : "No"}`
1562
+ ].filter(Boolean).join(" | ");
1563
+ if (typeInfo) {
1564
+ details.push({ text: typeInfo, style: "dim" });
1565
+ }
1566
+ if (item.description) {
1567
+ details.push({
1568
+ text: item.description,
1569
+ style: "normal"
1570
+ });
1571
+ }
1572
+ if (item.default_value) {
1573
+ details.push({
1574
+ text: `Default: ${item.default_value}`,
1575
+ style: "accent"
1576
+ });
1577
+ }
1578
+ if (item.placeholder) {
1579
+ details.push({
1580
+ text: `Placeholder: ${item.placeholder}`,
1581
+ style: "dim"
1582
+ });
1583
+ }
1584
+ if (item.depends_on && item.depends_on.length > 0) {
1585
+ details.push({
1586
+ text: `Depends on: ${item.depends_on.join(", ")}`,
1587
+ style: "warning"
1588
+ });
1589
+ }
1590
+ if (item.format) {
1591
+ details.push({ text: `Format: ${item.format}`, style: "dim" });
1592
+ }
1593
+ if (item.items) {
1594
+ details.push({
1595
+ text: `Items type: ${item.items.type}`,
1596
+ style: "dim"
1597
+ });
1598
+ }
1599
+ return {
1600
+ title: item.title || item.key,
1601
+ key: item.key,
1602
+ description: item.description,
1603
+ details
1604
+ };
1605
+ }
1606
+ }
1607
+ );
1362
1608
 
1363
1609
  // src/plugins/listInputFields/index.ts
1364
1610
  function getInputFieldTypeFromNeed(need) {
@@ -1403,9 +1649,8 @@ function getItemsTypeFromNeed(need) {
1403
1649
  function transformNeedToInputFieldItem(need) {
1404
1650
  const itemsType = getItemsTypeFromNeed(need);
1405
1651
  return {
1406
- ...need,
1407
- // Pass through all original Need fields
1408
- id: need.key,
1652
+ // Only the final computed/mapped fields that are in InputFieldItemSchema
1653
+ key: need.key,
1409
1654
  default_value: need.default || "",
1410
1655
  depends_on: need.depends_on || [],
1411
1656
  description: need.help_text || "",
@@ -1465,7 +1710,17 @@ var listInputFieldsPlugin = ({ context }) => {
1465
1710
  meta: {
1466
1711
  listInputFields: {
1467
1712
  categories: ["action"],
1468
- inputSchema: ListInputFieldsSchema
1713
+ type: "list",
1714
+ itemType: "InputField",
1715
+ inputSchema: ListInputFieldsSchema,
1716
+ outputSchema: InputFieldItemSchema,
1717
+ resolvers: {
1718
+ appKey: appKeyResolver,
1719
+ actionType: actionTypeResolver,
1720
+ actionKey: actionKeyResolver,
1721
+ authenticationId: authenticationIdResolver,
1722
+ inputs: inputsAllOptionalResolver
1723
+ }
1469
1724
  }
1470
1725
  }
1471
1726
  }
@@ -1475,6 +1730,7 @@ var ListAuthenticationsSchema = z.object({
1475
1730
  appKey: AppKeyPropertySchema.optional().describe(
1476
1731
  "App key of authentications to list (e.g., 'SlackCLIAPI')"
1477
1732
  ),
1733
+ authenticationIds: z.array(z.string()).optional().describe("List of authentication IDs to filter by"),
1478
1734
  search: z.string().optional().describe("Search term to filter authentications by title"),
1479
1735
  title: z.string().optional().describe("Filter authentications by exact title match"),
1480
1736
  accountId: z.string().optional().describe("Filter by account ID"),
@@ -1482,6 +1738,49 @@ var ListAuthenticationsSchema = z.object({
1482
1738
  pageSize: z.number().min(1).optional().describe("Number of authentications per page"),
1483
1739
  maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
1484
1740
  }).describe("List available authentications with optional filtering");
1741
+ var AuthenticationItemSchema = withFormatter(
1742
+ AuthenticationSchema.omit({ selected_api: true, customuser_id: true }).extend(
1743
+ {
1744
+ implementation_id: z.string().optional(),
1745
+ // Renamed from selected_api
1746
+ is_expired: z.string().optional(),
1747
+ // Mapped from is_stale
1748
+ expired_at: z.string().nullable().optional(),
1749
+ // Mapped from marked_stale_at
1750
+ app_key: z.string().optional(),
1751
+ // App key from implementations endpoint
1752
+ version: z.string().optional(),
1753
+ // Version extracted from implementation_id
1754
+ user_id: z.number().optional()
1755
+ }
1756
+ ),
1757
+ {
1758
+ format: (item) => {
1759
+ const details = [];
1760
+ if (item.identifier) {
1761
+ details.push({
1762
+ text: `Identifier: ${item.identifier}`,
1763
+ style: "accent"
1764
+ });
1765
+ }
1766
+ details.push({
1767
+ text: `Account: ${item.account_id} | Private: ${item.is_private} | Shared: ${item.shared_with_all}`,
1768
+ style: "dim"
1769
+ });
1770
+ if (item.marked_stale_at) {
1771
+ details.push({
1772
+ text: `\u26A0\uFE0F Marked stale: ${new Date(item.marked_stale_at).toLocaleDateString()}`,
1773
+ style: "warning"
1774
+ });
1775
+ }
1776
+ return {
1777
+ title: item.title || `Authentication ${item.id}`,
1778
+ id: item.id?.toString(),
1779
+ details
1780
+ };
1781
+ }
1782
+ }
1783
+ );
1485
1784
 
1486
1785
  // src/plugins/listAuthentications/index.ts
1487
1786
  var listAuthenticationsPlugin = ({ context }) => {
@@ -1498,6 +1797,9 @@ var listAuthenticationsPlugin = ({ context }) => {
1498
1797
  searchParams.versionless_selected_api = versionlessSelectedApi;
1499
1798
  }
1500
1799
  }
1800
+ if (options.authenticationIds && options.authenticationIds.length > 0) {
1801
+ searchParams.ids = options.authenticationIds.join(",");
1802
+ }
1501
1803
  if (options.search) {
1502
1804
  searchParams.search = options.search;
1503
1805
  } else if (options.title) {
@@ -1554,33 +1856,36 @@ var listAuthenticationsPlugin = ({ context }) => {
1554
1856
  meta: {
1555
1857
  listAuthentications: {
1556
1858
  categories: ["authentication"],
1557
- inputSchema: ListAuthenticationsSchema
1859
+ type: "list",
1860
+ itemType: "Authentication",
1861
+ inputSchema: ListAuthenticationsSchema,
1862
+ outputSchema: AuthenticationItemSchema,
1863
+ resolvers: {
1864
+ appKey: appKeyResolver
1865
+ }
1558
1866
  }
1559
1867
  }
1560
1868
  }
1561
1869
  };
1562
1870
  };
1563
- var GetAppSchema = withOutputSchema(
1564
- z.object({
1565
- appKey: AppKeyPropertySchema.describe(
1566
- "App key of app to fetch (e.g., 'SlackCLIAPI')"
1567
- )
1568
- }).describe("Get detailed information about a specific app"),
1569
- AppItemSchema
1570
- );
1871
+ var GetAppSchema = z.object({
1872
+ appKey: AppKeyPropertySchema.describe(
1873
+ "App key of app to fetch (e.g., 'SlackCLIAPI')"
1874
+ )
1875
+ }).describe("Get detailed information about a specific app");
1571
1876
 
1572
1877
  // src/plugins/getApp/index.ts
1573
- var getAppPlugin = ({ context }) => {
1878
+ var getAppPlugin = ({ sdk }) => {
1574
1879
  const getApp = createFunction(async function getApp2(options) {
1575
- const app = await context.getImplementation(options.appKey);
1576
- if (!app) {
1577
- throw new ZapierAppNotFoundError("App not found", {
1578
- appKey: options.appKey
1579
- });
1880
+ const appsIterator = sdk.listApps({ appKeys: [options.appKey] }).items();
1881
+ for await (const app of appsIterator) {
1882
+ return {
1883
+ data: app
1884
+ };
1580
1885
  }
1581
- return {
1582
- data: app
1583
- };
1886
+ throw new ZapierAppNotFoundError("App not found", {
1887
+ appKey: options.appKey
1888
+ });
1584
1889
  }, GetAppSchema);
1585
1890
  return {
1586
1891
  getApp,
@@ -1588,7 +1893,13 @@ var getAppPlugin = ({ context }) => {
1588
1893
  meta: {
1589
1894
  getApp: {
1590
1895
  categories: ["app"],
1591
- inputSchema: GetAppSchema
1896
+ type: "item",
1897
+ itemType: "App",
1898
+ inputSchema: GetAppSchema,
1899
+ outputSchema: AppItemSchema,
1900
+ resolvers: {
1901
+ appKey: appKeyResolver
1902
+ }
1592
1903
  }
1593
1904
  }
1594
1905
  }
@@ -1621,7 +1932,15 @@ var getActionPlugin = ({ sdk }) => {
1621
1932
  meta: {
1622
1933
  getAction: {
1623
1934
  categories: ["action"],
1624
- inputSchema: GetActionSchema
1935
+ type: "item",
1936
+ itemType: "Action",
1937
+ inputSchema: GetActionSchema,
1938
+ outputSchema: ActionItemSchema,
1939
+ resolvers: {
1940
+ appKey: appKeyResolver,
1941
+ actionType: actionTypeResolver,
1942
+ actionKey: actionKeyResolver
1943
+ }
1625
1944
  }
1626
1945
  }
1627
1946
  }
@@ -1676,7 +1995,13 @@ var getAuthenticationPlugin = ({ context }) => {
1676
1995
  meta: {
1677
1996
  getAuthentication: {
1678
1997
  categories: ["authentication"],
1679
- inputSchema: GetAuthenticationSchema
1998
+ type: "item",
1999
+ itemType: "Authentication",
2000
+ inputSchema: GetAuthenticationSchema,
2001
+ outputSchema: AuthenticationItemSchema,
2002
+ resolvers: {
2003
+ authenticationId: authenticationIdGenericResolver
2004
+ }
1680
2005
  }
1681
2006
  }
1682
2007
  }
@@ -1700,8 +2025,14 @@ var findFirstAuthenticationPlugin = ({ sdk }) => {
1700
2025
  ...options,
1701
2026
  maxItems: 1
1702
2027
  });
2028
+ if (authsResponse.data.length === 0) {
2029
+ throw new ZapierResourceNotFoundError(
2030
+ "No authentication found matching the specified criteria",
2031
+ { resourceType: "Authentication" }
2032
+ );
2033
+ }
1703
2034
  return {
1704
- data: authsResponse.data.length > 0 ? authsResponse.data[0] : null
2035
+ data: authsResponse.data[0]
1705
2036
  };
1706
2037
  },
1707
2038
  FindFirstAuthenticationSchema
@@ -1712,7 +2043,10 @@ var findFirstAuthenticationPlugin = ({ sdk }) => {
1712
2043
  meta: {
1713
2044
  findFirstAuthentication: {
1714
2045
  categories: ["authentication"],
1715
- inputSchema: FindFirstAuthenticationSchema
2046
+ type: "item",
2047
+ itemType: "Authentication",
2048
+ inputSchema: FindFirstAuthenticationSchema,
2049
+ outputSchema: AuthenticationItemSchema
1716
2050
  }
1717
2051
  }
1718
2052
  }
@@ -1760,7 +2094,10 @@ var findUniqueAuthenticationPlugin = ({ sdk }) => {
1760
2094
  meta: {
1761
2095
  findUniqueAuthentication: {
1762
2096
  categories: ["authentication"],
1763
- inputSchema: FindUniqueAuthenticationSchema
2097
+ type: "item",
2098
+ itemType: "Authentication",
2099
+ inputSchema: FindUniqueAuthenticationSchema,
2100
+ outputSchema: AuthenticationItemSchema
1764
2101
  }
1765
2102
  }
1766
2103
  }
@@ -1777,6 +2114,31 @@ var RunActionSchema = z.object({
1777
2114
  pageSize: z.number().min(1).optional().describe("Number of results per page"),
1778
2115
  maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
1779
2116
  }).describe("Execute an action with the given inputs");
2117
+ function getStringProperty(obj, key) {
2118
+ if (typeof obj === "object" && obj !== null && key in obj) {
2119
+ const value = obj[key];
2120
+ return typeof value === "string" ? value : void 0;
2121
+ }
2122
+ return void 0;
2123
+ }
2124
+ function formatActionResult(item) {
2125
+ const obj = typeof item === "object" && item !== null ? item : {};
2126
+ const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
2127
+ return {
2128
+ title,
2129
+ id: getStringProperty(obj, "id"),
2130
+ key: getStringProperty(obj, "key"),
2131
+ description: getStringProperty(obj, "description"),
2132
+ data: item,
2133
+ // Let formatJsonOutput handle the JSON rendering
2134
+ details: []
2135
+ // Not used when data is provided
2136
+ };
2137
+ }
2138
+ var ActionResultItemSchema = withFormatter(
2139
+ z.unknown().describe("Action execution result"),
2140
+ { format: formatActionResult }
2141
+ );
1780
2142
 
1781
2143
  // src/plugins/runAction/index.ts
1782
2144
  async function executeAction(actionOptions) {
@@ -1868,7 +2230,17 @@ var runActionPlugin = ({ sdk, context }) => {
1868
2230
  meta: {
1869
2231
  runAction: {
1870
2232
  categories: ["action"],
1871
- inputSchema: RunActionSchema
2233
+ type: "list",
2234
+ itemType: "ActionResult",
2235
+ inputSchema: RunActionSchema,
2236
+ outputSchema: ActionResultItemSchema,
2237
+ resolvers: {
2238
+ appKey: appKeyResolver,
2239
+ actionType: actionTypeResolver,
2240
+ actionKey: actionKeyResolver,
2241
+ authenticationId: authenticationIdResolver,
2242
+ inputs: inputsResolver
2243
+ }
1872
2244
  }
1873
2245
  }
1874
2246
  }
@@ -1940,12 +2312,74 @@ var requestPlugin = ({ context }) => {
1940
2312
  meta: {
1941
2313
  request: {
1942
2314
  categories: ["http"],
2315
+ returnType: "Response",
1943
2316
  inputSchema: RelayRequestSchema
1944
2317
  }
1945
2318
  }
1946
2319
  }
1947
2320
  };
1948
2321
  };
2322
+
2323
+ // src/utils/file-utils.ts
2324
+ var inMemoryFiles = {};
2325
+ var fsPromises = null;
2326
+ var pathModule = null;
2327
+ async function loadFsPromises() {
2328
+ if (fsPromises) return fsPromises;
2329
+ try {
2330
+ fsPromises = await import('fs/promises');
2331
+ return fsPromises;
2332
+ } catch {
2333
+ return null;
2334
+ }
2335
+ }
2336
+ async function loadPathModule() {
2337
+ if (pathModule) return pathModule;
2338
+ try {
2339
+ pathModule = await import('path');
2340
+ return pathModule;
2341
+ } catch {
2342
+ return null;
2343
+ }
2344
+ }
2345
+ async function resolve(path, basePath = "/") {
2346
+ const pathModule2 = await loadPathModule();
2347
+ if (pathModule2) {
2348
+ return pathModule2.resolve(path);
2349
+ }
2350
+ if (path.startsWith("/")) {
2351
+ return path;
2352
+ }
2353
+ if (path.startsWith("./")) {
2354
+ const cleanPath = path.slice(2);
2355
+ return basePath.endsWith("/") ? basePath + cleanPath : basePath + "/" + cleanPath;
2356
+ }
2357
+ if (path.startsWith("../")) {
2358
+ const cleanPath = path.replace(/^(\.\.\/)+/, "");
2359
+ return basePath.endsWith("/") ? basePath + cleanPath : basePath + "/" + cleanPath;
2360
+ }
2361
+ return basePath.endsWith("/") ? basePath + path : basePath + "/" + path;
2362
+ }
2363
+ async function writeFile(filePath, content) {
2364
+ const fs = await loadFsPromises();
2365
+ if (fs) {
2366
+ await fs.writeFile(filePath, content, "utf8");
2367
+ return;
2368
+ }
2369
+ inMemoryFiles[filePath] = content;
2370
+ }
2371
+ async function readFile(filePath) {
2372
+ const fs = await loadFsPromises();
2373
+ if (fs) {
2374
+ return await fs.readFile(filePath, "utf8");
2375
+ }
2376
+ const content = inMemoryFiles[filePath];
2377
+ if (content !== void 0) {
2378
+ return content;
2379
+ }
2380
+ throw new Error(`File not found: ${filePath}`);
2381
+ }
2382
+ var DEFAULT_CONFIG_PATH = ".zapierrc";
1949
2383
  var ManifestSchema = z.object({
1950
2384
  apps: z.record(
1951
2385
  z.string(),
@@ -1968,6 +2402,15 @@ z.object({
1968
2402
  ).optional().describe("Direct manifest object")
1969
2403
  });
1970
2404
 
2405
+ // src/utils/array-utils.ts
2406
+ async function toArrayFromAsync(asyncIterable) {
2407
+ const result = [];
2408
+ for await (const item of asyncIterable) {
2409
+ result.push(item);
2410
+ }
2411
+ return result;
2412
+ }
2413
+
1971
2414
  // src/plugins/manifest/index.ts
1972
2415
  function parseManifestContent(content, source) {
1973
2416
  try {
@@ -1985,172 +2428,239 @@ function parseManifestContent(content, source) {
1985
2428
  return null;
1986
2429
  }
1987
2430
  }
1988
- function loadManifestFromFile(filePath) {
2431
+ async function readManifestFromFile(filePath) {
1989
2432
  try {
1990
- const resolvedPath = resolve(filePath);
1991
- const content = readFileSync(resolvedPath, "utf8");
2433
+ const resolvedPath = await resolve(filePath);
2434
+ const content = await readFile(resolvedPath);
1992
2435
  return parseManifestContent(content, resolvedPath);
1993
2436
  } catch {
1994
- console.warn(`\u26A0\uFE0F Failed to load manifest from ${filePath}`);
2437
+ console.warn(`\u26A0\uFE0F Failed to read manifest from ${filePath}`);
1995
2438
  return null;
1996
2439
  }
1997
2440
  }
1998
- var emitWarning = (appKey) => {
1999
- console.warn(
2000
- `
2001
- ${"\u26A0\uFE0F".padEnd(3)} ${"WARNING".padEnd(8)} No manifest version found for '${appKey}'`
2002
- );
2003
- console.warn(
2004
- ` ${"\u21B3".padEnd(3)} Using a manifest ensures version locking and prevents unexpected behavior due to version changes.`
2441
+ async function writeManifestToFile(manifest, filePath) {
2442
+ const resolvedPath = await resolve(filePath);
2443
+ await writeFile(resolvedPath, JSON.stringify(manifest, null, 2));
2444
+ }
2445
+ async function getPreferredManifestEntryKey({
2446
+ appKey,
2447
+ api
2448
+ }) {
2449
+ const locator = toAppLocator(appKey);
2450
+ if (locator.slug) {
2451
+ return locator.slug;
2452
+ }
2453
+ if (locator.implementationName) {
2454
+ try {
2455
+ const implementationsEnvelope = await api.get(`/api/v4/implementations-meta/lookup/`, {
2456
+ searchParams: {
2457
+ selected_apis: locator.implementationName
2458
+ }
2459
+ });
2460
+ if (implementationsEnvelope.results.length > 0 && implementationsEnvelope.results[0].slug) {
2461
+ return implementationsEnvelope.results[0].slug;
2462
+ }
2463
+ } catch {
2464
+ }
2465
+ return locator.implementationName;
2466
+ }
2467
+ return locator.lookupAppKey;
2468
+ }
2469
+ async function listAppsForSlugsPage({
2470
+ slugs,
2471
+ cursor,
2472
+ api
2473
+ }) {
2474
+ const searchParams = {};
2475
+ if (slugs.length > 0) {
2476
+ searchParams.slugs = slugs.join(",");
2477
+ }
2478
+ if (cursor) {
2479
+ searchParams.offset = cursor;
2480
+ }
2481
+ const implementationsEnvelope = await api.get(
2482
+ "/api/v4/implementations-meta/lookup/",
2483
+ {
2484
+ searchParams
2485
+ }
2005
2486
  );
2006
- console.warn(
2007
- ` ${"\u21B3".padEnd(3)} Generate/update the manifest with: \`zapier-sdk lock-version ${appKey}\`
2008
- `
2487
+ return {
2488
+ data: implementationsEnvelope.results.map(
2489
+ normalizeImplementationMetaToAppItem
2490
+ ),
2491
+ nextCursor: extractCursor(implementationsEnvelope)
2492
+ };
2493
+ }
2494
+ function findManifestEntry({
2495
+ appKey,
2496
+ manifest
2497
+ }) {
2498
+ const [appKeyWithoutVersion] = splitVersionedKey(appKey);
2499
+ if (manifest.apps[appKeyWithoutVersion]) {
2500
+ return [appKeyWithoutVersion, manifest.apps[appKeyWithoutVersion]];
2501
+ }
2502
+ if (isSnakeCasedSlug(appKey)) {
2503
+ const slug = dashifySnakeCasedSlug(appKey);
2504
+ if (manifest.apps[slug]) {
2505
+ return [slug, manifest.apps[slug]];
2506
+ }
2507
+ }
2508
+ for (const [key, entry] of Object.entries(manifest.apps)) {
2509
+ if (entry.implementationName === appKeyWithoutVersion) {
2510
+ return [key, entry];
2511
+ }
2512
+ }
2513
+ return null;
2514
+ }
2515
+ async function resolveAppKeys({
2516
+ appKeys,
2517
+ api,
2518
+ manifest
2519
+ }) {
2520
+ const locators = appKeys.map(toAppLocator);
2521
+ const locatorsWithManifest = locators.map((locator) => {
2522
+ const manifestEntryResult = findManifestEntry({
2523
+ appKey: locator.lookupAppKey,
2524
+ manifest
2525
+ });
2526
+ if (manifestEntryResult) {
2527
+ const [, manifestEntry] = manifestEntryResult;
2528
+ const resolvedVersion = locator.version || manifestEntry.version;
2529
+ const resolvedLocator = {
2530
+ ...locator,
2531
+ implementationName: manifestEntry.implementationName,
2532
+ version: resolvedVersion
2533
+ };
2534
+ return resolvedLocator;
2535
+ }
2536
+ return locator;
2537
+ });
2538
+ const unresolvedLocators = locatorsWithManifest.filter(
2539
+ (locator) => !isResolvedAppLocator(locator)
2009
2540
  );
2010
- };
2541
+ const slugsToResolve = unresolvedLocators.map((locator) => locator.slug).filter((slug) => !!slug).filter((slug, index, array) => array.indexOf(slug) === index);
2542
+ if (slugsToResolve.length === 0) {
2543
+ return locatorsWithManifest.filter(isResolvedAppLocator);
2544
+ }
2545
+ const iterator = paginate(listAppsForSlugsPage, {
2546
+ slugs: slugsToResolve,
2547
+ api
2548
+ });
2549
+ const pages = await toArrayFromAsync(iterator);
2550
+ const apps = pages.flatMap((page) => page.data);
2551
+ const slugToAppData = /* @__PURE__ */ new Map();
2552
+ for (const app of apps) {
2553
+ if (app.slug) {
2554
+ slugToAppData.set(app.slug, app);
2555
+ }
2556
+ }
2557
+ const slugResolvedLocators = locatorsWithManifest.map((locator) => {
2558
+ if (isResolvedAppLocator(locator)) {
2559
+ return locator;
2560
+ }
2561
+ if (locator.slug) {
2562
+ const appData = slugToAppData.get(locator.slug);
2563
+ if (appData) {
2564
+ const manifestEntryByImplementationName = findManifestEntry({
2565
+ appKey: appData.key,
2566
+ // appData.key is the implementation name
2567
+ manifest
2568
+ });
2569
+ let version = locator.version;
2570
+ if (!version) {
2571
+ version = manifestEntryByImplementationName ? manifestEntryByImplementationName[1].version || appData.version : appData.version;
2572
+ }
2573
+ return {
2574
+ ...locator,
2575
+ implementationName: appData.key,
2576
+ version
2577
+ };
2578
+ }
2579
+ }
2580
+ return locator;
2581
+ });
2582
+ return slugResolvedLocators.filter(isResolvedAppLocator);
2583
+ }
2011
2584
  var manifestPlugin = (params) => {
2012
- const { sdk, context } = params;
2585
+ const { context } = params;
2013
2586
  const { api, options } = context;
2014
- const { manifestPath = ".zapierrc", manifest } = options || {};
2587
+ const { manifestPath = DEFAULT_CONFIG_PATH, manifest } = options || {};
2015
2588
  let resolvedManifest;
2016
- function resolveManifest() {
2589
+ async function resolveManifest() {
2017
2590
  if (manifest) {
2018
2591
  return manifest;
2019
2592
  }
2020
2593
  if (manifestPath) {
2021
- return loadManifestFromFile(manifestPath);
2594
+ return await readManifestFromFile(manifestPath);
2022
2595
  }
2023
2596
  return null;
2024
2597
  }
2025
- const getResolvedManifest = () => {
2598
+ const getResolvedManifest = async () => {
2026
2599
  if (typeof resolvedManifest === "undefined") {
2027
- resolvedManifest = resolveManifest() ?? null;
2600
+ resolvedManifest = await resolveManifest() ?? null;
2028
2601
  }
2029
2602
  return resolvedManifest;
2030
2603
  };
2031
- const getManifestEntry = (appKey) => {
2032
- return getResolvedManifest()?.apps?.[appKey] || null;
2604
+ const getVersionedImplementationId = async (appKey) => {
2605
+ const resolvedApps = await resolveAppKeys({
2606
+ appKeys: [appKey],
2607
+ api,
2608
+ manifest: await getResolvedManifest() ?? { apps: {} }
2609
+ });
2610
+ const resolvedApp = resolvedApps[0];
2611
+ if (!resolvedApp) return null;
2612
+ return `${resolvedApp.implementationName}@${resolvedApp.version || "latest"}`;
2033
2613
  };
2034
- const getImplementation = async (appKey) => {
2035
- let selectedApi = null;
2036
- const manifestImplementation = getResolvedManifest()?.apps?.[appKey];
2037
- const [versionlessAppKey, version] = splitVersionedKey(appKey);
2038
- if (version) {
2039
- selectedApi = `${versionlessAppKey}@${version}`;
2040
- } else if (manifestImplementation) {
2041
- selectedApi = `${manifestImplementation.implementationName}@${manifestImplementation.version || "latest"}`;
2042
- }
2043
- if (selectedApi) {
2044
- const searchParams = {
2045
- selected_apis: selectedApi
2046
- };
2047
- const implementationData = await api.get(
2048
- "/api/v4/implementations/",
2049
- {
2050
- searchParams
2614
+ const updateManifestEntry = async (appKey, entry, configPath = DEFAULT_CONFIG_PATH) => {
2615
+ const manifest2 = await readManifestFromFile(configPath) || { apps: {} };
2616
+ let existingEntry = findManifestEntry({
2617
+ appKey,
2618
+ manifest: manifest2
2619
+ });
2620
+ if (!existingEntry) {
2621
+ try {
2622
+ const resolvedApps = await resolveAppKeys({
2623
+ appKeys: [appKey],
2624
+ api,
2625
+ manifest: manifest2
2626
+ });
2627
+ if (resolvedApps.length > 0) {
2628
+ const resolvedImplementationName = resolvedApps[0].implementationName;
2629
+ existingEntry = findManifestEntry({
2630
+ appKey: resolvedImplementationName,
2631
+ manifest: manifest2
2632
+ });
2051
2633
  }
2052
- );
2053
- const implementationResults = implementationData.results[0];
2054
- if (!implementationResults) return null;
2055
- return normalizeImplementationToAppItem(implementationResults);
2056
- }
2057
- emitWarning(appKey);
2058
- const appsIterator = sdk.listApps({ appKeys: [appKey] }).items();
2059
- const apps = [];
2060
- for await (const app2 of appsIterator) {
2061
- apps.push(app2);
2062
- break;
2063
- }
2064
- if (apps.length === 0) {
2065
- return null;
2066
- }
2067
- const app = apps[0];
2068
- return app;
2069
- };
2070
- const getVersionedImplementationId = async (appKey) => {
2071
- const manifestEntry = getManifestEntry(appKey);
2072
- if (manifestEntry) {
2073
- return `${manifestEntry.implementationName}@${manifestEntry.version || "latest"}`;
2634
+ } catch {
2635
+ }
2074
2636
  }
2075
- const implementation = await getImplementation(appKey);
2076
- if (!implementation) return null;
2077
- return implementation.current_implementation_id;
2078
- };
2079
- return {
2080
- context: {
2081
- getVersionedImplementationId,
2082
- getManifestEntry,
2083
- getImplementation
2637
+ let manifestKey;
2638
+ if (existingEntry) {
2639
+ manifestKey = existingEntry[0];
2640
+ } else {
2641
+ manifestKey = await getPreferredManifestEntryKey({
2642
+ appKey,
2643
+ api
2644
+ });
2084
2645
  }
2646
+ manifest2.apps[manifestKey] = entry;
2647
+ await writeManifestToFile(manifest2, configPath);
2648
+ resolvedManifest = void 0;
2649
+ return [manifestKey, entry];
2085
2650
  };
2086
- };
2087
- var LockVersionSchema = z.object({
2088
- appKey: z.string().describe("The app key to lock version for (e.g., 'slack', 'gmail')")
2089
- });
2090
- var lockVersionPlugin = ({ sdk }) => {
2091
- const lockVersion = createFunction(
2092
- async function lockVersion2(options) {
2093
- const { appKey, configPath = ".zapierrc" } = options;
2094
- const resolvedPath = resolve(configPath);
2095
- const appsIterator = sdk.listApps({ appKeys: [appKey] }).items();
2096
- const apps = [];
2097
- for await (const app2 of appsIterator) {
2098
- apps.push(app2);
2099
- break;
2100
- }
2101
- const app = apps[0];
2102
- const currentImplementationId = app.current_implementation_id;
2103
- const [implementationName, version] = currentImplementationId.split("@");
2104
- if (!implementationName || !version) {
2105
- throw new Error(
2106
- `Invalid implementation ID format: ${currentImplementationId}. Expected format: <implementationName>@<version>`
2107
- );
2108
- }
2109
- let config = { apps: {} };
2110
- if (existsSync(resolvedPath)) {
2111
- try {
2112
- const configContent = readFileSync(resolvedPath, "utf8");
2113
- config = JSON.parse(configContent);
2114
- if (!config.apps) {
2115
- config.apps = {};
2116
- }
2117
- } catch (error) {
2118
- console.warn(
2119
- `\u26A0\uFE0F Failed to parse existing config file, creating new one: ${error}`
2120
- );
2121
- config = { apps: {} };
2122
- }
2123
- }
2124
- config.apps[appKey] = {
2125
- implementationName,
2126
- version
2127
- };
2128
- writeFileSync(resolvedPath, JSON.stringify(config, null, 2));
2129
- return {
2130
- data: {
2131
- ...app,
2132
- implementationName,
2133
- version
2134
- },
2135
- configPath: resolvedPath
2136
- };
2137
- },
2138
- LockVersionSchema.extend({
2139
- configPath: z.string().optional().describe("Path to .zapierrc file (defaults to '.zapierrc')")
2140
- })
2141
- );
2142
2651
  return {
2143
- lockVersion,
2144
2652
  context: {
2145
- meta: {
2146
- lockVersion: {
2147
- categories: ["utility"],
2148
- inputSchema: LockVersionSchema
2149
- }
2150
- }
2653
+ getVersionedImplementationId,
2654
+ resolveAppKeys: async ({ appKeys }) => resolveAppKeys({
2655
+ appKeys,
2656
+ api,
2657
+ manifest: await getResolvedManifest() ?? { apps: {} }
2658
+ }),
2659
+ updateManifestEntry
2151
2660
  }
2152
2661
  };
2153
2662
  };
2663
+ var GetProfileSchema = z.object({}).optional().describe("Get current user's profile information");
2154
2664
  var UserProfileItemSchema = withFormatter(
2155
2665
  UserProfileSchema.omit({ user_id: true }).extend({
2156
2666
  full_name: z.string()
@@ -2159,32 +2669,37 @@ var UserProfileItemSchema = withFormatter(
2159
2669
  {
2160
2670
  format: (item) => {
2161
2671
  const details = [];
2162
- details.push({ text: item.email, style: "dim" });
2163
- if (item.timezone) {
2672
+ if (item == null || typeof item !== "object" || !("full_name" in item) || !("username" in item)) {
2673
+ return {
2674
+ title: "User Profile",
2675
+ subtitle: "Malformatted result item",
2676
+ details: []
2677
+ };
2678
+ }
2679
+ if ("email" in item) {
2680
+ details.push({ text: item.email, style: "dim" });
2681
+ }
2682
+ if ("timezone" in item && item.timezone) {
2164
2683
  details.push({
2165
2684
  text: `Timezone: ${item.timezone}`,
2166
2685
  style: "accent"
2167
2686
  });
2168
2687
  }
2169
- details.push({
2170
- text: `Member since: ${item.since_signup}`,
2171
- style: "dim"
2172
- });
2688
+ if ("since_signup" in item && item.since_signup) {
2689
+ details.push({
2690
+ text: `Member since: ${item.since_signup}`,
2691
+ style: "dim"
2692
+ });
2693
+ }
2173
2694
  return {
2174
2695
  title: item.full_name,
2175
- subtitle: `@${item.username}`,
2696
+ id: item.id.toString(),
2176
2697
  details
2177
2698
  };
2178
2699
  }
2179
2700
  }
2180
2701
  );
2181
2702
 
2182
- // src/plugins/getProfile/schemas.ts
2183
- var GetProfileSchema = withOutputSchema(
2184
- z.object({}).optional().describe("Get current user's profile information"),
2185
- UserProfileItemSchema
2186
- );
2187
-
2188
2703
  // src/plugins/getProfile/index.ts
2189
2704
  var getProfilePlugin = ({ context }) => {
2190
2705
  const getProfile = createFunction(async function getProfile2() {
@@ -2207,7 +2722,10 @@ var getProfilePlugin = ({ context }) => {
2207
2722
  meta: {
2208
2723
  getProfile: {
2209
2724
  categories: ["account"],
2210
- inputSchema: GetProfileSchema
2725
+ type: "item",
2726
+ itemType: "Profile",
2727
+ inputSchema: GetProfileSchema,
2728
+ outputSchema: UserProfileItemSchema
2211
2729
  }
2212
2730
  }
2213
2731
  }
@@ -2240,6 +2758,38 @@ function createDebugLogger(enabled) {
2240
2758
  console.log(`[Zapier SDK] ${message}`, data || "");
2241
2759
  };
2242
2760
  }
2761
+ function censorHeaders(headers) {
2762
+ if (!headers) return headers;
2763
+ const headersObj = new Headers(headers);
2764
+ const authKeys = ["authorization", "x-api-key"];
2765
+ for (const [key, value] of headersObj.entries()) {
2766
+ if (authKeys.some((authKey) => key.toLowerCase() === authKey)) {
2767
+ const spaceIndex = value.indexOf(" ");
2768
+ if (spaceIndex > 0 && spaceIndex < value.length - 1) {
2769
+ const prefix = value.substring(0, spaceIndex + 1);
2770
+ const token = value.substring(spaceIndex + 1);
2771
+ if (token.length > 12) {
2772
+ const start = token.substring(0, 4);
2773
+ const end = token.substring(token.length - 4);
2774
+ headersObj.set(key, `${prefix}${start}...${end}`);
2775
+ } else {
2776
+ const firstChar = token.charAt(0);
2777
+ headersObj.set(key, `${prefix}${firstChar}...`);
2778
+ }
2779
+ } else {
2780
+ if (value.length > 12) {
2781
+ const start = value.substring(0, 4);
2782
+ const end = value.substring(value.length - 4);
2783
+ headersObj.set(key, `${start}...${end}`);
2784
+ } else {
2785
+ const firstChar = value.charAt(0);
2786
+ headersObj.set(key, `${firstChar}...`);
2787
+ }
2788
+ }
2789
+ }
2790
+ }
2791
+ return Object.fromEntries(headersObj);
2792
+ }
2243
2793
  function createDebugFetch(options) {
2244
2794
  const { originalFetch, debugLog } = options;
2245
2795
  return async (input, options2) => {
@@ -2247,7 +2797,7 @@ function createDebugFetch(options) {
2247
2797
  const url = typeof input === "string" ? input : input.toString();
2248
2798
  const method = options2?.method || "GET";
2249
2799
  debugLog(`\u2192 ${method} ${url}`, {
2250
- headers: options2?.headers,
2800
+ headers: censorHeaders(options2?.headers),
2251
2801
  body: options2?.body && typeof options2.body === "string" ? (() => {
2252
2802
  try {
2253
2803
  return JSON.parse(options2.body);
@@ -2598,6 +3148,16 @@ var ZapierApiClient = class {
2598
3148
  if ("errors" in data && Array.isArray(data.errors)) {
2599
3149
  if (this.isApiErrorArray(data.errors)) {
2600
3150
  return data.errors[0].detail || data.errors[0].title;
3151
+ } else if (data.errors.length > 0) {
3152
+ const firstError = data.errors[0];
3153
+ if (typeof firstError === "string") {
3154
+ return firstError;
3155
+ }
3156
+ try {
3157
+ return JSON.stringify(firstError);
3158
+ } catch {
3159
+ return String(firstError);
3160
+ }
2601
3161
  }
2602
3162
  }
2603
3163
  }
@@ -2782,174 +3342,6 @@ var apiPlugin = (params) => {
2782
3342
  };
2783
3343
  };
2784
3344
 
2785
- // src/resolvers/appKey.ts
2786
- var appKeyResolver = {
2787
- type: "static",
2788
- inputType: "text",
2789
- placeholder: "Enter app key (e.g., 'SlackCLIAPI' or slug like 'github')"
2790
- };
2791
-
2792
- // src/resolvers/actionType.ts
2793
- var actionTypeResolver = {
2794
- type: "dynamic",
2795
- depends: ["appKey"],
2796
- fetch: async (sdk, resolvedParams) => {
2797
- const actionsResponse = await sdk.listActions({
2798
- appKey: resolvedParams.appKey
2799
- });
2800
- const types = [
2801
- ...new Set(actionsResponse.data.map((action) => action.action_type))
2802
- ];
2803
- return types.map((type) => ({ key: type, name: type }));
2804
- },
2805
- prompt: (types) => ({
2806
- type: "list",
2807
- name: "actionType",
2808
- message: "Select action type:",
2809
- choices: types.map((type) => ({
2810
- name: type.name,
2811
- value: type.key
2812
- }))
2813
- })
2814
- };
2815
-
2816
- // src/resolvers/actionKey.ts
2817
- var actionKeyResolver = {
2818
- type: "dynamic",
2819
- depends: ["appKey", "actionType"],
2820
- fetch: async (sdk, resolvedParams) => {
2821
- const actionsResponse = await sdk.listActions({
2822
- appKey: resolvedParams.appKey
2823
- });
2824
- return actionsResponse.data.filter(
2825
- (action) => action.action_type === resolvedParams.actionType
2826
- );
2827
- },
2828
- prompt: (actions) => ({
2829
- type: "list",
2830
- name: "actionKey",
2831
- message: "Select action:",
2832
- choices: actions.map((action) => ({
2833
- name: `${action.title || action.name || action.key} - ${action.description || "No description"}`,
2834
- value: action.key
2835
- }))
2836
- })
2837
- };
2838
-
2839
- // src/resolvers/authenticationId.ts
2840
- var authenticationIdResolver = {
2841
- type: "dynamic",
2842
- depends: ["appKey"],
2843
- fetch: async (sdk, resolvedParams) => {
2844
- const myAuths = await sdk.listAuthentications({
2845
- appKey: resolvedParams.appKey,
2846
- maxItems: 1e3,
2847
- owner: "me"
2848
- });
2849
- const allAuths = await sdk.listAuthentications({
2850
- appKey: resolvedParams.appKey,
2851
- maxItems: 1e3
2852
- });
2853
- const otherAuths = allAuths.data.filter(
2854
- (auth) => !myAuths.data.some((myAuth) => myAuth.id === auth.id)
2855
- );
2856
- return [...myAuths.data, ...otherAuths];
2857
- },
2858
- prompt: (auths, params) => ({
2859
- type: "list",
2860
- name: "authenticationId",
2861
- message: `Select authentication for ${params.appKey}:`,
2862
- choices: [
2863
- ...auths.map((auth) => ({
2864
- name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
2865
- value: auth.id
2866
- })),
2867
- {
2868
- name: "\u2197 Skip authentication (may fail)",
2869
- value: null
2870
- }
2871
- ]
2872
- })
2873
- };
2874
-
2875
- // src/resolvers/inputs.ts
2876
- var inputsResolver = {
2877
- type: "fields",
2878
- depends: ["appKey", "actionKey", "actionType", "authenticationId"],
2879
- fetch: async (sdk, resolvedParams) => {
2880
- const fieldsResponse = await sdk.listInputFields({
2881
- appKey: resolvedParams.appKey,
2882
- actionKey: resolvedParams.actionKey,
2883
- actionType: resolvedParams.actionType,
2884
- authenticationId: resolvedParams.authenticationId,
2885
- inputs: resolvedParams.inputs
2886
- // Pass along currently resolved inputs
2887
- });
2888
- return fieldsResponse.data;
2889
- }
2890
- };
2891
-
2892
- // src/resolvers/index.ts
2893
- var resolverRegistry = {
2894
- appKey: appKeyResolver,
2895
- actionType: actionTypeResolver,
2896
- actionKey: actionKeyResolver,
2897
- authenticationId: authenticationIdResolver,
2898
- inputs: inputsResolver
2899
- };
2900
- function getResolver(name) {
2901
- return resolverRegistry[name];
2902
- }
2903
- function getResolversForMissingParams(missingParams) {
2904
- const resolvers = {};
2905
- for (const param of missingParams) {
2906
- const resolver = resolverRegistry[param];
2907
- if (resolver) {
2908
- resolvers[param] = resolver;
2909
- }
2910
- }
2911
- return resolvers;
2912
- }
2913
- function hasResolver(paramName) {
2914
- return paramName in resolverRegistry;
2915
- }
2916
- function getResolvableParams() {
2917
- return Object.keys(resolverRegistry);
2918
- }
2919
- function getResolutionOrder(paramName, resolved = /* @__PURE__ */ new Set()) {
2920
- const resolver = getResolver(paramName);
2921
- if (!resolver || resolver.type === "static") {
2922
- return [paramName];
2923
- }
2924
- const order = [];
2925
- if ("depends" in resolver && resolver.depends) {
2926
- for (const dependency of resolver.depends) {
2927
- if (!resolved.has(dependency)) {
2928
- order.push(...getResolutionOrder(dependency, resolved));
2929
- resolved.add(dependency);
2930
- }
2931
- }
2932
- }
2933
- if (!resolved.has(paramName)) {
2934
- order.push(paramName);
2935
- resolved.add(paramName);
2936
- }
2937
- return order;
2938
- }
2939
- function getResolutionOrderForParams(paramNames) {
2940
- const resolved = /* @__PURE__ */ new Set();
2941
- const order = [];
2942
- for (const paramName of paramNames) {
2943
- const paramOrder = getResolutionOrder(paramName, resolved);
2944
- for (const param of paramOrder) {
2945
- if (!order.includes(param)) {
2946
- order.push(param);
2947
- }
2948
- }
2949
- }
2950
- return order;
2951
- }
2952
-
2953
3345
  // src/plugins/registry/index.ts
2954
3346
  var registryPlugin = ({ sdk, context }) => {
2955
3347
  const metaKeys = Object.keys(context.meta || {});
@@ -2979,10 +3371,16 @@ var registryPlugin = ({ sdk, context }) => {
2979
3371
  }
2980
3372
  };
2981
3373
  const functions = metaKeys.filter((key) => typeof sdk[key] === "function").map((key) => {
3374
+ const meta = context.meta[key];
2982
3375
  return {
2983
- ...context.meta[key],
2984
- categories: context.meta[key].categories || [],
2985
- name: key
3376
+ name: key,
3377
+ type: meta.type,
3378
+ itemType: meta.itemType,
3379
+ returnType: meta.returnType,
3380
+ inputSchema: meta.inputSchema,
3381
+ outputSchema: meta.outputSchema,
3382
+ categories: meta.categories || [],
3383
+ resolvers: meta.resolvers
2986
3384
  };
2987
3385
  }).sort((a, b) => a.name.localeCompare(b.name));
2988
3386
  const knownCategories = Object.keys(categoryDefinitions);
@@ -3016,52 +3414,43 @@ var registryPlugin = ({ sdk, context }) => {
3016
3414
  getRegistry
3017
3415
  };
3018
3416
  };
3019
- var InputFieldChoiceItemSchema = withFormatter(
3020
- z.object({
3021
- key: z.string().optional().describe("Unique key/value for the choice"),
3022
- label: z.string().optional().describe("Human readable label for the choice"),
3023
- sample: z.string().optional().describe("Sample value for the choice"),
3024
- value: z.string().optional().describe("Value to be submitted when selected")
3025
- }),
3026
- {
3027
- format: (item) => {
3028
- const title = item.label || item.key || "Choice";
3029
- const subtitle = item.label && item.key && item.label !== item.key ? `(${item.key})` : void 0;
3030
- const details = [];
3031
- if (item.sample && item.sample !== item.key) {
3032
- details.push({ text: `Sample: ${item.sample}`, style: "dim" });
3033
- }
3034
- if (item.value && item.value !== item.key) {
3035
- details.push({ text: `Value: ${item.value}`, style: "normal" });
3036
- }
3037
- return {
3038
- title,
3039
- subtitle,
3040
- details
3041
- };
3417
+ var InputFieldChoiceItemSchema = withFormatter(NeedChoicesSchema, {
3418
+ format: (item) => {
3419
+ const title = item.label || item.key || "Choice";
3420
+ const details = [];
3421
+ if (item.label && item.key && item.label !== item.key) {
3422
+ details.push({ text: `Key: ${item.key}`, style: "dim" });
3423
+ }
3424
+ if (item.sample && item.sample !== item.key) {
3425
+ details.push({ text: `Sample: ${item.sample}`, style: "dim" });
3426
+ }
3427
+ if (item.value && item.value !== item.key) {
3428
+ details.push({ text: `Value: ${item.value}`, style: "normal" });
3042
3429
  }
3430
+ return {
3431
+ title,
3432
+ key: item.key,
3433
+ details
3434
+ };
3043
3435
  }
3044
- );
3045
- var ListInputFieldChoicesSchema = withOutputSchema(
3046
- z.object({
3047
- // Required action identification
3048
- appKey: AppKeyPropertySchema,
3049
- actionType: ActionTypePropertySchema,
3050
- actionKey: ActionKeyPropertySchema,
3051
- // Input field specification
3052
- inputFieldKey: z.string().min(1).describe("Input field key to get choices for."),
3053
- // Common parameters
3054
- authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
3055
- inputs: InputsPropertySchema.optional().describe(
3056
- "Current input values that may affect available choices"
3057
- ),
3058
- page: z.number().int().min(0).optional().describe("Page number for paginated results"),
3059
- // Pagination options (SDK-level)
3060
- pageSize: z.number().min(1).optional().describe("Number of choices per page"),
3061
- maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
3062
- }).describe("Get the available choices for a dynamic dropdown input field"),
3063
- InputFieldChoiceItemSchema
3064
- );
3436
+ });
3437
+ var ListInputFieldChoicesSchema = z.object({
3438
+ // Required action identification
3439
+ appKey: AppKeyPropertySchema,
3440
+ actionType: ActionTypePropertySchema,
3441
+ actionKey: ActionKeyPropertySchema,
3442
+ // Input field specification
3443
+ inputFieldKey: z.string().min(1).describe("Input field key to get choices for."),
3444
+ // Common parameters
3445
+ authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
3446
+ inputs: InputsPropertySchema.optional().describe(
3447
+ "Current input values that may affect available choices"
3448
+ ),
3449
+ page: z.number().int().min(0).optional().describe("Page number for paginated results"),
3450
+ // Pagination options (SDK-level)
3451
+ pageSize: z.number().min(1).optional().describe("Number of choices per page"),
3452
+ maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
3453
+ }).describe("Get the available choices for a dynamic dropdown input field");
3065
3454
 
3066
3455
  // src/plugins/listInputFieldChoices/index.ts
3067
3456
  function transformNeedChoicesToInputFieldChoiceItem(choice) {
@@ -3115,7 +3504,7 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
3115
3504
  transformNeedChoicesToInputFieldChoiceItem
3116
3505
  );
3117
3506
  let nextCursor;
3118
- if (choicesData.next_page !== void 0) {
3507
+ if (choicesData.next_page != null) {
3119
3508
  nextCursor = choicesData.next_page.toString();
3120
3509
  } else if (choicesData.links?.next) {
3121
3510
  try {
@@ -3139,7 +3528,18 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
3139
3528
  meta: {
3140
3529
  listInputFieldChoices: {
3141
3530
  categories: ["action"],
3142
- inputSchema: ListInputFieldChoicesSchema
3531
+ type: "list",
3532
+ itemType: "InputFieldChoice",
3533
+ inputSchema: ListInputFieldChoicesSchema,
3534
+ outputSchema: InputFieldChoiceItemSchema,
3535
+ resolvers: {
3536
+ appKey: appKeyResolver,
3537
+ actionType: actionTypeResolver,
3538
+ actionKey: actionKeyResolver,
3539
+ authenticationId: authenticationIdResolver,
3540
+ inputFieldKey: inputFieldKeyResolver,
3541
+ inputs: inputsAllOptionalResolver
3542
+ }
3143
3543
  }
3144
3544
  }
3145
3545
  }
@@ -3195,10 +3595,10 @@ function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} })
3195
3595
  };
3196
3596
  }
3197
3597
  function createZapierSdkWithoutRegistry(options = {}) {
3198
- return createSdk(options).addPlugin(apiPlugin).addPlugin(listAppsPlugin).addPlugin(manifestPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(lockVersionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(requestPlugin).addPlugin(fetchPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
3598
+ return createSdk(options).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(requestPlugin).addPlugin(fetchPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
3199
3599
  }
3200
3600
  function createZapierSdk(options = {}) {
3201
3601
  return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
3202
3602
  }
3203
3603
 
3204
- export { ActionKeyPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, 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, findUniqueAuthenticationPlugin, formatErrorMessage, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getProfilePlugin, getResolutionOrder, getResolutionOrderForParams, getResolvableParams, getResolver, getResolversForMissingParams, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, hasResolver, inputsResolver, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, loadManifestFromFile, lockVersionPlugin, manifestPlugin, registryPlugin, requestPlugin, resolverRegistry, runActionPlugin };
3604
+ 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 };