@zapier/zapier-sdk 0.8.2 → 0.9.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.
- package/CHANGELOG.md +12 -0
- package/README.md +10 -33
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +1 -2
- package/dist/api/polling.d.ts +36 -6
- package/dist/api/polling.d.ts.map +1 -1
- package/dist/api/polling.js +132 -28
- package/dist/api/polling.test.d.ts +2 -0
- package/dist/api/polling.test.d.ts.map +1 -0
- package/dist/api/polling.test.js +318 -0
- package/dist/api/types.d.ts +1 -2
- package/dist/api/types.d.ts.map +1 -1
- package/dist/index.cjs +489 -252
- package/dist/index.d.mts +182 -187
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.mjs +486 -251
- package/dist/plugins/apps/index.d.ts +4 -0
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.d.ts +2 -7
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +9 -9
- package/dist/plugins/getApp/index.test.js +1 -1
- package/dist/plugins/getAuthentication/index.test.js +1 -1
- package/dist/plugins/listActions/index.d.ts +2 -4
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +1 -1
- package/dist/plugins/listActions/index.test.js +4 -4
- package/dist/plugins/listApps/index.d.ts +4 -7
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +33 -17
- package/dist/plugins/listApps/index.test.js +22 -2
- package/dist/plugins/listAuthentications/index.d.ts +2 -4
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/index.js +4 -0
- package/dist/plugins/listAuthentications/index.test.js +39 -13
- package/dist/plugins/listAuthentications/schemas.d.ts +3 -0
- package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/schemas.js +4 -0
- package/dist/plugins/manifest/index.d.ts +25 -9
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +239 -67
- package/dist/plugins/manifest/index.test.js +426 -171
- package/dist/plugins/manifest/schemas.d.ts +5 -1
- package/dist/plugins/manifest/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/schemas.js +1 -0
- package/dist/sdk.d.ts +5 -11
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +1 -4
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +6 -3
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/domain-utils.d.ts +16 -0
- package/dist/utils/domain-utils.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +46 -27
- package/dist/utils/domain-utils.test.js +157 -3
- package/dist/utils/file-utils.d.ts +4 -0
- package/dist/utils/file-utils.d.ts.map +1 -0
- package/dist/utils/file-utils.js +74 -0
- package/dist/utils/file-utils.test.d.ts +2 -0
- package/dist/utils/file-utils.test.d.ts.map +1 -0
- package/dist/utils/file-utils.test.js +51 -0
- package/package.json +1 -1
- package/src/api/client.ts +5 -4
- package/src/api/polling.test.ts +405 -0
- package/src/api/polling.ts +224 -44
- package/src/api/types.ts +1 -2
- package/src/index.ts +1 -1
- package/src/plugins/apps/index.ts +9 -2
- package/src/plugins/getApp/index.test.ts +1 -1
- package/src/plugins/getApp/index.ts +12 -14
- package/src/plugins/getAuthentication/index.test.ts +1 -1
- package/src/plugins/listActions/index.test.ts +8 -7
- package/src/plugins/listActions/index.ts +3 -3
- package/src/plugins/listApps/index.test.ts +23 -2
- package/src/plugins/listApps/index.ts +46 -25
- package/src/plugins/listAuthentications/index.test.ts +52 -15
- package/src/plugins/listAuthentications/index.ts +7 -2
- package/src/plugins/listAuthentications/schemas.ts +4 -0
- package/src/plugins/manifest/index.test.ts +503 -197
- package/src/plugins/manifest/index.ts +338 -82
- package/src/plugins/manifest/schemas.ts +9 -2
- package/src/sdk.ts +1 -5
- package/src/types/plugin.ts +3 -0
- package/src/types/sdk.ts +26 -21
- package/src/utils/domain-utils.test.ts +196 -2
- package/src/utils/domain-utils.ts +68 -35
- package/src/utils/file-utils.test.ts +73 -0
- package/src/utils/file-utils.ts +94 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/plugins/lockVersion/index.d.ts +0 -24
- package/dist/plugins/lockVersion/index.d.ts.map +0 -1
- package/dist/plugins/lockVersion/index.js +0 -72
- package/dist/plugins/lockVersion/index.test.d.ts +0 -2
- package/dist/plugins/lockVersion/index.test.d.ts.map +0 -1
- package/dist/plugins/lockVersion/index.test.js +0 -129
- package/dist/plugins/lockVersion/schemas.d.ts +0 -10
- package/dist/plugins/lockVersion/schemas.d.ts.map +0 -1
- package/dist/plugins/lockVersion/schemas.js +0 -6
- package/src/plugins/lockVersion/index.test.ts +0 -176
- package/src/plugins/lockVersion/index.ts +0 -112
- package/src/plugins/lockVersion/schemas.ts +0 -9
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
import { listAuthenticationsPlugin } from "./index";
|
|
7
7
|
import { createSdk } from "../../sdk";
|
|
8
8
|
import type { ApiClient } from "../../api";
|
|
9
|
-
import type { AppItem } from "../../types/domain";
|
|
10
9
|
|
|
11
10
|
const mockAuthenticationsResponse = {
|
|
12
11
|
results: [
|
|
@@ -42,15 +41,6 @@ const mockAuthenticationsResponse = {
|
|
|
42
41
|
previous: null,
|
|
43
42
|
};
|
|
44
43
|
|
|
45
|
-
const mockSlackApp: AppItem = {
|
|
46
|
-
title: "Slack",
|
|
47
|
-
key: "SlackCLIAPI",
|
|
48
|
-
current_implementation_id: "SlackCLIAPI@1.21.1",
|
|
49
|
-
version: "1.21.1",
|
|
50
|
-
description: "Team communication platform",
|
|
51
|
-
slug: "slack",
|
|
52
|
-
};
|
|
53
|
-
|
|
54
44
|
describe("listAuthentications plugin", () => {
|
|
55
45
|
let mockApiClient: ApiClient;
|
|
56
46
|
let mockGetVersionedImplementationId: any;
|
|
@@ -72,15 +62,14 @@ describe("listAuthentications plugin", () => {
|
|
|
72
62
|
},
|
|
73
63
|
});
|
|
74
64
|
|
|
65
|
+
const mockResolveAppKeys = vi.fn().mockResolvedValue([]);
|
|
66
|
+
|
|
75
67
|
const manifestPlugin = () => ({
|
|
76
68
|
context: {
|
|
77
69
|
manifest: null,
|
|
78
70
|
getVersionedImplementationId: mockGetVersionedImplementationId,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
version: "1.21.1",
|
|
82
|
-
}),
|
|
83
|
-
getImplementation: vi.fn().mockResolvedValue(mockSlackApp),
|
|
71
|
+
resolveAppKeys: mockResolveAppKeys,
|
|
72
|
+
updateManifestEntry: vi.fn().mockResolvedValue(["test-key", {}]),
|
|
84
73
|
},
|
|
85
74
|
});
|
|
86
75
|
|
|
@@ -152,6 +141,21 @@ describe("listAuthentications plugin", () => {
|
|
|
152
141
|
}).toThrow(ZapierValidationError);
|
|
153
142
|
});
|
|
154
143
|
|
|
144
|
+
it("should throw validation error for invalid authenticationIds type", () => {
|
|
145
|
+
const sdk = createTestSdk();
|
|
146
|
+
expect(() => {
|
|
147
|
+
sdk.listAuthentications({
|
|
148
|
+
authenticationIds: "123" as any, // Should be array of strings
|
|
149
|
+
});
|
|
150
|
+
}).toThrow(ZapierValidationError);
|
|
151
|
+
|
|
152
|
+
expect(() => {
|
|
153
|
+
sdk.listAuthentications({
|
|
154
|
+
authenticationIds: [123] as any, // Should be array of strings, not numbers
|
|
155
|
+
});
|
|
156
|
+
}).toThrow(ZapierValidationError);
|
|
157
|
+
});
|
|
158
|
+
|
|
155
159
|
it("should throw validation error for invalid pageSize", () => {
|
|
156
160
|
const sdk = createTestSdk();
|
|
157
161
|
expect(() => {
|
|
@@ -186,6 +190,7 @@ describe("listAuthentications plugin", () => {
|
|
|
186
190
|
const sdk = createTestSdk();
|
|
187
191
|
const result = await sdk.listAuthentications({
|
|
188
192
|
appKey: "slack",
|
|
193
|
+
authenticationIds: ["123", "456"],
|
|
189
194
|
search: "workspace",
|
|
190
195
|
title: "My Slack Workspace",
|
|
191
196
|
accountId: "acc_123",
|
|
@@ -336,6 +341,38 @@ describe("listAuthentications plugin", () => {
|
|
|
336
341
|
}),
|
|
337
342
|
);
|
|
338
343
|
});
|
|
344
|
+
|
|
345
|
+
it("should pass authenticationIds as ids parameter to API", async () => {
|
|
346
|
+
const sdk = createTestSdk();
|
|
347
|
+
await sdk.listAuthentications({
|
|
348
|
+
authenticationIds: ["123", "456", "789"],
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
expect(mockApiClient.get).toHaveBeenCalledWith(
|
|
352
|
+
"/api/v4/authentications/",
|
|
353
|
+
expect.objectContaining({
|
|
354
|
+
searchParams: expect.objectContaining({
|
|
355
|
+
ids: "123,456,789",
|
|
356
|
+
}),
|
|
357
|
+
}),
|
|
358
|
+
);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
it("should not include ids parameter when authenticationIds is empty", async () => {
|
|
362
|
+
const sdk = createTestSdk();
|
|
363
|
+
await sdk.listAuthentications({
|
|
364
|
+
authenticationIds: [],
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
expect(mockApiClient.get).toHaveBeenCalledWith(
|
|
368
|
+
"/api/v4/authentications/",
|
|
369
|
+
expect.objectContaining({
|
|
370
|
+
searchParams: expect.not.objectContaining({
|
|
371
|
+
ids: expect.anything(),
|
|
372
|
+
}),
|
|
373
|
+
}),
|
|
374
|
+
);
|
|
375
|
+
});
|
|
339
376
|
});
|
|
340
377
|
|
|
341
378
|
describe("pagination", () => {
|
|
@@ -36,11 +36,11 @@ export interface ListAuthenticationsPluginProvides {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export const listAuthenticationsPlugin: Plugin<
|
|
39
|
-
GetSdkType<ManifestPluginProvides>,
|
|
39
|
+
GetSdkType<ManifestPluginProvides>,
|
|
40
40
|
{
|
|
41
41
|
api: ApiClient;
|
|
42
42
|
getVersionedImplementationId: GetVersionedImplementationId;
|
|
43
|
-
},
|
|
43
|
+
},
|
|
44
44
|
ListAuthenticationsPluginProvides
|
|
45
45
|
> = ({ context }) => {
|
|
46
46
|
const listAuthentications = createPaginatedFunction(
|
|
@@ -64,6 +64,11 @@ export const listAuthenticationsPlugin: Plugin<
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
// Add authenticationIds as ids parameter if provided
|
|
68
|
+
if (options.authenticationIds && options.authenticationIds.length > 0) {
|
|
69
|
+
searchParams.ids = options.authenticationIds.join(",");
|
|
70
|
+
}
|
|
71
|
+
|
|
67
72
|
// Add other query parameters if provided
|
|
68
73
|
// Use title as search if no explicit search provided
|
|
69
74
|
if (options.search) {
|
|
@@ -16,6 +16,10 @@ export const ListAuthenticationsSchema = z
|
|
|
16
16
|
appKey: AppKeyPropertySchema.optional().describe(
|
|
17
17
|
"App key of authentications to list (e.g., 'SlackCLIAPI')",
|
|
18
18
|
),
|
|
19
|
+
authenticationIds: z
|
|
20
|
+
.array(z.string())
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("List of authentication IDs to filter by"),
|
|
19
23
|
search: z
|
|
20
24
|
.string()
|
|
21
25
|
.optional()
|