@enonic-types/core 7.12.1 → 7.13.0-B1
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/index.d.ts +129 -13
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
+
export type ComponentDescriptor = `${string}:${string}`;
|
|
2
|
+
|
|
3
|
+
export interface NestedRecord {
|
|
4
|
+
[name: PropertyKey]: NestedRecord | unknown
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
declare global {
|
|
8
|
+
interface XpLayoutMap {
|
|
9
|
+
[layoutDescriptor: ComponentDescriptor]: NestedRecord;
|
|
10
|
+
}
|
|
11
|
+
interface XpPageMap {
|
|
12
|
+
[pageDescriptor: ComponentDescriptor]: NestedRecord;
|
|
13
|
+
}
|
|
14
|
+
interface XpPartMap {
|
|
15
|
+
[partDescriptor: ComponentDescriptor]: NestedRecord;
|
|
16
|
+
}
|
|
2
17
|
interface XpXData {
|
|
3
18
|
[key: string]: Record<string, Record<string, unknown>>;
|
|
4
19
|
}
|
|
@@ -52,43 +67,143 @@ export interface PublishInfo {
|
|
|
52
67
|
first?: string;
|
|
53
68
|
}
|
|
54
69
|
|
|
55
|
-
export interface
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
export interface FragmentComponent {
|
|
71
|
+
type: 'fragment'
|
|
72
|
+
fragment: string;
|
|
58
73
|
path: string;
|
|
59
|
-
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface LayoutComponent<
|
|
77
|
+
Descriptor extends ComponentDescriptor = ComponentDescriptor,
|
|
78
|
+
Config extends NestedRecord = Descriptor extends LayoutDescriptor
|
|
79
|
+
? XpLayoutMap[LayoutDescriptor]
|
|
80
|
+
: NestedRecord,
|
|
81
|
+
Regions extends
|
|
82
|
+
Record<string, Region<(FragmentComponent | PartComponent | TextComponent)[]>> =
|
|
83
|
+
Record<string, Region<(FragmentComponent | Part | TextComponent)[]>>
|
|
84
|
+
> {
|
|
85
|
+
type: 'layout'
|
|
86
|
+
descriptor: Descriptor
|
|
87
|
+
config: Config
|
|
88
|
+
path?: string // Missing in fragmentPreview https://github.com/enonic/xp/issues/10116
|
|
89
|
+
regions: Regions;
|
|
90
|
+
}
|
|
91
|
+
type LayoutDescriptor = keyof XpLayoutMap;
|
|
92
|
+
type Layout = LayoutDescriptor extends any // this lets us iterate over every member of the union
|
|
93
|
+
? LayoutComponent<LayoutDescriptor, XpLayoutMap[LayoutDescriptor]>
|
|
94
|
+
: never;
|
|
95
|
+
|
|
96
|
+
export interface PartComponent<
|
|
97
|
+
Descriptor extends ComponentDescriptor = ComponentDescriptor,
|
|
98
|
+
Config extends NestedRecord =
|
|
99
|
+
Descriptor extends PartDescriptor
|
|
100
|
+
? XpPartMap<PartDescriptor>
|
|
101
|
+
: NestedRecord
|
|
102
|
+
> {
|
|
103
|
+
type: 'part'
|
|
104
|
+
descriptor: Descriptor
|
|
105
|
+
config: Config
|
|
106
|
+
path?: string // Missing in fragmentPreview https://github.com/enonic/xp/issues/10116
|
|
107
|
+
}
|
|
108
|
+
type PartDescriptor = keyof XpPartMap;
|
|
109
|
+
type Part = PartDescriptor extends any // this lets us iterate over every member of the union
|
|
110
|
+
? PartComponent<PartDescriptor, XpPartMap<PartDescriptor>>
|
|
111
|
+
: never;
|
|
112
|
+
|
|
113
|
+
export interface PageComponent<
|
|
114
|
+
Descriptor extends ComponentDescriptor = ComponentDescriptor,
|
|
115
|
+
Config extends NestedRecord =
|
|
116
|
+
Descriptor extends PageDescriptor
|
|
117
|
+
? XpPageMap[PageDescriptor]
|
|
118
|
+
: NestedRecord,
|
|
119
|
+
Regions extends
|
|
120
|
+
Record<string, Region<(FragmentComponent | LayoutComponent | PartComponent | TextComponent)[]>> =
|
|
121
|
+
Record<string, Region<(FragmentComponent | Layout | Part | TextComponent)[]>>
|
|
122
|
+
> {
|
|
123
|
+
type: 'page'
|
|
124
|
+
descriptor: Descriptor
|
|
125
|
+
config: Config
|
|
126
|
+
path: '/'
|
|
60
127
|
regions: Regions;
|
|
61
128
|
}
|
|
129
|
+
type PageDescriptor = keyof XpPageMap;
|
|
130
|
+
type Page = PageDescriptor extends any // this lets us iterate over every member of the union
|
|
131
|
+
? PageComponent<PageDescriptor, XpPageMap[PageDescriptor]>
|
|
132
|
+
: never;
|
|
133
|
+
|
|
134
|
+
export interface TextComponent {
|
|
135
|
+
type: 'text'
|
|
136
|
+
path: string
|
|
137
|
+
text: string
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export type Component<
|
|
141
|
+
Descriptor extends ComponentDescriptor = LayoutDescriptor | PageDescriptor | PartDescriptor,
|
|
142
|
+
Config extends NestedRecord = NestedRecord,
|
|
143
|
+
Regions extends Record<string, Region> = Record<string, Region>,
|
|
144
|
+
> =
|
|
145
|
+
| FragmentComponent
|
|
146
|
+
| LayoutComponent<Descriptor, Config, Regions>
|
|
147
|
+
| PageComponent<Descriptor, Config, Regions>
|
|
148
|
+
| PartComponent<Descriptor, Config>
|
|
149
|
+
| TextComponent;
|
|
150
|
+
|
|
151
|
+
export interface PageRegion<
|
|
152
|
+
Components extends
|
|
153
|
+
(FragmentComponent | LayoutComponent | PartComponent | TextComponent)[] =
|
|
154
|
+
(FragmentComponent | Layout | Part | TextComponent)[]
|
|
155
|
+
> {
|
|
156
|
+
name: string;
|
|
157
|
+
components: Components;
|
|
158
|
+
}
|
|
62
159
|
|
|
63
|
-
export interface
|
|
160
|
+
export interface LayoutRegion<
|
|
161
|
+
Components extends
|
|
162
|
+
(FragmentComponent | PartComponent | TextComponent)[] =
|
|
163
|
+
(FragmentComponent | Part | TextComponent)[]
|
|
164
|
+
> {
|
|
64
165
|
name: string;
|
|
65
|
-
components:
|
|
166
|
+
components: Components;
|
|
66
167
|
}
|
|
67
168
|
|
|
169
|
+
export type Region<
|
|
170
|
+
Components extends
|
|
171
|
+
(FragmentComponent | LayoutComponent | PartComponent | TextComponent)[] =
|
|
172
|
+
(FragmentComponent | Layout | Part | TextComponent)[]
|
|
173
|
+
> = PageRegion<Components> | LayoutRegion<Components>;
|
|
174
|
+
|
|
68
175
|
export interface Content<
|
|
69
176
|
Data = Record<string, unknown>,
|
|
70
177
|
Type extends string = string,
|
|
71
|
-
|
|
178
|
+
_Component extends (
|
|
179
|
+
Type extends 'portal:fragment'
|
|
180
|
+
? LayoutComponent | PartComponent
|
|
181
|
+
: PageComponent
|
|
182
|
+
) = (
|
|
183
|
+
Type extends 'portal:fragment'
|
|
184
|
+
? Layout | Part
|
|
185
|
+
: Page
|
|
186
|
+
),
|
|
72
187
|
> {
|
|
73
188
|
_id: string;
|
|
74
189
|
_name: string;
|
|
75
190
|
_path: string;
|
|
76
|
-
_score
|
|
191
|
+
_score?: number;
|
|
77
192
|
creator: UserKey;
|
|
78
|
-
modifier
|
|
193
|
+
modifier?: UserKey;
|
|
79
194
|
createdTime: string;
|
|
80
|
-
modifiedTime
|
|
195
|
+
modifiedTime?: string;
|
|
81
196
|
owner: string;
|
|
82
|
-
data: Data;
|
|
197
|
+
data: Type extends 'portal:fragment' ? undefined : Data;
|
|
83
198
|
type: Type;
|
|
84
199
|
displayName: string;
|
|
85
200
|
hasChildren: boolean;
|
|
86
201
|
language?: string;
|
|
87
202
|
valid: boolean;
|
|
88
|
-
originProject
|
|
203
|
+
originProject?: string;
|
|
89
204
|
childOrder?: string;
|
|
90
205
|
_sort?: object[];
|
|
91
|
-
page:
|
|
206
|
+
page: Type extends 'portal:fragment' ? undefined : _Component;
|
|
92
207
|
x: XpXData;
|
|
93
208
|
attachments: Record<string, Attachment>;
|
|
94
209
|
publish?: PublishInfo;
|
|
@@ -98,6 +213,7 @@ export interface Content<
|
|
|
98
213
|
};
|
|
99
214
|
inherit?: ('CONTENT' | 'PARENT' | 'NAME' | 'SORT')[];
|
|
100
215
|
variantOf?: string;
|
|
216
|
+
fragment: Type extends 'portal:fragment' ? _Component : undefined;
|
|
101
217
|
}
|
|
102
218
|
|
|
103
219
|
// Compliant with npm module ts-brand
|