@anthropic-ai/sdk 0.5.0 → 0.5.1
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/{dist/esm/_shims → _shims}/agent.d.ts +2 -2
- package/_shims/agent.d.ts.map +1 -0
- package/_shims/agent.js.map +1 -0
- package/{dist/esm/_shims/agent.js → _shims/agent.mjs} +1 -1
- package/_shims/agent.mjs.map +1 -0
- package/{dist/cjs/_shims → _shims}/agent.node.d.ts +1 -0
- package/_shims/agent.node.d.ts.map +1 -0
- package/_shims/agent.node.js.map +1 -0
- package/{dist/esm/_shims/agent.node.js → _shims/agent.node.mjs} +1 -1
- package/_shims/agent.node.mjs.map +1 -0
- package/_shims/fetch.d.ts +52 -0
- package/_shims/fetch.js +13 -0
- package/_shims/fetch.mjs +15 -0
- package/_shims/fetch.node.d.ts +53 -0
- package/_shims/fetch.node.js +12 -0
- package/_shims/fetch.node.mjs +14 -0
- package/{dist/cjs/_shims → _shims}/fileFromPath.d.ts +1 -2
- package/_shims/fileFromPath.d.ts.map +1 -0
- package/_shims/fileFromPath.js +16 -0
- package/_shims/fileFromPath.js.map +1 -0
- package/{dist/esm/_shims/fileFromPath.js → _shims/fileFromPath.mjs} +1 -1
- package/_shims/fileFromPath.mjs.map +1 -0
- package/{dist/cjs/_shims → _shims}/fileFromPath.node.d.ts +1 -2
- package/_shims/fileFromPath.node.d.ts.map +1 -0
- package/_shims/fileFromPath.node.js +17 -0
- package/_shims/fileFromPath.node.js.map +1 -0
- package/{dist/esm/_shims/fileFromPath.node.js → _shims/fileFromPath.node.mjs} +1 -1
- package/_shims/fileFromPath.node.mjs.map +1 -0
- package/_shims/formdata.d.ts +43 -0
- package/_shims/formdata.js +9 -0
- package/{dist/esm/_shims/formdata.js → _shims/formdata.mjs} +7 -11
- package/_shims/formdata.node.d.ts +44 -0
- package/_shims/formdata.node.js +11 -0
- package/_shims/getMultipartRequestOptions.d.ts.map +1 -0
- package/_shims/getMultipartRequestOptions.js +12 -0
- package/_shims/getMultipartRequestOptions.js.map +1 -0
- package/_shims/getMultipartRequestOptions.mjs +8 -0
- package/_shims/getMultipartRequestOptions.mjs.map +1 -0
- package/_shims/getMultipartRequestOptions.node.d.ts.map +1 -0
- package/_shims/getMultipartRequestOptions.node.js +22 -0
- package/_shims/getMultipartRequestOptions.node.js.map +1 -0
- package/{dist/esm/_shims/getMultipartRequestOptions.node.js → _shims/getMultipartRequestOptions.node.mjs} +3 -2
- package/_shims/getMultipartRequestOptions.node.mjs.map +1 -0
- package/_shims/node-readable.d.ts +23 -0
- package/_shims/node-readable.d.ts.map +1 -0
- package/_shims/node-readable.js +11 -0
- package/_shims/node-readable.js.map +1 -0
- package/_shims/node-readable.mjs +7 -0
- package/_shims/node-readable.mjs.map +1 -0
- package/_shims/node-readable.node.d.ts +8 -0
- package/_shims/node-readable.node.d.ts.map +1 -0
- package/_shims/node-readable.node.js +9 -0
- package/_shims/node-readable.node.js.map +1 -0
- package/_shims/node-readable.node.mjs +5 -0
- package/_shims/node-readable.node.mjs.map +1 -0
- package/{dist/esm/core.d.ts → core.d.ts} +15 -10
- package/core.d.ts.map +1 -0
- package/{dist/cjs/core.js → core.js} +191 -333
- package/core.js.map +1 -0
- package/{dist/esm/core.js → core.mjs} +56 -25
- package/core.mjs.map +1 -0
- package/error.d.ts.map +1 -0
- package/{dist/cjs/error.js → error.js} +1 -1
- package/error.js.map +1 -0
- package/{dist/esm/error.js → error.mjs} +5 -3
- package/error.mjs.map +1 -0
- package/{dist/cjs/index.d.ts → index.d.mts} +42 -7
- package/{dist/esm/index.d.ts → index.d.ts} +38 -3
- package/index.d.ts.map +1 -0
- package/{dist/cjs/index.js → index.js} +17 -15
- package/index.js.map +1 -0
- package/{dist/esm/index.js → index.mjs} +12 -6
- package/index.mjs.map +1 -0
- package/package.json +34 -77
- package/resource.d.ts.map +1 -0
- package/resource.js.map +1 -0
- package/{dist/esm/resource.js → resource.mjs} +1 -1
- package/resource.mjs.map +1 -0
- package/{dist/esm/resources → resources}/completions.d.ts +3 -3
- package/resources/completions.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/completions.js +7 -7
- package/resources/completions.js.map +1 -0
- package/resources/completions.mjs +15 -0
- package/resources/completions.mjs.map +1 -0
- package/resources/index.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/index.js +1 -1
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +3 -0
- package/resources/index.mjs.map +1 -0
- package/resources/top-level.d.ts.map +1 -0
- package/resources/top-level.js.map +1 -0
- package/{dist/esm/resources/top-level.js → resources/top-level.mjs} +1 -1
- package/resources/top-level.mjs.map +1 -0
- package/{_shims → src/_shims}/agent.node.ts +2 -0
- package/{_shims → src/_shims}/agent.ts +2 -2
- package/src/_shims/fetch.d.ts +52 -0
- package/src/_shims/fetch.js +13 -0
- package/src/_shims/fetch.mjs +15 -0
- package/src/_shims/fetch.node.d.ts +53 -0
- package/src/_shims/fetch.node.js +12 -0
- package/src/_shims/fetch.node.mjs +14 -0
- package/{_shims → src/_shims}/fileFromPath.node.ts +1 -2
- package/{_shims → src/_shims}/fileFromPath.ts +1 -2
- package/src/_shims/formdata.d.ts +43 -0
- package/src/_shims/formdata.js +9 -0
- package/src/_shims/formdata.mjs +11 -0
- package/src/_shims/formdata.node.d.ts +44 -0
- package/src/_shims/formdata.node.js +11 -0
- package/{dist/esm/_shims/formdata.node.js → src/_shims/formdata.node.mjs} +3 -1
- package/{_shims → src/_shims}/getMultipartRequestOptions.node.ts +2 -1
- package/{_shims → src/_shims}/getMultipartRequestOptions.ts +2 -1
- package/src/_shims/node-readable.node.ts +10 -0
- package/src/_shims/node-readable.ts +30 -0
- package/{core.ts → src/core.ts} +42 -20
- package/{index.ts → src/index.ts} +50 -3
- package/{resources → src/resources}/completions.ts +4 -4
- package/{streaming.ts → src/streaming.ts} +6 -3
- package/src/uploads.ts +248 -0
- package/src/version.ts +1 -0
- package/{dist/esm/streaming.d.ts → streaming.d.ts} +2 -0
- package/streaming.d.ts.map +1 -0
- package/streaming.js +168 -0
- package/streaming.js.map +1 -0
- package/{dist/esm/streaming.js → streaming.mjs} +5 -4
- package/streaming.mjs.map +1 -0
- package/uploads.d.ts +90 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +207 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +174 -0
- package/uploads.mjs.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/{dist/cjs/version.js → version.js} +1 -1
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
- package/LICENSE +0 -8
- package/README.md +0 -305
- package/_shims/fetch.node.ts +0 -11
- package/_shims/fetch.ts +0 -32
- package/_shims/formdata.ts +0 -22
- package/_shims/newFileArgs.ts +0 -94
- package/_shims/toFile.node.ts +0 -25
- package/_shims/toFile.ts +0 -26
- package/_shims/uploadable.node.ts +0 -21
- package/_shims/uploadable.ts +0 -82
- package/check-version.ts +0 -18
- package/dist/cjs/_shims/agent.d.ts +0 -9
- package/dist/cjs/_shims/agent.d.ts.map +0 -1
- package/dist/cjs/_shims/agent.js.map +0 -1
- package/dist/cjs/_shims/agent.node.d.ts.map +0 -1
- package/dist/cjs/_shims/agent.node.js.map +0 -1
- package/dist/cjs/_shims/fetch.d.ts +0 -19
- package/dist/cjs/_shims/fetch.d.ts.map +0 -1
- package/dist/cjs/_shims/fetch.js +0 -24
- package/dist/cjs/_shims/fetch.js.map +0 -1
- package/dist/cjs/_shims/fetch.node.d.ts +0 -9
- package/dist/cjs/_shims/fetch.node.d.ts.map +0 -1
- package/dist/cjs/_shims/fetch.node.js +0 -68
- package/dist/cjs/_shims/fetch.node.js.map +0 -1
- package/dist/cjs/_shims/fileFromPath.d.ts.map +0 -1
- package/dist/cjs/_shims/fileFromPath.js +0 -49
- package/dist/cjs/_shims/fileFromPath.js.map +0 -1
- package/dist/cjs/_shims/fileFromPath.node.d.ts.map +0 -1
- package/dist/cjs/_shims/fileFromPath.node.js +0 -50
- package/dist/cjs/_shims/fileFromPath.node.js.map +0 -1
- package/dist/cjs/_shims/formdata.d.ts +0 -13
- package/dist/cjs/_shims/formdata.d.ts.map +0 -1
- package/dist/cjs/_shims/formdata.js +0 -20
- package/dist/cjs/_shims/formdata.js.map +0 -1
- package/dist/cjs/_shims/formdata.node.d.ts +0 -7
- package/dist/cjs/_shims/formdata.node.d.ts.map +0 -1
- package/dist/cjs/_shims/formdata.node.js +0 -27
- package/dist/cjs/_shims/formdata.node.js.map +0 -1
- package/dist/cjs/_shims/getMultipartRequestOptions.d.ts +0 -10
- package/dist/cjs/_shims/getMultipartRequestOptions.d.ts.map +0 -1
- package/dist/cjs/_shims/getMultipartRequestOptions.js +0 -44
- package/dist/cjs/_shims/getMultipartRequestOptions.js.map +0 -1
- package/dist/cjs/_shims/getMultipartRequestOptions.node.d.ts +0 -10
- package/dist/cjs/_shims/getMultipartRequestOptions.node.d.ts.map +0 -1
- package/dist/cjs/_shims/getMultipartRequestOptions.node.js +0 -52
- package/dist/cjs/_shims/getMultipartRequestOptions.node.js.map +0 -1
- package/dist/cjs/_shims/newFileArgs.d.ts +0 -19
- package/dist/cjs/_shims/newFileArgs.d.ts.map +0 -1
- package/dist/cjs/_shims/newFileArgs.js +0 -169
- package/dist/cjs/_shims/newFileArgs.js.map +0 -1
- package/dist/cjs/_shims/toFile.d.ts +0 -21
- package/dist/cjs/_shims/toFile.d.ts.map +0 -1
- package/dist/cjs/_shims/toFile.js +0 -56
- package/dist/cjs/_shims/toFile.js.map +0 -1
- package/dist/cjs/_shims/toFile.node.d.ts +0 -20
- package/dist/cjs/_shims/toFile.node.d.ts.map +0 -1
- package/dist/cjs/_shims/toFile.node.js +0 -56
- package/dist/cjs/_shims/toFile.node.js.map +0 -1
- package/dist/cjs/_shims/uploadable.d.ts +0 -56
- package/dist/cjs/_shims/uploadable.d.ts.map +0 -1
- package/dist/cjs/_shims/uploadable.js +0 -37
- package/dist/cjs/_shims/uploadable.js.map +0 -1
- package/dist/cjs/_shims/uploadable.node.d.ts +0 -7
- package/dist/cjs/_shims/uploadable.node.d.ts.map +0 -1
- package/dist/cjs/_shims/uploadable.node.js +0 -23
- package/dist/cjs/_shims/uploadable.node.js.map +0 -1
- package/dist/cjs/check-version.d.ts +0 -2
- package/dist/cjs/check-version.d.ts.map +0 -1
- package/dist/cjs/check-version.js +0 -23
- package/dist/cjs/check-version.js.map +0 -1
- package/dist/cjs/core.d.ts +0 -221
- package/dist/cjs/core.d.ts.map +0 -1
- package/dist/cjs/core.js.map +0 -1
- package/dist/cjs/error.d.ts +0 -48
- package/dist/cjs/error.d.ts.map +0 -1
- package/dist/cjs/error.js.map +0 -1
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/resource.d.ts +0 -12
- package/dist/cjs/resource.d.ts.map +0 -1
- package/dist/cjs/resource.js.map +0 -1
- package/dist/cjs/resources/completions.d.ts +0 -311
- package/dist/cjs/resources/completions.d.ts.map +0 -1
- package/dist/cjs/resources/completions.js.map +0 -1
- package/dist/cjs/resources/index.d.ts +0 -2
- package/dist/cjs/resources/index.d.ts.map +0 -1
- package/dist/cjs/resources/index.js.map +0 -1
- package/dist/cjs/resources/top-level.d.ts.map +0 -1
- package/dist/cjs/resources/top-level.js.map +0 -1
- package/dist/cjs/streaming.d.ts +0 -12
- package/dist/cjs/streaming.d.ts.map +0 -1
- package/dist/cjs/streaming.js +0 -297
- package/dist/cjs/streaming.js.map +0 -1
- package/dist/cjs/uploads.d.ts +0 -24
- package/dist/cjs/uploads.d.ts.map +0 -1
- package/dist/cjs/uploads.js +0 -121
- package/dist/cjs/uploads.js.map +0 -1
- package/dist/cjs/version.d.ts +0 -2
- package/dist/cjs/version.d.ts.map +0 -1
- package/dist/cjs/version.js.map +0 -1
- package/dist/esm/_shims/agent.d.ts.map +0 -1
- package/dist/esm/_shims/agent.js.map +0 -1
- package/dist/esm/_shims/agent.node.d.ts +0 -6
- package/dist/esm/_shims/agent.node.d.ts.map +0 -1
- package/dist/esm/_shims/agent.node.js.map +0 -1
- package/dist/esm/_shims/fetch.d.ts +0 -19
- package/dist/esm/_shims/fetch.d.ts.map +0 -1
- package/dist/esm/_shims/fetch.js +0 -18
- package/dist/esm/_shims/fetch.js.map +0 -1
- package/dist/esm/_shims/fetch.node.d.ts +0 -9
- package/dist/esm/_shims/fetch.node.d.ts.map +0 -1
- package/dist/esm/_shims/fetch.node.js +0 -7
- package/dist/esm/_shims/fetch.node.js.map +0 -1
- package/dist/esm/_shims/fileFromPath.d.ts +0 -23
- package/dist/esm/_shims/fileFromPath.d.ts.map +0 -1
- package/dist/esm/_shims/fileFromPath.js.map +0 -1
- package/dist/esm/_shims/fileFromPath.node.d.ts +0 -18
- package/dist/esm/_shims/fileFromPath.node.d.ts.map +0 -1
- package/dist/esm/_shims/fileFromPath.node.js.map +0 -1
- package/dist/esm/_shims/formdata.d.ts +0 -13
- package/dist/esm/_shims/formdata.d.ts.map +0 -1
- package/dist/esm/_shims/formdata.js.map +0 -1
- package/dist/esm/_shims/formdata.node.d.ts +0 -7
- package/dist/esm/_shims/formdata.node.d.ts.map +0 -1
- package/dist/esm/_shims/formdata.node.js.map +0 -1
- package/dist/esm/_shims/getMultipartRequestOptions.d.ts.map +0 -1
- package/dist/esm/_shims/getMultipartRequestOptions.js +0 -7
- package/dist/esm/_shims/getMultipartRequestOptions.js.map +0 -1
- package/dist/esm/_shims/getMultipartRequestOptions.node.d.ts.map +0 -1
- package/dist/esm/_shims/getMultipartRequestOptions.node.js.map +0 -1
- package/dist/esm/_shims/newFileArgs.d.ts +0 -19
- package/dist/esm/_shims/newFileArgs.d.ts.map +0 -1
- package/dist/esm/_shims/newFileArgs.js +0 -66
- package/dist/esm/_shims/newFileArgs.js.map +0 -1
- package/dist/esm/_shims/toFile.d.ts +0 -21
- package/dist/esm/_shims/toFile.d.ts.map +0 -1
- package/dist/esm/_shims/toFile.js +0 -19
- package/dist/esm/_shims/toFile.js.map +0 -1
- package/dist/esm/_shims/toFile.node.d.ts +0 -20
- package/dist/esm/_shims/toFile.node.d.ts.map +0 -1
- package/dist/esm/_shims/toFile.node.js +0 -19
- package/dist/esm/_shims/toFile.node.js.map +0 -1
- package/dist/esm/_shims/uploadable.d.ts +0 -56
- package/dist/esm/_shims/uploadable.d.ts.map +0 -1
- package/dist/esm/_shims/uploadable.js +0 -30
- package/dist/esm/_shims/uploadable.js.map +0 -1
- package/dist/esm/_shims/uploadable.node.d.ts +0 -7
- package/dist/esm/_shims/uploadable.node.d.ts.map +0 -1
- package/dist/esm/_shims/uploadable.node.js +0 -10
- package/dist/esm/_shims/uploadable.node.js.map +0 -1
- package/dist/esm/check-version.d.ts +0 -2
- package/dist/esm/check-version.d.ts.map +0 -1
- package/dist/esm/check-version.js +0 -16
- package/dist/esm/check-version.js.map +0 -1
- package/dist/esm/core.d.ts.map +0 -1
- package/dist/esm/core.js.map +0 -1
- package/dist/esm/error.d.ts.map +0 -1
- package/dist/esm/error.js.map +0 -1
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/dist/esm/resource.d.ts.map +0 -1
- package/dist/esm/resource.js.map +0 -1
- package/dist/esm/resources/completions.d.ts.map +0 -1
- package/dist/esm/resources/completions.js +0 -9
- package/dist/esm/resources/completions.js.map +0 -1
- package/dist/esm/resources/index.d.ts.map +0 -1
- package/dist/esm/resources/index.js +0 -3
- package/dist/esm/resources/index.js.map +0 -1
- package/dist/esm/resources/top-level.d.ts +0 -2
- package/dist/esm/resources/top-level.d.ts.map +0 -1
- package/dist/esm/resources/top-level.js.map +0 -1
- package/dist/esm/streaming.d.ts.map +0 -1
- package/dist/esm/streaming.js.map +0 -1
- package/dist/esm/uploads.d.ts +0 -24
- package/dist/esm/uploads.d.ts.map +0 -1
- package/dist/esm/uploads.js +0 -61
- package/dist/esm/uploads.js.map +0 -1
- package/dist/esm/version.d.ts +0 -2
- package/dist/esm/version.d.ts.map +0 -1
- package/dist/esm/version.js +0 -2
- package/dist/esm/version.js.map +0 -1
- package/uploads.ts +0 -81
- package/version.ts +0 -1
- /package/{dist/cjs/_shims → _shims}/agent.js +0 -0
- /package/{dist/cjs/_shims → _shims}/agent.node.js +0 -0
- /package/_shims/{formdata.node.ts → formdata.node.mjs} +0 -0
- /package/{dist/esm/_shims → _shims}/getMultipartRequestOptions.d.ts +0 -0
- /package/{dist/esm/_shims → _shims}/getMultipartRequestOptions.node.d.ts +0 -0
- /package/{dist/esm/error.d.ts → error.d.ts} +0 -0
- /package/{dist/esm/resource.d.ts → resource.d.ts} +0 -0
- /package/{dist/cjs/resource.js → resource.js} +0 -0
- /package/{dist/esm/resources → resources}/index.d.ts +0 -0
- /package/{dist/cjs/resources → resources}/top-level.d.ts +0 -0
- /package/{dist/cjs/resources → resources}/top-level.js +0 -0
- /package/{error.ts → src/error.ts} +0 -0
- /package/{resource.ts → src/resource.ts} +0 -0
- /package/{resources → src/resources}/index.ts +0 -0
- /package/{resources → src/resources}/top-level.ts +0 -0
package/_shims/newFileArgs.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { type BlobPart, type Uploadable, isResponseLike, isBlobLike } from './uploadable';
|
|
6
|
-
|
|
7
|
-
export type ToFileInput = Uploadable | Exclude<BlobPart, string> | AsyncIterable<BlobPart>;
|
|
8
|
-
|
|
9
|
-
export type FilePropertyBag = {
|
|
10
|
-
type?: string;
|
|
11
|
-
lastModified?: number;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export async function newFileArgs(
|
|
15
|
-
value: ToFileInput,
|
|
16
|
-
name?: string | null,
|
|
17
|
-
options: FilePropertyBag = {},
|
|
18
|
-
): Promise<{
|
|
19
|
-
bits: BlobPart[];
|
|
20
|
-
name: string;
|
|
21
|
-
options: FilePropertyBag;
|
|
22
|
-
}> {
|
|
23
|
-
if (isResponseLike(value)) {
|
|
24
|
-
const blob = await value.blob();
|
|
25
|
-
name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file';
|
|
26
|
-
|
|
27
|
-
return { bits: [blob as any], name, options };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const bits = await getBytes(value);
|
|
31
|
-
|
|
32
|
-
name ||= getName(value) ?? 'unknown_file';
|
|
33
|
-
|
|
34
|
-
if (!options.type) {
|
|
35
|
-
const type = (bits[0] as any)?.type;
|
|
36
|
-
if (typeof type === 'string') {
|
|
37
|
-
options = { ...options, type };
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return { bits, name, options };
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function getBytes(value: ToFileInput): Promise<Array<BlobPart>> {
|
|
45
|
-
if (value instanceof Promise) return getBytes(await (value as any));
|
|
46
|
-
|
|
47
|
-
let parts: Array<BlobPart> = [];
|
|
48
|
-
if (
|
|
49
|
-
typeof value === 'string' ||
|
|
50
|
-
ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
|
|
51
|
-
value instanceof ArrayBuffer
|
|
52
|
-
) {
|
|
53
|
-
parts.push(value);
|
|
54
|
-
} else if (isBlobLike(value)) {
|
|
55
|
-
parts.push(await value.arrayBuffer());
|
|
56
|
-
} else if (
|
|
57
|
-
isAsyncIterableIterator(value) // includes Readable, ReadableStream, etc.
|
|
58
|
-
) {
|
|
59
|
-
for await (const chunk of value) {
|
|
60
|
-
parts.push(chunk as BlobPart); // TODO, consider validating?
|
|
61
|
-
}
|
|
62
|
-
} else {
|
|
63
|
-
throw new Error(
|
|
64
|
-
`Unexpected data type: ${typeof value}; constructor: ${
|
|
65
|
-
value?.constructor?.name
|
|
66
|
-
}; props: ${propsForError(value)}`,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return parts;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function propsForError(value: any): string {
|
|
74
|
-
const props = Object.getOwnPropertyNames(value);
|
|
75
|
-
return `[${props.map((p) => `"${p}"`).join(', ')}]`;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function getName(value: any): string | undefined {
|
|
79
|
-
return (
|
|
80
|
-
getStringFromMaybeBuffer(value.name) ||
|
|
81
|
-
getStringFromMaybeBuffer(value.filename) ||
|
|
82
|
-
// For fs.ReadStream
|
|
83
|
-
getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop()
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const getStringFromMaybeBuffer = (x: string | Buffer | unknown): string | undefined => {
|
|
88
|
-
if (typeof x === 'string') return x;
|
|
89
|
-
if (typeof Buffer !== 'undefined' && x instanceof Buffer) return String(x);
|
|
90
|
-
return undefined;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const isAsyncIterableIterator = (value: any): value is AsyncIterableIterator<unknown> =>
|
|
94
|
-
value != null && typeof value === 'object' && typeof value[Symbol.asyncIterator] === 'function';
|
package/_shims/toFile.node.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { File } from 'formdata-node';
|
|
6
|
-
import { type ToFileInput, newFileArgs, type FilePropertyBag } from './newFileArgs';
|
|
7
|
-
import type { Uploadable, BlobPart, FileLike } from './uploadable.node'; // eslint-disable-line
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
|
|
11
|
-
* @param bits the raw content of the file. Can be an {@link Uploadable}, {@link BlobPart}, or {@link AsyncIterable} of {@link BlobPart}s
|
|
12
|
-
* @param name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
|
|
13
|
-
* @param {Object=} options additional properties
|
|
14
|
-
* @param {string=} options.type the MIME type of the content
|
|
15
|
-
* @param {number=} options.lastModified the last modified timestamp
|
|
16
|
-
* @returns a {@link File} with the given properties
|
|
17
|
-
*/
|
|
18
|
-
export async function toFile(
|
|
19
|
-
bits: ToFileInput,
|
|
20
|
-
name?: string | null | undefined,
|
|
21
|
-
options: FilePropertyBag | undefined = {},
|
|
22
|
-
): Promise<FileLike> {
|
|
23
|
-
const args = await newFileArgs(bits, name, options);
|
|
24
|
-
return new File(args.bits, args.name, args.options);
|
|
25
|
-
}
|
package/_shims/toFile.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/// <reference lib="dom" />;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { type ToFileInput, newFileArgs, type FilePropertyBag } from './newFileArgs';
|
|
8
|
-
import type { FileLike, Uploadable } from './uploadable'; // eslint-disable-line
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
|
|
12
|
-
* @param bits the raw content of the file. Can be an {@link Uploadable}, {@link BlobPart}, or {@link AsyncIterable} of {@link BlobPart}s
|
|
13
|
-
* @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
|
|
14
|
-
* @param {Object=} options additional properties
|
|
15
|
-
* @param {string=} options.type the MIME type of the content
|
|
16
|
-
* @param {number=} options.lastModified the last modified timestamp
|
|
17
|
-
* @returns a {@link File} with the given properties
|
|
18
|
-
*/
|
|
19
|
-
export async function toFile(
|
|
20
|
-
bits: ToFileInput,
|
|
21
|
-
name?: string | null | undefined,
|
|
22
|
-
options: FilePropertyBag | undefined = {},
|
|
23
|
-
): Promise<FileLike> {
|
|
24
|
-
const args = await newFileArgs(bits, name, options);
|
|
25
|
-
return new File(args.bits as BlobPart[], args.name, args.options);
|
|
26
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { ReadStream } from 'node:fs';
|
|
6
|
-
import {
|
|
7
|
-
BlobPart,
|
|
8
|
-
Uploadable,
|
|
9
|
-
BlobLike,
|
|
10
|
-
FileLike,
|
|
11
|
-
ResponseLike,
|
|
12
|
-
isBlobLike,
|
|
13
|
-
isFileLike,
|
|
14
|
-
isResponseLike,
|
|
15
|
-
} from './uploadable';
|
|
16
|
-
|
|
17
|
-
export { BlobPart, BlobLike, FileLike, ResponseLike, isBlobLike, Uploadable };
|
|
18
|
-
|
|
19
|
-
export const isUploadable = (value: any): value is Uploadable => {
|
|
20
|
-
return isFileLike(value) || isResponseLike(value) || value instanceof ReadStream;
|
|
21
|
-
};
|
package/_shims/uploadable.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type * as fs from 'node:fs';
|
|
6
|
-
import type { toFile } from '@anthropic-ai/sdk/_shims/toFile'; // eslint-disable-line
|
|
7
|
-
|
|
8
|
-
export type BlobPart = string | ArrayBuffer | ArrayBufferView | BlobLike | Uint8Array | DataView;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Typically, this is a native "File" class.
|
|
12
|
-
*
|
|
13
|
-
* We provide the {@link toFile} utility to convert a variety of objects
|
|
14
|
-
* into the File class.
|
|
15
|
-
*
|
|
16
|
-
* For convenience, you can also pass a fetch Response
|
|
17
|
-
* or, on Node, the result of {@link fs.createReadStream}('./myfile').
|
|
18
|
-
*/
|
|
19
|
-
export type Uploadable = FileLike | ResponseLike | fs.ReadStream;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Intended to match web.Blob, node.Blob, node-fetch.Blob, etc.
|
|
23
|
-
*/
|
|
24
|
-
export interface BlobLike {
|
|
25
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */
|
|
26
|
-
readonly size: number;
|
|
27
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */
|
|
28
|
-
readonly type: string;
|
|
29
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */
|
|
30
|
-
text(): Promise<string>;
|
|
31
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
|
|
32
|
-
slice(start?: number, end?: number): BlobLike;
|
|
33
|
-
// unfortunately @types/node-fetch@^2.6.4 doesn't type the arrayBuffer method
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Intended to match web.File, node.File, node-fetch.File, etc.
|
|
38
|
-
*/
|
|
39
|
-
export interface FileLike extends BlobLike {
|
|
40
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */
|
|
41
|
-
readonly lastModified: number;
|
|
42
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */
|
|
43
|
-
readonly name: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Intended to match web.Response, node.Response, node-fetch.Response, etc.
|
|
48
|
-
*/
|
|
49
|
-
export interface ResponseLike {
|
|
50
|
-
url: string;
|
|
51
|
-
blob(): Promise<BlobLike>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export const isResponseLike = (value: any): value is ResponseLike =>
|
|
55
|
-
value != null &&
|
|
56
|
-
typeof value === 'object' &&
|
|
57
|
-
typeof value.url === 'string' &&
|
|
58
|
-
typeof value.blob === 'function';
|
|
59
|
-
|
|
60
|
-
export const isFileLike = (value: any): value is FileLike =>
|
|
61
|
-
value != null &&
|
|
62
|
-
typeof value === 'object' &&
|
|
63
|
-
typeof value.name === 'string' &&
|
|
64
|
-
typeof value.lastModified === 'number' &&
|
|
65
|
-
isBlobLike(value);
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* The BlobLike type omits arrayBuffer() because @types/node-fetch@^2.6.4 lacks it; but this check
|
|
69
|
-
* adds the arrayBuffer() method type because it is available and used at runtime
|
|
70
|
-
*/
|
|
71
|
-
export const isBlobLike = (value: any): value is BlobLike & { arrayBuffer(): Promise<ArrayBuffer> } =>
|
|
72
|
-
value != null &&
|
|
73
|
-
typeof value === 'object' &&
|
|
74
|
-
typeof value.size === 'number' &&
|
|
75
|
-
typeof value.type === 'string' &&
|
|
76
|
-
typeof value.text === 'function' &&
|
|
77
|
-
typeof value.slice === 'function' &&
|
|
78
|
-
typeof value.arrayBuffer === 'function';
|
|
79
|
-
|
|
80
|
-
export const isUploadable = (value: any): value is Uploadable => {
|
|
81
|
-
return isFileLike(value) || isResponseLike(value);
|
|
82
|
-
};
|
package/check-version.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
|
|
3
|
-
const main = () => {
|
|
4
|
-
const pkg = JSON.parse(fs.readFileSync('package.json').toString()) as Record<string, unknown>;
|
|
5
|
-
const version = pkg['version'];
|
|
6
|
-
if (!version) throw 'The version property is not set in the package.json file';
|
|
7
|
-
if (typeof version !== 'string') {
|
|
8
|
-
throw `Unexpected type for the package.json version field; got ${typeof version}, expected string`;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const contents = fs.readFileSync('version.ts', 'utf8');
|
|
12
|
-
const output = contents.replace(/(export const VERSION = ')(.*)(')/g, `$1${version}$3`);
|
|
13
|
-
fs.writeFileSync('version.ts', output);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
if (require.main === module) {
|
|
17
|
-
main();
|
|
18
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
|
-
*
|
|
4
|
-
* This is a stub for non-node environments.
|
|
5
|
-
* In node environments, it gets replaced agent.node.ts by the package export map
|
|
6
|
-
*/
|
|
7
|
-
import type { Agent } from 'node:http';
|
|
8
|
-
export declare const getDefaultAgent: (url: string) => Agent | undefined;
|
|
9
|
-
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../_shims/agent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,eAAO,MAAM,eAAe,QAAS,MAAM,KAAG,KAAK,GAAG,SAErD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../_shims/agent.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAII,MAAM,eAAe,GAAG,CAAC,GAAW,EAAqB,EAAE;IAChE,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.node.d.ts","sourceRoot":"","sources":["../../../_shims/agent.node.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAWvC,eAAO,MAAM,eAAe,QAAS,MAAM,KAAG,KAAK,GAAG,SAGrD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.node.js","sourceRoot":"","sources":["../../../_shims/agent.node.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;AAEH,oEAA4C;AAE5C,uDAA8E;AAE9E,MAAM,gBAAgB,GAAU,IAAI,wBAAc,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AAChG,MAAM,iBAAiB,GAAU,IAAI,wBAAc,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AAE5G,oCAAoC;AACpC,IAAI,OAAO,eAAe,KAAK,WAAW,EAAE;IAC1C,eAAe,GAAG,kCAAwD,CAAC;CAC5E;AAEM,MAAM,eAAe,GAAG,CAAC,GAAW,EAAqB,EAAE;IAChE,IAAI,iBAAiB,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,iBAAiB,CAAC;IAC3E,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAHW,QAAA,eAAe,mBAG1B"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
|
-
*/
|
|
4
|
-
import type * as nf from 'node-fetch';
|
|
5
|
-
declare const _fetch: typeof nf.default;
|
|
6
|
-
type _fetch = typeof nf.default;
|
|
7
|
-
declare const _Request: typeof nf.Request;
|
|
8
|
-
type _Request = nf.Request;
|
|
9
|
-
declare const _Response: typeof nf.Response;
|
|
10
|
-
type _Response = nf.Response;
|
|
11
|
-
declare const _Headers: typeof nf.Headers;
|
|
12
|
-
type _Headers = nf.Headers;
|
|
13
|
-
export declare const isPolyfilled = false;
|
|
14
|
-
export { _fetch as fetch, _Request as Request, _Response as Response, _Headers as Headers };
|
|
15
|
-
type _RequestInfo = nf.RequestInfo;
|
|
16
|
-
type _RequestInit = nf.RequestInit;
|
|
17
|
-
type _BodyInit = nf.BodyInit;
|
|
18
|
-
export type { _RequestInit as RequestInit, _RequestInfo as RequestInfo, _BodyInit as BodyInit };
|
|
19
|
-
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../_shims/fetch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtC,QAAA,MAAM,MAAM,EAAE,OAAO,EAAE,CAAC,OAEV,CAAC;AACf,KAAK,MAAM,GAAG,OAAO,EAAE,CAAC,OAAO,CAAC;AAChC,QAAA,MAAM,QAAQ,EAAE,OAAO,EAAE,CAAC,OAEV,CAAC;AACjB,KAAK,QAAQ,GAAG,EAAE,CAAC,OAAO,CAAC;AAC3B,QAAA,MAAM,SAAS,EAAE,OAAO,EAAE,CAAC,QAEV,CAAC;AAClB,KAAK,SAAS,GAAG,EAAE,CAAC,QAAQ,CAAC;AAC7B,QAAA,MAAM,QAAQ,EAAE,OAAO,EAAE,CAAC,OAEV,CAAC;AACjB,KAAK,QAAQ,GAAG,EAAE,CAAC,OAAO,CAAC;AAE3B,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,QAAQ,IAAI,OAAO,EAAE,SAAS,IAAI,QAAQ,EAAE,QAAQ,IAAI,OAAO,EAAE,CAAC;AAE5F,KAAK,YAAY,GAAG,EAAE,CAAC,WAAW,CAAC;AACnC,KAAK,YAAY,GAAG,EAAE,CAAC,WAAW,CAAC;AACnC,KAAK,SAAS,GAAG,EAAE,CAAC,QAAQ,CAAC;AAE7B,YAAY,EAAE,YAAY,IAAI,WAAW,EAAE,YAAY,IAAI,WAAW,EAAE,SAAS,IAAI,QAAQ,EAAE,CAAC"}
|
package/dist/cjs/_shims/fetch.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6
|
-
exports.Headers = exports.Response = exports.Request = exports.fetch = exports.isPolyfilled = void 0;
|
|
7
|
-
const _fetch =
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
fetch;
|
|
10
|
-
exports.fetch = _fetch;
|
|
11
|
-
const _Request =
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
Request;
|
|
14
|
-
exports.Request = _Request;
|
|
15
|
-
const _Response =
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
Response;
|
|
18
|
-
exports.Response = _Response;
|
|
19
|
-
const _Headers =
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
Headers;
|
|
22
|
-
exports.Headers = _Headers;
|
|
23
|
-
exports.isPolyfilled = false;
|
|
24
|
-
//# sourceMappingURL=fetch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../_shims/fetch.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAIH,MAAM,MAAM;AACV,aAAa;AACb,KAAY,CAAC;AAiBI,uBAAK;AAfxB,MAAM,QAAQ;AACZ,aAAa;AACb,OAAc,CAAC;AAaqB,2BAAO;AAX7C,MAAM,SAAS;AACb,aAAa;AACb,QAAe,CAAC;AAS0C,6BAAQ;AAPpE,MAAM,QAAQ;AACZ,aAAa;AACb,OAAc,CAAC;AAKiE,2BAAO;AAF5E,QAAA,YAAY,GAAG,KAAK,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
|
-
*/
|
|
4
|
-
import fetch, { Request, Response, Headers } from 'node-fetch';
|
|
5
|
-
import type { RequestInfo, RequestInit, BodyInit } from 'node-fetch';
|
|
6
|
-
export { fetch, Request, Response, Headers };
|
|
7
|
-
export type { RequestInfo, RequestInit, BodyInit };
|
|
8
|
-
export declare const isPolyfilled = true;
|
|
9
|
-
//# sourceMappingURL=fetch.node.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.node.d.ts","sourceRoot":"","sources":["../../../_shims/fetch.node.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;AAEnD,eAAO,MAAM,YAAY,OAAO,CAAC"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
4
|
-
*/
|
|
5
|
-
var __createBinding =
|
|
6
|
-
(this && this.__createBinding) ||
|
|
7
|
-
(Object.create ?
|
|
8
|
-
function (o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return m[k];
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}
|
|
21
|
-
: function (o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
});
|
|
25
|
-
var __setModuleDefault =
|
|
26
|
-
(this && this.__setModuleDefault) ||
|
|
27
|
-
(Object.create ?
|
|
28
|
-
function (o, v) {
|
|
29
|
-
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
30
|
-
}
|
|
31
|
-
: function (o, v) {
|
|
32
|
-
o['default'] = v;
|
|
33
|
-
});
|
|
34
|
-
var __importStar =
|
|
35
|
-
(this && this.__importStar) ||
|
|
36
|
-
function (mod) {
|
|
37
|
-
if (mod && mod.__esModule) return mod;
|
|
38
|
-
var result = {};
|
|
39
|
-
if (mod != null)
|
|
40
|
-
for (var k in mod)
|
|
41
|
-
if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
42
|
-
__setModuleDefault(result, mod);
|
|
43
|
-
return result;
|
|
44
|
-
};
|
|
45
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
46
|
-
exports.isPolyfilled = exports.Headers = exports.Response = exports.Request = exports.fetch = void 0;
|
|
47
|
-
const node_fetch_1 = __importStar(require('node-fetch'));
|
|
48
|
-
exports.fetch = node_fetch_1.default;
|
|
49
|
-
Object.defineProperty(exports, 'Request', {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
get: function () {
|
|
52
|
-
return node_fetch_1.Request;
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(exports, 'Response', {
|
|
56
|
-
enumerable: true,
|
|
57
|
-
get: function () {
|
|
58
|
-
return node_fetch_1.Response;
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
Object.defineProperty(exports, 'Headers', {
|
|
62
|
-
enumerable: true,
|
|
63
|
-
get: function () {
|
|
64
|
-
return node_fetch_1.Headers;
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
exports.isPolyfilled = true;
|
|
68
|
-
//# sourceMappingURL=fetch.node.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.node.js","sourceRoot":"","sources":["../../../_shims/fetch.node.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yDAA+D;AAGtD,gBAHF,oBAAK,CAGE;AAAE,wFAHA,oBAAO,OAGA;AAAE,yFAHA,qBAAQ,OAGA;AAAE,wFAHA,oBAAO,OAGA;AAG7B,QAAA,YAAY,GAAG,IAAI,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fileFromPath.d.ts","sourceRoot":"","sources":["../../../_shims/fileFromPath.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;AAExE;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAChE,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACnF,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAC/F,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
4
|
-
*
|
|
5
|
-
* This is a stub that gets replaced by fileFromPath.node.js for node environments
|
|
6
|
-
* in the package export map
|
|
7
|
-
*/
|
|
8
|
-
var __awaiter =
|
|
9
|
-
(this && this.__awaiter) ||
|
|
10
|
-
function (thisArg, _arguments, P, generator) {
|
|
11
|
-
function adopt(value) {
|
|
12
|
-
return value instanceof P ? value : (
|
|
13
|
-
new P(function (resolve) {
|
|
14
|
-
resolve(value);
|
|
15
|
-
})
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) {
|
|
20
|
-
try {
|
|
21
|
-
step(generator.next(value));
|
|
22
|
-
} catch (e) {
|
|
23
|
-
reject(e);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function rejected(value) {
|
|
27
|
-
try {
|
|
28
|
-
step(generator['throw'](value));
|
|
29
|
-
} catch (e) {
|
|
30
|
-
reject(e);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function step(result) {
|
|
34
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
35
|
-
}
|
|
36
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
40
|
-
exports.fileFromPath = void 0;
|
|
41
|
-
function fileFromPath() {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
throw new Error(
|
|
44
|
-
'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/anthropics/anthropic-sdk-typescript#file-uploads',
|
|
45
|
-
);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
exports.fileFromPath = fileFromPath;
|
|
49
|
-
//# sourceMappingURL=fileFromPath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fileFromPath.js","sourceRoot":"","sources":["../../../_shims/fileFromPath.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;AAoBH,SAAsB,YAAY;;QAChC,MAAM,IAAI,KAAK,CACb,iKAAiK,CAClK,CAAC;IACJ,CAAC;CAAA;AAJD,oCAIC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fileFromPath.node.d.ts","sourceRoot":"","sources":["../../../_shims/fileFromPath.node.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;AAIxE;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAChE,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACnF,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAC/F,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
4
|
-
*/
|
|
5
|
-
var __awaiter =
|
|
6
|
-
(this && this.__awaiter) ||
|
|
7
|
-
function (thisArg, _arguments, P, generator) {
|
|
8
|
-
function adopt(value) {
|
|
9
|
-
return value instanceof P ? value : (
|
|
10
|
-
new P(function (resolve) {
|
|
11
|
-
resolve(value);
|
|
12
|
-
})
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) {
|
|
17
|
-
try {
|
|
18
|
-
step(generator.next(value));
|
|
19
|
-
} catch (e) {
|
|
20
|
-
reject(e);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function rejected(value) {
|
|
24
|
-
try {
|
|
25
|
-
step(generator['throw'](value));
|
|
26
|
-
} catch (e) {
|
|
27
|
-
reject(e);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function step(result) {
|
|
31
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
32
|
-
}
|
|
33
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
37
|
-
exports.fileFromPath = void 0;
|
|
38
|
-
const file_from_path_1 = require('formdata-node/file-from-path');
|
|
39
|
-
let warned = false;
|
|
40
|
-
function fileFromPath(path, ...args) {
|
|
41
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
if (!warned) {
|
|
43
|
-
console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path)}) instead`);
|
|
44
|
-
warned = true;
|
|
45
|
-
}
|
|
46
|
-
return yield (0, file_from_path_1.fileFromPath)(path, ...args);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
exports.fileFromPath = fileFromPath;
|
|
50
|
-
//# sourceMappingURL=fileFromPath.node.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fileFromPath.node.js","sourceRoot":"","sources":["../../../_shims/fileFromPath.node.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;AAGH,iEAA6E;AAK7E,IAAI,MAAM,GAAG,KAAK,CAAC;AAanB,SAAsB,YAAY,CAAC,IAAY,EAAE,GAAG,IAAW;;QAC7D,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,CAAC,IAAI,CAAC,uDAAuD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACrG,MAAM,GAAG,IAAI,CAAC;SACf;QACD,OAAO,MAAM,IAAA,6BAAa,EAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5C,CAAC;CAAA;AAND,oCAMC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
|
-
*/
|
|
4
|
-
import type * as fd from 'formdata-node';
|
|
5
|
-
declare const _FormData: typeof fd.FormData;
|
|
6
|
-
type _FormData = fd.FormData;
|
|
7
|
-
declare const _File: typeof fd.File;
|
|
8
|
-
type _File = fd.File;
|
|
9
|
-
declare const _Blob: typeof fd.Blob;
|
|
10
|
-
type _Blob = fd.Blob;
|
|
11
|
-
export declare const isPolyfilled = false;
|
|
12
|
-
export { _FormData as FormData, _File as File, _Blob as Blob };
|
|
13
|
-
//# sourceMappingURL=formdata.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formdata.d.ts","sourceRoot":"","sources":["../../../_shims/formdata.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAEzC,QAAA,MAAM,SAAS,EAAE,OAAO,EAAE,CAAC,QAEV,CAAC;AAClB,KAAK,SAAS,GAAG,EAAE,CAAC,QAAQ,CAAC;AAC7B,QAAA,MAAM,KAAK,EAAE,OAAO,EAAE,CAAC,IAEV,CAAC;AACd,KAAK,KAAK,GAAG,EAAE,CAAC,IAAI,CAAC;AACrB,QAAA,MAAM,KAAK,EAAE,OAAO,EAAE,CAAC,IAEV,CAAC;AACd,KAAK,KAAK,GAAG,EAAE,CAAC,IAAI,CAAC;AAErB,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,OAAO,EAAE,SAAS,IAAI,QAAQ,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6
|
-
exports.Blob = exports.File = exports.FormData = exports.isPolyfilled = void 0;
|
|
7
|
-
const _FormData =
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
FormData;
|
|
10
|
-
exports.FormData = _FormData;
|
|
11
|
-
const _File =
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
File;
|
|
14
|
-
exports.File = _File;
|
|
15
|
-
const _Blob =
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
Blob;
|
|
18
|
-
exports.Blob = _Blob;
|
|
19
|
-
exports.isPolyfilled = false;
|
|
20
|
-
//# sourceMappingURL=formdata.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formdata.js","sourceRoot":"","sources":["../../../_shims/formdata.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAIH,MAAM,SAAS;AACb,aAAa;AACb,QAAe,CAAC;AAaI,6BAAQ;AAX9B,MAAM,KAAK;AACT,aAAa;AACb,IAAW,CAAC;AAS2B,qBAAI;AAP7C,MAAM,KAAK;AACT,aAAa;AACb,IAAW,CAAC;AAK0C,qBAAI;AAF/C,QAAA,YAAY,GAAG,KAAK,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
|
-
*/
|
|
4
|
-
import { FormData, File, Blob } from 'formdata-node';
|
|
5
|
-
export { FormData, File, Blob };
|
|
6
|
-
export declare const isPolyfilled = true;
|
|
7
|
-
//# sourceMappingURL=formdata.node.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formdata.node.d.ts","sourceRoot":"","sources":["../../../_shims/formdata.node.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAEhC,eAAO,MAAM,YAAY,OAAO,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6
|
-
exports.isPolyfilled = exports.Blob = exports.File = exports.FormData = void 0;
|
|
7
|
-
const formdata_node_1 = require('formdata-node');
|
|
8
|
-
Object.defineProperty(exports, 'FormData', {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function () {
|
|
11
|
-
return formdata_node_1.FormData;
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(exports, 'File', {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () {
|
|
17
|
-
return formdata_node_1.File;
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(exports, 'Blob', {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () {
|
|
23
|
-
return formdata_node_1.Blob;
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
exports.isPolyfilled = true;
|
|
27
|
-
//# sourceMappingURL=formdata.node.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formdata.node.js","sourceRoot":"","sources":["../../../_shims/formdata.node.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iDAAqD;AAE5C,yFAFA,wBAAQ,OAEA;AAAE,qFAFA,oBAAI,OAEA;AAAE,qFAFA,oBAAI,OAEA;AAEhB,QAAA,YAAY,GAAG,IAAI,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
|
-
*/
|
|
4
|
-
import { FormData } from './formdata';
|
|
5
|
-
import type { RequestOptions } from '../core';
|
|
6
|
-
export declare function getMultipartRequestOptions<T extends {} = Record<string, unknown>>(
|
|
7
|
-
form: FormData,
|
|
8
|
-
opts: RequestOptions<T>,
|
|
9
|
-
): Promise<RequestOptions<T>>;
|
|
10
|
-
//# sourceMappingURL=getMultipartRequestOptions.d.ts.map
|