@prismicio/types-internal 0.2.2 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/lib/customtypes/CustomType.d.ts +4 -21
  2. package/lib/customtypes/CustomType.js +38 -27
  3. package/lib/customtypes/Format.js +5 -2
  4. package/lib/customtypes/Section.d.ts +4 -31
  5. package/lib/customtypes/Section.js +14 -9
  6. package/lib/customtypes/index.js +9 -4
  7. package/lib/customtypes/widgets/Group.js +12 -9
  8. package/lib/customtypes/widgets/UID.js +10 -7
  9. package/lib/customtypes/widgets/Widget.d.ts +4 -31
  10. package/lib/customtypes/widgets/Widget.js +19 -14
  11. package/lib/customtypes/widgets/WidgetTypes.js +3 -1
  12. package/lib/customtypes/widgets/index.js +14 -7
  13. package/lib/customtypes/widgets/nestable/BooleanField.js +9 -6
  14. package/lib/customtypes/widgets/nestable/Color.js +10 -7
  15. package/lib/customtypes/widgets/nestable/Date.js +10 -7
  16. package/lib/customtypes/widgets/nestable/Embed.js +10 -7
  17. package/lib/customtypes/widgets/nestable/GeoPoint.js +10 -7
  18. package/lib/customtypes/widgets/nestable/Image.js +13 -10
  19. package/lib/customtypes/widgets/nestable/IntegrationField.js +10 -7
  20. package/lib/customtypes/widgets/nestable/Link.js +14 -11
  21. package/lib/customtypes/widgets/nestable/NestableWidget.js +35 -32
  22. package/lib/customtypes/widgets/nestable/Number.js +14 -11
  23. package/lib/customtypes/widgets/nestable/Range.js +14 -11
  24. package/lib/customtypes/widgets/nestable/RichText.d.ts +22 -3
  25. package/lib/customtypes/widgets/nestable/RichText.js +78 -35
  26. package/lib/customtypes/widgets/nestable/Select.js +11 -8
  27. package/lib/customtypes/widgets/nestable/Separator.js +9 -6
  28. package/lib/customtypes/widgets/nestable/Text.js +10 -7
  29. package/lib/customtypes/widgets/nestable/Timestamp.js +10 -7
  30. package/lib/customtypes/widgets/nestable/index.d.ts +2 -1
  31. package/lib/customtypes/widgets/nestable/index.js +35 -15
  32. package/lib/customtypes/widgets/shared/ImageConstraint.js +12 -9
  33. package/lib/customtypes/widgets/shared/index.js +8 -1
  34. package/lib/customtypes/widgets/slices/CompositeSlice.js +13 -10
  35. package/lib/customtypes/widgets/slices/LegacySlice.d.ts +1 -10
  36. package/lib/customtypes/widgets/slices/LegacySlice.js +8 -6
  37. package/lib/customtypes/widgets/slices/SharedSlice.d.ts +327 -3
  38. package/lib/customtypes/widgets/slices/SharedSlice.js +15 -12
  39. package/lib/customtypes/widgets/slices/SharedSliceRef.js +7 -4
  40. package/lib/customtypes/widgets/slices/Slice.d.ts +1 -1
  41. package/lib/customtypes/widgets/slices/Slice.js +2 -1
  42. package/lib/customtypes/widgets/slices/Slices.d.ts +7 -61
  43. package/lib/customtypes/widgets/slices/Slices.js +33 -27
  44. package/lib/customtypes/widgets/slices/SlicesTypes.js +3 -1
  45. package/lib/customtypes/widgets/slices/index.d.ts +1 -1
  46. package/lib/customtypes/widgets/slices/index.js +15 -7
  47. package/lib/documents/DocumentData.js +7 -4
  48. package/lib/documents/index.js +7 -2
  49. package/lib/documents/widgets/EmptyContent.js +6 -3
  50. package/lib/documents/widgets/GroupContent.js +14 -10
  51. package/lib/documents/widgets/SimpleWidgetContent.d.ts +2 -2
  52. package/lib/documents/widgets/SimpleWidgetContent.js +32 -27
  53. package/lib/documents/widgets/StaticWidgetContent.js +11 -8
  54. package/lib/documents/widgets/UIDContent.js +8 -4
  55. package/lib/documents/widgets/index.d.ts +18 -18
  56. package/lib/documents/widgets/index.js +27 -22
  57. package/lib/documents/widgets/nestable/BooleanContent.js +10 -6
  58. package/lib/documents/widgets/nestable/EmbedContent.d.ts +6 -3
  59. package/lib/documents/widgets/nestable/EmbedContent.js +23 -20
  60. package/lib/documents/widgets/nestable/FieldContent.d.ts +3 -2
  61. package/lib/documents/widgets/nestable/FieldContent.js +10 -6
  62. package/lib/documents/widgets/nestable/GeoPointContent.js +9 -5
  63. package/lib/documents/widgets/nestable/ImageContent.js +16 -12
  64. package/lib/documents/widgets/nestable/IntegrationFieldsContent.js +10 -6
  65. package/lib/documents/widgets/nestable/Link/DocumentLink.js +12 -7
  66. package/lib/documents/widgets/nestable/Link/ExternalLink.js +15 -10
  67. package/lib/documents/widgets/nestable/Link/FileLink.js +15 -10
  68. package/lib/documents/widgets/nestable/Link/ImageLink.js +14 -9
  69. package/lib/documents/widgets/nestable/Link/LinkContent.js +13 -9
  70. package/lib/documents/widgets/nestable/Link/index.d.ts +5 -5
  71. package/lib/documents/widgets/nestable/Link/index.js +33 -24
  72. package/lib/documents/widgets/nestable/SeparatorContent.js +5 -2
  73. package/lib/documents/widgets/nestable/StructuredTextContent/Block.d.ts +2 -3
  74. package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +39 -33
  75. package/lib/documents/widgets/nestable/StructuredTextContent/index.js +11 -7
  76. package/lib/documents/widgets/nestable/index.d.ts +15 -15
  77. package/lib/documents/widgets/nestable/index.js +38 -28
  78. package/lib/documents/widgets/slices/CompositeSliceContent.js +13 -9
  79. package/lib/documents/widgets/slices/SharedSliceContent.js +16 -12
  80. package/lib/documents/widgets/slices/SimpleSliceContent.js +6 -2
  81. package/lib/documents/widgets/slices/SliceWidgetContent.js +12 -8
  82. package/lib/documents/widgets/slices/SlicesContent.js +17 -13
  83. package/lib/documents/widgets/slices/index.js +8 -5
  84. package/lib/index.js +7 -3
  85. package/lib/validators/DateFromString.js +7 -4
  86. package/lib/validators/DateFromStringOrNumber.js +7 -4
  87. package/lib/validators/DateFromTsMs.js +7 -4
  88. package/lib/validators/IntFromNumber.js +7 -4
  89. package/lib/validators/IntFromPixels.js +7 -4
  90. package/lib/validators/NonEmptyString.js +6 -3
  91. package/lib/validators/NonEmptyStringOrNull.js +10 -7
  92. package/lib/validators/NumberOrNull.js +6 -3
  93. package/lib/validators/StringFromBoolean.js +7 -4
  94. package/lib/validators/StringFromNumber.js +7 -4
  95. package/lib/validators/StringOrNull.js +6 -3
  96. package/lib/validators/function.js +28 -15
  97. package/lib/validators/index.js +27 -12
  98. package/package.json +1 -1
  99. package/src/customtypes/CustomType.ts +8 -7
  100. package/src/customtypes/Section.ts +1 -1
  101. package/src/customtypes/widgets/Widget.ts +1 -1
  102. package/src/customtypes/widgets/nestable/NestableWidget.ts +1 -1
  103. package/src/customtypes/widgets/nestable/RichText.ts +64 -24
  104. package/src/customtypes/widgets/nestable/index.ts +2 -1
  105. package/src/customtypes/widgets/slices/LegacySlice.ts +1 -2
  106. package/src/customtypes/widgets/slices/SharedSlice.ts +4 -6
  107. package/src/customtypes/widgets/slices/Slice.ts +1 -1
  108. package/src/customtypes/widgets/slices/Slices.ts +1 -1
  109. package/src/customtypes/widgets/slices/index.ts +1 -1
  110. package/src/documents/widgets/SimpleWidgetContent.ts +4 -4
  111. package/src/documents/widgets/index.ts +1 -1
  112. package/src/documents/widgets/nestable/EmbedContent.ts +8 -6
  113. package/src/documents/widgets/nestable/FieldContent.ts +10 -2
  114. package/src/documents/widgets/nestable/Link/index.ts +1 -1
  115. package/src/documents/widgets/nestable/StructuredTextContent/Block.ts +1 -1
  116. package/src/documents/widgets/nestable/index.ts +2 -2
