@alva-ai/toolkit 0.26.0 → 0.28.0-beta.0
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/README.md +36 -1
- package/dist/browser.global.js +41 -14
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +124 -2
- package/dist/cli.js +581 -26
- package/dist/cli.js.map +1 -1
- package/dist/dispatch.d.ts +124 -2
- package/dist/dispatch.js +376 -15
- package/dist/dispatch.js.map +1 -1
- package/dist/index.cjs +337 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +125 -3
- package/dist/index.d.ts +125 -3
- package/dist/index.js +335 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6626,6 +6626,134 @@ function requireFeedID(id) {
|
|
|
6626
6626
|
return id;
|
|
6627
6627
|
}
|
|
6628
6628
|
|
|
6629
|
+
// src/resources/forYou.ts
|
|
6630
|
+
var FOR_YOU_QUERY = `
|
|
6631
|
+
query ToolkitForYou($input: FeedEntryConnectionInput) {
|
|
6632
|
+
viewer {
|
|
6633
|
+
forYou(input: $input) {
|
|
6634
|
+
edges {
|
|
6635
|
+
cursor
|
|
6636
|
+
node {
|
|
6637
|
+
id
|
|
6638
|
+
feed { id }
|
|
6639
|
+
major { id feedId number }
|
|
6640
|
+
displayName source eventTimeMs publishedAtMs title body
|
|
6641
|
+
actions { type label url prompt }
|
|
6642
|
+
presentation {
|
|
6643
|
+
card {
|
|
6644
|
+
accentColor url thumbnailUrl footer
|
|
6645
|
+
fields { label value inline }
|
|
6646
|
+
}
|
|
6647
|
+
}
|
|
6648
|
+
tickers { symbol logoUrl sentiment }
|
|
6649
|
+
media { type coverUrl url }
|
|
6650
|
+
sources { type url iconUrl title subtitle description publishedAtMs }
|
|
6651
|
+
}
|
|
6652
|
+
}
|
|
6653
|
+
pageInfo { startCursor endCursor hasNextPage hasPreviousPage }
|
|
6654
|
+
}
|
|
6655
|
+
}
|
|
6656
|
+
}
|
|
6657
|
+
`.trim();
|
|
6658
|
+
function record(value) {
|
|
6659
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6660
|
+
}
|
|
6661
|
+
function validateForYouListParams(params) {
|
|
6662
|
+
if (!record(params)) throw new Error("For You parameters must be an object");
|
|
6663
|
+
const first = params.first === void 0 ? 20 : params.first;
|
|
6664
|
+
if (typeof first !== "number" || !Number.isInteger(first) || first < 1 || first > 50) {
|
|
6665
|
+
throw new Error("first must be an integer between 1 and 50");
|
|
6666
|
+
}
|
|
6667
|
+
for (const field of ["after", "newerThan"]) {
|
|
6668
|
+
const value = params[field];
|
|
6669
|
+
if (value !== void 0 && (typeof value !== "string" || !value.trim())) {
|
|
6670
|
+
throw new Error(`${field} must be a non-empty cursor`);
|
|
6671
|
+
}
|
|
6672
|
+
}
|
|
6673
|
+
if (params.feedId !== void 0 && !isPositiveInt64(params.feedId)) {
|
|
6674
|
+
throw new Error("feedId must be a positive decimal int64 string");
|
|
6675
|
+
}
|
|
6676
|
+
}
|
|
6677
|
+
function isPositiveInt64(value) {
|
|
6678
|
+
return typeof value === "string" && /^[1-9]\d{0,18}$/.test(value) && BigInt(value) <= 9223372036854775807n;
|
|
6679
|
+
}
|
|
6680
|
+
function invalidResponse() {
|
|
6681
|
+
throw new AlvaError(
|
|
6682
|
+
"GRAPHQL_INVALID_RESPONSE",
|
|
6683
|
+
"GraphQL returned an invalid For You connection",
|
|
6684
|
+
502
|
|
6685
|
+
);
|
|
6686
|
+
}
|
|
6687
|
+
function connection(value) {
|
|
6688
|
+
if (!record(value) || !Array.isArray(value.edges) || !record(value.pageInfo)) {
|
|
6689
|
+
return invalidResponse();
|
|
6690
|
+
}
|
|
6691
|
+
const page = value.pageInfo;
|
|
6692
|
+
if (typeof page.startCursor !== "string" || typeof page.endCursor !== "string" || typeof page.hasNextPage !== "boolean" || typeof page.hasPreviousPage !== "boolean") {
|
|
6693
|
+
return invalidResponse();
|
|
6694
|
+
}
|
|
6695
|
+
for (const edge of value.edges) {
|
|
6696
|
+
if (!record(edge) || typeof edge.cursor !== "string" || !edge.cursor.trim() || !record(edge.node))
|
|
6697
|
+
return invalidResponse();
|
|
6698
|
+
const node = edge.node;
|
|
6699
|
+
if (typeof node.id !== "string" || !node.id.startsWith("FeedEntry:") || !isPositiveInt64(node.id.slice("FeedEntry:".length)) || !record(node.feed) || !isPositiveInt64(node.feed.id) || !record(node.major) || typeof node.major.id !== "string" || !isPositiveInt64(node.major.feedId) || typeof node.title !== "string" || typeof node.body !== "string") {
|
|
6700
|
+
return invalidResponse();
|
|
6701
|
+
}
|
|
6702
|
+
}
|
|
6703
|
+
const first = value.edges[0];
|
|
6704
|
+
const last = value.edges[value.edges.length - 1];
|
|
6705
|
+
if (page.startCursor !== (first?.cursor ?? "") || page.endCursor !== (last?.cursor ?? "") || value.edges.length === 0 && page.hasNextPage)
|
|
6706
|
+
return invalidResponse();
|
|
6707
|
+
return value;
|
|
6708
|
+
}
|
|
6709
|
+
var ForYouResource = class {
|
|
6710
|
+
constructor(client) {
|
|
6711
|
+
this.client = client;
|
|
6712
|
+
}
|
|
6713
|
+
client;
|
|
6714
|
+
/** One newest-first page. Does not truncate content or advance a watermark. */
|
|
6715
|
+
async list(params = {}) {
|
|
6716
|
+
validateForYouListParams(params);
|
|
6717
|
+
this.client._requireAuth();
|
|
6718
|
+
const response = await this.client._request("POST", "/query", {
|
|
6719
|
+
body: {
|
|
6720
|
+
query: FOR_YOU_QUERY,
|
|
6721
|
+
variables: {
|
|
6722
|
+
input: {
|
|
6723
|
+
first: params.first ?? 20,
|
|
6724
|
+
after: params.after,
|
|
6725
|
+
newerThan: params.newerThan,
|
|
6726
|
+
feedId: params.feedId
|
|
6727
|
+
}
|
|
6728
|
+
}
|
|
6729
|
+
}
|
|
6730
|
+
});
|
|
6731
|
+
if (!record(response)) return invalidResponse();
|
|
6732
|
+
if (response.errors !== void 0) {
|
|
6733
|
+
if (!Array.isArray(response.errors)) return invalidResponse();
|
|
6734
|
+
if (response.errors.length > 0) {
|
|
6735
|
+
const messages = response.errors.flatMap(
|
|
6736
|
+
(error) => record(error) && typeof error.message === "string" ? [error.message] : []
|
|
6737
|
+
);
|
|
6738
|
+
throw new AlvaError(
|
|
6739
|
+
"GRAPHQL_ERROR",
|
|
6740
|
+
messages.join("; ") || "GraphQL request failed",
|
|
6741
|
+
400,
|
|
6742
|
+
{ errors: response.errors }
|
|
6743
|
+
);
|
|
6744
|
+
}
|
|
6745
|
+
}
|
|
6746
|
+
if (!record(response.data) || !record(response.data.viewer) || response.data.viewer.forYou == null) {
|
|
6747
|
+
throw new AlvaError(
|
|
6748
|
+
"GRAPHQL_EMPTY_RESPONSE",
|
|
6749
|
+
"GraphQL response did not include viewer.forYou",
|
|
6750
|
+
502
|
|
6751
|
+
);
|
|
6752
|
+
}
|
|
6753
|
+
return connection(response.data.viewer.forYou);
|
|
6754
|
+
}
|
|
6755
|
+
};
|
|
6756
|
+
|
|
6629
6757
|
// src/resources/automation.ts
|
|
6630
6758
|
var AUTOMATION_ALERT_DELIVERY_QUERY = `
|
|
6631
6759
|
query ToolkitAutomationAlertDelivery($automationId: ID!) {
|
|
@@ -8179,8 +8307,8 @@ var NotificationsResource = class {
|
|
|
8179
8307
|
client;
|
|
8180
8308
|
/**
|
|
8181
8309
|
* List the caller's notification history for one feed
|
|
8182
|
-
* `(username, name)`. Authorization
|
|
8183
|
-
*
|
|
8310
|
+
* `(username, name)`. Authorization uses the backend's canonical Feed read
|
|
8311
|
+
* decision (owner, public, bundled paid access, Plan, or Access Group).
|
|
8184
8312
|
*/
|
|
8185
8313
|
async listFeed(params) {
|
|
8186
8314
|
this.client._requireAuth();
|
|
@@ -9139,14 +9267,14 @@ var SchedulesResource = class {
|
|
|
9139
9267
|
LIST_SCHEDULES,
|
|
9140
9268
|
{ channelId: id, after }
|
|
9141
9269
|
);
|
|
9142
|
-
const
|
|
9143
|
-
if (!
|
|
9144
|
-
for (const edge of
|
|
9270
|
+
const connection2 = data.viewer?.channel?.schedules;
|
|
9271
|
+
if (!connection2?.edges) throw scheduleNotFound();
|
|
9272
|
+
for (const edge of connection2.edges) {
|
|
9145
9273
|
if (!edge?.node) throw scheduleEmptyResponse();
|
|
9146
9274
|
schedules.push(fromWireSchedule(edge.node));
|
|
9147
9275
|
}
|
|
9148
|
-
if (
|
|
9149
|
-
const next =
|
|
9276
|
+
if (connection2.pageInfo?.hasNextPage !== true) return schedules;
|
|
9277
|
+
const next = connection2.pageInfo.endCursor;
|
|
9150
9278
|
if (!next || seenCursors.has(next)) throw scheduleEmptyResponse();
|
|
9151
9279
|
seenCursors.add(next);
|
|
9152
9280
|
after = next;
|
|
@@ -9442,14 +9570,199 @@ function scheduleEmptyResponse() {
|
|
|
9442
9570
|
);
|
|
9443
9571
|
}
|
|
9444
9572
|
|
|
9573
|
+
// src/resources/tradingPairs.ts
|
|
9574
|
+
function isRecord(value) {
|
|
9575
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9576
|
+
}
|
|
9577
|
+
function stringValue(value) {
|
|
9578
|
+
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
9579
|
+
}
|
|
9580
|
+
function numberValue(value) {
|
|
9581
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
9582
|
+
}
|
|
9583
|
+
function upper(value) {
|
|
9584
|
+
return value === void 0 ? void 0 : value.trim().toUpperCase();
|
|
9585
|
+
}
|
|
9586
|
+
function pairParts(pair) {
|
|
9587
|
+
return pair.split("_");
|
|
9588
|
+
}
|
|
9589
|
+
function inferInstrumentType(rawType, tradingPair) {
|
|
9590
|
+
const type = rawType?.toLowerCase();
|
|
9591
|
+
if (type?.includes("spot")) return "spot";
|
|
9592
|
+
if (type?.includes("perp")) return "perp";
|
|
9593
|
+
if (type?.includes("option")) return "option";
|
|
9594
|
+
return pairParts(tradingPair)[1]?.toLowerCase() ?? "";
|
|
9595
|
+
}
|
|
9596
|
+
function inferUnderlyingType(rawType) {
|
|
9597
|
+
if (rawType === void 0) return void 0;
|
|
9598
|
+
const prefix = rawType.split("-")[0]?.trim().toLowerCase();
|
|
9599
|
+
return prefix && prefix !== rawType.toLowerCase() ? prefix : void 0;
|
|
9600
|
+
}
|
|
9601
|
+
function normalizeCandidate(raw, outerSymbol) {
|
|
9602
|
+
const tradingPair = stringValue(raw.trading_pair) ?? stringValue(raw.tradingPair) ?? stringValue(raw.symbol);
|
|
9603
|
+
if (tradingPair === void 0) return void 0;
|
|
9604
|
+
const type = stringValue(raw.type);
|
|
9605
|
+
const parts = pairParts(tradingPair);
|
|
9606
|
+
const symbol = stringValue(raw.base) ?? outerSymbol ?? (parts.length >= 4 ? parts.slice(2, -1).join("_") : parts.length === 3 ? parts[2] : tradingPair);
|
|
9607
|
+
const market = stringValue(raw.market) ?? stringValue(raw.exchange) ?? parts[0] ?? "";
|
|
9608
|
+
const quote = stringValue(raw.quote) ?? parts[parts.length - 1] ?? "";
|
|
9609
|
+
const instrumentType = stringValue(raw.instrument_type) ?? stringValue(raw.instrumentType) ?? inferInstrumentType(type, tradingPair);
|
|
9610
|
+
const underlyingType = stringValue(raw.underlying_type) ?? stringValue(raw.underlyingType) ?? inferUnderlyingType(type);
|
|
9611
|
+
return {
|
|
9612
|
+
symbol,
|
|
9613
|
+
tradingPair,
|
|
9614
|
+
market,
|
|
9615
|
+
instrumentType,
|
|
9616
|
+
...underlyingType === void 0 ? {} : { underlyingType },
|
|
9617
|
+
quote,
|
|
9618
|
+
...type === void 0 ? {} : { type },
|
|
9619
|
+
...stringValue(raw.description) === void 0 ? {} : { description: stringValue(raw.description) },
|
|
9620
|
+
...numberValue(raw.fee_rate) === void 0 ? numberValue(raw.feeRate) === void 0 ? {} : { feeRate: numberValue(raw.feeRate) } : { feeRate: numberValue(raw.fee_rate) },
|
|
9621
|
+
...stringValue(raw.symbol_icon_url) === void 0 ? stringValue(raw.symbolIconUrl) === void 0 ? {} : { symbolIconUrl: stringValue(raw.symbolIconUrl) } : { symbolIconUrl: stringValue(raw.symbol_icon_url) }
|
|
9622
|
+
};
|
|
9623
|
+
}
|
|
9624
|
+
function flattenResponse(value) {
|
|
9625
|
+
if (!isRecord(value)) return [];
|
|
9626
|
+
const flat = value.trading_pairs;
|
|
9627
|
+
if (Array.isArray(flat)) {
|
|
9628
|
+
return flat.flatMap(
|
|
9629
|
+
(item) => isRecord(item) ? [normalizeCandidate(item)].filter(
|
|
9630
|
+
(candidate) => candidate !== void 0
|
|
9631
|
+
) : []
|
|
9632
|
+
);
|
|
9633
|
+
}
|
|
9634
|
+
const data = value.data;
|
|
9635
|
+
if (!Array.isArray(data)) return [];
|
|
9636
|
+
const candidates = [];
|
|
9637
|
+
for (const symbolGroup of data) {
|
|
9638
|
+
if (!isRecord(symbolGroup)) continue;
|
|
9639
|
+
const symbol = stringValue(symbolGroup.symbol);
|
|
9640
|
+
const groups = symbolGroup.trading_pairs;
|
|
9641
|
+
if (!Array.isArray(groups)) continue;
|
|
9642
|
+
for (const group of groups) {
|
|
9643
|
+
if (!isRecord(group) || !Array.isArray(group.pairs)) continue;
|
|
9644
|
+
for (const pair of group.pairs) {
|
|
9645
|
+
if (!isRecord(pair)) continue;
|
|
9646
|
+
const candidate = normalizeCandidate(
|
|
9647
|
+
{
|
|
9648
|
+
...pair,
|
|
9649
|
+
instrument_type: pair.instrument_type ?? group.instrument_type
|
|
9650
|
+
},
|
|
9651
|
+
symbol
|
|
9652
|
+
);
|
|
9653
|
+
if (candidate !== void 0) candidates.push(candidate);
|
|
9654
|
+
}
|
|
9655
|
+
}
|
|
9656
|
+
}
|
|
9657
|
+
return candidates;
|
|
9658
|
+
}
|
|
9659
|
+
function matchesQuery(candidate, query) {
|
|
9660
|
+
const expected = query.trim();
|
|
9661
|
+
if (candidate.tradingPair === expected) return true;
|
|
9662
|
+
return upper(candidate.symbol) === upper(expected);
|
|
9663
|
+
}
|
|
9664
|
+
function matchesFilter(value, expected) {
|
|
9665
|
+
return expected === void 0 || upper(value) === upper(expected);
|
|
9666
|
+
}
|
|
9667
|
+
function dedupe(candidates) {
|
|
9668
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9669
|
+
return candidates.filter((candidate) => {
|
|
9670
|
+
if (seen.has(candidate.tradingPair)) return false;
|
|
9671
|
+
seen.add(candidate.tradingPair);
|
|
9672
|
+
return true;
|
|
9673
|
+
});
|
|
9674
|
+
}
|
|
9675
|
+
function resolveFilters(params) {
|
|
9676
|
+
const record2 = isRecord(params) ? params : {};
|
|
9677
|
+
return {
|
|
9678
|
+
market: typeof record2.market === "string" ? record2.market : void 0,
|
|
9679
|
+
instrumentType: typeof record2.instrumentType === "string" ? record2.instrumentType : void 0,
|
|
9680
|
+
underlyingType: typeof record2.underlyingType === "string" ? record2.underlyingType : void 0,
|
|
9681
|
+
quote: typeof record2.quote === "string" ? record2.quote : void 0
|
|
9682
|
+
};
|
|
9683
|
+
}
|
|
9684
|
+
function pairSearchParams(pair, params) {
|
|
9685
|
+
const parts = pair.split("_");
|
|
9686
|
+
const market = parts[0];
|
|
9687
|
+
const instrumentType = parts[1];
|
|
9688
|
+
const symbol = parts.length >= 4 ? parts.slice(2, -1).join("_") : parts.length === 3 ? parts[2] : void 0;
|
|
9689
|
+
const quote = parts.at(-1);
|
|
9690
|
+
if (!market || !instrumentType || !symbol || !quote) {
|
|
9691
|
+
return { symbol: pair, ...params };
|
|
9692
|
+
}
|
|
9693
|
+
return {
|
|
9694
|
+
symbol,
|
|
9695
|
+
market: params.market ?? market,
|
|
9696
|
+
instrumentType: params.instrumentType ?? instrumentType,
|
|
9697
|
+
underlyingType: params.underlyingType,
|
|
9698
|
+
quote: params.quote ?? quote
|
|
9699
|
+
};
|
|
9700
|
+
}
|
|
9701
|
+
var TradingPairsResource = class {
|
|
9702
|
+
constructor(client) {
|
|
9703
|
+
this.client = client;
|
|
9704
|
+
}
|
|
9705
|
+
client;
|
|
9706
|
+
async search(params) {
|
|
9707
|
+
this.client._requireAuth();
|
|
9708
|
+
const rawSymbol = isRecord(params) ? params.symbol : void 0;
|
|
9709
|
+
const query = typeof rawSymbol === "string" ? rawSymbol.trim() : "";
|
|
9710
|
+
if (!query)
|
|
9711
|
+
throw new AlvaError("INVALID_ARGUMENT", "symbol is required", 400);
|
|
9712
|
+
const response = await this.client._request(
|
|
9713
|
+
"GET",
|
|
9714
|
+
"/api/v1/trading-pairs/search",
|
|
9715
|
+
{ query: { q: query, strict: true } }
|
|
9716
|
+
);
|
|
9717
|
+
const candidates = dedupe(flattenResponse(response)).filter((candidate) => matchesQuery(candidate, query)).filter((candidate) => matchesFilter(candidate.market, params.market)).filter(
|
|
9718
|
+
(candidate) => matchesFilter(candidate.instrumentType, params.instrumentType)
|
|
9719
|
+
).filter(
|
|
9720
|
+
(candidate) => matchesFilter(candidate.underlyingType, params.underlyingType)
|
|
9721
|
+
).filter((candidate) => matchesFilter(candidate.quote, params.quote));
|
|
9722
|
+
const limit = params.limit;
|
|
9723
|
+
if (limit !== void 0 && candidates.length > limit) {
|
|
9724
|
+
return { query, candidates: candidates.slice(0, limit), truncated: true };
|
|
9725
|
+
}
|
|
9726
|
+
return { query, candidates };
|
|
9727
|
+
}
|
|
9728
|
+
async resolve(params) {
|
|
9729
|
+
const record2 = isRecord(params) ? params : {};
|
|
9730
|
+
const pair = typeof record2.pair === "string" ? record2.pair.trim() : void 0;
|
|
9731
|
+
const filters = resolveFilters(params);
|
|
9732
|
+
const searchParams = pair === void 0 ? {
|
|
9733
|
+
symbol: typeof record2.symbol === "string" ? record2.symbol : "",
|
|
9734
|
+
...filters
|
|
9735
|
+
} : pairSearchParams(pair, filters);
|
|
9736
|
+
const result = await this.search(searchParams);
|
|
9737
|
+
const candidates = pair === void 0 ? result.candidates : result.candidates.filter(
|
|
9738
|
+
(candidate) => candidate.tradingPair === pair
|
|
9739
|
+
);
|
|
9740
|
+
if (candidates.length !== 1) {
|
|
9741
|
+
const detailLimit = 50;
|
|
9742
|
+
throw new AlvaError(
|
|
9743
|
+
candidates.length === 0 ? "TRADING_PAIR_NOT_FOUND" : "TRADING_PAIR_NOT_UNIQUE",
|
|
9744
|
+
candidates.length === 0 ? `no canonical trading pair matched "${pair ?? searchParams.symbol}"` : `multiple canonical trading pairs matched "${searchParams.symbol}"`,
|
|
9745
|
+
candidates.length === 0 ? 404 : 409,
|
|
9746
|
+
{
|
|
9747
|
+
query: pair ?? searchParams.symbol,
|
|
9748
|
+
candidateCount: candidates.length,
|
|
9749
|
+
candidates: candidates.slice(0, detailLimit),
|
|
9750
|
+
...candidates.length > detailLimit ? { truncated: true } : {}
|
|
9751
|
+
}
|
|
9752
|
+
);
|
|
9753
|
+
}
|
|
9754
|
+
return candidates[0];
|
|
9755
|
+
}
|
|
9756
|
+
};
|
|
9757
|
+
|
|
9445
9758
|
// src/client.ts
|
|
9446
9759
|
var DEFAULT_BASE_URL = "https://api-llm.prd.alva.ai";
|
|
9447
9760
|
var DEFAULT_ARRAYS_BASE_URL = "https://data-tools.prd.space.id";
|
|
9448
|
-
function
|
|
9761
|
+
function isRecord2(value) {
|
|
9449
9762
|
return typeof value === "object" && value !== null;
|
|
9450
9763
|
}
|
|
9451
9764
|
function stringField(value, field) {
|
|
9452
|
-
if (!
|
|
9765
|
+
if (!isRecord2(value)) return void 0;
|
|
9453
9766
|
const fieldValue = value[field];
|
|
9454
9767
|
return typeof fieldValue === "string" && fieldValue ? fieldValue : void 0;
|
|
9455
9768
|
}
|
|
@@ -9463,7 +9776,7 @@ function describeCause(cause) {
|
|
|
9463
9776
|
if (cause.message) details.message = cause.message;
|
|
9464
9777
|
const code = stringField(cause, "code");
|
|
9465
9778
|
if (code) details.code = code;
|
|
9466
|
-
} else if (
|
|
9779
|
+
} else if (isRecord2(cause)) {
|
|
9467
9780
|
const code = stringField(cause, "code");
|
|
9468
9781
|
const name = stringField(cause, "name");
|
|
9469
9782
|
const message = stringField(cause, "message");
|
|
@@ -9491,7 +9804,7 @@ function describeFetchFailure(err) {
|
|
|
9491
9804
|
details.message = String(err);
|
|
9492
9805
|
}
|
|
9493
9806
|
const { message: causeMessage, details: causeDetails } = describeCause(
|
|
9494
|
-
|
|
9807
|
+
isRecord2(err) ? err.cause : void 0
|
|
9495
9808
|
);
|
|
9496
9809
|
if (causeDetails) {
|
|
9497
9810
|
details.cause = causeDetails;
|
|
@@ -9528,6 +9841,7 @@ var AlvaClient = class {
|
|
|
9528
9841
|
_serviceAccount;
|
|
9529
9842
|
_release;
|
|
9530
9843
|
_feed;
|
|
9844
|
+
_forYou;
|
|
9531
9845
|
_automation;
|
|
9532
9846
|
_playbooks;
|
|
9533
9847
|
_secrets;
|
|
@@ -9551,6 +9865,7 @@ var AlvaClient = class {
|
|
|
9551
9865
|
_credits;
|
|
9552
9866
|
_markets;
|
|
9553
9867
|
_schedules;
|
|
9868
|
+
_tradingPairs;
|
|
9554
9869
|
constructor(config) {
|
|
9555
9870
|
this.baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
|
|
9556
9871
|
this.arraysBaseUrl = config.arraysBaseUrl ?? DEFAULT_ARRAYS_BASE_URL;
|
|
@@ -9648,6 +9963,9 @@ var AlvaClient = class {
|
|
|
9648
9963
|
get markets() {
|
|
9649
9964
|
return this._markets ??= new MarketsResource(this);
|
|
9650
9965
|
}
|
|
9966
|
+
get tradingPairs() {
|
|
9967
|
+
return this._tradingPairs ??= new TradingPairsResource(this);
|
|
9968
|
+
}
|
|
9651
9969
|
get schedules() {
|
|
9652
9970
|
return this._schedules ??= new SchedulesResource(this);
|
|
9653
9971
|
}
|
|
@@ -9660,6 +9978,9 @@ var AlvaClient = class {
|
|
|
9660
9978
|
);
|
|
9661
9979
|
}
|
|
9662
9980
|
}
|
|
9981
|
+
get forYou() {
|
|
9982
|
+
return this._forYou ??= new ForYouResource(this);
|
|
9983
|
+
}
|
|
9663
9984
|
async _request(method, path, options) {
|
|
9664
9985
|
const baseUrl = options?.baseUrl ?? this.baseUrl;
|
|
9665
9986
|
let url = `${baseUrl}${path}`;
|
|
@@ -10030,7 +10351,8 @@ var COMMAND_DEFINITIONS = [
|
|
|
10030
10351
|
"args",
|
|
10031
10352
|
"max-heap-size-mb",
|
|
10032
10353
|
"timeout-ms"
|
|
10033
|
-
]
|
|
10354
|
+
],
|
|
10355
|
+
booleans: ["args-stdin"]
|
|
10034
10356
|
}),
|
|
10035
10357
|
command("deploy create", {
|
|
10036
10358
|
values: [
|
|
@@ -10141,6 +10463,10 @@ var COMMAND_DEFINITIONS = [
|
|
|
10141
10463
|
command("automation resume", { values: ["id"] }),
|
|
10142
10464
|
command("automation delete", { values: ["id"] }),
|
|
10143
10465
|
command("credits wallet"),
|
|
10466
|
+
command("for-you"),
|
|
10467
|
+
command("for-you list", {
|
|
10468
|
+
values: ["limit", "cursor", "newer-than", "feed-id"]
|
|
10469
|
+
}),
|
|
10144
10470
|
command("credits items", {
|
|
10145
10471
|
values: ["last", "start", "end", "session-id", "first", "after"],
|
|
10146
10472
|
booleans: ["today"]
|
|
@@ -10376,6 +10702,28 @@ var COMMAND_DEFINITIONS = [
|
|
|
10376
10702
|
command("markets earnings", {
|
|
10377
10703
|
values: ["ticker", "event", "fiscal-year", "fiscal-quarter"]
|
|
10378
10704
|
}),
|
|
10705
|
+
command("trading-pairs search", {
|
|
10706
|
+
values: [
|
|
10707
|
+
"symbol",
|
|
10708
|
+
"market",
|
|
10709
|
+
"instrument-type",
|
|
10710
|
+
"underlying-type",
|
|
10711
|
+
"quote",
|
|
10712
|
+
"limit"
|
|
10713
|
+
],
|
|
10714
|
+
booleans: ["json"]
|
|
10715
|
+
}),
|
|
10716
|
+
command("trading-pairs resolve", {
|
|
10717
|
+
values: [
|
|
10718
|
+
"pair",
|
|
10719
|
+
"symbol",
|
|
10720
|
+
"market",
|
|
10721
|
+
"instrument-type",
|
|
10722
|
+
"underlying-type",
|
|
10723
|
+
"quote"
|
|
10724
|
+
],
|
|
10725
|
+
booleans: ["json"]
|
|
10726
|
+
}),
|
|
10379
10727
|
command("trading accounts"),
|
|
10380
10728
|
command("trading portfolio", { values: ["account-id"] }),
|
|
10381
10729
|
command("trading orders", {
|
|
@@ -10472,6 +10820,28 @@ function closestFlag(input, available) {
|
|
|
10472
10820
|
const threshold = input.length <= 4 ? 1 : 2;
|
|
10473
10821
|
return distance <= threshold ? closest : void 0;
|
|
10474
10822
|
}
|
|
10823
|
+
var TOP_LEVEL_COMMAND_SUGGESTIONS = {
|
|
10824
|
+
market: "markets",
|
|
10825
|
+
data: "data-skills",
|
|
10826
|
+
feeds: "automation"
|
|
10827
|
+
};
|
|
10828
|
+
function closestCommand(input, available) {
|
|
10829
|
+
const terminology = TOP_LEVEL_COMMAND_SUGGESTIONS[input];
|
|
10830
|
+
if (terminology !== void 0 && available.has(terminology)) {
|
|
10831
|
+
return terminology;
|
|
10832
|
+
}
|
|
10833
|
+
let closest;
|
|
10834
|
+
let distance = Number.POSITIVE_INFINITY;
|
|
10835
|
+
for (const candidate of available.keys()) {
|
|
10836
|
+
const candidateDistance = editDistance(input, candidate);
|
|
10837
|
+
if (candidateDistance < distance) {
|
|
10838
|
+
closest = candidate;
|
|
10839
|
+
distance = candidateDistance;
|
|
10840
|
+
}
|
|
10841
|
+
}
|
|
10842
|
+
const threshold = input.length <= 4 ? 1 : 2;
|
|
10843
|
+
return distance <= threshold ? closest : void 0;
|
|
10844
|
+
}
|
|
10475
10845
|
function mergeFlags(definition, globalFlags) {
|
|
10476
10846
|
return { ...globalFlags, ...definition.flags };
|
|
10477
10847
|
}
|
|
@@ -10489,7 +10859,9 @@ function resolveCommand(args, tree) {
|
|
|
10489
10859
|
}
|
|
10490
10860
|
if (node.definition !== void 0 && node.children.size === 0) break;
|
|
10491
10861
|
if (consumed === 0) {
|
|
10492
|
-
|
|
10862
|
+
const suggestion = closestCommand(input, node.children);
|
|
10863
|
+
const recovery = suggestion === void 0 ? " Run 'alva --help' to list command families." : ` Did you mean '${suggestion}'?`;
|
|
10864
|
+
throw new CliUsageError(`Unknown command: '${input}'.${recovery}`);
|
|
10493
10865
|
}
|
|
10494
10866
|
const group2 = args[0];
|
|
10495
10867
|
const command2 = args.slice(0, consumed).join(" ");
|
|
@@ -14670,8 +15042,41 @@ ${formatReport(report, "human")}
|
|
|
14670
15042
|
return report;
|
|
14671
15043
|
}
|
|
14672
15044
|
|
|
15045
|
+
// src/cli/tradingPairsFormat.ts
|
|
15046
|
+
function candidateLine(candidate) {
|
|
15047
|
+
const metadata = [
|
|
15048
|
+
`market=${candidate.market}`,
|
|
15049
|
+
`instrument=${candidate.instrumentType}`,
|
|
15050
|
+
candidate.underlyingType === void 0 ? void 0 : `underlying=${candidate.underlyingType}`,
|
|
15051
|
+
`quote=${candidate.quote}`
|
|
15052
|
+
].filter((value) => value !== void 0);
|
|
15053
|
+
return `${candidate.tradingPair} (${metadata.join(" ")})`;
|
|
15054
|
+
}
|
|
15055
|
+
function formatTradingPairSearch(result) {
|
|
15056
|
+
if (result.candidates.length === 0) {
|
|
15057
|
+
return `No trading pairs found for "${result.query}".`;
|
|
15058
|
+
}
|
|
15059
|
+
const lines = result.candidates.map(candidateLine);
|
|
15060
|
+
if (result.truncated === true) {
|
|
15061
|
+
lines.push(
|
|
15062
|
+
`... results truncated at ${result.candidates.length} candidates`
|
|
15063
|
+
);
|
|
15064
|
+
}
|
|
15065
|
+
return lines.join("\n");
|
|
15066
|
+
}
|
|
15067
|
+
function formatTradingPairResolved(result) {
|
|
15068
|
+
return [
|
|
15069
|
+
result.tradingPair,
|
|
15070
|
+
`symbol=${result.symbol}`,
|
|
15071
|
+
`market=${result.market}`,
|
|
15072
|
+
`instrument=${result.instrumentType}`,
|
|
15073
|
+
...result.underlyingType === void 0 ? [] : [`underlying=${result.underlyingType}`],
|
|
15074
|
+
`quote=${result.quote}`
|
|
15075
|
+
].join("\n");
|
|
15076
|
+
}
|
|
15077
|
+
|
|
14673
15078
|
// src/cli/dispatch.ts
|
|
14674
|
-
var CLI_VERSION = true ? "0.
|
|
15079
|
+
var CLI_VERSION = true ? "0.28.0-beta.0" : "dev";
|
|
14675
15080
|
var DEFAULT_RUN_TIMEOUT_MS = 6e5;
|
|
14676
15081
|
var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
|
|
14677
15082
|
var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
|
|
@@ -14723,6 +15128,7 @@ Commands:
|
|
|
14723
15128
|
playbooks Playbook discovery (trending, get, list) and visibility
|
|
14724
15129
|
functions Playbook UDF function management (register, list, delete, invoke, allowance)
|
|
14725
15130
|
credits Credit wallet and self-scoped usage history (wallet, items)
|
|
15131
|
+
for-you Read your For You publications (list)
|
|
14726
15132
|
secrets Secret management (create, list, get, update, delete)
|
|
14727
15133
|
sdk SDK documentation (doc, partitions, partition-summary)
|
|
14728
15134
|
skillhub Playbook skills (list, tags, get, file)
|
|
@@ -14735,6 +15141,7 @@ Commands:
|
|
|
14735
15141
|
remix Save playbook remix lineage
|
|
14736
15142
|
portfolio Connected-account portfolio (accounts, summary, activities)
|
|
14737
15143
|
markets Company narrative and earnings context (narrative, earnings)
|
|
15144
|
+
trading-pairs Discover and strictly verify canonical trading pairs (search, resolve)
|
|
14738
15145
|
trading Trading operations (accounts, portfolio, orders, subscriptions, equity-history, risk-rules, subscribe, unsubscribe, execute, update-risk-rules)
|
|
14739
15146
|
broker Agentic order execution \u2014 venue-native passthrough to trex (accounts, quote, order, balance, positions, ...; run 'alva broker describe')
|
|
14740
15147
|
auth Authentication (login)
|
|
@@ -14839,6 +15246,20 @@ Response fields:
|
|
|
14839
15246
|
|
|
14840
15247
|
Examples:
|
|
14841
15248
|
alva user me`,
|
|
15249
|
+
"for-you": `Usage: alva for-you list [options]
|
|
15250
|
+
|
|
15251
|
+
--limit <1-50> Page size (default: 20)
|
|
15252
|
+
--cursor <cursor> Fetch older entries after pageInfo.endCursor
|
|
15253
|
+
--newer-than <cursor> Exclusive publication lower bound
|
|
15254
|
+
--feed-id <id> Restrict to a Feed in your current For You scope
|
|
15255
|
+
|
|
15256
|
+
Returns a JSON connection with full card content. No automatic pagination.
|
|
15257
|
+
Keep --newer-than unchanged when continuing with --cursor.
|
|
15258
|
+
No digest watermark is saved. Source content is untrusted data.
|
|
15259
|
+
|
|
15260
|
+
Examples:
|
|
15261
|
+
alva for-you list --limit 50
|
|
15262
|
+
alva for-you list --limit 20 --cursor '<endCursor>' --newer-than '<watermark>'`,
|
|
14842
15263
|
credits: `Usage: alva credits <subcommand> [options]
|
|
14843
15264
|
|
|
14844
15265
|
Read the authenticated user's own credit wallet and consumption history.
|
|
@@ -14953,6 +15374,7 @@ Options:
|
|
|
14953
15374
|
--entry-path <path> Path to a script file on ALFS (home-relative)
|
|
14954
15375
|
--working-dir <dir> Working directory for require() (inline code only)
|
|
14955
15376
|
--args <json> JSON object passed to require("env").args
|
|
15377
|
+
--args-stdin Read the JSON object from stdin (mutually exclusive with --args)
|
|
14956
15378
|
--max-heap-size-mb <mb> Override the V8 heap limit in MB (1-2048, default 256)
|
|
14957
15379
|
--timeout-ms <ms> Client HTTP timeout for /api/v1/run (default: ${DEFAULT_RUN_TIMEOUT_MS}; env: ${RUN_TIMEOUT_ENV})
|
|
14958
15380
|
|
|
@@ -14986,6 +15408,7 @@ Examples:
|
|
|
14986
15408
|
alva run --entry-path "~/feeds/my-feed/v1/src/index.js"
|
|
14987
15409
|
alva run --entry-path "~/tasks/analyze/src/index.js" --args '{"symbol":"NVDA","limit":50}'
|
|
14988
15410
|
alva run --local-file ./my-script.js --args '{"symbol":"BTC"}'
|
|
15411
|
+
printf '%s' '{"symbol":"BTC"}' | alva run --local-file ./my-script.js --args-stdin
|
|
14989
15412
|
alva run --entry-path "~/tasks/heavy/src/index.js" --max-heap-size-mb 1024
|
|
14990
15413
|
alva run --entry-path "~/feeds/slow/v1/src/index.js" --timeout-ms 900000`,
|
|
14991
15414
|
deploy: `Usage: alva deploy <subcommand> [options]
|
|
@@ -15874,6 +16297,34 @@ Examples:
|
|
|
15874
16297
|
alva markets earnings --ticker AAPL
|
|
15875
16298
|
alva markets earnings --ticker AAPL --event next-confirmed
|
|
15876
16299
|
alva markets earnings --ticker AAPL --fiscal-year 2026 --fiscal-quarter Q3`,
|
|
16300
|
+
"trading-pairs": `Usage: alva trading-pairs <subcommand> [options]
|
|
16301
|
+
|
|
16302
|
+
Discover canonical trading-pair identities before backtesting or trading.
|
|
16303
|
+
The returned tradingPair is the exact value to use in OHLCV, Altra targets,
|
|
16304
|
+
positions, and orders. This command never constructs aliases or picks the
|
|
16305
|
+
first result.
|
|
16306
|
+
|
|
16307
|
+
Subcommands:
|
|
16308
|
+
search Return all matching candidates; multiple results are normal
|
|
16309
|
+
resolve Require exactly one matching canonical tradingPair
|
|
16310
|
+
|
|
16311
|
+
Search and resolve flags:
|
|
16312
|
+
--symbol <ticker> Underlying ticker/query (for example RKLB)
|
|
16313
|
+
--market <market> Venue/market filter (for example US, BINANCE)
|
|
16314
|
+
--instrument-type <type> spot, perp, option, ...
|
|
16315
|
+
--underlying-type <type> stock, crypto, ...
|
|
16316
|
+
--quote <currency> USD, USDT, USDC, ...
|
|
16317
|
+
--json Return the machine-readable result
|
|
16318
|
+
|
|
16319
|
+
Search-only flags:
|
|
16320
|
+
--limit <n> Limit returned candidates; truncation is reported
|
|
16321
|
+
|
|
16322
|
+
Resolve forms:
|
|
16323
|
+
alva trading-pairs resolve --pair US_SPOT_RKLB_USD --json
|
|
16324
|
+
alva trading-pairs resolve --symbol RKLB --market US --instrument-type spot --quote USD --json
|
|
16325
|
+
|
|
16326
|
+
Resolve fails when zero or multiple distinct pairs remain. Existing holdings
|
|
16327
|
+
must keep their stored full tradingPair instead of being resolved again.`,
|
|
15877
16328
|
trading: `Usage: alva trading <subcommand> [options]
|
|
15878
16329
|
|
|
15879
16330
|
Manage trading accounts, portfolios, orders, subscriptions, and risk rules.
|
|
@@ -15987,13 +16438,13 @@ function boolFlag(val) {
|
|
|
15987
16438
|
if (val === "false") return false;
|
|
15988
16439
|
return void 0;
|
|
15989
16440
|
}
|
|
15990
|
-
function serializedJSONFlag(value, command2) {
|
|
16441
|
+
function serializedJSONFlag(value, command2, flag = "--args") {
|
|
15991
16442
|
if (value === void 0) return void 0;
|
|
15992
16443
|
try {
|
|
15993
16444
|
validateSerializedArgs(value);
|
|
15994
16445
|
} catch (error) {
|
|
15995
16446
|
throw new CliUsageError(
|
|
15996
|
-
|
|
16447
|
+
`${flag} must contain valid JSON for '${command2}': ${error instanceof Error ? error.message : String(error)}`,
|
|
15997
16448
|
command2.split(" ")[0]
|
|
15998
16449
|
);
|
|
15999
16450
|
}
|
|
@@ -16178,19 +16629,19 @@ function deliveryProviderFilter(flags, command2) {
|
|
|
16178
16629
|
}
|
|
16179
16630
|
return flags["delivery-provider"];
|
|
16180
16631
|
}
|
|
16181
|
-
function projectUserProfileForCLI(
|
|
16182
|
-
const { active_channel: activeIMProvider, ...profile } =
|
|
16632
|
+
function projectUserProfileForCLI(record2) {
|
|
16633
|
+
const { active_channel: activeIMProvider, ...profile } = record2;
|
|
16183
16634
|
return { ...profile, active_im_provider: activeIMProvider };
|
|
16184
16635
|
}
|
|
16185
16636
|
function projectNotificationHistoryForCLI(response) {
|
|
16186
16637
|
if (response === null || typeof response !== "object" || Array.isArray(response)) {
|
|
16187
16638
|
return response;
|
|
16188
16639
|
}
|
|
16189
|
-
const
|
|
16190
|
-
if (!Array.isArray(
|
|
16640
|
+
const record2 = response;
|
|
16641
|
+
if (!Array.isArray(record2.items)) return response;
|
|
16191
16642
|
return {
|
|
16192
|
-
...
|
|
16193
|
-
items:
|
|
16643
|
+
...record2,
|
|
16644
|
+
items: record2.items.map((item) => {
|
|
16194
16645
|
if (item === null || typeof item !== "object" || Array.isArray(item)) {
|
|
16195
16646
|
return item;
|
|
16196
16647
|
}
|
|
@@ -16700,7 +17151,7 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
16700
17151
|
const positionals = parsedCommand.positionals;
|
|
16701
17152
|
if (group === "whoami") {
|
|
16702
17153
|
const user = await client.user.me();
|
|
16703
|
-
const
|
|
17154
|
+
const record2 = projectUserProfileForCLI(
|
|
16704
17155
|
user
|
|
16705
17156
|
);
|
|
16706
17157
|
const version = meta?.cliVersion ?? CLI_VERSION;
|
|
@@ -16717,10 +17168,10 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
16717
17168
|
metaBlock.arrays_jwt = arraysJwtStatus;
|
|
16718
17169
|
}
|
|
16719
17170
|
const result = {
|
|
16720
|
-
...
|
|
17171
|
+
...record2,
|
|
16721
17172
|
_meta: metaBlock
|
|
16722
17173
|
};
|
|
16723
|
-
const minVersion =
|
|
17174
|
+
const minVersion = record2.toolkit_min_version;
|
|
16724
17175
|
if (typeof minVersion === "string" && version && version !== "dev" && isVersionOlderThan(version, minVersion)) {
|
|
16725
17176
|
result._warning = `Warning: your toolkit version (${version}) is older than the minimum recommended version (${minVersion}). Please upgrade: npm install -g @alva-ai/toolkit`;
|
|
16726
17177
|
}
|
|
@@ -16860,7 +17311,30 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
16860
17311
|
),
|
|
16861
17312
|
timeout_ms
|
|
16862
17313
|
};
|
|
16863
|
-
const
|
|
17314
|
+
const argsFromStdin = boolFlag(flags["args-stdin"]) === true;
|
|
17315
|
+
if (argsFromStdin && flags["args"] !== void 0) {
|
|
17316
|
+
throw new CliUsageError(
|
|
17317
|
+
"--args and --args-stdin are mutually exclusive",
|
|
17318
|
+
"run"
|
|
17319
|
+
);
|
|
17320
|
+
}
|
|
17321
|
+
let serializedArgs = serializedJSONFlag(flags["args"], "run");
|
|
17322
|
+
if (argsFromStdin) {
|
|
17323
|
+
if (!deps?.readStdin) {
|
|
17324
|
+
throw new CliUsageError(
|
|
17325
|
+
"--args-stdin requires a Node.js runtime adapter",
|
|
17326
|
+
"run"
|
|
17327
|
+
);
|
|
17328
|
+
}
|
|
17329
|
+
const stdin = await deps.readStdin();
|
|
17330
|
+
serializedArgs = serializedJSONFlag(stdin, "run", "--args-stdin");
|
|
17331
|
+
if (serializedArgs === void 0) {
|
|
17332
|
+
throw new CliUsageError(
|
|
17333
|
+
"--args-stdin requires JSON input from stdin",
|
|
17334
|
+
"run"
|
|
17335
|
+
);
|
|
17336
|
+
}
|
|
17337
|
+
}
|
|
16864
17338
|
return serializedArgs === void 0 ? client.run.execute(params) : client.run._executeSerializedArgs(params, serializedArgs);
|
|
16865
17339
|
}
|
|
16866
17340
|
case "deploy": {
|
|
@@ -17190,6 +17664,32 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
17190
17664
|
);
|
|
17191
17665
|
}
|
|
17192
17666
|
}
|
|
17667
|
+
case "for-you": {
|
|
17668
|
+
if (subcommand !== "list") {
|
|
17669
|
+
throw new CliUsageError("Expected for-you list", "for-you");
|
|
17670
|
+
}
|
|
17671
|
+
const params = {
|
|
17672
|
+
first: optionalBoundedIntegerFlag(
|
|
17673
|
+
flags,
|
|
17674
|
+
"limit",
|
|
17675
|
+
"for-you list",
|
|
17676
|
+
1,
|
|
17677
|
+
50
|
|
17678
|
+
),
|
|
17679
|
+
after: flags.cursor,
|
|
17680
|
+
newerThan: flags["newer-than"],
|
|
17681
|
+
feedId: flags["feed-id"]
|
|
17682
|
+
};
|
|
17683
|
+
try {
|
|
17684
|
+
validateForYouListParams(params);
|
|
17685
|
+
} catch (error) {
|
|
17686
|
+
throw new CliUsageError(
|
|
17687
|
+
error instanceof Error ? error.message : String(error),
|
|
17688
|
+
"for-you"
|
|
17689
|
+
);
|
|
17690
|
+
}
|
|
17691
|
+
return client.forYou.list(params);
|
|
17692
|
+
}
|
|
17193
17693
|
case "credits": {
|
|
17194
17694
|
if (!subcommand)
|
|
17195
17695
|
throw new CliUsageError("Missing subcommand for credits", "credits");
|
|
@@ -18186,6 +18686,61 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
18186
18686
|
);
|
|
18187
18687
|
}
|
|
18188
18688
|
}
|
|
18689
|
+
case "trading-pairs": {
|
|
18690
|
+
if (!subcommand) {
|
|
18691
|
+
throw new CliUsageError(
|
|
18692
|
+
"Missing subcommand for trading-pairs",
|
|
18693
|
+
"trading-pairs"
|
|
18694
|
+
);
|
|
18695
|
+
}
|
|
18696
|
+
const asJson = boolFlag(flags["json"]) ?? false;
|
|
18697
|
+
const filters = {
|
|
18698
|
+
market: flags["market"],
|
|
18699
|
+
instrumentType: flags["instrument-type"],
|
|
18700
|
+
underlyingType: flags["underlying-type"],
|
|
18701
|
+
quote: flags["quote"]
|
|
18702
|
+
};
|
|
18703
|
+
switch (subcommand) {
|
|
18704
|
+
case "search": {
|
|
18705
|
+
const limit = flags["limit"] === void 0 ? void 0 : requirePositiveIntegerFlag(
|
|
18706
|
+
flags,
|
|
18707
|
+
"limit",
|
|
18708
|
+
"trading-pairs search"
|
|
18709
|
+
);
|
|
18710
|
+
const result = await client.tradingPairs.search({
|
|
18711
|
+
symbol: requireFlag(flags, "symbol", "trading-pairs search"),
|
|
18712
|
+
...filters,
|
|
18713
|
+
limit
|
|
18714
|
+
});
|
|
18715
|
+
return asJson ? result : formatTradingPairSearch(result);
|
|
18716
|
+
}
|
|
18717
|
+
case "resolve": {
|
|
18718
|
+
const pair = flags["pair"];
|
|
18719
|
+
const symbol = flags["symbol"];
|
|
18720
|
+
if (pair !== void 0 && symbol !== void 0) {
|
|
18721
|
+
throw new CliUsageError(
|
|
18722
|
+
"'trading-pairs resolve' accepts either --pair or --symbol, not both",
|
|
18723
|
+
"trading-pairs"
|
|
18724
|
+
);
|
|
18725
|
+
}
|
|
18726
|
+
if (pair === void 0 && symbol === void 0) {
|
|
18727
|
+
throw new CliUsageError(
|
|
18728
|
+
"'trading-pairs resolve' requires --pair or --symbol",
|
|
18729
|
+
"trading-pairs"
|
|
18730
|
+
);
|
|
18731
|
+
}
|
|
18732
|
+
const result = await client.tradingPairs.resolve(
|
|
18733
|
+
pair !== void 0 ? { pair, ...filters } : { symbol, ...filters }
|
|
18734
|
+
);
|
|
18735
|
+
return asJson ? result : formatTradingPairResolved(result);
|
|
18736
|
+
}
|
|
18737
|
+
default:
|
|
18738
|
+
throw new CliUsageError(
|
|
18739
|
+
`Unknown subcommand: trading-pairs ${subcommand}`,
|
|
18740
|
+
"trading-pairs"
|
|
18741
|
+
);
|
|
18742
|
+
}
|
|
18743
|
+
}
|
|
18189
18744
|
case "trading": {
|
|
18190
18745
|
if (!subcommand)
|
|
18191
18746
|
throw new CliUsageError("Missing subcommand for trading", "trading");
|