@prismicio/types-internal 1.5.3 → 2.0.0-alpha.0

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 (252) hide show
  1. package/lib/common/WidgetKey.d.ts +3 -0
  2. package/lib/common/WidgetKey.js +8 -0
  3. package/lib/common/index.d.ts +1 -0
  4. package/lib/common/index.js +4 -0
  5. package/lib/content/Document.d.ts +4285 -2573
  6. package/lib/content/Document.js +87 -10
  7. package/lib/content/LegacyContentCtx.d.ts +41 -0
  8. package/lib/content/LegacyContentCtx.js +65 -0
  9. package/lib/content/fields/EmptyContent.d.ts +16 -0
  10. package/lib/content/fields/EmptyContent.js +30 -0
  11. package/lib/content/fields/GroupContent.d.ts +1063 -364
  12. package/lib/content/fields/GroupContent.js +65 -6
  13. package/lib/content/fields/UIDContent.d.ts +10 -1
  14. package/lib/content/fields/UIDContent.js +17 -4
  15. package/lib/content/fields/WidgetContent.d.ts +6820 -0
  16. package/lib/content/fields/WidgetContent.js +57 -0
  17. package/lib/content/fields/index.d.ts +1 -2989
  18. package/lib/content/fields/index.js +1 -18
  19. package/lib/content/fields/nestable/BooleanContent.d.ts +10 -1
  20. package/lib/content/fields/nestable/BooleanContent.js +17 -4
  21. package/lib/content/fields/nestable/EmbedContent.d.ts +56 -5
  22. package/lib/content/fields/nestable/EmbedContent.js +57 -6
  23. package/lib/content/fields/nestable/FieldContent/ColorContent.d.ts +18 -0
  24. package/lib/content/fields/nestable/FieldContent/ColorContent.js +34 -0
  25. package/lib/content/fields/nestable/FieldContent/DateContent.d.ts +18 -0
  26. package/lib/content/fields/nestable/FieldContent/DateContent.js +34 -0
  27. package/lib/content/fields/nestable/FieldContent/NumberContent.d.ts +18 -0
  28. package/lib/content/fields/nestable/FieldContent/NumberContent.js +34 -0
  29. package/lib/content/fields/nestable/FieldContent/RangeContent.d.ts +18 -0
  30. package/lib/content/fields/nestable/FieldContent/RangeContent.js +34 -0
  31. package/lib/content/fields/nestable/FieldContent/SelectContent.d.ts +18 -0
  32. package/lib/content/fields/nestable/FieldContent/SelectContent.js +34 -0
  33. package/lib/content/fields/nestable/FieldContent/TextContent.d.ts +18 -0
  34. package/lib/content/fields/nestable/FieldContent/TextContent.js +34 -0
  35. package/lib/content/fields/nestable/FieldContent/TimestampContent.d.ts +18 -0
  36. package/lib/content/fields/nestable/FieldContent/TimestampContent.js +34 -0
  37. package/lib/content/fields/nestable/FieldContent/common.d.ts +1 -0
  38. package/lib/content/fields/nestable/FieldContent/common.js +4 -0
  39. package/lib/content/fields/nestable/FieldContent/index.d.ts +49 -0
  40. package/lib/content/fields/nestable/FieldContent/index.js +38 -0
  41. package/lib/content/fields/nestable/FieldContent.d.ts +7 -1
  42. package/lib/content/fields/nestable/FieldContent.js +19 -4
  43. package/lib/content/fields/nestable/GeoPointContent.d.ts +19 -4
  44. package/lib/content/fields/nestable/GeoPointContent.js +22 -5
  45. package/lib/content/fields/nestable/ImageContent.d.ts +109 -11
  46. package/lib/content/fields/nestable/ImageContent.js +64 -6
  47. package/lib/content/fields/nestable/IntegrationFieldContent.d.ts +10 -1
  48. package/lib/content/fields/nestable/IntegrationFieldContent.js +20 -4
  49. package/lib/content/fields/nestable/LinkContent.d.ts +240 -87
  50. package/lib/content/fields/nestable/LinkContent.js +133 -36
  51. package/lib/content/fields/nestable/NestableContent.d.ts +711 -251
  52. package/lib/content/fields/nestable/NestableContent.js +116 -13
  53. package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +594 -0
  54. package/lib/content/fields/nestable/RichTextContent/Blocks.js +151 -0
  55. package/lib/content/fields/nestable/RichTextContent/index.d.ts +489 -0
  56. package/lib/content/fields/nestable/RichTextContent/index.js +27 -0
  57. package/lib/content/fields/nestable/SeparatorContent.d.ts +8 -1
  58. package/lib/content/fields/nestable/SeparatorContent.js +15 -4
  59. package/lib/content/fields/slices/CompositeSliceContent.d.ts +296 -362
  60. package/lib/content/fields/slices/RepeatableContent.d.ts +148 -181
  61. package/lib/content/fields/slices/SharedSliceContent.d.ts +296 -362
  62. package/lib/content/fields/slices/SimpleSliceContent.d.ts +296 -362
  63. package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +1709 -0
  64. package/lib/content/fields/slices/Slice/CompositeSliceContent.js +81 -0
  65. package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +582 -0
  66. package/lib/content/fields/slices/Slice/RepeatableContent.js +18 -0
  67. package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +1713 -0
  68. package/lib/content/fields/slices/Slice/SharedSliceContent.js +98 -0
  69. package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +1429 -0
  70. package/lib/content/fields/slices/Slice/SimpleSliceContent.js +24 -0
  71. package/lib/content/fields/slices/Slice/index.d.ts +3216 -0
  72. package/lib/content/fields/slices/Slice/index.js +41 -0
  73. package/lib/content/fields/slices/SliceItem.d.ts +3498 -0
  74. package/lib/content/fields/slices/SliceItem.js +61 -0
  75. package/lib/content/fields/slices/SlicesContent.d.ts +4243 -3576
  76. package/lib/content/fields/slices/SlicesContent.js +28 -18
  77. package/lib/content/fields/slices/index.d.ts +4 -3
  78. package/lib/content/fields/slices/index.js +4 -3
  79. package/lib/content/index.d.ts +1 -0
  80. package/lib/content/index.js +1 -0
  81. package/lib/content/utils.d.ts +10 -0
  82. package/lib/content/utils.js +19 -0
  83. package/lib/customtypes/CustomType.d.ts +366 -366
  84. package/lib/customtypes/CustomType.js +4 -7
  85. package/lib/customtypes/Section.d.ts +366 -366
  86. package/lib/customtypes/Section.js +2 -2
  87. package/lib/customtypes/diff/SharedSlice.d.ts +4 -4
  88. package/lib/customtypes/diff/Variation.d.ts +4 -4
  89. package/lib/customtypes/widgets/Group.d.ts +1 -0
  90. package/lib/customtypes/widgets/Group.js +6 -5
  91. package/lib/customtypes/widgets/UID.d.ts +1 -0
  92. package/lib/customtypes/widgets/UID.js +3 -2
  93. package/lib/customtypes/widgets/Widget.d.ts +384 -362
  94. package/lib/customtypes/widgets/Widget.js +29 -8
  95. package/lib/customtypes/widgets/index.d.ts +6 -7
  96. package/lib/customtypes/widgets/index.js +6 -11
  97. package/lib/customtypes/widgets/nestable/BooleanField.d.ts +10 -3
  98. package/lib/customtypes/widgets/nestable/BooleanField.js +6 -6
  99. package/lib/customtypes/widgets/nestable/Color.d.ts +8 -3
  100. package/lib/customtypes/widgets/nestable/Color.js +6 -6
  101. package/lib/customtypes/widgets/nestable/Date.d.ts +9 -3
  102. package/lib/customtypes/widgets/nestable/Date.js +6 -6
  103. package/lib/customtypes/widgets/nestable/Embed.d.ts +9 -3
  104. package/lib/customtypes/widgets/nestable/Embed.js +6 -6
  105. package/lib/customtypes/widgets/nestable/GeoPoint.d.ts +7 -3
  106. package/lib/customtypes/widgets/nestable/GeoPoint.js +6 -6
  107. package/lib/customtypes/widgets/nestable/Image.d.ts +25 -3
  108. package/lib/customtypes/widgets/nestable/Image.js +8 -8
  109. package/lib/customtypes/widgets/nestable/IntegrationField.d.ts +9 -3
  110. package/lib/customtypes/widgets/nestable/IntegrationField.js +6 -6
  111. package/lib/customtypes/widgets/nestable/Link.d.ts +14 -2
  112. package/lib/customtypes/widgets/nestable/Link.js +7 -6
  113. package/lib/customtypes/widgets/nestable/NestableWidget.d.ts +3 -3
  114. package/lib/customtypes/widgets/nestable/NestableWidget.js +30 -30
  115. package/lib/customtypes/widgets/nestable/Number.d.ts +11 -3
  116. package/lib/customtypes/widgets/nestable/Number.js +6 -6
  117. package/lib/customtypes/widgets/nestable/Range.d.ts +11 -3
  118. package/lib/customtypes/widgets/nestable/Range.js +6 -6
  119. package/lib/customtypes/widgets/nestable/RichText.d.ts +1 -0
  120. package/lib/customtypes/widgets/nestable/RichText.js +3 -3
  121. package/lib/customtypes/widgets/nestable/Select.d.ts +10 -3
  122. package/lib/customtypes/widgets/nestable/Select.js +6 -6
  123. package/lib/customtypes/widgets/nestable/Separator.d.ts +7 -3
  124. package/lib/customtypes/widgets/nestable/Separator.js +6 -6
  125. package/lib/customtypes/widgets/nestable/Text.d.ts +9 -2
  126. package/lib/customtypes/widgets/nestable/Text.js +7 -6
  127. package/lib/customtypes/widgets/nestable/Timestamp.d.ts +9 -3
  128. package/lib/customtypes/widgets/nestable/Timestamp.js +6 -6
  129. package/lib/customtypes/widgets/nestable/index.d.ts +15 -15
  130. package/lib/customtypes/widgets/nestable/index.js +15 -31
  131. package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +1 -0
  132. package/lib/customtypes/widgets/slices/CompositeSlice.js +7 -6
  133. package/lib/customtypes/widgets/slices/LegacySlice.js +2 -2
  134. package/lib/customtypes/widgets/slices/SharedSlice.d.ts +1 -0
  135. package/lib/customtypes/widgets/slices/SharedSlice.js +7 -7
  136. package/lib/customtypes/widgets/slices/SharedSliceRef.js +2 -2
  137. package/lib/customtypes/widgets/slices/Slices.d.ts +364 -362
  138. package/lib/customtypes/widgets/slices/Slices.js +8 -8
  139. package/lib/customtypes/widgets/slices/SlicesTypes.d.ts +6 -5
  140. package/lib/customtypes/widgets/slices/SlicesTypes.js +8 -4
  141. package/lib/documents/DocumentData.d.ts +3 -14
  142. package/lib/documents/DocumentData.js +5 -60
  143. package/lib/documents/widgets/nestable/ImageContent.d.ts +1 -1
  144. package/lib/documents/widgets/nestable/ImageContent.js +2 -2
  145. package/lib/utils/Objects.d.ts +1 -0
  146. package/lib/utils/Objects.js +10 -1
  147. package/package.json +1 -1
  148. package/src/common/WidgetKey.ts +13 -0
  149. package/src/common/index.ts +1 -0
  150. package/src/content/Document.ts +129 -16
  151. package/src/content/LegacyContentCtx.ts +57 -0
  152. package/src/content/fields/EmptyContent.ts +45 -0
  153. package/src/content/fields/GroupContent.ts +103 -8
  154. package/src/content/fields/UIDContent.ts +33 -3
  155. package/src/content/fields/WidgetContent.ts +76 -0
  156. package/src/content/fields/index.ts +1 -23
  157. package/src/content/fields/nestable/BooleanContent.ts +32 -3
  158. package/src/content/fields/nestable/EmbedContent.ts +79 -8
  159. package/src/content/fields/nestable/FieldContent/ColorContent.ts +48 -0
  160. package/src/content/fields/nestable/FieldContent/DateContent.ts +48 -0
  161. package/src/content/fields/nestable/FieldContent/NumberContent.ts +48 -0
  162. package/src/content/fields/nestable/FieldContent/RangeContent.ts +48 -0
  163. package/src/content/fields/nestable/FieldContent/SelectContent.ts +48 -0
  164. package/src/content/fields/nestable/FieldContent/TextContent.ts +48 -0
  165. package/src/content/fields/nestable/FieldContent/TimestampContent.ts +48 -0
  166. package/src/content/fields/nestable/FieldContent/common.ts +1 -0
  167. package/src/content/fields/nestable/FieldContent/index.ts +40 -0
  168. package/src/content/fields/nestable/GeoPointContent.ts +38 -7
  169. package/src/content/fields/nestable/ImageContent.ts +91 -11
  170. package/src/content/fields/nestable/IntegrationFieldContent.ts +42 -3
  171. package/src/content/fields/nestable/LinkContent.ts +208 -47
  172. package/src/content/fields/nestable/NestableContent.ts +180 -24
  173. package/src/content/fields/nestable/RichTextContent/Blocks.ts +205 -0
  174. package/src/content/fields/nestable/RichTextContent/index.ts +43 -0
  175. package/src/content/fields/nestable/SeparatorContent.ts +26 -3
  176. package/src/content/fields/slices/Slice/CompositeSliceContent.ts +118 -0
  177. package/src/content/fields/slices/{RepeatableContent.ts → Slice/RepeatableContent.ts} +7 -4
  178. package/src/content/fields/slices/Slice/SharedSliceContent.ts +129 -0
  179. package/src/content/fields/slices/Slice/SimpleSliceContent.ts +30 -0
  180. package/src/content/fields/slices/Slice/index.ts +47 -0
  181. package/src/content/fields/slices/SliceItem.ts +83 -0
  182. package/src/content/fields/slices/SlicesContent.ts +47 -19
  183. package/src/content/fields/slices/index.ts +4 -3
  184. package/src/content/index.ts +1 -0
  185. package/src/content/utils.ts +20 -0
  186. package/src/customtypes/CustomType.ts +4 -10
  187. package/src/customtypes/Section.ts +1 -1
  188. package/src/customtypes/widgets/Group.ts +4 -4
  189. package/src/customtypes/widgets/UID.ts +3 -2
  190. package/src/customtypes/widgets/Widget.ts +53 -7
  191. package/src/customtypes/widgets/index.ts +6 -7
  192. package/src/customtypes/widgets/nestable/BooleanField.ts +7 -8
  193. package/src/customtypes/widgets/nestable/Color.ts +6 -8
  194. package/src/customtypes/widgets/nestable/Date.ts +7 -8
  195. package/src/customtypes/widgets/nestable/Embed.ts +7 -8
  196. package/src/customtypes/widgets/nestable/GeoPoint.ts +7 -8
  197. package/src/customtypes/widgets/nestable/Image.ts +9 -10
  198. package/src/customtypes/widgets/nestable/IntegrationField.ts +6 -8
  199. package/src/customtypes/widgets/nestable/Link.ts +7 -6
  200. package/src/customtypes/widgets/nestable/NestableWidget.ts +17 -18
  201. package/src/customtypes/widgets/nestable/Number.ts +7 -8
  202. package/src/customtypes/widgets/nestable/Range.ts +7 -8
  203. package/src/customtypes/widgets/nestable/RichText.ts +3 -2
  204. package/src/customtypes/widgets/nestable/Select.ts +7 -8
  205. package/src/customtypes/widgets/nestable/Separator.ts +7 -8
  206. package/src/customtypes/widgets/nestable/Text.ts +7 -6
  207. package/src/customtypes/widgets/nestable/Timestamp.ts +7 -8
  208. package/src/customtypes/widgets/nestable/index.ts +15 -15
  209. package/src/customtypes/widgets/slices/CompositeSlice.ts +5 -4
  210. package/src/customtypes/widgets/slices/LegacySlice.ts +1 -1
  211. package/src/customtypes/widgets/slices/SharedSlice.ts +5 -4
  212. package/src/customtypes/widgets/slices/SharedSliceRef.ts +2 -2
  213. package/src/customtypes/widgets/slices/Slices.ts +7 -6
  214. package/src/customtypes/widgets/slices/SlicesTypes.ts +10 -5
  215. package/src/utils/Objects.ts +12 -0
  216. package/src/content/fields/nestable/FieldContent.ts +0 -25
  217. package/src/content/fields/nestable/RichTextContent.ts +0 -32
  218. package/src/content/fields/slices/CompositeSliceContent.ts +0 -14
  219. package/src/content/fields/slices/SharedSliceContent.ts +0 -14
  220. package/src/content/fields/slices/SimpleSliceContent.ts +0 -7
  221. package/src/customtypes/widgets/WidgetTypes.ts +0 -24
  222. package/src/documents/DocumentData.ts +0 -112
  223. package/src/documents/index.ts +0 -2
  224. package/src/documents/widgets/EmptyContent.ts +0 -8
  225. package/src/documents/widgets/GroupContent.ts +0 -91
  226. package/src/documents/widgets/SimpleWidgetContent.ts +0 -96
  227. package/src/documents/widgets/StaticWidgetContent.ts +0 -46
  228. package/src/documents/widgets/UIDContent.ts +0 -18
  229. package/src/documents/widgets/index.ts +0 -70
  230. package/src/documents/widgets/nestable/BooleanContent.ts +0 -21
  231. package/src/documents/widgets/nestable/EmbedContent.ts +0 -56
  232. package/src/documents/widgets/nestable/FieldContent.ts +0 -53
  233. package/src/documents/widgets/nestable/GeoPointContent.ts +0 -18
  234. package/src/documents/widgets/nestable/ImageContent.ts +0 -51
  235. package/src/documents/widgets/nestable/IntegrationFieldsContent.ts +0 -26
  236. package/src/documents/widgets/nestable/Link/DocumentLink.ts +0 -18
  237. package/src/documents/widgets/nestable/Link/ExternalLink.ts +0 -31
  238. package/src/documents/widgets/nestable/Link/FileLink.ts +0 -30
  239. package/src/documents/widgets/nestable/Link/ImageLink.ts +0 -31
  240. package/src/documents/widgets/nestable/Link/LinkContent.ts +0 -25
  241. package/src/documents/widgets/nestable/Link/index.ts +0 -35
  242. package/src/documents/widgets/nestable/SeparatorContent.ts +0 -13
  243. package/src/documents/widgets/nestable/StructuredTextContent/Block.ts +0 -126
  244. package/src/documents/widgets/nestable/StructuredTextContent/index.ts +0 -25
  245. package/src/documents/widgets/nestable/index.ts +0 -35
  246. package/src/documents/widgets/slices/CompositeSliceContent.ts +0 -77
  247. package/src/documents/widgets/slices/SharedSliceContent.ts +0 -94
  248. package/src/documents/widgets/slices/SimpleSliceContent.ts +0 -4
  249. package/src/documents/widgets/slices/SliceWidgetContent.ts +0 -51
  250. package/src/documents/widgets/slices/SlicesContent.ts +0 -91
  251. package/src/documents/widgets/slices/index.ts +0 -5
  252. package/src/index.ts +0 -3
