@zapier/zapier-sdk 0.15.0 → 0.15.2
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.
- package/CHANGELOG.md +12 -0
- package/README.md +28 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.integration.test.d.ts +5 -0
- package/dist/api/client.integration.test.d.ts.map +1 -0
- package/dist/api/client.integration.test.js +318 -0
- package/dist/api/client.js +31 -1
- package/dist/api/schemas.d.ts +3 -0
- package/dist/api/schemas.d.ts.map +1 -1
- package/dist/api/schemas.js +1 -0
- package/dist/index.cjs +386 -106
- package/dist/index.d.mts +290 -33
- package/dist/index.mjs +386 -106
- package/dist/plugins/getApp/index.test.js +17 -21
- package/dist/plugins/getInputFieldsSchema/index.d.ts +22 -0
- package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -0
- package/dist/plugins/getInputFieldsSchema/index.js +51 -0
- package/dist/plugins/getInputFieldsSchema/index.test.d.ts +2 -0
- package/dist/plugins/getInputFieldsSchema/index.test.d.ts.map +1 -0
- package/dist/plugins/getInputFieldsSchema/index.test.js +288 -0
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +31 -0
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +1 -0
- package/dist/plugins/getInputFieldsSchema/schemas.js +13 -0
- package/dist/plugins/listActions/schemas.d.ts +4 -4
- package/dist/plugins/listApps/index.d.ts +1 -3
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +18 -44
- package/dist/plugins/listApps/index.test.js +89 -288
- package/dist/plugins/listApps/schemas.d.ts +19 -26
- package/dist/plugins/listApps/schemas.d.ts.map +1 -1
- package/dist/plugins/listApps/schemas.js +19 -18
- package/dist/plugins/listAuthentications/schemas.d.ts +4 -4
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +4 -4
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +2 -0
- package/dist/plugins/listInputFields/schemas.d.ts +4 -4
- package/dist/plugins/runAction/schemas.d.ts +4 -4
- package/dist/sdk.d.ts +8 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +2 -0
- package/dist/temporary-internal-core/handlers/listApps.d.ts +67 -0
- package/dist/temporary-internal-core/handlers/listApps.d.ts.map +1 -0
- package/dist/temporary-internal-core/handlers/listApps.js +121 -0
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts +2 -0
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +1 -0
- package/dist/temporary-internal-core/handlers/listApps.test.js +328 -0
- package/dist/temporary-internal-core/index.d.ts +18 -0
- package/dist/temporary-internal-core/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/index.js +18 -0
- package/dist/temporary-internal-core/schemas/apps/index.d.ts +582 -0
- package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/schemas/apps/index.js +95 -0
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts +511 -0
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/schemas/implementations/index.js +79 -0
- package/dist/temporary-internal-core/types/handler.d.ts +51 -0
- package/dist/temporary-internal-core/types/handler.d.ts.map +1 -0
- package/dist/temporary-internal-core/types/handler.js +8 -0
- package/dist/temporary-internal-core/types/index.d.ts +5 -0
- package/dist/temporary-internal-core/types/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/types/index.js +4 -0
- package/dist/temporary-internal-core/utils/app-locators.d.ts +54 -0
- package/dist/temporary-internal-core/utils/app-locators.d.ts.map +1 -0
- package/dist/temporary-internal-core/utils/app-locators.js +83 -0
- package/dist/temporary-internal-core/utils/transformations.d.ts +18 -0
- package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -0
- package/dist/temporary-internal-core/utils/transformations.js +36 -0
- package/dist/types/sdk.d.ts +2 -1
- package/dist/types/sdk.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -3,43 +3,19 @@ import { ZapierValidationError } from "../../types/errors";
|
|
|
3
3
|
import { listAppsPlugin } from "./index";
|
|
4
4
|
import { createSdk } from "../../sdk";
|
|
5
5
|
import { apiPlugin } from "../api/index";
|
|
6
|
-
const mockAppsResponse = {
|
|
7
|
-
results: [
|
|
8
|
-
{
|
|
9
|
-
id: "SlackCLIAPI@1.0.0",
|
|
10
|
-
slug: "slack",
|
|
11
|
-
name: "Slack",
|
|
12
|
-
description: "Team communication",
|
|
13
|
-
primary_color: "#4A154B",
|
|
14
|
-
categories: ["communication"],
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
id: "GoogleSheetsCLIAPI@1.0.0",
|
|
18
|
-
slug: "google-sheets",
|
|
19
|
-
name: "Google Sheets",
|
|
20
|
-
description: "Online spreadsheets",
|
|
21
|
-
primary_color: "#34A853",
|
|
22
|
-
categories: ["productivity"],
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
meta: {
|
|
26
|
-
next_cursor: null,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
6
|
const mockResolveAppKeys = vi
|
|
30
7
|
.fn()
|
|
31
8
|
.mockImplementation(async ({ appKeys }) => {
|
|
32
|
-
// Mock implementation that returns resolved locators for the app keys
|
|
33
9
|
return appKeys.map((appKey) => ({
|
|
34
10
|
lookupAppKey: appKey,
|
|
35
|
-
implementationName: appKey,
|
|
11
|
+
implementationName: appKey,
|
|
36
12
|
slug: appKey.toLowerCase(),
|
|
37
13
|
version: undefined,
|
|
38
14
|
}));
|
|
39
15
|
});
|
|
40
|
-
function createTestSdk() {
|
|
16
|
+
function createTestSdk(mockFetch) {
|
|
41
17
|
return createSdk()
|
|
42
|
-
.addPlugin(apiPlugin, { fetch: global.fetch })
|
|
18
|
+
.addPlugin(apiPlugin, { fetch: mockFetch || global.fetch })
|
|
43
19
|
.addPlugin(() => ({
|
|
44
20
|
context: {
|
|
45
21
|
resolveAppKeys: mockResolveAppKeys,
|
|
@@ -47,287 +23,112 @@ function createTestSdk() {
|
|
|
47
23
|
}))
|
|
48
24
|
.addPlugin(listAppsPlugin);
|
|
49
25
|
}
|
|
26
|
+
function createMockFetch(handlers) {
|
|
27
|
+
return vi.fn().mockImplementation(async (url, _init) => {
|
|
28
|
+
const urlString = typeof url === "string" ? url : url.toString();
|
|
29
|
+
const urlPath = new URL(urlString).pathname;
|
|
30
|
+
for (const [handlerPath, response] of Object.entries(handlers)) {
|
|
31
|
+
if (urlPath === handlerPath) {
|
|
32
|
+
const responseData = typeof response === "function" ? response() : response;
|
|
33
|
+
return {
|
|
34
|
+
ok: true,
|
|
35
|
+
status: 200,
|
|
36
|
+
statusText: "OK",
|
|
37
|
+
json: async () => responseData,
|
|
38
|
+
headers: new Headers({ "content-type": "application/json" }),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
ok: false,
|
|
44
|
+
status: 404,
|
|
45
|
+
statusText: "Not Found",
|
|
46
|
+
json: async () => ({ message: `No mock for path: ${urlPath}` }),
|
|
47
|
+
headers: new Headers(),
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}
|
|
50
51
|
describe("listApps plugin", () => {
|
|
51
52
|
beforeEach(() => {
|
|
52
53
|
vi.clearAllMocks();
|
|
53
54
|
});
|
|
54
|
-
describe("
|
|
55
|
-
it("should
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const context = sdk.getContext();
|
|
77
|
-
// Mock the API client in context
|
|
78
|
-
context.api.get = vi
|
|
79
|
-
.fn()
|
|
80
|
-
.mockResolvedValue(mockServicesResponse);
|
|
81
|
-
const result = await sdk.listApps({});
|
|
82
|
-
expect(result.data).toHaveLength(2);
|
|
83
|
-
});
|
|
84
|
-
it("should handle undefined options by converting to empty object", async () => {
|
|
85
|
-
const sdk = createTestSdk();
|
|
86
|
-
const context = sdk.getContext();
|
|
87
|
-
// Mock the API client in context
|
|
88
|
-
context.api.get = vi.fn().mockResolvedValueOnce({
|
|
89
|
-
results: [
|
|
90
|
-
{
|
|
91
|
-
id: "SlackCLIAPI@1.0.0",
|
|
92
|
-
name: "Slack",
|
|
93
|
-
description: "Team communication",
|
|
94
|
-
primary_color: "#4A154B",
|
|
95
|
-
categories: ["communication"],
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
next: null,
|
|
99
|
-
});
|
|
100
|
-
const result = await sdk.listApps(undefined);
|
|
101
|
-
expect(result.data).toHaveLength(1);
|
|
102
|
-
expect(result.data[0]).toMatchObject({
|
|
103
|
-
key: "SlackCLIAPI",
|
|
104
|
-
title: "Slack",
|
|
105
|
-
});
|
|
106
|
-
expect(context.api.get).toHaveBeenCalledWith("/zapier/api/v4/implementations-meta/lookup/", {
|
|
107
|
-
searchParams: {
|
|
108
|
-
latest_only: "true",
|
|
109
|
-
limit: "100",
|
|
110
|
-
selected_apis: "",
|
|
55
|
+
describe("basic functionality", () => {
|
|
56
|
+
it("should provide listApps method that returns apps", async () => {
|
|
57
|
+
const mockFetch = createMockFetch({
|
|
58
|
+
"/api/v0/sdk/zapier/api/v4/implementations-meta/lookup/": {
|
|
59
|
+
count: 2,
|
|
60
|
+
results: [
|
|
61
|
+
{
|
|
62
|
+
id: "SlackCLIAPI@1.0.0",
|
|
63
|
+
name: "Slack",
|
|
64
|
+
description: "Team communication",
|
|
65
|
+
primary_color: "#4A154B",
|
|
66
|
+
categories: ["communication"],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "GoogleSheetsCLIAPI@1.0.0",
|
|
70
|
+
name: "Google Sheets",
|
|
71
|
+
description: "Online spreadsheets",
|
|
72
|
+
primary_color: "#34A853",
|
|
73
|
+
categories: ["productivity"],
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
next: null,
|
|
111
77
|
},
|
|
112
78
|
});
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
pageSize: 0, // Should be >= 1
|
|
119
|
-
});
|
|
120
|
-
}).toThrow(ZapierValidationError);
|
|
121
|
-
expect(() => {
|
|
122
|
-
sdk.listApps({
|
|
123
|
-
pageSize: -5, // Should be >= 1
|
|
124
|
-
});
|
|
125
|
-
}).toThrow(ZapierValidationError);
|
|
126
|
-
});
|
|
127
|
-
it("should throw validation error for invalid maxItems", () => {
|
|
128
|
-
const sdk = createTestSdk();
|
|
129
|
-
expect(() => {
|
|
130
|
-
sdk.listApps({
|
|
131
|
-
maxItems: 0, // Should be >= 1
|
|
132
|
-
});
|
|
133
|
-
}).toThrow(ZapierValidationError);
|
|
134
|
-
expect(() => {
|
|
135
|
-
sdk.listApps({
|
|
136
|
-
maxItems: -10, // Should be >= 1
|
|
137
|
-
});
|
|
138
|
-
}).toThrow(ZapierValidationError);
|
|
139
|
-
});
|
|
140
|
-
it("should throw validation error for invalid appKeys type", () => {
|
|
141
|
-
const sdk = createTestSdk();
|
|
142
|
-
expect(() => {
|
|
143
|
-
sdk.listApps({
|
|
144
|
-
appKeys: 123,
|
|
145
|
-
});
|
|
146
|
-
}).toThrow(ZapierValidationError);
|
|
147
|
-
});
|
|
148
|
-
it("should pass validation with all valid fields", async () => {
|
|
149
|
-
const sdk = createTestSdk();
|
|
150
|
-
const context = sdk.getContext();
|
|
151
|
-
// Mock the API client in context
|
|
152
|
-
context.api.get = vi.fn().mockResolvedValueOnce({
|
|
153
|
-
results: [
|
|
154
|
-
{
|
|
155
|
-
id: "SlackCLIAPI@1.0.0",
|
|
156
|
-
name: "Slack",
|
|
157
|
-
description: "Team communication",
|
|
158
|
-
primary_color: "#4A154B",
|
|
159
|
-
categories: ["communication"],
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
id: "GitHubCLIAPI@1.0.0",
|
|
163
|
-
name: "GitHub",
|
|
164
|
-
description: "Code repository hosting",
|
|
165
|
-
primary_color: "#24292e",
|
|
166
|
-
categories: ["developer-tools"],
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
next: null,
|
|
170
|
-
});
|
|
171
|
-
const result = await sdk.listApps({
|
|
172
|
-
appKeys: ["SlackCLIAPI", "GitHubCLIAPI"],
|
|
173
|
-
pageSize: 10,
|
|
174
|
-
maxItems: 50,
|
|
175
|
-
});
|
|
176
|
-
expect(result.data).toHaveLength(2);
|
|
177
|
-
expect(result.data[0].key).toBe("SlackCLIAPI");
|
|
178
|
-
expect(result.data[1].key).toBe("GitHubCLIAPI");
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
describe("data mapping", () => {
|
|
182
|
-
it("should return essential app properties", async () => {
|
|
183
|
-
const mockServicesResponse = {
|
|
184
|
-
results: [
|
|
185
|
-
{
|
|
186
|
-
id: "slack_service_id",
|
|
187
|
-
slug: "slack",
|
|
188
|
-
name: "Slack",
|
|
189
|
-
description: "Team communication",
|
|
190
|
-
current_implementation_id: "SlackCLIAPI@1.0.0",
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
next: null,
|
|
194
|
-
};
|
|
195
|
-
const sdk = createTestSdk();
|
|
196
|
-
const context = sdk.getContext();
|
|
197
|
-
// Mock the API client in context
|
|
198
|
-
context.api.get = vi
|
|
199
|
-
.fn()
|
|
200
|
-
.mockResolvedValue(mockServicesResponse);
|
|
201
|
-
const result = await sdk.listApps({});
|
|
79
|
+
const sdk = createTestSdk(mockFetch);
|
|
80
|
+
// Provide explicit pageSize to limit results
|
|
81
|
+
const result = await sdk.listApps({ pageSize: 2 });
|
|
82
|
+
// Just verify the structure - handler tests verify correct data
|
|
83
|
+
expect(result.data.length).toBeGreaterThan(0);
|
|
202
84
|
expect(result.data[0]).toHaveProperty("title");
|
|
203
85
|
expect(result.data[0]).toHaveProperty("key");
|
|
204
86
|
expect(result.data[0]).toHaveProperty("implementation_id");
|
|
205
|
-
// Version is optional
|
|
206
87
|
expect(result.data[0]).toHaveProperty("version");
|
|
207
88
|
});
|
|
208
89
|
});
|
|
209
|
-
describe("
|
|
210
|
-
it("should
|
|
211
|
-
const mockServicesResponse = {
|
|
212
|
-
results: [
|
|
213
|
-
{
|
|
214
|
-
id: "slack_service_id",
|
|
215
|
-
slug: "slack",
|
|
216
|
-
name: "Slack",
|
|
217
|
-
description: "Team communication",
|
|
218
|
-
current_implementation_id: "SlackCLIAPI@1.0.0",
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
id: "sheets_service_id",
|
|
222
|
-
slug: "google-sheets",
|
|
223
|
-
name: "Google Sheets",
|
|
224
|
-
description: "Online spreadsheets",
|
|
225
|
-
current_implementation_id: "GoogleSheetsCLIAPI@1.0.0",
|
|
226
|
-
},
|
|
227
|
-
],
|
|
228
|
-
next: null,
|
|
229
|
-
};
|
|
90
|
+
describe("plugin integration", () => {
|
|
91
|
+
it("should provide metadata in context for CLI introspection", () => {
|
|
230
92
|
const sdk = createTestSdk();
|
|
231
93
|
const context = sdk.getContext();
|
|
232
|
-
|
|
233
|
-
context.
|
|
234
|
-
const result = await sdk.listApps({ maxItems: 5 });
|
|
235
|
-
// Should return all items since maxItems (5) is greater than available items (2)
|
|
236
|
-
expect(result.data).toHaveLength(2);
|
|
237
|
-
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
94
|
+
expect(context.meta.listApps).toBeDefined();
|
|
95
|
+
expect(context.meta.listApps.inputSchema).toBeDefined();
|
|
238
96
|
});
|
|
239
|
-
it("should
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
})
|
|
255
|
-
.mockResolvedValueOnce({
|
|
256
|
-
results: [
|
|
257
|
-
{
|
|
258
|
-
id: "GoogleSheetsCLIAPI@1.0.0",
|
|
259
|
-
slug: "google-sheets",
|
|
260
|
-
name: "Google Sheets",
|
|
261
|
-
description: "Online spreadsheets",
|
|
262
|
-
},
|
|
263
|
-
],
|
|
264
|
-
next: null,
|
|
97
|
+
it("should integrate with resolveAppKeys", async () => {
|
|
98
|
+
const mockFetch = createMockFetch({
|
|
99
|
+
"/api/v0/sdk/zapier/api/v4/implementations-meta/lookup/": {
|
|
100
|
+
count: 1,
|
|
101
|
+
results: [
|
|
102
|
+
{
|
|
103
|
+
id: "SlackCLIAPI@1.0.0",
|
|
104
|
+
name: "Slack",
|
|
105
|
+
description: "Team communication",
|
|
106
|
+
primary_color: "#4A154B",
|
|
107
|
+
categories: ["communication"],
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
next: null,
|
|
111
|
+
},
|
|
265
112
|
});
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
expect(pages).toHaveLength(2);
|
|
274
|
-
expect(pages[0].data).toHaveLength(1);
|
|
275
|
-
expect(pages[1].data).toHaveLength(1);
|
|
276
|
-
expect(pages[0].data[0].key).toBe("SlackCLIAPI");
|
|
277
|
-
expect(pages[1].data[0].key).toBe("GoogleSheetsCLIAPI");
|
|
278
|
-
});
|
|
279
|
-
it("should support async iteration over individual items", async () => {
|
|
280
|
-
const mockServicesResponse = {
|
|
281
|
-
results: [
|
|
282
|
-
{
|
|
283
|
-
id: "SlackCLIAPI@1.0.0",
|
|
284
|
-
slug: "slack",
|
|
285
|
-
name: "Slack",
|
|
286
|
-
description: "Team communication",
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
id: "GoogleSheetsCLIAPI@1.0.0",
|
|
290
|
-
slug: "google-sheets",
|
|
291
|
-
name: "Google Sheets",
|
|
292
|
-
description: "Online spreadsheets",
|
|
293
|
-
},
|
|
294
|
-
],
|
|
295
|
-
next: null,
|
|
296
|
-
};
|
|
297
|
-
const sdk = createTestSdk();
|
|
298
|
-
const context = sdk.getContext();
|
|
299
|
-
context.api.get = vi
|
|
300
|
-
.fn()
|
|
301
|
-
.mockResolvedValue(mockServicesResponse);
|
|
302
|
-
const items = [];
|
|
303
|
-
for await (const item of sdk.listApps({ maxItems: 2 }).items()) {
|
|
304
|
-
items.push(item);
|
|
305
|
-
}
|
|
306
|
-
expect(items).toHaveLength(2);
|
|
307
|
-
expect(items[0].key).toBe("SlackCLIAPI");
|
|
308
|
-
expect(items[1].key).toBe("GoogleSheetsCLIAPI");
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
describe("API integration", () => {
|
|
312
|
-
it("should pass appKeys filter to API", async () => {
|
|
313
|
-
const sdk = createTestSdk();
|
|
314
|
-
const context = sdk.getContext();
|
|
315
|
-
const mockGet = vi.fn().mockResolvedValue(mockAppsResponse);
|
|
316
|
-
context.api.get = mockGet;
|
|
317
|
-
await sdk.listApps({ appKeys: ["SlackCLIAPI", "GitHubCLIAPI"] });
|
|
318
|
-
expect(mockGet).toHaveBeenCalledWith(expect.stringContaining("implementations-meta"), expect.objectContaining({
|
|
319
|
-
searchParams: expect.objectContaining({
|
|
320
|
-
selected_apis: "SlackCLIAPI@latest,GitHubCLIAPI@latest",
|
|
321
|
-
}),
|
|
113
|
+
const sdk = createTestSdk(mockFetch);
|
|
114
|
+
await sdk.listApps({ appKeys: ["SlackCLIAPI"] });
|
|
115
|
+
// Verify resolveAppKeys was called with the provided appKeys
|
|
116
|
+
expect(mockResolveAppKeys).toHaveBeenCalledWith(expect.objectContaining({
|
|
117
|
+
appKeys: ["SlackCLIAPI"],
|
|
322
118
|
}));
|
|
323
119
|
});
|
|
324
120
|
});
|
|
325
|
-
describe("
|
|
326
|
-
it("should
|
|
121
|
+
describe("validation", () => {
|
|
122
|
+
it("should throw validation error for invalid input", () => {
|
|
327
123
|
const sdk = createTestSdk();
|
|
328
|
-
|
|
329
|
-
expect(
|
|
330
|
-
|
|
124
|
+
// Invalid pageSize
|
|
125
|
+
expect(() => {
|
|
126
|
+
sdk.listApps({ pageSize: 0 });
|
|
127
|
+
}).toThrow(ZapierValidationError);
|
|
128
|
+
// Invalid appKeys type
|
|
129
|
+
expect(() => {
|
|
130
|
+
sdk.listApps({ appKeys: 123 });
|
|
131
|
+
}).toThrow(ZapierValidationError);
|
|
331
132
|
});
|
|
332
133
|
});
|
|
333
134
|
});
|
|
@@ -1,32 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Plugin schemas for listApps
|
|
3
|
+
*
|
|
4
|
+
* Re-exports from temporary-internal-core to maintain single source of truth.
|
|
5
|
+
* Plugin-specific types (like PaginatedSdkFunction) remain here.
|
|
6
|
+
*
|
|
7
|
+
* Note: The handler (handleListApps) uses a different request interface (ListAppsHandlerRequest)
|
|
8
|
+
* than the public API (ListAppsOptions). This is because:
|
|
9
|
+
* - ListAppsOptions accepts user-friendly `appKeys` (slugs, implementation names, etc.) and `search`
|
|
10
|
+
* - ListAppsHandlerRequest expects pre-resolved `implementationIds` and `search`
|
|
11
|
+
* - The plugin is responsible for:
|
|
12
|
+
* 1. App key resolution (slugs, implementation names → implementation IDs)
|
|
13
|
+
* 2. Early returns for invalid appKeys (prevents returning all apps)
|
|
14
|
+
* - The handler is responsible for:
|
|
15
|
+
* 1. Search augmentation (merging search results with implementation IDs)
|
|
16
|
+
* 2. Empty search handling (returns empty, not all apps)
|
|
17
|
+
*/
|
|
3
18
|
import type { PaginatedSdkFunction } from "../../types/functions";
|
|
4
19
|
import type { ZapierApiError, ZapierValidationError } from "../../types/errors";
|
|
20
|
+
import type { ListAppsOptions, AppItem } from "../../temporary-internal-core/schemas/apps";
|
|
21
|
+
export { ListAppsOptionsSchema as ListAppsSchema, ListAppsResponseSchema, type ListAppsOptions, type ListAppsResponse as ListAppsPage, type AppItem, } from "../../temporary-internal-core/schemas/apps";
|
|
5
22
|
export type ListAppsError = ZapierApiError | ZapierValidationError;
|
|
6
|
-
export interface ListAppsPage {
|
|
7
|
-
data: AppItem[];
|
|
8
|
-
nextCursor?: string;
|
|
9
|
-
}
|
|
10
|
-
export declare const ListAppsSchema: z.ZodObject<{
|
|
11
|
-
appKeys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
12
|
-
search: z.ZodOptional<z.ZodString>;
|
|
13
|
-
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
14
|
-
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
15
|
-
cursor: z.ZodOptional<z.ZodString>;
|
|
16
|
-
}, "strip", z.ZodTypeAny, {
|
|
17
|
-
search?: string | undefined;
|
|
18
|
-
appKeys?: string[] | undefined;
|
|
19
|
-
cursor?: string | undefined;
|
|
20
|
-
maxItems?: number | undefined;
|
|
21
|
-
pageSize?: number | undefined;
|
|
22
|
-
}, {
|
|
23
|
-
search?: string | undefined;
|
|
24
|
-
appKeys?: string[] | undefined;
|
|
25
|
-
cursor?: string | undefined;
|
|
26
|
-
maxItems?: number | undefined;
|
|
27
|
-
pageSize?: number | undefined;
|
|
28
|
-
}>;
|
|
29
|
-
export type ListAppsOptions = z.infer<typeof ListAppsSchema>;
|
|
30
23
|
export interface ListAppsSdkFunction {
|
|
31
24
|
listApps: PaginatedSdkFunction<ListAppsOptions | undefined, AppItem>;
|
|
32
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,KAAK,EACV,eAAe,EACf,OAAO,EACR,MAAM,4CAA4C,CAAC;AAGpD,OAAO,EACL,qBAAqB,IAAI,cAAc,EACvC,sBAAsB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,IAAI,YAAY,EACrC,KAAK,OAAO,GACb,MAAM,4CAA4C,CAAC;AAGpD,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,qBAAqB,CAAC;AAGnE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,oBAAoB,CAAC,eAAe,GAAG,SAAS,EAAE,OAAO,CAAC,CAAC;CACtE"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Plugin schemas for listApps
|
|
3
|
+
*
|
|
4
|
+
* Re-exports from temporary-internal-core to maintain single source of truth.
|
|
5
|
+
* Plugin-specific types (like PaginatedSdkFunction) remain here.
|
|
6
|
+
*
|
|
7
|
+
* Note: The handler (handleListApps) uses a different request interface (ListAppsHandlerRequest)
|
|
8
|
+
* than the public API (ListAppsOptions). This is because:
|
|
9
|
+
* - ListAppsOptions accepts user-friendly `appKeys` (slugs, implementation names, etc.) and `search`
|
|
10
|
+
* - ListAppsHandlerRequest expects pre-resolved `implementationIds` and `search`
|
|
11
|
+
* - The plugin is responsible for:
|
|
12
|
+
* 1. App key resolution (slugs, implementation names → implementation IDs)
|
|
13
|
+
* 2. Early returns for invalid appKeys (prevents returning all apps)
|
|
14
|
+
* - The handler is responsible for:
|
|
15
|
+
* 1. Search augmentation (merging search results with implementation IDs)
|
|
16
|
+
* 2. Empty search handling (returns empty, not all apps)
|
|
17
|
+
*/
|
|
18
|
+
// Re-export core schemas and types
|
|
19
|
+
export { ListAppsOptionsSchema as ListAppsSchema, ListAppsResponseSchema, } from "../../temporary-internal-core/schemas/apps";
|
|
@@ -18,9 +18,9 @@ export declare const ListAuthenticationsSchema: z.ZodObject<{
|
|
|
18
18
|
search?: string | undefined;
|
|
19
19
|
title?: string | undefined;
|
|
20
20
|
appKey?: string | undefined;
|
|
21
|
-
cursor?: string | undefined;
|
|
22
|
-
maxItems?: number | undefined;
|
|
23
21
|
pageSize?: number | undefined;
|
|
22
|
+
maxItems?: number | undefined;
|
|
23
|
+
cursor?: string | undefined;
|
|
24
24
|
accountId?: string | undefined;
|
|
25
25
|
owner?: string | undefined;
|
|
26
26
|
authenticationIds?: string[] | undefined;
|
|
@@ -28,9 +28,9 @@ export declare const ListAuthenticationsSchema: z.ZodObject<{
|
|
|
28
28
|
search?: string | undefined;
|
|
29
29
|
title?: string | undefined;
|
|
30
30
|
appKey?: string | undefined;
|
|
31
|
-
cursor?: string | undefined;
|
|
32
|
-
maxItems?: number | undefined;
|
|
33
31
|
pageSize?: number | undefined;
|
|
32
|
+
maxItems?: number | undefined;
|
|
33
|
+
cursor?: string | undefined;
|
|
34
34
|
accountId?: string | undefined;
|
|
35
35
|
owner?: string | undefined;
|
|
36
36
|
authenticationIds?: string[] | undefined;
|
|
@@ -37,9 +37,9 @@ export declare const ListInputFieldChoicesSchema: z.ZodObject<{
|
|
|
37
37
|
actionKey: string;
|
|
38
38
|
inputFieldKey: string;
|
|
39
39
|
page?: number | undefined;
|
|
40
|
-
cursor?: string | undefined;
|
|
41
|
-
maxItems?: number | undefined;
|
|
42
40
|
pageSize?: number | undefined;
|
|
41
|
+
maxItems?: number | undefined;
|
|
42
|
+
cursor?: string | undefined;
|
|
43
43
|
authenticationId?: number | null | undefined;
|
|
44
44
|
inputs?: Record<string, unknown> | undefined;
|
|
45
45
|
}, {
|
|
@@ -48,9 +48,9 @@ export declare const ListInputFieldChoicesSchema: z.ZodObject<{
|
|
|
48
48
|
actionKey: string;
|
|
49
49
|
inputFieldKey: string;
|
|
50
50
|
page?: number | undefined;
|
|
51
|
-
cursor?: string | undefined;
|
|
52
|
-
maxItems?: number | undefined;
|
|
53
51
|
pageSize?: number | undefined;
|
|
52
|
+
maxItems?: number | undefined;
|
|
53
|
+
cursor?: string | undefined;
|
|
54
54
|
authenticationId?: number | null | undefined;
|
|
55
55
|
inputs?: Record<string, unknown> | undefined;
|
|
56
56
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFields/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,qBAAqB,EACrB,KAAK,sBAAsB,EAE5B,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAoKxE,MAAM,WAAW,6BAA6B;IAC5C,eAAe,EAAE,CAAC,OAAO,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC;QAC7D,IAAI,EAAE,aAAa,EAAE,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,aAAa,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC9D,KAAK,IAAI,aAAa,CAAC,cAAc,GAAG,aAAa,GAAG,YAAY,CAAC,CAAC;KACvE,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,eAAe,EAAE;gBACf,WAAW,EAAE,OAAO,qBAAqB,CAAC;aAC3C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,UAAU,CAAC,oBAAoB,GAAG,uBAAuB,CAAC,EAAE,uCAAuC;AACnG;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,EAAE,2DAA2D;AAC9D,6BAA6B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFields/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,qBAAqB,EACrB,KAAK,sBAAsB,EAE5B,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAoKxE,MAAM,WAAW,6BAA6B;IAC5C,eAAe,EAAE,CAAC,OAAO,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC;QAC7D,IAAI,EAAE,aAAa,EAAE,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,aAAa,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC9D,KAAK,IAAI,aAAa,CAAC,cAAc,GAAG,aAAa,GAAG,YAAY,CAAC,CAAC;KACvE,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,eAAe,EAAE;gBACf,WAAW,EAAE,OAAO,qBAAqB,CAAC;aAC3C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,UAAU,CAAC,oBAAoB,GAAG,uBAAuB,CAAC,EAAE,uCAAuC;AACnG;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,EAAE,2DAA2D;AAC9D,6BAA6B,CAgF9B,CAAC"}
|
|
@@ -154,6 +154,8 @@ export const listInputFieldsPlugin = ({ sdk, context }) => {
|
|
|
154
154
|
if (!selectedApi) {
|
|
155
155
|
throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
|
|
156
156
|
}
|
|
157
|
+
// Need to call getAction here because it resolves both action.key AND action.id
|
|
158
|
+
// eg: `create_report` or `core:39487493`
|
|
157
159
|
const { data: action } = await sdk.getAction({
|
|
158
160
|
appKey,
|
|
159
161
|
actionType,
|
|
@@ -17,18 +17,18 @@ export declare const ListInputFieldsSchema: z.ZodObject<{
|
|
|
17
17
|
appKey: string;
|
|
18
18
|
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
19
19
|
actionKey: string;
|
|
20
|
-
cursor?: string | undefined;
|
|
21
|
-
maxItems?: number | undefined;
|
|
22
20
|
pageSize?: number | undefined;
|
|
21
|
+
maxItems?: number | undefined;
|
|
22
|
+
cursor?: string | undefined;
|
|
23
23
|
authenticationId?: number | null | undefined;
|
|
24
24
|
inputs?: Record<string, unknown> | undefined;
|
|
25
25
|
}, {
|
|
26
26
|
appKey: string;
|
|
27
27
|
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
28
28
|
actionKey: string;
|
|
29
|
-
cursor?: string | undefined;
|
|
30
|
-
maxItems?: number | undefined;
|
|
31
29
|
pageSize?: number | undefined;
|
|
30
|
+
maxItems?: number | undefined;
|
|
31
|
+
cursor?: string | undefined;
|
|
32
32
|
authenticationId?: number | null | undefined;
|
|
33
33
|
inputs?: Record<string, unknown> | undefined;
|
|
34
34
|
}>;
|
|
@@ -16,18 +16,18 @@ export declare const RunActionSchema: z.ZodObject<{
|
|
|
16
16
|
appKey: string;
|
|
17
17
|
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
18
18
|
actionKey: string;
|
|
19
|
-
cursor?: string | undefined;
|
|
20
|
-
maxItems?: number | undefined;
|
|
21
19
|
pageSize?: number | undefined;
|
|
20
|
+
maxItems?: number | undefined;
|
|
21
|
+
cursor?: string | undefined;
|
|
22
22
|
authenticationId?: number | null | undefined;
|
|
23
23
|
inputs?: Record<string, unknown> | undefined;
|
|
24
24
|
}, {
|
|
25
25
|
appKey: string;
|
|
26
26
|
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
27
27
|
actionKey: string;
|
|
28
|
-
cursor?: string | undefined;
|
|
29
|
-
maxItems?: number | undefined;
|
|
30
28
|
pageSize?: number | undefined;
|
|
29
|
+
maxItems?: number | undefined;
|
|
30
|
+
cursor?: string | undefined;
|
|
31
31
|
authenticationId?: number | null | undefined;
|
|
32
32
|
inputs?: Record<string, unknown> | undefined;
|
|
33
33
|
}>;
|