@supernova-studio/client 0.4.5 → 0.5.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/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // src/api/requests/post-bulk-doc-page-elements.ts
1
+ // src/api/dto/documentation-v1.ts
2
2
  import { z as z125 } from "zod";
3
3
 
4
4
  // ../model/dist/index.mjs
@@ -565,10 +565,8 @@ var DesignElement = ShallowDesignElement.extend({
565
565
  createdAt: z27.date(),
566
566
  updatedAt: z27.date(),
567
567
  exportProperties: DesignSystemElementExportProps.optional(),
568
- data: z27.any(),
569
- // TODO this should be an object, not any.
570
- origin: z27.any().optional()
571
- // TODO object, not any.
568
+ data: z27.record(z27.any()),
569
+ origin: z27.record(z27.any()).optional()
572
570
  });
573
571
  var ElementPropertyType = z28.enum(["Text", "Number", "Boolean", "Select", "Generic", "Link", "URL"]);
574
572
  var ElementPropertyTargetType = z28.enum(["Token", "Component", "DocumentationPage"]);
@@ -996,6 +994,7 @@ var PageBlockItemTextValue = z33.object({
996
994
  var PageBlockItemTokenValue = z33.object({
997
995
  selectedPropertyIds: z33.array(z33.string()).optional(),
998
996
  selectedThemeIds: z33.array(z33.string()).optional(),
997
+ themeDisplayMode: z33.enum(["Split", "Override"]).optional(),
999
998
  value: z33.array(
1000
999
  z33.object({
1001
1000
  entityId: z33.string(),
@@ -1077,13 +1076,13 @@ var DocumentationItemHeaderImageScaleType = DocumentationItemHeaderImageScaleTyp
1077
1076
  var DocumentationItemHeader = z36.object({
1078
1077
  description: z36.string(),
1079
1078
  alignment: DocumentationItemHeaderAlignmentSchema,
1080
- foregroundColor: ColorTokenData.optional(),
1081
- backgroundColor: ColorTokenData.optional(),
1082
- backgroundImageAsset: DocumentationPageAsset.optional(),
1079
+ foregroundColor: ColorTokenData.nullish(),
1080
+ backgroundColor: ColorTokenData.nullish(),
1081
+ backgroundImageAsset: DocumentationPageAsset.nullish(),
1083
1082
  backgroundImageScaleType: DocumentationItemHeaderImageScaleTypeSchema,
1084
1083
  showBackgroundOverlay: z36.boolean(),
1085
1084
  showCoverText: z36.boolean(),
1086
- minHeight: z36.number().optional()
1085
+ minHeight: z36.number().nullish()
1087
1086
  });
1088
1087
  var defaultDocumentationItemHeader = {
1089
1088
  alignment: DocumentationItemHeaderAlignment.Left,
@@ -1315,15 +1314,6 @@ var DocumentationPageV1 = DesignElementBase.extend(DesignElementGroupableRequire
1315
1314
  shortPersistentId: z64.string(),
1316
1315
  data: DocumentationPageDataV1
1317
1316
  });
1318
- var DocumentationPageDTOV1 = DocumentationPageV1.omit({
1319
- data: true,
1320
- meta: true,
1321
- parentPersistentId: true,
1322
- sortOrder: true
1323
- }).extend(DocumentationPageV1.shape.data.shape).extend({
1324
- title: z64.string(),
1325
- path: z64.string()
1326
- });
1327
1317
  var DocumentationPageV2 = DesignElementBase.extend(DesignElementGroupableRequiredPart.shape).extend(DesignElementSlugPart.shape).extend({
1328
1318
  shortPersistentId: z65.string(),
1329
1319
  data: DocumentationPageDataV2
@@ -1349,22 +1339,6 @@ var ElementGroup = DesignElementBase.extend(DesignElementGroupablePart.shape).ex
1349
1339
  data: ElementGroupData.optional()
1350
1340
  });
1351
1341
  var BrandedElementGroup = ElementGroup.extend(DesignElementBrandedPart.shape);
1352
- var DocumentationGroupDTO = ElementGroup.omit({
1353
- sortOrder: true,
1354
- parentPersistentId: true,
1355
- brandPersistentId: true,
1356
- meta: true,
1357
- childType: true,
1358
- data: true,
1359
- shortPersistentId: true
1360
- }).extend({
1361
- title: z67.string(),
1362
- isRoot: z67.boolean(),
1363
- childrenIds: z67.array(z67.string()),
1364
- groupBehavior: DocumentationGroupBehavior,
1365
- configuration: DocumentationItemConfiguration,
1366
- shortPersistentId: z67.string()
1367
- });
1368
1342
  var PageBlockV2 = DesignElementBase.extend(DesignElementGroupableRequiredPart.shape).extend({
1369
1343
  data: PageBlockDataV2
1370
1344
  });
@@ -2503,60 +2477,186 @@ var ContentLoaderPayload = z124.object({
2503
2477
  })
2504
2478
  );
2505
2479
 
2506
- // src/api/requests/post-bulk-doc-page-elements.ts
2507
- var CreateBulkElementsInput = z125.object({
2508
- persistentId: z125.string().uuid(),
2480
+ // src/api/dto/documentation-v1.ts
2481
+ var DocumentationPageV1DTO = DocumentationPageV1.omit({
2482
+ data: true,
2483
+ meta: true,
2484
+ parentPersistentId: true,
2485
+ sortOrder: true
2486
+ }).extend(DocumentationPageV1.shape.data.shape).extend({
2509
2487
  title: z125.string(),
2488
+ path: z125.string()
2489
+ });
2490
+
2491
+ // src/api/dto/documentation-v2.ts
2492
+ import { z as z127 } from "zod";
2493
+
2494
+ // src/api/dto/documentation.ts
2495
+ import { z as z126 } from "zod";
2496
+ var DocumentationGroupStructureDTO = ElementGroup.omit({
2497
+ sortOrder: true,
2498
+ parentPersistentId: true,
2499
+ brandPersistentId: true,
2500
+ meta: true,
2501
+ childType: true,
2502
+ data: true,
2503
+ shortPersistentId: true
2504
+ }).extend({
2505
+ title: z126.string(),
2506
+ isRoot: z126.boolean(),
2507
+ childrenIds: z126.array(z126.string()),
2508
+ groupBehavior: DocumentationGroupBehavior,
2509
+ shortPersistentId: z126.string()
2510
+ });
2511
+ var DocumentationGroupDTO = DocumentationGroupStructureDTO.extend({
2512
+ configuration: DocumentationItemConfiguration
2513
+ });
2514
+
2515
+ // src/api/dto/documentation-v2.ts
2516
+ var DocumentationPageStructureV2DTO = DocumentationPageV2.omit({
2517
+ data: true,
2518
+ meta: true,
2519
+ parentPersistentId: true,
2520
+ sortOrder: true
2521
+ }).extend({
2522
+ title: z127.string(),
2523
+ path: z127.string()
2524
+ });
2525
+ var DocumentationPageV2DTO = DocumentationPageStructureV2DTO.extend(DocumentationPageV2.shape.data.shape);
2526
+ var DocumentationHierarchyV2DTO = z127.object({
2527
+ pages: z127.array(DocumentationPageStructureV2DTO),
2528
+ groups: z127.array(DocumentationGroupStructureDTO)
2529
+ });
2530
+
2531
+ // src/api/requests/post-bulk-doc-page-elements.ts
2532
+ import { z as z128 } from "zod";
2533
+ var CreateBulkElementsInput = z128.object({
2534
+ persistentId: z128.string().uuid(),
2535
+ title: z128.string(),
2510
2536
  configuration: DocumentationItemConfiguration,
2511
- parentPersistentId: z125.string().nullish(),
2512
- afterPersistentId: z125.string().nullish()
2537
+ parentPersistentId: z128.string().nullish(),
2538
+ afterPersistentId: z128.string().nullish()
2513
2539
  });
2514
- var UpdateBulkElementsInput = z125.object({
2515
- id: z125.string(),
2516
- title: z125.string().optional(),
2540
+ var UpdateBulkElementsInput = z128.object({
2541
+ id: z128.string(),
2542
+ title: z128.string().optional(),
2517
2543
  configuration: DocumentationItemConfiguration.optional(),
2518
- parentPersistentId: z125.string().optional(),
2519
- afterPersistentId: z125.string().optional()
2520
- });
2521
- var DeleteBulkElementsInput = z125.array(z125.string());
2522
- var DuplicateBulkElementsInput = z125.object({
2523
- id: z125.string(),
2524
- persistentId: z125.string().uuid(),
2525
- parentPersistentId: z125.string().uuid(),
2526
- afterPersistentId: z125.string().uuid().nullish()
2527
- });
2528
- var BulkEditDocPageElementsInput = z125.object({
2529
- documentationPages: z125.object({
2530
- create: z125.array(CreateBulkElementsInput).optional(),
2531
- update: z125.array(UpdateBulkElementsInput).optional(),
2544
+ parentPersistentId: z128.string().optional(),
2545
+ afterPersistentId: z128.string().optional()
2546
+ });
2547
+ var DeleteBulkElementsInput = z128.array(z128.string());
2548
+ var DuplicateBulkElementsInput = z128.object({
2549
+ id: z128.string(),
2550
+ persistentId: z128.string().uuid(),
2551
+ parentPersistentId: z128.string().uuid(),
2552
+ afterPersistentId: z128.string().uuid().nullish()
2553
+ });
2554
+ var BulkEditDocPageElementsInput = z128.object({
2555
+ documentationPages: z128.object({
2556
+ create: z128.array(CreateBulkElementsInput).optional(),
2557
+ update: z128.array(UpdateBulkElementsInput).optional(),
2532
2558
  delete: DeleteBulkElementsInput.optional(),
2533
- duplicate: z125.array(DuplicateBulkElementsInput).optional()
2559
+ duplicate: z128.array(DuplicateBulkElementsInput).optional()
2534
2560
  })
2535
2561
  });
2536
2562
 
2537
2563
  // src/api/requests/post-liveblocks-auth.ts
2538
- import { z as z126 } from "zod";
2539
- var PostLiveblocksAuth = z126.object({
2540
- room: z126.string()
2564
+ import { z as z129 } from "zod";
2565
+ var PostLiveblocksAuth = z129.object({
2566
+ room: z129.string()
2541
2567
  });
2542
2568
 
2543
2569
  // src/api/responses/get-block-definitions.ts
2544
- import { z as z127 } from "zod";
2545
- var GetBlockDefinitionsResponse = z127.object({
2546
- definitions: z127.array(PageBlockDefinition)
2570
+ import { z as z130 } from "zod";
2571
+ var GetBlockDefinitionsResponse = z130.object({
2572
+ definitions: z130.array(PageBlockDefinition)
2547
2573
  });
2548
2574
 
2575
+ // src/design-system-content/documentation-hierarchy.ts
2576
+ function documentationHierarchyToYjs(documentationHierarchy, doc) {
2577
+ doc.transact((trx) => {
2578
+ const pagesMap = trx.doc.getMap("documentationPages");
2579
+ documentationHierarchy.pages.forEach((page) => {
2580
+ pagesMap.set(page.persistentId, page);
2581
+ });
2582
+ const groupsMap = trx.doc.getMap("documentationGroups");
2583
+ documentationHierarchy.groups.forEach((group) => {
2584
+ groupsMap.set(group.persistentId, group);
2585
+ });
2586
+ });
2587
+ return doc;
2588
+ }
2589
+ function yjsToDocumentationHierarchy(doc) {
2590
+ const pagesMap = doc.getMap("documentationPages");
2591
+ const groupsMap = doc.getMap("documentationGroups");
2592
+ const pages = [];
2593
+ pagesMap.forEach((page) => {
2594
+ pages.push(DocumentationPageStructureV2DTO.parse(page));
2595
+ });
2596
+ const groups = [];
2597
+ groupsMap.forEach((group) => {
2598
+ groups.push(DocumentationGroupStructureDTO.parse(group));
2599
+ });
2600
+ return {
2601
+ pages,
2602
+ groups
2603
+ };
2604
+ }
2605
+
2606
+ // src/design-system-content/item-configuration.ts
2607
+ function itemConfigurationToYjs(item, yDoc) {
2608
+ yDoc.transact((trx) => {
2609
+ const header = item.header;
2610
+ if (header) {
2611
+ const headerYMap = trx.doc.getMap("itemHeader");
2612
+ header.description !== void 0 && headerYMap.set("description", header.description);
2613
+ header.alignment !== void 0 && headerYMap.set("alignment", header.alignment);
2614
+ header.foregroundColor !== void 0 && headerYMap.set("foregroundColor", header.foregroundColor);
2615
+ header.backgroundColor !== void 0 && headerYMap.set("backgroundColor", header.backgroundColor);
2616
+ header.backgroundImageAsset !== void 0 && headerYMap.set("backgroundImageAsset", header.backgroundImageAsset);
2617
+ header.backgroundImageScaleType !== void 0 && headerYMap.set("backgroundImageScaleType", header.backgroundImageScaleType);
2618
+ header.showBackgroundOverlay !== void 0 && headerYMap.set("showBackgroundOverlay", header.showBackgroundOverlay);
2619
+ header.showCoverText !== void 0 && headerYMap.set("showCoverText", header.showCoverText);
2620
+ header.minHeight !== void 0 && headerYMap.set("minHeight", header.minHeight);
2621
+ }
2622
+ if (item.showSidebar !== void 0) {
2623
+ const configYMap = trx.doc.getMap("itemConfiguration");
2624
+ configYMap.set("showSidebar", item.showSidebar);
2625
+ }
2626
+ });
2627
+ }
2628
+ function yjsToItemConfiguration(yDoc) {
2629
+ const headerYMap = yDoc.getMap("itemHeader");
2630
+ const rawHeader = {
2631
+ description: headerYMap.get("description"),
2632
+ alignment: headerYMap.get("alignment"),
2633
+ foregroundColor: headerYMap.get("foregroundColor"),
2634
+ backgroundColor: headerYMap.get("backgroundColor"),
2635
+ backgroundImageAsset: headerYMap.get("backgroundImageAsset"),
2636
+ backgroundImageScaleType: headerYMap.get("backgroundImageScaleType"),
2637
+ showBackgroundOverlay: headerYMap.get("showBackgroundOverlay"),
2638
+ showCoverText: headerYMap.get("showCoverText"),
2639
+ minHeight: headerYMap.get("minHeight")
2640
+ };
2641
+ const configYMap = yDoc.getMap("itemConfiguration");
2642
+ const rawConfig = {
2643
+ showSidebar: configYMap.get("showSidebar"),
2644
+ header: rawHeader
2645
+ };
2646
+ return DocumentationItemConfiguration.parse(rawConfig);
2647
+ }
2648
+
2549
2649
  // src/docs-editor/model/block.ts
2550
- import { z as z128 } from "zod";
2551
- var PageBlockEditorModel = z128.object({
2552
- id: z128.string(),
2650
+ import { z as z131 } from "zod";
2651
+ var PageBlockEditorModel = z131.object({
2652
+ id: z131.string(),
2553
2653
  data: PageBlockDataV2
2554
2654
  });
2555
2655
 
2556
2656
  // src/docs-editor/model/page.ts
2557
- import { z as z129 } from "zod";
2558
- var DocumentationPageEditorModel = z129.object({
2559
- blocks: z129.array(PageBlockEditorModel)
2657
+ import { z as z132 } from "zod";
2658
+ var DocumentationPageEditorModel = z132.object({
2659
+ blocks: z132.array(PageBlockEditorModel)
2560
2660
  });
2561
2661
 
2562
2662
  // src/docs-editor/prosemirror/schema.ts
@@ -2730,6 +2830,9 @@ var newSchema = {
2730
2830
  markSet: [],
2731
2831
  groups: [],
2732
2832
  attrs: {
2833
+ id: {
2834
+ default: null
2835
+ },
2733
2836
  textAlign: {
2734
2837
  hasDefault: true,
2735
2838
  default: "left"
@@ -2748,6 +2851,7 @@ var newSchema = {
2748
2851
  }
2749
2852
  },
2750
2853
  defaultAttrs: {
2854
+ id: null,
2751
2855
  textAlign: "left",
2752
2856
  colspan: 1,
2753
2857
  rowspan: 1,
@@ -2793,6 +2897,9 @@ var newSchema = {
2793
2897
  markSet: [],
2794
2898
  groups: [],
2795
2899
  attrs: {
2900
+ id: {
2901
+ default: null
2902
+ },
2796
2903
  textAlign: {
2797
2904
  hasDefault: true,
2798
2905
  default: "left"
@@ -2811,6 +2918,7 @@ var newSchema = {
2811
2918
  }
2812
2919
  },
2813
2920
  defaultAttrs: {
2921
+ id: null,
2814
2922
  textAlign: "left",
2815
2923
  colspan: 1,
2816
2924
  rowspan: 1,
@@ -3321,6 +3429,7 @@ var newSchema = {
3321
3429
  defining: true,
3322
3430
  attrs: {
3323
3431
  id: {
3432
+ hasDefault: true,
3324
3433
  default: null
3325
3434
  },
3326
3435
  definitionId: {
@@ -3339,6 +3448,9 @@ var newSchema = {
3339
3448
  markSet: [],
3340
3449
  groups: ["block"],
3341
3450
  attrs: {
3451
+ id: {
3452
+ default: null
3453
+ },
3342
3454
  definitionId: {
3343
3455
  hasDefault: true,
3344
3456
  default: "io.supernova.block.blockquote"
@@ -3349,6 +3461,7 @@ var newSchema = {
3349
3461
  }
3350
3462
  },
3351
3463
  defaultAttrs: {
3464
+ id: null,
3352
3465
  definitionId: "io.supernova.block.blockquote",
3353
3466
  variantId: "default"
3354
3467
  },
@@ -5681,7 +5794,10 @@ var blocks = [
5681
5794
 
5682
5795
  // src/docs-editor/prosemirror-to-blocks.ts
5683
5796
  import { yXmlFragmentToProsemirrorJSON } from "y-prosemirror";
5684
- function yXmlFragmetToPage(fragment, definitions) {
5797
+ function yDocToPage(yDoc, definitions) {
5798
+ return yXmlFragmentToPage(yDoc.getXmlFragment("default"), definitions);
5799
+ }
5800
+ function yXmlFragmentToPage(fragment, definitions) {
5685
5801
  const prosemirrorJson = yXmlFragmentToProsemirrorJSON(fragment);
5686
5802
  return prosemirrorDocToPage(prosemirrorJson, definitions);
5687
5803
  }
@@ -6136,7 +6252,13 @@ export {
6136
6252
  BulkEditDocPageElementsInput,
6137
6253
  CreateBulkElementsInput,
6138
6254
  DeleteBulkElementsInput,
6255
+ DocumentationGroupDTO,
6256
+ DocumentationGroupStructureDTO,
6257
+ DocumentationHierarchyV2DTO,
6139
6258
  DocumentationPageEditorModel,
6259
+ DocumentationPageStructureV2DTO,
6260
+ DocumentationPageV1DTO,
6261
+ DocumentationPageV2DTO,
6140
6262
  DuplicateBulkElementsInput,
6141
6263
  GetBlockDefinitionsResponse,
6142
6264
  PageBlockEditorModel,
@@ -6144,13 +6266,18 @@ export {
6144
6266
  UpdateBulkElementsInput,
6145
6267
  blockDefinitionForBlock,
6146
6268
  blockToProsemirrorNode,
6269
+ documentationHierarchyToYjs,
6147
6270
  getMockPageBlockDefinitions,
6271
+ itemConfigurationToYjs,
6148
6272
  pageToProsemirrorDoc,
6149
6273
  pageToYXmlFragment,
6150
6274
  pmSchema,
6151
6275
  prosemirrorDocToPage,
6152
6276
  prosemirrorNodeToBlock,
6153
6277
  serializeAsCustomBlock,
6154
- yXmlFragmetToPage
6278
+ yDocToPage,
6279
+ yXmlFragmentToPage,
6280
+ yjsToDocumentationHierarchy,
6281
+ yjsToItemConfiguration
6155
6282
  };
6156
6283
  //# sourceMappingURL=index.mjs.map