@@ -1,7 +1,103 @@
1
1
  import * as t from "io-ts";
2
+ import type { LegacyContentCtx, WithTypes } from "../../LegacyContentCtx";
3
+ export declare const ImageLinkType = "ImageLink";
2
4
  export declare const ImageLinkContent: t.IntersectionC<[t.ExactC<t.TypeC<{
3
5
  __TYPE__: t.LiteralC<"ImageLink">;
4
- }>>, t.Type<{
6
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
7
+ id: t.StringC;
8
+ url: t.StringC;
9
+ height: t.StringC;
10
+ width: t.StringC;
11
+ size: t.StringC;
12
+ name: t.StringC;
13
+ kind: t.StringC;
14
+ }>, t.PartialC<{
15
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
16
+ }>]>>]>;
17
+ export declare type ImageLinkContent = t.TypeOf<typeof ImageLinkContent>;
18
+ export declare const FileLinkType = "FileLink";
19
+ export declare const FileLinkContent: t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
20
+ id: t.StringC;
21
+ url: t.StringC;
22
+ name: t.StringC;
23
+ kind: t.StringC;
24
+ }>, t.PartialC<{
25
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
26
+ size: t.StringC;
27
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
28
+ __TYPE__: t.LiteralC<"FileLink">;
29
+ }>, t.PartialC<{
30
+ size: t.StringC;
31
+ }>]>>]>;
32
+ export declare type FileLinkContent = t.TypeOf<typeof FileLinkContent>;
33
+ export declare const DocumentLinkType = "DocumentLink";
34
+ export declare const DocumentLinkContent: t.IntersectionC<[t.ExactC<t.TypeC<{
35
+ __TYPE__: t.LiteralC<"DocumentLink">;
36
+ }>>, t.ExactC<t.TypeC<{
37
+ id: t.Type<string, string, unknown>;
38
+ }>>]>;
39
+ export declare type DocumentLinkContent = t.TypeOf<typeof DocumentLinkContent>;
40
+ export declare const ExternalLinkType = "ExternalLink";
41
+ export declare const ExternalLinkContent: t.IntersectionC<[t.ExactC<t.TypeC<{
42
+ __TYPE__: t.LiteralC<"ExternalLink">;
43
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
44
+ url: t.StringC;
45
+ }>, t.PartialC<{
46
+ kind: t.LiteralC<"web">;
47
+ target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
48
+ preview: t.UnionC<[t.Type<{
49
+ title?: string;
50
+ }, {
51
+ title?: string;
52
+ }, unknown>, t.NullC, t.UndefinedC]>;
53
+ }>]>>]>;
54
+ export declare type ExternalLinkContent = t.TypeOf<typeof ExternalLinkContent>;
55
+ export declare const LinkContentType = "LinkContent";
56
+ export declare const isLinkContent: (u: unknown) => u is {
57
+ __TYPE__: "LinkContent";
58
+ value: ({
59
+ __TYPE__: "ImageLink";
60
+ } & {
61
+ id: string;
62
+ url: string;
63
+ height: string;
64
+ width: string;
65
+ size: string;
66
+ name: string;
67
+ kind: string;
68
+ } & {
69
+ date?: string | null | undefined;
70
+ }) | ({
71
+ id: string;
72
+ url: string;
73
+ name: string;
74
+ kind: string;
75
+ } & {
76
+ date?: string | null | undefined;
77
+ size?: string;
78
+ } & {
79
+ __TYPE__: "FileLink";
80
+ } & {
81
+ size?: string;
82
+ }) | ({
83
+ __TYPE__: "DocumentLink";
84
+ } & {
85
+ id: string;
86
+ }) | ({
87
+ __TYPE__: "ExternalLink";
88
+ } & {
89
+ url: string;
90
+ } & {
91
+ kind?: "web";
92
+ target?: string | null | undefined;
93
+ preview?: {
94
+ title?: string;
95
+ } | null | undefined;
96
+ });
97
+ };
98
+ export declare const LinkLegacy: t.UnionC<[t.Type<{
99
+ __TYPE__: "ImageLink";
100
+ } & {
5
101
  id: string;
6
102
  url: string;
7
103
  height: string;
@@ -21,12 +117,7 @@ export declare const ImageLinkContent: t.IntersectionC<[t.ExactC<t.TypeC<{
21
117
  kind: string;
22
118
  } & {
23
119
  date?: string | null | undefined;
24
- } & {
25
- __TYPE__: "ImageLink";
26
- }, unknown>]>;
27
- export declare type ImageLinkContent = t.TypeOf<typeof ImageLinkContent>;
28
- export declare const ImageLinkType = "ImageLink";
29
- export declare const FileLinkContent: t.IntersectionC<[t.Type<{
120
+ }, unknown>, t.Type<{
30
121
  id: string;
31
122
  url: string;
32
123
  name: string;
@@ -34,34 +125,27 @@ export declare const FileLinkContent: t.IntersectionC<[t.Type<{
34
125
  } & {
35
126
  date?: string | null | undefined;
36
127
  size?: string;
128
+ } & {
129
+ __TYPE__: "FileLink";
130
+ } & {
131
+ size?: string;
37
132
  }, {
38
- readonly size: string;
39
- readonly __TYPE__: "FileLink";
40
- readonly id: string;
41
- readonly url: string;
42
- readonly name: string;
43
- readonly kind: string;
44
- readonly date?: string | null | undefined;
45
- }, unknown>, t.ExactC<t.TypeC<{
46
- __TYPE__: t.LiteralC<"FileLink">;
47
- size: t.StringC;
48
- }>>]>;
49
- export declare type FileLinkContent = t.TypeOf<typeof FileLinkContent>;
50
- export declare const FileLinkType = "FileLink";
51
- export declare const DocumentLinkContent: t.IntersectionC<[t.ExactC<t.TypeC<{
52
- __TYPE__: t.LiteralC<"DocumentLink">;
53
- }>>, t.Type<{
133
+ id: string;
134
+ url: string;
135
+ name: string;
136
+ kind: string;
137
+ } & {
138
+ date?: string | null | undefined;
139
+ size?: string;
140
+ }, unknown>, t.Type<{
141
+ __TYPE__: "DocumentLink";
142
+ } & {
54
143
  id: string;
55
144
  }, {
56
145
  id: string;
146
+ }, unknown>, t.Type<{
147
+ __TYPE__: "ExternalLink";
57
148
  } & {
58
- __TYPE__: "DocumentLink";
59
- }, unknown>]>;
60
- export declare type DocumentLinkContent = t.TypeOf<typeof DocumentLinkContent>;
61
- export declare const DocumentLinkType = "DocumentLink";
62
- export declare const ExternalLinkContent: t.IntersectionC<[t.ExactC<t.TypeC<{
63
- __TYPE__: t.LiteralC<"ExternalLink">;
64
- }>>, t.Type<{
65
149
  url: string;
66
150
  } & {
67
151
  kind?: "web";
@@ -77,16 +161,12 @@ export declare const ExternalLinkContent: t.IntersectionC<[t.ExactC<t.TypeC<{
77
161
  preview?: {
78
162
  title?: string;
79
163
  } | null | undefined;
80
- } & {
81
- __TYPE__: "ExternalLink";
82
164
  }, unknown>]>;
83
- export declare type ExternalLinkContent = t.TypeOf<typeof ExternalLinkContent>;
84
- export declare const ExternalLinkType = "ExternalLink";
85
- export declare const LinkContent: t.ExactC<t.TypeC<{
86
- __TYPE__: t.LiteralC<"LinkContent">;
87
- value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
88
- __TYPE__: t.LiteralC<"ImageLink">;
89
- }>>, t.Type<{
165
+ export declare const LinkContentLegacy: (ctx: LegacyContentCtx) => t.Type<{
166
+ __TYPE__: "LinkContent";
167
+ value: ({
168
+ __TYPE__: "ImageLink";
169
+ } & {
90
170
  id: string;
91
171
  url: string;
92
172
  height: string;
@@ -96,48 +176,25 @@ export declare const LinkContent: t.ExactC<t.TypeC<{
96
176
  kind: string;
97
177
  } & {
98
178
  date?: string | null | undefined;
99
- }, {
179
+ }) | ({
100
180
  id: string;
101
181
  url: string;
102
- height: string;
103
- width: string;
104
- size: string;
105
182
  name: string;
106
183
  kind: string;
107
184
  } & {
108
185
  date?: string | null | undefined;
186
+ size?: string;
109
187
  } & {
110
- __TYPE__: "ImageLink";
111
- }, unknown>]>, t.IntersectionC<[t.Type<{
112
- id: string;
113
- url: string;
114
- name: string;
115
- kind: string;
188
+ __TYPE__: "FileLink";
116
189
  } & {
117
- date?: string | null | undefined;
118
190
  size?: string;
119
- }, {
120
- readonly size: string;
121
- readonly __TYPE__: "FileLink";
122
- readonly id: string;
123
- readonly url: string;
124
- readonly name: string;
125
- readonly kind: string;
126
- readonly date?: string | null | undefined;
127
- }, unknown>, t.ExactC<t.TypeC<{
128
- __TYPE__: t.LiteralC<"FileLink">;
129
- size: t.StringC;
130
- }>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
131
- __TYPE__: t.LiteralC<"DocumentLink">;
132
- }>>, t.Type<{
133
- id: string;
134
- }, {
191
+ }) | ({
192
+ __TYPE__: "DocumentLink";
193
+ } & {
135
194
  id: string;
195
+ }) | ({
196
+ __TYPE__: "ExternalLink";
136
197
  } & {
137
- __TYPE__: "DocumentLink";
138
- }, unknown>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
139
- __TYPE__: t.LiteralC<"ExternalLink">;
140
- }>>, t.Type<{
141
198
  url: string;
142
199
  } & {
143
200
  kind?: "web";
@@ -145,24 +202,120 @@ export declare const LinkContent: t.ExactC<t.TypeC<{
145
202
  preview?: {
146
203
  title?: string;
147
204
  } | null | undefined;
205
+ });
206
+ }, WithTypes<({
207
+ id: string;
208
+ url: string;
209
+ height: string;
210
+ width: string;
211
+ size: string;
212
+ name: string;
213
+ kind: string;
214
+ } & {
215
+ date?: string | null | undefined;
216
+ }) | ({
217
+ id: string;
218
+ url: string;
219
+ name: string;
220
+ kind: string;
221
+ } & {
222
+ date?: string | null | undefined;
223
+ size?: string;
224
+ }) | {
225
+ id: string;
226
+ } | ({
227
+ url: string;
228
+ } & {
229
+ kind?: "web";
230
+ target?: string | null | undefined;
231
+ preview?: {
232
+ title?: string;
233
+ } | null | undefined;
234
+ })>, unknown>;
235
+ export declare const Link: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
236
+ __TYPE__: t.LiteralC<"ImageLink">;
237
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
238
+ id: t.StringC;
239
+ url: t.StringC;
240
+ height: t.StringC;
241
+ width: t.StringC;
242
+ size: t.StringC;
243
+ name: t.StringC;
244
+ kind: t.StringC;
245
+ }>, t.PartialC<{
246
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
247
+ }>]>>]>, t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
248
+ id: t.StringC;
249
+ url: t.StringC;
250
+ name: t.StringC;
251
+ kind: t.StringC;
252
+ }>, t.PartialC<{
253
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
254
+ size: t.StringC;
255
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
256
+ __TYPE__: t.LiteralC<"FileLink">;
257
+ }>, t.PartialC<{
258
+ size: t.StringC;
259
+ }>]>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
260
+ __TYPE__: t.LiteralC<"DocumentLink">;
261
+ }>>, t.ExactC<t.TypeC<{
262
+ id: t.Type<string, string, unknown>;
263
+ }>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
264
+ __TYPE__: t.LiteralC<"ExternalLink">;
265
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
266
+ url: t.StringC;
267
+ }>, t.PartialC<{
268
+ kind: t.LiteralC<"web">;
269
+ target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
270
+ preview: t.UnionC<[t.Type<{
271
+ title?: string;
148
272
  }, {
149
- url: string;
150
- } & {
151
- kind?: "web";
152
- target?: string | null | undefined;
153
- preview?: {
273
+ title?: string;
274
+ }, unknown>, t.NullC, t.UndefinedC]>;
275
+ }>]>>]>]>;
276
+ export declare const LinkContent: t.ExactC<t.TypeC<{
277
+ __TYPE__: t.LiteralC<"LinkContent">;
278
+ value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
279
+ __TYPE__: t.LiteralC<"ImageLink">;
280
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
281
+ id: t.StringC;
282
+ url: t.StringC;
283
+ height: t.StringC;
284
+ width: t.StringC;
285
+ size: t.StringC;
286
+ name: t.StringC;
287
+ kind: t.StringC;
288
+ }>, t.PartialC<{
289
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
290
+ }>]>>]>, t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
291
+ id: t.StringC;
292
+ url: t.StringC;
293
+ name: t.StringC;
294
+ kind: t.StringC;
295
+ }>, t.PartialC<{
296
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
297
+ size: t.StringC;
298
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
299
+ __TYPE__: t.LiteralC<"FileLink">;
300
+ }>, t.PartialC<{
301
+ size: t.StringC;
302
+ }>]>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
303
+ __TYPE__: t.LiteralC<"DocumentLink">;
304
+ }>>, t.ExactC<t.TypeC<{
305
+ id: t.Type<string, string, unknown>;
306
+ }>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
307
+ __TYPE__: t.LiteralC<"ExternalLink">;
308
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
309
+ url: t.StringC;
310
+ }>, t.PartialC<{
311
+ kind: t.LiteralC<"web">;
312
+ target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
313
+ preview: t.UnionC<[t.Type<{
154
314
  title?: string;
155
- } | null | undefined;
156
- } & {
157
- __TYPE__: "ExternalLink";
158
- }, unknown>]>]>;
315
+ }, {
316
+ title?: string;
317
+ }, unknown>, t.NullC, t.UndefinedC]>;
318
+ }>]>>]>]>;
159
319
  }>>;
