-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
670 lines (600 loc) · 22.3 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
declare module "color-name-list/dist/colornames.esm.mjs";
declare module "@neos-project/neos-ui-backend-connector" {
type MakeFetchRequest = (csrf: string) => RequestInit & { url?: string };
interface RequestQueueItem {
makeFetchRequest: MakeFetchRequest;
resolve: (value?: any | undefined) => void;
reject: (reason?: any) => void;
}
declare class FetchWithErrorHandling {
/**
* MAIN ENTRY POINT, replacing the "fetch" API.
*
* does a "fetch" request with a CSRF token and automatic relogin if a login error occurs.
*
* EXAMPLE
*
* fetchWithErrorHandling.withCsrfToken((csrfToken) => ({
* url: "/neos/route",
* method: "POST",
* credentials: "include",
* headers: {
* 'X-Flow-Csrftoken': csrfToken,
* 'Content-Type': 'application/json'
* },
* body: JSON.stringify(
* args
* )
* })).catch(reason => fetchWithErrorHandling.generalErrorHandler(reason))
*
*/
public withCsrfToken(makeFetchRequest: MakeFetchRequest): Promise<any>;
/**
* Every request that is supposed to show an error message on failure (i.e. any request),
* should end with this catch block:
* `.catch(reason => fetchWithErrorHandling.generalErrorHandler(reason))`
*/
public generalErrorHandler(reason: string | Error): void;
/**
* Safely parse JSON from response
*/
public parseJson(response: Body): any;
}
export const fetchWithErrorHandling = new FetchWithErrorHandling();
}
declare module "@neos-project/neos-ui-i18n" {
import React from "react";
interface I18nProps {
/**
* Fallback key which gets rendered once the i18n service doesn't return a translation.
*/
fallback?: string;
/**
* The target id which the i18n service accepts.
*/
id?: string;
/**
* The destination paths for the package of the translation.
*/
packageKey?: string;
/**
* The destination paths for the source of the translation.
*/
sourceName?: string;
/**
* Additional parameters which are passed to the i18n service.
*/
params?: object;
/**
* className which gets added to the translation span.
*/
className?: string;
}
export default class I18n extends React.PureComponent<I18nProps> {}
}
declare module "@neos-project/neos-ui" {
type Unsubscribe = () => void;
// we dont require the @types/redux as they are deprecated
export interface Store {
dispatch(action: any): void;
getState(): any;
subscribe(listener: () => void): Unsubscribe;
}
}
declare module "@neos-project/neos-ui-redux-store" {
import { Node } from "@neos-project/neos-ts-interfaces";
import { DefaultRootState } from "react-redux";
type Selector<S> = (state: DefaultRootState) => S;
type Selectors = {
CR: {
Nodes: {
focusedSelector: Selector<Node | undefined>;
};
};
System: {
authenticationTimeout: Selector<boolean>;
};
UI: {
Inspector: {
transientValues: Selector<Record<string, { value: any }> | undefined>;
};
};
};
type Actions = {
System: {
authenticationTimeout(): any;
};
UI: {
FlashMessages: {
add(key: string, message: string, severity: "success" | "info" | "error", timeout?: number);
};
};
};
export const actions: Actions;
export const selectors: Selectors;
}
declare module "@neos-project/neos-ui-decorators" {
import { InferableComponentEnhancerWithProps, ConnectedProps } from "react-redux";
import { GlobalRegistry } from "@neos-project/neos-ts-interfaces";
export interface NeosContextInterface {
globalRegistry: GlobalRegistry;
configuration: {};
routes: {};
}
/**
* Infers the type of props that a neosifier will inject into a component.
* we reuse this behavior from {@link ConnectedProps}
*/
export type NeosifiedProps<TNeosifier> = ConnectedProps<TNeosifier>;
export const NeosContext: React.Context<NeosContextInterface | null>;
type MapRegistryToPropsParam<TStateProps> = (globalRegistry: GlobalRegistry) => TStateProps;
interface Neos {
<TStateProps = {}, TOwnProps = {}>(
mapRegistryToProps: MapRegistryToPropsParam<TStateProps>,
): InferableComponentEnhancerWithProps<TStateProps & { neos: NeosContextInterface }, TOwnProps>;
}
export const neos: Neos;
}
declare module "@neos-project/neos-ui-extensibility" {
import type { Store } from "@neos-project/neos-ui";
import { GlobalRegistry, FrontendConfigurationRaw } from "@neos-project/neos-ts-interfaces";
type BootstrapOptions = {
store: Store;
frontendConfiguration: FrontendConfigurationRaw;
configuration;
routes;
};
type Bootstrap = (globalRegistry: GlobalRegistry, bootstrapOptions: BootstrapOptions) => void;
export default function manifest(identifier: string, options: {}, bootstrap: Bootstrap): void;
export {
SynchronousMetaRegistry,
SynchronousRegistry,
} from "@mhsdesign/esbuild-neos-ui-extensibility/@neos-project/neos-ui-extensibility/src/registry";
}
declare module "@neos-project/neos-ts-interfaces" {
export type NodeContextPath = string;
export type FusionPath = string;
export type NodeTypeName = string;
export type WorkspaceName = string;
export type DimensionName = string;
export type DimensionValue = string;
export type DimensionPresetName = string;
export type DimensionValues = DimensionValue[];
export interface DimensionCombination {
[propName: string]: DimensionValues;
}
export interface DimensionPresetCombination {
[propName: string]: DimensionPresetName;
}
export interface PresetConfiguration {
name?: string;
label: string;
values: DimensionValues;
uriSegment: string;
}
export interface DimensionInformation {
default: string;
defaultPreset: string;
label: string;
icon: string;
presets: {
[propName: string]: PresetConfiguration;
};
}
export interface ContextProperties {
contextPath?: NodeContextPath;
workspaceName?: WorkspaceName;
invisibleContentShown?: boolean;
removedContentShown?: boolean;
}
export interface NodeChild {
contextPath: NodeContextPath;
nodeType: NodeTypeName;
}
// TODO: for some reason (probably due to immer) I can not use ReadonlyArray here
export interface NodeChildren extends Array<NodeChild> {}
export interface NodePolicy
extends Readonly<{
disallowedNodeTypes: NodeTypeName[];
canRemove: boolean;
canEdit: boolean;
disallowedProperties: string[];
}> {}
// TODO: for some reason (probably due to immer) I can not use Readonly here
export interface Node {
contextPath: NodeContextPath;
name: string;
identifier: string;
nodeType: NodeTypeName;
label: string;
isAutoCreated: boolean;
depth: number;
children: NodeChildren;
matchesCurrentDimensions: boolean;
properties: {
[propName: string]: any;
};
isFullyLoaded: boolean;
uri: string;
parent: NodeContextPath;
policy?: NodePolicy;
dimensions?: DimensionPresetCombination;
otherNodeVariants?: DimensionPresetCombination[];
}
// Type guard using duck-typing on some random properties to know if object is a Node
export function isNode(node: any): node is Node;
export interface NodeMap {
[propName: string]: Node | undefined;
}
export enum ClipboardMode {
COPY = "Copy",
MOVE = "Move",
}
export enum InsertPosition {
INTO = "into",
BEFORE = "before",
AFTER = "after",
}
export enum SelectionModeTypes {
SINGLE_SELECT = "SINGLE_SELECT",
MULTIPLE_SELECT = "MULTIPLE_SELECT",
RANGE_SELECT = "RANGE_SELECT",
}
export interface ValidatorConfiguration {
[propName: string]: any;
}
export interface PropertyConfiguration {
type?: string;
ui?: {
label?: string;
reloadIfChanged?: boolean;
inline?: {
editor?: string;
editorOptions?: {
[propName: string]: any;
};
};
inlineEditable?: boolean;
inspector?: {
hidden?: boolean;
defaultValue?: string;
editor?: string;
editorOptions?: {
[propName: string]: any;
};
group?: string;
position?: number | string;
};
help?: {
message?: string;
thumbnail?: string;
};
aloha?: any; // deprecated format
};
validation?: {
[propName: string]: ValidatorConfiguration | undefined;
};
}
export interface NodeType {
name?: string;
superTypes: {
[propName: string]: boolean | undefined;
};
constraints: {
nodeTypes: {
[propName: string]: boolean | undefined;
};
};
label?: string;
ui?: {
group?: string;
icon?: string;
label?: string;
position?: number | string;
inlineEditable?: boolean;
inspector?: {
groups?: {
[propName: string]:
| {
title?: string;
label?: string;
icon?: string;
tab?: string;
position?: number | string;
collapsed?: boolean;
}
| undefined;
};
tabs?: {
[propName: string]:
| {
label?: string;
position?: number | string;
icon?: string;
}
| undefined;
};
views?: {
[propName: string]: {
group?: string;
label?: string;
position?: number | string;
helpMessage?: string;
view?: string;
viewOptions?: {
[propName: string]: any;
};
};
};
};
creationDialog?: {
elements?: {
[propName: string]: {
type?: string;
ui?: {
label?: string;
editor?: string;
editorOptions?: {
[propName: string]: any;
};
};
validation?: {
[propName: string]: {
[propName: string]: any;
};
};
};
};
};
};
properties?: {
[propName: string]: PropertyConfiguration | undefined;
};
}
//
// Change object from our Changes API
//
export interface Change
extends Readonly<{
type: string;
subject: NodeContextPath;
payload: {
propertyName: string;
value: any;
};
}> {}
import { SynchronousMetaRegistry, SynchronousRegistry } from "@neos-project/neos-ui-extensibility";
import React from "react";
// TODO: move to nodetypesregistry itself
export interface NodeTypesRegistry extends SynchronousRegistry<NodeType> {
get: (nodeType: NodeTypeName) => NodeType | null;
getRole: (roleName: string) => NodeTypeName | null;
getSubTypesOf: (nodeType: NodeTypeName) => NodeTypeName[];
getAllowedNodeTypesTakingAutoCreatedIntoAccount: (
isSubjectNodeAutocreated: boolean,
referenceParentName: string,
referenceParentNodeType: NodeTypeName,
referenceGrandParentNodeType: NodeTypeName | null,
role: string,
) => NodeTypeName[];
}
// TODO: move to validatorsregistry itself
type Validator = (values: {}, elementConfigurations: any) => null | {} | string;
export interface ValidatorRegistry extends SynchronousRegistry<Validator> {}
export interface I18nRegistry extends SynchronousRegistry<string> {
translate: (
id?: string,
fallback?: string,
params?: {},
packageKey?: string,
sourceName?: string,
quantity?: 0,
) => string;
}
/**
* Component Wiring
*
* {@link https://docs.neos.io/cms/manual/extending-the-user-interface/react-extensibility-api#component-wiring}
*/
export type EditorProps<Options = {}, Value = any> = {
/**
* an identifier which can be used for HTML ID generation
* @example
* "__neos__editor__property---{propertyName}"
*/
id?: string;
/** name of the node property to edit */
identifier: string;
/**
* label of the node property
* to be possibly translated via i18n.translate(label)
*
* recommended, when {@link RegisteredEditor.hasOwnLabel} = true is used
*
* @example
* ```jsx
* <Label htmlFor={this.props.id}>
* <I18n id={this.props.label} />
* {this.props.renderHelpIcon()}
* </Label>
* ```
*/
label: string;
/** additional editor options of the `editorOptions` */
options: Options;
/**
* currently edited property value of the node
* is reactive - eg updates on discard and commit
*/
value?: Value;
/**
* @param secondaryInspectorName identifier, used to implement toggling of the inspector when calling this method twice.
* @param secondaryInspectorComponentFactory factory for the secondary inspector content or undefined|null to close the secondary inspector
* @example
* props.renderSecondaryInspector('IMAGE_CROPPING', () => <MySecondaryInspectorContent />)
*/
renderSecondaryInspector(
secondaryInspectorName: string,
secondaryInspectorComponentFactory: () => JSX.Element | undefined | null,
): void;
/**
* register value change of the node property, which can be applied or discarded
*
* @param value the new value.
* @param hooks an object whose keys are saveHooks to be triggered, the values are hook-specific options: Example: `{'Neos.UI:Hook.BeforeSave.CreateImageVariant': nextImage}`
*/
commit(value: Value, hooks?: Record<string, unknown>): void;
/**
* unsets the property
*
* @param value an empty string to unset the property
*/
commit(value: "", hooks?: Record<string, unknown>): void;
// unofficial api
/** name of the editor `Foo.Bar/EditorName` */
editor: string;
/**
* renders toggleable button
*
* see for an examle:
* {@link EditorProps.label}
*/
renderHelpIcon(): JSX.Element | "";
hooks?: Record<string, unknown>;
editorRegistry: EditorRegistry;
i18nRegistry: I18nRegistry;
/** applies any pending changes (as if you clicked the apply button) */
onEnterKey(): void;
helpMessage?: string;
helpThumbnail?: string;
/** the value has pending changes (was changed via commit) */
highlight?: boolean;
/**
* styles an orange or red box-shadow
* around the element the class is applied
* to indicate pending changes or failure on validation errors
*
* @example
* ```css
* box-shadow: 0 0 0 2px /^(red|orange)$/;
* border-radius: 2px;
* ```
*/
className: string;
};
interface RegisteredEditor {
/** Editor component to use */
component: React.ComponentType<any>;
/**
* No label of the property and helpmessage will be rendered above the component.
*
* You need to render the label internally in the component
* @example
* ```jsx
* <Label htmlFor={this.props.id}>
* <I18n id={this.props.label} />
* {this.props.renderHelpIcon()}
* </Label>
* ```
*/
hasOwnLabel?: boolean;
}
interface EditorRegistry extends SynchronousRegistry<RegisteredEditor> {}
interface InspectorRegistry extends SynchronousMetaRegistry<any> {
get: <K extends "editors" | "secondaryEditors">(
key: K,
) => K extends "editors" ? EditorRegistry : K extends "secondaryEditors" ? EditorRegistry : never;
}
type VendorPackageName = string;
type NeosUiOption = string;
type Configuration = unknown;
type FrontendConfigurationRaw = Record<VendorPackageName | NeosUiOption, Configuration>;
export interface FrontendConfigurationRegistry extends SynchronousRegistry<Configuration> {
get: (firstLevelKey: VendorPackageName | NeosUiOption) => Configuration | null;
}
export interface GlobalRegistry extends SynchronousMetaRegistry<any> {
get: <K extends "i18n" | "validators" | "inspector" | "frontendConfiguration">(
key: K,
) => K extends "i18n"
? I18nRegistry
: K extends "validators"
? ValidatorRegistry
: K extends "inspector"
? InspectorRegistry
: K extends "frontendConfiguration"
? FrontendConfigurationRegistry
: never;
}
}
declare module "@neos-project/react-ui-components" {
import enhanceWithClickOutside from "@neos-project/react-ui-components/lib-esm/enhanceWithClickOutside";
import Badge from "@neos-project/react-ui-components/lib-esm/Badge/badge";
import Bar from "@neos-project/react-ui-components/lib-esm/Bar/bar";
import Button from "@neos-project/react-ui-components/lib-esm/Button/button";
import ButtonGroup from "@neos-project/react-ui-components/lib-esm/ButtonGroup/buttonGroup";
import CheckBox from "@neos-project/react-ui-components/lib-esm/CheckBox/checkBox";
import DateInput from "@neos-project/react-ui-components/lib-esm/DateInput/dateInput";
import Dialog from "@neos-project/react-ui-components/lib-esm/Dialog/dialog";
import DropDown from "@neos-project/react-ui-components/lib-esm/DropDown/wrapper";
import Frame from "@neos-project/react-ui-components/lib-esm/Frame/frame";
import Headline from "@neos-project/react-ui-components/lib-esm/Headline/headline";
import Icon from "@neos-project/react-ui-components/lib-esm/Icon/icon";
import IconButton from "@neos-project/react-ui-components/lib-esm/IconButton/iconButton";
import IconButtonDropDown from "@neos-project/react-ui-components/lib-esm/IconButtonDropDown/iconButtonDropDown";
import Label from "@neos-project/react-ui-components/lib-esm/Label/label";
// @ts-expect-error not correctly exported
import Logo from "@neos-project/react-ui-components/lib-esm/Logo";
// @ts-expect-error not correctly exported
import SelectBox from "@neos-project/react-ui-components/lib-esm/SelectBox";
import SideBar from "@neos-project/react-ui-components/lib-esm/SideBar/sideBar";
import Tabs from "@neos-project/react-ui-components/lib-esm/Tabs/tabs";
import TextArea from "@neos-project/react-ui-components/lib-esm/TextArea/textArea";
import TextInput from "@neos-project/react-ui-components/lib-esm/TextInput/textInput";
// @ts-expect-error not correctly exported
import ToggablePanel from "@neos-project/react-ui-components/lib-esm/ToggablePanel";
import Tooltip from "@neos-project/react-ui-components/lib-esm/Tooltip/tooltip";
// @ts-expect-error not correctly exported
import Tree from "@neos-project/react-ui-components/lib-esm/Tree";
// @ts-expect-error not correctly exported
import MultiSelectBox from "@neos-project/react-ui-components/lib-esm/MultiSelectBox";
// @ts-expect-error not correctly exported
import MultiSelectBox_ListPreviewSortable from "@neos-project/react-ui-components/lib-esm/MultiSelectBox_ListPreviewSortable";
// @ts-expect-error not correctly exported
import SelectBox_Option_SingleLine from "@neos-project/react-ui-components/lib-esm/SelectBox_Option_SingleLine";
// @ts-expect-error not correctly exported
import SelectBox_Option_MultiLineWithThumbnail from "@neos-project/react-ui-components/lib-esm/SelectBox_Option_MultiLineWithThumbnail";
module "react" {
// the removed SFC is used, which nearly equals the FC
export type SFC<P = {}> = FC<P>;
}
export {
enhanceWithClickOutside,
Badge,
Bar,
Button,
ButtonGroup,
CheckBox,
DateInput,
Dialog,
DropDown,
Frame,
Headline,
Icon,
IconButton,
IconButtonDropDown,
Label,
Logo,
SelectBox,
SideBar,
Tabs,
TextArea,
TextInput,
ToggablePanel,
Tooltip,
Tree,
MultiSelectBox,
MultiSelectBox_ListPreviewSortable,
SelectBox_Option_SingleLine,
SelectBox_Option_MultiLineWithThumbnail,
};
}