@prismicio/types-internal
Advanced tools
Comparing version 2.8.0 to 2.9.0-alpha.0
import type { SharedSliceItemContent, SliceItemContent, WidgetContent } from "../content"; | ||
import type { RepeatableContent } from "../content/fields/RepeatableContent"; | ||
import type { CompositeSlice, Group, NestableWidget, StaticSlices, UID, VariationFields } from "../customtypes"; | ||
@@ -10,3 +11,3 @@ export declare type TraverseSliceContentFn = <S extends SliceItemContent | SharedSliceItemContent, D extends VariationFields | CompositeSlice | Group | NestableWidget>({ path, key, apiId, model, content, }: { | ||
}) => S | SharedSliceItemContent | undefined; | ||
export declare type TraverseWidgetContentFn = <C extends WidgetContent, D extends NestableWidget | StaticSlices | Group | UID>({ path, key, apiId, model, content, }: { | ||
export declare type TraverseWidgetContentFn = <C extends WidgetContent | RepeatableContent, D extends NestableWidget | StaticSlices | Group | UID>({ path, key, apiId, model, content, }: { | ||
path: ContentPath; | ||
@@ -19,3 +20,3 @@ key: string; | ||
export declare type ContentPathEntry = { | ||
type: "CustomType" | "Widget" | "SharedSlice" | "Slice" | "LegacySlice" | "GroupItem" | "primary" | "items"; | ||
type: "CustomType" | "Widget" | "SharedSlice" | "Slice" | "LegacySlice" | "GroupItem" | "primary" | "items" | "RepeatableItem"; | ||
key: string; | ||
@@ -22,0 +23,0 @@ }; |
@@ -0,1 +1,24 @@ | ||
/** | ||
* LinkContent is a union of different link content types. | ||
* | ||
* Most link content types are built from a union of a filled and an unfilled version. | ||
* | ||
* Filled versions make sure that the important fields that make the link work | ||
* are present. They are also exported for when there's a need to ensure that | ||
* the link is filled when used in a specific context, e.g. links in rich text fields. | ||
* | ||
* Unfilled versions are used when the link is not filled yet but contains other | ||
* information like the text. | ||
* | ||
* There are some exceptions that don't have a filled version (e.g. MediaLink) | ||
* for when the exact subtype is not yet known. | ||
* | ||
* Unfilled versions all have a special `kind` property that is used to | ||
* determine the type of the link. For legacy reasons, filled versions don't | ||
* necessarily require this property or its type is loose (e.g. `string`). In | ||
* this cases, the type is determined based on a specific combination of the | ||
* rest of the link data. This is why the order of the subtypes in the union is | ||
* important and should be from the most specific to the least specific. A | ||
* battery of tests ensures that the correct type is inferred. | ||
*/ | ||
import * as t from "io-ts"; | ||
@@ -2,0 +25,0 @@ import type { LegacyContentCtx, WithTypes } from "../../LegacyContentCtx"; |
"use strict"; | ||
/** | ||
* LinkContent is a union of different link content types. | ||
* | ||
* Most link content types are built from a union of a filled and an unfilled version. | ||
* | ||
* Filled versions make sure that the important fields that make the link work | ||
* are present. They are also exported for when there's a need to ensure that | ||
* the link is filled when used in a specific context, e.g. links in rich text fields. | ||
* | ||
* Unfilled versions are used when the link is not filled yet but contains other | ||
* information like the text. | ||
* | ||
* There are some exceptions that don't have a filled version (e.g. MediaLink) | ||
* for when the exact subtype is not yet known. | ||
* | ||
* Unfilled versions all have a special `kind` property that is used to | ||
* determine the type of the link. For legacy reasons, filled versions don't | ||
* necessarily require this property or its type is loose (e.g. `string`). In | ||
* this cases, the type is determined based on a specific combination of the | ||
* rest of the link data. This is why the order of the subtypes in the union is | ||
* important and should be from the most specific to the least specific. A | ||
* battery of tests ensures that the correct type is inferred. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -3,0 +26,0 @@ exports.FilledLinkContent = exports.FilledLink = exports.FilledLinkContentLegacy = exports.FilledLinkLegacy = exports.isFilledLinkContent = exports.LinkContent = exports.Link = exports.LinkContentLegacy = exports.LinkLegacy = exports.isLinkContent = exports.LinkContentType = exports.AnyLinkContent = exports.AnyLinkType = exports.ExternalLinkContent = exports.FilledExternalLinkContent = exports.ExternalLinkType = exports.DocumentLinkContent = exports.FilledDocumentLinkContent = exports.DocumentLinkType = exports.MediaLinkContent = exports.MediaLinkType = exports.FileLinkContent = exports.FilledFileLinkContent = exports.FileLinkType = exports.ImageLinkContent = exports.FilledImageLinkContent = exports.ImageLinkType = void 0; |
import * as t from "io-ts"; | ||
import type { NestableWidget } from "../../../customtypes"; | ||
import { type NestableWidget } from "../../../customtypes"; | ||
import type { LegacyContentCtx } from "../../LegacyContentCtx"; | ||
@@ -425,2 +425,76 @@ export declare const NestableContent: t.UnionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"SeparatorContent">; | ||
}>>, t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"RepeatableContent">; | ||
type: t.UnionC<[t.LiteralC<"Color">, t.LiteralC<"Boolean">, t.LiteralC<"Embed">, t.LiteralC<"GeoPoint">, t.LiteralC<"Date">, t.LiteralC<"Number">, t.LiteralC<"Range">, t.LiteralC<"StructuredText">, t.LiteralC<"Select">, t.LiteralC<"Separator">, t.LiteralC<"Text">, t.LiteralC<"Timestamp">, t.LiteralC<"Link">, t.LiteralC<"Image">, t.LiteralC<"IntegrationFields">]>; | ||
value: t.ArrayC<t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"LinkContent">; | ||
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"ImageLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
kind: t.StringC; | ||
id: t.StringC; | ||
url: t.StringC; | ||
height: t.StringC; | ||
width: t.StringC; | ||
size: t.StringC; | ||
name: t.StringC; | ||
}>>, t.ExactC<t.PartialC<{ | ||
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; | ||
}>>]>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"image">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"FileLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
kind: t.StringC; | ||
id: t.StringC; | ||
url: t.StringC; | ||
name: t.StringC; | ||
size: t.StringC; | ||
}>, t.PartialC<{ | ||
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; | ||
}>]>>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"file">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"DocumentLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
id: t.Type<string, string, unknown>; | ||
}>>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"document">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"ExternalLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
url: t.StringC; | ||
}>, t.PartialC<{ | ||
kind: t.LiteralC<"web">; | ||
target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; | ||
preview: t.UnionC<[t.Type<{ | ||
title?: string; | ||
}, { | ||
title?: string; | ||
}, unknown>, t.NullC, t.UndefinedC]>; | ||
}>]>>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"web">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"MediaLink">; | ||
}>>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"media">; | ||
text: t.StringC; | ||
}>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"AnyLink">; | ||
}>>, t.ExactC<t.TypeC<{ | ||
text: t.StringC; | ||
}>>]>]>; | ||
}>>>; | ||
}>>]>; | ||
@@ -611,2 +685,74 @@ export declare type NestableContent = t.TypeOf<typeof NestableContent>; | ||
} | { | ||
__TYPE__: "RepeatableContent"; | ||
type: "Boolean" | "Color" | "Date" | "Embed" | "GeoPoint" | "Image" | "IntegrationFields" | "Link" | "Number" | "Range" | "StructuredText" | "Select" | "Separator" | "Text" | "Timestamp"; | ||
value: { | ||
__TYPE__: "LinkContent"; | ||
value: ({ | ||
__TYPE__: "ImageLink"; | ||
} & (({ | ||
kind: string; | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "image"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "FileLink"; | ||
} & (({ | ||
kind: string; | ||
id: string; | ||
url: string; | ||
name: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "file"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "MediaLink"; | ||
} & { | ||
kind: "media"; | ||
text: string; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & (({ | ||
id: string; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "document"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & (({ | ||
url: string; | ||
} & { | ||
kind?: "web"; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string; | ||
} | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "web"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "AnyLink"; | ||
} & { | ||
text: string; | ||
}); | ||
}[]; | ||
} | { | ||
__TYPE__: "StructuredTextContent"; | ||
@@ -768,3 +914,3 @@ value: (({ | ||
export declare const NestableLegacy: (ctx: LegacyContentCtx) => { | ||
decode(value: unknown): import("fp-ts/lib/Either").Left<t.Errors> | import("fp-ts/lib/Either").Right<{ | ||
decode(value: unknown): import("fp-ts/lib/Either").Right<{ | ||
type: string; | ||
@@ -949,2 +1095,74 @@ __TYPE__: "EmptyContent"; | ||
}); | ||
}> | t.Validation<{ | ||
__TYPE__: "RepeatableContent"; | ||
type: "Boolean" | "Color" | "Date" | "Embed" | "GeoPoint" | "Image" | "IntegrationFields" | "Link" | "Number" | "Range" | "StructuredText" | "Select" | "Separator" | "Text" | "Timestamp"; | ||
value: { | ||
__TYPE__: "LinkContent"; | ||
value: ({ | ||
__TYPE__: "ImageLink"; | ||
} & (({ | ||
kind: string; | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "image"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "FileLink"; | ||
} & (({ | ||
kind: string; | ||
id: string; | ||
url: string; | ||
name: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "file"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "MediaLink"; | ||
} & { | ||
kind: "media"; | ||
text: string; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & (({ | ||
id: string; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "document"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & (({ | ||
url: string; | ||
} & { | ||
kind?: "web"; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string; | ||
} | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "web"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "AnyLink"; | ||
} & { | ||
text: string; | ||
}); | ||
}[]; | ||
}> | import("fp-ts/lib/Either").Right<{ | ||
@@ -951,0 +1169,0 @@ __TYPE__: "StructuredTextContent"; |
@@ -7,3 +7,5 @@ "use strict"; | ||
const t = (0, tslib_1.__importStar)(require("io-ts")); | ||
const customtypes_1 = require("../../../customtypes"); | ||
const EmptyContent_1 = require("../EmptyContent"); | ||
const RepeatableContent_1 = require("../RepeatableContent"); | ||
const BooleanContent_1 = require("./BooleanContent"); | ||
@@ -36,2 +38,3 @@ const EmbedContent_1 = require("./EmbedContent"); | ||
SeparatorContent_1.SeparatorContent, | ||
RepeatableContent_1.RepeatableContent, | ||
]); | ||
@@ -64,3 +67,4 @@ const NestableContentDefaultValue = (widgetDef) => { | ||
(0, SeparatorContent_1.isSeparatorContent)(u) || | ||
(0, EmptyContent_1.isEmptyContent)(u); | ||
(0, EmptyContent_1.isEmptyContent)(u) || | ||
(0, RepeatableContent_1.isRepeatableContent)(u); | ||
exports.isNestableContent = isNestableContent; | ||
@@ -70,2 +74,3 @@ const NestableLegacy = (ctx) => { | ||
decode(value) { | ||
var _a, _b; | ||
if (!ctx.fieldType) | ||
@@ -76,4 +81,8 @@ return; | ||
return nullValue; | ||
const fieldTypeSplit = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.fieldType) === null || _a === void 0 ? void 0 : _a.split("."); | ||
const fieldType = (_b = fieldTypeSplit === null || fieldTypeSplit === void 0 ? void 0 : fieldTypeSplit[1]) !== null && _b !== void 0 ? _b : ctx.fieldType; | ||
if (!customtypes_1.NestableFieldTypes.is(fieldType)) | ||
return; | ||
const codec = (() => { | ||
switch (ctx.fieldType) { | ||
switch (fieldType) { | ||
case "Text": | ||
@@ -115,5 +124,15 @@ return (0, FieldContent_1.TextLegacy)(ctx); | ||
return; | ||
// We check if the Nestable Content is repeated. If so, we decode each | ||
// item in the array using the specific codec for the repeated content. | ||
if ((fieldTypeSplit === null || fieldTypeSplit === void 0 ? void 0 : fieldTypeSplit[0]) === "Repeatable") { | ||
return (0, RepeatableContent_1.RepeatableLegacy)(ctx, fieldType).decode(value); | ||
} | ||
return codec.decode(value); | ||
}, | ||
encode(value) { | ||
// We check if the Nestable Content is repeated. If so, we decode each | ||
// item in the array using the specific codec for the repeated content. | ||
if (value.__TYPE__ === RepeatableContent_1.RepeatableContentType) { | ||
return (0, RepeatableContent_1.RepeatableLegacy)(ctx, value.type).encode(value); | ||
} | ||
switch (value.__TYPE__) { | ||
@@ -120,0 +139,0 @@ case common_1.FieldContentType: { |
@@ -762,68 +762,2 @@ import * as t from "io-ts"; | ||
}), ({ | ||
type: "image"; | ||
data: { | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string; | ||
credits?: string | null; | ||
alt?: string | null; | ||
provider?: string | null | undefined; | ||
} & { | ||
linkTo?: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
kind: string; | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
__TYPE__: "FileLink"; | ||
} & { | ||
kind: string; | ||
id: string; | ||
url: string; | ||
name: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web"; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string; | ||
} | null | undefined; | ||
}) | null | undefined; | ||
}; | ||
} & { | ||
label?: string | null | undefined; | ||
direction?: string | null | undefined; | ||
}) | ({ | ||
type: "embed"; | ||
@@ -912,2 +846,68 @@ data: { | ||
direction?: string; | ||
}) | ({ | ||
type: "image"; | ||
data: { | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string; | ||
credits?: string | null; | ||
alt?: string | null; | ||
provider?: string | null | undefined; | ||
} & { | ||
linkTo?: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
kind: string; | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
__TYPE__: "FileLink"; | ||
} & { | ||
kind: string; | ||
id: string; | ||
url: string; | ||
name: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web"; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string; | ||
} | null | undefined; | ||
}) | null | undefined; | ||
}; | ||
} & { | ||
label?: string | null | undefined; | ||
direction?: string | null | undefined; | ||
}), unknown>; | ||
@@ -914,0 +914,0 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ |
@@ -430,3 +430,77 @@ import * as t from "io-ts"; | ||
__TYPE__: t.LiteralC<"SeparatorContent">; | ||
}>>, t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"RepeatableContent">; | ||
type: t.UnionC<[t.LiteralC<"Color">, t.LiteralC<"Boolean">, t.LiteralC<"Embed">, t.LiteralC<"GeoPoint">, t.LiteralC<"Date">, t.LiteralC<"Number">, t.LiteralC<"Range">, t.LiteralC<"StructuredText">, t.LiteralC<"Select">, t.LiteralC<"Separator">, t.LiteralC<"Text">, t.LiteralC<"Timestamp">, t.LiteralC<"Link">, t.LiteralC<"Image">, t.LiteralC<"IntegrationFields">]>; | ||
value: t.ArrayC<t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"LinkContent">; | ||
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"ImageLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
kind: t.StringC; | ||
id: t.StringC; | ||
url: t.StringC; | ||
height: t.StringC; | ||
width: t.StringC; | ||
size: t.StringC; | ||
name: t.StringC; | ||
}>>, t.ExactC<t.PartialC<{ | ||
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; | ||
}>>]>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"image">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"FileLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
kind: t.StringC; | ||
id: t.StringC; | ||
url: t.StringC; | ||
name: t.StringC; | ||
size: t.StringC; | ||
}>, t.PartialC<{ | ||
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; | ||
}>]>>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"file">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"DocumentLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
id: t.Type<string, string, unknown>; | ||
}>>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"document">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"ExternalLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
url: t.StringC; | ||
}>, t.PartialC<{ | ||
kind: t.LiteralC<"web">; | ||
target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; | ||
preview: t.UnionC<[t.Type<{ | ||
title?: string; | ||
}, { | ||
title?: string; | ||
}, unknown>, t.NullC, t.UndefinedC]>; | ||
}>]>>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"web">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"MediaLink">; | ||
}>>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"media">; | ||
text: t.StringC; | ||
}>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"AnyLink">; | ||
}>>, t.ExactC<t.TypeC<{ | ||
text: t.StringC; | ||
}>>]>]>; | ||
}>>>; | ||
}>>]>, t.Type<GroupContent, GroupContent, unknown>]>]>>; | ||
}>>>; |
@@ -428,2 +428,76 @@ import * as t from "io-ts"; | ||
__TYPE__: t.LiteralC<"SeparatorContent">; | ||
}>>, t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"RepeatableContent">; | ||
type: t.UnionC<[t.LiteralC<"Color">, t.LiteralC<"Boolean">, t.LiteralC<"Embed">, t.LiteralC<"GeoPoint">, t.LiteralC<"Date">, t.LiteralC<"Number">, t.LiteralC<"Range">, t.LiteralC<"StructuredText">, t.LiteralC<"Select">, t.LiteralC<"Separator">, t.LiteralC<"Text">, t.LiteralC<"Timestamp">, t.LiteralC<"Link">, t.LiteralC<"Image">, t.LiteralC<"IntegrationFields">]>; | ||
value: t.ArrayC<t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"LinkContent">; | ||
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"ImageLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
kind: t.StringC; | ||
id: t.StringC; | ||
url: t.StringC; | ||
height: t.StringC; | ||
width: t.StringC; | ||
size: t.StringC; | ||
name: t.StringC; | ||
}>>, t.ExactC<t.PartialC<{ | ||
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; | ||
}>>]>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"image">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"FileLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
kind: t.StringC; | ||
id: t.StringC; | ||
url: t.StringC; | ||
name: t.StringC; | ||
size: t.StringC; | ||
}>, t.PartialC<{ | ||
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; | ||
}>]>>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"file">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"DocumentLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
id: t.Type<string, string, unknown>; | ||
}>>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"document">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"ExternalLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
url: t.StringC; | ||
}>, t.PartialC<{ | ||
kind: t.LiteralC<"web">; | ||
target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; | ||
preview: t.UnionC<[t.Type<{ | ||
title?: string; | ||
}, { | ||
title?: string; | ||
}, unknown>, t.NullC, t.UndefinedC]>; | ||
}>]>>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"web">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"MediaLink">; | ||
}>>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"media">; | ||
text: t.StringC; | ||
}>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"AnyLink">; | ||
}>>, t.ExactC<t.TypeC<{ | ||
text: t.StringC; | ||
}>>]>]>; | ||
}>>>; | ||
}>>]>, t.Type<GroupContent, GroupContent, unknown>]>; | ||
@@ -612,2 +686,74 @@ export declare type SimpleSliceContent = t.TypeOf<typeof SimpleSliceContent>; | ||
} | { | ||
__TYPE__: "RepeatableContent"; | ||
type: "Boolean" | "Color" | "Date" | "Embed" | "GeoPoint" | "Image" | "IntegrationFields" | "Link" | "Number" | "Range" | "StructuredText" | "Select" | "Separator" | "Text" | "Timestamp"; | ||
value: { | ||
__TYPE__: "LinkContent"; | ||
value: ({ | ||
__TYPE__: "ImageLink"; | ||
} & (({ | ||
kind: string; | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "image"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "FileLink"; | ||
} & (({ | ||
kind: string; | ||
id: string; | ||
url: string; | ||
name: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "file"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "MediaLink"; | ||
} & { | ||
kind: "media"; | ||
text: string; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & (({ | ||
id: string; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "document"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & (({ | ||
url: string; | ||
} & { | ||
kind?: "web"; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string; | ||
} | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "web"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "AnyLink"; | ||
} & { | ||
text: string; | ||
}); | ||
}[]; | ||
} | GroupContent | { | ||
__TYPE__: "StructuredTextContent"; | ||
@@ -767,5 +913,5 @@ value: (({ | ||
__TYPE__: "SeparatorContent"; | ||
} | GroupContent; | ||
}; | ||
export declare const SimpleSliceLegacy: (ctx: LegacyContentCtx) => { | ||
decode: ((value: unknown) => import("fp-ts/lib/Either").Left<t.Errors> | import("fp-ts/lib/Either").Right<{ | ||
decode: ((value: unknown) => import("fp-ts/lib/Either").Right<{ | ||
type: string; | ||
@@ -950,2 +1096,74 @@ __TYPE__: "EmptyContent"; | ||
}); | ||
}> | t.Validation<{ | ||
__TYPE__: "RepeatableContent"; | ||
type: "Boolean" | "Color" | "Date" | "Embed" | "GeoPoint" | "Image" | "IntegrationFields" | "Link" | "Number" | "Range" | "StructuredText" | "Select" | "Separator" | "Text" | "Timestamp"; | ||
value: { | ||
__TYPE__: "LinkContent"; | ||
value: ({ | ||
__TYPE__: "ImageLink"; | ||
} & (({ | ||
kind: string; | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "image"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "FileLink"; | ||
} & (({ | ||
kind: string; | ||
id: string; | ||
url: string; | ||
name: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "file"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "MediaLink"; | ||
} & { | ||
kind: "media"; | ||
text: string; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & (({ | ||
id: string; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "document"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & (({ | ||
url: string; | ||
} & { | ||
kind?: "web"; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string; | ||
} | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "web"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "AnyLink"; | ||
} & { | ||
text: string; | ||
}); | ||
}[]; | ||
}> | import("fp-ts/lib/Either").Right<{ | ||
@@ -952,0 +1170,0 @@ __TYPE__: "StructuredTextContent"; |
@@ -425,2 +425,76 @@ import * as t from "io-ts"; | ||
__TYPE__: t.LiteralC<"SeparatorContent">; | ||
}>>, t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"RepeatableContent">; | ||
type: t.UnionC<[t.LiteralC<"Color">, t.LiteralC<"Boolean">, t.LiteralC<"Embed">, t.LiteralC<"GeoPoint">, t.LiteralC<"Date">, t.LiteralC<"Number">, t.LiteralC<"Range">, t.LiteralC<"StructuredText">, t.LiteralC<"Select">, t.LiteralC<"Separator">, t.LiteralC<"Text">, t.LiteralC<"Timestamp">, t.LiteralC<"Link">, t.LiteralC<"Image">, t.LiteralC<"IntegrationFields">]>; | ||
value: t.ArrayC<t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"LinkContent">; | ||
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"ImageLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
kind: t.StringC; | ||
id: t.StringC; | ||
url: t.StringC; | ||
height: t.StringC; | ||
width: t.StringC; | ||
size: t.StringC; | ||
name: t.StringC; | ||
}>>, t.ExactC<t.PartialC<{ | ||
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; | ||
}>>]>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"image">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"FileLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
kind: t.StringC; | ||
id: t.StringC; | ||
url: t.StringC; | ||
name: t.StringC; | ||
size: t.StringC; | ||
}>, t.PartialC<{ | ||
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; | ||
}>]>>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"file">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"DocumentLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
id: t.Type<string, string, unknown>; | ||
}>>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"document">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"ExternalLink">; | ||
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
url: t.StringC; | ||
}>, t.PartialC<{ | ||
kind: t.LiteralC<"web">; | ||
target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; | ||
preview: t.UnionC<[t.Type<{ | ||
title?: string; | ||
}, { | ||
title?: string; | ||
}, unknown>, t.NullC, t.UndefinedC]>; | ||
}>]>>, t.ExactC<t.PartialC<{ | ||
text: t.StringC; | ||
}>>]>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"web">; | ||
text: t.StringC; | ||
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"MediaLink">; | ||
}>>, t.ExactC<t.TypeC<{ | ||
kind: t.LiteralC<"media">; | ||
text: t.StringC; | ||
}>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{ | ||
__TYPE__: t.LiteralC<"AnyLink">; | ||
}>>, t.ExactC<t.TypeC<{ | ||
text: t.StringC; | ||
}>>]>]>; | ||
}>>>; | ||
}>>]>, t.Type<GroupContent, GroupContent, unknown>]>; | ||
@@ -430,3 +504,3 @@ export declare type SlicePrimaryContent = t.TypeOf<typeof SlicePrimaryContent>; | ||
export declare const SlicePrimaryLegacy: (ctx: LegacyContentCtx) => { | ||
decode(value: unknown): import("fp-ts/lib/Either").Right<{ | ||
decode(value: unknown): import("fp-ts/lib/Either").Left<t.Errors> | import("fp-ts/lib/Either").Right<{ | ||
type: string; | ||
@@ -612,2 +686,74 @@ __TYPE__: "EmptyContent"; | ||
}> | import("fp-ts/lib/Either").Right<{ | ||
__TYPE__: "RepeatableContent"; | ||
type: "Boolean" | "Color" | "Date" | "Embed" | "GeoPoint" | "Image" | "IntegrationFields" | "Link" | "Number" | "Range" | "StructuredText" | "Select" | "Separator" | "Text" | "Timestamp"; | ||
value: { | ||
__TYPE__: "LinkContent"; | ||
value: ({ | ||
__TYPE__: "ImageLink"; | ||
} & (({ | ||
kind: string; | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "image"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "FileLink"; | ||
} & (({ | ||
kind: string; | ||
id: string; | ||
url: string; | ||
name: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "file"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "MediaLink"; | ||
} & { | ||
kind: "media"; | ||
text: string; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & (({ | ||
id: string; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "document"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & (({ | ||
url: string; | ||
} & { | ||
kind?: "web"; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string; | ||
} | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "web"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "AnyLink"; | ||
} & { | ||
text: string; | ||
}); | ||
}[]; | ||
}> | import("fp-ts/lib/Either").Right<{ | ||
__TYPE__: "StructuredTextContent"; | ||
@@ -767,3 +913,3 @@ value: (({ | ||
__TYPE__: "SeparatorContent"; | ||
}> | t.Validation<GroupContent> | undefined; | ||
}> | import("fp-ts/lib/Either").Right<GroupContent> | undefined; | ||
encode(value: SlicePrimaryContent): import("../../../LegacyContentCtx").WithTypes<unknown> | undefined; | ||
@@ -952,2 +1098,74 @@ }; | ||
} | { | ||
__TYPE__: "RepeatableContent"; | ||
type: "Boolean" | "Color" | "Date" | "Embed" | "GeoPoint" | "Image" | "IntegrationFields" | "Link" | "Number" | "Range" | "StructuredText" | "Select" | "Separator" | "Text" | "Timestamp"; | ||
value: { | ||
__TYPE__: "LinkContent"; | ||
value: ({ | ||
__TYPE__: "ImageLink"; | ||
} & (({ | ||
kind: string; | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "image"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "FileLink"; | ||
} & (({ | ||
kind: string; | ||
id: string; | ||
url: string; | ||
name: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "file"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "MediaLink"; | ||
} & { | ||
kind: "media"; | ||
text: string; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & (({ | ||
id: string; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "document"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & (({ | ||
url: string; | ||
} & { | ||
kind?: "web"; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string; | ||
} | null | undefined; | ||
} & { | ||
text?: string; | ||
}) | { | ||
kind: "web"; | ||
text: string; | ||
})) | ({ | ||
__TYPE__: "AnyLink"; | ||
} & { | ||
text: string; | ||
}); | ||
}[]; | ||
} | GroupContent | { | ||
__TYPE__: "StructuredTextContent"; | ||
@@ -1107,2 +1325,2 @@ value: (({ | ||
__TYPE__: "SeparatorContent"; | ||
} | GroupContent; | ||
}; |
@@ -22,2 +22,17 @@ import * as t from "io-ts"; | ||
Choice: null; | ||
"Repeatable.Color": null; | ||
"Repeatable.Boolean": null; | ||
"Repeatable.Number": null; | ||
"Repeatable.Embed": null; | ||
"Repeatable.GeoPoint": null; | ||
"Repeatable.Date": null; | ||
"Repeatable.Range": null; | ||
"Repeatable.StructuredText": null; | ||
"Repeatable.Select": null; | ||
"Repeatable.Separator": null; | ||
"Repeatable.Text": null; | ||
"Repeatable.Timestamp": null; | ||
"Repeatable.Link": null; | ||
"Repeatable.Image": null; | ||
"Repeatable.IntegrationFields": null; | ||
}>, t.KeyofC<{ | ||
@@ -24,0 +39,0 @@ Slice: null; |
@@ -103,2 +103,3 @@ import type { Variation } from "../widgets/slices"; | ||
allowText?: boolean; | ||
repeat?: boolean; | ||
}; | ||
@@ -271,2 +272,3 @@ }) | ({ | ||
allowText?: boolean; | ||
repeat?: boolean; | ||
}; | ||
@@ -439,2 +441,3 @@ }) | ({ | ||
allowText?: boolean; | ||
repeat?: boolean; | ||
}; | ||
@@ -606,2 +609,3 @@ }) | ({ | ||
allowText?: boolean; | ||
repeat?: boolean; | ||
}; | ||
@@ -776,2 +780,3 @@ }) | ({ | ||
allowText?: boolean; | ||
repeat?: boolean; | ||
}; | ||
@@ -944,2 +949,3 @@ }) | ({ | ||
allowText?: boolean; | ||
repeat?: boolean; | ||
}; | ||
@@ -1112,2 +1118,3 @@ }) | ({ | ||
allowText?: boolean; | ||
repeat?: boolean; | ||
}; | ||
@@ -1279,2 +1286,3 @@ }) | ({ | ||
allowText?: boolean; | ||
repeat?: boolean; | ||
}; | ||
@@ -1281,0 +1289,0 @@ }) | ({ |
@@ -135,2 +135,3 @@ import * as t from "io-ts"; | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -305,2 +306,3 @@ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -470,2 +472,3 @@ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -637,2 +640,3 @@ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -809,2 +813,3 @@ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -976,2 +981,3 @@ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -978,0 +984,0 @@ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{ |
@@ -13,2 +13,3 @@ import * as t from "io-ts"; | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -30,4 +31,5 @@ export declare type LinkConfig = t.TypeOf<typeof LinkConfig>; | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
}>]>>; | ||
export declare type Link = t.TypeOf<typeof Link>; |
@@ -46,2 +46,3 @@ "use strict"; | ||
allowText: t.boolean, | ||
repeat: (0, withFallback_1.withFallback)(t.boolean, false), | ||
})); | ||
@@ -54,4 +55,7 @@ exports.Link = t.exact(t.intersection([ | ||
fieldset: validators_1.StringOrNull, | ||
config: exports.LinkConfig, | ||
config: (0, withFallback_1.withFallback)(exports.LinkConfig, { | ||
select: null, | ||
repeat: false, | ||
}), | ||
}), | ||
])); |
@@ -131,2 +131,3 @@ import * as t from "io-ts"; | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -162,2 +163,3 @@ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
export declare type NestableWidget = t.TypeOf<typeof NestableWidget>; | ||
export declare type NestableFieldTypes = NestableWidget["type"]; | ||
export declare const NestableFieldTypes: t.UnionC<[t.LiteralC<"Color">, t.LiteralC<"Boolean">, t.LiteralC<"Embed">, t.LiteralC<"GeoPoint">, t.LiteralC<"Date">, t.LiteralC<"Number">, t.LiteralC<"Range">, t.LiteralC<"StructuredText">, t.LiteralC<"Select">, t.LiteralC<"Separator">, t.LiteralC<"Text">, t.LiteralC<"Timestamp">, t.LiteralC<"Link">, t.LiteralC<"Image">, t.LiteralC<"IntegrationFields">]>; | ||
export declare type NestableFieldTypes = t.TypeOf<typeof NestableFieldTypes>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NestableWidget = void 0; | ||
exports.NestableFieldTypes = exports.NestableWidget = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -38,1 +38,18 @@ const t = (0, tslib_1.__importStar)(require("io-ts")); | ||
]); | ||
exports.NestableFieldTypes = t.union([ | ||
t.literal(Color_1.ColorFieldType), | ||
t.literal(BooleanField_1.BooleanFieldType), | ||
t.literal(Embed_1.EmbedFieldType), | ||
t.literal(GeoPoint_1.GeoPointFieldType), | ||
t.literal(Date_1.DateFieldType), | ||
t.literal(Number_1.NumberFieldType), | ||
t.literal(Range_1.RangeFieldType), | ||
t.literal(RichText_1.RichTextFieldType), | ||
t.literal(Select_1.SelectFieldType), | ||
t.literal(Separator_1.SeparatorFieldType), | ||
t.literal(Text_1.TextFieldType), | ||
t.literal(Timestamp_1.TimestampFieldType), | ||
t.literal(Link_1.LinkFieldType), | ||
t.literal(Image_1.ImageFieldType), | ||
t.literal(IntegrationField_1.IntegrationFieldType), | ||
]); |
@@ -144,2 +144,3 @@ import * as t from "io-ts"; | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -303,2 +304,3 @@ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -305,0 +307,0 @@ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{ |
@@ -132,2 +132,3 @@ import * as t from "io-ts"; | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -299,2 +300,3 @@ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -301,0 +303,0 @@ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{ |
@@ -131,2 +131,3 @@ import * as t from "io-ts"; | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -298,2 +299,3 @@ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -465,2 +467,3 @@ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
allowText: t.BooleanC; | ||
repeat: t.BooleanC; | ||
}>>; | ||
@@ -584,2 +587,3 @@ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
allowText?: boolean; | ||
repeat?: boolean; | ||
}; | ||
@@ -752,2 +756,3 @@ }) | ({ | ||
allowText?: boolean; | ||
repeat?: boolean; | ||
}; | ||
@@ -920,2 +925,3 @@ }) | ({ | ||
allowText?: boolean; | ||
repeat?: boolean; | ||
}; | ||
@@ -922,0 +928,0 @@ }) | ({ |
@@ -37,2 +37,17 @@ "use strict"; | ||
[Slices_1.LegacySlicesFieldType]: null, | ||
[`Repeatable.Color`]: null, | ||
[`Repeatable.Boolean`]: null, | ||
[`Repeatable.Number`]: null, | ||
[`Repeatable.Embed`]: null, | ||
[`Repeatable.GeoPoint`]: null, | ||
[`Repeatable.Date`]: null, | ||
[`Repeatable.Range`]: null, | ||
[`Repeatable.StructuredText`]: null, | ||
[`Repeatable.Select`]: null, | ||
[`Repeatable.Separator`]: null, | ||
[`Repeatable.Text`]: null, | ||
[`Repeatable.Timestamp`]: null, | ||
[`Repeatable.Link`]: null, | ||
[`Repeatable.Image`]: null, | ||
[`Repeatable.IntegrationFields`]: null, | ||
}); | ||
@@ -39,0 +54,0 @@ exports.Widgets = { |
{ | ||
"name": "@prismicio/types-internal", | ||
"version": "2.8.0", | ||
"version": "2.9.0-alpha.0", | ||
"description": "Prismic types for Custom Types and Prismic Data", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -6,2 +6,3 @@ import type { | ||
} from "../content" | ||
import type { RepeatableContent } from "../content/fields/RepeatableContent" | ||
import type { | ||
@@ -34,3 +35,3 @@ CompositeSlice, | ||
export type TraverseWidgetContentFn = < | ||
C extends WidgetContent, | ||
C extends WidgetContent | RepeatableContent, | ||
D extends NestableWidget | StaticSlices | Group | UID, | ||
@@ -61,2 +62,3 @@ >({ | ||
| "items" | ||
| "RepeatableItem" | ||
key: string | ||
@@ -63,0 +65,0 @@ } |
@@ -0,1 +1,25 @@ | ||
/** | ||
* LinkContent is a union of different link content types. | ||
* | ||
* Most link content types are built from a union of a filled and an unfilled version. | ||
* | ||
* Filled versions make sure that the important fields that make the link work | ||
* are present. They are also exported for when there's a need to ensure that | ||
* the link is filled when used in a specific context, e.g. links in rich text fields. | ||
* | ||
* Unfilled versions are used when the link is not filled yet but contains other | ||
* information like the text. | ||
* | ||
* There are some exceptions that don't have a filled version (e.g. MediaLink) | ||
* for when the exact subtype is not yet known. | ||
* | ||
* Unfilled versions all have a special `kind` property that is used to | ||
* determine the type of the link. For legacy reasons, filled versions don't | ||
* necessarily require this property or its type is loose (e.g. `string`). In | ||
* this cases, the type is determined based on a specific combination of the | ||
* rest of the link data. This is why the order of the subtypes in the union is | ||
* important and should be from the most specific to the least specific. A | ||
* battery of tests ensures that the correct type is inferred. | ||
*/ | ||
import { either } from "fp-ts" | ||
@@ -2,0 +26,0 @@ import { pipe } from "fp-ts/lib/function" |
import { isRight } from "fp-ts/lib/Either" | ||
import * as t from "io-ts" | ||
import type { NestableWidget } from "../../../customtypes" | ||
import { type NestableWidget, NestableFieldTypes } from "../../../customtypes" | ||
import type { LegacyContentCtx } from "../../LegacyContentCtx" | ||
import { EmptyContent, EmptyLegacy, isEmptyContent } from "../EmptyContent" | ||
import { | ||
isRepeatableContent, | ||
RepeatableContent, | ||
RepeatableContentType, | ||
RepeatableLegacy, | ||
} from "../RepeatableContent" | ||
import { | ||
BooleanContent, | ||
@@ -99,2 +105,3 @@ BooleanContentDefaultValue, | ||
SeparatorContent, | ||
RepeatableContent, | ||
]) | ||
@@ -133,3 +140,4 @@ export type NestableContent = t.TypeOf<typeof NestableContent> | ||
isSeparatorContent(u) || | ||
isEmptyContent(u) | ||
isEmptyContent(u) || | ||
isRepeatableContent(u) | ||
@@ -144,4 +152,9 @@ export const NestableLegacy = (ctx: LegacyContentCtx) => { | ||
const fieldTypeSplit = ctx?.fieldType?.split(".") | ||
const fieldType = fieldTypeSplit?.[1] ?? ctx.fieldType | ||
if (!NestableFieldTypes.is(fieldType)) return | ||
const codec = (() => { | ||
switch (ctx.fieldType) { | ||
switch (fieldType) { | ||
case "Text": | ||
@@ -184,5 +197,17 @@ return TextLegacy(ctx) | ||
// We check if the Nestable Content is repeated. If so, we decode each | ||
// item in the array using the specific codec for the repeated content. | ||
if (fieldTypeSplit?.[0] === "Repeatable") { | ||
return RepeatableLegacy(ctx, fieldType).decode(value) | ||
} | ||
return codec.decode(value) | ||
}, | ||
encode(value: NestableContent) { | ||
// We check if the Nestable Content is repeated. If so, we decode each | ||
// item in the array using the specific codec for the repeated content. | ||
if (value.__TYPE__ === RepeatableContentType) { | ||
return RepeatableLegacy(ctx, value.type).encode(value) | ||
} | ||
switch (value.__TYPE__) { | ||
@@ -189,0 +214,0 @@ case FieldContentType: { |
@@ -82,2 +82,3 @@ import { either } from "fp-ts/lib/Either" | ||
allowText: t.boolean, | ||
repeat: withFallback(t.boolean, false), | ||
}), | ||
@@ -94,3 +95,6 @@ ) | ||
fieldset: StringOrNull, | ||
config: LinkConfig, | ||
config: withFallback(LinkConfig, { | ||
select: null, | ||
repeat: false, | ||
}), | ||
}), | ||
@@ -97,0 +101,0 @@ ]), |
import * as t from "io-ts" | ||
import { BooleanField } from "./BooleanField" | ||
import { Color } from "./Color" | ||
import { Date } from "./Date" | ||
import { Embed } from "./Embed" | ||
import { GeoPoint } from "./GeoPoint" | ||
import { Image } from "./Image" | ||
import { IntegrationField } from "./IntegrationField" | ||
import { Link } from "./Link" | ||
import { Number } from "./Number" | ||
import { Range } from "./Range" | ||
import { RichText } from "./RichText" | ||
import { Select } from "./Select" | ||
import { Separator } from "./Separator" | ||
import { Text } from "./Text" | ||
import { Timestamp } from "./Timestamp" | ||
import { BooleanField, BooleanFieldType } from "./BooleanField" | ||
import { Color, ColorFieldType } from "./Color" | ||
import { Date, DateFieldType } from "./Date" | ||
import { Embed, EmbedFieldType } from "./Embed" | ||
import { GeoPoint, GeoPointFieldType } from "./GeoPoint" | ||
import { Image, ImageFieldType } from "./Image" | ||
import { IntegrationField, IntegrationFieldType } from "./IntegrationField" | ||
import { Link, LinkFieldType } from "./Link" | ||
import { Number, NumberFieldType } from "./Number" | ||
import { Range, RangeFieldType } from "./Range" | ||
import { RichText, RichTextFieldType } from "./RichText" | ||
import { Select, SelectFieldType } from "./Select" | ||
import { Separator, SeparatorFieldType } from "./Separator" | ||
import { Text, TextFieldType } from "./Text" | ||
import { Timestamp, TimestampFieldType } from "./Timestamp" | ||
@@ -38,2 +38,20 @@ export const NestableWidget = t.union([ | ||
export type NestableWidget = t.TypeOf<typeof NestableWidget> | ||
export type NestableFieldTypes = NestableWidget["type"] | ||
export const NestableFieldTypes = t.union([ | ||
t.literal(ColorFieldType), | ||
t.literal(BooleanFieldType), | ||
t.literal(EmbedFieldType), | ||
t.literal(GeoPointFieldType), | ||
t.literal(DateFieldType), | ||
t.literal(NumberFieldType), | ||
t.literal(RangeFieldType), | ||
t.literal(RichTextFieldType), | ||
t.literal(SelectFieldType), | ||
t.literal(SeparatorFieldType), | ||
t.literal(TextFieldType), | ||
t.literal(TimestampFieldType), | ||
t.literal(LinkFieldType), | ||
t.literal(ImageFieldType), | ||
t.literal(IntegrationFieldType), | ||
]) | ||
export type NestableFieldTypes = t.TypeOf<typeof NestableFieldTypes> |
@@ -64,2 +64,17 @@ import * as t from "io-ts" | ||
[LegacySlicesFieldType]: null, | ||
[`Repeatable.Color`]: null, | ||
[`Repeatable.Boolean`]: null, | ||
[`Repeatable.Number`]: null, | ||
[`Repeatable.Embed`]: null, | ||
[`Repeatable.GeoPoint`]: null, | ||
[`Repeatable.Date`]: null, | ||
[`Repeatable.Range`]: null, | ||
[`Repeatable.StructuredText`]: null, | ||
[`Repeatable.Select`]: null, | ||
[`Repeatable.Separator`]: null, | ||
[`Repeatable.Text`]: null, | ||
[`Repeatable.Timestamp`]: null, | ||
[`Repeatable.Link`]: null, | ||
[`Repeatable.Image`]: null, | ||
[`Repeatable.IntegrationFields`]: null, | ||
}) | ||
@@ -66,0 +81,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3293174
327
78417
2
1