@supernova-studio/client 0.57.5 → 0.57.6

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.57.5",
3
+ "version": "0.57.6",
4
4
  "description": "Supernova Data Models",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -1,13 +1,17 @@
1
1
  import { DesignTokenOrigin, DesignTokenTypedData, ObjectMeta } from "@supernova-studio/model";
2
2
  import { z } from "zod";
3
3
 
4
+ //
5
+ // Read
6
+ //
7
+
4
8
  export const DTODesignToken = DesignTokenTypedData.and(
5
9
  z.object({
6
10
  id: z.string(),
7
11
  persistentId: z.string(),
8
12
  designSystemVersionId: z.string(),
9
13
  meta: ObjectMeta,
10
- origin: DesignTokenOrigin.optional(),
14
+ originStyle: DesignTokenOrigin.optional(),
11
15
  brandId: z.string(),
12
16
  updatedAt: z.coerce.date(),
13
17
  })
@@ -17,5 +21,25 @@ export const DTODesignTokenListResponse = z.object({
17
21
  tokens: DTODesignToken.array(),
18
22
  });
19
23
 
24
+ export const DTODesignTokenResponse = z.object({
25
+ token: DTODesignToken,
26
+ });
27
+
20
28
  export type DTODesignToken = z.infer<typeof DTODesignToken>;
29
+ export type DTODesignTokenResponse = z.infer<typeof DTODesignTokenResponse>;
21
30
  export type DTODesignTokenListResponse = z.infer<typeof DTODesignTokenListResponse>;
31
+
32
+ //
33
+ // Write
34
+ //
35
+
36
+ export const DTODesignTokenCreatePayload = DesignTokenTypedData.and(
37
+ z.object({
38
+ persistentId: z.string(),
39
+ meta: ObjectMeta,
40
+ brandId: z.string(),
41
+ groupPersistentId: z.string().optional(),
42
+ })
43
+ );
44
+
45
+ export type DTODesignTokenCreatePayload = z.infer<typeof DTODesignTokenCreatePayload>;
@@ -8,5 +8,6 @@ export * from "./elements";
8
8
  export * from "./export";
9
9
  export * from "./figma-components";
10
10
  export * from "./liveblocks";
11
+ export * from "./themes";
11
12
  export * from "./users";
12
13
  export * from "./workspaces";
@@ -0,0 +1,2 @@
1
+ export * from "./override";
2
+ export * from "./theme";
@@ -0,0 +1,27 @@
1
+ import { DesignTokenTypedData, ThemeOverrideOrigin } from "@supernova-studio/model";
2
+ import { z } from "zod";
3
+
4
+ //
5
+ // Read
6
+ //
7
+
8
+ export const DTOThemeOverride = DesignTokenTypedData.and(
9
+ z.object({
10
+ tokenPersistentId: z.string(),
11
+ origin: ThemeOverrideOrigin.optional(),
12
+ })
13
+ );
14
+
15
+ export type DTOThemeOverride = z.infer<typeof DTOThemeOverride>;
16
+
17
+ //
18
+ // Write
19
+ //
20
+
21
+ export const DTOThemeOverrideCreatePayload = DesignTokenTypedData.and(
22
+ z.object({
23
+ tokenPersistentId: z.string(),
24
+ })
25
+ );
26
+
27
+ export type DTOThemeOverrideCreatePayload = z.infer<typeof DTOThemeOverrideCreatePayload>;
@@ -0,0 +1,45 @@
1
+ import { ObjectMeta } from "@supernova-studio/model";
2
+ import { z } from "zod";
3
+ import { DTOThemeOverride } from "./override";
4
+
5
+ //
6
+ // Read
7
+ //
8
+
9
+ export const DTOTheme = z.object({
10
+ id: z.string(),
11
+ persistentId: z.string(),
12
+ designSystemVersionId: z.string(),
13
+ brandId: z.string(),
14
+
15
+ meta: ObjectMeta,
16
+ codeName: z.string(),
17
+
18
+ overrides: DTOThemeOverride.array(),
19
+ });
20
+
21
+ export const DTOThemeResponse = z.object({
22
+ theme: DTOTheme,
23
+ });
24
+
25
+ export const DTOThemeListResponse = z.object({
26
+ themes: DTOTheme.array(),
27
+ });
28
+
29
+ export type DTOTheme = z.infer<typeof DTOTheme>;
30
+ export type DTOThemeResponse = z.infer<typeof DTOThemeResponse>;
31
+ export type DTOThemeListResponse = z.infer<typeof DTOThemeListResponse>;
32
+
33
+ //
34
+ // Write
35
+ //
36
+
37
+ export const DTOThemeCreatePayload = z.object({
38
+ meta: ObjectMeta,
39
+ persistentId: z.string(),
40
+ brandId: z.string(),
41
+ codeName: z.string(),
42
+ overrides: DTOThemeOverride.array(),
43
+ });
44
+
45
+ export type DTOThemeCreatePayload = z.infer<typeof DTOThemeCreatePayload>;
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
+ import { DTOThemeCreatePayload, DTOThemeListResponse, DTOThemeResponse } from "../../../dto";
2
3
  import { RequestExecutor } from "../../../transport/request-executor";
3
4
  import { OverridesEndpoint } from "./overrides";
4
- import { DTOCreateThemeInput } from "../../../payloads/design-systems/theme";
5
5
 
6
6
  export class ThemesEndpoint {
7
7
  readonly overrides: OverridesEndpoint;
@@ -9,8 +9,19 @@ export class ThemesEndpoint {
9
9
  this.overrides = new OverridesEndpoint(requestExecutor);
10
10
  }
11
11
 
12
- create(dsId: string, versionId: string, body: DTOCreateThemeInput) {
13
- return this.requestExecutor.json(`/design-systems/${dsId}/versions/${versionId}/themes`, z.any(), {
12
+ list(dsId: string, versionId: string) {
13
+ return this.requestExecutor.json(`/design-systems/${dsId}/versions/${versionId}/themes`, DTOThemeListResponse);
14
+ }
15
+
16
+ get(dsId: string, versionId: string, themeId: string) {
17
+ return this.requestExecutor.json(
18
+ `/design-systems/${dsId}/versions/${versionId}/themes/${themeId}`,
19
+ DTOThemeResponse
20
+ );
21
+ }
22
+
23
+ create(dsId: string, versionId: string, body: DTOThemeCreatePayload) {
24
+ return this.requestExecutor.json(`/design-systems/${dsId}/versions/${versionId}/themes`, DTOThemeResponse, {
14
25
  method: "POST",
15
26
  body,
16
27
  });
@@ -1,12 +1,11 @@
1
- import { z } from "zod";
2
- import { DTODesignTokenListResponse } from "../../../dto";
1
+ import { DTODesignTokenCreatePayload, DTODesignTokenListResponse, DTODesignTokenResponse } from "../../../dto";
3
2
  import { RequestExecutor } from "../../../transport/request-executor";
4
3
 
5
4
  export class TokensEndpoint {
6
5
  constructor(private readonly requestExecutor: RequestExecutor) {}
7
6
 
8
- create(dsId: string, versionId: string, body: any) {
9
- return this.requestExecutor.json(`/design-systems/${dsId}/versions/${versionId}/tokens`, z.any(), {
7
+ create(dsId: string, versionId: string, body: DTODesignTokenCreatePayload) {
8
+ return this.requestExecutor.json(`/design-systems/${dsId}/versions/${versionId}/tokens`, DTODesignTokenResponse, {
10
9
  method: "POST",
11
10
  body,
12
11
  });
@@ -18,4 +17,11 @@ export class TokensEndpoint {
18
17
  DTODesignTokenListResponse
19
18
  );
20
19
  }
20
+
21
+ get(dsId: string, versionId: string, tokenId: string): Promise<DTODesignTokenListResponse> {
22
+ return this.requestExecutor.json(
23
+ `/design-systems/${dsId}/versions/${versionId}/tokens/${tokenId}`,
24
+ DTODesignTokenListResponse
25
+ );
26
+ }
21
27
  }
@@ -1,4 +1,3 @@
1
1
  export * from "./brand";
2
- export * from "./theme";
3
2
  export * from "./update-design-system";
4
3
  export * from "./version";
@@ -1,14 +0,0 @@
1
- import { ObjectMeta } from "@supernova-studio/model";
2
- import { z } from "zod";
3
-
4
- export const DTOCreateThemeInput = z.object({
5
- meta: ObjectMeta,
6
- persistentId: z.string(),
7
- designSystemVersionId: z.string(),
8
- brandId: z.string(),
9
- codeName: z.string(),
10
- version: z.string().optional(),
11
- overrides: z.array(z.any()), // TODO Add actual overrides.
12
- });
13
-
14
- export type DTOCreateThemeInput = z.infer<typeof DTOCreateThemeInput>;