@lorikeetai/node-sdk 0.1.0-beta.4 → 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.
- package/CHANGELOG.md +40 -0
- package/README.md +11 -11
- package/_shims/MultipartBody.js.map +1 -1
- package/_shims/MultipartBody.mjs.map +1 -1
- package/_shims/auto/runtime-bun.d.ts.map +1 -1
- package/_shims/auto/runtime-bun.js.map +1 -1
- package/_shims/auto/runtime-node.d.ts.map +1 -1
- package/_shims/auto/runtime-node.js.map +1 -1
- package/_shims/auto/runtime.d.ts.map +1 -1
- package/_shims/auto/runtime.js.map +1 -1
- package/_shims/auto/types-node.d.ts.map +1 -1
- package/_shims/auto/types-node.js.map +1 -1
- package/_shims/auto/types.d.ts +52 -52
- package/_shims/bun-runtime.d.ts.map +1 -1
- package/_shims/bun-runtime.js.map +1 -1
- package/_shims/bun-runtime.mjs.map +1 -1
- package/_shims/index.d.ts +36 -36
- package/_shims/index.js +5 -5
- package/_shims/index.mjs +4 -4
- package/_shims/node-runtime.d.ts.map +1 -1
- package/_shims/node-runtime.js.map +1 -1
- package/_shims/node-runtime.mjs.map +1 -1
- package/_shims/node-types.d.ts +27 -27
- package/_shims/registry.d.ts.map +1 -1
- package/_shims/registry.js.map +1 -1
- package/_shims/registry.mjs.map +1 -1
- package/_shims/web-runtime.d.ts.map +1 -1
- package/_shims/web-runtime.js.map +1 -1
- package/_shims/web-runtime.mjs.map +1 -1
- package/_shims/web-types.d.ts +52 -52
- package/core.d.ts.map +1 -1
- package/core.js +0 -1
- package/core.js.map +1 -1
- package/core.mjs +0 -1
- package/core.mjs.map +1 -1
- package/error.d.ts.map +1 -1
- package/error.js.map +1 -1
- package/error.mjs.map +1 -1
- package/index.d.mts +3 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -1
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/index.mjs +3 -0
- package/index.mjs.map +1 -1
- package/lib/generate-signature.js.map +1 -1
- package/lib/generate-signature.mjs.map +1 -1
- package/package.json +1 -1
- package/resource.d.ts.map +1 -1
- package/resource.js.map +1 -1
- package/resource.mjs.map +1 -1
- package/resources/conversation/chat.d.ts +9 -5
- package/resources/conversation/chat.d.ts.map +1 -1
- package/resources/conversation/chat.js +3 -3
- package/resources/conversation/chat.js.map +1 -1
- package/resources/conversation/chat.mjs +3 -3
- package/resources/conversation/chat.mjs.map +1 -1
- package/resources/conversation/conversation.d.ts.map +1 -1
- package/resources/conversation/conversation.js.map +1 -1
- package/resources/conversation/conversation.mjs.map +1 -1
- package/resources/conversation/email.d.ts +6 -2
- package/resources/conversation/email.d.ts.map +1 -1
- package/resources/conversation/email.js +1 -1
- package/resources/conversation/email.js.map +1 -1
- package/resources/conversation/email.mjs +1 -1
- package/resources/conversation/email.mjs.map +1 -1
- package/resources/conversation/index.d.ts.map +1 -1
- package/resources/conversation/index.js.map +1 -1
- package/resources/customer.d.ts +61 -0
- package/resources/customer.d.ts.map +1 -0
- package/resources/customer.js +12 -0
- package/resources/customer.js.map +1 -0
- package/resources/customer.mjs +8 -0
- package/resources/customer.mjs.map +1 -0
- package/resources/index.d.ts +1 -0
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/ingest.d.ts.map +1 -1
- package/resources/ingest.js.map +1 -1
- package/resources/ingest.mjs.map +1 -1
- package/resources/token.d.ts.map +1 -1
- package/resources/token.js.map +1 -1
- package/resources/token.mjs.map +1 -1
- package/shims/node.d.ts.map +1 -1
- package/shims/node.js.map +1 -1
- package/shims/node.mjs.map +1 -1
- package/shims/web.d.ts.map +1 -1
- package/shims/web.js.map +1 -1
- package/shims/web.mjs.map +1 -1
- package/src/_shims/MultipartBody.ts +1 -1
- package/src/_shims/auto/runtime-bun.ts +1 -1
- package/src/_shims/auto/runtime-node.ts +1 -1
- package/src/_shims/auto/runtime.ts +1 -1
- package/src/_shims/auto/types-node.ts +1 -1
- package/src/_shims/auto/types.d.ts +52 -52
- package/src/_shims/bun-runtime.ts +6 -6
- package/src/_shims/index.d.ts +36 -36
- package/src/_shims/index.js +5 -5
- package/src/_shims/index.mjs +4 -4
- package/src/_shims/node-runtime.ts +32 -32
- package/src/_shims/node-types.d.ts +27 -27
- package/src/_shims/registry.ts +44 -44
- package/src/_shims/web-runtime.ts +16 -16
- package/src/_shims/web-types.d.ts +52 -52
- package/src/core.ts +372 -372
- package/src/error.ts +37 -37
- package/src/index.ts +74 -65
- package/src/lib/generate-signature.ts +3 -3
- package/src/resource.ts +3 -3
- package/src/resources/conversation/chat.ts +23 -18
- package/src/resources/conversation/conversation.ts +11 -11
- package/src/resources/conversation/email.ts +12 -7
- package/src/resources/conversation/index.ts +3 -3
- package/src/resources/customer.ts +81 -0
- package/src/resources/index.ts +4 -3
- package/src/resources/ingest.ts +7 -7
- package/src/resources/token.ts +9 -9
- package/src/shims/node.ts +24 -24
- package/src/shims/web.ts +24 -24
- package/src/uploads.ts +72 -72
- package/src/version.ts +1 -1
- package/uploads.d.ts.map +1 -1
- package/uploads.js.map +1 -1
- package/uploads.mjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
|
@@ -1,101 +1,101 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
3
|
*/
|
|
4
|
-
export type Agent = any
|
|
4
|
+
export type Agent = any;
|
|
5
5
|
|
|
6
6
|
// @ts-ignore
|
|
7
|
-
declare const _fetch: typeof fetch
|
|
8
|
-
export { _fetch as fetch }
|
|
7
|
+
declare const _fetch: typeof fetch;
|
|
8
|
+
export { _fetch as fetch };
|
|
9
9
|
|
|
10
10
|
// @ts-ignore
|
|
11
|
-
type _Request = Request
|
|
12
|
-
export { _Request as Request }
|
|
11
|
+
type _Request = Request;
|
|
12
|
+
export { _Request as Request };
|
|
13
13
|
|
|
14
14
|
// @ts-ignore
|
|
15
|
-
type _RequestInfo = RequestInfo
|
|
16
|
-
export { type _RequestInfo as RequestInfo }
|
|
15
|
+
type _RequestInfo = RequestInfo;
|
|
16
|
+
export { type _RequestInfo as RequestInfo };
|
|
17
17
|
|
|
18
18
|
// @ts-ignore
|
|
19
|
-
type _RequestInit = RequestInit
|
|
20
|
-
export { type _RequestInit as RequestInit }
|
|
19
|
+
type _RequestInit = RequestInit;
|
|
20
|
+
export { type _RequestInit as RequestInit };
|
|
21
21
|
|
|
22
22
|
// @ts-ignore
|
|
23
|
-
type _Response = Response
|
|
24
|
-
export { _Response as Response }
|
|
23
|
+
type _Response = Response;
|
|
24
|
+
export { _Response as Response };
|
|
25
25
|
|
|
26
26
|
// @ts-ignore
|
|
27
|
-
type _ResponseInit = ResponseInit
|
|
28
|
-
export { type _ResponseInit as ResponseInit }
|
|
27
|
+
type _ResponseInit = ResponseInit;
|
|
28
|
+
export { type _ResponseInit as ResponseInit };
|
|
29
29
|
|
|
30
30
|
// @ts-ignore
|
|
31
|
-
type _ResponseType = ResponseType
|
|
32
|
-
export { type _ResponseType as ResponseType }
|
|
31
|
+
type _ResponseType = ResponseType;
|
|
32
|
+
export { type _ResponseType as ResponseType };
|
|
33
33
|
|
|
34
34
|
// @ts-ignore
|
|
35
|
-
type _BodyInit = BodyInit
|
|
36
|
-
export { type _BodyInit as BodyInit }
|
|
35
|
+
type _BodyInit = BodyInit;
|
|
36
|
+
export { type _BodyInit as BodyInit };
|
|
37
37
|
|
|
38
38
|
// @ts-ignore
|
|
39
|
-
type _Headers = Headers
|
|
40
|
-
export { _Headers as Headers }
|
|
39
|
+
type _Headers = Headers;
|
|
40
|
+
export { _Headers as Headers };
|
|
41
41
|
|
|
42
42
|
// @ts-ignore
|
|
43
|
-
type _HeadersInit = HeadersInit
|
|
44
|
-
export { type _HeadersInit as HeadersInit }
|
|
43
|
+
type _HeadersInit = HeadersInit;
|
|
44
|
+
export { type _HeadersInit as HeadersInit };
|
|
45
45
|
|
|
46
|
-
type EndingType = 'native' | 'transparent'
|
|
46
|
+
type EndingType = 'native' | 'transparent';
|
|
47
47
|
|
|
48
48
|
export interface BlobPropertyBag {
|
|
49
|
-
endings?: EndingType
|
|
50
|
-
type?: string
|
|
49
|
+
endings?: EndingType;
|
|
50
|
+
type?: string;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export interface FilePropertyBag extends BlobPropertyBag {
|
|
54
|
-
lastModified?: number
|
|
54
|
+
lastModified?: number;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export type FileFromPathOptions = Omit<FilePropertyBag, 'lastModified'
|
|
57
|
+
export type FileFromPathOptions = Omit<FilePropertyBag, 'lastModified'>;
|
|
58
58
|
|
|
59
59
|
// @ts-ignore
|
|
60
|
-
type _FormData = FormData
|
|
60
|
+
type _FormData = FormData;
|
|
61
61
|
// @ts-ignore
|
|
62
|
-
declare const _FormData: typeof FormData
|
|
63
|
-
export { _FormData as FormData }
|
|
62
|
+
declare const _FormData: typeof FormData;
|
|
63
|
+
export { _FormData as FormData };
|
|
64
64
|
|
|
65
65
|
// @ts-ignore
|
|
66
|
-
type _File = File
|
|
66
|
+
type _File = File;
|
|
67
67
|
// @ts-ignore
|
|
68
|
-
declare const _File: typeof File
|
|
69
|
-
export { _File as File }
|
|
68
|
+
declare const _File: typeof File;
|
|
69
|
+
export { _File as File };
|
|
70
70
|
|
|
71
71
|
// @ts-ignore
|
|
72
|
-
type _Blob = Blob
|
|
72
|
+
type _Blob = Blob;
|
|
73
73
|
// @ts-ignore
|
|
74
|
-
declare const _Blob: typeof Blob
|
|
75
|
-
export { _Blob as Blob }
|
|
74
|
+
declare const _Blob: typeof Blob;
|
|
75
|
+
export { _Blob as Blob };
|
|
76
76
|
|
|
77
77
|
export declare class Readable {
|
|
78
|
-
readable: boolean
|
|
79
|
-
readonly readableEnded: boolean
|
|
80
|
-
readonly readableFlowing: boolean | null
|
|
81
|
-
readonly readableHighWaterMark: number
|
|
82
|
-
readonly readableLength: number
|
|
83
|
-
readonly readableObjectMode: boolean
|
|
84
|
-
destroyed: boolean
|
|
85
|
-
read(size?: number): any
|
|
86
|
-
pause(): this
|
|
87
|
-
resume(): this
|
|
88
|
-
isPaused(): boolean
|
|
89
|
-
destroy(error?: Error): this
|
|
90
|
-
[Symbol.asyncIterator](): AsyncIterableIterator<any
|
|
78
|
+
readable: boolean;
|
|
79
|
+
readonly readableEnded: boolean;
|
|
80
|
+
readonly readableFlowing: boolean | null;
|
|
81
|
+
readonly readableHighWaterMark: number;
|
|
82
|
+
readonly readableLength: number;
|
|
83
|
+
readonly readableObjectMode: boolean;
|
|
84
|
+
destroyed: boolean;
|
|
85
|
+
read(size?: number): any;
|
|
86
|
+
pause(): this;
|
|
87
|
+
resume(): this;
|
|
88
|
+
isPaused(): boolean;
|
|
89
|
+
destroy(error?: Error): this;
|
|
90
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<any>;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
export declare class FsReadStream extends Readable {
|
|
94
|
-
path: {} // node type is string | Buffer
|
|
94
|
+
path: {}; // node type is string | Buffer
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
// @ts-ignore
|
|
98
|
-
type _ReadableStream<R = any> = ReadableStream<R
|
|
98
|
+
type _ReadableStream<R = any> = ReadableStream<R>;
|
|
99
99
|
// @ts-ignore
|
|
100
|
-
declare const _ReadableStream: typeof ReadableStream
|
|
101
|
-
export { _ReadableStream as ReadableStream }
|
|
100
|
+
declare const _ReadableStream: typeof ReadableStream;
|
|
101
|
+
export { _ReadableStream as ReadableStream };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
3
|
*/
|
|
4
|
-
import { type Shims } from './registry'
|
|
5
|
-
import { getRuntime as getWebRuntime } from './web-runtime'
|
|
6
|
-
import { ReadStream as FsReadStream } from 'node:fs'
|
|
4
|
+
import { type Shims } from './registry';
|
|
5
|
+
import { getRuntime as getWebRuntime } from './web-runtime';
|
|
6
|
+
import { ReadStream as FsReadStream } from 'node:fs';
|
|
7
7
|
|
|
8
8
|
export function getRuntime(): Shims {
|
|
9
|
-
const runtime = getWebRuntime()
|
|
9
|
+
const runtime = getWebRuntime();
|
|
10
10
|
function isFsReadStream(value: any): value is FsReadStream {
|
|
11
|
-
return value instanceof FsReadStream
|
|
11
|
+
return value instanceof FsReadStream;
|
|
12
12
|
}
|
|
13
|
-
return { ...runtime, isFsReadStream }
|
|
13
|
+
return { ...runtime, isFsReadStream };
|
|
14
14
|
}
|
package/src/_shims/index.d.ts
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
3
|
*/
|
|
4
|
-
import { manual } from './manual-types'
|
|
5
|
-
import * as auto from "./auto/types"
|
|
6
|
-
import { type RequestOptions } from '../core'
|
|
4
|
+
import { manual } from './manual-types';
|
|
5
|
+
import * as auto from "./auto/types";
|
|
6
|
+
import { type RequestOptions } from '../core';
|
|
7
7
|
|
|
8
|
-
type SelectType<Manual, Auto> = unknown extends Manual ? Auto : Manual
|
|
8
|
+
type SelectType<Manual, Auto> = unknown extends Manual ? Auto : Manual;
|
|
9
9
|
|
|
10
|
-
export const kind: string
|
|
10
|
+
export const kind: string;
|
|
11
11
|
|
|
12
12
|
// @ts-ignore
|
|
13
|
-
export type Agent = SelectType<manual.Agent, auto.Agent
|
|
13
|
+
export type Agent = SelectType<manual.Agent, auto.Agent>;
|
|
14
14
|
|
|
15
15
|
// @ts-ignore
|
|
16
|
-
export const fetch: SelectType<typeof manual.fetch, typeof auto.fetch
|
|
16
|
+
export const fetch: SelectType<typeof manual.fetch, typeof auto.fetch>;
|
|
17
17
|
|
|
18
18
|
// @ts-ignore
|
|
19
|
-
export type Request = SelectType<manual.Request, auto.Request
|
|
19
|
+
export type Request = SelectType<manual.Request, auto.Request>;
|
|
20
20
|
// @ts-ignore
|
|
21
|
-
export type RequestInfo = SelectType<manual.RequestInfo, auto.RequestInfo
|
|
21
|
+
export type RequestInfo = SelectType<manual.RequestInfo, auto.RequestInfo>;
|
|
22
22
|
// @ts-ignore
|
|
23
|
-
export type RequestInit = SelectType<manual.RequestInit, auto.RequestInit
|
|
23
|
+
export type RequestInit = SelectType<manual.RequestInit, auto.RequestInit>;
|
|
24
24
|
|
|
25
25
|
// @ts-ignore
|
|
26
|
-
export type Response = SelectType<manual.Response, auto.Response
|
|
26
|
+
export type Response = SelectType<manual.Response, auto.Response>;
|
|
27
27
|
// @ts-ignore
|
|
28
|
-
export type ResponseInit = SelectType<manual.ResponseInit, auto.ResponseInit
|
|
28
|
+
export type ResponseInit = SelectType<manual.ResponseInit, auto.ResponseInit>;
|
|
29
29
|
// @ts-ignore
|
|
30
|
-
export type ResponseType = SelectType<manual.ResponseType, auto.ResponseType
|
|
30
|
+
export type ResponseType = SelectType<manual.ResponseType, auto.ResponseType>;
|
|
31
31
|
// @ts-ignore
|
|
32
|
-
export type BodyInit = SelectType<manual.BodyInit, auto.BodyInit
|
|
32
|
+
export type BodyInit = SelectType<manual.BodyInit, auto.BodyInit>;
|
|
33
33
|
// @ts-ignore
|
|
34
|
-
export type Headers = SelectType<manual.Headers, auto.Headers
|
|
34
|
+
export type Headers = SelectType<manual.Headers, auto.Headers>;
|
|
35
35
|
// @ts-ignore
|
|
36
|
-
export const Headers: SelectType<typeof manual.Headers, typeof auto.Headers
|
|
36
|
+
export const Headers: SelectType<typeof manual.Headers, typeof auto.Headers>;
|
|
37
37
|
// @ts-ignore
|
|
38
|
-
export type HeadersInit = SelectType<manual.HeadersInit, auto.HeadersInit
|
|
38
|
+
export type HeadersInit = SelectType<manual.HeadersInit, auto.HeadersInit>;
|
|
39
39
|
|
|
40
40
|
// @ts-ignore
|
|
41
|
-
export type BlobPropertyBag = SelectType<manual.BlobPropertyBag, auto.BlobPropertyBag
|
|
41
|
+
export type BlobPropertyBag = SelectType<manual.BlobPropertyBag, auto.BlobPropertyBag>;
|
|
42
42
|
// @ts-ignore
|
|
43
|
-
export type FilePropertyBag = SelectType<manual.FilePropertyBag, auto.FilePropertyBag
|
|
43
|
+
export type FilePropertyBag = SelectType<manual.FilePropertyBag, auto.FilePropertyBag>;
|
|
44
44
|
// @ts-ignore
|
|
45
|
-
export type FileFromPathOptions = SelectType<manual.FileFromPathOptions, auto.FileFromPathOptions
|
|
45
|
+
export type FileFromPathOptions = SelectType<manual.FileFromPathOptions, auto.FileFromPathOptions>;
|
|
46
46
|
// @ts-ignore
|
|
47
|
-
export type FormData = SelectType<manual.FormData, auto.FormData
|
|
47
|
+
export type FormData = SelectType<manual.FormData, auto.FormData>;
|
|
48
48
|
// @ts-ignore
|
|
49
|
-
export const FormData: SelectType<typeof manual.FormData, typeof auto.FormData
|
|
49
|
+
export const FormData: SelectType<typeof manual.FormData, typeof auto.FormData>;
|
|
50
50
|
// @ts-ignore
|
|
51
|
-
export type File = SelectType<manual.File, auto.File
|
|
51
|
+
export type File = SelectType<manual.File, auto.File>;
|
|
52
52
|
// @ts-ignore
|
|
53
|
-
export const File: SelectType<typeof manual.File, typeof auto.File
|
|
53
|
+
export const File: SelectType<typeof manual.File, typeof auto.File>;
|
|
54
54
|
// @ts-ignore
|
|
55
|
-
export type Blob = SelectType<manual.Blob, auto.Blob
|
|
55
|
+
export type Blob = SelectType<manual.Blob, auto.Blob>;
|
|
56
56
|
// @ts-ignore
|
|
57
|
-
export const Blob: SelectType<typeof manual.Blob, typeof auto.Blob
|
|
57
|
+
export const Blob: SelectType<typeof manual.Blob, typeof auto.Blob>;
|
|
58
58
|
|
|
59
59
|
// @ts-ignore
|
|
60
|
-
export type Readable = SelectType<manual.Readable, auto.Readable
|
|
60
|
+
export type Readable = SelectType<manual.Readable, auto.Readable>;
|
|
61
61
|
// @ts-ignore
|
|
62
|
-
export type FsReadStream = SelectType<manual.FsReadStream, auto.FsReadStream
|
|
62
|
+
export type FsReadStream = SelectType<manual.FsReadStream, auto.FsReadStream>;
|
|
63
63
|
// @ts-ignore
|
|
64
|
-
export type ReadableStream = SelectType<manual.ReadableStream, auto.ReadableStream
|
|
64
|
+
export type ReadableStream = SelectType<manual.ReadableStream, auto.ReadableStream>;
|
|
65
65
|
// @ts-ignore
|
|
66
|
-
export const ReadableStream: SelectType<typeof manual.ReadableStream, typeof auto.ReadableStream
|
|
66
|
+
export const ReadableStream: SelectType<typeof manual.ReadableStream, typeof auto.ReadableStream>;
|
|
67
67
|
|
|
68
68
|
export function getMultipartRequestOptions<T = Record<string, unknown>>(
|
|
69
69
|
form: FormData,
|
|
70
70
|
opts: RequestOptions<T>,
|
|
71
|
-
): Promise<RequestOptions<T
|
|
71
|
+
): Promise<RequestOptions<T>>;
|
|
72
72
|
|
|
73
|
-
export function getDefaultAgent(url: string): any
|
|
73
|
+
export function getDefaultAgent(url: string): any;
|
|
74
74
|
|
|
75
75
|
// @ts-ignore
|
|
76
|
-
export type FileFromPathOptions = SelectType<manual.FileFromPathOptions, auto.FileFromPathOptions
|
|
76
|
+
export type FileFromPathOptions = SelectType<manual.FileFromPathOptions, auto.FileFromPathOptions>;
|
|
77
77
|
|
|
78
|
-
export function fileFromPath(path: string, options?: FileFromPathOptions): Promise<File
|
|
79
|
-
export function fileFromPath(path: string, filename?: string, options?: FileFromPathOptions): Promise<File
|
|
78
|
+
export function fileFromPath(path: string, options?: FileFromPathOptions): Promise<File>;
|
|
79
|
+
export function fileFromPath(path: string, filename?: string, options?: FileFromPathOptions): Promise<File>;
|
|
80
80
|
|
|
81
|
-
export function isFsReadStream(value: any): value is FsReadStream
|
|
81
|
+
export function isFsReadStream(value: any): value is FsReadStream;
|
package/src/_shims/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
3
|
*/
|
|
4
|
-
const shims = require('./registry')
|
|
5
|
-
const auto = require('@lorikeetai/node-sdk/_shims/auto/runtime')
|
|
6
|
-
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true })
|
|
4
|
+
const shims = require('./registry');
|
|
5
|
+
const auto = require('@lorikeetai/node-sdk/_shims/auto/runtime');
|
|
6
|
+
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
|
|
7
7
|
for (const property of Object.keys(shims)) {
|
|
8
8
|
Object.defineProperty(exports, property, {
|
|
9
9
|
get() {
|
|
10
|
-
return shims[property]
|
|
10
|
+
return shims[property];
|
|
11
11
|
},
|
|
12
|
-
})
|
|
12
|
+
});
|
|
13
13
|
}
|
package/src/_shims/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
3
|
*/
|
|
4
|
-
import * as shims from './registry.mjs'
|
|
5
|
-
import * as auto from "./auto/runtime"
|
|
6
|
-
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true })
|
|
7
|
-
export * from './registry.mjs'
|
|
4
|
+
import * as shims from './registry.mjs';
|
|
5
|
+
import * as auto from "./auto/runtime";
|
|
6
|
+
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
|
|
7
|
+
export * from './registry.mjs';
|
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
3
|
*/
|
|
4
|
-
import * as nf from 'node-fetch'
|
|
5
|
-
import * as fd from 'formdata-node'
|
|
6
|
-
import { type File, type FilePropertyBag } from 'formdata-node'
|
|
7
|
-
import KeepAliveAgent from 'agentkeepalive'
|
|
8
|
-
import { AbortController as AbortControllerPolyfill } from 'abort-controller'
|
|
9
|
-
import { ReadStream as FsReadStream } from 'node:fs'
|
|
10
|
-
import { type Agent } from 'node:http'
|
|
11
|
-
import { FormDataEncoder } from 'form-data-encoder'
|
|
12
|
-
import { Readable } from 'node:stream'
|
|
13
|
-
import { type RequestOptions } from '../core'
|
|
14
|
-
import { MultipartBody } from './MultipartBody'
|
|
15
|
-
import { type Shims } from './registry'
|
|
16
|
-
import { ReadableStream } from 'node:stream/web'
|
|
4
|
+
import * as nf from 'node-fetch';
|
|
5
|
+
import * as fd from 'formdata-node';
|
|
6
|
+
import { type File, type FilePropertyBag } from 'formdata-node';
|
|
7
|
+
import KeepAliveAgent from 'agentkeepalive';
|
|
8
|
+
import { AbortController as AbortControllerPolyfill } from 'abort-controller';
|
|
9
|
+
import { ReadStream as FsReadStream } from 'node:fs';
|
|
10
|
+
import { type Agent } from 'node:http';
|
|
11
|
+
import { FormDataEncoder } from 'form-data-encoder';
|
|
12
|
+
import { Readable } from 'node:stream';
|
|
13
|
+
import { type RequestOptions } from '../core';
|
|
14
|
+
import { MultipartBody } from './MultipartBody';
|
|
15
|
+
import { type Shims } from './registry';
|
|
16
|
+
import { ReadableStream } from 'node:stream/web';
|
|
17
17
|
|
|
18
|
-
type FileFromPathOptions = Omit<FilePropertyBag, 'lastModified'
|
|
18
|
+
type FileFromPathOptions = Omit<FilePropertyBag, 'lastModified'>;
|
|
19
19
|
|
|
20
|
-
let fileFromPathWarned = false
|
|
20
|
+
let fileFromPathWarned = false;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @deprecated use fs.createReadStream('./my/file.txt') instead
|
|
24
24
|
*/
|
|
25
|
-
async function fileFromPath(path: string): Promise<File
|
|
26
|
-
async function fileFromPath(path: string, filename?: string): Promise<File
|
|
27
|
-
async function fileFromPath(path: string, options?: FileFromPathOptions): Promise<File
|
|
28
|
-
async function fileFromPath(path: string, filename?: string, options?: FileFromPathOptions): Promise<File
|
|
25
|
+
async function fileFromPath(path: string): Promise<File>;
|
|
26
|
+
async function fileFromPath(path: string, filename?: string): Promise<File>;
|
|
27
|
+
async function fileFromPath(path: string, options?: FileFromPathOptions): Promise<File>;
|
|
28
|
+
async function fileFromPath(path: string, filename?: string, options?: FileFromPathOptions): Promise<File>;
|
|
29
29
|
async function fileFromPath(path: string, ...args: any[]): Promise<File> {
|
|
30
30
|
// this import fails in environments that don't handle export maps correctly, like old versions of Jest
|
|
31
|
-
const { fileFromPath: _fileFromPath } = await import('formdata-node/file-from-path')
|
|
31
|
+
const { fileFromPath: _fileFromPath } = await import('formdata-node/file-from-path');
|
|
32
32
|
|
|
33
33
|
if (!fileFromPathWarned) {
|
|
34
|
-
console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path)}) instead`)
|
|
35
|
-
fileFromPathWarned = true
|
|
34
|
+
console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path)}) instead`);
|
|
35
|
+
fileFromPathWarned = true;
|
|
36
36
|
}
|
|
37
37
|
// @ts-ignore
|
|
38
|
-
return await _fileFromPath(path, ...args)
|
|
38
|
+
return await _fileFromPath(path, ...args);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const defaultHttpAgent: Agent = new KeepAliveAgent({ keepAlive: true, timeout: 5 * 60 * 1000 })
|
|
42
|
-
const defaultHttpsAgent: Agent = new KeepAliveAgent.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1000 })
|
|
41
|
+
const defaultHttpAgent: Agent = new KeepAliveAgent({ keepAlive: true, timeout: 5 * 60 * 1000 });
|
|
42
|
+
const defaultHttpsAgent: Agent = new KeepAliveAgent.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1000 });
|
|
43
43
|
|
|
44
44
|
async function getMultipartRequestOptions<T = Record<string, unknown>>(
|
|
45
45
|
form: fd.FormData,
|
|
46
46
|
opts: RequestOptions<T>,
|
|
47
47
|
): Promise<RequestOptions<T>> {
|
|
48
|
-
const encoder = new FormDataEncoder(form)
|
|
49
|
-
const readable = Readable.from(encoder)
|
|
50
|
-
const body = new MultipartBody(readable)
|
|
48
|
+
const encoder = new FormDataEncoder(form);
|
|
49
|
+
const readable = Readable.from(encoder);
|
|
50
|
+
const body = new MultipartBody(readable);
|
|
51
51
|
const headers = {
|
|
52
52
|
...opts.headers,
|
|
53
53
|
...encoder.headers,
|
|
54
54
|
'Content-Length': encoder.contentLength,
|
|
55
|
-
}
|
|
55
|
+
};
|
|
56
56
|
|
|
57
|
-
return { ...opts, body: body as any, headers }
|
|
57
|
+
return { ...opts, body: body as any, headers };
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export function getRuntime(): Shims {
|
|
61
61
|
// Polyfill global object if needed.
|
|
62
62
|
if (typeof AbortController === 'undefined') {
|
|
63
63
|
// @ts-expect-error (the types are subtly different, but compatible in practice)
|
|
64
|
-
globalThis.AbortController = AbortControllerPolyfill
|
|
64
|
+
globalThis.AbortController = AbortControllerPolyfill;
|
|
65
65
|
}
|
|
66
66
|
return {
|
|
67
67
|
kind: 'node',
|
|
@@ -77,5 +77,5 @@ export function getRuntime(): Shims {
|
|
|
77
77
|
getDefaultAgent: (url: string): Agent => (url.startsWith('https') ? defaultHttpsAgent : defaultHttpAgent),
|
|
78
78
|
fileFromPath,
|
|
79
79
|
isFsReadStream: (value: any): value is FsReadStream => value instanceof FsReadStream,
|
|
80
|
-
}
|
|
80
|
+
};
|
|
81
81
|
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
3
|
*/
|
|
4
|
-
import * as nf from 'node-fetch'
|
|
5
|
-
import * as fd from 'formdata-node'
|
|
4
|
+
import * as nf from 'node-fetch';
|
|
5
|
+
import * as fd from 'formdata-node';
|
|
6
6
|
|
|
7
|
-
export { type Agent } from 'node:http'
|
|
8
|
-
export { type Readable } from 'node:stream'
|
|
9
|
-
export { type ReadStream as FsReadStream } from 'node:fs'
|
|
10
|
-
export { ReadableStream } from 'node:stream/web'
|
|
7
|
+
export { type Agent } from 'node:http';
|
|
8
|
+
export { type Readable } from 'node:stream';
|
|
9
|
+
export { type ReadStream as FsReadStream } from 'node:fs';
|
|
10
|
+
export { ReadableStream } from 'node:stream/web';
|
|
11
11
|
|
|
12
|
-
export const fetch: typeof nf.default
|
|
12
|
+
export const fetch: typeof nf.default;
|
|
13
13
|
|
|
14
|
-
export type Request = nf.Request
|
|
15
|
-
export type RequestInfo = nf.RequestInfo
|
|
16
|
-
export type RequestInit = nf.RequestInit
|
|
14
|
+
export type Request = nf.Request;
|
|
15
|
+
export type RequestInfo = nf.RequestInfo;
|
|
16
|
+
export type RequestInit = nf.RequestInit;
|
|
17
17
|
|
|
18
|
-
export type Response = nf.Response
|
|
19
|
-
export type ResponseInit = nf.ResponseInit
|
|
20
|
-
export type ResponseType = nf.ResponseType
|
|
21
|
-
export type BodyInit = nf.BodyInit
|
|
22
|
-
export type Headers = nf.Headers
|
|
23
|
-
export type HeadersInit = nf.HeadersInit
|
|
18
|
+
export type Response = nf.Response;
|
|
19
|
+
export type ResponseInit = nf.ResponseInit;
|
|
20
|
+
export type ResponseType = nf.ResponseType;
|
|
21
|
+
export type BodyInit = nf.BodyInit;
|
|
22
|
+
export type Headers = nf.Headers;
|
|
23
|
+
export type HeadersInit = nf.HeadersInit;
|
|
24
24
|
|
|
25
|
-
type EndingType = 'native' | 'transparent'
|
|
25
|
+
type EndingType = 'native' | 'transparent';
|
|
26
26
|
export interface BlobPropertyBag {
|
|
27
|
-
endings?: EndingType
|
|
28
|
-
type?: string
|
|
27
|
+
endings?: EndingType;
|
|
28
|
+
type?: string;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface FilePropertyBag extends BlobPropertyBag {
|
|
32
|
-
lastModified?: number
|
|
32
|
+
lastModified?: number;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export type FileFromPathOptions = Omit<FilePropertyBag, 'lastModified'
|
|
35
|
+
export type FileFromPathOptions = Omit<FilePropertyBag, 'lastModified'>;
|
|
36
36
|
|
|
37
|
-
export type FormData = fd.FormData
|
|
38
|
-
export const FormData: typeof fd.FormData
|
|
39
|
-
export type File = fd.File
|
|
40
|
-
export const File: typeof fd.File
|
|
41
|
-
export type Blob = fd.Blob
|
|
42
|
-
export const Blob: typeof fd.Blob
|
|
37
|
+
export type FormData = fd.FormData;
|
|
38
|
+
export const FormData: typeof fd.FormData;
|
|
39
|
+
export type File = fd.File;
|
|
40
|
+
export const File: typeof fd.File;
|
|
41
|
+
export type Blob = fd.Blob;
|
|
42
|
+
export const Blob: typeof fd.Blob;
|
package/src/_shims/registry.ts
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
3
|
*/
|
|
4
|
-
import { type RequestOptions } from '../core'
|
|
4
|
+
import { type RequestOptions } from '../core';
|
|
5
5
|
|
|
6
6
|
export interface Shims {
|
|
7
|
-
kind: string
|
|
8
|
-
fetch: any
|
|
9
|
-
Request: any
|
|
10
|
-
Response: any
|
|
11
|
-
Headers: any
|
|
12
|
-
FormData: any
|
|
13
|
-
Blob: any
|
|
14
|
-
File: any
|
|
15
|
-
ReadableStream: any
|
|
7
|
+
kind: string;
|
|
8
|
+
fetch: any;
|
|
9
|
+
Request: any;
|
|
10
|
+
Response: any;
|
|
11
|
+
Headers: any;
|
|
12
|
+
FormData: any;
|
|
13
|
+
Blob: any;
|
|
14
|
+
File: any;
|
|
15
|
+
ReadableStream: any;
|
|
16
16
|
getMultipartRequestOptions: <T = Record<string, unknown>>(
|
|
17
17
|
form: Shims['FormData'],
|
|
18
18
|
opts: RequestOptions<T>,
|
|
19
|
-
) => Promise<RequestOptions<T
|
|
20
|
-
getDefaultAgent: (url: string) => any
|
|
19
|
+
) => Promise<RequestOptions<T>>;
|
|
20
|
+
getDefaultAgent: (url: string) => any;
|
|
21
21
|
fileFromPath:
|
|
22
22
|
| ((path: string, filename?: string, options?: {}) => Promise<Shims['File']>)
|
|
23
|
-
| ((path: string, options?: {}) => Promise<Shims['File']>)
|
|
24
|
-
isFsReadStream: (value: any) => boolean
|
|
23
|
+
| ((path: string, options?: {}) => Promise<Shims['File']>);
|
|
24
|
+
isFsReadStream: (value: any) => boolean;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export let auto = false
|
|
28
|
-
export let kind: Shims['kind'] | undefined = undefined
|
|
29
|
-
export let fetch: Shims['fetch'] | undefined = undefined
|
|
30
|
-
export let Request: Shims['Request'] | undefined = undefined
|
|
31
|
-
export let Response: Shims['Response'] | undefined = undefined
|
|
32
|
-
export let Headers: Shims['Headers'] | undefined = undefined
|
|
33
|
-
export let FormData: Shims['FormData'] | undefined = undefined
|
|
34
|
-
export let Blob: Shims['Blob'] | undefined = undefined
|
|
35
|
-
export let File: Shims['File'] | undefined = undefined
|
|
36
|
-
export let ReadableStream: Shims['ReadableStream'] | undefined = undefined
|
|
37
|
-
export let getMultipartRequestOptions: Shims['getMultipartRequestOptions'] | undefined = undefined
|
|
38
|
-
export let getDefaultAgent: Shims['getDefaultAgent'] | undefined = undefined
|
|
39
|
-
export let fileFromPath: Shims['fileFromPath'] | undefined = undefined
|
|
40
|
-
export let isFsReadStream: Shims['isFsReadStream'] | undefined = undefined
|
|
27
|
+
export let auto = false;
|
|
28
|
+
export let kind: Shims['kind'] | undefined = undefined;
|
|
29
|
+
export let fetch: Shims['fetch'] | undefined = undefined;
|
|
30
|
+
export let Request: Shims['Request'] | undefined = undefined;
|
|
31
|
+
export let Response: Shims['Response'] | undefined = undefined;
|
|
32
|
+
export let Headers: Shims['Headers'] | undefined = undefined;
|
|
33
|
+
export let FormData: Shims['FormData'] | undefined = undefined;
|
|
34
|
+
export let Blob: Shims['Blob'] | undefined = undefined;
|
|
35
|
+
export let File: Shims['File'] | undefined = undefined;
|
|
36
|
+
export let ReadableStream: Shims['ReadableStream'] | undefined = undefined;
|
|
37
|
+
export let getMultipartRequestOptions: Shims['getMultipartRequestOptions'] | undefined = undefined;
|
|
38
|
+
export let getDefaultAgent: Shims['getDefaultAgent'] | undefined = undefined;
|
|
39
|
+
export let fileFromPath: Shims['fileFromPath'] | undefined = undefined;
|
|
40
|
+
export let isFsReadStream: Shims['isFsReadStream'] | undefined = undefined;
|
|
41
41
|
|
|
42
42
|
export function setShims(shims: Shims, options: { auto: boolean } = { auto: false }) {
|
|
43
43
|
if (auto) {
|
|
44
44
|
throw new Error(
|
|
45
45
|
`you must \`import '@lorikeetai/node-sdk/shims/${shims.kind}'\` before importing anything else from @lorikeetai/node-sdk`,
|
|
46
|
-
)
|
|
46
|
+
);
|
|
47
47
|
}
|
|
48
48
|
if (kind) {
|
|
49
49
|
throw new Error(
|
|
50
50
|
`can't \`import '@lorikeetai/node-sdk/shims/${shims.kind}'\` after \`import '@lorikeetai/node-sdk/shims/${kind}'\``,
|
|
51
|
-
)
|
|
51
|
+
);
|
|
52
52
|
}
|
|
53
|
-
auto = options.auto
|
|
54
|
-
kind = shims.kind
|
|
55
|
-
fetch = shims.fetch
|
|
56
|
-
Request = shims.Request
|
|
57
|
-
Response = shims.Response
|
|
58
|
-
Headers = shims.Headers
|
|
59
|
-
FormData = shims.FormData
|
|
60
|
-
Blob = shims.Blob
|
|
61
|
-
File = shims.File
|
|
62
|
-
ReadableStream = shims.ReadableStream
|
|
63
|
-
getMultipartRequestOptions = shims.getMultipartRequestOptions
|
|
64
|
-
getDefaultAgent = shims.getDefaultAgent
|
|
65
|
-
fileFromPath = shims.fileFromPath
|
|
66
|
-
isFsReadStream = shims.isFsReadStream
|
|
53
|
+
auto = options.auto;
|
|
54
|
+
kind = shims.kind;
|
|
55
|
+
fetch = shims.fetch;
|
|
56
|
+
Request = shims.Request;
|
|
57
|
+
Response = shims.Response;
|
|
58
|
+
Headers = shims.Headers;
|
|
59
|
+
FormData = shims.FormData;
|
|
60
|
+
Blob = shims.Blob;
|
|
61
|
+
File = shims.File;
|
|
62
|
+
ReadableStream = shims.ReadableStream;
|
|
63
|
+
getMultipartRequestOptions = shims.getMultipartRequestOptions;
|
|
64
|
+
getDefaultAgent = shims.getDefaultAgent;
|
|
65
|
+
fileFromPath = shims.fileFromPath;
|
|
66
|
+
isFsReadStream = shims.isFsReadStream;
|
|
67
67
|
}
|