Skip to content

Commit

Permalink
Merge pull request #57 from clear-street/release-please--branches--ma…
Browse files Browse the repository at this point in the history
…in--changes--next--components--studio-sdk

release: 0.1.0-alpha.13
  • Loading branch information
sonicxml authored Nov 29, 2024
2 parents c9fc3d7 + bfa57c0 commit 95bad5e
Show file tree
Hide file tree
Showing 33 changed files with 326 additions and 245 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ yarn-error.log
codegen.log
Brewfile.lock.json
dist
/deno
dist-deno
/*.tgz
.idea/

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.12"
".": "0.1.0-alpha.13"
}
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

## 0.1.0-alpha.13 (2024-11-28)

Full Changelog: [v0.1.0-alpha.12...v0.1.0-alpha.13](https://github.com/clear-street/studio-sdk-node/compare/v0.1.0-alpha.12...v0.1.0-alpha.13)

### Features

* **internal:** make git install file structure match npm ([#65](https://github.com/clear-street/studio-sdk-node/issues/65)) ([0a97e8d](https://github.com/clear-street/studio-sdk-node/commit/0a97e8dac6a65c9354d80fd3da7d4ba0add30ad3))


### Chores

* **internal:** version bump ([#56](https://github.com/clear-street/studio-sdk-node/issues/56)) ([edbfb81](https://github.com/clear-street/studio-sdk-node/commit/edbfb81a999c641559f5509af03c904223d26340))
* rebuild project due to codegen change ([#58](https://github.com/clear-street/studio-sdk-node/issues/58)) ([9de16eb](https://github.com/clear-street/studio-sdk-node/commit/9de16eb6782a634457f9d1c301764637f5296e52))
* rebuild project due to codegen change ([#59](https://github.com/clear-street/studio-sdk-node/issues/59)) ([d4c4b6b](https://github.com/clear-street/studio-sdk-node/commit/d4c4b6bc92160bbe6d011723502688ccb4a93a76))
* rebuild project due to codegen change ([#60](https://github.com/clear-street/studio-sdk-node/issues/60)) ([3e9fb2b](https://github.com/clear-street/studio-sdk-node/commit/3e9fb2bc4de1b0ca2506ce46b010fba1b70492ab))
* rebuild project due to codegen change ([#61](https://github.com/clear-street/studio-sdk-node/issues/61)) ([677ee27](https://github.com/clear-street/studio-sdk-node/commit/677ee2768857d7f3e1a6312d4b6adaaccb84bb7b))
* rebuild project due to codegen change ([#62](https://github.com/clear-street/studio-sdk-node/issues/62)) ([bfe87b7](https://github.com/clear-street/studio-sdk-node/commit/bfe87b739732e335dbb66c77d5a5ca17ded60d4a))
* remove redundant word in comment ([#64](https://github.com/clear-street/studio-sdk-node/issues/64)) ([cc8bab8](https://github.com/clear-street/studio-sdk-node/commit/cc8bab80186d5f5a0c1ffcac082c62f18c5dc231))


### Documentation

* remove suggestion to use `npm` call out ([#63](https://github.com/clear-street/studio-sdk-node/issues/63)) ([face38a](https://github.com/clear-street/studio-sdk-node/commit/face38a396911e3f80722c99ceb49254e1a6149c))

## 0.1.0-alpha.12 (2024-11-01)

Full Changelog: [v0.1.0-alpha.10...v0.1.0-alpha.12](https://github.com/clear-street/studio-sdk-node/compare/v0.1.0-alpha.10...v0.1.0-alpha.12)
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,15 @@ TypeScript >= 4.5 is supported.

The following runtimes are supported:

- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
- Deno v1.28.0 or higher.
- Bun 1.0 or later.
- Cloudflare Workers.
- Vercel Edge Runtime.
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
- Nitro v2.6 or greater.

Note that React Native is not supported at this time.

If you are interested in other runtime environments, please open or upvote an issue on GitHub.
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@clear-street/studio-sdk",
"version": "0.1.0-alpha.12",
"version": "0.1.0-alpha.13",
"description": "The official TypeScript library for the Studio SDK API",
"author": "Studio SDK <[email protected]>",
"types": "dist/index.d.ts",
Expand All @@ -10,15 +10,15 @@
"license": "Apache-2.0",
"packageManager": "[email protected]",
"files": [
"*"
"**/*"
],
"private": false,
"scripts": {
"test": "./scripts/test",
"build": "./scripts/build",
"prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1",
"format": "prettier --write --cache --cache-strategy metadata . !dist",
"prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build; fi",
"prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build && ./scripts/utils/git-swap.sh; fi",
"tsn": "ts-node -r tsconfig-paths/register",
"lint": "./scripts/lint",
"fix": "./scripts/format"
Expand All @@ -45,7 +45,6 @@
"jest": "^29.4.0",
"prettier": "^3.0.0",
"ts-jest": "^29.1.0",
"ts-morph": "^19.0.0",
"ts-node": "^10.5.0",
"tsc-multi": "^1.1.0",
"tsconfig-paths": "^4.0.0",
Expand Down
4 changes: 2 additions & 2 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ npm exec tsc-multi
# copy over handwritten .js/.mjs/.d.ts files
cp src/_shims/*.{d.ts,js,mjs,md} dist/_shims
cp src/_shims/auto/*.{d.ts,js,mjs} dist/_shims/auto
# we need to add exports = module.exports = Studio SDK Node to index.js;
# we need to add exports = module.exports = StudioSDK to index.js;
# No way to get that from index.ts because it would cause compile errors
# when building .mjs
node scripts/utils/fix-index-exports.cjs
Expand All @@ -50,7 +50,7 @@ node scripts/utils/postprocess-files.cjs
(cd dist && node -e 'require("@clear-street/studio-sdk")')
(cd dist && node -e 'import("@clear-street/studio-sdk")' --input-type=module)

if command -v deno &> /dev/null && [ -e ./scripts/build-deno ]
if [ -e ./scripts/build-deno ]
then
./scripts/build-deno
fi
2 changes: 1 addition & 1 deletion scripts/utils/check-is-in-git-install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Check if you happen to call prepare for a repository that's already in node_modules.
[ "$(basename "$(dirname "$PWD")")" = 'node_modules' ] ||
# The name of the containing directory that 'npm` uses, which looks like
Expand Down
13 changes: 13 additions & 0 deletions scripts/utils/git-swap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -exuo pipefail
# the package is published to NPM from ./dist
# we want the final file structure for git installs to match the npm installs, so we

# delete everything except ./dist and ./node_modules
find . -maxdepth 1 -mindepth 1 ! -name 'dist' ! -name 'node_modules' -exec rm -rf '{}' +

# move everything from ./dist to .
mv dist/* .

# delete the now-empty ./dist
rmdir dist
10 changes: 5 additions & 5 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export abstract class APIClient {
error: Object | undefined,
message: string | undefined,
headers: Headers | undefined,
) {
): APIError {
return APIError.generate(status, error, message, headers);
}

Expand Down Expand Up @@ -668,17 +668,17 @@ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
return await this.#client.requestAPIList(this.constructor as any, nextOptions);
}

async *iterPages() {
async *iterPages(): AsyncGenerator<this> {
// eslint-disable-next-line @typescript-eslint/no-this-alias
let page: AbstractPage<Item> = this;
let page: this = this;
yield page;
while (page.hasNextPage()) {
page = await page.getNextPage();
yield page;
}
}

async *[Symbol.asyncIterator]() {
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
for await (const page of this.iterPages()) {
for (const item of page.getPaginatedItems()) {
yield item;
Expand Down Expand Up @@ -721,7 +721,7 @@ export class PagePromise<
* console.log(item)
* }
*/
async *[Symbol.asyncIterator]() {
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
const page = await this;
for await (const item of page) {
yield item;
Expand Down
2 changes: 1 addition & 1 deletion src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class APIError extends StudioSDKError {
errorResponse: Object | undefined,
message: string | undefined,
headers: Headers | undefined,
) {
): APIError {
if (!status) {
return new APIConnectionError({ message, cause: castToError(errorResponse) });
}
Expand Down
82 changes: 47 additions & 35 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Errors from './error';
import * as Uploads from './uploads';
import { type Agent } from './_shims/index';
import * as Core from './core';
import * as Errors from './error';
import * as Uploads from './uploads';
import * as API from './resources/index';
import { Instrument, InstrumentRetrieveParams, Instruments } from './resources/instruments';
import { Account, AccountListResponse, Accounts } from './resources/accounts/accounts';
import {
Entities,
Entity,
EntityListResponse,
PnlSummary,
PortfolioMargin,
RegtMargin,
} from './resources/entities/entities';

const environments = {
production: 'https://api.clearstreet.io/studio/v2',
sandbox: 'https://sandbox-api.clearstreet.io/studio/v2',
};
type Environment = keyof typeof environments;

export interface ClientOptions {
/**
* Defaults to process.env['STUDIO_SDK_BEARER_TOKEN'].
Expand Down Expand Up @@ -182,7 +191,40 @@ export class StudioSDK extends Core.APIClient {
static fileFromPath = Uploads.fileFromPath;
}

export const {
StudioSDK.Entities = Entities;
StudioSDK.Accounts = Accounts;
StudioSDK.Instruments = Instruments;
export declare namespace StudioSDK {
export type RequestOptions = Core.RequestOptions;

export {
Entities as Entities,
type Entity as Entity,
type PnlSummary as PnlSummary,
type PortfolioMargin as PortfolioMargin,
type RegtMargin as RegtMargin,
type EntityListResponse as EntityListResponse,
};

export { Accounts as Accounts, type Account as Account, type AccountListResponse as AccountListResponse };

export {
Instruments as Instruments,
type Instrument as Instrument,
type InstrumentRetrieveParams as InstrumentRetrieveParams,
};

export type BaseStrategy = API.BaseStrategy;
export type LocateOrder = API.LocateOrder;
export type Order = API.Order;
export type Position = API.Position;
export type RegtMarginSimulation = API.RegtMarginSimulation;
export type Strategy = API.Strategy;
export type Trade = API.Trade;
}

export { toFile, fileFromPath } from './uploads';
export {
StudioSDKError,
APIError,
APIConnectionError,
Expand All @@ -196,36 +238,6 @@ export const {
InternalServerError,
PermissionDeniedError,
UnprocessableEntityError,
} = Errors;

export import toFile = Uploads.toFile;
export import fileFromPath = Uploads.fileFromPath;

export namespace StudioSDK {
export import RequestOptions = Core.RequestOptions;

export import Entities = API.Entities;
export import Entity = API.Entity;
export import PnlSummary = API.PnlSummary;
export import PortfolioMargin = API.PortfolioMargin;
export import RegtMargin = API.RegtMargin;
export import EntityListResponse = API.EntityListResponse;

export import Accounts = API.Accounts;
export import Account = API.Account;
export import AccountListResponse = API.AccountListResponse;

export import Instruments = API.Instruments;
export import Instrument = API.Instrument;
export import InstrumentRetrieveParams = API.InstrumentRetrieveParams;

export import BaseStrategy = API.BaseStrategy;
export import LocateOrder = API.LocateOrder;
export import Order = API.Order;
export import Position = API.Position;
export import RegtMarginSimulation = API.RegtMarginSimulation;
export import Strategy = API.Strategy;
export import Trade = API.Trade;
}
} from './error';

export default StudioSDK;
Loading

0 comments on commit 95bad5e

Please sign in to comment.