@alva-ai/toolkit 0.33.1-beta.0 → 0.34.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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.cjs
CHANGED
|
@@ -4039,7 +4039,7 @@ query ToolkitStewardPending($inboxPath: String!, $input: StewardDigestPendingInp
|
|
|
4039
4039
|
stewardDigestPending(inboxPath: $inboxPath, input: $input) {
|
|
4040
4040
|
edges {
|
|
4041
4041
|
cursor
|
|
4042
|
-
node { deliveryId feedEntryId source { kind id } decisionReason consumedAtMs }
|
|
4042
|
+
node { deliveryId feedEntryId source { kind id } decisionReason consumedAtMs alertSnapshot }
|
|
4043
4043
|
}
|
|
4044
4044
|
pageInfo { hasNextPage endCursor }
|
|
4045
4045
|
windowSinceMs
|
|
@@ -4677,6 +4677,18 @@ function notFound() {
|
|
|
4677
4677
|
}
|
|
4678
4678
|
|
|
4679
4679
|
// src/resources/theses.ts
|
|
4680
|
+
var SET_THESIS_STARRED = `mutation SetThesisStarred($input: SetThesisStarredInput!) {
|
|
4681
|
+
setThesisStarred(input: $input) {
|
|
4682
|
+
thesisId
|
|
4683
|
+
stats { starCount }
|
|
4684
|
+
viewerState { isStarred }
|
|
4685
|
+
}
|
|
4686
|
+
}`;
|
|
4687
|
+
var SET_THESIS_SIGNAL_ENABLED = `mutation SetThesisSignalEnabled($input: SetThesisSignalEnabledInput!) {
|
|
4688
|
+
setThesisSignalEnabled(input: $input) {
|
|
4689
|
+
publication { playbookId authorVersionId archived researchPaused }
|
|
4690
|
+
}
|
|
4691
|
+
}`;
|
|
4680
4692
|
var MAX_SIGNED_INT64 = 9223372036854775807n;
|
|
4681
4693
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
4682
4694
|
var UNPAIRED_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
@@ -4753,9 +4765,14 @@ var ThesesResource = class {
|
|
|
4753
4765
|
}
|
|
4754
4766
|
async get(id) {
|
|
4755
4767
|
this.client._requireAuth();
|
|
4756
|
-
|
|
4757
|
-
|
|
4768
|
+
const thesisID = requireID(id, "id");
|
|
4769
|
+
const response = thesisGetResponse(
|
|
4770
|
+
await this.client._request("GET", `/api/v1/theses/${thesisID}`)
|
|
4758
4771
|
);
|
|
4772
|
+
if (response.thesis.id !== thesisID) {
|
|
4773
|
+
throw invalidResponse3("get response must match the requested thesis");
|
|
4774
|
+
}
|
|
4775
|
+
return response;
|
|
4759
4776
|
}
|
|
4760
4777
|
async getVersion(id, authorVersionID) {
|
|
4761
4778
|
this.client._requireAuth();
|
|
@@ -4774,6 +4791,55 @@ var ThesesResource = class {
|
|
|
4774
4791
|
}
|
|
4775
4792
|
return response;
|
|
4776
4793
|
}
|
|
4794
|
+
/** Lists reader-visible Updates, with editorial revisions folded together. */
|
|
4795
|
+
async listUpdates(id, params = {}) {
|
|
4796
|
+
this.client._requireAuth();
|
|
4797
|
+
const thesisID = requireID(id, "id");
|
|
4798
|
+
const first = params.first ?? 10;
|
|
4799
|
+
if (!Number.isInteger(first) || first < 1 || first > 100)
|
|
4800
|
+
throw invalidArgument("first must be between 1 and 100");
|
|
4801
|
+
if (params.cursor !== void 0 && typeof params.cursor !== "string")
|
|
4802
|
+
throw invalidArgument("cursor must be a string");
|
|
4803
|
+
const response = await this.client._request(
|
|
4804
|
+
"GET",
|
|
4805
|
+
`/api/v1/theses/${thesisID}/versions`,
|
|
4806
|
+
{
|
|
4807
|
+
query: { first, cursor: params.cursor, updates_only: true }
|
|
4808
|
+
}
|
|
4809
|
+
);
|
|
4810
|
+
if (!isRecord2(response) || !Array.isArray(response.versions) || typeof response.next_cursor !== "string")
|
|
4811
|
+
throw invalidResponse3("invalid Update list");
|
|
4812
|
+
const versions = response.versions.map(
|
|
4813
|
+
(value) => thesisResponse({ thesis: value }).thesis
|
|
4814
|
+
);
|
|
4815
|
+
if (versions.some((version) => version.id !== thesisID))
|
|
4816
|
+
throw invalidResponse3("Update list must match requested Thesis");
|
|
4817
|
+
return { versions, next_cursor: response.next_cursor };
|
|
4818
|
+
}
|
|
4819
|
+
/** Deletes only the selected Update; never falls back to whole-Thesis deletion. */
|
|
4820
|
+
async deleteUpdate(id, authorVersionID, expectedAuthorVersionID) {
|
|
4821
|
+
this.client._requireAuth();
|
|
4822
|
+
const thesisID = requireID(id, "id");
|
|
4823
|
+
const versionID = requireID(authorVersionID, "author_version_id");
|
|
4824
|
+
const expected = requireID(
|
|
4825
|
+
expectedAuthorVersionID,
|
|
4826
|
+
"expected_author_version_id"
|
|
4827
|
+
);
|
|
4828
|
+
const response = thesisResponse(
|
|
4829
|
+
await this.client._request(
|
|
4830
|
+
"DELETE",
|
|
4831
|
+
`/api/v1/theses/${thesisID}/versions/${versionID}`,
|
|
4832
|
+
{
|
|
4833
|
+
query: { expected_author_version_id: expected }
|
|
4834
|
+
}
|
|
4835
|
+
)
|
|
4836
|
+
);
|
|
4837
|
+
if (response.thesis.id !== thesisID)
|
|
4838
|
+
throw invalidResponse3(
|
|
4839
|
+
"delete Update response must match requested Thesis"
|
|
4840
|
+
);
|
|
4841
|
+
return response;
|
|
4842
|
+
}
|
|
4777
4843
|
async signals(id, params = {}) {
|
|
4778
4844
|
this.client._requireAuth();
|
|
4779
4845
|
const first = params.first ?? 20;
|
|
@@ -4801,15 +4867,132 @@ var ThesesResource = class {
|
|
|
4801
4867
|
async update(id, params) {
|
|
4802
4868
|
this.client._requireAuth();
|
|
4803
4869
|
const body = updateBody(params);
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
)
|
|
4870
|
+
const thesisID = requireID(id, "id");
|
|
4871
|
+
const response = thesisResponse(
|
|
4872
|
+
await this.client._request("PUT", `/api/v1/theses/${thesisID}`, {
|
|
4873
|
+
body
|
|
4874
|
+
})
|
|
4875
|
+
);
|
|
4876
|
+
if (response.thesis.id !== thesisID) {
|
|
4877
|
+
throw invalidResponse3("update response must match the requested thesis");
|
|
4878
|
+
}
|
|
4879
|
+
return response;
|
|
4880
|
+
}
|
|
4881
|
+
/** Archive or restore the current version without asking callers to resend its body. */
|
|
4882
|
+
async setArchived(id, params) {
|
|
4883
|
+
this.client._requireAuth();
|
|
4884
|
+
if (!isRecord2(params)) throw invalidArgument("params is required");
|
|
4885
|
+
const thesisID = requireID(id, "id");
|
|
4886
|
+
const requestID = requireRequestID(params.request_id);
|
|
4887
|
+
if (typeof params.archived !== "boolean") {
|
|
4888
|
+
throw invalidArgument("archived must be a boolean");
|
|
4889
|
+
}
|
|
4890
|
+
if (params.note !== void 0) requireText2(params.note, "note");
|
|
4891
|
+
const current = await this.get(thesisID);
|
|
4892
|
+
if (current.thesis.archived === params.archived && params.note === void 0) {
|
|
4893
|
+
return { thesis: current.thesis };
|
|
4894
|
+
}
|
|
4895
|
+
if (!completeEntityStances(
|
|
4896
|
+
current.thesis.entity_ids,
|
|
4897
|
+
current.thesis.entity_stances
|
|
4898
|
+
)) {
|
|
4899
|
+
throw invalidResponse3(
|
|
4900
|
+
"archive requires one entity_stance for every Thesis entity"
|
|
4901
|
+
);
|
|
4902
|
+
}
|
|
4903
|
+
const response = await this.update(thesisID, {
|
|
4904
|
+
request_id: requestID,
|
|
4905
|
+
expected_author_version_id: current.thesis.author_version_id,
|
|
4906
|
+
body: current.thesis.body,
|
|
4907
|
+
title: current.thesis.title,
|
|
4908
|
+
entity_ids: current.thesis.entity_ids,
|
|
4909
|
+
entity_stances: current.thesis.entity_stances,
|
|
4910
|
+
visibility: current.thesis.visibility,
|
|
4911
|
+
archived: params.archived,
|
|
4912
|
+
medias: current.thesis.medias,
|
|
4913
|
+
note: params.note
|
|
4914
|
+
});
|
|
4915
|
+
if (response.thesis.id !== thesisID || response.thesis.archived !== params.archived) {
|
|
4916
|
+
throw invalidResponse3("archive response must match the requested state");
|
|
4917
|
+
}
|
|
4918
|
+
return response;
|
|
4919
|
+
}
|
|
4920
|
+
async setStarred(id, isStarred) {
|
|
4921
|
+
this.client._requireAuth();
|
|
4922
|
+
const thesisID = requireID(id, "id");
|
|
4923
|
+
if (typeof isStarred !== "boolean") {
|
|
4924
|
+
throw invalidArgument("isStarred must be a boolean");
|
|
4925
|
+
}
|
|
4926
|
+
const data = await thesisGraphql(this.client, SET_THESIS_STARRED, {
|
|
4927
|
+
input: { thesisId: thesisID, isStarred }
|
|
4928
|
+
});
|
|
4929
|
+
const result = data.setThesisStarred;
|
|
4930
|
+
if (!isRecord2(result) || !isRecord2(result.stats) || !isRecord2(result.viewerState)) {
|
|
4931
|
+
throw invalidResponse3("star response must contain stats and viewerState");
|
|
4932
|
+
}
|
|
4933
|
+
const returnedID = responseID(result.thesisId, "thesisId");
|
|
4934
|
+
if (returnedID !== thesisID) {
|
|
4935
|
+
throw invalidResponse3("star response must match the requested thesis");
|
|
4936
|
+
}
|
|
4937
|
+
const starCount = result.stats.starCount;
|
|
4938
|
+
if (typeof starCount !== "number" || !Number.isInteger(starCount) || starCount < 0) {
|
|
4939
|
+
throw invalidResponse3(
|
|
4940
|
+
"star response must contain a nonnegative star count"
|
|
4941
|
+
);
|
|
4942
|
+
}
|
|
4943
|
+
const returnedStarred = responseBoolean(
|
|
4944
|
+
result.viewerState.isStarred,
|
|
4945
|
+
"viewerState.isStarred"
|
|
4946
|
+
);
|
|
4947
|
+
if (returnedStarred !== isStarred) {
|
|
4948
|
+
throw invalidResponse3("star response did not apply the requested state");
|
|
4949
|
+
}
|
|
4950
|
+
return {
|
|
4951
|
+
thesis_id: returnedID,
|
|
4952
|
+
star_count: starCount,
|
|
4953
|
+
is_starred: returnedStarred
|
|
4954
|
+
};
|
|
4955
|
+
}
|
|
4956
|
+
async setSignalEnabled(id, enabled) {
|
|
4957
|
+
this.client._requireAuth();
|
|
4958
|
+
const thesisID = requireID(id, "id");
|
|
4959
|
+
if (typeof enabled !== "boolean") {
|
|
4960
|
+
throw invalidArgument("enabled must be a boolean");
|
|
4961
|
+
}
|
|
4962
|
+
const data = await thesisGraphql(this.client, SET_THESIS_SIGNAL_ENABLED, {
|
|
4963
|
+
input: { thesisId: thesisID, enabled }
|
|
4964
|
+
});
|
|
4965
|
+
const result = data.setThesisSignalEnabled;
|
|
4966
|
+
if (!isRecord2(result) || !isRecord2(result.publication)) {
|
|
4967
|
+
throw invalidResponse3("Signal response must contain publication");
|
|
4968
|
+
}
|
|
4969
|
+
const publication = result.publication;
|
|
4970
|
+
const returnedID = responseID(
|
|
4971
|
+
publication.playbookId,
|
|
4972
|
+
"publication.playbookId"
|
|
4812
4973
|
);
|
|
4974
|
+
if (returnedID !== thesisID) {
|
|
4975
|
+
throw invalidResponse3("Signal response must match the requested thesis");
|
|
4976
|
+
}
|
|
4977
|
+
const researchPaused = responseBoolean(
|
|
4978
|
+
publication.researchPaused,
|
|
4979
|
+
"publication.researchPaused"
|
|
4980
|
+
);
|
|
4981
|
+
if (researchPaused === enabled) {
|
|
4982
|
+
throw invalidResponse3(
|
|
4983
|
+
"Signal response did not apply the requested state"
|
|
4984
|
+
);
|
|
4985
|
+
}
|
|
4986
|
+
return {
|
|
4987
|
+
thesis_id: returnedID,
|
|
4988
|
+
author_version_id: responseID(
|
|
4989
|
+
publication.authorVersionId,
|
|
4990
|
+
"publication.authorVersionId"
|
|
4991
|
+
),
|
|
4992
|
+
archived: responseBoolean(publication.archived, "publication.archived"),
|
|
4993
|
+
research_paused: researchPaused,
|
|
4994
|
+
enabled: !researchPaused
|
|
4995
|
+
};
|
|
4813
4996
|
}
|
|
4814
4997
|
async setVisibility(id, params) {
|
|
4815
4998
|
this.client._requireAuth();
|
|
@@ -4817,7 +5000,7 @@ var ThesesResource = class {
|
|
|
4817
5000
|
throw invalidArgument("params is required");
|
|
4818
5001
|
}
|
|
4819
5002
|
const thesisID = requireID(id, "id");
|
|
4820
|
-
const visibility =
|
|
5003
|
+
const visibility = requirePublicVisibility(params.visibility);
|
|
4821
5004
|
const response = thesisResponse(
|
|
4822
5005
|
await this.client._request(
|
|
4823
5006
|
"POST",
|
|
@@ -4884,8 +5067,23 @@ function createBody(params) {
|
|
|
4884
5067
|
body: requireBody(params.body),
|
|
4885
5068
|
title: requireTitle(params.title ?? ""),
|
|
4886
5069
|
entity_ids: requireIDs(params.entity_ids ?? [], "entity_ids"),
|
|
4887
|
-
visibility:
|
|
5070
|
+
visibility: requirePublicVisibility(params.visibility ?? "public")
|
|
4888
5071
|
};
|
|
5072
|
+
if (params.images !== void 0) {
|
|
5073
|
+
if (!Array.isArray(params.images) || params.images.length > 20)
|
|
5074
|
+
throw invalidArgument("images must contain at most 20 URLs");
|
|
5075
|
+
if (params.images.length && body.visibility !== "public")
|
|
5076
|
+
throw invalidArgument(
|
|
5077
|
+
"image publication currently requires public visibility"
|
|
5078
|
+
);
|
|
5079
|
+
body.medias = params.images.map((url) => {
|
|
5080
|
+
if (!validMediaURL(url) || !url.startsWith("https://"))
|
|
5081
|
+
throw invalidArgument(
|
|
5082
|
+
"images must contain HTTPS URLs returned by the upload tool"
|
|
5083
|
+
);
|
|
5084
|
+
return { type: "image", cover_url: url, url };
|
|
5085
|
+
});
|
|
5086
|
+
}
|
|
4889
5087
|
if (params.tickers !== void 0)
|
|
4890
5088
|
body.tickers = requireTickers(params.tickers);
|
|
4891
5089
|
if (params.entity_stances !== void 0) {
|
|
@@ -4931,6 +5129,19 @@ function updateBody(params) {
|
|
|
4931
5129
|
visibility: requireVisibility(params.visibility),
|
|
4932
5130
|
editorial: params.editorial ?? false
|
|
4933
5131
|
};
|
|
5132
|
+
if (params.medias !== void 0) {
|
|
5133
|
+
if (!Array.isArray(params.medias) || params.medias.length > 20)
|
|
5134
|
+
throw invalidArgument("medias must be an array of at most 20 items");
|
|
5135
|
+
if (!params.medias.every(validMedia))
|
|
5136
|
+
throw invalidArgument("medias contains invalid media");
|
|
5137
|
+
body.medias = params.medias;
|
|
5138
|
+
}
|
|
5139
|
+
if (params.archived !== void 0) {
|
|
5140
|
+
if (typeof params.archived !== "boolean")
|
|
5141
|
+
throw invalidArgument("archived must be a boolean");
|
|
5142
|
+
body.archived = params.archived;
|
|
5143
|
+
}
|
|
5144
|
+
if (params.note !== void 0) body.note = requireText2(params.note, "note");
|
|
4934
5145
|
if (params.entity_stances !== void 0) {
|
|
4935
5146
|
body.entity_stances = requireEntityStances(
|
|
4936
5147
|
params.entity_stances,
|
|
@@ -4959,10 +5170,31 @@ function thesisResponse(response) {
|
|
|
4959
5170
|
entity_ids: responseIDs(thesis.entity_ids, "thesis.entity_ids"),
|
|
4960
5171
|
visibility: responseVisibility(thesis.visibility),
|
|
4961
5172
|
closed: responseBoolean(thesis.closed, "thesis.closed"),
|
|
5173
|
+
archived: responseBoolean(thesis.archived, "thesis.archived"),
|
|
4962
5174
|
closing_note: responseClosingNote(thesis.closing_note),
|
|
4963
5175
|
author_kind: responseText(thesis.author_kind, "thesis.author_kind"),
|
|
4964
5176
|
author_ref: responseText(thesis.author_ref, "thesis.author_ref")
|
|
4965
5177
|
};
|
|
5178
|
+
if (thesis.medias !== void 0) {
|
|
5179
|
+
if (!Array.isArray(thesis.medias) || thesis.medias.length > 20)
|
|
5180
|
+
throw invalidResponse3("thesis.medias must contain at most 20 items");
|
|
5181
|
+
value.medias = thesis.medias.map((item) => {
|
|
5182
|
+
if (!validMedia(item))
|
|
5183
|
+
throw invalidResponse3("thesis.medias contains invalid media");
|
|
5184
|
+
return {
|
|
5185
|
+
type: item.type,
|
|
5186
|
+
cover_url: item.cover_url,
|
|
5187
|
+
...item.url === void 0 ? {} : { url: item.url }
|
|
5188
|
+
};
|
|
5189
|
+
});
|
|
5190
|
+
}
|
|
5191
|
+
if (thesis.version_archived !== void 0)
|
|
5192
|
+
value.version_archived = responseBoolean(
|
|
5193
|
+
thesis.version_archived,
|
|
5194
|
+
"thesis.version_archived"
|
|
5195
|
+
);
|
|
5196
|
+
if (thesis.note !== void 0)
|
|
5197
|
+
value.note = responseText(thesis.note, "thesis.note");
|
|
4966
5198
|
if (thesis.entity_stances !== void 0) {
|
|
4967
5199
|
if (!Array.isArray(thesis.entity_stances))
|
|
4968
5200
|
throw invalidResponse3("thesis.entity_stances must be an array");
|
|
@@ -5179,6 +5411,13 @@ function requireTitle(value) {
|
|
|
5179
5411
|
return title;
|
|
5180
5412
|
}
|
|
5181
5413
|
function requireVisibility(value) {
|
|
5414
|
+
const visibility = requireText2(value, "visibility");
|
|
5415
|
+
if (visibility !== "public" && visibility !== "private" && visibility !== "paid") {
|
|
5416
|
+
throw invalidArgument("visibility must be public, private or paid");
|
|
5417
|
+
}
|
|
5418
|
+
return visibility;
|
|
5419
|
+
}
|
|
5420
|
+
function requirePublicVisibility(value) {
|
|
5182
5421
|
const visibility = requireText2(value, "visibility");
|
|
5183
5422
|
if (visibility !== "public" && visibility !== "private") {
|
|
5184
5423
|
throw invalidArgument("visibility must be public or private");
|
|
@@ -5247,7 +5486,7 @@ function responseVisibility(value) {
|
|
|
5247
5486
|
try {
|
|
5248
5487
|
return requireVisibility(value);
|
|
5249
5488
|
} catch {
|
|
5250
|
-
throw invalidResponse3("thesis.visibility must be public or
|
|
5489
|
+
throw invalidResponse3("thesis.visibility must be public, private or paid");
|
|
5251
5490
|
}
|
|
5252
5491
|
}
|
|
5253
5492
|
function responseBody(value) {
|
|
@@ -5271,12 +5510,67 @@ function responseTitle(value) {
|
|
|
5271
5510
|
function isRecord2(value) {
|
|
5272
5511
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5273
5512
|
}
|
|
5513
|
+
function completeEntityStances(entityIDs, stances) {
|
|
5514
|
+
if (entityIDs.length === 0) return !stances || stances.length === 0;
|
|
5515
|
+
if (!stances || stances.length !== entityIDs.length) return false;
|
|
5516
|
+
const expected = new Set(entityIDs);
|
|
5517
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5518
|
+
return stances.every(
|
|
5519
|
+
(stance) => expected.has(stance.entity_id) && !seen.has(stance.entity_id) && seen.add(stance.entity_id)
|
|
5520
|
+
);
|
|
5521
|
+
}
|
|
5274
5522
|
function invalidArgument(message) {
|
|
5275
5523
|
return new AlvaError("INVALID_ARGUMENT", message, 400);
|
|
5276
5524
|
}
|
|
5277
5525
|
function invalidResponse3(message) {
|
|
5278
5526
|
return new AlvaError("INVALID_RESPONSE", message, 502);
|
|
5279
5527
|
}
|
|
5528
|
+
function validMedia(item) {
|
|
5529
|
+
return isRecord2(item) && ["image", "price_chart", "audio", "video"].includes(item.type) && validMediaURL(item.cover_url) && (item.url == null || validMediaURL(item.url));
|
|
5530
|
+
}
|
|
5531
|
+
function validMediaURL(value) {
|
|
5532
|
+
if (typeof value !== "string" || value.length > 2048 || /[\s\u0000]/.test(value))
|
|
5533
|
+
return false;
|
|
5534
|
+
try {
|
|
5535
|
+
const url = new URL(value);
|
|
5536
|
+
return ["http:", "https:"].includes(url.protocol) && !!url.hostname && !url.username && !url.password;
|
|
5537
|
+
} catch {
|
|
5538
|
+
return false;
|
|
5539
|
+
}
|
|
5540
|
+
}
|
|
5541
|
+
async function thesisGraphql(client, query, variables) {
|
|
5542
|
+
const response = await client._request("POST", "/query", {
|
|
5543
|
+
body: { query, variables }
|
|
5544
|
+
});
|
|
5545
|
+
if (!isRecord2(response))
|
|
5546
|
+
throw invalidResponse3("GraphQL response must be an object");
|
|
5547
|
+
if (response.errors !== void 0) {
|
|
5548
|
+
if (!Array.isArray(response.errors))
|
|
5549
|
+
throw invalidResponse3("GraphQL errors must be an array");
|
|
5550
|
+
if (response.errors.length > 0) {
|
|
5551
|
+
const messages = response.errors.flatMap(
|
|
5552
|
+
(error) => isRecord2(error) && typeof error.message === "string" ? [error.message] : []
|
|
5553
|
+
);
|
|
5554
|
+
const codes = new Set(
|
|
5555
|
+
response.errors.map(
|
|
5556
|
+
(error) => isRecord2(error) && isRecord2(error.extensions) ? error.extensions.code : void 0
|
|
5557
|
+
)
|
|
5558
|
+
);
|
|
5559
|
+
const [code] = codes;
|
|
5560
|
+
const canonicalCode = codes.size === 1 && (code === "NOT_FOUND" || code === "PERMISSION_DENIED" || code === "UNAUTHENTICATED") ? code : void 0;
|
|
5561
|
+
const status = canonicalCode === "NOT_FOUND" ? 404 : canonicalCode === "PERMISSION_DENIED" ? 403 : canonicalCode === "UNAUTHENTICATED" ? 401 : 400;
|
|
5562
|
+
throw new AlvaError(
|
|
5563
|
+
canonicalCode ?? "GRAPHQL_ERROR",
|
|
5564
|
+
messages.join("; ") || "GraphQL request failed",
|
|
5565
|
+
status,
|
|
5566
|
+
{ errors: response.errors }
|
|
5567
|
+
);
|
|
5568
|
+
}
|
|
5569
|
+
}
|
|
5570
|
+
if (!isRecord2(response.data))
|
|
5571
|
+
throw invalidResponse3("GraphQL response must contain data");
|
|
5572
|
+
return response.data;
|
|
5573
|
+
}
|
|
5280
5574
|
|
|
5281
5575
|
// src/resources/companyNews.ts
|
|
5282
5576
|
var CREATE_COMPANY_NEWS = `mutation CreateCompanyNews($input: CompanyNewsFeedInput!) {
|
|
@@ -6222,7 +6516,7 @@ var installPlaybookRuntime = (targetWindow) => {
|
|
|
6222
6516
|
};
|
|
6223
6517
|
|
|
6224
6518
|
// src/index.ts
|
|
6225
|
-
var VERSION = true ? "0.
|
|
6519
|
+
var VERSION = true ? "0.34.0-beta.0" : "dev";
|
|
6226
6520
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6227
6521
|
0 && (module.exports = {
|
|
6228
6522
|
AlertsResource,
|