Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@prismicio/types-internal

Package Overview
Dependencies
Maintainers
24
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prismicio/types-internal - npm Package Compare versions

Comparing version 2.2.0-traverse.alpha-3 to 2.2.0-traverse.alpha-4

18

lib/content/Document.js

@@ -103,3 +103,6 @@ "use strict";

*/
function traverseDocument({ document, model, }) {
function traverseDocument({ document, customType, }) {
const model = customType && customtypes_1.StaticCustomType.is(customType)
? simplifyCustomType(customType)
: customType;
return ({ transformWidget = ({ content }) => content, transformSlice = ({ content }) => content, }) => {

@@ -155,2 +158,8 @@ const fieldModels = model &&

exports.traverseDocument = traverseDocument;
function simplifyCustomType(customType) {
return {
customTypeId: customType === null || customType === void 0 ? void 0 : customType.id,
fields: Object.fromEntries((0, customtypes_1.flattenStaticWidgets)(customType)),
};
}
// /**

@@ -177,3 +186,6 @@ // * The goal is to be able to collect all widgets or slices of a given type at any level of nesting inside a prismic content

function migrateDocument(document, customType) {
const needsMigration = Object.values((0, customtypes_1.collectSharedSlices)(customType)).some((slice) => Boolean(slice.legacyPaths));
const model = customtypes_1.StaticCustomType.is(customType)
? simplifyCustomType(customType)
: customType;
const needsMigration = Object.values((0, customtypes_1.collectSharedSlices)(model)).some((slice) => Boolean(slice.legacyPaths));
if (!needsMigration)

@@ -183,3 +195,3 @@ return document;

document,
model: customType,
customType,
})({

@@ -186,0 +198,0 @@ transformSlice: ({ content, model }) => {

2

package.json
{
"name": "@prismicio/types-internal",
"version": "2.2.0-traverse.alpha-3",
"version": "2.2.0-traverse.alpha-4",
"description": "Prismic types for Custom Types and Prismic Data",

@@ -5,0 +5,0 @@ "keywords": [

@@ -12,4 +12,9 @@ import { either } from "fp-ts"

import { WidgetKey } from "../common"
import { type StaticWidget, collectSharedSlices } from "../customtypes"
import {
type StaticWidget,
collectSharedSlices,
flattenStaticWidgets,
StaticCustomType,
} from "../customtypes"
import {
isCompositeSliceItemContent,

@@ -168,10 +173,17 @@ isSimpleSliceItemContent,

document,
model,
customType,
}: {
document: Document
model?: {
customTypeId: string
fields: Record<string, StaticWidget>
}
customType?:
| StaticCustomType
| {
customTypeId: string
fields: Record<string, StaticWidget>
}
| undefined
}) {
const model =
customType && StaticCustomType.is(customType)
? simplifyCustomType(customType)
: customType
return ({

@@ -243,2 +255,12 @@ transformWidget = ({ content }) => content,

function simplifyCustomType(customType: StaticCustomType): {
customTypeId: string
fields: Record<string, StaticWidget>
} {
return {
customTypeId: customType?.id,
fields: Object.fromEntries(flattenStaticWidgets(customType)),
}
}
// /**

@@ -269,8 +291,13 @@ // * The goal is to be able to collect all widgets or slices of a given type at any level of nesting inside a prismic content

document: Document,
customType: {
customTypeId: string
fields: Record<string, StaticWidget>
},
customType:
| StaticCustomType
| {
customTypeId: string
fields: Record<string, StaticWidget>
},
) {
const needsMigration = Object.values(collectSharedSlices(customType)).some(
const model = StaticCustomType.is(customType)
? simplifyCustomType(customType)
: customType
const needsMigration = Object.values(collectSharedSlices(model)).some(
(slice) => Boolean(slice.legacyPaths),

@@ -283,3 +310,3 @@ )

document,
model: customType,
customType,
})({

@@ -286,0 +313,0 @@ transformSlice: ({ content, model }) => {

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc