@prismicio/types-internal 4.0.0-canary.72def6d → 4.0.0-pr.6.09bccf8
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/_virtual/_rolldown/runtime.js +13 -0
- package/dist/content/codec/boolean.js +2 -2
- package/dist/content/codec/boolean.js.map +1 -1
- package/dist/content/codec/document.js +5 -5
- package/dist/content/codec/document.js.map +1 -1
- package/dist/content/codec/embed.js +2 -2
- package/dist/content/codec/embed.js.map +1 -1
- package/dist/content/codec/empty.js +2 -2
- package/dist/content/codec/empty.js.map +1 -1
- package/dist/content/codec/field.js +2 -2
- package/dist/content/codec/field.js.map +1 -1
- package/dist/content/codec/geopoint.js +2 -2
- package/dist/content/codec/geopoint.js.map +1 -1
- package/dist/content/codec/group.js +12 -12
- package/dist/content/codec/group.js.map +1 -1
- package/dist/content/codec/image.js +2 -2
- package/dist/content/codec/image.js.map +1 -1
- package/dist/content/codec/integrationField.js +2 -2
- package/dist/content/codec/integrationField.js.map +1 -1
- package/dist/content/codec/legacyContentCtx.d.ts +1 -23
- package/dist/content/codec/legacyContentCtx.d.ts.map +1 -1
- package/dist/content/codec/legacyContentCtx.js +0 -8
- package/dist/content/codec/legacyContentCtx.js.map +1 -1
- package/dist/content/codec/link.js +10 -10
- package/dist/content/codec/link.js.map +1 -1
- package/dist/content/codec/nestable.js +37 -37
- package/dist/content/codec/nestable.js.map +1 -1
- package/dist/content/codec/repeatable.js +3 -3
- package/dist/content/codec/repeatable.js.map +1 -1
- package/dist/content/codec/richText.js +2 -2
- package/dist/content/codec/richText.js.map +1 -1
- package/dist/content/codec/separator.js +2 -2
- package/dist/content/codec/separator.js.map +1 -1
- package/dist/content/codec/slice.js +29 -29
- package/dist/content/codec/slice.js.map +1 -1
- package/dist/content/codec/slices.js +8 -8
- package/dist/content/codec/slices.js.map +1 -1
- package/dist/content/codec/table.js +2 -2
- package/dist/content/codec/table.js.map +1 -1
- package/dist/content/codec/uid.js +2 -2
- package/dist/content/codec/uid.js.map +1 -1
- package/dist/content/codec/widget.js +10 -10
- package/dist/content/codec/widget.js.map +1 -1
- package/dist/content/legacy/document.d.ts +8 -0
- package/dist/content/legacy/document.d.ts.map +1 -0
- package/dist/content/legacy/slice.js +2 -2
- package/dist/content/legacy/slice.js.map +1 -1
- package/dist/content/nestable.d.ts.map +1 -1
- package/dist/content/nestable.js +30 -13
- package/dist/content/nestable.js.map +1 -1
- package/dist/content/repeatable.js +6 -2
- package/dist/content/repeatable.js.map +1 -1
- package/dist/content/slice.d.ts +3 -3
- package/dist/content/slice.js +3 -3
- package/dist/content/slice.js.map +1 -1
- package/dist/content/slices.d.ts +2278 -1
- package/dist/content/slices.d.ts.map +1 -1
- package/dist/content/slices.js +13 -7
- package/dist/content/slices.js.map +1 -1
- package/dist/helpers/contentPath.d.ts +15 -0
- package/dist/helpers/contentPath.d.ts.map +1 -0
- package/dist/helpers/contentPath.js +30 -0
- package/dist/helpers/contentPath.js.map +1 -0
- package/dist/helpers/customTypeModel.d.ts +14 -0
- package/dist/helpers/customTypeModel.d.ts.map +1 -0
- package/dist/helpers/customTypeModel.js +55 -0
- package/dist/helpers/customTypeModel.js.map +1 -0
- package/dist/helpers/documentContent.d.ts +25 -0
- package/dist/helpers/documentContent.d.ts.map +1 -0
- package/dist/helpers/documentContent.js +51 -0
- package/dist/helpers/documentContent.js.map +1 -0
- package/dist/helpers/traverseContent.d.ts +85 -0
- package/dist/helpers/traverseContent.d.ts.map +1 -0
- package/dist/helpers/traverseContent.js +342 -0
- package/dist/helpers/traverseContent.js.map +1 -0
- package/dist/helpers/traverseContentWithModel.d.ts +85 -0
- package/dist/helpers/traverseContentWithModel.d.ts.map +1 -0
- package/dist/helpers/traverseContentWithModel.js +362 -0
- package/dist/helpers/traverseContentWithModel.js.map +1 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.js +6 -1
- package/dist/io-ts.d.ts +34 -34
- package/dist/io-ts.d.ts.map +1 -1
- package/dist/io-ts.js +35 -36
- package/dist/io-ts.js.map +1 -1
- package/dist/model/nestable.js +1 -1
- package/dist/model/slice.d.ts +737 -3
- package/dist/model/slice.d.ts.map +1 -1
- package/dist/model/slice.js +13 -4
- package/dist/model/slice.js.map +1 -1
- package/dist/model/table.js +10 -7
- package/dist/model/table.js.map +1 -1
- package/dist/model/widget.d.ts +28 -3
- package/dist/model/widget.d.ts.map +1 -1
- package/dist/model/widget.js +5 -2
- package/dist/model/widget.js.map +1 -1
- package/dist/zod4.d.ts +2 -24
- package/dist/zod4.d.ts.map +1 -1
- package/dist/zod4.js +24 -25
- package/dist/zod4.js.map +1 -1
- package/package.json +1 -1
- package/src/content/codec/boolean.ts +2 -2
- package/src/content/codec/document.ts +5 -5
- package/src/content/codec/embed.ts +2 -2
- package/src/content/codec/empty.ts +3 -3
- package/src/content/codec/field.ts +2 -2
- package/src/content/codec/geopoint.ts +2 -2
- package/src/content/codec/group.ts +16 -16
- package/src/content/codec/image.ts +2 -2
- package/src/content/codec/integrationField.ts +2 -2
- package/src/content/codec/legacyContentCtx.ts +4 -15
- package/src/content/codec/link.ts +10 -10
- package/src/content/codec/nestable.ts +37 -37
- package/src/content/codec/repeatable.ts +4 -4
- package/src/content/codec/richText.ts +2 -2
- package/src/content/codec/separator.ts +2 -2
- package/src/content/codec/slice.ts +34 -34
- package/src/content/codec/slices.ts +9 -9
- package/src/content/codec/table.ts +2 -2
- package/src/content/codec/uid.ts +2 -2
- package/src/content/codec/widget.ts +10 -10
- package/src/content/legacy/slice.ts +4 -4
- package/src/content/nestable.ts +33 -11
- package/src/content/repeatable.ts +9 -1
- package/src/content/slice.ts +4 -4
- package/src/content/slices.ts +39 -7
- package/src/helpers/contentPath.ts +35 -0
- package/src/helpers/customTypeModel.ts +66 -0
- package/src/helpers/documentContent.ts +82 -0
- package/src/helpers/traverseContent.ts +527 -0
- package/src/helpers/traverseContentWithModel.ts +581 -0
- package/src/index.ts +39 -3
- package/src/io-ts.ts +9 -10
- package/src/model/diff/sharedSlice.ts +2 -2
- package/src/model/diff/variation.ts +9 -6
- package/src/model/slice.ts +17 -5
- package/src/model/table.ts +1 -1
- package/src/model/widget.ts +13 -3
- package/src/zod4.ts +3 -4
- package/src/content/utils.ts +0 -77
|
@@ -31,55 +31,55 @@ const NestableLegacyCodec = (ctx) => ({
|
|
|
31
31
|
is(input) {
|
|
32
32
|
return NestableContentSchema.safeParse(input).success;
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
toContent(input) {
|
|
35
35
|
if (!ctx.fieldType) return UnsupportedNestableLegacySchema.safeParse(input);
|
|
36
|
-
const empty = EmptyLegacyCodec(ctx).
|
|
36
|
+
const empty = EmptyLegacyCodec(ctx).toContent(input);
|
|
37
37
|
if (empty.success) return {
|
|
38
38
|
success: true,
|
|
39
39
|
data: empty.data
|
|
40
40
|
};
|
|
41
41
|
switch (ctx.fieldType) {
|
|
42
|
-
case "Text": return TextLegacyCodec(ctx).
|
|
43
|
-
case "Color": return ColorLegacyCodec(ctx).
|
|
44
|
-
case "Date": return DateLegacyCodec(ctx).
|
|
45
|
-
case "Timestamp": return TimestampLegacyCodec(ctx).
|
|
46
|
-
case "Number": return NumberLegacyCodec(ctx).
|
|
47
|
-
case "Range": return RangeLegacyCodec(ctx).
|
|
48
|
-
case "Select": return SelectLegacyCodec(ctx).
|
|
49
|
-
case "GeoPoint": return GeoPointLegacyCodec(ctx).
|
|
50
|
-
case "StructuredText": return RichTextLegacyCodec(ctx).
|
|
51
|
-
case "Boolean": return BooleanLegacyCodec(ctx).
|
|
52
|
-
case "Embed": return EmbedLegacyCodec(ctx).
|
|
53
|
-
case "Image": return ImageLegacyCodec(ctx).
|
|
54
|
-
case "IntegrationFields": return IntegrationFieldLegacyCodec(ctx).
|
|
55
|
-
case "Link": return LinkLegacyCodec(ctx).
|
|
56
|
-
case "Separator": return SeparatorLegacyCodec(ctx).
|
|
57
|
-
case "Table": return TableLegacyCodec(ctx).
|
|
58
|
-
case "Repeatable.Link": return RepeatableLegacyCodec(ctx, "Link").
|
|
42
|
+
case "Text": return TextLegacyCodec(ctx).toContent(input);
|
|
43
|
+
case "Color": return ColorLegacyCodec(ctx).toContent(input);
|
|
44
|
+
case "Date": return DateLegacyCodec(ctx).toContent(input);
|
|
45
|
+
case "Timestamp": return TimestampLegacyCodec(ctx).toContent(input);
|
|
46
|
+
case "Number": return NumberLegacyCodec(ctx).toContent(input);
|
|
47
|
+
case "Range": return RangeLegacyCodec(ctx).toContent(input);
|
|
48
|
+
case "Select": return SelectLegacyCodec(ctx).toContent(input);
|
|
49
|
+
case "GeoPoint": return GeoPointLegacyCodec(ctx).toContent(input);
|
|
50
|
+
case "StructuredText": return RichTextLegacyCodec(ctx).toContent(input);
|
|
51
|
+
case "Boolean": return BooleanLegacyCodec(ctx).toContent(input);
|
|
52
|
+
case "Embed": return EmbedLegacyCodec(ctx).toContent(input);
|
|
53
|
+
case "Image": return ImageLegacyCodec(ctx).toContent(input);
|
|
54
|
+
case "IntegrationFields": return IntegrationFieldLegacyCodec(ctx).toContent(input);
|
|
55
|
+
case "Link": return LinkLegacyCodec(ctx).toContent(input);
|
|
56
|
+
case "Separator": return SeparatorLegacyCodec(ctx).toContent(input);
|
|
57
|
+
case "Table": return TableLegacyCodec(ctx).toContent(input);
|
|
58
|
+
case "Repeatable.Link": return RepeatableLegacyCodec(ctx, "Link").toContent(input);
|
|
59
59
|
default: return UnsupportedNestableLegacySchema.safeParse(input);
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
-
|
|
62
|
+
fromContent(input) {
|
|
63
63
|
switch (input.__TYPE__) {
|
|
64
64
|
case FieldContentType:
|
|
65
|
-
if (input.type === "Text") return TextLegacyCodec(ctx).
|
|
66
|
-
if (input.type === "Color") return ColorLegacyCodec(ctx).
|
|
67
|
-
if (input.type === "Range") return RangeLegacyCodec(ctx).
|
|
68
|
-
if (input.type === "Date") return DateLegacyCodec(ctx).
|
|
69
|
-
if (input.type === "Number") return NumberLegacyCodec(ctx).
|
|
70
|
-
if (input.type === "Timestamp") return TimestampLegacyCodec(ctx).
|
|
71
|
-
if (input.type === "Select") return SelectLegacyCodec(ctx).
|
|
65
|
+
if (input.type === "Text") return TextLegacyCodec(ctx).fromContent(input);
|
|
66
|
+
if (input.type === "Color") return ColorLegacyCodec(ctx).fromContent(input);
|
|
67
|
+
if (input.type === "Range") return RangeLegacyCodec(ctx).fromContent(input);
|
|
68
|
+
if (input.type === "Date") return DateLegacyCodec(ctx).fromContent(input);
|
|
69
|
+
if (input.type === "Number") return NumberLegacyCodec(ctx).fromContent(input);
|
|
70
|
+
if (input.type === "Timestamp") return TimestampLegacyCodec(ctx).fromContent(input);
|
|
71
|
+
if (input.type === "Select") return SelectLegacyCodec(ctx).fromContent(input);
|
|
72
72
|
return;
|
|
73
|
-
case GeoPointContentType: return GeoPointLegacyCodec(ctx).
|
|
74
|
-
case RichTextContentType: return RichTextLegacyCodec(ctx).
|
|
75
|
-
case EmbedContentType: return EmbedLegacyCodec(ctx).
|
|
76
|
-
case BooleanContentType: return BooleanLegacyCodec(ctx).
|
|
77
|
-
case ImageContentType: return ImageLegacyCodec(ctx).
|
|
78
|
-
case IntegrationFieldContentType: return IntegrationFieldLegacyCodec(ctx).
|
|
79
|
-
case LinkContentType: return LinkLegacyCodec(ctx).
|
|
80
|
-
case SeparatorContentType: return SeparatorLegacyCodec(ctx).
|
|
81
|
-
case TableContentType: return TableLegacyCodec(ctx).
|
|
82
|
-
case RepeatableContentType: return RepeatableLegacyCodec(ctx, input.type).
|
|
73
|
+
case GeoPointContentType: return GeoPointLegacyCodec(ctx).fromContent(input);
|
|
74
|
+
case RichTextContentType: return RichTextLegacyCodec(ctx).fromContent(input);
|
|
75
|
+
case EmbedContentType: return EmbedLegacyCodec(ctx).fromContent(input);
|
|
76
|
+
case BooleanContentType: return BooleanLegacyCodec(ctx).fromContent(input);
|
|
77
|
+
case ImageContentType: return ImageLegacyCodec(ctx).fromContent(input);
|
|
78
|
+
case IntegrationFieldContentType: return IntegrationFieldLegacyCodec(ctx).fromContent(input);
|
|
79
|
+
case LinkContentType: return LinkLegacyCodec(ctx).fromContent(input);
|
|
80
|
+
case SeparatorContentType: return SeparatorLegacyCodec(ctx).fromContent(input);
|
|
81
|
+
case TableContentType: return TableLegacyCodec(ctx).fromContent(input);
|
|
82
|
+
case RepeatableContentType: return RepeatableLegacyCodec(ctx, input.type).fromContent(input);
|
|
83
83
|
case EmptyContentType:
|
|
84
84
|
default: return;
|
|
85
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nestable.js","names":[],"sources":["../../../src/content/codec/nestable.ts"],"sourcesContent":["import { z } from \"zod/mini\"\n\nimport { BooleanContentType } from \"../boolean\"\nimport { EmbedContentType } from \"../embed\"\nimport { EmptyContentType } from \"../empty\"\nimport { FieldContentType } from \"../field\"\nimport { GeoPointContentType } from \"../geopoint\"\nimport { ImageContentType } from \"../image\"\nimport { IntegrationFieldContentType } from \"../integrationField\"\nimport type { NestableLegacy } from \"../legacy/nestable\"\nimport { LinkContentType } from \"../link\"\nimport type { NestableContent } from \"../nestable\"\nimport { NestableContentSchema } from \"../nestable\"\nimport { RepeatableContentType } from \"../repeatable\"\nimport { RichTextContentType } from \"../richText\"\nimport { SeparatorContentType } from \"../separator\"\nimport { TableContentType } from \"../table\"\nimport { BooleanLegacyCodec } from \"./boolean\"\nimport { EmbedLegacyCodec } from \"./embed\"\nimport { EmptyLegacyCodec } from \"./empty\"\nimport {\n\tColorLegacyCodec,\n\tDateLegacyCodec,\n\tNumberLegacyCodec,\n\tRangeLegacyCodec,\n\tSelectLegacyCodec,\n\tTextLegacyCodec,\n\tTimestampLegacyCodec,\n} from \"./field\"\nimport { GeoPointLegacyCodec } from \"./geopoint\"\nimport { ImageLegacyCodec } from \"./image\"\nimport { IntegrationFieldLegacyCodec } from \"./integrationField\"\nimport type { LegacyCodec, LegacyContentCtx } from \"./legacyContentCtx\"\nimport { LinkLegacyCodec } from \"./link\"\nimport { RepeatableLegacyCodec } from \"./repeatable\"\nimport { RichTextLegacyCodec } from \"./richText\"\nimport { SeparatorLegacyCodec } from \"./separator\"\nimport { TableLegacyCodec } from \"./table\"\n\nconst UnsupportedNestableLegacySchema = z.never()\n\nexport const NestableLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<NestableContent, NestableLegacy, true> => ({\n\tname: \"NestableLegacy\",\n\n\tis(input): input is NestableContent {\n\t\treturn NestableContentSchema.safeParse(input).success\n\t},\n\n\
|
|
1
|
+
{"version":3,"file":"nestable.js","names":[],"sources":["../../../src/content/codec/nestable.ts"],"sourcesContent":["import { z } from \"zod/mini\"\n\nimport { BooleanContentType } from \"../boolean\"\nimport { EmbedContentType } from \"../embed\"\nimport { EmptyContentType } from \"../empty\"\nimport { FieldContentType } from \"../field\"\nimport { GeoPointContentType } from \"../geopoint\"\nimport { ImageContentType } from \"../image\"\nimport { IntegrationFieldContentType } from \"../integrationField\"\nimport type { NestableLegacy } from \"../legacy/nestable\"\nimport { LinkContentType } from \"../link\"\nimport type { NestableContent } from \"../nestable\"\nimport { NestableContentSchema } from \"../nestable\"\nimport { RepeatableContentType } from \"../repeatable\"\nimport { RichTextContentType } from \"../richText\"\nimport { SeparatorContentType } from \"../separator\"\nimport { TableContentType } from \"../table\"\nimport { BooleanLegacyCodec } from \"./boolean\"\nimport { EmbedLegacyCodec } from \"./embed\"\nimport { EmptyLegacyCodec } from \"./empty\"\nimport {\n\tColorLegacyCodec,\n\tDateLegacyCodec,\n\tNumberLegacyCodec,\n\tRangeLegacyCodec,\n\tSelectLegacyCodec,\n\tTextLegacyCodec,\n\tTimestampLegacyCodec,\n} from \"./field\"\nimport { GeoPointLegacyCodec } from \"./geopoint\"\nimport { ImageLegacyCodec } from \"./image\"\nimport { IntegrationFieldLegacyCodec } from \"./integrationField\"\nimport type { LegacyCodec, LegacyContentCtx } from \"./legacyContentCtx\"\nimport { LinkLegacyCodec } from \"./link\"\nimport { RepeatableLegacyCodec } from \"./repeatable\"\nimport { RichTextLegacyCodec } from \"./richText\"\nimport { SeparatorLegacyCodec } from \"./separator\"\nimport { TableLegacyCodec } from \"./table\"\n\nconst UnsupportedNestableLegacySchema = z.never()\n\nexport const NestableLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<NestableContent, NestableLegacy, true> => ({\n\tname: \"NestableLegacy\",\n\n\tis(input): input is NestableContent {\n\t\treturn NestableContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\tif (!ctx.fieldType) {\n\t\t\treturn UnsupportedNestableLegacySchema.safeParse(\n\t\t\t\tinput,\n\t\t\t) as z.core.util.SafeParseError<NestableLegacy>\n\t\t}\n\n\t\tconst empty = EmptyLegacyCodec(ctx).toContent(input)\n\t\tif (empty.success) {\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: empty.data,\n\t\t\t}\n\t\t}\n\n\t\tswitch (ctx.fieldType) {\n\t\t\tcase \"Text\":\n\t\t\t\treturn TextLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"Color\":\n\t\t\t\treturn ColorLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"Date\":\n\t\t\t\treturn DateLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"Timestamp\":\n\t\t\t\treturn TimestampLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"Number\":\n\t\t\t\treturn NumberLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"Range\":\n\t\t\t\treturn RangeLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"Select\":\n\t\t\t\treturn SelectLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"GeoPoint\":\n\t\t\t\treturn GeoPointLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"StructuredText\":\n\t\t\t\treturn RichTextLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"Boolean\":\n\t\t\t\treturn BooleanLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"Embed\":\n\t\t\t\treturn EmbedLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"Image\":\n\t\t\t\treturn ImageLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"IntegrationFields\":\n\t\t\t\treturn IntegrationFieldLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"Link\":\n\t\t\t\treturn LinkLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"Separator\":\n\t\t\t\treturn SeparatorLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"Table\":\n\t\t\t\treturn TableLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"Repeatable.Link\":\n\t\t\t\treturn RepeatableLegacyCodec(ctx, \"Link\").toContent(input)\n\t\t\tdefault:\n\t\t\t\treturn UnsupportedNestableLegacySchema.safeParse(\n\t\t\t\t\tinput,\n\t\t\t\t) as z.core.util.SafeParseError<NestableLegacy>\n\t\t}\n\t},\n\n\tfromContent(input) {\n\t\tswitch (input.__TYPE__) {\n\t\t\tcase FieldContentType: {\n\t\t\t\tif (input.type === \"Text\") return TextLegacyCodec(ctx).fromContent(input)\n\t\t\t\tif (input.type === \"Color\") return ColorLegacyCodec(ctx).fromContent(input)\n\t\t\t\tif (input.type === \"Range\") return RangeLegacyCodec(ctx).fromContent(input)\n\t\t\t\tif (input.type === \"Date\") return DateLegacyCodec(ctx).fromContent(input)\n\t\t\t\tif (input.type === \"Number\") return NumberLegacyCodec(ctx).fromContent(input)\n\t\t\t\tif (input.type === \"Timestamp\") return TimestampLegacyCodec(ctx).fromContent(input)\n\t\t\t\tif (input.type === \"Select\") return SelectLegacyCodec(ctx).fromContent(input)\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tcase GeoPointContentType:\n\t\t\t\treturn GeoPointLegacyCodec(ctx).fromContent(input)\n\t\t\tcase RichTextContentType:\n\t\t\t\treturn RichTextLegacyCodec(ctx).fromContent(input)\n\t\t\tcase EmbedContentType:\n\t\t\t\treturn EmbedLegacyCodec(ctx).fromContent(input)\n\t\t\tcase BooleanContentType:\n\t\t\t\treturn BooleanLegacyCodec(ctx).fromContent(input)\n\t\t\tcase ImageContentType:\n\t\t\t\treturn ImageLegacyCodec(ctx).fromContent(input)\n\t\t\tcase IntegrationFieldContentType:\n\t\t\t\treturn IntegrationFieldLegacyCodec(ctx).fromContent(input)\n\t\t\tcase LinkContentType:\n\t\t\t\treturn LinkLegacyCodec(ctx).fromContent(input)\n\t\t\tcase SeparatorContentType:\n\t\t\t\treturn SeparatorLegacyCodec(ctx).fromContent(input)\n\t\t\tcase TableContentType:\n\t\t\t\treturn TableLegacyCodec(ctx).fromContent(input)\n\t\t\tcase RepeatableContentType:\n\t\t\t\treturn RepeatableLegacyCodec(ctx, input.type).fromContent(input)\n\n\t\t\tcase EmptyContentType:\n\t\t\tdefault:\n\t\t\t\treturn undefined\n\t\t}\n\t},\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,kCAAkC,EAAE,OAAO;AAEjD,MAAa,uBACZ,SACyD;CACzD,MAAM;CAEN,GAAG,OAAiC;AACnC,SAAO,sBAAsB,UAAU,MAAM,CAAC;;CAG/C,UAAU,OAAO;AAChB,MAAI,CAAC,IAAI,UACR,QAAO,gCAAgC,UACtC,MACA;EAGF,MAAM,QAAQ,iBAAiB,IAAI,CAAC,UAAU,MAAM;AACpD,MAAI,MAAM,QACT,QAAO;GACN,SAAS;GACT,MAAM,MAAM;GACZ;AAGF,UAAQ,IAAI,WAAZ;GACC,KAAK,OACJ,QAAO,gBAAgB,IAAI,CAAC,UAAU,MAAM;GAC7C,KAAK,QACJ,QAAO,iBAAiB,IAAI,CAAC,UAAU,MAAM;GAC9C,KAAK,OACJ,QAAO,gBAAgB,IAAI,CAAC,UAAU,MAAM;GAC7C,KAAK,YACJ,QAAO,qBAAqB,IAAI,CAAC,UAAU,MAAM;GAClD,KAAK,SACJ,QAAO,kBAAkB,IAAI,CAAC,UAAU,MAAM;GAC/C,KAAK,QACJ,QAAO,iBAAiB,IAAI,CAAC,UAAU,MAAM;GAC9C,KAAK,S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AAO,oBAAoB,IAAI,CAAC,YAAY,MAAM;GACnD,KAAK,oBACJ,QAAO,oBAAoB,IAAI,CAAC,YAAY,MAAM;GACnD,KAAK,iBACJ,QAAO,iBAAiB,IAAI,CAAC,YAAY,MAAM;GAChD,KAAK,mBACJ,QAAO,mBAAmB,IAAI,CAAC,YAAY,MAAM;GAClD,KAAK,iBACJ,QAAO,iBAAiB,IAAI,CAAC,YAAY,MAAM;GAChD,KAAK,4BACJ,QAAO,4BAA4B,IAAI,CAAC,YAAY,MAAM;GAC3D,KAAK,gBACJ,QAAO,gBAAgB,IAAI,CAAC,YAAY,MAAM;GAC/C,KAAK,qBACJ,QAAO,qBAAqB,IAAI,CAAC,YAAY,MAAM;GACpD,KAAK,iBACJ,QAAO,iBAAiB,IAAI,CAAC,YAAY,MAAM;GAChD,KAAK,sBACJ,QAAO,sBAAsB,KAAK,MAAM,KAAK,CAAC,YAAY,MAAM;GAEjE,KAAK;GACL,QACC;;;CAGH"}
|
|
@@ -8,7 +8,7 @@ const RepeatableLegacyCodec = (ctx, fieldType) => ({
|
|
|
8
8
|
is(input) {
|
|
9
9
|
return RepeatableContentSchema.safeParse(input).success;
|
|
10
10
|
},
|
|
11
|
-
|
|
11
|
+
toContent(input) {
|
|
12
12
|
const parsed = RepeatableLegacySchema.safeParse(input);
|
|
13
13
|
if (!parsed.success) return parsed;
|
|
14
14
|
return {
|
|
@@ -29,7 +29,7 @@ const RepeatableLegacyCodec = (ctx, fieldType) => ({
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
},
|
|
32
|
-
|
|
32
|
+
fromContent(input) {
|
|
33
33
|
const legacy = {
|
|
34
34
|
content: [],
|
|
35
35
|
types: { [ctx.keyOfType]: `Repeatable.${fieldType}` },
|
|
@@ -38,7 +38,7 @@ const RepeatableLegacyCodec = (ctx, fieldType) => ({
|
|
|
38
38
|
for (const item of input.value) try {
|
|
39
39
|
switch (fieldType) {
|
|
40
40
|
case "Link":
|
|
41
|
-
const result = LinkLegacyCodec(ctx).
|
|
41
|
+
const result = LinkLegacyCodec(ctx).fromContent(item);
|
|
42
42
|
legacy.content.push(result.content);
|
|
43
43
|
legacy.keys = {
|
|
44
44
|
...legacy.keys,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repeatable.js","names":[],"sources":["../../../src/content/codec/repeatable.ts"],"sourcesContent":["import { LinkLegacySchema } from \"../legacy/link\"\nimport { RepeatableLegacySchema } from \"../legacy/repeatable\"\nimport type { RepeatableLegacy } from \"../legacy/repeatable\"\nimport { RepeatableContentSchema, RepeatableContentType } from \"../repeatable\"\nimport type { RepeatableContent } from \"../repeatable\"\nimport type { LegacyCodec, LegacyContentCtx } from \"./legacyContentCtx\"\nimport { LinkLegacyCodec, linkLegacyToContent } from \"./link\"\n\nexport const RepeatableLegacyCodec = (\n\tctx: LegacyContentCtx,\n\tfieldType: \"Link\",\n): LegacyCodec<RepeatableContent, RepeatableLegacy> => ({\n\tname: \"RepeatableLegacy\",\n\n\tis(input): input is RepeatableContent {\n\t\treturn RepeatableContentSchema.safeParse(input).success\n\t},\n\n\
|
|
1
|
+
{"version":3,"file":"repeatable.js","names":[],"sources":["../../../src/content/codec/repeatable.ts"],"sourcesContent":["import { LinkLegacySchema } from \"../legacy/link\"\nimport { RepeatableLegacySchema } from \"../legacy/repeatable\"\nimport type { RepeatableLegacy } from \"../legacy/repeatable\"\nimport { RepeatableContentSchema, RepeatableContentType } from \"../repeatable\"\nimport type { RepeatableContent } from \"../repeatable\"\nimport type { LegacyCodec, LegacyContentCtx } from \"./legacyContentCtx\"\nimport { LinkLegacyCodec, linkLegacyToContent } from \"./link\"\n\nexport const RepeatableLegacyCodec = (\n\tctx: LegacyContentCtx,\n\tfieldType: \"Link\",\n): LegacyCodec<RepeatableContent, RepeatableLegacy> => ({\n\tname: \"RepeatableLegacy\",\n\n\tis(input): input is RepeatableContent {\n\t\treturn RepeatableContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\tconst parsed = RepeatableLegacySchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\treturn parsed\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: {\n\t\t\t\t__TYPE__: RepeatableContentType,\n\t\t\t\ttype: fieldType,\n\t\t\t\tvalue: parsed.data.flatMap((item) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tswitch (fieldType) {\n\t\t\t\t\t\t\tcase \"Link\":\n\t\t\t\t\t\t\t\treturn [linkLegacyToContent(LinkLegacySchema.parse(item))]\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\treturn []\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\treturn []\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t},\n\t\t}\n\t},\n\n\tfromContent(input) {\n\t\tconst legacy: ReturnType<LegacyCodec<RepeatableContent, RepeatableLegacy>[\"fromContent\"]> = {\n\t\t\tcontent: [],\n\t\t\ttypes: { [ctx.keyOfType]: `Repeatable.${fieldType}` },\n\t\t\tkeys: {},\n\t\t}\n\n\t\tfor (const item of input.value) {\n\t\t\ttry {\n\t\t\t\tswitch (fieldType) {\n\t\t\t\t\tcase \"Link\":\n\t\t\t\t\t\tconst result = LinkLegacyCodec(ctx).fromContent(item)\n\t\t\t\t\t\tlegacy.content.push(result.content)\n\t\t\t\t\t\tlegacy.keys = { ...legacy.keys, ...result.keys }\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// noop, continue\n\t\t\t}\n\t\t}\n\t\treturn legacy\n\t},\n})\n"],"mappings":";;;;;AAQA,MAAa,yBACZ,KACA,eACuD;CACvD,MAAM;CAEN,GAAG,OAAmC;AACrC,SAAO,wBAAwB,UAAU,MAAM,CAAC;;CAGjD,UAAU,OAAO;EAChB,MAAM,SAAS,uBAAuB,UAAU,MAAM;AACtD,MAAI,CAAC,OAAO,QACX,QAAO;AAGR,SAAO;GACN,SAAS;GACT,MAAM;IACL,UAAU;IACV,MAAM;IACN,OAAO,OAAO,KAAK,SAAS,SAAS;AACpC,SAAI;AACH,cAAQ,WAAR;OACC,KAAK,OACJ,QAAO,CAAC,oBAAoB,iBAAiB,MAAM,KAAK,CAAC,CAAC;OAC3D,QACC,QAAO,EAAE;;aAEJ;AACP,aAAO,EAAE;;MAET;IACF;GACD;;CAGF,YAAY,OAAO;EAClB,MAAM,SAAsF;GAC3F,SAAS,EAAE;GACX,OAAO,GAAG,IAAI,YAAY,cAAc,aAAa;GACrD,MAAM,EAAE;GACR;AAED,OAAK,MAAM,QAAQ,MAAM,MACxB,KAAI;AACH,WAAQ,WAAR;IACC,KAAK;KACJ,MAAM,SAAS,gBAAgB,IAAI,CAAC,YAAY,KAAK;AACrD,YAAO,QAAQ,KAAK,OAAO,QAAQ;AACnC,YAAO,OAAO;MAAE,GAAG,OAAO;MAAM,GAAG,OAAO;MAAM;AAChD;;UAEK;AAIT,SAAO;;CAER"}
|
|
@@ -62,7 +62,7 @@ const RichTextLegacyCodec = (ctx) => ({
|
|
|
62
62
|
is(input) {
|
|
63
63
|
return RichTextContentSchema.safeParse(input).success;
|
|
64
64
|
},
|
|
65
|
-
|
|
65
|
+
toContent(input) {
|
|
66
66
|
const parsed = RichTextLegacySchema.safeParse(input);
|
|
67
67
|
if (!parsed.success) return parsed;
|
|
68
68
|
return {
|
|
@@ -73,7 +73,7 @@ const RichTextLegacyCodec = (ctx) => ({
|
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
},
|
|
76
|
-
|
|
76
|
+
fromContent(input) {
|
|
77
77
|
return {
|
|
78
78
|
content: input.value.map((block) => blockValueToLegacy(block)),
|
|
79
79
|
types: { [ctx.keyOfType]: "StructuredText" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"richText.js","names":[],"sources":["../../../src/content/codec/richText.ts"],"sourcesContent":["import type { BlockLegacy, RichTextLegacy } from \"../legacy/richText\"\nimport { BlockLegacySchema, RichTextLegacySchema, RichTextNodeType } from \"../legacy/richText\"\nimport type { BlockValue, RichTextContent } from \"../richText\"\nimport { RichTextContentSchema, RichTextContentType } from \"../richText\"\nimport { embedLegacyToContent, embedContentToLegacy } from \"./embed\"\nimport { imageLegacyToContent } from \"./image\"\nimport type { LegacyCodec, LegacyContentCtx } from \"./legacyContentCtx\"\nimport { linkLegacyToValue, linkValueToLegacy } from \"./link\"\n\n// Also used by content/codec/table\nexport function blockLegacyToValue(block: BlockLegacy): BlockValue {\n\tif (block.type === RichTextNodeType.embed) {\n\t\treturn {\n\t\t\t...block,\n\t\t\tdata: embedLegacyToContent(block.data),\n\t\t}\n\t}\n\n\tif (block.type === RichTextNodeType.image) {\n\t\treturn {\n\t\t\t...block,\n\t\t\tdata: {\n\t\t\t\t...imageLegacyToContent(block.data),\n\t\t\t\t...(block.data.linkTo ? { linkTo: linkLegacyToValue(block.data.linkTo) } : {}),\n\t\t\t},\n\t\t}\n\t}\n\n\treturn {\n\t\t...block,\n\t\tcontent: {\n\t\t\t...block.content,\n\t\t\tspans: block.content.spans?.map((span) => {\n\t\t\t\tif (span.type === RichTextNodeType.hyperlink) {\n\t\t\t\t\treturn { ...span, data: linkLegacyToValue(span.data) }\n\t\t\t\t}\n\n\t\t\t\treturn span\n\t\t\t}),\n\t\t},\n\t}\n}\n\n// Also used by content/codec/table\nexport function blockValueToLegacy(block: BlockValue): BlockLegacy {\n\tif (block.type === RichTextNodeType.embed) {\n\t\treturn {\n\t\t\t...block,\n\t\t\tdata: embedContentToLegacy(block.data),\n\t\t}\n\t}\n\n\tif (block.type === RichTextNodeType.image) {\n\t\treturn {\n\t\t\t...block,\n\t\t\tdata: {\n\t\t\t\t...block.data,\n\t\t\t\t...(block.data.linkTo ? { linkTo: linkValueToLegacy(block.data.linkTo) } : {}),\n\t\t\t},\n\t\t}\n\t}\n\n\tif (\"content\" in block) {\n\t\treturn {\n\t\t\t...block,\n\t\t\tcontent: {\n\t\t\t\t...block.content,\n\t\t\t\tspans: block.content.spans?.map((span) => {\n\t\t\t\t\tif (span.type === RichTextNodeType.hyperlink) {\n\t\t\t\t\t\treturn { ...span, data: linkValueToLegacy(span.data) }\n\t\t\t\t\t}\n\n\t\t\t\t\treturn span\n\t\t\t\t}),\n\t\t\t},\n\t\t}\n\t}\n\n\treturn BlockLegacySchema.parse(block)\n}\n\nexport const RichTextLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<RichTextContent, RichTextLegacy> => ({\n\tname: \"RichTextLegacy\",\n\n\tis(input): input is RichTextContent {\n\t\treturn RichTextContentSchema.safeParse(input).success\n\t},\n\n\
|
|
1
|
+
{"version":3,"file":"richText.js","names":[],"sources":["../../../src/content/codec/richText.ts"],"sourcesContent":["import type { BlockLegacy, RichTextLegacy } from \"../legacy/richText\"\nimport { BlockLegacySchema, RichTextLegacySchema, RichTextNodeType } from \"../legacy/richText\"\nimport type { BlockValue, RichTextContent } from \"../richText\"\nimport { RichTextContentSchema, RichTextContentType } from \"../richText\"\nimport { embedLegacyToContent, embedContentToLegacy } from \"./embed\"\nimport { imageLegacyToContent } from \"./image\"\nimport type { LegacyCodec, LegacyContentCtx } from \"./legacyContentCtx\"\nimport { linkLegacyToValue, linkValueToLegacy } from \"./link\"\n\n// Also used by content/codec/table\nexport function blockLegacyToValue(block: BlockLegacy): BlockValue {\n\tif (block.type === RichTextNodeType.embed) {\n\t\treturn {\n\t\t\t...block,\n\t\t\tdata: embedLegacyToContent(block.data),\n\t\t}\n\t}\n\n\tif (block.type === RichTextNodeType.image) {\n\t\treturn {\n\t\t\t...block,\n\t\t\tdata: {\n\t\t\t\t...imageLegacyToContent(block.data),\n\t\t\t\t...(block.data.linkTo ? { linkTo: linkLegacyToValue(block.data.linkTo) } : {}),\n\t\t\t},\n\t\t}\n\t}\n\n\treturn {\n\t\t...block,\n\t\tcontent: {\n\t\t\t...block.content,\n\t\t\tspans: block.content.spans?.map((span) => {\n\t\t\t\tif (span.type === RichTextNodeType.hyperlink) {\n\t\t\t\t\treturn { ...span, data: linkLegacyToValue(span.data) }\n\t\t\t\t}\n\n\t\t\t\treturn span\n\t\t\t}),\n\t\t},\n\t}\n}\n\n// Also used by content/codec/table\nexport function blockValueToLegacy(block: BlockValue): BlockLegacy {\n\tif (block.type === RichTextNodeType.embed) {\n\t\treturn {\n\t\t\t...block,\n\t\t\tdata: embedContentToLegacy(block.data),\n\t\t}\n\t}\n\n\tif (block.type === RichTextNodeType.image) {\n\t\treturn {\n\t\t\t...block,\n\t\t\tdata: {\n\t\t\t\t...block.data,\n\t\t\t\t...(block.data.linkTo ? { linkTo: linkValueToLegacy(block.data.linkTo) } : {}),\n\t\t\t},\n\t\t}\n\t}\n\n\tif (\"content\" in block) {\n\t\treturn {\n\t\t\t...block,\n\t\t\tcontent: {\n\t\t\t\t...block.content,\n\t\t\t\tspans: block.content.spans?.map((span) => {\n\t\t\t\t\tif (span.type === RichTextNodeType.hyperlink) {\n\t\t\t\t\t\treturn { ...span, data: linkValueToLegacy(span.data) }\n\t\t\t\t\t}\n\n\t\t\t\t\treturn span\n\t\t\t\t}),\n\t\t\t},\n\t\t}\n\t}\n\n\treturn BlockLegacySchema.parse(block)\n}\n\nexport const RichTextLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<RichTextContent, RichTextLegacy> => ({\n\tname: \"RichTextLegacy\",\n\n\tis(input): input is RichTextContent {\n\t\treturn RichTextContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\tconst parsed = RichTextLegacySchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\treturn parsed\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: {\n\t\t\t\tvalue: parsed.data.map((block) => blockLegacyToValue(block)),\n\t\t\t\t__TYPE__: RichTextContentType,\n\t\t\t},\n\t\t}\n\t},\n\n\tfromContent(input) {\n\t\treturn {\n\t\t\tcontent: input.value.map((block) => blockValueToLegacy(block)),\n\t\t\ttypes: { [ctx.keyOf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AACnC,SAAO,sBAAsB,UAAU,MAAM,CAAC;;CAG/C,UAAU,OAAO;EAChB,MAAM,SAAS,qBAAqB,UAAU,MAAM;AACpD,MAAI,CAAC,OAAO,QACX,QAAO;AAGR,SAAO;GACN,SAAS;GACT,MAAM;IACL,OAAO,OAAO,KAAK,KAAK,UAAU,mBAAmB,MAAM,CAAC;IAC5D,UAAU;IACV;GACD;;CAGF,YAAY,OAAO;AAClB,SAAO;GACN,SAAS,MAAM,MAAM,KAAK,UAAU,mBAAmB,MAAM,CAAC;GAC9D,OAAO,GAAG,IAAI,YAAY,kBAAkB;GAC5C,MAAM,EAAE;GACR;;CAEF"}
|
|
@@ -6,13 +6,13 @@ const SeparatorLegacyCodec = (ctx) => ({
|
|
|
6
6
|
is(input) {
|
|
7
7
|
return SeparatorContentSchema.safeParse(input).success;
|
|
8
8
|
},
|
|
9
|
-
|
|
9
|
+
toContent(_input) {
|
|
10
10
|
return {
|
|
11
11
|
success: true,
|
|
12
12
|
data: { __TYPE__: SeparatorContentType }
|
|
13
13
|
};
|
|
14
14
|
},
|
|
15
|
-
|
|
15
|
+
fromContent() {
|
|
16
16
|
return {
|
|
17
17
|
content: {},
|
|
18
18
|
types: { [ctx.keyOfType]: "Separator" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"separator.js","names":[],"sources":["../../../src/content/codec/separator.ts"],"sourcesContent":["import type { SeparatorLegacy } from \"../legacy/separator\"\nimport { SeparatorContentSchema } from \"../separator\"\nimport type { SeparatorContent } from \"../separator\"\nimport type { LegacyContentCtx, LegacyCodec } from \"./legacyContentCtx\"\n\nconst SeparatorContentType = \"SeparatorContent\"\n\nexport const SeparatorLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<SeparatorContent, SeparatorLegacy> => ({\n\tname: \"SeparatorLegacy\",\n\n\tis(input): input is SeparatorContent {\n\t\treturn SeparatorContentSchema.safeParse(input).success\n\t},\n\n\
|
|
1
|
+
{"version":3,"file":"separator.js","names":[],"sources":["../../../src/content/codec/separator.ts"],"sourcesContent":["import type { SeparatorLegacy } from \"../legacy/separator\"\nimport { SeparatorContentSchema } from \"../separator\"\nimport type { SeparatorContent } from \"../separator\"\nimport type { LegacyContentCtx, LegacyCodec } from \"./legacyContentCtx\"\n\nconst SeparatorContentType = \"SeparatorContent\"\n\nexport const SeparatorLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<SeparatorContent, SeparatorLegacy> => ({\n\tname: \"SeparatorLegacy\",\n\n\tis(input): input is SeparatorContent {\n\t\treturn SeparatorContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(_input) {\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: {\n\t\t\t\t__TYPE__: SeparatorContentType,\n\t\t\t},\n\t\t}\n\t},\n\n\tfromContent() {\n\t\treturn {\n\t\t\tcontent: {},\n\t\t\ttypes: { [ctx.keyOfType]: \"Separator\" },\n\t\t\tkeys: {},\n\t\t}\n\t},\n})\n"],"mappings":";;AAKA,MAAM,uBAAuB;AAE7B,MAAa,wBACZ,SACqD;CACrD,MAAM;CAEN,GAAG,OAAkC;AACpC,SAAO,uBAAuB,UAAU,MAAM,CAAC;;CAGhD,UAAU,QAAQ;AACjB,SAAO;GACN,SAAS;GACT,MAAM,EACL,UAAU,sBACV;GACD;;CAGF,cAAc;AACb,SAAO;GACN,SAAS,EAAE;GACX,OAAO,GAAG,IAAI,YAAY,aAAa;GACvC,MAAM,EAAE;GACR;;CAEF"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { getFieldCtx } from "./legacyContentCtx.js";
|
|
2
|
-
import { CompositeSliceContentSchema, CompositeSliceContentType, SharedSliceContentSchema, SharedSliceContentType,
|
|
2
|
+
import { CompositeSliceContentSchema, CompositeSliceContentType, LegacySliceContentSchema, SharedSliceContentSchema, SharedSliceContentType, SliceContentSchema } from "../slice.js";
|
|
3
3
|
import { NestableLegacyCodec } from "./nestable.js";
|
|
4
4
|
import { GroupItemLegacyCodec, NestableAndGroupLegacyCodec } from "./group.js";
|
|
5
5
|
import { CompositeSliceLegacySchema, SharedSliceLegacySchema } from "../legacy/slice.js";
|
|
6
6
|
//#region src/content/codec/slice.ts
|
|
7
|
-
const
|
|
8
|
-
name: "
|
|
7
|
+
const LegacySliceLegacyCodec = (ctx) => ({
|
|
8
|
+
name: "LegacySliceLegacy",
|
|
9
9
|
is(input) {
|
|
10
|
-
return
|
|
10
|
+
return LegacySliceContentSchema.safeParse(input).success;
|
|
11
11
|
},
|
|
12
|
-
|
|
13
|
-
return NestableAndGroupLegacyCodec(ctx).
|
|
12
|
+
toContent(input) {
|
|
13
|
+
return NestableAndGroupLegacyCodec(ctx).toContent(input);
|
|
14
14
|
},
|
|
15
|
-
|
|
16
|
-
return NestableAndGroupLegacyCodec(ctx).
|
|
15
|
+
fromContent(input) {
|
|
16
|
+
return NestableAndGroupLegacyCodec(ctx).fromContent(input);
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
const CompositeSliceLegacyCodec = (ctx) => ({
|
|
@@ -21,7 +21,7 @@ const CompositeSliceLegacyCodec = (ctx) => ({
|
|
|
21
21
|
is(input) {
|
|
22
22
|
return CompositeSliceContentSchema.safeParse(input).success;
|
|
23
23
|
},
|
|
24
|
-
|
|
24
|
+
toContent(input) {
|
|
25
25
|
const parsed = CompositeSliceLegacySchema.safeParse(input);
|
|
26
26
|
if (!parsed.success) return parsed;
|
|
27
27
|
const nonRepeat = {};
|
|
@@ -30,7 +30,7 @@ const CompositeSliceLegacyCodec = (ctx) => ({
|
|
|
30
30
|
fieldKey: key,
|
|
31
31
|
ctx,
|
|
32
32
|
prefixes: ["non-repeat"]
|
|
33
|
-
})).
|
|
33
|
+
})).toContent(legacy);
|
|
34
34
|
if (!result.success) continue;
|
|
35
35
|
nonRepeat[key] = result.data;
|
|
36
36
|
}
|
|
@@ -40,7 +40,7 @@ const CompositeSliceLegacyCodec = (ctx) => ({
|
|
|
40
40
|
const result = GroupItemLegacyCodec(getFieldCtx({
|
|
41
41
|
fieldKey: "repeat",
|
|
42
42
|
ctx
|
|
43
|
-
}), index).
|
|
43
|
+
}), index).toContent(item);
|
|
44
44
|
if (!result.success) continue;
|
|
45
45
|
repeat.push(result.data);
|
|
46
46
|
}
|
|
@@ -53,7 +53,7 @@ const CompositeSliceLegacyCodec = (ctx) => ({
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
},
|
|
56
|
-
|
|
56
|
+
fromContent(input) {
|
|
57
57
|
const legacy = {
|
|
58
58
|
content: {
|
|
59
59
|
"non-repeat": {},
|
|
@@ -67,7 +67,7 @@ const CompositeSliceLegacyCodec = (ctx) => ({
|
|
|
67
67
|
fieldKey: key,
|
|
68
68
|
ctx,
|
|
69
69
|
prefixes: ["non-repeat"]
|
|
70
|
-
})).
|
|
70
|
+
})).fromContent(content);
|
|
71
71
|
if (!result) continue;
|
|
72
72
|
legacy.content["non-repeat"][key] = result.content;
|
|
73
73
|
legacy.types = {
|
|
@@ -85,7 +85,7 @@ const CompositeSliceLegacyCodec = (ctx) => ({
|
|
|
85
85
|
});
|
|
86
86
|
for (let index = 0; index < input.repeat.length; index++) {
|
|
87
87
|
const item = input.repeat[index];
|
|
88
|
-
const result = GroupItemLegacyCodec(repeatCtx, index).
|
|
88
|
+
const result = GroupItemLegacyCodec(repeatCtx, index).fromContent(item);
|
|
89
89
|
legacy.content.repeat.push(result.content);
|
|
90
90
|
legacy.types = {
|
|
91
91
|
...legacy.types,
|
|
@@ -104,7 +104,7 @@ const SharedSliceLegacyCodec = (ctx) => ({
|
|
|
104
104
|
is(input) {
|
|
105
105
|
return SharedSliceContentSchema.safeParse(input).success;
|
|
106
106
|
},
|
|
107
|
-
|
|
107
|
+
toContent(input) {
|
|
108
108
|
const parsed = SharedSliceLegacySchema.safeParse(input);
|
|
109
109
|
if (!parsed.success) return parsed;
|
|
110
110
|
const primary = {};
|
|
@@ -117,7 +117,7 @@ const SharedSliceLegacyCodec = (ctx) => ({
|
|
|
117
117
|
parsed.data.variation,
|
|
118
118
|
"primary"
|
|
119
119
|
]
|
|
120
|
-
})).
|
|
120
|
+
})).toContent(legacy);
|
|
121
121
|
if (!result.success) continue;
|
|
122
122
|
primary[key] = result.data;
|
|
123
123
|
}
|
|
@@ -128,7 +128,7 @@ const SharedSliceLegacyCodec = (ctx) => ({
|
|
|
128
128
|
fieldKey: "items",
|
|
129
129
|
ctx,
|
|
130
130
|
prefixes: ["variations", parsed.data.variation]
|
|
131
|
-
}), index).
|
|
131
|
+
}), index).toContent(item);
|
|
132
132
|
if (!result.success) continue;
|
|
133
133
|
items.push(result.data);
|
|
134
134
|
}
|
|
@@ -142,7 +142,7 @@ const SharedSliceLegacyCodec = (ctx) => ({
|
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
144
|
},
|
|
145
|
-
|
|
145
|
+
fromContent(input) {
|
|
146
146
|
const legacy = {
|
|
147
147
|
content: {
|
|
148
148
|
primary: {},
|
|
@@ -161,7 +161,7 @@ const SharedSliceLegacyCodec = (ctx) => ({
|
|
|
161
161
|
input.variation,
|
|
162
162
|
"primary"
|
|
163
163
|
]
|
|
164
|
-
})).
|
|
164
|
+
})).fromContent(content);
|
|
165
165
|
if (!result) continue;
|
|
166
166
|
legacy.content.primary[key] = result.content;
|
|
167
167
|
legacy.types = {
|
|
@@ -180,7 +180,7 @@ const SharedSliceLegacyCodec = (ctx) => ({
|
|
|
180
180
|
});
|
|
181
181
|
for (let index = 0; index < input.items.length; index++) {
|
|
182
182
|
const item = input.items[index];
|
|
183
|
-
const result = GroupItemLegacyCodec(repeatCtx, index).
|
|
183
|
+
const result = GroupItemLegacyCodec(repeatCtx, index).fromContent(item);
|
|
184
184
|
legacy.content.items.push(result.content);
|
|
185
185
|
legacy.types = {
|
|
186
186
|
...legacy.types,
|
|
@@ -199,22 +199,22 @@ const SliceLegacyCodec = (ctx) => ({
|
|
|
199
199
|
is(input) {
|
|
200
200
|
return SliceContentSchema.safeParse(input).success;
|
|
201
201
|
},
|
|
202
|
-
|
|
202
|
+
toContent(input) {
|
|
203
203
|
switch (ctx.fieldType) {
|
|
204
|
-
case "Slice": return CompositeSliceLegacyCodec(ctx).
|
|
205
|
-
case "SharedSlice": return SharedSliceLegacyCodec(ctx).
|
|
206
|
-
default: return
|
|
204
|
+
case "Slice": return CompositeSliceLegacyCodec(ctx).toContent(input);
|
|
205
|
+
case "SharedSlice": return SharedSliceLegacyCodec(ctx).toContent(input);
|
|
206
|
+
default: return LegacySliceLegacyCodec(ctx).toContent(input);
|
|
207
207
|
}
|
|
208
208
|
},
|
|
209
|
-
|
|
209
|
+
fromContent(input) {
|
|
210
210
|
switch (input.__TYPE__) {
|
|
211
|
-
case CompositeSliceContentType: return CompositeSliceLegacyCodec(ctx).
|
|
212
|
-
case SharedSliceContentType: return SharedSliceLegacyCodec(ctx).
|
|
213
|
-
default: return
|
|
211
|
+
case CompositeSliceContentType: return CompositeSliceLegacyCodec(ctx).fromContent(input);
|
|
212
|
+
case SharedSliceContentType: return SharedSliceLegacyCodec(ctx).fromContent(input);
|
|
213
|
+
default: return LegacySliceLegacyCodec(ctx).fromContent(input);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
});
|
|
217
217
|
//#endregion
|
|
218
|
-
export { CompositeSliceLegacyCodec,
|
|
218
|
+
export { CompositeSliceLegacyCodec, LegacySliceLegacyCodec, SharedSliceLegacyCodec, SliceLegacyCodec };
|
|
219
219
|
|
|
220
220
|
//# sourceMappingURL=slice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice.js","names":[],"sources":["../../../src/content/codec/slice.ts"],"sourcesContent":["import { CompositeSliceLegacySchema, SharedSliceLegacySchema } from \"../legacy/slice\"\nimport type {\n\tCompositeSliceLegacy,\n\tSharedSliceLegacy,\n\tSimpleSliceLegacy,\n\tSliceLegacy,\n} from \"../legacy/slice\"\nimport {\n\tCompositeSliceContentSchema,\n\tCompositeSliceContentType,\n\tSharedSliceContentSchema,\n\tSharedSliceContentType,\n\tSimpleSliceContentSchema,\n\tSliceContentSchema,\n} from \"../slice\"\nimport type {\n\tCompositeSliceContent,\n\tSharedSliceContent,\n\tSimpleSliceContent,\n\tSliceContent,\n} from \"../slice\"\nimport { GroupItemLegacyCodec, NestableAndGroupLegacyCodec } from \"./group\"\nimport { getFieldCtx, type LegacyCodec, type LegacyContentCtx } from \"./legacyContentCtx\"\nimport { NestableLegacyCodec } from \"./nestable\"\n\n// Simple (before 2020)\nexport const SimpleSliceLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<SimpleSliceContent, SimpleSliceLegacy, true> => ({\n\tname: \"SimpleSliceLegacy\",\n\n\tis(input): input is SimpleSliceContent {\n\t\treturn SimpleSliceContentSchema.safeParse(input).success\n\t},\n\n\tdecode(input) {\n\t\treturn NestableAndGroupLegacyCodec(ctx).decode(input)\n\t},\n\n\tencode(input) {\n\t\treturn NestableAndGroupLegacyCodec(ctx).encode(input)\n\t},\n})\n\n// Composite (2020 to 2021)\nexport const CompositeSliceLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<CompositeSliceContent, CompositeSliceLegacy> => ({\n\tname: \"CompositeSliceLegacy\",\n\n\tis(input): input is CompositeSliceContent {\n\t\treturn CompositeSliceContentSchema.safeParse(input).success\n\t},\n\n\tdecode(input) {\n\t\tconst parsed = CompositeSliceLegacySchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\treturn parsed\n\t\t}\n\n\t\tconst nonRepeat: CompositeSliceContent[\"nonRepeat\"] = {}\n\t\tfor (const [key, legacy] of Object.entries(parsed.data[\"non-repeat\"] || {})) {\n\t\t\tconst fieldCtx = getFieldCtx({\n\t\t\t\tfieldKey: key,\n\t\t\t\tctx,\n\t\t\t\tprefixes: [\"non-repeat\"],\n\t\t\t})\n\n\t\t\tconst result = NestableLegacyCodec(fieldCtx).decode(legacy)\n\t\t\tif (!result.success) continue\n\n\t\t\tnonRepeat[key] = result.data\n\t\t}\n\n\t\tconst repeat: CompositeSliceContent[\"repeat\"] = []\n\t\tfor (let index = 0; index < (parsed.data.repeat?.length || 0); index++) {\n\t\t\tconst item = parsed.data.repeat?.[index]\n\t\t\tconst itemCtx = getFieldCtx({ fieldKey: \"repeat\", ctx })\n\n\t\t\tconst result = GroupItemLegacyCodec(itemCtx, index).decode(item)\n\t\t\tif (!result.success) continue\n\n\t\t\trepeat.push(result.data)\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: {\n\t\t\t\t__TYPE__: CompositeSliceContentType,\n\t\t\t\tnonRepeat,\n\t\t\t\trepeat,\n\t\t\t},\n\t\t}\n\t},\n\n\tencode(input) {\n\t\tconst legacy: ReturnType<LegacyCodec<CompositeSliceContent, CompositeSliceLegacy>[\"encode\"]> = {\n\t\t\tcontent: {\n\t\t\t\t\"non-repeat\": {},\n\t\t\t\trepeat: [],\n\t\t\t},\n\t\t\ttypes: {\n\t\t\t\t[ctx.keyOfType]: \"Slice\",\n\t\t\t},\n\t\t\tkeys: {},\n\t\t}\n\n\t\t// Non-repeat\n\t\tfor (const [key, content] of Object.entries(input.nonRepeat)) {\n\t\t\tconst fieldCtx = getFieldCtx({\n\t\t\t\tfieldKey: key,\n\t\t\t\tctx,\n\t\t\t\tprefixes: [\"non-repeat\"],\n\t\t\t})\n\n\t\t\tconst result = NestableLegacyCodec(fieldCtx).encode(content)\n\t\t\tif (!result) continue\n\n\t\t\tlegacy.content[\"non-repeat\"]![key] = result.content\n\t\t\tlegacy.types = { ...legacy.types, ...result.types }\n\t\t\tlegacy.keys = { ...legacy.keys, ...result.keys }\n\t\t}\n\n\t\t// Repeat\n\t\tconst repeatCtx = getFieldCtx({ fieldKey: \"repeat\", ctx })\n\t\tfor (let index = 0; index < input.repeat.length; index++) {\n\t\t\tconst item = input.repeat[index]\n\t\t\tconst result = GroupItemLegacyCodec(repeatCtx, index).encode(item)\n\n\t\t\tlegacy.content.repeat!.push(result.content)\n\t\t\tlegacy.types = { ...legacy.types, ...result.types }\n\t\t\tlegacy.keys = { ...legacy.keys, ...result.keys }\n\t\t}\n\n\t\treturn legacy\n\t},\n})\n\n// Shared (2021 to present)\nexport const SharedSliceLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<SharedSliceContent, SharedSliceLegacy> => ({\n\tname: \"SharedSliceLegacy\",\n\n\tis(input): input is SharedSliceContent {\n\t\treturn SharedSliceContentSchema.safeParse(input).success\n\t},\n\n\tdecode(input) {\n\t\tconst parsed = SharedSliceLegacySchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\treturn parsed\n\t\t}\n\n\t\tconst primary: SharedSliceContent[\"primary\"] = {}\n\t\tfor (const [key, legacy] of Object.entries(parsed.data[\"primary\"])) {\n\t\t\tconst fieldCtx = getFieldCtx({\n\t\t\t\tfieldKey: key,\n\t\t\t\tctx,\n\t\t\t\tprefixes: [\"variations\", parsed.data.variation, \"primary\"],\n\t\t\t})\n\n\t\t\tconst result = NestableAndGroupLegacyCodec(fieldCtx).decode(legacy)\n\t\t\tif (!result.success) continue\n\n\t\t\tprimary[key] = result.data\n\t\t}\n\n\t\tconst items: SharedSliceContent[\"items\"] = []\n\t\tfor (let index = 0; index < parsed.data.items.length; index++) {\n\t\t\tconst item = parsed.data.items[index]\n\t\t\tconst itemCtx = getFieldCtx({\n\t\t\t\tfieldKey: \"items\",\n\t\t\t\tctx,\n\t\t\t\tprefixes: [\"variations\", parsed.data.variation],\n\t\t\t})\n\n\t\t\tconst result = GroupItemLegacyCodec(itemCtx, index).decode(item)\n\t\t\tif (!result.success) continue\n\n\t\t\titems.push(result.data)\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: {\n\t\t\t\t__TYPE__: SharedSliceContentType,\n\t\t\t\tvariation: parsed.data.variation,\n\t\t\t\tprimary,\n\t\t\t\titems,\n\t\t\t},\n\t\t}\n\t},\n\n\tencode(input) {\n\t\tconst legacy: ReturnType<LegacyCodec<SharedSliceContent, SharedSliceLegacy>[\"encode\"]> = {\n\t\t\tcontent: {\n\t\t\t\tprimary: {},\n\t\t\t\titems: [],\n\t\t\t\tvariation: input.variation,\n\t\t\t},\n\t\t\ttypes: {\n\t\t\t\t[ctx.keyOfType]: \"SharedSlice\",\n\t\t\t},\n\t\t\tkeys: {},\n\t\t}\n\n\t\t// Primary\n\t\tfor (const [key, content] of Object.entries(input.primary)) {\n\t\t\tconst fieldCtx = getFieldCtx({\n\t\t\t\tfieldKey: key,\n\t\t\t\tctx,\n\t\t\t\tprefixes: [\"variations\", input.variation, \"primary\"],\n\t\t\t})\n\n\t\t\tconst result = NestableAndGroupLegacyCodec(fieldCtx).encode(content)\n\t\t\tif (!result) continue\n\n\t\t\tlegacy.content.primary[key] = result.content\n\t\t\tlegacy.types = { ...legacy.types, ...result.types }\n\t\t\tlegacy.keys = { ...legacy.keys, ...result.keys }\n\t\t}\n\n\t\t// Items\n\t\tconst repeatCtx = getFieldCtx({\n\t\t\tfieldKey: \"items\",\n\t\t\tctx,\n\t\t\tprefixes: [\"variations\", input.variation],\n\t\t})\n\t\tfor (let index = 0; index < input.items.length; index++) {\n\t\t\tconst item = input.items[index]\n\t\t\tconst result = GroupItemLegacyCodec(repeatCtx, index).encode(item)\n\n\t\t\tlegacy.content.items.push(result.content)\n\t\t\tlegacy.types = { ...legacy.types, ...result.types }\n\t\t\tlegacy.keys = { ...legacy.keys, ...result.keys }\n\t\t}\n\n\t\treturn legacy\n\t},\n})\n\n// All\nexport const SliceLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<SliceContent, SliceLegacy, true> => ({\n\tname: \"SliceLegacy\",\n\n\tis(input): input is SliceContent {\n\t\treturn SliceContentSchema.safeParse(input).success\n\t},\n\n\tdecode(input) {\n\t\tswitch (ctx.fieldType) {\n\t\t\tcase \"Slice\":\n\t\t\t\treturn CompositeSliceLegacyCodec(ctx).decode(input)\n\t\t\tcase \"SharedSlice\":\n\t\t\t\treturn SharedSliceLegacyCodec(ctx).decode(input)\n\t\t\tdefault:\n\t\t\t\treturn SimpleSliceLegacyCodec(ctx).decode(input)\n\t\t}\n\t},\n\n\tencode(input) {\n\t\tswitch (input.__TYPE__) {\n\t\t\tcase CompositeSliceContentType:\n\t\t\t\treturn CompositeSliceLegacyCodec(ctx).encode(input)\n\t\t\tcase SharedSliceContentType:\n\t\t\t\treturn SharedSliceLegacyCodec(ctx).encode(input)\n\t\t\tdefault:\n\t\t\t\treturn SimpleSliceLegacyCodec(ctx).encode(input)\n\t\t}\n\t},\n})\n"],"mappings":";;;;;;AA0BA,MAAa,0BACZ,SAC+D;CAC/D,MAAM;CAEN,GAAG,OAAoC;AACtC,SAAO,yBAAyB,UAAU,MAAM,CAAC;;CAGlD,OAAO,OAAO;AACb,SAAO,4BAA4B,IAAI,CAAC,OAAO,MAAM;;CAGtD,OAAO,OAAO;AACb,SAAO,4BAA4B,IAAI,CAAC,OAAO,MAAM;;CAEtD;AAGD,MAAa,6BACZ,SAC+D;CAC/D,MAAM;CAEN,GAAG,OAAuC;AACzC,SAAO,4BAA4B,UAAU,MAAM,CAAC;;CAGrD,OAAO,OAAO;EACb,MAAM,SAAS,2BAA2B,UAAU,MAAM;AAC1D,MAAI,CAAC,OAAO,QACX,QAAO;EAGR,MAAM,YAAgD,EAAE;AACxD,OAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,OAAO,KAAK,iBAAiB,EAAE,CAAC,EAAE;GAO5E,MAAM,SAAS,oBANE,YAAY;IAC5B,UAAU;IACV;IACA,UAAU,CAAC,aAAa;IACxB,CAAC,CAE0C,CAAC,OAAO,OAAO;AAC3D,OAAI,CAAC,OAAO,QAAS;AAErB,aAAU,OAAO,OAAO;;EAGzB,MAAM,SAA0C,EAAE;AAClD,OAAK,IAAI,QAAQ,GAAG,SAAS,OAAO,KAAK,QAAQ,UAAU,IAAI,SAAS;GACvE,MAAM,OAAO,OAAO,KAAK,SAAS;GAGlC,MAAM,SAAS,qBAFC,YAAY;IAAE,UAAU;IAAU;I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UAAO,OAAO;IAAE,GAAG,OAAO;IAAM,GAAG,OAAO;IAAM;;EAIjD,MAAM,YAAY,YAAY;GAC7B,UAAU;GACV;GACA,UAAU,CAAC,cAAc,MAAM,UAAU;GACzC,CAAC;AACF,OAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,MAAM,QAAQ,SAAS;GACxD,MAAM,OAAO,MAAM,MAAM;GACzB,MAAM,SAAS,qBAAqB,WAAW,MAAM,CAAC,OAAO,KAAK;AAElE,UAAO,QAAQ,MAAM,KAAK,OAAO,QAAQ;AACzC,UAAO,QAAQ;IAAE,GAAG,OAAO;IAAO,GAAG,OAAO;IAAO;AACnD,UAAO,OAAO;IAAE,GAAG,OAAO;IAAM,GAAG,OAAO;IAAM;;AAGjD,SAAO;;CAER;AAGD,MAAa,oBACZ,SACmD;CACnD,MAAM;CAEN,GAAG,OAA8B;AAChC,SAAO,mBAAmB,UAAU,MAAM,CAAC;;CAG5C,OAAO,OAAO;AACb,UAAQ,IAAI,WAAZ;GACC,KAAK,QACJ,QAAO,0BAA0B,IAAI,CAAC,OAAO,MAAM;GACpD,KAAK,cACJ,QAAO,uBAAuB,IAAI,CAAC,OAAO,MAAM;GACjD,QACC,QAAO,uBAAuB,IAAI,CAAC,OAAO,MAAM;;;CAInD,OAAO,OAAO;AACb,UAAQ,MAAM,UAAd;GACC,KAAK,0BACJ,QAAO,0BAA0B,IAAI,CAAC,OAAO,MAAM;GACpD,KAAK,uBACJ,QAAO,uBAAuB,IAAI,CAAC,OAAO,MAAM;GACjD,QACC,QAAO,uBAAuB,IAAI,CAAC,OAAO,MAAM;;;CAGnD"}
|
|
1
|
+
{"version":3,"file":"slice.js","names":[],"sources":["../../../src/content/codec/slice.ts"],"sourcesContent":["import { CompositeSliceLegacySchema, SharedSliceLegacySchema } from \"../legacy/slice\"\nimport type {\n\tCompositeSliceLegacy,\n\tSharedSliceLegacy,\n\tLegacySliceLegacy,\n\tSliceLegacy,\n} from \"../legacy/slice\"\nimport {\n\tCompositeSliceContentSchema,\n\tCompositeSliceContentType,\n\tSharedSliceContentSchema,\n\tSharedSliceContentType,\n\tLegacySliceContentSchema,\n\tSliceContentSchema,\n} from \"../slice\"\nimport type {\n\tCompositeSliceContent,\n\tSharedSliceContent,\n\tLegacySliceContent,\n\tSliceContent,\n} from \"../slice\"\nimport { GroupItemLegacyCodec, NestableAndGroupLegacyCodec } from \"./group\"\nimport { getFieldCtx, type LegacyCodec, type LegacyContentCtx } from \"./legacyContentCtx\"\nimport { NestableLegacyCodec } from \"./nestable\"\n\n// Simple (before 2020)\nexport const LegacySliceLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<LegacySliceContent, LegacySliceLegacy, true> => ({\n\tname: \"LegacySliceLegacy\",\n\n\tis(input): input is LegacySliceContent {\n\t\treturn LegacySliceContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\treturn NestableAndGroupLegacyCodec(ctx).toContent(input)\n\t},\n\n\tfromContent(input) {\n\t\treturn NestableAndGroupLegacyCodec(ctx).fromContent(input)\n\t},\n})\n\n// Composite (2020 to 2021)\nexport const CompositeSliceLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<CompositeSliceContent, CompositeSliceLegacy> => ({\n\tname: \"CompositeSliceLegacy\",\n\n\tis(input): input is CompositeSliceContent {\n\t\treturn CompositeSliceContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\tconst parsed = CompositeSliceLegacySchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\treturn parsed\n\t\t}\n\n\t\tconst nonRepeat: CompositeSliceContent[\"nonRepeat\"] = {}\n\t\tfor (const [key, legacy] of Object.entries(parsed.data[\"non-repeat\"] || {})) {\n\t\t\tconst fieldCtx = getFieldCtx({\n\t\t\t\tfieldKey: key,\n\t\t\t\tctx,\n\t\t\t\tprefixes: [\"non-repeat\"],\n\t\t\t})\n\n\t\t\tconst result = NestableLegacyCodec(fieldCtx).toContent(legacy)\n\t\t\tif (!result.success) continue\n\n\t\t\tnonRepeat[key] = result.data\n\t\t}\n\n\t\tconst repeat: CompositeSliceContent[\"repeat\"] = []\n\t\tfor (let index = 0; index < (parsed.data.repeat?.length || 0); index++) {\n\t\t\tconst item = parsed.data.repeat?.[index]\n\t\t\tconst itemCtx = getFieldCtx({ fieldKey: \"repeat\", ctx })\n\n\t\t\tconst result = GroupItemLegacyCodec(itemCtx, index).toContent(item)\n\t\t\tif (!result.success) continue\n\n\t\t\trepeat.push(result.data)\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: {\n\t\t\t\t__TYPE__: CompositeSliceContentType,\n\t\t\t\tnonRepeat,\n\t\t\t\trepeat,\n\t\t\t},\n\t\t}\n\t},\n\n\tfromContent(input) {\n\t\tconst legacy: ReturnType<LegacyCodec<CompositeSliceContent, CompositeSliceLegacy>[\"fromContent\"]> = {\n\t\t\tcontent: {\n\t\t\t\t\"non-repeat\": {},\n\t\t\t\trepeat: [],\n\t\t\t},\n\t\t\ttypes: {\n\t\t\t\t[ctx.keyOfType]: \"Slice\",\n\t\t\t},\n\t\t\tkeys: {},\n\t\t}\n\n\t\t// Non-repeat\n\t\tfor (const [key, content] of Object.entries(input.nonRepeat)) {\n\t\t\tconst fieldCtx = getFieldCtx({\n\t\t\t\tfieldKey: key,\n\t\t\t\tctx,\n\t\t\t\tprefixes: [\"non-repeat\"],\n\t\t\t})\n\n\t\t\tconst result = NestableLegacyCodec(fieldCtx).fromContent(content)\n\t\t\tif (!result) continue\n\n\t\t\tlegacy.content[\"non-repeat\"]![key] = result.content\n\t\t\tlegacy.types = { ...legacy.types, ...result.types }\n\t\t\tlegacy.keys = { ...legacy.keys, ...result.keys }\n\t\t}\n\n\t\t// Repeat\n\t\tconst repeatCtx = getFieldCtx({ fieldKey: \"repeat\", ctx })\n\t\tfor (let index = 0; index < input.repeat.length; index++) {\n\t\t\tconst item = input.repeat[index]\n\t\t\tconst result = GroupItemLegacyCodec(repeatCtx, index).fromContent(item)\n\n\t\t\tlegacy.content.repeat!.push(result.content)\n\t\t\tlegacy.types = { ...legacy.types, ...result.types }\n\t\t\tlegacy.keys = { ...legacy.keys, ...result.keys }\n\t\t}\n\n\t\treturn legacy\n\t},\n})\n\n// Shared (2021 to present)\nexport const SharedSliceLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<SharedSliceContent, SharedSliceLegacy> => ({\n\tname: \"SharedSliceLegacy\",\n\n\tis(input): input is SharedSliceContent {\n\t\treturn SharedSliceContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\tconst parsed = SharedSliceLegacySchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\treturn parsed\n\t\t}\n\n\t\tconst primary: SharedSliceContent[\"primary\"] = {}\n\t\tfor (const [key, legacy] of Object.entries(parsed.data[\"primary\"])) {\n\t\t\tconst fieldCtx = getFieldCtx({\n\t\t\t\tfieldKey: key,\n\t\t\t\tctx,\n\t\t\t\tprefixes: [\"variations\", parsed.data.variation, \"primary\"],\n\t\t\t})\n\n\t\t\tconst result = NestableAndGroupLegacyCodec(fieldCtx).toContent(legacy)\n\t\t\tif (!result.success) continue\n\n\t\t\tprimary[key] = result.data\n\t\t}\n\n\t\tconst items: SharedSliceContent[\"items\"] = []\n\t\tfor (let index = 0; index < parsed.data.items.length; index++) {\n\t\t\tconst item = parsed.data.items[index]\n\t\t\tconst itemCtx = getFieldCtx({\n\t\t\t\tfieldKey: \"items\",\n\t\t\t\tctx,\n\t\t\t\tprefixes: [\"variations\", parsed.data.variation],\n\t\t\t})\n\n\t\t\tconst result = GroupItemLegacyCodec(itemCtx, index).toContent(item)\n\t\t\tif (!result.success) continue\n\n\t\t\titems.push(result.data)\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: {\n\t\t\t\t__TYPE__: SharedSliceContentType,\n\t\t\t\tvariation: parsed.data.variation,\n\t\t\t\tprimary,\n\t\t\t\titems,\n\t\t\t},\n\t\t}\n\t},\n\n\tfromContent(input) {\n\t\tconst legacy: ReturnType<LegacyCodec<SharedSliceContent, SharedSliceLegacy>[\"fromContent\"]> = {\n\t\t\tcontent: {\n\t\t\t\tprimary: {},\n\t\t\t\titems: [],\n\t\t\t\tvariation: input.variation,\n\t\t\t},\n\t\t\ttypes: {\n\t\t\t\t[ctx.keyOfType]: \"SharedSlice\",\n\t\t\t},\n\t\t\tkeys: {},\n\t\t}\n\n\t\t// Primary\n\t\tfor (const [key, content] of Object.entries(input.primary)) {\n\t\t\tconst fieldCtx = getFieldCtx({\n\t\t\t\tfieldKey: key,\n\t\t\t\tctx,\n\t\t\t\tprefixes: [\"variations\", input.variation, \"primary\"],\n\t\t\t})\n\n\t\t\tconst result = NestableAndGroupLegacyCodec(fieldCtx).fromContent(content)\n\t\t\tif (!result) continue\n\n\t\t\tlegacy.content.primary[key] = result.content\n\t\t\tlegacy.types = { ...legacy.types, ...result.types }\n\t\t\tlegacy.keys = { ...legacy.keys, ...result.keys }\n\t\t}\n\n\t\t// Items\n\t\tconst repeatCtx = getFieldCtx({\n\t\t\tfieldKey: \"items\",\n\t\t\tctx,\n\t\t\tprefixes: [\"variations\", input.variation],\n\t\t})\n\t\tfor (let index = 0; index < input.items.length; index++) {\n\t\t\tconst item = input.items[index]\n\t\t\tconst result = GroupItemLegacyCodec(repeatCtx, index).fromContent(item)\n\n\t\t\tlegacy.content.items.push(result.content)\n\t\t\tlegacy.types = { ...legacy.types, ...result.types }\n\t\t\tlegacy.keys = { ...legacy.keys, ...result.keys }\n\t\t}\n\n\t\treturn legacy\n\t},\n})\n\n// All\nexport const SliceLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<SliceContent, SliceLegacy, true> => ({\n\tname: \"SliceLegacy\",\n\n\tis(input): input is SliceContent {\n\t\treturn SliceContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\tswitch (ctx.fieldType) {\n\t\t\tcase \"Slice\":\n\t\t\t\treturn CompositeSliceLegacyCodec(ctx).toContent(input)\n\t\t\tcase \"SharedSlice\":\n\t\t\t\treturn SharedSliceLegacyCodec(ctx).toContent(input)\n\t\t\tdefault:\n\t\t\t\treturn LegacySliceLegacyCodec(ctx).toContent(input)\n\t\t}\n\t},\n\n\tfromContent(input) {\n\t\tswitch (input.__TYPE__) {\n\t\t\tcase CompositeSliceContentType:\n\t\t\t\treturn CompositeSliceLegacyCodec(ctx).fromContent(input)\n\t\t\tcase SharedSliceContentType:\n\t\t\t\treturn SharedSliceLegacyCodec(ctx).fromContent(input)\n\t\t\tdefault:\n\t\t\t\treturn LegacySliceLegacyCodec(ctx).fromContent(input)\n\t\t}\n\t},\n})\n"],"mappings":";;;;;;AA0BA,MAAa,0BACZ,SAC+D;CAC/D,MAAM;CAEN,GAAG,OAAoC;AACtC,SAAO,yBAAyB,UAAU,MAAM,CAAC;;CAGlD,UAAU,OAAO;AAChB,SAAO,4BAA4B,IAAI,CAAC,UAAU,MAAM;;CAGzD,YAAY,OAAO;AAClB,SAAO,4BAA4B,IAAI,CAAC,YAAY,MAAM;;CAE3D;AAGD,MAAa,6BACZ,SAC+D;CAC/D,MAAM;CAEN,GAAG,OAAuC;AACzC,SAAO,4BAA4B,UAAU,MAAM,CAAC;;CAGrD,UAAU,OAAO;EAChB,MAAM,SAAS,2BAA2B,UAAU,MAAM;AAC1D,MAAI,CAAC,OAAO,QACX,QAAO;EAGR,MAAM,YAAgD,EAAE;AACxD,OAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,OAAO,KAAK,iBAAiB,EAAE,CAAC,EAAE;GAO5E,MAAM,SAAS,oBANE,YAAY;IAC5B,UAAU;IACV;IACA,UAAU,CAAC,aAAa;IACxB,CAAC,CAE0C,CAAC,UAAU,OAAO;AAC9D,OAAI,CAAC,OAAO,QAAS;AAErB,aAAU,OAAO,OAAO;;EAGzB,MAAM,SAA0C,EAAE;AAClD,OAAK,IAAI,QAAQ,GAAG,SAAS,OAAO,KAAK,QAAQ,UAAU,IA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},
|
|
11
|
-
|
|
11
|
+
toContent(input) {
|
|
12
12
|
const parsed = SliceItemLegacySchema.safeParse(input);
|
|
13
13
|
if (!parsed.success) return parsed;
|
|
14
14
|
const sliceName = parsed.data.key.split("$")[0];
|
|
@@ -16,7 +16,7 @@ const SliceItemLegacyCodec = (ctx) => ({
|
|
|
16
16
|
fieldKey: sliceName,
|
|
17
17
|
contentKey: parsed.data.key,
|
|
18
18
|
ctx
|
|
19
|
-
})).
|
|
19
|
+
})).toContent(parsed.data.value);
|
|
20
20
|
if (!result.success) return result;
|
|
21
21
|
return {
|
|
22
22
|
success: true,
|
|
@@ -28,12 +28,12 @@ const SliceItemLegacyCodec = (ctx) => ({
|
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
},
|
|
31
|
-
|
|
31
|
+
fromContent(input) {
|
|
32
32
|
const result = SliceLegacyCodec(getFieldCtx({
|
|
33
33
|
fieldKey: input.name,
|
|
34
34
|
contentKey: input.key,
|
|
35
35
|
ctx
|
|
36
|
-
})).
|
|
36
|
+
})).fromContent(input.widget);
|
|
37
37
|
if (!result) return {
|
|
38
38
|
content: {
|
|
39
39
|
key: input.key,
|
|
@@ -59,13 +59,13 @@ const SlicesLegacyCodec = (ctx) => ({
|
|
|
59
59
|
is(input) {
|
|
60
60
|
return SlicesContentSchema.safeParse(input).success;
|
|
61
61
|
},
|
|
62
|
-
|
|
62
|
+
toContent(input) {
|
|
63
63
|
const parsed = SlicesLegacySchema.safeParse(input);
|
|
64
64
|
if (!parsed.success) return parsed;
|
|
65
65
|
const value = [];
|
|
66
66
|
for (let index = 0; index < parsed.data.length; index++) {
|
|
67
67
|
const item = parsed.data[index];
|
|
68
|
-
const result = SliceItemLegacyCodec(ctx).
|
|
68
|
+
const result = SliceItemLegacyCodec(ctx).toContent(item);
|
|
69
69
|
if (!result.success) return result;
|
|
70
70
|
value.push(result.data);
|
|
71
71
|
}
|
|
@@ -77,7 +77,7 @@ const SlicesLegacyCodec = (ctx) => ({
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
},
|
|
80
|
-
|
|
80
|
+
fromContent(input) {
|
|
81
81
|
const legacy = {
|
|
82
82
|
content: [],
|
|
83
83
|
types: { [ctx.keyOfType]: "Slices" },
|
|
@@ -85,7 +85,7 @@ const SlicesLegacyCodec = (ctx) => ({
|
|
|
85
85
|
};
|
|
86
86
|
for (let index = 0; index < input.value.length; index++) {
|
|
87
87
|
const item = input.value[index];
|
|
88
|
-
const result = SliceItemLegacyCodec(ctx).
|
|
88
|
+
const result = SliceItemLegacyCodec(ctx).fromContent(item);
|
|
89
89
|
if (!result) continue;
|
|
90
90
|
legacy.content.push(result.content);
|
|
91
91
|
legacy.types = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slices.js","names":[],"sources":["../../../src/content/codec/slices.ts"],"sourcesContent":["import { SliceItemLegacySchema, SlicesLegacySchema } from \"../legacy/slices\"\nimport type { SliceItemLegacy, SlicesLegacy } from \"../legacy/slices\"\nimport { SliceItemContentSchema, SlicesContentSchema, SlicesContentType } from \"../slices\"\nimport type { SliceItemContent, SlicesContent } from \"../slices\"\nimport { type LegacyContentCtx, type LegacyCodec, getFieldCtx } from \"./legacyContentCtx\"\nimport { SliceLegacyCodec } from \"./slice\"\n\n// Item\nexport const SliceItemLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<SliceItemContent, SliceItemLegacy> => ({\n\tname: \"SlicesItemLegacy\",\n\n\tis(input): input is SliceItemContent {\n\t\treturn SliceItemContentSchema.safeParse(input).success\n\t},\n\n\
|
|
1
|
+
{"version":3,"file":"slices.js","names":[],"sources":["../../../src/content/codec/slices.ts"],"sourcesContent":["import { SliceItemLegacySchema, SlicesLegacySchema } from \"../legacy/slices\"\nimport type { SliceItemLegacy, SlicesLegacy } from \"../legacy/slices\"\nimport { SliceItemContentSchema, SlicesContentSchema, SlicesContentType } from \"../slices\"\nimport type { SliceItemContent, SlicesContent } from \"../slices\"\nimport { type LegacyContentCtx, type LegacyCodec, getFieldCtx } from \"./legacyContentCtx\"\nimport { SliceLegacyCodec } from \"./slice\"\n\n// Item\nexport const SliceItemLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<SliceItemContent, SliceItemLegacy> => ({\n\tname: \"SlicesItemLegacy\",\n\n\tis(input): input is SliceItemContent {\n\t\treturn SliceItemContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\tconst parsed = SliceItemLegacySchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\treturn parsed\n\t\t}\n\n\t\tconst sliceName = parsed.data.key.split(\"$\")[0]\n\t\tconst itemCtx = getFieldCtx({\n\t\t\tfieldKey: sliceName,\n\t\t\tcontentKey: parsed.data.key,\n\t\t\tctx,\n\t\t})\n\t\tconst result = SliceLegacyCodec(itemCtx).toContent(parsed.data.value)\n\n\t\tif (!result.success) {\n\t\t\treturn result\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: {\n\t\t\t\tkey: parsed.data.key,\n\t\t\t\tname: sliceName,\n\t\t\t\tmaybeLabel: parsed.data.label || undefined,\n\t\t\t\twidget: result.data,\n\t\t\t},\n\t\t}\n\t},\n\n\tfromContent(input) {\n\t\tconst itemCtx = getFieldCtx({\n\t\t\tfieldKey: input.name,\n\t\t\tcontentKey: input.key,\n\t\t\tctx,\n\t\t})\n\t\tconst result = SliceLegacyCodec(itemCtx).fromContent(input.widget)\n\n\t\tif (!result) {\n\t\t\treturn {\n\t\t\t\tcontent: {\n\t\t\t\t\tkey: input.key,\n\t\t\t\t\tlabel: input.maybeLabel,\n\t\t\t\t\tvalue: {},\n\t\t\t\t},\n\t\t\t\ttypes: {},\n\t\t\t\tkeys: {},\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tcontent: {\n\t\t\t\tkey: input.key,\n\t\t\t\tlabel: input.maybeLabel,\n\t\t\t\tvalue: result.content,\n\t\t\t},\n\t\t\ttypes: result.types,\n\t\t\tkeys: result.keys,\n\t\t}\n\t},\n})\n\n// Slices\nexport const SlicesLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<SlicesContent, SlicesLegacy> => ({\n\tname: \"SlicesLegacy\",\n\n\tis(input): input is SlicesContent {\n\t\treturn SlicesContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\tconst parsed = SlicesLegacySchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\treturn parsed\n\t\t}\n\n\t\tconst value: SlicesContent[\"value\"] = []\n\t\tfor (let index = 0; index < parsed.data.length; index++) {\n\t\t\tconst item = parsed.data[index]\n\t\t\tconst result = SliceItemLegacyCodec(ctx).toContent(item)\n\t\t\tif (!result.success) {\n\t\t\t\treturn result\n\t\t\t}\n\t\t\tvalue.push(result.data)\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: { __TYPE__: SlicesContentType, value },\n\t\t}\n\t},\n\n\tfromContent(input) {\n\t\tconst legacy: ReturnType<LegacyCodec<SlicesContent, SlicesLegacy>[\"fromContent\"]> = {\n\t\t\tcontent: [],\n\t\t\ttypes: { [ctx.keyOfType]: \"Slices\" },\n\t\t\tkeys: {},\n\t\t}\n\n\t\tfor (let index = 0; index < input.value.length; index++) {\n\t\t\tconst item = input.value[index]\n\t\t\tconst result = SliceItemLegacyCodec(ctx).fromContent(item)\n\t\t\tif (!result) continue\n\n\t\t\tlegacy.content.push(result.content)\n\t\t\tlegacy.types = { ...legacy.types, ...result.types }\n\t\t\tlegacy.keys = { ...legacy.keys, ...result.keys }\n\t\t}\n\n\t\treturn legacy\n\t},\n})\n"],"mappings":";;;;;AAQA,MAAa,wBACZ,SACqD;CACrD,MAAM;CAEN,GAAG,OAAkC;AACpC,SAAO,uBAAuB,UAAU,MAAM,CAAC;;CAGhD,UAAU,OAAO;EAChB,MAAM,SAAS,sBAAsB,UAAU,MAAM;AACrD,MAAI,CAAC,OAAO,QACX,QAAO;EAGR,MAAM,YAAY,OAA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MAAM,SAA8E;GACnF,SAAS,EAAE;GACX,OAAO,GAAG,IAAI,YAAY,UAAU;GACpC,MAAM,EAAE;GACR;AAED,OAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,MAAM,QAAQ,SAAS;GACxD,MAAM,OAAO,MAAM,MAAM;GACzB,MAAM,SAAS,qBAAqB,IAAI,CAAC,YAAY,KAAK;AAC1D,OAAI,CAAC,OAAQ;AAEb,UAAO,QAAQ,KAAK,OAAO,QAAQ;AACnC,UAAO,QAAQ;IAAE,GAAG,OAAO;IAAO,GAAG,OAAO;IAAO;AACnD,UAAO,OAAO;IAAE,GAAG,OAAO;IAAM,GAAG,OAAO;IAAM;;AAGjD,SAAO;;CAER"}
|
|
@@ -8,7 +8,7 @@ const TableLegacyCodec = (ctx) => ({
|
|
|
8
8
|
is(input) {
|
|
9
9
|
return TableContentSchema.safeParse(input).success;
|
|
10
10
|
},
|
|
11
|
-
|
|
11
|
+
toContent(input) {
|
|
12
12
|
const parsed = TableLegacySchema.safeParse(input);
|
|
13
13
|
if (!parsed.success) return parsed;
|
|
14
14
|
return {
|
|
@@ -32,7 +32,7 @@ const TableLegacyCodec = (ctx) => ({
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
},
|
|
35
|
-
|
|
35
|
+
fromContent(input) {
|
|
36
36
|
return {
|
|
37
37
|
content: { content: input.content.map((row) => {
|
|
38
38
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","names":[],"sources":["../../../src/content/codec/table.ts"],"sourcesContent":["import { TableLegacySchema } from \"../legacy/table\"\nimport type { TableLegacy } from \"../legacy/table\"\nimport { RichTextContentType } from \"../richText\"\nimport { TableContentSchema, TableContentType } from \"../table\"\nimport type { TableContent } from \"../table\"\nimport type { LegacyContentCtx, LegacyCodec } from \"./legacyContentCtx\"\nimport { blockLegacyToValue, blockValueToLegacy } from \"./richText\"\n\nexport const TableLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<TableContent, TableLegacy> => ({\n\tname: \"TableLegacy\",\n\n\tis(input): input is TableContent {\n\t\treturn TableContentSchema.safeParse(input).success\n\t},\n\n\
|
|
1
|
+
{"version":3,"file":"table.js","names":[],"sources":["../../../src/content/codec/table.ts"],"sourcesContent":["import { TableLegacySchema } from \"../legacy/table\"\nimport type { TableLegacy } from \"../legacy/table\"\nimport { RichTextContentType } from \"../richText\"\nimport { TableContentSchema, TableContentType } from \"../table\"\nimport type { TableContent } from \"../table\"\nimport type { LegacyContentCtx, LegacyCodec } from \"./legacyContentCtx\"\nimport { blockLegacyToValue, blockValueToLegacy } from \"./richText\"\n\nexport const TableLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<TableContent, TableLegacy> => ({\n\tname: \"TableLegacy\",\n\n\tis(input): input is TableContent {\n\t\treturn TableContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\tconst parsed = TableLegacySchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\treturn parsed\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: {\n\t\t\t\t__TYPE__: TableContentType,\n\t\t\t\tcontent: parsed.data.content.map((row) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...row,\n\t\t\t\t\t\tcontent: row.content.map((cell) => {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t...cell,\n\t\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t\t__TYPE__: RichTextContentType,\n\t\t\t\t\t\t\t\t\tvalue: cell.content.map((block) => blockLegacyToValue(block)),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t},\n\t\t}\n\t},\n\n\tfromContent(input) {\n\t\treturn {\n\t\t\tcontent: {\n\t\t\t\tcontent: input.content.map((row) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...row,\n\t\t\t\t\t\tcontent: row.content.map((cell) => {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t...cell,\n\t\t\t\t\t\t\t\tcontent: cell.content.value.map((block) => blockValueToLegacy(block)),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t},\n\t\t\ttypes: { [ctx.keyOfType]: \"Table\" },\n\t\t\tkeys: {},\n\t\t}\n\t},\n})\n"],"mappings":";;;;;AAQA,MAAa,oBACZ,SAC6C;CAC7C,MAAM;CAEN,GAAG,OAA8B;AAChC,SAAO,mBAAmB,UAAU,MAAM,CAAC;;CAG5C,UAAU,OAAO;EAChB,MAAM,SAAS,kBAAkB,UAAU,MAAM;AACjD,MAAI,CAAC,OAAO,QACX,QAAO;AAGR,SAAO;GACN,SAAS;GACT,MAAM;IACL,UAAU;IACV,SAAS,OAAO,KAAK,QAAQ,KAAK,QAAQ;AACzC,YAAO;MACN,GAAG;MACH,SAAS,IAAI,QAAQ,KAAK,SAAS;AAClC,cAAO;QACN,GAAG;QACH,SAAS;SACR,UAAU;SACV,OAAO,KAAK,QAAQ,KAAK,UAAU,mBAAmB,MAAM,CAAC;SAC7D;QACD;QACA;MACF;MACA;IACF;GACD;;CAGF,YAAY,OAAO;AAClB,SAAO;GACN,SAAS,EACR,SAAS,MAAM,QAAQ,KAAK,QAAQ;AACnC,WAAO;KACN,GAAG;KACH,SAAS,IAAI,QAAQ,KAAK,SAAS;AAClC,aAAO;OACN,GAAG;OACH,SAAS,KAAK,QAAQ,MAAM,KAAK,UAAU,mBAAmB,MAAM,CAAC;OACrE;OACA;KACF;KACA,EACF;GACD,OAAO,GAAG,IAAI,YAAY,SAAS;GACnC,MAAM,EAAE;GACR;;CAEF"}
|
|
@@ -6,7 +6,7 @@ const UIDLegacyCodec = (ctx) => ({
|
|
|
6
6
|
is(input) {
|
|
7
7
|
return UIDContentSchema.safeParse(input).success;
|
|
8
8
|
},
|
|
9
|
-
|
|
9
|
+
toContent(input) {
|
|
10
10
|
const parsed = UIDLegacySchema.safeParse(input);
|
|
11
11
|
if (!parsed.success) return parsed;
|
|
12
12
|
return {
|
|
@@ -17,7 +17,7 @@ const UIDLegacyCodec = (ctx) => ({
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
},
|
|
20
|
-
|
|
20
|
+
fromContent(input) {
|
|
21
21
|
return {
|
|
22
22
|
content: input.value,
|
|
23
23
|
types: { [ctx.keyOfType]: "UID" },
|