diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 347d8bf7..931fce1a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.9" + ".": "0.1.0-alpha.10" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 6158f93d..0a13f2d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.0-alpha.10 (2025-07-02) + +Full Changelog: [v0.1.0-alpha.9...v0.1.0-alpha.10](https://github.com/stainless-api/stainless-api-typescript/compare/v0.1.0-alpha.9...v0.1.0-alpha.10) + +### Features + +* add unwrapFile ([#2](https://github.com/stainless-api/stainless-api-typescript/issues/2)) ([75f71a2](https://github.com/stainless-api/stainless-api-typescript/commit/75f71a2486ef8db3c6c3c2684bf4edaba6fc758b)) + ## 0.1.0-alpha.9 (2025-07-02) Full Changelog: [v0.1.0-alpha.8...v0.1.0-alpha.9](https://github.com/stainless-api/stainless-api-typescript/compare/v0.1.0-alpha.8...v0.1.0-alpha.9) diff --git a/package.json b/package.json index b7cb2285..7313e302 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stainless-api/sdk", - "version": "0.1.0-alpha.9", + "version": "0.1.0-alpha.10", "description": "The official TypeScript library for the Stainless API", "author": "Stainless <>", "types": "dist/index.d.ts", diff --git a/packages/mcp-server/package.json b/packages/mcp-server/package.json index 9a15cd12..bf9f9847 100644 --- a/packages/mcp-server/package.json +++ b/packages/mcp-server/package.json @@ -1,6 +1,6 @@ { "name": "@stainless-api/mcp", - "version": "0.1.0-alpha.9", + "version": "0.1.0-alpha.10", "description": "The official MCP Server for the Stainless API", "author": "Stainless <>", "types": "dist/index.d.ts", diff --git a/packages/mcp-server/src/server.ts b/packages/mcp-server/src/server.ts index ea4915b4..c2e5062e 100644 --- a/packages/mcp-server/src/server.ts +++ b/packages/mcp-server/src/server.ts @@ -26,7 +26,7 @@ export { endpoints } from './tools'; export const server = new McpServer( { name: 'stainless_api_sdk_api', - version: '0.1.0-alpha.9', + version: '0.1.0-alpha.10', }, { capabilities: { diff --git a/src/client.ts b/src/client.ts index 901d86d3..333a65b5 100644 --- a/src/client.ts +++ b/src/client.ts @@ -55,6 +55,7 @@ import { parseLogLevel, } from './internal/utils/log'; import { isEmptyObj } from './internal/utils/values'; +import { unwrapFile } from './lib/unwrap'; const environments = { production: 'https://api.stainless.com', @@ -775,6 +776,7 @@ export class Stainless { static UnprocessableEntityError = Errors.UnprocessableEntityError; static toFile = Uploads.toFile; + static unwrapFile = unwrapFile; projects: API.Projects = new API.Projects(this); builds: API.Builds = new API.Builds(this); diff --git a/src/lib/unwrap.ts b/src/lib/unwrap.ts new file mode 100644 index 00000000..a55f9448 --- /dev/null +++ b/src/lib/unwrap.ts @@ -0,0 +1,25 @@ +/** + * Unwrap a file value from a union type, like the build object's `documented_spec`. + * + * @example + * const build = await client.builds.retrieve(buildID); + * const spec = await Stainless.unwrapFile(build.documented_spec); + */ +export async function unwrapFile( + value: { type: 'content'; content: string } | { type: 'url'; url: string }, +): Promise; +export async function unwrapFile( + value: { type: 'content'; content: string } | { type: 'url'; url: string } | null, +): Promise; +export async function unwrapFile( + value: { type: 'content'; content: string } | { type: 'url'; url: string } | null, +): Promise { + if (value === null) { + return null; + } + if (value.type === 'content') { + return value.content; + } + const response = await fetch(value.url); + return response.text(); +} diff --git a/src/version.ts b/src/version.ts index fdbf6896..5ed52cd1 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.1.0-alpha.9'; // x-release-please-version +export const VERSION = '0.1.0-alpha.10'; // x-release-please-version