@supernova-studio/client 0.40.0 → 0.44.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.
Files changed (45) hide show
  1. package/dist/index.d.mts +8731 -2798
  2. package/dist/index.d.ts +8731 -2798
  3. package/dist/index.js +398 -85
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +1135 -822
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +1 -1
  8. package/src/api/conversion/design-systems/elements/properties/property-definition.ts +1 -1
  9. package/src/api/conversion/design-systems/elements/properties/property-value.ts +1 -1
  10. package/src/api/conversion/documentation/documentation-group-v2-to-dto.ts +4 -11
  11. package/src/api/conversion/documentation/documentation-item-configuration-v1-to-dto.ts +4 -0
  12. package/src/api/conversion/documentation/documentation-item-configuration-v2-to-dto.ts +32 -0
  13. package/src/api/conversion/documentation/documentation-page-v2-to-dto.ts +4 -5
  14. package/src/api/conversion/documentation/index.ts +1 -0
  15. package/src/api/conversion/index.ts +1 -0
  16. package/src/api/conversion/integrations/index.ts +1 -0
  17. package/src/api/conversion/integrations/integration.ts +12 -0
  18. package/src/api/dto/design-systems/brand.ts +5 -0
  19. package/src/api/dto/design-systems/design-system.ts +2 -0
  20. package/src/api/dto/design-systems/exporter-property.ts +8 -0
  21. package/src/api/dto/design-systems/index.ts +1 -0
  22. package/src/api/dto/documentation/anchor.ts +15 -0
  23. package/src/api/dto/documentation/index.ts +1 -0
  24. package/src/api/dto/elements/documentation/group-v2.ts +11 -12
  25. package/src/api/dto/elements/documentation/index.ts +2 -0
  26. package/src/api/dto/elements/documentation/item-configuration-v1.ts +2 -0
  27. package/src/api/dto/elements/documentation/item-configuration-v2.ts +14 -0
  28. package/src/api/dto/elements/documentation/page-content.ts +15 -0
  29. package/src/api/dto/elements/documentation/page-v2.ts +13 -13
  30. package/src/api/dto/elements/elements-action-v2.ts +30 -12
  31. package/src/api/dto/elements/properties/index.ts +1 -0
  32. package/src/api/dto/elements/properties/property-definitions-actions-v2.ts +53 -0
  33. package/src/api/dto/elements/properties/property-definitions.ts +38 -3
  34. package/src/api/dto/workspaces/index.ts +1 -0
  35. package/src/api/dto/workspaces/integrations.ts +27 -0
  36. package/src/api/payloads/design-systems/brand.ts +11 -0
  37. package/src/api/payloads/design-systems/index.ts +2 -0
  38. package/src/api/payloads/design-systems/version.ts +18 -0
  39. package/src/api/payloads/index.ts +1 -0
  40. package/src/api/payloads/liveblocks/auth.ts +1 -1
  41. package/src/api/payloads/workspaces/index.ts +1 -0
  42. package/src/api/payloads/workspaces/workspace-integrations.ts +8 -0
  43. package/src/yjs/design-system-content/item-configuration.ts +14 -9
  44. package/src/yjs/docs-editor/blocks-to-prosemirror.ts +11 -5
  45. package/src/yjs/docs-editor/prosemirror-to-blocks.ts +9 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supernova-studio/client",
3
- "version": "0.40.0",
3
+ "version": "0.44.0",
4
4
  "description": "Supernova Data Models",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -1,5 +1,5 @@
1
1
  import { ElementPropertyDefinition } from "@supernova-studio/model";
2
- import { DTOElementPropertyDefinition } from "packages/client/src/api/dto/elements/properties/property-definitions";
2
+ import { DTOElementPropertyDefinition } from "packages/client/src/api/dto";
3
3
 
