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

@prismicio/types-internal

Package Overview
Dependencies
Maintainers
19
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.11 to 0.3.0

19

lib/customtypes/widgets/nestable/RichText.d.ts

@@ -22,3 +22,20 @@ import * as t from "io-ts";

}
export declare function parseRichTextNodeType(str: string): RichTextNodeType | undefined;
export declare const RichTextNodeTypeCodec: t.KeyofC<{
heading1: null;
heading2: null;
heading3: null;
heading4: null;
heading5: null;
heading6: null;
paragraph: null;
strong: null;
em: null;
preformatted: null;
hyperlink: null;
image: null;
embed: null;
"list-item": null;
"o-list-item": null;
rtl: null;
}>;
export declare const RichTextConfig: t.ExactC<t.PartialC<{

@@ -25,0 +42,0 @@ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;

63

lib/customtypes/widgets/nestable/RichText.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RichText = exports.RichTextConfig = exports.parseRichTextNodeType = exports.RichTextNodeType = exports.DEFAULT_OPTION = void 0;
exports.RichText = exports.RichTextConfig = exports.RichTextNodeTypeCodec = exports.RichTextNodeType = exports.DEFAULT_OPTION = void 0;
const tslib_1 = require("tslib");

@@ -30,41 +30,20 @@ const Either_1 = require("fp-ts/lib/Either");

})(RichTextNodeType = exports.RichTextNodeType || (exports.RichTextNodeType = {}));
function parseRichTextNodeType(str) {
switch (str) {
case RichTextNodeType.heading1:
return RichTextNodeType.heading1;
case RichTextNodeType.heading2:
return RichTextNodeType.heading2;
case RichTextNodeType.heading3:
return RichTextNodeType.heading3;
case RichTextNodeType.heading4:
return RichTextNodeType.heading4;
case RichTextNodeType.heading5:
return RichTextNodeType.heading5;
case RichTextNodeType.heading6:
return RichTextNodeType.heading6;
case RichTextNodeType.paragraph:
return RichTextNodeType.paragraph;
case RichTextNodeType.strong:
return RichTextNodeType.strong;
case RichTextNodeType.em:
return RichTextNodeType.em;
case RichTextNodeType.preformatted:
return RichTextNodeType.preformatted;
case RichTextNodeType.hyperlink:
return RichTextNodeType.hyperlink;
case RichTextNodeType.image:
return RichTextNodeType.image;
case RichTextNodeType.embed:
return RichTextNodeType.embed;
case RichTextNodeType.list:
return RichTextNodeType.list;
case RichTextNodeType.orderedList:
return RichTextNodeType.orderedList;
case RichTextNodeType.rtl:
return RichTextNodeType.rtl;
default:
return;
}
}
exports.parseRichTextNodeType = parseRichTextNodeType;
exports.RichTextNodeTypeCodec = t.keyof({
[RichTextNodeType.heading1]: null,
[RichTextNodeType.heading2]: null,
[RichTextNodeType.heading3]: null,
[RichTextNodeType.heading4]: null,
[RichTextNodeType.heading5]: null,
[RichTextNodeType.heading6]: null,
[RichTextNodeType.paragraph]: null,
[RichTextNodeType.strong]: null,
[RichTextNodeType.em]: null,
[RichTextNodeType.preformatted]: null,
[RichTextNodeType.hyperlink]: null,
[RichTextNodeType.image]: null,
[RichTextNodeType.embed]: null,
[RichTextNodeType.list]: null,
[RichTextNodeType.orderedList]: null,
[RichTextNodeType.rtl]: null,
});
const RichTextOptions = new t.Type("RichTextOptions", (u) => typeof u === "string", (u, context) => {

@@ -75,3 +54,5 @@ return Either_1.either.chain(t.union([t.string, t.null]).validate(u, context), (s) => {

const entries = s.split(",").map((e) => e.trim());
const filtered = entries.filter((entry) => parseRichTextNodeType(entry));
const filtered = entries.filter((entry) => {
return (0, Either_1.getOrElseW)(() => undefined)(exports.RichTextNodeTypeCodec.decode(entry));
});
if (!filtered.length)

@@ -78,0 +59,0 @@ return t.success(exports.DEFAULT_OPTION);

import * as t from "io-ts";
import { RichTextNodeType } from "../../../../customtypes/widgets/nestable";
export declare const Meta: t.ExactC<t.IntersectionC<[t.PartialC<{

@@ -7,3 +8,20 @@ data: t.UnknownC;

end: t.NumberC;
type: t.StringC;
type: t.KeyofC<{
heading1: null;
heading2: null;
heading3: null;
heading4: null;
heading5: null;
heading6: null;
paragraph: null;
strong: null;
em: null;
preformatted: null;
hyperlink: null;
image: null;
embed: null;
"list-item": null;
"o-list-item": null;
rtl: null;
}>;
}>]>>;

@@ -16,3 +34,20 @@ export declare type Meta = t.TypeOf<typeof Meta>;

end: t.NumberC;
type: t.StringC;
type: t.KeyofC<{
heading1: null;
heading2: null;
heading3: null;
heading4: null;
heading5: null;
heading6: null;
paragraph: null;
strong: null;
em: null;
preformatted: null;
hyperlink: null;
image: null;
embed: null;
"list-item": null;
"o-list-item": null;
rtl: null;
}>;
}>]>>;

@@ -25,3 +60,3 @@ export declare type Span = Meta;

end: number;
type: string;
type: RichTextNodeType;
})[], ({

@@ -32,7 +67,6 @@ data?: unknown;

end: number;
type: string;
type: RichTextNodeType;
})[], unknown>;
export declare const ImageBlockType = "image";
export declare const ImageBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
type: t.LiteralC<"image">;
type: t.LiteralC<RichTextNodeType.image>;
data: t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{

@@ -131,5 +165,4 @@ origin: t.ExactC<t.TypeC<{

export declare function checkImageBlock(block: Block): block is ImageBlock;
export declare const EmbedBlockType = "embed";
export declare const EmbedBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
type: t.LiteralC<"embed">;
type: t.LiteralC<RichTextNodeType.embed>;
data: t.Type<import("../EmbedContent").EmbedContentO, unknown, unknown>;

@@ -143,3 +176,3 @@ }>, t.PartialC<{

export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
type: t.Type<string, string, unknown>;
type: t.Type<RichTextNodeType, RichTextNodeType, unknown>;
content: t.IntersectionC<[t.TypeC<{

@@ -153,3 +186,3 @@ text: t.StringC;

end: number;
type: string;
type: RichTextNodeType;
})[], ({

@@ -160,3 +193,3 @@ data?: unknown;

end: number;
type: string;
type: RichTextNodeType;
})[], unknown>;

@@ -170,3 +203,3 @@ }>]>;

