@prismicio/types-internal 3.16.2-alpha.0 → 3.16.2-alpha.2
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/lib/content/Document.d.ts +11 -1
- package/lib/content/Document.js +99 -1
- package/lib/content/fields/GroupContent.d.ts +13 -2
- package/lib/content/fields/GroupContent.js +100 -1
- package/lib/content/fields/nestable/RepeatableContent.d.ts +7 -1
- package/lib/content/fields/nestable/RepeatableContent.js +43 -1
- package/lib/content/fields/nestable/TableContent.d.ts +7 -1
- package/lib/content/fields/nestable/TableContent.js +47 -1
- package/lib/content/fields/slices/SlicesContent.d.ts +24 -14
- package/lib/content/fields/slices/SlicesContent.js +278 -1
- package/lib/content/utils.d.ts +14 -0
- package/package.json +1 -15
- package/src/content/Document.ts +130 -0
- package/src/content/fields/GroupContent.ts +138 -1
- package/src/content/fields/nestable/RepeatableContent.ts +60 -0
- package/src/content/fields/nestable/TableContent.ts +60 -0
- package/src/content/fields/slices/SlicesContent.ts +391 -4
- package/src/content/utils.ts +38 -0
|
@@ -3,7 +3,7 @@ import { WidgetKey } from "../common";
|
|
|
3
3
|
import { type StaticWidget, StaticCustomType } from "../customtypes";
|
|
4
4
|
import { WidgetContent } from "./fields";
|
|
5
5
|
import { FieldOrSliceType, WithTypes } from "./LegacyContentCtx";
|
|
6
|
-
import { ContentPath, TraverseSliceContentFn, TraverseWidgetContentFn } from "./utils";
|
|
6
|
+
import { ContentPath, TraverseSliceContentFn, TraverseSliceContentWithModelFn, TraverseWidgetContentFn, TraverseWidgetContentWithModelFn } from "./utils";
|
|
7
7
|
export declare const Document: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.Type<import("./fields").GroupContent, import("./fields").GroupContent, unknown>, t.UnionC<[t.ExactC<t.TypeC<{
|
|
8
8
|
type: t.StringC;
|
|
9
9
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -11800,4 +11800,14 @@ export declare function migrateDocument(document: Document, customType: StaticCu
|
|
|
11800
11800
|
}[];
|
|
11801
11801
|
};
|
|
11802
11802
|
};
|
|
11803
|
+
export declare function traverseDocumentWithModel({ document, customType, }: {
|
|
11804
|
+
document: Document;
|
|
11805
|
+
customType: StaticCustomType | {
|
|
11806
|
+
customTypeId: string;
|
|
11807
|
+
fields: Record<string, StaticWidget>;
|
|
11808
|
+
};
|
|
11809
|
+
}): ({ transformWidget, transformSlice, }: {
|
|
11810
|
+
transformWidget: TraverseWidgetContentWithModelFn;
|
|
11811
|
+
transformSlice: TraverseSliceContentWithModelFn;
|
|
11812
|
+
}) => Document;
|
|
11803
11813
|
export {};
|
package/lib/content/Document.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.migrateDocument = exports.collectWidgets = exports.traverseDocument = exports.fillDocumentWithDefaultValues = exports.DocumentLegacy = exports.Document = void 0;
|
|
3
|
+
exports.traverseDocumentWithModel = exports.migrateDocument = exports.collectWidgets = exports.traverseDocument = exports.fillDocumentWithDefaultValues = exports.DocumentLegacy = exports.Document = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fp_ts_1 = require("fp-ts");
|
|
6
6
|
const Either_1 = require("fp-ts/lib/Either");
|
|
@@ -264,3 +264,101 @@ function migrateDocument(document, customType) {
|
|
|
264
264
|
});
|
|
265
265
|
}
|
|
266
266
|
exports.migrateDocument = migrateDocument;
|
|
267
|
+
function traverseDocumentWithModel({ document, customType, }) {
|
|
268
|
+
const model = customtypes_1.StaticCustomType.is(customType)
|
|
269
|
+
? simplifyCustomType(customType)
|
|
270
|
+
: customType;
|
|
271
|
+
return ({ transformWidget, transformSlice, }) => {
|
|
272
|
+
return Object.entries(model.fields).reduce((acc, [key, fieldModel]) => {
|
|
273
|
+
const content = document[key];
|
|
274
|
+
const path = utils_1.ContentPath.make([
|
|
275
|
+
{ key: model.customTypeId, type: "CustomType" },
|
|
276
|
+
{ key, type: "Widget" },
|
|
277
|
+
]);
|
|
278
|
+
const transformedWidget = (() => {
|
|
279
|
+
var _a;
|
|
280
|
+
switch (fieldModel.type) {
|
|
281
|
+
case "Choice":
|
|
282
|
+
case "Slices": {
|
|
283
|
+
const slicesContent = (0, fields_1.isSlicesContent)(content)
|
|
284
|
+
? content
|
|
285
|
+
: undefined;
|
|
286
|
+
return (0, fields_1.traverseSlicesWithModel)({
|
|
287
|
+
path,
|
|
288
|
+
key,
|
|
289
|
+
model: fieldModel,
|
|
290
|
+
content: slicesContent,
|
|
291
|
+
})({ transformWidget, transformSlice });
|
|
292
|
+
}
|
|
293
|
+
case "Group": {
|
|
294
|
+
const groupContent = (0, fields_1.isGroupContent)(content) ? content : undefined;
|
|
295
|
+
return (0, fields_1.traverseGroupContentWithModel)({
|
|
296
|
+
path,
|
|
297
|
+
key,
|
|
298
|
+
model: fieldModel,
|
|
299
|
+
content: groupContent,
|
|
300
|
+
})(transformWidget);
|
|
301
|
+
}
|
|
302
|
+
case "Link": {
|
|
303
|
+
if (((_a = fieldModel.config) === null || _a === void 0 ? void 0 : _a.repeat) === true) {
|
|
304
|
+
const repeatableContent = (0, fields_1.isRepeatableContent)(content)
|
|
305
|
+
? content
|
|
306
|
+
: undefined;
|
|
307
|
+
return (0, fields_1.traverseRepeatableContentWithModel)({
|
|
308
|
+
path,
|
|
309
|
+
key,
|
|
310
|
+
model: fieldModel,
|
|
311
|
+
content: repeatableContent,
|
|
312
|
+
})(transformWidget);
|
|
313
|
+
}
|
|
314
|
+
const nestableContent = (0, fields_1.isNestableContent)(content)
|
|
315
|
+
? content
|
|
316
|
+
: undefined;
|
|
317
|
+
return transformWidget({
|
|
318
|
+
path,
|
|
319
|
+
key,
|
|
320
|
+
apiId: key,
|
|
321
|
+
model: fieldModel,
|
|
322
|
+
content: nestableContent,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
case "Table": {
|
|
326
|
+
const tableContent = (0, fields_1.isTableContent)(content) ? content : undefined;
|
|
327
|
+
return (0, fields_1.traverseTableContentWithModel)({
|
|
328
|
+
path,
|
|
329
|
+
key,
|
|
330
|
+
model: fieldModel,
|
|
331
|
+
content: tableContent,
|
|
332
|
+
})(transformWidget);
|
|
333
|
+
}
|
|
334
|
+
case "UID": {
|
|
335
|
+
return transformWidget({
|
|
336
|
+
path,
|
|
337
|
+
key,
|
|
338
|
+
apiId: key,
|
|
339
|
+
model: fieldModel,
|
|
340
|
+
content,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
default: {
|
|
344
|
+
const nestableContent = (0, fields_1.isNestableContent)(content)
|
|
345
|
+
? content
|
|
346
|
+
: undefined;
|
|
347
|
+
return transformWidget({
|
|
348
|
+
path,
|
|
349
|
+
key,
|
|
350
|
+
apiId: key,
|
|
351
|
+
model: fieldModel,
|
|
352
|
+
content: nestableContent,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
})();
|
|
357
|
+
return {
|
|
358
|
+
...acc,
|
|
359
|
+
...(transformedWidget ? { [key]: transformedWidget } : {}),
|
|
360
|
+
};
|
|
361
|
+
}, {});
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
exports.traverseDocumentWithModel = traverseDocumentWithModel;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
import { type Group, type NestableWidget } from "../../customtypes";
|
|
2
|
+
import { type Group, type NestableWidget, type NestedGroup } from "../../customtypes";
|
|
3
3
|
import { LegacyContentCtx, WithTypes } from "../LegacyContentCtx";
|
|
4
|
-
import { ContentPath, TraverseWidgetContentFn } from "../utils";
|
|
4
|
+
import { ContentPath, TraverseWidgetContentFn, TraverseWidgetContentWithModelFn } from "../utils";
|
|
5
5
|
import { NestableContent } from "./nestable";
|
|
6
6
|
export declare const GroupItemContentType: "GroupItemContent";
|
|
7
7
|
export declare const GroupContentType: "GroupContentType";
|
|
@@ -39,4 +39,15 @@ export declare function traverseGroupItemsContent({ path, model, content, }: {
|
|
|
39
39
|
content: Array<GroupItemContent>;
|
|
40
40
|
model?: Record<string, Group | NestableWidget> | undefined;
|
|
41
41
|
}): (transform: TraverseWidgetContentFn) => Array<GroupItemContent>;
|
|
42
|
+
export declare function traverseGroupContentWithModel({ path, key, model, content, }: {
|
|
43
|
+
path: ContentPath;
|
|
44
|
+
key: string;
|
|
45
|
+
model: Group;
|
|
46
|
+
content: GroupContent | undefined;
|
|
47
|
+
}): (transform: TraverseWidgetContentWithModelFn) => GroupContent | undefined;
|
|
48
|
+
export declare function traverseGroupItemsContentWithModel({ path, model, content, }: {
|
|
49
|
+
path: ContentPath;
|
|
50
|
+
model: Record<string, NestableWidget | Group | NestedGroup>;
|
|
51
|
+
content: Array<GroupItemContent> | undefined;
|
|
52
|
+
}): (transform: TraverseWidgetContentWithModelFn) => Array<GroupItemContent>;
|
|
42
53
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traverseGroupItemsContent = exports.traverseGroupContent = exports.groupContentWithDefaultValues = exports.GroupLegacy = exports.arrayWithIndexCodec = exports.GroupItemLegacy = exports.GroupContentDefaultValue = exports.isGroupContent = exports.GroupContent = exports.GroupItemContent = exports.GroupContentType = exports.GroupItemContentType = void 0;
|
|
3
|
+
exports.traverseGroupItemsContentWithModel = exports.traverseGroupContentWithModel = exports.traverseGroupItemsContent = exports.traverseGroupContent = exports.groupContentWithDefaultValues = exports.GroupLegacy = exports.arrayWithIndexCodec = exports.GroupItemLegacy = exports.GroupContentDefaultValue = exports.isGroupContent = exports.GroupContent = exports.GroupItemContent = exports.GroupContentType = exports.GroupItemContentType = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fp_ts_1 = require("fp-ts");
|
|
6
6
|
const Either_1 = require("fp-ts/lib/Either");
|
|
@@ -206,3 +206,102 @@ function traverseGroupItemsContent({ path, model, content, }) {
|
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
208
|
exports.traverseGroupItemsContent = traverseGroupItemsContent;
|
|
209
|
+
function traverseGroupContentWithModel({ path, key, model, content, }) {
|
|
210
|
+
return (transform) => {
|
|
211
|
+
var _a, _b;
|
|
212
|
+
const groupItems = traverseGroupItemsContentWithModel({
|
|
213
|
+
path,
|
|
214
|
+
model: (_b = (_a = model.config) === null || _a === void 0 ? void 0 : _a.fields) !== null && _b !== void 0 ? _b : {},
|
|
215
|
+
content: content === null || content === void 0 ? void 0 : content.value,
|
|
216
|
+
})(transform);
|
|
217
|
+
return transform({
|
|
218
|
+
path,
|
|
219
|
+
key,
|
|
220
|
+
apiId: key,
|
|
221
|
+
model,
|
|
222
|
+
content: content
|
|
223
|
+
? {
|
|
224
|
+
__TYPE__: content.__TYPE__,
|
|
225
|
+
value: groupItems,
|
|
226
|
+
}
|
|
227
|
+
: undefined,
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
exports.traverseGroupContentWithModel = traverseGroupContentWithModel;
|
|
232
|
+
function traverseGroupItemsContentWithModel({ path, model, content, }) {
|
|
233
|
+
return (transform) => {
|
|
234
|
+
if (!content)
|
|
235
|
+
return [];
|
|
236
|
+
return content.map((groupItem) => {
|
|
237
|
+
const groupItemPath = path.concat([
|
|
238
|
+
{ key: groupItem.key, type: "GroupItem" },
|
|
239
|
+
]);
|
|
240
|
+
const groupItemFields = Object.entries(model).reduce((acc, [fieldKey, fieldModel]) => {
|
|
241
|
+
var _a, _b;
|
|
242
|
+
const fieldContent = (_a = groupItem.value.find(([key]) => key === fieldKey)) === null || _a === void 0 ? void 0 : _a[1];
|
|
243
|
+
const fieldPath = groupItemPath.concat([
|
|
244
|
+
{ key: fieldKey, type: "Widget" },
|
|
245
|
+
]);
|
|
246
|
+
let transformedField;
|
|
247
|
+
if (fieldModel.type === "Group") {
|
|
248
|
+
const groupContent = (0, exports.isGroupContent)(fieldContent)
|
|
249
|
+
? fieldContent
|
|
250
|
+
: undefined;
|
|
251
|
+
transformedField = traverseGroupContentWithModel({
|
|
252
|
+
path: fieldPath,
|
|
253
|
+
key: fieldKey,
|
|
254
|
+
model: fieldModel,
|
|
255
|
+
content: groupContent,
|
|
256
|
+
})(transform);
|
|
257
|
+
}
|
|
258
|
+
else if (fieldModel.type === "Link" &&
|
|
259
|
+
((_b = fieldModel.config) === null || _b === void 0 ? void 0 : _b.repeat) === true) {
|
|
260
|
+
const repeatableContent = (0, nestable_1.isRepeatableContent)(fieldContent)
|
|
261
|
+
? fieldContent
|
|
262
|
+
: undefined;
|
|
263
|
+
transformedField = (0, nestable_1.traverseRepeatableContentWithModel)({
|
|
264
|
+
path: fieldPath,
|
|
265
|
+
key: fieldKey,
|
|
266
|
+
model: fieldModel,
|
|
267
|
+
content: repeatableContent,
|
|
268
|
+
})(transform);
|
|
269
|
+
}
|
|
270
|
+
else if (fieldModel.type === "Table") {
|
|
271
|
+
const tableContent = (0, nestable_1.isTableContent)(fieldContent)
|
|
272
|
+
? fieldContent
|
|
273
|
+
: undefined;
|
|
274
|
+
transformedField = (0, nestable_1.traverseTableContentWithModel)({
|
|
275
|
+
path: fieldPath,
|
|
276
|
+
key: fieldKey,
|
|
277
|
+
model: fieldModel,
|
|
278
|
+
content: tableContent,
|
|
279
|
+
})(transform);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
const nestableContent = (0, nestable_1.isNestableContent)(fieldContent)
|
|
283
|
+
? fieldContent
|
|
284
|
+
: undefined;
|
|
285
|
+
transformedField = transform({
|
|
286
|
+
path: fieldPath,
|
|
287
|
+
key: fieldKey,
|
|
288
|
+
apiId: fieldKey,
|
|
289
|
+
model: fieldModel,
|
|
290
|
+
content: nestableContent,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
if (!transformedField ||
|
|
294
|
+
!((0, nestable_1.isNestableContent)(transformedField) ||
|
|
295
|
+
(0, exports.isGroupContent)(transformedField)))
|
|
296
|
+
return acc;
|
|
297
|
+
return acc.concat([[fieldKey, transformedField]]);
|
|
298
|
+
}, []);
|
|
299
|
+
return {
|
|
300
|
+
__TYPE__: groupItem.__TYPE__,
|
|
301
|
+
key: groupItem.key,
|
|
302
|
+
value: groupItemFields,
|
|
303
|
+
};
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
exports.traverseGroupItemsContentWithModel = traverseGroupItemsContentWithModel;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
2
|
import type { Link, NestableWidget } from "../../../customtypes";
|
|
3
3
|
import type { LegacyContentCtx, WithTypes } from "../../LegacyContentCtx";
|
|
4
|
-
import { ContentPath, TraverseWidgetContentFn } from "../../utils";
|
|
4
|
+
import { ContentPath, TraverseWidgetContentFn, TraverseWidgetContentWithModelFn } from "../../utils";
|
|
5
5
|
export declare const RepeatableContent: t.ExactC<t.TypeC<{
|
|
6
6
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
7
7
|
type: t.LiteralC<"Link">;
|
|
@@ -174,3 +174,9 @@ export declare function traverseRepeatableContent({ path, key, apiId, model, con
|
|
|
174
174
|
content: RepeatableContent;
|
|
175
175
|
model?: NestableWidget | undefined;
|
|
176
176
|
}): (transform: TraverseWidgetContentFn) => RepeatableContent | undefined;
|
|
177
|
+
export declare function traverseRepeatableContentWithModel({ path, key, model, content, }: {
|
|
178
|
+
path: ContentPath;
|
|
179
|
+
key: string;
|
|
180
|
+
model: NestableWidget;
|
|
181
|
+
content: RepeatableContent | undefined;
|
|
182
|
+
}): (transform: TraverseWidgetContentWithModelFn) => RepeatableContent | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traverseRepeatableContent = exports.RepeatableLegacy = exports.isRepeatableContent = exports.RepeatableContent = void 0;
|
|
3
|
+
exports.traverseRepeatableContentWithModel = exports.traverseRepeatableContent = exports.RepeatableLegacy = exports.isRepeatableContent = exports.RepeatableContent = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fp_ts_1 = require("fp-ts");
|
|
6
6
|
const Either_1 = require("fp-ts/lib/Either");
|
|
@@ -102,3 +102,45 @@ function traverseRepeatableContent({ path, key, apiId, model, content, }) {
|
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
exports.traverseRepeatableContent = traverseRepeatableContent;
|
|
105
|
+
function traverseRepeatableContentWithModel({ path, key, model, content, }) {
|
|
106
|
+
return (transform) => {
|
|
107
|
+
var _a;
|
|
108
|
+
const items = (_a = content === null || content === void 0 ? void 0 : content.value.reduce((acc, fieldContent, index) => {
|
|
109
|
+
const itemPath = path.concat([
|
|
110
|
+
{ key: index.toString(), type: "Widget" },
|
|
111
|
+
]);
|
|
112
|
+
const newModel = (model === null || model === void 0 ? void 0 : model.type) === "Link" && model.config
|
|
113
|
+
? {
|
|
114
|
+
...model,
|
|
115
|
+
config: { ...model.config, repeat: false },
|
|
116
|
+
}
|
|
117
|
+
: model;
|
|
118
|
+
const transformedField = transform({
|
|
119
|
+
path: itemPath,
|
|
120
|
+
key: key,
|
|
121
|
+
apiId: key,
|
|
122
|
+
model: newModel,
|
|
123
|
+
content: fieldContent,
|
|
124
|
+
});
|
|
125
|
+
if (!transformedField)
|
|
126
|
+
return acc;
|
|
127
|
+
if (!(0, LinkContent_1.isLinkContent)(transformedField))
|
|
128
|
+
return acc;
|
|
129
|
+
return acc.concat(transformedField);
|
|
130
|
+
}, [])) !== null && _a !== void 0 ? _a : [];
|
|
131
|
+
return transform({
|
|
132
|
+
path,
|
|
133
|
+
key,
|
|
134
|
+
apiId: key,
|
|
135
|
+
model,
|
|
136
|
+
content: content
|
|
137
|
+
? {
|
|
138
|
+
__TYPE__: content.__TYPE__,
|
|
139
|
+
type: content.type,
|
|
140
|
+
value: items,
|
|
141
|
+
}
|
|
142
|
+
: undefined,
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
exports.traverseRepeatableContentWithModel = traverseRepeatableContentWithModel;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
2
|
import { type NestableWidget } from "../../../customtypes";
|
|
3
3
|
import type { LegacyContentCtx, WithTypes } from "../../LegacyContentCtx";
|
|
4
|
-
import { ContentPath, TraverseWidgetContentFn } from "../../utils";
|
|
4
|
+
import { ContentPath, TraverseWidgetContentFn, TraverseWidgetContentWithModelFn } from "../../utils";
|
|
5
5
|
export declare const TableContentType = "TableContent";
|
|
6
6
|
export declare const isTableContent: (u: unknown) => u is {
|
|
7
7
|
__TYPE__: "TableContent";
|
|
@@ -768,3 +768,9 @@ export declare function traverseTableContent({ path, key, apiId, model, content,
|
|
|
768
768
|
content: TableContent;
|
|
769
769
|
model?: NestableWidget | undefined;
|
|
770
770
|
}): (transform: TraverseWidgetContentFn) => TableContent | undefined;
|
|
771
|
+
export declare function traverseTableContentWithModel({ path, key, model, content, }: {
|
|
772
|
+
path: ContentPath;
|
|
773
|
+
key: string;
|
|
774
|
+
model: NestableWidget;
|
|
775
|
+
content: TableContent | undefined;
|
|
776
|
+
}): (transform: TraverseWidgetContentWithModelFn) => TableContent | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traverseTableContent = exports.TableLegacy = exports.TableContent = exports.isTableContent = exports.TableContentType = void 0;
|
|
3
|
+
exports.traverseTableContentWithModel = exports.traverseTableContent = exports.TableLegacy = exports.TableContent = exports.isTableContent = exports.TableContentType = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fp_ts_1 = require("fp-ts");
|
|
6
6
|
const function_1 = require("fp-ts/lib/function");
|
|
@@ -119,3 +119,49 @@ function traverseTableContent({ path, key, apiId, model, content, }) {
|
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
exports.traverseTableContent = traverseTableContent;
|
|
122
|
+
function traverseTableContentWithModel({ path, key, model, content, }) {
|
|
123
|
+
return (transform) => {
|
|
124
|
+
var _a;
|
|
125
|
+
const tableContent = (_a = content === null || content === void 0 ? void 0 : content.content.map((row, rowIndex) => ({
|
|
126
|
+
...row,
|
|
127
|
+
content: row.content.map((cell, cellIndex) => {
|
|
128
|
+
const itemPath = path.concat([
|
|
129
|
+
{
|
|
130
|
+
key: [rowIndex.toString(), cellIndex.toString()].join(","),
|
|
131
|
+
type: "Widget",
|
|
132
|
+
},
|
|
133
|
+
]);
|
|
134
|
+
const cellContent = transform({
|
|
135
|
+
path: itemPath,
|
|
136
|
+
key,
|
|
137
|
+
apiId: key,
|
|
138
|
+
model: customtypes_1.TableCell,
|
|
139
|
+
content: {
|
|
140
|
+
__TYPE__: cell.content.__TYPE__,
|
|
141
|
+
value: cell.content.value,
|
|
142
|
+
},
|
|
143
|
+
}) || {
|
|
144
|
+
__TYPE__: "StructuredTextContent",
|
|
145
|
+
value: [],
|
|
146
|
+
};
|
|
147
|
+
return {
|
|
148
|
+
...cell,
|
|
149
|
+
content: cellContent,
|
|
150
|
+
};
|
|
151
|
+
}),
|
|
152
|
+
}))) !== null && _a !== void 0 ? _a : [];
|
|
153
|
+
return transform({
|
|
154
|
+
path,
|
|
155
|
+
key,
|
|
156
|
+
apiId: key,
|
|
157
|
+
model,
|
|
158
|
+
content: content
|
|
159
|
+
? {
|
|
160
|
+
__TYPE__: content.__TYPE__,
|
|
161
|
+
content: tableContent,
|
|
162
|
+
}
|
|
163
|
+
: undefined,
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
exports.traverseTableContentWithModel = traverseTableContentWithModel;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
import { type StaticSlices } from "../../../customtypes";
|
|
2
|
+
import { type StaticSlices, CompositeSlice, Group, NestableWidget, VariationFields } from "../../../customtypes";
|
|
3
3
|
import type { LegacyContentCtx, WithTypes } from "../../LegacyContentCtx";
|
|
4
|
-
import { ContentPath, TraverseSliceContentFn, TraverseWidgetContentFn } from "../../utils";
|
|
4
|
+
import { ContentPath, TraverseSliceContentFn, TraverseSliceContentWithModelFn, TraverseWidgetContentFn, TraverseWidgetContentWithModelFn } from "../../utils";
|
|
5
5
|
export declare const SlicesContentType = "SliceContentType";
|
|
6
6
|
export declare const isSlicesContent: (u: unknown) => u is {
|
|
7
7
|
__TYPE__: "SliceContentType";
|
|
@@ -598,7 +598,7 @@ export declare const isSlicesContent: (u: unknown) => u is {
|
|
|
598
598
|
variant?: string;
|
|
599
599
|
});
|
|
600
600
|
})[];
|
|
601
|
-
} | import("
|
|
601
|
+
} | import("../GroupContent").GroupContent | {
|
|
602
602
|
__TYPE__: "CompositeSliceContent";
|
|
603
603
|
nonRepeat: {
|
|
604
604
|
[x: string]: {
|
|
@@ -1784,7 +1784,7 @@ export declare const isSlicesContent: (u: unknown) => u is {
|
|
|
1784
1784
|
variant?: string;
|
|
1785
1785
|
});
|
|
1786
1786
|
})[];
|
|
1787
|
-
} | import("
|
|
1787
|
+
} | import("../GroupContent").GroupContent][];
|
|
1788
1788
|
}[];
|
|
1789
1789
|
} | {
|
|
1790
1790
|
__TYPE__: "SharedSliceContent";
|
|
@@ -2379,7 +2379,7 @@ export declare const isSlicesContent: (u: unknown) => u is {
|
|
|
2379
2379
|
variant?: string;
|
|
2380
2380
|
});
|
|
2381
2381
|
})[];
|
|
2382
|
-
} | import("
|
|
2382
|
+
} | import("../GroupContent").GroupContent;
|
|
2383
2383
|
};
|
|
2384
2384
|
items: {
|
|
2385
2385
|
__TYPE__: "GroupItemContent";
|
|
@@ -2973,12 +2973,13 @@ export declare const isSlicesContent: (u: unknown) => u is {
|
|
|
2973
2973
|
variant?: string;
|
|
2974
2974
|
});
|
|
2975
2975
|
})[];
|
|
2976
|
-
} | import("
|
|
2976
|
+
} | import("../GroupContent").GroupContent][];
|
|
2977
2977
|
}[];
|
|
2978
2978
|
};
|
|
2979
2979
|
}[];
|
|
2980
2980
|
};
|
|
2981
2981
|
declare type SlicesLegacy = Array<unknown>;
|
|
2982
|
+
export declare type SliceModel = VariationFields | NestableWidget | CompositeSlice | Group;
|
|
2982
2983
|
export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
2983
2984
|
__TYPE__: "SliceContentType";
|
|
2984
2985
|
value: {
|
|
@@ -3574,7 +3575,7 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
3574
3575
|
variant?: string;
|
|
3575
3576
|
});
|
|
3576
3577
|
})[];
|
|
3577
|
-
} | import("
|
|
3578
|
+
} | import("../GroupContent").GroupContent | {
|
|
3578
3579
|
__TYPE__: "CompositeSliceContent";
|
|
3579
3580
|
nonRepeat: {
|
|
3580
3581
|
[x: string]: {
|
|
@@ -4760,7 +4761,7 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
4760
4761
|
variant?: string;
|
|
4761
4762
|
});
|
|
4762
4763
|
})[];
|
|
4763
|
-
} | import("
|
|
4764
|
+
} | import("../GroupContent").GroupContent][];
|
|
4764
4765
|
}[];
|
|
4765
4766
|
} | {
|
|
4766
4767
|
__TYPE__: "SharedSliceContent";
|
|
@@ -5355,7 +5356,7 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
5355
5356
|
variant?: string;
|
|
5356
5357
|
});
|
|
5357
5358
|
})[];
|
|
5358
|
-
} | import("
|
|
5359
|
+
} | import("../GroupContent").GroupContent;
|
|
5359
5360
|
};
|
|
5360
5361
|
items: {
|
|
5361
5362
|
__TYPE__: "GroupItemContent";
|
|
@@ -5949,7 +5950,7 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
5949
5950
|
variant?: string;
|
|
5950
5951
|
});
|
|
5951
5952
|
})[];
|
|
5952
|
-
} | import("
|
|
5953
|
+
} | import("../GroupContent").GroupContent][];
|
|
5953
5954
|
}[];
|
|
5954
5955
|
};
|
|
5955
5956
|
}[];
|
|
@@ -7492,7 +7493,7 @@ export declare const SlicesContent: t.TypeC<{
|
|
|
7492
7493
|
variant: t.StringC;
|
|
7493
7494
|
}>]>>]>]>;
|
|
7494
7495
|
}>>]>>;
|
|
7495
|
-
}>>]>, t.Type<import("
|
|
7496
|
+
}>>]>, t.Type<import("../GroupContent").GroupContent, import("../GroupContent").GroupContent, unknown>]>]>>;
|
|
7496
7497
|
}>>>;
|
|
7497
7498
|
}>>, t.ExactC<t.TypeC<{
|
|
7498
7499
|
__TYPE__: t.LiteralC<"SharedSliceContent">;
|
|
@@ -8260,7 +8261,7 @@ export declare const SlicesContent: t.TypeC<{
|
|
|
8260
8261
|
variant: t.StringC;
|
|
8261
8262
|
}>]>>]>]>;
|
|
8262
8263
|
}>>]>>;
|
|
8263
|
-
}>>]>, t.Type<import("
|
|
8264
|
+
}>>]>, t.Type<import("../GroupContent").GroupContent, import("../GroupContent").GroupContent, unknown>]>>;
|
|
8264
8265
|
items: t.ArrayC<t.ExactC<t.TypeC<{
|
|
8265
8266
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
8266
8267
|
key: t.StringC;
|
|
@@ -9027,7 +9028,7 @@ export declare const SlicesContent: t.TypeC<{
|
|
|
9027
9028
|
variant: t.StringC;
|
|
9028
9029
|
}>]>>]>]>;
|
|
9029
9030
|
}>>]>>;
|
|
9030
|
-
}>>]>, t.Type<import("
|
|
9031
|
+
}>>]>, t.Type<import("../GroupContent").GroupContent, import("../GroupContent").GroupContent, unknown>]>]>>;
|
|
9031
9032
|
}>>>;
|
|
9032
9033
|
}>>, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
9033
9034
|
type: t.StringC;
|
|
@@ -9792,7 +9793,7 @@ export declare const SlicesContent: t.TypeC<{
|
|
|
9792
9793
|
variant: t.StringC;
|
|
9793
9794
|
}>]>>]>]>;
|
|
9794
9795
|
}>>]>>;
|
|
9795
|
-
}>>]>, t.Type<import("
|
|
9796
|
+
}>>]>, t.Type<import("../GroupContent").GroupContent, import("../GroupContent").GroupContent, unknown>]>]>;
|
|
9796
9797
|
}>>;
|
|
9797
9798
|
}>;
|
|
9798
9799
|
export declare type SlicesContent = t.TypeOf<typeof SlicesContent>;
|
|
@@ -9806,4 +9807,13 @@ export declare function traverseSlices({ path, key, model, content, }: {
|
|
|
9806
9807
|
transformWidget?: TraverseWidgetContentFn;
|
|
9807
9808
|
transformSlice?: TraverseSliceContentFn;
|
|
9808
9809
|
}) => SlicesContent | undefined;
|
|
9810
|
+
export declare function traverseSlicesWithModel({ path, key, model, content, }: {
|
|
9811
|
+
path: ContentPath;
|
|
9812
|
+
key: string;
|
|
9813
|
+
model: StaticSlices;
|
|
9814
|
+
content: SlicesContent | undefined;
|
|
9815
|
+
}): (args: {
|
|
9816
|
+
transformWidget: TraverseWidgetContentWithModelFn;
|
|
9817
|
+
transformSlice: TraverseSliceContentWithModelFn;
|
|
9818
|
+
}) => SlicesContent | undefined;
|
|
9809
9819
|
export {};
|