@prismicio/types-internal
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -6,5 +6,6 @@ "use strict"; | ||
const t = (0, tslib_1.__importStar)(require("io-ts")); | ||
const widgets_1 = require("../documents/widgets"); | ||
const Widget_1 = require("./widgets/Widget"); | ||
function sectionReader(codec) { | ||
return t.record(t.string, codec); // WidgetId -> Widget Data | ||
return t.record(widgets_1.WidgetKey, codec); // WidgetId -> Widget Data | ||
} | ||
@@ -11,0 +12,0 @@ exports.sectionReader = sectionReader; |
@@ -11,3 +11,3 @@ import * as t from "io-ts"; | ||
repeat: t.BooleanC; | ||
fields: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
fields: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
type: t.LiteralC<"Color">; | ||
@@ -14,0 +14,0 @@ }>, t.PartialC<{ |
@@ -5,2 +5,3 @@ "use strict"; | ||
const t = (0, tslib_1.__importStar)(require("io-ts")); | ||
const widgets_1 = require("../../documents/widgets"); | ||
const validators_1 = require("../../validators"); | ||
@@ -12,3 +13,3 @@ const NestableWidget_1 = (0, tslib_1.__importDefault)(require("./nestable/NestableWidget")); | ||
repeat: t.boolean, | ||
fields: t.record(t.string, NestableWidget_1.default), | ||
fields: t.record(widgets_1.WidgetKey, NestableWidget_1.default), | ||
})); | ||
@@ -15,0 +16,0 @@ const Group = t.exact(t.intersection([ |
@@ -9,3 +9,3 @@ import * as t from "io-ts"; | ||
display: t.StringC; | ||
"non-repeat": t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
"non-repeat": t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
type: t.LiteralC<"Color">; | ||
@@ -167,3 +167,3 @@ }>, t.PartialC<{ | ||
}>]>>]>>; | ||
repeat: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
repeat: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
type: t.LiteralC<"Color">; | ||
@@ -170,0 +170,0 @@ }>, t.PartialC<{ |
@@ -5,2 +5,3 @@ "use strict"; | ||
const t = (0, tslib_1.__importStar)(require("io-ts")); | ||
const widgets_1 = require("../../../documents/widgets"); | ||
const validators_1 = require("../../../validators"); | ||
@@ -21,4 +22,4 @@ const NestableWidget_1 = (0, tslib_1.__importDefault)(require("../nestable/NestableWidget")); | ||
display: t.string, | ||
"non-repeat": t.record(t.string, NestableWidget_1.default), | ||
repeat: t.record(t.string, NestableWidget_1.default), | ||
"non-repeat": t.record(widgets_1.WidgetKey, NestableWidget_1.default), | ||
repeat: t.record(widgets_1.WidgetKey, NestableWidget_1.default), | ||
config: CompositeSliceConfig, | ||
@@ -25,0 +26,0 @@ }), |
@@ -167,3 +167,3 @@ import * as t from "io-ts"; | ||
repeat: t.BooleanC; | ||
fields: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
fields: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
type: t.LiteralC<"Color">; | ||
@@ -170,0 +170,0 @@ }>, t.PartialC<{ |
@@ -11,3 +11,3 @@ import * as t from "io-ts"; | ||
display: t.StringC; | ||
primary: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
primary: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
type: t.LiteralC<"Color">; | ||
@@ -169,3 +169,3 @@ }>, t.PartialC<{ | ||
}>]>>]>>; | ||
items: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
items: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
type: t.LiteralC<"Color">; | ||
@@ -342,3 +342,3 @@ }>, t.PartialC<{ | ||
display: t.StringC; | ||
primary: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
primary: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
type: t.LiteralC<"Color">; | ||
@@ -500,3 +500,3 @@ }>, t.PartialC<{ | ||
}>]>>]>>; | ||
items: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
items: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ | ||
type: t.LiteralC<"Color">; | ||
@@ -503,0 +503,0 @@ }>, t.PartialC<{ |
@@ -7,2 +7,3 @@ "use strict"; | ||
const withFallback_1 = require("io-ts-types/lib/withFallback"); | ||
const widgets_1 = require("../../../documents/widgets"); | ||
const NestableWidget_1 = (0, tslib_1.__importDefault)(require("../nestable/NestableWidget")); | ||
@@ -22,4 +23,4 @@ const SlicesTypes_1 = require("./SlicesTypes"); | ||
display: t.string, | ||
primary: t.record(t.string, NestableWidget_1.default), | ||
items: t.record(t.string, NestableWidget_1.default), | ||
primary: t.record(widgets_1.WidgetKey, NestableWidget_1.default), | ||
items: t.record(widgets_1.WidgetKey, NestableWidget_1.default), | ||
}), | ||
@@ -26,0 +27,0 @@ ])); |
@@ -6,2 +6,3 @@ "use strict"; | ||
const t = (0, tslib_1.__importStar)(require("io-ts")); | ||
const widgets_1 = require("../../../documents/widgets"); | ||
const validators_1 = require("../../../validators"); | ||
@@ -29,3 +30,3 @@ const WidgetTypes_1 = require("../WidgetTypes"); | ||
labels: exports.SlicesLabels, | ||
choices: t.record(t.string, t.union([LegacySlice_1.default, CompositeSlice_1.default, codec])), | ||
choices: t.record(widgets_1.WidgetKey, t.union([LegacySlice_1.default, CompositeSlice_1.default, codec])), | ||
})); | ||
@@ -32,0 +33,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import * as t from "io-ts"; | ||
import { SlicesContent } from "./slices"; | ||
@@ -32,3 +33,4 @@ import StaticWidgetContent from "./StaticWidgetContent"; | ||
export declare type WidgetTypes = typeof WidgetTypes[keyof typeof WidgetTypes]; | ||
export declare type WidgetKey = string; | ||
export declare const WidgetKey: t.Type<string, string, unknown>; | ||
export declare type WidgetKey = t.TypeOf<typeof WidgetKey>; | ||
export declare type WidgetContent = SlicesContent | StaticWidgetContent; | ||
@@ -35,0 +37,0 @@ export declare const Widget: { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Widget = exports.WidgetTypes = exports.StaticWidgetContent = exports.Slices = exports.Nestable = void 0; | ||
exports.Widget = exports.WidgetKey = exports.WidgetTypes = exports.StaticWidgetContent = exports.Slices = exports.Nestable = void 0; | ||
const tslib_1 = require("tslib"); | ||
const t = (0, tslib_1.__importStar)(require("io-ts")); | ||
const function_1 = require("../../validators/function"); | ||
const EmptyContent_1 = require("./EmptyContent"); | ||
@@ -26,2 +28,4 @@ const GroupContent_1 = require("./GroupContent"); | ||
}; | ||
const widgetKeyRegex = new RegExp("^[^<>]+$"); | ||
exports.WidgetKey = (0, function_1.refineType)(t.string, "WidgetKey", (s) => widgetKeyRegex.test(s)); | ||
exports.Widget = { | ||
@@ -28,0 +32,0 @@ fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions) { |
{ | ||
"name": "@prismicio/types-internal", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Prismic types for Custom Types and Prismic Data", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
import * as t from "io-ts" | ||
import { WidgetKey } from "../documents/widgets" | ||
import type { SharedSlice } from "./widgets/slices" | ||
@@ -9,3 +10,3 @@ import { DynamicWidget, StaticWidget, Widgets } from "./widgets/Widget" | ||
) { | ||
return t.record(t.string, codec) // WidgetId -> Widget Data | ||
return t.record(WidgetKey, codec) // WidgetId -> Widget Data | ||
} | ||
@@ -12,0 +13,0 @@ |
import * as t from "io-ts" | ||
import { WidgetKey } from "../../documents/widgets" | ||
import { StringOrNull } from "../../validators" | ||
@@ -11,3 +12,3 @@ import NestableWidget from "./nestable/NestableWidget" | ||
repeat: t.boolean, | ||
fields: t.record(t.string, NestableWidget), | ||
fields: t.record(WidgetKey, NestableWidget), | ||
}), | ||
@@ -14,0 +15,0 @@ ) |
import * as t from "io-ts" | ||
import { WidgetKey } from "../../../documents/widgets" | ||
import { StringOrNull } from "../../../validators" | ||
@@ -24,4 +25,4 @@ import NestableWidget from "../nestable/NestableWidget" | ||
display: t.string, | ||
"non-repeat": t.record(t.string, NestableWidget), | ||
repeat: t.record(t.string, NestableWidget), | ||
"non-repeat": t.record(WidgetKey, NestableWidget), | ||
repeat: t.record(WidgetKey, NestableWidget), | ||
config: CompositeSliceConfig, | ||
@@ -28,0 +29,0 @@ }), |
import * as t from "io-ts" | ||
import { withFallback } from "io-ts-types/lib/withFallback" | ||
import { WidgetKey } from "../../../documents/widgets" | ||
import NestableWidget from "../nestable/NestableWidget" | ||
@@ -22,4 +23,4 @@ import { SlicesTypes } from "./SlicesTypes" | ||
display: t.string, | ||
primary: t.record(t.string, NestableWidget), | ||
items: t.record(t.string, NestableWidget), | ||
primary: t.record(WidgetKey, NestableWidget), | ||
items: t.record(WidgetKey, NestableWidget), | ||
}), | ||
@@ -26,0 +27,0 @@ ]), |
import * as t from "io-ts" | ||
import { WidgetKey } from "../../../documents/widgets" | ||
import { StringOrNull } from "../../../validators" | ||
@@ -39,3 +40,3 @@ import { WidgetTypes } from "../WidgetTypes" | ||
choices: t.record( | ||
t.string, | ||
WidgetKey, | ||
t.union([LegacySlice, CompositeSlice, codec]), | ||
@@ -42,0 +43,0 @@ ), |
@@ -0,1 +1,4 @@ | ||
import * as t from "io-ts" | ||
import { refineType } from "../../validators/function" | ||
import { EmptyContentType } from "./EmptyContent" | ||
@@ -29,4 +32,10 @@ import { GroupContentType } from "./GroupContent" | ||
export type WidgetKey = string | ||
const widgetKeyRegex = new RegExp("^[^<>]+$") | ||
export const WidgetKey = refineType(t.string, "WidgetKey", (s: string) => | ||
widgetKeyRegex.test(s), | ||
) | ||
export type WidgetKey = t.TypeOf<typeof WidgetKey> | ||
export type WidgetContent = SlicesContent | StaticWidgetContent | ||
@@ -33,0 +42,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
823134
19363
241