@webstudio-is/http-client 0.95.0 → 0.96.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/lib/index.js +7 -3
- package/package.json +4 -4
- package/lib/index.test.js +0 -52
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var loadProjectDataById = async (params) => {
|
|
3
3
|
const result = await getLatestBuildUsingProjectId(params);
|
|
4
4
|
if (result === null) {
|
|
5
5
|
throw new Error(``);
|
|
@@ -16,7 +16,7 @@ export const loadProjectDataById = async (params) => {
|
|
|
16
16
|
const message = await response.text();
|
|
17
17
|
throw new Error(message.slice(0, 1e3));
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
var getLatestBuildUsingProjectId = async (params) => {
|
|
20
20
|
const { host, projectId, authToken } = params;
|
|
21
21
|
const url = new URL(host);
|
|
22
22
|
url.pathname = `/rest/buildId/${projectId}`;
|
|
@@ -30,3 +30,7 @@ export const getLatestBuildUsingProjectId = async (params) => {
|
|
|
30
30
|
const message = await response.text();
|
|
31
31
|
throw new Error(message.slice(0, 1e3));
|
|
32
32
|
};
|
|
33
|
+
export {
|
|
34
|
+
getLatestBuildUsingProjectId,
|
|
35
|
+
loadProjectDataById
|
|
36
|
+
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/http-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.0",
|
|
4
4
|
"description": "Webstudio HTTP Client",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@webstudio-is/sdk": "^0.
|
|
9
|
+
"@webstudio-is/sdk": "^0.96.0"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@jest/globals": "^29.6.4",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"private": false,
|
|
30
30
|
"sideEffects": false,
|
|
31
31
|
"scripts": {
|
|
32
|
-
"dev": "
|
|
33
|
-
"build": "rm -rf lib && esbuild
|
|
32
|
+
"dev": "rm -rf lib && esbuild 'src/**/*.ts' 'src/**/*.tsx' --outdir=lib --watch",
|
|
33
|
+
"build": "rm -rf lib && esbuild src/index.ts --outdir=lib --bundle --format=esm --packages=external",
|
|
34
34
|
"dts": "tsc --project tsconfig.dts.json",
|
|
35
35
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
36
36
|
"typecheck": "tsc",
|
package/lib/index.test.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
import { describe, test, expect } from "@jest/globals";
|
|
3
|
-
import { loadProjectDataById } from "./index";
|
|
4
|
-
const existingProjectId = "675e8af3-48fa-4b18-9ebf-fd2b128865e2";
|
|
5
|
-
const notPublishedProjectId = "7ec397c6-b3d0-4967-9073-9d83623fcf8e";
|
|
6
|
-
const onlyHomeProjectId = "36d6c16f-04a0-45d4-ab1d-aa0ab61eb5b6";
|
|
7
|
-
const morePagesProjectId = existingProjectId;
|
|
8
|
-
const host = "http://localhost:3000";
|
|
9
|
-
describe("getProjectDetails", () => {
|
|
10
|
-
test("include pages", async () => {
|
|
11
|
-
const response = await loadProjectDataById({
|
|
12
|
-
host,
|
|
13
|
-
projectId: morePagesProjectId
|
|
14
|
-
});
|
|
15
|
-
if (typeof response === "object") {
|
|
16
|
-
return expect(response.pages.length).toBeTruthy();
|
|
17
|
-
}
|
|
18
|
-
throw new Error("Unexpected response");
|
|
19
|
-
});
|
|
20
|
-
test("does not include pages", async () => {
|
|
21
|
-
const response = await loadProjectDataById({
|
|
22
|
-
host,
|
|
23
|
-
projectId: onlyHomeProjectId
|
|
24
|
-
});
|
|
25
|
-
if (typeof response === "object") {
|
|
26
|
-
return expect(response.pages.length === 1).toBeTruthy();
|
|
27
|
-
}
|
|
28
|
-
throw new Error("Unexpected response");
|
|
29
|
-
});
|
|
30
|
-
test("loads existing project", async () => {
|
|
31
|
-
const response = await loadProjectDataById({
|
|
32
|
-
host,
|
|
33
|
-
projectId: existingProjectId
|
|
34
|
-
});
|
|
35
|
-
expect(response).toBeTruthy();
|
|
36
|
-
});
|
|
37
|
-
test("loads not published project", async () => {
|
|
38
|
-
const response = await loadProjectDataById({
|
|
39
|
-
host,
|
|
40
|
-
projectId: notPublishedProjectId
|
|
41
|
-
});
|
|
42
|
-
if (response instanceof Error) {
|
|
43
|
-
throw response;
|
|
44
|
-
}
|
|
45
|
-
if (typeof response === "string") {
|
|
46
|
-
return expect(response).toBe(
|
|
47
|
-
`Project ${notPublishedProjectId} not found or not published yet. Please contact us to get help.`
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
throw new Error("Unexpected response");
|
|
51
|
-
});
|
|
52
|
-
});
|