@prismicio/types-internal 3.1.0 → 3.2.0-alpha.0

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.
@@ -5,12 +5,14 @@ import type { LegacyContentCtx, WithTypes } from "../LegacyContentCtx";
5
5
  export declare const RepeatableContent: t.ExactC<t.TypeC<{
6
6
  __TYPE__: t.LiteralC<"RepeatableContent">;
7
7
  type: t.LiteralC<"Link">;
8
- value: t.ArrayC<t.ExactC<t.TypeC<{
8
+ value: t.ArrayC<t.IntersectionC<[t.ExactC<t.TypeC<{
9
+ key: t.Type<string, string, unknown>;
10
+ }>>, t.ExactC<t.TypeC<{
9
11
  __TYPE__: t.LiteralC<"LinkContent">;
10
12
  value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
11
13
  __TYPE__: t.LiteralC<"ImageLink">;
12
- }>>, t.UnionC<[t.IntersectionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
13
- kind: t.StringC;
14
+ }>>, t.IntersectionC<[t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
15
+ kind: t.Type<"image", "image", unknown>;
14
16
  id: t.StringC;
15
17
  url: t.StringC;
16
18
  height: t.StringC;
@@ -19,38 +21,35 @@ export declare const RepeatableContent: t.ExactC<t.TypeC<{
19
21
  name: t.StringC;
20
22
  }>>, t.ExactC<t.PartialC<{
21
23
  date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
22
- }>>]>, t.ExactC<t.PartialC<{
23
- text: t.StringC;
24
24
  }>>]>, t.ExactC<t.TypeC<{
25
25
  kind: t.LiteralC<"image">;
26
+ }>>]>, t.ExactC<t.PartialC<{
26
27
  text: t.StringC;
27
28
  }>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
28
29
  __TYPE__: t.LiteralC<"FileLink">;
29
- }>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
30
- kind: t.StringC;
30
+ }>>, t.IntersectionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
31
+ kind: t.Type<"file", "file", unknown>;
31
32
  id: t.StringC;
32
33
  url: t.StringC;
33
34
  name: t.StringC;
34
35
  size: t.StringC;
35
36
  }>, t.PartialC<{
36
37
  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<{
38
+ }>]>>, t.ExactC<t.TypeC<{
40
39
  kind: t.LiteralC<"file">;
40
+ }>>]>, t.ExactC<t.PartialC<{
41
41
  text: t.StringC;
42
42
  }>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
43
43
  __TYPE__: t.LiteralC<"DocumentLink">;
44
- }>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
44
+ }>>, t.IntersectionC<[t.UnionC<[t.ExactC<t.TypeC<{
45
45
  id: t.Type<string, string, unknown>;
46
- }>>, t.ExactC<t.PartialC<{
47
- text: t.StringC;
48
- }>>]>, t.ExactC<t.TypeC<{
46
+ }>>, t.ExactC<t.TypeC<{
49
47
  kind: t.LiteralC<"document">;
48
+ }>>]>, t.ExactC<t.PartialC<{
50
49
  text: t.StringC;
51
50
  }>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
52
51
  __TYPE__: t.LiteralC<"ExternalLink">;
53
- }>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
52
+ }>>, t.IntersectionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
54
53
  url: t.StringC;
55
54
  }>, t.PartialC<{
56
55
  kind: t.LiteralC<"web">;
@@ -60,33 +59,37 @@ export declare const RepeatableContent: t.ExactC<t.TypeC<{
60
59
  }, {
61
60
  title?: string;
62
61
  }, unknown>, t.NullC, t.UndefinedC]>;
63
- }>]>>, t.ExactC<t.PartialC<{
64
- text: t.StringC;
65
- }>>]>, t.ExactC<t.TypeC<{
62
+ }>]>>, t.ExactC<t.TypeC<{
66
63
  kind: t.LiteralC<"web">;
64
+ }>>]>, t.ExactC<t.PartialC<{
67
65
  text: t.StringC;
68
66
  }>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
69
67
  __TYPE__: t.LiteralC<"MediaLink">;
70
- }>>, t.ExactC<t.TypeC<{
68
+ }>>, t.IntersectionC<[t.ExactC<t.TypeC<{
71
69
  kind: t.LiteralC<"media">;
70
+ }>>, t.ExactC<t.PartialC<{
72
71
  text: t.StringC;
73
- }>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
72
+ }>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
74
73
  __TYPE__: t.LiteralC<"AnyLink">;
75
- }>>, t.ExactC<t.TypeC<{
74
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
75
+ kind: t.LiteralC<"any">;
76
+ }>, t.PartialC<{
76
77
  text: t.StringC;
77
- }>>]>]>;
78
- }>>>;
78
+ }>]>>]>]>;
79
+ }>>]>>;
79
80
  }>>;
