@prismicio/types-internal 3.0.0 → 3.1.0-alpha.1

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 (53) hide show
  1. package/lib/_internal/utils.d.ts +3 -2
  2. package/lib/content/Document.d.ts +1561 -361
  3. package/lib/content/Document.js +11 -0
  4. package/lib/content/LegacyContentCtx.d.ts +2 -2
  5. package/lib/content/LegacyContentCtx.js +4 -1
  6. package/lib/content/fields/GroupContent.js +13 -0
  7. package/lib/content/fields/RepeatableContent.d.ts +34 -40
  8. package/lib/content/fields/WidgetContent.d.ts +1558 -358
  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/LinkContent.d.ts +122 -146
  12. package/lib/content/fields/nestable/LinkContent.js +19 -39
  13. package/lib/content/fields/nestable/NestableContent.d.ts +254 -54
  14. package/lib/content/fields/nestable/NestableContent.js +8 -1
  15. package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +66 -66
  16. package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +510 -110
  17. package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +86 -18
  18. package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +512 -112
  19. package/lib/content/fields/slices/Slice/SharedSliceContent.js +20 -4
  20. package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +255 -55
  21. package/lib/content/fields/slices/Slice/SlicePrimaryContent.d.ts +255 -55
  22. package/lib/content/fields/slices/Slice/index.d.ts +855 -185
  23. package/lib/content/fields/slices/SliceItem.d.ts +854 -184
  24. package/lib/content/fields/slices/SlicesContent.d.ts +1278 -278
  25. package/lib/customtypes/CustomType.d.ts +18 -0
  26. package/lib/customtypes/Section.d.ts +18 -0
  27. package/lib/customtypes/diff/SharedSlice.d.ts +8 -0
  28. package/lib/customtypes/diff/Variation.d.ts +8 -0
  29. package/lib/customtypes/widgets/Group.d.ts +6 -0
  30. package/lib/customtypes/widgets/Widget.d.ts +21 -0
  31. package/lib/customtypes/widgets/nestable/Link.d.ts +10 -0
  32. package/lib/customtypes/widgets/nestable/Link.js +5 -0
  33. package/lib/customtypes/widgets/nestable/NestableWidget.d.ts +1 -0
  34. package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +2 -0
  35. package/lib/customtypes/widgets/slices/LegacySlice.d.ts +2 -0
  36. package/lib/customtypes/widgets/slices/SharedSlice.d.ts +8 -0
  37. package/lib/customtypes/widgets/slices/SlicePrimaryWidget.d.ts +6 -0
  38. package/lib/customtypes/widgets/slices/Slices.d.ts +28 -0
  39. package/package.json +2 -1
  40. package/src/_internal/utils.ts +3 -1
  41. package/src/content/Document.ts +12 -0
  42. package/src/content/LegacyContentCtx.ts +4 -1
  43. package/src/content/fields/GroupContent.ts +13 -0
  44. package/src/content/fields/RepeatableContent.ts +147 -0
  45. package/src/content/fields/index.ts +1 -0
  46. package/src/content/fields/nestable/LinkContent.ts +19 -39
  47. package/src/content/fields/nestable/NestableContent.ts +12 -1
  48. package/src/content/fields/slices/Slice/SharedSliceContent.ts +18 -0
  49. package/src/customtypes/widgets/nestable/Link.ts +6 -0
  50. package/lib/content/fields/nestable/RichTextContent/TextBlock.d.ts +0 -727
  51. package/lib/content/fields/nestable/RichTextContent/TextBlock.js +0 -80
  52. package/lib/customtypes/widgets/slices/SliceWidget.d.ts +0 -327
  53. package/lib/customtypes/widgets/slices/SliceWidget.js +0 -8
@@ -158,6 +158,7 @@ function traverseDocument({ document, customType, }) {
158
158
  { key, type: "Widget" },
159
159
  ]);
