@zapier/zapier-sdk 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +7 -7
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +14 -0
  5. package/dist/api/debug.d.ts +1 -0
  6. package/dist/api/debug.d.ts.map +1 -1
  7. package/dist/api/debug.js +42 -1
  8. package/dist/api/debug.test.d.ts +2 -0
  9. package/dist/api/debug.test.d.ts.map +1 -0
  10. package/dist/api/debug.test.js +59 -0
  11. package/dist/api/schemas.d.ts +451 -251
  12. package/dist/api/schemas.d.ts.map +1 -1
  13. package/dist/api/schemas.js +51 -29
  14. package/dist/index.cjs +968 -582
  15. package/dist/index.d.mts +2537 -2229
  16. package/dist/index.d.ts +2 -3
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +2 -3
  19. package/dist/index.mjs +966 -576
  20. package/dist/plugins/findFirstAuthentication/index.d.ts +1 -1
  21. package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
  22. package/dist/plugins/findFirstAuthentication/index.js +9 -1
  23. package/dist/plugins/findFirstAuthentication/index.test.js +3 -4
  24. package/dist/plugins/findFirstAuthentication/schemas.d.ts +5 -3
  25. package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -1
  26. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
  27. package/dist/plugins/findUniqueAuthentication/index.js +4 -0
  28. package/dist/plugins/findUniqueAuthentication/schemas.d.ts +5 -3
  29. package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -1
  30. package/dist/plugins/getAction/index.d.ts.map +1 -1
  31. package/dist/plugins/getAction/index.js +10 -0
  32. package/dist/plugins/getAction/schemas.d.ts +5 -3
  33. package/dist/plugins/getAction/schemas.d.ts.map +1 -1
  34. package/dist/plugins/getApp/index.d.ts.map +1 -1
  35. package/dist/plugins/getApp/index.js +8 -0
  36. package/dist/plugins/getApp/index.test.js +2 -2
  37. package/dist/plugins/getApp/schemas.d.ts +3 -1
  38. package/dist/plugins/getApp/schemas.d.ts.map +1 -1
  39. package/dist/plugins/getApp/schemas.js +2 -4
  40. package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
  41. package/dist/plugins/getAuthentication/index.js +8 -0
  42. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  43. package/dist/plugins/getProfile/index.js +4 -0
  44. package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
  45. package/dist/plugins/getProfile/schemas.js +4 -3
  46. package/dist/plugins/listActions/index.d.ts.map +1 -1
  47. package/dist/plugins/listActions/index.js +9 -0
  48. package/dist/plugins/listActions/schemas.d.ts +5 -3
  49. package/dist/plugins/listActions/schemas.d.ts.map +1 -1
  50. package/dist/plugins/listActions/schemas.js +2 -4
  51. package/dist/plugins/listApps/index.d.ts.map +1 -1
  52. package/dist/plugins/listApps/index.js +4 -0
  53. package/dist/plugins/listApps/index.test.js +1 -1
  54. package/dist/plugins/listApps/schemas.d.ts.map +1 -1
  55. package/dist/plugins/listApps/schemas.js +3 -9
  56. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  57. package/dist/plugins/listAuthentications/index.js +8 -0
  58. package/dist/plugins/listAuthentications/schemas.d.ts +5 -3
  59. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
  60. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  61. package/dist/plugins/listInputFieldChoices/index.js +14 -2
  62. package/dist/plugins/listInputFieldChoices/schemas.d.ts +5 -3
  63. package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
  64. package/dist/plugins/listInputFieldChoices/schemas.js +10 -19
  65. package/dist/plugins/listInputFields/index.d.ts +4 -4
  66. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  67. package/dist/plugins/listInputFields/index.js +71 -5
  68. package/dist/plugins/listInputFields/index.test.js +5 -9
  69. package/dist/plugins/listInputFields/schemas.d.ts +8 -6
  70. package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
  71. package/dist/plugins/registry/index.d.ts.map +1 -1
  72. package/dist/plugins/registry/index.js +8 -2
  73. package/dist/plugins/request/index.d.ts.map +1 -1
  74. package/dist/plugins/request/index.js +1 -0
  75. package/dist/plugins/runAction/index.d.ts.map +1 -1
  76. package/dist/plugins/runAction/index.js +12 -0
  77. package/dist/plugins/runAction/schemas.d.ts +5 -3
  78. package/dist/plugins/runAction/schemas.d.ts.map +1 -1
  79. package/dist/resolvers/actionKey.d.ts +13 -7
  80. package/dist/resolvers/actionKey.d.ts.map +1 -1
  81. package/dist/resolvers/actionType.d.ts +8 -7
  82. package/dist/resolvers/actionType.d.ts.map +1 -1
  83. package/dist/resolvers/appKey.d.ts +2 -6
  84. package/dist/resolvers/appKey.d.ts.map +1 -1
  85. package/dist/resolvers/authenticationId.d.ts +7 -7
  86. package/dist/resolvers/authenticationId.d.ts.map +1 -1
  87. package/dist/resolvers/authenticationId.js +16 -7
  88. package/dist/resolvers/index.d.ts +3 -35
  89. package/dist/resolvers/index.d.ts.map +1 -1
  90. package/dist/resolvers/index.js +4 -87
  91. package/dist/resolvers/inputFieldKey.d.ts +11 -0
  92. package/dist/resolvers/inputFieldKey.d.ts.map +1 -0
  93. package/dist/resolvers/inputFieldKey.js +47 -0
  94. package/dist/resolvers/inputs.d.ts +13 -4
  95. package/dist/resolvers/inputs.d.ts.map +1 -1
  96. package/dist/resolvers/inputs.js +36 -0
  97. package/dist/schemas/Action.d.ts +8 -8
  98. package/dist/schemas/Action.d.ts.map +1 -1
  99. package/dist/schemas/Action.js +8 -3
  100. package/dist/schemas/App.d.ts +183 -11
  101. package/dist/schemas/App.d.ts.map +1 -1
  102. package/dist/schemas/App.js +7 -9
  103. package/dist/schemas/Auth.d.ts +12 -12
  104. package/dist/schemas/Auth.js +1 -1
  105. package/dist/schemas/Field.d.ts +112 -97
  106. package/dist/schemas/Field.d.ts.map +1 -1
  107. package/dist/schemas/Field.js +63 -52
  108. package/dist/schemas/Run.d.ts +3 -0
  109. package/dist/schemas/Run.d.ts.map +1 -0
  110. package/dist/schemas/Run.js +31 -0
  111. package/dist/schemas/UserProfile.d.ts +11 -11
  112. package/dist/schemas/UserProfile.d.ts.map +1 -1
  113. package/dist/schemas/UserProfile.js +21 -7
  114. package/dist/sdk.d.ts +11 -4
  115. package/dist/sdk.d.ts.map +1 -1
  116. package/dist/types/domain.d.ts +17 -1
  117. package/dist/types/domain.d.ts.map +1 -1
  118. package/dist/types/plugin.d.ts +5 -0
  119. package/dist/types/plugin.d.ts.map +1 -1
  120. package/dist/types/properties.d.ts +3 -1
  121. package/dist/types/properties.d.ts.map +1 -1
  122. package/dist/types/sdk.d.ts +5 -0
  123. package/dist/types/sdk.d.ts.map +1 -1
  124. package/dist/utils/domain-utils.d.ts +1 -16
  125. package/dist/utils/domain-utils.d.ts.map +1 -1
  126. package/dist/utils/domain-utils.js +7 -51
  127. package/dist/utils/schema-utils.d.ts +44 -21
  128. package/dist/utils/schema-utils.d.ts.map +1 -1
  129. package/dist/utils/schema-utils.js +17 -11
  130. package/dist/utils/string-utils.d.ts +12 -0
  131. package/dist/utils/string-utils.d.ts.map +1 -0
  132. package/dist/utils/string-utils.js +23 -0
  133. package/dist/utils/string-utils.test.d.ts +2 -0
  134. package/dist/utils/string-utils.test.d.ts.map +1 -0
  135. package/dist/utils/string-utils.test.js +36 -0
  136. package/package.json +1 -1
  137. package/src/api/client.ts +12 -0
  138. package/src/api/debug.test.ts +76 -0
  139. package/src/api/debug.ts +46 -2
  140. package/src/api/schemas.ts +51 -29
  141. package/src/index.ts +4 -5
  142. package/src/plugins/findFirstAuthentication/index.test.ts +8 -5
  143. package/src/plugins/findFirstAuthentication/index.ts +14 -2
  144. package/src/plugins/findUniqueAuthentication/index.ts +4 -0
  145. package/src/plugins/getAction/index.ts +14 -0
  146. package/src/plugins/getApp/index.test.ts +2 -2
  147. package/src/plugins/getApp/index.ts +8 -0
  148. package/src/plugins/getApp/schemas.ts +7 -12
  149. package/src/plugins/getAuthentication/index.ts +8 -0
  150. package/src/plugins/getProfile/index.ts +4 -0
  151. package/src/plugins/getProfile/schemas.ts +4 -6
  152. package/src/plugins/listActions/index.ts +9 -0
  153. package/src/plugins/listActions/schemas.ts +20 -25
  154. package/src/plugins/listApps/index.test.ts +1 -1
  155. package/src/plugins/listApps/index.ts +4 -0
  156. package/src/plugins/listApps/schemas.ts +17 -26
  157. package/src/plugins/listAuthentications/index.ts +8 -0
  158. package/src/plugins/listInputFieldChoices/index.ts +21 -1
  159. package/src/plugins/listInputFieldChoices/schemas.ts +61 -76
  160. package/src/plugins/listInputFields/index.test.ts +5 -9
  161. package/src/plugins/listInputFields/index.ts +89 -11
  162. package/src/plugins/listInputFields/schemas.ts +6 -3
  163. package/src/plugins/registry/index.ts +8 -2
  164. package/src/plugins/request/index.ts +1 -0
  165. package/src/plugins/runAction/index.ts +18 -0
  166. package/src/resolvers/actionKey.ts +15 -13
  167. package/src/resolvers/actionType.ts +10 -12
  168. package/src/resolvers/appKey.ts +2 -6
  169. package/src/resolvers/authenticationId.ts +25 -19
  170. package/src/resolvers/index.ts +7 -113
  171. package/src/resolvers/inputFieldKey.ts +70 -0
  172. package/src/resolvers/inputs.ts +51 -7
  173. package/src/schemas/Action.ts +8 -3
  174. package/src/schemas/App.ts +7 -9
  175. package/src/schemas/Auth.ts +1 -1
  176. package/src/schemas/Field.ts +97 -60
  177. package/src/schemas/Run.ts +40 -0
  178. package/src/schemas/UserProfile.ts +24 -7
  179. package/src/sdk.ts +17 -7
  180. package/src/types/domain.ts +24 -1
  181. package/src/types/plugin.ts +5 -0
  182. package/src/types/sdk.ts +5 -0
  183. package/src/utils/domain-utils.ts +9 -67
  184. package/src/utils/schema-utils.ts +96 -44
  185. package/src/utils/string-utils.test.ts +45 -0
  186. package/src/utils/string-utils.ts +26 -0
  187. package/tsconfig.tsbuildinfo +1 -1
