@stxapp/stx-typescript 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/{chunk-GLUTQFBV.js → chunk-BDKOZ6S2.js} +29 -20
- package/dist/chunk-BDKOZ6S2.js.map +1 -0
- package/dist/{chunk-VLNOUSFW.cjs → chunk-JHREXRKD.cjs} +29 -20
- package/dist/chunk-JHREXRKD.cjs.map +1 -0
- package/dist/{client-CRccD5B2.d.cts → client-jcBBoio1.d.cts} +45 -16
- package/dist/{client-CRccD5B2.d.ts → client-jcBBoio1.d.ts} +45 -16
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/oauth.cjs +17 -17
- package/dist/oauth.d.cts +2 -2
- package/dist/oauth.d.ts +2 -2
- package/dist/oauth.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-GLUTQFBV.js.map +0 -1
- package/dist/chunk-VLNOUSFW.cjs.map +0 -1
|
@@ -650,17 +650,22 @@ function isValidLine(line) {
|
|
|
650
650
|
return typeof line === "number" && Number.isFinite(line) && line > 0 && line * 2 % 2 === 1;
|
|
651
651
|
}
|
|
652
652
|
function marketEntry(m) {
|
|
653
|
-
return {
|
|
654
|
-
stat_detail: { player_id: m.playerId, stat: m.stat, prop_type: _nullishCoalesce(m.propType, () => ( "ou")), line: m.line }
|
|
655
|
-
};
|
|
653
|
+
return { rule: _nullishCoalesce(m.rule, () => ( "player_stat_line")), player_id: m.playerId, stat: m.stat, line: m.line };
|
|
656
654
|
}
|
|
657
|
-
function toCreateMarketResult(raw) {
|
|
658
|
-
const market =
|
|
659
|
-
|
|
655
|
+
function toCreateMarketResult(raw, m, index) {
|
|
656
|
+
const market = marketEntry(m);
|
|
657
|
+
switch (raw.status) {
|
|
658
|
+
case "created":
|
|
659
|
+
case "exists":
|
|
660
|
+
return { index, status: raw.status, market_id: String(raw.market_id), reason: null, market };
|
|
661
|
+
case "valid":
|
|
662
|
+
return { index, status: "valid", market_id: null, reason: null, market };
|
|
663
|
+
default:
|
|
664
|
+
return rejected(m, index, _nullishCoalesce(raw.reason, () => ( "not_created")));
|
|
665
|
+
}
|
|
660
666
|
}
|
|
661
|
-
function rejected(m, reason) {
|
|
662
|
-
|
|
663
|
-
return { status: "rejected", reason, market };
|
|
667
|
+
function rejected(m, index, reason) {
|
|
668
|
+
return { index, status: "rejected", market_id: null, reason, market: marketEntry(m) };
|
|
664
669
|
}
|
|
665
670
|
function checkMarket(m, players) {
|
|
666
671
|
if (!isValidLine(m.line)) return { reason: "invalid_line" };
|
|
@@ -981,7 +986,7 @@ function credentialsFromSettings(keyId, privateKey, signer) {
|
|
|
981
986
|
}
|
|
982
987
|
|
|
983
988
|
// src/version.ts
|
|
984
|
-
var VERSION = "0.8.
|
|
989
|
+
var VERSION = "0.8.2";
|
|
985
990
|
var USER_AGENT = `stx-typescript/${VERSION}`;
|
|
986
991
|
var ASYNC_DISPOSE = _nullishCoalesce(Symbol.asyncDispose, () => ( /* @__PURE__ */ Symbol.for("Symbol.asyncDispose")));
|
|
987
992
|
|
|
@@ -2015,14 +2020,17 @@ var STX = (_class3 = class _STX {
|
|
|
2015
2020
|
* `markets.write`, which STX grants, from the client's IP allow-list.
|
|
2016
2021
|
*
|
|
2017
2022
|
* Returns one result per market, in order: `created` or `exists` (both with
|
|
2018
|
-
* `market_id`), or `rejected` with a `reason`.
|
|
2023
|
+
* `market_id`), `valid` with `dryRun`, or `rejected` with a `reason`. Each
|
|
2024
|
+
* result's `index` is its position in `markets`, and `market` is that market
|
|
2025
|
+
* as requested. A rejected market is a
|
|
2019
2026
|
* result, not an error, and resending is safe: a market that is already
|
|
2020
2027
|
* listed comes back `exists`. A refused request throws (`403` without
|
|
2021
2028
|
* `markets.write`, `404` unknown event, `422` event not open).
|
|
2022
2029
|
*
|
|
2023
2030
|
* Each `line` must be a positive number ending in `.5`, e.g. `18.5`. More
|
|
2024
2031
|
* than `MAX_MARKETS_PER_REQUEST` markets throws `TypeError` before any
|
|
2025
|
-
* request. `
|
|
2032
|
+
* request. `dryRun` runs every check and creates nothing. `validate` also
|
|
2033
|
+
* needs the `events` scope.
|
|
2026
2034
|
*/
|
|
2027
2035
|
async createMarkets(eventId, markets, opts = {}) {
|
|
2028
2036
|
if (markets.length < 1 || markets.length > MAX_MARKETS_PER_REQUEST) {
|
|
@@ -2035,19 +2043,20 @@ var STX = (_class3 = class _STX {
|
|
|
2035
2043
|
send = send.flatMap(({ m, i }) => {
|
|
2036
2044
|
const checked = checkMarket(m, players);
|
|
2037
2045
|
if ("market" in checked) return [{ m: checked.market, i }];
|
|
2038
|
-
results[i] = rejected(m, checked.reason);
|
|
2046
|
+
results[i] = rejected(m, i, checked.reason);
|
|
2039
2047
|
return [];
|
|
2040
2048
|
});
|
|
2041
2049
|
}
|
|
2042
2050
|
if (send.length) {
|
|
2043
2051
|
const body = { event_id: eventId, markets: send.map(({ m }) => marketEntry(m)) };
|
|
2052
|
+
if (opts.dryRun) body.dry_run = true;
|
|
2044
2053
|
const raw = await this.#one("markets_post", { body });
|
|
2045
2054
|
(_nullishCoalesce(raw.markets, () => ( []))).forEach((r, k) => {
|
|
2046
|
-
const slot = send[k];
|
|
2047
|
-
if (slot) results[slot.i] = toCreateMarketResult(r);
|
|
2055
|
+
const slot = send[typeof r.index === "number" ? r.index : k];
|
|
2056
|
+
if (slot) results[slot.i] = toCreateMarketResult(r, slot.m, slot.i);
|
|
2048
2057
|
});
|
|
2049
2058
|
}
|
|
2050
|
-
return results.map((r, i) => _nullishCoalesce(r, () => ( rejected(markets[i], "not_created"))));
|
|
2059
|
+
return results.map((r, i) => _nullishCoalesce(r, () => ( rejected(markets[i], i, "not_created"))));
|
|
2051
2060
|
}
|
|
2052
2061
|
// ------------------------------------------------------------------
|
|
2053
2062
|
// Orders
|
|
@@ -2866,13 +2875,13 @@ var STXWebSocket = (_class5 = class {
|
|
|
2866
2875
|
return this.#joinAccount("user_info", {}, opts.onMessage);
|
|
2867
2876
|
}
|
|
2868
2877
|
// ------------------------------------------------------------------
|
|
2869
|
-
// Combos
|
|
2878
|
+
// Combos
|
|
2870
2879
|
// ------------------------------------------------------------------
|
|
2871
2880
|
/**
|
|
2872
2881
|
* Join `rfq:{user_id}` and return a `ComboPlayer`: request quotes on a
|
|
2873
2882
|
* combination, cash one out, accept, cancel and read a request.
|
|
2874
2883
|
*
|
|
2875
|
-
*
|
|
2884
|
+
* Available on US demo.
|
|
2876
2885
|
* Where combos are not available, rejects with
|
|
2877
2886
|
* `STXCombosUnavailableException`. Other join refusals (a read-only key, an
|
|
2878
2887
|
* account that may not trade) reject with `STXComboRefusedException`.
|
|
@@ -2892,7 +2901,7 @@ var STXWebSocket = (_class5 = class {
|
|
|
2892
2901
|
* Join `combo_quote:{user_id}` and return a `ComboMaker`: receive every
|
|
2893
2902
|
* request opened from now on (`rfq_opened`), quote and withdraw quotes.
|
|
2894
2903
|
*
|
|
2895
|
-
*
|
|
2904
|
+
* Available on US demo.
|
|
2896
2905
|
* Where combos are not available, rejects with
|
|
2897
2906
|
* `STXCombosUnavailableException`.
|
|
2898
2907
|
*/
|
|
@@ -3356,4 +3365,4 @@ function dropUndefined(payload) {
|
|
|
3356
3365
|
|
|
3357
3366
|
|
|
3358
3367
|
exports.Region = Region; exports.Environment = Environment; exports.geoRejection = geoRejection; exports.STXException = STXException; exports.STXConfigException = STXConfigException; exports.STXAPIException = STXAPIException; exports.STXValidationException = STXValidationException; exports.STXAuthenticationException = STXAuthenticationException; exports.STXForbiddenException = STXForbiddenException; exports.STXInvalidTokenException = STXInvalidTokenException; exports.STXInsufficientScopeException = STXInsufficientScopeException; exports.STXNotFoundException = STXNotFoundException; exports.STXRejectedException = STXRejectedException; exports.STXGeoLocationException = STXGeoLocationException; exports.STXRateLimitException = STXRateLimitException; exports.STXServerException = STXServerException; exports.STXTransportException = STXTransportException; exports.STXChannelException = STXChannelException; exports.STXTimeoutException = STXTimeoutException; exports.STXCombosUnavailableException = STXCombosUnavailableException; exports.STXComboRefusedException = STXComboRefusedException; exports.STXComboPriceMovedException = STXComboPriceMovedException; exports.errorForStatus = errorForStatus; exports.Environments = Environments; exports.HOSTS = HOSTS; exports.environmentNamed = environmentNamed; exports.resolveHost = resolveHost; exports.baseUrlFor = baseUrlFor; exports.socketUrlFor = socketUrlFor; exports.OPERATIONS = OPERATIONS; exports.Stats = Stats; exports.MAX_MARKETS_PER_REQUEST = MAX_MARKETS_PER_REQUEST; exports.isValidLine = isValidLine; exports.Page = Page; exports.RetryPolicy = RetryPolicy; exports.NO_RETRY = NO_RETRY; exports.resolveSettings = resolveSettings; exports.KEY_HEADER = KEY_HEADER; exports.TIMESTAMP_HEADER = TIMESTAMP_HEADER; exports.SIGNATURE_HEADER = SIGNATURE_HEADER; exports.buildMessage = buildMessage; exports.requestPath = requestPath; exports.handshakePath = handshakePath; exports.loadPrivateKey = loadPrivateKey; exports.signerFromPrivateKey = signerFromPrivateKey; exports.ApiKeyCredentials = ApiKeyCredentials; exports.VERSION = VERSION; exports.USER_AGENT = USER_AGENT; exports.TERMINAL_ORDER_STATUSES = TERMINAL_ORDER_STATUSES; exports.AccountView = AccountView; exports.ComboPlayer = ComboPlayer; exports.ComboMaker = ComboMaker; exports.centsToDollars = centsToDollars; exports.toDollarString = toDollarString; exports.toQuantity = toQuantity; exports.convertMarketPayload = convertMarketPayload; exports.convertMarketsFrame = convertMarketsFrame; exports.convertBook = convertBook; exports.convertMarketChannelPayload = convertMarketChannelPayload; exports.SNAPSHOT_EVENTS = SNAPSHOT_EVENTS; exports.ChannelMessage = ChannelMessage; exports.ReconnectPolicy = ReconnectPolicy; exports.Channel = Channel; exports.STXWebSocket = STXWebSocket; exports.orderBody = orderBody; exports.STX = STX;
|
|
3359
|
-
//# sourceMappingURL=chunk-
|
|
3368
|
+
//# sourceMappingURL=chunk-JHREXRKD.cjs.map
|