160
320
  export declare type LinkContent = t.TypeOf<typeof LinkContent>;
161
- export declare const LinkContentType = "LinkContent";
162
- export declare const LinksTypes: {
163
- readonly DocumentLink: "DocumentLink";
164
- readonly FileLink: "FileLink";
165
- readonly ExternalLink: "ExternalLink";
166
- readonly ImageLink: "ImageLink";
167
- readonly LinkContent: "LinkContent";
168
- };
321
+ export declare type LinksTypes = LinkContent["__TYPE__"] | LinkContent["value"]["__TYPE__"];
@@ -1,57 +1,154 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LinksTypes = exports.LinkContentType = exports.LinkContent = exports.ExternalLinkType = exports.ExternalLinkContent = exports.DocumentLinkType = exports.DocumentLinkContent = exports.FileLinkType = exports.FileLinkContent = exports.ImageLinkType = exports.ImageLinkContent = void 0;
3
+ exports.LinkContent = exports.Link = exports.LinkContentLegacy = exports.LinkLegacy = exports.isLinkContent = exports.LinkContentType = exports.ExternalLinkContent = exports.ExternalLinkType = exports.DocumentLinkContent = exports.DocumentLinkType = exports.FileLinkContent = exports.FileLinkType = exports.ImageLinkContent = exports.ImageLinkType = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const fp_ts_1 = require("fp-ts");
6
+ const function_1 = require("fp-ts/lib/function");
5
7
  const t = (0, tslib_1.__importStar)(require("io-ts"));
