Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.9"
".": "0.1.0-alpha.10"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-server/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 2 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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);
Expand Down
25 changes: 25 additions & 0 deletions src/lib/unwrap.ts
Original file line number Diff line number Diff line change
@@ -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<string>;
export async function unwrapFile(
value: { type: 'content'; content: string } | { type: 'url'; url: string } | null,
): Promise<string | null>;
export async function unwrapFile(
value: { type: 'content'; content: string } | { type: 'url'; url: string } | null,
): Promise<string | null> {
if (value === null) {
return null;
}
if (value.type === 'content') {
return value.content;
}
const response = await fetch(value.url);
return response.text();
}
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -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