@prismicio/types-internal 3.17.0 → 4.0.0-canary.3fe5f1e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -20
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/common/asset.d.ts +22 -0
- package/dist/common/asset.d.ts.map +1 -0
- package/dist/common/asset.js +21 -0
- package/dist/common/asset.js.map +1 -0
- package/dist/common/embed.d.ts +21 -0
- package/dist/common/embed.d.ts.map +1 -0
- package/dist/common/embed.js +20 -0
- package/dist/common/embed.js.map +1 -0
- package/dist/common/hexaColorCode.d.ts +8 -0
- package/dist/common/hexaColorCode.d.ts.map +1 -0
- package/dist/common/hexaColorCode.js +8 -0
- package/dist/common/hexaColorCode.js.map +1 -0
- package/dist/common/nonEmptyString.d.ts +8 -0
- package/dist/common/nonEmptyString.d.ts.map +1 -0
- package/dist/common/nonEmptyString.js +7 -0
- package/dist/common/nonEmptyString.js.map +1 -0
- package/dist/common/widgetKey.d.ts +8 -0
- package/dist/common/widgetKey.d.ts.map +1 -0
- package/dist/common/widgetKey.js +8 -0
- package/dist/common/widgetKey.js.map +1 -0
- package/dist/content/boolean.d.ts +11 -0
- package/dist/content/boolean.d.ts.map +1 -0
- package/dist/content/boolean.js +11 -0
- package/dist/content/boolean.js.map +1 -0
- package/dist/content/codec/boolean.js +31 -0
- package/dist/content/codec/boolean.js.map +1 -0
- package/dist/content/codec/document.js +49 -0
- package/dist/content/codec/document.js.map +1 -0
- package/dist/content/codec/embed.js +42 -0
- package/dist/content/codec/embed.js.map +1 -0
- package/dist/content/codec/empty.js +35 -0
- package/dist/content/codec/empty.js.map +1 -0
- package/dist/content/codec/field.js +41 -0
- package/dist/content/codec/field.js.map +1 -0
- package/dist/content/codec/geopoint.js +32 -0
- package/dist/content/codec/geopoint.js.map +1 -0
- package/dist/content/codec/group.js +127 -0
- package/dist/content/codec/group.js.map +1 -0
- package/dist/content/codec/image.js +44 -0
- package/dist/content/codec/image.js.map +1 -0
- package/dist/content/codec/integrationField.js +31 -0
- package/dist/content/codec/integrationField.js.map +1 -0
- package/dist/content/codec/legacyContentCtx.d.ts +50 -0
- package/dist/content/codec/legacyContentCtx.d.ts.map +1 -0
- package/dist/content/codec/legacyContentCtx.js +68 -0
- package/dist/content/codec/legacyContentCtx.js.map +1 -0
- package/dist/content/codec/link.js +93 -0
- package/dist/content/codec/link.js.map +1 -0
- package/dist/content/codec/nestable.js +91 -0
- package/dist/content/codec/nestable.js.map +1 -0
- package/dist/content/codec/repeatable.js +56 -0
- package/dist/content/codec/repeatable.js.map +1 -0
- package/dist/content/codec/richText.js +87 -0
- package/dist/content/codec/richText.js.map +1 -0
- package/dist/content/codec/separator.js +26 -0
- package/dist/content/codec/separator.js.map +1 -0
- package/dist/content/codec/slice.js +220 -0
- package/dist/content/codec/slice.js.map +1 -0
- package/dist/content/codec/slices.js +106 -0
- package/dist/content/codec/slices.js.map +1 -0
- package/dist/content/codec/table.js +56 -0
- package/dist/content/codec/table.js.map +1 -0
- package/dist/content/codec/uid.js +31 -0
- package/dist/content/codec/uid.js.map +1 -0
- package/dist/content/codec/widget.js +39 -0
- package/dist/content/codec/widget.js.map +1 -0
- package/dist/content/document.d.ts +9 -0
- package/dist/content/document.d.ts.map +1 -0
- package/dist/content/document.js +9 -0
- package/dist/content/document.js.map +1 -0
- package/dist/content/embed.d.ts +24 -0
- package/dist/content/embed.d.ts.map +1 -0
- package/dist/content/embed.js +12 -0
- package/dist/content/embed.js.map +1 -0
- package/dist/content/empty.d.ts +11 -0
- package/dist/content/empty.d.ts.map +1 -0
- package/dist/content/empty.js +11 -0
- package/dist/content/empty.js.map +1 -0
- package/dist/content/field.d.ts +49 -0
- package/dist/content/field.d.ts.map +1 -0
- package/dist/content/field.js +52 -0
- package/dist/content/field.js.map +1 -0
- package/dist/content/geopoint.d.ts +14 -0
- package/dist/content/geopoint.d.ts.map +1 -0
- package/dist/content/geopoint.js +9 -0
- package/dist/content/geopoint.js.map +1 -0
- package/dist/content/group.d.ts +19 -0
- package/dist/content/group.d.ts.map +1 -0
- package/dist/content/group.js +19 -0
- package/dist/content/group.js.map +1 -0
- package/dist/content/image.d.ts +52 -0
- package/dist/content/image.d.ts.map +1 -0
- package/dist/content/image.js +10 -0
- package/dist/content/image.js.map +1 -0
- package/dist/content/integrationField.d.ts +11 -0
- package/dist/content/integrationField.d.ts.map +1 -0
- package/dist/content/integrationField.js +11 -0
- package/dist/content/integrationField.js.map +1 -0
- package/dist/content/legacy/boolean.d.ts +1 -0
- package/dist/content/legacy/boolean.js +7 -0
- package/dist/content/legacy/boolean.js.map +1 -0
- package/dist/content/legacy/document.d.ts +8 -0
- package/dist/content/legacy/document.d.ts.map +1 -0
- package/dist/content/legacy/document.js +15 -0
- package/dist/content/legacy/document.js.map +1 -0
- package/dist/content/legacy/embed.d.ts +1 -0
- package/dist/content/legacy/embed.js +23 -0
- package/dist/content/legacy/embed.js.map +1 -0
- package/dist/content/legacy/empty.d.ts +1 -0
- package/dist/content/legacy/empty.js +7 -0
- package/dist/content/legacy/empty.js.map +1 -0
- package/dist/content/legacy/field.d.ts +1 -0
- package/dist/content/legacy/field.js +7 -0
- package/dist/content/legacy/field.js.map +1 -0
- package/dist/content/legacy/geopoint.d.ts +1 -0
- package/dist/content/legacy/geopoint.js +10 -0
- package/dist/content/legacy/geopoint.js.map +1 -0
- package/dist/content/legacy/group.d.ts +9 -0
- package/dist/content/legacy/group.d.ts.map +1 -0
- package/dist/content/legacy/group.js +10 -0
- package/dist/content/legacy/group.js.map +1 -0
- package/dist/content/legacy/image.d.ts +1 -0
- package/dist/content/legacy/image.js +33 -0
- package/dist/content/legacy/image.js.map +1 -0
- package/dist/content/legacy/integrationField.d.ts +1 -0
- package/dist/content/legacy/integrationField.js +7 -0
- package/dist/content/legacy/integrationField.js.map +1 -0
- package/dist/content/legacy/link.d.ts +41 -0
- package/dist/content/legacy/link.d.ts.map +1 -0
- package/dist/content/legacy/link.js +88 -0
- package/dist/content/legacy/link.js.map +1 -0
- package/dist/content/legacy/nestable.d.ts +1 -0
- package/dist/content/legacy/nestable.js +32 -0
- package/dist/content/legacy/nestable.js.map +1 -0
- package/dist/content/legacy/repeatable.d.ts +1 -0
- package/dist/content/legacy/repeatable.js +7 -0
- package/dist/content/legacy/repeatable.js.map +1 -0
- package/dist/content/legacy/richText.d.ts +109 -0
- package/dist/content/legacy/richText.d.ts.map +1 -0
- package/dist/content/legacy/richText.js +100 -0
- package/dist/content/legacy/richText.js.map +1 -0
- package/dist/content/legacy/separator.d.ts +1 -0
- package/dist/content/legacy/separator.js +7 -0
- package/dist/content/legacy/separator.js.map +1 -0
- package/dist/content/legacy/slice.js +22 -0
- package/dist/content/legacy/slice.js.map +1 -0
- package/dist/content/legacy/slices.js +13 -0
- package/dist/content/legacy/slices.js.map +1 -0
- package/dist/content/legacy/table.d.ts +1 -0
- package/dist/content/legacy/table.js +19 -0
- package/dist/content/legacy/table.js.map +1 -0
- package/dist/content/legacy/uid.js +7 -0
- package/dist/content/legacy/uid.js.map +1 -0
- package/dist/content/link.d.ts +163 -0
- package/dist/content/link.d.ts.map +1 -0
- package/dist/content/link.js +50 -0
- package/dist/content/link.js.map +1 -0
- package/dist/content/nestable.d.ts +19 -0
- package/dist/content/nestable.d.ts.map +1 -0
- package/dist/content/nestable.js +56 -0
- package/dist/content/nestable.js.map +1 -0
- package/dist/content/repeatable.d.ts +97 -0
- package/dist/content/repeatable.d.ts.map +1 -0
- package/dist/content/repeatable.js +17 -0
- package/dist/content/repeatable.js.map +1 -0
- package/dist/content/richText.d.ts +91 -0
- package/dist/content/richText.d.ts.map +1 -0
- package/dist/content/richText.js +24 -0
- package/dist/content/richText.js.map +1 -0
- package/dist/content/separator.d.ts +10 -0
- package/dist/content/separator.d.ts.map +1 -0
- package/dist/content/separator.js +8 -0
- package/dist/content/separator.js.map +1 -0
- package/dist/content/slice.d.ts +24 -0
- package/dist/content/slice.d.ts.map +1 -0
- package/dist/content/slice.js +27 -0
- package/dist/content/slice.js.map +1 -0
- package/dist/content/slices.d.ts +56 -0
- package/dist/content/slices.d.ts.map +1 -0
- package/dist/content/slices.js +24 -0
- package/dist/content/slices.js.map +1 -0
- package/dist/content/table.d.ts +21 -0
- package/dist/content/table.d.ts.map +1 -0
- package/dist/content/table.js +13 -0
- package/dist/content/table.js.map +1 -0
- package/dist/content/uid.d.ts +11 -0
- package/dist/content/uid.d.ts.map +1 -0
- package/dist/content/uid.js +11 -0
- package/dist/content/uid.js.map +1 -0
- package/dist/content/widget.d.ts +11 -0
- package/dist/content/widget.d.ts.map +1 -0
- package/dist/content/widget.js +16 -0
- package/dist/content/widget.js.map +1 -0
- 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 +15 -0
- package/dist/helpers/customTypeModel.d.ts.map +1 -0
- package/dist/helpers/customTypeModel.js +85 -0
- package/dist/helpers/customTypeModel.js.map +1 -0
- package/dist/helpers/documentContent.d.ts +20 -0
- package/dist/helpers/documentContent.d.ts.map +1 -0
- package/dist/helpers/documentContent.js +64 -0
- package/dist/helpers/documentContent.js.map +1 -0
- package/dist/helpers/sliceContent.d.ts +12 -0
- package/dist/helpers/sliceContent.d.ts.map +1 -0
- package/dist/helpers/sliceContent.js +60 -0
- package/dist/helpers/sliceContent.js.map +1 -0
- package/dist/helpers/traverseContent.d.ts +84 -0
- package/dist/helpers/traverseContent.d.ts.map +1 -0
- package/dist/helpers/traverseContent.js +374 -0
- package/dist/helpers/traverseContent.js.map +1 -0
- package/dist/helpers/traverseContentWithModel.d.ts +84 -0
- package/dist/helpers/traverseContentWithModel.d.ts.map +1 -0
- package/dist/helpers/traverseContentWithModel.js +388 -0
- package/dist/helpers/traverseContentWithModel.js.map +1 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +9 -0
- package/dist/io-ts.d.ts +4363 -0
- package/dist/io-ts.d.ts.map +1 -0
- package/dist/io-ts.js +220 -0
- package/dist/io-ts.js.map +1 -0
- package/dist/model/boolean.d.ts +16 -0
- package/dist/model/boolean.d.ts.map +1 -0
- package/dist/model/boolean.js +16 -0
- package/dist/model/boolean.js.map +1 -0
- package/dist/model/color.d.ts +15 -0
- package/dist/model/color.d.ts.map +1 -0
- package/dist/model/color.js +15 -0
- package/dist/model/color.js.map +1 -0
- package/dist/model/customType.d.ts +31 -0
- package/dist/model/customType.d.ts.map +1 -0
- package/dist/model/customType.js +18 -0
- package/dist/model/customType.js.map +1 -0
- package/dist/model/date.d.ts +16 -0
- package/dist/model/date.d.ts.map +1 -0
- package/dist/model/date.js +16 -0
- package/dist/model/date.js.map +1 -0
- package/dist/model/embed.d.ts +16 -0
- package/dist/model/embed.d.ts.map +1 -0
- package/dist/model/embed.js +16 -0
- package/dist/model/embed.js.map +1 -0
- package/dist/model/geopoint.d.ts +14 -0
- package/dist/model/geopoint.d.ts.map +1 -0
- package/dist/model/geopoint.js +12 -0
- package/dist/model/geopoint.js.map +1 -0
- package/dist/model/group.d.ts +567 -0
- package/dist/model/group.d.ts.map +1 -0
- package/dist/model/group.js +23 -0
- package/dist/model/group.js.map +1 -0
- package/dist/model/image.d.ts +24 -0
- package/dist/model/image.d.ts.map +1 -0
- package/dist/model/image.js +41 -0
- package/dist/model/image.js.map +1 -0
- package/dist/model/integrationField.d.ts +16 -0
- package/dist/model/integrationField.d.ts.map +1 -0
- package/dist/model/integrationField.js +16 -0
- package/dist/model/integrationField.js.map +1 -0
- package/dist/model/link.d.ts +48 -0
- package/dist/model/link.d.ts.map +1 -0
- package/dist/model/link.js +94 -0
- package/dist/model/link.js.map +1 -0
- package/dist/model/nestable.d.ts +23 -0
- package/dist/model/nestable.d.ts.map +1 -0
- package/dist/model/nestable.js +40 -0
- package/dist/model/nestable.js.map +1 -0
- package/dist/model/number.d.ts +18 -0
- package/dist/model/number.d.ts.map +1 -0
- package/dist/model/number.js +19 -0
- package/dist/model/number.js.map +1 -0
- package/dist/model/range.d.ts +18 -0
- package/dist/model/range.d.ts.map +1 -0
- package/dist/model/range.js +19 -0
- package/dist/model/range.js.map +1 -0
- package/dist/model/richText.d.ts +24 -0
- package/dist/model/richText.d.ts.map +1 -0
- package/dist/model/richText.js +73 -0
- package/dist/model/richText.js.map +1 -0
- package/dist/model/section.d.ts +11 -0
- package/dist/model/section.d.ts.map +1 -0
- package/dist/model/section.js +10 -0
- package/dist/model/section.js.map +1 -0
- package/dist/model/select.d.ts +17 -0
- package/dist/model/select.d.ts.map +1 -0
- package/dist/model/select.js +22 -0
- package/dist/model/select.js.map +1 -0
- package/dist/model/separator.d.ts +13 -0
- package/dist/model/separator.d.ts.map +1 -0
- package/dist/model/separator.js +11 -0
- package/dist/model/separator.js.map +1 -0
- package/dist/model/slice.d.ts +1476 -0
- package/dist/model/slice.d.ts.map +1 -0
- package/dist/model/slice.js +68 -0
- package/dist/model/slice.js.map +1 -0
- package/dist/model/slices.d.ts +33 -0
- package/dist/model/slices.d.ts.map +1 -0
- package/dist/model/slices.js +29 -0
- package/dist/model/slices.js.map +1 -0
- package/dist/model/table.d.ts +14 -0
- package/dist/model/table.d.ts.map +1 -0
- package/dist/model/table.js +22 -0
- package/dist/model/table.js.map +1 -0
- package/dist/model/text.d.ts +16 -0
- package/dist/model/text.d.ts.map +1 -0
- package/dist/model/text.js +16 -0
- package/dist/model/text.js.map +1 -0
- package/dist/model/timestamp.d.ts +16 -0
- package/dist/model/timestamp.d.ts.map +1 -0
- package/dist/model/timestamp.js +16 -0
- package/dist/model/timestamp.js.map +1 -0
- package/dist/model/uid.d.ts +16 -0
- package/dist/model/uid.d.ts.map +1 -0
- package/dist/model/uid.js +16 -0
- package/dist/model/uid.js.map +1 -0
- package/dist/model/widget.d.ts +60 -0
- package/dist/model/widget.d.ts.map +1 -0
- package/dist/model/widget.js +47 -0
- package/dist/model/widget.js.map +1 -0
- package/dist/zod4.d.ts +2321 -0
- package/dist/zod4.d.ts.map +1 -0
- package/dist/zod4.js +132 -0
- package/dist/zod4.js.map +1 -0
- package/package.json +55 -58
- package/src/common/asset.ts +29 -0
- package/src/common/embed.ts +27 -0
- package/src/common/hexaColorCode.ts +11 -0
- package/src/common/nonEmptyString.ts +9 -0
- package/src/common/widgetKey.ts +11 -0
- package/src/content/boolean.ts +23 -0
- package/src/content/codec/boolean.ts +38 -0
- package/src/content/codec/document.ts +60 -0
- package/src/content/codec/embed.ts +55 -0
- package/src/content/codec/empty.ts +49 -0
- package/src/content/codec/field.ts +96 -0
- package/src/content/codec/geopoint.ts +40 -0
- package/src/content/codec/group.ts +163 -0
- package/src/content/codec/image.ts +50 -0
- package/src/content/codec/integrationField.ts +38 -0
- package/src/content/{LegacyContentCtx.ts → codec/legacyContentCtx.ts} +17 -17
- package/src/content/codec/link.ts +103 -0
- package/src/content/codec/nestable.ts +146 -0
- package/src/content/codec/repeatable.ts +68 -0
- package/src/content/codec/richText.ts +117 -0
- package/src/content/codec/separator.ts +33 -0
- package/src/content/codec/slice.ts +276 -0
- package/src/content/codec/slices.ts +130 -0
- package/src/content/codec/table.ts +65 -0
- package/src/content/codec/uid.ts +36 -0
- package/src/content/codec/widget.ts +58 -0
- package/src/content/document.ts +8 -0
- package/src/content/embed.ts +12 -0
- package/src/content/empty.ts +10 -0
- package/src/content/field.ts +94 -0
- package/src/content/geopoint.ts +11 -0
- package/src/content/group.ts +99 -0
- package/src/content/image.ts +103 -0
- package/src/content/integrationField.ts +10 -0
- package/src/content/legacy/boolean.ts +5 -0
- package/src/content/legacy/document.ts +25 -0
- package/src/content/legacy/embed.ts +23 -0
- package/src/content/legacy/empty.ts +10 -0
- package/src/content/legacy/field.ts +8 -0
- package/src/content/legacy/geopoint.ts +10 -0
- package/src/content/legacy/group.ts +23 -0
- package/src/content/legacy/image.ts +43 -0
- package/src/content/legacy/integrationField.ts +5 -0
- package/src/content/legacy/link.ts +194 -0
- package/src/content/legacy/nestable.ts +55 -0
- package/src/content/legacy/repeatable.ts +7 -0
- package/src/content/legacy/richText.ts +198 -0
- package/src/content/legacy/separator.ts +6 -0
- package/src/content/legacy/slice.ts +38 -0
- package/src/content/legacy/slices.ts +17 -0
- package/src/content/legacy/table.ts +39 -0
- package/src/content/legacy/uid.ts +6 -0
- package/src/content/legacy/widget.ts +19 -0
- package/src/content/link.ts +154 -0
- package/src/content/nestable.ts +126 -0
- package/src/content/repeatable.ts +21 -0
- package/src/content/richText.ts +54 -0
- package/src/content/separator.ts +9 -0
- package/src/content/slice.ts +41 -0
- package/src/content/slices.ts +57 -0
- package/src/content/table.ts +14 -0
- package/src/content/uid.ts +10 -0
- package/src/content/widget.ts +21 -0
- package/src/content/{fields/withDefaultValues.ts → withDefaultValues.ts} +34 -39
- package/src/helpers/contentPath.ts +35 -0
- package/src/helpers/customTypeModel.ts +113 -0
- package/src/helpers/documentContent.ts +108 -0
- package/src/helpers/sliceContent.ts +86 -0
- package/src/helpers/traverseContent.ts +594 -0
- package/src/helpers/traverseContentWithModel.ts +616 -0
- package/src/index.ts +123 -0
- package/src/io-ts.ts +351 -0
- package/src/model/boolean.ts +15 -0
- package/src/model/color.ts +14 -0
- package/src/model/customType.ts +26 -0
- package/src/model/date.ts +15 -0
- package/src/model/diff/index.ts +4 -0
- package/src/{customtypes/diff/SharedSlice.ts → model/diff/sharedSlice.ts} +16 -18
- package/src/model/diff/utils.ts +45 -0
- package/src/model/diff/variation.ts +155 -0
- package/src/model/diff/widgets.ts +15 -0
- package/src/model/embed.ts +15 -0
- package/src/model/geopoint.ts +13 -0
- package/src/model/group.ts +39 -0
- package/src/model/image.ts +54 -0
- package/src/model/integrationField.ts +15 -0
- package/src/model/link.ts +141 -0
- package/src/model/nestable.ts +71 -0
- package/src/model/number.ts +26 -0
- package/src/model/range.ts +26 -0
- package/src/model/richText.ts +106 -0
- package/src/model/section.ts +12 -0
- package/src/model/select.ts +30 -0
- package/src/model/separator.ts +12 -0
- package/src/model/slice.ts +133 -0
- package/src/model/slices.ts +54 -0
- package/src/model/table.ts +29 -0
- package/src/model/text.ts +15 -0
- package/src/model/timestamp.ts +15 -0
- package/src/model/uid.ts +15 -0
- package/src/model/widget.ts +63 -0
- package/src/zod4.ts +187 -0
- package/lib/common/Asset.d.ts +0 -16
- package/lib/common/Asset.js +0 -11
- package/lib/common/Embed.d.ts +0 -15
- package/lib/common/Embed.js +0 -10
- package/lib/common/HexaColorCode.d.ts +0 -4
- package/lib/common/HexaColorCode.js +0 -7
- package/lib/common/UUID.d.ts +0 -6
- package/lib/common/UUID.js +0 -8
- package/lib/common/WidgetKey.d.ts +0 -3
- package/lib/common/WidgetKey.js +0 -8
- package/lib/common/index.d.ts +0 -3
- package/lib/common/index.js +0 -6
- package/lib/content/Document.d.ts +0 -11813
- package/lib/content/Document.js +0 -364
- package/lib/content/LegacyContentCtx.d.ts +0 -64
- package/lib/content/LegacyContentCtx.js +0 -130
- package/lib/content/fields/EmptyContent.d.ts +0 -16
- package/lib/content/fields/EmptyContent.js +0 -30
- package/lib/content/fields/GroupContent.d.ts +0 -53
- package/lib/content/fields/GroupContent.js +0 -307
- package/lib/content/fields/UIDContent.d.ts +0 -16
- package/lib/content/fields/UIDContent.js +0 -25
- package/lib/content/fields/WidgetContent.d.ts +0 -11749
- package/lib/content/fields/WidgetContent.js +0 -57
- package/lib/content/fields/index.d.ts +0 -6
- package/lib/content/fields/index.js +0 -9
- package/lib/content/fields/nestable/BooleanContent.d.ts +0 -18
- package/lib/content/fields/nestable/BooleanContent.js +0 -35
- package/lib/content/fields/nestable/EmbedContent.d.ts +0 -78
- package/lib/content/fields/nestable/EmbedContent.js +0 -56
- package/lib/content/fields/nestable/FieldContent/ColorContent.d.ts +0 -18
- package/lib/content/fields/nestable/FieldContent/ColorContent.js +0 -35
- package/lib/content/fields/nestable/FieldContent/DateContent.d.ts +0 -18
- package/lib/content/fields/nestable/FieldContent/DateContent.js +0 -35
- package/lib/content/fields/nestable/FieldContent/NumberContent.d.ts +0 -18
- package/lib/content/fields/nestable/FieldContent/NumberContent.js +0 -35
- package/lib/content/fields/nestable/FieldContent/RangeContent.d.ts +0 -18
- package/lib/content/fields/nestable/FieldContent/RangeContent.js +0 -35
- package/lib/content/fields/nestable/FieldContent/SelectContent.d.ts +0 -20
- package/lib/content/fields/nestable/FieldContent/SelectContent.js +0 -46
- package/lib/content/fields/nestable/FieldContent/TextContent.d.ts +0 -18
- package/lib/content/fields/nestable/FieldContent/TextContent.js +0 -35
- package/lib/content/fields/nestable/FieldContent/TimestampContent.d.ts +0 -18
- package/lib/content/fields/nestable/FieldContent/TimestampContent.js +0 -35
- package/lib/content/fields/nestable/FieldContent/common.d.ts +0 -1
- package/lib/content/fields/nestable/FieldContent/common.js +0 -4
- package/lib/content/fields/nestable/FieldContent/index.d.ts +0 -49
- package/lib/content/fields/nestable/FieldContent/index.js +0 -38
- package/lib/content/fields/nestable/GeoPointContent.d.ts +0 -33
- package/lib/content/fields/nestable/GeoPointContent.js +0 -31
- package/lib/content/fields/nestable/ImageContent.d.ts +0 -252
- package/lib/content/fields/nestable/ImageContent.js +0 -122
- package/lib/content/fields/nestable/IntegrationFieldContent.d.ts +0 -16
- package/lib/content/fields/nestable/IntegrationFieldContent.js +0 -28
- package/lib/content/fields/nestable/LinkContent.d.ts +0 -919
- package/lib/content/fields/nestable/LinkContent.js +0 -399
- package/lib/content/fields/nestable/NestableContent.d.ts +0 -1953
- package/lib/content/fields/nestable/NestableContent.js +0 -167
- package/lib/content/fields/nestable/RepeatableContent.d.ts +0 -182
- package/lib/content/fields/nestable/RepeatableContent.js +0 -146
- package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +0 -1261
- package/lib/content/fields/nestable/RichTextContent/Blocks.js +0 -170
- package/lib/content/fields/nestable/RichTextContent/index.d.ts +0 -1004
- package/lib/content/fields/nestable/RichTextContent/index.js +0 -28
- package/lib/content/fields/nestable/SeparatorContent.d.ts +0 -13
- package/lib/content/fields/nestable/SeparatorContent.js +0 -22
- package/lib/content/fields/nestable/TableContent.d.ts +0 -776
- package/lib/content/fields/nestable/TableContent.js +0 -167
- package/lib/content/fields/nestable/index.d.ts +0 -12
- package/lib/content/fields/nestable/index.js +0 -15
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +0 -3934
- package/lib/content/fields/slices/Slice/CompositeSliceContent.js +0 -195
- package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +0 -774
- package/lib/content/fields/slices/Slice/RepeatableContent.js +0 -21
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +0 -3937
- package/lib/content/fields/slices/Slice/SharedSliceContent.js +0 -215
- package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +0 -1962
- package/lib/content/fields/slices/Slice/SimpleSliceContent.js +0 -130
- package/lib/content/fields/slices/Slice/SlicePrimaryContent.d.ts +0 -1952
- package/lib/content/fields/slices/Slice/SlicePrimaryContent.js +0 -30
- package/lib/content/fields/slices/Slice/index.d.ts +0 -6810
- package/lib/content/fields/slices/Slice/index.js +0 -45
- package/lib/content/fields/slices/SliceItem.d.ts +0 -6846
- package/lib/content/fields/slices/SliceItem.js +0 -116
- package/lib/content/fields/slices/SlicesContent.d.ts +0 -9827
- package/lib/content/fields/slices/SlicesContent.js +0 -465
- package/lib/content/fields/slices/index.d.ts +0 -3
- package/lib/content/fields/slices/index.js +0 -6
- package/lib/content/fields/withDefaultValues.d.ts +0 -9
- package/lib/content/fields/withDefaultValues.js +0 -79
- package/lib/content/helpers.d.ts +0 -9
- package/lib/content/helpers.js +0 -22
- package/lib/content/index.d.ts +0 -4
- package/lib/content/index.js +0 -7
- package/lib/content/utils.d.ts +0 -50
- package/lib/content/utils.js +0 -35
- package/lib/customtypes/CustomType.d.ts +0 -3680
- package/lib/customtypes/CustomType.js +0 -184
- package/lib/customtypes/Section.d.ts +0 -3635
- package/lib/customtypes/Section.js +0 -66
- package/lib/customtypes/diff/Changes.d.ts +0 -17
- package/lib/customtypes/diff/Changes.js +0 -9
- package/lib/customtypes/diff/SharedSlice.d.ts +0 -1624
- package/lib/customtypes/diff/SharedSlice.js +0 -55
- package/lib/customtypes/diff/Variation.d.ts +0 -1605
- package/lib/customtypes/diff/Variation.js +0 -113
- package/lib/customtypes/diff/Widgets.d.ts +0 -11
- package/lib/customtypes/diff/Widgets.js +0 -2
- package/lib/customtypes/diff/index.d.ts +0 -4
- package/lib/customtypes/diff/index.js +0 -7
- package/lib/customtypes/index.d.ts +0 -4
- package/lib/customtypes/index.js +0 -7
- package/lib/customtypes/widgets/Group.d.ts +0 -1352
- package/lib/customtypes/widgets/Group.js +0 -92
- package/lib/customtypes/widgets/UID.d.ts +0 -19
- package/lib/customtypes/widgets/UID.js +0 -21
- package/lib/customtypes/widgets/Widget.d.ts +0 -4457
- package/lib/customtypes/widgets/Widget.js +0 -49
- package/lib/customtypes/widgets/index.d.ts +0 -6
- package/lib/customtypes/widgets/index.js +0 -9
- package/lib/customtypes/widgets/nestable/BooleanField.d.ts +0 -20
- package/lib/customtypes/widgets/nestable/BooleanField.js +0 -21
- package/lib/customtypes/widgets/nestable/Color.d.ts +0 -17
- package/lib/customtypes/widgets/nestable/Color.js +0 -20
- package/lib/customtypes/widgets/nestable/Date.d.ts +0 -19
- package/lib/customtypes/widgets/nestable/Date.js +0 -21
- package/lib/customtypes/widgets/nestable/Embed.d.ts +0 -19
- package/lib/customtypes/widgets/nestable/Embed.js +0 -21
- package/lib/customtypes/widgets/nestable/GeoPoint.d.ts +0 -15
- package/lib/customtypes/widgets/nestable/GeoPoint.js +0 -19
- package/lib/customtypes/widgets/nestable/Image.d.ts +0 -44
- package/lib/customtypes/widgets/nestable/Image.js +0 -29
- package/lib/customtypes/widgets/nestable/IntegrationField.d.ts +0 -19
- package/lib/customtypes/widgets/nestable/IntegrationField.js +0 -21
- package/lib/customtypes/widgets/nestable/Link.d.ts +0 -196
- package/lib/customtypes/widgets/nestable/Link.js +0 -167
- package/lib/customtypes/widgets/nestable/NestableWidget.d.ts +0 -217
- package/lib/customtypes/widgets/nestable/NestableWidget.js +0 -39
- package/lib/customtypes/widgets/nestable/Number.d.ts +0 -23
- package/lib/customtypes/widgets/nestable/Number.js +0 -24
- package/lib/customtypes/widgets/nestable/Range.d.ts +0 -23
- package/lib/customtypes/widgets/nestable/Range.js +0 -24
- package/lib/customtypes/widgets/nestable/RichText.d.ts +0 -73
- package/lib/customtypes/widgets/nestable/RichText.js +0 -131
- package/lib/customtypes/widgets/nestable/Select.d.ts +0 -21
- package/lib/customtypes/widgets/nestable/Select.js +0 -22
- package/lib/customtypes/widgets/nestable/Separator.d.ts +0 -14
- package/lib/customtypes/widgets/nestable/Separator.js +0 -18
- package/lib/customtypes/widgets/nestable/Table.d.ts +0 -21
- package/lib/customtypes/widgets/nestable/Table.js +0 -30
- package/lib/customtypes/widgets/nestable/Text.d.ts +0 -19
- package/lib/customtypes/widgets/nestable/Text.js +0 -21
- package/lib/customtypes/widgets/nestable/Timestamp.d.ts +0 -19
- package/lib/customtypes/widgets/nestable/Timestamp.js +0 -21
- package/lib/customtypes/widgets/nestable/index.d.ts +0 -17
- package/lib/customtypes/widgets/nestable/index.js +0 -20
- package/lib/customtypes/widgets/shared/ImageConstraint.d.ts +0 -7
- package/lib/customtypes/widgets/shared/ImageConstraint.js +0 -31
- package/lib/customtypes/widgets/shared/index.d.ts +0 -1
- package/lib/customtypes/widgets/shared/index.js +0 -8
- package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +0 -455
- package/lib/customtypes/widgets/slices/CompositeSlice.js +0 -63
- package/lib/customtypes/widgets/slices/LegacySlice.d.ts +0 -442
- package/lib/customtypes/widgets/slices/LegacySlice.js +0 -12
- package/lib/customtypes/widgets/slices/SharedSlice.d.ts +0 -1807
- package/lib/customtypes/widgets/slices/SharedSlice.js +0 -118
- package/lib/customtypes/widgets/slices/SharedSliceRef.d.ts +0 -5
- package/lib/customtypes/widgets/slices/SharedSliceRef.js +0 -9
- package/lib/customtypes/widgets/slices/Slice.d.ts +0 -6
- package/lib/customtypes/widgets/slices/Slice.js +0 -2
- package/lib/customtypes/widgets/slices/SlicePrimaryWidget.d.ts +0 -1259
- package/lib/customtypes/widgets/slices/SlicePrimaryWidget.js +0 -10
- package/lib/customtypes/widgets/slices/Slices.d.ts +0 -5917
- package/lib/customtypes/widgets/slices/Slices.js +0 -146
- package/lib/customtypes/widgets/slices/SlicesTypes.d.ts +0 -6
- package/lib/customtypes/widgets/slices/SlicesTypes.js +0 -11
- package/lib/customtypes/widgets/slices/index.d.ts +0 -8
- package/lib/customtypes/widgets/slices/index.js +0 -11
- package/lib/utils/Arrays.d.ts +0 -1
- package/lib/utils/Arrays.js +0 -13
- package/lib/utils/DocumentId.d.ts +0 -2
- package/lib/utils/DocumentId.js +0 -7
- package/lib/utils/Fields.d.ts +0 -6
- package/lib/utils/Fields.js +0 -2
- package/lib/utils/Objects.d.ts +0 -8
- package/lib/utils/Objects.js +0 -42
- package/lib/utils/index.d.ts +0 -4
- package/lib/utils/index.js +0 -8
- package/lib/validators/BasicTypes.d.ts +0 -10
- package/lib/validators/BasicTypes.js +0 -25
- package/lib/validators/DateFromString.d.ts +0 -3
- package/lib/validators/DateFromString.js +0 -11
- package/lib/validators/DateFromStringOrNumber.d.ts +0 -3
- package/lib/validators/DateFromStringOrNumber.js +0 -10
- package/lib/validators/DateFromTsMs.d.ts +0 -3
- package/lib/validators/DateFromTsMs.js +0 -10
- package/lib/validators/DefaultOrElse.d.ts +0 -5
- package/lib/validators/DefaultOrElse.js +0 -21
- package/lib/validators/IntFromNumber.d.ts +0 -5
- package/lib/validators/IntFromNumber.js +0 -14
- package/lib/validators/IntFromPixels.d.ts +0 -8
- package/lib/validators/IntFromPixels.js +0 -24
- package/lib/validators/NonEmptyString.d.ts +0 -3
- package/lib/validators/NonEmptyString.js +0 -6
- package/lib/validators/NonEmptyStringOrNull.d.ts +0 -3
- package/lib/validators/NonEmptyStringOrNull.js +0 -15
- package/lib/validators/NumberOrNull.d.ts +0 -3
- package/lib/validators/NumberOrNull.js +0 -6
- package/lib/validators/NumberRange.d.ts +0 -32
- package/lib/validators/NumberRange.js +0 -40
- package/lib/validators/StringFromBoolean.d.ts +0 -5
- package/lib/validators/StringFromBoolean.js +0 -10
- package/lib/validators/StringFromNumber.d.ts +0 -5
- package/lib/validators/StringFromNumber.js +0 -10
- package/lib/validators/StringOrNull.d.ts +0 -3
- package/lib/validators/StringOrNull.js +0 -6
- package/lib/validators/TrimmedString.d.ts +0 -5
- package/lib/validators/TrimmedString.js +0 -23
- package/lib/validators/function.d.ts +0 -34
- package/lib/validators/function.js +0 -100
- package/lib/validators/index.d.ts +0 -15
- package/lib/validators/index.js +0 -31
- package/src/common/Asset.ts +0 -25
- package/src/common/Embed.ts +0 -22
- package/src/common/HexaColorCode.ts +0 -11
- package/src/common/UUID.ts +0 -19
- package/src/common/WidgetKey.ts +0 -13
- package/src/common/index.ts +0 -3
- package/src/content/Document.ts +0 -539
- package/src/content/fields/EmptyContent.ts +0 -45
- package/src/content/fields/GroupContent.ts +0 -466
- package/src/content/fields/UIDContent.ts +0 -42
- package/src/content/fields/WidgetContent.ts +0 -76
- package/src/content/fields/index.ts +0 -6
- package/src/content/fields/nestable/BooleanContent.ts +0 -52
- package/src/content/fields/nestable/EmbedContent.ts +0 -74
- package/src/content/fields/nestable/FieldContent/ColorContent.ts +0 -49
- package/src/content/fields/nestable/FieldContent/DateContent.ts +0 -49
- package/src/content/fields/nestable/FieldContent/NumberContent.ts +0 -49
- package/src/content/fields/nestable/FieldContent/RangeContent.ts +0 -49
- package/src/content/fields/nestable/FieldContent/SelectContent.ts +0 -60
- package/src/content/fields/nestable/FieldContent/TextContent.ts +0 -49
- package/src/content/fields/nestable/FieldContent/TimestampContent.ts +0 -49
- package/src/content/fields/nestable/FieldContent/common.ts +0 -1
- package/src/content/fields/nestable/FieldContent/index.ts +0 -40
- package/src/content/fields/nestable/GeoPointContent.ts +0 -48
- package/src/content/fields/nestable/ImageContent.ts +0 -196
- package/src/content/fields/nestable/IntegrationFieldContent.ts +0 -51
- package/src/content/fields/nestable/LinkContent.ts +0 -651
- package/src/content/fields/nestable/NestableContent.ts +0 -241
- package/src/content/fields/nestable/RepeatableContent.ts +0 -224
- package/src/content/fields/nestable/RichTextContent/Blocks.ts +0 -238
- package/src/content/fields/nestable/RichTextContent/index.ts +0 -42
- package/src/content/fields/nestable/SeparatorContent.ts +0 -34
- package/src/content/fields/nestable/TableContent.ts +0 -234
- package/src/content/fields/nestable/index.ts +0 -12
- package/src/content/fields/slices/Slice/CompositeSliceContent.ts +0 -293
- package/src/content/fields/slices/Slice/RepeatableContent.ts +0 -29
- package/src/content/fields/slices/Slice/SharedSliceContent.ts +0 -305
- package/src/content/fields/slices/Slice/SimpleSliceContent.ts +0 -180
- package/src/content/fields/slices/Slice/SlicePrimaryContent.ts +0 -40
- package/src/content/fields/slices/Slice/index.ts +0 -52
- package/src/content/fields/slices/SliceItem.ts +0 -184
- package/src/content/fields/slices/SlicesContent.ts +0 -677
- package/src/content/fields/slices/index.ts +0 -3
- package/src/content/helpers.ts +0 -25
- package/src/content/index.ts +0 -4
- package/src/content/utils.ts +0 -145
- package/src/customtypes/CustomType.ts +0 -280
- package/src/customtypes/Section.ts +0 -98
- package/src/customtypes/diff/Variation.ts +0 -167
- package/src/customtypes/diff/Widgets.ts +0 -17
- package/src/customtypes/diff/index.ts +0 -4
- package/src/customtypes/index.ts +0 -4
- package/src/customtypes/widgets/Group.ts +0 -120
- package/src/customtypes/widgets/UID.ts +0 -27
- package/src/customtypes/widgets/Widget.ts +0 -83
- package/src/customtypes/widgets/index.ts +0 -6
- package/src/customtypes/widgets/nestable/BooleanField.ts +0 -29
- package/src/customtypes/widgets/nestable/Color.ts +0 -25
- package/src/customtypes/widgets/nestable/Date.ts +0 -27
- package/src/customtypes/widgets/nestable/Embed.ts +0 -27
- package/src/customtypes/widgets/nestable/GeoPoint.ts +0 -25
- package/src/customtypes/widgets/nestable/Image.ts +0 -39
- package/src/customtypes/widgets/nestable/IntegrationField.ts +0 -26
- package/src/customtypes/widgets/nestable/Link.ts +0 -313
- package/src/customtypes/widgets/nestable/NestableWidget.ts +0 -40
- package/src/customtypes/widgets/nestable/Number.ts +0 -30
- package/src/customtypes/widgets/nestable/Range.ts +0 -30
- package/src/customtypes/widgets/nestable/RichText.ts +0 -215
- package/src/customtypes/widgets/nestable/Select.ts +0 -34
- package/src/customtypes/widgets/nestable/Separator.ts +0 -24
- package/src/customtypes/widgets/nestable/Table.ts +0 -38
- package/src/customtypes/widgets/nestable/Text.ts +0 -27
- package/src/customtypes/widgets/nestable/Timestamp.ts +0 -27
- package/src/customtypes/widgets/nestable/index.ts +0 -17
- package/src/customtypes/widgets/shared/ImageConstraint.ts +0 -41
- package/src/customtypes/widgets/shared/index.ts +0 -1
- package/src/customtypes/widgets/slices/CompositeSlice.ts +0 -79
- package/src/customtypes/widgets/slices/LegacySlice.ts +0 -15
- package/src/customtypes/widgets/slices/SharedSlice.ts +0 -152
- package/src/customtypes/widgets/slices/SharedSliceRef.ts +0 -10
- package/src/customtypes/widgets/slices/Slice.ts +0 -7
- package/src/customtypes/widgets/slices/SlicePrimaryWidget.ts +0 -12
- package/src/customtypes/widgets/slices/Slices.ts +0 -184
- package/src/customtypes/widgets/slices/SlicesTypes.ts +0 -11
- package/src/customtypes/widgets/slices/index.ts +0 -8
- package/src/utils/Arrays.ts +0 -12
- package/src/utils/DocumentId.ts +0 -8
- package/src/utils/Fields.ts +0 -4
- package/src/utils/Objects.ts +0 -53
- package/src/utils/index.ts +0 -4
- package/src/validators/BasicTypes.ts +0 -55
- package/src/validators/DateFromString.ts +0 -19
- package/src/validators/DateFromStringOrNumber.ts +0 -17
- package/src/validators/DateFromTsMs.ts +0 -17
- package/src/validators/DefaultOrElse.ts +0 -24
- package/src/validators/IntFromNumber.ts +0 -22
- package/src/validators/IntFromPixels.ts +0 -32
- package/src/validators/NonEmptyString.ts +0 -8
- package/src/validators/NonEmptyStringOrNull.ts +0 -22
- package/src/validators/NumberOrNull.ts +0 -5
- package/src/validators/NumberRange.ts +0 -51
- package/src/validators/StringFromBoolean.ts +0 -19
- package/src/validators/StringFromNumber.ts +0 -19
- package/src/validators/StringOrNull.ts +0 -5
- package/src/validators/TrimmedString.ts +0 -33
- package/src/validators/function.ts +0 -115
- package/src/validators/index.ts +0 -15
- /package/src/{customtypes/diff/Changes.ts → model/diff/changes.ts} +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { getFieldCtx } from "./legacyContentCtx.js";
|
|
2
|
+
import { GroupContentSchema, GroupContentType, GroupItemContentSchema, GroupItemContentType, NestableAndGroupContentSchema } from "../group.js";
|
|
3
|
+
import { GroupItemLegacySchema, GroupLegacySchema } from "../legacy/group.js";
|
|
4
|
+
import { NestableLegacyCodec } from "./nestable.js";
|
|
5
|
+
//#region src/content/codec/group.ts
|
|
6
|
+
const GroupItemLegacyCodec = (ctx, index) => ({
|
|
7
|
+
name: "GroupItemLegacy",
|
|
8
|
+
is(input) {
|
|
9
|
+
return GroupItemContentSchema.safeParse(input).success;
|
|
10
|
+
},
|
|
11
|
+
toContent(input) {
|
|
12
|
+
const parsed = GroupItemLegacySchema.safeParse(input);
|
|
13
|
+
if (!parsed.success) return parsed;
|
|
14
|
+
const groupItemCtx = ctx.withContentKey(index.toString());
|
|
15
|
+
const value = [];
|
|
16
|
+
for (const [key, legacy] of Object.entries(parsed.data)) {
|
|
17
|
+
const result = NestableAndGroupLegacyCodec(getFieldCtx({
|
|
18
|
+
fieldKey: key,
|
|
19
|
+
contentKey: key,
|
|
20
|
+
ctx: groupItemCtx
|
|
21
|
+
})).toContent(legacy);
|
|
22
|
+
if (result.success) value.push([key, result.data]);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
success: true,
|
|
26
|
+
data: {
|
|
27
|
+
__TYPE__: GroupItemContentType,
|
|
28
|
+
key: groupItemCtx.fieldContentKey,
|
|
29
|
+
value
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
fromContent(input) {
|
|
34
|
+
const legacy = {
|
|
35
|
+
content: {},
|
|
36
|
+
types: {},
|
|
37
|
+
keys: { [ctx.withContentKey(index.toString()).keyOfKey]: input.key }
|
|
38
|
+
};
|
|
39
|
+
for (const [key, content] of input.value) {
|
|
40
|
+
const result = NestableAndGroupLegacyCodec(getFieldCtx({
|
|
41
|
+
fieldKey: key,
|
|
42
|
+
ctx
|
|
43
|
+
})).fromContent(content);
|
|
44
|
+
if (result) {
|
|
45
|
+
legacy.content[key] = result.content;
|
|
46
|
+
legacy.types = {
|
|
47
|
+
...legacy.types,
|
|
48
|
+
...result.types
|
|
49
|
+
};
|
|
50
|
+
legacy.keys = {
|
|
51
|
+
...legacy.keys,
|
|
52
|
+
...result.keys
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return legacy;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const GroupLegacyCodec = (ctx) => ({
|
|
60
|
+
name: "GroupLegacy",
|
|
61
|
+
is(input) {
|
|
62
|
+
return GroupContentSchema.safeParse(input).success;
|
|
63
|
+
},
|
|
64
|
+
toContent(input) {
|
|
65
|
+
const parsed = GroupLegacySchema.safeParse(input);
|
|
66
|
+
if (!parsed.success) return parsed;
|
|
67
|
+
const value = [];
|
|
68
|
+
for (let index = 0; index < parsed.data.length; index++) {
|
|
69
|
+
const item = parsed.data[index];
|
|
70
|
+
if (!item) {
|
|
71
|
+
value.push({
|
|
72
|
+
__TYPE__: GroupItemContentType,
|
|
73
|
+
key: ctx.withContentKey(index.toString()).fieldContentKey,
|
|
74
|
+
value: []
|
|
75
|
+
});
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const result = GroupItemLegacyCodec(ctx, index).toContent(item);
|
|
79
|
+
if (!result.success) return result;
|
|
80
|
+
value.push(result.data);
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
success: true,
|
|
84
|
+
data: {
|
|
85
|
+
__TYPE__: GroupContentType,
|
|
86
|
+
value
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
fromContent(input) {
|
|
91
|
+
const legacy = {
|
|
92
|
+
content: [],
|
|
93
|
+
types: { [ctx.keyOfType]: "Group" },
|
|
94
|
+
keys: {}
|
|
95
|
+
};
|
|
96
|
+
for (let index = 0; index < input.value.length; index++) {
|
|
97
|
+
const item = input.value[index];
|
|
98
|
+
const result = GroupItemLegacyCodec(ctx, index).fromContent(item);
|
|
99
|
+
legacy.content.push(result.content);
|
|
100
|
+
legacy.types = {
|
|
101
|
+
...legacy.types,
|
|
102
|
+
...result.types
|
|
103
|
+
};
|
|
104
|
+
legacy.keys = {
|
|
105
|
+
...legacy.keys,
|
|
106
|
+
...result.keys
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return legacy;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
const NestableAndGroupLegacyCodec = (ctx) => ({
|
|
113
|
+
name: "NestableAndGroupLegacy",
|
|
114
|
+
is(input) {
|
|
115
|
+
return NestableAndGroupContentSchema.safeParse(input).success;
|
|
116
|
+
},
|
|
117
|
+
toContent(input) {
|
|
118
|
+
return ctx.fieldType === "Group" ? GroupLegacyCodec(ctx).toContent(input) : NestableLegacyCodec(ctx).toContent(input);
|
|
119
|
+
},
|
|
120
|
+
fromContent(input) {
|
|
121
|
+
return input.__TYPE__ === "GroupContentType" ? GroupLegacyCodec(ctx).fromContent(input) : NestableLegacyCodec(ctx).fromContent(input);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
//#endregion
|
|
125
|
+
export { GroupItemLegacyCodec, GroupLegacyCodec, NestableAndGroupLegacyCodec };
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.js","names":[],"sources":["../../../src/content/codec/group.ts"],"sourcesContent":["import {\n\tGroupContentSchema,\n\tGroupContentType,\n\tGroupItemContentSchema,\n\tGroupItemContentType,\n\tNestableAndGroupContentSchema,\n} from \"../group\"\nimport type { GroupContent, GroupItemContent, NestableAndGroupContent } from \"../group\"\nimport { GroupItemLegacySchema, GroupLegacySchema } from \"../legacy/group\"\nimport type { GroupItemLegacy, GroupLegacy, NestableAndGroupLegacy } from \"../legacy/group\"\nimport { type LegacyContentCtx, type LegacyCodec, getFieldCtx } from \"./legacyContentCtx\"\nimport { NestableLegacyCodec } from \"./nestable\"\n\nexport const GroupItemLegacyCodec = (\n\tctx: LegacyContentCtx,\n\tindex: number,\n): LegacyCodec<GroupItemContent, GroupItemLegacy> => ({\n\tname: \"GroupItemLegacy\",\n\n\tis(input): input is GroupItemContent {\n\t\treturn GroupItemContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\tconst parsed = GroupItemLegacySchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\treturn parsed\n\t\t}\n\n\t\tconst groupItemCtx = ctx.withContentKey(index.toString())\n\n\t\tconst value: GroupItemContent[\"value\"] = []\n\t\tfor (const [key, legacy] of Object.entries(parsed.data)) {\n\t\t\tconst itemCtx = getFieldCtx({\n\t\t\t\tfieldKey: key,\n\t\t\t\tcontentKey: key,\n\t\t\t\tctx: groupItemCtx,\n\t\t\t})\n\n\t\t\tconst result = NestableAndGroupLegacyCodec(itemCtx).toContent(legacy)\n\t\t\tif (result.success) {\n\t\t\t\tvalue.push([key, result.data])\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: {\n\t\t\t\t__TYPE__: GroupItemContentType,\n\t\t\t\tkey: groupItemCtx.fieldContentKey,\n\t\t\t\tvalue,\n\t\t\t},\n\t\t}\n\t},\n\n\tfromContent(input) {\n\t\tconst groupItemCtx = ctx.withContentKey(index.toString())\n\n\t\tconst legacy: ReturnType<LegacyCodec<GroupItemContent, GroupItemLegacy>[\"fromContent\"]> = {\n\t\t\tcontent: {},\n\t\t\ttypes: {},\n\t\t\tkeys: { [groupItemCtx.keyOfKey]: input.key },\n\t\t}\n\n\t\tfor (const [key, content] of input.value) {\n\t\t\tconst itemCtx = getFieldCtx({ fieldKey: key, ctx })\n\n\t\t\tconst result = NestableAndGroupLegacyCodec(itemCtx).fromContent(content)\n\t\t\tif (result) {\n\t\t\t\tlegacy.content[key] = result.content\n\t\t\t\tlegacy.types = { ...legacy.types, ...result.types }\n\t\t\t\tlegacy.keys = { ...legacy.keys, ...result.keys }\n\t\t\t}\n\t\t}\n\n\t\treturn legacy\n\t},\n})\n\nexport const GroupLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<GroupContent, GroupLegacy> => ({\n\tname: \"GroupLegacy\",\n\n\tis(input): input is GroupContent {\n\t\treturn GroupContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\tconst parsed = GroupLegacySchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\treturn parsed\n\t\t}\n\n\t\tconst value: GroupContent[\"value\"] = []\n\t\tfor (let index = 0; index < parsed.data.length; index++) {\n\t\t\tconst item = parsed.data[index]\n\n\t\t\t// Replace null items with empty GroupItemContent\n\t\t\tif (!item) {\n\t\t\t\tvalue.push({\n\t\t\t\t\t__TYPE__: GroupItemContentType,\n\t\t\t\t\tkey: ctx.withContentKey(index.toString()).fieldContentKey,\n\t\t\t\t\tvalue: [],\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst result = GroupItemLegacyCodec(ctx, index).toContent(item)\n\t\t\tif (!result.success) {\n\t\t\t\treturn result\n\t\t\t}\n\n\t\t\tvalue.push(result.data)\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: { __TYPE__: GroupContentType, value },\n\t\t}\n\t},\n\n\tfromContent(input) {\n\t\tconst legacy: ReturnType<LegacyCodec<GroupContent, GroupLegacy>[\"fromContent\"]> = {\n\t\t\tcontent: [],\n\t\t\ttypes: { [ctx.keyOfType]: \"Group\" },\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 = GroupItemLegacyCodec(ctx, index).fromContent(item)\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\nexport const NestableAndGroupLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<NestableAndGroupContent, NestableAndGroupLegacy, true> => ({\n\tname: \"NestableAndGroupLegacy\",\n\n\tis(input): input is NestableAndGroupContent {\n\t\treturn NestableAndGroupContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\treturn ctx.fieldType === \"Group\"\n\t\t\t? GroupLegacyCodec(ctx).toContent(input)\n\t\t\t: NestableLegacyCodec(ctx).toContent(input)\n\t},\n\n\tfromContent(input) {\n\t\treturn input.__TYPE__ === GroupContentType\n\t\t\t? GroupLegacyCodec(ctx).fromContent(input)\n\t\t\t: NestableLegacyCodec(ctx).fromContent(input)\n\t},\n})\n"],"mappings":"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"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ImageLegacySchema } from "../legacy/image.js";
|
|
2
|
+
import { ImageContentSchema, ImageContentType } from "../image.js";
|
|
3
|
+
//#region src/content/codec/image.ts
|
|
4
|
+
function imageLegacyToContent(value) {
|
|
5
|
+
return {
|
|
6
|
+
...value,
|
|
7
|
+
__TYPE__: ImageContentType
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
const ImageLegacyCodec = (ctx) => ({
|
|
11
|
+
name: "ImageLegacy",
|
|
12
|
+
is(input) {
|
|
13
|
+
return ImageContentSchema.safeParse(input).success;
|
|
14
|
+
},
|
|
15
|
+
toContent(input) {
|
|
16
|
+
const parsed = ImageLegacySchema.safeParse(input);
|
|
17
|
+
if (!parsed.success) return parsed;
|
|
18
|
+
return {
|
|
19
|
+
success: true,
|
|
20
|
+
data: imageLegacyToContent(parsed.data)
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
fromContent(input) {
|
|
24
|
+
return {
|
|
25
|
+
content: {
|
|
26
|
+
edit: input.edit,
|
|
27
|
+
height: input.height,
|
|
28
|
+
origin: input.origin,
|
|
29
|
+
width: input.width,
|
|
30
|
+
...input.alt ? { alt: input.alt } : {},
|
|
31
|
+
...input.credits ? { credits: input.credits } : {},
|
|
32
|
+
...input.provider ? { provider: input.provider } : {},
|
|
33
|
+
...input.thumbnails ? { thumbnails: input.thumbnails } : {},
|
|
34
|
+
...input.url ? { url: input.url } : {}
|
|
35
|
+
},
|
|
36
|
+
types: { [ctx.keyOfType]: "Image" },
|
|
37
|
+
keys: {}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
//#endregion
|
|
42
|
+
export { ImageLegacyCodec, imageLegacyToContent };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","names":[],"sources":["../../../src/content/codec/image.ts"],"sourcesContent":["import { ImageContentSchema, ImageContentType } from \"../image\"\nimport type { ImageContent } from \"../image\"\nimport type { ImageLegacy } from \"../legacy/image\"\nimport { ImageLegacySchema } from \"../legacy/image\"\nimport type { LegacyContentCtx, LegacyCodec } from \"./legacyContentCtx\"\n\n// Also used by content/codec/richText\nexport function imageLegacyToContent(value: ImageLegacy): ImageContent {\n\treturn { ...value, __TYPE__: ImageContentType }\n}\n\nexport const ImageLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<ImageContent, ImageLegacy> => ({\n\tname: \"ImageLegacy\",\n\n\tis(input): input is ImageContent {\n\t\treturn ImageContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\tconst parsed = ImageLegacySchema.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: imageLegacyToContent(parsed.data),\n\t\t}\n\t},\n\n\tfromContent(input) {\n\t\treturn {\n\t\t\tcontent: {\n\t\t\t\tedit: input.edit,\n\t\t\t\theight: input.height,\n\t\t\t\torigin: input.origin,\n\t\t\t\twidth: input.width,\n\t\t\t\t...(input.alt ? { alt: input.alt } : {}),\n\t\t\t\t...(input.credits ? { credits: input.credits } : {}),\n\t\t\t\t...(input.provider ? { provider: input.provider } : {}),\n\t\t\t\t...(input.thumbnails ? { thumbnails: input.thumbnails } : {}),\n\t\t\t\t...(input.url ? { url: input.url } : {}),\n\t\t\t},\n\t\t\ttypes: { [ctx.keyOfType]: \"Image\" },\n\t\t\tkeys: {},\n\t\t}\n\t},\n})\n"],"mappings":";;;AAOA,SAAgB,qBAAqB,OAAkC;AACtE,QAAO;EAAE,GAAG;EAAO,UAAU;EAAkB;;AAGhD,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,qBAAqB,OAAO,KAAK;GACvC;;CAGF,YAAY,OAAO;AAClB,SAAO;GACN,SAAS;IACR,MAAM,MAAM;IACZ,QAAQ,MAAM;IACd,QAAQ,MAAM;IACd,OAAO,MAAM;IACb,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,KAAK,GAAG,EAAE;IACvC,GAAI,MAAM,UAAU,EAAE,SAAS,MAAM,SAAS,GAAG,EAAE;IACnD,GAAI,MAAM,WAAW,EAAE,UAAU,MAAM,UAAU,GAAG,EAAE;IACtD,GAAI,MAAM,aAAa,EAAE,YAAY,MAAM,YAAY,GAAG,EAAE;IAC5D,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,KAAK,GAAG,EAAE;IACvC;GACD,OAAO,GAAG,IAAI,YAAY,SAAS;GACnC,MAAM,EAAE;GACR;;CAEF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { IntegrationFieldContentSchema, IntegrationFieldContentType } from "../integrationField.js";
|
|
2
|
+
import { IntegrationFieldLegacySchema } from "../legacy/integrationField.js";
|
|
3
|
+
//#region src/content/codec/integrationField.ts
|
|
4
|
+
const IntegrationFieldLegacyCodec = (ctx) => ({
|
|
5
|
+
name: "IntegrationFieldLegacy",
|
|
6
|
+
is(input) {
|
|
7
|
+
return IntegrationFieldContentSchema.safeParse(input).success;
|
|
8
|
+
},
|
|
9
|
+
toContent(input) {
|
|
10
|
+
const parsed = IntegrationFieldLegacySchema.safeParse(input);
|
|
11
|
+
if (!parsed.success) return parsed;
|
|
12
|
+
return {
|
|
13
|
+
success: true,
|
|
14
|
+
data: {
|
|
15
|
+
__TYPE__: IntegrationFieldContentType,
|
|
16
|
+
value: parsed.data
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
fromContent(input) {
|
|
21
|
+
return {
|
|
22
|
+
content: input.value,
|
|
23
|
+
types: { [ctx.keyOfType]: "IntegrationFields" },
|
|
24
|
+
keys: {}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
//#endregion
|
|
29
|
+
export { IntegrationFieldLegacyCodec };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=integrationField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrationField.js","names":[],"sources":["../../../src/content/codec/integrationField.ts"],"sourcesContent":["import { IntegrationFieldContentSchema, IntegrationFieldContentType } from \"../integrationField\"\nimport type { IntegrationFieldContent } from \"../integrationField\"\nimport { IntegrationFieldLegacySchema } from \"../legacy/integrationField\"\nimport type { IntegrationFieldLegacy } from \"../legacy/integrationField\"\nimport type { LegacyContentCtx, LegacyCodec } from \"./legacyContentCtx\"\n\nexport const IntegrationFieldLegacyCodec = (\n\tctx: LegacyContentCtx,\n): LegacyCodec<IntegrationFieldContent, IntegrationFieldLegacy> => ({\n\tname: \"IntegrationFieldLegacy\",\n\n\tis(input): input is IntegrationFieldContent {\n\t\treturn IntegrationFieldContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\tconst parsed = IntegrationFieldLegacySchema.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__: IntegrationFieldContentType,\n\t\t\t\tvalue: parsed.data,\n\t\t\t},\n\t\t}\n\t},\n\n\tfromContent(input) {\n\t\treturn {\n\t\t\tcontent: input.value,\n\t\t\ttypes: { [ctx.keyOfType]: \"IntegrationFields\" },\n\t\t\tkeys: {},\n\t\t}\n\t},\n})\n"],"mappings":";;;AAMA,MAAa,+BACZ,SACmE;CACnE,MAAM;CAEN,GAAG,OAAyC;AAC3C,SAAO,8BAA8B,UAAU,MAAM,CAAC;;CAGvD,UAAU,OAAO;EAChB,MAAM,SAAS,6BAA6B,UAAU,MAAM;AAC5D,MAAI,CAAC,OAAO,QACX,QAAO;AAGR,SAAO;GACN,SAAS;GACT,MAAM;IACL,UAAU;IACV,OAAO,OAAO;IACd;GACD;;CAGF,YAAY,OAAO;AAClB,SAAO;GACN,SAAS,MAAM;GACf,OAAO,GAAG,IAAI,YAAY,qBAAqB;GAC/C,MAAM,EAAE;GACR;;CAEF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { FieldOrSliceType } from "../../model/widget.js";
|
|
2
|
+
import { z } from "zod/mini";
|
|
3
|
+
|
|
4
|
+
//#region src/content/codec/legacyContentCtx.d.ts
|
|
5
|
+
interface LegacyContentCtxParams {
|
|
6
|
+
fieldKey: string;
|
|
7
|
+
contentKey?: string;
|
|
8
|
+
fieldPath?: Array<string>;
|
|
9
|
+
contentPath?: Array<string>;
|
|
10
|
+
allTypes?: Map<string, FieldOrSliceType>;
|
|
11
|
+
allKeys?: Map<string, string>;
|
|
12
|
+
}
|
|
13
|
+
declare class LegacyContentCtx {
|
|
14
|
+
fieldKey: string;
|
|
15
|
+
prefixedKey: string;
|
|
16
|
+
keyOfType: string;
|
|
17
|
+
keyOfKey: string;
|
|
18
|
+
fieldPath: Array<string>;
|
|
19
|
+
fieldType?: FieldOrSliceType | undefined;
|
|
20
|
+
allTypes: Map<string, FieldOrSliceType>;
|
|
21
|
+
allKeys: Map<string, string>;
|
|
22
|
+
contentKey: string;
|
|
23
|
+
contentPath: Array<string>;
|
|
24
|
+
fieldContentKey: string;
|
|
25
|
+
constructor({
|
|
26
|
+
fieldKey,
|
|
27
|
+
contentKey,
|
|
28
|
+
contentPath,
|
|
29
|
+
fieldPath,
|
|
30
|
+
allTypes,
|
|
31
|
+
allKeys
|
|
32
|
+
}: LegacyContentCtxParams);
|
|
33
|
+
withContentKey(contentKey: string): LegacyContentCtx;
|
|
34
|
+
}
|
|
35
|
+
interface GetFieldCtxParams {
|
|
36
|
+
fieldKey: string;
|
|
37
|
+
contentKey?: string;
|
|
38
|
+
ctx: LegacyContentCtx;
|
|
39
|
+
prefixes?: Array<string>;
|
|
40
|
+
}
|
|
41
|
+
declare function getFieldCtx({
|
|
42
|
+
fieldKey,
|
|
43
|
+
contentKey: contentKeyParam,
|
|
44
|
+
ctx,
|
|
45
|
+
prefixes
|
|
46
|
+
}: GetFieldCtxParams): LegacyContentCtx;
|
|
47
|
+
declare function defaultCtx(key: string, allTypes?: Map<string, FieldOrSliceType>, allKeys?: Map<string, string>): LegacyContentCtx;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { LegacyContentCtx, defaultCtx, getFieldCtx };
|
|
50
|
+
//# sourceMappingURL=legacyContentCtx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacyContentCtx.d.ts","names":[],"sources":["../../../src/content/codec/legacyContentCtx.ts"],"mappings":";;;;UAIU,sBAAA;EACT,QAAA;EACA,UAAA;EACA,SAAA,GAAY,KAAA;EACZ,WAAA,GAAc,KAAA;EACd,QAAA,GAAW,GAAA,SAAY,gBAAA;EACvB,OAAA,GAAU,GAAA;AAAA;AAAA,cAGE,gBAAA;EACZ,QAAA;EACA,WAAA;EACA,SAAA;EACA,QAAA;EACA,SAAA,EAAW,KAAA;EACX,SAAA,GAAY,gBAAA;EACZ,QAAA,EAAU,GAAA,SAAY,gBAAA;EACtB,OAAA,EAAS,GAAA;EACT,UAAA;EACA,WAAA,EAAa,KAAA;EACb,eAAA;;IAGC,QAAA;IACA,UAAA;IACA,WAAA;IACA,SAAA;IACA,QAAA;IACA;EAAA,GACE,sBAAA;EAmBH,cAAA,CAAe,UAAA,WAAqB,gBAAA;AAAA;AAAA,UAS3B,iBAAA;EACT,QAAA;EACA,UAAA;EACA,GAAA,EAAK,gBAAA;EACL,QAAA,GAAW,KAAA;AAAA;AAAA,iBAGI,WAAA,CAAA;EACf,QAAA;EACA,UAAA,EAAY,eAAA;EACZ,GAAA;EACA;AAAA,GACE,iBAAA,GAAoB,gBAAA;AAAA,iBAYP,UAAA,CACf,GAAA,UACA,QAAA,GAAU,GAAA,SAAY,gBAAA,GACtB,OAAA,GAAS,GAAA,mBACP,gBAAA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region src/content/codec/legacyContentCtx.ts
|
|
2
|
+
var LegacyContentCtx = class LegacyContentCtx {
|
|
3
|
+
fieldKey;
|
|
4
|
+
prefixedKey;
|
|
5
|
+
keyOfType;
|
|
6
|
+
keyOfKey;
|
|
7
|
+
fieldPath;
|
|
8
|
+
fieldType;
|
|
9
|
+
allTypes;
|
|
10
|
+
allKeys;
|
|
11
|
+
contentKey;
|
|
12
|
+
contentPath;
|
|
13
|
+
fieldContentKey;
|
|
14
|
+
constructor({ fieldKey, contentKey, contentPath, fieldPath, allTypes, allKeys }) {
|
|
15
|
+
this.fieldKey = fieldKey;
|
|
16
|
+
this.contentKey = contentKey || fieldKey;
|
|
17
|
+
this.fieldPath = fieldPath || [];
|
|
18
|
+
this.contentPath = contentPath || [];
|
|
19
|
+
this.allTypes = allTypes || /* @__PURE__ */ new Map();
|
|
20
|
+
this.allKeys = allKeys || /* @__PURE__ */ new Map();
|
|
21
|
+
const prefixedKey = Array.of(this.fieldPath, [this.fieldKey]).flat().join(".");
|
|
22
|
+
const prefixedContentKey = Array.of(this.contentPath, [this.contentKey]).flat().join(".");
|
|
23
|
+
this.prefixedKey = prefixedKey;
|
|
24
|
+
this.keyOfType = `${prefixedKey}_TYPE`;
|
|
25
|
+
this.keyOfKey = `${prefixedContentKey}_KEY`;
|
|
26
|
+
this.fieldType = this.allTypes.get(this.prefixedKey);
|
|
27
|
+
this.fieldContentKey = this.allKeys.get(prefixedContentKey) ?? crypto.randomUUID();
|
|
28
|
+
}
|
|
29
|
+
withContentKey(contentKey) {
|
|
30
|
+
return new LegacyContentCtx({
|
|
31
|
+
...this,
|
|
32
|
+
contentPath: [...this.contentPath, this.contentKey],
|
|
33
|
+
contentKey
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function getFieldCtx({ fieldKey, contentKey: contentKeyParam, ctx, prefixes }) {
|
|
38
|
+
return new LegacyContentCtx({
|
|
39
|
+
fieldKey,
|
|
40
|
+
contentKey: contentKeyParam || fieldKey,
|
|
41
|
+
contentPath: [
|
|
42
|
+
...ctx.contentPath,
|
|
43
|
+
ctx.contentKey,
|
|
44
|
+
...prefixes || []
|
|
45
|
+
],
|
|
46
|
+
fieldPath: [
|
|
47
|
+
...ctx.fieldPath,
|
|
48
|
+
ctx.fieldKey,
|
|
49
|
+
...prefixes || []
|
|
50
|
+
],
|
|
51
|
+
allTypes: ctx.allTypes,
|
|
52
|
+
allKeys: ctx.allKeys
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function defaultCtx(key, allTypes = /* @__PURE__ */ new Map(), allKeys = /* @__PURE__ */ new Map()) {
|
|
56
|
+
return new LegacyContentCtx({
|
|
57
|
+
fieldKey: key,
|
|
58
|
+
contentKey: key,
|
|
59
|
+
contentPath: [],
|
|
60
|
+
fieldPath: [],
|
|
61
|
+
allTypes,
|
|
62
|
+
allKeys
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { LegacyContentCtx, defaultCtx, getFieldCtx };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=legacyContentCtx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacyContentCtx.js","names":[],"sources":["../../../src/content/codec/legacyContentCtx.ts"],"sourcesContent":["import type { z } from \"zod/mini\"\n\nimport type { FieldOrSliceType } from \"../../model/widget\"\n\ninterface LegacyContentCtxParams {\n\tfieldKey: string\n\tcontentKey?: string\n\tfieldPath?: Array<string>\n\tcontentPath?: Array<string>\n\tallTypes?: Map<string, FieldOrSliceType>\n\tallKeys?: Map<string, string>\n}\n\nexport class LegacyContentCtx {\n\tfieldKey: string\n\tprefixedKey: string\n\tkeyOfType: string\n\tkeyOfKey: string\n\tfieldPath: Array<string>\n\tfieldType?: FieldOrSliceType | undefined\n\tallTypes: Map<string, FieldOrSliceType>\n\tallKeys: Map<string, string>\n\tcontentKey: string\n\tcontentPath: Array<string>\n\tfieldContentKey: string\n\n\tconstructor({\n\t\tfieldKey,\n\t\tcontentKey,\n\t\tcontentPath,\n\t\tfieldPath,\n\t\tallTypes,\n\t\tallKeys,\n\t}: LegacyContentCtxParams) {\n\t\tthis.fieldKey = fieldKey\n\t\tthis.contentKey = contentKey || fieldKey\n\t\tthis.fieldPath = fieldPath || []\n\t\tthis.contentPath = contentPath || []\n\t\tthis.allTypes = allTypes || new Map<string, FieldOrSliceType>()\n\t\tthis.allKeys = allKeys || new Map<string, string>()\n\n\t\tconst prefixedKey = Array.of(this.fieldPath, [this.fieldKey]).flat().join(\".\")\n\n\t\tconst prefixedContentKey = Array.of(this.contentPath, [this.contentKey]).flat().join(\".\")\n\n\t\tthis.prefixedKey = prefixedKey\n\t\tthis.keyOfType = `${prefixedKey}_TYPE`\n\t\tthis.keyOfKey = `${prefixedContentKey}_KEY`\n\t\tthis.fieldType = this.allTypes.get(this.prefixedKey)\n\t\tthis.fieldContentKey = this.allKeys.get(prefixedContentKey) ?? crypto.randomUUID()\n\t}\n\n\twithContentKey(contentKey: string): LegacyContentCtx {\n\t\treturn new LegacyContentCtx({\n\t\t\t...this,\n\t\t\tcontentPath: [...this.contentPath, this.contentKey],\n\t\t\tcontentKey,\n\t\t})\n\t}\n}\n\ninterface GetFieldCtxParams {\n\tfieldKey: string\n\tcontentKey?: string\n\tctx: LegacyContentCtx\n\tprefixes?: Array<string>\n}\n\nexport function getFieldCtx({\n\tfieldKey,\n\tcontentKey: contentKeyParam,\n\tctx,\n\tprefixes,\n}: GetFieldCtxParams): LegacyContentCtx {\n\tconst contentKey = contentKeyParam || fieldKey\n\treturn new LegacyContentCtx({\n\t\tfieldKey,\n\t\tcontentKey,\n\t\tcontentPath: [...ctx.contentPath, ctx.contentKey, ...(prefixes || [])],\n\t\tfieldPath: [...ctx.fieldPath, ctx.fieldKey, ...(prefixes || [])],\n\t\tallTypes: ctx.allTypes,\n\t\tallKeys: ctx.allKeys,\n\t})\n}\n\nexport function defaultCtx(\n\tkey: string,\n\tallTypes: Map<string, FieldOrSliceType> = new Map(),\n\tallKeys: Map<string, string> = new Map(),\n): LegacyContentCtx {\n\treturn new LegacyContentCtx({\n\t\tfieldKey: key,\n\t\tcontentKey: key,\n\t\tcontentPath: [],\n\t\tfieldPath: [],\n\t\tallTypes,\n\t\tallKeys,\n\t})\n}\n\ntype WithTypes<T> = {\n\tkeys: Record<string, string>\n\ttypes: Record<string, FieldOrSliceType>\n\tcontent: T\n}\n\nexport type LegacyCodec<A, LegacyRaw, AllowUndefined extends boolean = false> = {\n\tname: string\n\tis(input: unknown): input is A\n\ttoContent(\n\t\tinput: unknown,\n\t): z.core.util.SafeParseSuccess<A> | z.core.util.SafeParseError<LegacyRaw | unknown>\n\tfromContent(\n\t\tvalue: A,\n\t): AllowUndefined extends false ? WithTypes<LegacyRaw> : WithTypes<LegacyRaw> | undefined\n}\n"],"mappings":";AAaA,IAAa,mBAAb,MAAa,iBAAiB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,EACX,UACA,YACA,aACA,WACA,UACA,WAC0B;AAC1B,OAAK,WAAW;AAChB,OAAK,aAAa,cAAc;AAChC,OAAK,YAAY,aAAa,EAAE;AAChC,OAAK,cAAc,eAAe,EAAE;AACpC,OAAK,WAAW,4BAAY,IAAI,KAA+B;AAC/D,OAAK,UAAU,2BAAW,IAAI,KAAqB;EAEnD,MAAM,cAAc,MAAM,GAAG,KAAK,WAAW,CAAC,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI;EAE9E,MAAM,qBAAqB,MAAM,GAAG,KAAK,aAAa,CAAC,KAAK,WAAW,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI;AAEzF,OAAK,cAAc;AACnB,OAAK,YAAY,GAAG,YAAY;AAChC,OAAK,WAAW,GAAG,mBAAmB;AACtC,OAAK,YAAY,KAAK,SAAS,IAAI,KAAK,YAAY;AACpD,OAAK,kBAAkB,KAAK,QAAQ,IAAI,mBAAmB,IAAI,OAAO,YAAY;;CAGnF,eAAe,YAAsC;AACpD,SAAO,IAAI,iBAAiB;GAC3B,GAAG;GACH,aAAa,CAAC,GAAG,KAAK,aAAa,KAAK,WAAW;GACnD;GACA,CAAC;;;AAWJ,SAAgB,YAAY,EAC3B,UACA,YAAY,iBACZ,KACA,YACuC;AAEvC,QAAO,IAAI,iBAAiB;EAC3B;EACA,YAHkB,mBAAmB;EAIrC,aAAa;GAAC,GAAG,IAAI;GAAa,IAAI;GAAY,GAAI,YAAY,EAAE;GAAE;EACtE,WAAW;GAAC,GAAG,IAAI;GAAW,IAAI;GAAU,GAAI,YAAY,EAAE;GAAE;EAChE,UAAU,IAAI;EACd,SAAS,IAAI;EACb,CAAC;;AAGH,SAAgB,WACf,KACA,2BAA0C,IAAI,KAAK,EACnD,0BAA+B,IAAI,KAAK,EACrB;AACnB,QAAO,IAAI,iBAAiB;EAC3B,UAAU;EACV,YAAY;EACZ,aAAa,EAAE;EACf,WAAW,EAAE;EACb;EACA;EACA,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { LinkKind, LinkLegacySchema, LinkType } from "../legacy/link.js";
|
|
2
|
+
import { LinkContentSchema, LinkContentType } from "../link.js";
|
|
3
|
+
//#region src/content/codec/link.ts
|
|
4
|
+
function linkLegacyToValue(value) {
|
|
5
|
+
let content;
|
|
6
|
+
switch (value.kind) {
|
|
7
|
+
case LinkKind.Image:
|
|
8
|
+
content = {
|
|
9
|
+
__TYPE__: LinkType.Image,
|
|
10
|
+
...value
|
|
11
|
+
};
|
|
12
|
+
break;
|
|
13
|
+
case LinkKind.File:
|
|
14
|
+
content = {
|
|
15
|
+
__TYPE__: LinkType.File,
|
|
16
|
+
...value
|
|
17
|
+
};
|
|
18
|
+
break;
|
|
19
|
+
case LinkKind.Document:
|
|
20
|
+
content = {
|
|
21
|
+
__TYPE__: LinkType.Document,
|
|
22
|
+
...value
|
|
23
|
+
};
|
|
24
|
+
break;
|
|
25
|
+
case LinkKind.External:
|
|
26
|
+
content = {
|
|
27
|
+
__TYPE__: LinkType.External,
|
|
28
|
+
...value
|
|
29
|
+
};
|
|
30
|
+
break;
|
|
31
|
+
case LinkKind.Media:
|
|
32
|
+
content = {
|
|
33
|
+
__TYPE__: LinkType.Media,
|
|
34
|
+
...value
|
|
35
|
+
};
|
|
36
|
+
break;
|
|
37
|
+
case LinkKind.Any:
|
|
38
|
+
default:
|
|
39
|
+
content = {
|
|
40
|
+
__TYPE__: LinkType.Any,
|
|
41
|
+
...value
|
|
42
|
+
};
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
return content;
|
|
46
|
+
}
|
|
47
|
+
function linkLegacyToContent({ key, text, variant, ...legacy }) {
|
|
48
|
+
return {
|
|
49
|
+
__TYPE__: LinkContentType,
|
|
50
|
+
key,
|
|
51
|
+
value: {
|
|
52
|
+
...text ? { text } : {},
|
|
53
|
+
...variant ? { variant } : {},
|
|
54
|
+
...linkLegacyToValue(legacy)
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function linkValueToLegacy(value) {
|
|
59
|
+
const { __TYPE__, ...legacy } = value;
|
|
60
|
+
return legacy;
|
|
61
|
+
}
|
|
62
|
+
function linkContentToLegacy({ key, value }) {
|
|
63
|
+
const { __TYPE__, ...legacy } = value;
|
|
64
|
+
return {
|
|
65
|
+
key,
|
|
66
|
+
...legacy
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const LinkLegacyCodec = (ctx) => ({
|
|
70
|
+
name: "LinkLegacy",
|
|
71
|
+
is(input) {
|
|
72
|
+
return LinkContentSchema.safeParse(input).success;
|
|
73
|
+
},
|
|
74
|
+
toContent(input) {
|
|
75
|
+
const parsed = LinkLegacySchema.safeParse(input);
|
|
76
|
+
if (!parsed.success) return parsed;
|
|
77
|
+
return {
|
|
78
|
+
success: true,
|
|
79
|
+
data: linkLegacyToContent(parsed.data)
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
fromContent(input) {
|
|
83
|
+
return {
|
|
84
|
+
content: linkContentToLegacy(input),
|
|
85
|
+
types: { [ctx.keyOfType]: "Link" },
|
|
86
|
+
keys: {}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
//#endregion
|
|
91
|
+
export { LinkLegacyCodec, linkLegacyToContent, linkLegacyToValue, linkValueToLegacy };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.js","names":[],"sources":["../../../src/content/codec/link.ts"],"sourcesContent":["import type {\n\tEmptyLinkValueLegacy,\n\tFilledLinkValueLegacy,\n\tLinkValueLegacy,\n\tLinkLegacy,\n} from \"../legacy/link\"\nimport { LinkKind, LinkType, LinkLegacySchema } from \"../legacy/link\"\nimport { LinkContentSchema, LinkContentType } from \"../link\"\nimport type {\n\tEmptyLinkValueContent,\n\tFilledLinkValueContent,\n\tLinkContent,\n\tLinkValueContent,\n} from \"../link\"\nimport type { LegacyContentCtx, LegacyCodec } from \"./legacyContentCtx\"\n\n// Also used by content/codec/richText\nexport function linkLegacyToValue(value: FilledLinkValueLegacy): FilledLinkValueContent\nexport function linkLegacyToValue(value: EmptyLinkValueLegacy): EmptyLinkValueContent\nexport function linkLegacyToValue(value: LinkValueLegacy): LinkValueContent\nexport function linkLegacyToValue(\n\tvalue: Omit<LinkLegacy, \"text\" | \"variant\" | \"key\">,\n): Omit<LinkContent[\"value\"], \"text\" | \"variant\"> {\n\tlet content: Omit<LinkContent[\"value\"], \"text\" | \"variant\">\n\tswitch (value.kind) {\n\t\tcase LinkKind.Image:\n\t\t\tcontent = { __TYPE__: LinkType.Image, ...value }\n\t\t\tbreak\n\t\tcase LinkKind.File:\n\t\t\tcontent = { __TYPE__: LinkType.File, ...value }\n\t\t\tbreak\n\t\tcase LinkKind.Document:\n\t\t\tcontent = { __TYPE__: LinkType.Document, ...value }\n\t\t\tbreak\n\t\tcase LinkKind.External:\n\t\t\tcontent = { __TYPE__: LinkType.External, ...value }\n\t\t\tbreak\n\t\tcase LinkKind.Media:\n\t\t\tcontent = { __TYPE__: LinkType.Media, ...value }\n\t\t\tbreak\n\t\tcase LinkKind.Any:\n\t\tdefault:\n\t\t\tcontent = { __TYPE__: LinkType.Any, ...value }\n\t\t\tbreak\n\t}\n\n\treturn content\n}\n\n// Also used by content/codec/repeatable\nexport function linkLegacyToContent({ key, text, variant, ...legacy }: LinkLegacy): LinkContent {\n\treturn {\n\t\t__TYPE__: LinkContentType,\n\t\tkey,\n\t\tvalue: {\n\t\t\t...(text ? { text } : {}),\n\t\t\t...(variant ? { variant } : {}),\n\t\t\t...linkLegacyToValue(legacy),\n\t\t},\n\t}\n}\n\n// Also used by content/codec/richText\nexport function linkValueToLegacy(value: FilledLinkValueContent): FilledLinkValueLegacy\nexport function linkValueToLegacy(value: EmptyLinkValueContent): EmptyLinkValueLegacy\nexport function linkValueToLegacy(value: LinkValueContent): LinkValueLegacy {\n\tconst { __TYPE__, ...legacy } = value\n\treturn legacy\n}\n\nfunction linkContentToLegacy({ key, value }: LinkContent): LinkLegacy {\n\tconst { __TYPE__, ...legacy } = value\n\n\treturn { key, ...legacy }\n}\n\nexport const LinkLegacyCodec = (ctx: LegacyContentCtx): LegacyCodec<LinkContent, LinkLegacy> => ({\n\tname: \"LinkLegacy\",\n\n\tis(input): input is LinkContent {\n\t\treturn LinkContentSchema.safeParse(input).success\n\t},\n\n\ttoContent(input) {\n\t\tconst parsed = LinkLegacySchema.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: linkLegacyToContent(parsed.data),\n\t\t}\n\t},\n\n\tfromContent(input) {\n\t\treturn {\n\t\t\tcontent: linkContentToLegacy(input),\n\t\t\ttypes: { [ctx.keyOfType]: \"Link\" },\n\t\t\tkeys: {},\n\t\t}\n\t},\n})\n"],"mappings":";;;AAoBA,SAAgB,kBACf,OACiD;CACjD,IAAI;AACJ,SAAQ,MAAM,MAAd;EACC,KAAK,SAAS;AACb,aAAU;IAAE,UAAU,SAAS;IAAO,GAAG;IAAO;AAChD;EACD,KAAK,SAAS;AACb,aAAU;IAAE,UAAU,SAAS;IAAM,GAAG;IAAO;AAC/C;EACD,KAAK,SAAS;AACb,aAAU;IAAE,UAAU,SAAS;IAAU,GAAG;IAAO;AACnD;EACD,KAAK,SAAS;AACb,aAAU;IAAE,UAAU,SAAS;IAAU,GAAG;IAAO;AACnD;EACD,KAAK,SAAS;AACb,aAAU;IAAE,UAAU,SAAS;IAAO,GAAG;IAAO;AAChD;EACD,KAAK,SAAS;EACd;AACC,aAAU;IAAE,UAAU,SAAS;IAAK,GAAG;IAAO;AAC9C;;AAGF,QAAO;;AAIR,SAAgB,oBAAoB,EAAE,KAAK,MAAM,SAAS,GAAG,UAAmC;AAC/F,QAAO;EACN,UAAU;EACV;EACA,OAAO;GACN,GAAI,OAAO,EAAE,MAAM,GAAG,EAAE;GACxB,GAAI,UAAU,EAAE,SAAS,GAAG,EAAE;GAC9B,GAAG,kBAAkB,OAAO;GAC5B;EACD;;AAMF,SAAgB,kBAAkB,OAA0C;CAC3E,MAAM,EAAE,UAAU,GAAG,WAAW;AAChC,QAAO;;AAGR,SAAS,oBAAoB,EAAE,KAAK,SAAkC;CACrE,MAAM,EAAE,UAAU,GAAG,WAAW;AAEhC,QAAO;EAAE;EAAK,GAAG;EAAQ;;AAG1B,MAAa,mBAAmB,SAAiE;CAChG,MAAM;CAEN,GAAG,OAA6B;AAC/B,SAAO,kBAAkB,UAAU,MAAM,CAAC;;CAG3C,UAAU,OAAO;EAChB,MAAM,SAAS,iBAAiB,UAAU,MAAM;AAChD,MAAI,CAAC,OAAO,QACX,QAAO;AAGR,SAAO;GACN,SAAS;GACT,MAAM,oBAAoB,OAAO,KAAK;GACtC;;CAGF,YAAY,OAAO;AAClB,SAAO;GACN,SAAS,oBAAoB,MAAM;GACnC,OAAO,GAAG,IAAI,YAAY,QAAQ;GAClC,MAAM,EAAE;GACR;;CAEF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { BooleanContentType } from "../boolean.js";
|
|
2
|
+
import { EmbedContentType } from "../embed.js";
|
|
3
|
+
import { EmptyContentType } from "../empty.js";
|
|
4
|
+
import { FieldContentType } from "../field.js";
|
|
5
|
+
import { GeoPointContentType } from "../geopoint.js";
|
|
6
|
+
import { ImageContentType } from "../image.js";
|
|
7
|
+
import { IntegrationFieldContentType } from "../integrationField.js";
|
|
8
|
+
import { LinkContentType } from "../link.js";
|
|
9
|
+
import { RepeatableContentType } from "../repeatable.js";
|
|
10
|
+
import { RichTextContentType } from "../richText.js";
|
|
11
|
+
import { SeparatorContentType } from "../separator.js";
|
|
12
|
+
import { TableContentType } from "../table.js";
|
|
13
|
+
import { NestableContentSchema } from "../nestable.js";
|
|
14
|
+
import { BooleanLegacyCodec } from "./boolean.js";
|
|
15
|
+
import { EmbedLegacyCodec } from "./embed.js";
|
|
16
|
+
import { EmptyLegacyCodec } from "./empty.js";
|
|
17
|
+
import { ColorLegacyCodec, DateLegacyCodec, NumberLegacyCodec, RangeLegacyCodec, SelectLegacyCodec, TextLegacyCodec, TimestampLegacyCodec } from "./field.js";
|
|
18
|
+
import { GeoPointLegacyCodec } from "./geopoint.js";
|
|
19
|
+
import { ImageLegacyCodec } from "./image.js";
|
|
20
|
+
import { IntegrationFieldLegacyCodec } from "./integrationField.js";
|
|
21
|
+
import { LinkLegacyCodec } from "./link.js";
|
|
22
|
+
import { RepeatableLegacyCodec } from "./repeatable.js";
|
|
23
|
+
import { RichTextLegacyCodec } from "./richText.js";
|
|
24
|
+
import { SeparatorLegacyCodec } from "./separator.js";
|
|
25
|
+
import { TableLegacyCodec } from "./table.js";
|
|
26
|
+
import { z } from "zod/mini";
|
|
27
|
+
//#region src/content/codec/nestable.ts
|
|
28
|
+
const UnsupportedNestableLegacySchema = z.never();
|
|
29
|
+
const NestableLegacyCodec = (ctx) => ({
|
|
30
|
+
name: "NestableLegacy",
|
|
31
|
+
is(input) {
|
|
32
|
+
return NestableContentSchema.safeParse(input).success;
|
|
33
|
+
},
|
|
34
|
+
toContent(input) {
|
|
35
|
+
if (!ctx.fieldType) return UnsupportedNestableLegacySchema.safeParse(input);
|
|
36
|
+
const empty = EmptyLegacyCodec(ctx).toContent(input);
|
|
37
|
+
if (empty.success) return {
|
|
38
|
+
success: true,
|
|
39
|
+
data: empty.data
|
|
40
|
+
};
|
|
41
|
+
switch (ctx.fieldType) {
|
|
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
|
+
default: return UnsupportedNestableLegacySchema.safeParse(input);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
fromContent(input) {
|
|
63
|
+
switch (input.__TYPE__) {
|
|
64
|
+
case FieldContentType:
|
|
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
|
+
return;
|
|
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
|
+
case EmptyContentType:
|
|
84
|
+
default: return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
//#endregion
|
|
89
|
+
export { NestableLegacyCodec };
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=nestable.js.map
|
|
@@ -0,0 +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\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,SACJ,QAAO,kBAAkB,IAAI,CAAC,UAAU,MAAM;GAC/C,KAAK,WACJ,QAAO,oBAAoB,IAAI,CAAC,UAAU,MAAM;GACjD,KAAK,iBACJ,QAAO,oBAAoB,IAAI,CAAC,UAAU,MAAM;GACjD,KAAK,UACJ,QAAO,mBAAmB,IAAI,CAAC,UAAU,MAAM;GAChD,KAAK,QACJ,QAAO,iBAAiB,IAAI,CAAC,UAAU,MAAM;GAC9C,KAAK,QACJ,QAAO,iBAAiB,IAAI,CAAC,UAAU,MAAM;GAC9C,KAAK,oBACJ,QAAO,4BAA4B,IAAI,CAAC,UAAU,MAAM;GACzD,KAAK,OACJ,QAAO,gBAAgB,IAAI,CAAC,UAAU,MAAM;GAC7C,KAAK,YACJ,QAAO,qBAAqB,IAAI,CAAC,UAAU,MAAM;GAClD,KAAK,QACJ,QAAO,iBAAiB,IAAI,CAAC,UAAU,MAAM;GAC9C,KAAK,kBACJ,QAAO,sBAAsB,KAAK,OAAO,CAAC,UAAU,MAAM;GAC3D,QACC,QAAO,gCAAgC,UACtC,MACA;;;CAIJ,YAAY,OAAO;AAClB,UAAQ,MAAM,UAAd;GACC,KAAK;AACJ,QAAI,MAAM,SAAS,OAAQ,QAAO,gBAAgB,IAAI,CAAC,YAAY,MAAM;AACzE,QAAI,MAAM,SAAS,QAAS,QAAO,iBAAiB,IAAI,CAAC,YAAY,MAAM;AAC3E,QAAI,MAAM,SAAS,QAAS,QAAO,iBAAiB,IAAI,CAAC,YAAY,MAAM;AAC3E,QAAI,MAAM,SAAS,OAAQ,QAAO,gBAAgB,IAAI,CAAC,YAAY,MAAM;AACzE,QAAI,MAAM,SAAS,SAAU,QAAO,kBAAkB,IAAI,CAAC,YAAY,MAAM;AAC7E,QAAI,MAAM,SAAS,YAAa,QAAO,qBAAqB,IAAI,CAAC,YAAY,MAAM;AACnF,QAAI,MAAM,SAAS,SAAU,QAAO,kBAAkB,IAAI,CAAC,YAAY,MAAM;AAC7E;GAED,KAAK,oBACJ,QAAO,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"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { LinkLegacySchema } from "../legacy/link.js";
|
|
2
|
+
import { RepeatableContentSchema, RepeatableContentType } from "../repeatable.js";
|
|
3
|
+
import { RepeatableLegacySchema } from "../legacy/repeatable.js";
|
|
4
|
+
import { LinkLegacyCodec, linkLegacyToContent } from "./link.js";
|
|
5
|
+
//#region src/content/codec/repeatable.ts
|
|
6
|
+
const RepeatableLegacyCodec = (ctx, fieldType) => ({
|
|
7
|
+
name: "RepeatableLegacy",
|
|
8
|
+
is(input) {
|
|
9
|
+
return RepeatableContentSchema.safeParse(input).success;
|
|
10
|
+
},
|
|
11
|
+
toContent(input) {
|
|
12
|
+
const parsed = RepeatableLegacySchema.safeParse(input);
|
|
13
|
+
if (!parsed.success) return parsed;
|
|
14
|
+
return {
|
|
15
|
+
success: true,
|
|
16
|
+
data: {
|
|
17
|
+
__TYPE__: RepeatableContentType,
|
|
18
|
+
type: fieldType,
|
|
19
|
+
value: parsed.data.flatMap((item) => {
|
|
20
|
+
try {
|
|
21
|
+
switch (fieldType) {
|
|
22
|
+
case "Link": return [linkLegacyToContent(LinkLegacySchema.parse(item))];
|
|
23
|
+
default: return [];
|
|
24
|
+
}
|
|
25
|
+
} catch {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
fromContent(input) {
|
|
33
|
+
const legacy = {
|
|
34
|
+
content: [],
|
|
35
|
+
types: { [ctx.keyOfType]: `Repeatable.${fieldType}` },
|
|
36
|
+
keys: {}
|
|
37
|
+
};
|
|
38
|
+
for (const item of input.value) try {
|
|
39
|
+
switch (fieldType) {
|
|
40
|
+
case "Link":
|
|
41
|
+
const result = LinkLegacyCodec(ctx).fromContent(item);
|
|
42
|
+
legacy.content.push(result.content);
|
|
43
|
+
legacy.keys = {
|
|
44
|
+
...legacy.keys,
|
|
45
|
+
...result.keys
|
|
46
|
+
};
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
} catch {}
|
|
50
|
+
return legacy;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
//#endregion
|
|
54
|
+
export { RepeatableLegacyCodec };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=repeatable.js.map
|
|
@@ -0,0 +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\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"}
|