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

@prismicio/types-internal

Package Overview
Dependencies
Maintainers
20
Versions
166
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 0.2.6 to 0.2.7

9

lib/documents/DocumentData.d.ts

@@ -7,3 +7,12 @@ import * as O from "fp-ts/lib/Option";

fromJson(widgets: Map<WidgetKey, unknown>, widgetTypes: Map<WidgetKey, string>, widgetPositions: Map<WidgetKey, number>): DocumentData;
partitionData(data: {
[p: string]: unknown;
}): {
types: Map<string, string>;
positions: Map<string, number>;
widgets: Map<WidgetKey, unknown>;
slugs: ReadonlyArray<string>;
uid: string | undefined;
};
};
export default DocumentData;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const Either_1 = require("fp-ts/lib/Either");
const O = (0, tslib_1.__importStar)(require("fp-ts/lib/Option"));
const t = (0, tslib_1.__importStar)(require("io-ts"));
const widgets_1 = require("./widgets");

@@ -27,3 +29,43 @@ function computeWidget(key, widgets, widgetTypes, widgetPositions) {

},
partitionData(data) {
const fields = Object.entries(data);
const { types, positions, widgets } = fields.reduce((acc, [k, v]) => {
if (k.endsWith("_TYPE")) {
const decodedValue = t.string.decode(v);
if ((0, Either_1.isRight)(decodedValue)) {
return {
...acc,
types: acc.types.set(k.substring(0, k.length - 5), decodedValue.right),
};
}
}
if (k.endsWith("_POSITION") && typeof v === "number") {
return {
...acc,
positions: acc.positions.set(k.substring(0, k.length - 9), v),
};
}
if (!k.endsWith("_POSITION") && !k.endsWith("_TYPE")) {
return {
...acc,
widgets: acc.widgets.set(k, v),
};
}
return acc;
}, {
types: new Map(),
positions: new Map(),
widgets: new Map(),
});
const slugs = data["slugs_INTERNAL"] || [];
const uid = data["uid"];
return {
widgets,
types,
positions,
uid,
slugs,
};
},
};
exports.default = DocumentData;

2

package.json
{
"name": "@prismicio/types-internal",
"version": "0.2.6",
"version": "0.2.7",
"description": "Prismic types for Custom Types and Prismic Data",

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

@@ -0,2 +1,4 @@

import { isRight } from "fp-ts/lib/Either"
import * as O from "fp-ts/lib/Option"
import * as t from "io-ts"

@@ -52,4 +54,60 @@ import { type WidgetContent, type WidgetKey, Widget } from "./widgets"

},
partitionData(data: { [p: string]: unknown }): {
types: Map<string, string>
positions: Map<string, number>
widgets: Map<WidgetKey, unknown>
slugs: ReadonlyArray<string>
uid: string | undefined
} {
const fields: [string, unknown][] = Object.entries(data)
const { types, positions, widgets } = fields.reduce(
(acc, [k, v]) => {
if (k.endsWith("_TYPE")) {
const decodedValue = t.string.decode(v)
if (isRight(decodedValue)) {
return {
...acc,
types: acc.types.set(
k.substring(0, k.length - 5),
decodedValue.right,
),
}
}
}
if (k.endsWith("_POSITION") && typeof v === "number") {
return {
...acc,
positions: acc.positions.set(k.substring(0, k.length - 9), v),
}
}
if (!k.endsWith("_POSITION") && !k.endsWith("_TYPE")) {
return {
...acc,
widgets: acc.widgets.set(k, v),
}
}
return acc
},
{
types: new Map<string, string>(),
positions: new Map<string, number>(),
widgets: new Map<string, unknown>(),
},
)
const slugs = (data["slugs_INTERNAL"] as string[]) || []
const uid = data["uid"] as string | undefined
return {
widgets,
types,
positions,
uid,
slugs,
}
},
}
export default DocumentData
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