@prismicio/types-internal 2.9.0-alpha.0 → 2.9.0-alpha.2

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 (42) hide show
  1. package/lib/content/Document.d.ts +19 -19
  2. package/lib/content/Document.js +11 -0
  3. package/lib/content/LegacyContentCtx.d.ts +2 -17
  4. package/lib/content/LegacyContentCtx.js +4 -1
  5. package/lib/content/fields/GroupContent.js +13 -0
  6. package/lib/content/fields/RepeatableContent.d.ts +4 -78
  7. package/lib/content/fields/RepeatableContent.js +10 -14
  8. package/lib/content/fields/WidgetContent.d.ts +18 -18
  9. package/lib/content/fields/index.d.ts +1 -0
  10. package/lib/content/fields/index.js +1 -0
  11. package/lib/content/fields/nestable/NestableContent.d.ts +6 -6
  12. package/lib/content/fields/nestable/NestableContent.js +5 -17
  13. package/lib/content/fields/nestable/RichTextContent/TextBlock.d.ts +727 -0
  14. package/lib/content/fields/nestable/RichTextContent/TextBlock.js +80 -0
  15. package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +6 -6
  16. package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +1 -1
  17. package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +6 -6
  18. package/lib/content/fields/slices/Slice/SharedSliceContent.js +20 -4
  19. package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +5 -5
  20. package/lib/content/fields/slices/Slice/SlicePrimaryContent.d.ts +5 -5
  21. package/lib/content/fields/slices/Slice/index.d.ts +10 -10
  22. package/lib/content/fields/slices/SliceItem.d.ts +10 -10
  23. package/lib/content/fields/slices/SlicesContent.d.ts +15 -15
  24. package/lib/customtypes/widgets/Widget.d.ts +0 -15
  25. package/lib/customtypes/widgets/Widget.js +0 -15
  26. package/lib/customtypes/widgets/nestable/Link.d.ts +8 -0
  27. package/lib/customtypes/widgets/nestable/Link.js +6 -5
  28. package/lib/customtypes/widgets/nestable/NestableWidget.d.ts +1 -2
  29. package/lib/customtypes/widgets/nestable/NestableWidget.js +1 -18
  30. package/lib/customtypes/widgets/slices/SliceWidget.d.ts +327 -0
  31. package/lib/customtypes/widgets/slices/SliceWidget.js +8 -0
  32. package/package.json +1 -1
  33. package/src/content/Document.ts +12 -0
  34. package/src/content/LegacyContentCtx.ts +4 -1
  35. package/src/content/fields/GroupContent.ts +13 -0
  36. package/src/content/fields/RepeatableContent.ts +29 -38
  37. package/src/content/fields/index.ts +1 -0
  38. package/src/content/fields/nestable/NestableContent.ts +6 -20
  39. package/src/content/fields/slices/Slice/SharedSliceContent.ts +18 -0
  40. package/src/customtypes/widgets/Widget.ts +0 -15
  41. package/src/customtypes/widgets/nestable/Link.ts +7 -5
  42. package/src/customtypes/widgets/nestable/NestableWidget.ts +16 -34
@@ -1,5 +1,5 @@
1
1
  import * as t from "io-ts";
2
- import { type NestableWidget } from "../../../customtypes";
2
+ import type { NestableWidget } from "../../../customtypes";
3
3
  import type { LegacyContentCtx } from "../../LegacyContentCtx";
