@zapier/zapier-sdk 0.18.2 → 0.18.4

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 (85) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +13 -13
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +0 -18
  5. package/dist/api/schemas.d.ts +0 -158
  6. package/dist/api/schemas.d.ts.map +1 -1
  7. package/dist/api/schemas.js +0 -95
  8. package/dist/api/types.d.ts +2 -1
  9. package/dist/api/types.d.ts.map +1 -1
  10. package/dist/index.cjs +400 -808
  11. package/dist/index.d.mts +67 -122
  12. package/dist/index.mjs +401 -809
  13. package/dist/plugins/findFirstAuthentication/index.test.js +2 -2
  14. package/dist/plugins/findUniqueAuthentication/index.test.js +2 -2
  15. package/dist/plugins/listApps/index.d.ts +2 -8
  16. package/dist/plugins/listApps/index.d.ts.map +1 -1
  17. package/dist/plugins/listApps/index.js +4 -6
  18. package/dist/plugins/listApps/index.test.js +62 -82
  19. package/dist/plugins/listApps/schemas.d.ts +35 -14
  20. package/dist/plugins/listApps/schemas.d.ts.map +1 -1
  21. package/dist/plugins/listApps/schemas.js +44 -14
  22. package/dist/plugins/listAuthentications/index.d.ts +4 -10
  23. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  24. package/dist/plugins/listAuthentications/index.js +19 -31
  25. package/dist/plugins/listAuthentications/index.test.js +363 -127
  26. package/dist/plugins/listAuthentications/schemas.d.ts +7 -7
  27. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
  28. package/dist/plugins/listAuthentications/schemas.js +10 -16
  29. package/dist/schemas/App.d.ts +28 -28
  30. package/dist/schemas/App.d.ts.map +1 -1
  31. package/dist/schemas/App.js +3 -8
  32. package/dist/sdk.d.ts +2 -2
  33. package/dist/sdk.test.js +12 -9
  34. package/dist/utils/domain-utils.d.ts +2 -15
  35. package/dist/utils/domain-utils.d.ts.map +1 -1
  36. package/dist/utils/domain-utils.js +0 -38
  37. package/dist/utils/function-utils.d.ts +1 -0
  38. package/dist/utils/function-utils.d.ts.map +1 -1
  39. package/dist/utils/function-utils.js +15 -3
  40. package/package.json +2 -2
  41. package/dist/api/client.integration.test.d.ts +0 -5
  42. package/dist/api/client.integration.test.d.ts.map +0 -1
  43. package/dist/api/client.integration.test.js +0 -318
  44. package/dist/api/client.methods.test.d.ts +0 -2
  45. package/dist/api/client.methods.test.d.ts.map +0 -1
  46. package/dist/api/client.methods.test.js +0 -158
  47. package/dist/api/router.d.ts +0 -16
  48. package/dist/api/router.d.ts.map +0 -1
  49. package/dist/api/router.js +0 -31
  50. package/dist/api/router.test.d.ts +0 -2
  51. package/dist/api/router.test.d.ts.map +0 -1
  52. package/dist/api/router.test.js +0 -103
  53. package/dist/temporary-internal-core/handlers/listApps.d.ts +0 -67
  54. package/dist/temporary-internal-core/handlers/listApps.d.ts.map +0 -1
  55. package/dist/temporary-internal-core/handlers/listApps.js +0 -134
  56. package/dist/temporary-internal-core/handlers/listApps.test.d.ts +0 -2
  57. package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +0 -1
  58. package/dist/temporary-internal-core/handlers/listApps.test.js +0 -367
  59. package/dist/temporary-internal-core/index.d.ts +0 -18
  60. package/dist/temporary-internal-core/index.d.ts.map +0 -1
  61. package/dist/temporary-internal-core/index.js +0 -18
  62. package/dist/temporary-internal-core/schemas/apps/index.d.ts +0 -175
  63. package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +0 -1
  64. package/dist/temporary-internal-core/schemas/apps/index.js +0 -97
  65. package/dist/temporary-internal-core/schemas/errors/index.d.ts +0 -139
  66. package/dist/temporary-internal-core/schemas/errors/index.d.ts.map +0 -1
  67. package/dist/temporary-internal-core/schemas/errors/index.js +0 -129
  68. package/dist/temporary-internal-core/schemas/implementations/index.d.ts +0 -127
  69. package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +0 -1
  70. package/dist/temporary-internal-core/schemas/implementations/index.js +0 -79
  71. package/dist/temporary-internal-core/types/handler.d.ts +0 -51
  72. package/dist/temporary-internal-core/types/handler.d.ts.map +0 -1
  73. package/dist/temporary-internal-core/types/handler.js +0 -8
  74. package/dist/temporary-internal-core/types/index.d.ts +0 -5
  75. package/dist/temporary-internal-core/types/index.d.ts.map +0 -1
  76. package/dist/temporary-internal-core/types/index.js +0 -4
  77. package/dist/temporary-internal-core/utils/app-locators.d.ts +0 -34
  78. package/dist/temporary-internal-core/utils/app-locators.d.ts.map +0 -1
  79. package/dist/temporary-internal-core/utils/app-locators.js +0 -39
  80. package/dist/temporary-internal-core/utils/string-utils.d.ts +0 -28
  81. package/dist/temporary-internal-core/utils/string-utils.d.ts.map +0 -1
  82. package/dist/temporary-internal-core/utils/string-utils.js +0 -52
  83. package/dist/temporary-internal-core/utils/transformations.d.ts +0 -32
  84. package/dist/temporary-internal-core/utils/transformations.d.ts.map +0 -1
  85. package/dist/temporary-internal-core/utils/transformations.js +0 -74
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { ZapierValidationError } from "../../types/errors";
3
3
  import { findFirstAuthenticationPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
- import { ListAuthenticationsSchema } from "../listAuthentications/schemas";
5
+ import { ListAuthenticationsQuerySchema } from "../listAuthentications/schemas";
6
6
  import { eventEmissionPlugin } from "../eventEmission";
7
7
  const mockAuthentications = [
8
8
  {
@@ -45,7 +45,7 @@ describe("findFirstAuthentication plugin", () => {
45
45
  context: {
46
46
  meta: {
47
47
  listAuthentications: {
48
- inputSchema: ListAuthenticationsSchema,
48
+ inputSchema: ListAuthenticationsQuerySchema,
49
49
  },
50
50
  },
51
51
  },
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { ZapierValidationError, ZapierResourceNotFoundError, } from "../../types/errors";
3
3
  import { findUniqueAuthenticationPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
- import { ListAuthenticationsSchema } from "../listAuthentications/schemas";
5
+ import { ListAuthenticationsQuerySchema } from "../listAuthentications/schemas";
6
6
  import { eventEmissionPlugin } from "../eventEmission";
7
7
  const mockAuthentication = {
8
8
  id: "123",
@@ -46,7 +46,7 @@ describe("findUniqueAuthentication plugin", () => {
46
46
  context: {
47
47
  meta: {
48
48
  listAuthentications: {
49
- inputSchema: ListAuthenticationsSchema,
49
+ inputSchema: ListAuthenticationsQuerySchema,
50
50
  },
51
51
  },
52
52
  },
@@ -1,16 +1,10 @@
1
1
  import type { GetContextType, Plugin } from "../../types/plugin";
2
- import { ListAppsSchema, type ListAppsOptions, type AppItem } from "./schemas";
2
+ import { ListAppsSchema, type ListAppsOptions, type ListAppsPage, type AppItem } from "./schemas";
3
3
  import type { ManifestPluginProvides } from "../manifest";
4
4
  import type { ApiPluginProvides } from "../api";
5
5
  import type { EventEmissionContext } from "../eventEmission";
6
6
  export interface ListAppsPluginProvides {
7
- listApps: (options?: ListAppsOptions) => Promise<{
8
- data: AppItem[];
9
- nextCursor?: string;
10
- }> & AsyncIterable<{
11
- data: AppItem[];
12
- nextCursor?: string;
13
- }> & {
7
+ listApps: (options?: ListAppsOptions) => Promise<ListAppsPage> & AsyncIterable<ListAppsPage> & {
14
8
  items(): AsyncIterable<AppItem>;
15
9
  };
16
10
  context: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EAEpB,KAAK,OAAO,EACb,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;A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jC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR,WAAW,EAAE,OAAO,cAAc,CAAC;aACpC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EACF,cAAc,CAAC,iBAAiB,GAAG,sBAAsB,CAAC,GACxD,oBAAoB,EACtB,sBAAsB,CA+EvB,CAAC"}
@@ -31,27 +31,25 @@ export const listAppsPlugin = ({ context }) => {
31
31
  if (appKeys.length > 0 && appLocators.length === 0 && !options.search) {
32
32
  return {
33
33
  data: [],
34
- nextCursor: undefined,
34
+ links: { next: null },
35
+ meta: { count: 0, limit: 0, offset: 0 },
35
36
  };
36
37
  }
37
38
  const implementationIds = appLocators.map((locator) => {
38
39
  const version = locator.version || "latest";
39
40
  return `${locator.implementationName}@${version}`;
40
41
  });
41
- // Call the API, which will be routed to the handler via handlerOverride in pathConfig.
42
- // When the handler is migrated to sdkapi, this same API call will go over the network.
43
42
  return await api.get("/api/v0/apps", {
44
43
  searchParams: {
45
- implementationIds: implementationIds.join(","),
44
+ appKeys: implementationIds.join(","),
46
45
  ...(options.search && { search: options.search }),
47
46
  pageSize: options.pageSize.toString(),
48
- ...(options.cursor && { cursor: options.cursor }),
47
+ ...(options.cursor && { offset: options.cursor }),
49
48
  },
50
49
  });
51
50
  }
52
51
  const methodName = stripPageSuffix(listAppsPage.name);
53
52
  const listAppsDefinition = createPaginatedFunction(listAppsPage, ListAppsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
54
- // Return flat structure - listApps goes directly to SDK
55
53
  return {
56
54
  listApps: listAppsDefinition,
57
55
  context: {
@@ -2,8 +2,19 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { ZapierValidationError } from "../../types/errors";
3
3
  import { listAppsPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
- import { apiPlugin } from "../api/index";
6
5
  import { eventEmissionPlugin } from "../eventEmission";
6
+ // Mock transport for testing - prevents real HTTP telemetry requests
7
+ const mockTransport = {
8
+ emit: vi.fn().mockResolvedValue(undefined),
9
+ close: vi.fn().mockResolvedValue(undefined),
10
+ };
11
+ vi.mock("../eventEmission/transport", () => ({
12
+ createTransport: vi.fn(() => mockTransport),
13
+ }));
14
+ // Mock CLI login package - prevents real token resolution requests
15
+ vi.mock("@zapier/zapier-sdk-cli-login", () => ({
16
+ getToken: vi.fn().mockResolvedValue(undefined),
17
+ }));
7
18
  const mockResolveAppKeys = vi
8
19
  .fn()
9
20
  .mockImplementation(async ({ appKeys }) => {
@@ -14,77 +25,61 @@ const mockResolveAppKeys = vi
14
25
  version: undefined,
15
26
  }));
16
27
  });
17
- function createTestSdk(mockFetch) {
18
- return createSdk()
19
- .addPlugin(() => ({
20
- context: {
21
- options: {},
22
- },
23
- }))
24
- .addPlugin(apiPlugin, { fetch: mockFetch || global.fetch })
25
- .addPlugin(eventEmissionPlugin)
26
- .addPlugin(() => ({
27
- context: {
28
- resolveAppKeys: mockResolveAppKeys,
29
- },
30
- }))
31
- .addPlugin(listAppsPlugin);
32
- }
33
- function createMockFetch(handlers) {
34
- return vi.fn().mockImplementation(async (url, _init) => {
35
- const urlString = typeof url === "string" ? url : url.toString();
36
- const urlPath = new URL(urlString).pathname;
37
- for (const [handlerPath, response] of Object.entries(handlers)) {
38
- if (urlPath === handlerPath) {
39
- const responseData = typeof response === "function" ? response() : response;
40
- return {
41
- ok: true,
42
- status: 200,
43
- statusText: "OK",
44
- json: async () => responseData,
45
- headers: new Headers({ "content-type": "application/json" }),
46
- };
47
- }
48
- }
49
- return {
50
- ok: false,
51
- status: 404,
52
- statusText: "Not Found",
53
- json: async () => ({ message: `No mock for path: ${urlPath}` }),
54
- headers: new Headers(),
55
- };
56
- });
57
- }
58
28
  describe("listApps plugin", () => {
29
+ let mockApiClient;
59
30
  beforeEach(() => {
60
31
  vi.clearAllMocks();
32
+ mockApiClient = {
33
+ get: vi.fn().mockResolvedValue({
34
+ data: [
35
+ {
36
+ title: "Slack",
37
+ key: "SlackCLIAPI",
38
+ implementation_id: "SlackCLIAPI@1.0.0",
39
+ version: "1.0.0",
40
+ slug: "slack",
41
+ description: "Team communication",
42
+ primary_color: "#4A154B",
43
+ },
44
+ {
45
+ title: "Google Sheets",
46
+ key: "GoogleSheetsCLIAPI",
47
+ implementation_id: "GoogleSheetsCLIAPI@1.0.0",
48
+ version: "1.0.0",
49
+ slug: "google-sheets",
50
+ description: "Online spreadsheets",
51
+ primary_color: "#34A853",
52
+ },
53
+ ],
54
+ links: { next: null },
55
+ meta: { count: 2, limit: 100, offset: 0 },
56
+ }),
57
+ };
58
+ });
59
+ const apiPlugin = () => ({
60
+ context: {
61
+ api: mockApiClient,
62
+ },
61
63
  });
64
+ function createTestSdk() {
65
+ return createSdk()
66
+ .addPlugin(() => ({
67
+ context: {
68
+ options: {},
69
+ },
70
+ }))
71
+ .addPlugin(apiPlugin)
72
+ .addPlugin(eventEmissionPlugin)
73
+ .addPlugin(() => ({
74
+ context: {
75
+ resolveAppKeys: mockResolveAppKeys,
76
+ },
77
+ }))
78
+ .addPlugin(listAppsPlugin);
79
+ }
62
80
  describe("basic functionality", () => {
63
81
  it("should provide listApps method that returns apps", async () => {
64
- const mockFetch = createMockFetch({
65
- "/api/v0/sdk/zapier/api/v4/implementations-meta/lookup/": {
66
- count: 2,
67
- results: [
68
- {
69
- id: "SlackCLIAPI@1.0.0",
70
- name: "Slack",
71
- description: "Team communication",
72
- primary_color: "#4A154B",
73
- categories: ["communication"],
74
- },
75
- {
76
- id: "GoogleSheetsCLIAPI@1.0.0",
77
- name: "Google Sheets",
78
- description: "Online spreadsheets",
79
- primary_color: "#34A853",
80
- categories: ["productivity"],
81
- },
82
- ],
83
- next: null,
84
- },
85
- });
86
- const sdk = createTestSdk(mockFetch);
87
- // Provide explicit pageSize to limit results
82
+ const sdk = createTestSdk();
88
83
  const result = await sdk.listApps({ pageSize: 2 });
89
84
  // Just verify the structure - handler tests verify correct data
90
85
  expect(result.data.length).toBeGreaterThan(0);
@@ -102,22 +97,7 @@ describe("listApps plugin", () => {
102
97
  expect(context.meta.listApps.inputSchema).toBeDefined();
103
98
  });
104
99
  it("should integrate with resolveAppKeys", async () => {
105
- const mockFetch = createMockFetch({
106
- "/api/v0/sdk/zapier/api/v4/implementations-meta/lookup/": {
107
- count: 1,
108
- results: [
109
- {
110
- id: "SlackCLIAPI@1.0.0",
111
- name: "Slack",
112
- description: "Team communication",
113
- primary_color: "#4A154B",
114
- categories: ["communication"],
115
- },
116
- ],
117
- next: null,
118
- },
119
- });
120
- const sdk = createTestSdk(mockFetch);
100
+ const sdk = createTestSdk();
121
101
  await sdk.listApps({ appKeys: ["SlackCLIAPI"] });
122
102
  // Verify resolveAppKeys was called with the provided appKeys
123
103
  expect(mockResolveAppKeys).toHaveBeenCalledWith(expect.objectContaining({
@@ -1,24 +1,45 @@
1
1
  /**
2
2
  * Plugin schemas for listApps
3
3
  *
4
- * Re-exports from temporary-internal-core to maintain single source of truth.
5
- * Plugin-specific types (like PaginatedSdkFunction) remain here.
4
+ * Imports base query schema from @zapier/zapier-sdk-core (sdkapi) and extends
5
+ * with SDK-specific options.
6
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)
7
+ * Note: The sdkapi endpoint uses ListAppsQuerySchema (HTTP query params),
8
+ * but the SDK exposes ListAppsSchema (user-friendly options):
9
+ * - ListAppsOptions accepts `appKeys` as array, `cursor`, `maxItems`
10
+ * - ListAppsQuery accepts `appKeys` as comma-separated string, `offset`
11
+ * - The plugin transforms between these formats
17
12
  */
13
+ import { z } from "zod";
18
14
  import type { PaginatedSdkFunction } from "../../types/functions";
19
15
  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";
16
+ import { AppItemSchema as AppItemSchemaBase, ListAppsResponseSchema as ListAppsResponseSchemaBase, type AppItem, type ListAppsResponse } from "@zapier/zapier-sdk-core/v0/schemas/apps";
17
+ export { AppItemSchemaBase as AppItemSchema };
18
+ export { ListAppsResponseSchemaBase as ListAppsResponseSchema };
19
+ export type { AppItem, ListAppsResponse };
20
+ /**
21
+ * SDK user-facing options for listApps
22
+ *
23
+ * Extends ListAppsQuerySchema from zapier-sdk-core with SDK-specific options:
24
+ * - appKeys: array (not comma-separated string)
25
+ * - cursor: pagination cursor (not offset)
26
+ * - maxItems: SDK-specific pagination limit
27
+ */
28
+ export declare const ListAppsSchema: z.ZodObject<{
29
+ search: z.ZodOptional<z.ZodString>;
30
+ appKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
31
+ pageSize: z.ZodOptional<z.ZodNumber>;
32
+ maxItems: z.ZodOptional<z.ZodNumber>;
33
+ cursor: z.ZodOptional<z.ZodString>;
34
+ _telemetry: z.ZodOptional<z.ZodObject<{
35
+ isNested: z.ZodOptional<z.ZodBoolean>;
36
+ }, z.core.$strip>>;
37
+ }, z.core.$strip>;
38
+ export type ListAppsOptions = z.infer<typeof ListAppsSchema>;
39
+ export interface ListAppsPage {
40
+ data: AppItem[];
41
+ nextCursor?: string;
42
+ }
22
43
  export type ListAppsError = ZapierApiError | ZapierValidationError;
23
44
  export interface ListAppsSdkFunction {
24
45
  listApps: PaginatedSdkFunction<ListAppsOptions | undefined, AppItem>;
@@ -1 +1 @@
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
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAIhF,OAAO,EACL,aAAa,IAAI,iBAAiB,EAClC,sBAAsB,IAAI,0BAA0B,EAEpD,KAAK,OAAO,EACZ,KAAK,gBAAgB,EACtB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,iBAAiB,IAAI,aAAa,EAAE,CAAC;AAC9C,OAAO,EAAE,0BAA0B,IAAI,sBAAsB,EAAE,CAAC;AAChE,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;;;;;;;iBAuBmC,CAAC;AAE/D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAG7D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,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,19 +1,49 @@
1
1
  /**
2
2
  * Plugin schemas for listApps
3
3
  *
4
- * Re-exports from temporary-internal-core to maintain single source of truth.
5
- * Plugin-specific types (like PaginatedSdkFunction) remain here.
4
+ * Imports base query schema from @zapier/zapier-sdk-core (sdkapi) and extends
5
+ * with SDK-specific options.
6
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)
7
+ * Note: The sdkapi endpoint uses ListAppsQuerySchema (HTTP query params),
8
+ * but the SDK exposes ListAppsSchema (user-friendly options):
9
+ * - ListAppsOptions accepts `appKeys` as array, `cursor`, `maxItems`
10
+ * - ListAppsQuery accepts `appKeys` as comma-separated string, `offset`
11
+ * - The plugin transforms between these formats
17
12
  */
18
- // Re-export core schemas and types
19
- export { ListAppsOptionsSchema as ListAppsSchema, ListAppsResponseSchema, } from "../../temporary-internal-core/schemas/apps";
13
+ import { z } from "zod";
14
+ import { TelemetryMarkerSchema } from "../../utils/function-utils";
15
+ // Import schemas and types from @zapier/zapier-sdk-core (sdkapi)
16
+ import { AppItemSchema as AppItemSchemaBase, ListAppsResponseSchema as ListAppsResponseSchemaBase, ListAppsQuerySchema as ListAppsQueryBase, } from "@zapier/zapier-sdk-core/v0/schemas/apps";
17
+ // Re-export for consumers
18
+ export { AppItemSchemaBase as AppItemSchema };
19
+ export { ListAppsResponseSchemaBase as ListAppsResponseSchema };
20
+ /**
21
+ * SDK user-facing options for listApps
22
+ *
23
+ * Extends ListAppsQuerySchema from zapier-sdk-core with SDK-specific options:
24
+ * - appKeys: array (not comma-separated string)
25
+ * - cursor: pagination cursor (not offset)
26
+ * - maxItems: SDK-specific pagination limit
27
+ */
28
+ export const ListAppsSchema = ListAppsQueryBase.omit({
29
+ offset: true,
30
+ })
31
+ .extend({
32
+ // Override appKeys to be an array instead of comma-separated string
33
+ appKeys: z
34
+ .array(z.string())
35
+ .optional()
36
+ .describe("Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"),
37
+ // Override pageSize to make optional (base has default value)
38
+ pageSize: z.number().min(1).optional().describe("Number of apps per page"),
39
+ // SDK specific property for pagination/iterator helpers
40
+ maxItems: z
41
+ .number()
42
+ .min(1)
43
+ .optional()
44
+ .describe("Maximum total items to return across all pages"),
45
+ // SDK specific property for pagination/iterator helpers
46
+ cursor: z.string().optional().describe("Cursor to start from"),
47
+ })
48
+ .merge(TelemetryMarkerSchema)
49
+ .describe("List all available apps with optional filtering");
@@ -1,24 +1,18 @@
1
1
  import type { Plugin, GetSdkType } from "../../types/plugin";
2
2
  import type { ApiClient } from "../../api";
3
- import type { AuthenticationItem } from "../../types/domain";
4
- import { ListAuthenticationsSchema, type ListAuthenticationsOptions } from "./schemas";
3
+ import type { AuthenticationItem } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
4
+ import { ListAuthenticationsQuerySchema, type ListAuthenticationsOptions, type ListAuthenticationsPage } from "./schemas";
5
5
  import type { GetVersionedImplementationId } from "../manifest/schemas";
6
6
  import type { ManifestPluginProvides } from "../manifest";
7
7
  import type { EventEmissionContext } from "../eventEmission";
8
8
  export interface ListAuthenticationsPluginProvides {
9
- listAuthentications: (options?: ListAuthenticationsOptions) => Promise<{
10
- data: AuthenticationItem[];
11
- nextCursor?: string;
12
- }> & AsyncIterable<{
13
- data: AuthenticationItem[];
14
- nextCursor?: string;
15
- }> & {
9
+ listAuthentications: (options?: ListAuthenticationsOptions) => Promise<ListAuthenticationsPage> & AsyncIterable<ListAuthenticationsPage> & {
16
10
  items(): AsyncIterable<AuthenticationItem>;
17
11
  };
18
12
  context: {
19
13
  meta: {
20
14
  listAuthentications: {
21
- inputSchema: typeof ListAuthenticationsSchema;
15
+ inputSchema: typeof ListAuthenticationsQuerySchema;
22
16
  };
23
17
  };
24
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listAuthentications/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,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,yBAAyB,EACzB,KAAK,0BAA0B,EAEhC,MAAM,WAAW,CAAC;AAUnB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAI7D,MAAM,WAAW,iCAAiC;IAChD,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,0BAA0B,KAAK,OAAO,CAAC;QACrE,IAAI,EAAE,kBAAkB,EAAE,CAAC;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AAG;QACvC,KAAK,IAAI,aAAa,CAAC,kBAAkB,CAAC,CAAC;KAC5C,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,mBAAmB,EAAE;gBACnB,WAAW,EAAE,OAAO,8BAA8B,CAAC;aACpD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAC5C,UAAU,CAAC,sBAAsB,CAAC,EAClC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EACxB,iCAAiC,CAiGlC,CAAC"}
@@ -1,49 +1,46 @@
1
- import { ListAuthenticationsSchema, } from "./schemas";
2
- import { normalizeAuthenticationItem, splitVersionedKey, } from "../../utils/domain-utils";
3
- import { ZapierAuthenticationError } from "../../types/errors";
4
- import { createPaginatedFunction, extractCursor, } from "../../utils/function-utils";
1
+ import { ListAuthenticationsQuerySchema, } from "./schemas";
2
+ import { splitVersionedKey } from "../../utils/domain-utils";
3
+ import { createPaginatedFunction } from "../../utils/function-utils";
5
4
  import { appKeyResolver } from "../../resolvers";
6
5
  import { AuthenticationItemSchema } from "../../schemas/Auth";
7
6
  import { createTelemetryCallback } from "../../utils/telemetry-utils";
8
7
  import { stripPageSuffix } from "../../utils/string-utils";
8
+ import { ZapierAuthenticationError } from "../../types/errors";
9
9
  export const listAuthenticationsPlugin = ({ context }) => {
10
10
  async function listAuthenticationsPage(options) {
11
11
  const { api, getVersionedImplementationId } = context;
12
- // Build search parameters
13
- const searchParams = {};
14
- // Handle appKey filtering by getting the selected_api first
12
+ const searchParams = {
13
+ pageSize: options.pageSize.toString(),
14
+ };
15
+ // Resolve appKey to implementationId if provided
15
16
  if (options.appKey) {
16
17
  const implementationId = await getVersionedImplementationId(options.appKey);
17
18
  if (implementationId) {
19
+ // Extract versionless app key to pass to handler
18
20
  const [versionlessSelectedApi] = splitVersionedKey(implementationId);
19
- searchParams.versionless_selected_api = versionlessSelectedApi;
21
+ searchParams.appKey = versionlessSelectedApi;
20
22
  }
21
23
  }
22
- // Add authenticationIds as ids parameter if provided
24
+ // Pass other filter options as searchParams
23
25
  if (options.authenticationIds && options.authenticationIds.length > 0) {
24
- searchParams.ids = options.authenticationIds.join(",");
26
+ searchParams.authenticationIds = options.authenticationIds.join(",");
25
27
  }
26
- // Add other query parameters if provided
27
- // Use title as search if no explicit search provided
28
28
  if (options.search) {
29
29
  searchParams.search = options.search;
30
30
  }
31
- else if (options.title) {
32
- searchParams.search = options.title;
31
+ if (options.title) {
32
+ searchParams.title = options.title;
33
33
  }
34
34
  if (options.accountId) {
35
- searchParams.account_id = options.accountId;
35
+ searchParams.accountId = options.accountId;
36
36
  }
37
37
  if (options.owner) {
38
38
  searchParams.owner = options.owner;
39
39
  }
40
- // pageSize is now guaranteed to be set by the higher-order function
41
- searchParams.limit = options.pageSize.toString();
42
40
  if (options.cursor) {
43
- // Convert cursor back to offset for the API
44
41
  searchParams.offset = options.cursor;
45
42
  }
46
- const data = await api.get("/zapier/api/v4/authentications/", {
43
+ const response = await api.get("/api/v0/authentications", {
47
44
  searchParams,
48
45
  customErrorHandler: ({ status }) => {
49
46
  if (status === 401) {
@@ -56,19 +53,10 @@ export const listAuthenticationsPlugin = ({ context }) => {
56
53
  },
57
54
  authRequired: true,
58
55
  });
59
- // Transform API response and filter by exact title match if specified
60
- let auths = (data.results || []).map((auth) => normalizeAuthenticationItem(auth));
61
- // Filter by exact title match if specified
62
- if (options.title) {
63
- auths = auths.filter((auth) => auth.title === options.title);
64
- }
65
- return {
66
- data: auths,
67
- nextCursor: extractCursor(data),
68
- };
56
+ return response;
69
57
  }
70
58
  const methodName = stripPageSuffix(listAuthenticationsPage.name);
71
- const listAuthenticationsDefinition = createPaginatedFunction(listAuthenticationsPage, ListAuthenticationsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
59
+ const listAuthenticationsDefinition = createPaginatedFunction(listAuthenticationsPage, ListAuthenticationsQuerySchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
72
60
  return {
73
61
  listAuthentications: listAuthenticationsDefinition,
74
62
  context: {
@@ -77,7 +65,7 @@ export const listAuthenticationsPlugin = ({ context }) => {
77
65
  categories: ["authentication"],
78
66
  type: "list",
79
67
  itemType: "Authentication",
80
- inputSchema: ListAuthenticationsSchema,
68
+ inputSchema: ListAuthenticationsQuerySchema,
81
69
  outputSchema: AuthenticationItemSchema,
82
70
  resolvers: {
83
71
  appKey: appKeyResolver,