@prismicio/types-internal 2.2.1 → 2.3.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 (193) hide show
  1. package/lib/content/Document.d.ts +10 -4
  2. package/lib/content/Document.js +45 -11
  3. package/lib/content/fields/GroupContent.d.ts +1 -0
  4. package/lib/content/fields/GroupContent.js +13 -1
  5. package/lib/content/fields/nestable/BooleanContent.d.ts +2 -0
  6. package/lib/content/fields/nestable/BooleanContent.js +11 -1
  7. package/lib/content/fields/nestable/FieldContent/SelectContent.d.ts +2 -0
  8. package/lib/content/fields/nestable/FieldContent/SelectContent.js +12 -1
  9. package/lib/content/fields/nestable/NestableContent.d.ts +2 -0
  10. package/lib/content/fields/nestable/NestableContent.js +12 -1
  11. package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +1 -0
  12. package/lib/content/fields/slices/Slice/CompositeSliceContent.js +13 -1
  13. package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +2 -1
  14. package/lib/content/fields/slices/Slice/SharedSliceContent.js +16 -1
  15. package/lib/content/fields/slices/SliceItem.d.ts +3 -0
  16. package/lib/content/fields/slices/SliceItem.js +24 -1
  17. package/lib/content/fields/slices/SlicesContent.d.ts +1 -0
  18. package/lib/content/fields/slices/SlicesContent.js +23 -1
  19. package/lib/content/fields/withDefaultValues.d.ts +6 -0
  20. package/lib/content/fields/withDefaultValues.js +38 -0
  21. package/lib/import/converters/Document.d.ts +4 -0
  22. package/lib/import/converters/Document.js +21 -0
  23. package/lib/import/converters/fields/Group.d.ts +4 -0
  24. package/lib/import/converters/fields/Group.js +14 -0
  25. package/lib/import/converters/fields/RepeatableZone.d.ts +317 -0
  26. package/lib/import/converters/fields/RepeatableZone.js +15 -0
  27. package/lib/import/converters/fields/RepeatableZoneItem.d.ts +11 -0
  28. package/lib/import/converters/fields/RepeatableZoneItem.js +19 -0
  29. package/lib/import/converters/fields/Slices/SharedSlice.d.ts +4 -0
  30. package/lib/import/converters/fields/Slices/SharedSlice.js +19 -0
  31. package/lib/import/converters/fields/Slices/SharedSliceContent.d.ts +10 -0
  32. package/lib/import/converters/fields/Slices/SharedSliceContent.js +23 -0
  33. package/lib/import/converters/fields/Slices/Slices.d.ts +4 -0
  34. package/lib/import/converters/fields/Slices/Slices.js +16 -0
  35. package/lib/import/converters/fields/Slices/index.d.ts +1 -0
  36. package/lib/import/converters/fields/Slices/index.js +4 -0
  37. package/lib/import/converters/fields/UID.d.ts +3 -0
  38. package/lib/import/converters/fields/UID.js +10 -0
  39. package/lib/import/converters/fields/index.d.ts +4 -0
  40. package/lib/import/converters/fields/index.js +7 -0
  41. package/lib/import/converters/fields/nestable/Boolean.d.ts +3 -0
  42. package/lib/import/converters/fields/nestable/Boolean.js +12 -0
  43. package/lib/import/converters/fields/nestable/Color.d.ts +3 -0
  44. package/lib/import/converters/fields/nestable/Color.js +13 -0
  45. package/lib/import/converters/fields/nestable/Date.d.ts +3 -0
  46. package/lib/import/converters/fields/nestable/Date.js +15 -0
  47. package/lib/import/converters/fields/nestable/Embed.d.ts +4 -0
  48. package/lib/import/converters/fields/nestable/Embed.js +32 -0
  49. package/lib/import/converters/fields/nestable/GeoPoint.d.ts +3 -0
  50. package/lib/import/converters/fields/nestable/GeoPoint.js +15 -0
  51. package/lib/import/converters/fields/nestable/Image.d.ts +28 -0
  52. package/lib/import/converters/fields/nestable/Image.js +67 -0
  53. package/lib/import/converters/fields/nestable/Link.d.ts +4 -0
  54. package/lib/import/converters/fields/nestable/Link.js +70 -0
  55. package/lib/import/converters/fields/nestable/Nestable.d.ts +5 -0
  56. package/lib/import/converters/fields/nestable/Nestable.js +35 -0
  57. package/lib/import/converters/fields/nestable/Number.d.ts +3 -0
  58. package/lib/import/converters/fields/nestable/Number.js +13 -0
  59. package/lib/import/converters/fields/nestable/RichText/embedBlock.d.ts +4 -0
  60. package/lib/import/converters/fields/nestable/RichText/embedBlock.js +14 -0
  61. package/lib/import/converters/fields/nestable/RichText/imageBlock.d.ts +4 -0
  62. package/lib/import/converters/fields/nestable/RichText/imageBlock.js +12 -0
  63. package/lib/import/converters/fields/nestable/RichText/index.d.ts +4 -0
  64. package/lib/import/converters/fields/nestable/RichText/index.js +22 -0
  65. package/lib/import/converters/fields/nestable/RichText/textBlock.d.ts +4 -0
  66. package/lib/import/converters/fields/nestable/RichText/textBlock.js +54 -0
  67. package/lib/import/converters/fields/nestable/Select.d.ts +3 -0
  68. package/lib/import/converters/fields/nestable/Select.js +13 -0
  69. package/lib/import/converters/fields/nestable/Text.d.ts +3 -0
  70. package/lib/import/converters/fields/nestable/Text.js +13 -0
  71. package/lib/import/converters/fields/nestable/Timestamp.d.ts +3 -0
  72. package/lib/import/converters/fields/nestable/Timestamp.js +13 -0
  73. package/lib/import/converters/fields/nestable/index.d.ts +13 -0
  74. package/lib/import/converters/fields/nestable/index.js +16 -0
  75. package/lib/import/converters/index.d.ts +2 -0
  76. package/lib/import/converters/index.js +5 -0
  77. package/lib/import/index.d.ts +2 -0
  78. package/lib/import/index.js +5 -0
  79. package/lib/import/validators/Document.d.ts +6 -0
  80. package/lib/import/validators/Document.js +64 -0
  81. package/lib/import/validators/fields/ImportContent.d.ts +5 -0
  82. package/lib/import/validators/fields/ImportContent.js +21 -0
  83. package/lib/import/validators/fields/ImportField.d.ts +141 -0
  84. package/lib/import/validators/fields/ImportField.js +33 -0
  85. package/lib/import/validators/fields/ImportGroup.d.ts +345 -0
  86. package/lib/import/validators/fields/ImportGroup.js +27 -0
  87. package/lib/import/validators/fields/ImportSlices/ImportSlices.d.ts +8 -0
  88. package/lib/import/validators/fields/ImportSlices/ImportSlices.js +30 -0
  89. package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.d.ts +16 -0
  90. package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.js +61 -0
  91. package/lib/import/validators/fields/ImportSlices/SharedSlice/errors.d.ts +4 -0
  92. package/lib/import/validators/fields/ImportSlices/SharedSlice/errors.js +7 -0
  93. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/OptionalSharedSliceId.d.ts +2 -0
  94. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/OptionalSharedSliceId.js +15 -0
  95. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceId.d.ts +9 -0
  96. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceId.js +39 -0
  97. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.d.ts +11 -0
  98. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.js +24 -0
  99. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.d.ts +11 -0
  100. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.js +24 -0
  101. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/index.d.ts +4 -0
  102. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/index.js +7 -0
  103. package/lib/import/validators/fields/ImportSlices/SharedSlice/index.d.ts +3 -0
  104. package/lib/import/validators/fields/ImportSlices/SharedSlice/index.js +6 -0
  105. package/lib/import/validators/fields/ImportSlices/SharedSlice/utils.d.ts +342 -0
  106. package/lib/import/validators/fields/ImportSlices/SharedSlice/utils.js +11 -0
  107. package/lib/import/validators/fields/ImportSlices/index.d.ts +1 -0
  108. package/lib/import/validators/fields/ImportSlices/index.js +4 -0
  109. package/lib/import/validators/fields/ImportSlices/utils.d.ts +4 -0
  110. package/lib/import/validators/fields/ImportSlices/utils.js +35 -0
  111. package/lib/import/validators/fields/RepeatableZone.d.ts +11 -0
  112. package/lib/import/validators/fields/RepeatableZone.js +14 -0
  113. package/lib/import/validators/fields/RepeatableZoneItem.d.ts +11 -0
  114. package/lib/import/validators/fields/RepeatableZoneItem.js +39 -0
  115. package/lib/import/validators/fields/UID.d.ts +6 -0
  116. package/lib/import/validators/fields/UID.js +15 -0
  117. package/lib/import/validators/fields/index.d.ts +4 -0
  118. package/lib/import/validators/fields/index.js +7 -0
  119. package/lib/import/validators/fields/nestable/Boolean.d.ts +6 -0
  120. package/lib/import/validators/fields/nestable/Boolean.js +6 -0
  121. package/lib/import/validators/fields/nestable/Color.d.ts +6 -0
  122. package/lib/import/validators/fields/nestable/Color.js +15 -0
  123. package/lib/import/validators/fields/nestable/Date.d.ts +6 -0
  124. package/lib/import/validators/fields/nestable/Date.js +19 -0
  125. package/lib/import/validators/fields/nestable/Embed.d.ts +13 -0
  126. package/lib/import/validators/fields/nestable/Embed.js +31 -0
  127. package/lib/import/validators/fields/nestable/GeoPoint.d.ts +13 -0
  128. package/lib/import/validators/fields/nestable/GeoPoint.js +13 -0
  129. package/lib/import/validators/fields/nestable/Image/default.d.ts +22 -0
  130. package/lib/import/validators/fields/nestable/Image/default.js +19 -0
  131. package/lib/import/validators/fields/nestable/Image/index.d.ts +26 -0
  132. package/lib/import/validators/fields/nestable/Image/index.js +32 -0
  133. package/lib/import/validators/fields/nestable/Image/merge.d.ts +23 -0
  134. package/lib/import/validators/fields/nestable/Image/merge.js +44 -0
  135. package/lib/import/validators/fields/nestable/Image/model.d.ts +18 -0
  136. package/lib/import/validators/fields/nestable/Image/model.js +2 -0
  137. package/lib/import/validators/fields/nestable/Image/validators.d.ts +132 -0
  138. package/lib/import/validators/fields/nestable/Image/validators.js +43 -0
  139. package/lib/import/validators/fields/nestable/ImportRichText/ImportBlock.d.ts +6 -0
  140. package/lib/import/validators/fields/nestable/ImportRichText/ImportBlock.js +25 -0
  141. package/lib/import/validators/fields/nestable/ImportRichText/ImportRichText.d.ts +24 -0
  142. package/lib/import/validators/fields/nestable/ImportRichText/ImportRichText.js +32 -0
  143. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.d.ts +6 -0
  144. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.js +18 -0
  145. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.d.ts +10 -0
  146. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.js +11 -0
  147. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.d.ts +22 -0
  148. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.js +13 -0
  149. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.d.ts +78 -0
  150. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.js +43 -0
  151. package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.d.ts +79 -0
  152. package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.js +27 -0
  153. package/lib/import/validators/fields/nestable/ImportRichText/blocks/index.d.ts +4 -0
  154. package/lib/import/validators/fields/nestable/ImportRichText/blocks/index.js +7 -0
  155. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.d.ts +24 -0
  156. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.js +18 -0
  157. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/LabelSpan.d.ts +12 -0
  158. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/LabelSpan.js +16 -0
  159. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.d.ts +5 -0
  160. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.js +10 -0
  161. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.d.ts +15 -0
  162. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.js +20 -0
  163. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/index.d.ts +2 -0
  164. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/index.js +5 -0
  165. package/lib/import/validators/fields/nestable/ImportRichText/index.d.ts +2 -0
  166. package/lib/import/validators/fields/nestable/ImportRichText/index.js +7 -0
  167. package/lib/import/validators/fields/nestable/Link.d.ts +53 -0
  168. package/lib/import/validators/fields/nestable/Link.js +35 -0
  169. package/lib/import/validators/fields/nestable/Nestable.d.ts +192 -0
  170. package/lib/import/validators/fields/nestable/Nestable.js +71 -0
  171. package/lib/import/validators/fields/nestable/Number.d.ts +17 -0
  172. package/lib/import/validators/fields/nestable/Number.js +17 -0
  173. package/lib/import/validators/fields/nestable/Select.d.ts +16 -0
  174. package/lib/import/validators/fields/nestable/Select.js +19 -0
  175. package/lib/import/validators/fields/nestable/Text.d.ts +6 -0
  176. package/lib/import/validators/fields/nestable/Text.js +6 -0
  177. package/lib/import/validators/fields/nestable/Timestamp.d.ts +7 -0
  178. package/lib/import/validators/fields/nestable/Timestamp.js +19 -0
  179. package/lib/import/validators/fields/nestable/index.d.ts +14 -0
  180. package/lib/import/validators/fields/nestable/index.js +19 -0
  181. package/lib/import/validators/index.d.ts +2 -0
  182. package/lib/import/validators/index.js +5 -0
  183. package/package.json +1 -1
  184. package/src/content/Document.ts +68 -14
  185. package/src/content/fields/GroupContent.ts +16 -0
  186. package/src/content/fields/nestable/BooleanContent.ts +11 -0
  187. package/src/content/fields/nestable/FieldContent/SelectContent.ts +12 -1
  188. package/src/content/fields/nestable/NestableContent.ts +16 -0
  189. package/src/content/fields/slices/Slice/CompositeSliceContent.ts +25 -0
  190. package/src/content/fields/slices/Slice/SharedSliceContent.ts +32 -1
  191. package/src/content/fields/slices/SliceItem.ts +43 -1
  192. package/src/content/fields/slices/SlicesContent.ts +30 -0
  193. package/src/content/fields/withDefaultValues.ts +48 -0
