Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Aug 27, 2024
1 parent 263a81c commit 8a3ba42
Show file tree
Hide file tree
Showing 109 changed files with 823 additions and 618 deletions.
Empty file modified .devcontainer/Dockerfile
100644 → 100755
Empty file.
Empty file modified .devcontainer/devcontainer.json
100644 → 100755
Empty file.
Empty file modified .eslintrc.js
100644 → 100755
Empty file.
Empty file modified .github/workflows/ci.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/publish-npm.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/release-doctor.yml
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .prettierignore
100644 → 100755
Empty file.
Empty file modified .prettierrc.json
100644 → 100755
Empty file.
Empty file modified .release-please-manifest.json
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion .stats.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 27
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/clear-street%2Fstudio-sdk-b38e4c48f2b9f0eae71813383b666bb6d32ffab6d74423e95e7da1cf046b893f.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/clear-street%2Fstudio-sdk-cac25d6221de76f03b4e417f9d33f9665f8ed5c2d324693a46d9506212a1fb3e.yml
Empty file modified Brewfile
100644 → 100755
Empty file.
Empty file modified CONTRIBUTING.md
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified SECURITY.md
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion api.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Methods:

Methods:

- <code title="get /accounts/{account_id}/pnl-summary">client.accounts.pnlSummary.<a href="./src/resources/accounts/pnl-summary.ts">retrieve</a>(accountId) -> PnlSummaryForAccount</code>
- <code title="get /accounts/{account_id}/pnl-summary">client.accounts.pnlSummary.<a href="./src/resources/accounts/pnl-summary.ts">retrieve</a>(accountId) -> PnlSummary</code>

## PnlDetails

Expand Down
Empty file modified bin/check-release-environment
100644 → 100755
Empty file.
Empty file modified bin/publish-npm
100644 → 100755
Empty file.
Empty file modified examples/.keep
100644 → 100755
Empty file.
Empty file modified jest.config.ts
100644 → 100755
Empty file.
Empty file modified package.json
100644 → 100755
Empty file.
Empty file modified release-please-config.json
100644 → 100755
Empty file.
Empty file modified scripts/utils/check-version.cjs
100644 → 100755
Empty file.
Empty file modified scripts/utils/fix-index-exports.cjs
100644 → 100755
Empty file.
Empty file modified scripts/utils/make-dist-package-json.cjs
100644 → 100755
Empty file.
Empty file modified scripts/utils/postprocess-files.cjs
100644 → 100755
Empty file.
Empty file modified src/_shims/MultipartBody.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/README.md
100644 → 100755
Empty file.
Empty file modified src/_shims/auto/runtime-bun.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/auto/runtime-deno.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/auto/runtime-node.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/auto/runtime.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/auto/types-deno.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/auto/types-node.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/auto/types.d.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/auto/types.js
100644 → 100755
Empty file.
Empty file modified src/_shims/auto/types.mjs
100644 → 100755
Empty file.
Empty file modified src/_shims/bun-runtime.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/index-deno.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/index.d.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/index.js
100644 → 100755
Empty file.
Empty file modified src/_shims/index.mjs
100644 → 100755
Empty file.
Empty file modified src/_shims/manual-types.d.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/manual-types.js
100644 → 100755
Empty file.
Empty file modified src/_shims/manual-types.mjs
100644 → 100755
Empty file.
Empty file modified src/_shims/node-runtime.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/node-types.d.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/node-types.js
100644 → 100755
Empty file.
Empty file modified src/_shims/node-types.mjs
100644 → 100755
Empty file.
Empty file modified src/_shims/registry.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/web-runtime.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/web-types.d.ts
100644 → 100755
Empty file.
Empty file modified src/_shims/web-types.js
100644 → 100755
Empty file.
Empty file modified src/_shims/web-types.mjs
100644 → 100755
Empty file.
14 changes: 12 additions & 2 deletions src/core.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { VERSION } from './version';
;

