@supernova-studio/client 0.4.6 → 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.d.mts +2537 -177
- package/dist/index.d.ts +2537 -177
- package/dist/index.js +150 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +185 -71
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
- package/src/api/dto/documentation-v1.ts +16 -0
- package/src/api/dto/documentation-v2.ts +28 -0
- package/src/api/dto/documentation.ts +29 -0
- package/src/api/dto/index.ts +3 -0
- package/src/api/index.ts +1 -0
- package/src/design-system-content/documentation-hierarchy.ts +41 -0
- package/src/design-system-content/index.ts +2 -0
- package/src/design-system-content/item-configuration.ts +57 -0
- package/src/docs-editor/prosemirror-to-blocks.ts +6 -1
- package/src/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/api/
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/api/dto/documentation-v1.ts
|
|
2
2
|
var _zod = require('zod');
|
|
3
3
|
|
|
4
4
|
// ../model/dist/index.mjs
|
|
@@ -565,10 +565,8 @@ var DesignElement = ShallowDesignElement.extend({
|
|
|
565
565
|
createdAt: _zod.z.date(),
|
|
566
566
|
updatedAt: _zod.z.date(),
|
|
567
567
|
exportProperties: DesignSystemElementExportProps.optional(),
|
|
568
|
-
data: _zod.z.any(),
|
|
569
|
-
|
|
570
|
-
origin: _zod.z.any().optional()
|
|
571
|
-
// TODO object, not any.
|
|
568
|
+
data: _zod.z.record(_zod.z.any()),
|
|
569
|
+
origin: _zod.z.record(_zod.z.any()).optional()
|
|
572
570
|
});
|
|
573
571
|
var ElementPropertyType = _zod.z.enum(["Text", "Number", "Boolean", "Select", "Generic", "Link", "URL"]);
|
|
574
572
|
var ElementPropertyTargetType = _zod.z.enum(["Token", "Component", "DocumentationPage"]);
|
|
@@ -996,6 +994,7 @@ var PageBlockItemTextValue = _zod.z.object({
|
|
|
996
994
|
var PageBlockItemTokenValue = _zod.z.object({
|
|
997
995
|
selectedPropertyIds: _zod.z.array(_zod.z.string()).optional(),
|
|
998
996
|
selectedThemeIds: _zod.z.array(_zod.z.string()).optional(),
|
|
997
|
+
themeDisplayMode: _zod.z.enum(["Split", "Override"]).optional(),
|
|
999
998
|
value: _zod.z.array(
|
|
1000
999
|
_zod.z.object({
|
|
1001
1000
|
entityId: _zod.z.string(),
|
|
@@ -1077,13 +1076,13 @@ var DocumentationItemHeaderImageScaleType = DocumentationItemHeaderImageScaleTyp
|
|
|
1077
1076
|
var DocumentationItemHeader = _zod.z.object({
|
|
1078
1077
|
description: _zod.z.string(),
|
|
1079
1078
|
alignment: DocumentationItemHeaderAlignmentSchema,
|
|
1080
|
-
foregroundColor: ColorTokenData.
|
|
1081
|
-
backgroundColor: ColorTokenData.
|
|
1082
|
-
backgroundImageAsset: DocumentationPageAsset.
|
|
1079
|
+
foregroundColor: ColorTokenData.nullish(),
|
|
1080
|
+
backgroundColor: ColorTokenData.nullish(),
|
|
1081
|
+
backgroundImageAsset: DocumentationPageAsset.nullish(),
|
|
1083
1082
|
backgroundImageScaleType: DocumentationItemHeaderImageScaleTypeSchema,
|
|
1084
1083
|
showBackgroundOverlay: _zod.z.boolean(),
|
|
1085
1084
|
showCoverText: _zod.z.boolean(),
|
|
1086
|
-
minHeight: _zod.z.number().
|
|
1085
|
+
minHeight: _zod.z.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: _zod.z.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: _zod.z.string(),
|
|
1325
|
-
path: _zod.z.string()
|
|
1326
|
-
});
|
|
1327
1317
|
var DocumentationPageV2 = DesignElementBase.extend(DesignElementGroupableRequiredPart.shape).extend(DesignElementSlugPart.shape).extend({
|
|
1328
1318
|
shortPersistentId: _zod.z.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: _zod.z.string(),
|
|
1362
|
-
isRoot: _zod.z.boolean(),
|
|
1363
|
-
childrenIds: _zod.z.array(_zod.z.string()),
|
|
1364
|
-
groupBehavior: DocumentationGroupBehavior,
|
|
1365
|
-
configuration: DocumentationItemConfiguration,
|
|
1366
|
-
shortPersistentId: _zod.z.string()
|
|
1367
|
-
});
|
|
1368
1342
|
var PageBlockV2 = DesignElementBase.extend(DesignElementGroupableRequiredPart.shape).extend({
|
|
1369
1343
|
data: PageBlockDataV2
|
|
1370
1344
|
});
|
|
@@ -2503,7 +2477,59 @@ var ContentLoaderPayload = _zod.z.object({
|
|
|
2503
2477
|
})
|
|
2504
2478
|
);
|
|
2505
2479
|
|
|
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({
|
|
2487
|
+
title: _zod.z.string(),
|
|
2488
|
+
path: _zod.z.string()
|
|
2489
|
+
});
|
|
2490
|
+
|
|
2491
|
+
// src/api/dto/documentation-v2.ts
|
|
2492
|
+
|
|
2493
|
+
|
|
2494
|
+
// src/api/dto/documentation.ts
|
|
2495
|
+
|
|
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: _zod.z.string(),
|
|
2506
|
+
isRoot: _zod.z.boolean(),
|
|
2507
|
+
childrenIds: _zod.z.array(_zod.z.string()),
|
|
2508
|
+
groupBehavior: DocumentationGroupBehavior,
|
|
2509
|
+
shortPersistentId: _zod.z.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: _zod.z.string(),
|
|
2523
|
+
path: _zod.z.string()
|
|
2524
|
+
});
|
|
2525
|
+
var DocumentationPageV2DTO = DocumentationPageStructureV2DTO.extend(DocumentationPageV2.shape.data.shape);
|
|
2526
|
+
var DocumentationHierarchyV2DTO = _zod.z.object({
|
|
2527
|
+
pages: _zod.z.array(DocumentationPageStructureV2DTO),
|
|
2528
|
+
groups: _zod.z.array(DocumentationGroupStructureDTO)
|
|
2529
|
+
});
|
|
2530
|
+
|
|
2506
2531
|
// src/api/requests/post-bulk-doc-page-elements.ts
|
|
2532
|
+
|
|
2507
2533
|
var CreateBulkElementsInput = _zod.z.object({
|
|
2508
2534
|
persistentId: _zod.z.string().uuid(),
|
|
2509
2535
|
title: _zod.z.string(),
|
|
@@ -2546,6 +2572,80 @@ var GetBlockDefinitionsResponse = _zod.z.object({
|
|
|
2546
2572
|
definitions: _zod.z.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
2650
|
|
|
2551
2651
|
var PageBlockEditorModel = _zod.z.object({
|
|
@@ -5694,7 +5794,10 @@ var blocks = [
|
|
|
5694
5794
|
|
|
5695
5795
|
// src/docs-editor/prosemirror-to-blocks.ts
|
|
5696
5796
|
|
|
5697
|
-
function
|
|
5797
|
+
function yDocToPage(yDoc, definitions) {
|
|
5798
|
+
return yXmlFragmentToPage(yDoc.getXmlFragment("default"), definitions);
|
|
5799
|
+
}
|
|
5800
|
+
function yXmlFragmentToPage(fragment, definitions) {
|
|
5698
5801
|
const prosemirrorJson = _yprosemirror.yXmlFragmentToProsemirrorJSON.call(void 0, fragment);
|
|
5699
5802
|
return prosemirrorDocToPage(prosemirrorJson, definitions);
|
|
5700
5803
|
}
|
|
@@ -6165,5 +6268,16 @@ function mapByUnique(items, keyFn) {
|
|
|
6165
6268
|
|
|
6166
6269
|
|
|
6167
6270
|
|
|
6168
|
-
|
|
6271
|
+
|
|
6272
|
+
|
|
6273
|
+
|
|
6274
|
+
|
|
6275
|
+
|
|
6276
|
+
|
|
6277
|
+
|
|
6278
|
+
|
|
6279
|
+
|
|
6280
|
+
|
|
6281
|
+
|
|
6282
|
+
exports.BlockDefinitionUtils = BlockDefinitionUtils; exports.BlockParsingUtils = BlockParsingUtils; exports.BulkEditDocPageElementsInput = BulkEditDocPageElementsInput; exports.CreateBulkElementsInput = CreateBulkElementsInput; exports.DeleteBulkElementsInput = DeleteBulkElementsInput; exports.DocumentationGroupDTO = DocumentationGroupDTO; exports.DocumentationGroupStructureDTO = DocumentationGroupStructureDTO; exports.DocumentationHierarchyV2DTO = DocumentationHierarchyV2DTO; exports.DocumentationPageEditorModel = DocumentationPageEditorModel; exports.DocumentationPageStructureV2DTO = DocumentationPageStructureV2DTO; exports.DocumentationPageV1DTO = DocumentationPageV1DTO; exports.DocumentationPageV2DTO = DocumentationPageV2DTO; exports.DuplicateBulkElementsInput = DuplicateBulkElementsInput; exports.GetBlockDefinitionsResponse = GetBlockDefinitionsResponse; exports.PageBlockEditorModel = PageBlockEditorModel; exports.PostLiveblocksAuth = PostLiveblocksAuth; exports.UpdateBulkElementsInput = UpdateBulkElementsInput; exports.blockDefinitionForBlock = blockDefinitionForBlock; exports.blockToProsemirrorNode = blockToProsemirrorNode; exports.documentationHierarchyToYjs = documentationHierarchyToYjs; exports.getMockPageBlockDefinitions = getMockPageBlockDefinitions; exports.itemConfigurationToYjs = itemConfigurationToYjs; exports.pageToProsemirrorDoc = pageToProsemirrorDoc; exports.pageToYXmlFragment = pageToYXmlFragment; exports.pmSchema = pmSchema; exports.prosemirrorDocToPage = prosemirrorDocToPage; exports.prosemirrorNodeToBlock = prosemirrorNodeToBlock; exports.serializeAsCustomBlock = serializeAsCustomBlock; exports.yDocToPage = yDocToPage; exports.yXmlFragmentToPage = yXmlFragmentToPage; exports.yjsToDocumentationHierarchy = yjsToDocumentationHierarchy; exports.yjsToItemConfiguration = yjsToItemConfiguration;
|
|
6169
6283
|
//# sourceMappingURL=index.js.map
|