@zapier/zapier-sdk 0.5.2 → 0.6.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 (115) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +107 -83
  3. package/dist/index.cjs +320 -50
  4. package/dist/index.d.mts +409 -340
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +0 -1
  7. package/dist/index.mjs +320 -50
  8. package/dist/plugins/api/index.js +1 -1
  9. package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
  10. package/dist/plugins/findFirstAuthentication/index.js +1 -0
  11. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
  12. package/dist/plugins/findUniqueAuthentication/index.js +1 -0
  13. package/dist/plugins/getAction/index.d.ts.map +1 -1
  14. package/dist/plugins/getAction/index.js +1 -0
  15. package/dist/plugins/getAction/index.test.js +1 -1
  16. package/dist/plugins/getApp/index.d.ts +6 -3
  17. package/dist/plugins/getApp/index.d.ts.map +1 -1
  18. package/dist/plugins/getApp/index.js +8 -18
  19. package/dist/plugins/getApp/index.test.js +2 -0
  20. package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
  21. package/dist/plugins/getAuthentication/index.js +1 -0
  22. package/dist/plugins/getAuthentication/index.test.js +12 -1
  23. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  24. package/dist/plugins/getProfile/index.js +1 -0
  25. package/dist/plugins/listActions/index.d.ts +5 -3
  26. package/dist/plugins/listActions/index.d.ts.map +1 -1
  27. package/dist/plugins/listActions/index.js +6 -6
  28. package/dist/plugins/listActions/index.test.js +26 -74
  29. package/dist/plugins/listActions/schemas.d.ts +4 -4
  30. package/dist/plugins/listApps/index.d.ts.map +1 -1
  31. package/dist/plugins/listApps/index.js +1 -0
  32. package/dist/plugins/listApps/schemas.d.ts +2 -2
  33. package/dist/plugins/listAuthentications/index.d.ts +4 -2
  34. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  35. package/dist/plugins/listAuthentications/index.js +9 -12
  36. package/dist/plugins/listAuthentications/index.test.js +33 -40
  37. package/dist/plugins/listAuthentications/schemas.d.ts +4 -4
  38. package/dist/plugins/listInputFields/index.d.ts +3 -1
  39. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  40. package/dist/plugins/listInputFields/index.js +5 -5
  41. package/dist/plugins/listInputFields/index.test.js +10 -8
  42. package/dist/plugins/listInputFields/schemas.d.ts +4 -4
  43. package/dist/plugins/lockVersion/index.d.ts +24 -0
  44. package/dist/plugins/lockVersion/index.d.ts.map +1 -0
  45. package/dist/plugins/lockVersion/index.js +72 -0
  46. package/dist/plugins/lockVersion/index.test.d.ts +2 -0
  47. package/dist/plugins/lockVersion/index.test.d.ts.map +1 -0
  48. package/dist/plugins/lockVersion/index.test.js +129 -0
  49. package/dist/plugins/lockVersion/schemas.d.ts +10 -0
  50. package/dist/plugins/lockVersion/schemas.d.ts.map +1 -0
  51. package/dist/plugins/lockVersion/schemas.js +6 -0
  52. package/dist/plugins/manifest/index.d.ts +24 -0
  53. package/dist/plugins/manifest/index.d.ts.map +1 -0
  54. package/dist/plugins/manifest/index.js +119 -0
  55. package/dist/plugins/manifest/index.test.d.ts +2 -0
  56. package/dist/plugins/manifest/index.test.d.ts.map +1 -0
  57. package/dist/plugins/manifest/index.test.js +331 -0
  58. package/dist/plugins/manifest/schemas.d.ts +64 -0
  59. package/dist/plugins/manifest/schemas.d.ts.map +1 -0
  60. package/dist/plugins/manifest/schemas.js +25 -0
  61. package/dist/plugins/registry/index.d.ts +9 -1
  62. package/dist/plugins/registry/index.d.ts.map +1 -1
  63. package/dist/plugins/registry/index.js +68 -3
  64. package/dist/plugins/request/index.d.ts.map +1 -1
  65. package/dist/plugins/request/index.js +1 -0
  66. package/dist/plugins/request/index.test.js +6 -1
  67. package/dist/plugins/request/schemas.d.ts +4 -4
  68. package/dist/plugins/runAction/index.d.ts +2 -0
  69. package/dist/plugins/runAction/index.d.ts.map +1 -1
  70. package/dist/plugins/runAction/index.js +5 -5
  71. package/dist/plugins/runAction/index.test.js +9 -8
  72. package/dist/plugins/runAction/schemas.d.ts +4 -4
  73. package/dist/sdk.d.ts +3 -3
  74. package/dist/sdk.d.ts.map +1 -1
  75. package/dist/sdk.js +18 -7
  76. package/dist/sdk.test.js +1 -1
  77. package/dist/types/plugin.d.ts +10 -2
  78. package/dist/types/plugin.d.ts.map +1 -1
  79. package/dist/types/sdk.d.ts +13 -2
  80. package/dist/types/sdk.d.ts.map +1 -1
  81. package/package.json +1 -1
  82. package/src/index.ts +0 -2
  83. package/src/plugins/api/index.ts +1 -1
  84. package/src/plugins/findFirstAuthentication/index.ts +1 -0
  85. package/src/plugins/findUniqueAuthentication/index.ts +1 -0
  86. package/src/plugins/getAction/index.test.ts +1 -1
  87. package/src/plugins/getAction/index.ts +1 -0
  88. package/src/plugins/getApp/index.test.ts +2 -0
  89. package/src/plugins/getApp/index.ts +12 -24
  90. package/src/plugins/getAuthentication/index.test.ts +13 -3
  91. package/src/plugins/getAuthentication/index.ts +1 -0
  92. package/src/plugins/getProfile/index.ts +1 -0
  93. package/src/plugins/listActions/index.test.ts +30 -89
  94. package/src/plugins/listActions/index.ts +13 -9
  95. package/src/plugins/listApps/index.ts +1 -0
  96. package/src/plugins/listAuthentications/index.test.ts +38 -47
  97. package/src/plugins/listAuthentications/index.ts +21 -18
  98. package/src/plugins/listInputFields/index.test.ts +12 -9
  99. package/src/plugins/listInputFields/index.ts +10 -6
  100. package/src/plugins/lockVersion/index.test.ts +176 -0
  101. package/src/plugins/lockVersion/index.ts +112 -0
  102. package/src/plugins/lockVersion/schemas.ts +9 -0
  103. package/src/plugins/manifest/index.test.ts +439 -0
  104. package/src/plugins/manifest/index.ts +171 -0
  105. package/src/plugins/manifest/schemas.ts +53 -0
  106. package/src/plugins/registry/index.ts +89 -8
  107. package/src/plugins/request/index.test.ts +8 -4
  108. package/src/plugins/request/index.ts +1 -0
  109. package/src/plugins/runAction/index.test.ts +9 -8
  110. package/src/plugins/runAction/index.ts +13 -7
  111. package/src/sdk.test.ts +1 -1
  112. package/src/sdk.ts +22 -7
  113. package/src/types/plugin.ts +14 -2
  114. package/src/types/sdk.ts +15 -1
  115. package/tsconfig.tsbuildinfo +1 -1
