@prismicio/types-internal 0.2.2 → 0.2.3

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 (87) hide show
  1. package/lib/customtypes/CustomType.d.ts +2 -20
  2. package/lib/customtypes/CustomType.js +33 -25
  3. package/lib/customtypes/Format.js +5 -2
  4. package/lib/customtypes/Section.d.ts +3 -30
  5. package/lib/customtypes/Section.js +14 -9
  6. package/lib/customtypes/index.js +9 -4
  7. package/lib/customtypes/widgets/Group.js +12 -9
  8. package/lib/customtypes/widgets/UID.js +10 -7
  9. package/lib/customtypes/widgets/Widget.d.ts +3 -30
  10. package/lib/customtypes/widgets/Widget.js +19 -14
  11. package/lib/customtypes/widgets/WidgetTypes.js +3 -1
  12. package/lib/customtypes/widgets/index.js +14 -7
  13. package/lib/customtypes/widgets/nestable/BooleanField.js +9 -6
  14. package/lib/customtypes/widgets/nestable/Color.js +10 -7
  15. package/lib/customtypes/widgets/nestable/Date.js +10 -7
  16. package/lib/customtypes/widgets/nestable/Embed.js +10 -7
  17. package/lib/customtypes/widgets/nestable/GeoPoint.js +10 -7
  18. package/lib/customtypes/widgets/nestable/Image.js +13 -10
  19. package/lib/customtypes/widgets/nestable/IntegrationField.js +10 -7
  20. package/lib/customtypes/widgets/nestable/Link.js +14 -11
  21. package/lib/customtypes/widgets/nestable/NestableWidget.js +35 -32
  22. package/lib/customtypes/widgets/nestable/Number.js +14 -11
  23. package/lib/customtypes/widgets/nestable/Range.js +14 -11
  24. package/lib/customtypes/widgets/nestable/RichText.js +15 -12
  25. package/lib/customtypes/widgets/nestable/Select.js +11 -8
  26. package/lib/customtypes/widgets/nestable/Separator.js +9 -6
  27. package/lib/customtypes/widgets/nestable/Text.js +10 -7
  28. package/lib/customtypes/widgets/nestable/Timestamp.js +10 -7
  29. package/lib/customtypes/widgets/nestable/index.js +36 -15
  30. package/lib/customtypes/widgets/shared/ImageConstraint.js +12 -9
  31. package/lib/customtypes/widgets/shared/index.js +8 -1
  32. package/lib/customtypes/widgets/slices/CompositeSlice.js +13 -10
  33. package/lib/customtypes/widgets/slices/LegacySlice.d.ts +1 -10
  34. package/lib/customtypes/widgets/slices/LegacySlice.js +8 -6
  35. package/lib/customtypes/widgets/slices/SharedSlice.js +12 -9
  36. package/lib/customtypes/widgets/slices/SharedSliceRef.js +7 -4
  37. package/lib/customtypes/widgets/slices/Slice.js +2 -1
  38. package/lib/customtypes/widgets/slices/Slices.d.ts +6 -60
  39. package/lib/customtypes/widgets/slices/Slices.js +33 -27
  40. package/lib/customtypes/widgets/slices/SlicesTypes.js +3 -1
  41. package/lib/customtypes/widgets/slices/index.js +16 -7
  42. package/lib/documents/DocumentData.js +7 -4
  43. package/lib/documents/index.js +7 -2
  44. package/lib/documents/widgets/EmptyContent.js +6 -3
  45. package/lib/documents/widgets/GroupContent.js +14 -10
  46. package/lib/documents/widgets/SimpleWidgetContent.js +32 -27
  47. package/lib/documents/widgets/StaticWidgetContent.js +11 -8
  48. package/lib/documents/widgets/UIDContent.js +8 -4
  49. package/lib/documents/widgets/index.js +27 -22
  50. package/lib/documents/widgets/nestable/BooleanContent.js +10 -6
  51. package/lib/documents/widgets/nestable/EmbedContent.js +24 -20
  52. package/lib/documents/widgets/nestable/FieldContent.js +10 -6
  53. package/lib/documents/widgets/nestable/GeoPointContent.js +9 -5
  54. package/lib/documents/widgets/nestable/ImageContent.js +16 -12
  55. package/lib/documents/widgets/nestable/IntegrationFieldsContent.js +10 -6
  56. package/lib/documents/widgets/nestable/Link/DocumentLink.js +12 -7
  57. package/lib/documents/widgets/nestable/Link/ExternalLink.js +15 -10
  58. package/lib/documents/widgets/nestable/Link/FileLink.js +15 -10
  59. package/lib/documents/widgets/nestable/Link/ImageLink.js +14 -9
  60. package/lib/documents/widgets/nestable/Link/LinkContent.js +13 -9
  61. package/lib/documents/widgets/nestable/Link/index.js +33 -24
  62. package/lib/documents/widgets/nestable/SeparatorContent.js +5 -2
  63. package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +39 -33
  64. package/lib/documents/widgets/nestable/StructuredTextContent/index.js +11 -7
  65. package/lib/documents/widgets/nestable/index.js +39 -28
  66. package/lib/documents/widgets/slices/CompositeSliceContent.js +13 -9
  67. package/lib/documents/widgets/slices/SharedSliceContent.js +16 -12
  68. package/lib/documents/widgets/slices/SimpleSliceContent.js +6 -2
  69. package/lib/documents/widgets/slices/SliceWidgetContent.js +12 -8
  70. package/lib/documents/widgets/slices/SlicesContent.js +17 -13
  71. package/lib/documents/widgets/slices/index.js +8 -5
  72. package/lib/index.js +7 -3
  73. package/lib/validators/DateFromString.js +7 -4
  74. package/lib/validators/DateFromStringOrNumber.js +7 -4
  75. package/lib/validators/DateFromTsMs.js +7 -4
  76. package/lib/validators/IntFromNumber.js +7 -4
  77. package/lib/validators/IntFromPixels.js +7 -4
  78. package/lib/validators/NonEmptyString.js +6 -3
  79. package/lib/validators/NonEmptyStringOrNull.js +10 -7
  80. package/lib/validators/NumberOrNull.js +6 -3
  81. package/lib/validators/StringFromBoolean.js +7 -4
  82. package/lib/validators/StringFromNumber.js +7 -4
  83. package/lib/validators/StringOrNull.js +6 -3
  84. package/lib/validators/function.js +28 -15
  85. package/lib/validators/index.js +27 -12
  86. package/package.json +1 -1
  87. package/src/customtypes/widgets/slices/LegacySlice.ts +1 -2
