-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Travis Fischer <fisch0920@gmail.com>
- Loading branch information
1 parent
98a6a53
commit f013dcb
Showing
94 changed files
with
9,423 additions
and
2,950 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,23 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
test: | ||
name: Test Node.js ${{ matrix.node-version }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
node-version: | ||
- 21 | ||
- 20 | ||
- 18 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'yarn' | ||
- run: yarn install --frozen-lockfile | ||
- run: yarn lint | ||
types: | ||
name: Types | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: 'yarn' | ||
- run: yarn install --frozen-lockfile | ||
- run: yarn typecheck | ||
- run: yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
enable-pre-post-scripts=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
openai-types | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
|
||
/** | ||
* This is used to extract the type declarations from the openai Node.js | ||
* package. Doing this allows it to be a devDependency instead of a dependency, | ||
* which greatly reduces the size of the final bundle. | ||
*/ | ||
function extractTypes(srcDir, destDir) { | ||
if (!fs.existsSync(destDir)) { | ||
fs.mkdirSync(destDir, { recursive: true }); | ||
} | ||
|
||
const entries = fs.readdirSync(srcDir, { withFileTypes: true }); | ||
|
||
for (const entry of entries) { | ||
const srcPath = path.join(srcDir, entry.name); | ||
const destPath = path.join(destDir, entry.name); | ||
|
||
if (entry.isDirectory()) { | ||
extractTypes(srcPath, destPath); | ||
} else if (entry.isFile() && entry.name.endsWith('.d.ts')) { | ||
const depth = Math.max(0, destPath.split('/').length - 2); | ||
const relativePath = depth > 0 ? '../'.repeat(depth) : './'; | ||
|
||
// OpenAI has some absolute package imports, so switch them to use relative imports. | ||
const content = fs | ||
.readFileSync(srcPath, 'utf8') | ||
.replaceAll(/'openai\/([^'.]*)'/g, `'${relativePath}$1.js'`); | ||
fs.writeFileSync(destPath, content); | ||
console.log(destPath); | ||
} | ||
} | ||
} | ||
|
||
extractTypes('node_modules/openai', 'openai-types'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Disclaimer: modules in _shims aren't intended to be imported by SDK users. | ||
*/ | ||
export declare class MultipartBody { | ||
body: any; | ||
constructor(body: any); | ||
get [Symbol.toStringTag](): string; | ||
} | ||
//# sourceMappingURL=MultipartBody.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** | ||
* Disclaimer: modules in _shims aren't intended to be imported by SDK users. | ||
*/ | ||
export * from "../bun-runtime.js"; | ||
//# sourceMappingURL=runtime-bun.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** | ||
* Disclaimer: modules in _shims aren't intended to be imported by SDK users. | ||
*/ | ||
export * from "../node-runtime.js"; | ||
//# sourceMappingURL=runtime-node.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** | ||
* Disclaimer: modules in _shims aren't intended to be imported by SDK users. | ||
*/ | ||
export * from "../web-runtime.js"; | ||
//# sourceMappingURL=runtime.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** | ||
* Disclaimer: modules in _shims aren't intended to be imported by SDK users. | ||
*/ | ||
export * from "../node-types.js"; | ||
//# sourceMappingURL=types-node.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/** | ||
* Disclaimer: modules in _shims aren't intended to be imported by SDK users. | ||
*/ | ||
export type Agent = any; | ||
|
||
// @ts-ignore | ||
declare const _fetch: unknown extends typeof fetch ? never : typeof fetch; | ||
export { _fetch as fetch }; | ||
|
||
// @ts-ignore | ||
type _Request = unknown extends Request ? never : Request; | ||
export { _Request as Request }; | ||
|
||
// @ts-ignore | ||
type _RequestInfo = unknown extends RequestInfo ? never : RequestInfo; | ||
export { type _RequestInfo as RequestInfo }; | ||
|
||
// @ts-ignore | ||
type _RequestInit = unknown extends RequestInit ? never : RequestInit; | ||
export { type _RequestInit as RequestInit }; | ||
|
||
// @ts-ignore | ||
type _Response = unknown extends Response ? never : Response; | ||
export { _Response as Response }; | ||
|
||
// @ts-ignore | ||
type _ResponseInit = unknown extends ResponseInit ? never : ResponseInit; | ||
export { type _ResponseInit as ResponseInit }; | ||
|
||
// @ts-ignore | ||
type _ResponseType = unknown extends ResponseType ? never : ResponseType; | ||
export { type _ResponseType as ResponseType }; | ||
|
||
// @ts-ignore | ||
type _BodyInit = unknown extends BodyInit ? never : BodyInit; | ||
export { type _BodyInit as BodyInit }; | ||
|
||
// @ts-ignore | ||
type _Headers = unknown extends Headers ? never : Headers; | ||
export { _Headers as Headers }; | ||
|
||
// @ts-ignore | ||
type _HeadersInit = unknown extends HeadersInit ? never : HeadersInit; | ||
export { type _HeadersInit as HeadersInit }; | ||
|
||
type EndingType = 'native' | 'transparent'; | ||
|
||
export interface BlobPropertyBag { | ||
endings?: EndingType; | ||
type?: string; | ||
} | ||
|
||
export interface FilePropertyBag extends BlobPropertyBag { | ||
lastModified?: number; | ||
} | ||
|
||
export type FileFromPathOptions = Omit<FilePropertyBag, 'lastModified'>; | ||
|
||
// @ts-ignore | ||
type _FormData = unknown extends FormData ? never : FormData; | ||
// @ts-ignore | ||
declare const _FormData: unknown extends typeof FormData ? never : typeof FormData; | ||
export { _FormData as FormData }; | ||
|
||
// @ts-ignore | ||
type _File = unknown extends File ? never : File; | ||
// @ts-ignore | ||
declare const _File: unknown extends typeof File ? never : typeof File; | ||
export { _File as File }; | ||
|
||
// @ts-ignore | ||
type _Blob = unknown extends Blob ? never : Blob; | ||
// @ts-ignore | ||
declare const _Blob: unknown extends typeof Blob ? never : typeof Blob; | ||
export { _Blob as Blob }; | ||
|
||
export declare class Readable { | ||
readable: boolean; | ||
readonly readableEnded: boolean; | ||
readonly readableFlowing: boolean | null; | ||
readonly readableHighWaterMark: number; | ||
readonly readableLength: number; | ||
readonly readableObjectMode: boolean; | ||
destroyed: boolean; | ||
read(size?: number): any; | ||
pause(): this; | ||
resume(): this; | ||
isPaused(): boolean; | ||
destroy(error?: Error): this; | ||
[Symbol.asyncIterator](): AsyncIterableIterator<any>; | ||
} | ||
|
||
export declare class FsReadStream extends Readable { | ||
path: {}; // node type is string | Buffer | ||
} | ||
|
||
// @ts-ignore | ||
type _ReadableStream<R = any> = unknown extends ReadableStream<R> ? never : ReadableStream<R>; | ||
// @ts-ignore | ||
declare const _ReadableStream: unknown extends typeof ReadableStream ? never : typeof ReadableStream; | ||
export { _ReadableStream as ReadableStream }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Disclaimer: modules in _shims aren't intended to be imported by SDK users. | ||
*/ | ||
import { type Shims } from "./registry.js"; | ||
export declare function getRuntime(): Shims; | ||
//# sourceMappingURL=bun-runtime.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* Disclaimer: modules in _shims aren't intended to be imported by SDK users. | ||
*/ | ||
import { manual } from "./manual-types.js"; | ||
import * as auto from '../_shims/auto/types.js'; | ||
import { type RequestOptions } from "../core.js"; | ||
|
||
type SelectType<Manual, Auto> = unknown extends Manual ? Auto : Manual; | ||
|
||
export const kind: string; | ||
|
||
// @ts-ignore | ||
export type Agent = SelectType<manual.Agent, auto.Agent>; | ||
|
||
// @ts-ignore | ||
export const fetch: SelectType<typeof manual.fetch, typeof auto.fetch>; | ||
|
||
// @ts-ignore | ||
export type Request = SelectType<manual.Request, auto.Request>; | ||
// @ts-ignore | ||
export type RequestInfo = SelectType<manual.RequestInfo, auto.RequestInfo>; | ||
// @ts-ignore | ||
export type RequestInit = SelectType<manual.RequestInit, auto.RequestInit>; | ||
|
||
// @ts-ignore | ||
export type Response = SelectType<manual.Response, auto.Response>; | ||
// @ts-ignore | ||
export type ResponseInit = SelectType<manual.ResponseInit, auto.ResponseInit>; | ||
// @ts-ignore | ||
export type ResponseType = SelectType<manual.ResponseType, auto.ResponseType>; | ||
// @ts-ignore | ||
export type BodyInit = SelectType<manual.BodyInit, auto.BodyInit>; | ||
// @ts-ignore | ||
export type Headers = SelectType<manual.Headers, auto.Headers>; | ||
// @ts-ignore | ||
export const Headers: SelectType<typeof manual.Headers, typeof auto.Headers>; | ||
// @ts-ignore | ||
export type HeadersInit = SelectType<manual.HeadersInit, auto.HeadersInit>; | ||
|
||
// @ts-ignore | ||
export type BlobPropertyBag = SelectType<manual.BlobPropertyBag, auto.BlobPropertyBag>; | ||
// @ts-ignore | ||
export type FilePropertyBag = SelectType<manual.FilePropertyBag, auto.FilePropertyBag>; | ||
// @ts-ignore | ||
export type FileFromPathOptions = SelectType<manual.FileFromPathOptions, auto.FileFromPathOptions>; | ||
// @ts-ignore | ||
export type FormData = SelectType<manual.FormData, auto.FormData>; | ||
// @ts-ignore | ||
export const FormData: SelectType<typeof manual.FormData, typeof auto.FormData>; | ||
// @ts-ignore | ||
export type File = SelectType<manual.File, auto.File>; | ||
// @ts-ignore | ||
export const File: SelectType<typeof manual.File, typeof auto.File>; | ||
// @ts-ignore | ||
export type Blob = SelectType<manual.Blob, auto.Blob>; | ||
// @ts-ignore | ||
export const Blob: SelectType<typeof manual.Blob, typeof auto.Blob>; | ||
|
||
// @ts-ignore | ||
export type Readable = SelectType<manual.Readable, auto.Readable>; | ||
// @ts-ignore | ||
export type FsReadStream = SelectType<manual.FsReadStream, auto.FsReadStream>; | ||
// @ts-ignore | ||
export type ReadableStream = SelectType<manual.ReadableStream, auto.ReadableStream>; | ||
// @ts-ignore | ||
export const ReadableStream: SelectType<typeof manual.ReadableStream, typeof auto.ReadableStream>; | ||
|
||
export function getMultipartRequestOptions<T extends {} = Record<string, unknown>>( | ||
form: FormData, | ||
opts: RequestOptions<T>, | ||
): Promise<RequestOptions<T>>; | ||
|
||
export function getDefaultAgent(url: string): any; | ||
|
||
// @ts-ignore | ||
export type FileFromPathOptions = SelectType<manual.FileFromPathOptions, auto.FileFromPathOptions>; | ||
|
||
export function fileFromPath(path: string, options?: FileFromPathOptions): Promise<File>; | ||
export function fileFromPath(path: string, filename?: string, options?: FileFromPathOptions): Promise<File>; | ||
|
||
export function isFsReadStream(value: any): value is FsReadStream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Disclaimer: modules in _shims aren't intended to be imported by SDK users. | ||
*/ | ||
/** | ||
* Types will get added to this namespace when you import one of the following: | ||
* | ||
* import '../shims/node.js' | ||
* import '../shims/web.js' | ||
* | ||
* Importing more than one will cause type and runtime errors. | ||
*/ | ||
export namespace manual {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { type Shims } from "./registry.js"; | ||
export declare function getRuntime(): Shims; | ||
//# sourceMappingURL=node-runtime.d.ts.map |
Oops, something went wrong.