160
160
  const transformedWidget = (() => {
161
+ var _a;
161
162
  switch (content.__TYPE__) {
162
163
  case "SliceContentType":
163
164
  return (0, fields_1.traverseSlices)({
@@ -176,6 +177,16 @@ function traverseDocument({ document, customType, }) {
176
177
  model: (fieldModel === null || fieldModel === void 0 ? void 0 : fieldModel.type) === "Group" ? fieldModel : undefined,
177
178
  content,
178
179
  })(transformWidget);
180
+ case "RepeatableContent":
181
+ return (0, fields_1.traverseRepeatableContent)({
182
+ path,
183
+ key,
184
+ apiId: key,
185
+ model: (fieldModel === null || fieldModel === void 0 ? void 0 : fieldModel.type) === "Link" && ((_a = fieldModel.config) === null || _a === void 0 ? void 0 : _a.repeat)
186
+ ? fieldModel
187
+ : undefined,
188
+ content,
189
+ })(transformWidget);
179
190
  default:
180
191
  return transformWidget({
181
192
  path,
@@ -1,5 +1,5 @@
1
1
  import * as t from "io-ts";
2
- export declare const FieldOrSliceType: t.UnionC<[t.KeyofC<{
2
+ export declare const FieldOrSliceType: t.UnionC<[t.UnionC<[t.KeyofC<{
3
3
  Color: null;
4
4
  Boolean: null;
5
5
  Number: null;
@@ -22,7 +22,7 @@ export declare const FieldOrSliceType: t.UnionC<[t.KeyofC<{
22
22
  }>, t.KeyofC<{
23
23
  Slice: null;
24
24
  SharedSlice: null;
25
- }>]>;
25
+ }>]>, t.LiteralC<"Repeatable.Link">]>;
26
26
  export declare type FieldOrSliceType = t.TypeOf<typeof FieldOrSliceType>;
27
27
  export declare class LegacyContentCtx {
28
28
  fieldKey: string;
@@ -4,7 +4,10 @@ exports.defaultCtx = exports.getFieldCtx = exports.LegacyContentCtx = exports.Fi
4
4
  const tslib_1 = require("tslib");
5
5
  const t = (0, tslib_1.__importStar)(require("io-ts"));
6
6
  const widgets_1 = require("../customtypes/widgets");
7
- exports.FieldOrSliceType = t.union([widgets_1.FieldType, widgets_1.SlicesTypes]);
7
+ exports.FieldOrSliceType = t.union([
8
+ t.union([widgets_1.FieldType, widgets_1.SlicesTypes]),
9
+ t.literal("Repeatable.Link"),
10
+ ]);
8
11
  class LegacyContentCtx {
9
12
  constructor(fieldKey, fieldPath, allTypes) {
10
13
  Object.defineProperty(this, "fieldKey", {
@@ -10,6 +10,7 @@ const customtypes_1 = require("../../customtypes");
10
10
  const LegacyContentCtx_1 = require("../LegacyContentCtx");
11
11
  const utils_1 = require("../utils");
12
12
  const nestable_1 = require("./nestable");
13
+ const RepeatableContent_1 = require("./RepeatableContent");
13
14
  const withDefaultValues_1 = require("./withDefaultValues");
14
15
  exports.GroupItemContentType = "GroupItemContent";
15
16
  exports.GroupContentType = "GroupContentType";
@@ -129,6 +130,7 @@ function traverseGroupItemsContent({ path, model, content, }) {
129
130
  { key: index.toString(), type: "GroupItem" },
130
131
  ]);
131
132
  const groupItemFields = groupItem.value.reduce((acc, [fieldKey, fieldContent]) => {
133
+ var _a;
132
134
  const fieldDef = model === null || model === void 0 ? void 0 : model[fieldKey];
133
135
  let transformedField;
134
136
  if ((!fieldDef || (fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.type) === customtypes_1.GroupFieldType) &&
@@ -141,6 +143,17 @@ function traverseGroupItemsContent({ path, model, content, }) {
141
143
  content: fieldContent,
142
144
  })(transform);
143
145
  }
146
+ else if ((!fieldDef ||
147
+ ((fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.type) === "Link" && ((_a = fieldDef.config) === null || _a === void 0 ? void 0 : _a.repeat))) &&
148
+ fieldContent.__TYPE__ === "RepeatableContent") {
149
+ transformedField = (0, RepeatableContent_1.traverseRepeatableContent)({
150
+ path: groupItemPath.concat([{ key: fieldKey, type: "Widget" }]),
151
+ key: fieldKey,
152
+ apiId: fieldKey,
153
+ model: fieldDef,
154
+ content: fieldContent,
155
+ })(transform);
156
+ }
144
157
  else {
145
158
  transformedField = transform({
146
159
  path: groupItemPath.concat([{ key: fieldKey, type: "Widget" }]),
@@ -9,8 +9,8 @@ export declare const RepeatableContent: t.ExactC<t.TypeC<{
9
9
  __TYPE__: t.LiteralC<"LinkContent">;
10
10
  value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
11
11
  __TYPE__: t.LiteralC<"ImageLink">;
12
- }>>, t.UnionC<[t.IntersectionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
13
- kind: t.StringC;
12
+ }>>, t.IntersectionC<[t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
13
+ kind: t.Type<"image", "image", unknown>;
14
14
  id: t.StringC;
15
15
  url: t.StringC;
16
16
  height: t.StringC;
@@ -19,38 +19,35 @@ export declare const RepeatableContent: t.ExactC<t.TypeC<{
19
19
  name: t.StringC;
20
20
  }>>, t.ExactC<t.PartialC<{
21
21
  date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
22
- }>>]>, t.ExactC<t.PartialC<{
23
- text: t.StringC;
24
22
  }>>]>, t.ExactC<t.TypeC<{
25
23
  kind: t.LiteralC<"image">;
24
+ }>>]>, t.ExactC<t.PartialC<{
26
25
  text: t.StringC;
27
26
  }>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
28
27
  __TYPE__: t.LiteralC<"FileLink">;
29
- }>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
30
- kind: t.StringC;
28
+ }>>, t.IntersectionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
29
+ kind: t.Type<"file", "file", unknown>;
31
30
  id: t.StringC;
32
31
  url: t.StringC;
33
32
  name: t.StringC;
34
33
  size: t.StringC;
35
34
  }>, t.PartialC<{
36
35
  date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
37
- }>]>>, t.ExactC<t.PartialC<{
38
- text: t.StringC;
39
- }>>]>, t.ExactC<t.TypeC<{
36
+ }>]>>, t.ExactC<t.TypeC<{
40
37
  kind: t.LiteralC<"file">;
38
+ }>>]>, t.ExactC<t.PartialC<{
41
39
  text: t.StringC;
42
40
  }>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
43
41
  __TYPE__: t.LiteralC<"DocumentLink">;
44
- }>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
42
+ }>>, t.IntersectionC<[t.UnionC<[t.ExactC<t.TypeC<{
45
43
  id: t.Type<string, string, unknown>;
46
- }>>, t.ExactC<t.PartialC<{
47
- text: t.StringC;
48
- }>>]>, t.ExactC<t.TypeC<{
44
+ }>>, t.ExactC<t.TypeC<{
49
45
  kind: t.LiteralC<"document">;
46
+ }>>]>, t.ExactC<t.PartialC<{
50
47
  text: t.StringC;
51
48
  }>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
52
49
  __TYPE__: t.LiteralC<"ExternalLink">;
53
- }>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
50
+ }>>, t.IntersectionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
54
51
  url: t.StringC;
55
52
  }>, t.PartialC<{
56
53
  kind: t.LiteralC<"web">;
@@ -60,19 +57,19 @@ export declare const RepeatableContent: t.ExactC<t.TypeC<{
60
57
  }, {
61
58
  title?: string;
62
59
  }, unknown>, t.NullC, t.UndefinedC]>;
63
- }>]>>, t.ExactC<t.PartialC<{
64
- text: t.StringC;
65
- }>>]>, t.ExactC<t.TypeC<{
60
+ }>]>>, t.ExactC<t.TypeC<{
66
61
  kind: t.LiteralC<"web">;
62
+ }>>]>, t.ExactC<t.PartialC<{
67
63
  text: t.StringC;
68
64
  }>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
