@zapier/zapier-sdk 0.15.3 → 0.15.8

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 (66) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/api/auth.d.ts +10 -0
  3. package/dist/api/auth.d.ts.map +1 -1
  4. package/dist/api/auth.js +45 -0
  5. package/dist/api/auth.test.d.ts +2 -0
  6. package/dist/api/auth.test.d.ts.map +1 -0
  7. package/dist/api/auth.test.js +220 -0
  8. package/dist/api/client.d.ts.map +1 -1
  9. package/dist/api/client.js +18 -32
  10. package/dist/api/client.methods.test.d.ts +2 -0
  11. package/dist/api/client.methods.test.d.ts.map +1 -0
  12. package/dist/api/client.methods.test.js +158 -0
  13. package/dist/api/client.test.js +27 -11
  14. package/dist/api/router.d.ts +16 -0
  15. package/dist/api/router.d.ts.map +1 -0
  16. package/dist/api/router.js +37 -0
  17. package/dist/api/router.test.d.ts +2 -0
  18. package/dist/api/router.test.d.ts.map +1 -0
  19. package/dist/api/router.test.js +109 -0
  20. package/dist/api/schemas.d.ts +38 -38
  21. package/dist/auth.d.ts +15 -0
  22. package/dist/auth.d.ts.map +1 -1
  23. package/dist/auth.js +25 -0
  24. package/dist/index.cjs +350 -87
  25. package/dist/index.d.mts +430 -269
  26. package/dist/index.mjs +350 -88
  27. package/dist/plugins/eventEmission/index.d.ts +1 -1
  28. package/dist/plugins/eventEmission/index.d.ts.map +1 -1
  29. package/dist/plugins/eventEmission/index.js +94 -22
  30. package/dist/plugins/eventEmission/index.test.js +340 -2
  31. package/dist/plugins/getAuthentication/index.d.ts +2 -5
  32. package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
  33. package/dist/plugins/getAuthentication/index.js +3 -24
  34. package/dist/plugins/getAuthentication/index.test.js +32 -144
  35. package/dist/plugins/getAuthentication/schemas.d.ts +4 -13
  36. package/dist/plugins/getAuthentication/schemas.d.ts.map +1 -1
  37. package/dist/plugins/getAuthentication/schemas.js +1 -11
  38. package/dist/schemas/Action.d.ts +1 -1
  39. package/dist/schemas/Auth.d.ts +6 -6
  40. package/dist/sdk.d.ts +1 -1
  41. package/dist/temporary-internal-core/handlers/getAuthentication.d.ts +94 -0
  42. package/dist/temporary-internal-core/handlers/getAuthentication.d.ts.map +1 -0
  43. package/dist/temporary-internal-core/handlers/getAuthentication.js +68 -0
  44. package/dist/temporary-internal-core/handlers/getAuthentication.test.d.ts +2 -0
  45. package/dist/temporary-internal-core/handlers/getAuthentication.test.d.ts.map +1 -0
  46. package/dist/temporary-internal-core/handlers/getAuthentication.test.js +248 -0
  47. package/dist/temporary-internal-core/handlers/listApps.js +1 -1
  48. package/dist/temporary-internal-core/index.d.ts +2 -0
  49. package/dist/temporary-internal-core/index.d.ts.map +1 -1
  50. package/dist/temporary-internal-core/index.js +2 -0
  51. package/dist/temporary-internal-core/schemas/authentications/index.d.ts +454 -0
  52. package/dist/temporary-internal-core/schemas/authentications/index.d.ts.map +1 -0
  53. package/dist/temporary-internal-core/schemas/authentications/index.js +96 -0
  54. package/dist/temporary-internal-core/schemas/errors/index.d.ts +139 -0
  55. package/dist/temporary-internal-core/schemas/errors/index.d.ts.map +1 -0
  56. package/dist/temporary-internal-core/schemas/errors/index.js +129 -0
  57. package/dist/temporary-internal-core/utils/app-locators.d.ts +0 -20
  58. package/dist/temporary-internal-core/utils/app-locators.d.ts.map +1 -1
  59. package/dist/temporary-internal-core/utils/app-locators.js +1 -45
  60. package/dist/temporary-internal-core/utils/string-utils.d.ts +28 -0
  61. package/dist/temporary-internal-core/utils/string-utils.d.ts.map +1 -0
  62. package/dist/temporary-internal-core/utils/string-utils.js +52 -0
  63. package/dist/temporary-internal-core/utils/transformations.d.ts +14 -0
  64. package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -1
  65. package/dist/temporary-internal-core/utils/transformations.js +37 -1
  66. package/package.json +1 -1