@@ -0,0 +1,141 @@
1
+ import type { StaticWidget } from "../../../customtypes";
2
+ import { ImportGroup } from "./ImportGroup";
3
+ import { ImportSlices } from "./ImportSlices";
4
+ import { ImportNestable } from "./nestable";
5
+ export declare type ImportField = ImportSlices | ImportNestable | ImportGroup;
6
+ export declare const ImportField: {
7
+ is(u: unknown): u is ImportField;
8
+ decode: (field: StaticWidget) => (content: unknown) => {
9
+ codec: import("io-ts").Type<{
10
+ type: "Boolean";
11
+ value: boolean | null;
12
+ }, boolean | undefined, unknown> | import("io-ts").Type<{
13
+ type: "Color";
14
+ value: `#${string}` | null;
15
+ }, string | undefined, unknown> | import("io-ts").Type<{
16
+ type: "Date";
17
+ value: Date | null;
18
+ }, Date | undefined, unknown> | import("io-ts").Type<{
19
+ type: "Embed";
20
+ value: {
21
+ embed_url: string;
22
+ } | null;
23
+ }, {
24
+ embed_url: string;
25
+ } | undefined, unknown> | import("io-ts").Type<{
26
+ type: "GeoPoint";
27
+ value: {
28
+ latitude: number;
29
+ longitude: number;
30
+ } | null;
31
+ }, {
32
+ latitude: number;
33
+ longitude: number;
34
+ } | undefined, unknown> | import("io-ts").Type<{
35
+ type: "Image";
36
+ value: import("./nestable").ImageFieldWithThumbnails | null;
37
+ }, import("./nestable").ImageFieldWithThumbnails | undefined, unknown> | import("io-ts").Type<{
38
+ type: "Link";
39
+ value: ({
40
+ link_type: "Web";
41
+ url: string;
42
+ } & {
43
+ target?: string;
44
+ }) | {
45
+ link_type: "Document";
46
+ id: string;
47
+ } | {
48
+ link_type: "Media";
49
+ id: string;
50
+ } | null;
51
+ }, {
52
+ link_type: "Document" | "Web" | "Media";
53
+ } | undefined, unknown> | import("io-ts").Type<{
54
+ type: "StructuredText";
55
+ value: import("./nestable").ImportBlock[] | null;
56
+ }, import("./nestable").ImportBlock[] | undefined, unknown> | import("io-ts").Type<{
57
+ type: "Number";
58
+ value: number | null;
59
+ }, number | undefined, unknown> | import("io-ts").Type<{
60
+ type: "Select";
61
+ value: string | null;
62
+ }, string | undefined, unknown> | import("io-ts").Type<{
63
+ type: "Text";
64
+ value: string | null;
65
+ }, string | undefined, unknown> | import("io-ts").Type<{
66
+ type: "Timestamp";
67
+ value: Date | null;
68
+ }, Date | undefined, unknown>;
69
+ result: import("fp-ts/lib/Either").Left<import("io-ts").Errors> | import("fp-ts/lib/Either").Right<{
70
+ type: "Timestamp";
71
+ value: Date | null;
72
+ }> | import("fp-ts/lib/Either").Right<{
73
+ type: "Text";
74
+ value: string | null;
75
+ }> | import("fp-ts/lib/Either").Right<{
76
+ type: "Select";
77
+ value: string | null;
78
+ }> | import("fp-ts/lib/Either").Right<{
79
+ type: "Number";
80
+ value: number | null;
81
+ }> | import("fp-ts/lib/Either").Right<{
82
+ type: "StructuredText";
83
+ value: import("./nestable").ImportBlock[] | null;
84
+ }> | import("fp-ts/lib/Either").Right<{
85
+ type: "Link";
86
+ value: ({
87
+ link_type: "Web";
88
+ url: string;
89
+ } & {
90
+ target?: string;
91
+ }) | {
92
+ link_type: "Document";
93
+ id: string;
94
+ } | {
95
+ link_type: "Media";
96
+ id: string;
97
+ } | null;
98
+ }> | import("fp-ts/lib/Either").Right<{
99
+ type: "Image";
100
+ value: import("./nestable").ImageFieldWithThumbnails | null;
101
+ }> | import("fp-ts/lib/Either").Right<{
102
+ type: "GeoPoint";
103
+ value: {
104
+ latitude: number;
105
+ longitude: number;
106
+ } | null;
107
+ }> | import("fp-ts/lib/Either").Right<{
108
+ type: "Embed";
109
+ value: {
110
+ embed_url: string;
111
+ } | null;
112
+ }> | import("fp-ts/lib/Either").Right<{
113
+ type: "Date";
114
+ value: Date | null;
115
+ }> | import("fp-ts/lib/Either").Right<{
116
+ type: "Color";
117
+ value: `#${string}` | null;
118
+ }> | import("fp-ts/lib/Either").Right<{
119
+ type: "Boolean";
120
+ value: boolean | null;
121
+ }>;
122
+ } | {
123
+ codec: import("io-ts").Type<{
124
+ type: "Slices";
125
+ value: import("./ImportSlices/SharedSlice").SharedSlice[] | null;
126
+ }, import("./ImportSlices/SharedSlice").SharedSlice[] | undefined, unknown>;
127
+ result: import("io-ts").Validation<{
128
+ type: "Slices";
129
+ value: import("./ImportSlices/SharedSlice").SharedSlice[] | null;
130
+ }>;
131
+ } | {
132
+ codec: import("io-ts").Type<{
133
+ type: "Group";
134
+ value: import("./RepeatableZoneItem").RepeatableZoneItem[] | null;
135
+ }, import("./RepeatableZoneItem").RepeatableZoneItem[] | undefined, unknown>;
136
+ result: import("io-ts").Validation<{
137
+ type: "Group";
138
+ value: import("./RepeatableZoneItem").RepeatableZoneItem[] | null;
139
+ }>;
140
+ };
141
+ };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportField = void 0;
4
+ const ImportGroup_1 = require("./ImportGroup");
5
+ const ImportSlices_1 = require("./ImportSlices");
6
+ const nestable_1 = require("./nestable");
7
+ exports.ImportField = {
8
+ is(u) {
9
+ return exports.ImportField.is(u);
10
+ },
11
+ decode: (field) => {
12
+ return (content) => {
13
+ switch (field.type) {
14
+ case "UID":
15
+ throw new Error(`The field '${field.type}' should be put at the root level of the document`);
16
+ case "Slices":
17
+ return {
18
+ codec: (0, ImportSlices_1.ImportSlices)(field),
19
+ result: (0, ImportSlices_1.ImportSlices)(field).decode(content),
20
+ };
21
+ case "Group":
22
+ return {
23
+ codec: (0, ImportGroup_1.ImportGroup)(field),
24
+ result: (0, ImportGroup_1.ImportGroup)(field).decode(content),
25
+ };
26
+ case "Choice":
27
+ throw new Error(`Unsupported type of field ${field.type}`);
28
+ default:
29
+ return nestable_1.ImportNestable.decode(field)(content);
30
+ }
31
+ };
32
+ },
33
+ };
@@ -0,0 +1,345 @@
1
+ import * as t from "io-ts";
2
+ export declare const ImportGroupValue: (groupCustomType?: ({
3
+ type: "Group";
4
+ } & {
5
+ fieldset?: string | null | undefined;
6
+ icon?: string;
7
+ description?: string;
8
+ config?: {
9
+ label?: string | null | undefined;
10
+ repeat?: boolean;
11
+ fields?: {
12
+ [x: string]: ({
13
+ type: "Boolean";
14
+ } & {
15
+ config?: {
16
+ label?: string | null | undefined;
17
+ default_value?: boolean;
18
+ placeholder_true?: string;
19
+ placeholder_false?: string;
20
+ };
21
+ }) | ({
22
+ type: "Color";
23
+ } & {
24
+ fieldset?: string | null | undefined;
25
+ config?: {
26
+ label?: string | null | undefined;
27
+ placeholder?: string;
28
+ };
29
+ }) | ({
30
+ type: "Date";
31
+ } & {
32
+ fieldset?: string | null | undefined;
33
+ config?: {
34
+ label?: string | null | undefined;
35
+ placeholder?: string;
36
+ default?: string;
37
+ };
38
+ }) | ({
39
+ type: "Embed";
40
+ } & {
41
+ fieldset?: string | null | undefined;
42
+ config?: {
43
+ label?: string | null | undefined;
44
+ placeholder?: string;
45
+ useAsTitle?: boolean;
46
+ };
47
+ }) | ({
48
+ type: "GeoPoint";
49
+ } & {
50
+ fieldset?: string | null | undefined;
51
+ config?: {
52
+ label?: string | null | undefined;
53
+ };
54
+ }) | ({
55
+ type: "Image";
56
+ } & {
57
+ fieldset?: string | null | undefined;
58
+ config?: {
59
+ label?: string | null | undefined;
60
+ placeholder?: string;
61
+ constraint?: {
62
+ width?: number | null;
63
+ height?: number | null;
64
+ };
65
+ thumbnails?: readonly ({
66
+ name: string;
67
+ } & {
68
+ width?: number | null;
69
+ height?: number | null;
70
+ })[];
71
+ };
72
+ }) | ({
73
+ type: "IntegrationFields";
74
+ } & {
75
+ fieldset?: string | null | undefined;
76
+ config?: {
77
+ label?: string | null | undefined;
78
+ placeholder?: string;
79
+ catalog?: string;
80
+ };
81
+ }) | ({
82
+ type: "Link";
83
+ } & {
84
+ fieldset?: string | null | undefined;
85
+ config?: {
86
+ label?: string | null | undefined;
87
+ useAsTitle?: boolean;
88
+ placeholder?: string;
89
+ select?: "media" | "document" | "web" | null;
90
+ customtypes?: readonly string[];
91
+ masks?: readonly string[];
92
+ tags?: readonly string[];
93
+ allowTargetBlank?: boolean;
94
+ };
95
+ }) | ({
96
+ type: "Number";
97
+ } & {
98
+ fieldset?: string | null | undefined;
99
+ config?: {
100
+ label?: string | null | undefined;
101
+ placeholder?: string;
102
+ min?: number;
103
+ max?: number;
104
+ step?: number;
105
+ };
106
+ }) | ({
107
+ type: "Range";
108
+ } & {
109
+ fieldset?: string | null | undefined;
110
+ config?: {
111
+ label?: string | null | undefined;
112
+ placeholder?: string;
113
+ min?: number;
114
+ max?: number;
115
+ step?: number;
116
+ };
117
+ }) | ({
118
+ type: "StructuredText";
119
+ } & {
120
+ fieldset?: string | null | undefined;
121
+ config?: {
122
+ label?: string | null | undefined;
123
+ placeholder?: string;
124
+ useAsTitle?: boolean;
125
+ single?: string;
126
+ multi?: string;
127
+ imageConstraint?: {
128
+ width?: number | null;
129
+ height?: number | null;
130
+ };
131
+ labels?: readonly string[];
132
+ allowTargetBlank?: boolean;
133
+ };
134
+ }) | ({
135
+ type: "Select";
136
+ } & {
137
+ fieldset?: string | null | undefined;
138
+ config?: {
139
+ label?: string | null | undefined;
140
+ placeholder?: string;
141
+ default_value?: string;
142
+ options?: readonly string[];
143
+ };
144
+ }) | ({
145
+ type: "Separator";
146
+ } & {
147
+ config?: {
148
+ label?: string | null | undefined;
149
+ };
150
+ }) | ({
151
+ type: "Text";
152
+ } & {
153
+ fieldset?: string | null | undefined;
154
+ config?: {
155
+ label?: string | null | undefined;
156
+ useAsTitle?: boolean;
157
+ placeholder?: string;
158
+ };
159
+ }) | ({
160
+ type: "Timestamp";
161
+ } & {
162
+ fieldset?: string | null | undefined;
163
+ config?: {
164
+ label?: string | null | undefined;
165
+ placeholder?: string;
166
+ default?: string;
167
+ };
168
+ });
169
+ };
170
+ };
171
+ }) | undefined) => t.Type<import("./RepeatableZoneItem").RepeatableZoneItem[], import("./RepeatableZoneItem").RepeatableZoneItem[], unknown>;
172
+ export declare const ImportGroup: (groupCustomType?: ({
173
+ type: "Group";
174
+ } & {
175
+ fieldset?: string | null | undefined;
176
+ icon?: string;
177
+ description?: string;
178
+ config?: {
179
+ label?: string | null | undefined;
180
+ repeat?: boolean;
181
+ fields?: {
182
+ [x: string]: ({
183
+ type: "Boolean";
184
+ } & {
185
+ config?: {
186
+ label?: string | null | undefined;
187
+ default_value?: boolean;
188
+ placeholder_true?: string;
189
+ placeholder_false?: string;
190
+ };
191
+ }) | ({
192
+ type: "Color";
193
+ } & {
194
+ fieldset?: string | null | undefined;
195
+ config?: {
196
+ label?: string | null | undefined;
197
+ placeholder?: string;
198
+ };
199
+ }) | ({
200
+ type: "Date";
201
+ } & {
202
+ fieldset?: string | null | undefined;
203
+ config?: {
204
+ label?: string | null | undefined;
205
+ placeholder?: string;
206
+ default?: string;
207
+ };
208
+ }) | ({
209
+ type: "Embed";
210
+ } & {
211
+ fieldset?: string | null | undefined;
212
+ config?: {
213
+ label?: string | null | undefined;
214
+ placeholder?: string;
215
+ useAsTitle?: boolean;
216
+ };
217
+ }) | ({
218
+ type: "GeoPoint";
219
+ } & {
220
+ fieldset?: string | null | undefined;
221
+ config?: {
222
+ label?: string | null | undefined;
223
+ };
224
+ }) | ({
225
+ type: "Image";
226
+ } & {
227
+ fieldset?: string | null | undefined;
228
+ config?: {
229
+ label?: string | null | undefined;
230
+ placeholder?: string;
231
+ constraint?: {
232
+ width?: number | null;
233
+ height?: number | null;
234
+ };
235
+ thumbnails?: readonly ({
236
+ name: string;
237
+ } & {
238
+ width?: number | null;
239
+ height?: number | null;
240
+ })[];
241
+ };
242
+ }) | ({
243
+ type: "IntegrationFields";
244
+ } & {
245
+ fieldset?: string | null | undefined;
246
+ config?: {
247
+ label?: string | null | undefined;
248
+ placeholder?: string;
249
+ catalog?: string;
250
+ };
251
+ }) | ({
252
+ type: "Link";
253
+ } & {
254
+ fieldset?: string | null | undefined;
255
+ config?: {
256
+ label?: string | null | undefined;
257
+ useAsTitle?: boolean;
258
+ placeholder?: string;
259
+ select?: "media" | "document" | "web" | null;
260
+ customtypes?: readonly string[];
261
+ masks?: readonly string[];
262
+ tags?: readonly string[];
263
+ allowTargetBlank?: boolean;
264
+ };
265
+ }) | ({
266
+ type: "Number";
267
+ } & {
268
+ fieldset?: string | null | undefined;
269
+ config?: {
270
+ label?: string | null | undefined;
271
+ placeholder?: string;
272
+ min?: number;
273
+ max?: number;
274
+ step?: number;
275
+ };
276
+ }) | ({
277
+ type: "Range";
278
+ } & {
279
+ fieldset?: string | null | undefined;
280
+ config?: {
281
+ label?: string | null | undefined;
282
+ placeholder?: string;
283
+ min?: number;
284
+ max?: number;
285
+ step?: number;
286
+ };
287
+ }) | ({
288
+ type: "StructuredText";
289
+ } & {
290
+ fieldset?: string | null | undefined;
291
+ config?: {
292
+ label?: string | null | undefined;
293
+ placeholder?: string;
294
+ useAsTitle?: boolean;
295
+ single?: string;
296
+ multi?: string;
297
+ imageConstraint?: {
298
+ width?: number | null;
299
+ height?: number | null;
300
+ };
301
+ labels?: readonly string[];
302
+ allowTargetBlank?: boolean;
303
+ };
304
+ }) | ({
305
+ type: "Select";
306
+ } & {
307
+ fieldset?: string | null | undefined;
308
+ config?: {
309
+ label?: string | null | undefined;
310
+ placeholder?: string;
311
+ default_value?: string;
312
+ options?: readonly string[];
313
+ };
314
+ }) | ({
315
+ type: "Separator";
316
+ } & {
317
+ config?: {
318
+ label?: string | null | undefined;
319
+ };
320
+ }) | ({
321
+ type: "Text";
322
+ } & {
323
+ fieldset?: string | null | undefined;
324
+ config?: {
325
+ label?: string | null | undefined;
326
+ useAsTitle?: boolean;
327
+ placeholder?: string;
328
+ };
329
+ }) | ({
330
+ type: "Timestamp";
331
+ } & {
332
+ fieldset?: string | null | undefined;
333
+ config?: {
334
+ label?: string | null | undefined;
335
+ placeholder?: string;
336
+ default?: string;
337
+ };
338
+ });
339
+ };
340
+ };
341
+ }) | undefined) => t.Type<{
342
+ type: "Group";
343
+ value: import("./RepeatableZoneItem").RepeatableZoneItem[] | null;
344
+ }, import("./RepeatableZoneItem").RepeatableZoneItem[] | undefined, unknown>;
345
+ export declare type ImportGroup = t.TypeOf<ReturnType<typeof ImportGroup>>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportGroup = exports.ImportGroupValue = 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 validators_1 = require("../../../validators");
9
+ const function_2 = require("../../../validators/function");
10
+ const ImportContent_1 = require("./ImportContent");
11
+ const RepeatableZone_1 = require("./RepeatableZone");
12
+ const ImportGroupValue = (groupCustomType) => {
13
+ var _a, _b;
14
+ const fieldsModel = (_b = (_a = groupCustomType === null || groupCustomType === void 0 ? void 0 : groupCustomType.config) === null || _a === void 0 ? void 0 : _a.fields) !== null && _b !== void 0 ? _b : {};
15
+ const groupArrayCodec = (0, RepeatableZone_1.RepeatableZone)(fieldsModel);
16
+ return (0, function_2.withCustomError)(new t.Type(groupArrayCodec.name, groupArrayCodec.is, (u, c) => (0, function_1.pipe)(groupArrayCodec.validate(u, c), E.chain((groups) => {
17
+ var _a;
18
+ if (((_a = groupCustomType === null || groupCustomType === void 0 ? void 0 : groupCustomType.config) === null || _a === void 0 ? void 0 : _a.repeat) === false &&
19
+ groups.length > 1) {
20
+ return t.failure(groups, c, "The custom type for this group field does not allow multiple group items");
21
+ }
22
+ return t.success(groups);
23
+ })), t.identity), () => "The group field value must be an array");
24
+ };
25
+ exports.ImportGroupValue = ImportGroupValue;
26
+ const ImportGroup = (groupCustomType) => (0, ImportContent_1.ImportContent)("Group", (0, validators_1.EmptyArrayOrElse)((0, exports.ImportGroupValue)(groupCustomType)));
27
+ exports.ImportGroup = ImportGroup;
@@ -0,0 +1,8 @@
1
+ import * as t from "io-ts";
2
+ import type { StaticSlices } from "../../../../customtypes";
3
+ import { SharedSlice } from "./SharedSlice";
4
+ export declare const ImportSlices: (staticSlices: StaticSlices) => t.Type<{
5
+ type: "Slices";
6
+ value: SharedSlice[] | null;
7
+ }, SharedSlice[] | undefined, unknown>;
8
+ export declare type ImportSlices = t.TypeOf<ReturnType<typeof ImportSlices>>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportSlices = 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 validators_1 = require("../../../../validators");
9
+ const ImportContent_1 = require("../ImportContent");
10
+ const SharedSlice_1 = require("./SharedSlice");
11
+ const utils_1 = require("./utils");
12
+ const ImportSlices = (staticSlices) => {
13
+ const supportedSlices = (0, utils_1.extractSupportedSlices)(staticSlices);
14
+ // For now we only support the SharedSlice, however if we want to support more in the future
15
+ // we would have to change the codec here to something like this: t.array(t.union([ImportSharedSlice(sharedSlices), NewSliceCodec(newSliceCustomTypes)])).
16
+ const SharedSliceCodec = (0, SharedSlice_1.SharedSlice)(supportedSlices);
17
+ const SlicesArrayCodec = t.array(SharedSliceCodec);
18
+ return (0, ImportContent_1.ImportContent)("Slices", (0, validators_1.EmptyArrayOrElse)(new t.ArrayType(SlicesArrayCodec.name, (u) => SlicesArrayCodec.is(u), (u, c) => {
19
+ return (0, function_1.pipe)(SlicesArrayCodec.validate(u, c), E.chain((slices) => {
20
+ // This part might not make sense for all Slice types in the future, but for now we only support the SharedSlice
21
+ // In case we support more in the future, we would have to filter only the relevant type for this check
22
+ const sharedSliceDuplicates = (0, utils_1.findImportSharedSliceDuplicateIds)(slices);
23
+ if (sharedSliceDuplicates.length > 0) {
24
+ return t.failure(slices, [], `Duplicate slice IDs detected: ${sharedSliceDuplicates.join(", ")}`);
25
+ }
26
+ return t.success(slices);
27
+ }));
28
+ }, t.identity, SharedSliceCodec)));
29
+ };
30
+ exports.ImportSlices = ImportSlices;
@@ -0,0 +1,16 @@
1
+ import * as t from "io-ts";
2
+ import type { SharedSlice as SharedSliceCustomType } from "../../../../../customtypes";
3
+ import { RepeatableZone } from "../../RepeatableZone";
4
+ import { RepeatableZoneItem } from "../../RepeatableZoneItem";
5
+ import { SharedSliceId } from "./fields";
6
+ export declare type SharedSlice = {
7
+ id: SharedSliceId | null | undefined;
8
+ slice_type: string;
9
+ name: string;
10
+ variation: string;
11
+ primary: RepeatableZoneItem | null | undefined;
12
+ items: RepeatableZone | null | undefined;
13
+ slice_label: string | null | undefined;
14
+ version: string | null | undefined;
15
+ };
16
+ export declare const SharedSlice: (sharedSlices: SharedSliceCustomType[]) => t.Type<SharedSlice, SharedSlice, unknown>;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SharedSlice = 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 validators_1 = require("../../../../../validators");
9
+ const RepeatableZone_1 = require("../../RepeatableZone");
10
+ const RepeatableZoneItem_1 = require("../../RepeatableZoneItem");
11
+ const fields_1 = require("./fields");
12
+ const SharedSliceShape = t.strict({
13
+ id: fields_1.OptionalSharedSliceId,
14
+ slice_type: validators_1.NonEmptyString,
15
+ name: validators_1.String,
16
+ variation: validators_1.NonEmptyString,
17
+ primary: t.union([t.undefined, t.null, t.record(validators_1.NonEmptyString, t.unknown)]),
18
+ items: t.union([
19
+ t.undefined,
20
+ t.null,
21
+ t.array(t.record(validators_1.NonEmptyString, t.unknown)),
22
+ ]),
23
+ slice_label: t.union([t.undefined, t.null, validators_1.String]),
24
+ version: t.union([t.undefined, t.null, validators_1.String]),
25
+ });
26
+ const SharedSlice = (sharedSlices) => new t.Type("SharedSlice", (u) => SharedSliceShape.is(u), (u, c) => (0, function_1.pipe)(
27
+ // We validate the base fields that we can validate directly based on the provided 'sharedSlices'
28
+ t
29
+ .type({
30
+ id: fields_1.OptionalSharedSliceId,
31
+ slice_type: (0, fields_1.SharedSliceType)(sharedSlices),
32
+ slice_label: t.union([t.undefined, t.null, validators_1.String]),
33
+ version: t.union([t.undefined, t.null, validators_1.String]),
34
+ })
35
+ .validate(u, c), E.chain((decoded) => (0, function_1.pipe)(
36
+ // We validate the 'variation' field, for which we need the SharedSlice custom type retrieved in the first step
37
+ t
38
+ .type({
39
+ variation: (0, fields_1.SharedSliceVariation)(decoded.slice_type.data),
40
+ })
41
+ .validate(u, c), E.map(({ variation }) => ({ ...decoded, variation })))), E.chain((decoded) => {
42
+ var _a, _b;
43
+ return (0, function_1.pipe)(
44
+ // We validate the 'primary' and 'items' content fields, for which we need the Variation custom type retrieved in the previous step
45
+ t
46
+ .partial({
47
+ primary: (0, RepeatableZoneItem_1.RepeatableZoneItem)((_a = decoded.variation.data.primary) !== null && _a !== void 0 ? _a : {}),
48
+ items: (0, RepeatableZone_1.RepeatableZone)((_b = decoded.variation.data.items) !== null && _b !== void 0 ? _b : {}),
49
+ })
50
+ .validate(u, c), E.map(({ primary, items }) => ({ ...decoded, primary, items })));
51
+ }), E.map(({ id, slice_type, variation, primary, items, slice_label, version, }) => ({
52
+ id,
53
+ slice_type: slice_type.slice_type,
54
+ name: slice_type.data.name,
55
+ variation: variation.variation,
56
+ primary,
57
+ items,
58
+ slice_label,
59
+ version: version !== null && version !== void 0 ? version : variation.data.version,
60
+ }))), t.identity);
61
+ exports.SharedSlice = SharedSlice;
@@ -0,0 +1,4 @@
1
+ export declare const SharedSliceErrors: {
2
+ readonly SliceTypeNotFound: (slice_type: string) => string;
3
+ readonly VariationNotFound: (variation: string, slice_type: string) => string;
4
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SharedSliceErrors = void 0;
4
+ exports.SharedSliceErrors = {
5
+ SliceTypeNotFound: (slice_type) => `Shared slice '${slice_type}' not found in this slice zone in the document's custom type`,
6
+ VariationNotFound: (variation, slice_type) => `Variation '${variation}' not found for Slice '${slice_type}'`,
7
+ };