diff --git a/jest.config.js b/jest.config.js index 55beec5..306a8d4 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,10 +1,15 @@ /** @type {import('ts-jest').JestConfigWithTsJest} */ -module.exports = { +const config = { preset: 'ts-jest', - setupFiles: ["dotenv/config"], + setupFiles: ['dotenv/config'], testEnvironment: 'node', transform: { '^.+\\.ts?$': 'ts-jest', }, - transformIgnorePatterns: ['/node_modules/'] -}; \ No newline at end of file + moduleNameMapper: { + '(.+)\\.js': '$1', + }, + transformIgnorePatterns: ['/node_modules/'], +}; + +export default config; diff --git a/lib/account-streamer.ts b/lib/account-streamer.ts index d08c44d..39c7990 100644 --- a/lib/account-streamer.ts +++ b/lib/account-streamer.ts @@ -1,9 +1,9 @@ import WebSocket from 'isomorphic-ws' import _ from 'lodash' -import type { JsonMap, JsonValue } from './utils/json-util' -import { JsonBuilder } from './utils/json-util' -import TastytradeSession from './models/tastytrade-session' -import { MinTlsVersion } from './utils/constants' +import type { JsonMap, JsonValue } from './utils/json-util.js' +import { JsonBuilder } from './utils/json-util.js' +import TastytradeSession from './models/tastytrade-session.js' +import { MinTlsVersion } from './utils/constants.js' export enum STREAMER_STATE { Open = 0, diff --git a/lib/market-data-streamer.ts b/lib/market-data-streamer.ts index c191e28..537a926 100644 --- a/lib/market-data-streamer.ts +++ b/lib/market-data-streamer.ts @@ -1,7 +1,7 @@ import WebSocket from 'isomorphic-ws' import _ from 'lodash' import { v4 as uuidv4 } from 'uuid' -import { MinTlsVersion } from './utils/constants' +import { MinTlsVersion } from './utils/constants.js' export enum MarketDataSubscriptionType { Candle = 'Candle', diff --git a/lib/services/account-status-service.ts b/lib/services/account-status-service.ts index 61e8e26..18dfdbc 100644 --- a/lib/services/account-status-service.ts +++ b/lib/services/account-status-service.ts @@ -1,5 +1,5 @@ -import extractResponseData from "../utils/response-util"; -import TastytradeHttpClient from "./tastytrade-http-client"; +import extractResponseData from "../utils/response-util.js"; +import TastytradeHttpClient from "./tastytrade-http-client.js"; // create the central class that aggregates all services export default class AccountStatusService { diff --git a/lib/services/accounts-and-customers-service.ts b/lib/services/accounts-and-customers-service.ts index 940c07a..23ef86d 100644 --- a/lib/services/accounts-and-customers-service.ts +++ b/lib/services/accounts-and-customers-service.ts @@ -1,5 +1,5 @@ -import extractResponseData from "../utils/response-util"; -import TastytradeHttpClient from "./tastytrade-http-client"; +import extractResponseData from "../utils/response-util.js"; +import TastytradeHttpClient from "./tastytrade-http-client.js"; export default class AccountsAndCustomersService { constructor(private httpClient: TastytradeHttpClient) { diff --git a/lib/services/balances-and-positions-service.ts b/lib/services/balances-and-positions-service.ts index 2827a67..55f4cd9 100644 --- a/lib/services/balances-and-positions-service.ts +++ b/lib/services/balances-and-positions-service.ts @@ -1,5 +1,5 @@ -import extractResponseData from "../utils/response-util"; -import TastytradeHttpClient from "./tastytrade-http-client"; +import extractResponseData from "../utils/response-util.js"; +import TastytradeHttpClient from "./tastytrade-http-client.js"; export default class BalancesAndPositionsService { constructor(private httpClient: TastytradeHttpClient) { diff --git a/lib/services/instruments-service.ts b/lib/services/instruments-service.ts index 1cb8b61..128c8d1 100644 --- a/lib/services/instruments-service.ts +++ b/lib/services/instruments-service.ts @@ -1,5 +1,5 @@ -import extractResponseData from "../utils/response-util"; -import TastytradeHttpClient from "./tastytrade-http-client"; +import extractResponseData from "../utils/response-util.js"; +import TastytradeHttpClient from "./tastytrade-http-client.js"; import _ from 'lodash' export default class InstrumentsService { diff --git a/lib/services/margin-requirements-service.ts b/lib/services/margin-requirements-service.ts index 1bfcb91..cf23ca2 100644 --- a/lib/services/margin-requirements-service.ts +++ b/lib/services/margin-requirements-service.ts @@ -1,5 +1,5 @@ -import extractResponseData from "../utils/response-util"; -import TastytradeHttpClient from "./tastytrade-http-client"; +import extractResponseData from "../utils/response-util.js"; +import TastytradeHttpClient from "./tastytrade-http-client.js"; export default class MarginRequirementsService { constructor(private httpClient: TastytradeHttpClient) { diff --git a/lib/services/market-metrics-service.ts b/lib/services/market-metrics-service.ts index 8c2839a..da05b98 100644 --- a/lib/services/market-metrics-service.ts +++ b/lib/services/market-metrics-service.ts @@ -1,5 +1,5 @@ -import extractResponseData from "../utils/response-util"; -import TastytradeHttpClient from "./tastytrade-http-client"; +import extractResponseData from "../utils/response-util.js"; +import TastytradeHttpClient from "./tastytrade-http-client.js"; export default class MarketMetricsService { constructor(private httpClient: TastytradeHttpClient) { diff --git a/lib/services/net-liquidating-value-history-service.ts b/lib/services/net-liquidating-value-history-service.ts index c1e8973..a12b852 100644 --- a/lib/services/net-liquidating-value-history-service.ts +++ b/lib/services/net-liquidating-value-history-service.ts @@ -1,5 +1,5 @@ -import extractResponseData from "../utils/response-util"; -import TastytradeHttpClient from "./tastytrade-http-client"; +import extractResponseData from "../utils/response-util.js"; +import TastytradeHttpClient from "./tastytrade-http-client.js"; export default class NetLiquidatingValueHistoryService { constructor(private httpClient: TastytradeHttpClient) { diff --git a/lib/services/orders-service.ts b/lib/services/orders-service.ts index ad3f109..136f2e3 100644 --- a/lib/services/orders-service.ts +++ b/lib/services/orders-service.ts @@ -1,5 +1,5 @@ -import extractResponseData from "../utils/response-util"; -import TastytradeHttpClient from "./tastytrade-http-client"; +import extractResponseData from "../utils/response-util.js"; +import TastytradeHttpClient from "./tastytrade-http-client.js"; export default class OrderService { constructor(private httpClient: TastytradeHttpClient) { diff --git a/lib/services/risk-parameters-service.ts b/lib/services/risk-parameters-service.ts index 0d1b08d..6e0f21c 100644 --- a/lib/services/risk-parameters-service.ts +++ b/lib/services/risk-parameters-service.ts @@ -1,5 +1,5 @@ -import extractResponseData from "../utils/response-util"; -import TastytradeHttpClient from "./tastytrade-http-client"; +import extractResponseData from "../utils/response-util.js"; +import TastytradeHttpClient from "./tastytrade-http-client.js"; export default class RiskParametersService { constructor(private httpClient: TastytradeHttpClient) { diff --git a/lib/services/session-service.ts b/lib/services/session-service.ts index 354f5c3..7c8a64f 100644 --- a/lib/services/session-service.ts +++ b/lib/services/session-service.ts @@ -1,5 +1,5 @@ -import extractResponseData from "../utils/response-util"; -import TastytradeHttpClient from "./tastytrade-http-client"; +import extractResponseData from "../utils/response-util.js"; +import TastytradeHttpClient from "./tastytrade-http-client.js"; export default class SessionService { constructor(public httpClient: TastytradeHttpClient) { diff --git a/lib/services/symbol-search-service.ts b/lib/services/symbol-search-service.ts index 92ee766..6240d4e 100644 --- a/lib/services/symbol-search-service.ts +++ b/lib/services/symbol-search-service.ts @@ -1,5 +1,5 @@ -import extractResponseData from "../utils/response-util"; -import TastytradeHttpClient from "./tastytrade-http-client"; +import extractResponseData from "../utils/response-util.js"; +import TastytradeHttpClient from "./tastytrade-http-client.js"; export default class SymbolSearchService { constructor(private httpClient: TastytradeHttpClient) { diff --git a/lib/services/tastytrade-http-client.ts b/lib/services/tastytrade-http-client.ts index 1a4bc34..7f92940 100644 --- a/lib/services/tastytrade-http-client.ts +++ b/lib/services/tastytrade-http-client.ts @@ -1,7 +1,7 @@ -import TastytradeSession from "../models/tastytrade-session" +import TastytradeSession from "../models/tastytrade-session.js" import axios from "axios" import qs from 'qs' -import { recursiveDasherizeKeys } from "../utils/json-util" +import { recursiveDasherizeKeys } from "../utils/json-util.js" import _ from 'lodash' const ParamsSerializer = { diff --git a/lib/services/transactions-service.ts b/lib/services/transactions-service.ts index e3bcd4b..8a8d20f 100644 --- a/lib/services/transactions-service.ts +++ b/lib/services/transactions-service.ts @@ -1,5 +1,5 @@ -import extractResponseData from "../utils/response-util"; -import TastytradeHttpClient from "./tastytrade-http-client"; +import extractResponseData from "../utils/response-util.js"; +import TastytradeHttpClient from "./tastytrade-http-client.js"; export default class TransactionsService { constructor(private httpClient: TastytradeHttpClient) { diff --git a/lib/services/watchlists-service.ts b/lib/services/watchlists-service.ts index 79a3352..85d3be2 100644 --- a/lib/services/watchlists-service.ts +++ b/lib/services/watchlists-service.ts @@ -1,5 +1,5 @@ -import extractResponseData from "../utils/response-util"; -import TastytradeHttpClient from "./tastytrade-http-client"; +import extractResponseData from "../utils/response-util.js"; +import TastytradeHttpClient from "./tastytrade-http-client.js"; export default class WatchlistsService { constructor(private httpClient: TastytradeHttpClient) { diff --git a/lib/tastytrade-api.ts b/lib/tastytrade-api.ts index 5867465..5bb1704 100644 --- a/lib/tastytrade-api.ts +++ b/lib/tastytrade-api.ts @@ -1,22 +1,22 @@ -import TastytradeHttpClient from "./services/tastytrade-http-client" -import { AccountStreamer, STREAMER_STATE, Disposer, StreamerStateObserver } from './account-streamer' -import MarketDataStreamer, { CandleSubscriptionOptions, CandleType, MarketDataSubscriptionType, MarketDataListener } from "./market-data-streamer" +import TastytradeHttpClient from "./services/tastytrade-http-client.js" +import { AccountStreamer, STREAMER_STATE, Disposer, StreamerStateObserver } from './account-streamer.js' +import MarketDataStreamer, { CandleSubscriptionOptions, CandleType, MarketDataSubscriptionType, MarketDataListener } from "./market-data-streamer.js" //Services: -import SessionService from "./services/session-service" -import AccountStatusService from "./services/account-status-service" -import AccountsAndCustomersService from "./services/accounts-and-customers-service" -import BalancesAndPositionsService from "./services/balances-and-positions-service" -import InstrumentsService from "./services/instruments-service" -import MarginRequirementsService from "./services/margin-requirements-service" -import MarketMetricsService from "./services/market-metrics-service" -import NetLiquidatingValueHistoryService from "./services/net-liquidating-value-history-service" -import OrderService from "./services/orders-service" -import RiskParametersService from "./services/risk-parameters-service" -import SymbolSearchService from "./services/symbol-search-service" -import TransactionsService from "./services/transactions-service" -import WatchlistsService from "./services/watchlists-service" -import TastytradeSession from "./models/tastytrade-session" +import SessionService from "./services/session-service.js" +import AccountStatusService from "./services/account-status-service.js" +import AccountsAndCustomersService from "./services/accounts-and-customers-service.js" +import BalancesAndPositionsService from "./services/balances-and-positions-service.js" +import InstrumentsService from "./services/instruments-service.js" +import MarginRequirementsService from "./services/margin-requirements-service.js" +import MarketMetricsService from "./services/market-metrics-service.js" +import NetLiquidatingValueHistoryService from "./services/net-liquidating-value-history-service.js" +import OrderService from "./services/orders-service.js" +import RiskParametersService from "./services/risk-parameters-service.js" +import SymbolSearchService from "./services/symbol-search-service.js" +import TransactionsService from "./services/transactions-service.js" +import WatchlistsService from "./services/watchlists-service.js" +import TastytradeSession from "./models/tastytrade-session.js" export default class TastytradeClient { public readonly httpClient: TastytradeHttpClient diff --git a/package.json b/package.json index 63cf0a0..aacd63e 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,13 @@ { "name": "@tastytrade/api", "version": "3.1.0", - "main": "dist/tastytrade-api.js", - "typings": "dist/tastytrade-api.d.ts", + "type": "module", + "module": "dist/tastytrade-api.js", + "types": "dist/tastytrade-api.d.ts", + "exports": { + "types": "./dist/tastytrade-api.d.ts", + "default": "./dist/tastytrade-api.js" + }, "repository": "https://github.com/tastytrade/tastytrade-api-js", "license": "MIT", "description": "Typescript impelementation of tastytrade api",