Skip to content

Commit 2a368bb

Browse files
chore(internal): codegen related update (#737)
1 parent e0a4bec commit 2a368bb

File tree

5 files changed

+30
-15
lines changed

5 files changed

+30
-15
lines changed

api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Methods:
119119
- <code title="get /v1/messages/batches">client.messages.batches.<a href="./src/resources/messages/batches.ts">list</a>({ ...params }) -> MessageBatchesPage</code>
120120
- <code title="delete /v1/messages/batches/{message_batch_id}">client.messages.batches.<a href="./src/resources/messages/batches.ts">delete</a>(messageBatchId) -> DeletedMessageBatch</code>
121121
- <code title="post /v1/messages/batches/{message_batch_id}/cancel">client.messages.batches.<a href="./src/resources/messages/batches.ts">cancel</a>(messageBatchId) -> MessageBatch</code>
122-
- <code title="get /v1/messages/batches/{message_batch_id}/results">client.messages.batches.<a href="./src/resources/messages/batches.ts">results</a>(messageBatchId) -> JSONLDecoder&lt;MessageBatchIndividualResponse&gt;</code>
122+
- <code title="get /v1/messages/batches/{message_batch_id}/results">client.messages.batches.<a href="./src/resources/messages/batches.ts">results</a>(messageBatchId) -> MessageBatchIndividualResponse</code>
123123

124124
# Models
125125

@@ -257,4 +257,4 @@ Methods:
257257
- <code title="get /v1/messages/batches?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">list</a>({ ...params }) -> BetaMessageBatchesPage</code>
258258
- <code title="delete /v1/messages/batches/{message_batch_id}?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">delete</a>(messageBatchId, { ...params }) -> BetaDeletedMessageBatch</code>
259259
- <code title="post /v1/messages/batches/{message_batch_id}/cancel?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">cancel</a>(messageBatchId, { ...params }) -> BetaMessageBatch</code>
260-
- <code title="get /v1/messages/batches/{message_batch_id}/results?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">results</a>(messageBatchId, { ...params }) -> JSONLDecoder&lt;BetaMessageBatchIndividualResponse&gt;</code>
260+
- <code title="get /v1/messages/batches/{message_batch_id}/results?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">results</a>(messageBatchId, { ...params }) -> BetaMessageBatchIndividualResponse</code>

src/resources/beta/messages/batches.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { APIResource } from '../../../resource';
44
import { isRequestOptions } from '../../../core';
5+
import { APIPromise } from '../../../core';
56
import * as Core from '../../../core';
67
import * as BetaAPI from '../beta';
78
import * as BetaMessagesAPI from './messages';
@@ -177,7 +178,7 @@ export class Batches extends APIResource {
177178
*/
178179
async results(
179180
messageBatchId: string,
180-
params?: BatchResultsParams,
181+
params: BatchResultsParams | undefined = {},
181182
options?: Core.RequestOptions,
182183
): Promise<JSONLDecoder<BetaMessageBatchIndividualResponse>>;
183184
async results(
@@ -209,9 +210,12 @@ export class Batches extends APIResource {
209210
Accept: 'application/binary',
210211
...options?.headers,
211212
},
213+
stream: true,
212214
__binaryResponse: true,
213215
})
214-
._thenUnwrap((_, props) => JSONLDecoder.fromResponse(props.response, props.controller));
216+
._thenUnwrap((_, props) => JSONLDecoder.fromResponse(props.response, props.controller)) as APIPromise<
217+
JSONLDecoder<BetaMessageBatchIndividualResponse>
218+
>;
215219
}
216220
}
217221

src/resources/messages/batches.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { APIResource } from '../../resource';
44
import { isRequestOptions } from '../../core';
5+
import { APIPromise } from '../../core';
56
import * as Core from '../../core';
67
import * as Shared from '../shared';
78
import * as MessagesAPI from './messages';
@@ -119,7 +120,9 @@ export class Batches extends APIResource {
119120
},
120121
__binaryResponse: true,
121122
})
122-
._thenUnwrap((_, props) => JSONLDecoder.fromResponse(props.response, props.controller));
123+
._thenUnwrap((_, props) => JSONLDecoder.fromResponse(props.response, props.controller)) as APIPromise<
124+
JSONLDecoder<MessageBatchIndividualResponse>
125+
>;
123126
}
124127
}
125128

tests/api-resources/beta/messages/batches.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,15 @@ describe('resource batches', () => {
206206
});
207207

208208
// Prism doesn't support JSONL responses yet
209-
test.skip('results: request options instead of params are passed correctly', async () => {
210-
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
211-
await expect(
212-
client.beta.messages.batches.results('message_batch_id', { path: '/_stainless_unknown_path' }),
213-
).rejects.toThrow(Anthropic.NotFoundError);
209+
test.skip('results', async () => {
210+
const responsePromise = client.beta.messages.batches.results('message_batch_id');
211+
const rawResponse = await responsePromise.asResponse();
212+
expect(rawResponse).toBeInstanceOf(Response);
213+
const response = await responsePromise;
214+
expect(response).not.toBeInstanceOf(Response);
215+
const dataAndResponse = await responsePromise.withResponse();
216+
expect(dataAndResponse.data).toBe(response);
217+
expect(dataAndResponse.response).toBe(rawResponse);
214218
});
215219

216220
// Prism doesn't support JSONL responses yet

tests/api-resources/messages/batches.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,14 @@ describe('resource batches', () => {
170170
});
171171

172172
// Prism doesn't support JSONL responses yet
173-
test.skip('results: request options instead of params are passed correctly', async () => {
174-
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
175-
await expect(
176-
client.messages.batches.results('message_batch_id', { path: '/_stainless_unknown_path' }),
177-
).rejects.toThrow(Anthropic.NotFoundError);
173+
test.skip('results', async () => {
174+
const responsePromise = client.messages.batches.results('message_batch_id');
175+
const rawResponse = await responsePromise.asResponse();
176+
expect(rawResponse).toBeInstanceOf(Response);
177+
const response = await responsePromise;
178+
expect(response).not.toBeInstanceOf(Response);
179+
const dataAndResponse = await responsePromise.withResponse();
180+
expect(dataAndResponse.data).toBe(response);
181+
expect(dataAndResponse.response).toBe(rawResponse);
178182
});
179183
});

0 commit comments

Comments
 (0)