Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed May 23, 2024
1 parent a97cf54 commit 99a66ce
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 31 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-9c3f3823cc0decee65ba1dd592f62942ba230629e291b01f5b6e8b6088dd87c1.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/plastic-labs%2FHoncho-7967581df14089cda98ce7bd258102d5da5ec541dc5b17aa918f96be11a2bde8.yml
17 changes: 10 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface ClientOptions {
/**
* Defaults to process.env['HONCHO_AUTH_TOKEN'].
*/
apiKey?: string | null | undefined;
apiKey?: string | undefined;

/**
* Specifies the environment to use for the API.
Expand Down Expand Up @@ -87,14 +87,14 @@ export interface ClientOptions {

/** API Client for interfacing with the Honcho API. */
export class Honcho extends Core.APIClient {
apiKey: string | null;
apiKey: string;

private _options: ClientOptions;

/**
* API Client for interfacing with the Honcho API.
*
* @param {string | null | undefined} [opts.apiKey=process.env['HONCHO_AUTH_TOKEN'] ?? null]
* @param {string | undefined} [opts.apiKey=process.env['HONCHO_AUTH_TOKEN'] ?? undefined]
* @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 {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
Expand All @@ -106,9 +106,15 @@ export class Honcho extends Core.APIClient {
*/
constructor({
baseURL = Core.readEnv('HONCHO_BASE_URL'),
apiKey = Core.readEnv('HONCHO_AUTH_TOKEN') ?? null,
apiKey = Core.readEnv('HONCHO_AUTH_TOKEN'),
...opts
}: ClientOptions = {}) {
if (apiKey === undefined) {
throw new Errors.HonchoError(
"The HONCHO_AUTH_TOKEN environment variable is missing or empty; either provide it, or instantiate the Honcho client with an apiKey option, like new Honcho({ apiKey: 'My API Key' }).",
);
}

const options: ClientOptions = {
apiKey,
...opts,
Expand Down Expand Up @@ -148,9 +154,6 @@ export class Honcho extends Core.APIClient {
}

protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
if (this.apiKey == null) {
return {};
}
return { Authorization: `Bearer ${this.apiKey}` };
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/apps/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export interface AppCreateParams {
}

export interface AppUpdateParams {
metadata?: unknown | null;
metadata?: Record<string, unknown> | null;

name?: string | null;
}
Expand Down
6 changes: 3 additions & 3 deletions src/resources/apps/users/collections/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export interface Collection {

created_at: string;

metadata: unknown;
metadata: Record<string, unknown>;

name: string;

Expand All @@ -159,13 +159,13 @@ export type CollectionQueryResponse = Array<DocumentsAPI.Document>;
export interface CollectionCreateParams {
name: string;

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

export interface CollectionUpdateParams {
name: string;

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

export interface CollectionListParams extends PageParams {
Expand Down
6 changes: 3 additions & 3 deletions src/resources/apps/users/collections/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export interface Document {

created_at: string;

metadata: unknown;
metadata: Record<string, unknown>;
}

export interface PageDocument {
Expand All @@ -137,13 +137,13 @@ export type DocumentDeleteResponse = unknown;
export interface DocumentCreateParams {
content: string;

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

export interface DocumentUpdateParams {
content?: string | null;

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

export interface DocumentListParams extends PageParams {
Expand Down
6 changes: 3 additions & 3 deletions src/resources/apps/users/sessions/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export interface Message {

is_user: boolean;

metadata: unknown;
metadata: Record<string, unknown>;

session_id: string;
}
Expand All @@ -142,11 +142,11 @@ export interface MessageCreateParams {

is_user: boolean;

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

export interface MessageUpdateParams {
metadata?: unknown | null;
metadata?: Record<string, unknown> | null;
}

export interface MessageListParams extends PageParams {
Expand Down
6 changes: 3 additions & 3 deletions src/resources/apps/users/sessions/metamessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export interface Metamessage {

message_id: string;

metadata: unknown;
metadata: Record<string, unknown>;

metamessage_type: string;
}
Expand All @@ -153,13 +153,13 @@ export interface MetamessageCreateParams {

metamessage_type: string;

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

export interface MetamessageUpdateParams {
message_id: string;

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

metamessage_type?: string | null;
}
Expand Down
6 changes: 3 additions & 3 deletions src/resources/apps/users/sessions/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export interface Session {

location_id: string;

metadata: unknown;
metadata: Record<string, unknown>;

user_id: string;
}
Expand All @@ -195,11 +195,11 @@ export type SessionStreamResponse = unknown;
export interface SessionCreateParams {
location_id: string;

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

export interface SessionUpdateParams {
metadata?: unknown | null;
metadata?: Record<string, unknown> | null;
}

export interface SessionListParams extends PageParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('resource collections', () => {
const response = await honcho.apps.users.collections.create(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ name: 'string', metadata: {} },
{ name: 'string', metadata: { foo: 'bar' } },
);
});

Expand All @@ -53,7 +53,7 @@ describe('resource collections', () => {
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ name: 'string', metadata: {} },
{ name: 'string', metadata: { foo: 'bar' } },
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('resource documents', () => {
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ content: 'string', metadata: {} },
{ content: 'string', metadata: { foo: 'bar' } },
);
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/apps/users/sessions/messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('resource messages', () => {
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ content: 'string', is_user: true, metadata: {} },
{ content: 'string', is_user: true, metadata: { foo: 'bar' } },
);
});

Expand Down
8 changes: 6 additions & 2 deletions tests/api-resources/apps/users/sessions/metamessages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('resource metamessages', () => {
content: 'string',
message_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
metamessage_type: 'string',
metadata: {},
metadata: { foo: 'bar' },
},
);
});
Expand Down Expand Up @@ -62,7 +62,11 @@ describe('resource metamessages', () => {
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ message_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', metadata: {}, metamessage_type: 'string' },
{
message_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
metadata: { foo: 'bar' },
metamessage_type: 'string',
},
);
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/apps/users/sessions/sessions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('resource sessions', () => {
const response = await honcho.apps.users.sessions.create(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ location_id: 'string', metadata: {} },
{ location_id: 'string', metadata: { foo: 'bar' } },
);
});

Expand Down

0 comments on commit 99a66ce

Please sign in to comment.