@pronto-tools-and-more/network-process 3.11.1 → 3.12.2
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 +1 -1
- package/src/parts/CommandMap/CommandMap.js +11 -0
- package/src/parts/DownloadDiffFile/DownloadDiffFile.js +50 -0
- package/src/parts/GetDiffSimpleResponse/GetDiffSimpleResponse.js +58 -0
- package/src/parts/GetListExperienceVersionsResponse/GetListExperienceVersionsResponse.js +55 -0
- package/src/parts/MakeUpgradeRequest/MakeUpgradeRequest.js +60 -0
- package/src/parts/PullWorkingCopy/PullWorkingCopy.js +56 -0
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import * as CreateZip from "../CreateZip/CreateZip.js";
|
|
2
|
+
import * as DownloadDiffFile from "../DownloadDiffFile/DownloadDiffFile.js";
|
|
2
3
|
import * as DownloadZipFile from "../DownloadZipFile/DownloadZipFile.js";
|
|
3
4
|
import * as ExtractZip from "../ExtractZip/ExtractZip.js";
|
|
5
|
+
import * as GetDiffSimpleResponse from "../GetDiffSimpleResponse/GetDiffSimpleResponse.js";
|
|
4
6
|
import * as GetListContentZipFilesResponse from "../GetListContentZipFilesResponse/GetListContentZipFilesResponse.js";
|
|
7
|
+
import * as GetListExperienceVersionsResponse from "../GetListExperienceVersionsResponse/GetListExperienceVersionsResponse.js";
|
|
5
8
|
import * as Login from "../Login/Login.js";
|
|
9
|
+
import * as MakeUpgradeRequest from "../MakeUpgradeRequest/MakeUpgradeRequest.js";
|
|
10
|
+
import * as PullWorkingCopy from "../PullWorkingCopy/PullWorkingCopy.js";
|
|
6
11
|
import * as UploadZip from "../UploadZip/UploadZip.js";
|
|
7
12
|
|
|
8
13
|
export const commandMap = {
|
|
@@ -13,4 +18,10 @@ export const commandMap = {
|
|
|
13
18
|
"Network.getListContentZipFilesResponse":
|
|
14
19
|
GetListContentZipFilesResponse.getListContentZipFilesResponse,
|
|
15
20
|
"Network.login": Login.login,
|
|
21
|
+
"Network.getListExperienceVersionsResponse":
|
|
22
|
+
GetListExperienceVersionsResponse.getListExperienceVersionsResponse,
|
|
23
|
+
"Network.makeUpgradeRequest": MakeUpgradeRequest.makeUpgradeRequest,
|
|
24
|
+
"Network.getDiffSimpleResponse": GetDiffSimpleResponse.getDiffSimpleResponse,
|
|
25
|
+
"Network.downloadDiffFile": DownloadDiffFile.downloadDiffFile,
|
|
26
|
+
"Network.pullWorkingCopy": PullWorkingCopy.pullWorkingCopy,
|
|
16
27
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { VError } from "@lvce-editor/verror";
|
|
2
|
+
import ky from "ky";
|
|
3
|
+
import * as GetXr from "../GetXr/GetXr.js";
|
|
4
|
+
|
|
5
|
+
const getHeaders = () => {
|
|
6
|
+
const xr = GetXr.getXr();
|
|
7
|
+
return {
|
|
8
|
+
accept: "*/*",
|
|
9
|
+
"accept-language": "en,en-US;q=0.9",
|
|
10
|
+
"content-type": "application/json",
|
|
11
|
+
priority: "u=1, i",
|
|
12
|
+
"sec-ch-ua":
|
|
13
|
+
'"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
|
14
|
+
"sec-ch-ua-mobile": "?0",
|
|
15
|
+
"sec-ch-ua-platform": '"Linux"',
|
|
16
|
+
"sec-fetch-dest": "empty",
|
|
17
|
+
"sec-fetch-mode": "cors",
|
|
18
|
+
"sec-fetch-site": "same-origin",
|
|
19
|
+
xr,
|
|
20
|
+
// TODO
|
|
21
|
+
cookie: "",
|
|
22
|
+
Referer: "https://purplemanager.com/",
|
|
23
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const downloadDiffFile = async ({
|
|
28
|
+
diffFile,
|
|
29
|
+
downloadFileBaseUrl,
|
|
30
|
+
sessionId,
|
|
31
|
+
appId,
|
|
32
|
+
}) => {
|
|
33
|
+
try {
|
|
34
|
+
const absolutePath = `${downloadFileBaseUrl}${diffFile}`;
|
|
35
|
+
const headers = getHeaders();
|
|
36
|
+
const response = await ky(absolutePath, {
|
|
37
|
+
method: "get",
|
|
38
|
+
headers,
|
|
39
|
+
searchParams: {
|
|
40
|
+
appId,
|
|
41
|
+
sessionID: sessionId,
|
|
42
|
+
xr: headers.xr,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
const result = await response.text();
|
|
46
|
+
return result;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
throw new VError(error, `Failed to download file`);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
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 getHeaders = () => {
|
|
7
|
+
const xr = GetXr.getXr();
|
|
8
|
+
return {
|
|
9
|
+
accept: "*/*",
|
|
10
|
+
"accept-language": "en,en-US;q=0.9",
|
|
11
|
+
"content-type": "application/json",
|
|
12
|
+
priority: "u=1, i",
|
|
13
|
+
"sec-ch-ua":
|
|
14
|
+
'"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
|
15
|
+
"sec-ch-ua-mobile": "?0",
|
|
16
|
+
"sec-ch-ua-platform": '"Linux"',
|
|
17
|
+
"sec-fetch-dest": "empty",
|
|
18
|
+
"sec-fetch-mode": "cors",
|
|
19
|
+
"sec-fetch-site": "same-origin",
|
|
20
|
+
xr,
|
|
21
|
+
// TODO
|
|
22
|
+
cookie: "",
|
|
23
|
+
Referer: "https://purplemanager.com/",
|
|
24
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const getDiffSimpleResponse = async ({
|
|
29
|
+
diffSimpleUrl,
|
|
30
|
+
sessionId,
|
|
31
|
+
appId,
|
|
32
|
+
}) => {
|
|
33
|
+
try {
|
|
34
|
+
Assert.string(diffSimpleUrl);
|
|
35
|
+
const headers = getHeaders();
|
|
36
|
+
const response = await ky(diffSimpleUrl, {
|
|
37
|
+
method: "get",
|
|
38
|
+
headers,
|
|
39
|
+
searchParams: {
|
|
40
|
+
appId,
|
|
41
|
+
sessionID: sessionId,
|
|
42
|
+
xr: headers.xr,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
const result = await response.json();
|
|
46
|
+
return result;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
if (error && error.name === "HTTPError") {
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
const serverMessage = await error.response.text();
|
|
52
|
+
if (serverMessage) {
|
|
53
|
+
throw new Error(`Failed to get simple diff: Server ${serverMessage}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
throw new VError(error, `Failed to get simple diff`);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { VError } from "@lvce-editor/verror";
|
|
2
|
+
import ky from "ky";
|
|
3
|
+
import * as Assert from "../Assert/Assert.js";
|
|
4
|
+
|
|
5
|
+
const getHeaders = () => {
|
|
6
|
+
return {
|
|
7
|
+
accept: "*/*",
|
|
8
|
+
"accept-language": "en,en-US;q=0.9",
|
|
9
|
+
"content-type": "application/json",
|
|
10
|
+
priority: "u=1, i",
|
|
11
|
+
"sec-ch-ua":
|
|
12
|
+
'"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
|
13
|
+
"sec-ch-ua-mobile": "?0",
|
|
14
|
+
"sec-ch-ua-platform": '"Linux"',
|
|
15
|
+
"sec-fetch-dest": "empty",
|
|
16
|
+
"sec-fetch-mode": "cors",
|
|
17
|
+
"sec-fetch-site": "same-origin",
|
|
18
|
+
// TODO
|
|
19
|
+
cookie: "",
|
|
20
|
+
Referer: "https://purplemanager.com/",
|
|
21
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const getListExperienceVersionsResponse = async ({
|
|
26
|
+
listVersionsUrl,
|
|
27
|
+
sessionId,
|
|
28
|
+
appId,
|
|
29
|
+
}) => {
|
|
30
|
+
try {
|
|
31
|
+
Assert.string(listVersionsUrl);
|
|
32
|
+
const headers = getHeaders();
|
|
33
|
+
const response = await ky(listVersionsUrl, {
|
|
34
|
+
method: "get",
|
|
35
|
+
headers,
|
|
36
|
+
searchParams: {
|
|
37
|
+
sessionID: sessionId,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const result = await response.json();
|
|
41
|
+
return result;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
if (error && error.name === "HTTPError") {
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
const serverMessage = await error.response.text();
|
|
47
|
+
if (serverMessage) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`Failed to list experience versions: Server ${serverMessage}`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
throw new VError(error, `Failed to experience versions`);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
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 = (targetVersion) => {
|
|
7
|
+
return {
|
|
8
|
+
targetVersion,
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const getHeaders = () => {
|
|
13
|
+
const xr = GetXr.getXr();
|
|
14
|
+
return {
|
|
15
|
+
accept: "*/*",
|
|
16
|
+
"accept-language": "en,en-US;q=0.9",
|
|
17
|
+
"content-type": "application/json",
|
|
18
|
+
priority: "u=1, i",
|
|
19
|
+
"sec-ch-ua":
|
|
20
|
+
'"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
|
21
|
+
"sec-ch-ua-mobile": "?0",
|
|
22
|
+
"sec-ch-ua-platform": '"Linux"',
|
|
23
|
+
"sec-fetch-dest": "empty",
|
|
24
|
+
"sec-fetch-mode": "cors",
|
|
25
|
+
"sec-fetch-site": "same-origin",
|
|
26
|
+
xr,
|
|
27
|
+
// TODO
|
|
28
|
+
cookie: "",
|
|
29
|
+
Referer: "https://purplemanager.com/",
|
|
30
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const makeUpgradeRequest = async ({
|
|
35
|
+
appsUrl,
|
|
36
|
+
appId,
|
|
37
|
+
targetVersion,
|
|
38
|
+
sessionId,
|
|
39
|
+
}) => {
|
|
40
|
+
try {
|
|
41
|
+
Assert.string(appsUrl);
|
|
42
|
+
Assert.string(appId);
|
|
43
|
+
Assert.string(targetVersion);
|
|
44
|
+
const absoluteUrl = `${appsUrl}/${appId}/upgrade`;
|
|
45
|
+
const body = getBodyJson(targetVersion);
|
|
46
|
+
const headers = getHeaders();
|
|
47
|
+
await ky(absoluteUrl, {
|
|
48
|
+
json: body,
|
|
49
|
+
method: "post",
|
|
50
|
+
headers,
|
|
51
|
+
searchParams: {
|
|
52
|
+
appId,
|
|
53
|
+
sessionID: sessionId,
|
|
54
|
+
xr: headers.xr,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
} catch (error) {
|
|
58
|
+
throw new VError(error, `Upgrade request failed`);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
};
|
|
9
|
+
|
|
10
|
+
const getHeaders = () => {
|
|
11
|
+
const xr = GetXr.getXr();
|
|
12
|
+
return {
|
|
13
|
+
accept: "*/*",
|
|
14
|
+
"accept-language": "en,en-US;q=0.9",
|
|
15
|
+
"content-type": "application/json",
|
|
16
|
+
priority: "u=1, i",
|
|
17
|
+
"sec-ch-ua":
|
|
18
|
+
'"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
|
19
|
+
"sec-ch-ua-mobile": "?0",
|
|
20
|
+
"sec-ch-ua-platform": '"Linux"',
|
|
21
|
+
"sec-fetch-dest": "empty",
|
|
22
|
+
"sec-fetch-mode": "cors",
|
|
23
|
+
"sec-fetch-site": "same-origin",
|
|
24
|
+
xr,
|
|
25
|
+
// TODO
|
|
26
|
+
cookie: "",
|
|
27
|
+
Referer: "https://purplemanager.com/",
|
|
28
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const pullWorkingCopy = async ({
|
|
33
|
+
pullWorkingCopyUrl,
|
|
34
|
+
sessionId,
|
|
35
|
+
appId,
|
|
36
|
+
}) => {
|
|
37
|
+
try {
|
|
38
|
+
Assert.string(pullWorkingCopyUrl);
|
|
39
|
+
Assert.string(appId);
|
|
40
|
+
Assert.string(sessionId);
|
|
41
|
+
const body = getBodyJson();
|
|
42
|
+
const headers = getHeaders();
|
|
43
|
+
await ky(pullWorkingCopyUrl, {
|
|
44
|
+
json: body,
|
|
45
|
+
method: "post",
|
|
46
|
+
headers,
|
|
47
|
+
searchParams: {
|
|
48
|
+
appId,
|
|
49
|
+
sessionID: sessionId,
|
|
50
|
+
xr: headers.xr,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
} catch (error) {
|
|
54
|
+
throw new VError(error, `Pull working copy request failed`);
|
|
55
|
+
}
|
|
56
|
+
};
|