@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,180 @@
|
|
|
1
|
+
import { BooleanContentType } from "../content/boolean"
|
|
2
|
+
import type { DocumentContent } from "../content/document"
|
|
3
|
+
import { FieldContentType, SelectFieldType } from "../content/field"
|
|
4
|
+
import type { GroupContent, GroupItemContent } from "../content/group"
|
|
5
|
+
import { GroupContentType } from "../content/group"
|
|
6
|
+
import type { SliceContent } from "../content/slice"
|
|
7
|
+
import { CompositeSliceContentType, SharedSliceContentType } from "../content/slice"
|
|
8
|
+
import type { SlicesContent } from "../content/slices"
|
|
9
|
+
import { SlicesContentType } from "../content/slices"
|
|
10
|
+
import type { WidgetContent } from "../content/widget"
|
|
11
|
+
import type { StaticCustomTypeModel } from "../model/customType"
|
|
12
|
+
import type { GroupModel } from "../model/group"
|
|
13
|
+
import type { NestableModel } from "../model/nestable"
|
|
14
|
+
import type { StaticSliceModel } from "../model/slice"
|
|
15
|
+
import type { StaticWidgetModel } from "../model/widget"
|
|
16
|
+
import * as customTypeModel from "./customTypeModel"
|
|
17
|
+
|
|
18
|
+
export function document(content: DocumentContent, model: StaticCustomTypeModel): DocumentContent {
|
|
19
|
+
return record(content, customTypeModel.flatten(model))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function slice(content: SliceContent, model: StaticSliceModel | undefined): SliceContent {
|
|
23
|
+
if (!model) {
|
|
24
|
+
return content
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (model.type === "SharedSlice") {
|
|
28
|
+
if (content.__TYPE__ !== SharedSliceContentType) {
|
|
29
|
+
return content
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const variation = model.variations.find((variation) => variation.id === content.variation)
|
|
33
|
+
if (!variation) {
|
|
34
|
+
return content
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
...content,
|
|
39
|
+
primary: record(content.primary, variation?.primary),
|
|
40
|
+
items: items(content.items, variation?.items),
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (model.type === "Slice") {
|
|
45
|
+
if (content.__TYPE__ !== CompositeSliceContentType) {
|
|
46
|
+
return content
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
...content,
|
|
51
|
+
nonRepeat: record(content.nonRepeat, model["non-repeat"]),
|
|
52
|
+
repeat: items(content.repeat, model.repeat),
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (
|
|
57
|
+
content.__TYPE__ === SharedSliceContentType ||
|
|
58
|
+
content.__TYPE__ === CompositeSliceContentType
|
|
59
|
+
) {
|
|
60
|
+
return content
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return widget(content, model)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function widget<TContent extends WidgetContent | undefined>(
|
|
67
|
+
content: TContent,
|
|
68
|
+
model: StaticWidgetModel | undefined,
|
|
69
|
+
): TContent {
|
|
70
|
+
if (!model) {
|
|
71
|
+
return content
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (
|
|
75
|
+
(model.type === "Slices" || model.type === "Choice") &&
|
|
76
|
+
content?.__TYPE__ === SlicesContentType
|
|
77
|
+
) {
|
|
78
|
+
if (!model.config?.choices) return content
|
|
79
|
+
|
|
80
|
+
const value: SlicesContent["value"] = []
|
|
81
|
+
for (const sliceItem of content.value) {
|
|
82
|
+
value.push({
|
|
83
|
+
...sliceItem,
|
|
84
|
+
widget: slice(sliceItem.widget, model.config.choices[sliceItem.name]),
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return { ...content, value }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (model.type === "Group") {
|
|
92
|
+
if (content?.__TYPE__ !== GroupContentType) {
|
|
93
|
+
return <TContent>{
|
|
94
|
+
__TYPE__: GroupContentType,
|
|
95
|
+
value: items([], model.config?.fields),
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return { ...content, value: items(content.value, model.config?.fields) }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (model.type === "Boolean" && !content) {
|
|
103
|
+
if (model.config?.default_value === undefined) {
|
|
104
|
+
return <TContent>undefined
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return <TContent>{
|
|
108
|
+
__TYPE__: BooleanContentType,
|
|
109
|
+
value: model.config.default_value,
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (model.type === "Select" && !content) {
|
|
114
|
+
if (!model.config?.default_value) {
|
|
115
|
+
return <TContent>undefined
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return <TContent>{
|
|
119
|
+
__TYPE__: FieldContentType,
|
|
120
|
+
type: SelectFieldType,
|
|
121
|
+
value: model.config.default_value,
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return content
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function items(
|
|
129
|
+
items: GroupContent["value"],
|
|
130
|
+
fields: Record<string, GroupModel | NestableModel> | undefined,
|
|
131
|
+
): GroupContent["value"] {
|
|
132
|
+
if (!fields) {
|
|
133
|
+
return items
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const itemsWithDefaults: GroupContent["value"] = []
|
|
137
|
+
for (const item of items) {
|
|
138
|
+
const itemValue: GroupItemContent["value"] = []
|
|
139
|
+
|
|
140
|
+
const missingFields = { ...fields }
|
|
141
|
+
for (const [key, value] of item.value) {
|
|
142
|
+
delete missingFields[key]
|
|
143
|
+
itemValue.push([key, widget(value, fields[key])])
|
|
144
|
+
}
|
|
145
|
+
for (const [key, field] of Object.entries(missingFields)) {
|
|
146
|
+
const content = widget(undefined, field)
|
|
147
|
+
if (content) {
|
|
148
|
+
itemValue.push([key, content])
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
itemsWithDefaults.push({ ...item, value: itemValue })
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return itemsWithDefaults
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function record<TContent extends WidgetContent>(
|
|
159
|
+
record: Record<string, TContent>,
|
|
160
|
+
fields: Record<string, StaticWidgetModel> | undefined,
|
|
161
|
+
): Record<string, TContent> {
|
|
162
|
+
if (!fields) {
|
|
163
|
+
return record
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const missingFields = { ...fields }
|
|
167
|
+
const recordWithDefaults: Record<string, TContent> = {}
|
|
168
|
+
for (const [key, value] of Object.entries(record)) {
|
|
169
|
+
delete missingFields[key]
|
|
170
|
+
recordWithDefaults[key] = widget(value, fields[key])
|
|
171
|
+
}
|
|
172
|
+
for (const [key, field] of Object.entries(missingFields)) {
|
|
173
|
+
const content = widget(undefined, field)
|
|
174
|
+
if (content) {
|
|
175
|
+
recordWithDefaults[key] = content
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return recordWithDefaults
|
|
180
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Common
|
|
2
|
+
export type { Asset } from "./common/asset"
|
|
3
|
+
export type { Embed } from "./common/embed"
|
|
4
|
+
export type { HexaColorCode } from "./common/hexaColorCode"
|
|
5
|
+
export type { NonEmptyString } from "./common/nonEmptyString"
|
|
6
|
+
export type { WidgetKey } from "./common/widgetKey"
|
|
7
|
+
|
|
8
|
+
// Content
|
|
9
|
+
export type { BooleanContent } from "./content/boolean"
|
|
10
|
+
export type { DocumentContent } from "./content/document"
|
|
11
|
+
export type { EmbedContent } from "./content/embed"
|
|
12
|
+
export type { EmptyContent } from "./content/empty"
|
|
13
|
+
export type {
|
|
14
|
+
ColorContent,
|
|
15
|
+
DateContent,
|
|
16
|
+
NumberContent,
|
|
17
|
+
RangeContent,
|
|
18
|
+
SelectContent,
|
|
19
|
+
TextContent,
|
|
20
|
+
TimestampContent,
|
|
21
|
+
FieldContent,
|
|
22
|
+
} from "./content/field"
|
|
23
|
+
export type { GeoPointContent } from "./content/geopoint"
|
|
24
|
+
export type { GroupContent, GroupItemContent } from "./content/group"
|
|
25
|
+
export type { ImageContent, ImageContentView } from "./content/image"
|
|
26
|
+
export type { IntegrationFieldContent } from "./content/integrationField"
|
|
27
|
+
export type { EmptyLinkContent, FilledLinkContent, LinkContent } from "./content/link"
|
|
28
|
+
export type { NestableContent } from "./content/nestable"
|
|
29
|
+
export type { RepeatableContent } from "./content/repeatable"
|
|
30
|
+
export type {
|
|
31
|
+
RichTextContent,
|
|
32
|
+
RichTextContentBlock,
|
|
33
|
+
RichTextContentTextBlock,
|
|
34
|
+
RichTextContentImageBlock,
|
|
35
|
+
RichTextContentEmbedBlock,
|
|
36
|
+
RichTextContentSpan,
|
|
37
|
+
RichTextNodeTypes,
|
|
38
|
+
} from "./content/richText"
|
|
39
|
+
export { RichTextNodeType } from "./content/richText"
|
|
40
|
+
export type { SeparatorContent } from "./content/separator"
|
|
41
|
+
export type {
|
|
42
|
+
LegacySliceContent,
|
|
43
|
+
CompositeSliceContent,
|
|
44
|
+
SharedSliceContent,
|
|
45
|
+
SliceContent,
|
|
46
|
+
} from "./content/slice"
|
|
47
|
+
export type {
|
|
48
|
+
LegacySliceItemContent,
|
|
49
|
+
CompositeSliceItemContent,
|
|
50
|
+
SharedSliceItemContent,
|
|
51
|
+
SliceItemContent,
|
|
52
|
+
SlicesContent,
|
|
53
|
+
} from "./content/slices"
|
|
54
|
+
export type { TableContent } from "./content/table"
|
|
55
|
+
export type { UIDContent } from "./content/uid"
|
|
56
|
+
export type { WidgetContent } from "./content/widget"
|
|
57
|
+
|
|
58
|
+
// Model
|
|
59
|
+
export type { BooleanModel } from "./model/boolean"
|
|
60
|
+
export type { ColorModel } from "./model/color"
|
|
61
|
+
export type { StaticCustomTypeModel, CustomTypeModel } from "./model/customType"
|
|
62
|
+
export type { DateModel } from "./model/date"
|
|
63
|
+
export type { EmbedModel } from "./model/embed"
|
|
64
|
+
export type { GeoPointModel } from "./model/geopoint"
|
|
65
|
+
export type { GroupModel, NestedGroupModel } from "./model/group"
|
|
66
|
+
export type { ImageModel } from "./model/image"
|
|
67
|
+
export type { IntegrationFieldModel } from "./model/integrationField"
|
|
68
|
+
export type { LinkModel } from "./model/link"
|
|
69
|
+
export type { NestableModel } from "./model/nestable"
|
|
70
|
+
export type { NumberModel } from "./model/number"
|
|
71
|
+
export type { RangeModel } from "./model/range"
|
|
72
|
+
export type { RichTextModel, RichTextModelNodeTypes } from "./model/richText"
|
|
73
|
+
export { RichTextModelNodeType } from "./model/richText"
|
|
74
|
+
export type { StaticSectionModel, DynamicSectionModel } from "./model/section"
|
|
75
|
+
export type { SelectModel } from "./model/select"
|
|
76
|
+
export type { SeparatorModel } from "./model/separator"
|
|
77
|
+
export type {
|
|
78
|
+
LegacySliceModel,
|
|
79
|
+
CompositeSliceModel,
|
|
80
|
+
SharedSliceModel,
|
|
81
|
+
SharedSliceRefModel,
|
|
82
|
+
SharedSliceModelVariation,
|
|
83
|
+
SharedSliceVariationContentModel,
|
|
84
|
+
StaticSliceModel,
|
|
85
|
+
DynamicSliceModel,
|
|
86
|
+
SliceContentModel,
|
|
87
|
+
SliceModelType,
|
|
88
|
+
} from "./model/slice"
|
|
89
|
+
export type { DynamicSlicesModel, StaticSlicesModel } from "./model/slices"
|
|
90
|
+
export type { TableModel } from "./model/table"
|
|
91
|
+
export { TableCellModelNodeTypes } from "./model/table"
|
|
92
|
+
export type { TextModel } from "./model/text"
|
|
93
|
+
export type { TimestampModel } from "./model/timestamp"
|
|
94
|
+
export type { UIDModel } from "./model/uid"
|
|
95
|
+
export type { StaticWidgetModel, DynamicWidgetModel, FieldModelType } from "./model/widget"
|
|
96
|
+
|
|
97
|
+
// Legacy
|
|
98
|
+
export { LegacyContentCtx, getFieldCtx, defaultCtx } from "./content/codec/legacyContentCtx"
|
|
99
|
+
|
|
100
|
+
// Helpers
|
|
101
|
+
export * as contentPath from "./helpers/contentPath"
|
|
102
|
+
export * as customTypeModel from "./helpers/customTypeModel"
|
|
103
|
+
export * as documentContent from "./helpers/documentContent"
|
|
104
|
+
export * as sliceContent from "./helpers/sliceContent"
|
|
105
|
+
export * as withDefaultContent from "./helpers/withDefaultContent"
|
|
106
|
+
export * as imageContent from "./helpers/imageContent"
|
|
107
|
+
export {
|
|
108
|
+
traverseDocumentContent,
|
|
109
|
+
traverseSlicesContent,
|
|
110
|
+
traverseSharedSliceContent,
|
|
111
|
+
traverseCompositeSliceContent,
|
|
112
|
+
traverseLegacySliceContent,
|
|
113
|
+
traverseGroupContent,
|
|
114
|
+
traverseGroupItemsContent,
|
|
115
|
+
traverseRepeatableContent,
|
|
116
|
+
traverseTableContent,
|
|
117
|
+
} from "./helpers/traverseContent"
|
|
118
|
+
export type {
|
|
119
|
+
TraverseSliceContentFunction,
|
|
120
|
+
TraverseWidgetContentFunction,
|
|
121
|
+
} from "./helpers/traverseContent"
|
|
122
|
+
export {
|
|
123
|
+
traverseDocumentContentWithModel,
|
|
124
|
+
traverseSlicesContentWithModel,
|
|
125
|
+
traverseSharedSliceContentWithModel,
|
|
126
|
+
traverseCompositeSliceContentWithModel,
|
|
127
|
+
traverseLegacySliceContentWithModel,
|
|
128
|
+
traverseGroupContentWithModel,
|
|
129
|
+
traverseGroupItemsContentWithModel,
|
|
130
|
+
traverseRepeatableContentWithModel,
|
|
131
|
+
traverseTableContentWithModel,
|
|
132
|
+
} from "./helpers/traverseContentWithModel"
|
|
133
|
+
export type {
|
|
134
|
+
TraverseSliceContentWithModelFunction,
|
|
135
|
+
TraverseWidgetContentWithModelFunction,
|
|
136
|
+
} from "./helpers/traverseContentWithModel"
|
package/src/io-ts.ts
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import * as t from "io-ts"
|
|
2
|
+
import type { ZodMiniType } from "zod/mini"
|
|
3
|
+
|
|
4
|
+
// Common
|
|
5
|
+
import { AssetSchema as rawAssetSchema } from "./common/asset"
|
|
6
|
+
import { EmbedSchema as rawEmbedSchema } from "./common/embed"
|
|
7
|
+
import { HexaColorCodeSchema as rawHexaColorCodeSchema } from "./common/hexaColorCode"
|
|
8
|
+
import { NonEmptyStringSchema as rawNonEmptyStringSchema } from "./common/nonEmptyString"
|
|
9
|
+
import { WidgetKeySchema as rawWidgetKeySchema } from "./common/widgetKey"
|
|
10
|
+
// Content
|
|
11
|
+
import { BooleanContentSchema as rawBooleanContentSchema } from "./content/boolean"
|
|
12
|
+
import { BooleanLegacyCodec } from "./content/codec/boolean"
|
|
13
|
+
import { DocumentLegacyCodec } from "./content/codec/document"
|
|
14
|
+
import { EmbedLegacyCodec } from "./content/codec/embed"
|
|
15
|
+
import { EmptyLegacyCodec } from "./content/codec/empty"
|
|
16
|
+
import {
|
|
17
|
+
ColorLegacyCodec,
|
|
18
|
+
DateLegacyCodec,
|
|
19
|
+
NumberLegacyCodec,
|
|
20
|
+
RangeLegacyCodec,
|
|
21
|
+
SelectLegacyCodec,
|
|
22
|
+
TextLegacyCodec,
|
|
23
|
+
TimestampLegacyCodec,
|
|
24
|
+
} from "./content/codec/field"
|
|
25
|
+
import { GeoPointLegacyCodec } from "./content/codec/geopoint"
|
|
26
|
+
import { GroupItemLegacyCodec, GroupLegacyCodec } from "./content/codec/group"
|
|
27
|
+
import { ImageLegacyCodec } from "./content/codec/image"
|
|
28
|
+
import { IntegrationFieldLegacyCodec } from "./content/codec/integrationField"
|
|
29
|
+
import type { LegacyCodec } from "./content/codec/legacyContentCtx"
|
|
30
|
+
import { LinkLegacyCodec } from "./content/codec/link"
|
|
31
|
+
import { NestableLegacyCodec } from "./content/codec/nestable"
|
|
32
|
+
import { RepeatableLegacyCodec } from "./content/codec/repeatable"
|
|
33
|
+
import { RichTextLegacyCodec } from "./content/codec/richText"
|
|
34
|
+
import { SeparatorLegacyCodec } from "./content/codec/separator"
|
|
35
|
+
import {
|
|
36
|
+
CompositeSliceLegacyCodec,
|
|
37
|
+
SharedSliceLegacyCodec,
|
|
38
|
+
LegacySliceLegacyCodec,
|
|
39
|
+
SliceLegacyCodec,
|
|
40
|
+
} from "./content/codec/slice"
|
|
41
|
+
import { SliceItemLegacyCodec, SlicesLegacyCodec } from "./content/codec/slices"
|
|
42
|
+
import { TableLegacyCodec } from "./content/codec/table"
|
|
43
|
+
import { UIDLegacyCodec } from "./content/codec/uid"
|
|
44
|
+
import { WidgetLegacyCodec } from "./content/codec/widget"
|
|
45
|
+
import { DocumentContentSchema as rawDocumentContentSchema } from "./content/document"
|
|
46
|
+
import { EmbedContentSchema as rawEmbedContentSchema } from "./content/embed"
|
|
47
|
+
import { EmptyContentSchema as rawEmptyContentSchema } from "./content/empty"
|
|
48
|
+
import {
|
|
49
|
+
ColorContentSchema as rawColorContentSchema,
|
|
50
|
+
DateContentSchema as rawDateContentSchema,
|
|
51
|
+
NumberContentSchema as rawNumberContentSchema,
|
|
52
|
+
RangeContentSchema as rawRangeContentSchema,
|
|
53
|
+
SelectContentSchema as rawSelectContentSchema,
|
|
54
|
+
TextContentSchema as rawTextContentSchema,
|
|
55
|
+
TimestampContentSchema as rawTimestampContentSchema,
|
|
56
|
+
FieldContentSchema as rawFieldContentSchema,
|
|
57
|
+
} from "./content/field"
|
|
58
|
+
import { GeoPointContentSchema as rawGeoPointContentSchema } from "./content/geopoint"
|
|
59
|
+
import {
|
|
60
|
+
GroupContentSchema as rawGroupContentSchema,
|
|
61
|
+
GroupItemContentSchema as rawGroupItemContentSchema,
|
|
62
|
+
} from "./content/group"
|
|
63
|
+
import {
|
|
64
|
+
ImageContentSchema as rawImageContentSchema,
|
|
65
|
+
ImageContentViewSchema as rawImageContentViewSchema,
|
|
66
|
+
} from "./content/image"
|
|
67
|
+
import { IntegrationFieldContentSchema as rawIntegrationFieldContentSchema } from "./content/integrationField"
|
|
68
|
+
import {
|
|
69
|
+
EmptyLinkContentSchema as rawEmptyLinkContentSchema,
|
|
70
|
+
FilledLinkContentSchema as rawFilledLinkContentSchema,
|
|
71
|
+
LinkContentSchema as rawLinkContentSchema,
|
|
72
|
+
} from "./content/link"
|
|
73
|
+
import { NestableContentSchema as rawNestableContentSchema } from "./content/nestable"
|
|
74
|
+
import { RepeatableContentSchema as rawRepeatableContentSchema } from "./content/repeatable"
|
|
75
|
+
import {
|
|
76
|
+
RichTextContentSchema as rawRichTextContentSchema,
|
|
77
|
+
RichTextContentBlockSchema as rawRichTextContentBlockSchema,
|
|
78
|
+
RichTextContentSpanSchema as rawRichTextContentSpanSchema,
|
|
79
|
+
} from "./content/richText"
|
|
80
|
+
import { SeparatorContentSchema as rawSeparatorContentSchema } from "./content/separator"
|
|
81
|
+
import {
|
|
82
|
+
LegacySliceContentSchema as rawLegacySliceContentSchema,
|
|
83
|
+
CompositeSliceContentSchema as rawCompositeSliceContentSchema,
|
|
84
|
+
SharedSliceContentSchema as rawSharedSliceContentSchema,
|
|
85
|
+
SliceContentSchema as rawSliceContentSchema,
|
|
86
|
+
} from "./content/slice"
|
|
87
|
+
import {
|
|
88
|
+
LegacySliceItemContentSchema as rawLegacySliceItemContentSchema,
|
|
89
|
+
CompositeSliceItemContentSchema as rawCompositeSliceItemContentSchema,
|
|
90
|
+
SharedSliceItemContentSchema as rawSharedSliceItemContentSchema,
|
|
91
|
+
SliceItemContentSchema as rawSliceItemContentSchema,
|
|
92
|
+
SlicesContentSchema as rawSlicesContentSchema,
|
|
93
|
+
} from "./content/slices"
|
|
94
|
+
import { TableContentSchema as rawTableContentSchema } from "./content/table"
|
|
95
|
+
import { UIDContentSchema as rawUIDContentSchema } from "./content/uid"
|
|
96
|
+
import { WidgetContentSchema as rawWidgetContentSchema } from "./content/widget"
|
|
97
|
+
// Model
|
|
98
|
+
import { BooleanModelSchema as rawBooleanModelSchema } from "./model/boolean"
|
|
99
|
+
import { ColorModelSchema as rawColorModelSchema } from "./model/color"
|
|
100
|
+
import {
|
|
101
|
+
StaticCustomTypeModelSchema as rawStaticCustomTypeModelSchema,
|
|
102
|
+
CustomTypeModelSchema as rawCustomTypeModelSchema,
|
|
103
|
+
} from "./model/customType"
|
|
104
|
+
import { DateModelSchema as rawDateModelSchema } from "./model/date"
|
|
105
|
+
import { EmbedModelSchema as rawEmbedModelSchema } from "./model/embed"
|
|
106
|
+
import { GeoPointModelSchema as rawGeoPointModelSchema } from "./model/geopoint"
|
|
107
|
+
import {
|
|
108
|
+
GroupModelSchema as rawGroupModelSchema,
|
|
109
|
+
NestedGroupModelSchema as rawNestedGroupModelSchema,
|
|
110
|
+
} from "./model/group"
|
|
111
|
+
import { ImageModelSchema as rawImageModelSchema } from "./model/image"
|
|
112
|
+
import { IntegrationFieldModelSchema as rawIntegrationFieldModelSchema } from "./model/integrationField"
|
|
113
|
+
import { LinkModelSchema as rawLinkModelSchema } from "./model/link"
|
|
114
|
+
import { NestableModelSchema as rawNestableModelSchema } from "./model/nestable"
|
|
115
|
+
import { NumberModelSchema as rawNumberModelSchema } from "./model/number"
|
|
116
|
+
import { RangeModelSchema as rawRangeModelSchema } from "./model/range"
|
|
117
|
+
import { RichTextModelSchema as rawRichTextModelSchema } from "./model/richText"
|
|
118
|
+
import {
|
|
119
|
+
StaticSectionModelSchema as rawStaticSectionModelSchema,
|
|
120
|
+
DynamicSectionModelSchema as rawDynamicSectionModelSchema,
|
|
121
|
+
} from "./model/section"
|
|
122
|
+
import { SelectModelSchema as rawSelectModelSchema } from "./model/select"
|
|
123
|
+
import { SeparatorModelSchema as rawSeparatorModelSchema } from "./model/separator"
|
|
124
|
+
import {
|
|
125
|
+
LegacySliceModelSchema as rawLegacySliceModelSchema,
|
|
126
|
+
CompositeSliceModelSchema as rawCompositeSliceModelSchema,
|
|
127
|
+
SharedSliceModelSchema as rawSharedSliceModelSchema,
|
|
128
|
+
SharedSliceModelVariationSchema as rawSharedSliceModelVariationSchema,
|
|
129
|
+
SharedSliceRefModelSchema as rawSharedSliceRefModelSchema,
|
|
130
|
+
StaticSliceModelSchema as rawStaticSliceModelSchema,
|
|
131
|
+
DynamicSliceModelSchema as rawDynamicSliceModelSchema,
|
|
132
|
+
SliceContentModelSchema as rawSliceContentModelSchema,
|
|
133
|
+
} from "./model/slice"
|
|
134
|
+
import {
|
|
135
|
+
DynamicSlicesModelSchema as rawDynamicSlicesModelSchema,
|
|
136
|
+
StaticSlicesModelSchema as rawStaticSlicesModelSchema,
|
|
137
|
+
} from "./model/slices"
|
|
138
|
+
import { TableModelSchema as rawTableModelSchema } from "./model/table"
|
|
139
|
+
import { TextModelSchema as rawTextModelSchema } from "./model/text"
|
|
140
|
+
import { TimestampModelSchema as rawTimestampModelSchema } from "./model/timestamp"
|
|
141
|
+
import { UIDModelSchema as rawUIDModelSchema } from "./model/uid"
|
|
142
|
+
import {
|
|
143
|
+
StaticWidgetModelSchema as rawStaticWidgetModelSchema,
|
|
144
|
+
DynamicWidgetModelSchema as rawDynamicWidgetModelSchema,
|
|
145
|
+
} from "./model/widget"
|
|
146
|
+
|
|
147
|
+
// Common
|
|
148
|
+
export const AssetSchema = toIOTS(rawAssetSchema)
|
|
149
|
+
export const EmbedSchema = toIOTS(rawEmbedSchema)
|
|
150
|
+
export const HexaColorCodeSchema = toIOTS(rawHexaColorCodeSchema)
|
|
151
|
+
export const NonEmptyStringSchema = toIOTS(rawNonEmptyStringSchema)
|
|
152
|
+
export const WidgetKeySchema = toIOTS(rawWidgetKeySchema)
|
|
153
|
+
|
|
154
|
+
// Content
|
|
155
|
+
export const BooleanContentSchema = toIOTS(rawBooleanContentSchema)
|
|
156
|
+
export const ColorContentSchema = toIOTS(rawColorContentSchema)
|
|
157
|
+
export const DateContentSchema = toIOTS(rawDateContentSchema)
|
|
158
|
+
export const EmptyContentSchema = toIOTS(rawEmptyContentSchema)
|
|
159
|
+
export const GeoPointContentSchema = toIOTS(rawGeoPointContentSchema)
|
|
160
|
+
export const FilledLinkContentSchema = toIOTS(rawFilledLinkContentSchema)
|
|
161
|
+
export const EmptyLinkContentSchema = toIOTS(rawEmptyLinkContentSchema)
|
|
162
|
+
export const LinkContentSchema = toIOTS(rawLinkContentSchema)
|
|
163
|
+
export const NumberContentSchema = toIOTS(rawNumberContentSchema)
|
|
164
|
+
export const RangeContentSchema = toIOTS(rawRangeContentSchema)
|
|
165
|
+
export const SelectContentSchema = toIOTS(rawSelectContentSchema)
|
|
166
|
+
export const SeparatorContentSchema = toIOTS(rawSeparatorContentSchema)
|
|
167
|
+
export const SharedSliceContentSchema = toIOTS(rawSharedSliceContentSchema)
|
|
168
|
+
export const TextContentSchema = toIOTS(rawTextContentSchema)
|
|
169
|
+
export const TimestampContentSchema = toIOTS(rawTimestampContentSchema)
|
|
170
|
+
export const FieldContentSchema = toIOTS(rawFieldContentSchema)
|
|
171
|
+
export const UIDContentSchema = toIOTS(rawUIDContentSchema)
|
|
172
|
+
export const IntegrationFieldContentSchema = toIOTS(rawIntegrationFieldContentSchema)
|
|
173
|
+
export const EmbedContentSchema = toIOTS(rawEmbedContentSchema)
|
|
174
|
+
export const ImageContentViewSchema = toIOTS(rawImageContentViewSchema)
|
|
175
|
+
export const ImageContentSchema = toIOTS(rawImageContentSchema)
|
|
176
|
+
export const RichTextContentSchema = toIOTS(rawRichTextContentSchema)
|
|
177
|
+
export const RichTextContentBlockSchema = toIOTS(rawRichTextContentBlockSchema)
|
|
178
|
+
export const RichTextContentSpanSchema = toIOTS(rawRichTextContentSpanSchema)
|
|
179
|
+
export const TableContentSchema = toIOTS(rawTableContentSchema)
|
|
180
|
+
export const RepeatableContentSchema = toIOTS(rawRepeatableContentSchema)
|
|
181
|
+
export const NestableContentSchema = toIOTS(rawNestableContentSchema)
|
|
182
|
+
export const GroupContentSchema = toIOTS(rawGroupContentSchema)
|
|
183
|
+
export const GroupItemContentSchema = toIOTS(rawGroupItemContentSchema)
|
|
184
|
+
export const CompositeSliceContentSchema = toIOTS(rawCompositeSliceContentSchema)
|
|
185
|
+
export const LegacySliceContentSchema = toIOTS(rawLegacySliceContentSchema)
|
|
186
|
+
export const SliceContentSchema = toIOTS(rawSliceContentSchema)
|
|
187
|
+
export const LegacySliceItemContentSchema = toIOTS(rawLegacySliceItemContentSchema)
|
|
188
|
+
export const CompositeSliceItemContentSchema = toIOTS(rawCompositeSliceItemContentSchema)
|
|
189
|
+
export const SharedSliceItemContentSchema = toIOTS(rawSharedSliceItemContentSchema)
|
|
190
|
+
export const SliceItemContentSchema = toIOTS(rawSliceItemContentSchema)
|
|
191
|
+
export const SlicesContentSchema = toIOTS(rawSlicesContentSchema)
|
|
192
|
+
export const WidgetContentSchema = toIOTS(rawWidgetContentSchema)
|
|
193
|
+
export const DocumentContentSchema = toIOTS(rawDocumentContentSchema)
|
|
194
|
+
|
|
195
|
+
// Content legacy
|
|
196
|
+
export const BooleanLegacy = toIOTSCodec(BooleanLegacyCodec)
|
|
197
|
+
export const EmptyLegacy = toIOTSCodec(EmptyLegacyCodec)
|
|
198
|
+
export const TextLegacy = toIOTSCodec(TextLegacyCodec)
|
|
199
|
+
export const ColorLegacy = toIOTSCodec(ColorLegacyCodec)
|
|
200
|
+
export const DateLegacy = toIOTSCodec(DateLegacyCodec)
|
|
201
|
+
export const TimestampLegacy = toIOTSCodec(TimestampLegacyCodec)
|
|
202
|
+
export const NumberLegacy = toIOTSCodec(NumberLegacyCodec)
|
|
203
|
+
export const RangeLegacy = toIOTSCodec(RangeLegacyCodec)
|
|
204
|
+
export const SelectLegacy = toIOTSCodec(SelectLegacyCodec)
|
|
205
|
+
export const GeoPointLegacy = toIOTSCodec(GeoPointLegacyCodec)
|
|
206
|
+
export const EmbedLegacy = toIOTSCodec(EmbedLegacyCodec)
|
|
207
|
+
export const ImageLegacy = toIOTSCodec(ImageLegacyCodec)
|
|
208
|
+
export const LinkLegacy = toIOTSCodec(LinkLegacyCodec)
|
|
209
|
+
export const RepeatableLegacy = toIOTSCodec(RepeatableLegacyCodec)
|
|
210
|
+
export const RichTextLegacy = toIOTSCodec(RichTextLegacyCodec)
|
|
211
|
+
export const SeparatorLegacy = toIOTSCodec(SeparatorLegacyCodec)
|
|
212
|
+
export const IntegrationFieldLegacy = toIOTSCodec(IntegrationFieldLegacyCodec)
|
|
213
|
+
export const TableLegacy = toIOTSCodec(TableLegacyCodec)
|
|
214
|
+
export const NestableLegacy = toIOTSCodec(NestableLegacyCodec)
|
|
215
|
+
export const UIDLegacy = toIOTSCodec(UIDLegacyCodec)
|
|
216
|
+
export const GroupItemLegacy = toIOTSCodec(GroupItemLegacyCodec)
|
|
217
|
+
export const GroupLegacy = toIOTSCodec(GroupLegacyCodec)
|
|
218
|
+
export const LegacySliceLegacy = toIOTSCodec(LegacySliceLegacyCodec)
|
|
219
|
+
export const CompositeSliceLegacy = toIOTSCodec(CompositeSliceLegacyCodec)
|
|
220
|
+
export const SharedSliceLegacy = toIOTSCodec(SharedSliceLegacyCodec)
|
|
221
|
+
export const SliceLegacy = toIOTSCodec(SliceLegacyCodec)
|
|
222
|
+
export const SliceItemLegacy = toIOTSCodec(SliceItemLegacyCodec)
|
|
223
|
+
export const SlicesLegacy = toIOTSCodec(SlicesLegacyCodec)
|
|
224
|
+
export const WidgetLegacy = toIOTSCodec(WidgetLegacyCodec)
|
|
225
|
+
export const DocumentLegacy = toIOTSCodec(DocumentLegacyCodec)
|
|
226
|
+
|
|
227
|
+
// Model
|
|
228
|
+
export const BooleanModelSchema = toIOTS(rawBooleanModelSchema)
|
|
229
|
+
export const ColorModelSchema = toIOTS(rawColorModelSchema)
|
|
230
|
+
export const DateModelSchema = toIOTS(rawDateModelSchema)
|
|
231
|
+
export const EmbedModelSchema = toIOTS(rawEmbedModelSchema)
|
|
232
|
+
export const GeoPointModelSchema = toIOTS(rawGeoPointModelSchema)
|
|
233
|
+
export const ImageModelSchema = toIOTS(rawImageModelSchema)
|
|
234
|
+
export const IntegrationFieldModelSchema = toIOTS(rawIntegrationFieldModelSchema)
|
|
235
|
+
export const LinkModelSchema = toIOTS(rawLinkModelSchema)
|
|
236
|
+
export const NestableModelSchema = toIOTS(rawNestableModelSchema)
|
|
237
|
+
export const NumberModelSchema = toIOTS(rawNumberModelSchema)
|
|
238
|
+
export const RangeModelSchema = toIOTS(rawRangeModelSchema)
|
|
239
|
+
export const RichTextModelSchema = toIOTS(rawRichTextModelSchema)
|
|
240
|
+
export const SelectModelSchema = toIOTS(rawSelectModelSchema)
|
|
241
|
+
export const SeparatorModelSchema = toIOTS(rawSeparatorModelSchema)
|
|
242
|
+
export const SharedSliceModelSchema = toIOTS(rawSharedSliceModelSchema)
|
|
243
|
+
export const TableModelSchema = toIOTS(rawTableModelSchema)
|
|
244
|
+
export const TextModelSchema = toIOTS(rawTextModelSchema)
|
|
245
|
+
export const TimestampModelSchema = toIOTS(rawTimestampModelSchema)
|
|
246
|
+
export const UIDModelSchema = toIOTS(rawUIDModelSchema)
|
|
247
|
+
export const GroupModelSchema = toIOTS(rawGroupModelSchema)
|
|
248
|
+
export const NestedGroupModelSchema = toIOTS(rawNestedGroupModelSchema)
|
|
249
|
+
export const SharedSliceModelVariationSchema = toIOTS(rawSharedSliceModelVariationSchema)
|
|
250
|
+
export const SharedSliceRefModelSchema = toIOTS(rawSharedSliceRefModelSchema)
|
|
251
|
+
export const CompositeSliceModelSchema = toIOTS(rawCompositeSliceModelSchema)
|
|
252
|
+
export const LegacySliceModelSchema = toIOTS(rawLegacySliceModelSchema)
|
|
253
|
+
export const DynamicSliceModelSchema = toIOTS(rawDynamicSliceModelSchema)
|
|
254
|
+
export const StaticSliceModelSchema = toIOTS(rawStaticSliceModelSchema)
|
|
255
|
+
export const SliceContentModelSchema = toIOTS(rawSliceContentModelSchema)
|
|
256
|
+
export const DynamicSlicesModelSchema = toIOTS(rawDynamicSlicesModelSchema)
|
|
257
|
+
export const StaticSlicesModelSchema = toIOTS(rawStaticSlicesModelSchema)
|
|
258
|
+
export const StaticWidgetModelSchema = toIOTS(rawStaticWidgetModelSchema)
|
|
259
|
+
export const DynamicWidgetModelSchema = toIOTS(rawDynamicWidgetModelSchema)
|
|
260
|
+
export const StaticSectionModelSchema = toIOTS(rawStaticSectionModelSchema)
|
|
261
|
+
export const DynamicSectionModelSchema = toIOTS(rawDynamicSectionModelSchema)
|
|
262
|
+
export const StaticCustomTypeModelSchema = toIOTS(rawStaticCustomTypeModelSchema)
|
|
263
|
+
export const CustomTypeModelSchema = toIOTS(rawCustomTypeModelSchema)
|
|
264
|
+
|
|
265
|
+
function toIOTS<T>(type: ZodMiniType<T>): t.Type<T> {
|
|
266
|
+
return new t.Type<T>(
|
|
267
|
+
"Type",
|
|
268
|
+
(input): input is T => type.safeParse(input).success,
|
|
269
|
+
(input, context) => {
|
|
270
|
+
const result = type.safeParse(input)
|
|
271
|
+
return result.success
|
|
272
|
+
? t.success(result.data)
|
|
273
|
+
: t.failure(
|
|
274
|
+
input,
|
|
275
|
+
context,
|
|
276
|
+
result.error.issues.map((issue) => formatIssue(issue, input)).join("\n"),
|
|
277
|
+
)
|
|
278
|
+
},
|
|
279
|
+
t.identity,
|
|
280
|
+
)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function toIOTSCodec<TArgs extends unknown[], A, LegacyRaw, AllowUndefined extends boolean>(
|
|
284
|
+
codecFactory: (...args: TArgs) => LegacyCodec<A, LegacyRaw, AllowUndefined>,
|
|
285
|
+
): (
|
|
286
|
+
...args: TArgs
|
|
287
|
+
) => t.Type<A, ReturnType<LegacyCodec<A, LegacyRaw, AllowUndefined>["fromContent"]>, unknown> {
|
|
288
|
+
return (...args: TArgs) => {
|
|
289
|
+
const codec = codecFactory(...args)
|
|
290
|
+
return new t.Type<
|
|
291
|
+
A,
|
|
292
|
+
ReturnType<LegacyCodec<A, LegacyRaw, AllowUndefined>["fromContent"]>,
|
|
293
|
+
unknown
|
|
294
|
+
>(
|
|
295
|
+
codec.name,
|
|
296
|
+
codec.is,
|
|
297
|
+
(input, context) => {
|
|
298
|
+
const result = codec.toContent(input)
|
|
299
|
+
return result.success
|
|
300
|
+
? t.success(result.data)
|
|
301
|
+
: t.failure(
|
|
302
|
+
input,
|
|
303
|
+
context,
|
|
304
|
+
result.error.issues.map((issue) => formatIssue(issue, input)).join("\n"),
|
|
305
|
+
)
|
|
306
|
+
},
|
|
307
|
+
codec.fromContent,
|
|
308
|
+
)
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
interface ZodIssue {
|
|
313
|
+
code: string
|
|
314
|
+
message: string
|
|
315
|
+
path?: PropertyKey[]
|
|
316
|
+
expected?: string
|
|
317
|
+
values?: unknown[]
|
|
318
|
+
keys?: string[]
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function resolveValue(input: unknown, path: PropertyKey[]): unknown {
|
|
322
|
+
let current = input
|
|
323
|
+
for (const key of path) {
|
|
324
|
+
if (current == null || typeof current !== "object") return undefined
|
|
325
|
+
current = (current as Record<PropertyKey, unknown>)[key]
|
|
326
|
+
}
|
|
327
|
+
return current
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function formatValue(value: unknown): string {
|
|
331
|
+
if (value === null) return "null"
|
|
332
|
+
if (value === undefined) return "undefined"
|
|
333
|
+
if (typeof value === "string") return JSON.stringify(value)
|
|
334
|
+
return String(value)
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function formatIssue(issue: ZodIssue, input: unknown): string {
|
|
338
|
+
if (issue.code === "custom" && issue.message !== "Invalid input") {
|
|
339
|
+
return issue.message
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const value = resolveValue(input, issue.path ?? [])
|
|
343
|
+
const pathStr = issue.path?.length ? issue.path.join(".") : undefined
|
|
344
|
+
|
|
345
|
+
if (issue.code === "invalid_value" && issue.values) {
|
|
346
|
+
const expected = issue.values.map(formatValue).join(", ")
|
|
347
|
+
return pathStr
|
|
348
|
+
? `Invalid value ${formatValue(value)} at .${pathStr}: expected ${expected}`
|
|
349
|
+
: `Invalid value ${formatValue(value)}: expected ${expected}`
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if (issue.code === "invalid_type" && issue.expected) {
|
|
353
|
+
return pathStr
|
|
354
|
+
? `Invalid value ${formatValue(value)} at .${pathStr}: expected ${issue.expected}`
|
|
355
|
+
: `Invalid value ${formatValue(value)}: expected ${issue.expected}`
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (issue.code === "unrecognized_keys" && issue.keys) {
|
|
359
|
+
return `Unrecognized key(s): ${issue.keys.join(", ")}`
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return issue.message
|
|
363
|
+
}
|