From ec7be8d0c90029c4fb5911afee057dcd73f6caa1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 7 Jun 2025 03:29:18 +0000 Subject: [PATCH 01/23] chore: avoid type error in certain environments --- src/internal/uploads.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/uploads.ts b/src/internal/uploads.ts index a708afa..4c04463 100644 --- a/src/internal/uploads.ts +++ b/src/internal/uploads.ts @@ -138,7 +138,7 @@ export const createForm = async >( // We check for Blob not File because Bun.File doesn't inherit from File, // but they both inherit from Blob and have a `name` property at runtime. -const isNamedBlob = (value: object) => value instanceof Blob && 'name' in value; +const isNamedBlob = (value: unknown) => value instanceof Blob && 'name' in value; const isUploadable = (value: unknown) => typeof value === 'object' && From 16c70f444b06763b186c7138e16476d03b9638fe Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 02:25:06 +0000 Subject: [PATCH 02/23] =?UTF-8?q?fix:=20publish=20script=20=E2=80=94=20han?= =?UTF-8?q?dle=20NPM=20errors=20correctly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/publish-npm | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/bin/publish-npm b/bin/publish-npm index 2505dec..fa2243d 100644 --- a/bin/publish-npm +++ b/bin/publish-npm @@ -7,15 +7,35 @@ npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN" yarn build cd dist +# Get package name and version from package.json +PACKAGE_NAME="$(jq -r -e '.name' ./package.json)" +VERSION="$(jq -r -e '.version' ./package.json)" + # Get latest version from npm # -# If the package doesn't exist, yarn will return -# {"type":"error","data":"Received invalid response from npm."} -# where .data.version doesn't exist so LAST_VERSION will be an empty string. -LAST_VERSION="$(yarn info --json 2> /dev/null | jq -r '.data.version')" - -# Get current version from package.json -VERSION="$(node -p "require('./package.json').version")" +# If the package doesn't exist, npm will return: +# { +# "error": { +# "code": "E404", +# "summary": "Unpublished on 2025-06-05T09:54:53.528Z", +# "detail": "'the_package' is not in this registry..." +# } +# } +NPM_INFO="$(npm view "$PACKAGE_NAME" version --json 2>/dev/null || true)" + +# Check if we got an E404 error +if echo "$NPM_INFO" | jq -e '.error.code == "E404"' > /dev/null 2>&1; then + # Package doesn't exist yet, no last version + LAST_VERSION="" +elif echo "$NPM_INFO" | jq -e '.error' > /dev/null 2>&1; then + # Report other errors + echo "ERROR: npm returned unexpected data:" + echo "$NPM_INFO" + exit 1 +else + # Success - get the version + LAST_VERSION=$(echo "$NPM_INFO" | jq -r '.') # strip quotes +fi # Check if current version is pre-release (e.g. alpha / beta / rc) CURRENT_IS_PRERELEASE=false From 71cd5185af173938e8bf933045de56dec7c04802 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 02:38:55 +0000 Subject: [PATCH 03/23] chore(internal): add pure annotations, make base APIResource abstract --- package.json | 2 +- scripts/build | 2 +- src/core/resource.ts | 2 +- src/internal/headers.ts | 10 +++++----- src/internal/uploads.ts | 2 +- src/internal/utils/log.ts | 2 +- src/internal/utils/path.ts | 2 +- src/internal/utils/values.ts | 3 +++ tsc-multi.json | 12 ++++++++++-- yarn.lock | 6 +++--- 10 files changed, 27 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 6b06ec5..13306fb 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "publint": "^0.2.12", "ts-jest": "^29.1.0", "ts-node": "^10.5.0", - "tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.4/tsc-multi-1.1.4.tgz", + "tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.7/tsc-multi.tgz", "tsconfig-paths": "^4.0.0", "typescript": "5.8.3" }, diff --git a/scripts/build b/scripts/build index b2ad914..a008cb0 100755 --- a/scripts/build +++ b/scripts/build @@ -31,7 +31,7 @@ fi node scripts/utils/make-dist-package-json.cjs > dist/package.json # build to .js/.mjs/.d.ts files -npm exec tsc-multi +./node_modules/.bin/tsc-multi # we need to patch index.js so that `new module.exports()` works for cjs backwards # compat. No way to get that from index.ts because it would cause compile errors # when building .mjs diff --git a/src/core/resource.ts b/src/core/resource.ts index b8cfadd..f1dd803 100644 --- a/src/core/resource.ts +++ b/src/core/resource.ts @@ -2,7 +2,7 @@ import type { Kernel } from '../client'; -export class APIResource { +export abstract class APIResource { protected _client: Kernel; constructor(client: Kernel) { diff --git a/src/internal/headers.ts b/src/internal/headers.ts index 5cc03ce..c724a9d 100644 --- a/src/internal/headers.ts +++ b/src/internal/headers.ts @@ -1,5 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +import { isReadonlyArray } from './utils/values'; + type HeaderValue = string | undefined | null; export type HeadersLike = | Headers @@ -9,7 +11,7 @@ export type HeadersLike = | null | NullableHeaders; -const brand_privateNullableHeaders = Symbol('brand.privateNullableHeaders'); +const brand_privateNullableHeaders = /* @__PURE__ */ Symbol('brand.privateNullableHeaders'); /** * @internal @@ -25,8 +27,6 @@ export type NullableHeaders = { nulls: Set; }; -const isArray = Array.isArray as (val: unknown) => val is readonly unknown[]; - function* iterateHeaders(headers: HeadersLike): IterableIterator { if (!headers) return; @@ -43,7 +43,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator; if (headers instanceof Headers) { iter = headers.entries(); - } else if (isArray(headers)) { + } else if (isReadonlyArray(headers)) { iter = headers; } else { shouldClear = true; @@ -52,7 +52,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator>(); +const supportsFormDataMap = /** @__PURE__ */ new WeakMap>(); /** * node-fetch doesn't support the global FormData object in recent node versions. Instead of sending diff --git a/src/internal/utils/log.ts b/src/internal/utils/log.ts index 4865262..44d8f65 100644 --- a/src/internal/utils/log.ts +++ b/src/internal/utils/log.ts @@ -58,7 +58,7 @@ const noopLogger = { debug: noop, }; -let cachedLoggers = new WeakMap(); +let cachedLoggers = /** @__PURE__ */ new WeakMap(); export function loggerFor(client: Kernel): Logger { const logger = client.logger; diff --git a/src/internal/utils/path.ts b/src/internal/utils/path.ts index e9bcaf5..8abf278 100644 --- a/src/internal/utils/path.ts +++ b/src/internal/utils/path.ts @@ -60,4 +60,4 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) => /** * URI-encodes path params and ensures no unsafe /./ or /../ path segments are introduced. */ -export const path = createPathTagFunction(encodeURIPath); +export const path = /* @__PURE__ */ createPathTagFunction(encodeURIPath); diff --git a/src/internal/utils/values.ts b/src/internal/utils/values.ts index 0953aea..667646d 100644 --- a/src/internal/utils/values.ts +++ b/src/internal/utils/values.ts @@ -9,6 +9,9 @@ export const isAbsoluteURL = (url: string): boolean => { return startsWithSchemeRegexp.test(url); }; +export let isArray = (val: unknown): val is unknown[] => ((isArray = Array.isArray), isArray(val)); +export let isReadonlyArray = isArray as (val: unknown) => val is readonly unknown[]; + /** Returns an object if the given value isn't an object, otherwise returns as-is */ export function maybeObj(x: unknown): object { if (typeof x !== 'object') { diff --git a/tsc-multi.json b/tsc-multi.json index 170bac7..384ddac 100644 --- a/tsc-multi.json +++ b/tsc-multi.json @@ -1,7 +1,15 @@ { "targets": [ - { "extname": ".js", "module": "commonjs", "shareHelpers": "internal/tslib.js" }, - { "extname": ".mjs", "module": "esnext", "shareHelpers": "internal/tslib.mjs" } + { + "extname": ".js", + "module": "commonjs", + "shareHelpers": "internal/tslib.js" + }, + { + "extname": ".mjs", + "module": "esnext", + "shareHelpers": "internal/tslib.mjs" + } ], "projects": ["tsconfig.build.json"] } diff --git a/yarn.lock b/yarn.lock index 49d3eb8..c611c53 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3283,9 +3283,9 @@ ts-node@^10.5.0: v8-compile-cache-lib "^3.0.0" yn "3.1.1" -"tsc-multi@https://github.com/stainless-api/tsc-multi/releases/download/v1.1.4/tsc-multi-1.1.4.tgz": - version "1.1.4" - resolved "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.4/tsc-multi-1.1.4.tgz#cbed459a9e902f5295ec3daaf1c7aa3b10427e55" +"tsc-multi@https://github.com/stainless-api/tsc-multi/releases/download/v1.1.7/tsc-multi.tgz": + version "1.1.7" + resolved "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.7/tsc-multi.tgz#52f40adf8b808bd0b633346d11cc4a8aeea465cd" dependencies: debug "^4.3.7" fast-glob "^3.3.2" From bb6cff2a9c869faa2589fbb4e2c13fc6450031d6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 19:42:31 +0000 Subject: [PATCH 04/23] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index d654666..d2422bd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 11 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-4502c65bef0843a6ae96d23bba075433af6bab49b55b544b1522f63e7881c00c.yml -openapi_spec_hash: 3e67b77bbc8cd6155b8f66f3271f2643 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-fa302aa17477431aaa82682fe71bdbb519270815fdc917477e1d7e606411be50.yml +openapi_spec_hash: 291cb0245ba582712900f0fb5cf44ee4 config_hash: c6bab7ac8da570a5abbcfb19db119b6b From 638c748f3a8ade5b9b843d24c4224a0053c10992 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 19:47:33 +0000 Subject: [PATCH 05/23] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index d2422bd..8826a54 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 11 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-fa302aa17477431aaa82682fe71bdbb519270815fdc917477e1d7e606411be50.yml -openapi_spec_hash: 291cb0245ba582712900f0fb5cf44ee4 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-e622f6886b1153050eb4ee9fda37fff8b36b38b52e5d247ea172deb2594bf9d6.yml +openapi_spec_hash: 3fa294f57c68b34e526a52bdd86eb562 config_hash: c6bab7ac8da570a5abbcfb19db119b6b From 171423fb6af8fde206a1e32a1e8611f4b1d325be Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 19:59:25 +0000 Subject: [PATCH 06/23] feat(api): update via SDK Studio --- .stats.yml | 8 +- api.md | 14 + src/client.ts | 17 ++ src/resources/deployments.ts | 381 ++++++++++++++++++++++++ src/resources/index.ts | 7 + tests/api-resources/deployments.test.ts | 61 ++++ 6 files changed, 484 insertions(+), 4 deletions(-) create mode 100644 src/resources/deployments.ts create mode 100644 tests/api-resources/deployments.test.ts diff --git a/.stats.yml b/.stats.yml index 8826a54..f34bfc3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 11 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-e622f6886b1153050eb4ee9fda37fff8b36b38b52e5d247ea172deb2594bf9d6.yml -openapi_spec_hash: 3fa294f57c68b34e526a52bdd86eb562 -config_hash: c6bab7ac8da570a5abbcfb19db119b6b +configured_endpoints: 14 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-d2dfee8d576aa73f6075e6da61228571cb2e844b969a06067e34e43eb7898554.yml +openapi_spec_hash: 9981744bf9c27426cdf721f7b27cf093 +config_hash: a085d1b39ddf0b26ee798501a9f47e20 diff --git a/api.md b/api.md index 6cef980..b27a84a 100644 --- a/api.md +++ b/api.md @@ -1,3 +1,17 @@ +# Deployments + +Types: + +- DeploymentCreateResponse +- DeploymentRetrieveResponse +- DeploymentFollowResponse + +Methods: + +- client.deployments.create({ ...params }) -> DeploymentCreateResponse +- client.deployments.retrieve(id) -> DeploymentRetrieveResponse +- client.deployments.follow(id) -> DeploymentFollowResponse + # Apps Types: diff --git a/src/client.ts b/src/client.ts index 21d63a6..3e63b03 100644 --- a/src/client.ts +++ b/src/client.ts @@ -29,6 +29,13 @@ import { BrowserRetrieveResponse, Browsers, } from './resources/browsers'; +import { + DeploymentCreateParams, + DeploymentCreateResponse, + DeploymentFollowResponse, + DeploymentRetrieveResponse, + Deployments, +} from './resources/deployments'; import { readEnv } from './internal/utils/env'; import { formatRequestDetails, loggerFor } from './internal/utils/log'; import { isEmptyObj } from './internal/utils/values'; @@ -735,14 +742,24 @@ export class Kernel { static toFile = Uploads.toFile; + deployments: API.Deployments = new API.Deployments(this); apps: API.Apps = new API.Apps(this); browsers: API.Browsers = new API.Browsers(this); } +Kernel.Deployments = Deployments; Kernel.Apps = Apps; Kernel.Browsers = Browsers; export declare namespace Kernel { export type RequestOptions = Opts.RequestOptions; + export { + Deployments as Deployments, + type DeploymentCreateResponse as DeploymentCreateResponse, + type DeploymentRetrieveResponse as DeploymentRetrieveResponse, + type DeploymentFollowResponse as DeploymentFollowResponse, + type DeploymentCreateParams as DeploymentCreateParams, + }; + export { Apps as Apps, type AppListResponse as AppListResponse, type AppListParams as AppListParams }; export { diff --git a/src/resources/deployments.ts b/src/resources/deployments.ts new file mode 100644 index 0000000..f1eec5e --- /dev/null +++ b/src/resources/deployments.ts @@ -0,0 +1,381 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../core/resource'; +import { APIPromise } from '../core/api-promise'; +import { Stream } from '../core/streaming'; +import { type Uploadable } from '../core/uploads'; +import { buildHeaders } from '../internal/headers'; +import { RequestOptions } from '../internal/request-options'; +import { multipartFormRequestOptions } from '../internal/uploads'; +import { path } from '../internal/utils/path'; + +export class Deployments extends APIResource { + /** + * Create a new deployment. + * + * @example + * ```ts + * const deployment = await client.deployments.create({ + * entrypoint_rel_path: 'src/app.py', + * file: fs.createReadStream('path/to/file'), + * }); + * ``` + */ + create(body: DeploymentCreateParams, options?: RequestOptions): APIPromise { + return this._client.post('/deployments', multipartFormRequestOptions({ body, ...options }, this._client)); + } + + /** + * Get information about a deployment's status. + * + * @example + * ```ts + * const deployment = await client.deployments.retrieve('id'); + * ``` + */ + retrieve(id: string, options?: RequestOptions): APIPromise { + return this._client.get(path`/deployments/${id}`, options); + } + + /** + * Establishes a Server-Sent Events (SSE) stream that delivers real-time logs and + * status updates for a deployment. The stream terminates automatically once the + * deployment reaches a terminal state. + * + * @example + * ```ts + * const response = await client.deployments.follow('id'); + * ``` + */ + follow(id: string, options?: RequestOptions): APIPromise> { + return this._client.get(path`/deployments/${id}/events`, { + ...options, + headers: buildHeaders([{ Accept: 'text/event-stream' }, options?.headers]), + stream: true, + }) as APIPromise>; + } +} + +/** + * Deployment record information. + */ +export interface DeploymentCreateResponse { + /** + * Unique identifier for the deployment + */ + id: string; + + /** + * Timestamp when the deployment was created + */ + created_at: string; + + /** + * Deployment region code + */ + region: string; + + /** + * Current status of the deployment + */ + status: 'queued' | 'in_progress' | 'running' | 'failed' | 'stopped'; + + /** + * Relative path to the application entrypoint + */ + entrypoint_rel_path?: string; + + /** + * Environment variables configured for this deployment + */ + env_vars?: Record; + + /** + * Status reason + */ + status_reason?: string; + + /** + * Timestamp when the deployment was last updated + */ + updated_at?: string | null; +} + +/** + * Deployment record information. + */ +export interface DeploymentRetrieveResponse { + /** + * Unique identifier for the deployment + */ + id: string; + + /** + * Timestamp when the deployment was created + */ + created_at: string; + + /** + * Deployment region code + */ + region: string; + + /** + * Current status of the deployment + */ + status: 'queued' | 'in_progress' | 'running' | 'failed' | 'stopped'; + + /** + * Relative path to the application entrypoint + */ + entrypoint_rel_path?: string; + + /** + * Environment variables configured for this deployment + */ + env_vars?: Record; + + /** + * Status reason + */ + status_reason?: string; + + /** + * Timestamp when the deployment was last updated + */ + updated_at?: string | null; +} + +/** + * Union type representing any deployment event. + */ +export type DeploymentFollowResponse = + | DeploymentFollowResponse.LogEvent + | DeploymentFollowResponse.DeploymentStateEvent + | DeploymentFollowResponse.AppVersionSummaryEvent + | DeploymentFollowResponse.ErrorEvent; + +export namespace DeploymentFollowResponse { + /** + * A log entry from the application. + */ + export interface LogEvent { + /** + * Event type identifier (always "log"). + */ + event: 'log'; + + /** + * Log message text. + */ + message: string; + + /** + * Time the log entry was produced. + */ + timestamp?: string; + } + + /** + * An event representing the current state of a deployment. + */ + export interface DeploymentStateEvent { + /** + * Deployment record information. + */ + deployment: DeploymentStateEvent.Deployment; + + /** + * Event type identifier (always "deployment_state"). + */ + event: 'deployment_state'; + + /** + * Time the state was reported. + */ + timestamp?: string; + } + + export namespace DeploymentStateEvent { + /** + * Deployment record information. + */ + export interface Deployment { + /** + * Unique identifier for the deployment + */ + id: string; + + /** + * Timestamp when the deployment was created + */ + created_at: string; + + /** + * Deployment region code + */ + region: string; + + /** + * Current status of the deployment + */ + status: 'queued' | 'in_progress' | 'running' | 'failed' | 'stopped'; + + /** + * Relative path to the application entrypoint + */ + entrypoint_rel_path?: string; + + /** + * Environment variables configured for this deployment + */ + env_vars?: Record; + + /** + * Status reason + */ + status_reason?: string; + + /** + * Timestamp when the deployment was last updated + */ + updated_at?: string | null; + } + } + + /** + * Summary of an application version. + */ + export interface AppVersionSummaryEvent { + /** + * Unique identifier for the app version + */ + id?: string; + + /** + * Name of the application + */ + app_name?: string; + + /** + * Environment variables configured for this app version + */ + env_vars?: Record; + + /** + * Event type identifier (always "app_version_summary"). + */ + event?: 'app_version_summary'; + + /** + * Deployment region code + */ + region?: string; + + /** + * Version label for the application + */ + version?: string; + } + + /** + * An error event from the application. + */ + export interface ErrorEvent { + error?: ErrorEvent.Error; + + /** + * Event type identifier (always "error"). + */ + event?: 'error'; + } + + export namespace ErrorEvent { + export interface Error { + /** + * Application-specific error code (machine-readable) + */ + code: string; + + /** + * Human-readable error description for debugging + */ + message: string; + + /** + * Additional error details (for multiple errors) + */ + details?: Array; + + inner_error?: Error.InnerError; + } + + export namespace Error { + export interface Detail { + /** + * Lower-level error code providing more specific detail + */ + code?: string; + + /** + * Further detail about the error + */ + message?: string; + } + + export interface InnerError { + /** + * Lower-level error code providing more specific detail + */ + code?: string; + + /** + * Further detail about the error + */ + message?: string; + } + } + } +} + +export interface DeploymentCreateParams { + /** + * Relative path to the entrypoint of the application + */ + entrypoint_rel_path: string; + + /** + * ZIP file containing the application source directory + */ + file: Uploadable; + + /** + * Map of environment variables to set for the deployed application. Each key-value + * pair represents an environment variable. + */ + env_vars?: Record; + + /** + * Allow overwriting an existing app version + */ + force?: boolean; + + /** + * Region for deployment. Currently we only support "aws.us-east-1a" + */ + region?: 'aws.us-east-1a'; + + /** + * Version of the application. Can be any string. + */ + version?: string; +} + +export declare namespace Deployments { + export { + type DeploymentCreateResponse as DeploymentCreateResponse, + type DeploymentRetrieveResponse as DeploymentRetrieveResponse, + type DeploymentFollowResponse as DeploymentFollowResponse, + type DeploymentCreateParams as DeploymentCreateParams, + }; +} diff --git a/src/resources/index.ts b/src/resources/index.ts index 5faf2a5..4da3454 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -10,3 +10,10 @@ export { type BrowserCreateParams, type BrowserDeleteParams, } from './browsers'; +export { + Deployments, + type DeploymentCreateResponse, + type DeploymentRetrieveResponse, + type DeploymentFollowResponse, + type DeploymentCreateParams, +} from './deployments'; diff --git a/tests/api-resources/deployments.test.ts b/tests/api-resources/deployments.test.ts new file mode 100644 index 0000000..d8d0b1d --- /dev/null +++ b/tests/api-resources/deployments.test.ts @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Kernel, { toFile } from '@onkernel/sdk'; + +const client = new Kernel({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource deployments', () => { + // skipped: tests are disabled for the time being + test.skip('create: only required params', async () => { + const responsePromise = client.deployments.create({ + entrypoint_rel_path: 'src/app.py', + file: await toFile(Buffer.from('# my file contents'), 'README.md'), + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // skipped: tests are disabled for the time being + test.skip('create: required and optional params', async () => { + const response = await client.deployments.create({ + entrypoint_rel_path: 'src/app.py', + file: await toFile(Buffer.from('# my file contents'), 'README.md'), + env_vars: { foo: 'string' }, + force: false, + region: 'aws.us-east-1a', + version: '1.0.0', + }); + }); + + // skipped: tests are disabled for the time being + test.skip('retrieve', async () => { + const responsePromise = client.deployments.retrieve('id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // skipped: currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail + test.skip('follow', async () => { + const responsePromise = client.deployments.follow('id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); +}); From e4ad78d21af5a7d009f55cea09da358780ca8d2d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 20:04:04 +0000 Subject: [PATCH 07/23] feat(api): update via SDK Studio --- .stats.yml | 4 ++-- src/resources/apps/deployments.ts | 2 +- src/resources/deployments.ts | 36 ++++++++++++++++++++----------- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.stats.yml b/.stats.yml index f34bfc3..f219d4b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 14 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-d2dfee8d576aa73f6075e6da61228571cb2e844b969a06067e34e43eb7898554.yml -openapi_spec_hash: 9981744bf9c27426cdf721f7b27cf093 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-aec3b879aa30638614c6217afbafcf737f37ac78ef3a51186dbf7b6fbf9e91ef.yml +openapi_spec_hash: 0aba27c707612e35b4068b1d748dc379 config_hash: a085d1b39ddf0b26ee798501a9f47e20 diff --git a/src/resources/apps/deployments.ts b/src/resources/apps/deployments.ts index a5cf463..e6ee49f 100644 --- a/src/resources/apps/deployments.ts +++ b/src/resources/apps/deployments.ts @@ -156,7 +156,7 @@ export namespace DeploymentFollowResponse { /** * Time the log entry was produced. */ - timestamp?: string; + timestamp: string; } } diff --git a/src/resources/deployments.ts b/src/resources/deployments.ts index f1eec5e..735ad57 100644 --- a/src/resources/deployments.ts +++ b/src/resources/deployments.ts @@ -173,7 +173,7 @@ export namespace DeploymentFollowResponse { /** * Time the log entry was produced. */ - timestamp?: string; + timestamp: string; } /** @@ -193,7 +193,7 @@ export namespace DeploymentFollowResponse { /** * Time the state was reported. */ - timestamp?: string; + timestamp: string; } export namespace DeploymentStateEvent { @@ -250,44 +250,54 @@ export namespace DeploymentFollowResponse { /** * Unique identifier for the app version */ - id?: string; + id: string; /** * Name of the application */ - app_name?: string; + app_name: string; /** - * Environment variables configured for this app version + * Event type identifier (always "app_version_summary"). */ - env_vars?: Record; + event: 'app_version_summary'; /** - * Event type identifier (always "app_version_summary"). + * Deployment region code */ - event?: 'app_version_summary'; + region: string; /** - * Deployment region code + * Time the state was reported. */ - region?: string; + timestamp: string; /** * Version label for the application */ - version?: string; + version: string; + + /** + * Environment variables configured for this app version + */ + env_vars?: Record; } /** * An error event from the application. */ export interface ErrorEvent { - error?: ErrorEvent.Error; + error: ErrorEvent.Error; /** * Event type identifier (always "error"). */ - event?: 'error'; + event: 'error'; + + /** + * Time the error occurred. + */ + timestamp: string; } export namespace ErrorEvent { From ef99764a42bc6243b028162eb1fcc88ae36eed41 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 21:04:32 +0000 Subject: [PATCH 08/23] feat(api): update via SDK Studio --- .stats.yml | 4 ++-- src/resources/deployments.ts | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index f219d4b..c68e415 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 14 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-aec3b879aa30638614c6217afbafcf737f37ac78ef3a51186dbf7b6fbf9e91ef.yml -openapi_spec_hash: 0aba27c707612e35b4068b1d748dc379 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-aac74422364f9d25e30fcefd510297580b77be4b84c71416c5b9de5b882e5945.yml +openapi_spec_hash: 4d42a5d93bd82754acf11e32e7438a04 config_hash: a085d1b39ddf0b26ee798501a9f47e20 diff --git a/src/resources/deployments.ts b/src/resources/deployments.ts index 735ad57..5b501ea 100644 --- a/src/resources/deployments.ts +++ b/src/resources/deployments.ts @@ -277,6 +277,11 @@ export namespace DeploymentFollowResponse { */ version: string; + /** + * List of actions available on the app + */ + actions?: Array; + /** * Environment variables configured for this app version */ From 567602fb83e9135938abd7cd080f864fc787f288 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 22:37:37 +0000 Subject: [PATCH 09/23] feat(api): update via SDK Studio --- .stats.yml | 4 ++-- src/resources/apps/apps.ts | 2 +- src/resources/deployments.ts | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.stats.yml b/.stats.yml index c68e415..3f66d22 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 14 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-aac74422364f9d25e30fcefd510297580b77be4b84c71416c5b9de5b882e5945.yml -openapi_spec_hash: 4d42a5d93bd82754acf11e32e7438a04 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-2fed6c2aef6fb20a2815d0ed36d801c566a73ea11a66db5d892b1533a1fac19e.yml +openapi_spec_hash: 55559a2ca985ed36cb8a13b09f80dcb5 config_hash: a085d1b39ddf0b26ee798501a9f47e20 diff --git a/src/resources/apps/apps.ts b/src/resources/apps/apps.ts index 2b982f6..b964b33 100644 --- a/src/resources/apps/apps.ts +++ b/src/resources/apps/apps.ts @@ -57,7 +57,7 @@ export namespace AppListResponse { /** * Deployment region code */ - region: string; + region: 'aws.us-east-1a'; /** * Version label for the application diff --git a/src/resources/deployments.ts b/src/resources/deployments.ts index 5b501ea..3cfb875 100644 --- a/src/resources/deployments.ts +++ b/src/resources/deployments.ts @@ -73,7 +73,7 @@ export interface DeploymentCreateResponse { /** * Deployment region code */ - region: string; + region: 'aws.us-east-1a'; /** * Current status of the deployment @@ -118,7 +118,7 @@ export interface DeploymentRetrieveResponse { /** * Deployment region code */ - region: string; + region: 'aws.us-east-1a'; /** * Current status of the deployment @@ -214,7 +214,7 @@ export namespace DeploymentFollowResponse { /** * Deployment region code */ - region: string; + region: 'aws.us-east-1a'; /** * Current status of the deployment @@ -265,7 +265,7 @@ export namespace DeploymentFollowResponse { /** * Deployment region code */ - region: string; + region: 'aws.us-east-1a'; /** * Time the state was reported. From 121219a8e7dab92398d7373afb84be06a9d15217 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 23:01:18 +0000 Subject: [PATCH 10/23] feat(api): update via SDK Studio --- .stats.yml | 4 ++-- src/resources/deployments.ts | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3f66d22..4dea91f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 14 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-2fed6c2aef6fb20a2815d0ed36d801c566a73ea11a66db5d892b1533a1fac19e.yml -openapi_spec_hash: 55559a2ca985ed36cb8a13b09f80dcb5 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-da3b6999bce525461011a620a559d34d4b4ab1d073758e7add4d2ba09f57a2ba.yml +openapi_spec_hash: 7bec5f31fa27666a3955076653c6ac40 config_hash: a085d1b39ddf0b26ee798501a9f47e20 diff --git a/src/resources/deployments.ts b/src/resources/deployments.ts index 3cfb875..b4b493c 100644 --- a/src/resources/deployments.ts +++ b/src/resources/deployments.ts @@ -252,6 +252,11 @@ export namespace DeploymentFollowResponse { */ id: string; + /** + * List of actions available on the app + */ + actions: Array; + /** * Name of the application */ @@ -277,11 +282,6 @@ export namespace DeploymentFollowResponse { */ version: string; - /** - * List of actions available on the app - */ - actions?: Array; - /** * Environment variables configured for this app version */ From 6e4f782824e8ec1956d31ddaff7073a0015a3014 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 23:12:46 +0000 Subject: [PATCH 11/23] feat(api): update via SDK Studio --- .stats.yml | 4 ++-- src/resources/deployments.ts | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 4dea91f..3ea11ab 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 14 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-da3b6999bce525461011a620a559d34d4b4ab1d073758e7add4d2ba09f57a2ba.yml -openapi_spec_hash: 7bec5f31fa27666a3955076653c6ac40 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-b8c3224543bfd828075063a87302ec205b54f8b24658cc869b98aa81d995d855.yml +openapi_spec_hash: 52f5b821303fef54e61bae285f185200 config_hash: a085d1b39ddf0b26ee798501a9f47e20 diff --git a/src/resources/deployments.ts b/src/resources/deployments.ts index b4b493c..41b7c67 100644 --- a/src/resources/deployments.ts +++ b/src/resources/deployments.ts @@ -255,7 +255,7 @@ export namespace DeploymentFollowResponse { /** * List of actions available on the app */ - actions: Array; + actions: Array; /** * Name of the application @@ -288,6 +288,15 @@ export namespace DeploymentFollowResponse { env_vars?: Record; } + export namespace AppVersionSummaryEvent { + export interface Action { + /** + * Name of the action + */ + name: string; + } + } + /** * An error event from the application. */ From 371e3178a73439915a459dc0b7e968aeaf9f7e8f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 23:14:01 +0000 Subject: [PATCH 12/23] feat(api): update via SDK Studio --- .stats.yml | 4 ++-- src/resources/deployments.ts | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3ea11ab..3493617 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 14 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-b8c3224543bfd828075063a87302ec205b54f8b24658cc869b98aa81d995d855.yml -openapi_spec_hash: 52f5b821303fef54e61bae285f185200 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-ba02d679c34c3af5ea47ec2b1a7387785d831e09f35bebfef9f05538ff380c3b.yml +openapi_spec_hash: 7ddbbe7354f65437d4eb567e8b042552 config_hash: a085d1b39ddf0b26ee798501a9f47e20 diff --git a/src/resources/deployments.ts b/src/resources/deployments.ts index 41b7c67..c885b2f 100644 --- a/src/resources/deployments.ts +++ b/src/resources/deployments.ts @@ -289,11 +289,14 @@ export namespace DeploymentFollowResponse { } export namespace AppVersionSummaryEvent { + /** + * An action available on the app + */ export interface Action { /** * Name of the action */ - name: string; + name?: string; } } From 76a1ea8d2d978b7872ff122f6b4457f361695e22 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 23:14:46 +0000 Subject: [PATCH 13/23] feat(api): update via SDK Studio --- .stats.yml | 4 ++-- src/resources/deployments.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3493617..bb23445 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 14 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-ba02d679c34c3af5ea47ec2b1a7387785d831e09f35bebfef9f05538ff380c3b.yml -openapi_spec_hash: 7ddbbe7354f65437d4eb567e8b042552 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-f7fa782f119b02d610bac1dbc75bf8355e73169d978997527f643e24036dabdd.yml +openapi_spec_hash: 9543dfe156b1c42a2fe4d3767e6b0778 config_hash: a085d1b39ddf0b26ee798501a9f47e20 diff --git a/src/resources/deployments.ts b/src/resources/deployments.ts index c885b2f..ae2e487 100644 --- a/src/resources/deployments.ts +++ b/src/resources/deployments.ts @@ -296,7 +296,7 @@ export namespace DeploymentFollowResponse { /** * Name of the action */ - name?: string; + name: string; } } From 801fb38b66af7598d9bbc12d6964031f44f7a6ea Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 03:20:14 +0000 Subject: [PATCH 14/23] chore(client): refactor imports --- src/client.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/client.ts b/src/client.ts index 3e63b03..12b0e73 100644 --- a/src/client.ts +++ b/src/client.ts @@ -5,7 +5,6 @@ import type { HTTPMethod, PromiseOrValue, MergedRequestInit, FinalizedRequestIni import { uuid4 } from './internal/utils/uuid'; import { validatePositiveInteger, isAbsoluteURL, safeJSON } from './internal/utils/values'; import { sleep } from './internal/utils/sleep'; -import { type Logger, type LogLevel, parseLogLevel } from './internal/utils/log'; export type { Logger, LogLevel } from './internal/utils/log'; import { castToError, isAbortError } from './internal/errors'; import type { APIResponseProps } from './internal/parse'; @@ -17,9 +16,6 @@ import * as Errors from './core/error'; import * as Uploads from './core/uploads'; import * as API from './resources/index'; import { APIPromise } from './core/api-promise'; -import { type Fetch } from './internal/builtin-types'; -import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers'; -import { FinalRequestOptions, RequestOptions } from './internal/request-options'; import { BrowserCreateParams, BrowserCreateResponse, @@ -36,11 +32,20 @@ import { DeploymentRetrieveResponse, Deployments, } from './resources/deployments'; -import { readEnv } from './internal/utils/env'; -import { formatRequestDetails, loggerFor } from './internal/utils/log'; -import { isEmptyObj } from './internal/utils/values'; import { KernelApp } from './core/app-framework'; import { AppListParams, AppListResponse, Apps } from './resources/apps/apps'; +import { type Fetch } from './internal/builtin-types'; +import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers'; +import { FinalRequestOptions, RequestOptions } from './internal/request-options'; +import { readEnv } from './internal/utils/env'; +import { + type LogLevel, + type Logger, + formatRequestDetails, + loggerFor, + parseLogLevel, +} from './internal/utils/log'; +import { isEmptyObj } from './internal/utils/values'; const environments = { production: 'https://api.onkernel.com/', From 7b4d7a2da7ba44fa0e0648545eccb5e175cf8255 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 03:58:00 +0000 Subject: [PATCH 15/23] feat(client): add support for endpoint-specific base URLs --- package.json | 2 +- src/client.ts | 20 ++++++++++++++++---- src/internal/request-options.ts | 1 + tests/index.test.ts | 22 ++++++++++++++++++++++ yarn.lock | 6 +++--- 5 files changed, 43 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 13306fb..7881f39 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "publint": "^0.2.12", "ts-jest": "^29.1.0", "ts-node": "^10.5.0", - "tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.7/tsc-multi.tgz", + "tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.8/tsc-multi.tgz", "tsconfig-paths": "^4.0.0", "typescript": "5.8.3" }, diff --git a/src/client.ts b/src/client.ts index 12b0e73..184bba6 100644 --- a/src/client.ts +++ b/src/client.ts @@ -228,6 +228,13 @@ export class Kernel { }); } + /** + * Check whether the base URL is set to its default. + */ + #baseURLOverridden(): boolean { + return this.baseURL !== environments[this._options.environment || 'production']; + } + protected defaultQuery(): Record | undefined { return this._options.defaultQuery; } @@ -277,11 +284,16 @@ export class Kernel { return Errors.APIError.generate(status, error, message, headers); } - buildURL(path: string, query: Record | null | undefined): string { + buildURL( + path: string, + query: Record | null | undefined, + defaultBaseURL?: string | undefined, + ): string { + const baseURL = (!this.#baseURLOverridden() && defaultBaseURL) || this.baseURL; const url = isAbsoluteURL(path) ? new URL(path) - : new URL(this.baseURL + (this.baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path)); + : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path)); const defaultQuery = this.defaultQuery(); if (!isEmptyObj(defaultQuery)) { @@ -622,9 +634,9 @@ export class Kernel { { retryCount = 0 }: { retryCount?: number } = {}, ): { req: FinalizedRequestInit; url: string; timeout: number } { const options = { ...inputOptions }; - const { method, path, query } = options; + const { method, path, query, defaultBaseURL } = options; - const url = this.buildURL(path!, query as Record); + const url = this.buildURL(path!, query as Record, defaultBaseURL); if ('timeout' in options) validatePositiveInteger('timeout', options.timeout); options.timeout = options.timeout ?? this.timeout; const { bodyHeaders, body } = this.buildBody({ options }); diff --git a/src/internal/request-options.ts b/src/internal/request-options.ts index ef09931..ffe01ae 100644 --- a/src/internal/request-options.ts +++ b/src/internal/request-options.ts @@ -21,6 +21,7 @@ export type RequestOptions = { fetchOptions?: MergedRequestInit; signal?: AbortSignal | undefined | null; idempotencyKey?: string; + defaultBaseURL?: string | undefined; __binaryResponse?: boolean | undefined; __streamClass?: typeof Stream; diff --git a/tests/index.test.ts b/tests/index.test.ts index b452e0f..5c12c9a 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -323,6 +323,28 @@ describe('instantiate client', () => { const client = new Kernel({ apiKey: 'My API Key', baseURL: null, environment: 'production' }); expect(client.baseURL).toEqual('https://api.onkernel.com/'); }); + + test('in request options', () => { + const client = new Kernel({ apiKey: 'My API Key' }); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( + 'http://localhost:5000/option/foo', + ); + }); + + test('in request options overridden by client options', () => { + const client = new Kernel({ apiKey: 'My API Key', baseURL: 'http://localhost:5000/client' }); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( + 'http://localhost:5000/client/foo', + ); + }); + + test('in request options overridden by env variable', () => { + process.env['KERNEL_BASE_URL'] = 'http://localhost:5000/env'; + const client = new Kernel({ apiKey: 'My API Key' }); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( + 'http://localhost:5000/env/foo', + ); + }); }); test('maxRetries option is correctly set', () => { diff --git a/yarn.lock b/yarn.lock index c611c53..58c08d5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3283,9 +3283,9 @@ ts-node@^10.5.0: v8-compile-cache-lib "^3.0.0" yn "3.1.1" -"tsc-multi@https://github.com/stainless-api/tsc-multi/releases/download/v1.1.7/tsc-multi.tgz": - version "1.1.7" - resolved "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.7/tsc-multi.tgz#52f40adf8b808bd0b633346d11cc4a8aeea465cd" +"tsc-multi@https://github.com/stainless-api/tsc-multi/releases/download/v1.1.8/tsc-multi.tgz": + version "1.1.8" + resolved "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.8/tsc-multi.tgz#f544b359b8f05e607771ffacc280e58201476b04" dependencies: debug "^4.3.7" fast-glob "^3.3.2" From 0dc0e130a319209e0debcb41df6a7e4e473a013b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 06:42:52 +0000 Subject: [PATCH 16/23] chore(ci): enable for pull requests --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 097e558..b35fe33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,10 @@ on: - 'integrated/**' - 'stl-preview-head/**' - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: lint: From b0652c76a0d9b8ff39c8d97d0087a305ed1bb0b7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 15:09:47 +0000 Subject: [PATCH 17/23] feat(api): update via SDK Studio --- .stats.yml | 8 +- api.md | 25 ++- src/client.ts | 28 +++ src/resources/apps/apps.ts | 20 -- src/resources/apps/deployments.ts | 23 +-- src/resources/apps/index.ts | 8 - src/resources/deployments.ts | 190 +++++++----------- src/resources/index.ts | 12 ++ src/resources/{apps => }/invocations.ts | 158 ++++++++++++++- src/resources/shared.ts | 33 +++ .../{apps => }/invocations.test.ts | 22 +- 11 files changed, 335 insertions(+), 192 deletions(-) rename src/resources/{apps => }/invocations.ts (55%) create mode 100644 src/resources/shared.ts rename tests/api-resources/{apps => }/invocations.test.ts (69%) diff --git a/.stats.yml b/.stats.yml index bb23445..b912099 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 14 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-f7fa782f119b02d610bac1dbc75bf8355e73169d978997527f643e24036dabdd.yml -openapi_spec_hash: 9543dfe156b1c42a2fe4d3767e6b0778 -config_hash: a085d1b39ddf0b26ee798501a9f47e20 +configured_endpoints: 15 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-5d4e11bc46eeecee7363d56a9dfe946acee997d5b352c2b0a50c20e742c54d2d.yml +openapi_spec_hash: 333e53ad9c706296b9afdb8ff73bec8f +config_hash: 4e2f9aebc2153d5caf7bb8b2eb107026 diff --git a/api.md b/api.md index b27a84a..aecd8e9 100644 --- a/api.md +++ b/api.md @@ -1,7 +1,15 @@ +# Shared + +Types: + +- ErrorDetail +- LogEvent + # Deployments Types: +- DeploymentStateEvent - DeploymentCreateResponse - DeploymentRetrieveResponse - DeploymentFollowResponse @@ -34,19 +42,22 @@ Methods: - client.apps.deployments.create({ ...params }) -> DeploymentCreateResponse - client.apps.deployments.follow(id) -> DeploymentFollowResponse -## Invocations +# Invocations Types: -- InvocationCreateResponse -- InvocationRetrieveResponse -- InvocationUpdateResponse +- InvocationStateEvent +- InvocationCreateResponse +- InvocationRetrieveResponse +- InvocationUpdateResponse +- InvocationFollowResponse Methods: -- client.apps.invocations.create({ ...params }) -> InvocationCreateResponse -- client.apps.invocations.retrieve(id) -> InvocationRetrieveResponse -- client.apps.invocations.update(id, { ...params }) -> InvocationUpdateResponse +- client.invocations.create({ ...params }) -> InvocationCreateResponse +- client.invocations.retrieve(id) -> InvocationRetrieveResponse +- client.invocations.update(id, { ...params }) -> InvocationUpdateResponse +- client.invocations.follow(id) -> InvocationFollowResponse # Browsers diff --git a/src/client.ts b/src/client.ts index 184bba6..2684270 100644 --- a/src/client.ts +++ b/src/client.ts @@ -30,9 +30,20 @@ import { DeploymentCreateResponse, DeploymentFollowResponse, DeploymentRetrieveResponse, + DeploymentStateEvent, Deployments, } from './resources/deployments'; import { KernelApp } from './core/app-framework'; +import { + InvocationCreateParams, + InvocationCreateResponse, + InvocationFollowResponse, + InvocationRetrieveResponse, + InvocationStateEvent, + InvocationUpdateParams, + InvocationUpdateResponse, + Invocations, +} from './resources/invocations'; import { AppListParams, AppListResponse, Apps } from './resources/apps/apps'; import { type Fetch } from './internal/builtin-types'; import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers'; @@ -761,16 +772,19 @@ export class Kernel { deployments: API.Deployments = new API.Deployments(this); apps: API.Apps = new API.Apps(this); + invocations: API.Invocations = new API.Invocations(this); browsers: API.Browsers = new API.Browsers(this); } Kernel.Deployments = Deployments; Kernel.Apps = Apps; +Kernel.Invocations = Invocations; Kernel.Browsers = Browsers; export declare namespace Kernel { export type RequestOptions = Opts.RequestOptions; export { Deployments as Deployments, + type DeploymentStateEvent as DeploymentStateEvent, type DeploymentCreateResponse as DeploymentCreateResponse, type DeploymentRetrieveResponse as DeploymentRetrieveResponse, type DeploymentFollowResponse as DeploymentFollowResponse, @@ -779,6 +793,17 @@ export declare namespace Kernel { export { Apps as Apps, type AppListResponse as AppListResponse, type AppListParams as AppListParams }; + export { + Invocations as Invocations, + type InvocationStateEvent as InvocationStateEvent, + type InvocationCreateResponse as InvocationCreateResponse, + type InvocationRetrieveResponse as InvocationRetrieveResponse, + type InvocationUpdateResponse as InvocationUpdateResponse, + type InvocationFollowResponse as InvocationFollowResponse, + type InvocationCreateParams as InvocationCreateParams, + type InvocationUpdateParams as InvocationUpdateParams, + }; + export { Browsers as Browsers, type BrowserPersistence as BrowserPersistence, @@ -788,4 +813,7 @@ export declare namespace Kernel { type BrowserCreateParams as BrowserCreateParams, type BrowserDeleteParams as BrowserDeleteParams, }; + + export type ErrorDetail = API.ErrorDetail; + export type LogEvent = API.LogEvent; } diff --git a/src/resources/apps/apps.ts b/src/resources/apps/apps.ts index b964b33..7f8831e 100644 --- a/src/resources/apps/apps.ts +++ b/src/resources/apps/apps.ts @@ -8,21 +8,11 @@ import { DeploymentFollowResponse, Deployments, } from './deployments'; -import * as InvocationsAPI from './invocations'; -import { - InvocationCreateParams, - InvocationCreateResponse, - InvocationRetrieveResponse, - InvocationUpdateParams, - InvocationUpdateResponse, - Invocations, -} from './invocations'; import { APIPromise } from '../../core/api-promise'; import { RequestOptions } from '../../internal/request-options'; export class Apps extends APIResource { deployments: DeploymentsAPI.Deployments = new DeploymentsAPI.Deployments(this._client); - invocations: InvocationsAPI.Invocations = new InvocationsAPI.Invocations(this._client); /** * List applications. Optionally filter by app name and/or version label. @@ -84,7 +74,6 @@ export interface AppListParams { } Apps.Deployments = Deployments; -Apps.Invocations = Invocations; export declare namespace Apps { export { type AppListResponse as AppListResponse, type AppListParams as AppListParams }; @@ -95,13 +84,4 @@ export declare namespace Apps { type DeploymentFollowResponse as DeploymentFollowResponse, type DeploymentCreateParams as DeploymentCreateParams, }; - - export { - Invocations as Invocations, - type InvocationCreateResponse as InvocationCreateResponse, - type InvocationRetrieveResponse as InvocationRetrieveResponse, - type InvocationUpdateResponse as InvocationUpdateResponse, - type InvocationCreateParams as InvocationCreateParams, - type InvocationUpdateParams as InvocationUpdateParams, - }; } diff --git a/src/resources/apps/deployments.ts b/src/resources/apps/deployments.ts index e6ee49f..1581c8e 100644 --- a/src/resources/apps/deployments.ts +++ b/src/resources/apps/deployments.ts @@ -1,6 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; +import * as Shared from '../shared'; import { APIPromise } from '../../core/api-promise'; import { Stream } from '../../core/streaming'; import { type Uploadable } from '../../core/uploads'; @@ -96,7 +97,7 @@ export namespace DeploymentCreateResponse { export type DeploymentFollowResponse = | DeploymentFollowResponse.StateEvent | DeploymentFollowResponse.StateUpdateEvent - | DeploymentFollowResponse.LogEvent; + | Shared.LogEvent; export namespace DeploymentFollowResponse { /** @@ -138,26 +139,6 @@ export namespace DeploymentFollowResponse { */ timestamp?: string; } - - /** - * A log entry from the application. - */ - export interface LogEvent { - /** - * Event type identifier (always "log"). - */ - event: 'log'; - - /** - * Log message text. - */ - message: string; - - /** - * Time the log entry was produced. - */ - timestamp: string; - } } export interface DeploymentCreateParams { diff --git a/src/resources/apps/index.ts b/src/resources/apps/index.ts index 29751c0..a32f41e 100644 --- a/src/resources/apps/index.ts +++ b/src/resources/apps/index.ts @@ -7,11 +7,3 @@ export { type DeploymentFollowResponse, type DeploymentCreateParams, } from './deployments'; -export { - Invocations, - type InvocationCreateResponse, - type InvocationRetrieveResponse, - type InvocationUpdateResponse, - type InvocationCreateParams, - type InvocationUpdateParams, -} from './invocations'; diff --git a/src/resources/deployments.ts b/src/resources/deployments.ts index ae2e487..ef7b309 100644 --- a/src/resources/deployments.ts +++ b/src/resources/deployments.ts @@ -1,6 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; +import * as Shared from './shared'; import { APIPromise } from '../core/api-promise'; import { Stream } from '../core/streaming'; import { type Uploadable } from '../core/uploads'; @@ -56,6 +57,73 @@ export class Deployments extends APIResource { } } +/** + * An event representing the current state of a deployment. + */ +export interface DeploymentStateEvent { + /** + * Deployment record information. + */ + deployment: DeploymentStateEvent.Deployment; + + /** + * Event type identifier (always "deployment_state"). + */ + event: 'deployment_state'; + + /** + * Time the state was reported. + */ + timestamp: string; +} + +export namespace DeploymentStateEvent { + /** + * Deployment record information. + */ + export interface Deployment { + /** + * Unique identifier for the deployment + */ + id: string; + + /** + * Timestamp when the deployment was created + */ + created_at: string; + + /** + * Deployment region code + */ + region: 'aws.us-east-1a'; + + /** + * Current status of the deployment + */ + status: 'queued' | 'in_progress' | 'running' | 'failed' | 'stopped'; + + /** + * Relative path to the application entrypoint + */ + entrypoint_rel_path?: string; + + /** + * Environment variables configured for this deployment + */ + env_vars?: Record; + + /** + * Status reason + */ + status_reason?: string; + + /** + * Timestamp when the deployment was last updated + */ + updated_at?: string | null; + } +} + /** * Deployment record information. */ @@ -150,99 +218,12 @@ export interface DeploymentRetrieveResponse { * Union type representing any deployment event. */ export type DeploymentFollowResponse = - | DeploymentFollowResponse.LogEvent - | DeploymentFollowResponse.DeploymentStateEvent + | Shared.LogEvent + | DeploymentStateEvent | DeploymentFollowResponse.AppVersionSummaryEvent | DeploymentFollowResponse.ErrorEvent; export namespace DeploymentFollowResponse { - /** - * A log entry from the application. - */ - export interface LogEvent { - /** - * Event type identifier (always "log"). - */ - event: 'log'; - - /** - * Log message text. - */ - message: string; - - /** - * Time the log entry was produced. - */ - timestamp: string; - } - - /** - * An event representing the current state of a deployment. - */ - export interface DeploymentStateEvent { - /** - * Deployment record information. - */ - deployment: DeploymentStateEvent.Deployment; - - /** - * Event type identifier (always "deployment_state"). - */ - event: 'deployment_state'; - - /** - * Time the state was reported. - */ - timestamp: string; - } - - export namespace DeploymentStateEvent { - /** - * Deployment record information. - */ - export interface Deployment { - /** - * Unique identifier for the deployment - */ - id: string; - - /** - * Timestamp when the deployment was created - */ - created_at: string; - - /** - * Deployment region code - */ - region: 'aws.us-east-1a'; - - /** - * Current status of the deployment - */ - status: 'queued' | 'in_progress' | 'running' | 'failed' | 'stopped'; - - /** - * Relative path to the application entrypoint - */ - entrypoint_rel_path?: string; - - /** - * Environment variables configured for this deployment - */ - env_vars?: Record; - - /** - * Status reason - */ - status_reason?: string; - - /** - * Timestamp when the deployment was last updated - */ - updated_at?: string | null; - } - } - /** * Summary of an application version. */ @@ -332,35 +313,9 @@ export namespace DeploymentFollowResponse { /** * Additional error details (for multiple errors) */ - details?: Array; - - inner_error?: Error.InnerError; - } + details?: Array; - export namespace Error { - export interface Detail { - /** - * Lower-level error code providing more specific detail - */ - code?: string; - - /** - * Further detail about the error - */ - message?: string; - } - - export interface InnerError { - /** - * Lower-level error code providing more specific detail - */ - code?: string; - - /** - * Further detail about the error - */ - message?: string; - } + inner_error?: Shared.ErrorDetail; } } } @@ -400,6 +355,7 @@ export interface DeploymentCreateParams { export declare namespace Deployments { export { + type DeploymentStateEvent as DeploymentStateEvent, type DeploymentCreateResponse as DeploymentCreateResponse, type DeploymentRetrieveResponse as DeploymentRetrieveResponse, type DeploymentFollowResponse as DeploymentFollowResponse, diff --git a/src/resources/index.ts b/src/resources/index.ts index 4da3454..8c96ec4 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -1,5 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +export * from './shared'; export { Apps, type AppListResponse, type AppListParams } from './apps/apps'; export { Browsers, @@ -12,8 +13,19 @@ export { } from './browsers'; export { Deployments, + type DeploymentStateEvent, type DeploymentCreateResponse, type DeploymentRetrieveResponse, type DeploymentFollowResponse, type DeploymentCreateParams, } from './deployments'; +export { + Invocations, + type InvocationStateEvent, + type InvocationCreateResponse, + type InvocationRetrieveResponse, + type InvocationUpdateResponse, + type InvocationFollowResponse, + type InvocationCreateParams, + type InvocationUpdateParams, +} from './invocations'; diff --git a/src/resources/apps/invocations.ts b/src/resources/invocations.ts similarity index 55% rename from src/resources/apps/invocations.ts rename to src/resources/invocations.ts index 7479550..0751cc4 100644 --- a/src/resources/apps/invocations.ts +++ b/src/resources/invocations.ts @@ -1,9 +1,12 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { APIResource } from '../../core/resource'; -import { APIPromise } from '../../core/api-promise'; -import { RequestOptions } from '../../internal/request-options'; -import { path } from '../../internal/utils/path'; +import { APIResource } from '../core/resource'; +import * as Shared from './shared'; +import { APIPromise } from '../core/api-promise'; +import { Stream } from '../core/streaming'; +import { buildHeaders } from '../internal/headers'; +import { RequestOptions } from '../internal/request-options'; +import { path } from '../internal/utils/path'; export class Invocations extends APIResource { /** @@ -11,7 +14,7 @@ export class Invocations extends APIResource { * * @example * ```ts - * const invocation = await client.apps.invocations.create({ + * const invocation = await client.invocations.create({ * action_name: 'analyze', * app_name: 'my-app', * version: '1.0.0', @@ -27,7 +30,7 @@ export class Invocations extends APIResource { * * @example * ```ts - * const invocation = await client.apps.invocations.retrieve( + * const invocation = await client.invocations.retrieve( * 'rr33xuugxj9h0bkf1rdt2bet', * ); * ``` @@ -41,10 +44,9 @@ export class Invocations extends APIResource { * * @example * ```ts - * const invocation = await client.apps.invocations.update( - * 'id', - * { status: 'succeeded' }, - * ); + * const invocation = await client.invocations.update('id', { + * status: 'succeeded', + * }); * ``` */ update( @@ -54,6 +56,92 @@ export class Invocations extends APIResource { ): APIPromise { return this._client.patch(path`/invocations/${id}`, { body, ...options }); } + + /** + * Establishes a Server-Sent Events (SSE) stream that delivers real-time logs and + * status updates for an invocation. The stream terminates automatically once the + * invocation reaches a terminal state. + * + * @example + * ```ts + * const response = await client.invocations.follow('id'); + * ``` + */ + follow(id: string, options?: RequestOptions): APIPromise> { + return this._client.get(path`/invocations/${id}/events`, { + ...options, + headers: buildHeaders([{ Accept: 'text/event-stream' }, options?.headers]), + stream: true, + }) as APIPromise>; + } +} + +/** + * An event representing the current state of an invocation. + */ +export interface InvocationStateEvent { + /** + * Event type identifier (always "invocation_state"). + */ + event: 'invocation_state'; + + invocation: InvocationStateEvent.Invocation; + + /** + * Time the state was reported. + */ + timestamp: string; +} + +export namespace InvocationStateEvent { + export interface Invocation { + /** + * ID of the invocation + */ + id: string; + + /** + * Name of the action invoked + */ + action_name: string; + + /** + * Name of the application + */ + app_name: string; + + /** + * RFC 3339 Nanoseconds timestamp when the invocation started + */ + started_at: string; + + /** + * Status of the invocation + */ + status: 'queued' | 'running' | 'succeeded' | 'failed'; + + /** + * RFC 3339 Nanoseconds timestamp when the invocation finished (null if still + * running) + */ + finished_at?: string | null; + + /** + * Output produced by the action, rendered as a JSON string. This could be: string, + * number, boolean, array, object, or null. + */ + output?: string; + + /** + * Payload provided to the invocation. This is a string that can be parsed as JSON. + */ + payload?: string; + + /** + * Status reason + */ + status_reason?: string; + } } export interface InvocationCreateResponse { @@ -177,6 +265,54 @@ export interface InvocationUpdateResponse { status_reason?: string; } +/** + * Union type representing any invocation event. + */ +export type InvocationFollowResponse = + | Shared.LogEvent + | InvocationStateEvent + | InvocationFollowResponse.ErrorEvent; + +export namespace InvocationFollowResponse { + /** + * An error event from the application. + */ + export interface ErrorEvent { + error: ErrorEvent.Error; + + /** + * Event type identifier (always "error"). + */ + event: 'error'; + + /** + * Time the error occurred. + */ + timestamp: string; + } + + export namespace ErrorEvent { + export interface Error { + /** + * Application-specific error code (machine-readable) + */ + code: string; + + /** + * Human-readable error description for debugging + */ + message: string; + + /** + * Additional error details (for multiple errors) + */ + details?: Array; + + inner_error?: Shared.ErrorDetail; + } + } +} + export interface InvocationCreateParams { /** * Name of the action to invoke @@ -219,9 +355,11 @@ export interface InvocationUpdateParams { export declare namespace Invocations { export { + type InvocationStateEvent as InvocationStateEvent, type InvocationCreateResponse as InvocationCreateResponse, type InvocationRetrieveResponse as InvocationRetrieveResponse, type InvocationUpdateResponse as InvocationUpdateResponse, + type InvocationFollowResponse as InvocationFollowResponse, type InvocationCreateParams as InvocationCreateParams, type InvocationUpdateParams as InvocationUpdateParams, }; diff --git a/src/resources/shared.ts b/src/resources/shared.ts new file mode 100644 index 0000000..c56dcb1 --- /dev/null +++ b/src/resources/shared.ts @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export interface ErrorDetail { + /** + * Lower-level error code providing more specific detail + */ + code?: string; + + /** + * Further detail about the error + */ + message?: string; +} + +/** + * A log entry from the application. + */ +export interface LogEvent { + /** + * Event type identifier (always "log"). + */ + event: 'log'; + + /** + * Log message text. + */ + message: string; + + /** + * Time the log entry was produced. + */ + timestamp: string; +} diff --git a/tests/api-resources/apps/invocations.test.ts b/tests/api-resources/invocations.test.ts similarity index 69% rename from tests/api-resources/apps/invocations.test.ts rename to tests/api-resources/invocations.test.ts index 9a1b028..2201a59 100644 --- a/tests/api-resources/apps/invocations.test.ts +++ b/tests/api-resources/invocations.test.ts @@ -10,7 +10,7 @@ const client = new Kernel({ describe('resource invocations', () => { // skipped: tests are disabled for the time being test.skip('create: only required params', async () => { - const responsePromise = client.apps.invocations.create({ + const responsePromise = client.invocations.create({ action_name: 'analyze', app_name: 'my-app', version: '1.0.0', @@ -26,7 +26,7 @@ describe('resource invocations', () => { // skipped: tests are disabled for the time being test.skip('create: required and optional params', async () => { - const response = await client.apps.invocations.create({ + const response = await client.invocations.create({ action_name: 'analyze', app_name: 'my-app', version: '1.0.0', @@ -37,7 +37,7 @@ describe('resource invocations', () => { // skipped: tests are disabled for the time being test.skip('retrieve', async () => { - const responsePromise = client.apps.invocations.retrieve('rr33xuugxj9h0bkf1rdt2bet'); + const responsePromise = client.invocations.retrieve('rr33xuugxj9h0bkf1rdt2bet'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -49,7 +49,7 @@ describe('resource invocations', () => { // skipped: tests are disabled for the time being test.skip('update: only required params', async () => { - const responsePromise = client.apps.invocations.update('id', { status: 'succeeded' }); + const responsePromise = client.invocations.update('id', { status: 'succeeded' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -61,6 +61,18 @@ describe('resource invocations', () => { // skipped: tests are disabled for the time being test.skip('update: required and optional params', async () => { - const response = await client.apps.invocations.update('id', { status: 'succeeded', output: 'output' }); + const response = await client.invocations.update('id', { status: 'succeeded', output: 'output' }); + }); + + // skipped: currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail + test.skip('follow', async () => { + const responsePromise = client.invocations.follow('id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); }); }); From 842ec5503a95b8a7bd43405cb0af36411610d14a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 15:20:44 +0000 Subject: [PATCH 18/23] feat(api): update via SDK Studio --- .stats.yml | 6 ++--- api.md | 2 ++ src/client.ts | 2 ++ src/resources/deployments.ts | 40 +------------------------------- src/resources/invocations.ts | 44 +++--------------------------------- src/resources/shared.ts | 36 +++++++++++++++++++++++++++++ 6 files changed, 47 insertions(+), 83 deletions(-) diff --git a/.stats.yml b/.stats.yml index b912099..763dad3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 15 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-5d4e11bc46eeecee7363d56a9dfe946acee997d5b352c2b0a50c20e742c54d2d.yml -openapi_spec_hash: 333e53ad9c706296b9afdb8ff73bec8f -config_hash: 4e2f9aebc2153d5caf7bb8b2eb107026 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-b1b412b00906fca75bfa73cff7267dbb5bf975581778072e0a90c73ad7ba9cb1.yml +openapi_spec_hash: 9b7a1b29bcb4963fe6da37005c357d27 +config_hash: df959c379e1145106030a4869b006afe diff --git a/api.md b/api.md index aecd8e9..c7d96d1 100644 --- a/api.md +++ b/api.md @@ -2,7 +2,9 @@ Types: +- Error - ErrorDetail +- ErrorEvent - LogEvent # Deployments diff --git a/src/client.ts b/src/client.ts index 2684270..2acca25 100644 --- a/src/client.ts +++ b/src/client.ts @@ -814,6 +814,8 @@ export declare namespace Kernel { type BrowserDeleteParams as BrowserDeleteParams, }; + export type Error = API.Error; export type ErrorDetail = API.ErrorDetail; + export type ErrorEvent = API.ErrorEvent; export type LogEvent = API.LogEvent; } diff --git a/src/resources/deployments.ts b/src/resources/deployments.ts index ef7b309..bc247fc 100644 --- a/src/resources/deployments.ts +++ b/src/resources/deployments.ts @@ -221,7 +221,7 @@ export type DeploymentFollowResponse = | Shared.LogEvent | DeploymentStateEvent | DeploymentFollowResponse.AppVersionSummaryEvent - | DeploymentFollowResponse.ErrorEvent; + | Shared.ErrorEvent; export namespace DeploymentFollowResponse { /** @@ -280,44 +280,6 @@ export namespace DeploymentFollowResponse { name: string; } } - - /** - * An error event from the application. - */ - export interface ErrorEvent { - error: ErrorEvent.Error; - - /** - * Event type identifier (always "error"). - */ - event: 'error'; - - /** - * Time the error occurred. - */ - timestamp: string; - } - - export namespace ErrorEvent { - export interface Error { - /** - * Application-specific error code (machine-readable) - */ - code: string; - - /** - * Human-readable error description for debugging - */ - message: string; - - /** - * Additional error details (for multiple errors) - */ - details?: Array; - - inner_error?: Shared.ErrorDetail; - } - } } export interface DeploymentCreateParams { diff --git a/src/resources/invocations.ts b/src/resources/invocations.ts index 0751cc4..19f44bd 100644 --- a/src/resources/invocations.ts +++ b/src/resources/invocations.ts @@ -1,6 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; +import * as DeploymentsAPI from './deployments'; import * as Shared from './shared'; import { APIPromise } from '../core/api-promise'; import { Stream } from '../core/streaming'; @@ -270,48 +271,9 @@ export interface InvocationUpdateResponse { */ export type InvocationFollowResponse = | Shared.LogEvent + | DeploymentsAPI.DeploymentStateEvent | InvocationStateEvent - | InvocationFollowResponse.ErrorEvent; - -export namespace InvocationFollowResponse { - /** - * An error event from the application. - */ - export interface ErrorEvent { - error: ErrorEvent.Error; - - /** - * Event type identifier (always "error"). - */ - event: 'error'; - - /** - * Time the error occurred. - */ - timestamp: string; - } - - export namespace ErrorEvent { - export interface Error { - /** - * Application-specific error code (machine-readable) - */ - code: string; - - /** - * Human-readable error description for debugging - */ - message: string; - - /** - * Additional error details (for multiple errors) - */ - details?: Array; - - inner_error?: Shared.ErrorDetail; - } - } -} + | Shared.ErrorEvent; export interface InvocationCreateParams { /** diff --git a/src/resources/shared.ts b/src/resources/shared.ts index c56dcb1..876b2e3 100644 --- a/src/resources/shared.ts +++ b/src/resources/shared.ts @@ -1,5 +1,24 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +export interface Error { + /** + * Application-specific error code (machine-readable) + */ + code: string; + + /** + * Human-readable error description for debugging + */ + message: string; + + /** + * Additional error details (for multiple errors) + */ + details?: Array; + + inner_error?: ErrorDetail; +} + export interface ErrorDetail { /** * Lower-level error code providing more specific detail @@ -12,6 +31,23 @@ export interface ErrorDetail { message?: string; } +/** + * An error event from the application. + */ +export interface ErrorEvent { + error: Error; + + /** + * Event type identifier (always "error"). + */ + event: 'error'; + + /** + * Time the error occurred. + */ + timestamp: string; +} + /** * A log entry from the application. */ From c6890ba4c2ccebc4be3388107de407ef833555d6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 15:23:21 +0000 Subject: [PATCH 19/23] feat(api): update via SDK Studio --- .stats.yml | 4 ++-- src/resources/invocations.ts | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.stats.yml b/.stats.yml index 763dad3..1e9f62b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 15 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-b1b412b00906fca75bfa73cff7267dbb5bf975581778072e0a90c73ad7ba9cb1.yml -openapi_spec_hash: 9b7a1b29bcb4963fe6da37005c357d27 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-5d4e11bc46eeecee7363d56a9dfe946acee997d5b352c2b0a50c20e742c54d2d.yml +openapi_spec_hash: 333e53ad9c706296b9afdb8ff73bec8f config_hash: df959c379e1145106030a4869b006afe diff --git a/src/resources/invocations.ts b/src/resources/invocations.ts index 19f44bd..40e16b6 100644 --- a/src/resources/invocations.ts +++ b/src/resources/invocations.ts @@ -1,7 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; -import * as DeploymentsAPI from './deployments'; import * as Shared from './shared'; import { APIPromise } from '../core/api-promise'; import { Stream } from '../core/streaming'; @@ -269,11 +268,7 @@ export interface InvocationUpdateResponse { /** * Union type representing any invocation event. */ -export type InvocationFollowResponse = - | Shared.LogEvent - | DeploymentsAPI.DeploymentStateEvent - | InvocationStateEvent - | Shared.ErrorEvent; +export type InvocationFollowResponse = Shared.LogEvent | InvocationStateEvent | Shared.ErrorEvent; export interface InvocationCreateParams { /** From b4fbd8cd5287894a1e31c3369e6268676b5cfb93 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 15:25:21 +0000 Subject: [PATCH 20/23] feat(api): update via SDK Studio --- .stats.yml | 2 +- api.md | 1 - src/client.ts | 1 - src/resources/shared.ts | 42 ++++++++++++++++++++++------------------- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1e9f62b..71dae95 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 15 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-5d4e11bc46eeecee7363d56a9dfe946acee997d5b352c2b0a50c20e742c54d2d.yml openapi_spec_hash: 333e53ad9c706296b9afdb8ff73bec8f -config_hash: df959c379e1145106030a4869b006afe +config_hash: 79af9b3bec53ee798dddcf815befa25d diff --git a/api.md b/api.md index c7d96d1..27523f3 100644 --- a/api.md +++ b/api.md @@ -2,7 +2,6 @@ Types: -- Error - ErrorDetail - ErrorEvent - LogEvent diff --git a/src/client.ts b/src/client.ts index 2acca25..72ead64 100644 --- a/src/client.ts +++ b/src/client.ts @@ -814,7 +814,6 @@ export declare namespace Kernel { type BrowserDeleteParams as BrowserDeleteParams, }; - export type Error = API.Error; export type ErrorDetail = API.ErrorDetail; export type ErrorEvent = API.ErrorEvent; export type LogEvent = API.LogEvent; diff --git a/src/resources/shared.ts b/src/resources/shared.ts index 876b2e3..55345c3 100644 --- a/src/resources/shared.ts +++ b/src/resources/shared.ts @@ -1,23 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export interface Error { - /** - * Application-specific error code (machine-readable) - */ - code: string; - - /** - * Human-readable error description for debugging - */ - message: string; - - /** - * Additional error details (for multiple errors) - */ - details?: Array; - - inner_error?: ErrorDetail; -} +import * as Shared from './shared'; export interface ErrorDetail { /** @@ -35,7 +18,7 @@ export interface ErrorDetail { * An error event from the application. */ export interface ErrorEvent { - error: Error; + error: ErrorEvent.Error; /** * Event type identifier (always "error"). @@ -48,6 +31,27 @@ export interface ErrorEvent { timestamp: string; } +export namespace ErrorEvent { + export interface Error { + /** + * Application-specific error code (machine-readable) + */ + code: string; + + /** + * Human-readable error description for debugging + */ + message: string; + + /** + * Additional error details (for multiple errors) + */ + details?: Array; + + inner_error?: Shared.ErrorDetail; + } +} + /** * A log entry from the application. */ From ce675afa43f72708fd26bd0ab9d37b43f2e4b645 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 15:26:00 +0000 Subject: [PATCH 21/23] feat(api): update via SDK Studio --- .stats.yml | 2 +- api.md | 1 + src/client.ts | 1 + src/resources/shared.ts | 34 +++++++++++++++------------------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.stats.yml b/.stats.yml index 71dae95..ba1c7c9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 15 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-5d4e11bc46eeecee7363d56a9dfe946acee997d5b352c2b0a50c20e742c54d2d.yml openapi_spec_hash: 333e53ad9c706296b9afdb8ff73bec8f -config_hash: 79af9b3bec53ee798dddcf815befa25d +config_hash: 0fdf285ddd8dee229fd84ea57df9080f diff --git a/api.md b/api.md index 27523f3..2f61707 100644 --- a/api.md +++ b/api.md @@ -4,6 +4,7 @@ Types: - ErrorDetail - ErrorEvent +- ErrorModel - LogEvent # Deployments diff --git a/src/client.ts b/src/client.ts index 72ead64..d27d6c9 100644 --- a/src/client.ts +++ b/src/client.ts @@ -816,5 +816,6 @@ export declare namespace Kernel { export type ErrorDetail = API.ErrorDetail; export type ErrorEvent = API.ErrorEvent; + export type ErrorModel = API.ErrorModel; export type LogEvent = API.LogEvent; } diff --git a/src/resources/shared.ts b/src/resources/shared.ts index 55345c3..1760bd4 100644 --- a/src/resources/shared.ts +++ b/src/resources/shared.ts @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Shared from './shared'; - export interface ErrorDetail { /** * Lower-level error code providing more specific detail @@ -18,7 +16,7 @@ export interface ErrorDetail { * An error event from the application. */ export interface ErrorEvent { - error: ErrorEvent.Error; + error: ErrorModel; /** * Event type identifier (always "error"). @@ -31,25 +29,23 @@ export interface ErrorEvent { timestamp: string; } -export namespace ErrorEvent { - export interface Error { - /** - * Application-specific error code (machine-readable) - */ - code: string; +export interface ErrorModel { + /** + * Application-specific error code (machine-readable) + */ + code: string; - /** - * Human-readable error description for debugging - */ - message: string; + /** + * Human-readable error description for debugging + */ + message: string; - /** - * Additional error details (for multiple errors) - */ - details?: Array; + /** + * Additional error details (for multiple errors) + */ + details?: Array; - inner_error?: Shared.ErrorDetail; - } + inner_error?: ErrorDetail; } /** From 48f24e9591eeb869dfeb38b6f52f28d6edfcd10e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Jun 2025 02:12:20 +0000 Subject: [PATCH 22/23] chore(readme): update badges --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 22327b8..4217f0f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Kernel TypeScript API Library -[![NPM version](https://img.shields.io/npm/v/@onkernel/sdk.svg)](https://npmjs.org/package/@onkernel/sdk) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@onkernel/sdk) +[![NPM version]()](https://npmjs.org/package/@onkernel/sdk) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@onkernel/sdk) This library provides convenient access to the Kernel REST API from server-side TypeScript or JavaScript. From e931ee651f15e2ab73f99d4d30cf2f9f2f26d8a1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Jun 2025 02:14:36 +0000 Subject: [PATCH 23/23] release: 0.6.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++++ package.json | 2 +- src/version.ts | 2 +- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f1c1e58..bcd0522 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.5.0" + ".": "0.6.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 60707d6..6ba64d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,40 @@ # Changelog +## 0.6.0 (2025-06-18) + +Full Changelog: [v0.5.0...v0.6.0](https://github.com/onkernel/kernel-node-sdk/compare/v0.5.0...v0.6.0) + +### Features + +* **api:** update via SDK Studio ([ce675af](https://github.com/onkernel/kernel-node-sdk/commit/ce675afa43f72708fd26bd0ab9d37b43f2e4b645)) +* **api:** update via SDK Studio ([b4fbd8c](https://github.com/onkernel/kernel-node-sdk/commit/b4fbd8cd5287894a1e31c3369e6268676b5cfb93)) +* **api:** update via SDK Studio ([c6890ba](https://github.com/onkernel/kernel-node-sdk/commit/c6890ba4c2ccebc4be3388107de407ef833555d6)) +* **api:** update via SDK Studio ([842ec55](https://github.com/onkernel/kernel-node-sdk/commit/842ec5503a95b8a7bd43405cb0af36411610d14a)) +* **api:** update via SDK Studio ([b0652c7](https://github.com/onkernel/kernel-node-sdk/commit/b0652c76a0d9b8ff39c8d97d0087a305ed1bb0b7)) +* **api:** update via SDK Studio ([76a1ea8](https://github.com/onkernel/kernel-node-sdk/commit/76a1ea8d2d978b7872ff122f6b4457f361695e22)) +* **api:** update via SDK Studio ([371e317](https://github.com/onkernel/kernel-node-sdk/commit/371e3178a73439915a459dc0b7e968aeaf9f7e8f)) +* **api:** update via SDK Studio ([6e4f782](https://github.com/onkernel/kernel-node-sdk/commit/6e4f782824e8ec1956d31ddaff7073a0015a3014)) +* **api:** update via SDK Studio ([121219a](https://github.com/onkernel/kernel-node-sdk/commit/121219a8e7dab92398d7373afb84be06a9d15217)) +* **api:** update via SDK Studio ([567602f](https://github.com/onkernel/kernel-node-sdk/commit/567602fb83e9135938abd7cd080f864fc787f288)) +* **api:** update via SDK Studio ([ef99764](https://github.com/onkernel/kernel-node-sdk/commit/ef99764a42bc6243b028162eb1fcc88ae36eed41)) +* **api:** update via SDK Studio ([e4ad78d](https://github.com/onkernel/kernel-node-sdk/commit/e4ad78d21af5a7d009f55cea09da358780ca8d2d)) +* **api:** update via SDK Studio ([171423f](https://github.com/onkernel/kernel-node-sdk/commit/171423fb6af8fde206a1e32a1e8611f4b1d325be)) +* **client:** add support for endpoint-specific base URLs ([7b4d7a2](https://github.com/onkernel/kernel-node-sdk/commit/7b4d7a2da7ba44fa0e0648545eccb5e175cf8255)) + + +### Bug Fixes + +* publish script — handle NPM errors correctly ([16c70f4](https://github.com/onkernel/kernel-node-sdk/commit/16c70f444b06763b186c7138e16476d03b9638fe)) + + +### Chores + +* avoid type error in certain environments ([ec7be8d](https://github.com/onkernel/kernel-node-sdk/commit/ec7be8d0c90029c4fb5911afee057dcd73f6caa1)) +* **ci:** enable for pull requests ([0dc0e13](https://github.com/onkernel/kernel-node-sdk/commit/0dc0e130a319209e0debcb41df6a7e4e473a013b)) +* **client:** refactor imports ([801fb38](https://github.com/onkernel/kernel-node-sdk/commit/801fb38b66af7598d9bbc12d6964031f44f7a6ea)) +* **internal:** add pure annotations, make base APIResource abstract ([71cd518](https://github.com/onkernel/kernel-node-sdk/commit/71cd5185af173938e8bf933045de56dec7c04802)) +* **readme:** update badges ([48f24e9](https://github.com/onkernel/kernel-node-sdk/commit/48f24e9591eeb869dfeb38b6f52f28d6edfcd10e)) + ## 0.5.0 (2025-06-04) Full Changelog: [v0.4.0...v0.5.0](https://github.com/onkernel/kernel-node-sdk/compare/v0.4.0...v0.5.0) diff --git a/package.json b/package.json index 7881f39..05bd20a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onkernel/sdk", - "version": "0.5.0", + "version": "0.6.0", "description": "The official TypeScript library for the Kernel API", "author": "Kernel <>", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index 1f5d158..30c2817 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.5.0'; // x-release-please-version +export const VERSION = '0.6.0'; // x-release-please-version