@@ -2,8 +2,9 @@ import type { Plugin } from "../../types/plugin";
2
2
  import { GetAppSchema } from "./schemas";
3
3
  import type { GetAppOptions } from "./schemas";
4
4
  import type { AppItem } from "../../types/domain";
5
- import type { ListAppsPluginProvides } from "../listApps";
6
5
  import type { GetSdkType } from "../../types/plugin";
6
+ import { GetImplementation } from "../manifest/schemas";
7
+ import { ManifestPluginProvides } from "../manifest";
7
8
  export interface GetAppPluginProvides {
8
9
  getApp: (options: GetAppOptions) => Promise<{
9
10
  data: AppItem;
@@ -16,7 +17,9 @@ export interface GetAppPluginProvides {
16
17
  };
17
18
  };
18
19
  }
19
- export declare const getAppPlugin: Plugin<GetSdkType<ListAppsPluginProvides>, // depends on listApps
20
- {}, // no additional context dependencies
20
+ export declare const getAppPlugin: Plugin<GetSdkType<ManifestPluginProvides>, // depends on manifest plugin with getImplementation in context
21
+ {
22
+ getImplementation: GetImplementation;
23
+ }, //
21
24
  GetAppPluginProvides>;
22
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getApp/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,MAAM,WAAW,oBAA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E,EAAE,EAAE;AAC5C,oBAAoB,CA2BrB,CAAC"}
@@ -2,27 +2,16 @@ import { createFunction } from "../../utils/function-utils";
2
2
  import { GetAppSchema } from "./schemas";
3
3
  import { ZapierAppNotFoundError } from "../../types/errors";
4
4
  // GetApp plugin depends on listApps SDK function
