@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/index.js
CHANGED
|
@@ -3972,7 +3972,7 @@ query ToolkitStewardPending($inboxPath: String!, $input: StewardDigestPendingInp
|
|
|
3972
3972
|
stewardDigestPending(inboxPath: $inboxPath, input: $input) {
|
|
3973
3973
|
edges {
|
|
3974
3974
|
cursor
|
|
3975
|
-
node { deliveryId feedEntryId source { kind id } decisionReason consumedAtMs }
|
|
3975
|
+
node { deliveryId feedEntryId source { kind id } decisionReason consumedAtMs alertSnapshot }
|
|
3976
3976
|
}
|
|
3977
3977
|
pageInfo { hasNextPage endCursor }
|
|
3978
3978
|
windowSinceMs
|
|
@@ -4610,6 +4610,18 @@ function notFound() {
|
|
|
4610
4610
|
}
|
|
4611
4611
|
|
|
4612
4612
|
// src/resources/theses.ts
|
|
4613
|
+
var SET_THESIS_STARRED = `mutation SetThesisStarred($input: SetThesisStarredInput!) {
|
|
4614
|
+
setThesisStarred(input: $input) {
|
|
4615
|
+
thesisId
|
|
4616
|
+
stats { starCount }
|
|
4617
|
+
viewerState { isStarred }
|
|
4618
|
+
}
|
|
4619
|
+
}`;
|
|
4620
|
+
var SET_THESIS_SIGNAL_ENABLED = `mutation SetThesisSignalEnabled($input: SetThesisSignalEnabledInput!) {
|
|
4621
|
+
setThesisSignalEnabled(input: $input) {
|
|
4622
|
+
publication { playbookId authorVersionId archived researchPaused }
|
|
4623
|
+
}
|
|
4624
|
+
}`;
|
|
4613
4625
|
var MAX_SIGNED_INT64 = 9223372036854775807n;
|
|
4614
4626
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
4615
4627
|
var UNPAIRED_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
@@ -4686,9 +4698,14 @@ var ThesesResource = class {
|
|
|
4686
4698
|
}
|
|
4687
4699
|
async get(id) {
|
|
4688
4700
|
this.client._requireAuth();
|
|
4689
|
-
|
|
4690
|
-
|
|
4701
|
+
const thesisID = requireID(id, "id");
|
|
4702
|
+
const response = thesisGetResponse(
|
|
4703
|
+
await this.client._request("GET", `/api/v1/theses/${thesisID}`)
|
|
4691
4704
|
);
|
|
4705
|
+
if (response.thesis.id !== thesisID) {
|
|
4706
|
+
throw invalidResponse3("get response must match the requested thesis");
|
|
4707
|
+
}
|
|
4708
|
+
return response;
|
|
4692
4709
|
}
|
|
4693
4710
|
async getVersion(id, authorVersionID) {
|
|
4694
4711
|
this.client._requireAuth();
|
|
@@ -4707,6 +4724,55 @@ var ThesesResource = class {
|
|
|
4707
4724
|
}
|
|
4708
4725
|
return response;
|
|
4709
4726
|
}
|
|
4727
|
+
/** Lists reader-visible Updates, with editorial revisions folded together. */
|
|
4728
|
+
async listUpdates(id, params = {}) {
|
|
4729
|
+
this.client._requireAuth();
|
|
4730
|
+
const thesisID = requireID(id, "id");
|
|
4731
|
+
const first = params.first ?? 10;
|
|
4732
|
+
if (!Number.isInteger(first) || first < 1 || first > 100)
|
|
4733
|
+
throw invalidArgument("first must be between 1 and 100");
|
|
4734
|
+
if (params.cursor !== void 0 && typeof params.cursor !== "string")
|
|
4735
|
+
throw invalidArgument("cursor must be a string");
|
|
4736
|
+
const response = await this.client._request(
|
|
4737
|
+
"GET",
|
|
4738
|
+
`/api/v1/theses/${thesisID}/versions`,
|
|
4739
|
+
{
|
|
4740
|
+
query: { first, cursor: params.cursor, updates_only: true }
|
|
4741
|
+
}
|
|
4742
|
+
);
|
|
4743
|
+
if (!isRecord2(response) || !Array.isArray(response.versions) || typeof response.next_cursor !== "string")
|
|
4744
|
+
throw invalidResponse3("invalid Update list");
|
|
4745
|
+
const versions = response.versions.map(
|
|
4746
|
+
(value) => thesisResponse({ thesis: value }).thesis
|
|
4747
|
+
);
|
|
4748
|
+
if (versions.some((version) => version.id !== thesisID))
|
|
4749
|
+
throw invalidResponse3("Update list must match requested Thesis");
|
|
4750
|
+
return { versions, next_cursor: response.next_cursor };
|
|
4751
|
+
}
|
|
4752
|
+
/** Deletes only the selected Update; never falls back to whole-Thesis deletion. */
|
|
4753
|
+
async deleteUpdate(id, authorVersionID, expectedAuthorVersionID) {
|
|
4754
|
+
this.client._requireAuth();
|
|
4755
|
+
const thesisID = requireID(id, "id");
|
|
4756
|
+
const versionID = requireID(authorVersionID, "author_version_id");
|
|
4757
|
+
const expected = requireID(
|
|
4758
|
+
expectedAuthorVersionID,
|
|
4759
|
+
"expected_author_version_id"
|
|
4760
|
+
);
|
|
4761
|
+
const response = thesisResponse(
|
|
4762
|
+
await this.client._request(
|
|
4763
|
+
"DELETE",
|
|
4764
|
+
`/api/v1/theses/${thesisID}/versions/${versionID}`,
|
|
4765
|
+
{
|
|
4766
|
+
query: { expected_author_version_id: expected }
|
|
4767
|
+
}
|
|
4768
|
+
)
|
|
4769
|
+
);
|
|
4770
|
+
if (response.thesis.id !== thesisID)
|
|
4771
|
+
throw invalidResponse3(
|
|
4772
|
+
"delete Update response must match requested Thesis"
|
|
4773
|
+
);
|
|
4774
|
+
return response;
|
|
4775
|
+
}
|
|
4710
4776
|
async signals(id, params = {}) {
|
|
4711
4777
|
this.client._requireAuth();
|
|
4712
4778
|
const first = params.first ?? 20;
|
|
@@ -4734,15 +4800,132 @@ var ThesesResource = class {
|
|
|
4734
4800
|
async update(id, params) {
|
|
4735
4801
|
this.client._requireAuth();
|
|
4736
4802
|
const body = updateBody(params);
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
)
|
|
4803
|
+
const thesisID = requireID(id, "id");
|
|
4804
|
+
const response = thesisResponse(
|
|
4805
|
+
await this.client._request("PUT", `/api/v1/theses/${thesisID}`, {
|
|
4806
|
+
body
|
|
4807
|
+
})
|
|
4808
|
+
);
|
|
4809
|
+
if (response.thesis.id !== thesisID) {
|
|
4810
|
+
throw invalidResponse3("update response must match the requested thesis");
|
|
4811
|
+
}
|
|
4812
|
+
return response;
|
|
4813
|
+
}
|
|
4814
|
+
/** Archive or restore the current version without asking callers to resend its body. */
|
|
4815
|
+
async setArchived(id, params) {
|
|
4816
|
+
this.client._requireAuth();
|
|
4817
|
+
if (!isRecord2(params)) throw invalidArgument("params is required");
|
|
4818
|
+
const thesisID = requireID(id, "id");
|
|
4819
|
+
const requestID = requireRequestID(params.request_id);
|
|
4820
|
+
if (typeof params.archived !== "boolean") {
|
|
4821
|
+
throw invalidArgument("archived must be a boolean");
|
|
4822
|
+
}
|
|
4823
|
+
if (params.note !== void 0) requireText2(params.note, "note");
|
|
4824
|
+
const current = await this.get(thesisID);
|
|
4825
|
+
if (current.thesis.archived === params.archived && params.note === void 0) {
|
|
4826
|
+
return { thesis: current.thesis };
|
|
4827
|
+
}
|
|
4828
|
+
if (!completeEntityStances(
|
|
4829
|
+
current.thesis.entity_ids,
|
|
4830
|
+
current.thesis.entity_stances
|
|
4831
|
+
)) {
|
|
4832
|
+
throw invalidResponse3(
|
|
4833
|
+
"archive requires one entity_stance for every Thesis entity"
|
|
4834
|
+
);
|
|
4835
|
+
}
|
|
4836
|
+
const response = await this.update(thesisID, {
|
|
4837
|
+
request_id: requestID,
|
|
4838
|
+
expected_author_version_id: current.thesis.author_version_id,
|
|
4839
|
+
body: current.thesis.body,
|
|
4840
|
+
title: current.thesis.title,
|
|
4841
|
+
entity_ids: current.thesis.entity_ids,
|
|
4842
|
+
entity_stances: current.thesis.entity_stances,
|
|
4843
|
+
visibility: current.thesis.visibility,
|
|
4844
|
+
archived: params.archived,
|
|
4845
|
+
medias: current.thesis.medias,
|
|
4846
|
+
note: params.note
|
|
4847
|
+
});
|
|
4848
|
+
if (response.thesis.id !== thesisID || response.thesis.archived !== params.archived) {
|
|
4849
|
+
throw invalidResponse3("archive response must match the requested state");
|
|
4850
|
+
}
|
|
4851
|
+
return response;
|
|
4852
|
+
}
|
|
4853
|
+
async setStarred(id, isStarred) {
|
|
4854
|
+
this.client._requireAuth();
|
|
4855
|
+
const thesisID = requireID(id, "id");
|
|
4856
|
+
if (typeof isStarred !== "boolean") {
|
|
4857
|
+
throw invalidArgument("isStarred must be a boolean");
|
|
4858
|
+
}
|
|
4859
|
+
const data = await thesisGraphql(this.client, SET_THESIS_STARRED, {
|
|
4860
|
+
input: { thesisId: thesisID, isStarred }
|
|
4861
|
+
});
|
|
4862
|
+
const result = data.setThesisStarred;
|
|
4863
|
+
if (!isRecord2(result) || !isRecord2(result.stats) || !isRecord2(result.viewerState)) {
|
|
4864
|
+
throw invalidResponse3("star response must contain stats and viewerState");
|
|
4865
|
+
}
|
|
4866
|
+
const returnedID = responseID(result.thesisId, "thesisId");
|
|
4867
|
+
if (returnedID !== thesisID) {
|
|
4868
|
+
throw invalidResponse3("star response must match the requested thesis");
|
|
4869
|
+
}
|
|
4870
|
+
const starCount = result.stats.starCount;
|
|
4871
|
+
if (typeof starCount !== "number" || !Number.isInteger(starCount) || starCount < 0) {
|
|
4872
|
+
throw invalidResponse3(
|
|
4873
|
+
"star response must contain a nonnegative star count"
|
|
4874
|
+
);
|
|
4875
|
+
}
|
|
4876
|
+
const returnedStarred = responseBoolean(
|
|
4877
|
+
result.viewerState.isStarred,
|
|
4878
|
+
"viewerState.isStarred"
|
|
4879
|
+
);
|
|
4880
|
+
if (returnedStarred !== isStarred) {
|
|
4881
|
+
throw invalidResponse3("star response did not apply the requested state");
|
|
4882
|
+
}
|
|
4883
|
+
return {
|
|
4884
|
+
thesis_id: returnedID,
|
|
4885
|
+
star_count: starCount,
|
|
4886
|
+
is_starred: returnedStarred
|
|
4887
|
+
};
|
|
4888
|
+
}
|
|
4889
|
+
async setSignalEnabled(id, enabled) {
|
|
4890
|
+
this.client._requireAuth();
|
|
4891
|
+
const thesisID = requireID(id, "id");
|
|
4892
|
+
if (typeof enabled !== "boolean") {
|
|
4893
|
+
throw invalidArgument("enabled must be a boolean");
|
|
4894
|
+
}
|
|
4895
|
+
const data = await thesisGraphql(this.client, SET_THESIS_SIGNAL_ENABLED, {
|
|
4896
|
+
input: { thesisId: thesisID, enabled }
|
|
4897
|
+
});
|
|
4898
|
+
const result = data.setThesisSignalEnabled;
|
|
4899
|
+
if (!isRecord2(result) || !isRecord2(result.publication)) {
|
|
4900
|
+
throw invalidResponse3("Signal response must contain publication");
|
|
4901
|
+
}
|
|
4902
|
+
const publication = result.publication;
|
|
4903
|
+
const returnedID = responseID(
|
|
4904
|
+
publication.playbookId,
|
|
4905
|
+
"publication.playbookId"
|
|
4745
4906
|
);
|
|
4907
|
+
if (returnedID !== thesisID) {
|
|
4908
|
+
throw invalidResponse3("Signal response must match the requested thesis");
|
|
4909
|
+
}
|
|
4910
|
+
const researchPaused = responseBoolean(
|
|
4911
|
+
publication.researchPaused,
|
|
4912
|
+
"publication.researchPaused"
|
|
4913
|
+
);
|
|
4914
|
+
if (researchPaused === enabled) {
|
|
4915
|
+
throw invalidResponse3(
|
|
4916
|
+
"Signal response did not apply the requested state"
|
|
4917
|
+
);
|
|
4918
|
+
}
|
|
4919
|
+
return {
|
|
4920
|
+
thesis_id: returnedID,
|
|
4921
|
+
author_version_id: responseID(
|
|
4922
|
+
publication.authorVersionId,
|
|
4923
|
+
"publication.authorVersionId"
|
|
4924
|
+
),
|
|
4925
|
+
archived: responseBoolean(publication.archived, "publication.archived"),
|
|
4926
|
+
research_paused: researchPaused,
|
|
4927
|
+
enabled: !researchPaused
|
|
4928
|
+
};
|
|
4746
4929
|
}
|
|
4747
4930
|
async setVisibility(id, params) {
|
|
4748
4931
|
this.client._requireAuth();
|
|
@@ -4750,7 +4933,7 @@ var ThesesResource = class {
|
|
|
4750
4933
|
throw invalidArgument("params is required");
|
|
4751
4934
|
}
|
|
4752
4935
|
const thesisID = requireID(id, "id");
|
|
4753
|
-
const visibility =
|
|
4936
|
+
const visibility = requirePublicVisibility(params.visibility);
|
|
4754
4937
|
const response = thesisResponse(
|
|
4755
4938
|
await this.client._request(
|
|
4756
4939
|
"POST",
|
|
@@ -4817,8 +5000,23 @@ function createBody(params) {
|
|
|
4817
5000
|
body: requireBody(params.body),
|
|
4818
5001
|
title: requireTitle(params.title ?? ""),
|
|
4819
5002
|
entity_ids: requireIDs(params.entity_ids ?? [], "entity_ids"),
|
|
4820
|
-
visibility:
|
|
5003
|
+
visibility: requirePublicVisibility(params.visibility ?? "public")
|
|
4821
5004
|
};
|
|
5005
|
+
if (params.images !== void 0) {
|
|
5006
|
+
if (!Array.isArray(params.images) || params.images.length > 20)
|
|
5007
|
+
throw invalidArgument("images must contain at most 20 URLs");
|
|
5008
|
+
if (params.images.length && body.visibility !== "public")
|
|
5009
|
+
throw invalidArgument(
|
|
5010
|
+
"image publication currently requires public visibility"
|
|
5011
|
+
);
|
|
5012
|
+
body.medias = params.images.map((url) => {
|
|
5013
|
+
if (!validMediaURL(url) || !url.startsWith("https://"))
|
|
5014
|
+
throw invalidArgument(
|
|
5015
|
+
"images must contain HTTPS URLs returned by the upload tool"
|
|
5016
|
+
);
|
|
5017
|
+
return { type: "image", cover_url: url, url };
|
|
5018
|
+
});
|
|
5019
|
+
}
|
|
4822
5020
|
if (params.tickers !== void 0)
|
|
4823
5021
|
body.tickers = requireTickers(params.tickers);
|
|
4824
5022
|
if (params.entity_stances !== void 0) {
|
|
@@ -4864,6 +5062,19 @@ function updateBody(params) {
|
|
|
4864
5062
|
visibility: requireVisibility(params.visibility),
|
|
4865
5063
|
editorial: params.editorial ?? false
|
|
4866
5064
|
};
|
|
5065
|
+
if (params.medias !== void 0) {
|
|
5066
|
+
if (!Array.isArray(params.medias) || params.medias.length > 20)
|
|
5067
|
+
throw invalidArgument("medias must be an array of at most 20 items");
|
|
5068
|
+
if (!params.medias.every(validMedia))
|
|
5069
|
+
throw invalidArgument("medias contains invalid media");
|
|
5070
|
+
body.medias = params.medias;
|
|
5071
|
+
}
|
|
5072
|
+
if (params.archived !== void 0) {
|
|
5073
|
+
if (typeof params.archived !== "boolean")
|
|
5074
|
+
throw invalidArgument("archived must be a boolean");
|
|
5075
|
+
body.archived = params.archived;
|
|
5076
|
+
}
|
|
5077
|
+
if (params.note !== void 0) body.note = requireText2(params.note, "note");
|
|
4867
5078
|
if (params.entity_stances !== void 0) {
|
|
4868
5079
|
body.entity_stances = requireEntityStances(
|
|
4869
5080
|
params.entity_stances,
|
|
@@ -4892,10 +5103,31 @@ function thesisResponse(response) {
|
|
|
4892
5103
|
entity_ids: responseIDs(thesis.entity_ids, "thesis.entity_ids"),
|
|
4893
5104
|
visibility: responseVisibility(thesis.visibility),
|
|
4894
5105
|
closed: responseBoolean(thesis.closed, "thesis.closed"),
|
|
5106
|
+
archived: responseBoolean(thesis.archived, "thesis.archived"),
|
|
4895
5107
|
closing_note: responseClosingNote(thesis.closing_note),
|
|
4896
5108
|
author_kind: responseText(thesis.author_kind, "thesis.author_kind"),
|
|
4897
5109
|
author_ref: responseText(thesis.author_ref, "thesis.author_ref")
|
|
4898
5110
|
};
|
|
5111
|
+
if (thesis.medias !== void 0) {
|
|
5112
|
+
if (!Array.isArray(thesis.medias) || thesis.medias.length > 20)
|
|
5113
|
+
throw invalidResponse3("thesis.medias must contain at most 20 items");
|
|
5114
|
+
value.medias = thesis.medias.map((item) => {
|
|
5115
|
+
if (!validMedia(item))
|
|
5116
|
+
throw invalidResponse3("thesis.medias contains invalid media");
|
|
5117
|
+
return {
|
|
5118
|
+
type: item.type,
|
|
5119
|
+
cover_url: item.cover_url,
|
|
5120
|
+
...item.url === void 0 ? {} : { url: item.url }
|
|
5121
|
+
};
|
|
5122
|
+
});
|
|
5123
|
+
}
|
|
5124
|
+
if (thesis.version_archived !== void 0)
|
|
5125
|
+
value.version_archived = responseBoolean(
|
|
5126
|
+
thesis.version_archived,
|
|
5127
|
+
"thesis.version_archived"
|
|
5128
|
+
);
|
|
5129
|
+
if (thesis.note !== void 0)
|
|
5130
|
+
value.note = responseText(thesis.note, "thesis.note");
|
|
4899
5131
|
if (thesis.entity_stances !== void 0) {
|
|
4900
5132
|
if (!Array.isArray(thesis.entity_stances))
|
|
4901
5133
|
throw invalidResponse3("thesis.entity_stances must be an array");
|
|
@@ -5112,6 +5344,13 @@ function requireTitle(value) {
|
|
|
5112
5344
|
return title;
|
|
5113
5345
|
}
|
|
5114
5346
|
function requireVisibility(value) {
|
|
5347
|
+
const visibility = requireText2(value, "visibility");
|
|
5348
|
+
if (visibility !== "public" && visibility !== "private" && visibility !== "paid") {
|
|
5349
|
+
throw invalidArgument("visibility must be public, private or paid");
|
|
5350
|
+
}
|
|
5351
|
+
return visibility;
|
|
5352
|
+
}
|
|
5353
|
+
function requirePublicVisibility(value) {
|
|
5115
5354
|
const visibility = requireText2(value, "visibility");
|
|
5116
5355
|
if (visibility !== "public" && visibility !== "private") {
|
|
5117
5356
|
throw invalidArgument("visibility must be public or private");
|
|
@@ -5180,7 +5419,7 @@ function responseVisibility(value) {
|
|
|
5180
5419
|
try {
|
|
5181
5420
|
return requireVisibility(value);
|
|
5182
5421
|
} catch {
|
|
5183
|
-
throw invalidResponse3("thesis.visibility must be public or
|
|
5422
|
+
throw invalidResponse3("thesis.visibility must be public, private or paid");
|
|
5184
5423
|
}
|
|
5185
5424
|
}
|
|
5186
5425
|
function responseBody(value) {
|
|
@@ -5204,12 +5443,67 @@ function responseTitle(value) {
|
|
|
5204
5443
|
function isRecord2(value) {
|
|
5205
5444
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5206
5445
|
}
|
|
5446
|
+
function completeEntityStances(entityIDs, stances) {
|
|
5447
|
+
if (entityIDs.length === 0) return !stances || stances.length === 0;
|
|
5448
|
+
if (!stances || stances.length !== entityIDs.length) return false;
|
|
5449
|
+
const expected = new Set(entityIDs);
|
|
5450
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5451
|
+
return stances.every(
|
|
5452
|
+
(stance) => expected.has(stance.entity_id) && !seen.has(stance.entity_id) && seen.add(stance.entity_id)
|
|
5453
|
+
);
|
|
5454
|
+
}
|
|
5207
5455
|
function invalidArgument(message) {
|
|
5208
5456
|
return new AlvaError("INVALID_ARGUMENT", message, 400);
|
|
5209
5457
|
}
|
|
5210
5458
|
function invalidResponse3(message) {
|
|
5211
5459
|
return new AlvaError("INVALID_RESPONSE", message, 502);
|
|
5212
5460
|
}
|
|
5461
|
+
function validMedia(item) {
|
|
5462
|
+
return isRecord2(item) && ["image", "price_chart", "audio", "video"].includes(item.type) && validMediaURL(item.cover_url) && (item.url == null || validMediaURL(item.url));
|
|
5463
|
+
}
|
|
5464
|
+
function validMediaURL(value) {
|
|
5465
|
+
if (typeof value !== "string" || value.length > 2048 || /[\s\u0000]/.test(value))
|
|
5466
|
+
return false;
|
|
5467
|
+
try {
|
|
5468
|
+
const url = new URL(value);
|
|
5469
|
+
return ["http:", "https:"].includes(url.protocol) && !!url.hostname && !url.username && !url.password;
|
|
5470
|
+
} catch {
|
|
5471
|
+
return false;
|
|
5472
|
+
}
|
|
5473
|
+
}
|
|
5474
|
+
async function thesisGraphql(client, query, variables) {
|
|
5475
|
+
const response = await client._request("POST", "/query", {
|
|
5476
|
+
body: { query, variables }
|
|
5477
|
+
});
|
|
5478
|
+
if (!isRecord2(response))
|
|
5479
|
+
throw invalidResponse3("GraphQL response must be an object");
|
|
5480
|
+
if (response.errors !== void 0) {
|
|
5481
|
+
if (!Array.isArray(response.errors))
|
|
5482
|
+
throw invalidResponse3("GraphQL errors must be an array");
|
|
5483
|
+
if (response.errors.length > 0) {
|
|
5484
|
+
const messages = response.errors.flatMap(
|
|
5485
|
+
(error) => isRecord2(error) && typeof error.message === "string" ? [error.message] : []
|
|
5486
|
+
);
|
|
5487
|
+
const codes = new Set(
|
|
5488
|
+
response.errors.map(
|
|
5489
|
+
(error) => isRecord2(error) && isRecord2(error.extensions) ? error.extensions.code : void 0
|
|
5490
|
+
)
|
|
5491
|
+
);
|
|
5492
|
+
const [code] = codes;
|
|
5493
|
+
const canonicalCode = codes.size === 1 && (code === "NOT_FOUND" || code === "PERMISSION_DENIED" || code === "UNAUTHENTICATED") ? code : void 0;
|
|
5494
|
+
const status = canonicalCode === "NOT_FOUND" ? 404 : canonicalCode === "PERMISSION_DENIED" ? 403 : canonicalCode === "UNAUTHENTICATED" ? 401 : 400;
|
|
5495
|
+
throw new AlvaError(
|
|
5496
|
+
canonicalCode ?? "GRAPHQL_ERROR",
|
|
5497
|
+
messages.join("; ") || "GraphQL request failed",
|
|
5498
|
+
status,
|
|
5499
|
+
{ errors: response.errors }
|
|
5500
|
+
);
|
|
5501
|
+
}
|
|
5502
|
+
}
|
|
5503
|
+
if (!isRecord2(response.data))
|
|
5504
|
+
throw invalidResponse3("GraphQL response must contain data");
|
|
5505
|
+
return response.data;
|
|
5506
|
+
}
|
|
5213
5507
|
|
|
5214
5508
|
// src/resources/companyNews.ts
|
|
5215
5509
|
var CREATE_COMPANY_NEWS = `mutation CreateCompanyNews($input: CompanyNewsFeedInput!) {
|
|
@@ -6155,7 +6449,7 @@ var installPlaybookRuntime = (targetWindow) => {
|
|
|
6155
6449
|
};
|
|
6156
6450
|
|
|
6157
6451
|
// src/index.ts
|
|
6158
|
-
var VERSION = true ? "0.
|
|
6452
|
+
var VERSION = true ? "0.34.0" : "dev";
|
|
6159
6453
|
export {
|
|
6160
6454
|
AlertsResource,
|
|
6161
6455
|
AlvaClient,
|