@prismicio/types-internal 2.0.0-alpha.9 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -316,7 +316,7 @@ export declare const GroupItemContent: t.ExactC<t.TypeC<{
|
|
|
316
316
|
}>>]>]>>;
|
|
317
317
|
}>>;
|
|
318
318
|
export type GroupItemContent = t.TypeOf<typeof GroupItemContent>;
|
|
319
|
-
declare const itemLegacyReader: t.
|
|
319
|
+
declare const itemLegacyReader: t.RecordC<t.StringC, t.UnknownC>;
|
|
320
320
|
type GroupItemLegacy = t.TypeOf<typeof itemLegacyReader>;
|
|
321
321
|
export declare const GroupItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
322
322
|
__TYPE__: "GroupItemContent";
|
|
@@ -587,7 +587,9 @@ export declare const GroupItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
587
587
|
} | {
|
|
588
588
|
__TYPE__: "SeparatorContent";
|
|
589
589
|
}][];
|
|
590
|
-
}, WithTypes<
|
|
590
|
+
}, WithTypes<{
|
|
591
|
+
[x: string]: unknown;
|
|
592
|
+
}>, unknown>;
|
|
591
593
|
type GroupLegacy = Array<GroupItemLegacy>;
|
|
592
594
|
export declare const GroupLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
593
595
|
__TYPE__: "GroupContentType";
|
|
@@ -14,11 +14,11 @@ exports.GroupItemContent = t.strict({
|
|
|
14
14
|
__TYPE__: t.literal(exports.GroupItemContentType),
|
|
15
15
|
value: t.array(t.tuple([t.string, nestable_1.NestableContent])),
|
|
16
16
|
});
|
|
17
|
-
const itemLegacyReader = t.
|
|
17
|
+
const itemLegacyReader = t.record(t.string, t.unknown);
|
|
18
18
|
const GroupItemLegacy = (ctx) => {
|
|
19
19
|
return new t.Type("GroupItemLegacy", (u) => (0, utils_1.hasContentType)(u) && u.__TYPE__ === exports.GroupItemContentType, (u) => {
|
|
20
20
|
const parsed = (0, function_1.pipe)(itemLegacyReader.decode(u), fp_ts_1.either.map((items) => {
|
|
21
|
-
const parsedItems = items.reduce((acc, [itemKey, itemValue]) => {
|
|
21
|
+
const parsedItems = Object.entries(items).reduce((acc, [itemKey, itemValue]) => {
|
|
22
22
|
const itemCtx = (0, LegacyContentCtx_1.getFieldCtx)(itemKey, ctx);
|
|
23
23
|
const result = (0, nestable_1.NestableLegacy)(itemCtx).decode(itemValue);
|
|
24
24
|
if (!result)
|
|
@@ -40,10 +40,10 @@ const GroupItemLegacy = (ctx) => {
|
|
|
40
40
|
if (!encoded)
|
|
41
41
|
return acc;
|
|
42
42
|
return {
|
|
43
|
-
content:
|
|
43
|
+
content: { ...acc.content, [key]: encoded.content },
|
|
44
44
|
types: { ...acc.types, ...encoded.types },
|
|
45
45
|
};
|
|
46
|
-
}, { content:
|
|
46
|
+
}, { content: {}, types: {} });
|
|
47
47
|
});
|
|
48
48
|
};
|
|
49
49
|
exports.GroupItemLegacy = GroupItemLegacy;
|
|
@@ -269,7 +269,9 @@ export declare const RepeatableWidgetsLegacy: (ctx: LegacyContentCtx) => t.Array
|
|
|
269
269
|
} | {
|
|
270
270
|
__TYPE__: "SeparatorContent";
|
|
271
271
|
}][];
|
|
272
|
-
}, import("../../../LegacyContentCtx").WithTypes<
|
|
272
|
+
}, import("../../../LegacyContentCtx").WithTypes<{
|
|
273
|
+
[x: string]: unknown;
|
|
274
|
+
}>, unknown>>;
|
|
273
275
|
export declare const RepeatableWidgets: t.ArrayC<t.ExactC<t.TypeC<{
|
|
274
276
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
275
277
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.ExactC<t.TypeC<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/types-internal",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
4
|
"description": "Prismic types for Custom Types and Prismic Data",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"release:dry": "standard-version --dry-run",
|
|
28
28
|
"release:alpha": "npm run test && standard-version --release-as major --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha",
|
|
29
29
|
"release:alpha:dry": "standard-version --release-as major --prerelease alpha --dry-run",
|
|
30
|
-
"test": "jest --no-cache --silent=false --verbose=false",
|
|
30
|
+
"test": "jest --no-cache --silent=false --verbose=false --coverage",
|
|
31
31
|
"eslint": "eslint . --cache --cache-location .caches/eslint --cache-strategy content --ext js,ts,tsx --max-warnings 0",
|
|
32
32
|
"eslint-fix": "npm run eslint -- --fix",
|
|
33
33
|
"preflight": "npm run prettier && npm run build && npm run eslint",
|
|
@@ -20,7 +20,7 @@ export const GroupItemContent = t.strict({
|
|
|
20
20
|
})
|
|
21
21
|
export type GroupItemContent = t.TypeOf<typeof GroupItemContent>
|
|
22
22
|
|
|
23
|
-
const itemLegacyReader = t.
|
|
23
|
+
const itemLegacyReader = t.record(t.string, t.unknown)
|
|
24
24
|
type GroupItemLegacy = t.TypeOf<typeof itemLegacyReader>
|
|
25
25
|
|
|
26
26
|
export const GroupItemLegacy = (ctx: LegacyContentCtx) => {
|
|
@@ -32,17 +32,16 @@ export const GroupItemLegacy = (ctx: LegacyContentCtx) => {
|
|
|
32
32
|
const parsed = pipe(
|
|
33
33
|
itemLegacyReader.decode(u),
|
|
34
34
|
either.map((items) => {
|
|
35
|
-
const parsedItems = items.reduce<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
const parsedItems = Object.entries(items).reduce<
|
|
36
|
+
Array<[string, NestableContent]>
|
|
37
|
+
>((acc, [itemKey, itemValue]) => {
|
|
38
|
+
const itemCtx = getFieldCtx(itemKey, ctx)
|
|
39
|
+
const result = NestableLegacy(itemCtx).decode(itemValue)
|
|
40
|
+
if (!result) return acc
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
[],
|
|
45
|
-
)
|
|
42
|
+
if (isLeft(result)) return acc
|
|
43
|
+
return [...acc, [itemKey, result.right]]
|
|
44
|
+
}, [])
|
|
46
45
|
|
|
47
46
|
return {
|
|
48
47
|
value: parsedItems,
|
|
@@ -60,11 +59,11 @@ export const GroupItemLegacy = (ctx: LegacyContentCtx) => {
|
|
|
60
59
|
if (!encoded) return acc
|
|
61
60
|
|
|
62
61
|
return {
|
|
63
|
-
content:
|
|
62
|
+
content: { ...acc.content, [key]: encoded.content },
|
|
64
63
|
types: { ...acc.types, ...encoded.types },
|
|
65
64
|
}
|
|
66
65
|
},
|
|
67
|
-
{ content:
|
|
66
|
+
{ content: {}, types: {} },
|
|
68
67
|
)
|
|
69
68
|
},
|
|
70
69
|
)
|