/
opt
/
canhelp
/
node_modules
/
openai
/
internal
/
/opt/canhelp/node_modules/openai/internal
mkdir
upload
Name
Size
Mode
Actions
decoders/
-
0755
rm
qs/
-
0755
rm
utils/
-
0755
rm
builtin-types.d.mts
2847
0644
edit
dl
rm
builtin-types.d.mts.map
1099
0644
edit
dl
rm
builtin-types.d.ts
2846
0644
edit
dl
rm
builtin-types.d.ts.map
1098
0644
edit
dl
rm
builtin-types.js
205
0644
edit
dl
rm
builtin-types.js.map
139
0644
edit
dl
rm
builtin-types.mjs
140
0644
edit
dl
rm
builtin-types.mjs.map
139
0644
edit
dl
rm
detect-platform.d.mts
749
0644
edit
dl
rm
detect-platform.d.mts.map
736
0644
edit
dl
rm
detect-platform.d.ts
748
0644
edit
dl
rm
detect-platform.d.ts.map
735
0644
edit
dl
rm
detect-platform.js
6200
0644
edit
dl
rm
detect-platform.js.map
4417
0644
edit
dl
rm
detect-platform.mjs
5922
0644
edit
dl
rm
detect-platform.mjs.map
4390
0644
edit
dl
rm
errors.d.mts
153
0644
edit
dl
rm
errors.d.mts.map
210
0644
edit
dl
rm
errors.d.ts
152
0644
edit
dl
rm
errors.d.ts.map
209
0644
edit
dl
rm
errors.js
1539
0644
edit
dl
rm
errors.js.map
1370
0644
edit
dl
rm
errors.mjs
1375
0644
edit
dl
rm
errors.mjs.map
1348
0644
edit
dl
rm
headers.d.mts
917
0644
edit
dl
rm
headers.d.mts.map
648
0644
edit
dl
rm
headers.d.ts
916
0644
edit
dl
rm
headers.d.ts.map
647
0644
edit
dl
rm
headers.js
2745
0644
edit
dl
rm
headers.js.map
2523
0644
edit
dl
rm
headers.mjs
2528
0644
edit
dl
rm
headers.mjs.map
2491
0644
edit
dl
rm
parse.d.mts
796
0644
edit
dl
rm
parse.d.mts.map
851
0644
edit
dl
rm
parse.d.ts
792
0644
edit
dl
rm
parse.d.ts.map
850
0644
edit
dl
rm
parse.js
2685
0644
edit
dl
rm
parse.js.map
2240
0644
edit
dl
rm
parse.mjs
2509
0644
edit
dl
rm
parse.mjs.map
2239
0644
edit
dl
rm
request-options.d.mts
2519
0644
edit
dl
rm
request-options.d.mts.map
1361
0644
edit
dl
rm
request-options.d.ts
2513
0644
edit
dl
rm
request-options.d.ts.map
1360
0644
edit
dl
rm
request-options.js
474
0644
edit
dl
rm
request-options.js.map
355
0644
edit
dl
rm
request-options.mjs
328
0644
edit
dl
rm
request-options.mjs.map
341
0644
edit
dl
rm
shim-types.d.mts
873
0644
edit
dl
rm
shim-types.d.mts.map
852
0644
edit
dl
rm
shim-types.d.ts
872
0644
edit
dl
rm
shim-types.d.ts.map
851
0644
edit
dl
rm
shim-types.js
202
0644
edit
dl
rm
shim-types.js.map
133
0644
edit
dl
rm
shim-types.mjs
137
0644
edit
dl
rm
shim-types.mjs.map
133
0644
edit
dl
rm
shims.d.mts
1051
0644
edit
dl
rm
shims.d.mts.map
614
0644
edit
dl
rm
shims.d.ts
1048
0644
edit
dl
rm
shims.d.ts.map
613
0644
edit
dl
rm
shims.js
3431
0644
edit
dl
rm
shims.js.map
2271
0644
edit
dl
rm
shims.mjs
3125
0644
edit
dl
rm
shims.mjs.map
2238
0644
edit
dl
rm
stream-utils.d.mts
428
0644
edit
dl
rm
stream-utils.d.mts.map
224
0644
edit
dl
rm
stream-utils.d.ts
427
0644
edit
dl
rm
stream-utils.d.ts.map
223
0644
edit
dl
rm
stream-utils.js
1338
0644
edit
dl
rm
stream-utils.js.map
868
0644
edit
dl
rm
stream-utils.mjs
1198
0644
edit
dl
rm
stream-utils.mjs.map
858
0644
edit
dl
rm
to-file.d.mts
2216
0644
edit
dl
rm
to-file.d.mts.map
1048
0644
edit
dl
rm
to-file.d.ts
2214
0644
edit
dl
rm
to-file.d.ts.map
1047
0644
edit
dl
rm
to-file.js
3721
0644
edit
dl
rm
to-file.js.map
3080
0644
edit
dl
rm
to-file.mjs
3569
0644
edit
dl
rm
to-file.mjs.map
3078
0644
edit
dl
rm
tslib.js
3089
0644
edit
dl
rm
tslib.mjs
1080
0644
edit
dl
rm
types.d.mts
6231
0644
edit
dl
rm
types.d.mts.map
3657
0644
edit
dl
rm
types.d.ts
6230
0644
edit
dl
rm
types.d.ts.map
3656
0644
edit
dl
rm
types.js
197
0644
edit
dl
rm
types.js.map
123
0644
edit
dl
rm
types.mjs
132
0644
edit
dl
rm
types.mjs.map
123
0644
edit
dl
rm
uploads.d.mts
1926
0644
edit
dl
rm
uploads.d.mts.map
1312
0644
edit
dl
rm
uploads.d.ts
1922
0644
edit
dl
rm
uploads.d.ts.map
1311
0644
edit
dl
rm
uploads.js
6151
0644
edit
dl
rm
uploads.js.map
5384
0644
edit
dl
rm
uploads.mjs
5573
0644
edit
dl
rm
uploads.mjs.map
5276
0644
edit
dl
rm
utils.d.mts
278
0644
edit
dl
rm
utils.d.mts.map
114
0644
edit
dl
rm
utils.d.ts
270
0644
edit
dl
rm
utils.d.ts.map
113
0644
edit
dl
rm
utils.js
653
0644
edit
dl
rm
utils.js.map
216
0644
edit
dl
rm
utils.mjs
363
0644
edit
dl
rm
utils.mjs.map
123
0644
edit
dl
rm
Edit:
/opt/canhelp/node_modules/openai/internal/uploads.js
(6151B)
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createForm = exports.multipartFormRequestOptions = exports.maybeMultipartFormRequestOptions = exports.isAsyncIterable = exports.checkFileSupport = void 0; exports.makeFile = makeFile; exports.getName = getName; const shims_1 = require("./shims.js"); const checkFileSupport = () => { if (typeof File === 'undefined') { const { process } = globalThis; const isOldNode = typeof process?.versions?.node === 'string' && parseInt(process.versions.node.split('.')) < 20; throw new Error('`File` is not defined as a global, which is required for file uploads.' + (isOldNode ? " Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`." : '')); } }; exports.checkFileSupport = checkFileSupport; /** * Construct a `File` instance. This is used to ensure a helpful error is thrown * for environments that don't define a global `File` yet. */ function makeFile(fileBits, fileName, options) { (0, exports.checkFileSupport)(); return new File(fileBits, fileName ?? 'unknown_file', options); } function getName(value) { return (((typeof value === 'object' && value !== null && (('name' in value && value.name && String(value.name)) || ('url' in value && value.url && String(value.url)) || ('filename' in value && value.filename && String(value.filename)) || ('path' in value && value.path && String(value.path)))) || '') .split(/[\\/]/) .pop() || undefined); } const isAsyncIterable = (value) => value != null && typeof value === 'object' && typeof value[Symbol.asyncIterator] === 'function'; exports.isAsyncIterable = isAsyncIterable; /** * Returns a multipart/form-data request if any part of the given request body contains a File / Blob value. * Otherwise returns the request as is. */ const maybeMultipartFormRequestOptions = async (opts, fetch) => { if (!hasUploadableValue(opts.body)) return opts; return { ...opts, body: await (0, exports.createForm)(opts.body, fetch) }; }; exports.maybeMultipartFormRequestOptions = maybeMultipartFormRequestOptions; const multipartFormRequestOptions = async (opts, fetch) => { return { ...opts, body: await (0, exports.createForm)(opts.body, fetch) }; }; exports.multipartFormRequestOptions = multipartFormRequestOptions; const supportsFormDataMap = /* @__PURE__ */ new WeakMap(); /** * node-fetch doesn't support the global FormData object in recent node versions. Instead of sending * properly-encoded form data, it just stringifies the object, resulting in a request body of "[object FormData]". * This function detects if the fetch function provided supports the global FormData object to avoid * confusing error messages later on. */ function supportsFormData(fetchObject) { const fetch = typeof fetchObject === 'function' ? fetchObject : fetchObject.fetch; const cached = supportsFormDataMap.get(fetch); if (cached) return cached; const promise = (async () => { try { const FetchResponse = ('Response' in fetch ? fetch.Response : (await fetch('data:,')).constructor); const data = new FormData(); if (data.toString() === (await new FetchResponse(data).text())) { return false; } return true; } catch { // avoid false negatives return true; } })(); supportsFormDataMap.set(fetch, promise); return promise; } const createForm = async (body, fetch) => { if (!(await supportsFormData(fetch))) { throw new TypeError('The provided fetch function does not support file uploads with the current global FormData class.'); } const form = new FormData(); await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value))); return form; }; exports.createForm = createForm; // We check for Blob not File because Bun.File doesn't inherit from File, // but they both inherit from Blob and have a `name` property at runtime. const isNamedBlob = (value) => value instanceof Blob && 'name' in value; const isUploadable = (value) => typeof value === 'object' && value !== null && (value instanceof Response || (0, exports.isAsyncIterable)(value) || isNamedBlob(value)); const hasUploadableValue = (value) => { if (isUploadable(value)) return true; if (Array.isArray(value)) return value.some(hasUploadableValue); if (value && typeof value === 'object') { for (const k in value) { if (hasUploadableValue(value[k])) return true; } } return false; }; const addFormValue = async (form, key, value) => { if (value === undefined) return; if (value == null) { throw new TypeError(`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`); } // TODO: make nested formats configurable if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { form.append(key, String(value)); } else if (value instanceof Response) { form.append(key, makeFile([await value.blob()], getName(value))); } else if ((0, exports.isAsyncIterable)(value)) { form.append(key, makeFile([await new Response((0, shims_1.ReadableStreamFrom)(value)).blob()], getName(value))); } else if (isNamedBlob(value)) { form.append(key, value, getName(value)); } else if (Array.isArray(value)) { await Promise.all(value.map((entry) => addFormValue(form, key + '[]', entry))); } else if (typeof value === 'object') { await Promise.all(Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop))); } else { throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`); } }; //# sourceMappingURL=uploads.js.map
Save
cmd:
run