@@ -3,6 +3,7 @@ import { createPaginatedFunction } from "../../utils/function-utils";
3
3
  import { ListAppsSchema } from "./schemas";
4
4
  import type { ListAppsOptions, ListAppsPage } from "./schemas";
5
5
  import type { AppItem } from "../../types/domain";
6
+ import { AppItemSchema } from "../../schemas/App";
6
7
  import type { ResolvedAppLocator } from "../../utils/domain-utils";
7
8
  import {
8
9
  normalizeImplementationMetaToAppItem,
@@ -135,7 +136,10 @@ export const listAppsPlugin: Plugin<
135
136
  meta: {
136
137
  listApps: {
137
138
  categories: ["app"],
139
+ type: "list",
140
+ itemType: "App",
138
141
  inputSchema: ListAppsSchema,
142
+ outputSchema: AppItemSchema,
139
143
  },
140
144
  },
141
145
  },
@@ -2,8 +2,6 @@ import { z } from "zod";
2
2
  import type { AppItem } from "../../types/domain";
3
3
  import type { PaginatedSdkFunction } from "../../types/functions";
4
4
  import type { ZapierApiError, ZapierValidationError } from "../../types/errors";
5
- import { AppItemSchema } from "../../schemas/App";
6
- import { withOutputSchema } from "../../utils/schema-utils";
7
5
 