@@ -1,27 +1,30 @@
1
- import * as t from "io-ts";
2
- import { withFallback } from "io-ts-types/lib/withFallback";
3
- import NestableWidget from "../nestable/NestableWidget";
4
- import SlicesTypes from "./SlicesTypes";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
5
+ const withFallback_1 = require("io-ts-types/lib/withFallback");
6
+ const NestableWidget_1 = (0, tslib_1.__importDefault)(require("../nestable/NestableWidget"));
7
+ const SlicesTypes_1 = (0, tslib_1.__importDefault)(require("./SlicesTypes"));
5
8
  const IMAGE_PLACEHOLDER_URL = "https://images.prismic.io/slice-machine/621a5ec4-0387-4bc5-9860-2dd46cbc07cd_default_ss.png?auto=compress,format";
6
9
  const Variation = t.exact(t.intersection([
7
10
  t.type({
8
11
  id: t.string,
9
12
  name: t.string,
10
13
  description: t.string,
11
- imageUrl: withFallback(t.string, IMAGE_PLACEHOLDER_URL),
14
+ imageUrl: (0, withFallback_1.withFallback)(t.string, IMAGE_PLACEHOLDER_URL),
12
15
  docURL: t.string,
13
16
  version: t.string,
14
17
  }),
15
18
  t.partial({
16
19
  display: t.string,
17
- primary: t.record(t.string, NestableWidget),
18
- items: t.record(t.string, NestableWidget),
20
+ primary: t.record(t.string, NestableWidget_1.default),
21
+ items: t.record(t.string, NestableWidget_1.default),
19
22
  }),
20
23
  ]));
21
24
  const SharedSlice = t.exact(t.intersection([
22
25
  t.type({
23
26
  id: t.string,
24
- type: t.literal(SlicesTypes.SharedSlice),
27
+ type: t.literal(SlicesTypes_1.default.SharedSlice),
25
28
  name: t.string,
26
29
  variations: t.array(Variation),
27
30
  }),
@@ -29,4 +32,4 @@ const SharedSlice = t.exact(t.intersection([
29
32
  description: t.string,
30
33
  }),
31
34
  ]));
32
- export default SharedSlice;
35
+ exports.default = SharedSlice;
@@ -1,6 +1,9 @@
1
- import * as t from "io-ts";
2
- import SlicesTypes from "./SlicesTypes";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
5
+ const SlicesTypes_1 = (0, tslib_1.__importDefault)(require("./SlicesTypes"));
3
6
  const SharedSliceRef = t.exact(t.type({
4
- type: t.literal(SlicesTypes.SharedSlice),
7
+ type: t.literal(SlicesTypes_1.default.SharedSlice),
5
8
  }));
6
- export default SharedSliceRef;
9
+ exports.default = SharedSliceRef;
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -10,16 +10,7 @@ export declare function slicesConfigReader<F extends Format>(format: F): t.Exact
10
10
  }>, t.PartialC<{
11
11
  display: t.StringC;
12
12
  }>]>>>>, t.NullC]>;
