@prismicio/types-internal 0.2.2 → 0.2.6

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.
Files changed (116) hide show
  1. package/lib/customtypes/CustomType.d.ts +4 -21
  2. package/lib/customtypes/CustomType.js +38 -27
  3. package/lib/customtypes/Format.js +5 -2
  4. package/lib/customtypes/Section.d.ts +4 -31
  5. package/lib/customtypes/Section.js +14 -9
  6. package/lib/customtypes/index.js +9 -4
  7. package/lib/customtypes/widgets/Group.js +12 -9
  8. package/lib/customtypes/widgets/UID.js +10 -7
  9. package/lib/customtypes/widgets/Widget.d.ts +4 -31
  10. package/lib/customtypes/widgets/Widget.js +19 -14
  11. package/lib/customtypes/widgets/WidgetTypes.js +3 -1
  12. package/lib/customtypes/widgets/index.js +14 -7
  13. package/lib/customtypes/widgets/nestable/BooleanField.js +9 -6
  14. package/lib/customtypes/widgets/nestable/Color.js +10 -7
  15. package/lib/customtypes/widgets/nestable/Date.js +10 -7
  16. package/lib/customtypes/widgets/nestable/Embed.js +10 -7
  17. package/lib/customtypes/widgets/nestable/GeoPoint.js +10 -7
  18. package/lib/customtypes/widgets/nestable/Image.js +13 -10
  19. package/lib/customtypes/widgets/nestable/IntegrationField.js +10 -7
  20. package/lib/customtypes/widgets/nestable/Link.js +14 -11
  21. package/lib/customtypes/widgets/nestable/NestableWidget.js +35 -32
  22. package/lib/customtypes/widgets/nestable/Number.js +14 -11
  23. package/lib/customtypes/widgets/nestable/Range.js +14 -11
  24. package/lib/customtypes/widgets/nestable/RichText.d.ts +22 -3
  25. package/lib/customtypes/widgets/nestable/RichText.js +78 -35
  26. package/lib/customtypes/widgets/nestable/Select.js +11 -8
  27. package/lib/customtypes/widgets/nestable/Separator.js +9 -6
  28. package/lib/customtypes/widgets/nestable/Text.js +10 -7
  29. package/lib/customtypes/widgets/nestable/Timestamp.js +10 -7
  30. package/lib/customtypes/widgets/nestable/index.d.ts +2 -1
  31. package/lib/customtypes/widgets/nestable/index.js +35 -15
  32. package/lib/customtypes/widgets/shared/ImageConstraint.js +12 -9
  33. package/lib/customtypes/widgets/shared/index.js +8 -1
  34. package/lib/customtypes/widgets/slices/CompositeSlice.js +13 -10
  35. package/lib/customtypes/widgets/slices/LegacySlice.d.ts +1 -10
  36. package/lib/customtypes/widgets/slices/LegacySlice.js +8 -6
  37. package/lib/customtypes/widgets/slices/SharedSlice.d.ts +327 -3
  38. package/lib/customtypes/widgets/slices/SharedSlice.js +15 -12
  39. package/lib/customtypes/widgets/slices/SharedSliceRef.js +7 -4
  40. package/lib/customtypes/widgets/slices/Slice.d.ts +1 -1
  41. package/lib/customtypes/widgets/slices/Slice.js +2 -1
  42. package/lib/customtypes/widgets/slices/Slices.d.ts +7 -61
  43. package/lib/customtypes/widgets/slices/Slices.js +33 -27
  44. package/lib/customtypes/widgets/slices/SlicesTypes.js +3 -1
  45. package/lib/customtypes/widgets/slices/index.d.ts +1 -1
  46. package/lib/customtypes/widgets/slices/index.js +15 -7
  47. package/lib/documents/DocumentData.js +7 -4
  48. package/lib/documents/index.js +7 -2
  49. package/lib/documents/widgets/EmptyContent.js +6 -3
  50. package/lib/documents/widgets/GroupContent.js +14 -10
  51. package/lib/documents/widgets/SimpleWidgetContent.d.ts +2 -2
  52. package/lib/documents/widgets/SimpleWidgetContent.js +32 -27
  53. package/lib/documents/widgets/StaticWidgetContent.js +11 -8
  54. package/lib/documents/widgets/UIDContent.js +8 -4
  55. package/lib/documents/widgets/index.d.ts +18 -18
  56. package/lib/documents/widgets/index.js +27 -22
  57. package/lib/documents/widgets/nestable/BooleanContent.js +10 -6
  58. package/lib/documents/widgets/nestable/EmbedContent.d.ts +6 -3
  59. package/lib/documents/widgets/nestable/EmbedContent.js +23 -20
  60. package/lib/documents/widgets/nestable/FieldContent.d.ts +3 -2
  61. package/lib/documents/widgets/nestable/FieldContent.js +10 -6
  62. package/lib/documents/widgets/nestable/GeoPointContent.js +9 -5
  63. package/lib/documents/widgets/nestable/ImageContent.js +16 -12
  64. package/lib/documents/widgets/nestable/IntegrationFieldsContent.js +10 -6
  65. package/lib/documents/widgets/nestable/Link/DocumentLink.js +12 -7
  66. package/lib/documents/widgets/nestable/Link/ExternalLink.js +15 -10
  67. package/lib/documents/widgets/nestable/Link/FileLink.js +15 -10
  68. package/lib/documents/widgets/nestable/Link/ImageLink.js +14 -9
  69. package/lib/documents/widgets/nestable/Link/LinkContent.js +13 -9
  70. package/lib/documents/widgets/nestable/Link/index.d.ts +5 -5
  71. package/lib/documents/widgets/nestable/Link/index.js +33 -24
  72. package/lib/documents/widgets/nestable/SeparatorContent.js +5 -2
  73. package/lib/documents/widgets/nestable/StructuredTextContent/Block.d.ts +2 -3
  74. package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +39 -33
  75. package/lib/documents/widgets/nestable/StructuredTextContent/index.js +11 -7
  76. package/lib/documents/widgets/nestable/index.d.ts +15 -15
  77. package/lib/documents/widgets/nestable/index.js +38 -28
  78. package/lib/documents/widgets/slices/CompositeSliceContent.js +13 -9
  79. package/lib/documents/widgets/slices/SharedSliceContent.js +16 -12
  80. package/lib/documents/widgets/slices/SimpleSliceContent.js +6 -2
  81. package/lib/documents/widgets/slices/SliceWidgetContent.js +12 -8
  82. package/lib/documents/widgets/slices/SlicesContent.js +17 -13
  83. package/lib/documents/widgets/slices/index.js +8 -5
  84. package/lib/index.js +7 -3
  85. package/lib/validators/DateFromString.js +7 -4
  86. package/lib/validators/DateFromStringOrNumber.js +7 -4
  87. package/lib/validators/DateFromTsMs.js +7 -4
  88. package/lib/validators/IntFromNumber.js +7 -4
  89. package/lib/validators/IntFromPixels.js +7 -4
  90. package/lib/validators/NonEmptyString.js +6 -3
  91. package/lib/validators/NonEmptyStringOrNull.js +10 -7
  92. package/lib/validators/NumberOrNull.js +6 -3
  93. package/lib/validators/StringFromBoolean.js +7 -4
  94. package/lib/validators/StringFromNumber.js +7 -4
  95. package/lib/validators/StringOrNull.js +6 -3
  96. package/lib/validators/function.js +28 -15
  97. package/lib/validators/index.js +27 -12
  98. package/package.json +1 -1
  99. package/src/customtypes/CustomType.ts +8 -7
  100. package/src/customtypes/Section.ts +1 -1
  101. package/src/customtypes/widgets/Widget.ts +1 -1
  102. package/src/customtypes/widgets/nestable/NestableWidget.ts +1 -1
  103. package/src/customtypes/widgets/nestable/RichText.ts +64 -24
  104. package/src/customtypes/widgets/nestable/index.ts +2 -1
  105. package/src/customtypes/widgets/slices/LegacySlice.ts +1 -2
  106. package/src/customtypes/widgets/slices/SharedSlice.ts +4 -6
  107. package/src/customtypes/widgets/slices/Slice.ts +1 -1
  108. package/src/customtypes/widgets/slices/Slices.ts +1 -1
  109. package/src/customtypes/widgets/slices/index.ts +1 -1
  110. package/src/documents/widgets/SimpleWidgetContent.ts +4 -4
  111. package/src/documents/widgets/index.ts +1 -1
  112. package/src/documents/widgets/nestable/EmbedContent.ts +8 -6
  113. package/src/documents/widgets/nestable/FieldContent.ts +10 -2
  114. package/src/documents/widgets/nestable/Link/index.ts +1 -1
  115. package/src/documents/widgets/nestable/StructuredTextContent/Block.ts +1 -1
  116. package/src/documents/widgets/nestable/index.ts +2 -2