export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
type: t.LiteralC<"image">;
type: t.LiteralC<RichTextNodeType.image>;
data: t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{

@@ -263,3 +296,3 @@ origin: t.ExactC<t.TypeC<{

}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
type: t.LiteralC<"embed">;
type: t.LiteralC<RichTextNodeType.embed>;
data: t.Type<import("../EmbedContent").EmbedContentO, unknown, unknown>;

@@ -270,3 +303,3 @@ }>, t.PartialC<{

}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
type: t.Type<string, string, unknown>;
type: t.Type<RichTextNodeType, RichTextNodeType, unknown>;
content: t.IntersectionC<[t.TypeC<{

@@ -280,3 +313,3 @@ text: t.StringC;

end: number;
type: string;
type: RichTextNodeType;
})[], ({

@@ -287,3 +320,3 @@ data?: unknown;

end: number;
type: string;
type: RichTextNodeType;
})[], unknown>;

@@ -290,0 +323,0 @@ }>]>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Block = exports.TextBlock = exports.checkEmbedBlock = exports.EmbedBlock = exports.EmbedBlockType = exports.checkImageBlock = exports.ImageBlock = exports.ImageBlockType = exports.ValidatedMetas = exports.Span = exports.Meta = void 0;
exports.Block = exports.TextBlock = exports.checkEmbedBlock = exports.EmbedBlock = exports.checkImageBlock = exports.ImageBlock = exports.ValidatedMetas = exports.Span = exports.Meta = void 0;
const tslib_1 = require("tslib");
const E = (0, tslib_1.__importStar)(require("fp-ts/lib/Either"));
const t = (0, tslib_1.__importStar)(require("io-ts"));
const nestable_1 = require("../../../../customtypes/widgets/nestable");
const validators_1 = require("../../../../validators");

@@ -19,3 +20,3 @@ const function_1 = require("../../../../validators/function");

end: t.number,
type: t.string,
type: nestable_1.RichTextNodeTypeCodec,
}),

