@pronto-tools-and-more/network-process 4.1.0 → 4.2.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pronto-tools-and-more/network-process",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/networkProcessMain.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/archiver": "^6.0.2",
|
|
26
|
-
"@types/node": "^20.14.
|
|
26
|
+
"@types/node": "^20.14.10",
|
|
27
27
|
"jest": "^29.7.0"
|
|
28
28
|
},
|
|
29
29
|
"jest": {
|
|
@@ -2,6 +2,7 @@ import * as CreateZip from "../CreateZip/CreateZip.js";
|
|
|
2
2
|
import * as DownloadDiffFile from "../DownloadDiffFile/DownloadDiffFile.js";
|
|
3
3
|
import * as DownloadZipFile from "../DownloadZipFile/DownloadZipFile.js";
|
|
4
4
|
import * as ExtractZip from "../ExtractZip/ExtractZip.js";
|
|
5
|
+
import * as GetAllListContentZipFilesResponse from "../GetAllListContentZipFilesResponse/GetAllListContentZipFilesResponse.js";
|
|
5
6
|
import * as GetDiffSimpleResponse from "../GetDiffSimpleResponse/GetDiffSimpleResponse.js";
|
|
6
7
|
import * as GetListContentZipFilesResponse from "../GetListContentZipFilesResponse/GetListContentZipFilesResponse.js";
|
|
7
8
|
import * as GetListExperienceVersionsResponse from "../GetListExperienceVersionsResponse/GetListExperienceVersionsResponse.js";
|
|
@@ -17,6 +18,8 @@ export const commandMap = {
|
|
|
17
18
|
"Network.extractZip": ExtractZip.extractZip,
|
|
18
19
|
"Network.getListContentZipFilesResponse":
|
|
19
20
|
GetListContentZipFilesResponse.getListContentZipFilesResponse,
|
|
21
|
+
"Network.getAllListContentZipFilesResponse":
|
|
22
|
+
GetAllListContentZipFilesResponse.getAllListContentZipFilesResponse,
|
|
20
23
|
"Network.login": Login.login,
|
|
21
24
|
"Network.getListExperienceVersionsResponse":
|
|
22
25
|
GetListExperienceVersionsResponse.getListExperienceVersionsResponse,
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { VError } from "@lvce-editor/verror";
|
|
2
|
+
import ky from "ky";
|
|
3
|
+
import * as Assert from "../Assert/Assert.js";
|
|
4
|
+
import * as GetXr from "../GetXr/GetXr.js";
|
|
5
|
+
|
|
6
|
+
const getBodyJson = () => {
|
|
7
|
+
return {
|
|
8
|
+
pageNumber: 0,
|
|
9
|
+
pageSize: 99,
|
|
10
|
+
sortBy: "created",
|
|
11
|
+
sortDirection: "asc",
|
|
12
|
+
filters: [],
|
|
13
|
+
t: "cri",
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const getHeaders = () => {
|
|
18
|
+
const xr = GetXr.getXr();
|
|
19
|
+
return {
|
|
20
|
+
accept: "*/*",
|
|
21
|
+
"accept-language": "en,en-US;q=0.9",
|
|
22
|
+
"content-type": "application/json",
|
|
23
|
+
priority: "u=1, i",
|
|
24
|
+
"sec-ch-ua":
|
|
25
|
+
'"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
|
26
|
+
"sec-ch-ua-mobile": "?0",
|
|
27
|
+
"sec-ch-ua-platform": '"Linux"',
|
|
28
|
+
"sec-fetch-dest": "empty",
|
|
29
|
+
"sec-fetch-mode": "cors",
|
|
30
|
+
"sec-fetch-site": "same-origin",
|
|
31
|
+
xr,
|
|
32
|
+
// TODO
|
|
33
|
+
cookie: "",
|
|
34
|
+
Referer: "https://purplemanager.com/",
|
|
35
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const getAllListContentZipFilesResponse = async ({
|
|
40
|
+
listResourcesUrl,
|
|
41
|
+
sessionId,
|
|
42
|
+
appId,
|
|
43
|
+
}) => {
|
|
44
|
+
try {
|
|
45
|
+
Assert.string(listResourcesUrl);
|
|
46
|
+
const body = getBodyJson();
|
|
47
|
+
const headers = getHeaders();
|
|
48
|
+
const response = await ky(listResourcesUrl, {
|
|
49
|
+
json: body,
|
|
50
|
+
method: "post",
|
|
51
|
+
headers,
|
|
52
|
+
searchParams: {
|
|
53
|
+
appId,
|
|
54
|
+
sessionID: sessionId,
|
|
55
|
+
xr: headers.xr,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
const result = await response.json();
|
|
59
|
+
return result;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
if (error && error.name === "HTTPError") {
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
const serverMessage = await error.response.text();
|
|
65
|
+
if (serverMessage === "INTERNAL_ERROR") {
|
|
66
|
+
throw new Error(
|
|
67
|
+
"Failed to list content zip files: internal error. Hint: Check invalid credentials too many requests"
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
if (serverMessage) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`Failed to list content zip files: Server ${serverMessage}`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
throw new VError(error, `Failed to list content zip files`);
|
|
77
|
+
}
|
|
78
|
+
};
|