@prismicio/types-internal 4.0.0-pr.6.eb53f11 → 4.0.0-pr.9.e09af2c
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/README.md +5 -5
- package/dist/content/boolean.d.ts.map +1 -1
- package/dist/content/boolean.js.map +1 -1
- package/dist/content/document.d.ts +2 -3019
- package/dist/content/document.d.ts.map +1 -1
- package/dist/content/field.d.ts +1 -30
- package/dist/content/field.d.ts.map +1 -1
- package/dist/content/field.js +1 -1
- package/dist/content/field.js.map +1 -1
- package/dist/content/group.d.ts +2 -1
- package/dist/content/group.d.ts.map +1 -1
- package/dist/content/group.js.map +1 -1
- package/dist/content/legacy/boolean.d.ts +1 -0
- package/dist/content/legacy/embed.d.ts +1 -0
- package/dist/content/legacy/empty.d.ts +1 -0
- package/dist/content/legacy/field.d.ts +1 -0
- package/dist/content/legacy/geopoint.d.ts +1 -0
- package/dist/content/legacy/group.d.ts +9 -0
- package/dist/content/legacy/group.d.ts.map +1 -0
- package/dist/content/legacy/group.js.map +1 -1
- package/dist/content/legacy/integrationField.d.ts +1 -0
- package/dist/content/legacy/link.d.ts +41 -0
- package/dist/content/legacy/link.d.ts.map +1 -0
- package/dist/content/legacy/link.js.map +1 -1
- package/dist/content/legacy/nestable.d.ts +1 -0
- package/dist/content/legacy/nestable.js.map +1 -1
- package/dist/content/legacy/repeatable.d.ts +1 -0
- package/dist/content/legacy/repeatable.js +2 -8
- package/dist/content/legacy/repeatable.js.map +1 -1
- package/dist/content/legacy/richText.d.ts +109 -0
- package/dist/content/legacy/richText.d.ts.map +1 -0
- package/dist/content/legacy/richText.js.map +1 -1
- package/dist/content/legacy/separator.d.ts +1 -0
- package/dist/content/legacy/slice.js +2 -3
- package/dist/content/legacy/slice.js.map +1 -1
- package/dist/content/legacy/table.d.ts +1 -0
- package/dist/content/link.d.ts +74 -99
- package/dist/content/link.d.ts.map +1 -1
- package/dist/content/link.js +2 -2
- package/dist/content/link.js.map +1 -1
- package/dist/content/nestable.d.ts +13 -749
- package/dist/content/nestable.d.ts.map +1 -1
- package/dist/content/nestable.js +1 -0
- package/dist/content/nestable.js.map +1 -1
- package/dist/content/repeatable.d.ts +3 -98
- package/dist/content/repeatable.d.ts.map +1 -1
- package/dist/content/richText.d.ts +20 -248
- package/dist/content/richText.d.ts.map +1 -1
- package/dist/content/richText.js.map +1 -1
- package/dist/content/slice.d.ts +6 -4509
- package/dist/content/slice.d.ts.map +1 -1
- package/dist/content/slice.js.map +1 -1
- package/dist/content/slices.d.ts +8 -6765
- package/dist/content/slices.d.ts.map +1 -1
- package/dist/content/table.d.ts +2 -134
- package/dist/content/table.d.ts.map +1 -1
- package/dist/content/widget.d.ts +5 -3020
- package/dist/content/widget.d.ts.map +1 -1
- package/dist/content/widget.js.map +1 -1
- package/dist/helpers/contentPath.js +1 -1
- package/dist/helpers/customTypeModel.d.ts +3 -2
- package/dist/helpers/customTypeModel.d.ts.map +1 -1
- package/dist/helpers/customTypeModel.js +31 -1
- package/dist/helpers/customTypeModel.js.map +1 -1
- package/dist/helpers/documentContent.d.ts +3 -2
- package/dist/helpers/documentContent.d.ts.map +1 -1
- package/dist/helpers/documentContent.js +14 -1
- package/dist/helpers/documentContent.js.map +1 -1
- package/dist/helpers/sliceContent.d.ts +12 -0
- package/dist/helpers/sliceContent.d.ts.map +1 -0
- package/dist/helpers/sliceContent.js +60 -0
- package/dist/helpers/sliceContent.js.map +1 -0
- package/dist/helpers/traverseContent.d.ts +15 -16
- package/dist/helpers/traverseContent.d.ts.map +1 -1
- package/dist/helpers/traverseContent.js +53 -19
- package/dist/helpers/traverseContent.js.map +1 -1
- package/dist/helpers/traverseContentWithModel.d.ts +14 -15
- package/dist/helpers/traverseContentWithModel.d.ts.map +1 -1
- package/dist/helpers/traverseContentWithModel.js +61 -35
- package/dist/helpers/traverseContentWithModel.js.map +1 -1
- package/dist/helpers/withDefaultContent.d.ts +17 -0
- package/dist/helpers/withDefaultContent.d.ts.map +1 -0
- package/dist/helpers/withDefaultContent.js +113 -0
- package/dist/helpers/withDefaultContent.js.map +1 -0
- package/dist/index.d.ts +16 -14
- package/dist/index.js +4 -1
- package/dist/io-ts.d.ts +3629 -70848
- package/dist/io-ts.d.ts.map +1 -1
- package/dist/io-ts.js +126 -124
- package/dist/io-ts.js.map +1 -1
- package/dist/model/customType.d.ts +3 -3329
- package/dist/model/customType.d.ts.map +1 -1
- package/dist/model/group.d.ts +375 -376
- package/dist/model/group.d.ts.map +1 -1
- package/dist/model/group.js.map +1 -1
- package/dist/model/image.d.ts +4 -4
- package/dist/model/image.js.map +1 -1
- package/dist/model/link.d.ts +2 -2
- package/dist/model/link.js.map +1 -1
- package/dist/model/nestable.d.ts +17 -178
- package/dist/model/nestable.d.ts.map +1 -1
- package/dist/model/nestable.js +3 -3
- package/dist/model/nestable.js.map +1 -1
- package/dist/model/richText.d.ts +3 -7
- package/dist/model/richText.d.ts.map +1 -1
- package/dist/model/richText.js +4 -3
- package/dist/model/richText.js.map +1 -1
- package/dist/model/section.d.ts +3 -3329
- package/dist/model/section.d.ts.map +1 -1
- package/dist/model/select.d.ts +1 -1
- package/dist/model/select.js +1 -1
- package/dist/model/select.js.map +1 -1
- package/dist/model/slice.d.ts +1360 -3691
- package/dist/model/slice.d.ts.map +1 -1
- package/dist/model/slice.js +10 -5
- package/dist/model/slice.js.map +1 -1
- package/dist/model/slices.d.ts +3 -2195
- package/dist/model/slices.d.ts.map +1 -1
- package/dist/model/table.d.ts +2 -1
- package/dist/model/table.d.ts.map +1 -1
- package/dist/model/table.js +9 -7
- package/dist/model/table.js.map +1 -1
- package/dist/model/widget.d.ts +7 -3334
- package/dist/model/widget.d.ts.map +1 -1
- package/dist/model/widget.js +5 -2
- package/dist/model/widget.js.map +1 -1
- package/dist/zod4.d.ts +1796 -34837
- package/dist/zod4.d.ts.map +1 -1
- package/dist/zod4.js +126 -124
- package/dist/zod4.js.map +1 -1
- package/package.json +3 -2
- package/src/content/boolean.ts +0 -13
- package/src/content/field.ts +9 -16
- package/src/content/group.ts +6 -56
- package/src/content/legacy/group.ts +12 -4
- package/src/content/legacy/link.ts +32 -9
- package/src/content/legacy/nestable.ts +26 -2
- package/src/content/legacy/repeatable.ts +3 -16
- package/src/content/legacy/richText.ts +37 -5
- package/src/content/legacy/slice.ts +8 -7
- package/src/content/legacy/widget.ts +6 -2
- package/src/content/link.ts +32 -9
- package/src/content/nestable.ts +43 -22
- package/src/content/richText.ts +19 -7
- package/src/content/slice.ts +2 -2
- package/src/content/widget.ts +6 -2
- package/src/helpers/customTypeModel.ts +44 -0
- package/src/helpers/documentContent.ts +32 -1
- package/src/helpers/sliceContent.ts +86 -0
- package/src/helpers/traverseContent.ts +96 -32
- package/src/helpers/traverseContentWithModel.ts +73 -48
- package/src/helpers/withDefaultContent.ts +173 -0
- package/src/index.ts +6 -1
- package/src/io-ts.ts +166 -144
- package/src/model/diff/sharedSlice.ts +2 -2
- package/src/model/diff/variation.ts +7 -7
- package/src/model/group.ts +4 -1
- package/src/model/image.ts +1 -1
- package/src/model/link.ts +1 -1
- package/src/model/nestable.ts +33 -1
- package/src/model/richText.ts +2 -2
- package/src/model/select.ts +2 -2
- package/src/model/slice.ts +38 -13
- package/src/model/table.ts +11 -2
- package/src/model/widget.ts +14 -6
- package/src/zod4.ts +166 -144
- package/src/content/withDefaultValues.ts +0 -114
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.d.ts","names":[],"sources":["../../src/content/widget.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"widget.d.ts","names":[],"sources":["../../src/content/widget.ts"],"mappings":";;;;;;;KAkBY,aAAA,GAAgB,YAAA,GAAe,eAAA,GAAkB,UAAA,GAAa,aAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.js","names":[],"sources":["../../src/content/widget.ts"],"sourcesContent":["import { z } from \"zod/mini\"\n\nimport { GroupContentSchema } from \"./group\"\nimport { NestableContentSchema } from \"./nestable\"\nimport { SlicesContentSchema } from \"./slices\"\nimport { UIDContentSchema } from \"./uid\"\n\nexport const WidgetContentSchema = z.union([\n\tGroupContentSchema,\n\tNestableContentSchema,\n\tUIDContentSchema,\n\tSlicesContentSchema,\n])\n\nexport type WidgetContent =
|
|
1
|
+
{"version":3,"file":"widget.js","names":[],"sources":["../../src/content/widget.ts"],"sourcesContent":["import { z } from \"zod/mini\"\n\nimport type { GroupContent } from \"./group\"\nimport { GroupContentSchema } from \"./group\"\nimport type { NestableContent } from \"./nestable\"\nimport { NestableContentSchema } from \"./nestable\"\nimport type { SlicesContent } from \"./slices\"\nimport { SlicesContentSchema } from \"./slices\"\nimport type { UIDContent } from \"./uid\"\nimport { UIDContentSchema } from \"./uid\"\n\nexport const WidgetContentSchema: z.ZodMiniType<WidgetContent> = z.union([\n\tGroupContentSchema,\n\tNestableContentSchema,\n\tUIDContentSchema,\n\tSlicesContentSchema,\n])\n\nexport type WidgetContent = GroupContent | NestableContent | UIDContent | SlicesContent\n\nexport type ContentType = WidgetContent[\"__TYPE__\"]\n"],"mappings":";;;;;;AAWA,MAAa,sBAAoD,EAAE,MAAM;CACxE;CACA;CACA;CACA;CACA,CAAC"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { SharedSliceModel } from "../model/slice.js";
|
|
1
2
|
import { CustomTypeModel, StaticCustomTypeModel } from "../model/customType.js";
|
|
2
3
|
import { StaticSectionModel } from "../model/section.js";
|
|
3
|
-
import { SharedSliceModel } from "../model/slice.js";
|
|
4
4
|
|
|
5
5
|
//#region src/helpers/customTypeModel.d.ts
|
|
6
6
|
declare namespace customTypeModel_d_exports {
|
|
7
|
-
export { collectSharedSlices, flatten, toStatic };
|
|
7
|
+
export { collectSharedSlices, filterMissingSharedSlices, flatten, toStatic };
|
|
8
8
|
}
|
|
9
9
|
declare function toStatic(customType: CustomTypeModel, sharedSlices: Map<string, SharedSliceModel> | Record<string, SharedSliceModel>): StaticCustomTypeModel;
|
|
10
10
|
declare function flatten(customType: StaticCustomTypeModel): StaticSectionModel;
|
|
11
11
|
declare function collectSharedSlices(customType: StaticCustomTypeModel): Record<string, SharedSliceModel>;
|
|
12
|
+
declare function filterMissingSharedSlices<TCustomType extends StaticCustomTypeModel | CustomTypeModel>(customType: TCustomType, sharedSlices: Map<string, SharedSliceModel> | Record<string, SharedSliceModel>): TCustomType;
|
|
12
13
|
//#endregion
|
|
13
14
|
export { customTypeModel_d_exports };
|
|
14
15
|
//# sourceMappingURL=customTypeModel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customTypeModel.d.ts","names":[],"sources":["../../src/helpers/customTypeModel.ts"],"mappings":";;;;;;;;iBAIgB,QAAA,CACf,UAAA,EAAY,eAAA,EACZ,YAAA,EAAc,GAAA,SAAY,gBAAA,IAAoB,MAAA,SAAe,gBAAA,IAC3D,qBAAA;AAAA,iBAwCa,OAAA,CAAQ,UAAA,EAAY,qBAAA,GAAwB,kBAAA;AAAA,iBAI5C,mBAAA,CACf,UAAA,EAAY,qBAAA,GACV,MAAA,SAAe,gBAAA"}
|
|
1
|
+
{"version":3,"file":"customTypeModel.d.ts","names":[],"sources":["../../src/helpers/customTypeModel.ts"],"mappings":";;;;;;;;iBAIgB,QAAA,CACf,UAAA,EAAY,eAAA,EACZ,YAAA,EAAc,GAAA,SAAY,gBAAA,IAAoB,MAAA,SAAe,gBAAA,IAC3D,qBAAA;AAAA,iBAwCa,OAAA,CAAQ,UAAA,EAAY,qBAAA,GAAwB,kBAAA;AAAA,iBAI5C,mBAAA,CACf,UAAA,EAAY,qBAAA,GACV,MAAA,SAAe,gBAAA;AAAA,iBAiBF,yBAAA,qBACK,qBAAA,GAAwB,eAAA,CAAA,CAE5C,UAAA,EAAY,WAAA,EACZ,YAAA,EAAc,GAAA,SAAY,gBAAA,IAAoB,MAAA,SAAe,gBAAA,IAC3D,WAAA"}
|
|
@@ -2,6 +2,7 @@ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
|
2
2
|
//#region src/helpers/customTypeModel.ts
|
|
3
3
|
var customTypeModel_exports = /* @__PURE__ */ __exportAll({
|
|
4
4
|
collectSharedSlices: () => collectSharedSlices,
|
|
5
|
+
filterMissingSharedSlices: () => filterMissingSharedSlices,
|
|
5
6
|
flatten: () => flatten,
|
|
6
7
|
toStatic: () => toStatic
|
|
7
8
|
});
|
|
@@ -49,7 +50,36 @@ function collectSharedSlices(customType) {
|
|
|
49
50
|
}
|
|
50
51
|
return sharedSlices;
|
|
51
52
|
}
|
|
53
|
+
function filterMissingSharedSlices(customType, sharedSlices) {
|
|
54
|
+
const json = {};
|
|
55
|
+
const sharedSlicesMap = sharedSlices instanceof Map ? sharedSlices : new Map(Object.entries(sharedSlices));
|
|
56
|
+
for (const [tabKey, tab] of Object.entries(customType.json)) {
|
|
57
|
+
const tabJSON = {};
|
|
58
|
+
for (const [key, widget] of Object.entries(tab)) switch (widget.type) {
|
|
59
|
+
case "Slices":
|
|
60
|
+
case "Choice":
|
|
61
|
+
const choices = {};
|
|
62
|
+
for (const [id, model] of Object.entries(widget.config?.choices || {})) if (model.type === "SharedSlice") {
|
|
63
|
+
if (sharedSlicesMap.get(id)) choices[id] = model;
|
|
64
|
+
} else choices[id] = model;
|
|
65
|
+
tabJSON[key] = {
|
|
66
|
+
...widget,
|
|
67
|
+
config: {
|
|
68
|
+
...widget.config,
|
|
69
|
+
choices
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
break;
|
|
73
|
+
default: tabJSON[key] = widget;
|
|
74
|
+
}
|
|
75
|
+
json[tabKey] = tabJSON;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
...customType,
|
|
79
|
+
json
|
|
80
|
+
};
|
|
81
|
+
}
|
|
52
82
|
//#endregion
|
|
53
|
-
export { customTypeModel_exports, flatten };
|
|
83
|
+
export { collectSharedSlices, customTypeModel_exports, flatten };
|
|
54
84
|
|
|
55
85
|
//# sourceMappingURL=customTypeModel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customTypeModel.js","names":[],"sources":["../../src/helpers/customTypeModel.ts"],"sourcesContent":["import type { CustomTypeModel, StaticCustomTypeModel } from \"../model/customType\"\nimport type { StaticSectionModel } from \"../model/section\"\nimport type { SharedSliceModel, StaticSliceModel } from \"../model/slice\"\n\nexport function toStatic(\n\tcustomType: CustomTypeModel,\n\tsharedSlices: Map<string, SharedSliceModel> | Record<string, SharedSliceModel>,\n): StaticCustomTypeModel {\n\tconst json: StaticCustomTypeModel[\"json\"] = {}\n\n\tconst sharedSlicesMap =\n\t\tsharedSlices instanceof Map ? sharedSlices : new Map(Object.entries(sharedSlices))\n\n\tfor (const [tabKey, tab] of Object.entries(customType.json)) {\n\t\tconst tabJSON: StaticCustomTypeModel[\"json\"][string] = {}\n\t\tfor (const [key, widget] of Object.entries(tab)) {\n\t\t\tswitch (widget.type) {\n\t\t\t\tcase \"Slices\":\n\t\t\t\tcase \"Choice\":\n\t\t\t\t\tconst choices: Record<string, StaticSliceModel> = {}\n\t\t\t\t\tfor (const [id, model] of Object.entries(widget.config?.choices || {})) {\n\t\t\t\t\t\tif (model.type === \"SharedSlice\") {\n\t\t\t\t\t\t\tconst sharedSlice = sharedSlicesMap.get(id)\n\t\t\t\t\t\t\tif (sharedSlice) {\n\t\t\t\t\t\t\t\tchoices[id] = sharedSlice\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tchoices[id] = model\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\ttabJSON[key] = {\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tconfig: { ...widget.config, choices },\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\ttabJSON[key] = widget\n\t\t\t}\n\t\t}\n\n\t\tjson[tabKey] = tabJSON\n\t}\n\n\treturn { ...customType, json }\n}\n\nexport function flatten(customType: StaticCustomTypeModel): StaticSectionModel {\n\treturn Object.values(customType.json).reduce((acc, fields) => ({ ...acc, ...fields }), {})\n}\n\nexport function collectSharedSlices(\n\tcustomType: StaticCustomTypeModel,\n): Record<string, SharedSliceModel> {\n\tconst sharedSlices: Record<string, SharedSliceModel> = {}\n\n\tconst flattened = flatten(customType)\n\tfor (const widget of Object.values(flattened)) {\n\t\tif (widget.type === \"Slices\" || widget.type === \"Choice\") {\n\t\t\tfor (const [id, model] of Object.entries(widget.config?.choices || {})) {\n\t\t\t\tif (model.type === \"SharedSlice\") {\n\t\t\t\t\tsharedSlices[id] = model\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn sharedSlices\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"customTypeModel.js","names":[],"sources":["../../src/helpers/customTypeModel.ts"],"sourcesContent":["import type { CustomTypeModel, StaticCustomTypeModel } from \"../model/customType\"\nimport type { StaticSectionModel } from \"../model/section\"\nimport type { SharedSliceModel, StaticSliceModel } from \"../model/slice\"\n\nexport function toStatic(\n\tcustomType: CustomTypeModel,\n\tsharedSlices: Map<string, SharedSliceModel> | Record<string, SharedSliceModel>,\n): StaticCustomTypeModel {\n\tconst json: StaticCustomTypeModel[\"json\"] = {}\n\n\tconst sharedSlicesMap =\n\t\tsharedSlices instanceof Map ? sharedSlices : new Map(Object.entries(sharedSlices))\n\n\tfor (const [tabKey, tab] of Object.entries(customType.json)) {\n\t\tconst tabJSON: StaticCustomTypeModel[\"json\"][string] = {}\n\t\tfor (const [key, widget] of Object.entries(tab)) {\n\t\t\tswitch (widget.type) {\n\t\t\t\tcase \"Slices\":\n\t\t\t\tcase \"Choice\":\n\t\t\t\t\tconst choices: Record<string, StaticSliceModel> = {}\n\t\t\t\t\tfor (const [id, model] of Object.entries(widget.config?.choices || {})) {\n\t\t\t\t\t\tif (model.type === \"SharedSlice\") {\n\t\t\t\t\t\t\tconst sharedSlice = sharedSlicesMap.get(id)\n\t\t\t\t\t\t\tif (sharedSlice) {\n\t\t\t\t\t\t\t\tchoices[id] = sharedSlice\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tchoices[id] = model\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\ttabJSON[key] = {\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tconfig: { ...widget.config, choices },\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\ttabJSON[key] = widget\n\t\t\t}\n\t\t}\n\n\t\tjson[tabKey] = tabJSON\n\t}\n\n\treturn { ...customType, json }\n}\n\nexport function flatten(customType: StaticCustomTypeModel): StaticSectionModel {\n\treturn Object.values(customType.json).reduce((acc, fields) => ({ ...acc, ...fields }), {})\n}\n\nexport function collectSharedSlices(\n\tcustomType: StaticCustomTypeModel,\n): Record<string, SharedSliceModel> {\n\tconst sharedSlices: Record<string, SharedSliceModel> = {}\n\n\tconst flattened = flatten(customType)\n\tfor (const widget of Object.values(flattened)) {\n\t\tif (widget.type === \"Slices\" || widget.type === \"Choice\") {\n\t\t\tfor (const [id, model] of Object.entries(widget.config?.choices || {})) {\n\t\t\t\tif (model.type === \"SharedSlice\") {\n\t\t\t\t\tsharedSlices[id] = model\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn sharedSlices\n}\n\nexport function filterMissingSharedSlices<\n\tTCustomType extends StaticCustomTypeModel | CustomTypeModel,\n>(\n\tcustomType: TCustomType,\n\tsharedSlices: Map<string, SharedSliceModel> | Record<string, SharedSliceModel>,\n): TCustomType {\n\tconst json: TCustomType[\"json\"] = {}\n\n\tconst sharedSlicesMap =\n\t\tsharedSlices instanceof Map ? sharedSlices : new Map(Object.entries(sharedSlices))\n\n\tfor (const [tabKey, tab] of Object.entries(customType.json)) {\n\t\tconst tabJSON: typeof tab = {}\n\t\tfor (const [key, widget] of Object.entries(tab)) {\n\t\t\tswitch (widget.type) {\n\t\t\t\tcase \"Slices\":\n\t\t\t\tcase \"Choice\":\n\t\t\t\t\tconst choices: Required<typeof widget>[\"config\"][\"choices\"] = {}\n\t\t\t\t\tfor (const [id, model] of Object.entries(widget.config?.choices || {})) {\n\t\t\t\t\t\tif (model.type === \"SharedSlice\") {\n\t\t\t\t\t\t\tif (sharedSlicesMap.get(id)) {\n\t\t\t\t\t\t\t\tchoices[id] = model\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tchoices[id] = model\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\ttabJSON[key] = {\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tconfig: { ...widget.config, choices },\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\ttabJSON[key] = widget\n\t\t\t}\n\t\t}\n\n\t\tjson[tabKey] = tabJSON\n\t}\n\n\treturn { ...customType, json }\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,SACf,YACA,cACwB;CACxB,MAAM,OAAsC,EAAE;CAE9C,MAAM,kBACL,wBAAwB,MAAM,eAAe,IAAI,IAAI,OAAO,QAAQ,aAAa,CAAC;AAEnF,MAAK,MAAM,CAAC,QAAQ,QAAQ,OAAO,QAAQ,WAAW,KAAK,EAAE;EAC5D,MAAM,UAAiD,EAAE;AACzD,OAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,IAAI,CAC9C,SAAQ,OAAO,MAAf;GACC,KAAK;GACL,KAAK;IACJ,MAAM,UAA4C,EAAE;AACpD,SAAK,MAAM,CAAC,IAAI,UAAU,OAAO,QAAQ,OAAO,QAAQ,WAAW,EAAE,CAAC,CACrE,KAAI,MAAM,SAAS,eAAe;KACjC,MAAM,cAAc,gBAAgB,IAAI,GAAG;AAC3C,SAAI,YACH,SAAQ,MAAM;UAGf,SAAQ,MAAM;AAIhB,YAAQ,OAAO;KACd,GAAG;KACH,QAAQ;MAAE,GAAG,OAAO;MAAQ;MAAS;KACrC;AACD;GACD,QACC,SAAQ,OAAO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
|
1
|
-
import { DocumentContent } from "../content/document.js";
|
|
2
1
|
import { WidgetContent } from "../content/widget.js";
|
|
2
|
+
import { DocumentContent } from "../content/document.js";
|
|
3
|
+
import { StaticCustomTypeModel } from "../model/customType.js";
|
|
3
4
|
import { Path } from "./contentPath.js";
|
|
4
5
|
import { DocumentLegacy } from "../content/legacy/document.js";
|
|
5
6
|
|
|
@@ -12,7 +13,7 @@ declare function collectWidgets<TWidgetContent extends WidgetContent>(document:
|
|
|
12
13
|
key: string;
|
|
13
14
|
apiID: string;
|
|
14
15
|
}) => content is TWidgetContent): Record<string, TWidgetContent>;
|
|
15
|
-
declare function fromLegacy(legacy: DocumentLegacy): DocumentContent | undefined;
|
|
16
|
+
declare function fromLegacy(legacy: DocumentLegacy, model: StaticCustomTypeModel): DocumentContent | undefined;
|
|
16
17
|
declare function toLegacy(document: DocumentContent): DocumentLegacy;
|
|
17
18
|
//#endregion
|
|
18
19
|
export { documentContent_d_exports };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentContent.d.ts","names":[],"sources":["../../src/helpers/documentContent.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"documentContent.d.ts","names":[],"sources":["../../src/helpers/documentContent.ts"],"mappings":";;;;;;;;;;iBAkBgB,cAAA,wBAAsC,aAAA,CAAA,CACrD,QAAA,EAAU,eAAA,EACV,IAAA,GACC,OAAA,EAAS,aAAA,EACT,IAAA;EACC,IAAA,EAAM,IAAA;EACN,GAAA;EACA,KAAA;AAAA,MAEG,OAAA,IAAW,cAAA,GACd,MAAA,SAAe,cAAA;AAAA,iBAgBF,UAAA,CACf,MAAA,EAAQ,cAAA,EACR,KAAA,EAAO,qBAAA,GACL,eAAA;AAAA,iBAwDa,QAAA,CAAS,QAAA,EAAU,eAAA,GAAkB,cAAA"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { defaultCtx } from "../content/codec/legacyContentCtx.js";
|
|
3
3
|
import { serialize } from "./contentPath.js";
|
|
4
|
+
import { collectSharedSlices } from "./customTypeModel.js";
|
|
5
|
+
import { isNestableContent } from "../content/nestable.js";
|
|
4
6
|
import { DocumentLegacySchema } from "../content/legacy/document.js";
|
|
5
7
|
import { DocumentLegacyCodec } from "../content/codec/document.js";
|
|
6
8
|
import { FieldOrSliceTypeSchema } from "../model/widget.js";
|
|
9
|
+
import { compositeToShared, legacyToShared } from "./sliceContent.js";
|
|
7
10
|
import { traverseDocumentContent } from "./traverseContent.js";
|
|
8
11
|
import { z } from "zod/mini";
|
|
9
12
|
//#region src/helpers/documentContent.ts
|
|
@@ -20,7 +23,7 @@ function collectWidgets(document, test) {
|
|
|
20
23
|
} });
|
|
21
24
|
return collected;
|
|
22
25
|
}
|
|
23
|
-
function fromLegacy(legacy) {
|
|
26
|
+
function fromLegacy(legacy, model) {
|
|
24
27
|
const parsed = DocumentLegacySchema.safeParse(legacy);
|
|
25
28
|
if (!parsed.success) return;
|
|
26
29
|
const types = /* @__PURE__ */ new Map();
|
|
@@ -35,6 +38,16 @@ function fromLegacy(legacy) {
|
|
|
35
38
|
} else if (!key.endsWith("_POSITION")) widgets[key] = value;
|
|
36
39
|
const result = DocumentLegacyCodec(defaultCtx("", types, keys)).toContent(widgets);
|
|
37
40
|
if (!result.success) return;
|
|
41
|
+
if (Object.values(collectSharedSlices(model)).some((slice) => Boolean(slice.legacyPaths))) return traverseDocumentContent(result.data, {
|
|
42
|
+
model,
|
|
43
|
+
transformSlice: ({ content, model }) => {
|
|
44
|
+
if (model?.type === "SharedSlice") {
|
|
45
|
+
if (content.widget.__TYPE__ === "CompositeSliceContent") return compositeToShared(content, model);
|
|
46
|
+
else if (content.widget.__TYPE__ === "GroupContentType" || isNestableContent(content.widget)) return legacyToShared(content, model);
|
|
47
|
+
}
|
|
48
|
+
return content;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
38
51
|
return result.data;
|
|
39
52
|
}
|
|
40
53
|
function toLegacy(document) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentContent.js","names":["contentPath.serialize"],"sources":["../../src/helpers/documentContent.ts"],"sourcesContent":["import { z } from \"zod/mini\"\n\nimport { DocumentLegacyCodec } from \"../content/codec/document\"\nimport { defaultCtx } from \"../content/codec/legacyContentCtx\"\nimport type { DocumentContent } from \"../content/document\"\nimport type { DocumentLegacy } from \"../content/legacy/document\"\nimport { DocumentLegacySchema } from \"../content/legacy/document\"\nimport type { WidgetContent } from \"../content/widget\"\nimport type { FieldOrSliceType } from \"../model/widget\"\nimport { FieldOrSliceTypeSchema } from \"../model/widget\"\nimport * as contentPath from \"./contentPath\"\nimport { traverseDocumentContent } from \"./traverseContent\"\n\nexport function collectWidgets<TWidgetContent extends WidgetContent>(\n\tdocument: DocumentContent,\n\ttest: (\n\t\tcontent: WidgetContent,\n\t\targs: {\n\t\t\tpath: contentPath.Path\n\t\t\tkey: string\n\t\t\tapiID: string\n\t\t},\n\t) => content is TWidgetContent,\n): Record<string, TWidgetContent> {\n\tconst collected: Record<string, TWidgetContent> = {}\n\n\ttraverseDocumentContent(document, {\n\t\ttransformWidget: ({ content, ...args }) => {\n\t\t\tif (test(content, args)) {\n\t\t\t\tcollected[contentPath.serialize(args.path)] = content\n\t\t\t}\n\n\t\t\treturn content\n\t\t},\n\t})\n\n\treturn collected\n}\n\nexport function fromLegacy(
|
|
1
|
+
{"version":3,"file":"documentContent.js","names":["contentPath.serialize","customTypeModel.collectSharedSlices","sliceContent.compositeToShared","sliceContent.legacyToShared"],"sources":["../../src/helpers/documentContent.ts"],"sourcesContent":["import { z } from \"zod/mini\"\n\nimport { DocumentLegacyCodec } from \"../content/codec/document\"\nimport { defaultCtx } from \"../content/codec/legacyContentCtx\"\nimport type { DocumentContent } from \"../content/document\"\nimport type { DocumentLegacy } from \"../content/legacy/document\"\nimport { DocumentLegacySchema } from \"../content/legacy/document\"\nimport { isNestableContent } from \"../content/nestable\"\nimport type { CompositeSliceItemContent, LegacySliceItemContent } from \"../content/slices\"\nimport type { WidgetContent } from \"../content/widget\"\nimport type { StaticCustomTypeModel } from \"../model/customType\"\nimport type { FieldOrSliceType } from \"../model/widget\"\nimport { FieldOrSliceTypeSchema } from \"../model/widget\"\nimport * as contentPath from \"./contentPath\"\nimport * as customTypeModel from \"./customTypeModel\"\nimport * as sliceContent from \"./sliceContent\"\nimport { traverseDocumentContent } from \"./traverseContent\"\n\nexport function collectWidgets<TWidgetContent extends WidgetContent>(\n\tdocument: DocumentContent,\n\ttest: (\n\t\tcontent: WidgetContent,\n\t\targs: {\n\t\t\tpath: contentPath.Path\n\t\t\tkey: string\n\t\t\tapiID: string\n\t\t},\n\t) => content is TWidgetContent,\n): Record<string, TWidgetContent> {\n\tconst collected: Record<string, TWidgetContent> = {}\n\n\ttraverseDocumentContent(document, {\n\t\ttransformWidget: ({ content, ...args }) => {\n\t\t\tif (test(content, args)) {\n\t\t\t\tcollected[contentPath.serialize(args.path)] = content\n\t\t\t}\n\n\t\t\treturn content\n\t\t},\n\t})\n\n\treturn collected\n}\n\nexport function fromLegacy(\n\tlegacy: DocumentLegacy,\n\tmodel: StaticCustomTypeModel,\n): DocumentContent | undefined {\n\tconst parsed = DocumentLegacySchema.safeParse(legacy)\n\tif (!parsed.success) {\n\t\treturn\n\t}\n\n\tconst types = new Map<string, FieldOrSliceType>()\n\tconst keys = new Map<string, string>()\n\tconst widgets: DocumentLegacy = {}\n\tfor (const [key, value] of Object.entries(parsed.data)) {\n\t\tif (key.endsWith(\"_TYPE\")) {\n\t\t\tconst parsed = FieldOrSliceTypeSchema.safeParse(value)\n\t\t\tif (parsed.success) {\n\t\t\t\ttypes.set(key.substring(0, key.length - 5), parsed.data)\n\t\t\t}\n\t\t} else if (key.endsWith(\"_KEY\")) {\n\t\t\tconst parsed = z.uuidv4().safeParse(value)\n\t\t\tif (parsed.success) {\n\t\t\t\tkeys.set(key.substring(0, key.length - 4), parsed.data)\n\t\t\t}\n\t\t} else if (!key.endsWith(\"_POSITION\")) {\n\t\t\twidgets[key] = value\n\t\t}\n\t}\n\n\tconst result = DocumentLegacyCodec(defaultCtx(\"\", types, keys)).toContent(widgets)\n\tif (!result.success) {\n\t\treturn\n\t}\n\n\tconst needsMigration = Object.values(customTypeModel.collectSharedSlices(model)).some((slice) =>\n\t\tBoolean(slice.legacyPaths),\n\t)\n\n\tif (needsMigration) {\n\t\treturn traverseDocumentContent(result.data, {\n\t\t\tmodel,\n\t\t\ttransformSlice: ({ content, model }) => {\n\t\t\t\tif (model?.type === \"SharedSlice\") {\n\t\t\t\t\tif (content.widget.__TYPE__ === \"CompositeSliceContent\") {\n\t\t\t\t\t\treturn sliceContent.compositeToShared(content as CompositeSliceItemContent, model)\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tcontent.widget.__TYPE__ === \"GroupContentType\" ||\n\t\t\t\t\t\tisNestableContent(content.widget)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn sliceContent.legacyToShared(content as LegacySliceItemContent, model)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn content\n\t\t\t},\n\t\t})\n\t}\n\n\treturn result.data\n}\n\nexport function toLegacy(document: DocumentContent): DocumentLegacy {\n\tconst { content, types, keys } = DocumentLegacyCodec(defaultCtx(\"\")).fromContent(document)\n\n\treturn { ...content, ...types, ...keys }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,SAAgB,eACf,UACA,MAQiC;CACjC,MAAM,YAA4C,EAAE;AAEpD,yBAAwB,UAAU,EACjC,kBAAkB,EAAE,SAAS,GAAG,WAAW;AAC1C,MAAI,KAAK,SAAS,KAAK,CACtB,WAAUA,UAAsB,KAAK,KAAK,IAAI;AAG/C,SAAO;IAER,CAAC;AAEF,QAAO;;AAGR,SAAgB,WACf,QACA,OAC8B;CAC9B,MAAM,SAAS,qBAAqB,UAAU,OAAO;AACrD,KAAI,CAAC,OAAO,QACX;CAGD,MAAM,wBAAQ,IAAI,KAA+B;CACjD,MAA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} from "../content/slices.js";
|
|
2
|
+
import { SharedSliceVariationContentModel } from "../model/slice.js";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/sliceContent.d.ts
|
|
5
|
+
declare namespace sliceContent_d_exports {
|
|
6
|
+
export { compositeToShared, legacyToShared };
|
|
7
|
+
}
|
|
8
|
+
declare const legacyToShared: (content: LegacySliceItemContent, model: SharedSliceVariationContentModel) => SharedSliceItemContent;
|
|
9
|
+
declare const compositeToShared: (content: CompositeSliceItemContent, model: SharedSliceVariationContentModel) => SharedSliceItemContent;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { sliceContent_d_exports };
|
|
12
|
+
//# sourceMappingURL=sliceContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sliceContent.d.ts","names":[],"sources":["../../src/helpers/sliceContent.ts"],"mappings":";;;;;;;cASa,cAAA,GACZ,OAAA,EAAS,sBAAA,EACT,KAAA,EAAO,gCAAA,KACL,sBAAA;AAAA,cAoCU,iBAAA,GACZ,OAAA,EAAS,yBAAA,EACT,KAAA,EAAO,gCAAA,KACL,sBAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region src/helpers/sliceContent.ts
|
|
3
|
+
var sliceContent_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
compositeToShared: () => compositeToShared,
|
|
5
|
+
legacyToShared: () => legacyToShared
|
|
6
|
+
});
|
|
7
|
+
const legacyToShared = (content, model) => {
|
|
8
|
+
const sliceUUID = content.key.split("$")[1];
|
|
9
|
+
const primary = {};
|
|
10
|
+
const items = [];
|
|
11
|
+
if (content.widget.__TYPE__ === "GroupContentType") for (const item of content.widget.value) {
|
|
12
|
+
const value = [];
|
|
13
|
+
for (const [key, nestable] of item.value) if (model.fields.items?.[key]) value.push([key, nestable]);
|
|
14
|
+
items.push({
|
|
15
|
+
...item,
|
|
16
|
+
value
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
else if (model.fields.primary?.[content.name]) primary[content.name] = content.widget;
|
|
20
|
+
return {
|
|
21
|
+
key: `${model.sliceName}$${sliceUUID}`,
|
|
22
|
+
name: model.sliceName,
|
|
23
|
+
maybeLabel: content.maybeLabel,
|
|
24
|
+
widget: {
|
|
25
|
+
__TYPE__: "SharedSliceContent",
|
|
26
|
+
variation: model.variationID,
|
|
27
|
+
primary,
|
|
28
|
+
items
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const compositeToShared = (content, model) => {
|
|
33
|
+
const sliceUUID = content.key.split("$")[1];
|
|
34
|
+
const primary = {};
|
|
35
|
+
for (const [key, value] of Object.entries(content.widget.nonRepeat)) if (model.fields.primary?.[key]) primary[key] = value;
|
|
36
|
+
const items = [];
|
|
37
|
+
for (const item of content.widget.repeat) {
|
|
38
|
+
const value = [];
|
|
39
|
+
for (const [key, nestable] of item.value) if (model.fields.items?.[key]) value.push([key, nestable]);
|
|
40
|
+
items.push({
|
|
41
|
+
...item,
|
|
42
|
+
value
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
key: `${model.sliceName}$${sliceUUID}`,
|
|
47
|
+
name: model.sliceName,
|
|
48
|
+
maybeLabel: content.maybeLabel,
|
|
49
|
+
widget: {
|
|
50
|
+
__TYPE__: "SharedSliceContent",
|
|
51
|
+
variation: model.variationID,
|
|
52
|
+
primary,
|
|
53
|
+
items
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { compositeToShared, legacyToShared, sliceContent_exports };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=sliceContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sliceContent.js","names":[],"sources":["../../src/helpers/sliceContent.ts"],"sourcesContent":["import type { GroupItemContent } from \"../content/group\"\nimport type { SharedSliceContent } from \"../content/slice\"\nimport type {\n\tCompositeSliceItemContent,\n\tLegacySliceItemContent,\n\tSharedSliceItemContent,\n} from \"../content/slices\"\nimport type { SharedSliceVariationContentModel } from \"../model/slice\"\n\nexport const legacyToShared = (\n\tcontent: LegacySliceItemContent,\n\tmodel: SharedSliceVariationContentModel,\n): SharedSliceItemContent => {\n\tconst sliceUUID = content.key.split(\"$\")[1]\n\n\tconst primary: SharedSliceContent[\"primary\"] = {}\n\tconst items: SharedSliceContent[\"items\"] = []\n\tif (content.widget.__TYPE__ === \"GroupContentType\") {\n\t\t// Group content\n\t\tfor (const item of content.widget.value) {\n\t\t\tconst value: GroupItemContent[\"value\"] = []\n\n\t\t\tfor (const [key, nestable] of item.value) {\n\t\t\t\tif (model.fields.items?.[key]) {\n\t\t\t\t\tvalue.push([key, nestable])\n\t\t\t\t}\n\t\t\t}\n\n\t\t\titems.push({ ...item, value })\n\t\t}\n\t} else if (model.fields.primary?.[content.name]) {\n\t\t// Nestable content\n\t\tprimary[content.name] = content.widget\n\t}\n\n\treturn {\n\t\tkey: `${model.sliceName}$${sliceUUID}`,\n\t\tname: model.sliceName,\n\t\tmaybeLabel: content.maybeLabel,\n\t\twidget: {\n\t\t\t__TYPE__: \"SharedSliceContent\",\n\t\t\tvariation: model.variationID,\n\t\t\tprimary,\n\t\t\titems,\n\t\t},\n\t}\n}\n\nexport const compositeToShared = (\n\tcontent: CompositeSliceItemContent,\n\tmodel: SharedSliceVariationContentModel,\n): SharedSliceItemContent => {\n\tconst sliceUUID = content.key.split(\"$\")[1]\n\n\tconst primary: SharedSliceContent[\"primary\"] = {}\n\tfor (const [key, value] of Object.entries(content.widget.nonRepeat)) {\n\t\tif (model.fields.primary?.[key]) {\n\t\t\tprimary[key] = value\n\t\t}\n\t}\n\n\tconst items: SharedSliceContent[\"items\"] = []\n\tfor (const item of content.widget.repeat) {\n\t\tconst value: GroupItemContent[\"value\"] = []\n\n\t\tfor (const [key, nestable] of item.value) {\n\t\t\tif (model.fields.items?.[key]) {\n\t\t\t\tvalue.push([key, nestable])\n\t\t\t}\n\t\t}\n\n\t\titems.push({ ...item, value })\n\t}\n\n\treturn {\n\t\tkey: `${model.sliceName}$${sliceUUID}`,\n\t\tname: model.sliceName,\n\t\tmaybeLabel: content.maybeLabel,\n\t\twidget: {\n\t\t\t__TYPE__: \"SharedSliceContent\",\n\t\t\tvariation: model.variationID,\n\t\t\tprimary,\n\t\t\titems,\n\t\t},\n\t}\n}\n"],"mappings":";;;;;;AASA,MAAa,kBACZ,SACA,UAC4B;CAC5B,MAAM,YAAY,QAAQ,IAAI,MAAM,IAAI,CAAC;CAEzC,MAAM,UAAyC,EAAE;CACjD,MAAM,QAAqC,EAAE;AAC7C,KAAI,QAAQ,OAAO,aAAa,mBAE/B,MAAK,MAAM,QAAQ,QAAQ,OAAO,OAAO;EACxC,MAAM,QAAmC,EAAE;AAE3C,OAAK,MAAM,CAAC,KAAK,aAAa,KAAK,MAClC,KAAI,MAAM,OAAO,QAAQ,KACxB,OAAM,KAAK,CAAC,KAAK,SAAS,CAAC;AAI7B,QAAM,KAAK;GAAE,GAAG;GAAM;GAAO,CAAC;;UAErB,MAAM,OAAO,UAAU,QAAQ,MAEzC,SAAQ,QAAQ,QAAQ,QAAQ;AAGjC,QAAO;EACN,KAAK,GAAG,MAAM,UAAU,GAAG;EAC3B,MAAM,MAAM;EACZ,YAAY,QAAQ;EACpB,QAAQ;GACP,UAAU;GACV,WAAW,MAAM;GACjB;GACA;GACA;EACD;;AAGF,MAAa,qBACZ,SACA,UAC4B;CAC5B,MAAM,YAAY,QAAQ,IAAI,MAAM,IAAI,CAAC;CAEzC,MAAM,UAAyC,EAAE;AACjD,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,QAAQ,OAAO,UAAU,CAClE,KAAI,MAAM,OAAO,UAAU,KAC1B,SAAQ,OAAO;CAIjB,MAAM,QAAqC,EAAE;AAC7C,MAAK,MAAM,QAAQ,QAAQ,OAAO,QAAQ;EACzC,MAAM,QAAmC,EAAE;AAE3C,OAAK,MAAM,CAAC,KAAK,aAAa,KAAK,MAClC,KAAI,MAAM,OAAO,QAAQ,KACxB,OAAM,KAAK,CAAC,KAAK,SAAS,CAAC;AAI7B,QAAM,KAAK;GAAE,GAAG;GAAM;GAAO,CAAC;;AAG/B,QAAO;EACN,KAAK,GAAG,MAAM,UAAU,GAAG;EAC3B,MAAM,MAAM;EACZ,YAAY,QAAQ;EACpB,QAAQ;GACP,UAAU;GACV,WAAW,MAAM;GACjB;GACA;GACA;EACD"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { GroupModel, NestedGroupModel } from "../model/group.js";
|
|
2
|
-
import { NestableModel } from "../model/nestable.js";
|
|
3
|
-
import { GroupContent, GroupItemContent } from "../content/group.js";
|
|
4
|
-
import { DocumentContent } from "../content/document.js";
|
|
5
1
|
import { RepeatableContent } from "../content/repeatable.js";
|
|
6
|
-
import { CompositeSliceItemContent, LegacySliceItemContent, SharedSliceItemContent, SliceItemContent, SlicesContent } from "../content/slices.js";
|
|
7
2
|
import { TableContent } from "../content/table.js";
|
|
3
|
+
import { GroupContent, GroupItemContent } from "../content/group.js";
|
|
4
|
+
import { CompositeSliceItemContent, LegacySliceItemContent, SharedSliceItemContent, SliceItemContent, SlicesContent } from "../content/slices.js";
|
|
8
5
|
import { WidgetContent } from "../content/widget.js";
|
|
9
|
-
import {
|
|
6
|
+
import { DocumentContent } from "../content/document.js";
|
|
10
7
|
import { LinkModel } from "../model/link.js";
|
|
11
|
-
import { CompositeSliceModel, LegacySliceModel, SharedSliceVariationModel } from "../model/slice.js";
|
|
12
|
-
import { StaticSlicesModel } from "../model/slices.js";
|
|
13
8
|
import { TableModel } from "../model/table.js";
|
|
9
|
+
import { NestableModel } from "../model/nestable.js";
|
|
10
|
+
import { GroupModel, NestedGroupModel } from "../model/group.js";
|
|
11
|
+
import { CompositeSliceModel, LegacySliceModel, SharedSliceVariationContentModel, SliceContentModel } from "../model/slice.js";
|
|
12
|
+
import { StaticSlicesModel } from "../model/slices.js";
|
|
14
13
|
import { StaticWidgetModel } from "../model/widget.js";
|
|
14
|
+
import { StaticCustomTypeModel } from "../model/customType.js";
|
|
15
15
|
import { Path } from "./contentPath.js";
|
|
16
16
|
|
|
17
17
|
//#region src/helpers/traverseContent.d.ts
|
|
@@ -28,23 +28,23 @@ type TraverseSlicesContentConfig = {
|
|
|
28
28
|
};
|
|
29
29
|
declare function traverseSlicesContent(path: Path, key: string, apiID: string, content: SlicesContent, config: TraverseSlicesContentConfig): SlicesContent | undefined;
|
|
30
30
|
type TraverseSharedSliceContentConfig = {
|
|
31
|
-
model?:
|
|
31
|
+
model?: SharedSliceVariationContentModel;
|
|
32
32
|
transformWidget?: TraverseWidgetContentFunction;
|
|
33
33
|
transformSlice?: TraverseSliceContentFunction;
|
|
34
34
|
};
|
|
35
35
|
declare function traverseSharedSliceContent(path: Path, key: string, apiID: string, content: SharedSliceItemContent, config: TraverseSharedSliceContentConfig): SharedSliceItemContent | undefined;
|
|
36
36
|
type TraverseCompositeSliceContentConfig = {
|
|
37
|
-
model?: CompositeSliceModel;
|
|
37
|
+
model?: CompositeSliceModel | SharedSliceVariationContentModel;
|
|
38
38
|
transformWidget?: TraverseWidgetContentFunction;
|
|
39
39
|
transformSlice?: TraverseSliceContentFunction;
|
|
40
40
|
};
|
|
41
|
-
declare function traverseCompositeSliceContent(path: Path, key: string, apiID: string, content: CompositeSliceItemContent, config: TraverseCompositeSliceContentConfig): CompositeSliceItemContent | undefined;
|
|
41
|
+
declare function traverseCompositeSliceContent(path: Path, key: string, apiID: string, content: CompositeSliceItemContent, config: TraverseCompositeSliceContentConfig): CompositeSliceItemContent | SharedSliceItemContent | undefined;
|
|
42
42
|
type TraverseLegacySliceContentConfig = {
|
|
43
|
-
model?: LegacySliceModel;
|
|
43
|
+
model?: LegacySliceModel | SharedSliceVariationContentModel;
|
|
44
44
|
transformWidget?: TraverseWidgetContentFunction;
|
|
45
45
|
transformSlice?: TraverseSliceContentFunction;
|
|
46
46
|
};
|
|
47
|
-
declare function traverseLegacySliceContent(path: Path, key: string, apiID: string, content: LegacySliceItemContent, config: TraverseLegacySliceContentConfig): LegacySliceItemContent | undefined;
|
|
47
|
+
declare function traverseLegacySliceContent(path: Path, key: string, apiID: string, content: LegacySliceItemContent, config: TraverseLegacySliceContentConfig): LegacySliceItemContent | SharedSliceItemContent | undefined;
|
|
48
48
|
type TraverseGroupContentConfig = {
|
|
49
49
|
model?: GroupModel;
|
|
50
50
|
transformWidget: TraverseWidgetContentFunction;
|
|
@@ -70,8 +70,8 @@ type TraverseSliceContentFunction = <TContent extends SliceItemContent>(args: {
|
|
|
70
70
|
key: string;
|
|
71
71
|
apiID: string;
|
|
72
72
|
content: TContent;
|
|
73
|
-
model?:
|
|
74
|
-
}) => TContent | undefined;
|
|
73
|
+
model?: SliceContentModel;
|
|
74
|
+
}) => TContent | SharedSliceItemContent | undefined;
|
|
75
75
|
type TraverseWidgetContentFunction<TContentTransformMode extends "preserve" | "widen" = "preserve"> = <TContent extends WidgetContent>(args: {
|
|
76
76
|
path: Path;
|
|
77
77
|
key: string;
|
|
@@ -79,7 +79,6 @@ type TraverseWidgetContentFunction<TContentTransformMode extends "preserve" | "w
|
|
|
79
79
|
content: TContent;
|
|
80
80
|
model?: StaticWidgetModel;
|
|
81
81
|
}) => (TContentTransformMode extends "preserve" ? TContent : WidgetContent) | undefined;
|
|
82
|
-
type SliceModel = SharedSliceVariationModel | CompositeSliceModel | LegacySliceModel;
|
|
83
82
|
//#endregion
|
|
84
83
|
export { TraverseSliceContentFunction, TraverseWidgetContentFunction, traverseCompositeSliceContent, traverseDocumentContent, traverseGroupContent, traverseGroupItemsContent, traverseLegacySliceContent, traverseRepeatableContent, traverseSharedSliceContent, traverseSlicesContent, traverseTableContent };
|
|
85
84
|
//# sourceMappingURL=traverseContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverseContent.d.ts","names":[],"sources":["../../src/helpers/traverseContent.ts"],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|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TableCellModel } from "../model/table.js";
|
|
2
|
+
import { append, make, serialize } from "./contentPath.js";
|
|
2
3
|
import { flatten } from "./customTypeModel.js";
|
|
3
4
|
import { isRepeatableContentValue } from "../content/repeatable.js";
|
|
4
5
|
import { RichTextContentType } from "../content/richText.js";
|
|
@@ -7,7 +8,6 @@ import { isNestableContent } from "../content/nestable.js";
|
|
|
7
8
|
import "../content/group.js";
|
|
8
9
|
import "../content/slice.js";
|
|
9
10
|
import "../content/slices.js";
|
|
10
|
-
import { TableCellModel } from "../model/table.js";
|
|
11
11
|
//#region src/helpers/traverseContent.ts
|
|
12
12
|
function traverseDocumentContent(document, config) {
|
|
13
13
|
const { model, transformWidget, transformSlice } = config;
|
|
@@ -34,22 +34,44 @@ function traverseSlicesContent(path, key, apiID, content, config) {
|
|
|
34
34
|
const traversed = [];
|
|
35
35
|
for (const sliceItemContent of content.value) {
|
|
36
36
|
const sliceModel = config.model?.config?.choices?.[sliceItemContent.name];
|
|
37
|
-
let
|
|
38
|
-
if (sliceItemContent.widget.__TYPE__ === "SharedSliceContent") {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
let sliceContentModel;
|
|
38
|
+
if (sliceItemContent.widget.__TYPE__ === "SharedSliceContent" && sliceModel?.type === "SharedSlice") {
|
|
39
|
+
const variationID = sliceItemContent.widget.variation;
|
|
40
|
+
const variationModel = sliceModel.variations.find((variation) => variation.id === variationID);
|
|
41
|
+
if (variationModel) sliceContentModel = {
|
|
42
|
+
type: "SharedSlice",
|
|
43
|
+
sliceName: sliceModel.id,
|
|
44
|
+
variationID: variationModel.id,
|
|
45
|
+
fields: {
|
|
46
|
+
primary: variationModel.primary || {},
|
|
47
|
+
items: variationModel.items || {}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (!sliceContentModel) {
|
|
52
|
+
const legacyPath = append(serialize(path), sliceItemContent.name);
|
|
53
|
+
const migratedSliceModel = Object.values(config.model?.config?.choices || {}).find((model) => {
|
|
54
|
+
return model.type === "SharedSlice" && Boolean(model.legacyPaths?.[legacyPath]);
|
|
55
|
+
});
|
|
56
|
+
if (migratedSliceModel) {
|
|
57
|
+
const variation = migratedSliceModel.variations.find((variation) => {
|
|
58
|
+
return variation.id === migratedSliceModel.legacyPaths?.[legacyPath];
|
|
59
|
+
});
|
|
60
|
+
if (variation) sliceContentModel = {
|
|
44
61
|
type: "SharedSlice",
|
|
45
|
-
sliceName:
|
|
46
|
-
variationID,
|
|
62
|
+
sliceName: migratedSliceModel.id,
|
|
63
|
+
variationID: variation.id,
|
|
47
64
|
fields: {
|
|
48
|
-
primary:
|
|
49
|
-
items:
|
|
65
|
+
primary: variation.primary || {},
|
|
66
|
+
items: variation.items || {}
|
|
50
67
|
}
|
|
51
68
|
};
|
|
52
69
|
}
|
|
70
|
+
}
|
|
71
|
+
if (!sliceContentModel && sliceModel && sliceModel.type !== "SharedSlice") sliceContentModel = sliceModel;
|
|
72
|
+
let traversedSliceItemContent;
|
|
73
|
+
if (sliceItemContent.widget.__TYPE__ === "SharedSliceContent") {
|
|
74
|
+
const model = sliceContentModel?.type === "SharedSlice" ? sliceContentModel : void 0;
|
|
53
75
|
traversedSliceItemContent = traverseSharedSliceContent(path.concat({
|
|
54
76
|
key: sliceItemContent.key,
|
|
55
77
|
type: "SharedSlice"
|
|
@@ -59,7 +81,7 @@ function traverseSlicesContent(path, key, apiID, content, config) {
|
|
|
59
81
|
transformSlice
|
|
60
82
|
});
|
|
61
83
|
} else if (sliceItemContent.widget.__TYPE__ === "CompositeSliceContent") {
|
|
62
|
-
const model =
|
|
84
|
+
const model = sliceContentModel?.type === "Slice" || sliceContentModel?.type === "SharedSlice" ? sliceContentModel : void 0;
|
|
63
85
|
traversedSliceItemContent = traverseCompositeSliceContent(path.concat({
|
|
64
86
|
key: sliceItemContent.key,
|
|
65
87
|
type: "Slice"
|
|
@@ -69,7 +91,7 @@ function traverseSlicesContent(path, key, apiID, content, config) {
|
|
|
69
91
|
transformSlice
|
|
70
92
|
});
|
|
71
93
|
} else {
|
|
72
|
-
const model =
|
|
94
|
+
const model = sliceContentModel?.type !== "Slice" ? sliceContentModel : void 0;
|
|
73
95
|
traversedSliceItemContent = traverseLegacySliceContent(path.concat({
|
|
74
96
|
key: sliceItemContent.key,
|
|
75
97
|
type: "LegacySlice"
|
|
@@ -133,9 +155,9 @@ function traverseSharedSliceContent(path, key, apiID, content, config) {
|
|
|
133
155
|
}
|
|
134
156
|
function traverseCompositeSliceContent(path, key, apiID, content, config) {
|
|
135
157
|
const { transformWidget = (args) => args.content, transformSlice = (args) => args.content } = config;
|
|
158
|
+
const primaryModel = config.model?.type === "SharedSlice" ? config.model?.fields.primary : config.model?.["non-repeat"];
|
|
136
159
|
const traversedPrimary = {};
|
|
137
160
|
for (const [key, fieldContent] of Object.entries(content.widget.nonRepeat)) {
|
|
138
|
-
const model = config.model?.["non-repeat"]?.[key];
|
|
139
161
|
const traversedContent = traverseWidgetContent(path.concat({
|
|
140
162
|
key: "non-repeat",
|
|
141
163
|
type: "primary"
|
|
@@ -143,16 +165,17 @@ function traverseCompositeSliceContent(path, key, apiID, content, config) {
|
|
|
143
165
|
key,
|
|
144
166
|
type: "Widget"
|
|
145
167
|
}), key, apiID, fieldContent, {
|
|
146
|
-
model,
|
|
168
|
+
model: primaryModel?.[key],
|
|
147
169
|
transformWidget
|
|
148
170
|
});
|
|
149
171
|
if (traversedContent && isNestableContent(traversedContent)) traversedPrimary[key] = traversedContent;
|
|
150
172
|
}
|
|
173
|
+
const itemsModel = config.model?.type === "SharedSlice" ? config.model?.fields.items : config.model?.repeat;
|
|
151
174
|
const traversedItems = traverseGroupItemsContent(path.concat({
|
|
152
175
|
key: "repeat",
|
|
153
176
|
type: "items"
|
|
154
177
|
}), content.widget.repeat, {
|
|
155
|
-
model:
|
|
178
|
+
model: itemsModel,
|
|
156
179
|
transformWidget
|
|
157
180
|
});
|
|
158
181
|
return transformSlice({
|
|
@@ -172,8 +195,19 @@ function traverseCompositeSliceContent(path, key, apiID, content, config) {
|
|
|
172
195
|
}
|
|
173
196
|
function traverseLegacySliceContent(path, key, apiID, content, config) {
|
|
174
197
|
const { model, transformWidget = (args) => args.content, transformSlice = (args) => args.content } = config;
|
|
198
|
+
let legacySliceModel;
|
|
199
|
+
if (content.widget.__TYPE__ === "GroupContentType") {
|
|
200
|
+
if (model?.type === "Group") legacySliceModel = model;
|
|
201
|
+
else if (model?.type === "SharedSlice") legacySliceModel = {
|
|
202
|
+
type: "Group",
|
|
203
|
+
config: { fields: model.fields.items }
|
|
204
|
+
};
|
|
205
|
+
} else if (model?.type === "SharedSlice") {
|
|
206
|
+
const primaryModel = model.fields.primary?.[content.name];
|
|
207
|
+
if (primaryModel?.type !== "Group") legacySliceModel = primaryModel;
|
|
208
|
+
} else if (model?.type !== "Group") legacySliceModel = model;
|
|
175
209
|
const traversedContent = traverseWidgetContent(path, key, apiID, content.widget, {
|
|
176
|
-
model,
|
|
210
|
+
model: legacySliceModel,
|
|
177
211
|
transformWidget,
|
|
178
212
|
transformSlice
|
|
179
213
|
});
|