From 617733b2dedf1a50ecc580213ca6a0a38a4390aa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 15:42:19 -0400 Subject: [PATCH] release: 0.0.5 (#17) * chore(internal): codegen related update (#16) * chore(tests): update prism version (#18) * feat(api): update via SDK Studio (#19) * fix(compat): remove ReadableStream polyfill redundant since node v16 (#21) Note that this breaks streaming in Node v14, which has been unsupported since v4.0.0 of this library. * chore(docs): fix incorrect client var names (#22) * chore(internal): add constant for default timeout (#23) * feat(api): OpenAPI spec update via Stainless API (#24) * feat(api): update via SDK Studio (#25) * chore(internal): codegen related update (#26) * chore(ci): correctly tag pre-release npm packages (#27) * chore(internal): codegen related update (#28) * release: 0.0.5 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 1 + .github/workflows/release-doctor.yml | 2 + .gitignore | 1 + .release-please-manifest.json | 2 +- .stats.yml | 2 +- CHANGELOG.md | 26 +++++++++ README.md | 52 +++++++---------- bin/publish-npm | 20 ++++++- package.json | 6 +- scripts/mock | 4 +- src/_shims/node-runtime.ts | 4 +- src/core.ts | 35 +++++++++--- src/index.ts | 35 +++++++++--- src/resources/apps/apps.ts | 2 +- .../apps/users/collections/collections.ts | 6 +- .../apps/users/collections/documents.ts | 2 +- src/resources/apps/users/sessions/messages.ts | 2 +- .../apps/users/sessions/metamessages.ts | 12 ++-- src/resources/apps/users/sessions/sessions.ts | 13 +---- src/resources/apps/users/users.ts | 2 +- src/version.ts | 2 +- tests/api-resources/apps/apps.test.ts | 20 +++---- .../users/collections/collections.test.ts | 57 ++++++++----------- .../apps/users/collections/documents.test.ts | 28 ++++----- .../apps/users/sessions/messages.test.ts | 24 ++++---- .../apps/users/sessions/metamessages.test.ts | 36 ++++++------ .../apps/users/sessions/sessions.test.ts | 50 +++++++--------- tests/api-resources/apps/users/users.test.ts | 32 +++++------ tests/index.test.ts | 10 ++-- tests/stringifyQuery.test.ts | 9 ++- yarn.lock | 5 -- 31 files changed, 275 insertions(+), 227 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 491db96..d791adb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,7 @@ on: pull_request: branches: - main + - next jobs: lint: diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index dd03026..1e6c440 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -1,6 +1,8 @@ name: Release Doctor on: pull_request: + branches: + - main workflow_dispatch: jobs: diff --git a/.gitignore b/.gitignore index 9a5858a..3eed6dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.prism.log node_modules yarn-error.log codegen.log diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 63c033c..45ca42f 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.0.4" + ".": "0.0.5" } diff --git a/.stats.yml b/.stats.yml index a479c92..4bb711f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 38 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/plastic-labs%2Fhoncho-7967581df14089cda98ce7bd258102d5da5ec541dc5b17aa918f96be11a2bde8.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/plastic-labs%2Fhoncho-9b368f4c227f4695fb1b16d44996ca0dcaab52c7ee1433491ce2989fee846115.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 6836dce..1fc45a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,31 @@ # Changelog +## 0.0.5 (2024-08-01) + +Full Changelog: [v0.0.4...v0.0.5](https://github.com/plastic-labs/honcho-node/compare/v0.0.4...v0.0.5) + +### Features + +* **api:** OpenAPI spec update via Stainless API ([#24](https://github.com/plastic-labs/honcho-node/issues/24)) ([f1760b0](https://github.com/plastic-labs/honcho-node/commit/f1760b014808b25acacea1dbe58d0e67e78b0709)) +* **api:** update via SDK Studio ([#19](https://github.com/plastic-labs/honcho-node/issues/19)) ([d58ce64](https://github.com/plastic-labs/honcho-node/commit/d58ce641232a10967d41d45be9ff159f3c6f1583)) +* **api:** update via SDK Studio ([#25](https://github.com/plastic-labs/honcho-node/issues/25)) ([d2b2c76](https://github.com/plastic-labs/honcho-node/commit/d2b2c76c4a28c3f2452492aedb240d563f33238c)) + + +### Bug Fixes + +* **compat:** remove ReadableStream polyfill redundant since node v16 ([#21](https://github.com/plastic-labs/honcho-node/issues/21)) ([697784b](https://github.com/plastic-labs/honcho-node/commit/697784bdd6d64b700cdc6ab1572a4ad130725d6b)) + + +### Chores + +* **ci:** correctly tag pre-release npm packages ([#27](https://github.com/plastic-labs/honcho-node/issues/27)) ([1f718ec](https://github.com/plastic-labs/honcho-node/commit/1f718eccfe135dc2bad1f9c31a43d1014e3831be)) +* **docs:** fix incorrect client var names ([#22](https://github.com/plastic-labs/honcho-node/issues/22)) ([b19d486](https://github.com/plastic-labs/honcho-node/commit/b19d4865708dee7c6f5ac0af9ad74487709554e7)) +* **internal:** add constant for default timeout ([#23](https://github.com/plastic-labs/honcho-node/issues/23)) ([67519e0](https://github.com/plastic-labs/honcho-node/commit/67519e0ebfbf52350f0dcbfd4b699285d5b765ec)) +* **internal:** codegen related update ([#16](https://github.com/plastic-labs/honcho-node/issues/16)) ([8fd8961](https://github.com/plastic-labs/honcho-node/commit/8fd89613e59d87ecd9bf6822d69dc01e17cba411)) +* **internal:** codegen related update ([#26](https://github.com/plastic-labs/honcho-node/issues/26)) ([5f40103](https://github.com/plastic-labs/honcho-node/commit/5f40103250bd1c732e9cd0e99c8f06e41f088a08)) +* **internal:** codegen related update ([#28](https://github.com/plastic-labs/honcho-node/issues/28)) ([a87faf6](https://github.com/plastic-labs/honcho-node/commit/a87faf690c13f796027a92a18e8759846997aa8d)) +* **tests:** update prism version ([#18](https://github.com/plastic-labs/honcho-node/issues/18)) ([09748fe](https://github.com/plastic-labs/honcho-node/commit/09748fe2cec34eb7c7d7ed1f839212e4c65642ea)) + ## 0.0.4 (2024-05-23) Full Changelog: [v0.0.3...v0.0.4](https://github.com/plastic-labs/honcho-node/compare/v0.0.3...v0.0.4) diff --git a/README.md b/README.md index 6b69237..dd39150 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Honcho Node API Library -[![NPM version](https://img.shields.io/npm/v/honcho-ai.svg)](https://npmjs.org/package/honcho-ai) +[![NPM version](https://img.shields.io/npm/v/honcho-ai.svg)](https://npmjs.org/package/honcho-ai) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/honcho-ai) This library provides convenient access to the Honcho REST API from server-side TypeScript or JavaScript. -The REST API documentation can be found [on docs.honcho.dev](https://docs.honcho.dev). The full API of this library can be found in [api.md](api.md). +The REST API documentation can be found on [docs.honcho.dev](https://docs.honcho.dev). The full API of this library can be found in [api.md](api.md). It is generated with [Stainless](https://www.stainlessapi.com/). @@ -22,13 +22,13 @@ The full API of this library can be found in [api.md](api.md). ```js import Honcho from 'honcho-ai'; -const honcho = new Honcho({ +const client = new Honcho({ apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - environment: 'demo', // defaults to 'local' + environment: 'local', // defaults to 'demo' }); async function main() { - const app = await honcho.apps.create({ name: 'string' }); + const app = await client.apps.create({ name: 'name' }); console.log(app.id); } @@ -44,14 +44,14 @@ This library includes TypeScript definitions for all request params and response ```ts import Honcho from 'honcho-ai'; -const honcho = new Honcho({ +const client = new Honcho({ apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - environment: 'demo', // defaults to 'local' + environment: 'local', // defaults to 'demo' }); async function main() { - const params: Honcho.AppCreateParams = { name: 'string' }; - const app: Honcho.App = await honcho.apps.create(params); + const params: Honcho.AppCreateParams = { name: 'name' }; + const app: Honcho.App = await client.apps.create(params); } main(); @@ -68,7 +68,7 @@ a subclass of `APIError` will be thrown: ```ts async function main() { - const app = await honcho.apps.create({ name: 'string' }).catch(async (err) => { + const app = await client.apps.create({ name: 'name' }).catch(async (err) => { if (err instanceof Honcho.APIError) { console.log(err.status); // 400 console.log(err.name); // BadRequestError @@ -106,12 +106,12 @@ You can use the `maxRetries` option to configure or disable this: ```js // Configure the default for all requests: -const honcho = new Honcho({ +const client = new Honcho({ maxRetries: 0, // default is 2 }); // Or, configure per-request: -await honcho.apps.create({ name: 'string' }, { +await client.apps.create({ name: 'name' }, { maxRetries: 5, }); ``` @@ -123,12 +123,12 @@ Requests time out after 1 minute by default. You can configure this with a `time ```ts // Configure the default for all requests: -const honcho = new Honcho({ +const client = new Honcho({ timeout: 20 * 1000, // 20 seconds (default is 1 minute) }); // Override per-request: -await honcho.apps.create({ name: 'string' }, { +await client.apps.create({ name: 'name' }, { timeout: 5 * 1000, }); ``` @@ -146,7 +146,7 @@ You can use `for await … of` syntax to iterate through items across all pages: async function fetchAllAppsUsers(params) { const allAppsUsers = []; // Automatically fetches more pages as needed. - for await (const user of honcho.apps.users.list('REPLACE_ME')) { + for await (const user of client.apps.users.list('REPLACE_ME')) { allAppsUsers.push(user); } return allAppsUsers; @@ -156,7 +156,7 @@ async function fetchAllAppsUsers(params) { Alternatively, you can make request a single page at a time: ```ts -let page = await honcho.apps.users.list('REPLACE_ME'); +let page = await client.apps.users.list('REPLACE_ME'); for (const user of page.items) { console.log(user); } @@ -178,13 +178,13 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi ```ts -const honcho = new Honcho(); +const client = new Honcho(); -const response = await honcho.apps.create({ name: 'string' }).asResponse(); +const response = await client.apps.create({ name: 'name' }).asResponse(); console.log(response.headers.get('X-My-Header')); console.log(response.statusText); // access the underlying Response object -const { data: app, response: raw } = await honcho.apps.create({ name: 'string' }).withResponse(); +const { data: app, response: raw } = await client.apps.create({ name: 'name' }).withResponse(); console.log(raw.headers.get('X-My-Header')); console.log(app.id); ``` @@ -285,13 +285,13 @@ import http from 'http'; import { HttpsProxyAgent } from 'https-proxy-agent'; // Configure the default for all requests: -const honcho = new Honcho({ +const client = new Honcho({ httpAgent: new HttpsProxyAgent(process.env.PROXY_URL), }); // Override per-request: -await honcho.apps.create( - { name: 'string' }, +await client.apps.create( + { name: 'name' }, { httpAgent: new http.Agent({ keepAlive: false }), }, @@ -316,14 +316,6 @@ TypeScript >= 4.5 is supported. The following runtimes are supported: -- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions. -- Deno v1.28.0 or higher, using `import Honcho from "npm:honcho-ai"`. -- Bun 1.0 or later. -- Cloudflare Workers. -- Vercel Edge Runtime. -- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time). -- Nitro v2.6 or greater. - Note that React Native is not supported at this time. If you are interested in other runtime environments, please open or upvote an issue on GitHub. diff --git a/bin/publish-npm b/bin/publish-npm index 4d6c9f3..4c21181 100644 --- a/bin/publish-npm +++ b/bin/publish-npm @@ -2,8 +2,24 @@ set -eux -npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN +npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN" +# Build the project yarn build + +# Navigate to the dist directory cd dist -yarn publish --access public + +# Get the version from package.json +VERSION="$(node -p "require('./package.json').version")" + +# Extract the pre-release tag if it exists +if [[ "$VERSION" =~ -([a-zA-Z]+) ]]; then + # Extract the part before any dot in the pre-release identifier + TAG="${BASH_REMATCH[1]}" +else + TAG="latest" +fi + +# Publish with the appropriate tag +yarn publish --access public --tag "$TAG" diff --git a/package.json b/package.json index 2eb5b2e..981d315 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "honcho-ai", - "version": "0.0.4", + "version": "0.0.5", "description": "The official TypeScript library for the Honcho API", "author": "Honcho ", "types": "dist/index.d.ts", @@ -16,7 +16,6 @@ "scripts": { "test": "./scripts/test", "build": "./scripts/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 --cache --cache-strategy metadata . !dist", "prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build; fi", @@ -31,8 +30,7 @@ "agentkeepalive": "^4.2.1", "form-data-encoder": "1.7.2", "formdata-node": "^4.3.2", - "node-fetch": "^2.6.7", - "web-streams-polyfill": "^3.2.1" + "node-fetch": "^2.6.7" }, "devDependencies": { "@swc/core": "^1.3.102", diff --git a/scripts/mock b/scripts/mock index fe89a1d..f586157 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" &> .prism.log & # Wait for server to come online echo -n "Waiting for server" @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" + npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" fi diff --git a/src/_shims/node-runtime.ts b/src/_shims/node-runtime.ts index a9c42eb..ab9f2ab 100644 --- a/src/_shims/node-runtime.ts +++ b/src/_shims/node-runtime.ts @@ -13,9 +13,7 @@ import { Readable } from 'node:stream'; import { type RequestOptions } from '../core'; import { MultipartBody } from './MultipartBody'; import { type Shims } from './registry'; - -// @ts-ignore (this package does not have proper export maps for this export) -import { ReadableStream } from 'web-streams-polyfill/dist/ponyfill.es2018.js'; +import { ReadableStream } from 'node:stream/web'; type FileFromPathOptions = Omit; diff --git a/src/core.ts b/src/core.ts index bed42d6..0f7a3b1 100644 --- a/src/core.ts +++ b/src/core.ts @@ -18,7 +18,7 @@ import { type HeadersInit, } from './_shims/index'; export { type Response }; -import { isMultipartBody } from './uploads'; +import { BlobLike, isBlobLike, isMultipartBody } from './uploads'; export { maybeMultipartFormRequestOptions, multipartFormRequestOptions, @@ -235,7 +235,17 @@ export abstract class APIClient { path: string, opts?: PromiseOrValue>, ): APIPromise { - return this.request(Promise.resolve(opts).then((opts) => ({ method, path, ...opts }))); + return this.request( + Promise.resolve(opts).then(async (opts) => { + const body = + opts && isBlobLike(opts?.body) ? new DataView(await opts.body.arrayBuffer()) + : opts?.body instanceof DataView ? opts.body + : opts?.body instanceof ArrayBuffer ? new DataView(opts.body) + : opts && ArrayBuffer.isView(opts?.body) ? new DataView(opts.body.buffer) + : opts?.body; + return { method, path, ...opts, body }; + }), + ); } getAPIList = AbstractPage>( @@ -257,6 +267,8 @@ export abstract class APIClient { const encoded = encoder.encode(body); return encoded.length.toString(); } + } else if (ArrayBuffer.isView(body)) { + return body.byteLength.toString(); } return null; @@ -266,7 +278,9 @@ export abstract class APIClient { const { method, path, query, headers: headers = {} } = options; const body = - isMultipartBody(options.body) ? options.body.body + ArrayBuffer.isView(options.body) || (options.__binaryRequest && typeof options.body === 'string') ? + options.body + : isMultipartBody(options.body) ? options.body.body : options.body ? JSON.stringify(options.body, null, 2) : null; const contentLength = this.calculateContentLength(body); @@ -721,7 +735,9 @@ export type Headers = Record; export type DefaultQuery = Record; export type KeysEnum = { [P in keyof Required]: true }; -export type RequestOptions | Readable> = { +export type RequestOptions< + Req = unknown | Record | Readable | BlobLike | ArrayBufferView | ArrayBuffer, +> = { method?: HTTPMethod; path?: string; query?: Req | undefined; @@ -735,6 +751,7 @@ export type RequestOptions | Readable> = signal?: AbortSignal | undefined | null; idempotencyKey?: string; + __binaryRequest?: boolean | undefined; __binaryResponse?: boolean | undefined; }; @@ -755,6 +772,7 @@ const requestOptionsKeys: KeysEnum = { signal: true, idempotencyKey: true, + __binaryRequest: true, __binaryResponse: true, }; @@ -767,10 +785,11 @@ export const isRequestOptions = (obj: unknown): obj is RequestOptions => { ); }; -export type FinalRequestOptions | Readable> = RequestOptions & { - method: HTTPMethod; - path: string; -}; +export type FinalRequestOptions | Readable | DataView> = + RequestOptions & { + method: HTTPMethod; + path: string; + }; declare const Deno: any; declare const EdgeRuntime: any; diff --git a/src/index.ts b/src/index.ts index 0c0325f..3e6c217 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from './core'; import * as Errors from './error'; -import { type Agent } from './_shims/index'; import * as Uploads from './uploads'; +import { type Agent } from './_shims/index'; +import * as Core from './core'; import * as Pagination from './pagination'; import * as API from './resources/index'; const environments = { - local: 'http://localhost:8000', demo: 'https://demo.honcho.dev', + local: 'http://localhost:8000', }; type Environment = keyof typeof environments; @@ -23,8 +23,8 @@ export interface ClientOptions { * Specifies the environment to use for the API. * * Each environment maps to a different base URL: - * - `local` corresponds to `http://localhost:8000` * - `demo` corresponds to `https://demo.honcho.dev` + * - `local` corresponds to `http://localhost:8000` */ environment?: Environment; @@ -85,7 +85,9 @@ export interface ClientOptions { defaultQuery?: Core.DefaultQuery; } -/** API Client for interfacing with the Honcho API. */ +/** + * API Client for interfacing with the Honcho API. + */ export class Honcho extends Core.APIClient { apiKey: string | null; @@ -95,8 +97,8 @@ export class Honcho extends Core.APIClient { * API Client for interfacing with the Honcho API. * * @param {string | null | undefined} [opts.apiKey=process.env['HONCHO_API_KEY'] ?? null] - * @param {Environment} [opts.environment=local] - Specifies the environment URL to use for the API. - * @param {string} [opts.baseURL=process.env['HONCHO_BASE_URL'] ?? http://localhost:8000] - Override the default base URL for the API. + * @param {Environment} [opts.environment=demo] - Specifies the environment URL to use for the API. + * @param {string} [opts.baseURL=process.env['HONCHO_BASE_URL'] ?? https://demo.honcho.dev] - 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. @@ -113,7 +115,7 @@ export class Honcho extends Core.APIClient { apiKey, ...opts, baseURL, - environment: opts.environment ?? 'local', + environment: opts.environment ?? 'demo', }; if (baseURL && opts.environment) { @@ -123,12 +125,13 @@ export class Honcho extends Core.APIClient { } super({ - baseURL: options.baseURL || environments[options.environment || 'local'], + baseURL: options.baseURL || environments[options.environment || 'demo'], timeout: options.timeout ?? 60000 /* 1 minute */, httpAgent: options.httpAgent, maxRetries: options.maxRetries, fetch: options.fetch, }); + this._options = options; this.apiKey = apiKey; @@ -147,6 +150,19 @@ export class Honcho extends Core.APIClient { }; } + protected override validateHeaders(headers: Core.Headers, customHeaders: Core.Headers) { + if (this.apiKey && headers['authorization']) { + return; + } + if (customHeaders['authorization'] === null) { + return; + } + + throw new Error( + 'Could not resolve authentication method. Expected the apiKey to be set. Or for the "Authorization" headers to be explicitly omitted', + ); + } + protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers { if (this.apiKey == null) { return {}; @@ -155,6 +171,7 @@ export class Honcho extends Core.APIClient { } static Honcho = this; + static DEFAULT_TIMEOUT = 60000; // 1 minute static HonchoError = Errors.HonchoError; static APIError = Errors.APIError; diff --git a/src/resources/apps/apps.ts b/src/resources/apps/apps.ts index 46b2282..4a2e929 100644 --- a/src/resources/apps/apps.ts +++ b/src/resources/apps/apps.ts @@ -1,7 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../core'; import { APIResource } from '../../resource'; +import * as Core from '../../core'; import * as AppsAPI from './apps'; import * as UsersAPI from './users/users'; diff --git a/src/resources/apps/users/collections/collections.ts b/src/resources/apps/users/collections/collections.ts index 64ddf4a..35f1e3b 100644 --- a/src/resources/apps/users/collections/collections.ts +++ b/src/resources/apps/users/collections/collections.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../../core'; import { APIResource } from '../../../../resource'; import { isRequestOptions } from '../../../../core'; +import * as Core from '../../../../core'; import * as CollectionsAPI from './collections'; import * as DocumentsAPI from './documents'; import { Page, type PageParams } from '../../../../pagination'; @@ -163,9 +163,9 @@ export interface CollectionCreateParams { } export interface CollectionUpdateParams { - name: string; - metadata?: Record | null; + + name?: string | null; } export interface CollectionListParams extends PageParams { diff --git a/src/resources/apps/users/collections/documents.ts b/src/resources/apps/users/collections/documents.ts index c7e7180..a89863f 100644 --- a/src/resources/apps/users/collections/documents.ts +++ b/src/resources/apps/users/collections/documents.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../../core'; import { APIResource } from '../../../../resource'; import { isRequestOptions } from '../../../../core'; +import * as Core from '../../../../core'; import * as DocumentsAPI from './documents'; import { Page, type PageParams } from '../../../../pagination'; diff --git a/src/resources/apps/users/sessions/messages.ts b/src/resources/apps/users/sessions/messages.ts index 5395388..8387161 100644 --- a/src/resources/apps/users/sessions/messages.ts +++ b/src/resources/apps/users/sessions/messages.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../../core'; import { APIResource } from '../../../../resource'; import { isRequestOptions } from '../../../../core'; +import * as Core from '../../../../core'; import * as MessagesAPI from './messages'; import { Page, type PageParams } from '../../../../pagination'; diff --git a/src/resources/apps/users/sessions/metamessages.ts b/src/resources/apps/users/sessions/metamessages.ts index 916ab4d..156dd4e 100644 --- a/src/resources/apps/users/sessions/metamessages.ts +++ b/src/resources/apps/users/sessions/metamessages.ts @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../../core'; import { APIResource } from '../../../../resource'; import { isRequestOptions } from '../../../../core'; +import * as Core from '../../../../core'; import * as MetamessagesAPI from './metamessages'; import { Page, type PageParams } from '../../../../pagination'; export class Metamessages extends APIResource { /** - * Adds a message to a session + * Adds a metamessage to a session * * Args: app_id (uuid.UUID): The ID of the app representing the client application * using honcho user_id (str): The User ID representing the user, managed by the - * user session_id (int): The ID of the Session to add the message to message - * (schemas.MessageCreate): The Message object to add containing the message - * content and type + * user session_id (int): The ID of the Session to add the metamessage to + * metamessage (schemas.MetamessageCreate): The Metamessage object to add + * containing the metamessage content and type * - * Returns: schemas.Message: The Message object of the added message + * Returns: schemas.Metamessage: The Metamessage object of the added metamessage * * Raises: HTTPException: If the session is not found */ diff --git a/src/resources/apps/users/sessions/sessions.ts b/src/resources/apps/users/sessions/sessions.ts index 1f6429c..f697aeb 100644 --- a/src/resources/apps/users/sessions/sessions.ts +++ b/src/resources/apps/users/sessions/sessions.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../../core'; import { APIResource } from '../../../../resource'; import { isRequestOptions } from '../../../../core'; +import * as Core from '../../../../core'; import * as SessionsAPI from './sessions'; import * as MessagesAPI from './messages'; import * as MetamessagesAPI from './metamessages'; @@ -18,7 +18,7 @@ export class Sessions extends APIResource { * Args: app_id (uuid.UUID): The ID of the app representing the client application * using honcho user_id (uuid.UUID): The User ID representing the user, managed by * the user session (schemas.SessionCreate): The Session object containing any - * metadata and a location ID + * metadata * * Returns: schemas.Session: The Session object of the new Session */ @@ -56,8 +56,7 @@ export class Sessions extends APIResource { * * Args: app_id (uuid.UUID): The ID of the app representing the client application * using honcho user_id (uuid.UUID): The User ID representing the user, managed by - * the user location_id (str, optional): Optional Location ID representing the - * location of a session + * the user * * Returns: list[schemas.Session]: List of Session objects */ @@ -181,8 +180,6 @@ export interface Session { is_active: boolean; - location_id: string; - metadata: Record; user_id: string; @@ -193,8 +190,6 @@ export type SessionDeleteResponse = unknown; export type SessionStreamResponse = unknown; export interface SessionCreateParams { - location_id: string; - metadata?: Record | null; } @@ -207,8 +202,6 @@ export interface SessionListParams extends PageParams { is_active?: boolean | null; - location_id?: string | null; - reverse?: boolean | null; } diff --git a/src/resources/apps/users/users.ts b/src/resources/apps/users/users.ts index 1fca410..97c4641 100644 --- a/src/resources/apps/users/users.ts +++ b/src/resources/apps/users/users.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../core'; import { APIResource } from '../../../resource'; import { isRequestOptions } from '../../../core'; +import * as Core from '../../../core'; import * as UsersAPI from './users'; import * as CollectionsAPI from './collections/collections'; import * as SessionsAPI from './sessions/sessions'; diff --git a/src/version.ts b/src/version.ts index 79eabb0..2922e88 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.0.4'; // x-release-please-version +export const VERSION = '0.0.5'; // x-release-please-version diff --git a/tests/api-resources/apps/apps.test.ts b/tests/api-resources/apps/apps.test.ts index bebd006..b4bb873 100644 --- a/tests/api-resources/apps/apps.test.ts +++ b/tests/api-resources/apps/apps.test.ts @@ -3,14 +3,14 @@ import Honcho from 'honcho-ai'; import { Response } from 'node-fetch'; -const honcho = new Honcho({ +const client = new Honcho({ apiKey: 'My API Key', baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource apps', () => { test('create: only required params', async () => { - const responsePromise = honcho.apps.create({ name: 'string' }); + const responsePromise = client.apps.create({ name: 'name' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,11 +21,11 @@ describe('resource apps', () => { }); test('create: required and optional params', async () => { - const response = await honcho.apps.create({ name: 'string', metadata: { foo: 'bar' } }); + const response = await client.apps.create({ name: 'name', metadata: { foo: 'bar' } }); }); test('update', async () => { - const responsePromise = honcho.apps.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); + const responsePromise = client.apps.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -36,7 +36,7 @@ describe('resource apps', () => { }); test('get', async () => { - const responsePromise = honcho.apps.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.apps.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -49,12 +49,12 @@ describe('resource apps', () => { test('get: 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( - honcho.apps.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + client.apps.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Honcho.NotFoundError); }); test('getByName', async () => { - const responsePromise = honcho.apps.getByName('string'); + const responsePromise = client.apps.getByName('name'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -66,13 +66,13 @@ describe('resource apps', () => { test('getByName: 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(honcho.apps.getByName('string', { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.apps.getByName('name', { path: '/_stainless_unknown_path' })).rejects.toThrow( Honcho.NotFoundError, ); }); test('getOrCreate', async () => { - const responsePromise = honcho.apps.getOrCreate('string'); + const responsePromise = client.apps.getOrCreate('name'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -84,7 +84,7 @@ describe('resource apps', () => { test('getOrCreate: 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(honcho.apps.getOrCreate('string', { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.apps.getOrCreate('name', { path: '/_stainless_unknown_path' })).rejects.toThrow( Honcho.NotFoundError, ); }); diff --git a/tests/api-resources/apps/users/collections/collections.test.ts b/tests/api-resources/apps/users/collections/collections.test.ts index 21c043c..8b20218 100644 --- a/tests/api-resources/apps/users/collections/collections.test.ts +++ b/tests/api-resources/apps/users/collections/collections.test.ts @@ -3,17 +3,17 @@ import Honcho from 'honcho-ai'; import { Response } from 'node-fetch'; -const honcho = new Honcho({ +const client = new Honcho({ apiKey: 'My API Key', baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource collections', () => { test('create: only required params', async () => { - const responsePromise = honcho.apps.users.collections.create( + const responsePromise = client.apps.users.collections.create( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { name: 'string' }, + { name: 'name' }, ); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -25,19 +25,19 @@ describe('resource collections', () => { }); test('create: required and optional params', async () => { - const response = await honcho.apps.users.collections.create( + const response = await client.apps.users.collections.create( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { name: 'string', metadata: { foo: 'bar' } }, + { name: 'name', metadata: { foo: 'bar' } }, ); }); - test('update: only required params', async () => { - const responsePromise = honcho.apps.users.collections.update( + test('update', async () => { + const responsePromise = client.apps.users.collections.update( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { name: 'string' }, + {}, ); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -48,17 +48,8 @@ describe('resource collections', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - test('update: required and optional params', async () => { - const response = await honcho.apps.users.collections.update( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { name: 'string', metadata: { foo: 'bar' } }, - ); - }); - test('list', async () => { - const responsePromise = honcho.apps.users.collections.list( + const responsePromise = client.apps.users.collections.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', ); @@ -74,7 +65,7 @@ describe('resource collections', () => { test('list: 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( - honcho.apps.users.collections.list( + client.apps.users.collections.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }, @@ -85,17 +76,17 @@ describe('resource collections', () => { test('list: 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( - honcho.apps.users.collections.list( + client.apps.users.collections.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { filter: 'string', page: 1, reverse: true, size: 1 }, + { filter: 'filter', page: 1, reverse: true, size: 1 }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(Honcho.NotFoundError); }); test('delete', async () => { - const responsePromise = honcho.apps.users.collections.delete( + const responsePromise = client.apps.users.collections.delete( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -112,7 +103,7 @@ describe('resource collections', () => { test('delete: 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( - honcho.apps.users.collections.delete( + client.apps.users.collections.delete( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -122,7 +113,7 @@ describe('resource collections', () => { }); test('get', async () => { - const responsePromise = honcho.apps.users.collections.get( + const responsePromise = client.apps.users.collections.get( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -139,7 +130,7 @@ describe('resource collections', () => { test('get: 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( - honcho.apps.users.collections.get( + client.apps.users.collections.get( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -149,10 +140,10 @@ describe('resource collections', () => { }); test('getByName', async () => { - const responsePromise = honcho.apps.users.collections.getByName( + const responsePromise = client.apps.users.collections.getByName( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - 'string', + 'name', ); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -166,21 +157,21 @@ describe('resource collections', () => { test('getByName: 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( - honcho.apps.users.collections.getByName( + client.apps.users.collections.getByName( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - 'string', + 'name', { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(Honcho.NotFoundError); }); test('query: only required params', async () => { - const responsePromise = honcho.apps.users.collections.query( + const responsePromise = client.apps.users.collections.query( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { query: 'string' }, + { query: 'query' }, ); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -192,11 +183,11 @@ describe('resource collections', () => { }); test('query: required and optional params', async () => { - const response = await honcho.apps.users.collections.query( + const response = await client.apps.users.collections.query( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { query: 'string', filter: 'string', top_k: 0 }, + { query: 'query', filter: 'filter', top_k: 0 }, ); }); }); diff --git a/tests/api-resources/apps/users/collections/documents.test.ts b/tests/api-resources/apps/users/collections/documents.test.ts index 403dee6..147ba52 100644 --- a/tests/api-resources/apps/users/collections/documents.test.ts +++ b/tests/api-resources/apps/users/collections/documents.test.ts @@ -3,18 +3,18 @@ import Honcho from 'honcho-ai'; import { Response } from 'node-fetch'; -const honcho = new Honcho({ +const client = new Honcho({ apiKey: 'My API Key', baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource documents', () => { test('create: only required params', async () => { - const responsePromise = honcho.apps.users.collections.documents.create( + const responsePromise = client.apps.users.collections.documents.create( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { content: 'string' }, + { content: 'content' }, ); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -26,16 +26,16 @@ describe('resource documents', () => { }); test('create: required and optional params', async () => { - const response = await honcho.apps.users.collections.documents.create( + const response = await client.apps.users.collections.documents.create( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { content: 'string', metadata: { foo: 'bar' } }, + { content: 'content', metadata: { foo: 'bar' } }, ); }); test('update', async () => { - const responsePromise = honcho.apps.users.collections.documents.update( + const responsePromise = client.apps.users.collections.documents.update( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -52,7 +52,7 @@ describe('resource documents', () => { }); test('list', async () => { - const responsePromise = honcho.apps.users.collections.documents.list( + const responsePromise = client.apps.users.collections.documents.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -69,7 +69,7 @@ describe('resource documents', () => { test('list: 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( - honcho.apps.users.collections.documents.list( + client.apps.users.collections.documents.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -81,18 +81,18 @@ describe('resource documents', () => { test('list: 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( - honcho.apps.users.collections.documents.list( + client.apps.users.collections.documents.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { filter: 'string', page: 1, reverse: true, size: 1 }, + { filter: 'filter', page: 1, reverse: true, size: 1 }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(Honcho.NotFoundError); }); test('delete', async () => { - const responsePromise = honcho.apps.users.collections.documents.delete( + const responsePromise = client.apps.users.collections.documents.delete( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -110,7 +110,7 @@ describe('resource documents', () => { test('delete: 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( - honcho.apps.users.collections.documents.delete( + client.apps.users.collections.documents.delete( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -121,7 +121,7 @@ describe('resource documents', () => { }); test('get', async () => { - const responsePromise = honcho.apps.users.collections.documents.get( + const responsePromise = client.apps.users.collections.documents.get( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -139,7 +139,7 @@ describe('resource documents', () => { test('get: 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( - honcho.apps.users.collections.documents.get( + client.apps.users.collections.documents.get( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', diff --git a/tests/api-resources/apps/users/sessions/messages.test.ts b/tests/api-resources/apps/users/sessions/messages.test.ts index 4253e41..3c75884 100644 --- a/tests/api-resources/apps/users/sessions/messages.test.ts +++ b/tests/api-resources/apps/users/sessions/messages.test.ts @@ -3,18 +3,18 @@ import Honcho from 'honcho-ai'; import { Response } from 'node-fetch'; -const honcho = new Honcho({ +const client = new Honcho({ apiKey: 'My API Key', baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource messages', () => { test('create: only required params', async () => { - const responsePromise = honcho.apps.users.sessions.messages.create( + const responsePromise = client.apps.users.sessions.messages.create( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { content: 'string', is_user: true }, + { content: 'content', is_user: true }, ); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -26,16 +26,16 @@ describe('resource messages', () => { }); test('create: required and optional params', async () => { - const response = await honcho.apps.users.sessions.messages.create( + const response = await client.apps.users.sessions.messages.create( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { content: 'string', is_user: true, metadata: { foo: 'bar' } }, + { content: 'content', is_user: true, metadata: { foo: 'bar' } }, ); }); test('update', async () => { - const responsePromise = honcho.apps.users.sessions.messages.update( + const responsePromise = client.apps.users.sessions.messages.update( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -52,7 +52,7 @@ describe('resource messages', () => { }); test('list', async () => { - const responsePromise = honcho.apps.users.sessions.messages.list( + const responsePromise = client.apps.users.sessions.messages.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -69,7 +69,7 @@ describe('resource messages', () => { test('list: 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( - honcho.apps.users.sessions.messages.list( + client.apps.users.sessions.messages.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -81,18 +81,18 @@ describe('resource messages', () => { test('list: 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( - honcho.apps.users.sessions.messages.list( + client.apps.users.sessions.messages.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { filter: 'string', page: 1, reverse: true, size: 1 }, + { filter: 'filter', page: 1, reverse: true, size: 1 }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(Honcho.NotFoundError); }); test('get', async () => { - const responsePromise = honcho.apps.users.sessions.messages.get( + const responsePromise = client.apps.users.sessions.messages.get( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -110,7 +110,7 @@ describe('resource messages', () => { test('get: 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( - honcho.apps.users.sessions.messages.get( + client.apps.users.sessions.messages.get( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', diff --git a/tests/api-resources/apps/users/sessions/metamessages.test.ts b/tests/api-resources/apps/users/sessions/metamessages.test.ts index 9bd8c06..a3c5b60 100644 --- a/tests/api-resources/apps/users/sessions/metamessages.test.ts +++ b/tests/api-resources/apps/users/sessions/metamessages.test.ts @@ -3,18 +3,22 @@ import Honcho from 'honcho-ai'; import { Response } from 'node-fetch'; -const honcho = new Honcho({ +const client = new Honcho({ apiKey: 'My API Key', baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource metamessages', () => { test('create: only required params', async () => { - const responsePromise = honcho.apps.users.sessions.metamessages.create( + const responsePromise = client.apps.users.sessions.metamessages.create( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { content: 'string', message_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', metamessage_type: 'string' }, + { + content: 'content', + message_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + metamessage_type: 'metamessage_type', + }, ); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -26,21 +30,21 @@ describe('resource metamessages', () => { }); test('create: required and optional params', async () => { - const response = await honcho.apps.users.sessions.metamessages.create( + const response = await client.apps.users.sessions.metamessages.create( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { - content: 'string', + content: 'content', message_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - metamessage_type: 'string', + metamessage_type: 'metamessage_type', metadata: { foo: 'bar' }, }, ); }); test('update: only required params', async () => { - const responsePromise = honcho.apps.users.sessions.metamessages.update( + const responsePromise = client.apps.users.sessions.metamessages.update( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -57,7 +61,7 @@ describe('resource metamessages', () => { }); test('update: required and optional params', async () => { - const response = await honcho.apps.users.sessions.metamessages.update( + const response = await client.apps.users.sessions.metamessages.update( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -65,13 +69,13 @@ describe('resource metamessages', () => { { message_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', metadata: { foo: 'bar' }, - metamessage_type: 'string', + metamessage_type: 'metamessage_type', }, ); }); test('list', async () => { - const responsePromise = honcho.apps.users.sessions.metamessages.list( + const responsePromise = client.apps.users.sessions.metamessages.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -88,7 +92,7 @@ describe('resource metamessages', () => { test('list: 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( - honcho.apps.users.sessions.metamessages.list( + client.apps.users.sessions.metamessages.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -100,14 +104,14 @@ describe('resource metamessages', () => { test('list: 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( - honcho.apps.users.sessions.metamessages.list( + client.apps.users.sessions.metamessages.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { - filter: 'string', + filter: 'filter', message_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - metamessage_type: 'string', + metamessage_type: 'metamessage_type', page: 1, reverse: true, size: 1, @@ -118,7 +122,7 @@ describe('resource metamessages', () => { }); test('get: only required params', async () => { - const responsePromise = honcho.apps.users.sessions.metamessages.get( + const responsePromise = client.apps.users.sessions.metamessages.get( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -135,7 +139,7 @@ describe('resource metamessages', () => { }); test('get: required and optional params', async () => { - const response = await honcho.apps.users.sessions.metamessages.get( + const response = await client.apps.users.sessions.metamessages.get( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', diff --git a/tests/api-resources/apps/users/sessions/sessions.test.ts b/tests/api-resources/apps/users/sessions/sessions.test.ts index 4c40b52..3d2ce39 100644 --- a/tests/api-resources/apps/users/sessions/sessions.test.ts +++ b/tests/api-resources/apps/users/sessions/sessions.test.ts @@ -3,17 +3,17 @@ import Honcho from 'honcho-ai'; import { Response } from 'node-fetch'; -const honcho = new Honcho({ +const client = new Honcho({ apiKey: 'My API Key', baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource sessions', () => { - test('create: only required params', async () => { - const responsePromise = honcho.apps.users.sessions.create( + test('create', async () => { + const responsePromise = client.apps.users.sessions.create( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { location_id: 'string' }, + {}, ); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -24,16 +24,8 @@ describe('resource sessions', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - test('create: required and optional params', async () => { - const response = await honcho.apps.users.sessions.create( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { location_id: 'string', metadata: { foo: 'bar' } }, - ); - }); - test('update', async () => { - const responsePromise = honcho.apps.users.sessions.update( + const responsePromise = client.apps.users.sessions.update( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -49,7 +41,7 @@ describe('resource sessions', () => { }); test('list', async () => { - const responsePromise = honcho.apps.users.sessions.list( + const responsePromise = client.apps.users.sessions.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', ); @@ -65,7 +57,7 @@ describe('resource sessions', () => { test('list: 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( - honcho.apps.users.sessions.list( + client.apps.users.sessions.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }, @@ -76,17 +68,17 @@ describe('resource sessions', () => { test('list: 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( - honcho.apps.users.sessions.list( + client.apps.users.sessions.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { filter: 'string', is_active: true, location_id: 'string', page: 1, reverse: true, size: 1 }, + { filter: 'filter', is_active: true, page: 1, reverse: true, size: 1 }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(Honcho.NotFoundError); }); test('delete', async () => { - const responsePromise = honcho.apps.users.sessions.delete( + const responsePromise = client.apps.users.sessions.delete( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -103,7 +95,7 @@ describe('resource sessions', () => { test('delete: 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( - honcho.apps.users.sessions.delete( + client.apps.users.sessions.delete( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -113,11 +105,11 @@ describe('resource sessions', () => { }); test('chat: only required params', async () => { - const responsePromise = honcho.apps.users.sessions.chat( + const responsePromise = client.apps.users.sessions.chat( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { query: 'string' }, + { query: 'query' }, ); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -129,16 +121,16 @@ describe('resource sessions', () => { }); test('chat: required and optional params', async () => { - const response = await honcho.apps.users.sessions.chat( + const response = await client.apps.users.sessions.chat( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { query: 'string' }, + { query: 'query' }, ); }); test('get', async () => { - const responsePromise = honcho.apps.users.sessions.get( + const responsePromise = client.apps.users.sessions.get( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -155,7 +147,7 @@ describe('resource sessions', () => { test('get: 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( - honcho.apps.users.sessions.get( + client.apps.users.sessions.get( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', @@ -165,11 +157,11 @@ describe('resource sessions', () => { }); test('stream: only required params', async () => { - const responsePromise = honcho.apps.users.sessions.stream( + const responsePromise = client.apps.users.sessions.stream( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { query: 'string' }, + { query: 'query' }, ); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -181,11 +173,11 @@ describe('resource sessions', () => { }); test('stream: required and optional params', async () => { - const response = await honcho.apps.users.sessions.stream( + const response = await client.apps.users.sessions.stream( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { query: 'string' }, + { query: 'query' }, ); }); }); diff --git a/tests/api-resources/apps/users/users.test.ts b/tests/api-resources/apps/users/users.test.ts index 97150b3..5724af2 100644 --- a/tests/api-resources/apps/users/users.test.ts +++ b/tests/api-resources/apps/users/users.test.ts @@ -3,15 +3,15 @@ import Honcho from 'honcho-ai'; import { Response } from 'node-fetch'; -const honcho = new Honcho({ +const client = new Honcho({ apiKey: 'My API Key', baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource users', () => { test('create: only required params', async () => { - const responsePromise = honcho.apps.users.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { - name: 'string', + const responsePromise = client.apps.users.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + name: 'name', }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -23,14 +23,14 @@ describe('resource users', () => { }); test('create: required and optional params', async () => { - const response = await honcho.apps.users.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { - name: 'string', + const response = await client.apps.users.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + name: 'name', metadata: { foo: 'bar' }, }); }); test('update', async () => { - const responsePromise = honcho.apps.users.update( + const responsePromise = client.apps.users.update( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}, @@ -45,7 +45,7 @@ describe('resource users', () => { }); test('list', async () => { - const responsePromise = honcho.apps.users.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.apps.users.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -58,23 +58,23 @@ describe('resource users', () => { test('list: 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( - honcho.apps.users.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + client.apps.users.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Honcho.NotFoundError); }); test('list: 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( - honcho.apps.users.list( + client.apps.users.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { filter: 'string', page: 1, reverse: true, size: 1 }, + { filter: 'filter', page: 1, reverse: true, size: 1 }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(Honcho.NotFoundError); }); test('get', async () => { - const responsePromise = honcho.apps.users.get( + const responsePromise = client.apps.users.get( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', ); @@ -90,14 +90,14 @@ describe('resource users', () => { test('get: 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( - honcho.apps.users.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + client.apps.users.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path', }), ).rejects.toThrow(Honcho.NotFoundError); }); test('getByName', async () => { - const responsePromise = honcho.apps.users.getByName('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', 'string'); + const responsePromise = client.apps.users.getByName('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', 'name'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -110,14 +110,14 @@ describe('resource users', () => { test('getByName: 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( - honcho.apps.users.getByName('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', 'string', { + client.apps.users.getByName('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', 'name', { path: '/_stainless_unknown_path', }), ).rejects.toThrow(Honcho.NotFoundError); }); test('getOrCreate', async () => { - const responsePromise = honcho.apps.users.getOrCreate('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', 'string'); + const responsePromise = client.apps.users.getOrCreate('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', 'name'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -130,7 +130,7 @@ describe('resource users', () => { test('getOrCreate: 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( - honcho.apps.users.getOrCreate('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', 'string', { + client.apps.users.getOrCreate('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', 'name', { path: '/_stainless_unknown_path', }), ).rejects.toThrow(Honcho.NotFoundError); diff --git a/tests/index.test.ts b/tests/index.test.ts index 1f9ec62..b0376ba 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -151,26 +151,26 @@ describe('instantiate client', () => { test('empty env variable', () => { process.env['HONCHO_BASE_URL'] = ''; // empty const client = new Honcho({ apiKey: 'My API Key' }); - expect(client.baseURL).toEqual('http://localhost:8000'); + expect(client.baseURL).toEqual('https://demo.honcho.dev'); }); test('blank env variable', () => { process.env['HONCHO_BASE_URL'] = ' '; // blank const client = new Honcho({ apiKey: 'My API Key' }); - expect(client.baseURL).toEqual('http://localhost:8000'); + expect(client.baseURL).toEqual('https://demo.honcho.dev'); }); test('env variable with environment', () => { process.env['HONCHO_BASE_URL'] = 'https://example.com/from_env'; expect( - () => new Honcho({ apiKey: 'My API Key', environment: 'local' }), + () => new Honcho({ apiKey: 'My API Key', environment: 'demo' }), ).toThrowErrorMatchingInlineSnapshot( `"Ambiguous URL; The \`baseURL\` option (or HONCHO_BASE_URL env var) and the \`environment\` option are given. If you want to use the environment you must pass baseURL: null"`, ); - const client = new Honcho({ apiKey: 'My API Key', baseURL: null, environment: 'local' }); - expect(client.baseURL).toEqual('http://localhost:8000'); + const client = new Honcho({ apiKey: 'My API Key', baseURL: null, environment: 'demo' }); + expect(client.baseURL).toEqual('https://demo.honcho.dev'); }); }); diff --git a/tests/stringifyQuery.test.ts b/tests/stringifyQuery.test.ts index bee9edc..467dc37 100644 --- a/tests/stringifyQuery.test.ts +++ b/tests/stringifyQuery.test.ts @@ -1,8 +1,10 @@ -import { APIClient } from 'honcho-ai/core'; +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -const { stringifyQuery } = APIClient.prototype as any; +import { Honcho } from 'honcho-ai'; -describe('APIClient.stringifyQuery', () => { +const { stringifyQuery } = Honcho.prototype as any; + +describe(stringifyQuery, () => { for (const [input, expected] of [ [{ a: '1', b: 2, c: true }, 'a=1&b=2&c=true'], [{ a: null, b: false, c: undefined }, 'a=&b=false'], @@ -18,6 +20,7 @@ describe('APIClient.stringifyQuery', () => { expect(stringifyQuery(input)).toEqual(expected); }); } + for (const value of [[], {}, new Date()]) { it(`${JSON.stringify(value)} -> `, () => { expect(() => stringifyQuery({ value })).toThrow(`Cannot stringify type ${typeof value}`); diff --git a/yarn.lock b/yarn.lock index dda4d2e..358dbf2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3412,11 +3412,6 @@ web-streams-polyfill@4.0.0-beta.1: resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.1.tgz#3b19b9817374b7cee06d374ba7eeb3aeb80e8c95" integrity sha512-3ux37gEX670UUphBF9AMCq8XM6iQ8Ac6A+DSRRjDoRBm1ufCkaCDdNVbaqq60PsEkdNlLKrGtv/YBP4EJXqNtQ== -web-streams-polyfill@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz#71c2718c52b45fd49dbeee88634b3a60ceab42a6" - integrity sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q== - webidl-conversions@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"