80
81
  export declare type RepeatableContent = t.TypeOf<typeof RepeatableContent>;
81
82
  export declare const isRepeatableContent: t.Is<{
82
83
  __TYPE__: "RepeatableContent";
83
84
  type: "Link";
84
- value: {
85
+ value: ({
86
+ key: string;
87
+ } & {
85
88
  __TYPE__: "LinkContent";
86
89
  value: ({
87
90
  __TYPE__: "ImageLink";
88
- } & (({
89
- kind: string;
91
+ } & ((({
92
+ kind: "image";
90
93
  id: string;
91
94
  url: string;
92
95
  height: string;
@@ -95,43 +98,41 @@ export declare const isRepeatableContent: t.Is<{
95
98
  name: string;
96
99
  } & {
97
100
  date?: string | null | undefined;
98
- } & {
99
- text?: string;
100
101
  }) | {
101
102
  kind: "image";
102
- text: string;
103
+ }) & {
104
+ text?: string;
103
105
  })) | ({
104
106
  __TYPE__: "FileLink";
105
- } & (({
106
- kind: string;
107
+ } & ((({
108
+ kind: "file";
107
109
  id: string;
108
110
  url: string;
109
111
  name: string;
110
112
  size: string;
111
113
  } & {
112
114
  date?: string | null | undefined;
113
- } & {
114
- text?: string;
115
115
  }) | {
116
116
  kind: "file";
117
- text: string;
117
+ }) & {
118
+ text?: string;
118
119
  })) | ({
119
120
  __TYPE__: "MediaLink";
120
121
  } & {
121
122
  kind: "media";
122
- text: string;
123
+ } & {
124
+ text?: string;
123
125
  }) | ({
124
126
  __TYPE__: "DocumentLink";
125
127
  } & (({
126
128
  id: string;
127
- } & {
128
- text?: string;
129
- }) | {
129
+ } | {
130
130
  kind: "document";
131
- text: string;
131
+ }) & {
132
+ text?: string;
132
133
  })) | ({
133
134
  __TYPE__: "ExternalLink";
134
- } & (({
135
+ } & ((({
135
136
  url: string;
136
137
  } & {
137
138
  kind?: "web";
@@ -139,17 +140,18 @@ export declare const isRepeatableContent: t.Is<{
139
140
  preview?: {
140
141
  title?: string;
141
142
  } | null | undefined;
142
- } & {
143
- text?: string;
144
143
  }) | {
145
144
  kind: "web";
146
- text: string;
145
+ }) & {
146
+ text?: string;
147
147
  })) | ({
148
148
  __TYPE__: "AnyLink";
149
149
  } & {
150
- text: string;
150
+ kind: "any";
151
+ } & {
152
+ text?: string;
151
153
  });
152
- }[];
154
+ })[];
153
155
  }>;
154
156
  export declare const RepeatableLegacy: (ctx: LegacyContentCtx, fieldType: "Link") => t.Type<RepeatableContent, WithTypes<Array<unknown>>, unknown>;
155
157
  export declare type RepeatableCustomType = Link;
@@ -62,11 +62,15 @@ function traverseRepeatableContent({ path, key, apiId, model, content, }) {
62
62
  const itemPath = path.concat([
63
63
  { key: index.toString(), type: "Widget" },
64
64
  ]);
65
+ const overriddenModel = model;
66
+ if ((overriddenModel === null || overriddenModel === void 0 ? void 0 : overriddenModel.config) && overriddenModel.type === "Link") {
67
+ overriddenModel.config.repeat = false;
68
+ }
65
69
  const transformedField = transform({
66
70
  path: itemPath,
67
71
  key: key,
68
72
  apiId: apiId,
69
- model: model,
73
+ model: overriddenModel,
70
74
  content: fieldContent,
71
75
  });
72
76
  // Can happen if the transform function returns undefined to filter out a field
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/types-internal",
3
- "version": "3.1.0",
3
+ "version": "3.2.0-alpha.0",
4
4
  "description": "Prismic types for Custom Types and Prismic Data",
5
5
  "keywords": [
6
6
  "typescript",
@@ -113,11 +113,16 @@ export function traverseRepeatableContent({
113
113
  { key: index.toString(), type: "Widget" },
114
114
  ])
115
115
 
116
+ const overriddenModel = model
117
+ if (overriddenModel?.config && overriddenModel.type === "Link") {
118
+ overriddenModel.config.repeat = false
119
+ }
120
+
116
121
  const transformedField = transform({
117
122
  path: itemPath,
118
123
  key: key,
119
124
  apiId: apiId,
120
- model: model,
125
+ model: overriddenModel,
121
126
  content: fieldContent,
122
127
  })
123
128