Skip to content

Commit

Permalink
chore: remove unused build-deno condition (#585)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Nov 4, 2024
1 parent 86c5ade commit 461e300
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ yarn-error.log
codegen.log
Brewfile.lock.json
dist
/deno
dist-deno
/*.tgz
.idea/

10 changes: 5 additions & 5 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export abstract class APIClient {
error: Object | undefined,
message: string | undefined,
headers: Headers | undefined,
) {
): APIError {
return APIError.generate(status, error, message, headers);
}

Expand Down Expand Up @@ -682,17 +682,17 @@ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
return await this.#client.requestAPIList(this.constructor as any, nextOptions);
}

async *iterPages() {
async *iterPages(): AsyncGenerator<this> {
// eslint-disable-next-line @typescript-eslint/no-this-alias
let page: AbstractPage<Item> = this;
let page: this = this;
yield page;
while (page.hasNextPage()) {
page = await page.getNextPage();
yield page;
}
}

async *[Symbol.asyncIterator]() {
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
for await (const page of this.iterPages()) {
for (const item of page.getPaginatedItems()) {
yield item;
Expand Down Expand Up @@ -735,7 +735,7 @@ export class PagePromise<
* console.log(item)
* }
*/
async *[Symbol.asyncIterator]() {
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
const page = await this;
for await (const item of page) {
yield item;
Expand Down
2 changes: 1 addition & 1 deletion src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class APIError extends AnthropicError {
errorResponse: Object | undefined,
message: string | undefined,
headers: Headers | undefined,
) {
): APIError {
if (!status) {
return new APIConnectionError({ message, cause: castToError(errorResponse) });
}
Expand Down
28 changes: 15 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,19 +291,21 @@ export class Anthropic extends Core.APIClient {

export const { HUMAN_PROMPT, AI_PROMPT } = Anthropic;

export const AnthropicError = Errors.AnthropicError;
export const APIError = Errors.APIError;
export const APIConnectionError = Errors.APIConnectionError;
export const APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
export const APIUserAbortError = Errors.APIUserAbortError;
export const NotFoundError = Errors.NotFoundError;
export const ConflictError = Errors.ConflictError;
export const RateLimitError = Errors.RateLimitError;
export const BadRequestError = Errors.BadRequestError;
export const AuthenticationError = Errors.AuthenticationError;
export const InternalServerError = Errors.InternalServerError;
export const PermissionDeniedError = Errors.PermissionDeniedError;
export const UnprocessableEntityError = Errors.UnprocessableEntityError;
export {
AnthropicError,
APIError,
APIConnectionError,
APIConnectionTimeoutError,
APIUserAbortError,
NotFoundError,
ConflictError,
RateLimitError,
BadRequestError,
AuthenticationError,
InternalServerError,
PermissionDeniedError,
UnprocessableEntityError,
} from './error';

export import toFile = Uploads.toFile;
export import fileFromPath = Uploads.fileFromPath;
Expand Down
4 changes: 2 additions & 2 deletions src/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
this.controller = controller;
}

static fromSSEResponse<Item>(response: Response, controller: AbortController) {
static fromSSEResponse<Item>(response: Response, controller: AbortController): Stream<Item> {
let consumed = false;

async function* iterator(): AsyncIterator<Item, any, undefined> {
Expand Down Expand Up @@ -92,7 +92,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
* Generates a Stream from a newline-separated ReadableStream
* where each item is a JSON value.
*/
static fromReadableStream<Item>(readableStream: ReadableStream, controller: AbortController) {
static fromReadableStream<Item>(readableStream: ReadableStream, controller: AbortController): Stream<Item> {
let consumed = false;

async function* iterLines(): AsyncGenerator<string, void, unknown> {
Expand Down
11 changes: 3 additions & 8 deletions tsconfig.deno.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
{
"extends": "./tsconfig.json",
"include": ["deno"],
"include": ["dist-deno"],
"exclude": [],
"compilerOptions": {
"rootDir": "./deno",
"rootDir": "./dist-deno",
"lib": ["es2020", "DOM"],
"paths": {
"@anthropic-ai/sdk/_shims/auto/*": ["deno/_shims/auto/*-deno"],
"@anthropic-ai/sdk/*": ["deno/*"],
"@anthropic-ai/sdk": ["deno/index.ts"],
},
"noEmit": true,
"declaration": true,
"declarationMap": true,
"outDir": "deno",
"outDir": "dist-deno",
"pretty": true,
"sourceMap": true
}
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"isolatedModules": false,

"skipLibCheck": true
}
Expand Down

0 comments on commit 461e300

Please sign in to comment.