@ai-sdk/gateway 3.0.21 → 3.0.22
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.
- package/CHANGELOG.md +9 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +8 -4
- package/src/errors/create-gateway-error.test.ts +0 -590
- package/src/errors/extract-api-call-response.test.ts +0 -270
- package/src/errors/gateway-error-types.test.ts +0 -278
- package/src/errors/parse-auth-method.test.ts +0 -136
- package/src/gateway-embedding-model.test.ts +0 -213
- package/src/gateway-fetch-metadata.test.ts +0 -774
- package/src/gateway-image-model.test.ts +0 -823
- package/src/gateway-language-model.test.ts +0 -1485
- package/src/gateway-provider.test.ts +0 -1210
- package/src/vercel-environment.test.ts +0 -65
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
-
import { getVercelOidcToken, getVercelRequestId } from './vercel-environment';
|
|
3
|
-
|
|
4
|
-
const SYMBOL_FOR_REQ_CONTEXT = Symbol.for('@vercel/request-context');
|
|
5
|
-
|
|
6
|
-
describe('getVercelRequestId', () => {
|
|
7
|
-
const originalSymbolValue = (globalThis as any)[SYMBOL_FOR_REQ_CONTEXT];
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
(globalThis as any)[SYMBOL_FOR_REQ_CONTEXT] = undefined;
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
afterEach(() => {
|
|
14
|
-
if (originalSymbolValue) {
|
|
15
|
-
(globalThis as any)[SYMBOL_FOR_REQ_CONTEXT] = originalSymbolValue;
|
|
16
|
-
} else {
|
|
17
|
-
(globalThis as any)[SYMBOL_FOR_REQ_CONTEXT] = undefined;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('should get request ID from request headers when available', async () => {
|
|
22
|
-
(globalThis as any)[SYMBOL_FOR_REQ_CONTEXT] = {
|
|
23
|
-
get: () => ({
|
|
24
|
-
headers: {
|
|
25
|
-
'x-vercel-id': 'req_1234567890abcdef',
|
|
26
|
-
},
|
|
27
|
-
}),
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const requestId = await getVercelRequestId();
|
|
31
|
-
expect(requestId).toBe('req_1234567890abcdef');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should return undefined when request ID header is not available', async () => {
|
|
35
|
-
(globalThis as any)[SYMBOL_FOR_REQ_CONTEXT] = {
|
|
36
|
-
get: () => ({ headers: {} }),
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const requestId = await getVercelRequestId();
|
|
40
|
-
expect(requestId).toBeUndefined();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should return undefined when no headers are available', async () => {
|
|
44
|
-
(globalThis as any)[SYMBOL_FOR_REQ_CONTEXT] = {
|
|
45
|
-
get: () => ({}),
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const requestId = await getVercelRequestId();
|
|
49
|
-
expect(requestId).toBeUndefined();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('should handle missing request context gracefully', async () => {
|
|
53
|
-
(globalThis as any)[SYMBOL_FOR_REQ_CONTEXT] = undefined;
|
|
54
|
-
|
|
55
|
-
const requestId = await getVercelRequestId();
|
|
56
|
-
expect(requestId).toBeUndefined();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should handle missing get method in request context', async () => {
|
|
60
|
-
(globalThis as any)[SYMBOL_FOR_REQ_CONTEXT] = {};
|
|
61
|
-
|
|
62
|
-
const requestId = await getVercelRequestId();
|
|
63
|
-
expect(requestId).toBeUndefined();
|
|
64
|
-
});
|
|
65
|
-
});
|