@webstudio-is/http-client 0.3.0 → 0.3.1

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.d.ts CHANGED
@@ -1,22 +1,6 @@
1
- import type { BaseInstance, UserProp } from "@webstudio-is/react-sdk";
2
- import type { Breakpoint } from "@webstudio-is/css-data";
3
- export declare type Page = {
4
- id: string;
5
- root: [string, string];
6
- };
7
- export declare type Project = {
8
- pages: {
9
- [path: string]: {
10
- page: Page;
11
- tree: BaseInstance;
12
- props: Array<UserProp> | [];
13
- breakpoints: Array<Breakpoint> | null;
14
- css: string;
15
- };
16
- };
17
- };
1
+ import type { CanvasData } from "@webstudio-is/project";
18
2
  export declare const loadProject: ({ apiUrl, projectId, }: {
19
3
  apiUrl: string;
20
4
  projectId: string;
21
- }) => Promise<Project | string>;
5
+ }) => Promise<Array<CanvasData> | string>;
22
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,oBAAY,IAAI,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxB,CAAC;AACF,oBAAY,OAAO,GAAG;IACpB,KAAK,EAAE;QACL,CAAC,IAAI,EAAE,MAAM,GAAG;YACd,IAAI,EAAE,IAAI,CAAC;YACX,IAAI,EAAE,YAAY,CAAC;YACnB,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YAC5B,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;YACtC,GAAG,EAAE,MAAM,CAAC;SACb,CAAC;KACH,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,WAAW;YAId,MAAM;eACH,MAAM;MACf,QAAQ,OAAO,GAAG,MAAM,CAmB3B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,eAAO,MAAM,WAAW;YAId,MAAM;eACH,MAAM;MACf,QAAQ,MAAM,UAAU,CAAC,GAAG,MAAM,CAmBrC,CAAC"}
package/lib/index.test.js CHANGED
@@ -12,11 +12,8 @@ describe("getProjectDetails", () => {
12
12
  apiUrl,
13
13
  projectId: morePagesProjectId,
14
14
  });
15
- if (response instanceof Error) {
16
- throw response;
17
- }
18
15
  if (typeof response === "object") {
19
- return expect(Object.keys(response.pages).length > 1).toBeTruthy();
16
+ return expect(response.length > 1).toBeTruthy();
20
17
  }
21
18
  throw new Error("Unexpected response");
22
19
  });
@@ -25,11 +22,8 @@ describe("getProjectDetails", () => {
25
22
  apiUrl,
26
23
  projectId: onlyHomeProjectId,
27
24
  });
28
- if (response instanceof Error) {
29
- throw response;
30
- }
31
25
  if (typeof response === "object") {
32
- return expect(Object.keys(response.pages).length === 1).toBeTruthy();
26
+ return expect(response.length === 1).toBeTruthy();
33
27
  }
34
28
  throw new Error("Unexpected response");
35
29
  });
@@ -45,6 +39,12 @@ describe("getProjectDetails", () => {
45
39
  apiUrl,
46
40
  projectId: notPublishedProjectId,
47
41
  });
48
- expect(response.toString()).toBe(`Project ${notPublishedProjectId} not found or not published yet. Please contact us to get help.`);
42
+ if (response instanceof Error) {
43
+ throw response;
44
+ }
45
+ if (typeof response === "string") {
46
+ return expect(response).toBe(`Project ${notPublishedProjectId} not found or not published yet. Please contact us to get help.`);
47
+ }
48
+ throw new Error("Unexpected response");
49
49
  });
50
50
  });
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@webstudio-is/http-client",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Webstudio HTTP Client",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
7
7
  "scripts": {
8
8
  "dev": "tsup --watch",
9
- "test": "jest",
9
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
10
10
  "build": "rm -fr lib tsconfig.tsbuildinfo && tsc",
11
11
  "typecheck": "tsc --noEmit",
12
12
  "lint": "eslint ./src --ext .ts,.tsx --max-warnings 0",
@@ -16,7 +16,7 @@
16
16
  "@types/isomorphic-fetch": "^0.0.36",
17
17
  "@webstudio-is/jest-config": "*",
18
18
  "@webstudio-is/prisma-client": "*",
19
- "@webstudio-is/react-sdk": "*",
19
+ "@webstudio-is/project": "*",
20
20
  "tsup": "^6.1.3",
21
21
  "typescript": "4.7.4"
22
22
  },