@supernova-studio/client 0.55.33 → 0.55.34

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": "@supernova-studio/client",
3
- "version": "0.55.33",
3
+ "version": "0.55.34",
4
4
  "description": "Supernova Data Models",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,60 @@
1
+ import {
2
+ DataSourceAutoImportMode,
3
+ DataSourceFigmaScope,
4
+ DataSourceRemoteType,
5
+ ImportJobState,
6
+ } from "@supernova-studio/model";
7
+ import { z } from "zod";
8
+
9
+ //
10
+ // Read
11
+ //
12
+
13
+ export const DTOImportJob = z.object({
14
+ id: z.string(),
15
+ designSystemId: z.string(),
16
+ designSystemVersionId: z.string(),
17
+ operation: z.literal("Import"),
18
+ createdAt: z.coerce.date(),
19
+ stateChangedAt: z.coerce.date(),
20
+ state: ImportJobState,
21
+ sourceIds: z.string().array(),
22
+ });
23
+
24
+ export const DTOImportJobResponse = z.object({
25
+ job: DTOImportJob,
26
+ });
27
+
28
+ export type DTOImportJob = z.infer<typeof DTOImportJob>;
29
+ export type DTOImportJobResponse = z.infer<typeof DTOImportJobResponse>;
30
+
31
+ //
32
+ // Write
33
+ //
34
+
35
+ export const DTOBffFigmaImportRequestBody = z.object({
36
+ type: z.literal(DataSourceRemoteType.Enum.Figma),
37
+ brandPersistentId: z.string().optional(),
38
+ fileId: z.string(),
39
+ scope: DataSourceFigmaScope,
40
+ autoImportMode: DataSourceAutoImportMode,
41
+ });
42
+
43
+ export const DTOBffUploadImportRequestBody = z.object({
44
+ type: z
45
+ .enum([DataSourceRemoteType.Enum.FigmaVariablesPlugin, "Upload"])
46
+ .transform(v => DataSourceRemoteType.Enum.FigmaVariablesPlugin),
47
+ brandPersistentId: z.string().optional(),
48
+ sourceName: z.string().optional(),
49
+ remoteId: z.string(),
50
+ payload: z.any(),
51
+ });
52
+
53
+ export const DTOBffImportRequestBody = z.discriminatedUnion("type", [
54
+ DTOBffFigmaImportRequestBody,
55
+ DTOBffUploadImportRequestBody,
56
+ ]);
57
+
58
+ export type DTOBffFigmaImportRequestBody = z.infer<typeof DTOBffFigmaImportRequestBody>;
59
+ export type DTOBffUploadImportRequestBody = z.infer<typeof DTOBffUploadImportRequestBody>;
60
+ export type DTOBffImportRequestBody = z.infer<typeof DTOBffImportRequestBody>;
@@ -3,6 +3,7 @@ export * from "./data-source";
3
3
  export * from "./design-system";
4
4
  export * from "./elements-diff";
5
5
  export * from "./exporter-property";
6
+ export * from "./import-job";
6
7
  export * from "./members";
7
8
  export * from "./role";
8
9
  export * from "./stats";
@@ -0,0 +1,13 @@
1
+ import { DTOBffImportRequestBody, DTOImportJobResponse } from "../../dto";
2
+ import { RequestExecutor } from "../../transport/request-executor";
3
+
4
+ export class DesignSystemBffEndpoint {
5
+ constructor(private readonly requestExecutor: RequestExecutor) {}
6
+
7
+ import(dsId: string, payload: DTOBffImportRequestBody) {
8
+ return this.requestExecutor.json(`/design-systems/${dsId}/bff/import`, DTOImportJobResponse, {
9
+ method: "POST",
10
+ body: payload,
11
+ });
12
+ }
13
+ }
@@ -2,17 +2,19 @@ import { z } from "zod";
2
2
  import { DTODesignSystemCreateInput, DTODesignSystemResponse, DTODesignSystemsListResponse } from "../../dto";
3
3
  import { DTODesignSystemUpdateAccessModeInput, DTODesignSystemUpdateInput } from "../../payloads";
4
4
  import { RequestExecutor } from "../../transport/request-executor";
5
- import { DesignSystemMembersEndpoint } from "./design-system-members";
6
- import { DesignSystemVersionsEndpoint } from "./design-system-versions";
7
- import { TokensEndpoint } from "./versions";
5
+ import { DesignSystemBffEndpoint } from "./bff";
6
+ import { DesignSystemMembersEndpoint } from "./members";
7
+ import { DesignSystemVersionsEndpoint } from "./versions";
8
8
 
