@prismicio/types-internal 0.1.1 → 0.2.3
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 +13 -13
- package/{dist → lib}/customtypes/CustomType.d.ts +697 -715
- package/{dist → lib}/customtypes/CustomType.js +42 -52
- package/{dist → lib}/customtypes/Format.d.ts +0 -0
- package/{dist → lib}/customtypes/Format.js +0 -0
- package/{dist → lib}/customtypes/Section.d.ts +1035 -1062
- package/lib/customtypes/Section.js +21 -0
- package/lib/customtypes/index.d.ts +4 -0
- package/lib/customtypes/index.js +9 -0
- package/{dist → lib}/customtypes/widgets/Group.d.ts +45 -45
- package/lib/customtypes/widgets/Group.js +24 -0
- package/{dist → lib}/customtypes/widgets/UID.d.ts +4 -4
- package/lib/customtypes/widgets/UID.js +21 -0
- package/{dist → lib}/customtypes/widgets/Widget.d.ts +1036 -1063
- package/lib/customtypes/widgets/Widget.js +27 -0
- package/{dist → lib}/customtypes/widgets/WidgetTypes.d.ts +0 -0
- package/{dist → lib}/customtypes/widgets/WidgetTypes.js +0 -0
- package/lib/customtypes/widgets/index.d.ts +7 -0
- package/lib/customtypes/widgets/index.js +14 -0
- package/{dist → lib}/customtypes/widgets/nestable/BooleanField.d.ts +3 -3
- package/lib/customtypes/widgets/nestable/BooleanField.js +21 -0
- package/{dist → lib}/customtypes/widgets/nestable/Color.d.ts +4 -4
- package/lib/customtypes/widgets/nestable/Color.js +20 -0
- package/{dist → lib}/customtypes/widgets/nestable/Date.d.ts +4 -4
- package/lib/customtypes/widgets/nestable/Date.js +21 -0
- package/{dist → lib}/customtypes/widgets/nestable/Embed.d.ts +4 -4
- package/lib/customtypes/widgets/nestable/Embed.js +21 -0
- package/{dist → lib}/customtypes/widgets/nestable/GeoPoint.d.ts +4 -4
- package/lib/customtypes/widgets/nestable/GeoPoint.js +19 -0
- package/lib/customtypes/widgets/nestable/Image.d.ts +23 -0
- package/lib/customtypes/widgets/nestable/Image.js +29 -0
- package/{dist → lib}/customtypes/widgets/nestable/IntegrationField.d.ts +4 -4
- package/lib/customtypes/widgets/nestable/IntegrationField.js +21 -0
- package/{dist → lib}/customtypes/widgets/nestable/Link.d.ts +4 -4
- package/lib/customtypes/widgets/nestable/Link.js +54 -0
- package/{dist → lib}/customtypes/widgets/nestable/NestableWidget.d.ts +42 -42
- package/lib/customtypes/widgets/nestable/NestableWidget.js +37 -0
- package/{dist → lib}/customtypes/widgets/nestable/Number.d.ts +4 -4
- package/lib/customtypes/widgets/nestable/Number.js +24 -0
- package/{dist → lib}/customtypes/widgets/nestable/Range.d.ts +4 -4
- package/lib/customtypes/widgets/nestable/Range.js +24 -0
- package/{dist → lib}/customtypes/widgets/nestable/RichText.d.ts +6 -6
- package/lib/customtypes/widgets/nestable/RichText.js +111 -0
- package/lib/customtypes/widgets/nestable/Select.d.ts +15 -0
- package/lib/customtypes/widgets/nestable/Select.js +22 -0
- package/{dist → lib}/customtypes/widgets/nestable/Separator.d.ts +3 -3
- package/lib/customtypes/widgets/nestable/Separator.js +18 -0
- package/{dist → lib}/customtypes/widgets/nestable/Text.d.ts +4 -4
- package/lib/customtypes/widgets/nestable/Text.js +21 -0
- package/{dist → lib}/customtypes/widgets/nestable/Timestamp.d.ts +4 -4
- package/lib/customtypes/widgets/nestable/Timestamp.js +21 -0
- package/lib/customtypes/widgets/nestable/index.d.ts +15 -0
- package/{dist → lib}/customtypes/widgets/nestable/index.js +0 -0
- package/{dist → lib}/customtypes/widgets/shared/ImageConstraint.d.ts +3 -3
- package/lib/customtypes/widgets/shared/ImageConstraint.js +31 -0
- package/lib/customtypes/widgets/shared/index.d.ts +1 -0
- package/{dist → lib}/customtypes/widgets/shared/index.js +0 -0
- package/{dist → lib}/customtypes/widgets/slices/CompositeSlice.d.ts +87 -87
- package/lib/customtypes/widgets/slices/CompositeSlice.js +25 -0
- package/{dist → lib}/customtypes/widgets/slices/LegacySlice.d.ts +86 -95
- package/lib/customtypes/widgets/slices/LegacySlice.js +8 -0
- package/{dist → lib}/customtypes/widgets/slices/SharedSlice.d.ts +84 -84
- package/lib/customtypes/widgets/slices/SharedSlice.js +35 -0
- package/{dist → lib}/customtypes/widgets/slices/SharedSliceRef.d.ts +2 -2
- package/lib/customtypes/widgets/slices/SharedSliceRef.js +9 -0
- package/lib/customtypes/widgets/slices/Slice.d.ts +6 -0
- package/{dist → lib}/customtypes/widgets/slices/Slice.js +0 -0
- package/{dist → lib}/customtypes/widgets/slices/Slices.d.ts +1550 -1604
- package/lib/customtypes/widgets/slices/Slices.js +93 -0
- package/{dist → lib}/customtypes/widgets/slices/SlicesTypes.d.ts +0 -0
- package/{dist → lib}/customtypes/widgets/slices/SlicesTypes.js +0 -0
- package/lib/customtypes/widgets/slices/index.d.ts +7 -0
- package/lib/customtypes/widgets/slices/index.js +16 -0
- package/lib/documents/DocumentData.d.ts +8 -0
- package/lib/documents/DocumentData.js +28 -0
- package/lib/documents/index.d.ts +2 -0
- package/lib/documents/index.js +7 -0
- package/lib/documents/widgets/EmptyContent.d.ts +8 -0
- package/lib/documents/widgets/EmptyContent.js +9 -0
- package/lib/documents/widgets/GroupContent.d.ts +16 -0
- package/lib/documents/widgets/GroupContent.js +59 -0
- package/lib/documents/widgets/SimpleWidgetContent.d.ts +20 -0
- package/lib/documents/widgets/SimpleWidgetContent.js +75 -0
- package/lib/documents/widgets/StaticWidgetContent.d.ts +10 -0
- package/lib/documents/widgets/StaticWidgetContent.js +26 -0
- package/lib/documents/widgets/UIDContent.d.ts +7 -0
- package/lib/documents/widgets/UIDContent.js +10 -0
- package/lib/documents/widgets/index.d.ts +35 -0
- package/lib/documents/widgets/index.js +36 -0
- package/lib/documents/widgets/nestable/BooleanContent.d.ts +8 -0
- package/lib/documents/widgets/nestable/BooleanContent.js +11 -0
- package/lib/documents/widgets/nestable/EmbedContent.d.ts +40 -0
- package/lib/documents/widgets/nestable/EmbedContent.js +36 -0
- package/lib/documents/widgets/nestable/FieldContent.d.ts +12 -0
- package/lib/documents/widgets/nestable/FieldContent.js +37 -0
- package/lib/documents/widgets/nestable/GeoPointContent.d.ts +17 -0
- package/lib/documents/widgets/nestable/GeoPointContent.js +13 -0
- package/lib/documents/widgets/nestable/ImageContent.d.ts +127 -0
- package/lib/documents/widgets/nestable/ImageContent.js +41 -0
- package/lib/documents/widgets/nestable/IntegrationFieldsContent.d.ts +8 -0
- package/lib/documents/widgets/nestable/IntegrationFieldsContent.js +16 -0
- package/lib/documents/widgets/nestable/Link/DocumentLink.d.ts +12 -0
- package/lib/documents/widgets/nestable/Link/DocumentLink.js +13 -0
- package/lib/documents/widgets/nestable/Link/ExternalLink.d.ts +24 -0
- package/lib/documents/widgets/nestable/Link/ExternalLink.js +24 -0
- package/lib/documents/widgets/nestable/Link/FileLink.d.ts +22 -0
- package/lib/documents/widgets/nestable/Link/FileLink.js +24 -0
- package/lib/documents/widgets/nestable/Link/ImageLink.d.ts +28 -0
- package/lib/documents/widgets/nestable/Link/ImageLink.js +26 -0
- package/lib/documents/widgets/nestable/Link/LinkContent.d.ts +36 -0
- package/lib/documents/widgets/nestable/Link/LinkContent.js +13 -0
- package/lib/documents/widgets/nestable/Link/index.d.ts +89 -0
- package/lib/documents/widgets/nestable/Link/index.js +35 -0
- package/lib/documents/widgets/nestable/SeparatorContent.d.ts +7 -0
- package/lib/documents/widgets/nestable/SeparatorContent.js +10 -0
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.d.ts +274 -0
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +97 -0
- package/lib/documents/widgets/nestable/StructuredTextContent/index.d.ts +9 -0
- package/lib/documents/widgets/nestable/StructuredTextContent/index.js +14 -0
- package/lib/documents/widgets/nestable/index.d.ts +26 -0
- package/lib/documents/widgets/nestable/index.js +40 -0
- package/lib/documents/widgets/slices/CompositeSliceContent.d.ts +14 -0
- package/lib/documents/widgets/slices/CompositeSliceContent.js +50 -0
- package/lib/documents/widgets/slices/SharedSliceContent.d.ts +15 -0
- package/lib/documents/widgets/slices/SharedSliceContent.js +62 -0
- package/lib/documents/widgets/slices/SimpleSliceContent.d.ts +6 -0
- package/lib/documents/widgets/slices/SimpleSliceContent.js +6 -0
- package/lib/documents/widgets/slices/SliceWidgetContent.d.ts +8 -0
- package/lib/documents/widgets/slices/SliceWidgetContent.js +26 -0
- package/lib/documents/widgets/slices/SlicesContent.d.ts +17 -0
- package/lib/documents/widgets/slices/SlicesContent.js +51 -0
- package/lib/documents/widgets/slices/index.d.ts +5 -0
- package/lib/documents/widgets/slices/index.js +8 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +7 -0
- package/lib/validators/DateFromString.d.ts +3 -0
- package/lib/validators/DateFromString.js +10 -0
- package/lib/validators/DateFromStringOrNumber.d.ts +3 -0
- package/lib/validators/DateFromStringOrNumber.js +10 -0
- package/lib/validators/DateFromTsMs.d.ts +3 -0
- package/lib/validators/DateFromTsMs.js +10 -0
- package/lib/validators/IntFromNumber.d.ts +5 -0
- package/lib/validators/IntFromNumber.js +14 -0
- package/lib/validators/IntFromPixels.d.ts +8 -0
- package/lib/validators/IntFromPixels.js +24 -0
- package/lib/validators/NonEmptyString.d.ts +3 -0
- package/lib/validators/NonEmptyString.js +6 -0
- package/lib/validators/NonEmptyStringOrNull.d.ts +3 -0
- package/lib/validators/NonEmptyStringOrNull.js +15 -0
- package/lib/validators/NumberOrNull.d.ts +3 -0
- package/lib/validators/NumberOrNull.js +6 -0
- package/lib/validators/StringFromBoolean.d.ts +5 -0
- package/lib/validators/StringFromBoolean.js +10 -0
- package/lib/validators/StringFromNumber.d.ts +5 -0
- package/lib/validators/StringFromNumber.js +10 -0
- package/lib/validators/StringOrNull.d.ts +3 -0
- package/lib/validators/StringOrNull.js +6 -0
- package/lib/validators/function.d.ts +14 -0
- package/lib/validators/function.js +60 -0
- package/lib/validators/index.d.ts +12 -0
- package/lib/validators/index.js +27 -0
- package/package.json +30 -18
- package/src/customtypes/CustomType.ts +173 -116
- package/src/customtypes/Format.ts +3 -3
- package/src/customtypes/Section.ts +26 -13
- package/src/customtypes/index.ts +4 -4
- package/src/customtypes/widgets/Group.ts +21 -20
- package/src/customtypes/widgets/UID.ts +18 -17
- package/src/customtypes/widgets/Widget.ts +22 -23
- package/src/customtypes/widgets/WidgetTypes.ts +21 -21
- package/src/customtypes/widgets/index.ts +7 -7
- package/src/customtypes/widgets/nestable/BooleanField.ts +19 -19
- package/src/customtypes/widgets/nestable/Color.ts +17 -16
- package/src/customtypes/widgets/nestable/Date.ts +19 -18
- package/src/customtypes/widgets/nestable/Embed.ts +19 -18
- package/src/customtypes/widgets/nestable/GeoPoint.ts +17 -16
- package/src/customtypes/widgets/nestable/Image.ts +26 -26
- package/src/customtypes/widgets/nestable/IntegrationField.ts +18 -17
- package/src/customtypes/widgets/nestable/Link.ts +80 -68
- package/src/customtypes/widgets/nestable/NestableWidget.ts +32 -32
- package/src/customtypes/widgets/nestable/Number.ts +22 -21
- package/src/customtypes/widgets/nestable/Range.ts +22 -21
- package/src/customtypes/widgets/nestable/RichText.ts +164 -134
- package/src/customtypes/widgets/nestable/Select.ts +22 -21
- package/src/customtypes/widgets/nestable/Separator.ts +15 -14
- package/src/customtypes/widgets/nestable/Text.ts +18 -17
- package/src/customtypes/widgets/nestable/Timestamp.ts +19 -18
- package/src/customtypes/widgets/nestable/index.ts +15 -15
- package/src/customtypes/widgets/shared/ImageConstraint.ts +31 -29
- package/src/customtypes/widgets/shared/index.ts +1 -1
- package/src/customtypes/widgets/slices/CompositeSlice.ts +21 -21
- package/src/customtypes/widgets/slices/LegacySlice.ts +5 -10
- package/src/customtypes/widgets/slices/SharedSlice.ts +33 -31
- package/src/customtypes/widgets/slices/SharedSliceRef.ts +6 -6
- package/src/customtypes/widgets/slices/Slice.ts +4 -4
- package/src/customtypes/widgets/slices/Slices.ts +95 -73
- package/src/customtypes/widgets/slices/SlicesTypes.ts +3 -3
- package/src/customtypes/widgets/slices/index.ts +7 -7
- package/src/documents/DocumentData.ts +54 -0
- package/src/documents/index.ts +2 -0
- package/src/documents/widgets/EmptyContent.ts +8 -0
- package/src/documents/widgets/GroupContent.ts +91 -0
- package/src/documents/widgets/SimpleWidgetContent.ts +96 -0
- package/src/documents/widgets/StaticWidgetContent.ts +46 -0
- package/src/documents/widgets/UIDContent.ts +18 -0
- package/src/documents/widgets/index.ts +56 -0
- package/src/documents/widgets/nestable/BooleanContent.ts +21 -0
- package/src/documents/widgets/nestable/EmbedContent.ts +54 -0
- package/src/documents/widgets/nestable/FieldContent.ts +45 -0
- package/src/documents/widgets/nestable/GeoPointContent.ts +18 -0
- package/src/documents/widgets/nestable/ImageContent.ts +51 -0
- package/src/documents/widgets/nestable/IntegrationFieldsContent.ts +26 -0
- package/src/documents/widgets/nestable/Link/DocumentLink.ts +18 -0
- package/src/documents/widgets/nestable/Link/ExternalLink.ts +31 -0
- package/src/documents/widgets/nestable/Link/FileLink.ts +29 -0
- package/src/documents/widgets/nestable/Link/ImageLink.ts +31 -0
- package/src/documents/widgets/nestable/Link/LinkContent.ts +22 -0
- package/src/documents/widgets/nestable/Link/index.ts +33 -0
- package/src/documents/widgets/nestable/SeparatorContent.ts +8 -0
- package/src/documents/widgets/nestable/StructuredTextContent/Block.ts +122 -0
- package/src/documents/widgets/nestable/StructuredTextContent/index.ts +25 -0
- package/src/documents/widgets/nestable/index.ts +35 -0
- package/src/documents/widgets/slices/CompositeSliceContent.ts +77 -0
- package/src/documents/widgets/slices/SharedSliceContent.ts +94 -0
- package/src/documents/widgets/slices/SimpleSliceContent.ts +4 -0
- package/src/documents/widgets/slices/SliceWidgetContent.ts +51 -0
- package/src/documents/widgets/slices/SlicesContent.ts +91 -0
- package/src/documents/widgets/slices/index.ts +5 -0
- package/src/index.ts +3 -1
- package/src/validators/DateFromString.ts +17 -0
- package/src/validators/DateFromStringOrNumber.ts +17 -0
- package/src/validators/DateFromTsMs.ts +17 -0
- package/src/validators/IntFromNumber.ts +22 -24
- package/src/validators/IntFromPixels.ts +27 -26
- package/src/validators/NonEmptyString.ts +9 -0
- package/src/validators/NonEmptyStringOrNull.ts +22 -0
- package/src/validators/NumberOrNull.ts +5 -0
- package/src/validators/StringFromBoolean.ts +17 -19
- package/src/validators/StringFromNumber.ts +17 -19
- package/src/validators/StringOrNull.ts +4 -2
- package/src/validators/function.ts +71 -0
- package/src/validators/index.ts +12 -0
- package/dist/customtypes/Section.js +0 -40
- package/dist/customtypes/index.d.ts +0 -4
- package/dist/customtypes/index.js +0 -30
- package/dist/customtypes/widgets/Group.js +0 -45
- package/dist/customtypes/widgets/UID.js +0 -42
- package/dist/customtypes/widgets/Widget.js +0 -51
- package/dist/customtypes/widgets/index.d.ts +0 -7
- package/dist/customtypes/widgets/index.js +0 -35
- package/dist/customtypes/widgets/nestable/BooleanField.js +0 -42
- package/dist/customtypes/widgets/nestable/Color.js +0 -41
- package/dist/customtypes/widgets/nestable/Date.js +0 -42
- package/dist/customtypes/widgets/nestable/Embed.js +0 -42
- package/dist/customtypes/widgets/nestable/GeoPoint.js +0 -40
- package/dist/customtypes/widgets/nestable/Image.d.ts +0 -23
- package/dist/customtypes/widgets/nestable/Image.js +0 -50
- package/dist/customtypes/widgets/nestable/IntegrationField.js +0 -42
- package/dist/customtypes/widgets/nestable/Link.js +0 -78
- package/dist/customtypes/widgets/nestable/NestableWidget.js +0 -58
- package/dist/customtypes/widgets/nestable/Number.js +0 -45
- package/dist/customtypes/widgets/nestable/Range.js +0 -45
- package/dist/customtypes/widgets/nestable/RichText.js +0 -134
- package/dist/customtypes/widgets/nestable/Select.d.ts +0 -15
- package/dist/customtypes/widgets/nestable/Select.js +0 -45
- package/dist/customtypes/widgets/nestable/Separator.js +0 -39
- package/dist/customtypes/widgets/nestable/Text.js +0 -42
- package/dist/customtypes/widgets/nestable/Timestamp.js +0 -42
- package/dist/customtypes/widgets/nestable/index.d.ts +0 -15
- package/dist/customtypes/widgets/shared/ImageConstraint.js +0 -48
- package/dist/customtypes/widgets/shared/index.d.ts +0 -1
- package/dist/customtypes/widgets/slices/CompositeSlice.js +0 -46
- package/dist/customtypes/widgets/slices/LegacySlice.js +0 -34
- package/dist/customtypes/widgets/slices/SharedSlice.js +0 -56
- package/dist/customtypes/widgets/slices/SharedSliceRef.js +0 -30
- package/dist/customtypes/widgets/slices/Slice.d.ts +0 -6
- package/dist/customtypes/widgets/slices/Slices.js +0 -106
- package/dist/customtypes/widgets/slices/index.d.ts +0 -7
- package/dist/customtypes/widgets/slices/index.js +0 -37
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -23
- package/dist/index.js.map +0 -1
- package/dist/validators/IntFromNumber.d.ts +0 -7
- package/dist/validators/IntFromNumber.js +0 -35
- package/dist/validators/IntFromPixels.d.ts +0 -7
- package/dist/validators/IntFromPixels.js +0 -43
- package/dist/validators/StringFromBoolean.d.ts +0 -7
- package/dist/validators/StringFromBoolean.js +0 -31
- package/dist/validators/StringFromNumber.d.ts +0 -7
- package/dist/validators/StringFromNumber.js +0 -31
- package/dist/validators/StringOrNull.d.ts +0 -2
- package/dist/validators/StringOrNull.js +0 -24
|
@@ -1,159 +1,189 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { either } from 'fp-ts/lib/Either'
|
|
4
|
-
import WidgetTypes from '../WidgetTypes'
|
|
5
|
-
import ImageConstraint from '../shared/ImageConstraint'
|
|
1
|
+
import { either } from "fp-ts/lib/Either"
|
|
2
|
+
import * as t from "io-ts"
|
|
6
3
|
|
|
7
|
-
|
|
4
|
+
import { StringOrNull } from "../../../validators"
|
|
5
|
+
import ImageConstraint from "../shared/ImageConstraint"
|
|
6
|
+
import WidgetTypes from "../WidgetTypes"
|
|
7
|
+
|
|
8
|
+
const DEFAULT_OPTION = "paragraph"
|
|
8
9
|
const options = [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
]
|
|
10
|
+
"heading1",
|
|
11
|
+
"heading2",
|
|
12
|
+
"heading3",
|
|
13
|
+
"heading4",
|
|
14
|
+
"heading5",
|
|
15
|
+
"heading6",
|
|
16
|
+
"paragraph",
|
|
17
|
+
"strong",
|
|
18
|
+
"em",
|
|
19
|
+
"preformatted",
|
|
20
|
+
"hyperlink",
|
|
21
|
+
"image",
|
|
22
|
+
"embed",
|
|
23
|
+
"list-item",
|
|
24
|
+
"o-list-item",
|
|
25
|
+
"rtl",
|
|
26
|
+
]
|
|
26
27
|
|
|
27
28
|
const RichTextOptions = new t.Type<string, string, unknown>(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const filtered = entries.filter(entry => options.includes(entry))
|
|
39
|
-
if(!filtered.length) return t.success(DEFAULT_OPTION)
|
|
40
|
-
|
|
41
|
-
return t.success(filtered.join(','))
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
},
|
|
45
|
-
a => a
|
|
46
|
-
)
|
|
29
|
+
"RichTextOptions",
|
|
30
|
+
(u: unknown): u is string => typeof u === "string",
|
|
31
|
+
(u: unknown, context: t.Context) => {
|
|
32
|
+
return either.chain(
|
|
33
|
+
t.union([t.string, t.null]).validate(u, context),
|
|
34
|
+
(s: string | null) => {
|
|
35
|
+
if (!s) return t.success(DEFAULT_OPTION)
|
|
36
|
+
const entries = s.split(",").map((e: string) => e.trim())
|
|
37
|
+
const filtered = entries.filter((entry) => options.includes(entry))
|
|
38
|
+
if (!filtered.length) return t.success(DEFAULT_OPTION)
|
|
47
39
|
|
|
40
|
+
return t.success(filtered.join(","))
|
|
41
|
+
},
|
|
42
|
+
)
|
|
43
|
+
},
|
|
44
|
+
(a) => a,
|
|
45
|
+
)
|
|
48
46
|
|
|
49
|
-
const NoLabels = (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
const NoLabels = (
|
|
48
|
+
labels:
|
|
49
|
+
| string
|
|
50
|
+
| string[]
|
|
51
|
+
| {
|
|
52
|
+
[x: string]: {
|
|
53
|
+
name: string
|
|
54
|
+
}[]
|
|
55
|
+
}
|
|
56
|
+
| null,
|
|
57
|
+
) => {
|
|
58
|
+
if (!labels) return t.success([])
|
|
59
|
+
return
|
|
55
60
|
}
|
|
56
61
|
|
|
57
|
-
const LabelsAsObject = (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
62
|
+
const LabelsAsObject = (
|
|
63
|
+
labels:
|
|
64
|
+
| string
|
|
65
|
+
| string[]
|
|
66
|
+
| {
|
|
67
|
+
[x: string]: {
|
|
68
|
+
name: string
|
|
69
|
+
}[]
|
|
70
|
+
}
|
|
71
|
+
| null,
|
|
72
|
+
) => {
|
|
73
|
+
if (labels instanceof Object) {
|
|
74
|
+
const labelsObj = labels as { [x: string]: { name: string }[] }
|
|
75
|
+
|
|
76
|
+
// empty labels
|
|
77
|
+
if (!Object.entries(labelsObj).length) return t.success([])
|
|
78
|
+
|
|
79
|
+
// weird case labels with empty key as parent
|
|
80
|
+
if (labelsObj[""]) {
|
|
81
|
+
return t.success(labelsObj[""].map((l) => l.name))
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const convertedObjectToArray = Object.entries(labelsObj)
|
|
85
|
+
.reduce<ReadonlyArray<string>>((acc, [, labelsEntries]) => {
|
|
86
|
+
return acc.concat(labelsEntries.map((l) => l.name))
|
|
87
|
+
}, [])
|
|
88
|
+
.filter(Boolean)
|
|
89
|
+
|
|
90
|
+
return t.success(convertedObjectToArray)
|
|
91
|
+
}
|
|
92
|
+
return
|
|
81
93
|
}
|
|
82
94
|
|
|
83
|
-
const LabelsAsArray = (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
const LabelsAsArray = (
|
|
96
|
+
labels:
|
|
97
|
+
| string
|
|
98
|
+
| string[]
|
|
99
|
+
| {
|
|
100
|
+
[x: string]: {
|
|
101
|
+
name: string
|
|
102
|
+
}[]
|
|
103
|
+
}
|
|
104
|
+
| null,
|
|
105
|
+
) => {
|
|
106
|
+
if (labels instanceof Array) {
|
|
107
|
+
const isValidLabels = labels.reduce(
|
|
108
|
+
(acc, l) => acc && typeof l === "string",
|
|
109
|
+
true,
|
|
110
|
+
)
|
|
111
|
+
if (isValidLabels) return t.success(labels)
|
|
112
|
+
}
|
|
113
|
+
return
|
|
92
114
|
}
|
|
93
115
|
|
|
94
|
-
const LabelsAsString = (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
116
|
+
const LabelsAsString = (
|
|
117
|
+
labels:
|
|
118
|
+
| string
|
|
119
|
+
| string[]
|
|
120
|
+
| {
|
|
121
|
+
[x: string]: {
|
|
122
|
+
name: string
|
|
123
|
+
}[]
|
|
124
|
+
}
|
|
125
|
+
| null,
|
|
126
|
+
) => {
|
|
127
|
+
if (typeof labels === "string") {
|
|
128
|
+
return t.success([labels])
|
|
129
|
+
}
|
|
130
|
+
return
|
|
102
131
|
}
|
|
103
132
|
|
|
104
133
|
const RichTextLabels = new t.Type<Array<string>, object, unknown>(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
"RichTextLabels",
|
|
135
|
+
(u: unknown): u is Array<string> => {
|
|
136
|
+
return u instanceof Array
|
|
137
|
+
},
|
|
138
|
+
(u: unknown, context: t.Context) => {
|
|
139
|
+
const legacyValidator = t.record(
|
|
140
|
+
t.string,
|
|
141
|
+
t.array(t.record(t.literal("name"), t.string)),
|
|
142
|
+
)
|
|
143
|
+
const validator = t.array(t.string)
|
|
144
|
+
|
|
145
|
+
return either.chain(
|
|
146
|
+
t
|
|
147
|
+
.union([legacyValidator, validator, t.string, t.null])
|
|
148
|
+
.validate(u, context),
|
|
149
|
+
(labels) => {
|
|
150
|
+
return (
|
|
151
|
+
NoLabels(labels) ||
|
|
152
|
+
LabelsAsArray(labels) ||
|
|
153
|
+
LabelsAsObject(labels) ||
|
|
154
|
+
LabelsAsString(labels) ||
|
|
155
|
+
t.failure(u, context)
|
|
156
|
+
)
|
|
157
|
+
},
|
|
158
|
+
)
|
|
159
|
+
},
|
|
160
|
+
(res) => res,
|
|
131
161
|
)
|
|
132
162
|
|
|
133
163
|
const RichTextConfig = t.exact(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
164
|
+
t.partial({
|
|
165
|
+
label: StringOrNull,
|
|
166
|
+
placeholder: t.string,
|
|
167
|
+
useAsTitle: t.boolean,
|
|
168
|
+
single: RichTextOptions,
|
|
169
|
+
multi: RichTextOptions,
|
|
170
|
+
imageConstraint: ImageConstraint,
|
|
171
|
+
labels: RichTextLabels,
|
|
172
|
+
allowTargetBlank: t.boolean,
|
|
173
|
+
}),
|
|
144
174
|
)
|
|
145
175
|
type RichTextConfig = t.TypeOf<typeof RichTextConfig>
|
|
146
176
|
|
|
147
177
|
const RichText = t.exact(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
178
|
+
t.intersection([
|
|
179
|
+
t.type({
|
|
180
|
+
type: t.literal(WidgetTypes.RichText),
|
|
181
|
+
}),
|
|
182
|
+
t.partial({
|
|
183
|
+
fieldset: StringOrNull,
|
|
184
|
+
config: RichTextConfig,
|
|
185
|
+
}),
|
|
186
|
+
]),
|
|
157
187
|
)
|
|
158
188
|
type RichText = t.TypeOf<typeof RichText>
|
|
159
189
|
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import * as t from
|
|
2
|
-
import { StringOrNull } from '../../../validators/StringOrNull'
|
|
3
|
-
import { StringFromBoolean } from '../../../validators/StringFromBoolean'
|
|
4
|
-
import WidgetTypes from '../WidgetTypes'
|
|
1
|
+
import * as t from "io-ts"
|
|
5
2
|
|
|
6
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
StringFromBoolean,
|
|
5
|
+
StringFromNumber,
|
|
6
|
+
StringOrNull,
|
|
7
|
+
} from "../../../validators"
|
|
8
|
+
import WidgetTypes from "../WidgetTypes"
|
|
7
9
|
|
|
8
10
|
const SelectConfig = t.exact(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
t.partial({
|
|
12
|
+
label: StringOrNull,
|
|
13
|
+
placeholder: t.string,
|
|
14
|
+
default_value: t.string,
|
|
15
|
+
options: t.array(t.union([t.string, StringFromNumber, StringFromBoolean])),
|
|
16
|
+
}),
|
|
15
17
|
)
|
|
16
18
|
type SelectConfig = t.TypeOf<typeof SelectConfig>
|
|
17
19
|
|
|
18
20
|
const Select = t.exact(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
t.intersection([
|
|
22
|
+
t.type({
|
|
23
|
+
type: t.literal(WidgetTypes.Select),
|
|
24
|
+
}),
|
|
25
|
+
t.partial({
|
|
26
|
+
fieldset: StringOrNull,
|
|
27
|
+
config: SelectConfig,
|
|
28
|
+
}),
|
|
29
|
+
]),
|
|
28
30
|
)
|
|
29
31
|
type Select = t.TypeOf<typeof Select>
|
|
30
32
|
|
|
31
33
|
export default Select
|
|
32
|
-
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import * as t from
|
|
2
|
-
|
|
3
|
-
import
|
|
1
|
+
import * as t from "io-ts"
|
|
2
|
+
|
|
3
|
+
import { StringOrNull } from "../../../validators"
|
|
4
|
+
import WidgetTypes from "../WidgetTypes"
|
|
4
5
|
|
|
5
6
|
const SeparatorConfig = t.exact(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
t.partial({
|
|
8
|
+
label: StringOrNull,
|
|
9
|
+
}),
|
|
9
10
|
)
|
|
10
11
|
type SeparatorConfig = t.TypeOf<typeof SeparatorConfig>
|
|
11
12
|
|
|
12
13
|
const Separator = t.exact(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
t.intersection([
|
|
15
|
+
t.type({
|
|
16
|
+
type: t.literal(WidgetTypes.Separator),
|
|
17
|
+
}),
|
|
18
|
+
t.partial({
|
|
19
|
+
config: SeparatorConfig,
|
|
20
|
+
}),
|
|
21
|
+
]),
|
|
21
22
|
)
|
|
22
23
|
type Separator = t.TypeOf<typeof Separator>
|
|
23
24
|
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import * as t from
|
|
2
|
-
|
|
3
|
-
import
|
|
1
|
+
import * as t from "io-ts"
|
|
2
|
+
|
|
3
|
+
import { StringOrNull } from "../../../validators"
|
|
4
|
+
import WidgetTypes from "../WidgetTypes"
|
|
4
5
|
|
|
5
6
|
const TextConfig = t.exact(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
t.partial({
|
|
8
|
+
label: StringOrNull,
|
|
9
|
+
useAsTitle: t.boolean,
|
|
10
|
+
placeholder: t.string,
|
|
11
|
+
}),
|
|
11
12
|
)
|
|
12
13
|
type TextConfig = t.TypeOf<typeof TextConfig>
|
|
13
14
|
|
|
14
15
|
const Text = t.exact(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
t.intersection([
|
|
17
|
+
t.type({
|
|
18
|
+
type: t.literal(WidgetTypes.Text),
|
|
19
|
+
}),
|
|
20
|
+
t.partial({
|
|
21
|
+
fieldset: StringOrNull,
|
|
22
|
+
config: TextConfig,
|
|
23
|
+
}),
|
|
24
|
+
]),
|
|
24
25
|
)
|
|
25
26
|
type Text = t.TypeOf<typeof Text>
|
|
26
27
|
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import * as t from
|
|
2
|
-
|
|
3
|
-
import
|
|
1
|
+
import * as t from "io-ts"
|
|
2
|
+
|
|
3
|
+
import { StringOrNull } from "../../../validators"
|
|
4
|
+
import WidgetTypes from "../WidgetTypes"
|
|
4
5
|
|
|
5
6
|
const TimestampConfig = t.exact(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
t.partial({
|
|
8
|
+
label: StringOrNull,
|
|
9
|
+
placeholder: t.string,
|
|
10
|
+
default: t.string,
|
|
11
|
+
}),
|
|
11
12
|
)
|
|
12
13
|
type TimestampConfig = t.TypeOf<typeof TimestampConfig>
|
|
13
14
|
|
|
14
15
|
const Timestamp = t.exact(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
t.intersection([
|
|
17
|
+
t.type({
|
|
18
|
+
type: t.literal(WidgetTypes.Timestamp),
|
|
19
|
+
}),
|
|
20
|
+
t.partial({
|
|
21
|
+
fieldset: StringOrNull,
|
|
22
|
+
config: TimestampConfig,
|
|
23
|
+
}),
|
|
24
|
+
]),
|
|
24
25
|
)
|
|
25
26
|
type Timestamp = t.TypeOf<typeof Timestamp>
|
|
26
27
|
|
|
27
|
-
export default Timestamp
|
|
28
|
+
export default Timestamp
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export { default as BooleanField } from
|
|
2
|
-
export { default as Color } from
|
|
3
|
-
export { default as Date } from
|
|
4
|
-
export { default as GeoPoint } from
|
|
5
|
-
export { default as Image } from
|
|
6
|
-
export { default as IntegrationField } from
|
|
7
|
-
export { default as Link } from
|
|
8
|
-
export { default as NestableWidget } from
|
|
9
|
-
export { default as Number } from
|
|
10
|
-
export { default as Range } from
|
|
11
|
-
export { default as RichText } from
|
|
12
|
-
export { default as Select } from
|
|
13
|
-
export { default as Separator } from
|
|
14
|
-
export { default as Text } from
|
|
15
|
-
export { default as Timestamp } from
|
|
1
|
+
export { default as BooleanField } from "./BooleanField"
|
|
2
|
+
export { default as Color } from "./Color"
|
|
3
|
+
export { default as Date } from "./Date"
|
|
4
|
+
export { default as GeoPoint } from "./GeoPoint"
|
|
5
|
+
export { default as Image } from "./Image"
|
|
6
|
+
export { default as IntegrationField } from "./IntegrationField"
|
|
7
|
+
export { default as Link } from "./Link"
|
|
8
|
+
export { default as NestableWidget } from "./NestableWidget"
|
|
9
|
+
export { default as Number } from "./Number"
|
|
10
|
+
export { default as Range } from "./Range"
|
|
11
|
+
export { default as RichText } from "./RichText"
|
|
12
|
+
export { default as Select } from "./Select"
|
|
13
|
+
export { default as Separator } from "./Separator"
|
|
14
|
+
export { default as Text } from "./Text"
|
|
15
|
+
export { default as Timestamp } from "./Timestamp"
|
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { IntFromString } from
|
|
1
|
+
import { either } from "fp-ts/lib/Either"
|
|
2
|
+
import * as t from "io-ts"
|
|
3
|
+
import { IntFromString } from "io-ts-types/lib/IntFromString"
|
|
4
4
|
|
|
5
|
-
import { IntFromNumber } from
|
|
6
|
-
import { IntFromPixels } from '../../../validators/IntFromPixels'
|
|
5
|
+
import { IntFromNumber, IntFromPixels } from "../../../validators"
|
|
7
6
|
|
|
8
|
-
const SideConstraint = new t.Type<number | null,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
7
|
+
const SideConstraint = new t.Type<number | null, unknown, unknown>(
|
|
8
|
+
"SideConstraints",
|
|
9
|
+
(u: unknown): u is number | null => {
|
|
10
|
+
return !u || typeof u === "number"
|
|
11
|
+
},
|
|
12
|
+
(u: unknown, context: t.Context) => {
|
|
13
|
+
return either.chain(
|
|
14
|
+
t
|
|
15
|
+
.union([
|
|
16
|
+
t.literal("auto"),
|
|
17
|
+
t.literal(""),
|
|
18
|
+
t.Int,
|
|
19
|
+
IntFromString,
|
|
20
|
+
IntFromNumber,
|
|
21
|
+
IntFromPixels,
|
|
22
|
+
t.null,
|
|
23
|
+
])
|
|
24
|
+
.validate(u, context),
|
|
25
|
+
(constraint) => {
|
|
26
|
+
if (constraint === "auto" || constraint === "") return t.success(null)
|
|
27
|
+
return t.success(constraint)
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
},
|
|
31
|
+
(res) => res,
|
|
30
32
|
)
|
|
31
33
|
|
|
32
34
|
const ImageConstraint = t.partial({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
width: SideConstraint,
|
|
36
|
+
height: SideConstraint,
|
|
35
37
|
})
|
|
36
38
|
|
|
37
39
|
type ImageConstraint = t.TypeOf<typeof ImageConstraint>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as ImageConstraint } from
|
|
1
|
+
export { default as ImageConstraint } from "./ImageConstraint"
|