@prismicio/types-internal 2.0.0-alpha.3 → 2.0.0-alpha.5

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 (62) hide show
  1. package/lib/content/Document.js +4 -3
  2. package/lib/content/LegacyContentCtx.js +1 -1
  3. package/lib/content/fields/GroupContent.d.ts +1 -1
  4. package/lib/content/fields/GroupContent.js +3 -3
  5. package/lib/content/fields/WidgetContent.d.ts +1 -1
  6. package/lib/content/fields/nestable/EmbedContent.d.ts +0 -1
  7. package/lib/content/fields/nestable/NestableContent.js +2 -1
  8. package/lib/content/fields/nestable/RichTextContent/Blocks.js +4 -4
  9. package/lib/content/fields/slices/Slice/CompositeSliceContent.js +4 -4
  10. package/lib/content/fields/slices/Slice/SharedSliceContent.js +4 -4
  11. package/lib/content/fields/slices/SliceItem.js +2 -1
  12. package/lib/content/utils.js +3 -3
  13. package/lib/customtypes/index.d.ts +2 -2
  14. package/lib/customtypes/index.js +2 -3
  15. package/lib/customtypes/widgets/Group.d.ts +164 -3
  16. package/lib/customtypes/widgets/Group.js +4 -5
  17. package/lib/customtypes/widgets/UID.d.ts +8 -3
  18. package/lib/customtypes/widgets/UID.js +4 -5
  19. package/lib/customtypes/widgets/Widget.d.ts +2 -2
  20. package/lib/customtypes/widgets/Widget.js +5 -5
  21. package/lib/customtypes/widgets/nestable/Link.d.ts +0 -1
  22. package/lib/customtypes/widgets/nestable/Link.js +0 -1
  23. package/lib/customtypes/widgets/nestable/RichText.d.ts +1 -1
  24. package/lib/customtypes/widgets/nestable/RichText.js +10 -10
  25. package/lib/customtypes/widgets/nestable/Text.d.ts +0 -1
  26. package/lib/customtypes/widgets/nestable/Text.js +0 -1
  27. package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +6 -3
  28. package/lib/customtypes/widgets/slices/CompositeSlice.js +4 -5
  29. package/lib/customtypes/widgets/slices/LegacySlice.d.ts +2 -3
  30. package/lib/customtypes/widgets/slices/LegacySlice.js +3 -3
  31. package/lib/customtypes/widgets/slices/SharedSliceRef.d.ts +2 -3
  32. package/lib/customtypes/widgets/slices/SharedSliceRef.js +2 -2
  33. package/lib/customtypes/widgets/slices/Slice.d.ts +3 -3
  34. package/lib/customtypes/widgets/slices/Slices.d.ts +13 -4
  35. package/lib/customtypes/widgets/slices/Slices.js +9 -9
  36. package/lib/customtypes/widgets/slices/index.d.ts +6 -6
  37. package/lib/customtypes/widgets/slices/index.js +6 -11
  38. package/package.json +1 -1
  39. package/src/content/Document.ts +4 -3
  40. package/src/content/LegacyContentCtx.ts +2 -2
  41. package/src/content/fields/GroupContent.ts +4 -4
  42. package/src/content/fields/WidgetContent.ts +1 -1
  43. package/src/content/fields/nestable/EmbedContent.ts +1 -1
  44. package/src/content/fields/nestable/NestableContent.ts +2 -1
  45. package/src/content/fields/nestable/RichTextContent/Blocks.ts +4 -4
  46. package/src/content/fields/slices/Slice/CompositeSliceContent.ts +4 -3
  47. package/src/content/fields/slices/Slice/SharedSliceContent.ts +4 -3
  48. package/src/content/fields/slices/SliceItem.ts +2 -2
  49. package/src/content/utils.ts +4 -5
  50. package/src/customtypes/index.ts +2 -2
  51. package/src/customtypes/widgets/Group.ts +4 -6
  52. package/src/customtypes/widgets/UID.ts +4 -6
  53. package/src/customtypes/widgets/Widget.ts +5 -5
  54. package/src/customtypes/widgets/nestable/Link.ts +0 -2
  55. package/src/customtypes/widgets/nestable/RichText.ts +16 -16
  56. package/src/customtypes/widgets/nestable/Text.ts +0 -2
  57. package/src/customtypes/widgets/slices/CompositeSlice.ts +4 -6
  58. package/src/customtypes/widgets/slices/LegacySlice.ts +3 -5
  59. package/src/customtypes/widgets/slices/SharedSliceRef.ts +2 -4
  60. package/src/customtypes/widgets/slices/Slice.ts +3 -3
  61. package/src/customtypes/widgets/slices/Slices.ts +7 -7
  62. package/src/customtypes/widgets/slices/index.ts +6 -6
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DocumentLegacy = exports.Document = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fp_ts_1 = require("fp-ts");
6
+ const Either_1 = require("fp-ts/lib/Either");
6
7
  const function_1 = require("fp-ts/lib/function");