9
9
  export class DesignSystemsEndpoint {
10
10
  readonly members: DesignSystemMembersEndpoint;
11
11
  readonly versions: DesignSystemVersionsEndpoint;
12
+ readonly bff: DesignSystemBffEndpoint;
12
13
 
13
14
  constructor(private readonly requestExecutor: RequestExecutor) {
14
15
  this.members = new DesignSystemMembersEndpoint(requestExecutor);
15
16
  this.versions = new DesignSystemVersionsEndpoint(requestExecutor);
17
+ this.bff = new DesignSystemBffEndpoint(requestExecutor);
16
18
  }
17
19
 
18
20
  create(body: DTODesignSystemCreateInput) {
@@ -1,4 +1,5 @@
1
1
  export * from "./versions";
2
- export * from "./design-system-members";
3
- export * from "./design-system-versions";
2
+ export * from "./bff";
4
3
  export * from "./design-systems";
4
+ export * from "./members";
5
+ export * from "./versions";
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import { DTOBrandGetResponse, DTOBrandsListResponse } from "../../../dto";
2
2
  import { RequestExecutor } from "../../../transport/request-executor";
3
3
 
4
4
  export class BrandsEndpoint {
@@ -7,11 +7,14 @@ export class BrandsEndpoint {
7
7
  get(designSystemId: string, versionId: string, brandId: string) {
8
8
  return this.requestExecutor.json(
9
9
  `/design-systems/${designSystemId}/versions/${versionId}/brands/${brandId}`,
10
- z.any()
10
+ DTOBrandGetResponse
11
11
  );
12
12
  }
13
13
 
14
14
  list(designSystemId: string, versionId: string) {
15
- return this.requestExecutor.json(`/design-systems/${designSystemId}/versions/${versionId}/brands`, z.any());
15
+ return this.requestExecutor.json(
16
+ `/design-systems/${designSystemId}/versions/${versionId}/brands`,
17
+ DTOBrandsListResponse
18
+ );
16
19
  }
17
20
  }
@@ -0,0 +1,13 @@
1
+ import { DTOImportJobResponse } from "../../../dto";
2
+ import { RequestExecutor } from "../../../transport/request-executor";
3
+
4
+ export class ImportJobsEndpoint {
5
+ constructor(private readonly requestExecutor: RequestExecutor) {}
6
+
7
+ get(designSystemId: string, versionId: string, jobId: string) {
8
+ return this.requestExecutor.json(
9
+ `/design-systems/${designSystemId}/versions/${versionId}/import-jobs/${jobId}`,
10
+ DTOImportJobResponse
11
+ );
12
+ }
13
+ }
@@ -1,4 +1,5 @@
1
1
  export * from "./brands";
2
+ export * from "./import-jobs";
2
3
  export * from "./overrides";
3
4
  export * from "./stats";
4
5
  export * from "./themes";
@@ -1,18 +1,22 @@
1
1
  import { DTODesignSystemVersionsListResponse } from "../../dto";
2
2
  import { RequestExecutor } from "../../transport/request-executor";
3
- import { TokensEndpoint, VersionStatsEndpoint } from "./versions";
4
3
  import { BrandsEndpoint } from "./versions/brands";
4
+ import { ImportJobsEndpoint } from "./versions/import-jobs";
5
+ import { VersionStatsEndpoint } from "./versions/stats";
5
6
  import { ThemesEndpoint } from "./versions/themes";
7
+ import { TokensEndpoint } from "./versions/tokens";
6
8
 
7
9
  export class DesignSystemVersionsEndpoint {
8
10
  readonly themes: ThemesEndpoint;
9
11
  readonly brands: BrandsEndpoint;
12
+ readonly importJobs: ImportJobsEndpoint;
10
13
  readonly tokens: TokensEndpoint;
11
14
  readonly stats: VersionStatsEndpoint;
12
15
 
13
16
  constructor(private readonly requestExecutor: RequestExecutor) {
14
17
  this.themes = new ThemesEndpoint(requestExecutor);
15
18
  this.brands = new BrandsEndpoint(requestExecutor);
19
+ this.importJobs = new ImportJobsEndpoint(requestExecutor);
16
20
  this.tokens = new TokensEndpoint(requestExecutor);
17
21
  this.stats = new VersionStatsEndpoint(requestExecutor);
18
22
  }