@@ -1,6 +1,6 @@
1
1
  import { Either } from "fp-ts/lib/Either";
2
2
  import * as t from "io-ts";
3
- import type SharedSlice from "./widgets/slices/SharedSlice";
3
+ import type { SharedSlice } from "./widgets/slices/SharedSlice";
4
4
  import SlicesTypes from "./widgets/slices/SlicesTypes";
5
5
  import type { DynamicWidget } from "./widgets/Widget";
6
6
  import WidgetTypes from "./widgets/WidgetTypes";
@@ -357,16 +357,7 @@ export declare const StaticCustomType: t.ExactC<t.IntersectionC<[t.TypeC<{
357
357
  }>, t.PartialC<{
358
358
  display: t.StringC;
359
359
  }>]>>>>, t.NullC]>;
360
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
361
- type: t.LiteralC<WidgetTypes.UID>;
362
- }>, t.PartialC<{
363
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
364
- config: t.ExactC<t.PartialC<{
365
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
366
- useAsTitle: t.BooleanC;
367
- placeholder: t.StringC;
368
- }>>;
369
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
360
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
370
361
  type: t.LiteralC<WidgetTypes.Color>;
371
362
  }>, t.PartialC<{
372
363
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1700,16 +1691,7 @@ export declare const CustomType: t.ExactC<t.IntersectionC<[t.TypeC<{
1700
1691
  }>, t.PartialC<{
1701
1692
  display: t.StringC;
1702
1693
  }>]>>>>, t.NullC]>;
