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

@prismicio/api-renderer

Package Overview
Dependencies
Maintainers
19
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prismicio/api-renderer - npm Package Compare versions

Comparing version 1.0.0-alpha.2.0 to 1.0.0-alpha.3

89

lib/DocumentRenderer.d.ts
import { WidgetContent } from "@prismicio/types-internal/lib/documents/widgets";
import { type ApiDocument, type ApiModel, type RelatedDocument, type RenderContext, Fetch } from "./models";
import { WidgetDefO } from "./models";
import { type ApiDocument, type ApiModel, type RelatedDocument, type RenderContext, Fetch, WidgetDefO } from "./models";
declare const DocumentRenderer: (ctx: RenderContext) => {
renderV1: (doc: ApiDocument, content: [string, WidgetContent][], masterLang: string, searchURL: string, i18n: {
renderV1: (doc: ApiDocument, content: [string, WidgetContent][], searchURL: string, i18n: {
[k: string]: ({

@@ -14,23 +13,24 @@ typ: string;

})[];
}, withMeta: boolean, brokenRoute?: string | undefined, linkResolver?: {
[x: string]: {
}, withMeta: boolean, linkResolver?: {
pages: {
[x: string]: {
[x: string]: {
pattern: {
trailingSlash: boolean;
params: ({
isOptional: boolean;
name: string;
type: "custom";
} | {
isOptional: boolean;
type: "uid";
} | {
isOptional: boolean;
type: "lang";
} | {
value: string;
type: "static";
})[];
};
pageType: string;
urlPattern: {
trailingSlash: boolean;
params: ({
isOptional: boolean;
name: string;
type: "custom";
} | {
isOptional: boolean;
type: "uid";
} | {
isOptional: boolean;
type: "lang";
} | {
value: string;
type: "static";
})[];
};
urlResolver: {
resolvers: {

@@ -66,3 +66,3 @@ [x: string]: {

renderWidgetV2: (mask: WidgetDefO, content: WidgetContent, fetchOpt: Fetch.Field | undefined) => unknown;
renderV2: (mask: ApiModel, doc: ApiDocument, masterLang: string, content: [string, WidgetContent][], searchURL: string, i18n: {
renderV2: (mask: ApiModel, doc: ApiDocument, content: [string, WidgetContent][], searchURL: string, i18n: {
[k: string]: ({

@@ -76,23 +76,24 @@ typ: string;

})[];
}, withMeta: boolean, brokenRoute?: string | undefined, linkResolver?: {
[x: string]: {
}, withMeta: boolean, linkResolver?: {
pages: {
[x: string]: {
[x: string]: {
pattern: {
trailingSlash: boolean;
params: ({
isOptional: boolean;
name: string;
type: "custom";
} | {
isOptional: boolean;
type: "uid";
} | {
isOptional: boolean;
type: "lang";
} | {
value: string;
type: "static";
})[];
};
pageType: string;
urlPattern: {
trailingSlash: boolean;
params: ({
isOptional: boolean;
name: string;
type: "custom";
} | {
isOptional: boolean;
type: "uid";
} | {
isOptional: boolean;
type: "lang";
} | {
value: string;
type: "static";
})[];
};
urlResolver: {
resolvers: {

@@ -99,0 +100,0 @@ [x: string]: {

@@ -7,3 +7,2 @@ "use strict";

const models_1 = require("./models");
const models_2 = require("./models");
const utils_1 = require("./utils");

@@ -49,5 +48,3 @@ const widgets_2 = require("./widgets");

const newKey = (isDeprecatedArray ? deprecatedArray[1] : key);
const maybeContent = isDeprecatedArray
? renderedContent[newKey]
: undefined;
const maybeContent = isDeprecatedArray ? renderedContent[newKey] : undefined;
if (fetch !== undefined) {

@@ -58,6 +55,3 @@ const field = fetch.fields[key];

renderedContent[newKey] = Array.isArray(maybeContent)
? [
...maybeContent,
renderWidgetV1(ctx)(widgetContent, field),
]
? [...maybeContent, renderWidgetV1(ctx)(widgetContent, field)]
: [renderWidgetV1(ctx)(widgetContent, field)];

@@ -73,6 +67,3 @@ }

renderedContent[newKey] = Array.isArray(maybeContent)
? [
...maybeContent,
renderWidgetV1(ctx)(widgetContent, undefined),
]
? [...maybeContent, renderWidgetV1(ctx)(widgetContent, undefined)]
: [renderWidgetV1(ctx)(widgetContent, undefined)];

@@ -90,3 +81,3 @@ }

function renderV1(ctx) {
return (doc, content, masterLang, searchURL, i18n, withMeta, brokenRoute, linkResolver, fetchDoc) => {
return (doc, content, searchURL, i18n, withMeta, linkResolver, fetchDoc) => {
var _a, _b;

@@ -103,4 +94,2 @@ const relatedDocs = (i18n[doc.groupLangId] || [])

pageType: doc.type,
masterLang,
brokenRoute,
doc,

@@ -111,8 +100,4 @@ })) !== null && _b !== void 0 ? _b : null,

tags: doc.tags,
first_publication_date: doc.first_publication_date
? (0, utils_1.formatDateTime)(doc.first_publication_date)
: null,
last_publication_date: doc.last_publication_date
? (0, utils_1.formatDateTime)(doc.last_publication_date)
: null,
first_publication_date: doc.first_publication_date ? (0, utils_1.formatDateTime)(doc.first_publication_date) : null,
last_publication_date: doc.last_publication_date ? (0, utils_1.formatDateTime)(doc.last_publication_date) : null,
slugs: doc.data.slugs,

@@ -129,7 +114,6 @@ linked_documents: [],

return (mask, content, fetchOpt) => {
if (content.__TYPE__ === slices_1.SlicesContentType &&
mask.__TYPE__ === models_2.SlicesDefType) {
if (content.__TYPE__ === slices_1.SlicesContentType && mask.__TYPE__ === models_1.SlicesDefType) {
return (0, SlicesRenderer_1.default)(ctx).renderV2(mask, content, models_1.Fetch.extractSliceFetchIfAny(fetchOpt));
}
else if (widgets_1.StaticWidgetContent.is(content) && (0, models_2.isStaticFieldDef)(mask)) {
else if (widgets_1.StaticWidgetContent.is(content) && (0, models_1.isStaticFieldDef)(mask)) {
return (0, widgets_2.StaticWidgetRenderer)(ctx).renderV2(mask, content, models_1.Fetch.extractGroupOrFieldIfAny(fetchOpt));

@@ -143,3 +127,3 @@ }

function renderV2(ctx) {
return (mask, doc, masterLang, content, searchURL, i18n, withMeta, brokenRoute, linkResolver, fetchDoc) => {
return (mask, doc, content, searchURL, i18n, withMeta, linkResolver, fetchDoc) => {
var _a, _b;

@@ -155,9 +139,7 @@ const widgets = mask.definitions

const correspondingContent = content.find(([id]) => id === name.apiId);
const encodedWidgetDef = models_2.WidgetDef.encode(widgetDef);
const encodedWidgetDef = models_1.WidgetDef.encode(widgetDef);
const fetchField = fetchDoc === null || fetchDoc === void 0 ? void 0 : fetchDoc.fields[name.apiId];
const deprecatedArray = name.apiId.match(DEPRECATED_ARRAY_REGEX);
const isDeprecatedArray = Boolean(deprecatedArray && deprecatedArray[1]);
const newKey = (isDeprecatedArray
? deprecatedArray[1]
: name.apiId);
const newKey = (isDeprecatedArray ? deprecatedArray[1] : name.apiId);
if (correspondingContent) {

@@ -178,7 +160,3 @@ if (fetchDoc === undefined || fetchField !== undefined) {

if (fetchDoc === undefined || fetchField !== undefined) {
return [
newKey,
renderDefaultWidget(ctx)(encodedWidgetDef),
isDeprecatedArray,
];
return [newKey, renderDefaultWidget(ctx)(encodedWidgetDef), isDeprecatedArray];
}

@@ -229,4 +207,2 @@ else {

pageType: doc.type,
masterLang,
brokenRoute,
doc,

@@ -237,8 +213,4 @@ })) !== null && _b !== void 0 ? _b : null,

tags: doc.tags,
first_publication_date: doc.first_publication_date
? (0, utils_1.formatDateTime)(doc.first_publication_date)
: null,
last_publication_date: doc.last_publication_date
? (0, utils_1.formatDateTime)(doc.last_publication_date)
: null,
first_publication_date: doc.first_publication_date ? (0, utils_1.formatDateTime)(doc.first_publication_date) : null,
last_publication_date: doc.last_publication_date ? (0, utils_1.formatDateTime)(doc.last_publication_date) : null,
slugs: doc.data.slugs,

@@ -255,7 +227,6 @@ linked_documents: [],

return (mask, content) => {
if (content.__TYPE__ === slices_1.SlicesContentType &&
mask.__TYPE__ === models_2.SlicesDefType) {
if (content.__TYPE__ === slices_1.SlicesContentType && mask.__TYPE__ === models_1.SlicesDefType) {
return (0, SlicesRenderer_1.default)(ctx).renderMocks(mask, content);
}
else if (widgets_1.StaticWidgetContent.is(content) && (0, models_2.isStaticFieldDef)(mask)) {
else if (widgets_1.StaticWidgetContent.is(content) && (0, models_1.isStaticFieldDef)(mask)) {
return (0, widgets_2.StaticWidgetRenderer)(ctx).renderMocks(mask, content);

@@ -284,21 +255,11 @@ }

const correspondingContent = content.find(([id]) => id === name.apiId);
const encodedWidgetDef = models_2.WidgetDef.encode(widgetDef);
const encodedWidgetDef = models_1.WidgetDef.encode(widgetDef);
const deprecatedArray = name.apiId.match(DEPRECATED_ARRAY_REGEX);
const isDeprecatedArray = Boolean(deprecatedArray && deprecatedArray[1]);
const newKey = (isDeprecatedArray
? deprecatedArray[1]
: name.apiId);
const newKey = (isDeprecatedArray ? deprecatedArray[1] : name.apiId);
if (correspondingContent) {
return [
newKey,
renderWidgetMocks(ctx)(encodedWidgetDef, correspondingContent[1]),
isDeprecatedArray,
];
return [newKey, renderWidgetMocks(ctx)(encodedWidgetDef, correspondingContent[1]), isDeprecatedArray];
}
else {
return [
newKey,
renderDefaultWidget(ctx)(encodedWidgetDef),
isDeprecatedArray,
];
return [newKey, renderDefaultWidget(ctx)(encodedWidgetDef), isDeprecatedArray];
}

@@ -355,8 +316,8 @@ }

return (widgetDef) => {
if (widgetDef.__TYPE__ === models_2.SlicesDefType) {
return (0, SlicesRenderer_1.default)(ctx).renderDefault(widgetDef);
if (widgetDef.__TYPE__ === models_1.SlicesDefType) {
(0, SlicesRenderer_1.default)(ctx).renderDefault(widgetDef);
}
else if (widgetDef.__TYPE__ === models_2.SimpleSliceDefType ||
widgetDef.__TYPE__ === models_2.SharedSliceDefType ||
widgetDef.__TYPE__ === models_2.CompositeSliceDefType) {
else if (widgetDef.__TYPE__ === models_1.SimpleSliceDefType ||
widgetDef.__TYPE__ === models_1.SharedSliceDefType ||
widgetDef.__TYPE__ === models_1.CompositeSliceDefType) {
return (0, widgets_2.SliceWidgetRenderer)(ctx).renderDefault(widgetDef);

@@ -363,0 +324,0 @@ }

@@ -53,3 +53,5 @@ "use strict";

getWidget(key) {
return documents_1.DocumentData.getWidget(key, this.widgets, this.fieldTypes, this.fieldPositions, this.parsed);
const widget = documents_1.DocumentData.getWidget(key, this.widgets, this.fieldTypes, this.fieldPositions, this.parsed);
this.parsed.set(key, widget);
return widget;
}

@@ -56,0 +58,0 @@ parseAll() {

@@ -32,3 +32,3 @@ import type { Group } from "@prismicio/types-internal/lib/customtypes/widgets";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -46,3 +46,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -95,3 +95,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -117,3 +117,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -120,0 +120,0 @@ readonly __TYPE__: "selectDef";

@@ -34,3 +34,3 @@ import type { CustomType } from "@prismicio/types-internal/lib/customtypes";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -48,3 +48,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -97,3 +97,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -119,3 +119,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -168,3 +168,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -184,3 +184,3 @@ select: "media";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -225,3 +225,3 @@ __TYPE__: "ConfigDocumentLinkDef";

config: {
options: string[];
options: readonly string[];
};

@@ -231,3 +231,3 @@ }, {

readonly config: {
options: string[];
options: readonly string[];
};

@@ -298,3 +298,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -312,3 +312,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -354,3 +354,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -368,3 +368,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -413,3 +413,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -427,3 +427,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -467,3 +467,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -481,3 +481,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -525,3 +525,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -539,3 +539,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -580,3 +580,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -594,3 +594,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -647,3 +647,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -669,3 +669,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -724,3 +724,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -746,3 +746,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -808,3 +808,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -830,3 +830,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -883,3 +883,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -905,3 +905,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -966,3 +966,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -988,3 +988,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1042,3 +1042,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -1064,3 +1064,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1120,3 +1120,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -1134,3 +1134,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -1175,3 +1175,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -1189,3 +1189,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -1239,3 +1239,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -1261,3 +1261,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1315,3 +1315,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -1337,3 +1337,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1392,3 +1392,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -1406,3 +1406,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -1446,3 +1446,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -1460,3 +1460,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -1513,3 +1513,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -1535,3 +1535,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1588,3 +1588,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -1610,3 +1610,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1664,3 +1664,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -1678,3 +1678,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -1720,3 +1720,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -1734,3 +1734,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -1784,3 +1784,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -1806,3 +1806,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1861,3 +1861,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -1883,3 +1883,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1886,0 +1886,0 @@ readonly __TYPE__: "selectDef";

@@ -6,6 +6,6 @@ import type Link from "@prismicio/types-internal/lib/customtypes/widgets/nestable/Link";

select: "document";
customtypes: string[];
customtypes: readonly string[];
}, {
select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -12,0 +12,0 @@ __TYPE__: "ConfigDocumentLinkDef";

@@ -10,3 +10,3 @@ "use strict";

select: t.literal("document"),
customtypes: t.array(t.string),
customtypes: t.readonlyArray(t.string),
}), exports.DocumentLinkDefType);

@@ -13,0 +13,0 @@ function fromDocumentLink(link) {

@@ -11,3 +11,3 @@ import type { Link } from "@prismicio/types-internal/lib/customtypes/widgets/nestable";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -27,3 +27,3 @@ select: "media";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -30,0 +30,0 @@ __TYPE__: "ConfigDocumentLinkDef";

@@ -12,8 +12,3 @@ "use strict";

const WebLink_1 = require("./WebLink");
const LinkDefConfig = t.union([
MediaLink_1.MediaLinkDef,
DocumentLink_1.DocumentLinkDef,
WebLink_1.WebLinkDef,
AnyLink_1.AnyLinkDef,
]);
const LinkDefConfig = t.union([MediaLink_1.MediaLinkDef, DocumentLink_1.DocumentLinkDef, WebLink_1.WebLinkDef, AnyLink_1.AnyLinkDef]);
exports.LinkDefType = "LinkDefType";

@@ -51,4 +46,2 @@ exports.LinkDef = (0, mapOutput_1.mapOutput)(t.strict({

return (0, WebLink_1.defaultWebLinkDef)();
default:
throw new Error(`[UNREACHABLE] ${type} is unknown`);
}

@@ -55,0 +48,0 @@ })();

@@ -7,3 +7,3 @@ import type { Select } from "@prismicio/types-internal/lib/customtypes/widgets/nestable";

config: {
options: string[];
options: readonly string[];
};

@@ -13,3 +13,3 @@ }, {

readonly config: {
options: string[];
options: readonly string[];
};

@@ -16,0 +16,0 @@ readonly __TYPE__: "selectDef";

@@ -11,3 +11,3 @@ "use strict";

config: t.strict({
options: t.array(t.string),
options: t.readonlyArray(t.string),
}),

@@ -14,0 +14,0 @@ }), (o) => ({ name: o.select, config: o.config, __TYPE__: exports.SelectDefType }));

@@ -31,3 +31,3 @@ import { type UID } from "@prismicio/types-internal/lib/customtypes/widgets";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -47,3 +47,3 @@ select: "media";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -88,3 +88,3 @@ __TYPE__: "ConfigDocumentLinkDef";

config: {
options: string[];
options: readonly string[];
};

@@ -94,3 +94,3 @@ }, {

readonly config: {
options: string[];
options: readonly string[];
};

@@ -97,0 +97,0 @@ readonly __TYPE__: "selectDef";

@@ -32,3 +32,3 @@ import type { CompositeSlice } from "@prismicio/types-internal/lib/customtypes/widgets/slices";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -46,3 +46,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -88,3 +88,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -102,3 +102,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -152,3 +152,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -174,3 +174,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -229,3 +229,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -251,3 +251,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -254,0 +254,0 @@ readonly __TYPE__: "selectDef";

@@ -32,3 +32,3 @@ import type { SharedSlice } from "@prismicio/types-internal/lib/customtypes/widgets/slices";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -46,3 +46,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -86,3 +86,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -100,3 +100,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -150,3 +150,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -172,3 +172,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -225,3 +225,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -247,3 +247,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -303,3 +303,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -317,3 +317,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -357,3 +357,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -371,3 +371,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -424,3 +424,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -446,3 +446,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -499,3 +499,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -521,3 +521,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -524,0 +524,0 @@ readonly __TYPE__: "selectDef";

@@ -32,3 +32,3 @@ import type { LegacySlice } from "@prismicio/types-internal/lib/customtypes/widgets/slices";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -46,3 +46,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -87,3 +87,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -101,3 +101,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -151,3 +151,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -173,3 +173,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -227,3 +227,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -249,3 +249,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -252,0 +252,0 @@ readonly __TYPE__: "selectDef";

@@ -31,3 +31,3 @@ import { CompositeSlice, LegacySlice, SharedSlice } from "@prismicio/types-internal/lib/customtypes/widgets/slices";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -45,3 +45,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -86,3 +86,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -100,3 +100,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -150,3 +150,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -172,3 +172,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -226,3 +226,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -248,3 +248,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -303,3 +303,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -317,3 +317,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -357,3 +357,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -371,3 +371,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -424,3 +424,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -446,3 +446,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -499,3 +499,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -521,3 +521,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -575,3 +575,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -589,3 +589,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -631,3 +631,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -645,3 +645,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -695,3 +695,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -717,3 +717,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -772,3 +772,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -794,3 +794,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -797,0 +797,0 @@ readonly __TYPE__: "selectDef";

@@ -11,7 +11,3 @@ "use strict";

const SimpleSlice_1 = require("./SimpleSlice");
exports.SliceDef = t.union([
SimpleSlice_1.SimpleSliceDef,
SharedSlice_1.SharedSliceDef,
CompositeSlice_1.CompositeSliceDef,
]);
exports.SliceDef = t.union([SimpleSlice_1.SimpleSliceDef, SharedSlice_1.SharedSliceDef, CompositeSlice_1.CompositeSliceDef]);
function fromSlice(key, model) {

@@ -18,0 +14,0 @@ switch (model.type) {

@@ -35,3 +35,3 @@ import { SharedSlice } from "@prismicio/types-internal/lib/customtypes/widgets/slices";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -49,3 +49,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -91,3 +91,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -105,3 +105,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -150,3 +150,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -164,3 +164,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -204,3 +204,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -218,3 +218,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -262,3 +262,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -276,3 +276,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -317,3 +317,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -331,3 +331,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -384,3 +384,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -406,3 +406,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -461,3 +461,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -483,3 +483,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -545,3 +545,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -567,3 +567,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -620,3 +620,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -642,3 +642,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -703,3 +703,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -725,3 +725,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -779,3 +779,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -801,3 +801,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -804,0 +804,0 @@ readonly __TYPE__: "selectDef";

@@ -33,3 +33,3 @@ import { type Group, type UID } from "@prismicio/types-internal/lib/customtypes/widgets";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -47,3 +47,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -96,3 +96,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -118,3 +118,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -167,3 +167,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -183,3 +183,3 @@ select: "media";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -224,3 +224,3 @@ __TYPE__: "ConfigDocumentLinkDef";

config: {
options: string[];
options: readonly string[];
};

@@ -230,3 +230,3 @@ }, {

readonly config: {
options: string[];
options: readonly string[];
};

@@ -233,0 +233,0 @@ readonly __TYPE__: "selectDef";

@@ -36,3 +36,3 @@ import { type Group, type UID } from "@prismicio/types-internal/lib/customtypes/widgets";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -50,3 +50,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -99,3 +99,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -121,3 +121,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -170,3 +170,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -186,3 +186,3 @@ select: "media";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -227,3 +227,3 @@ __TYPE__: "ConfigDocumentLinkDef";

config: {
options: string[];
options: readonly string[];
};

@@ -233,3 +233,3 @@ }, {

readonly config: {
options: string[];
options: readonly string[];
};

@@ -300,3 +300,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -314,3 +314,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -356,3 +356,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -370,3 +370,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -415,3 +415,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -429,3 +429,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -469,3 +469,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -483,3 +483,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -527,3 +527,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -541,3 +541,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -582,3 +582,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -596,3 +596,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -649,3 +649,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -671,3 +671,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -726,3 +726,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -748,3 +748,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -810,3 +810,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -832,3 +832,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -885,3 +885,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -907,3 +907,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -968,3 +968,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -990,3 +990,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1044,3 +1044,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -1066,3 +1066,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1122,3 +1122,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -1136,3 +1136,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -1177,3 +1177,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -1191,3 +1191,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -1241,3 +1241,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -1263,3 +1263,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1317,3 +1317,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -1339,3 +1339,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1394,3 +1394,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -1408,3 +1408,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -1448,3 +1448,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -1462,3 +1462,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -1515,3 +1515,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -1537,3 +1537,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1590,3 +1590,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -1612,3 +1612,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1666,3 +1666,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -1680,3 +1680,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -1722,3 +1722,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} | {

@@ -1736,3 +1736,3 @@ select: "media";

config: {
options: string[];
options: readonly string[];
};

@@ -1786,3 +1786,3 @@ } | {

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -1808,3 +1808,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1863,3 +1863,3 @@ readonly __TYPE__: "selectDef";

select: "document";
customtypes: string[];
customtypes: readonly string[];
} & {

@@ -1885,3 +1885,3 @@ __TYPE__: "ConfigDocumentLinkDef";

readonly config: {
options: string[];
options: readonly string[];
};

@@ -1888,0 +1888,0 @@ readonly __TYPE__: "selectDef";

@@ -79,5 +79,3 @@ "use strict";

if (fetchOpt !== undefined &&
(fetchOpt.TYPE === exports.SimpleFieldType ||
fetchOpt.TYPE === exports.DocRelationType ||
fetchOpt.TYPE === exports.GroupType)) {
(fetchOpt.TYPE === exports.SimpleFieldType || fetchOpt.TYPE === exports.DocRelationType || fetchOpt.TYPE === exports.GroupType)) {
return fetchOpt;

@@ -84,0 +82,0 @@ }

@@ -68,26 +68,3 @@ import * as t from "io-ts";

export declare type URLPattern = t.TypeOf<typeof URLPattern>;
declare const URLResolver: t.RecordC<t.StringC, t.ArrayC<t.TypeC<{
customTypeID: t.StringC;
relationName: t.StringC;
targetCustomTypeID: t.StringC;
}>>>;
export declare type URLResolver = t.TypeOf<typeof URLResolver>;
export declare const Rule: t.TypeC<{
pattern: t.TypeC<{
trailingSlash: t.BooleanC;
params: t.ArrayC<t.UnionC<[t.TypeC<{
value: t.StringC;
type: t.LiteralC<"static">;
}>, t.UnionC<[t.TypeC<{
isOptional: t.BooleanC;
name: t.StringC;
type: t.LiteralC<"custom">;
}>, t.TypeC<{
isOptional: t.BooleanC;
type: t.LiteralC<"uid">;
}>, t.TypeC<{
isOptional: t.BooleanC;
type: t.LiteralC<"lang">;
}>]>]>>;
}>;
declare const URLResolver: t.TypeC<{
resolvers: t.RecordC<t.StringC, t.ArrayC<t.TypeC<{

@@ -99,5 +76,6 @@ customTypeID: t.StringC;

}>;
export declare type Rule = t.TypeOf<typeof Rule>;
export declare const LinkResolver: t.RecordC<t.StringC, t.RecordC<t.StringC, t.RecordC<t.StringC, t.TypeC<{
pattern: t.TypeC<{
export declare type URLResolver = t.TypeOf<typeof URLResolver>;
declare const Page: t.TypeC<{
pageType: t.StringC;
urlPattern: t.TypeC<{
trailingSlash: t.BooleanC;

@@ -119,8 +97,40 @@ params: t.ArrayC<t.UnionC<[t.TypeC<{

}>;
resolvers: t.RecordC<t.StringC, t.ArrayC<t.TypeC<{
customTypeID: t.StringC;
relationName: t.StringC;
targetCustomTypeID: t.StringC;
}>>>;
}>>>>;
urlResolver: t.TypeC<{
resolvers: t.RecordC<t.StringC, t.ArrayC<t.TypeC<{
customTypeID: t.StringC;
relationName: t.StringC;
targetCustomTypeID: t.StringC;
}>>>;
}>;
}>;
export declare type Page = t.TypeOf<typeof Page>;
export declare const LinkResolver: t.TypeC<{
pages: t.RecordC<t.StringC, t.TypeC<{
pageType: t.StringC;
urlPattern: t.TypeC<{
trailingSlash: t.BooleanC;
params: t.ArrayC<t.UnionC<[t.TypeC<{
value: t.StringC;
type: t.LiteralC<"static">;
}>, t.UnionC<[t.TypeC<{
isOptional: t.BooleanC;
name: t.StringC;
type: t.LiteralC<"custom">;
}>, t.TypeC<{
isOptional: t.BooleanC;
type: t.LiteralC<"uid">;
}>, t.TypeC<{
isOptional: t.BooleanC;
type: t.LiteralC<"lang">;
}>]>]>>;
}>;
urlResolver: t.TypeC<{
resolvers: t.RecordC<t.StringC, t.ArrayC<t.TypeC<{
customTypeID: t.StringC;
relationName: t.StringC;
targetCustomTypeID: t.StringC;
}>>>;
}>;
}>>;
}>;
export declare type LinkResolver = t.TypeOf<typeof LinkResolver>;

@@ -127,0 +137,0 @@ export declare type URLPart = {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.customParam = exports.langParam = exports.uidParam = exports.staticParam = exports.LinkResolver = exports.Rule = void 0;
exports.customParam = exports.langParam = exports.uidParam = exports.staticParam = exports.LinkResolver = void 0;
const tslib_1 = require("tslib");

@@ -35,8 +35,13 @@ const t = (0, tslib_1.__importStar)(require("io-ts"));

});
const URLResolver = t.record(t.string, t.array(Relation));
exports.Rule = t.type({
pattern: URLPattern,
resolvers: URLResolver
const URLResolver = t.type({
resolvers: t.record(t.string, t.array(Relation)),
});
exports.LinkResolver = t.record(t.string, t.record(t.string, t.record(t.string, exports.Rule)));
const Page = t.type({
pageType: t.string,
urlPattern: URLPattern,
urlResolver: URLResolver,
});
exports.LinkResolver = t.type({
pages: t.record(t.string, Page),
});
function staticParam(value) {

@@ -43,0 +48,0 @@ return {

@@ -20,4 +20,2 @@ import type { ApiDocument } from "./ApiDocument";

pageType: string;
masterLang: string;
brokenRoute?: string;
doc?: ApiDocument;

@@ -24,0 +22,0 @@ }): string | undefined | null;

import type { GroupContent } from "@prismicio/types-internal/lib/documents/widgets";
import type { GroupDefO } from "../models/ApiModel";
import type { GroupDefO, Renderer } from "../models";
import type { Group as GroupFetch } from "../models/fetch";
import type RenderContext from "../models/RenderContext";
import type { Renderer } from "../models/Renderer";
declare const GroupRenderer: (ctx: RenderContext) => Renderer<GroupDefO, GroupContent, GroupFetch>;
export default GroupRenderer;
import type { BooleanContent } from "@prismicio/types-internal/lib/documents/widgets/nestable";
import type { BooleanFieldDefO } from "../../models/ApiModel";
import type { Renderer } from "../../models/Renderer";
import type { BooleanFieldDefO, Renderer } from "../../models";
declare const BooleanRenderer: Renderer<BooleanFieldDefO, BooleanContent>;
export default BooleanRenderer;
import type { EmbedContentO } from "@prismicio/types-internal/lib/documents/widgets/nestable";
import type { EmbedDefO } from "../../models/ApiModel";
import type { Renderer } from "../../models/Renderer";
import type { EmbedDefO, Renderer } from "../../models";
declare const EmbedRenderer: Renderer<EmbedDefO, EmbedContentO>;
export default EmbedRenderer;
import type { FieldContent } from "@prismicio/types-internal/lib/documents/widgets/nestable";
import type { FieldDefO } from "../../models/ApiModel";
import type { Renderer } from "../../models/Renderer";
import type { FieldDefO, Renderer } from "../../models";
declare const FieldRenderer: Renderer<FieldDefO, FieldContent>;
export default FieldRenderer;
import type { GeoPointContentO } from "@prismicio/types-internal/lib/documents/widgets/nestable";
import type { GeoPointDefO } from "../../models/ApiModel";
import type { Renderer } from "../../models/Renderer";
import type { GeoPointDefO, Renderer } from "../../models";
declare const GeoPointRenderer: Renderer<GeoPointDefO, GeoPointContentO>;
export default GeoPointRenderer;
import type { ImageContentO } from "@prismicio/types-internal/lib/documents/widgets/nestable";
import type { RenderContext } from "../../models";
import type { ImageDefO } from "../../models/ApiModel";
import type { Renderer } from "../../models/Renderer";
import type { ImageDefO, RenderContext, Renderer } from "../../models";
declare const ImageRenderer: (ctx: RenderContext) => Renderer<ImageDefO, ImageContentO>;
export default ImageRenderer;
import type { IntegrationFieldsContent } from "@prismicio/types-internal/lib/documents/widgets/nestable";
import type { IntegrationFieldDefO } from "../../models/ApiModel";
import type { IntegrationFieldDefO, Renderer } from "../../models";
import type RenderContext from "../../models/RenderContext";
import type { Renderer } from "../../models/Renderer";
declare const IntegrationFieldRenderer: (ctx: RenderContext) => Renderer<IntegrationFieldDefO, IntegrationFieldsContent>;
export default IntegrationFieldRenderer;
import { type DocumentLink } from "@prismicio/types-internal/lib/documents/widgets/nestable/Link";
import type { RenderContext } from "../../../models";
import { DocumentLinkDef } from "../../../models/ApiModel";
import { DocumentLinkDef, LinkRenderer } from "../../../models";
import type { DocRelation } from "../../../models/fetch";
import type { LinkRenderer } from "../../../models/Renderer";
declare const DocumentLinkRenderer: (ctx: RenderContext) => LinkRenderer<DocumentLinkDef, DocumentLink, DocRelation>;
export default DocumentLinkRenderer;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Link_1 = require("@prismicio/types-internal/lib/documents/widgets/nestable/Link");
const ApiModel_1 = require("../../../models/ApiModel");
const models_1 = require("../../../models");
function brokenLinkV2(id) {

@@ -43,3 +43,3 @@ return {

renderMocks(def, link) {
const type = (ApiModel_1.DocumentLinkDef.is(def) && def.customtypes[0]) || "mock";
const type = (models_1.DocumentLinkDef.is(def) && def.customtypes[0]) || "mock";
return {

@@ -46,0 +46,0 @@ id: link.id,

import type { ExternalLink } from "@prismicio/types-internal/lib/documents/widgets/nestable/Link";
import type { WebLinkDef } from "../../../models/ApiModel";
import type { LinkRenderer } from "../../../models/Renderer";
import type { LinkRenderer, WebLinkDef } from "../../../models";
declare const ExternalLinkRenderer: LinkRenderer<WebLinkDef, ExternalLink>;
export default ExternalLinkRenderer;
import type { FileLink } from "@prismicio/types-internal/lib/documents/widgets/nestable/Link";
import type { RenderContext } from "../../../models";
import type { MediaLinkDef } from "../../../models/ApiModel";
import type { LinkRenderer } from "../../../models/Renderer";
import type { LinkRenderer, MediaLinkDef } from "../../../models";
declare const FileLinkRenderer: (ctx: RenderContext) => LinkRenderer<MediaLinkDef, FileLink>;
export default FileLinkRenderer;
import type { ImageLink } from "@prismicio/types-internal/lib/documents/widgets/nestable/Link";
import type { RenderContext } from "../../../models";
import type { MediaLinkDef } from "../../../models/ApiModel";
import type { LinkRenderer } from "../../../models/Renderer";
import type { LinkRenderer, MediaLinkDef } from "../../../models";
declare const ImageLinkRenderer: (ctx: RenderContext) => LinkRenderer<MediaLinkDef, ImageLink>;
export default ImageLinkRenderer;

@@ -11,2 +11,2 @@ import { type LinkContent } from "@prismicio/types-internal/lib/documents/widgets/nestable/Link";

export default LinkRenderer;
export { DocumentLinkRenderer, ExternalLinkRenderer, FileLinkRenderer, ImageLinkRenderer, };
export { DocumentLinkRenderer, ExternalLinkRenderer, FileLinkRenderer, ImageLinkRenderer };

@@ -36,16 +36,12 @@ "use strict";

const encoded = Link_1.Link.encode(content.value);
if (encoded.__TYPE__ === "ImageLink" &&
((0, ApiModel_1.isMediaLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def))) {
if (encoded.__TYPE__ === "ImageLink" && ((0, ApiModel_1.isMediaLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def))) {
return (0, ImageLinkRenderer_1.default)(ctx).renderV2(def.config, encoded);
}
else if (((0, ApiModel_1.isDocumentLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def)) &&
encoded.__TYPE__ === "DocumentLink") {
else if (((0, ApiModel_1.isDocumentLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def)) && encoded.__TYPE__ === "DocumentLink") {
return (0, DocumentLinkRenderer_1.default)(ctx).renderV2(def.config, encoded, fetch);
}
else if (((0, ApiModel_1.isMediaLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def)) &&
encoded.__TYPE__ === "FileLink") {
else if (((0, ApiModel_1.isMediaLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def)) && encoded.__TYPE__ === "FileLink") {
return (0, FileLinkRenderer_1.default)(ctx).renderV2(def.config, encoded);
}
else if (((0, ApiModel_1.isWebLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def)) &&
encoded.__TYPE__ === "ExternalLink") {
else if (((0, ApiModel_1.isWebLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def)) && encoded.__TYPE__ === "ExternalLink") {
return ExternalLinkRenderer_1.default.renderV2(def.config, encoded);

@@ -79,16 +75,12 @@ }

const encoded = Link_1.Link.encode(content.value);
if (encoded.__TYPE__ === "ImageLink" &&
((0, ApiModel_1.isMediaLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def))) {
if (encoded.__TYPE__ === "ImageLink" && ((0, ApiModel_1.isMediaLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def))) {
return (0, ImageLinkRenderer_1.default)(ctx).renderMocks(def.config, encoded);
}
else if (((0, ApiModel_1.isDocumentLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def)) &&
encoded.__TYPE__ === "DocumentLink") {
else if (((0, ApiModel_1.isDocumentLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def)) && encoded.__TYPE__ === "DocumentLink") {
return (0, DocumentLinkRenderer_1.default)(ctx).renderMocks(def.config, encoded);
}
else if (((0, ApiModel_1.isMediaLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def)) &&
encoded.__TYPE__ === "FileLink") {
else if (((0, ApiModel_1.isMediaLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def)) && encoded.__TYPE__ === "FileLink") {
return (0, FileLinkRenderer_1.default)(ctx).renderMocks(def.config, encoded);
}
else if (((0, ApiModel_1.isWebLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def)) &&
encoded.__TYPE__ === "ExternalLink") {
else if (((0, ApiModel_1.isWebLinkDef)(def) || (0, ApiModel_1.isAnyLinkDef)(def)) && encoded.__TYPE__ === "ExternalLink") {
return ExternalLinkRenderer_1.default.renderMocks(def.config, encoded);

@@ -95,0 +87,0 @@ }

import type { SeparatorContent } from "@prismicio/types-internal/lib/documents/widgets/nestable";
import type { SeparatorDefO } from "../../models/ApiModel";
import type { Renderer } from "../../models/Renderer";
import type { Renderer, SeparatorDefO } from "../../models";
declare const SeparatorRenderer: Renderer<SeparatorDefO, SeparatorContent>;
export default SeparatorRenderer;

@@ -8,3 +8,3 @@ "use strict";

const models_1 = require("../../../models");
const ApiModel_1 = require("../../../models/ApiModel");
const models_2 = require("../../../models");
const utils_1 = require("../../../utils");

@@ -28,6 +28,6 @@ const Link_2 = (0, tslib_1.__importDefault)(require("../Link"));

else if (apiVersion === models_1.ApiVersion.v2) {
return (0, Link_2.default)(ctx).renderV2((0, ApiModel_1.defaultLinkDef)(linkType()), link, undefined);
return (0, Link_2.default)(ctx).renderV2((0, models_2.defaultLinkDef)(linkType()), link, undefined);
}
else if (apiVersion === models_1.ApiVersion.mocks) {
return (0, Link_2.default)(ctx).renderMocks((0, ApiModel_1.defaultLinkDef)(linkType()), link);
return (0, Link_2.default)(ctx).renderMocks((0, models_2.defaultLinkDef)(linkType()), link);
}

@@ -34,0 +34,0 @@ }

@@ -10,3 +10,3 @@ "use strict";

function renderSummaryJson(text, renderer) {
const firstBlock = (0, function_1.pipe)(O.fromNullable(text.value.find((block) => block.type === "header")), O.alt(() => O.fromNullable(text.value.find((block) => block.type !== "embed" && block.type !== "image"))), O.map((block) => [block]), O.getOrElse(() => []));
const firstBlock = (0, function_1.pipe)(O.fromNullable(text.value.find((block) => block.type.startsWith("heading"))), O.alt(() => O.fromNullable(text.value.find((block) => block.type !== "embed" && block.type !== "image"))), O.map((block) => [block]), O.getOrElse(() => []));
return renderer({

@@ -13,0 +13,0 @@ __TYPE__: StructuredTextContent_1.StructuredTextContentType,

import type { SimpleWidgetContent } from "@prismicio/types-internal/lib/documents/widgets";
import type { RenderContext } from "../models";
import { SimpleFieldDefO } from "../models/ApiModel";
import type { Renderer } from "../models";
import { SimpleFieldDefO } from "../models";
import { Field } from "../models/fetch";
import type { Renderer } from "../models/Renderer";
declare const SimpleWidgetRenderer: (ctx: RenderContext) => Renderer<SimpleFieldDefO, SimpleWidgetContent, Field> & {

@@ -7,0 +7,0 @@ renderObjectOfSimpleWidgetV1(content: Array<[string, SimpleWidgetContent]> | Record<string, SimpleWidgetContent>, fetch: Record<string, Field> | undefined): object;

@@ -6,5 +6,10 @@ "use strict";

const nestable_1 = require("@prismicio/types-internal/lib/documents/widgets/nestable");
const BooleanContent_1 = require("@prismicio/types-internal/lib/documents/widgets/nestable/BooleanContent");
const GeoPointContent_1 = require("@prismicio/types-internal/lib/documents/widgets/nestable/GeoPointContent");
const ImageContent_1 = require("@prismicio/types-internal/lib/documents/widgets/nestable/ImageContent");
const IntegrationFieldsContent_1 = require("@prismicio/types-internal/lib/documents/widgets/nestable/IntegrationFieldsContent");
const LinkContent_1 = require("@prismicio/types-internal/lib/documents/widgets/nestable/Link/LinkContent");
const Array_1 = require("fp-ts/lib/Array");
const O = (0, tslib_1.__importStar)(require("fp-ts/lib/Option"));
const ApiModel_1 = require("../models/ApiModel");
const models_1 = require("../models");
const fetch_1 = require("../models/fetch");

@@ -32,6 +37,6 @@ const utils_1 = require("../utils");

renderV1(content, fetch) {
if (nestable_1.StructuredTextContent.is(content)) {
if (content.__TYPE__ === nestable_1.StructuredTextContentType) {
return (0, nestable_2.StructuredTextRenderer)(ctx).renderV1(content, extractSimpleFieldIfAny(fetch));
}
else if (nestable_1.ImageContent.is(content)) {
else if (content.__TYPE__ === ImageContent_1.ImageContentType) {
return (0, nestable_2.ImageRenderer)(ctx).renderV1(content);

@@ -42,21 +47,21 @@ }

}
else if (nestable_1.Links.LinkContent.is(content)) {
else if (content.__TYPE__ === LinkContent_1.LinkContentType) {
return (0, nestable_2.LinkRenderer)(ctx).renderV1(content, extractFetchDocRelationIfAny(fetch));
}
else if (nestable_1.EmbedContent.is(content)) {
else if (content.__TYPE__ === nestable_1.EmbedContentType) {
return nestable_2.EmbedRenderer.renderV1(content);
}
else if (nestable_1.GeoPointContent.is(content)) {
else if (content.__TYPE__ === GeoPointContent_1.GeoPointContentType) {
return nestable_2.GeoPointRenderer.renderV1(content);
}
else if (widgets_1.UIDContent.is(content)) {
else if (content.__TYPE__ === widgets_1.UIDContentType) {
return UIDRenderer_1.default.renderV1(content);
}
else if (nestable_1.IntegrationFieldsContent.is(content)) {
else if (content.__TYPE__ === IntegrationFieldsContent_1.IntegrationFieldsContentType) {
return (0, nestable_2.IntegrationFieldsRenderer)(ctx).renderV1(content);
}
else if (nestable_1.SeparatorContent.is(content)) {
else if (content.__TYPE__ === nestable_1.SeparatorContentType) {
return nestable_2.SeparatorRenderer.renderV1(content);
}
else if (nestable_1.BooleanContent.is(content)) {
else if (content.__TYPE__ === BooleanContent_1.BooleanContentType) {
return nestable_2.BooleanRenderer.renderV1(content);

@@ -69,32 +74,27 @@ }

renderV2(def, content, fetch) {
if (def.__TYPE__ === ApiModel_1.StructuredTextDefType &&
nestable_1.StructuredTextContent.is(content)) {
if (def.__TYPE__ === models_1.StructuredTextDefType && nestable_1.StructuredTextContent.is(content)) {
return (0, nestable_2.StructuredTextRenderer)(ctx).renderV2(def, content, extractSimpleFieldIfAny(fetch));
}
else if (def.__TYPE__ === ApiModel_1.ImageDefType && nestable_1.ImageContent.is(content)) {
else if (def.__TYPE__ === models_1.ImageDefType && nestable_1.ImageContent.is(content)) {
return (0, nestable_2.ImageRenderer)(ctx).renderV2(def, content);
}
else if (def.__TYPE__ === ApiModel_1.LinkDefType && nestable_1.Links.LinkContent.is(content)) {
else if (def.__TYPE__ === models_1.LinkDefType && nestable_1.Links.LinkContent.is(content)) {
return (0, nestable_2.LinkRenderer)(ctx).renderV2(def, content, extractFetchDocRelationIfAny(fetch));
}
else if (def.__TYPE__ === ApiModel_1.EmbedDefType && nestable_1.EmbedContent.is(content)) {
else if (def.__TYPE__ === models_1.EmbedDefType && nestable_1.EmbedContent.is(content)) {
return nestable_2.EmbedRenderer.renderV2(def, content);
}
else if (def.__TYPE__ === ApiModel_1.GeoPointDefType &&
nestable_1.GeoPointContent.is(content)) {
else if (def.__TYPE__ === models_1.GeoPointDefType && nestable_1.GeoPointContent.is(content)) {
return nestable_2.GeoPointRenderer.renderV2(def, content);
}
else if (def.__TYPE__ === ApiModel_1.UIDDefType && widgets_1.UIDContent.is(content)) {
else if (def.__TYPE__ === models_1.UIDDefType && widgets_1.UIDContent.is(content)) {
return UIDRenderer_1.default.renderV2(def, content);
}
else if (def.__TYPE__ === ApiModel_1.IntegrationFieldDefType &&
nestable_1.IntegrationFieldsContent.is(content)) {
else if (def.__TYPE__ === models_1.IntegrationFieldDefType && nestable_1.IntegrationFieldsContent.is(content)) {
return (0, nestable_2.IntegrationFieldsRenderer)(ctx).renderV2(def, content);
}
else if (def.__TYPE__ === ApiModel_1.SeparatorDefType &&
nestable_1.SeparatorContent.is(content)) {
else if (def.__TYPE__ === models_1.SeparatorDefType && nestable_1.SeparatorContent.is(content)) {
return nestable_2.SeparatorRenderer.renderV2(def, content);
}
else if (def.__TYPE__ === ApiModel_1.BooleanFieldDefType &&
nestable_1.BooleanContent.is(content)) {
else if (def.__TYPE__ === models_1.BooleanFieldDefType && nestable_1.BooleanContent.is(content)) {
return nestable_2.BooleanRenderer.renderV2(def, content);

@@ -110,27 +110,27 @@ }

renderDefault(def) {
if (def.__TYPE__ === ApiModel_1.LinkDefType) {
if (def.__TYPE__ === models_1.LinkDefType) {
return (0, nestable_2.LinkRenderer)(ctx).renderDefault(def);
}
else if (def.__TYPE__ === ApiModel_1.EmbedDefType) {
else if (def.__TYPE__ === models_1.EmbedDefType) {
return nestable_2.EmbedRenderer.renderDefault(def);
}
else if (def.__TYPE__ === ApiModel_1.GeoPointDefType) {
else if (def.__TYPE__ === models_1.GeoPointDefType) {
return nestable_2.GeoPointRenderer.renderDefault(def);
}
else if (def.__TYPE__ === ApiModel_1.StructuredTextDefType) {
else if (def.__TYPE__ === models_1.StructuredTextDefType) {
return (0, nestable_2.StructuredTextRenderer)(ctx).renderDefault(def);
}
else if (def.__TYPE__ === ApiModel_1.ImageDefType) {
else if (def.__TYPE__ === models_1.ImageDefType) {
return (0, nestable_2.ImageRenderer)(ctx).renderDefault(def);
}
else if (def.__TYPE__ === ApiModel_1.SeparatorDefType) {
else if (def.__TYPE__ === models_1.SeparatorDefType) {
return nestable_2.SeparatorRenderer.renderDefault(def);
}
else if (def.__TYPE__ === ApiModel_1.UIDDefType) {
else if (def.__TYPE__ === models_1.UIDDefType) {
return UIDRenderer_1.default.renderDefault(def);
}
else if (def.__TYPE__ === ApiModel_1.BooleanFieldDefType) {
else if (def.__TYPE__ === models_1.BooleanFieldDefType) {
return nestable_2.BooleanRenderer.renderDefault(def);
}
else if (def.__TYPE__ === ApiModel_1.IntegrationFieldDefType) {
else if (def.__TYPE__ === models_1.IntegrationFieldDefType) {
return (0, nestable_2.IntegrationFieldsRenderer)(ctx).renderDefault(def);

@@ -143,32 +143,27 @@ }

renderMocks(def, content) {
if (def.__TYPE__ === ApiModel_1.StructuredTextDefType &&
nestable_1.StructuredTextContent.is(content)) {
if (def.__TYPE__ === models_1.StructuredTextDefType && nestable_1.StructuredTextContent.is(content)) {
return (0, nestable_2.StructuredTextRenderer)(ctx).renderMocks(def, content);
}
else if (def.__TYPE__ === ApiModel_1.ImageDefType && nestable_1.ImageContent.is(content)) {
else if (def.__TYPE__ === models_1.ImageDefType && nestable_1.ImageContent.is(content)) {
return (0, nestable_2.ImageRenderer)(ctx).renderMocks(def, content);
}
else if (def.__TYPE__ === ApiModel_1.LinkDefType && nestable_1.Links.LinkContent.is(content)) {
else if (def.__TYPE__ === models_1.LinkDefType && nestable_1.Links.LinkContent.is(content)) {
return (0, nestable_2.LinkRenderer)(ctx).renderMocks(def, content);
}
else if (def.__TYPE__ === ApiModel_1.EmbedDefType && nestable_1.EmbedContent.is(content)) {
else if (def.__TYPE__ === models_1.EmbedDefType && nestable_1.EmbedContent.is(content)) {
return nestable_2.EmbedRenderer.renderMocks(def, content);
}
else if (def.__TYPE__ === ApiModel_1.GeoPointDefType &&
nestable_1.GeoPointContent.is(content)) {
else if (def.__TYPE__ === models_1.GeoPointDefType && nestable_1.GeoPointContent.is(content)) {
return nestable_2.GeoPointRenderer.renderMocks(def, content);
}
else if (def.__TYPE__ === ApiModel_1.UIDDefType && widgets_1.UIDContent.is(content)) {
else if (def.__TYPE__ === models_1.UIDDefType && widgets_1.UIDContent.is(content)) {
return UIDRenderer_1.default.renderMocks(def, content);
}
else if (def.__TYPE__ === ApiModel_1.IntegrationFieldDefType &&
nestable_1.IntegrationFieldsContent.is(content)) {
else if (def.__TYPE__ === models_1.IntegrationFieldDefType && nestable_1.IntegrationFieldsContent.is(content)) {
return (0, nestable_2.IntegrationFieldsRenderer)(ctx).renderMocks(def, content);
}
else if (def.__TYPE__ === ApiModel_1.SeparatorDefType &&
nestable_1.SeparatorContent.is(content)) {
else if (def.__TYPE__ === models_1.SeparatorDefType && nestable_1.SeparatorContent.is(content)) {
return nestable_2.SeparatorRenderer.renderMocks(def, content);
}
else if (def.__TYPE__ === ApiModel_1.BooleanFieldDefType &&
nestable_1.BooleanContent.is(content)) {
else if (def.__TYPE__ === models_1.BooleanFieldDefType && nestable_1.BooleanContent.is(content)) {
return nestable_2.BooleanRenderer.renderMocks(def, content);

@@ -175,0 +170,0 @@ }

import type { CompositeSliceContent } from "@prismicio/types-internal/lib/documents/widgets/slices";
import type { RenderContext } from "../../models";
import type { CompositeSliceDefO } from "../../models/ApiModel";
import type { CompositeSliceDefO, RenderContext } from "../../models";
import { CompositeSlice } from "../../models/fetch";

@@ -5,0 +4,0 @@ import type { SliceRenderer } from "../../models/Renderer";

import type { SharedSliceContent } from "@prismicio/types-internal/lib/documents/widgets/slices";
import type { RenderContext } from "../../models";
import type { SharedSliceDefO } from "../../models/ApiModel";
import type { RenderContext, SharedSliceDefO } from "../../models";
import type { SharedSlice } from "../../models/fetch";

@@ -5,0 +4,0 @@ import type { SliceRenderer } from "../../models/Renderer";

import type { SimpleSliceContent } from "@prismicio/types-internal/lib/documents/widgets/slices";
import type { RenderContext } from "../../models";
import type { SimpleSliceDefO } from "../../models/ApiModel";
import type { RenderContext, SimpleSliceDefO } from "../../models";
import type { GroupOrField } from "../../models/fetch";

@@ -5,0 +4,0 @@ import type { SliceRenderer } from "../../models/Renderer";

import type { SlicesContent } from "@prismicio/types-internal/lib/documents/widgets/slices";
import type { RenderContext } from "../../models";
import type { SlicesDefO } from "../../models/ApiModel";
import type { Renderer, SlicesDefO } from "../../models";
import type { SliceZone } from "../../models/fetch";
import type { Renderer } from "../../models/Renderer";
declare const SlicesRenderer: (ctx: RenderContext) => Renderer<SlicesDefO, SlicesContent, SliceZone>;
export default SlicesRenderer;

@@ -18,4 +18,3 @@ "use strict";

function renderContent(slice, sliceFetch, ctx, keyToSliceDef) {
if ("__TYPE__" in slice.widget &&
slice.widget.__TYPE__ === EmptyContent_1.EmptyContentType) {
if ("__TYPE__" in slice.widget && slice.widget.__TYPE__ === EmptyContent_1.EmptyContentType) {
return O.none;

@@ -22,0 +21,0 @@ }

import { type SliceWidgetContent } from "@prismicio/types-internal/lib/documents/widgets/slices";
import type { RenderContext } from "../../models";
import { SliceDefO } from "../../models/ApiModel";
import { SliceDefO } from "../../models";
import { GroupOrField, Slice } from "../../models/fetch";

@@ -5,0 +5,0 @@ import type { SliceRenderer } from "../../models/Renderer";

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

const O = (0, tslib_1.__importStar)(require("fp-ts/lib/Option"));
const ApiModel_1 = require("../../models/ApiModel");
const models_1 = require("../../models");
const fetch_1 = require("../../models/fetch");

@@ -26,5 +26,3 @@ const CompositeSliceRenderer_1 = (0, tslib_1.__importDefault)(require("./CompositeSliceRenderer"));

extractGroupOrField(fetch) {
if (fetch !== undefined &&
fetch.TYPE !== fetch_1.CompositeSliceType &&
fetch.TYPE !== fetch_1.SharedSliceType) {
if (fetch !== undefined && fetch.TYPE !== fetch_1.CompositeSliceType && fetch.TYPE !== fetch_1.SharedSliceType) {
return fetch;

@@ -49,3 +47,3 @@ }

if (content.__TYPE__ === slices_1.CompositeSliceContentType) {
if (def.__TYPE__ === ApiModel_1.CompositeSliceDefType) {
if (def.__TYPE__ === models_1.CompositeSliceDefType) {
return O.some((0, CompositeSliceRenderer_1.default)(ctx).renderV2(def, content, Fetch.extractCompositeSlice(fetch)));

@@ -55,3 +53,3 @@ }

else if (content && content.__TYPE__ === slices_1.SharedSliceContentType) {
if (def.__TYPE__ === ApiModel_1.SharedSliceDefType) {
if (def.__TYPE__ === models_1.SharedSliceDefType) {
return O.some((0, SharedSliceRenderer_1.default)(ctx).renderV2(def, content, Fetch.extractSharedSlice(fetch)));

@@ -61,3 +59,3 @@ }

else {
if (def.__TYPE__ === ApiModel_1.SimpleSliceDefType) {
if (def.__TYPE__ === models_1.SimpleSliceDefType) {
return (0, SimpleSliceRenderer_1.default)(ctx).renderV2(def, content, Fetch.extractGroupOrField(fetch));

@@ -73,3 +71,3 @@ }

if (content.__TYPE__ === slices_1.CompositeSliceContentType) {
if (def.__TYPE__ === ApiModel_1.CompositeSliceDefType) {
if (def.__TYPE__ === models_1.CompositeSliceDefType) {
return O.some((0, CompositeSliceRenderer_1.default)(ctx).renderMocks(def, content));

@@ -79,3 +77,3 @@ }

else if (content && content.__TYPE__ === slices_1.SharedSliceContentType) {
if (def.__TYPE__ === ApiModel_1.SharedSliceDefType) {
if (def.__TYPE__ === models_1.SharedSliceDefType) {
return O.some((0, SharedSliceRenderer_1.default)(ctx).renderMocks(def, content));

@@ -85,3 +83,3 @@ }

else {
if (def.__TYPE__ === ApiModel_1.SimpleSliceDefType) {
if (def.__TYPE__ === models_1.SimpleSliceDefType) {
return (0, SimpleSliceRenderer_1.default)(ctx).renderMocks(def, content);

@@ -88,0 +86,0 @@ }

import type { StaticWidgetContent } from "@prismicio/types-internal/lib/documents/widgets";
import type { RenderContext, Renderer } from "../models";
import { type StaticDefO } from "../models/ApiModel";
import { type StaticDefO } from "../models";
import { GroupOrField } from "../models/fetch";
declare const StaticWidgetRenderer: (ctx: RenderContext) => Renderer<StaticDefO, StaticWidgetContent, GroupOrField>;
export default StaticWidgetRenderer;

@@ -5,3 +5,3 @@ "use strict";

const widgets_1 = require("@prismicio/types-internal/lib/documents/widgets");
const ApiModel_1 = require("../models/ApiModel");
const models_1 = require("../models");
const fetch_1 = require("../models/fetch");

@@ -36,8 +36,7 @@ const GroupRenderer_1 = (0, tslib_1.__importDefault)(require("./GroupRenderer"));

renderV2(def, content, fetch) {
if (widgets_1.SimpleWidgetContent.is(content) && (0, ApiModel_1.isSimpleFieldDef)(def)) {
if (widgets_1.SimpleWidgetContent.is(content) && (0, models_1.isSimpleFieldDef)(def)) {
// todo maybe find an other condition
return (0, SimpleWidgetRenderer_1.default)(ctx).renderV2(def, content, extractFetchFieldIfAny(fetch));
}
else if (content.__TYPE__ === widgets_1.WidgetTypes.Group &&
def.__TYPE__ === ApiModel_1.GroupDefType) {
else if (content.__TYPE__ === widgets_1.WidgetTypes.Group && def.__TYPE__ === models_1.GroupDefType) {
return (0, GroupRenderer_1.default)(ctx).renderV2(def, content, extractFetchGroupIfAny(fetch));

@@ -50,3 +49,3 @@ }

renderDefault(def) {
if (def.__TYPE__ === ApiModel_1.GroupDefType) {
if (def.__TYPE__ === models_1.GroupDefType) {
return (0, GroupRenderer_1.default)(ctx).renderDefault(def);

@@ -59,7 +58,6 @@ }

renderMocks(def, content) {
if (widgets_1.SimpleWidgetContent.is(content) && (0, ApiModel_1.isSimpleFieldDef)(def)) {
if (widgets_1.SimpleWidgetContent.is(content) && (0, models_1.isSimpleFieldDef)(def)) {
return (0, SimpleWidgetRenderer_1.default)(ctx).renderMocks(def, content);
}
else if (content.__TYPE__ === widgets_1.WidgetTypes.Group &&
def.__TYPE__ === ApiModel_1.GroupDefType) {
else if (content.__TYPE__ === widgets_1.WidgetTypes.Group && def.__TYPE__ === models_1.GroupDefType) {
return (0, GroupRenderer_1.default)(ctx).renderMocks(def, content);

@@ -66,0 +64,0 @@ }

import { UIDContent } from "@prismicio/types-internal/lib/documents/widgets";
import type { UIDDefO } from "../models/ApiModel";
import type { Renderer } from "../models/Renderer";
import type { Renderer, UIDDefO } from "../models";
declare const UIDRenderer: Renderer<UIDDefO, UIDContent>;
export default UIDRenderer;
{
"name": "@prismicio/api-renderer",
"version": "1.0.0-alpha.2.0",
"version": "1.0.0-alpha.3",
"description": "Prismic renderers for the content API",

@@ -38,3 +38,3 @@ "keywords": [

"dependencies": {
"@prismicio/types-internal": "0.2.10",
"@prismicio/types-internal": "1.0.0-alpha.0",
"tslib": "^2.3.1"

@@ -41,0 +41,0 @@ },

@@ -16,6 +16,4 @@ import {

type RenderContext,
CompositeSliceDefType,
Fetch,
} from "./models"
import {
CompositeSliceDefType,
isStaticFieldDef,

@@ -50,18 +48,9 @@ SharedSliceDefType,

function renderWidgetV1(ctx: RenderContext) {
return (
content: WidgetContent,
fetchOpt: Fetch.Field | undefined,
): unknown => {
return (content: WidgetContent, fetchOpt: Fetch.Field | undefined): unknown => {
if (content.__TYPE__ === EmptyContentType) {
return undefined
} else if (StaticWidgetContent.is(content) && !EmptyContent.is(content)) {
return StaticWidgetRenderer(ctx).renderV1(
content,
Fetch.extractGroupOrFieldIfAny(fetchOpt),
)
return StaticWidgetRenderer(ctx).renderV1(content, Fetch.extractGroupOrFieldIfAny(fetchOpt))
} else {
return SlicesRenderer(ctx).renderV1(
content,
Fetch.extractSliceFetchIfAny(fetchOpt),
)
return SlicesRenderer(ctx).renderV1(content, Fetch.extractSliceFetchIfAny(fetchOpt))
}

@@ -72,7 +61,3 @@ }

function renderWidgetsV1(ctx: RenderContext) {
return (
doc: ApiDocument,
content: [string, WidgetContent][],
fetch: Fetch.Doc | undefined,
): unknown => {
return (doc: ApiDocument, content: [string, WidgetContent][], fetch: Fetch.Doc | undefined): unknown => {
const renderedContent: Record<string, unknown> = {}

@@ -85,5 +70,3 @@ for (const [key, widgetContent] of content) {

const newKey = (isDeprecatedArray ? deprecatedArray[1] : key) as string
const maybeContent: undefined | unknown = isDeprecatedArray
? renderedContent[newKey]
: undefined
const maybeContent: undefined | unknown = isDeprecatedArray ? renderedContent[newKey] : undefined

@@ -95,12 +78,6 @@ if (fetch !== undefined) {

renderedContent[newKey] = Array.isArray(maybeContent)
? [
...(maybeContent as unknown[]),
renderWidgetV1(ctx)(widgetContent, field),
]
? [...(maybeContent as unknown[]), renderWidgetV1(ctx)(widgetContent, field)]
: [renderWidgetV1(ctx)(widgetContent, field)]
} else {
renderedContent[newKey] = renderWidgetV1(ctx)(
widgetContent,
field,
)
renderedContent[newKey] = renderWidgetV1(ctx)(widgetContent, field)
}

@@ -111,12 +88,6 @@ }

renderedContent[newKey] = Array.isArray(maybeContent)
? [
...(maybeContent as unknown[]),
renderWidgetV1(ctx)(widgetContent, undefined),
]
? [...(maybeContent as unknown[]), renderWidgetV1(ctx)(widgetContent, undefined)]
: [renderWidgetV1(ctx)(widgetContent, undefined)]
} else {
renderedContent[newKey] = renderWidgetV1(ctx)(
widgetContent,
undefined,
)
renderedContent[newKey] = renderWidgetV1(ctx)(widgetContent, undefined)
}

@@ -135,7 +106,5 @@ }

content: [string, WidgetContent][],
masterLang: string,
searchURL: string,
i18n: { [k: string]: RelatedDocument[] },
withMeta: boolean,
brokenRoute?: string,
linkResolver?: LinkResolver,

@@ -156,4 +125,2 @@ fetchDoc?: Fetch.Doc,

pageType: doc.type,
masterLang,
brokenRoute,
doc,

@@ -164,8 +131,4 @@ }) ?? null,

tags: doc.tags,
first_publication_date: doc.first_publication_date
? formatDateTime(doc.first_publication_date)
: null,
last_publication_date: doc.last_publication_date
? formatDateTime(doc.last_publication_date)
: null,
first_publication_date: doc.first_publication_date ? formatDateTime(doc.first_publication_date) : null,
last_publication_date: doc.last_publication_date ? formatDateTime(doc.last_publication_date) : null,
slugs: doc.data.slugs,

@@ -182,22 +145,7 @@ linked_documents: [],

function renderWidgetV2(ctx: RenderContext) {
return (
mask: WidgetDefO,
content: WidgetContent,
fetchOpt: Fetch.Field | undefined,
): unknown => {
if (
content.__TYPE__ === SlicesContentType &&
mask.__TYPE__ === SlicesDefType
) {
return SlicesRenderer(ctx).renderV2(
mask,
content,
Fetch.extractSliceFetchIfAny(fetchOpt),
)
return (mask: WidgetDefO, content: WidgetContent, fetchOpt: Fetch.Field | undefined): unknown => {
if (content.__TYPE__ === SlicesContentType && mask.__TYPE__ === SlicesDefType) {
return SlicesRenderer(ctx).renderV2(mask, content, Fetch.extractSliceFetchIfAny(fetchOpt))
} else if (StaticWidgetContent.is(content) && isStaticFieldDef(mask)) {
return StaticWidgetRenderer(ctx).renderV2(
mask,
content,
Fetch.extractGroupOrFieldIfAny(fetchOpt),
)
return StaticWidgetRenderer(ctx).renderV2(mask, content, Fetch.extractGroupOrFieldIfAny(fetchOpt))
} else {

@@ -213,3 +161,2 @@ return renderDefaultWidget(ctx)(mask)

doc: ApiDocument,
masterLang: string,
content: [string, WidgetContent][],

@@ -219,3 +166,2 @@ searchURL: string,

withMeta: boolean,
brokenRoute?: string,
linkResolver?: LinkResolver,

@@ -227,5 +173,3 @@ fetchDoc?: Fetch.Doc,

.map<[string, unknown, boolean] | undefined>((widgetDef: WidgetDef) => {
const filteredWidget = Object.entries(widgetDef).find(
([k]) => k !== "config",
) // name[0] is the SimpleFieldDef name i.e. the widget name and apiId the api id of the field
const filteredWidget = Object.entries(widgetDef).find(([k]) => k !== "config") // name[0] is the SimpleFieldDef name i.e. the widget name and apiId the api id of the field
const name: { apiId: string } | undefined = filteredWidget && {

@@ -241,10 +185,4 @@ apiId: filteredWidget[1] as string,

const deprecatedArray = name.apiId.match(DEPRECATED_ARRAY_REGEX)
const isDeprecatedArray = Boolean(
deprecatedArray && deprecatedArray[1],
)
const newKey = (
isDeprecatedArray
? (deprecatedArray as RegExpExecArray)[1]
: name.apiId
) as string
const isDeprecatedArray = Boolean(deprecatedArray && deprecatedArray[1])
const newKey = (isDeprecatedArray ? (deprecatedArray as RegExpExecArray)[1] : name.apiId) as string

@@ -255,7 +193,3 @@ if (correspondingContent) {

newKey,
renderWidgetV2(ctx)(
encodedWidgetDef,
correspondingContent[1],
fetchField,
),
renderWidgetV2(ctx)(encodedWidgetDef, correspondingContent[1], fetchField),
isDeprecatedArray,

@@ -269,7 +203,3 @@ ]

if (fetchDoc === undefined || fetchField !== undefined) {
return [
newKey,
renderDefaultWidget(ctx)(encodedWidgetDef),
isDeprecatedArray,
]
return [newKey, renderDefaultWidget(ctx)(encodedWidgetDef), isDeprecatedArray]
} else {

@@ -294,7 +224,3 @@ return undefined

} else {
throw new Error(
`[UNEXPECTED ERROR] ${JSON.stringify(
maybeContent,
)} should be an Array`,
)
throw new Error(`[UNEXPECTED ERROR] ${JSON.stringify(maybeContent)} should be an Array`)
}

@@ -326,4 +252,2 @@ }

pageType: doc.type,
masterLang,
brokenRoute,
doc,

@@ -334,8 +258,4 @@ }) ?? null,

tags: doc.tags,
first_publication_date: doc.first_publication_date
? formatDateTime(doc.first_publication_date)
: null,
last_publication_date: doc.last_publication_date
? formatDateTime(doc.last_publication_date)
: null,
first_publication_date: doc.first_publication_date ? formatDateTime(doc.first_publication_date) : null,
last_publication_date: doc.last_publication_date ? formatDateTime(doc.last_publication_date) : null,
slugs: doc.data.slugs,

@@ -353,6 +273,3 @@ linked_documents: [],

return (mask: WidgetDefO, content: WidgetContent): unknown => {
if (
content.__TYPE__ === SlicesContentType &&
mask.__TYPE__ === SlicesDefType
) {
if (content.__TYPE__ === SlicesContentType && mask.__TYPE__ === SlicesDefType) {
return SlicesRenderer(ctx).renderMocks(mask, content)

@@ -377,5 +294,3 @@ } else if (StaticWidgetContent.is(content) && isStaticFieldDef(mask)) {

.map<[string, unknown, boolean]>((widgetDef: WidgetDef) => {
const filteredWidget = Object.entries(widgetDef).find(
([k]) => k !== "config",
) // name[0] is the SimpleFieldDef name i.e. the widget name and apiId the api id of the field
const filteredWidget = Object.entries(widgetDef).find(([k]) => k !== "config") // name[0] is the SimpleFieldDef name i.e. the widget name and apiId the api id of the field
const name: { apiId: string } | undefined = filteredWidget && {

@@ -390,23 +305,9 @@ apiId: filteredWidget[1] as string,

const deprecatedArray = name.apiId.match(DEPRECATED_ARRAY_REGEX)
const isDeprecatedArray = Boolean(
deprecatedArray && deprecatedArray[1],
)
const newKey = (
isDeprecatedArray
? (deprecatedArray as RegExpExecArray)[1]
: name.apiId
) as string
const isDeprecatedArray = Boolean(deprecatedArray && deprecatedArray[1])
const newKey = (isDeprecatedArray ? (deprecatedArray as RegExpExecArray)[1] : name.apiId) as string
if (correspondingContent) {
return [
newKey,
renderWidgetMocks(ctx)(encodedWidgetDef, correspondingContent[1]),
isDeprecatedArray,
]
return [newKey, renderWidgetMocks(ctx)(encodedWidgetDef, correspondingContent[1]), isDeprecatedArray]
} else {
return [
newKey,
renderDefaultWidget(ctx)(encodedWidgetDef),
isDeprecatedArray,
]
return [newKey, renderDefaultWidget(ctx)(encodedWidgetDef), isDeprecatedArray]
}

@@ -428,7 +329,3 @@ }

} else {
throw new Error(
`[UNEXPECTED ERROR] ${JSON.stringify(
maybeContent,
)} should be an Array`,
)
throw new Error(`[UNEXPECTED ERROR] ${JSON.stringify(maybeContent)} should be an Array`)
}

@@ -470,3 +367,3 @@ }

if (widgetDef.__TYPE__ === SlicesDefType) {
return SlicesRenderer(ctx).renderDefault(widgetDef)
SlicesRenderer(ctx).renderDefault(widgetDef)
} else if (

@@ -473,0 +370,0 @@ widgetDef.__TYPE__ === SimpleSliceDefType ||

import { DocumentData } from "@prismicio/types-internal/lib/documents"
import type {
WidgetContent,
WidgetKey,
} from "@prismicio/types-internal/lib/documents/widgets"
import type { WidgetContent, WidgetKey } from "@prismicio/types-internal/lib/documents/widgets"
import type * as O from "fp-ts/lib/Option"
export class DocumentContent {

@@ -19,4 +17,3 @@ fieldTypes: Map<WidgetKey, string>

constructor(data: { [p: string]: unknown }) {
const { widgets, types, positions, slugs, uid } =
DocumentData.partitionData(data)
const { widgets, types, positions, slugs, uid } = DocumentData.partitionData(data)
this.fieldTypes = types

@@ -30,17 +27,9 @@ this.fieldPositions = positions

getWidget(key: string): O.Option<WidgetContent> {
return DocumentData.getWidget(
key,
this.widgets,
this.fieldTypes,
this.fieldPositions,
this.parsed,
)
const widget = DocumentData.getWidget(key, this.widgets, this.fieldTypes, this.fieldPositions, this.parsed)
this.parsed.set(key, widget)
return widget
}
parseAll(): DocumentData {
const parsed = DocumentData.fromJson(
this.widgets,
this.fieldTypes,
this.fieldPositions,
)
const parsed = DocumentData.fromJson(this.widgets, this.fieldTypes, this.fieldPositions)
this.parsed = parsed

@@ -47,0 +36,0 @@ return parsed

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

import {
DateFromStringOrNumber,
Function,
} from "@prismicio/types-internal/lib/validators"
import { DateFromStringOrNumber, Function } from "@prismicio/types-internal/lib/validators"
import { either } from "fp-ts"

@@ -30,6 +27,3 @@ import { pipe } from "fp-ts/function"

last_publication_date: Function.nullable(DateFromStringOrNumber),
metadata: withFallback(
Function.nullable(DocumentMetadata.codec),
DocumentMetadata.empty,
),
metadata: withFallback(Function.nullable(DocumentMetadata.codec), DocumentMetadata.empty),
}),

@@ -36,0 +30,0 @@ ]),

@@ -9,18 +9,4 @@ import type { ColorDef, ColorDefO } from "./Color"

export type FieldDef =
| TextDef
| DateDef
| TimestampDef
| ColorDef
| NumberDef
| RangeDef
| SelectDef
export type FieldDef = TextDef | DateDef | TimestampDef | ColorDef | NumberDef | RangeDef | SelectDef
export type FieldDefO =
| TextDefO
| DateDefO
| TimestampDefO
| ColorDefO
| NumberDefO
| RangeDefO
| SelectDefO
export type FieldDefO = TextDefO | DateDefO | TimestampDefO | ColorDefO | NumberDefO | RangeDefO | SelectDefO

@@ -20,5 +20,3 @@ import type { Group } from "@prismicio/types-internal/lib/customtypes/widgets"

export function fromGroup(key: string, model: Group): GroupDef {
const fields = Object.entries(model.config?.fields || {}).map(([key, f]) =>
fromSimpleField(key, f),
)
const fields = Object.entries(model.config?.fields || {}).map(([key, f]) => fromSimpleField(key, f))
return {

@@ -25,0 +23,0 @@ name: key,

@@ -15,6 +15,3 @@ import type { CustomType } from "@prismicio/types-internal/lib/customtypes"

export function fromCustomType(
model: CustomType,
sharedSlices: Partial<Record<string, SharedSlice>>,
): ApiModel {
export function fromCustomType(model: CustomType, sharedSlices: Partial<Record<string, SharedSlice>>): ApiModel {
const flattenWidgets = Object.values(model.json)

@@ -24,5 +21,3 @@ .map((tab) => Object.entries(tab))

const definitions = flattenWidgets.map(([key, widget]) =>
fromWidget(key, widget, sharedSlices),
)
const definitions = flattenWidgets.map(([key, widget]) => fromWidget(key, widget, sharedSlices))
return {

@@ -29,0 +24,0 @@ id: model.id,

@@ -9,4 +9,3 @@ import * as t from "io-ts"

}),
(o) =>
({ name: o.integrationFields, __TYPE__: IntegrationFieldDefType } as const),
(o) => ({ name: o.integrationFields, __TYPE__: IntegrationFieldDefType } as const),
)

@@ -13,0 +12,0 @@ export type IntegrationFieldDef = t.TypeOf<typeof IntegrationFieldDef>

import type Link from "@prismicio/types-internal/lib/customtypes/widgets/nestable/Link"
import {
addType,
nullable,
} from "@prismicio/types-internal/lib/validators/function"
import { addType, nullable } from "@prismicio/types-internal/lib/validators/function"
import * as t from "io-ts"

@@ -18,5 +15,4 @@

export function fromAnyLink(link: Link): AnyLinkDef {
if (link.config?.select)
throw new Error("Invalid link type provided, should not be of type any")
if (link.config?.select) throw new Error("Invalid link type provided, should not be of type any")
return AnyLinkDef.encode({ select: "any" })
}

@@ -9,3 +9,3 @@ import type Link from "@prismicio/types-internal/lib/customtypes/widgets/nestable/Link"

select: t.literal("document"),
customtypes: t.array(t.string),
customtypes: t.readonlyArray(t.string),
}),

@@ -18,5 +18,3 @@ DocumentLinkDefType,

if (!("document" === link.config?.select))
throw new Error(
'Invalid link type provided, should contain { select: "document" }',
)
throw new Error('Invalid link type provided, should contain { select: "document" }')
return DocumentLinkDef.encode({

@@ -23,0 +21,0 @@ select: "document",

@@ -7,27 +7,7 @@ import type { Link } from "@prismicio/types-internal/lib/customtypes/widgets/nestable"

import { AnyLinkDef, AnyLinkDefType, fromAnyLink } from "./AnyLink"
import {
defaultDocumentLinkDef,
DocumentLinkDef,
DocumentLinkDefType,
fromDocumentLink,
} from "./DocumentLink"
import {
defaultMediaLinkDef,
fromMediaLink,
MediaLinkDef,
MediaLinkDefType,
} from "./MediaLink"
import {
defaultWebLinkDef,
fromWebLink,
WebLinkDef,
WebLinkDefType,
} from "./WebLink"
import { defaultDocumentLinkDef, DocumentLinkDef, DocumentLinkDefType, fromDocumentLink } from "./DocumentLink"
import { defaultMediaLinkDef, fromMediaLink, MediaLinkDef, MediaLinkDefType } from "./MediaLink"
import { defaultWebLinkDef, fromWebLink, WebLinkDef, WebLinkDefType } from "./WebLink"
const LinkDefConfig = t.union([
MediaLinkDef,
DocumentLinkDef,
WebLinkDef,
AnyLinkDef,
])
const LinkDefConfig = t.union([MediaLinkDef, DocumentLinkDef, WebLinkDef, AnyLinkDef])

@@ -80,4 +60,2 @@ type LinkDefConfig = t.OutputOf<typeof LinkDefConfig>

return defaultWebLinkDef()
default:
throw new Error(`[UNREACHABLE] ${type} is unknown`)
}

@@ -93,17 +71,13 @@ })()

export const isMediaLinkDef: (linkDef: LinkDefO) => boolean = (
linkDef: LinkDefO,
) => linkDef.config.__TYPE__ === MediaLinkDefType
export const isMediaLinkDef: (linkDef: LinkDefO) => boolean = (linkDef: LinkDefO) =>
linkDef.config.__TYPE__ === MediaLinkDefType
export const isAnyLinkDef: (linkDef: LinkDefO) => boolean = (
linkDef: LinkDefO,
) => linkDef.config.__TYPE__ === AnyLinkDefType
export const isAnyLinkDef: (linkDef: LinkDefO) => boolean = (linkDef: LinkDefO) =>
linkDef.config.__TYPE__ === AnyLinkDefType
export const isDocumentLinkDef: (linkDef: LinkDefO) => boolean = (
linkDef: LinkDefO,
) => linkDef.config.__TYPE__ === DocumentLinkDefType
export const isDocumentLinkDef: (linkDef: LinkDefO) => boolean = (linkDef: LinkDefO) =>
linkDef.config.__TYPE__ === DocumentLinkDefType
export const isWebLinkDef: (linkDef: LinkDefO) => boolean = (
linkDef: LinkDefO,
) => linkDef.config.__TYPE__ === WebLinkDefType
export const isWebLinkDef: (linkDef: LinkDefO) => boolean = (linkDef: LinkDefO) =>
linkDef.config.__TYPE__ === WebLinkDefType

@@ -110,0 +84,0 @@ export * from "./AnyLink"

@@ -16,5 +16,3 @@ import type Link from "@prismicio/types-internal/lib/customtypes/widgets/nestable/Link"

if (!("media" === link.config?.select))
throw new Error(
'Invalid link type provided, should contain { select: "media" }',
)
throw new Error('Invalid link type provided, should contain { select: "media" }')
return MediaLinkDef.encode({ select: "media" })

@@ -21,0 +19,0 @@ }

@@ -15,6 +15,3 @@ import type Link from "@prismicio/types-internal/lib/customtypes/widgets/nestable/Link"

export function fromWebLink(link: Link): WebLinkDef {
if (!("web" === link.config?.select))
throw new Error(
'Invalid link type provided, should contain { select: "web" }',
)
if (!("web" === link.config?.select)) throw new Error('Invalid link type provided, should contain { select: "web" }')
return WebLinkDef.encode({ select: "web" })

@@ -21,0 +18,0 @@ }

@@ -10,7 +10,6 @@ import type { Select } from "@prismicio/types-internal/lib/customtypes/widgets/nestable"

config: t.strict({
options: t.array(t.string),
options: t.readonlyArray(t.string),
}),
}),
(o) =>
({ name: o.select, config: o.config, __TYPE__: SelectDefType } as const),
(o) => ({ name: o.select, config: o.config, __TYPE__: SelectDefType } as const),
)

@@ -17,0 +16,0 @@ export type SelectDef = t.TypeOf<typeof SelectDef>

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

import {
type UID,
WidgetTypes,
} from "@prismicio/types-internal/lib/customtypes/widgets"
import { type UID, WidgetTypes } from "@prismicio/types-internal/lib/customtypes/widgets"
import type { NestableWidget } from "@prismicio/types-internal/lib/customtypes/widgets/nestable"

@@ -46,6 +43,3 @@ import * as t from "io-ts"

export function fromSimpleField(
key: string,
model: NestableWidget | UID,
): SimpleFieldDef {
export function fromSimpleField(key: string, model: NestableWidget | UID): SimpleFieldDef {
switch (model.type) {

@@ -52,0 +46,0 @@ case WidgetTypes.UID:

@@ -21,11 +21,6 @@ import { WidgetTypes } from "@prismicio/types-internal/lib/customtypes/widgets"

export function fromCompositeSlice(
key: string,
model: CompositeSlice,
): CompositeSliceDef {
export function fromCompositeSlice(key: string, model: CompositeSlice): CompositeSliceDef {
return {
name: key,
primary: Object.entries(model["non-repeat"] || {}).map(([k, w]) =>
fromSimpleField(k, w),
),
primary: Object.entries(model["non-repeat"] || {}).map(([k, w]) => fromSimpleField(k, w)),
items: fromGroup(key, {

@@ -32,0 +27,0 @@ type: WidgetTypes.Group,

@@ -30,6 +30,3 @@ import type { SharedSlice } from "@prismicio/types-internal/lib/customtypes/widgets/slices"

export function fromSharedSlice(
key: string,
model: SharedSlice,
): SharedSliceDef {
export function fromSharedSlice(key: string, model: SharedSlice): SharedSliceDef {
return {

@@ -39,8 +36,4 @@ name: key,

id: v.id,
primary: Object.entries(v.primary || {}).map(([k, w]) =>
fromSimpleField(k, w),
),
items: Object.entries(v.items || {}).map(([k, w]) =>
fromSimpleField(k, w),
),
primary: Object.entries(v.primary || {}).map(([k, w]) => fromSimpleField(k, w)),
items: Object.entries(v.items || {}).map(([k, w]) => fromSimpleField(k, w)),
version: v.version,

@@ -47,0 +40,0 @@ })),

@@ -18,6 +18,3 @@ import type { LegacySlice } from "@prismicio/types-internal/lib/customtypes/widgets/slices"

export function fromSimpleSlice(
key: string,
model: LegacySlice,
): SimpleSliceDef {
export function fromSimpleSlice(key: string, model: LegacySlice): SimpleSliceDef {
return {

@@ -24,0 +21,0 @@ name: key,

@@ -14,14 +14,7 @@ import {

export const SliceDef = t.union([
SimpleSliceDef,
SharedSliceDef,
CompositeSliceDef,
])
export const SliceDef = t.union([SimpleSliceDef, SharedSliceDef, CompositeSliceDef])
export type SliceDef = t.TypeOf<typeof SliceDef>
export type SliceDefO = t.OutputOf<typeof SliceDef>
export function fromSlice(
key: string,
model: SharedSlice | CompositeSlice | LegacySlice,
): SliceDef {
export function fromSlice(key: string, model: SharedSlice | CompositeSlice | LegacySlice): SliceDef {
switch (model.type) {

@@ -28,0 +21,0 @@ case SlicesTypes.SharedSlice:

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

import {
SharedSlice,
SlicesTypes,
} from "@prismicio/types-internal/lib/customtypes/widgets/slices"
import { SharedSlice, SlicesTypes } from "@prismicio/types-internal/lib/customtypes/widgets/slices"
import type { DynamicSlices } from "@prismicio/types-internal/lib/customtypes/widgets/slices/Slices"

@@ -6,0 +3,0 @@ import { addType } from "@prismicio/types-internal/lib/validators/function"

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

import {
type Group,
type UID,
WidgetTypes,
} from "@prismicio/types-internal/lib/customtypes/widgets"
import { type Group, type UID, WidgetTypes } from "@prismicio/types-internal/lib/customtypes/widgets"
import type { NestableWidget } from "@prismicio/types-internal/lib/customtypes/widgets/nestable"

@@ -10,7 +6,3 @@ import * as t from "io-ts"

import { fromGroup, GroupDef, GroupDefType } from "./Group"
import {
type SimpleFieldDefO,
fromSimpleField,
SimpleFieldDef,
} from "./SimpleField"
import { type SimpleFieldDefO, fromSimpleField, SimpleFieldDef } from "./SimpleField"

@@ -21,12 +13,7 @@ export const StaticDef = t.union([GroupDef, SimpleFieldDef])

export function isSimpleFieldDef(
staticDef: StaticDefO,
): staticDef is SimpleFieldDefO {
export function isSimpleFieldDef(staticDef: StaticDefO): staticDef is SimpleFieldDefO {
return staticDef.__TYPE__ !== GroupDefType
}
export function fromStatic(
key: string,
model: NestableWidget | UID | Group,
): StaticDef {
export function fromStatic(key: string, model: NestableWidget | UID | Group): StaticDef {
switch (model.type) {

@@ -33,0 +20,0 @@ case WidgetTypes.Group:

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

import {
type Group,
type UID,
WidgetTypes,
} from "@prismicio/types-internal/lib/customtypes/widgets"
import { type Group, type UID, WidgetTypes } from "@prismicio/types-internal/lib/customtypes/widgets"
import type { NestableWidget } from "@prismicio/types-internal/lib/customtypes/widgets/nestable"

@@ -7,0 +3,0 @@ import type { SharedSlice } from "@prismicio/types-internal/lib/customtypes/widgets/slices"

const DOC_SEPARATOR = "%%"
export function encodeDocId(
documentId: string,
maybeAdditionalData: string | undefined,
): string {
export function encodeDocId(documentId: string, maybeAdditionalData: string | undefined): string {
return `${documentId}${DOC_SEPARATOR}${maybeAdditionalData ?? ""}`
}
export function decodeDocId(
id: string,
handlerType: string,
): [string, string?] {
export function decodeDocId(id: string, handlerType: string): [string, string?] {
const [docId, maybeAdditionalData] = id.split(DOC_SEPARATOR)

@@ -19,5 +13,3 @@

} else {
throw new Error(
`Unable to read from for extension ${handlerType} with encoded api key ${id}`,
)
throw new Error(`Unable to read from for extension ${handlerType} with encoded api key ${id}`)
}

@@ -40,5 +32,3 @@ }

} else {
throw new Error(
`ID is too long. Its size is ${idLength} and should be inferior to 1000`,
)
throw new Error(`ID is too long. Its size is ${idLength} and should be inferior to 1000`)
}

@@ -45,0 +35,0 @@ },

@@ -28,11 +28,6 @@ import * as t from "io-ts"

export type GroupOrField = Simple | Group
export const GroupOrFieldC: t.Type<GroupOrField> = t.recursion(
"GroupOrField",
() => t.union([Simple, Group]),
)
export const GroupOrFieldC: t.Type<GroupOrField> = t.recursion("GroupOrField", () => t.union([Simple, Group]))
export type Field = GroupOrField | SliceZone
export const FieldC: t.Type<Field> = t.recursion("Field", () =>
t.union([GroupOrFieldC, SliceZone]),
)
export const FieldC: t.Type<Field> = t.recursion("Field", () => t.union([GroupOrFieldC, SliceZone]))

@@ -120,13 +115,10 @@ export const SliceZoneType = "SliceZone"

export const DocRelationC: t.Type<DocRelation> = t.recursion(
"DocRelation",
() => {
return t.strict({
TYPE: t.literal(DocRelationType),
name: t.string,
uuid: t.string,
fields: t.record(t.string, t.record(t.string, FieldC)),
})
},
)
export const DocRelationC: t.Type<DocRelation> = t.recursion("DocRelation", () => {
return t.strict({
TYPE: t.literal(DocRelationType),
name: t.string,
uuid: t.string,
fields: t.record(t.string, t.record(t.string, FieldC)),
})
})

@@ -155,6 +147,3 @@ export type Simple = DocRelation | SimpleField

t.strict({
docs: t.record(
t.string,
t.union([DocRelationC, SimpleField, Group, SliceZone]),
),
docs: t.record(t.string, t.union([DocRelationC, SimpleField, Group, SliceZone])),
docRelationsMap: t.record(t.string, DocRelationC),

@@ -167,10 +156,6 @@ }),

export function extractGroupOrFieldIfAny(
fetchOpt: Field | undefined,
): GroupOrField | undefined {
export function extractGroupOrFieldIfAny(fetchOpt: Field | undefined): GroupOrField | undefined {
if (
fetchOpt !== undefined &&
(fetchOpt.TYPE === SimpleFieldType ||
fetchOpt.TYPE === DocRelationType ||
fetchOpt.TYPE === GroupType)
(fetchOpt.TYPE === SimpleFieldType || fetchOpt.TYPE === DocRelationType || fetchOpt.TYPE === GroupType)
) {

@@ -183,5 +168,3 @@ return fetchOpt

export function extractSliceFetchIfAny(
fetchOpt: Field | undefined,
): SliceZone | undefined {
export function extractSliceFetchIfAny(fetchOpt: Field | undefined): SliceZone | undefined {
if (fetchOpt !== undefined && fetchOpt.TYPE === SliceZoneType) {

@@ -188,0 +171,0 @@ return fetchOpt

@@ -47,15 +47,17 @@ import * as t from "io-ts"

const URLResolver = t.record(t.string, t.array(Relation))
const URLResolver = t.type({
resolvers: t.record(t.string, t.array(Relation)),
})
export type URLResolver = t.TypeOf<typeof URLResolver>
export const Rule = t.type({
pattern: URLPattern,
resolvers: URLResolver
const Page = t.type({
pageType: t.string,
urlPattern: URLPattern,
urlResolver: URLResolver,
})
export type Page = t.TypeOf<typeof Page>
export type Rule = t.TypeOf<typeof Rule>
export const LinkResolver = t.record(t.string, t.record(t.string, t.record(t.string, Rule)))
export const LinkResolver = t.type({
pages: t.record(t.string, Page),
})
export type LinkResolver = t.TypeOf<typeof LinkResolver>

@@ -62,0 +64,0 @@

@@ -9,6 +9,3 @@ import type { ApiDocument } from "./ApiDocument"

DocEncoder: {
encodeDocId(
documentId: string,
maybeAdditionalData: string | undefined,
): string
encodeDocId(documentId: string, maybeAdditionalData: string | undefined): string
}

@@ -25,4 +22,2 @@ encoders: {

pageType: string
masterLang: string,
brokenRoute?: string,
doc?: ApiDocument

@@ -29,0 +24,0 @@ }): string | undefined | null

@@ -10,17 +10,6 @@ import type { WidgetContent } from "@prismicio/types-internal/lib/documents/widgets"

import type {
AnyLinkDef,
DocumentLinkDef,
MediaLinkDef,
SliceDefO,
WebLinkDef,
WidgetDefO,
} from "./ApiModel"
import type { AnyLinkDef, DocumentLinkDef, MediaLinkDef, SliceDefO, WebLinkDef, WidgetDefO } from "./ApiModel"
import type { Field, GroupOrField, Slice } from "./fetch"
export interface Renderer<
D extends WidgetDefO,
C extends WidgetContent,
F extends Field | undefined = undefined,
> {
export interface Renderer<D extends WidgetDefO, C extends WidgetContent, F extends Field | undefined = undefined> {
renderV1(content: C, fetch?: F | undefined): unknown

@@ -38,15 +27,7 @@ renderV2(definition: D, content: C, fetch?: F | undefined): unknown

renderV1(content: C, fetch?: F | undefined): unknown
renderV2(
definition: D | AnyLinkDef,
content: C,
fetch?: F | undefined,
): unknown
renderV2(definition: D | AnyLinkDef, content: C, fetch?: F | undefined): unknown
renderMocks(definition: D | AnyLinkDef, content: C): unknown
}
export interface SliceRenderer<
D extends SliceDefO,
C extends SliceWidgetContent,
F extends Slice | GroupOrField,
> {
export interface SliceRenderer<D extends SliceDefO, C extends SliceWidgetContent, F extends Slice | GroupOrField> {
renderV1(content: C, fetch?: F | undefined): unknown

@@ -53,0 +34,0 @@ renderV2(definition: D, content: C, fetch?: F | undefined): unknown

@@ -20,6 +20,3 @@ import * as O from "fp-ts/lib/Option"

export function writeEmptyStringOrNull(
s: string | null | undefined,
emptyStringInsteadOfNull: boolean,
): string | null {
export function writeEmptyStringOrNull(s: string | null | undefined, emptyStringInsteadOfNull: boolean): string | null {
if (s === null || s === undefined) {

@@ -26,0 +23,0 @@ return emptyStringInsteadOfNull ? "" : null

import type { GroupContent } from "@prismicio/types-internal/lib/documents/widgets"
import type { GroupDefO } from "../models/ApiModel"
import type { GroupDefO, Renderer } from "../models"
import type { Group as GroupFetch } from "../models/fetch"
import type RenderContext from "../models/RenderContext"
import type { Renderer } from "../models/Renderer"
import SimpleWidgetRenderer from "./SimpleWidgetRenderer"
const GroupRenderer: (
ctx: RenderContext,
) => Renderer<GroupDefO, GroupContent, GroupFetch> = (ctx) => ({
const GroupRenderer: (ctx: RenderContext) => Renderer<GroupDefO, GroupContent, GroupFetch> = (ctx) => ({
renderV1(content: GroupContent, fetch?: GroupFetch | undefined): unknown {

@@ -16,6 +13,3 @@ return {

value: content.value.map((items) => {
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV1(
items.value,
fetch?.fields,
)
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV1(items.value, fetch?.fields)
}),

@@ -25,7 +19,3 @@ }

renderV2(
groupDef: GroupDefO,
content: GroupContent,
fetch?: GroupFetch | undefined,
): unknown {
renderV2(groupDef: GroupDefO, content: GroupContent, fetch?: GroupFetch | undefined): unknown {
return content.value.map((items) =>

@@ -54,6 +44,3 @@ SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV2(

return content.value.map((items) =>
SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetMocks(
items.value,
def.fields,
),
SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetMocks(items.value, def.fields),
)

@@ -60,0 +47,0 @@ },

import type { BooleanContent } from "@prismicio/types-internal/lib/documents/widgets/nestable"
import type { BooleanFieldDefO } from "../../models/ApiModel"
import type { Renderer } from "../../models/Renderer"
import type { BooleanFieldDefO, Renderer } from "../../models"

@@ -6,0 +5,0 @@ const BooleanRenderer: Renderer<BooleanFieldDefO, BooleanContent> = {

import type { EmbedContentO } from "@prismicio/types-internal/lib/documents/widgets/nestable"
import type { EmbedDefO } from "../../models/ApiModel"
import type { Renderer } from "../../models/Renderer"
import type { EmbedDefO, Renderer } from "../../models"

@@ -6,0 +5,0 @@ const EmbedRenderer: Renderer<EmbedDefO, EmbedContentO> = {

import type { FieldContent } from "@prismicio/types-internal/lib/documents/widgets/nestable"
import type { FieldDefO } from "../../models/ApiModel"
import type { Renderer } from "../../models/Renderer"
import type { FieldDefO, Renderer } from "../../models"
import { filterDouble, formatDate, formatDateTime } from "../../utils"

@@ -13,6 +12,3 @@

/* eslint-disable @typescript-eslint/no-non-null-assertion */
return `${year!.padStart(4, "0")}-${month!.padStart(2, "0")}-${day!.padStart(
2,
"0",
)}T00:00:00.000+0000`
return `${year!.padStart(4, "0")}-${month!.padStart(2, "0")}-${day!.padStart(2, "0")}T00:00:00.000+0000`
}

@@ -44,7 +40,3 @@

} catch (e) {
console.warn(
`Unable to render Date value with ${content.value}: ${(
e as Error
).toString()}`,
)
console.warn(`Unable to render Date value with ${content.value}: ${(e as Error).toString()}`)
return partialResult

@@ -63,7 +55,3 @@ }

} catch (e) {
console.warn(
`Unable to render Timestamp value with ${content.value}: ${(
e as Error
).toString()}`,
)
console.warn(`Unable to render Timestamp value with ${content.value}: ${(e as Error).toString()}`)
return partialResult

@@ -92,7 +80,3 @@ }

} catch (e) {
console.warn(
`Unable to render Date value with ${content.value}: ${(
e as Error
).toString()}`,
)
console.warn(`Unable to render Date value with ${content.value}: ${(e as Error).toString()}`)
return null

@@ -108,7 +92,3 @@ }

} catch (e) {
console.warn(
`Unable to render Timestamp value with ${content.value}: ${(
e as Error
).toString()}`,
)
console.warn(`Unable to render Timestamp value with ${content.value}: ${(e as Error).toString()}`)
return null

@@ -115,0 +95,0 @@ }

import type { GeoPointContentO } from "@prismicio/types-internal/lib/documents/widgets/nestable"
import type { GeoPointDefO } from "../../models/ApiModel"
import type { Renderer } from "../../models/Renderer"
import type { GeoPointDefO, Renderer } from "../../models"

@@ -6,0 +5,0 @@ const GeoPointRenderer: Renderer<GeoPointDefO, GeoPointContentO> = {

@@ -1,15 +0,7 @@

import type {
ImageContentO,
ImageContentView,
} from "@prismicio/types-internal/lib/documents/widgets/nestable"
import type { ImageContentO, ImageContentView } from "@prismicio/types-internal/lib/documents/widgets/nestable"
import type { RenderContext } from "../../models"
import type { ImageDefO } from "../../models/ApiModel"
import type { Renderer } from "../../models/Renderer"
import type { ImageDefO, RenderContext, Renderer } from "../../models"
import { writeEmptyStringOrNull } from "../../utils"
function renderImageContentView(
imageContentView: ImageContentView,
ctx: RenderContext,
) {
function renderImageContentView(imageContentView: ImageContentView, ctx: RenderContext) {
return {

@@ -20,10 +12,4 @@ dimensions: {

},
alt: writeEmptyStringOrNull(
imageContentView.alt,
ctx.emptyStringInsteadOfNull,
),
copyright: writeEmptyStringOrNull(
imageContentView.credits,
ctx.emptyStringInsteadOfNull,
),
alt: writeEmptyStringOrNull(imageContentView.alt, ctx.emptyStringInsteadOfNull),
copyright: writeEmptyStringOrNull(imageContentView.credits, ctx.emptyStringInsteadOfNull),
url: ctx.urlRewriter.rewriteImageUrl(imageContentView),

@@ -33,5 +19,3 @@ }

const ImageRenderer: (
ctx: RenderContext,
) => Renderer<ImageDefO, ImageContentO> = (ctx) => ({
const ImageRenderer: (ctx: RenderContext) => Renderer<ImageDefO, ImageContentO> = (ctx) => ({
renderV1(content: ImageContentO): unknown {

@@ -38,0 +22,0 @@ if (content.thumbnails) {

import type { IntegrationFieldsContent } from "@prismicio/types-internal/lib/documents/widgets/nestable"
import type { IntegrationFieldDefO } from "../../models/ApiModel"
import type { IntegrationFieldDefO, Renderer } from "../../models"
import type RenderContext from "../../models/RenderContext"
import type { Renderer } from "../../models/Renderer"
const IntegrationFieldRenderer: (
ctx: RenderContext,
) => Renderer<IntegrationFieldDefO, IntegrationFieldsContent> = (ctx) => ({
const IntegrationFieldRenderer: (ctx: RenderContext) => Renderer<IntegrationFieldDefO, IntegrationFieldsContent> = (
ctx,
) => ({
renderV1(content: IntegrationFieldsContent): unknown {

@@ -24,6 +23,3 @@ try {

renderV2(
_def: IntegrationFieldDefO,
content: IntegrationFieldsContent,
): unknown {
renderV2(_def: IntegrationFieldDefO, content: IntegrationFieldsContent): unknown {
try {

@@ -30,0 +26,0 @@ return ctx.Extension.encoders.integrationFields.encode(content.value)

@@ -1,10 +0,6 @@

import {
type DocumentLink,
BROKEN_CUSTOM_TYPE,
} from "@prismicio/types-internal/lib/documents/widgets/nestable/Link"
import { type DocumentLink, BROKEN_CUSTOM_TYPE } from "@prismicio/types-internal/lib/documents/widgets/nestable/Link"
import type { RenderContext } from "../../../models"
import { AnyLinkDef, DocumentLinkDef } from "../../../models/ApiModel"
import { AnyLinkDef, DocumentLinkDef, LinkRenderer } from "../../../models"
import type { DocRelation } from "../../../models/fetch"
import type { LinkRenderer } from "../../../models/Renderer"

@@ -27,5 +23,5 @@ function brokenLinkV2(id: string): unknown {

const DocumentLinkRenderer: (
ctx: RenderContext,
) => LinkRenderer<DocumentLinkDef, DocumentLink, DocRelation> = (ctx) => ({
const DocumentLinkRenderer: (ctx: RenderContext) => LinkRenderer<DocumentLinkDef, DocumentLink, DocRelation> = (
ctx,
) => ({
renderV1(link: DocumentLink, fetch: DocRelation | undefined): unknown {

@@ -44,7 +40,3 @@ //todo check fetch type

renderV2(
_def: DocumentLinkDef | AnyLinkDef,
link: DocumentLink,
fetch: DocRelation | undefined,
): unknown {
renderV2(_def: DocumentLinkDef | AnyLinkDef, link: DocumentLink, fetch: DocRelation | undefined): unknown {
//todo check fetch type

@@ -51,0 +43,0 @@ try {

import type { ExternalLink } from "@prismicio/types-internal/lib/documents/widgets/nestable/Link"
import type { AnyLinkDef, WebLinkDef } from "../../../models/ApiModel"
import type { LinkRenderer } from "../../../models/Renderer"
import type { AnyLinkDef, LinkRenderer, WebLinkDef } from "../../../models"
const ExternalLinkRenderer: LinkRenderer<WebLinkDef, ExternalLink> = {
renderV1(link: ExternalLink): unknown {
const target =
typeof link.target === "string" ? { target: link.target } : {}
const target = typeof link.target === "string" ? { target: link.target } : {}
return {

@@ -25,6 +23,3 @@ type: "Link.web",

return Object.assign(
partialRender,
typeof link.target === "string" ? { target: link.target } : {},
)
return Object.assign(partialRender, typeof link.target === "string" ? { target: link.target } : {})
},

@@ -31,0 +26,0 @@

import type { FileLink } from "@prismicio/types-internal/lib/documents/widgets/nestable/Link"
import type { RenderContext } from "../../../models"
import type { AnyLinkDef, MediaLinkDef } from "../../../models/ApiModel"
import type { LinkRenderer } from "../../../models/Renderer"
import type { AnyLinkDef, LinkRenderer, MediaLinkDef } from "../../../models"
const FileLinkRenderer: (
ctx: RenderContext,
) => LinkRenderer<MediaLinkDef, FileLink> = (ctx) => ({
const FileLinkRenderer: (ctx: RenderContext) => LinkRenderer<MediaLinkDef, FileLink> = (ctx) => ({
renderV1(link: FileLink): unknown {

@@ -11,0 +8,0 @@ return {

import type { ImageLink } from "@prismicio/types-internal/lib/documents/widgets/nestable/Link"
import type { RenderContext } from "../../../models"
import type { AnyLinkDef, MediaLinkDef } from "../../../models/ApiModel"
import type { LinkRenderer } from "../../../models/Renderer"
import type { AnyLinkDef, LinkRenderer, MediaLinkDef } from "../../../models"
const ImageLinkRenderer: (
ctx: RenderContext,
) => LinkRenderer<MediaLinkDef, ImageLink> = (ctx) => ({
const ImageLinkRenderer: (ctx: RenderContext) => LinkRenderer<MediaLinkDef, ImageLink> = (ctx) => ({
renderV1(link: ImageLink): unknown {

@@ -11,0 +8,0 @@ return {

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

import {
type LinkContent,
Link,
} from "@prismicio/types-internal/lib/documents/widgets/nestable/Link"
import { type LinkContent, Link } from "@prismicio/types-internal/lib/documents/widgets/nestable/Link"

@@ -24,5 +21,3 @@ import type { RenderContext, Renderer } from "../../../models"

const LinkRenderer: (
ctx: RenderContext,
) => Renderer<LinkDefO, LinkContent, DocRelation> = (ctx) => ({
const LinkRenderer: (ctx: RenderContext) => Renderer<LinkDefO, LinkContent, DocRelation> = (ctx) => ({
renderV1(link: LinkContent, fetch: DocRelation | undefined): unknown {

@@ -43,41 +38,12 @@ const encoded = Link.encode(link.value)

renderV2(
def: LinkDefO,
content: LinkContent,
fetch: DocRelation | undefined,
): unknown {
renderV2(def: LinkDefO, content: LinkContent, fetch: DocRelation | undefined): unknown {
const encoded = Link.encode(content.value)
if (
encoded.__TYPE__ === "ImageLink" &&
(isMediaLinkDef(def) || isAnyLinkDef(def))
) {
return ImageLinkRenderer(ctx).renderV2(
def.config as MediaLinkDef | AnyLinkDef,
encoded,
)
} else if (
(isDocumentLinkDef(def) || isAnyLinkDef(def)) &&
encoded.__TYPE__ === "DocumentLink"
) {
return DocumentLinkRenderer(ctx).renderV2(
def.config as DocumentLinkDef | AnyLinkDef,
encoded,
fetch,
)
} else if (
(isMediaLinkDef(def) || isAnyLinkDef(def)) &&
encoded.__TYPE__ === "FileLink"
) {
return FileLinkRenderer(ctx).renderV2(
def.config as MediaLinkDef | AnyLinkDef,
encoded,
)
} else if (
(isWebLinkDef(def) || isAnyLinkDef(def)) &&
encoded.__TYPE__ === "ExternalLink"
) {
return ExternalLinkRenderer.renderV2(
def.config as WebLinkDef | AnyLinkDef,
encoded,
)
if (encoded.__TYPE__ === "ImageLink" && (isMediaLinkDef(def) || isAnyLinkDef(def))) {
return ImageLinkRenderer(ctx).renderV2(def.config as MediaLinkDef | AnyLinkDef, encoded)
} else if ((isDocumentLinkDef(def) || isAnyLinkDef(def)) && encoded.__TYPE__ === "DocumentLink") {
return DocumentLinkRenderer(ctx).renderV2(def.config as DocumentLinkDef | AnyLinkDef, encoded, fetch)
} else if ((isMediaLinkDef(def) || isAnyLinkDef(def)) && encoded.__TYPE__ === "FileLink") {
return FileLinkRenderer(ctx).renderV2(def.config as MediaLinkDef | AnyLinkDef, encoded)
} else if ((isWebLinkDef(def) || isAnyLinkDef(def)) && encoded.__TYPE__ === "ExternalLink") {
return ExternalLinkRenderer.renderV2(def.config as WebLinkDef | AnyLinkDef, encoded)
} else {

@@ -111,34 +77,10 @@ return this.renderDefault(def)

const encoded = Link.encode(content.value)
if (
encoded.__TYPE__ === "ImageLink" &&
(isMediaLinkDef(def) || isAnyLinkDef(def))
) {
return ImageLinkRenderer(ctx).renderMocks(
def.config as MediaLinkDef | AnyLinkDef,
encoded,
)
} else if (
(isDocumentLinkDef(def) || isAnyLinkDef(def)) &&
encoded.__TYPE__ === "DocumentLink"
) {
return DocumentLinkRenderer(ctx).renderMocks(
def.config as DocumentLinkDef | AnyLinkDef,
encoded,
)
} else if (
(isMediaLinkDef(def) || isAnyLinkDef(def)) &&
encoded.__TYPE__ === "FileLink"
) {
return FileLinkRenderer(ctx).renderMocks(
def.config as MediaLinkDef | AnyLinkDef,
encoded,
)
} else if (
(isWebLinkDef(def) || isAnyLinkDef(def)) &&
encoded.__TYPE__ === "ExternalLink"
) {
return ExternalLinkRenderer.renderMocks(
def.config as WebLinkDef | AnyLinkDef,
encoded,
)
if (encoded.__TYPE__ === "ImageLink" && (isMediaLinkDef(def) || isAnyLinkDef(def))) {
return ImageLinkRenderer(ctx).renderMocks(def.config as MediaLinkDef | AnyLinkDef, encoded)
} else if ((isDocumentLinkDef(def) || isAnyLinkDef(def)) && encoded.__TYPE__ === "DocumentLink") {
return DocumentLinkRenderer(ctx).renderMocks(def.config as DocumentLinkDef | AnyLinkDef, encoded)
} else if ((isMediaLinkDef(def) || isAnyLinkDef(def)) && encoded.__TYPE__ === "FileLink") {
return FileLinkRenderer(ctx).renderMocks(def.config as MediaLinkDef | AnyLinkDef, encoded)
} else if ((isWebLinkDef(def) || isAnyLinkDef(def)) && encoded.__TYPE__ === "ExternalLink") {
return ExternalLinkRenderer.renderMocks(def.config as WebLinkDef | AnyLinkDef, encoded)
} else {

@@ -152,7 +94,2 @@ return this.renderDefault(def)

export {
DocumentLinkRenderer,
ExternalLinkRenderer,
FileLinkRenderer,
ImageLinkRenderer,
}
export { DocumentLinkRenderer, ExternalLinkRenderer, FileLinkRenderer, ImageLinkRenderer }
import type { SeparatorContent } from "@prismicio/types-internal/lib/documents/widgets/nestable"
import type { SeparatorDefO } from "../../models/ApiModel"
import type { Renderer } from "../../models/Renderer"
import type { Renderer, SeparatorDefO } from "../../models"

@@ -6,0 +5,0 @@ const SeparatorRenderer: Renderer<SeparatorDefO, SeparatorContent> = {

@@ -0,8 +1,3 @@

import { is, Link, LinkContent, LinksTypes } from "@prismicio/types-internal/lib/documents/widgets/nestable/Link"
import {
is,
Link,
LinkContent,
LinksTypes,
} from "@prismicio/types-internal/lib/documents/widgets/nestable/Link"
import {
type Block,

@@ -15,11 +10,7 @@ checkEmbedBlock,

import { type RenderContext, ApiVersion } from "../../../models"
import { defaultLinkDef } from "../../../models/ApiModel"
import { defaultLinkDef } from "../../../models"
import { writeEmptyStringOrNull } from "../../../utils"
import LinkRenderer from "../Link"
function renderStructuredTextLink(
link: LinkContent,
apiVersion: ApiVersion,
ctx: RenderContext,
) {
function renderStructuredTextLink(link: LinkContent, apiVersion: ApiVersion, ctx: RenderContext) {
const linkType = () => {

@@ -30,5 +21,3 @@ if (is.documentLink(link.value)) return LinksTypes.DocumentLink

if (is.externalLink(link.value)) return LinksTypes.ExternalLink
throw new Error(
`[UNREACHABLE] unknown Link type for ${JSON.stringify(link)}`,
)
throw new Error(`[UNREACHABLE] unknown Link type for ${JSON.stringify(link)}`)
}

@@ -39,7 +28,3 @@

} else if (apiVersion === ApiVersion.v2) {
return LinkRenderer(ctx).renderV2(
defaultLinkDef(linkType()),
link,
undefined,
)
return LinkRenderer(ctx).renderV2(defaultLinkDef(linkType()), link, undefined)
} else if (apiVersion === ApiVersion.mocks) {

@@ -74,10 +59,4 @@ return LinkRenderer(ctx).renderMocks(defaultLinkDef(linkType()), link)

url: ctx.urlRewriter.rewriteImageUrl(block.data),
alt: writeEmptyStringOrNull(
block.data.alt,
ctx.emptyStringInsteadOfNull,
),
copyright: writeEmptyStringOrNull(
block.data.credits,
ctx.emptyStringInsteadOfNull,
),
alt: writeEmptyStringOrNull(block.data.alt, ctx.emptyStringInsteadOfNull),
copyright: writeEmptyStringOrNull(block.data.credits, ctx.emptyStringInsteadOfNull),
dimensions: {

@@ -84,0 +63,0 @@ width: block.data.width,

@@ -16,6 +16,3 @@ import {

function renderSummaryJson(
text: StructuredTextContent,
renderer: (text: StructuredTextContent) => unknown,
): unknown {
function renderSummaryJson(text: StructuredTextContent, renderer: (text: StructuredTextContent) => unknown): unknown {
const firstBlock = pipe<

@@ -28,3 +25,3 @@ O.Option<Blocks.TextBlock>,

O.fromNullable(
text.value.find((block: Blocks.Block) => block.type === "header"),
text.value.find((block: Blocks.Block) => block.type.startsWith("heading")),
) as O.Option<Blocks.TextBlock>,

@@ -34,6 +31,3 @@ O.alt(

O.fromNullable(
text.value.find(
(block: Blocks.Block) =>
block.type !== "embed" && block.type !== "image",
),
text.value.find((block: Blocks.Block) => block.type !== "embed" && block.type !== "image"),
) as O.Option<Blocks.TextBlock>,

@@ -53,19 +47,10 @@ ),

ctx: RenderContext,
) => Renderer<StructuredTextDefO, StructuredTextContent, SimpleField> = (
ctx,
) => ({
renderV1(
content: StructuredTextContent,
fetch: SimpleField | undefined,
): unknown {
) => Renderer<StructuredTextDefO, StructuredTextContent, SimpleField> = (ctx) => ({
renderV1(content: StructuredTextContent, fetch: SimpleField | undefined): unknown {
//TODO: factorize that
const renderedBlocks = content.value.map((block) =>
BlockRenderer(ctx).renderBlock(block)(ApiVersion.v1),
)
const renderedBlocks = content.value.map((block) => BlockRenderer(ctx).renderBlock(block)(ApiVersion.v1))
if (fetch !== undefined && fetch.legacy) {
return renderSummaryJson(content, (text) =>
text.value.map((block) =>
BlockRenderer(ctx).renderBlock(block)(ApiVersion.v1),
),
text.value.map((block) => BlockRenderer(ctx).renderBlock(block)(ApiVersion.v1)),
)

@@ -80,16 +65,8 @@ }

renderV2(
def: StructuredTextDefO,
content: StructuredTextContent,
fetch: SimpleField | undefined,
): unknown {
renderV2(def: StructuredTextDefO, content: StructuredTextContent, fetch: SimpleField | undefined): unknown {
if (fetch != undefined && fetch.legacy) {
return renderSummaryJson(content, (text) =>
this.renderV2(def, text, undefined),
)
return renderSummaryJson(content, (text) => this.renderV2(def, text, undefined))
}
return content.value.map((block) =>
BlockRenderer(ctx).renderBlock(block)(ApiVersion.v2),
)
return content.value.map((block) => BlockRenderer(ctx).renderBlock(block)(ApiVersion.v2))
},

@@ -101,9 +78,4 @@

renderMocks(
_def: StructuredTextDefO,
content: StructuredTextContent,
): unknown {
return content.value.map((block) =>
BlockRenderer(ctx).renderBlock(block)(ApiVersion.mocks),
)
renderMocks(_def: StructuredTextDefO, content: StructuredTextContent): unknown {
return content.value.map((block) => BlockRenderer(ctx).renderBlock(block)(ApiVersion.mocks))
},

@@ -110,0 +82,0 @@ })

import type { SimpleWidgetContent } from "@prismicio/types-internal/lib/documents/widgets"
import { EmptyContent, UIDContent, UIDContentType, WidgetTypes } from "@prismicio/types-internal/lib/documents/widgets"
import {
EmptyContent,
UIDContent,
WidgetTypes,
} from "@prismicio/types-internal/lib/documents/widgets"
import {
BooleanContent,
EmbedContent,
FieldContent,
EmbedContentType,
GeoPointContent,

@@ -16,4 +12,11 @@ ImageContent,

SeparatorContent,
SeparatorContentType,
StructuredTextContent,
StructuredTextContentType,
} from "@prismicio/types-internal/lib/documents/widgets/nestable"
import { BooleanContentType } from "@prismicio/types-internal/lib/documents/widgets/nestable/BooleanContent"
import { GeoPointContentType } from "@prismicio/types-internal/lib/documents/widgets/nestable/GeoPointContent"
import { ImageContentType } from "@prismicio/types-internal/lib/documents/widgets/nestable/ImageContent"
import { IntegrationFieldsContentType } from "@prismicio/types-internal/lib/documents/widgets/nestable/IntegrationFieldsContent"
import { LinkContentType } from "@prismicio/types-internal/lib/documents/widgets/nestable/Link/LinkContent"
import { compact } from "fp-ts/lib/Array"

@@ -23,2 +26,3 @@ import * as O from "fp-ts/lib/Option"

import type { RenderContext } from "../models"
import type { Renderer } from "../models"
import {

@@ -36,11 +40,4 @@ BooleanFieldDefType,

UIDDefType,
} from "../models/ApiModel"
import {
DocRelation,
DocRelationType,
Field,
SimpleField,
SimpleFieldType,
} from "../models/fetch"
import type { Renderer } from "../models/Renderer"
} from "../models"
import { DocRelation, DocRelationType, Field, SimpleField, SimpleFieldType } from "../models/fetch"
import { renderIfNoFetchOrFetchDefined } from "../utils"

@@ -60,5 +57,3 @@ import {

function extractSimpleFieldIfAny(
field: Field | undefined,
): SimpleField | undefined {
function extractSimpleFieldIfAny(field: Field | undefined): SimpleField | undefined {
if (field !== undefined && field.TYPE === SimpleFieldType) {

@@ -71,5 +66,3 @@ return field

function extractFetchDocRelationIfAny(
field: Field | undefined,
): DocRelation | undefined {
function extractFetchDocRelationIfAny(field: Field | undefined): DocRelation | undefined {
if (field !== undefined && field.TYPE === DocRelationType) {

@@ -82,17 +75,9 @@ return field

const SimpleWidgetRenderer: (ctx: RenderContext) => Renderer<
SimpleFieldDefO,
SimpleWidgetContent,
Field
> & {
const SimpleWidgetRenderer: (ctx: RenderContext) => Renderer<SimpleFieldDefO, SimpleWidgetContent, Field> & {
renderObjectOfSimpleWidgetV1(
content:
| Array<[string, SimpleWidgetContent]>
| Record<string, SimpleWidgetContent>,
content: Array<[string, SimpleWidgetContent]> | Record<string, SimpleWidgetContent>,
fetch: Record<string, Field> | undefined,
): object
renderObjectOfSimpleWidgetV2(
content:
| Array<[string, SimpleWidgetContent]>
| Record<string, SimpleWidgetContent>,
content: Array<[string, SimpleWidgetContent]> | Record<string, SimpleWidgetContent>,
fetch: Record<string, Field> | undefined,

@@ -110,5 +95,3 @@ fieldsDef: SimpleFieldDefO[],

renderObjectOfSimpleWidgetMocks(
content:
| Array<[string, SimpleWidgetContent]>
| Record<string, SimpleWidgetContent>,
content: Array<[string, SimpleWidgetContent]> | Record<string, SimpleWidgetContent>,
fieldsDef: SimpleFieldDefO[],

@@ -118,27 +101,21 @@ ): Record<string, unknown>

renderV1(content: SimpleWidgetContent, fetch: Field | undefined): unknown {
if (StructuredTextContent.is(content)) {
return StructuredTextRenderer(ctx).renderV1(
content,
extractSimpleFieldIfAny(fetch),
)
} else if (ImageContent.is(content)) {
if (content.__TYPE__ === StructuredTextContentType) {
return StructuredTextRenderer(ctx).renderV1(content, extractSimpleFieldIfAny(fetch))
} else if (content.__TYPE__ === ImageContentType) {
return ImageRenderer(ctx).renderV1(content)
} else if (content.__TYPE__ === WidgetTypes.Field) {
return FieldRenderer.renderV1(content as FieldContent)
} else if (Links.LinkContent.is(content)) {
return LinkRenderer(ctx).renderV1(
content,
extractFetchDocRelationIfAny(fetch),
)
} else if (EmbedContent.is(content)) {
return FieldRenderer.renderV1(content)
} else if (content.__TYPE__ === LinkContentType) {
return LinkRenderer(ctx).renderV1(content, extractFetchDocRelationIfAny(fetch))
} else if (content.__TYPE__ === EmbedContentType) {
return EmbedRenderer.renderV1(content)
} else if (GeoPointContent.is(content)) {
} else if (content.__TYPE__ === GeoPointContentType) {
return GeoPointRenderer.renderV1(content)
} else if (UIDContent.is(content)) {
} else if (content.__TYPE__ === UIDContentType) {
return UIDRenderer.renderV1(content)
} else if (IntegrationFieldsContent.is(content)) {
} else if (content.__TYPE__ === IntegrationFieldsContentType) {
return IntegrationFieldsRenderer(ctx).renderV1(content)
} else if (SeparatorContent.is(content)) {
} else if (content.__TYPE__ === SeparatorContentType) {
return SeparatorRenderer.renderV1(content)
} else if (BooleanContent.is(content)) {
} else if (content.__TYPE__ === BooleanContentType) {
return BooleanRenderer.renderV1(content)

@@ -150,50 +127,23 @@ } else {

renderV2(
def: SimpleFieldDefO,
content: SimpleWidgetContent,
fetch: Field | undefined,
): unknown {
if (
def.__TYPE__ === StructuredTextDefType &&
StructuredTextContent.is(content)
) {
return StructuredTextRenderer(ctx).renderV2(
def,
content,
extractSimpleFieldIfAny(fetch),
)
renderV2(def: SimpleFieldDefO, content: SimpleWidgetContent, fetch: Field | undefined): unknown {
if (def.__TYPE__ === StructuredTextDefType && StructuredTextContent.is(content)) {
return StructuredTextRenderer(ctx).renderV2(def, content, extractSimpleFieldIfAny(fetch))
} else if (def.__TYPE__ === ImageDefType && ImageContent.is(content)) {
return ImageRenderer(ctx).renderV2(def, content)
} else if (def.__TYPE__ === LinkDefType && Links.LinkContent.is(content)) {
return LinkRenderer(ctx).renderV2(
def,
content,
extractFetchDocRelationIfAny(fetch),
)
return LinkRenderer(ctx).renderV2(def, content, extractFetchDocRelationIfAny(fetch))
} else if (def.__TYPE__ === EmbedDefType && EmbedContent.is(content)) {
return EmbedRenderer.renderV2(def, content)
} else if (
def.__TYPE__ === GeoPointDefType &&
GeoPointContent.is(content)
) {
} else if (def.__TYPE__ === GeoPointDefType && GeoPointContent.is(content)) {
return GeoPointRenderer.renderV2(def, content)
} else if (def.__TYPE__ === UIDDefType && UIDContent.is(content)) {
return UIDRenderer.renderV2(def, content)
} else if (
def.__TYPE__ === IntegrationFieldDefType &&
IntegrationFieldsContent.is(content)
) {
} else if (def.__TYPE__ === IntegrationFieldDefType && IntegrationFieldsContent.is(content)) {
return IntegrationFieldsRenderer(ctx).renderV2(def, content)
} else if (
def.__TYPE__ === SeparatorDefType &&
SeparatorContent.is(content)
) {
} else if (def.__TYPE__ === SeparatorDefType && SeparatorContent.is(content)) {
return SeparatorRenderer.renderV2(def, content)
} else if (
def.__TYPE__ === BooleanFieldDefType &&
BooleanContent.is(content)
) {
} else if (def.__TYPE__ === BooleanFieldDefType && BooleanContent.is(content)) {
return BooleanRenderer.renderV2(def, content)
} else if (content?.__TYPE__ === WidgetTypes.Field) {
return FieldRenderer.renderV2(def as FieldDefO, content as FieldContent)
return FieldRenderer.renderV2(def as FieldDefO, content)
} else {

@@ -229,6 +179,3 @@ return null

renderMocks(def: SimpleFieldDefO, content: SimpleWidgetContent): unknown {
if (
def.__TYPE__ === StructuredTextDefType &&
StructuredTextContent.is(content)
) {
if (def.__TYPE__ === StructuredTextDefType && StructuredTextContent.is(content)) {
return StructuredTextRenderer(ctx).renderMocks(def, content)

@@ -241,29 +188,14 @@ } else if (def.__TYPE__ === ImageDefType && ImageContent.is(content)) {

return EmbedRenderer.renderMocks(def, content)
} else if (
def.__TYPE__ === GeoPointDefType &&
GeoPointContent.is(content)
) {
} else if (def.__TYPE__ === GeoPointDefType && GeoPointContent.is(content)) {
return GeoPointRenderer.renderMocks(def, content)
} else if (def.__TYPE__ === UIDDefType && UIDContent.is(content)) {
return UIDRenderer.renderMocks(def, content)
} else if (
def.__TYPE__ === IntegrationFieldDefType &&
IntegrationFieldsContent.is(content)
) {
} else if (def.__TYPE__ === IntegrationFieldDefType && IntegrationFieldsContent.is(content)) {
return IntegrationFieldsRenderer(ctx).renderMocks(def, content)
} else if (
def.__TYPE__ === SeparatorDefType &&
SeparatorContent.is(content)
) {
} else if (def.__TYPE__ === SeparatorDefType && SeparatorContent.is(content)) {
return SeparatorRenderer.renderMocks(def, content)
} else if (
def.__TYPE__ === BooleanFieldDefType &&
BooleanContent.is(content)
) {
} else if (def.__TYPE__ === BooleanFieldDefType && BooleanContent.is(content)) {
return BooleanRenderer.renderMocks(def, content)
} else if (content?.__TYPE__ === WidgetTypes.Field) {
return FieldRenderer.renderMocks(
def as FieldDefO,
content as FieldContent,
)
return FieldRenderer.renderMocks(def as FieldDefO, content)
} else {

@@ -275,9 +207,6 @@ return null

renderObjectOfSimpleWidgetV1(
content:
| Array<[string, SimpleWidgetContent]>
| Record<string, SimpleWidgetContent>,
content: Array<[string, SimpleWidgetContent]> | Record<string, SimpleWidgetContent>,
fetch: Record<string, Field> | undefined,
): object {
const c: Array<[string, SimpleWidgetContent]> =
content instanceof Array ? content : Object.entries(content)
const c: Array<[string, SimpleWidgetContent]> = content instanceof Array ? content : Object.entries(content)

@@ -291,6 +220,4 @@ return Object.fromEntries(

return renderIfNoFetchOrFetchDefined(
fetch,
key,
(f: Field | undefined) => O.some([key, this.renderV1(widget, f)]),
return renderIfNoFetchOrFetchDefined(fetch, key, (f: Field | undefined) =>
O.some([key, this.renderV1(widget, f)]),
)

@@ -303,5 +230,3 @@ }),

renderObjectOfSimpleWidgetV2(
content:
| Array<[string, SimpleWidgetContent]>
| Record<string, SimpleWidgetContent>,
content: Array<[string, SimpleWidgetContent]> | Record<string, SimpleWidgetContent>,
fetch: Record<string, Field> | undefined,

@@ -352,5 +277,3 @@ fieldsDef: SimpleFieldDefO[],

} else {
const renderedO = renderIfNoFetchOrFetchDefined(fetch, key, (f) =>
O.some(this.renderV2(def, item, f)),
)
const renderedO = renderIfNoFetchOrFetchDefined(fetch, key, (f) => O.some(this.renderV2(def, item, f)))
if (O.isSome(renderedO)) {

@@ -366,5 +289,3 @@ result[key] = renderedO.value

renderObjectOfSimpleWidgetMocks(
content:
| Array<[string, SimpleWidgetContent]>
| Record<string, SimpleWidgetContent>,
content: Array<[string, SimpleWidgetContent]> | Record<string, SimpleWidgetContent>,
fieldsDef: SimpleFieldDefO[],

@@ -384,5 +305,3 @@ ): Record<string, unknown> {

} else {
const renderedO = renderIfNoFetchOrFetchDefined(undefined, key, () =>
O.some(this.renderMocks(def, item)),
)
const renderedO = renderIfNoFetchOrFetchDefined(undefined, key, () => O.some(this.renderMocks(def, item)))
if (O.isSome(renderedO)) {

@@ -389,0 +308,0 @@ result[key] = renderedO.value

import type { CompositeSliceContent } from "@prismicio/types-internal/lib/documents/widgets/slices"
import type { RenderContext } from "../../models"
import type { CompositeSliceDefO } from "../../models/ApiModel"
import type { CompositeSliceDefO, RenderContext } from "../../models"
import { CompositeSlice, Group, GroupType } from "../../models/fetch"

@@ -12,11 +11,4 @@ import type { SliceRenderer } from "../../models/Renderer"

ctx: RenderContext,
) => SliceRenderer<
CompositeSliceDefO,
CompositeSliceContent,
CompositeSlice
> = (ctx) => ({
renderV1(
content: CompositeSliceContent,
fetch: CompositeSlice | undefined,
): unknown {
) => SliceRenderer<CompositeSliceDefO, CompositeSliceContent, CompositeSlice> = (ctx) => ({
renderV1(content: CompositeSliceContent, fetch: CompositeSlice | undefined): unknown {
const repeatFetch = fetch?.repeat?.fields

@@ -26,6 +18,3 @@ const nonRepeatFetch = fetch?.nonRepeat?.fields

const itemsValue = content.repeat.flatMap((groupItem) => {
const rendered = SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV1(
groupItem.value,
repeatFetch,
)
const rendered = SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV1(groupItem.value, repeatFetch)
if (isEmpty(rendered)) {

@@ -36,6 +25,3 @@ return []

})
const primaryValue = SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV1(
content.nonRepeat,
nonRepeatFetch,
)
const primaryValue = SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV1(content.nonRepeat, nonRepeatFetch)
return {

@@ -47,7 +33,3 @@ "non-repeat": primaryValue,

renderV2(
def: CompositeSliceDefO,
content: CompositeSliceContent,
fetch: CompositeSlice | undefined,
): unknown {
renderV2(def: CompositeSliceDefO, content: CompositeSliceContent, fetch: CompositeSlice | undefined): unknown {
const repeatFetch: Group | undefined =

@@ -103,15 +85,7 @@ fetch === undefined

renderMocks(
def: CompositeSliceDefO,
content: CompositeSliceContent,
): unknown {
renderMocks(def: CompositeSliceDefO, content: CompositeSliceContent): unknown {
const itemsValue = content.repeat.map((items) => {
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetMocks(
items.value,
def.items.fields,
)
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetMocks(items.value, def.items.fields)
})
const primaryValue = SimpleWidgetRenderer(
ctx,
).renderObjectOfSimpleWidgetMocks(content.nonRepeat, def.primary)
const primaryValue = SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetMocks(content.nonRepeat, def.primary)

@@ -118,0 +92,0 @@ return {

import type { SharedSliceContent } from "@prismicio/types-internal/lib/documents/widgets/slices"
import type { RenderContext } from "../../models"
import type { SharedSliceDefO, VariationDef } from "../../models/ApiModel"
import type { RenderContext, SharedSliceDefO, VariationDef } from "../../models"
import type { Field, SharedSlice } from "../../models/fetch"

@@ -17,11 +16,6 @@ import type { SliceRenderer } from "../../models/Renderer"

const SharedSliceRenderer: (
ctx: RenderContext,
) => SliceRenderer<SharedSliceDefO, SharedSliceContent, SharedSlice> = (
const SharedSliceRenderer: (ctx: RenderContext) => SliceRenderer<SharedSliceDefO, SharedSliceContent, SharedSlice> = (
ctx,
) => ({
renderV1(
content: SharedSliceContent,
fetch: SharedSlice | undefined,
): unknown {
renderV1(content: SharedSliceContent, fetch: SharedSlice | undefined): unknown {
const itemsValue = content.items.map((groupItem) => {

@@ -44,10 +38,4 @@ return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV1(

renderV2(
def: SharedSliceDefO,
content: SharedSliceContent,
fetch: SharedSlice | undefined,
): unknown {
const variation = def.variations.find(
(variation: VariationDef) => variation.id === content.variation,
)
renderV2(def: SharedSliceDefO, content: SharedSliceContent, fetch: SharedSlice | undefined): unknown {
const variation = def.variations.find((variation: VariationDef) => variation.id === content.variation)
if (variation === undefined) {

@@ -99,5 +87,3 @@ return this.renderDefault(def)

renderMocks(def: SharedSliceDefO, content: SharedSliceContent): unknown {
const variation = def.variations.find(
(variation: VariationDef) => variation.id === content.variation,
)
const variation = def.variations.find((variation: VariationDef) => variation.id === content.variation)
if (variation === undefined) {

@@ -108,10 +94,5 @@ return this.renderDefault(def)

const itemsValue = content.items.map((groupItem) => {
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetMocks(
groupItem.value,
variation.items,
)
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetMocks(groupItem.value, variation.items)
})
const primaryValue = SimpleWidgetRenderer(
ctx,
).renderObjectOfSimpleWidgetMocks(content.primary, variation.primary)
const primaryValue = SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetMocks(content.primary, variation.primary)

@@ -118,0 +99,0 @@ return {

@@ -5,4 +5,3 @@ import { EmptyContentType } from "@prismicio/types-internal/lib/documents/widgets/EmptyContent"

import type { RenderContext } from "../../models"
import type { SimpleSliceDefO } from "../../models/ApiModel"
import type { RenderContext, SimpleSliceDefO } from "../../models"
import type { GroupOrField } from "../../models/fetch"

@@ -12,11 +11,6 @@ import type { SliceRenderer } from "../../models/Renderer"

const SimpleSliceRenderer: (
ctx: RenderContext,
) => SliceRenderer<SimpleSliceDefO, SimpleSliceContent, GroupOrField> = (
const SimpleSliceRenderer: (ctx: RenderContext) => SliceRenderer<SimpleSliceDefO, SimpleSliceContent, GroupOrField> = (
ctx,
) => ({
renderV1(
content: SimpleSliceContent,
fetch: GroupOrField | undefined,
): unknown {
renderV1(content: SimpleSliceContent, fetch: GroupOrField | undefined): unknown {
if (content.__TYPE__ === EmptyContentType) {

@@ -31,7 +25,3 @@ return O.none

renderV2(
def: SimpleSliceDefO,
content: SimpleSliceContent,
fetch: GroupOrField | undefined,
): unknown {
renderV2(def: SimpleSliceDefO, content: SimpleSliceContent, fetch: GroupOrField | undefined): unknown {
if (content.__TYPE__ === EmptyContentType) {

@@ -38,0 +28,0 @@ return O.none

import { EmptyContentType } from "@prismicio/types-internal/lib/documents/widgets/EmptyContent"
import type {
SlicesContent,
SlicesContentItem,
} from "@prismicio/types-internal/lib/documents/widgets/slices"
import type { SlicesContent, SlicesContentItem } from "@prismicio/types-internal/lib/documents/widgets/slices"
import { pipe } from "fp-ts/function"

@@ -11,5 +8,4 @@ import { compact } from "fp-ts/lib/Array"

import type { RenderContext } from "../../models"
import type { SliceDefO, SlicesDefO } from "../../models/ApiModel"
import type { Renderer, SliceDefO, SlicesDefO } from "../../models"
import type { GroupOrField, Slice, SliceZone } from "../../models/fetch"
import type { Renderer } from "../../models/Renderer"
import { renderIfNoFetchOrFetchDefined } from "../../utils"

@@ -30,11 +26,5 @@ import SliceWidgetRenderer from "./SliceWidgetRenderer"

item.key,
(f) =>
SliceWidgetRenderer(ctx).renderV1(
item.widget,
f,
) as O.Option<unknown>,
(f) => SliceWidgetRenderer(ctx).renderV1(item.widget, f) as O.Option<unknown>,
), //TODO: add fetch
O.map(
(renderedItem) => [item, renderedItem] as [SlicesContentItem, object],
),
O.map((renderedItem) => [item, renderedItem] as [SlicesContentItem, object]),
)

@@ -51,6 +41,3 @@ }),

): O.Option<unknown> {
if (
"__TYPE__" in slice.widget &&
slice.widget.__TYPE__ === EmptyContentType
) {
if ("__TYPE__" in slice.widget && slice.widget.__TYPE__ === EmptyContentType) {
return O.none

@@ -76,29 +63,19 @@ } else if (!(slice.name in keyToSliceDef)) {

const SlicesRenderer: (
ctx: RenderContext,
) => Renderer<SlicesDefO, SlicesContent, SliceZone> = (ctx) => ({
const SlicesRenderer: (ctx: RenderContext) => Renderer<SlicesDefO, SlicesContent, SliceZone> = (ctx) => ({
renderV1(content: SlicesContent, fetch: SliceZone | undefined): unknown {
return {
type: "SliceZone",
value: renderItemAndFilterOutEmptyOne(content, fetch, ctx).map(
([item, renderedItem]) => {
return {
...renderedItem,
slice_type: item.name,
slice_label: item.maybeLabel ?? null,
type: "Slice",
}
},
),
value: renderItemAndFilterOutEmptyOne(content, fetch, ctx).map(([item, renderedItem]) => {
return {
...renderedItem,
slice_type: item.name,
slice_label: item.maybeLabel ?? null,
type: "Slice",
}
}),
}
},
renderV2(
def: SlicesDefO,
content: SlicesContent,
fetch: SliceZone | undefined,
): unknown {
const keyToSliceDef = Object.fromEntries(
def.slices.map((slice) => [slice.name, slice]),
)
renderV2(def: SlicesDefO, content: SlicesContent, fetch: SliceZone | undefined): unknown {
const keyToSliceDef = Object.fromEntries(def.slices.map((slice) => [slice.name, slice]))
const fetchRecord = fetch?.slices

@@ -108,6 +85,4 @@

content.value.map((contentValue) => {
return renderIfNoFetchOrFetchDefined(
fetchRecord,
contentValue.name,
(f) => renderContent(contentValue, f, ctx, keyToSliceDef),
return renderIfNoFetchOrFetchDefined(fetchRecord, contentValue.name, (f) =>
renderContent(contentValue, f, ctx, keyToSliceDef),
)

@@ -114,0 +89,0 @@ }),

@@ -9,9 +9,4 @@ import {

import type { RenderContext } from "../../models"
import { CompositeSliceDefType, SharedSliceDefType, SimpleSliceDefType, SliceDefO } from "../../models"
import {
CompositeSliceDefType,
SharedSliceDefType,
SimpleSliceDefType,
SliceDefO,
} from "../../models/ApiModel"
import {
CompositeSlice,

@@ -30,5 +25,3 @@ CompositeSliceType,

const Fetch = {
extractCompositeSlice(
fetch: GroupOrField | Slice | undefined,
): CompositeSlice | undefined {
extractCompositeSlice(fetch: GroupOrField | Slice | undefined): CompositeSlice | undefined {
if (fetch !== undefined && fetch.TYPE === CompositeSliceType) {

@@ -39,5 +32,3 @@ return fetch

},
extractSharedSlice(
fetch: GroupOrField | Slice | undefined,
): SharedSlice | undefined {
extractSharedSlice(fetch: GroupOrField | Slice | undefined): SharedSlice | undefined {
if (fetch !== undefined && fetch.TYPE === SharedSliceType) {

@@ -48,10 +39,4 @@ return fetch

},
extractGroupOrField(
fetch: GroupOrField | Slice | undefined,
): GroupOrField | undefined {
if (
fetch !== undefined &&
fetch.TYPE !== CompositeSliceType &&
fetch.TYPE !== SharedSliceType
) {
extractGroupOrField(fetch: GroupOrField | Slice | undefined): GroupOrField | undefined {
if (fetch !== undefined && fetch.TYPE !== CompositeSliceType && fetch.TYPE !== SharedSliceType) {
return fetch

@@ -65,63 +50,25 @@ }

ctx: RenderContext,
) => SliceRenderer<SliceDefO, SliceWidgetContent, Slice | GroupOrField> = (
ctx,
) => ({
renderV1(
content: SliceWidgetContent,
fetch: Slice | GroupOrField | undefined,
): unknown {
) => SliceRenderer<SliceDefO, SliceWidgetContent, Slice | GroupOrField> = (ctx) => ({
renderV1(content: SliceWidgetContent, fetch: Slice | GroupOrField | undefined): unknown {
if (content.__TYPE__ === CompositeSliceContentType) {
return O.some(
CompositeSliceRenderer(ctx).renderV1(
content,
Fetch.extractCompositeSlice(fetch),
),
)
return O.some(CompositeSliceRenderer(ctx).renderV1(content, Fetch.extractCompositeSlice(fetch)))
} else if (content.__TYPE__ === SharedSliceContentType) {
return O.some(
SharedSliceRenderer(ctx).renderV1(
content,
Fetch.extractSharedSlice(fetch),
),
)
return O.some(SharedSliceRenderer(ctx).renderV1(content, Fetch.extractSharedSlice(fetch)))
} else {
return SimpleSliceRenderer(ctx).renderV1(
content,
Fetch.extractGroupOrField(fetch),
)
return SimpleSliceRenderer(ctx).renderV1(content, Fetch.extractGroupOrField(fetch))
}
},
renderV2(
def: SliceDefO,
content: SliceWidgetContent,
fetch: Slice | GroupOrField | undefined,
): unknown {
renderV2(def: SliceDefO, content: SliceWidgetContent, fetch: Slice | GroupOrField | undefined): unknown {
if (content.__TYPE__ === CompositeSliceContentType) {
if (def.__TYPE__ === CompositeSliceDefType) {
return O.some(
CompositeSliceRenderer(ctx).renderV2(
def,
content,
Fetch.extractCompositeSlice(fetch),
),
)
return O.some(CompositeSliceRenderer(ctx).renderV2(def, content, Fetch.extractCompositeSlice(fetch)))
}
} else if (content && content.__TYPE__ === SharedSliceContentType) {
if (def.__TYPE__ === SharedSliceDefType) {
return O.some(
SharedSliceRenderer(ctx).renderV2(
def,
content,
Fetch.extractSharedSlice(fetch),
),
)
return O.some(SharedSliceRenderer(ctx).renderV2(def, content, Fetch.extractSharedSlice(fetch)))
}
} else {
if (def.__TYPE__ === SimpleSliceDefType) {
return SimpleSliceRenderer(ctx).renderV2(
def,
content,
Fetch.extractGroupOrField(fetch),
)
return SimpleSliceRenderer(ctx).renderV2(def, content, Fetch.extractGroupOrField(fetch))
}

@@ -128,0 +75,0 @@ }

import type { StaticWidgetContent } from "@prismicio/types-internal/lib/documents/widgets"
import {
GroupContent,
SimpleWidgetContent,
WidgetTypes,
} from "@prismicio/types-internal/lib/documents/widgets"
import { SimpleWidgetContent, WidgetTypes } from "@prismicio/types-internal/lib/documents/widgets"
import type { RenderContext, Renderer } from "../models"
import {
type StaticDefO,
GroupDefType,
isSimpleFieldDef,
} from "../models/ApiModel"
import { type StaticDefO, GroupDefType, isSimpleFieldDef } from "../models"
import { Field, Group, GroupOrField, GroupType } from "../models/fetch"

@@ -18,5 +10,3 @@ import GroupRenderer from "./GroupRenderer"

function extractFetchGroupIfAny(
fetch: GroupOrField | undefined,
): Group | undefined {
function extractFetchGroupIfAny(fetch: GroupOrField | undefined): Group | undefined {
if (fetch !== undefined && fetch.TYPE === GroupType) {

@@ -29,5 +19,3 @@ return fetch

function extractFetchFieldIfAny(
fetch: GroupOrField | undefined,
): Field | undefined {
function extractFetchFieldIfAny(fetch: GroupOrField | undefined): Field | undefined {
if (fetch !== undefined && fetch.TYPE !== GroupType) {

@@ -40,43 +28,19 @@ return fetch

const StaticWidgetRenderer: (
ctx: RenderContext,
) => Renderer<StaticDefO, StaticWidgetContent, GroupOrField> = (ctx) => ({
renderV1(
content: StaticWidgetContent,
fetch: GroupOrField | undefined,
): unknown {
const StaticWidgetRenderer: (ctx: RenderContext) => Renderer<StaticDefO, StaticWidgetContent, GroupOrField> = (
ctx,
) => ({
renderV1(content: StaticWidgetContent, fetch: GroupOrField | undefined): unknown {
if (content.__TYPE__ === WidgetTypes.Group) {
return GroupRenderer(ctx).renderV1(
content as GroupContent,
extractFetchGroupIfAny(fetch),
)
return GroupRenderer(ctx).renderV1(content, extractFetchGroupIfAny(fetch))
} else {
return SimpleWidgetRenderer(ctx).renderV1(
content as SimpleWidgetContent,
extractFetchFieldIfAny(fetch),
)
return SimpleWidgetRenderer(ctx).renderV1(content, extractFetchFieldIfAny(fetch))
}
},
renderV2(
def: StaticDefO,
content: StaticWidgetContent,
fetch: GroupOrField | undefined,
): unknown {
renderV2(def: StaticDefO, content: StaticWidgetContent, fetch: GroupOrField | undefined): unknown {
if (SimpleWidgetContent.is(content) && isSimpleFieldDef(def)) {
// todo maybe find an other condition
return SimpleWidgetRenderer(ctx).renderV2(
def,
content,
extractFetchFieldIfAny(fetch),
)
} else if (
content.__TYPE__ === WidgetTypes.Group &&
def.__TYPE__ === GroupDefType
) {
return GroupRenderer(ctx).renderV2(
def,
content as GroupContent,
extractFetchGroupIfAny(fetch),
)
return SimpleWidgetRenderer(ctx).renderV2(def, content, extractFetchFieldIfAny(fetch))
} else if (content.__TYPE__ === WidgetTypes.Group && def.__TYPE__ === GroupDefType) {
return GroupRenderer(ctx).renderV2(def, content, extractFetchGroupIfAny(fetch))
} else {

@@ -98,7 +62,4 @@ return this.renderDefault(def)

return SimpleWidgetRenderer(ctx).renderMocks(def, content)
} else if (
content.__TYPE__ === WidgetTypes.Group &&
def.__TYPE__ === GroupDefType
) {
return GroupRenderer(ctx).renderMocks(def, content as GroupContent)
} else if (content.__TYPE__ === WidgetTypes.Group && def.__TYPE__ === GroupDefType) {
return GroupRenderer(ctx).renderMocks(def, content)
} else {

@@ -105,0 +66,0 @@ return this.renderDefault(def)

import { UIDContent } from "@prismicio/types-internal/lib/documents/widgets"
import type { UIDDefO } from "../models/ApiModel"
import type { Renderer } from "../models/Renderer"
import type { Renderer, UIDDefO } from "../models"

@@ -6,0 +5,0 @@ const UIDRenderer: Renderer<UIDDefO, UIDContent> = {

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