@zapier/zapier-sdk 0.32.5 → 0.33.1

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 (129) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/auth.d.ts.map +1 -1
  3. package/dist/auth.js +1 -0
  4. package/dist/constants.d.ts +0 -14
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/constants.js +0 -14
  7. package/dist/credentials.d.ts.map +1 -1
  8. package/dist/credentials.js +19 -20
  9. package/dist/index.cjs +22 -37
  10. package/dist/index.d.mts +1 -15
  11. package/dist/index.mjs +23 -30
  12. package/package.json +2 -2
  13. package/dist/api/auth.test.d.ts +0 -2
  14. package/dist/api/auth.test.d.ts.map +0 -1
  15. package/dist/api/auth.test.js +0 -220
  16. package/dist/api/client.test.d.ts +0 -2
  17. package/dist/api/client.test.d.ts.map +0 -1
  18. package/dist/api/client.test.js +0 -611
  19. package/dist/api/debug.test.d.ts +0 -2
  20. package/dist/api/debug.test.d.ts.map +0 -1
  21. package/dist/api/debug.test.js +0 -59
  22. package/dist/api/polling.test.d.ts +0 -2
  23. package/dist/api/polling.test.d.ts.map +0 -1
  24. package/dist/api/polling.test.js +0 -360
  25. package/dist/auth.test.d.ts +0 -2
  26. package/dist/auth.test.d.ts.map +0 -1
  27. package/dist/auth.test.js +0 -480
  28. package/dist/plugins/eventEmission/builders.test.d.ts +0 -2
  29. package/dist/plugins/eventEmission/builders.test.d.ts.map +0 -1
  30. package/dist/plugins/eventEmission/builders.test.js +0 -138
  31. package/dist/plugins/eventEmission/index.test.d.ts +0 -5
  32. package/dist/plugins/eventEmission/index.test.d.ts.map +0 -1
  33. package/dist/plugins/eventEmission/index.test.js +0 -704
  34. package/dist/plugins/eventEmission/transport.test.d.ts +0 -5
  35. package/dist/plugins/eventEmission/transport.test.d.ts.map +0 -1
  36. package/dist/plugins/eventEmission/transport.test.js +0 -164
  37. package/dist/plugins/fetch/index.test.d.ts +0 -2
  38. package/dist/plugins/fetch/index.test.d.ts.map +0 -1
  39. package/dist/plugins/fetch/index.test.js +0 -428
  40. package/dist/plugins/findFirstConnection/index.test.d.ts +0 -2
  41. package/dist/plugins/findFirstConnection/index.test.d.ts.map +0 -1
  42. package/dist/plugins/findFirstConnection/index.test.js +0 -177
  43. package/dist/plugins/findUniqueConnection/index.test.d.ts +0 -2
  44. package/dist/plugins/findUniqueConnection/index.test.d.ts.map +0 -1
  45. package/dist/plugins/findUniqueConnection/index.test.js +0 -159
  46. package/dist/plugins/getAction/index.test.d.ts +0 -2
  47. package/dist/plugins/getAction/index.test.d.ts.map +0 -1
  48. package/dist/plugins/getAction/index.test.js +0 -211
  49. package/dist/plugins/getApp/index.test.d.ts +0 -2
  50. package/dist/plugins/getApp/index.test.d.ts.map +0 -1
  51. package/dist/plugins/getApp/index.test.js +0 -157
  52. package/dist/plugins/getConnection/index.test.d.ts +0 -2
  53. package/dist/plugins/getConnection/index.test.d.ts.map +0 -1
  54. package/dist/plugins/getConnection/index.test.js +0 -124
  55. package/dist/plugins/getInputFieldsSchema/index.test.d.ts +0 -2
  56. package/dist/plugins/getInputFieldsSchema/index.test.d.ts.map +0 -1
  57. package/dist/plugins/getInputFieldsSchema/index.test.js +0 -291
  58. package/dist/plugins/listActions/index.test.d.ts +0 -2
  59. package/dist/plugins/listActions/index.test.d.ts.map +0 -1
  60. package/dist/plugins/listActions/index.test.js +0 -454
  61. package/dist/plugins/listApps/index.test.d.ts +0 -2
  62. package/dist/plugins/listApps/index.test.d.ts.map +0 -1
  63. package/dist/plugins/listApps/index.test.js +0 -124
  64. package/dist/plugins/listConnections/index.test.d.ts +0 -2
  65. package/dist/plugins/listConnections/index.test.d.ts.map +0 -1
  66. package/dist/plugins/listConnections/index.test.js +0 -920
  67. package/dist/plugins/listInputFieldChoices/index.test.d.ts +0 -2
  68. package/dist/plugins/listInputFieldChoices/index.test.d.ts.map +0 -1
  69. package/dist/plugins/listInputFieldChoices/index.test.js +0 -717
  70. package/dist/plugins/listInputFields/index.test.d.ts +0 -2
  71. package/dist/plugins/listInputFields/index.test.d.ts.map +0 -1
  72. package/dist/plugins/listInputFields/index.test.js +0 -359
  73. package/dist/plugins/manifest/index.test.d.ts +0 -2
  74. package/dist/plugins/manifest/index.test.d.ts.map +0 -1
  75. package/dist/plugins/manifest/index.test.js +0 -1179
  76. package/dist/plugins/request/index.test.d.ts +0 -2
  77. package/dist/plugins/request/index.test.d.ts.map +0 -1
  78. package/dist/plugins/request/index.test.js +0 -458
  79. package/dist/plugins/runAction/index.test.d.ts +0 -2
  80. package/dist/plugins/runAction/index.test.d.ts.map +0 -1
  81. package/dist/plugins/runAction/index.test.js +0 -350
  82. package/dist/resolvers/connectionId.test.d.ts +0 -2
  83. package/dist/resolvers/connectionId.test.d.ts.map +0 -1
  84. package/dist/resolvers/connectionId.test.js +0 -61
  85. package/dist/sdk.test.d.ts +0 -2
  86. package/dist/sdk.test.d.ts.map +0 -1
  87. package/dist/sdk.test.js +0 -260
  88. package/dist/types/domain.test.d.ts +0 -2
  89. package/dist/types/domain.test.d.ts.map +0 -1
  90. package/dist/types/domain.test.js +0 -39
  91. package/dist/utils/array-utils.test.d.ts +0 -2
  92. package/dist/utils/array-utils.test.d.ts.map +0 -1
  93. package/dist/utils/array-utils.test.js +0 -107
  94. package/dist/utils/batch-utils.test.d.ts +0 -2
  95. package/dist/utils/batch-utils.test.d.ts.map +0 -1
  96. package/dist/utils/batch-utils.test.js +0 -476
  97. package/dist/utils/domain-utils.test.d.ts +0 -2
  98. package/dist/utils/domain-utils.test.d.ts.map +0 -1
  99. package/dist/utils/domain-utils.test.js +0 -346
  100. package/dist/utils/file-utils.test.d.ts +0 -2
  101. package/dist/utils/file-utils.test.d.ts.map +0 -1
  102. package/dist/utils/file-utils.test.js +0 -51
  103. package/dist/utils/function-utils.test.d.ts +0 -2
  104. package/dist/utils/function-utils.test.d.ts.map +0 -1
  105. package/dist/utils/function-utils.test.js +0 -188
  106. package/dist/utils/id-utils.test.d.ts +0 -2
  107. package/dist/utils/id-utils.test.d.ts.map +0 -1
  108. package/dist/utils/id-utils.test.js +0 -22
  109. package/dist/utils/pagination-utils.test.d.ts +0 -17
  110. package/dist/utils/pagination-utils.test.d.ts.map +0 -1
  111. package/dist/utils/pagination-utils.test.js +0 -461
  112. package/dist/utils/retry-utils.test.d.ts +0 -2
  113. package/dist/utils/retry-utils.test.d.ts.map +0 -1
  114. package/dist/utils/retry-utils.test.js +0 -90
  115. package/dist/utils/string-utils.test.d.ts +0 -2
  116. package/dist/utils/string-utils.test.d.ts.map +0 -1
  117. package/dist/utils/string-utils.test.js +0 -59
  118. package/dist/utils/telemetry-context.test.d.ts +0 -2
  119. package/dist/utils/telemetry-context.test.d.ts.map +0 -1
  120. package/dist/utils/telemetry-context.test.js +0 -154
  121. package/dist/utils/telemetry-utils.test.d.ts +0 -2
  122. package/dist/utils/telemetry-utils.test.d.ts.map +0 -1
  123. package/dist/utils/telemetry-utils.test.js +0 -155
  124. package/dist/utils/url-utils.test.d.ts +0 -2
  125. package/dist/utils/url-utils.test.d.ts.map +0 -1
  126. package/dist/utils/url-utils.test.js +0 -103
  127. package/dist/utils/validation.test.d.ts +0 -2
  128. package/dist/utils/validation.test.d.ts.map +0 -1
  129. package/dist/utils/validation.test.js +0 -44
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/request/index.test.ts"],"names":[],"mappings":""}
@@ -1,458 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
- import { ZapierValidationError } from "../../types/errors";
3
- import { requestPlugin } from "./index";
4
- import { fetchPlugin } from "../fetch";
5
- import { createSdk } from "../../sdk";
6
- import { eventEmissionPlugin, } from "../eventEmission";
7
- import { resetDeprecationWarnings } from "../../utils/logging";
8
- describe("request plugin", () => {
9
- let mockApiClient;
10
- let mockFetch;
11
- beforeEach(() => {
12
- vi.clearAllMocks();
13
- mockFetch = vi.fn().mockResolvedValue(new Response('{"success": true}', {
14
- status: 200,
15
- headers: { "Content-Type": "application/json" },
16
- }));
17
- mockApiClient = {
18
- fetch: mockFetch,
19
- };
20
- });
21
- const apiPlugin = () => ({
22
- context: {
23
- api: mockApiClient,
24
- },
25
- });
26
- function createTestSdk() {
27
- return createSdk()
28
- .addPlugin(() => ({
29
- context: {
30
- options: {},
31
- },
32
- }))
33
- .addPlugin(apiPlugin)
34
- .addPlugin(eventEmissionPlugin)
35
- .addPlugin(fetchPlugin)
36
- .addPlugin(requestPlugin);
37
- }
38
- describe("schema validation", () => {
39
- it("should throw validation error for missing url", async () => {
40
- const sdk = createTestSdk();
41
- await expect(sdk.request({})).rejects.toThrow(ZapierValidationError);
42
- });
43
- it("should throw validation error for invalid url", async () => {
44
- const sdk = createTestSdk();
45
- await expect(sdk.request({ url: "not-a-url" })).rejects.toThrow(ZapierValidationError);
46
- });
47
- it("should throw validation error for invalid method", async () => {
48
- const sdk = createTestSdk();
49
- await expect(sdk.request({
50
- url: "https://api.example.com/data",
51
- method: "INVALID",
52
- })).rejects.toThrow(ZapierValidationError);
53
- });
54
- it("should throw validation error for invalid authenticationId type", async () => {
55
- const sdk = createTestSdk();
56
- await expect(sdk.request({
57
- url: "https://api.example.com/data",
58
- authenticationId: "not-a-number",
59
- })).rejects.toThrow(ZapierValidationError);
60
- });
61
- it("should throw validation error for invalid callbackUrl", async () => {
62
- const sdk = createTestSdk();
63
- await expect(sdk.request({
64
- url: "https://api.example.com/data",
65
- callbackUrl: "not-a-url",
66
- })).rejects.toThrow(ZapierValidationError);
67
- });
68
- it("should pass validation with valid minimal options", async () => {
69
- const sdk = createTestSdk();
70
- await sdk.request({ url: "https://api.example.com/data" });
71
- expect(mockFetch).toHaveBeenCalled();
72
- });
73
- it("should pass validation with all valid options", async () => {
74
- const sdk = createTestSdk();
75
- await sdk.request({
76
- url: "https://api.example.com/data",
77
- method: "POST",
78
- body: '{"test": true}',
79
- headers: { "Content-Type": "application/json" },
80
- authenticationId: 123,
81
- callbackUrl: "https://webhook.example.com/callback",
82
- });
83
- expect(mockFetch).toHaveBeenCalled();
84
- });
85
- });
86
- describe("URL transformation", () => {
87
- it("should transform full URLs to relay path format", async () => {
88
- const sdk = createTestSdk();
89
- await sdk.request({
90
- url: "https://api.github.com/user",
91
- method: "GET",
92
- });
93
- expect(mockFetch).toHaveBeenCalledWith("/relay/api.github.com/user", expect.any(Object));
94
- });
95
- it("should preserve query parameters and fragments", async () => {
96
- const sdk = createTestSdk();
97
- await sdk.request({
98
- url: "https://api.example.com/search?q=test&limit=10#section",
99
- method: "GET",
100
- });
101
- expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/search?q=test&limit=10#section", expect.any(Object));
102
- });
103
- it("should handle URLs with ports", async () => {
104
- const sdk = createTestSdk();
105
- await sdk.request({
106
- url: "https://api.example.com:8443/data",
107
- method: "GET",
108
- });
109
- expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com:8443/data", expect.any(Object));
110
- });
111
- });
112
- describe("headers handling", () => {
113
- it("should pass through regular headers", async () => {
114
- const sdk = createTestSdk();
115
- const headers = {
116
- "Content-Type": "application/json",
117
- "X-Custom-Header": "test-value",
118
- };
119
- await sdk.request({
120
- url: "https://api.example.com/data",
121
- method: "POST",
122
- headers,
123
- });
124
- expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
125
- method: "POST",
126
- body: undefined,
127
- headers: {
128
- "Content-Type": "application/json",
129
- "X-Custom-Header": "test-value",
130
- },
131
- authRequired: true,
132
- });
133
- });
134
- it("should add relay-specific headers when provided", async () => {
135
- const sdk = createTestSdk();
136
- await sdk.request({
137
- url: "https://api.example.com/data",
138
- method: "POST",
139
- authenticationId: 123,
140
- callbackUrl: "https://webhook.example.com/callback",
141
- });
142
- expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
143
- method: "POST",
144
- body: undefined,
145
- headers: {
146
- "X-Relay-Authentication-Id": "123",
147
- "X-Relay-Callback-Url": "https://webhook.example.com/callback",
148
- },
149
- authRequired: true,
150
- });
151
- });
152
- it("should handle Headers object", async () => {
153
- const sdk = createTestSdk();
154
- const headers = new Headers();
155
- headers.set("Content-Type", "application/json");
156
- headers.set("Authorization", "Bearer token");
157
- await sdk.request({
158
- url: "https://api.example.com/data",
159
- headers,
160
- });
161
- expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
162
- method: "GET",
163
- body: undefined,
164
- headers: {
165
- "content-type": "application/json", // Headers constructor lowercases names
166
- authorization: "Bearer token", // Headers constructor lowercases names
167
- },
168
- authRequired: true,
169
- });
170
- });
171
- it("should handle headers as array of tuples", async () => {
172
- const sdk = createTestSdk();
173
- const headers = [
174
- ["Content-Type", "application/json"],
175
- ["X-Api-Key", "secret"],
176
- ];
177
- await sdk.request({
178
- url: "https://api.example.com/data",
179
- headers,
180
- });
181
- expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
182
- method: "GET",
183
- body: undefined,
184
- headers: {
185
- "Content-Type": "application/json",
186
- "X-Api-Key": "secret",
187
- },
188
- authRequired: true,
189
- });
190
- });
191
- });
192
- describe("HTTP methods", () => {
193
- const methods = [
194
- "GET",
195
- "POST",
196
- "PUT",
197
- "DELETE",
198
- "PATCH",
199
- "HEAD",
200
- "OPTIONS",
201
- ];
202
- methods.forEach((method) => {
203
- it(`should support ${method} method`, async () => {
204
- const sdk = createTestSdk();
205
- await sdk.request({
206
- url: "https://api.example.com/data",
207
- method,
208
- });
209
- expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
210
- method,
211
- body: undefined,
212
- headers: {},
213
- authRequired: true,
214
- });
215
- });
216
- });
217
- it("should default to GET method", async () => {
218
- const sdk = createTestSdk();
219
- await sdk.request({
220
- url: "https://api.example.com/data",
221
- });
222
- expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
223
- method: "GET",
224
- body: undefined,
225
- headers: {},
226
- authRequired: true,
227
- });
228
- });
229
- });
230
- describe("request body", () => {
231
- it("should pass through request body", async () => {
232
- const sdk = createTestSdk();
233
- const body = '{"name": "test", "value": 42}';
234
- await sdk.request({
235
- url: "https://api.example.com/data",
236
- method: "POST",
237
- body,
238
- });
239
- expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
240
- method: "POST",
241
- body,
242
- headers: {
243
- "Content-Type": "application/json; charset=utf-8",
244
- },
245
- authRequired: true,
246
- });
247
- });
248
- it("should auto-set Content-Type for JSON object bodies", async () => {
249
- const sdk = createTestSdk();
250
- const body = '{"key": "value"}';
251
- await sdk.request({
252
- url: "https://api.example.com/data",
253
- method: "POST",
254
- body,
255
- });
256
- expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
257
- method: "POST",
258
- body,
259
- headers: {
260
- "Content-Type": "application/json; charset=utf-8",
261
- },
262
- authRequired: true,
263
- });
264
- });
265
- it("should auto-set Content-Type for JSON array bodies", async () => {
266
- const sdk = createTestSdk();
267
- const body = '[{"id": 1}, {"id": 2}]';
268
- await sdk.request({
269
- url: "https://api.example.com/data",
270
- method: "POST",
271
- body,
272
- });
273
- expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
274
- method: "POST",
275
- body,
276
- headers: {
277
- "Content-Type": "application/json; charset=utf-8",
278
- },
279
- authRequired: true,
280
- });
281
- });
282
- it("should not override explicit Content-Type header", async () => {
283
- const sdk = createTestSdk();
284
- const body = '{"key": "value"}';
285
- await sdk.request({
286
- url: "https://api.example.com/data",
287
- method: "POST",
288
- body,
289
- headers: {
290
- "Content-Type": "text/plain",
291
- },
292
- });
293
- expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
294
- method: "POST",
295
- body,
296
- headers: {
297
- "Content-Type": "text/plain",
298
- },
299
- authRequired: true,
300
- });
301
- });
302
- it("should not set Content-Type for non-JSON bodies", async () => {
303
- const sdk = createTestSdk();
304
- const body = "plain text body";
305
- await sdk.request({
306
- url: "https://api.example.com/data",
307
- method: "POST",
308
- body,
309
- });
310
- expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
311
- method: "POST",
312
- body,
313
- headers: {},
314
- authRequired: true,
315
- });
316
- });
317
- });
318
- describe("authentication", () => {
319
- it("should set authRequired to true in API call options", async () => {
320
- const sdk = createTestSdk();
321
- await sdk.request({ url: "https://api.example.com/data" });
322
- expect(mockFetch).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({
323
- authRequired: true,
324
- }));
325
- });
326
- });
327
- describe("response handling", () => {
328
- it("should return the response from api.fetch", async () => {
329
- const mockResponse = new Response('{"result": "success"}', {
330
- status: 200,
331
- statusText: "OK",
332
- headers: { "Content-Type": "application/json" },
333
- });
334
- mockFetch.mockResolvedValue(mockResponse);
335
- const sdk = createTestSdk();
336
- const response = await sdk.request({
337
- url: "https://api.example.com/data",
338
- });
339
- expect(response).toBe(mockResponse);
340
- expect(response.status).toBe(200);
341
- });
342
- it("should handle API errors", async () => {
343
- const error = new Error("Network error");
344
- mockFetch.mockRejectedValue(error);
345
- const sdk = createTestSdk();
346
- await expect(sdk.request({ url: "https://api.example.com/data" })).rejects.toThrow("Network error");
347
- });
348
- });
349
- describe("context and metadata", () => {
350
- it("should provide context with meta information", () => {
351
- const sdk = createTestSdk();
352
- const context = sdk.getContext();
353
- expect(context.meta.request).toBeDefined();
354
- expect(context.meta.request.inputSchema).toBeDefined();
355
- });
356
- it("should be in both cli and mcp packages for backward compat", () => {
357
- const sdk = createTestSdk();
358
- const context = sdk.getContext();
359
- expect(context.meta.request.packages).toContain("cli");
360
- expect(context.meta.request.packages).toContain("mcp");
361
- });
362
- it("should be marked as deprecated", () => {
363
- const sdk = createTestSdk();
364
- const context = sdk.getContext();
365
- expect(context.meta.request.categories).toContain("deprecated");
366
- expect(context.meta.request.categories).toContain("http");
367
- });
368
- });
369
- describe("deprecation warning", () => {
370
- let warnSpy;
371
- beforeEach(() => {
372
- resetDeprecationWarnings();
373
- warnSpy = vi.spyOn(console, "warn").mockImplementation(() => { });
374
- });
375
- afterEach(() => {
376
- warnSpy.mockRestore();
377
- });
378
- it("should log a deprecation warning when called", async () => {
379
- const sdk = createTestSdk();
380
- await sdk.request({ url: "https://api.example.com/data" });
381
- expect(warnSpy).toHaveBeenCalledWith("[zapier-sdk] Deprecation: request() is deprecated. Use fetch() instead.");
382
- });
383
- it("should only log the deprecation warning once", async () => {
384
- const sdk = createTestSdk();
385
- await sdk.request({ url: "https://api.example.com/data" });
386
- await sdk.request({ url: "https://api.example.com/other" });
387
- const deprecationCalls = warnSpy.mock.calls.filter((call) => typeof call[0] === "string" && call[0].includes("Deprecation"));
388
- expect(deprecationCalls).toHaveLength(1);
389
- });
390
- });
391
- describe("backward compatibility with fetch", () => {
392
- it("should produce the same api.fetch call as sdk.fetch for a simple GET", async () => {
393
- const sdk = createTestSdk();
394
- await sdk.request({ url: "https://api.example.com/data" });
395
- const requestCall = mockFetch.mock.calls[0];
396
- mockFetch.mockClear();
397
- await sdk.fetch("https://api.example.com/data");
398
- const fetchCall = mockFetch.mock.calls[0];
399
- expect(requestCall).toEqual(fetchCall);
400
- });
401
- it("should produce the same api.fetch call as sdk.fetch for a POST with body and auth", async () => {
402
- const sdk = createTestSdk();
403
- const body = '{"key": "value"}';
404
- await sdk.request({
405
- url: "https://api.example.com/data",
406
- method: "POST",
407
- body,
408
- headers: { "X-Custom": "header" },
409
- authenticationId: 456,
410
- callbackUrl: "https://callback.example.com/hook",
411
- });
412
- const requestCall = mockFetch.mock.calls[0];
413
- mockFetch.mockClear();
414
- await sdk.fetch("https://api.example.com/data", {
415
- method: "POST",
416
- body,
417
- headers: { "X-Custom": "header" },
418
- authenticationId: 456,
419
- callbackUrl: "https://callback.example.com/hook",
420
- });
421
- const fetchCall = mockFetch.mock.calls[0];
422
- expect(requestCall).toEqual(fetchCall);
423
- });
424
- it("should propagate errors from fetch through request", async () => {
425
- const error = new Error("Network error");
426
- mockFetch.mockRejectedValue(error);
427
- const sdk = createTestSdk();
428
- await expect(sdk.request({ url: "https://api.example.com/data" })).rejects.toThrow("Network error");
429
- });
430
- it("should not emit double telemetry when request delegates to fetch", async () => {
431
- const emitSpy = vi.fn();
432
- const mockEventEmissionPlugin = () => ({
433
- context: {
434
- eventEmission: {
435
- transport: {},
436
- config: {},
437
- emit: () => { },
438
- createBaseEvent: (() => ({})),
439
- emitMethodCalled: emitSpy,
440
- flush: async () => { },
441
- close: async () => { },
442
- },
443
- },
444
- });
445
- const sdk = createSdk()
446
- .addPlugin(() => ({
447
- context: { options: {} },
448
- }))
449
- .addPlugin(apiPlugin)
450
- .addPlugin(mockEventEmissionPlugin)
451
- .addPlugin(fetchPlugin)
452
- .addPlugin(requestPlugin);
453
- await sdk.request({ url: "https://api.example.com/data" });
454
- const methodCalledEvents = emitSpy.mock.calls.map((c) => c[0].method_name);
455
- expect(methodCalledEvents).toEqual(["request"]);
456
- });
457
- });
458
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/runAction/index.test.ts"],"names":[],"mappings":""}