Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jul 31, 2024
1 parent 67519e0 commit f1760b0
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 42 deletions.
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-9de9efee1447340a4b99258885f8c5472ee853fa3bc7327fd632be3c5f23f161.yml
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Honcho API Library
# honcho-ai API Library

[![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)

Expand Down
2 changes: 1 addition & 1 deletion scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Environment = keyof typeof environments;

export interface ClientOptions {
/**
* API Key
* Defaults to process.env['HONCHO_API_KEY'].
*/
apiKey?: string | null | undefined;

Expand Down
4 changes: 2 additions & 2 deletions src/resources/apps/users/collections/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ export interface CollectionCreateParams {
}

export interface CollectionUpdateParams {
name: string;

metadata?: Record<string, unknown> | null;

name?: string | null;
}

export interface CollectionListParams extends PageParams {
Expand Down
10 changes: 5 additions & 5 deletions src/resources/apps/users/sessions/metamessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ 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
*/
Expand Down
11 changes: 2 additions & 9 deletions src/resources/apps/users/sessions/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -181,8 +180,6 @@ export interface Session {

is_active: boolean;

location_id: string;

metadata: Record<string, unknown>;

user_id: string;
Expand All @@ -193,8 +190,6 @@ export type SessionDeleteResponse = unknown;
export type SessionStreamResponse = unknown;

export interface SessionCreateParams {
location_id: string;

metadata?: Record<string, unknown> | null;
}

Expand All @@ -207,8 +202,6 @@ export interface SessionListParams extends PageParams {

is_active?: boolean | null;

location_id?: string | null;

reverse?: boolean | null;
}

Expand Down
13 changes: 2 additions & 11 deletions tests/api-resources/apps/users/collections/collections.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ describe('resource collections', () => {
);
});

test('update: only required params', async () => {
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: 'name' },
{},
);
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
Expand All @@ -48,15 +48,6 @@ describe('resource collections', () => {
expect(dataAndResponse.response).toBe(rawResponse);
});

test('update: required and optional params', async () => {
const response = await client.apps.users.collections.update(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ name: 'name', metadata: { foo: 'bar' } },
);
});

test('list', async () => {
const responsePromise = client.apps.users.collections.list(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
Expand Down
14 changes: 3 additions & 11 deletions tests/api-resources/apps/users/sessions/sessions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const client = new Honcho({
});

describe('resource sessions', () => {
test('create: only required params', async () => {
test('create', async () => {
const responsePromise = client.apps.users.sessions.create(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ location_id: 'location_id' },
{},
);
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
Expand All @@ -24,14 +24,6 @@ describe('resource sessions', () => {
expect(dataAndResponse.response).toBe(rawResponse);
});

test('create: required and optional params', async () => {
const response = await client.apps.users.sessions.create(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ location_id: 'location_id', metadata: { foo: 'bar' } },
);
});

test('update', async () => {
const responsePromise = client.apps.users.sessions.update(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
Expand Down Expand Up @@ -79,7 +71,7 @@ describe('resource sessions', () => {
client.apps.users.sessions.list(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ filter: 'filter', is_active: true, location_id: 'location_id', 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);
Expand Down

0 comments on commit f1760b0

Please sign in to comment.