69
65
  __TYPE__: t.LiteralC<"MediaLink">;
70
- }>>, t.ExactC<t.TypeC<{
66
+ }>>, t.IntersectionC<[t.ExactC<t.TypeC<{
71
67
  kind: t.LiteralC<"media">;
68
+ }>>, t.ExactC<t.PartialC<{
72
69
  text: t.StringC;
73
- }>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
70
+ }>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
74
71
  __TYPE__: t.LiteralC<"AnyLink">;
75
- }>>, t.ExactC<t.TypeC<{
72
+ }>>, t.ExactC<t.PartialC<{
76
73
  text: t.StringC;
77
74
  }>>]>]>;
78
75
  }>>>;
@@ -85,8 +82,8 @@ export declare const isRepeatableContent: t.Is<{
85
82
  __TYPE__: "LinkContent";
86
83
  value: ({
87
84
  __TYPE__: "ImageLink";
88
- } & (({
89
- kind: string;
85
+ } & ((({
86
+ kind: "image";
90
87
  id: string;
91
88
  url: string;
92
89
  height: string;
@@ -95,43 +92,41 @@ export declare const isRepeatableContent: t.Is<{
95
92
  name: string;
96
93
  } & {
97
94
  date?: string | null | undefined;
98
- } & {
99
- text?: string;
100
95
  }) | {
101
96
  kind: "image";
102
- text: string;
97
+ }) & {
98
+ text?: string;
103
99
  })) | ({
104
100
  __TYPE__: "FileLink";
105
- } & (({
106
- kind: string;
101
+ } & ((({
102
+ kind: "file";
107
103
  id: string;
108
104
  url: string;
109
105
  name: string;
110
106
  size: string;
111
107
  } & {
112
108
  date?: string | null | undefined;
113
- } & {
114
- text?: string;
115
109
  }) | {
116
110
  kind: "file";
117
- text: string;
111
+ }) & {
112
+ text?: string;
118
113
  })) | ({
119
114
  __TYPE__: "MediaLink";
120
115
  } & {
121
116
  kind: "media";
122
- text: string;
117
+ } & {
118
+ text?: string;
123
119
  }) | ({
124
120
  __TYPE__: "DocumentLink";
125
121
  } & (({
126
122
  id: string;
127
- } & {
128
- text?: string;
129
- }) | {
123
+ } | {
130
124
  kind: "document";
131
- text: string;
125
+ }) & {
126
+ text?: string;
132
127
  })) | ({
133
128
  __TYPE__: "ExternalLink";
134
- } & (({
129
+ } & ((({
135
130
  url: string;
136
131
  } & {
137
132
  kind?: "web";
@@ -139,15 +134,14 @@ export declare const isRepeatableContent: t.Is<{
139
134
  preview?: {
140
135
  title?: string;
141
136
  } | null | undefined;
142
- } & {
143
- text?: string;
144
137
  }) | {
145
138
  kind: "web";
146
- text: string;
139
+ }) & {
140
+ text?: string;
147
141
  })) | ({
148
142
  __TYPE__: "AnyLink";
149
143
  } & {
150
- text: string;
144
+ text?: string;
151
145
  });
152
146
  }[];
153
147
  }>;