1703
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1704
- type: t.LiteralC<WidgetTypes.UID>;
1705
- }>, t.PartialC<{
1706
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1707
- config: t.ExactC<t.PartialC<{
1708
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1709
- useAsTitle: t.BooleanC;
1710
- placeholder: t.StringC;
1711
- }>>;
1712
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1694
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1713
1695
  type: t.LiteralC<WidgetTypes.Color>;
1714
1696
  }>, t.PartialC<{
1715
1697
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -2696,6 +2678,7 @@ export declare const CustomType: t.ExactC<t.IntersectionC<[t.TypeC<{
2696
2678
  hash: t.StringC;
2697
2679
  }>]>>;
2698
2680
  export declare type CustomType = t.TypeOf<typeof CustomType>;
2681
+ export declare function flattenWidgets(customType: CustomType): Array<[string, DynamicWidget]>;
2699
2682
  export declare function toStatic(customType: CustomType, sharedSlices: Map<string, SharedSlice>): StaticCustomType;
2700
2683
  export declare function validateSlices(customType: CustomType, sharedSlices: Map<string, SharedSlice>): Either<CustomTypeSlicesError, CustomType>;
2701
2684
  export declare function collectWidgets(customType: CustomType, f: (ref: string, widget: DynamicWidget) => DynamicWidget | undefined): CustomType;
@@ -1,11 +1,15 @@
1
- import { left, right } from "fp-ts/lib/Either";
2
- import * as t from "io-ts";
3
- import { withFallback } from "io-ts-types/lib/withFallback";
4
- import { StringOrNull } from "../validators";
5
- import { Format } from "./Format";
6
- import { sectionReader, Sections, } from "./Section";
7
- import SlicesTypes from "./widgets/slices/SlicesTypes";
8
- import WidgetTypes from "./widgets/WidgetTypes";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterMissingSharedSlices = exports.collectWidgets = exports.validateSlices = exports.toStatic = exports.flattenWidgets = exports.CustomType = exports.StaticCustomType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const Either_1 = require("fp-ts/lib/Either");
6
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
7
+ const withFallback_1 = require("io-ts-types/lib/withFallback");
8
+ const validators_1 = require("../validators");
9
+ const Format_1 = require("./Format");
10
+ const Section_1 = require("./Section");
11
+ const SlicesTypes_1 = (0, tslib_1.__importDefault)(require("./widgets/slices/SlicesTypes"));
12
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("./widgets/WidgetTypes"));
9
13
  class CustomTypeSlicesError extends Error {
10
14
  constructor(slices) {
11
15
  super();
@@ -35,29 +39,32 @@ function customTypeReader(format) {
35
39
  return t.exact(t.intersection([
36
40
  t.type({
37
41
  id: t.string,
38
- label: StringOrNull,
39
- repeatable: withFallback(t.boolean, true),
40
- json: t.record(t.string, sectionReader(format)),
41
- status: withFallback(t.boolean, true),
42
+ label: validators_1.StringOrNull,
43
+ repeatable: (0, withFallback_1.withFallback)(t.boolean, true),
44
+ json: t.record(t.string, (0, Section_1.sectionReader)(format)),
45
+ status: (0, withFallback_1.withFallback)(t.boolean, true),
42
46
  }),
43
47
  t.partial({
44
48
  hash: t.string,
45
49
  }),
46
50
  ]));
47
51
  }
48
- export const StaticCustomType = customTypeReader(Format.Static);
49
- export const CustomType = customTypeReader(Format.Dynamic);
50
- function _retrieveSharedSlicesRef(customType) {
51
- const flattenWidgets = Object.entries(customType.json).reduce((acc, [, section]) => {
52
+ exports.StaticCustomType = customTypeReader(Format_1.Format.Static);
53
+ exports.CustomType = customTypeReader(Format_1.Format.Dynamic);
54
+ function flattenWidgets(customType) {
55
+ return Object.entries(customType.json).reduce((acc, [, section]) => {
52
56
  const sectionWidgets = Object.entries(section);
53
57
  return acc.concat(sectionWidgets);
54
58
  }, []);
55
- const slicezones = flattenWidgets.filter(([, widget]) => widget.type === WidgetTypes.Slices);
59
+ }
60
+ exports.flattenWidgets = flattenWidgets;
61
+ function _retrieveSharedSlicesRef(customType) {
62
+ const slicezones = flattenWidgets(customType).filter(([, widget]) => widget.type === WidgetTypes_1.default.Slices);
56
63
  const allSharedRefs = slicezones.reduce((acc, [, slicezone]) => {
57
64
  const sharedRefs = Object.entries(slicezone.config && slicezone.config.choices
58
65
  ? slicezone.config.choices
59
66
  : {})
60
- .filter(([, slice]) => slice.type === SlicesTypes.SharedSlice)
67
+ .filter(([, slice]) => slice.type === SlicesTypes_1.default.SharedSlice)
61
68
  .map(([key]) => key);
62
69
  return acc.concat(sharedRefs);
63
70
  }, []);
@@ -69,16 +76,17 @@ function _mapSharedSlicesRefs(customType) {
69
76
  return refs.map(mapFn);
70
77
  };
71
78
  }
72
- export function toStatic(customType, sharedSlices) {
79
+ function toStatic(customType, sharedSlices) {
73
80
  const json = Object.entries(customType.json).reduce((acc, [sectionKey, dynSection]) => {
74
81
  return {
75
82
  ...acc,
76
- [sectionKey]: Sections.toStatic(dynSection, sharedSlices),
83
+ [sectionKey]: Section_1.Sections.toStatic(dynSection, sharedSlices),
77
84
  };
78
85
  }, {});
79
86
  return { ...customType, json };
80
87
  }
81
- export function validateSlices(customType, sharedSlices) {
88
+ exports.toStatic = toStatic;
89
+ function validateSlices(customType, sharedSlices) {
82
90
  const missingSlices = _mapSharedSlicesRefs(customType)((ref) => {
83
91
  const slice = sharedSlices.get(ref);
84
92
  const isMissing = !slice;
@@ -87,11 +95,12 @@ export function validateSlices(customType, sharedSlices) {
87
95
  return;
88
96
  }).filter(Boolean);
89
97
  if (missingSlices.length > 0)
90
- return left(new CustomTypeSlicesError(missingSlices));
98
+ return (0, Either_1.left)(new CustomTypeSlicesError(missingSlices));
91
99
  else
92
- return right(customType);
100
+ return (0, Either_1.right)(customType);
93
101
  }
94
- export function collectWidgets(customType, f) {
102
+ exports.validateSlices = validateSlices;
103
+ function collectWidgets(customType, f) {
95
104
  const json = Object.entries(customType.json).reduce((acc, [sectionId, section]) => {
96
105
  const updatedSection = Object.entries(section).reduce((acc, [ref, widget]) => {
97
106
  const updatedWidget = f(ref, widget);
@@ -104,13 +113,14 @@ export function collectWidgets(customType, f) {
104
113
  }, {});
105
114
  return { ...customType, json };
106
115
  }
107
- export function filterMissingSharedSlices(customType, sharedSlices) {
116
+ exports.collectWidgets = collectWidgets;
117
+ function filterMissingSharedSlices(customType, sharedSlices) {
108
118
  return collectWidgets(customType, (_widgetId, widget) => {
109
- if (widget.type === WidgetTypes.Slices) {
119
+ if (widget.type === WidgetTypes_1.default.Slices) {
110
120
  if (!widget.config || !widget.config.choices)
111
121
  return widget;
112
122
  const choices = Object.entries(widget.config.choices).reduce((acc, [sliceId, sliceValue]) => {
113
- if (sliceValue.type === SlicesTypes.SharedSlice &&
123
+ if (sliceValue.type === SlicesTypes_1.default.SharedSlice &&
114
124
  !sharedSlices.get(sliceId))
115
125
  return acc;
116
126
  return { ...acc, [sliceId]: sliceValue };
@@ -121,3 +131,4 @@ export function filterMissingSharedSlices(customType, sharedSlices) {
121
131
  return widget;
122
132
  });
123
133
  }
134
+ exports.filterMissingSharedSlices = filterMissingSharedSlices;
@@ -1,5 +1,8 @@
1
- export var Format;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Format = void 0;
4
+ var Format;
2
5
  (function (Format) {
3
6
  Format["Static"] = "static";
4
7
  Format["Dynamic"] = "dynamic";
5
- })(Format || (Format = {}));
8
+ })(Format = exports.Format || (exports.Format = {}));
@@ -1,6 +1,6 @@
1
1
  import * as t from "io-ts";
2
2
  import { Format } from "./Format";
3
- import type SharedSlice from "./widgets/slices/SharedSlice";
3
+ import type { SharedSlice } from "./widgets/slices/SharedSlice";
4
4
  export declare function sectionReader<F extends Format>(format: F): t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
5
5
  type: t.LiteralC<import("./widgets/WidgetTypes").default.UID>;
6
6
  }>, t.PartialC<{
@@ -344,16 +344,7 @@ export declare function sectionReader<F extends Format>(format: F): t.RecordC<t.
344
344
  }>, t.PartialC<{
345
345
  display: t.StringC;
346
346
  }>]>>>>, t.NullC]>;
347
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
348
- type: t.LiteralC<import("./widgets/WidgetTypes").default.UID>;
349
- }>, t.PartialC<{
350
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
351
- config: t.ExactC<t.PartialC<{
352
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
353
- useAsTitle: t.BooleanC;
354
- placeholder: t.StringC;
355
- }>>;
356
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
347
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
357
348
  type: t.LiteralC<import("./widgets/WidgetTypes").default.Color>;
358
349
  }>, t.PartialC<{
359
350
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1678,16 +1669,7 @@ export declare const StaticSection: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.In
1678
1669
  }>, t.PartialC<{
1679
1670
  display: t.StringC;
1680
1671
  }>]>>>>, t.NullC]>;
1681
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1682
- type: t.LiteralC<import("./widgets/WidgetTypes").default.UID>;
1683
- }>, t.PartialC<{
1684
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1685
- config: t.ExactC<t.PartialC<{
1686
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1687
- useAsTitle: t.BooleanC;
1688
- placeholder: t.StringC;
1689
- }>>;
1690
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1672
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1691
1673
  type: t.LiteralC<import("./widgets/WidgetTypes").default.Color>;
1692
1674
  }>, t.PartialC<{
1693
1675
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -3013,16 +2995,7 @@ export declare const DynamicSection: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.I
3013
2995
  }>, t.PartialC<{
3014
2996
  display: t.StringC;
3015
2997
  }>]>>>>, t.NullC]>;
3016
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
3017
- type: t.LiteralC<import("./widgets/WidgetTypes").default.UID>;
3018
- }>, t.PartialC<{
3019
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
3020
- config: t.ExactC<t.PartialC<{
3021
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
3022
- useAsTitle: t.BooleanC;
3023
- placeholder: t.StringC;
3024
- }>>;
3025
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
2998
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
3026
2999
  type: t.LiteralC<import("./widgets/WidgetTypes").default.Color>;
3027
3000
  }>, t.PartialC<{
3028
3001
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1,15 +1,20 @@
1
- import * as t from "io-ts";
2
- import { Format } from "./Format";
3
- import { widgetReader, Widgets, } from "./widgets/Widget";
4
- export function sectionReader(format) {
5
- return t.record(t.string, widgetReader(format));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Sections = exports.DynamicSection = exports.StaticSection = exports.sectionReader = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const Format_1 = require("./Format");
7
+ const Widget_1 = require("./widgets/Widget");
8
+ function sectionReader(format) {
9
+ return t.record(t.string, (0, Widget_1.widgetReader)(format));
6
10
  }
7
- export const StaticSection = sectionReader(Format.Static);
8
- export const DynamicSection = sectionReader(Format.Dynamic);
9
- export const Sections = {
11
+ exports.sectionReader = sectionReader;
12
+ exports.StaticSection = sectionReader(Format_1.Format.Static);
13
+ exports.DynamicSection = sectionReader(Format_1.Format.Dynamic);
14
+ exports.Sections = {
10
15
  toStatic(dynamic, sharedSlices) {
11
16
  const section = Object.entries(dynamic).reduce((acc, [widgetKey, widget]) => {
12
- return { ...acc, [widgetKey]: Widgets.toStatic(widget, sharedSlices) };
17
+ return { ...acc, [widgetKey]: Widget_1.Widgets.toStatic(widget, sharedSlices) };
13
18
  }, {});
14
19
  return section;
15
20
  },
@@ -1,4 +1,9 @@
1
- export * from "./CustomType";
2
- export { Format } from "./Format";
3
- export * as Section from "./Section";
4
- export * as Widgets from "./widgets";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Widgets = exports.Section = exports.Format = void 0;
4
+ const tslib_1 = require("tslib");
5
+ (0, tslib_1.__exportStar)(require("./CustomType"), exports);
6
+ var Format_1 = require("./Format");
7
+ Object.defineProperty(exports, "Format", { enumerable: true, get: function () { return Format_1.Format; } });
8
+ exports.Section = (0, tslib_1.__importStar)(require("./Section"));
9
+ exports.Widgets = (0, tslib_1.__importStar)(require("./widgets"));
@@ -1,21 +1,24 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../validators";
3
- import NestableWidget from "./nestable/NestableWidget";
4
- import WidgetTypes from "./WidgetTypes";
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 validators_1 = require("../../validators");
6
+ const NestableWidget_1 = (0, tslib_1.__importDefault)(require("./nestable/NestableWidget"));
7
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("./WidgetTypes"));
5
8
  const GroupConfig = t.exact(t.partial({
6
- label: StringOrNull,
9
+ label: validators_1.StringOrNull,
7
10
  repeat: t.boolean,
8
- fields: t.record(t.string, NestableWidget),
11
+ fields: t.record(t.string, NestableWidget_1.default),
9
12
  }));
10
13
  const Group = t.exact(t.intersection([
11
14
  t.type({
12
- type: t.literal(WidgetTypes.Group),
15
+ type: t.literal(WidgetTypes_1.default.Group),
13
16
  }),
14
17
  t.partial({
15
- fieldset: StringOrNull,
18
+ fieldset: validators_1.StringOrNull,
16
19
  icon: t.string,
17
20
  description: t.string,
18
21
  config: GroupConfig,
19
22
  }),
20
23
  ]));
21
- export default Group;
24
+ exports.default = Group;
@@ -1,18 +1,21 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../validators";
3
- import WidgetTypes from "./WidgetTypes";
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 validators_1 = require("../../validators");
6
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("./WidgetTypes"));
4
7
  const UIDConfig = t.exact(t.partial({
5
- label: StringOrNull,
8
+ label: validators_1.StringOrNull,
6
9
  useAsTitle: t.boolean,
7
10
  placeholder: t.string,
8
11
  }));
9
12
  const UID = t.exact(t.intersection([
10
13
  t.type({
11
- type: t.literal(WidgetTypes.UID),
14
+ type: t.literal(WidgetTypes_1.default.UID),
12
15
  }),
13
16
  t.partial({
14
- fieldset: StringOrNull,
17
+ fieldset: validators_1.StringOrNull,
15
18
  config: UIDConfig,
16
19
  }),
17
20
  ]));
18
- export default UID;
21
+ exports.default = UID;
@@ -1,6 +1,6 @@
1
1
  import * as t from "io-ts";
2
2
  import { Format } from "../Format";
3
- import type SharedSlice from "./slices/SharedSlice";
3
+ import type { SharedSlice } from "./slices/SharedSlice";
4
4
  import WidgetTypes from "./WidgetTypes";
5
5
  export declare function widgetReader<F extends Format>(format: F): t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
6
6
  type: t.LiteralC<WidgetTypes.UID>;
@@ -345,16 +345,7 @@ export declare function widgetReader<F extends Format>(format: F): t.UnionC<[t.E
345
345
  }>, t.PartialC<{
346
346
  display: t.StringC;
347
347
  }>]>>>>, t.NullC]>;
348
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
349
- type: t.LiteralC<WidgetTypes.UID>;
350
- }>, t.PartialC<{
351
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
352
- config: t.ExactC<t.PartialC<{
353
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
354
- useAsTitle: t.BooleanC;
355
- placeholder: t.StringC;
356
- }>>;
357
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
348
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
358
349
  type: t.LiteralC<WidgetTypes.Color>;
359
350
  }>, t.PartialC<{
360
351
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1679,16 +1670,7 @@ export declare const StaticWidget: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1679
1670
  }>, t.PartialC<{
1680
1671
  display: t.StringC;
1681
1672
  }>]>>>>, t.NullC]>;
1682
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1683
- type: t.LiteralC<WidgetTypes.UID>;
1684
- }>, t.PartialC<{
1685
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1686
- config: t.ExactC<t.PartialC<{
1687
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1688
- useAsTitle: t.BooleanC;
1689
- placeholder: t.StringC;
1690
- }>>;
1691
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1673
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1692
1674
  type: t.LiteralC<WidgetTypes.Color>;
1693
1675
  }>, t.PartialC<{
1694
1676
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -3014,16 +2996,7 @@ export declare const DynamicWidget: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<
3014
2996
  }>, t.PartialC<{
3015
2997
  display: t.StringC;
3016
2998
  }>]>>>>, t.NullC]>;
3017
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
3018
- type: t.LiteralC<WidgetTypes.UID>;
3019
- }>, t.PartialC<{
3020
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
3021
- config: t.ExactC<t.PartialC<{
3022
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
3023
- useAsTitle: t.BooleanC;
3024
- placeholder: t.StringC;
3025
- }>>;
3026
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
2999
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
3027
3000
  type: t.LiteralC<WidgetTypes.Color>;
3028
3001
  }>, t.PartialC<{
3029
3002
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1,20 +1,25 @@
1
- import * as t from "io-ts";
2
- import { Format } from "../Format";
3
- import Group from "./Group";
4
- import NestableWidget from "./nestable/NestableWidget";
5
- import { Slices, slicesReader } from "./slices/Slices";
6
- import UID from "./UID";
7
- import WidgetTypes from "./WidgetTypes";
8
- export function widgetReader(format) {
9
- return t.union([UID, NestableWidget, Group, slicesReader(format)]);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Widgets = exports.DynamicWidget = exports.StaticWidget = exports.widgetReader = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const Format_1 = require("../Format");
7
+ const Group_1 = (0, tslib_1.__importDefault)(require("./Group"));
8
+ const NestableWidget_1 = (0, tslib_1.__importDefault)(require("./nestable/NestableWidget"));
9
+ const Slices_1 = require("./slices/Slices");
10
+ const UID_1 = (0, tslib_1.__importDefault)(require("./UID"));
11
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("./WidgetTypes"));
12
+ function widgetReader(format) {
13
+ return t.union([UID_1.default, NestableWidget_1.default, Group_1.default, (0, Slices_1.slicesReader)(format)]);
10
14
  }
11
- export const StaticWidget = widgetReader(Format.Static);
12
- export const DynamicWidget = widgetReader(Format.Dynamic);
13
- export const Widgets = {
15
+ exports.widgetReader = widgetReader;
16
+ exports.StaticWidget = widgetReader(Format_1.Format.Static);
17
+ exports.DynamicWidget = widgetReader(Format_1.Format.Dynamic);
18
+ exports.Widgets = {
14
19
  toStatic(widget, sharedSlices) {
15
20
  switch (widget.type) {
16
- case WidgetTypes.Slices:
17
- return Slices.toStatic(widget, sharedSlices);
21
+ case WidgetTypes_1.default.Slices:
22
+ return Slices_1.Slices.toStatic(widget, sharedSlices);
18
23
  default:
19
24
  return widget;
20
25
  }
@@ -1,3 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  var WidgetTypes;
2
4
  (function (WidgetTypes) {
3
5
  WidgetTypes["Text"] = "Text";
@@ -21,4 +23,4 @@ var WidgetTypes;
21
23
  // Legacy type for slices
22
24
  WidgetTypes["LegacySlices"] = "Choice";
23
25
  })(WidgetTypes || (WidgetTypes = {}));
24
- export default WidgetTypes;
26
+ exports.default = WidgetTypes;
@@ -1,7 +1,14 @@
1
- export { default as Group } from "./Group";
2
- export * as Nestable from "./nestable";
3
- export * as Shared from "./shared";
4
- export * as Slices from "./slices";
5
- export { default as UID } from "./UID";
6
- export * as Widget from "./Widget";
7
- export { default as WidgetTypes } from "./WidgetTypes";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WidgetTypes = exports.Widget = exports.UID = exports.Slices = exports.Shared = exports.Nestable = exports.Group = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var Group_1 = require("./Group");
6
+ Object.defineProperty(exports, "Group", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(Group_1).default; } });
7
+ exports.Nestable = (0, tslib_1.__importStar)(require("./nestable"));
8
+ exports.Shared = (0, tslib_1.__importStar)(require("./shared"));
9
+ exports.Slices = (0, tslib_1.__importStar)(require("./slices"));
10
+ var UID_1 = require("./UID");
11
+ Object.defineProperty(exports, "UID", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(UID_1).default; } });
12
+ exports.Widget = (0, tslib_1.__importStar)(require("./Widget"));
13
+ var WidgetTypes_1 = require("./WidgetTypes");
14
+ Object.defineProperty(exports, "WidgetTypes", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(WidgetTypes_1).default; } });
@@ -1,18 +1,21 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../../validators";
3
- import WidgetTypes from "../WidgetTypes";
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 validators_1 = require("../../../validators");
6
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
4
7
  const BooleanConfig = t.exact(t.partial({
5
- label: StringOrNull,
8
+ label: validators_1.StringOrNull,
6
9
  default_value: t.boolean,
7
10
  placeholder_true: t.string,
8
11
  placeholder_false: t.string,
9
12
  }));
