@zapier/zapier-sdk 0.18.0 → 0.18.2

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 (43) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +5 -5
  3. package/dist/api/router.d.ts.map +1 -1
  4. package/dist/api/router.js +1 -7
  5. package/dist/api/router.test.js +1 -7
  6. package/dist/api/types.d.ts +2 -1
  7. package/dist/api/types.d.ts.map +1 -1
  8. package/dist/api/types.js +0 -10
  9. package/dist/index.cjs +59 -247
  10. package/dist/index.d.mts +100 -191
  11. package/dist/index.mjs +59 -247
  12. package/dist/plugins/eventEmission/transport.d.ts +8 -18
  13. package/dist/plugins/eventEmission/transport.d.ts.map +1 -1
  14. package/dist/plugins/eventEmission/transport.js +47 -44
  15. package/dist/plugins/eventEmission/transport.test.js +36 -25
  16. package/dist/plugins/getAuthentication/index.d.ts +3 -3
  17. package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
  18. package/dist/plugins/getAuthentication/index.js +3 -5
  19. package/dist/plugins/getAuthentication/index.test.js +4 -16
  20. package/dist/plugins/getAuthentication/schemas.d.ts +2 -4
  21. package/dist/plugins/getAuthentication/schemas.d.ts.map +1 -1
  22. package/dist/plugins/getAuthentication/schemas.js +1 -1
  23. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  24. package/dist/schemas/Auth.d.ts +11 -11
  25. package/dist/schemas/Auth.d.ts.map +1 -1
  26. package/dist/schemas/Auth.js +2 -12
  27. package/dist/sdk.d.ts +3 -1
  28. package/dist/sdk.d.ts.map +1 -1
  29. package/dist/temporary-internal-core/index.d.ts +0 -2
  30. package/dist/temporary-internal-core/index.d.ts.map +1 -1
  31. package/dist/temporary-internal-core/index.js +0 -2
  32. package/dist/temporary-internal-core/utils/transformations.d.ts +1 -1
  33. package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -1
  34. package/package.json +2 -1
  35. package/dist/temporary-internal-core/handlers/getAuthentication.d.ts +0 -94
  36. package/dist/temporary-internal-core/handlers/getAuthentication.d.ts.map +0 -1
  37. package/dist/temporary-internal-core/handlers/getAuthentication.js +0 -68
  38. package/dist/temporary-internal-core/handlers/getAuthentication.test.d.ts +0 -2
  39. package/dist/temporary-internal-core/handlers/getAuthentication.test.d.ts.map +0 -1
  40. package/dist/temporary-internal-core/handlers/getAuthentication.test.js +0 -248
  41. package/dist/temporary-internal-core/schemas/authentications/index.d.ts +0 -150
  42. package/dist/temporary-internal-core/schemas/authentications/index.d.ts.map +0 -1
  43. package/dist/temporary-internal-core/schemas/authentications/index.js +0 -97
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=getAuthentication.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getAuthentication.test.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/handlers/getAuthentication.test.ts"],"names":[],"mappings":""}
@@ -1,248 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import { handleGetAuthentication, } from "./getAuthentication";
3
- import { ZapierAuthenticationError, ZapierResourceNotFoundError, } from "../schemas/errors";
4
- const mockAuthenticationResponse = {
5
- id: 123,
6
- date: "2021-01-01",
7
- account_id: 456,
8
- selected_api: "SlackCLIAPI@1.21.1",
9
- is_invite_only: false,
10
- is_private: false,
11
- shared_with_all: false,
12
- is_stale: "false",
13
- marked_stale_at: null,
14
- label: "My Slack Workspace",
15
- title: "My Slack Workspace",
16
- };
17
- describe("handleGetAuthentication", () => {
18
- let mockHttpClient;
19
- beforeEach(() => {
20
- vi.clearAllMocks();
21
- mockHttpClient = {
22
- get: vi.fn().mockResolvedValue(mockAuthenticationResponse),
23
- post: vi.fn(),
24
- delete: vi.fn(),
25
- };
26
- });
27
- describe("request validation", () => {
28
- it("should reject request with missing authenticationId", async () => {
29
- const invalidRequest = {};
30
- const deps = {
31
- httpClient: mockHttpClient,
32
- };
33
- await expect(handleGetAuthentication({ request: invalidRequest, deps })).rejects.toThrow();
34
- });
35
- it("should reject request with invalid authenticationId type", async () => {
36
- const invalidRequest = {
37
- authenticationId: { invalid: true },
38
- };
39
- const deps = {
40
- httpClient: mockHttpClient,
41
- };
42
- await expect(handleGetAuthentication({ request: invalidRequest, deps })).rejects.toThrow();
43
- });
44
- it("should accept string authenticationId and convert to number", async () => {
45
- // Note: The schema accepts string or number as input and transforms to number
46
- const request = {
47
- authenticationId: "123",
48
- };
49
- const deps = {
50
- httpClient: mockHttpClient,
51
- };
52
- const result = await handleGetAuthentication({ request, deps });
53
- expect(mockHttpClient.get).toHaveBeenCalledWith("/zapier/api/v4/authentications/123/", expect.any(Object));
54
- expect(result.data).toBeDefined();
55
- });
56
- it("should accept number authenticationId", async () => {
57
- const request = {
58
- authenticationId: 123,
59
- };
60
- const deps = {
61
- httpClient: mockHttpClient,
62
- };
63
- const result = await handleGetAuthentication({ request, deps });
64
- expect(result.data).toBeDefined();
65
- });
66
- });
67
- describe("API integration", () => {
68
- it("should call the correct API endpoint", async () => {
69
- const request = {
70
- authenticationId: 123,
71
- };
72
- const deps = {
73
- httpClient: mockHttpClient,
74
- };
75
- await handleGetAuthentication({ request, deps });
76
- expect(mockHttpClient.get).toHaveBeenCalledWith("/zapier/api/v4/authentications/123/", expect.objectContaining({
77
- authRequired: true,
78
- customErrorHandler: expect.any(Function),
79
- }));
80
- });
81
- it("should return normalized authentication data", async () => {
82
- const request = {
83
- authenticationId: 123,
84
- };
85
- const deps = {
86
- httpClient: mockHttpClient,
87
- };
88
- const result = await handleGetAuthentication({ request, deps });
89
- expect(result.data).toEqual({
90
- id: "123",
91
- date: "2021-01-01",
92
- account_id: "456",
93
- implementation_id: "SlackCLIAPI@1.21.1",
94
- is_invite_only: false,
95
- is_private: false,
96
- shared_with_all: false,
97
- is_expired: "false",
98
- expired_at: null,
99
- label: "My Slack Workspace",
100
- title: "My Slack Workspace",
101
- app_key: "SlackCLIAPI",
102
- app_version: "1.21.1",
103
- profile_id: undefined, // customuser_id wasn't in mock data
104
- is_stale: "false", // Original field preserved
105
- marked_stale_at: null, // Original field preserved
106
- });
107
- });
108
- });
109
- describe("error handling", () => {
110
- it("should throw ZapierAuthenticationError for 401 responses", async () => {
111
- mockHttpClient.get = vi.fn().mockImplementation((_path, options) => {
112
- const error = options?.customErrorHandler?.({
113
- status: 401,
114
- statusText: "Unauthorized",
115
- data: {},
116
- });
117
- throw error;
118
- });
119
- const request = {
120
- authenticationId: 123,
121
- };
122
- const deps = {
123
- httpClient: mockHttpClient,
124
- };
125
- await expect(handleGetAuthentication({ request, deps })).rejects.toThrow(ZapierAuthenticationError);
126
- });
127
- it("should throw ZapierAuthenticationError for 403 responses", async () => {
128
- mockHttpClient.get = vi.fn().mockImplementation((_path, options) => {
129
- const error = options?.customErrorHandler?.({
130
- status: 403,
131
- statusText: "Forbidden",
132
- data: {},
133
- });
134
- throw error;
135
- });
136
- const request = {
137
- authenticationId: 123,
138
- };
139
- const deps = {
140
- httpClient: mockHttpClient,
141
- };
142
- await expect(handleGetAuthentication({ request, deps })).rejects.toThrow(ZapierAuthenticationError);
143
- });
144
- it("should throw ZapierResourceNotFoundError for 404 responses", async () => {
145
- mockHttpClient.get = vi.fn().mockImplementation((_path, options) => {
146
- const error = options?.customErrorHandler?.({
147
- status: 404,
148
- statusText: "Not Found",
149
- data: {},
150
- });
151
- throw error;
152
- });
153
- const request = {
154
- authenticationId: 123,
155
- };
156
- const deps = {
157
- httpClient: mockHttpClient,
158
- };
159
- await expect(handleGetAuthentication({ request, deps })).rejects.toThrow(ZapierResourceNotFoundError);
160
- });
161
- it("should handle network errors", async () => {
162
- mockHttpClient.get = vi
163
- .fn()
164
- .mockRejectedValue(new Error("Network error"));
165
- const request = {
166
- authenticationId: 123,
167
- };
168
- const deps = {
169
- httpClient: mockHttpClient,
170
- };
171
- await expect(handleGetAuthentication({ request, deps })).rejects.toThrow("Network error");
172
- });
173
- });
174
- describe("data transformation", () => {
175
- it("should map is_stale to is_expired and marked_stale_at to expired_at", async () => {
176
- const authWithExpiration = {
177
- ...mockAuthenticationResponse,
178
- is_stale: "true",
179
- marked_stale_at: "2021-06-01",
180
- };
181
- mockHttpClient.get = vi.fn().mockResolvedValue(authWithExpiration);
182
- const request = {
183
- authenticationId: 123,
184
- };
185
- const deps = {
186
- httpClient: mockHttpClient,
187
- };
188
- const result = await handleGetAuthentication({ request, deps });
189
- expect(result.data.is_expired).toBe("true");
190
- expect(result.data.expired_at).toBe("2021-06-01");
191
- });
192
- it("should preserve all original authentication fields", async () => {
193
- const authWithAllFields = {
194
- id: 123,
195
- date: "2021-01-01",
196
- lastchanged: "2021-01-02",
197
- account_id: 456,
198
- customuser_id: 789,
199
- selected_api: "SlackCLIAPI@1.21.1",
200
- destination_selected_api: "SlackDestAPI@1.0.0",
201
- is_invite_only: true,
202
- is_private: true,
203
- shared_with_all: false,
204
- is_stale: "true",
205
- is_shared: "false",
206
- marked_stale_at: "2021-06-01",
207
- label: "Auth Label",
208
- title: "Auth Title",
209
- identifier: "auth-identifier",
210
- url: "https://example.com",
211
- groups: "group1,group2",
212
- members: "user1,user2",
213
- permissions: { read: true, write: false },
214
- };
215
- mockHttpClient.get = vi.fn().mockResolvedValue(authWithAllFields);
216
- const request = {
217
- authenticationId: 123,
218
- };
219
- const deps = {
220
- httpClient: mockHttpClient,
221
- };
222
- const result = await handleGetAuthentication({ request, deps });
223
- const auth = result.data;
224
- // Verify original fields are preserved (IDs converted to strings)
225
- expect(auth.id).toBe("123");
226
- expect(auth.date).toBe("2021-01-01");
227
- expect(auth.lastchanged).toBe("2021-01-02");
228
- expect(auth.account_id).toBe("456");
229
- expect(auth.profile_id).toBe("789");
230
- expect(auth.implementation_id).toBe("SlackCLIAPI@1.21.1");
231
- expect(auth.destination_selected_api).toBe("SlackDestAPI@1.0.0");
232
- expect(auth.is_invite_only).toBe(true);
233
- expect(auth.is_private).toBe(true);
234
- expect(auth.shared_with_all).toBe(false);
235
- expect(auth.is_shared).toBe("false");
236
- expect(auth.label).toBe("Auth Label");
237
- expect(auth.title).toBe("Auth Title");
238
- expect(auth.identifier).toBe("auth-identifier");
239
- expect(auth.url).toBe("https://example.com");
240
- expect(auth.groups).toBe("group1,group2");
241
- expect(auth.members).toBe("user1,user2");
242
- expect(auth.permissions).toEqual({ read: true, write: false });
243
- // Verify mapped fields
244
- expect(auth.is_expired).toBe("true");
245
- expect(auth.expired_at).toBe("2021-06-01");
246
- });
247
- });
248
- });
@@ -1,150 +0,0 @@
1
- /**
2
- * Authentication schemas
3
- */
4
- import { z } from "zod";
5
- export declare const AuthenticationSchema: z.ZodObject<{
6
- id: z.ZodNumber;
7
- date: z.ZodString;
8
- lastchanged: z.ZodOptional<z.ZodString>;
9
- account_id: z.ZodNumber;
10
- customuser_id: z.ZodOptional<z.ZodNumber>;
11
- selected_api: z.ZodString;
12
- destination_selected_api: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
- is_invite_only: z.ZodBoolean;
14
- is_private: z.ZodBoolean;
15
- shared_with_all: z.ZodBoolean;
16
- is_stale: z.ZodOptional<z.ZodString>;
17
- is_shared: z.ZodOptional<z.ZodString>;
18
- marked_stale_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
- label: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
- identifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
21
- title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
- url: z.ZodOptional<z.ZodString>;
23
- groups: z.ZodOptional<z.ZodString>;
24
- members: z.ZodOptional<z.ZodString>;
25
- permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
26
- }, z.core.$strip>;
27
- export declare const AuthenticationsResponseSchema: z.ZodObject<{
28
- count: z.ZodNumber;
29
- next: z.ZodOptional<z.ZodNullable<z.ZodString>>;
30
- previous: z.ZodOptional<z.ZodNullable<z.ZodString>>;
31
- results: z.ZodArray<z.ZodObject<{
32
- id: z.ZodNumber;
33
- date: z.ZodString;
34
- lastchanged: z.ZodOptional<z.ZodString>;
35
- account_id: z.ZodNumber;
36
- customuser_id: z.ZodOptional<z.ZodNumber>;
37
- selected_api: z.ZodString;
38
- destination_selected_api: z.ZodOptional<z.ZodNullable<z.ZodString>>;
39
- is_invite_only: z.ZodBoolean;
40
- is_private: z.ZodBoolean;
41
- shared_with_all: z.ZodBoolean;
42
- is_stale: z.ZodOptional<z.ZodString>;
43
- is_shared: z.ZodOptional<z.ZodString>;
44
- marked_stale_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
45
- label: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
- identifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
- title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
- url: z.ZodOptional<z.ZodString>;
49
- groups: z.ZodOptional<z.ZodString>;
50
- members: z.ZodOptional<z.ZodString>;
51
- permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
52
- }, z.core.$strip>>;
53
- }, z.core.$strip>;
54
- export type Authentication = z.infer<typeof AuthenticationSchema>;
55
- /**
56
- * Normalized authentication item returned by getAuthentication handler
57
- *
58
- * Transforms API response fields:
59
- * - selected_api → implementation_id
60
- * - customuser_id → profile_id
61
- * - is_stale → is_expired (preserved as is_stale too)
62
- * - marked_stale_at → expired_at (preserved as marked_stale_at too)
63
- *
64
- * Adds computed fields:
65
- * - app_key: Extracted from selected_api (e.g., "SlackCLIAPI@1.0.0" → "SlackCLIAPI")
66
- * - app_version: Extracted from selected_api (e.g., "SlackCLIAPI@1.0.0" → "1.0.0")
67
- */
68
- export declare const AuthenticationItemSchema: z.ZodObject<{
69
- url: z.ZodOptional<z.ZodString>;
70
- members: z.ZodOptional<z.ZodString>;
71
- label: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
- date: z.ZodString;
73
- lastchanged: z.ZodOptional<z.ZodString>;
74
- destination_selected_api: z.ZodOptional<z.ZodNullable<z.ZodString>>;
75
- is_invite_only: z.ZodBoolean;
76
- is_private: z.ZodBoolean;
77
- shared_with_all: z.ZodBoolean;
78
- is_stale: z.ZodOptional<z.ZodString>;
79
- is_shared: z.ZodOptional<z.ZodString>;
80
- marked_stale_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
81
- identifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
82
- title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
83
- groups: z.ZodOptional<z.ZodString>;
84
- permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
85
- id: z.ZodString;
86
- account_id: z.ZodString;
87
- implementation_id: z.ZodOptional<z.ZodString>;
88
- profile_id: z.ZodOptional<z.ZodString>;
89
- is_expired: z.ZodOptional<z.ZodString>;
90
- expired_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
91
- app_key: z.ZodOptional<z.ZodString>;
92
- app_version: z.ZodOptional<z.ZodString>;
93
- }, z.core.$strip>;
94
- export type AuthenticationItem = z.infer<typeof AuthenticationItemSchema>;
95
- /**
96
- * Public API schema for getAuthentication operation
97
- *
98
- * This is the user-facing schema that the SDK plugin accepts.
99
- */
100
- export declare const GetAuthenticationOptionsSchema: z.ZodObject<{
101
- authenticationId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
102
- }, z.core.$strip>;
103
- export type GetAuthenticationOptions = z.infer<typeof GetAuthenticationOptionsSchema>;
104
- /**
105
- * Handler request schema for getAuthentication operation
106
- *
107
- * Accepts authenticationId as either string (from searchParams) or number,
108
- * and normalizes to number for internal use.
109
- */
110
- export declare const GetAuthenticationHandlerRequestSchema: z.ZodPipe<z.ZodObject<{
111
- authenticationId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
112
- }, z.core.$strip>, z.ZodTransform<{
113
- authenticationId: number;
114
- }, {
115
- authenticationId: string | number;
116
- }>>;
117
- export type GetAuthenticationHandlerRequest = z.infer<typeof GetAuthenticationHandlerRequestSchema>;
118
- /**
119
- * Response schema for getAuthentication (single item)
120
- */
121
- export declare const GetAuthenticationResponseSchema: z.ZodObject<{
122
- data: z.ZodLazy<z.ZodObject<{
123
- url: z.ZodOptional<z.ZodString>;
124
- members: z.ZodOptional<z.ZodString>;
125
- label: z.ZodOptional<z.ZodNullable<z.ZodString>>;
126
- date: z.ZodString;
127
- lastchanged: z.ZodOptional<z.ZodString>;
128
- destination_selected_api: z.ZodOptional<z.ZodNullable<z.ZodString>>;
129
- is_invite_only: z.ZodBoolean;
130
- is_private: z.ZodBoolean;
131
- shared_with_all: z.ZodBoolean;
132
- is_stale: z.ZodOptional<z.ZodString>;
133
- is_shared: z.ZodOptional<z.ZodString>;
134
- marked_stale_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
135
- identifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
136
- title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
137
- groups: z.ZodOptional<z.ZodString>;
138
- permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
139
- id: z.ZodString;
140
- account_id: z.ZodString;
141
- implementation_id: z.ZodOptional<z.ZodString>;
142
- profile_id: z.ZodOptional<z.ZodString>;
143
- is_expired: z.ZodOptional<z.ZodString>;
144
- expired_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
145
- app_key: z.ZodOptional<z.ZodString>;
146
- app_version: z.ZodOptional<z.ZodString>;
147
- }, z.core.$strip>>;
148
- }, z.core.$strip>;
149
- export type GetAuthenticationResponse = z.infer<typeof GetAuthenticationResponseSchema>;
150
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/temporary-internal-core/schemas/authentications/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;iBAqB/B,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKxC,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;iBAmBnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,8BAA8B;;iBAMO,CAAC;AAEnD,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qCAAqC;;;;;;GAW7C,CAAC;AAEN,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CACnD,OAAO,qCAAqC,CAC7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAE1C,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC"}
@@ -1,97 +0,0 @@
1
- /**
2
- * Authentication schemas
3
- */
4
- import { z } from "zod";
5
- export const AuthenticationSchema = z.object({
6
- id: z.number(),
7
- date: z.string(),
8
- lastchanged: z.string().optional(),
9
- account_id: z.number(),
10
- customuser_id: z.number().optional(),
11
- selected_api: z.string(),
12
- destination_selected_api: z.string().nullable().optional(),
13
- is_invite_only: z.boolean(),
14
- is_private: z.boolean(),
15
- shared_with_all: z.boolean(),
16
- is_stale: z.string().optional(),
17
- is_shared: z.string().optional(),
18
- marked_stale_at: z.string().nullable().optional(),
19
- label: z.string().nullable().optional(),
20
- identifier: z.string().nullable().optional(),
21
- title: z.string().nullable().optional(),
22
- url: z.string().optional(),
23
- groups: z.string().optional(),
24
- members: z.string().optional(),
25
- permissions: z.record(z.string(), z.boolean()).optional(),
26
- });
27
- export const AuthenticationsResponseSchema = z.object({
28
- count: z.number(),
29
- next: z.string().nullable().optional(),
30
- previous: z.string().nullable().optional(),
31
- results: z.array(AuthenticationSchema),
32
- });
33
- /**
34
- * Normalized authentication item returned by getAuthentication handler
35
- *
36
- * Transforms API response fields:
37
- * - selected_api → implementation_id
38
- * - customuser_id → profile_id
39
- * - is_stale → is_expired (preserved as is_stale too)
40
- * - marked_stale_at → expired_at (preserved as marked_stale_at too)
41
- *
42
- * Adds computed fields:
43
- * - app_key: Extracted from selected_api (e.g., "SlackCLIAPI@1.0.0" → "SlackCLIAPI")
44
- * - app_version: Extracted from selected_api (e.g., "SlackCLIAPI@1.0.0" → "1.0.0")
45
- */
46
- export const AuthenticationItemSchema = AuthenticationSchema.omit({
47
- selected_api: true,
48
- customuser_id: true,
49
- }).extend({
50
- // Override numeric IDs with string versions (converted by normalizeAuthenticationItem)
51
- id: z.string(),
52
- account_id: z.string(),
53
- // Renamed fields
54
- implementation_id: z.string().optional(),
55
- profile_id: z.string().optional(),
56
- // Mapped fields (originals preserved in ...restOfAuth)
57
- is_expired: z.string().optional(),
58
- expired_at: z.string().nullable().optional(),
59
- // Computed fields
60
- app_key: z.string().optional(),
61
- app_version: z.string().optional(),
62
- });
63
- /**
64
- * Public API schema for getAuthentication operation
65
- *
66
- * This is the user-facing schema that the SDK plugin accepts.
67
- */
68
- export const GetAuthenticationOptionsSchema = z
69
- .object({
70
- authenticationId: z
71
- .union([z.string(), z.number().int().positive()])
72
- .describe("Authentication ID to retrieve"),
73
- })
74
- .describe("Get a specific authentication by ID");
75
- /**
76
- * Handler request schema for getAuthentication operation
77
- *
78
- * Accepts authenticationId as either string (from searchParams) or number,
79
- * and normalizes to number for internal use.
80
- */
81
- export const GetAuthenticationHandlerRequestSchema = z
82
- .object({
83
- authenticationId: z
84
- .union([z.string(), z.number()])
85
- .describe("Authentication ID - string from searchParams or number"),
86
- })
87
- .transform((data) => ({
88
- authenticationId: typeof data.authenticationId === "string"
89
- ? parseInt(data.authenticationId, 10)
90
- : data.authenticationId,
91
- }));
92
- /**
93
- * Response schema for getAuthentication (single item)
94
- */
95
- export const GetAuthenticationResponseSchema = z.object({
96
- data: z.lazy(() => AuthenticationItemSchema),
97
- });