@zapier/zapier-sdk 0.33.0 → 0.33.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 (128) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.cjs +2 -1
  3. package/dist/index.d.mts +9 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.mjs +2 -1
  7. package/dist/plugins/registry/index.d.ts.map +1 -1
  8. package/dist/plugins/registry/index.js +1 -0
  9. package/dist/types/sdk.d.ts +8 -0
  10. package/dist/types/sdk.d.ts.map +1 -1
  11. package/package.json +2 -2
  12. package/dist/api/auth.test.d.ts +0 -2
  13. package/dist/api/auth.test.d.ts.map +0 -1
  14. package/dist/api/auth.test.js +0 -220
  15. package/dist/api/client.test.d.ts +0 -2
  16. package/dist/api/client.test.d.ts.map +0 -1
  17. package/dist/api/client.test.js +0 -611
  18. package/dist/api/debug.test.d.ts +0 -2
  19. package/dist/api/debug.test.d.ts.map +0 -1
  20. package/dist/api/debug.test.js +0 -59
  21. package/dist/api/polling.test.d.ts +0 -2
  22. package/dist/api/polling.test.d.ts.map +0 -1
  23. package/dist/api/polling.test.js +0 -360
  24. package/dist/auth.test.d.ts +0 -2
  25. package/dist/auth.test.d.ts.map +0 -1
  26. package/dist/auth.test.js +0 -480
  27. package/dist/plugins/eventEmission/builders.test.d.ts +0 -2
  28. package/dist/plugins/eventEmission/builders.test.d.ts.map +0 -1
  29. package/dist/plugins/eventEmission/builders.test.js +0 -138
  30. package/dist/plugins/eventEmission/index.test.d.ts +0 -5
  31. package/dist/plugins/eventEmission/index.test.d.ts.map +0 -1
  32. package/dist/plugins/eventEmission/index.test.js +0 -712
  33. package/dist/plugins/eventEmission/transport.test.d.ts +0 -5
  34. package/dist/plugins/eventEmission/transport.test.d.ts.map +0 -1
  35. package/dist/plugins/eventEmission/transport.test.js +0 -164
  36. package/dist/plugins/fetch/index.test.d.ts +0 -2
  37. package/dist/plugins/fetch/index.test.d.ts.map +0 -1
  38. package/dist/plugins/fetch/index.test.js +0 -428
  39. package/dist/plugins/findFirstConnection/index.test.d.ts +0 -2
  40. package/dist/plugins/findFirstConnection/index.test.d.ts.map +0 -1
  41. package/dist/plugins/findFirstConnection/index.test.js +0 -177
  42. package/dist/plugins/findUniqueConnection/index.test.d.ts +0 -2
  43. package/dist/plugins/findUniqueConnection/index.test.d.ts.map +0 -1
  44. package/dist/plugins/findUniqueConnection/index.test.js +0 -159
  45. package/dist/plugins/getAction/index.test.d.ts +0 -2
  46. package/dist/plugins/getAction/index.test.d.ts.map +0 -1
  47. package/dist/plugins/getAction/index.test.js +0 -211
  48. package/dist/plugins/getApp/index.test.d.ts +0 -2
  49. package/dist/plugins/getApp/index.test.d.ts.map +0 -1
  50. package/dist/plugins/getApp/index.test.js +0 -157
  51. package/dist/plugins/getConnection/index.test.d.ts +0 -2
  52. package/dist/plugins/getConnection/index.test.d.ts.map +0 -1
  53. package/dist/plugins/getConnection/index.test.js +0 -124
  54. package/dist/plugins/getInputFieldsSchema/index.test.d.ts +0 -2
  55. package/dist/plugins/getInputFieldsSchema/index.test.d.ts.map +0 -1
  56. package/dist/plugins/getInputFieldsSchema/index.test.js +0 -291
  57. package/dist/plugins/listActions/index.test.d.ts +0 -2
  58. package/dist/plugins/listActions/index.test.d.ts.map +0 -1
  59. package/dist/plugins/listActions/index.test.js +0 -454
  60. package/dist/plugins/listApps/index.test.d.ts +0 -2
  61. package/dist/plugins/listApps/index.test.d.ts.map +0 -1
  62. package/dist/plugins/listApps/index.test.js +0 -124
  63. package/dist/plugins/listConnections/index.test.d.ts +0 -2
  64. package/dist/plugins/listConnections/index.test.d.ts.map +0 -1
  65. package/dist/plugins/listConnections/index.test.js +0 -920
  66. package/dist/plugins/listInputFieldChoices/index.test.d.ts +0 -2
  67. package/dist/plugins/listInputFieldChoices/index.test.d.ts.map +0 -1
  68. package/dist/plugins/listInputFieldChoices/index.test.js +0 -717
  69. package/dist/plugins/listInputFields/index.test.d.ts +0 -2
  70. package/dist/plugins/listInputFields/index.test.d.ts.map +0 -1
  71. package/dist/plugins/listInputFields/index.test.js +0 -359
  72. package/dist/plugins/manifest/index.test.d.ts +0 -2
  73. package/dist/plugins/manifest/index.test.d.ts.map +0 -1
  74. package/dist/plugins/manifest/index.test.js +0 -1179
  75. package/dist/plugins/request/index.test.d.ts +0 -2
  76. package/dist/plugins/request/index.test.d.ts.map +0 -1
  77. package/dist/plugins/request/index.test.js +0 -458
  78. package/dist/plugins/runAction/index.test.d.ts +0 -2
  79. package/dist/plugins/runAction/index.test.d.ts.map +0 -1
  80. package/dist/plugins/runAction/index.test.js +0 -350
  81. package/dist/resolvers/connectionId.test.d.ts +0 -2
  82. package/dist/resolvers/connectionId.test.d.ts.map +0 -1
  83. package/dist/resolvers/connectionId.test.js +0 -61
  84. package/dist/sdk.test.d.ts +0 -2
  85. package/dist/sdk.test.d.ts.map +0 -1
  86. package/dist/sdk.test.js +0 -260
  87. package/dist/types/domain.test.d.ts +0 -2
  88. package/dist/types/domain.test.d.ts.map +0 -1
  89. package/dist/types/domain.test.js +0 -39
  90. package/dist/utils/array-utils.test.d.ts +0 -2
  91. package/dist/utils/array-utils.test.d.ts.map +0 -1
  92. package/dist/utils/array-utils.test.js +0 -107
  93. package/dist/utils/batch-utils.test.d.ts +0 -2
  94. package/dist/utils/batch-utils.test.d.ts.map +0 -1
  95. package/dist/utils/batch-utils.test.js +0 -476
  96. package/dist/utils/domain-utils.test.d.ts +0 -2
  97. package/dist/utils/domain-utils.test.d.ts.map +0 -1
  98. package/dist/utils/domain-utils.test.js +0 -346
  99. package/dist/utils/file-utils.test.d.ts +0 -2
  100. package/dist/utils/file-utils.test.d.ts.map +0 -1
  101. package/dist/utils/file-utils.test.js +0 -51
  102. package/dist/utils/function-utils.test.d.ts +0 -2
  103. package/dist/utils/function-utils.test.d.ts.map +0 -1
  104. package/dist/utils/function-utils.test.js +0 -188
  105. package/dist/utils/id-utils.test.d.ts +0 -2
  106. package/dist/utils/id-utils.test.d.ts.map +0 -1
  107. package/dist/utils/id-utils.test.js +0 -22
  108. package/dist/utils/pagination-utils.test.d.ts +0 -17
  109. package/dist/utils/pagination-utils.test.d.ts.map +0 -1
  110. package/dist/utils/pagination-utils.test.js +0 -461
  111. package/dist/utils/retry-utils.test.d.ts +0 -2
  112. package/dist/utils/retry-utils.test.d.ts.map +0 -1
  113. package/dist/utils/retry-utils.test.js +0 -90
  114. package/dist/utils/string-utils.test.d.ts +0 -2
  115. package/dist/utils/string-utils.test.d.ts.map +0 -1
  116. package/dist/utils/string-utils.test.js +0 -59
  117. package/dist/utils/telemetry-context.test.d.ts +0 -2
  118. package/dist/utils/telemetry-context.test.d.ts.map +0 -1
  119. package/dist/utils/telemetry-context.test.js +0 -154
  120. package/dist/utils/telemetry-utils.test.d.ts +0 -2
  121. package/dist/utils/telemetry-utils.test.d.ts.map +0 -1
  122. package/dist/utils/telemetry-utils.test.js +0 -155
  123. package/dist/utils/url-utils.test.d.ts +0 -2
  124. package/dist/utils/url-utils.test.d.ts.map +0 -1
  125. package/dist/utils/url-utils.test.js +0 -103
  126. package/dist/utils/validation.test.d.ts +0 -2
  127. package/dist/utils/validation.test.d.ts.map +0 -1
  128. 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":""}