10
13
  const BooleanField = t.exact(t.intersection([
11
14
  t.type({
12
- type: t.literal(WidgetTypes.BooleanField),
15
+ type: t.literal(WidgetTypes_1.default.BooleanField),
13
16
  }),
14
17
  t.partial({
15
18
  config: BooleanConfig,
16
19
  }),
17
20
  ]));
18
- export default BooleanField;
21
+ exports.default = BooleanField;
@@ -1,17 +1,20 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../../validators";
3
- import WidgetTypes from "../WidgetTypes";
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 validators_1 = require("../../../validators");
6
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
4
7
  const ColorConfig = t.exact(t.partial({
5
- label: StringOrNull,
8
+ label: validators_1.StringOrNull,
6
9
  placeholder: t.string,
7
10
  }));
8
11
  const Color = t.exact(t.intersection([
9
12
  t.type({
10
- type: t.literal(WidgetTypes.Color),
13
+ type: t.literal(WidgetTypes_1.default.Color),
11
14
  }),
12
15
  t.partial({
13
- fieldset: StringOrNull,
16
+ fieldset: validators_1.StringOrNull,
14
17
  config: ColorConfig,
15
18
  }),
16
19
  ]));
17
- export default Color;
20
+ exports.default = Color;
@@ -1,18 +1,21 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../../validators";
3
- import WidgetTypes from "../WidgetTypes";
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 validators_1 = require("../../../validators");
6
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
4
7
  const DateConfig = t.exact(t.partial({
5
- label: StringOrNull,
8
+ label: validators_1.StringOrNull,
6
9
  placeholder: t.string,
7
10
  default: t.string,
8
11
  }));
