@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
@@ -0,0 +1,27 @@
1
+ import { IntegrationCredentialsSchema, IntegrationType } from "@supernova-studio/model";
2
+ import { z } from "zod";
3
+
4
+ export const DTOIntegration = z.object({
5
+ id: z.string(),
6
+ workspaceId: z.string(),
7
+ type: IntegrationType,
8
+ createdAt: z.coerce.date(),
9
+ integrationCredentials: z.array(IntegrationCredentialsSchema).optional(),
10
+ });
11
+
12
+ export const DTOIntegrationOAuthGetResponse = z.object({
13
+ url: z.string(),
14
+ });
15
+
16
+ export const DTOIntegrationPostResponse = z.object({
17
+ integration: DTOIntegration,
18
+ });
19
+
20
+ export const DTOIntegrationsGetListResponse = z.object({
21
+ integrations: DTOIntegration.array(),
22
+ });
23
+
24
+ export type DTOIntegration = z.infer<typeof DTOIntegration>;
25
+ export type DTOIntegrationOAuthGetResponse = z.infer<typeof DTOIntegrationOAuthGetResponse>;
26
+ export type DTOIntegrationPostResponse = z.infer<typeof DTOIntegrationPostResponse>;
27
+ export type DTOIntegrationsGetListResponse = z.infer<typeof DTOIntegrationsGetListResponse>;
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+
3
+ export const DTOCreateBrandInput = z.object({
4
+ persistentId: z.string().uuid(),
5
+ meta: z.object({
6
+ name: z.string(),
7
+ description: z.string(),
8
+ }),
9
+ });
10
+
11
+ export type DTOCreateBrandInput = z.infer<typeof DTOCreateBrandInput>;
@@ -0,0 +1,2 @@
1
+ export * from "./brand";
2
+ export * from "./version";
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ import { ObjectMeta } from "@supernova-studio/model";
3
+
4
+
5
+ export function validateSemver(version: string) {
6
+ const semverRegex = /^(\d+)(\.\d+)?(\.\d+)?$/;
7
+ return semverRegex.test(version);
8
+ }
9
+
10
+ export const DTOCreateVersionInput = z.object({
11
+ meta: ObjectMeta,
12
+ version: z.string().refine(validateSemver, {
13
+ message: "Invalid semantic versioning format",
14
+ }),
15
+ changeLog: z.string(),
16
+ });
17
+
18
+ export type DTOCreateVersionInput = z.infer<typeof DTOCreateVersionInput>;
@@ -1,3 +1,4 @@
1
+ export * from "./design-systems";
1
2
  export * from "./documentation";
2
3
  export * from "./liveblocks";
3
4
  export * from "./workspaces";
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
 
3
3
  export const DTOLiveblocksAuthRequest = z.object({
4
- room: z.string(),
4
+ room: z.string().optional(),
5
5
  });
6
6
 
7
7
  export type DTOLiveblocksAuthRequest = z.infer<typeof DTOLiveblocksAuthRequest>;
@@ -1 +1,2 @@
1
1
  export * from "./workspace-configuration";
2
+ export * from "./workspace-integrations";
@@ -0,0 +1,8 @@
1
+ import { IntegrationType } from "@supernova-studio/model";
2
+ import { z } from "zod";
3
+
4
+ export const DTOWorkspaceIntegrationOauthInput = z.object({
5
+ type: IntegrationType,
6
+ });
7
+
8
+ export type DTOWorkspaceIntegrationOauthInput = z.infer<typeof DTOWorkspaceIntegrationOauthInput>;
@@ -1,6 +1,7 @@
1
- import { DocumentationItemConfigurationV2, DocumentationItemHeaderV2 } from "@supernova-studio/model";
1
+ import { DocumentationItemHeaderV2 } from "@supernova-studio/model";
2
2
  import * as Y from "yjs";
3
3
  import { z } from "zod";
4
+ import { DTODocumentationItemConfigurationV2 } from "../../api/dto/elements/documentation/item-configuration-v2";
4
5
 
5
6
  //
6
7
  // Types
@@ -8,12 +9,12 @@ import { z } from "zod";
8
9
 
9
10
  export const DTODocumentationPageRoomHeaderData = z.object({
10
11
  title: z.string(),
11
- configuration: DocumentationItemConfigurationV2,
12
+ configuration: DTODocumentationItemConfigurationV2,
12
13
  });
13
14
 
14
15
  export const DTODocumentationPageRoomHeaderDataUpdate = z.object({
15
16
  title: z.string().optional(),
16
- configuration: DocumentationItemConfigurationV2.omit({ header: true })
17
+ configuration: DTODocumentationItemConfigurationV2.omit({ header: true })
17
18
  .extend({ header: DocumentationItemHeaderV2.partial() })
18
19
  .optional(),
19
20
  });
@@ -52,10 +53,11 @@ export function itemConfigurationToYjs(yDoc: Y.Doc, item: DTODocumentationPageRo
52
53
  header.minHeight !== undefined && headerYMap.set("minHeight", header.minHeight);
53
54
  }
