@prismicio/api-renderer
Advanced tools
Comparing version 0.1.7 to 1.0.0-alpha.0
@@ -5,3 +5,3 @@ import { WidgetContent } from "@prismicio/types-internal/lib/documents/widgets"; | ||
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]: ({ | ||
@@ -16,23 +16,22 @@ typ: string; | ||
}, withMeta: boolean, linkResolver?: { | ||
pages: { | ||
[x: string]: { | ||
[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: { | ||
[x: string]: { | ||
pattern: { | ||
trailingSlash: boolean; | ||
params: ({ | ||
isOptional: boolean; | ||
name: string; | ||
type: "custom"; | ||
} | { | ||
isOptional: boolean; | ||
type: "uid"; | ||
} | { | ||
isOptional: boolean; | ||
type: "lang"; | ||
} | { | ||
value: string; | ||
type: "static"; | ||
})[]; | ||
}; | ||
resolvers: { | ||
@@ -68,3 +67,3 @@ [x: string]: { | ||
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]: ({ | ||
@@ -79,23 +78,22 @@ typ: string; | ||
}, withMeta: boolean, linkResolver?: { | ||
pages: { | ||
[x: string]: { | ||
[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: { | ||
[x: string]: { | ||
pattern: { | ||
trailingSlash: boolean; | ||
params: ({ | ||
isOptional: boolean; | ||
name: string; | ||
type: "custom"; | ||
} | { | ||
isOptional: boolean; | ||
type: "uid"; | ||
} | { | ||
isOptional: boolean; | ||
type: "lang"; | ||
} | { | ||
value: string; | ||
type: "static"; | ||
})[]; | ||
}; | ||
resolvers: { | ||
@@ -102,0 +100,0 @@ [x: string]: { |
@@ -86,3 +86,3 @@ "use strict"; | ||
function renderV1(ctx) { | ||
return (doc, content, searchURL, i18n, withMeta, linkResolver, fetchDoc) => { | ||
return (doc, content, masterLang, searchURL, i18n, withMeta, linkResolver, fetchDoc) => { | ||
var _a, _b; | ||
@@ -99,2 +99,3 @@ const relatedDocs = (i18n[doc.groupLangId] || []) | ||
pageType: doc.type, | ||
masterLang, | ||
doc, | ||
@@ -135,3 +136,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, linkResolver, fetchDoc) => { | ||
var _a, _b; | ||
@@ -219,2 +220,3 @@ const widgets = mask.definitions | ||
pageType: doc.type, | ||
masterLang, | ||
doc, | ||
@@ -221,0 +223,0 @@ })) !== null && _b !== void 0 ? _b : null, |
@@ -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"); | ||
@@ -35,13 +35,8 @@ const t = (0, tslib_1.__importStar)(require("io-ts")); | ||
}); | ||
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,3 @@ import type { ApiDocument } from "./ApiDocument"; | ||
pageType: string; | ||
masterLang: string; | ||
doc?: ApiDocument; | ||
@@ -22,0 +23,0 @@ }): string | undefined | null; |
{ | ||
"name": "@prismicio/api-renderer", | ||
"version": "0.1.7", | ||
"version": "1.0.0-alpha.0", | ||
"description": "Prismic renderers for the content API", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -129,2 +129,3 @@ import { | ||
content: [string, WidgetContent][], | ||
masterLang: string, | ||
searchURL: string, | ||
@@ -148,2 +149,3 @@ i18n: { [k: string]: RelatedDocument[] }, | ||
pageType: doc.type, | ||
masterLang, | ||
doc, | ||
@@ -201,2 +203,3 @@ }) ?? null, | ||
doc: ApiDocument, | ||
masterLang: string, | ||
content: [string, WidgetContent][], | ||
@@ -306,2 +309,3 @@ searchURL: string, | ||
pageType: doc.type, | ||
masterLang, | ||
doc, | ||
@@ -308,0 +312,0 @@ }) ?? null, |
@@ -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 @@ |
@@ -24,2 +24,3 @@ import type { ApiDocument } from "./ApiDocument" | ||
pageType: string | ||
masterLang: string | ||
doc?: ApiDocument | ||
@@ -26,0 +27,0 @@ }): string | undefined | null |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
87
496074
226
14887