9
12
  const Date = t.exact(t.intersection([
10
13
  t.type({
11
- type: t.literal(WidgetTypes.Date),
14
+ type: t.literal(WidgetTypes_1.default.Date),
12
15
  }),
13
16
  t.partial({
14
- fieldset: StringOrNull,
17
+ fieldset: validators_1.StringOrNull,
15
18
  config: DateConfig,
16
19
  }),
17
20
  ]));
18
- export default Date;
21
+ exports.default = Date;
@@ -1,18 +1,21 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../../validators";
3
- import WidgetTypes from "../WidgetTypes";
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 validators_1 = require("../../../validators");
6
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
4
7
  const EmbedConfig = t.exact(t.partial({
5
- label: StringOrNull,
8
+ label: validators_1.StringOrNull,
6
9
  placeholder: t.string,
7
10
  useAsTitle: t.boolean,
8
11
  }));
9
12
  const Embed = t.exact(t.intersection([
10
13
  t.type({
11
- type: t.literal(WidgetTypes.Embed),
14
+ type: t.literal(WidgetTypes_1.default.Embed),
12
15
  }),
13
16
  t.partial({
14
- fieldset: StringOrNull,
17
+ fieldset: validators_1.StringOrNull,
15
18
  config: EmbedConfig,
16
19
  }),
17
20
  ]));
18
- export default Embed;
21
+ exports.default = Embed;