@@ -3,7 +3,7 @@ import { createZapierApi } from "./client";
3
3
  import * as auth from "../auth";
4
4
  vi.mock("../auth");
5
5
  describe("ApiClient", () => {
6
- const mockGetTokenFromEnvOrConfig = vi.mocked(auth.getTokenFromEnvOrConfig);
6
+ const mockResolveAuthToken = vi.mocked(auth.resolveAuthToken);
7
7
  beforeEach(() => {
8
8
  vi.clearAllMocks();
9
9
  // Prevent any actual HTTP calls
@@ -14,8 +14,8 @@ describe("ApiClient", () => {
14
14
  });
15
15
  });
16
16
  describe("authentication token resolution", () => {
17
- it("should pass authBaseUrl to getTokenFromEnvOrConfig when provided", async () => {
18
- mockGetTokenFromEnvOrConfig.mockResolvedValue("test-token");
17
+ it("should pass authBaseUrl to resolveAuthToken when provided", async () => {
18
+ mockResolveAuthToken.mockResolvedValue("test-token");
19
19
  const client = createZapierApi({
20
20
  baseUrl: "https://api.custom.zapier.dev",
21
21
  authBaseUrl: "https://auth.custom.zapier.dev",
@@ -23,7 +23,9 @@ describe("ApiClient", () => {
23
23
  });
24
24
  // Make a request that would trigger token resolution
25
25
  await client.get("/test", { authRequired: true });
26
- expect(mockGetTokenFromEnvOrConfig).toHaveBeenCalledWith({
26
+ expect(mockResolveAuthToken).toHaveBeenCalledWith({
27
+ token: undefined,
28
+ getToken: undefined,
27
29
  onEvent: undefined,
28
30
  fetch: expect.any(Function),
29
31
  baseUrl: "https://api.custom.zapier.dev",
@@ -32,7 +34,7 @@ describe("ApiClient", () => {
32
34
  });
33
35
  });
34
36
  it("should pass undefined authBaseUrl when not provided", async () => {
35
- mockGetTokenFromEnvOrConfig.mockResolvedValue("test-token");
37
+ mockResolveAuthToken.mockResolvedValue("test-token");
36
38
  const client = createZapierApi({
37
39
  baseUrl: "https://api.custom.zapier.dev",
38
40
  // authBaseUrl intentionally omitted
@@ -40,7 +42,9 @@ describe("ApiClient", () => {
40
42
  });
41
43
  // Make a request that would trigger token resolution
42
44
  await client.get("/test", { authRequired: true });
43
- expect(mockGetTokenFromEnvOrConfig).toHaveBeenCalledWith({
45
+ expect(mockResolveAuthToken).toHaveBeenCalledWith({
46
+ token: undefined,
47
+ getToken: undefined,
44
48
  onEvent: undefined,
45
49
  fetch: expect.any(Function),
46
50
  baseUrl: "https://api.custom.zapier.dev",
@@ -48,8 +52,8 @@ describe("ApiClient", () => {
48
52
  authClientId: undefined,
49
53
  });
50
54
  });
51
- it("should pass authClientId to getTokenFromEnvOrConfig when provided", async () => {
52
- mockGetTokenFromEnvOrConfig.mockResolvedValue("test-token");
55
+ it("should pass authClientId to resolveAuthToken when provided", async () => {
56
+ mockResolveAuthToken.mockResolvedValue("test-token");
53
57
  const client = createZapierApi({
54
58
  baseUrl: "https://api.custom.zapier.dev",
55
59
  authClientId: "custom-client-id",
@@ -57,7 +61,9 @@ describe("ApiClient", () => {
57
61
  });
58
62
  // Make a request that would trigger token resolution
59
63
  await client.get("/test", { authRequired: true });
60
- expect(mockGetTokenFromEnvOrConfig).toHaveBeenCalledWith({
64
+ expect(mockResolveAuthToken).toHaveBeenCalledWith({
65
+ token: undefined,
66
+ getToken: undefined,
61
67
  onEvent: undefined,
62
68
  fetch: expect.any(Function),
63
69
  baseUrl: "https://api.custom.zapier.dev",
@@ -65,7 +71,8 @@ describe("ApiClient", () => {
65
71
  authClientId: "custom-client-id",
66
72
  });
67
73
  });
68
- it("should not call getTokenFromEnvOrConfig when token is provided directly", async () => {
74
+ it("should not call resolveAuthToken when token is provided directly", async () => {
75
+ mockResolveAuthToken.mockResolvedValue("direct-token");
69
76
  const client = createZapierApi({
70
77
  token: "direct-token",
71
78
  baseUrl: "https://api.custom.zapier.dev",
@@ -74,7 +81,16 @@ describe("ApiClient", () => {
74
81
  });
75
82
  // Make a request that would use the direct token
76
83
  await client.get("/test", { authRequired: true });
77
- expect(mockGetTokenFromEnvOrConfig).not.toHaveBeenCalled();
84
+ // resolveAuthToken is still called, but it returns the direct token immediately
85
+ expect(mockResolveAuthToken).toHaveBeenCalledWith({
86
+ token: "direct-token",
87
+ getToken: undefined,
88
+ onEvent: undefined,
89
+ fetch: expect.any(Function),
90
+ baseUrl: "https://api.custom.zapier.dev",
91
+ authBaseUrl: "https://auth.custom.zapier.dev",
92
+ authClientId: undefined,
93
+ });
78
94
  });
79
95
  });
80
96
  });
@@ -0,0 +1,16 @@
1
+ import { type Handler } from "../temporary-internal-core";
2
+ export interface Route {
3
+ method: string;
4
+ pattern: RegExp;
5
+ handler: Handler<any, any, any>;
6
+ paramMap: string[];
7
+ }
8
+ export declare function findMatchingRoute(routeList: Route[], method: string, path: string): {
9
+ handler: Handler<any, any, any>;
10
+ params: Record<string, string>;
11
+ } | null;
12
+ export declare function matchRoute(method: string, path: string): {
13
+ handler: Handler<any, any, any>;
14
+ params: Record<string, string>;
15
+ } | null;
16
+ //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/api/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACb,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAChC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAiBD,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,KAAK,EAAE,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM;;;SAsBb;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;;;SAEtD"}
@@ -0,0 +1,37 @@
1
+ import { handleListApps, handleGetAuthentication, } from "../temporary-internal-core";
2
+ const routes = [
3
+ {
4
+ method: "GET",
5
+ pattern: /^\/api\/v0\/apps$/,
6
+ handler: handleListApps,
7
+ paramMap: [],
8
+ },
9
+ {
10
+ method: "GET",
11
+ pattern: /^\/api\/v0\/authentications\/([^\/]+)$/,
12
+ handler: handleGetAuthentication,
13
+ paramMap: ["authenticationId"],
14
+ },
15
+ ];
16
+ export function findMatchingRoute(routeList, method, path) {
17
+ for (const route of routeList) {
18
+ if (route.method !== method) {
19
+ continue;
20
+ }
21
+ const match = path.match(route.pattern);
22
+ if (match) {
23
+ const params = {};
24
+ route.paramMap.forEach((name, index) => {
25
+ params[name] = match[index + 1];
26
+ });
27
+ return {
28
+ handler: route.handler,
29
+ params,
30
+ };
31
+ }
32
+ }
33
+ return null;
34
+ }
35
+ export function matchRoute(method, path) {
36
+ return findMatchingRoute(routes, method, path);
37
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=router.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.test.d.ts","sourceRoot":"","sources":["../../src/api/router.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,109 @@
1
+ import { describe, it, expect, vi } from "vitest";
2
+ import { matchRoute, findMatchingRoute } from "./router";
3
+ import { handleListApps, handleGetAuthentication, } from "../temporary-internal-core";
4
+ describe("Router", () => {
5
+ describe("matchRoute (Integration)", () => {
6
+ it("should match GET /api/v0/apps", () => {
7
+ const match = matchRoute("GET", "/api/v0/apps");
8
+ expect(match).not.toBeNull();
9
+ expect(match?.handler).toBe(handleListApps);
10
+ expect(match?.params).toEqual({});
11
+ });
12
+ it("should match GET /api/v0/authentications/:authenticationId", () => {
13
+ const match = matchRoute("GET", "/api/v0/authentications/12345");
14
+ expect(match).not.toBeNull();
15
+ expect(match?.handler).toBe(handleGetAuthentication);
16
+ expect(match?.params).toEqual({ authenticationId: "12345" });
17
+ });
18
+ it("should not match POST /api/v0/apps", () => {
19
+ const match = matchRoute("POST", "/api/v0/apps");
20
+ expect(match).toBeNull();
21
+ });
22
+ it("should not match unknown paths", () => {
23
+ expect(matchRoute("GET", "/api/v0/unknown")).toBeNull();
24
+ expect(matchRoute("GET", "/")).toBeNull();
25
+ });
26
+ it("should not match partial paths if regex is anchored", () => {
27
+ // The regex is /^\/api\/v0\/apps$/ so it shouldn't match suffix
28
+ expect(matchRoute("GET", "/api/v0/apps/something")).toBeNull();
29
+ });
30
+ });
31
+ describe("findMatchingRoute (Unit)", () => {
32
+ const mockHandler = vi.fn();
33
+ const testRoutes = [
34
+ {
35
+ method: "GET",
36
+ pattern: /^\/items$/,
37
+ handler: mockHandler,
38
+ paramMap: [],
39
+ },
40
+ {
41
+ method: "GET",
42
+ pattern: /^\/items\/(\d+)$/,
43
+ handler: mockHandler,
44
+ paramMap: ["id"],
45
+ },
46
+ {
47
+ method: "POST",
48
+ pattern: /^\/items$/,
49
+ handler: mockHandler,
50
+ paramMap: [],
51
+ },
52
+ {
53
+ method: "GET",
54
+ pattern: /^\/users\/(\w+)\/posts\/(\d+)$/,
55
+ handler: mockHandler,
56
+ paramMap: ["userId", "postId"],
57
+ },
58
+ ];
59
+ it("should match exact path", () => {
60
+ const match = findMatchingRoute(testRoutes, "GET", "/items");
61
+ expect(match).not.toBeNull();
62
+ expect(match?.handler).toBe(mockHandler);
63
+ expect(match?.params).toEqual({});
64
+ });
65
+ it("should extract single parameter", () => {
66
+ const match = findMatchingRoute(testRoutes, "GET", "/items/123");
67
+ expect(match).not.toBeNull();
68
+ expect(match?.params).toEqual({ id: "123" });
69
+ });
70
+ it("should extract multiple parameters", () => {
71
+ const match = findMatchingRoute(testRoutes, "GET", "/users/alice/posts/456");
72
+ expect(match).not.toBeNull();
73
+ expect(match?.params).toEqual({ userId: "alice", postId: "456" });
74
+ });
75
+ it("should respect HTTP method", () => {
76
+ // GET /items exists
77
+ expect(findMatchingRoute(testRoutes, "GET", "/items")).not.toBeNull();
78
+ // POST /items exists
79
+ expect(findMatchingRoute(testRoutes, "POST", "/items")).not.toBeNull();
80
+ // PUT /items does not exist
81
+ expect(findMatchingRoute(testRoutes, "PUT", "/items")).toBeNull();
82
+ });
83
+ it("should not match if regex does not match", () => {
84
+ // /items/abc does not match /^\/items\/(\d+)$/ (\d+ is digits only)
85
+ expect(findMatchingRoute(testRoutes, "GET", "/items/abc")).toBeNull();
86
+ });
87
+ it("should handle empty route list", () => {
88
+ expect(findMatchingRoute([], "GET", "/anything")).toBeNull();
89
+ });
90
+ it("should return first matching route", () => {
91
+ const overlappingRoutes = [
92
+ {
93
+ method: "GET",
94
+ pattern: /^\/overlapping$/,
95
+ handler: mockHandler,
96
+ paramMap: [],
97
+ },
98
+ {
99
+ method: "GET",
100
+ pattern: /^\/overlapping$/, // duplicate pattern
101
+ handler: () => Promise.resolve("second"),
102
+ paramMap: [],
103
+ },
104
+ ];
105
+ const match = findMatchingRoute(overlappingRoutes, "GET", "/overlapping");
106
+ expect(match?.handler).toBe(mockHandler); // Should match the first one
107
+ });
108
+ });
109
+ });
@@ -152,19 +152,19 @@ export declare const ActionSchema: z.ZodObject<{
152
152
  type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
153
153
  name: string;
154
154
  description: string;
155
+ selected_api?: string | undefined;
155
156
  id?: string | undefined;
156
157
  is_important?: boolean | undefined;
157
158
  is_hidden?: boolean | undefined;
158
- selected_api?: string | undefined;
159
159
  }, {
160
160
  key: string;
161
161
  type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
162
162
  name: string;
163
163
  description: string;
164
+ selected_api?: string | undefined;
164
165
  id?: string | undefined;
165
166
  is_important?: boolean | undefined;
166
167
  is_hidden?: boolean | undefined;
167
- selected_api?: string | undefined;
168
168
  }>;
169
169
  export declare const ChoiceSchema: z.ZodObject<{
170
170
  value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
@@ -313,18 +313,18 @@ export declare const AuthenticationSchema: z.ZodObject<{
313
313
  members: z.ZodOptional<z.ZodString>;
314
314
  permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
315
315
  }, "strip", z.ZodTypeAny, {
316
+ account_id: number;
317
+ selected_api: string;
316
318
  id: number;
317
319
  date: string;
318
- selected_api: string;
319
- account_id: number;
320
320
  is_invite_only: boolean;
321
321
  is_private: boolean;
322
322
  shared_with_all: boolean;
323
323
  url?: string | undefined;
324
324
  members?: string | undefined;
325
+ customuser_id?: number | undefined;
325
326
  label?: string | null | undefined;
326
327
  lastchanged?: string | undefined;
327
- customuser_id?: number | undefined;
328
328
  destination_selected_api?: string | null | undefined;
329
329
  is_stale?: string | undefined;
330
330
  is_shared?: string | undefined;
@@ -334,18 +334,18 @@ export declare const AuthenticationSchema: z.ZodObject<{
334
334
  groups?: string | undefined;
335
335
  permissions?: Record<string, boolean> | undefined;
336
336
  }, {
337
+ account_id: number;
338
+ selected_api: string;
337
339
  id: number;
338
340
  date: string;
339
- selected_api: string;
340
- account_id: number;
341
341
  is_invite_only: boolean;
342
342
  is_private: boolean;
343
343
  shared_with_all: boolean;
344
344
  url?: string | undefined;
345
345
  members?: string | undefined;
346
+ customuser_id?: number | undefined;
346
347
  label?: string | null | undefined;
347
348
  lastchanged?: string | undefined;
348
- customuser_id?: number | undefined;
349
349
  destination_selected_api?: string | null | undefined;
350
350
  is_stale?: string | undefined;
351
351
  is_shared?: string | undefined;
@@ -381,18 +381,18 @@ export declare const AuthenticationsResponseSchema: z.ZodObject<{
381
381
  members: z.ZodOptional<z.ZodString>;
382
382
  permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
383
383
  }, "strip", z.ZodTypeAny, {
384
+ account_id: number;
385
+ selected_api: string;
384
386
  id: number;
385
387
  date: string;
386
- selected_api: string;
387
- account_id: number;
388
388
  is_invite_only: boolean;
389
389
  is_private: boolean;
390
390
  shared_with_all: boolean;
391
391
  url?: string | undefined;
392
392
  members?: string | undefined;
393
+ customuser_id?: number | undefined;
393
394
  label?: string | null | undefined;
394
395
  lastchanged?: string | undefined;
395
- customuser_id?: number | undefined;
396
396
  destination_selected_api?: string | null | undefined;
397
397
  is_stale?: string | undefined;
398
398
  is_shared?: string | undefined;
@@ -402,18 +402,18 @@ export declare const AuthenticationsResponseSchema: z.ZodObject<{
402
402
  groups?: string | undefined;
403
403
  permissions?: Record<string, boolean> | undefined;
404
404
  }, {
405
+ account_id: number;
406
+ selected_api: string;
405
407
  id: number;
406
408
  date: string;
407
- selected_api: string;
408
- account_id: number;
409
409
  is_invite_only: boolean;
410
410
  is_private: boolean;
411
411
  shared_with_all: boolean;
412
412
  url?: string | undefined;
413
413
  members?: string | undefined;
414
+ customuser_id?: number | undefined;
414
415
  label?: string | null | undefined;
415
416
  lastchanged?: string | undefined;
416
- customuser_id?: number | undefined;
417
417
  destination_selected_api?: string | null | undefined;
418
418
  is_stale?: string | undefined;
419
419
  is_shared?: string | undefined;
@@ -426,18 +426,18 @@ export declare const AuthenticationsResponseSchema: z.ZodObject<{
426
426
  }, "strip", z.ZodTypeAny, {
427
427
  count: number;
428
428
  results: {
429
+ account_id: number;
430
+ selected_api: string;
429
431
  id: number;
430
432
  date: string;
431
- selected_api: string;
432
- account_id: number;
433
433
  is_invite_only: boolean;
434
434
  is_private: boolean;
435
435
  shared_with_all: boolean;
436
436
  url?: string | undefined;
437
437
  members?: string | undefined;
438
+ customuser_id?: number | undefined;
438
439
  label?: string | null | undefined;
439
440
  lastchanged?: string | undefined;
440
- customuser_id?: number | undefined;
441
441
  destination_selected_api?: string | null | undefined;
442
442
  is_stale?: string | undefined;
443
443
  is_shared?: string | undefined;
@@ -452,18 +452,18 @@ export declare const AuthenticationsResponseSchema: z.ZodObject<{
452
452
  }, {
453
453
  count: number;
454
454
  results: {
455
+ account_id: number;
456
+ selected_api: string;
455
457
  id: number;
456
458
  date: string;
457
- selected_api: string;
458
- account_id: number;
459
459
  is_invite_only: boolean;
460
460
  is_private: boolean;
461
461
  shared_with_all: boolean;
462
462
  url?: string | undefined;
463
463
  members?: string | undefined;
464
+ customuser_id?: number | undefined;
464
465
  label?: string | null | undefined;
465
466
  lastchanged?: string | undefined;
466
- customuser_id?: number | undefined;
467
467
  destination_selected_api?: string | null | undefined;
468
468
  is_stale?: string | undefined;
469
469
  is_shared?: string | undefined;
@@ -1067,19 +1067,19 @@ export declare const ImplementationSchema: z.ZodObject<{
1067
1067
  type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
1068
1068
  name: string;
1069
1069
  description: string;
1070
+ selected_api?: string | undefined;
1070
1071
  id?: string | undefined;
1071
1072
  is_important?: boolean | undefined;
1072
1073
  is_hidden?: boolean | undefined;
1073
- selected_api?: string | undefined;
1074
1074
  }, {
1075
1075
  key: string;
1076
1076
  type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
1077
1077
  name: string;
1078
1078
  description: string;
1079
+ selected_api?: string | undefined;
1079
1080
  id?: string | undefined;
1080
1081
  is_important?: boolean | undefined;
1081
1082
  is_hidden?: boolean | undefined;
1082
- selected_api?: string | undefined;
1083
1083
  }>, "many">>;
1084
1084
  is_deprecated: z.ZodOptional<z.ZodBoolean>;
1085
1085
  is_private_only: z.ZodOptional<z.ZodBoolean>;
@@ -1103,18 +1103,18 @@ export declare const ImplementationSchema: z.ZodObject<{
1103
1103
  type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
1104
1104
  name: string;
1105
1105
  description: string;
1106
+ selected_api?: string | undefined;
1106
1107
  id?: string | undefined;
1107
1108
  is_important?: boolean | undefined;
1108
1109
  is_hidden?: boolean | undefined;
1109
- selected_api?: string | undefined;
1110
1110
  }[] | undefined;
1111
+ app_id?: number | undefined;
1111
1112
  name?: string | undefined;
1112
1113
  is_hidden?: string | undefined;
1113
1114
  is_invite_only?: boolean | undefined;
1114
1115
  images?: Record<string, string | null> | undefined;
1115
1116
  primary_color?: string | undefined;
1116
1117
  slug?: string | undefined;
1117
- app_id?: number | undefined;
1118
1118
  auth_type?: string | undefined;
1119
1119
  auth_fields?: string | undefined;
1120
1120
  is_deprecated?: boolean | undefined;
@@ -1129,11 +1129,12 @@ export declare const ImplementationSchema: z.ZodObject<{
1129
1129
  type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
1130
1130
  name: string;
1131
1131
  description: string;
1132
+ selected_api?: string | undefined;
1132
1133
  id?: string | undefined;
1133
1134
  is_important?: boolean | undefined;
1134
1135
  is_hidden?: boolean | undefined;
1135
- selected_api?: string | undefined;
1136
1136
  }[] | undefined;
1137
+ app_id?: number | undefined;
1137
1138
  name?: string | undefined;
1138
1139
  is_hidden?: string | undefined;
1139
1140
  is_invite_only?: boolean | undefined;
@@ -1142,7 +1143,6 @@ export declare const ImplementationSchema: z.ZodObject<{
1142
1143
  is_premium?: boolean | undefined;
1143
1144
  primary_color?: string | undefined;
1144
1145
  slug?: string | undefined;
1145
- app_id?: number | undefined;
1146
1146
  auth_type?: string | undefined;
1147
1147
  auth_fields?: string | undefined;
1148
1148
  is_deprecated?: boolean | undefined;
@@ -1174,19 +1174,19 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
1174
1174
  type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
1175
1175
  name: string;
1176
1176
  description: string;
1177
+ selected_api?: string | undefined;
1177
1178
  id?: string | undefined;
1178
1179
  is_important?: boolean | undefined;
1179
1180
  is_hidden?: boolean | undefined;
1180
- selected_api?: string | undefined;
1181
1181
  }, {
1182
1182
  key: string;
1183
1183
  type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
1184
1184
  name: string;
1185
1185
  description: string;
1186
+ selected_api?: string | undefined;
1186
1187
  id?: string | undefined;
1187
1188
  is_important?: boolean | undefined;
1188
1189
  is_hidden?: boolean | undefined;
1189
- selected_api?: string | undefined;
1190
1190
  }>, "many">>;
1191
1191
  is_deprecated: z.ZodOptional<z.ZodBoolean>;
1192
1192
  is_private_only: z.ZodOptional<z.ZodBoolean>;
@@ -1210,18 +1210,18 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
1210
1210
  type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
1211
1211
  name: string;
1212
1212
  description: string;
1213
+ selected_api?: string | undefined;
1213
1214
  id?: string | undefined;
1214
1215
  is_important?: boolean | undefined;
1215
1216
  is_hidden?: boolean | undefined;
1216
- selected_api?: string | undefined;
1217
1217
  }[] | undefined;
1218
+ app_id?: number | undefined;
1218
1219
  name?: string | undefined;
1219
1220
  is_hidden?: string | undefined;
1220
1221
  is_invite_only?: boolean | undefined;
1221
1222
  images?: Record<string, string | null> | undefined;
1222
1223
  primary_color?: string | undefined;
1223
1224
  slug?: string | undefined;
1224
- app_id?: number | undefined;
1225
1225
  auth_type?: string | undefined;
1226
1226
  auth_fields?: string | undefined;
1227
1227
  is_deprecated?: boolean | undefined;
@@ -1236,11 +1236,12 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
1236
1236
  type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
1237
1237
  name: string;
1238
1238
  description: string;
1239
+ selected_api?: string | undefined;
1239
1240
  id?: string | undefined;
1240
1241
  is_important?: boolean | undefined;
1241
1242
  is_hidden?: boolean | undefined;
1242
- selected_api?: string | undefined;
1243
1243
  }[] | undefined;
1244
+ app_id?: number | undefined;
1244
1245
  name?: string | undefined;
1245
1246
  is_hidden?: string | undefined;
1246
1247
  is_invite_only?: boolean | undefined;
@@ -1249,7 +1250,6 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
1249
1250
  is_premium?: boolean | undefined;
1250
1251
  primary_color?: string | undefined;
1251
1252
  slug?: string | undefined;
1252
- app_id?: number | undefined;
1253
1253
  auth_type?: string | undefined;
1254
1254
  auth_fields?: string | undefined;
1255
1255
  is_deprecated?: boolean | undefined;
@@ -1269,18 +1269,18 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
1269
1269
  type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
1270
1270
  name: string;
1271
1271
  description: string;
1272
+ selected_api?: string | undefined;
1272
1273
  id?: string | undefined;
1273
1274
  is_important?: boolean | undefined;
1274
1275
  is_hidden?: boolean | undefined;
1275
- selected_api?: string | undefined;
1276
1276
  }[] | undefined;
1277
+ app_id?: number | undefined;
1277
1278
  name?: string | undefined;
1278
1279
  is_hidden?: string | undefined;
1279
1280
  is_invite_only?: boolean | undefined;
1280
1281
  images?: Record<string, string | null> | undefined;
1281
1282
  primary_color?: string | undefined;
1282
1283
  slug?: string | undefined;
1283
- app_id?: number | undefined;
1284
1284
  auth_type?: string | undefined;
1285
1285
  auth_fields?: string | undefined;
1286
1286
  is_deprecated?: boolean | undefined;
@@ -1300,11 +1300,12 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
1300
1300
  type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
1301
1301
  name: string;
1302
1302
  description: string;
1303
+ selected_api?: string | undefined;
1303
1304
  id?: string | undefined;
1304
1305
  is_important?: boolean | undefined;
1305
1306
  is_hidden?: boolean | undefined;
1306
- selected_api?: string | undefined;
1307
1307
  }[] | undefined;
1308
+ app_id?: number | undefined;
1308
1309
  name?: string | undefined;
1309
1310
  is_hidden?: string | undefined;
1310
1311
  is_invite_only?: boolean | undefined;
@@ -1313,7 +1314,6 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
1313
1314
  is_premium?: boolean | undefined;
1314
1315
  primary_color?: string | undefined;
1315
1316
  slug?: string | undefined;
1316
- app_id?: number | undefined;
1317
1317
  auth_type?: string | undefined;
1318
1318
  auth_fields?: string | undefined;
1319
1319
  is_deprecated?: boolean | undefined;
@@ -1845,16 +1845,16 @@ export declare const NeedChoicesRequestSchema: z.ZodObject<{
1845
1845
  input_field_id: z.ZodOptional<z.ZodString>;
1846
1846
  }, "strip", z.ZodTypeAny, {
1847
1847
  page: number;
1848
+ selected_api?: string | undefined;
1848
1849
  params?: Record<string, unknown> | undefined;
1849
1850
  prefill?: string | undefined;
1850
- selected_api?: string | undefined;
1851
1851
  authentication_id?: number | undefined;
1852
1852
  action_id?: string | undefined;
1853
1853
  input_field_id?: string | undefined;
1854
1854
  }, {
1855
+ selected_api?: string | undefined;
1855
1856
  params?: Record<string, unknown> | undefined;
1856
1857
  prefill?: string | undefined;
1857
- selected_api?: string | undefined;
1858
1858
  authentication_id?: number | undefined;
1859
1859
  page?: number | undefined;
1860
1860
  action_id?: string | undefined;
package/dist/auth.d.ts CHANGED
@@ -14,6 +14,10 @@ export interface AuthOptions {
14
14
  authBaseUrl?: string;
15
15
  authClientId?: string;
16
16
  }
17
+ export interface ResolveAuthTokenOptions extends AuthOptions {
18
+ token?: string;
19
+ getToken?: () => Promise<string | undefined> | string | undefined;
20
+ }
17
21
  /**
18
22
  * Gets the ZAPIER_TOKEN from environment variables.
19
23
  * Returns undefined if not set.
@@ -34,4 +38,15 @@ export declare function getTokenFromCliLogin(options?: AuthOptions): Promise<str
34
38
  * Returns undefined if no valid token is found.
35
39
  */
36
40
  export declare function getTokenFromEnvOrConfig(options?: AuthOptions): Promise<string | undefined>;
41
+ /**
42
+ * Resolves an auth token from all possible sources with the following precedence:
43
+ * 1. Explicitly provided token in options
44
+ * 2. Token from getToken callback in options
45
+ * 3. ZAPIER_TOKEN environment variable
46
+ * 4. CLI login package (if available)
47
+ *
48
+ * This is the canonical token resolution logic used throughout the SDK.
49
+ * Returns undefined if no valid token is found.
50
+ */
51
+ export declare function resolveAuthToken(options?: ResolveAuthTokenOptions): Promise<string | undefined>;
37
52
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpD,YAAY,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,aAAa,GACd,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,GAAG,SAAS,CAEpD;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAS7B;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAS7B"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpD,YAAY,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,aAAa,GACd,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,uBAAwB,SAAQ,WAAW;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,GAAG,SAAS,CAAC;CACnE;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,GAAG,SAAS,CAEpD;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAS7B;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAS7B;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAgB7B"}