@prismicio/types-internal 2.2.0-alpha.2 → 2.2.0-alpha.21

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 (244) hide show
  1. package/lib/common/Asset.d.ts +16 -0
  2. package/lib/common/Asset.js +11 -0
  3. package/lib/common/Embed.d.ts +15 -0
  4. package/lib/common/Embed.js +10 -0
  5. package/lib/common/UUID.d.ts +7 -0
  6. package/lib/common/UUID.js +8 -0
  7. package/lib/common/index.d.ts +2 -0
  8. package/lib/common/index.js +2 -0
  9. package/lib/content/Document.d.ts +40 -40
  10. package/lib/content/fields/GroupContent.d.ts +12 -12
  11. package/lib/content/fields/WidgetContent.d.ts +56 -56
  12. package/lib/content/fields/nestable/NestableContent.d.ts +7 -7
  13. package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +35 -12
  14. package/lib/content/fields/nestable/RichTextContent/Blocks.js +5 -5
  15. package/lib/content/fields/nestable/RichTextContent/index.d.ts +9 -9
  16. package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +14 -14
  17. package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +5 -5
  18. package/lib/content/fields/slices/Slice/RepeatableContent.js +0 -1
  19. package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +14 -14
  20. package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +14 -14
  21. package/lib/content/fields/slices/Slice/index.d.ts +30 -30
  22. package/lib/content/fields/slices/SliceItem.d.ts +30 -30
  23. package/lib/content/fields/slices/SlicesContent.d.ts +42 -42
  24. package/lib/customtypes/CustomType.d.ts +2 -0
  25. package/lib/customtypes/CustomType.js +8 -1
  26. package/lib/import/converters/Document.d.ts +2 -2
  27. package/lib/import/converters/Document.js +6 -6
  28. package/lib/import/converters/fields/Slices/SharedSlice.d.ts +4 -0
  29. package/lib/import/converters/fields/Slices/SharedSlice.js +19 -0
  30. package/lib/import/converters/fields/Slices/SharedSliceContent.d.ts +10 -0
  31. package/lib/import/converters/fields/Slices/SharedSliceContent.js +58 -0
  32. package/lib/import/converters/fields/Slices/Slices.d.ts +4 -0
  33. package/lib/import/converters/fields/Slices/Slices.js +16 -0
  34. package/lib/import/converters/fields/Slices/index.d.ts +1 -0
  35. package/lib/import/converters/fields/Slices/index.js +4 -0
  36. package/lib/import/converters/fields/UID.d.ts +1 -1
  37. package/lib/import/converters/fields/UID.js +0 -2
  38. package/lib/import/converters/fields/index.d.ts +1 -0
  39. package/lib/import/converters/fields/index.js +1 -0
  40. package/lib/import/converters/fields/nestable/Embed.d.ts +2 -1
  41. package/lib/import/converters/fields/nestable/Embed.js +24 -5
  42. package/lib/import/converters/fields/nestable/GeoPoint.d.ts +3 -0
  43. package/lib/import/converters/fields/nestable/GeoPoint.js +15 -0
  44. package/lib/import/converters/fields/nestable/GeooPoint.d.ts +3 -0
  45. package/lib/import/converters/fields/nestable/GeooPoint.js +15 -0
  46. package/lib/import/converters/fields/nestable/Image.d.ts +6 -18
  47. package/lib/import/converters/fields/nestable/Image.js +47 -24
  48. package/lib/import/converters/fields/nestable/Link.d.ts +3 -2
  49. package/lib/import/converters/fields/nestable/Link.js +62 -11
  50. package/lib/import/converters/fields/nestable/Nestable.d.ts +4 -3
  51. package/lib/import/converters/fields/nestable/Nestable.js +9 -3
  52. package/lib/import/converters/fields/nestable/RichText/embedBlock.d.ts +4 -0
  53. package/lib/import/converters/fields/nestable/RichText/embedBlock.js +14 -0
  54. package/lib/import/converters/fields/nestable/RichText/imageBlock.d.ts +4 -0
  55. package/lib/import/converters/fields/nestable/RichText/imageBlock.js +12 -0
  56. package/lib/import/converters/fields/nestable/RichText/index.d.ts +4 -0
  57. package/lib/import/converters/fields/nestable/RichText/index.js +22 -0
  58. package/lib/import/converters/fields/nestable/RichText/textBlock.d.ts +4 -0
  59. package/lib/import/converters/fields/nestable/RichText/textBlock.js +34 -0
  60. package/lib/import/converters/fields/nestable/RichText.d.ts +4 -0
  61. package/lib/import/converters/fields/nestable/RichText.js +55 -0
  62. package/lib/import/converters/fields/nestable/index.d.ts +3 -0
  63. package/lib/import/converters/fields/nestable/index.js +3 -0
  64. package/lib/import/validators/Document.js +4 -9
  65. package/lib/import/validators/fields/ImportField.d.ts +68 -68
  66. package/lib/import/validators/fields/ImportField.js +8 -4
  67. package/lib/import/validators/fields/ImportSlices/ImportSlices.d.ts +8 -0
  68. package/lib/import/validators/fields/ImportSlices/ImportSlices.js +29 -0
  69. package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.d.ts +14 -0
  70. package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.js +61 -0
  71. package/lib/import/validators/fields/ImportSlices/SharedSlice/errors.d.ts +4 -0
  72. package/lib/import/validators/fields/ImportSlices/SharedSlice/errors.js +7 -0
  73. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/OptionalSharedSliceId.d.ts +2 -0
  74. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/OptionalSharedSliceId.js +15 -0
  75. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.d.ts +17 -0
  76. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.js +30 -0
  77. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.d.ts +43 -0
  78. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.js +69 -0
  79. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/errors.d.ts +4 -0
  80. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/errors.js +6 -0
  81. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/index.d.ts +2 -0
  82. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/index.js +5 -0
  83. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/types.d.ts +1 -0
  84. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/types.js +2 -0
  85. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceId.d.ts +9 -0
  86. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceId.js +39 -0
  87. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.d.ts +11 -0
  88. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.js +24 -0
  89. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.d.ts +11 -0
  90. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.js +24 -0
  91. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/index.d.ts +5 -0
  92. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/index.js +8 -0
  93. package/lib/import/validators/fields/ImportSlices/SharedSlice/index.d.ts +3 -0
  94. package/lib/import/validators/fields/ImportSlices/SharedSlice/index.js +6 -0
  95. package/lib/import/validators/fields/ImportSlices/SharedSlice/utils.d.ts +339 -0
  96. package/lib/import/validators/fields/ImportSlices/SharedSlice/utils.js +11 -0
  97. package/lib/import/validators/fields/ImportSlices/index.d.ts +1 -0
  98. package/lib/import/validators/fields/ImportSlices/index.js +4 -0
  99. package/lib/import/validators/fields/ImportSlices/utils.d.ts +4 -0
  100. package/lib/import/validators/fields/ImportSlices/utils.js +35 -0
  101. package/lib/import/validators/fields/UID.d.ts +2 -2
  102. package/lib/import/validators/fields/UID.js +1 -1
  103. package/lib/import/validators/fields/nestable/Embed.d.ts +8 -22
  104. package/lib/import/validators/fields/nestable/Embed.js +5 -28
  105. package/lib/import/validators/fields/nestable/GeoPoint.d.ts +13 -0
  106. package/lib/import/validators/fields/nestable/GeoPoint.js +13 -0
  107. package/lib/import/validators/fields/nestable/Image/default.d.ts +22 -0
  108. package/lib/import/validators/fields/nestable/Image/default.js +19 -0
  109. package/lib/import/validators/fields/nestable/Image/index.d.ts +45 -0
  110. package/lib/import/validators/fields/nestable/Image/index.js +41 -0
  111. package/lib/import/validators/fields/nestable/Image/merge.d.ts +23 -0
  112. package/lib/import/validators/fields/nestable/Image/merge.js +44 -0
  113. package/lib/import/validators/fields/nestable/Image/model.d.ts +18 -0
  114. package/lib/import/validators/fields/nestable/Image/model.js +2 -0
  115. package/lib/import/validators/fields/nestable/Image/validators.d.ts +35 -0
  116. package/lib/import/validators/fields/nestable/Image/validators.js +31 -0
  117. package/lib/import/validators/fields/nestable/ImportRichText/ImportBlock.d.ts +6 -0
  118. package/lib/import/validators/fields/nestable/ImportRichText/ImportBlock.js +25 -0
  119. package/lib/import/validators/fields/nestable/ImportRichText/ImportRichText.d.ts +24 -0
  120. package/lib/import/validators/fields/nestable/ImportRichText/ImportRichText.js +26 -0
  121. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.d.ts +6 -0
  122. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.js +18 -0
  123. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.d.ts +10 -0
  124. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.js +11 -0
  125. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.d.ts +8 -0
  126. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.js +11 -0
  127. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.d.ts +70 -0
  128. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.js +43 -0
  129. package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.d.ts +65 -0
  130. package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.js +20 -0
  131. package/lib/import/validators/fields/nestable/ImportRichText/blocks/index.d.ts +4 -0
  132. package/lib/import/validators/fields/nestable/ImportRichText/blocks/index.js +7 -0
  133. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.d.ts +24 -0
  134. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.js +18 -0
  135. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.d.ts +5 -0
  136. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.js +10 -0
  137. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.d.ts +17 -0
  138. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.js +22 -0
  139. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/index.d.ts +2 -0
  140. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/index.js +5 -0
  141. package/lib/import/validators/fields/nestable/ImportRichText/index.d.ts +2 -0
  142. package/lib/import/validators/fields/nestable/ImportRichText/index.js +7 -0
  143. package/lib/import/validators/fields/nestable/Link.d.ts +33 -0
  144. package/lib/import/validators/fields/nestable/Link.js +16 -11
  145. package/lib/import/validators/fields/nestable/Nestable.d.ts +65 -62
  146. package/lib/import/validators/fields/nestable/Nestable.js +18 -6
  147. package/lib/import/validators/fields/nestable/index.d.ts +5 -1
  148. package/lib/import/validators/fields/nestable/index.js +7 -1
  149. package/lib/utils/DocumentId.d.ts +2 -0
  150. package/lib/utils/DocumentId.js +7 -0
  151. package/lib/utils/Objects.d.ts +1 -1
  152. package/lib/utils/Objects.js +1 -1
  153. package/lib/utils/io-ts.d.ts +2 -0
  154. package/lib/utils/io-ts.js +22 -0
  155. package/lib/validators/BasicTypes.d.ts +0 -1
  156. package/lib/validators/BasicTypes.js +7 -8
  157. package/lib/validators/DefaultOrElse.js +1 -1
  158. package/lib/validators/NonEmptyString.js +1 -1
  159. package/lib/validators/NumberRange.d.ts +32 -0
  160. package/lib/validators/NumberRange.js +40 -0
  161. package/lib/validators/function.d.ts +20 -0
  162. package/lib/validators/function.js +41 -1
  163. package/lib/validators/index.d.ts +1 -0
  164. package/lib/validators/index.js +3 -1
  165. package/package.json +4 -2
  166. package/src/common/Asset.ts +25 -0
  167. package/src/common/Embed.ts +22 -0
  168. package/src/common/UUID.ts +19 -0
  169. package/src/common/index.ts +2 -0
  170. package/src/content/fields/nestable/RichTextContent/Blocks.ts +1 -1
  171. package/src/content/fields/slices/Slice/RepeatableContent.ts +0 -1
  172. package/src/customtypes/CustomType.ts +13 -0
  173. package/src/import/converters/Document.ts +10 -7
  174. package/src/import/converters/fields/Slices/SharedSlice.ts +24 -0
  175. package/src/import/converters/fields/Slices/SharedSliceContent.ts +94 -0
  176. package/src/import/converters/fields/Slices/Slices.ts +20 -0
  177. package/src/import/converters/fields/Slices/index.ts +1 -0
  178. package/src/import/converters/fields/UID.ts +1 -5
  179. package/src/import/converters/fields/index.ts +1 -0
  180. package/src/import/converters/fields/nestable/Embed.ts +29 -7
  181. package/src/import/converters/fields/nestable/GeoPoint.ts +16 -0
  182. package/src/import/converters/fields/nestable/Image.ts +69 -44
  183. package/src/import/converters/fields/nestable/Link.ts +77 -0
  184. package/src/import/converters/fields/nestable/Nestable.ts +17 -6
  185. package/src/import/converters/fields/nestable/RichText/embedBlock.ts +14 -0
  186. package/src/import/converters/fields/nestable/RichText/imageBlock.ts +14 -0
  187. package/src/import/converters/fields/nestable/RichText/index.ts +23 -0
  188. package/src/import/converters/fields/nestable/RichText/textBlock.ts +35 -0
  189. package/src/import/converters/fields/nestable/index.ts +3 -0
  190. package/src/import/validators/Document.ts +4 -12
  191. package/src/import/validators/fields/ImportField.ts +12 -6
  192. package/src/import/validators/fields/ImportSlices/ImportSlices.ts +54 -0
  193. package/src/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.ts +116 -0
  194. package/src/import/validators/fields/ImportSlices/SharedSlice/errors.ts +6 -0
  195. package/src/import/validators/fields/ImportSlices/SharedSlice/fields/OptionalSharedSliceId.ts +20 -0
  196. package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.ts +64 -0
  197. package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.ts +100 -0
  198. package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/errors.ts +10 -0
  199. package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/index.ts +2 -0
  200. package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/types.ts +1 -0
  201. package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceId.ts +65 -0
  202. package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.ts +45 -0
  203. package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.ts +45 -0
  204. package/src/import/validators/fields/ImportSlices/SharedSlice/fields/index.ts +5 -0
  205. package/src/import/validators/fields/ImportSlices/SharedSlice/index.ts +3 -0
  206. package/src/import/validators/fields/ImportSlices/SharedSlice/utils.ts +21 -0
  207. package/src/import/validators/fields/ImportSlices/index.ts +1 -0
  208. package/src/import/validators/fields/ImportSlices/utils.ts +43 -0
  209. package/src/import/validators/fields/UID.ts +2 -2
  210. package/src/import/validators/fields/nestable/Embed.ts +6 -51
  211. package/src/import/validators/fields/nestable/GeoPoint.ts +21 -0
  212. package/src/import/validators/fields/nestable/Image/default.ts +25 -0
  213. package/src/import/validators/fields/nestable/Image/index.ts +73 -0
  214. package/src/import/validators/fields/nestable/Image/merge.ts +64 -0
  215. package/src/import/validators/fields/nestable/Image/model.ts +18 -0
  216. package/src/import/validators/fields/nestable/Image/validators.ts +45 -0
  217. package/src/import/validators/fields/nestable/ImportRichText/ImportBlock.ts +39 -0
  218. package/src/import/validators/fields/nestable/ImportRichText/ImportRichText.ts +41 -0
  219. package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.ts +44 -0
  220. package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.ts +13 -0
  221. package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.ts +13 -0
  222. package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.ts +56 -0
  223. package/src/import/validators/fields/nestable/ImportRichText/blocks/Span.ts +44 -0
  224. package/src/import/validators/fields/nestable/ImportRichText/blocks/index.ts +4 -0
  225. package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.ts +24 -0
  226. package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.ts +8 -0
  227. package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.ts +26 -0
  228. package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/index.ts +2 -0
  229. package/src/import/validators/fields/nestable/ImportRichText/index.ts +2 -0
  230. package/src/import/validators/fields/nestable/Link.ts +59 -0
  231. package/src/import/validators/fields/nestable/Nestable.ts +19 -4
  232. package/src/import/validators/fields/nestable/index.ts +5 -1
  233. package/src/utils/DocumentId.ts +8 -0
  234. package/src/utils/Objects.ts +2 -2
  235. package/src/utils/io-ts.ts +29 -0
  236. package/src/validators/BasicTypes.ts +13 -11
  237. package/src/validators/DefaultOrElse.ts +1 -1
  238. package/src/validators/NonEmptyString.ts +4 -5
  239. package/src/validators/NumberRange.ts +51 -0
  240. package/src/validators/function.ts +44 -0
  241. package/src/validators/index.ts +1 -0
  242. package/lib/import/validators/fields/nestable/Image.d.ts +0 -24
  243. package/lib/import/validators/fields/nestable/Image.js +0 -45
  244. package/src/import/validators/fields/nestable/Image.ts +0 -90
