@mapbox/mcp-server 0.2.0-issue.11.1 → 0.2.0

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 (33) hide show
  1. package/README.md +4 -82
  2. package/dist/index.js +0 -0
  3. package/dist/tools/directions-tool/DirectionsTool.d.ts +32 -7
  4. package/dist/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
  5. package/dist/tools/directions-tool/DirectionsTool.js +61 -37
  6. package/dist/tools/directions-tool/DirectionsTool.js.map +1 -1
  7. package/dist/tools/directions-tool/DirectionsTool.test.js +257 -208
  8. package/dist/tools/directions-tool/DirectionsTool.test.js.map +1 -1
  9. package/dist/utils/requestUtils.d.ts.map +1 -1
  10. package/dist/utils/requestUtils.js +2 -23
  11. package/dist/utils/requestUtils.js.map +1 -1
  12. package/dist/version.json +4 -4
  13. package/package.json +2 -2
  14. package/dist/tools/directions-tool/cleanResponseData.d.ts +0 -11
  15. package/dist/tools/directions-tool/cleanResponseData.d.ts.map +0 -1
  16. package/dist/tools/directions-tool/cleanResponseData.js +0 -175
  17. package/dist/tools/directions-tool/cleanResponseData.js.map +0 -1
  18. package/dist/tools/directions-tool/cleanResponseData.test.d.ts +0 -2
  19. package/dist/tools/directions-tool/cleanResponseData.test.d.ts.map +0 -1
  20. package/dist/tools/directions-tool/cleanResponseData.test.js +0 -295
  21. package/dist/tools/directions-tool/cleanResponseData.test.js.map +0 -1
  22. package/dist/tools/directions-tool/formatIsoDateTime.d.ts +0 -8
  23. package/dist/tools/directions-tool/formatIsoDateTime.d.ts.map +0 -1
  24. package/dist/tools/directions-tool/formatIsoDateTime.js +0 -17
  25. package/dist/tools/directions-tool/formatIsoDateTime.js.map +0 -1
  26. package/dist/tools/directions-tool/formatIsoDateTime.test.d.ts +0 -2
  27. package/dist/tools/directions-tool/formatIsoDateTime.test.d.ts.map +0 -1
  28. package/dist/tools/directions-tool/formatIsoDateTime.test.js +0 -26
  29. package/dist/tools/directions-tool/formatIsoDateTime.test.js.map +0 -1
  30. package/dist/utils/requestUtils.test.d.ts +0 -2
  31. package/dist/utils/requestUtils.test.d.ts.map +0 -1
  32. package/dist/utils/requestUtils.test.js +0 -114
  33. package/dist/utils/requestUtils.test.js.map +0 -1
