@alva-ai/toolkit 0.34.0-beta.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/browser.global.js +67 -47
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +190 -2
- package/dist/cli.js +932 -101
- package/dist/cli.js.map +1 -1
- package/dist/dispatch.d.ts +190 -2
- package/dist/dispatch.js +405 -45
- package/dist/dispatch.js.map +1 -1
- package/dist/index.cjs +706 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +191 -3
- package/dist/index.d.ts +191 -3
- package/dist/index.js +705 -73
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -27,6 +27,7 @@ __export(src_exports, {
|
|
|
27
27
|
AutomationResource: () => AutomationResource,
|
|
28
28
|
CliUsageError: () => CliUsageError,
|
|
29
29
|
CompanyNewsResource: () => CompanyNewsResource,
|
|
30
|
+
FollowsResource: () => FollowsResource,
|
|
30
31
|
ForYouResource: () => ForYouResource,
|
|
31
32
|
MarketsResource: () => MarketsResource,
|
|
32
33
|
PBSV_UPDATE_MESSAGE: () => PBSV_UPDATE_MESSAGE,
|
|
@@ -2888,6 +2889,458 @@ var SubscriptionsResource = class {
|
|
|
2888
2889
|
}
|
|
2889
2890
|
};
|
|
2890
2891
|
|
|
2892
|
+
// src/resources/follows.ts
|
|
2893
|
+
var MAX_TICKERS = 50;
|
|
2894
|
+
var MAX_TICKER_LENGTH = 40;
|
|
2895
|
+
var MAX_WATCHLIST_FIRST = 100;
|
|
2896
|
+
var MAX_PROFILE_FIRST = 50;
|
|
2897
|
+
var MAX_PROFILE_QUERY_LENGTH = 200;
|
|
2898
|
+
var LOOKUP_CONCURRENCY = 5;
|
|
2899
|
+
var TICKER_KINDS = ["STOCK", "ETF", "CRYPTO"];
|
|
2900
|
+
var PROFILE_KINDS = ["USER", "PERSON"];
|
|
2901
|
+
var UNRESOLVED_LOOKUP_CODES = /* @__PURE__ */ new Set(["NOT_FOUND", "FAILED_PRECONDITION"]);
|
|
2902
|
+
var GRAPHQL_STATUS_BY_CODE2 = {
|
|
2903
|
+
INVALID_ARGUMENT: 400,
|
|
2904
|
+
UNAUTHENTICATED: 401,
|
|
2905
|
+
PERMISSION_DENIED: 403,
|
|
2906
|
+
NOT_FOUND: 404,
|
|
2907
|
+
ALREADY_EXISTS: 409,
|
|
2908
|
+
ABORTED: 409,
|
|
2909
|
+
FAILED_PRECONDITION: 412,
|
|
2910
|
+
RESOURCE_EXHAUSTED: 429,
|
|
2911
|
+
INTERNAL: 500,
|
|
2912
|
+
UNKNOWN: 500,
|
|
2913
|
+
DATA_LOSS: 500,
|
|
2914
|
+
UNAVAILABLE: 503,
|
|
2915
|
+
DEADLINE_EXCEEDED: 504
|
|
2916
|
+
};
|
|
2917
|
+
var TICKER_FIELDS = "id ticker name kind";
|
|
2918
|
+
var PROFILE_FIELDS = "__typename id displayName followersCount viewerState { following } ... on PublicUser { username } ... on Person { slug xHandle }";
|
|
2919
|
+
function record3(value) {
|
|
2920
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2921
|
+
}
|
|
2922
|
+
function invalidResponse3(field) {
|
|
2923
|
+
throw new AlvaError(
|
|
2924
|
+
"GRAPHQL_INVALID_RESPONSE",
|
|
2925
|
+
`GraphQL returned an invalid ${field} response`,
|
|
2926
|
+
502
|
|
2927
|
+
);
|
|
2928
|
+
}
|
|
2929
|
+
function graphQLFailure(response) {
|
|
2930
|
+
if (!record3(response) || response.errors === void 0) return void 0;
|
|
2931
|
+
if (!Array.isArray(response.errors)) return invalidResponse3("GraphQL");
|
|
2932
|
+
if (response.errors.length === 0) return void 0;
|
|
2933
|
+
const errors = response.errors;
|
|
2934
|
+
const messages = errors.flatMap(
|
|
2935
|
+
(error) => record3(error) && typeof error.message === "string" ? [error.message] : []
|
|
2936
|
+
);
|
|
2937
|
+
const codes = errors.map(
|
|
2938
|
+
(error) => record3(error) && record3(error.extensions) ? error.extensions.code : void 0
|
|
2939
|
+
);
|
|
2940
|
+
const code = typeof codes[0] === "string" && Object.hasOwn(GRAPHQL_STATUS_BY_CODE2, codes[0]) && codes.every((value) => value === codes[0]) ? codes[0] : "GRAPHQL_ERROR";
|
|
2941
|
+
return { code, message: messages.join("; ") || "Request failed", errors };
|
|
2942
|
+
}
|
|
2943
|
+
function throwFailure(failure) {
|
|
2944
|
+
throw new AlvaError(
|
|
2945
|
+
failure.code,
|
|
2946
|
+
failure.message,
|
|
2947
|
+
GRAPHQL_STATUS_BY_CODE2[failure.code] ?? 502,
|
|
2948
|
+
{ errors: failure.errors }
|
|
2949
|
+
);
|
|
2950
|
+
}
|
|
2951
|
+
function responseData(response, field) {
|
|
2952
|
+
const failure = graphQLFailure(response);
|
|
2953
|
+
if (failure) throwFailure(failure);
|
|
2954
|
+
if (!record3(response) || !record3(response.data))
|
|
2955
|
+
return invalidResponse3(field);
|
|
2956
|
+
return response.data;
|
|
2957
|
+
}
|
|
2958
|
+
function viewerField2(response, field) {
|
|
2959
|
+
const data = responseData(response, field);
|
|
2960
|
+
if (!record3(data.viewer)) return invalidResponse3(field);
|
|
2961
|
+
return data.viewer[field];
|
|
2962
|
+
}
|
|
2963
|
+
function requireString(value, field) {
|
|
2964
|
+
if (typeof value !== "string" || !value) return invalidResponse3(field);
|
|
2965
|
+
return value;
|
|
2966
|
+
}
|
|
2967
|
+
function pageInfo(value, field) {
|
|
2968
|
+
if (!record3(value) || typeof value.hasNextPage !== "boolean" || value.endCursor !== null && value.endCursor !== void 0 && typeof value.endCursor !== "string" || value.hasNextPage && !value.endCursor) {
|
|
2969
|
+
return invalidResponse3(field);
|
|
2970
|
+
}
|
|
2971
|
+
return {
|
|
2972
|
+
endCursor: typeof value.endCursor === "string" ? value.endCursor : "",
|
|
2973
|
+
hasNextPage: value.hasNextPage
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2976
|
+
function normalizeProfile(value, field) {
|
|
2977
|
+
if (!record3(value) || !record3(value.viewerState))
|
|
2978
|
+
return invalidResponse3(field);
|
|
2979
|
+
const following = value.viewerState.following;
|
|
2980
|
+
if (typeof value.followersCount !== "number" || typeof value.displayName !== "string" || following !== null && typeof following !== "boolean") {
|
|
2981
|
+
return invalidResponse3(field);
|
|
2982
|
+
}
|
|
2983
|
+
const base = {
|
|
2984
|
+
id: requireString(value.id, field),
|
|
2985
|
+
displayName: value.displayName,
|
|
2986
|
+
followersCount: value.followersCount,
|
|
2987
|
+
following: following ?? null
|
|
2988
|
+
};
|
|
2989
|
+
if (value.__typename === "PublicUser") {
|
|
2990
|
+
return {
|
|
2991
|
+
kind: "USER",
|
|
2992
|
+
...base,
|
|
2993
|
+
username: requireString(value.username, field)
|
|
2994
|
+
};
|
|
2995
|
+
}
|
|
2996
|
+
if (value.__typename === "Person") {
|
|
2997
|
+
if (value.xHandle !== null && value.xHandle !== void 0 && typeof value.xHandle !== "string") {
|
|
2998
|
+
return invalidResponse3(field);
|
|
2999
|
+
}
|
|
3000
|
+
return {
|
|
3001
|
+
kind: "PERSON",
|
|
3002
|
+
...base,
|
|
3003
|
+
slug: requireString(value.slug, field),
|
|
3004
|
+
xHandle: value.xHandle ?? null
|
|
3005
|
+
};
|
|
3006
|
+
}
|
|
3007
|
+
return invalidResponse3(field);
|
|
3008
|
+
}
|
|
3009
|
+
function boundedFirst(value, max, name = "first") {
|
|
3010
|
+
if (value === void 0) return void 0;
|
|
3011
|
+
if (!Number.isInteger(value) || value < 1 || value > max) {
|
|
3012
|
+
throw new Error(`${name} must be an integer between 1 and ${max}`);
|
|
3013
|
+
}
|
|
3014
|
+
return value;
|
|
3015
|
+
}
|
|
3016
|
+
function optionalCursor(value) {
|
|
3017
|
+
if (value === void 0) return void 0;
|
|
3018
|
+
if (typeof value !== "string" || !value.trim() || value.length > 4096) {
|
|
3019
|
+
throw new Error(
|
|
3020
|
+
"after must be a non-empty cursor of at most 4096 characters"
|
|
3021
|
+
);
|
|
3022
|
+
}
|
|
3023
|
+
return value;
|
|
3024
|
+
}
|
|
3025
|
+
function profileKind(value, required) {
|
|
3026
|
+
if (value === void 0 && !required) return void 0;
|
|
3027
|
+
if (typeof value !== "string" || !PROFILE_KINDS.includes(value)) {
|
|
3028
|
+
throw new Error("kind must be USER or PERSON");
|
|
3029
|
+
}
|
|
3030
|
+
return value;
|
|
3031
|
+
}
|
|
3032
|
+
function tickerKind(value) {
|
|
3033
|
+
if (value === void 0) return void 0;
|
|
3034
|
+
if (typeof value !== "string" || !TICKER_KINDS.includes(value)) {
|
|
3035
|
+
throw new Error("kind must be STOCK, ETF, or CRYPTO");
|
|
3036
|
+
}
|
|
3037
|
+
return value;
|
|
3038
|
+
}
|
|
3039
|
+
function normalizeWatchlistTickersParams(params) {
|
|
3040
|
+
if (!record3(params) || !Array.isArray(params.tickers)) {
|
|
3041
|
+
throw new Error("tickers must be a list of ticker symbols");
|
|
3042
|
+
}
|
|
3043
|
+
const defaultKind = tickerKind(params.kind);
|
|
3044
|
+
const tickers = [];
|
|
3045
|
+
for (const raw of params.tickers) {
|
|
3046
|
+
const spec = typeof raw === "string" ? { ticker: raw } : raw;
|
|
3047
|
+
if (!record3(spec) || typeof spec.ticker !== "string") {
|
|
3048
|
+
throw new Error("tickers must be symbols or {ticker, kind} specs");
|
|
3049
|
+
}
|
|
3050
|
+
const ticker = spec.ticker.trim().toUpperCase();
|
|
3051
|
+
if (!ticker || /\s/.test(ticker) || ticker.length > MAX_TICKER_LENGTH) {
|
|
3052
|
+
throw new Error(
|
|
3053
|
+
`ticker '${spec.ticker}' must be a non-empty symbol of at most ${MAX_TICKER_LENGTH} characters`
|
|
3054
|
+
);
|
|
3055
|
+
}
|
|
3056
|
+
const kind = tickerKind(spec.kind) ?? defaultKind;
|
|
3057
|
+
if (!tickers.some((t) => t.ticker === ticker && t.kind === kind)) {
|
|
3058
|
+
tickers.push(kind === void 0 ? { ticker } : { ticker, kind });
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
if (tickers.length === 0 || tickers.length > MAX_TICKERS) {
|
|
3062
|
+
throw new Error(
|
|
3063
|
+
`tickers must contain between 1 and ${MAX_TICKERS} symbols`
|
|
3064
|
+
);
|
|
3065
|
+
}
|
|
3066
|
+
return { tickers };
|
|
3067
|
+
}
|
|
3068
|
+
function validateProfileRef(params) {
|
|
3069
|
+
if (!record3(params)) throw new Error("profile reference must be an object");
|
|
3070
|
+
const kind = profileKind(params.kind, true);
|
|
3071
|
+
if (typeof params.id !== "string" || !/^[1-9]\d{0,18}$/.test(params.id)) {
|
|
3072
|
+
throw new Error("id must be a positive decimal profile id");
|
|
3073
|
+
}
|
|
3074
|
+
return { kind, id: params.id };
|
|
3075
|
+
}
|
|
3076
|
+
function validateSearchProfilesParams(params) {
|
|
3077
|
+
if (!record3(params) || typeof params.query !== "string") {
|
|
3078
|
+
throw new Error("query is required");
|
|
3079
|
+
}
|
|
3080
|
+
const query = params.query.trim();
|
|
3081
|
+
if (!query || query.length > MAX_PROFILE_QUERY_LENGTH) {
|
|
3082
|
+
throw new Error(
|
|
3083
|
+
`query must be non-empty and at most ${MAX_PROFILE_QUERY_LENGTH} characters`
|
|
3084
|
+
);
|
|
3085
|
+
}
|
|
3086
|
+
return {
|
|
3087
|
+
query,
|
|
3088
|
+
kind: profileKind(params.kind, false),
|
|
3089
|
+
first: boundedFirst(params.first, MAX_PROFILE_FIRST)
|
|
3090
|
+
};
|
|
3091
|
+
}
|
|
3092
|
+
function unresolvedTicker(input, kind, code, message) {
|
|
3093
|
+
if (kind === void 0) {
|
|
3094
|
+
return { ok: false, unresolved: { input, code, message } };
|
|
3095
|
+
}
|
|
3096
|
+
return {
|
|
3097
|
+
ok: false,
|
|
3098
|
+
unresolved: {
|
|
3099
|
+
input,
|
|
3100
|
+
kind,
|
|
3101
|
+
code,
|
|
3102
|
+
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
|
|
3103
|
+
}
|
|
3104
|
+
};
|
|
3105
|
+
}
|
|
3106
|
+
var FollowsResource = class {
|
|
3107
|
+
constructor(client) {
|
|
3108
|
+
this.client = client;
|
|
3109
|
+
}
|
|
3110
|
+
client;
|
|
3111
|
+
/** Add tickers to the watchlist by exact symbol in one atomic batch. */
|
|
3112
|
+
async addToWatchlist(params) {
|
|
3113
|
+
const { changed, unchanged, unresolved } = await this.changeWatchlist(
|
|
3114
|
+
params,
|
|
3115
|
+
"add"
|
|
3116
|
+
);
|
|
3117
|
+
return { added: changed, unchanged, unresolved };
|
|
3118
|
+
}
|
|
3119
|
+
/** Remove tickers from the watchlist by exact symbol in one atomic batch. */
|
|
3120
|
+
async removeFromWatchlist(params) {
|
|
3121
|
+
const { changed, unchanged, unresolved } = await this.changeWatchlist(
|
|
3122
|
+
params,
|
|
3123
|
+
"remove"
|
|
3124
|
+
);
|
|
3125
|
+
return { removed: changed, unchanged, unresolved };
|
|
3126
|
+
}
|
|
3127
|
+
/** One page of the watchlist, most recently added first. */
|
|
3128
|
+
async watchlist(params = {}) {
|
|
3129
|
+
const first = boundedFirst(params.first, MAX_WATCHLIST_FIRST);
|
|
3130
|
+
const after = optionalCursor(params.after);
|
|
3131
|
+
this.client._requireAuth();
|
|
3132
|
+
const response = await this.client._request("POST", "/query", {
|
|
3133
|
+
body: {
|
|
3134
|
+
query: `query ToolkitWatchlist($input: MarketWatchlistConnectionInput) { viewer { marketWatchlist(input: $input) { totalCount edges { cursor followedAtMs node { ${TICKER_FIELDS} } } pageInfo { endCursor hasNextPage } } } }`,
|
|
3135
|
+
variables: { input: { first: first ?? 20, after } }
|
|
3136
|
+
}
|
|
3137
|
+
});
|
|
3138
|
+
const field = "viewer.marketWatchlist";
|
|
3139
|
+
const value = viewerField2(response, "marketWatchlist");
|
|
3140
|
+
if (!record3(value) || typeof value.totalCount !== "number" || !Array.isArray(value.edges)) {
|
|
3141
|
+
return invalidResponse3(field);
|
|
3142
|
+
}
|
|
3143
|
+
const tickers = value.edges.map((edge) => {
|
|
3144
|
+
if (!record3(edge) || !record3(edge.node) || typeof edge.followedAtMs !== "number") {
|
|
3145
|
+
return invalidResponse3(field);
|
|
3146
|
+
}
|
|
3147
|
+
return {
|
|
3148
|
+
entityId: requireString(edge.node.id, field),
|
|
3149
|
+
ticker: requireString(edge.node.ticker, field),
|
|
3150
|
+
name: typeof edge.node.name === "string" ? edge.node.name : "",
|
|
3151
|
+
kind: requireString(edge.node.kind, field),
|
|
3152
|
+
addedAtMs: edge.followedAtMs
|
|
3153
|
+
};
|
|
3154
|
+
});
|
|
3155
|
+
return {
|
|
3156
|
+
totalCount: value.totalCount,
|
|
3157
|
+
tickers,
|
|
3158
|
+
pageInfo: pageInfo(value.pageInfo, field)
|
|
3159
|
+
};
|
|
3160
|
+
}
|
|
3161
|
+
/** Search public profiles (Alva users and curated people). */
|
|
3162
|
+
async searchProfiles(params) {
|
|
3163
|
+
const { query, kind, first } = validateSearchProfilesParams(params);
|
|
3164
|
+
this.client._requireAuth();
|
|
3165
|
+
const response = await this.client._request("POST", "/query", {
|
|
3166
|
+
body: {
|
|
3167
|
+
query: `query ToolkitSearchProfiles($input: PublicProfileConnectionInput) { profiles(input: $input) { edges { node { ${PROFILE_FIELDS} } } pageInfo { endCursor hasNextPage } } }`,
|
|
3168
|
+
variables: { input: { query, kind, first: first ?? 10 } }
|
|
3169
|
+
}
|
|
3170
|
+
});
|
|
3171
|
+
return this.profilesPage(
|
|
3172
|
+
responseData(response, "profiles").profiles,
|
|
3173
|
+
"profiles"
|
|
3174
|
+
);
|
|
3175
|
+
}
|
|
3176
|
+
/** One page of profiles the caller follows. */
|
|
3177
|
+
async profiles(params = {}) {
|
|
3178
|
+
const kind = profileKind(params.kind, false);
|
|
3179
|
+
const first = boundedFirst(params.first, MAX_PROFILE_FIRST);
|
|
3180
|
+
const after = optionalCursor(params.after);
|
|
3181
|
+
this.client._requireAuth();
|
|
3182
|
+
const response = await this.client._request("POST", "/query", {
|
|
3183
|
+
body: {
|
|
3184
|
+
query: `query ToolkitFollowedProfiles($input: FollowingProfileConnectionInput) { viewer { followingProfiles(input: $input) { edges { node { ${PROFILE_FIELDS} } } pageInfo { endCursor hasNextPage } } } }`,
|
|
3185
|
+
variables: { input: { kind, first: first ?? 20, after } }
|
|
3186
|
+
}
|
|
3187
|
+
});
|
|
3188
|
+
return this.profilesPage(
|
|
3189
|
+
viewerField2(response, "followingProfiles"),
|
|
3190
|
+
"viewer.followingProfiles"
|
|
3191
|
+
);
|
|
3192
|
+
}
|
|
3193
|
+
/** Follow one profile. Idempotent. */
|
|
3194
|
+
async followProfile(params) {
|
|
3195
|
+
return this.changeProfile(params, "followProfile");
|
|
3196
|
+
}
|
|
3197
|
+
/** Unfollow one profile. Idempotent. */
|
|
3198
|
+
async unfollowProfile(params) {
|
|
3199
|
+
return this.changeProfile(params, "unfollowProfile");
|
|
3200
|
+
}
|
|
3201
|
+
profilesPage(value, field) {
|
|
3202
|
+
if (!record3(value) || !Array.isArray(value.edges)) {
|
|
3203
|
+
return invalidResponse3(field);
|
|
3204
|
+
}
|
|
3205
|
+
return {
|
|
3206
|
+
profiles: value.edges.map(
|
|
3207
|
+
(edge) => record3(edge) ? normalizeProfile(edge.node, field) : invalidResponse3(field)
|
|
3208
|
+
),
|
|
3209
|
+
pageInfo: pageInfo(value.pageInfo, field)
|
|
3210
|
+
};
|
|
3211
|
+
}
|
|
3212
|
+
async changeProfile(params, mutation) {
|
|
3213
|
+
const input = validateProfileRef(params);
|
|
3214
|
+
this.client._requireAuth();
|
|
3215
|
+
const response = await this.client._request("POST", "/query", {
|
|
3216
|
+
body: {
|
|
3217
|
+
query: `mutation ToolkitChangeProfileFollow($input: PublicProfileRefInput!) { ${mutation}(input: $input) { following target { ${PROFILE_FIELDS} } } }`,
|
|
3218
|
+
variables: { input }
|
|
3219
|
+
}
|
|
3220
|
+
});
|
|
3221
|
+
const value = responseData(response, mutation)[mutation];
|
|
3222
|
+
if (!record3(value) || typeof value.following !== "boolean") {
|
|
3223
|
+
return invalidResponse3(mutation);
|
|
3224
|
+
}
|
|
3225
|
+
return {
|
|
3226
|
+
following: value.following,
|
|
3227
|
+
profile: value.target === null || value.target === void 0 ? null : normalizeProfile(value.target, mutation)
|
|
3228
|
+
};
|
|
3229
|
+
}
|
|
3230
|
+
async changeWatchlist(params, direction) {
|
|
3231
|
+
const { tickers } = normalizeWatchlistTickersParams(params);
|
|
3232
|
+
this.client._requireAuth();
|
|
3233
|
+
const lookups = await this.lookupTickers(tickers);
|
|
3234
|
+
const changed = [];
|
|
3235
|
+
const unchanged = [];
|
|
3236
|
+
const unresolved = [];
|
|
3237
|
+
const groupByEntity = /* @__PURE__ */ new Map();
|
|
3238
|
+
const writeIds = [];
|
|
3239
|
+
for (const lookup of lookups) {
|
|
3240
|
+
if (!lookup.ok) {
|
|
3241
|
+
unresolved.push(lookup.unresolved);
|
|
3242
|
+
continue;
|
|
3243
|
+
}
|
|
3244
|
+
const seenGroup = groupByEntity.get(lookup.ticker.entityId);
|
|
3245
|
+
if (seenGroup) {
|
|
3246
|
+
seenGroup.push(lookup.ticker);
|
|
3247
|
+
continue;
|
|
3248
|
+
}
|
|
3249
|
+
const needsChange = direction === "add" ? !lookup.inWatchlist : lookup.inWatchlist;
|
|
3250
|
+
const group = needsChange ? changed : unchanged;
|
|
3251
|
+
group.push(lookup.ticker);
|
|
3252
|
+
groupByEntity.set(lookup.ticker.entityId, group);
|
|
3253
|
+
if (needsChange || direction === "remove") {
|
|
3254
|
+
writeIds.push(lookup.ticker.entityId);
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
if (writeIds.length > 0) {
|
|
3258
|
+
const mutation = direction === "add" ? "followTickers" : "unfollowTickers";
|
|
3259
|
+
const input = direction === "add" ? "FollowTickersInput" : "UnfollowTickersInput";
|
|
3260
|
+
const response = await this.client._request("POST", "/query", {
|
|
3261
|
+
body: {
|
|
3262
|
+
query: `mutation ToolkitChangeWatchlist($input: ${input}!) { ${mutation}(input: $input) { entities { id } } }`,
|
|
3263
|
+
variables: { input: { entityIds: writeIds } }
|
|
3264
|
+
}
|
|
3265
|
+
});
|
|
3266
|
+
const value = responseData(response, mutation)[mutation];
|
|
3267
|
+
if (!record3(value) || !Array.isArray(value.entities)) {
|
|
3268
|
+
return invalidResponse3(mutation);
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
return { changed, unchanged, unresolved };
|
|
3272
|
+
}
|
|
3273
|
+
async lookupTickers(tickers) {
|
|
3274
|
+
const results = new Array(tickers.length);
|
|
3275
|
+
let next = 0;
|
|
3276
|
+
const worker = async () => {
|
|
3277
|
+
while (next < tickers.length) {
|
|
3278
|
+
const index = next++;
|
|
3279
|
+
const { ticker, kind } = tickers[index];
|
|
3280
|
+
results[index] = await this.lookupTicker(ticker, kind);
|
|
3281
|
+
}
|
|
3282
|
+
};
|
|
3283
|
+
await Promise.all(
|
|
3284
|
+
Array.from(
|
|
3285
|
+
{ length: Math.min(LOOKUP_CONCURRENCY, tickers.length) },
|
|
3286
|
+
worker
|
|
3287
|
+
)
|
|
3288
|
+
);
|
|
3289
|
+
return results;
|
|
3290
|
+
}
|
|
3291
|
+
async lookupTicker(input, kind) {
|
|
3292
|
+
const response = await this.client._request("POST", "/query", {
|
|
3293
|
+
body: {
|
|
3294
|
+
query: `query ToolkitTickerLookup($input: MarketEntityLookupInput!) { market { entity(input: $input) { ${TICKER_FIELDS} viewerState { isFollowed } } } }`,
|
|
3295
|
+
variables: { input: { ticker: input, kind } }
|
|
3296
|
+
}
|
|
3297
|
+
});
|
|
3298
|
+
const failure = graphQLFailure(response);
|
|
3299
|
+
if (failure) {
|
|
3300
|
+
if (UNRESOLVED_LOOKUP_CODES.has(failure.code)) {
|
|
3301
|
+
return unresolvedTicker(input, kind, failure.code, failure.message);
|
|
3302
|
+
}
|
|
3303
|
+
throwFailure(failure);
|
|
3304
|
+
}
|
|
3305
|
+
const field = "market.entity";
|
|
3306
|
+
if (!record3(response) || !record3(response.data) || !record3(response.data.market)) {
|
|
3307
|
+
return invalidResponse3(field);
|
|
3308
|
+
}
|
|
3309
|
+
const entity = response.data.market.entity;
|
|
3310
|
+
if (entity === null || entity === void 0) {
|
|
3311
|
+
return unresolvedTicker(
|
|
3312
|
+
input,
|
|
3313
|
+
kind,
|
|
3314
|
+
"NOT_FOUND",
|
|
3315
|
+
`no entity found for ticker: ${input}`
|
|
3316
|
+
);
|
|
3317
|
+
}
|
|
3318
|
+
if (!record3(entity)) return invalidResponse3(field);
|
|
3319
|
+
const viewerState = entity.viewerState;
|
|
3320
|
+
if (viewerState === null || viewerState === void 0) {
|
|
3321
|
+
throw new AlvaError(
|
|
3322
|
+
"PERMISSION_DENIED",
|
|
3323
|
+
"This credential cannot read the user's watchlist",
|
|
3324
|
+
403
|
|
3325
|
+
);
|
|
3326
|
+
}
|
|
3327
|
+
if (!record3(viewerState) || typeof viewerState.isFollowed !== "boolean") {
|
|
3328
|
+
return invalidResponse3(field);
|
|
3329
|
+
}
|
|
3330
|
+
return {
|
|
3331
|
+
ok: true,
|
|
3332
|
+
inWatchlist: viewerState.isFollowed,
|
|
3333
|
+
ticker: {
|
|
3334
|
+
input,
|
|
3335
|
+
entityId: requireString(entity.id, field),
|
|
3336
|
+
ticker: requireString(entity.ticker, field),
|
|
3337
|
+
name: typeof entity.name === "string" ? entity.name : "",
|
|
3338
|
+
kind: requireString(entity.kind, field)
|
|
3339
|
+
}
|
|
3340
|
+
};
|
|
3341
|
+
}
|
|
3342
|
+
};
|
|
3343
|
+
|
|
2891
3344
|
// src/resources/alerts.ts
|
|
2892
3345
|
var AlertsResource = class {
|
|
2893
3346
|
constructor(client) {
|
|
@@ -3559,7 +4012,8 @@ var MarketsResource = class {
|
|
|
3559
4012
|
}
|
|
3560
4013
|
selectPeriod(catalog, event, ticker) {
|
|
3561
4014
|
if (event === "latest-completed") {
|
|
3562
|
-
|
|
4015
|
+
const completed = catalog.periods.filter((period) => period.status === "COMPLETED").sort((a, b) => b.earningsDate.localeCompare(a.earningsDate));
|
|
4016
|
+
if (completed.length > 0) return completed[0];
|
|
3563
4017
|
} else {
|
|
3564
4018
|
const upcoming = catalog.periods.filter((period) => period.status === "UPCOMING").sort((a, b) => a.earningsDate.localeCompare(b.earningsDate));
|
|
3565
4019
|
if (upcoming.length > 0) return upcoming[0];
|
|
@@ -3655,7 +4109,7 @@ var SCHEDULE_NAME = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
|
3655
4109
|
var RFC3339 = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(Z|[+-](\d{2}):(\d{2}))$/i;
|
|
3656
4110
|
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;
|
|
3657
4111
|
var ISO_DURATION = /^P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;
|
|
3658
|
-
var
|
|
4112
|
+
var GRAPHQL_STATUS_BY_CODE3 = {
|
|
3659
4113
|
INVALID_ARGUMENT: 400,
|
|
3660
4114
|
UNAUTHENTICATED: 401,
|
|
3661
4115
|
PERMISSION_DENIED: 403,
|
|
@@ -3757,7 +4211,7 @@ var SchedulesResource = class {
|
|
|
3757
4211
|
const codes = response.errors.map((error) => error.extensions?.code);
|
|
3758
4212
|
const distinctCodes = new Set(codes);
|
|
3759
4213
|
const canonicalCode = distinctCodes.size === 1 && typeof codes[0] === "string" ? codes[0] : void 0;
|
|
3760
|
-
const canonicalStatus = canonicalCode ?
|
|
4214
|
+
const canonicalStatus = canonicalCode ? GRAPHQL_STATUS_BY_CODE3[canonicalCode] : void 0;
|
|
3761
4215
|
const errorCode = canonicalCode !== void 0 && canonicalStatus !== void 0 ? canonicalCode : "GRAPHQL_ERROR";
|
|
3762
4216
|
throw new AlvaError(
|
|
3763
4217
|
errorCode,
|
|
@@ -4006,7 +4460,7 @@ function scheduleEmptyResponse() {
|
|
|
4006
4460
|
}
|
|
4007
4461
|
|
|
4008
4462
|
// src/resources/steward.ts
|
|
4009
|
-
var
|
|
4463
|
+
var GRAPHQL_STATUS_BY_CODE4 = {
|
|
4010
4464
|
INVALID_ARGUMENT: 400,
|
|
4011
4465
|
UNAUTHENTICATED: 401,
|
|
4012
4466
|
PERMISSION_DENIED: 403,
|
|
@@ -4051,12 +4505,47 @@ var BRIEFED = `
|
|
|
4051
4505
|
mutation ToolkitStewardBriefed($input: CompleteStewardBriefInput!) {
|
|
4052
4506
|
completeStewardBrief(input: $input) { ok }
|
|
4053
4507
|
}`.trim();
|
|
4508
|
+
var DIGEST_RUN_FIELDS = `
|
|
4509
|
+
digestRunId state scheduleId scheduleVersion occurrenceIndex
|
|
4510
|
+
windowSinceMs windowUntilMs scanCompletedAtMs bodySha256 coverageSha256
|
|
4511
|
+
channelMessageId attempts lastError startedAtMs completedAtMs sendUncertainAtMs
|
|
4512
|
+
`.trim();
|
|
4513
|
+
var DIGEST_RUN = `
|
|
4514
|
+
query ToolkitStewardDigestRun($inboxPath: String!, $digestRunId: String!) {
|
|
4515
|
+
viewer { stewardDigestRun(inboxPath: $inboxPath, digestRunId: $digestRunId) { ${DIGEST_RUN_FIELDS} } }
|
|
4516
|
+
}`.trim();
|
|
4517
|
+
var DIGEST_RUN_PENDING = `
|
|
4518
|
+
query ToolkitStewardDigestRunPending($inboxPath: String!, $digestRunId: String!, $input: StewardDigestRunPendingInput) {
|
|
4519
|
+
viewer {
|
|
4520
|
+
stewardDigestRunPending(inboxPath: $inboxPath, digestRunId: $digestRunId, input: $input) {
|
|
4521
|
+
edges {
|
|
4522
|
+
node { deliveryId feedEntryId source { kind id } decisionReason consumedAtMs alertSnapshot }
|
|
4523
|
+
}
|
|
4524
|
+
pageInfo { hasNextPage endCursor }
|
|
4525
|
+
}
|
|
4526
|
+
}
|
|
4527
|
+
}`.trim();
|
|
4528
|
+
var PUBLISH_DAILY_BRIEF = `
|
|
4529
|
+
mutation ToolkitStewardPublishDailyBrief($input: PublishStewardDailyBriefInput!) {
|
|
4530
|
+
publishStewardDailyBrief(input: $input) { run { ${DIGEST_RUN_FIELDS} } }
|
|
4531
|
+
}`.trim();
|
|
4054
4532
|
var DECISIONS = /* @__PURE__ */ new Set([
|
|
4055
4533
|
"immediate",
|
|
4056
4534
|
"digest",
|
|
4057
4535
|
"suppress"
|
|
4058
4536
|
]);
|
|
4059
4537
|
var DELIVERY_ID = /^[1-9][0-9]{0,18}$/;
|
|
4538
|
+
var MAX_LEGACY_BRIEFED_IDS = 100;
|
|
4539
|
+
var MAX_DIGEST_RUN_COVERAGE = 1e4;
|
|
4540
|
+
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;
|
|
4541
|
+
var PENDING_ATTEMPTS = 3;
|
|
4542
|
+
var TRANSIENT_PENDING_CODES = /* @__PURE__ */ new Set([
|
|
4543
|
+
"NETWORK_ERROR",
|
|
4544
|
+
"NETWORK_TIMEOUT",
|
|
4545
|
+
"UNAVAILABLE",
|
|
4546
|
+
"DEADLINE_EXCEEDED"
|
|
4547
|
+
]);
|
|
4548
|
+
var TRANSIENT_HTTP_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
|
|
4060
4549
|
function invalid2(message) {
|
|
4061
4550
|
return new AlvaError("INVALID_ARGUMENT", message, 400);
|
|
4062
4551
|
}
|
|
@@ -4115,6 +4604,13 @@ function requireRequestId(value) {
|
|
|
4115
4604
|
throw invalid2("request id must be a UUID");
|
|
4116
4605
|
return value;
|
|
4117
4606
|
}
|
|
4607
|
+
function requireDigestRunId(value) {
|
|
4608
|
+
if (!DIGEST_RUN_ID.test(value)) throw invalid2("digest run id must be a UUID");
|
|
4609
|
+
return value.toLowerCase();
|
|
4610
|
+
}
|
|
4611
|
+
function isTransientStewardError(error) {
|
|
4612
|
+
return error instanceof AlvaError && (TRANSIENT_PENDING_CODES.has(error.code) || TRANSIENT_HTTP_STATUSES.has(error.status));
|
|
4613
|
+
}
|
|
4118
4614
|
function emptyResponse() {
|
|
4119
4615
|
return new AlvaError("EMPTY_RESPONSE", "steward response was empty", 502);
|
|
4120
4616
|
}
|
|
@@ -4177,6 +4673,56 @@ var StewardResource = class {
|
|
|
4177
4673
|
return message;
|
|
4178
4674
|
}
|
|
4179
4675
|
async pending(params) {
|
|
4676
|
+
if (params.after !== void 0) return this.pendingPage(params);
|
|
4677
|
+
const items = [];
|
|
4678
|
+
const deliveryIds = /* @__PURE__ */ new Set();
|
|
4679
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
4680
|
+
let after;
|
|
4681
|
+
let windowSinceMs;
|
|
4682
|
+
let windowUntilMs;
|
|
4683
|
+
do {
|
|
4684
|
+
const page = await this.pendingPageWithRetry({
|
|
4685
|
+
...params,
|
|
4686
|
+
after,
|
|
4687
|
+
sinceMs: after === void 0 ? params.sinceMs : void 0,
|
|
4688
|
+
untilMs: after === void 0 ? params.untilMs : void 0
|
|
4689
|
+
});
|
|
4690
|
+
if (windowSinceMs === void 0) {
|
|
4691
|
+
windowSinceMs = page.windowSinceMs;
|
|
4692
|
+
windowUntilMs = page.windowUntilMs;
|
|
4693
|
+
} else if (page.windowSinceMs !== windowSinceMs || page.windowUntilMs !== windowUntilMs) {
|
|
4694
|
+
throw new AlvaError(
|
|
4695
|
+
"ABORTED",
|
|
4696
|
+
"steward pending window changed during pagination",
|
|
4697
|
+
409
|
|
4698
|
+
);
|
|
4699
|
+
}
|
|
4700
|
+
for (const item of page.items) {
|
|
4701
|
+
if (deliveryIds.has(item.deliveryId)) continue;
|
|
4702
|
+
deliveryIds.add(item.deliveryId);
|
|
4703
|
+
items.push(item);
|
|
4704
|
+
}
|
|
4705
|
+
after = page.nextCursor ?? void 0;
|
|
4706
|
+
if (after !== void 0) {
|
|
4707
|
+
if (cursors.has(after)) {
|
|
4708
|
+
throw new AlvaError(
|
|
4709
|
+
"INTERNAL",
|
|
4710
|
+
"steward pending pagination loop detected",
|
|
4711
|
+
500
|
|
4712
|
+
);
|
|
4713
|
+
}
|
|
4714
|
+
cursors.add(after);
|
|
4715
|
+
}
|
|
4716
|
+
} while (after !== void 0);
|
|
4717
|
+
if (windowSinceMs === void 0 || windowUntilMs === void 0)
|
|
4718
|
+
throw emptyResponse();
|
|
4719
|
+
return {
|
|
4720
|
+
items,
|
|
4721
|
+
windowSinceMs,
|
|
4722
|
+
windowUntilMs
|
|
4723
|
+
};
|
|
4724
|
+
}
|
|
4725
|
+
async pendingPage(params) {
|
|
4180
4726
|
this.client._requireAuth();
|
|
4181
4727
|
const first = params.first ?? 50;
|
|
4182
4728
|
if (!Number.isInteger(first) || first < 1 || first > 100)
|
|
@@ -4205,7 +4751,14 @@ var StewardResource = class {
|
|
|
4205
4751
|
if (!Number.isSafeInteger(windowSinceMs) || !Number.isSafeInteger(windowUntilMs) || windowSinceMs <= 0 || windowUntilMs <= windowSinceMs)
|
|
4206
4752
|
throw emptyResponse();
|
|
4207
4753
|
const items = page.edges.map((edge) => edge.node);
|
|
4208
|
-
const
|
|
4754
|
+
const pageInfo2 = page.pageInfo;
|
|
4755
|
+
if (!pageInfo2 || typeof pageInfo2.hasNextPage !== "boolean")
|
|
4756
|
+
throw emptyResponse();
|
|
4757
|
+
const endCursor = pageInfo2.endCursor;
|
|
4758
|
+
if (endCursor !== void 0 && endCursor !== null && typeof endCursor !== "string")
|
|
4759
|
+
throw emptyResponse();
|
|
4760
|
+
if (pageInfo2.hasNextPage && !endCursor) throw emptyResponse();
|
|
4761
|
+
const nextCursor2 = pageInfo2.hasNextPage ? endCursor : null;
|
|
4209
4762
|
return {
|
|
4210
4763
|
items,
|
|
4211
4764
|
nextCursor: nextCursor2,
|
|
@@ -4213,20 +4766,95 @@ var StewardResource = class {
|
|
|
4213
4766
|
windowUntilMs
|
|
4214
4767
|
};
|
|
4215
4768
|
}
|
|
4769
|
+
async pendingPageWithRetry(params) {
|
|
4770
|
+
for (let attempt = 1; attempt < PENDING_ATTEMPTS; attempt += 1) {
|
|
4771
|
+
try {
|
|
4772
|
+
return await this.pendingPage(params);
|
|
4773
|
+
} catch (error) {
|
|
4774
|
+
if (!isTransientStewardError(error)) throw error;
|
|
4775
|
+
}
|
|
4776
|
+
}
|
|
4777
|
+
return this.pendingPage(params);
|
|
4778
|
+
}
|
|
4216
4779
|
async briefed(params) {
|
|
4217
4780
|
this.client._requireAuth();
|
|
4218
4781
|
const digestRunId = params.digestRunId?.trim();
|
|
4219
4782
|
if (!digestRunId) throw invalid2("a digest run id is required");
|
|
4783
|
+
const inboxPath = requireInboxPath(params);
|
|
4784
|
+
const deliveryIds = requireDeliveryIds(params.deliveryIds);
|
|
4785
|
+
if (deliveryIds.length > MAX_LEGACY_BRIEFED_IDS)
|
|
4786
|
+
throw invalid2("legacy briefed accepts at most 100 delivery ids");
|
|
4220
4787
|
const data = await this.graphql(BRIEFED, {
|
|
4221
4788
|
input: {
|
|
4222
|
-
inboxPath
|
|
4223
|
-
deliveryIds
|
|
4789
|
+
inboxPath,
|
|
4790
|
+
deliveryIds,
|
|
4224
4791
|
digestRunId
|
|
4225
4792
|
}
|
|
4226
4793
|
});
|
|
4227
4794
|
if (data.completeStewardBrief?.ok !== true) throw emptyResponse();
|
|
4228
4795
|
return { ok: true };
|
|
4229
4796
|
}
|
|
4797
|
+
async digestRun(params) {
|
|
4798
|
+
this.client._requireAuth();
|
|
4799
|
+
const data = await this.graphql(DIGEST_RUN, {
|
|
4800
|
+
inboxPath: requireInboxPath(params),
|
|
4801
|
+
digestRunId: requireDigestRunId(params.digestRunId)
|
|
4802
|
+
});
|
|
4803
|
+
const run = data.viewer?.stewardDigestRun;
|
|
4804
|
+
if (!run) throw emptyResponse();
|
|
4805
|
+
return run;
|
|
4806
|
+
}
|
|
4807
|
+
async digestRunPending(params) {
|
|
4808
|
+
this.client._requireAuth();
|
|
4809
|
+
const inboxPath = requireInboxPath(params);
|
|
4810
|
+
const digestRunId = requireDigestRunId(params.digestRunId);
|
|
4811
|
+
const items = [];
|
|
4812
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
4813
|
+
let after;
|
|
4814
|
+
for (; ; ) {
|
|
4815
|
+
const data = await this.graphql(DIGEST_RUN_PENDING, {
|
|
4816
|
+
inboxPath,
|
|
4817
|
+
digestRunId,
|
|
4818
|
+
input: { first: 100, ...after === void 0 ? {} : { after } }
|
|
4819
|
+
});
|
|
4820
|
+
const connection2 = data.viewer?.stewardDigestRunPending;
|
|
4821
|
+
if (!connection2 || !Array.isArray(connection2.edges))
|
|
4822
|
+
throw emptyResponse();
|
|
4823
|
+
const pageInfo2 = connection2.pageInfo;
|
|
4824
|
+
if (!pageInfo2 || typeof pageInfo2.hasNextPage !== "boolean")
|
|
4825
|
+
throw emptyResponse();
|
|
4826
|
+
for (const edge of connection2.edges) {
|
|
4827
|
+
if (!edge?.node) throw emptyResponse();
|
|
4828
|
+
items.push(edge.node);
|
|
4829
|
+
}
|
|
4830
|
+
if (!pageInfo2.hasNextPage) break;
|
|
4831
|
+
const next = pageInfo2.endCursor;
|
|
4832
|
+
if (typeof next !== "string" || next === "" || seenCursors.has(next))
|
|
4833
|
+
throw emptyResponse();
|
|
4834
|
+
seenCursors.add(next);
|
|
4835
|
+
after = next;
|
|
4836
|
+
}
|
|
4837
|
+
return items;
|
|
4838
|
+
}
|
|
4839
|
+
async sendDigestRun(params) {
|
|
4840
|
+
this.client._requireAuth();
|
|
4841
|
+
const deliveryIds = normalizeDeliveryIds(params.deliveryIds ?? []);
|
|
4842
|
+
if (deliveryIds.length > MAX_DIGEST_RUN_COVERAGE)
|
|
4843
|
+
throw invalid2("durable Daily Brief accepts at most 10000 delivery ids");
|
|
4844
|
+
if (params.body !== void 0 && params.body.trim() === "")
|
|
4845
|
+
throw invalid2("a message body must be non-blank when provided");
|
|
4846
|
+
const data = await this.graphql(PUBLISH_DAILY_BRIEF, {
|
|
4847
|
+
input: {
|
|
4848
|
+
inboxPath: requireInboxPath(params),
|
|
4849
|
+
digestRunId: requireDigestRunId(params.digestRunId),
|
|
4850
|
+
deliveryIds,
|
|
4851
|
+
...params.body === void 0 ? {} : { body: params.body }
|
|
4852
|
+
}
|
|
4853
|
+
});
|
|
4854
|
+
const run = data.publishStewardDailyBrief?.run;
|
|
4855
|
+
if (!run) throw emptyResponse();
|
|
4856
|
+
return run;
|
|
4857
|
+
}
|
|
4230
4858
|
async graphql(query, variables) {
|
|
4231
4859
|
const response = await this.client._request("POST", "/query", {
|
|
4232
4860
|
body: { query, variables }
|
|
@@ -4235,7 +4863,7 @@ var StewardResource = class {
|
|
|
4235
4863
|
if (response.errors?.length) {
|
|
4236
4864
|
const codes = response.errors.map((error) => error.extensions?.code);
|
|
4237
4865
|
const canonicalCode = new Set(codes).size === 1 && typeof codes[0] === "string" ? codes[0] : void 0;
|
|
4238
|
-
const canonicalStatus = canonicalCode ?
|
|
4866
|
+
const canonicalStatus = canonicalCode ? GRAPHQL_STATUS_BY_CODE4[canonicalCode] : void 0;
|
|
4239
4867
|
throw new AlvaError(
|
|
4240
4868
|
canonicalCode !== void 0 && canonicalStatus !== void 0 ? canonicalCode : "GRAPHQL_ERROR",
|
|
4241
4869
|
response.errors.map((error) => error.message).filter((message) => typeof message === "string").join("; ") || "GraphQL request failed",
|
|
@@ -4351,12 +4979,12 @@ function dedupe(candidates) {
|
|
|
4351
4979
|
});
|
|
4352
4980
|
}
|
|
4353
4981
|
function resolveFilters(params) {
|
|
4354
|
-
const
|
|
4982
|
+
const record4 = isRecord(params) ? params : {};
|
|
4355
4983
|
return {
|
|
4356
|
-
market: typeof
|
|
4357
|
-
instrumentType: typeof
|
|
4358
|
-
underlyingType: typeof
|
|
4359
|
-
quote: typeof
|
|
4984
|
+
market: typeof record4.market === "string" ? record4.market : void 0,
|
|
4985
|
+
instrumentType: typeof record4.instrumentType === "string" ? record4.instrumentType : void 0,
|
|
4986
|
+
underlyingType: typeof record4.underlyingType === "string" ? record4.underlyingType : void 0,
|
|
4987
|
+
quote: typeof record4.quote === "string" ? record4.quote : void 0
|
|
4360
4988
|
};
|
|
4361
4989
|
}
|
|
4362
4990
|
function pairSearchParams(pair, params) {
|
|
@@ -4404,11 +5032,11 @@ var TradingPairsResource = class {
|
|
|
4404
5032
|
return { query, candidates };
|
|
4405
5033
|
}
|
|
4406
5034
|
async resolve(params) {
|
|
4407
|
-
const
|
|
4408
|
-
const pair = typeof
|
|
5035
|
+
const record4 = isRecord(params) ? params : {};
|
|
5036
|
+
const pair = typeof record4.pair === "string" ? record4.pair.trim() : void 0;
|
|
4409
5037
|
const filters = resolveFilters(params);
|
|
4410
5038
|
const searchParams = pair === void 0 ? {
|
|
4411
|
-
symbol: typeof
|
|
5039
|
+
symbol: typeof record4.symbol === "string" ? record4.symbol : "",
|
|
4412
5040
|
...filters
|
|
4413
5041
|
} : pairSearchParams(pair, filters);
|
|
4414
5042
|
const result = await this.search(searchParams);
|
|
@@ -4728,19 +5356,19 @@ var ThesesResource = class {
|
|
|
4728
5356
|
const viewer = isRecord2(data) ? data.viewer : void 0;
|
|
4729
5357
|
const result = isRecord2(viewer) ? viewer.thesisAssetCandidates : void 0;
|
|
4730
5358
|
if (!isRecord2(result) || !Array.isArray(result.mentions)) {
|
|
4731
|
-
throw
|
|
5359
|
+
throw invalidResponse4("asset candidates response must contain mentions");
|
|
4732
5360
|
}
|
|
4733
5361
|
const mentions = result.mentions.map((item, index) => {
|
|
4734
5362
|
if (!isRecord2(item) || typeof item.quote !== "string" || typeof item.ticker !== "string" || !["RESOLVED", "AMBIGUOUS", "UNRESOLVED"].includes(
|
|
4735
5363
|
item.resolution
|
|
4736
5364
|
) || !["UNKNOWN", "BULLISH", "BEARISH"].includes(item.stance) || !Array.isArray(item.candidates)) {
|
|
4737
|
-
throw
|
|
5365
|
+
throw invalidResponse4(`asset mention ${index} is invalid`);
|
|
4738
5366
|
}
|
|
4739
5367
|
const candidates = item.candidates.map((candidate) => {
|
|
4740
5368
|
if (!isRecord2(candidate) || typeof candidate.ticker !== "string" || typeof candidate.name !== "string" || !["STOCK", "ETF", "CRYPTO", "INDEX"].includes(
|
|
4741
5369
|
candidate.kind
|
|
4742
5370
|
)) {
|
|
4743
|
-
throw
|
|
5371
|
+
throw invalidResponse4(`asset mention ${index} has invalid candidate`);
|
|
4744
5372
|
}
|
|
4745
5373
|
return {
|
|
4746
5374
|
entityId: responseID(
|
|
@@ -4770,7 +5398,7 @@ var ThesesResource = class {
|
|
|
4770
5398
|
await this.client._request("GET", `/api/v1/theses/${thesisID}`)
|
|
4771
5399
|
);
|
|
4772
5400
|
if (response.thesis.id !== thesisID) {
|
|
4773
|
-
throw
|
|
5401
|
+
throw invalidResponse4("get response must match the requested thesis");
|
|
4774
5402
|
}
|
|
4775
5403
|
return response;
|
|
4776
5404
|
}
|
|
@@ -4785,7 +5413,7 @@ var ThesesResource = class {
|
|
|
4785
5413
|
)
|
|
4786
5414
|
);
|
|
4787
5415
|
if (response.thesis.id !== thesisID || response.thesis.author_version_id !== versionID) {
|
|
4788
|
-
throw
|
|
5416
|
+
throw invalidResponse4(
|
|
4789
5417
|
"version response must match the requested thesis and author version"
|
|
4790
5418
|
);
|
|
4791
5419
|
}
|
|
@@ -4808,12 +5436,12 @@ var ThesesResource = class {
|
|
|
4808
5436
|
}
|
|
4809
5437
|
);
|
|
4810
5438
|
if (!isRecord2(response) || !Array.isArray(response.versions) || typeof response.next_cursor !== "string")
|
|
4811
|
-
throw
|
|
5439
|
+
throw invalidResponse4("invalid Update list");
|
|
4812
5440
|
const versions = response.versions.map(
|
|
4813
5441
|
(value) => thesisResponse({ thesis: value }).thesis
|
|
4814
5442
|
);
|
|
4815
5443
|
if (versions.some((version) => version.id !== thesisID))
|
|
4816
|
-
throw
|
|
5444
|
+
throw invalidResponse4("Update list must match requested Thesis");
|
|
4817
5445
|
return { versions, next_cursor: response.next_cursor };
|
|
4818
5446
|
}
|
|
4819
5447
|
/** Deletes only the selected Update; never falls back to whole-Thesis deletion. */
|
|
@@ -4835,7 +5463,7 @@ var ThesesResource = class {
|
|
|
4835
5463
|
)
|
|
4836
5464
|
);
|
|
4837
5465
|
if (response.thesis.id !== thesisID)
|
|
4838
|
-
throw
|
|
5466
|
+
throw invalidResponse4(
|
|
4839
5467
|
"delete Update response must match requested Thesis"
|
|
4840
5468
|
);
|
|
4841
5469
|
return response;
|
|
@@ -4874,7 +5502,7 @@ var ThesesResource = class {
|
|
|
4874
5502
|
})
|
|
4875
5503
|
);
|
|
4876
5504
|
if (response.thesis.id !== thesisID) {
|
|
4877
|
-
throw
|
|
5505
|
+
throw invalidResponse4("update response must match the requested thesis");
|
|
4878
5506
|
}
|
|
4879
5507
|
return response;
|
|
4880
5508
|
}
|
|
@@ -4896,7 +5524,7 @@ var ThesesResource = class {
|
|
|
4896
5524
|
current.thesis.entity_ids,
|
|
4897
5525
|
current.thesis.entity_stances
|
|
4898
5526
|
)) {
|
|
4899
|
-
throw
|
|
5527
|
+
throw invalidResponse4(
|
|
4900
5528
|
"archive requires one entity_stance for every Thesis entity"
|
|
4901
5529
|
);
|
|
4902
5530
|
}
|
|
@@ -4913,7 +5541,7 @@ var ThesesResource = class {
|
|
|
4913
5541
|
note: params.note
|
|
4914
5542
|
});
|
|
4915
5543
|
if (response.thesis.id !== thesisID || response.thesis.archived !== params.archived) {
|
|
4916
|
-
throw
|
|
5544
|
+
throw invalidResponse4("archive response must match the requested state");
|
|
4917
5545
|
}
|
|
4918
5546
|
return response;
|
|
4919
5547
|
}
|
|
@@ -4928,15 +5556,15 @@ var ThesesResource = class {
|
|
|
4928
5556
|
});
|
|
4929
5557
|
const result = data.setThesisStarred;
|
|
4930
5558
|
if (!isRecord2(result) || !isRecord2(result.stats) || !isRecord2(result.viewerState)) {
|
|
4931
|
-
throw
|
|
5559
|
+
throw invalidResponse4("star response must contain stats and viewerState");
|
|
4932
5560
|
}
|
|
4933
5561
|
const returnedID = responseID(result.thesisId, "thesisId");
|
|
4934
5562
|
if (returnedID !== thesisID) {
|
|
4935
|
-
throw
|
|
5563
|
+
throw invalidResponse4("star response must match the requested thesis");
|
|
4936
5564
|
}
|
|
4937
5565
|
const starCount = result.stats.starCount;
|
|
4938
5566
|
if (typeof starCount !== "number" || !Number.isInteger(starCount) || starCount < 0) {
|
|
4939
|
-
throw
|
|
5567
|
+
throw invalidResponse4(
|
|
4940
5568
|
"star response must contain a nonnegative star count"
|
|
4941
5569
|
);
|
|
4942
5570
|
}
|
|
@@ -4945,7 +5573,7 @@ var ThesesResource = class {
|
|
|
4945
5573
|
"viewerState.isStarred"
|
|
4946
5574
|
);
|
|
4947
5575
|
if (returnedStarred !== isStarred) {
|
|
4948
|
-
throw
|
|
5576
|
+
throw invalidResponse4("star response did not apply the requested state");
|
|
4949
5577
|
}
|
|
4950
5578
|
return {
|
|
4951
5579
|
thesis_id: returnedID,
|
|
@@ -4964,7 +5592,7 @@ var ThesesResource = class {
|
|
|
4964
5592
|
});
|
|
4965
5593
|
const result = data.setThesisSignalEnabled;
|
|
4966
5594
|
if (!isRecord2(result) || !isRecord2(result.publication)) {
|
|
4967
|
-
throw
|
|
5595
|
+
throw invalidResponse4("Signal response must contain publication");
|
|
4968
5596
|
}
|
|
4969
5597
|
const publication = result.publication;
|
|
4970
5598
|
const returnedID = responseID(
|
|
@@ -4972,14 +5600,14 @@ var ThesesResource = class {
|
|
|
4972
5600
|
"publication.playbookId"
|
|
4973
5601
|
);
|
|
4974
5602
|
if (returnedID !== thesisID) {
|
|
4975
|
-
throw
|
|
5603
|
+
throw invalidResponse4("Signal response must match the requested thesis");
|
|
4976
5604
|
}
|
|
4977
5605
|
const researchPaused = responseBoolean(
|
|
4978
5606
|
publication.researchPaused,
|
|
4979
5607
|
"publication.researchPaused"
|
|
4980
5608
|
);
|
|
4981
5609
|
if (researchPaused === enabled) {
|
|
4982
|
-
throw
|
|
5610
|
+
throw invalidResponse4(
|
|
4983
5611
|
"Signal response did not apply the requested state"
|
|
4984
5612
|
);
|
|
4985
5613
|
}
|
|
@@ -5009,7 +5637,7 @@ var ThesesResource = class {
|
|
|
5009
5637
|
)
|
|
5010
5638
|
);
|
|
5011
5639
|
if (response.thesis.id !== thesisID || response.thesis.visibility !== visibility) {
|
|
5012
|
-
throw
|
|
5640
|
+
throw invalidResponse4(
|
|
5013
5641
|
"visibility response must match the requested thesis and visibility"
|
|
5014
5642
|
);
|
|
5015
5643
|
}
|
|
@@ -5040,7 +5668,7 @@ var ThesesResource = class {
|
|
|
5040
5668
|
);
|
|
5041
5669
|
if (response === void 0) return {};
|
|
5042
5670
|
if (!isRecord2(response) || Object.keys(response).length !== 0) {
|
|
5043
|
-
throw
|
|
5671
|
+
throw invalidResponse4("delete response must be {}");
|
|
5044
5672
|
}
|
|
5045
5673
|
return {};
|
|
5046
5674
|
}
|
|
@@ -5056,7 +5684,7 @@ var ThesesResource = class {
|
|
|
5056
5684
|
}
|
|
5057
5685
|
);
|
|
5058
5686
|
if (!isRecord2(response) || typeof response.body !== "string") {
|
|
5059
|
-
throw
|
|
5687
|
+
throw invalidResponse4("rewrite response must contain a string body");
|
|
5060
5688
|
}
|
|
5061
5689
|
return { body: responseBody(response.body) };
|
|
5062
5690
|
}
|
|
@@ -5152,7 +5780,7 @@ function updateBody(params) {
|
|
|
5152
5780
|
}
|
|
5153
5781
|
function thesisResponse(response) {
|
|
5154
5782
|
if (!isRecord2(response) || !isRecord2(response.thesis)) {
|
|
5155
|
-
throw
|
|
5783
|
+
throw invalidResponse4("response must contain thesis");
|
|
5156
5784
|
}
|
|
5157
5785
|
const thesis = response.thesis;
|
|
5158
5786
|
const value = {
|
|
@@ -5177,10 +5805,10 @@ function thesisResponse(response) {
|
|
|
5177
5805
|
};
|
|
5178
5806
|
if (thesis.medias !== void 0) {
|
|
5179
5807
|
if (!Array.isArray(thesis.medias) || thesis.medias.length > 20)
|
|
5180
|
-
throw
|
|
5808
|
+
throw invalidResponse4("thesis.medias must contain at most 20 items");
|
|
5181
5809
|
value.medias = thesis.medias.map((item) => {
|
|
5182
5810
|
if (!validMedia(item))
|
|
5183
|
-
throw
|
|
5811
|
+
throw invalidResponse4("thesis.medias contains invalid media");
|
|
5184
5812
|
return {
|
|
5185
5813
|
type: item.type,
|
|
5186
5814
|
cover_url: item.cover_url,
|
|
@@ -5197,15 +5825,15 @@ function thesisResponse(response) {
|
|
|
5197
5825
|
value.note = responseText(thesis.note, "thesis.note");
|
|
5198
5826
|
if (thesis.entity_stances !== void 0) {
|
|
5199
5827
|
if (!Array.isArray(thesis.entity_stances))
|
|
5200
|
-
throw
|
|
5828
|
+
throw invalidResponse4("thesis.entity_stances must be an array");
|
|
5201
5829
|
value.entity_stances = thesis.entity_stances.map((item) => {
|
|
5202
5830
|
if (!isRecord2(item))
|
|
5203
|
-
throw
|
|
5831
|
+
throw invalidResponse4("thesis.entity_stances contains invalid entry");
|
|
5204
5832
|
const entityID = responseID(item.entity_id, "entity_stances.entity_id");
|
|
5205
5833
|
if (!value.entity_ids.includes(entityID))
|
|
5206
|
-
throw
|
|
5834
|
+
throw invalidResponse4("entity stance must reference a thesis entity");
|
|
5207
5835
|
if (!["unknown", "bullish", "bearish"].includes(item.stance))
|
|
5208
|
-
throw
|
|
5836
|
+
throw invalidResponse4("thesis.entity_stances contains invalid stance");
|
|
5209
5837
|
return { entity_id: entityID, stance: item.stance };
|
|
5210
5838
|
});
|
|
5211
5839
|
}
|
|
@@ -5214,7 +5842,7 @@ function thesisResponse(response) {
|
|
|
5214
5842
|
function thesisGetResponse(response) {
|
|
5215
5843
|
const base = thesisResponse(response);
|
|
5216
5844
|
if (!isRecord2(response) || !isRecord2(response.author)) {
|
|
5217
|
-
throw
|
|
5845
|
+
throw invalidResponse4("response must contain author");
|
|
5218
5846
|
}
|
|
5219
5847
|
const authorRecord = response.author;
|
|
5220
5848
|
const author = {
|
|
@@ -5228,14 +5856,14 @@ function thesisGetResponse(response) {
|
|
|
5228
5856
|
username: responseText(authorRecord.username, "author.username")
|
|
5229
5857
|
};
|
|
5230
5858
|
if (!Array.isArray(response.entities)) {
|
|
5231
|
-
throw
|
|
5859
|
+
throw invalidResponse4("response must contain entities");
|
|
5232
5860
|
}
|
|
5233
5861
|
if (response.entities.length !== base.thesis.entity_ids.length) {
|
|
5234
|
-
throw
|
|
5862
|
+
throw invalidResponse4("entities must match thesis.entity_ids");
|
|
5235
5863
|
}
|
|
5236
5864
|
const entities = response.entities.map((item, index) => {
|
|
5237
5865
|
if (!isRecord2(item))
|
|
5238
|
-
throw
|
|
5866
|
+
throw invalidResponse4(`entities[${index}] must be an object`);
|
|
5239
5867
|
const entity = {
|
|
5240
5868
|
id: responseID(item.id, `entities[${index}].id`),
|
|
5241
5869
|
ticker: responseText(item.ticker, `entities[${index}].ticker`),
|
|
@@ -5244,7 +5872,7 @@ function thesisGetResponse(response) {
|
|
|
5244
5872
|
kind: responseText(item.kind, `entities[${index}].kind`)
|
|
5245
5873
|
};
|
|
5246
5874
|
if (entity.id !== base.thesis.entity_ids[index]) {
|
|
5247
|
-
throw
|
|
5875
|
+
throw invalidResponse4("entities must preserve thesis.entity_ids order");
|
|
5248
5876
|
}
|
|
5249
5877
|
return entity;
|
|
5250
5878
|
});
|
|
@@ -5252,7 +5880,7 @@ function thesisGetResponse(response) {
|
|
|
5252
5880
|
}
|
|
5253
5881
|
function thesisSignalsResponse(response, thesisID, first) {
|
|
5254
5882
|
if (!isRecord2(response) || !isRecord2(response.research) || !Array.isArray(response.entries) || response.entries.length > first) {
|
|
5255
|
-
throw
|
|
5883
|
+
throw invalidResponse4("invalid Signal history response");
|
|
5256
5884
|
}
|
|
5257
5885
|
const research = response.research;
|
|
5258
5886
|
const status = {
|
|
@@ -5278,13 +5906,13 @@ function thesisSignalsResponse(response, thesisID, first) {
|
|
|
5278
5906
|
);
|
|
5279
5907
|
const entries = response.entries.map((raw) => {
|
|
5280
5908
|
if (!isRecord2(raw) || !isRecord2(raw.signal) || !isRecord2(raw.signal.source)) {
|
|
5281
|
-
throw
|
|
5909
|
+
throw invalidResponse4("entry must include a Signal and source");
|
|
5282
5910
|
}
|
|
5283
5911
|
const signal = raw.signal;
|
|
5284
5912
|
const source = signal.source;
|
|
5285
5913
|
const signalID = responseID(signal.thesis_id, "signal.thesis_id");
|
|
5286
5914
|
if (signalID !== thesisID)
|
|
5287
|
-
throw
|
|
5915
|
+
throw invalidResponse4("Signal belongs to another Thesis");
|
|
5288
5916
|
const cursor = responseNonemptyText(raw.cursor, "entry.cursor");
|
|
5289
5917
|
const mappedSource = {
|
|
5290
5918
|
title: responseText(source.title, "source.title")
|
|
@@ -5317,7 +5945,7 @@ function thesisSignalsResponse(response, thesisID, first) {
|
|
|
5317
5945
|
};
|
|
5318
5946
|
if (signal.evidence_excerpt !== void 0) {
|
|
5319
5947
|
if (!isRecord2(signal.evidence_excerpt))
|
|
5320
|
-
throw
|
|
5948
|
+
throw invalidResponse4("invalid evidence excerpt");
|
|
5321
5949
|
mappedSignal.evidence_excerpt = {
|
|
5322
5950
|
text: responseNonemptyText(
|
|
5323
5951
|
signal.evidence_excerpt.text,
|
|
@@ -5341,19 +5969,19 @@ function thesisSignalsResponse(response, thesisID, first) {
|
|
|
5341
5969
|
});
|
|
5342
5970
|
const nextCursor2 = responseText(response.next_cursor, "next_cursor");
|
|
5343
5971
|
if (nextCursor2 && nextCursor2 !== entries[entries.length - 1]?.cursor) {
|
|
5344
|
-
throw
|
|
5972
|
+
throw invalidResponse4("next_cursor must match the final entry");
|
|
5345
5973
|
}
|
|
5346
5974
|
return { research: status, entries, next_cursor: nextCursor2 };
|
|
5347
5975
|
}
|
|
5348
5976
|
function responseNonnegativeInteger(value, field) {
|
|
5349
5977
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
5350
|
-
throw
|
|
5978
|
+
throw invalidResponse4(field + " must be a nonnegative safe integer");
|
|
5351
5979
|
}
|
|
5352
5980
|
return value;
|
|
5353
5981
|
}
|
|
5354
5982
|
function responseNonemptyText(value, field) {
|
|
5355
5983
|
const valueText = responseText(value, field);
|
|
5356
|
-
if (!valueText.trim()) throw
|
|
5984
|
+
if (!valueText.trim()) throw invalidResponse4(field + " must be nonempty");
|
|
5357
5985
|
return valueText;
|
|
5358
5986
|
}
|
|
5359
5987
|
function requireRequestID(value) {
|
|
@@ -5444,20 +6072,20 @@ function requireText2(value, field) {
|
|
|
5444
6072
|
}
|
|
5445
6073
|
function responseID(value, field) {
|
|
5446
6074
|
if (typeof value === "number") {
|
|
5447
|
-
throw
|
|
6075
|
+
throw invalidResponse4(
|
|
5448
6076
|
`${field} must be a decimal string; numeric IDs are unsafe`
|
|
5449
6077
|
);
|
|
5450
6078
|
}
|
|
5451
6079
|
try {
|
|
5452
6080
|
return requireID(value, field);
|
|
5453
6081
|
} catch {
|
|
5454
|
-
throw
|
|
6082
|
+
throw invalidResponse4(`${field} must be a positive int64 decimal string`);
|
|
5455
6083
|
}
|
|
5456
6084
|
}
|
|
5457
6085
|
function responseIDs(value, field) {
|
|
5458
|
-
if (!Array.isArray(value)) throw
|
|
6086
|
+
if (!Array.isArray(value)) throw invalidResponse4(`${field} must be an array`);
|
|
5459
6087
|
if (value.length > MAX_ENTITY_IDS) {
|
|
5460
|
-
throw
|
|
6088
|
+
throw invalidResponse4(
|
|
5461
6089
|
`${field} must contain at most ${MAX_ENTITY_IDS} IDs`
|
|
5462
6090
|
);
|
|
5463
6091
|
}
|
|
@@ -5467,33 +6095,33 @@ function responseText(value, field) {
|
|
|
5467
6095
|
try {
|
|
5468
6096
|
return requireText2(value, field);
|
|
5469
6097
|
} catch {
|
|
5470
|
-
throw
|
|
6098
|
+
throw invalidResponse4(`${field} must be valid text`);
|
|
5471
6099
|
}
|
|
5472
6100
|
}
|
|
5473
6101
|
function responseClosingNote(value) {
|
|
5474
6102
|
try {
|
|
5475
6103
|
return requireText2(value, "note");
|
|
5476
6104
|
} catch {
|
|
5477
|
-
throw
|
|
6105
|
+
throw invalidResponse4("thesis.closing_note must be valid text");
|
|
5478
6106
|
}
|
|
5479
6107
|
}
|
|
5480
6108
|
function responseBoolean(value, field) {
|
|
5481
6109
|
if (typeof value !== "boolean")
|
|
5482
|
-
throw
|
|
6110
|
+
throw invalidResponse4(`${field} must be boolean`);
|
|
5483
6111
|
return value;
|
|
5484
6112
|
}
|
|
5485
6113
|
function responseVisibility(value) {
|
|
5486
6114
|
try {
|
|
5487
6115
|
return requireVisibility(value);
|
|
5488
6116
|
} catch {
|
|
5489
|
-
throw
|
|
6117
|
+
throw invalidResponse4("thesis.visibility must be public, private or paid");
|
|
5490
6118
|
}
|
|
5491
6119
|
}
|
|
5492
6120
|
function responseBody(value) {
|
|
5493
6121
|
try {
|
|
5494
6122
|
return requireBody(value);
|
|
5495
6123
|
} catch {
|
|
5496
|
-
throw
|
|
6124
|
+
throw invalidResponse4(
|
|
5497
6125
|
"response body must be nonblank valid text at most 65536 UTF-8 bytes"
|
|
5498
6126
|
);
|
|
5499
6127
|
}
|
|
@@ -5502,7 +6130,7 @@ function responseTitle(value) {
|
|
|
5502
6130
|
try {
|
|
5503
6131
|
return requireTitle(value);
|
|
5504
6132
|
} catch {
|
|
5505
|
-
throw
|
|
6133
|
+
throw invalidResponse4(
|
|
5506
6134
|
"response title must be valid text at most 500 UTF-8 bytes"
|
|
5507
6135
|
);
|
|
5508
6136
|
}
|
|
@@ -5522,7 +6150,7 @@ function completeEntityStances(entityIDs, stances) {
|
|
|
5522
6150
|
function invalidArgument(message) {
|
|
5523
6151
|
return new AlvaError("INVALID_ARGUMENT", message, 400);
|
|
5524
6152
|
}
|
|
5525
|
-
function
|
|
6153
|
+
function invalidResponse4(message) {
|
|
5526
6154
|
return new AlvaError("INVALID_RESPONSE", message, 502);
|
|
5527
6155
|
}
|
|
5528
6156
|
function validMedia(item) {
|
|
@@ -5543,10 +6171,10 @@ async function thesisGraphql(client, query, variables) {
|
|
|
5543
6171
|
body: { query, variables }
|
|
5544
6172
|
});
|
|
5545
6173
|
if (!isRecord2(response))
|
|
5546
|
-
throw
|
|
6174
|
+
throw invalidResponse4("GraphQL response must be an object");
|
|
5547
6175
|
if (response.errors !== void 0) {
|
|
5548
6176
|
if (!Array.isArray(response.errors))
|
|
5549
|
-
throw
|
|
6177
|
+
throw invalidResponse4("GraphQL errors must be an array");
|
|
5550
6178
|
if (response.errors.length > 0) {
|
|
5551
6179
|
const messages = response.errors.flatMap(
|
|
5552
6180
|
(error) => isRecord2(error) && typeof error.message === "string" ? [error.message] : []
|
|
@@ -5568,7 +6196,7 @@ async function thesisGraphql(client, query, variables) {
|
|
|
5568
6196
|
}
|
|
5569
6197
|
}
|
|
5570
6198
|
if (!isRecord2(response.data))
|
|
5571
|
-
throw
|
|
6199
|
+
throw invalidResponse4("GraphQL response must contain data");
|
|
5572
6200
|
return response.data;
|
|
5573
6201
|
}
|
|
5574
6202
|
|
|
@@ -5578,7 +6206,7 @@ var CREATE_COMPANY_NEWS = `mutation CreateCompanyNews($input: CompanyNewsFeedInp
|
|
|
5578
6206
|
createFeed(input: $input) { id producer { id } }
|
|
5579
6207
|
}
|
|
5580
6208
|
}`;
|
|
5581
|
-
var
|
|
6209
|
+
var GRAPHQL_STATUS_BY_CODE5 = {
|
|
5582
6210
|
INVALID_ARGUMENT: 400,
|
|
5583
6211
|
UNAUTHENTICATED: 401,
|
|
5584
6212
|
PERMISSION_DENIED: 403,
|
|
@@ -5647,7 +6275,7 @@ var CompanyNewsResource = class {
|
|
|
5647
6275
|
throw new AlvaError(
|
|
5648
6276
|
code,
|
|
5649
6277
|
graph.errors.map((error) => error?.message).filter(Boolean).join("; ") || "Company News creation failed",
|
|
5650
|
-
|
|
6278
|
+
GRAPHQL_STATUS_BY_CODE5[code] ?? 502,
|
|
5651
6279
|
{ errors: graph.errors }
|
|
5652
6280
|
);
|
|
5653
6281
|
}
|
|
@@ -5773,6 +6401,7 @@ var AlvaClient = class {
|
|
|
5773
6401
|
_notifications;
|
|
5774
6402
|
_notificationPreferences;
|
|
5775
6403
|
_subscriptions;
|
|
6404
|
+
_follows;
|
|
5776
6405
|
_alerts;
|
|
5777
6406
|
_channelGroupSubscriptions;
|
|
5778
6407
|
_feedback;
|
|
@@ -5864,6 +6493,9 @@ var AlvaClient = class {
|
|
|
5864
6493
|
get subscriptions() {
|
|
5865
6494
|
return this._subscriptions ??= new SubscriptionsResource(this);
|
|
5866
6495
|
}
|
|
6496
|
+
get follows() {
|
|
6497
|
+
return this._follows ??= new FollowsResource(this);
|
|
6498
|
+
}
|
|
5867
6499
|
get alerts() {
|
|
5868
6500
|
return this._alerts ??= new AlertsResource(this);
|
|
5869
6501
|
}
|
|
@@ -6516,7 +7148,7 @@ var installPlaybookRuntime = (targetWindow) => {
|
|
|
6516
7148
|
};
|
|
6517
7149
|
|
|
6518
7150
|
// src/index.ts
|
|
6519
|
-
var VERSION = true ? "0.
|
|
7151
|
+
var VERSION = true ? "0.35.0" : "dev";
|
|
6520
7152
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6521
7153
|
0 && (module.exports = {
|
|
6522
7154
|
AlertsResource,
|
|
@@ -6526,6 +7158,7 @@ var VERSION = true ? "0.34.0-beta.0" : "dev";
|
|
|
6526
7158
|
AutomationResource,
|
|
6527
7159
|
CliUsageError,
|
|
6528
7160
|
CompanyNewsResource,
|
|
7161
|
+
FollowsResource,
|
|
6529
7162
|
ForYouResource,
|
|
6530
7163
|
MarketsResource,
|
|
6531
7164
|
PBSV_UPDATE_MESSAGE,
|