6
8
  const io_ts_types_1 = require("io-ts-types");
7
- const DocumentLink_1 = require("../../../documents/widgets/nestable/Link/DocumentLink");
8
- const ExternalLink_1 = require("../../../documents/widgets/nestable/Link/ExternalLink");
9
- const FileLink_1 = require("../../../documents/widgets/nestable/Link/FileLink");
10
- const ImageLink_1 = require("../../../documents/widgets/nestable/Link/ImageLink");
11
- const LinkContent_1 = require("../../../documents/widgets/nestable/Link/LinkContent");
9
+ const validators_1 = require("../../../validators");
10
+ const function_2 = require("../../../validators/function");
11
+ const utils_1 = require("../../utils");
12
+ exports.ImageLinkType = "ImageLink";
13
+ const imageLinkLegacyCodec = t.exact(t.intersection([
14
+ t.type({
15
+ id: t.string,
16
+ url: t.string,
17
+ height: t.string,
18
+ width: t.string,
19
+ size: t.string,
20
+ name: t.string,
21
+ kind: t.string,
22
+ }),
23
+ t.partial({
24
+ date: validators_1.StringOrNull,
25
+ }),
26
+ ]));
27
+ const ImageLinkLegacy = new t.Type("ImageLink", (u) => (0, utils_1.hasContentType)(u) && u.__TYPE__ === exports.ImageLinkType, (image) => {
28
+ return (0, function_1.pipe)(imageLinkLegacyCodec.decode(image), fp_ts_1.either.map((parsedImage) => {
29
+ return exports.ImageLinkContent.encode({
30
+ ...parsedImage,
31
+ __TYPE__: exports.ImageLinkType,
32
+ });
33
+ }));
34
+ }, (image) => {
35
+ return imageLinkLegacyCodec.encode(image);
36
+ });
12
37
  exports.ImageLinkContent = t.intersection([
13
38
  t.strict({
14
- __TYPE__: t.literal(ImageLink_1.ImageLinkType),
39
+ __TYPE__: t.literal(exports.ImageLinkType),
15
40
  }),
16
- ImageLink_1.ImageLink,
41
+ imageLinkLegacyCodec,
17
42
  ]);
