@prismicio/types-internal 2.2.0 → 2.2.1-remove-import.alpha-1
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/lib/common/UUID.d.ts +1 -2
- package/package.json +1 -1
- package/src/common/UUID.ts +1 -1
- package/lib/import/converters/Document.d.ts +0 -4
- package/lib/import/converters/Document.js +0 -21
- package/lib/import/converters/fields/Group.d.ts +0 -4
- package/lib/import/converters/fields/Group.js +0 -14
- package/lib/import/converters/fields/RepeatableZone.d.ts +0 -317
- package/lib/import/converters/fields/RepeatableZone.js +0 -15
- package/lib/import/converters/fields/RepeatableZoneItem.d.ts +0 -11
- package/lib/import/converters/fields/RepeatableZoneItem.js +0 -19
- package/lib/import/converters/fields/Slices/SharedSlice.d.ts +0 -4
- package/lib/import/converters/fields/Slices/SharedSlice.js +0 -19
- package/lib/import/converters/fields/Slices/SharedSliceContent.d.ts +0 -10
- package/lib/import/converters/fields/Slices/SharedSliceContent.js +0 -23
- package/lib/import/converters/fields/Slices/Slices.d.ts +0 -4
- package/lib/import/converters/fields/Slices/Slices.js +0 -16
- package/lib/import/converters/fields/Slices/index.d.ts +0 -1
- package/lib/import/converters/fields/Slices/index.js +0 -4
- package/lib/import/converters/fields/UID.d.ts +0 -3
- package/lib/import/converters/fields/UID.js +0 -10
- package/lib/import/converters/fields/index.d.ts +0 -4
- package/lib/import/converters/fields/index.js +0 -7
- package/lib/import/converters/fields/nestable/Boolean.d.ts +0 -3
- package/lib/import/converters/fields/nestable/Boolean.js +0 -12
- package/lib/import/converters/fields/nestable/Color.d.ts +0 -3
- package/lib/import/converters/fields/nestable/Color.js +0 -13
- package/lib/import/converters/fields/nestable/Date.d.ts +0 -3
- package/lib/import/converters/fields/nestable/Date.js +0 -15
- package/lib/import/converters/fields/nestable/Embed.d.ts +0 -4
- package/lib/import/converters/fields/nestable/Embed.js +0 -32
- package/lib/import/converters/fields/nestable/GeoPoint.d.ts +0 -3
- package/lib/import/converters/fields/nestable/GeoPoint.js +0 -15
- package/lib/import/converters/fields/nestable/Image.d.ts +0 -28
- package/lib/import/converters/fields/nestable/Image.js +0 -67
- package/lib/import/converters/fields/nestable/Link.d.ts +0 -4
- package/lib/import/converters/fields/nestable/Link.js +0 -70
- package/lib/import/converters/fields/nestable/Nestable.d.ts +0 -5
- package/lib/import/converters/fields/nestable/Nestable.js +0 -35
- package/lib/import/converters/fields/nestable/Number.d.ts +0 -3
- package/lib/import/converters/fields/nestable/Number.js +0 -13
- package/lib/import/converters/fields/nestable/RichText/embedBlock.d.ts +0 -4
- package/lib/import/converters/fields/nestable/RichText/embedBlock.js +0 -14
- package/lib/import/converters/fields/nestable/RichText/imageBlock.d.ts +0 -4
- package/lib/import/converters/fields/nestable/RichText/imageBlock.js +0 -12
- package/lib/import/converters/fields/nestable/RichText/index.d.ts +0 -4
- package/lib/import/converters/fields/nestable/RichText/index.js +0 -22
- package/lib/import/converters/fields/nestable/RichText/textBlock.d.ts +0 -4
- package/lib/import/converters/fields/nestable/RichText/textBlock.js +0 -54
- package/lib/import/converters/fields/nestable/Select.d.ts +0 -3
- package/lib/import/converters/fields/nestable/Select.js +0 -13
- package/lib/import/converters/fields/nestable/Text.d.ts +0 -3
- package/lib/import/converters/fields/nestable/Text.js +0 -13
- package/lib/import/converters/fields/nestable/Timestamp.d.ts +0 -3
- package/lib/import/converters/fields/nestable/Timestamp.js +0 -13
- package/lib/import/converters/fields/nestable/index.d.ts +0 -13
- package/lib/import/converters/fields/nestable/index.js +0 -16
- package/lib/import/converters/index.d.ts +0 -2
- package/lib/import/converters/index.js +0 -5
- package/lib/import/index.d.ts +0 -2
- package/lib/import/index.js +0 -5
- package/lib/import/validators/Document.d.ts +0 -6
- package/lib/import/validators/Document.js +0 -64
- package/lib/import/validators/fields/ImportContent.d.ts +0 -5
- package/lib/import/validators/fields/ImportContent.js +0 -21
- package/lib/import/validators/fields/ImportField.d.ts +0 -141
- package/lib/import/validators/fields/ImportField.js +0 -33
- package/lib/import/validators/fields/ImportGroup.d.ts +0 -345
- package/lib/import/validators/fields/ImportGroup.js +0 -27
- package/lib/import/validators/fields/ImportSlices/ImportSlices.d.ts +0 -8
- package/lib/import/validators/fields/ImportSlices/ImportSlices.js +0 -30
- package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.d.ts +0 -16
- package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.js +0 -61
- package/lib/import/validators/fields/ImportSlices/SharedSlice/errors.d.ts +0 -4
- package/lib/import/validators/fields/ImportSlices/SharedSlice/errors.js +0 -7
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/OptionalSharedSliceId.d.ts +0 -2
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/OptionalSharedSliceId.js +0 -15
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.d.ts +0 -17
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.js +0 -30
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.d.ts +0 -43
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.js +0 -69
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/errors.d.ts +0 -4
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/errors.js +0 -6
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/index.d.ts +0 -2
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/index.js +0 -5
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/types.d.ts +0 -1
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/types.js +0 -2
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceId.d.ts +0 -9
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceId.js +0 -39
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.d.ts +0 -11
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.js +0 -24
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.d.ts +0 -11
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.js +0 -24
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/index.d.ts +0 -4
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/index.js +0 -7
- package/lib/import/validators/fields/ImportSlices/SharedSlice/index.d.ts +0 -3
- package/lib/import/validators/fields/ImportSlices/SharedSlice/index.js +0 -6
- package/lib/import/validators/fields/ImportSlices/SharedSlice/utils.d.ts +0 -342
- package/lib/import/validators/fields/ImportSlices/SharedSlice/utils.js +0 -11
- package/lib/import/validators/fields/ImportSlices/index.d.ts +0 -1
- package/lib/import/validators/fields/ImportSlices/index.js +0 -4
- package/lib/import/validators/fields/ImportSlices/utils.d.ts +0 -4
- package/lib/import/validators/fields/ImportSlices/utils.js +0 -35
- package/lib/import/validators/fields/RepeatableZone.d.ts +0 -11
- package/lib/import/validators/fields/RepeatableZone.js +0 -14
- package/lib/import/validators/fields/RepeatableZoneItem.d.ts +0 -11
- package/lib/import/validators/fields/RepeatableZoneItem.js +0 -39
- package/lib/import/validators/fields/UID.d.ts +0 -6
- package/lib/import/validators/fields/UID.js +0 -15
- package/lib/import/validators/fields/index.d.ts +0 -4
- package/lib/import/validators/fields/index.js +0 -7
- package/lib/import/validators/fields/nestable/Boolean.d.ts +0 -6
- package/lib/import/validators/fields/nestable/Boolean.js +0 -6
- package/lib/import/validators/fields/nestable/Color.d.ts +0 -6
- package/lib/import/validators/fields/nestable/Color.js +0 -15
- package/lib/import/validators/fields/nestable/Date.d.ts +0 -6
- package/lib/import/validators/fields/nestable/Date.js +0 -19
- package/lib/import/validators/fields/nestable/Embed.d.ts +0 -13
- package/lib/import/validators/fields/nestable/Embed.js +0 -31
- package/lib/import/validators/fields/nestable/GeoPoint.d.ts +0 -13
- package/lib/import/validators/fields/nestable/GeoPoint.js +0 -13
- package/lib/import/validators/fields/nestable/Image/default.d.ts +0 -22
- package/lib/import/validators/fields/nestable/Image/default.js +0 -19
- package/lib/import/validators/fields/nestable/Image/index.d.ts +0 -45
- package/lib/import/validators/fields/nestable/Image/index.js +0 -41
- package/lib/import/validators/fields/nestable/Image/merge.d.ts +0 -23
- package/lib/import/validators/fields/nestable/Image/merge.js +0 -44
- package/lib/import/validators/fields/nestable/Image/model.d.ts +0 -18
- package/lib/import/validators/fields/nestable/Image/model.js +0 -2
- package/lib/import/validators/fields/nestable/Image/validators.d.ts +0 -35
- package/lib/import/validators/fields/nestable/Image/validators.js +0 -31
- package/lib/import/validators/fields/nestable/ImportRichText/ImportBlock.d.ts +0 -6
- package/lib/import/validators/fields/nestable/ImportRichText/ImportBlock.js +0 -25
- package/lib/import/validators/fields/nestable/ImportRichText/ImportRichText.d.ts +0 -24
- package/lib/import/validators/fields/nestable/ImportRichText/ImportRichText.js +0 -32
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.d.ts +0 -6
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.js +0 -18
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.d.ts +0 -10
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.js +0 -11
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.d.ts +0 -22
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.js +0 -13
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.d.ts +0 -78
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.js +0 -43
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.d.ts +0 -79
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.js +0 -27
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/index.d.ts +0 -4
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/index.js +0 -7
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.d.ts +0 -24
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.js +0 -18
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/LabelSpan.d.ts +0 -12
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/LabelSpan.js +0 -16
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.d.ts +0 -5
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.js +0 -10
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.d.ts +0 -15
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.js +0 -20
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/index.d.ts +0 -2
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/index.js +0 -5
- package/lib/import/validators/fields/nestable/ImportRichText/index.d.ts +0 -2
- package/lib/import/validators/fields/nestable/ImportRichText/index.js +0 -7
- package/lib/import/validators/fields/nestable/Link.d.ts +0 -53
- package/lib/import/validators/fields/nestable/Link.js +0 -35
- package/lib/import/validators/fields/nestable/Nestable.d.ts +0 -192
- package/lib/import/validators/fields/nestable/Nestable.js +0 -71
- package/lib/import/validators/fields/nestable/Number.d.ts +0 -17
- package/lib/import/validators/fields/nestable/Number.js +0 -17
- package/lib/import/validators/fields/nestable/Select.d.ts +0 -16
- package/lib/import/validators/fields/nestable/Select.js +0 -19
- package/lib/import/validators/fields/nestable/Text.d.ts +0 -6
- package/lib/import/validators/fields/nestable/Text.js +0 -6
- package/lib/import/validators/fields/nestable/Timestamp.d.ts +0 -7
- package/lib/import/validators/fields/nestable/Timestamp.js +0 -19
- package/lib/import/validators/fields/nestable/index.d.ts +0 -14
- package/lib/import/validators/fields/nestable/index.js +0 -19
- package/lib/import/validators/index.d.ts +0 -2
- package/lib/import/validators/index.js +0 -5
- package/lib/utils/io-ts.d.ts +0 -2
- package/lib/utils/io-ts.js +0 -22
- package/src/import/converters/Document.ts +0 -38
- package/src/import/converters/fields/Group.ts +0 -18
- package/src/import/converters/fields/RepeatableZone.ts +0 -19
- package/src/import/converters/fields/RepeatableZoneItem.ts +0 -32
- package/src/import/converters/fields/Slices/SharedSlice.ts +0 -24
- package/src/import/converters/fields/Slices/SharedSliceContent.ts +0 -27
- package/src/import/converters/fields/Slices/Slices.ts +0 -20
- package/src/import/converters/fields/Slices/index.ts +0 -1
- package/src/import/converters/fields/UID.ts +0 -9
- package/src/import/converters/fields/index.ts +0 -4
- package/src/import/converters/fields/nestable/Boolean.ts +0 -13
- package/src/import/converters/fields/nestable/Color.ts +0 -14
- package/src/import/converters/fields/nestable/Date.ts +0 -17
- package/src/import/converters/fields/nestable/Embed.ts +0 -37
- package/src/import/converters/fields/nestable/GeoPoint.ts +0 -16
- package/src/import/converters/fields/nestable/Image.ts +0 -91
- package/src/import/converters/fields/nestable/Link.ts +0 -77
- package/src/import/converters/fields/nestable/Nestable.ts +0 -55
- package/src/import/converters/fields/nestable/Number.ts +0 -14
- package/src/import/converters/fields/nestable/RichText/embedBlock.ts +0 -17
- package/src/import/converters/fields/nestable/RichText/imageBlock.ts +0 -17
- package/src/import/converters/fields/nestable/RichText/index.ts +0 -23
- package/src/import/converters/fields/nestable/RichText/textBlock.ts +0 -62
- package/src/import/converters/fields/nestable/Select.ts +0 -14
- package/src/import/converters/fields/nestable/Text.ts +0 -14
- package/src/import/converters/fields/nestable/Timestamp.ts +0 -14
- package/src/import/converters/fields/nestable/index.ts +0 -13
- package/src/import/converters/index.ts +0 -2
- package/src/import/index.ts +0 -2
- package/src/import/validators/Document.ts +0 -103
- package/src/import/validators/fields/ImportContent.ts +0 -30
- package/src/import/validators/fields/ImportField.ts +0 -36
- package/src/import/validators/fields/ImportGroup.ts +0 -45
- package/src/import/validators/fields/ImportSlices/ImportSlices.ts +0 -56
- package/src/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.ts +0 -104
- package/src/import/validators/fields/ImportSlices/SharedSlice/errors.ts +0 -6
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/OptionalSharedSliceId.ts +0 -20
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceId.ts +0 -65
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.ts +0 -45
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.ts +0 -45
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/index.ts +0 -4
- package/src/import/validators/fields/ImportSlices/SharedSlice/index.ts +0 -3
- package/src/import/validators/fields/ImportSlices/SharedSlice/utils.ts +0 -21
- package/src/import/validators/fields/ImportSlices/index.ts +0 -1
- package/src/import/validators/fields/ImportSlices/utils.ts +0 -43
- package/src/import/validators/fields/RepeatableZone.ts +0 -21
- package/src/import/validators/fields/RepeatableZoneItem.ts +0 -64
- package/src/import/validators/fields/UID.ts +0 -27
- package/src/import/validators/fields/index.ts +0 -4
- package/src/import/validators/fields/nestable/Boolean.ts +0 -7
- package/src/import/validators/fields/nestable/Color.ts +0 -28
- package/src/import/validators/fields/nestable/Date.ts +0 -34
- package/src/import/validators/fields/nestable/Embed.ts +0 -41
- package/src/import/validators/fields/nestable/GeoPoint.ts +0 -21
- package/src/import/validators/fields/nestable/Image/default.ts +0 -25
- package/src/import/validators/fields/nestable/Image/index.ts +0 -73
- package/src/import/validators/fields/nestable/Image/merge.ts +0 -64
- package/src/import/validators/fields/nestable/Image/model.ts +0 -18
- package/src/import/validators/fields/nestable/Image/validators.ts +0 -45
- package/src/import/validators/fields/nestable/ImportRichText/ImportBlock.ts +0 -39
- package/src/import/validators/fields/nestable/ImportRichText/ImportRichText.ts +0 -54
- package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.ts +0 -44
- package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.ts +0 -13
- package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.ts +0 -17
- package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.ts +0 -56
- package/src/import/validators/fields/nestable/ImportRichText/blocks/Span.ts +0 -48
- package/src/import/validators/fields/nestable/ImportRichText/blocks/index.ts +0 -4
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.ts +0 -24
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/LabelSpan.ts +0 -19
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.ts +0 -8
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.ts +0 -24
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/index.ts +0 -2
- package/src/import/validators/fields/nestable/ImportRichText/index.ts +0 -2
- package/src/import/validators/fields/nestable/Link.ts +0 -59
- package/src/import/validators/fields/nestable/Nestable.ts +0 -88
- package/src/import/validators/fields/nestable/Number.ts +0 -38
- package/src/import/validators/fields/nestable/Select.ts +0 -38
- package/src/import/validators/fields/nestable/Text.ts +0 -7
- package/src/import/validators/fields/nestable/Timestamp.ts +0 -39
- package/src/import/validators/fields/nestable/index.ts +0 -14
- package/src/import/validators/index.ts +0 -2
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts"
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Number,
|
|
5
|
-
String,
|
|
6
|
-
StringOrNull,
|
|
7
|
-
} from "../../../../../validators/BasicTypes"
|
|
8
|
-
import { withCustomError } from "../../../../../validators/function"
|
|
9
|
-
|
|
10
|
-
export const ImportImageView = withCustomError(
|
|
11
|
-
t.intersection([
|
|
12
|
-
t.type({
|
|
13
|
-
// Image Id
|
|
14
|
-
id: String,
|
|
15
|
-
}),
|
|
16
|
-
t.partial({
|
|
17
|
-
// Dimensions here will be used if they are not defined in the custom type
|
|
18
|
-
dimensions: withCustomError(
|
|
19
|
-
t.partial({
|
|
20
|
-
width: Number,
|
|
21
|
-
height: Number,
|
|
22
|
-
}),
|
|
23
|
-
() => "The value must be an object",
|
|
24
|
-
),
|
|
25
|
-
// Crop information
|
|
26
|
-
edit: withCustomError(
|
|
27
|
-
t.partial({
|
|
28
|
-
x: Number,
|
|
29
|
-
y: Number,
|
|
30
|
-
zoom: Number,
|
|
31
|
-
background: String,
|
|
32
|
-
}),
|
|
33
|
-
() => "The value must be an object",
|
|
34
|
-
),
|
|
35
|
-
// Copyrights and alt are set in the Asset by default but they can be overrided
|
|
36
|
-
copyright: StringOrNull,
|
|
37
|
-
alt: StringOrNull,
|
|
38
|
-
}),
|
|
39
|
-
]),
|
|
40
|
-
() => "The value must be an object",
|
|
41
|
-
)
|
|
42
|
-
export type ImportImageView = t.TypeOf<typeof ImportImageView>
|
|
43
|
-
|
|
44
|
-
export const ImportThumbnails = t.record(t.string, ImportImageView)
|
|
45
|
-
export type ImportThumbnails = t.TypeOf<typeof ImportThumbnails>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts"
|
|
2
|
-
|
|
3
|
-
import { withCustomError } from "../../../../../validators/function"
|
|
4
|
-
import {
|
|
5
|
-
ImportBlockType,
|
|
6
|
-
ImportEmbedBlock,
|
|
7
|
-
ImportImageBlock,
|
|
8
|
-
ImportTextBlock,
|
|
9
|
-
} from "./blocks"
|
|
10
|
-
|
|
11
|
-
export type ImportBlock = ImportTextBlock | ImportImageBlock | ImportEmbedBlock
|
|
12
|
-
|
|
13
|
-
export const ImportBlock = (allowedBlockTypes: string[]) =>
|
|
14
|
-
withCustomError(
|
|
15
|
-
t
|
|
16
|
-
.type({
|
|
17
|
-
type: ImportBlockType(allowedBlockTypes),
|
|
18
|
-
})
|
|
19
|
-
.pipe(
|
|
20
|
-
new t.Type<ImportBlock, ImportBlock, { type: ImportBlockType }>(
|
|
21
|
-
"ImportBlock",
|
|
22
|
-
(u): u is ImportBlock =>
|
|
23
|
-
t
|
|
24
|
-
.union([ImportTextBlock, ImportImageBlock, ImportEmbedBlock])
|
|
25
|
-
.is(u),
|
|
26
|
-
(u, c) => {
|
|
27
|
-
if (u.type === "image") {
|
|
28
|
-
return ImportImageBlock.validate(u, c)
|
|
29
|
-
} else if (u.type === "embed") {
|
|
30
|
-
return ImportEmbedBlock.validate(u, c)
|
|
31
|
-
} else {
|
|
32
|
-
return ImportTextBlock.validate(u, c)
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
t.identity,
|
|
36
|
-
),
|
|
37
|
-
),
|
|
38
|
-
() => "Rich text block must be an object",
|
|
39
|
-
)
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as E from "fp-ts/Either"
|
|
2
|
-
import { pipe } from "fp-ts/function"
|
|
3
|
-
import * as t from "io-ts"
|
|
4
|
-
|
|
5
|
-
import type { RichText as RichTextCustomType } from "../../../../../customtypes"
|
|
6
|
-
import { EmptyArrayOrElse } from "../../../../../validators"
|
|
7
|
-
import { withCustomError } from "../../../../../validators/function"
|
|
8
|
-
import { ImportContent } from "../../ImportContent"
|
|
9
|
-
import { ImportBlock } from "./ImportBlock"
|
|
10
|
-
|
|
11
|
-
export const ImportRichText = (customType?: RichTextCustomType) => {
|
|
12
|
-
const single = customType?.config?.single?.split(",")
|
|
13
|
-
const multi = customType?.config?.multi?.split(",")
|
|
14
|
-
const allowedBlockTypes = multi || single
|
|
15
|
-
|
|
16
|
-
const isSingleBlockAllowed = multi === undefined && single !== undefined
|
|
17
|
-
|
|
18
|
-
const BlockCodec = ImportBlock(allowedBlockTypes ?? [])
|
|
19
|
-
const RichTextArrayCodec = withCustomError(
|
|
20
|
-
t.array(BlockCodec),
|
|
21
|
-
() => "Rich text field must be an array",
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
return ImportContent(
|
|
25
|
-
"StructuredText",
|
|
26
|
-
EmptyArrayOrElse(
|
|
27
|
-
new t.ArrayType<typeof BlockCodec, ImportBlock[], ImportBlock[]>(
|
|
28
|
-
RichTextArrayCodec.name,
|
|
29
|
-
(u): u is ImportBlock[] => RichTextArrayCodec.is(u),
|
|
30
|
-
(u, c) => {
|
|
31
|
-
if (allowedBlockTypes === undefined) {
|
|
32
|
-
throw new Error(
|
|
33
|
-
"Invalid custom type for the rich text field: the model is missing a 'single' or 'multi' field defining a list of allowed block types",
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return pipe(
|
|
38
|
-
RichTextArrayCodec.validate(u, c),
|
|
39
|
-
E.chain((blocks) => {
|
|
40
|
-
if (isSingleBlockAllowed && blocks.length > 1) {
|
|
41
|
-
return t.failure(blocks, c, "This field only allows one block")
|
|
42
|
-
}
|
|
43
|
-
return t.success(blocks)
|
|
44
|
-
}),
|
|
45
|
-
)
|
|
46
|
-
},
|
|
47
|
-
t.identity,
|
|
48
|
-
BlockCodec,
|
|
49
|
-
),
|
|
50
|
-
),
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export type ImportRichText = t.TypeOf<ReturnType<typeof ImportRichText>>
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import * as E from "fp-ts/Either"
|
|
2
|
-
import { pipe } from "fp-ts/function"
|
|
3
|
-
import * as t from "io-ts"
|
|
4
|
-
|
|
5
|
-
import { withCustomError } from "../../../../../../validators/function"
|
|
6
|
-
import { ImportEmbedBlockType } from "./ImportEmbedBlock"
|
|
7
|
-
import { ImportImageBlockType } from "./ImportImageBlock"
|
|
8
|
-
import { ImportTextBlockType } from "./ImportTextBlock"
|
|
9
|
-
|
|
10
|
-
export type ImportBlockType =
|
|
11
|
-
| ImportTextBlockType
|
|
12
|
-
| ImportImageBlockType
|
|
13
|
-
| ImportEmbedBlockType
|
|
14
|
-
|
|
15
|
-
const ImportBlockTypeValidator = withCustomError(
|
|
16
|
-
t.union([ImportTextBlockType, ImportImageBlockType, ImportEmbedBlockType]),
|
|
17
|
-
() =>
|
|
18
|
-
`Invalid block type. Supported block types are: ${Object.keys(
|
|
19
|
-
ImportTextBlockType.keys,
|
|
20
|
-
).join(", ")}, ${ImportImageBlockType.value}, ${
|
|
21
|
-
ImportEmbedBlockType.value
|
|
22
|
-
}`,
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
export const ImportBlockType = (allowedBlockTypes: string[]) =>
|
|
26
|
-
new t.Type<ImportBlockType>(
|
|
27
|
-
"ImportBlockType",
|
|
28
|
-
(u): u is ImportBlockType => ImportBlockTypeValidator.is(u),
|
|
29
|
-
(u, c) => {
|
|
30
|
-
return pipe(
|
|
31
|
-
ImportBlockTypeValidator.validate(u, c),
|
|
32
|
-
E.chain((validBlockType) =>
|
|
33
|
-
allowedBlockTypes.includes(validBlockType)
|
|
34
|
-
? t.success(validBlockType)
|
|
35
|
-
: t.failure(
|
|
36
|
-
u,
|
|
37
|
-
c,
|
|
38
|
-
`The block type '${validBlockType}' is not allowed in your document type. Enable the type for this rich text field to create the document.`,
|
|
39
|
-
),
|
|
40
|
-
),
|
|
41
|
-
)
|
|
42
|
-
},
|
|
43
|
-
t.identity,
|
|
44
|
-
)
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts"
|
|
2
|
-
|
|
3
|
-
import { ImportEmbedValue } from "../../Embed"
|
|
4
|
-
|
|
5
|
-
export const ImportEmbedBlockType = t.literal("embed")
|
|
6
|
-
export type ImportEmbedBlockType = t.TypeOf<typeof ImportEmbedBlockType>
|
|
7
|
-
|
|
8
|
-
export const ImportEmbedBlock = t.strict({
|
|
9
|
-
type: ImportEmbedBlockType,
|
|
10
|
-
oembed: ImportEmbedValue,
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
export type ImportEmbedBlock = t.TypeOf<typeof ImportEmbedBlock>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts"
|
|
2
|
-
|
|
3
|
-
import { ImportImageView } from "../../Image/validators"
|
|
4
|
-
|
|
5
|
-
export const ImportImageBlockType = t.literal("image")
|
|
6
|
-
export type ImportImageBlockType = t.TypeOf<typeof ImportImageBlockType>
|
|
7
|
-
|
|
8
|
-
export const ImportImageBlock = t.exact(
|
|
9
|
-
t.intersection([
|
|
10
|
-
t.type({
|
|
11
|
-
type: ImportImageBlockType,
|
|
12
|
-
}),
|
|
13
|
-
ImportImageView,
|
|
14
|
-
]),
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
export type ImportImageBlock = t.TypeOf<typeof ImportImageBlock>
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts"
|
|
2
|
-
|
|
3
|
-
import { String } from "../../../../../../validators"
|
|
4
|
-
import { withCustomError } from "../../../../../../validators/function"
|
|
5
|
-
import { Span } from "./Span"
|
|
6
|
-
|
|
7
|
-
export const ImportTextBlockTypes = {
|
|
8
|
-
Paragraph: "paragraph",
|
|
9
|
-
OListItem: "o-list-item",
|
|
10
|
-
ListItem: "list-item",
|
|
11
|
-
Heading1: "heading1",
|
|
12
|
-
Heading2: "heading2",
|
|
13
|
-
Heading3: "heading3",
|
|
14
|
-
Heading4: "heading4",
|
|
15
|
-
Heading5: "heading5",
|
|
16
|
-
Heading6: "heading6",
|
|
17
|
-
Preformatted: "preformatted",
|
|
18
|
-
} as const
|
|
19
|
-
|
|
20
|
-
export const ImportTextBlockType = t.keyof({
|
|
21
|
-
[ImportTextBlockTypes.Paragraph]: null,
|
|
22
|
-
[ImportTextBlockTypes.OListItem]: null,
|
|
23
|
-
[ImportTextBlockTypes.ListItem]: null,
|
|
24
|
-
[ImportTextBlockTypes.Heading1]: null,
|
|
25
|
-
[ImportTextBlockTypes.Heading2]: null,
|
|
26
|
-
[ImportTextBlockTypes.Heading3]: null,
|
|
27
|
-
[ImportTextBlockTypes.Heading4]: null,
|
|
28
|
-
[ImportTextBlockTypes.Heading5]: null,
|
|
29
|
-
[ImportTextBlockTypes.Heading6]: null,
|
|
30
|
-
[ImportTextBlockTypes.Preformatted]: null,
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
export type ImportTextBlockType = t.TypeOf<typeof ImportTextBlockType>
|
|
34
|
-
|
|
35
|
-
const TextDirection = withCustomError(
|
|
36
|
-
t.union([t.literal("ltr"), t.literal("rtl")]),
|
|
37
|
-
() => "The 'direction' property must be one of the following: ltr, rtl",
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
export const ImportTextBlock = t.exact(
|
|
41
|
-
t.intersection([
|
|
42
|
-
t.type({
|
|
43
|
-
type: ImportTextBlockType,
|
|
44
|
-
text: String,
|
|
45
|
-
}),
|
|
46
|
-
t.partial({
|
|
47
|
-
spans: withCustomError(
|
|
48
|
-
t.array(Span),
|
|
49
|
-
() => "The 'spans' field must be an array",
|
|
50
|
-
),
|
|
51
|
-
direction: TextDirection,
|
|
52
|
-
}),
|
|
53
|
-
]),
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
export type ImportTextBlock = t.TypeOf<typeof ImportTextBlock>
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts"
|
|
2
|
-
|
|
3
|
-
import { withCustomError } from "../../../../../../validators/function"
|
|
4
|
-
import {
|
|
5
|
-
HyperlinkSpan,
|
|
6
|
-
HyperlinkSpanType,
|
|
7
|
-
TextSpan,
|
|
8
|
-
TextSpanType,
|
|
9
|
-
} from "./spans"
|
|
10
|
-
import { LabelSpan, LabelSpanType } from "./spans/LabelSpan"
|
|
11
|
-
|
|
12
|
-
const SpanType = withCustomError(
|
|
13
|
-
t.union([HyperlinkSpanType, TextSpanType, LabelSpanType]),
|
|
14
|
-
() =>
|
|
15
|
-
`Span 'type' field must be specified and have one of the following values: ${[
|
|
16
|
-
...Object.keys(TextSpanType.keys),
|
|
17
|
-
LabelSpanType.value,
|
|
18
|
-
].join(", ")} or ${HyperlinkSpanType.value}`,
|
|
19
|
-
)
|
|
20
|
-
export type SpanType = t.TypeOf<typeof SpanType>
|
|
21
|
-
|
|
22
|
-
const SpanTypeValidator = withCustomError(
|
|
23
|
-
t.type({
|
|
24
|
-
type: SpanType,
|
|
25
|
-
}),
|
|
26
|
-
() => "Span must be an object",
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
const SpanShape = t.union([HyperlinkSpan, TextSpan, LabelSpan])
|
|
30
|
-
|
|
31
|
-
export type Span = t.TypeOf<typeof SpanShape>
|
|
32
|
-
|
|
33
|
-
export const Span = SpanTypeValidator.pipe(
|
|
34
|
-
new t.Type<Span, Span, { type: SpanType }>(
|
|
35
|
-
"Span",
|
|
36
|
-
(u): u is Span => SpanShape.is(u),
|
|
37
|
-
(u, c) => {
|
|
38
|
-
if (HyperlinkSpanType.is(u.type)) {
|
|
39
|
-
return HyperlinkSpan.validate(u, c)
|
|
40
|
-
} else if (LabelSpanType.is(u.type)) {
|
|
41
|
-
return LabelSpan.validate(u, c)
|
|
42
|
-
} else {
|
|
43
|
-
return TextSpan.validate(u, c)
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
t.identity,
|
|
47
|
-
),
|
|
48
|
-
)
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts"
|
|
2
|
-
|
|
3
|
-
import { withCustomError } from "../../../../../../../validators/function"
|
|
4
|
-
import { Link } from "../../../Link"
|
|
5
|
-
import { SpanLocation } from "./SpanLocation"
|
|
6
|
-
|
|
7
|
-
export const HyperlinkSpanType = t.literal("hyperlink")
|
|
8
|
-
|
|
9
|
-
export type HyperlinkSpanType = t.TypeOf<typeof HyperlinkSpanType>
|
|
10
|
-
|
|
11
|
-
export const HyperlinkSpan = t.exact(
|
|
12
|
-
t.intersection([
|
|
13
|
-
t.type({
|
|
14
|
-
type: HyperlinkSpanType,
|
|
15
|
-
}),
|
|
16
|
-
SpanLocation,
|
|
17
|
-
withCustomError(
|
|
18
|
-
t.type({
|
|
19
|
-
data: Link,
|
|
20
|
-
}),
|
|
21
|
-
() => "Hyperlink span must contain a 'data' field with link data",
|
|
22
|
-
),
|
|
23
|
-
]),
|
|
24
|
-
)
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts"
|
|
2
|
-
|
|
3
|
-
import { SpanLocation } from "./SpanLocation"
|
|
4
|
-
|
|
5
|
-
export const LabelSpanType = t.literal("label")
|
|
6
|
-
|
|
7
|
-
export const LabelSpan = t.exact(
|
|
8
|
-
t.intersection([
|
|
9
|
-
t.type({
|
|
10
|
-
type: LabelSpanType,
|
|
11
|
-
data: t.strict({
|
|
12
|
-
label: t.string,
|
|
13
|
-
}),
|
|
14
|
-
}),
|
|
15
|
-
SpanLocation,
|
|
16
|
-
]),
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
export type LabelSpan = t.TypeOf<typeof LabelSpan>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts"
|
|
2
|
-
|
|
3
|
-
import { SpanLocation } from "./SpanLocation"
|
|
4
|
-
|
|
5
|
-
const TextSpanTypes = {
|
|
6
|
-
Strong: "strong",
|
|
7
|
-
Em: "em",
|
|
8
|
-
} as const
|
|
9
|
-
|
|
10
|
-
export const TextSpanType = t.keyof({
|
|
11
|
-
[TextSpanTypes.Strong]: null,
|
|
12
|
-
[TextSpanTypes.Em]: null,
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
export const TextSpan = t.exact(
|
|
16
|
-
t.intersection([
|
|
17
|
-
t.type({
|
|
18
|
-
type: TextSpanType,
|
|
19
|
-
}),
|
|
20
|
-
SpanLocation,
|
|
21
|
-
]),
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
export type TextSpan = t.TypeOf<typeof TextSpan>
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { OutputOf, TypeOf } from "io-ts"
|
|
2
|
-
import * as t from "io-ts"
|
|
3
|
-
|
|
4
|
-
import { DocumentId } from "../../../../utils/DocumentId"
|
|
5
|
-
import { DefaultOrElse, String } from "../../../../validators"
|
|
6
|
-
import { withCustomError } from "../../../../validators/function"
|
|
7
|
-
import { ImportContent } from "../ImportContent"
|
|
8
|
-
|
|
9
|
-
const LinkTypeValidator = t.type({
|
|
10
|
-
link_type: withCustomError(
|
|
11
|
-
t.union([t.literal("Web"), t.literal("Document"), t.literal("Media")]),
|
|
12
|
-
() => "The value must be `Web`, `Document` or `Media`",
|
|
13
|
-
),
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
const WebLink = t.exact(
|
|
17
|
-
t.intersection([
|
|
18
|
-
t.type({
|
|
19
|
-
link_type: t.literal("Web"),
|
|
20
|
-
url: String,
|
|
21
|
-
}),
|
|
22
|
-
t.partial({
|
|
23
|
-
target: String,
|
|
24
|
-
}),
|
|
25
|
-
]),
|
|
26
|
-
)
|
|
27
|
-
export type WebLink = t.TypeOf<typeof WebLink>
|
|
28
|
-
|
|
29
|
-
const DocumentLink = t.strict({
|
|
30
|
-
link_type: t.literal("Document"),
|
|
31
|
-
id: DocumentId,
|
|
32
|
-
})
|
|
33
|
-
export type DocumentLink = t.TypeOf<typeof DocumentLink>
|
|
34
|
-
|
|
35
|
-
const MediaLink = t.strict({
|
|
36
|
-
link_type: t.literal("Media"),
|
|
37
|
-
id: String,
|
|
38
|
-
})
|
|
39
|
-
export type MediaLink = t.TypeOf<typeof MediaLink>
|
|
40
|
-
|
|
41
|
-
export const Link = LinkTypeValidator.pipe(
|
|
42
|
-
t.union([WebLink, DocumentLink, MediaLink]),
|
|
43
|
-
)
|
|
44
|
-
export type Link = TypeOf<typeof Link>
|
|
45
|
-
|
|
46
|
-
// This is the default value for the link
|
|
47
|
-
const AnyLink = t.strict({
|
|
48
|
-
link_type: t.literal("Any"),
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
export const ImportLink = ImportContent(
|
|
52
|
-
"Link",
|
|
53
|
-
DefaultOrElse<
|
|
54
|
-
TypeOf<typeof AnyLink>,
|
|
55
|
-
TypeOf<typeof Link>,
|
|
56
|
-
OutputOf<typeof Link>
|
|
57
|
-
>(AnyLink)(Link),
|
|
58
|
-
)
|
|
59
|
-
export type ImportLink = TypeOf<typeof ImportLink>
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import type { NestableWidget } from "../../../../customtypes"
|
|
2
|
-
import { ImportBoolean } from "./Boolean"
|
|
3
|
-
import { ImportColor } from "./Color"
|
|
4
|
-
import { ImportDate } from "./Date"
|
|
5
|
-
import { ImportEmbed } from "./Embed"
|
|
6
|
-
import { ImportGeoPoint } from "./GeoPoint"
|
|
7
|
-
import { ImportImage } from "./Image"
|
|
8
|
-
import { ImportRichText } from "./ImportRichText"
|
|
9
|
-
import { ImportLink } from "./Link"
|
|
10
|
-
import { ImportNumber } from "./Number"
|
|
11
|
-
import { ImportSelect } from "./Select"
|
|
12
|
-
import { ImportText } from "./Text"
|
|
13
|
-
import { ImportTimestamp } from "./Timestamp"
|
|
14
|
-
|
|
15
|
-
export type ImportNestable =
|
|
16
|
-
| ImportBoolean
|
|
17
|
-
| ImportColor
|
|
18
|
-
| ImportNumber
|
|
19
|
-
| ImportSelect
|
|
20
|
-
| ImportText
|
|
21
|
-
| ImportDate
|
|
22
|
-
| ImportTimestamp
|
|
23
|
-
| ImportEmbed
|
|
24
|
-
| ImportLink
|
|
25
|
-
| ImportGeoPoint
|
|
26
|
-
| ImportImage
|
|
27
|
-
| ImportRichText
|
|
28
|
-
|
|
29
|
-
const getCodecOrThrow = (field: NestableWidget) => {
|
|
30
|
-
switch (field.type) {
|
|
31
|
-
case "Boolean":
|
|
32
|
-
return ImportBoolean
|
|
33
|
-
case "Color":
|
|
34
|
-
return ImportColor
|
|
35
|
-
case "Number":
|
|
36
|
-
return ImportNumber(field)
|
|
37
|
-
case "Select":
|
|
38
|
-
return ImportSelect(field)
|
|
39
|
-
case "Text":
|
|
40
|
-
return ImportText
|
|
41
|
-
case "Date":
|
|
42
|
-
return ImportDate
|
|
43
|
-
case "Timestamp":
|
|
44
|
-
return ImportTimestamp
|
|
45
|
-
case "Embed":
|
|
46
|
-
return ImportEmbed
|
|
47
|
-
case "Link":
|
|
48
|
-
return ImportLink
|
|
49
|
-
case "Image":
|
|
50
|
-
return ImportImage(field)
|
|
51
|
-
case "GeoPoint":
|
|
52
|
-
return ImportGeoPoint
|
|
53
|
-
case "StructuredText":
|
|
54
|
-
return ImportRichText(field)
|
|
55
|
-
default:
|
|
56
|
-
throw new Error(`Unsupported type of nestable field ${field.type}`)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export const ImportNestable = {
|
|
61
|
-
is(u: unknown): u is ImportNestable {
|
|
62
|
-
return (
|
|
63
|
-
ImportBoolean.is(u) ||
|
|
64
|
-
ImportColor.is(u) ||
|
|
65
|
-
ImportNumber().is(u) ||
|
|
66
|
-
ImportSelect().is(u) ||
|
|
67
|
-
ImportText.is(u) ||
|
|
68
|
-
ImportDate.is(u) ||
|
|
69
|
-
ImportTimestamp.is(u) ||
|
|
70
|
-
ImportEmbed.is(u) ||
|
|
71
|
-
ImportLink.is(u) ||
|
|
72
|
-
ImportGeoPoint.is(u) ||
|
|
73
|
-
ImportImage().is(u) ||
|
|
74
|
-
ImportRichText().is(u)
|
|
75
|
-
)
|
|
76
|
-
},
|
|
77
|
-
decode: (field: NestableWidget) => {
|
|
78
|
-
return (content: unknown) => {
|
|
79
|
-
const codec = getCodecOrThrow(field)
|
|
80
|
-
return {
|
|
81
|
-
codec,
|
|
82
|
-
result: codec.decode(content),
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
getCodec: getCodecOrThrow,
|
|
88
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts"
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
Number as NumberField,
|
|
5
|
-
NumberConfig,
|
|
6
|
-
} from "../../../../customtypes"
|
|
7
|
-
import { NullOrElse, Number } from "../../../../validators"
|
|
8
|
-
import { ImportContent } from "../ImportContent"
|
|
9
|
-
|
|
10
|
-
const numberValue = (config?: NumberConfig) =>
|
|
11
|
-
Number.pipe(
|
|
12
|
-
new t.Type<number, number, number>(
|
|
13
|
-
"ImportNumberValue",
|
|
14
|
-
(u: unknown): u is number => Number.is(u),
|
|
15
|
-
(n: number, c: t.Context) => {
|
|
16
|
-
const min = config?.min
|
|
17
|
-
const max = config?.max
|
|
18
|
-
|
|
19
|
-
if ((min !== undefined && n < min) || (max !== undefined && n > max)) {
|
|
20
|
-
return t.failure(
|
|
21
|
-
n,
|
|
22
|
-
c,
|
|
23
|
-
`The value must be between [${min !== undefined ? min : ""}, ${
|
|
24
|
-
max !== undefined ? max : ""
|
|
25
|
-
}]`,
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return t.success(n)
|
|
30
|
-
},
|
|
31
|
-
t.identity,
|
|
32
|
-
),
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
export const ImportNumber = (field?: NumberField) =>
|
|
36
|
-
ImportContent("Number", NullOrElse(numberValue(field?.config)))
|
|
37
|
-
|
|
38
|
-
export type ImportNumber = t.TypeOf<ReturnType<typeof ImportNumber>>
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts"
|
|
2
|
-
|
|
3
|
-
import type { Select, SelectConfig } from "../../../../customtypes"
|
|
4
|
-
import { NullOrElse, String } from "../../../../validators"
|
|
5
|
-
import { ImportContent } from "../ImportContent"
|
|
6
|
-
|
|
7
|
-
const selectValue = (config?: SelectConfig) =>
|
|
8
|
-
String.pipe(
|
|
9
|
-
new t.Type<string, string, string>(
|
|
10
|
-
"ImportSelectValue",
|
|
11
|
-
(u: unknown): u is string => String.is(u),
|
|
12
|
-
(s: string, c: t.Context) => {
|
|
13
|
-
if (!config?.options) {
|
|
14
|
-
return t.failure(
|
|
15
|
-
s,
|
|
16
|
-
c,
|
|
17
|
-
"The value must be defined in the custom type's configuration of the field",
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (!config.options.includes(s)) {
|
|
22
|
-
return t.failure(
|
|
23
|
-
s,
|
|
24
|
-
c,
|
|
25
|
-
`The value must be one of these: ${config.options?.join(",")}`,
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return t.success(s)
|
|
30
|
-
},
|
|
31
|
-
t.identity,
|
|
32
|
-
),
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
export const ImportSelect = (field?: Select) =>
|
|
36
|
-
ImportContent("Select", NullOrElse(selectValue(field?.config)))
|
|
37
|
-
|
|
38
|
-
export type ImportSelect = t.TypeOf<ReturnType<typeof ImportSelect>>
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { TypeOf } from "io-ts"
|
|
2
|
-
|
|
3
|
-
import { NullOrElse, String } from "../../../../validators"
|
|
4
|
-
import { ImportContent } from "../ImportContent"
|
|
5
|
-
|
|
6
|
-
export const ImportText = ImportContent("Text", NullOrElse(String))
|
|
7
|
-
export type ImportText = TypeOf<typeof ImportText>
|