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
94
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.4 to 1.0.0

CHANGELOG.md

74

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

@@ -13,35 +13,3 @@ typ: string;

})[];
}, withMeta: boolean, linkResolver?: {
pages: {
[x: string]: {
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: {
[x: string]: {
customTypeID: string;
relationName: string;
targetCustomTypeID: string;
}[];
};
};
};
};
} | undefined, fetchDoc?: Fetch.Doc | undefined) => {
}, withMeta: boolean, brokenRoute?: string, linkResolver?: LinkResolver, fetchDoc?: Fetch.Doc) => {
title?: string | undefined;

@@ -66,3 +34,3 @@ description?: string | undefined;

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

@@ -76,35 +44,3 @@ typ: string;

})[];
}, withMeta: boolean, linkResolver?: {
pages: {
[x: string]: {
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: {
[x: string]: {
customTypeID: string;
relationName: string;
targetCustomTypeID: string;
}[];
};
};
};
};
} | undefined, fetchDoc?: Fetch.Doc | undefined) => {
}, withMeta: boolean, brokenRoute?: string, linkResolver?: LinkResolver, fetchDoc?: Fetch.Doc) => {
title?: string | undefined;

@@ -111,0 +47,0 @@ description?: string | undefined;

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

const widgets_2 = require("./widgets");
const SlicesRenderer_1 = (0, tslib_1.__importDefault)(require("./widgets/slices/SlicesRenderer"));
const SlicesRenderer_1 = tslib_1.__importDefault(require("./widgets/slices/SlicesRenderer"));
const DEPRECATED_ARRAY_REGEX = /(\w+)\[\d+]/;

@@ -78,3 +78,3 @@ function i18nWriter(doc) {

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

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

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

@@ -122,3 +124,3 @@ })) !== null && _b !== void 0 ? _b : null,

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

@@ -200,2 +202,4 @@ const widgets = mask.definitions

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

@@ -307,3 +311,3 @@ })) !== null && _b !== void 0 ? _b : null,

if (widgetDef.__TYPE__ === models_1.SlicesDefType) {
(0, SlicesRenderer_1.default)(ctx).renderDefault(widgetDef);
return (0, SlicesRenderer_1.default)(ctx).renderDefault(widgetDef);
}

@@ -310,0 +314,0 @@ else if (widgetDef.__TYPE__ === models_1.SimpleSliceDefType ||

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

var DocumentRenderer_1 = require("./DocumentRenderer");
Object.defineProperty(exports, "DocumentRenderer", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(DocumentRenderer_1).default; } });
exports.Models = (0, tslib_1.__importStar)(require("./models"));
exports.Utils = (0, tslib_1.__importStar)(require("./utils"));
(0, tslib_1.__exportStar)(require("./widgets"), exports);
Object.defineProperty(exports, "DocumentRenderer", { enumerable: true, get: function () { return tslib_1.__importDefault(DocumentRenderer_1).default; } });
exports.Models = tslib_1.__importStar(require("./models"));
exports.Utils = tslib_1.__importStar(require("./utils"));
tslib_1.__exportStar(require("./widgets"), exports);

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

