Skip to content

Commit 1acf5c1

Browse files
committed
fix: tests
1 parent 72ceaa6 commit 1acf5c1

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

src/APIClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
UnifiedResponse,
1111
} from './types';
1212
import { AI21EnvConfig } from './EnvConfig';
13-
import { createFetchInstance } from 'envFetch';
13+
import { createFetchInstance } from './runtime';
1414
import { Fetch } from 'fetch';
1515

1616
const validatePositiveInteger = (name: string, n: unknown): number => {

src/Streaming/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { Stream } from './Stream';
2+
export { BrowserSSEDecoder, NodeSSEDecoder, SSEDecoder } from './SSEDecoder';

src/fetch/BaseFetch.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { AI21Error } from 'errors';
2-
import { Stream } from 'Streaming';
3-
import { FinalRequestOptions, UnifiedResponse } from 'types';
4-
import { APIResponseProps } from 'types/API';
1+
import { AI21Error } from '../errors';
2+
import { Stream } from '../Streaming';
3+
import { FinalRequestOptions, UnifiedResponse } from '../types';
4+
import { APIResponseProps } from '../types/API';
55

66
export type APIResponse<T> = {
77
data?: T;

src/fetch/BrowserFetch.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { FinalRequestOptions, UnifiedResponse } from 'types';
22
import { Fetch } from './BaseFetch';
3-
import { Stream } from 'Streaming';
4-
import { BrowserSSEDecoder } from 'Streaming/SSEDecoder';
3+
import { Stream, BrowserSSEDecoder } from '../Streaming';
54

65
export class BrowserFetch extends Fetch {
76
call(url: string, options: FinalRequestOptions): Promise<UnifiedResponse> {

src/fetch/NodeFetch.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { FinalRequestOptions, UnifiedResponse } from 'types';
22
import { Fetch } from './BaseFetch';
3-
import { NodeSSEDecoder } from 'Streaming/SSEDecoder';
4-
import { Stream } from 'Streaming';
3+
import { Stream, NodeSSEDecoder } from '../Streaming';
54

65
export class NodeFetch extends Fetch {
76
async call(url: string, options: FinalRequestOptions): Promise<UnifiedResponse> {

src/envFetch.ts renamed to src/runtime.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
import { BrowserFetch, Fetch, NodeFetch } from 'fetch';
1+
import { BrowserFetch, Fetch, NodeFetch } from './fetch';
2+
23

34
export const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
5+
6+
/**
7+
* A Web Worker is a background thread that runs JavaScript code separate from the main thread.
8+
* Web Workers enable concurrent processing by:
9+
* - Running CPU-intensive tasks without blocking the UI
10+
* - Performing background operations like data fetching and processing
11+
* - Operating independently from the main window context
12+
*/
413
export const isWebWorker =
514
typeof self === 'object' &&
615
typeof self?.importScripts === 'function' &&
@@ -14,7 +23,7 @@ export const isNode =
1423
export function createFetchInstance(): Fetch {
1524
if (isBrowser || isWebWorker) {
1625
return new BrowserFetch();
17-
} else {
18-
return new NodeFetch();
1926
}
27+
28+
return new NodeFetch();
2029
}

0 commit comments

Comments
 (0)