@prismicio/types-internal
Advanced tools
Comparing version 2.0.0-alpha.9 to 2.0.0-alpha.10
@@ -319,3 +319,3 @@ import * as t from "io-ts"; | ||
export type GroupItemContent = t.TypeOf<typeof GroupItemContent>; | ||
declare const itemLegacyReader: t.ArrayC<t.TupleC<[t.StringC, t.UnknownC]>>; | ||
declare const itemLegacyReader: t.RecordC<t.StringC, t.UnknownC>; | ||
type GroupItemLegacy = t.TypeOf<typeof itemLegacyReader>; | ||
@@ -591,3 +591,5 @@ export declare const GroupItemLegacy: (ctx: LegacyContentCtx) => t.Type<{ | ||
}][]; | ||
}, WithTypes<[string, unknown][]>, unknown>; | ||
}, WithTypes<{ | ||
[x: string]: unknown; | ||
}>, unknown>; | ||
type GroupLegacy = Array<GroupItemLegacy>; | ||
@@ -594,0 +596,0 @@ export declare const GroupLegacy: (ctx: LegacyContentCtx) => t.Type<{ |
@@ -17,7 +17,7 @@ "use strict"; | ||
}); | ||
const itemLegacyReader = t.array(t.tuple([t.string, t.unknown])); | ||
const itemLegacyReader = t.record(t.string, t.unknown); | ||
const GroupItemLegacy = (ctx) => { | ||
return new t.Type("GroupItemLegacy", (u) => (0, utils_1.hasContentType)(u) && u.__TYPE__ === exports.GroupItemContentType, (u) => { | ||
const parsed = (0, function_1.pipe)(itemLegacyReader.decode(u), fp_ts_1.either.map((items) => { | ||
const parsedItems = items.reduce((acc, [itemKey, itemValue]) => { | ||
const parsedItems = Object.entries(items).reduce((acc, [itemKey, itemValue]) => { | ||
const itemCtx = (0, LegacyContentCtx_1.getFieldCtx)(itemKey, ctx); | ||
@@ -44,6 +44,6 @@ const result = (0, nestable_1.NestableLegacy)(itemCtx).decode(itemValue); | ||
return { | ||
content: [...acc.content, [key, encoded.content]], | ||
content: { ...acc.content, [key]: encoded.content }, | ||
types: { ...acc.types, ...encoded.types }, | ||
}; | ||
}, { content: [], types: {} }); | ||
}, { content: {}, types: {} }); | ||
}); | ||
@@ -50,0 +50,0 @@ }; |
@@ -272,3 +272,5 @@ import * as t from "io-ts"; | ||
}][]; | ||
}, import("../../../LegacyContentCtx").WithTypes<[string, unknown][]>, unknown>>; | ||
}, import("../../../LegacyContentCtx").WithTypes<{ | ||
[x: string]: unknown; | ||
}>, unknown>>; | ||
export declare const RepeatableWidgets: t.ArrayC<t.ExactC<t.TypeC<{ | ||
@@ -275,0 +277,0 @@ __TYPE__: t.LiteralC<"GroupItemContent">; |
{ | ||
"name": "@prismicio/types-internal", | ||
"version": "2.0.0-alpha.9", | ||
"version": "2.0.0-alpha.10", | ||
"description": "Prismic types for Custom Types and Prismic Data", | ||
@@ -30,3 +30,3 @@ "keywords": [ | ||
"release:alpha:dry": "standard-version --release-as major --prerelease alpha --dry-run", | ||
"test": "jest --no-cache --silent=false --verbose=false", | ||
"test": "jest --no-cache --silent=false --verbose=false --coverage", | ||
"eslint": "eslint . --cache --cache-location .caches/eslint --cache-strategy content --ext js,ts,tsx --max-warnings 0", | ||
@@ -33,0 +33,0 @@ "eslint-fix": "npm run eslint -- --fix", |
@@ -23,3 +23,3 @@ import { either } from "fp-ts" | ||
const itemLegacyReader = t.array(t.tuple([t.string, t.unknown])) | ||
const itemLegacyReader = t.record(t.string, t.unknown) | ||
type GroupItemLegacy = t.TypeOf<typeof itemLegacyReader> | ||
@@ -36,13 +36,12 @@ | ||
either.map((items) => { | ||
const parsedItems = items.reduce<Array<[string, NestableContent]>>( | ||
(acc, [itemKey, itemValue]) => { | ||
const itemCtx = getFieldCtx(itemKey, ctx) | ||
const result = NestableLegacy(itemCtx).decode(itemValue) | ||
if (!result) return acc | ||
const parsedItems = Object.entries(items).reduce< | ||
Array<[string, NestableContent]> | ||
>((acc, [itemKey, itemValue]) => { | ||
const itemCtx = getFieldCtx(itemKey, ctx) | ||
const result = NestableLegacy(itemCtx).decode(itemValue) | ||
if (!result) return acc | ||
if (isLeft(result)) return acc | ||
return [...acc, [itemKey, result.right]] | ||
}, | ||
[], | ||
) | ||
if (isLeft(result)) return acc | ||
return [...acc, [itemKey, result.right]] | ||
}, []) | ||
@@ -65,7 +64,7 @@ return { | ||
return { | ||
content: [...acc.content, [key, encoded.content]], | ||
content: { ...acc.content, [key]: encoded.content }, | ||
types: { ...acc.types, ...encoded.types }, | ||
} | ||
}, | ||
{ content: [], types: {} }, | ||
{ content: {}, types: {} }, | ||
) | ||
@@ -72,0 +71,0 @@ }, |
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
2278682
54322
167
21
29
61
2