@prismicio/types-internal 4.0.0-pr.6.09bccf8 → 4.0.0-pr.6.0ddf815
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.
- package/dist/content/codec/document.js +1 -1
- package/dist/content/codec/legacyContentCtx.d.ts.map +1 -1
- package/dist/content/codec/legacyContentCtx.js.map +1 -1
- package/dist/content/codec/slice.js.map +1 -1
- package/dist/content/slices.d.ts.map +1 -1
- package/dist/content/slices.js +4 -4
- package/dist/content/slices.js.map +1 -1
- package/dist/helpers/customTypeModel.d.ts.map +1 -1
- package/dist/helpers/customTypeModel.js.map +1 -1
- package/dist/helpers/documentContent.d.ts.map +1 -1
- package/dist/helpers/documentContent.js +1 -1
- package/dist/helpers/documentContent.js.map +1 -1
- package/dist/helpers/traverseContent.d.ts +6 -6
- package/dist/helpers/traverseContent.d.ts.map +1 -1
- package/dist/helpers/traverseContent.js +4 -4
- package/dist/helpers/traverseContent.js.map +1 -1
- package/dist/helpers/traverseContentWithModel.d.ts +6 -6
- package/dist/helpers/traverseContentWithModel.d.ts.map +1 -1
- package/dist/helpers/traverseContentWithModel.js +4 -4
- package/dist/helpers/traverseContentWithModel.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/io-ts.d.ts +3250 -1
- package/dist/io-ts.d.ts.map +1 -1
- package/dist/io-ts.js +7 -4
- package/dist/io-ts.js.map +1 -1
- package/dist/model/nestable.js +1 -1
- package/dist/model/widget.d.ts.map +1 -1
- package/dist/model/widget.js.map +1 -1
- package/dist/zod4.d.ts +2275 -1
- package/dist/zod4.d.ts.map +1 -1
- package/dist/zod4.js +7 -4
- package/dist/zod4.js.map +1 -1
- package/package.json +1 -1
- package/src/content/codec/legacyContentCtx.ts +1 -0
- package/src/content/codec/slice.ts +3 -1
- package/src/content/slices.ts +5 -3
- package/src/helpers/customTypeModel.ts +6 -3
- package/src/helpers/documentContent.ts +20 -22
- package/src/helpers/traverseContent.ts +36 -24
- package/src/helpers/traverseContentWithModel.ts +35 -21
- package/src/index.ts +7 -1
- package/src/io-ts.ts +15 -2
- package/src/model/widget.ts +2 -5
- package/src/zod4.ts +10 -1
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import type { StaticCustomTypeModel } from "../model/customType"
|
|
2
|
-
import type { GroupModel, NestedGroupModel } from "../model/group"
|
|
3
|
-
import type { LinkModel } from "../model/link"
|
|
4
|
-
import type { NestableModel } from "../model/nestable"
|
|
5
|
-
import type { CompositeSliceModel, LegacySliceModel, SharedSliceVariationModel } from "../model/slice"
|
|
6
|
-
import type { StaticSlicesModel } from "../model/slices"
|
|
7
|
-
import { TableCellModel } from "../model/table"
|
|
8
|
-
import type { TableModel } from "../model/table"
|
|
9
|
-
import type { StaticWidgetModel } from "../model/widget"
|
|
10
1
|
import type { DocumentContent } from "../content/document"
|
|
11
2
|
import { GroupContentType } from "../content/group"
|
|
12
3
|
import type { GroupContent, GroupItemContent } from "../content/group"
|
|
@@ -26,6 +17,19 @@ import {
|
|
|
26
17
|
} from "../content/slices"
|
|
27
18
|
import { TableContentType, type TableContent } from "../content/table"
|
|
28
19
|
import type { WidgetContent } from "../content/widget"
|
|
20
|
+
import type { StaticCustomTypeModel } from "../model/customType"
|
|
21
|
+
import type { GroupModel, NestedGroupModel } from "../model/group"
|
|
22
|
+
import type { LinkModel } from "../model/link"
|
|
23
|
+
import type { NestableModel } from "../model/nestable"
|
|
24
|
+
import type {
|
|
25
|
+
CompositeSliceModel,
|
|
26
|
+
LegacySliceModel,
|
|
27
|
+
SharedSliceVariationModel,
|
|
28
|
+
} from "../model/slice"
|
|
29
|
+
import type { StaticSlicesModel } from "../model/slices"
|
|
30
|
+
import { TableCellModel } from "../model/table"
|
|
31
|
+
import type { TableModel } from "../model/table"
|
|
32
|
+
import type { StaticWidgetModel } from "../model/widget"
|
|
29
33
|
import * as contentPath from "./contentPath"
|
|
30
34
|
import * as customTypeModel from "./customTypeModel"
|
|
31
35
|
|
|
@@ -162,8 +166,8 @@ export function traverseSlicesContentWithModel(
|
|
|
162
166
|
|
|
163
167
|
type TraverseSharedSliceContentWithModelConfig = {
|
|
164
168
|
model: SharedSliceVariationModel
|
|
165
|
-
transformWidget
|
|
166
|
-
transformSlice
|
|
169
|
+
transformWidget?: TraverseWidgetContentWithModelFunction
|
|
170
|
+
transformSlice?: TraverseSliceContentWithModelFunction
|
|
167
171
|
}
|
|
168
172
|
|
|
169
173
|
export function traverseSharedSliceContentWithModel(
|
|
@@ -173,12 +177,15 @@ export function traverseSharedSliceContentWithModel(
|
|
|
173
177
|
content: SharedSliceItemContent | undefined,
|
|
174
178
|
config: TraverseSharedSliceContentWithModelConfig,
|
|
175
179
|
): SharedSliceItemContent | undefined {
|
|
176
|
-
const { transformWidget, transformSlice } = config
|
|
177
|
-
|
|
178
180
|
if (!content) {
|
|
179
181
|
return
|
|
180
182
|
}
|
|
181
183
|
|
|
184
|
+
const {
|
|
185
|
+
transformWidget = (args) => args.content,
|
|
186
|
+
transformSlice = (args) => args.content
|
|
187
|
+
} = config
|
|
188
|
+
|
|
182
189
|
const traversedPrimary: SharedSliceContent["primary"] = {}
|
|
183
190
|
for (const [key, model] of Object.entries(config.model.fields.primary ?? {})) {
|
|
184
191
|
const traversedContent = traverseWidgetContentWithModel(
|
|
@@ -217,8 +224,8 @@ export function traverseSharedSliceContentWithModel(
|
|
|
217
224
|
|
|
218
225
|
type TraverseCompositeSliceContentWithModelConfig = {
|
|
219
226
|
model: CompositeSliceModel
|
|
220
|
-
transformWidget
|
|
221
|
-
transformSlice
|
|
227
|
+
transformWidget?: TraverseWidgetContentWithModelFunction
|
|
228
|
+
transformSlice?: TraverseSliceContentWithModelFunction
|
|
222
229
|
}
|
|
223
230
|
|
|
224
231
|
export function traverseCompositeSliceContentWithModel(
|
|
@@ -228,12 +235,15 @@ export function traverseCompositeSliceContentWithModel(
|
|
|
228
235
|
content: CompositeSliceItemContent | undefined,
|
|
229
236
|
config: TraverseCompositeSliceContentWithModelConfig,
|
|
230
237
|
): CompositeSliceItemContent | undefined {
|
|
231
|
-
const { transformWidget, transformSlice } = config
|
|
232
|
-
|
|
233
238
|
if (!content) {
|
|
234
239
|
return
|
|
235
240
|
}
|
|
236
241
|
|
|
242
|
+
const {
|
|
243
|
+
transformWidget = (args) => args.content,
|
|
244
|
+
transformSlice = (args) => args.content
|
|
245
|
+
} = config
|
|
246
|
+
|
|
237
247
|
const traversedPrimary: CompositeSliceContent["nonRepeat"] = {}
|
|
238
248
|
for (const [key, model] of Object.entries(config.model?.["non-repeat"] ?? {})) {
|
|
239
249
|
const traversedContent = traverseWidgetContentWithModel(
|
|
@@ -269,8 +279,8 @@ export function traverseCompositeSliceContentWithModel(
|
|
|
269
279
|
|
|
270
280
|
type TraverseLegacySliceContentWithModelConfig = {
|
|
271
281
|
model: LegacySliceModel
|
|
272
|
-
transformWidget
|
|
273
|
-
transformSlice
|
|
282
|
+
transformWidget?: TraverseWidgetContentWithModelFunction
|
|
283
|
+
transformSlice?: TraverseSliceContentWithModelFunction
|
|
274
284
|
}
|
|
275
285
|
|
|
276
286
|
export function traverseLegacySliceContentWithModel(
|
|
@@ -280,12 +290,16 @@ export function traverseLegacySliceContentWithModel(
|
|
|
280
290
|
content: LegacySliceItemContent | undefined,
|
|
281
291
|
config: TraverseLegacySliceContentWithModelConfig,
|
|
282
292
|
): LegacySliceItemContent | undefined {
|
|
283
|
-
const { model, transformWidget, transformSlice } = config
|
|
284
|
-
|
|
285
293
|
if (!content) {
|
|
286
294
|
return
|
|
287
295
|
}
|
|
288
296
|
|
|
297
|
+
const {
|
|
298
|
+
model,
|
|
299
|
+
transformWidget = (args) => args.content,
|
|
300
|
+
transformSlice = (args) => args.content
|
|
301
|
+
} = config
|
|
302
|
+
|
|
289
303
|
const traversedContent = traverseWidgetContentWithModel(path, key, apiID, content.widget, {
|
|
290
304
|
model,
|
|
291
305
|
transformWidget,
|
package/src/index.ts
CHANGED
|
@@ -35,7 +35,13 @@ export type {
|
|
|
35
35
|
SharedSliceContent,
|
|
36
36
|
SliceContent,
|
|
37
37
|
} from "./content/slice"
|
|
38
|
-
export type {
|
|
38
|
+
export type {
|
|
39
|
+
LegacySliceItemContent,
|
|
40
|
+
CompositeSliceItemContent,
|
|
41
|
+
SharedSliceItemContent,
|
|
42
|
+
SliceItemContent,
|
|
43
|
+
SlicesContent,
|
|
44
|
+
} from "./content/slices"
|
|
39
45
|
export type { TableContent } from "./content/table"
|
|
40
46
|
export type { UIDContent } from "./content/uid"
|
|
41
47
|
export type { WidgetContent } from "./content/widget"
|
package/src/io-ts.ts
CHANGED
|
@@ -70,7 +70,13 @@ import {
|
|
|
70
70
|
SharedSliceContentSchema,
|
|
71
71
|
SliceContentSchema,
|
|
72
72
|
} from "./content/slice"
|
|
73
|
-
import {
|
|
73
|
+
import {
|
|
74
|
+
LegacySliceItemContentSchema,
|
|
75
|
+
CompositeSliceItemContentSchema,
|
|
76
|
+
SharedSliceItemContentSchema,
|
|
77
|
+
SliceItemContentSchema,
|
|
78
|
+
SlicesContentSchema,
|
|
79
|
+
} from "./content/slices"
|
|
74
80
|
import { TableContentSchema } from "./content/table"
|
|
75
81
|
import { UIDContentSchema } from "./content/uid"
|
|
76
82
|
import { WidgetContentSchema } from "./content/widget"
|
|
@@ -142,6 +148,9 @@ export const GroupItemContent = toIOTS(GroupItemContentSchema)
|
|
|
142
148
|
export const CompositeSliceContent = toIOTS(CompositeSliceContentSchema)
|
|
143
149
|
export const LegacySliceContent = toIOTS(LegacySliceContentSchema)
|
|
144
150
|
export const SliceContent = toIOTS(SliceContentSchema)
|
|
151
|
+
export const LegacySliceItemContent = toIOTS(LegacySliceItemContentSchema)
|
|
152
|
+
export const CompositeSliceItemContent = toIOTS(CompositeSliceItemContentSchema)
|
|
153
|
+
export const SharedSliceItemContent = toIOTS(SharedSliceItemContentSchema)
|
|
145
154
|
export const SliceItemContent = toIOTS(SliceItemContentSchema)
|
|
146
155
|
export const SlicesContent = toIOTS(SlicesContentSchema)
|
|
147
156
|
export const WidgetContent = toIOTS(WidgetContentSchema)
|
|
@@ -240,7 +249,11 @@ function toIOTSCodec<TArgs extends unknown[], A, LegacyRaw, AllowUndefined exten
|
|
|
240
249
|
) => t.Type<A, ReturnType<LegacyCodec<A, LegacyRaw, AllowUndefined>["fromContent"]>, unknown> {
|
|
241
250
|
return (...args: TArgs) => {
|
|
242
251
|
const codec = codecFactory(...args)
|
|
243
|
-
return new t.Type<
|
|
252
|
+
return new t.Type<
|
|
253
|
+
A,
|
|
254
|
+
ReturnType<LegacyCodec<A, LegacyRaw, AllowUndefined>["fromContent"]>,
|
|
255
|
+
unknown
|
|
256
|
+
>(
|
|
244
257
|
codec.name,
|
|
245
258
|
codec.is,
|
|
246
259
|
(input, context) => {
|
package/src/model/widget.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { z } from "zod/mini"
|
|
|
2
2
|
|
|
3
3
|
import { GroupModelSchema } from "./group"
|
|
4
4
|
import { NestableModelSchema } from "./nestable"
|
|
5
|
+
import { SliceModelTypeSchema } from "./slice"
|
|
5
6
|
import { DynamicSlicesModelSchema, StaticSlicesModelSchema } from "./slices"
|
|
6
7
|
import { UIDModelSchema } from "./uid"
|
|
7
|
-
import { SliceModelTypeSchema } from "./slice"
|
|
8
8
|
|
|
9
9
|
// StaticWidget = UID | Nestable | Group | StaticSlices
|
|
10
10
|
export const StaticWidgetModelSchema = z.union([
|
|
@@ -54,9 +54,6 @@ export const FieldModelTypeSchema = z.enum([
|
|
|
54
54
|
export type FieldModelType = z.infer<typeof FieldModelTypeSchema>
|
|
55
55
|
|
|
56
56
|
// Field and slice types
|
|
57
|
-
export const FieldOrSliceTypeSchema = z.union([
|
|
58
|
-
FieldModelTypeSchema,
|
|
59
|
-
SliceModelTypeSchema,
|
|
60
|
-
])
|
|
57
|
+
export const FieldOrSliceTypeSchema = z.union([FieldModelTypeSchema, SliceModelTypeSchema])
|
|
61
58
|
|
|
62
59
|
export type FieldOrSliceType = z.infer<typeof FieldOrSliceTypeSchema>
|
package/src/zod4.ts
CHANGED
|
@@ -34,7 +34,13 @@ import {
|
|
|
34
34
|
SharedSliceContentSchema,
|
|
35
35
|
SliceContentSchema,
|
|
36
36
|
} from "./content/slice"
|
|
37
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
LegacySliceItemContentSchema,
|
|
39
|
+
CompositeSliceItemContentSchema,
|
|
40
|
+
SharedSliceItemContentSchema,
|
|
41
|
+
SliceItemContentSchema,
|
|
42
|
+
SlicesContentSchema,
|
|
43
|
+
} from "./content/slices"
|
|
38
44
|
import { TableContentSchema } from "./content/table"
|
|
39
45
|
import { UIDContentSchema } from "./content/uid"
|
|
40
46
|
import { WidgetContentSchema } from "./content/widget"
|
|
@@ -106,6 +112,9 @@ export const GroupItemContent = toZod4(GroupItemContentSchema)
|
|
|
106
112
|
export const CompositeSliceContent = toZod4(CompositeSliceContentSchema)
|
|
107
113
|
export const LegacySliceContent = toZod4(LegacySliceContentSchema)
|
|
108
114
|
export const SliceContent = toZod4(SliceContentSchema)
|
|
115
|
+
export const LegacySliceItemContent = toZod4(LegacySliceItemContentSchema)
|
|
116
|
+
export const CompositeSliceItemContent = toZod4(CompositeSliceItemContentSchema)
|
|
117
|
+
export const SharedSliceItemContent = toZod4(SharedSliceItemContentSchema)
|
|
109
118
|
export const SliceItemContent = toZod4(SliceItemContentSchema)
|
|
110
119
|
export const SlicesContent = toZod4(SlicesContentSchema)
|
|
111
120
|
export const WidgetContent = toZod4(WidgetContentSchema)
|