7
8
  const t = tslib_1.__importStar(require("io-ts"));
8
9
  const common_1 = require("../common");
@@ -16,7 +17,7 @@ const DocumentLegacyCodec = (allTypes) => {
16
17
  return Object.entries(parsedDoc).reduce((acc, [widgetKey, widgetValue]) => {
17
18
  const widgetCtx = (0, LegacyContentCtx_1.defaultCtx)(widgetKey, allTypes);
18
19
  const parsedW = (0, fields_1.WidgetLegacy)(widgetCtx).decode(widgetValue);
19
- if (!parsedW || (parsedW === null || parsedW === void 0 ? void 0 : parsedW._tag) === "Left")
20
+ if (!parsedW || (0, Either_1.isLeft)(parsedW))
20
21
  return acc;
21
22
  return { ...acc, [widgetKey]: parsedW.right };
22
23
  }, {});
@@ -39,7 +40,7 @@ function extractMetadata(data) {
39
40
  const { types, widgets } = fields.reduce((acc, [k, v]) => {
40
41
  if (k.endsWith("_TYPE")) {
41
42
  const decodedValue = LegacyContentCtx_1.FieldOrSliceType.decode(v);
42
- if (decodedValue._tag === "Right") {
43
+ if ((0, Either_1.isRight)(decodedValue)) {
43
44
  return {
44
45
  ...acc,
45
46
  types: acc.types.set(k.substring(0, k.length - 5), decodedValue.right),
@@ -78,7 +79,7 @@ function parseLegacyDocument(legacyDoc) {
78
79
  // parse the actual widgets
79
80
  return DocumentLegacyCodec(types).decode(widgets);
80
81
  }));
81
- return result._tag === "Left" ? undefined : result.right;
82
+ return (0, Either_1.isLeft)(result) ? undefined : result.right;
82
83
  }
83
84
  function encodeToLegacyDocument(document) {
84
85
  const encoded = DocumentLegacyCodec().encode(document);
@@ -4,7 +4,7 @@ exports.defaultCtx = exports.getFieldCtx = exports.LegacyContentCtx = exports.Fi
4
4
  const tslib_1 = require("tslib");
5
5
  const t = tslib_1.__importStar(require("io-ts"));
6
6
  const widgets_1 = require("../customtypes/widgets");
7
- exports.FieldOrSliceType = t.union([widgets_1.FieldTypes, widgets_1.SlicesTypes]);
7
+ exports.FieldOrSliceType = t.union([widgets_1.FieldType, widgets_1.SlicesTypes]);
8
8
  class LegacyContentCtx {
9
9
  constructor(fieldKey, fieldPath, allTypes) {
10
10
  Object.defineProperty(this, "fieldKey", {
@@ -315,7 +315,7 @@ export declare const GroupItemContent: t.ExactC<t.TypeC<{
315
315
  }>>;
316
316
  export type GroupItemContent = t.TypeOf<typeof GroupItemContent>;
317
317
  declare const itemLegacyReader: t.ArrayC<t.TupleC<[t.StringC, t.UnknownC]>>;
318
- export type GroupItemLegacy = t.TypeOf<typeof itemLegacyReader>;
318
+ type GroupItemLegacy = t.TypeOf<typeof itemLegacyReader>;
319
319
  export declare const GroupItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
320
320
  __TYPE__: "GroupItemContent";
321
321
  value: [string, {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GroupContent = exports.isGroupContent = exports.GroupContentType = exports.GroupLegacy = exports.GroupItemLegacy = exports.GroupItemContent = exports.GroupItemContentType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fp_ts_1 = require("fp-ts");
6
+ const Either_1 = require("fp-ts/lib/Either");
6
7
  const function_1 = require("fp-ts/lib/function");
7
8
  const t = tslib_1.__importStar(require("io-ts"));
8
9
  const LegacyContentCtx_1 = require("../LegacyContentCtx");
@@ -22,10 +23,9 @@ const GroupItemLegacy = (ctx) => {
22
23
  const result = (0, nestable_1.NestableLegacy)(itemCtx).decode(itemValue);
23
24
  if (!result)
24
25
  return acc;
25
- if (result._tag === "Right")
26
- return [...acc, [itemKey, result.right]];
27
- else
26
+ if ((0, Either_1.isLeft)(result))
28
27
  return acc;
28
+ return [...acc, [itemKey, result.right]];
29
29
  }, []);
30
30
  return {
31
31
  value: parsedItems,
@@ -4659,7 +4659,7 @@ export declare const isWidgetContent: (u: unknown) => u is {
4659
4659
  value: string;
4660
4660
  };
4661
4661
  export type WidgetContent = t.TypeOf<typeof WidgetContent>;
4662
- export type WidgetTypes = WidgetContent["__TYPE__"];
4662
+ export type ContentType = WidgetContent["__TYPE__"];
4663
4663
  export declare const WidgetLegacy: (ctx: LegacyContentCtx) => {
4664
4664
  decode(value: unknown): import("fp-ts/lib/Either").Left<t.Errors> | import("fp-ts/lib/Either").Right<{
4665
4665
  __TYPE__: "BooleanContent";
@@ -35,7 +35,6 @@ export declare const EmbedContentLegacy: t.ExactC<t.IntersectionC<[t.TypeC<{
35
35
  thumbnail_height: t.UnionC<[t.Type<number, number, unknown>, t.NullC, t.UndefinedC]>;
36
36
  html: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
37
37
  }>]>>;
38
- export type EmbedLegacy = t.TypeOf<typeof EmbedContentLegacy>;
39
38
  export declare const EmbedLegacy: (ctx: LegacyContentCtx) => t.Type<{
40
39
  embed_url: string;
41
40
  type: string;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NestableLegacy = exports.isNestableContent = exports.NestableContent = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const Either_1 = require("fp-ts/lib/Either");
5
6
  const t = tslib_1.__importStar(require("io-ts"));
6
7
  const EmptyContent_1 = require("../EmptyContent");
7
8
  const BooleanContent_1 = require("./BooleanContent");
@@ -54,7 +55,7 @@ const NestableLegacy = (ctx) => {
54
55
  if (!ctx.fieldType)
55
56
  return;
56
57
  const nullValue = (0, EmptyContent_1.EmptyLegacy)(ctx.fieldType).decode(value);
57
- if (nullValue._tag === "Right")
58
+ if ((0, Either_1.isRight)(nullValue))
58
59
  return nullValue;
59
60
  const codec = (() => {
60
61
  switch (ctx.fieldType) {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Block = exports.BlockLegacy = exports.TextBlock = exports.checkEmbedBlock = exports.EmbedBlock = exports.checkImageBlock = exports.ImageBlock = exports.ValidatedMetas = exports.Span = exports.Meta = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fp_ts_1 = require("fp-ts");
6
- const E = tslib_1.__importStar(require("fp-ts/lib/Either"));
6
+ const Either_1 = require("fp-ts/lib/Either");
7
7
  const function_1 = require("fp-ts/lib/function");
8
8
  const t = tslib_1.__importStar(require("io-ts"));
9
9
  const nestable_1 = require("../../../../customtypes/widgets/nestable");
@@ -29,12 +29,12 @@ const ValidatedMetas = (linkCodec) => new t.Type("ValidatedMetas", (metas) => Ar
29
29
  const res = metas
30
30
  .reduce((acc, maybeMeta) => {
31
31
  const maybeDecodedMeta = exports.Meta.decode(maybeMeta);
32
- if (E.isRight(maybeDecodedMeta)) {
32
+ if ((0, Either_1.isRight)(maybeDecodedMeta)) {
33
33
  const meta = maybeDecodedMeta.right;
34
34
  // if it's an hyperlink it should have data validated as link otherwise we don't care and keep the meta
35
35
  if (meta.data && meta.type === "hyperlink") {
36
36
  const decoded = linkCodec.decode(meta.data);
37
- if (decoded._tag === "Left")
37
+ if ((0, Either_1.isLeft)(decoded))
38
38
  return acc;
39
39
  return [...acc, { ...meta, data: decoded.right }];
40
40
  }
@@ -54,7 +54,7 @@ const ValidatedMetas = (linkCodec) => new t.Type("ValidatedMetas", (metas) => Ar
54
54
  if (meta.type === "hyperlink" && meta.data) {
55
55
  // since the Span data are typed as unknown we have to redecode for type safety and then encode to either new format or legacy.
56
56
  const decoded = linkCodec.decode(meta.data);
57
- if (decoded._tag === "Left")
57
+ if ((0, Either_1.isLeft)(decoded))
58
58
  return acc;
59
59
  return [...acc, { ...meta, data: linkCodec.encode(decoded.right) }];
60
60
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CompositeSliceContent = exports.CompositeSliceLegacy = exports.isCompositeSliceContent = exports.CompositeSliceContentType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fp_ts_1 = require("fp-ts");
6
+ const Either_1 = require("fp-ts/lib/Either");
6
7
  const function_1 = require("fp-ts/lib/function");
7
8
  const t = tslib_1.__importStar(require("io-ts"));
8
9
  const LegacyContentCtx_1 = require("../../../LegacyContentCtx");
@@ -22,7 +23,7 @@ const CompositeSliceLegacy = (ctx) => {
22
23
  const repeat = (() => {
23
24
  const itemsCtx = (0, LegacyContentCtx_1.getFieldCtx)("repeat", ctx);
24
25
  const result = (0, RepeatableContent_1.RepeatableWidgetsLegacy)(itemsCtx).decode(parsedSlice.repeat);
25
- if (!result || result._tag === "Left")
26
+ if (!result || (0, Either_1.isLeft)(result))
26
27
  return;
27
28
  return result.right;
28
29
  })() || [];
@@ -33,10 +34,9 @@ const CompositeSliceLegacy = (ctx) => {
33
34
  const result = (0, nestable_1.NestableLegacy)(fieldCtx).decode(value);
34
35
  if (!result)
35
36
  return acc;
36
- if (result._tag === "Right")
37
- return { ...acc, [key]: result.right };
38
- else
37
+ if ((0, Either_1.isLeft)(result))
39
38
  return acc;
39
+ return { ...acc, [key]: result.right };
40
40
  }, {});
41
41
  return {
42
42
  nonRepeat,
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SharedSliceContent = exports.SharedSliceLegacy = exports.isSharedSliceContent = exports.SharedSliceContentType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fp_ts_1 = require("fp-ts");
6
+ const Either_1 = require("fp-ts/lib/Either");
6
7
  const function_1 = require("fp-ts/lib/function");
7
8
  const t = tslib_1.__importStar(require("io-ts"));
8
9
  const io_ts_types_1 = require("io-ts-types");
@@ -27,7 +28,7 @@ const SharedSliceLegacy = (ctx) => {
27
28
  parsedSlice.variation,
28
29
  ]);
29
30
  const result = (0, RepeatableContent_1.RepeatableWidgetsLegacy)(itemsCtx).decode(parsedSlice.items);
30
- if (!result || result._tag === "Left")
31
+ if (!result || (0, Either_1.isLeft)(result))
31
32
  return;
32
33
  return result.right;
33
34
  })() || [];
@@ -40,10 +41,9 @@ const SharedSliceLegacy = (ctx) => {
40
41
  const result = (0, nestable_1.NestableLegacy)(FieldCtx).decode(value);
41
42
  if (!result)
42
43
  return acc;
43
- if (result._tag === "Right")
44
- return { ...acc, [key]: result.right };
45
- else
44
+ if ((0, Either_1.isLeft)(result))
46
45
  return acc;
46
+ return { ...acc, [key]: result.right };
47
47
  }, {});
48
48
  return {
49
49
  variation: parsedSlice.variation,
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SlicesItemLegacy = exports.SliceItemContent = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fp_ts_1 = require("fp-ts");
6
+ const Either_1 = require("fp-ts/lib/Either");
6
7
  const function_1 = require("fp-ts/lib/function");
7
8
  const t = tslib_1.__importStar(require("io-ts"));
8
9
  const function_2 = require("../../../validators/function");
@@ -36,7 +37,7 @@ const SlicesItemLegacy = (ctx) => {
36
37
  const sliceName = parsedSlice.key.substring(0, stopIdx > 0 ? stopIdx : undefined);
37
38
  const itemCtx = (0, LegacyContentCtx_1.getFieldCtx)(parsedSlice.key, ctx);
38
39
  const item = (0, Slice_1.SliceLegacy)(itemCtx).decode(parsedSlice.value);
39
- if (!item || item._tag === "Left")
40
+ if (!item || (0, Either_1.isLeft)(item))
40
41
  return t.failure(sliceItem, context);
41
42
  return t.success({
42
43
  key: parsedSlice.key,
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hasContentType = exports.hasFieldContentType = void 0;
4
+ const Either_1 = require("fp-ts/lib/Either");
4
5
  const fields_1 = require("./fields");
5
6
  function hasFieldContentType(obj) {
6
7
  return (hasContentType(obj) &&
7
8
  obj.__TYPE__ === fields_1.FieldContentType &&
8
9
  (obj === null || obj === void 0 ? void 0 : obj.type) !== undefined &&
9
10
  typeof obj.type === "string" &&
10
- fields_1.FieldType.decode(obj.type)._tag === "Right");
11
+ (0, Either_1.isRight)(fields_1.FieldType.decode(obj.type)));
11
12
  }
12
13
  exports.hasFieldContentType = hasFieldContentType;
13
14
  function hasContentType(obj) {
14
- return ((obj === null || obj === void 0 ? void 0 : obj.__TYPE__) !== undefined &&
15
- typeof obj.__TYPE__ === "string");
15
+ return typeof obj.__TYPE__ === "string";
16
16
  }
17
17
  exports.hasContentType = hasContentType;
@@ -1,4 +1,4 @@
1
1
  export * from "./CustomType";
2
- export * as Comparators from "./diff";
3
- export * as Section from "./Section";
2
+ export * from "./diff";
3
+ export * from "./Section";
4
4
  export * from "./widgets";
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Section = exports.Comparators = void 0;
4
3
  const tslib_1 = require("tslib");
5
4
  tslib_1.__exportStar(require("./CustomType"), exports);
6
- exports.Comparators = tslib_1.__importStar(require("./diff"));
7
- exports.Section = tslib_1.__importStar(require("./Section"));
5
+ tslib_1.__exportStar(require("./diff"), exports);
6
+ tslib_1.__exportStar(require("./Section"), exports);
8
7
  tslib_1.__exportStar(require("./widgets"), exports);
@@ -1,6 +1,168 @@
1
1
  import * as t from "io-ts";
2
2
  export declare const GroupFieldType = "Group";
3
- declare const Group: t.ExactC<t.IntersectionC<[t.TypeC<{
3
+ export declare const GroupConfig: t.ExactC<t.PartialC<{
4
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
5
+ repeat: t.BooleanC;
6
+ fields: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
7
+ type: t.LiteralC<"Color">;
8
+ }>, t.PartialC<{
9
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
10
+ config: t.ExactC<t.PartialC<{
11
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
12
+ placeholder: t.StringC;
13
+ }>>;
14
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
15
+ type: t.LiteralC<"Boolean">;
16
+ }>, t.PartialC<{
17
+ config: t.ExactC<t.PartialC<{
18
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
19
+ default_value: t.BooleanC;
20
+ placeholder_true: t.StringC;
21
+ placeholder_false: t.StringC;
22
+ }>>;
23
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
24
+ type: t.LiteralC<"Embed">;
25
+ }>, t.PartialC<{
26
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
27
+ config: t.ExactC<t.PartialC<{
28
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
29
+ placeholder: t.StringC;
30
+ useAsTitle: t.BooleanC;
31
+ }>>;
32
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
33
+ type: t.LiteralC<"GeoPoint">;
34
+ }>, t.PartialC<{
35
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
36
+ config: t.ExactC<t.PartialC<{
37
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
38
+ }>>;
39
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
40
+ type: t.LiteralC<"Date">;
41
+ }>, t.PartialC<{
42
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
43
+ config: t.ExactC<t.PartialC<{
44
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
45
+ placeholder: t.StringC;
46
+ default: t.StringC;
47
+ }>>;
48
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
49
+ type: t.LiteralC<"Number">;
50
+ }>, t.PartialC<{
51
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
52
+ config: t.ExactC<t.PartialC<{
53
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
54
+ placeholder: t.StringC;
55
+ min: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
56
+ max: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
57
+ step: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
58
+ }>>;
59
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
60
+ type: t.LiteralC<"Range">;
61
+ }>, t.PartialC<{
62
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
63
+ config: t.ExactC<t.PartialC<{
64
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
65
+ placeholder: t.StringC;
66
+ min: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
67
+ max: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
68
+ step: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
69
+ }>>;
70
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
71
+ type: t.LiteralC<"StructuredText">;
72
+ }>, t.PartialC<{
73
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
74
+ config: t.ExactC<t.PartialC<{
75
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
76
+ placeholder: t.StringC;
77
+ useAsTitle: t.BooleanC;
78
+ single: t.Type<string, string, unknown>;
79
+ multi: t.Type<string, string, unknown>;
80
+ imageConstraint: t.PartialC<{
81
+ width: t.Type<number | null, unknown, unknown>;
82
+ height: t.Type<number | null, unknown, unknown>;
83
+ }>;
84
+ labels: t.Type<readonly string[], object, unknown>;
85
+ allowTargetBlank: t.BooleanC;
86
+ }>>;
87
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
88
+ type: t.LiteralC<"Select">;
89
+ }>, t.PartialC<{
90
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
91
+ config: t.ExactC<t.PartialC<{
92
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
93
+ placeholder: t.StringC;
94
+ default_value: t.StringC;
95
+ options: t.ReadonlyArrayC<t.UnionC<[t.StringC, t.Type<string, string, unknown>, t.Type<string, string, unknown>]>>;
96
+ }>>;
97
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
98
+ type: t.LiteralC<"Separator">;
99
+ }>, t.PartialC<{
100
+ config: t.ExactC<t.PartialC<{
101
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
102
+ }>>;
103
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
104
+ type: t.LiteralC<"Text">;
105
+ }>, t.PartialC<{
106
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
107
+ config: t.ExactC<t.PartialC<{
108
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
109
+ useAsTitle: t.BooleanC;
110
+ placeholder: t.StringC;
111
+ }>>;
112
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
113
+ type: t.LiteralC<"Timestamp">;
114
+ }>, t.PartialC<{
115
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
116
+ config: t.ExactC<t.PartialC<{
117
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
118
+ placeholder: t.StringC;
119
+ default: t.StringC;
120
+ }>>;
121
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
122
+ type: t.LiteralC<"Link">;
123
+ }>, t.PartialC<{
124
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
125
+ config: t.ExactC<t.PartialC<{
126
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
127
+ useAsTitle: t.BooleanC;
128
+ placeholder: t.StringC;
129
+ select: t.UnionC<[t.LiteralC<"media">, t.LiteralC<"document">, t.LiteralC<"web">, t.NullC]>;
130
+ customtypes: t.ReadonlyArrayC<t.StringC>;
131
+ masks: t.Type<readonly string[], object, unknown>;
132
+ tags: t.Type<readonly string[], object, unknown>;
133
+ allowTargetBlank: t.BooleanC;
134
+ }>>;
135
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
136
+ type: t.LiteralC<"Image">;
137
+ }>, t.PartialC<{
138
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
139
+ config: t.ExactC<t.PartialC<{
140
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
141
+ placeholder: t.StringC;
142
+ constraint: t.PartialC<{
143
+ width: t.Type<number | null, unknown, unknown>;
144
+ height: t.Type<number | null, unknown, unknown>;
145
+ }>;
146
+ thumbnails: t.ReadonlyArrayC<t.ExactC<t.IntersectionC<[t.TypeC<{
147
+ name: t.StringC;
148
+ }>, t.PartialC<{
149
+ width: t.Type<number | null, unknown, unknown>;
150
+ height: t.Type<number | null, unknown, unknown>;
151
+ }>]>>>;
152
+ }>>;
153
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
154
+ type: t.LiteralC<"IntegrationFields">;
155
+ }>, t.PartialC<{
156
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
157
+ config: t.ExactC<t.PartialC<{
158
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
159
+ placeholder: t.StringC;
160
+ catalog: t.StringC;
161
+ }>>;
162
+ }>]>>]>>;
163
+ }>>;
164
+ export type GroupConfig = t.TypeOf<typeof GroupConfig>;
165
+ export declare const Group: t.ExactC<t.IntersectionC<[t.TypeC<{
4
166
  type: t.LiteralC<"Group">;
5
167
  }>, t.PartialC<{
6
168
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -168,5 +330,4 @@ declare const Group: t.ExactC<t.IntersectionC<[t.TypeC<{
168
330
  }>]>>]>>;
169
331
  }>>;
170
332
  }>]>>;
171
- type Group = t.TypeOf<typeof Group>;
172
- export default Group;
333
+ export type Group = t.TypeOf<typeof Group>;
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GroupFieldType = void 0;
3
+ exports.Group = exports.GroupConfig = exports.GroupFieldType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const t = tslib_1.__importStar(require("io-ts"));
6
6
  const common_1 = require("../../common");
7
7
  const validators_1 = require("../../validators");
8
8
  const NestableWidget_1 = require("./nestable/NestableWidget");
9
9
  exports.GroupFieldType = "Group";
10
- const GroupConfig = t.exact(t.partial({
10
+ exports.GroupConfig = t.exact(t.partial({
11
11
  label: validators_1.StringOrNull,
12
12
  repeat: t.boolean,
13
13
  fields: t.record(common_1.WidgetKey, NestableWidget_1.NestableWidget),
14
14
  }));
15
- const Group = t.exact(t.intersection([
15
+ exports.Group = t.exact(t.intersection([
16
16
  t.type({
17
17
  type: t.literal(exports.GroupFieldType),
18
18
  }),
@@ -20,7 +20,6 @@ const Group = t.exact(t.intersection([
20
20
  fieldset: validators_1.StringOrNull,
21
21
  icon: t.string,
22
22
  description: t.string,
23
- config: GroupConfig,
23
+ config: exports.GroupConfig,
24
24
  }),
25
25
  ]));
26
- exports.default = Group;
@@ -1,6 +1,12 @@
1
1
  import * as t from "io-ts";
2
2
  export declare const UIDFieldType = "UID";
3
- declare const UID: t.ExactC<t.IntersectionC<[t.TypeC<{
3
+ export declare const UIDConfig: t.ExactC<t.PartialC<{
4
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
5
+ useAsTitle: t.BooleanC;
6
+ placeholder: t.StringC;
7
+ }>>;
8
+ export type UIDConfig = t.TypeOf<typeof UIDConfig>;
9
+ export declare const UID: t.ExactC<t.IntersectionC<[t.TypeC<{
4
10
  type: t.LiteralC<"UID">;
5
11
  }>, t.PartialC<{
6
12
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -10,5 +16,4 @@ declare const UID: t.ExactC<t.IntersectionC<[t.TypeC<{
10
16
  placeholder: t.StringC;
11
17
  }>>;
12
18
  }>]>>;
13
- type UID = t.TypeOf<typeof UID>;
14
- export default UID;
19
+ export type UID = t.TypeOf<typeof UID>;
@@ -1,22 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UIDFieldType = void 0;
3
+ exports.UID = exports.UIDConfig = exports.UIDFieldType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const t = tslib_1.__importStar(require("io-ts"));
6
6
  const validators_1 = require("../../validators");
7
7
  exports.UIDFieldType = "UID";
8
- const UIDConfig = t.exact(t.partial({
8
+ exports.UIDConfig = t.exact(t.partial({
9
9
  label: validators_1.StringOrNull,
10
10
  useAsTitle: t.boolean,
11
11
  placeholder: t.string,
12
12
  }));
13
- const UID = t.exact(t.intersection([
13
+ exports.UID = t.exact(t.intersection([
14
14
  t.type({
15
15
  type: t.literal(exports.UIDFieldType),
16
16
  }),
17
17
  t.partial({
18
18
  fieldset: validators_1.StringOrNull,
19
- config: UIDConfig,
19
+ config: exports.UIDConfig,
20
20
  }),
21
21
  ]));
22
- exports.default = UID;
@@ -2678,7 +2678,7 @@ export declare const DynamicWidget: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<
2678
2678
  };
2679
2679
  }, unknown, unknown>]>;
2680
2680
  export type DynamicWidget = t.TypeOf<typeof DynamicWidget>;
2681
- export declare const FieldTypes: t.KeyofC<{
2681
+ export declare const FieldType: t.KeyofC<{
2682
2682
  Color: null;
2683
2683
  Boolean: null;
2684
2684
  Number: null;
@@ -2699,7 +2699,7 @@ export declare const FieldTypes: t.KeyofC<{
2699
2699
  Slices: null;
2700
2700
  Choice: null;
2701
2701
  }>;
2702
- export type FieldTypes = t.TypeOf<typeof FieldTypes>;
2702
+ export type FieldType = t.TypeOf<typeof FieldType>;
2703
2703
  export declare const Widgets: {
2704
2704
  toStatic(widget: DynamicWidget, sharedSlices: Map<string, SharedSlice>): StaticWidget;
2705
2705
  };
@@ -1,20 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Widgets = exports.FieldTypes = exports.DynamicWidget = exports.StaticWidget = exports.widgetReader = void 0;
3
+ exports.Widgets = exports.FieldType = exports.DynamicWidget = exports.StaticWidget = exports.widgetReader = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const t = tslib_1.__importStar(require("io-ts"));
6
- const Group_1 = tslib_1.__importStar(require("./Group"));
6
+ const Group_1 = require("./Group");
7
7
  const nestable_1 = require("./nestable");
8
8
  const NestableWidget_1 = require("./nestable/NestableWidget");
9
9
  const Slices_1 = require("./slices/Slices");
10
- const UID_1 = tslib_1.__importStar(require("./UID"));
10
+ const UID_1 = require("./UID");
11
11
  function widgetReader(codec) {
12
- return t.union([UID_1.default, NestableWidget_1.NestableWidget, Group_1.default, codec]);
12
+ return t.union([UID_1.UID, NestableWidget_1.NestableWidget, Group_1.Group, codec]);
13
13
  }
14
14
  exports.widgetReader = widgetReader;
15
15
  exports.StaticWidget = widgetReader(Slices_1.StaticSlices);
16
16
  exports.DynamicWidget = widgetReader(Slices_1.DynamicSlices);
17
- exports.FieldTypes = t.keyof({
17
+ exports.FieldType = t.keyof({
18
18
  [nestable_1.ColorFieldType]: null,
19
19
  [nestable_1.BooleanFieldType]: null,
20
20
  [nestable_1.NumberFieldType]: null,
@@ -27,4 +27,3 @@ export declare const Link: t.ExactC<t.IntersectionC<[t.TypeC<{
27
27
  }>>;
28
28
  }>]>>;
29
29
  export type Link = t.TypeOf<typeof Link>;
30
- export default Link;
@@ -52,4 +52,3 @@ exports.Link = t.exact(t.intersection([
52
52
  config: exports.LinkConfig,
53
53
  }),
54
54
  ]));
55
- exports.default = exports.Link;
@@ -1,7 +1,7 @@
1
1
  import * as t from "io-ts";
2
2
  export declare const RichTextFieldType = "StructuredText";
3
3
  export declare const DEFAULT_OPTION = "paragraph";
4
- export type RichTextNodeType = typeof RichTextNodeType[keyof typeof RichTextNodeType];
4
+ export type RichTextNodeType = (typeof RichTextNodeType)[keyof typeof RichTextNodeType];
5
5
  export declare const RichTextNodeType: {
6
6
  readonly heading1: "heading1";
7
7
  readonly heading2: "heading2";
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RichText = exports.RichTextConfig = exports.RichTextNodeTypeCodec = exports.RichTextNodeType = exports.DEFAULT_OPTION = exports.RichTextFieldType = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const fp_ts_1 = require("fp-ts/");
5
6
  const Either_1 = require("fp-ts/lib/Either");
7
+ const function_1 = require("fp-ts/lib/function");
6
8
  const t = tslib_1.__importStar(require("io-ts"));
7
9
  const validators_1 = require("../../../validators");
8
10
  const ImageConstraint_1 = tslib_1.__importDefault(require("../shared/ImageConstraint"));
@@ -44,18 +46,18 @@ exports.RichTextNodeTypeCodec = t.keyof({
44
46
  [exports.RichTextNodeType.orderedList]: null,
45
47
  [exports.RichTextNodeType.rtl]: null,
46
48
  });
47
- const RichTextOptions = new t.Type("RichTextOptions", (u) => typeof u === "string", (u, context) => {
48
- return Either_1.either.chain(t.union([t.string, t.null]).validate(u, context), (s) => {
49
+ const RichTextOptions = new t.Type("RichTextOptions", (u) => typeof u === "string", (u) => {
50
+ return (0, function_1.pipe)(t.union([t.string, t.null]).decode(u), fp_ts_1.either.map((s) => {
49
51
  if (!s)
50
- return t.success(exports.DEFAULT_OPTION);
52
+ return exports.DEFAULT_OPTION;
51
53
  const entries = s.split(",").map((e) => e.trim());
52
54
  const filtered = entries.filter((entry) => {
53
55
  return (0, Either_1.getOrElseW)(() => undefined)(exports.RichTextNodeTypeCodec.decode(entry));
54
56
  });
55
57
  if (!filtered.length)
56
- return t.success(exports.DEFAULT_OPTION);
57
- return t.success(filtered.join(","));
58
- });
58
+ return exports.DEFAULT_OPTION;
59
+ return filtered.join(",");
60
+ }));
59
61
  }, (a) => a);
60
62
  const NoLabels = (labels) => {
61
63
  if (!labels)
@@ -100,15 +102,13 @@ const RichTextLabels = new t.Type("RichTextLabels", (u) => {
100
102
  }, (u, context) => {
101
103
  const legacyValidator = t.record(t.string, t.readonlyArray(t.record(t.literal("name"), t.string)));
102
104
  const validator = t.readonlyArray(t.string);
103
- return Either_1.either.chain(t
104
- .union([legacyValidator, validator, t.string, t.null])
105
- .validate(u, context), (labels) => {
105
+ return (0, function_1.pipe)(t.union([legacyValidator, validator, t.string, t.null]).decode(u), fp_ts_1.either.chain((labels) => {
106
106
  return (NoLabels(labels) ||
107
107
  LabelsAsArray(labels) ||
108
108
  LabelsAsObject(labels) ||
109
109
  LabelsAsString(labels) ||
110
110
  t.failure(u, context));
111
- });
111
+ }));
112
112
  }, (res) => res);
113
113
  exports.RichTextConfig = t.exact(t.partial({
114
114
  label: validators_1.StringOrNull,