@alva-ai/toolkit 0.34.0 → 0.35.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 +34 -0
- package/dist/browser.global.js +67 -47
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +190 -2
- package/dist/cli.js +932 -101
- package/dist/cli.js.map +1 -1
- package/dist/dispatch.d.ts +190 -2
- package/dist/dispatch.js +405 -45
- package/dist/dispatch.js.map +1 -1
- package/dist/index.cjs +706 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +191 -3
- package/dist/index.d.ts +191 -3
- package/dist/index.js +705 -73
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8775,6 +8775,468 @@ var SubscriptionsResource = class {
|
|
|
8775
8775
|
}
|
|
8776
8776
|
};
|
|
8777
8777
|
|
|
8778
|
+
// src/resources/follows.ts
|
|
8779
|
+
var MAX_TICKERS = 50;
|
|
8780
|
+
var MAX_TICKER_LENGTH = 40;
|
|
8781
|
+
var MAX_WATCHLIST_FIRST = 100;
|
|
8782
|
+
var MAX_PROFILE_FIRST = 50;
|
|
8783
|
+
var MAX_PROFILE_QUERY_LENGTH = 200;
|
|
8784
|
+
var LOOKUP_CONCURRENCY = 5;
|
|
8785
|
+
var TICKER_KINDS = ["STOCK", "ETF", "CRYPTO"];
|
|
8786
|
+
var PROFILE_KINDS = ["USER", "PERSON"];
|
|
8787
|
+
var UNRESOLVED_LOOKUP_CODES = /* @__PURE__ */ new Set(["NOT_FOUND", "FAILED_PRECONDITION"]);
|
|
8788
|
+
var GRAPHQL_STATUS_BY_CODE2 = {
|
|
8789
|
+
INVALID_ARGUMENT: 400,
|
|
8790
|
+
UNAUTHENTICATED: 401,
|
|
8791
|
+
PERMISSION_DENIED: 403,
|
|
8792
|
+
NOT_FOUND: 404,
|
|
8793
|
+
ALREADY_EXISTS: 409,
|
|
8794
|
+
ABORTED: 409,
|
|
8795
|
+
FAILED_PRECONDITION: 412,
|
|
8796
|
+
RESOURCE_EXHAUSTED: 429,
|
|
8797
|
+
INTERNAL: 500,
|
|
8798
|
+
UNKNOWN: 500,
|
|
8799
|
+
DATA_LOSS: 500,
|
|
8800
|
+
UNAVAILABLE: 503,
|
|
8801
|
+
DEADLINE_EXCEEDED: 504
|
|
8802
|
+
};
|
|
8803
|
+
var TICKER_FIELDS = "id ticker name kind";
|
|
8804
|
+
var PROFILE_FIELDS = "__typename id displayName followersCount viewerState { following } ... on PublicUser { username } ... on Person { slug xHandle }";
|
|
8805
|
+
function record3(value) {
|
|
8806
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8807
|
+
}
|
|
8808
|
+
function invalidResponse3(field) {
|
|
8809
|
+
throw new AlvaError(
|
|
8810
|
+
"GRAPHQL_INVALID_RESPONSE",
|
|
8811
|
+
`GraphQL returned an invalid ${field} response`,
|
|
8812
|
+
502
|
|
8813
|
+
);
|
|
8814
|
+
}
|
|
8815
|
+
function graphQLFailure(response) {
|
|
8816
|
+
if (!record3(response) || response.errors === void 0) return void 0;
|
|
8817
|
+
if (!Array.isArray(response.errors)) return invalidResponse3("GraphQL");
|
|
8818
|
+
if (response.errors.length === 0) return void 0;
|
|
8819
|
+
const errors = response.errors;
|
|
8820
|
+
const messages = errors.flatMap(
|
|
8821
|
+
(error) => record3(error) && typeof error.message === "string" ? [error.message] : []
|
|
8822
|
+
);
|
|
8823
|
+
const codes = errors.map(
|
|
8824
|
+
(error) => record3(error) && record3(error.extensions) ? error.extensions.code : void 0
|
|
8825
|
+
);
|
|
8826
|
+
const code = typeof codes[0] === "string" && Object.hasOwn(GRAPHQL_STATUS_BY_CODE2, codes[0]) && codes.every((value) => value === codes[0]) ? codes[0] : "GRAPHQL_ERROR";
|
|
8827
|
+
return { code, message: messages.join("; ") || "Request failed", errors };
|
|
8828
|
+
}
|
|
8829
|
+
function throwFailure(failure) {
|
|
8830
|
+
throw new AlvaError(
|
|
8831
|
+
failure.code,
|
|
8832
|
+
failure.message,
|
|
8833
|
+
GRAPHQL_STATUS_BY_CODE2[failure.code] ?? 502,
|
|
8834
|
+
{ errors: failure.errors }
|
|
8835
|
+
);
|
|
8836
|
+
}
|
|
8837
|
+
function responseData(response, field) {
|
|
8838
|
+
const failure = graphQLFailure(response);
|
|
8839
|
+
if (failure) throwFailure(failure);
|
|
8840
|
+
if (!record3(response) || !record3(response.data))
|
|
8841
|
+
return invalidResponse3(field);
|
|
8842
|
+
return response.data;
|
|
8843
|
+
}
|
|
8844
|
+
function viewerField2(response, field) {
|
|
8845
|
+
const data = responseData(response, field);
|
|
8846
|
+
if (!record3(data.viewer)) return invalidResponse3(field);
|
|
8847
|
+
return data.viewer[field];
|
|
8848
|
+
}
|
|
8849
|
+
function requireString(value, field) {
|
|
8850
|
+
if (typeof value !== "string" || !value) return invalidResponse3(field);
|
|
8851
|
+
return value;
|
|
8852
|
+
}
|
|
8853
|
+
function pageInfo(value, field) {
|
|
8854
|
+
if (!record3(value) || typeof value.hasNextPage !== "boolean" || value.endCursor !== null && value.endCursor !== void 0 && typeof value.endCursor !== "string" || value.hasNextPage && !value.endCursor) {
|
|
8855
|
+
return invalidResponse3(field);
|
|
8856
|
+
}
|
|
8857
|
+
return {
|
|
8858
|
+
endCursor: typeof value.endCursor === "string" ? value.endCursor : "",
|
|
8859
|
+
hasNextPage: value.hasNextPage
|
|
8860
|
+
};
|
|
8861
|
+
}
|
|
8862
|
+
function normalizeProfile(value, field) {
|
|
8863
|
+
if (!record3(value) || !record3(value.viewerState))
|
|
8864
|
+
return invalidResponse3(field);
|
|
8865
|
+
const following = value.viewerState.following;
|
|
8866
|
+
if (typeof value.followersCount !== "number" || typeof value.displayName !== "string" || following !== null && typeof following !== "boolean") {
|
|
8867
|
+
return invalidResponse3(field);
|
|
8868
|
+
}
|
|
8869
|
+
const base = {
|
|
8870
|
+
id: requireString(value.id, field),
|
|
8871
|
+
displayName: value.displayName,
|
|
8872
|
+
followersCount: value.followersCount,
|
|
8873
|
+
following: following ?? null
|
|
8874
|
+
};
|
|
8875
|
+
if (value.__typename === "PublicUser") {
|
|
8876
|
+
return {
|
|
8877
|
+
kind: "USER",
|
|
8878
|
+
...base,
|
|
8879
|
+
username: requireString(value.username, field)
|
|
8880
|
+
};
|
|
8881
|
+
}
|
|
8882
|
+
if (value.__typename === "Person") {
|
|
8883
|
+
if (value.xHandle !== null && value.xHandle !== void 0 && typeof value.xHandle !== "string") {
|
|
8884
|
+
return invalidResponse3(field);
|
|
8885
|
+
}
|
|
8886
|
+
return {
|
|
8887
|
+
kind: "PERSON",
|
|
8888
|
+
...base,
|
|
8889
|
+
slug: requireString(value.slug, field),
|
|
8890
|
+
xHandle: value.xHandle ?? null
|
|
8891
|
+
};
|
|
8892
|
+
}
|
|
8893
|
+
return invalidResponse3(field);
|
|
8894
|
+
}
|
|
8895
|
+
function boundedFirst(value, max, name = "first") {
|
|
8896
|
+
if (value === void 0) return void 0;
|
|
8897
|
+
if (!Number.isInteger(value) || value < 1 || value > max) {
|
|
8898
|
+
throw new Error(`${name} must be an integer between 1 and ${max}`);
|
|
8899
|
+
}
|
|
8900
|
+
return value;
|
|
8901
|
+
}
|
|
8902
|
+
function optionalCursor(value) {
|
|
8903
|
+
if (value === void 0) return void 0;
|
|
8904
|
+
if (typeof value !== "string" || !value.trim() || value.length > 4096) {
|
|
8905
|
+
throw new Error(
|
|
8906
|
+
"after must be a non-empty cursor of at most 4096 characters"
|
|
8907
|
+
);
|
|
8908
|
+
}
|
|
8909
|
+
return value;
|
|
8910
|
+
}
|
|
8911
|
+
function profileKind(value, required) {
|
|
8912
|
+
if (value === void 0 && !required) return void 0;
|
|
8913
|
+
if (typeof value !== "string" || !PROFILE_KINDS.includes(value)) {
|
|
8914
|
+
throw new Error("kind must be USER or PERSON");
|
|
8915
|
+
}
|
|
8916
|
+
return value;
|
|
8917
|
+
}
|
|
8918
|
+
function tickerKind(value) {
|
|
8919
|
+
if (value === void 0) return void 0;
|
|
8920
|
+
if (typeof value !== "string" || !TICKER_KINDS.includes(value)) {
|
|
8921
|
+
throw new Error("kind must be STOCK, ETF, or CRYPTO");
|
|
8922
|
+
}
|
|
8923
|
+
return value;
|
|
8924
|
+
}
|
|
8925
|
+
function parseTickerSpec(raw) {
|
|
8926
|
+
const separator = raw.lastIndexOf(":");
|
|
8927
|
+
if (separator === -1) return { ticker: raw };
|
|
8928
|
+
return {
|
|
8929
|
+
ticker: raw.slice(0, separator),
|
|
8930
|
+
kind: tickerKind(
|
|
8931
|
+
raw.slice(separator + 1).trim().toUpperCase()
|
|
8932
|
+
)
|
|
8933
|
+
};
|
|
8934
|
+
}
|
|
8935
|
+
function normalizeWatchlistTickersParams(params) {
|
|
8936
|
+
if (!record3(params) || !Array.isArray(params.tickers)) {
|
|
8937
|
+
throw new Error("tickers must be a list of ticker symbols");
|
|
8938
|
+
}
|
|
8939
|
+
const defaultKind = tickerKind(params.kind);
|
|
8940
|
+
const tickers = [];
|
|
8941
|
+
for (const raw of params.tickers) {
|
|
8942
|
+
const spec = typeof raw === "string" ? { ticker: raw } : raw;
|
|
8943
|
+
if (!record3(spec) || typeof spec.ticker !== "string") {
|
|
8944
|
+
throw new Error("tickers must be symbols or {ticker, kind} specs");
|
|
8945
|
+
}
|
|
8946
|
+
const ticker = spec.ticker.trim().toUpperCase();
|
|
8947
|
+
if (!ticker || /\s/.test(ticker) || ticker.length > MAX_TICKER_LENGTH) {
|
|
8948
|
+
throw new Error(
|
|
8949
|
+
`ticker '${spec.ticker}' must be a non-empty symbol of at most ${MAX_TICKER_LENGTH} characters`
|
|
8950
|
+
);
|
|
8951
|
+
}
|
|
8952
|
+
const kind = tickerKind(spec.kind) ?? defaultKind;
|
|
8953
|
+
if (!tickers.some((t) => t.ticker === ticker && t.kind === kind)) {
|
|
8954
|
+
tickers.push(kind === void 0 ? { ticker } : { ticker, kind });
|
|
8955
|
+
}
|
|
8956
|
+
}
|
|
8957
|
+
if (tickers.length === 0 || tickers.length > MAX_TICKERS) {
|
|
8958
|
+
throw new Error(
|
|
8959
|
+
`tickers must contain between 1 and ${MAX_TICKERS} symbols`
|
|
8960
|
+
);
|
|
8961
|
+
}
|
|
8962
|
+
return { tickers };
|
|
8963
|
+
}
|
|
8964
|
+
function validateProfileRef(params) {
|
|
8965
|
+
if (!record3(params)) throw new Error("profile reference must be an object");
|
|
8966
|
+
const kind = profileKind(params.kind, true);
|
|
8967
|
+
if (typeof params.id !== "string" || !/^[1-9]\d{0,18}$/.test(params.id)) {
|
|
8968
|
+
throw new Error("id must be a positive decimal profile id");
|
|
8969
|
+
}
|
|
8970
|
+
return { kind, id: params.id };
|
|
8971
|
+
}
|
|
8972
|
+
function validateSearchProfilesParams(params) {
|
|
8973
|
+
if (!record3(params) || typeof params.query !== "string") {
|
|
8974
|
+
throw new Error("query is required");
|
|
8975
|
+
}
|
|
8976
|
+
const query = params.query.trim();
|
|
8977
|
+
if (!query || query.length > MAX_PROFILE_QUERY_LENGTH) {
|
|
8978
|
+
throw new Error(
|
|
8979
|
+
`query must be non-empty and at most ${MAX_PROFILE_QUERY_LENGTH} characters`
|
|
8980
|
+
);
|
|
8981
|
+
}
|
|
8982
|
+
return {
|
|
8983
|
+
query,
|
|
8984
|
+
kind: profileKind(params.kind, false),
|
|
8985
|
+
first: boundedFirst(params.first, MAX_PROFILE_FIRST)
|
|
8986
|
+
};
|
|
8987
|
+
}
|
|
8988
|
+
function unresolvedTicker(input, kind, code, message) {
|
|
8989
|
+
if (kind === void 0) {
|
|
8990
|
+
return { ok: false, unresolved: { input, code, message } };
|
|
8991
|
+
}
|
|
8992
|
+
return {
|
|
8993
|
+
ok: false,
|
|
8994
|
+
unresolved: {
|
|
8995
|
+
input,
|
|
8996
|
+
kind,
|
|
8997
|
+
code,
|
|
8998
|
+
message: code === "NOT_FOUND" ? `no ${kind} entity found for ticker ${input}; it may exist as another kind (retry with a different :kind suffix or none)` : message
|
|
8999
|
+
}
|
|
9000
|
+
};
|
|
9001
|
+
}
|
|
9002
|
+
var FollowsResource = class {
|
|
9003
|
+
constructor(client) {
|
|
9004
|
+
this.client = client;
|
|
9005
|
+
}
|
|
9006
|
+
client;
|
|
9007
|
+
/** Add tickers to the watchlist by exact symbol in one atomic batch. */
|
|
9008
|
+
async addToWatchlist(params) {
|
|
9009
|
+
const { changed, unchanged, unresolved } = await this.changeWatchlist(
|
|
9010
|
+
params,
|
|
9011
|
+
"add"
|
|
9012
|
+
);
|
|
9013
|
+
return { added: changed, unchanged, unresolved };
|
|
9014
|
+
}
|
|
9015
|
+
/** Remove tickers from the watchlist by exact symbol in one atomic batch. */
|
|
9016
|
+
async removeFromWatchlist(params) {
|
|
9017
|
+
const { changed, unchanged, unresolved } = await this.changeWatchlist(
|
|
9018
|
+
params,
|
|
9019
|
+
"remove"
|
|
9020
|
+
);
|
|
9021
|
+
return { removed: changed, unchanged, unresolved };
|
|
9022
|
+
}
|
|
9023
|
+
/** One page of the watchlist, most recently added first. */
|
|
9024
|
+
async watchlist(params = {}) {
|
|
9025
|
+
const first = boundedFirst(params.first, MAX_WATCHLIST_FIRST);
|
|
9026
|
+
const after = optionalCursor(params.after);
|
|
9027
|
+
this.client._requireAuth();
|
|
9028
|
+
const response = await this.client._request("POST", "/query", {
|
|
9029
|
+
body: {
|
|
9030
|
+
query: `query ToolkitWatchlist($input: MarketWatchlistConnectionInput) { viewer { marketWatchlist(input: $input) { totalCount edges { cursor followedAtMs node { ${TICKER_FIELDS} } } pageInfo { endCursor hasNextPage } } } }`,
|
|
9031
|
+
variables: { input: { first: first ?? 20, after } }
|
|
9032
|
+
}
|
|
9033
|
+
});
|
|
9034
|
+
const field = "viewer.marketWatchlist";
|
|
9035
|
+
const value = viewerField2(response, "marketWatchlist");
|
|
9036
|
+
if (!record3(value) || typeof value.totalCount !== "number" || !Array.isArray(value.edges)) {
|
|
9037
|
+
return invalidResponse3(field);
|
|
9038
|
+
}
|
|
9039
|
+
const tickers = value.edges.map((edge) => {
|
|
9040
|
+
if (!record3(edge) || !record3(edge.node) || typeof edge.followedAtMs !== "number") {
|
|
9041
|
+
return invalidResponse3(field);
|
|
9042
|
+
}
|
|
9043
|
+
return {
|
|
9044
|
+
entityId: requireString(edge.node.id, field),
|
|
9045
|
+
ticker: requireString(edge.node.ticker, field),
|
|
9046
|
+
name: typeof edge.node.name === "string" ? edge.node.name : "",
|
|
9047
|
+
kind: requireString(edge.node.kind, field),
|
|
9048
|
+
addedAtMs: edge.followedAtMs
|
|
9049
|
+
};
|
|
9050
|
+
});
|
|
9051
|
+
return {
|
|
9052
|
+
totalCount: value.totalCount,
|
|
9053
|
+
tickers,
|
|
9054
|
+
pageInfo: pageInfo(value.pageInfo, field)
|
|
9055
|
+
};
|
|
9056
|
+
}
|
|
9057
|
+
/** Search public profiles (Alva users and curated people). */
|
|
9058
|
+
async searchProfiles(params) {
|
|
9059
|
+
const { query, kind, first } = validateSearchProfilesParams(params);
|
|
9060
|
+
this.client._requireAuth();
|
|
9061
|
+
const response = await this.client._request("POST", "/query", {
|
|
9062
|
+
body: {
|
|
9063
|
+
query: `query ToolkitSearchProfiles($input: PublicProfileConnectionInput) { profiles(input: $input) { edges { node { ${PROFILE_FIELDS} } } pageInfo { endCursor hasNextPage } } }`,
|
|
9064
|
+
variables: { input: { query, kind, first: first ?? 10 } }
|
|
9065
|
+
}
|
|
9066
|
+
});
|
|
9067
|
+
return this.profilesPage(
|
|
9068
|
+
responseData(response, "profiles").profiles,
|
|
9069
|
+
"profiles"
|
|
9070
|
+
);
|
|
9071
|
+
}
|
|
9072
|
+
/** One page of profiles the caller follows. */
|
|
9073
|
+
async profiles(params = {}) {
|
|
9074
|
+
const kind = profileKind(params.kind, false);
|
|
9075
|
+
const first = boundedFirst(params.first, MAX_PROFILE_FIRST);
|
|
9076
|
+
const after = optionalCursor(params.after);
|
|
9077
|
+
this.client._requireAuth();
|
|
9078
|
+
const response = await this.client._request("POST", "/query", {
|
|
9079
|
+
body: {
|
|
9080
|
+
query: `query ToolkitFollowedProfiles($input: FollowingProfileConnectionInput) { viewer { followingProfiles(input: $input) { edges { node { ${PROFILE_FIELDS} } } pageInfo { endCursor hasNextPage } } } }`,
|
|
9081
|
+
variables: { input: { kind, first: first ?? 20, after } }
|
|
9082
|
+
}
|
|
9083
|
+
});
|
|
9084
|
+
return this.profilesPage(
|
|
9085
|
+
viewerField2(response, "followingProfiles"),
|
|
9086
|
+
"viewer.followingProfiles"
|
|
9087
|
+
);
|
|
9088
|
+
}
|
|
9089
|
+
/** Follow one profile. Idempotent. */
|
|
9090
|
+
async followProfile(params) {
|
|
9091
|
+
return this.changeProfile(params, "followProfile");
|
|
9092
|
+
}
|
|
9093
|
+
/** Unfollow one profile. Idempotent. */
|
|
9094
|
+
async unfollowProfile(params) {
|
|
9095
|
+
return this.changeProfile(params, "unfollowProfile");
|
|
9096
|
+
}
|
|
9097
|
+
profilesPage(value, field) {
|
|
9098
|
+
if (!record3(value) || !Array.isArray(value.edges)) {
|
|
9099
|
+
return invalidResponse3(field);
|
|
9100
|
+
}
|
|
9101
|
+
return {
|
|
9102
|
+
profiles: value.edges.map(
|
|
9103
|
+
(edge) => record3(edge) ? normalizeProfile(edge.node, field) : invalidResponse3(field)
|
|
9104
|
+
),
|
|
9105
|
+
pageInfo: pageInfo(value.pageInfo, field)
|
|
9106
|
+
};
|
|
9107
|
+
}
|
|
9108
|
+
async changeProfile(params, mutation) {
|
|
9109
|
+
const input = validateProfileRef(params);
|
|
9110
|
+
this.client._requireAuth();
|
|
9111
|
+
const response = await this.client._request("POST", "/query", {
|
|
9112
|
+
body: {
|
|
9113
|
+
query: `mutation ToolkitChangeProfileFollow($input: PublicProfileRefInput!) { ${mutation}(input: $input) { following target { ${PROFILE_FIELDS} } } }`,
|
|
9114
|
+
variables: { input }
|
|
9115
|
+
}
|
|
9116
|
+
});
|
|
9117
|
+
const value = responseData(response, mutation)[mutation];
|
|
9118
|
+
if (!record3(value) || typeof value.following !== "boolean") {
|
|
9119
|
+
return invalidResponse3(mutation);
|
|
9120
|
+
}
|
|
9121
|
+
return {
|
|
9122
|
+
following: value.following,
|
|
9123
|
+
profile: value.target === null || value.target === void 0 ? null : normalizeProfile(value.target, mutation)
|
|
9124
|
+
};
|
|
9125
|
+
}
|
|
9126
|
+
async changeWatchlist(params, direction) {
|
|
9127
|
+
const { tickers } = normalizeWatchlistTickersParams(params);
|
|
9128
|
+
this.client._requireAuth();
|
|
9129
|
+
const lookups = await this.lookupTickers(tickers);
|
|
9130
|
+
const changed = [];
|
|
9131
|
+
const unchanged = [];
|
|
9132
|
+
const unresolved = [];
|
|
9133
|
+
const groupByEntity = /* @__PURE__ */ new Map();
|
|
9134
|
+
const writeIds = [];
|
|
9135
|
+
for (const lookup of lookups) {
|
|
9136
|
+
if (!lookup.ok) {
|
|
9137
|
+
unresolved.push(lookup.unresolved);
|
|
9138
|
+
continue;
|
|
9139
|
+
}
|
|
9140
|
+
const seenGroup = groupByEntity.get(lookup.ticker.entityId);
|
|
9141
|
+
if (seenGroup) {
|
|
9142
|
+
seenGroup.push(lookup.ticker);
|
|
9143
|
+
continue;
|
|
9144
|
+
}
|
|
9145
|
+
const needsChange = direction === "add" ? !lookup.inWatchlist : lookup.inWatchlist;
|
|
9146
|
+
const group = needsChange ? changed : unchanged;
|
|
9147
|
+
group.push(lookup.ticker);
|
|
9148
|
+
groupByEntity.set(lookup.ticker.entityId, group);
|
|
9149
|
+
if (needsChange || direction === "remove") {
|
|
9150
|
+
writeIds.push(lookup.ticker.entityId);
|
|
9151
|
+
}
|
|
9152
|
+
}
|
|
9153
|
+
if (writeIds.length > 0) {
|
|
9154
|
+
const mutation = direction === "add" ? "followTickers" : "unfollowTickers";
|
|
9155
|
+
const input = direction === "add" ? "FollowTickersInput" : "UnfollowTickersInput";
|
|
9156
|
+
const response = await this.client._request("POST", "/query", {
|
|
9157
|
+
body: {
|
|
9158
|
+
query: `mutation ToolkitChangeWatchlist($input: ${input}!) { ${mutation}(input: $input) { entities { id } } }`,
|
|
9159
|
+
variables: { input: { entityIds: writeIds } }
|
|
9160
|
+
}
|
|
9161
|
+
});
|
|
9162
|
+
const value = responseData(response, mutation)[mutation];
|
|
9163
|
+
if (!record3(value) || !Array.isArray(value.entities)) {
|
|
9164
|
+
return invalidResponse3(mutation);
|
|
9165
|
+
}
|
|
9166
|
+
}
|
|
9167
|
+
return { changed, unchanged, unresolved };
|
|
9168
|
+
}
|
|
9169
|
+
async lookupTickers(tickers) {
|
|
9170
|
+
const results = new Array(tickers.length);
|
|
9171
|
+
let next = 0;
|
|
9172
|
+
const worker = async () => {
|
|
9173
|
+
while (next < tickers.length) {
|
|
9174
|
+
const index = next++;
|
|
9175
|
+
const { ticker, kind } = tickers[index];
|
|
9176
|
+
results[index] = await this.lookupTicker(ticker, kind);
|
|
9177
|
+
}
|
|
9178
|
+
};
|
|
9179
|
+
await Promise.all(
|
|
9180
|
+
Array.from(
|
|
9181
|
+
{ length: Math.min(LOOKUP_CONCURRENCY, tickers.length) },
|
|
9182
|
+
worker
|
|
9183
|
+
)
|
|
9184
|
+
);
|
|
9185
|
+
return results;
|
|
9186
|
+
}
|
|
9187
|
+
async lookupTicker(input, kind) {
|
|
9188
|
+
const response = await this.client._request("POST", "/query", {
|
|
9189
|
+
body: {
|
|
9190
|
+
query: `query ToolkitTickerLookup($input: MarketEntityLookupInput!) { market { entity(input: $input) { ${TICKER_FIELDS} viewerState { isFollowed } } } }`,
|
|
9191
|
+
variables: { input: { ticker: input, kind } }
|
|
9192
|
+
}
|
|
9193
|
+
});
|
|
9194
|
+
const failure = graphQLFailure(response);
|
|
9195
|
+
if (failure) {
|
|
9196
|
+
if (UNRESOLVED_LOOKUP_CODES.has(failure.code)) {
|
|
9197
|
+
return unresolvedTicker(input, kind, failure.code, failure.message);
|
|
9198
|
+
}
|
|
9199
|
+
throwFailure(failure);
|
|
9200
|
+
}
|
|
9201
|
+
const field = "market.entity";
|
|
9202
|
+
if (!record3(response) || !record3(response.data) || !record3(response.data.market)) {
|
|
9203
|
+
return invalidResponse3(field);
|
|
9204
|
+
}
|
|
9205
|
+
const entity = response.data.market.entity;
|
|
9206
|
+
if (entity === null || entity === void 0) {
|
|
9207
|
+
return unresolvedTicker(
|
|
9208
|
+
input,
|
|
9209
|
+
kind,
|
|
9210
|
+
"NOT_FOUND",
|
|
9211
|
+
`no entity found for ticker: ${input}`
|
|
9212
|
+
);
|
|
9213
|
+
}
|
|
9214
|
+
if (!record3(entity)) return invalidResponse3(field);
|
|
9215
|
+
const viewerState = entity.viewerState;
|
|
9216
|
+
if (viewerState === null || viewerState === void 0) {
|
|
9217
|
+
throw new AlvaError(
|
|
9218
|
+
"PERMISSION_DENIED",
|
|
9219
|
+
"This credential cannot read the user's watchlist",
|
|
9220
|
+
403
|
|
9221
|
+
);
|
|
9222
|
+
}
|
|
9223
|
+
if (!record3(viewerState) || typeof viewerState.isFollowed !== "boolean") {
|
|
9224
|
+
return invalidResponse3(field);
|
|
9225
|
+
}
|
|
9226
|
+
return {
|
|
9227
|
+
ok: true,
|
|
9228
|
+
inWatchlist: viewerState.isFollowed,
|
|
9229
|
+
ticker: {
|
|
9230
|
+
input,
|
|
9231
|
+
entityId: requireString(entity.id, field),
|
|
9232
|
+
ticker: requireString(entity.ticker, field),
|
|
9233
|
+
name: typeof entity.name === "string" ? entity.name : "",
|
|
9234
|
+
kind: requireString(entity.kind, field)
|
|
9235
|
+
}
|
|
9236
|
+
};
|
|
9237
|
+
}
|
|
9238
|
+
};
|
|
9239
|
+
|
|
8778
9240
|
// src/resources/alerts.ts
|
|
8779
9241
|
var AlertsResource = class {
|
|
8780
9242
|
constructor(client) {
|
|
@@ -9446,7 +9908,8 @@ var MarketsResource = class {
|
|
|
9446
9908
|
}
|
|
9447
9909
|
selectPeriod(catalog, event, ticker) {
|
|
9448
9910
|
if (event === "latest-completed") {
|
|
9449
|
-
|
|
9911
|
+
const completed = catalog.periods.filter((period) => period.status === "COMPLETED").sort((a, b) => b.earningsDate.localeCompare(a.earningsDate));
|
|
9912
|
+
if (completed.length > 0) return completed[0];
|
|
9450
9913
|
} else {
|
|
9451
9914
|
const upcoming = catalog.periods.filter((period) => period.status === "UPCOMING").sort((a, b) => a.earningsDate.localeCompare(b.earningsDate));
|
|
9452
9915
|
if (upcoming.length > 0) return upcoming[0];
|
|
@@ -9542,7 +10005,7 @@ var SCHEDULE_NAME = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
|
9542
10005
|
var RFC3339 = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(Z|[+-](\d{2}):(\d{2}))$/i;
|
|
9543
10006
|
var RFC3339_FRACTIONAL = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d{1,9})?(Z|[+-](\d{2}):(\d{2}))$/i;
|
|
9544
10007
|
var ISO_DURATION = /^P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;
|
|
9545
|
-
var
|
|
10008
|
+
var GRAPHQL_STATUS_BY_CODE3 = {
|
|
9546
10009
|
INVALID_ARGUMENT: 400,
|
|
9547
10010
|
UNAUTHENTICATED: 401,
|
|
9548
10011
|
PERMISSION_DENIED: 403,
|
|
@@ -9644,7 +10107,7 @@ var SchedulesResource = class {
|
|
|
9644
10107
|
const codes = response.errors.map((error) => error.extensions?.code);
|
|
9645
10108
|
const distinctCodes = new Set(codes);
|
|
9646
10109
|
const canonicalCode = distinctCodes.size === 1 && typeof codes[0] === "string" ? codes[0] : void 0;
|
|
9647
|
-
const canonicalStatus = canonicalCode ?
|
|
10110
|
+
const canonicalStatus = canonicalCode ? GRAPHQL_STATUS_BY_CODE3[canonicalCode] : void 0;
|
|
9648
10111
|
const errorCode = canonicalCode !== void 0 && canonicalStatus !== void 0 ? canonicalCode : "GRAPHQL_ERROR";
|
|
9649
10112
|
throw new AlvaError(
|
|
9650
10113
|
errorCode,
|
|
@@ -9896,7 +10359,7 @@ function scheduleEmptyResponse() {
|
|
|
9896
10359
|
}
|
|
9897
10360
|
|
|
9898
10361
|
// src/resources/steward.ts
|
|
9899
|
-
var
|
|
10362
|
+
var GRAPHQL_STATUS_BY_CODE4 = {
|
|
9900
10363
|
INVALID_ARGUMENT: 400,
|
|
9901
10364
|
UNAUTHENTICATED: 401,
|
|
9902
10365
|
PERMISSION_DENIED: 403,
|
|
@@ -9941,12 +10404,47 @@ var BRIEFED = `
|
|
|
9941
10404
|
mutation ToolkitStewardBriefed($input: CompleteStewardBriefInput!) {
|
|
9942
10405
|
completeStewardBrief(input: $input) { ok }
|
|
9943
10406
|
}`.trim();
|
|
10407
|
+
var DIGEST_RUN_FIELDS = `
|
|
10408
|
+
digestRunId state scheduleId scheduleVersion occurrenceIndex
|
|
10409
|
+
windowSinceMs windowUntilMs scanCompletedAtMs bodySha256 coverageSha256
|
|
10410
|
+
channelMessageId attempts lastError startedAtMs completedAtMs sendUncertainAtMs
|
|
10411
|
+
`.trim();
|
|
10412
|
+
var DIGEST_RUN = `
|
|
10413
|
+
query ToolkitStewardDigestRun($inboxPath: String!, $digestRunId: String!) {
|
|
10414
|
+
viewer { stewardDigestRun(inboxPath: $inboxPath, digestRunId: $digestRunId) { ${DIGEST_RUN_FIELDS} } }
|
|
10415
|
+
}`.trim();
|
|
10416
|
+
var DIGEST_RUN_PENDING = `
|
|
10417
|
+
query ToolkitStewardDigestRunPending($inboxPath: String!, $digestRunId: String!, $input: StewardDigestRunPendingInput) {
|
|
10418
|
+
viewer {
|
|
10419
|
+
stewardDigestRunPending(inboxPath: $inboxPath, digestRunId: $digestRunId, input: $input) {
|
|
10420
|
+
edges {
|
|
10421
|
+
node { deliveryId feedEntryId source { kind id } decisionReason consumedAtMs alertSnapshot }
|
|
10422
|
+
}
|
|
10423
|
+
pageInfo { hasNextPage endCursor }
|
|
10424
|
+
}
|
|
10425
|
+
}
|
|
10426
|
+
}`.trim();
|
|
10427
|
+
var PUBLISH_DAILY_BRIEF = `
|
|
10428
|
+
mutation ToolkitStewardPublishDailyBrief($input: PublishStewardDailyBriefInput!) {
|
|
10429
|
+
publishStewardDailyBrief(input: $input) { run { ${DIGEST_RUN_FIELDS} } }
|
|
10430
|
+
}`.trim();
|
|
9944
10431
|
var DECISIONS = /* @__PURE__ */ new Set([
|
|
9945
10432
|
"immediate",
|
|
9946
10433
|
"digest",
|
|
9947
10434
|
"suppress"
|
|
9948
10435
|
]);
|
|
9949
10436
|
var DELIVERY_ID = /^[1-9][0-9]{0,18}$/;
|
|
10437
|
+
var MAX_LEGACY_BRIEFED_IDS = 100;
|
|
10438
|
+
var MAX_DIGEST_RUN_COVERAGE = 1e4;
|
|
10439
|
+
var DIGEST_RUN_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
10440
|
+
var PENDING_ATTEMPTS = 3;
|
|
10441
|
+
var TRANSIENT_PENDING_CODES = /* @__PURE__ */ new Set([
|
|
10442
|
+
"NETWORK_ERROR",
|
|
10443
|
+
"NETWORK_TIMEOUT",
|
|
10444
|
+
"UNAVAILABLE",
|
|
10445
|
+
"DEADLINE_EXCEEDED"
|
|
10446
|
+
]);
|
|
10447
|
+
var TRANSIENT_HTTP_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
|
|
9950
10448
|
function invalid2(message) {
|
|
9951
10449
|
return new AlvaError("INVALID_ARGUMENT", message, 400);
|
|
9952
10450
|
}
|
|
@@ -10005,6 +10503,13 @@ function requireRequestId(value) {
|
|
|
10005
10503
|
throw invalid2("request id must be a UUID");
|
|
10006
10504
|
return value;
|
|
10007
10505
|
}
|
|
10506
|
+
function requireDigestRunId(value) {
|
|
10507
|
+
if (!DIGEST_RUN_ID.test(value)) throw invalid2("digest run id must be a UUID");
|
|
10508
|
+
return value.toLowerCase();
|
|
10509
|
+
}
|
|
10510
|
+
function isTransientStewardError(error) {
|
|
10511
|
+
return error instanceof AlvaError && (TRANSIENT_PENDING_CODES.has(error.code) || TRANSIENT_HTTP_STATUSES.has(error.status));
|
|
10512
|
+
}
|
|
10008
10513
|
function emptyResponse() {
|
|
10009
10514
|
return new AlvaError("EMPTY_RESPONSE", "steward response was empty", 502);
|
|
10010
10515
|
}
|
|
@@ -10067,6 +10572,56 @@ var StewardResource = class {
|
|
|
10067
10572
|
return message;
|
|
10068
10573
|
}
|
|
10069
10574
|
async pending(params) {
|
|
10575
|
+
if (params.after !== void 0) return this.pendingPage(params);
|
|
10576
|
+
const items = [];
|
|
10577
|
+
const deliveryIds = /* @__PURE__ */ new Set();
|
|
10578
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
10579
|
+
let after;
|
|
10580
|
+
let windowSinceMs;
|
|
10581
|
+
let windowUntilMs;
|
|
10582
|
+
do {
|
|
10583
|
+
const page = await this.pendingPageWithRetry({
|
|
10584
|
+
...params,
|
|
10585
|
+
after,
|
|
10586
|
+
sinceMs: after === void 0 ? params.sinceMs : void 0,
|
|
10587
|
+
untilMs: after === void 0 ? params.untilMs : void 0
|
|
10588
|
+
});
|
|
10589
|
+
if (windowSinceMs === void 0) {
|
|
10590
|
+
windowSinceMs = page.windowSinceMs;
|
|
10591
|
+
windowUntilMs = page.windowUntilMs;
|
|
10592
|
+
} else if (page.windowSinceMs !== windowSinceMs || page.windowUntilMs !== windowUntilMs) {
|
|
10593
|
+
throw new AlvaError(
|
|
10594
|
+
"ABORTED",
|
|
10595
|
+
"steward pending window changed during pagination",
|
|
10596
|
+
409
|
|
10597
|
+
);
|
|
10598
|
+
}
|
|
10599
|
+
for (const item of page.items) {
|
|
10600
|
+
if (deliveryIds.has(item.deliveryId)) continue;
|
|
10601
|
+
deliveryIds.add(item.deliveryId);
|
|
10602
|
+
items.push(item);
|
|
10603
|
+
}
|
|
10604
|
+
after = page.nextCursor ?? void 0;
|
|
10605
|
+
if (after !== void 0) {
|
|
10606
|
+
if (cursors.has(after)) {
|
|
10607
|
+
throw new AlvaError(
|
|
10608
|
+
"INTERNAL",
|
|
10609
|
+
"steward pending pagination loop detected",
|
|
10610
|
+
500
|
|
10611
|
+
);
|
|
10612
|
+
}
|
|
10613
|
+
cursors.add(after);
|
|
10614
|
+
}
|
|
10615
|
+
} while (after !== void 0);
|
|
10616
|
+
if (windowSinceMs === void 0 || windowUntilMs === void 0)
|
|
10617
|
+
throw emptyResponse();
|
|
10618
|
+
return {
|
|
10619
|
+
items,
|
|
10620
|
+
windowSinceMs,
|
|
10621
|
+
windowUntilMs
|
|
10622
|
+
};
|
|
10623
|
+
}
|
|
10624
|
+
async pendingPage(params) {
|
|
10070
10625
|
this.client._requireAuth();
|
|
10071
10626
|
const first = params.first ?? 50;
|
|
10072
10627
|
if (!Number.isInteger(first) || first < 1 || first > 100)
|
|
@@ -10095,7 +10650,14 @@ var StewardResource = class {
|
|
|
10095
10650
|
if (!Number.isSafeInteger(windowSinceMs) || !Number.isSafeInteger(windowUntilMs) || windowSinceMs <= 0 || windowUntilMs <= windowSinceMs)
|
|
10096
10651
|
throw emptyResponse();
|
|
10097
10652
|
const items = page.edges.map((edge) => edge.node);
|
|
10098
|
-
const
|
|
10653
|
+
const pageInfo2 = page.pageInfo;
|
|
10654
|
+
if (!pageInfo2 || typeof pageInfo2.hasNextPage !== "boolean")
|
|
10655
|
+
throw emptyResponse();
|
|
10656
|
+
const endCursor = pageInfo2.endCursor;
|
|
10657
|
+
if (endCursor !== void 0 && endCursor !== null && typeof endCursor !== "string")
|
|
10658
|
+
throw emptyResponse();
|
|
10659
|
+
if (pageInfo2.hasNextPage && !endCursor) throw emptyResponse();
|
|
10660
|
+
const nextCursor2 = pageInfo2.hasNextPage ? endCursor : null;
|
|
10099
10661
|
return {
|
|
10100
10662
|
items,
|
|
10101
10663
|
nextCursor: nextCursor2,
|
|
@@ -10103,20 +10665,95 @@ var StewardResource = class {
|
|
|
10103
10665
|
windowUntilMs
|
|
10104
10666
|
};
|
|
10105
10667
|
}
|
|
10668
|
+
async pendingPageWithRetry(params) {
|
|
10669
|
+
for (let attempt = 1; attempt < PENDING_ATTEMPTS; attempt += 1) {
|
|
10670
|
+
try {
|
|
10671
|
+
return await this.pendingPage(params);
|
|
10672
|
+
} catch (error) {
|
|
10673
|
+
if (!isTransientStewardError(error)) throw error;
|
|
10674
|
+
}
|
|
10675
|
+
}
|
|
10676
|
+
return this.pendingPage(params);
|
|
10677
|
+
}
|
|
10106
10678
|
async briefed(params) {
|
|
10107
10679
|
this.client._requireAuth();
|
|
10108
10680
|
const digestRunId = params.digestRunId?.trim();
|
|
10109
10681
|
if (!digestRunId) throw invalid2("a digest run id is required");
|
|
10682
|
+
const inboxPath = requireInboxPath(params);
|
|
10683
|
+
const deliveryIds = requireDeliveryIds(params.deliveryIds);
|
|
10684
|
+
if (deliveryIds.length > MAX_LEGACY_BRIEFED_IDS)
|
|
10685
|
+
throw invalid2("legacy briefed accepts at most 100 delivery ids");
|
|
10110
10686
|
const data = await this.graphql(BRIEFED, {
|
|
10111
10687
|
input: {
|
|
10112
|
-
inboxPath
|
|
10113
|
-
deliveryIds
|
|
10688
|
+
inboxPath,
|
|
10689
|
+
deliveryIds,
|
|
10114
10690
|
digestRunId
|
|
10115
10691
|
}
|
|
10116
10692
|
});
|
|
10117
10693
|
if (data.completeStewardBrief?.ok !== true) throw emptyResponse();
|
|
10118
10694
|
return { ok: true };
|
|
10119
10695
|
}
|
|
10696
|
+
async digestRun(params) {
|
|
10697
|
+
this.client._requireAuth();
|
|
10698
|
+
const data = await this.graphql(DIGEST_RUN, {
|
|
10699
|
+
inboxPath: requireInboxPath(params),
|
|
10700
|
+
digestRunId: requireDigestRunId(params.digestRunId)
|
|
10701
|
+
});
|
|
10702
|
+
const run = data.viewer?.stewardDigestRun;
|
|
10703
|
+
if (!run) throw emptyResponse();
|
|
10704
|
+
return run;
|
|
10705
|
+
}
|
|
10706
|
+
async digestRunPending(params) {
|
|
10707
|
+
this.client._requireAuth();
|
|
10708
|
+
const inboxPath = requireInboxPath(params);
|
|
10709
|
+
const digestRunId = requireDigestRunId(params.digestRunId);
|
|
10710
|
+
const items = [];
|
|
10711
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
10712
|
+
let after;
|
|
10713
|
+
for (; ; ) {
|
|
10714
|
+
const data = await this.graphql(DIGEST_RUN_PENDING, {
|
|
10715
|
+
inboxPath,
|
|
10716
|
+
digestRunId,
|
|
10717
|
+
input: { first: 100, ...after === void 0 ? {} : { after } }
|
|
10718
|
+
});
|
|
10719
|
+
const connection2 = data.viewer?.stewardDigestRunPending;
|
|
10720
|
+
if (!connection2 || !Array.isArray(connection2.edges))
|
|
10721
|
+
throw emptyResponse();
|
|
10722
|
+
const pageInfo2 = connection2.pageInfo;
|
|
10723
|
+
if (!pageInfo2 || typeof pageInfo2.hasNextPage !== "boolean")
|
|
10724
|
+
throw emptyResponse();
|
|
10725
|
+
for (const edge of connection2.edges) {
|
|
10726
|
+
if (!edge?.node) throw emptyResponse();
|
|
10727
|
+
items.push(edge.node);
|
|
10728
|
+
}
|
|
10729
|
+
if (!pageInfo2.hasNextPage) break;
|
|
10730
|
+
const next = pageInfo2.endCursor;
|
|
10731
|
+
if (typeof next !== "string" || next === "" || seenCursors.has(next))
|
|
10732
|
+
throw emptyResponse();
|
|
10733
|
+
seenCursors.add(next);
|
|
10734
|
+
after = next;
|
|
10735
|
+
}
|
|
10736
|
+
return items;
|
|
10737
|
+
}
|
|
10738
|
+
async sendDigestRun(params) {
|
|
10739
|
+
this.client._requireAuth();
|
|
10740
|
+
const deliveryIds = normalizeDeliveryIds(params.deliveryIds ?? []);
|
|
10741
|
+
if (deliveryIds.length > MAX_DIGEST_RUN_COVERAGE)
|
|
10742
|
+
throw invalid2("durable Daily Brief accepts at most 10000 delivery ids");
|
|
10743
|
+
if (params.body !== void 0 && params.body.trim() === "")
|
|
10744
|
+
throw invalid2("a message body must be non-blank when provided");
|
|
10745
|
+
const data = await this.graphql(PUBLISH_DAILY_BRIEF, {
|
|
10746
|
+
input: {
|
|
10747
|
+
inboxPath: requireInboxPath(params),
|
|
10748
|
+
digestRunId: requireDigestRunId(params.digestRunId),
|
|
10749
|
+
deliveryIds,
|
|
10750
|
+
...params.body === void 0 ? {} : { body: params.body }
|
|
10751
|
+
}
|
|
10752
|
+
});
|
|
10753
|
+
const run = data.publishStewardDailyBrief?.run;
|
|
10754
|
+
if (!run) throw emptyResponse();
|
|
10755
|
+
return run;
|
|
10756
|
+
}
|
|
10120
10757
|
async graphql(query, variables) {
|
|
10121
10758
|
const response = await this.client._request("POST", "/query", {
|
|
10122
10759
|
body: { query, variables }
|
|
@@ -10125,7 +10762,7 @@ var StewardResource = class {
|
|
|
10125
10762
|
if (response.errors?.length) {
|
|
10126
10763
|
const codes = response.errors.map((error) => error.extensions?.code);
|
|
10127
10764
|
const canonicalCode = new Set(codes).size === 1 && typeof codes[0] === "string" ? codes[0] : void 0;
|
|
10128
|
-
const canonicalStatus = canonicalCode ?
|
|
10765
|
+
const canonicalStatus = canonicalCode ? GRAPHQL_STATUS_BY_CODE4[canonicalCode] : void 0;
|
|
10129
10766
|
throw new AlvaError(
|
|
10130
10767
|
canonicalCode !== void 0 && canonicalStatus !== void 0 ? canonicalCode : "GRAPHQL_ERROR",
|
|
10131
10768
|
response.errors.map((error) => error.message).filter((message) => typeof message === "string").join("; ") || "GraphQL request failed",
|
|
@@ -10241,12 +10878,12 @@ function dedupe(candidates) {
|
|
|
10241
10878
|
});
|
|
10242
10879
|
}
|
|
10243
10880
|
function resolveFilters(params) {
|
|
10244
|
-
const
|
|
10881
|
+
const record4 = isRecord(params) ? params : {};
|
|
10245
10882
|
return {
|
|
10246
|
-
market: typeof
|
|
10247
|
-
instrumentType: typeof
|
|
10248
|
-
underlyingType: typeof
|
|
10249
|
-
quote: typeof
|
|
10883
|
+
market: typeof record4.market === "string" ? record4.market : void 0,
|
|
10884
|
+
instrumentType: typeof record4.instrumentType === "string" ? record4.instrumentType : void 0,
|
|
10885
|
+
underlyingType: typeof record4.underlyingType === "string" ? record4.underlyingType : void 0,
|
|
10886
|
+
quote: typeof record4.quote === "string" ? record4.quote : void 0
|
|
10250
10887
|
};
|
|
10251
10888
|
}
|
|
10252
10889
|
function pairSearchParams(pair, params) {
|
|
@@ -10294,11 +10931,11 @@ var TradingPairsResource = class {
|
|
|
10294
10931
|
return { query, candidates };
|
|
10295
10932
|
}
|
|
10296
10933
|
async resolve(params) {
|
|
10297
|
-
const
|
|
10298
|
-
const pair = typeof
|
|
10934
|
+
const record4 = isRecord(params) ? params : {};
|
|
10935
|
+
const pair = typeof record4.pair === "string" ? record4.pair.trim() : void 0;
|
|
10299
10936
|
const filters = resolveFilters(params);
|
|
10300
10937
|
const searchParams = pair === void 0 ? {
|
|
10301
|
-
symbol: typeof
|
|
10938
|
+
symbol: typeof record4.symbol === "string" ? record4.symbol : "",
|
|
10302
10939
|
...filters
|
|
10303
10940
|
} : pairSearchParams(pair, filters);
|
|
10304
10941
|
const result = await this.search(searchParams);
|
|
@@ -10618,19 +11255,19 @@ var ThesesResource = class {
|
|
|
10618
11255
|
const viewer = isRecord2(data) ? data.viewer : void 0;
|
|
10619
11256
|
const result = isRecord2(viewer) ? viewer.thesisAssetCandidates : void 0;
|
|
10620
11257
|
if (!isRecord2(result) || !Array.isArray(result.mentions)) {
|
|
10621
|
-
throw
|
|
11258
|
+
throw invalidResponse4("asset candidates response must contain mentions");
|
|
10622
11259
|
}
|
|
10623
11260
|
const mentions = result.mentions.map((item, index) => {
|
|
10624
11261
|
if (!isRecord2(item) || typeof item.quote !== "string" || typeof item.ticker !== "string" || !["RESOLVED", "AMBIGUOUS", "UNRESOLVED"].includes(
|
|
10625
11262
|
item.resolution
|
|
10626
11263
|
) || !["UNKNOWN", "BULLISH", "BEARISH"].includes(item.stance) || !Array.isArray(item.candidates)) {
|
|
10627
|
-
throw
|
|
11264
|
+
throw invalidResponse4(`asset mention ${index} is invalid`);
|
|
10628
11265
|
}
|
|
10629
11266
|
const candidates = item.candidates.map((candidate) => {
|
|
10630
11267
|
if (!isRecord2(candidate) || typeof candidate.ticker !== "string" || typeof candidate.name !== "string" || !["STOCK", "ETF", "CRYPTO", "INDEX"].includes(
|
|
10631
11268
|
candidate.kind
|
|
10632
11269
|
)) {
|
|
10633
|
-
throw
|
|
11270
|
+
throw invalidResponse4(`asset mention ${index} has invalid candidate`);
|
|
10634
11271
|
}
|
|
10635
11272
|
return {
|
|
10636
11273
|
entityId: responseID(
|
|
@@ -10660,7 +11297,7 @@ var ThesesResource = class {
|
|
|
10660
11297
|
await this.client._request("GET", `/api/v1/theses/${thesisID}`)
|
|
10661
11298
|
);
|
|
10662
11299
|
if (response.thesis.id !== thesisID) {
|
|
10663
|
-
throw
|
|
11300
|
+
throw invalidResponse4("get response must match the requested thesis");
|
|
10664
11301
|
}
|
|
10665
11302
|
return response;
|
|
10666
11303
|
}
|
|
@@ -10675,7 +11312,7 @@ var ThesesResource = class {
|
|
|
10675
11312
|
)
|
|
10676
11313
|
);
|
|
10677
11314
|
if (response.thesis.id !== thesisID || response.thesis.author_version_id !== versionID) {
|
|
10678
|
-
throw
|
|
11315
|
+
throw invalidResponse4(
|
|
10679
11316
|
"version response must match the requested thesis and author version"
|
|
10680
11317
|
);
|
|
10681
11318
|
}
|
|
@@ -10698,12 +11335,12 @@ var ThesesResource = class {
|
|
|
10698
11335
|
}
|
|
10699
11336
|
);
|
|
10700
11337
|
if (!isRecord2(response) || !Array.isArray(response.versions) || typeof response.next_cursor !== "string")
|
|
10701
|
-
throw
|
|
11338
|
+
throw invalidResponse4("invalid Update list");
|
|
10702
11339
|
const versions = response.versions.map(
|
|
10703
11340
|
(value) => thesisResponse({ thesis: value }).thesis
|
|
10704
11341
|
);
|
|
10705
11342
|
if (versions.some((version) => version.id !== thesisID))
|
|
10706
|
-
throw
|
|
11343
|
+
throw invalidResponse4("Update list must match requested Thesis");
|
|
10707
11344
|
return { versions, next_cursor: response.next_cursor };
|
|
10708
11345
|
}
|
|
10709
11346
|
/** Deletes only the selected Update; never falls back to whole-Thesis deletion. */
|
|
@@ -10725,7 +11362,7 @@ var ThesesResource = class {
|
|
|
10725
11362
|
)
|
|
10726
11363
|
);
|
|
10727
11364
|
if (response.thesis.id !== thesisID)
|
|
10728
|
-
throw
|
|
11365
|
+
throw invalidResponse4(
|
|
10729
11366
|
"delete Update response must match requested Thesis"
|
|
10730
11367
|
);
|
|
10731
11368
|
return response;
|
|
@@ -10764,7 +11401,7 @@ var ThesesResource = class {
|
|
|
10764
11401
|
})
|
|
10765
11402
|
);
|
|
10766
11403
|
if (response.thesis.id !== thesisID) {
|
|
10767
|
-
throw
|
|
11404
|
+
throw invalidResponse4("update response must match the requested thesis");
|
|
10768
11405
|
}
|
|
10769
11406
|
return response;
|
|
10770
11407
|
}
|
|
@@ -10786,7 +11423,7 @@ var ThesesResource = class {
|
|
|
10786
11423
|
current.thesis.entity_ids,
|
|
10787
11424
|
current.thesis.entity_stances
|
|
10788
11425
|
)) {
|
|
10789
|
-
throw
|
|
11426
|
+
throw invalidResponse4(
|
|
10790
11427
|
"archive requires one entity_stance for every Thesis entity"
|
|
10791
11428
|
);
|
|
10792
11429
|
}
|
|
@@ -10803,7 +11440,7 @@ var ThesesResource = class {
|
|
|
10803
11440
|
note: params.note
|
|
10804
11441
|
});
|
|
10805
11442
|
if (response.thesis.id !== thesisID || response.thesis.archived !== params.archived) {
|
|
10806
|
-
throw
|
|
11443
|
+
throw invalidResponse4("archive response must match the requested state");
|
|
10807
11444
|
}
|
|
10808
11445
|
return response;
|
|
10809
11446
|
}
|
|
@@ -10818,15 +11455,15 @@ var ThesesResource = class {
|
|
|
10818
11455
|
});
|
|
10819
11456
|
const result = data.setThesisStarred;
|
|
10820
11457
|
if (!isRecord2(result) || !isRecord2(result.stats) || !isRecord2(result.viewerState)) {
|
|
10821
|
-
throw
|
|
11458
|
+
throw invalidResponse4("star response must contain stats and viewerState");
|
|
10822
11459
|
}
|
|
10823
11460
|
const returnedID = responseID(result.thesisId, "thesisId");
|
|
10824
11461
|
if (returnedID !== thesisID) {
|
|
10825
|
-
throw
|
|
11462
|
+
throw invalidResponse4("star response must match the requested thesis");
|
|
10826
11463
|
}
|
|
10827
11464
|
const starCount = result.stats.starCount;
|
|
10828
11465
|
if (typeof starCount !== "number" || !Number.isInteger(starCount) || starCount < 0) {
|
|
10829
|
-
throw
|
|
11466
|
+
throw invalidResponse4(
|
|
10830
11467
|
"star response must contain a nonnegative star count"
|
|
10831
11468
|
);
|
|
10832
11469
|
}
|
|
@@ -10835,7 +11472,7 @@ var ThesesResource = class {
|
|
|
10835
11472
|
"viewerState.isStarred"
|
|
10836
11473
|
);
|
|
10837
11474
|
if (returnedStarred !== isStarred) {
|
|
10838
|
-
throw
|
|
11475
|
+
throw invalidResponse4("star response did not apply the requested state");
|
|
10839
11476
|
}
|
|
10840
11477
|
return {
|
|
10841
11478
|
thesis_id: returnedID,
|
|
@@ -10854,7 +11491,7 @@ var ThesesResource = class {
|
|
|
10854
11491
|
});
|
|
10855
11492
|
const result = data.setThesisSignalEnabled;
|
|
10856
11493
|
if (!isRecord2(result) || !isRecord2(result.publication)) {
|
|
10857
|
-
throw
|
|
11494
|
+
throw invalidResponse4("Signal response must contain publication");
|
|
10858
11495
|
}
|
|
10859
11496
|
const publication = result.publication;
|
|
10860
11497
|
const returnedID = responseID(
|
|
@@ -10862,14 +11499,14 @@ var ThesesResource = class {
|
|
|
10862
11499
|
"publication.playbookId"
|
|
10863
11500
|
);
|
|
10864
11501
|
if (returnedID !== thesisID) {
|
|
10865
|
-
throw
|
|
11502
|
+
throw invalidResponse4("Signal response must match the requested thesis");
|
|
10866
11503
|
}
|
|
10867
11504
|
const researchPaused = responseBoolean(
|
|
10868
11505
|
publication.researchPaused,
|
|
10869
11506
|
"publication.researchPaused"
|
|
10870
11507
|
);
|
|
10871
11508
|
if (researchPaused === enabled) {
|
|
10872
|
-
throw
|
|
11509
|
+
throw invalidResponse4(
|
|
10873
11510
|
"Signal response did not apply the requested state"
|
|
10874
11511
|
);
|
|
10875
11512
|
}
|
|
@@ -10899,7 +11536,7 @@ var ThesesResource = class {
|
|
|
10899
11536
|
)
|
|
10900
11537
|
);
|
|
10901
11538
|
if (response.thesis.id !== thesisID || response.thesis.visibility !== visibility) {
|
|
10902
|
-
throw
|
|
11539
|
+
throw invalidResponse4(
|
|
10903
11540
|
"visibility response must match the requested thesis and visibility"
|
|
10904
11541
|
);
|
|
10905
11542
|
}
|
|
@@ -10930,7 +11567,7 @@ var ThesesResource = class {
|
|
|
10930
11567
|
);
|
|
10931
11568
|
if (response === void 0) return {};
|
|
10932
11569
|
if (!isRecord2(response) || Object.keys(response).length !== 0) {
|
|
10933
|
-
throw
|
|
11570
|
+
throw invalidResponse4("delete response must be {}");
|
|
10934
11571
|
}
|
|
10935
11572
|
return {};
|
|
10936
11573
|
}
|
|
@@ -10946,7 +11583,7 @@ var ThesesResource = class {
|
|
|
10946
11583
|
}
|
|
10947
11584
|
);
|
|
10948
11585
|
if (!isRecord2(response) || typeof response.body !== "string") {
|
|
10949
|
-
throw
|
|
11586
|
+
throw invalidResponse4("rewrite response must contain a string body");
|
|
10950
11587
|
}
|
|
10951
11588
|
return { body: responseBody(response.body) };
|
|
10952
11589
|
}
|
|
@@ -11042,7 +11679,7 @@ function updateBody(params) {
|
|
|
11042
11679
|
}
|
|
11043
11680
|
function thesisResponse(response) {
|
|
11044
11681
|
if (!isRecord2(response) || !isRecord2(response.thesis)) {
|
|
11045
|
-
throw
|
|
11682
|
+
throw invalidResponse4("response must contain thesis");
|
|
11046
11683
|
}
|
|
11047
11684
|
const thesis = response.thesis;
|
|
11048
11685
|
const value = {
|
|
@@ -11067,10 +11704,10 @@ function thesisResponse(response) {
|
|
|
11067
11704
|
};
|
|
11068
11705
|
if (thesis.medias !== void 0) {
|
|
11069
11706
|
if (!Array.isArray(thesis.medias) || thesis.medias.length > 20)
|
|
11070
|
-
throw
|
|
11707
|
+
throw invalidResponse4("thesis.medias must contain at most 20 items");
|
|
11071
11708
|
value.medias = thesis.medias.map((item) => {
|
|
11072
11709
|
if (!validMedia(item))
|
|
11073
|
-
throw
|
|
11710
|
+
throw invalidResponse4("thesis.medias contains invalid media");
|
|
11074
11711
|
return {
|
|
11075
11712
|
type: item.type,
|
|
11076
11713
|
cover_url: item.cover_url,
|
|
@@ -11087,15 +11724,15 @@ function thesisResponse(response) {
|
|
|
11087
11724
|
value.note = responseText(thesis.note, "thesis.note");
|
|
11088
11725
|
if (thesis.entity_stances !== void 0) {
|
|
11089
11726
|
if (!Array.isArray(thesis.entity_stances))
|
|
11090
|
-
throw
|
|
11727
|
+
throw invalidResponse4("thesis.entity_stances must be an array");
|
|
11091
11728
|
value.entity_stances = thesis.entity_stances.map((item) => {
|
|
11092
11729
|
if (!isRecord2(item))
|
|
11093
|
-
throw
|
|
11730
|
+
throw invalidResponse4("thesis.entity_stances contains invalid entry");
|
|
11094
11731
|
const entityID = responseID(item.entity_id, "entity_stances.entity_id");
|
|
11095
11732
|
if (!value.entity_ids.includes(entityID))
|
|
11096
|
-
throw
|
|
11733
|
+
throw invalidResponse4("entity stance must reference a thesis entity");
|
|
11097
11734
|
if (!["unknown", "bullish", "bearish"].includes(item.stance))
|
|
11098
|
-
throw
|
|
11735
|
+
throw invalidResponse4("thesis.entity_stances contains invalid stance");
|
|
11099
11736
|
return { entity_id: entityID, stance: item.stance };
|
|
11100
11737
|
});
|
|
11101
11738
|
}
|
|
@@ -11104,7 +11741,7 @@ function thesisResponse(response) {
|
|
|
11104
11741
|
function thesisGetResponse(response) {
|
|
11105
11742
|
const base = thesisResponse(response);
|
|
11106
11743
|
if (!isRecord2(response) || !isRecord2(response.author)) {
|
|
11107
|
-
throw
|
|
11744
|
+
throw invalidResponse4("response must contain author");
|
|
11108
11745
|
}
|
|
11109
11746
|
const authorRecord = response.author;
|
|
11110
11747
|
const author = {
|
|
@@ -11118,14 +11755,14 @@ function thesisGetResponse(response) {
|
|
|
11118
11755
|
username: responseText(authorRecord.username, "author.username")
|
|
11119
11756
|
};
|
|
11120
11757
|
if (!Array.isArray(response.entities)) {
|
|
11121
|
-
throw
|
|
11758
|
+
throw invalidResponse4("response must contain entities");
|
|
11122
11759
|
}
|
|
11123
11760
|
if (response.entities.length !== base.thesis.entity_ids.length) {
|
|
11124
|
-
throw
|
|
11761
|
+
throw invalidResponse4("entities must match thesis.entity_ids");
|
|
11125
11762
|
}
|
|
11126
11763
|
const entities = response.entities.map((item, index) => {
|
|
11127
11764
|
if (!isRecord2(item))
|
|
11128
|
-
throw
|
|
11765
|
+
throw invalidResponse4(`entities[${index}] must be an object`);
|
|
11129
11766
|
const entity = {
|
|
11130
11767
|
id: responseID(item.id, `entities[${index}].id`),
|
|
11131
11768
|
ticker: responseText(item.ticker, `entities[${index}].ticker`),
|
|
@@ -11134,7 +11771,7 @@ function thesisGetResponse(response) {
|
|
|
11134
11771
|
kind: responseText(item.kind, `entities[${index}].kind`)
|
|
11135
11772
|
};
|
|
11136
11773
|
if (entity.id !== base.thesis.entity_ids[index]) {
|
|
11137
|
-
throw
|
|
11774
|
+
throw invalidResponse4("entities must preserve thesis.entity_ids order");
|
|
11138
11775
|
}
|
|
11139
11776
|
return entity;
|
|
11140
11777
|
});
|
|
@@ -11142,7 +11779,7 @@ function thesisGetResponse(response) {
|
|
|
11142
11779
|
}
|
|
11143
11780
|
function thesisSignalsResponse(response, thesisID, first) {
|
|
11144
11781
|
if (!isRecord2(response) || !isRecord2(response.research) || !Array.isArray(response.entries) || response.entries.length > first) {
|
|
11145
|
-
throw
|
|
11782
|
+
throw invalidResponse4("invalid Signal history response");
|
|
11146
11783
|
}
|
|
11147
11784
|
const research = response.research;
|
|
11148
11785
|
const status = {
|
|
@@ -11168,13 +11805,13 @@ function thesisSignalsResponse(response, thesisID, first) {
|
|
|
11168
11805
|
);
|
|
11169
11806
|
const entries = response.entries.map((raw) => {
|
|
11170
11807
|
if (!isRecord2(raw) || !isRecord2(raw.signal) || !isRecord2(raw.signal.source)) {
|
|
11171
|
-
throw
|
|
11808
|
+
throw invalidResponse4("entry must include a Signal and source");
|
|
11172
11809
|
}
|
|
11173
11810
|
const signal = raw.signal;
|
|
11174
11811
|
const source = signal.source;
|
|
11175
11812
|
const signalID = responseID(signal.thesis_id, "signal.thesis_id");
|
|
11176
11813
|
if (signalID !== thesisID)
|
|
11177
|
-
throw
|
|
11814
|
+
throw invalidResponse4("Signal belongs to another Thesis");
|
|
11178
11815
|
const cursor = responseNonemptyText(raw.cursor, "entry.cursor");
|
|
11179
11816
|
const mappedSource = {
|
|
11180
11817
|
title: responseText(source.title, "source.title")
|
|
@@ -11207,7 +11844,7 @@ function thesisSignalsResponse(response, thesisID, first) {
|
|
|
11207
11844
|
};
|
|
11208
11845
|
if (signal.evidence_excerpt !== void 0) {
|
|
11209
11846
|
if (!isRecord2(signal.evidence_excerpt))
|
|
11210
|
-
throw
|
|
11847
|
+
throw invalidResponse4("invalid evidence excerpt");
|
|
11211
11848
|
mappedSignal.evidence_excerpt = {
|
|
11212
11849
|
text: responseNonemptyText(
|
|
11213
11850
|
signal.evidence_excerpt.text,
|
|
@@ -11231,19 +11868,19 @@ function thesisSignalsResponse(response, thesisID, first) {
|
|
|
11231
11868
|
});
|
|
11232
11869
|
const nextCursor2 = responseText(response.next_cursor, "next_cursor");
|
|
11233
11870
|
if (nextCursor2 && nextCursor2 !== entries[entries.length - 1]?.cursor) {
|
|
11234
|
-
throw
|
|
11871
|
+
throw invalidResponse4("next_cursor must match the final entry");
|
|
11235
11872
|
}
|
|
11236
11873
|
return { research: status, entries, next_cursor: nextCursor2 };
|
|
11237
11874
|
}
|
|
11238
11875
|
function responseNonnegativeInteger(value, field) {
|
|
11239
11876
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
11240
|
-
throw
|
|
11877
|
+
throw invalidResponse4(field + " must be a nonnegative safe integer");
|
|
11241
11878
|
}
|
|
11242
11879
|
return value;
|
|
11243
11880
|
}
|
|
11244
11881
|
function responseNonemptyText(value, field) {
|
|
11245
11882
|
const valueText = responseText(value, field);
|
|
11246
|
-
if (!valueText.trim()) throw
|
|
11883
|
+
if (!valueText.trim()) throw invalidResponse4(field + " must be nonempty");
|
|
11247
11884
|
return valueText;
|
|
11248
11885
|
}
|
|
11249
11886
|
function requireRequestID(value) {
|
|
@@ -11334,20 +11971,20 @@ function requireText2(value, field) {
|
|
|
11334
11971
|
}
|
|
11335
11972
|
function responseID(value, field) {
|
|
11336
11973
|
if (typeof value === "number") {
|
|
11337
|
-
throw
|
|
11974
|
+
throw invalidResponse4(
|
|
11338
11975
|
`${field} must be a decimal string; numeric IDs are unsafe`
|
|
11339
11976
|
);
|
|
11340
11977
|
}
|
|
11341
11978
|
try {
|
|
11342
11979
|
return requireID(value, field);
|
|
11343
11980
|
} catch {
|
|
11344
|
-
throw
|
|
11981
|
+
throw invalidResponse4(`${field} must be a positive int64 decimal string`);
|
|
11345
11982
|
}
|
|
11346
11983
|
}
|
|
11347
11984
|
function responseIDs(value, field) {
|
|
11348
|
-
if (!Array.isArray(value)) throw
|
|
11985
|
+
if (!Array.isArray(value)) throw invalidResponse4(`${field} must be an array`);
|
|
11349
11986
|
if (value.length > MAX_ENTITY_IDS) {
|
|
11350
|
-
throw
|
|
11987
|
+
throw invalidResponse4(
|
|
11351
11988
|
`${field} must contain at most ${MAX_ENTITY_IDS} IDs`
|
|
11352
11989
|
);
|
|
11353
11990
|
}
|
|
@@ -11357,33 +11994,33 @@ function responseText(value, field) {
|
|
|
11357
11994
|
try {
|
|
11358
11995
|
return requireText2(value, field);
|
|
11359
11996
|
} catch {
|
|
11360
|
-
throw
|
|
11997
|
+
throw invalidResponse4(`${field} must be valid text`);
|
|
11361
11998
|
}
|
|
11362
11999
|
}
|
|
11363
12000
|
function responseClosingNote(value) {
|
|
11364
12001
|
try {
|
|
11365
12002
|
return requireText2(value, "note");
|
|
11366
12003
|
} catch {
|
|
11367
|
-
throw
|
|
12004
|
+
throw invalidResponse4("thesis.closing_note must be valid text");
|
|
11368
12005
|
}
|
|
11369
12006
|
}
|
|
11370
12007
|
function responseBoolean(value, field) {
|
|
11371
12008
|
if (typeof value !== "boolean")
|
|
11372
|
-
throw
|
|
12009
|
+
throw invalidResponse4(`${field} must be boolean`);
|
|
11373
12010
|
return value;
|
|
11374
12011
|
}
|
|
11375
12012
|
function responseVisibility(value) {
|
|
11376
12013
|
try {
|
|
11377
12014
|
return requireVisibility(value);
|
|
11378
12015
|
} catch {
|
|
11379
|
-
throw
|
|
12016
|
+
throw invalidResponse4("thesis.visibility must be public, private or paid");
|
|
11380
12017
|
}
|
|
11381
12018
|
}
|
|
11382
12019
|
function responseBody(value) {
|
|
11383
12020
|
try {
|
|
11384
12021
|
return requireBody(value);
|
|
11385
12022
|
} catch {
|
|
11386
|
-
throw
|
|
12023
|
+
throw invalidResponse4(
|
|
11387
12024
|
"response body must be nonblank valid text at most 65536 UTF-8 bytes"
|
|
11388
12025
|
);
|
|
11389
12026
|
}
|
|
@@ -11392,7 +12029,7 @@ function responseTitle(value) {
|
|
|
11392
12029
|
try {
|
|
11393
12030
|
return requireTitle(value);
|
|
11394
12031
|
} catch {
|
|
11395
|
-
throw
|
|
12032
|
+
throw invalidResponse4(
|
|
11396
12033
|
"response title must be valid text at most 500 UTF-8 bytes"
|
|
11397
12034
|
);
|
|
11398
12035
|
}
|
|
@@ -11412,7 +12049,7 @@ function completeEntityStances(entityIDs, stances) {
|
|
|
11412
12049
|
function invalidArgument(message) {
|
|
11413
12050
|
return new AlvaError("INVALID_ARGUMENT", message, 400);
|
|
11414
12051
|
}
|
|
11415
|
-
function
|
|
12052
|
+
function invalidResponse4(message) {
|
|
11416
12053
|
return new AlvaError("INVALID_RESPONSE", message, 502);
|
|
11417
12054
|
}
|
|
11418
12055
|
function validMedia(item) {
|
|
@@ -11433,10 +12070,10 @@ async function thesisGraphql(client, query, variables) {
|
|
|
11433
12070
|
body: { query, variables }
|
|
11434
12071
|
});
|
|
11435
12072
|
if (!isRecord2(response))
|
|
11436
|
-
throw
|
|
12073
|
+
throw invalidResponse4("GraphQL response must be an object");
|
|
11437
12074
|
if (response.errors !== void 0) {
|
|
11438
12075
|
if (!Array.isArray(response.errors))
|
|
11439
|
-
throw
|
|
12076
|
+
throw invalidResponse4("GraphQL errors must be an array");
|
|
11440
12077
|
if (response.errors.length > 0) {
|
|
11441
12078
|
const messages = response.errors.flatMap(
|
|
11442
12079
|
(error) => isRecord2(error) && typeof error.message === "string" ? [error.message] : []
|
|
@@ -11458,7 +12095,7 @@ async function thesisGraphql(client, query, variables) {
|
|
|
11458
12095
|
}
|
|
11459
12096
|
}
|
|
11460
12097
|
if (!isRecord2(response.data))
|
|
11461
|
-
throw
|
|
12098
|
+
throw invalidResponse4("GraphQL response must contain data");
|
|
11462
12099
|
return response.data;
|
|
11463
12100
|
}
|
|
11464
12101
|
|
|
@@ -11468,7 +12105,7 @@ var CREATE_COMPANY_NEWS = `mutation CreateCompanyNews($input: CompanyNewsFeedInp
|
|
|
11468
12105
|
createFeed(input: $input) { id producer { id } }
|
|
11469
12106
|
}
|
|
11470
12107
|
}`;
|
|
11471
|
-
var
|
|
12108
|
+
var GRAPHQL_STATUS_BY_CODE5 = {
|
|
11472
12109
|
INVALID_ARGUMENT: 400,
|
|
11473
12110
|
UNAUTHENTICATED: 401,
|
|
11474
12111
|
PERMISSION_DENIED: 403,
|
|
@@ -11537,7 +12174,7 @@ var CompanyNewsResource = class {
|
|
|
11537
12174
|
throw new AlvaError(
|
|
11538
12175
|
code,
|
|
11539
12176
|
graph.errors.map((error) => error?.message).filter(Boolean).join("; ") || "Company News creation failed",
|
|
11540
|
-
|
|
12177
|
+
GRAPHQL_STATUS_BY_CODE5[code] ?? 502,
|
|
11541
12178
|
{ errors: graph.errors }
|
|
11542
12179
|
);
|
|
11543
12180
|
}
|
|
@@ -11663,6 +12300,7 @@ var AlvaClient = class {
|
|
|
11663
12300
|
_notifications;
|
|
11664
12301
|
_notificationPreferences;
|
|
11665
12302
|
_subscriptions;
|
|
12303
|
+
_follows;
|
|
11666
12304
|
_alerts;
|
|
11667
12305
|
_channelGroupSubscriptions;
|
|
11668
12306
|
_feedback;
|
|
@@ -11754,6 +12392,9 @@ var AlvaClient = class {
|
|
|
11754
12392
|
get subscriptions() {
|
|
11755
12393
|
return this._subscriptions ??= new SubscriptionsResource(this);
|
|
11756
12394
|
}
|
|
12395
|
+
get follows() {
|
|
12396
|
+
return this._follows ??= new FollowsResource(this);
|
|
12397
|
+
}
|
|
11757
12398
|
get alerts() {
|
|
11758
12399
|
return this._alerts ??= new AlertsResource(this);
|
|
11759
12400
|
}
|
|
@@ -12237,14 +12878,21 @@ var COMMAND_DEFINITIONS = [
|
|
|
12237
12878
|
values: ["inbox-path", "delivery-id", "request-id"]
|
|
12238
12879
|
}),
|
|
12239
12880
|
command("steward send", {
|
|
12240
|
-
values: [
|
|
12881
|
+
values: [
|
|
12882
|
+
"inbox-path",
|
|
12883
|
+
"body",
|
|
12884
|
+
"delivery-ids",
|
|
12885
|
+
"request-id",
|
|
12886
|
+
"digest-run-id"
|
|
12887
|
+
]
|
|
12241
12888
|
}),
|
|
12242
12889
|
command("steward pending", {
|
|
12243
|
-
values: ["inbox-path", "
|
|
12890
|
+
values: ["inbox-path", "since", "until", "first", "digest-run-id"]
|
|
12244
12891
|
}),
|
|
12245
12892
|
command("steward briefed", {
|
|
12246
12893
|
values: ["inbox-path", "delivery-ids", "digest-run-id"]
|
|
12247
12894
|
}),
|
|
12895
|
+
command("steward status", { values: ["inbox-path", "digest-run-id"] }),
|
|
12248
12896
|
command("company-news create", {
|
|
12249
12897
|
values: ["name", "tickers", "initial-lookback-hours", "page-size"]
|
|
12250
12898
|
}),
|
|
@@ -12610,9 +13258,18 @@ var COMMAND_DEFINITIONS = [
|
|
|
12610
13258
|
values: ["account-id", "limit", "page-token"]
|
|
12611
13259
|
}),
|
|
12612
13260
|
command("markets narrative", { values: ["ticker"] }),
|
|
13261
|
+
command("markets watchlist"),
|
|
13262
|
+
command("markets watchlist list", { values: ["limit", "cursor"] }),
|
|
13263
|
+
command("markets watchlist add", { values: ["tickers", "kind"] }),
|
|
13264
|
+
command("markets watchlist remove", { values: ["tickers", "kind"] }),
|
|
12613
13265
|
command("markets earnings", {
|
|
12614
13266
|
values: ["ticker", "event", "fiscal-year", "fiscal-quarter"]
|
|
12615
13267
|
}),
|
|
13268
|
+
command("people search", { values: ["query", "kind", "limit"] }),
|
|
13269
|
+
command("people follows"),
|
|
13270
|
+
command("people follows list", { values: ["kind", "limit", "cursor"] }),
|
|
13271
|
+
command("people follows follow", { values: ["kind", "id"] }),
|
|
13272
|
+
command("people follows unfollow", { values: ["kind", "id"] }),
|
|
12616
13273
|
command("trading-pairs search", {
|
|
12617
13274
|
values: [
|
|
12618
13275
|
"symbol",
|
|
@@ -16987,7 +17644,7 @@ function formatTradingPairResolved(result) {
|
|
|
16987
17644
|
}
|
|
16988
17645
|
|
|
16989
17646
|
// src/cli/dispatch.ts
|
|
16990
|
-
var CLI_VERSION = true ? "0.
|
|
17647
|
+
var CLI_VERSION = true ? "0.35.0" : "dev";
|
|
16991
17648
|
var DEFAULT_RUN_TIMEOUT_MS = 6e5;
|
|
16992
17649
|
var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
|
|
16993
17650
|
var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
|
|
@@ -17055,7 +17712,8 @@ Commands:
|
|
|
17055
17712
|
subscriptions Playbook follows and feed alert subscriptions
|
|
17056
17713
|
remix Save playbook remix lineage
|
|
17057
17714
|
portfolio Connected-account portfolio (accounts, summary, activities)
|
|
17058
|
-
markets Company
|
|
17715
|
+
markets Company context and the ticker watchlist (narrative, earnings, watchlist list|add|remove)
|
|
17716
|
+
people Search, follow, and unfollow Alva users and curated people (search, follows list|follow|unfollow)
|
|
17059
17717
|
trading-pairs Discover and strictly verify canonical trading pairs (search, resolve)
|
|
17060
17718
|
trading Trading operations (accounts, portfolio, orders, subscriptions, equity-history, risk-rules, subscribe, unsubscribe, execute, update-risk-rules)
|
|
17061
17719
|
broker Agentic order execution \u2014 venue-native passthrough to trex (accounts, quote, order, balance, positions, ...; run 'alva broker describe')
|
|
@@ -17110,31 +17768,30 @@ Embedded commands target the host-attached Inbox; the terminal CLI requires
|
|
|
17110
17768
|
Subcommands:
|
|
17111
17769
|
decide Record the decision for one delivery (required before forward/send)
|
|
17112
17770
|
forward Re-post the original alert card by reference (immediate only)
|
|
17113
|
-
|
|
17114
|
-
pending
|
|
17115
|
-
|
|
17771
|
+
status Read one durable Daily Brief run
|
|
17772
|
+
pending Read a durable run's complete fixed-window set, or use legacy bounds
|
|
17773
|
+
send Publish and complete a durable run, or use the legacy send contract
|
|
17774
|
+
briefed Record that a Daily Brief covered at most 100 listed deliveries
|
|
17116
17775
|
|
|
17117
17776
|
Flags:
|
|
17118
17777
|
--inbox-path <path> Steward Session Inbox (terminal CLI only)
|
|
17119
17778
|
--delivery-id <id> One delivery (decide, forward)
|
|
17120
|
-
--delivery-ids <a,b,c> Comma-separated deliveries (briefed; optional for send \u2014 omit for a For-You-only Brief)
|
|
17779
|
+
--delivery-ids <a,b,c> Comma-separated deliveries (legacy briefed: max 100; optional for send \u2014 omit for a For-You-only Brief)
|
|
17121
17780
|
--decision <immediate|digest|suppress>
|
|
17122
17781
|
--reason <text> Short audit note stored with the decision
|
|
17123
|
-
--body <markdown> Message body (send)
|
|
17782
|
+
--body <markdown> Message body (durable send: omit when reviewed coverage yields no useful content)
|
|
17124
17783
|
--request-id <uuid> Idempotency key; generated when omitted
|
|
17125
|
-
--
|
|
17126
|
-
--
|
|
17127
|
-
--
|
|
17128
|
-
--
|
|
17129
|
-
--digest-run-id <id> The request id echoed by the send that carried these deliveries (briefed)
|
|
17784
|
+
--since <RFC3339> Lower bound on decision time (pending)
|
|
17785
|
+
--until <RFC3339> Fixed upper bound of the Brief window (pending)
|
|
17786
|
+
--first <n> Internal page size, 1-100 (terminal pending only)
|
|
17787
|
+
--digest-run-id <uuid> Durable run identity (status/pending/send)
|
|
17130
17788
|
|
|
17131
17789
|
Examples (terminal; the embedded Agent tool omits --inbox-path):
|
|
17132
17790
|
alva steward decide --inbox-path /alva/home/alice/agents/steward-9/.pi/agent/sessions/main.inbox.jsonl --delivery-id 123 --decision immediate --reason "guidance cut 15%"
|
|
17133
17791
|
alva steward forward --inbox-path <inbox> --delivery-id 123
|
|
17134
|
-
alva steward
|
|
17135
|
-
alva steward
|
|
17136
|
-
alva steward
|
|
17137
|
-
alva steward pending --inbox-path <inbox> --after <nextCursor from the previous page>
|
|
17792
|
+
alva steward status --inbox-path <inbox> --digest-run-id <uuid>
|
|
17793
|
+
alva steward pending --inbox-path <inbox> --digest-run-id <uuid>
|
|
17794
|
+
alva steward send --inbox-path <inbox> --digest-run-id <uuid> --delivery-ids 124,125 --body "Daily Brief..."
|
|
17138
17795
|
alva steward briefed --inbox-path <inbox> --digest-run-id <request id echoed by send> --delivery-ids 124,125`,
|
|
17139
17796
|
configure: `Usage: alva configure --api-key <key> [--base-url <url>] [--profile <name>]
|
|
17140
17797
|
|
|
@@ -18279,6 +18936,8 @@ owners, feed slugs, versions, or paths.
|
|
|
18279
18936
|
Subcommands:
|
|
18280
18937
|
narrative Get the current narrative, history, and narrative change log
|
|
18281
18938
|
earnings Get Pre, Release, Transcript, and Post for one fiscal event
|
|
18939
|
+
watchlist list|add|remove
|
|
18940
|
+
The user's ticker watchlist in the Alva App
|
|
18282
18941
|
|
|
18283
18942
|
Narrative flags:
|
|
18284
18943
|
--ticker <symbol> Stock ticker (required)
|
|
@@ -18292,6 +18951,21 @@ Earnings flags:
|
|
|
18292
18951
|
Do not combine --event with --fiscal-year/--fiscal-quarter. These commands read
|
|
18293
18952
|
the current backend view; historical query-as-of gating is not supported yet.
|
|
18294
18953
|
|
|
18954
|
+
Watchlist flags:
|
|
18955
|
+
--tickers <A,B> add/remove: 1-50 exact symbols (required).
|
|
18956
|
+
Suffix one symbol with :stock, :etf, or
|
|
18957
|
+
:crypto to pick its kind (BTC:crypto)
|
|
18958
|
+
--kind <stock|etf|crypto> add/remove: default kind for unsuffixed symbols
|
|
18959
|
+
--limit <1-100> list: page size (default 20)
|
|
18960
|
+
--cursor <endCursor> list: pageInfo.endCursor of the previous page
|
|
18961
|
+
|
|
18962
|
+
add/remove write every resolved symbol in one atomic batch. Result groups:
|
|
18963
|
+
added|removed (written now), unchanged (already in that state), unresolved
|
|
18964
|
+
(NOT_FOUND, or FAILED_PRECONDITION = several entities share the symbol:
|
|
18965
|
+
retry it with a kind suffix). Nothing is written when no symbol resolves.
|
|
18966
|
+
remove is recorded even for symbols not in the watchlist, so holdings sync
|
|
18967
|
+
does not add them back; add re-adds a symbol the user removed earlier.
|
|
18968
|
+
|
|
18295
18969
|
Output semantics:
|
|
18296
18970
|
Narrative is dated Alva analysis. Use current for present-tense company
|
|
18297
18971
|
context and history only to explain changes; use separate sources for live
|
|
@@ -18309,7 +18983,32 @@ Examples:
|
|
|
18309
18983
|
alva markets narrative --ticker AAPL
|
|
18310
18984
|
alva markets earnings --ticker AAPL
|
|
18311
18985
|
alva markets earnings --ticker AAPL --event next-confirmed
|
|
18312
|
-
alva markets earnings --ticker AAPL --fiscal-year 2026 --fiscal-quarter Q3
|
|
18986
|
+
alva markets earnings --ticker AAPL --fiscal-year 2026 --fiscal-quarter Q3
|
|
18987
|
+
alva markets watchlist add --tickers NVDA,LMT,BTC:crypto
|
|
18988
|
+
alva markets watchlist list --limit 50`,
|
|
18989
|
+
people: `Usage: alva people <subcommand> [options]
|
|
18990
|
+
|
|
18991
|
+
Search and follow public profiles: USER is an Alva user, PERSON is a curated
|
|
18992
|
+
person. These change the same Following list the user sees in the Alva App.
|
|
18993
|
+
|
|
18994
|
+
Subcommands:
|
|
18995
|
+
search Prefix match on name, username, slug, or alias
|
|
18996
|
+
follows list List the profiles the caller follows
|
|
18997
|
+
follows follow Follow one profile (idempotent)
|
|
18998
|
+
follows unfollow Unfollow one profile (idempotent)
|
|
18999
|
+
|
|
19000
|
+
Flags:
|
|
19001
|
+
--query <text> search: name or username prefix (required)
|
|
19002
|
+
--kind <user|person> search/list: optional filter; follow/unfollow:
|
|
19003
|
+
required, from a search or list result
|
|
19004
|
+
--id <id> follow/unfollow: profile id (required)
|
|
19005
|
+
--limit <1-50> search/list: page size
|
|
19006
|
+
--cursor <endCursor> list: pageInfo.endCursor of the previous page
|
|
19007
|
+
|
|
19008
|
+
Examples:
|
|
19009
|
+
alva people search --query "cathie wood" --kind person
|
|
19010
|
+
alva people follows follow --kind person --id 42
|
|
19011
|
+
alva people follows list`,
|
|
18313
19012
|
"trading-pairs": `Usage: alva trading-pairs <subcommand> [options]
|
|
18314
19013
|
|
|
18315
19014
|
Discover canonical trading-pair identities before backtesting or trading.
|
|
@@ -18760,19 +19459,19 @@ function deliveryProviderFilter(flags, command2) {
|
|
|
18760
19459
|
}
|
|
18761
19460
|
return flags["delivery-provider"];
|
|
18762
19461
|
}
|
|
18763
|
-
function projectUserProfileForCLI(
|
|
18764
|
-
const { active_channel: activeIMProvider, ...profile } =
|
|
19462
|
+
function projectUserProfileForCLI(record4) {
|
|
19463
|
+
const { active_channel: activeIMProvider, ...profile } = record4;
|
|
18765
19464
|
return { ...profile, active_im_provider: activeIMProvider };
|
|
18766
19465
|
}
|
|
18767
19466
|
function projectNotificationHistoryForCLI(response) {
|
|
18768
19467
|
if (response === null || typeof response !== "object" || Array.isArray(response)) {
|
|
18769
19468
|
return response;
|
|
18770
19469
|
}
|
|
18771
|
-
const
|
|
18772
|
-
if (!Array.isArray(
|
|
19470
|
+
const record4 = response;
|
|
19471
|
+
if (!Array.isArray(record4.items)) return response;
|
|
18773
19472
|
return {
|
|
18774
|
-
...
|
|
18775
|
-
items:
|
|
19473
|
+
...record4,
|
|
19474
|
+
items: record4.items.map((item) => {
|
|
18776
19475
|
if (item === null || typeof item !== "object" || Array.isArray(item)) {
|
|
18777
19476
|
return item;
|
|
18778
19477
|
}
|
|
@@ -18786,6 +19485,111 @@ function num(val) {
|
|
|
18786
19485
|
const n = Number(val);
|
|
18787
19486
|
return Number.isNaN(n) ? void 0 : n;
|
|
18788
19487
|
}
|
|
19488
|
+
function upperFlag(val) {
|
|
19489
|
+
return val === void 0 ? void 0 : val.trim().toUpperCase();
|
|
19490
|
+
}
|
|
19491
|
+
function optionalCursorFlag(val) {
|
|
19492
|
+
if (val === void 0) return void 0;
|
|
19493
|
+
if (!val.trim() || val.length > 4096) {
|
|
19494
|
+
throw new Error(
|
|
19495
|
+
"--cursor must be a non-empty cursor of at most 4096 characters"
|
|
19496
|
+
);
|
|
19497
|
+
}
|
|
19498
|
+
return val;
|
|
19499
|
+
}
|
|
19500
|
+
function usageChecked(command2, check) {
|
|
19501
|
+
try {
|
|
19502
|
+
return check();
|
|
19503
|
+
} catch (error) {
|
|
19504
|
+
if (error instanceof CliUsageError) throw error;
|
|
19505
|
+
throw new CliUsageError(
|
|
19506
|
+
error instanceof Error ? error.message : String(error),
|
|
19507
|
+
command2.split(" ")[0]
|
|
19508
|
+
);
|
|
19509
|
+
}
|
|
19510
|
+
}
|
|
19511
|
+
function dispatchWatchlist(client, leaf, flags) {
|
|
19512
|
+
switch (leaf) {
|
|
19513
|
+
case void 0:
|
|
19514
|
+
return { _help: true, text: COMMAND_HELP.markets };
|
|
19515
|
+
case "add":
|
|
19516
|
+
case "remove": {
|
|
19517
|
+
const command2 = `markets watchlist ${leaf}`;
|
|
19518
|
+
const params = usageChecked(
|
|
19519
|
+
command2,
|
|
19520
|
+
() => normalizeWatchlistTickersParams({
|
|
19521
|
+
tickers: (csvList(requireFlag(flags, "tickers", command2)) ?? []).map(
|
|
19522
|
+
parseTickerSpec
|
|
19523
|
+
),
|
|
19524
|
+
kind: upperFlag(flags["kind"])
|
|
19525
|
+
})
|
|
19526
|
+
);
|
|
19527
|
+
return leaf === "add" ? client.follows.addToWatchlist(params) : client.follows.removeFromWatchlist(params);
|
|
19528
|
+
}
|
|
19529
|
+
case "list": {
|
|
19530
|
+
const command2 = "markets watchlist list";
|
|
19531
|
+
return client.follows.watchlist({
|
|
19532
|
+
first: optionalBoundedIntegerFlag(flags, "limit", command2, 1, 100),
|
|
19533
|
+
after: usageChecked(command2, () => optionalCursorFlag(flags["cursor"]))
|
|
19534
|
+
});
|
|
19535
|
+
}
|
|
19536
|
+
default:
|
|
19537
|
+
throw new CliUsageError(
|
|
19538
|
+
`Unknown subcommand: markets watchlist ${leaf}`,
|
|
19539
|
+
"markets"
|
|
19540
|
+
);
|
|
19541
|
+
}
|
|
19542
|
+
}
|
|
19543
|
+
function dispatchPeople(client, path, flags) {
|
|
19544
|
+
const [subcommand, leaf] = path;
|
|
19545
|
+
if (subcommand === void 0 || subcommand === "follows" && !leaf) {
|
|
19546
|
+
return { _help: true, text: COMMAND_HELP.people };
|
|
19547
|
+
}
|
|
19548
|
+
const command2 = ["people", ...path].join(" ");
|
|
19549
|
+
switch (subcommand === "follows" ? `follows ${leaf}` : subcommand) {
|
|
19550
|
+
case "search":
|
|
19551
|
+
return client.follows.searchProfiles(
|
|
19552
|
+
usageChecked(
|
|
19553
|
+
command2,
|
|
19554
|
+
() => validateSearchProfilesParams({
|
|
19555
|
+
query: requireFlag(flags, "query", command2),
|
|
19556
|
+
kind: upperFlag(flags["kind"]),
|
|
19557
|
+
first: optionalBoundedIntegerFlag(flags, "limit", command2, 1, 50)
|
|
19558
|
+
})
|
|
19559
|
+
)
|
|
19560
|
+
);
|
|
19561
|
+
case "follows list":
|
|
19562
|
+
return client.follows.profiles({
|
|
19563
|
+
kind: usageChecked(
|
|
19564
|
+
command2,
|
|
19565
|
+
() => optionalProfileKind(upperFlag(flags["kind"]))
|
|
19566
|
+
),
|
|
19567
|
+
first: optionalBoundedIntegerFlag(flags, "limit", command2, 1, 50),
|
|
19568
|
+
after: usageChecked(command2, () => optionalCursorFlag(flags["cursor"]))
|
|
19569
|
+
});
|
|
19570
|
+
case "follows follow":
|
|
19571
|
+
case "follows unfollow": {
|
|
19572
|
+
const params = usageChecked(
|
|
19573
|
+
command2,
|
|
19574
|
+
() => validateProfileRef({
|
|
19575
|
+
kind: upperFlag(
|
|
19576
|
+
requireFlag(flags, "kind", command2)
|
|
19577
|
+
),
|
|
19578
|
+
id: requireFlag(flags, "id", command2)
|
|
19579
|
+
})
|
|
19580
|
+
);
|
|
19581
|
+
return leaf === "follow" ? client.follows.followProfile(params) : client.follows.unfollowProfile(params);
|
|
19582
|
+
}
|
|
19583
|
+
default:
|
|
19584
|
+
throw new CliUsageError(`Unknown subcommand: ${command2}`, "people");
|
|
19585
|
+
}
|
|
19586
|
+
}
|
|
19587
|
+
function optionalProfileKind(kind) {
|
|
19588
|
+
if (kind !== void 0 && kind !== "USER" && kind !== "PERSON") {
|
|
19589
|
+
throw new Error("kind must be USER or PERSON");
|
|
19590
|
+
}
|
|
19591
|
+
return kind;
|
|
19592
|
+
}
|
|
18789
19593
|
function csvList(val) {
|
|
18790
19594
|
if (val === void 0) return void 0;
|
|
18791
19595
|
const values = val.split(",").map((item) => item.trim()).filter(Boolean);
|
|
@@ -19467,7 +20271,7 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19467
20271
|
const positionals = parsedCommand.positionals;
|
|
19468
20272
|
if (group === "whoami") {
|
|
19469
20273
|
const user = await client.user.me();
|
|
19470
|
-
const
|
|
20274
|
+
const record4 = projectUserProfileForCLI(
|
|
19471
20275
|
user
|
|
19472
20276
|
);
|
|
19473
20277
|
const version = meta?.cliVersion ?? CLI_VERSION;
|
|
@@ -19484,10 +20288,10 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19484
20288
|
metaBlock.arrays_jwt = arraysJwtStatus;
|
|
19485
20289
|
}
|
|
19486
20290
|
const result = {
|
|
19487
|
-
...
|
|
20291
|
+
...record4,
|
|
19488
20292
|
_meta: metaBlock
|
|
19489
20293
|
};
|
|
19490
|
-
const minVersion =
|
|
20294
|
+
const minVersion = record4.toolkit_min_version;
|
|
19491
20295
|
if (typeof minVersion === "string" && version && version !== "dev" && isVersionOlderThan(version, minVersion)) {
|
|
19492
20296
|
result._warning = `Warning: your toolkit version (${version}) is older than the minimum recommended version (${minVersion}). Please upgrade: npm install -g @alva-ai/toolkit`;
|
|
19493
20297
|
}
|
|
@@ -19861,6 +20665,14 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19861
20665
|
requestId: flags["request-id"]
|
|
19862
20666
|
});
|
|
19863
20667
|
case "send":
|
|
20668
|
+
if (flags["digest-run-id"] !== void 0) {
|
|
20669
|
+
return client.steward.sendDigestRun({
|
|
20670
|
+
inboxPath,
|
|
20671
|
+
digestRunId: requireFlag(flags, "digest-run-id", "steward send"),
|
|
20672
|
+
deliveryIds: optionalIds("delivery-ids"),
|
|
20673
|
+
body: flags.body
|
|
20674
|
+
});
|
|
20675
|
+
}
|
|
19864
20676
|
return client.steward.send({
|
|
19865
20677
|
inboxPath,
|
|
19866
20678
|
body: requireFlag(flags, "body", "steward send"),
|
|
@@ -19868,6 +20680,16 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19868
20680
|
requestId: flags["request-id"]
|
|
19869
20681
|
});
|
|
19870
20682
|
case "pending": {
|
|
20683
|
+
if (flags["digest-run-id"] !== void 0) {
|
|
20684
|
+
return client.steward.digestRunPending({
|
|
20685
|
+
inboxPath,
|
|
20686
|
+
digestRunId: requireFlag(
|
|
20687
|
+
flags,
|
|
20688
|
+
"digest-run-id",
|
|
20689
|
+
"steward pending"
|
|
20690
|
+
)
|
|
20691
|
+
});
|
|
20692
|
+
}
|
|
19871
20693
|
const parseTime = (name) => {
|
|
19872
20694
|
const value = flags[name];
|
|
19873
20695
|
if (value === void 0) return void 0;
|
|
@@ -19883,7 +20705,6 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19883
20705
|
const first = flags.first === void 0 ? void 0 : Number(flags.first);
|
|
19884
20706
|
return client.steward.pending({
|
|
19885
20707
|
inboxPath,
|
|
19886
|
-
after: flags.after,
|
|
19887
20708
|
sinceMs: parseTime("since"),
|
|
19888
20709
|
untilMs: parseTime("until"),
|
|
19889
20710
|
first
|
|
@@ -19895,6 +20716,11 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19895
20716
|
deliveryIds: ids("delivery-ids"),
|
|
19896
20717
|
digestRunId: requireFlag(flags, "digest-run-id", "steward briefed")
|
|
19897
20718
|
});
|
|
20719
|
+
case "status":
|
|
20720
|
+
return client.steward.digestRun({
|
|
20721
|
+
inboxPath,
|
|
20722
|
+
digestRunId: requireFlag(flags, "digest-run-id", "steward status")
|
|
20723
|
+
});
|
|
19898
20724
|
default:
|
|
19899
20725
|
throw new CliUsageError(
|
|
19900
20726
|
`Unknown subcommand: steward ${subcommand}`,
|
|
@@ -21280,6 +22106,9 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
21280
22106
|
case "markets": {
|
|
21281
22107
|
if (!subcommand)
|
|
21282
22108
|
throw new CliUsageError("Missing subcommand for markets", "markets");
|
|
22109
|
+
if (subcommand === "watchlist") {
|
|
22110
|
+
return dispatchWatchlist(client, parsedCommand.path[2], flags);
|
|
22111
|
+
}
|
|
21283
22112
|
const ticker = requireFlag(flags, "ticker", `markets ${subcommand}`);
|
|
21284
22113
|
switch (subcommand) {
|
|
21285
22114
|
case "narrative":
|
|
@@ -21393,6 +22222,8 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
21393
22222
|
);
|
|
21394
22223
|
}
|
|
21395
22224
|
}
|
|
22225
|
+
case "people":
|
|
22226
|
+
return dispatchPeople(client, parsedCommand.path.slice(1), flags);
|
|
21396
22227
|
case "trading": {
|
|
21397
22228
|
if (!subcommand)
|
|
21398
22229
|
throw new CliUsageError("Missing subcommand for trading", "trading");
|