@prismicio/types-internal 2.2.0-traverse.alpha-7 → 2.2.0-traverse.alpha-9

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 (33) hide show
  1. package/lib/_internal/utils.d.ts +0 -3
  2. package/lib/content/Document.d.ts +96 -32
  3. package/lib/content/Document.js +1 -1
  4. package/lib/content/fields/GroupContent.d.ts +21 -7
  5. package/lib/content/fields/WidgetContent.d.ts +96 -32
  6. package/lib/content/fields/nestable/NestableContent.d.ts +12 -6
  7. package/lib/content/fields/nestable/NestableContent.js +1 -29
  8. package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +30 -12
  9. package/lib/content/fields/nestable/RichTextContent/Blocks.js +11 -2
  10. package/lib/content/fields/nestable/RichTextContent/index.d.ts +15 -5
  11. package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +24 -8
  12. package/lib/content/fields/slices/Slice/CompositeSliceContent.js +15 -7
  13. package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +9 -3
  14. package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +24 -8
  15. package/lib/content/fields/slices/Slice/SharedSliceContent.js +5 -1
  16. package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +24 -8
  17. package/lib/content/fields/slices/Slice/SimpleSliceContent.js +1 -1
  18. package/lib/content/fields/slices/Slice/index.d.ts +54 -18
  19. package/lib/content/fields/slices/SliceItem.d.ts +54 -18
  20. package/lib/content/fields/slices/SlicesContent.d.ts +72 -24
  21. package/lib/customtypes/CustomType.d.ts +1 -1
  22. package/lib/customtypes/CustomType.js +3 -3
  23. package/lib/customtypes/widgets/slices/SharedSlice.d.ts +1 -2
  24. package/package.json +1 -1
  25. package/src/_internal/utils.ts +0 -4
  26. package/src/content/Document.ts +2 -2
  27. package/src/content/fields/nestable/NestableContent.ts +0 -32
  28. package/src/content/fields/nestable/RichTextContent/Blocks.ts +15 -3
  29. package/src/content/fields/slices/Slice/CompositeSliceContent.ts +22 -7
  30. package/src/content/fields/slices/Slice/SharedSliceContent.ts +7 -1
  31. package/src/content/fields/slices/Slice/SimpleSliceContent.ts +1 -1
  32. package/src/customtypes/CustomType.ts +1 -1
  33. package/src/customtypes/widgets/slices/SharedSlice.ts +2 -2
@@ -174,7 +174,13 @@ export function traverseSharedSliceContent({
174
174
  content: fieldContent,
175
175
  })
176
176
  // Can happen if the transform function returns undefined to filter out a field
177
- if (!transformedField || !isNestableContent(transformedField)) return acc
177
+ if (!transformedField) return acc
178
+ if (!isNestableContent(transformedField)) {
179
+ console.warn(
180
+ `Warn: Non nestable content with key [${fieldKey}] detected in a shared slice [${sliceName}] with key [${sliceKey}]`,
181
+ )
182
+ return acc
183
+ }
178
184
  return {
179
185
  ...acc,
180
186
  [fieldKey]: transformedField,
@@ -168,7 +168,7 @@ export function migrateSimpleSlice(
168
168
  __TYPE__: "SharedSliceContent",
169
169
  variation: model.variationId,
170
170
  primary: model.fields.primary?.[content.name]
171
- ? { [content.key]: content.widget }
171
+ ? { [content.name]: content.widget }
172
172
  : {},
173
173
  items: [],
174
174
  },
@@ -75,7 +75,7 @@ export function flattenWidgets(
75
75
  )
76
76
  }
77
77
 
78
- export function flattenStaticWidgets(
78
+ export function flattenSections(
79
79
  customType: StaticCustomType,
80
80
  ): Array<[string, StaticWidget]> {
81
81
  return Object.entries(customType.json).reduce(
@@ -1,7 +1,6 @@
1
1
  import * as t from "io-ts"
2
2
  import { withFallback } from "io-ts-types/lib/withFallback"
3
3
 
4
- import type { PickOnly } from "../../../_internal/utils"
5
4
  import { WidgetKey } from "../../../common"
6
5
  import { NestableWidget } from "../nestable/NestableWidget"
7
6
  import type { SharedSliceRef } from "./SharedSliceRef"
@@ -30,11 +29,12 @@ export const Variation = t.exact(
30
29
 
31
30
  export type Variation = t.TypeOf<typeof Variation>
32
31
 
32
+ // VariationFields is used exclusively for the slices migration, LegacySlice -> SharedSlice
33
33
  export type VariationFields = {
34
34
  type: "SharedSlice"
35
35
  sliceName: string
36
36
  variationId: string
37
- fields: PickOnly<Variation, "primary" | "items">
37
+ fields: Pick<Variation, "primary" | "items">
38
38
  }
39
39
 
40
40
  export const SharedSliceType = "SharedSlice"