@alva-ai/toolkit 0.34.0 → 0.36.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 +39 -4
- package/dist/browser.global.js +77 -47
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +273 -13
- package/dist/cli.js +1114 -212
- package/dist/cli.js.map +1 -1
- package/dist/dispatch.d.ts +273 -13
- package/dist/dispatch.js +478 -116
- package/dist/dispatch.js.map +1 -1
- package/dist/index.cjs +846 -135
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +274 -14
- package/dist/index.d.ts +274 -14
- package/dist/index.js +845 -135
- 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);
|
|
@@ -10511,6 +11148,58 @@ function nextCursor(page) {
|
|
|
10511
11148
|
throw invalid3();
|
|
10512
11149
|
return info.hasNextPage ? info.endCursor : null;
|
|
10513
11150
|
}
|
|
11151
|
+
var RETURN_QUERY = `query ToolkitThesisReturn($id: ID!, $detail: Boolean!) {
|
|
11152
|
+
node(id: $id) { ... on Playbook { latestRelease { thesisPublication {
|
|
11153
|
+
returnTracking
|
|
11154
|
+
thesisReturn(detail: $detail) {
|
|
11155
|
+
live value firstFillAtMs pricedAtMs stale computedAtMs
|
|
11156
|
+
updates { authorVersionId publishedAtMs startValue updateReturn
|
|
11157
|
+
positions { entityId symbol direction startPrice startAtMs endPrice endAtMs end positionReturn currency } }
|
|
11158
|
+
}
|
|
11159
|
+
} } } }
|
|
11160
|
+
}`;
|
|
11161
|
+
async function thesisReturn(client, id, params = {}) {
|
|
11162
|
+
if (!isPositiveInt64(id))
|
|
11163
|
+
throw argument("id must be an internal positive int64 Playbook ID");
|
|
11164
|
+
if (params.detail !== void 0 && typeof params.detail !== "boolean")
|
|
11165
|
+
throw argument("detail must be a boolean");
|
|
11166
|
+
client._requireAuth();
|
|
11167
|
+
const data = await graphql(client, RETURN_QUERY, {
|
|
11168
|
+
id: `Playbook:${id}`,
|
|
11169
|
+
detail: params.detail ?? false
|
|
11170
|
+
});
|
|
11171
|
+
if (data.node === null) throw notFound();
|
|
11172
|
+
if (!record2(data.node)) throw invalid3();
|
|
11173
|
+
const release = data.node.latestRelease;
|
|
11174
|
+
if (release === null || release === void 0)
|
|
11175
|
+
return { playbookId: id, returnTracking: null, thesisReturn: null };
|
|
11176
|
+
if (!record2(release)) throw invalid3();
|
|
11177
|
+
const publication = release.thesisPublication;
|
|
11178
|
+
if (publication === null)
|
|
11179
|
+
return { playbookId: id, returnTracking: null, thesisReturn: null };
|
|
11180
|
+
if (!record2(publication)) throw invalid3();
|
|
11181
|
+
const tracking = publication.returnTracking;
|
|
11182
|
+
if (tracking !== null && !["UNSET", "ON", "OFF"].includes(tracking))
|
|
11183
|
+
throw invalid3();
|
|
11184
|
+
const value = publication.thesisReturn;
|
|
11185
|
+
if (value !== null && !validThesisReturn(value)) throw invalid3();
|
|
11186
|
+
return {
|
|
11187
|
+
playbookId: id,
|
|
11188
|
+
returnTracking: tracking,
|
|
11189
|
+
thesisReturn: value
|
|
11190
|
+
};
|
|
11191
|
+
}
|
|
11192
|
+
function validThesisReturn(value) {
|
|
11193
|
+
if (!record2(value) || typeof value.live !== "boolean" || typeof value.value !== "number" || typeof value.stale !== "boolean" || typeof value.computedAtMs !== "number" || !Array.isArray(value.updates))
|
|
11194
|
+
return false;
|
|
11195
|
+
return value.updates.every(
|
|
11196
|
+
(update) => record2(update) && nonempty(update.authorVersionId) && typeof update.publishedAtMs === "number" && typeof update.startValue === "number" && Array.isArray(update.positions) && update.positions.every(
|
|
11197
|
+
(position) => record2(position) && nonempty(position.symbol) && ["BULLISH", "BEARISH"].includes(position.direction) && ["PENDING", "NEXT_UPDATE", "LATEST"].includes(
|
|
11198
|
+
position.end
|
|
11199
|
+
) && typeof position.positionReturn === "number"
|
|
11200
|
+
)
|
|
11201
|
+
);
|
|
11202
|
+
}
|
|
10514
11203
|
async function graphql(client, document, variables) {
|
|
10515
11204
|
const response = await client._request("POST", "/query", {
|
|
10516
11205
|
body: { query: document, variables }
|
|
@@ -10596,17 +11285,29 @@ var ThesesResource = class {
|
|
|
10596
11285
|
related(id, params = {}) {
|
|
10597
11286
|
return relatedTheses(this.client, id, params);
|
|
10598
11287
|
}
|
|
10599
|
-
async assetCandidates(text) {
|
|
11288
|
+
async assetCandidates(text, params = {}) {
|
|
10600
11289
|
this.client._requireAuth();
|
|
10601
11290
|
const source = requireBody(text);
|
|
11291
|
+
const input = {
|
|
11292
|
+
text: source,
|
|
11293
|
+
selectedEntityIds: requireIDs(params.entityIds ?? [], "entityIds")
|
|
11294
|
+
};
|
|
11295
|
+
if (params.thesisId !== void 0)
|
|
11296
|
+
input.thesisId = requireID(params.thesisId, "thesisId");
|
|
11297
|
+
if (params.discover !== void 0) {
|
|
11298
|
+
if (typeof params.discover !== "boolean")
|
|
11299
|
+
throw invalidArgument("discover must be a boolean");
|
|
11300
|
+
input.discover = params.discover;
|
|
11301
|
+
}
|
|
10602
11302
|
const response = await this.client._request("POST", "/query", {
|
|
10603
11303
|
body: {
|
|
10604
11304
|
query: `query ThesisAssetCandidates($input: ThesisAssetCandidatesInput!) {
|
|
10605
11305
|
viewer { thesisAssetCandidates(input: $input) {
|
|
10606
11306
|
mentions { quote ticker resolution stance candidates { entityId ticker name kind } }
|
|
11307
|
+
returnPreview { tracking askSwitch directions { entityId direction } keptEntityIds lastLegRemoved }
|
|
10607
11308
|
} }
|
|
10608
11309
|
}`,
|
|
10609
|
-
variables: { input
|
|
11310
|
+
variables: { input }
|
|
10610
11311
|
}
|
|
10611
11312
|
});
|
|
10612
11313
|
if (Array.isArray(response?.errors) && response.errors.length > 0) {
|
|
@@ -10618,19 +11319,19 @@ var ThesesResource = class {
|
|
|
10618
11319
|
const viewer = isRecord2(data) ? data.viewer : void 0;
|
|
10619
11320
|
const result = isRecord2(viewer) ? viewer.thesisAssetCandidates : void 0;
|
|
10620
11321
|
if (!isRecord2(result) || !Array.isArray(result.mentions)) {
|
|
10621
|
-
throw
|
|
11322
|
+
throw invalidResponse4("asset candidates response must contain mentions");
|
|
10622
11323
|
}
|
|
10623
11324
|
const mentions = result.mentions.map((item, index) => {
|
|
10624
11325
|
if (!isRecord2(item) || typeof item.quote !== "string" || typeof item.ticker !== "string" || !["RESOLVED", "AMBIGUOUS", "UNRESOLVED"].includes(
|
|
10625
11326
|
item.resolution
|
|
10626
11327
|
) || !["UNKNOWN", "BULLISH", "BEARISH"].includes(item.stance) || !Array.isArray(item.candidates)) {
|
|
10627
|
-
throw
|
|
11328
|
+
throw invalidResponse4(`asset mention ${index} is invalid`);
|
|
10628
11329
|
}
|
|
10629
11330
|
const candidates = item.candidates.map((candidate) => {
|
|
10630
11331
|
if (!isRecord2(candidate) || typeof candidate.ticker !== "string" || typeof candidate.name !== "string" || !["STOCK", "ETF", "CRYPTO", "INDEX"].includes(
|
|
10631
11332
|
candidate.kind
|
|
10632
11333
|
)) {
|
|
10633
|
-
throw
|
|
11334
|
+
throw invalidResponse4(`asset mention ${index} has invalid candidate`);
|
|
10634
11335
|
}
|
|
10635
11336
|
return {
|
|
10636
11337
|
entityId: responseID(
|
|
@@ -10644,7 +11345,11 @@ var ThesesResource = class {
|
|
|
10644
11345
|
});
|
|
10645
11346
|
return { ...item, candidates };
|
|
10646
11347
|
});
|
|
10647
|
-
return { mentions };
|
|
11348
|
+
return { mentions, returnPreview: returnPreview(result.returnPreview) };
|
|
11349
|
+
}
|
|
11350
|
+
/** The Thesis return of a Playbook's current publication; detail revalues it. */
|
|
11351
|
+
thesisReturn(id, params = {}) {
|
|
11352
|
+
return thesisReturn(this.client, id, params);
|
|
10648
11353
|
}
|
|
10649
11354
|
async create(params) {
|
|
10650
11355
|
this.client._requireAuth();
|
|
@@ -10660,7 +11365,7 @@ var ThesesResource = class {
|
|
|
10660
11365
|
await this.client._request("GET", `/api/v1/theses/${thesisID}`)
|
|
10661
11366
|
);
|
|
10662
11367
|
if (response.thesis.id !== thesisID) {
|
|
10663
|
-
throw
|
|
11368
|
+
throw invalidResponse4("get response must match the requested thesis");
|
|
10664
11369
|
}
|
|
10665
11370
|
return response;
|
|
10666
11371
|
}
|
|
@@ -10675,7 +11380,7 @@ var ThesesResource = class {
|
|
|
10675
11380
|
)
|
|
10676
11381
|
);
|
|
10677
11382
|
if (response.thesis.id !== thesisID || response.thesis.author_version_id !== versionID) {
|
|
10678
|
-
throw
|
|
11383
|
+
throw invalidResponse4(
|
|
10679
11384
|
"version response must match the requested thesis and author version"
|
|
10680
11385
|
);
|
|
10681
11386
|
}
|
|
@@ -10698,38 +11403,14 @@ var ThesesResource = class {
|
|
|
10698
11403
|
}
|
|
10699
11404
|
);
|
|
10700
11405
|
if (!isRecord2(response) || !Array.isArray(response.versions) || typeof response.next_cursor !== "string")
|
|
10701
|
-
throw
|
|
11406
|
+
throw invalidResponse4("invalid Update list");
|
|
10702
11407
|
const versions = response.versions.map(
|
|
10703
11408
|
(value) => thesisResponse({ thesis: value }).thesis
|
|
10704
11409
|
);
|
|
10705
11410
|
if (versions.some((version) => version.id !== thesisID))
|
|
10706
|
-
throw
|
|
11411
|
+
throw invalidResponse4("Update list must match requested Thesis");
|
|
10707
11412
|
return { versions, next_cursor: response.next_cursor };
|
|
10708
11413
|
}
|
|
10709
|
-
/** Deletes only the selected Update; never falls back to whole-Thesis deletion. */
|
|
10710
|
-
async deleteUpdate(id, authorVersionID, expectedAuthorVersionID) {
|
|
10711
|
-
this.client._requireAuth();
|
|
10712
|
-
const thesisID = requireID(id, "id");
|
|
10713
|
-
const versionID = requireID(authorVersionID, "author_version_id");
|
|
10714
|
-
const expected = requireID(
|
|
10715
|
-
expectedAuthorVersionID,
|
|
10716
|
-
"expected_author_version_id"
|
|
10717
|
-
);
|
|
10718
|
-
const response = thesisResponse(
|
|
10719
|
-
await this.client._request(
|
|
10720
|
-
"DELETE",
|
|
10721
|
-
`/api/v1/theses/${thesisID}/versions/${versionID}`,
|
|
10722
|
-
{
|
|
10723
|
-
query: { expected_author_version_id: expected }
|
|
10724
|
-
}
|
|
10725
|
-
)
|
|
10726
|
-
);
|
|
10727
|
-
if (response.thesis.id !== thesisID)
|
|
10728
|
-
throw invalidResponse3(
|
|
10729
|
-
"delete Update response must match requested Thesis"
|
|
10730
|
-
);
|
|
10731
|
-
return response;
|
|
10732
|
-
}
|
|
10733
11414
|
async signals(id, params = {}) {
|
|
10734
11415
|
this.client._requireAuth();
|
|
10735
11416
|
const first = params.first ?? 20;
|
|
@@ -10764,7 +11445,7 @@ var ThesesResource = class {
|
|
|
10764
11445
|
})
|
|
10765
11446
|
);
|
|
10766
11447
|
if (response.thesis.id !== thesisID) {
|
|
10767
|
-
throw
|
|
11448
|
+
throw invalidResponse4("update response must match the requested thesis");
|
|
10768
11449
|
}
|
|
10769
11450
|
return response;
|
|
10770
11451
|
}
|
|
@@ -10786,7 +11467,7 @@ var ThesesResource = class {
|
|
|
10786
11467
|
current.thesis.entity_ids,
|
|
10787
11468
|
current.thesis.entity_stances
|
|
10788
11469
|
)) {
|
|
10789
|
-
throw
|
|
11470
|
+
throw invalidResponse4(
|
|
10790
11471
|
"archive requires one entity_stance for every Thesis entity"
|
|
10791
11472
|
);
|
|
10792
11473
|
}
|
|
@@ -10803,7 +11484,7 @@ var ThesesResource = class {
|
|
|
10803
11484
|
note: params.note
|
|
10804
11485
|
});
|
|
10805
11486
|
if (response.thesis.id !== thesisID || response.thesis.archived !== params.archived) {
|
|
10806
|
-
throw
|
|
11487
|
+
throw invalidResponse4("archive response must match the requested state");
|
|
10807
11488
|
}
|
|
10808
11489
|
return response;
|
|
10809
11490
|
}
|
|
@@ -10818,15 +11499,15 @@ var ThesesResource = class {
|
|
|
10818
11499
|
});
|
|
10819
11500
|
const result = data.setThesisStarred;
|
|
10820
11501
|
if (!isRecord2(result) || !isRecord2(result.stats) || !isRecord2(result.viewerState)) {
|
|
10821
|
-
throw
|
|
11502
|
+
throw invalidResponse4("star response must contain stats and viewerState");
|
|
10822
11503
|
}
|
|
10823
11504
|
const returnedID = responseID(result.thesisId, "thesisId");
|
|
10824
11505
|
if (returnedID !== thesisID) {
|
|
10825
|
-
throw
|
|
11506
|
+
throw invalidResponse4("star response must match the requested thesis");
|
|
10826
11507
|
}
|
|
10827
11508
|
const starCount = result.stats.starCount;
|
|
10828
11509
|
if (typeof starCount !== "number" || !Number.isInteger(starCount) || starCount < 0) {
|
|
10829
|
-
throw
|
|
11510
|
+
throw invalidResponse4(
|
|
10830
11511
|
"star response must contain a nonnegative star count"
|
|
10831
11512
|
);
|
|
10832
11513
|
}
|
|
@@ -10835,7 +11516,7 @@ var ThesesResource = class {
|
|
|
10835
11516
|
"viewerState.isStarred"
|
|
10836
11517
|
);
|
|
10837
11518
|
if (returnedStarred !== isStarred) {
|
|
10838
|
-
throw
|
|
11519
|
+
throw invalidResponse4("star response did not apply the requested state");
|
|
10839
11520
|
}
|
|
10840
11521
|
return {
|
|
10841
11522
|
thesis_id: returnedID,
|
|
@@ -10854,7 +11535,7 @@ var ThesesResource = class {
|
|
|
10854
11535
|
});
|
|
10855
11536
|
const result = data.setThesisSignalEnabled;
|
|
10856
11537
|
if (!isRecord2(result) || !isRecord2(result.publication)) {
|
|
10857
|
-
throw
|
|
11538
|
+
throw invalidResponse4("Signal response must contain publication");
|
|
10858
11539
|
}
|
|
10859
11540
|
const publication = result.publication;
|
|
10860
11541
|
const returnedID = responseID(
|
|
@@ -10862,14 +11543,14 @@ var ThesesResource = class {
|
|
|
10862
11543
|
"publication.playbookId"
|
|
10863
11544
|
);
|
|
10864
11545
|
if (returnedID !== thesisID) {
|
|
10865
|
-
throw
|
|
11546
|
+
throw invalidResponse4("Signal response must match the requested thesis");
|
|
10866
11547
|
}
|
|
10867
11548
|
const researchPaused = responseBoolean(
|
|
10868
11549
|
publication.researchPaused,
|
|
10869
11550
|
"publication.researchPaused"
|
|
10870
11551
|
);
|
|
10871
11552
|
if (researchPaused === enabled) {
|
|
10872
|
-
throw
|
|
11553
|
+
throw invalidResponse4(
|
|
10873
11554
|
"Signal response did not apply the requested state"
|
|
10874
11555
|
);
|
|
10875
11556
|
}
|
|
@@ -10899,41 +11580,12 @@ var ThesesResource = class {
|
|
|
10899
11580
|
)
|
|
10900
11581
|
);
|
|
10901
11582
|
if (response.thesis.id !== thesisID || response.thesis.visibility !== visibility) {
|
|
10902
|
-
throw
|
|
11583
|
+
throw invalidResponse4(
|
|
10903
11584
|
"visibility response must match the requested thesis and visibility"
|
|
10904
11585
|
);
|
|
10905
11586
|
}
|
|
10906
11587
|
return response;
|
|
10907
11588
|
}
|
|
10908
|
-
async close(id, params) {
|
|
10909
|
-
this.client._requireAuth();
|
|
10910
|
-
const body = {
|
|
10911
|
-
expected_author_version_id: requireID(
|
|
10912
|
-
params.expected_author_version_id,
|
|
10913
|
-
"expected_author_version_id"
|
|
10914
|
-
)
|
|
10915
|
-
};
|
|
10916
|
-
if (params.note !== void 0) body.note = requireText2(params.note, "note");
|
|
10917
|
-
return thesisResponse(
|
|
10918
|
-
await this.client._request(
|
|
10919
|
-
"POST",
|
|
10920
|
-
`/api/v1/theses/${requireID(id, "id")}/close`,
|
|
10921
|
-
{ body }
|
|
10922
|
-
)
|
|
10923
|
-
);
|
|
10924
|
-
}
|
|
10925
|
-
async delete(id) {
|
|
10926
|
-
this.client._requireAuth();
|
|
10927
|
-
const response = await this.client._request(
|
|
10928
|
-
"DELETE",
|
|
10929
|
-
`/api/v1/theses/${requireID(id, "id")}`
|
|
10930
|
-
);
|
|
10931
|
-
if (response === void 0) return {};
|
|
10932
|
-
if (!isRecord2(response) || Object.keys(response).length !== 0) {
|
|
10933
|
-
throw invalidResponse3("delete response must be {}");
|
|
10934
|
-
}
|
|
10935
|
-
return {};
|
|
10936
|
-
}
|
|
10937
11589
|
async rewrite(params) {
|
|
10938
11590
|
this.client._requireAuth();
|
|
10939
11591
|
const body = requireBody(params.body);
|
|
@@ -10946,7 +11598,7 @@ var ThesesResource = class {
|
|
|
10946
11598
|
}
|
|
10947
11599
|
);
|
|
10948
11600
|
if (!isRecord2(response) || typeof response.body !== "string") {
|
|
10949
|
-
throw
|
|
11601
|
+
throw invalidResponse4("rewrite response must contain a string body");
|
|
10950
11602
|
}
|
|
10951
11603
|
return { body: responseBody(response.body) };
|
|
10952
11604
|
}
|
|
@@ -10976,6 +11628,8 @@ function createBody(params) {
|
|
|
10976
11628
|
}
|
|
10977
11629
|
if (params.tickers !== void 0)
|
|
10978
11630
|
body.tickers = requireTickers(params.tickers);
|
|
11631
|
+
if (params.track_return !== void 0)
|
|
11632
|
+
body.track_return = requireTrackReturn(params.track_return);
|
|
10979
11633
|
if (params.entity_stances !== void 0) {
|
|
10980
11634
|
body.entity_stances = requireEntityStances(
|
|
10981
11635
|
params.entity_stances,
|
|
@@ -10984,6 +11638,52 @@ function createBody(params) {
|
|
|
10984
11638
|
}
|
|
10985
11639
|
return body;
|
|
10986
11640
|
}
|
|
11641
|
+
var ENTITY_STANCES = [
|
|
11642
|
+
"unknown",
|
|
11643
|
+
"bullish",
|
|
11644
|
+
"bearish",
|
|
11645
|
+
"none"
|
|
11646
|
+
];
|
|
11647
|
+
var THESIS_DIRECTIONS = [
|
|
11648
|
+
"UNKNOWN",
|
|
11649
|
+
"BULLISH",
|
|
11650
|
+
"BEARISH",
|
|
11651
|
+
"NONE"
|
|
11652
|
+
];
|
|
11653
|
+
var RETURN_TRACKING = ["UNSET", "ON", "OFF"];
|
|
11654
|
+
function requireTrackReturn(value) {
|
|
11655
|
+
if (typeof value !== "boolean")
|
|
11656
|
+
throw invalidArgument("track_return must be a boolean");
|
|
11657
|
+
return value;
|
|
11658
|
+
}
|
|
11659
|
+
function selectedDirections(value, field) {
|
|
11660
|
+
if (!Array.isArray(value)) throw invalidResponse4(`${field} must be an array`);
|
|
11661
|
+
return value.map((item, index) => {
|
|
11662
|
+
if (!isRecord2(item) || !THESIS_DIRECTIONS.includes(item.direction))
|
|
11663
|
+
throw invalidResponse4(`${field}[${index}] is invalid`);
|
|
11664
|
+
return {
|
|
11665
|
+
entityId: responseID(item.entityId, `${field}[${index}].entityId`),
|
|
11666
|
+
direction: item.direction
|
|
11667
|
+
};
|
|
11668
|
+
});
|
|
11669
|
+
}
|
|
11670
|
+
function returnPreview(value) {
|
|
11671
|
+
if (value === null || value === void 0) return null;
|
|
11672
|
+
if (!isRecord2(value) || !RETURN_TRACKING.includes(value.tracking) || typeof value.askSwitch !== "boolean" || typeof value.lastLegRemoved !== "boolean" || !Array.isArray(value.keptEntityIds))
|
|
11673
|
+
throw invalidResponse4("returnPreview is invalid");
|
|
11674
|
+
return {
|
|
11675
|
+
tracking: value.tracking,
|
|
11676
|
+
askSwitch: value.askSwitch,
|
|
11677
|
+
directions: selectedDirections(
|
|
11678
|
+
value.directions,
|
|
11679
|
+
"returnPreview.directions"
|
|
11680
|
+
),
|
|
11681
|
+
keptEntityIds: value.keptEntityIds.map(
|
|
11682
|
+
(id, index) => responseID(id, `returnPreview.keptEntityIds[${index}]`)
|
|
11683
|
+
),
|
|
11684
|
+
lastLegRemoved: value.lastLegRemoved
|
|
11685
|
+
};
|
|
11686
|
+
}
|
|
10987
11687
|
function requireEntityStances(value, entityIDs) {
|
|
10988
11688
|
if (!Array.isArray(value) || value.length > MAX_ENTITY_IDS)
|
|
10989
11689
|
throw invalidArgument("entity_stances must contain at most 100 values");
|
|
@@ -11001,7 +11701,7 @@ function requireEntityStances(value, entityIDs) {
|
|
|
11001
11701
|
"entity stance must reference one unique entity_id"
|
|
11002
11702
|
);
|
|
11003
11703
|
seen.add(entityID);
|
|
11004
|
-
if (!
|
|
11704
|
+
if (!ENTITY_STANCES.includes(item.stance))
|
|
11005
11705
|
throw invalidArgument(`entity_stances[${index}].stance is invalid`);
|
|
11006
11706
|
return { entity_id: entityID, stance: item.stance };
|
|
11007
11707
|
});
|
|
@@ -11016,8 +11716,7 @@ function updateBody(params) {
|
|
|
11016
11716
|
body: requireBody(params.body),
|
|
11017
11717
|
title: requireTitle(params.title ?? ""),
|
|
11018
11718
|
entity_ids: requireIDs(params.entity_ids ?? [], "entity_ids"),
|
|
11019
|
-
visibility: requireVisibility(params.visibility)
|
|
11020
|
-
editorial: params.editorial ?? false
|
|
11719
|
+
visibility: requireVisibility(params.visibility)
|
|
11021
11720
|
};
|
|
11022
11721
|
if (params.medias !== void 0) {
|
|
11023
11722
|
if (!Array.isArray(params.medias) || params.medias.length > 20)
|
|
@@ -11032,6 +11731,8 @@ function updateBody(params) {
|
|
|
11032
11731
|
body.archived = params.archived;
|
|
11033
11732
|
}
|
|
11034
11733
|
if (params.note !== void 0) body.note = requireText2(params.note, "note");
|
|
11734
|
+
if (params.track_return !== void 0)
|
|
11735
|
+
body.track_return = requireTrackReturn(params.track_return);
|
|
11035
11736
|
if (params.entity_stances !== void 0) {
|
|
11036
11737
|
body.entity_stances = requireEntityStances(
|
|
11037
11738
|
params.entity_stances,
|
|
@@ -11042,7 +11743,7 @@ function updateBody(params) {
|
|
|
11042
11743
|
}
|
|
11043
11744
|
function thesisResponse(response) {
|
|
11044
11745
|
if (!isRecord2(response) || !isRecord2(response.thesis)) {
|
|
11045
|
-
throw
|
|
11746
|
+
throw invalidResponse4("response must contain thesis");
|
|
11046
11747
|
}
|
|
11047
11748
|
const thesis = response.thesis;
|
|
11048
11749
|
const value = {
|
|
@@ -11067,10 +11768,10 @@ function thesisResponse(response) {
|
|
|
11067
11768
|
};
|
|
11068
11769
|
if (thesis.medias !== void 0) {
|
|
11069
11770
|
if (!Array.isArray(thesis.medias) || thesis.medias.length > 20)
|
|
11070
|
-
throw
|
|
11771
|
+
throw invalidResponse4("thesis.medias must contain at most 20 items");
|
|
11071
11772
|
value.medias = thesis.medias.map((item) => {
|
|
11072
11773
|
if (!validMedia(item))
|
|
11073
|
-
throw
|
|
11774
|
+
throw invalidResponse4("thesis.medias contains invalid media");
|
|
11074
11775
|
return {
|
|
11075
11776
|
type: item.type,
|
|
11076
11777
|
cover_url: item.cover_url,
|
|
@@ -11087,16 +11788,27 @@ function thesisResponse(response) {
|
|
|
11087
11788
|
value.note = responseText(thesis.note, "thesis.note");
|
|
11088
11789
|
if (thesis.entity_stances !== void 0) {
|
|
11089
11790
|
if (!Array.isArray(thesis.entity_stances))
|
|
11090
|
-
throw
|
|
11791
|
+
throw invalidResponse4("thesis.entity_stances must be an array");
|
|
11091
11792
|
value.entity_stances = thesis.entity_stances.map((item) => {
|
|
11092
11793
|
if (!isRecord2(item))
|
|
11093
|
-
throw
|
|
11794
|
+
throw invalidResponse4("thesis.entity_stances contains invalid entry");
|
|
11094
11795
|
const entityID = responseID(item.entity_id, "entity_stances.entity_id");
|
|
11095
11796
|
if (!value.entity_ids.includes(entityID))
|
|
11096
|
-
throw
|
|
11097
|
-
if (!
|
|
11098
|
-
throw
|
|
11099
|
-
|
|
11797
|
+
throw invalidResponse4("entity stance must reference a thesis entity");
|
|
11798
|
+
if (!ENTITY_STANCES.includes(item.stance))
|
|
11799
|
+
throw invalidResponse4("thesis.entity_stances contains invalid stance");
|
|
11800
|
+
const stance = {
|
|
11801
|
+
entity_id: entityID,
|
|
11802
|
+
stance: item.stance
|
|
11803
|
+
};
|
|
11804
|
+
if (item.direction !== void 0) {
|
|
11805
|
+
if (!ENTITY_STANCES.includes(item.direction))
|
|
11806
|
+
throw invalidResponse4(
|
|
11807
|
+
"thesis.entity_stances contains invalid direction"
|
|
11808
|
+
);
|
|
11809
|
+
stance.direction = item.direction;
|
|
11810
|
+
}
|
|
11811
|
+
return stance;
|
|
11100
11812
|
});
|
|
11101
11813
|
}
|
|
11102
11814
|
return { thesis: value };
|
|
@@ -11104,7 +11816,7 @@ function thesisResponse(response) {
|
|
|
11104
11816
|
function thesisGetResponse(response) {
|
|
11105
11817
|
const base = thesisResponse(response);
|
|
11106
11818
|
if (!isRecord2(response) || !isRecord2(response.author)) {
|
|
11107
|
-
throw
|
|
11819
|
+
throw invalidResponse4("response must contain author");
|
|
11108
11820
|
}
|
|
11109
11821
|
const authorRecord = response.author;
|
|
11110
11822
|
const author = {
|
|
@@ -11118,14 +11830,14 @@ function thesisGetResponse(response) {
|
|
|
11118
11830
|
username: responseText(authorRecord.username, "author.username")
|
|
11119
11831
|
};
|
|
11120
11832
|
if (!Array.isArray(response.entities)) {
|
|
11121
|
-
throw
|
|
11833
|
+
throw invalidResponse4("response must contain entities");
|
|
11122
11834
|
}
|
|
11123
11835
|
if (response.entities.length !== base.thesis.entity_ids.length) {
|
|
11124
|
-
throw
|
|
11836
|
+
throw invalidResponse4("entities must match thesis.entity_ids");
|
|
11125
11837
|
}
|
|
11126
11838
|
const entities = response.entities.map((item, index) => {
|
|
11127
11839
|
if (!isRecord2(item))
|
|
11128
|
-
throw
|
|
11840
|
+
throw invalidResponse4(`entities[${index}] must be an object`);
|
|
11129
11841
|
const entity = {
|
|
11130
11842
|
id: responseID(item.id, `entities[${index}].id`),
|
|
11131
11843
|
ticker: responseText(item.ticker, `entities[${index}].ticker`),
|
|
@@ -11134,7 +11846,7 @@ function thesisGetResponse(response) {
|
|
|
11134
11846
|
kind: responseText(item.kind, `entities[${index}].kind`)
|
|
11135
11847
|
};
|
|
11136
11848
|
if (entity.id !== base.thesis.entity_ids[index]) {
|
|
11137
|
-
throw
|
|
11849
|
+
throw invalidResponse4("entities must preserve thesis.entity_ids order");
|
|
11138
11850
|
}
|
|
11139
11851
|
return entity;
|
|
11140
11852
|
});
|
|
@@ -11142,7 +11854,7 @@ function thesisGetResponse(response) {
|
|
|
11142
11854
|
}
|
|
11143
11855
|
function thesisSignalsResponse(response, thesisID, first) {
|
|
11144
11856
|
if (!isRecord2(response) || !isRecord2(response.research) || !Array.isArray(response.entries) || response.entries.length > first) {
|
|
11145
|
-
throw
|
|
11857
|
+
throw invalidResponse4("invalid Signal history response");
|
|
11146
11858
|
}
|
|
11147
11859
|
const research = response.research;
|
|
11148
11860
|
const status = {
|
|
@@ -11168,13 +11880,13 @@ function thesisSignalsResponse(response, thesisID, first) {
|
|
|
11168
11880
|
);
|
|
11169
11881
|
const entries = response.entries.map((raw) => {
|
|
11170
11882
|
if (!isRecord2(raw) || !isRecord2(raw.signal) || !isRecord2(raw.signal.source)) {
|
|
11171
|
-
throw
|
|
11883
|
+
throw invalidResponse4("entry must include a Signal and source");
|
|
11172
11884
|
}
|
|
11173
11885
|
const signal = raw.signal;
|
|
11174
11886
|
const source = signal.source;
|
|
11175
11887
|
const signalID = responseID(signal.thesis_id, "signal.thesis_id");
|
|
11176
11888
|
if (signalID !== thesisID)
|
|
11177
|
-
throw
|
|
11889
|
+
throw invalidResponse4("Signal belongs to another Thesis");
|
|
11178
11890
|
const cursor = responseNonemptyText(raw.cursor, "entry.cursor");
|
|
11179
11891
|
const mappedSource = {
|
|
11180
11892
|
title: responseText(source.title, "source.title")
|
|
@@ -11207,7 +11919,7 @@ function thesisSignalsResponse(response, thesisID, first) {
|
|
|
11207
11919
|
};
|
|
11208
11920
|
if (signal.evidence_excerpt !== void 0) {
|
|
11209
11921
|
if (!isRecord2(signal.evidence_excerpt))
|
|
11210
|
-
throw
|
|
11922
|
+
throw invalidResponse4("invalid evidence excerpt");
|
|
11211
11923
|
mappedSignal.evidence_excerpt = {
|
|
11212
11924
|
text: responseNonemptyText(
|
|
11213
11925
|
signal.evidence_excerpt.text,
|
|
@@ -11231,19 +11943,19 @@ function thesisSignalsResponse(response, thesisID, first) {
|
|
|
11231
11943
|
});
|
|
11232
11944
|
const nextCursor2 = responseText(response.next_cursor, "next_cursor");
|
|
11233
11945
|
if (nextCursor2 && nextCursor2 !== entries[entries.length - 1]?.cursor) {
|
|
11234
|
-
throw
|
|
11946
|
+
throw invalidResponse4("next_cursor must match the final entry");
|
|
11235
11947
|
}
|
|
11236
11948
|
return { research: status, entries, next_cursor: nextCursor2 };
|
|
11237
11949
|
}
|
|
11238
11950
|
function responseNonnegativeInteger(value, field) {
|
|
11239
11951
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
11240
|
-
throw
|
|
11952
|
+
throw invalidResponse4(field + " must be a nonnegative safe integer");
|
|
11241
11953
|
}
|
|
11242
11954
|
return value;
|
|
11243
11955
|
}
|
|
11244
11956
|
function responseNonemptyText(value, field) {
|
|
11245
11957
|
const valueText = responseText(value, field);
|
|
11246
|
-
if (!valueText.trim()) throw
|
|
11958
|
+
if (!valueText.trim()) throw invalidResponse4(field + " must be nonempty");
|
|
11247
11959
|
return valueText;
|
|
11248
11960
|
}
|
|
11249
11961
|
function requireRequestID(value) {
|
|
@@ -11334,20 +12046,20 @@ function requireText2(value, field) {
|
|
|
11334
12046
|
}
|
|
11335
12047
|
function responseID(value, field) {
|
|
11336
12048
|
if (typeof value === "number") {
|
|
11337
|
-
throw
|
|
12049
|
+
throw invalidResponse4(
|
|
11338
12050
|
`${field} must be a decimal string; numeric IDs are unsafe`
|
|
11339
12051
|
);
|
|
11340
12052
|
}
|
|
11341
12053
|
try {
|
|
11342
12054
|
return requireID(value, field);
|
|
11343
12055
|
} catch {
|
|
11344
|
-
throw
|
|
12056
|
+
throw invalidResponse4(`${field} must be a positive int64 decimal string`);
|
|
11345
12057
|
}
|
|
11346
12058
|
}
|
|
11347
12059
|
function responseIDs(value, field) {
|
|
11348
|
-
if (!Array.isArray(value)) throw
|
|
12060
|
+
if (!Array.isArray(value)) throw invalidResponse4(`${field} must be an array`);
|
|
11349
12061
|
if (value.length > MAX_ENTITY_IDS) {
|
|
11350
|
-
throw
|
|
12062
|
+
throw invalidResponse4(
|
|
11351
12063
|
`${field} must contain at most ${MAX_ENTITY_IDS} IDs`
|
|
11352
12064
|
);
|
|
11353
12065
|
}
|
|
@@ -11357,33 +12069,33 @@ function responseText(value, field) {
|
|
|
11357
12069
|
try {
|
|
11358
12070
|
return requireText2(value, field);
|
|
11359
12071
|
} catch {
|
|
11360
|
-
throw
|
|
12072
|
+
throw invalidResponse4(`${field} must be valid text`);
|
|
11361
12073
|
}
|
|
11362
12074
|
}
|
|
11363
12075
|
function responseClosingNote(value) {
|
|
11364
12076
|
try {
|
|
11365
12077
|
return requireText2(value, "note");
|
|
11366
12078
|
} catch {
|
|
11367
|
-
throw
|
|
12079
|
+
throw invalidResponse4("thesis.closing_note must be valid text");
|
|
11368
12080
|
}
|
|
11369
12081
|
}
|
|
11370
12082
|
function responseBoolean(value, field) {
|
|
11371
12083
|
if (typeof value !== "boolean")
|
|
11372
|
-
throw
|
|
12084
|
+
throw invalidResponse4(`${field} must be boolean`);
|
|
11373
12085
|
return value;
|
|
11374
12086
|
}
|
|
11375
12087
|
function responseVisibility(value) {
|
|
11376
12088
|
try {
|
|
11377
12089
|
return requireVisibility(value);
|
|
11378
12090
|
} catch {
|
|
11379
|
-
throw
|
|
12091
|
+
throw invalidResponse4("thesis.visibility must be public, private or paid");
|
|
11380
12092
|
}
|
|
11381
12093
|
}
|
|
11382
12094
|
function responseBody(value) {
|
|
11383
12095
|
try {
|
|
11384
12096
|
return requireBody(value);
|
|
11385
12097
|
} catch {
|
|
11386
|
-
throw
|
|
12098
|
+
throw invalidResponse4(
|
|
11387
12099
|
"response body must be nonblank valid text at most 65536 UTF-8 bytes"
|
|
11388
12100
|
);
|
|
11389
12101
|
}
|
|
@@ -11392,7 +12104,7 @@ function responseTitle(value) {
|
|
|
11392
12104
|
try {
|
|
11393
12105
|
return requireTitle(value);
|
|
11394
12106
|
} catch {
|
|
11395
|
-
throw
|
|
12107
|
+
throw invalidResponse4(
|
|
11396
12108
|
"response title must be valid text at most 500 UTF-8 bytes"
|
|
11397
12109
|
);
|
|
11398
12110
|
}
|
|
@@ -11412,7 +12124,7 @@ function completeEntityStances(entityIDs, stances) {
|
|
|
11412
12124
|
function invalidArgument(message) {
|
|
11413
12125
|
return new AlvaError("INVALID_ARGUMENT", message, 400);
|
|
11414
12126
|
}
|
|
11415
|
-
function
|
|
12127
|
+
function invalidResponse4(message) {
|
|
11416
12128
|
return new AlvaError("INVALID_RESPONSE", message, 502);
|
|
11417
12129
|
}
|
|
11418
12130
|
function validMedia(item) {
|
|
@@ -11433,10 +12145,10 @@ async function thesisGraphql(client, query, variables) {
|
|
|
11433
12145
|
body: { query, variables }
|
|
11434
12146
|
});
|
|
11435
12147
|
if (!isRecord2(response))
|
|
11436
|
-
throw
|
|
12148
|
+
throw invalidResponse4("GraphQL response must be an object");
|
|
11437
12149
|
if (response.errors !== void 0) {
|
|
11438
12150
|
if (!Array.isArray(response.errors))
|
|
11439
|
-
throw
|
|
12151
|
+
throw invalidResponse4("GraphQL errors must be an array");
|
|
11440
12152
|
if (response.errors.length > 0) {
|
|
11441
12153
|
const messages = response.errors.flatMap(
|
|
11442
12154
|
(error) => isRecord2(error) && typeof error.message === "string" ? [error.message] : []
|
|
@@ -11458,7 +12170,7 @@ async function thesisGraphql(client, query, variables) {
|
|
|
11458
12170
|
}
|
|
11459
12171
|
}
|
|
11460
12172
|
if (!isRecord2(response.data))
|
|
11461
|
-
throw
|
|
12173
|
+
throw invalidResponse4("GraphQL response must contain data");
|
|
11462
12174
|
return response.data;
|
|
11463
12175
|
}
|
|
11464
12176
|
|
|
@@ -11468,7 +12180,7 @@ var CREATE_COMPANY_NEWS = `mutation CreateCompanyNews($input: CompanyNewsFeedInp
|
|
|
11468
12180
|
createFeed(input: $input) { id producer { id } }
|
|
11469
12181
|
}
|
|
11470
12182
|
}`;
|
|
11471
|
-
var
|
|
12183
|
+
var GRAPHQL_STATUS_BY_CODE5 = {
|
|
11472
12184
|
INVALID_ARGUMENT: 400,
|
|
11473
12185
|
UNAUTHENTICATED: 401,
|
|
11474
12186
|
PERMISSION_DENIED: 403,
|
|
@@ -11537,7 +12249,7 @@ var CompanyNewsResource = class {
|
|
|
11537
12249
|
throw new AlvaError(
|
|
11538
12250
|
code,
|
|
11539
12251
|
graph.errors.map((error) => error?.message).filter(Boolean).join("; ") || "Company News creation failed",
|
|
11540
|
-
|
|
12252
|
+
GRAPHQL_STATUS_BY_CODE5[code] ?? 502,
|
|
11541
12253
|
{ errors: graph.errors }
|
|
11542
12254
|
);
|
|
11543
12255
|
}
|
|
@@ -11663,6 +12375,7 @@ var AlvaClient = class {
|
|
|
11663
12375
|
_notifications;
|
|
11664
12376
|
_notificationPreferences;
|
|
11665
12377
|
_subscriptions;
|
|
12378
|
+
_follows;
|
|
11666
12379
|
_alerts;
|
|
11667
12380
|
_channelGroupSubscriptions;
|
|
11668
12381
|
_feedback;
|
|
@@ -11754,6 +12467,9 @@ var AlvaClient = class {
|
|
|
11754
12467
|
get subscriptions() {
|
|
11755
12468
|
return this._subscriptions ??= new SubscriptionsResource(this);
|
|
11756
12469
|
}
|
|
12470
|
+
get follows() {
|
|
12471
|
+
return this._follows ??= new FollowsResource(this);
|
|
12472
|
+
}
|
|
11757
12473
|
get alerts() {
|
|
11758
12474
|
return this._alerts ??= new AlertsResource(this);
|
|
11759
12475
|
}
|
|
@@ -11943,7 +12659,8 @@ var AlvaClient = class {
|
|
|
11943
12659
|
throw new AlvaError(
|
|
11944
12660
|
data.error.code ?? "UNKNOWN",
|
|
11945
12661
|
data.error.message ?? `HTTP ${response.status}`,
|
|
11946
|
-
response.status
|
|
12662
|
+
response.status,
|
|
12663
|
+
data.details
|
|
11947
12664
|
);
|
|
11948
12665
|
}
|
|
11949
12666
|
} catch (e) {
|
|
@@ -12237,14 +12954,21 @@ var COMMAND_DEFINITIONS = [
|
|
|
12237
12954
|
values: ["inbox-path", "delivery-id", "request-id"]
|
|
12238
12955
|
}),
|
|
12239
12956
|
command("steward send", {
|
|
12240
|
-
values: [
|
|
12957
|
+
values: [
|
|
12958
|
+
"inbox-path",
|
|
12959
|
+
"body",
|
|
12960
|
+
"delivery-ids",
|
|
12961
|
+
"request-id",
|
|
12962
|
+
"digest-run-id"
|
|
12963
|
+
]
|
|
12241
12964
|
}),
|
|
12242
12965
|
command("steward pending", {
|
|
12243
|
-
values: ["inbox-path", "
|
|
12966
|
+
values: ["inbox-path", "since", "until", "first", "digest-run-id"]
|
|
12244
12967
|
}),
|
|
12245
12968
|
command("steward briefed", {
|
|
12246
12969
|
values: ["inbox-path", "delivery-ids", "digest-run-id"]
|
|
12247
12970
|
}),
|
|
12971
|
+
command("steward status", { values: ["inbox-path", "digest-run-id"] }),
|
|
12248
12972
|
command("company-news create", {
|
|
12249
12973
|
values: ["name", "tickers", "initial-lookback-hours", "page-size"]
|
|
12250
12974
|
}),
|
|
@@ -12258,11 +12982,16 @@ var COMMAND_DEFINITIONS = [
|
|
|
12258
12982
|
"entity-ids",
|
|
12259
12983
|
"entity-stances",
|
|
12260
12984
|
"tickers",
|
|
12261
|
-
"visibility"
|
|
12985
|
+
"visibility",
|
|
12986
|
+
"track-return"
|
|
12262
12987
|
],
|
|
12263
12988
|
booleans: ["body-stdin"]
|
|
12264
12989
|
}),
|
|
12265
|
-
command("thesis asset-candidates", {
|
|
12990
|
+
command("thesis asset-candidates", {
|
|
12991
|
+
values: ["text", "entity-ids", "thesis-id"],
|
|
12992
|
+
booleans: ["no-discovery"]
|
|
12993
|
+
}),
|
|
12994
|
+
command("thesis return", { values: ["id"], booleans: ["detail"] }),
|
|
12266
12995
|
command("thesis list", {
|
|
12267
12996
|
values: [
|
|
12268
12997
|
"person",
|
|
@@ -12278,9 +13007,6 @@ var COMMAND_DEFINITIONS = [
|
|
|
12278
13007
|
command("thesis related", { values: ["id", "first", "cursor"] }),
|
|
12279
13008
|
command("thesis get", { values: ["id"] }),
|
|
12280
13009
|
command("thesis version list", { values: ["id", "first", "cursor"] }),
|
|
12281
|
-
command("thesis version delete", {
|
|
12282
|
-
values: ["id", "author-version-id", "expected-author-version-id"]
|
|
12283
|
-
}),
|
|
12284
13010
|
command("thesis version get", {
|
|
12285
13011
|
values: ["id", "author-version-id"]
|
|
12286
13012
|
}),
|
|
@@ -12302,14 +13028,11 @@ var COMMAND_DEFINITIONS = [
|
|
|
12302
13028
|
"entity-ids",
|
|
12303
13029
|
"entity-stances",
|
|
12304
13030
|
"medias",
|
|
12305
|
-
"visibility"
|
|
13031
|
+
"visibility",
|
|
13032
|
+
"track-return"
|
|
12306
13033
|
],
|
|
12307
|
-
booleans: ["body-stdin"
|
|
12308
|
-
}),
|
|
12309
|
-
command("thesis close", {
|
|
12310
|
-
values: ["id", "expected-author-version-id", "note"]
|
|
13034
|
+
booleans: ["body-stdin"]
|
|
12311
13035
|
}),
|
|
12312
|
-
command("thesis delete", { values: ["id"] }),
|
|
12313
13036
|
command("thesis rewrite", {
|
|
12314
13037
|
values: ["body", "body-file", "mode"],
|
|
12315
13038
|
booleans: ["body-stdin"]
|
|
@@ -12610,9 +13333,18 @@ var COMMAND_DEFINITIONS = [
|
|
|
12610
13333
|
values: ["account-id", "limit", "page-token"]
|
|
12611
13334
|
}),
|
|
12612
13335
|
command("markets narrative", { values: ["ticker"] }),
|
|
13336
|
+
command("markets watchlist"),
|
|
13337
|
+
command("markets watchlist list", { values: ["limit", "cursor"] }),
|
|
13338
|
+
command("markets watchlist add", { values: ["tickers", "kind"] }),
|
|
13339
|
+
command("markets watchlist remove", { values: ["tickers", "kind"] }),
|
|
12613
13340
|
command("markets earnings", {
|
|
12614
13341
|
values: ["ticker", "event", "fiscal-year", "fiscal-quarter"]
|
|
12615
13342
|
}),
|
|
13343
|
+
command("people search", { values: ["query", "kind", "limit"] }),
|
|
13344
|
+
command("people follows"),
|
|
13345
|
+
command("people follows list", { values: ["kind", "limit", "cursor"] }),
|
|
13346
|
+
command("people follows follow", { values: ["kind", "id"] }),
|
|
13347
|
+
command("people follows unfollow", { values: ["kind", "id"] }),
|
|
12616
13348
|
command("trading-pairs search", {
|
|
12617
13349
|
values: [
|
|
12618
13350
|
"symbol",
|
|
@@ -16987,7 +17719,7 @@ function formatTradingPairResolved(result) {
|
|
|
16987
17719
|
}
|
|
16988
17720
|
|
|
16989
17721
|
// src/cli/dispatch.ts
|
|
16990
|
-
var CLI_VERSION = true ? "0.
|
|
17722
|
+
var CLI_VERSION = true ? "0.36.0-beta.0" : "dev";
|
|
16991
17723
|
var DEFAULT_RUN_TIMEOUT_MS = 6e5;
|
|
16992
17724
|
var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
|
|
16993
17725
|
var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
|
|
@@ -17055,7 +17787,8 @@ Commands:
|
|
|
17055
17787
|
subscriptions Playbook follows and feed alert subscriptions
|
|
17056
17788
|
remix Save playbook remix lineage
|
|
17057
17789
|
portfolio Connected-account portfolio (accounts, summary, activities)
|
|
17058
|
-
markets Company
|
|
17790
|
+
markets Company context and the ticker watchlist (narrative, earnings, watchlist list|add|remove)
|
|
17791
|
+
people Search, follow, and unfollow Alva users and curated people (search, follows list|follow|unfollow)
|
|
17059
17792
|
trading-pairs Discover and strictly verify canonical trading pairs (search, resolve)
|
|
17060
17793
|
trading Trading operations (accounts, portfolio, orders, subscriptions, equity-history, risk-rules, subscribe, unsubscribe, execute, update-risk-rules)
|
|
17061
17794
|
broker Agentic order execution \u2014 venue-native passthrough to trex (accounts, quote, order, balance, positions, ...; run 'alva broker describe')
|
|
@@ -17110,31 +17843,30 @@ Embedded commands target the host-attached Inbox; the terminal CLI requires
|
|
|
17110
17843
|
Subcommands:
|
|
17111
17844
|
decide Record the decision for one delivery (required before forward/send)
|
|
17112
17845
|
forward Re-post the original alert card by reference (immediate only)
|
|
17113
|
-
|
|
17114
|
-
pending
|
|
17115
|
-
|
|
17846
|
+
status Read one durable Daily Brief run
|
|
17847
|
+
pending Read a durable run's complete fixed-window set, or use legacy bounds
|
|
17848
|
+
send Publish and complete a durable run, or use the legacy send contract
|
|
17849
|
+
briefed Record that a Daily Brief covered at most 100 listed deliveries
|
|
17116
17850
|
|
|
17117
17851
|
Flags:
|
|
17118
17852
|
--inbox-path <path> Steward Session Inbox (terminal CLI only)
|
|
17119
17853
|
--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)
|
|
17854
|
+
--delivery-ids <a,b,c> Comma-separated deliveries (legacy briefed: max 100; optional for send \u2014 omit for a For-You-only Brief)
|
|
17121
17855
|
--decision <immediate|digest|suppress>
|
|
17122
17856
|
--reason <text> Short audit note stored with the decision
|
|
17123
|
-
--body <markdown> Message body (send)
|
|
17857
|
+
--body <markdown> Message body (durable send: omit when reviewed coverage yields no useful content)
|
|
17124
17858
|
--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)
|
|
17859
|
+
--since <RFC3339> Lower bound on decision time (pending)
|
|
17860
|
+
--until <RFC3339> Fixed upper bound of the Brief window (pending)
|
|
17861
|
+
--first <n> Internal page size, 1-100 (terminal pending only)
|
|
17862
|
+
--digest-run-id <uuid> Durable run identity (status/pending/send)
|
|
17130
17863
|
|
|
17131
17864
|
Examples (terminal; the embedded Agent tool omits --inbox-path):
|
|
17132
17865
|
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
17866
|
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>
|
|
17867
|
+
alva steward status --inbox-path <inbox> --digest-run-id <uuid>
|
|
17868
|
+
alva steward pending --inbox-path <inbox> --digest-run-id <uuid>
|
|
17869
|
+
alva steward send --inbox-path <inbox> --digest-run-id <uuid> --delivery-ids 124,125 --body "Daily Brief..."
|
|
17138
17870
|
alva steward briefed --inbox-path <inbox> --digest-run-id <request id echoed by send> --delivery-ids 124,125`,
|
|
17139
17871
|
configure: `Usage: alva configure --api-key <key> [--base-url <url>] [--profile <name>]
|
|
17140
17872
|
|
|
@@ -18279,6 +19011,8 @@ owners, feed slugs, versions, or paths.
|
|
|
18279
19011
|
Subcommands:
|
|
18280
19012
|
narrative Get the current narrative, history, and narrative change log
|
|
18281
19013
|
earnings Get Pre, Release, Transcript, and Post for one fiscal event
|
|
19014
|
+
watchlist list|add|remove
|
|
19015
|
+
The user's ticker watchlist in the Alva App
|
|
18282
19016
|
|
|
18283
19017
|
Narrative flags:
|
|
18284
19018
|
--ticker <symbol> Stock ticker (required)
|
|
@@ -18292,6 +19026,21 @@ Earnings flags:
|
|
|
18292
19026
|
Do not combine --event with --fiscal-year/--fiscal-quarter. These commands read
|
|
18293
19027
|
the current backend view; historical query-as-of gating is not supported yet.
|
|
18294
19028
|
|
|
19029
|
+
Watchlist flags:
|
|
19030
|
+
--tickers <A,B> add/remove: 1-50 exact symbols (required).
|
|
19031
|
+
Suffix one symbol with :stock, :etf, or
|
|
19032
|
+
:crypto to pick its kind (BTC:crypto)
|
|
19033
|
+
--kind <stock|etf|crypto> add/remove: default kind for unsuffixed symbols
|
|
19034
|
+
--limit <1-100> list: page size (default 20)
|
|
19035
|
+
--cursor <endCursor> list: pageInfo.endCursor of the previous page
|
|
19036
|
+
|
|
19037
|
+
add/remove write every resolved symbol in one atomic batch. Result groups:
|
|
19038
|
+
added|removed (written now), unchanged (already in that state), unresolved
|
|
19039
|
+
(NOT_FOUND, or FAILED_PRECONDITION = several entities share the symbol:
|
|
19040
|
+
retry it with a kind suffix). Nothing is written when no symbol resolves.
|
|
19041
|
+
remove is recorded even for symbols not in the watchlist, so holdings sync
|
|
19042
|
+
does not add them back; add re-adds a symbol the user removed earlier.
|
|
19043
|
+
|
|
18295
19044
|
Output semantics:
|
|
18296
19045
|
Narrative is dated Alva analysis. Use current for present-tense company
|
|
18297
19046
|
context and history only to explain changes; use separate sources for live
|
|
@@ -18309,7 +19058,32 @@ Examples:
|
|
|
18309
19058
|
alva markets narrative --ticker AAPL
|
|
18310
19059
|
alva markets earnings --ticker AAPL
|
|
18311
19060
|
alva markets earnings --ticker AAPL --event next-confirmed
|
|
18312
|
-
alva markets earnings --ticker AAPL --fiscal-year 2026 --fiscal-quarter Q3
|
|
19061
|
+
alva markets earnings --ticker AAPL --fiscal-year 2026 --fiscal-quarter Q3
|
|
19062
|
+
alva markets watchlist add --tickers NVDA,LMT,BTC:crypto
|
|
19063
|
+
alva markets watchlist list --limit 50`,
|
|
19064
|
+
people: `Usage: alva people <subcommand> [options]
|
|
19065
|
+
|
|
19066
|
+
Search and follow public profiles: USER is an Alva user, PERSON is a curated
|
|
19067
|
+
person. These change the same Following list the user sees in the Alva App.
|
|
19068
|
+
|
|
19069
|
+
Subcommands:
|
|
19070
|
+
search Prefix match on name, username, slug, or alias
|
|
19071
|
+
follows list List the profiles the caller follows
|
|
19072
|
+
follows follow Follow one profile (idempotent)
|
|
19073
|
+
follows unfollow Unfollow one profile (idempotent)
|
|
19074
|
+
|
|
19075
|
+
Flags:
|
|
19076
|
+
--query <text> search: name or username prefix (required)
|
|
19077
|
+
--kind <user|person> search/list: optional filter; follow/unfollow:
|
|
19078
|
+
required, from a search or list result
|
|
19079
|
+
--id <id> follow/unfollow: profile id (required)
|
|
19080
|
+
--limit <1-50> search/list: page size
|
|
19081
|
+
--cursor <endCursor> list: pageInfo.endCursor of the previous page
|
|
19082
|
+
|
|
19083
|
+
Examples:
|
|
19084
|
+
alva people search --query "cathie wood" --kind person
|
|
19085
|
+
alva people follows follow --kind person --id 42
|
|
19086
|
+
alva people follows list`,
|
|
18313
19087
|
"trading-pairs": `Usage: alva trading-pairs <subcommand> [options]
|
|
18314
19088
|
|
|
18315
19089
|
Discover canonical trading-pair identities before backtesting or trading.
|
|
@@ -18419,7 +19193,7 @@ Examples:
|
|
|
18419
19193
|
alva arrays token status`,
|
|
18420
19194
|
thesis: `Usage: alva thesis <subcommand> [options]
|
|
18421
19195
|
|
|
18422
|
-
Create, read, inspect Signals and exact author versions,
|
|
19196
|
+
Create, read, inspect Signals and exact author versions, publish Updates to, or explicitly rewrite an authored thesis.
|
|
18423
19197
|
Backend owns Signal/Alert setup; the CLI never starts them separately.
|
|
18424
19198
|
Create and update never rewrite text automatically.
|
|
18425
19199
|
|
|
@@ -18430,7 +19204,6 @@ Subcommands:
|
|
|
18430
19204
|
get Get one thesis
|
|
18431
19205
|
version get Get one exact author version
|
|
18432
19206
|
version list List visible Updates with editorial revisions folded together
|
|
18433
|
-
version delete Delete one Update; restore prior content if it is current
|
|
18434
19207
|
signals Read published Signal history
|
|
18435
19208
|
set-visibility Change current access without publishing a version
|
|
18436
19209
|
archive Archive the current author version
|
|
@@ -18438,9 +19211,7 @@ Subcommands:
|
|
|
18438
19211
|
star Add the Thesis to your bookmarks
|
|
18439
19212
|
unstar Remove the Thesis from your bookmarks
|
|
18440
19213
|
set-signal-enabled Enable or disable managed Signal research
|
|
18441
|
-
update
|
|
18442
|
-
close Close the current author version with an optional note
|
|
18443
|
-
delete Delete a thesis
|
|
19214
|
+
update Publish a new Update replacing body, title, entities, visibility (all sent in full)
|
|
18444
19215
|
rewrite Explicitly request a candidate body rewrite; never called by another command
|
|
18445
19216
|
|
|
18446
19217
|
Body input (create, update, rewrite): choose exactly one:
|
|
@@ -18455,7 +19226,7 @@ the backend; do not send a fresh ID. Create defaults --visibility to public.
|
|
|
18455
19226
|
Update requires --visibility explicitly so it cannot inadvertently publish.
|
|
18456
19227
|
|
|
18457
19228
|
Other flags:
|
|
18458
|
-
create --request-id <uuid> --body ... [--images <json-array-of-https-urls>] [--title <text>] [--tickers <ticker,ticker>] [--entity-ids <id,id>] [--entity-stances <json>] [--visibility <value>]
|
|
19229
|
+
create --request-id <uuid> --body ... [--images <json-array-of-https-urls>] [--title <text>] [--tickers <ticker,ticker>] [--entity-ids <id,id>] [--entity-stances <json>] [--visibility <value>] [--track-return true|false]
|
|
18459
19230
|
Images: public creation only, at most 20 in display order. Upload selected files
|
|
18460
19231
|
with the existing host upload tool after publication confirmation. Private
|
|
18461
19232
|
images and local/ALFS paths are not supported; this flag does not upload.
|
|
@@ -18473,12 +19244,14 @@ Other flags:
|
|
|
18473
19244
|
publication.playbookId is the ID for get/version/signals/related;
|
|
18474
19245
|
publication=null means no readable snapshot. Author lists include the
|
|
18475
19246
|
signed-in owner's private Theses (visibility private).
|
|
18476
|
-
asset-candidates --text <unsaved thesis text>
|
|
19247
|
+
asset-candidates --text <unsaved thesis text> [--entity-ids <id,id>] [--thesis-id <id>] [--no-discovery]
|
|
19248
|
+
--no-discovery only classifies --entity-ids (no ticker discovery) and
|
|
19249
|
+
returns returnPreview: the directions publishing would store, the return
|
|
19250
|
+
switch (askSwitch) and lastLegRemoved. --thesis-id seeds an Update.
|
|
19251
|
+
return --id <id> [--detail] the Thesis return; --detail adds each Update's positions
|
|
18477
19252
|
get --id <signed-int64-decimal>
|
|
18478
19253
|
version get --id <signed-int64-decimal> --author-version-id <signed-int64-decimal>
|
|
18479
19254
|
version list --id <id> [--first <1-100>] [--cursor <next_cursor>]
|
|
18480
|
-
version delete --id <id> --author-version-id <selected> --expected-author-version-id <current>
|
|
18481
|
-
Cannot remove the last Update. Never falls back to whole-Thesis deletion.
|
|
18482
19255
|
signals --id <id> [--first <1-50>] [--cursor <opaque-cursor>]
|
|
18483
19256
|
set-visibility --id <id> --visibility public|private
|
|
18484
19257
|
archive --id <id> --request-id <uuid> [--note <text>]
|
|
@@ -18499,13 +19272,12 @@ Maintenance behavior:
|
|
|
18499
19272
|
set-signal-enabled changes managed Signal research without deleting history.
|
|
18500
19273
|
The command returns enabled, research_paused, archived, and author version
|
|
18501
19274
|
state; GraphQL errors and noncanonical error codes fail closed.
|
|
18502
|
-
update --id <id> --request-id <uuid> --expected-author-version-id <id> --body ... --visibility <value> [--title <text>] [--entity-ids <id,id>] [--entity-stances <json>] [--medias <json-array>] [--
|
|
19275
|
+
update --id <id> --request-id <uuid> --expected-author-version-id <id> --body ... --visibility <value> [--title <text>] [--entity-ids <id,id>] [--entity-stances <json>] [--medias <json-array>] [--track-return true|false]
|
|
18503
19276
|
For text edits, pass current medias unchanged; omission clears media.
|
|
18504
19277
|
|
|
18505
19278
|
Only editing the body? Resubmit the existing entity IDs and directions.
|
|
18506
|
-
|
|
18507
|
-
|
|
18508
|
-
delete --id <id>
|
|
19279
|
+
On an Update, an omitted or unknown direction of a carried ticker keeps its
|
|
19280
|
+
previous direction; none is an exit.
|
|
18509
19281
|
rewrite --body ... [--mode reformat|shorten|enrich]
|
|
18510
19282
|
|
|
18511
19283
|
Rewrite mode defaults only when omitted, and the toolkit always sends the
|
|
@@ -18760,19 +19532,19 @@ function deliveryProviderFilter(flags, command2) {
|
|
|
18760
19532
|
}
|
|
18761
19533
|
return flags["delivery-provider"];
|
|
18762
19534
|
}
|
|
18763
|
-
function projectUserProfileForCLI(
|
|
18764
|
-
const { active_channel: activeIMProvider, ...profile } =
|
|
19535
|
+
function projectUserProfileForCLI(record4) {
|
|
19536
|
+
const { active_channel: activeIMProvider, ...profile } = record4;
|
|
18765
19537
|
return { ...profile, active_im_provider: activeIMProvider };
|
|
18766
19538
|
}
|
|
18767
19539
|
function projectNotificationHistoryForCLI(response) {
|
|
18768
19540
|
if (response === null || typeof response !== "object" || Array.isArray(response)) {
|
|
18769
19541
|
return response;
|
|
18770
19542
|
}
|
|
18771
|
-
const
|
|
18772
|
-
if (!Array.isArray(
|
|
19543
|
+
const record4 = response;
|
|
19544
|
+
if (!Array.isArray(record4.items)) return response;
|
|
18773
19545
|
return {
|
|
18774
|
-
...
|
|
18775
|
-
items:
|
|
19546
|
+
...record4,
|
|
19547
|
+
items: record4.items.map((item) => {
|
|
18776
19548
|
if (item === null || typeof item !== "object" || Array.isArray(item)) {
|
|
18777
19549
|
return item;
|
|
18778
19550
|
}
|
|
@@ -18786,6 +19558,111 @@ function num(val) {
|
|
|
18786
19558
|
const n = Number(val);
|
|
18787
19559
|
return Number.isNaN(n) ? void 0 : n;
|
|
18788
19560
|
}
|
|
19561
|
+
function upperFlag(val) {
|
|
19562
|
+
return val === void 0 ? void 0 : val.trim().toUpperCase();
|
|
19563
|
+
}
|
|
19564
|
+
function optionalCursorFlag(val) {
|
|
19565
|
+
if (val === void 0) return void 0;
|
|
19566
|
+
if (!val.trim() || val.length > 4096) {
|
|
19567
|
+
throw new Error(
|
|
19568
|
+
"--cursor must be a non-empty cursor of at most 4096 characters"
|
|
19569
|
+
);
|
|
19570
|
+
}
|
|
19571
|
+
return val;
|
|
19572
|
+
}
|
|
19573
|
+
function usageChecked(command2, check) {
|
|
19574
|
+
try {
|
|
19575
|
+
return check();
|
|
19576
|
+
} catch (error) {
|
|
19577
|
+
if (error instanceof CliUsageError) throw error;
|
|
19578
|
+
throw new CliUsageError(
|
|
19579
|
+
error instanceof Error ? error.message : String(error),
|
|
19580
|
+
command2.split(" ")[0]
|
|
19581
|
+
);
|
|
19582
|
+
}
|
|
19583
|
+
}
|
|
19584
|
+
function dispatchWatchlist(client, leaf, flags) {
|
|
19585
|
+
switch (leaf) {
|
|
19586
|
+
case void 0:
|
|
19587
|
+
return { _help: true, text: COMMAND_HELP.markets };
|
|
19588
|
+
case "add":
|
|
19589
|
+
case "remove": {
|
|
19590
|
+
const command2 = `markets watchlist ${leaf}`;
|
|
19591
|
+
const params = usageChecked(
|
|
19592
|
+
command2,
|
|
19593
|
+
() => normalizeWatchlistTickersParams({
|
|
19594
|
+
tickers: (csvList(requireFlag(flags, "tickers", command2)) ?? []).map(
|
|
19595
|
+
parseTickerSpec
|
|
19596
|
+
),
|
|
19597
|
+
kind: upperFlag(flags["kind"])
|
|
19598
|
+
})
|
|
19599
|
+
);
|
|
19600
|
+
return leaf === "add" ? client.follows.addToWatchlist(params) : client.follows.removeFromWatchlist(params);
|
|
19601
|
+
}
|
|
19602
|
+
case "list": {
|
|
19603
|
+
const command2 = "markets watchlist list";
|
|
19604
|
+
return client.follows.watchlist({
|
|
19605
|
+
first: optionalBoundedIntegerFlag(flags, "limit", command2, 1, 100),
|
|
19606
|
+
after: usageChecked(command2, () => optionalCursorFlag(flags["cursor"]))
|
|
19607
|
+
});
|
|
19608
|
+
}
|
|
19609
|
+
default:
|
|
19610
|
+
throw new CliUsageError(
|
|
19611
|
+
`Unknown subcommand: markets watchlist ${leaf}`,
|
|
19612
|
+
"markets"
|
|
19613
|
+
);
|
|
19614
|
+
}
|
|
19615
|
+
}
|
|
19616
|
+
function dispatchPeople(client, path, flags) {
|
|
19617
|
+
const [subcommand, leaf] = path;
|
|
19618
|
+
if (subcommand === void 0 || subcommand === "follows" && !leaf) {
|
|
19619
|
+
return { _help: true, text: COMMAND_HELP.people };
|
|
19620
|
+
}
|
|
19621
|
+
const command2 = ["people", ...path].join(" ");
|
|
19622
|
+
switch (subcommand === "follows" ? `follows ${leaf}` : subcommand) {
|
|
19623
|
+
case "search":
|
|
19624
|
+
return client.follows.searchProfiles(
|
|
19625
|
+
usageChecked(
|
|
19626
|
+
command2,
|
|
19627
|
+
() => validateSearchProfilesParams({
|
|
19628
|
+
query: requireFlag(flags, "query", command2),
|
|
19629
|
+
kind: upperFlag(flags["kind"]),
|
|
19630
|
+
first: optionalBoundedIntegerFlag(flags, "limit", command2, 1, 50)
|
|
19631
|
+
})
|
|
19632
|
+
)
|
|
19633
|
+
);
|
|
19634
|
+
case "follows list":
|
|
19635
|
+
return client.follows.profiles({
|
|
19636
|
+
kind: usageChecked(
|
|
19637
|
+
command2,
|
|
19638
|
+
() => optionalProfileKind(upperFlag(flags["kind"]))
|
|
19639
|
+
),
|
|
19640
|
+
first: optionalBoundedIntegerFlag(flags, "limit", command2, 1, 50),
|
|
19641
|
+
after: usageChecked(command2, () => optionalCursorFlag(flags["cursor"]))
|
|
19642
|
+
});
|
|
19643
|
+
case "follows follow":
|
|
19644
|
+
case "follows unfollow": {
|
|
19645
|
+
const params = usageChecked(
|
|
19646
|
+
command2,
|
|
19647
|
+
() => validateProfileRef({
|
|
19648
|
+
kind: upperFlag(
|
|
19649
|
+
requireFlag(flags, "kind", command2)
|
|
19650
|
+
),
|
|
19651
|
+
id: requireFlag(flags, "id", command2)
|
|
19652
|
+
})
|
|
19653
|
+
);
|
|
19654
|
+
return leaf === "follow" ? client.follows.followProfile(params) : client.follows.unfollowProfile(params);
|
|
19655
|
+
}
|
|
19656
|
+
default:
|
|
19657
|
+
throw new CliUsageError(`Unknown subcommand: ${command2}`, "people");
|
|
19658
|
+
}
|
|
19659
|
+
}
|
|
19660
|
+
function optionalProfileKind(kind) {
|
|
19661
|
+
if (kind !== void 0 && kind !== "USER" && kind !== "PERSON") {
|
|
19662
|
+
throw new Error("kind must be USER or PERSON");
|
|
19663
|
+
}
|
|
19664
|
+
return kind;
|
|
19665
|
+
}
|
|
18789
19666
|
function csvList(val) {
|
|
18790
19667
|
if (val === void 0) return void 0;
|
|
18791
19668
|
const values = val.split(",").map((item) => item.trim()).filter(Boolean);
|
|
@@ -19292,6 +20169,17 @@ function thesisImages(flags) {
|
|
|
19292
20169
|
"thesis"
|
|
19293
20170
|
);
|
|
19294
20171
|
}
|
|
20172
|
+
function thesisTrackReturn(flags, command2) {
|
|
20173
|
+
const raw = flags["track-return"];
|
|
20174
|
+
if (raw === void 0) return void 0;
|
|
20175
|
+
const parsed = boolFlag(raw);
|
|
20176
|
+
if (parsed === void 0)
|
|
20177
|
+
throw new CliUsageError(
|
|
20178
|
+
`--track-return must be true or false for ${command2}`,
|
|
20179
|
+
"thesis"
|
|
20180
|
+
);
|
|
20181
|
+
return parsed;
|
|
20182
|
+
}
|
|
19295
20183
|
function thesisEntityStances(flags) {
|
|
19296
20184
|
const raw = flags["entity-stances"];
|
|
19297
20185
|
if (raw === void 0) return void 0;
|
|
@@ -19467,7 +20355,7 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19467
20355
|
const positionals = parsedCommand.positionals;
|
|
19468
20356
|
if (group === "whoami") {
|
|
19469
20357
|
const user = await client.user.me();
|
|
19470
|
-
const
|
|
20358
|
+
const record4 = projectUserProfileForCLI(
|
|
19471
20359
|
user
|
|
19472
20360
|
);
|
|
19473
20361
|
const version = meta?.cliVersion ?? CLI_VERSION;
|
|
@@ -19484,10 +20372,10 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19484
20372
|
metaBlock.arrays_jwt = arraysJwtStatus;
|
|
19485
20373
|
}
|
|
19486
20374
|
const result = {
|
|
19487
|
-
...
|
|
20375
|
+
...record4,
|
|
19488
20376
|
_meta: metaBlock
|
|
19489
20377
|
};
|
|
19490
|
-
const minVersion =
|
|
20378
|
+
const minVersion = record4.toolkit_min_version;
|
|
19491
20379
|
if (typeof minVersion === "string" && version && version !== "dev" && isVersionOlderThan(version, minVersion)) {
|
|
19492
20380
|
result._warning = `Warning: your toolkit version (${version}) is older than the minimum recommended version (${minVersion}). Please upgrade: npm install -g @alva-ai/toolkit`;
|
|
19493
20381
|
}
|
|
@@ -19861,6 +20749,14 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19861
20749
|
requestId: flags["request-id"]
|
|
19862
20750
|
});
|
|
19863
20751
|
case "send":
|
|
20752
|
+
if (flags["digest-run-id"] !== void 0) {
|
|
20753
|
+
return client.steward.sendDigestRun({
|
|
20754
|
+
inboxPath,
|
|
20755
|
+
digestRunId: requireFlag(flags, "digest-run-id", "steward send"),
|
|
20756
|
+
deliveryIds: optionalIds("delivery-ids"),
|
|
20757
|
+
body: flags.body
|
|
20758
|
+
});
|
|
20759
|
+
}
|
|
19864
20760
|
return client.steward.send({
|
|
19865
20761
|
inboxPath,
|
|
19866
20762
|
body: requireFlag(flags, "body", "steward send"),
|
|
@@ -19868,6 +20764,16 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19868
20764
|
requestId: flags["request-id"]
|
|
19869
20765
|
});
|
|
19870
20766
|
case "pending": {
|
|
20767
|
+
if (flags["digest-run-id"] !== void 0) {
|
|
20768
|
+
return client.steward.digestRunPending({
|
|
20769
|
+
inboxPath,
|
|
20770
|
+
digestRunId: requireFlag(
|
|
20771
|
+
flags,
|
|
20772
|
+
"digest-run-id",
|
|
20773
|
+
"steward pending"
|
|
20774
|
+
)
|
|
20775
|
+
});
|
|
20776
|
+
}
|
|
19871
20777
|
const parseTime = (name) => {
|
|
19872
20778
|
const value = flags[name];
|
|
19873
20779
|
if (value === void 0) return void 0;
|
|
@@ -19883,7 +20789,6 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19883
20789
|
const first = flags.first === void 0 ? void 0 : Number(flags.first);
|
|
19884
20790
|
return client.steward.pending({
|
|
19885
20791
|
inboxPath,
|
|
19886
|
-
after: flags.after,
|
|
19887
20792
|
sinceMs: parseTime("since"),
|
|
19888
20793
|
untilMs: parseTime("until"),
|
|
19889
20794
|
first
|
|
@@ -19895,6 +20800,11 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19895
20800
|
deliveryIds: ids("delivery-ids"),
|
|
19896
20801
|
digestRunId: requireFlag(flags, "digest-run-id", "steward briefed")
|
|
19897
20802
|
});
|
|
20803
|
+
case "status":
|
|
20804
|
+
return client.steward.digestRun({
|
|
20805
|
+
inboxPath,
|
|
20806
|
+
digestRunId: requireFlag(flags, "digest-run-id", "steward status")
|
|
20807
|
+
});
|
|
19898
20808
|
default:
|
|
19899
20809
|
throw new CliUsageError(
|
|
19900
20810
|
`Unknown subcommand: steward ${subcommand}`,
|
|
@@ -19948,11 +20858,22 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19948
20858
|
entity_ids: thesisEntityIDs(flags),
|
|
19949
20859
|
entity_stances: thesisEntityStances(flags),
|
|
19950
20860
|
tickers: thesisTickers(flags),
|
|
19951
|
-
visibility: flags.visibility === void 0 ? "public" : thesisCreateVisibility(flags.visibility)
|
|
20861
|
+
visibility: flags.visibility === void 0 ? "public" : thesisCreateVisibility(flags.visibility),
|
|
20862
|
+
track_return: thesisTrackReturn(flags, "thesis create")
|
|
19952
20863
|
});
|
|
19953
20864
|
case "asset-candidates":
|
|
19954
20865
|
return client.theses.assetCandidates(
|
|
19955
|
-
requireFlag(flags, "text", "thesis asset-candidates")
|
|
20866
|
+
requireFlag(flags, "text", "thesis asset-candidates"),
|
|
20867
|
+
{
|
|
20868
|
+
entityIds: thesisEntityIDs(flags),
|
|
20869
|
+
thesisId: flags["thesis-id"],
|
|
20870
|
+
discover: boolFlag(flags["no-discovery"]) !== true
|
|
20871
|
+
}
|
|
20872
|
+
);
|
|
20873
|
+
case "return":
|
|
20874
|
+
return client.theses.thesisReturn(
|
|
20875
|
+
requireFlag(flags, "id", "thesis return"),
|
|
20876
|
+
{ detail: boolFlag(flags.detail) === true }
|
|
19956
20877
|
);
|
|
19957
20878
|
case "list": {
|
|
19958
20879
|
const params = {
|
|
@@ -19999,17 +20920,6 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19999
20920
|
}
|
|
20000
20921
|
);
|
|
20001
20922
|
}
|
|
20002
|
-
if (parsedCommand.path[2] === "delete") {
|
|
20003
|
-
return client.theses.deleteUpdate(
|
|
20004
|
-
requireFlag(flags, "id", "thesis version delete"),
|
|
20005
|
-
requireFlag(flags, "author-version-id", "thesis version delete"),
|
|
20006
|
-
requireFlag(
|
|
20007
|
-
flags,
|
|
20008
|
-
"expected-author-version-id",
|
|
20009
|
-
"thesis version delete"
|
|
20010
|
-
)
|
|
20011
|
-
);
|
|
20012
|
-
}
|
|
20013
20923
|
return client.theses.getVersion(
|
|
20014
20924
|
requireFlag(flags, "id", "thesis version get"),
|
|
20015
20925
|
requireFlag(flags, "author-version-id", "thesis version get")
|
|
@@ -20082,22 +20992,9 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
20082
20992
|
visibility: thesisVisibility(
|
|
20083
20993
|
requireFlag(flags, "visibility", "thesis update")
|
|
20084
20994
|
),
|
|
20085
|
-
|
|
20995
|
+
track_return: thesisTrackReturn(flags, "thesis update")
|
|
20086
20996
|
}
|
|
20087
20997
|
);
|
|
20088
|
-
case "close":
|
|
20089
|
-
return client.theses.close(requireFlag(flags, "id", "thesis close"), {
|
|
20090
|
-
expected_author_version_id: requireFlag(
|
|
20091
|
-
flags,
|
|
20092
|
-
"expected-author-version-id",
|
|
20093
|
-
"thesis close"
|
|
20094
|
-
),
|
|
20095
|
-
note: flags.note
|
|
20096
|
-
});
|
|
20097
|
-
case "delete":
|
|
20098
|
-
return client.theses.delete(
|
|
20099
|
-
requireFlag(flags, "id", "thesis delete")
|
|
20100
|
-
);
|
|
20101
20998
|
case "rewrite":
|
|
20102
20999
|
return client.theses.rewrite({
|
|
20103
21000
|
body: await thesisBodyFromFlags(flags, "thesis rewrite", deps),
|
|
@@ -21280,6 +22177,9 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
21280
22177
|
case "markets": {
|
|
21281
22178
|
if (!subcommand)
|
|
21282
22179
|
throw new CliUsageError("Missing subcommand for markets", "markets");
|
|
22180
|
+
if (subcommand === "watchlist") {
|
|
22181
|
+
return dispatchWatchlist(client, parsedCommand.path[2], flags);
|
|
22182
|
+
}
|
|
21283
22183
|
const ticker = requireFlag(flags, "ticker", `markets ${subcommand}`);
|
|
21284
22184
|
switch (subcommand) {
|
|
21285
22185
|
case "narrative":
|
|
@@ -21393,6 +22293,8 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
21393
22293
|
);
|
|
21394
22294
|
}
|
|
21395
22295
|
}
|
|
22296
|
+
case "people":
|
|
22297
|
+
return dispatchPeople(client, parsedCommand.path.slice(1), flags);
|
|
21396
22298
|
case "trading": {
|
|
21397
22299
|
if (!subcommand)
|
|
21398
22300
|
throw new CliUsageError("Missing subcommand for trading", "trading");
|