5
- export const getAppPlugin = ({ sdk }) => {
5
+ export const getAppPlugin = ({ context }) => {
6
6
  const getApp = createFunction(async function getApp(options) {
7
- const { appKey } = options;
8
- // Use listApps to get the app by key
9
- const appsIterator = sdk
10
- .listApps({
11
- ...options,
12
- appKeys: [appKey],
13
- })
14
- .items();
15
- // Get the first (and should be only) result
16
- const apps = [];
17
- for await (const app of appsIterator) {
18
- apps.push(app);
19
- break; // Only need the first result
20
- }
21
- if (apps.length === 0) {
22
- throw new ZapierAppNotFoundError(appKey);
7
+ const app = await context.getImplementation(options.appKey);
8
+ if (!app) {
9
+ throw new ZapierAppNotFoundError("App not found", {
10
+ appKey: options.appKey,
11
+ });
23
12
  }
24
13
  return {
25
- data: apps[0],
14
+ data: app,
26
15
  };
27
16
  }, GetAppSchema);
28
17
  // Return flat structure - getApp goes directly to SDK
@@ -31,6 +20,7 @@ export const getAppPlugin = ({ sdk }) => {
31
20
  context: {
32
21
  meta: {
33
22
  getApp: {
23
+ categories: ["app"],
34
24
  inputSchema: GetAppSchema,
35
25
  },
36
26
  },
@@ -4,10 +4,12 @@ import { getAppPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
5
  import { apiPlugin } from "../api/index";
6
6
  import { listAppsPlugin } from "../listApps";
7
+ import { manifestPlugin } from "../manifest";
7
8
  function createTestSdk() {
8
9
  return createSdk()
9
10
  .addPlugin(apiPlugin, { fetch: global.fetch })
10
11
  .addPlugin(listAppsPlugin)
12
+ .addPlugin(manifestPlugin)
11
13
  .addPlugin(getAppPlugin);
12
14
  }
13
15
  describe("getApp plugin", () => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAuthentication/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,uBAAuB,EACvB,KAAK,wBAAwB,EAC9B,MAAM,WAAW,CAAC;AAQnB,MAAM,WAAW,+BAA+B;IAC9C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC;QAAE,IAAI,EAAE,kBAAkB,CAAA;KAAE,CAAC,CAAC;IAC3C,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,iBAAiB,EAAE;gBACjB,WAAW,EAAE,OAAO,uBAAuB,CAAC;aAC7C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,+BAA+B,CAsDhC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAuthentication/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,uBAAuB,EACvB,KAAK,wBAAwB,EAC9B,MAAM,WAAW,CAAC;AAQnB,MAAM,WAAW,+BAA+B;IAC9C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC;QAAE,IAAI,EAAE,kBAAkB,CAAA;KAAE,CAAC,CAAC;IAC3C,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,iBAAiB,EAAE;gBACjB,WAAW,EAAE,OAAO,uBAAuB,CAAC;aAC7C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,+BAA+B,CAuDhC,CAAC"}
@@ -33,6 +33,7 @@ export const getAuthenticationPlugin = ({ context }) => {
33
33
  context: {
34
34
  meta: {
35
35
  getAuthentication: {
36
+ categories: ["authentication"],
36
37
  inputSchema: GetAuthenticationSchema,
37
38
  },
38
39
  },
@@ -2,6 +2,8 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { ZapierValidationError, ZapierAuthenticationError, ZapierResourceNotFoundError, } from "../../types/errors";
3
3
  import { getAuthenticationPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
+ import { manifestPlugin } from "../manifest";
6
+ import { listAppsPlugin } from "../listApps";
5
7
  const mockAuthenticationResponse = {
6
8
  id: 123,
7
9
  date: "2021-01-01",
@@ -23,8 +25,17 @@ describe("getAuthentication plugin", () => {
23
25
  get: vi.fn().mockResolvedValue(mockAuthenticationResponse),
24
26
  };
25
27
  });
28
+ const apiPlugin = () => ({
29
+ context: {
30
+ api: mockApiClient,
31
+ },
32
+ });
26
33
  function createTestSdk() {
27
- return createSdk({}, { api: mockApiClient, meta: {} }).addPlugin(getAuthenticationPlugin);
34
+ return createSdk()
35
+ .addPlugin(apiPlugin)
36
+ .addPlugin(listAppsPlugin)
37
+ .addPlugin(manifestPlugin)
38
+ .addPlugin(getAuthenticationPlugin);
28
39
  }
29
40
  describe("schema validation", () => {
30
41
  it("should throw validation error for missing authenticationId", async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getProfile/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAA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;aACtC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,wBAAwB,CA8BzB,CAAC"}
@@ -21,6 +21,7 @@ export const getProfilePlugin = ({ context }) => {
21
21
  context: {
22
22
  meta: {
23
23
  getProfile: {
24
+ categories: ["user"],
24
25
  inputSchema: GetProfileSchema,
25
26
  },
26
27
  },
@@ -2,7 +2,8 @@ import type { Plugin, GetSdkType } from "../../types/plugin";
2
2
  import type { ApiClient } from "../../api";
3
3
  import type { ActionItem } from "../../types/domain";
4
4
  import { ListActionsSchema, type ListActionsOptions } from "./schemas";
5
- import type { GetAppPluginProvides } from "../getApp";
5
+ import { ManifestPluginProvides } from "../manifest";
6
+ import { GetVersionedImplementationId } from "../manifest/schemas";
6
7
  export interface ListActionsPluginProvides {
7
8
  listActions: (options?: ListActionsOptions) => Promise<{
8
9
  data: ActionItem[];
@@ -20,9 +21,10 @@ export interface ListActionsPluginProvides {
20
21
  };
21
22
  };
22
23
  }
23
- export declare const listActionsPlugin: Plugin<GetSdkType<GetAppPluginProvides>, // requires getApp in SDK
24
+ export declare const listActionsPlugin: Plugin<GetSdkType<ManifestPluginProvides>, // requires getApp in SDK
24
25
  {
25
26
  api: ApiClient;
26
- }, // requires api in context
27
+ getVersionedImplementationId: GetVersionedImplementationId;
28
+ }, // requires api and getVersionedImplementationId in context
27
29
  ListActionsPluginProvides>;
28
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listActions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,WAAW,CAAC;AAC3D,OAAO,KAAK,E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AW,yBAAyB;IACxC,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,OAAO,CAAC;QACrD,IAAI,EAAE,UAAU,EAAE,CAAC;KACpB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC3D,KAAK,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;KACpC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,WAAW,EAAE;gBACX,WAAW,EAAE,OAAO,iBAAiB,CAAC;aACvC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CACpC,UAAU,CAAC,sBAAsB,CAAC,EAAE,yBAAyB;AAC7D;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,EAAE,2DAA2D;AAC9D,yBAAyB,CAkF1B,CAAC"}
@@ -2,19 +2,18 @@ import { normalizeActionItem } from "../../utils/domain-utils";
2
2
  import { ListActionsSchema, } from "./schemas";
3
3
  import { ZapierConfigurationError, ZapierAuthenticationError, } from "../../types/errors";
4
4
  import { createPaginatedFunction } from "../../utils/function-utils";
5
- export const listActionsPlugin = ({ sdk, context }) => {
5
+ export const listActionsPlugin = ({ context }) => {
6
6
  const listActions = createPaginatedFunction(async function listActionsPage(options) {
7
- const { api } = context;
7
+ const { api, getVersionedImplementationId } = context;
8
8
  // Use the getApp function from the SDK (dependency injection)
9
- const app = await sdk.getApp({ appKey: options.appKey });
10
- const implementationId = app.data.current_implementation_id?.split("@")[0];
11
- if (!implementationId) {
9
+ const selectedApi = await getVersionedImplementationId(options.appKey);
10
+ if (!selectedApi) {
12
11
  throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
13
12
  }
14
13
  const searchParams = {
15
14
  global: "true",
16
15
  public_only: "true",
17
- selected_apis: implementationId,
16
+ selected_apis: selectedApi,
18
17
  };
19
18
  const data = await api.get("/api/v4/implementations/", {
20
19
  searchParams,
@@ -53,6 +52,7 @@ export const listActionsPlugin = ({ sdk, context }) => {
53
52
  context: {
54
53
  meta: {
55
54
  listActions: {
55
+ categories: ["action"],
56
56
  inputSchema: ListActionsSchema,
57
57
  },
58
58
  },
@@ -2,17 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { ZapierValidationError, ZapierAuthenticationError, ZapierConfigurationError, } from "../../types/errors";
3
3
  import { listActionsPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
- import { GetAppSchema } from "../getApp/schemas";
6
- const mockAppResponse = {
7
- data: {
8
- slug: "slack",
9
- name: "Slack",
10
- current_implementation_id: "SlackCLIAPI@1.20.0",
11
- key: "slack",
12
- title: "Slack",
13
- hex_color: "#4A154B",
14
- },
15
- };
5
+ import { listAppsPlugin } from "../listApps";
16
6
  const mockImplementationsResponse = {
17
7
  results: [
18
8
  {
@@ -55,29 +45,35 @@ const mockEmptyImplementationsResponse = {
55
45
  };
56
46
  describe("listActions plugin", () => {
57
47
  let mockApiClient;
58
- let mockGetApp;
48
+ let mockGetVersionedImplementationId;
59
49
  beforeEach(() => {
60
50
  vi.clearAllMocks();
61
51
  mockApiClient = {
62
52
  get: vi.fn().mockResolvedValue(mockImplementationsResponse),
63
53
  };
64
- mockGetApp = vi.fn().mockResolvedValue(mockAppResponse);
54
+ mockGetVersionedImplementationId = vi
55
+ .fn()
56
+ .mockResolvedValue("SlackCLIAPI@1.21.1");
65
57
  });
66
58
  function createTestSdk() {
67
59
  // Create a proper plugin chain with context dependencies
68
- const mockGetAppPlugin = () => ({
69
- getApp: mockGetApp,
60
+ // Build SDK with proper plugin composition, providing API in initial context
61
+ return createSdk()
62
+ .addPlugin(() => ({
70
63
  context: {
71
- meta: {
72
- getApp: {
73
- inputSchema: GetAppSchema,
74
- },
75
- },
64
+ api: mockApiClient,
65
+ getVersionedImplementationId: mockGetVersionedImplementationId,
76
66
  },
77
- });
78
- // Build SDK with proper plugin composition, providing API in initial context
79
- return createSdk({}, { api: mockApiClient, meta: {} })
80
- .addPlugin(mockGetAppPlugin)
67
+ }))
68
+ .addPlugin(listAppsPlugin)
69
+ .addPlugin(() => ({
70
+ context: {
71
+ manifest: null,
72
+ getManifestEntry: () => null,
73
+ getVersionedImplementationId: mockGetVersionedImplementationId,
74
+ getImplementation: () => Promise.resolve(null),
75
+ },
76
+ }))
81
77
  .addPlugin(listActionsPlugin);
82
78
  }
83
79
  describe("schema validation", () => {
@@ -332,9 +328,7 @@ describe("listActions plugin", () => {
332
328
  it("should call getApp to get implementation ID", async () => {
333
329
  const sdk = createTestSdk();
334
330
  await sdk.listActions({ appKey: "slack" });
335
- expect(mockGetApp).toHaveBeenCalledWith({
336
- appKey: "slack",
337
- });
331
+ expect(mockGetVersionedImplementationId).toHaveBeenCalledWith("slack");
338
332
  });
339
333
  it("should pass correct search parameters to implementations API", async () => {
340
334
  const sdk = createTestSdk();
@@ -343,29 +337,19 @@ describe("listActions plugin", () => {
343
337
  searchParams: expect.objectContaining({
344
338
  global: "true",
345
339
  public_only: "true",
346
- selected_apis: "SlackCLIAPI", // Extracted from current_implementation_id
340
+ selected_apis: "SlackCLIAPI@1.21.1",
347
341
  }),
348
342
  }));
349
343
  });
350
344
  });
351
345
  describe("error handling", () => {
352
346
  it("should throw ZapierConfigurationError when app has no current_implementation_id", async () => {
353
- mockGetApp.mockResolvedValue({
354
- data: {
355
- ...mockAppResponse.data,
356
- current_implementation_id: undefined, // Missing implementation ID
357
- },
358
- });
347
+ mockGetVersionedImplementationId.mockResolvedValue(null);
359
348
  const sdk = createTestSdk();
360
349
  await expect(sdk.listActions({ appKey: "slack" })).rejects.toThrow(ZapierConfigurationError);
361
350
  });
362
351
  it("should throw ZapierConfigurationError when current_implementation_id is empty", async () => {
363
- mockGetApp.mockResolvedValue({
364
- data: {
365
- ...mockAppResponse.data,
366
- current_implementation_id: "", // Empty implementation ID
367
- },
368
- });
352
+ mockGetVersionedImplementationId.mockResolvedValue("");
369
353
  const sdk = createTestSdk();
370
354
  await expect(sdk.listActions({ appKey: "slack" })).rejects.toThrow(ZapierConfigurationError);
371
355
  });
@@ -418,44 +402,12 @@ describe("listActions plugin", () => {
418
402
  const result = await sdk.listActions({ appKey: "slack" });
419
403
  expect(result.data).toHaveLength(0);
420
404
  });
421
- it("should propagate getApp errors", async () => {
422
- mockGetApp.mockRejectedValue(new Error("App not found"));
405
+ it("should propagate getVersionedImplementationId errors", async () => {
406
+ mockGetVersionedImplementationId.mockRejectedValue(new Error("App not found"));
423
407
  const sdk = createTestSdk();
424
408
  await expect(sdk.listActions({ appKey: "nonexistent" })).rejects.toThrow("App not found");
425
409
  });
426
410
  });
427
- describe("implementation ID extraction", () => {
428
- it("should extract implementation name from versioned ID", async () => {
429
- mockGetApp.mockResolvedValue({
430
- data: {
431
- ...mockAppResponse.data,
432
- current_implementation_id: "CustomAPIName@2.5.0",
433
- },
434
- });
435
- const sdk = createTestSdk();
436
- await sdk.listActions({ appKey: "slack" });
437
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v4/implementations/", expect.objectContaining({
438
- searchParams: expect.objectContaining({
439
- selected_apis: "CustomAPIName", // Extracted name without version
440
- }),
441
- }));
442
- });
443
- it("should handle implementation ID without version", async () => {
444
- mockGetApp.mockResolvedValue({
445
- data: {
446
- ...mockAppResponse.data,
447
- current_implementation_id: "PlainAPIName",
448
- },
449
- });
450
- const sdk = createTestSdk();
451
- await sdk.listActions({ appKey: "slack" });
452
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v4/implementations/", expect.objectContaining({
453
- searchParams: expect.objectContaining({
454
- selected_apis: "PlainAPIName", // Used as-is
455
- }),
456
- }));
457
- });
458
- });
459
411
  describe("context and metadata", () => {
460
412
  it("should provide context with meta information", () => {
461
413
  const sdk = createTestSdk();
@@ -8,14 +8,14 @@ export declare const ListActionsSchema: z.ZodObject<{
8
8
  maxItems: z.ZodOptional<z.ZodNumber>;
9
9
  }, "strip", z.ZodTypeAny, {
10
10
  appKey: string;
11
- maxItems?: number | undefined;
12
- pageSize?: number | undefined;
13
11
  actionType?: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write" | undefined;
12
+ pageSize?: number | undefined;
13
+ maxItems?: number | undefined;
14
14
  }, {
15
15
  appKey: string;
16
- maxItems?: number | undefined;
17
- pageSize?: number | undefined;
18
16
  actionType?: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write" | undefined;
17
+ pageSize?: number | undefined;
18
+ maxItems?: number | undefined;
19
19
  }>;
20
20
  export type ListActionsOptions = z.infer<typeof ListActionsSchema>;
21
21
  export interface ListActionsPage {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,WAAW,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AASlD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,GACnE,aAAa,CAAC;QAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACxD,KAAK,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;KACjC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR,WAAW,EAAE,OAAO,cAAc,CAAC;aACpC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,sBAAsB,CAwFvB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,WAAW,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AASlD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,GACnE,aAAa,CAAC;QAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACxD,KAAK,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;KACjC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR,WAAW,EAAE,OAAO,cAAc,CAAC;aACpC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,sBAAsB,CAyFvB,CAAC"}
@@ -54,6 +54,7 @@ export const listAppsPlugin = ({ context }) => {
54
54
  context: {
55
55
  meta: {
56
56
  listApps: {
57
+ categories: ["app"],
57
58
  inputSchema: ListAppsSchema,
58
59
  },
59
60
  },
@@ -14,13 +14,13 @@ export declare const ListAppsSchema: z.ZodObject<{
14
14
  maxItems: z.ZodOptional<z.ZodNumber>;
15
15
  }, "strip", z.ZodTypeAny, {
16
16
  search?: string | undefined;
17
- maxItems?: number | undefined;
18
17
  pageSize?: number | undefined;
18
+ maxItems?: number | undefined;
19
19
  appKeys?: string[] | undefined;
20
20
  }, {
21
21
  search?: string | undefined;
22
- maxItems?: number | undefined;
23
22
  pageSize?: number | undefined;
23
+ maxItems?: number | undefined;
24
24
  appKeys?: string[] | undefined;
25
25
  }>;
26
26
  export type ListAppsOptions = z.infer<typeof ListAppsSchema>;
@@ -2,7 +2,8 @@ import type { Plugin, GetSdkType } from "../../types/plugin";
2
2
  import type { ApiClient } from "../../api";
3
3
  import type { AuthenticationItem } from "../../types/domain";
4
4
  import { ListAuthenticationsSchema, type ListAuthenticationsOptions } from "./schemas";
5
- import type { GetAppPluginProvides } from "../getApp";
5
+ import { GetVersionedImplementationId } from "../manifest/schemas";
6
+ import { ManifestPluginProvides } from "../manifest";
6
7
  export interface ListAuthenticationsPluginProvides {
7
8
  listAuthentications: (options?: ListAuthenticationsOptions) => Promise<{
8
9
  data: AuthenticationItem[];
@@ -20,9 +21,10 @@ export interface ListAuthenticationsPluginProvides {
20
21
  };
21
22
  };
22
23
  }
23
- export declare const listAuthenticationsPlugin: Plugin<GetSdkType<GetAppPluginProvides>, // requires getApp in SDK
24
+ export declare const listAuthenticationsPlugin: Plugin<GetSdkType<ManifestPluginProvides>, // requires getApp in SDK
24
25
  {
25
26
  api: ApiClient;
27
+ getVersionedImplementationId: GetVersionedImplementationId;
26
28
  }, // requires api in context
27
29
  ListAuthenticationsPluginProvides>;
28
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listAuthentications/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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BAA0B,EAEhC,MAAM,WAAW,CAAC;AAUnB,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,WAAW,iCAAiC;IAChD,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,0BAA0B,KAAK,OAAO,CAAC;QACrE,IAAI,EAAE,kBAAkB,EAAE,CAAC;KAC5B,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACnE,KAAK,IAAI,aAAa,CAAC,kBAAkB,CAAC,CAAC;KAC5C,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,mBAAmB,EAAE;gBACnB,WAAW,EAAE,OAAO,yBAAyB,CAAC;aAC/C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAC5C,UAAU,CAAC,sBAAsB,CAAC,EAAE,yBAAyB;AAC7D;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,EAAE,0BAA0B;AAC7B,iCAAiC,CA+FlC,CAAC"}
@@ -1,23 +1,18 @@
1
1
  import { ListAuthenticationsSchema, } from "./schemas";
2
- import { normalizeAuthenticationItem } from "../../utils/domain-utils";
2
+ import { normalizeAuthenticationItem, splitVersionedKey, } from "../../utils/domain-utils";
3
3
  import { ZapierAuthenticationError } from "../../types/errors";
4
4
  import { createPaginatedFunction, extractCursor, } from "../../utils/function-utils";
5
- export const listAuthenticationsPlugin = ({ sdk, context }) => {
5
+ export const listAuthenticationsPlugin = ({ context }) => {
6
6
  const listAuthentications = createPaginatedFunction(async function listAuthenticationsPage(options) {
7
- const { api } = context;
7
+ const { api, getVersionedImplementationId } = context;
8
8
  // Build search parameters
9
9
  const searchParams = {};
10
10
  // Handle appKey filtering by getting the selected_api first
11
11
  if (options.appKey) {
12
- const app = await sdk.getApp({
13
- appKey: options.appKey,
14
- });
15
- const selectedApi = app.data.current_implementation_id;
16
- if (selectedApi) {
17
- // Use versionless_selected_api to find auths across all app versions
18
- // Extract the base name without the version (e.g., "SlackCLIAPI" from "SlackCLIAPI@1.21.1")
19
- const versionlessApi = selectedApi.split("@")[0];
20
- searchParams.versionless_selected_api = versionlessApi;
12
+ const implementationId = await getVersionedImplementationId(options.appKey);
13
+ if (implementationId) {
14
+ const [versionlessSelectedApi] = splitVersionedKey(implementationId);
15
+ searchParams.versionless_selected_api = versionlessSelectedApi;
21
16
  }
22
17
  }
23
18
  // Add other query parameters if provided
@@ -40,6 +35,7 @@ export const listAuthenticationsPlugin = ({ sdk, context }) => {
40
35
  // Convert cursor back to offset for the API
41
36
  searchParams.offset = options.cursor;
42
37
  }
38
+ console.log({ searchParams });
43
39
  const data = await api.get("/api/v4/authentications/", {
44
40
  searchParams,
45
41
  customErrorHandler: ({ status }) => {
@@ -69,6 +65,7 @@ export const listAuthenticationsPlugin = ({ sdk, context }) => {
69
65
  context: {
70
66
  meta: {
71
67
  listAuthentications: {
68
+ categories: ["authentication"],
72
69
  inputSchema: ListAuthenticationsSchema,
73
70
  },
74
71
  },
@@ -36,37 +36,46 @@ const mockAuthenticationsResponse = {
36
36
  previous: null,
37
37
  };
38
38
  const mockSlackApp = {
39
- data: {
40
- id: 1,
41
- key: "slack",
42
- title: "Slack",
43
- hex_color: "#000000",
44
- age_in_days: "100",
45
- api_docs_url: "https://slack.com/api-docs",
46
- app_profile_url: "https://slack.com",
47
- banner: "https://slack.com/banner.png",
48
- categories: [],
49
- canonical_id: "slack",
50
- zap_usage_count: 100,
51
- zap_usage_count_last_updated: "2021-01-01",
52
- zap_usage_count_last_updated_by: "user1",
53
- zap_usage_count_last_updated_by_id: 123,
54
- current_implementation_id: "SlackCLIAPI@1.21.1",
55
- },
39
+ title: "Slack",
40
+ key: "SlackCLIAPI",
41
+ current_implementation_id: "SlackCLIAPI@1.21.1",
42
+ version: "1.21.1",
43
+ description: "Team communication platform",
44
+ slug: "slack",
56
45
  };
57
46
  describe("listAuthentications plugin", () => {
58
47
  let mockApiClient;
59
- let mockGetApp;
48
+ let mockGetVersionedImplementationId;
60
49
  beforeEach(() => {
61
50
  vi.clearAllMocks();
62
51
  mockApiClient = {
63
52
  get: vi.fn().mockResolvedValue(mockAuthenticationsResponse),
64
53
  };
65
- mockGetApp = vi.fn().mockResolvedValue(mockSlackApp);
54
+ mockGetVersionedImplementationId = vi
55
+ .fn()
56
+ .mockResolvedValue("SlackCLIAPI@1.21.1");
57
+ });
58
+ const apiPlugin = () => ({
59
+ context: {
60
+ api: mockApiClient,
61
+ },
62
+ });
63
+ const manifestPlugin = () => ({
64
+ context: {
65
+ manifest: null,
66
+ getVersionedImplementationId: mockGetVersionedImplementationId,
67
+ getManifestEntry: () => ({
68
+ implementationName: "SlackCLIAPI",
69
+ version: "1.21.1",
70
+ }),
71
+ getImplementation: vi.fn().mockResolvedValue(mockSlackApp),
72
+ },
66
73
  });
67
74
  function createTestSdk() {
68
- return createSdk({ getApp: mockGetApp }, // Provide getApp in SDK
69
- { api: mockApiClient, meta: {} }).addPlugin(listAuthenticationsPlugin);
75
+ return createSdk()
76
+ .addPlugin(apiPlugin)
77
+ .addPlugin(manifestPlugin)
78
+ .addPlugin(listAuthenticationsPlugin);
70
79
  }
71
80
  describe("schema validation", () => {
72
81
  it("should pass validation with empty options", async () => {
@@ -165,7 +174,7 @@ describe("listAuthentications plugin", () => {
165
174
  describe("data mapping", () => {
166
175
  it("should map is_stale to is_expired and marked_stale_at to expired_at", async () => {
167
176
  const sdk = createTestSdk();
168
- const result = await sdk.listAuthentications({});
177
+ const result = await sdk.listAuthentications();
169
178
  expect(result.data[0].is_expired).toBe("false");
170
179
  expect(result.data[0].expired_at).toBe(null);
171
180
  expect(result.data[1].is_expired).toBe("true");
@@ -459,15 +468,7 @@ describe("listAuthentications plugin", () => {
459
468
  });
460
469
  describe("app key integration", () => {
461
470
  it("should handle app without current_implementation_id", async () => {
462
- const appWithoutImplementation = {
463
- data: {
464
- id: 123,
465
- key: "slack",
466
- title: "Slack",
467
- current_implementation_id: undefined,
468
- },
469
- };
470
- mockGetApp.mockResolvedValue(appWithoutImplementation);
471
+ mockGetVersionedImplementationId.mockResolvedValue(null);
471
472
  const sdk = createTestSdk();
472
473
  await sdk.listAuthentications({ appKey: "slack" });
473
474
  // Should not add versionless_selected_api parameter
@@ -478,15 +479,7 @@ describe("listAuthentications plugin", () => {
478
479
  }));
479
480
  });
480
481
  it("should extract versionless API from versioned implementation ID", async () => {
481
- const appWithVersionedApi = {
482
- data: {
483
- id: 123,
484
- key: "slack",
485
- title: "Slack",
486
- current_implementation_id: "SlackCLIAPI@2.1.3",
487
- },
488
- };
489
- mockGetApp.mockResolvedValue(appWithVersionedApi);
482
+ mockGetVersionedImplementationId.mockResolvedValue("SlackCLIAPI@2.1.3");
490
483
  const sdk = createTestSdk();
491
484
  await sdk.listAuthentications({ appKey: "slack" });
492
485
  expect(mockApiClient.get).toHaveBeenCalledWith("/api/v4/authentications/", expect.objectContaining({
@@ -13,17 +13,17 @@ export declare const ListAuthenticationsSchema: z.ZodObject<{
13
13
  title?: string | undefined;
14
14
  search?: string | undefined;
15
15
  account_id?: string | undefined;
16
- maxItems?: number | undefined;
17
- pageSize?: number | undefined;
18
16
  appKey?: string | undefined;
17
+ pageSize?: number | undefined;
18
+ maxItems?: number | undefined;
19
19
  owner?: string | undefined;
20
20
  }, {
21
21
  title?: string | undefined;
22
22
  search?: string | undefined;
23
23
  account_id?: string | undefined;
24
- maxItems?: number | undefined;
25
- pageSize?: number | undefined;
26
24
  appKey?: string | undefined;
25
+ pageSize?: number | undefined;
26
+ maxItems?: number | undefined;
27
27
  owner?: string | undefined;
28
28
  }>;
29
29
  export type ListAuthenticationsOptions = z.infer<typeof ListAuthenticationsSchema>;