4
4
  export function elementPropertyDefinitionToDto(
5
5
  elementProperyDefinition: ElementPropertyDefinition
@@ -1,5 +1,5 @@
1
1
  import { ElementPropertyValue } from "@supernova-studio/model";
2
- import { DTOElementPropertyValue } from "packages/client/src/api/dto/elements/properties/property-values";
2
+ import { DTOElementPropertyValue } from "packages/client/src/api/dto";
3
3
 
4
4
  export function elementPropertyValueToDto(elementPropertyValue: ElementPropertyValue): DTOElementPropertyValue {
5
5
  let value: string | number | boolean | undefined;
@@ -1,11 +1,6 @@
1
- import {
2
- defaultDocumentationItemHeaderV2,
3
- DocumentationPageV1,
4
- DocumentationPageV2,
5
- ElementGroup,
6
- groupBy,
7
- } from "@supernova-studio/model";
1
+ import { DocumentationPageV1, DocumentationPageV2, ElementGroup, groupBy } from "@supernova-studio/model";
8
2
  import { DTODocumentationGroupStructureV2, DTODocumentationGroupV2 } from "../../dto";
3
+ import { documentationItemConfigurationToDTOV2 } from "./documentation-item-configuration-v2-to-dto";
9
4
 
10
5
  // The fact that DTO conversion is located here instead of main backend code is due to the fact
11
6
  // that we store page and group data in YJS documents in the same way as they are stored in the database.
@@ -31,10 +26,7 @@ export function elementGroupsToDocumentationGroupDTOV2(
31
26
  return groups.map(group => {
32
27
  return {
33
28
  ...elementGroupToDocumentationGroupStructureDTOV2(group, childrenIdsMap),
34
- configuration: group.data?.configuration ?? {
35
- showSidebar: true,
36
- header: defaultDocumentationItemHeaderV2,
37
- },
29
+ configuration: documentationItemConfigurationToDTOV2(group.data?.configuration),
38
30
  };
39
31
  });
40
32
  }
@@ -58,6 +50,7 @@ function elementGroupToDocumentationGroupStructureDTOV2(
58
50
  createdAt: group.createdAt,
59
51
  updatedAt: group.updatedAt,
60
52
  title: group.meta.name,
53
+ configuration: documentationItemConfigurationToDTOV2(group?.data?.configuration),
61
54
  childrenIds: childrenIds,
62
55
  isRoot: !group.parentPersistentId,
63
56
  groupBehavior: group.data?.behavior ?? "Group",
@@ -8,6 +8,8 @@ import { DTODocumentationItemConfigurationV1 } from "../../dto";
8
8
 
9
9
  export const dtoDefaultItemConfigurationV1: DTODocumentationItemConfigurationV1 = {
10
10
  showSidebar: true,
11
+ isHidden: false,
12
+ isPrivate: false,
11
13
  header: {
12
14
  alignment: DocumentationItemHeaderAlignment.Left,
13
15
  backgroundImageScaleType: DocumentationItemHeaderImageScaleType.AspectFill,
@@ -26,6 +28,8 @@ export function documentationItemConfigurationToDTOV1(
26
28
 
27
29
  return {
28
30
  showSidebar,
31
+ isHidden: config.isHidden ?? dtoDefaultItemConfigurationV1.isHidden,
32
+ isPrivate: config.isPrivate ?? dtoDefaultItemConfigurationV1.isPrivate,
29
33
  header: {
30
34
  ...headerRest,
31
35
  backgroundColor: colorToDTOV1(backgroundColor ?? undefined),
@@ -0,0 +1,32 @@
1
+ import {
2
+ DocumentationItemConfigurationV2,
3
+ DocumentationItemHeaderAlignment,
4
+ DocumentationItemHeaderImageScaleType,
5
+ } from "@supernova-studio/model";
6
+ import { DTODocumentationItemConfigurationV2 } from "../../dto/elements/documentation/item-configuration-v2";
7
+
8
+ const dtoDefaultItemConfigurationV2: DTODocumentationItemConfigurationV2 = {
9
+ showSidebar: true,
10
+ isHidden: false,
11
+ isPrivate: false,
12
+ header: {
13
+ alignment: DocumentationItemHeaderAlignment.Left,
14
+ backgroundImageScaleType: DocumentationItemHeaderImageScaleType.AspectFill,
15
+ description: "",
16
+ showBackgroundOverlay: false,
17
+ showCoverText: true,
18
+ },
19
+ };
20
+
21
+ export function documentationItemConfigurationToDTOV2(
22
+ config: DocumentationItemConfigurationV2 | undefined
23
+ ): DTODocumentationItemConfigurationV2 {
24
+ if (!config) return dtoDefaultItemConfigurationV2;
25
+
26
+ return {
27
+ header: config.header,
28
+ isHidden: config.isHidden ?? dtoDefaultItemConfigurationV2.isPrivate,
29
+ isPrivate: config.isPrivate ?? dtoDefaultItemConfigurationV2.isPrivate,
30
+ showSidebar: config.showSidebar,
31
+ };
32
+ }
@@ -1,5 +1,6 @@
1
- import { DocumentationPageV2, ElementGroup, defaultDocumentationItemHeaderV2 } from "@supernova-studio/model";
1
+ import { DocumentationPageV2, ElementGroup } from "@supernova-studio/model";
2
2
  import { DTODocumentationPageStructureV2, DTODocumentationPageV2 } from "../../dto";
3
+ import { documentationItemConfigurationToDTOV2 } from "./documentation-item-configuration-v2-to-dto";
3
4
  import { buildDocPagePublishPaths } from "./documentation-page-to-dto-utils";
4
5
 
5
6
  // The fact that DTO conversion is located here instead of main backend code is due to the fact
@@ -27,10 +28,7 @@ export function documentationPagesToDTOV2(
27
28
  return pages.map(page => {
28
29
  return {
29
30
  ...documentationPageToStructureDTOV2(page, pathsMap),
30
- configuration: page.data.configuration ?? {
31
- showSidebar: true,
32
- header: defaultDocumentationItemHeaderV2,
33
- },
31
+ configuration: documentationItemConfigurationToDTOV2(page.data.configuration),
34
32
  };
35
33
  });
36
34
  }
@@ -52,6 +50,7 @@ function documentationPageToStructureDTOV2(
52
50
  title: page.meta.name,
53
51
  slug: page.slug,
54
52
  userSlug: page.userSlug,
53
+ configuration: documentationItemConfigurationToDTOV2(page.data.configuration),
55
54
  createdAt: page.createdAt,
56
55
  updatedAt: page.updatedAt,
57
56
  path: path,
@@ -2,6 +2,7 @@ export * from "./documentation-elements-to-hierarchy-v2-dto";
2
2
  export * from "./documentation-group-v1-to-dto";
3
3
  export * from "./documentation-group-v2-to-dto";
4
4
  export * from "./documentation-item-configuration-v1-to-dto";
5
+ export * from "./documentation-item-configuration-v2-to-dto";
5
6
  export * from "./documentation-page-to-dto-utils";
6
7
  export * from "./documentation-page-v1-to-dto";
7
8
  export * from "./documentation-page-v2-to-dto";
@@ -1,3 +1,4 @@
1
1
  export * from "./design-system";
2
2
  export * from "./design-systems";
3
3
  export * from "./documentation";
4
+ export * from "./integrations";
@@ -0,0 +1 @@
1
+ export * from "./integration";
@@ -0,0 +1,12 @@
1
+ import { Integration } from "@supernova-studio/model";
2
+ import { DTOIntegration } from "../../dto";
3
+
4
+ export function integrationToDto(integration: Integration): DTOIntegration {
5
+ return {
6
+ id: integration.id,
7
+ workspaceId: integration.workspaceId,
8
+ type: integration.type,
9
+ createdAt: integration.createdAt,
10
+ integrationCredentials: integration.integrationCredentials ?? undefined,
11
+ };
12
+ }
@@ -10,8 +10,13 @@ export const DTOBrand = z.object({
10
10
 
11
11
  export const DTOBrandGetResponse = z.object({ brand: DTOBrand });
12
12
 
13
+ export const DTOBrandCreateResponse = z.object({
14
+ brand: DTOBrand,
15
+ });
16
+
13
17
  export const DTOBrandsListResponse = z.object({ brands: z.array(DTOBrand) });
14
18
 
15
19
  export type DTOBrand = z.infer<typeof DTOBrand>;
16
20
  export type DTOBrandGetResponse = z.infer<typeof DTOBrandGetResponse>;
21
+ export type DTOBrandCreateResponse = z.infer<typeof DTOBrandCreateResponse>;
17
22
  export type DTOBrandsListResponse = z.infer<typeof DTOBrandsListResponse>;
@@ -8,8 +8,10 @@ import { z } from "zod";
8
8
  export const DTODesignSystem = DesignSystem.omit({
9
9
  name: true,
10
10
  description: true,
11
+ docExporterId: true,
11
12
  }).extend({
12
13
  meta: ObjectMeta,
14
+ docExporterId: z.string(),
13
15
  });
14
16
 
15
17
  export type DTODesignSystem = z.infer<typeof DTODesignSystem>;
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+
3
+ export const DTOExporterProperty = z.any({});
4
+
5
+ export const DTOExporterPropertyListResponse = z.object({ items: z.array(DTOExporterProperty) });
6
+
7
+ export type DTOExporterProperty = z.infer<typeof DTOExporterProperty>;
8
+ export type DTOExporterPropertyListResponse = z.infer<typeof DTOExporterPropertyListResponse>;
@@ -1,4 +1,5 @@
1
1
  export * from "./brand";
2
2
  export * from "./design-system";
3
+ export * from "./exporter-property";
3
4
  export * from "./version";
4
5
  export * from "./view";
@@ -0,0 +1,15 @@
1
+ import { DocumentationPageAnchor } from "@supernova-studio/model";
2
+ import { z } from "zod";
3
+
4
+ //
5
+ // Read
6
+ //
7
+
8
+ export const DTODocumentationPageAnchor = DocumentationPageAnchor;
9
+
10
+ export const DTOGetDocumentationPageAnchorsResponse = z.object({
11
+ anchors: z.array(DTODocumentationPageAnchor),
12
+ });
13
+
14
+ export type DTODocumentationPageAnchor = z.infer<typeof DTODocumentationPageAnchor>;
15
+ export type DTOGetDocumentationPageAnchorsResponse = z.infer<typeof DTOGetDocumentationPageAnchorsResponse>;
@@ -1 +1,2 @@
1
+ export * from "./anchor";
1
2
  export * from "./link-preview";
@@ -1,5 +1,6 @@
1
+ import { DocumentationGroupBehavior, ElementGroup } from "@supernova-studio/model";
1
2
  import { z } from "zod";
2
- import { DocumentationGroupBehavior, DocumentationItemConfigurationV2, ElementGroup } from "@supernova-studio/model";
3
+ import { DTODocumentationItemConfigurationV2 } from "./item-configuration-v2";
3
4
 
4
5
  //
5
6
  // Read
@@ -9,7 +10,7 @@ import { DocumentationGroupBehavior, DocumentationItemConfigurationV2, ElementGr
9
10
  * Structure DTO is element properties minus element data (in other words data required
10
11
  * to display the element in the left panel)
11
12
  */
12
- export const DTODocumentationGroupStructureV2 = ElementGroup.omit({
13
+ export const DTODocumentationGroupV2 = ElementGroup.omit({
13
14
  sortOrder: true,
14
15
  parentPersistentId: true,
15
16
  brandPersistentId: true,
@@ -23,15 +24,13 @@ export const DTODocumentationGroupStructureV2 = ElementGroup.omit({
23
24
  childrenIds: z.array(z.string()),
24
25
  groupBehavior: DocumentationGroupBehavior,
25
26
  shortPersistentId: z.string(),
27
+ configuration: DTODocumentationItemConfigurationV2,
26
28
  type: z.literal("Group"),
27
29
  });
28
30
 
29
- export const DTODocumentationGroupV2 = DTODocumentationGroupStructureV2.extend({
30
- configuration: DocumentationItemConfigurationV2,
31
- });
32
-
33
- export type DTODocumentationGroupStructureV2 = z.infer<typeof DTODocumentationGroupStructureV2>;
34
31
  export type DTODocumentationGroupV2 = z.infer<typeof DTODocumentationGroupV2>;
32
+ export const DTODocumentationGroupStructureV2 = DTODocumentationGroupV2;
33
+ export type DTODocumentationGroupStructureV2 = DTODocumentationGroupV2;
35
34
 
36
35
  //
37
36
  // Write
@@ -43,10 +42,10 @@ export const DTOCreateDocumentationGroupInput = z.object({
43
42
 
44
43
  // Group properties
45
44
  title: z.string(),
46
- configuration: DocumentationItemConfigurationV2.optional(),
45
+ configuration: DTODocumentationItemConfigurationV2.optional(),
47
46
 
48
47
  // Group placement properties
49
- afterPersistentId: z.string().uuid().optional(),
48
+ afterPersistentId: z.string().uuid().nullish(),
50
49
  parentPersistentId: z.string().uuid(),
51
50
  });
52
51
 
@@ -56,7 +55,7 @@ export const DTOUpdateDocumentationGroupInput = z.object({
56
55
 
57
56
  // Group properties
58
57
  title: z.string().optional(),
59
- configuration: DocumentationItemConfigurationV2.optional(),
58
+ configuration: DTODocumentationItemConfigurationV2.partial().optional(),
60
59
  });
61
60
 
62
61
  export const DTOMoveDocumentationGroupInput = z.object({
@@ -65,7 +64,7 @@ export const DTOMoveDocumentationGroupInput = z.object({
65
64
 
66
65
  // Group placement properties
67
66
  parentPersistentId: z.string().uuid(),
68
- afterPersistentId: z.string().uuid().optional(),
67
+ afterPersistentId: z.string().uuid().nullish(),
69
68
  });
70
69
 
71
70
  export const DTODuplicateDocumentationGroupInput = z.object({
@@ -76,7 +75,7 @@ export const DTODuplicateDocumentationGroupInput = z.object({
76
75
  persistentId: z.string().uuid(),
77
76
 
78
77
  // Group placement properties
79
- afterPersistentId: z.string().uuid().optional(),
78
+ afterPersistentId: z.string().uuid().nullish(),
80
79
  parentPersistentId: z.string().uuid(),
81
80
  });
82
81
 
@@ -2,6 +2,8 @@ export * from "./group-action";
2
2
  export * from "./group-v1";
3
3
  export * from "./group-v2";
4
4
  export * from "./item-configuration-v1";
5
+ export * from "./item-configuration-v2";
5
6
  export * from "./page-actions-v2";
7
+ export * from "./page-content";
6
8
  export * from "./page-v1";
7
9
  export * from "./page-v2";
@@ -16,6 +16,8 @@ const DTODocumentationItemHeaderV1 = DocumentationItemHeaderV1.omit({
16
16
 
17
17
  export const DTODocumentationItemConfigurationV1 = z.object({
18
18
  showSidebar: z.boolean(),
19
+ isPrivate: z.boolean(),
20
+ isHidden: z.boolean(),
19
21
  header: DTODocumentationItemHeaderV1,
20
22
  });
21
23
 
@@ -0,0 +1,14 @@
1
+ import { DocumentationItemHeaderV2 } from "@supernova-studio/model";
2
+ import { z } from "zod";
3
+
4
+ export const DTODocumentationItemHeaderV2 = DocumentationItemHeaderV2;
5
+
6
+ export const DTODocumentationItemConfigurationV2 = z.object({
7
+ showSidebar: z.boolean(),
8
+ isPrivate: z.boolean(),
9
+ isHidden: z.boolean(),
10
+ header: DTODocumentationItemHeaderV2,
11
+ });
12
+
13
+ export type DTODocumentationItemHeaderV2 = z.infer<typeof DTODocumentationItemHeaderV2>;
14
+ export type DTODocumentationItemConfigurationV2 = z.infer<typeof DTODocumentationItemConfigurationV2>;
@@ -0,0 +1,15 @@
1
+ import { DocumentationPageContent } from "@supernova-studio/model";
2
+ import { z } from "zod";
3
+
4
+ //
5
+ // Read
6
+ //
7
+
8
+ export const DTODocumentationPageContent = DocumentationPageContent;
9
+
10
+ export const DTODocumentationPageContentGetResponse = z.object({
11
+ pageContent: DTODocumentationPageContent,
12
+ });
13
+
14
+ export type DTODocumentationPageContent = z.infer<typeof DTODocumentationPageContent>;
15
+ export type DTODocumentationPageContentGetResponse = z.infer<typeof DTODocumentationPageContentGetResponse>;
@@ -1,7 +1,7 @@
1
- import { DocumentationItemConfigurationV2, DocumentationPageV2 } from "@supernova-studio/model";
1
+ import { DocumentationPageV2 } from "@supernova-studio/model";
2
2
  import { z } from "zod";
3
+ import { DTODocumentationItemConfigurationV2 } from "./item-configuration-v2";
3
4
  import { DTODocumentationGroupStructureV2 } from "./group-v2";
4
-
5
5
  //
6
6
  // Read
7
7
  //
@@ -10,7 +10,7 @@ import { DTODocumentationGroupStructureV2 } from "./group-v2";
10
10
  * Structure DTO is element properties minus element data (in other words data required
11
11
  * to display the element in the left panel)
12
12
  */
13
- export const DTODocumentationPageStructureV2 = DocumentationPageV2.omit({
13
+ export const DTODocumentationPageV2 = DocumentationPageV2.omit({
14
14
  data: true,
15
15
  meta: true,
16
16
  parentPersistentId: true,
@@ -19,21 +19,21 @@ export const DTODocumentationPageStructureV2 = DocumentationPageV2.omit({
19
19
  title: z.string(),
20
20
  path: z.string(),
21
21
  type: z.literal("Page"),
22
+ configuration: DTODocumentationItemConfigurationV2,
22
23
  });
24
+ export type DTODocumentationPageV2 = z.infer<typeof DTODocumentationPageV2>;
23
25
 
24
- export const DTODocumentationPageV2 = DTODocumentationPageStructureV2.extend({
25
- configuration: DocumentationItemConfigurationV2,
26
- });
26
+ export const DTODocumentationPageStructureV2 = DTODocumentationPageV2;
27
+ export type DTODocumentationPageStructureV2 = DTODocumentationPageV2;
27
28
 
28
29
  export const DTODocumentationHierarchyV2 = z.object({
29
30
  pages: z.array(DTODocumentationPageStructureV2),
30
31
  groups: z.array(DTODocumentationGroupStructureV2),
31
32
  });
32
33
 
33
- export type DTODocumentationPageV2 = z.infer<typeof DTODocumentationPageV2>;
34
- export type DTODocumentationPageStructureV2 = z.infer<typeof DTODocumentationPageStructureV2>;
35
34
  export type DTODocumentationHierarchyV2 = z.infer<typeof DTODocumentationHierarchyV2>;
36
35
 
36
+
37
37
  //
38
38
  // Write
39
39
  //
@@ -44,11 +44,11 @@ export const DTOCreateDocumentationPageInputV2 = z.object({
44
44
 
45
45
  // Page properties
46
46
  title: z.string(),
47
- configuration: DocumentationItemConfigurationV2.optional(),
47
+ configuration: DTODocumentationItemConfigurationV2.optional(),
48
48
 
49
49
  // Page placement properties
50
50
  parentPersistentId: z.string().uuid(),
51
- afterPersistentId: z.string().uuid().optional(),
51
+ afterPersistentId: z.string().uuid().nullish(),
52
52
  });
53
53
 
54
54
  export const DTOUpdateDocumentationPageInputV2 = z.object({
@@ -57,7 +57,7 @@ export const DTOUpdateDocumentationPageInputV2 = z.object({
57
57
 
58
58
  // Page properties
59
59
  title: z.string().optional(),
60
- configuration: DocumentationItemConfigurationV2.optional(),
60
+ configuration: DTODocumentationItemConfigurationV2.partial().optional(),
61
61
  });
62
62
 
63
63
  export const DTOMoveDocumentationPageInputV2 = z.object({
@@ -66,7 +66,7 @@ export const DTOMoveDocumentationPageInputV2 = z.object({
66
66
 
67
67
  // Page placement properties
68
68
  parentPersistentId: z.string().uuid(),
69
- afterPersistentId: z.string().uuid().optional(),
69
+ afterPersistentId: z.string().uuid().nullish(),
70
70
  });
71
71
 
72
72
  export const DTODuplicateDocumentationPageInputV2 = z.object({
@@ -78,7 +78,7 @@ export const DTODuplicateDocumentationPageInputV2 = z.object({
78
78
 
79
79
  // Page placement properties
80
80
  parentPersistentId: z.string().uuid(),
81
- afterPersistentId: z.string().uuid().optional(),
81
+ afterPersistentId: z.string().uuid().nullish(),
82
82
  });
83
83
 
84
84
  export const DTODeleteDocumentationPageInputV2 = z.object({
@@ -1,16 +1,4 @@
1
1
  import { z } from "zod";
2
- import {
3
- DTODocumentationPageCreateActionInputV2,
4
- DTODocumentationPageCreateActionOutputV2,
5
- DTODocumentationPageDeleteActionInputV2,
6
- DTODocumentationPageDeleteActionOutputV2,
7
- DTODocumentationPageDuplicateActionInputV2,
8
- DTODocumentationPageDuplicateActionOutputV2,
9
- DTODocumentationPageMoveActionInputV2,
10
- DTODocumentationPageMoveActionOutputV2,
11
- DTODocumentationPageUpdateActionInputV2,
12
- DTODocumentationPageUpdateActionOutputV2,
13
- } from "./documentation/page-actions-v2";
14
2
  import {
15
3
  DTODocumentationGroupCreateActionInputV2,
16
4
  DTODocumentationGroupCreateActionOutputV2,
@@ -27,7 +15,27 @@ import {
27
15
  DTODocumentationTabGroupDeleteActionInputV2,
28
16
  DTODocumentationTabGroupDeleteActionOutputV2,
29
17
  } from "./documentation/group-action";
18
+ import {
19
+ DTODocumentationPageCreateActionInputV2,
20
+ DTODocumentationPageCreateActionOutputV2,
21
+ DTODocumentationPageDeleteActionInputV2,
22
+ DTODocumentationPageDeleteActionOutputV2,
23
+ DTODocumentationPageDuplicateActionInputV2,
24
+ DTODocumentationPageDuplicateActionOutputV2,
25
+ DTODocumentationPageMoveActionInputV2,
26
+ DTODocumentationPageMoveActionOutputV2,
27
+ DTODocumentationPageUpdateActionInputV2,
28
+ DTODocumentationPageUpdateActionOutputV2,
29
+ } from "./documentation/page-actions-v2";
30
30
  import { DTOFigmaNodeRenderActionInput, DTOFigmaNodeRenderActionOutput } from "./figma-nodes/node-actions-v2";
31
+ import {
32
+ DTOPropertyDefinitionCreateActionInputV2,
33
+ DTOPropertyDefinitionCreateActionOutputV2,
34
+ DTOPropertyDefinitionDeleteActionInputV2,
35
+ DTOPropertyDefinitionDeleteActionOutputV2,
36
+ DTOPropertyDefinitionUpdateActionInputV2,
37
+ DTOPropertyDefinitionUpdateActionOutputV2,
38
+ } from "./properties/property-definitions-actions-v2";
31
39
 
32
40
  //
33
41
  // Read
@@ -52,6 +60,11 @@ export const DTOElementActionOutput = z.discriminatedUnion("type", [
52
60
 
53
61
  // Figma frames
54
62
  DTOFigmaNodeRenderActionOutput,
63
+
64
+ // Properties Definitions
65
+ DTOPropertyDefinitionCreateActionOutputV2,
66
+ DTOPropertyDefinitionUpdateActionOutputV2,
67
+ DTOPropertyDefinitionDeleteActionOutputV2,
55
68
  ]);
56
69
 
57
70
  export type DTOElementActionOutput = z.infer<typeof DTOElementActionOutput>;
@@ -79,6 +92,11 @@ export const DTOElementActionInput = z.discriminatedUnion("type", [
79
92
 
80
93
  // Figma frames
81
94
  DTOFigmaNodeRenderActionInput,
95
+
96
+ // Properties Definitions
97
+ DTOPropertyDefinitionCreateActionInputV2,
98
+ DTOPropertyDefinitionUpdateActionInputV2,
99
+ DTOPropertyDefinitionDeleteActionInputV2,
82
100
  ]);
83
101
 
84
102
  export type DTOElementActionInput = z.infer<typeof DTOElementActionInput>;
@@ -1,2 +1,3 @@
1
+ export * from "./property-definitions-actions-v2";
1
2
  export * from "./property-definitions";
2
3
  export * from "./property-values";
@@ -0,0 +1,53 @@
1
+ import { z } from "zod";
2
+ import {
3
+ DTOCreateElementPropertyDefinitionInputV2,
4
+ DTODeleteElementPropertyDefinitionInputV2,
5
+ DTOElementPropertyDefinition,
6
+ DTOUpdateElementPropertyDefinitionInputV2,
7
+ } from "./property-definitions";
8
+
9
+ // Outputs
10
+
11
+ const SuccessPayload = z.object({
12
+ success: z.literal(true),
13
+ });
14
+
15
+ export const DTOPropertyDefinitionCreateActionOutputV2 = z.object({
16
+ type: z.literal("PropertyDefinitionCreate"),
17
+ definition: DTOElementPropertyDefinition,
18
+ });
19
+
20
+ export const DTOPropertyDefinitionUpdateActionOutputV2 = z.object({
21
+ type: z.literal("PropertyDefinitionUpdate"),
22
+ definition: DTOElementPropertyDefinition,
23
+ });
24
+
25
+ export const DTOPropertyDefinitionDeleteActionOutputV2 = z.object({
26
+ type: z.literal("PropertyDefinitionDelete"),
27
+ output: SuccessPayload,
28
+ });
29
+
30
+ export type DTOPropertyDefinitionCreateActionOutputV2 = z.infer<typeof DTOPropertyDefinitionCreateActionOutputV2>;
31
+ export type DTOPropertyDefinitionUpdateActionOutputV2 = z.infer<typeof DTOPropertyDefinitionUpdateActionOutputV2>;
32
+ export type DTOPropertyDefinitionDeleteActionOutputV2 = z.infer<typeof DTOPropertyDefinitionDeleteActionOutputV2>;
33
+
34
+ // Inputs
35
+
36
+ export const DTOPropertyDefinitionCreateActionInputV2 = z.object({
37
+ type: z.literal("PropertyDefinitionCreate"),
38
+ input: DTOCreateElementPropertyDefinitionInputV2,
39
+ });
40
+
41
+ export const DTOPropertyDefinitionUpdateActionInputV2 = z.object({
42
+ type: z.literal("PropertyDefinitionUpdate"),
43
+ input: DTOUpdateElementPropertyDefinitionInputV2,
44
+ });
45
+
46
+ export const DTOPropertyDefinitionDeleteActionInputV2 = z.object({
47
+ type: z.literal("PropertyDefinitionDelete"),
48
+ input: DTODeleteElementPropertyDefinitionInputV2,
49
+ });
50
+
51
+ export type DTOPropertyDefinitionCreateActionInputV2 = z.infer<typeof DTOPropertyDefinitionCreateActionInputV2>;
52
+ export type DTOPropertyDefinitionUpdateActionInputV2 = z.infer<typeof DTOPropertyDefinitionUpdateActionInputV2>;
53
+ export type DTOPropertyDefinitionDeleteActionInputV2 = z.infer<typeof DTOPropertyDefinitionDeleteActionInputV2>;
@@ -1,4 +1,3 @@
1
- import { z } from "zod";
2
1
  import {
3
2
  ElementPropertyDefinitionOption,
4
3
  ElementPropertyLinkType,
@@ -6,7 +5,11 @@ import {
6
5
  ElementPropertyTypeSchema,
7
6
  ObjectMeta,
8
7
  } from "@supernova-studio/model";
8
+ import { z } from "zod";
9
+
10
+ const CODE_NAME_REGEX = /^[a-zA-Z_$][a-zA-Z_$0-9]{1,99}$/;
9
11
 
12
+ // DTO Object
10
13
  export const DTOElementPropertyDefinition = z.object({
11
14
  id: z.string(),
12
15
  designSystemVersionId: z.string(),
@@ -14,14 +17,46 @@ export const DTOElementPropertyDefinition = z.object({
14
17
  persistentId: z.string(),
15
18
  type: ElementPropertyTypeSchema,
16
19
  targetElementType: ElementPropertyTargetType,
17
- codeName: z.string(),
20
+ codeName: z.string().regex(CODE_NAME_REGEX),
18
21
  options: z.array(ElementPropertyDefinitionOption).optional(),
19
22
  linkElementType: ElementPropertyLinkType.optional(),
20
23
  });
21
24
 
25
+ export type DTOElementPropertyDefinition = z.infer<typeof DTOElementPropertyDefinition>;
26
+
27
+ //
28
+ // Read
29
+ //
30
+
22
31
  export const DTOElementPropertyDefinitionsGetResponse = z.object({
23
32
  definitions: z.array(DTOElementPropertyDefinition),
24
33
  });
25
34
 
26
- export type DTOElementPropertyDefinition = z.infer<typeof DTOElementPropertyDefinition>;
27
35
  export type DTOElementPropertyDefinitionsGetResponse = z.infer<typeof DTOElementPropertyDefinitionsGetResponse>;
36
+
37
+ //
38
+ // Write
39
+ //
40
+
41
+ export const DTOCreateElementPropertyDefinitionInputV2 = DTOElementPropertyDefinition.omit({
42
+ id: true,
43
+ designSystemVersionId: true,
44
+ });
45
+
46
+ export type DTOCreateElementPropertyDefinitionInputV2 = z.infer<typeof DTOCreateElementPropertyDefinitionInputV2>;
47
+
48
+ export const DTOUpdateElementPropertyDefinitionInputV2 = z.object({
49
+ id: z.string(),
50
+ name: z.string().optional(),
51
+ description: z.string().optional(),
52
+ codeName: z.string().regex(CODE_NAME_REGEX).optional(),
53
+ options: z.array(ElementPropertyDefinitionOption).optional(),
54
+ });
55
+
56
+ export type DTOUpdateElementPropertyDefinitionInputV2 = z.infer<typeof DTOUpdateElementPropertyDefinitionInputV2>;
57
+
58
+ export const DTODeleteElementPropertyDefinitionInputV2 = z.object({
59
+ id: z.string(),
60
+ });
61
+
62
+ export type DTODeleteElementPropertyDefinitionInputV2 = z.infer<typeof DTODeleteElementPropertyDefinitionInputV2>;
@@ -1,3 +1,4 @@
1
+ export * from "./integrations";
1
2
  export * from "./membership";
2
3
  export * from "./npm-registry";
3
4
  export * from "./workspace";