@superblocksteam/sdk 2.0.102-next.0 → 2.0.102
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/.turbo/turbo-build.log +1 -1
- package/dist/application-build.d.mts.map +1 -1
- package/dist/application-build.mjs +1 -1
- package/dist/application-build.mjs.map +1 -1
- package/dist/cli-replacement/auth-hot-reload.d.mts.map +1 -1
- package/dist/cli-replacement/auth-hot-reload.mjs.map +1 -1
- package/dist/cli-replacement/automatic-upgrades.d.ts +1 -1
- package/dist/cli-replacement/automatic-upgrades.d.ts.map +1 -1
- package/dist/cli-replacement/automatic-upgrades.js +1 -1
- package/dist/cli-replacement/automatic-upgrades.js.map +1 -1
- package/dist/cli-replacement/dev.d.mts.map +1 -1
- package/dist/cli-replacement/dev.mjs +7 -5
- package/dist/cli-replacement/dev.mjs.map +1 -1
- package/dist/cli-replacement/git-repo-setup.d.mts.map +1 -1
- package/dist/cli-replacement/git-repo-setup.mjs +0 -30
- package/dist/cli-replacement/git-repo-setup.mjs.map +1 -1
- package/dist/cli-replacement/git-repo-setup.test.mjs.map +1 -1
- package/dist/cli-replacement/init.d.ts +2 -2
- package/dist/cli-replacement/init.d.ts.map +1 -1
- package/dist/cli-replacement/init.js.map +1 -1
- package/dist/cli-replacement/version-detection.d.ts.map +1 -1
- package/dist/cli-replacement/version-detection.js.map +1 -1
- package/dist/cli-replacement/version-detection.test.js.map +1 -1
- package/dist/client-sync.test.mjs.map +1 -1
- package/dist/client.d.ts +3 -252
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -762
- package/dist/client.js.map +1 -1
- package/dist/collect-sdk-apis.d.mts.map +1 -1
- package/dist/collect-sdk-apis.mjs.map +1 -1
- package/dist/collect-sdk-apis.test.mjs.map +1 -1
- package/dist/dbfs/client.d.ts.map +1 -1
- package/dist/dbfs/client.js.map +1 -1
- package/dist/dbfs/client.test.js +1 -1
- package/dist/dbfs/client.test.js.map +1 -1
- package/dist/dbfs/local.d.ts.map +1 -1
- package/dist/dbfs/local.js.map +1 -1
- package/dist/dev-utils/custom-build.d.mts.map +1 -1
- package/dist/dev-utils/custom-build.mjs.map +1 -1
- package/dist/dev-utils/custom-config.d.mts.map +1 -1
- package/dist/dev-utils/custom-config.mjs.map +1 -1
- package/dist/dev-utils/dev-server.d.mts +2 -2
- package/dist/dev-utils/dev-server.d.mts.map +1 -1
- package/dist/dev-utils/dev-server.mjs +11 -5
- package/dist/dev-utils/dev-server.mjs.map +1 -1
- package/dist/dev-utils/token-manager.d.ts.map +1 -1
- package/dist/dev-utils/token-manager.js.map +1 -1
- package/dist/extract-api-integrations.d.mts +16 -1
- package/dist/extract-api-integrations.d.mts.map +1 -1
- package/dist/extract-api-integrations.mjs +232 -1
- package/dist/extract-api-integrations.mjs.map +1 -1
- package/dist/extract-api-integrations.test.mjs.map +1 -1
- package/dist/flag.d.ts.map +1 -1
- package/dist/flag.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/parse-sdk-registry.d.mts.map +1 -1
- package/dist/parse-sdk-registry.mjs.map +1 -1
- package/dist/parse-sdk-registry.test.mjs.map +1 -1
- package/dist/sdk.d.ts +4 -59
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +1 -184
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.test.js +2 -72
- package/dist/sdk.test.js.map +1 -1
- package/dist/socket/handlers.d.ts +1 -1
- package/dist/socket/handlers.d.ts.map +1 -1
- package/dist/socket/handlers.js.map +1 -1
- package/dist/socket/index.d.ts +1 -1
- package/dist/socket/index.d.ts.map +1 -1
- package/dist/socket/index.js.map +1 -1
- package/dist/socket/signing.d.ts +1 -1
- package/dist/socket/signing.d.ts.map +1 -1
- package/dist/socket/signing.js.map +1 -1
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/logging.d.ts.map +1 -1
- package/dist/telemetry/logging.js +1 -1
- package/dist/telemetry/logging.js.map +1 -1
- package/dist/types/common.d.ts +1 -1
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/dist/version-control.d.mts +1 -1
- package/dist/version-control.d.mts.map +1 -1
- package/dist/version-control.mjs +2 -2
- package/dist/version-control.mjs.map +1 -1
- package/dist/vite-plugin-generate-api-build-manifest.d.mts.map +1 -1
- package/dist/vite-plugin-generate-api-build-manifest.mjs +3 -3
- package/dist/vite-plugin-generate-api-build-manifest.mjs.map +1 -1
- package/dist/vite-plugin-inject-sb-ids-transform.d.mts.map +1 -1
- package/dist/vite-plugin-inject-sb-ids-transform.mjs +1 -1
- package/dist/vite-plugin-inject-sb-ids-transform.mjs.map +1 -1
- package/dist/vite-plugin-sdk-api-entry-point.d.mts.map +1 -1
- package/dist/vite-plugin-sdk-api-entry-point.mjs.map +1 -1
- package/dist/vite-plugin-sdk-api-entry-point.test.mjs.map +1 -1
- package/eslint.config.js +17 -2
- package/package.json +6 -6
- package/src/application-build.mts +1 -4
- package/src/cli-replacement/auth-hot-reload.mts +2 -2
- package/src/cli-replacement/automatic-upgrades.ts +7 -10
- package/src/cli-replacement/dev.mts +17 -17
- package/src/cli-replacement/git-repo-setup.mts +1 -34
- package/src/cli-replacement/git-repo-setup.test.mts +1 -4
- package/src/cli-replacement/init.ts +4 -5
- package/src/cli-replacement/version-detection.test.ts +0 -2
- package/src/cli-replacement/version-detection.ts +0 -1
- package/src/client-sync.test.mts +0 -1
- package/src/client.ts +21 -1204
- package/src/collect-sdk-apis.mts +0 -1
- package/src/collect-sdk-apis.test.mts +0 -2
- package/src/dbfs/client.test.ts +1 -2
- package/src/dbfs/client.ts +0 -1
- package/src/dbfs/local.ts +0 -2
- package/src/dev-utils/custom-build.mts +1 -3
- package/src/dev-utils/custom-config.mts +0 -1
- package/src/dev-utils/dev-server.mts +26 -22
- package/src/dev-utils/token-manager.ts +0 -1
- package/src/extract-api-integrations.mts +345 -5
- package/src/extract-api-integrations.test.mts +0 -1
- package/src/flag.ts +0 -1
- package/src/index.ts +0 -7
- package/src/parse-sdk-registry.mts +0 -1
- package/src/parse-sdk-registry.test.mts +0 -2
- package/src/sdk.test.ts +5 -85
- package/src/sdk.ts +14 -324
- package/src/socket/handlers.ts +2 -3
- package/src/socket/index.ts +3 -4
- package/src/socket/signing.ts +3 -5
- package/src/telemetry/index.ts +2 -5
- package/src/telemetry/logging.ts +3 -4
- package/src/types/common.ts +1 -2
- package/src/utils.ts +2 -4
- package/src/version-control.mts +18 -21
- package/src/vite-plugin-generate-api-build-manifest.mts +7 -10
- package/src/vite-plugin-inject-sb-ids-transform.mts +2 -5
- package/src/vite-plugin-sdk-api-entry-point.mts +0 -1
- package/src/vite-plugin-sdk-api-entry-point.test.mts +0 -2
- package/test/clients.test.mts +1 -4
- package/test/safe-stringify.test.mts +0 -1
- package/test/version-control.test.mts +14 -17
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/client.fetch-audit-events.test.d.ts +0 -2
- package/dist/client.fetch-audit-events.test.d.ts.map +0 -1
- package/dist/client.fetch-audit-events.test.js +0 -69
- package/dist/client.fetch-audit-events.test.js.map +0 -1
- package/src/client.fetch-audit-events.test.ts +0 -82
package/src/client.ts
CHANGED
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
import axios, { AxiosError } from "axios";
|
|
5
|
-
import type { AxiosRequestConfig } from "axios";
|
|
6
|
-
import FormData from "form-data";
|
|
7
|
-
import { isEqual, isEmpty } from "lodash-es";
|
|
8
|
-
|
|
9
3
|
import { Bucketeer, FileDescriptor } from "@superblocksteam/bucketeer-sdk";
|
|
10
4
|
import {
|
|
11
5
|
CommitType,
|
|
12
6
|
ExportViewMode,
|
|
13
|
-
type AssignmentDto,
|
|
14
|
-
type OCSFAuditEvent,
|
|
15
|
-
type AuditLogDto,
|
|
16
|
-
type AuditLogEntity,
|
|
17
|
-
type FactDto,
|
|
18
|
-
type FactListQuery,
|
|
19
7
|
type GetApplicationCommitsResponseBody,
|
|
20
8
|
type GetPublicOrganizationSummaryResponseBody,
|
|
21
|
-
type IHomepageApplicationV2Dto,
|
|
22
9
|
} from "@superblocksteam/shared";
|
|
23
10
|
import {
|
|
24
11
|
COMPONENT_EVENT_HEADER,
|
|
@@ -31,12 +18,9 @@ import {
|
|
|
31
18
|
unreachable,
|
|
32
19
|
getSuperblocksDevEnvironmentConfigJson,
|
|
33
20
|
} from "@superblocksteam/util";
|
|
34
|
-
import
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
ValidateGitSetupRequestBody,
|
|
38
|
-
} from "@superblocksteam/util";
|
|
39
|
-
|
|
21
|
+
import axios, { AxiosError } from "axios";
|
|
22
|
+
import FormData from "form-data";
|
|
23
|
+
import { isEqual, isEmpty } from "lodash-es";
|
|
40
24
|
import { doUploadLocalDirectory } from "./dbfs/local.js";
|
|
41
25
|
import {
|
|
42
26
|
BranchNotCheckedOutError,
|
|
@@ -45,8 +29,14 @@ import {
|
|
|
45
29
|
} from "./errors.js";
|
|
46
30
|
import { signingEnabled } from "./flag.js";
|
|
47
31
|
import { connectToISocketRPCServer } from "./socket/index.js";
|
|
48
|
-
import type { StdISocketRPCClient } from "./socket/index.js";
|
|
49
32
|
import { AgentType } from "./types/index.js";
|
|
33
|
+
import { getAgentUrl } from "./utils.js";
|
|
34
|
+
import {
|
|
35
|
+
DEFAULT_BRANCH,
|
|
36
|
+
findGitRepositoryRoot,
|
|
37
|
+
getCurrentGitBranchIfGit,
|
|
38
|
+
} from "./version-control.mjs";
|
|
39
|
+
import type { StdISocketRPCClient } from "./socket/index.js";
|
|
50
40
|
import type {
|
|
51
41
|
ApiWithPb,
|
|
52
42
|
Page,
|
|
@@ -54,15 +44,15 @@ import type {
|
|
|
54
44
|
DeploymentDto,
|
|
55
45
|
UserMeDto,
|
|
56
46
|
} from "./types/index.js";
|
|
57
|
-
|
|
58
|
-
import {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
} from "
|
|
47
|
+
|
|
48
|
+
import type {
|
|
49
|
+
LocalGitRepoState,
|
|
50
|
+
SuperblocksResourceType,
|
|
51
|
+
ValidateGitSetupRequestBody,
|
|
52
|
+
} from "@superblocksteam/util";
|
|
53
|
+
import type { AxiosRequestConfig } from "axios";
|
|
63
54
|
|
|
64
55
|
const BASE_BUCKETEER_URL = "api";
|
|
65
|
-
const BASE_SERVER_API_URL_V1 = "api/v1";
|
|
66
56
|
const BASE_SERVER_PUBLIC_API_URL_V1 = "api/v1/public";
|
|
67
57
|
const BASE_SERVER_PUBLIC_API_URL_v2 = "api/v2/public";
|
|
68
58
|
const BASE_SERVER_API_URL_V2 = "api/v2";
|
|
@@ -527,7 +517,7 @@ export async function fetchApplications(
|
|
|
527
517
|
token: string,
|
|
528
518
|
superblocksBaseUrl: string,
|
|
529
519
|
injectedHeaders: Record<string, string> = {},
|
|
530
|
-
)
|
|
520
|
+
) {
|
|
531
521
|
try {
|
|
532
522
|
const config: AxiosRequestConfig = {
|
|
533
523
|
method: "get",
|
|
@@ -542,7 +532,7 @@ export async function fetchApplications(
|
|
|
542
532
|
},
|
|
543
533
|
};
|
|
544
534
|
const response = await axios(config);
|
|
545
|
-
return response.data.data.applications
|
|
535
|
+
return response.data.data.applications;
|
|
546
536
|
} catch (e: any) {
|
|
547
537
|
let message: string;
|
|
548
538
|
if (e instanceof AxiosError) {
|
|
@@ -996,79 +986,6 @@ export async function fetchOrganizationSummary(
|
|
|
996
986
|
}
|
|
997
987
|
}
|
|
998
988
|
|
|
999
|
-
export interface CreateApplicationParams {
|
|
1000
|
-
cliVersion: string;
|
|
1001
|
-
token: string;
|
|
1002
|
-
superblocksBaseUrl: string;
|
|
1003
|
-
name: string;
|
|
1004
|
-
organizationId: string;
|
|
1005
|
-
codeMode?: boolean;
|
|
1006
|
-
templateName?: string;
|
|
1007
|
-
folderId?: string;
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
export interface CreateApplicationResult {
|
|
1011
|
-
id: string;
|
|
1012
|
-
name: string;
|
|
1013
|
-
organizationId: string;
|
|
1014
|
-
devEnvEnabled?: boolean;
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
export async function createApplication({
|
|
1018
|
-
cliVersion,
|
|
1019
|
-
token,
|
|
1020
|
-
superblocksBaseUrl,
|
|
1021
|
-
name,
|
|
1022
|
-
organizationId,
|
|
1023
|
-
codeMode = true,
|
|
1024
|
-
templateName,
|
|
1025
|
-
folderId,
|
|
1026
|
-
}: CreateApplicationParams): Promise<CreateApplicationResult> {
|
|
1027
|
-
const body: Record<string, unknown> = {
|
|
1028
|
-
name,
|
|
1029
|
-
organizationId,
|
|
1030
|
-
};
|
|
1031
|
-
if (codeMode) {
|
|
1032
|
-
body.createUsingReact = true;
|
|
1033
|
-
if (templateName) {
|
|
1034
|
-
body.templateName = templateName;
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
if (folderId) {
|
|
1038
|
-
body.folderId = folderId;
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
try {
|
|
1042
|
-
const config: AxiosRequestConfig = {
|
|
1043
|
-
method: "post",
|
|
1044
|
-
url: new URL(
|
|
1045
|
-
`${BASE_SERVER_API_URL_V2}/applications/`,
|
|
1046
|
-
superblocksBaseUrl,
|
|
1047
|
-
).toString(),
|
|
1048
|
-
headers: {
|
|
1049
|
-
Authorization: "Bearer " + token,
|
|
1050
|
-
"Content-Type": "application/json",
|
|
1051
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
1052
|
-
},
|
|
1053
|
-
data: body,
|
|
1054
|
-
};
|
|
1055
|
-
const response = await axios(config);
|
|
1056
|
-
return response.data.data as CreateApplicationResult;
|
|
1057
|
-
} catch (e: any) {
|
|
1058
|
-
let message: string;
|
|
1059
|
-
if (e instanceof AxiosError) {
|
|
1060
|
-
message =
|
|
1061
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
1062
|
-
JSON.stringify(e.response?.data) ??
|
|
1063
|
-
e.response?.statusText ??
|
|
1064
|
-
e?.message;
|
|
1065
|
-
} else {
|
|
1066
|
-
message = `${e?.message ? e?.message : e}`;
|
|
1067
|
-
}
|
|
1068
|
-
throw new Error(`Could not create application: ${message}`);
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
989
|
const createSocketConnectionIfNeeded = async (
|
|
1073
990
|
cliVersion: string,
|
|
1074
991
|
token: string,
|
|
@@ -1597,9 +1514,9 @@ export async function fetchApiCommits({
|
|
|
1597
1514
|
return serverResponse?.data?.data;
|
|
1598
1515
|
} catch (e) {
|
|
1599
1516
|
if (axios.isAxiosError(e) && e.response?.status === 404) {
|
|
1600
|
-
throw new NotFoundError(`
|
|
1517
|
+
throw new NotFoundError(`Application ${applicationId} was not found`);
|
|
1601
1518
|
}
|
|
1602
|
-
throw new Error("Could not fetch
|
|
1519
|
+
throw new Error("Could not fetch application");
|
|
1603
1520
|
}
|
|
1604
1521
|
}
|
|
1605
1522
|
|
|
@@ -1713,1106 +1630,6 @@ export async function uploadApplication({
|
|
|
1713
1630
|
await bucketeer.uploadApplication(fds);
|
|
1714
1631
|
}
|
|
1715
1632
|
|
|
1716
|
-
export async function fetchRbacAssignments({
|
|
1717
|
-
cliVersion,
|
|
1718
|
-
token,
|
|
1719
|
-
superblocksBaseUrl,
|
|
1720
|
-
resourceType,
|
|
1721
|
-
resourceId,
|
|
1722
|
-
}: {
|
|
1723
|
-
cliVersion: string;
|
|
1724
|
-
token: string;
|
|
1725
|
-
superblocksBaseUrl: string;
|
|
1726
|
-
resourceType: string;
|
|
1727
|
-
resourceId: string;
|
|
1728
|
-
}): Promise<AssignmentDto[]> {
|
|
1729
|
-
try {
|
|
1730
|
-
const url = new URL(
|
|
1731
|
-
`${BASE_SERVER_API_URL_V2}/rbac/assignments`,
|
|
1732
|
-
superblocksBaseUrl,
|
|
1733
|
-
);
|
|
1734
|
-
url.searchParams.set("resourceType", resourceType);
|
|
1735
|
-
url.searchParams.set("resourceId", resourceId);
|
|
1736
|
-
|
|
1737
|
-
const config: AxiosRequestConfig = {
|
|
1738
|
-
method: "get",
|
|
1739
|
-
url: url.toString(),
|
|
1740
|
-
headers: {
|
|
1741
|
-
Authorization: "Bearer " + token,
|
|
1742
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
1743
|
-
},
|
|
1744
|
-
};
|
|
1745
|
-
const response = await axios(config);
|
|
1746
|
-
return response.data.data as AssignmentDto[];
|
|
1747
|
-
} catch (e: any) {
|
|
1748
|
-
let message: string;
|
|
1749
|
-
if (e instanceof AxiosError) {
|
|
1750
|
-
message =
|
|
1751
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
1752
|
-
JSON.stringify(e.response?.data) ??
|
|
1753
|
-
e.response?.statusText ??
|
|
1754
|
-
e?.message;
|
|
1755
|
-
} else {
|
|
1756
|
-
message = `${e?.message ? e?.message : e}`;
|
|
1757
|
-
}
|
|
1758
|
-
throw new Error(`Could not fetch RBAC assignments: ${message}`);
|
|
1759
|
-
}
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
export interface CreateRbacAssignmentsRequest {
|
|
1763
|
-
assignments: Array<{
|
|
1764
|
-
assignmentType: string;
|
|
1765
|
-
assignmentId: string;
|
|
1766
|
-
resourceType: string;
|
|
1767
|
-
resourceId: string;
|
|
1768
|
-
principalType: string;
|
|
1769
|
-
principalId: string;
|
|
1770
|
-
organizationId: string;
|
|
1771
|
-
}>;
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
export interface UpdateRbacAssignmentRequest {
|
|
1775
|
-
assignmentType: string;
|
|
1776
|
-
assignmentId: string;
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
|
-
export async function createRbacAssignments({
|
|
1780
|
-
cliVersion,
|
|
1781
|
-
token,
|
|
1782
|
-
superblocksBaseUrl,
|
|
1783
|
-
payload,
|
|
1784
|
-
}: {
|
|
1785
|
-
cliVersion: string;
|
|
1786
|
-
token: string;
|
|
1787
|
-
superblocksBaseUrl: string;
|
|
1788
|
-
payload: CreateRbacAssignmentsRequest;
|
|
1789
|
-
}): Promise<AssignmentDto[]> {
|
|
1790
|
-
try {
|
|
1791
|
-
const url = new URL(
|
|
1792
|
-
`${BASE_SERVER_API_URL_V2}/rbac/assignments`,
|
|
1793
|
-
superblocksBaseUrl,
|
|
1794
|
-
);
|
|
1795
|
-
const config: AxiosRequestConfig = {
|
|
1796
|
-
method: "post",
|
|
1797
|
-
url: url.toString(),
|
|
1798
|
-
data: payload,
|
|
1799
|
-
headers: {
|
|
1800
|
-
Authorization: "Bearer " + token,
|
|
1801
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
1802
|
-
},
|
|
1803
|
-
};
|
|
1804
|
-
const response = await axios(config);
|
|
1805
|
-
return response.data.data as AssignmentDto[];
|
|
1806
|
-
} catch (e: any) {
|
|
1807
|
-
let message: string;
|
|
1808
|
-
if (e instanceof AxiosError) {
|
|
1809
|
-
message =
|
|
1810
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
1811
|
-
JSON.stringify(e.response?.data) ??
|
|
1812
|
-
e.response?.statusText ??
|
|
1813
|
-
e?.message;
|
|
1814
|
-
} else {
|
|
1815
|
-
message = `${e?.message ? e?.message : e}`;
|
|
1816
|
-
}
|
|
1817
|
-
throw new Error(`Could not create RBAC assignments: ${message}`);
|
|
1818
|
-
}
|
|
1819
|
-
}
|
|
1820
|
-
|
|
1821
|
-
export async function updateRbacAssignment({
|
|
1822
|
-
cliVersion,
|
|
1823
|
-
token,
|
|
1824
|
-
superblocksBaseUrl,
|
|
1825
|
-
assignmentRecordId,
|
|
1826
|
-
payload,
|
|
1827
|
-
}: {
|
|
1828
|
-
cliVersion: string;
|
|
1829
|
-
token: string;
|
|
1830
|
-
superblocksBaseUrl: string;
|
|
1831
|
-
assignmentRecordId: string;
|
|
1832
|
-
payload: UpdateRbacAssignmentRequest;
|
|
1833
|
-
}): Promise<AssignmentDto> {
|
|
1834
|
-
try {
|
|
1835
|
-
const url = new URL(
|
|
1836
|
-
`${BASE_SERVER_API_URL_V2}/rbac/assignments/${assignmentRecordId}`,
|
|
1837
|
-
superblocksBaseUrl,
|
|
1838
|
-
);
|
|
1839
|
-
const config: AxiosRequestConfig = {
|
|
1840
|
-
method: "put",
|
|
1841
|
-
url: url.toString(),
|
|
1842
|
-
data: payload,
|
|
1843
|
-
headers: {
|
|
1844
|
-
Authorization: "Bearer " + token,
|
|
1845
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
1846
|
-
},
|
|
1847
|
-
};
|
|
1848
|
-
const response = await axios(config);
|
|
1849
|
-
return response.data.data as AssignmentDto;
|
|
1850
|
-
} catch (e: any) {
|
|
1851
|
-
let message: string;
|
|
1852
|
-
if (e instanceof AxiosError) {
|
|
1853
|
-
message =
|
|
1854
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
1855
|
-
JSON.stringify(e.response?.data) ??
|
|
1856
|
-
e.response?.statusText ??
|
|
1857
|
-
e?.message;
|
|
1858
|
-
} else {
|
|
1859
|
-
message = `${e?.message ? e?.message : e}`;
|
|
1860
|
-
}
|
|
1861
|
-
throw new Error(`Could not update RBAC assignment: ${message}`);
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
|
-
|
|
1865
|
-
export async function deleteRbacAssignment({
|
|
1866
|
-
cliVersion,
|
|
1867
|
-
token,
|
|
1868
|
-
superblocksBaseUrl,
|
|
1869
|
-
assignmentRecordId,
|
|
1870
|
-
}: {
|
|
1871
|
-
cliVersion: string;
|
|
1872
|
-
token: string;
|
|
1873
|
-
superblocksBaseUrl: string;
|
|
1874
|
-
assignmentRecordId: string;
|
|
1875
|
-
}): Promise<AssignmentDto> {
|
|
1876
|
-
try {
|
|
1877
|
-
const url = new URL(
|
|
1878
|
-
`${BASE_SERVER_API_URL_V2}/rbac/assignments/${assignmentRecordId}`,
|
|
1879
|
-
superblocksBaseUrl,
|
|
1880
|
-
);
|
|
1881
|
-
const config: AxiosRequestConfig = {
|
|
1882
|
-
method: "delete",
|
|
1883
|
-
url: url.toString(),
|
|
1884
|
-
headers: {
|
|
1885
|
-
Authorization: "Bearer " + token,
|
|
1886
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
1887
|
-
},
|
|
1888
|
-
};
|
|
1889
|
-
const response = await axios(config);
|
|
1890
|
-
return response.data.data as AssignmentDto;
|
|
1891
|
-
} catch (e: any) {
|
|
1892
|
-
let message: string;
|
|
1893
|
-
if (e instanceof AxiosError) {
|
|
1894
|
-
message =
|
|
1895
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
1896
|
-
JSON.stringify(e.response?.data) ??
|
|
1897
|
-
e.response?.statusText ??
|
|
1898
|
-
e?.message;
|
|
1899
|
-
} else {
|
|
1900
|
-
message = `${e?.message ? e?.message : e}`;
|
|
1901
|
-
}
|
|
1902
|
-
throw new Error(`Could not delete RBAC assignment: ${message}`);
|
|
1903
|
-
}
|
|
1904
|
-
}
|
|
1905
|
-
|
|
1906
|
-
export interface AuditLogFilters {
|
|
1907
|
-
startTime: string;
|
|
1908
|
-
endTime: string;
|
|
1909
|
-
entityType?: number;
|
|
1910
|
-
auditEntityId?: string;
|
|
1911
|
-
auditEntityType?: number;
|
|
1912
|
-
status?: string;
|
|
1913
|
-
deployed?: boolean;
|
|
1914
|
-
triggeredBy?: string[];
|
|
1915
|
-
}
|
|
1916
|
-
|
|
1917
|
-
export async function fetchAuditLogs({
|
|
1918
|
-
cliVersion,
|
|
1919
|
-
token,
|
|
1920
|
-
superblocksBaseUrl,
|
|
1921
|
-
filters,
|
|
1922
|
-
}: {
|
|
1923
|
-
cliVersion: string;
|
|
1924
|
-
token: string;
|
|
1925
|
-
superblocksBaseUrl: string;
|
|
1926
|
-
filters: AuditLogFilters;
|
|
1927
|
-
}): Promise<AuditLogDto[]> {
|
|
1928
|
-
try {
|
|
1929
|
-
const url = new URL(`${BASE_SERVER_API_URL_V2}/audit`, superblocksBaseUrl);
|
|
1930
|
-
url.searchParams.set("startTime", filters.startTime);
|
|
1931
|
-
url.searchParams.set("endTime", filters.endTime);
|
|
1932
|
-
if (filters.entityType !== undefined) {
|
|
1933
|
-
url.searchParams.set("entity_type", String(filters.entityType));
|
|
1934
|
-
}
|
|
1935
|
-
if (filters.auditEntityId !== undefined) {
|
|
1936
|
-
url.searchParams.set("audit_entity_id", filters.auditEntityId);
|
|
1937
|
-
}
|
|
1938
|
-
if (filters.auditEntityType !== undefined) {
|
|
1939
|
-
url.searchParams.set(
|
|
1940
|
-
"audit_entity_type",
|
|
1941
|
-
String(filters.auditEntityType),
|
|
1942
|
-
);
|
|
1943
|
-
}
|
|
1944
|
-
if (filters.status !== undefined) {
|
|
1945
|
-
url.searchParams.set("status", filters.status);
|
|
1946
|
-
}
|
|
1947
|
-
if (filters.deployed !== undefined) {
|
|
1948
|
-
url.searchParams.set("deployed", String(filters.deployed));
|
|
1949
|
-
}
|
|
1950
|
-
if (filters.triggeredBy?.length) {
|
|
1951
|
-
for (const src of filters.triggeredBy) {
|
|
1952
|
-
url.searchParams.append("triggered_by", src);
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1955
|
-
|
|
1956
|
-
const config: AxiosRequestConfig = {
|
|
1957
|
-
method: "get",
|
|
1958
|
-
url: url.toString(),
|
|
1959
|
-
headers: {
|
|
1960
|
-
Authorization: "Bearer " + token,
|
|
1961
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
1962
|
-
},
|
|
1963
|
-
};
|
|
1964
|
-
const response = await axios(config);
|
|
1965
|
-
return response.data.data as AuditLogDto[];
|
|
1966
|
-
} catch (e: any) {
|
|
1967
|
-
let message: string;
|
|
1968
|
-
if (e instanceof AxiosError) {
|
|
1969
|
-
message =
|
|
1970
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
1971
|
-
JSON.stringify(e.response?.data) ??
|
|
1972
|
-
e.response?.statusText ??
|
|
1973
|
-
e?.message;
|
|
1974
|
-
} else {
|
|
1975
|
-
message = `${e?.message ? e?.message : e}`;
|
|
1976
|
-
}
|
|
1977
|
-
throw new Error(`Could not fetch audit logs: ${message}`);
|
|
1978
|
-
}
|
|
1979
|
-
}
|
|
1980
|
-
|
|
1981
|
-
export interface AuditEventFilters {
|
|
1982
|
-
timeStart: string;
|
|
1983
|
-
timeEnd: string;
|
|
1984
|
-
classUid?: number;
|
|
1985
|
-
status?: number;
|
|
1986
|
-
severity?: number;
|
|
1987
|
-
actor?: string;
|
|
1988
|
-
resourceType?: string;
|
|
1989
|
-
resourceId?: string;
|
|
1990
|
-
search?: string;
|
|
1991
|
-
cursor?: string;
|
|
1992
|
-
limit?: number;
|
|
1993
|
-
}
|
|
1994
|
-
|
|
1995
|
-
export interface AuditEventsResponse {
|
|
1996
|
-
events: OCSFAuditEvent[];
|
|
1997
|
-
next_cursor: string | null;
|
|
1998
|
-
}
|
|
1999
|
-
|
|
2000
|
-
export async function fetchAuditEvents({
|
|
2001
|
-
cliVersion,
|
|
2002
|
-
token,
|
|
2003
|
-
superblocksBaseUrl,
|
|
2004
|
-
filters,
|
|
2005
|
-
}: {
|
|
2006
|
-
cliVersion: string;
|
|
2007
|
-
token: string;
|
|
2008
|
-
superblocksBaseUrl: string;
|
|
2009
|
-
filters: AuditEventFilters;
|
|
2010
|
-
}): Promise<AuditEventsResponse> {
|
|
2011
|
-
try {
|
|
2012
|
-
const url = new URL(
|
|
2013
|
-
`${BASE_SERVER_API_URL_V2}/audit/events`,
|
|
2014
|
-
superblocksBaseUrl,
|
|
2015
|
-
);
|
|
2016
|
-
url.searchParams.set("time_start", filters.timeStart);
|
|
2017
|
-
url.searchParams.set("time_end", filters.timeEnd);
|
|
2018
|
-
if (filters.classUid !== undefined) {
|
|
2019
|
-
url.searchParams.set("class_uid", String(filters.classUid));
|
|
2020
|
-
}
|
|
2021
|
-
if (filters.status !== undefined) {
|
|
2022
|
-
url.searchParams.set("status", String(filters.status));
|
|
2023
|
-
}
|
|
2024
|
-
if (filters.severity !== undefined) {
|
|
2025
|
-
url.searchParams.set("severity", String(filters.severity));
|
|
2026
|
-
}
|
|
2027
|
-
if (filters.actor !== undefined) {
|
|
2028
|
-
url.searchParams.set("actor", filters.actor);
|
|
2029
|
-
}
|
|
2030
|
-
if (filters.resourceType !== undefined) {
|
|
2031
|
-
url.searchParams.set("resource_type", filters.resourceType);
|
|
2032
|
-
}
|
|
2033
|
-
if (filters.resourceId !== undefined) {
|
|
2034
|
-
url.searchParams.set("resource_id", filters.resourceId);
|
|
2035
|
-
}
|
|
2036
|
-
if (filters.search !== undefined) {
|
|
2037
|
-
url.searchParams.set("search", filters.search);
|
|
2038
|
-
}
|
|
2039
|
-
if (filters.cursor !== undefined) {
|
|
2040
|
-
url.searchParams.set("cursor", filters.cursor);
|
|
2041
|
-
}
|
|
2042
|
-
if (filters.limit !== undefined) {
|
|
2043
|
-
url.searchParams.set("limit", String(filters.limit));
|
|
2044
|
-
}
|
|
2045
|
-
|
|
2046
|
-
const config: AxiosRequestConfig = {
|
|
2047
|
-
method: "get",
|
|
2048
|
-
url: url.toString(),
|
|
2049
|
-
headers: {
|
|
2050
|
-
Authorization: "Bearer " + token,
|
|
2051
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2052
|
-
},
|
|
2053
|
-
};
|
|
2054
|
-
const response = await axios(config);
|
|
2055
|
-
const responseData = response.data as
|
|
2056
|
-
| AuditEventsResponse
|
|
2057
|
-
| { data?: AuditEventsResponse };
|
|
2058
|
-
if (
|
|
2059
|
-
responseData &&
|
|
2060
|
-
typeof responseData === "object" &&
|
|
2061
|
-
"data" in responseData &&
|
|
2062
|
-
responseData.data !== undefined
|
|
2063
|
-
) {
|
|
2064
|
-
return responseData.data;
|
|
2065
|
-
}
|
|
2066
|
-
return responseData as AuditEventsResponse;
|
|
2067
|
-
} catch (e: any) {
|
|
2068
|
-
let message: string;
|
|
2069
|
-
if (e instanceof AxiosError) {
|
|
2070
|
-
message =
|
|
2071
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2072
|
-
JSON.stringify(e.response?.data) ??
|
|
2073
|
-
e.response?.statusText ??
|
|
2074
|
-
e?.message;
|
|
2075
|
-
} else {
|
|
2076
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2077
|
-
}
|
|
2078
|
-
throw new Error(`Could not fetch audit events: ${message}`);
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
|
|
2082
|
-
export interface IntegrationFilters {
|
|
2083
|
-
kind?: string[];
|
|
2084
|
-
slug?: string[];
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
export interface IntegrationSummary {
|
|
2088
|
-
id: string;
|
|
2089
|
-
name: string;
|
|
2090
|
-
pluginId: string;
|
|
2091
|
-
organizationId: string;
|
|
2092
|
-
kind: string;
|
|
2093
|
-
slug?: string;
|
|
2094
|
-
created: string;
|
|
2095
|
-
updated: string;
|
|
2096
|
-
}
|
|
2097
|
-
|
|
2098
|
-
export interface IntegrationDetail extends IntegrationSummary {
|
|
2099
|
-
configurations?: unknown[];
|
|
2100
|
-
demoIntegrationId?: string;
|
|
2101
|
-
enabledForV2?: boolean;
|
|
2102
|
-
isUserConfigured?: boolean;
|
|
2103
|
-
ownerEmail?: string;
|
|
2104
|
-
}
|
|
2105
|
-
|
|
2106
|
-
export interface IntegrationMutationPayload {
|
|
2107
|
-
[key: string]: unknown;
|
|
2108
|
-
}
|
|
2109
|
-
|
|
2110
|
-
export async function fetchIntegrations({
|
|
2111
|
-
cliVersion,
|
|
2112
|
-
token,
|
|
2113
|
-
superblocksBaseUrl,
|
|
2114
|
-
filters,
|
|
2115
|
-
}: {
|
|
2116
|
-
cliVersion: string;
|
|
2117
|
-
token: string;
|
|
2118
|
-
superblocksBaseUrl: string;
|
|
2119
|
-
filters?: IntegrationFilters;
|
|
2120
|
-
}): Promise<IntegrationSummary[]> {
|
|
2121
|
-
try {
|
|
2122
|
-
const url = new URL(
|
|
2123
|
-
`${BASE_SERVER_API_URL_V1}/integrations`,
|
|
2124
|
-
superblocksBaseUrl,
|
|
2125
|
-
);
|
|
2126
|
-
if (filters?.kind) {
|
|
2127
|
-
for (const k of filters.kind) {
|
|
2128
|
-
url.searchParams.append("kind", k);
|
|
2129
|
-
}
|
|
2130
|
-
}
|
|
2131
|
-
if (filters?.slug) {
|
|
2132
|
-
for (const s of filters.slug) {
|
|
2133
|
-
url.searchParams.append("slug", s);
|
|
2134
|
-
}
|
|
2135
|
-
}
|
|
2136
|
-
|
|
2137
|
-
const config: AxiosRequestConfig = {
|
|
2138
|
-
method: "get",
|
|
2139
|
-
url: url.toString(),
|
|
2140
|
-
headers: {
|
|
2141
|
-
Authorization: "Bearer " + token,
|
|
2142
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2143
|
-
},
|
|
2144
|
-
};
|
|
2145
|
-
const response = await axios(config);
|
|
2146
|
-
return response.data.data as IntegrationSummary[];
|
|
2147
|
-
} catch (e: any) {
|
|
2148
|
-
let message: string;
|
|
2149
|
-
if (e instanceof AxiosError) {
|
|
2150
|
-
message =
|
|
2151
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2152
|
-
JSON.stringify(e.response?.data) ??
|
|
2153
|
-
e.response?.statusText ??
|
|
2154
|
-
e?.message;
|
|
2155
|
-
} else {
|
|
2156
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2157
|
-
}
|
|
2158
|
-
throw new Error(`Could not fetch integrations: ${message}`);
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
|
|
2162
|
-
export async function fetchIntegrationById({
|
|
2163
|
-
cliVersion,
|
|
2164
|
-
token,
|
|
2165
|
-
superblocksBaseUrl,
|
|
2166
|
-
integrationId,
|
|
2167
|
-
}: {
|
|
2168
|
-
cliVersion: string;
|
|
2169
|
-
token: string;
|
|
2170
|
-
superblocksBaseUrl: string;
|
|
2171
|
-
integrationId: string;
|
|
2172
|
-
}): Promise<IntegrationDetail> {
|
|
2173
|
-
try {
|
|
2174
|
-
const url = new URL(
|
|
2175
|
-
`${BASE_SERVER_API_URL_V1}/integrations/${integrationId}`,
|
|
2176
|
-
superblocksBaseUrl,
|
|
2177
|
-
);
|
|
2178
|
-
const config: AxiosRequestConfig = {
|
|
2179
|
-
method: "get",
|
|
2180
|
-
url: url.toString(),
|
|
2181
|
-
headers: {
|
|
2182
|
-
Authorization: "Bearer " + token,
|
|
2183
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2184
|
-
},
|
|
2185
|
-
};
|
|
2186
|
-
const response = await axios(config);
|
|
2187
|
-
return response.data.data as IntegrationDetail;
|
|
2188
|
-
} catch (e: any) {
|
|
2189
|
-
let message: string;
|
|
2190
|
-
if (e instanceof AxiosError) {
|
|
2191
|
-
message =
|
|
2192
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2193
|
-
JSON.stringify(e.response?.data) ??
|
|
2194
|
-
e.response?.statusText ??
|
|
2195
|
-
e?.message;
|
|
2196
|
-
} else {
|
|
2197
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2198
|
-
}
|
|
2199
|
-
throw new Error(`Could not fetch integration: ${message}`);
|
|
2200
|
-
}
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2203
|
-
export async function createIntegration({
|
|
2204
|
-
cliVersion,
|
|
2205
|
-
token,
|
|
2206
|
-
superblocksBaseUrl,
|
|
2207
|
-
payload,
|
|
2208
|
-
}: {
|
|
2209
|
-
cliVersion: string;
|
|
2210
|
-
token: string;
|
|
2211
|
-
superblocksBaseUrl: string;
|
|
2212
|
-
payload: IntegrationMutationPayload;
|
|
2213
|
-
}): Promise<IntegrationDetail> {
|
|
2214
|
-
try {
|
|
2215
|
-
const url = new URL(
|
|
2216
|
-
`${BASE_SERVER_API_URL_V1}/integrations`,
|
|
2217
|
-
superblocksBaseUrl,
|
|
2218
|
-
);
|
|
2219
|
-
const config: AxiosRequestConfig = {
|
|
2220
|
-
method: "post",
|
|
2221
|
-
url: url.toString(),
|
|
2222
|
-
data: payload,
|
|
2223
|
-
headers: {
|
|
2224
|
-
Authorization: "Bearer " + token,
|
|
2225
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2226
|
-
},
|
|
2227
|
-
};
|
|
2228
|
-
const response = await axios(config);
|
|
2229
|
-
return response.data.data as IntegrationDetail;
|
|
2230
|
-
} catch (e: any) {
|
|
2231
|
-
let message: string;
|
|
2232
|
-
if (e instanceof AxiosError) {
|
|
2233
|
-
message =
|
|
2234
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2235
|
-
JSON.stringify(e.response?.data) ??
|
|
2236
|
-
e.response?.statusText ??
|
|
2237
|
-
e?.message;
|
|
2238
|
-
} else {
|
|
2239
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2240
|
-
}
|
|
2241
|
-
throw new Error(`Could not create integration: ${message}`);
|
|
2242
|
-
}
|
|
2243
|
-
}
|
|
2244
|
-
|
|
2245
|
-
export async function updateIntegration({
|
|
2246
|
-
cliVersion,
|
|
2247
|
-
token,
|
|
2248
|
-
superblocksBaseUrl,
|
|
2249
|
-
integrationId,
|
|
2250
|
-
payload,
|
|
2251
|
-
}: {
|
|
2252
|
-
cliVersion: string;
|
|
2253
|
-
token: string;
|
|
2254
|
-
superblocksBaseUrl: string;
|
|
2255
|
-
integrationId: string;
|
|
2256
|
-
payload: IntegrationMutationPayload;
|
|
2257
|
-
}): Promise<IntegrationDetail> {
|
|
2258
|
-
try {
|
|
2259
|
-
const url = new URL(
|
|
2260
|
-
`${BASE_SERVER_API_URL_V1}/integrations/${integrationId}`,
|
|
2261
|
-
superblocksBaseUrl,
|
|
2262
|
-
);
|
|
2263
|
-
const config: AxiosRequestConfig = {
|
|
2264
|
-
method: "put",
|
|
2265
|
-
url: url.toString(),
|
|
2266
|
-
data: payload,
|
|
2267
|
-
headers: {
|
|
2268
|
-
Authorization: "Bearer " + token,
|
|
2269
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2270
|
-
},
|
|
2271
|
-
};
|
|
2272
|
-
const response = await axios(config);
|
|
2273
|
-
return response.data.data as IntegrationDetail;
|
|
2274
|
-
} catch (e: any) {
|
|
2275
|
-
let message: string;
|
|
2276
|
-
if (e instanceof AxiosError) {
|
|
2277
|
-
message =
|
|
2278
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2279
|
-
JSON.stringify(e.response?.data) ??
|
|
2280
|
-
e.response?.statusText ??
|
|
2281
|
-
e?.message;
|
|
2282
|
-
} else {
|
|
2283
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2284
|
-
}
|
|
2285
|
-
throw new Error(`Could not update integration: ${message}`);
|
|
2286
|
-
}
|
|
2287
|
-
}
|
|
2288
|
-
|
|
2289
|
-
export async function deleteIntegration({
|
|
2290
|
-
cliVersion,
|
|
2291
|
-
token,
|
|
2292
|
-
superblocksBaseUrl,
|
|
2293
|
-
integrationId,
|
|
2294
|
-
}: {
|
|
2295
|
-
cliVersion: string;
|
|
2296
|
-
token: string;
|
|
2297
|
-
superblocksBaseUrl: string;
|
|
2298
|
-
integrationId: string;
|
|
2299
|
-
}): Promise<IntegrationDetail> {
|
|
2300
|
-
try {
|
|
2301
|
-
const url = new URL(
|
|
2302
|
-
`${BASE_SERVER_API_URL_V1}/integrations/${integrationId}`,
|
|
2303
|
-
superblocksBaseUrl,
|
|
2304
|
-
);
|
|
2305
|
-
const config: AxiosRequestConfig = {
|
|
2306
|
-
method: "delete",
|
|
2307
|
-
url: url.toString(),
|
|
2308
|
-
headers: {
|
|
2309
|
-
Authorization: "Bearer " + token,
|
|
2310
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2311
|
-
},
|
|
2312
|
-
};
|
|
2313
|
-
const response = await axios(config);
|
|
2314
|
-
return response.data.data as IntegrationDetail;
|
|
2315
|
-
} catch (e: any) {
|
|
2316
|
-
let message: string;
|
|
2317
|
-
if (e instanceof AxiosError) {
|
|
2318
|
-
message =
|
|
2319
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2320
|
-
JSON.stringify(e.response?.data) ??
|
|
2321
|
-
e.response?.statusText ??
|
|
2322
|
-
e?.message;
|
|
2323
|
-
} else {
|
|
2324
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2325
|
-
}
|
|
2326
|
-
throw new Error(`Could not delete integration: ${message}`);
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2329
|
-
|
|
2330
|
-
export interface FolderSummary {
|
|
2331
|
-
id: string;
|
|
2332
|
-
name: string;
|
|
2333
|
-
organizationId: string;
|
|
2334
|
-
totalResources?: number;
|
|
2335
|
-
updated?: string;
|
|
2336
|
-
}
|
|
2337
|
-
|
|
2338
|
-
export interface FolderMutationPayload {
|
|
2339
|
-
name: string;
|
|
2340
|
-
}
|
|
2341
|
-
|
|
2342
|
-
export async function fetchFolders({
|
|
2343
|
-
cliVersion,
|
|
2344
|
-
token,
|
|
2345
|
-
superblocksBaseUrl,
|
|
2346
|
-
}: {
|
|
2347
|
-
cliVersion: string;
|
|
2348
|
-
token: string;
|
|
2349
|
-
superblocksBaseUrl: string;
|
|
2350
|
-
}): Promise<FolderSummary[]> {
|
|
2351
|
-
try {
|
|
2352
|
-
const url = new URL(
|
|
2353
|
-
`${BASE_SERVER_API_URL_V1}/folders`,
|
|
2354
|
-
superblocksBaseUrl,
|
|
2355
|
-
);
|
|
2356
|
-
const config: AxiosRequestConfig = {
|
|
2357
|
-
method: "get",
|
|
2358
|
-
url: url.toString(),
|
|
2359
|
-
headers: {
|
|
2360
|
-
Authorization: "Bearer " + token,
|
|
2361
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2362
|
-
},
|
|
2363
|
-
};
|
|
2364
|
-
const response = await axios(config);
|
|
2365
|
-
return response.data.data as FolderSummary[];
|
|
2366
|
-
} catch (e: any) {
|
|
2367
|
-
let message: string;
|
|
2368
|
-
if (e instanceof AxiosError) {
|
|
2369
|
-
message =
|
|
2370
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2371
|
-
JSON.stringify(e.response?.data) ??
|
|
2372
|
-
e.response?.statusText ??
|
|
2373
|
-
e?.message;
|
|
2374
|
-
} else {
|
|
2375
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2376
|
-
}
|
|
2377
|
-
throw new Error(`Could not fetch folders: ${message}`);
|
|
2378
|
-
}
|
|
2379
|
-
}
|
|
2380
|
-
|
|
2381
|
-
export async function createFolder({
|
|
2382
|
-
cliVersion,
|
|
2383
|
-
token,
|
|
2384
|
-
superblocksBaseUrl,
|
|
2385
|
-
payload,
|
|
2386
|
-
}: {
|
|
2387
|
-
cliVersion: string;
|
|
2388
|
-
token: string;
|
|
2389
|
-
superblocksBaseUrl: string;
|
|
2390
|
-
payload: FolderMutationPayload;
|
|
2391
|
-
}): Promise<FolderSummary> {
|
|
2392
|
-
try {
|
|
2393
|
-
const url = new URL(
|
|
2394
|
-
`${BASE_SERVER_API_URL_V1}/folders`,
|
|
2395
|
-
superblocksBaseUrl,
|
|
2396
|
-
);
|
|
2397
|
-
const config: AxiosRequestConfig = {
|
|
2398
|
-
method: "post",
|
|
2399
|
-
url: url.toString(),
|
|
2400
|
-
data: { folder: payload },
|
|
2401
|
-
headers: {
|
|
2402
|
-
Authorization: "Bearer " + token,
|
|
2403
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2404
|
-
},
|
|
2405
|
-
};
|
|
2406
|
-
const response = await axios(config);
|
|
2407
|
-
return response.data.data as FolderSummary;
|
|
2408
|
-
} catch (e: any) {
|
|
2409
|
-
let message: string;
|
|
2410
|
-
if (e instanceof AxiosError) {
|
|
2411
|
-
message =
|
|
2412
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2413
|
-
JSON.stringify(e.response?.data) ??
|
|
2414
|
-
e.response?.statusText ??
|
|
2415
|
-
e?.message;
|
|
2416
|
-
} else {
|
|
2417
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2418
|
-
}
|
|
2419
|
-
throw new Error(`Could not create folder: ${message}`);
|
|
2420
|
-
}
|
|
2421
|
-
}
|
|
2422
|
-
|
|
2423
|
-
export async function updateFolder({
|
|
2424
|
-
cliVersion,
|
|
2425
|
-
token,
|
|
2426
|
-
superblocksBaseUrl,
|
|
2427
|
-
folderId,
|
|
2428
|
-
payload,
|
|
2429
|
-
}: {
|
|
2430
|
-
cliVersion: string;
|
|
2431
|
-
token: string;
|
|
2432
|
-
superblocksBaseUrl: string;
|
|
2433
|
-
folderId: string;
|
|
2434
|
-
payload: FolderMutationPayload;
|
|
2435
|
-
}): Promise<FolderSummary> {
|
|
2436
|
-
try {
|
|
2437
|
-
const url = new URL(
|
|
2438
|
-
`${BASE_SERVER_API_URL_V1}/folders/${folderId}`,
|
|
2439
|
-
superblocksBaseUrl,
|
|
2440
|
-
);
|
|
2441
|
-
const config: AxiosRequestConfig = {
|
|
2442
|
-
method: "put",
|
|
2443
|
-
url: url.toString(),
|
|
2444
|
-
data: { folder: payload },
|
|
2445
|
-
headers: {
|
|
2446
|
-
Authorization: "Bearer " + token,
|
|
2447
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2448
|
-
},
|
|
2449
|
-
};
|
|
2450
|
-
const response = await axios(config);
|
|
2451
|
-
return response.data.data as FolderSummary;
|
|
2452
|
-
} catch (e: any) {
|
|
2453
|
-
let message: string;
|
|
2454
|
-
if (e instanceof AxiosError) {
|
|
2455
|
-
message =
|
|
2456
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2457
|
-
JSON.stringify(e.response?.data) ??
|
|
2458
|
-
e.response?.statusText ??
|
|
2459
|
-
e?.message;
|
|
2460
|
-
} else {
|
|
2461
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2462
|
-
}
|
|
2463
|
-
throw new Error(`Could not update folder: ${message}`);
|
|
2464
|
-
}
|
|
2465
|
-
}
|
|
2466
|
-
|
|
2467
|
-
export async function deleteFolder({
|
|
2468
|
-
cliVersion,
|
|
2469
|
-
token,
|
|
2470
|
-
superblocksBaseUrl,
|
|
2471
|
-
folderId,
|
|
2472
|
-
}: {
|
|
2473
|
-
cliVersion: string;
|
|
2474
|
-
token: string;
|
|
2475
|
-
superblocksBaseUrl: string;
|
|
2476
|
-
folderId: string;
|
|
2477
|
-
}): Promise<FolderSummary> {
|
|
2478
|
-
try {
|
|
2479
|
-
const url = new URL(
|
|
2480
|
-
`${BASE_SERVER_API_URL_V1}/folders/${folderId}`,
|
|
2481
|
-
superblocksBaseUrl,
|
|
2482
|
-
);
|
|
2483
|
-
const config: AxiosRequestConfig = {
|
|
2484
|
-
method: "delete",
|
|
2485
|
-
url: url.toString(),
|
|
2486
|
-
headers: {
|
|
2487
|
-
Authorization: "Bearer " + token,
|
|
2488
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2489
|
-
},
|
|
2490
|
-
};
|
|
2491
|
-
const response = await axios(config);
|
|
2492
|
-
return response.data.data as FolderSummary;
|
|
2493
|
-
} catch (e: any) {
|
|
2494
|
-
let message: string;
|
|
2495
|
-
if (e instanceof AxiosError) {
|
|
2496
|
-
message =
|
|
2497
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2498
|
-
JSON.stringify(e.response?.data) ??
|
|
2499
|
-
e.response?.statusText ??
|
|
2500
|
-
e?.message;
|
|
2501
|
-
} else {
|
|
2502
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2503
|
-
}
|
|
2504
|
-
throw new Error(`Could not delete folder: ${message}`);
|
|
2505
|
-
}
|
|
2506
|
-
}
|
|
2507
|
-
|
|
2508
|
-
// ---------------------------------------------------------------------------
|
|
2509
|
-
// Billing
|
|
2510
|
-
// ---------------------------------------------------------------------------
|
|
2511
|
-
|
|
2512
|
-
export interface DailyUsageRow {
|
|
2513
|
-
date: string;
|
|
2514
|
-
creditsUsed: number;
|
|
2515
|
-
}
|
|
2516
|
-
|
|
2517
|
-
export interface UsageRecordRow {
|
|
2518
|
-
date: string;
|
|
2519
|
-
email: string;
|
|
2520
|
-
name: string;
|
|
2521
|
-
creditsUsed: number;
|
|
2522
|
-
source: string;
|
|
2523
|
-
}
|
|
2524
|
-
|
|
2525
|
-
export interface PlanSummary {
|
|
2526
|
-
billingInterval: "annual" | "monthly";
|
|
2527
|
-
currentPlanCredits: number;
|
|
2528
|
-
currentUsageCredits: number;
|
|
2529
|
-
cycleStart: string | null;
|
|
2530
|
-
cycleEnd: string | null;
|
|
2531
|
-
creditsPerSeat: number | null;
|
|
2532
|
-
pricePerSeatAnnual: number | null;
|
|
2533
|
-
pricePerSeatMonthly: number | null;
|
|
2534
|
-
deployedAppsUsed: number;
|
|
2535
|
-
deployedAppsLimit: number;
|
|
2536
|
-
deployedAppsIncluded: number;
|
|
2537
|
-
deployedAppsAdditional: number;
|
|
2538
|
-
deployedAppPriceMonthly: number | null;
|
|
2539
|
-
deployedAppPriceAnnual: number | null;
|
|
2540
|
-
}
|
|
2541
|
-
|
|
2542
|
-
export async function fetchBillingUsageDaily({
|
|
2543
|
-
cliVersion,
|
|
2544
|
-
token,
|
|
2545
|
-
superblocksBaseUrl,
|
|
2546
|
-
startDate,
|
|
2547
|
-
endDate,
|
|
2548
|
-
}: {
|
|
2549
|
-
cliVersion: string;
|
|
2550
|
-
token: string;
|
|
2551
|
-
superblocksBaseUrl: string;
|
|
2552
|
-
startDate: string;
|
|
2553
|
-
endDate: string;
|
|
2554
|
-
}): Promise<DailyUsageRow[]> {
|
|
2555
|
-
try {
|
|
2556
|
-
const url = new URL(
|
|
2557
|
-
`${BASE_SERVER_API_URL_V1}/billing/usage-daily`,
|
|
2558
|
-
superblocksBaseUrl,
|
|
2559
|
-
);
|
|
2560
|
-
url.searchParams.set("start", startDate);
|
|
2561
|
-
url.searchParams.set("end", endDate);
|
|
2562
|
-
|
|
2563
|
-
const config: AxiosRequestConfig = {
|
|
2564
|
-
method: "get",
|
|
2565
|
-
url: url.toString(),
|
|
2566
|
-
headers: {
|
|
2567
|
-
Authorization: "Bearer " + token,
|
|
2568
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2569
|
-
},
|
|
2570
|
-
};
|
|
2571
|
-
const response = await axios(config);
|
|
2572
|
-
return response.data.data.dailyUsage as DailyUsageRow[];
|
|
2573
|
-
} catch (e: any) {
|
|
2574
|
-
let message: string;
|
|
2575
|
-
if (e instanceof AxiosError) {
|
|
2576
|
-
message =
|
|
2577
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2578
|
-
JSON.stringify(e.response?.data) ??
|
|
2579
|
-
e.response?.statusText ??
|
|
2580
|
-
e?.message;
|
|
2581
|
-
} else {
|
|
2582
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2583
|
-
}
|
|
2584
|
-
throw new Error(`Could not fetch billing daily usage: ${message}`);
|
|
2585
|
-
}
|
|
2586
|
-
}
|
|
2587
|
-
|
|
2588
|
-
export async function fetchBillingUsageRecords({
|
|
2589
|
-
cliVersion,
|
|
2590
|
-
token,
|
|
2591
|
-
superblocksBaseUrl,
|
|
2592
|
-
startDate,
|
|
2593
|
-
endDate,
|
|
2594
|
-
}: {
|
|
2595
|
-
cliVersion: string;
|
|
2596
|
-
token: string;
|
|
2597
|
-
superblocksBaseUrl: string;
|
|
2598
|
-
startDate: string;
|
|
2599
|
-
endDate: string;
|
|
2600
|
-
}): Promise<UsageRecordRow[]> {
|
|
2601
|
-
try {
|
|
2602
|
-
const url = new URL(
|
|
2603
|
-
`${BASE_SERVER_API_URL_V1}/billing/usage-records`,
|
|
2604
|
-
superblocksBaseUrl,
|
|
2605
|
-
);
|
|
2606
|
-
url.searchParams.set("start", startDate);
|
|
2607
|
-
url.searchParams.set("end", endDate);
|
|
2608
|
-
|
|
2609
|
-
const config: AxiosRequestConfig = {
|
|
2610
|
-
method: "get",
|
|
2611
|
-
url: url.toString(),
|
|
2612
|
-
headers: {
|
|
2613
|
-
Authorization: "Bearer " + token,
|
|
2614
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2615
|
-
},
|
|
2616
|
-
};
|
|
2617
|
-
const response = await axios(config);
|
|
2618
|
-
return response.data.data.rows as UsageRecordRow[];
|
|
2619
|
-
} catch (e: any) {
|
|
2620
|
-
let message: string;
|
|
2621
|
-
if (e instanceof AxiosError) {
|
|
2622
|
-
message =
|
|
2623
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2624
|
-
JSON.stringify(e.response?.data) ??
|
|
2625
|
-
e.response?.statusText ??
|
|
2626
|
-
e?.message;
|
|
2627
|
-
} else {
|
|
2628
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2629
|
-
}
|
|
2630
|
-
throw new Error(`Could not fetch billing usage records: ${message}`);
|
|
2631
|
-
}
|
|
2632
|
-
}
|
|
2633
|
-
|
|
2634
|
-
export async function fetchBillingPlanSummary({
|
|
2635
|
-
cliVersion,
|
|
2636
|
-
token,
|
|
2637
|
-
superblocksBaseUrl,
|
|
2638
|
-
}: {
|
|
2639
|
-
cliVersion: string;
|
|
2640
|
-
token: string;
|
|
2641
|
-
superblocksBaseUrl: string;
|
|
2642
|
-
}): Promise<PlanSummary> {
|
|
2643
|
-
try {
|
|
2644
|
-
const url = new URL(
|
|
2645
|
-
`${BASE_SERVER_API_URL_V1}/billing/plan-summary`,
|
|
2646
|
-
superblocksBaseUrl,
|
|
2647
|
-
);
|
|
2648
|
-
|
|
2649
|
-
const config: AxiosRequestConfig = {
|
|
2650
|
-
method: "get",
|
|
2651
|
-
url: url.toString(),
|
|
2652
|
-
headers: {
|
|
2653
|
-
Authorization: "Bearer " + token,
|
|
2654
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2655
|
-
},
|
|
2656
|
-
};
|
|
2657
|
-
const response = await axios(config);
|
|
2658
|
-
return response.data.data as PlanSummary;
|
|
2659
|
-
} catch (e: any) {
|
|
2660
|
-
let message: string;
|
|
2661
|
-
if (e instanceof AxiosError) {
|
|
2662
|
-
message =
|
|
2663
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2664
|
-
JSON.stringify(e.response?.data) ??
|
|
2665
|
-
e.response?.statusText ??
|
|
2666
|
-
e?.message;
|
|
2667
|
-
} else {
|
|
2668
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2669
|
-
}
|
|
2670
|
-
throw new Error(`Could not fetch billing plan summary: ${message}`);
|
|
2671
|
-
}
|
|
2672
|
-
}
|
|
2673
|
-
|
|
2674
|
-
// ---------------------------------------------------------------------------
|
|
2675
|
-
// Knowledge (Facts)
|
|
2676
|
-
// ---------------------------------------------------------------------------
|
|
2677
|
-
|
|
2678
|
-
export async function fetchFacts({
|
|
2679
|
-
cliVersion,
|
|
2680
|
-
token,
|
|
2681
|
-
superblocksBaseUrl,
|
|
2682
|
-
query,
|
|
2683
|
-
}: {
|
|
2684
|
-
cliVersion: string;
|
|
2685
|
-
token: string;
|
|
2686
|
-
superblocksBaseUrl: string;
|
|
2687
|
-
query?: FactListQuery;
|
|
2688
|
-
}): Promise<FactDto[]> {
|
|
2689
|
-
try {
|
|
2690
|
-
const url = new URL(`${BASE_SERVER_API_URL_V1}/facts`, superblocksBaseUrl);
|
|
2691
|
-
if (query?.entityScope)
|
|
2692
|
-
url.searchParams.set("entityScope", query.entityScope);
|
|
2693
|
-
if (query?.entityId) url.searchParams.set("entityId", query.entityId);
|
|
2694
|
-
if (query?.accessType) url.searchParams.set("accessType", query.accessType);
|
|
2695
|
-
if (query?.isEnabled !== undefined)
|
|
2696
|
-
url.searchParams.set("isEnabled", String(query.isEnabled));
|
|
2697
|
-
if (query?.search) url.searchParams.set("search", query.search);
|
|
2698
|
-
if (query?.limit !== undefined)
|
|
2699
|
-
url.searchParams.set("limit", String(query.limit));
|
|
2700
|
-
if (query?.offset !== undefined)
|
|
2701
|
-
url.searchParams.set("offset", String(query.offset));
|
|
2702
|
-
if (query?.sortBy) url.searchParams.set("sortBy", query.sortBy);
|
|
2703
|
-
if (query?.sortOrder) url.searchParams.set("sortOrder", query.sortOrder);
|
|
2704
|
-
|
|
2705
|
-
const config: AxiosRequestConfig = {
|
|
2706
|
-
method: "get",
|
|
2707
|
-
url: url.toString(),
|
|
2708
|
-
headers: {
|
|
2709
|
-
Authorization: "Bearer " + token,
|
|
2710
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2711
|
-
},
|
|
2712
|
-
};
|
|
2713
|
-
const response = await axios(config);
|
|
2714
|
-
return response.data.data.facts as FactDto[];
|
|
2715
|
-
} catch (e: any) {
|
|
2716
|
-
let message: string;
|
|
2717
|
-
if (e instanceof AxiosError) {
|
|
2718
|
-
message =
|
|
2719
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2720
|
-
JSON.stringify(e.response?.data) ??
|
|
2721
|
-
e.response?.statusText ??
|
|
2722
|
-
e?.message;
|
|
2723
|
-
} else {
|
|
2724
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2725
|
-
}
|
|
2726
|
-
throw new Error(`Could not fetch knowledge entries: ${message}`);
|
|
2727
|
-
}
|
|
2728
|
-
}
|
|
2729
|
-
|
|
2730
|
-
export async function fetchFact({
|
|
2731
|
-
cliVersion,
|
|
2732
|
-
token,
|
|
2733
|
-
superblocksBaseUrl,
|
|
2734
|
-
factId,
|
|
2735
|
-
}: {
|
|
2736
|
-
cliVersion: string;
|
|
2737
|
-
token: string;
|
|
2738
|
-
superblocksBaseUrl: string;
|
|
2739
|
-
factId: string;
|
|
2740
|
-
}): Promise<FactDto> {
|
|
2741
|
-
try {
|
|
2742
|
-
const url = new URL(
|
|
2743
|
-
`${BASE_SERVER_API_URL_V1}/facts/${encodeURIComponent(factId)}`,
|
|
2744
|
-
superblocksBaseUrl,
|
|
2745
|
-
);
|
|
2746
|
-
|
|
2747
|
-
const config: AxiosRequestConfig = {
|
|
2748
|
-
method: "get",
|
|
2749
|
-
url: url.toString(),
|
|
2750
|
-
headers: {
|
|
2751
|
-
Authorization: "Bearer " + token,
|
|
2752
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2753
|
-
},
|
|
2754
|
-
};
|
|
2755
|
-
const response = await axios(config);
|
|
2756
|
-
return response.data.data as FactDto;
|
|
2757
|
-
} catch (e: any) {
|
|
2758
|
-
let message: string;
|
|
2759
|
-
if (e instanceof AxiosError) {
|
|
2760
|
-
message =
|
|
2761
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2762
|
-
JSON.stringify(e.response?.data) ??
|
|
2763
|
-
e.response?.statusText ??
|
|
2764
|
-
e?.message;
|
|
2765
|
-
} else {
|
|
2766
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2767
|
-
}
|
|
2768
|
-
throw new Error(`Could not fetch knowledge entry: ${message}`);
|
|
2769
|
-
}
|
|
2770
|
-
}
|
|
2771
|
-
|
|
2772
|
-
// ---------------------------------------------------------------------------
|
|
2773
|
-
// Audit entities
|
|
2774
|
-
// ---------------------------------------------------------------------------
|
|
2775
|
-
|
|
2776
|
-
export async function fetchAuditEntities({
|
|
2777
|
-
cliVersion,
|
|
2778
|
-
token,
|
|
2779
|
-
superblocksBaseUrl,
|
|
2780
|
-
}: {
|
|
2781
|
-
cliVersion: string;
|
|
2782
|
-
token: string;
|
|
2783
|
-
superblocksBaseUrl: string;
|
|
2784
|
-
}): Promise<AuditLogEntity[]> {
|
|
2785
|
-
try {
|
|
2786
|
-
const url = new URL(
|
|
2787
|
-
`${BASE_SERVER_API_URL_V2}/audit/entities`,
|
|
2788
|
-
superblocksBaseUrl,
|
|
2789
|
-
);
|
|
2790
|
-
|
|
2791
|
-
const config: AxiosRequestConfig = {
|
|
2792
|
-
method: "get",
|
|
2793
|
-
url: url.toString(),
|
|
2794
|
-
headers: {
|
|
2795
|
-
Authorization: "Bearer " + token,
|
|
2796
|
-
[CLI_VERSION_HEADER]: cliVersion,
|
|
2797
|
-
},
|
|
2798
|
-
};
|
|
2799
|
-
const response = await axios(config);
|
|
2800
|
-
return response.data.data as AuditLogEntity[];
|
|
2801
|
-
} catch (e: any) {
|
|
2802
|
-
let message: string;
|
|
2803
|
-
if (e instanceof AxiosError) {
|
|
2804
|
-
message =
|
|
2805
|
-
(e.response?.data?.responseMeta?.message as string) ??
|
|
2806
|
-
JSON.stringify(e.response?.data) ??
|
|
2807
|
-
e.response?.statusText ??
|
|
2808
|
-
e?.message;
|
|
2809
|
-
} else {
|
|
2810
|
-
message = `${e?.message ? e?.message : e}`;
|
|
2811
|
-
}
|
|
2812
|
-
throw new Error(`Could not fetch audit entities: ${message}`);
|
|
2813
|
-
}
|
|
2814
|
-
}
|
|
2815
|
-
|
|
2816
1633
|
function filesToFileDescriptors(files: string[], appRoot?: string) {
|
|
2817
1634
|
const fds = files.map((file) => {
|
|
2818
1635
|
const relativePath = appRoot ? path.relative(appRoot, file) : undefined;
|