@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.
Files changed (104) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +10 -33
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +1 -2
  5. package/dist/api/polling.d.ts +36 -6
  6. package/dist/api/polling.d.ts.map +1 -1
  7. package/dist/api/polling.js +132 -28
  8. package/dist/api/polling.test.d.ts +2 -0
  9. package/dist/api/polling.test.d.ts.map +1 -0
  10. package/dist/api/polling.test.js +318 -0
  11. package/dist/api/types.d.ts +1 -2
  12. package/dist/api/types.d.ts.map +1 -1
  13. package/dist/index.cjs +489 -252
  14. package/dist/index.d.mts +182 -187
  15. package/dist/index.d.ts +1 -2
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +0 -1
  18. package/dist/index.mjs +486 -251
  19. package/dist/plugins/apps/index.d.ts +4 -0
  20. package/dist/plugins/apps/index.d.ts.map +1 -1
  21. package/dist/plugins/getApp/index.d.ts +2 -7
  22. package/dist/plugins/getApp/index.d.ts.map +1 -1
  23. package/dist/plugins/getApp/index.js +9 -9
  24. package/dist/plugins/getApp/index.test.js +1 -1
  25. package/dist/plugins/getAuthentication/index.test.js +1 -1
  26. package/dist/plugins/listActions/index.d.ts +2 -4
  27. package/dist/plugins/listActions/index.d.ts.map +1 -1
  28. package/dist/plugins/listActions/index.js +1 -1
  29. package/dist/plugins/listActions/index.test.js +4 -4
  30. package/dist/plugins/listApps/index.d.ts +4 -7
  31. package/dist/plugins/listApps/index.d.ts.map +1 -1
  32. package/dist/plugins/listApps/index.js +33 -17
  33. package/dist/plugins/listApps/index.test.js +22 -2
  34. package/dist/plugins/listAuthentications/index.d.ts +2 -4
  35. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  36. package/dist/plugins/listAuthentications/index.js +4 -0
  37. package/dist/plugins/listAuthentications/index.test.js +39 -13
  38. package/dist/plugins/listAuthentications/schemas.d.ts +3 -0
  39. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
  40. package/dist/plugins/listAuthentications/schemas.js +4 -0
  41. package/dist/plugins/manifest/index.d.ts +25 -9
  42. package/dist/plugins/manifest/index.d.ts.map +1 -1
  43. package/dist/plugins/manifest/index.js +239 -67
  44. package/dist/plugins/manifest/index.test.js +426 -171
  45. package/dist/plugins/manifest/schemas.d.ts +5 -1
  46. package/dist/plugins/manifest/schemas.d.ts.map +1 -1
  47. package/dist/plugins/manifest/schemas.js +1 -0
  48. package/dist/sdk.d.ts +5 -11
  49. package/dist/sdk.d.ts.map +1 -1
  50. package/dist/sdk.js +1 -4
  51. package/dist/types/plugin.d.ts +1 -0
  52. package/dist/types/plugin.d.ts.map +1 -1
  53. package/dist/types/sdk.d.ts +6 -3
  54. package/dist/types/sdk.d.ts.map +1 -1
  55. package/dist/utils/domain-utils.d.ts +16 -0
  56. package/dist/utils/domain-utils.d.ts.map +1 -1
  57. package/dist/utils/domain-utils.js +46 -27
  58. package/dist/utils/domain-utils.test.js +157 -3
  59. package/dist/utils/file-utils.d.ts +4 -0
  60. package/dist/utils/file-utils.d.ts.map +1 -0
  61. package/dist/utils/file-utils.js +74 -0
  62. package/dist/utils/file-utils.test.d.ts +2 -0
  63. package/dist/utils/file-utils.test.d.ts.map +1 -0
  64. package/dist/utils/file-utils.test.js +51 -0
  65. package/package.json +1 -1
  66. package/src/api/client.ts +5 -4
  67. package/src/api/polling.test.ts +405 -0
  68. package/src/api/polling.ts +224 -44
  69. package/src/api/types.ts +1 -2
  70. package/src/index.ts +1 -1
  71. package/src/plugins/apps/index.ts +9 -2
  72. package/src/plugins/getApp/index.test.ts +1 -1
  73. package/src/plugins/getApp/index.ts +12 -14
  74. package/src/plugins/getAuthentication/index.test.ts +1 -1
  75. package/src/plugins/listActions/index.test.ts +8 -7
  76. package/src/plugins/listActions/index.ts +3 -3
  77. package/src/plugins/listApps/index.test.ts +23 -2
  78. package/src/plugins/listApps/index.ts +46 -25
  79. package/src/plugins/listAuthentications/index.test.ts +52 -15
  80. package/src/plugins/listAuthentications/index.ts +7 -2
  81. package/src/plugins/listAuthentications/schemas.ts +4 -0
  82. package/src/plugins/manifest/index.test.ts +503 -197
  83. package/src/plugins/manifest/index.ts +338 -82
  84. package/src/plugins/manifest/schemas.ts +9 -2
  85. package/src/sdk.ts +1 -5
  86. package/src/types/plugin.ts +3 -0
  87. package/src/types/sdk.ts +26 -21
  88. package/src/utils/domain-utils.test.ts +196 -2
  89. package/src/utils/domain-utils.ts +68 -35
  90. package/src/utils/file-utils.test.ts +73 -0
  91. package/src/utils/file-utils.ts +94 -0
  92. package/tsconfig.tsbuildinfo +1 -1
  93. package/dist/plugins/lockVersion/index.d.ts +0 -24
  94. package/dist/plugins/lockVersion/index.d.ts.map +0 -1
  95. package/dist/plugins/lockVersion/index.js +0 -72
  96. package/dist/plugins/lockVersion/index.test.d.ts +0 -2
  97. package/dist/plugins/lockVersion/index.test.d.ts.map +0 -1
  98. package/dist/plugins/lockVersion/index.test.js +0 -129
  99. package/dist/plugins/lockVersion/schemas.d.ts +0 -10
  100. package/dist/plugins/lockVersion/schemas.d.ts.map +0 -1
  101. package/dist/plugins/lockVersion/schemas.js +0 -6
  102. package/src/plugins/lockVersion/index.test.ts +0 -176
  103. package/src/plugins/lockVersion/index.ts +0 -112
  104. 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
- getManifestEntry: () => ({
80
- implementationName: "SlackCLIAPI",
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>, // requires getApp in SDK
39
+ GetSdkType<ManifestPluginProvides>,
40
40
  {
41
41
  api: ApiClient;
42
42
  getVersionedImplementationId: GetVersionedImplementationId;
43
- }, // requires api in context
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()