diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..3374492 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,4 @@ +# This file is used to automatically assign reviewers to PRs +# For more information see: https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners + +* @maestro-org/Typescript diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index f81295e..40b97fb 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -29,4 +29,4 @@ jobs: run: | bash ./bin/publish-npm env: - NPM_TOKEN: ${{ secrets.MAESTRO_ARCH_RPC_NPM_TOKEN || secrets.NPM_TOKEN }} + NPM_TOKEN: ${{ secrets.MAESTRO_NPM_TOKEN || secrets.NPM_TOKEN }} diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 357a5b5..481ce3a 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -18,5 +18,5 @@ jobs: run: | bash ./bin/check-release-environment env: - NPM_TOKEN: ${{ secrets.MAESTRO_ARCH_RPC_NPM_TOKEN || secrets.NPM_TOKEN }} + NPM_TOKEN: ${{ secrets.MAESTRO_NPM_TOKEN || secrets.NPM_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db75253..0368ec0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,25 +42,25 @@ If you’d like to use the repository from source, you can either install from g To install via git: ```sh -$ npm install git+ssh://git@github.com:stainless-sdks/maestro-arch-rpc-node.git +$ npm install git+ssh://git@github.com:maestro-org/maestro-arch-rpc-node-sdk.git ``` Alternatively, to link a local copy of the repo: ```sh # Clone -$ git clone https://www.github.com/stainless-sdks/maestro-arch-rpc-node -$ cd maestro-arch-rpc-node +$ git clone https://www.github.com/maestro-org/maestro-arch-rpc-node-sdk +$ cd maestro-arch-rpc-node-sdk # With yarn $ yarn link $ cd ../my-package -$ yarn link maestro-arch-rpc +$ yarn link @maestro-org/maestro-arch-rpc-node-sdk # With pnpm $ pnpm link --global $ cd ../my-package -$ pnpm link -—global maestro-arch-rpc +$ pnpm link -—global @maestro-org/maestro-arch-rpc-node-sdk ``` ## Running tests @@ -99,7 +99,7 @@ the changes aren't made through the automated pipeline, you may want to make rel ### Publish with a GitHub workflow -You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/stainless-sdks/maestro-arch-rpc-node/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up. +You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/maestro-org/maestro-arch-rpc-node-sdk/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up. ### Publish manually diff --git a/LICENSE b/LICENSE index 18123ca..f9d2593 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2024 Maestro Arch Rpc + Copyright 2024 Maestro Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 674def3..d0c319d 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,28 @@ -# Maestro Arch Rpc Node API Library +# Maestro Node API Library -[![NPM version](https://img.shields.io/npm/v/maestro-arch-rpc.svg)](https://npmjs.org/package/maestro-arch-rpc) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/maestro-arch-rpc) +[![NPM version](https://img.shields.io/npm/v/@maestro-org/maestro-arch-rpc-node-sdk.svg)](https://npmjs.org/package/@maestro-org/maestro-arch-rpc-node-sdk) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@maestro-org/maestro-arch-rpc-node-sdk) -This library provides convenient access to the Maestro Arch Rpc REST API from server-side TypeScript or JavaScript. +This library provides convenient access to the Maestro REST API from server-side TypeScript or JavaScript. -The REST API documentation can be found on [docs.maestro-arch-rpc.com](https://docs.maestro-arch-rpc.com). The full API of this library can be found in [api.md](api.md). +The REST API documentation can be found on [docs.gomaestro.org](https://docs.gomaestro.org/). The full API of this library can be found in [api.md](api.md). It is generated with [Stainless](https://www.stainlessapi.com/). ## Installation ```sh -npm install git+ssh://git@github.com:stainless-sdks/maestro-arch-rpc-node.git +npm install @maestro-org/maestro-arch-rpc-node-sdk ``` -> [!NOTE] -> Once this package is [published to npm](https://app.stainlessapi.com/docs/guides/publish), this will become: `npm install maestro-arch-rpc` - ## Usage The full API of this library can be found in [api.md](api.md). ```js -import MaestroArchRpc from 'maestro-arch-rpc'; +import Maestro from '@maestro-org/maestro-arch-rpc-node-sdk'; -const client = new MaestroArchRpc(); +const client = new Maestro(); async function main() { const response = await client.accounts.address([0, 0, 0]); @@ -42,13 +39,13 @@ This library includes TypeScript definitions for all request params and response ```ts -import MaestroArchRpc from 'maestro-arch-rpc'; +import Maestro from '@maestro-org/maestro-arch-rpc-node-sdk'; -const client = new MaestroArchRpc(); +const client = new Maestro(); async function main() { - const params: MaestroArchRpc.AccountAddressParams = [0, 0, 0]; - const response: MaestroArchRpc.AccountAddressResponse = await client.accounts.address(params); + const params: Maestro.AccountAddressParams = [0, 0, 0]; + const response: Maestro.AccountAddressResponse = await client.accounts.address(params); } main(); @@ -66,7 +63,7 @@ a subclass of `APIError` will be thrown: ```ts async function main() { const response = await client.accounts.address([0, 0, 0]).catch(async (err) => { - if (err instanceof MaestroArchRpc.APIError) { + if (err instanceof Maestro.APIError) { console.log(err.status); // 400 console.log(err.name); // BadRequestError console.log(err.headers); // {server: 'nginx', ...} @@ -103,7 +100,7 @@ You can use the `maxRetries` option to configure or disable this: ```js // Configure the default for all requests: -const client = new MaestroArchRpc({ +const client = new Maestro({ maxRetries: 0, // default is 2 }); @@ -120,7 +117,7 @@ Requests time out after 1 minute by default. You can configure this with a `time ```ts // Configure the default for all requests: -const client = new MaestroArchRpc({ +const client = new Maestro({ timeout: 20 * 1000, // 20 seconds (default is 1 minute) }); @@ -144,7 +141,7 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi ```ts -const client = new MaestroArchRpc(); +const client = new Maestro(); const response = await client.accounts.address([0, 0, 0]).asResponse(); console.log(response.headers.get('X-My-Header')); @@ -205,17 +202,17 @@ By default, this library uses `node-fetch` in Node, and expects a global `fetch` If you would prefer to use a global, web-standards-compliant `fetch` function even in a Node environment, (for example, if you are running Node with `--experimental-fetch` or using NextJS which polyfills with `undici`), -add the following import before your first import `from "MaestroArchRpc"`: +add the following import before your first import `from "Maestro"`: ```ts // Tell TypeScript and the package to use the global web fetch instead of node-fetch. // Note, despite the name, this does not add any polyfills, but expects them to be provided if needed. -import 'maestro-arch-rpc/shims/web'; -import MaestroArchRpc from 'maestro-arch-rpc'; +import '@maestro-org/maestro-arch-rpc-node-sdk/shims/web'; +import Maestro from '@maestro-org/maestro-arch-rpc-node-sdk'; ``` -To do the inverse, add `import "maestro-arch-rpc/shims/node"` (which does import polyfills). -This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/stainless-sdks/maestro-arch-rpc-node/tree/main/src/_shims#readme)). +To do the inverse, add `import "@maestro-org/maestro-arch-rpc-node-sdk/shims/node"` (which does import polyfills). +This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/maestro-org/maestro-arch-rpc-node-sdk/tree/main/src/_shims#readme)). ### Logging and middleware @@ -224,9 +221,9 @@ which can be used to inspect or alter the `Request` or `Response` before/after e ```ts import { fetch } from 'undici'; // as one example -import MaestroArchRpc from 'maestro-arch-rpc'; +import Maestro from '@maestro-org/maestro-arch-rpc-node-sdk'; -const client = new MaestroArchRpc({ +const client = new Maestro({ fetch: async (url: RequestInfo, init?: RequestInit): Promise => { console.log('About to make a request', url, init); const response = await fetch(url, init); @@ -251,7 +248,7 @@ import http from 'http'; import { HttpsProxyAgent } from 'https-proxy-agent'; // Configure the default for all requests: -const client = new MaestroArchRpc({ +const client = new Maestro({ httpAgent: new HttpsProxyAgent(process.env.PROXY_URL), }); @@ -271,7 +268,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/maestro-arch-rpc-node/issues) with questions, bugs, or suggestions. +We are keen for your feedback; please open an [issue](https://www.github.com/maestro-org/maestro-arch-rpc-node-sdk/issues) with questions, bugs, or suggestions. ## Requirements diff --git a/SECURITY.md b/SECURITY.md index 2512f8b..5fe573d 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -16,11 +16,11 @@ before making any information public. ## Reporting Non-SDK Related Security Issues If you encounter security issues that are not directly related to SDKs but pertain to the services -or products provided by Maestro Arch Rpc please follow the respective company's security reporting guidelines. +or products provided by Maestro please follow the respective company's security reporting guidelines. -### Maestro Arch Rpc Terms and Policies +### Maestro Terms and Policies -Please contact support@gomaestro.org for any questions or concerns regarding security of our services. +Please contact info@gomaestro.org for any questions or concerns regarding security of our services. --- diff --git a/bin/check-release-environment b/bin/check-release-environment index 25265d2..276c4bb 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -3,7 +3,7 @@ errors=() if [ -z "${NPM_TOKEN}" ]; then - errors+=("The MAESTRO_ARCH_RPC_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The MAESTRO_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi lenErrors=${#errors[@]} diff --git a/jest.config.ts b/jest.config.ts index 0e23174..b9bf9a9 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -7,9 +7,9 @@ const config: JestConfigWithTsJest = { '^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }], }, moduleNameMapper: { - '^maestro-arch-rpc$': '/src/index.ts', - '^maestro-arch-rpc/_shims/auto/(.*)$': '/src/_shims/auto/$1-node', - '^maestro-arch-rpc/(.*)$': '/src/$1', + '^@maestro-org/maestro-arch-rpc-node-sdk$': '/src/index.ts', + '^@maestro-org/maestro-arch-rpc-node-sdk/_shims/auto/(.*)$': '/src/_shims/auto/$1-node', + '^@maestro-org/maestro-arch-rpc-node-sdk/(.*)$': '/src/$1', }, modulePathIgnorePatterns: [ '/ecosystem-tests/', diff --git a/package.json b/package.json index 04cc57b..9370d3e 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { - "name": "maestro-arch-rpc", + "name": "@maestro-org/maestro-arch-rpc-node-sdk", "version": "0.1.0-alpha.1", - "description": "The official TypeScript library for the Maestro Arch Rpc API", - "author": "Maestro Arch Rpc ", + "description": "The official TypeScript library for the Maestro API", + "author": "Maestro ", "types": "dist/index.d.ts", "main": "dist/index.js", "type": "commonjs", - "repository": "github:stainless-sdks/maestro-arch-rpc-node", + "repository": "github:maestro-org/maestro-arch-rpc-node-sdk", "license": "Apache-2.0", "packageManager": "yarn@1.22.22", "files": [ @@ -60,8 +60,8 @@ "./shims/web.mjs" ], "imports": { - "maestro-arch-rpc": ".", - "maestro-arch-rpc/*": "./src/*" + "@maestro-org/maestro-arch-rpc-node-sdk": ".", + "@maestro-org/maestro-arch-rpc-node-sdk/*": "./src/*" }, "exports": { "./_shims/auto/*": { diff --git a/scripts/build b/scripts/build index 79fef28..f4558b0 100755 --- a/scripts/build +++ b/scripts/build @@ -8,7 +8,7 @@ node scripts/utils/check-version.cjs # Build into dist and will publish the package from there, # so that src/resources/foo.ts becomes /resources/foo.js -# This way importing from `"maestro-arch-rpc/resources/foo"` works +# This way importing from `"@maestro-org/maestro-arch-rpc-node-sdk/resources/foo"` works # even with `"moduleResolution": "node"` rm -rf dist; mkdir dist @@ -32,7 +32,7 @@ npm exec tsc-multi # copy over handwritten .js/.mjs/.d.ts files cp src/_shims/*.{d.ts,js,mjs,md} dist/_shims cp src/_shims/auto/*.{d.ts,js,mjs} dist/_shims/auto -# we need to add exports = module.exports = Maestro Arch Rpc Node to index.js; +# we need to add exports = module.exports = Maestro Node to index.js; # No way to get that from index.ts because it would cause compile errors # when building .mjs node scripts/utils/fix-index-exports.cjs @@ -47,8 +47,8 @@ node scripts/utils/postprocess-files.cjs # make sure that nothing crashes when we require the output CJS or # import the output ESM -(cd dist && node -e 'require("maestro-arch-rpc")') -(cd dist && node -e 'import("maestro-arch-rpc")' --input-type=module) +(cd dist && node -e 'require("@maestro-org/maestro-arch-rpc-node-sdk")') +(cd dist && node -e 'import("@maestro-org/maestro-arch-rpc-node-sdk")' --input-type=module) if command -v deno &> /dev/null && [ -e ./scripts/build-deno ] then diff --git a/scripts/utils/postprocess-files.cjs b/scripts/utils/postprocess-files.cjs index 24bd377..0ad0ddd 100644 --- a/scripts/utils/postprocess-files.cjs +++ b/scripts/utils/postprocess-files.cjs @@ -2,7 +2,7 @@ const fs = require('fs'); const path = require('path'); const { parse } = require('@typescript-eslint/parser'); -const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? 'maestro-arch-rpc/'; +const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? '@maestro-org/maestro-arch-rpc-node-sdk/'; const distDir = process.env['DIST_PATH'] ? @@ -142,7 +142,7 @@ async function postprocess() { if (file.endsWith('.d.ts')) { // work around bad tsc behavior - // if we have `import { type Readable } from 'maestro-arch-rpc/_shims/index'`, + // if we have `import { type Readable } from '@maestro-org/maestro-arch-rpc-node-sdk/_shims/index'`, // tsc sometimes replaces `Readable` with `import("stream").Readable` inline // in the output .d.ts transformed = transformed.replace(/import\("stream"\).Readable/g, 'Readable'); diff --git a/src/_shims/README.md b/src/_shims/README.md index 3666285..21952ac 100644 --- a/src/_shims/README.md +++ b/src/_shims/README.md @@ -1,9 +1,9 @@ # 👋 Wondering what everything in here does? -`maestro-arch-rpc` supports a wide variety of runtime environments like Node.js, Deno, Bun, browsers, and various +`@maestro-org/maestro-arch-rpc-node-sdk` supports a wide variety of runtime environments like Node.js, Deno, Bun, browsers, and various edge runtimes, as well as both CommonJS (CJS) and EcmaScript Modules (ESM). -To do this, `maestro-arch-rpc` provides shims for either using `node-fetch` when in Node (because `fetch` is still experimental there) or the global `fetch` API built into the environment when not in Node. +To do this, `@maestro-org/maestro-arch-rpc-node-sdk` provides shims for either using `node-fetch` when in Node (because `fetch` is still experimental there) or the global `fetch` API built into the environment when not in Node. It uses [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) to automatically select the correct shims for each environment. However, conditional exports are a fairly new @@ -15,32 +15,32 @@ getting the wrong raw `Response` type from `.asResponse()`, for example. The user can work around these issues by manually importing one of: -- `import 'maestro-arch-rpc/shims/node'` -- `import 'maestro-arch-rpc/shims/web'` +- `import '@maestro-org/maestro-arch-rpc-node-sdk/shims/node'` +- `import '@maestro-org/maestro-arch-rpc-node-sdk/shims/web'` All of the code here in `_shims` handles selecting the automatic default shims or manual overrides. ### How it works - Runtime -Runtime shims get installed by calling `setShims` exported by `maestro-arch-rpc/_shims/registry`. +Runtime shims get installed by calling `setShims` exported by `@maestro-org/maestro-arch-rpc-node-sdk/_shims/registry`. -Manually importing `maestro-arch-rpc/shims/node` or `maestro-arch-rpc/shims/web`, calls `setShims` with the respective runtime shims. +Manually importing `@maestro-org/maestro-arch-rpc-node-sdk/shims/node` or `@maestro-org/maestro-arch-rpc-node-sdk/shims/web`, calls `setShims` with the respective runtime shims. -All client code imports shims from `maestro-arch-rpc/_shims/index`, which: +All client code imports shims from `@maestro-org/maestro-arch-rpc-node-sdk/_shims/index`, which: - checks if shims have been set manually -- if not, calls `setShims` with the shims from `maestro-arch-rpc/_shims/auto/runtime` -- re-exports the installed shims from `maestro-arch-rpc/_shims/registry`. +- if not, calls `setShims` with the shims from `@maestro-org/maestro-arch-rpc-node-sdk/_shims/auto/runtime` +- re-exports the installed shims from `@maestro-org/maestro-arch-rpc-node-sdk/_shims/registry`. -`maestro-arch-rpc/_shims/auto/runtime` exports web runtime shims. -If the `node` export condition is set, the export map replaces it with `maestro-arch-rpc/_shims/auto/runtime-node`. +`@maestro-org/maestro-arch-rpc-node-sdk/_shims/auto/runtime` exports web runtime shims. +If the `node` export condition is set, the export map replaces it with `@maestro-org/maestro-arch-rpc-node-sdk/_shims/auto/runtime-node`. ### How it works - Type time -All client code imports shim types from `maestro-arch-rpc/_shims/index`, which selects the manual types from `maestro-arch-rpc/_shims/manual-types` if they have been declared, otherwise it exports the auto types from `maestro-arch-rpc/_shims/auto/types`. +All client code imports shim types from `@maestro-org/maestro-arch-rpc-node-sdk/_shims/index`, which selects the manual types from `@maestro-org/maestro-arch-rpc-node-sdk/_shims/manual-types` if they have been declared, otherwise it exports the auto types from `@maestro-org/maestro-arch-rpc-node-sdk/_shims/auto/types`. -`maestro-arch-rpc/_shims/manual-types` exports an empty namespace. -Manually importing `maestro-arch-rpc/shims/node` or `maestro-arch-rpc/shims/web` merges declarations into this empty namespace, so they get picked up by `maestro-arch-rpc/_shims/index`. +`@maestro-org/maestro-arch-rpc-node-sdk/_shims/manual-types` exports an empty namespace. +Manually importing `@maestro-org/maestro-arch-rpc-node-sdk/shims/node` or `@maestro-org/maestro-arch-rpc-node-sdk/shims/web` merges declarations into this empty namespace, so they get picked up by `@maestro-org/maestro-arch-rpc-node-sdk/_shims/index`. -`maestro-arch-rpc/_shims/auto/types` exports web type definitions. -If the `node` export condition is set, the export map replaces it with `maestro-arch-rpc/_shims/auto/types-node`, though TS only picks this up if `"moduleResolution": "nodenext"` or `"moduleResolution": "bundler"`. +`@maestro-org/maestro-arch-rpc-node-sdk/_shims/auto/types` exports web type definitions. +If the `node` export condition is set, the export map replaces it with `@maestro-org/maestro-arch-rpc-node-sdk/_shims/auto/types-node`, though TS only picks this up if `"moduleResolution": "nodenext"` or `"moduleResolution": "bundler"`. diff --git a/src/_shims/index-deno.ts b/src/_shims/index-deno.ts index 8bab0e2..33cc545 100644 --- a/src/_shims/index-deno.ts +++ b/src/_shims/index-deno.ts @@ -79,7 +79,7 @@ export function getDefaultAgent(url: string) { } export function fileFromPath() { throw new Error( - 'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/stainless-sdks/maestro-arch-rpc-node#file-uploads', + 'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/maestro-org/maestro-arch-rpc-node-sdk#file-uploads', ); } diff --git a/src/_shims/index.d.ts b/src/_shims/index.d.ts index 5f7138e..fc915a5 100644 --- a/src/_shims/index.d.ts +++ b/src/_shims/index.d.ts @@ -2,7 +2,7 @@ * Disclaimer: modules in _shims aren't intended to be imported by SDK users. */ import { manual } from './manual-types'; -import * as auto from 'maestro-arch-rpc/_shims/auto/types'; +import * as auto from '@maestro-org/maestro-arch-rpc-node-sdk/_shims/auto/types'; import { type RequestOptions } from '../core'; type SelectType = unknown extends Manual ? Auto : Manual; diff --git a/src/_shims/index.js b/src/_shims/index.js index d110a7b..1eddcb5 100644 --- a/src/_shims/index.js +++ b/src/_shims/index.js @@ -2,7 +2,7 @@ * Disclaimer: modules in _shims aren't intended to be imported by SDK users. */ const shims = require('./registry'); -const auto = require('maestro-arch-rpc/_shims/auto/runtime'); +const auto = require('@maestro-org/maestro-arch-rpc-node-sdk/_shims/auto/runtime'); if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true }); for (const property of Object.keys(shims)) { Object.defineProperty(exports, property, { diff --git a/src/_shims/index.mjs b/src/_shims/index.mjs index 9fffe37..a9eb160 100644 --- a/src/_shims/index.mjs +++ b/src/_shims/index.mjs @@ -2,6 +2,6 @@ * Disclaimer: modules in _shims aren't intended to be imported by SDK users. */ import * as shims from './registry.mjs'; -import * as auto from 'maestro-arch-rpc/_shims/auto/runtime'; +import * as auto from '@maestro-org/maestro-arch-rpc-node-sdk/_shims/auto/runtime'; if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true }); export * from './registry.mjs'; diff --git a/src/_shims/manual-types.d.ts b/src/_shims/manual-types.d.ts index 077c832..321d16b 100644 --- a/src/_shims/manual-types.d.ts +++ b/src/_shims/manual-types.d.ts @@ -4,8 +4,8 @@ /** * Types will get added to this namespace when you import one of the following: * - * import 'maestro-arch-rpc/shims/node' - * import 'maestro-arch-rpc/shims/web' + * import '@maestro-org/maestro-arch-rpc-node-sdk/shims/node' + * import '@maestro-org/maestro-arch-rpc-node-sdk/shims/web' * * Importing more than one will cause type and runtime errors. */ diff --git a/src/_shims/registry.ts b/src/_shims/registry.ts index d90560a..5b9af85 100644 --- a/src/_shims/registry.ts +++ b/src/_shims/registry.ts @@ -42,12 +42,12 @@ export let isFsReadStream: Shims['isFsReadStream'] | undefined = undefined; export function setShims(shims: Shims, options: { auto: boolean } = { auto: false }) { if (auto) { throw new Error( - `you must \`import 'maestro-arch-rpc/shims/${shims.kind}'\` before importing anything else from maestro-arch-rpc`, + `you must \`import '@maestro-org/maestro-arch-rpc-node-sdk/shims/${shims.kind}'\` before importing anything else from @maestro-org/maestro-arch-rpc-node-sdk`, ); } if (kind) { throw new Error( - `can't \`import 'maestro-arch-rpc/shims/${shims.kind}'\` after \`import 'maestro-arch-rpc/shims/${kind}'\``, + `can't \`import '@maestro-org/maestro-arch-rpc-node-sdk/shims/${shims.kind}'\` after \`import '@maestro-org/maestro-arch-rpc-node-sdk/shims/${kind}'\``, ); } auto = options.auto; diff --git a/src/_shims/web-runtime.ts b/src/_shims/web-runtime.ts index cae2e07..7f9075f 100644 --- a/src/_shims/web-runtime.ts +++ b/src/_shims/web-runtime.ts @@ -9,9 +9,9 @@ export function getRuntime({ manuallyImported }: { manuallyImported?: boolean } const recommendation = manuallyImported ? `You may need to use polyfills` - : `Add one of these imports before your first \`import … from 'maestro-arch-rpc'\`: -- \`import 'maestro-arch-rpc/shims/node'\` (if you're running on Node) -- \`import 'maestro-arch-rpc/shims/web'\` (otherwise) + : `Add one of these imports before your first \`import … from '@maestro-org/maestro-arch-rpc-node-sdk'\`: +- \`import '@maestro-org/maestro-arch-rpc-node-sdk/shims/node'\` (if you're running on Node) +- \`import '@maestro-org/maestro-arch-rpc-node-sdk/shims/web'\` (otherwise) `; let _fetch, _Request, _Response, _Headers; @@ -95,7 +95,7 @@ export function getRuntime({ manuallyImported }: { manuallyImported?: boolean } getDefaultAgent: (url: string) => undefined, fileFromPath: () => { throw new Error( - 'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/stainless-sdks/maestro-arch-rpc-node#file-uploads', + 'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/maestro-org/maestro-arch-rpc-node-sdk#file-uploads', ); }, isFsReadStream: (value: any) => false, diff --git a/src/core.ts b/src/core.ts index cea3f27..2269c35 100644 --- a/src/core.ts +++ b/src/core.ts @@ -1,6 +1,6 @@ import { VERSION } from './version'; import { - MaestroArchRpcError, + MaestroError, APIError, APIConnectionError, APIConnectionTimeoutError, @@ -99,9 +99,9 @@ export class APIPromise extends Promise { * * 👋 Getting the wrong TypeScript type for `Response`? * Try setting `"moduleResolution": "NodeNext"` if you can, - * or add one of these imports before your first `import … from 'maestro-arch-rpc'`: - * - `import 'maestro-arch-rpc/shims/node'` (if you're running on Node) - * - `import 'maestro-arch-rpc/shims/web'` (otherwise) + * or add one of these imports before your first `import … from '@maestro-org/maestro-arch-rpc-node-sdk'`: + * - `import '@maestro-org/maestro-arch-rpc-node-sdk/shims/node'` (if you're running on Node) + * - `import '@maestro-org/maestro-arch-rpc-node-sdk/shims/web'` (otherwise) */ asResponse(): Promise { return this.responsePromise.then((p) => p.response); @@ -115,9 +115,9 @@ export class APIPromise extends Promise { * * 👋 Getting the wrong TypeScript type for `Response`? * Try setting `"moduleResolution": "NodeNext"` if you can, - * or add one of these imports before your first `import … from 'maestro-arch-rpc'`: - * - `import 'maestro-arch-rpc/shims/node'` (if you're running on Node) - * - `import 'maestro-arch-rpc/shims/web'` (otherwise) + * or add one of these imports before your first `import … from '@maestro-org/maestro-arch-rpc-node-sdk'`: + * - `import '@maestro-org/maestro-arch-rpc-node-sdk/shims/node'` (if you're running on Node) + * - `import '@maestro-org/maestro-arch-rpc-node-sdk/shims/web'` (otherwise) */ async withResponse(): Promise<{ data: T; response: Response }> { const [data, response] = await Promise.all([this.parse(), this.asResponse()]); @@ -504,7 +504,7 @@ export abstract class APIClient { if (value === null) { return `${encodeURIComponent(key)}=`; } - throw new MaestroArchRpcError( + throw new MaestroError( `Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`, ); }) @@ -650,7 +650,7 @@ export abstract class AbstractPage implements AsyncIterable { async getNextPage(): Promise { const nextInfo = this.nextPageInfo(); if (!nextInfo) { - throw new MaestroArchRpcError( + throw new MaestroError( 'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.', ); } @@ -986,10 +986,10 @@ export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve const validatePositiveInteger = (name: string, n: unknown): number => { if (typeof n !== 'number' || !Number.isInteger(n)) { - throw new MaestroArchRpcError(`${name} must be an integer`); + throw new MaestroError(`${name} must be an integer`); } if (n < 0) { - throw new MaestroArchRpcError(`${name} must be a positive integer`); + throw new MaestroError(`${name} must be a positive integer`); } return n; }; @@ -1005,8 +1005,7 @@ export const castToError = (err: any): Error => { }; export const ensurePresent = (value: T | null | undefined): T => { - if (value == null) - throw new MaestroArchRpcError(`Expected a value to be given but received ${value} instead.`); + if (value == null) throw new MaestroError(`Expected a value to be given but received ${value} instead.`); return value; }; @@ -1031,14 +1030,14 @@ export const coerceInteger = (value: unknown): number => { if (typeof value === 'number') return Math.round(value); if (typeof value === 'string') return parseInt(value, 10); - throw new MaestroArchRpcError(`Could not coerce ${value} (type: ${typeof value}) into a number`); + throw new MaestroError(`Could not coerce ${value} (type: ${typeof value}) into a number`); }; export const coerceFloat = (value: unknown): number => { if (typeof value === 'number') return value; if (typeof value === 'string') return parseFloat(value); - throw new MaestroArchRpcError(`Could not coerce ${value} (type: ${typeof value}) into a number`); + throw new MaestroError(`Could not coerce ${value} (type: ${typeof value}) into a number`); }; export const coerceBoolean = (value: unknown): boolean => { @@ -1104,7 +1103,7 @@ function applyHeadersMut(targetHeaders: Headers, newHeaders: Headers): void { export function debug(action: string, ...args: any[]) { if (typeof process !== 'undefined' && process?.env?.['DEBUG'] === 'true') { - console.log(`MaestroArchRpc:DEBUG:${action}`, ...args); + console.log(`Maestro:DEBUG:${action}`, ...args); } } @@ -1189,7 +1188,7 @@ export const toBase64 = (str: string | null | undefined): string => { return btoa(str); } - throw new MaestroArchRpcError('Cannot generate b64 string; Expected `Buffer` or `btoa` to be defined'); + throw new MaestroError('Cannot generate b64 string; Expected `Buffer` or `btoa` to be defined'); }; export function isObj(obj: unknown): obj is Record { diff --git a/src/error.ts b/src/error.ts index 68ba882..3dd8903 100644 --- a/src/error.ts +++ b/src/error.ts @@ -2,9 +2,9 @@ import { castToError, Headers } from './core'; -export class MaestroArchRpcError extends Error {} +export class MaestroError extends Error {} -export class APIError extends MaestroArchRpcError { +export class APIError extends MaestroError { readonly status: number | undefined; readonly headers: Headers | undefined; readonly error: Object | undefined; diff --git a/src/index.ts b/src/index.ts index ae4b884..04c80cf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,7 +10,7 @@ export interface ClientOptions { /** * Override the default base URL for the API, e.g., "https://api.example.com/v2/" * - * Defaults to process.env['MAESTRO_ARCH_RPC_BASE_URL']. + * Defaults to process.env['MAESTRO_BASE_URL']. */ baseURL?: string | null | undefined; @@ -65,15 +65,15 @@ export interface ClientOptions { } /** - * API Client for interfacing with the Maestro Arch Rpc API. + * API Client for interfacing with the Maestro API. */ -export class MaestroArchRpc extends Core.APIClient { +export class Maestro extends Core.APIClient { private _options: ClientOptions; /** - * API Client for interfacing with the Maestro Arch Rpc API. + * API Client for interfacing with the Maestro API. * - * @param {string} [opts.baseURL=process.env['MAESTRO_ARCH_RPC_BASE_URL'] ?? https://arch-testnet.gomaestro-api.org/v0/rpc] - Override the default base URL for the API. + * @param {string} [opts.baseURL=process.env['MAESTRO_BASE_URL'] ?? https://arch-testnet.gomaestro-api.org/v0/rpc] - Override the default base URL for the API. * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections. * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation. @@ -81,7 +81,7 @@ export class MaestroArchRpc extends Core.APIClient { * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API. * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API. */ - constructor({ baseURL = Core.readEnv('MAESTRO_ARCH_RPC_BASE_URL'), ...opts }: ClientOptions = {}) { + constructor({ baseURL = Core.readEnv('MAESTRO_BASE_URL'), ...opts }: ClientOptions = {}) { const options: ClientOptions = { ...opts, baseURL: baseURL || `https://arch-testnet.gomaestro-api.org/v0/rpc`, @@ -114,10 +114,10 @@ export class MaestroArchRpc extends Core.APIClient { }; } - static MaestroArchRpc = this; + static Maestro = this; static DEFAULT_TIMEOUT = 60000; // 1 minute - static MaestroArchRpcError = Errors.MaestroArchRpcError; + static MaestroError = Errors.MaestroError; static APIError = Errors.APIError; static APIConnectionError = Errors.APIConnectionError; static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError; @@ -136,7 +136,7 @@ export class MaestroArchRpc extends Core.APIClient { } export const { - MaestroArchRpcError, + MaestroError, APIError, APIConnectionError, APIConnectionTimeoutError, @@ -154,7 +154,7 @@ export const { export import toFile = Uploads.toFile; export import fileFromPath = Uploads.fileFromPath; -export namespace MaestroArchRpc { +export namespace Maestro { export import RequestOptions = Core.RequestOptions; export import Accounts = API.Accounts; @@ -184,4 +184,4 @@ export namespace MaestroArchRpc { export import TransactionSendParams = API.TransactionSendParams; } -export default MaestroArchRpc; +export default Maestro; diff --git a/src/resource.ts b/src/resource.ts index a584545..b197f59 100644 --- a/src/resource.ts +++ b/src/resource.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import type { MaestroArchRpc } from './index'; +import type { Maestro } from './index'; export class APIResource { - protected _client: MaestroArchRpc; + protected _client: Maestro; - constructor(client: MaestroArchRpc) { + constructor(client: Maestro) { this._client = client; } } diff --git a/src/version.ts b/src/version.ts index 7d1e798..b0bfd9e 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.0.1-alpha.1'; +export const VERSION = '0.1.0-alpha.1'; // x-release-please-version diff --git a/tests/api-resources/accounts.test.ts b/tests/api-resources/accounts.test.ts index 913f7be..97de263 100644 --- a/tests/api-resources/accounts.test.ts +++ b/tests/api-resources/accounts.test.ts @@ -1,12 +1,13 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import MaestroArchRpc from 'maestro-arch-rpc'; +import Maestro from '@maestro-org/maestro-arch-rpc-node-sdk'; import { Response } from 'node-fetch'; -const client = new MaestroArchRpc({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' }); +const client = new Maestro({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' }); describe('resource accounts', () => { - test('address: only required params', async () => { + // skipped: tests are disabled for the time being + test.skip('address: only required params', async () => { const responsePromise = client.accounts.address([0, 0, 0]); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -17,11 +18,13 @@ describe('resource accounts', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - test('address: required and optional params', async () => { + // skipped: tests are disabled for the time being + test.skip('address: required and optional params', async () => { const response = await client.accounts.address([0, 0, 0]); }); - test('info: only required params', async () => { + // skipped: tests are disabled for the time being + test.skip('info: only required params', async () => { const responsePromise = client.accounts.info([0, 0, 0]); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -32,7 +35,8 @@ describe('resource accounts', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - test('info: required and optional params', async () => { + // skipped: tests are disabled for the time being + test.skip('info: required and optional params', async () => { const response = await client.accounts.info([0, 0, 0]); }); }); diff --git a/tests/api-resources/blocks.test.ts b/tests/api-resources/blocks.test.ts index 3fe5c2e..10e58a1 100644 --- a/tests/api-resources/blocks.test.ts +++ b/tests/api-resources/blocks.test.ts @@ -1,12 +1,13 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import MaestroArchRpc from 'maestro-arch-rpc'; +import Maestro from '@maestro-org/maestro-arch-rpc-node-sdk'; import { Response } from 'node-fetch'; -const client = new MaestroArchRpc({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' }); +const client = new Maestro({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' }); describe('resource blocks', () => { - test('retrieve', async () => { + // skipped: tests are disabled for the time being + test.skip('retrieve', async () => { const responsePromise = client.blocks.retrieve('height_or_hash'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -17,14 +18,16 @@ describe('resource blocks', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - test('retrieve: request options instead of params are passed correctly', async () => { + // skipped: tests are disabled for the time being + test.skip('retrieve: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.blocks.retrieve('height_or_hash', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(MaestroArchRpc.NotFoundError); + ).rejects.toThrow(Maestro.NotFoundError); }); - test('count', async () => { + // skipped: tests are disabled for the time being + test.skip('count', async () => { const responsePromise = client.blocks.count(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -35,14 +38,16 @@ describe('resource blocks', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - test('count: request options instead of params are passed correctly', async () => { + // skipped: tests are disabled for the time being + test.skip('count: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect(client.blocks.count({ path: '/_stainless_unknown_path' })).rejects.toThrow( - MaestroArchRpc.NotFoundError, + Maestro.NotFoundError, ); }); - test('latest', async () => { + // skipped: tests are disabled for the time being + test.skip('latest', async () => { const responsePromise = client.blocks.latest(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -53,14 +58,16 @@ describe('resource blocks', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - test('latest: request options instead of params are passed correctly', async () => { + // skipped: tests are disabled for the time being + test.skip('latest: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect(client.blocks.latest({ path: '/_stainless_unknown_path' })).rejects.toThrow( - MaestroArchRpc.NotFoundError, + Maestro.NotFoundError, ); }); - test('latestHash', async () => { + // skipped: tests are disabled for the time being + test.skip('latestHash', async () => { const responsePromise = client.blocks.latestHash(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -71,14 +78,16 @@ describe('resource blocks', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - test('latestHash: request options instead of params are passed correctly', async () => { + // skipped: tests are disabled for the time being + test.skip('latestHash: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect(client.blocks.latestHash({ path: '/_stainless_unknown_path' })).rejects.toThrow( - MaestroArchRpc.NotFoundError, + Maestro.NotFoundError, ); }); - test('range', async () => { + // skipped: tests are disabled for the time being + test.skip('range', async () => { const responsePromise = client.blocks.range('start_height', 'end_height'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -89,14 +98,16 @@ describe('resource blocks', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - test('range: request options instead of params are passed correctly', async () => { + // skipped: tests are disabled for the time being + test.skip('range: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.blocks.range('start_height', 'end_height', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(MaestroArchRpc.NotFoundError); + ).rejects.toThrow(Maestro.NotFoundError); }); - test('range: request options and params are passed correctly', async () => { + // skipped: tests are disabled for the time being + test.skip('range: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.blocks.range( @@ -105,10 +116,11 @@ describe('resource blocks', () => { { count: 0, page: 0 }, { path: '/_stainless_unknown_path' }, ), - ).rejects.toThrow(MaestroArchRpc.NotFoundError); + ).rejects.toThrow(Maestro.NotFoundError); }); - test('recent', async () => { + // skipped: tests are disabled for the time being + test.skip('recent', async () => { const responsePromise = client.blocks.recent(1); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -119,10 +131,11 @@ describe('resource blocks', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - test('recent: request options instead of params are passed correctly', async () => { + // skipped: tests are disabled for the time being + test.skip('recent: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect(client.blocks.recent(1, { path: '/_stainless_unknown_path' })).rejects.toThrow( - MaestroArchRpc.NotFoundError, + Maestro.NotFoundError, ); }); }); diff --git a/tests/api-resources/programs.test.ts b/tests/api-resources/programs.test.ts index 7824aca..4f0a561 100644 --- a/tests/api-resources/programs.test.ts +++ b/tests/api-resources/programs.test.ts @@ -1,12 +1,13 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import MaestroArchRpc from 'maestro-arch-rpc'; +import Maestro from '@maestro-org/maestro-arch-rpc-node-sdk'; import { Response } from 'node-fetch'; -const client = new MaestroArchRpc({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' }); +const client = new Maestro({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' }); describe('resource programs', () => { - test('accounts', async () => { + // skipped: tests are disabled for the time being + test.skip('accounts', async () => { const responsePromise = client.programs.accounts({}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); diff --git a/tests/api-resources/transactions.test.ts b/tests/api-resources/transactions.test.ts index 8ace44f..8674b52 100644 --- a/tests/api-resources/transactions.test.ts +++ b/tests/api-resources/transactions.test.ts @@ -1,12 +1,13 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import MaestroArchRpc from 'maestro-arch-rpc'; +import Maestro from '@maestro-org/maestro-arch-rpc-node-sdk'; import { Response } from 'node-fetch'; -const client = new MaestroArchRpc({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' }); +const client = new Maestro({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' }); describe('resource transactions', () => { - test('retrieve', async () => { + // skipped: tests are disabled for the time being + test.skip('retrieve', async () => { const responsePromise = client.transactions.retrieve('tx_hash'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -17,14 +18,16 @@ describe('resource transactions', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - test('retrieve: request options instead of params are passed correctly', async () => { + // skipped: tests are disabled for the time being + test.skip('retrieve: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.transactions.retrieve('tx_hash', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(MaestroArchRpc.NotFoundError); + ).rejects.toThrow(Maestro.NotFoundError); }); - test('batchSend: only required params', async () => { + // skipped: tests are disabled for the time being + test.skip('batchSend: only required params', async () => { const responsePromise = client.transactions.batchSend([{}, {}, {}]); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -35,7 +38,8 @@ describe('resource transactions', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - test('batchSend: required and optional params', async () => { + // skipped: tests are disabled for the time being + test.skip('batchSend: required and optional params', async () => { const response = await client.transactions.batchSend([ { message: { @@ -172,7 +176,8 @@ describe('resource transactions', () => { ]); }); - test('send', async () => { + // skipped: tests are disabled for the time being + test.skip('send', async () => { const responsePromise = client.transactions.send({}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); diff --git a/tests/form.test.ts b/tests/form.test.ts index 76e19ad..d60cb7a 100644 --- a/tests/form.test.ts +++ b/tests/form.test.ts @@ -1,6 +1,6 @@ -import { multipartFormRequestOptions, createForm } from 'maestro-arch-rpc/core'; -import { Blob } from 'maestro-arch-rpc/_shims/index'; -import { toFile } from 'maestro-arch-rpc'; +import { multipartFormRequestOptions, createForm } from '@maestro-org/maestro-arch-rpc-node-sdk/core'; +import { Blob } from '@maestro-org/maestro-arch-rpc-node-sdk/_shims/index'; +import { toFile } from '@maestro-org/maestro-arch-rpc-node-sdk'; describe('form data validation', () => { test('valid values do not error', async () => { diff --git a/tests/index.test.ts b/tests/index.test.ts index cc273ac..2e10faa 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import MaestroArchRpc from 'maestro-arch-rpc'; -import { APIUserAbortError } from 'maestro-arch-rpc'; -import { Headers } from 'maestro-arch-rpc/core'; +import Maestro from '@maestro-org/maestro-arch-rpc-node-sdk'; +import { APIUserAbortError } from '@maestro-org/maestro-arch-rpc-node-sdk'; +import { Headers } from '@maestro-org/maestro-arch-rpc-node-sdk/core'; import defaultFetch, { Response, type RequestInit, type RequestInfo } from 'node-fetch'; describe('instantiate client', () => { @@ -20,7 +20,7 @@ describe('instantiate client', () => { }); describe('defaultHeaders', () => { - const client = new MaestroArchRpc({ + const client = new Maestro({ baseURL: 'http://localhost:5000/', defaultHeaders: { 'X-My-Default-Header': '2' }, }); @@ -51,15 +51,12 @@ describe('instantiate client', () => { describe('defaultQuery', () => { test('with null query params given', () => { - const client = new MaestroArchRpc({ - baseURL: 'http://localhost:5000/', - defaultQuery: { apiVersion: 'foo' }, - }); + const client = new Maestro({ baseURL: 'http://localhost:5000/', defaultQuery: { apiVersion: 'foo' } }); expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/foo?apiVersion=foo'); }); test('multiple default query params', () => { - const client = new MaestroArchRpc({ + const client = new Maestro({ baseURL: 'http://localhost:5000/', defaultQuery: { apiVersion: 'foo', hello: 'world' }, }); @@ -67,16 +64,13 @@ describe('instantiate client', () => { }); test('overriding with `undefined`', () => { - const client = new MaestroArchRpc({ - baseURL: 'http://localhost:5000/', - defaultQuery: { hello: 'world' }, - }); + const client = new Maestro({ baseURL: 'http://localhost:5000/', defaultQuery: { hello: 'world' } }); expect(client.buildURL('/foo', { hello: undefined })).toEqual('http://localhost:5000/foo'); }); }); test('custom fetch', async () => { - const client = new MaestroArchRpc({ + const client = new Maestro({ baseURL: 'http://localhost:5000/', fetch: (url) => { return Promise.resolve( @@ -92,7 +86,7 @@ describe('instantiate client', () => { }); test('custom signal', async () => { - const client = new MaestroArchRpc({ + const client = new Maestro({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', fetch: (...args) => { return new Promise((resolve, reject) => @@ -118,55 +112,55 @@ describe('instantiate client', () => { describe('baseUrl', () => { test('trailing slash', () => { - const client = new MaestroArchRpc({ baseURL: 'http://localhost:5000/custom/path/' }); + const client = new Maestro({ baseURL: 'http://localhost:5000/custom/path/' }); expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/custom/path/foo'); }); test('no trailing slash', () => { - const client = new MaestroArchRpc({ baseURL: 'http://localhost:5000/custom/path' }); + const client = new Maestro({ baseURL: 'http://localhost:5000/custom/path' }); expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/custom/path/foo'); }); afterEach(() => { - process.env['MAESTRO_ARCH_RPC_BASE_URL'] = undefined; + process.env['MAESTRO_BASE_URL'] = undefined; }); test('explicit option', () => { - const client = new MaestroArchRpc({ baseURL: 'https://example.com' }); + const client = new Maestro({ baseURL: 'https://example.com' }); expect(client.baseURL).toEqual('https://example.com'); }); test('env variable', () => { - process.env['MAESTRO_ARCH_RPC_BASE_URL'] = 'https://example.com/from_env'; - const client = new MaestroArchRpc({}); + process.env['MAESTRO_BASE_URL'] = 'https://example.com/from_env'; + const client = new Maestro({}); expect(client.baseURL).toEqual('https://example.com/from_env'); }); test('empty env variable', () => { - process.env['MAESTRO_ARCH_RPC_BASE_URL'] = ''; // empty - const client = new MaestroArchRpc({}); + process.env['MAESTRO_BASE_URL'] = ''; // empty + const client = new Maestro({}); expect(client.baseURL).toEqual('https://arch-testnet.gomaestro-api.org/v0/rpc'); }); test('blank env variable', () => { - process.env['MAESTRO_ARCH_RPC_BASE_URL'] = ' '; // blank - const client = new MaestroArchRpc({}); + process.env['MAESTRO_BASE_URL'] = ' '; // blank + const client = new Maestro({}); expect(client.baseURL).toEqual('https://arch-testnet.gomaestro-api.org/v0/rpc'); }); }); test('maxRetries option is correctly set', () => { - const client = new MaestroArchRpc({ maxRetries: 4 }); + const client = new Maestro({ maxRetries: 4 }); expect(client.maxRetries).toEqual(4); // default - const client2 = new MaestroArchRpc({}); + const client2 = new Maestro({}); expect(client2.maxRetries).toEqual(2); }); }); describe('request building', () => { - const client = new MaestroArchRpc({}); + const client = new Maestro({}); describe('Content-Length', () => { test('handles multi-byte characters', () => { @@ -208,7 +202,7 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; - const client = new MaestroArchRpc({ timeout: 10, fetch: testFetch }); + const client = new Maestro({ timeout: 10, fetch: testFetch }); expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); expect(count).toEqual(2); @@ -238,7 +232,7 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; - const client = new MaestroArchRpc({ fetch: testFetch, maxRetries: 4 }); + const client = new Maestro({ fetch: testFetch, maxRetries: 4 }); expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); @@ -262,7 +256,7 @@ describe('retries', () => { capturedRequest = init; return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; - const client = new MaestroArchRpc({ fetch: testFetch, maxRetries: 4 }); + const client = new Maestro({ fetch: testFetch, maxRetries: 4 }); expect( await client.request({ @@ -291,7 +285,7 @@ describe('retries', () => { capturedRequest = init; return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; - const client = new MaestroArchRpc({ + const client = new Maestro({ fetch: testFetch, maxRetries: 4, defaultHeaders: { 'X-Stainless-Retry-Count': null }, @@ -323,7 +317,7 @@ describe('retries', () => { capturedRequest = init; return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; - const client = new MaestroArchRpc({ fetch: testFetch, maxRetries: 4 }); + const client = new Maestro({ fetch: testFetch, maxRetries: 4 }); expect( await client.request({ @@ -350,7 +344,7 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; - const client = new MaestroArchRpc({ fetch: testFetch }); + const client = new Maestro({ fetch: testFetch }); expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); expect(count).toEqual(2); @@ -377,7 +371,7 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; - const client = new MaestroArchRpc({ fetch: testFetch }); + const client = new Maestro({ fetch: testFetch }); expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); expect(count).toEqual(2); diff --git a/tests/responses.test.ts b/tests/responses.test.ts index 0fc0289..7a8ddd6 100644 --- a/tests/responses.test.ts +++ b/tests/responses.test.ts @@ -1,5 +1,5 @@ -import { createResponseHeaders } from 'maestro-arch-rpc/core'; -import { Headers } from 'maestro-arch-rpc/_shims/index'; +import { createResponseHeaders } from '@maestro-org/maestro-arch-rpc-node-sdk/core'; +import { Headers } from '@maestro-org/maestro-arch-rpc-node-sdk/_shims/index'; describe('response parsing', () => { // TODO: test unicode characters diff --git a/tests/stringifyQuery.test.ts b/tests/stringifyQuery.test.ts index b66c7bc..ffeec6b 100644 --- a/tests/stringifyQuery.test.ts +++ b/tests/stringifyQuery.test.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { MaestroArchRpc } from 'maestro-arch-rpc'; +import { Maestro } from '@maestro-org/maestro-arch-rpc-node-sdk'; -const { stringifyQuery } = MaestroArchRpc.prototype as any; +const { stringifyQuery } = Maestro.prototype as any; describe(stringifyQuery, () => { for (const [input, expected] of [ diff --git a/tests/uploads.test.ts b/tests/uploads.test.ts index 1c71336..7c50550 100644 --- a/tests/uploads.test.ts +++ b/tests/uploads.test.ts @@ -1,6 +1,6 @@ import fs from 'fs'; -import { toFile, type ResponseLike } from 'maestro-arch-rpc/uploads'; -import { File } from 'maestro-arch-rpc/_shims/index'; +import { toFile, type ResponseLike } from '@maestro-org/maestro-arch-rpc-node-sdk/uploads'; +import { File } from '@maestro-org/maestro-arch-rpc-node-sdk/_shims/index'; class MyClass { name: string = 'foo'; diff --git a/tsconfig.build.json b/tsconfig.build.json index 3ab00d9..86f0a59 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -5,8 +5,8 @@ "compilerOptions": { "rootDir": "./dist/src", "paths": { - "maestro-arch-rpc/*": ["dist/src/*"], - "maestro-arch-rpc": ["dist/src/index.ts"], + "@maestro-org/maestro-arch-rpc-node-sdk/*": ["dist/src/*"], + "@maestro-org/maestro-arch-rpc-node-sdk": ["dist/src/index.ts"], }, "noEmit": false, "declaration": true, diff --git a/tsconfig.deno.json b/tsconfig.deno.json index ec33451..ab94620 100644 --- a/tsconfig.deno.json +++ b/tsconfig.deno.json @@ -6,9 +6,9 @@ "rootDir": "./deno", "lib": ["es2020", "DOM"], "paths": { - "maestro-arch-rpc/_shims/auto/*": ["deno/_shims/auto/*-deno"], - "maestro-arch-rpc/*": ["deno/*"], - "maestro-arch-rpc": ["deno/index.ts"], + "@maestro-org/maestro-arch-rpc-node-sdk/_shims/auto/*": ["deno/_shims/auto/*-deno"], + "@maestro-org/maestro-arch-rpc-node-sdk/*": ["deno/*"], + "@maestro-org/maestro-arch-rpc-node-sdk": ["deno/index.ts"], }, "noEmit": true, "declaration": true, diff --git a/tsconfig.json b/tsconfig.json index 50fdf6b..910207c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,9 +9,9 @@ "esModuleInterop": true, "baseUrl": "./", "paths": { - "maestro-arch-rpc/_shims/auto/*": ["src/_shims/auto/*-node"], - "maestro-arch-rpc/*": ["src/*"], - "maestro-arch-rpc": ["src/index.ts"], + "@maestro-org/maestro-arch-rpc-node-sdk/_shims/auto/*": ["src/_shims/auto/*-node"], + "@maestro-org/maestro-arch-rpc-node-sdk/*": ["src/*"], + "@maestro-org/maestro-arch-rpc-node-sdk": ["src/index.ts"], }, "noEmit": true,