8
6
  // Union of all possible errors for listApps
9
7
  export type ListAppsError = ZapierApiError | ZapierValidationError;
@@ -15,30 +13,23 @@ export interface ListAppsPage {
15
13
  }
16
14
 
17
15
  // Pure Zod schema - no pagination metadata exposed
18
- export const ListAppsSchema = withOutputSchema(
19
- z
20
- .object({
21
- appKeys: z
22
- .array(z.string())
23
- .optional()
24
- .describe(
25
- "Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')",
26
- ),
27
- search: z.string().optional().describe("Search for apps by name"),
28
- pageSize: z
29
- .number()
30
- .min(1)
31
- .optional()
32
- .describe("Number of apps per page"),
33
- maxItems: z
34
- .number()
35
- .min(1)
36
- .optional()
37
- .describe("Maximum total items to return across all pages"),
38
- })
39
- .describe("List all available apps with optional filtering"),
40
- AppItemSchema,
41
- );
16
+ export const ListAppsSchema = z
17
+ .object({
18
+ appKeys: z
19
+ .array(z.string())
20
+ .optional()
21
+ .describe(
22
+ "Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')",
23
+ ),
24
+ search: z.string().optional().describe("Search for apps by name"),
25
+ pageSize: z.number().min(1).optional().describe("Number of apps per page"),
26
+ maxItems: z
27
+ .number()
28
+ .min(1)
29
+ .optional()
30
+ .describe("Maximum total items to return across all pages"),
31
+ })
32
+ .describe("List all available apps with optional filtering");
42
33
 
