From 5c5e04930da23a0ff4f66fab395c6c1e3e42832c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:13:00 +0000 Subject: [PATCH 1/4] chore(internal): codegen related update (#15) --- .stats.yml | 2 +- api.md | 2 +- src/resources/sessions.ts | 79 +------------- tests/api-resources/agents/agents.test.ts | 20 ++-- tests/api-resources/agents/docs.test.ts | 38 ++----- tests/api-resources/docs.test.ts | 8 +- .../executions/executions.test.ts | 36 +++--- .../executions/transitions.test.ts | 16 +-- tests/api-resources/jobs.test.ts | 8 +- tests/api-resources/sessions.test.ts | 29 +++-- tests/api-resources/tasks.test.ts | 103 +++++++++--------- tests/api-resources/users/docs.test.ts | 38 ++----- tests/api-resources/users/users.test.ts | 22 ++-- 13 files changed, 139 insertions(+), 262 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1b9f14b..d05385a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 50 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/julep-ai-inc-dash%2Fjulep-f47e1a49bc70ec6069357e446dd826357b4402328fde2500da313c56ade84a0b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/julep-ai-inc-dash%2Fjulep-6a1e46c04a25dba0557ccbab92a9b9ccfbdb804849b91a8a780949c771321b12.yml diff --git a/api.md b/api.md index 13f9537..06729c3 100644 --- a/api.md +++ b/api.md @@ -69,7 +69,7 @@ Methods: - client.sessions.list({ ...params }) -> SessionsOffsetPagination - client.sessions.delete(sessionId) -> ResourceDeleted - client.sessions.chat(sessionId, { ...params }) -> SessionChatResponse -- client.sessions.createOrUpdate(sessionId, { ...params }) -> ResourceUpdated +- client.sessions.createOrUpdate(sessionId, { ...params }) -> ResourceCreated - client.sessions.get(sessionId) -> Session - client.sessions.history(sessionId) -> History - client.sessions.patch(sessionId, { ...params }) -> ResourceUpdated diff --git a/src/resources/sessions.ts b/src/resources/sessions.ts index efbd4c9..c2dd978 100644 --- a/src/resources/sessions.ts +++ b/src/resources/sessions.ts @@ -57,18 +57,10 @@ export class Sessions extends APIResource { */ chat( sessionId: string, - params: SessionChatParams, + body: SessionChatParams, options?: Core.RequestOptions, ): Core.APIPromise { - const { 'X-Custom-Api-Key': xCustomAPIKey, ...body } = params; - return this._client.post(`/sessions/${sessionId}/chat`, { - body, - ...options, - headers: { - ...(xCustomAPIKey != null ? { 'X-Custom-Api-Key': xCustomAPIKey } : undefined), - ...options?.headers, - }, - }); + return this._client.post(`/sessions/${sessionId}/chat`, { body, ...options }); } /** @@ -78,7 +70,7 @@ export class Sessions extends APIResource { sessionId: string, body: SessionCreateOrUpdateParams, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { return this._client.post(`/sessions/${sessionId}`, { body, ...options }); } @@ -1013,113 +1005,48 @@ export interface SessionListParams extends OffsetPaginationParams { } export interface SessionChatParams { - /** - * Body param: - */ messages: Array; - /** - * Body param: - */ agent?: string | null; - /** - * Body param: - */ frequency_penalty?: number | null; - /** - * Body param: - */ length_penalty?: number | null; - /** - * Body param: - */ logit_bias?: Record | null; - /** - * Body param: - */ max_tokens?: number | null; - /** - * Body param: - */ min_p?: number | null; - /** - * Body param: - */ model?: string | null; - /** - * Body param: - */ presence_penalty?: number | null; - /** - * Body param: - */ recall?: boolean; - /** - * Body param: - */ repetition_penalty?: number | null; - /** - * Body param: - */ response_format?: | SessionChatParams.SimpleCompletionResponseFormat | SessionChatParams.SchemaCompletionResponseFormat | null; - /** - * Body param: - */ save?: boolean; - /** - * Body param: - */ seed?: number | null; - /** - * Body param: - */ stop?: Array; - /** - * Body param: - */ stream?: boolean; - /** - * Body param: - */ temperature?: number | null; - /** - * Body param: - */ tool_choice?: 'auto' | 'none' | SessionChatParams.NamedToolChoice | null; - /** - * Body param: - */ tools?: Array; - /** - * Body param: - */ top_p?: number | null; - - /** - * Header param: - */ - 'X-Custom-Api-Key'?: string; } export namespace SessionChatParams { diff --git a/tests/api-resources/agents/agents.test.ts b/tests/api-resources/agents/agents.test.ts index e3dec15..e232d7f 100644 --- a/tests/api-resources/agents/agents.test.ts +++ b/tests/api-resources/agents/agents.test.ts @@ -21,7 +21,7 @@ describe('resource agents', () => { }); test('update', async () => { - const responsePromise = client.agents.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); + const responsePromise = client.agents.update('agent_id', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -60,7 +60,7 @@ describe('resource agents', () => { }); test('delete', async () => { - const responsePromise = client.agents.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.agents.delete('agent_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -72,9 +72,9 @@ describe('resource agents', () => { 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( - client.agents.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.agents.delete('agent_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.NotFoundError, + ); }); test('createOrUpdate', async () => { @@ -89,7 +89,7 @@ describe('resource agents', () => { }); test('get', async () => { - const responsePromise = client.agents.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.agents.get('agent_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -101,13 +101,13 @@ describe('resource agents', () => { 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( - client.agents.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.agents.get('agent_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.NotFoundError, + ); }); test('patch', async () => { - const responsePromise = client.agents.patch('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); + const responsePromise = client.agents.patch('agent_id', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; diff --git a/tests/api-resources/agents/docs.test.ts b/tests/api-resources/agents/docs.test.ts index 306c1b4..b813aa9 100644 --- a/tests/api-resources/agents/docs.test.ts +++ b/tests/api-resources/agents/docs.test.ts @@ -10,10 +10,7 @@ const client = new Julep({ describe('resource docs', () => { test('create: only required params', async () => { - const responsePromise = client.agents.docs.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { - content: 'string', - title: 'title', - }); + const responsePromise = client.agents.docs.create('agent_id', { content: 'string', title: 'title' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -24,7 +21,7 @@ describe('resource docs', () => { }); test('create: required and optional params', async () => { - const response = await client.agents.docs.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + const response = await client.agents.docs.create('agent_id', { content: 'string', title: 'title', metadata: {}, @@ -32,7 +29,7 @@ describe('resource docs', () => { }); test('list', async () => { - const responsePromise = client.agents.docs.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.agents.docs.list('agent_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -44,16 +41,16 @@ describe('resource docs', () => { 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( - client.agents.docs.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.agents.docs.list('agent_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.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( client.agents.docs.list( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + 'agent_id', { direction: 'asc', limit: 0, metadata_filter: 'metadata_filter', offset: 0, sort_by: 'created_at' }, { path: '/_stainless_unknown_path' }, ), @@ -61,10 +58,7 @@ describe('resource docs', () => { }); test('delete', async () => { - const responsePromise = client.agents.docs.delete( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - ); + const responsePromise = client.agents.docs.delete('agent_id', 'doc_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -77,18 +71,12 @@ describe('resource docs', () => { 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( - client.agents.docs.delete( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { path: '/_stainless_unknown_path' }, - ), + client.agents.docs.delete('agent_id', 'doc_id', { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Julep.NotFoundError); }); test('search: only required params', async () => { - const responsePromise = client.agents.docs.search('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { - text: 'text', - }); + const responsePromise = client.agents.docs.search('agent_id', { text: 'text' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -99,10 +87,6 @@ describe('resource docs', () => { }); test('search: required and optional params', async () => { - const response = await client.agents.docs.search('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { - text: 'text', - lang: 'en-US', - limit: 1, - }); + const response = await client.agents.docs.search('agent_id', { text: 'text', lang: 'en-US', limit: 1 }); }); }); diff --git a/tests/api-resources/docs.test.ts b/tests/api-resources/docs.test.ts index 2affb7f..3ac35e8 100644 --- a/tests/api-resources/docs.test.ts +++ b/tests/api-resources/docs.test.ts @@ -25,7 +25,7 @@ describe('resource docs', () => { }); test('get', async () => { - const responsePromise = client.docs.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.docs.get('doc_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -37,8 +37,8 @@ describe('resource docs', () => { 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( - client.docs.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.docs.get('doc_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.NotFoundError, + ); }); }); diff --git a/tests/api-resources/executions/executions.test.ts b/tests/api-resources/executions/executions.test.ts index 58941f7..708ce3f 100644 --- a/tests/api-resources/executions/executions.test.ts +++ b/tests/api-resources/executions/executions.test.ts @@ -10,7 +10,7 @@ const client = new Julep({ describe('resource executions', () => { test('create: only required params', async () => { - const responsePromise = client.executions.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { input: {} }); + const responsePromise = client.executions.create('task_id', { input: {} }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,7 +21,7 @@ describe('resource executions', () => { }); test('create: required and optional params', async () => { - const response = await client.executions.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + const response = await client.executions.create('task_id', { input: {}, error: 'error', metadata: {}, @@ -30,7 +30,7 @@ describe('resource executions', () => { }); test('list', async () => { - const responsePromise = client.executions.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.executions.list('task_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -42,16 +42,16 @@ describe('resource executions', () => { 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( - client.executions.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.executions.list('task_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.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( client.executions.list( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + 'task_id', { direction: 'asc', limit: 0, offset: 0, sort_by: 'created_at' }, { path: '/_stainless_unknown_path' }, ), @@ -59,7 +59,7 @@ describe('resource executions', () => { }); test('changeStatus', async () => { - const responsePromise = client.executions.changeStatus('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); + const responsePromise = client.executions.changeStatus('execution_id', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -70,7 +70,7 @@ describe('resource executions', () => { }); test('get', async () => { - const responsePromise = client.executions.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.executions.get('execution_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -82,17 +82,13 @@ describe('resource executions', () => { 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( - client.executions.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.executions.get('execution_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.NotFoundError, + ); }); test('patch: only required params', async () => { - const responsePromise = client.executions.patch( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { status: 'queued' }, - ); + const responsePromise = client.executions.patch('task_id', 'execution_id', { status: 'queued' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -103,10 +99,6 @@ describe('resource executions', () => { }); test('patch: required and optional params', async () => { - const response = await client.executions.patch( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { status: 'queued' }, - ); + const response = await client.executions.patch('task_id', 'execution_id', { status: 'queued' }); }); }); diff --git a/tests/api-resources/executions/transitions.test.ts b/tests/api-resources/executions/transitions.test.ts index cae5811..dab9adc 100644 --- a/tests/api-resources/executions/transitions.test.ts +++ b/tests/api-resources/executions/transitions.test.ts @@ -10,7 +10,7 @@ const client = new Julep({ describe('resource transitions', () => { test('list', async () => { - const responsePromise = client.executions.transitions.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.executions.transitions.list('execution_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,9 +23,7 @@ describe('resource transitions', () => { 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( - client.executions.transitions.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { - path: '/_stainless_unknown_path', - }), + client.executions.transitions.list('execution_id', { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Julep.NotFoundError); }); @@ -33,7 +31,7 @@ describe('resource transitions', () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.executions.transitions.list( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + 'execution_id', { direction: 'asc', limit: 0, offset: 0, sort_by: 'created_at' }, { path: '/_stainless_unknown_path' }, ), @@ -41,7 +39,7 @@ describe('resource transitions', () => { }); test('stream', async () => { - const responsePromise = client.executions.transitions.stream('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.executions.transitions.stream('execution_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -54,9 +52,7 @@ describe('resource transitions', () => { test('stream: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.executions.transitions.stream('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { - path: '/_stainless_unknown_path', - }), + client.executions.transitions.stream('execution_id', { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Julep.NotFoundError); }); @@ -64,7 +60,7 @@ describe('resource transitions', () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.executions.transitions.stream( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + 'execution_id', { next_page_token: 'next_page_token' }, { path: '/_stainless_unknown_path' }, ), diff --git a/tests/api-resources/jobs.test.ts b/tests/api-resources/jobs.test.ts index 0c7fdb4..ef28580 100644 --- a/tests/api-resources/jobs.test.ts +++ b/tests/api-resources/jobs.test.ts @@ -10,7 +10,7 @@ const client = new Julep({ describe('resource jobs', () => { test('get', async () => { - const responsePromise = client.jobs.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.jobs.get('job_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,8 +22,8 @@ describe('resource jobs', () => { 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( - client.jobs.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.jobs.get('job_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.NotFoundError, + ); }); }); diff --git a/tests/api-resources/sessions.test.ts b/tests/api-resources/sessions.test.ts index 4b90730..1f398a4 100644 --- a/tests/api-resources/sessions.test.ts +++ b/tests/api-resources/sessions.test.ts @@ -21,7 +21,7 @@ describe('resource sessions', () => { }); test('update', async () => { - const responsePromise = client.sessions.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); + const responsePromise = client.sessions.update('session_id', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -60,7 +60,7 @@ describe('resource sessions', () => { }); test('delete', async () => { - const responsePromise = client.sessions.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.sessions.delete('session_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -72,9 +72,9 @@ 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( - client.sessions.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.sessions.delete('session_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.NotFoundError, + ); }); test('chat: only required params', async () => { @@ -137,7 +137,6 @@ describe('resource sessions', () => { }, ], top_p: 0, - 'X-Custom-Api-Key': 'X-Custom-Api-Key', }); }); @@ -153,7 +152,7 @@ describe('resource sessions', () => { }); test('get', async () => { - const responsePromise = client.sessions.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.sessions.get('session_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -165,13 +164,13 @@ 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( - client.sessions.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.sessions.get('session_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.NotFoundError, + ); }); test('history', async () => { - const responsePromise = client.sessions.history('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.sessions.history('session_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -183,13 +182,13 @@ describe('resource sessions', () => { test('history: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.sessions.history('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.sessions.history('session_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.NotFoundError, + ); }); test('patch', async () => { - const responsePromise = client.sessions.patch('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); + const responsePromise = client.sessions.patch('session_id', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; diff --git a/tests/api-resources/tasks.test.ts b/tests/api-resources/tasks.test.ts index 1ab2f67..521c5fc 100644 --- a/tests/api-resources/tasks.test.ts +++ b/tests/api-resources/tasks.test.ts @@ -10,7 +10,7 @@ const client = new Julep({ describe('resource tasks', () => { test('create: only required params', async () => { - const responsePromise = client.tasks.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + const responsePromise = client.tasks.create('agent_id', { main: [{ evaluate: { foo: 'string' } }], name: 'name', }); @@ -24,7 +24,7 @@ describe('resource tasks', () => { }); test('create: required and optional params', async () => { - const response = await client.tasks.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + const response = await client.tasks.create('agent_id', { main: [{ evaluate: { foo: 'string' } }], name: 'name', description: 'description', @@ -61,7 +61,7 @@ describe('resource tasks', () => { }); test('list', async () => { - const responsePromise = client.tasks.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.tasks.list('agent_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -73,16 +73,16 @@ describe('resource tasks', () => { 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( - client.tasks.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.tasks.list('agent_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.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( client.tasks.list( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + 'agent_id', { direction: 'asc', limit: 0, offset: 0, sort_by: 'created_at' }, { path: '/_stainless_unknown_path' }, ), @@ -90,11 +90,10 @@ describe('resource tasks', () => { }); test('createOrUpdate: only required params', async () => { - const responsePromise = client.tasks.createOrUpdate( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { main: [{ evaluate: { foo: 'string' } }], name: 'name' }, - ); + const responsePromise = client.tasks.createOrUpdate('agent_id', 'task_id', { + main: [{ evaluate: { foo: 'string' } }], + name: 'name', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -105,48 +104,44 @@ describe('resource tasks', () => { }); test('createOrUpdate: required and optional params', async () => { - const response = await client.tasks.createOrUpdate( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { - main: [{ evaluate: { foo: 'string' } }], - name: 'name', - description: 'description', - inherit_tools: true, - input_schema: {}, - metadata: {}, - tools: [ - { - function: { description: 'description', name: {}, parameters: {} }, - name: 'name', - api_call: {}, - integration: {}, - system: {}, - type: 'function', - }, - { - function: { description: 'description', name: {}, parameters: {} }, - name: 'name', - api_call: {}, - integration: {}, - system: {}, - type: 'function', - }, - { - function: { description: 'description', name: {}, parameters: {} }, - name: 'name', - api_call: {}, - integration: {}, - system: {}, - type: 'function', - }, - ], - }, - ); + const response = await client.tasks.createOrUpdate('agent_id', 'task_id', { + main: [{ evaluate: { foo: 'string' } }], + name: 'name', + description: 'description', + inherit_tools: true, + input_schema: {}, + metadata: {}, + tools: [ + { + function: { description: 'description', name: {}, parameters: {} }, + name: 'name', + api_call: {}, + integration: {}, + system: {}, + type: 'function', + }, + { + function: { description: 'description', name: {}, parameters: {} }, + name: 'name', + api_call: {}, + integration: {}, + system: {}, + type: 'function', + }, + { + function: { description: 'description', name: {}, parameters: {} }, + name: 'name', + api_call: {}, + integration: {}, + system: {}, + type: 'function', + }, + ], + }); }); test('get', async () => { - const responsePromise = client.tasks.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.tasks.get('task_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -158,8 +153,8 @@ describe('resource tasks', () => { 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( - client.tasks.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.tasks.get('task_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.NotFoundError, + ); }); }); diff --git a/tests/api-resources/users/docs.test.ts b/tests/api-resources/users/docs.test.ts index 8ada33c..df2de9c 100644 --- a/tests/api-resources/users/docs.test.ts +++ b/tests/api-resources/users/docs.test.ts @@ -10,10 +10,7 @@ const client = new Julep({ describe('resource docs', () => { test('create: only required params', async () => { - const responsePromise = client.users.docs.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { - content: 'string', - title: 'title', - }); + const responsePromise = client.users.docs.create('user_id', { content: 'string', title: 'title' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -24,7 +21,7 @@ describe('resource docs', () => { }); test('create: required and optional params', async () => { - const response = await client.users.docs.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + const response = await client.users.docs.create('user_id', { content: 'string', title: 'title', metadata: {}, @@ -32,7 +29,7 @@ describe('resource docs', () => { }); test('list', async () => { - const responsePromise = client.users.docs.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.users.docs.list('user_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -44,16 +41,16 @@ describe('resource docs', () => { 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( - client.users.docs.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.users.docs.list('user_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.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( client.users.docs.list( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + 'user_id', { direction: 'asc', limit: 0, metadata_filter: 'metadata_filter', offset: 0, sort_by: 'created_at' }, { path: '/_stainless_unknown_path' }, ), @@ -61,10 +58,7 @@ describe('resource docs', () => { }); test('delete', async () => { - const responsePromise = client.users.docs.delete( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - ); + const responsePromise = client.users.docs.delete('user_id', 'doc_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -77,18 +71,12 @@ describe('resource docs', () => { 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( - client.users.docs.delete( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { path: '/_stainless_unknown_path' }, - ), + client.users.docs.delete('user_id', 'doc_id', { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Julep.NotFoundError); }); test('search: only required params', async () => { - const responsePromise = client.users.docs.search('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { - text: 'text', - }); + const responsePromise = client.users.docs.search('user_id', { text: 'text' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -99,10 +87,6 @@ describe('resource docs', () => { }); test('search: required and optional params', async () => { - const response = await client.users.docs.search('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { - text: 'text', - lang: 'en-US', - limit: 1, - }); + const response = await client.users.docs.search('user_id', { text: 'text', lang: 'en-US', limit: 1 }); }); }); diff --git a/tests/api-resources/users/users.test.ts b/tests/api-resources/users/users.test.ts index 0d4c29e..65ee1bf 100644 --- a/tests/api-resources/users/users.test.ts +++ b/tests/api-resources/users/users.test.ts @@ -21,7 +21,7 @@ describe('resource users', () => { }); test('update', async () => { - const responsePromise = client.users.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); + const responsePromise = client.users.update('user_id', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -60,7 +60,7 @@ describe('resource users', () => { }); test('delete', async () => { - const responsePromise = client.users.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.users.delete('user_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -72,13 +72,13 @@ describe('resource users', () => { 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( - client.users.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.users.delete('user_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.NotFoundError, + ); }); test('createOrUpdate', async () => { - const responsePromise = client.users.createOrUpdate('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); + const responsePromise = client.users.createOrUpdate('user_id', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -89,7 +89,7 @@ describe('resource users', () => { }); test('get', async () => { - const responsePromise = client.users.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + const responsePromise = client.users.get('user_id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -101,13 +101,13 @@ 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( - client.users.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Julep.NotFoundError); + await expect(client.users.get('user_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Julep.NotFoundError, + ); }); test('patch', async () => { - const responsePromise = client.users.patch('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); + const responsePromise = client.users.patch('user_id', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; From f908edb94c57723e77497aa7a6381f26e5b785c5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:13:55 +0000 Subject: [PATCH 2/4] feat(client): send retry count header (#17) --- src/core.ts | 16 ++++++++++++---- tests/index.test.ts | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/core.ts b/src/core.ts index 2b9c512..2c5c7d4 100644 --- a/src/core.ts +++ b/src/core.ts @@ -274,7 +274,10 @@ export abstract class APIClient { return null; } - buildRequest(options: FinalRequestOptions): { req: RequestInit; url: string; timeout: number } { + buildRequest( + options: FinalRequestOptions, + { retryCount = 0 }: { retryCount?: number } = {}, + ): { req: RequestInit; url: string; timeout: number } { const { method, path, query, headers: headers = {} } = options; const body = @@ -306,7 +309,7 @@ export abstract class APIClient { headers[this.idempotencyHeader] = options.idempotencyKey; } - const reqHeaders = this.buildHeaders({ options, headers, contentLength }); + const reqHeaders = this.buildHeaders({ options, headers, contentLength, retryCount }); const req: RequestInit = { method, @@ -325,10 +328,12 @@ export abstract class APIClient { options, headers, contentLength, + retryCount, }: { options: FinalRequestOptions; headers: Record; contentLength: string | null | undefined; + retryCount: number; }): Record { const reqHeaders: Record = {}; if (contentLength) { @@ -344,6 +349,8 @@ export abstract class APIClient { delete reqHeaders['content-type']; } + reqHeaders['x-stainless-retry-count'] = String(retryCount); + this.validateHeaders(reqHeaders, headers); return reqHeaders; @@ -395,13 +402,14 @@ export abstract class APIClient { retriesRemaining: number | null, ): Promise { const options = await optionsInput; + const maxRetries = options.maxRetries ?? this.maxRetries; if (retriesRemaining == null) { - retriesRemaining = options.maxRetries ?? this.maxRetries; + retriesRemaining = maxRetries; } await this.prepareOptions(options); - const { req, url, timeout } = this.buildRequest(options); + const { req, url, timeout } = this.buildRequest(options, { retryCount: maxRetries - retriesRemaining }); await this.prepareRequest(req, { url, options }); diff --git a/tests/index.test.ts b/tests/index.test.ts index 00ad818..0508366 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -254,6 +254,31 @@ describe('retries', () => { expect(count).toEqual(3); }); + test('retry count header', async () => { + let count = 0; + let capturedRequest: RequestInit | undefined; + const testFetch = async (url: RequestInfo, init: RequestInit = {}): Promise => { + count++; + if (count <= 2) { + return new Response(undefined, { + status: 429, + headers: { + 'Retry-After': '0.1', + }, + }); + } + capturedRequest = init; + return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); + }; + + const client = new Julep({ apiKey: 'My API Key', fetch: testFetch, maxRetries: 4 }); + + expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); + + expect((capturedRequest!.headers as Headers)['x-stainless-retry-count']).toEqual('2'); + expect(count).toEqual(3); + }); + test('retry on 429 with retry-after', async () => { let count = 0; const testFetch = async (url: RequestInfo, { signal }: RequestInit = {}): Promise => { From cd15af02f95bd82f296b2f050d9fc4659aaa0940 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 02:12:55 +0000 Subject: [PATCH 3/4] feat(api): OpenAPI spec update via Stainless API (#18) --- .stats.yml | 2 +- api.md | 2 +- src/resources/sessions.ts | 79 +++++++++++++- tests/api-resources/agents/agents.test.ts | 20 ++-- tests/api-resources/agents/docs.test.ts | 38 +++++-- tests/api-resources/docs.test.ts | 8 +- .../executions/executions.test.ts | 36 +++--- .../executions/transitions.test.ts | 16 ++- tests/api-resources/jobs.test.ts | 8 +- tests/api-resources/sessions.test.ts | 29 ++--- tests/api-resources/tasks.test.ts | 103 +++++++++--------- tests/api-resources/users/docs.test.ts | 38 +++++-- tests/api-resources/users/users.test.ts | 22 ++-- 13 files changed, 262 insertions(+), 139 deletions(-) diff --git a/.stats.yml b/.stats.yml index d05385a..8f38ad0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 50 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/julep-ai-inc-dash%2Fjulep-6a1e46c04a25dba0557ccbab92a9b9ccfbdb804849b91a8a780949c771321b12.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/julep-ai-inc-dash%2Fjulep-f81af3213db01ef83d8f104374a7f47b8d46c3817e26d587a555ae05f2cae02c.yml diff --git a/api.md b/api.md index 06729c3..13f9537 100644 --- a/api.md +++ b/api.md @@ -69,7 +69,7 @@ Methods: - client.sessions.list({ ...params }) -> SessionsOffsetPagination - client.sessions.delete(sessionId) -> ResourceDeleted - client.sessions.chat(sessionId, { ...params }) -> SessionChatResponse -- client.sessions.createOrUpdate(sessionId, { ...params }) -> ResourceCreated +- client.sessions.createOrUpdate(sessionId, { ...params }) -> ResourceUpdated - client.sessions.get(sessionId) -> Session - client.sessions.history(sessionId) -> History - client.sessions.patch(sessionId, { ...params }) -> ResourceUpdated diff --git a/src/resources/sessions.ts b/src/resources/sessions.ts index c2dd978..efbd4c9 100644 --- a/src/resources/sessions.ts +++ b/src/resources/sessions.ts @@ -57,10 +57,18 @@ export class Sessions extends APIResource { */ chat( sessionId: string, - body: SessionChatParams, + params: SessionChatParams, options?: Core.RequestOptions, ): Core.APIPromise { - return this._client.post(`/sessions/${sessionId}/chat`, { body, ...options }); + const { 'X-Custom-Api-Key': xCustomAPIKey, ...body } = params; + return this._client.post(`/sessions/${sessionId}/chat`, { + body, + ...options, + headers: { + ...(xCustomAPIKey != null ? { 'X-Custom-Api-Key': xCustomAPIKey } : undefined), + ...options?.headers, + }, + }); } /** @@ -70,7 +78,7 @@ export class Sessions extends APIResource { sessionId: string, body: SessionCreateOrUpdateParams, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { return this._client.post(`/sessions/${sessionId}`, { body, ...options }); } @@ -1005,48 +1013,113 @@ export interface SessionListParams extends OffsetPaginationParams { } export interface SessionChatParams { + /** + * Body param: + */ messages: Array; + /** + * Body param: + */ agent?: string | null; + /** + * Body param: + */ frequency_penalty?: number | null; + /** + * Body param: + */ length_penalty?: number | null; + /** + * Body param: + */ logit_bias?: Record | null; + /** + * Body param: + */ max_tokens?: number | null; + /** + * Body param: + */ min_p?: number | null; + /** + * Body param: + */ model?: string | null; + /** + * Body param: + */ presence_penalty?: number | null; + /** + * Body param: + */ recall?: boolean; + /** + * Body param: + */ repetition_penalty?: number | null; + /** + * Body param: + */ response_format?: | SessionChatParams.SimpleCompletionResponseFormat | SessionChatParams.SchemaCompletionResponseFormat | null; + /** + * Body param: + */ save?: boolean; + /** + * Body param: + */ seed?: number | null; + /** + * Body param: + */ stop?: Array; + /** + * Body param: + */ stream?: boolean; + /** + * Body param: + */ temperature?: number | null; + /** + * Body param: + */ tool_choice?: 'auto' | 'none' | SessionChatParams.NamedToolChoice | null; + /** + * Body param: + */ tools?: Array; + /** + * Body param: + */ top_p?: number | null; + + /** + * Header param: + */ + 'X-Custom-Api-Key'?: string; } export namespace SessionChatParams { diff --git a/tests/api-resources/agents/agents.test.ts b/tests/api-resources/agents/agents.test.ts index e232d7f..e3dec15 100644 --- a/tests/api-resources/agents/agents.test.ts +++ b/tests/api-resources/agents/agents.test.ts @@ -21,7 +21,7 @@ describe('resource agents', () => { }); test('update', async () => { - const responsePromise = client.agents.update('agent_id', {}); + const responsePromise = client.agents.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -60,7 +60,7 @@ describe('resource agents', () => { }); test('delete', async () => { - const responsePromise = client.agents.delete('agent_id'); + const responsePromise = client.agents.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -72,9 +72,9 @@ describe('resource agents', () => { 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(client.agents.delete('agent_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.agents.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.NotFoundError); }); test('createOrUpdate', async () => { @@ -89,7 +89,7 @@ describe('resource agents', () => { }); test('get', async () => { - const responsePromise = client.agents.get('agent_id'); + const responsePromise = client.agents.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -101,13 +101,13 @@ describe('resource agents', () => { 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(client.agents.get('agent_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.agents.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.NotFoundError); }); test('patch', async () => { - const responsePromise = client.agents.patch('agent_id', {}); + const responsePromise = client.agents.patch('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; diff --git a/tests/api-resources/agents/docs.test.ts b/tests/api-resources/agents/docs.test.ts index b813aa9..306c1b4 100644 --- a/tests/api-resources/agents/docs.test.ts +++ b/tests/api-resources/agents/docs.test.ts @@ -10,7 +10,10 @@ const client = new Julep({ describe('resource docs', () => { test('create: only required params', async () => { - const responsePromise = client.agents.docs.create('agent_id', { content: 'string', title: 'title' }); + const responsePromise = client.agents.docs.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + content: 'string', + title: 'title', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,7 +24,7 @@ describe('resource docs', () => { }); test('create: required and optional params', async () => { - const response = await client.agents.docs.create('agent_id', { + const response = await client.agents.docs.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { content: 'string', title: 'title', metadata: {}, @@ -29,7 +32,7 @@ describe('resource docs', () => { }); test('list', async () => { - const responsePromise = client.agents.docs.list('agent_id'); + const responsePromise = client.agents.docs.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -41,16 +44,16 @@ describe('resource docs', () => { 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(client.agents.docs.list('agent_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.agents.docs.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.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( client.agents.docs.list( - 'agent_id', + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { direction: 'asc', limit: 0, metadata_filter: 'metadata_filter', offset: 0, sort_by: 'created_at' }, { path: '/_stainless_unknown_path' }, ), @@ -58,7 +61,10 @@ describe('resource docs', () => { }); test('delete', async () => { - const responsePromise = client.agents.docs.delete('agent_id', 'doc_id'); + const responsePromise = client.agents.docs.delete( + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + ); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -71,12 +77,18 @@ describe('resource docs', () => { 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( - client.agents.docs.delete('agent_id', 'doc_id', { path: '/_stainless_unknown_path' }), + client.agents.docs.delete( + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + { path: '/_stainless_unknown_path' }, + ), ).rejects.toThrow(Julep.NotFoundError); }); test('search: only required params', async () => { - const responsePromise = client.agents.docs.search('agent_id', { text: 'text' }); + const responsePromise = client.agents.docs.search('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + text: 'text', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -87,6 +99,10 @@ describe('resource docs', () => { }); test('search: required and optional params', async () => { - const response = await client.agents.docs.search('agent_id', { text: 'text', lang: 'en-US', limit: 1 }); + const response = await client.agents.docs.search('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + text: 'text', + lang: 'en-US', + limit: 1, + }); }); }); diff --git a/tests/api-resources/docs.test.ts b/tests/api-resources/docs.test.ts index 3ac35e8..2affb7f 100644 --- a/tests/api-resources/docs.test.ts +++ b/tests/api-resources/docs.test.ts @@ -25,7 +25,7 @@ describe('resource docs', () => { }); test('get', async () => { - const responsePromise = client.docs.get('doc_id'); + const responsePromise = client.docs.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -37,8 +37,8 @@ describe('resource docs', () => { 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(client.docs.get('doc_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.docs.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.NotFoundError); }); }); diff --git a/tests/api-resources/executions/executions.test.ts b/tests/api-resources/executions/executions.test.ts index 708ce3f..58941f7 100644 --- a/tests/api-resources/executions/executions.test.ts +++ b/tests/api-resources/executions/executions.test.ts @@ -10,7 +10,7 @@ const client = new Julep({ describe('resource executions', () => { test('create: only required params', async () => { - const responsePromise = client.executions.create('task_id', { input: {} }); + const responsePromise = client.executions.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { input: {} }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,7 +21,7 @@ describe('resource executions', () => { }); test('create: required and optional params', async () => { - const response = await client.executions.create('task_id', { + const response = await client.executions.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { input: {}, error: 'error', metadata: {}, @@ -30,7 +30,7 @@ describe('resource executions', () => { }); test('list', async () => { - const responsePromise = client.executions.list('task_id'); + const responsePromise = client.executions.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -42,16 +42,16 @@ describe('resource executions', () => { 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(client.executions.list('task_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.executions.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.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( client.executions.list( - 'task_id', + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { direction: 'asc', limit: 0, offset: 0, sort_by: 'created_at' }, { path: '/_stainless_unknown_path' }, ), @@ -59,7 +59,7 @@ describe('resource executions', () => { }); test('changeStatus', async () => { - const responsePromise = client.executions.changeStatus('execution_id', {}); + const responsePromise = client.executions.changeStatus('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -70,7 +70,7 @@ describe('resource executions', () => { }); test('get', async () => { - const responsePromise = client.executions.get('execution_id'); + const responsePromise = client.executions.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -82,13 +82,17 @@ describe('resource executions', () => { 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(client.executions.get('execution_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.executions.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.NotFoundError); }); test('patch: only required params', async () => { - const responsePromise = client.executions.patch('task_id', 'execution_id', { status: 'queued' }); + const responsePromise = client.executions.patch( + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + { status: 'queued' }, + ); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -99,6 +103,10 @@ describe('resource executions', () => { }); test('patch: required and optional params', async () => { - const response = await client.executions.patch('task_id', 'execution_id', { status: 'queued' }); + const response = await client.executions.patch( + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + { status: 'queued' }, + ); }); }); diff --git a/tests/api-resources/executions/transitions.test.ts b/tests/api-resources/executions/transitions.test.ts index dab9adc..cae5811 100644 --- a/tests/api-resources/executions/transitions.test.ts +++ b/tests/api-resources/executions/transitions.test.ts @@ -10,7 +10,7 @@ const client = new Julep({ describe('resource transitions', () => { test('list', async () => { - const responsePromise = client.executions.transitions.list('execution_id'); + const responsePromise = client.executions.transitions.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,7 +23,9 @@ describe('resource transitions', () => { 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( - client.executions.transitions.list('execution_id', { path: '/_stainless_unknown_path' }), + client.executions.transitions.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + path: '/_stainless_unknown_path', + }), ).rejects.toThrow(Julep.NotFoundError); }); @@ -31,7 +33,7 @@ describe('resource transitions', () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.executions.transitions.list( - 'execution_id', + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { direction: 'asc', limit: 0, offset: 0, sort_by: 'created_at' }, { path: '/_stainless_unknown_path' }, ), @@ -39,7 +41,7 @@ describe('resource transitions', () => { }); test('stream', async () => { - const responsePromise = client.executions.transitions.stream('execution_id'); + const responsePromise = client.executions.transitions.stream('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -52,7 +54,9 @@ describe('resource transitions', () => { test('stream: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.executions.transitions.stream('execution_id', { path: '/_stainless_unknown_path' }), + client.executions.transitions.stream('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + path: '/_stainless_unknown_path', + }), ).rejects.toThrow(Julep.NotFoundError); }); @@ -60,7 +64,7 @@ describe('resource transitions', () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.executions.transitions.stream( - 'execution_id', + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { next_page_token: 'next_page_token' }, { path: '/_stainless_unknown_path' }, ), diff --git a/tests/api-resources/jobs.test.ts b/tests/api-resources/jobs.test.ts index ef28580..0c7fdb4 100644 --- a/tests/api-resources/jobs.test.ts +++ b/tests/api-resources/jobs.test.ts @@ -10,7 +10,7 @@ const client = new Julep({ describe('resource jobs', () => { test('get', async () => { - const responsePromise = client.jobs.get('job_id'); + const responsePromise = client.jobs.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,8 +22,8 @@ describe('resource jobs', () => { 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(client.jobs.get('job_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.jobs.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.NotFoundError); }); }); diff --git a/tests/api-resources/sessions.test.ts b/tests/api-resources/sessions.test.ts index 1f398a4..4b90730 100644 --- a/tests/api-resources/sessions.test.ts +++ b/tests/api-resources/sessions.test.ts @@ -21,7 +21,7 @@ describe('resource sessions', () => { }); test('update', async () => { - const responsePromise = client.sessions.update('session_id', {}); + const responsePromise = client.sessions.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -60,7 +60,7 @@ describe('resource sessions', () => { }); test('delete', async () => { - const responsePromise = client.sessions.delete('session_id'); + const responsePromise = client.sessions.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -72,9 +72,9 @@ 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(client.sessions.delete('session_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.sessions.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.NotFoundError); }); test('chat: only required params', async () => { @@ -137,6 +137,7 @@ describe('resource sessions', () => { }, ], top_p: 0, + 'X-Custom-Api-Key': 'X-Custom-Api-Key', }); }); @@ -152,7 +153,7 @@ describe('resource sessions', () => { }); test('get', async () => { - const responsePromise = client.sessions.get('session_id'); + const responsePromise = client.sessions.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -164,13 +165,13 @@ 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(client.sessions.get('session_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.sessions.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.NotFoundError); }); test('history', async () => { - const responsePromise = client.sessions.history('session_id'); + const responsePromise = client.sessions.history('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -182,13 +183,13 @@ describe('resource sessions', () => { test('history: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect(client.sessions.history('session_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.sessions.history('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.NotFoundError); }); test('patch', async () => { - const responsePromise = client.sessions.patch('session_id', {}); + const responsePromise = client.sessions.patch('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; diff --git a/tests/api-resources/tasks.test.ts b/tests/api-resources/tasks.test.ts index 521c5fc..1ab2f67 100644 --- a/tests/api-resources/tasks.test.ts +++ b/tests/api-resources/tasks.test.ts @@ -10,7 +10,7 @@ const client = new Julep({ describe('resource tasks', () => { test('create: only required params', async () => { - const responsePromise = client.tasks.create('agent_id', { + const responsePromise = client.tasks.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { main: [{ evaluate: { foo: 'string' } }], name: 'name', }); @@ -24,7 +24,7 @@ describe('resource tasks', () => { }); test('create: required and optional params', async () => { - const response = await client.tasks.create('agent_id', { + const response = await client.tasks.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { main: [{ evaluate: { foo: 'string' } }], name: 'name', description: 'description', @@ -61,7 +61,7 @@ describe('resource tasks', () => { }); test('list', async () => { - const responsePromise = client.tasks.list('agent_id'); + const responsePromise = client.tasks.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -73,16 +73,16 @@ describe('resource tasks', () => { 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(client.tasks.list('agent_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.tasks.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.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( client.tasks.list( - 'agent_id', + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { direction: 'asc', limit: 0, offset: 0, sort_by: 'created_at' }, { path: '/_stainless_unknown_path' }, ), @@ -90,10 +90,11 @@ describe('resource tasks', () => { }); test('createOrUpdate: only required params', async () => { - const responsePromise = client.tasks.createOrUpdate('agent_id', 'task_id', { - main: [{ evaluate: { foo: 'string' } }], - name: 'name', - }); + const responsePromise = client.tasks.createOrUpdate( + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + { main: [{ evaluate: { foo: 'string' } }], name: 'name' }, + ); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -104,44 +105,48 @@ describe('resource tasks', () => { }); test('createOrUpdate: required and optional params', async () => { - const response = await client.tasks.createOrUpdate('agent_id', 'task_id', { - main: [{ evaluate: { foo: 'string' } }], - name: 'name', - description: 'description', - inherit_tools: true, - input_schema: {}, - metadata: {}, - tools: [ - { - function: { description: 'description', name: {}, parameters: {} }, - name: 'name', - api_call: {}, - integration: {}, - system: {}, - type: 'function', - }, - { - function: { description: 'description', name: {}, parameters: {} }, - name: 'name', - api_call: {}, - integration: {}, - system: {}, - type: 'function', - }, - { - function: { description: 'description', name: {}, parameters: {} }, - name: 'name', - api_call: {}, - integration: {}, - system: {}, - type: 'function', - }, - ], - }); + const response = await client.tasks.createOrUpdate( + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + { + main: [{ evaluate: { foo: 'string' } }], + name: 'name', + description: 'description', + inherit_tools: true, + input_schema: {}, + metadata: {}, + tools: [ + { + function: { description: 'description', name: {}, parameters: {} }, + name: 'name', + api_call: {}, + integration: {}, + system: {}, + type: 'function', + }, + { + function: { description: 'description', name: {}, parameters: {} }, + name: 'name', + api_call: {}, + integration: {}, + system: {}, + type: 'function', + }, + { + function: { description: 'description', name: {}, parameters: {} }, + name: 'name', + api_call: {}, + integration: {}, + system: {}, + type: 'function', + }, + ], + }, + ); }); test('get', async () => { - const responsePromise = client.tasks.get('task_id'); + const responsePromise = client.tasks.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -153,8 +158,8 @@ describe('resource tasks', () => { 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(client.tasks.get('task_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.tasks.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.NotFoundError); }); }); diff --git a/tests/api-resources/users/docs.test.ts b/tests/api-resources/users/docs.test.ts index df2de9c..8ada33c 100644 --- a/tests/api-resources/users/docs.test.ts +++ b/tests/api-resources/users/docs.test.ts @@ -10,7 +10,10 @@ const client = new Julep({ describe('resource docs', () => { test('create: only required params', async () => { - const responsePromise = client.users.docs.create('user_id', { content: 'string', title: 'title' }); + const responsePromise = client.users.docs.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + content: 'string', + title: 'title', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,7 +24,7 @@ describe('resource docs', () => { }); test('create: required and optional params', async () => { - const response = await client.users.docs.create('user_id', { + const response = await client.users.docs.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { content: 'string', title: 'title', metadata: {}, @@ -29,7 +32,7 @@ describe('resource docs', () => { }); test('list', async () => { - const responsePromise = client.users.docs.list('user_id'); + const responsePromise = client.users.docs.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -41,16 +44,16 @@ describe('resource docs', () => { 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(client.users.docs.list('user_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.users.docs.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.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( client.users.docs.list( - 'user_id', + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { direction: 'asc', limit: 0, metadata_filter: 'metadata_filter', offset: 0, sort_by: 'created_at' }, { path: '/_stainless_unknown_path' }, ), @@ -58,7 +61,10 @@ describe('resource docs', () => { }); test('delete', async () => { - const responsePromise = client.users.docs.delete('user_id', 'doc_id'); + const responsePromise = client.users.docs.delete( + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + ); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -71,12 +77,18 @@ describe('resource docs', () => { 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( - client.users.docs.delete('user_id', 'doc_id', { path: '/_stainless_unknown_path' }), + client.users.docs.delete( + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + { path: '/_stainless_unknown_path' }, + ), ).rejects.toThrow(Julep.NotFoundError); }); test('search: only required params', async () => { - const responsePromise = client.users.docs.search('user_id', { text: 'text' }); + const responsePromise = client.users.docs.search('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + text: 'text', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -87,6 +99,10 @@ describe('resource docs', () => { }); test('search: required and optional params', async () => { - const response = await client.users.docs.search('user_id', { text: 'text', lang: 'en-US', limit: 1 }); + const response = await client.users.docs.search('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + text: 'text', + lang: 'en-US', + limit: 1, + }); }); }); diff --git a/tests/api-resources/users/users.test.ts b/tests/api-resources/users/users.test.ts index 65ee1bf..0d4c29e 100644 --- a/tests/api-resources/users/users.test.ts +++ b/tests/api-resources/users/users.test.ts @@ -21,7 +21,7 @@ describe('resource users', () => { }); test('update', async () => { - const responsePromise = client.users.update('user_id', {}); + const responsePromise = client.users.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -60,7 +60,7 @@ describe('resource users', () => { }); test('delete', async () => { - const responsePromise = client.users.delete('user_id'); + const responsePromise = client.users.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -72,13 +72,13 @@ describe('resource users', () => { 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(client.users.delete('user_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.users.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.NotFoundError); }); test('createOrUpdate', async () => { - const responsePromise = client.users.createOrUpdate('user_id', {}); + const responsePromise = client.users.createOrUpdate('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -89,7 +89,7 @@ describe('resource users', () => { }); test('get', async () => { - const responsePromise = client.users.get('user_id'); + const responsePromise = client.users.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -101,13 +101,13 @@ 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(client.users.get('user_id', { path: '/_stainless_unknown_path' })).rejects.toThrow( - Julep.NotFoundError, - ); + await expect( + client.users.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Julep.NotFoundError); }); test('patch', async () => { - const responsePromise = client.users.patch('user_id', {}); + const responsePromise = client.users.patch('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; From a347c9053aa8c784791a5b192adda535e608388d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 02:13:14 +0000 Subject: [PATCH 4/4] release: 1.3.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 14 ++++++++++++++ package.json | 2 +- src/version.ts | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 41ea87d..96f1cd9 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.2.1" + ".": "1.3.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 11da514..fd079b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 1.3.0 (2024-09-23) + +Full Changelog: [v1.2.1...v1.3.0](https://github.com/julep-ai/node-sdk/compare/v1.2.1...v1.3.0) + +### Features + +* **api:** OpenAPI spec update via Stainless API ([#18](https://github.com/julep-ai/node-sdk/issues/18)) ([cd15af0](https://github.com/julep-ai/node-sdk/commit/cd15af02f95bd82f296b2f050d9fc4659aaa0940)) +* **client:** send retry count header ([#17](https://github.com/julep-ai/node-sdk/issues/17)) ([f908edb](https://github.com/julep-ai/node-sdk/commit/f908edb94c57723e77497aa7a6381f26e5b785c5)) + + +### Chores + +* **internal:** codegen related update ([#15](https://github.com/julep-ai/node-sdk/issues/15)) ([5c5e049](https://github.com/julep-ai/node-sdk/commit/5c5e04930da23a0ff4f66fab395c6c1e3e42832c)) + ## 1.2.1 (2024-09-19) Full Changelog: [v1.2.0...v1.2.1](https://github.com/julep-ai/node-sdk/compare/v1.2.0...v1.2.1) diff --git a/package.json b/package.json index 6dbeac8..530d38d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@julep/sdk", - "version": "1.2.1", + "version": "1.3.0", "description": "The official TypeScript library for the Julep API", "author": "Julep ", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index aba755e..39fa5bc 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '1.2.1'; // x-release-please-version +export const VERSION = '1.3.0'; // x-release-please-version