18
- exports.ImageLinkType = ImageLink_1.ImageLinkType;
19
- exports.FileLinkContent = t.intersection([
20
- FileLink_1.FileLink,
21
- t.exact(t.type({
22
- __TYPE__: t.literal(FileLink_1.FileLinkType),
43
+ exports.FileLinkType = "FileLink";
44
+ const fileLinkLegacyCodec = t.exact(t.intersection([
45
+ t.type({
46
+ id: t.string,
47
+ url: t.string,
48
+ name: t.string,
49
+ kind: t.string,
50
+ }),
51
+ t.partial({
52
+ date: (0, function_2.nullable)(t.string),
23
53
  size: (0, io_ts_types_1.withFallback)(t.string, "0"),
24
- })),
54
+ }),
55
+ ]));
56
+ const FileLinkLegacy = new t.Type("FileLink", (u) => (0, utils_1.hasContentType)(u) && u.__TYPE__ === exports.FileLinkType, (file) => {
57
+ return (0, function_1.pipe)(fileLinkLegacyCodec.decode(file), fp_ts_1.either.map((parsedFile) => {
58
+ return exports.FileLinkContent.encode({
59
+ ...parsedFile,
60
+ __TYPE__: exports.FileLinkType,
61
+ });
62
+ }));
63
+ }, (file) => {
64
+ return fileLinkLegacyCodec.encode(file);
65
+ });
66
+ exports.FileLinkContent = t.intersection([
67
+ fileLinkLegacyCodec,
68
+ t.exact(t.intersection([
69
+ t.type({
70
+ __TYPE__: t.literal(exports.FileLinkType),
71
+ }),
72
+ t.partial({
73
+ size: (0, io_ts_types_1.withFallback)(t.string, "0"),
74
+ }),
75
+ ])),
25
76
  ]);
26
- exports.FileLinkType = FileLink_1.FileLinkType;
77
+ exports.DocumentLinkType = "DocumentLink";
78
+ const documentLinkLegacyCodec = t.strict({ id: validators_1.NonEmptyString });
79
+ const DocumentLinkLegacy = new t.Type("DocumentLink", (u) => (0, utils_1.hasContentType)(u) && u.__TYPE__ === exports.DocumentLinkType, (file) => {
80
+ return (0, function_1.pipe)(documentLinkLegacyCodec.decode(file), fp_ts_1.either.map((parsedDoc) => {
81
+ return exports.DocumentLinkContent.encode({
82
+ ...parsedDoc,
83
+ __TYPE__: exports.DocumentLinkType,
84
+ });
85
+ }));
86
+ }, (doc) => {
87
+ return documentLinkLegacyCodec.encode(doc);
88
+ });
27
89
  exports.DocumentLinkContent = t.intersection([
28
90
  t.strict({
29
- __TYPE__: t.literal(DocumentLink_1.DocumentLinkType),
91
+ __TYPE__: t.literal(exports.DocumentLinkType),
30
92
  }),
31
- DocumentLink_1.DocumentLink,
93
+ documentLinkLegacyCodec,
32
94
  ]);
33
- exports.DocumentLinkType = DocumentLink_1.DocumentLinkType;
95
+ exports.ExternalLinkType = "ExternalLink";
96
+ const externalLinkLegacyCodec = t.exact(t.intersection([
97
+ t.type({
98
+ url: t.string,
99
+ }),
100
+ t.partial({
101
+ kind: t.literal("web"),
102
+ target: validators_1.StringOrNull,
103
+ preview: (0, function_2.nullable)(t.partial({
104
+ title: t.string,
105
+ })),
106
+ }),
107
+ ]));
108
+ const ExternalLinkLegacy = new t.Type("ExternalLink", (u) => (0, utils_1.hasContentType)(u) && u.__TYPE__ === exports.ExternalLinkType, (file) => {
109
+ return (0, function_1.pipe)(externalLinkLegacyCodec.decode(file), fp_ts_1.either.map((parsedLink) => {
110
+ return exports.ExternalLinkContent.encode({
111
+ ...parsedLink,
112
+ __TYPE__: exports.ExternalLinkType,
113
+ });
114
+ }));
115
+ }, (link) => {
116
+ return externalLinkLegacyCodec.encode(link);
117
+ });
34
118
  exports.ExternalLinkContent = t.intersection([
35
119
  t.strict({
36
- __TYPE__: t.literal(ExternalLink_1.ExternalLinkType),
120
+ __TYPE__: t.literal(exports.ExternalLinkType),
37
121
  }),
38
- ExternalLink_1.ExternalLink,
122
+ externalLinkLegacyCodec,
123
+ ]);
124
+ exports.LinkContentType = "LinkContent";
125
+ const isLinkContent = (u) => (0, utils_1.hasContentType)(u) && u.__TYPE__ === exports.LinkContentType;
126
+ exports.isLinkContent = isLinkContent;
127
+ exports.LinkLegacy = t.union([
128
+ ImageLinkLegacy,
129
+ FileLinkLegacy,
130
+ DocumentLinkLegacy,
131
+ ExternalLinkLegacy,
132
+ ]);
133
+ const LinkContentLegacy = (ctx) => new t.Type("LinkLegacy", exports.isLinkContent, (u) => {
134
+ return (0, function_1.pipe)(exports.LinkLegacy.decode(u), fp_ts_1.either.map((link) => exports.LinkContent.encode({
135
+ value: link,
136
+ __TYPE__: exports.LinkContentType,
137
+ })));
138
+ }, (link) => {
139
+ return {
140
+ content: exports.LinkLegacy.encode(link.value),
141
+ types: { [ctx.keyOfType]: "Link" },
142
+ };
143
+ });
144
+ exports.LinkContentLegacy = LinkContentLegacy;
145
+ exports.Link = t.union([
146
+ exports.ImageLinkContent,
147
+ exports.FileLinkContent,
148
+ exports.DocumentLinkContent,
149
+ exports.ExternalLinkContent,
39
150
  ]);
40
- exports.ExternalLinkType = ExternalLink_1.ExternalLinkType;
41
151
  exports.LinkContent = t.strict({
42
- __TYPE__: t.literal(LinkContent_1.LinkContentType),
43
- value: t.union([
44
- exports.ImageLinkContent,
45
- exports.FileLinkContent,
46
- exports.DocumentLinkContent,
47
- exports.ExternalLinkContent,
48
- ]),
152
+ __TYPE__: t.literal(exports.LinkContentType),
153
+ value: exports.Link,
49
154
  });
50
- exports.LinkContentType = LinkContent_1.LinkContentType;
51
- exports.LinksTypes = {
52
- DocumentLink: exports.DocumentLinkType,
53
- FileLink: exports.FileLinkType,
54
- ExternalLink: exports.ExternalLinkType,
55
- ImageLink: exports.ImageLinkType,
56
- LinkContent: exports.LinkContentType,
57
- };