@zapier/zapier-sdk 0.9.0 → 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 (174) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +7 -7
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +14 -0
  5. package/dist/api/debug.d.ts +1 -0
  6. package/dist/api/debug.d.ts.map +1 -1
  7. package/dist/api/debug.js +42 -1
  8. package/dist/api/debug.test.d.ts +2 -0
  9. package/dist/api/debug.test.d.ts.map +1 -0
  10. package/dist/api/debug.test.js +59 -0
  11. package/dist/api/schemas.d.ts +451 -251
  12. package/dist/api/schemas.d.ts.map +1 -1
  13. package/dist/api/schemas.js +51 -29
  14. package/dist/index.cjs +834 -563
  15. package/dist/index.d.mts +2287 -2085
  16. package/dist/index.d.ts +2 -3
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +2 -3
  19. package/dist/index.mjs +832 -557
  20. package/dist/plugins/findFirstAuthentication/index.d.ts +1 -1
  21. package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
  22. package/dist/plugins/findFirstAuthentication/index.js +9 -1
  23. package/dist/plugins/findFirstAuthentication/index.test.js +3 -4
  24. package/dist/plugins/findFirstAuthentication/schemas.d.ts +5 -3
  25. package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -1
  26. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
  27. package/dist/plugins/findUniqueAuthentication/index.js +4 -0
  28. package/dist/plugins/findUniqueAuthentication/schemas.d.ts +5 -3
  29. package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -1
  30. package/dist/plugins/getAction/index.d.ts.map +1 -1
  31. package/dist/plugins/getAction/index.js +10 -0
  32. package/dist/plugins/getAction/schemas.d.ts +5 -3
  33. package/dist/plugins/getAction/schemas.d.ts.map +1 -1
  34. package/dist/plugins/getApp/index.d.ts.map +1 -1
  35. package/dist/plugins/getApp/index.js +8 -0
  36. package/dist/plugins/getApp/index.test.js +2 -2
  37. package/dist/plugins/getApp/schemas.d.ts +3 -1
  38. package/dist/plugins/getApp/schemas.d.ts.map +1 -1
  39. package/dist/plugins/getApp/schemas.js +2 -4
  40. package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
  41. package/dist/plugins/getAuthentication/index.js +8 -0
  42. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  43. package/dist/plugins/getProfile/index.js +4 -0
  44. package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
  45. package/dist/plugins/getProfile/schemas.js +4 -3
  46. package/dist/plugins/listActions/index.d.ts.map +1 -1
  47. package/dist/plugins/listActions/index.js +9 -0
  48. package/dist/plugins/listActions/schemas.d.ts +5 -3
  49. package/dist/plugins/listActions/schemas.d.ts.map +1 -1
  50. package/dist/plugins/listActions/schemas.js +2 -4
  51. package/dist/plugins/listApps/index.d.ts.map +1 -1
  52. package/dist/plugins/listApps/index.js +4 -0
  53. package/dist/plugins/listApps/index.test.js +1 -1
  54. package/dist/plugins/listApps/schemas.d.ts.map +1 -1
  55. package/dist/plugins/listApps/schemas.js +3 -9
  56. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  57. package/dist/plugins/listAuthentications/index.js +8 -0
  58. package/dist/plugins/listAuthentications/schemas.d.ts +5 -3
  59. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
  60. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  61. package/dist/plugins/listInputFieldChoices/index.js +14 -2
  62. package/dist/plugins/listInputFieldChoices/schemas.d.ts +5 -3
  63. package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
  64. package/dist/plugins/listInputFieldChoices/schemas.js +10 -19
  65. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  66. package/dist/plugins/listInputFields/index.js +14 -2
  67. package/dist/plugins/listInputFields/index.test.js +5 -9
  68. package/dist/plugins/listInputFields/schemas.d.ts +5 -3
  69. package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
  70. package/dist/plugins/registry/index.d.ts.map +1 -1
  71. package/dist/plugins/registry/index.js +8 -2
  72. package/dist/plugins/request/index.d.ts.map +1 -1
  73. package/dist/plugins/request/index.js +1 -0
  74. package/dist/plugins/runAction/index.d.ts.map +1 -1
  75. package/dist/plugins/runAction/index.js +12 -0
  76. package/dist/plugins/runAction/schemas.d.ts +5 -3
  77. package/dist/plugins/runAction/schemas.d.ts.map +1 -1
  78. package/dist/resolvers/actionKey.d.ts +13 -7
  79. package/dist/resolvers/actionKey.d.ts.map +1 -1
  80. package/dist/resolvers/actionType.d.ts +8 -7
  81. package/dist/resolvers/actionType.d.ts.map +1 -1
  82. package/dist/resolvers/appKey.d.ts +2 -6
  83. package/dist/resolvers/appKey.d.ts.map +1 -1
  84. package/dist/resolvers/authenticationId.d.ts +7 -7
  85. package/dist/resolvers/authenticationId.d.ts.map +1 -1
  86. package/dist/resolvers/authenticationId.js +16 -7
  87. package/dist/resolvers/index.d.ts +3 -35
  88. package/dist/resolvers/index.d.ts.map +1 -1
  89. package/dist/resolvers/index.js +4 -87
  90. package/dist/resolvers/inputFieldKey.d.ts +11 -0
  91. package/dist/resolvers/inputFieldKey.d.ts.map +1 -0
  92. package/dist/resolvers/inputFieldKey.js +23 -0
  93. package/dist/resolvers/inputs.d.ts +11 -6
  94. package/dist/resolvers/inputs.d.ts.map +1 -1
  95. package/dist/resolvers/inputs.js +17 -0
  96. package/dist/schemas/Action.d.ts +8 -8
  97. package/dist/schemas/Action.d.ts.map +1 -1
  98. package/dist/schemas/Action.js +8 -3
  99. package/dist/schemas/App.d.ts +183 -11
  100. package/dist/schemas/App.d.ts.map +1 -1
  101. package/dist/schemas/App.js +7 -9
  102. package/dist/schemas/Auth.d.ts +12 -12
  103. package/dist/schemas/Auth.js +1 -1
  104. package/dist/schemas/Field.d.ts +5 -98
  105. package/dist/schemas/Field.d.ts.map +1 -1
  106. package/dist/schemas/Field.js +24 -52
  107. package/dist/schemas/Run.d.ts +3 -0
  108. package/dist/schemas/Run.d.ts.map +1 -0
  109. package/dist/schemas/Run.js +31 -0
  110. package/dist/schemas/UserProfile.d.ts +11 -11
  111. package/dist/schemas/UserProfile.d.ts.map +1 -1
  112. package/dist/schemas/UserProfile.js +21 -7
  113. package/dist/sdk.d.ts +11 -4
  114. package/dist/sdk.d.ts.map +1 -1
  115. package/dist/types/plugin.d.ts +5 -0
  116. package/dist/types/plugin.d.ts.map +1 -1
  117. package/dist/types/properties.d.ts +3 -1
  118. package/dist/types/properties.d.ts.map +1 -1
  119. package/dist/types/sdk.d.ts +5 -0
  120. package/dist/types/sdk.d.ts.map +1 -1
  121. package/dist/utils/domain-utils.d.ts +1 -16
  122. package/dist/utils/domain-utils.d.ts.map +1 -1
  123. package/dist/utils/domain-utils.js +7 -51
  124. package/dist/utils/schema-utils.d.ts +44 -21
  125. package/dist/utils/schema-utils.d.ts.map +1 -1
  126. package/dist/utils/schema-utils.js +17 -11
  127. package/package.json +1 -1
  128. package/src/api/client.ts +12 -0
  129. package/src/api/debug.test.ts +76 -0
  130. package/src/api/debug.ts +46 -2
  131. package/src/api/schemas.ts +51 -29
  132. package/src/index.ts +4 -5
  133. package/src/plugins/findFirstAuthentication/index.test.ts +8 -5
  134. package/src/plugins/findFirstAuthentication/index.ts +14 -2
  135. package/src/plugins/findUniqueAuthentication/index.ts +4 -0
  136. package/src/plugins/getAction/index.ts +14 -0
  137. package/src/plugins/getApp/index.test.ts +2 -2
  138. package/src/plugins/getApp/index.ts +8 -0
  139. package/src/plugins/getApp/schemas.ts +7 -12
  140. package/src/plugins/getAuthentication/index.ts +8 -0
  141. package/src/plugins/getProfile/index.ts +4 -0
  142. package/src/plugins/getProfile/schemas.ts +4 -6
  143. package/src/plugins/listActions/index.ts +9 -0
  144. package/src/plugins/listActions/schemas.ts +20 -25
  145. package/src/plugins/listApps/index.test.ts +1 -1
  146. package/src/plugins/listApps/index.ts +4 -0
  147. package/src/plugins/listApps/schemas.ts +17 -26
  148. package/src/plugins/listAuthentications/index.ts +8 -0
  149. package/src/plugins/listInputFieldChoices/index.ts +21 -1
  150. package/src/plugins/listInputFieldChoices/schemas.ts +61 -76
  151. package/src/plugins/listInputFields/index.test.ts +5 -9
  152. package/src/plugins/listInputFields/index.ts +20 -2
  153. package/src/plugins/registry/index.ts +8 -2
  154. package/src/plugins/request/index.ts +1 -0
  155. package/src/plugins/runAction/index.ts +18 -0
  156. package/src/resolvers/actionKey.ts +15 -13
  157. package/src/resolvers/actionType.ts +10 -12
  158. package/src/resolvers/appKey.ts +2 -6
  159. package/src/resolvers/authenticationId.ts +25 -19
  160. package/src/resolvers/index.ts +7 -113
  161. package/src/resolvers/inputFieldKey.ts +38 -0
  162. package/src/resolvers/inputs.ts +28 -10
  163. package/src/schemas/Action.ts +8 -3
  164. package/src/schemas/App.ts +7 -9
  165. package/src/schemas/Auth.ts +1 -1
  166. package/src/schemas/Field.ts +24 -57
  167. package/src/schemas/Run.ts +40 -0
  168. package/src/schemas/UserProfile.ts +24 -7
  169. package/src/sdk.ts +17 -7
  170. package/src/types/plugin.ts +5 -0
  171. package/src/types/sdk.ts +5 -0
  172. package/src/utils/domain-utils.ts +9 -67
  173. package/src/utils/schema-utils.ts +96 -44
  174. package/tsconfig.tsbuildinfo +1 -1
