@zapier/zapier-sdk 0.18.3 → 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 (71) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  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 -109
  6. package/dist/api/schemas.d.ts.map +1 -1
  7. package/dist/api/schemas.js +0 -67
  8. package/dist/api/types.d.ts +2 -1
  9. package/dist/api/types.d.ts.map +1 -1
  10. package/dist/index.cjs +337 -673
  11. package/dist/index.d.mts +52 -105
  12. package/dist/index.mjs +337 -673
  13. package/dist/plugins/listApps/index.d.ts +2 -8
  14. package/dist/plugins/listApps/index.d.ts.map +1 -1
  15. package/dist/plugins/listApps/index.js +4 -6
  16. package/dist/plugins/listApps/index.test.js +62 -82
  17. package/dist/plugins/listApps/schemas.d.ts +35 -14
  18. package/dist/plugins/listApps/schemas.d.ts.map +1 -1
  19. package/dist/plugins/listApps/schemas.js +44 -14
  20. package/dist/plugins/listAuthentications/index.test.js +16 -0
  21. package/dist/schemas/App.d.ts +28 -28
  22. package/dist/schemas/App.d.ts.map +1 -1
  23. package/dist/schemas/App.js +3 -8
  24. package/dist/sdk.d.ts +1 -1
  25. package/dist/sdk.test.js +12 -9
  26. package/package.json +1 -1
  27. package/dist/api/client.integration.test.d.ts +0 -5
  28. package/dist/api/client.integration.test.d.ts.map +0 -1
  29. package/dist/api/client.integration.test.js +0 -318
  30. package/dist/api/client.methods.test.d.ts +0 -2
  31. package/dist/api/client.methods.test.d.ts.map +0 -1
  32. package/dist/api/client.methods.test.js +0 -158
  33. package/dist/api/router.d.ts +0 -16
  34. package/dist/api/router.d.ts.map +0 -1
  35. package/dist/api/router.js +0 -31
  36. package/dist/api/router.test.d.ts +0 -2
  37. package/dist/api/router.test.d.ts.map +0 -1
  38. package/dist/api/router.test.js +0 -103
  39. package/dist/temporary-internal-core/handlers/listApps.d.ts +0 -67
  40. package/dist/temporary-internal-core/handlers/listApps.d.ts.map +0 -1
  41. package/dist/temporary-internal-core/handlers/listApps.js +0 -134
  42. package/dist/temporary-internal-core/handlers/listApps.test.d.ts +0 -2
  43. package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +0 -1
  44. package/dist/temporary-internal-core/handlers/listApps.test.js +0 -367
  45. package/dist/temporary-internal-core/index.d.ts +0 -18
  46. package/dist/temporary-internal-core/index.d.ts.map +0 -1
  47. package/dist/temporary-internal-core/index.js +0 -18
  48. package/dist/temporary-internal-core/schemas/apps/index.d.ts +0 -175
  49. package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +0 -1
  50. package/dist/temporary-internal-core/schemas/apps/index.js +0 -97
  51. package/dist/temporary-internal-core/schemas/errors/index.d.ts +0 -139
  52. package/dist/temporary-internal-core/schemas/errors/index.d.ts.map +0 -1
  53. package/dist/temporary-internal-core/schemas/errors/index.js +0 -129
  54. package/dist/temporary-internal-core/schemas/implementations/index.d.ts +0 -127
  55. package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +0 -1
  56. package/dist/temporary-internal-core/schemas/implementations/index.js +0 -79
  57. package/dist/temporary-internal-core/types/handler.d.ts +0 -51
  58. package/dist/temporary-internal-core/types/handler.d.ts.map +0 -1
  59. package/dist/temporary-internal-core/types/handler.js +0 -8
  60. package/dist/temporary-internal-core/types/index.d.ts +0 -5
  61. package/dist/temporary-internal-core/types/index.d.ts.map +0 -1
  62. package/dist/temporary-internal-core/types/index.js +0 -4
  63. package/dist/temporary-internal-core/utils/app-locators.d.ts +0 -34
  64. package/dist/temporary-internal-core/utils/app-locators.d.ts.map +0 -1
  65. package/dist/temporary-internal-core/utils/app-locators.js +0 -39
  66. package/dist/temporary-internal-core/utils/string-utils.d.ts +0 -28
  67. package/dist/temporary-internal-core/utils/string-utils.d.ts.map +0 -1
  68. package/dist/temporary-internal-core/utils/string-utils.js +0 -52
  69. package/dist/temporary-internal-core/utils/transformations.d.ts +0 -18
  70. package/dist/temporary-internal-core/utils/transformations.d.ts.map +0 -1
  71. package/dist/temporary-internal-core/utils/transformations.js +0 -36