13
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
14
- type: t.LiteralC<WidgetTypes.UID>;
15
- }>, t.PartialC<{
16
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
17
- config: t.ExactC<t.PartialC<{
18
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
19
- useAsTitle: t.BooleanC;
20
- placeholder: t.StringC;
21
- }>>;
22
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
13
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
23
14
  type: t.LiteralC<WidgetTypes.Color>;
24
15
  }>, t.PartialC<{
25
16
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1007,16 +998,7 @@ export declare const StaticSlicesConfig: t.ExactC<t.PartialC<{
1007
998
  }>, t.PartialC<{
1008
999
  display: t.StringC;
1009
1000
  }>]>>>>, t.NullC]>;
1010
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1011
- type: t.LiteralC<WidgetTypes.UID>;
1012
- }>, t.PartialC<{
1013
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1014
- config: t.ExactC<t.PartialC<{
1015
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1016
- useAsTitle: t.BooleanC;
1017
- placeholder: t.StringC;
1018
- }>>;
1019
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1001
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1020
1002
  type: t.LiteralC<WidgetTypes.Color>;
1021
1003
  }>, t.PartialC<{
1022
1004
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -2005,16 +1987,7 @@ export declare const DynamicSlicesConfig: t.ExactC<t.PartialC<{
2005
1987
  }>, t.PartialC<{
2006
1988
  display: t.StringC;
2007
1989
  }>]>>>>, t.NullC]>;
2008
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
2009
- type: t.LiteralC<WidgetTypes.UID>;
2010
- }>, t.PartialC<{
2011
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
2012
- config: t.ExactC<t.PartialC<{
2013
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
2014
- useAsTitle: t.BooleanC;
2015
- placeholder: t.StringC;
2016
- }>>;
2017
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1990
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
2018
1991
  type: t.LiteralC<WidgetTypes.Color>;
2019
1992
  }>, t.PartialC<{
2020
1993
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -3007,16 +2980,7 @@ export declare function slicesReader<F extends Format>(format: F): t.ExactC<t.In
3007
2980
  }>, t.PartialC<{
3008
2981
  display: t.StringC;
3009
2982
  }>]>>>>, t.NullC]>;
3010
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
3011
- type: t.LiteralC<WidgetTypes.UID>;
3012
- }>, t.PartialC<{
3013
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
3014
- config: t.ExactC<t.PartialC<{
3015
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
3016
- useAsTitle: t.BooleanC;
3017
- placeholder: t.StringC;
3018
- }>>;
3019
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
2983
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
3020
2984
  type: t.LiteralC<WidgetTypes.Color>;
3021
2985
  }>, t.PartialC<{
3022
2986
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -4009,16 +3973,7 @@ export declare const StaticSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
4009
3973
  }>, t.PartialC<{
4010
3974
  display: t.StringC;
4011
3975
  }>]>>>>, t.NullC]>;
4012
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
4013
- type: t.LiteralC<WidgetTypes.UID>;
4014
- }>, t.PartialC<{
4015
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
4016
- config: t.ExactC<t.PartialC<{
4017
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
4018
- useAsTitle: t.BooleanC;
4019
- placeholder: t.StringC;
4020
- }>>;
4021
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
3976
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
4022
3977
  type: t.LiteralC<WidgetTypes.Color>;
4023
3978
  }>, t.PartialC<{
4024
3979
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -5012,16 +4967,7 @@ export declare const DynamicSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
5012
4967
  }>, t.PartialC<{
5013
4968
  display: t.StringC;
5014
4969
  }>]>>>>, t.NullC]>;