43
34
  // Type inferred from schema
44
35
  export type ListAppsOptions = z.infer<typeof ListAppsSchema>;
@@ -18,6 +18,8 @@ import {
18
18
  } from "../../utils/function-utils";
19
19
  import type { GetVersionedImplementationId } from "../manifest/schemas";
20
20
  import type { ManifestPluginProvides } from "../manifest";
21
+ import { appKeyResolver } from "../../resolvers";
22
+ import { AuthenticationItemSchema } from "../../schemas/Auth";
21
23
 
22
24
  export interface ListAuthenticationsPluginProvides {
23
25
  listAuthentications: (options?: ListAuthenticationsOptions) => Promise<{
@@ -135,7 +137,13 @@ export const listAuthenticationsPlugin: Plugin<
135
137
  meta: {
136
138
  listAuthentications: {
137
139
  categories: ["authentication"],
140
+ type: "list",
141
+ itemType: "Authentication",
138
142
  inputSchema: ListAuthenticationsSchema,
143
+ outputSchema: AuthenticationItemSchema,
144
+ resolvers: {
145
+ appKey: appKeyResolver,
146
+ },
139
147
  },
140
148
  },
141
149
  },
@@ -10,10 +10,19 @@ import {
10
10
  ListInputFieldChoicesSchema,
11
11
  type ListInputFieldChoicesOptions,
12
12
  type ListInputFieldChoicesPage,
13
+ InputFieldChoiceItemSchema,
13
14
  } from "./schemas";
14
15
  import { ZapierApiError } from "../../types/errors";
15
16
  import { createPaginatedFunction } from "../../utils/function-utils";
16
17
  import type { GetActionPluginProvides } from "../getAction";
18
+ import {
19
+ appKeyResolver,
20
+ actionTypeResolver,
21
+ actionKeyResolver,
22
+ authenticationIdResolver,
23
+ inputFieldKeyResolver,
24
+ inputsAllOptionalResolver,
25
+ } from "../../resolvers";
17
26
 
18
27
  // Transform NeedChoices to InputFieldChoiceItem
19
28
  function transformNeedChoicesToInputFieldChoiceItem(
@@ -116,7 +125,7 @@ export const listInputFieldChoicesPlugin: Plugin<
116
125
 
117
126
  // Handle pagination
118
127
  let nextCursor: string | undefined;
119
- if (choicesData.next_page !== undefined) {
128
+ if (choicesData.next_page != null) {
120
129
  nextCursor = choicesData.next_page.toString();
121
130
  } else if (choicesData.links?.next) {
122
131
  // Extract page from next URL for external actions
@@ -144,7 +153,18 @@ export const listInputFieldChoicesPlugin: Plugin<
144
153
  meta: {
145
154
  listInputFieldChoices: {
146
155
  categories: ["action"],
156
+ type: "list",
157
+ itemType: "InputFieldChoice",
147
158
  inputSchema: ListInputFieldChoicesSchema,
159
+ outputSchema: InputFieldChoiceItemSchema,
160
+ resolvers: {
161
+ appKey: appKeyResolver,
162
+ actionType: actionTypeResolver,
163
+ actionKey: actionKeyResolver,
164
+ authenticationId: authenticationIdResolver,
165
+ inputFieldKey: inputFieldKeyResolver,
166
+ inputs: inputsAllOptionalResolver,
167
+ },
148
168
  },
149
169
  },
150
170
  },
@@ -6,7 +6,8 @@ import {
6
6
  ActionKeyPropertySchema,
7
7
  InputsPropertySchema,
8
8
  } from "../../types/properties";
9
- import { withFormatter, withOutputSchema } from "../../utils/schema-utils";
9
+ import { withFormatter } from "../../utils/schema-utils";
10
+ import { NeedChoicesSchema } from "../../api/schemas";
10
11
  import type { PaginatedSdkFunction } from "../../types/functions";
11
12
  import type {
12
13
  ZapierConfigurationError,
@@ -21,46 +22,33 @@ import type {
21
22
  // Input Field Choice Item Schema
22
23
  // ============================================================================
23
24
 
24
- export const InputFieldChoiceItemSchema = withFormatter(
25
- z.object({
26
- key: z.string().optional().describe("Unique key/value for the choice"),
27
- label: z
28
- .string()
29
- .optional()
30
- .describe("Human readable label for the choice"),
31
- sample: z.string().optional().describe("Sample value for the choice"),
32
- value: z
33
- .string()
34
- .optional()
35
- .describe("Value to be submitted when selected"),
36
- }),
37
- {
38
- format: (item) => {
39
- const title = item.label || item.key || "Choice";
40
- const subtitle =
41
- item.label && item.key && item.label !== item.key
42
- ? `(${item.key})`
43
- : undefined;
44
- const details: Array<{
45
- text: string;
46
- style: "success" | "dim" | "normal" | "accent" | "warning";
47
- }> = [];
25
+ export const InputFieldChoiceItemSchema = withFormatter(NeedChoicesSchema, {
26
+ format: (item) => {
27
+ const title = item.label || item.key || "Choice";
28
+ const details: Array<{
29
+ text: string;
30
+ style: "success" | "dim" | "normal" | "accent" | "warning";
31
+ }> = [];
32
+
33
+ // Show key as detail if different from label
34
+ if (item.label && item.key && item.label !== item.key) {
35
+ details.push({ text: `Key: ${item.key}`, style: "dim" });
36
+ }
48
37
 
49
- if (item.sample && item.sample !== item.key) {
50
- details.push({ text: `Sample: ${item.sample}`, style: "dim" });
51
- }
52
- if (item.value && item.value !== item.key) {
53
- details.push({ text: `Value: ${item.value}`, style: "normal" });
54
- }
38
+ if (item.sample && item.sample !== item.key) {
39
+ details.push({ text: `Sample: ${item.sample}`, style: "dim" });
40
+ }
41
+ if (item.value && item.value !== item.key) {
42
+ details.push({ text: `Value: ${item.value}`, style: "normal" });
43
+ }
55
44
 
56
- return {
57
- title,
58
- subtitle,
59
- details,
60
- };
61
- },
45
+ return {
46
+ title,
47
+ key: item.key,
48
+ details,
49
+ };
62
50
  },
63
- );
51
+ });
64
52
 
65
53
  export type InputFieldChoiceItem = z.infer<typeof InputFieldChoiceItemSchema>;
66
54
 
@@ -68,47 +56,44 @@ export type InputFieldChoiceItem = z.infer<typeof InputFieldChoiceItemSchema>;
68
56
  // Plugin Schema Definition
69
57
  // ============================================================================
70
58
 
71
- export const ListInputFieldChoicesSchema = withOutputSchema(
72
- z
73
- .object({
74
- // Required action identification
75
- appKey: AppKeyPropertySchema,
76
- actionType: ActionTypePropertySchema,
77
- actionKey: ActionKeyPropertySchema,
59
+ export const ListInputFieldChoicesSchema = z
60
+ .object({
61
+ // Required action identification
62
+ appKey: AppKeyPropertySchema,
63
+ actionType: ActionTypePropertySchema,
64
+ actionKey: ActionKeyPropertySchema,
78
65
 
79
- // Input field specification
80
- inputFieldKey: z
81
- .string()
82
- .min(1)
83
- .describe("Input field key to get choices for."),
66
+ // Input field specification
67
+ inputFieldKey: z
68
+ .string()
69
+ .min(1)
70
+ .describe("Input field key to get choices for."),
84
71
 
85
- // Common parameters
86
- authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
87
- inputs: InputsPropertySchema.optional().describe(
88
- "Current input values that may affect available choices",
89
- ),
90
- page: z
91
- .number()
92
- .int()
93
- .min(0)
94
- .optional()
95
- .describe("Page number for paginated results"),
72
+ // Common parameters
73
+ authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
74
+ inputs: InputsPropertySchema.optional().describe(
75
+ "Current input values that may affect available choices",
76
+ ),
77
+ page: z
78
+ .number()
79
+ .int()
80
+ .min(0)
81
+ .optional()
82
+ .describe("Page number for paginated results"),
96
83
 
97
- // Pagination options (SDK-level)
98
- pageSize: z
99
- .number()
100
- .min(1)
101
- .optional()
102
- .describe("Number of choices per page"),
103
- maxItems: z
104
- .number()
105
- .min(1)
106
- .optional()
107
- .describe("Maximum total items to return across all pages"),
108
- })
109
- .describe("Get the available choices for a dynamic dropdown input field"),
110
- InputFieldChoiceItemSchema,
111
- );
84
+ // Pagination options (SDK-level)
85
+ pageSize: z
86
+ .number()
87
+ .min(1)
88
+ .optional()
89
+ .describe("Number of choices per page"),
90
+ maxItems: z
91
+ .number()
92
+ .min(1)
93
+ .optional()
94
+ .describe("Maximum total items to return across all pages"),
95
+ })
96
+ .describe("Get the available choices for a dynamic dropdown input field");
112
97
 
113
98
  // Type inferred from schema
114
99
  export type ListInputFieldChoicesOptions = z.infer<
@@ -217,7 +217,7 @@ describe("listInputFields plugin", () => {
217
217
  // Check message field transformation
218
218
  expect(result.data[0]).toEqual(
219
219
  expect.objectContaining({
220
- id: "message",
220
+ key: "message",
221
221
  title: "Message",
222
222
  description: "The message to send",
223
223
  is_required: true,
@@ -227,26 +227,22 @@ describe("listInputFields plugin", () => {
227
227
  }),
228
228
  );
229
229
 
230
- // Check channel field with choices (SELECT format)
230
+ // Check channel field with SELECT format
231
231
  expect(result.data[1]).toEqual(
232
232
  expect.objectContaining({
233
- id: "channel",
233
+ key: "channel",
234
234
  title: "Channel",
235
235
  description: "The channel to send to",
236
236
  is_required: true,
237
237
  value_type: "STRING",
238
238
  format: "SELECT",
239
- choices: [
240
- { value: "#general", label: "General", sample: "#general" },
241
- { value: "#random", label: "Random", sample: "#random" },
242
- ],
243
239
  }),
244
240
  );
245
241
 
246
242
  // Check array field
247
243
  expect(result.data[2]).toEqual(
248
244
  expect.objectContaining({
249
- id: "tags",
245
+ key: "tags",
250
246
  title: "Tags",
251
247
  description: "List of tags",
252
248
  value_type: "ARRAY",
@@ -405,7 +401,7 @@ describe("listInputFields plugin", () => {
405
401
  }
406
402
 
407
403
  expect(items).toHaveLength(3);
408
- expect(items[0].id).toBe("message");
404
+ expect(items[0].key).toBe("message");
409
405
  });
410
406
  });
411
407
  });
@@ -1,7 +1,12 @@
1
1
  import type { Plugin, GetSdkType } from "../../types/plugin";
2
2
  import type { ApiClient } from "../../api";
3
3
  import type { NeedsRequest, NeedsResponse, Need } from "../../api/types";
4
- import type { InputFieldItem } from "../../types/domain";
4
+ import type {
5
+ InputFieldItem,
6
+ InfoFieldItem,
7
+ FieldsetItem,
8
+ RootFieldItem,
9
+ } from "../../types/domain";
5
10
  import {
6
11
  ListInputFieldsSchema,
7
12
  type ListInputFieldsOptions,
@@ -11,6 +16,15 @@ import { ZapierConfigurationError, ZapierApiError } from "../../types/errors";
11
16
  import { createPaginatedFunction } from "../../utils/function-utils";
12
17
  import type { GetAppPluginProvides } from "../getApp";
13
18
  import type { GetVersionedImplementationId } from "../manifest/schemas";
19
+ import {
20
+ appKeyResolver,
21
+ actionTypeResolver,
22
+ actionKeyResolver,
23
+ authenticationIdResolver,
24
+ inputsAllOptionalResolver,
25
+ } from "../../resolvers";
26
+ import { RootFieldItemSchema } from "../../schemas/Field";
27
+ import { toTitleCase } from "../../utils/string-utils";
14
28
 
15
29
  // Enums for input field transformation
16
30
  enum InputFieldType {
@@ -93,8 +107,8 @@ function transformNeedToInputFieldItem(need: Need): InputFieldItem {
93
107
  const itemsType = getItemsTypeFromNeed(need);
94
108
 
95
109
  return {
96
- ...need, // Pass through all original Need fields
97
- id: need.key,
110
+ type: "input_field",
111
+ key: need.key,
98
112
  default_value: need.default || "",
99
113
  depends_on: need.depends_on || [],
100
114
  description: need.help_text || "",
@@ -108,12 +122,68 @@ function transformNeedToInputFieldItem(need: Need): InputFieldItem {
108
122
  };
109
123
  }
110
124
 
125
+ // Transform Need to InfoFieldItem (for copy fields)
126
+ function transformNeedToInfoFieldItem(need: Need): InfoFieldItem {
127
+ return {
128
+ type: "info_field",
129
+ key: need.key,
130
+ description: need.help_text || "",
131
+ title: need.label,
132
+ };
133
+ }
134
+
135
+ // Transform needs to fields (similar to partnerapi compute_root_fieldset_from_needs)
136
+ function transformNeedsToFields(needs: Need[]): RootFieldItem[] {
137
+ const rootFields: (InputFieldItem | InfoFieldItem | FieldsetItem)[] = [];
138
+ const fieldsetMap = new Map<string, FieldsetItem>();
139
+
140
+ for (const need of needs) {
141
+ if (need.computed) {
142
+ // Computed needs (i.e zap_id for CodeAPI steps) are not shown by the
143
+ // editor, hide them here too.
144
+ continue;
145
+ }
146
+
147
+ // If parent_key is set, we need to ensure that a corresponding
148
+ // fieldset exists, since we'll be adding this need to that fieldset
149
+ if (need.parent_key) {
150
+ let fieldset = fieldsetMap.get(need.parent_key);
151
+ if (!fieldset) {
152
+ fieldset = {
153
+ type: "fieldset",
154
+ key: need.parent_key,
155
+ title: toTitleCase(need.parent_key),
156
+ fields: [],
157
+ };
158
+ fieldsetMap.set(need.parent_key, fieldset);
159
+ rootFields.push(fieldset);
160
+ }
161
+
162
+ // Add field to fieldset
163
+ if (need.type === "copy" && need.help_text) {
164
+ fieldset.fields.push(transformNeedToInfoFieldItem(need));
165
+ } else {
166
+ fieldset.fields.push(transformNeedToInputFieldItem(need));
167
+ }
168
+ } else {
169
+ // Add field to root
170
+ if (need.type === "copy" && need.help_text) {
171
+ rootFields.push(transformNeedToInfoFieldItem(need));
172
+ } else {
173
+ rootFields.push(transformNeedToInputFieldItem(need));
174
+ }
175
+ }
176
+ }
177
+
178
+ return rootFields;
179
+ }
180
+
111
181
  export interface ListInputFieldsPluginProvides {
112
182
  listInputFields: (options?: ListInputFieldsOptions) => Promise<{
113
- data: InputFieldItem[];
183
+ data: RootFieldItem[];
114
184
  }> &
115
- AsyncIterable<{ data: InputFieldItem[]; nextCursor?: string }> & {
116
- items(): AsyncIterable<InputFieldItem>;
185
+ AsyncIterable<{ data: RootFieldItem[]; nextCursor?: string }> & {
186
+ items(): AsyncIterable<InputFieldItem | InfoFieldItem | FieldsetItem>;
117
187
  };
118
188
  context: {
119
189
  meta: {
@@ -181,13 +251,11 @@ export const listInputFieldsPlugin: Plugin<
181
251
  );
182
252
  }
183
253
 
184
- // Transform Need objects to InputFieldItem objects
185
- const inputFields: InputFieldItem[] = (needsData.needs || []).map(
186
- transformNeedToInputFieldItem,
187
- );
254
+ // Transform Need objects to Root Fieldset with proper nesting
255
+ const rootFieldset = transformNeedsToFields(needsData.needs || []);
188
256
 
189
257
  return {
190
- data: inputFields,
258
+ data: rootFieldset,
191
259
  nextCursor: undefined, // No pagination needed since we return all input fields
192
260
  };
193
261
  },
@@ -200,7 +268,17 @@ export const listInputFieldsPlugin: Plugin<
200
268
  meta: {
201
269
  listInputFields: {
202
270
  categories: ["action"],
271
+ type: "list",
272
+ itemType: "RootFieldItem",
203
273
  inputSchema: ListInputFieldsSchema,
274
+ outputSchema: RootFieldItemSchema,
275
+ resolvers: {
276
+ appKey: appKeyResolver,
277
+ actionType: actionTypeResolver,
278
+ actionKey: actionKeyResolver,
279
+ authenticationId: authenticationIdResolver,
280
+ inputs: inputsAllOptionalResolver,
281
+ },
204
282
  },
205
283
  },
206
284
  },
@@ -6,7 +6,7 @@ import {
6
6
  AuthenticationIdPropertySchema,
7
7
  InputsPropertySchema,
8
8
  } from "../../types/properties";
9
- import type { InputFieldItem } from "../../types/domain";
9
+ import type { RootFieldItem } from "../../types/domain";
10
10
  import type { PaginatedSdkFunction } from "../../types/functions";
11
11
  import type {
12
12
  ZapierConfigurationError,
@@ -54,11 +54,14 @@ export type ListInputFieldsError =
54
54
 
55
55
  // Page result structure
56
56
  export interface ListInputFieldsPage {
57
- data: InputFieldItem[];
57
+ data: RootFieldItem[];
58
58
  nextCursor?: string;
59
59
  }
60
60
 
61
61
  // SDK function interface
62
62
  export interface ListInputFieldsSdkFunction {
63
- listInputFields: PaginatedSdkFunction<ListInputFieldsOptions, InputFieldItem>;
63
+ listInputFields: PaginatedSdkFunction<
64
+ ListInputFieldsOptions,
65
+ RootFieldItem[]
66
+ >;
64
67
  }
@@ -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:",