diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 8ea34be..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -# syntax=docker/dockerfile:1 -FROM debian:bookworm-slim AS stainless - -RUN apt-get update && apt-get install -y \ - nodejs \ - npm \ - yarnpkg \ - && apt-get clean autoclean - -# Ensure UTF-8 encoding -ENV LANG=C.UTF-8 -ENV LC_ALL=C.UTF-8 - -# Yarn -RUN ln -sf /usr/bin/yarnpkg /usr/bin/yarn - -WORKDIR /workspace - -COPY package.json yarn.lock /workspace/ - -RUN yarn install - -COPY . /workspace diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d55fc4d..763462f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,20 +1,17 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/debian { - "name": "Debian", - "build": { - "dockerfile": "Dockerfile" + "name": "Development", + "image": "mcr.microsoft.com/devcontainers/typescript-node:latest", + "features": { + "ghcr.io/devcontainers/features/node:1": {} + }, + "postCreateCommand": "yarn install", + "customizations": { + "vscode": { + "extensions": [ + "esbenp.prettier-vscode" + ] + } } - - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - - // Configure tool-specific properties. - // "customizations": {}, - - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" } diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 8032c17..ed21d28 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.12.0" + ".": "0.13.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b97fbb..db22395 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ # Changelog +## 0.13.0 (2025-03-22) + +Full Changelog: [v0.12.0...v0.13.0](https://github.com/openlayer-ai/openlayer-ts/compare/v0.12.0...v0.13.0) + +### Features + +* **api:** api update ([3345b62](https://github.com/openlayer-ai/openlayer-ts/commit/3345b629c1904bfb2c2f9e05c86312c6c7b88b48)) +* **client:** send `X-Stainless-Timeout` header ([333edef](https://github.com/openlayer-ai/openlayer-ts/commit/333edef002f95acecdb29d3e6a698343c3361937)) + + +### Bug Fixes + +* avoid type error in certain environments ([#115](https://github.com/openlayer-ai/openlayer-ts/issues/115)) ([701091f](https://github.com/openlayer-ai/openlayer-ts/commit/701091ff829ca7b7f6ee3bf66af961b660eb3371)) +* **client:** fix export map for index exports ([ac3dffc](https://github.com/openlayer-ai/openlayer-ts/commit/ac3dffce4624d350d5cf73e3020067cb2f71ab59)) + + +### Chores + +* **exports:** cleaner resource index imports ([#113](https://github.com/openlayer-ai/openlayer-ts/issues/113)) ([9ac3180](https://github.com/openlayer-ai/openlayer-ts/commit/9ac318013fd2128e7f0a98db699534569c8e18a3)) +* **exports:** stop using path fallbacks ([#114](https://github.com/openlayer-ai/openlayer-ts/issues/114)) ([fdcd6e2](https://github.com/openlayer-ai/openlayer-ts/commit/fdcd6e2effcd89201604c545e0c3b8f0f0800032)) +* **internal:** codegen related update ([1016df6](https://github.com/openlayer-ai/openlayer-ts/commit/1016df6f549fd3312c26f6ecfd15b3aac58c5d65)) +* **internal:** codegen related update ([ca17307](https://github.com/openlayer-ai/openlayer-ts/commit/ca173073bc522424d9d6a35b5a2af14ccd7b8c88)) +* **internal:** codegen related update ([fd5d0a9](https://github.com/openlayer-ai/openlayer-ts/commit/fd5d0a9808b2abf8d1b88d3becf2350d9b25887e)) +* **internal:** fix devcontainers setup ([6a459de](https://github.com/openlayer-ai/openlayer-ts/commit/6a459de24ebec36ba38b751b6ab7143b3b9e16fd)) +* **internal:** fix workflows ([59a7cb4](https://github.com/openlayer-ai/openlayer-ts/commit/59a7cb4439a344c0ed6b4adb9e6b113dbed0f940)) +* **internal:** version bump ([3a31790](https://github.com/openlayer-ai/openlayer-ts/commit/3a317902d8bf523f3f54398cdb077a11a18d9995)) + + +### Documentation + +* update URLs from stainlessapi.com to stainless.com ([e56ef04](https://github.com/openlayer-ai/openlayer-ts/commit/e56ef04346aa002b8481a8018ad540c678a9a21e)) + ## 0.12.0 (2025-03-14) Full Changelog: [v0.11.0...v0.12.0](https://github.com/openlayer-ai/openlayer-ts/compare/v0.11.0...v0.12.0) diff --git a/README.md b/README.md index c0a8352..c58157a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This library provides convenient access to the Openlayer REST API from server-si The REST API documentation can be found on [openlayer.com](https://openlayer.com/docs/api-reference/rest/overview). The full API of this library can be found in [api.md](api.md). -It is generated with [Stainless](https://www.stainlessapi.com/). +It is generated with [Stainless](https://www.stainless.com/). ## Installation @@ -380,7 +380,7 @@ await client.inferencePipelines.data.stream( 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. diff --git a/SECURITY.md b/SECURITY.md index 6dfa13e..8614b05 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,9 +2,9 @@ ## Reporting Security Issues -This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. +This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. -To report a security issue, please contact the Stainless team at security@stainlessapi.com. +To report a security issue, please contact the Stainless team at security@stainless.com. ## Responsible Disclosure diff --git a/bin/check-release-environment b/bin/check-release-environment index 0f4fafe..5da9dd7 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -2,6 +2,10 @@ errors=() +if [ -z "${STAINLESS_API_KEY}" ]; then + errors+=("The STAINLESS_API_KEY secret has not been set. Please contact Stainless for an API key & set it in your organization secrets on GitHub.") +fi + if [ -z "${NPM_TOKEN}" ]; then errors+=("The OPENLAYER_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi diff --git a/package.json b/package.json index 13eefa3..b6df9a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openlayer", - "version": "0.12.0", + "version": "0.13.0", "description": "The official TypeScript library for the Openlayer API", "author": "Openlayer ", "types": "dist/index.d.ts", diff --git a/src/core.ts b/src/core.ts index 5981ff8..fbf6d3b 100644 --- a/src/core.ts +++ b/src/core.ts @@ -280,6 +280,7 @@ export abstract class APIClient { options: FinalRequestOptions, { retryCount = 0 }: { retryCount?: number } = {}, ): { req: RequestInit; url: string; timeout: number } { + options = { ...options }; const { method, path, query, headers: headers = {} } = options; const body = @@ -292,9 +293,9 @@ export abstract class APIClient { const url = this.buildURL(path!, query); if ('timeout' in options) validatePositiveInteger('timeout', options.timeout); - const timeout = options.timeout ?? this.timeout; + options.timeout = options.timeout ?? this.timeout; const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url); - const minAgentTimeout = timeout + 1000; + const minAgentTimeout = options.timeout + 1000; if ( typeof (httpAgent as any)?.options?.timeout === 'number' && minAgentTimeout > ((httpAgent as any).options.timeout ?? 0) @@ -323,7 +324,7 @@ export abstract class APIClient { signal: options.signal ?? null, }; - return { req, url, timeout }; + return { req, url, timeout: options.timeout }; } private buildHeaders({ @@ -351,15 +352,22 @@ export abstract class APIClient { delete reqHeaders['content-type']; } - // Don't set the retry count header if it was already set or removed through default headers or by the - // caller. We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to - // account for the removal case. + // Don't set theses headers if they were already set or removed through default headers or by the caller. + // We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to account + // for the removal case. if ( getHeader(defaultHeaders, 'x-stainless-retry-count') === undefined && getHeader(headers, 'x-stainless-retry-count') === undefined ) { reqHeaders['x-stainless-retry-count'] = String(retryCount); } + if ( + getHeader(defaultHeaders, 'x-stainless-timeout') === undefined && + getHeader(headers, 'x-stainless-timeout') === undefined && + options.timeout + ) { + reqHeaders['x-stainless-timeout'] = String(options.timeout); + } this.validateHeaders(reqHeaders, headers); @@ -387,7 +395,7 @@ export abstract class APIClient { !headers ? {} : Symbol.iterator in headers ? Object.fromEntries(Array.from(headers as Iterable).map((header) => [...header])) - : { ...headers } + : { ...(headers as any as Record) } ); } diff --git a/src/index.ts b/src/index.ts index e2cc2f8..96767aa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -43,7 +43,7 @@ export interface ClientOptions { * Note that request timeouts are retried by default, so in a worst-case scenario you may wait * much longer than this timeout before the promise succeeds or fails. */ - timeout?: number; + timeout?: number | undefined; /** * An HTTP agent used to manage HTTP(S) connections. @@ -51,7 +51,7 @@ export interface ClientOptions { * If not provided, an agent will be constructed by default in the Node.js environment, * otherwise no agent is used. */ - httpAgent?: Agent; + httpAgent?: Agent | undefined; /** * Specify a custom `fetch` function implementation. @@ -67,7 +67,7 @@ export interface ClientOptions { * * @default 2 */ - maxRetries?: number; + maxRetries?: number | undefined; /** * Default headers to include with every request to the API. @@ -75,7 +75,7 @@ export interface ClientOptions { * These can be removed in individual requests by explicitly setting the * header to `undefined` or `null` in request options. */ - defaultHeaders?: Core.Headers; + defaultHeaders?: Core.Headers | undefined; /** * Default query parameters to include with every request to the API. @@ -83,7 +83,7 @@ export interface ClientOptions { * These can be removed in individual requests by explicitly setting the * param to `undefined` in request options. */ - defaultQuery?: Core.DefaultQuery; + defaultQuery?: Core.DefaultQuery | undefined; } /** diff --git a/src/resources.ts b/src/resources.ts new file mode 100644 index 0000000..b283d57 --- /dev/null +++ b/src/resources.ts @@ -0,0 +1 @@ +export * from './resources/index'; diff --git a/src/resources/inference-pipelines/inference-pipelines.ts b/src/resources/inference-pipelines/inference-pipelines.ts index efdb59b..4e5b1c8 100644 --- a/src/resources/inference-pipelines/inference-pipelines.ts +++ b/src/resources/inference-pipelines/inference-pipelines.ts @@ -275,26 +275,59 @@ export namespace InferencePipelineRetrieveResponse { } export interface Workspace { + /** + * The workspace id. + */ id: string; + /** + * The workspace creator id. + */ creatorId: string | null; + /** + * The workspace creation date. + */ dateCreated: string; + /** + * The workspace last updated date. + */ dateUpdated: string; + /** + * The number of invites in the workspace. + */ inviteCount: number; + /** + * The number of members in the workspace. + */ memberCount: number; + /** + * The workspace name. + */ name: string; + /** + * The end date of the current billing period. + */ periodEndDate: string | null; + /** + * The start date of the current billing period. + */ periodStartDate: string | null; + /** + * The number of projects in the workspace. + */ projectCount: number; + /** + * The workspace slug. + */ slug: string; status: @@ -309,6 +342,9 @@ export namespace InferencePipelineRetrieveResponse { monthlyUsage?: Array; + /** + * Whether the workspace only allows SAML authentication. + */ samlOnlyAccess?: boolean; wildcardDomains?: Array; @@ -528,26 +564,59 @@ export namespace InferencePipelineUpdateResponse { } export interface Workspace { + /** + * The workspace id. + */ id: string; + /** + * The workspace creator id. + */ creatorId: string | null; + /** + * The workspace creation date. + */ dateCreated: string; + /** + * The workspace last updated date. + */ dateUpdated: string; + /** + * The number of invites in the workspace. + */ inviteCount: number; + /** + * The number of members in the workspace. + */ memberCount: number; + /** + * The workspace name. + */ name: string; + /** + * The end date of the current billing period. + */ periodEndDate: string | null; + /** + * The start date of the current billing period. + */ periodStartDate: string | null; + /** + * The number of projects in the workspace. + */ projectCount: number; + /** + * The workspace slug. + */ slug: string; status: @@ -562,6 +631,9 @@ export namespace InferencePipelineUpdateResponse { monthlyUsage?: Array; + /** + * Whether the workspace only allows SAML authentication. + */ samlOnlyAccess?: boolean; wildcardDomains?: Array; diff --git a/src/resources/projects/inference-pipelines.ts b/src/resources/projects/inference-pipelines.ts index 7f91d92..eed6c61 100644 --- a/src/resources/projects/inference-pipelines.ts +++ b/src/resources/projects/inference-pipelines.ts @@ -240,26 +240,59 @@ export namespace InferencePipelineCreateResponse { } export interface Workspace { + /** + * The workspace id. + */ id: string; + /** + * The workspace creator id. + */ creatorId: string | null; + /** + * The workspace creation date. + */ dateCreated: string; + /** + * The workspace last updated date. + */ dateUpdated: string; + /** + * The number of invites in the workspace. + */ inviteCount: number; + /** + * The number of members in the workspace. + */ memberCount: number; + /** + * The workspace name. + */ name: string; + /** + * The end date of the current billing period. + */ periodEndDate: string | null; + /** + * The start date of the current billing period. + */ periodStartDate: string | null; + /** + * The number of projects in the workspace. + */ projectCount: number; + /** + * The workspace slug. + */ slug: string; status: @@ -274,6 +307,9 @@ export namespace InferencePipelineCreateResponse { monthlyUsage?: Array; + /** + * Whether the workspace only allows SAML authentication. + */ samlOnlyAccess?: boolean; wildcardDomains?: Array; @@ -498,26 +534,59 @@ export namespace InferencePipelineListResponse { } export interface Workspace { + /** + * The workspace id. + */ id: string; + /** + * The workspace creator id. + */ creatorId: string | null; + /** + * The workspace creation date. + */ dateCreated: string; + /** + * The workspace last updated date. + */ dateUpdated: string; + /** + * The number of invites in the workspace. + */ inviteCount: number; + /** + * The number of members in the workspace. + */ memberCount: number; + /** + * The workspace name. + */ name: string; + /** + * The end date of the current billing period. + */ periodEndDate: string | null; + /** + * The start date of the current billing period. + */ periodStartDate: string | null; + /** + * The number of projects in the workspace. + */ projectCount: number; + /** + * The workspace slug. + */ slug: string; status: @@ -532,6 +601,9 @@ export namespace InferencePipelineListResponse { monthlyUsage?: Array; + /** + * Whether the workspace only allows SAML authentication. + */ samlOnlyAccess?: boolean; wildcardDomains?: Array; @@ -584,12 +656,24 @@ export namespace InferencePipelineCreateParams { } export interface Workspace { + /** + * The workspace name. + */ name: string; + /** + * The workspace slug. + */ slug: string; + /** + * The workspace invite code. + */ inviteCode?: string; + /** + * Whether the workspace only allows SAML authentication. + */ samlOnlyAccess?: boolean; wildcardDomains?: Array; diff --git a/src/version.ts b/src/version.ts index ce6b899..9d013cc 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.12.0'; // x-release-please-version +export const VERSION = '0.13.0'; // x-release-please-version diff --git a/tests/index.test.ts b/tests/index.test.ts index f45c1b0..86dc23a 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -96,6 +96,15 @@ describe('instantiate client', () => { expect(response).toEqual({ url: 'http://localhost:5000/foo', custom: true }); }); + test('explicit global fetch', async () => { + // make sure the global fetch type is assignable to our Fetch type + const client = new Openlayer({ + baseURL: 'http://localhost:5000/', + apiKey: 'My API Key', + fetch: defaultFetch, + }); + }); + test('custom signal', async () => { const client = new Openlayer({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',