diff --git a/_shims/fetch.node.ts b/_shims/fetch.node.ts deleted file mode 100644 index 3bb8a610..00000000 --- a/_shims/fetch.node.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Disclaimer: modules in _shims aren't intended to be imported by SDK users. - */ - -import fetch, { Request, Response, Headers } from 'node-fetch'; -import type { RequestInfo, RequestInit, BodyInit } from 'node-fetch'; - -export { fetch, Request, Response, Headers }; -export type { RequestInfo, RequestInit, BodyInit }; - -export const isPolyfilled = true; diff --git a/_shims/fetch.ts b/_shims/fetch.ts deleted file mode 100644 index 638fb6fa..00000000 --- a/_shims/fetch.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Disclaimer: modules in _shims aren't intended to be imported by SDK users. - */ - -import type * as nf from 'node-fetch'; - -const _fetch: typeof nf.default = - // @ts-ignore - fetch as any; -type _fetch = typeof nf.default; -const _Request: typeof nf.Request = - // @ts-ignore - Request as any; -type _Request = nf.Request; -const _Response: typeof nf.Response = - // @ts-ignore - Response as any; -type _Response = nf.Response; -const _Headers: typeof nf.Headers = - // @ts-ignore - Headers as any; -type _Headers = nf.Headers; - -export const isPolyfilled = false; - -export { _fetch as fetch, _Request as Request, _Response as Response, _Headers as Headers }; - -type _RequestInfo = nf.RequestInfo; -type _RequestInit = nf.RequestInit; -type _BodyInit = nf.BodyInit; - -export type { _RequestInit as RequestInit, _RequestInfo as RequestInfo, _BodyInit as BodyInit }; diff --git a/_shims/formdata.ts b/_shims/formdata.ts deleted file mode 100644 index 862da725..00000000 --- a/_shims/formdata.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Disclaimer: modules in _shims aren't intended to be imported by SDK users. - */ - -import type * as fd from 'formdata-node'; - -const _FormData: typeof fd.FormData = - // @ts-ignore - FormData as any; -type _FormData = fd.FormData; -const _File: typeof fd.File = - // @ts-ignore - File as any; -type _File = fd.File; -const _Blob: typeof fd.Blob = - // @ts-ignore - Blob as any; -type _Blob = fd.Blob; - -export const isPolyfilled = false; - -export { _FormData as FormData, _File as File, _Blob as Blob }; diff --git a/_shims/newFileArgs.ts b/_shims/newFileArgs.ts deleted file mode 100644 index af7041d2..00000000 --- a/_shims/newFileArgs.ts +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Disclaimer: modules in _shims aren't intended to be imported by SDK users. - */ - -import { type BlobPart, type Uploadable, isResponseLike, isBlobLike } from './uploadable'; - -export type ToFileInput = Uploadable | Exclude | AsyncIterable; - -export type FilePropertyBag = { - type?: string; - lastModified?: number; -}; - -export async function newFileArgs( - value: ToFileInput, - name?: string | null, - options: FilePropertyBag = {}, -): Promise<{ - bits: BlobPart[]; - name: string; - options: FilePropertyBag; -}> { - if (isResponseLike(value)) { - const blob = await value.blob(); - name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file'; - - return { bits: [blob as any], name, options }; - } - - const bits = await getBytes(value); - - name ||= getName(value) ?? 'unknown_file'; - - if (!options.type) { - const type = (bits[0] as any)?.type; - if (typeof type === 'string') { - options = { ...options, type }; - } - } - - return { bits, name, options }; -} - -async function getBytes(value: ToFileInput): Promise> { - if (value instanceof Promise) return getBytes(await (value as any)); - - let parts: Array = []; - if ( - typeof value === 'string' || - ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc. - value instanceof ArrayBuffer - ) { - parts.push(value); - } else if (isBlobLike(value)) { - parts.push(await value.arrayBuffer()); - } else if ( - isAsyncIterableIterator(value) // includes Readable, ReadableStream, etc. - ) { - for await (const chunk of value) { - parts.push(chunk as BlobPart); // TODO, consider validating? - } - } else { - throw new Error( - `Unexpected data type: ${typeof value}; constructor: ${ - value?.constructor?.name - }; props: ${propsForError(value)}`, - ); - } - - return parts; -} - -function propsForError(value: any): string { - const props = Object.getOwnPropertyNames(value); - return `[${props.map((p) => `"${p}"`).join(', ')}]`; -} - -function getName(value: any): string | undefined { - return ( - getStringFromMaybeBuffer(value.name) || - getStringFromMaybeBuffer(value.filename) || - // For fs.ReadStream - getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop() - ); -} - -const getStringFromMaybeBuffer = (x: string | Buffer | unknown): string | undefined => { - if (typeof x === 'string') return x; - if (typeof Buffer !== 'undefined' && x instanceof Buffer) return String(x); - return undefined; -}; - -const isAsyncIterableIterator = (value: any): value is AsyncIterableIterator => - value != null && typeof value === 'object' && typeof value[Symbol.asyncIterator] === 'function'; diff --git a/_shims/toFile.node.ts b/_shims/toFile.node.ts deleted file mode 100644 index 82a7cc77..00000000 --- a/_shims/toFile.node.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Disclaimer: modules in _shims aren't intended to be imported by SDK users. - */ - -import { File } from 'formdata-node'; -import { type ToFileInput, newFileArgs, type FilePropertyBag } from './newFileArgs'; -import type { Uploadable, BlobPart, FileLike } from './uploadable.node'; // eslint-disable-line - -/** - * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats - * @param bits the raw content of the file. Can be an {@link Uploadable}, {@link BlobPart}, or {@link AsyncIterable} of {@link BlobPart}s - * @param name the name of the file. If omitted, toFile will try to determine a file name from bits if possible - * @param {Object=} options additional properties - * @param {string=} options.type the MIME type of the content - * @param {number=} options.lastModified the last modified timestamp - * @returns a {@link File} with the given properties - */ -export async function toFile( - bits: ToFileInput, - name?: string | null | undefined, - options: FilePropertyBag | undefined = {}, -): Promise { - const args = await newFileArgs(bits, name, options); - return new File(args.bits, args.name, args.options); -} diff --git a/_shims/toFile.ts b/_shims/toFile.ts deleted file mode 100644 index 7490d0f1..00000000 --- a/_shims/toFile.ts +++ /dev/null @@ -1,26 +0,0 @@ -/// ; - -/** - * Disclaimer: modules in _shims aren't intended to be imported by SDK users. - */ - -import { type ToFileInput, newFileArgs, type FilePropertyBag } from './newFileArgs'; -import type { FileLike, Uploadable } from './uploadable'; // eslint-disable-line - -/** - * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats - * @param bits the raw content of the file. Can be an {@link Uploadable}, {@link BlobPart}, or {@link AsyncIterable} of {@link BlobPart}s - * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible - * @param {Object=} options additional properties - * @param {string=} options.type the MIME type of the content - * @param {number=} options.lastModified the last modified timestamp - * @returns a {@link File} with the given properties - */ -export async function toFile( - bits: ToFileInput, - name?: string | null | undefined, - options: FilePropertyBag | undefined = {}, -): Promise { - const args = await newFileArgs(bits, name, options); - return new File(args.bits as BlobPart[], args.name, args.options); -} diff --git a/_shims/uploadable.node.ts b/_shims/uploadable.node.ts deleted file mode 100644 index 78c4c362..00000000 --- a/_shims/uploadable.node.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Disclaimer: modules in _shims aren't intended to be imported by SDK users. - */ - -import { ReadStream } from 'node:fs'; -import { - BlobPart, - Uploadable, - BlobLike, - FileLike, - ResponseLike, - isBlobLike, - isFileLike, - isResponseLike, -} from './uploadable'; - -export { BlobPart, BlobLike, FileLike, ResponseLike, isBlobLike, Uploadable }; - -export const isUploadable = (value: any): value is Uploadable => { - return isFileLike(value) || isResponseLike(value) || value instanceof ReadStream; -}; diff --git a/_shims/uploadable.ts b/_shims/uploadable.ts deleted file mode 100644 index 2f49a8b4..00000000 --- a/_shims/uploadable.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Disclaimer: modules in _shims aren't intended to be imported by SDK users. - */ - -import type * as fs from 'node:fs'; -import type { toFile } from 'modern-treasury/_shims/toFile'; // eslint-disable-line - -export type BlobPart = string | ArrayBuffer | ArrayBufferView | BlobLike | Uint8Array | DataView; - -/** - * Typically, this is a native "File" class. - * - * We provide the {@link toFile} utility to convert a variety of objects - * into the File class. - * - * For convenience, you can also pass a fetch Response - * or, on Node, the result of {@link fs.createReadStream}('./myfile'). - */ -export type Uploadable = FileLike | ResponseLike | fs.ReadStream; - -/** - * Intended to match web.Blob, node.Blob, node-fetch.Blob, etc. - */ -export interface BlobLike { - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */ - readonly size: number; - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */ - readonly type: string; - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */ - text(): Promise; - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */ - slice(start?: number, end?: number): BlobLike; - // unfortunately @types/node-fetch@^2.6.4 doesn't type the arrayBuffer method -} - -/** - * Intended to match web.File, node.File, node-fetch.File, etc. - */ -export interface FileLike extends BlobLike { - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */ - readonly lastModified: number; - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */ - readonly name: string; -} - -/** - * Intended to match web.Response, node.Response, node-fetch.Response, etc. - */ -export interface ResponseLike { - url: string; - blob(): Promise; -} - -export const isResponseLike = (value: any): value is ResponseLike => - value != null && - typeof value === 'object' && - typeof value.url === 'string' && - typeof value.blob === 'function'; - -export const isFileLike = (value: any): value is FileLike => - value != null && - typeof value === 'object' && - typeof value.name === 'string' && - typeof value.lastModified === 'number' && - isBlobLike(value); - -/** - * The BlobLike type omits arrayBuffer() because @types/node-fetch@^2.6.4 lacks it; but this check - * adds the arrayBuffer() method type because it is available and used at runtime - */ -export const isBlobLike = (value: any): value is BlobLike & { arrayBuffer(): Promise } => - value != null && - typeof value === 'object' && - typeof value.size === 'number' && - typeof value.type === 'string' && - typeof value.text === 'function' && - typeof value.slice === 'function' && - typeof value.arrayBuffer === 'function'; - -export const isUploadable = (value: any): value is Uploadable => { - return isFileLike(value) || isResponseLike(value); -}; diff --git a/bin/publish-npm b/bin/publish-npm index c8eb6166..80b75040 100644 --- a/bin/publish-npm +++ b/bin/publish-npm @@ -3,4 +3,7 @@ set -eux npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN -yarn publish --build --access public \ No newline at end of file + +yarn build +cd dist +yarn publish --access public \ No newline at end of file diff --git a/build b/build index 9e837884..96030e02 100755 --- a/build +++ b/build @@ -1,24 +1,50 @@ #!/usr/bin/env bash set -exuo pipefail -rm -rf dist/* +node scripts/check-version.cjs -yarn ts-node --transpileOnly check-version.ts +# Build into dist and will publish the package from there, +# so that src/resources/foo.ts becomes /resources/foo.js +# This way importing from `"modern-treasury/resources/foo"` works +# even with `"moduleResolution": "node"` -# build node: -node scripts/prepare-cjs-build.mjs -yarn tsc -p tsconfig.cjs.json -yarn tsc-alias -p tsconfig.cjs.json +rm -rf dist +mkdir dist +# Copy src to dist/src and build from dist/src into dist, so that +# the source map for index.js.map will refer to ./src/index.ts etc +cp -rp src dist +# this converts the export map paths for the dist directory +# and does a few other minor things +node scripts/make-dist-package-json.cjs > dist/package.json -node scripts/prepare-esm-build.mjs -yarn tsc -p tsconfig.esm.json -yarn tsc-alias -p tsconfig.esm.json --resolve-full-paths true +# build to .js/.mjs/.d.ts files +tsc-multi +# copy over handwritten .js/.mjs/.d.ts files +cp src/_shims/*.{d.ts,js,mjs} dist/_shims +tsc-alias -p tsconfig.json --resolve-full-paths +# we need to add exports = module.exports = Modern Treasury Node to index.js; +# No way to get that from index.ts because it would cause compile errors +# when building .mjs +node scripts/fix-index-exports.cjs +# with "moduleResolution": "nodenext", if ESM resolves to index.d.ts, +# it'll have TS errors on the default import. But if it resolves to +# index.d.mts the default import will work (even though both files have +# the same export default statement) +cp dist/index.d.ts dist/index.d.mts -echo '{"type": "module"}' > dist/esm/package.json +# strip out lib="dom" and types="node" references; these are needed at build time, +# but would pollute the user's TS environment +REFERENCE_SUBS='s/^ *\/\/\/ */$1', - '^modern-treasury/_shims/(.*)$': '/_shims/$1.node', + '^modern-treasury$': '/src/index.ts', + '^modern-treasury/_shims/(.*)$': '/src/_shims/$1.node', + '^modern-treasury/(.*)$': '/src/$1', }, - modulePathIgnorePatterns: ['/ecosystem-tests/'], + modulePathIgnorePatterns: ['/ecosystem-tests/', '/dist/'], }; diff --git a/package.json b/package.json index 879e5ff9..d8d33554 100644 --- a/package.json +++ b/package.json @@ -3,96 +3,70 @@ "version": "1.7.0", "description": "Client library for the ModernTreasury API", "author": "Modern Treasury ", - "types": "dist/cjs/index.d.ts", - "main": "dist/cjs/index.js", + "types": "dist/index.d.ts", + "main": "dist/index.js", "type": "commonjs", "repository": "github:Modern-Treasury/modern-treasury-node", "license": "MIT", "private": false, - "files": [ - "dist", - "resources", - "_shims", - "/*.ts" - ], "exports": { "./_shims/*": { "deno": { - "require": { - "types": "./dist/cjs/_shims/*.d.ts", - "default": "./dist/cjs/_shims/*.js" - }, - "types": "./dist/esm/_shims/*.d.ts", - "default": "./dist/esm/_shims/*.js" + "types": "./dist/_shims/*.d.ts", + "require": "./dist/_shims/*.js", + "default": "./dist/_shims/*.mjs" }, "browser": { - "require": { - "types": "./dist/cjs/_shims/*.d.ts", - "default": "./dist/cjs/_shims/*.js" - }, - "types": "./dist/esm/_shims/*.d.ts", - "default": "./dist/esm/_shims/*.js" + "types": "./dist/_shims/*.d.ts", + "require": "./dist/_shims/*.js", + "default": "./dist/_shims/*.mjs" }, "worker": { - "require": { - "types": "./dist/cjs/_shims/*.d.ts", - "default": "./dist/cjs/_shims/*.js" - }, - "types": "./dist/esm/_shims/*.d.ts", - "default": "./dist/esm/_shims/*.js" + "types": "./dist/_shims/*.d.ts", + "require": "./dist/_shims/*.js", + "default": "./dist/_shims/*.mjs" }, "workerd": { - "require": { - "types": "./dist/cjs/_shims/*.d.ts", - "default": "./dist/cjs/_shims/*.js" - }, - "types": "./dist/esm/_shims/*.d.ts", - "default": "./dist/esm/_shims/*.js" + "types": "./dist/_shims/*.d.ts", + "require": "./dist/_shims/*.js", + "default": "./dist/_shims/*.mjs" }, "node": { - "require": { - "types": "./dist/cjs/_shims/*.node.d.ts", - "default": "./dist/cjs/_shims/*.node.js" - }, - "types": "./dist/esm/_shims/*.node.d.ts", - "default": "./dist/esm/_shims/*.node.js" + "types": "./dist/_shims/*.node.d.ts", + "require": "./dist/_shims/*.node.js", + "default": "./dist/_shims/*.node.mjs" }, - "require": { - "types": "./dist/cjs/_shims/*.d.ts", - "default": "./dist/cjs/_shims/*.js" - }, - "types": "./dist/esm/_shims/*.d.ts", - "default": "./dist/esm/_shims/*.js" + "types": "./dist/_shims/*.d.ts", + "require": "./dist/_shims/*.js", + "default": "./dist/_shims/*.mjs" }, ".": { "require": { - "types": "./dist/cjs/index.d.ts", - "default": "./dist/cjs/index.js" + "types": "./dist/index.d.ts", + "default": "./dist/index.js" }, - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" }, "./*": { - "require": { - "types": "./dist/cjs/*.d.ts", - "require": "./dist/cjs/*.js" - }, - "types": "./dist/esm/*.d.ts", - "default": "./dist/esm/*.js" + "types": "./dist/*.d.ts", + "require": "./dist/*.js", + "default": "./dist/*.mjs" }, "./*.js": { - "require": { - "types": "./dist/cjs/*.d.ts", - "require": "./dist/cjs/*.js" - }, - "types": "./dist/esm/*.d.ts", - "default": "./dist/esm/*.js" + "types": "./dist/*.d.ts", + "default": "./dist/*.js" + }, + "./*.mjs": { + "types": "./dist/*.d.ts", + "default": "./dist/*.mjs" } }, "scripts": { "test": "bin/check-test-server && yarn jest", "build": "bash ./build", - "prepack": "yarn build", + "prepack": "echo 'to pack, run yarn build && (cd dist; yarn pack)' && exit 1", + "prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1", "format": "prettier --write .", "tsn": "ts-node -r tsconfig-paths/register", "fix": "eslint --fix --ext ts,js ." @@ -110,17 +84,18 @@ "qs": "^6.10.3" }, "devDependencies": { - "modern-treasury": "link:.", "@types/jest": "^29.4.0", "@typescript-eslint/eslint-plugin": "^5.33.0", "@typescript-eslint/parser": "^5.33.0", + "modern-treasury": "link:.", "eslint": "^8.22.0", "eslint-plugin-unused-imports": "^2.0.0", "jest": "^29.4.0", "prettier": "rattrayalex/prettier#postfix-ternaries", "ts-jest": "^29.1.0", "ts-node": "^10.5.0", - "tsc-alias": "^1.6.9", + "tsc-alias": "^1.8.6", + "tsc-multi": "^1.1.0", "tsconfig-paths": "^3.12.0", "typescript": "^4.8.2" } diff --git a/check-version.ts b/scripts/check-version.cjs similarity index 60% rename from check-version.ts rename to scripts/check-version.cjs index 8bbd6a96..50a85669 100644 --- a/check-version.ts +++ b/scripts/check-version.cjs @@ -1,16 +1,18 @@ -import fs from 'fs'; +const fs = require('fs'); +const path = require('path'); const main = () => { - const pkg = JSON.parse(fs.readFileSync('package.json').toString()) as Record; + const pkg = require('../package.json'); const version = pkg['version']; if (!version) throw 'The version property is not set in the package.json file'; if (typeof version !== 'string') { throw `Unexpected type for the package.json version field; got ${typeof version}, expected string`; } - const contents = fs.readFileSync('version.ts', 'utf8'); + const versionFile = path.resolve(__dirname, '..', 'src', 'version.ts'); + const contents = fs.readFileSync(versionFile, 'utf8'); const output = contents.replace(/(export const VERSION = ')(.*)(')/g, `$1${version}$3`); - fs.writeFileSync('version.ts', output); + fs.writeFileSync(versionFile, output); }; if (require.main === module) { diff --git a/scripts/fix-index-exports.cjs b/scripts/fix-index-exports.cjs new file mode 100644 index 00000000..0909af7c --- /dev/null +++ b/scripts/fix-index-exports.cjs @@ -0,0 +1,10 @@ +const fs = require('fs'); +const path = require('path'); + +const indexJs = path.resolve(__dirname, '..', 'dist', 'index.js'); +let before = fs.readFileSync(indexJs, 'utf8'); +let after = before.replace( + /^\s*exports\.default\s*=\s*(\w+)/m, + 'exports = module.exports = $1;\nexports.default = $1', +); +fs.writeFileSync(indexJs, after, 'utf8'); diff --git a/scripts/make-dist-package-json.cjs b/scripts/make-dist-package-json.cjs new file mode 100644 index 00000000..8c5889fa --- /dev/null +++ b/scripts/make-dist-package-json.cjs @@ -0,0 +1,20 @@ +const pkgJson = require('../package.json'); + +function processExportMap(m) { + for (const key in m) { + const value = m[key]; + if (typeof value === 'string') m[key] = value.replace(/^\.\/dist\//, './'); + else processExportMap(value); + } +} +processExportMap(pkgJson.exports); + +for (const key of ['types', 'main', 'module']) { + if (typeof pkgJson[key] === 'string') pkgJson[key] = pkgJson[key].replace(/^(\.\/)?dist\//, './'); +} + +delete pkgJson.devDependencies; +delete pkgJson.scripts.prepack; +delete pkgJson.scripts.prepublishOnly; + +console.log(JSON.stringify(pkgJson, null, 2)); diff --git a/scripts/prepare-cjs-build.mjs b/scripts/prepare-cjs-build.mjs deleted file mode 100755 index cbb89607..00000000 --- a/scripts/prepare-cjs-build.mjs +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env node - -import fs from 'node:fs/promises'; - -// add the following line back to index.ts if necessary: -// + exports = module.exports = OpenAI -// export default OpenAI -const code = await fs.readFile('index.ts', 'utf8'); -if (!/^\s*exports\s*=\s*module.exports\s*=\s*(\w+)/m.test(code)) { - await fs.writeFile( - 'index.ts', - code.replace(/\n?\s*export\s+default\s+(\w+)/m, '\nexports = module.exports = $1;\nexport default $1'), - 'utf8', - ); -} diff --git a/scripts/prepare-esm-build.mjs b/scripts/prepare-esm-build.mjs deleted file mode 100755 index bad68ebb..00000000 --- a/scripts/prepare-esm-build.mjs +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env node - -import fs from 'node:fs/promises'; - -// remove the following line from index.ts if present: -// - exports = module.exports = OpenAI -// export default OpenAI -const code = await fs.readFile('index.ts', 'utf8'); -const transformed = code.replace(/^\s*exports\s*=\s*module.exports\s*=\s*(\w+)\s*;?\s*\n?/m, ''); -if (transformed !== code) { - await fs.writeFile('index.ts', transformed, 'utf8'); -} diff --git a/_shims/agent.node.ts b/src/_shims/agent.node.ts similarity index 97% rename from _shims/agent.node.ts rename to src/_shims/agent.node.ts index c1225ca2..31f4d7c5 100644 --- a/_shims/agent.node.ts +++ b/src/_shims/agent.node.ts @@ -6,6 +6,8 @@ import KeepAliveAgent from 'agentkeepalive'; import type { Agent } from 'node:http'; import { AbortController as AbortControllerPolyfill } from 'abort-controller'; +export type { Agent }; + const defaultHttpAgent: Agent = new KeepAliveAgent({ keepAlive: true, timeout: 5 * 60 * 1000 }); const defaultHttpsAgent: Agent = new KeepAliveAgent.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1000 }); diff --git a/_shims/agent.ts b/src/_shims/agent.ts similarity index 68% rename from _shims/agent.ts rename to src/_shims/agent.ts index 310adfdd..c39d1cfb 100644 --- a/_shims/agent.ts +++ b/src/_shims/agent.ts @@ -5,8 +5,8 @@ * In node environments, it gets replaced agent.node.ts by the package export map */ -import type { Agent } from 'node:http'; +export type Agent = any; -export const getDefaultAgent = (url: string): Agent | undefined => { +export const getDefaultAgent = (url: string): any => { return undefined; }; diff --git a/src/_shims/fetch.d.ts b/src/_shims/fetch.d.ts new file mode 100644 index 00000000..7635e5a1 --- /dev/null +++ b/src/_shims/fetch.d.ts @@ -0,0 +1,52 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ + +// Use builtin web types if present; else never (user should +// add appropriate lib or types to tsconfig) + +/** + * >>> Confused? <<< + * + * If you're getting errors from these types, try adding "lib": ["DOM"] + * to your tsconfig.json, or otherwise configure the appropriate builtin + * `fetch` types for your environment. + */ + +// @ts-ignore +type _fetch = unknown extends typeof fetch ? never : typeof fetch; +// @ts-ignore +type _Request = unknown extends Request ? never : Request; +// @ts-ignore +type _RequestInfo = unknown extends RequestInfo ? never : RequestInfo; +// @ts-ignore +type _RequestInit = unknown extends RequestInit ? never : RequestInit; +// @ts-ignore +type _Response = unknown extends Response ? never : Response; +// @ts-ignore +type _ResponseInit = unknown extends ResponseInit ? never : ResponseInit; +// @ts-ignore +type _BodyInit = unknown extends BodyInit ? never : BodyInit; +// @ts-ignore +type _Headers = unknown extends Headers ? never : Headers; +// @ts-ignore +type _HeadersInit = unknown extends HeadersInit ? never : HeadersInit; + +declare const _fetch: _fetch; +declare const _Request: { + prototype: _Request; + new (input: _RequestInfo | URL, init?: _RequestInit): _Request; +}; +declare const _Response: { + prototype: _Response; + new (body?: _BodyInit | null, init?: _ResponseInit): _Response; +}; +declare const _Headers: { + prototype: _Headers; + new (init?: _HeadersInit): _Headers; +}; + +export const isPolyfilled = false; + +export { _fetch as fetch, _Request as Request, _Response as Response, _Headers as Headers }; +export type { _RequestInit as RequestInit, _RequestInfo as RequestInfo, _BodyInit as BodyInit }; diff --git a/src/_shims/fetch.js b/src/_shims/fetch.js new file mode 100644 index 00000000..28637363 --- /dev/null +++ b/src/_shims/fetch.js @@ -0,0 +1,13 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ + +// If we accidentally call fetch with the wrong this binding, +// in the browser it would throw: +// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation +exports.fetch = fetch.bind(undefined); +exports.Request = Request; +exports.Response = Response; +exports.Headers = Headers; + +exports.isPolyfilled = true; diff --git a/src/_shims/fetch.mjs b/src/_shims/fetch.mjs new file mode 100644 index 00000000..6d539fba --- /dev/null +++ b/src/_shims/fetch.mjs @@ -0,0 +1,15 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ + +// If we accidentally call fetch with the wrong this binding, +// in the browser it would throw: +// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation +const _fetch = fetch.bind(undefined); +const _Request = Request; +const _Response = Response; +const _Headers = Headers; + +export const isPolyfilled = false; + +export { _fetch as fetch, _Request as Request, _Response as Response, _Headers as Headers }; diff --git a/src/_shims/fetch.node.d.ts b/src/_shims/fetch.node.d.ts new file mode 100644 index 00000000..a220f8ad --- /dev/null +++ b/src/_shims/fetch.node.d.ts @@ -0,0 +1,53 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ + +import * as nf from 'node-fetch'; + +// Use builtin web types if present; else node-fetch types + +/** + * >>> Confused? <<< + * + * If you're getting errors from these types, try adding "lib": ["DOM"] + * to your tsconfig.json, or otherwise configure the appropriate builtin + * `fetch` types for your environment. + */ + +// @ts-ignore +type _fetch = unknown extends typeof fetch ? typeof nf.default : typeof fetch; +// @ts-ignore +type _Request = unknown extends Request ? nf.Request : Request; +// @ts-ignore +type _RequestInfo = unknown extends RequestInfo ? nf.RequestInfo : RequestInfo; +// @ts-ignore +type _RequestInit = unknown extends RequestInit ? nf.RequestInit : RequestInit; +// @ts-ignore +type _Response = unknown extends Response ? nf.Response : Response; +// @ts-ignore +type _ResponseInit = unknown extends ResponseInit ? nf.ResponseInit : ResponseInit; +// @ts-ignore +type _BodyInit = unknown extends BodyInit ? nf.BodyInit : BodyInit; +// @ts-ignore +type _Headers = unknown extends Headers ? nf.Headers : Headers; +// @ts-ignore +type _HeadersInit = unknown extends HeadersInit ? nf.HeadersInit : HeadersInit; + +declare const _fetch: _fetch; +declare const _Request: { + prototype: _Request; + new (input: _RequestInfo | URL, init?: _RequestInit): _Request; +}; +declare const _Response: { + prototype: _Response; + new (body?: _BodyInit | null, init?: _ResponseInit): _Response; +}; +declare const _Headers: { + prototype: _Headers; + new (init?: _HeadersInit): _Headers; +}; + +export const isPolyfilled = false; + +export { _fetch as fetch, _Request as Request, _Response as Response, _Headers as Headers }; +export type { _RequestInit as RequestInit, _RequestInfo as RequestInfo, _BodyInit as BodyInit }; diff --git a/src/_shims/fetch.node.js b/src/_shims/fetch.node.js new file mode 100644 index 00000000..15f8f8ab --- /dev/null +++ b/src/_shims/fetch.node.js @@ -0,0 +1,12 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ + +const nf = require('node-fetch'); + +exports.fetch = nf.default; +exports.Request = nf.Request; +exports.Response = nf.Response; +exports.Headers = nf.Headers; + +exports.isPolyfilled = true; diff --git a/src/_shims/fetch.node.mjs b/src/_shims/fetch.node.mjs new file mode 100644 index 00000000..d8543dca --- /dev/null +++ b/src/_shims/fetch.node.mjs @@ -0,0 +1,14 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ + +import * as nf from 'node-fetch'; + +const _fetch = nf.default; +const _Request = nf.Request; +const _Response = nf.Response; +const _Headers = nf.Headers; + +export { _fetch as fetch, _Request as Request, _Response as Response, _Headers as Headers }; + +export const isPolyfilled = true; diff --git a/_shims/fileFromPath.node.ts b/src/_shims/fileFromPath.node.ts similarity index 90% rename from _shims/fileFromPath.node.ts rename to src/_shims/fileFromPath.node.ts index eca866a1..676d2e2d 100644 --- a/_shims/fileFromPath.node.ts +++ b/src/_shims/fileFromPath.node.ts @@ -2,9 +2,8 @@ * Disclaimer: modules in _shims aren't intended to be imported by SDK users. */ -import type { FilePropertyBag } from 'formdata-node'; import { fileFromPath as _fileFromPath } from 'formdata-node/file-from-path'; -import type { File } from './formdata.node'; +import type { File, FilePropertyBag } from './formdata.node'; export type FileFromPathOptions = Omit; diff --git a/_shims/fileFromPath.ts b/src/_shims/fileFromPath.ts similarity index 83% rename from _shims/fileFromPath.ts rename to src/_shims/fileFromPath.ts index 8c45e249..7926b4a5 100644 --- a/_shims/fileFromPath.ts +++ b/src/_shims/fileFromPath.ts @@ -5,8 +5,7 @@ * in the package export map */ -import type { FilePropertyBag } from 'formdata-node'; -import type { File } from './formdata'; +import type { FilePropertyBag, File } from './formdata'; export type FileFromPathOptions = Omit; @@ -25,6 +24,6 @@ export async function fileFromPath( ): Promise; export async function fileFromPath(): Promise { throw new Error( - 'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/Modern-Treasury/modern-treasury-node#file-uploads', + 'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openai/openai-node#file-uploads', ); } diff --git a/src/_shims/formdata.d.ts b/src/_shims/formdata.d.ts new file mode 100644 index 00000000..0fb24cc4 --- /dev/null +++ b/src/_shims/formdata.d.ts @@ -0,0 +1,43 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ + +import type { BlobPart } from '../uploads'; + +type EndingType = 'native' | 'transparent'; + +export interface BlobPropertyBag { + endings?: EndingType; + type?: string; +} + +export interface FilePropertyBag extends BlobPropertyBag { + lastModified?: number; +} + +// Use builtin web types if present; else never (user should +// add appropriate lib or types to tsconfig) + +// @ts-ignore +type _FormData = unknown extends FormData ? never : FormData; +// @ts-ignore +type _File = unknown extends File ? never : File; +// @ts-ignore +type _Blob = unknown extends Blob ? never : Blob; + +declare const _FormData: { + new (form?: any): _FormData; + prototype: _FormData; +}; +declare const _File: { + new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag | undefined): _File; + prototype: _File; +}; +declare const _Blob: { + new (blobParts?: BlobPart[] | undefined, options?: BlobPropertyBag | undefined): _Blob; + prototype: _Blob; +}; + +export const isPolyfilled = false; + +export { _FormData as FormData, _File as File, _Blob as Blob }; diff --git a/src/_shims/formdata.js b/src/_shims/formdata.js new file mode 100644 index 00000000..a3debe98 --- /dev/null +++ b/src/_shims/formdata.js @@ -0,0 +1,9 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ + +exports.FormData = FormData; +exports.File = File; +exports.Blob = Blob; + +exports.isPolyfilled = false; diff --git a/src/_shims/formdata.mjs b/src/_shims/formdata.mjs new file mode 100644 index 00000000..2871d130 --- /dev/null +++ b/src/_shims/formdata.mjs @@ -0,0 +1,11 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ + +const _FormData = FormData; +const _File = File; +const _Blob = Blob; + +export { _FormData as FormData, _File as File, _Blob as Blob }; + +export const isPolyfilled = false; diff --git a/src/_shims/formdata.node.d.ts b/src/_shims/formdata.node.d.ts new file mode 100644 index 00000000..feea1ff9 --- /dev/null +++ b/src/_shims/formdata.node.d.ts @@ -0,0 +1,44 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ + +import * as fd from 'formdata-node'; + +import type { BlobPart } from '../uploads'; + +type EndingType = 'native' | 'transparent'; + +export interface BlobPropertyBag { + endings?: EndingType; + type?: string; +} + +export interface FilePropertyBag extends BlobPropertyBag { + lastModified?: number; +} + +// Use builtin web types if present; else formdata-node types + +// @ts-ignore +type _FormData = unknown extends FormData ? fd.FormData : FormData; +// @ts-ignore +type _File = unknown extends File ? fd.File : File; +// @ts-ignore +type _Blob = unknown extends Blob ? fd.Blob : Blob; + +declare const _FormData: { + new (form?: any): _FormData; + prototype: _FormData; +}; +declare const _File: { + new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag | undefined): _File; + prototype: _File; +}; +declare const _Blob: { + new (blobParts?: BlobPart[] | undefined, options?: BlobPropertyBag | undefined): _Blob; + prototype: _Blob; +}; + +export const isPolyfilled = false; + +export { _FormData as FormData, _File as File, _Blob as Blob }; diff --git a/src/_shims/formdata.node.js b/src/_shims/formdata.node.js new file mode 100644 index 00000000..892aba54 --- /dev/null +++ b/src/_shims/formdata.node.js @@ -0,0 +1,11 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ + +const fd = require('formdata-node'); + +exports.FormData = fd.FormData; +exports.File = fd.File; +exports.Blob = fd.Blob; + +exports.isPolyfilled = true; diff --git a/_shims/formdata.node.ts b/src/_shims/formdata.node.mjs similarity index 100% rename from _shims/formdata.node.ts rename to src/_shims/formdata.node.mjs diff --git a/_shims/getMultipartRequestOptions.node.ts b/src/_shims/getMultipartRequestOptions.node.ts similarity index 88% rename from _shims/getMultipartRequestOptions.node.ts rename to src/_shims/getMultipartRequestOptions.node.ts index c55c664d..3d690749 100644 --- a/_shims/getMultipartRequestOptions.node.ts +++ b/src/_shims/getMultipartRequestOptions.node.ts @@ -6,6 +6,7 @@ import { FormData } from './formdata.node'; import type { RequestOptions } from '../core'; import { Readable } from 'node:stream'; import { FormDataEncoder } from 'form-data-encoder'; +import { MultipartBody } from '../uploads'; export async function getMultipartRequestOptions>( form: FormData, @@ -13,7 +14,7 @@ export async function getMultipartRequestOptions> { const encoder = new FormDataEncoder(form); const readable = Readable.from(encoder); - const body = { __multipartBody__: readable }; + const body = new MultipartBody(readable); const headers = { ...opts.headers, ...encoder.headers, diff --git a/_shims/getMultipartRequestOptions.ts b/src/_shims/getMultipartRequestOptions.ts similarity index 76% rename from _shims/getMultipartRequestOptions.ts rename to src/_shims/getMultipartRequestOptions.ts index 1b38c298..b9abe643 100644 --- a/_shims/getMultipartRequestOptions.ts +++ b/src/_shims/getMultipartRequestOptions.ts @@ -4,10 +4,11 @@ import { FormData } from './formdata'; import type { RequestOptions } from '../core'; +import { MultipartBody } from '../uploads'; export async function getMultipartRequestOptions>( form: FormData, opts: RequestOptions, ): Promise> { - return { ...opts, body: { __multipartBody__: form } as any }; + return { ...opts, body: new MultipartBody(form) as any }; } diff --git a/src/_shims/node-readable.node.ts b/src/_shims/node-readable.node.ts new file mode 100644 index 00000000..0355aa1e --- /dev/null +++ b/src/_shims/node-readable.node.ts @@ -0,0 +1,10 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +export type { Readable } from 'node:stream'; +import { ReadStream as FsReadStream } from 'node:fs'; +export type { FsReadStream }; + +export function isFsReadStream(value: any): value is FsReadStream { + return value instanceof FsReadStream; +} diff --git a/src/_shims/node-readable.ts b/src/_shims/node-readable.ts new file mode 100644 index 00000000..fc3f2f55 --- /dev/null +++ b/src/_shims/node-readable.ts @@ -0,0 +1,30 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ + +// shim these Node types to avoid importing @types/node and polluting the user's +// type environment in non-node projects + +export declare class Readable { + readable: boolean; + readonly readableEnded: boolean; + readonly readableFlowing: boolean | null; + readonly readableHighWaterMark: number; + readonly readableLength: number; + readonly readableObjectMode: boolean; + destroyed: boolean; + read(size?: number): any; + pause(): this; + resume(): this; + isPaused(): boolean; + destroy(error?: Error): this; + [Symbol.asyncIterator](): AsyncIterableIterator; +} + +export declare class FsReadStream extends Readable { + path: {}; // node type is string | Buffer +} + +export function isFsReadStream(value: any): value is FsReadStream { + return false; +} diff --git a/core.ts b/src/core.ts similarity index 95% rename from core.ts rename to src/core.ts index 3d7a7018..bc7e1c5b 100644 --- a/core.ts +++ b/src/core.ts @@ -1,17 +1,23 @@ -import type { Readable } from 'node:stream'; -import type { Agent } from 'http'; - -import qs from 'qs'; - +import * as qs from 'qs'; import { VERSION } from './version'; import { Stream } from './streaming'; import { APIError, APIConnectionError, APIConnectionTimeoutError } from './error'; -import { getDefaultAgent } from 'modern-treasury/_shims/agent'; -import { fetch, isPolyfilled as fetchIsPolyfilled } from 'modern-treasury/_shims/fetch'; -import type { RequestInfo, RequestInit, Response } from 'modern-treasury/_shims/fetch'; +import type { Readable } from 'modern-treasury/_shims/node-readable'; +import { getDefaultAgent, type Agent } from 'modern-treasury/_shims/agent'; +import { + fetch, + isPolyfilled as fetchIsPolyfilled, + type RequestInfo, + type RequestInit, + type Response, +} from 'modern-treasury/_shims/fetch'; import { isMultipartBody } from './uploads'; -export { maybeMultipartFormRequestOptions, multipartFormRequestOptions, createForm } from './uploads'; -export type { Uploadable } from 'modern-treasury/_shims/uploadable'; +export { + maybeMultipartFormRequestOptions, + multipartFormRequestOptions, + createForm, + type Uploadable, +} from './uploads'; const MAX_RETRIES = 2; @@ -118,7 +124,7 @@ export abstract class APIClient { const { method, path, query, headers: headers = {} } = options; const body = - isMultipartBody(options.body) ? options.body.__multipartBody__ + isMultipartBody(options.body) ? options.body.body : options.body ? JSON.stringify(options.body, null, 2) : null; const contentLength = typeof body === 'string' ? body.length.toString() : null; @@ -148,7 +154,7 @@ export abstract class APIClient { const req: RequestInit = { method, - ...(body && { body }), + ...(body && { body: body as any }), headers: reqHeaders, ...(httpAgent && { agent: httpAgent }), }; @@ -263,11 +269,12 @@ export abstract class APIClient { async fetchWithTimeout( url: RequestInfo, - { signal, ...options }: RequestInit = {}, + init: RequestInit | undefined, ms: number, controller: AbortController, - ) { - if (signal) signal.addEventListener('abort', controller.abort); + ): Promise { + const { signal, ...options } = init || {}; + if (signal) signal.addEventListener('abort', () => controller.abort()); const timeout = setTimeout(() => controller.abort(), ms); @@ -491,12 +498,18 @@ export class PagePromise< export const createResponseHeaders = ( headers: Awaited>['headers'], ): Record => { - return new Proxy(Object.fromEntries(headers.entries()), { - get(target, name) { - const key = name.toString(); - return target[key.toLowerCase()] || target[key]; + return new Proxy( + Object.fromEntries( + // @ts-ignore + headers.entries(), + ), + { + get(target, name) { + const key = name.toString(); + return target[key.toLowerCase()] || target[key]; + }, }, - }); + ); }; type HTTPMethod = 'get' | 'post' | 'put' | 'patch' | 'delete'; diff --git a/error.ts b/src/error.ts similarity index 100% rename from error.ts rename to src/error.ts diff --git a/index.ts b/src/index.ts similarity index 99% rename from index.ts rename to src/index.ts index 783ea01a..6e8860a6 100644 --- a/index.ts +++ b/src/index.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -import qs from 'qs'; +import * as qs from 'qs'; import * as Core from './core'; import * as Pagination from './pagination'; -import * as API from './resources'; +import * as API from './resources/index'; import * as Errors from './error'; -import type { Agent } from 'http'; +import type { Agent } from 'modern-treasury/_shims/agent'; import * as Uploads from './uploads'; type Config = { @@ -371,4 +371,5 @@ export namespace ModernTreasury { export import AsyncResponse = API.AsyncResponse; export import Currency = API.Currency; } + export default ModernTreasury; diff --git a/pagination.ts b/src/pagination.ts similarity index 100% rename from pagination.ts rename to src/pagination.ts diff --git a/resource.ts b/src/resource.ts similarity index 100% rename from resource.ts rename to src/resource.ts diff --git a/resources/account-collection-flows.ts b/src/resources/account-collection-flows.ts similarity index 95% rename from resources/account-collection-flows.ts rename to src/resources/account-collection-flows.ts index 8de2a280..da111f8a 100644 --- a/resources/account-collection-flows.ts +++ b/src/resources/account-collection-flows.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class AccountCollectionFlows extends APIResource { /** diff --git a/resources/account-details.ts b/src/resources/account-details.ts similarity index 94% rename from resources/account-details.ts rename to src/resources/account-details.ts index 197bcb2d..8b5e26d0 100644 --- a/resources/account-details.ts +++ b/src/resources/account-details.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class AccountDetails extends APIResource { /** diff --git a/resources/connections.ts b/src/resources/connections.ts similarity index 88% rename from resources/connections.ts rename to src/resources/connections.ts index 5b960a37..50b873e2 100644 --- a/resources/connections.ts +++ b/src/resources/connections.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class Connections extends APIResource { /** diff --git a/resources/counterparties.ts b/src/resources/counterparties.ts similarity index 97% rename from resources/counterparties.ts rename to src/resources/counterparties.ts index 1c275e1c..6125023b 100644 --- a/resources/counterparties.ts +++ b/src/resources/counterparties.ts @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; -import * as ExternalAccounts from '~/resources/external-accounts'; -import * as AccountDetails from '~/resources/account-details'; -import * as RoutingDetails from '~/resources/routing-details'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; +import * as ExternalAccounts from 'modern-treasury/resources/external-accounts'; +import * as AccountDetails from 'modern-treasury/resources/account-details'; +import * as RoutingDetails from 'modern-treasury/resources/routing-details'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class Counterparties extends APIResource { /** diff --git a/resources/documents.ts b/src/resources/documents.ts similarity index 94% rename from resources/documents.ts rename to src/resources/documents.ts index 5aab79c5..fbe8e39b 100644 --- a/resources/documents.ts +++ b/src/resources/documents.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { type Uploadable, multipartFormRequestOptions } from '~/core'; -import { Page, PageParams } from '~/pagination'; +import { type Uploadable, multipartFormRequestOptions } from 'modern-treasury/core'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class Documents extends APIResource { /** diff --git a/resources/events.ts b/src/resources/events.ts similarity index 89% rename from resources/events.ts rename to src/resources/events.ts index 985daa1c..a5624a79 100644 --- a/resources/events.ts +++ b/src/resources/events.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class Events extends APIResource { /** diff --git a/resources/expected-payments.ts b/src/resources/expected-payments.ts similarity index 97% rename from resources/expected-payments.ts rename to src/resources/expected-payments.ts index 0b2b6258..b945c036 100644 --- a/resources/expected-payments.ts +++ b/src/resources/expected-payments.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; -import * as Shared from '~/resources/shared'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; +import * as Shared from 'modern-treasury/resources/shared'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class ExpectedPayments extends APIResource { /** diff --git a/resources/external-accounts.ts b/src/resources/external-accounts.ts similarity index 97% rename from resources/external-accounts.ts rename to src/resources/external-accounts.ts index 417b7441..3bb96536 100644 --- a/resources/external-accounts.ts +++ b/src/resources/external-accounts.ts @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; -import * as AccountDetails from '~/resources/account-details'; -import * as RoutingDetails from '~/resources/routing-details'; -import * as Shared from '~/resources/shared'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; +import * as AccountDetails from 'modern-treasury/resources/account-details'; +import * as RoutingDetails from 'modern-treasury/resources/routing-details'; +import * as Shared from 'modern-treasury/resources/shared'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class ExternalAccounts extends APIResource { /** diff --git a/resources/incoming-payment-details.ts b/src/resources/incoming-payment-details.ts similarity index 96% rename from resources/incoming-payment-details.ts rename to src/resources/incoming-payment-details.ts index 5b13db55..26a142c8 100644 --- a/resources/incoming-payment-details.ts +++ b/src/resources/incoming-payment-details.ts @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; -import * as VirtualAccounts from '~/resources/virtual-accounts'; -import * as Shared from '~/resources/shared'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; +import * as VirtualAccounts from 'modern-treasury/resources/virtual-accounts'; +import * as Shared from 'modern-treasury/resources/shared'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class IncomingPaymentDetails extends APIResource { /** diff --git a/resources/index.ts b/src/resources/index.ts similarity index 100% rename from resources/index.ts rename to src/resources/index.ts diff --git a/resources/internal-accounts/balance-reports.ts b/src/resources/internal-accounts/balance-reports.ts similarity index 93% rename from resources/internal-accounts/balance-reports.ts rename to src/resources/internal-accounts/balance-reports.ts index 57936fd9..b30a59f6 100644 --- a/resources/internal-accounts/balance-reports.ts +++ b/src/resources/internal-accounts/balance-reports.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; -import * as Shared from '~/resources/shared'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; +import * as Shared from 'modern-treasury/resources/shared'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class BalanceReports extends APIResource { /** diff --git a/resources/internal-accounts/index.ts b/src/resources/internal-accounts/index.ts similarity index 100% rename from resources/internal-accounts/index.ts rename to src/resources/internal-accounts/index.ts diff --git a/resources/internal-accounts/internal-accounts.ts b/src/resources/internal-accounts/internal-accounts.ts similarity index 94% rename from resources/internal-accounts/internal-accounts.ts rename to src/resources/internal-accounts/internal-accounts.ts index 2e62aa67..4143977e 100644 --- a/resources/internal-accounts/internal-accounts.ts +++ b/src/resources/internal-accounts/internal-accounts.ts @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; -import * as AccountDetails from '~/resources/account-details'; -import * as RoutingDetails from '~/resources/routing-details'; -import * as Connections from '~/resources/connections'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; +import * as AccountDetails from 'modern-treasury/resources/account-details'; +import * as RoutingDetails from 'modern-treasury/resources/routing-details'; +import * as Connections from 'modern-treasury/resources/connections'; import { BalanceReports } from './balance-reports'; -import * as Shared from '~/resources/shared'; +import * as Shared from 'modern-treasury/resources/shared'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class InternalAccounts extends APIResource { balanceReports: BalanceReports = new BalanceReports(this.client); diff --git a/resources/invoices/index.ts b/src/resources/invoices/index.ts similarity index 100% rename from resources/invoices/index.ts rename to src/resources/invoices/index.ts diff --git a/resources/invoices/invoices.ts b/src/resources/invoices/invoices.ts similarity index 97% rename from resources/invoices/invoices.ts rename to src/resources/invoices/invoices.ts index 61fda3ee..7454eaa9 100644 --- a/resources/invoices/invoices.ts +++ b/src/resources/invoices/invoices.ts @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; -import * as PaymentOrders from '~/resources/payment-orders'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; +import * as PaymentOrders from 'modern-treasury/resources/payment-orders/index'; import { LineItems } from './line-items'; -import * as Shared from '~/resources/shared'; +import * as Shared from 'modern-treasury/resources/shared'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class Invoices extends APIResource { lineItems: LineItems = new LineItems(this.client); diff --git a/resources/invoices/line-items.ts b/src/resources/invoices/line-items.ts similarity index 96% rename from resources/invoices/line-items.ts rename to src/resources/invoices/line-items.ts index 63ece5bf..c8e2e0d5 100644 --- a/resources/invoices/line-items.ts +++ b/src/resources/invoices/line-items.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; -import * as Shared from '~/resources/shared'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; +import * as Shared from 'modern-treasury/resources/shared'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class LineItems extends APIResource { /** diff --git a/resources/ledger-account-categories.ts b/src/resources/ledger-account-categories.ts similarity index 98% rename from resources/ledger-account-categories.ts rename to src/resources/ledger-account-categories.ts index 1f2835b7..1ad7b063 100644 --- a/resources/ledger-account-categories.ts +++ b/src/resources/ledger-account-categories.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class LedgerAccountCategories extends APIResource { /** diff --git a/resources/ledger-account-payouts.ts b/src/resources/ledger-account-payouts.ts similarity index 96% rename from resources/ledger-account-payouts.ts rename to src/resources/ledger-account-payouts.ts index b9e4fd87..cb18be3b 100644 --- a/resources/ledger-account-payouts.ts +++ b/src/resources/ledger-account-payouts.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class LedgerAccountPayouts extends APIResource { /** diff --git a/resources/ledger-account-statements.ts b/src/resources/ledger-account-statements.ts similarity index 99% rename from resources/ledger-account-statements.ts rename to src/resources/ledger-account-statements.ts index 113503b1..2030fcc2 100644 --- a/resources/ledger-account-statements.ts +++ b/src/resources/ledger-account-statements.ts @@ -1,7 +1,7 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; import * as API from './'; export class LedgerAccountStatements extends APIResource { diff --git a/resources/ledger-accounts.ts b/src/resources/ledger-accounts.ts similarity index 98% rename from resources/ledger-accounts.ts rename to src/resources/ledger-accounts.ts index 3c9cf6f8..b7481d6a 100644 --- a/resources/ledger-accounts.ts +++ b/src/resources/ledger-accounts.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class LedgerAccounts extends APIResource { /** diff --git a/resources/ledger-entries.ts b/src/resources/ledger-entries.ts similarity index 97% rename from resources/ledger-entries.ts rename to src/resources/ledger-entries.ts index 40843850..39c0f994 100644 --- a/resources/ledger-entries.ts +++ b/src/resources/ledger-entries.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class LedgerEntries extends APIResource { /** diff --git a/resources/ledger-event-handlers.ts b/src/resources/ledger-event-handlers.ts similarity index 98% rename from resources/ledger-event-handlers.ts rename to src/resources/ledger-event-handlers.ts index 5f59fc81..af99652d 100644 --- a/resources/ledger-event-handlers.ts +++ b/src/resources/ledger-event-handlers.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class LedgerEventHandlers extends APIResource { /** diff --git a/resources/ledger-transactions/index.ts b/src/resources/ledger-transactions/index.ts similarity index 100% rename from resources/ledger-transactions/index.ts rename to src/resources/ledger-transactions/index.ts diff --git a/resources/ledger-transactions/ledger-transactions.ts b/src/resources/ledger-transactions/ledger-transactions.ts similarity index 98% rename from resources/ledger-transactions/ledger-transactions.ts rename to src/resources/ledger-transactions/ledger-transactions.ts index ee8ccb98..5cc29a0f 100644 --- a/resources/ledger-transactions/ledger-transactions.ts +++ b/src/resources/ledger-transactions/ledger-transactions.ts @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; -import * as LedgerEntries from '~/resources/ledger-entries'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; +import * as LedgerEntries from 'modern-treasury/resources/ledger-entries'; import { Versions } from './versions'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class LedgerTransactions extends APIResource { versions: Versions = new Versions(this.client); diff --git a/resources/ledger-transactions/versions.ts b/src/resources/ledger-transactions/versions.ts similarity index 97% rename from resources/ledger-transactions/versions.ts rename to src/resources/ledger-transactions/versions.ts index 01295a47..562e4372 100644 --- a/resources/ledger-transactions/versions.ts +++ b/src/resources/ledger-transactions/versions.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class Versions extends APIResource { /** diff --git a/resources/ledgerable-events.ts b/src/resources/ledgerable-events.ts similarity index 97% rename from resources/ledgerable-events.ts rename to src/resources/ledgerable-events.ts index 82af636f..b29b2add 100644 --- a/resources/ledgerable-events.ts +++ b/src/resources/ledgerable-events.ts @@ -1,7 +1,7 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; import * as API from './'; export class LedgerableEvents extends APIResource { diff --git a/resources/ledgers.ts b/src/resources/ledgers.ts similarity index 95% rename from resources/ledgers.ts rename to src/resources/ledgers.ts index fa282133..f5072653 100644 --- a/resources/ledgers.ts +++ b/src/resources/ledgers.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class Ledgers extends APIResource { /** diff --git a/resources/line-items.ts b/src/resources/line-items.ts similarity index 95% rename from resources/line-items.ts rename to src/resources/line-items.ts index 1a96b588..af8d49bf 100644 --- a/resources/line-items.ts +++ b/src/resources/line-items.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class LineItems extends APIResource { /** diff --git a/resources/paper-items.ts b/src/resources/paper-items.ts similarity index 91% rename from resources/paper-items.ts rename to src/resources/paper-items.ts index dd440849..08803f87 100644 --- a/resources/paper-items.ts +++ b/src/resources/paper-items.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; -import * as Shared from '~/resources/shared'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; +import * as Shared from 'modern-treasury/resources/shared'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class PaperItems extends APIResource { /** diff --git a/resources/payment-flows.ts b/src/resources/payment-flows.ts similarity index 96% rename from resources/payment-flows.ts rename to src/resources/payment-flows.ts index c6a369ec..1a6a4e72 100644 --- a/resources/payment-flows.ts +++ b/src/resources/payment-flows.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class PaymentFlows extends APIResource { /** diff --git a/resources/payment-orders/index.ts b/src/resources/payment-orders/index.ts similarity index 100% rename from resources/payment-orders/index.ts rename to src/resources/payment-orders/index.ts diff --git a/resources/payment-orders/payment-orders.ts b/src/resources/payment-orders/payment-orders.ts similarity index 99% rename from resources/payment-orders/payment-orders.ts rename to src/resources/payment-orders/payment-orders.ts index 684c64f3..1e443f7f 100644 --- a/resources/payment-orders/payment-orders.ts +++ b/src/resources/payment-orders/payment-orders.ts @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; -import * as Returns from '~/resources/returns'; -import * as ExternalAccounts from '~/resources/external-accounts'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; +import * as Returns from 'modern-treasury/resources/returns'; +import * as ExternalAccounts from 'modern-treasury/resources/external-accounts'; import { Reversals } from './reversals'; -import * as Shared from '~/resources/shared'; +import * as Shared from 'modern-treasury/resources/shared'; import * as API from './'; -import { type Uploadable, maybeMultipartFormRequestOptions } from '~/core'; -import { Page, PageParams } from '~/pagination'; +import { type Uploadable, maybeMultipartFormRequestOptions } from 'modern-treasury/core'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class PaymentOrders extends APIResource { reversals: Reversals = new Reversals(this.client); diff --git a/resources/payment-orders/reversals.ts b/src/resources/payment-orders/reversals.ts similarity index 97% rename from resources/payment-orders/reversals.ts rename to src/resources/payment-orders/reversals.ts index b25f2af0..10548437 100644 --- a/resources/payment-orders/reversals.ts +++ b/src/resources/payment-orders/reversals.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class Reversals extends APIResource { /** diff --git a/resources/payment-references.ts b/src/resources/payment-references.ts similarity index 94% rename from resources/payment-references.ts rename to src/resources/payment-references.ts index 3859cf7c..54344867 100644 --- a/resources/payment-references.ts +++ b/src/resources/payment-references.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class PaymentReferences extends APIResource { /** diff --git a/resources/returns.ts b/src/resources/returns.ts similarity index 97% rename from resources/returns.ts rename to src/resources/returns.ts index 9f607f83..8b752692 100644 --- a/resources/returns.ts +++ b/src/resources/returns.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; -import * as Shared from '~/resources/shared'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; +import * as Shared from 'modern-treasury/resources/shared'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class Returns extends APIResource { /** diff --git a/resources/routing-details.ts b/src/resources/routing-details.ts similarity index 96% rename from resources/routing-details.ts rename to src/resources/routing-details.ts index 87dcac80..2b80655b 100644 --- a/resources/routing-details.ts +++ b/src/resources/routing-details.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class RoutingDetails extends APIResource { /** diff --git a/resources/shared.ts b/src/resources/shared.ts similarity index 100% rename from resources/shared.ts rename to src/resources/shared.ts diff --git a/resources/top-level.ts b/src/resources/top-level.ts similarity index 100% rename from resources/top-level.ts rename to src/resources/top-level.ts diff --git a/resources/transactions/index.ts b/src/resources/transactions/index.ts similarity index 100% rename from resources/transactions/index.ts rename to src/resources/transactions/index.ts diff --git a/resources/transactions/line-items.ts b/src/resources/transactions/line-items.ts similarity index 93% rename from resources/transactions/line-items.ts rename to src/resources/transactions/line-items.ts index 064f2cc2..7cfe59ac 100644 --- a/resources/transactions/line-items.ts +++ b/src/resources/transactions/line-items.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class LineItems extends APIResource { /** diff --git a/resources/transactions/transactions.ts b/src/resources/transactions/transactions.ts similarity index 96% rename from resources/transactions/transactions.ts rename to src/resources/transactions/transactions.ts index eb61eac3..45992504 100644 --- a/resources/transactions/transactions.ts +++ b/src/resources/transactions/transactions.ts @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; import { LineItems } from './line-items'; -import * as Shared from '~/resources/shared'; +import * as Shared from 'modern-treasury/resources/shared'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class Transactions extends APIResource { lineItems: LineItems = new LineItems(this.client); diff --git a/resources/validations.ts b/src/resources/validations.ts similarity index 96% rename from resources/validations.ts rename to src/resources/validations.ts index 5338515b..c0ef59c7 100644 --- a/resources/validations.ts +++ b/src/resources/validations.ts @@ -1,7 +1,7 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; import * as API from './'; export class Validations extends APIResource { diff --git a/resources/virtual-accounts.ts b/src/resources/virtual-accounts.ts similarity index 94% rename from resources/virtual-accounts.ts rename to src/resources/virtual-accounts.ts index 64b28f51..baac264a 100644 --- a/resources/virtual-accounts.ts +++ b/src/resources/virtual-accounts.ts @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from '~/core'; -import { APIResource } from '~/resource'; -import { isRequestOptions } from '~/core'; -import * as AccountDetails from '~/resources/account-details'; -import * as RoutingDetails from '~/resources/routing-details'; +import * as Core from 'modern-treasury/core'; +import { APIResource } from 'modern-treasury/resource'; +import { isRequestOptions } from 'modern-treasury/core'; +import * as AccountDetails from 'modern-treasury/resources/account-details'; +import * as RoutingDetails from 'modern-treasury/resources/routing-details'; import * as API from './'; -import { Page, PageParams } from '~/pagination'; +import { Page, PageParams } from 'modern-treasury/pagination'; export class VirtualAccounts extends APIResource { /** diff --git a/resources/webhooks.ts b/src/resources/webhooks.ts similarity index 91% rename from resources/webhooks.ts rename to src/resources/webhooks.ts index 36d85b85..7634577b 100644 --- a/resources/webhooks.ts +++ b/src/resources/webhooks.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -import { APIResource } from '~/resource'; +import { APIResource } from 'modern-treasury/resource'; import { createHmac } from 'crypto'; -import type { HeadersLike } from '~/core'; -import { getHeader } from '~/core'; +import type { HeadersLike } from 'modern-treasury/core'; +import { getHeader } from 'modern-treasury/core'; export class Webhooks extends APIResource { /** diff --git a/streaming.ts b/src/streaming.ts similarity index 98% rename from streaming.ts rename to src/streaming.ts index f017cb95..27e03f55 100644 --- a/streaming.ts +++ b/src/streaming.ts @@ -1,5 +1,5 @@ import type { Response } from 'modern-treasury/_shims/fetch'; -import { APIResponse, Headers, createResponseHeaders } from '~/core'; +import { APIResponse, Headers, createResponseHeaders } from './core'; type ServerSentEvent = { event: string | null; @@ -84,6 +84,7 @@ export class Stream implements AsyncIterable, APIResponse; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */ + slice(start?: number, end?: number): BlobLike; + // unfortunately @types/node-fetch@^2.6.4 doesn't type the arrayBuffer method +} + +/** + * Intended to match web.File, node.File, node-fetch.File, etc. + */ +export interface FileLike extends BlobLike { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */ + readonly lastModified: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */ + readonly name: string; +} + +/** + * Intended to match web.Response, node.Response, node-fetch.Response, etc. + */ +export interface ResponseLike { + url: string; + blob(): Promise; +} + +export const isResponseLike = (value: any): value is ResponseLike => + value != null && + typeof value === 'object' && + typeof value.url === 'string' && + typeof value.blob === 'function'; + +export const isFileLike = (value: any): value is FileLike => + value != null && + typeof value === 'object' && + typeof value.name === 'string' && + typeof value.lastModified === 'number' && + isBlobLike(value); + +/** + * The BlobLike type omits arrayBuffer() because @types/node-fetch@^2.6.4 lacks it; but this check + * adds the arrayBuffer() method type because it is available and used at runtime + */ +export const isBlobLike = (value: any): value is BlobLike & { arrayBuffer(): Promise } => + value != null && + typeof value === 'object' && + typeof value.size === 'number' && + typeof value.type === 'string' && + typeof value.text === 'function' && + typeof value.slice === 'function' && + typeof value.arrayBuffer === 'function'; + +export const isUploadable = (value: any): value is Uploadable => { + return isFileLike(value) || isResponseLike(value) || isFsReadStream(value); +}; + +export type ToFileInput = Uploadable | Exclude | AsyncIterable; + +/** + * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats + * @param bits the raw content of the file. Can be an {@link Uploadable}, {@link BlobPart}, or {@link AsyncIterable} of {@link BlobPart}s + * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible + * @param {Object=} options additional properties + * @param {string=} options.type the MIME type of the content + * @param {number=} options.lastModified the last modified timestamp + * @returns a {@link File} with the given properties + */ +export async function toFile( + value: ToFileInput, + name?: string | null | undefined, + options: FilePropertyBag | undefined = {}, +): Promise { + if (isResponseLike(value)) { + const blob = await value.blob(); + name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file'; + + return new File([blob as any], name, options); + } + + const bits = await getBytes(value); + + name ||= getName(value) ?? 'unknown_file'; + + if (!options.type) { + const type = (bits[0] as any)?.type; + if (typeof type === 'string') { + options = { ...options, type }; + } + } + + return new File(bits, name, options); +} + +async function getBytes(value: ToFileInput): Promise> { + if (value instanceof Promise) return getBytes(await (value as any)); + + let parts: Array = []; + if ( + typeof value === 'string' || + ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc. + value instanceof ArrayBuffer + ) { + parts.push(value); + } else if (isBlobLike(value)) { + parts.push(await value.arrayBuffer()); + } else if ( + isAsyncIterableIterator(value) // includes Readable, ReadableStream, etc. + ) { + for await (const chunk of value) { + parts.push(chunk as BlobPart); // TODO, consider validating? + } + } else { + throw new Error( + `Unexpected data type: ${typeof value}; constructor: ${ + value?.constructor?.name + }; props: ${propsForError(value)}`, + ); + } + + return parts; +} + +function propsForError(value: any): string { + const props = Object.getOwnPropertyNames(value); + return `[${props.map((p) => `"${p}"`).join(', ')}]`; +} + +function getName(value: any): string | undefined { + return ( + getStringFromMaybeBuffer(value.name) || + getStringFromMaybeBuffer(value.filename) || + // For fs.ReadStream + getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop() + ); +} + +const getStringFromMaybeBuffer = (x: string | Buffer | unknown): string | undefined => { + if (typeof x === 'string') return x; + if (typeof Buffer !== 'undefined' && x instanceof Buffer) return String(x); + return undefined; +}; + +const isAsyncIterableIterator = (value: any): value is AsyncIterableIterator => + value != null && typeof value === 'object' && typeof value[Symbol.asyncIterator] === 'function'; + +export class MultipartBody { + constructor(public body: Readable | BodyInit) {} + get [Symbol.toStringTag](): string { + return 'MultipartBody'; + } +} + +export const isMultipartBody = (body: any): body is MultipartBody => + body && typeof body === 'object' && body.body && body[Symbol.toStringTag] === 'MultipartBody'; + +/** + * 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. + */ +export const maybeMultipartFormRequestOptions = async >( + opts: RequestOptions, +): Promise> => { + if (!hasUploadableValue(opts.body)) return opts; + + const form = await createForm(opts.body); + return getMultipartRequestOptions(form, opts); +}; + +export const multipartFormRequestOptions = async >( + opts: RequestOptions, +): Promise> => { + const form = await createForm(opts.body); + return getMultipartRequestOptions(form, opts); +}; + +export const createForm = async >(body: T | undefined): Promise => { + const form = new FormData(); + await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value))); + return form; +}; + +const hasUploadableValue = (value: unknown): boolean => { + 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 as any)[k])) return true; + } + } + return false; +}; + +const addFormValue = async (form: FormData, key: string, value: unknown): Promise => { + 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, value); + } else if (isUploadable(value)) { + const file = await toFile(value); + form.append(key, file); + } 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`, + ); + } +}; diff --git a/version.ts b/src/version.ts similarity index 100% rename from version.ts rename to src/version.ts diff --git a/tests/api-resources/account-collection-flows.test.ts b/tests/api-resources/account-collection-flows.test.ts index 17964512..12d0f701 100644 --- a/tests/api-resources/account-collection-flows.test.ts +++ b/tests/api-resources/account-collection-flows.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/account-details.test.ts b/tests/api-resources/account-details.test.ts index a4506536..d62bd0cd 100644 --- a/tests/api-resources/account-details.test.ts +++ b/tests/api-resources/account-details.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/connections.test.ts b/tests/api-resources/connections.test.ts index 5a1a656c..86e0bd4a 100644 --- a/tests/api-resources/connections.test.ts +++ b/tests/api-resources/connections.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/counterparties.test.ts b/tests/api-resources/counterparties.test.ts index 9c850429..0b79bce3 100644 --- a/tests/api-resources/counterparties.test.ts +++ b/tests/api-resources/counterparties.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/documents.test.ts b/tests/api-resources/documents.test.ts index 0b7a0716..627f5abd 100644 --- a/tests/api-resources/documents.test.ts +++ b/tests/api-resources/documents.test.ts @@ -1,7 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import { toFile } from 'modern-treasury'; -import ModernTreasury from '~/index'; +import ModernTreasury, { toFile } from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/events.test.ts b/tests/api-resources/events.test.ts index e0fe101e..4d7c26bd 100644 --- a/tests/api-resources/events.test.ts +++ b/tests/api-resources/events.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/expected-payments.test.ts b/tests/api-resources/expected-payments.test.ts index e345cabf..5033cd14 100644 --- a/tests/api-resources/expected-payments.test.ts +++ b/tests/api-resources/expected-payments.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/external-accounts.test.ts b/tests/api-resources/external-accounts.test.ts index 8cbbcb4b..964ed285 100644 --- a/tests/api-resources/external-accounts.test.ts +++ b/tests/api-resources/external-accounts.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/incoming-payment-details.test.ts b/tests/api-resources/incoming-payment-details.test.ts index a356f4c4..e6d57fcf 100644 --- a/tests/api-resources/incoming-payment-details.test.ts +++ b/tests/api-resources/incoming-payment-details.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/internal-accounts/balance-reports.test.ts b/tests/api-resources/internal-accounts/balance-reports.test.ts index 5303e13f..ace42ae3 100644 --- a/tests/api-resources/internal-accounts/balance-reports.test.ts +++ b/tests/api-resources/internal-accounts/balance-reports.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/internal-accounts/internal-accounts.test.ts b/tests/api-resources/internal-accounts/internal-accounts.test.ts index 88681b17..a7e7221f 100644 --- a/tests/api-resources/internal-accounts/internal-accounts.test.ts +++ b/tests/api-resources/internal-accounts/internal-accounts.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/invoices/invoices.test.ts b/tests/api-resources/invoices/invoices.test.ts index 585b8933..e163f7ce 100644 --- a/tests/api-resources/invoices/invoices.test.ts +++ b/tests/api-resources/invoices/invoices.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/invoices/line-items.test.ts b/tests/api-resources/invoices/line-items.test.ts index bd2579ff..72422fb8 100644 --- a/tests/api-resources/invoices/line-items.test.ts +++ b/tests/api-resources/invoices/line-items.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/ledger-account-categories.test.ts b/tests/api-resources/ledger-account-categories.test.ts index 5d3157a5..13654113 100644 --- a/tests/api-resources/ledger-account-categories.test.ts +++ b/tests/api-resources/ledger-account-categories.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/ledger-account-payouts.test.ts b/tests/api-resources/ledger-account-payouts.test.ts index b6383fbc..2bc19703 100644 --- a/tests/api-resources/ledger-account-payouts.test.ts +++ b/tests/api-resources/ledger-account-payouts.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/ledger-account-statements.test.ts b/tests/api-resources/ledger-account-statements.test.ts index 0063a335..6d424ce3 100644 --- a/tests/api-resources/ledger-account-statements.test.ts +++ b/tests/api-resources/ledger-account-statements.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/ledger-accounts.test.ts b/tests/api-resources/ledger-accounts.test.ts index 91d59146..2106ddf4 100644 --- a/tests/api-resources/ledger-accounts.test.ts +++ b/tests/api-resources/ledger-accounts.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/ledger-entries.test.ts b/tests/api-resources/ledger-entries.test.ts index cc975c54..307c5c89 100644 --- a/tests/api-resources/ledger-entries.test.ts +++ b/tests/api-resources/ledger-entries.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/ledger-event-handlers.test.ts b/tests/api-resources/ledger-event-handlers.test.ts index 7cb97881..f30810df 100644 --- a/tests/api-resources/ledger-event-handlers.test.ts +++ b/tests/api-resources/ledger-event-handlers.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/ledger-transactions/ledger-transactions.test.ts b/tests/api-resources/ledger-transactions/ledger-transactions.test.ts index 6ae0d1f2..58bf826a 100644 --- a/tests/api-resources/ledger-transactions/ledger-transactions.test.ts +++ b/tests/api-resources/ledger-transactions/ledger-transactions.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/ledger-transactions/versions.test.ts b/tests/api-resources/ledger-transactions/versions.test.ts index c43bdd75..abb9c7ff 100644 --- a/tests/api-resources/ledger-transactions/versions.test.ts +++ b/tests/api-resources/ledger-transactions/versions.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/ledgerable-events.test.ts b/tests/api-resources/ledgerable-events.test.ts index 982d675c..edd3ca98 100644 --- a/tests/api-resources/ledgerable-events.test.ts +++ b/tests/api-resources/ledgerable-events.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/ledgers.test.ts b/tests/api-resources/ledgers.test.ts index 1252b4d8..b1c56892 100644 --- a/tests/api-resources/ledgers.test.ts +++ b/tests/api-resources/ledgers.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/line-items.test.ts b/tests/api-resources/line-items.test.ts index c9a02a2e..a17330ef 100644 --- a/tests/api-resources/line-items.test.ts +++ b/tests/api-resources/line-items.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/paper-items.test.ts b/tests/api-resources/paper-items.test.ts index a7d05124..4e64c495 100644 --- a/tests/api-resources/paper-items.test.ts +++ b/tests/api-resources/paper-items.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/payment-flows.test.ts b/tests/api-resources/payment-flows.test.ts index 492f9767..436ac454 100644 --- a/tests/api-resources/payment-flows.test.ts +++ b/tests/api-resources/payment-flows.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/payment-orders/payment-orders.test.ts b/tests/api-resources/payment-orders/payment-orders.test.ts index ad2832ca..553fb98d 100644 --- a/tests/api-resources/payment-orders/payment-orders.test.ts +++ b/tests/api-resources/payment-orders/payment-orders.test.ts @@ -1,7 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import { toFile } from 'modern-treasury'; -import ModernTreasury from '~/index'; +import ModernTreasury, { toFile } from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/payment-orders/reversals.test.ts b/tests/api-resources/payment-orders/reversals.test.ts index 246fec10..d879b2a2 100644 --- a/tests/api-resources/payment-orders/reversals.test.ts +++ b/tests/api-resources/payment-orders/reversals.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/payment-references.test.ts b/tests/api-resources/payment-references.test.ts index fed600be..0904bc16 100644 --- a/tests/api-resources/payment-references.test.ts +++ b/tests/api-resources/payment-references.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/returns.test.ts b/tests/api-resources/returns.test.ts index d2fd11e8..6ca52945 100644 --- a/tests/api-resources/returns.test.ts +++ b/tests/api-resources/returns.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/routing-details.test.ts b/tests/api-resources/routing-details.test.ts index 9a4b0670..bb440a86 100644 --- a/tests/api-resources/routing-details.test.ts +++ b/tests/api-resources/routing-details.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/top-level.test.ts b/tests/api-resources/top-level.test.ts index 107ca53c..d1a7b0ff 100644 --- a/tests/api-resources/top-level.test.ts +++ b/tests/api-resources/top-level.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/transactions/line-items.test.ts b/tests/api-resources/transactions/line-items.test.ts index d5160779..2754aa5b 100644 --- a/tests/api-resources/transactions/line-items.test.ts +++ b/tests/api-resources/transactions/line-items.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/transactions/transactions.test.ts b/tests/api-resources/transactions/transactions.test.ts index a6d42928..50791574 100644 --- a/tests/api-resources/transactions/transactions.test.ts +++ b/tests/api-resources/transactions/transactions.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/validations.test.ts b/tests/api-resources/validations.test.ts index 2e3a28a3..b6faf8e5 100644 --- a/tests/api-resources/validations.test.ts +++ b/tests/api-resources/validations.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/virtual-accounts.test.ts b/tests/api-resources/virtual-accounts.test.ts index ac9270cf..c2123bed 100644 --- a/tests/api-resources/virtual-accounts.test.ts +++ b/tests/api-resources/virtual-accounts.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/api-resources/webhooks.test.ts b/tests/api-resources/webhooks.test.ts index a9a81a8f..57d9c0b9 100644 --- a/tests/api-resources/webhooks.test.ts +++ b/tests/api-resources/webhooks.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -import ModernTreasury from '~/index'; +import ModernTreasury from 'modern-treasury'; const modernTreasury = new ModernTreasury({ apiKey: 'something1234', diff --git a/tests/form.test.ts b/tests/form.test.ts index 17ef35cc..65666db1 100644 --- a/tests/form.test.ts +++ b/tests/form.test.ts @@ -1,4 +1,4 @@ -import { multipartFormRequestOptions, createForm } from '../core'; +import { multipartFormRequestOptions, createForm } from 'modern-treasury/core'; import { Blob } from 'modern-treasury/_shims/formdata'; import { toFile } from 'modern-treasury'; diff --git a/tests/index.test.ts b/tests/index.test.ts index 404c393d..7e2e30b9 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -1,7 +1,7 @@ // File generated from our OpenAPI spec by Stainless. -import { Headers } from '~/core'; -import ModernTreasury from '../index'; +import { Headers } from 'modern-treasury/core'; +import ModernTreasury from 'modern-treasury'; describe('instantiate client', () => { const env = process.env; diff --git a/tests/responses.test.ts b/tests/responses.test.ts index 396bf326..e2510b06 100644 --- a/tests/responses.test.ts +++ b/tests/responses.test.ts @@ -1,4 +1,4 @@ -import { createResponseHeaders } from '../core'; +import { createResponseHeaders } from 'modern-treasury/core'; import { Headers } from 'modern-treasury/_shims/fetch'; describe('response parsing', () => { diff --git a/tests/uploads.test.ts b/tests/uploads.test.ts index 53fc5219..9ee4d387 100644 --- a/tests/uploads.test.ts +++ b/tests/uploads.test.ts @@ -1,6 +1,5 @@ import fs from 'fs'; -import { toFile } from '~/uploads'; -import { ResponseLike } from 'modern-treasury/_shims/uploadable'; +import { toFile, type ResponseLike } from 'modern-treasury/uploads'; import { File } from 'modern-treasury/_shims/formdata'; class MyClass { diff --git a/tsc-multi.json b/tsc-multi.json new file mode 100644 index 00000000..4facad5a --- /dev/null +++ b/tsc-multi.json @@ -0,0 +1,7 @@ +{ + "targets": [ + { "extname": ".js", "module": "commonjs" }, + { "extname": ".mjs", "module": "esnext" } + ], + "projects": ["tsconfig.build.json"] +} diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 00000000..e750ce44 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,43 @@ +{ + "include": ["dist/src"], + "exclude": [], + "compilerOptions": { + "target": "es2019", + "lib": ["es2020"], + "module": "commonjs", + "moduleResolution": "node", + "esModuleInterop": true, + "rootDir": "./dist/src", + "baseUrl": "./", + "paths": { + "modern-treasury/_shims/*": ["dist/src/_shims/*.node"], + "modern-treasury": ["dist/src/index.ts"], + "modern-treasury/*": ["dist/src/*"], + "digest-fetch": ["./typings/digest-fetch"] + }, + + "declaration": true, + "declarationMap": true, + "outDir": "dist", + "pretty": true, + "sourceMap": true, + "resolveJsonModule": true, + + "forceConsistentCasingInFileNames": true, + + "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "strictBindCallApply": true, + "strictPropertyInitialization": true, + "noImplicitThis": true, + "alwaysStrict": true, + "exactOptionalPropertyTypes": true, + "noUncheckedIndexedAccess": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + + "skipLibCheck": true + } +} diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json deleted file mode 100644 index db6064ea..00000000 --- a/tsconfig.cjs.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "exclude": ["examples", "dist", "tests", "ecosystem-tests"], - "compilerOptions": { - "target": "es2016", - "module": "commonjs", - "outDir": "dist/cjs/" - } -} diff --git a/tsconfig.esm.json b/tsconfig.esm.json deleted file mode 100644 index f3f8823c..00000000 --- a/tsconfig.esm.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "exclude": ["examples", "dist", "tests", "ecosystem-tests"], - "compilerOptions": { - "lib": ["ES2021"], - "target": "ES2021", - "module": "ESNext", - "outDir": "dist/esm/" - } -} diff --git a/tsconfig.json b/tsconfig.json index 3f82c24c..7e260eac 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,17 @@ { - "exclude": ["dist", "ecosystem-tests"], + "include": ["src", "tests", "examples"], "compilerOptions": { "target": "es2019", "lib": ["es2020"], "module": "commonjs", "moduleResolution": "node", "esModuleInterop": true, - "rootDir": "./", + "rootDir": "./src", "baseUrl": "./", "paths": { - "~/*": ["*"], - "modern-treasury/_shims/*": ["_shims/*.node"], + "modern-treasury/_shims/*": ["src/_shims/*.node"], + "modern-treasury": ["src/index.ts"], + "modern-treasury/*": ["src/*"], "digest-fetch": ["./typings/digest-fetch"] }, diff --git a/uploads.ts b/uploads.ts deleted file mode 100644 index f6fd7b8d..00000000 --- a/uploads.ts +++ /dev/null @@ -1,81 +0,0 @@ -import type { Readable } from 'node:stream'; -import type { RequestOptions } from './core'; -import { type BodyInit } from 'modern-treasury/_shims/fetch'; -import { FormData } from 'modern-treasury/_shims/formdata'; -import { getMultipartRequestOptions } from 'modern-treasury/_shims/getMultipartRequestOptions'; -import { isUploadable } from 'modern-treasury/_shims/uploadable'; -import { toFile } from 'modern-treasury/_shims/toFile'; -import { fileFromPath } from 'modern-treasury/_shims/fileFromPath'; - -export { toFile, fileFromPath }; - -type MultipartBody = { - __multipartBody__: Readable | BodyInit; -}; - -export const isMultipartBody = (body: any): body is MultipartBody => - typeof body === 'object' && body?.__multipartBody__ != null; - -/** - * 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. - */ -export const maybeMultipartFormRequestOptions = async >( - opts: RequestOptions, -): Promise> => { - if (!hasUploadableValue(opts.body)) return opts; - - const form = await createForm(opts.body); - return getMultipartRequestOptions(form, opts); -}; - -export const multipartFormRequestOptions = async >( - opts: RequestOptions, -): Promise> => { - const form = await createForm(opts.body); - return getMultipartRequestOptions(form, opts); -}; - -export const createForm = async >(body: T | undefined): Promise => { - const form = new FormData(); - await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value))); - return form; -}; - -const hasUploadableValue = (value: unknown): boolean => { - 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 as any)[k])) return true; - } - } - return false; -}; - -const addFormValue = async (form: FormData, key: string, value: unknown): Promise => { - 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, value); - } else if (isUploadable(value)) { - const file = await toFile(value); - form.append(key, file); - } 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`, - ); - } -}; diff --git a/yarn.lock b/yarn.lock index d020062a..4e6aab3d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -978,6 +978,10 @@ "@typescript-eslint/types" "5.45.0" eslint-visitor-keys "^3.3.0" +"modern-treasury@link:.": + version "0.0.0" + uid "" + abort-controller@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" @@ -1019,6 +1023,14 @@ agentkeepalive@^4.2.1: depd "^1.1.2" humanize-ms "^1.2.1" +aggregate-error@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a" + integrity sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA== + dependencies: + clean-stack "^2.0.0" + indent-string "^4.0.0" + ajv@^6.10.0, ajv@^6.12.4: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" @@ -1080,7 +1092,7 @@ ansi-styles@^5.0.0: resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== -anymatch@^3.0.3, anymatch@~3.1.2: +anymatch@^3.0.3: version "3.1.2" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== @@ -1088,6 +1100,14 @@ anymatch@^3.0.3, anymatch@~3.1.2: normalize-path "^3.0.0" picomatch "^2.0.4" +anymatch@~3.1.2: + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + arg@^4.1.0: version "4.1.3" resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" @@ -1353,6 +1373,11 @@ cjs-module-lexer@^1.0.0: resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz#9f84ba3244a512f3a54e5277e8eef4c489864e40" integrity sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA== +clean-stack@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" + integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== + cliui@^7.0.2: version "7.0.4" resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" @@ -1362,6 +1387,15 @@ cliui@^7.0.2: strip-ansi "^6.0.0" wrap-ansi "^7.0.0" +cliui@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" + integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.1" + wrap-ansi "^7.0.0" + clone@^1.0.2: version "1.0.4" resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" @@ -1419,9 +1453,9 @@ commander@^2.19.0: integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== commander@^9.0.0: - version "9.3.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-9.3.0.tgz#f619114a5a2d2054e0d9ff1b31d5ccf89255e26b" - integrity sha512-hv95iU5uXPbK83mjrJKuZyFM/LBAoCV/XhVGkS5Je6tl7sxr6A0ITMw5WoRV46/UaJ46Nllm3Xt7IaJhXTIkzw== + version "9.5.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-9.5.0.tgz#bc08d1eb5cedf7ccb797a96199d41c7bc3e60d30" + integrity sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ== commondir@^1.0.1: version "1.0.1" @@ -1828,7 +1862,7 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-glob@3.2.12: +fast-glob@3.2.12, fast-glob@^3.2.12: version "3.2.12" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== @@ -2007,7 +2041,7 @@ get-package-type@^0.1.0: resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q== -get-stdin@8.0.0: +get-stdin@8.0.0, get-stdin@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-8.0.0.tgz#cbad6a73feb75f6eeb22ba9e01f89aa28aa97a53" integrity sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg== @@ -2167,6 +2201,11 @@ imurmurhash@^0.1.4: resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= +indent-string@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" + integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg== + indexes-of@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/indexes-of/-/indexes-of-1.0.1.tgz#f30f716c8e2bd346c7b67d3df3915566a7c05607" @@ -2180,7 +2219,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.0: +inherits@2, inherits@^2.0.0, inherits@^2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -2966,9 +3005,9 @@ ms@^2.0.0: integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== mylas@^2.1.9: - version "2.1.9" - resolved "https://registry.yarnpkg.com/mylas/-/mylas-2.1.9.tgz#8329626f95c0ce522ca7d3c192eca6221d172cdc" - integrity sha512-pa+cQvmhoM8zzgitPYZErmDt9EdTNVnXsH1XFjMeM4TyG4FFcgxrvK1+jwabVFwUOEDaSWuXBMjg43kqt/Ydlg== + version "2.1.13" + resolved "https://registry.yarnpkg.com/mylas/-/mylas-2.1.13.tgz#1e23b37d58fdcc76e15d8a5ed23f9ae9fc0cbdf4" + integrity sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg== n-readlines@1.0.1: version "1.0.1" @@ -3033,10 +3072,6 @@ onetime@^5.1.2: dependencies: mimic-fn "^2.1.0" -"modern-treasury@link:.": - version "0.0.0" - uid "" - optionator@^0.9.1: version "0.9.1" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499" @@ -3054,6 +3089,13 @@ outdent@0.8.0: resolved "https://registry.yarnpkg.com/outdent/-/outdent-0.8.0.tgz#2ebc3e77bf49912543f1008100ff8e7f44428eb0" integrity sha512-KiOAIsdpUTcAXuykya5fnVVT+/5uS0Q1mrkRHcF89tpieSmY33O/tmc54CqwA+bfhbtEfZUNLHaPUiB9X3jt1A== +p-all@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-all/-/p-all-3.0.0.tgz#077c023c37e75e760193badab2bad3ccd5782bfb" + integrity sha512-qUZbvbBFVXm6uJ7U/WDiO0fv6waBMbjlCm4E66oZdRR+egswICarIdHyVSZZHudH8T5SF8x/JG0q0duFzPnlBw== + dependencies: + p-map "^4.0.0" + p-defer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" @@ -3087,6 +3129,13 @@ p-locate@^5.0.0: dependencies: p-limit "^3.0.2" +p-map@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/p-map/-/p-map-4.0.0.tgz#bb2f95a5eda2ec168ec9274e06a747c3e2904d2b" + integrity sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ== + dependencies: + aggregate-error "^3.0.0" + p-try@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" @@ -3185,11 +3234,11 @@ please-upgrade-node@3.2.0: semver-compare "^1.0.0" plimit-lit@^1.2.6: - version "1.2.7" - resolved "https://registry.yarnpkg.com/plimit-lit/-/plimit-lit-1.2.7.tgz#ae16e6e5eadf87924e574337b4c01d140b986c4a" - integrity sha512-ce/kfCHFJ2sIK1IuSnXfVBxoMaIwuAF9J5NjFwxng1j+r8XguGxXMK87dBSODQfY+se2Raj/grpx5EAK9kapEA== + version "1.5.0" + resolved "https://registry.yarnpkg.com/plimit-lit/-/plimit-lit-1.5.0.tgz#f66df8a7041de1e965c4f1c0697ab486968a92a5" + integrity sha512-Eb/MqCb1Iv/ok4m1FqIXqvUKPISufcjZ605hl3KM/n8GaX8zfhtgdLwZU3vKjuHGh2O9Rjog/bHTq8ofIShdng== dependencies: - queue-lit "^1.2.8" + queue-lit "^1.5.0" postcss-less@3.1.4: version "3.1.4" @@ -3355,10 +3404,10 @@ qs@^6.10.3: dependencies: side-channel "^1.0.4" -queue-lit@^1.2.8: - version "1.2.8" - resolved "https://registry.yarnpkg.com/queue-lit/-/queue-lit-1.2.8.tgz#2bafa0eafb8db0380ab2301d90c52a065c4baad0" - integrity sha512-CR0/8Xb0oRk4rZrteSZcjrrPhWfXGBAWa/ATxYCqpdM4fnZu8M3zob5ajLxLUCXmpOzhHZ1+zgscrlzQtEOM0A== +queue-lit@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/queue-lit/-/queue-lit-1.5.0.tgz#8197fdafda1edd615c8a0fc14c48353626e5160a" + integrity sha512-IslToJ4eiCEE9xwMzq3viOO5nH8sUWUCwoElrhNMozzr9IIt2qqvB4I+uHu/zJTQVqc9R5DFwok4ijNK1pU3fA== queue-microtask@^1.2.2: version "1.2.3" @@ -3370,6 +3419,15 @@ react-is@^18.0.0: resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.1.0.tgz#61aaed3096d30eacf2a2127118b5b41387d32a67" integrity sha512-Fl7FuabXsJnV5Q1qIOQwx/sagGF18kogb4gpfcG4gjLBWO0WDiiz1ko/ExayuxE7InyQkBLkxRFG5oxY6Uu3Kg== +readable-stream@^3.4.0: + version "3.6.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" + integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + readdirp@~3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" @@ -3495,6 +3553,11 @@ safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== +safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + sdbm@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/sdbm/-/sdbm-2.0.0.tgz#23828c1195e341d0f5810c59dfa60d86278f8718" @@ -3606,6 +3669,13 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" +string-to-stream@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/string-to-stream/-/string-to-stream-3.0.1.tgz#480e6fb4d5476d31cb2221f75307a5dcb6638a42" + integrity sha512-Hl092MV3USJuUCC6mfl9sPzGloA3K5VwdIeJjYIkXY/8K+mUvaeEabWJgArp+xXrsWxCajeT2pc4axbVhIZJyg== + dependencies: + readable-stream "^3.4.0" + string-width@5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.0.1.tgz#0d8158335a6cfd8eb95da9b6b262ce314a036ffd" @@ -3624,6 +3694,13 @@ string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.1" +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + strip-ansi@7.0.1, strip-ansi@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2" @@ -3658,6 +3735,11 @@ strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== +superstruct@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-1.0.3.tgz#de626a5b49c6641ff4d37da3c7598e7a87697046" + integrity sha512-8iTn3oSS8nRGn+C2pgXSKPI3jmpm6FExNazNpjvqS6ZUJQCej3PUXEKM8NjHBOs54ExM+LPW/FBRhymrdcCiSg== + supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" @@ -3768,10 +3850,10 @@ ts-node@^10.5.0: v8-compile-cache-lib "^3.0.0" yn "3.1.1" -tsc-alias@^1.6.9: - version "1.6.9" - resolved "https://registry.yarnpkg.com/tsc-alias/-/tsc-alias-1.6.9.tgz#d04d95124b95ad8eea55e52d45cf65a744c26baa" - integrity sha512-5lv5uAHn0cgxY1XfpXIdquUSz2xXq3ryQyNtxC6DYH7YT5rt/W+9Gsft2uyLFTh+ozk4qU8iCSP3VemjT69xlQ== +tsc-alias@^1.8.6: + version "1.8.6" + resolved "https://registry.yarnpkg.com/tsc-alias/-/tsc-alias-1.8.6.tgz#28300ed398e90b1c600548ed956f58dfbecc1589" + integrity sha512-vq+i6VpE83IeMsSJVcFN03ZBofADhr8/gIJXjxpbnTRfN/MFXy0+SBaKG2o7p95QqXBGkeG98HYz3IkOOveFbg== dependencies: chokidar "^3.5.3" commander "^9.0.0" @@ -3780,6 +3862,22 @@ tsc-alias@^1.6.9: normalize-path "^3.0.0" plimit-lit "^1.2.6" +tsc-multi@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/tsc-multi/-/tsc-multi-1.1.0.tgz#0e2b03c0ed0ac58ecb556f11709441102d202680" + integrity sha512-THE6X+sse7EZ2qMhqXvBhd2HMTvXyWwYnx+2T/ijqdp/6Rf7rUc2uPRzPdrrljZCNcYDeL0qP2P7tqm2IwayTg== + dependencies: + debug "^4.3.4" + fast-glob "^3.2.12" + get-stdin "^8.0.0" + p-all "^3.0.0" + picocolors "^1.0.0" + signal-exit "^3.0.7" + string-to-stream "^3.0.1" + superstruct "^1.0.3" + tslib "^2.5.0" + yargs "^17.7.1" + tsconfig-paths@^3.12.0: version "3.14.1" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz#ba0734599e8ea36c862798e920bcf163277b137a" @@ -3800,6 +3898,11 @@ tslib@^2.0.3, tslib@^2.2.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.1.tgz#0d0bfbaac2880b91e22df0768e55be9753a5b17e" integrity sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA== +tslib@^2.5.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.0.tgz#b295854684dbda164e181d259a22cd779dcd7bc3" + integrity sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA== + tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" @@ -3916,6 +4019,11 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" +util-deprecate@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== + v8-compile-cache-lib@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz#0582bcb1c74f3a2ee46487ceecf372e46bce53e8" @@ -4072,7 +4180,7 @@ yargs-parser@^21.0.0: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.0.1.tgz#0267f286c877a4f0f728fceb6f8a3e4cb95c6e35" integrity sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg== -yargs-parser@^21.0.1: +yargs-parser@^21.0.1, yargs-parser@^21.1.1: version "21.1.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== @@ -4090,6 +4198,19 @@ yargs@^17.3.1: y18n "^5.0.5" yargs-parser "^21.0.0" +yargs@^17.7.1: + version "17.7.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" + integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w== + dependencies: + cliui "^8.0.1" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.3" + y18n "^5.0.5" + yargs-parser "^21.1.1" + yn@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"