Check failure on line 2 in src/core.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `;⏎`
import {
StudioSDKError,
APIError,
Expand Down Expand Up @@ -38,6 +39,8 @@ type APIResponseProps = {

async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
const { response } = props;

Check failure on line 41 in src/core.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎··;⏎`
;

// fetch refuses to read the body when the status code is 204.
if (response.status === 204) {
return null as T;
Expand Down Expand Up @@ -194,7 +197,7 @@ export abstract class APIClient {
Accept: 'application/json',
'Content-Type': 'application/json',
'User-Agent': this.getUserAgent(),
...getPlatformHeaders(),
...getPlatformHeaders(),

Check failure on line 200 in src/core.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `······`
...this.authHeaders(opts),
};
}
Expand Down Expand Up @@ -751,8 +754,11 @@ export type RequestOptions<
signal?: AbortSignal | undefined | null;
idempotencyKey?: string;


Check failure on line 757 in src/core.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎⏎`

__binaryRequest?: boolean | undefined;
__binaryResponse?: boolean | undefined;

Check failure on line 760 in src/core.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎`

};

// This is required so that we can determine if a given object matches the RequestOptions
Expand All @@ -772,8 +778,11 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
signal: true,
idempotencyKey: true,


Check failure on line 781 in src/core.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎⏎`

__binaryRequest: true,
__binaryResponse: true,

Check failure on line 784 in src/core.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎`

};

export const isRequestOptions = (obj: unknown): obj is RequestOptions => {
Expand Down Expand Up @@ -982,7 +991,8 @@ export const castToError = (err: any): Error => {
};

export const ensurePresent = <T>(value: T | null | undefined): T => {
if (value == null) throw new StudioSDKError(`Expected a value to be given but received ${value} instead.`);
if (value == null)

Check failure on line 994 in src/core.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎···`
throw new StudioSDKError(`Expected a value to be given but received ${value} instead.`);
return value;
};

Expand Down
26 changes: 10 additions & 16 deletions src/error.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@

import { castToError, Headers } from './core';

export class StudioSDKError extends Error {}
export class StudioSDKError extends Error {

Check failure on line 5 in src/error.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎`
}

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

constructor(
status: number | undefined,
error: Object | undefined,
message: string | undefined,
headers: Headers | undefined,
) {

Check failure on line 13 in src/error.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎··;⏎⏎··constructor(status:·number·|·undefined,·error:·Object·|·undefined,·message:·string·|·undefined,·headers:·Headers·|·undefined` with `··constructor(⏎····status:·number·|·undefined,⏎····error:·Object·|·undefined,⏎····message:·string·|·undefined,⏎····headers:·Headers·|·undefined,⏎··`
;

constructor(status: number | undefined, error: Object | undefined, message: string | undefined, headers: Headers | undefined) {
super(`${APIError.makeMessage(status, error, message)}`);
this.status = status;
this.headers = headers;
Expand All @@ -24,8 +23,7 @@ export class APIError extends StudioSDKError {
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
const msg =
error?.message ?
typeof error.message === 'string' ?
error.message
typeof error.message === 'string' ? error.message
: JSON.stringify(error.message)
: error ? JSON.stringify(error)
: message;
Expand All @@ -42,12 +40,7 @@ export class APIError extends StudioSDKError {
return '(no status code or body)';
}

static generate(
status: number | undefined,
errorResponse: Object | undefined,
message: string | undefined,
headers: Headers | undefined,
) {
static generate(status: number | undefined, errorResponse: Object | undefined, message: string | undefined, headers: Headers | undefined) {
if (!status) {
return new APIConnectionError({ cause: castToError(errorResponse) });
}
Expand Down Expand Up @@ -143,4 +136,5 @@ export class RateLimitError extends APIError {
override readonly status: 429 = 429;
}

export class InternalServerError extends APIError {}
export class InternalServerError extends APIError {
}
25 changes: 6 additions & 19 deletions src/index.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import * as Errors from './error';
import * as Uploads from './uploads';
import { type Agent } from './_shims/index';
import { isRequestOptions } from './core';
import { type Agent, type RequestInit } from './_shims/index';
import * as Core from '@clear-street/studio-sdk/core';
import * as API from '@clear-street/studio-sdk/resources/index';

Expand Down Expand Up @@ -70,7 +71,7 @@ export interface ClientOptions {
}

/**
* API Client for interfacing with the Studio SDK API.
* API Client for interfacing with the Studio SDK API.
*/
export class StudioSDK extends Core.APIClient {
bearerToken: string;
Expand All @@ -96,7 +97,7 @@ export class StudioSDK extends Core.APIClient {
}: ClientOptions = {}) {
if (bearerToken === undefined) {
throw new Errors.StudioSDKError(
"The STUDIO_SDK_BEARER_TOKEN environment variable is missing or empty; either provide it, or instantiate the StudioSDK client with an bearerToken option, like new StudioSDK({ bearerToken: 'My Bearer Token' }).",
'The STUDIO_SDK_BEARER_TOKEN environment variable is missing or empty; either provide it, or instantiate the StudioSDK client with an bearerToken option, like new StudioSDK({ bearerToken: \'My Bearer Token\' }).'
);
}

Expand Down Expand Up @@ -124,7 +125,7 @@ export class StudioSDK extends Core.APIClient {
instruments: API.Instruments = new API.Instruments(this);

protected override defaultQuery(): Core.DefaultQuery | undefined {
return this._options.defaultQuery;
return this._options.defaultQuery
}

protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
Expand Down Expand Up @@ -158,21 +159,7 @@ export class StudioSDK extends Core.APIClient {
static fileFromPath = Uploads.fileFromPath;
}

export const {
StudioSDKError,
APIError,
APIConnectionError,
APIConnectionTimeoutError,
APIUserAbortError,
NotFoundError,
ConflictError,
RateLimitError,
BadRequestError,
AuthenticationError,
InternalServerError,
PermissionDeniedError,
UnprocessableEntityError,
} = Errors;
export const { StudioSDKError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError } = Errors

export import toFile = Uploads.toFile;
export import fileFromPath = Uploads.fileFromPath;
Expand Down
Empty file modified src/lib/.keep
100644 → 100755
Empty file.
Empty file modified src/resource.ts
100644 → 100755
Empty file.
10 changes: 10 additions & 0 deletions src/resources/accounts/accounts.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '@clear-street/studio-sdk/resource';
import { isRequestOptions } from '@clear-street/studio-sdk/core';
import { APIPromise } from '@clear-street/studio-sdk/core';
import * as Core from '@clear-street/studio-sdk/core';
import { BulkOrders } from './bulk-orders';
import { Orders } from './orders';
import { Trades } from './trades';
import { Positions } from './positions';
import { LocateOrders } from './locate-orders';
import { EasyBorrows } from './easy-borrows';
import { PnlSummary } from './pnl-summary';
import { PnlDetails } from './pnl-details';
import * as AccountsAPI from '@clear-street/studio-sdk/resources/accounts/accounts';
import * as BulkOrdersAPI from '@clear-street/studio-sdk/resources/accounts/bulk-orders';
import * as EasyBorrowsAPI from '@clear-street/studio-sdk/resources/accounts/easy-borrows';
Expand Down
Loading

0 comments on commit 8a3ba42

Please sign in to comment.