@@ -1,295 +0,0 @@
1
- import { cleanResponseData } from './cleanResponseData.js';
2
- describe('cleanResponseData', () => {
3
- // Create a complete mock input that satisfies the DirectionsInputSchema
4
- const mockInput = {
5
- coordinates: [
6
- [0, 0],
7
- [1, 1]
8
- ], // Use a proper tuple type
9
- routing_profile: 'driving-traffic',
10
- geometries: 'none',
11
- alternatives: false
12
- };
13
- it('should remove unnecessary keys', () => {
14
- const mockData = {
15
- uuid: '12345',
16
- code: 'Ok',
17
- routes: []
18
- };
19
- const result = cleanResponseData(mockInput, mockData);
20
- expect(result.uuid).toBeUndefined();
21
- expect(result.code).toBeUndefined();
22
- });
23
- it('should rename waypoint location and distance properties', () => {
24
- const mockData = {
25
- waypoints: [
26
- {
27
- name: 'Test',
28
- location: [-73.989, 40.733],
29
- distance: 10.5
30
- }
31
- ],
32
- routes: []
33
- };
34
- const result = cleanResponseData(mockInput, mockData);
35
- expect(result.waypoints[0].location).toBeUndefined();
36
- expect(result.waypoints[0].snap_location).toEqual([-73.989, 40.733]);
37
- expect(result.waypoints[0].distance).toBeUndefined();
38
- expect(result.waypoints[0].snap_distance).toBe(11); // Rounded from 10.5
39
- });
40
- it('should round duration and distance', () => {
41
- const mockData = {
42
- routes: [
43
- {
44
- duration: 1234.56,
45
- distance: 5678.91,
46
- legs: []
47
- }
48
- ]
49
- };
50
- const result = cleanResponseData(mockInput, mockData);
51
- expect(result.routes[0].duration).toBe(1235);
52
- expect(result.routes[0].distance).toBe(5679);
53
- });
54
- it('should delete geometry when geometries is set to none', () => {
55
- const mockData = {
56
- routes: [
57
- {
58
- geometry: 'someGeometryData',
59
- legs: []
60
- }
61
- ]
62
- };
63
- const result = cleanResponseData(mockInput, mockData);
64
- expect(result.routes[0].geometry).toBeUndefined();
65
- });
66
- it('should keep geometry when geometries is not none', () => {
67
- const mockData = {
68
- routes: [
69
- {
70
- geometry: 'someGeometryData',
71
- legs: []
72
- }
73
- ]
74
- };
75
- // Override just the geometries property for this test
76
- const geojsonInput = {
77
- ...mockInput,
78
- geometries: 'geojson'
79
- };
80
- const result = cleanResponseData(geojsonInput, mockData);
81
- expect(result.routes[0].geometry).toBe('someGeometryData');
82
- });
83
- it('should process route data correctly', () => {
84
- const mockData = {
85
- routes: [
86
- {
87
- duration: 1200,
88
- distance: 5000,
89
- weight_name: 'routingWeight',
90
- weight: 1500,
91
- duration_typical: 1300,
92
- weight_typical: 1600,
93
- legs: [
94
- {
95
- summary: 'First leg summary',
96
- admins: [{ iso_3166_1_alpha3: 'USA' }],
97
- steps: []
98
- },
99
- {
100
- summary: 'Second leg summary',
101
- admins: [{ iso_3166_1_alpha3: 'CAN' }],
102
- steps: []
103
- }
104
- ]
105
- }
106
- ]
107
- };
108
- const result = cleanResponseData(mockInput, mockData);
109
- // Check if data is properly processed
110
- expect(result.routes[0].weight_name).toBeUndefined();
111
- expect(result.routes[0].weight).toBeUndefined();
112
- expect(result.routes[0].leg_summaries).toEqual([
113
- 'First leg summary',
114
- 'Second leg summary'
115
- ]);
116
- expect(result.routes[0].duration_typical).toBeUndefined();
117
- expect(result.routes[0].duration_under_typical_traffic_conditions).toBe(1300);
118
- expect(result.routes[0].weight_typical).toBeUndefined();
119
- expect(result.routes[0].intersecting_admins).toEqual(['USA', 'CAN']);
120
- expect(result.routes[0].num_legs).toBe(2);
121
- expect(result.routes[0].legs).toBeUndefined();
122
- });
123
- it('should handle notifications and collect unique messages', () => {
124
- const mockData = {
125
- routes: [
126
- {
127
- legs: [
128
- {
129
- notifications: [
130
- { details: { message: 'Traffic ahead' } },
131
- { details: { message: 'Road closure' } }
132
- ],
133
- summary: 'Leg 1'
134
- },
135
- {
136
- notifications: [
137
- { details: { message: 'Traffic ahead' } },
138
- { details: { message: 'Construction zone' } }
139
- ],
140
- summary: 'Leg 2'
141
- }
142
- ]
143
- }
144
- ]
145
- };
146
- const result = cleanResponseData(mockInput, mockData);
147
- expect(result.routes[0].notifications_summary).toEqual([
148
- 'Traffic ahead',
149
- 'Road closure',
150
- 'Construction zone'
151
- ]);
152
- });
153
- it('should process incidents information', () => {
154
- const mockData = {
155
- routes: [
156
- {
157
- legs: [
158
- {
159
- incidents: [
160
- {
161
- type: 'accident',
162
- end_time: '2023-05-01T12:00:00Z',
163
- long_description: 'Multiple vehicle collision',
164
- impact: 'severe',
165
- affected_road_names: ['Main St'],
166
- length: 500,
167
- extra_field: 'should not be included'
168
- }
169
- ],
170
- summary: 'Leg with incident'
171
- }
172
- ]
173
- }
174
- ]
175
- };
176
- const result = cleanResponseData(mockInput, mockData);
177
- expect(result.routes[0].incidents_summary).toHaveLength(1);
178
- expect(result.routes[0].incidents_summary[0]).toEqual({
179
- type: 'accident',
180
- end_time: '2023-05-01T12:00:00Z',
181
- long_description: 'Multiple vehicle collision',
182
- impact: 'severe',
183
- affected_road_names: ['Main St'],
184
- length: 500
185
- });
186
- expect(result.routes[0].incidents_summary[0].extra_field).toBeUndefined();
187
- });
188
- it('should collect voice instructions when within limits', () => {
189
- const mockData = {
190
- routes: [
191
- {
192
- legs: [
193
- {
194
- steps: [
195
- {
196
- voiceInstructions: [
197
- { announcement: 'Turn right in 100 meters' },
198
- { announcement: 'Turn right now' }
199
- ]
200
- },
201
- {
202
- voiceInstructions: [
203
- { announcement: 'Continue straight for 500 meters' }
204
- ]
205
- }
206
- ],
207
- summary: 'Leg with voice instructions'
208
- }
209
- ]
210
- }
211
- ]
212
- };
213
- const result = cleanResponseData(mockInput, mockData);
214
- expect(result.routes[0].instructions).toEqual([
215
- 'Turn right in 100 meters',
216
- 'Turn right now',
217
- 'Continue straight for 500 meters'
218
- ]);
219
- });
220
- it('should not include instructions when there are too many', () => {
221
- const mockData = {
222
- routes: [
223
- {
224
- legs: [
225
- {
226
- steps: Array(6)
227
- .fill(0)
228
- .map(() => ({
229
- voiceInstructions: [
230
- { announcement: 'Instruction 1' },
231
- { announcement: 'Instruction 2' }
232
- ]
233
- })),
234
- summary: 'Leg with many instructions'
235
- }
236
- ]
237
- }
238
- ]
239
- };
240
- const result = cleanResponseData(mockInput, mockData);
241
- // With 6 steps and 2 instructions each, we'd have 12 instructions total
242
- // The function should exclude them since it's > 10
243
- expect(result.routes[0].instructions).toBeUndefined();
244
- });
245
- it('should calculate congestion information correctly', () => {
246
- const mockData = {
247
- routes: [
248
- {
249
- legs: [
250
- {
251
- annotation: {
252
- congestion: ['severe', 'heavy', 'moderate', 'low', 'unknown'],
253
- distance: [100, 200, 300, 400, 500]
254
- },
255
- summary: 'Leg with congestion'
256
- }
257
- ]
258
- }
259
- ]
260
- };
261
- const result = cleanResponseData(mockInput, mockData);
262
- expect(result.routes[0].congestion_information).toEqual({
263
- length_severe: 100,
264
- length_heavy: 200,
265
- length_moderate: 300,
266
- length_low: 400
267
- });
268
- // Note: 'unknown' congestion type is skipped
269
- });
270
- it('should calculate average speed correctly', () => {
271
- const mockData = {
272
- routes: [
273
- {
274
- legs: [
275
- {
276
- annotation: {
277
- speed: [10, 20, 30], // m/s
278
- distance: [100, 200, 300] // meters
279
- },
280
- summary: 'Leg with speed data'
281
- }
282
- ]
283
- }
284
- ]
285
- };
286
- const result = cleanResponseData(mockInput, mockData);
287
- // Calculation:
288
- // Weighted sum = 10*100 + 20*200 + 30*300 = 1000 + 4000 + 9000 = 14000
289
- // Total distance = 100 + 200 + 300 = 600
290
- // Average m/s = 14000/600 = 23.33
291
- // Average km/h = 23.33 * 3.6 = 84 (rounded)
292
- expect(result.routes[0].average_speed_kph).toBe(84);
293
- });
294
- });
295
- //# sourceMappingURL=cleanResponseData.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cleanResponseData.test.js","sourceRoot":"","sources":["../../../src/tools/directions-tool/cleanResponseData.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE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BAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAEtD,eAAe;QACf,uEAAuE;QACvE,yCAAyC;QACzC,kCAAkC;QAClC,4CAA4C;QAC5C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Helper function to format ISO datetime strings according to Mapbox API requirements.
3
- * It converts the format YYYY-MM-DDThh:mm:ss (with seconds but no timezone) to
4
- * YYYY-MM-DDThh:mm (no seconds, no timezone) by removing the seconds part.
5
- * Other valid formats are left unchanged.
6
- */
7
- export declare const formatIsoDateTime: (dateTime: string) => string;
8
- //# sourceMappingURL=formatIsoDateTime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatIsoDateTime.d.ts","sourceRoot":"","sources":["../../../src/tools/directions-tool/formatIsoDateTime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,KAAG,MAWpD,CAAC"}
@@ -1,17 +0,0 @@
1
- /**
2
- * Helper function to format ISO datetime strings according to Mapbox API requirements.
3
- * It converts the format YYYY-MM-DDThh:mm:ss (with seconds but no timezone) to
4
- * YYYY-MM-DDThh:mm (no seconds, no timezone) by removing the seconds part.
5
- * Other valid formats are left unchanged.
6
- */
7
- export const formatIsoDateTime = (dateTime) => {
8
- // Regex for matching YYYY-MM-DDThh:mm:ss format (with seconds but no timezone)
9
- const dateWithSecondsNoTz = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/;
10
- if (dateWithSecondsNoTz.test(dateTime)) {
11
- // Extract up to the minutes part only, dropping the seconds
12
- return dateTime.substring(0, dateTime.lastIndexOf(':'));
13
- }
14
- // Return unchanged if it's already in a valid format
15
- return dateTime;
16
- };
17
- //# sourceMappingURL=formatIsoDateTime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatIsoDateTime.js","sourceRoot":"","sources":["../../../src/tools/directions-tool/formatIsoDateTime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAU,EAAE;IAC5D,+EAA+E;IAC/E,MAAM,mBAAmB,GAAG,uCAAuC,CAAC;IAEpE,IAAI,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACvC,4DAA4D;QAC5D,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,qDAAqD;IACrD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=formatIsoDateTime.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatIsoDateTime.test.d.ts","sourceRoot":"","sources":["../../../src/tools/directions-tool/formatIsoDateTime.test.ts"],"names":[],"mappings":""}
@@ -1,26 +0,0 @@
1
- import { formatIsoDateTime } from './formatIsoDateTime';
2
- describe('formatIsoDateTime', () => {
3
- it('converts YYYY-MM-DDThh:mm:ss to YYYY-MM-DDThh:mm by removing seconds', () => {
4
- const input = '2025-06-05T10:30:45';
5
- const expected = '2025-06-05T10:30';
6
- expect(formatIsoDateTime(input)).toBe(expected);
7
- });
8
- it('leaves YYYY-MM-DDThh:mm:ssZ format unchanged', () => {
9
- const input = '2025-06-05T10:30:45Z';
10
- expect(formatIsoDateTime(input)).toBe(input);
11
- });
12
- it('leaves YYYY-MM-DDThh:mm:ss±hh:mm format unchanged', () => {
13
- const input = '2025-06-05T10:30:45+02:00';
14
- expect(formatIsoDateTime(input)).toBe(input);
15
- });
16
- it('leaves YYYY-MM-DDThh:mm format unchanged', () => {
17
- const input = '2025-06-05T10:30';
18
- expect(formatIsoDateTime(input)).toBe(input);
19
- });
20
- it('handles edge cases with zeros in seconds', () => {
21
- const input = '2025-06-05T10:30:00';
22
- const expected = '2025-06-05T10:30';
23
- expect(formatIsoDateTime(input)).toBe(expected);
24
- });
25
- });
26
- //# sourceMappingURL=formatIsoDateTime.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatIsoDateTime.test.js","sourceRoot":"","sources":["../../../src/tools/directions-tool/formatIsoDateTime.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,sEAAsE,EAAE,GAAG,EAAE;QAC9E,MAAM,KAAK,GAAG,qBAAqB,CAAC;QACpC,MAAM,QAAQ,GAAG,kBAAkB,CAAC;QAEpC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,KAAK,GAAG,sBAAsB,CAAC;QAErC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,KAAK,GAAG,2BAA2B,CAAC;QAE1C,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,KAAK,GAAG,kBAAkB,CAAC;QAEjC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,KAAK,GAAG,qBAAqB,CAAC;QACpC,MAAM,QAAQ,GAAG,kBAAkB,CAAC;QAEpC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=requestUtils.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"requestUtils.test.d.ts","sourceRoot":"","sources":["../../src/utils/requestUtils.test.ts"],"names":[],"mappings":""}
@@ -1,114 +0,0 @@
1
- import { patchGlobalFetch, cleanup } from './requestUtils.js';
2
- describe('requestUtils', () => {
3
- let originalGlobalFetch;
4
- beforeEach(() => {
5
- // Save original fetch
6
- originalGlobalFetch = global.fetch;
7
- });
8
- afterEach(() => {
9
- // Restore original fetch
10
- global.fetch = originalGlobalFetch;
11
- cleanup();
12
- });
13
- describe('patchGlobalFetch', () => {
14
- it('should handle case when global.fetch is undefined at module load time', () => {
15
- // Simulate scenario where global.fetch doesn't exist initially
16
- delete global.fetch;
17
- // This should not throw "originalFetch is not a function" error
18
- expect(() => {
19
- patchGlobalFetch({
20
- name: 'TestServer',
21
- version: '1.0.0',
22
- sha: 'abcdef',
23
- tag: 'no-tag',
24
- branch: 'default'
25
- });
26
- }).not.toThrow();
27
- });
28
- it('should properly initialize originalFetch before patching', async () => {
29
- // Mock fetch function
30
- const mockFetch = jest.fn().mockResolvedValue({
31
- ok: true,
32
- status: 200,
33
- json: async () => ({ success: true })
34
- });
35
- global.fetch = mockFetch;
36
- // Patch global fetch
37
- patchGlobalFetch({
38
- name: 'TestServer',
39
- version: '1.0.0',
40
- sha: 'abcdef',
41
- tag: 'no-tag',
42
- branch: 'default'
43
- });
44
- // Make a fetch call
45
- await global.fetch('https://example.com', {
46
- headers: { 'Custom-Header': 'test' }
47
- });
48
- // Verify that the original fetch was called with User-Agent added
49
- expect(mockFetch).toHaveBeenCalledWith('https://example.com', {
50
- headers: {
51
- 'Custom-Header': 'test',
52
- 'User-Agent': 'TestServer/1.0.0 (default, no-tag, abcdef)'
53
- }
54
- });
55
- });
56
- it('should not throw originalFetch is not a function error', async () => {
57
- // Mock a scenario where fetch might be called before proper initialization
58
- const mockFetch = jest.fn().mockResolvedValue({
59
- ok: true,
60
- status: 200,
61
- json: async () => ({ success: true })
62
- });
63
- global.fetch = mockFetch;
64
- patchGlobalFetch({
65
- name: 'TestServer',
66
- version: '1.0.0',
67
- sha: 'abcdef',
68
- tag: 'no-tag',
69
- branch: 'default'
70
- });
71
- // This should not throw "originalFetch is not a function"
72
- await expect(global.fetch('https://example.com')).resolves.toBeDefined();
73
- });
74
- it('should handle multiple patch calls without breaking', () => {
75
- const mockFetch = jest.fn();
76
- global.fetch = mockFetch;
77
- // First patch
78
- patchGlobalFetch({
79
- name: 'TestServer',
80
- version: '1.0.0',
81
- sha: 'abcdef',
82
- tag: 'no-tag',
83
- branch: 'default'
84
- });
85
- // Second patch (should not break)
86
- patchGlobalFetch({
87
- name: 'TestServer2',
88
- version: '2.0.0',
89
- sha: 'abcdef2',
90
- tag: 'v2',
91
- branch: 'main'
92
- });
93
- // Should still work
94
- expect(typeof global.fetch).toBe('function');
95
- });
96
- it('should restore original fetch on cleanup', () => {
97
- const mockFetch = jest.fn();
98
- global.fetch = mockFetch;
99
- patchGlobalFetch({
100
- name: 'TestServer',
101
- version: '1.0.0',
102
- sha: 'abcdef',
103
- tag: 'no-tag',
104
- branch: 'default'
105
- });
106
- // Verify fetch was patched
107
- expect(global.fetch).not.toBe(mockFetch);
108
- // Cleanup should restore original
109
- cleanup();
110
- expect(global.fetch).toBe(mockFetch);
111
- });
112
- });
113
- });
114
- //# sourceMappingURL=requestUtils.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"requestUtils.test.js","sourceRoot":"","sources":["../../src/utils/requestUtils.test.ts"],"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