@@ -11,6 +11,14 @@ import { ZapierConfigurationError, ZapierApiError } from "../../types/errors";
11
11
  import { createPaginatedFunction } from "../../utils/function-utils";
12
12
  import type { GetAppPluginProvides } from "../getApp";
13
13
  import type { GetVersionedImplementationId } from "../manifest/schemas";
14
+ import {
15
+ appKeyResolver,
16
+ actionTypeResolver,
17
+ actionKeyResolver,
18
+ authenticationIdResolver,
19
+ inputsAllOptionalResolver,
20
+ } from "../../resolvers";
21
+ import { InputFieldItemSchema } from "../../schemas/Field";
14
22
 
15
23
  // Enums for input field transformation
16
24
  enum InputFieldType {
@@ -93,8 +101,8 @@ function transformNeedToInputFieldItem(need: Need): InputFieldItem {
93
101
  const itemsType = getItemsTypeFromNeed(need);
94
102
 
95
103
  return {
96
- ...need, // Pass through all original Need fields
97
- id: need.key,
104
+ // Only the final computed/mapped fields that are in InputFieldItemSchema
105
+ key: need.key,
98
106
  default_value: need.default || "",
99
107
  depends_on: need.depends_on || [],
100
108
  description: need.help_text || "",
@@ -200,7 +208,17 @@ export const listInputFieldsPlugin: Plugin<
200
208
  meta: {
201
209
  listInputFields: {
202
210
  categories: ["action"],
211
+ type: "list",
212
+ itemType: "InputField",
203
213
  inputSchema: ListInputFieldsSchema,
214
+ outputSchema: InputFieldItemSchema,
215
+ resolvers: {
216
+ appKey: appKeyResolver,
217
+ actionType: actionTypeResolver,
218
+ actionKey: actionKeyResolver,
219
+ authenticationId: authenticationIdResolver,
220
+ inputs: inputsAllOptionalResolver,
221
+ },
204
222
  },
205
223
  },
206
224
  },
@@ -55,10 +55,16 @@ export const registryPlugin: Plugin<
55
55
  const functions = metaKeys
56
56
  .filter((key) => typeof sdk[key as keyof typeof sdk] === "function")
57
57
  .map((key) => {
58
+ const meta = context.meta[key];
58
59
  return {
59
- ...context.meta[key],
60
- categories: context.meta[key].categories || [],
61
60
  name: key,
61
+ type: meta.type,
62
+ itemType: meta.itemType,
63
+ returnType: meta.returnType,
64
+ inputSchema: meta.inputSchema,
65
+ outputSchema: meta.outputSchema,
66
+ categories: meta.categories || [],
67
+ resolvers: meta.resolvers,
62
68
  };
63
69
  })
64
70
  .sort((a, b) => a.name.localeCompare(b.name));
@@ -96,6 +96,7 @@ export const requestPlugin: Plugin<
96
96
  meta: {
97
97
  request: {
98
98
  categories: ["http"],
99
+ returnType: "Response",
99
100
  inputSchema: RelayRequestSchema,
100
101
  },
101
102
  },
@@ -5,6 +5,7 @@ import {
5
5
  type RunActionOptions,
6
6
  type RunActionPage,
7
7
  } from "./schemas";
8
+ import { ActionResultItemSchema } from "../../schemas/Run";
8
9
  import {
9
10
  ZapierValidationError,
10
11
  ZapierConfigurationError,
@@ -13,6 +14,13 @@ import {
13
14
  import { createPaginatedFunction } from "../../utils/function-utils";
14
15
  import type { GetActionPluginProvides } from "../getAction";
15
16
  import type { GetAppPluginProvides } from "../getApp";
17
+ import {
18
+ appKeyResolver,
19
+ actionTypeResolver,
20
+ actionKeyResolver,
21
+ authenticationIdResolver,
22
+ inputsResolver,
23
+ } from "../../resolvers";
16
24
  import type { GetVersionedImplementationId } from "../manifest/schemas";
17
25
 
18
26
  export interface RunActionPluginProvides {
@@ -177,7 +185,17 @@ export const runActionPlugin: Plugin<
177
185
  meta: {
178
186
  runAction: {
179
187
  categories: ["action"],
188
+ type: "list",
189
+ itemType: "ActionResult",
180
190
  inputSchema: RunActionSchema,
191
+ outputSchema: ActionResultItemSchema,
192
+ resolvers: {
193
+ appKey: appKeyResolver,
194
+ actionType: actionTypeResolver,
195
+ actionKey: actionKeyResolver,
196
+ authenticationId: authenticationIdResolver,
197
+ inputs: inputsResolver,
198
+ },
181
199
  },
182
200
  },
183
201
  },
@@ -1,27 +1,29 @@
1
- import type { ZapierSdk } from "../types/sdk";
1
+ import type { DynamicResolver } from "../utils/schema-utils";
2
+ import type { ActionTypeProperty } from "../types/properties";
2
3
 
3
- export interface ActionKeyResolver {
4
- type: "dynamic";
5
- depends: readonly string[];
6
- fetch: (
7
- sdk: ZapierSdk,
8
- resolvedParams: Record<string, any>,
9
- ) => Promise<any[]>;
10
- prompt: (items: any[], params: Record<string, any>) => any;
4
+ interface ActionItem {
5
+ key: string;
6
+ title?: string;
7
+ name?: string;
8
+ description?: string;
9
+ action_type: string;
11
10
  }
12
11
 
13
- export const actionKeyResolver: ActionKeyResolver = {
12
+ export const actionKeyResolver: DynamicResolver<
13
+ ActionItem,
14
+ { appKey: string; actionType: ActionTypeProperty }
15
+ > = {
14
16
  type: "dynamic",
15
17
  depends: ["appKey", "actionType"] as const,
16
- fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
18
+ fetch: async (sdk, resolvedParams) => {
17
19
  const actionsResponse = await sdk.listActions({
18
20
  appKey: resolvedParams.appKey,
19
21
  });
20
22
  return actionsResponse.data.filter(
21
- (action: any) => action.action_type === resolvedParams.actionType,
23
+ (action: ActionItem) => action.action_type === resolvedParams.actionType,
22
24
  );
23
25
  },
24
- prompt: (actions: any[]) => ({
26
+ prompt: (actions) => ({
25
27
  type: "list",
26
28
  name: "actionKey",
27
29
  message: "Select action:",
@@ -1,19 +1,17 @@
1
- import type { ZapierSdk } from "../types/sdk";
1
+ import type { DynamicResolver } from "../utils/schema-utils";
2
2
 
3
- export interface ActionTypeResolver {
4
- type: "dynamic";
5
- depends: readonly string[];
6
- fetch: (
7
- sdk: ZapierSdk,
8
- resolvedParams: Record<string, any>,
9
- ) => Promise<any[]>;
10
- prompt: (items: any[], params: Record<string, any>) => any;
3
+ interface ActionTypeItem {
4
+ key: string;
5
+ name: string;
11
6
  }
12
7
 
13
- export const actionTypeResolver: ActionTypeResolver = {
8
+ export const actionTypeResolver: DynamicResolver<
9
+ ActionTypeItem,
10
+ { appKey: string }
11
+ > = {
14
12
  type: "dynamic",
15
13
  depends: ["appKey"] as const,
16
- fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
14
+ fetch: async (sdk, resolvedParams) => {
17
15
  const actionsResponse = await sdk.listActions({
18
16
  appKey: resolvedParams.appKey,
19
17
  });
@@ -23,7 +21,7 @@ export const actionTypeResolver: ActionTypeResolver = {
23
21
  ];
24
22
  return types.map((type) => ({ key: type, name: type }));
25
23
  },
26
- prompt: (types: any[]) => ({
24
+ prompt: (types) => ({
27
25
  type: "list",
28
26
  name: "actionType",
29
27
  message: "Select action type:",
@@ -1,10 +1,6 @@
1
- export interface AppKeyResolver {
2
- type: "static";
3
- inputType?: "text" | "password" | "email";
4
- placeholder?: string;
5
- }
1
+ import type { StaticResolver } from "../utils/schema-utils";
6
2
 
7
- export const appKeyResolver: AppKeyResolver = {
3
+ export const appKeyResolver: StaticResolver = {
8
4
  type: "static",
9
5
  inputType: "text",
10
6
  placeholder: "Enter app key (e.g., 'SlackCLIAPI' or slug like 'github')",
@@ -1,38 +1,38 @@
1
- import type { ZapierSdk } from "../types/sdk";
1
+ import type { DynamicResolver } from "../utils/schema-utils";
2
+ import type { AuthItem } from "../schemas/Auth";
2
3
 
3
- export interface AuthenticationIdResolver {
4
- type: "dynamic";
5
- depends: readonly string[];
6
- fetch: (
7
- sdk: ZapierSdk,
8
- resolvedParams: Record<string, any>,
9
- ) => Promise<any[]>;
10
- prompt: (items: any[], params: Record<string, any>) => any;
11
- }
4
+ type AuthenticationIdResolver = DynamicResolver<AuthItem, { appKey?: string }>;
12
5
 
13
6
  export const authenticationIdResolver: AuthenticationIdResolver = {
14
7
  type: "dynamic",
15
8
  depends: ["appKey"] as const,
16
- fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
17
- const myAuths = await sdk.listAuthentications({
18
- appKey: resolvedParams.appKey,
9
+ fetch: async (sdk, resolvedParams) => {
10
+ const listOptions: { maxItems: number; appKey?: string } = {
19
11
  maxItems: 1000,
12
+ };
13
+
14
+ if (resolvedParams.appKey) {
15
+ listOptions.appKey = resolvedParams.appKey;
16
+ }
17
+
18
+ const myAuths = await sdk.listAuthentications({
19
+ ...listOptions,
20
20
  owner: "me",
21
21
  });
22
- const allAuths = await sdk.listAuthentications({
23
- appKey: resolvedParams.appKey,
24
- maxItems: 1000,
25
- });
22
+ const allAuths = await sdk.listAuthentications(listOptions);
23
+
26
24
  // Filter out myAuths from allAuths
27
25
  const otherAuths = allAuths.data.filter(
28
26
  (auth) => !myAuths.data.some((myAuth) => myAuth.id === auth.id),
29
27
  );
30
28
  return [...myAuths.data, ...otherAuths];
31
29
  },
32
- prompt: (auths: any[], params: Record<string, any>) => ({
30
+ prompt: (auths, params) => ({
33
31
  type: "list",
34
32
  name: "authenticationId",
35
- message: `Select authentication for ${params.appKey}:`,
33
+ message: params.appKey
34
+ ? `Select authentication for ${params.appKey}:`
35
+ : "Select authentication:",
36
36
  choices: [
37
37
  ...auths.map((auth) => ({
38
38
  name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
@@ -45,3 +45,9 @@ export const authenticationIdResolver: AuthenticationIdResolver = {
45
45
  ],
46
46
  }),
47
47
  };
48
+
49
+ // Generic version without appKey dependency
50
+ export const authenticationIdGenericResolver: AuthenticationIdResolver = {
51
+ ...authenticationIdResolver,
52
+ depends: [] as const,
53
+ };
@@ -1,117 +1,11 @@
1
- import { appKeyResolver } from "./appKey";
2
- import { actionTypeResolver } from "./actionType";
3
- import { actionKeyResolver } from "./actionKey";
4
- import { authenticationIdResolver } from "./authenticationId";
5
- import { inputsResolver } from "./inputs";
6
-
7
- // Centralized resolver registry
8
- export const resolverRegistry = {
9
- appKey: appKeyResolver,
10
- actionType: actionTypeResolver,
11
- actionKey: actionKeyResolver,
12
- authenticationId: authenticationIdResolver,
13
- inputs: inputsResolver,
14
- } as const;
15
-
16
- // Type definitions
17
- export type ResolverName = keyof typeof resolverRegistry;
18
- export type ResolverType = (typeof resolverRegistry)[ResolverName];
19
-
20
- // Utility functions for working with resolvers
21
-
22
- /**
23
- * Get a resolver by name
24
- */
25
- export function getResolver(name: string): ResolverType | undefined {
26
- return resolverRegistry[name as ResolverName];
27
- }
28
-
29
- /**
30
- * Get all resolvers for a list of missing parameters
31
- */
32
- export function getResolversForMissingParams(
33
- missingParams: string[],
34
- ): Record<string, ResolverType> {
35
- const resolvers: Record<string, ResolverType> = {};
36
-
37
- for (const param of missingParams) {
38
- const resolver = resolverRegistry[param as ResolverName];
39
- if (resolver) {
40
- resolvers[param] = resolver;
41
- }
42
- }
43
-
44
- return resolvers;
45
- }
46
-
47
- /**
48
- * Check if a parameter has a resolver
49
- */
50
- export function hasResolver(paramName: string): boolean {
51
- return paramName in resolverRegistry;
52
- }
53
-
54
- /**
55
- * Get all parameter names that have resolvers
56
- */
57
- export function getResolvableParams(): string[] {
58
- return Object.keys(resolverRegistry);
59
- }
60
-
61
- /**
62
- * Resolve dependency chain for a parameter
63
- * Returns parameters in the order they need to be resolved
64
- */
65
- export function getResolutionOrder(
66
- paramName: string,
67
- resolved: Set<string> = new Set(),
68
- ): string[] {
69
- const resolver = getResolver(paramName);
70
- if (!resolver || resolver.type === "static") {
71
- return [paramName];
72
- }
73
-
74
- const order: string[] = [];
75
-
76
- if ("depends" in resolver && resolver.depends) {
77
- for (const dependency of resolver.depends) {
78
- if (!resolved.has(dependency)) {
79
- order.push(...getResolutionOrder(dependency, resolved));
80
- resolved.add(dependency);
81
- }
82
- }
83
- }
84
-
85
- if (!resolved.has(paramName)) {
86
- order.push(paramName);
87
- resolved.add(paramName);
88
- }
89
-
90
- return order;
91
- }
92
-
93
- /**
94
- * Get resolution order for multiple parameters
95
- */
96
- export function getResolutionOrderForParams(paramNames: string[]): string[] {
97
- const resolved = new Set<string>();
98
- const order: string[] = [];
99
-
100
- for (const paramName of paramNames) {
101
- const paramOrder = getResolutionOrder(paramName, resolved);
102
- for (const param of paramOrder) {
103
- if (!order.includes(param)) {
104
- order.push(param);
105
- }
106
- }
107
- }
108
-
109
- return order;
110
- }
111
-
112
- // Re-export individual resolvers for direct access if needed
1
+ // Re-export individual resolvers for plugin use
113
2
  export { appKeyResolver } from "./appKey";
114
3
  export { actionTypeResolver } from "./actionType";
115
4
  export { actionKeyResolver } from "./actionKey";
116
- export { authenticationIdResolver } from "./authenticationId";
5
+ export {
6
+ authenticationIdResolver,
7
+ authenticationIdGenericResolver,
8
+ } from "./authenticationId";
117
9
  export { inputsResolver } from "./inputs";
10
+ export { inputFieldKeyResolver } from "./inputFieldKey";
11
+ export { inputsAllOptionalResolver } from "./inputs";
@@ -0,0 +1,38 @@
1
+ import type { DynamicResolver } from "../utils/schema-utils";
2
+ import type { InputFieldItem } from "../schemas/Field";
3
+ import type { ActionTypeProperty } from "../types/properties";
4
+
5
+ export const inputFieldKeyResolver: DynamicResolver<
6
+ InputFieldItem,
7
+ {
8
+ appKey: string;
9
+ actionKey: string;
10
+ actionType: ActionTypeProperty;
11
+ authenticationId: number;
12
+ inputs?: Record<string, unknown>;
13
+ }
14
+ > = {
15
+ type: "dynamic",
16
+ depends: ["appKey", "actionKey", "actionType", "authenticationId"] as const,
17
+ fetch: async (sdk, resolvedParams) => {
18
+ const fieldsResponse = await sdk.listInputFields({
19
+ appKey: resolvedParams.appKey,
20
+ actionKey: resolvedParams.actionKey,
21
+ actionType: resolvedParams.actionType,
22
+ authenticationId: resolvedParams.authenticationId,
23
+ inputs: resolvedParams.inputs, // Pass along currently resolved inputs
24
+ });
25
+ return fieldsResponse.data;
26
+ },
27
+ prompt: (fields) => ({
28
+ type: "list",
29
+ name: "inputFieldKey",
30
+ message: "Select input field:",
31
+ choices: fields.map((field) => ({
32
+ name: `${field.title || field.key} - ${
33
+ field.value_type || "No type"
34
+ } ${field.is_required ? "(required)" : "(optional)"}`,
35
+ value: field.key,
36
+ })),
37
+ }),
38
+ };
@@ -1,18 +1,18 @@
1
- import type { ZapierSdk } from "../types/sdk";
1
+ import type { FieldsResolver } from "../utils/schema-utils";
2
+ import type { ActionTypeProperty } from "../types/properties";
2
3
 
3
- export interface InputsResolver {
4
- type: "fields";
5
- depends: readonly string[];
6
- fetch: (
7
- sdk: ZapierSdk,
8
- resolvedParams: Record<string, any>,
9
- ) => Promise<any[]>;
10
- }
4
+ type InputsResolver = FieldsResolver<{
5
+ appKey: string;
6
+ actionKey: string;
7
+ actionType: ActionTypeProperty;
8
+ authenticationId: number;
9
+ inputs?: Record<string, unknown>;
10
+ }>;
11
11
 
12
12
  export const inputsResolver: InputsResolver = {
13
13
  type: "fields",
14
14
  depends: ["appKey", "actionKey", "actionType", "authenticationId"] as const,
15
- fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
15
+ fetch: async (sdk, resolvedParams) => {
16
16
  const fieldsResponse = await sdk.listInputFields({
17
17
  appKey: resolvedParams.appKey,
18
18
  actionKey: resolvedParams.actionKey,
@@ -23,3 +23,21 @@ export const inputsResolver: InputsResolver = {
23
23
  return fieldsResponse.data;
24
24
  },
25
25
  };
26
+
27
+ export const inputsAllOptionalResolver: InputsResolver = {
28
+ type: "fields",
29
+ depends: ["appKey", "actionKey", "actionType", "authenticationId"] as const,
30
+ fetch: async (sdk, resolvedParams) => {
31
+ const fieldsResponse = await sdk.listInputFields({
32
+ appKey: resolvedParams.appKey,
33
+ actionKey: resolvedParams.actionKey,
34
+ actionType: resolvedParams.actionType,
35
+ authenticationId: resolvedParams.authenticationId,
36
+ inputs: resolvedParams.inputs, // Pass along currently resolved inputs
37
+ });
38
+ return fieldsResponse.data.map((field) => ({
39
+ ...field,
40
+ is_required: false,
41
+ }));
42
+ },
43
+ };
@@ -27,12 +27,17 @@ export const ActionItemSchema = withFormatter(
27
27
  });
28
28
  }
29
29
  if (item.description) {
30
- details.push({ text: item.description, style: "dim" as const });
30
+ details.push({
31
+ text: item.description,
32
+ style: "dim" as const,
33
+ });
31
34
  }
32
35
 
33
36
  return {
34
- title: item.title || item.name || item.key,
35
- subtitle: `(${item.key})`,
37
+ title: item.title || item.key,
38
+ id: item.id,
39
+ key: item.key,
40
+ description: item.description,
36
41
  details,
37
42
  };
38
43
  },
@@ -1,27 +1,25 @@
1
1
  import { z } from "zod";
2
2
  import { withFormatter } from "../utils/schema-utils";
3
+ import { ImplementationMetaSchema } from "../api/schemas";
3
4
 
4
5
  export { FormattedItem, FormatMetadata } from "../utils/schema-utils";
5
6
 
6
7
  // ============================================================================
7
- // App Item Schema (extends API schema with computed fields and formatting)
8
+ // App Item Schema (extends ImplementationMetaSchema with transformed fields)
8
9
  // ============================================================================
9
10
 
10
11
  export const AppItemSchema = withFormatter(
11
- z.object({
12
- // Essential properties only
12
+ ImplementationMetaSchema.omit({ name: true, id: true }).extend({
13
13
  title: z.string(), // Mapped from name
14
- key: z.string(), // Mapped from selected_api
15
- current_implementation_id: z.string(), // From id, keeps the full version
16
- version: z.string().optional(), // Extracted from implementation ID
17
- description: z.string().optional(),
18
- slug: z.string().optional(),
14
+ key: z.string(), // Extracted from id (base part without version)
15
+ implementation_id: z.string(), // Mapped from id (full versioned ID)
19
16
  }),
20
17
  {
21
18
  format: (item) => {
22
19
  return {
23
20
  title: item.title,
24
- subtitle: `(${item.key})`,
21
+ key: item.key,
22
+ description: item.description,
25
23
  details: [],
26
24
  };
27
25
  },
@@ -42,7 +42,7 @@ export const AuthenticationItemSchema = withFormatter(
42
42
 
43
43
  return {
44
44
  title: item.title || `Authentication ${item.id}`,
45
- subtitle: `(ID: ${item.id})`,
45
+ id: item.id?.toString(),
46
46
  details,
47
47
  };
48
48
  },