@prismicio/types-internal 2.2.0-traverse.alpha-0 → 2.2.0-traverse.alpha-2
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.
- package/lib/_internal/utils.d.ts +21 -4
- package/lib/_internal/utils.js +11 -0
- package/lib/content/Document.d.ts +2185 -13
- package/lib/content/Document.js +130 -35
- package/lib/content/fields/GroupContent.d.ts +11 -4
- package/lib/content/fields/GroupContent.js +31 -15
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +8 -6
- package/lib/content/fields/slices/Slice/CompositeSliceContent.js +33 -36
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +8 -6
- package/lib/content/fields/slices/Slice/SharedSliceContent.js +28 -38
- package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +10 -0
- package/lib/content/fields/slices/Slice/SimpleSliceContent.js +60 -1
- package/lib/content/fields/slices/SliceItem.d.ts +15 -0
- package/lib/content/fields/slices/SliceItem.js +15 -1
- package/lib/content/fields/slices/SlicesContent.d.ts +4 -3
- package/lib/content/fields/slices/SlicesContent.js +125 -62
- package/lib/customtypes/CustomType.d.ts +4 -0
- package/lib/customtypes/CustomType.js +18 -1
- package/lib/customtypes/Section.d.ts +3 -0
- package/lib/customtypes/diff/SharedSlice.d.ts +6 -0
- package/lib/customtypes/widgets/Widget.d.ts +3 -0
- package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +5 -0
- package/lib/customtypes/widgets/slices/SharedSlice.d.ts +8 -0
- package/lib/customtypes/widgets/slices/SharedSlice.js +3 -0
- package/lib/customtypes/widgets/slices/Slices.d.ts +6 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/utils.d.ts +3 -0
- package/package.json +1 -1
- package/src/_internal/utils.ts +63 -7
- package/src/content/Document.ts +177 -42
- package/src/content/fields/GroupContent.ts +50 -16
- package/src/content/fields/slices/Slice/CompositeSliceContent.ts +55 -44
- package/src/content/fields/slices/Slice/SharedSliceContent.ts +43 -49
- package/src/content/fields/slices/Slice/SimpleSliceContent.ts +99 -1
- package/src/content/fields/slices/SliceItem.ts +39 -3
- package/src/content/fields/slices/SlicesContent.ts +172 -69
- package/src/customtypes/CustomType.ts +21 -0
- package/src/customtypes/widgets/slices/CompositeSlice.ts +6 -0
- package/src/customtypes/widgets/slices/SharedSlice.ts +12 -0
- package/lib/validators/NullOrT.d.ts +0 -2
- package/lib/validators/NullOrT.js +0 -12
package/lib/_internal/utils.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export declare type
|
|
1
|
+
import type { SharedSliceItemContent, SliceItemContent, WidgetContent } from "../content";
|
|
2
|
+
import type { CompositeSliceFields, Group, NestableWidget, StaticSlices, UID, VariationFields } from "../customtypes";
|
|
3
|
+
export declare type PickOnly<T, K extends keyof T> = Pick<T, K> & {
|
|
4
|
+
[P in Exclude<keyof T, K>]?: never;
|
|
5
|
+
};
|
|
6
|
+
export declare type TraverseSliceContentFn = <S extends SliceItemContent | SharedSliceItemContent, D extends VariationFields | CompositeSliceFields | Group | NestableWidget>({ path, key, apiId, model, content, }: {
|
|
7
|
+
path: ContentPath;
|
|
8
|
+
key: string;
|
|
9
|
+
apiId: string;
|
|
10
|
+
model?: D | undefined;
|
|
11
|
+
content: S;
|
|
12
|
+
}) => S | SharedSliceItemContent | undefined;
|
|
13
|
+
export declare type TraverseWidgetContentFn = <C extends WidgetContent, D extends NestableWidget | StaticSlices | Group | UID>({ path, key, apiId, model, content, }: {
|
|
4
14
|
path: ContentPath;
|
|
5
15
|
key: string;
|
|
6
16
|
apiId: string;
|
|
@@ -8,10 +18,17 @@ export declare type TraverseContentFn = <C extends WidgetContent | SliceContent,
|
|
|
8
18
|
content: C;
|
|
9
19
|
}) => C | undefined;
|
|
10
20
|
export declare type ContentPathEntry = {
|
|
11
|
-
type: "CustomType" |
|
|
21
|
+
type: "CustomType" | "Widget" | "SharedSlice" | "Slice" | "LegacySlice" | "GroupItem" | "primary" | "items";
|
|
12
22
|
key: string;
|
|
13
23
|
};
|
|
14
24
|
export declare type ContentPath = ReadonlyArray<ContentPathEntry>;
|
|
15
25
|
export declare const ContentPath: {
|
|
16
26
|
serialize(path: ContentPath): string;
|
|
27
|
+
current(path: ContentPath): ContentPathEntry | undefined;
|
|
28
|
+
append(path: string, strElement: string): string;
|
|
29
|
+
make(entries: Array<{
|
|
30
|
+
key?: ContentPathEntry["key"] | undefined;
|
|
31
|
+
type: ContentPathEntry["type"];
|
|
32
|
+
}>): ContentPath;
|
|
17
33
|
};
|
|
34
|
+
export declare type SliceModel = VariationFields | NestableWidget | CompositeSliceFields | Group;
|
package/lib/_internal/utils.js
CHANGED
|
@@ -6,4 +6,15 @@ exports.ContentPath = {
|
|
|
6
6
|
serialize(path) {
|
|
7
7
|
return path.map((entry) => entry.key).join(PATH_SEPARATOR);
|
|
8
8
|
},
|
|
9
|
+
current(path) {
|
|
10
|
+
return path[path.length - 1];
|
|
11
|
+
},
|
|
12
|
+
append(path, strElement) {
|
|
13
|
+
return path + PATH_SEPARATOR + strElement;
|
|
14
|
+
},
|
|
15
|
+
make(entries) {
|
|
16
|
+
return entries.reduce((acc, { key, type }) => {
|
|
17
|
+
return key ? acc.concat({ key, type }) : acc;
|
|
18
|
+
}, []);
|
|
19
|
+
},
|
|
9
20
|
};
|