Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.0.5 #20

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
pull_request:
branches:
- main
- next

jobs:
lint:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Release Doctor
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.prism.log
node_modules
yarn-error.log
codegen.log
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.0.4"
".": "0.1.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 0.1.0 (2024-08-01)

Full Changelog: [v0.0.4...v0.1.0](https://github.com/plastic-labs/honcho-node/compare/v0.0.4...v0.1.0)

### 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

* **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))
* **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)
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ cd honcho-node
# With yarn
yarn link
cd ../my-package
yarn link honcho-ai
yarn link honcho

# With pnpm
pnpm link --global
cd ../my-package
pnpm link -—global honcho-ai
pnpm link -—global honcho
```

## Running tests
Expand Down
68 changes: 30 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Honcho Node API Library
# honcho-ai 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.svg)](https://npmjs.org/package/honcho) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/honcho)

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/).

## Installation

```sh
npm install honcho-ai
npm install honcho
```

## Usage
Expand All @@ -20,15 +20,15 @@ The full API of this library can be found in [api.md](api.md).

<!-- prettier-ignore -->
```js
import Honcho from 'honcho-ai';
import Honcho from 'honcho';

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);
}
Expand All @@ -42,16 +42,16 @@ This library includes TypeScript definitions for all request params and response

<!-- prettier-ignore -->
```ts
import Honcho from 'honcho-ai';
import Honcho from 'honcho';

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();
Expand All @@ -68,7 +68,7 @@ a subclass of `APIError` will be thrown:
<!-- prettier-ignore -->
```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
Expand Down Expand Up @@ -106,12 +106,12 @@ You can use the `maxRetries` option to configure or disable this:
<!-- prettier-ignore -->
```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,
});
```
Expand All @@ -123,12 +123,12 @@ Requests time out after 1 minute by default. You can configure this with a `time
<!-- prettier-ignore -->
```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,
});
```
Expand All @@ -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;
Expand All @@ -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);
}
Expand All @@ -178,13 +178,13 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi

<!-- prettier-ignore -->
```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);
```
Expand Down Expand Up @@ -244,11 +244,11 @@ add the following import before your first import `from "Honcho"`:
```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 'honcho-ai/shims/web';
import Honcho from 'honcho-ai';
import 'honcho/shims/web';
import Honcho from 'honcho';
```

To do the inverse, add `import "honcho-ai/shims/node"` (which does import polyfills).
To do the inverse, add `import "honcho/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/plastic-labs/honcho-node/tree/main/src/_shims#readme)).

### Logging and middleware
Expand All @@ -258,7 +258,7 @@ which can be used to inspect or alter the `Request` or `Response` before/after e

```ts
import { fetch } from 'undici'; // as one example
import Honcho from 'honcho-ai';
import Honcho from 'honcho';

const client = new Honcho({
fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
Expand All @@ -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 }),
},
Expand All @@ -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.
6 changes: 3 additions & 3 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const config: JestConfigWithTsJest = {
'^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }],
},
moduleNameMapper: {
'^honcho-ai$': '<rootDir>/src/index.ts',
'^honcho-ai/_shims/auto/(.*)$': '<rootDir>/src/_shims/auto/$1-node',
'^honcho-ai/(.*)$': '<rootDir>/src/$1',
'^honcho$': '<rootDir>/src/index.ts',
'^honcho/_shims/auto/(.*)$': '<rootDir>/src/_shims/auto/$1-node',
'^honcho/(.*)$': '<rootDir>/src/$1',
},
modulePathIgnorePatterns: [
'<rootDir>/ecosystem-tests/',
Expand Down
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "honcho-ai",
"version": "0.0.4",
"name": "honcho",
"version": "0.1.0",
"description": "The official TypeScript library for the Honcho API",
"author": "Honcho <[email protected]>",
"types": "dist/index.d.ts",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -61,8 +59,8 @@
"./shims/web.mjs"
],
"imports": {
"honcho-ai": ".",
"honcho-ai/*": "./src/*"
"honcho": ".",
"honcho/*": "./src/*"
},
"exports": {
"./_shims/auto/*": {
Expand Down
8 changes: 4 additions & 4 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -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 <package root>/resources/foo.js
# This way importing from `"honcho-ai/resources/foo"` works
# This way importing from `"honcho/resources/foo"` works
# even with `"moduleResolution": "node"`

rm -rf dist; mkdir dist
Expand All @@ -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 = Honcho Node to index.js;
# we need to add exports = module.exports = honcho-ai 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
Expand All @@ -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("honcho-ai")')
(cd dist && node -e 'import("honcho-ai")' --input-type=module)
(cd dist && node -e 'require("honcho")')
(cd dist && node -e 'import("honcho")' --input-type=module)

if command -v deno &> /dev/null && [ -e ./scripts/build-deno ]
then
Expand Down
4 changes: 2 additions & 2 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected].4 -- prism mock "$URL" &> .prism.log &

# Wait for server to come online
echo -n "Waiting for server"
Expand All @@ -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/[email protected].4 -- prism mock "$URL"
fi
4 changes: 2 additions & 2 deletions scripts/utils/postprocess-files.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ?? 'honcho-ai/';
const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? 'honcho/';

const distDir =
process.env['DIST_PATH'] ?
Expand Down Expand Up @@ -142,7 +142,7 @@ async function postprocess() {

if (file.endsWith('.d.ts')) {
// work around bad tsc behavior
// if we have `import { type Readable } from 'honcho-ai/_shims/index'`,
// if we have `import { type Readable } from 'honcho/_shims/index'`,
// tsc sometimes replaces `Readable` with `import("stream").Readable` inline
// in the output .d.ts
transformed = transformed.replace(/import\("stream"\).Readable/g, 'Readable');
Expand Down
Loading