const function_1 = require("@prismicio/types-internal/lib/validators/function");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const codec = t.exact(t.intersection([

@@ -9,0 +9,0 @@ t.type({

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

const function_1 = require("fp-ts/function");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const io_ts_types_1 = require("io-ts-types");

@@ -11,0 +11,0 @@ const mapOutput_1 = require("io-ts-types/lib/mapOutput");

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

const function_1 = require("@prismicio/types-internal/lib/validators/function");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
exports.RelatedDocument = t.exact(t.intersection([

@@ -9,0 +9,0 @@ t.type({

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.BooleanFieldDefType = "booleanFieldDef";

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.ColorDefType = "colorDef";

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.DateDefType = "dateDef";

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.EmbedDefType = "embedDef";

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.GeoPointDefType = "geopointDef";

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

const function_1 = require("@prismicio/types-internal/lib/validators/function");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const SimpleField_1 = require("./SimpleField");

@@ -9,0 +9,0 @@ exports.GroupDefType = "groupDef";

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.ImageDefType = "imageDef";

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const WidgetDef_1 = require("./WidgetDef");

@@ -23,23 +23,23 @@ exports.ApiModel = t.strict({

exports.fromCustomType = fromCustomType;
(0, tslib_1.__exportStar)(require("./BooleanField"), exports);
(0, tslib_1.__exportStar)(require("./Color"), exports);
(0, tslib_1.__exportStar)(require("./Date"), exports);
(0, tslib_1.__exportStar)(require("./Embed"), exports);
(0, tslib_1.__exportStar)(require("./Field"), exports);
(0, tslib_1.__exportStar)(require("./GeoPoint"), exports);
(0, tslib_1.__exportStar)(require("./Group"), exports);
(0, tslib_1.__exportStar)(require("./Image"), exports);
(0, tslib_1.__exportStar)(require("./IntegrationField"), exports);
(0, tslib_1.__exportStar)(require("./Link"), exports);
(0, tslib_1.__exportStar)(require("./Number"), exports);
(0, tslib_1.__exportStar)(require("./Range"), exports);
(0, tslib_1.__exportStar)(require("./Select"), exports);
(0, tslib_1.__exportStar)(require("./Separator"), exports);
(0, tslib_1.__exportStar)(require("./SimpleField"), exports);
(0, tslib_1.__exportStar)(require("./slices"), exports);
(0, tslib_1.__exportStar)(require("./StaticField"), exports);
(0, tslib_1.__exportStar)(require("./StructuredText"), exports);
(0, tslib_1.__exportStar)(require("./Text"), exports);
(0, tslib_1.__exportStar)(require("./Timestamp"), exports);
(0, tslib_1.__exportStar)(require("./UID"), exports);
(0, tslib_1.__exportStar)(require("./WidgetDef"), exports);
tslib_1.__exportStar(require("./BooleanField"), exports);
tslib_1.__exportStar(require("./Color"), exports);
tslib_1.__exportStar(require("./Date"), exports);
tslib_1.__exportStar(require("./Embed"), exports);
tslib_1.__exportStar(require("./Field"), exports);
tslib_1.__exportStar(require("./GeoPoint"), exports);
tslib_1.__exportStar(require("./Group"), exports);
tslib_1.__exportStar(require("./Image"), exports);
tslib_1.__exportStar(require("./IntegrationField"), exports);
tslib_1.__exportStar(require("./Link"), exports);
tslib_1.__exportStar(require("./Number"), exports);
tslib_1.__exportStar(require("./Range"), exports);
tslib_1.__exportStar(require("./Select"), exports);
tslib_1.__exportStar(require("./Separator"), exports);
tslib_1.__exportStar(require("./SimpleField"), exports);
tslib_1.__exportStar(require("./slices"), exports);
tslib_1.__exportStar(require("./StaticField"), exports);
tslib_1.__exportStar(require("./StructuredText"), exports);
tslib_1.__exportStar(require("./Text"), exports);
tslib_1.__exportStar(require("./Timestamp"), exports);
tslib_1.__exportStar(require("./UID"), exports);
tslib_1.__exportStar(require("./WidgetDef"), exports);

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.IntegrationFieldDefType = "integrationFieldDef";

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

const function_1 = require("@prismicio/types-internal/lib/validators/function");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
exports.AnyLinkDefType = "ConfigAnyLinkDef";

@@ -9,0 +9,0 @@ exports.AnyLinkDef = (0, function_1.addType)(t.partial({

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

const function_1 = require("@prismicio/types-internal/lib/validators/function");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
exports.DocumentLinkDefType = "ConfigDocumentLinkDef";

@@ -9,0 +9,0 @@ exports.DocumentLinkDef = (0, function_1.addType)(t.strict({

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

const Link_1 = require("@prismicio/types-internal/lib/documents/widgets/nestable/Link");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -63,5 +63,5 @@ const AnyLink_1 = require("./AnyLink");

exports.isWebLinkDef = isWebLinkDef;
(0, tslib_1.__exportStar)(require("./AnyLink"), exports);
(0, tslib_1.__exportStar)(require("./DocumentLink"), exports);
(0, tslib_1.__exportStar)(require("./MediaLink"), exports);
(0, tslib_1.__exportStar)(require("./WebLink"), exports);
tslib_1.__exportStar(require("./AnyLink"), exports);
tslib_1.__exportStar(require("./DocumentLink"), exports);
tslib_1.__exportStar(require("./MediaLink"), exports);
tslib_1.__exportStar(require("./WebLink"), exports);

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

const function_1 = require("@prismicio/types-internal/lib/validators/function");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
exports.MediaLinkDefType = "ConfigMediaLinkDef";

@@ -9,0 +9,0 @@ exports.MediaLinkDef = (0, function_1.addType)(t.strict({

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

const function_1 = require("@prismicio/types-internal/lib/validators/function");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
exports.WebLinkDefType = "ConfigWebLinkDef";

@@ -9,0 +9,0 @@ exports.WebLinkDef = (0, function_1.addType)(t.strict({

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.NumberDefType = "numberDef";

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.RangeDefType = "RangeDef";

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.SelectDefType = "selectDef";

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.SeparatorDefType = "separatorDef";

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

const widgets_1 = require("@prismicio/types-internal/lib/customtypes/widgets");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const BooleanField_1 = require("./BooleanField");

@@ -9,0 +9,0 @@ const Color_1 = require("./Color");

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

const function_1 = require("@prismicio/types-internal/lib/validators/function");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const Group_1 = require("../Group");

@@ -10,0 +10,0 @@ const SimpleField_1 = require("../SimpleField");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./CompositeSlice"), exports);
(0, tslib_1.__exportStar)(require("./SharedSlice"), exports);
(0, tslib_1.__exportStar)(require("./SimpleSlice"), exports);
(0, tslib_1.__exportStar)(require("./Slice"), exports);
(0, tslib_1.__exportStar)(require("./Slices"), exports);
tslib_1.__exportStar(require("./CompositeSlice"), exports);
tslib_1.__exportStar(require("./SharedSlice"), exports);
tslib_1.__exportStar(require("./SimpleSlice"), exports);
tslib_1.__exportStar(require("./Slice"), exports);
tslib_1.__exportStar(require("./Slices"), exports);

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

const function_1 = require("@prismicio/types-internal/lib/validators/function");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const SimpleField_1 = require("../SimpleField");

@@ -9,0 +9,0 @@ exports.VariationDefType = "variationDef";

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

const function_1 = require("@prismicio/types-internal/lib/validators/function");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const StaticField_1 = require("../StaticField");

@@ -9,0 +9,0 @@ exports.SimpleSliceDefType = "simpleSliceDef";

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

const slices_1 = require("@prismicio/types-internal/lib/customtypes/widgets/slices");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const _1 = require(".");

@@ -9,0 +9,0 @@ const CompositeSlice_1 = require("./CompositeSlice");

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

const function_1 = require("@prismicio/types-internal/lib/validators/function");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const Slice_1 = require("./Slice");

@@ -10,0 +10,0 @@ exports.SlicesDefType = "slicesDef";

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

const widgets_1 = require("@prismicio/types-internal/lib/customtypes/widgets");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const Group_1 = require("./Group");

@@ -9,0 +9,0 @@ const SimpleField_1 = require("./SimpleField");

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.StructuredTextDefType = "structuredTextDef";

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.TextDefType = "textDef";

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.TimestampDefType = "timestampDef";

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const mapOutput_1 = require("io-ts-types/lib/mapOutput");

@@ -8,0 +8,0 @@ exports.UIDDefType = "UIDDef";

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

const widgets_1 = require("@prismicio/types-internal/lib/customtypes/widgets");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
const slices_1 = require("./slices");

@@ -9,0 +9,0 @@ const StaticField_1 = require("./StaticField");

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

const tslib_1 = require("tslib");
const t = (0, tslib_1.__importStar)(require("io-ts"));
const t = tslib_1.__importStar(require("io-ts"));
exports.SimpleFieldType = "SimpleField";

@@ -8,0 +8,0 @@ exports.SimpleField = t.strict({

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

const tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./ApiDocument"), exports);
(0, tslib_1.__exportStar)(require("./ApiModel"), exports);
tslib_1.__exportStar(require("./ApiDocument"), exports);
tslib_1.__exportStar(require("./ApiModel"), exports);
var ApiVersion_1 = require("./ApiVersion");
Object.defineProperty(exports, "ApiVersion", { enumerable: true, get: function () { return ApiVersion_1.ApiVersion; } });
exports.Extensions = (0, tslib_1.__importStar)(require("./extension/Encoder"));
exports.Fetch = (0, tslib_1.__importStar)(require("./fetch"));
exports.Extensions = tslib_1.__importStar(require("./extension/Encoder"));
exports.Fetch = tslib_1.__importStar(require("./fetch"));
var LinkResolver_1 = require("./LinkResolver");
Object.defineProperty(exports, "LinkResolver", { enumerable: true, get: function () { return LinkResolver_1.LinkResolver; } });

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

export declare type URLPattern = t.TypeOf<typeof URLPattern>;
declare const URLResolver: t.TypeC<{
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">;
}>]>]>>;
}>;
resolvers: t.RecordC<t.StringC, t.ArrayC<t.TypeC<{

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

}>;
export declare type URLResolver = t.TypeOf<typeof URLResolver>;
declare const Page: t.TypeC<{
pageType: t.StringC;
urlPattern: t.TypeC<{
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<{
trailingSlash: t.BooleanC;

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

}>;
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;
}>>>;
}>;
}>>;
}>;
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>;

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

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

@@ -35,13 +35,8 @@ isOptional: t.boolean,

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

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

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

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

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

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

const tslib_1 = require("tslib");
const O = (0, tslib_1.__importStar)(require("fp-ts/lib/Option"));
const O = tslib_1.__importStar(require("fp-ts/lib/Option"));
function renderIfNoFetchOrFetchDefined(fetch, name, renderer) {

@@ -8,0 +8,0 @@ if (fetch === undefined) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const SimpleWidgetRenderer_1 = (0, tslib_1.__importDefault)(require("./SimpleWidgetRenderer"));
const SimpleWidgetRenderer_1 = tslib_1.__importDefault(require("./SimpleWidgetRenderer"));
const GroupRenderer = (ctx) => ({

@@ -6,0 +6,0 @@ renderV1(content, fetch) {

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

var GroupRenderer_1 = require("./GroupRenderer");
Object.defineProperty(exports, "GroupRenderer", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(GroupRenderer_1).default; } });
(0, tslib_1.__exportStar)(require("./nestable"), exports);
Object.defineProperty(exports, "GroupRenderer", { enumerable: true, get: function () { return tslib_1.__importDefault(GroupRenderer_1).default; } });
tslib_1.__exportStar(require("./nestable"), exports);
var SimpleWidgetRenderer_1 = require("./SimpleWidgetRenderer");
Object.defineProperty(exports, "SimpleWidgetRenderer", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(SimpleWidgetRenderer_1).default; } });
(0, tslib_1.__exportStar)(require("./slices"), exports);
Object.defineProperty(exports, "SimpleWidgetRenderer", { enumerable: true, get: function () { return tslib_1.__importDefault(SimpleWidgetRenderer_1).default; } });
tslib_1.__exportStar(require("./slices"), exports);
var StaticWidgetRenderer_1 = require("./StaticWidgetRenderer");
Object.defineProperty(exports, "StaticWidgetRenderer", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(StaticWidgetRenderer_1).default; } });
Object.defineProperty(exports, "StaticWidgetRenderer", { enumerable: true, get: function () { return tslib_1.__importDefault(StaticWidgetRenderer_1).default; } });
var UIDRenderer_1 = require("./UIDRenderer");
Object.defineProperty(exports, "UIDRenderer", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(UIDRenderer_1).default; } });
Object.defineProperty(exports, "UIDRenderer", { enumerable: true, get: function () { return tslib_1.__importDefault(UIDRenderer_1).default; } });

@@ -7,9 +7,9 @@ "use strict";

const ApiModel_1 = require("../../../models/ApiModel");
const DocumentLinkRenderer_1 = (0, tslib_1.__importDefault)(require("./DocumentLinkRenderer"));
const DocumentLinkRenderer_1 = tslib_1.__importDefault(require("./DocumentLinkRenderer"));
exports.DocumentLinkRenderer = DocumentLinkRenderer_1.default;
const ExternalLinkRenderer_1 = (0, tslib_1.__importDefault)(require("./ExternalLinkRenderer"));
const ExternalLinkRenderer_1 = tslib_1.__importDefault(require("./ExternalLinkRenderer"));
exports.ExternalLinkRenderer = ExternalLinkRenderer_1.default;
const FileLinkRenderer_1 = (0, tslib_1.__importDefault)(require("./FileLinkRenderer"));
const FileLinkRenderer_1 = tslib_1.__importDefault(require("./FileLinkRenderer"));
exports.FileLinkRenderer = FileLinkRenderer_1.default;
const ImageLinkRenderer_1 = (0, tslib_1.__importDefault)(require("./ImageLinkRenderer"));
const ImageLinkRenderer_1 = tslib_1.__importDefault(require("./ImageLinkRenderer"));
exports.ImageLinkRenderer = ImageLinkRenderer_1.default;

@@ -16,0 +16,0 @@ const LinkRenderer = (ctx) => ({

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

const Block_1 = require("@prismicio/types-internal/lib/documents/widgets/nestable/StructuredTextContent/Block");
const E = (0, tslib_1.__importStar)(require("fp-ts/lib/Either"));
const E = tslib_1.__importStar(require("fp-ts/lib/Either"));
const models_1 = require("../../../models");
const models_2 = require("../../../models");
const utils_1 = require("../../../utils");
const Link_2 = (0, tslib_1.__importDefault)(require("../Link"));
const Link_2 = tslib_1.__importDefault(require("../Link"));
function renderStructuredTextLink(link, apiVersion, ctx) {

@@ -13,0 +13,0 @@ const linkType = () => {

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

const function_1 = require("fp-ts/lib/function");
const O = (0, tslib_1.__importStar)(require("fp-ts/lib/Option"));
const O = tslib_1.__importStar(require("fp-ts/lib/Option"));
const models_1 = require("../../../models");
const BlockRenderer_1 = (0, tslib_1.__importDefault)(require("./BlockRenderer"));
const BlockRenderer_1 = tslib_1.__importDefault(require("./BlockRenderer"));
function renderSummaryJson(text, renderer) {

@@ -11,0 +11,0 @@ 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(() => []));

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

const Array_1 = require("fp-ts/lib/Array");
const O = (0, tslib_1.__importStar)(require("fp-ts/lib/Option"));
const O = tslib_1.__importStar(require("fp-ts/lib/Option"));
const models_1 = require("../models");

@@ -18,3 +18,3 @@ const fetch_1 = require("../models/fetch");

const nestable_2 = require("./nestable");
const UIDRenderer_1 = (0, tslib_1.__importDefault)(require("./UIDRenderer"));
const UIDRenderer_1 = tslib_1.__importDefault(require("./UIDRenderer"));
function extractSimpleFieldIfAny(field) {

@@ -21,0 +21,0 @@ if (field !== undefined && field.TYPE === fetch_1.SimpleFieldType) {

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

const utils_1 = require("../../utils");
const SimpleWidgetRenderer_1 = (0, tslib_1.__importDefault)(require("../SimpleWidgetRenderer"));
const SimpleWidgetRenderer_1 = tslib_1.__importDefault(require("../SimpleWidgetRenderer"));
const CompositeSliceRenderer = (ctx) => ({

@@ -9,0 +9,0 @@ renderV1(content, fetch) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const SimpleWidgetRenderer_1 = (0, tslib_1.__importDefault)(require("../SimpleWidgetRenderer"));
const SimpleWidgetRenderer_1 = tslib_1.__importDefault(require("../SimpleWidgetRenderer"));
function getFetchField(variation, part, fetch) {

@@ -6,0 +6,0 @@ var _a, _b, _c;

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

const EmptyContent_1 = require("@prismicio/types-internal/lib/documents/widgets/EmptyContent");
const O = (0, tslib_1.__importStar)(require("fp-ts/lib/Option"));
const StaticWidgetRenderer_1 = (0, tslib_1.__importDefault)(require("../StaticWidgetRenderer"));
const O = tslib_1.__importStar(require("fp-ts/lib/Option"));
const StaticWidgetRenderer_1 = tslib_1.__importDefault(require("../StaticWidgetRenderer"));
const SimpleSliceRenderer = (ctx) => ({

@@ -9,0 +9,0 @@ renderV1(content, fetch) {

@@ -7,5 +7,12 @@ "use strict";

const Array_1 = require("fp-ts/lib/Array");
const O = (0, tslib_1.__importStar)(require("fp-ts/Option"));
const O = tslib_1.__importStar(require("fp-ts/Option"));
const uuid_1 = require("uuid");
const utils_1 = require("../../utils");
const SliceWidgetRenderer_1 = (0, tslib_1.__importDefault)(require("./SliceWidgetRenderer"));
const SliceWidgetRenderer_1 = tslib_1.__importDefault(require("./SliceWidgetRenderer"));
function sliceId(sliceKey, sliceName) {
const IdRegexp = new RegExp(`^(${sliceName})\\$\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}$`);
if (sliceKey.match(IdRegexp))
return sliceKey;
return `${sliceName}$${(0, uuid_1.v4)()}`;
}
function renderItemAndFilterOutEmptyOne(slicesContent, sliceFetch, ctx) {

@@ -31,2 +38,3 @@ const fetchRecord = sliceFetch === null || sliceFetch === void 0 ? void 0 : sliceFetch.slices;

...render,
id: sliceId(slice.key, slice.name),
slice_type: slice.name,

@@ -46,2 +54,3 @@ slice_label: (_a = slice.maybeLabel) !== null && _a !== void 0 ? _a : null,

...renderedItem,
id: sliceId(item.key, item.name),
slice_type: item.name,

@@ -48,0 +57,0 @@ slice_label: (_a = item.maybeLabel) !== null && _a !== void 0 ? _a : null,

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

const slices_1 = require("@prismicio/types-internal/lib/documents/widgets/slices");
const O = (0, tslib_1.__importStar)(require("fp-ts/lib/Option"));
const O = tslib_1.__importStar(require("fp-ts/lib/Option"));
const models_1 = require("../../models");
const fetch_1 = require("../../models/fetch");
const CompositeSliceRenderer_1 = (0, tslib_1.__importDefault)(require("./CompositeSliceRenderer"));
const SharedSliceRenderer_1 = (0, tslib_1.__importDefault)(require("./SharedSliceRenderer"));
const SimpleSliceRenderer_1 = (0, tslib_1.__importDefault)(require("./SimpleSliceRenderer"));
const CompositeSliceRenderer_1 = tslib_1.__importDefault(require("./CompositeSliceRenderer"));
const SharedSliceRenderer_1 = tslib_1.__importDefault(require("./SharedSliceRenderer"));
const SimpleSliceRenderer_1 = tslib_1.__importDefault(require("./SimpleSliceRenderer"));
const Fetch = {

@@ -13,0 +13,0 @@ extractCompositeSlice(fetch) {

@@ -7,4 +7,4 @@ "use strict";

const fetch_1 = require("../models/fetch");
const GroupRenderer_1 = (0, tslib_1.__importDefault)(require("./GroupRenderer"));
const SimpleWidgetRenderer_1 = (0, tslib_1.__importDefault)(require("./SimpleWidgetRenderer"));
const GroupRenderer_1 = tslib_1.__importDefault(require("./GroupRenderer"));
const SimpleWidgetRenderer_1 = tslib_1.__importDefault(require("./SimpleWidgetRenderer"));
function extractFetchGroupIfAny(fetch) {

@@ -11,0 +11,0 @@ if (fetch !== undefined && fetch.TYPE === fetch_1.GroupType) {

{
"name": "@prismicio/api-renderer",
"version": "1.0.0-alpha.4",
"version": "1.0.0",
"description": "Prismic renderers for the content API",

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

"eslint-fix": "npm run eslint -- --fix",
"preflight": "npm run prettier && npm run build && npm run eslint",
"preflight": "npm run prettier && npm run build && npm run eslint && npm run test",
"prettier": "prettier --check .",

@@ -39,4 +39,5 @@ "prettier-write": "prettier --write ."

"dependencies": {
"@prismicio/types-internal": "1.0.0-alpha.1",
"tslib": "^2.3.1"
"@prismicio/types-internal": "^1.0.1",
"tslib": "^2.3.1",
"uuid": "^8.3.2"
},

@@ -46,2 +47,3 @@ "devDependencies": {

"@types/jest": "^27.4.0",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^5.8.1",

@@ -48,0 +50,0 @@ "@typescript-eslint/parser": "^5.8.1",

@@ -100,5 +100,7 @@ import {

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

@@ -119,2 +121,4 @@ fetchDoc?: Fetch.Doc,

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

@@ -153,2 +157,3 @@ }) ?? null,

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

@@ -158,2 +163,3 @@ searchURL: string,

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

@@ -239,2 +245,4 @@ fetchDoc?: Fetch.Doc,

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

@@ -349,3 +357,3 @@ }) ?? null,

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

@@ -352,0 +360,0 @@ widgetDef.__TYPE__ === SimpleSliceDefType ||

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

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

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

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

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

@@ -23,0 +25,0 @@ }): string | undefined | null

@@ -6,2 +6,3 @@ import { EmptyContentType } from "@prismicio/types-internal/lib/documents/widgets/EmptyContent"

import * as O from "fp-ts/Option"
import { v4 as uuid } from "uuid"

@@ -14,2 +15,9 @@ import type { RenderContext } from "../../models"

function sliceId(sliceKey: string, sliceName: string): string {
const IdRegexp = new RegExp(`^(${sliceName})\\$\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}$`)
if (sliceKey.match(IdRegexp)) return sliceKey
return `${sliceName}$${uuid()}`
}
function renderItemAndFilterOutEmptyOne(

@@ -55,2 +63,3 @@ slicesContent: SlicesContent,

...(render as object),
id: sliceId(slice.key, slice.name),
slice_type: slice.name,

@@ -70,2 +79,3 @@ slice_label: slice.maybeLabel ?? null,

...renderedItem,
id: sliceId(item.key, item.name),
slice_type: item.name,

@@ -72,0 +82,0 @@ slice_label: item.maybeLabel ?? null,

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