From 75a58a2e3f8f0d3bfa7ff0059c2e61e9eaf38a84 Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Tue, 9 Apr 2024 12:46:14 -1000 Subject: [PATCH] feat: support `fields` slice variation config --- src/types/model/sharedSliceVariation.ts | 10 +++++++++- src/types/model/types.ts | 10 ++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/types/model/sharedSliceVariation.ts b/src/types/model/sharedSliceVariation.ts index ef856a12..760145cb 100644 --- a/src/types/model/sharedSliceVariation.ts +++ b/src/types/model/sharedSliceVariation.ts @@ -1,4 +1,7 @@ -import type { CustomTypeModelFieldForGroup } from "./types"; +import type { + CustomTypeModelFieldForGroup, + CustomTypeModelFieldForSlice, +} from "./types"; /** * A shared Slice variation. @@ -10,6 +13,10 @@ import type { CustomTypeModelFieldForGroup } from "./types"; */ export interface SharedSliceModelVariation< ID extends string = string, + Fields extends Record = Record< + string, + CustomTypeModelFieldForSlice + >, PrimaryFields extends Record = Record< string, CustomTypeModelFieldForGroup @@ -24,6 +31,7 @@ export interface SharedSliceModelVariation< docURL: string; version: string; description: string; + fields?: Fields; primary?: PrimaryFields; items?: ItemFields; imageUrl: string; diff --git a/src/types/model/types.ts b/src/types/model/types.ts index 1ac2840c..dfddc75d 100644 --- a/src/types/model/types.ts +++ b/src/types/model/types.ts @@ -89,3 +89,13 @@ export type CustomTypeModelFieldForGroup = | CustomTypeModelKeyTextField | CustomTypeModelTimestampField | CustomTypeModelSeparatorField; + +/** + * Any custom type field that is valid for a slice. + * + * **Note**: This type is only valid for a slice's `fields` property. It cannot + * be used for the deprecated `primary` or `items` properties. + */ +export type CustomTypeModelFieldForSlice = + | CustomTypeModelGroupField + | CustomTypeModelFieldForGroup;