5015
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
5016
- type: t.LiteralC<WidgetTypes.UID>;
5017
- }>, t.PartialC<{
5018
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
5019
- config: t.ExactC<t.PartialC<{
5020
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
5021
- useAsTitle: t.BooleanC;
5022
- placeholder: t.StringC;
5023
- }>>;
5024
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
4970
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
5025
4971
  type: t.LiteralC<WidgetTypes.Color>;
5026
4972
  }>, t.PartialC<{
5027
4973
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1,12 +1,16 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../../validators";
3
- import { Format } from "../../Format";
4
- import WidgetTypes from "../WidgetTypes";
5
- import CompositeSlice from "./CompositeSlice";
6
- import LegacySlice from "./LegacySlice";
7
- import SharedSlice from "./SharedSlice";
8
- import SharedSliceRef from "./SharedSliceRef";
9
- import SlicesTypes from "./SlicesTypes";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Slices = exports.DynamicSlices = exports.StaticSlices = exports.slicesReader = exports.DynamicSlicesConfig = exports.StaticSlicesConfig = exports.slicesConfigReader = 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 Format_1 = require("../../Format");
8
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
9
+ const CompositeSlice_1 = (0, tslib_1.__importDefault)(require("./CompositeSlice"));
10
+ const LegacySlice_1 = (0, tslib_1.__importDefault)(require("./LegacySlice"));
11
+ const SharedSlice_1 = (0, tslib_1.__importDefault)(require("./SharedSlice"));
12
+ const SharedSliceRef_1 = (0, tslib_1.__importDefault)(require("./SharedSliceRef"));
13
+ const SlicesTypes_1 = (0, tslib_1.__importDefault)(require("./SlicesTypes"));
10
14
  const SlicesLabels = t.union([
11
15
  t.record(t.string, t.array(t.exact(t.intersection([
12
16
  t.type({
@@ -18,19 +22,19 @@ const SlicesLabels = t.union([
18
22
  ])))),
19
23
  t.null,
20
24
  ]);
21
- export function slicesConfigReader(format) {
25
+ function slicesConfigReader(format) {
22
26
  return t.exact(t.partial({
23
- label: StringOrNull,
27
+ label: validators_1.StringOrNull,
24
28
  labels: SlicesLabels,
25
29
  choices: t.record(t.string, t.union([
26
- LegacySlice,
27
- CompositeSlice,
30
+ LegacySlice_1.default,
31
+ CompositeSlice_1.default,
28
32
  (() => {
29
33
  switch (format) {
30
- case Format.Static:
31
- return SharedSlice;
32
- case Format.Dynamic:
33
- return SharedSliceRef;
34
+ case Format_1.Format.Static:
35
+ return SharedSlice_1.default;
36
+ case Format_1.Format.Dynamic:
37
+ return SharedSliceRef_1.default;
34
38
  default:
35
39
  throw new Error(`Invalid Format Exception: ${format} doesn't exist`);
36
40
  }
@@ -38,12 +42,13 @@ export function slicesConfigReader(format) {
38
42
  ])),
39
43
  }));
40
44
  }
41
- export const StaticSlicesConfig = slicesConfigReader(Format.Static);
42
- export const DynamicSlicesConfig = slicesConfigReader(Format.Dynamic);
45
+ exports.slicesConfigReader = slicesConfigReader;
46
+ exports.StaticSlicesConfig = slicesConfigReader(Format_1.Format.Static);
47
+ exports.DynamicSlicesConfig = slicesConfigReader(Format_1.Format.Dynamic);
43
48
  const SlicesConfig = {
44
49
  toStatic(config, sharedSlices) {
45
50
  const choices = Object.entries(config.choices || {}).reduce((acc, [ref, slice]) => {
46
- if (slice.type === SlicesTypes.SharedSlice) {
51
+ if (slice.type === SlicesTypes_1.default.SharedSlice) {
47
52
  const sharedSlice = sharedSlices.get(ref);
48
53
  if (sharedSlice)
49
54
  return { ...acc, [ref]: sharedSlice };
@@ -57,23 +62,24 @@ const SlicesConfig = {
57
62
  return { ...config, choices };
58
63
  },
59
64
  };
60
- export function slicesReader(format) {
65
+ function slicesReader(format) {
61
66
  return t.exact(t.intersection([
62
67
  t.type({
63
68
  type: t.union([
64
- t.literal(WidgetTypes.Slices),
65
- t.literal(WidgetTypes.LegacySlices),
69
+ t.literal(WidgetTypes_1.default.Slices),
70
+ t.literal(WidgetTypes_1.default.LegacySlices),
66
71
  ]),
67
72
  }),
68
73
  t.partial({
69
- fieldset: StringOrNull,
74
+ fieldset: validators_1.StringOrNull,
70
75
  config: slicesConfigReader(format),
71
76
  }),
72
77
  ]));
73
78
  }
74
- export const StaticSlices = slicesReader(Format.Static);
75
- export const DynamicSlices = slicesReader(Format.Dynamic);
76
- export const Slices = {
79
+ exports.slicesReader = slicesReader;
80
+ exports.StaticSlices = slicesReader(Format_1.Format.Static);
81
+ exports.DynamicSlices = slicesReader(Format_1.Format.Dynamic);
82
+ exports.Slices = {
77
83
  toStatic(slices, sharedSlices) {
78
84
  if (!slices.config)
79
85
  return slices;
@@ -1,6 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  var SlicesTypes;
2
4
  (function (SlicesTypes) {
3
5
  SlicesTypes["Slice"] = "Slice";
4
6
  SlicesTypes["SharedSlice"] = "SharedSlice";
5
7
  })(SlicesTypes || (SlicesTypes = {}));
6
- export default SlicesTypes;
8
+ exports.default = SlicesTypes;
@@ -1,7 +1,16 @@
1
- export { default as CompositeSlice } from "./CompositeSlice";
2
- export { default as LegacySlice } from "./LegacySlice";
3
- export { default as SharedSlice } from "./SharedSlice";
4
- export { default as SharedSliceRef } from "./SharedSliceRef";
5
- export * as Slice from "./Slice";
6
- export * as SliceZone from "./Slices";
7
- export { default as SlicesTypes } from "./SlicesTypes";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SlicesTypes = exports.SliceZone = exports.Slice = exports.SharedSliceRef = exports.SharedSlice = exports.LegacySlice = exports.CompositeSlice = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var CompositeSlice_1 = require("./CompositeSlice");
6
+ Object.defineProperty(exports, "CompositeSlice", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(CompositeSlice_1).default; } });
7
+ var LegacySlice_1 = require("./LegacySlice");
8
+ Object.defineProperty(exports, "LegacySlice", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(LegacySlice_1).default; } });
9
+ var SharedSlice_1 = require("./SharedSlice");
10
+ Object.defineProperty(exports, "SharedSlice", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(SharedSlice_1).default; } });
11
+ var SharedSliceRef_1 = require("./SharedSliceRef");
12
+ Object.defineProperty(exports, "SharedSliceRef", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(SharedSliceRef_1).default; } });
13
+ exports.Slice = (0, tslib_1.__importStar)(require("./Slice"));
14
+ exports.SliceZone = (0, tslib_1.__importStar)(require("./Slices"));
15
+ var SlicesTypes_1 = require("./SlicesTypes");
16
+ Object.defineProperty(exports, "SlicesTypes", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(SlicesTypes_1).default; } });
@@ -1,11 +1,14 @@
1
- import * as O from "fp-ts/lib/Option";
2
- import { Widget } from "./widgets";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const O = (0, tslib_1.__importStar)(require("fp-ts/lib/Option"));
5
+ const widgets_1 = require("./widgets");
3
6
  function computeWidget(key, widgets, widgetTypes, widgetPositions) {
4
7
  const widget = widgets.get(key);
5
8
  if (widget === undefined) {
6
9
  return O.none;
7
10
  }
8
- return Widget.fromJson(key, widget, widgetTypes, widgetPositions);
11
+ return widgets_1.Widget.fromJson(key, widget, widgetTypes, widgetPositions);
9
12
  }
10
13
  const DocumentData = {
11
14
  getWidget(key, widgets, widgetTypes, widgetPositions, parsed) {
@@ -22,4 +25,4 @@ const DocumentData = {
22
25
  }, new Map());
23
26
  },
24
27
  };
25
- export default DocumentData;
28
+ exports.default = DocumentData;
@@ -1,2 +1,7 @@
1
- export { default as DocumentData } from "./DocumentData";
2
- export * as Widgets from "./widgets";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Widgets = exports.DocumentData = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var DocumentData_1 = require("./DocumentData");
6
+ Object.defineProperty(exports, "DocumentData", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(DocumentData_1).default; } });
7
+ exports.Widgets = (0, tslib_1.__importStar)(require("./widgets"));
@@ -1,6 +1,9 @@
1
- export const EmptyContentType = "EmptyContent";
2
- export const EmptyContent = {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmptyContent = exports.EmptyContentType = void 0;
4
+ exports.EmptyContentType = "EmptyContent";
5
+ exports.EmptyContent = {
3
6
  is: (value) => {
4
- return value.__TYPE__ === EmptyContentType;
7
+ return value.__TYPE__ === exports.EmptyContentType;
5
8
  },
6
9
  };
@@ -1,10 +1,14 @@
1
- import * as A from "fp-ts/Array";
2
- import * as O from "fp-ts/Option";
3
- import * as t from "io-ts";
4
- import { SimpleWidgetContent } from "./SimpleWidgetContent";
5
- export const GroupItemContentType = "GroupItemContent";
6
- export const GroupContentType = "GroupContentType";
7
- export const GroupContent = Object.freeze({
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GroupContent = exports.GroupContentType = exports.GroupItemContentType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const A = (0, tslib_1.__importStar)(require("fp-ts/Array"));
6
+ const O = (0, tslib_1.__importStar)(require("fp-ts/Option"));
7
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
8
+ const SimpleWidgetContent_1 = require("./SimpleWidgetContent");
9
+ exports.GroupItemContentType = "GroupItemContent";
10
+ exports.GroupContentType = "GroupContentType";
11
+ exports.GroupContent = Object.freeze({
8
12
  itemsContentsFromJson: (prefixedKey, jsItems, fieldTypes, fieldPositions) => {
9
13
  if (jsItems) {
10
14
  return jsItems.map((jsItem) => {
@@ -19,7 +23,7 @@ export const GroupContent = Object.freeze({
19
23
  if (kind) {
20
24
  return O.map((content) => {
21
25
  return [k, content];
22
- })(SimpleWidgetContent.from(kind, v));
26
+ })(SimpleWidgetContent_1.SimpleWidgetContent.from(kind, v));
23
27
  }
24
28
  else {
25
29
  return O.none;
@@ -47,8 +51,8 @@ export const GroupContent = Object.freeze({
47
51
  const maybeJsItems = O.fromEither(t.array(t.unknown).decode(value));
48
52
  return O.map((items) => {
49
53
  return {
50
- value: GroupContent.itemsContentsFromJson(prefixedKey, items, fieldTypes, fieldPositions),
51
- __TYPE__: GroupContentType,
54
+ value: exports.GroupContent.itemsContentsFromJson(prefixedKey, items, fieldTypes, fieldPositions),
55
+ __TYPE__: exports.GroupContentType,
52
56
  };
53
57
  })(maybeJsItems);
54
58
  },
@@ -1,17 +1,21 @@
1
- import { pipe } from "fp-ts/function";
2
- import * as O from "fp-ts/Option";
3
- import * as t from "io-ts";
4
- import BooleanContent from "./nestable/BooleanContent";
5
- import EmbedContent from "./nestable/EmbedContent";
6
- import FieldContent from "./nestable/FieldContent";
7
- import { GeoPointContent } from "./nestable/GeoPointContent";
8
- import { ImageContent } from "./nestable/ImageContent";
9
- import IntegrationFieldsContent from "./nestable/IntegrationFieldsContent";
10
- import { LinkContent } from "./nestable/Link";
11
- import { StructuredTextContent } from "./nestable/StructuredTextContent";
12
- import { UIDContent } from "./UIDContent";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SimpleWidgetContent = exports.is = exports.SimpleWidgetContentType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const function_1 = require("fp-ts/function");
6
+ const O = (0, tslib_1.__importStar)(require("fp-ts/Option"));
7
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
8
+ const BooleanContent_1 = (0, tslib_1.__importDefault)(require("./nestable/BooleanContent"));
9
+ const EmbedContent_1 = (0, tslib_1.__importDefault)(require("./nestable/EmbedContent"));
10
+ const FieldContent_1 = (0, tslib_1.__importDefault)(require("./nestable/FieldContent"));
11
+ const GeoPointContent_1 = require("./nestable/GeoPointContent");
12
+ const ImageContent_1 = require("./nestable/ImageContent");
13
+ const IntegrationFieldsContent_1 = (0, tslib_1.__importDefault)(require("./nestable/IntegrationFieldsContent"));
14
+ const Link_1 = require("./nestable/Link");
15
+ const StructuredTextContent_1 = require("./nestable/StructuredTextContent");
16
+ const UIDContent_1 = require("./UIDContent");
13
17
  //TODO: rework that using import such as EmptyContentType
14
- export const SimpleWidgetContentType = [
18
+ exports.SimpleWidgetContentType = [
15
19
  "EmptyContent",
16
20
  "ImageContent",
17
21
  "GeoPointContent",
@@ -24,14 +28,15 @@ export const SimpleWidgetContentType = [
24
28
  "SeparatorContent",
25
29
  "FieldContent",
26
30
  ];
27
- export function is(value) {
31
+ function is(value) {
28
32
  const asSwc = value;
29
- return SimpleWidgetContentType.includes(asSwc.__TYPE__);
33
+ return exports.SimpleWidgetContentType.includes(asSwc.__TYPE__);
30
34
  }
35
+ exports.is = is;
31
36
  const valueNullCodec = t.type({
32
37
  value: t.null,
33
38
  });
34
- export const SimpleWidgetContent = {
39
+ exports.SimpleWidgetContent = {
35
40
  from: (type, content) => {
36
41
  if (content === null || valueNullCodec.is(content)) {
37
42
  const result = { type: type, __TYPE__: "EmptyContent" };
@@ -39,26 +44,26 @@ export const SimpleWidgetContent = {
39
44
  }
40
45
  switch (type) {
41
46
  case "StructuredText":
42
- return O.fromEither(StructuredTextContent.decode(content));
47
+ return O.fromEither(StructuredTextContent_1.StructuredTextContent.decode(content));
43
48
  case "IntegrationFields":
44
- return O.fromEither(IntegrationFieldsContent.decode(content));
49
+ return O.fromEither(IntegrationFieldsContent_1.default.decode(content));
45
50
  case "Image":
46
- return pipe(O.fromEither(ImageContent.decode(content)), O.map((imageContent) => ImageContent.encode(imageContent)));
51
+ return (0, function_1.pipe)(O.fromEither(ImageContent_1.ImageContent.decode(content)), O.map((imageContent) => ImageContent_1.ImageContent.encode(imageContent)));
47
52
  case "GeoPoint":
48
- return pipe(O.fromEither(GeoPointContent.decode(content)), O.map((geopointContent) => GeoPointContent.encode(geopointContent)));
53
+ return (0, function_1.pipe)(O.fromEither(GeoPointContent_1.GeoPointContent.decode(content)), O.map((geopointContent) => GeoPointContent_1.GeoPointContent.encode(geopointContent)));
49
54
  case "Embed":
50
- return O.fromEither(EmbedContent.decode(content));
55
+ return O.fromEither(EmbedContent_1.default.decode(content));
51
56
  case "Link":
52
- return O.fromEither(LinkContent.decode(content));
57
+ return O.fromEither(Link_1.LinkContent.decode(content));
53
58
  case "UID":
54
- return O.fromEither(UIDContent.decode(content));
59
+ return O.fromEither(UIDContent_1.UIDContent.decode(content));
55
60
  case "Separator":
56
61
  return O.some({ __TYPE__: "SeparatorContent" });
57
62
  case "Boolean":
58
- return O.fromEither(BooleanContent.decode(content));
63
+ return O.fromEither(BooleanContent_1.default.decode(content));
59
64
  default:
60
- if (FieldContent.types.includes(type)) {
61
- return FieldContent.forType(type, content);
65
+ if (FieldContent_1.default.types.includes(type)) {
66
+ return FieldContent_1.default.forType(type, content);
62
67
  }
63
68
  else {
64
69
  return O.none;
@@ -66,5 +71,5 @@ export const SimpleWidgetContent = {
66
71
  }
67
72
  },
68
73
  //TODO: rework that
69
- is: (value) => SimpleWidgetContentType.includes(value.__TYPE__),
74
+ is: (value) => exports.SimpleWidgetContentType.includes(value.__TYPE__),
70
75
  };
@@ -1,23 +1,26 @@
1
- import * as O from "fp-ts/Option";
2
- import { GroupContent, GroupContentType } from "./GroupContent";
3
- import { SimpleWidgetContent, } from "./SimpleWidgetContent";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const O = (0, tslib_1.__importStar)(require("fp-ts/Option"));
5
+ const GroupContent_1 = require("./GroupContent");
6
+ const SimpleWidgetContent_1 = require("./SimpleWidgetContent");
4
7
  const StaticWidgetContent = {
5
8
  fromJson: (prefixes, key, value, fieldTypes, fieldPositions) => {
6
9
  const prefixedKey = Array.of(prefixes, [key]).flat().join(".");
7
10
  const type = fieldTypes.get(prefixedKey);
8
11
  if (type === "Group") {
9
- return GroupContent.fromJson(prefixes, key, value, fieldTypes, fieldPositions);
12
+ return GroupContent_1.GroupContent.fromJson(prefixes, key, value, fieldTypes, fieldPositions);
10
13
  }
11
14
  else if (type) {
12
- return SimpleWidgetContent.from(type, value);
15
+ return SimpleWidgetContent_1.SimpleWidgetContent.from(type, value);
13
16
  }
14
17
  else {
15
18
  return O.none;
16
19
  }
17
20
  },
18
21
  is: (value) => {
19
- return (SimpleWidgetContent.is(value) ||
20
- GroupContentType === value.__TYPE__);
22
+ return (SimpleWidgetContent_1.SimpleWidgetContent.is(value) ||
23
+ GroupContent_1.GroupContentType === value.__TYPE__);
21
24
  },
22
25
  };
23
- export default StaticWidgetContent;
26
+ exports.default = StaticWidgetContent;
@@ -1,6 +1,10 @@
1
- import { Chain } from "fp-ts/Either";
2
- import * as t from "io-ts";
3
- export const UIDContentType = "UIDContent";
4
- export const UIDContent = new t.Type("UIDContent", (u) => u?.__TYPE__ === UIDContentType, (u, c) => Chain.chain(t.string.validate(u, c), (u) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UIDContent = exports.UIDContentType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const Either_1 = require("fp-ts/Either");
6
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
7
+ exports.UIDContentType = "UIDContent";
8
+ exports.UIDContent = new t.Type("UIDContent", (u) => u?.__TYPE__ === exports.UIDContentType, (u, c) => Either_1.Chain.chain(t.string.validate(u, c), (u) => {
5
9
  return t.success({ value: u, __TYPE__: "UIDContent" });
6
10
  }), (uidContent) => uidContent.value);
@@ -1,31 +1,36 @@
1
- import { EmptyContentType } from "./EmptyContent";
2
- import { GroupContentType } from "./GroupContent";
3
- import { NestableTypes } from "./nestable";
4
- import { SlicesContent, SlicesContentType } from "./slices/SlicesContent";
5
- import StaticWidgetContent from "./StaticWidgetContent";
6
- import { UIDContentType } from "./UIDContent";
7
- export * from "./EmptyContent";
8
- export * from "./GroupContent";
9
- export * as Nestable from "./nestable";
10
- export * from "./SimpleWidgetContent";
11
- export * as Slices from "./slices";
12
- export { default as StaticWidgetContent, } from "./StaticWidgetContent";
13
- export * from "./UIDContent";
14
- export const WidgetTypes = {
15
- ...NestableTypes,
16
- Empty: EmptyContentType,
17
- UID: UIDContentType,
18
- Group: GroupContentType,
19
- slices: SlicesContentType,
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Widget = exports.WidgetTypes = exports.StaticWidgetContent = exports.Slices = exports.Nestable = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const EmptyContent_1 = require("./EmptyContent");
6
+ const GroupContent_1 = require("./GroupContent");
7
+ const nestable_1 = require("./nestable");
8
+ const SlicesContent_1 = require("./slices/SlicesContent");
9
+ const StaticWidgetContent_1 = (0, tslib_1.__importDefault)(require("./StaticWidgetContent"));
10
+ const UIDContent_1 = require("./UIDContent");
11
+ (0, tslib_1.__exportStar)(require("./EmptyContent"), exports);
12
+ (0, tslib_1.__exportStar)(require("./GroupContent"), exports);
13
+ exports.Nestable = (0, tslib_1.__importStar)(require("./nestable"));
14
+ (0, tslib_1.__exportStar)(require("./SimpleWidgetContent"), exports);
15
+ exports.Slices = (0, tslib_1.__importStar)(require("./slices"));
16
+ var StaticWidgetContent_2 = require("./StaticWidgetContent");
17
+ Object.defineProperty(exports, "StaticWidgetContent", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(StaticWidgetContent_2).default; } });
18
+ (0, tslib_1.__exportStar)(require("./UIDContent"), exports);
19
+ exports.WidgetTypes = {
20
+ ...nestable_1.NestableTypes,
21
+ Empty: EmptyContent_1.EmptyContentType,
22
+ UID: UIDContent_1.UIDContentType,
23
+ Group: GroupContent_1.GroupContentType,
24
+ slices: SlicesContent_1.SlicesContentType,
20
25
  };
21
- export const Widget = {
26
+ exports.Widget = {
22
27
  fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions) {
23
28
  const fieldType = widgetTypes.get(widgetKey);
24
29
  if (fieldType === "Slices") {
25
- return SlicesContent.fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions);
30
+ return SlicesContent_1.SlicesContent.fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions);
26
31
  }
27
32
  else {
28
- return StaticWidgetContent.fromJson([], widgetKey, widgetValue, widgetTypes, widgetPositions);
33
+ return StaticWidgetContent_1.default.fromJson([], widgetKey, widgetValue, widgetTypes, widgetPositions);
29
34
  }
30
35
  },
31
36
  };