54
55
 
55
- if (configuration?.showSidebar !== undefined) {
56
- const configYMap = trx.doc.getMap("itemConfiguration");
57
- configYMap.set("showSidebar", configuration.showSidebar);
58
- }
56
+ const configYMap = trx.doc.getMap("itemConfiguration");
57
+
58
+ configuration?.showSidebar !== undefined && configYMap.set("showSidebar", configuration.showSidebar);
59
+ configuration?.isHidden !== undefined && configYMap.set("isHidden", configuration.isHidden);
60
+ configuration?.isPrivate !== undefined && configYMap.set("isPrivate", configuration.isPrivate);
59
61
  });
60
62
  }
61
63
 
@@ -76,13 +78,16 @@ export function yjsToItemConfiguration(yDoc: Y.Doc): DTODocumentationPageRoomHea
76
78
  };
77
79
 
78
80
  const configYMap = yDoc.getMap("itemConfiguration");
81
+
79
82
  const rawConfig = {
80
83
  showSidebar: configYMap.get("showSidebar"),
84
+ isHidden: configYMap.get("isHidden") ?? false,
85
+ isPrivate: configYMap.get("isPrivate") ?? false,
81
86
  header: rawHeader,
82
- };
87
+ } satisfies Record<keyof DTODocumentationItemConfigurationV2, unknown>;
83
88
 
84
89
  return {
85
90
  title: z.string().parse(title),
86
- configuration: DocumentationItemConfigurationV2.parse(rawConfig),
91
+ configuration: DTODocumentationItemConfigurationV2.parse(rawConfig),
87
92
  };
88
93
  }
@@ -625,21 +625,27 @@ function serializeTextSpanAttribute(spanAttribute: PageBlockTextSpanAttribute):
625
625
  return { type: "code", attrs: {} };
626
626
  case "Link":
627
627
  if (spanAttribute.link) {
628
- return serializeLinkMark(spanAttribute.link, spanAttribute.openInNewWindow ?? false);
628
+ return serializeLinkMark(
629
+ spanAttribute.link,
630
+ spanAttribute.openInNewTab ?? spanAttribute.openInNewWindow ?? false
631
+ );
629
632
  } else if (spanAttribute.documentationItemId) {
630
- return serializeLinkMark(`@page:${spanAttribute.documentationItemId}`, spanAttribute.openInNewWindow ?? false);
633
+ return serializeLinkMark(
634
+ `@page:${spanAttribute.documentationItemId}`,
635
+ spanAttribute.openInNewTab ?? spanAttribute.openInNewWindow ?? false
636
+ );
631
637
  } else {
632
- return serializeLinkMark("about:blank", spanAttribute.openInNewWindow ?? false);
638
+ return serializeLinkMark("about:blank", spanAttribute.openInNewTab ?? spanAttribute.openInNewWindow ?? false);
633
639
  }
634
640
  }
635
641
  }
636
642
 
637
- function serializeLinkMark(href: string, openInNewWindow: boolean): ProsemirrorMark {
643
+ function serializeLinkMark(href: string, openInNewTab: boolean): ProsemirrorMark {
638
644
  return {
639
645
  type: "link",
640
646
  attrs: {
641
647
  href: href,
642
- target: openInNewWindow ? "_blank" : "_self",
648
+ target: openInNewTab ? "_blank" : "_self",
643
649
  rel: "noopener noreferrer nofollow",
644
650
  class: "tiptap-link",
645
651
  },
@@ -396,6 +396,10 @@ function parseRichText(spans: ProsemirrorNode[]): PageBlockText {
396
396
  }
397
397
 
398
398
  function parseRichTextSpan(span: ProsemirrorNode): PageBlockTextSpan | null {
399
+ if (span.type === "hardBreak") {
400
+ return { text: "\n", attributes: [] };
401
+ }
402
+
399
403
  if (span.type !== "text" || !span.text) return null;
400
404
 
401
405
  const marks = span.marks ?? [];
@@ -428,18 +432,20 @@ function parseProsemirrorLink(mark: ProsemirrorMark): PageBlockTextSpanAttribute
428
432
  if (!href) return null;
429
433
 
430
434
  const target = getProsemirrorAttribute(mark, "target", z.string().optional());
431
- const openInNewWindow = target === "_blank";
435
+ const openInNewTab = target === "_blank";
432
436
 
433
437
  if (href.startsWith("@")) {
434
438
  return {
435
439
  type: "Link",
436
- openInNewWindow: openInNewWindow,
440
+ openInNewWindow: openInNewTab,
441
+ openInNewTab: openInNewTab,
437
442
  documentationItemId: href.split(":")[1],
438
443
  };
439
444
  } else {
440
445
  return {
441
446
  type: "Link",
442
- openInNewWindow: openInNewWindow,
447
+ openInNewWindow: openInNewTab,
448
+ openInNewTab: openInNewTab,
443
449
  link: href,
444
450
  };
445
451
  }