@@ -1,12 +1,27 @@
1
- export { default as DateFromString } from "./DateFromString";
2
- export { default as DateFromStringOrNumber } from "./DateFromStringOrNumber";
3
- export { default as DateFromTsMs } from "./DateFromTsMs";
4
- export * as Function from "./function";
5
- export { default as IntFromNumber } from "./IntFromNumber";
6
- export { default as IntFromPixels } from "./IntFromPixels";
7
- export { default as NonEmptyString } from "./NonEmptyString";
8
- export { default as NonEmptyStringOrNull } from "./NonEmptyStringOrNull";
9
- export { default as NumberOrNull } from "./NumberOrNull";
10
- export { default as StringFromBoolean } from "./StringFromBoolean";
11
- export { default as StringFromNumber } from "./StringFromNumber";
12
- export { default as StringOrNull } from "./StringOrNull";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StringOrNull = exports.StringFromNumber = exports.StringFromBoolean = exports.NumberOrNull = exports.NonEmptyStringOrNull = exports.NonEmptyString = exports.IntFromPixels = exports.IntFromNumber = exports.Function = exports.DateFromTsMs = exports.DateFromStringOrNumber = exports.DateFromString = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var DateFromString_1 = require("./DateFromString");
6
+ Object.defineProperty(exports, "DateFromString", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(DateFromString_1).default; } });
7
+ var DateFromStringOrNumber_1 = require("./DateFromStringOrNumber");
8
+ Object.defineProperty(exports, "DateFromStringOrNumber", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(DateFromStringOrNumber_1).default; } });
9
+ var DateFromTsMs_1 = require("./DateFromTsMs");
10
+ Object.defineProperty(exports, "DateFromTsMs", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(DateFromTsMs_1).default; } });
11
+ exports.Function = (0, tslib_1.__importStar)(require("./function"));
12
+ var IntFromNumber_1 = require("./IntFromNumber");
13
+ Object.defineProperty(exports, "IntFromNumber", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(IntFromNumber_1).default; } });
14
+ var IntFromPixels_1 = require("./IntFromPixels");
15
+ Object.defineProperty(exports, "IntFromPixels", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(IntFromPixels_1).default; } });
16
+ var NonEmptyString_1 = require("./NonEmptyString");
17
+ Object.defineProperty(exports, "NonEmptyString", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(NonEmptyString_1).default; } });
18
+ var NonEmptyStringOrNull_1 = require("./NonEmptyStringOrNull");
19
+ Object.defineProperty(exports, "NonEmptyStringOrNull", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(NonEmptyStringOrNull_1).default; } });
20
+ var NumberOrNull_1 = require("./NumberOrNull");
21
+ Object.defineProperty(exports, "NumberOrNull", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(NumberOrNull_1).default; } });
22
+ var StringFromBoolean_1 = require("./StringFromBoolean");
23
+ Object.defineProperty(exports, "StringFromBoolean", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(StringFromBoolean_1).default; } });
24
+ var StringFromNumber_1 = require("./StringFromNumber");
25
+ Object.defineProperty(exports, "StringFromNumber", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(StringFromNumber_1).default; } });
26
+ var StringOrNull_1 = require("./StringOrNull");
27
+ Object.defineProperty(exports, "StringOrNull", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(StringOrNull_1).default; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/types-internal",
3
- "version": "0.2.2",
3
+ "version": "0.2.6",
4
4
  "description": "Prismic types for Custom Types and Prismic Data",
5
5
  "keywords": [
6
6
  "typescript",
@@ -10,7 +10,7 @@ import {
10
10
  Sections,
11
11
  StaticSection,
12
12
  } from "./Section"
13
- import type SharedSlice from "./widgets/slices/SharedSlice"
13
+ import type { SharedSlice } from "./widgets/slices/SharedSlice"
14
14
  import type { DynamicSlice } from "./widgets/slices/Slice"
15
15
  import type { DynamicSlices } from "./widgets/slices/Slices"
16
16
  import SlicesTypes from "./widgets/slices/SlicesTypes"
@@ -58,10 +58,10 @@ export type StaticCustomType = t.TypeOf<typeof StaticCustomType>
58
58
  export const CustomType = customTypeReader(Format.Dynamic)
59
59
  export type CustomType = t.TypeOf<typeof CustomType>
60
60
 
61
- function _retrieveSharedSlicesRef(customType: CustomType): Array<string> {
62
- const flattenWidgets: Array<[string, DynamicWidget]> = Object.entries(
63
- customType.json,
64
- ).reduce(
61
+ export function flattenWidgets(
62
+ customType: CustomType,
63
+ ): Array<[string, DynamicWidget]> {
64
+ return Object.entries(customType.json).reduce(
65
65
  (
66
66
  acc: Array<[string, DynamicWidget]>,
67
67
  [, section]: [string, DynamicSection],
@@ -72,8 +72,9 @@ function _retrieveSharedSlicesRef(customType: CustomType): Array<string> {
72
72
  },
73
73
  [],
74
74
  )
75
-
76
- const slicezones = flattenWidgets.filter(
75
+ }
76
+ function _retrieveSharedSlicesRef(customType: CustomType): Array<string> {
77
+ const slicezones = flattenWidgets(customType).filter(
77
78
  ([, widget]: [string, DynamicWidget]) => widget.type === WidgetTypes.Slices,
78
79
  ) as Array<[string, DynamicSlices]>
79
80
 
@@ -1,7 +1,7 @@
1
1
  import * as t from "io-ts"
2
2
 
3
3
  import { Format } from "./Format"
4
- import type SharedSlice from "./widgets/slices/SharedSlice"
4
+ import type { SharedSlice } from "./widgets/slices/SharedSlice"
5
5
  import {
6
6
  DynamicWidget,
7
7
  StaticWidget,
@@ -3,7 +3,7 @@ import * as t from "io-ts"
3
3
  import { Format } from "../Format"
4
4
  import Group from "./Group"
5
5
  import NestableWidget from "./nestable/NestableWidget"
6
- import type SharedSlice from "./slices/SharedSlice"
6
+ import type { SharedSlice } from "./slices/SharedSlice"
7
7
  import { Slices, slicesReader } from "./slices/Slices"
8
8
  import UID from "./UID"
9
9
  import WidgetTypes from "./WidgetTypes"
@@ -10,7 +10,7 @@ import IntegrationField from "./IntegrationField"
10
10
  import Link from "./Link"
11
11
  import Number from "./Number"
12
12
  import Range from "./Range"
13
- import RichText from "./RichText"
13
+ import { RichText } from "./RichText"
14
14
  import Select from "./Select"
15
15
  import Separator from "./Separator"
16
16
  import Text from "./Text"
@@ -5,25 +5,67 @@ import { StringOrNull } from "../../../validators"
5
5
  import ImageConstraint from "../shared/ImageConstraint"
6
6
  import WidgetTypes from "../WidgetTypes"
7
7
 
8
- const DEFAULT_OPTION = "paragraph"
9
- const options = [
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
- ]
8
+ export const DEFAULT_OPTION = "paragraph"
9
+
10
+ export enum RichTextNodeType {
11
+ heading1 = "heading1",
12
+ heading2 = "heading2",
13
+ heading3 = "heading3",
14
+ heading4 = "heading4",
15
+ heading5 = "heading5",
16
+ heading6 = "heading6",
17
+ paragraph = "paragraph",
18
+ strong = "strong",
19
+ em = "em",
20
+ preformatted = "preformatted",
21
+ hyperlink = "hyperlink",
22
+ image = "image",
23
+ embed = "embed",
24
+ list = "list-item",
25
+ orderedList = "o-list-item",
26
+ rtl = "rtl",
27
+ }
28
+
29
+ export function parseRichTextNodeType(
30
+ str: string,
31
+ ): RichTextNodeType | undefined {
32
+ switch (str) {
33
+ case RichTextNodeType.heading1:
34
+ return RichTextNodeType.heading1
35
+ case RichTextNodeType.heading2:
36
+ return RichTextNodeType.heading2
37
+ case RichTextNodeType.heading3:
38
+ return RichTextNodeType.heading3
39
+ case RichTextNodeType.heading4:
40
+ return RichTextNodeType.heading4
41
+ case RichTextNodeType.heading5:
42
+ return RichTextNodeType.heading5
43
+ case RichTextNodeType.heading6:
44
+ return RichTextNodeType.heading6
45
+ case RichTextNodeType.paragraph:
46
+ return RichTextNodeType.paragraph
47
+ case RichTextNodeType.strong:
48
+ return RichTextNodeType.strong
49
+ case RichTextNodeType.em:
50
+ return RichTextNodeType.em
51
+ case RichTextNodeType.preformatted:
52
+ return RichTextNodeType.preformatted
53
+ case RichTextNodeType.hyperlink:
54
+ return RichTextNodeType.hyperlink
55
+ case RichTextNodeType.image:
56
+ return RichTextNodeType.image
57
+ case RichTextNodeType.embed:
58
+ return RichTextNodeType.embed
59
+ case RichTextNodeType.list:
60
+ return RichTextNodeType.list
61
+ case RichTextNodeType.orderedList:
62
+ return RichTextNodeType.orderedList
63
+ case RichTextNodeType.rtl:
64
+ return RichTextNodeType.rtl
65
+ default:
66
+ return
67
+ }
68
+ }
27
69
 
28
70
  const RichTextOptions = new t.Type<string, string, unknown>(
29
71
  "RichTextOptions",
@@ -34,7 +76,7 @@ const RichTextOptions = new t.Type<string, string, unknown>(
34
76
  (s: string | null) => {
35
77
  if (!s) return t.success(DEFAULT_OPTION)
36
78
  const entries = s.split(",").map((e: string) => e.trim())
37
- const filtered = entries.filter((entry) => options.includes(entry))
79
+ const filtered = entries.filter((entry) => parseRichTextNodeType(entry))
38
80
  if (!filtered.length) return t.success(DEFAULT_OPTION)
39
81
 
40
82
  return t.success(filtered.join(","))
@@ -174,7 +216,7 @@ const RichTextConfig = t.exact(
174
216
  )
175
217
  type RichTextConfig = t.TypeOf<typeof RichTextConfig>
176
218
 
177
- const RichText = t.exact(
219
+ export const RichText = t.exact(
178
220
  t.intersection([
179
221
  t.type({
180
222
  type: t.literal(WidgetTypes.RichText),
@@ -185,6 +227,4 @@ const RichText = t.exact(
185
227
  }),
186
228
  ]),
187
229
  )
188
- type RichText = t.TypeOf<typeof RichText>
189
-
190
- export default RichText
230
+ export type RichText = t.TypeOf<typeof RichText>
@@ -1,6 +1,7 @@
1
1
  export { default as BooleanField } from "./BooleanField"
2
2
  export { default as Color } from "./Color"
3
3
  export { default as Date } from "./Date"
4
+ export { default as Embed } from "./Embed"
4
5
  export { default as GeoPoint } from "./GeoPoint"
5
6
  export { default as Image } from "./Image"
6
7
  export { default as IntegrationField } from "./IntegrationField"
@@ -8,7 +9,7 @@ export { default as Link } from "./Link"
8
9
  export { default as NestableWidget } from "./NestableWidget"
9
10
  export { default as Number } from "./Number"
10
11
  export { default as Range } from "./Range"
11
- export { default as RichText } from "./RichText"
12
+ export * from "./RichText"
12
13
  export { default as Select } from "./Select"
13
14
  export { default as Separator } from "./Separator"
14
15
  export { default as Text } from "./Text"
@@ -2,9 +2,8 @@ import * as t from "io-ts"
2
2
 
3
3
  import Group from "../Group"
4
4
  import NestableWidget from "../nestable/NestableWidget"
5
- import UID from "../UID"
6
5
 
7
- const LegacySlice = t.union([UID, NestableWidget, Group])
6
+ const LegacySlice = t.union([NestableWidget, Group])
8
7
 
9
8
  type LegacySlice = t.TypeOf<typeof LegacySlice>
10
9
 
@@ -7,7 +7,7 @@ import SlicesTypes from "./SlicesTypes"
7
7
  const IMAGE_PLACEHOLDER_URL =
8
8
  "https://images.prismic.io/slice-machine/621a5ec4-0387-4bc5-9860-2dd46cbc07cd_default_ss.png?auto=compress,format"
9
9
 
10
- const Variation = t.exact(
10
+ export const Variation = t.exact(
11
11
  t.intersection([
12
12
  t.type({
13
13
  id: t.string,
@@ -25,9 +25,9 @@ const Variation = t.exact(
25
25
  ]),
26
26
  )
27
27
 
28
- type Variation = t.TypeOf<typeof Variation>
28
+ export type Variation = t.TypeOf<typeof Variation>
29
29
 
30
- const SharedSlice = t.exact(
30
+ export const SharedSlice = t.exact(
31
31
  t.intersection([
32
32
  t.type({
33
33
  id: t.string,
@@ -41,6 +41,4 @@ const SharedSlice = t.exact(
41
41
  ]),
42
42
  )
43
43
 
44
- type SharedSlice = t.TypeOf<typeof SharedSlice>
45
-
46
- export default SharedSlice
44
+ export type SharedSlice = t.TypeOf<typeof SharedSlice>
@@ -1,6 +1,6 @@
1
1
  import type CompositeSlice from "./CompositeSlice"
2
2
  import type LegacySlice from "./LegacySlice"
3
- import type SharedSlice from "./SharedSlice"
3
+ import type { SharedSlice } from "./SharedSlice"
4
4
  import type SharedSliceRef from "./SharedSliceRef"
5
5
 
6
6
  export type DynamicSlice = CompositeSlice | LegacySlice | SharedSliceRef
@@ -5,7 +5,7 @@ import { Format } from "../../Format"
5
5
  import WidgetTypes from "../WidgetTypes"
6
6
  import CompositeSlice from "./CompositeSlice"
7
7
  import LegacySlice from "./LegacySlice"
8
- import SharedSlice from "./SharedSlice"
8
+ import { SharedSlice } from "./SharedSlice"
9
9
  import SharedSliceRef from "./SharedSliceRef"
10
10
  import SlicesTypes from "./SlicesTypes"
11
11
 
@@ -1,6 +1,6 @@
1
1
  export { default as CompositeSlice } from "./CompositeSlice"
2
2
  export { default as LegacySlice } from "./LegacySlice"
3
- export { default as SharedSlice } from "./SharedSlice"
3
+ export * from "./SharedSlice"
4
4
  export { default as SharedSliceRef } from "./SharedSliceRef"
5
5
  export * as Slice from "./Slice"
6
6
  export * as SliceZone from "./Slices"
@@ -4,8 +4,8 @@ import * as t from "io-ts"
4
4
 
5
5
  import type { EmptyContent } from "./EmptyContent"
6
6
  import BooleanContent from "./nestable/BooleanContent"
7
- import EmbedContent from "./nestable/EmbedContent"
8
- import FieldContent from "./nestable/FieldContent"
7
+ import { EmbedContent, EmbedContentO } from "./nestable/EmbedContent"
8
+ import FieldContent, { FieldType } from "./nestable/FieldContent"
9
9
  import { GeoPointContent, GeoPointContentO } from "./nestable/GeoPointContent"
10
10
  import { ImageContent, ImageContentO } from "./nestable/ImageContent"
11
11
  import IntegrationFieldsContent from "./nestable/IntegrationFieldsContent"
@@ -34,7 +34,7 @@ export type NonEmptySimpleWidgetContent =
34
34
  | StructuredTextContent
35
35
  | ImageContentO
36
36
  | GeoPointContentO
37
- | EmbedContent
37
+ | EmbedContentO
38
38
  | LinkContent
39
39
  | UIDContent
40
40
  | SeparatorContent
@@ -84,7 +84,7 @@ export const SimpleWidgetContent = {
84
84
  return O.fromEither(BooleanContent.decode(content))
85
85
  default:
86
86
  if (FieldContent.types.includes(type)) {
87
- return FieldContent.forType(type, content)
87
+ return FieldContent.forType(type as FieldType, content)
88
88
  } else {
89
89
  return O.none
90
90
  }
@@ -22,7 +22,7 @@ export const WidgetTypes = {
22
22
  UID: UIDContentType,
23
23
  Group: GroupContentType,
24
24
  slices: SlicesContentType,
25
- }
25
+ } as const
26
26
 
27
27
  export type WidgetKey = string
28
28
  export type WidgetContent = SlicesContent | StaticWidgetContent
@@ -7,13 +7,17 @@ import { addType } from "../../../validators/function"
7
7
 
8
8
  export const EmbedContentType = "EmbedContent"
9
9
 
10
- type EmbedContent = t.OutputOf<typeof EmbedContentC> & {
10
+ export type EmbedContent = t.TypeOf<typeof EmbedContentC> & {
11
11
  all: unknown
12
12
  }
13
13
 
14
- const EmbedContent = new t.Type<EmbedContent, unknown, unknown>(
14
+ export type EmbedContentO = t.OutputOf<typeof EmbedContentC> & {
15
+ all: unknown
16
+ }
17
+
18
+ export const EmbedContent = new t.Type<EmbedContentO, unknown, unknown>(
15
19
  "EmbedContent",
16
- (u): u is EmbedContent => (u as EmbedContent).__TYPE__ === EmbedContentType,
20
+ (u): u is EmbedContentO => (u as EmbedContentO).__TYPE__ === EmbedContentType,
17
21
  (u) => {
18
22
  return pipe(
19
23
  EmbedContentC.decode(u),
@@ -23,7 +27,7 @@ const EmbedContent = new t.Type<EmbedContent, unknown, unknown>(
23
27
  })),
24
28
  )
25
29
  },
26
- (ec: EmbedContent) => EmbedContentC.encode(ec),
30
+ (ec: EmbedContentO) => EmbedContentC.encode(ec),
27
31
  )
28
32
 
29
33
  const EmbedContentC = addType(
@@ -50,5 +54,3 @@ const EmbedContentC = addType(
50
54
  ),
51
55
  EmbedContentType,
52
56
  )
53
-
54
- export default EmbedContent
@@ -2,10 +2,18 @@ import { pipe } from "fp-ts/function"
2
2
  import * as O from "fp-ts/Option"
3
3
  import * as t from "io-ts"
4
4
 
5
+ export type FieldType =
6
+ | "Text"
7
+ | "Date"
8
+ | "Timestamp"
9
+ | "Color"
10
+ | "Number"
11
+ | "Range"
12
+ | "Select"
5
13
  export const FieldContentType = "FieldContent"
6
14
  type FieldContent = {
7
15
  value: string
8
- type: string
16
+ type: FieldType
9
17
  __TYPE__: typeof FieldContentType
10
18
  }
11
19
 
@@ -28,7 +36,7 @@ function trimScalaStyle(s: string): string {
28
36
 
29
37
  const FieldContent = {
30
38
  types: ["Text", "Date", "Timestamp", "Color", "Number", "Range", "Select"],
31
- forType: (type: string, value: unknown): O.Option<FieldContent> => {
39
+ forType: (type: FieldType, value: unknown): O.Option<FieldContent> => {
32
40
  return pipe(
33
41
  O.fromEither(t.string.decode(value)),
34
42
  O.map((r) => {
@@ -30,4 +30,4 @@ export const LinksTypes = {
30
30
  ExternalLink: ExternalLinkType,
31
31
  ImageLink: ImageLinkType,
32
32
  LinkContent: LinkContentType,
33
- }
33
+ } as const
@@ -3,7 +3,7 @@ import * as t from "io-ts"
3
3
 
4
4
  import { StringOrNull } from "../../../../validators"
5
5
  import { nullable, refineType } from "../../../../validators/function"
6
- import EmbedContent from "../EmbedContent"
6
+ import { EmbedContent } from "../EmbedContent"
7
7
  import { ImageContentView } from "../ImageContent"
8
8
  import { Link } from "../Link"
9
9
 
@@ -9,7 +9,7 @@ import { SeparatorContentType } from "./SeparatorContent"
9
9
  import { StructuredTextContentType } from "./StructuredTextContent"
10
10
 
11
11
  export { default as BooleanContent } from "./BooleanContent"
12
- export { default as EmbedContent } from "./EmbedContent"
12
+ export * from "./EmbedContent"
13
13
  export { default as FieldContent } from "./FieldContent"
14
14
  export { type GeoPointContentO, GeoPointContent } from "./GeoPointContent"
15
15
  export {
@@ -32,4 +32,4 @@ export const NestableTypes = {
32
32
  Image: ImageContentType,
33
33
  IntegrationFields: IntegrationFieldsContentType,
34
34
  Separator: SeparatorContentType,
35
- }
35
+ } as const