@alva-ai/toolkit 0.33.1 → 0.34.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/dist/browser.global.js +56 -46
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +53 -4
- package/dist/cli.js +460 -20
- package/dist/cli.js.map +1 -1
- package/dist/dispatch.d.ts +53 -4
- package/dist/dispatch.js +186 -9
- package/dist/dispatch.js.map +1 -1
- package/dist/index.cjs +309 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -5
- package/dist/index.d.ts +54 -5
- package/dist/index.js +309 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9929,7 +9929,7 @@ query ToolkitStewardPending($inboxPath: String!, $input: StewardDigestPendingInp
|
|
|
9929
9929
|
stewardDigestPending(inboxPath: $inboxPath, input: $input) {
|
|
9930
9930
|
edges {
|
|
9931
9931
|
cursor
|
|
9932
|
-
node { deliveryId feedEntryId source { kind id } decisionReason consumedAtMs }
|
|
9932
|
+
node { deliveryId feedEntryId source { kind id } decisionReason consumedAtMs alertSnapshot }
|
|
9933
9933
|
}
|
|
9934
9934
|
pageInfo { hasNextPage endCursor }
|
|
9935
9935
|
windowSinceMs
|
|
@@ -10567,6 +10567,18 @@ function notFound() {
|
|
|
10567
10567
|
}
|
|
10568
10568
|
|
|
10569
10569
|
// src/resources/theses.ts
|
|
10570
|
+
var SET_THESIS_STARRED = `mutation SetThesisStarred($input: SetThesisStarredInput!) {
|
|
10571
|
+
setThesisStarred(input: $input) {
|
|
10572
|
+
thesisId
|
|
10573
|
+
stats { starCount }
|
|
10574
|
+
viewerState { isStarred }
|
|
10575
|
+
}
|
|
10576
|
+
}`;
|
|
10577
|
+
var SET_THESIS_SIGNAL_ENABLED = `mutation SetThesisSignalEnabled($input: SetThesisSignalEnabledInput!) {
|
|
10578
|
+
setThesisSignalEnabled(input: $input) {
|
|
10579
|
+
publication { playbookId authorVersionId archived researchPaused }
|
|
10580
|
+
}
|
|
10581
|
+
}`;
|
|
10570
10582
|
var MAX_SIGNED_INT64 = 9223372036854775807n;
|
|
10571
10583
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
10572
10584
|
var UNPAIRED_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
@@ -10643,9 +10655,14 @@ var ThesesResource = class {
|
|
|
10643
10655
|
}
|
|
10644
10656
|
async get(id) {
|
|
10645
10657
|
this.client._requireAuth();
|
|
10646
|
-
|
|
10647
|
-
|
|
10658
|
+
const thesisID = requireID(id, "id");
|
|
10659
|
+
const response = thesisGetResponse(
|
|
10660
|
+
await this.client._request("GET", `/api/v1/theses/${thesisID}`)
|
|
10648
10661
|
);
|
|
10662
|
+
if (response.thesis.id !== thesisID) {
|
|
10663
|
+
throw invalidResponse3("get response must match the requested thesis");
|
|
10664
|
+
}
|
|
10665
|
+
return response;
|
|
10649
10666
|
}
|
|
10650
10667
|
async getVersion(id, authorVersionID) {
|
|
10651
10668
|
this.client._requireAuth();
|
|
@@ -10664,6 +10681,55 @@ var ThesesResource = class {
|
|
|
10664
10681
|
}
|
|
10665
10682
|
return response;
|
|
10666
10683
|
}
|
|
10684
|
+
/** Lists reader-visible Updates, with editorial revisions folded together. */
|
|
10685
|
+
async listUpdates(id, params = {}) {
|
|
10686
|
+
this.client._requireAuth();
|
|
10687
|
+
const thesisID = requireID(id, "id");
|
|
10688
|
+
const first = params.first ?? 10;
|
|
10689
|
+
if (!Number.isInteger(first) || first < 1 || first > 100)
|
|
10690
|
+
throw invalidArgument("first must be between 1 and 100");
|
|
10691
|
+
if (params.cursor !== void 0 && typeof params.cursor !== "string")
|
|
10692
|
+
throw invalidArgument("cursor must be a string");
|
|
10693
|
+
const response = await this.client._request(
|
|
10694
|
+
"GET",
|
|
10695
|
+
`/api/v1/theses/${thesisID}/versions`,
|
|
10696
|
+
{
|
|
10697
|
+
query: { first, cursor: params.cursor, updates_only: true }
|
|
10698
|
+
}
|
|
10699
|
+
);
|
|
10700
|
+
if (!isRecord2(response) || !Array.isArray(response.versions) || typeof response.next_cursor !== "string")
|
|
10701
|
+
throw invalidResponse3("invalid Update list");
|
|
10702
|
+
const versions = response.versions.map(
|
|
10703
|
+
(value) => thesisResponse({ thesis: value }).thesis
|
|
10704
|
+
);
|
|
10705
|
+
if (versions.some((version) => version.id !== thesisID))
|
|
10706
|
+
throw invalidResponse3("Update list must match requested Thesis");
|
|
10707
|
+
return { versions, next_cursor: response.next_cursor };
|
|
10708
|
+
}
|
|
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
|
+
}
|
|
10667
10733
|
async signals(id, params = {}) {
|
|
10668
10734
|
this.client._requireAuth();
|
|
10669
10735
|
const first = params.first ?? 20;
|
|
@@ -10691,15 +10757,132 @@ var ThesesResource = class {
|
|
|
10691
10757
|
async update(id, params) {
|
|
10692
10758
|
this.client._requireAuth();
|
|
10693
10759
|
const body = updateBody(params);
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
|
|
10700
|
-
|
|
10701
|
-
)
|
|
10760
|
+
const thesisID = requireID(id, "id");
|
|
10761
|
+
const response = thesisResponse(
|
|
10762
|
+
await this.client._request("PUT", `/api/v1/theses/${thesisID}`, {
|
|
10763
|
+
body
|
|
10764
|
+
})
|
|
10765
|
+
);
|
|
10766
|
+
if (response.thesis.id !== thesisID) {
|
|
10767
|
+
throw invalidResponse3("update response must match the requested thesis");
|
|
10768
|
+
}
|
|
10769
|
+
return response;
|
|
10770
|
+
}
|
|
10771
|
+
/** Archive or restore the current version without asking callers to resend its body. */
|
|
10772
|
+
async setArchived(id, params) {
|
|
10773
|
+
this.client._requireAuth();
|
|
10774
|
+
if (!isRecord2(params)) throw invalidArgument("params is required");
|
|
10775
|
+
const thesisID = requireID(id, "id");
|
|
10776
|
+
const requestID = requireRequestID(params.request_id);
|
|
10777
|
+
if (typeof params.archived !== "boolean") {
|
|
10778
|
+
throw invalidArgument("archived must be a boolean");
|
|
10779
|
+
}
|
|
10780
|
+
if (params.note !== void 0) requireText2(params.note, "note");
|
|
10781
|
+
const current = await this.get(thesisID);
|
|
10782
|
+
if (current.thesis.archived === params.archived && params.note === void 0) {
|
|
10783
|
+
return { thesis: current.thesis };
|
|
10784
|
+
}
|
|
10785
|
+
if (!completeEntityStances(
|
|
10786
|
+
current.thesis.entity_ids,
|
|
10787
|
+
current.thesis.entity_stances
|
|
10788
|
+
)) {
|
|
10789
|
+
throw invalidResponse3(
|
|
10790
|
+
"archive requires one entity_stance for every Thesis entity"
|
|
10791
|
+
);
|
|
10792
|
+
}
|
|
10793
|
+
const response = await this.update(thesisID, {
|
|
10794
|
+
request_id: requestID,
|
|
10795
|
+
expected_author_version_id: current.thesis.author_version_id,
|
|
10796
|
+
body: current.thesis.body,
|
|
10797
|
+
title: current.thesis.title,
|
|
10798
|
+
entity_ids: current.thesis.entity_ids,
|
|
10799
|
+
entity_stances: current.thesis.entity_stances,
|
|
10800
|
+
visibility: current.thesis.visibility,
|
|
10801
|
+
archived: params.archived,
|
|
10802
|
+
medias: current.thesis.medias,
|
|
10803
|
+
note: params.note
|
|
10804
|
+
});
|
|
10805
|
+
if (response.thesis.id !== thesisID || response.thesis.archived !== params.archived) {
|
|
10806
|
+
throw invalidResponse3("archive response must match the requested state");
|
|
10807
|
+
}
|
|
10808
|
+
return response;
|
|
10809
|
+
}
|
|
10810
|
+
async setStarred(id, isStarred) {
|
|
10811
|
+
this.client._requireAuth();
|
|
10812
|
+
const thesisID = requireID(id, "id");
|
|
10813
|
+
if (typeof isStarred !== "boolean") {
|
|
10814
|
+
throw invalidArgument("isStarred must be a boolean");
|
|
10815
|
+
}
|
|
10816
|
+
const data = await thesisGraphql(this.client, SET_THESIS_STARRED, {
|
|
10817
|
+
input: { thesisId: thesisID, isStarred }
|
|
10818
|
+
});
|
|
10819
|
+
const result = data.setThesisStarred;
|
|
10820
|
+
if (!isRecord2(result) || !isRecord2(result.stats) || !isRecord2(result.viewerState)) {
|
|
10821
|
+
throw invalidResponse3("star response must contain stats and viewerState");
|
|
10822
|
+
}
|
|
10823
|
+
const returnedID = responseID(result.thesisId, "thesisId");
|
|
10824
|
+
if (returnedID !== thesisID) {
|
|
10825
|
+
throw invalidResponse3("star response must match the requested thesis");
|
|
10826
|
+
}
|
|
10827
|
+
const starCount = result.stats.starCount;
|
|
10828
|
+
if (typeof starCount !== "number" || !Number.isInteger(starCount) || starCount < 0) {
|
|
10829
|
+
throw invalidResponse3(
|
|
10830
|
+
"star response must contain a nonnegative star count"
|
|
10831
|
+
);
|
|
10832
|
+
}
|
|
10833
|
+
const returnedStarred = responseBoolean(
|
|
10834
|
+
result.viewerState.isStarred,
|
|
10835
|
+
"viewerState.isStarred"
|
|
10702
10836
|
);
|
|
10837
|
+
if (returnedStarred !== isStarred) {
|
|
10838
|
+
throw invalidResponse3("star response did not apply the requested state");
|
|
10839
|
+
}
|
|
10840
|
+
return {
|
|
10841
|
+
thesis_id: returnedID,
|
|
10842
|
+
star_count: starCount,
|
|
10843
|
+
is_starred: returnedStarred
|
|
10844
|
+
};
|
|
10845
|
+
}
|
|
10846
|
+
async setSignalEnabled(id, enabled) {
|
|
10847
|
+
this.client._requireAuth();
|
|
10848
|
+
const thesisID = requireID(id, "id");
|
|
10849
|
+
if (typeof enabled !== "boolean") {
|
|
10850
|
+
throw invalidArgument("enabled must be a boolean");
|
|
10851
|
+
}
|
|
10852
|
+
const data = await thesisGraphql(this.client, SET_THESIS_SIGNAL_ENABLED, {
|
|
10853
|
+
input: { thesisId: thesisID, enabled }
|
|
10854
|
+
});
|
|
10855
|
+
const result = data.setThesisSignalEnabled;
|
|
10856
|
+
if (!isRecord2(result) || !isRecord2(result.publication)) {
|
|
10857
|
+
throw invalidResponse3("Signal response must contain publication");
|
|
10858
|
+
}
|
|
10859
|
+
const publication = result.publication;
|
|
10860
|
+
const returnedID = responseID(
|
|
10861
|
+
publication.playbookId,
|
|
10862
|
+
"publication.playbookId"
|
|
10863
|
+
);
|
|
10864
|
+
if (returnedID !== thesisID) {
|
|
10865
|
+
throw invalidResponse3("Signal response must match the requested thesis");
|
|
10866
|
+
}
|
|
10867
|
+
const researchPaused = responseBoolean(
|
|
10868
|
+
publication.researchPaused,
|
|
10869
|
+
"publication.researchPaused"
|
|
10870
|
+
);
|
|
10871
|
+
if (researchPaused === enabled) {
|
|
10872
|
+
throw invalidResponse3(
|
|
10873
|
+
"Signal response did not apply the requested state"
|
|
10874
|
+
);
|
|
10875
|
+
}
|
|
10876
|
+
return {
|
|
10877
|
+
thesis_id: returnedID,
|
|
10878
|
+
author_version_id: responseID(
|
|
10879
|
+
publication.authorVersionId,
|
|
10880
|
+
"publication.authorVersionId"
|
|
10881
|
+
),
|
|
10882
|
+
archived: responseBoolean(publication.archived, "publication.archived"),
|
|
10883
|
+
research_paused: researchPaused,
|
|
10884
|
+
enabled: !researchPaused
|
|
10885
|
+
};
|
|
10703
10886
|
}
|
|
10704
10887
|
async setVisibility(id, params) {
|
|
10705
10888
|
this.client._requireAuth();
|
|
@@ -10707,7 +10890,7 @@ var ThesesResource = class {
|
|
|
10707
10890
|
throw invalidArgument("params is required");
|
|
10708
10891
|
}
|
|
10709
10892
|
const thesisID = requireID(id, "id");
|
|
10710
|
-
const visibility =
|
|
10893
|
+
const visibility = requirePublicVisibility(params.visibility);
|
|
10711
10894
|
const response = thesisResponse(
|
|
10712
10895
|
await this.client._request(
|
|
10713
10896
|
"POST",
|
|
@@ -10774,8 +10957,23 @@ function createBody(params) {
|
|
|
10774
10957
|
body: requireBody(params.body),
|
|
10775
10958
|
title: requireTitle(params.title ?? ""),
|
|
10776
10959
|
entity_ids: requireIDs(params.entity_ids ?? [], "entity_ids"),
|
|
10777
|
-
visibility:
|
|
10960
|
+
visibility: requirePublicVisibility(params.visibility ?? "public")
|
|
10778
10961
|
};
|
|
10962
|
+
if (params.images !== void 0) {
|
|
10963
|
+
if (!Array.isArray(params.images) || params.images.length > 20)
|
|
10964
|
+
throw invalidArgument("images must contain at most 20 URLs");
|
|
10965
|
+
if (params.images.length && body.visibility !== "public")
|
|
10966
|
+
throw invalidArgument(
|
|
10967
|
+
"image publication currently requires public visibility"
|
|
10968
|
+
);
|
|
10969
|
+
body.medias = params.images.map((url) => {
|
|
10970
|
+
if (!validMediaURL(url) || !url.startsWith("https://"))
|
|
10971
|
+
throw invalidArgument(
|
|
10972
|
+
"images must contain HTTPS URLs returned by the upload tool"
|
|
10973
|
+
);
|
|
10974
|
+
return { type: "image", cover_url: url, url };
|
|
10975
|
+
});
|
|
10976
|
+
}
|
|
10779
10977
|
if (params.tickers !== void 0)
|
|
10780
10978
|
body.tickers = requireTickers(params.tickers);
|
|
10781
10979
|
if (params.entity_stances !== void 0) {
|
|
@@ -10821,6 +11019,19 @@ function updateBody(params) {
|
|
|
10821
11019
|
visibility: requireVisibility(params.visibility),
|
|
10822
11020
|
editorial: params.editorial ?? false
|
|
10823
11021
|
};
|
|
11022
|
+
if (params.medias !== void 0) {
|
|
11023
|
+
if (!Array.isArray(params.medias) || params.medias.length > 20)
|
|
11024
|
+
throw invalidArgument("medias must be an array of at most 20 items");
|
|
11025
|
+
if (!params.medias.every(validMedia))
|
|
11026
|
+
throw invalidArgument("medias contains invalid media");
|
|
11027
|
+
body.medias = params.medias;
|
|
11028
|
+
}
|
|
11029
|
+
if (params.archived !== void 0) {
|
|
11030
|
+
if (typeof params.archived !== "boolean")
|
|
11031
|
+
throw invalidArgument("archived must be a boolean");
|
|
11032
|
+
body.archived = params.archived;
|
|
11033
|
+
}
|
|
11034
|
+
if (params.note !== void 0) body.note = requireText2(params.note, "note");
|
|
10824
11035
|
if (params.entity_stances !== void 0) {
|
|
10825
11036
|
body.entity_stances = requireEntityStances(
|
|
10826
11037
|
params.entity_stances,
|
|
@@ -10849,10 +11060,31 @@ function thesisResponse(response) {
|
|
|
10849
11060
|
entity_ids: responseIDs(thesis.entity_ids, "thesis.entity_ids"),
|
|
10850
11061
|
visibility: responseVisibility(thesis.visibility),
|
|
10851
11062
|
closed: responseBoolean(thesis.closed, "thesis.closed"),
|
|
11063
|
+
archived: responseBoolean(thesis.archived, "thesis.archived"),
|
|
10852
11064
|
closing_note: responseClosingNote(thesis.closing_note),
|
|
10853
11065
|
author_kind: responseText(thesis.author_kind, "thesis.author_kind"),
|
|
10854
11066
|
author_ref: responseText(thesis.author_ref, "thesis.author_ref")
|
|
10855
11067
|
};
|
|
11068
|
+
if (thesis.medias !== void 0) {
|
|
11069
|
+
if (!Array.isArray(thesis.medias) || thesis.medias.length > 20)
|
|
11070
|
+
throw invalidResponse3("thesis.medias must contain at most 20 items");
|
|
11071
|
+
value.medias = thesis.medias.map((item) => {
|
|
11072
|
+
if (!validMedia(item))
|
|
11073
|
+
throw invalidResponse3("thesis.medias contains invalid media");
|
|
11074
|
+
return {
|
|
11075
|
+
type: item.type,
|
|
11076
|
+
cover_url: item.cover_url,
|
|
11077
|
+
...item.url === void 0 ? {} : { url: item.url }
|
|
11078
|
+
};
|
|
11079
|
+
});
|
|
11080
|
+
}
|
|
11081
|
+
if (thesis.version_archived !== void 0)
|
|
11082
|
+
value.version_archived = responseBoolean(
|
|
11083
|
+
thesis.version_archived,
|
|
11084
|
+
"thesis.version_archived"
|
|
11085
|
+
);
|
|
11086
|
+
if (thesis.note !== void 0)
|
|
11087
|
+
value.note = responseText(thesis.note, "thesis.note");
|
|
10856
11088
|
if (thesis.entity_stances !== void 0) {
|
|
10857
11089
|
if (!Array.isArray(thesis.entity_stances))
|
|
10858
11090
|
throw invalidResponse3("thesis.entity_stances must be an array");
|
|
@@ -11069,6 +11301,13 @@ function requireTitle(value) {
|
|
|
11069
11301
|
return title;
|
|
11070
11302
|
}
|
|
11071
11303
|
function requireVisibility(value) {
|
|
11304
|
+
const visibility = requireText2(value, "visibility");
|
|
11305
|
+
if (visibility !== "public" && visibility !== "private" && visibility !== "paid") {
|
|
11306
|
+
throw invalidArgument("visibility must be public, private or paid");
|
|
11307
|
+
}
|
|
11308
|
+
return visibility;
|
|
11309
|
+
}
|
|
11310
|
+
function requirePublicVisibility(value) {
|
|
11072
11311
|
const visibility = requireText2(value, "visibility");
|
|
11073
11312
|
if (visibility !== "public" && visibility !== "private") {
|
|
11074
11313
|
throw invalidArgument("visibility must be public or private");
|
|
@@ -11137,7 +11376,7 @@ function responseVisibility(value) {
|
|
|
11137
11376
|
try {
|
|
11138
11377
|
return requireVisibility(value);
|
|
11139
11378
|
} catch {
|
|
11140
|
-
throw invalidResponse3("thesis.visibility must be public or
|
|
11379
|
+
throw invalidResponse3("thesis.visibility must be public, private or paid");
|
|
11141
11380
|
}
|
|
11142
11381
|
}
|
|
11143
11382
|
function responseBody(value) {
|
|
@@ -11161,12 +11400,67 @@ function responseTitle(value) {
|
|
|
11161
11400
|
function isRecord2(value) {
|
|
11162
11401
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11163
11402
|
}
|
|
11403
|
+
function completeEntityStances(entityIDs, stances) {
|
|
11404
|
+
if (entityIDs.length === 0) return !stances || stances.length === 0;
|
|
11405
|
+
if (!stances || stances.length !== entityIDs.length) return false;
|
|
11406
|
+
const expected = new Set(entityIDs);
|
|
11407
|
+
const seen = /* @__PURE__ */ new Set();
|
|
11408
|
+
return stances.every(
|
|
11409
|
+
(stance) => expected.has(stance.entity_id) && !seen.has(stance.entity_id) && seen.add(stance.entity_id)
|
|
11410
|
+
);
|
|
11411
|
+
}
|
|
11164
11412
|
function invalidArgument(message) {
|
|
11165
11413
|
return new AlvaError("INVALID_ARGUMENT", message, 400);
|
|
11166
11414
|
}
|
|
11167
11415
|
function invalidResponse3(message) {
|
|
11168
11416
|
return new AlvaError("INVALID_RESPONSE", message, 502);
|
|
11169
11417
|
}
|
|
11418
|
+
function validMedia(item) {
|
|
11419
|
+
return isRecord2(item) && ["image", "price_chart", "audio", "video"].includes(item.type) && validMediaURL(item.cover_url) && (item.url == null || validMediaURL(item.url));
|
|
11420
|
+
}
|
|
11421
|
+
function validMediaURL(value) {
|
|
11422
|
+
if (typeof value !== "string" || value.length > 2048 || /[\s\u0000]/.test(value))
|
|
11423
|
+
return false;
|
|
11424
|
+
try {
|
|
11425
|
+
const url = new URL(value);
|
|
11426
|
+
return ["http:", "https:"].includes(url.protocol) && !!url.hostname && !url.username && !url.password;
|
|
11427
|
+
} catch {
|
|
11428
|
+
return false;
|
|
11429
|
+
}
|
|
11430
|
+
}
|
|
11431
|
+
async function thesisGraphql(client, query, variables) {
|
|
11432
|
+
const response = await client._request("POST", "/query", {
|
|
11433
|
+
body: { query, variables }
|
|
11434
|
+
});
|
|
11435
|
+
if (!isRecord2(response))
|
|
11436
|
+
throw invalidResponse3("GraphQL response must be an object");
|
|
11437
|
+
if (response.errors !== void 0) {
|
|
11438
|
+
if (!Array.isArray(response.errors))
|
|
11439
|
+
throw invalidResponse3("GraphQL errors must be an array");
|
|
11440
|
+
if (response.errors.length > 0) {
|
|
11441
|
+
const messages = response.errors.flatMap(
|
|
11442
|
+
(error) => isRecord2(error) && typeof error.message === "string" ? [error.message] : []
|
|
11443
|
+
);
|
|
11444
|
+
const codes = new Set(
|
|
11445
|
+
response.errors.map(
|
|
11446
|
+
(error) => isRecord2(error) && isRecord2(error.extensions) ? error.extensions.code : void 0
|
|
11447
|
+
)
|
|
11448
|
+
);
|
|
11449
|
+
const [code] = codes;
|
|
11450
|
+
const canonicalCode = codes.size === 1 && (code === "NOT_FOUND" || code === "PERMISSION_DENIED" || code === "UNAUTHENTICATED") ? code : void 0;
|
|
11451
|
+
const status = canonicalCode === "NOT_FOUND" ? 404 : canonicalCode === "PERMISSION_DENIED" ? 403 : canonicalCode === "UNAUTHENTICATED" ? 401 : 400;
|
|
11452
|
+
throw new AlvaError(
|
|
11453
|
+
canonicalCode ?? "GRAPHQL_ERROR",
|
|
11454
|
+
messages.join("; ") || "GraphQL request failed",
|
|
11455
|
+
status,
|
|
11456
|
+
{ errors: response.errors }
|
|
11457
|
+
);
|
|
11458
|
+
}
|
|
11459
|
+
}
|
|
11460
|
+
if (!isRecord2(response.data))
|
|
11461
|
+
throw invalidResponse3("GraphQL response must contain data");
|
|
11462
|
+
return response.data;
|
|
11463
|
+
}
|
|
11170
11464
|
|
|
11171
11465
|
// src/resources/companyNews.ts
|
|
11172
11466
|
var CREATE_COMPANY_NEWS = `mutation CreateCompanyNews($input: CompanyNewsFeedInput!) {
|
|
@@ -11957,6 +12251,7 @@ var COMMAND_DEFINITIONS = [
|
|
|
11957
12251
|
command("thesis create", {
|
|
11958
12252
|
values: [
|
|
11959
12253
|
"request-id",
|
|
12254
|
+
"images",
|
|
11960
12255
|
"body",
|
|
11961
12256
|
"body-file",
|
|
11962
12257
|
"title",
|
|
@@ -11982,11 +12277,20 @@ var COMMAND_DEFINITIONS = [
|
|
|
11982
12277
|
}),
|
|
11983
12278
|
command("thesis related", { values: ["id", "first", "cursor"] }),
|
|
11984
12279
|
command("thesis get", { values: ["id"] }),
|
|
12280
|
+
command("thesis version list", { values: ["id", "first", "cursor"] }),
|
|
12281
|
+
command("thesis version delete", {
|
|
12282
|
+
values: ["id", "author-version-id", "expected-author-version-id"]
|
|
12283
|
+
}),
|
|
11985
12284
|
command("thesis version get", {
|
|
11986
12285
|
values: ["id", "author-version-id"]
|
|
11987
12286
|
}),
|
|
11988
12287
|
command("thesis signals", { values: ["id", "first", "cursor"] }),
|
|
11989
12288
|
command("thesis set-visibility", { values: ["id", "visibility"] }),
|
|
12289
|
+
command("thesis archive", { values: ["id", "request-id", "note"] }),
|
|
12290
|
+
command("thesis restore", { values: ["id", "request-id", "note"] }),
|
|
12291
|
+
command("thesis star", { values: ["id"] }),
|
|
12292
|
+
command("thesis unstar", { values: ["id"] }),
|
|
12293
|
+
command("thesis set-signal-enabled", { values: ["id", "enabled"] }),
|
|
11990
12294
|
command("thesis update", {
|
|
11991
12295
|
values: [
|
|
11992
12296
|
"id",
|
|
@@ -11997,6 +12301,7 @@ var COMMAND_DEFINITIONS = [
|
|
|
11997
12301
|
"title",
|
|
11998
12302
|
"entity-ids",
|
|
11999
12303
|
"entity-stances",
|
|
12304
|
+
"medias",
|
|
12000
12305
|
"visibility"
|
|
12001
12306
|
],
|
|
12002
12307
|
booleans: ["body-stdin", "editorial"]
|
|
@@ -16682,7 +16987,7 @@ function formatTradingPairResolved(result) {
|
|
|
16682
16987
|
}
|
|
16683
16988
|
|
|
16684
16989
|
// src/cli/dispatch.ts
|
|
16685
|
-
var CLI_VERSION = true ? "0.
|
|
16990
|
+
var CLI_VERSION = true ? "0.34.0" : "dev";
|
|
16686
16991
|
var DEFAULT_RUN_TIMEOUT_MS = 6e5;
|
|
16687
16992
|
var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
|
|
16688
16993
|
var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
|
|
@@ -18124,8 +18429,15 @@ Subcommands:
|
|
|
18124
18429
|
related Read related current publications
|
|
18125
18430
|
get Get one thesis
|
|
18126
18431
|
version get Get one exact author version
|
|
18432
|
+
version list List visible Updates with editorial revisions folded together
|
|
18433
|
+
version delete Delete one Update; restore prior content if it is current
|
|
18127
18434
|
signals Read published Signal history
|
|
18128
18435
|
set-visibility Change current access without publishing a version
|
|
18436
|
+
archive Archive the current author version
|
|
18437
|
+
restore Restore an archived Thesis
|
|
18438
|
+
star Add the Thesis to your bookmarks
|
|
18439
|
+
unstar Remove the Thesis from your bookmarks
|
|
18440
|
+
set-signal-enabled Enable or disable managed Signal research
|
|
18129
18441
|
update Replaces document fields: body, title, entities, visibility (all sent in full)
|
|
18130
18442
|
close Close the current author version with an optional note
|
|
18131
18443
|
delete Delete a thesis
|
|
@@ -18143,7 +18455,10 @@ the backend; do not send a fresh ID. Create defaults --visibility to public.
|
|
|
18143
18455
|
Update requires --visibility explicitly so it cannot inadvertently publish.
|
|
18144
18456
|
|
|
18145
18457
|
Other flags:
|
|
18146
|
-
create --request-id <uuid> --body ... [--title <text>] [--tickers <ticker,ticker>] [--entity-ids <id,id>] [--entity-stances <json>] [--visibility <value>]
|
|
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>]
|
|
18459
|
+
Images: public creation only, at most 20 in display order. Upload selected files
|
|
18460
|
+
with the existing host upload tool after publication confirmation. Private
|
|
18461
|
+
images and local/ALFS paths are not supported; this flag does not upload.
|
|
18147
18462
|
list --person <slug> | --person-name <name> | --user <username>
|
|
18148
18463
|
| --ticker <ticker> | --entity-id <id>
|
|
18149
18464
|
[--status ACTIVE|ARCHIVED] [--first 10] [--cursor <nextCursor>]
|
|
@@ -18161,9 +18476,32 @@ Other flags:
|
|
|
18161
18476
|
asset-candidates --text <unsaved thesis text>
|
|
18162
18477
|
get --id <signed-int64-decimal>
|
|
18163
18478
|
version get --id <signed-int64-decimal> --author-version-id <signed-int64-decimal>
|
|
18479
|
+
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.
|
|
18164
18482
|
signals --id <id> [--first <1-50>] [--cursor <opaque-cursor>]
|
|
18165
18483
|
set-visibility --id <id> --visibility public|private
|
|
18166
|
-
|
|
18484
|
+
archive --id <id> --request-id <uuid> [--note <text>]
|
|
18485
|
+
restore --id <id> --request-id <uuid> [--note <text>]
|
|
18486
|
+
star|unstar --id <id>
|
|
18487
|
+
set-signal-enabled --id <id> --enabled true|false
|
|
18488
|
+
|
|
18489
|
+
Maintenance behavior:
|
|
18490
|
+
archive/restore read the current Thesis first, preserve its body, title,
|
|
18491
|
+
entities, directions, and visibility, then publish the state change against
|
|
18492
|
+
the current author version. They require a caller-supplied request UUID.
|
|
18493
|
+
A repeated request in the requested state is an idempotent read; a version
|
|
18494
|
+
conflict or incomplete directions fails without sending a stale update.
|
|
18495
|
+
--note is optional and belongs to the new author version.
|
|
18496
|
+
star/unstar change only the signed-in viewer's bookmark and return the
|
|
18497
|
+
authoritative bookmark state and count. They do not change Thesis content or
|
|
18498
|
+
Signal subscriptions.
|
|
18499
|
+
set-signal-enabled changes managed Signal research without deleting history.
|
|
18500
|
+
The command returns enabled, research_paused, archived, and author version
|
|
18501
|
+
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>] [--editorial]
|
|
18503
|
+
For text edits, pass current medias unchanged; omission clears media.
|
|
18504
|
+
|
|
18167
18505
|
Only editing the body? Resubmit the existing entity IDs and directions.
|
|
18168
18506
|
Omitted directions become unknown; explicit unknown clears a direction.
|
|
18169
18507
|
close --id <id> --expected-author-version-id <id> [--note <text>]
|
|
@@ -18576,12 +18914,37 @@ function feedVisibility(val) {
|
|
|
18576
18914
|
);
|
|
18577
18915
|
}
|
|
18578
18916
|
function thesisVisibility(value) {
|
|
18917
|
+
if (value === "public" || value === "private" || value === "paid")
|
|
18918
|
+
return value;
|
|
18919
|
+
throw new CliUsageError(
|
|
18920
|
+
"--visibility must be public, private or paid for thesis, got " + value,
|
|
18921
|
+
"thesis"
|
|
18922
|
+
);
|
|
18923
|
+
}
|
|
18924
|
+
function thesisCreateVisibility(value) {
|
|
18579
18925
|
if (value === "public" || value === "private") return value;
|
|
18580
18926
|
throw new CliUsageError(
|
|
18581
|
-
|
|
18927
|
+
"--visibility must be public or private for thesis create, got " + value,
|
|
18582
18928
|
"thesis"
|
|
18583
18929
|
);
|
|
18584
18930
|
}
|
|
18931
|
+
function thesisAccessVisibility(value) {
|
|
18932
|
+
if (value === "public" || value === "private") return value;
|
|
18933
|
+
throw new CliUsageError(
|
|
18934
|
+
"--visibility must be public or private for thesis set-visibility, got " + value,
|
|
18935
|
+
"thesis"
|
|
18936
|
+
);
|
|
18937
|
+
}
|
|
18938
|
+
function thesisBooleanFlag(value, command2) {
|
|
18939
|
+
const parsed = boolFlag(value);
|
|
18940
|
+
if (parsed === void 0) {
|
|
18941
|
+
throw new CliUsageError(
|
|
18942
|
+
"--enabled must be true or false for " + command2,
|
|
18943
|
+
"thesis"
|
|
18944
|
+
);
|
|
18945
|
+
}
|
|
18946
|
+
return parsed;
|
|
18947
|
+
}
|
|
18585
18948
|
function thesisRewriteMode(value) {
|
|
18586
18949
|
if (value === "reformat" || value === "shorten" || value === "enrich") {
|
|
18587
18950
|
return value;
|
|
@@ -18907,6 +19270,28 @@ function thesisTickers(flags) {
|
|
|
18907
19270
|
}
|
|
18908
19271
|
return tickers;
|
|
18909
19272
|
}
|
|
19273
|
+
function thesisMedias(flags) {
|
|
19274
|
+
if (flags.medias === void 0) return void 0;
|
|
19275
|
+
try {
|
|
19276
|
+
const value = JSON.parse(flags.medias);
|
|
19277
|
+
if (Array.isArray(value)) return value;
|
|
19278
|
+
} catch {
|
|
19279
|
+
}
|
|
19280
|
+
throw new CliUsageError("--medias must be a JSON array", "thesis update");
|
|
19281
|
+
}
|
|
19282
|
+
function thesisImages(flags) {
|
|
19283
|
+
if (flags.images === void 0) return void 0;
|
|
19284
|
+
try {
|
|
19285
|
+
const value = JSON.parse(flags.images);
|
|
19286
|
+
if (Array.isArray(value) && value.every((item) => typeof item === "string"))
|
|
19287
|
+
return value;
|
|
19288
|
+
} catch {
|
|
19289
|
+
}
|
|
19290
|
+
throw new CliUsageError(
|
|
19291
|
+
"--images must be a JSON array of uploaded HTTPS image URLs",
|
|
19292
|
+
"thesis"
|
|
19293
|
+
);
|
|
19294
|
+
}
|
|
18910
19295
|
function thesisEntityStances(flags) {
|
|
18911
19296
|
const raw = flags["entity-stances"];
|
|
18912
19297
|
if (raw === void 0) return void 0;
|
|
@@ -19557,12 +19942,13 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19557
19942
|
case "create":
|
|
19558
19943
|
return client.theses.create({
|
|
19559
19944
|
request_id: requireFlag(flags, "request-id", "thesis create"),
|
|
19945
|
+
images: thesisImages(flags),
|
|
19560
19946
|
body: await thesisBodyFromFlags(flags, "thesis create", deps),
|
|
19561
19947
|
title: flags.title ?? "",
|
|
19562
19948
|
entity_ids: thesisEntityIDs(flags),
|
|
19563
19949
|
entity_stances: thesisEntityStances(flags),
|
|
19564
19950
|
tickers: thesisTickers(flags),
|
|
19565
|
-
visibility: flags.visibility === void 0 ? "public" :
|
|
19951
|
+
visibility: flags.visibility === void 0 ? "public" : thesisCreateVisibility(flags.visibility)
|
|
19566
19952
|
});
|
|
19567
19953
|
case "asset-candidates":
|
|
19568
19954
|
return client.theses.assetCandidates(
|
|
@@ -19604,6 +19990,26 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19604
19990
|
case "get":
|
|
19605
19991
|
return client.theses.get(requireFlag(flags, "id", "thesis get"));
|
|
19606
19992
|
case "version":
|
|
19993
|
+
if (parsedCommand.path[2] === "list") {
|
|
19994
|
+
return client.theses.listUpdates(
|
|
19995
|
+
requireFlag(flags, "id", "thesis version list"),
|
|
19996
|
+
{
|
|
19997
|
+
first: flags.first === void 0 ? void 0 : Number(flags.first),
|
|
19998
|
+
cursor: flags.cursor
|
|
19999
|
+
}
|
|
20000
|
+
);
|
|
20001
|
+
}
|
|
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
|
+
}
|
|
19607
20013
|
return client.theses.getVersion(
|
|
19608
20014
|
requireFlag(flags, "id", "thesis version get"),
|
|
19609
20015
|
requireFlag(flags, "author-version-id", "thesis version get")
|
|
@@ -19620,11 +20026,44 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19620
20026
|
return client.theses.setVisibility(
|
|
19621
20027
|
requireFlag(flags, "id", "thesis set-visibility"),
|
|
19622
20028
|
{
|
|
19623
|
-
visibility:
|
|
20029
|
+
visibility: thesisAccessVisibility(
|
|
19624
20030
|
requireFlag(flags, "visibility", "thesis set-visibility")
|
|
19625
20031
|
)
|
|
19626
20032
|
}
|
|
19627
20033
|
);
|
|
20034
|
+
case "archive":
|
|
20035
|
+
return client.theses.setArchived(
|
|
20036
|
+
requireFlag(flags, "id", "thesis archive"),
|
|
20037
|
+
{
|
|
20038
|
+
request_id: requireFlag(flags, "request-id", "thesis archive"),
|
|
20039
|
+
archived: true,
|
|
20040
|
+
note: flags.note
|
|
20041
|
+
}
|
|
20042
|
+
);
|
|
20043
|
+
case "restore":
|
|
20044
|
+
return client.theses.setArchived(
|
|
20045
|
+
requireFlag(flags, "id", "thesis restore"),
|
|
20046
|
+
{
|
|
20047
|
+
request_id: requireFlag(flags, "request-id", "thesis restore"),
|
|
20048
|
+
archived: false,
|
|
20049
|
+
note: flags.note
|
|
20050
|
+
}
|
|
20051
|
+
);
|
|
20052
|
+
case "star":
|
|
20053
|
+
return client.theses.setStarred(
|
|
20054
|
+
requireFlag(flags, "id", "thesis star"),
|
|
20055
|
+
true
|
|
20056
|
+
);
|
|
20057
|
+
case "unstar":
|
|
20058
|
+
return client.theses.setStarred(
|
|
20059
|
+
requireFlag(flags, "id", "thesis unstar"),
|
|
20060
|
+
false
|
|
20061
|
+
);
|
|
20062
|
+
case "set-signal-enabled":
|
|
20063
|
+
return client.theses.setSignalEnabled(
|
|
20064
|
+
requireFlag(flags, "id", "thesis set-signal-enabled"),
|
|
20065
|
+
thesisBooleanFlag(flags.enabled, "thesis set-signal-enabled")
|
|
20066
|
+
);
|
|
19628
20067
|
case "update":
|
|
19629
20068
|
return client.theses.update(
|
|
19630
20069
|
requireFlag(flags, "id", "thesis update"),
|
|
@@ -19639,6 +20078,7 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19639
20078
|
title: flags.title ?? "",
|
|
19640
20079
|
entity_ids: thesisEntityIDs(flags),
|
|
19641
20080
|
entity_stances: thesisEntityStances(flags),
|
|
20081
|
+
medias: thesisMedias(flags),
|
|
19642
20082
|
visibility: thesisVisibility(
|
|
19643
20083
|
requireFlag(flags, "visibility", "thesis update")
|
|
19644
20084
|
),
|