@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,7 +1,11 @@
1
- import { Chain } from "fp-ts/Either";
2
- import * as t from "io-ts";
3
- export const BooleanContentType = "BooleanContent";
4
- const BooleanContent = new t.Type("BooleanContent", (u) => u?.__TYPE__ === BooleanContentType, (u, c) => Chain.chain(t.boolean.validate(u, c), (u) => {
5
- return t.success({ value: u, __TYPE__: BooleanContentType });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BooleanContentType = 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.BooleanContentType = "BooleanContent";
8
+ const BooleanContent = new t.Type("BooleanContent", (u) => u?.__TYPE__ === exports.BooleanContentType, (u, c) => Either_1.Chain.chain(t.boolean.validate(u, c), (u) => {
9
+ return t.success({ value: u, __TYPE__: exports.BooleanContentType });
6
10
  }), (booleanContent) => t.boolean.encode(booleanContent.value));
7
- export default BooleanContent;
11
+ exports.default = BooleanContent;
@@ -1,9 +1,12 @@
1
1
  import * as t from "io-ts";
2
2
  export declare const EmbedContentType = "EmbedContent";
3
- declare type EmbedContent = t.OutputOf<typeof EmbedContentC> & {
3
+ export declare type EmbedContent = t.TypeOf<typeof EmbedContentC> & {
4
4
  all: unknown;
5
5
  };
6
- declare const EmbedContent: t.Type<EmbedContent, unknown, unknown>;
6
+ export declare type EmbedContentO = t.OutputOf<typeof EmbedContentC> & {
7
+ all: unknown;
8
+ };
9
+ export declare const EmbedContent: t.Type<EmbedContentO, unknown, unknown>;
7
10
  declare const EmbedContentC: t.Type<{
8
11
  embed_url: string;
9
12
  type: string;
@@ -37,4 +40,4 @@ declare const EmbedContentC: t.Type<{
37
40
  } & {
38
41
  __TYPE__: "EmbedContent";
39
42
  }, unknown>;
40
- export default EmbedContent;
43
+ export {};
@@ -1,32 +1,35 @@
1
- import { either } from "fp-ts";
2
- import { pipe } from "fp-ts/function";
3
- import * as t from "io-ts";
4
- import { NumberOrNull, StringOrNull } from "../../../validators";
5
- import { addType } from "../../../validators/function";
6
- export const EmbedContentType = "EmbedContent";
7
- const EmbedContent = new t.Type("EmbedContent", (u) => u.__TYPE__ === EmbedContentType, (u) => {
8
- return pipe(EmbedContentC.decode(u), either.map((s) => ({
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmbedContent = exports.EmbedContentType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fp_ts_1 = require("fp-ts");
6
+ const function_1 = require("fp-ts/function");
7
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
8
+ const validators_1 = require("../../../validators");
9
+ const function_2 = require("../../../validators/function");
10
+ exports.EmbedContentType = "EmbedContent";
11
+ exports.EmbedContent = new t.Type("EmbedContent", (u) => u.__TYPE__ === exports.EmbedContentType, (u) => {
12
+ return (0, function_1.pipe)(EmbedContentC.decode(u), fp_ts_1.either.map((s) => ({
9
13
  ...EmbedContentC.encode(s),
10
14
  all: u,
11
15
  })));
12
16
  }, (ec) => EmbedContentC.encode(ec));
13
- const EmbedContentC = addType(t.exact(t.intersection([
17
+ const EmbedContentC = (0, function_2.addType)(t.exact(t.intersection([
14
18
  t.type({
15
19
  embed_url: t.string,
16
20
  type: t.string,
17
21
  }),
18
22
  t.partial({
19
23
  version: t.union([t.string, t.number, t.null]),
20
- title: StringOrNull,
21
- author_name: StringOrNull,
22
- author_url: StringOrNull,
23
- provider_name: StringOrNull,
24
- provider_url: StringOrNull,
24
+ title: validators_1.StringOrNull,
25
+ author_name: validators_1.StringOrNull,
26
+ author_url: validators_1.StringOrNull,
27
+ provider_name: validators_1.StringOrNull,
28
+ provider_url: validators_1.StringOrNull,
25
29
  cache_age: t.union([t.string, t.number, t.null]),
26
- thumbnail_url: StringOrNull,
27
- thumbnail_width: NumberOrNull,
28
- thumbnail_height: NumberOrNull,
29
- html: StringOrNull,
30
+ thumbnail_url: validators_1.StringOrNull,
31
+ thumbnail_width: validators_1.NumberOrNull,
32
+ thumbnail_height: validators_1.NumberOrNull,
33
+ html: validators_1.StringOrNull,
30
34
  }),
31
- ])), EmbedContentType);
32
- export default EmbedContent;
35
+ ])), exports.EmbedContentType);
@@ -1,12 +1,13 @@
1
1
  import * as O from "fp-ts/Option";
2
+ export declare type FieldType = "Text" | "Date" | "Timestamp" | "Color" | "Number" | "Range" | "Select";
2
3
  export declare const FieldContentType = "FieldContent";
3
4
  declare type FieldContent = {
4
5
  value: string;
5
- type: string;
6
+ type: FieldType;
6
7
  __TYPE__: typeof FieldContentType;
7
8
  };
8
9
  declare const FieldContent: {
9
10
  types: string[];
10
- forType: (type: string, value: unknown) => O.Option<FieldContent>;
11
+ forType: (type: FieldType, value: unknown) => O.Option<FieldContent>;
11
12
  };
12
13
  export default FieldContent;
@@ -1,7 +1,11 @@
1
- import { pipe } from "fp-ts/function";
2
- import * as O from "fp-ts/Option";
3
- import * as t from "io-ts";
4
- export const FieldContentType = "FieldContent";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldContentType = 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
+ exports.FieldContentType = "FieldContent";
5
9
  //we do that instead of idiomatic .trim()
6
10
  //because we need to have the exact same behaviour than scala/java .trim()
7
11
  //in other world only trim space and not non-breaking space or tab
@@ -21,7 +25,7 @@ function trimScalaStyle(s) {
21
25
  const FieldContent = {
22
26
  types: ["Text", "Date", "Timestamp", "Color", "Number", "Range", "Select"],
23
27
  forType: (type, value) => {
24
- return pipe(O.fromEither(t.string.decode(value)), O.map((r) => {
28
+ return (0, function_1.pipe)(O.fromEither(t.string.decode(value)), O.map((r) => {
25
29
  return {
26
30
  value: trimScalaStyle(r),
27
31
  type,
@@ -30,4 +34,4 @@ const FieldContent = {
30
34
  }));
31
35
  },
32
36
  };
33
- export default FieldContent;
37
+ exports.default = FieldContent;
@@ -1,9 +1,13 @@
1
- import * as t from "io-ts";
2
- import { addType } from "../../../validators/function";
3
- export const GeoPointContentType = "GeoPointContent";
4
- export const GeoPointContent = addType(t.strict({
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GeoPointContent = exports.GeoPointContentType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const function_1 = require("../../../validators/function");
7
+ exports.GeoPointContentType = "GeoPointContent";
8
+ exports.GeoPointContent = (0, function_1.addType)(t.strict({
5
9
  position: t.strict({
6
10
  lat: t.number,
7
11
  lng: t.number,
8
12
  }),
9
- }), GeoPointContentType);
13
+ }), exports.GeoPointContentType);
@@ -1,13 +1,17 @@
1
- import * as t from "io-ts";
2
- import { NonEmptyStringOrNull, StringOrNull } from "../../../validators";
3
- import { addType } from "../../../validators/function";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImageContent = exports.ImageContentType = exports.ImageContentView = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const validators_1 = require("../../../validators");
7
+ const function_1 = require("../../../validators/function");
4
8
  const Origin = t.exact(t.type({
5
9
  id: t.string,
6
10
  url: t.string,
7
11
  width: t.number,
8
12
  height: t.number,
9
13
  }));
10
- export const ImageContentView = t.exact(t.intersection([
14
+ exports.ImageContentView = t.exact(t.intersection([
11
15
  t.type({
12
16
  origin: Origin,
13
17
  width: t.number,
@@ -23,15 +27,15 @@ export const ImageContentView = t.exact(t.intersection([
23
27
  }),
24
28
  t.partial({
25
29
  url: t.string,
26
- credits: NonEmptyStringOrNull,
27
- alt: NonEmptyStringOrNull,
28
- provider: StringOrNull,
30
+ credits: validators_1.NonEmptyStringOrNull,
31
+ alt: validators_1.NonEmptyStringOrNull,
32
+ provider: validators_1.StringOrNull,
29
33
  }),
30
34
  ]));
31
- export const ImageContentType = "ImageContent";
32
- export const ImageContent = addType(t.intersection([
33
- ImageContentView,
35
+ exports.ImageContentType = "ImageContent";
36
+ exports.ImageContent = (0, function_1.addType)(t.intersection([
37
+ exports.ImageContentView,
34
38
  t.partial({
35
- thumbnails: t.record(t.string, ImageContentView),
39
+ thumbnails: t.record(t.string, exports.ImageContentView),
36
40
  }),
37
- ]), ImageContentType);
41
+ ]), exports.ImageContentType);
@@ -1,12 +1,16 @@
1
- import { Chain } from "fp-ts/Either";
2
- import * as t from "io-ts";
3
- export const IntegrationFieldsContentType = "IntegrationFieldsContent";
4
- const IntegrationFieldsContent = new t.Type("IntegrationFieldsContent", (u) => u?.__TYPE__ === IntegrationFieldsContentType, (u, c) => Chain.chain(t.string.validate(u, c), (u) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IntegrationFieldsContentType = 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.IntegrationFieldsContentType = "IntegrationFieldsContent";
8
+ const IntegrationFieldsContent = new t.Type("IntegrationFieldsContent", (u) => u?.__TYPE__ === exports.IntegrationFieldsContentType, (u, c) => Either_1.Chain.chain(t.string.validate(u, c), (u) => {
5
9
  return t.success({
6
10
  value: u,
7
- __TYPE__: IntegrationFieldsContentType,
11
+ __TYPE__: exports.IntegrationFieldsContentType,
8
12
  });
9
13
  }), () => {
10
14
  throw new Error("Not implemented - Not used - Not relevant");
11
15
  });
12
- export default IntegrationFieldsContent;
16
+ exports.default = IntegrationFieldsContent;
@@ -1,8 +1,13 @@
1
- import * as t from "io-ts";
2
- import { NonEmptyString } from "../../../../validators";
3
- import { addType } from "../../../../validators/function";
4
- export const DocumentLinkType = "DocumentLink";
5
- export const DocumentLink = addType(t.strict({ id: NonEmptyString }), DocumentLinkType);
6
- export function isDocumentLink(u) {
7
- return u.__TYPE__ === DocumentLinkType;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDocumentLink = exports.DocumentLink = exports.DocumentLinkType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const validators_1 = require("../../../../validators");
7
+ const function_1 = require("../../../../validators/function");
8
+ exports.DocumentLinkType = "DocumentLink";
9
+ exports.DocumentLink = (0, function_1.addType)(t.strict({ id: validators_1.NonEmptyString }), exports.DocumentLinkType);
10
+ function isDocumentLink(u) {
11
+ return u.__TYPE__ === exports.DocumentLinkType;
8
12
  }
13
+ exports.isDocumentLink = isDocumentLink;
@@ -1,19 +1,24 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../../../validators";
3
- import { addType, nullable } from "../../../../validators/function";
4
- export const ExternalLinkType = "ExternalLink";
5
- export const ExternalLink = addType(t.exact(t.intersection([
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isExternalLink = exports.ExternalLink = exports.ExternalLinkType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const validators_1 = require("../../../../validators");
7
+ const function_1 = require("../../../../validators/function");
8
+ exports.ExternalLinkType = "ExternalLink";
9
+ exports.ExternalLink = (0, function_1.addType)(t.exact(t.intersection([
6
10
  t.type({
7
11
  url: t.string,
8
12
  }),
9
13
  t.partial({
10
14
  kind: t.literal("web"),
11
- target: StringOrNull,
12
- preview: nullable(t.partial({
15
+ target: validators_1.StringOrNull,
16
+ preview: (0, function_1.nullable)(t.partial({
13
17
  title: t.string,
14
18
  })),
15
19
  }),
16
- ])), ExternalLinkType);
17
- export function isExternalLink(u) {
18
- return u.__TYPE__ === ExternalLinkType;
20
+ ])), exports.ExternalLinkType);
21
+ function isExternalLink(u) {
22
+ return u.__TYPE__ === exports.ExternalLinkType;
19
23
  }
24
+ exports.isExternalLink = isExternalLink;
@@ -1,8 +1,12 @@
1
- import * as t from "io-ts";
2
- import { mapOutput } from "io-ts-types/lib/mapOutput";
3
- import { nullable } from "../../../../validators/function";
4
- export const FileLinkType = "FileLink";
5
- export const FileLink = mapOutput(t.exact(t.intersection([
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isFileLink = exports.FileLink = exports.FileLinkType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const mapOutput_1 = require("io-ts-types/lib/mapOutput");
7
+ const function_1 = require("../../../../validators/function");
8
+ exports.FileLinkType = "FileLink";
9
+ exports.FileLink = (0, mapOutput_1.mapOutput)(t.exact(t.intersection([
6
10
  t.type({
7
11
  id: t.string,
8
12
  url: t.string,
@@ -10,10 +14,11 @@ export const FileLink = mapOutput(t.exact(t.intersection([
10
14
  kind: t.string,
11
15
  }),
12
16
  t.partial({
13
- date: nullable(t.string),
14
- size: nullable(t.string),
17
+ date: (0, function_1.nullable)(t.string),
18
+ size: (0, function_1.nullable)(t.string),
15
19
  }),
16
- ])), (o) => ({ ...o, size: o.size || "0", __TYPE__: FileLinkType }));
17
- export function isFileLink(u) {
18
- return u.__TYPE__ === FileLinkType;
20
+ ])), (o) => ({ ...o, size: o.size || "0", __TYPE__: exports.FileLinkType }));
21
+ function isFileLink(u) {
22
+ return u.__TYPE__ === exports.FileLinkType;
19
23
  }
24
+ exports.isFileLink = isFileLink;
@@ -1,8 +1,12 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../../../validators";
3
- import { addType } from "../../../../validators/function";
4
- export const ImageLinkType = "ImageLink";
5
- export const ImageLink = addType(t.exact(t.intersection([
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isImageLink = exports.ImageLink = exports.ImageLinkType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const validators_1 = require("../../../../validators");
7
+ const function_1 = require("../../../../validators/function");
8
+ exports.ImageLinkType = "ImageLink";
9
+ exports.ImageLink = (0, function_1.addType)(t.exact(t.intersection([
6
10
  t.type({
7
11
  id: t.string,
8
12
  url: t.string,
@@ -13,9 +17,10 @@ export const ImageLink = addType(t.exact(t.intersection([
13
17
  kind: t.string,
14
18
  }),
15
19
  t.partial({
16
- date: StringOrNull,
20
+ date: validators_1.StringOrNull,
17
21
  }),
18
- ])), ImageLinkType);
19
- export function isImageLink(u) {
20
- return u.__TYPE__ === ImageLinkType;
22
+ ])), exports.ImageLinkType);
23
+ function isImageLink(u) {
24
+ return u.__TYPE__ === exports.ImageLinkType;
21
25
  }
26
+ exports.isImageLink = isImageLink;
@@ -1,9 +1,13 @@
1
- import { Chain } from "fp-ts/Either";
2
- import * as t from "io-ts";
3
- import { Link } from "./index";
4
- export const LinkContentType = "LinkContent";
5
- export const LinkContent = new t.Type("LinkContent", (u) => {
6
- return Link.is(u?.value);
7
- }, (u, c) => Chain.chain(Link.validate(u, c), (u) => {
8
- return t.success({ value: u, __TYPE__: LinkContentType });
9
- }), (linkContent) => Link.encode(linkContent.value));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LinkContent = exports.LinkContentType = 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
+ const index_1 = require("./index");
8
+ exports.LinkContentType = "LinkContent";
9
+ exports.LinkContent = new t.Type("LinkContent", (u) => {
10
+ return index_1.Link.is(u?.value);
11
+ }, (u, c) => Either_1.Chain.chain(index_1.Link.validate(u, c), (u) => {
12
+ return t.success({ value: u, __TYPE__: exports.LinkContentType });
13
+ }), (linkContent) => index_1.Link.encode(linkContent.value));
@@ -81,9 +81,9 @@ export declare const is: {
81
81
  imageLink: typeof isImageLink;
82
82
  };
83
83
  export declare const LinksTypes: {
84
- DocumentLink: string;
85
- FileLink: string;
86
- ExternalLink: string;
87
- ImageLink: string;
88
- LinkContent: string;
84
+ readonly DocumentLink: "DocumentLink";
85
+ readonly FileLink: "FileLink";
86
+ readonly ExternalLink: "ExternalLink";
87
+ readonly ImageLink: "ImageLink";
88
+ readonly LinkContent: "LinkContent";
89
89
  };
@@ -1,26 +1,35 @@
1
- import * as t from "io-ts";
2
- import { DocumentLink, DocumentLinkType, isDocumentLink } from "./DocumentLink";
3
- import { ExternalLink, ExternalLinkType, isExternalLink } from "./ExternalLink";
4
- import { FileLink, FileLinkType, isFileLink } from "./FileLink";
5
- import { ImageLink, ImageLinkType, isImageLink } from "./ImageLink";
6
- import { LinkContentType } from "./LinkContent";
7
- export const Link = t.union([ImageLink, FileLink, DocumentLink, ExternalLink]);
8
- export { DocumentLink } from "./DocumentLink";
9
- export { ExternalLink } from "./ExternalLink";
10
- export { FileLink } from "./FileLink";
11
- export { ImageLink } from "./ImageLink";
12
- export { LinkContent } from "./LinkContent";
13
- export const BROKEN_CUSTOM_TYPE = "broken_type";
14
- export const is = {
15
- documentLink: isDocumentLink,
16
- fileLink: isFileLink,
17
- externalLink: isExternalLink,
18
- imageLink: isImageLink,
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LinksTypes = exports.is = exports.BROKEN_CUSTOM_TYPE = exports.LinkContent = exports.ImageLink = exports.FileLink = exports.ExternalLink = exports.DocumentLink = exports.Link = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const DocumentLink_1 = require("./DocumentLink");
7
+ const ExternalLink_1 = require("./ExternalLink");
8
+ const FileLink_1 = require("./FileLink");
9
+ const ImageLink_1 = require("./ImageLink");
10
+ const LinkContent_1 = require("./LinkContent");
11
+ exports.Link = t.union([ImageLink_1.ImageLink, FileLink_1.FileLink, DocumentLink_1.DocumentLink, ExternalLink_1.ExternalLink]);
12
+ var DocumentLink_2 = require("./DocumentLink");
13
+ Object.defineProperty(exports, "DocumentLink", { enumerable: true, get: function () { return DocumentLink_2.DocumentLink; } });
14
+ var ExternalLink_2 = require("./ExternalLink");
15
+ Object.defineProperty(exports, "ExternalLink", { enumerable: true, get: function () { return ExternalLink_2.ExternalLink; } });
16
+ var FileLink_2 = require("./FileLink");
17
+ Object.defineProperty(exports, "FileLink", { enumerable: true, get: function () { return FileLink_2.FileLink; } });
18
+ var ImageLink_2 = require("./ImageLink");
19
+ Object.defineProperty(exports, "ImageLink", { enumerable: true, get: function () { return ImageLink_2.ImageLink; } });
20
+ var LinkContent_2 = require("./LinkContent");
21
+ Object.defineProperty(exports, "LinkContent", { enumerable: true, get: function () { return LinkContent_2.LinkContent; } });
22
+ exports.BROKEN_CUSTOM_TYPE = "broken_type";
23
+ exports.is = {
24
+ documentLink: DocumentLink_1.isDocumentLink,
25
+ fileLink: FileLink_1.isFileLink,
26
+ externalLink: ExternalLink_1.isExternalLink,
27
+ imageLink: ImageLink_1.isImageLink,
19
28
  };
20
- export const LinksTypes = {
21
- DocumentLink: DocumentLinkType,
22
- FileLink: FileLinkType,
23
- ExternalLink: ExternalLinkType,
24
- ImageLink: ImageLinkType,
25
- LinkContent: LinkContentType,
29
+ exports.LinksTypes = {
30
+ DocumentLink: DocumentLink_1.DocumentLinkType,
31
+ FileLink: FileLink_1.FileLinkType,
32
+ ExternalLink: ExternalLink_1.ExternalLinkType,
33
+ ImageLink: ImageLink_1.ImageLinkType,
34
+ LinkContent: LinkContent_1.LinkContentType,
26
35
  };
@@ -1,5 +1,8 @@
1
- export const SeparatorContentType = "SeparatorContent";
2
- export const SeparatorContent = {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SeparatorContent = exports.SeparatorContentType = void 0;
4
+ exports.SeparatorContentType = "SeparatorContent";
5
+ exports.SeparatorContent = {
3
6
  is(value) {
4
7
  const asFieldContent = value;
5
8
  return asFieldContent.__TYPE__ === "SeparatorContent";
@@ -1,5 +1,4 @@
1
1
  import * as t from "io-ts";
2
- import EmbedContent from "../EmbedContent";
3
2
  export declare const Meta: t.ExactC<t.IntersectionC<[t.PartialC<{
4
3
  data: t.UnknownC;
5
4
  }>, t.TypeC<{
@@ -119,7 +118,7 @@ export declare function checkImageBlock(block: Block): block is ImageBlock;
119
118
  export declare const EmbedBlockType = "embed";
120
119
  export declare const EmbedBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
121
120
  type: t.LiteralC<"embed">;
122
- data: t.Type<EmbedContent, unknown, unknown>;
121
+ data: t.Type<import("../EmbedContent").EmbedContentO, unknown, unknown>;
123
122
  }>, t.PartialC<{
124
123
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
125
124
  direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -244,7 +243,7 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
244
243
  direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
245
244
  }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
246
245
  type: t.LiteralC<"embed">;
247
- data: t.Type<EmbedContent, unknown, unknown>;
246
+ data: t.Type<import("../EmbedContent").EmbedContentO, unknown, unknown>;
248
247
  }>, t.PartialC<{
249
248
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
250
249
  direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1,11 +1,15 @@
1
- import * as E from "fp-ts/lib/Either";
2
- import * as t from "io-ts";
3
- import { StringOrNull } from "../../../../validators";
4
- import { nullable, refineType } from "../../../../validators/function";
5
- import EmbedContent from "../EmbedContent";
6
- import { ImageContentView } from "../ImageContent";
7
- import { Link } from "../Link";
8
- export const Meta = t.exact(t.intersection([
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Block = exports.TextBlock = exports.checkEmbedBlock = exports.EmbedBlock = exports.EmbedBlockType = exports.checkImageBlock = exports.ImageBlock = exports.ImageBlockType = exports.ValidatedMetas = exports.Meta = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const E = (0, tslib_1.__importStar)(require("fp-ts/lib/Either"));
6
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
7
+ const validators_1 = require("../../../../validators");
8
+ const function_1 = require("../../../../validators/function");
9
+ const EmbedContent_1 = require("../EmbedContent");
10
+ const ImageContent_1 = require("../ImageContent");
11
+ const Link_1 = require("../Link");
12
+ exports.Meta = t.exact(t.intersection([
9
13
  t.partial({
10
14
  data: t.unknown,
11
15
  }),
@@ -15,17 +19,17 @@ export const Meta = t.exact(t.intersection([
15
19
  type: t.string,
16
20
  }),
17
21
  ]));
18
- export const ValidatedMetas = new t.Type("ValidatedMetas", (metas) => Array.isArray(metas) && metas.every(Meta.is), (metas, c) => {
22
+ exports.ValidatedMetas = new t.Type("ValidatedMetas", (metas) => Array.isArray(metas) && metas.every(exports.Meta.is), (metas, c) => {
19
23
  if (Array.isArray(metas)) {
20
24
  const res = metas
21
25
  .reduce((acc, maybeMeta) => {
22
- const maybeDecodedMeta = Meta.decode(maybeMeta);
26
+ const maybeDecodedMeta = exports.Meta.decode(maybeMeta);
23
27
  if (E.isRight(maybeDecodedMeta)) {
24
28
  const meta = maybeDecodedMeta.right;
25
29
  // if it's an hyperlink it should have data validated as link otherwise we don't care and keep the meta
26
30
  if ((meta.data &&
27
31
  meta.type === "hyperlink" &&
28
- E.isRight(Link.validate(meta.data, c))) ||
32
+ E.isRight(Link_1.Link.validate(meta.data, c))) ||
29
33
  meta.type !== "hyperlink") {
30
34
  return [...acc, meta];
31
35
  }
@@ -37,49 +41,51 @@ export const ValidatedMetas = new t.Type("ValidatedMetas", (metas) => Array.isAr
37
41
  }
38
42
  else
39
43
  return t.failure(metas, c);
40
- }, (m) => t.array(Meta).encode(m));
41
- export const ImageBlockType = "image";
42
- export const ImageBlock = t.exact(t.intersection([
44
+ }, (m) => t.array(exports.Meta).encode(m));
45
+ exports.ImageBlockType = "image";
46
+ exports.ImageBlock = t.exact(t.intersection([
43
47
  t.type({
44
- type: t.literal(ImageBlockType),
48
+ type: t.literal(exports.ImageBlockType),
45
49
  data: t.intersection([
46
- ImageContentView,
50
+ ImageContent_1.ImageContentView,
47
51
  t.partial({
48
- linkTo: nullable(Link),
52
+ linkTo: (0, function_1.nullable)(Link_1.Link),
49
53
  }),
50
54
  ]),
51
55
  }),
52
56
  t.partial({
53
- label: StringOrNull,
54
- direction: StringOrNull,
57
+ label: validators_1.StringOrNull,
58
+ direction: validators_1.StringOrNull,
55
59
  }),
56
60
  ]));
57
- export function checkImageBlock(block) {
58
- return block.type === ImageBlockType;
61
+ function checkImageBlock(block) {
62
+ return block.type === exports.ImageBlockType;
59
63
  }
60
- export const EmbedBlockType = "embed";
61
- export const EmbedBlock = t.exact(t.intersection([
64
+ exports.checkImageBlock = checkImageBlock;
65
+ exports.EmbedBlockType = "embed";
66
+ exports.EmbedBlock = t.exact(t.intersection([
62
67
  t.type({
63
- type: t.literal(EmbedBlockType),
64
- data: EmbedContent,
68
+ type: t.literal(exports.EmbedBlockType),
69
+ data: EmbedContent_1.EmbedContent,
65
70
  }),
66
71
  t.partial({
67
- label: StringOrNull,
68
- direction: StringOrNull,
72
+ label: validators_1.StringOrNull,
73
+ direction: validators_1.StringOrNull,
69
74
  }),
70
75
  ]));
71
- export function checkEmbedBlock(block) {
72
- return block.type === EmbedBlockType;
76
+ function checkEmbedBlock(block) {
77
+ return block.type === exports.EmbedBlockType;
73
78
  }
74
- export const TextBlock = t.exact(t.intersection([
79
+ exports.checkEmbedBlock = checkEmbedBlock;
80
+ exports.TextBlock = t.exact(t.intersection([
75
81
  t.type({
76
- type: refineType(t.string, `string which isn't ${ImageBlockType} ${EmbedBlockType}`, (s) => s !== ImageBlockType && s !== EmbedBlockType),
82
+ type: (0, function_1.refineType)(t.string, `string which isn't ${exports.ImageBlockType} ${exports.EmbedBlockType}`, (s) => s !== exports.ImageBlockType && s !== exports.EmbedBlockType),
77
83
  content: t.intersection([
78
84
  t.type({
79
85
  text: t.string,
80
86
  }),
81
87
  t.partial({
82
- spans: ValidatedMetas,
88
+ spans: exports.ValidatedMetas,
83
89
  }),
84
90
  ]),
85
91
  }),
@@ -88,4 +94,4 @@ export const TextBlock = t.exact(t.intersection([
88
94
  direction: t.string,
89
95
  }),
90
96
  ]));
91
- export const Block = t.union([ImageBlock, EmbedBlock, TextBlock]);
97
+ exports.Block = t.union([exports.ImageBlock, exports.EmbedBlock, exports.TextBlock]);