@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.cjs CHANGED
@@ -1,25 +1,26 @@
1
1
  'use strict';
2
2
 
3
3
  var zod = require('zod');
4
- var fs = require('fs');
5
- var path = require('path');
6
4
  var promises = require('timers/promises');
7
5
 
8
6
  // src/types/properties.ts
9
7
  function withFormatter(schema, formatMeta) {
10
- schema._def.formatMeta = formatMeta;
8
+ Object.assign(schema._def, {
9
+ formatMeta
10
+ });
11
11
  return schema;
12
12
  }
13
- function withOutputSchema(inputSchema, outputSchema) {
14
- inputSchema._def.outputSchema = outputSchema;
15
- return inputSchema;
16
- }
17
13
  function withPositional(schema) {
18
- schema._def.positionalMeta = { positional: true };
14
+ Object.assign(schema._def, {
15
+ positionalMeta: { positional: true }
16
+ });
19
17
  return schema;
20
18
  }
19
+ function schemaHasPositionalMeta(schema) {
20
+ return "positionalMeta" in schema._def;
21
+ }
21
22
  function isPositional(schema) {
22
- if (schema._def.positionalMeta?.positional) {
23
+ if (schemaHasPositionalMeta(schema) && schema._def.positionalMeta?.positional) {
23
24
  return true;
24
25
  }
25
26
  if (schema instanceof zod.z.ZodOptional) {
@@ -606,256 +607,14 @@ function createPaginatedFunction(coreFn, schema) {
606
607
  };
607
608
  return namedFunctions[functionName];
608
609
  }
609
- var AppItemSchema = withFormatter(
610
- zod.z.object({
611
- // Essential properties only
612
- title: zod.z.string(),
613
- // Mapped from name
614
- key: zod.z.string(),
615
- // Mapped from selected_api
616
- current_implementation_id: zod.z.string(),
617
- // From id, keeps the full version
618
- version: zod.z.string().optional(),
619
- // Extracted from implementation ID
620
- description: zod.z.string().optional(),
621
- slug: zod.z.string().optional()
622
- }),
623
- {
624
- format: (item) => {
625
- return {
626
- title: item.title,
627
- subtitle: `(${item.key})`,
628
- details: []
629
- };
630
- }
631
- }
632
- );
633
-
634
- // src/plugins/listApps/schemas.ts
635
- var ListAppsSchema = withOutputSchema(
636
- zod.z.object({
637
- appKeys: zod.z.array(zod.z.string()).optional().describe(
638
- "Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"
639
- ),
640
- search: zod.z.string().optional().describe("Search for apps by name"),
641
- pageSize: zod.z.number().min(1).optional().describe("Number of apps per page"),
642
- maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
643
- }).describe("List all available apps with optional filtering"),
644
- AppItemSchema
645
- );
646
-
647
- // src/utils/domain-utils.ts
648
- function splitVersionedKey(versionedKey) {
649
- const parts = versionedKey.split("@");
650
- if (parts.length >= 2) {
651
- const baseKey = parts[0];
652
- const version = parts.slice(1).join("@");
653
- return [baseKey, version];
654
- }
655
- return [versionedKey, void 0];
656
- }
657
- function normalizeImplementationToAppItem(implementation) {
658
- const [selectedApi, appVersion] = implementation.selected_api ? splitVersionedKey(implementation.selected_api) : [implementation.selected_api || "", void 0];
659
- return {
660
- title: implementation.name || selectedApi,
661
- key: selectedApi,
662
- current_implementation_id: implementation.selected_api || "",
663
- version: appVersion
664
- // Extract version separately
665
- };
666
- }
667
- function normalizeImplementationMetaToAppItem(implementationMeta) {
668
- const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
669
- return {
670
- title: implementationMeta.name,
671
- key: selectedApi,
672
- current_implementation_id: implementationMeta.id,
673
- // Keep the full versioned ID
674
- version: appVersion,
675
- // Extract version separately
676
- slug: implementationMeta.slug
677
- };
678
- }
679
- function normalizeAuthenticationItem(auth, options = {}) {
680
- let appKey = options.app_key;
681
- let version = options.version;
682
- if (auth.selected_api) {
683
- const [extractedAppKey, extractedVersion] = splitVersionedKey(
684
- auth.selected_api
685
- );
686
- if (!appKey) {
687
- appKey = extractedAppKey;
688
- }
689
- if (!version) {
690
- version = extractedVersion;
691
- }
692
- }
693
- const {
694
- selected_api: selectedApi,
695
- customuser_id: userId,
696
- ...restOfAuth
697
- } = auth;
698
- return {
699
- ...restOfAuth,
700
- // Pass through all other API response fields except selected_api
701
- implementation_id: selectedApi,
702
- // Rename selected_api to implementation_id
703
- title: auth.title || auth.label || void 0,
704
- // Coerce title from label if missing
705
- is_expired: auth.is_stale,
706
- // Map is_stale to is_expired
707
- expired_at: auth.marked_stale_at,
708
- // Map marked_stale_at to expired_at
709
- app_key: appKey,
710
- // App key from implementations endpoint or parsed from selected_api
711
- version,
712
- // Version from selected_api or provided
713
- user_id: userId
714
- // Map customuser_id to user_id
715
- };
716
- }
717
- function normalizeActionItem(action) {
718
- const { name, type, selected_api: appKey, ...restOfAction } = action;
719
- return {
720
- ...restOfAction,
721
- app_key: appKey || "",
722
- action_type: type,
723
- title: name,
724
- // Map name to title
725
- type: "action"
726
- };
727
- }
728
- function groupVersionedAppKeysByType(appKeys) {
729
- const result = {
730
- selectedApi: [],
731
- slug: []
732
- };
733
- const seenSelectedApi = /* @__PURE__ */ new Set();
734
- const seenSlugs = /* @__PURE__ */ new Set();
735
- for (const key of appKeys) {
736
- const [keyWithoutVersion, version] = splitVersionedKey(key);
737
- const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
738
- if (uuidRegex.test(keyWithoutVersion)) {
739
- throw new Error(
740
- `UUID app keys are not supported. Use app slug or implementation ID instead of: ${key}`
741
- );
742
- }
743
- if (isSnakeCasedSlug(keyWithoutVersion)) {
744
- const dashified = dashifySnakeCasedSlug(keyWithoutVersion);
745
- const slugWithVersion = version ? `${dashified}@${version}` : dashified;
746
- if (!seenSlugs.has(slugWithVersion)) {
747
- seenSlugs.add(slugWithVersion);
748
- result.slug.push(slugWithVersion);
749
- }
750
- continue;
751
- }
752
- if (keyWithoutVersion.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)) {
753
- seenSlugs.add(key);
754
- result.slug.push(key);
755
- continue;
756
- }
757
- if (!seenSelectedApi.has(key)) {
758
- seenSelectedApi.add(key);
759
- result.selectedApi.push(key);
760
- }
761
- }
762
- return result;
763
- }
764
- function groupAppKeysByType(appKeys) {
765
- const grouped = groupVersionedAppKeysByType(appKeys);
766
- return {
767
- selectedApi: [
768
- ...new Set(grouped.selectedApi.map((key) => key.split("@")[0]))
769
- ],
770
- slug: [...new Set(grouped.slug.map((key) => key.split("@")[0]))]
771
- };
772
- }
773
- function isSnakeCasedSlug(slug) {
774
- if (slug.match(/^_[0-9]/)) {
775
- slug = slug.slice(1);
776
- }
777
- return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
778
- }
779
- function dashifySnakeCasedSlug(slug) {
780
- if (!isSnakeCasedSlug(slug)) {
781
- return slug;
782
- }
783
- if (slug.startsWith("_")) {
784
- slug = slug.slice(1);
785
- }
786
- return slug.replace(/_/g, "-");
787
- }
788
-
789
- // src/plugins/listApps/index.ts
790
- var listAppsPlugin = ({ context }) => {
791
- const listApps = createPaginatedFunction(async function listAppsPage(options) {
792
- const api = context.api;
793
- const opts = options;
794
- const appKeys = [...opts.appKeys ?? []].map(
795
- (key) => splitVersionedKey(key)[0]
796
- );
797
- if (opts.search) {
798
- const searchParams2 = {};
799
- searchParams2.term = opts.search;
800
- const searchEnvelope = await api.get(
801
- "/api/v4/implementations-meta/search/",
802
- {
803
- searchParams: searchParams2
804
- }
805
- );
806
- const implementations = searchEnvelope.results.map(
807
- normalizeImplementationMetaToAppItem
808
- );
809
- const appKeysSet = new Set(appKeys);
810
- for (const implementation of implementations) {
811
- if (!appKeysSet.has(implementation.key)) {
812
- appKeysSet.add(implementation.key);
813
- appKeys.push(implementation.key);
814
- }
815
- }
816
- }
817
- const searchParams = {};
818
- if (opts.pageSize) {
819
- searchParams.limit = opts.pageSize.toString();
820
- }
821
- searchParams.latest_only = "true";
822
- if (opts.cursor) {
823
- searchParams.offset = opts.cursor;
824
- }
825
- if (appKeys.length > 0) {
826
- const groupedAppKeys = groupAppKeysByType(appKeys);
827
- if (groupedAppKeys.selectedApi.length > 0) {
828
- searchParams.selected_apis = groupedAppKeys.selectedApi.join(",");
829
- }
830
- if (groupedAppKeys.slug.length > 0) {
831
- searchParams.slugs = groupedAppKeys.slug.join(",");
832
- }
833
- }
834
- const implementationsEnvelope = await api.get(
835
- "/api/v4/implementations-meta/lookup/",
836
- {
837
- searchParams
838
- }
839
- );
840
- return {
841
- data: implementationsEnvelope.results.map(
842
- normalizeImplementationMetaToAppItem
843
- ),
844
- nextCursor: extractCursor(implementationsEnvelope)
845
- };
846
- }, ListAppsSchema);
847
- return {
848
- listApps,
849
- context: {
850
- meta: {
851
- listApps: {
852
- categories: ["app"],
853
- inputSchema: ListAppsSchema
854
- }
855
- }
856
- }
857
- };
858
- };
610
+ var ListAppsSchema = zod.z.object({
611
+ appKeys: zod.z.array(zod.z.string()).optional().describe(
612
+ "Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"
613
+ ),
614
+ search: zod.z.string().optional().describe("Search for apps by name"),
615
+ pageSize: zod.z.number().min(1).optional().describe("Number of apps per page"),
616
+ maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
617
+ }).describe("List all available apps with optional filtering");
859
618
  var NeedChoicesSchema = zod.z.object({
860
619
  key: zod.z.string().optional(),
861
620
  label: zod.z.string().optional(),
@@ -955,7 +714,7 @@ zod.z.object({
955
714
  choices: zod.z.array(ChoiceSchema).optional()
956
715
  });
957
716
  zod.z.object({
958
- data: zod.z.array(zod.z.any())
717
+ data: zod.z.array(zod.z.unknown())
959
718
  });
960
719
  var ActionFieldChoiceSchema = zod.z.object({
961
720
  value: zod.z.union([zod.z.string(), zod.z.number()]),
@@ -1045,9 +804,9 @@ var UserProfileSchema = zod.z.object({
1045
804
  enable_totp_2fa: zod.z.boolean(),
1046
805
  viewed_help: zod.z.record(zod.z.boolean()),
1047
806
  show_editor_migration_mesaging: zod.z.boolean(),
1048
- switches: zod.z.record(zod.z.any()),
1049
- organizations: zod.z.array(zod.z.any().nullable()),
1050
- primary_organization: zod.z.any().nullable(),
807
+ switches: zod.z.record(zod.z.unknown()),
808
+ organizations: zod.z.array(zod.z.record(zod.z.unknown()).nullable()),
809
+ primary_organization: zod.z.record(zod.z.unknown()).nullable(),
1051
810
  has_active_zaps: zod.z.boolean(),
1052
811
  has_google_sso: zod.z.boolean(),
1053
812
  auth_realm: zod.z.string(),
@@ -1063,8 +822,8 @@ zod.z.object({
1063
822
  api_docs_url: zod.z.string().nullable().optional(),
1064
823
  app_profile_url: zod.z.string(),
1065
824
  banner: zod.z.string().optional(),
1066
- categories: zod.z.array(zod.z.any()).optional(),
1067
- // TODO: Define proper service_category type
825
+ categories: zod.z.array(zod.z.string()).optional(),
826
+ // Service category names
1068
827
  canonical_id: zod.z.string().optional(),
1069
828
  current_implementation_id: zod.z.string(),
1070
829
  days_since_last_update: zod.z.string().optional(),
@@ -1115,7 +874,7 @@ zod.z.object({
1115
874
  action: zod.z.string(),
1116
875
  type_of: zod.z.string(),
1117
876
  authentication_id: zod.z.number().optional(),
1118
- params: zod.z.record(zod.z.any()).optional()
877
+ params: zod.z.record(zod.z.unknown()).optional()
1119
878
  });
1120
879
  zod.z.object({
1121
880
  success: zod.z.boolean(),
@@ -1151,18 +910,11 @@ zod.z.object({
1151
910
  });
1152
911
  var ImplementationMetaSchema = zod.z.object({
1153
912
  id: zod.z.string(),
1154
- // e.g. "ZapierFormatterCLIAPI@1.0.7"
913
+ // e.g. "100HiresCLIAPI@1.2.1"
1155
914
  name: zod.z.string(),
1156
915
  slug: zod.z.string(),
1157
- images: zod.z.object({
1158
- url_16x16: zod.z.string().optional(),
1159
- url_32x32: zod.z.string().optional(),
1160
- url_64x64: zod.z.string().optional(),
1161
- url_128x128: zod.z.string().optional()
1162
- }).optional(),
1163
- // Include other fields for completeness but we'll only use what we need
1164
- ageInDays: zod.z.union([zod.z.string(), zod.z.number()]).optional(),
1165
- authType: zod.z.string().nullable().optional(),
916
+ age_in_days: zod.z.number().optional(),
917
+ auth_type: zod.z.string().optional(),
1166
918
  banner: zod.z.string().optional(),
1167
919
  categories: zod.z.array(
1168
920
  zod.z.object({
@@ -1171,18 +923,45 @@ var ImplementationMetaSchema = zod.z.object({
1171
923
  slug: zod.z.string()
1172
924
  })
1173
925
  ).optional(),
1174
- isBeta: zod.z.boolean().optional(),
1175
- isBuiltIn: zod.z.boolean().optional(),
1176
- isDeprecated: zod.z.boolean().optional(),
1177
- isFeatured: zod.z.boolean().optional(),
1178
- isHidden: zod.z.boolean().optional(),
1179
- isInvite: zod.z.boolean().optional(),
1180
- isPremium: zod.z.boolean().optional(),
1181
- isPublic: zod.z.boolean().optional(),
1182
- isUpcoming: zod.z.boolean().optional(),
926
+ images: zod.z.object({
927
+ url_16x16: zod.z.string().optional(),
928
+ url_32x32: zod.z.string().optional(),
929
+ url_64x64: zod.z.string().optional(),
930
+ url_128x128: zod.z.string().optional()
931
+ }).optional(),
1183
932
  popularity: zod.z.number().optional(),
1184
- apiDocsUrl: zod.z.string().optional(),
1185
- classification: zod.z.string().optional()
933
+ has_filters: zod.z.boolean().optional(),
934
+ has_reads: zod.z.boolean().optional(),
935
+ has_searches: zod.z.boolean().optional(),
936
+ has_searches_or_writes: zod.z.boolean().optional(),
937
+ has_upfront_fields: zod.z.boolean().optional(),
938
+ has_writes: zod.z.boolean().optional(),
939
+ is_beta: zod.z.boolean().optional(),
940
+ is_built_in: zod.z.boolean().optional(),
941
+ is_deprecated: zod.z.boolean().optional(),
942
+ is_featured: zod.z.boolean().optional(),
943
+ is_hidden: zod.z.boolean().optional(),
944
+ is_invite: zod.z.boolean().optional(),
945
+ is_premium: zod.z.boolean().optional(),
946
+ is_public: zod.z.boolean().optional(),
947
+ is_upcoming: zod.z.boolean().optional(),
948
+ version: zod.z.string().optional(),
949
+ visibility: zod.z.string().optional(),
950
+ actions: zod.z.object({
951
+ read: zod.z.number().optional(),
952
+ read_bulk: zod.z.number().optional(),
953
+ write: zod.z.number().optional(),
954
+ search: zod.z.number().optional(),
955
+ search_or_write: zod.z.number().optional(),
956
+ search_and_write: zod.z.number().optional(),
957
+ filter: zod.z.number().optional()
958
+ }).optional(),
959
+ description: zod.z.string().optional(),
960
+ primary_color: zod.z.string().optional(),
961
+ secondary_color: zod.z.string().optional(),
962
+ classification: zod.z.string().optional(),
963
+ api_docs_url: zod.z.string().optional(),
964
+ image: zod.z.string().optional()
1186
965
  });
1187
966
  zod.z.object({
1188
967
  count: zod.z.number(),
@@ -1204,7 +983,7 @@ zod.z.object({
1204
983
  authentication_id: zod.z.number().optional().describe(
1205
984
  "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)."
1206
985
  ),
1207
- params: zod.z.record(zod.z.any()).optional().describe(
986
+ params: zod.z.record(zod.z.unknown()).optional().describe(
1208
987
  "Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action."
1209
988
  ),
1210
989
  page: zod.z.number().optional().default(0),
@@ -1227,73 +1006,456 @@ zod.z.object({
1227
1006
  links: NeedChoicesResponseLinksSchema.optional()
1228
1007
  });
1229
1008
 
1230
- // src/schemas/Action.ts
1231
- var ActionItemSchema = withFormatter(
1232
- ActionSchema.omit({ type: true, name: true }).extend({
1233
- app_key: zod.z.string(),
1234
- // Mapped from selected_api
1235
- action_type: ActionSchema.shape.type,
1236
- // Mapped from original 'type' field
1009
+ // src/schemas/App.ts
1010
+ var AppItemSchema = withFormatter(
1011
+ ImplementationMetaSchema.omit({ name: true, id: true }).extend({
1237
1012
  title: zod.z.string(),
1238
- // Mapped from original 'name' field
1239
- type: zod.z.literal("action")
1240
- // Fixed type identifier
1013
+ // Mapped from name
1014
+ key: zod.z.string(),
1015
+ // Extracted from id (base part without version)
1016
+ implementation_id: zod.z.string()
1017
+ // Mapped from id (full versioned ID)
1241
1018
  }),
1242
1019
  {
1243
1020
  format: (item) => {
1244
- const details = [];
1245
- details.push({
1246
- text: `Type: ${item.action_type}`,
1247
- style: "accent"
1248
- });
1249
- if (item.app_key) {
1250
- details.push({
1251
- text: `App: ${item.app_key}`,
1252
- style: "normal"
1253
- });
1254
- }
1255
- if (item.description) {
1256
- details.push({ text: item.description, style: "dim" });
1257
- }
1258
1021
  return {
1259
- title: item.title || item.name || item.key,
1260
- subtitle: `(${item.key})`,
1261
- details
1022
+ title: item.title,
1023
+ key: item.key,
1024
+ description: item.description,
1025
+ details: []
1262
1026
  };
1263
1027
  }
1264
1028
  }
1265
1029
  );
1266
1030
 
1267
- // src/plugins/listActions/schemas.ts
1268
- var ListActionsSchema = withOutputSchema(
1269
- zod.z.object({
1270
- appKey: AppKeyPropertySchema.describe(
1271
- "App key of actions to list (e.g., 'SlackCLIAPI')"
1272
- ),
1273
- actionType: ActionTypePropertySchema.optional().describe(
1274
- "Filter actions by type"
1275
- ),
1276
- pageSize: zod.z.number().min(1).optional().describe("Number of actions per page"),
1277
- maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
1278
- }).describe("List all actions for a specific app"),
1279
- ActionItemSchema
1280
- );
1281
-
1282
- // src/plugins/listActions/index.ts
1283
- var listActionsPlugin = ({ context }) => {
1284
- const listActions = createPaginatedFunction(async function listActionsPage(options) {
1285
- const { api, getVersionedImplementationId } = context;
1286
- const selectedApi = await getVersionedImplementationId(options.appKey);
1287
- if (!selectedApi) {
1288
- throw new ZapierConfigurationError(
1289
- "No current_implementation_id found for app",
1290
- { configType: "current_implementation_id" }
1291
- );
1292
- }
1293
- const searchParams = {
1294
- global: "true",
1295
- public_only: "true",
1296
- selected_apis: selectedApi
1031
+ // src/utils/domain-utils.ts
1032
+ function splitVersionedKey(versionedKey) {
1033
+ const parts = versionedKey.split("@");
1034
+ if (parts.length >= 2) {
1035
+ const baseKey = parts[0];
1036
+ const version = parts.slice(1).join("@");
1037
+ return [baseKey, version];
1038
+ }
1039
+ return [versionedKey, void 0];
1040
+ }
1041
+ function normalizeImplementationMetaToAppItem(implementationMeta) {
1042
+ const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
1043
+ const { id, name, ...restOfImplementationMeta } = implementationMeta;
1044
+ return {
1045
+ // Pass through all ImplementationMeta fields except id and name
1046
+ ...restOfImplementationMeta,
1047
+ // Transform key fields
1048
+ title: name,
1049
+ key: selectedApi,
1050
+ implementation_id: id,
1051
+ // Keep the full versioned ID
1052
+ version: appVersion
1053
+ // Extract version separately
1054
+ };
1055
+ }
1056
+ function normalizeAuthenticationItem(auth, options = {}) {
1057
+ let appKey = options.app_key;
1058
+ let version = options.version;
1059
+ if (auth.selected_api) {
1060
+ const [extractedAppKey, extractedVersion] = splitVersionedKey(
1061
+ auth.selected_api
1062
+ );
1063
+ if (!appKey) {
1064
+ appKey = extractedAppKey;
1065
+ }
1066
+ if (!version) {
1067
+ version = extractedVersion;
1068
+ }
1069
+ }
1070
+ const {
1071
+ selected_api: selectedApi,
1072
+ customuser_id: userId,
1073
+ ...restOfAuth
1074
+ } = auth;
1075
+ return {
1076
+ ...restOfAuth,
1077
+ // Pass through all other API response fields except selected_api
1078
+ implementation_id: selectedApi,
1079
+ // Rename selected_api to implementation_id
1080
+ title: auth.title || auth.label || void 0,
1081
+ // Coerce title from label if missing
1082
+ is_expired: auth.is_stale,
1083
+ // Map is_stale to is_expired
1084
+ expired_at: auth.marked_stale_at,
1085
+ // Map marked_stale_at to expired_at
1086
+ app_key: appKey,
1087
+ // App key from implementations endpoint or parsed from selected_api
1088
+ version,
1089
+ // Version from selected_api or provided
1090
+ user_id: userId
1091
+ // Map customuser_id to user_id
1092
+ };
1093
+ }
1094
+ function normalizeActionItem(action) {
1095
+ const { name, type, selected_api: appKey, ...restOfAction } = action;
1096
+ return {
1097
+ ...restOfAction,
1098
+ app_key: appKey || "",
1099
+ action_type: type,
1100
+ title: name,
1101
+ // Map name to title
1102
+ type: "action"
1103
+ };
1104
+ }
1105
+ function isSlug(slug) {
1106
+ return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
1107
+ }
1108
+ function isSnakeCasedSlug(slug) {
1109
+ if (slug.match(/^_[0-9]/)) {
1110
+ slug = slug.slice(1);
1111
+ }
1112
+ return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
1113
+ }
1114
+ function dashifySnakeCasedSlug(slug) {
1115
+ if (!isSnakeCasedSlug(slug)) {
1116
+ return slug;
1117
+ }
1118
+ if (slug.startsWith("_")) {
1119
+ slug = slug.slice(1);
1120
+ }
1121
+ return slug.replace(/_/g, "-");
1122
+ }
1123
+ function isUuid(appKey) {
1124
+ return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
1125
+ appKey
1126
+ );
1127
+ }
1128
+ function toAppLocator(appKey) {
1129
+ const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
1130
+ if (isUuid(appKeyWithoutVersion)) {
1131
+ throw new Error(
1132
+ `UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`
1133
+ );
1134
+ }
1135
+ const slug = isSlug(appKeyWithoutVersion) ? appKeyWithoutVersion : isSnakeCasedSlug(appKeyWithoutVersion) ? dashifySnakeCasedSlug(appKeyWithoutVersion) : void 0;
1136
+ return {
1137
+ lookupAppKey: appKeyWithoutVersion,
1138
+ slug,
1139
+ implementationName: slug ? void 0 : appKeyWithoutVersion,
1140
+ version
1141
+ };
1142
+ }
1143
+ function isResolvedAppLocator(appLocator) {
1144
+ return !!appLocator.implementationName;
1145
+ }
1146
+ function toImplementationId(appLocator) {
1147
+ return `${appLocator.implementationName}@${appLocator.version || "latest"}`;
1148
+ }
1149
+
1150
+ // src/plugins/listApps/index.ts
1151
+ var listAppsPlugin = ({ context }) => {
1152
+ const listApps = createPaginatedFunction(async function listAppsPage(options) {
1153
+ const api = context.api;
1154
+ const opts = options;
1155
+ const appLocators = await context.resolveAppKeys({
1156
+ appKeys: [...opts.appKeys ?? []]
1157
+ });
1158
+ const implementationNameToLocator = {};
1159
+ for (const locator of appLocators) {
1160
+ implementationNameToLocator[locator.implementationName] = [
1161
+ ...implementationNameToLocator[locator.implementationName] ?? [],
1162
+ locator
1163
+ ];
1164
+ }
1165
+ const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
1166
+ if (duplicatedLookupAppKeys.length > 0) {
1167
+ throw new Error(
1168
+ `Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
1169
+ );
1170
+ }
1171
+ if (opts.search) {
1172
+ const searchParams2 = {};
1173
+ searchParams2.term = opts.search;
1174
+ const searchEnvelope = await api.get(
1175
+ "/api/v4/implementations-meta/search/",
1176
+ {
1177
+ searchParams: searchParams2
1178
+ }
1179
+ );
1180
+ const implementations = searchEnvelope.results.map(
1181
+ normalizeImplementationMetaToAppItem
1182
+ );
1183
+ const implementationNameSet = new Set(
1184
+ appLocators.map((locator) => locator.implementationName)
1185
+ );
1186
+ for (const implementation of implementations) {
1187
+ const [implementationName] = splitVersionedKey(implementation.key);
1188
+ if (!implementationNameSet.has(implementationName)) {
1189
+ implementationNameSet.add(implementationName);
1190
+ appLocators.push({
1191
+ ...toAppLocator(implementation.key),
1192
+ implementationName
1193
+ });
1194
+ }
1195
+ }
1196
+ }
1197
+ const searchParams = {};
1198
+ if (opts.pageSize) {
1199
+ searchParams.limit = opts.pageSize.toString();
1200
+ }
1201
+ if (appLocators.length === 0) {
1202
+ searchParams.latest_only = "true";
1203
+ }
1204
+ if (opts.cursor) {
1205
+ searchParams.offset = opts.cursor;
1206
+ }
1207
+ searchParams.selected_apis = appLocators.map((locator) => toImplementationId(locator)).join(",");
1208
+ const implementationsEnvelope = await api.get(
1209
+ "/api/v4/implementations-meta/lookup/",
1210
+ {
1211
+ searchParams
1212
+ }
1213
+ );
1214
+ return {
1215
+ data: implementationsEnvelope.results.map(
1216
+ normalizeImplementationMetaToAppItem
1217
+ ),
1218
+ nextCursor: extractCursor(implementationsEnvelope)
1219
+ };
1220
+ }, ListAppsSchema);
1221
+ return {
1222
+ listApps,
1223
+ context: {
1224
+ meta: {
1225
+ listApps: {
1226
+ categories: ["app"],
1227
+ type: "list",
1228
+ itemType: "App",
1229
+ inputSchema: ListAppsSchema,
1230
+ outputSchema: AppItemSchema
1231
+ }
1232
+ }
1233
+ }
1234
+ };
1235
+ };
1236
+ var ListActionsSchema = zod.z.object({
1237
+ appKey: AppKeyPropertySchema.describe(
1238
+ "App key of actions to list (e.g., 'SlackCLIAPI')"
1239
+ ),
1240
+ actionType: ActionTypePropertySchema.optional().describe(
1241
+ "Filter actions by type"
1242
+ ),
1243
+ pageSize: zod.z.number().min(1).optional().describe("Number of actions per page"),
1244
+ maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
1245
+ }).describe("List all actions for a specific app");
1246
+ var ActionItemSchema = withFormatter(
1247
+ ActionSchema.omit({ type: true, name: true }).extend({
1248
+ app_key: zod.z.string(),
1249
+ // Mapped from selected_api
1250
+ action_type: ActionSchema.shape.type,
1251
+ // Mapped from original 'type' field
1252
+ title: zod.z.string(),
1253
+ // Mapped from original 'name' field
1254
+ type: zod.z.literal("action")
1255
+ // Fixed type identifier
1256
+ }),
1257
+ {
1258
+ format: (item) => {
1259
+ const details = [];
1260
+ details.push({
1261
+ text: `Type: ${item.action_type}`,
1262
+ style: "accent"
1263
+ });
1264
+ if (item.app_key) {
1265
+ details.push({
1266
+ text: `App: ${item.app_key}`,
1267
+ style: "normal"
1268
+ });
1269
+ }
1270
+ if (item.description) {
1271
+ details.push({
1272
+ text: item.description,
1273
+ style: "dim"
1274
+ });
1275
+ }
1276
+ return {
1277
+ title: item.title || item.key,
1278
+ id: item.id,
1279
+ key: item.key,
1280
+ description: item.description,
1281
+ details
1282
+ };
1283
+ }
1284
+ }
1285
+ );
1286
+
1287
+ // src/resolvers/appKey.ts
1288
+ var appKeyResolver = {
1289
+ type: "static",
1290
+ inputType: "text",
1291
+ placeholder: "Enter app key (e.g., 'SlackCLIAPI' or slug like 'github')"
1292
+ };
1293
+
1294
+ // src/resolvers/actionType.ts
1295
+ var actionTypeResolver = {
1296
+ type: "dynamic",
1297
+ depends: ["appKey"],
1298
+ fetch: async (sdk, resolvedParams) => {
1299
+ const actionsResponse = await sdk.listActions({
1300
+ appKey: resolvedParams.appKey
1301
+ });
1302
+ const types = [
1303
+ ...new Set(actionsResponse.data.map((action) => action.action_type))
1304
+ ];
1305
+ return types.map((type) => ({ key: type, name: type }));
1306
+ },
1307
+ prompt: (types) => ({
1308
+ type: "list",
1309
+ name: "actionType",
1310
+ message: "Select action type:",
1311
+ choices: types.map((type) => ({
1312
+ name: type.name,
1313
+ value: type.key
1314
+ }))
1315
+ })
1316
+ };
1317
+
1318
+ // src/resolvers/actionKey.ts
1319
+ var actionKeyResolver = {
1320
+ type: "dynamic",
1321
+ depends: ["appKey", "actionType"],
1322
+ fetch: async (sdk, resolvedParams) => {
1323
+ const actionsResponse = await sdk.listActions({
1324
+ appKey: resolvedParams.appKey
1325
+ });
1326
+ return actionsResponse.data.filter(
1327
+ (action) => action.action_type === resolvedParams.actionType
1328
+ );
1329
+ },
1330
+ prompt: (actions) => ({
1331
+ type: "list",
1332
+ name: "actionKey",
1333
+ message: "Select action:",
1334
+ choices: actions.map((action) => ({
1335
+ name: `${action.title || action.name || action.key} - ${action.description || "No description"}`,
1336
+ value: action.key
1337
+ }))
1338
+ })
1339
+ };
1340
+
1341
+ // src/resolvers/authenticationId.ts
1342
+ var authenticationIdResolver = {
1343
+ type: "dynamic",
1344
+ depends: ["appKey"],
1345
+ fetch: async (sdk, resolvedParams) => {
1346
+ const listOptions = {
1347
+ maxItems: 1e3
1348
+ };
1349
+ if (resolvedParams.appKey) {
1350
+ listOptions.appKey = resolvedParams.appKey;
1351
+ }
1352
+ const myAuths = await sdk.listAuthentications({
1353
+ ...listOptions,
1354
+ owner: "me"
1355
+ });
1356
+ const allAuths = await sdk.listAuthentications(listOptions);
1357
+ const otherAuths = allAuths.data.filter(
1358
+ (auth) => !myAuths.data.some((myAuth) => myAuth.id === auth.id)
1359
+ );
1360
+ return [...myAuths.data, ...otherAuths];
1361
+ },
1362
+ prompt: (auths, params) => ({
1363
+ type: "list",
1364
+ name: "authenticationId",
1365
+ message: params.appKey ? `Select authentication for ${params.appKey}:` : "Select authentication:",
1366
+ choices: [
1367
+ ...auths.map((auth) => ({
1368
+ name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
1369
+ value: auth.id
1370
+ })),
1371
+ {
1372
+ name: "\u2197 Skip authentication (may fail)",
1373
+ value: null
1374
+ }
1375
+ ]
1376
+ })
1377
+ };
1378
+ var authenticationIdGenericResolver = {
1379
+ ...authenticationIdResolver,
1380
+ depends: []
1381
+ };
1382
+
1383
+ // src/resolvers/inputs.ts
1384
+ var inputsResolver = {
1385
+ type: "fields",
1386
+ depends: ["appKey", "actionKey", "actionType", "authenticationId"],
1387
+ fetch: async (sdk, resolvedParams) => {
1388
+ const fieldsResponse = await sdk.listInputFields({
1389
+ appKey: resolvedParams.appKey,
1390
+ actionKey: resolvedParams.actionKey,
1391
+ actionType: resolvedParams.actionType,
1392
+ authenticationId: resolvedParams.authenticationId,
1393
+ inputs: resolvedParams.inputs
1394
+ // Pass along currently resolved inputs
1395
+ });
1396
+ return fieldsResponse.data;
1397
+ }
1398
+ };
1399
+ var inputsAllOptionalResolver = {
1400
+ type: "fields",
1401
+ depends: ["appKey", "actionKey", "actionType", "authenticationId"],
1402
+ fetch: async (sdk, resolvedParams) => {
1403
+ const fieldsResponse = await sdk.listInputFields({
1404
+ appKey: resolvedParams.appKey,
1405
+ actionKey: resolvedParams.actionKey,
1406
+ actionType: resolvedParams.actionType,
1407
+ authenticationId: resolvedParams.authenticationId,
1408
+ inputs: resolvedParams.inputs
1409
+ // Pass along currently resolved inputs
1410
+ });
1411
+ return fieldsResponse.data.map((field) => ({
1412
+ ...field,
1413
+ is_required: false
1414
+ }));
1415
+ }
1416
+ };
1417
+
1418
+ // src/resolvers/inputFieldKey.ts
1419
+ var inputFieldKeyResolver = {
1420
+ type: "dynamic",
1421
+ depends: ["appKey", "actionKey", "actionType", "authenticationId"],
1422
+ fetch: async (sdk, resolvedParams) => {
1423
+ const fieldsResponse = await sdk.listInputFields({
1424
+ appKey: resolvedParams.appKey,
1425
+ actionKey: resolvedParams.actionKey,
1426
+ actionType: resolvedParams.actionType,
1427
+ authenticationId: resolvedParams.authenticationId,
1428
+ inputs: resolvedParams.inputs
1429
+ // Pass along currently resolved inputs
1430
+ });
1431
+ return fieldsResponse.data;
1432
+ },
1433
+ prompt: (fields) => ({
1434
+ type: "list",
1435
+ name: "inputFieldKey",
1436
+ message: "Select input field:",
1437
+ choices: fields.map((field) => ({
1438
+ name: `${field.title || field.key} - ${field.value_type || "No type"} ${field.is_required ? "(required)" : "(optional)"}`,
1439
+ value: field.key
1440
+ }))
1441
+ })
1442
+ };
1443
+
1444
+ // src/plugins/listActions/index.ts
1445
+ var listActionsPlugin = ({ context }) => {
1446
+ const listActions = createPaginatedFunction(async function listActionsPage(options) {
1447
+ const { api, getVersionedImplementationId } = context;
1448
+ const selectedApi = await getVersionedImplementationId(options.appKey);
1449
+ if (!selectedApi) {
1450
+ throw new ZapierConfigurationError(
1451
+ "No current_implementation_id found for app",
1452
+ { configType: "current_implementation_id" }
1453
+ );
1454
+ }
1455
+ const searchParams = {
1456
+ global: "true",
1457
+ public_only: "true",
1458
+ selected_apis: selectedApi
1297
1459
  };
1298
1460
  const data = await api.get(
1299
1461
  "/api/v4/implementations/",
@@ -1344,7 +1506,14 @@ var listActionsPlugin = ({ context }) => {
1344
1506
  meta: {
1345
1507
  listActions: {
1346
1508
  categories: ["action"],
1347
- inputSchema: ListActionsSchema
1509
+ type: "list",
1510
+ itemType: "Action",
1511
+ inputSchema: ListActionsSchema,
1512
+ outputSchema: ActionItemSchema,
1513
+ resolvers: {
1514
+ appKey: appKeyResolver,
1515
+ actionType: actionTypeResolver
1516
+ }
1348
1517
  }
1349
1518
  }
1350
1519
  }
@@ -1361,6 +1530,83 @@ var ListInputFieldsSchema = zod.z.object({
1361
1530
  pageSize: zod.z.number().min(1).optional().describe("Number of input fields per page"),
1362
1531
  maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
1363
1532
  }).describe("Get the input fields required for a specific action");
1533
+ var InputFieldItemSchema = withFormatter(
1534
+ zod.z.object({
1535
+ key: zod.z.string(),
1536
+ // From need.key
1537
+ default_value: zod.z.string(),
1538
+ // Mapped from 'default' with fallback to ""
1539
+ depends_on: zod.z.array(zod.z.string()),
1540
+ // Mapped from 'depends_on' with fallback to []
1541
+ description: zod.z.string(),
1542
+ // Mapped from 'help_text' with fallback to ""
1543
+ invalidates_input_fields: zod.z.boolean(),
1544
+ // Mapped from 'alters_custom_fields' with fallback to false
1545
+ is_required: zod.z.boolean(),
1546
+ // Mapped from 'required' with fallback to false
1547
+ placeholder: zod.z.string(),
1548
+ // Mapped from 'placeholder' with fallback to ""
1549
+ title: zod.z.string(),
1550
+ // Mapped from 'label' with fallback to ""
1551
+ value_type: zod.z.string(),
1552
+ // Computed from InputFieldType enum
1553
+ format: zod.z.string().optional(),
1554
+ // Computed from InputFieldFormat enum (optional)
1555
+ items: zod.z.object({ type: zod.z.string() }).optional()
1556
+ // Computed from ItemsType enum (optional, only for arrays)
1557
+ }),
1558
+ {
1559
+ format: (item) => {
1560
+ const details = [];
1561
+ const typeInfo = [
1562
+ item.value_type && `Type: ${item.value_type}`,
1563
+ `Required: ${item.is_required ? "Yes" : "No"}`
1564
+ ].filter(Boolean).join(" | ");
1565
+ if (typeInfo) {
1566
+ details.push({ text: typeInfo, style: "dim" });
1567
+ }
1568
+ if (item.description) {
1569
+ details.push({
1570
+ text: item.description,
1571
+ style: "normal"
1572
+ });
1573
+ }
1574
+ if (item.default_value) {
1575
+ details.push({
1576
+ text: `Default: ${item.default_value}`,
1577
+ style: "accent"
1578
+ });
1579
+ }
1580
+ if (item.placeholder) {
1581
+ details.push({
1582
+ text: `Placeholder: ${item.placeholder}`,
1583
+ style: "dim"
1584
+ });
1585
+ }
1586
+ if (item.depends_on && item.depends_on.length > 0) {
1587
+ details.push({
1588
+ text: `Depends on: ${item.depends_on.join(", ")}`,
1589
+ style: "warning"
1590
+ });
1591
+ }
1592
+ if (item.format) {
1593
+ details.push({ text: `Format: ${item.format}`, style: "dim" });
1594
+ }
1595
+ if (item.items) {
1596
+ details.push({
1597
+ text: `Items type: ${item.items.type}`,
1598
+ style: "dim"
1599
+ });
1600
+ }
1601
+ return {
1602
+ title: item.title || item.key,
1603
+ key: item.key,
1604
+ description: item.description,
1605
+ details
1606
+ };
1607
+ }
1608
+ }
1609
+ );
1364
1610
 
1365
1611
  // src/plugins/listInputFields/index.ts
1366
1612
  function getInputFieldTypeFromNeed(need) {
@@ -1405,9 +1651,8 @@ function getItemsTypeFromNeed(need) {
1405
1651
  function transformNeedToInputFieldItem(need) {
1406
1652
  const itemsType = getItemsTypeFromNeed(need);
1407
1653
  return {
1408
- ...need,
1409
- // Pass through all original Need fields
1410
- id: need.key,
1654
+ // Only the final computed/mapped fields that are in InputFieldItemSchema
1655
+ key: need.key,
1411
1656
  default_value: need.default || "",
1412
1657
  depends_on: need.depends_on || [],
1413
1658
  description: need.help_text || "",
@@ -1467,7 +1712,17 @@ var listInputFieldsPlugin = ({ context }) => {
1467
1712
  meta: {
1468
1713
  listInputFields: {
1469
1714
  categories: ["action"],
1470
- inputSchema: ListInputFieldsSchema
1715
+ type: "list",
1716
+ itemType: "InputField",
1717
+ inputSchema: ListInputFieldsSchema,
1718
+ outputSchema: InputFieldItemSchema,
1719
+ resolvers: {
1720
+ appKey: appKeyResolver,
1721
+ actionType: actionTypeResolver,
1722
+ actionKey: actionKeyResolver,
1723
+ authenticationId: authenticationIdResolver,
1724
+ inputs: inputsAllOptionalResolver
1725
+ }
1471
1726
  }
1472
1727
  }
1473
1728
  }
@@ -1477,6 +1732,7 @@ var ListAuthenticationsSchema = zod.z.object({
1477
1732
  appKey: AppKeyPropertySchema.optional().describe(
1478
1733
  "App key of authentications to list (e.g., 'SlackCLIAPI')"
1479
1734
  ),
1735
+ authenticationIds: zod.z.array(zod.z.string()).optional().describe("List of authentication IDs to filter by"),
1480
1736
  search: zod.z.string().optional().describe("Search term to filter authentications by title"),
1481
1737
  title: zod.z.string().optional().describe("Filter authentications by exact title match"),
1482
1738
  accountId: zod.z.string().optional().describe("Filter by account ID"),
@@ -1484,6 +1740,49 @@ var ListAuthenticationsSchema = zod.z.object({
1484
1740
  pageSize: zod.z.number().min(1).optional().describe("Number of authentications per page"),
1485
1741
  maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
1486
1742
  }).describe("List available authentications with optional filtering");
1743
+ var AuthenticationItemSchema = withFormatter(
1744
+ AuthenticationSchema.omit({ selected_api: true, customuser_id: true }).extend(
1745
+ {
1746
+ implementation_id: zod.z.string().optional(),
1747
+ // Renamed from selected_api
1748
+ is_expired: zod.z.string().optional(),
1749
+ // Mapped from is_stale
1750
+ expired_at: zod.z.string().nullable().optional(),
1751
+ // Mapped from marked_stale_at
1752
+ app_key: zod.z.string().optional(),
1753
+ // App key from implementations endpoint
1754
+ version: zod.z.string().optional(),
1755
+ // Version extracted from implementation_id
1756
+ user_id: zod.z.number().optional()
1757
+ }
1758
+ ),
1759
+ {
1760
+ format: (item) => {
1761
+ const details = [];
1762
+ if (item.identifier) {
1763
+ details.push({
1764
+ text: `Identifier: ${item.identifier}`,
1765
+ style: "accent"
1766
+ });
1767
+ }
1768
+ details.push({
1769
+ text: `Account: ${item.account_id} | Private: ${item.is_private} | Shared: ${item.shared_with_all}`,
1770
+ style: "dim"
1771
+ });
1772
+ if (item.marked_stale_at) {
1773
+ details.push({
1774
+ text: `\u26A0\uFE0F Marked stale: ${new Date(item.marked_stale_at).toLocaleDateString()}`,
1775
+ style: "warning"
1776
+ });
1777
+ }
1778
+ return {
1779
+ title: item.title || `Authentication ${item.id}`,
1780
+ id: item.id?.toString(),
1781
+ details
1782
+ };
1783
+ }
1784
+ }
1785
+ );
1487
1786
 
1488
1787
  // src/plugins/listAuthentications/index.ts
1489
1788
  var listAuthenticationsPlugin = ({ context }) => {
@@ -1500,6 +1799,9 @@ var listAuthenticationsPlugin = ({ context }) => {
1500
1799
  searchParams.versionless_selected_api = versionlessSelectedApi;
1501
1800
  }
1502
1801
  }
1802
+ if (options.authenticationIds && options.authenticationIds.length > 0) {
1803
+ searchParams.ids = options.authenticationIds.join(",");
1804
+ }
1503
1805
  if (options.search) {
1504
1806
  searchParams.search = options.search;
1505
1807
  } else if (options.title) {
@@ -1556,33 +1858,36 @@ var listAuthenticationsPlugin = ({ context }) => {
1556
1858
  meta: {
1557
1859
  listAuthentications: {
1558
1860
  categories: ["authentication"],
1559
- inputSchema: ListAuthenticationsSchema
1861
+ type: "list",
1862
+ itemType: "Authentication",
1863
+ inputSchema: ListAuthenticationsSchema,
1864
+ outputSchema: AuthenticationItemSchema,
1865
+ resolvers: {
1866
+ appKey: appKeyResolver
1867
+ }
1560
1868
  }
1561
1869
  }
1562
1870
  }
1563
1871
  };
1564
1872
  };
1565
- var GetAppSchema = withOutputSchema(
1566
- zod.z.object({
1567
- appKey: AppKeyPropertySchema.describe(
1568
- "App key of app to fetch (e.g., 'SlackCLIAPI')"
1569
- )
1570
- }).describe("Get detailed information about a specific app"),
1571
- AppItemSchema
1572
- );
1873
+ var GetAppSchema = zod.z.object({
1874
+ appKey: AppKeyPropertySchema.describe(
1875
+ "App key of app to fetch (e.g., 'SlackCLIAPI')"
1876
+ )
1877
+ }).describe("Get detailed information about a specific app");
1573
1878
 
1574
1879
  // src/plugins/getApp/index.ts
1575
- var getAppPlugin = ({ context }) => {
1880
+ var getAppPlugin = ({ sdk }) => {
1576
1881
  const getApp = createFunction(async function getApp2(options) {
1577
- const app = await context.getImplementation(options.appKey);
1578
- if (!app) {
1579
- throw new ZapierAppNotFoundError("App not found", {
1580
- appKey: options.appKey
1581
- });
1882
+ const appsIterator = sdk.listApps({ appKeys: [options.appKey] }).items();
1883
+ for await (const app of appsIterator) {
1884
+ return {
1885
+ data: app
1886
+ };
1582
1887
  }
1583
- return {
1584
- data: app
1585
- };
1888
+ throw new ZapierAppNotFoundError("App not found", {
1889
+ appKey: options.appKey
1890
+ });
1586
1891
  }, GetAppSchema);
1587
1892
  return {
1588
1893
  getApp,
@@ -1590,7 +1895,13 @@ var getAppPlugin = ({ context }) => {
1590
1895
  meta: {
1591
1896
  getApp: {
1592
1897
  categories: ["app"],
1593
- inputSchema: GetAppSchema
1898
+ type: "item",
1899
+ itemType: "App",
1900
+ inputSchema: GetAppSchema,
1901
+ outputSchema: AppItemSchema,
1902
+ resolvers: {
1903
+ appKey: appKeyResolver
1904
+ }
1594
1905
  }
1595
1906
  }
1596
1907
  }
@@ -1623,7 +1934,15 @@ var getActionPlugin = ({ sdk }) => {
1623
1934
  meta: {
1624
1935
  getAction: {
1625
1936
  categories: ["action"],
1626
- inputSchema: GetActionSchema
1937
+ type: "item",
1938
+ itemType: "Action",
1939
+ inputSchema: GetActionSchema,
1940
+ outputSchema: ActionItemSchema,
1941
+ resolvers: {
1942
+ appKey: appKeyResolver,
1943
+ actionType: actionTypeResolver,
1944
+ actionKey: actionKeyResolver
1945
+ }
1627
1946
  }
1628
1947
  }
1629
1948
  }
@@ -1678,7 +1997,13 @@ var getAuthenticationPlugin = ({ context }) => {
1678
1997
  meta: {
1679
1998
  getAuthentication: {
1680
1999
  categories: ["authentication"],
1681
- inputSchema: GetAuthenticationSchema
2000
+ type: "item",
2001
+ itemType: "Authentication",
2002
+ inputSchema: GetAuthenticationSchema,
2003
+ outputSchema: AuthenticationItemSchema,
2004
+ resolvers: {
2005
+ authenticationId: authenticationIdGenericResolver
2006
+ }
1682
2007
  }
1683
2008
  }
1684
2009
  }
@@ -1702,8 +2027,14 @@ var findFirstAuthenticationPlugin = ({ sdk }) => {
1702
2027
  ...options,
1703
2028
  maxItems: 1
1704
2029
  });
2030
+ if (authsResponse.data.length === 0) {
2031
+ throw new ZapierResourceNotFoundError(
2032
+ "No authentication found matching the specified criteria",
2033
+ { resourceType: "Authentication" }
2034
+ );
2035
+ }
1705
2036
  return {
1706
- data: authsResponse.data.length > 0 ? authsResponse.data[0] : null
2037
+ data: authsResponse.data[0]
1707
2038
  };
1708
2039
  },
1709
2040
  FindFirstAuthenticationSchema
@@ -1714,7 +2045,10 @@ var findFirstAuthenticationPlugin = ({ sdk }) => {
1714
2045
  meta: {
1715
2046
  findFirstAuthentication: {
1716
2047
  categories: ["authentication"],
1717
- inputSchema: FindFirstAuthenticationSchema
2048
+ type: "item",
2049
+ itemType: "Authentication",
2050
+ inputSchema: FindFirstAuthenticationSchema,
2051
+ outputSchema: AuthenticationItemSchema
1718
2052
  }
1719
2053
  }
1720
2054
  }
@@ -1762,7 +2096,10 @@ var findUniqueAuthenticationPlugin = ({ sdk }) => {
1762
2096
  meta: {
1763
2097
  findUniqueAuthentication: {
1764
2098
  categories: ["authentication"],
1765
- inputSchema: FindUniqueAuthenticationSchema
2099
+ type: "item",
2100
+ itemType: "Authentication",
2101
+ inputSchema: FindUniqueAuthenticationSchema,
2102
+ outputSchema: AuthenticationItemSchema
1766
2103
  }
1767
2104
  }
1768
2105
  }
@@ -1779,6 +2116,31 @@ var RunActionSchema = zod.z.object({
1779
2116
  pageSize: zod.z.number().min(1).optional().describe("Number of results per page"),
1780
2117
  maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
1781
2118
  }).describe("Execute an action with the given inputs");
2119
+ function getStringProperty(obj, key) {
2120
+ if (typeof obj === "object" && obj !== null && key in obj) {
2121
+ const value = obj[key];
2122
+ return typeof value === "string" ? value : void 0;
2123
+ }
2124
+ return void 0;
2125
+ }
2126
+ function formatActionResult(item) {
2127
+ const obj = typeof item === "object" && item !== null ? item : {};
2128
+ const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
2129
+ return {
2130
+ title,
2131
+ id: getStringProperty(obj, "id"),
2132
+ key: getStringProperty(obj, "key"),
2133
+ description: getStringProperty(obj, "description"),
2134
+ data: item,
2135
+ // Let formatJsonOutput handle the JSON rendering
2136
+ details: []
2137
+ // Not used when data is provided
2138
+ };
2139
+ }
2140
+ var ActionResultItemSchema = withFormatter(
2141
+ zod.z.unknown().describe("Action execution result"),
2142
+ { format: formatActionResult }
2143
+ );
1782
2144
 
1783
2145
  // src/plugins/runAction/index.ts
1784
2146
  async function executeAction(actionOptions) {
@@ -1870,7 +2232,17 @@ var runActionPlugin = ({ sdk, context }) => {
1870
2232
  meta: {
1871
2233
  runAction: {
1872
2234
  categories: ["action"],
1873
- inputSchema: RunActionSchema
2235
+ type: "list",
2236
+ itemType: "ActionResult",
2237
+ inputSchema: RunActionSchema,
2238
+ outputSchema: ActionResultItemSchema,
2239
+ resolvers: {
2240
+ appKey: appKeyResolver,
2241
+ actionType: actionTypeResolver,
2242
+ actionKey: actionKeyResolver,
2243
+ authenticationId: authenticationIdResolver,
2244
+ inputs: inputsResolver
2245
+ }
1874
2246
  }
1875
2247
  }
1876
2248
  }
@@ -1942,12 +2314,74 @@ var requestPlugin = ({ context }) => {
1942
2314
  meta: {
1943
2315
  request: {
1944
2316
  categories: ["http"],
2317
+ returnType: "Response",
1945
2318
  inputSchema: RelayRequestSchema
1946
2319
  }
1947
2320
  }
1948
2321
  }
1949
2322
  };
1950
2323
  };
2324
+
2325
+ // src/utils/file-utils.ts
2326
+ var inMemoryFiles = {};
2327
+ var fsPromises = null;
2328
+ var pathModule = null;
2329
+ async function loadFsPromises() {
2330
+ if (fsPromises) return fsPromises;
2331
+ try {
2332
+ fsPromises = await import('fs/promises');
2333
+ return fsPromises;
2334
+ } catch {
2335
+ return null;
2336
+ }
2337
+ }
2338
+ async function loadPathModule() {
2339
+ if (pathModule) return pathModule;
2340
+ try {
2341
+ pathModule = await import('path');
2342
+ return pathModule;
2343
+ } catch {
2344
+ return null;
2345
+ }
2346
+ }
2347
+ async function resolve(path, basePath = "/") {
2348
+ const pathModule2 = await loadPathModule();
2349
+ if (pathModule2) {
2350
+ return pathModule2.resolve(path);
2351
+ }
2352
+ if (path.startsWith("/")) {
2353
+ return path;
2354
+ }
2355
+ if (path.startsWith("./")) {
2356
+ const cleanPath = path.slice(2);
2357
+ return basePath.endsWith("/") ? basePath + cleanPath : basePath + "/" + cleanPath;
2358
+ }
2359
+ if (path.startsWith("../")) {
2360
+ const cleanPath = path.replace(/^(\.\.\/)+/, "");
2361
+ return basePath.endsWith("/") ? basePath + cleanPath : basePath + "/" + cleanPath;
2362
+ }
2363
+ return basePath.endsWith("/") ? basePath + path : basePath + "/" + path;
2364
+ }
2365
+ async function writeFile(filePath, content) {
2366
+ const fs = await loadFsPromises();
2367
+ if (fs) {
2368
+ await fs.writeFile(filePath, content, "utf8");
2369
+ return;
2370
+ }
2371
+ inMemoryFiles[filePath] = content;
2372
+ }
2373
+ async function readFile(filePath) {
2374
+ const fs = await loadFsPromises();
2375
+ if (fs) {
2376
+ return await fs.readFile(filePath, "utf8");
2377
+ }
2378
+ const content = inMemoryFiles[filePath];
2379
+ if (content !== void 0) {
2380
+ return content;
2381
+ }
2382
+ throw new Error(`File not found: ${filePath}`);
2383
+ }
2384
+ var DEFAULT_CONFIG_PATH = ".zapierrc";
1951
2385
  var ManifestSchema = zod.z.object({
1952
2386
  apps: zod.z.record(
1953
2387
  zod.z.string(),
@@ -1970,6 +2404,15 @@ zod.z.object({
1970
2404
  ).optional().describe("Direct manifest object")
1971
2405
  });
1972
2406
 
2407
+ // src/utils/array-utils.ts
2408
+ async function toArrayFromAsync(asyncIterable) {
2409
+ const result = [];
2410
+ for await (const item of asyncIterable) {
2411
+ result.push(item);
2412
+ }
2413
+ return result;
2414
+ }
2415
+
1973
2416
  // src/plugins/manifest/index.ts
1974
2417
  function parseManifestContent(content, source) {
1975
2418
  try {
@@ -1987,172 +2430,239 @@ function parseManifestContent(content, source) {
1987
2430
  return null;
1988
2431
  }
1989
2432
  }
1990
- function loadManifestFromFile(filePath) {
2433
+ async function readManifestFromFile(filePath) {
1991
2434
  try {
1992
- const resolvedPath = path.resolve(filePath);
1993
- const content = fs.readFileSync(resolvedPath, "utf8");
2435
+ const resolvedPath = await resolve(filePath);
2436
+ const content = await readFile(resolvedPath);
1994
2437
  return parseManifestContent(content, resolvedPath);
1995
2438
  } catch {
1996
- console.warn(`\u26A0\uFE0F Failed to load manifest from ${filePath}`);
2439
+ console.warn(`\u26A0\uFE0F Failed to read manifest from ${filePath}`);
1997
2440
  return null;
1998
2441
  }
1999
2442
  }
2000
- var emitWarning = (appKey) => {
2001
- console.warn(
2002
- `
2003
- ${"\u26A0\uFE0F".padEnd(3)} ${"WARNING".padEnd(8)} No manifest version found for '${appKey}'`
2004
- );
2005
- console.warn(
2006
- ` ${"\u21B3".padEnd(3)} Using a manifest ensures version locking and prevents unexpected behavior due to version changes.`
2443
+ async function writeManifestToFile(manifest, filePath) {
2444
+ const resolvedPath = await resolve(filePath);
2445
+ await writeFile(resolvedPath, JSON.stringify(manifest, null, 2));
2446
+ }
2447
+ async function getPreferredManifestEntryKey({
2448
+ appKey,
2449
+ api
2450
+ }) {
2451
+ const locator = toAppLocator(appKey);
2452
+ if (locator.slug) {
2453
+ return locator.slug;
2454
+ }
2455
+ if (locator.implementationName) {
2456
+ try {
2457
+ const implementationsEnvelope = await api.get(`/api/v4/implementations-meta/lookup/`, {
2458
+ searchParams: {
2459
+ selected_apis: locator.implementationName
2460
+ }
2461
+ });
2462
+ if (implementationsEnvelope.results.length > 0 && implementationsEnvelope.results[0].slug) {
2463
+ return implementationsEnvelope.results[0].slug;
2464
+ }
2465
+ } catch {
2466
+ }
2467
+ return locator.implementationName;
2468
+ }
2469
+ return locator.lookupAppKey;
2470
+ }
2471
+ async function listAppsForSlugsPage({
2472
+ slugs,
2473
+ cursor,
2474
+ api
2475
+ }) {
2476
+ const searchParams = {};
2477
+ if (slugs.length > 0) {
2478
+ searchParams.slugs = slugs.join(",");
2479
+ }
2480
+ if (cursor) {
2481
+ searchParams.offset = cursor;
2482
+ }
2483
+ const implementationsEnvelope = await api.get(
2484
+ "/api/v4/implementations-meta/lookup/",
2485
+ {
2486
+ searchParams
2487
+ }
2007
2488
  );
2008
- console.warn(
2009
- ` ${"\u21B3".padEnd(3)} Generate/update the manifest with: \`zapier-sdk lock-version ${appKey}\`
2010
- `
2489
+ return {
2490
+ data: implementationsEnvelope.results.map(
2491
+ normalizeImplementationMetaToAppItem
2492
+ ),
2493
+ nextCursor: extractCursor(implementationsEnvelope)
2494
+ };
2495
+ }
2496
+ function findManifestEntry({
2497
+ appKey,
2498
+ manifest
2499
+ }) {
2500
+ const [appKeyWithoutVersion] = splitVersionedKey(appKey);
2501
+ if (manifest.apps[appKeyWithoutVersion]) {
2502
+ return [appKeyWithoutVersion, manifest.apps[appKeyWithoutVersion]];
2503
+ }
2504
+ if (isSnakeCasedSlug(appKey)) {
2505
+ const slug = dashifySnakeCasedSlug(appKey);
2506
+ if (manifest.apps[slug]) {
2507
+ return [slug, manifest.apps[slug]];
2508
+ }
2509
+ }
2510
+ for (const [key, entry] of Object.entries(manifest.apps)) {
2511
+ if (entry.implementationName === appKeyWithoutVersion) {
2512
+ return [key, entry];
2513
+ }
2514
+ }
2515
+ return null;
2516
+ }
2517
+ async function resolveAppKeys({
2518
+ appKeys,
2519
+ api,
2520
+ manifest
2521
+ }) {
2522
+ const locators = appKeys.map(toAppLocator);
2523
+ const locatorsWithManifest = locators.map((locator) => {
2524
+ const manifestEntryResult = findManifestEntry({
2525
+ appKey: locator.lookupAppKey,
2526
+ manifest
2527
+ });
2528
+ if (manifestEntryResult) {
2529
+ const [, manifestEntry] = manifestEntryResult;
2530
+ const resolvedVersion = locator.version || manifestEntry.version;
2531
+ const resolvedLocator = {
2532
+ ...locator,
2533
+ implementationName: manifestEntry.implementationName,
2534
+ version: resolvedVersion
2535
+ };
2536
+ return resolvedLocator;
2537
+ }
2538
+ return locator;
2539
+ });
2540
+ const unresolvedLocators = locatorsWithManifest.filter(
2541
+ (locator) => !isResolvedAppLocator(locator)
2011
2542
  );
2012
- };
2543
+ const slugsToResolve = unresolvedLocators.map((locator) => locator.slug).filter((slug) => !!slug).filter((slug, index, array) => array.indexOf(slug) === index);
2544
+ if (slugsToResolve.length === 0) {
2545
+ return locatorsWithManifest.filter(isResolvedAppLocator);
2546
+ }
2547
+ const iterator = paginate(listAppsForSlugsPage, {
2548
+ slugs: slugsToResolve,
2549
+ api
2550
+ });
2551
+ const pages = await toArrayFromAsync(iterator);
2552
+ const apps = pages.flatMap((page) => page.data);
2553
+ const slugToAppData = /* @__PURE__ */ new Map();
2554
+ for (const app of apps) {
2555
+ if (app.slug) {
2556
+ slugToAppData.set(app.slug, app);
2557
+ }
2558
+ }
2559
+ const slugResolvedLocators = locatorsWithManifest.map((locator) => {
2560
+ if (isResolvedAppLocator(locator)) {
2561
+ return locator;
2562
+ }
2563
+ if (locator.slug) {
2564
+ const appData = slugToAppData.get(locator.slug);
2565
+ if (appData) {
2566
+ const manifestEntryByImplementationName = findManifestEntry({
2567
+ appKey: appData.key,
2568
+ // appData.key is the implementation name
2569
+ manifest
2570
+ });
2571
+ let version = locator.version;
2572
+ if (!version) {
2573
+ version = manifestEntryByImplementationName ? manifestEntryByImplementationName[1].version || appData.version : appData.version;
2574
+ }
2575
+ return {
2576
+ ...locator,
2577
+ implementationName: appData.key,
2578
+ version
2579
+ };
2580
+ }
2581
+ }
2582
+ return locator;
2583
+ });
2584
+ return slugResolvedLocators.filter(isResolvedAppLocator);
2585
+ }
2013
2586
  var manifestPlugin = (params) => {
2014
- const { sdk, context } = params;
2587
+ const { context } = params;
2015
2588
  const { api, options } = context;
2016
- const { manifestPath = ".zapierrc", manifest } = options || {};
2589
+ const { manifestPath = DEFAULT_CONFIG_PATH, manifest } = options || {};
2017
2590
  let resolvedManifest;
2018
- function resolveManifest() {
2591
+ async function resolveManifest() {
2019
2592
  if (manifest) {
2020
2593
  return manifest;
2021
2594
  }
2022
2595
  if (manifestPath) {
2023
- return loadManifestFromFile(manifestPath);
2596
+ return await readManifestFromFile(manifestPath);
2024
2597
  }
2025
2598
  return null;
2026
2599
  }
2027
- const getResolvedManifest = () => {
2600
+ const getResolvedManifest = async () => {
2028
2601
  if (typeof resolvedManifest === "undefined") {
2029
- resolvedManifest = resolveManifest() ?? null;
2602
+ resolvedManifest = await resolveManifest() ?? null;
2030
2603
  }
2031
2604
  return resolvedManifest;
2032
2605
  };
2033
- const getManifestEntry = (appKey) => {
2034
- return getResolvedManifest()?.apps?.[appKey] || null;
2606
+ const getVersionedImplementationId = async (appKey) => {
2607
+ const resolvedApps = await resolveAppKeys({
2608
+ appKeys: [appKey],
2609
+ api,
2610
+ manifest: await getResolvedManifest() ?? { apps: {} }
2611
+ });
2612
+ const resolvedApp = resolvedApps[0];
2613
+ if (!resolvedApp) return null;
2614
+ return `${resolvedApp.implementationName}@${resolvedApp.version || "latest"}`;
2035
2615
  };
2036
- const getImplementation = async (appKey) => {
2037
- let selectedApi = null;
2038
- const manifestImplementation = getResolvedManifest()?.apps?.[appKey];
2039
- const [versionlessAppKey, version] = splitVersionedKey(appKey);
2040
- if (version) {
2041
- selectedApi = `${versionlessAppKey}@${version}`;
2042
- } else if (manifestImplementation) {
2043
- selectedApi = `${manifestImplementation.implementationName}@${manifestImplementation.version || "latest"}`;
2044
- }
2045
- if (selectedApi) {
2046
- const searchParams = {
2047
- selected_apis: selectedApi
2048
- };
2049
- const implementationData = await api.get(
2050
- "/api/v4/implementations/",
2051
- {
2052
- searchParams
2616
+ const updateManifestEntry = async (appKey, entry, configPath = DEFAULT_CONFIG_PATH) => {
2617
+ const manifest2 = await readManifestFromFile(configPath) || { apps: {} };
2618
+ let existingEntry = findManifestEntry({
2619
+ appKey,
2620
+ manifest: manifest2
2621
+ });
2622
+ if (!existingEntry) {
2623
+ try {
2624
+ const resolvedApps = await resolveAppKeys({
2625
+ appKeys: [appKey],
2626
+ api,
2627
+ manifest: manifest2
2628
+ });
2629
+ if (resolvedApps.length > 0) {
2630
+ const resolvedImplementationName = resolvedApps[0].implementationName;
2631
+ existingEntry = findManifestEntry({
2632
+ appKey: resolvedImplementationName,
2633
+ manifest: manifest2
2634
+ });
2053
2635
  }
2054
- );
2055
- const implementationResults = implementationData.results[0];
2056
- if (!implementationResults) return null;
2057
- return normalizeImplementationToAppItem(implementationResults);
2058
- }
2059
- emitWarning(appKey);
2060
- const appsIterator = sdk.listApps({ appKeys: [appKey] }).items();
2061
- const apps = [];
2062
- for await (const app2 of appsIterator) {
2063
- apps.push(app2);
2064
- break;
2065
- }
2066
- if (apps.length === 0) {
2067
- return null;
2068
- }
2069
- const app = apps[0];
2070
- return app;
2071
- };
2072
- const getVersionedImplementationId = async (appKey) => {
2073
- const manifestEntry = getManifestEntry(appKey);
2074
- if (manifestEntry) {
2075
- return `${manifestEntry.implementationName}@${manifestEntry.version || "latest"}`;
2636
+ } catch {
2637
+ }
2076
2638
  }
2077
- const implementation = await getImplementation(appKey);
2078
- if (!implementation) return null;
2079
- return implementation.current_implementation_id;
2080
- };
2081
- return {
2082
- context: {
2083
- getVersionedImplementationId,
2084
- getManifestEntry,
2085
- getImplementation
2639
+ let manifestKey;
2640
+ if (existingEntry) {
2641
+ manifestKey = existingEntry[0];
2642
+ } else {
2643
+ manifestKey = await getPreferredManifestEntryKey({
2644
+ appKey,
2645
+ api
2646
+ });
2086
2647
  }
2648
+ manifest2.apps[manifestKey] = entry;
2649
+ await writeManifestToFile(manifest2, configPath);
2650
+ resolvedManifest = void 0;
2651
+ return [manifestKey, entry];
2087
2652
  };
2088
- };
2089
- var LockVersionSchema = zod.z.object({
2090
- appKey: zod.z.string().describe("The app key to lock version for (e.g., 'slack', 'gmail')")
2091
- });
2092
- var lockVersionPlugin = ({ sdk }) => {
2093
- const lockVersion = createFunction(
2094
- async function lockVersion2(options) {
2095
- const { appKey, configPath = ".zapierrc" } = options;
2096
- const resolvedPath = path.resolve(configPath);
2097
- const appsIterator = sdk.listApps({ appKeys: [appKey] }).items();
2098
- const apps = [];
2099
- for await (const app2 of appsIterator) {
2100
- apps.push(app2);
2101
- break;
2102
- }
2103
- const app = apps[0];
2104
- const currentImplementationId = app.current_implementation_id;
2105
- const [implementationName, version] = currentImplementationId.split("@");
2106
- if (!implementationName || !version) {
2107
- throw new Error(
2108
- `Invalid implementation ID format: ${currentImplementationId}. Expected format: <implementationName>@<version>`
2109
- );
2110
- }
2111
- let config = { apps: {} };
2112
- if (fs.existsSync(resolvedPath)) {
2113
- try {
2114
- const configContent = fs.readFileSync(resolvedPath, "utf8");
2115
- config = JSON.parse(configContent);
2116
- if (!config.apps) {
2117
- config.apps = {};
2118
- }
2119
- } catch (error) {
2120
- console.warn(
2121
- `\u26A0\uFE0F Failed to parse existing config file, creating new one: ${error}`
2122
- );
2123
- config = { apps: {} };
2124
- }
2125
- }
2126
- config.apps[appKey] = {
2127
- implementationName,
2128
- version
2129
- };
2130
- fs.writeFileSync(resolvedPath, JSON.stringify(config, null, 2));
2131
- return {
2132
- data: {
2133
- ...app,
2134
- implementationName,
2135
- version
2136
- },
2137
- configPath: resolvedPath
2138
- };
2139
- },
2140
- LockVersionSchema.extend({
2141
- configPath: zod.z.string().optional().describe("Path to .zapierrc file (defaults to '.zapierrc')")
2142
- })
2143
- );
2144
2653
  return {
2145
- lockVersion,
2146
2654
  context: {
2147
- meta: {
2148
- lockVersion: {
2149
- categories: ["utility"],
2150
- inputSchema: LockVersionSchema
2151
- }
2152
- }
2655
+ getVersionedImplementationId,
2656
+ resolveAppKeys: async ({ appKeys }) => resolveAppKeys({
2657
+ appKeys,
2658
+ api,
2659
+ manifest: await getResolvedManifest() ?? { apps: {} }
2660
+ }),
2661
+ updateManifestEntry
2153
2662
  }
2154
2663
  };
2155
2664
  };
2665
+ var GetProfileSchema = zod.z.object({}).optional().describe("Get current user's profile information");
2156
2666
  var UserProfileItemSchema = withFormatter(
2157
2667
  UserProfileSchema.omit({ user_id: true }).extend({
2158
2668
  full_name: zod.z.string()
@@ -2161,32 +2671,37 @@ var UserProfileItemSchema = withFormatter(
2161
2671
  {
2162
2672
  format: (item) => {
2163
2673
  const details = [];
2164
- details.push({ text: item.email, style: "dim" });
2165
- if (item.timezone) {
2674
+ if (item == null || typeof item !== "object" || !("full_name" in item) || !("username" in item)) {
2675
+ return {
2676
+ title: "User Profile",
2677
+ subtitle: "Malformatted result item",
2678
+ details: []
2679
+ };
2680
+ }
2681
+ if ("email" in item) {
2682
+ details.push({ text: item.email, style: "dim" });
2683
+ }
2684
+ if ("timezone" in item && item.timezone) {
2166
2685
  details.push({
2167
2686
  text: `Timezone: ${item.timezone}`,
2168
2687
  style: "accent"
2169
2688
  });
2170
2689
  }
2171
- details.push({
2172
- text: `Member since: ${item.since_signup}`,
2173
- style: "dim"
2174
- });
2690
+ if ("since_signup" in item && item.since_signup) {
2691
+ details.push({
2692
+ text: `Member since: ${item.since_signup}`,
2693
+ style: "dim"
2694
+ });
2695
+ }
2175
2696
  return {
2176
2697
  title: item.full_name,
2177
- subtitle: `@${item.username}`,
2698
+ id: item.id.toString(),
2178
2699
  details
2179
2700
  };
2180
2701
  }
2181
2702
  }
2182
2703
  );
2183
2704
 
2184
- // src/plugins/getProfile/schemas.ts
2185
- var GetProfileSchema = withOutputSchema(
2186
- zod.z.object({}).optional().describe("Get current user's profile information"),
2187
- UserProfileItemSchema
2188
- );
2189
-
2190
2705
  // src/plugins/getProfile/index.ts
2191
2706
  var getProfilePlugin = ({ context }) => {
2192
2707
  const getProfile = createFunction(async function getProfile2() {
@@ -2209,7 +2724,10 @@ var getProfilePlugin = ({ context }) => {
2209
2724
  meta: {
2210
2725
  getProfile: {
2211
2726
  categories: ["account"],
2212
- inputSchema: GetProfileSchema
2727
+ type: "item",
2728
+ itemType: "Profile",
2729
+ inputSchema: GetProfileSchema,
2730
+ outputSchema: UserProfileItemSchema
2213
2731
  }
2214
2732
  }
2215
2733
  }
@@ -2242,6 +2760,38 @@ function createDebugLogger(enabled) {
2242
2760
  console.log(`[Zapier SDK] ${message}`, data || "");
2243
2761
  };
2244
2762
  }
2763
+ function censorHeaders(headers) {
2764
+ if (!headers) return headers;
2765
+ const headersObj = new Headers(headers);
2766
+ const authKeys = ["authorization", "x-api-key"];
2767
+ for (const [key, value] of headersObj.entries()) {
2768
+ if (authKeys.some((authKey) => key.toLowerCase() === authKey)) {
2769
+ const spaceIndex = value.indexOf(" ");
2770
+ if (spaceIndex > 0 && spaceIndex < value.length - 1) {
2771
+ const prefix = value.substring(0, spaceIndex + 1);
2772
+ const token = value.substring(spaceIndex + 1);
2773
+ if (token.length > 12) {
2774
+ const start = token.substring(0, 4);
2775
+ const end = token.substring(token.length - 4);
2776
+ headersObj.set(key, `${prefix}${start}...${end}`);
2777
+ } else {
2778
+ const firstChar = token.charAt(0);
2779
+ headersObj.set(key, `${prefix}${firstChar}...`);
2780
+ }
2781
+ } else {
2782
+ if (value.length > 12) {
2783
+ const start = value.substring(0, 4);
2784
+ const end = value.substring(value.length - 4);
2785
+ headersObj.set(key, `${start}...${end}`);
2786
+ } else {
2787
+ const firstChar = value.charAt(0);
2788
+ headersObj.set(key, `${firstChar}...`);
2789
+ }
2790
+ }
2791
+ }
2792
+ }
2793
+ return Object.fromEntries(headersObj);
2794
+ }
2245
2795
  function createDebugFetch(options) {
2246
2796
  const { originalFetch, debugLog } = options;
2247
2797
  return async (input, options2) => {
@@ -2249,7 +2799,7 @@ function createDebugFetch(options) {
2249
2799
  const url = typeof input === "string" ? input : input.toString();
2250
2800
  const method = options2?.method || "GET";
2251
2801
  debugLog(`\u2192 ${method} ${url}`, {
2252
- headers: options2?.headers,
2802
+ headers: censorHeaders(options2?.headers),
2253
2803
  body: options2?.body && typeof options2.body === "string" ? (() => {
2254
2804
  try {
2255
2805
  return JSON.parse(options2.body);
@@ -2600,6 +3150,16 @@ var ZapierApiClient = class {
2600
3150
  if ("errors" in data && Array.isArray(data.errors)) {
2601
3151
  if (this.isApiErrorArray(data.errors)) {
2602
3152
  return data.errors[0].detail || data.errors[0].title;
3153
+ } else if (data.errors.length > 0) {
3154
+ const firstError = data.errors[0];
3155
+ if (typeof firstError === "string") {
3156
+ return firstError;
3157
+ }
3158
+ try {
3159
+ return JSON.stringify(firstError);
3160
+ } catch {
3161
+ return String(firstError);
3162
+ }
2603
3163
  }
2604
3164
  }
2605
3165
  }
@@ -2784,174 +3344,6 @@ var apiPlugin = (params) => {
2784
3344
  };
2785
3345
  };
2786
3346
 
2787
- // src/resolvers/appKey.ts
2788
- var appKeyResolver = {
2789
- type: "static",
2790
- inputType: "text",
2791
- placeholder: "Enter app key (e.g., 'SlackCLIAPI' or slug like 'github')"
2792
- };
2793
-
2794
- // src/resolvers/actionType.ts
2795
- var actionTypeResolver = {
2796
- type: "dynamic",
2797
- depends: ["appKey"],
2798
- fetch: async (sdk, resolvedParams) => {
2799
- const actionsResponse = await sdk.listActions({
2800
- appKey: resolvedParams.appKey
2801
- });
2802
- const types = [
2803
- ...new Set(actionsResponse.data.map((action) => action.action_type))
2804
- ];
2805
- return types.map((type) => ({ key: type, name: type }));
2806
- },
2807
- prompt: (types) => ({
2808
- type: "list",
2809
- name: "actionType",
2810
- message: "Select action type:",
2811
- choices: types.map((type) => ({
2812
- name: type.name,
2813
- value: type.key
2814
- }))
2815
- })
2816
- };
2817
-
2818
- // src/resolvers/actionKey.ts
2819
- var actionKeyResolver = {
2820
- type: "dynamic",
2821
- depends: ["appKey", "actionType"],
2822
- fetch: async (sdk, resolvedParams) => {
2823
- const actionsResponse = await sdk.listActions({
2824
- appKey: resolvedParams.appKey
2825
- });
2826
- return actionsResponse.data.filter(
2827
- (action) => action.action_type === resolvedParams.actionType
2828
- );
2829
- },
2830
- prompt: (actions) => ({
2831
- type: "list",
2832
- name: "actionKey",
2833
- message: "Select action:",
2834
- choices: actions.map((action) => ({
2835
- name: `${action.title || action.name || action.key} - ${action.description || "No description"}`,
2836
- value: action.key
2837
- }))
2838
- })
2839
- };
2840
-
2841
- // src/resolvers/authenticationId.ts
2842
- var authenticationIdResolver = {
2843
- type: "dynamic",
2844
- depends: ["appKey"],
2845
- fetch: async (sdk, resolvedParams) => {
2846
- const myAuths = await sdk.listAuthentications({
2847
- appKey: resolvedParams.appKey,
2848
- maxItems: 1e3,
2849
- owner: "me"
2850
- });
2851
- const allAuths = await sdk.listAuthentications({
2852
- appKey: resolvedParams.appKey,
2853
- maxItems: 1e3
2854
- });
2855
- const otherAuths = allAuths.data.filter(
2856
- (auth) => !myAuths.data.some((myAuth) => myAuth.id === auth.id)
2857
- );
2858
- return [...myAuths.data, ...otherAuths];
2859
- },
2860
- prompt: (auths, params) => ({
2861
- type: "list",
2862
- name: "authenticationId",
2863
- message: `Select authentication for ${params.appKey}:`,
2864
- choices: [
2865
- ...auths.map((auth) => ({
2866
- name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
2867
- value: auth.id
2868
- })),
2869
- {
2870
- name: "\u2197 Skip authentication (may fail)",
2871
- value: null
2872
- }
2873
- ]
2874
- })
2875
- };
2876
-
2877
- // src/resolvers/inputs.ts
2878
- var inputsResolver = {
2879
- type: "fields",
2880
- depends: ["appKey", "actionKey", "actionType", "authenticationId"],
2881
- fetch: async (sdk, resolvedParams) => {
2882
- const fieldsResponse = await sdk.listInputFields({
2883
- appKey: resolvedParams.appKey,
2884
- actionKey: resolvedParams.actionKey,
2885
- actionType: resolvedParams.actionType,
2886
- authenticationId: resolvedParams.authenticationId,
2887
- inputs: resolvedParams.inputs
2888
- // Pass along currently resolved inputs
2889
- });
2890
- return fieldsResponse.data;
2891
- }
2892
- };
2893
-
2894
- // src/resolvers/index.ts
2895
- var resolverRegistry = {
2896
- appKey: appKeyResolver,
2897
- actionType: actionTypeResolver,
2898
- actionKey: actionKeyResolver,
2899
- authenticationId: authenticationIdResolver,
2900
- inputs: inputsResolver
2901
- };
2902
- function getResolver(name) {
2903
- return resolverRegistry[name];
2904
- }
2905
- function getResolversForMissingParams(missingParams) {
2906
- const resolvers = {};
2907
- for (const param of missingParams) {
2908
- const resolver = resolverRegistry[param];
2909
- if (resolver) {
2910
- resolvers[param] = resolver;
2911
- }
2912
- }
2913
- return resolvers;
2914
- }
2915
- function hasResolver(paramName) {
2916
- return paramName in resolverRegistry;
2917
- }
2918
- function getResolvableParams() {
2919
- return Object.keys(resolverRegistry);
2920
- }
2921
- function getResolutionOrder(paramName, resolved = /* @__PURE__ */ new Set()) {
2922
- const resolver = getResolver(paramName);
2923
- if (!resolver || resolver.type === "static") {
2924
- return [paramName];
2925
- }
2926
- const order = [];
2927
- if ("depends" in resolver && resolver.depends) {
2928
- for (const dependency of resolver.depends) {
2929
- if (!resolved.has(dependency)) {
2930
- order.push(...getResolutionOrder(dependency, resolved));
2931
- resolved.add(dependency);
2932
- }
2933
- }
2934
- }
2935
- if (!resolved.has(paramName)) {
2936
- order.push(paramName);
2937
- resolved.add(paramName);
2938
- }
2939
- return order;
2940
- }
2941
- function getResolutionOrderForParams(paramNames) {
2942
- const resolved = /* @__PURE__ */ new Set();
2943
- const order = [];
2944
- for (const paramName of paramNames) {
2945
- const paramOrder = getResolutionOrder(paramName, resolved);
2946
- for (const param of paramOrder) {
2947
- if (!order.includes(param)) {
2948
- order.push(param);
2949
- }
2950
- }
2951
- }
2952
- return order;
2953
- }
2954
-
2955
3347
  // src/plugins/registry/index.ts
2956
3348
  var registryPlugin = ({ sdk, context }) => {
2957
3349
  const metaKeys = Object.keys(context.meta || {});
@@ -2981,10 +3373,16 @@ var registryPlugin = ({ sdk, context }) => {
2981
3373
  }
2982
3374
  };
2983
3375
  const functions = metaKeys.filter((key) => typeof sdk[key] === "function").map((key) => {
3376
+ const meta = context.meta[key];
2984
3377
  return {
2985
- ...context.meta[key],
2986
- categories: context.meta[key].categories || [],
2987
- name: key
3378
+ name: key,
3379
+ type: meta.type,
3380
+ itemType: meta.itemType,
3381
+ returnType: meta.returnType,
3382
+ inputSchema: meta.inputSchema,
3383
+ outputSchema: meta.outputSchema,
3384
+ categories: meta.categories || [],
3385
+ resolvers: meta.resolvers
2988
3386
  };
2989
3387
  }).sort((a, b) => a.name.localeCompare(b.name));
2990
3388
  const knownCategories = Object.keys(categoryDefinitions);
@@ -3018,52 +3416,43 @@ var registryPlugin = ({ sdk, context }) => {
3018
3416
  getRegistry
3019
3417
  };
3020
3418
  };
3021
- var InputFieldChoiceItemSchema = withFormatter(
3022
- zod.z.object({
3023
- key: zod.z.string().optional().describe("Unique key/value for the choice"),
3024
- label: zod.z.string().optional().describe("Human readable label for the choice"),
3025
- sample: zod.z.string().optional().describe("Sample value for the choice"),
3026
- value: zod.z.string().optional().describe("Value to be submitted when selected")
3027
- }),
3028
- {
3029
- format: (item) => {
3030
- const title = item.label || item.key || "Choice";
3031
- const subtitle = item.label && item.key && item.label !== item.key ? `(${item.key})` : void 0;
3032
- const details = [];
3033
- if (item.sample && item.sample !== item.key) {
3034
- details.push({ text: `Sample: ${item.sample}`, style: "dim" });
3035
- }
3036
- if (item.value && item.value !== item.key) {
3037
- details.push({ text: `Value: ${item.value}`, style: "normal" });
3038
- }
3039
- return {
3040
- title,
3041
- subtitle,
3042
- details
3043
- };
3419
+ var InputFieldChoiceItemSchema = withFormatter(NeedChoicesSchema, {
3420
+ format: (item) => {
3421
+ const title = item.label || item.key || "Choice";
3422
+ const details = [];
3423
+ if (item.label && item.key && item.label !== item.key) {
3424
+ details.push({ text: `Key: ${item.key}`, style: "dim" });
3425
+ }
3426
+ if (item.sample && item.sample !== item.key) {
3427
+ details.push({ text: `Sample: ${item.sample}`, style: "dim" });
3428
+ }
3429
+ if (item.value && item.value !== item.key) {
3430
+ details.push({ text: `Value: ${item.value}`, style: "normal" });
3044
3431
  }
3432
+ return {
3433
+ title,
3434
+ key: item.key,
3435
+ details
3436
+ };
3045
3437
  }
3046
- );
3047
- var ListInputFieldChoicesSchema = withOutputSchema(
3048
- zod.z.object({
3049
- // Required action identification
3050
- appKey: AppKeyPropertySchema,
3051
- actionType: ActionTypePropertySchema,
3052
- actionKey: ActionKeyPropertySchema,
3053
- // Input field specification
3054
- inputFieldKey: zod.z.string().min(1).describe("Input field key to get choices for."),
3055
- // Common parameters
3056
- authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
3057
- inputs: InputsPropertySchema.optional().describe(
3058
- "Current input values that may affect available choices"
3059
- ),
3060
- page: zod.z.number().int().min(0).optional().describe("Page number for paginated results"),
3061
- // Pagination options (SDK-level)
3062
- pageSize: zod.z.number().min(1).optional().describe("Number of choices per page"),
3063
- maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
3064
- }).describe("Get the available choices for a dynamic dropdown input field"),
3065
- InputFieldChoiceItemSchema
3066
- );
3438
+ });
3439
+ var ListInputFieldChoicesSchema = zod.z.object({
3440
+ // Required action identification
3441
+ appKey: AppKeyPropertySchema,
3442
+ actionType: ActionTypePropertySchema,
3443
+ actionKey: ActionKeyPropertySchema,
3444
+ // Input field specification
3445
+ inputFieldKey: zod.z.string().min(1).describe("Input field key to get choices for."),
3446
+ // Common parameters
3447
+ authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
3448
+ inputs: InputsPropertySchema.optional().describe(
3449
+ "Current input values that may affect available choices"
3450
+ ),
3451
+ page: zod.z.number().int().min(0).optional().describe("Page number for paginated results"),
3452
+ // Pagination options (SDK-level)
3453
+ pageSize: zod.z.number().min(1).optional().describe("Number of choices per page"),
3454
+ maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
3455
+ }).describe("Get the available choices for a dynamic dropdown input field");
3067
3456
 
3068
3457
  // src/plugins/listInputFieldChoices/index.ts
3069
3458
  function transformNeedChoicesToInputFieldChoiceItem(choice) {
@@ -3117,7 +3506,7 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
3117
3506
  transformNeedChoicesToInputFieldChoiceItem
3118
3507
  );
3119
3508
  let nextCursor;
3120
- if (choicesData.next_page !== void 0) {
3509
+ if (choicesData.next_page != null) {
3121
3510
  nextCursor = choicesData.next_page.toString();
3122
3511
  } else if (choicesData.links?.next) {
3123
3512
  try {
@@ -3141,7 +3530,18 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
3141
3530
  meta: {
3142
3531
  listInputFieldChoices: {
3143
3532
  categories: ["action"],
3144
- inputSchema: ListInputFieldChoicesSchema
3533
+ type: "list",
3534
+ itemType: "InputFieldChoice",
3535
+ inputSchema: ListInputFieldChoicesSchema,
3536
+ outputSchema: InputFieldChoiceItemSchema,
3537
+ resolvers: {
3538
+ appKey: appKeyResolver,
3539
+ actionType: actionTypeResolver,
3540
+ actionKey: actionKeyResolver,
3541
+ authenticationId: authenticationIdResolver,
3542
+ inputFieldKey: inputFieldKeyResolver,
3543
+ inputs: inputsAllOptionalResolver
3544
+ }
3145
3545
  }
3146
3546
  }
3147
3547
  }
@@ -3197,7 +3597,7 @@ function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} })
3197
3597
  };
3198
3598
  }
3199
3599
  function createZapierSdkWithoutRegistry(options = {}) {
3200
- 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);
3600
+ 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);
3201
3601
  }
3202
3602
  function createZapierSdk(options = {}) {
3203
3603
  return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
@@ -3207,6 +3607,7 @@ exports.ActionKeyPropertySchema = ActionKeyPropertySchema;
3207
3607
  exports.ActionTypePropertySchema = ActionTypePropertySchema;
3208
3608
  exports.AppKeyPropertySchema = AppKeyPropertySchema;
3209
3609
  exports.AuthenticationIdPropertySchema = AuthenticationIdPropertySchema;
3610
+ exports.DEFAULT_CONFIG_PATH = DEFAULT_CONFIG_PATH;
3210
3611
  exports.DebugPropertySchema = DebugPropertySchema;
3211
3612
  exports.InputsPropertySchema = InputsPropertySchema;
3212
3613
  exports.LimitPropertySchema = LimitPropertySchema;
@@ -3232,6 +3633,7 @@ exports.actionTypeResolver = actionTypeResolver;
3232
3633
  exports.apiPlugin = apiPlugin;
3233
3634
  exports.appKeyResolver = appKeyResolver;
3234
3635
  exports.appsPlugin = appsPlugin;
3636
+ exports.authenticationIdGenericResolver = authenticationIdGenericResolver;
3235
3637
  exports.authenticationIdResolver = authenticationIdResolver;
3236
3638
  exports.createFunction = createFunction;
3237
3639
  exports.createSdk = createSdk;
@@ -3239,31 +3641,27 @@ exports.createZapierSdk = createZapierSdk;
3239
3641
  exports.createZapierSdkWithoutRegistry = createZapierSdkWithoutRegistry;
3240
3642
  exports.fetchPlugin = fetchPlugin;
3241
3643
  exports.findFirstAuthenticationPlugin = findFirstAuthenticationPlugin;
3644
+ exports.findManifestEntry = findManifestEntry;
3242
3645
  exports.findUniqueAuthenticationPlugin = findUniqueAuthenticationPlugin;
3243
3646
  exports.formatErrorMessage = formatErrorMessage;
3244
3647
  exports.getActionPlugin = getActionPlugin;
3245
3648
  exports.getAppPlugin = getAppPlugin;
3246
3649
  exports.getAuthenticationPlugin = getAuthenticationPlugin;
3650
+ exports.getPreferredManifestEntryKey = getPreferredManifestEntryKey;
3247
3651
  exports.getProfilePlugin = getProfilePlugin;
3248
- exports.getResolutionOrder = getResolutionOrder;
3249
- exports.getResolutionOrderForParams = getResolutionOrderForParams;
3250
- exports.getResolvableParams = getResolvableParams;
3251
- exports.getResolver = getResolver;
3252
- exports.getResolversForMissingParams = getResolversForMissingParams;
3253
3652
  exports.getTokenFromCliLogin = getTokenFromCliLogin;
3254
3653
  exports.getTokenFromEnv = getTokenFromEnv;
3255
3654
  exports.getTokenFromEnvOrConfig = getTokenFromEnvOrConfig;
3256
- exports.hasResolver = hasResolver;
3655
+ exports.inputFieldKeyResolver = inputFieldKeyResolver;
3656
+ exports.inputsAllOptionalResolver = inputsAllOptionalResolver;
3257
3657
  exports.inputsResolver = inputsResolver;
3258
3658
  exports.isPositional = isPositional;
3259
3659
  exports.listActionsPlugin = listActionsPlugin;
3260
3660
  exports.listAppsPlugin = listAppsPlugin;
3261
3661
  exports.listAuthenticationsPlugin = listAuthenticationsPlugin;
3262
3662
  exports.listInputFieldsPlugin = listInputFieldsPlugin;
3263
- exports.loadManifestFromFile = loadManifestFromFile;
3264
- exports.lockVersionPlugin = lockVersionPlugin;
3265
3663
  exports.manifestPlugin = manifestPlugin;
3664
+ exports.readManifestFromFile = readManifestFromFile;
3266
3665
  exports.registryPlugin = registryPlugin;
3267
3666
  exports.requestPlugin = requestPlugin;
3268
- exports.resolverRegistry = resolverRegistry;
3269
3667
  exports.runActionPlugin = runActionPlugin;