@@ -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;AAI7D,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC;QAC/C,IAAI,EAAE,OAAO,EAAE,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE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,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;AA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C;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");
@@ -3,6 +3,19 @@ import { ZapierValidationError, ZapierAuthenticationError, } from "../../types/e
3
3
  import { listAuthenticationsPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
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
+ }));
18
+ // Mock response in the new API format (data array, not results)
6
19
  const mockAuthenticationsResponse = {
7
20
  data: [
8
21
  {
@@ -206,6 +219,7 @@ describe("listAuthentications plugin", () => {
206
219
  it("should pass through is_expired and expired_at fields", async () => {
207
220
  const sdk = createTestSdk();
208
221
  const result = await sdk.listAuthentications();
222
+ // API returns these fields directly (no client-side transformation)
209
223
  expect(result.data[0].is_expired).toBe("false");
210
224
  expect(result.data[0].expired_at).toBe(null);
211
225
  expect(result.data[1].is_expired).toBe("true");
@@ -221,6 +235,7 @@ describe("listAuthentications plugin", () => {
221
235
  label: "Label Only Auth",
222
236
  },
223
237
  ],
238
+ nextCursor: undefined,
224
239
  };
225
240
  mockApiClient.get = vi.fn().mockResolvedValue(responseWithoutTitle);
226
241
  const sdk = createTestSdk();
@@ -239,6 +254,7 @@ describe("listAuthentications plugin", () => {
239
254
  label: undefined,
240
255
  },
241
256
  ],
257
+ nextCursor: undefined,
242
258
  };
243
259
  mockApiClient.get = vi
244
260
  .fn()
@@ -1,57 +1,57 @@
1
- import { z } from "zod";
1
+ import type { z } from "zod";
2
2
  export { FormattedItem, FormatMetadata } from "../utils/schema-utils";
3
3
  export declare const AppItemSchema: z.ZodObject<{
4
+ slug: z.ZodString;
5
+ age_in_days: z.ZodOptional<z.ZodNumber>;
6
+ auth_type: z.ZodOptional<z.ZodString>;
7
+ banner: z.ZodOptional<z.ZodString>;
4
8
  categories: z.ZodOptional<z.ZodArray<z.ZodObject<{
5
9
  id: z.ZodNumber;
6
10
  name: z.ZodString;
7
11
  slug: z.ZodString;
8
12
  }, z.core.$strip>>>;
9
- actions: z.ZodOptional<z.ZodObject<{
10
- read: z.ZodOptional<z.ZodNumber>;
11
- read_bulk: z.ZodOptional<z.ZodNumber>;
12
- write: z.ZodOptional<z.ZodNumber>;
13
- search: z.ZodOptional<z.ZodNumber>;
14
- search_or_write: z.ZodOptional<z.ZodNumber>;
15
- search_and_write: z.ZodOptional<z.ZodNumber>;
16
- filter: z.ZodOptional<z.ZodNumber>;
17
- }, z.core.$strip>>;
18
- description: z.ZodOptional<z.ZodString>;
19
- is_hidden: z.ZodOptional<z.ZodBoolean>;
20
- age_in_days: z.ZodOptional<z.ZodNumber>;
21
- api_docs_url: z.ZodOptional<z.ZodString>;
22
- banner: z.ZodOptional<z.ZodString>;
23
- image: z.ZodOptional<z.ZodString>;
24
13
  images: z.ZodOptional<z.ZodObject<{
25
14
  url_16x16: z.ZodOptional<z.ZodString>;
26
15
  url_32x32: z.ZodOptional<z.ZodString>;
27
16
  url_64x64: z.ZodOptional<z.ZodString>;
28
17
  url_128x128: z.ZodOptional<z.ZodString>;
29
18
  }, z.core.$strip>>;
30
- is_beta: z.ZodOptional<z.ZodBoolean>;
31
- is_built_in: z.ZodOptional<z.ZodBoolean>;
32
- is_featured: z.ZodOptional<z.ZodBoolean>;
33
- is_premium: z.ZodOptional<z.ZodBoolean>;
34
- is_public: z.ZodOptional<z.ZodBoolean>;
35
- is_upcoming: z.ZodOptional<z.ZodBoolean>;
36
19
  popularity: z.ZodOptional<z.ZodNumber>;
37
- primary_color: z.ZodOptional<z.ZodString>;
38
- slug: z.ZodString;
39
- auth_type: z.ZodOptional<z.ZodString>;
40
- is_deprecated: z.ZodOptional<z.ZodBoolean>;
41
- secondary_color: z.ZodOptional<z.ZodString>;
42
20
  has_filters: z.ZodOptional<z.ZodBoolean>;
43
21
  has_reads: z.ZodOptional<z.ZodBoolean>;
44
22
  has_searches: z.ZodOptional<z.ZodBoolean>;
45
23
  has_searches_or_writes: z.ZodOptional<z.ZodBoolean>;
46
24
  has_upfront_fields: z.ZodOptional<z.ZodBoolean>;
47
25
  has_writes: z.ZodOptional<z.ZodBoolean>;
26
+ is_beta: z.ZodOptional<z.ZodBoolean>;
27
+ is_built_in: z.ZodOptional<z.ZodBoolean>;
28
+ is_deprecated: z.ZodOptional<z.ZodBoolean>;
29
+ is_featured: z.ZodOptional<z.ZodBoolean>;
30
+ is_hidden: z.ZodOptional<z.ZodBoolean>;
48
31
  is_invite: z.ZodOptional<z.ZodBoolean>;
49
- version: z.ZodOptional<z.ZodString>;
32
+ is_premium: z.ZodOptional<z.ZodBoolean>;
33
+ is_public: z.ZodOptional<z.ZodBoolean>;
34
+ is_upcoming: z.ZodOptional<z.ZodBoolean>;
50
35
  visibility: z.ZodOptional<z.ZodString>;
36
+ actions: z.ZodOptional<z.ZodObject<{
37
+ read: z.ZodOptional<z.ZodNumber>;
38
+ read_bulk: z.ZodOptional<z.ZodNumber>;
39
+ write: z.ZodOptional<z.ZodNumber>;
40
+ search: z.ZodOptional<z.ZodNumber>;
41
+ search_or_write: z.ZodOptional<z.ZodNumber>;
42
+ search_and_write: z.ZodOptional<z.ZodNumber>;
43
+ filter: z.ZodOptional<z.ZodNumber>;
44
+ }, z.core.$strip>>;
45
+ description: z.ZodOptional<z.ZodString>;
46
+ primary_color: z.ZodOptional<z.ZodString>;
47
+ secondary_color: z.ZodOptional<z.ZodString>;
51
48
  classification: z.ZodOptional<z.ZodString>;
49
+ api_docs_url: z.ZodOptional<z.ZodString>;
50
+ image: z.ZodOptional<z.ZodString>;
52
51
  title: z.ZodString;
53
52
  key: z.ZodString;
54
53
  implementation_id: z.ZodString;
54
+ version: z.ZodOptional<z.ZodString>;
55
55
  }, z.core.$strip>;
56
56
  export type AppItem = z.infer<typeof AppItemSchema>;
57
57
  //# sourceMappingURL=App.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/schemas/App.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMtE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2BzB,CAAC;AAMF,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/schemas/App.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAK7B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMtE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoBxB,CAAC;AAMH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -1,15 +1,10 @@
1
- import { z } from "zod";
2
1
  import { withFormatter } from "../utils/schema-utils";
3
- import { ImplementationMetaSchema } from "../api/schemas";
2
+ import { AppItemSchema as AppItemSchemaBase } from "@zapier/zapier-sdk-core/v0/schemas/apps";
4
3
  import { toSnakeCase } from "../utils/string-utils";
5
4
  // ============================================================================
6
- // App Item Schema (extends ImplementationMetaSchema with transformed fields)
5
+ // App Item Schema (wraps core schema with SDK-specific formatting)
7
6
  // ============================================================================
8
- export const AppItemSchema = withFormatter(ImplementationMetaSchema.omit({ name: true, id: true }).extend({
9
- title: z.string(), // Mapped from name
10
- key: z.string(), // Extracted from id (base part without version)
11
- implementation_id: z.string(), // Mapped from id (full versioned ID)
12
- }), {
7
+ export const AppItemSchema = withFormatter(AppItemSchemaBase, {
13
8
  format: (item) => {
14
9
  // Create additional keys if slug exists
15
10
  const additionalKeys = [];
package/dist/sdk.d.ts CHANGED
@@ -46,7 +46,7 @@ export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOption
46
46
  } & {
47
47
  meta: {
48
48
  listApps: {
49
- inputSchema: typeof import("./temporary-internal-core").ListAppsOptionsSchema;
49
+ inputSchema: typeof import("./plugins/listApps/schemas").ListAppsSchema;
50
50
  };
51
51
  };
52
52
  } & {
package/dist/sdk.test.js CHANGED
@@ -162,8 +162,9 @@ describe("Environment Variable Support", () => {
162
162
  ok: true,
163
163
  status: 200,
164
164
  json: async () => ({
165
- results: [],
166
- meta: { next_cursor: null },
165
+ data: [],
166
+ links: { next: null },
167
+ meta: { count: 0, limit: 100, offset: 0 },
167
168
  }),
168
169
  headers: new Headers(),
169
170
  });
@@ -178,7 +179,7 @@ describe("Environment Variable Support", () => {
178
179
  expect(mockFetch).toHaveBeenCalledTimes(1);
179
180
  const [actualUrl] = mockFetch.mock.calls[0];
180
181
  expect(actualUrl).toMatch(new RegExp(`^${customBaseUrl}`));
181
- expect(actualUrl).toContain("/api/v4/");
182
+ expect(actualUrl).toContain("/api/v0/");
182
183
  });
183
184
  it("should use default base URL when ZAPIER_BASE_URL is not set", async () => {
184
185
  // Ensure environment variable is not set
@@ -191,8 +192,9 @@ describe("Environment Variable Support", () => {
191
192
  ok: true,
192
193
  status: 200,
193
194
  json: async () => ({
194
- results: [],
195
- meta: { next_cursor: null },
195
+ data: [],
196
+ links: { next: null },
197
+ meta: { count: 0, limit: 100, offset: 0 },
196
198
  }),
197
199
  headers: new Headers(),
198
200
  });
@@ -207,7 +209,7 @@ describe("Environment Variable Support", () => {
207
209
  expect(mockFetch).toHaveBeenCalledTimes(1);
208
210
  const [actualUrl] = mockFetch.mock.calls[0];
209
211
  expect(actualUrl).toMatch(/^https:\/\/sdkapi\.zapier\.com/);
210
- expect(actualUrl).toContain("/api/v4/");
212
+ expect(actualUrl).toContain("/api/v0/");
211
213
  });
212
214
  it("should use explicit baseUrl option for SDK API requests", async () => {
213
215
  // Clear environment variable to ensure we're testing the explicit option
@@ -221,8 +223,9 @@ describe("Environment Variable Support", () => {
221
223
  ok: true,
222
224
  status: 200,
223
225
  json: async () => ({
224
- results: [],
225
- meta: { next_cursor: null },
226
+ data: [],
227
+ links: { next: null },
228
+ meta: { count: 0, limit: 100, offset: 0 },
226
229
  }),
227
230
  headers: new Headers(),
228
231
  });
@@ -238,7 +241,7 @@ describe("Environment Variable Support", () => {
238
241
  expect(mockFetch).toHaveBeenCalledTimes(1);
239
242
  const [actualUrl] = mockFetch.mock.calls[0];
240
243
  expect(actualUrl).toMatch(new RegExp(`^${customBaseUrl}`));
241
- expect(actualUrl).toContain("/api/v4/");
244
+ expect(actualUrl).toContain("/api/v0/");
242
245
  });
243
246
  it("should accept authClientId in SDK options", async () => {
244
247
  delete process.env.ZAPIER_BASE_URL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk",
3
- "version": "0.18.3",
3
+ "version": "0.18.4",
4
4
  "description": "Complete Zapier SDK - combines all Zapier SDK packages",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -1,5 +0,0 @@
1
- /**
2
- * Integration tests for API client handler override mechanism
3
- */
4
- export {};
5
- //# sourceMappingURL=client.integration.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.integration.test.d.ts","sourceRoot":"","sources":["../../src/api/client.integration.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}