@prismicio/types-internal 4.0.0-pr.6.38cb7de → 4.0.0-pr.6.6ce647d
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/content/legacy/group.d.ts.map +1 -1
- package/dist/content/legacy/group.js.map +1 -1
- package/dist/content/legacy/nestable.js.map +1 -1
- package/dist/content/legacy/repeatable.js +2 -8
- package/dist/content/legacy/repeatable.js.map +1 -1
- package/dist/content/legacy/slice.js +2 -3
- package/dist/content/legacy/slice.js.map +1 -1
- package/dist/content/nestable.js +1 -0
- package/dist/content/nestable.js.map +1 -1
- package/dist/helpers/contentPath.js +1 -1
- package/dist/helpers/customTypeModel.js +1 -1
- package/dist/helpers/documentContent.d.ts +2 -1
- 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 +5 -5
- package/dist/helpers/traverseContent.d.ts.map +1 -1
- package/dist/helpers/traverseContent.js +50 -18
- package/dist/helpers/traverseContent.js.map +1 -1
- package/dist/helpers/traverseContentWithModel.d.ts +4 -4
- package/dist/helpers/traverseContentWithModel.d.ts.map +1 -1
- package/dist/helpers/traverseContentWithModel.js +60 -34
- package/dist/helpers/traverseContentWithModel.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/io-ts.d.ts +1 -69
- package/dist/io-ts.d.ts.map +1 -1
- package/dist/model/table.d.ts.map +1 -1
- package/dist/model/table.js.map +1 -1
- package/dist/model/widget.d.ts +8 -8
- package/package.json +1 -1
- package/src/content/legacy/group.ts +2 -0
- package/src/content/legacy/nestable.ts +1 -1
- package/src/content/legacy/repeatable.ts +3 -16
- package/src/content/legacy/slice.ts +6 -5
- package/src/content/nestable.ts +2 -0
- package/src/helpers/documentContent.ts +32 -1
- package/src/helpers/sliceContent.ts +86 -0
- package/src/helpers/traverseContent.ts +89 -27
- package/src/helpers/traverseContentWithModel.ts +69 -42
- package/src/index.ts +1 -0
- package/src/model/table.ts +2 -1
|
@@ -34,17 +34,17 @@ type TraverseSharedSliceContentWithModelConfig = {
|
|
|
34
34
|
};
|
|
35
35
|
declare function traverseSharedSliceContentWithModel(path: Path, key: string, apiID: string, content: SharedSliceItemContent | undefined, config: TraverseSharedSliceContentWithModelConfig): SharedSliceItemContent | undefined;
|
|
36
36
|
type TraverseCompositeSliceContentWithModelConfig = {
|
|
37
|
-
model: CompositeSliceModel;
|
|
37
|
+
model: CompositeSliceModel | SharedSliceVariationContentModel;
|
|
38
38
|
transformWidget?: TraverseWidgetContentWithModelFunction;
|
|
39
39
|
transformSlice?: TraverseSliceContentWithModelFunction;
|
|
40
40
|
};
|
|
41
|
-
declare function traverseCompositeSliceContentWithModel(path: Path, key: string, apiID: string, content: CompositeSliceItemContent | undefined, config: TraverseCompositeSliceContentWithModelConfig): CompositeSliceItemContent | undefined;
|
|
41
|
+
declare function traverseCompositeSliceContentWithModel(path: Path, key: string, apiID: string, content: CompositeSliceItemContent | undefined, config: TraverseCompositeSliceContentWithModelConfig): CompositeSliceItemContent | SharedSliceItemContent | undefined;
|
|
42
42
|
type TraverseLegacySliceContentWithModelConfig = {
|
|
43
43
|
model: LegacySliceModel;
|
|
44
44
|
transformWidget?: TraverseWidgetContentWithModelFunction;
|
|
45
45
|
transformSlice?: TraverseSliceContentWithModelFunction;
|
|
46
46
|
};
|
|
47
|
-
declare function traverseLegacySliceContentWithModel(path: Path, key: string, apiID: string, content: LegacySliceItemContent | undefined, config: TraverseLegacySliceContentWithModelConfig): LegacySliceItemContent | undefined;
|
|
47
|
+
declare function traverseLegacySliceContentWithModel(path: Path, key: string, apiID: string, content: LegacySliceItemContent | undefined, config: TraverseLegacySliceContentWithModelConfig): LegacySliceItemContent | SharedSliceItemContent | undefined;
|
|
48
48
|
type TraverseGroupContentWithModelConfig = {
|
|
49
49
|
model: GroupModel;
|
|
50
50
|
transformWidget: TraverseWidgetContentWithModelFunction;
|
|
@@ -71,7 +71,7 @@ type TraverseSliceContentWithModelFunction = <TContent extends SliceItemContent>
|
|
|
71
71
|
apiID: string;
|
|
72
72
|
content?: TContent;
|
|
73
73
|
model: SliceContentModel;
|
|
74
|
-
}) => TContent | undefined;
|
|
74
|
+
}) => TContent | SharedSliceItemContent | undefined;
|
|
75
75
|
type TraverseWidgetContentWithModelFunction<TContentTransformMode extends "preserve" | "widen" = "preserve"> = <TContent extends WidgetContent>(args: {
|
|
76
76
|
path: Path;
|
|
77
77
|
key: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverseContentWithModel.d.ts","names":[],"sources":["../../src/helpers/traverseContentWithModel.ts"],"mappings":";;;;;;;;;;;;;;;;;KAoCK,sCAAA;EACJ,KAAA,EAAO,qBAAA;EACP,eAAA,GAAkB,sCAAA;EAClB,cAAA,GAAiB,qCAAA;AAAA;AAAA,iBAGF,gCAAA,CACf,QAAA,EAAU,eAAA,EACV,MAAA,EAAQ,sCAAA,GACN,eAAA;AAAA,KA0BE,oCAAA;EACJ,KAAA,EAAO,iBAAA;EACP,eAAA,GAAkB,sCAAA;EAClB,cAAA,GAAiB,qCAAA;AAAA;AAAA,iBAGF,8BAAA,CACf,IAAA,EAAM,IAAA,EACN,GAAA,UACA,KAAA,UACA,OAAA,EAAS,aAAA,cACT,MAAA,EAAQ,oCAAA,GACN,aAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"traverseContentWithModel.d.ts","names":[],"sources":["../../src/helpers/traverseContentWithModel.ts"],"mappings":";;;;;;;;;;;;;;;;;KAoCK,sCAAA;EACJ,KAAA,EAAO,qBAAA;EACP,eAAA,GAAkB,sCAAA;EAClB,cAAA,GAAiB,qCAAA;AAAA;AAAA,iBAGF,gCAAA,CACf,QAAA,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;EACJ,KAAA,EAAO,MAAA,SAAe,gBAAA,GAAmB,aAAA;EACzC,eAAA,EAAiB,sCAAA;AAAA;AAAA,iBAGF,kCAAA,CACf,IAAA,EAAM,IAAA,EACN,OAAA,EAAS,gBAAA,gBACT,MAAA,EAAQ,wCAAA,GACN,gBAAA;AAAA,KAoCE,wCAAA;EACJ,KAAA,EAAO,SAAA;EACP,eAAA,EAAiB,sCAAA;AAAA;AAAA,iBAGF,kCAAA,CACf,IAAA,EAAM,IAAA,EACN,GAAA,UACA,KAAA,UACA,OAAA,EAAS,iBAAA,cACT,MAAA,EAAQ,wCAAA,GACN,iBAAA;AAAA,KAyCE,mCAAA;EACJ,KAAA,EAAO,UAAA;EACP,eAAA,EAAiB,sCAAA;AAAA;AAAA,iBAGF,6BAAA,CACf,IAAA,EAAM,IAAA,EACN,GAAA,UACA,KAAA,UACA,OAAA,EAAS,YAAA,cACT,MAAA,EAAQ,mCAAA,GACN,YAAA;AAAA,KAoDS,qCAAA,qBAA0D,gBAAA,EAAkB,IAAA;EACvF,IAAA,EAAM,IAAA;EACN,GAAA;EACA,KAAA;EACA,OAAA,GAAU,QAAA;EACV,KAAA,EAAO,iBAAA;AAAA,MACF,QAAA,GAAW,sBAAA;AAAA,KAEL,sCAAA,sFAEU,aAAA,EAAe,IAAA;EACpC,IAAA,EAAM,IAAA;EACN,GAAA;EACA,KAAA;EACA,OAAA,GAAU,QAAA;EACV,KAAA,EAAO,iBAAA;AAAA,OACD,qBAAA,sBAA2C,QAAA,GAAW,aAAA"}
|
|
@@ -39,43 +39,67 @@ function traverseSlicesContentWithModel(path, key, apiID, content, config) {
|
|
|
39
39
|
});
|
|
40
40
|
const traversed = [];
|
|
41
41
|
for (const sliceItemContent of content.value) {
|
|
42
|
-
const
|
|
42
|
+
const sliceModel = config.model.config?.choices?.[sliceItemContent.name];
|
|
43
43
|
let traversedSliceItemContent;
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
44
|
+
if (sliceModel?.type === "SharedSlice") {
|
|
45
|
+
if (sliceItemContent.widget.__TYPE__ === "SharedSliceContent") {
|
|
46
|
+
const variationID = sliceItemContent.widget.variation;
|
|
47
|
+
const variationModel = sliceModel.variations.find((variation) => variation.id === variationID);
|
|
48
|
+
if (variationModel) {
|
|
49
|
+
const model = {
|
|
50
|
+
type: "SharedSlice",
|
|
51
|
+
sliceName: sliceModel.id,
|
|
52
|
+
variationID: variationModel.id,
|
|
53
|
+
fields: {
|
|
54
|
+
primary: variationModel.primary || {},
|
|
55
|
+
items: variationModel.items || {}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
traversedSliceItemContent = traverseSharedSliceContentWithModel(path.concat({
|
|
59
|
+
key: sliceItemContent.key,
|
|
60
|
+
type: "SharedSlice"
|
|
61
|
+
}), sliceItemContent.key, sliceItemContent.name, sliceItemContent, {
|
|
62
|
+
model,
|
|
63
|
+
transformWidget,
|
|
64
|
+
transformSlice
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
} else if (sliceItemContent.widget.__TYPE__ === "CompositeSliceContent") {
|
|
68
|
+
const variationModel = sliceModel.variations[0];
|
|
69
|
+
if (variationModel) {
|
|
70
|
+
const model = {
|
|
71
|
+
type: "SharedSlice",
|
|
72
|
+
sliceName: sliceModel.id,
|
|
73
|
+
variationID: variationModel.id,
|
|
74
|
+
fields: {
|
|
75
|
+
primary: variationModel.primary || {},
|
|
76
|
+
items: variationModel.items || {}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
traversedSliceItemContent = traverseCompositeSliceContentWithModel(path.concat({
|
|
80
|
+
key: sliceItemContent.key,
|
|
81
|
+
type: "Slice"
|
|
82
|
+
}), sliceItemContent.key, sliceItemContent.name, sliceItemContent, {
|
|
83
|
+
model,
|
|
84
|
+
transformWidget,
|
|
85
|
+
transformSlice
|
|
86
|
+
});
|
|
87
|
+
}
|
|
65
88
|
}
|
|
66
|
-
} else if (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
89
|
+
} else if (sliceModel?.type === "Slice") {
|
|
90
|
+
if (sliceItemContent.widget.__TYPE__ === "CompositeSliceContent") traversedSliceItemContent = traverseCompositeSliceContentWithModel(path.concat({
|
|
91
|
+
key: sliceItemContent.key,
|
|
92
|
+
type: "Slice"
|
|
93
|
+
}), sliceItemContent.key, sliceItemContent.name, sliceItemContent, {
|
|
94
|
+
model: sliceModel,
|
|
95
|
+
transformWidget,
|
|
96
|
+
transformSlice
|
|
97
|
+
});
|
|
98
|
+
} else if (sliceModel && sliceItemContent.widget.__TYPE__ !== "SharedSliceContent" && sliceItemContent.widget.__TYPE__ !== "CompositeSliceContent") traversedSliceItemContent = traverseLegacySliceContentWithModel(path.concat({
|
|
75
99
|
key: sliceItemContent.key,
|
|
76
100
|
type: "LegacySlice"
|
|
77
101
|
}), sliceItemContent.key, sliceItemContent.name, sliceItemContent, {
|
|
78
|
-
model,
|
|
102
|
+
model: sliceModel,
|
|
79
103
|
transformWidget,
|
|
80
104
|
transformSlice
|
|
81
105
|
});
|
|
@@ -134,8 +158,9 @@ function traverseSharedSliceContentWithModel(path, key, apiID, content, config)
|
|
|
134
158
|
function traverseCompositeSliceContentWithModel(path, key, apiID, content, config) {
|
|
135
159
|
if (!content) return;
|
|
136
160
|
const { transformWidget = (args) => args.content, transformSlice = (args) => args.content } = config;
|
|
161
|
+
const primaryModel = config.model?.type === "SharedSlice" ? config.model?.fields.primary : config.model?.["non-repeat"];
|
|
137
162
|
const traversedPrimary = {};
|
|
138
|
-
for (const [key, model] of Object.entries(
|
|
163
|
+
for (const [key, model] of Object.entries(primaryModel ?? {})) {
|
|
139
164
|
const traversedContent = traverseWidgetContentWithModel(path.concat({
|
|
140
165
|
key: "non-repeat",
|
|
141
166
|
type: "primary"
|
|
@@ -148,11 +173,12 @@ function traverseCompositeSliceContentWithModel(path, key, apiID, content, confi
|
|
|
148
173
|
});
|
|
149
174
|
if (traversedContent && isNestableContent(traversedContent)) traversedPrimary[key] = traversedContent;
|
|
150
175
|
}
|
|
176
|
+
const itemsModel = config.model?.type === "SharedSlice" ? config.model?.fields.items : config.model?.repeat;
|
|
151
177
|
const traversedItems = traverseGroupItemsContentWithModel(path.concat({
|
|
152
178
|
key: "repeat",
|
|
153
179
|
type: "items"
|
|
154
180
|
}), content.widget.repeat, {
|
|
155
|
-
model:
|
|
181
|
+
model: itemsModel ?? {},
|
|
156
182
|
transformWidget
|
|
157
183
|
});
|
|
158
184
|
return transformSlice({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverseContentWithModel.js","names":["customTypeModel.flatten","contentPath.make"],"sources":["../../src/helpers/traverseContentWithModel.ts"],"sourcesContent":["import type { DocumentContent } from \"../content/document\"\nimport { GroupContentType } from \"../content/group\"\nimport type { GroupContent, GroupItemContent } from \"../content/group\"\nimport { isNestableContent } from \"../content/nestable\"\nimport { isRepeatableContentValue, RepeatableContentType } from \"../content/repeatable\"\nimport type { RepeatableContent } from \"../content/repeatable\"\nimport { RichTextContentType } from \"../content/richText\"\nimport { CompositeSliceContentType, SharedSliceContentType } from \"../content/slice\"\nimport type { CompositeSliceContent, SharedSliceContent } from \"../content/slice\"\nimport {\n\ttype CompositeSliceItemContent,\n\ttype SharedSliceItemContent,\n\ttype LegacySliceItemContent,\n\ttype SliceItemContent,\n\ttype SlicesContent,\n\tSlicesContentType,\n} from \"../content/slices\"\nimport { TableContentType, type TableContent } from \"../content/table\"\nimport type { WidgetContent } from \"../content/widget\"\nimport type { StaticCustomTypeModel } from \"../model/customType\"\nimport type { GroupModel, NestedGroupModel } from \"../model/group\"\nimport type { LinkModel } from \"../model/link\"\nimport type { NestableModel } from \"../model/nestable\"\nimport type {\n\tCompositeSliceModel,\n\tLegacySliceModel,\n\tSharedSliceVariationContentModel,\n\tSliceContentModel,\n} from \"../model/slice\"\nimport type { StaticSlicesModel } from \"../model/slices\"\nimport { TableCellModel } from \"../model/table\"\nimport type { TableModel } from \"../model/table\"\nimport type { StaticWidgetModel } from \"../model/widget\"\nimport * as contentPath from \"./contentPath\"\nimport * as customTypeModel from \"./customTypeModel\"\n\ntype TraverseDocumentContentWithModelConfig = {\n\tmodel: StaticCustomTypeModel\n\ttransformWidget?: TraverseWidgetContentWithModelFunction\n\ttransformSlice?: TraverseSliceContentWithModelFunction\n}\n\nexport function traverseDocumentContentWithModel(\n\tdocument: DocumentContent,\n\tconfig: TraverseDocumentContentWithModelConfig,\n): DocumentContent {\n\tconst { model, transformWidget, transformSlice } = config\n\n\t// Remove tabs from custom type model\n\tconst flatModel = model ? customTypeModel.flatten(model) : {}\n\n\tconst traversed: DocumentContent = {}\n\tfor (const [key, model] of Object.entries(flatModel)) {\n\t\tconst path = contentPath.make(\n\t\t\t{ key: config.model.id, type: \"CustomType\" },\n\t\t\t{ key, type: \"Widget\" },\n\t\t)\n\n\t\tconst traversedContent = traverseWidgetContentWithModel(path, key, key, document[key], {\n\t\t\tmodel,\n\t\t\ttransformWidget,\n\t\t\ttransformSlice,\n\t\t})\n\t\tif (traversedContent) {\n\t\t\ttraversed[key] = traversedContent\n\t\t}\n\t}\n\n\treturn traversed\n}\n\ntype TraverseSlicesContentWithModelConfig = {\n\tmodel: StaticSlicesModel\n\ttransformWidget?: TraverseWidgetContentWithModelFunction\n\ttransformSlice?: TraverseSliceContentWithModelFunction\n}\n\nexport function traverseSlicesContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: SlicesContent | undefined,\n\tconfig: TraverseSlicesContentWithModelConfig,\n): SlicesContent | undefined {\n\tconst { transformWidget = (args) => args.content, transformSlice = (args) => args.content } =\n\t\tconfig\n\n\tif (!content) {\n\t\treturn transformWidget({\n\t\t\tpath,\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tmodel: config.model,\n\t\t})\n\t}\n\n\tconst traversed: SlicesContent[\"value\"] = []\n\tfor (const sliceItemContent of content.value) {\n\t\tconst model = config.model.config?.choices?.[sliceItemContent.name]\n\n\t\tlet traversedSliceItemContent: SliceItemContent | undefined\n\t\tif (\n\t\t\tmodel?.type === \"SharedSlice\" &&\n\t\t\tsliceItemContent.widget.__TYPE__ === SharedSliceContentType\n\t\t) {\n\t\t\tconst variationID = sliceItemContent.widget.variation\n\t\t\tconst variationModel = model.variations.find((variation) => variation.id === variationID)\n\t\t\tif (variationModel) {\n\t\t\t\tconst sharedSliceVariationModel: SharedSliceVariationContentModel = {\n\t\t\t\t\ttype: \"SharedSlice\",\n\t\t\t\t\tsliceName: model.id,\n\t\t\t\t\tvariationID,\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tprimary: variationModel.primary || {},\n\t\t\t\t\t\titems: variationModel.items || {},\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\ttraversedSliceItemContent = traverseSharedSliceContentWithModel(\n\t\t\t\t\tpath.concat({ key: sliceItemContent.key, type: \"SharedSlice\" }),\n\t\t\t\t\tsliceItemContent.key,\n\t\t\t\t\tsliceItemContent.name,\n\t\t\t\t\tsliceItemContent as SharedSliceItemContent,\n\t\t\t\t\t{ model: sharedSliceVariationModel, transformWidget, transformSlice },\n\t\t\t\t)\n\t\t\t}\n\t\t} else if (\n\t\t\tmodel?.type === \"Slice\" &&\n\t\t\tsliceItemContent.widget.__TYPE__ === CompositeSliceContentType\n\t\t) {\n\t\t\ttraversedSliceItemContent = traverseCompositeSliceContentWithModel(\n\t\t\t\tpath.concat({ key: sliceItemContent.key, type: \"Slice\" }),\n\t\t\t\tsliceItemContent.key,\n\t\t\t\tsliceItemContent.name,\n\t\t\t\tsliceItemContent as CompositeSliceItemContent,\n\t\t\t\t{ model, transformWidget, transformSlice },\n\t\t\t)\n\t\t} else if (\n\t\t\tmodel &&\n\t\t\tmodel?.type !== \"SharedSlice\" &&\n\t\t\tmodel?.type !== \"Slice\" &&\n\t\t\tsliceItemContent.widget.__TYPE__ !== SharedSliceContentType &&\n\t\t\tsliceItemContent.widget.__TYPE__ !== CompositeSliceContentType\n\t\t) {\n\t\t\ttraversedSliceItemContent = traverseLegacySliceContentWithModel(\n\t\t\t\tpath.concat({ key: sliceItemContent.key, type: \"LegacySlice\" }),\n\t\t\t\tsliceItemContent.key,\n\t\t\t\tsliceItemContent.name,\n\t\t\t\tsliceItemContent as LegacySliceItemContent,\n\t\t\t\t{ model, transformWidget, transformSlice },\n\t\t\t)\n\t\t}\n\n\t\tif (traversedSliceItemContent) {\n\t\t\ttraversed.push(traversedSliceItemContent)\n\t\t}\n\t}\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, value: traversed },\n\t\tmodel: config.model,\n\t})\n}\n\ntype TraverseSharedSliceContentWithModelConfig = {\n\tmodel: SharedSliceVariationContentModel\n\ttransformWidget?: TraverseWidgetContentWithModelFunction\n\ttransformSlice?: TraverseSliceContentWithModelFunction\n}\n\nexport function traverseSharedSliceContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: SharedSliceItemContent | undefined,\n\tconfig: TraverseSharedSliceContentWithModelConfig,\n): SharedSliceItemContent | undefined {\n\tif (!content) {\n\t\treturn\n\t}\n\n\tconst { transformWidget = (args) => args.content, transformSlice = (args) => args.content } =\n\t\tconfig\n\n\tconst traversedPrimary: SharedSliceContent[\"primary\"] = {}\n\tfor (const [key, model] of Object.entries(config.model.fields.primary ?? {})) {\n\t\tconst traversedContent = traverseWidgetContentWithModel(\n\t\t\tpath.concat({ key: \"primary\", type: \"primary\" }, { key, type: \"Widget\" }),\n\t\t\tkey,\n\t\t\tkey,\n\t\t\tcontent.widget.primary[key],\n\t\t\t{ model, transformWidget },\n\t\t)\n\n\t\tif (\n\t\t\ttraversedContent &&\n\t\t\t(isNestableContent(traversedContent) || traversedContent.__TYPE__ === GroupContentType)\n\t\t) {\n\t\t\ttraversedPrimary[key] = traversedContent\n\t\t}\n\t}\n\n\tconst traversedItems = traverseGroupItemsContentWithModel(\n\t\tpath.concat({ key: \"items\", type: \"items\" }),\n\t\tcontent.widget.items,\n\t\t{ model: config.model.fields.items ?? {}, transformWidget },\n\t)\n\n\treturn transformSlice({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: {\n\t\t\t...content,\n\t\t\twidget: { ...content.widget, primary: traversedPrimary, items: traversedItems },\n\t\t},\n\t\tmodel: config.model,\n\t})\n}\n\ntype TraverseCompositeSliceContentWithModelConfig = {\n\tmodel: CompositeSliceModel\n\ttransformWidget?: TraverseWidgetContentWithModelFunction\n\ttransformSlice?: TraverseSliceContentWithModelFunction\n}\n\nexport function traverseCompositeSliceContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: CompositeSliceItemContent | undefined,\n\tconfig: TraverseCompositeSliceContentWithModelConfig,\n): CompositeSliceItemContent | undefined {\n\tif (!content) {\n\t\treturn\n\t}\n\n\tconst { transformWidget = (args) => args.content, transformSlice = (args) => args.content } =\n\t\tconfig\n\n\tconst traversedPrimary: CompositeSliceContent[\"nonRepeat\"] = {}\n\tfor (const [key, model] of Object.entries(config.model?.[\"non-repeat\"] ?? {})) {\n\t\tconst traversedContent = traverseWidgetContentWithModel(\n\t\t\tpath.concat({ key: \"non-repeat\", type: \"primary\" }, { key, type: \"Widget\" }),\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tcontent.widget.nonRepeat[key],\n\t\t\t{ model, transformWidget },\n\t\t)\n\n\t\tif (traversedContent && isNestableContent(traversedContent)) {\n\t\t\ttraversedPrimary[key] = traversedContent\n\t\t}\n\t}\n\n\tconst traversedItems = traverseGroupItemsContentWithModel(\n\t\tpath.concat({ key: \"repeat\", type: \"items\" }),\n\t\tcontent.widget.repeat,\n\t\t{ model: config.model.repeat ?? {}, transformWidget },\n\t)\n\n\treturn transformSlice({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: {\n\t\t\t...content,\n\t\t\twidget: { ...content.widget, nonRepeat: traversedPrimary, repeat: traversedItems },\n\t\t},\n\t\tmodel: config.model,\n\t})\n}\n\ntype TraverseLegacySliceContentWithModelConfig = {\n\tmodel: LegacySliceModel\n\ttransformWidget?: TraverseWidgetContentWithModelFunction\n\ttransformSlice?: TraverseSliceContentWithModelFunction\n}\n\nexport function traverseLegacySliceContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: LegacySliceItemContent | undefined,\n\tconfig: TraverseLegacySliceContentWithModelConfig,\n): LegacySliceItemContent | undefined {\n\tif (!content) {\n\t\treturn\n\t}\n\n\tconst {\n\t\tmodel,\n\t\ttransformWidget = (args) => args.content,\n\t\ttransformSlice = (args) => args.content,\n\t} = config\n\n\tconst traversedContent = traverseWidgetContentWithModel(path, key, apiID, content.widget, {\n\t\tmodel,\n\t\ttransformWidget,\n\t\ttransformSlice,\n\t})\n\n\tif (\n\t\ttraversedContent &&\n\t\t(isNestableContent(traversedContent) || traversedContent.__TYPE__ === GroupContentType)\n\t) {\n\t\treturn transformSlice({\n\t\t\tpath,\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tcontent: { ...content, widget: traversedContent },\n\t\t\tmodel,\n\t\t})\n\t}\n}\n\ntype TraverseGroupContentWithModelConfig = {\n\tmodel: GroupModel\n\ttransformWidget: TraverseWidgetContentWithModelFunction\n}\n\nexport function traverseGroupContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: GroupContent | undefined,\n\tconfig: TraverseGroupContentWithModelConfig,\n): GroupContent | undefined {\n\tconst { model, transformWidget } = config\n\n\tif (!content) {\n\t\treturn transformWidget({\n\t\t\tpath,\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tmodel,\n\t\t})\n\t}\n\n\tconst traversed = traverseGroupItemsContentWithModel(path, content.value, {\n\t\tmodel: model.config?.fields ?? {},\n\t\ttransformWidget,\n\t})\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, value: traversed },\n\t\tmodel,\n\t})\n}\n\ntype TraverseGroupItemsContentWithModelConfig = {\n\tmodel: Record<string, NestedGroupModel | NestableModel>\n\ttransformWidget: TraverseWidgetContentWithModelFunction\n}\n\nexport function traverseGroupItemsContentWithModel(\n\tpath: contentPath.Path,\n\tcontent: GroupItemContent[] | undefined,\n\tconfig: TraverseGroupItemsContentWithModelConfig,\n): GroupItemContent[] {\n\tconst { transformWidget } = config\n\n\tif (!content) {\n\t\treturn []\n\t}\n\n\tconst traversed: GroupItemContent[] = []\n\tfor (const groupItemContent of content) {\n\t\tconst groupItemPath = path.concat({ key: groupItemContent.key, type: \"GroupItem\" })\n\t\tconst groupItemContentValue = Object.fromEntries(groupItemContent.value)\n\n\t\tconst traversedValue: GroupItemContent[\"value\"] = []\n\t\tfor (const [key, model] of Object.entries(config.model)) {\n\t\t\tconst traversedContent = traverseWidgetContentWithModel(\n\t\t\t\tgroupItemPath.concat({ key, type: \"Widget\" }),\n\t\t\t\tkey,\n\t\t\t\tkey,\n\t\t\t\tgroupItemContentValue[key],\n\t\t\t\t{ model, transformWidget },\n\t\t\t)\n\n\t\t\tif (\n\t\t\t\ttraversedContent &&\n\t\t\t\t(isNestableContent(traversedContent) || traversedContent.__TYPE__ === GroupContentType)\n\t\t\t) {\n\t\t\t\ttraversedValue.push([key, traversedContent])\n\t\t\t}\n\t\t}\n\n\t\ttraversed.push({ ...groupItemContent, value: traversedValue })\n\t}\n\n\treturn traversed\n}\n\ntype TraverseRepeatableContentWithModelConfig = {\n\tmodel: LinkModel\n\ttransformWidget: TraverseWidgetContentWithModelFunction\n}\n\nexport function traverseRepeatableContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: RepeatableContent | undefined,\n\tconfig: TraverseRepeatableContentWithModelConfig,\n): RepeatableContent | undefined {\n\tconst { model, transformWidget } = config\n\n\tif (!content) {\n\t\treturn transformWidget({\n\t\t\tpath,\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tmodel,\n\t\t})\n\t}\n\n\tconst nonRepeatModel =\n\t\tmodel.type === \"Link\" && model.config\n\t\t\t? { ...model, config: { ...model.config, repeat: false } }\n\t\t\t: model\n\n\tconst traversed: RepeatableContent[\"value\"] = []\n\tfor (let index = 0; index < content.value.length; index++) {\n\t\tconst traversedContent = traverseWidgetContentWithModel(\n\t\t\tpath.concat({ key: index.toString(), type: \"Widget\" }),\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tcontent.value[index],\n\t\t\t{ model: nonRepeatModel, transformWidget },\n\t\t)\n\n\t\tif (traversedContent && isRepeatableContentValue(traversedContent)) {\n\t\t\ttraversed.push(traversedContent)\n\t\t}\n\t}\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, value: traversed },\n\t\tmodel,\n\t})\n}\n\ntype TraverseTableContentWithModelConfig = {\n\tmodel: TableModel\n\ttransformWidget: TraverseWidgetContentWithModelFunction\n}\n\nexport function traverseTableContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: TableContent | undefined,\n\tconfig: TraverseTableContentWithModelConfig,\n): TableContent | undefined {\n\tconst { model, transformWidget } = config\n\n\tif (!content) {\n\t\treturn transformWidget({\n\t\t\tpath,\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tmodel,\n\t\t})\n\t}\n\n\tconst traversed: TableContent[\"content\"] = []\n\tfor (let rowIndex = 0; rowIndex < content.content.length; rowIndex++) {\n\t\tconst traversedContent: TableContent[\"content\"][number][\"content\"] = []\n\t\tfor (let cellIndex = 0; cellIndex < content.content[rowIndex].content.length; cellIndex++) {\n\t\t\tconst cellPath = path.concat({ key: [rowIndex, cellIndex].join(\",\"), type: \"Widget\" })\n\t\t\tconst cell = content.content[rowIndex].content[cellIndex]\n\n\t\t\tconst transformed = transformWidget({\n\t\t\t\tpath: cellPath,\n\t\t\t\tkey,\n\t\t\t\tapiID,\n\t\t\t\tcontent: cell.content,\n\t\t\t\tmodel: TableCellModel,\n\t\t\t})\n\n\t\t\tif (transformed && transformed.__TYPE__ === RichTextContentType) {\n\t\t\t\ttraversedContent.push({ ...cell, content: transformed })\n\t\t\t} else {\n\t\t\t\ttraversedContent.push({\n\t\t\t\t\t...cell,\n\t\t\t\t\tcontent: {\n\t\t\t\t\t\t__TYPE__: RichTextContentType,\n\t\t\t\t\t\tvalue: [],\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\ttraversed.push({ ...content.content[rowIndex], content: traversedContent })\n\t}\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, content: traversed },\n\t\tmodel,\n\t})\n}\n\n// Internals\nexport type TraverseSliceContentWithModelFunction = <TContent extends SliceItemContent>(args: {\n\tpath: contentPath.Path\n\tkey: string\n\tapiID: string\n\tcontent?: TContent\n\tmodel: SliceContentModel\n}) => TContent | undefined\n\nexport type TraverseWidgetContentWithModelFunction<\n\tTContentTransformMode extends \"preserve\" | \"widen\" = \"preserve\",\n> = <TContent extends WidgetContent>(args: {\n\tpath: contentPath.Path\n\tkey: string\n\tapiID: string\n\tcontent?: TContent\n\tmodel: StaticWidgetModel\n}) => (TContentTransformMode extends \"preserve\" ? TContent : WidgetContent) | undefined\n\ntype TraverseWidgetContentWithModelConfig = {\n\tmodel: StaticWidgetModel\n\ttransformWidget?: TraverseWidgetContentWithModelFunction\n\ttransformSlice?: TraverseSliceContentWithModelFunction\n}\n\nfunction traverseWidgetContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: WidgetContent | undefined,\n\tconfig: TraverseWidgetContentWithModelConfig,\n): WidgetContent | undefined {\n\tconst {\n\t\tmodel,\n\t\ttransformWidget = (args) => args.content,\n\t\ttransformSlice = (args) => args.content,\n\t} = config\n\n\tif (model.type === \"Slices\" || model.type === \"Choice\") {\n\t\tconst slices = content?.__TYPE__ === SlicesContentType ? content : undefined\n\t\treturn traverseSlicesContentWithModel(path, key, apiID, slices, {\n\t\t\ttransformWidget,\n\t\t\ttransformSlice,\n\t\t\tmodel,\n\t\t})\n\t}\n\n\tif (model.type === \"Group\") {\n\t\tconst group = content?.__TYPE__ === GroupContentType ? content : undefined\n\t\treturn traverseGroupContentWithModel(path, key, apiID, group, { transformWidget, model })\n\t}\n\n\tif (model.type === \"Link\" && model.config?.repeat) {\n\t\tconst repeatable = content?.__TYPE__ === RepeatableContentType ? content : undefined\n\t\treturn traverseRepeatableContentWithModel(path, key, apiID, repeatable, {\n\t\t\ttransformWidget,\n\t\t\tmodel,\n\t\t})\n\t}\n\n\tif (model.type === \"Table\") {\n\t\tconst table = content?.__TYPE__ === TableContentType ? content : undefined\n\t\treturn traverseTableContentWithModel(path, key, apiID, table, { transformWidget, model })\n\t}\n\n\tconst nestable =\n\t\tcontent?.__TYPE__ !== SlicesContentType &&\n\t\tcontent?.__TYPE__ !== GroupContentType &&\n\t\tcontent?.__TYPE__ !== RepeatableContentType &&\n\t\tcontent?.__TYPE__ !== TableContentType\n\t\t\t? content\n\t\t\t: undefined\n\treturn transformWidget({ path, key, apiID, content: nestable, model })\n}\n"],"mappings":";;;;;;;;;;;AA0CA,SAAgB,iCACf,UACA,QACkB;CAClB,MAAM,EAAE,OAAO,iBAAiB,mBAAmB;CAGnD,MAAM,YAAY,QAAQA,QAAwB,MAAM,GAAG,EAAE;CAE7D,MAAM,YAA6B,EAAE;AACrC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,UAAU,EAAE;EAMrD,MAAM,mBAAmB,+BALZC,KACZ;GAAE,KAAK,OAAO,MAAM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,GAAG;GAAS,SAAS;GAAW;EAC3C;EACA,CAAC;;AA4BH,SAAS,+BACR,MACA,KACA,OACA,SACA,QAC4B;CAC5B,MAAM,EACL,OACA,mBAAmB,SAAS,KAAK,SACjC,kBAAkB,SAAS,KAAK,YAC7B;AAEJ,KAAI,MAAM,SAAS,YAAY,MAAM,SAAS,SAE7C,QAAO,+BAA+B,MAAM,KAAK,OADlC,SAAS,aAAA,qBAAiC,UAAU,KAAA,GACH;EAC/D;EACA;EACA;EACA,CAAC;AAGH,KAAI,MAAM,SAAS,QAElB,QAAO,8BAA8B,MAAM,KAAK,OADlC,SAAS,aAAA,qBAAgC,UAAU,KAAA,GACH;EAAE;EAAiB;EAAO,CAAC;AAG1F,KAAI,MAAM,SAAS,UAAU,MAAM,QAAQ,OAE1C,QAAO,mCAAmC,MAAM,KAAK,OADlC,SAAS,aAAA,sBAAqC,UAAU,KAAA,GACH;EACvE;EACA;EACA,CAAC;AAGH,KAAI,MAAM,SAAS,QAElB,QAAO,8BAA8B,MAAM,KAAK,OADlC,SAAS,aAAA,iBAAgC,UAAU,KAAA,GACH;EAAE;EAAiB;EAAO,CAAC;AAU1F,QAAO,gBAAgB;EAAE;EAAM;EAAK;EAAO,SAN1C,SAAS,aAAA,sBACT,SAAS,aAAA,sBACT,SAAS,aAAA,uBACT,SAAS,aAAA,iBACN,UACA,KAAA;EAC0D;EAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"traverseContentWithModel.js","names":["customTypeModel.flatten","contentPath.make"],"sources":["../../src/helpers/traverseContentWithModel.ts"],"sourcesContent":["import type { DocumentContent } from \"../content/document\"\nimport { GroupContentType } from \"../content/group\"\nimport type { GroupContent, GroupItemContent } from \"../content/group\"\nimport { isNestableContent } from \"../content/nestable\"\nimport { isRepeatableContentValue, RepeatableContentType } from \"../content/repeatable\"\nimport type { RepeatableContent } from \"../content/repeatable\"\nimport { RichTextContentType } from \"../content/richText\"\nimport { CompositeSliceContentType, SharedSliceContentType } from \"../content/slice\"\nimport type { CompositeSliceContent, SharedSliceContent } from \"../content/slice\"\nimport {\n\ttype CompositeSliceItemContent,\n\ttype SharedSliceItemContent,\n\ttype LegacySliceItemContent,\n\ttype SliceItemContent,\n\ttype SlicesContent,\n\tSlicesContentType,\n} from \"../content/slices\"\nimport { TableContentType, type TableContent } from \"../content/table\"\nimport type { WidgetContent } from \"../content/widget\"\nimport type { StaticCustomTypeModel } from \"../model/customType\"\nimport type { GroupModel, NestedGroupModel } from \"../model/group\"\nimport type { LinkModel } from \"../model/link\"\nimport type { NestableModel } from \"../model/nestable\"\nimport type {\n\tCompositeSliceModel,\n\tLegacySliceModel,\n\tSharedSliceVariationContentModel,\n\tSliceContentModel,\n} from \"../model/slice\"\nimport type { StaticSlicesModel } from \"../model/slices\"\nimport { TableCellModel } from \"../model/table\"\nimport type { TableModel } from \"../model/table\"\nimport type { StaticWidgetModel } from \"../model/widget\"\nimport * as contentPath from \"./contentPath\"\nimport * as customTypeModel from \"./customTypeModel\"\n\ntype TraverseDocumentContentWithModelConfig = {\n\tmodel: StaticCustomTypeModel\n\ttransformWidget?: TraverseWidgetContentWithModelFunction\n\ttransformSlice?: TraverseSliceContentWithModelFunction\n}\n\nexport function traverseDocumentContentWithModel(\n\tdocument: DocumentContent,\n\tconfig: TraverseDocumentContentWithModelConfig,\n): DocumentContent {\n\tconst { model, transformWidget, transformSlice } = config\n\n\t// Remove tabs from custom type model\n\tconst flatModel = model ? customTypeModel.flatten(model) : {}\n\n\tconst traversed: DocumentContent = {}\n\tfor (const [key, model] of Object.entries(flatModel)) {\n\t\tconst path = contentPath.make(\n\t\t\t{ key: config.model.id, type: \"CustomType\" },\n\t\t\t{ key, type: \"Widget\" },\n\t\t)\n\n\t\tconst traversedContent = traverseWidgetContentWithModel(path, key, key, document[key], {\n\t\t\tmodel,\n\t\t\ttransformWidget,\n\t\t\ttransformSlice,\n\t\t})\n\t\tif (traversedContent) {\n\t\t\ttraversed[key] = traversedContent\n\t\t}\n\t}\n\n\treturn traversed\n}\n\ntype TraverseSlicesContentWithModelConfig = {\n\tmodel: StaticSlicesModel\n\ttransformWidget?: TraverseWidgetContentWithModelFunction\n\ttransformSlice?: TraverseSliceContentWithModelFunction\n}\n\nexport function traverseSlicesContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: SlicesContent | undefined,\n\tconfig: TraverseSlicesContentWithModelConfig,\n): SlicesContent | undefined {\n\tconst { transformWidget = (args) => args.content, transformSlice = (args) => args.content } =\n\t\tconfig\n\n\tif (!content) {\n\t\treturn transformWidget({\n\t\t\tpath,\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tmodel: config.model,\n\t\t})\n\t}\n\n\tconst traversed: SlicesContent[\"value\"] = []\n\tfor (const sliceItemContent of content.value) {\n\t\tconst sliceModel = config.model.config?.choices?.[sliceItemContent.name]\n\n\t\tlet traversedSliceItemContent: SliceItemContent | undefined\n\t\tif (sliceModel?.type === \"SharedSlice\") {\n\t\t\tif (sliceItemContent.widget.__TYPE__ === SharedSliceContentType) {\n\t\t\t\t// Happy path, content and model are both shared slices\n\t\t\t\tconst variationID = sliceItemContent.widget.variation\n\t\t\t\tconst variationModel = sliceModel.variations.find(\n\t\t\t\t\t(variation) => variation.id === variationID,\n\t\t\t\t)\n\t\t\t\tif (variationModel) {\n\t\t\t\t\tconst model: SharedSliceVariationContentModel = {\n\t\t\t\t\t\ttype: \"SharedSlice\",\n\t\t\t\t\t\tsliceName: sliceModel.id,\n\t\t\t\t\t\tvariationID: variationModel.id,\n\t\t\t\t\t\tfields: {\n\t\t\t\t\t\t\tprimary: variationModel.primary || {},\n\t\t\t\t\t\t\titems: variationModel.items || {},\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\n\t\t\t\t\ttraversedSliceItemContent = traverseSharedSliceContentWithModel(\n\t\t\t\t\t\tpath.concat({ key: sliceItemContent.key, type: \"SharedSlice\" }),\n\t\t\t\t\t\tsliceItemContent.key,\n\t\t\t\t\t\tsliceItemContent.name,\n\t\t\t\t\t\tsliceItemContent as SharedSliceItemContent,\n\t\t\t\t\t\t{ model, transformWidget, transformSlice },\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else if (sliceItemContent.widget.__TYPE__ === CompositeSliceContentType) {\n\t\t\t\t// Migrated path, content is composite, model is shared slice\n\t\t\t\tconst variationModel = sliceModel.variations[0]\n\t\t\t\tif (variationModel) {\n\t\t\t\t\tconst model: SharedSliceVariationContentModel = {\n\t\t\t\t\t\ttype: \"SharedSlice\",\n\t\t\t\t\t\tsliceName: sliceModel.id,\n\t\t\t\t\t\tvariationID: variationModel.id,\n\t\t\t\t\t\tfields: {\n\t\t\t\t\t\t\tprimary: variationModel.primary || {},\n\t\t\t\t\t\t\titems: variationModel.items || {},\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\n\t\t\t\t\ttraversedSliceItemContent = traverseCompositeSliceContentWithModel(\n\t\t\t\t\t\tpath.concat({ key: sliceItemContent.key, type: \"Slice\" }),\n\t\t\t\t\t\tsliceItemContent.key,\n\t\t\t\t\t\tsliceItemContent.name,\n\t\t\t\t\t\tsliceItemContent as CompositeSliceItemContent,\n\t\t\t\t\t\t{ model, transformWidget, transformSlice },\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (sliceModel?.type === \"Slice\") {\n\t\t\tif (sliceItemContent.widget.__TYPE__ === CompositeSliceContentType) {\n\t\t\t\ttraversedSliceItemContent = traverseCompositeSliceContentWithModel(\n\t\t\t\t\tpath.concat({ key: sliceItemContent.key, type: \"Slice\" }),\n\t\t\t\t\tsliceItemContent.key,\n\t\t\t\t\tsliceItemContent.name,\n\t\t\t\t\tsliceItemContent as CompositeSliceItemContent,\n\t\t\t\t\t{ model: sliceModel, transformWidget, transformSlice },\n\t\t\t\t)\n\t\t\t}\n\t\t} else if (\n\t\t\tsliceModel &&\n\t\t\tsliceItemContent.widget.__TYPE__ !== SharedSliceContentType &&\n\t\t\tsliceItemContent.widget.__TYPE__ !== CompositeSliceContentType\n\t\t) {\n\t\t\ttraversedSliceItemContent = traverseLegacySliceContentWithModel(\n\t\t\t\tpath.concat({ key: sliceItemContent.key, type: \"LegacySlice\" }),\n\t\t\t\tsliceItemContent.key,\n\t\t\t\tsliceItemContent.name,\n\t\t\t\tsliceItemContent as LegacySliceItemContent,\n\t\t\t\t{ model: sliceModel, transformWidget, transformSlice },\n\t\t\t)\n\t\t}\n\n\t\tif (traversedSliceItemContent) {\n\t\t\ttraversed.push(traversedSliceItemContent)\n\t\t}\n\t}\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, value: traversed },\n\t\tmodel: config.model,\n\t})\n}\n\ntype TraverseSharedSliceContentWithModelConfig = {\n\tmodel: SharedSliceVariationContentModel\n\ttransformWidget?: TraverseWidgetContentWithModelFunction\n\ttransformSlice?: TraverseSliceContentWithModelFunction\n}\n\nexport function traverseSharedSliceContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: SharedSliceItemContent | undefined,\n\tconfig: TraverseSharedSliceContentWithModelConfig,\n): SharedSliceItemContent | undefined {\n\tif (!content) {\n\t\treturn\n\t}\n\n\tconst { transformWidget = (args) => args.content, transformSlice = (args) => args.content } =\n\t\tconfig\n\n\tconst traversedPrimary: SharedSliceContent[\"primary\"] = {}\n\tfor (const [key, model] of Object.entries(config.model.fields.primary ?? {})) {\n\t\tconst traversedContent = traverseWidgetContentWithModel(\n\t\t\tpath.concat({ key: \"primary\", type: \"primary\" }, { key, type: \"Widget\" }),\n\t\t\tkey,\n\t\t\tkey,\n\t\t\tcontent.widget.primary[key],\n\t\t\t{ model, transformWidget },\n\t\t)\n\n\t\tif (\n\t\t\ttraversedContent &&\n\t\t\t(isNestableContent(traversedContent) || traversedContent.__TYPE__ === GroupContentType)\n\t\t) {\n\t\t\ttraversedPrimary[key] = traversedContent\n\t\t}\n\t}\n\n\tconst traversedItems = traverseGroupItemsContentWithModel(\n\t\tpath.concat({ key: \"items\", type: \"items\" }),\n\t\tcontent.widget.items,\n\t\t{ model: config.model.fields.items ?? {}, transformWidget },\n\t)\n\n\treturn transformSlice({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: {\n\t\t\t...content,\n\t\t\twidget: { ...content.widget, primary: traversedPrimary, items: traversedItems },\n\t\t},\n\t\tmodel: config.model,\n\t})\n}\n\ntype TraverseCompositeSliceContentWithModelConfig = {\n\tmodel: CompositeSliceModel | SharedSliceVariationContentModel\n\ttransformWidget?: TraverseWidgetContentWithModelFunction\n\ttransformSlice?: TraverseSliceContentWithModelFunction\n}\n\nexport function traverseCompositeSliceContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: CompositeSliceItemContent | undefined,\n\tconfig: TraverseCompositeSliceContentWithModelConfig,\n): CompositeSliceItemContent | SharedSliceItemContent | undefined {\n\tif (!content) {\n\t\treturn\n\t}\n\n\tconst { transformWidget = (args) => args.content, transformSlice = (args) => args.content } =\n\t\tconfig\n\n\tconst primaryModel =\n\t\tconfig.model?.type === \"SharedSlice\"\n\t\t\t? config.model?.fields.primary\n\t\t\t: config.model?.[\"non-repeat\"]\n\tconst traversedPrimary: CompositeSliceContent[\"nonRepeat\"] = {}\n\tfor (const [key, model] of Object.entries(primaryModel ?? {})) {\n\t\tconst traversedContent = traverseWidgetContentWithModel(\n\t\t\tpath.concat({ key: \"non-repeat\", type: \"primary\" }, { key, type: \"Widget\" }),\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tcontent.widget.nonRepeat[key],\n\t\t\t{ model, transformWidget },\n\t\t)\n\n\t\tif (traversedContent && isNestableContent(traversedContent)) {\n\t\t\ttraversedPrimary[key] = traversedContent\n\t\t}\n\t}\n\n\tconst itemsModel =\n\t\tconfig.model?.type === \"SharedSlice\" ? config.model?.fields.items : config.model?.repeat\n\tconst traversedItems = traverseGroupItemsContentWithModel(\n\t\tpath.concat({ key: \"repeat\", type: \"items\" }),\n\t\tcontent.widget.repeat,\n\t\t{ model: itemsModel ?? {}, transformWidget },\n\t)\n\n\treturn transformSlice({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: {\n\t\t\t...content,\n\t\t\twidget: { ...content.widget, nonRepeat: traversedPrimary, repeat: traversedItems },\n\t\t},\n\t\tmodel: config.model,\n\t})\n}\n\ntype TraverseLegacySliceContentWithModelConfig = {\n\tmodel: LegacySliceModel\n\ttransformWidget?: TraverseWidgetContentWithModelFunction\n\ttransformSlice?: TraverseSliceContentWithModelFunction\n}\n\nexport function traverseLegacySliceContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: LegacySliceItemContent | undefined,\n\tconfig: TraverseLegacySliceContentWithModelConfig,\n): LegacySliceItemContent | SharedSliceItemContent | undefined {\n\tif (!content) {\n\t\treturn\n\t}\n\n\tconst {\n\t\tmodel,\n\t\ttransformWidget = (args) => args.content,\n\t\ttransformSlice = (args) => args.content,\n\t} = config\n\n\tconst traversedContent = traverseWidgetContentWithModel(path, key, apiID, content.widget, {\n\t\tmodel,\n\t\ttransformWidget,\n\t\ttransformSlice,\n\t})\n\n\tif (\n\t\ttraversedContent &&\n\t\t(isNestableContent(traversedContent) || traversedContent.__TYPE__ === GroupContentType)\n\t) {\n\t\treturn transformSlice({\n\t\t\tpath,\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tcontent: { ...content, widget: traversedContent },\n\t\t\tmodel,\n\t\t})\n\t}\n}\n\ntype TraverseGroupContentWithModelConfig = {\n\tmodel: GroupModel\n\ttransformWidget: TraverseWidgetContentWithModelFunction\n}\n\nexport function traverseGroupContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: GroupContent | undefined,\n\tconfig: TraverseGroupContentWithModelConfig,\n): GroupContent | undefined {\n\tconst { model, transformWidget } = config\n\n\tif (!content) {\n\t\treturn transformWidget({\n\t\t\tpath,\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tmodel,\n\t\t})\n\t}\n\n\tconst traversed = traverseGroupItemsContentWithModel(path, content.value, {\n\t\tmodel: model.config?.fields ?? {},\n\t\ttransformWidget,\n\t})\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, value: traversed },\n\t\tmodel,\n\t})\n}\n\ntype TraverseGroupItemsContentWithModelConfig = {\n\tmodel: Record<string, NestedGroupModel | NestableModel>\n\ttransformWidget: TraverseWidgetContentWithModelFunction\n}\n\nexport function traverseGroupItemsContentWithModel(\n\tpath: contentPath.Path,\n\tcontent: GroupItemContent[] | undefined,\n\tconfig: TraverseGroupItemsContentWithModelConfig,\n): GroupItemContent[] {\n\tconst { transformWidget } = config\n\n\tif (!content) {\n\t\treturn []\n\t}\n\n\tconst traversed: GroupItemContent[] = []\n\tfor (const groupItemContent of content) {\n\t\tconst groupItemPath = path.concat({ key: groupItemContent.key, type: \"GroupItem\" })\n\t\tconst groupItemContentValue = Object.fromEntries(groupItemContent.value)\n\n\t\tconst traversedValue: GroupItemContent[\"value\"] = []\n\t\tfor (const [key, model] of Object.entries(config.model)) {\n\t\t\tconst traversedContent = traverseWidgetContentWithModel(\n\t\t\t\tgroupItemPath.concat({ key, type: \"Widget\" }),\n\t\t\t\tkey,\n\t\t\t\tkey,\n\t\t\t\tgroupItemContentValue[key],\n\t\t\t\t{ model, transformWidget },\n\t\t\t)\n\n\t\t\tif (\n\t\t\t\ttraversedContent &&\n\t\t\t\t(isNestableContent(traversedContent) || traversedContent.__TYPE__ === GroupContentType)\n\t\t\t) {\n\t\t\t\ttraversedValue.push([key, traversedContent])\n\t\t\t}\n\t\t}\n\n\t\ttraversed.push({ ...groupItemContent, value: traversedValue })\n\t}\n\n\treturn traversed\n}\n\ntype TraverseRepeatableContentWithModelConfig = {\n\tmodel: LinkModel\n\ttransformWidget: TraverseWidgetContentWithModelFunction\n}\n\nexport function traverseRepeatableContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: RepeatableContent | undefined,\n\tconfig: TraverseRepeatableContentWithModelConfig,\n): RepeatableContent | undefined {\n\tconst { model, transformWidget } = config\n\n\tif (!content) {\n\t\treturn transformWidget({\n\t\t\tpath,\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tmodel,\n\t\t})\n\t}\n\n\tconst nonRepeatModel =\n\t\tmodel.type === \"Link\" && model.config\n\t\t\t? { ...model, config: { ...model.config, repeat: false } }\n\t\t\t: model\n\n\tconst traversed: RepeatableContent[\"value\"] = []\n\tfor (let index = 0; index < content.value.length; index++) {\n\t\tconst traversedContent = traverseWidgetContentWithModel(\n\t\t\tpath.concat({ key: index.toString(), type: \"Widget\" }),\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tcontent.value[index],\n\t\t\t{ model: nonRepeatModel, transformWidget },\n\t\t)\n\n\t\tif (traversedContent && isRepeatableContentValue(traversedContent)) {\n\t\t\ttraversed.push(traversedContent)\n\t\t}\n\t}\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, value: traversed },\n\t\tmodel,\n\t})\n}\n\ntype TraverseTableContentWithModelConfig = {\n\tmodel: TableModel\n\ttransformWidget: TraverseWidgetContentWithModelFunction\n}\n\nexport function traverseTableContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: TableContent | undefined,\n\tconfig: TraverseTableContentWithModelConfig,\n): TableContent | undefined {\n\tconst { model, transformWidget } = config\n\n\tif (!content) {\n\t\treturn transformWidget({\n\t\t\tpath,\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tmodel,\n\t\t})\n\t}\n\n\tconst traversed: TableContent[\"content\"] = []\n\tfor (let rowIndex = 0; rowIndex < content.content.length; rowIndex++) {\n\t\tconst traversedContent: TableContent[\"content\"][number][\"content\"] = []\n\t\tfor (let cellIndex = 0; cellIndex < content.content[rowIndex].content.length; cellIndex++) {\n\t\t\tconst cellPath = path.concat({ key: [rowIndex, cellIndex].join(\",\"), type: \"Widget\" })\n\t\t\tconst cell = content.content[rowIndex].content[cellIndex]\n\n\t\t\tconst transformed = transformWidget({\n\t\t\t\tpath: cellPath,\n\t\t\t\tkey,\n\t\t\t\tapiID,\n\t\t\t\tcontent: cell.content,\n\t\t\t\tmodel: TableCellModel,\n\t\t\t})\n\n\t\t\tif (transformed && transformed.__TYPE__ === RichTextContentType) {\n\t\t\t\ttraversedContent.push({ ...cell, content: transformed })\n\t\t\t} else {\n\t\t\t\ttraversedContent.push({\n\t\t\t\t\t...cell,\n\t\t\t\t\tcontent: {\n\t\t\t\t\t\t__TYPE__: RichTextContentType,\n\t\t\t\t\t\tvalue: [],\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\ttraversed.push({ ...content.content[rowIndex], content: traversedContent })\n\t}\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, content: traversed },\n\t\tmodel,\n\t})\n}\n\n// Internals\nexport type TraverseSliceContentWithModelFunction = <TContent extends SliceItemContent>(args: {\n\tpath: contentPath.Path\n\tkey: string\n\tapiID: string\n\tcontent?: TContent\n\tmodel: SliceContentModel\n}) => TContent | SharedSliceItemContent | undefined\n\nexport type TraverseWidgetContentWithModelFunction<\n\tTContentTransformMode extends \"preserve\" | \"widen\" = \"preserve\",\n> = <TContent extends WidgetContent>(args: {\n\tpath: contentPath.Path\n\tkey: string\n\tapiID: string\n\tcontent?: TContent\n\tmodel: StaticWidgetModel\n}) => (TContentTransformMode extends \"preserve\" ? TContent : WidgetContent) | undefined\n\ntype TraverseWidgetContentWithModelConfig = {\n\tmodel: StaticWidgetModel\n\ttransformWidget?: TraverseWidgetContentWithModelFunction\n\ttransformSlice?: TraverseSliceContentWithModelFunction\n}\n\nfunction traverseWidgetContentWithModel(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: WidgetContent | undefined,\n\tconfig: TraverseWidgetContentWithModelConfig,\n): WidgetContent | undefined {\n\tconst {\n\t\tmodel,\n\t\ttransformWidget = (args) => args.content,\n\t\ttransformSlice = (args) => args.content,\n\t} = config\n\n\tif (model.type === \"Slices\" || model.type === \"Choice\") {\n\t\tconst slices = content?.__TYPE__ === SlicesContentType ? content : undefined\n\t\treturn traverseSlicesContentWithModel(path, key, apiID, slices, {\n\t\t\ttransformWidget,\n\t\t\ttransformSlice,\n\t\t\tmodel,\n\t\t})\n\t}\n\n\tif (model.type === \"Group\") {\n\t\tconst group = content?.__TYPE__ === GroupContentType ? content : undefined\n\t\treturn traverseGroupContentWithModel(path, key, apiID, group, { transformWidget, model })\n\t}\n\n\tif (model.type === \"Link\" && model.config?.repeat) {\n\t\tconst repeatable = content?.__TYPE__ === RepeatableContentType ? content : undefined\n\t\treturn traverseRepeatableContentWithModel(path, key, apiID, repeatable, {\n\t\t\ttransformWidget,\n\t\t\tmodel,\n\t\t})\n\t}\n\n\tif (model.type === \"Table\") {\n\t\tconst table = content?.__TYPE__ === TableContentType ? content : undefined\n\t\treturn traverseTableContentWithModel(path, key, apiID, table, { transformWidget, model })\n\t}\n\n\tconst nestable =\n\t\tcontent?.__TYPE__ !== SlicesContentType &&\n\t\tcontent?.__TYPE__ !== GroupContentType &&\n\t\tcontent?.__TYPE__ !== RepeatableContentType &&\n\t\tcontent?.__TYPE__ !== TableContentType\n\t\t\t? content\n\t\t\t: undefined\n\treturn transformWidget({ path, key, apiID, content: nestable, model })\n}\n"],"mappings":";;;;;;;;;;;AA0CA,SAAgB,iCACf,UACA,QACkB;CAClB,MAAM,EAAE,OAAO,iBAAiB,mBAAmB;CAGnD,MAAM,YAAY,QAAQA,QAAwB,MAAM,GAAG,EAAE;CAE7D,MAAM,YAA6B,EAAE;AACrC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,UAAU,EAAE;EAMrD,MAAM,mBAAmB,+BALZC,KACZ;GAAE,KAAK,OAAO,MAAM;GAAI,MAAM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,gBAAgB;EAAE;EAAM;EAAK;EAAO,SAN1C,SAAS,aAAA,sBACT,SAAS,aAAA,sBACT,SAAS,aAAA,uBACT,SAAS,aAAA,iBACN,UACA,KAAA;EAC0D;EAAO,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ import { LegacyContentCtx, defaultCtx, getFieldCtx } from "./content/codec/legac
|
|
|
50
50
|
import { contentPath_d_exports } from "./helpers/contentPath.js";
|
|
51
51
|
import { customTypeModel_d_exports } from "./helpers/customTypeModel.js";
|
|
52
52
|
import { documentContent_d_exports } from "./helpers/documentContent.js";
|
|
53
|
+
import { sliceContent_d_exports } from "./helpers/sliceContent.js";
|
|
53
54
|
import { TraverseSliceContentFunction, TraverseWidgetContentFunction, traverseCompositeSliceContent, traverseDocumentContent, traverseGroupContent, traverseGroupItemsContent, traverseLegacySliceContent, traverseRepeatableContent, traverseSharedSliceContent, traverseSlicesContent, traverseTableContent } from "./helpers/traverseContent.js";
|
|
54
55
|
import { TraverseSliceContentWithModelFunction, TraverseWidgetContentWithModelFunction, traverseCompositeSliceContentWithModel, traverseDocumentContentWithModel, traverseGroupContentWithModel, traverseGroupItemsContentWithModel, traverseLegacySliceContentWithModel, traverseRepeatableContentWithModel, traverseSharedSliceContentWithModel, traverseSlicesContentWithModel, traverseTableContentWithModel } from "./helpers/traverseContentWithModel.js";
|
|
55
|
-
export { type Asset, type BooleanContent, type BooleanModel, type ColorContent, type ColorModel, type CompositeSliceContent, type CompositeSliceItemContent, type CompositeSliceModel, type CustomTypeModel, type DateContent, type DateModel, type DocumentContent, type DynamicSectionModel, type DynamicSliceModel, type DynamicSlicesModel, type DynamicWidgetModel, type Embed, type EmbedContent, type EmbedModel, type EmptyContent, type FieldContent, type FieldModelType, type GeoPointContent, type GeoPointModel, type GroupContent, type GroupItemContent, type GroupModel, type HexaColorCode, type ImageContent, type ImageModel, type IntegrationFieldContent, type IntegrationFieldModel, LegacyContentCtx, type LegacySliceContent, type LegacySliceItemContent, type LegacySliceModel, type LinkContent, type LinkModel, type NestableContent, type NestableModel, type NestedGroupModel, type NonEmptyString, type NumberContent, type NumberModel, type RangeContent, type RangeModel, type RepeatableContent, type RichTextContent, type RichTextContentBlock, type RichTextContentSpan, type RichTextModel, type SelectContent, type SelectModel, type SeparatorContent, type SeparatorModel, type SharedSliceContent, type SharedSliceItemContent, type SharedSliceModel, type SharedSliceRefModel, type SharedSliceVariationContentModel as SharedSliceVariationModel, type SliceContent, type SliceContentModel, type SliceItemContent, type SliceModelType, type SlicesContent, type StaticCustomTypeModel, type StaticSectionModel, type StaticSliceModel, type StaticSlicesModel, type StaticWidgetModel, TableCellModelNodeTypes, type TableContent, type TableModel, type TextContent, type TextModel, type TimestampContent, type TimestampModel, type TraverseSliceContentFunction, type TraverseSliceContentWithModelFunction, type TraverseWidgetContentFunction, type TraverseWidgetContentWithModelFunction, type UIDContent, type UIDModel, type WidgetContent, type WidgetKey, contentPath_d_exports as contentPath, customTypeModel_d_exports as customTypeModel, defaultCtx, documentContent_d_exports as documentContent, getFieldCtx, traverseCompositeSliceContent, traverseCompositeSliceContentWithModel, traverseDocumentContent, traverseDocumentContentWithModel, traverseGroupContent, traverseGroupContentWithModel, traverseGroupItemsContent, traverseGroupItemsContentWithModel, traverseLegacySliceContent, traverseLegacySliceContentWithModel, traverseRepeatableContent, traverseRepeatableContentWithModel, traverseSharedSliceContent, traverseSharedSliceContentWithModel, traverseSlicesContent, traverseSlicesContentWithModel, traverseTableContent, traverseTableContentWithModel };
|
|
56
|
+
export { type Asset, type BooleanContent, type BooleanModel, type ColorContent, type ColorModel, type CompositeSliceContent, type CompositeSliceItemContent, type CompositeSliceModel, type CustomTypeModel, type DateContent, type DateModel, type DocumentContent, type DynamicSectionModel, type DynamicSliceModel, type DynamicSlicesModel, type DynamicWidgetModel, type Embed, type EmbedContent, type EmbedModel, type EmptyContent, type FieldContent, type FieldModelType, type GeoPointContent, type GeoPointModel, type GroupContent, type GroupItemContent, type GroupModel, type HexaColorCode, type ImageContent, type ImageModel, type IntegrationFieldContent, type IntegrationFieldModel, LegacyContentCtx, type LegacySliceContent, type LegacySliceItemContent, type LegacySliceModel, type LinkContent, type LinkModel, type NestableContent, type NestableModel, type NestedGroupModel, type NonEmptyString, type NumberContent, type NumberModel, type RangeContent, type RangeModel, type RepeatableContent, type RichTextContent, type RichTextContentBlock, type RichTextContentSpan, type RichTextModel, type SelectContent, type SelectModel, type SeparatorContent, type SeparatorModel, type SharedSliceContent, type SharedSliceItemContent, type SharedSliceModel, type SharedSliceRefModel, type SharedSliceVariationContentModel as SharedSliceVariationModel, type SliceContent, type SliceContentModel, type SliceItemContent, type SliceModelType, type SlicesContent, type StaticCustomTypeModel, type StaticSectionModel, type StaticSliceModel, type StaticSlicesModel, type StaticWidgetModel, TableCellModelNodeTypes, type TableContent, type TableModel, type TextContent, type TextModel, type TimestampContent, type TimestampModel, type TraverseSliceContentFunction, type TraverseSliceContentWithModelFunction, type TraverseWidgetContentFunction, type TraverseWidgetContentWithModelFunction, type UIDContent, type UIDModel, type WidgetContent, type WidgetKey, contentPath_d_exports as contentPath, customTypeModel_d_exports as customTypeModel, defaultCtx, documentContent_d_exports as documentContent, getFieldCtx, sliceContent_d_exports as sliceContent, traverseCompositeSliceContent, traverseCompositeSliceContentWithModel, traverseDocumentContent, traverseDocumentContentWithModel, traverseGroupContent, traverseGroupContentWithModel, traverseGroupItemsContent, traverseGroupItemsContentWithModel, traverseLegacySliceContent, traverseLegacySliceContentWithModel, traverseRepeatableContent, traverseRepeatableContentWithModel, traverseSharedSliceContent, traverseSharedSliceContentWithModel, traverseSlicesContent, traverseSlicesContentWithModel, traverseTableContent, traverseTableContentWithModel };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,8 @@ import { TableCellModelNodeTypes } from "./model/table.js";
|
|
|
2
2
|
import { LegacyContentCtx, defaultCtx, getFieldCtx } from "./content/codec/legacyContentCtx.js";
|
|
3
3
|
import { contentPath_exports } from "./helpers/contentPath.js";
|
|
4
4
|
import { customTypeModel_exports } from "./helpers/customTypeModel.js";
|
|
5
|
+
import { sliceContent_exports } from "./helpers/sliceContent.js";
|
|
5
6
|
import { traverseCompositeSliceContent, traverseDocumentContent, traverseGroupContent, traverseGroupItemsContent, traverseLegacySliceContent, traverseRepeatableContent, traverseSharedSliceContent, traverseSlicesContent, traverseTableContent } from "./helpers/traverseContent.js";
|
|
6
7
|
import { documentContent_exports } from "./helpers/documentContent.js";
|
|
7
8
|
import { traverseCompositeSliceContentWithModel, traverseDocumentContentWithModel, traverseGroupContentWithModel, traverseGroupItemsContentWithModel, traverseLegacySliceContentWithModel, traverseRepeatableContentWithModel, traverseSharedSliceContentWithModel, traverseSlicesContentWithModel, traverseTableContentWithModel } from "./helpers/traverseContentWithModel.js";
|
|
8
|
-
export { LegacyContentCtx, TableCellModelNodeTypes, contentPath_exports as contentPath, customTypeModel_exports as customTypeModel, defaultCtx, documentContent_exports as documentContent, getFieldCtx, traverseCompositeSliceContent, traverseCompositeSliceContentWithModel, traverseDocumentContent, traverseDocumentContentWithModel, traverseGroupContent, traverseGroupContentWithModel, traverseGroupItemsContent, traverseGroupItemsContentWithModel, traverseLegacySliceContent, traverseLegacySliceContentWithModel, traverseRepeatableContent, traverseRepeatableContentWithModel, traverseSharedSliceContent, traverseSharedSliceContentWithModel, traverseSlicesContent, traverseSlicesContentWithModel, traverseTableContent, traverseTableContentWithModel };
|
|
9
|
+
export { LegacyContentCtx, TableCellModelNodeTypes, contentPath_exports as contentPath, customTypeModel_exports as customTypeModel, defaultCtx, documentContent_exports as documentContent, getFieldCtx, sliceContent_exports as sliceContent, traverseCompositeSliceContent, traverseCompositeSliceContentWithModel, traverseDocumentContent, traverseDocumentContentWithModel, traverseGroupContent, traverseGroupContentWithModel, traverseGroupItemsContent, traverseGroupItemsContentWithModel, traverseLegacySliceContent, traverseLegacySliceContentWithModel, traverseRepeatableContent, traverseRepeatableContentWithModel, traverseSharedSliceContent, traverseSharedSliceContentWithModel, traverseSlicesContent, traverseSlicesContentWithModel, traverseTableContent, traverseTableContentWithModel };
|
package/dist/io-ts.d.ts
CHANGED
|
@@ -1190,75 +1190,7 @@ declare const RepeatableLegacy: (ctx: LegacyContentCtx, fieldType: "Link") => t.
|
|
|
1190
1190
|
}, {
|
|
1191
1191
|
keys: Record<string, string>;
|
|
1192
1192
|
types: Record<string, FieldOrSliceType>;
|
|
1193
|
-
content:
|
|
1194
|
-
kind: "image";
|
|
1195
|
-
id: string;
|
|
1196
|
-
url: string;
|
|
1197
|
-
height: string;
|
|
1198
|
-
width: string;
|
|
1199
|
-
size: string;
|
|
1200
|
-
name: string;
|
|
1201
|
-
date?: string | null | undefined;
|
|
1202
|
-
variant?: string | undefined;
|
|
1203
|
-
text?: string | undefined;
|
|
1204
|
-
key: string;
|
|
1205
|
-
} | {
|
|
1206
|
-
kind: "file";
|
|
1207
|
-
id: string;
|
|
1208
|
-
url: string;
|
|
1209
|
-
name: string;
|
|
1210
|
-
size: string;
|
|
1211
|
-
date?: string | null | undefined;
|
|
1212
|
-
variant?: string | undefined;
|
|
1213
|
-
text?: string | undefined;
|
|
1214
|
-
key: string;
|
|
1215
|
-
} | {
|
|
1216
|
-
kind: "document";
|
|
1217
|
-
id: string;
|
|
1218
|
-
variant?: string | undefined;
|
|
1219
|
-
text?: string | undefined;
|
|
1220
|
-
key: string;
|
|
1221
|
-
} | {
|
|
1222
|
-
kind: "web";
|
|
1223
|
-
url: string;
|
|
1224
|
-
target?: string | null | undefined;
|
|
1225
|
-
preview?: {
|
|
1226
|
-
title?: string | undefined;
|
|
1227
|
-
} | null | undefined;
|
|
1228
|
-
variant?: string | undefined;
|
|
1229
|
-
text?: string | undefined;
|
|
1230
|
-
key: string;
|
|
1231
|
-
} | {
|
|
1232
|
-
kind: "image";
|
|
1233
|
-
variant?: string | undefined;
|
|
1234
|
-
text?: string | undefined;
|
|
1235
|
-
key: string;
|
|
1236
|
-
} | {
|
|
1237
|
-
kind: "file";
|
|
1238
|
-
variant?: string | undefined;
|
|
1239
|
-
text?: string | undefined;
|
|
1240
|
-
key: string;
|
|
1241
|
-
} | {
|
|
1242
|
-
kind: "media";
|
|
1243
|
-
variant?: string | undefined;
|
|
1244
|
-
text?: string | undefined;
|
|
1245
|
-
key: string;
|
|
1246
|
-
} | {
|
|
1247
|
-
kind: "document";
|
|
1248
|
-
variant?: string | undefined;
|
|
1249
|
-
text?: string | undefined;
|
|
1250
|
-
key: string;
|
|
1251
|
-
} | {
|
|
1252
|
-
kind: "web";
|
|
1253
|
-
variant?: string | undefined;
|
|
1254
|
-
text?: string | undefined;
|
|
1255
|
-
key: string;
|
|
1256
|
-
} | {
|
|
1257
|
-
kind: "any";
|
|
1258
|
-
variant?: string | undefined;
|
|
1259
|
-
text?: string | undefined;
|
|
1260
|
-
key: string;
|
|
1261
|
-
})[];
|
|
1193
|
+
content: unknown[];
|
|
1262
1194
|
}, unknown>;
|
|
1263
1195
|
declare const RichTextLegacy: (ctx: LegacyContentCtx) => t.Type<RichTextContent, {
|
|
1264
1196
|
keys: Record<string, string>;
|
package/dist/io-ts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"io-ts.d.ts","names":[],"sources":["../src/io-ts.ts"],"mappings":";;;;;;;;;;;;;;;cA2Ia,WAAA,EAAW,CAAA,CAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cACX,WAAA,EAAW,CAAA,CAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;cACX,mBAAA,EAAmB,CAAA,CAAA,IAAA;AAAA,cACnB,oBAAA,EAAoB,CAAA,CAAA,IAAA;AAAA,cACpB,eAAA,EAAe,CAAA,CAAA,IAAA;AAAA,cAGf,oBAAA,EAAoB,CAAA,CAAA,IAAA;;;;;;;cACpB,kBAAA,EAAkB,CAAA,CAAA,IAAA;;;;;;;;;cAClB,iBAAA,EAAiB,CAAA,CAAA,IAAA;;;;;;;;;cACjB,kBAAA,EAAkB,CAAA,CAAA,IAA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AAA,EAAqB,CAAA,CAAA,IAAA;;;sCAAmC,kBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","names":[],"sources":["../../src/model/table.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"table.d.ts","names":[],"sources":["../../src/model/table.ts"],"mappings":";;;cAQa,gBAAA,EAAgB,CAAA,CAAA,aAAA;;;;;;KAKjB,UAAA,GAAa,CAAA,CAAE,KAAA,QAAa,gBAAA;AAAA,cAG3B,uBAAA"}
|
package/dist/model/table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","names":[],"sources":["../../src/model/table.ts"],"sourcesContent":["import { z } from \"zod/mini\"\nimport { RichTextNodeType, type RichTextModel } from \"./richText\"\n\nconst TableConfigSchema = z.object({\n\tlabel: z.nullish(z.string()),\n})\n\nexport const TableModelSchema = z.object({\n\ttype: z.literal(\"Table\"),\n\tconfig: z.optional(TableConfigSchema),\n})\n\nexport type TableModel = z.infer<typeof TableModelSchema>\n\n// TableCell configuration constant (used for cell rich text configuration)\nexport const TableCellModelNodeTypes = [\n\tRichTextNodeType.paragraph,\n\tRichTextNodeType.strong,\n\tRichTextNodeType.em,\n\tRichTextNodeType.hyperlink
|
|
1
|
+
{"version":3,"file":"table.js","names":[],"sources":["../../src/model/table.ts"],"sourcesContent":["import { z } from \"zod/mini\"\n\nimport { RichTextNodeType, type RichTextModel } from \"./richText\"\n\nconst TableConfigSchema = z.object({\n\tlabel: z.nullish(z.string()),\n})\n\nexport const TableModelSchema = z.object({\n\ttype: z.literal(\"Table\"),\n\tconfig: z.optional(TableConfigSchema),\n})\n\nexport type TableModel = z.infer<typeof TableModelSchema>\n\n// TableCell configuration constant (used for cell rich text configuration)\nexport const TableCellModelNodeTypes = [\n\tRichTextNodeType.paragraph,\n\tRichTextNodeType.strong,\n\tRichTextNodeType.em,\n\tRichTextNodeType.hyperlink,\n]\n\nexport const TableCellModel: RichTextModel = {\n\ttype: \"StructuredText\" as const,\n\tconfig: {\n\t\tmulti: TableCellModelNodeTypes.join(\",\"),\n\t},\n}\n"],"mappings":";;;AAIA,MAAM,oBAAoB,EAAE,OAAO,EAClC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAC5B,CAAC;AAEF,MAAa,mBAAmB,EAAE,OAAO;CACxC,MAAM,EAAE,QAAQ,QAAQ;CACxB,QAAQ,EAAE,SAAS,kBAAkB;CACrC,CAAC;AAKF,MAAa,0BAA0B;CACtC,iBAAiB;CACjB,iBAAiB;CACjB,iBAAiB;CACjB,iBAAiB;CACjB;AAED,MAAa,iBAAgC;CAC5C,MAAM;CACN,QAAQ,EACP,OAAO,wBAAwB,KAAK,IAAI,EACxC;CACD"}
|
package/dist/model/widget.d.ts
CHANGED
|
@@ -19,16 +19,16 @@ declare const FieldModelTypeSchema: z.ZodMiniEnum<{
|
|
|
19
19
|
Boolean: "Boolean";
|
|
20
20
|
Embed: "Embed";
|
|
21
21
|
GeoPoint: "GeoPoint";
|
|
22
|
+
Image: "Image";
|
|
23
|
+
IntegrationFields: "IntegrationFields";
|
|
22
24
|
StructuredText: "StructuredText";
|
|
23
25
|
Separator: "Separator";
|
|
24
26
|
Table: "Table";
|
|
25
|
-
"Repeatable.Link": "Repeatable.Link";
|
|
26
|
-
Image: "Image";
|
|
27
|
-
IntegrationFields: "IntegrationFields";
|
|
28
|
-
UID: "UID";
|
|
29
27
|
Group: "Group";
|
|
28
|
+
UID: "UID";
|
|
30
29
|
Slices: "Slices";
|
|
31
30
|
Choice: "Choice";
|
|
31
|
+
"Repeatable.Link": "Repeatable.Link";
|
|
32
32
|
}>;
|
|
33
33
|
type FieldModelType = z.infer<typeof FieldModelTypeSchema>;
|
|
34
34
|
declare const FieldOrSliceTypeSchema: z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
|
|
@@ -43,16 +43,16 @@ declare const FieldOrSliceTypeSchema: z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
|
|
|
43
43
|
Boolean: "Boolean";
|
|
44
44
|
Embed: "Embed";
|
|
45
45
|
GeoPoint: "GeoPoint";
|
|
46
|
+
Image: "Image";
|
|
47
|
+
IntegrationFields: "IntegrationFields";
|
|
46
48
|
StructuredText: "StructuredText";
|
|
47
49
|
Separator: "Separator";
|
|
48
50
|
Table: "Table";
|
|
49
|
-
"Repeatable.Link": "Repeatable.Link";
|
|
50
|
-
Image: "Image";
|
|
51
|
-
IntegrationFields: "IntegrationFields";
|
|
52
|
-
UID: "UID";
|
|
53
51
|
Group: "Group";
|
|
52
|
+
UID: "UID";
|
|
54
53
|
Slices: "Slices";
|
|
55
54
|
Choice: "Choice";
|
|
55
|
+
"Repeatable.Link": "Repeatable.Link";
|
|
56
56
|
}>, z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"Slice">, z.ZodMiniLiteral<"SharedSlice">]>]>;
|
|
57
57
|
type FieldOrSliceType = z.infer<typeof FieldOrSliceTypeSchema>;
|
|
58
58
|
//#endregion
|
package/package.json
CHANGED
|
@@ -3,6 +3,8 @@ import { z } from "zod/mini"
|
|
|
3
3
|
import type { NestableLegacy } from "./nestable"
|
|
4
4
|
import { NestableLegacySchema } from "./nestable"
|
|
5
5
|
|
|
6
|
+
// Keep item values raw here: array-shaped legacy payloads are ambiguous until
|
|
7
|
+
// `codec/group.ts` resolves the field model and picks the right decoder.
|
|
6
8
|
export const GroupItemLegacySchema = z.record(z.string(), z.unknown())
|
|
7
9
|
|
|
8
10
|
export type GroupItemLegacy = z.infer<typeof GroupItemLegacySchema>
|
|
@@ -6,7 +6,7 @@ import type { EmbedLegacy } from "./embed"
|
|
|
6
6
|
import { EmbedLegacyLooseSchema } from "./embed"
|
|
7
7
|
import type { EmptyLegacy } from "./empty"
|
|
8
8
|
import { EmptyLegacySchema } from "./empty"
|
|
9
|
-
import type { StringLegacy} from "./field"
|
|
9
|
+
import type { StringLegacy } from "./field"
|
|
10
10
|
import { StringLegacySchema } from "./field"
|
|
11
11
|
import type { GeoPointLegacy } from "./geopoint"
|
|
12
12
|
import { GeoPointLegacySchema } from "./geopoint"
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
import { z } from "zod/mini"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
z.array(z.unknown()),
|
|
7
|
-
z.transform((value) =>
|
|
8
|
-
value.flatMap((item) => {
|
|
9
|
-
try {
|
|
10
|
-
return [LinkLegacySchema.parse(item)]
|
|
11
|
-
} catch {
|
|
12
|
-
return []
|
|
13
|
-
}
|
|
14
|
-
}),
|
|
15
|
-
),
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
export const RepeatableLegacySchema = RepeatableLinkLegacySchema
|
|
3
|
+
// Keep the legacy schema non-lossy; item-level link decoding lives in
|
|
4
|
+
// `codec/repeatable.ts`, where the field model is available.
|
|
5
|
+
export const RepeatableLegacySchema = z.array(z.unknown())
|
|
19
6
|
|
|
20
7
|
export type RepeatableLegacy = z.infer<typeof RepeatableLegacySchema>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { z } from "zod/mini"
|
|
2
2
|
|
|
3
3
|
import { GroupItemLegacySchema, NestableAndGroupLegacySchema } from "./group"
|
|
4
|
-
import { NestableLegacySchema } from "./nestable"
|
|
5
4
|
|
|
6
5
|
// Legacy (before 2020)
|
|
7
6
|
export const LegacySliceLegacySchema = NestableAndGroupLegacySchema
|
|
@@ -9,19 +8,21 @@ export const LegacySliceLegacySchema = NestableAndGroupLegacySchema
|
|
|
9
8
|
export type LegacySliceLegacy = z.infer<typeof LegacySliceLegacySchema>
|
|
10
9
|
|
|
11
10
|
// Composite (2020 to 2021)
|
|
11
|
+
// Keep non-repeat values raw here: array-shaped legacy payloads are ambiguous until
|
|
12
|
+
// `codec/slice.ts` resolves the field model and picks the right decoder.
|
|
12
13
|
export const CompositeSliceLegacySchema = z.object({
|
|
13
|
-
"non-repeat": z.optional(z.record(z.string(),
|
|
14
|
+
"non-repeat": z.optional(z.record(z.string(), z.unknown())),
|
|
14
15
|
repeat: z.optional(z.array(GroupItemLegacySchema)),
|
|
15
16
|
})
|
|
16
17
|
|
|
17
18
|
export type CompositeSliceLegacy = z.infer<typeof CompositeSliceLegacySchema>
|
|
18
19
|
|
|
19
20
|
// Shared (2021 to present)
|
|
21
|
+
// Keep primary values raw here: array-shaped legacy payloads are ambiguous until
|
|
22
|
+
// `codec/slice.ts` resolves the field model and picks the right decoder.
|
|
20
23
|
export const SharedSliceLegacySchema = z.object({
|
|
21
24
|
variation: z.string(),
|
|
22
|
-
primary: z.transform(
|
|
23
|
-
(value) => z.record(z.string(), NestableAndGroupLegacySchema).safeParse(value).data || {},
|
|
24
|
-
),
|
|
25
|
+
primary: z.transform((value) => z.record(z.string(), z.unknown()).safeParse(value).data || {}),
|
|
25
26
|
items: z.transform((value) => z.array(GroupItemLegacySchema).safeParse(value).data || []),
|
|
26
27
|
})
|
|
27
28
|
|
package/src/content/nestable.ts
CHANGED
|
@@ -100,6 +100,8 @@ const NestableContentTypes = [
|
|
|
100
100
|
TableContentType,
|
|
101
101
|
]
|
|
102
102
|
type NestableContentType = (typeof NestableContentTypes)[number]
|
|
103
|
+
|
|
104
|
+
/** @internal */
|
|
103
105
|
export function isNestableContent(content: {
|
|
104
106
|
__TYPE__: string
|
|
105
107
|
}): content is { __TYPE__: NestableContentType } {
|