@webstudio-is/http-client 0.270.0 → 0.272.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  // src/index.ts
2
2
  import { createTRPCUntypedClient, httpBatchLink } from "@trpc/client";
3
+ import {
4
+ importProjectBundleResultSchema,
5
+ publishedProjectBundleSchema
6
+ } from "@webstudio-is/protocol";
7
+ import {
8
+ getBundleVersion,
9
+ isAssetFileDataString,
10
+ bundleVersion
11
+ } from "@webstudio-is/protocol";
3
12
  var createTrpcClient = (origin, headers) => {
4
13
  const { sourceOrigin } = parseBuilderUrl(origin);
5
14
  const url = new URL("/trpc", sourceOrigin);
@@ -12,22 +21,48 @@ var createTrpcClient = (origin, headers) => {
12
21
  ]
13
22
  });
14
23
  };
15
- var loadProjectDataByBuildId = async (params) => {
16
- const headers = "seviceToken" in params ? { Authorization: params.seviceToken } : { "x-auth-token": params.authToken };
17
- return await createTrpcClient(params.origin, {
24
+ var createAuthTrpcClient = (params) => createTrpcClient(params.origin, {
25
+ ...params.headers,
26
+ "x-auth-token": params.authToken
27
+ });
28
+ var loadProjectBundleByBuildId = async (params) => {
29
+ const headers = "serviceToken" in params ? { Authorization: params.serviceToken } : { "x-auth-token": params.authToken };
30
+ const data = await createTrpcClient(params.origin, {
18
31
  ...params.headers,
19
32
  ...headers
20
- }).query("build.loadProjectDataByBuildId", {
33
+ }).query("build.loadProjectBundleByBuildId", {
21
34
  buildId: params.buildId
22
35
  });
36
+ return publishedProjectBundleSchema.parse(data);
23
37
  };
24
- var loadProjectDataByProjectId = async (params) => {
25
- return await createTrpcClient(params.origin, {
26
- ...params.headers,
27
- "x-auth-token": params.authToken
28
- }).query("build.loadProjectDataByProjectId", {
29
- projectId: params.projectId
30
- });
38
+ var loadProjectBundleByProjectId = async (params) => {
39
+ const data = await createAuthTrpcClient(params).query(
40
+ "build.loadProjectBundleByProjectId",
41
+ {
42
+ projectId: params.projectId
43
+ }
44
+ );
45
+ return publishedProjectBundleSchema.parse(data);
46
+ };
47
+ var checkProjectBuildPermission = async (params) => {
48
+ await createAuthTrpcClient(params).query(
49
+ "build.checkProjectBuildPermission",
50
+ {
51
+ projectId: params.projectId
52
+ }
53
+ );
54
+ };
55
+ var importProjectBundle = async (params) => {
56
+ const result = await createAuthTrpcClient(params).mutation(
57
+ "build.importProjectBundle",
58
+ {
59
+ projectId: params.projectId,
60
+ data: params.data,
61
+ assetFiles: params.assetFiles,
62
+ ignoreVersionCheck: params.ignoreVersionCheck
63
+ }
64
+ );
65
+ return importProjectBundleResultSchema.parse(result);
31
66
  };
32
67
  var buildProjectDomainPrefix = "p-";
33
68
  var parseBuilderUrl = (urlStr) => {
@@ -60,7 +95,12 @@ var parseBuilderUrl = (urlStr) => {
60
95
  };
61
96
  };
62
97
  export {
63
- loadProjectDataByBuildId,
64
- loadProjectDataByProjectId,
98
+ bundleVersion,
99
+ checkProjectBuildPermission,
100
+ getBundleVersion,
101
+ importProjectBundle,
102
+ isAssetFileDataString,
103
+ loadProjectBundleByBuildId,
104
+ loadProjectBundleByProjectId,
65
105
  parseBuilderUrl
66
106
  };
@@ -1,44 +1,36 @@
1
- import type { Asset, Breakpoint, DataSource, Deployment, Instance, Page, Prop, Resource, StyleDecl, StyleDeclKey, StyleSource, StyleSourceSelection } from "@webstudio-is/sdk";
2
- import type { SerializedPages } from "@webstudio-is/project-migrations/pages";
3
- export type Data = {
4
- page: Page;
5
- pages: Array<Page>;
6
- build: {
7
- id: string;
8
- projectId: string;
9
- version: number;
10
- createdAt: string;
11
- updatedAt: string;
12
- pages: SerializedPages;
13
- breakpoints: [Breakpoint["id"], Breakpoint][];
14
- styles: [StyleDeclKey, StyleDecl][];
15
- styleSources: [StyleSource["id"], StyleSource][];
16
- styleSourceSelections: [Instance["id"], StyleSourceSelection][];
17
- props: [Prop["id"], Prop][];
18
- instances: [Instance["id"], Instance][];
19
- dataSources: [DataSource["id"], DataSource][];
20
- resources: [Resource["id"], Resource][];
21
- deployment?: Deployment | undefined;
22
- };
23
- assets: Array<Asset>;
24
- projectDomain?: string;
25
- origin?: string;
26
- };
27
- export declare const loadProjectDataByBuildId: (params: {
1
+ import { type AssetFileData, type ImportProjectBundleResult, type PublishedProjectBundle } from "@webstudio-is/protocol";
2
+ export { getBundleVersion, isAssetFileDataString, bundleVersion, } from "@webstudio-is/protocol";
3
+ export type { AssetFileData, PublishedProjectBundle, ProjectBundle, } from "@webstudio-is/protocol";
4
+ export declare const loadProjectBundleByBuildId: (params: {
28
5
  buildId: string;
29
6
  origin: string;
30
7
  headers?: Record<string, string | undefined>;
31
8
  } & ({
32
- seviceToken: string;
9
+ serviceToken: string;
33
10
  } | {
34
11
  authToken: string;
35
- })) => Promise<Data>;
36
- export declare const loadProjectDataByProjectId: (params: {
12
+ })) => Promise<PublishedProjectBundle>;
13
+ export declare const loadProjectBundleByProjectId: (params: {
14
+ projectId: string;
15
+ origin: string;
16
+ authToken: string;
17
+ headers?: Record<string, string | undefined>;
18
+ }) => Promise<PublishedProjectBundle>;
19
+ export declare const checkProjectBuildPermission: (params: {
20
+ projectId: string;
21
+ origin: string;
22
+ authToken: string;
23
+ headers?: Record<string, string | undefined>;
24
+ }) => Promise<void>;
25
+ export declare const importProjectBundle: (params: {
37
26
  projectId: string;
38
27
  origin: string;
39
28
  authToken: string;
29
+ data: PublishedProjectBundle;
30
+ assetFiles?: AssetFileData[];
31
+ ignoreVersionCheck?: boolean;
40
32
  headers?: Record<string, string | undefined>;
41
- }) => Promise<Data>;
33
+ }) => Promise<ImportProjectBundleResult>;
42
34
  export declare const parseBuilderUrl: (urlStr: string) => {
43
35
  projectId: undefined;
44
36
  sourceOrigin: string;
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "@webstudio-is/http-client",
3
- "version": "0.270.0",
3
+ "version": "0.272.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
9
  "@trpc/client": "^10.45.2",
10
- "@webstudio-is/project-migrations": "0.270.0",
11
- "@webstudio-is/sdk": "0.270.0"
10
+ "@webstudio-is/protocol": "0.272.0"
12
11
  },
13
12
  "devDependencies": {
14
13
  "vitest": "^3.1.2",