4
4
  export declare const NestableContent: t.UnionC<[t.ExactC<t.TypeC<{
5
5
  type: t.StringC;
@@ -424,7 +424,7 @@ export declare const NestableContent: t.UnionC<[t.ExactC<t.TypeC<{
424
424
  __TYPE__: t.LiteralC<"SeparatorContent">;
425
425
  }>>, t.ExactC<t.TypeC<{
426
426
  __TYPE__: t.LiteralC<"RepeatableContent">;
427
- type: t.UnionC<[t.LiteralC<"Color">, t.LiteralC<"Boolean">, t.LiteralC<"Embed">, t.LiteralC<"GeoPoint">, t.LiteralC<"Date">, t.LiteralC<"Number">, t.LiteralC<"Range">, t.LiteralC<"StructuredText">, t.LiteralC<"Select">, t.LiteralC<"Separator">, t.LiteralC<"Text">, t.LiteralC<"Timestamp">, t.LiteralC<"Link">, t.LiteralC<"Image">, t.LiteralC<"IntegrationFields">]>;
427
+ type: t.LiteralC<"Link">;
428
428
  value: t.ArrayC<t.ExactC<t.TypeC<{
429
429
  __TYPE__: t.LiteralC<"LinkContent">;
430
430
  value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
@@ -682,7 +682,7 @@ export declare const isNestableContent: (u: unknown) => u is {
682
682
  });
683
683
  } | {
684
684
  __TYPE__: "RepeatableContent";
685
- type: "Boolean" | "Color" | "Date" | "Embed" | "GeoPoint" | "Image" | "IntegrationFields" | "Link" | "Number" | "Range" | "StructuredText" | "Select" | "Separator" | "Text" | "Timestamp";
685
+ type: "Link";
686
686
  value: {
687
687
  __TYPE__: "LinkContent";
688
688
  value: ({
@@ -909,7 +909,7 @@ export declare const isNestableContent: (u: unknown) => u is {
909
909
  __TYPE__: "SeparatorContent";
910
910
  };
911
911
  export declare const NestableLegacy: (ctx: LegacyContentCtx) => {
912
- decode(value: unknown): import("fp-ts/lib/Either").Right<{
912
+ decode(value: unknown): import("fp-ts/lib/Either").Left<t.Errors> | import("fp-ts/lib/Either").Right<{
913
913
  type: string;
914
914
  __TYPE__: "EmptyContent";
915
915
  }> | import("fp-ts/lib/Either").Right<{
@@ -1089,9 +1089,9 @@ export declare const NestableLegacy: (ctx: LegacyContentCtx) => {
1089
1089
  } & {
1090
1090
  text: string;
1091
1091
  });
1092
- }> | t.Validation<{
1092
+ }> | import("fp-ts/lib/Either").Right<{
1093
1093
  __TYPE__: "RepeatableContent";
1094
- type: "Boolean" | "Color" | "Date" | "Embed" | "GeoPoint" | "Image" | "IntegrationFields" | "Link" | "Number" | "Range" | "StructuredText" | "Select" | "Separator" | "Text" | "Timestamp";
1094
+ type: "Link";
1095
1095
  value: {
1096
1096
  __TYPE__: "LinkContent";
1097
1097
  value: ({
@@ -4,7 +4,6 @@ exports.NestableLegacy = exports.isNestableContent = exports.NestableContentDefa
4
4
  const tslib_1 = require("tslib");
5
5
  const Either_1 = require("fp-ts/lib/Either");
6
6
  const t = (0, tslib_1.__importStar)(require("io-ts"));
7
- const customtypes_1 = require("../../../customtypes");
8
7
  const EmptyContent_1 = require("../EmptyContent");
9
8
  const RepeatableContent_1 = require("../RepeatableContent");
10
9
  const BooleanContent_1 = require("./BooleanContent");
@@ -68,18 +67,13 @@ exports.isNestableContent = isNestableContent;
68
67
  const NestableLegacy = (ctx) => {
69
68
  return {
70
69
  decode(value) {
71
- var _a, _b;
72
70
  if (!ctx.fieldType)
73
71
  return;
74
72
  const nullValue = (0, EmptyContent_1.EmptyLegacy)(ctx.fieldType).decode(value);
75
73
  if ((0, Either_1.isRight)(nullValue))
76
74
  return nullValue;
77
- const fieldTypeSplit = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.fieldType) === null || _a === void 0 ? void 0 : _a.split(".");
78
- const fieldType = (_b = fieldTypeSplit === null || fieldTypeSplit === void 0 ? void 0 : fieldTypeSplit[1]) !== null && _b !== void 0 ? _b : ctx.fieldType;
79
- if (!customtypes_1.NestableFieldTypes.is(fieldType))
80
- return;
81
75
  const codec = (() => {
82
- switch (fieldType) {
76
+ switch (ctx.fieldType) {
83
77
  case "Text":
84
78
  return (0, FieldContent_1.TextLegacy)(ctx);
85
79
  case "Color":
@@ -110,25 +104,17 @@ const NestableLegacy = (ctx) => {
110
104
  return (0, LinkContent_1.LinkContentLegacy)(ctx);
111
105
  case "Separator":
112
106
  return (0, SeparatorContent_1.SeparatorLegacy)(ctx);
107
+ case "Repeatable.Link":
108
+ return (0, RepeatableContent_1.RepeatableLegacy)(ctx, "Link");
113
109
  default:
114
110
  return;
115
111
  }
116
112
  })();
117
113
  if (!codec)
118
114
  return;
119
- // We check if the Nestable Content is repeated. If so, we decode each
120
- // item in the array using the specific codec for the repeated content.
121
- if ((fieldTypeSplit === null || fieldTypeSplit === void 0 ? void 0 : fieldTypeSplit[0]) === "Repeatable") {
122
- return (0, RepeatableContent_1.RepeatableLegacy)(ctx, fieldType).decode(value);
123
- }
124
115
  return codec.decode(value);
125
116
  },
126
117
  encode(value) {
127
- // We check if the Nestable Content is repeated. If so, we decode each
128
- // item in the array using the specific codec for the repeated content.
129
- if (value.__TYPE__ === RepeatableContent_1.RepeatableContentType) {
130
- return (0, RepeatableContent_1.RepeatableLegacy)(ctx, value.type).encode(value);
131
- }
132
118
  switch (value.__TYPE__) {
133
119
  case common_1.FieldContentType: {
134
120
  if (value.type === "Text")
@@ -163,6 +149,8 @@ const NestableLegacy = (ctx) => {
163
149
  return (0, LinkContent_1.LinkContentLegacy)(ctx).encode(value);
164
150
  case SeparatorContent_1.SeparatorContentType:
165
151
  return (0, SeparatorContent_1.SeparatorLegacy)(ctx).encode(value);
152
+ case "RepeatableContent":
153
+ return (0, RepeatableContent_1.RepeatableLegacy)(ctx, value.type).encode(value);
166
154
  default:
167
155
  return;
168
156
  }