Skip to content

release: 0.1.0-alpha.2 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8890e6d
chore: rebuild project due to codegen change (#6)
stainless-app[bot] Nov 9, 2024
6af23e2
chore: rebuild project due to codegen change (#8)
stainless-app[bot] Nov 12, 2024
b2020fa
chore: rebuild project due to codegen change (#9)
stainless-app[bot] Nov 15, 2024
6050424
chore: rebuild project due to codegen change (#10)
stainless-app[bot] Nov 15, 2024
fe3f1bc
chore: rebuild project due to codegen change (#11)
stainless-app[bot] Nov 18, 2024
3b489d6
docs: remove suggestion to use `npm` call out (#12)
stainless-app[bot] Nov 20, 2024
841b092
chore: remove redundant word in comment (#13)
stainless-app[bot] Nov 20, 2024
c3b0820
feat(internal): make git install file structure match npm (#14)
stainless-app[bot] Nov 28, 2024
410700f
chore(internal): remove unnecessary getRequestClient function (#15)
stainless-app[bot] Dec 10, 2024
101ef91
chore(internal): bump cross-spawn to v7.0.6 (#16)
stainless-app[bot] Dec 11, 2024
ce16bc9
chore(types): nicer error class types + jsdocs (#17)
stainless-app[bot] Dec 11, 2024
86c928a
chore(internal): update isAbsoluteURL (#18)
stainless-app[bot] Dec 12, 2024
90d10b6
chore(internal): fix some typos (#19)
stainless-app[bot] Dec 18, 2024
6e53df1
chore(internal): codegen related update (#20)
stainless-app[bot] Dec 20, 2024
63242fe
chore(internal): codegen related update (#21)
stainless-app[bot] Dec 21, 2024
3688637
chore(internal): codegen related update (#22)
stainless-app[bot] Dec 21, 2024
5677030
docs: minor formatting changes (#23)
stainless-app[bot] Dec 21, 2024
a328825
chore(internal): codegen related update (#24)
stainless-app[bot] Jan 2, 2025
e830080
chore(internal): codegen related update (#25)
stainless-app[bot] Jan 9, 2025
848c166
fix: send correct Accept header for certain endpoints (#26)
stainless-app[bot] Jan 11, 2025
96158a4
chore(internal): codegen related update (#27)
stainless-app[bot] Jan 17, 2025
806f949
chore(internal): codegen related update (#28)
stainless-app[bot] Jan 22, 2025
5111f1e
chore(internal): codegen related update (#29)
stainless-app[bot] Jan 23, 2025
10f2d08
release: 0.1.0-alpha.2
stainless-app[bot] Jan 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/

2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.1"
".": "0.1.0-alpha.2"
}
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
# Changelog

## 0.1.0-alpha.2 (2025-01-23)

Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/argotdev/argot-stainless-openai/compare/v0.1.0-alpha.1...v0.1.0-alpha.2)

### Features

* **internal:** make git install file structure match npm ([#14](https://github.com/argotdev/argot-stainless-openai/issues/14)) ([c3b0820](https://github.com/argotdev/argot-stainless-openai/commit/c3b082040cca78f89db1eab85f73028830579ed5))


### Bug Fixes

* send correct Accept header for certain endpoints ([#26](https://github.com/argotdev/argot-stainless-openai/issues/26)) ([848c166](https://github.com/argotdev/argot-stainless-openai/commit/848c16616984deecdf2d9d93c79b70a64bf9f977))


### Chores

* **internal:** bump cross-spawn to v7.0.6 ([#16](https://github.com/argotdev/argot-stainless-openai/issues/16)) ([101ef91](https://github.com/argotdev/argot-stainless-openai/commit/101ef918167839d6d13cd5c0a9c1a7f17120edde))
* **internal:** codegen related update ([#20](https://github.com/argotdev/argot-stainless-openai/issues/20)) ([6e53df1](https://github.com/argotdev/argot-stainless-openai/commit/6e53df187ab17fc9b5acd95b3f360df2a9d5cf5e))
* **internal:** codegen related update ([#21](https://github.com/argotdev/argot-stainless-openai/issues/21)) ([63242fe](https://github.com/argotdev/argot-stainless-openai/commit/63242fe510869b809f9cfa8d8af61a8cc5aa1099))
* **internal:** codegen related update ([#22](https://github.com/argotdev/argot-stainless-openai/issues/22)) ([3688637](https://github.com/argotdev/argot-stainless-openai/commit/36886375e986fa7d119ba692c59910d7a82744bb))
* **internal:** codegen related update ([#24](https://github.com/argotdev/argot-stainless-openai/issues/24)) ([a328825](https://github.com/argotdev/argot-stainless-openai/commit/a32882583a927af3e7308fdc6b26754d2c521a6c))
* **internal:** codegen related update ([#25](https://github.com/argotdev/argot-stainless-openai/issues/25)) ([e830080](https://github.com/argotdev/argot-stainless-openai/commit/e83008087bc1459242122be71bfb2a03a7047e98))
* **internal:** codegen related update ([#27](https://github.com/argotdev/argot-stainless-openai/issues/27)) ([96158a4](https://github.com/argotdev/argot-stainless-openai/commit/96158a4f08d6693e8264cc885757d97216582e22))
* **internal:** codegen related update ([#28](https://github.com/argotdev/argot-stainless-openai/issues/28)) ([806f949](https://github.com/argotdev/argot-stainless-openai/commit/806f949936d37e8e8d1722a1ffc54d1a0b01d7d5))
* **internal:** codegen related update ([#29](https://github.com/argotdev/argot-stainless-openai/issues/29)) ([5111f1e](https://github.com/argotdev/argot-stainless-openai/commit/5111f1e4d0e2fa03ab2bab61a1c17fc656f8fdcc))
* **internal:** fix some typos ([#19](https://github.com/argotdev/argot-stainless-openai/issues/19)) ([90d10b6](https://github.com/argotdev/argot-stainless-openai/commit/90d10b677b82f57c39aeb0f8368281c9f756cc0c))
* **internal:** remove unnecessary getRequestClient function ([#15](https://github.com/argotdev/argot-stainless-openai/issues/15)) ([410700f](https://github.com/argotdev/argot-stainless-openai/commit/410700f2d8669ea95e423706a4ca897182a5640b))
* **internal:** update isAbsoluteURL ([#18](https://github.com/argotdev/argot-stainless-openai/issues/18)) ([86c928a](https://github.com/argotdev/argot-stainless-openai/commit/86c928a7d28179be9b1653a67c678c0a422c3525))
* rebuild project due to codegen change ([#10](https://github.com/argotdev/argot-stainless-openai/issues/10)) ([6050424](https://github.com/argotdev/argot-stainless-openai/commit/605042411e5de37ca1c1ff8600cf62356bac7da9))
* rebuild project due to codegen change ([#11](https://github.com/argotdev/argot-stainless-openai/issues/11)) ([fe3f1bc](https://github.com/argotdev/argot-stainless-openai/commit/fe3f1bc5c04fe8940e4470bbad3047540b861227))
* rebuild project due to codegen change ([#6](https://github.com/argotdev/argot-stainless-openai/issues/6)) ([8890e6d](https://github.com/argotdev/argot-stainless-openai/commit/8890e6d9c18d9e17d9de51832eee911b2af50f6d))
* rebuild project due to codegen change ([#8](https://github.com/argotdev/argot-stainless-openai/issues/8)) ([6af23e2](https://github.com/argotdev/argot-stainless-openai/commit/6af23e2b584129014300e7bd6230e9f0efe6b612))
* rebuild project due to codegen change ([#9](https://github.com/argotdev/argot-stainless-openai/issues/9)) ([b2020fa](https://github.com/argotdev/argot-stainless-openai/commit/b2020fae8a1a9a0c9777fb310fdb4f9bb1e828a0))
* remove redundant word in comment ([#13](https://github.com/argotdev/argot-stainless-openai/issues/13)) ([841b092](https://github.com/argotdev/argot-stainless-openai/commit/841b092383f30939083f63a62f5a3fe40b791bbd))
* **types:** nicer error class types + jsdocs ([#17](https://github.com/argotdev/argot-stainless-openai/issues/17)) ([ce16bc9](https://github.com/argotdev/argot-stainless-openai/commit/ce16bc99d0e6a7a92324a4746548842854605b2d))


### Documentation

* minor formatting changes ([#23](https://github.com/argotdev/argot-stainless-openai/issues/23)) ([5677030](https://github.com/argotdev/argot-stainless-openai/commit/56770302e8c268d7d84d1b4643c31071337e5925))
* remove suggestion to use `npm` call out ([#12](https://github.com/argotdev/argot-stainless-openai/issues/12)) ([3b489d6](https://github.com/argotdev/argot-stainless-openai/commit/3b489d6b255f74a829fb27cfd12daf6a5d2ca556))

## 0.1.0-alpha.1 (2024-10-18)

Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/argotdev/argot-stainless-openai/compare/v0.0.1-alpha.0...v0.1.0-alpha.1)
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Setting up the environment

This repository uses [`yarn@v1`](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable).
This repository uses [`yarn@v1`](https://classic.yarnpkg.com/lang/en/docs/install).
Other package managers may work but are not officially supported for development.

To set up the repository, run:
Expand Down Expand Up @@ -29,10 +29,10 @@ All files in the `examples/` directory are not modified by the generator and can
```

```
chmod +x examples/<your-example>.ts
```sh
$ chmod +x examples/<your-example>.ts
# run the example against your api
yarn tsn -T examples/<your-example>.ts
$ yarn tsn -T examples/<your-example>.ts
```

## Using the repository from source
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2024 Argot OpenAI
Copyright 2025 Argot OpenAI

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ await client.completions.create(
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:

1. Changes that only affect static types, without breaking runtime behavior.
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_.
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
3. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
Expand All @@ -287,6 +287,15 @@ TypeScript >= 4.5 is supported.

The following runtimes are supported:

- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
- Deno v1.28.0 or higher.
- Bun 1.0 or later.
- Cloudflare Workers.
- Vercel Edge Runtime.
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
- Nitro v2.6 or greater.

Note that React Native is not supported at this time.

If you are interested in other runtime environments, please open or upvote an issue on GitHub.
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "argot-stainless-openai",
"version": "0.1.0-alpha.1",
"version": "0.1.0-alpha.2",
"description": "The official TypeScript library for the Argot OpenAI API",
"author": "Argot OpenAI <[email protected]>",
"types": "dist/index.d.ts",
Expand All @@ -10,15 +10,15 @@
"license": "Apache-2.0",
"packageManager": "[email protected]",
"files": [
"*"
"**/*"
],
"private": false,
"scripts": {
"test": "./scripts/test",
"build": "./scripts/build",
"prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1",
"format": "prettier --write --cache --cache-strategy metadata . !dist",
"prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build; fi",
"prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build && ./scripts/utils/git-swap.sh; fi",
"tsn": "ts-node -r tsconfig-paths/register",
"lint": "./scripts/lint",
"fix": "./scripts/format"
Expand All @@ -45,7 +45,6 @@
"jest": "^29.4.0",
"prettier": "^3.0.0",
"ts-jest": "^29.1.0",
"ts-morph": "^19.0.0",
"ts-node": "^10.5.0",
"tsc-multi": "^1.1.0",
"tsconfig-paths": "^4.0.0",
Expand Down
4 changes: 2 additions & 2 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ npm exec tsc-multi
# copy over handwritten .js/.mjs/.d.ts files
cp src/_shims/*.{d.ts,js,mjs,md} dist/_shims
cp src/_shims/auto/*.{d.ts,js,mjs} dist/_shims/auto
# we need to add exports = module.exports = Argot OpenAI Node to index.js;
# we need to add exports = module.exports = ArgotOpenAI to index.js;
# No way to get that from index.ts because it would cause compile errors
# when building .mjs
node scripts/utils/fix-index-exports.cjs
Expand All @@ -50,7 +50,7 @@ node scripts/utils/postprocess-files.cjs
(cd dist && node -e 'require("argot-stainless-openai")')
(cd dist && node -e 'import("argot-stainless-openai")' --input-type=module)

if command -v deno &> /dev/null && [ -e ./scripts/build-deno ]
if [ -e ./scripts/build-deno ]
then
./scripts/build-deno
fi
2 changes: 1 addition & 1 deletion scripts/utils/check-is-in-git-install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Check if you happen to call prepare for a repository that's already in node_modules.
[ "$(basename "$(dirname "$PWD")")" = 'node_modules' ] ||
# The name of the containing directory that 'npm` uses, which looks like
Expand Down
13 changes: 13 additions & 0 deletions scripts/utils/git-swap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -exuo pipefail
# the package is published to NPM from ./dist
# we want the final file structure for git installs to match the npm installs, so we

# delete everything except ./dist and ./node_modules
find . -maxdepth 1 -mindepth 1 ! -name 'dist' ! -name 'node_modules' -exec rm -rf '{}' +

# move everything from ./dist to .
mv dist/* .

# delete the now-empty ./dist
rmdir dist
42 changes: 23 additions & 19 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export abstract class APIClient {
maxRetries = 2,
timeout = 60000, // 1 minute
httpAgent,
fetch: overridenFetch,
fetch: overriddenFetch,
}: {
baseURL: string;
maxRetries?: number | undefined;
Expand All @@ -176,7 +176,7 @@ export abstract class APIClient {
this.timeout = validatePositiveInteger('timeout', timeout);
this.httpAgent = httpAgent;

this.fetch = overridenFetch ?? fetch;
this.fetch = overriddenFetch ?? fetch;
}

protected authHeaders(opts: FinalRequestOptions): Headers {
Expand Down Expand Up @@ -396,7 +396,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 @@ -522,20 +522,24 @@ export abstract class APIClient {

const timeout = setTimeout(() => controller.abort(), ms);

const fetchOptions = {
signal: controller.signal as any,
...options,
};
if (fetchOptions.method) {
// Custom methods like 'patch' need to be uppercased
// See https://github.com/nodejs/undici/issues/2294
fetchOptions.method = fetchOptions.method.toUpperCase();
}

return (
this.getRequestClient()
// use undefined this binding; fetch errors if bound to something else in browser/cloudflare
.fetch.call(undefined, url, { signal: controller.signal as any, ...options })
.finally(() => {
clearTimeout(timeout);
})
// use undefined this binding; fetch errors if bound to something else in browser/cloudflare
this.fetch.call(undefined, url, fetchOptions).finally(() => {
clearTimeout(timeout);
})
);
}

protected getRequestClient(): RequestClient {
return { fetch: this.fetch };
}

private shouldRetry(response: Response): boolean {
// Note this is not a standard header.
const shouldRetryHeader = response.headers.get('x-should-retry');
Expand Down Expand Up @@ -668,17 +672,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 @@ -721,7 +725,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 Expand Up @@ -976,8 +980,8 @@ export const safeJSON = (text: string) => {
}
};

// https://stackoverflow.com/a/19709846
const startsWithSchemeRegexp = new RegExp('^(?:[a-z]+:)?//', 'i');
// https://url.spec.whatwg.org/#url-scheme-string
const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
const isAbsoluteURL = (url: string): boolean => {
return startsWithSchemeRegexp.test(url);
};
Expand Down
66 changes: 25 additions & 41 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import { castToError, Headers } from './core';

export class ArgotOpenAIError extends Error {}

export class APIError extends ArgotOpenAIError {
readonly status: number | undefined;
readonly headers: Headers | undefined;
readonly error: Object | undefined;

constructor(
status: number | undefined,
error: Object | undefined,
message: string | undefined,
headers: Headers | undefined,
) {
export class APIError<
TStatus extends number | undefined = number | undefined,
THeaders extends Headers | undefined = Headers | undefined,
TError extends Object | undefined = Object | undefined,
> extends ArgotOpenAIError {
/** HTTP status for the response that caused the error */
readonly status: TStatus;
/** HTTP headers for the response that caused the error */
readonly headers: THeaders;
/** JSON body of the response that caused the error */
readonly error: TError;

constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) {
super(`${APIError.makeMessage(status, error, message)}`);
this.status = status;
this.headers = headers;
Expand Down Expand Up @@ -47,8 +49,8 @@ export class APIError extends ArgotOpenAIError {
errorResponse: Object | undefined,
message: string | undefined,
headers: Headers | undefined,
) {
if (!status) {
): APIError {
if (!status || !headers) {
return new APIConnectionError({ message, cause: castToError(errorResponse) });
}

Expand Down Expand Up @@ -90,17 +92,13 @@ export class APIError extends ArgotOpenAIError {
}
}

export class APIUserAbortError extends APIError {
override readonly status: undefined = undefined;

export class APIUserAbortError extends APIError<undefined, undefined, undefined> {
constructor({ message }: { message?: string } = {}) {
super(undefined, undefined, message || 'Request was aborted.', undefined);
}
}

export class APIConnectionError extends APIError {
override readonly status: undefined = undefined;

export class APIConnectionError extends APIError<undefined, undefined, undefined> {
constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
super(undefined, undefined, message || 'Connection error.', undefined);
// in some environments the 'cause' property is already declared
Expand All @@ -115,32 +113,18 @@ export class APIConnectionTimeoutError extends APIConnectionError {
}
}

export class BadRequestError extends APIError {
override readonly status: 400 = 400;
}
export class BadRequestError extends APIError<400, Headers> {}

export class AuthenticationError extends APIError {
override readonly status: 401 = 401;
}
export class AuthenticationError extends APIError<401, Headers> {}

export class PermissionDeniedError extends APIError {
override readonly status: 403 = 403;
}
export class PermissionDeniedError extends APIError<403, Headers> {}

export class NotFoundError extends APIError {
override readonly status: 404 = 404;
}
export class NotFoundError extends APIError<404, Headers> {}

export class ConflictError extends APIError {
override readonly status: 409 = 409;
}
export class ConflictError extends APIError<409, Headers> {}

export class UnprocessableEntityError extends APIError {
override readonly status: 422 = 422;
}
export class UnprocessableEntityError extends APIError<422, Headers> {}

export class RateLimitError extends APIError {
override readonly status: 429 = 429;
}
export class RateLimitError extends APIError<429, Headers> {}

export class InternalServerError extends APIError {}
export class InternalServerError extends APIError<number, Headers> {}
Loading
Loading