@@ -48,6 +49,5 @@ ]));

}, (m) => t.array(exports.Meta).encode(m));
exports.ImageBlockType = "image";
exports.ImageBlock = t.exact(t.intersection([
t.type({
type: t.literal(exports.ImageBlockType),
type: t.literal(nestable_1.RichTextNodeType.image),
data: t.intersection([

@@ -66,9 +66,8 @@ ImageContent_1.ImageContentView,

function checkImageBlock(block) {
return block.type === exports.ImageBlockType;
return block.type === nestable_1.RichTextNodeType.image;
}
exports.checkImageBlock = checkImageBlock;
exports.EmbedBlockType = "embed";
exports.EmbedBlock = t.exact(t.intersection([
t.type({
type: t.literal(exports.EmbedBlockType),
type: t.literal(nestable_1.RichTextNodeType.embed),
data: EmbedContent_1.EmbedContent,

@@ -82,3 +81,3 @@ }),

function checkEmbedBlock(block) {
return block.type === exports.EmbedBlockType;
return block.type === nestable_1.RichTextNodeType.embed;
}

@@ -88,3 +87,3 @@ exports.checkEmbedBlock = checkEmbedBlock;

t.type({
type: (0, function_1.refineType)(t.string, `string which isn't ${exports.ImageBlockType} ${exports.EmbedBlockType}`, (s) => s !== exports.ImageBlockType && s !== exports.EmbedBlockType),
type: (0, function_1.refineType)(nestable_1.RichTextNodeTypeCodec, `string which isn't ${nestable_1.RichTextNodeType.image} ${nestable_1.RichTextNodeType.embed}`, (s) => s !== nestable_1.RichTextNodeType.image && s !== nestable_1.RichTextNodeType.embed),
content: t.intersection([

@@ -91,0 +90,0 @@ t.type({

{
"name": "@prismicio/types-internal",
"version": "0.2.11",
"version": "0.3.0",
"description": "Prismic types for Custom Types and Prismic Data",

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

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

import { either } from "fp-ts/lib/Either"
import { either, getOrElseW } from "fp-ts/lib/Either"
import * as t from "io-ts"

@@ -29,42 +29,20 @@

export function parseRichTextNodeType(
str: string,
): RichTextNodeType | undefined {
switch (str) {
case RichTextNodeType.heading1:
return RichTextNodeType.heading1
case RichTextNodeType.heading2:
return RichTextNodeType.heading2
case RichTextNodeType.heading3:
return RichTextNodeType.heading3
case RichTextNodeType.heading4:
return RichTextNodeType.heading4
case RichTextNodeType.heading5:
return RichTextNodeType.heading5
case RichTextNodeType.heading6:
return RichTextNodeType.heading6
case RichTextNodeType.paragraph:
return RichTextNodeType.paragraph
case RichTextNodeType.strong:
return RichTextNodeType.strong
case RichTextNodeType.em:
return RichTextNodeType.em
case RichTextNodeType.preformatted:
return RichTextNodeType.preformatted
case RichTextNodeType.hyperlink:
return RichTextNodeType.hyperlink
case RichTextNodeType.image:
return RichTextNodeType.image
case RichTextNodeType.embed:
return RichTextNodeType.embed
case RichTextNodeType.list:
return RichTextNodeType.list
case RichTextNodeType.orderedList:
return RichTextNodeType.orderedList
case RichTextNodeType.rtl:
return RichTextNodeType.rtl
default:
return
}
}
export const RichTextNodeTypeCodec = t.keyof({
[RichTextNodeType.heading1]: null,
[RichTextNodeType.heading2]: null,
[RichTextNodeType.heading3]: null,
[RichTextNodeType.heading4]: null,
[RichTextNodeType.heading5]: null,
[RichTextNodeType.heading6]: null,
[RichTextNodeType.paragraph]: null,
[RichTextNodeType.strong]: null,
[RichTextNodeType.em]: null,
[RichTextNodeType.preformatted]: null,
[RichTextNodeType.hyperlink]: null,
[RichTextNodeType.image]: null,
[RichTextNodeType.embed]: null,
[RichTextNodeType.list]: null,
[RichTextNodeType.orderedList]: null,
[RichTextNodeType.rtl]: null,
})

@@ -80,3 +58,7 @@ const RichTextOptions = new t.Type<string, string, unknown>(

const entries = s.split(",").map((e: string) => e.trim())
const filtered = entries.filter((entry) => parseRichTextNodeType(entry))
const filtered = entries.filter((entry) => {
return getOrElseW(() => undefined)(
RichTextNodeTypeCodec.decode(entry),
)
})
if (!filtered.length) return t.success(DEFAULT_OPTION)

@@ -83,0 +65,0 @@

import * as E from "fp-ts/lib/Either"
import * as t from "io-ts"
import {
RichTextNodeType,
RichTextNodeTypeCodec,
} from "../../../../customtypes/widgets/nestable"
import { StringOrNull } from "../../../../validators"

@@ -18,3 +22,3 @@ import { nullable, refineType } from "../../../../validators/function"

end: t.number,
type: t.string,
type: RichTextNodeTypeCodec,
}),

@@ -58,8 +62,6 @@ ]),

export const ImageBlockType = "image"
export const ImageBlock = t.exact(
t.intersection([
t.type({
type: t.literal(ImageBlockType),
type: t.literal(RichTextNodeType.image),
data: t.intersection([

@@ -80,10 +82,9 @@ ImageContentView,

export function checkImageBlock(block: Block): block is ImageBlock {
return block.type === ImageBlockType
return block.type === RichTextNodeType.image
}
export const EmbedBlockType = "embed"
export const EmbedBlock = t.exact(
t.intersection([
t.type({
type: t.literal(EmbedBlockType),
type: t.literal(RichTextNodeType.embed),
data: EmbedContent,

@@ -99,3 +100,3 @@ }),

export function checkEmbedBlock(block: Block): block is EmbedBlock {
return block.type === EmbedBlockType
return block.type === RichTextNodeType.embed
}

@@ -107,5 +108,5 @@

type: refineType(
t.string,
`string which isn't ${ImageBlockType} ${EmbedBlockType}`,
(s) => s !== ImageBlockType && s !== EmbedBlockType,
RichTextNodeTypeCodec,
`string which isn't ${RichTextNodeType.image} ${RichTextNodeType.embed}`,
(s) => s !== RichTextNodeType.image && s !== RichTextNodeType.embed,
),

@@ -112,0 +113,0 @@ content: t.intersection([

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