@@ -0,0 +1,45 @@
1
+ import * as t from "io-ts";
2
+ import type { ImageFieldWithThumbnails } from "./model";
3
+ export declare const ImageFieldCodec: (field?: ({
4
+ type: "Image";
5
+ } & {
6
+ fieldset?: string | null | undefined;
7
+ config?: {
8
+ label?: string | null | undefined;
9
+ placeholder?: string;
10
+ constraint?: {
11
+ width?: number | null;
12
+ height?: number | null;
13
+ };
14
+ thumbnails?: readonly ({
15
+ name: string;
16
+ } & {
17
+ width?: number | null;
18
+ height?: number | null;
19
+ })[];
20
+ };
21
+ }) | undefined) => t.Type<ImageFieldWithThumbnails, ImageFieldWithThumbnails, unknown>;
22
+ export declare const ImportImage: (field?: ({
23
+ type: "Image";
24
+ } & {
25
+ fieldset?: string | null | undefined;
26
+ config?: {
27
+ label?: string | null | undefined;
28
+ placeholder?: string;
29
+ constraint?: {
30
+ width?: number | null;
31
+ height?: number | null;
32
+ };
33
+ thumbnails?: readonly ({
34
+ name: string;
35
+ } & {
36
+ width?: number | null;
37
+ height?: number | null;
38
+ })[];
39
+ };
40
+ }) | undefined) => t.Type<{
41
+ type: "Image";
42
+ value: ImageFieldWithThumbnails | null;
43
+ }, ImageFieldWithThumbnails | undefined, unknown>;
44
+ export declare type ImportImage = t.TypeOf<ReturnType<typeof ImportImage>>;
45
+ export * from "./model";
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportImage = exports.ImageFieldCodec = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const Either_1 = require("fp-ts/Either");
6
+ const function_1 = require("fp-ts/function");
7
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
8
+ const validators_1 = require("../../../../../validators");
9
+ const function_2 = require("../../../../../validators/function");
10
+ const ImportContent_1 = require("../../ImportContent");
11
+ const default_1 = require("./default");
12
+ const merge_1 = require("./merge");
13
+ const validators_2 = require("./validators");
14
+ /* For code clarity, the output of this validator will be simplified
15
+ *
16
+ * Input -> type ImageAPIV2 = ImportImageView & ImportThumbnails
17
+ * Output -> type ImageWithThumbnails 👇
18
+ */
19
+ const ImageFieldCodec = (field) => new t.Type("ImageField", (u) => validators_2.ImportImageView.is(u) &&
20
+ "thumbnails" in u &&
21
+ validators_2.ImportThumbnails.is(u["thumbnails"]), (u, ctx) => {
22
+ return (0, function_1.pipe)(
23
+ // Validating the higher level image
24
+ validators_2.ImportImageView.validate(u, ctx), (0, Either_1.chain)((imageApiV2) => {
25
+ const { id, dimensions, edit, copyright, alt, ...thumbnails } = imageApiV2;
26
+ return (0, function_1.pipe)(
27
+ // Validating the thumbnails
28
+ validators_2.ImportThumbnails.validate(thumbnails, ctx), (0, Either_1.map)((thumbnails) => {
29
+ var _a;
30
+ return ({
31
+ ...(0, merge_1.mergeImageViewWithCtConstraints)(imageApiV2, imageApiV2, (_a = field === null || field === void 0 ? void 0 : field.config) === null || _a === void 0 ? void 0 : _a.constraint),
32
+ thumbnails: (0, merge_1.mergeThumbnailsWithCtConstraints)(thumbnails, imageApiV2, field),
33
+ });
34
+ }));
35
+ }));
36
+ }, t.identity);
37
+ exports.ImageFieldCodec = ImageFieldCodec;
38
+ const ImageCodec = (field) => (0, function_2.withCustomError)((0, validators_1.DefaultOrElse)((0, default_1.defaultImportImage)(field))((0, exports.ImageFieldCodec)(field)), () => "An image field must be an object");
39
+ const ImportImage = (field) => (0, ImportContent_1.ImportContent)("Image", ImageCodec(field));
40
+ exports.ImportImage = ImportImage;
41
+ (0, tslib_1.__exportStar)(require("./model"), exports);
@@ -0,0 +1,23 @@
1
+ import type ImageConstraint from "../../../../../customtypes/widgets/shared/ImageConstraint";
2
+ import type { ImageField } from "./model";
3
+ import type { ImportImageView, ImportThumbnails } from "./validators";
4
+ export declare const mergeImageViewWithCtConstraints: (image: ImportImageView | undefined, defaultImage: ImportImageView, constraints: ImageConstraint | undefined) => ImageField;
5
+ export declare const mergeThumbnailsWithCtConstraints: (thumbnails: ImportThumbnails, defaultImage: ImportImageView, field?: ({
6
+ type: "Image";
7
+ } & {
8
+ fieldset?: string | null | undefined;
9
+ config?: {
10
+ label?: string | null | undefined;
11
+ placeholder?: string;
12
+ constraint?: {
13
+ width?: number | null;
14
+ height?: number | null;
15
+ };
16
+ thumbnails?: readonly ({
17
+ name: string;
18
+ } & {
19
+ width?: number | null;
20
+ height?: number | null;
21
+ })[];
22
+ };
23
+ }) | undefined) => {};
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeThumbnailsWithCtConstraints = exports.mergeImageViewWithCtConstraints = void 0;
4
+ /* This function merges user input with custom type constraints.
5
+ * If a thumbnails' data are missing (`image`) then the default is used (`defaultImage`)
6
+ */
7
+ const mergeImageViewWithCtConstraints = (image, defaultImage, constraints) => {
8
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
9
+ const background = (_a = image === null || image === void 0 ? void 0 : image.edit) === null || _a === void 0 ? void 0 : _a.background;
10
+ const width = (_d = (_b = constraints === null || constraints === void 0 ? void 0 : constraints.width) !== null && _b !== void 0 ? _b : (_c = image === null || image === void 0 ? void 0 : image.dimensions) === null || _c === void 0 ? void 0 : _c.width) !== null && _d !== void 0 ? _d : (_e = defaultImage === null || defaultImage === void 0 ? void 0 : defaultImage.dimensions) === null || _e === void 0 ? void 0 : _e.width;
11
+ const height = (_h = (_f = constraints === null || constraints === void 0 ? void 0 : constraints.height) !== null && _f !== void 0 ? _f : (_g = image === null || image === void 0 ? void 0 : image.dimensions) === null || _g === void 0 ? void 0 : _g.height) !== null && _h !== void 0 ? _h : (_j = defaultImage === null || defaultImage === void 0 ? void 0 : defaultImage.dimensions) === null || _j === void 0 ? void 0 : _j.height;
12
+ const alt = image === null || image === void 0 ? void 0 : image.alt;
13
+ const copyright = image === null || image === void 0 ? void 0 : image.copyright;
14
+ return {
15
+ id: (_k = image === null || image === void 0 ? void 0 : image.id) !== null && _k !== void 0 ? _k : defaultImage === null || defaultImage === void 0 ? void 0 : defaultImage.id,
16
+ edit: {
17
+ x: (_m = (_l = image === null || image === void 0 ? void 0 : image.edit) === null || _l === void 0 ? void 0 : _l.x) !== null && _m !== void 0 ? _m : 0,
18
+ y: (_p = (_o = image === null || image === void 0 ? void 0 : image.edit) === null || _o === void 0 ? void 0 : _o.y) !== null && _p !== void 0 ? _p : 0,
19
+ zoom: (_r = (_q = image === null || image === void 0 ? void 0 : image.edit) === null || _q === void 0 ? void 0 : _q.zoom) !== null && _r !== void 0 ? _r : 1,
20
+ ...(background !== undefined ? { background } : {}),
21
+ },
22
+ dimensions: {
23
+ ...(width !== undefined ? { width } : {}),
24
+ ...(height !== undefined ? { height } : {}),
25
+ },
26
+ ...(alt !== undefined ? { alt } : {}),
27
+ ...(copyright !== undefined ? { copyright } : {}),
28
+ };
29
+ };
30
+ exports.mergeImageViewWithCtConstraints = mergeImageViewWithCtConstraints;
31
+ /* This function handles each thumbnail defined in the custom type.
32
+ *
33
+ * For each of them it merges the user input with custom type constraints.
34
+ *
35
+ * If a thumbnail is missing, the data from the default image is used.
36
+ */
37
+ const mergeThumbnailsWithCtConstraints = (thumbnails, defaultImage, field) => {
38
+ var _a, _b, _c;
39
+ return (_c = (_b = (_a = field === null || field === void 0 ? void 0 : field.config) === null || _a === void 0 ? void 0 : _a.thumbnails) === null || _b === void 0 ? void 0 : _b.reduce((acc, thumbnail) => ({
40
+ ...acc,
41
+ [thumbnail.name]: (0, exports.mergeImageViewWithCtConstraints)(thumbnails[thumbnail.name], defaultImage, thumbnail),
42
+ }), {})) !== null && _c !== void 0 ? _c : {};
43
+ };
44
+ exports.mergeThumbnailsWithCtConstraints = mergeThumbnailsWithCtConstraints;
@@ -0,0 +1,18 @@
1
+ export declare type ImageField = {
2
+ id: string;
3
+ edit: {
4
+ x: number;
5
+ y: number;
6
+ zoom: number;
7
+ background?: string;
8
+ };
9
+ dimensions: {
10
+ width?: number;
11
+ height?: number;
12
+ };
13
+ copyright?: string | null;
14
+ alt?: string | null;
15
+ };
16
+ export declare type ImageFieldWithThumbnails = ImageField & {
17
+ thumbnails: Record<string, ImageField>;
18
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,35 @@
1
+ import * as t from "io-ts";
2
+ export declare const ImportImageView: t.IntersectionC<[t.TypeC<{
3
+ id: t.StringC;
4
+ }>, t.PartialC<{
5
+ dimensions: t.PartialC<{
6
+ width: t.NumberC;
7
+ height: t.NumberC;
8
+ }>;
9
+ edit: t.PartialC<{
10
+ x: t.NumberC;
11
+ y: t.NumberC;
12
+ zoom: t.NumberC;
13
+ background: t.StringC;
14
+ }>;
15
+ copyright: t.UnionC<[t.StringC, t.NullC]>;
16
+ alt: t.UnionC<[t.StringC, t.NullC]>;
17
+ }>]>;
18
+ export declare type ImportImageView = t.TypeOf<typeof ImportImageView>;
19
+ export declare const ImportThumbnails: t.RecordC<t.StringC, t.IntersectionC<[t.TypeC<{
20
+ id: t.StringC;
21
+ }>, t.PartialC<{
22
+ dimensions: t.PartialC<{
23
+ width: t.NumberC;
24
+ height: t.NumberC;
25
+ }>;
26
+ edit: t.PartialC<{
27
+ x: t.NumberC;
28
+ y: t.NumberC;
29
+ zoom: t.NumberC;
30
+ background: t.StringC;
31
+ }>;
32
+ copyright: t.UnionC<[t.StringC, t.NullC]>;
33
+ alt: t.UnionC<[t.StringC, t.NullC]>;
34
+ }>]>>;
35
+ export declare type ImportThumbnails = t.TypeOf<typeof ImportThumbnails>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportThumbnails = exports.ImportImageView = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const BasicTypes_1 = require("../../../../../validators/BasicTypes");
7
+ const function_1 = require("../../../../../validators/function");
8
+ exports.ImportImageView = (0, function_1.withCustomError)(t.intersection([
9
+ t.type({
10
+ // Image Id
11
+ id: BasicTypes_1.String,
12
+ }),
13
+ t.partial({
14
+ // Dimensions here will be used if they are not defined in the custom type
15
+ dimensions: (0, function_1.withCustomError)(t.partial({
16
+ width: BasicTypes_1.Number,
17
+ height: BasicTypes_1.Number,
18
+ }), () => "The value must be an object"),
19
+ // Crop information
20
+ edit: (0, function_1.withCustomError)(t.partial({
21
+ x: BasicTypes_1.Number,
22
+ y: BasicTypes_1.Number,
23
+ zoom: BasicTypes_1.Number,
24
+ background: BasicTypes_1.String,
25
+ }), () => "The value must be an object"),
26
+ // Copyrights and alt are set in the Asset by default but they can be overrided
27
+ copyright: BasicTypes_1.StringOrNull,
28
+ alt: BasicTypes_1.StringOrNull,
29
+ }),
30
+ ]), () => "The value must be an object");
31
+ exports.ImportThumbnails = t.record(t.string, exports.ImportImageView);
@@ -0,0 +1,6 @@
1
+ import * as t from "io-ts";
2
+ import { ImportBlockType, ImportEmbedBlock, ImportImageBlock, ImportTextBlock } from "./blocks";
3
+ export declare type ImportBlock = ImportTextBlock | ImportImageBlock | ImportEmbedBlock;
4
+ export declare const ImportBlock: (allowedBlockTypes: string[]) => t.Type<ImportBlock, {
5
+ type: ImportBlockType;
6
+ }, unknown>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportBlock = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const function_1 = require("../../../../../validators/function");
7
+ const blocks_1 = require("./blocks");
8
+ const ImportBlock = (allowedBlockTypes) => (0, function_1.withCustomError)(t
9
+ .type({
10
+ type: (0, blocks_1.ImportBlockType)(allowedBlockTypes),
11
+ })
12
+ .pipe(new t.Type("ImportBlock", (u) => t
13
+ .union([blocks_1.ImportTextBlock, blocks_1.ImportImageBlock, blocks_1.ImportEmbedBlock])
14
+ .is(u), (u, c) => {
15
+ if (u.type === "image") {
16
+ return blocks_1.ImportImageBlock.validate(u, c);
17
+ }
18
+ else if (u.type === "embed") {
19
+ return blocks_1.ImportEmbedBlock.validate(u, c);
20
+ }
21
+ else {
22
+ return blocks_1.ImportTextBlock.validate(u, c);
23
+ }
24
+ }, t.identity)), () => "Rich text block must be an object");
25
+ exports.ImportBlock = ImportBlock;
@@ -0,0 +1,24 @@
1
+ import * as t from "io-ts";
2
+ import { ImportBlock } from "./ImportBlock";
3
+ export declare const ImportRichText: (customType?: ({
4
+ type: "StructuredText";
5
+ } & {
6
+ fieldset?: string | null | undefined;
7
+ config?: {
8
+ label?: string | null | undefined;
9
+ placeholder?: string;
10
+ useAsTitle?: boolean;
11
+ single?: string;
12
+ multi?: string;
13
+ imageConstraint?: {
14
+ width?: number | null;
15
+ height?: number | null;
16
+ };
17
+ labels?: readonly string[];
18
+ allowTargetBlank?: boolean;
19
+ };
20
+ }) | undefined) => t.Type<{
21
+ type: "StructuredText";
22
+ value: ImportBlock[] | null;
23
+ }, unknown[] | undefined, unknown>;
24
+ export declare type ImportRichText = t.TypeOf<ReturnType<typeof ImportRichText>>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportRichText = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const validators_1 = require("../../../../../validators");
7
+ const function_1 = require("../../../../../validators/function");
8
+ const ImportContent_1 = require("../../ImportContent");
9
+ const ImportBlock_1 = require("./ImportBlock");
10
+ const ImportRichText = (customType) => (0, ImportContent_1.ImportContent)("StructuredText", (0, validators_1.EmptyArrayOrElse)((0, function_1.withCustomError)(t.array(t.unknown).pipe(new t.Type("RichTextField", (u) => t.array((0, ImportBlock_1.ImportBlock)([])).is(u), (u, c) => {
11
+ var _a, _b, _c, _d;
12
+ const single = (_b = (_a = customType === null || customType === void 0 ? void 0 : customType.config) === null || _a === void 0 ? void 0 : _a.single) === null || _b === void 0 ? void 0 : _b.split(",");
13
+ const multi = (_d = (_c = customType === null || customType === void 0 ? void 0 : customType.config) === null || _c === void 0 ? void 0 : _c.multi) === null || _d === void 0 ? void 0 : _d.split(",");
14
+ if (multi) {
15
+ return t.array((0, ImportBlock_1.ImportBlock)(multi)).validate(u, c);
16
+ }
17
+ else if (single) {
18
+ return u.length > 1
19
+ ? t.failure(u, c, "This field only allows one block")
20
+ : t.array((0, ImportBlock_1.ImportBlock)(single)).validate(u, c);
21
+ }
22
+ else {
23
+ throw new Error("Rich text config must have either a 'single' or 'multi' field defined");
24
+ }
25
+ }, t.identity)), () => "Rich text field must be an array")));
26
+ exports.ImportRichText = ImportRichText;
@@ -0,0 +1,6 @@
1
+ import * as t from "io-ts";
2
+ import { ImportEmbedBlockType } from "./ImportEmbedBlock";
3
+ import { ImportImageBlockType } from "./ImportImageBlock";
4
+ import { ImportTextBlockType } from "./ImportTextBlock";
5
+ export declare type ImportBlockType = ImportTextBlockType | ImportImageBlockType | ImportEmbedBlockType;
6
+ export declare const ImportBlockType: (allowedBlockTypes: string[]) => t.Type<ImportBlockType, ImportBlockType, unknown>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportBlockType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const E = (0, tslib_1.__importStar)(require("fp-ts/Either"));
6
+ const function_1 = require("fp-ts/function");
7
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
8
+ const function_2 = require("../../../../../../validators/function");
9
+ const ImportEmbedBlock_1 = require("./ImportEmbedBlock");
10
+ const ImportImageBlock_1 = require("./ImportImageBlock");
11
+ const ImportTextBlock_1 = require("./ImportTextBlock");
12
+ const ImportBlockTypeValidator = (0, function_2.withCustomError)(t.union([ImportTextBlock_1.ImportTextBlockType, ImportImageBlock_1.ImportImageBlockType, ImportEmbedBlock_1.ImportEmbedBlockType]), () => `Invalid block type. Supported block types are: ${Object.keys(ImportTextBlock_1.ImportTextBlockType.keys).join(", ")}, ${ImportImageBlock_1.ImportImageBlockType.value}, ${ImportEmbedBlock_1.ImportEmbedBlockType.value}`);
13
+ const ImportBlockType = (allowedBlockTypes) => new t.Type("ImportBlockType", (u) => ImportBlockTypeValidator.is(u), (u, c) => {
14
+ return (0, function_1.pipe)(ImportBlockTypeValidator.validate(u, c), E.chain((validBlockType) => allowedBlockTypes.includes(validBlockType)
15
+ ? t.success(validBlockType)
16
+ : t.failure(u, c, `The block type '${validBlockType}' is not allowed in your document type. Enable the type for this rich text field to create the document.`)));
17
+ }, t.identity);
18
+ exports.ImportBlockType = ImportBlockType;
@@ -0,0 +1,10 @@
1
+ import * as t from "io-ts";
2
+ export declare const ImportEmbedBlockType: t.LiteralC<"embed">;
3
+ export declare type ImportEmbedBlockType = t.TypeOf<typeof ImportEmbedBlockType>;
4
+ export declare const ImportEmbedBlock: t.ExactC<t.TypeC<{
5
+ type: t.LiteralC<"embed">;
6
+ oembed: t.ExactC<t.TypeC<{
7
+ embed_url: t.Type<string, string, unknown>;
8
+ }>>;
9
+ }>>;
10
+ export declare type ImportEmbedBlock = t.TypeOf<typeof ImportEmbedBlock>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportEmbedBlock = exports.ImportEmbedBlockType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const Embed_1 = require("../../Embed");
7
+ exports.ImportEmbedBlockType = t.literal("embed");
8
+ exports.ImportEmbedBlock = t.strict({
9
+ type: exports.ImportEmbedBlockType,
10
+ oembed: Embed_1.ImportEmbedValue,
11
+ });
@@ -0,0 +1,8 @@
1
+ import * as t from "io-ts";
2
+ export declare const ImportImageBlockType: t.LiteralC<"image">;
3
+ export declare type ImportImageBlockType = t.TypeOf<typeof ImportImageBlockType>;
4
+ export declare const ImportImageBlock: t.ExactC<t.TypeC<{
5
+ type: t.LiteralC<"image">;
6
+ id: t.StringC;
7
+ }>>;
8
+ export declare type ImportImageBlock = t.TypeOf<typeof ImportImageBlock>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportImageBlock = exports.ImportImageBlockType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const validators_1 = require("../../../../../../validators");
7
+ exports.ImportImageBlockType = t.literal("image");
8
+ exports.ImportImageBlock = t.strict({
9
+ type: exports.ImportImageBlockType,
10
+ id: validators_1.String,
11
+ });
@@ -0,0 +1,70 @@
1
+ import * as t from "io-ts";
2
+ export declare const ImportTextBlockTypes: {
3
+ readonly Paragraph: "paragraph";
4
+ readonly OListItem: "o-list-item";
5
+ readonly ListItem: "list-item";
6
+ readonly Heading1: "heading1";
7
+ readonly Heading2: "heading2";
8
+ readonly Heading3: "heading3";
9
+ readonly Heading4: "heading4";
10
+ readonly Heading5: "heading5";
11
+ readonly Heading6: "heading6";
12
+ readonly Preformatted: "preformatted";
13
+ };
14
+ export declare const ImportTextBlockType: t.KeyofC<{
15
+ paragraph: null;
16
+ "o-list-item": null;
17
+ "list-item": null;
18
+ heading1: null;
19
+ heading2: null;
20
+ heading3: null;
21
+ heading4: null;
22
+ heading5: null;
23
+ heading6: null;
24
+ preformatted: null;
25
+ }>;
26
+ export declare type ImportTextBlockType = t.TypeOf<typeof ImportTextBlockType>;
27
+ export declare const ImportTextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
28
+ type: t.KeyofC<{
29
+ paragraph: null;
30
+ "o-list-item": null;
31
+ "list-item": null;
32
+ heading1: null;
33
+ heading2: null;
34
+ heading3: null;
35
+ heading4: null;
36
+ heading5: null;
37
+ heading6: null;
38
+ preformatted: null;
39
+ }>;
40
+ text: t.StringC;
41
+ }>, t.PartialC<{
42
+ spans: t.ArrayC<t.Type<({
43
+ type: "hyperlink";
44
+ } & {
45
+ start: number;
46
+ end: number;
47
+ } & {
48
+ data: ({
49
+ link_type: "Web";
50
+ url: string;
51
+ } & {
52
+ target?: string;
53
+ }) | {
54
+ link_type: "Document";
55
+ id: string;
56
+ } | {
57
+ link_type: "Media";
58
+ id: string;
59
+ };
60
+ }) | ({
61
+ type: "label" | "strong" | "em";
62
+ } & {
63
+ start: number;
64
+ end: number;
65
+ }), {
66
+ type: "label" | "strong" | "em" | "hyperlink";
67
+ }, unknown>>;
68
+ direction: t.UnionC<[t.LiteralC<"ltr">, t.LiteralC<"rtl">]>;
69
+ }>]>>;
70
+ export declare type ImportTextBlock = t.TypeOf<typeof ImportTextBlock>;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportTextBlock = exports.ImportTextBlockType = exports.ImportTextBlockTypes = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const validators_1 = require("../../../../../../validators");
7
+ const function_1 = require("../../../../../../validators/function");
8
+ const Span_1 = require("./Span");
9
+ exports.ImportTextBlockTypes = {
10
+ Paragraph: "paragraph",
11
+ OListItem: "o-list-item",
12
+ ListItem: "list-item",
13
+ Heading1: "heading1",
14
+ Heading2: "heading2",
15
+ Heading3: "heading3",
16
+ Heading4: "heading4",
17
+ Heading5: "heading5",
18
+ Heading6: "heading6",
19
+ Preformatted: "preformatted",
20
+ };
21
+ exports.ImportTextBlockType = t.keyof({
22
+ [exports.ImportTextBlockTypes.Paragraph]: null,
23
+ [exports.ImportTextBlockTypes.OListItem]: null,
24
+ [exports.ImportTextBlockTypes.ListItem]: null,
25
+ [exports.ImportTextBlockTypes.Heading1]: null,
26
+ [exports.ImportTextBlockTypes.Heading2]: null,
27
+ [exports.ImportTextBlockTypes.Heading3]: null,
28
+ [exports.ImportTextBlockTypes.Heading4]: null,
29
+ [exports.ImportTextBlockTypes.Heading5]: null,
30
+ [exports.ImportTextBlockTypes.Heading6]: null,
31
+ [exports.ImportTextBlockTypes.Preformatted]: null,
32
+ });
33
+ const TextDirection = (0, function_1.withCustomError)(t.union([t.literal("ltr"), t.literal("rtl")]), () => "The 'direction' property must be one of the following: ltr, rtl");
34
+ exports.ImportTextBlock = t.exact(t.intersection([
35
+ t.type({
36
+ type: exports.ImportTextBlockType,
37
+ text: validators_1.String,
38
+ }),
39
+ t.partial({
40
+ spans: (0, function_1.withCustomError)(t.array(Span_1.Span), () => "The 'spans' field must be an array"),
41
+ direction: TextDirection,
42
+ }),
43
+ ]));
@@ -0,0 +1,65 @@
1
+ import * as t from "io-ts";
2
+ declare const SpanType: t.UnionC<[t.LiteralC<"hyperlink">, t.KeyofC<{
3
+ strong: null;
4
+ em: null;
5
+ label: null;
6
+ }>]>;
7
+ export declare type SpanType = t.TypeOf<typeof SpanType>;
8
+ declare const SpanShape: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
9
+ type: t.LiteralC<"hyperlink">;
10
+ }>, t.TypeC<{
11
+ start: t.NumberC;
12
+ end: t.NumberC;
13
+ }>, t.TypeC<{
14
+ data: t.Type<({
15
+ link_type: "Web";
16
+ url: string;
17
+ } & {
18
+ target?: string;
19
+ }) | {
20
+ link_type: "Document";
21
+ id: string;
22
+ } | {
23
+ link_type: "Media";
24
+ id: string;
25
+ }, {
26
+ link_type: "Document" | "Web" | "Media";
27
+ }, unknown>;
28
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
29
+ type: t.KeyofC<{
30
+ strong: null;
31
+ em: null;
32
+ label: null;
33
+ }>;
34
+ }>, t.TypeC<{
35
+ start: t.NumberC;
36
+ end: t.NumberC;
37
+ }>]>>]>;
38
+ export declare type Span = t.TypeOf<typeof SpanShape>;
39
+ export declare const Span: t.Type<({
40
+ type: "hyperlink";
41
+ } & {
42
+ start: number;
43
+ end: number;
44
+ } & {
45
+ data: ({
46
+ link_type: "Web";
47
+ url: string;
48
+ } & {
49
+ target?: string;
50
+ }) | {
51
+ link_type: "Document";
52
+ id: string;
53
+ } | {
54
+ link_type: "Media";
55
+ id: string;
56
+ };
57
+ }) | ({
58
+ type: "label" | "strong" | "em";
59
+ } & {
60
+ start: number;
61
+ end: number;
62
+ }), {
63
+ type: "label" | "strong" | "em" | "hyperlink";
64
+ }, unknown>;
65
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Span = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const function_1 = require("../../../../../../validators/function");
7
+ const spans_1 = require("./spans");
8
+ const SpanType = (0, function_1.withCustomError)(t.union([spans_1.HyperlinkSpanType, spans_1.TextSpanType]), () => `Span 'type' field must be specified and have one of the following values: ${Object.keys(spans_1.TextSpanType.keys).join(", ")} or ${spans_1.HyperlinkSpanType.value}`);
9
+ const SpanTypeValidator = (0, function_1.withCustomError)(t.type({
10
+ type: SpanType,
11
+ }), () => "Span must be an object");
12
+ const SpanShape = t.union([spans_1.HyperlinkSpan, spans_1.TextSpan]);
13
+ exports.Span = SpanTypeValidator.pipe(new t.Type("Span", (u) => SpanShape.is(u), (u, c) => {
14
+ if (spans_1.HyperlinkSpanType.is(u.type)) {
15
+ return spans_1.HyperlinkSpan.validate(u, c);
16
+ }
17
+ else {
18
+ return spans_1.TextSpan.validate(u, c);
19
+ }
20
+ }, t.identity));
@@ -0,0 +1,4 @@
1
+ export * from "./ImportBlockType";
2
+ export * from "./ImportEmbedBlock";
3
+ export * from "./ImportImageBlock";
4
+ export * from "./ImportTextBlock";
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./ImportBlockType"), exports);
5
+ (0, tslib_1.__exportStar)(require("./ImportEmbedBlock"), exports);
6
+ (0, tslib_1.__exportStar)(require("./ImportImageBlock"), exports);
7
+ (0, tslib_1.__exportStar)(require("./ImportTextBlock"), exports);
@@ -0,0 +1,24 @@
1
+ import * as t from "io-ts";
2
+ export declare const HyperlinkSpanType: t.LiteralC<"hyperlink">;
3
+ export declare type HyperlinkSpanType = t.TypeOf<typeof HyperlinkSpanType>;
4
+ export declare const HyperlinkSpan: t.ExactC<t.IntersectionC<[t.TypeC<{
5
+ type: t.LiteralC<"hyperlink">;
6
+ }>, t.TypeC<{
7
+ start: t.NumberC;
8
+ end: t.NumberC;
9
+ }>, t.TypeC<{
10
+ data: t.Type<({
11
+ link_type: "Web";
12
+ url: string;
13
+ } & {
14
+ target?: string;
15
+ }) | {
16
+ link_type: "Document";
17
+ id: string;
18
+ } | {
19
+ link_type: "Media";
20
+ id: string;
21
+ }, {
22
+ link_type: "Document" | "Web" | "Media";
23
+ }, unknown>;
24
+ }>]>>;