@alva-ai/toolkit 0.32.0 → 0.33.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/dist/browser.global.js +45 -45
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +49 -0
- package/dist/cli.js +287 -103
- package/dist/cli.js.map +1 -1
- package/dist/dispatch.d.ts +49 -0
- package/dist/dispatch.js +102 -17
- package/dist/dispatch.js.map +1 -1
- package/dist/index.cjs +230 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -1
- package/dist/index.d.ts +50 -1
- package/dist/index.js +229 -93
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -674,10 +674,134 @@ function requireFeedID(id) {
|
|
|
674
674
|
return id;
|
|
675
675
|
}
|
|
676
676
|
|
|
677
|
-
// src/resources/
|
|
677
|
+
// src/resources/x.ts
|
|
678
|
+
var GRAPHQL_STATUS_BY_CODE = {
|
|
679
|
+
INVALID_ARGUMENT: 400,
|
|
680
|
+
UNAUTHENTICATED: 401,
|
|
681
|
+
PERMISSION_DENIED: 403,
|
|
682
|
+
NOT_FOUND: 404,
|
|
683
|
+
ALREADY_EXISTS: 409,
|
|
684
|
+
ABORTED: 409,
|
|
685
|
+
FAILED_PRECONDITION: 412,
|
|
686
|
+
RESOURCE_EXHAUSTED: 429,
|
|
687
|
+
INTERNAL: 500,
|
|
688
|
+
UNKNOWN: 500,
|
|
689
|
+
DATA_LOSS: 500,
|
|
690
|
+
UNAVAILABLE: 503,
|
|
691
|
+
DEADLINE_EXCEEDED: 504
|
|
692
|
+
};
|
|
678
693
|
function record(value) {
|
|
679
694
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
680
695
|
}
|
|
696
|
+
function validateXReadParams(params) {
|
|
697
|
+
if (!record(params)) throw new Error("X read parameters must be an object");
|
|
698
|
+
const first = params.first ?? 20;
|
|
699
|
+
if (params.first === null || typeof first !== "number" || !Number.isInteger(first) || first < 5 || first > 100) {
|
|
700
|
+
throw new Error("first must be an integer between 5 and 100");
|
|
701
|
+
}
|
|
702
|
+
if (params.after !== void 0 && (typeof params.after !== "string" || !params.after.trim() || params.after.length > 4096)) {
|
|
703
|
+
throw new Error(
|
|
704
|
+
"after must be a non-empty X cursor of at most 4096 characters"
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
function invalidResponse(field) {
|
|
709
|
+
throw new AlvaError(
|
|
710
|
+
"GRAPHQL_INVALID_RESPONSE",
|
|
711
|
+
`GraphQL returned an invalid viewer.${field} response`,
|
|
712
|
+
502
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
function viewerField(response, field) {
|
|
716
|
+
if (!record(response)) return invalidResponse(field);
|
|
717
|
+
if (response.errors !== void 0) {
|
|
718
|
+
if (!Array.isArray(response.errors)) return invalidResponse(field);
|
|
719
|
+
if (response.errors.length > 0) {
|
|
720
|
+
const messages = response.errors.flatMap(
|
|
721
|
+
(error) => record(error) && typeof error.message === "string" ? [error.message] : []
|
|
722
|
+
);
|
|
723
|
+
const codes = response.errors.map(
|
|
724
|
+
(error) => record(error) && record(error.extensions) ? error.extensions.code : void 0
|
|
725
|
+
);
|
|
726
|
+
const code = typeof codes[0] === "string" && Object.hasOwn(GRAPHQL_STATUS_BY_CODE, codes[0]) && codes.every((value) => value === codes[0]) ? codes[0] : "GRAPHQL_ERROR";
|
|
727
|
+
throw new AlvaError(
|
|
728
|
+
code,
|
|
729
|
+
messages.join("; ") || "X read failed",
|
|
730
|
+
GRAPHQL_STATUS_BY_CODE[code] ?? 502,
|
|
731
|
+
{ errors: response.errors }
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
if (!record(response.data) || !record(response.data.viewer))
|
|
736
|
+
return invalidResponse(field);
|
|
737
|
+
return response.data.viewer[field];
|
|
738
|
+
}
|
|
739
|
+
function readPage(value, field, fields) {
|
|
740
|
+
if (!record(value) || !Array.isArray(value.edges) || !record(value.pageInfo))
|
|
741
|
+
return invalidResponse(field);
|
|
742
|
+
const page = value.pageInfo;
|
|
743
|
+
if (typeof page.startCursor !== "string" || typeof page.endCursor !== "string" || typeof page.hasNextPage !== "boolean" || typeof page.hasPreviousPage !== "boolean" || page.hasNextPage && !page.endCursor)
|
|
744
|
+
return invalidResponse(field);
|
|
745
|
+
for (const edge of value.edges) {
|
|
746
|
+
if (!record(edge) || typeof edge.cursor !== "string" || !edge.cursor || !record(edge.node))
|
|
747
|
+
return invalidResponse(field);
|
|
748
|
+
const node = edge.node;
|
|
749
|
+
if (fields.some((key) => typeof node[key] !== "string"))
|
|
750
|
+
return invalidResponse(field);
|
|
751
|
+
if (!node.id) return invalidResponse(field);
|
|
752
|
+
}
|
|
753
|
+
const first = value.edges[0];
|
|
754
|
+
const last = value.edges[value.edges.length - 1];
|
|
755
|
+
if (page.startCursor !== (first?.cursor ?? "") || last && page.endCursor !== last.cursor)
|
|
756
|
+
return invalidResponse(field);
|
|
757
|
+
return {
|
|
758
|
+
edges: value.edges,
|
|
759
|
+
pageInfo: page,
|
|
760
|
+
retrievedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
var XResource = class {
|
|
764
|
+
constructor(client) {
|
|
765
|
+
this.client = client;
|
|
766
|
+
}
|
|
767
|
+
client;
|
|
768
|
+
async status() {
|
|
769
|
+
this.client._requireAuth();
|
|
770
|
+
const response = await this.client._request("POST", "/query", {
|
|
771
|
+
body: {
|
|
772
|
+
query: "query ToolkitXStatus { viewer { xConnection { connected canReadFollowing canReadPosts } } }"
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
const result = viewerField(response, "xConnection");
|
|
776
|
+
if (!record(result) || ["connected", "canReadFollowing", "canReadPosts"].some(
|
|
777
|
+
(key) => typeof result[key] !== "boolean"
|
|
778
|
+
))
|
|
779
|
+
return invalidResponse("xConnection");
|
|
780
|
+
return result;
|
|
781
|
+
}
|
|
782
|
+
async following(params = {}) {
|
|
783
|
+
return this.read("xFollowing", "id username name", params);
|
|
784
|
+
}
|
|
785
|
+
async posts(params = {}) {
|
|
786
|
+
return this.read("xPosts", "id text authorId createdAt", params);
|
|
787
|
+
}
|
|
788
|
+
async read(field, fields, params) {
|
|
789
|
+
validateXReadParams(params);
|
|
790
|
+
this.client._requireAuth();
|
|
791
|
+
const response = await this.client._request("POST", "/query", {
|
|
792
|
+
body: {
|
|
793
|
+
query: `query ToolkitXRead($first: Int, $after: String) { viewer { ${field}(first: $first, after: $after) { edges { cursor node { ${fields} } } pageInfo { startCursor endCursor hasNextPage hasPreviousPage } } } }`,
|
|
794
|
+
variables: { first: params.first ?? 20, after: params.after }
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
return readPage(viewerField(response, field), field, fields.split(" "));
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
// src/resources/thesisPublication.ts
|
|
802
|
+
function record2(value) {
|
|
803
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
804
|
+
}
|
|
681
805
|
function isPositiveInt64(value) {
|
|
682
806
|
return typeof value === "string" && /^[1-9]\d{0,18}$/.test(value) && BigInt(value) <= 9223372036854775807n;
|
|
683
807
|
}
|
|
@@ -708,35 +832,35 @@ function positiveInt64List(value) {
|
|
|
708
832
|
}
|
|
709
833
|
function stanceList(value) {
|
|
710
834
|
return Array.isArray(value) && value.every(
|
|
711
|
-
(item) =>
|
|
835
|
+
(item) => record2(item) && isPositiveInt64(item.entityId) && typeof item.stance === "string" && item.stance.trim() !== ""
|
|
712
836
|
);
|
|
713
837
|
}
|
|
714
838
|
function entityList(value) {
|
|
715
839
|
return Array.isArray(value) && value.every(
|
|
716
|
-
(item) =>
|
|
840
|
+
(item) => record2(item) && typeof item.id === "string" && item.id.trim() !== "" && typeof item.ticker === "string" && typeof item.name === "string"
|
|
717
841
|
);
|
|
718
842
|
}
|
|
719
843
|
function mediaList(value) {
|
|
720
844
|
return Array.isArray(value) && value.every(
|
|
721
|
-
(item) =>
|
|
845
|
+
(item) => record2(item) && typeof item.type === "string" && item.type.trim() !== "" && typeof item.coverUrl === "string" && (item.url === null || typeof item.url === "string")
|
|
722
846
|
);
|
|
723
847
|
}
|
|
724
848
|
function sourceRefList(value) {
|
|
725
849
|
return Array.isArray(value) && value.every(
|
|
726
|
-
(item) =>
|
|
850
|
+
(item) => record2(item) && (item.title === null || typeof item.title === "string") && typeof item.sourceKind === "string" && typeof item.sourceContentId === "string" && typeof item.publicUrl === "string" && nullableMs(item.sourceTimeMs) && typeof item.locator === "string"
|
|
727
851
|
);
|
|
728
852
|
}
|
|
729
853
|
function nullableMs(value) {
|
|
730
854
|
return value === null || typeof value === "number" && Number.isFinite(value);
|
|
731
855
|
}
|
|
732
856
|
function snapshot(value) {
|
|
733
|
-
return
|
|
857
|
+
return record2(value) && isPositiveInt64(value.versionId) && isPositiveInt64(value.materialVersionId) && typeof value.publishedAtMs === "number" && Number.isFinite(value.publishedAtMs) && typeof value.changeKind === "string" && value.changeKind.trim() !== "" && sourceRefList(value.sourceRefs);
|
|
734
858
|
}
|
|
735
859
|
function publisher(value) {
|
|
736
|
-
return
|
|
860
|
+
return record2(value) && (value.__typename === "Person" && typeof value.slug === "string" || value.__typename === "PublicUser" && typeof value.username === "string") && typeof value.id === "string" && value.id.trim() !== "" && typeof value.displayName === "string" && typeof value.avatarUrl === "string" && typeof value.bio === "string" && typeof value.followersCount === "number" && Number.isInteger(value.followersCount) && record2(value.viewerState) && (value.viewerState.following === null || typeof value.viewerState.following === "boolean");
|
|
737
861
|
}
|
|
738
862
|
function isThesisPublication(value) {
|
|
739
|
-
if (!
|
|
863
|
+
if (!record2(value)) return false;
|
|
740
864
|
for (const field of [
|
|
741
865
|
"thesisId",
|
|
742
866
|
"playbookId",
|
|
@@ -754,7 +878,7 @@ function isThesisPublication(value) {
|
|
|
754
878
|
if (!positiveInt64List(value.entityIds) || !positiveInt64List(value.categoryIds) || !stanceList(value.entityStances) || !entityList(value.entities) || !mediaList(value.medias) || !publisher(value.publisher) || !snapshot(value.snapshotRelease)) {
|
|
755
879
|
return false;
|
|
756
880
|
}
|
|
757
|
-
return value.signalFeed === null ||
|
|
881
|
+
return value.signalFeed === null || record2(value.signalFeed) && isPositiveInt64(value.signalFeed.id);
|
|
758
882
|
}
|
|
759
883
|
|
|
760
884
|
// src/resources/forYou.ts
|
|
@@ -787,7 +911,7 @@ query ToolkitForYou($input: FeedEntryConnectionInput) {
|
|
|
787
911
|
}
|
|
788
912
|
`.trim();
|
|
789
913
|
function validateForYouListParams(params) {
|
|
790
|
-
if (!
|
|
914
|
+
if (!record2(params)) throw new Error("For You parameters must be an object");
|
|
791
915
|
const first = params.first === void 0 ? 20 : params.first;
|
|
792
916
|
if (typeof first !== "number" || !Number.isInteger(first) || first < 1 || first > 50) {
|
|
793
917
|
throw new Error("first must be an integer between 1 and 50");
|
|
@@ -802,7 +926,7 @@ function validateForYouListParams(params) {
|
|
|
802
926
|
throw new Error("feedId must be a positive decimal int64 string");
|
|
803
927
|
}
|
|
804
928
|
}
|
|
805
|
-
function
|
|
929
|
+
function invalidResponse2() {
|
|
806
930
|
throw new AlvaError(
|
|
807
931
|
"GRAPHQL_INVALID_RESPONSE",
|
|
808
932
|
"GraphQL returned an invalid For You connection",
|
|
@@ -810,25 +934,25 @@ function invalidResponse() {
|
|
|
810
934
|
);
|
|
811
935
|
}
|
|
812
936
|
function connection(value) {
|
|
813
|
-
if (!
|
|
814
|
-
return
|
|
937
|
+
if (!record2(value) || !Array.isArray(value.edges) || !record2(value.pageInfo)) {
|
|
938
|
+
return invalidResponse2();
|
|
815
939
|
}
|
|
816
940
|
const page = value.pageInfo;
|
|
817
941
|
if (typeof page.startCursor !== "string" || typeof page.endCursor !== "string" || typeof page.hasNextPage !== "boolean" || typeof page.hasPreviousPage !== "boolean") {
|
|
818
|
-
return
|
|
942
|
+
return invalidResponse2();
|
|
819
943
|
}
|
|
820
944
|
for (const edge of value.edges) {
|
|
821
|
-
if (!
|
|
822
|
-
return
|
|
945
|
+
if (!record2(edge) || typeof edge.cursor !== "string" || !edge.cursor.trim() || !record2(edge.node))
|
|
946
|
+
return invalidResponse2();
|
|
823
947
|
const node = edge.node;
|
|
824
|
-
if (typeof node.id !== "string" || !node.id.startsWith("FeedEntry:") || !isPositiveInt64(node.id.slice("FeedEntry:".length)) || !
|
|
825
|
-
return
|
|
948
|
+
if (typeof node.id !== "string" || !node.id.startsWith("FeedEntry:") || !isPositiveInt64(node.id.slice("FeedEntry:".length)) || !record2(node.feed) || !isPositiveInt64(node.feed.id) || !record2(node.major) || typeof node.major.id !== "string" || !isPositiveInt64(node.major.feedId) || typeof node.title !== "string" || typeof node.body !== "string") {
|
|
949
|
+
return invalidResponse2();
|
|
826
950
|
}
|
|
827
951
|
}
|
|
828
952
|
const first = value.edges[0];
|
|
829
953
|
const last = value.edges[value.edges.length - 1];
|
|
830
954
|
if (page.startCursor !== (first?.cursor ?? "") || page.endCursor !== (last?.cursor ?? "") || value.edges.length === 0 && page.hasNextPage)
|
|
831
|
-
return
|
|
955
|
+
return invalidResponse2();
|
|
832
956
|
return value;
|
|
833
957
|
}
|
|
834
958
|
var THESIS_RECOMMENDATION_QUERY = `
|
|
@@ -851,7 +975,7 @@ query ToolkitForYouTheses($input: ThesisRecommendationInput) {
|
|
|
851
975
|
}
|
|
852
976
|
`.trim();
|
|
853
977
|
function validateForYouThesesParams(params) {
|
|
854
|
-
if (!
|
|
978
|
+
if (!record2(params)) throw new Error("Thesis parameters must be an object");
|
|
855
979
|
const first = params.first === void 0 ? 10 : params.first;
|
|
856
980
|
if (typeof first !== "number" || !Number.isInteger(first) || first < 1 || first > 10) {
|
|
857
981
|
throw new Error("first must be an integer between 1 and 10");
|
|
@@ -861,7 +985,7 @@ function validateForYouThesesParams(params) {
|
|
|
861
985
|
}
|
|
862
986
|
}
|
|
863
987
|
function graphqlViewerField(response, field) {
|
|
864
|
-
if (!
|
|
988
|
+
if (!record2(response)) {
|
|
865
989
|
throw new AlvaError(
|
|
866
990
|
"GRAPHQL_INVALID_RESPONSE",
|
|
867
991
|
`GraphQL returned an invalid viewer.${field} response`,
|
|
@@ -878,7 +1002,7 @@ function graphqlViewerField(response, field) {
|
|
|
878
1002
|
}
|
|
879
1003
|
if (response.errors.length > 0) {
|
|
880
1004
|
const messages = response.errors.flatMap(
|
|
881
|
-
(error) =>
|
|
1005
|
+
(error) => record2(error) && typeof error.message === "string" ? [error.message] : []
|
|
882
1006
|
);
|
|
883
1007
|
throw new AlvaError(
|
|
884
1008
|
"GRAPHQL_ERROR",
|
|
@@ -888,7 +1012,7 @@ function graphqlViewerField(response, field) {
|
|
|
888
1012
|
);
|
|
889
1013
|
}
|
|
890
1014
|
}
|
|
891
|
-
if (!
|
|
1015
|
+
if (!record2(response.data) || !record2(response.data.viewer) || response.data.viewer[field] == null) {
|
|
892
1016
|
throw new AlvaError(
|
|
893
1017
|
"GRAPHQL_EMPTY_RESPONSE",
|
|
894
1018
|
`GraphQL response did not include viewer.${field}`,
|
|
@@ -905,7 +1029,7 @@ function invalidPage() {
|
|
|
905
1029
|
);
|
|
906
1030
|
}
|
|
907
1031
|
function recommendationPage(value) {
|
|
908
|
-
if (!
|
|
1032
|
+
if (!record2(value) || !Array.isArray(value.edges) || !record2(value.pageInfo) || typeof value.listId !== "string" || typeof value.pageCursor !== "string" || typeof value.exhausted !== "boolean" || typeof value.scanLimited !== "boolean" || value.nextCursor !== null && typeof value.nextCursor !== "string") {
|
|
909
1033
|
return invalidPage();
|
|
910
1034
|
}
|
|
911
1035
|
const page = value.pageInfo;
|
|
@@ -913,7 +1037,7 @@ function recommendationPage(value) {
|
|
|
913
1037
|
return invalidPage();
|
|
914
1038
|
}
|
|
915
1039
|
for (const edge of value.edges) {
|
|
916
|
-
if (!
|
|
1040
|
+
if (!record2(edge) || typeof edge.cursor !== "string" || !edge.cursor.trim() || !record2(edge.node) || typeof edge.node.itemKey !== "string" || !edge.node.itemKey.trim() || !isThesisPublication(edge.node.publication)) {
|
|
917
1041
|
return invalidPage();
|
|
918
1042
|
}
|
|
919
1043
|
}
|
|
@@ -3464,7 +3588,7 @@ var SCHEDULE_NAME = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
|
3464
3588
|
var RFC3339 = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(Z|[+-](\d{2}):(\d{2}))$/i;
|
|
3465
3589
|
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;
|
|
3466
3590
|
var ISO_DURATION = /^P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;
|
|
3467
|
-
var
|
|
3591
|
+
var GRAPHQL_STATUS_BY_CODE2 = {
|
|
3468
3592
|
INVALID_ARGUMENT: 400,
|
|
3469
3593
|
UNAUTHENTICATED: 401,
|
|
3470
3594
|
PERMISSION_DENIED: 403,
|
|
@@ -3566,7 +3690,7 @@ var SchedulesResource = class {
|
|
|
3566
3690
|
const codes = response.errors.map((error) => error.extensions?.code);
|
|
3567
3691
|
const distinctCodes = new Set(codes);
|
|
3568
3692
|
const canonicalCode = distinctCodes.size === 1 && typeof codes[0] === "string" ? codes[0] : void 0;
|
|
3569
|
-
const canonicalStatus = canonicalCode ?
|
|
3693
|
+
const canonicalStatus = canonicalCode ? GRAPHQL_STATUS_BY_CODE2[canonicalCode] : void 0;
|
|
3570
3694
|
const errorCode = canonicalCode !== void 0 && canonicalStatus !== void 0 ? canonicalCode : "GRAPHQL_ERROR";
|
|
3571
3695
|
throw new AlvaError(
|
|
3572
3696
|
errorCode,
|
|
@@ -3815,7 +3939,7 @@ function scheduleEmptyResponse() {
|
|
|
3815
3939
|
}
|
|
3816
3940
|
|
|
3817
3941
|
// src/resources/steward.ts
|
|
3818
|
-
var
|
|
3942
|
+
var GRAPHQL_STATUS_BY_CODE3 = {
|
|
3819
3943
|
INVALID_ARGUMENT: 400,
|
|
3820
3944
|
UNAUTHENTICATED: 401,
|
|
3821
3945
|
PERMISSION_DENIED: 403,
|
|
@@ -4044,7 +4168,7 @@ var StewardResource = class {
|
|
|
4044
4168
|
if (response.errors?.length) {
|
|
4045
4169
|
const codes = response.errors.map((error) => error.extensions?.code);
|
|
4046
4170
|
const canonicalCode = new Set(codes).size === 1 && typeof codes[0] === "string" ? codes[0] : void 0;
|
|
4047
|
-
const canonicalStatus = canonicalCode ?
|
|
4171
|
+
const canonicalStatus = canonicalCode ? GRAPHQL_STATUS_BY_CODE3[canonicalCode] : void 0;
|
|
4048
4172
|
throw new AlvaError(
|
|
4049
4173
|
canonicalCode !== void 0 && canonicalStatus !== void 0 ? canonicalCode : "GRAPHQL_ERROR",
|
|
4050
4174
|
response.errors.map((error) => error.message).filter((message) => typeof message === "string").join("; ") || "GraphQL request failed",
|
|
@@ -4160,12 +4284,12 @@ function dedupe(candidates) {
|
|
|
4160
4284
|
});
|
|
4161
4285
|
}
|
|
4162
4286
|
function resolveFilters(params) {
|
|
4163
|
-
const
|
|
4287
|
+
const record3 = isRecord(params) ? params : {};
|
|
4164
4288
|
return {
|
|
4165
|
-
market: typeof
|
|
4166
|
-
instrumentType: typeof
|
|
4167
|
-
underlyingType: typeof
|
|
4168
|
-
quote: typeof
|
|
4289
|
+
market: typeof record3.market === "string" ? record3.market : void 0,
|
|
4290
|
+
instrumentType: typeof record3.instrumentType === "string" ? record3.instrumentType : void 0,
|
|
4291
|
+
underlyingType: typeof record3.underlyingType === "string" ? record3.underlyingType : void 0,
|
|
4292
|
+
quote: typeof record3.quote === "string" ? record3.quote : void 0
|
|
4169
4293
|
};
|
|
4170
4294
|
}
|
|
4171
4295
|
function pairSearchParams(pair, params) {
|
|
@@ -4213,11 +4337,11 @@ var TradingPairsResource = class {
|
|
|
4213
4337
|
return { query, candidates };
|
|
4214
4338
|
}
|
|
4215
4339
|
async resolve(params) {
|
|
4216
|
-
const
|
|
4217
|
-
const pair = typeof
|
|
4340
|
+
const record3 = isRecord(params) ? params : {};
|
|
4341
|
+
const pair = typeof record3.pair === "string" ? record3.pair.trim() : void 0;
|
|
4218
4342
|
const filters = resolveFilters(params);
|
|
4219
4343
|
const searchParams = pair === void 0 ? {
|
|
4220
|
-
symbol: typeof
|
|
4344
|
+
symbol: typeof record3.symbol === "string" ? record3.symbol : "",
|
|
4221
4345
|
...filters
|
|
4222
4346
|
} : pairSearchParams(pair, filters);
|
|
4223
4347
|
const result = await this.search(searchParams);
|
|
@@ -4286,7 +4410,7 @@ var SELECTORS = [
|
|
|
4286
4410
|
"entityId"
|
|
4287
4411
|
];
|
|
4288
4412
|
function validateThesisPageParams(params) {
|
|
4289
|
-
if (!
|
|
4413
|
+
if (!record2(params)) throw argument("Thesis parameters must be an object");
|
|
4290
4414
|
const first = params.first === void 0 ? 10 : params.first;
|
|
4291
4415
|
if (typeof first !== "number" || !Number.isInteger(first) || first < 1 || first > 50) {
|
|
4292
4416
|
throw argument("first must be an integer between 1 and 50");
|
|
@@ -4322,7 +4446,7 @@ async function listTheses(client, params) {
|
|
|
4322
4446
|
const entityId = params.ticker === void 0 ? params.entityId : (await resolveUnique(client, ENTITIES_QUERY, params.ticker, "Entity")).id;
|
|
4323
4447
|
if (entityId !== void 0) {
|
|
4324
4448
|
const data2 = await graphql(client, ENTITY_QUERY, { id: entityId, input });
|
|
4325
|
-
if (!
|
|
4449
|
+
if (!record2(data2.market)) throw invalid3();
|
|
4326
4450
|
return thesisPage(
|
|
4327
4451
|
data2.market.scope,
|
|
4328
4452
|
(node) => isThesisPublication(node) ? { playbookId: node.playbookId, publication: node } : void 0
|
|
@@ -4338,7 +4462,7 @@ async function listTheses(client, params) {
|
|
|
4338
4462
|
if (!isPositiveInt64(node.id)) return void 0;
|
|
4339
4463
|
const release = node.latestRelease;
|
|
4340
4464
|
if (release === null) return { playbookId: node.id, publication: null };
|
|
4341
|
-
if (!
|
|
4465
|
+
if (!record2(release)) return void 0;
|
|
4342
4466
|
const publication = release.thesisPublication;
|
|
4343
4467
|
if (publication !== null && !isThesisPublication(publication))
|
|
4344
4468
|
return void 0;
|
|
@@ -4355,9 +4479,9 @@ async function relatedTheses(client, id, params = {}) {
|
|
|
4355
4479
|
input: { first: params.first ?? 10, after: params.cursor }
|
|
4356
4480
|
});
|
|
4357
4481
|
if (data.node === null) throw notFound();
|
|
4358
|
-
if (!
|
|
4482
|
+
if (!record2(data.node)) throw invalid3();
|
|
4359
4483
|
const value = data.node.relatedTheses;
|
|
4360
|
-
if (!
|
|
4484
|
+
if (!record2(value) || !["GENERATING", "READY", "FAILED"].includes(value.state) || value.nextCursor !== null && !nonempty(value.nextCursor))
|
|
4361
4485
|
throw invalid3();
|
|
4362
4486
|
for (const edge of edges(value)) {
|
|
4363
4487
|
if (!nonempty(edge.node.itemKey) || typeof edge.node.score !== "number" || !isThesisPublication(edge.node.publication))
|
|
@@ -4372,7 +4496,7 @@ async function relatedTheses(client, id, params = {}) {
|
|
|
4372
4496
|
function thesisPage(value, readNode) {
|
|
4373
4497
|
if (value === null) throw notFound();
|
|
4374
4498
|
const scope = readScope(value);
|
|
4375
|
-
if (!
|
|
4499
|
+
if (!record2(value) || !record2(value.theses)) throw invalid3();
|
|
4376
4500
|
const page = value.theses;
|
|
4377
4501
|
const items = edges(page).map((edge) => {
|
|
4378
4502
|
const node = readNode(edge.node);
|
|
@@ -4383,11 +4507,11 @@ function thesisPage(value, readNode) {
|
|
|
4383
4507
|
}
|
|
4384
4508
|
async function resolveUnique(client, document, text, kind) {
|
|
4385
4509
|
const data = await graphql(client, document, { query: text });
|
|
4386
|
-
const search =
|
|
4387
|
-
if (!
|
|
4510
|
+
const search = record2(data.market) ? data.market.search : data.search;
|
|
4511
|
+
if (!record2(search) || !Array.isArray(search.edges) || !record2(search.pageInfo))
|
|
4388
4512
|
throw invalid3();
|
|
4389
4513
|
const candidates = search.edges.map(
|
|
4390
|
-
(edge) => readScope(
|
|
4514
|
+
(edge) => readScope(record2(edge) ? edge.node : void 0)
|
|
4391
4515
|
);
|
|
4392
4516
|
if (!candidates.every((c) => c.__typename === kind))
|
|
4393
4517
|
throw invalid3();
|
|
@@ -4404,11 +4528,11 @@ async function resolveUnique(client, document, text, kind) {
|
|
|
4404
4528
|
);
|
|
4405
4529
|
}
|
|
4406
4530
|
function readScope(value) {
|
|
4407
|
-
if (!
|
|
4531
|
+
if (!record2(value) || !nonempty(value.id)) throw invalid3();
|
|
4408
4532
|
if (value.__typename === "Entity") {
|
|
4409
4533
|
if (!["ticker", "name", "kind", "assetClass"].every(
|
|
4410
4534
|
(key) => typeof value[key] === "string"
|
|
4411
|
-
) || value.venue !== null && (!
|
|
4535
|
+
) || value.venue !== null && (!record2(value.venue) || !nonempty(value.venue.id) || typeof value.venue.name !== "string"))
|
|
4412
4536
|
throw invalid3();
|
|
4413
4537
|
} else if (typeof value.displayName !== "string" || typeof value.bio !== "string" || !(value.__typename === "Person" && nonempty(value.slug) || value.__typename === "PublicUser" && nonempty(value.username))) {
|
|
4414
4538
|
throw invalid3();
|
|
@@ -4419,14 +4543,14 @@ function readScope(value) {
|
|
|
4419
4543
|
}
|
|
4420
4544
|
function edges(value) {
|
|
4421
4545
|
if (!Array.isArray(value.edges) || !value.edges.every(
|
|
4422
|
-
(edge) =>
|
|
4546
|
+
(edge) => record2(edge) && nonempty(edge.cursor) && record2(edge.node)
|
|
4423
4547
|
))
|
|
4424
4548
|
throw invalid3();
|
|
4425
4549
|
return value.edges;
|
|
4426
4550
|
}
|
|
4427
4551
|
function nextCursor(page) {
|
|
4428
4552
|
const info = page.pageInfo;
|
|
4429
|
-
if (!
|
|
4553
|
+
if (!record2(info) || typeof info.hasNextPage !== "boolean" || info.hasNextPage && !nonempty(info.endCursor))
|
|
4430
4554
|
throw invalid3();
|
|
4431
4555
|
return info.hasNextPage ? info.endCursor : null;
|
|
4432
4556
|
}
|
|
@@ -4434,16 +4558,16 @@ async function graphql(client, document, variables) {
|
|
|
4434
4558
|
const response = await client._request("POST", "/query", {
|
|
4435
4559
|
body: { query: document, variables }
|
|
4436
4560
|
});
|
|
4437
|
-
if (!
|
|
4561
|
+
if (!record2(response)) throw invalid3();
|
|
4438
4562
|
if (response.errors !== void 0) {
|
|
4439
4563
|
if (!Array.isArray(response.errors)) throw invalid3();
|
|
4440
4564
|
if (response.errors.length) {
|
|
4441
4565
|
const messages = response.errors.flatMap(
|
|
4442
|
-
(error) =>
|
|
4566
|
+
(error) => record2(error) && typeof error.message === "string" ? [error.message] : []
|
|
4443
4567
|
);
|
|
4444
4568
|
const codes = new Set(
|
|
4445
4569
|
response.errors.map(
|
|
4446
|
-
(error) =>
|
|
4570
|
+
(error) => record2(error) && record2(error.extensions) ? error.extensions.code : void 0
|
|
4447
4571
|
)
|
|
4448
4572
|
);
|
|
4449
4573
|
const [code] = codes;
|
|
@@ -4456,7 +4580,7 @@ async function graphql(client, document, variables) {
|
|
|
4456
4580
|
);
|
|
4457
4581
|
}
|
|
4458
4582
|
}
|
|
4459
|
-
if (!
|
|
4583
|
+
if (!record2(response.data)) throw invalid3();
|
|
4460
4584
|
return response.data;
|
|
4461
4585
|
}
|
|
4462
4586
|
var CANONICAL_STATUS = /* @__PURE__ */ new Map([
|
|
@@ -4525,19 +4649,19 @@ var ThesesResource = class {
|
|
|
4525
4649
|
const viewer = isRecord2(data) ? data.viewer : void 0;
|
|
4526
4650
|
const result = isRecord2(viewer) ? viewer.thesisAssetCandidates : void 0;
|
|
4527
4651
|
if (!isRecord2(result) || !Array.isArray(result.mentions)) {
|
|
4528
|
-
throw
|
|
4652
|
+
throw invalidResponse3("asset candidates response must contain mentions");
|
|
4529
4653
|
}
|
|
4530
4654
|
const mentions = result.mentions.map((item, index) => {
|
|
4531
4655
|
if (!isRecord2(item) || typeof item.quote !== "string" || typeof item.ticker !== "string" || !["RESOLVED", "AMBIGUOUS", "UNRESOLVED"].includes(
|
|
4532
4656
|
item.resolution
|
|
4533
4657
|
) || !["UNKNOWN", "BULLISH", "BEARISH"].includes(item.stance) || !Array.isArray(item.candidates)) {
|
|
4534
|
-
throw
|
|
4658
|
+
throw invalidResponse3(`asset mention ${index} is invalid`);
|
|
4535
4659
|
}
|
|
4536
4660
|
const candidates = item.candidates.map((candidate) => {
|
|
4537
4661
|
if (!isRecord2(candidate) || typeof candidate.ticker !== "string" || typeof candidate.name !== "string" || !["STOCK", "ETF", "CRYPTO", "INDEX"].includes(
|
|
4538
4662
|
candidate.kind
|
|
4539
4663
|
)) {
|
|
4540
|
-
throw
|
|
4664
|
+
throw invalidResponse3(`asset mention ${index} has invalid candidate`);
|
|
4541
4665
|
}
|
|
4542
4666
|
return {
|
|
4543
4667
|
entityId: responseID(
|
|
@@ -4577,7 +4701,7 @@ var ThesesResource = class {
|
|
|
4577
4701
|
)
|
|
4578
4702
|
);
|
|
4579
4703
|
if (response.thesis.id !== thesisID || response.thesis.author_version_id !== versionID) {
|
|
4580
|
-
throw
|
|
4704
|
+
throw invalidResponse3(
|
|
4581
4705
|
"version response must match the requested thesis and author version"
|
|
4582
4706
|
);
|
|
4583
4707
|
}
|
|
@@ -4635,7 +4759,7 @@ var ThesesResource = class {
|
|
|
4635
4759
|
)
|
|
4636
4760
|
);
|
|
4637
4761
|
if (response.thesis.id !== thesisID || response.thesis.visibility !== visibility) {
|
|
4638
|
-
throw
|
|
4762
|
+
throw invalidResponse3(
|
|
4639
4763
|
"visibility response must match the requested thesis and visibility"
|
|
4640
4764
|
);
|
|
4641
4765
|
}
|
|
@@ -4666,7 +4790,7 @@ var ThesesResource = class {
|
|
|
4666
4790
|
);
|
|
4667
4791
|
if (response === void 0) return {};
|
|
4668
4792
|
if (!isRecord2(response) || Object.keys(response).length !== 0) {
|
|
4669
|
-
throw
|
|
4793
|
+
throw invalidResponse3("delete response must be {}");
|
|
4670
4794
|
}
|
|
4671
4795
|
return {};
|
|
4672
4796
|
}
|
|
@@ -4682,7 +4806,7 @@ var ThesesResource = class {
|
|
|
4682
4806
|
}
|
|
4683
4807
|
);
|
|
4684
4808
|
if (!isRecord2(response) || typeof response.body !== "string") {
|
|
4685
|
-
throw
|
|
4809
|
+
throw invalidResponse3("rewrite response must contain a string body");
|
|
4686
4810
|
}
|
|
4687
4811
|
return { body: responseBody(response.body) };
|
|
4688
4812
|
}
|
|
@@ -4728,7 +4852,7 @@ function requireEntityStances(value, entityIDs) {
|
|
|
4728
4852
|
});
|
|
4729
4853
|
}
|
|
4730
4854
|
function updateBody(params) {
|
|
4731
|
-
|
|
4855
|
+
const body = {
|
|
4732
4856
|
request_id: requireRequestID(params.request_id),
|
|
4733
4857
|
expected_author_version_id: requireID(
|
|
4734
4858
|
params.expected_author_version_id,
|
|
@@ -4740,10 +4864,17 @@ function updateBody(params) {
|
|
|
4740
4864
|
visibility: requireVisibility(params.visibility),
|
|
4741
4865
|
editorial: params.editorial ?? false
|
|
4742
4866
|
};
|
|
4867
|
+
if (params.entity_stances !== void 0) {
|
|
4868
|
+
body.entity_stances = requireEntityStances(
|
|
4869
|
+
params.entity_stances,
|
|
4870
|
+
body.entity_ids
|
|
4871
|
+
);
|
|
4872
|
+
}
|
|
4873
|
+
return body;
|
|
4743
4874
|
}
|
|
4744
4875
|
function thesisResponse(response) {
|
|
4745
4876
|
if (!isRecord2(response) || !isRecord2(response.thesis)) {
|
|
4746
|
-
throw
|
|
4877
|
+
throw invalidResponse3("response must contain thesis");
|
|
4747
4878
|
}
|
|
4748
4879
|
const thesis = response.thesis;
|
|
4749
4880
|
const value = {
|
|
@@ -4767,15 +4898,15 @@ function thesisResponse(response) {
|
|
|
4767
4898
|
};
|
|
4768
4899
|
if (thesis.entity_stances !== void 0) {
|
|
4769
4900
|
if (!Array.isArray(thesis.entity_stances))
|
|
4770
|
-
throw
|
|
4901
|
+
throw invalidResponse3("thesis.entity_stances must be an array");
|
|
4771
4902
|
value.entity_stances = thesis.entity_stances.map((item) => {
|
|
4772
4903
|
if (!isRecord2(item))
|
|
4773
|
-
throw
|
|
4904
|
+
throw invalidResponse3("thesis.entity_stances contains invalid entry");
|
|
4774
4905
|
const entityID = responseID(item.entity_id, "entity_stances.entity_id");
|
|
4775
4906
|
if (!value.entity_ids.includes(entityID))
|
|
4776
|
-
throw
|
|
4907
|
+
throw invalidResponse3("entity stance must reference a thesis entity");
|
|
4777
4908
|
if (!["unknown", "bullish", "bearish"].includes(item.stance))
|
|
4778
|
-
throw
|
|
4909
|
+
throw invalidResponse3("thesis.entity_stances contains invalid stance");
|
|
4779
4910
|
return { entity_id: entityID, stance: item.stance };
|
|
4780
4911
|
});
|
|
4781
4912
|
}
|
|
@@ -4784,7 +4915,7 @@ function thesisResponse(response) {
|
|
|
4784
4915
|
function thesisGetResponse(response) {
|
|
4785
4916
|
const base = thesisResponse(response);
|
|
4786
4917
|
if (!isRecord2(response) || !isRecord2(response.author)) {
|
|
4787
|
-
throw
|
|
4918
|
+
throw invalidResponse3("response must contain author");
|
|
4788
4919
|
}
|
|
4789
4920
|
const authorRecord = response.author;
|
|
4790
4921
|
const author = {
|
|
@@ -4798,14 +4929,14 @@ function thesisGetResponse(response) {
|
|
|
4798
4929
|
username: responseText(authorRecord.username, "author.username")
|
|
4799
4930
|
};
|
|
4800
4931
|
if (!Array.isArray(response.entities)) {
|
|
4801
|
-
throw
|
|
4932
|
+
throw invalidResponse3("response must contain entities");
|
|
4802
4933
|
}
|
|
4803
4934
|
if (response.entities.length !== base.thesis.entity_ids.length) {
|
|
4804
|
-
throw
|
|
4935
|
+
throw invalidResponse3("entities must match thesis.entity_ids");
|
|
4805
4936
|
}
|
|
4806
4937
|
const entities = response.entities.map((item, index) => {
|
|
4807
4938
|
if (!isRecord2(item))
|
|
4808
|
-
throw
|
|
4939
|
+
throw invalidResponse3(`entities[${index}] must be an object`);
|
|
4809
4940
|
const entity = {
|
|
4810
4941
|
id: responseID(item.id, `entities[${index}].id`),
|
|
4811
4942
|
ticker: responseText(item.ticker, `entities[${index}].ticker`),
|
|
@@ -4814,7 +4945,7 @@ function thesisGetResponse(response) {
|
|
|
4814
4945
|
kind: responseText(item.kind, `entities[${index}].kind`)
|
|
4815
4946
|
};
|
|
4816
4947
|
if (entity.id !== base.thesis.entity_ids[index]) {
|
|
4817
|
-
throw
|
|
4948
|
+
throw invalidResponse3("entities must preserve thesis.entity_ids order");
|
|
4818
4949
|
}
|
|
4819
4950
|
return entity;
|
|
4820
4951
|
});
|
|
@@ -4822,7 +4953,7 @@ function thesisGetResponse(response) {
|
|
|
4822
4953
|
}
|
|
4823
4954
|
function thesisSignalsResponse(response, thesisID, first) {
|
|
4824
4955
|
if (!isRecord2(response) || !isRecord2(response.research) || !Array.isArray(response.entries) || response.entries.length > first) {
|
|
4825
|
-
throw
|
|
4956
|
+
throw invalidResponse3("invalid Signal history response");
|
|
4826
4957
|
}
|
|
4827
4958
|
const research = response.research;
|
|
4828
4959
|
const status = {
|
|
@@ -4848,13 +4979,13 @@ function thesisSignalsResponse(response, thesisID, first) {
|
|
|
4848
4979
|
);
|
|
4849
4980
|
const entries = response.entries.map((raw) => {
|
|
4850
4981
|
if (!isRecord2(raw) || !isRecord2(raw.signal) || !isRecord2(raw.signal.source)) {
|
|
4851
|
-
throw
|
|
4982
|
+
throw invalidResponse3("entry must include a Signal and source");
|
|
4852
4983
|
}
|
|
4853
4984
|
const signal = raw.signal;
|
|
4854
4985
|
const source = signal.source;
|
|
4855
4986
|
const signalID = responseID(signal.thesis_id, "signal.thesis_id");
|
|
4856
4987
|
if (signalID !== thesisID)
|
|
4857
|
-
throw
|
|
4988
|
+
throw invalidResponse3("Signal belongs to another Thesis");
|
|
4858
4989
|
const cursor = responseNonemptyText(raw.cursor, "entry.cursor");
|
|
4859
4990
|
const mappedSource = {
|
|
4860
4991
|
title: responseText(source.title, "source.title")
|
|
@@ -4887,7 +5018,7 @@ function thesisSignalsResponse(response, thesisID, first) {
|
|
|
4887
5018
|
};
|
|
4888
5019
|
if (signal.evidence_excerpt !== void 0) {
|
|
4889
5020
|
if (!isRecord2(signal.evidence_excerpt))
|
|
4890
|
-
throw
|
|
5021
|
+
throw invalidResponse3("invalid evidence excerpt");
|
|
4891
5022
|
mappedSignal.evidence_excerpt = {
|
|
4892
5023
|
text: responseNonemptyText(
|
|
4893
5024
|
signal.evidence_excerpt.text,
|
|
@@ -4911,19 +5042,19 @@ function thesisSignalsResponse(response, thesisID, first) {
|
|
|
4911
5042
|
});
|
|
4912
5043
|
const nextCursor2 = responseText(response.next_cursor, "next_cursor");
|
|
4913
5044
|
if (nextCursor2 && nextCursor2 !== entries[entries.length - 1]?.cursor) {
|
|
4914
|
-
throw
|
|
5045
|
+
throw invalidResponse3("next_cursor must match the final entry");
|
|
4915
5046
|
}
|
|
4916
5047
|
return { research: status, entries, next_cursor: nextCursor2 };
|
|
4917
5048
|
}
|
|
4918
5049
|
function responseNonnegativeInteger(value, field) {
|
|
4919
5050
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
4920
|
-
throw
|
|
5051
|
+
throw invalidResponse3(field + " must be a nonnegative safe integer");
|
|
4921
5052
|
}
|
|
4922
5053
|
return value;
|
|
4923
5054
|
}
|
|
4924
5055
|
function responseNonemptyText(value, field) {
|
|
4925
5056
|
const valueText = responseText(value, field);
|
|
4926
|
-
if (!valueText.trim()) throw
|
|
5057
|
+
if (!valueText.trim()) throw invalidResponse3(field + " must be nonempty");
|
|
4927
5058
|
return valueText;
|
|
4928
5059
|
}
|
|
4929
5060
|
function requireRequestID(value) {
|
|
@@ -5007,20 +5138,20 @@ function requireText2(value, field) {
|
|
|
5007
5138
|
}
|
|
5008
5139
|
function responseID(value, field) {
|
|
5009
5140
|
if (typeof value === "number") {
|
|
5010
|
-
throw
|
|
5141
|
+
throw invalidResponse3(
|
|
5011
5142
|
`${field} must be a decimal string; numeric IDs are unsafe`
|
|
5012
5143
|
);
|
|
5013
5144
|
}
|
|
5014
5145
|
try {
|
|
5015
5146
|
return requireID(value, field);
|
|
5016
5147
|
} catch {
|
|
5017
|
-
throw
|
|
5148
|
+
throw invalidResponse3(`${field} must be a positive int64 decimal string`);
|
|
5018
5149
|
}
|
|
5019
5150
|
}
|
|
5020
5151
|
function responseIDs(value, field) {
|
|
5021
|
-
if (!Array.isArray(value)) throw
|
|
5152
|
+
if (!Array.isArray(value)) throw invalidResponse3(`${field} must be an array`);
|
|
5022
5153
|
if (value.length > MAX_ENTITY_IDS) {
|
|
5023
|
-
throw
|
|
5154
|
+
throw invalidResponse3(
|
|
5024
5155
|
`${field} must contain at most ${MAX_ENTITY_IDS} IDs`
|
|
5025
5156
|
);
|
|
5026
5157
|
}
|
|
@@ -5030,33 +5161,33 @@ function responseText(value, field) {
|
|
|
5030
5161
|
try {
|
|
5031
5162
|
return requireText2(value, field);
|
|
5032
5163
|
} catch {
|
|
5033
|
-
throw
|
|
5164
|
+
throw invalidResponse3(`${field} must be valid text`);
|
|
5034
5165
|
}
|
|
5035
5166
|
}
|
|
5036
5167
|
function responseClosingNote(value) {
|
|
5037
5168
|
try {
|
|
5038
5169
|
return requireText2(value, "note");
|
|
5039
5170
|
} catch {
|
|
5040
|
-
throw
|
|
5171
|
+
throw invalidResponse3("thesis.closing_note must be valid text");
|
|
5041
5172
|
}
|
|
5042
5173
|
}
|
|
5043
5174
|
function responseBoolean(value, field) {
|
|
5044
5175
|
if (typeof value !== "boolean")
|
|
5045
|
-
throw
|
|
5176
|
+
throw invalidResponse3(`${field} must be boolean`);
|
|
5046
5177
|
return value;
|
|
5047
5178
|
}
|
|
5048
5179
|
function responseVisibility(value) {
|
|
5049
5180
|
try {
|
|
5050
5181
|
return requireVisibility(value);
|
|
5051
5182
|
} catch {
|
|
5052
|
-
throw
|
|
5183
|
+
throw invalidResponse3("thesis.visibility must be public or private");
|
|
5053
5184
|
}
|
|
5054
5185
|
}
|
|
5055
5186
|
function responseBody(value) {
|
|
5056
5187
|
try {
|
|
5057
5188
|
return requireBody(value);
|
|
5058
5189
|
} catch {
|
|
5059
|
-
throw
|
|
5190
|
+
throw invalidResponse3(
|
|
5060
5191
|
"response body must be nonblank valid text at most 65536 UTF-8 bytes"
|
|
5061
5192
|
);
|
|
5062
5193
|
}
|
|
@@ -5065,7 +5196,7 @@ function responseTitle(value) {
|
|
|
5065
5196
|
try {
|
|
5066
5197
|
return requireTitle(value);
|
|
5067
5198
|
} catch {
|
|
5068
|
-
throw
|
|
5199
|
+
throw invalidResponse3(
|
|
5069
5200
|
"response title must be valid text at most 500 UTF-8 bytes"
|
|
5070
5201
|
);
|
|
5071
5202
|
}
|
|
@@ -5076,7 +5207,7 @@ function isRecord2(value) {
|
|
|
5076
5207
|
function invalidArgument(message) {
|
|
5077
5208
|
return new AlvaError("INVALID_ARGUMENT", message, 400);
|
|
5078
5209
|
}
|
|
5079
|
-
function
|
|
5210
|
+
function invalidResponse3(message) {
|
|
5080
5211
|
return new AlvaError("INVALID_RESPONSE", message, 502);
|
|
5081
5212
|
}
|
|
5082
5213
|
|
|
@@ -5086,7 +5217,7 @@ var CREATE_COMPANY_NEWS = `mutation CreateCompanyNews($input: CompanyNewsFeedInp
|
|
|
5086
5217
|
createFeed(input: $input) { id producer { id } }
|
|
5087
5218
|
}
|
|
5088
5219
|
}`;
|
|
5089
|
-
var
|
|
5220
|
+
var GRAPHQL_STATUS_BY_CODE4 = {
|
|
5090
5221
|
INVALID_ARGUMENT: 400,
|
|
5091
5222
|
UNAUTHENTICATED: 401,
|
|
5092
5223
|
PERMISSION_DENIED: 403,
|
|
@@ -5155,7 +5286,7 @@ var CompanyNewsResource = class {
|
|
|
5155
5286
|
throw new AlvaError(
|
|
5156
5287
|
code,
|
|
5157
5288
|
graph.errors.map((error) => error?.message).filter(Boolean).join("; ") || "Company News creation failed",
|
|
5158
|
-
|
|
5289
|
+
GRAPHQL_STATUS_BY_CODE4[code] ?? 502,
|
|
5159
5290
|
{ errors: graph.errors }
|
|
5160
5291
|
);
|
|
5161
5292
|
}
|
|
@@ -5263,6 +5394,7 @@ var AlvaClient = class {
|
|
|
5263
5394
|
_serviceAccount;
|
|
5264
5395
|
_release;
|
|
5265
5396
|
_feed;
|
|
5397
|
+
_x;
|
|
5266
5398
|
_forYou;
|
|
5267
5399
|
_automation;
|
|
5268
5400
|
_playbooks;
|
|
@@ -5413,6 +5545,9 @@ var AlvaClient = class {
|
|
|
5413
5545
|
);
|
|
5414
5546
|
}
|
|
5415
5547
|
}
|
|
5548
|
+
get x() {
|
|
5549
|
+
return this._x ??= new XResource(this);
|
|
5550
|
+
}
|
|
5416
5551
|
get forYou() {
|
|
5417
5552
|
return this._forYou ??= new ForYouResource(this);
|
|
5418
5553
|
}
|
|
@@ -6020,7 +6155,7 @@ var installPlaybookRuntime = (targetWindow) => {
|
|
|
6020
6155
|
};
|
|
6021
6156
|
|
|
6022
6157
|
// src/index.ts
|
|
6023
|
-
var VERSION = true ? "0.
|
|
6158
|
+
var VERSION = true ? "0.33.1-beta.0" : "dev";
|
|
6024
6159
|
export {
|
|
6025
6160
|
AlertsResource,
|
|
6026
6161
|
AlvaClient,
|
|
@@ -6057,6 +6192,7 @@ export {
|
|
|
6057
6192
|
UdfTokenInvalidError,
|
|
6058
6193
|
UdfTransportError,
|
|
6059
6194
|
VERSION,
|
|
6195
|
+
XResource,
|
|
6060
6196
|
getViewerToken,
|
|
6061
6197
|
installPlaybookRuntime,
|
|
6062
6198
|
mapUdfErrorResponse,
|