@prismicio/types-internal 3.17.0 → 4.0.0-canary.4689e2d
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 +54 -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 +28 -0
- package/dist/content/legacy/image.d.ts.map +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 +110 -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 +140 -0
- package/dist/content/link.d.ts.map +1 -0
- package/dist/content/link.js +53 -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 +32 -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/imageContent.d.ts +33 -0
- package/dist/helpers/imageContent.d.ts.map +1 -0
- package/dist/helpers/imageContent.js +55 -0
- package/dist/helpers/imageContent.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 +376 -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/helpers/withDefaultContent.d.ts +21 -0
- package/dist/helpers/withDefaultContent.d.ts.map +1 -0
- package/dist/helpers/withDefaultContent.js +120 -0
- package/dist/helpers/withDefaultContent.js.map +1 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +14 -0
- package/dist/io-ts.d.ts +4792 -0
- package/dist/io-ts.d.ts.map +1 -0
- package/dist/io-ts.js +224 -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 +43 -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 +2084 -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 +58 -0
- package/dist/model/widget.d.ts.map +1 -0
- package/dist/model/widget.js +50 -0
- package/dist/model/widget.js.map +1 -0
- package/dist/zod4.d.ts +2840 -0
- package/dist/zod4.d.ts.map +1 -0
- package/dist/zod4.js +136 -0
- package/dist/zod4.js.map +1 -0
- package/package.json +62 -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 +10 -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 +80 -0
- package/src/content/geopoint.ts +11 -0
- package/src/content/group.ts +46 -0
- package/src/content/image.ts +15 -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 +200 -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 +165 -0
- package/src/content/nestable.ts +107 -0
- package/src/content/repeatable.ts +21 -0
- package/src/content/richText.ts +60 -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/helpers/contentPath.ts +35 -0
- package/src/helpers/customTypeModel.ts +113 -0
- package/src/helpers/documentContent.ts +108 -0
- package/src/helpers/imageContent.ts +84 -0
- package/src/helpers/sliceContent.ts +86 -0
- package/src/helpers/traverseContent.ts +597 -0
- package/src/helpers/traverseContentWithModel.ts +616 -0
- package/src/helpers/withDefaultContent.ts +180 -0
- package/src/index.ts +136 -0
- package/src/io-ts.ts +363 -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 +109 -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 +131 -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 +67 -0
- package/src/zod4.ts +199 -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/fields/withDefaultValues.ts +0 -119
- 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,36 @@
|
|
|
1
|
+
import { UIDLegacySchema } from "../legacy/uid"
|
|
2
|
+
import type { UIDLegacy } from "../legacy/uid"
|
|
3
|
+
import { UIDContentSchema, UIDContentType } from "../uid"
|
|
4
|
+
import type { UIDContent } from "../uid"
|
|
5
|
+
import type { LegacyContentCtx, LegacyCodec } from "./legacyContentCtx"
|
|
6
|
+
|
|
7
|
+
export const UIDLegacyCodec = (ctx: LegacyContentCtx): LegacyCodec<UIDContent, UIDLegacy> => ({
|
|
8
|
+
name: "UIDLegacy",
|
|
9
|
+
|
|
10
|
+
is(input): input is UIDContent {
|
|
11
|
+
return UIDContentSchema.safeParse(input).success
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
toContent(input) {
|
|
15
|
+
const parsed = UIDLegacySchema.safeParse(input)
|
|
16
|
+
if (!parsed.success) {
|
|
17
|
+
return parsed
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
success: true,
|
|
22
|
+
data: {
|
|
23
|
+
__TYPE__: UIDContentType,
|
|
24
|
+
value: parsed.data,
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
fromContent(input) {
|
|
30
|
+
return {
|
|
31
|
+
content: input.value,
|
|
32
|
+
types: { [ctx.keyOfType]: "UID" },
|
|
33
|
+
keys: {},
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from "zod/mini"
|
|
2
|
+
|
|
3
|
+
import { GroupContentType } from "../group"
|
|
4
|
+
import type { WidgetLegacy } from "../legacy/widget"
|
|
5
|
+
import { SlicesContentType } from "../slices"
|
|
6
|
+
import { UIDContentType } from "../uid"
|
|
7
|
+
import { WidgetContentSchema } from "../widget"
|
|
8
|
+
import type { WidgetContent } from "../widget"
|
|
9
|
+
import { GroupLegacyCodec } from "./group"
|
|
10
|
+
import type { LegacyCodec, LegacyContentCtx } from "./legacyContentCtx"
|
|
11
|
+
import { NestableLegacyCodec } from "./nestable"
|
|
12
|
+
import { SlicesLegacyCodec } from "./slices"
|
|
13
|
+
import { UIDLegacyCodec } from "./uid"
|
|
14
|
+
|
|
15
|
+
const UnsupportedWidgetLegacySchema = z.never()
|
|
16
|
+
|
|
17
|
+
export const WidgetLegacyCodec = (
|
|
18
|
+
ctx: LegacyContentCtx,
|
|
19
|
+
): LegacyCodec<WidgetContent, WidgetLegacy, true> => ({
|
|
20
|
+
name: "WidgetLegacy",
|
|
21
|
+
|
|
22
|
+
is(input): input is WidgetContent {
|
|
23
|
+
return WidgetContentSchema.safeParse(input).success
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
toContent(input) {
|
|
27
|
+
if (!ctx.fieldType) {
|
|
28
|
+
return UnsupportedWidgetLegacySchema.safeParse(
|
|
29
|
+
input,
|
|
30
|
+
) as z.core.util.SafeParseError<WidgetLegacy>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
switch (ctx.fieldType) {
|
|
34
|
+
case "UID":
|
|
35
|
+
return UIDLegacyCodec(ctx).toContent(input)
|
|
36
|
+
case "Group":
|
|
37
|
+
return GroupLegacyCodec(ctx).toContent(input)
|
|
38
|
+
case "Choice":
|
|
39
|
+
case "Slices":
|
|
40
|
+
return SlicesLegacyCodec(ctx).toContent(input)
|
|
41
|
+
default:
|
|
42
|
+
return NestableLegacyCodec(ctx).toContent(input)
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
fromContent(input) {
|
|
47
|
+
switch (input.__TYPE__) {
|
|
48
|
+
case UIDContentType:
|
|
49
|
+
return UIDLegacyCodec(ctx).fromContent(input)
|
|
50
|
+
case GroupContentType:
|
|
51
|
+
return GroupLegacyCodec(ctx).fromContent(input)
|
|
52
|
+
case SlicesContentType:
|
|
53
|
+
return SlicesLegacyCodec(ctx).fromContent(input)
|
|
54
|
+
default:
|
|
55
|
+
return NestableLegacyCodec(ctx).fromContent(input)
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from "zod/mini"
|
|
2
|
+
|
|
3
|
+
import { WidgetKeySchema } from "../common/widgetKey"
|
|
4
|
+
import { WidgetContentSchema } from "./widget"
|
|
5
|
+
|
|
6
|
+
export const DocumentContentSchema = z.record(WidgetKeySchema, WidgetContentSchema)
|
|
7
|
+
|
|
8
|
+
export type DocumentContent = z.infer<typeof DocumentContentSchema>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from "zod/mini"
|
|
2
|
+
|
|
3
|
+
import { EmbedLegacySchema } from "./legacy/embed"
|
|
4
|
+
|
|
5
|
+
export const EmbedContentType = "EmbedContent" as const
|
|
6
|
+
|
|
7
|
+
export const EmbedContentSchema = z.extend(EmbedLegacySchema, {
|
|
8
|
+
__TYPE__: z.literal(EmbedContentType),
|
|
9
|
+
all: z.unknown(),
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
export type EmbedContent = z.infer<typeof EmbedContentSchema>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod/mini"
|
|
2
|
+
|
|
3
|
+
export const EmptyContentType = "EmptyContent" as const
|
|
4
|
+
|
|
5
|
+
export const EmptyContentSchema = z.object({
|
|
6
|
+
type: z.string(),
|
|
7
|
+
__TYPE__: z.literal(EmptyContentType),
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
export type EmptyContent = z.infer<typeof EmptyContentSchema>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from "zod/mini"
|
|
2
|
+
|
|
3
|
+
export const FieldContentType = "FieldContent" as const
|
|
4
|
+
export const SelectFieldType = "Select" as const
|
|
5
|
+
|
|
6
|
+
// Text
|
|
7
|
+
export const TextContentSchema = z.object({
|
|
8
|
+
type: z.literal("Text"),
|
|
9
|
+
value: z.string().check(z.trim()),
|
|
10
|
+
__TYPE__: z.literal(FieldContentType),
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
// Color
|
|
14
|
+
export const ColorContentSchema = z.object({
|
|
15
|
+
type: z.literal("Color"),
|
|
16
|
+
value: z.string().check(z.trim()),
|
|
17
|
+
__TYPE__: z.literal(FieldContentType),
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
// Date
|
|
21
|
+
export const DateContentSchema = z.object({
|
|
22
|
+
type: z.literal("Date"),
|
|
23
|
+
value: z.string().check(z.trim()),
|
|
24
|
+
__TYPE__: z.literal(FieldContentType),
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
// Timestamp
|
|
28
|
+
export const TimestampContentSchema = z.object({
|
|
29
|
+
type: z.literal("Timestamp"),
|
|
30
|
+
value: z.string().check(z.trim()),
|
|
31
|
+
__TYPE__: z.literal(FieldContentType),
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// Number
|
|
35
|
+
export const NumberContentSchema = z.object({
|
|
36
|
+
type: z.literal("Number"),
|
|
37
|
+
value: z.string().check(z.trim()),
|
|
38
|
+
__TYPE__: z.literal(FieldContentType),
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
// Range
|
|
42
|
+
export const RangeContentSchema = z.object({
|
|
43
|
+
type: z.literal("Range"),
|
|
44
|
+
value: z.string().check(z.trim()),
|
|
45
|
+
__TYPE__: z.literal(FieldContentType),
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// Select
|
|
49
|
+
export const SelectContentSchema = z.object({
|
|
50
|
+
type: z.literal(SelectFieldType),
|
|
51
|
+
value: z.string().check(z.trim()),
|
|
52
|
+
__TYPE__: z.literal(FieldContentType),
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// Fields
|
|
56
|
+
export const FieldContentSchema: z.ZodMiniType<FieldContent> = z.union([
|
|
57
|
+
TextContentSchema,
|
|
58
|
+
ColorContentSchema,
|
|
59
|
+
DateContentSchema,
|
|
60
|
+
TimestampContentSchema,
|
|
61
|
+
NumberContentSchema,
|
|
62
|
+
RangeContentSchema,
|
|
63
|
+
SelectContentSchema,
|
|
64
|
+
])
|
|
65
|
+
|
|
66
|
+
export type TextContent = z.infer<typeof TextContentSchema>
|
|
67
|
+
export type ColorContent = z.infer<typeof ColorContentSchema>
|
|
68
|
+
export type DateContent = z.infer<typeof DateContentSchema>
|
|
69
|
+
export type TimestampContent = z.infer<typeof TimestampContentSchema>
|
|
70
|
+
export type NumberContent = z.infer<typeof NumberContentSchema>
|
|
71
|
+
export type RangeContent = z.infer<typeof RangeContentSchema>
|
|
72
|
+
export type SelectContent = z.infer<typeof SelectContentSchema>
|
|
73
|
+
export type FieldContent =
|
|
74
|
+
| TextContent
|
|
75
|
+
| ColorContent
|
|
76
|
+
| DateContent
|
|
77
|
+
| TimestampContent
|
|
78
|
+
| NumberContent
|
|
79
|
+
| RangeContent
|
|
80
|
+
| SelectContent
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod/mini"
|
|
2
|
+
|
|
3
|
+
import { GeoPointLegacySchema } from "./legacy/geopoint"
|
|
4
|
+
|
|
5
|
+
export const GeoPointContentType = "GeoPointContent" as const
|
|
6
|
+
|
|
7
|
+
export const GeoPointContentSchema = z.extend(GeoPointLegacySchema, {
|
|
8
|
+
__TYPE__: z.literal(GeoPointContentType),
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
export type GeoPointContent = z.infer<typeof GeoPointContentSchema>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from "zod/mini"
|
|
2
|
+
|
|
3
|
+
import { NestableContentSchema } from "./nestable"
|
|
4
|
+
import type { NestableContent } from "./nestable"
|
|
5
|
+
|
|
6
|
+
// Item
|
|
7
|
+
export const GroupItemContentType = "GroupItemContent" as const
|
|
8
|
+
|
|
9
|
+
export const GroupItemContentSchema: z.ZodMiniType<GroupItemContent> = z.object({
|
|
10
|
+
__TYPE__: z.literal(GroupItemContentType),
|
|
11
|
+
key: z.string(),
|
|
12
|
+
value: z.array(
|
|
13
|
+
z.tuple([
|
|
14
|
+
z.string(),
|
|
15
|
+
z.union([
|
|
16
|
+
NestableContentSchema,
|
|
17
|
+
// `lazy` is used to handle circular dependency on GroupContentSchema
|
|
18
|
+
z.lazy(() => GroupContentSchema),
|
|
19
|
+
]),
|
|
20
|
+
]),
|
|
21
|
+
),
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
// Manual type definition to handle circular dependency on GroupItemContentSchema
|
|
25
|
+
export type GroupItemContent = {
|
|
26
|
+
__TYPE__: typeof GroupItemContentType
|
|
27
|
+
key: string
|
|
28
|
+
value: [string, NestableContent | GroupContent][]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Group
|
|
32
|
+
export const GroupContentType = "GroupContentType" as const
|
|
33
|
+
|
|
34
|
+
export const GroupContentSchema = z.object({
|
|
35
|
+
__TYPE__: z.literal(GroupContentType),
|
|
36
|
+
value: z.array(GroupItemContentSchema),
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
export type GroupContent = z.infer<typeof GroupContentSchema>
|
|
40
|
+
|
|
41
|
+
export const NestableAndGroupContentSchema: z.ZodMiniType<NestableAndGroupContent> = z.union([
|
|
42
|
+
NestableContentSchema,
|
|
43
|
+
GroupContentSchema,
|
|
44
|
+
])
|
|
45
|
+
|
|
46
|
+
export type NestableAndGroupContent = NestableContent | GroupContent
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod/mini"
|
|
2
|
+
|
|
3
|
+
import { ImageLegacyViewSchema, ImageLegacySchema } from "./legacy/image"
|
|
4
|
+
|
|
5
|
+
export const ImageContentType = "ImageContent" as const
|
|
6
|
+
|
|
7
|
+
export const ImageContentViewSchema = ImageLegacyViewSchema
|
|
8
|
+
|
|
9
|
+
export type ImageContentView = z.infer<typeof ImageLegacyViewSchema>
|
|
10
|
+
|
|
11
|
+
export const ImageContentSchema = z.extend(ImageLegacySchema, {
|
|
12
|
+
__TYPE__: z.literal(ImageContentType),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export type ImageContent = z.infer<typeof ImageContentSchema>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod/mini"
|
|
2
|
+
|
|
3
|
+
export const IntegrationFieldContentType = "IntegrationFieldsContent" as const
|
|
4
|
+
|
|
5
|
+
export const IntegrationFieldContentSchema = z.object({
|
|
6
|
+
__TYPE__: z.literal(IntegrationFieldContentType),
|
|
7
|
+
value: z.string(),
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
export type IntegrationFieldContent = z.infer<typeof IntegrationFieldContentSchema>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod/mini"
|
|
2
|
+
|
|
3
|
+
import { WidgetKeySchema } from "../../common/widgetKey"
|
|
4
|
+
import type { WidgetKey } from "../../common/widgetKey"
|
|
5
|
+
|
|
6
|
+
export const DocumentLegacySchema = z.pipe(
|
|
7
|
+
z.record(z.string(), z.unknown()),
|
|
8
|
+
z.transform((value) => {
|
|
9
|
+
const documentLegacy: Record<WidgetKey, unknown> = {}
|
|
10
|
+
|
|
11
|
+
for (const [widgetKey, widgetValue] of Object.entries(value)) {
|
|
12
|
+
// Keep v3 behavior: invalid widget keys are dropped, but the document
|
|
13
|
+
// decode still succeeds. Widget value validation happens later in
|
|
14
|
+
// DocumentLegacyCodec via WidgetLegacyCodec.
|
|
15
|
+
const result = WidgetKeySchema.safeParse(widgetKey)
|
|
16
|
+
if (result.success) {
|
|
17
|
+
documentLegacy[result.data] = widgetValue
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return documentLegacy
|
|
22
|
+
}),
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
export type DocumentLegacy = z.infer<typeof DocumentLegacySchema>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod/mini"
|
|
2
|
+
|
|
3
|
+
const EmbedShape = {
|
|
4
|
+
embed_url: z.string(),
|
|
5
|
+
type: z.string(),
|
|
6
|
+
version: z.nullish(z.union([z.string(), z.number()])),
|
|
7
|
+
title: z.nullish(z.string()),
|
|
8
|
+
author_name: z.nullish(z.string()),
|
|
9
|
+
author_url: z.nullish(z.string()),
|
|
10
|
+
provider_name: z.nullish(z.string()),
|
|
11
|
+
provider_url: z.nullish(z.string()),
|
|
12
|
+
cache_age: z.nullish(z.union([z.string(), z.number()])),
|
|
13
|
+
thumbnail_url: z.nullish(z.string()),
|
|
14
|
+
thumbnail_width: z.nullish(z.number()),
|
|
15
|
+
thumbnail_height: z.nullish(z.number()),
|
|
16
|
+
html: z.nullish(z.string()),
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const EmbedLegacySchema = z.object(EmbedShape)
|
|
20
|
+
|
|
21
|
+
export const EmbedLegacyLooseSchema = z.looseObject(EmbedShape)
|
|
22
|
+
|
|
23
|
+
export type EmbedLegacy = z.infer<typeof EmbedLegacySchema>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod/mini"
|
|
2
|
+
|
|
3
|
+
import type { NestableLegacy } from "./nestable"
|
|
4
|
+
import { NestableLegacySchema } from "./nestable"
|
|
5
|
+
|
|
6
|
+
// Keep item values raw here: array-shaped legacy payloads are ambiguous until
|
|
7
|
+
// `codec/group.ts` resolves the field model and picks the right decoder.
|
|
8
|
+
export const GroupItemLegacySchema = z.record(z.string(), z.unknown())
|
|
9
|
+
|
|
10
|
+
export type GroupItemLegacy = z.infer<typeof GroupItemLegacySchema>
|
|
11
|
+
|
|
12
|
+
export const GroupLegacySchema: z.ZodMiniType<GroupLegacy> = z.array(
|
|
13
|
+
z.union([GroupItemLegacySchema, z.null()]),
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
export type GroupLegacy = (GroupItemLegacy | null)[]
|
|
17
|
+
|
|
18
|
+
export const NestableAndGroupLegacySchema: z.ZodMiniType<NestableAndGroupLegacy> = z.union([
|
|
19
|
+
NestableLegacySchema,
|
|
20
|
+
GroupLegacySchema,
|
|
21
|
+
])
|
|
22
|
+
|
|
23
|
+
export type NestableAndGroupLegacy = NestableLegacy | GroupLegacy
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod/mini"
|
|
2
|
+
|
|
3
|
+
const OriginSchema = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
url: z.string(),
|
|
6
|
+
width: z.number(),
|
|
7
|
+
height: z.number(),
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const CropSchema = z.object({
|
|
11
|
+
x: z.number(),
|
|
12
|
+
y: z.number(),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const EditSchema = z.object({
|
|
16
|
+
zoom: z.number(),
|
|
17
|
+
crop: CropSchema,
|
|
18
|
+
background: z.string(),
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const NonEmptyStringOrNullSchema = z.pipe(
|
|
22
|
+
z.nullish(z.string()),
|
|
23
|
+
z.transform((value) => (typeof value === "string" && value.length > 0 ? value : null)),
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
export const ImageLegacyViewSchema = z.object({
|
|
27
|
+
origin: OriginSchema,
|
|
28
|
+
width: z.number(),
|
|
29
|
+
height: z.number(),
|
|
30
|
+
edit: EditSchema,
|
|
31
|
+
url: z.optional(z.string()),
|
|
32
|
+
credits: z.optional(NonEmptyStringOrNullSchema),
|
|
33
|
+
alt: z.optional(NonEmptyStringOrNullSchema),
|
|
34
|
+
provider: z.nullish(z.string()),
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
export type ImageLegacyView = z.infer<typeof ImageLegacyViewSchema>
|
|
38
|
+
|
|
39
|
+
export const ImageLegacySchema = z.extend(ImageLegacyViewSchema, {
|
|
40
|
+
thumbnails: z.optional(z.record(z.string(), ImageLegacyViewSchema)),
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
export type ImageLegacy = z.infer<typeof ImageLegacySchema>
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { z } from "zod/mini"
|
|
2
|
+
|
|
3
|
+
import { NonEmptyStringSchema } from "../../common/nonEmptyString"
|
|
4
|
+
|
|
5
|
+
export const LinkKind = {
|
|
6
|
+
Image: "image",
|
|
7
|
+
File: "file",
|
|
8
|
+
Media: "media",
|
|
9
|
+
Document: "document",
|
|
10
|
+
External: "web",
|
|
11
|
+
Any: "any",
|
|
12
|
+
} as const
|
|
13
|
+
|
|
14
|
+
export const LinkType = {
|
|
15
|
+
Image: "ImageLink",
|
|
16
|
+
File: "FileLink",
|
|
17
|
+
Document: "DocumentLink",
|
|
18
|
+
External: "ExternalLink",
|
|
19
|
+
Media: "MediaLink",
|
|
20
|
+
Any: "AnyLink",
|
|
21
|
+
} as const
|
|
22
|
+
|
|
23
|
+
// Image
|
|
24
|
+
export const FilledImageLinkLegacyValueSchema = z.strictObject({
|
|
25
|
+
// `kind` was normalized to the literal (legacy behavior)
|
|
26
|
+
kind: z.pipe(
|
|
27
|
+
z.string(),
|
|
28
|
+
z.transform(() => LinkKind.Image),
|
|
29
|
+
),
|
|
30
|
+
id: z.string(),
|
|
31
|
+
url: z.string(),
|
|
32
|
+
height: z.string(),
|
|
33
|
+
width: z.string(),
|
|
34
|
+
size: z.string(),
|
|
35
|
+
name: z.string(),
|
|
36
|
+
date: z.nullish(z.string()),
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
export const EmptyImageLinkLegacyValueSchema = z.strictObject({
|
|
40
|
+
kind: z.literal(LinkKind.Image),
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
// File
|
|
44
|
+
export const FilledFileLinkLegacyValueSchema = z.strictObject({
|
|
45
|
+
// `kind` was normalized to the literal (legacy behavior)
|
|
46
|
+
kind: z.pipe(
|
|
47
|
+
z.string(),
|
|
48
|
+
z.transform(() => LinkKind.File),
|
|
49
|
+
),
|
|
50
|
+
id: z.string(),
|
|
51
|
+
url: z.string(),
|
|
52
|
+
name: z.string(),
|
|
53
|
+
size: z.transform((value) => (typeof value === "string" ? value : "0")),
|
|
54
|
+
date: z.nullish(z.string()),
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
export const EmptyFileLinkLegacyValueSchema = z.strictObject({
|
|
58
|
+
kind: z.literal(LinkKind.File),
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
// Media
|
|
62
|
+
|
|
63
|
+
// Media link only represent the empty state as they turn into
|
|
64
|
+
// file or image links when they filled.
|
|
65
|
+
export const EmptyMediaLinkLegacyValueSchema = z.strictObject({
|
|
66
|
+
kind: z.literal(LinkKind.Media),
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
// Document
|
|
70
|
+
export const FilledDocumentLinkLegacyValueSchema = z.strictObject({
|
|
71
|
+
// `kind` is not part of the filled schema... (legacy behavior)
|
|
72
|
+
// We transform it to the literal for consistency.
|
|
73
|
+
kind: z.pipe(
|
|
74
|
+
z.optional(z.literal(LinkKind.Document)),
|
|
75
|
+
z.transform(() => LinkKind.Document),
|
|
76
|
+
),
|
|
77
|
+
id: NonEmptyStringSchema,
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
export const EmptyDocumentLinkLegacyValueSchema = z.strictObject({
|
|
81
|
+
kind: z.literal(LinkKind.Document),
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
// External
|
|
85
|
+
export const FilledExternalLinkLegacyValueSchema = z.strictObject({
|
|
86
|
+
// It's odd that `kind` is optional here... (legacy behavior)
|
|
87
|
+
// We transform it to the literal for consistency.
|
|
88
|
+
kind: z.pipe(
|
|
89
|
+
z.optional(z.literal(LinkKind.External)),
|
|
90
|
+
z.transform(() => LinkKind.External),
|
|
91
|
+
),
|
|
92
|
+
url: z.string(),
|
|
93
|
+
target: z.nullish(z.string()),
|
|
94
|
+
preview: z.nullish(
|
|
95
|
+
z.strictObject({
|
|
96
|
+
title: z.optional(z.string()),
|
|
97
|
+
}),
|
|
98
|
+
),
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
export const EmptyExternalLinkLegacyValueSchema = z.strictObject({
|
|
102
|
+
kind: z.literal(LinkKind.External),
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
// Any
|
|
106
|
+
export const AnyLinkLegacySchema = z.strictObject({
|
|
107
|
+
kind: z.transform(() => LinkKind.Any),
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
// All
|
|
111
|
+
|
|
112
|
+
export const FilledLinkLegacyValueSchema: z.ZodMiniType<FilledLinkLegacyValue> = z.union([
|
|
113
|
+
FilledImageLinkLegacyValueSchema,
|
|
114
|
+
FilledFileLinkLegacyValueSchema,
|
|
115
|
+
FilledDocumentLinkLegacyValueSchema,
|
|
116
|
+
FilledExternalLinkLegacyValueSchema,
|
|
117
|
+
])
|
|
118
|
+
|
|
119
|
+
type FilledImageLinkLegacyValue = z.infer<typeof FilledImageLinkLegacyValueSchema>
|
|
120
|
+
type FilledFileLinkLegacyValue = z.infer<typeof FilledFileLinkLegacyValueSchema>
|
|
121
|
+
type FilledDocumentLinkLegacyValue = z.infer<typeof FilledDocumentLinkLegacyValueSchema>
|
|
122
|
+
type FilledExternalLinkLegacyValue = z.infer<typeof FilledExternalLinkLegacyValueSchema>
|
|
123
|
+
export type FilledLinkLegacyValue =
|
|
124
|
+
| FilledImageLinkLegacyValue
|
|
125
|
+
| FilledFileLinkLegacyValue
|
|
126
|
+
| FilledDocumentLinkLegacyValue
|
|
127
|
+
| FilledExternalLinkLegacyValue
|
|
128
|
+
|
|
129
|
+
const EmptyLinkLegacyValueSchema: z.ZodMiniType<EmptyLinkLegacyValue> = z.union([
|
|
130
|
+
EmptyImageLinkLegacyValueSchema,
|
|
131
|
+
EmptyFileLinkLegacyValueSchema,
|
|
132
|
+
EmptyMediaLinkLegacyValueSchema,
|
|
133
|
+
EmptyDocumentLinkLegacyValueSchema,
|
|
134
|
+
EmptyExternalLinkLegacyValueSchema,
|
|
135
|
+
AnyLinkLegacySchema,
|
|
136
|
+
])
|
|
137
|
+
|
|
138
|
+
type EmptyImageLinkLegacyValue = z.infer<typeof EmptyImageLinkLegacyValueSchema>
|
|
139
|
+
type EmptyFileLinkLegacyValue = z.infer<typeof EmptyFileLinkLegacyValueSchema>
|
|
140
|
+
type EmptyMediaLinkLegacyValue = z.infer<typeof EmptyMediaLinkLegacyValueSchema>
|
|
141
|
+
type EmptyDocumentLinkLegacyValue = z.infer<typeof EmptyDocumentLinkLegacyValueSchema>
|
|
142
|
+
type EmptyExternalLinkLegacyValue = z.infer<typeof EmptyExternalLinkLegacyValueSchema>
|
|
143
|
+
type AnyLinkLegacy = z.infer<typeof AnyLinkLegacySchema>
|
|
144
|
+
export type EmptyLinkLegacyValue =
|
|
145
|
+
| EmptyImageLinkLegacyValue
|
|
146
|
+
| EmptyFileLinkLegacyValue
|
|
147
|
+
| EmptyMediaLinkLegacyValue
|
|
148
|
+
| EmptyDocumentLinkLegacyValue
|
|
149
|
+
| EmptyExternalLinkLegacyValue
|
|
150
|
+
| AnyLinkLegacy
|
|
151
|
+
|
|
152
|
+
const LinkLegacyValueSchema: z.ZodMiniType<LinkLegacyValue> = z.union([
|
|
153
|
+
FilledLinkLegacyValueSchema,
|
|
154
|
+
EmptyLinkLegacyValueSchema,
|
|
155
|
+
])
|
|
156
|
+
|
|
157
|
+
export type LinkLegacyValue = FilledLinkLegacyValue | EmptyLinkLegacyValue
|
|
158
|
+
|
|
159
|
+
// We cannot use z.extend here because we're working with unions.
|
|
160
|
+
// z.intersection wouldn't work also for the same reason.
|
|
161
|
+
export const LinkLegacySchema = z.pipe(
|
|
162
|
+
z.pipe(
|
|
163
|
+
z.pipe(
|
|
164
|
+
z.record(z.string(), z.unknown()),
|
|
165
|
+
z.transform(
|
|
166
|
+
({
|
|
167
|
+
key,
|
|
168
|
+
text,
|
|
169
|
+
variant,
|
|
170
|
+
...value
|
|
171
|
+
}): {
|
|
172
|
+
key?: unknown
|
|
173
|
+
text?: unknown
|
|
174
|
+
variant?: unknown
|
|
175
|
+
value: Record<string, unknown>
|
|
176
|
+
} => ({ key, text, variant, value }),
|
|
177
|
+
),
|
|
178
|
+
),
|
|
179
|
+
z.object({
|
|
180
|
+
key: z.optional(z.string()),
|
|
181
|
+
text: z.optional(z.string()),
|
|
182
|
+
variant: z.optional(z.string()),
|
|
183
|
+
value: LinkLegacyValueSchema as z.ZodMiniType<LinkLegacyValue, Record<string, unknown>>,
|
|
184
|
+
}),
|
|
185
|
+
),
|
|
186
|
+
z.transform(({ key, text, variant, value }) => ({
|
|
187
|
+
key: z.uuidv4().safeParse(key).data ?? crypto.randomUUID(),
|
|
188
|
+
...(text ? { text } : {}),
|
|
189
|
+
...(variant ? { variant } : {}),
|
|
190
|
+
...value,
|
|
191
|
+
})),
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
export type LinkLegacy = z.infer<typeof LinkLegacySchema>
|