@rebasepro/types 0.0.1-canary.0 → 0.0.1-canary.0e2f892
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/README.md +1 -1
- package/dist/controllers/analytics_controller.d.ts +2 -2
- package/dist/controllers/auth.d.ts +52 -6
- package/dist/controllers/client.d.ts +170 -0
- package/dist/controllers/collection_registry.d.ts +45 -0
- package/dist/controllers/customization_controller.d.ts +11 -1
- package/dist/controllers/data.d.ts +168 -0
- package/dist/controllers/data_driver.d.ts +160 -0
- package/dist/controllers/database_admin.d.ts +11 -0
- package/dist/controllers/effective_role.d.ts +4 -0
- package/dist/controllers/email.d.ts +34 -0
- package/dist/controllers/index.d.ts +12 -5
- package/dist/controllers/local_config_persistence.d.ts +4 -4
- package/dist/controllers/navigation.d.ts +12 -61
- package/dist/controllers/registry.d.ts +54 -0
- package/dist/controllers/side_entity_controller.d.ts +7 -7
- package/dist/controllers/storage.d.ts +24 -26
- package/dist/index.d.ts +0 -1
- package/dist/index.es.js +119 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +118 -13
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +40 -26
- package/dist/types/backend.d.ts +300 -18
- package/dist/types/builders.d.ts +15 -0
- package/dist/types/chips.d.ts +1 -1
- package/dist/types/collections.d.ts +324 -355
- package/dist/types/cron.d.ts +102 -0
- package/dist/types/data_source.d.ts +64 -0
- package/dist/types/entities.d.ts +29 -24
- package/dist/types/entity_actions.d.ts +12 -12
- package/dist/types/entity_callbacks.d.ts +12 -12
- package/dist/types/entity_link_builder.d.ts +1 -1
- package/dist/types/entity_overrides.d.ts +7 -2
- package/dist/types/entity_views.d.ts +61 -0
- package/dist/types/export_import.d.ts +3 -3
- package/dist/types/index.d.ts +9 -5
- package/dist/types/plugins.d.ts +228 -225
- package/dist/types/properties.d.ts +135 -62
- package/dist/types/property_config.d.ts +13 -11
- package/dist/types/relations.d.ts +1 -1
- package/dist/types/slots.d.ts +252 -0
- package/dist/types/translations.d.ts +870 -0
- package/dist/types/user_management_delegate.d.ts +43 -0
- package/dist/types/websockets.d.ts +45 -0
- package/dist/users/user.d.ts +4 -0
- package/package.json +99 -131
- package/src/controllers/analytics_controller.tsx +2 -2
- package/src/controllers/auth.tsx +55 -6
- package/src/controllers/client.ts +133 -0
- package/src/controllers/collection_registry.ts +57 -0
- package/src/controllers/customization_controller.tsx +12 -1
- package/src/controllers/data.ts +191 -0
- package/src/controllers/{datasource.ts → data_driver.ts} +50 -61
- package/src/controllers/database_admin.ts +22 -0
- package/src/controllers/effective_role.ts +4 -0
- package/src/controllers/email.ts +36 -0
- package/src/controllers/index.ts +15 -5
- package/src/controllers/local_config_persistence.tsx +4 -4
- package/src/controllers/navigation.ts +13 -76
- package/src/controllers/registry.ts +65 -0
- package/src/controllers/side_entity_controller.tsx +7 -7
- package/src/controllers/storage.ts +25 -28
- package/src/index.ts +0 -1
- package/src/rebase_context.tsx +41 -39
- package/src/types/backend.ts +359 -24
- package/src/types/builders.ts +17 -0
- package/src/types/chips.ts +15 -40
- package/src/types/collections.ts +375 -383
- package/src/types/cron.ts +149 -0
- package/src/types/data_source.ts +145 -0
- package/src/types/entities.ts +40 -33
- package/src/types/entity_actions.tsx +11 -11
- package/src/types/entity_callbacks.ts +12 -12
- package/src/types/entity_link_builder.ts +1 -1
- package/src/types/entity_overrides.tsx +7 -2
- package/src/types/entity_views.tsx +77 -0
- package/src/types/export_import.ts +3 -3
- package/src/types/index.ts +10 -5
- package/src/types/plugins.tsx +280 -261
- package/src/types/properties.ts +163 -61
- package/src/types/property_config.tsx +11 -11
- package/src/types/relations.ts +1 -1
- package/src/types/slots.tsx +297 -0
- package/src/types/translations.ts +977 -0
- package/src/types/user_management_delegate.ts +50 -7
- package/src/types/websockets.ts +48 -0
- package/src/users/roles.ts +0 -1
- package/src/users/user.ts +5 -0
- package/dist/components/EntityFormActionsProps.d.ts +0 -17
- package/dist/components/EntityFormProps.d.ts +0 -46
- package/dist/components/PropertyPreviewProps.d.ts +0 -50
- package/dist/components/formex.d.ts +0 -40
- package/dist/components/index.d.ts +0 -3
- package/dist/controllers/datasource.d.ts +0 -179
- package/dist/types/fields.d.ts +0 -221
- package/dist/types/rebase.d.ts +0 -180
- package/src/components/EntityFormActionsProps.tsx +0 -18
- package/src/components/EntityFormProps.tsx +0 -52
- package/src/components/PropertyPreviewProps.tsx +0 -61
- package/src/components/formex.tsx +0 -46
- package/src/components/index.ts +0 -3
- package/src/types/fields.tsx +0 -298
- package/src/types/rebase.tsx +0 -211
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { FilterValues } from "./collections";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { EntityAfterReadProps, EntityBeforeSaveProps } from "./entity_callbacks";
|
|
10
|
-
import { User } from "../users";
|
|
2
|
+
import type { EntityReference, EntityRelation, EntityValues, GeoPoint, Entity } from "./entities";
|
|
3
|
+
import type { Relation, JoinStep, OnAction } from "./relations";
|
|
4
|
+
import type { EntityCollection, FilterValues } from "./collections";
|
|
5
|
+
import type { ColorKey, ColorScheme } from "./chips";
|
|
6
|
+
import type { AuthController } from "../controllers/auth";
|
|
7
|
+
import type { EntityAfterReadProps, EntityBeforeSaveProps } from "./entity_callbacks";
|
|
8
|
+
import type { User } from "../users";
|
|
11
9
|
/**
|
|
12
10
|
* Callbacks/Hooks for individual property fields
|
|
13
11
|
* @group Entity properties
|
|
14
12
|
*/
|
|
15
|
-
export type PropertyCallbacks<T =
|
|
13
|
+
export type PropertyCallbacks<T = unknown, M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = {
|
|
16
14
|
/**
|
|
17
15
|
* Callback used after fetching data, to transform the value before rendering
|
|
18
16
|
*/
|
|
19
|
-
afterRead?(props: Omit<EntityAfterReadProps<M, USER>,
|
|
17
|
+
afterRead?(props: Omit<EntityAfterReadProps<M, USER>, "entity"> & {
|
|
20
18
|
value: T;
|
|
21
19
|
entity: Entity<M> | undefined;
|
|
22
20
|
}): Promise<T> | T;
|
|
@@ -24,7 +22,7 @@ export type PropertyCallbacks<T = any, M extends Record<string, any> = any, USER
|
|
|
24
22
|
* Callback used before saving, after validation.
|
|
25
23
|
* You can modify the value before it's saved.
|
|
26
24
|
*/
|
|
27
|
-
beforeSave?(props: Omit<EntityBeforeSaveProps<M, USER>,
|
|
25
|
+
beforeSave?(props: Omit<EntityBeforeSaveProps<M, USER>, "values"> & {
|
|
28
26
|
value: T;
|
|
29
27
|
previousValue: T | undefined;
|
|
30
28
|
values: Partial<M>;
|
|
@@ -42,37 +40,56 @@ export type Properties = {
|
|
|
42
40
|
* A helper type to infer the underlying data type from a Property definition.
|
|
43
41
|
* This is the core of the type inference system.
|
|
44
42
|
*/
|
|
45
|
-
export type InferPropertyType<P extends Property> = P extends StringProperty ? string : P extends NumberProperty ? number : P extends BooleanProperty ? boolean : P extends DateProperty ? Date : P extends GeopointProperty ? GeoPoint : P extends ReferenceProperty ? EntityReference : P extends RelationProperty ? EntityRelation | EntityRelation[] : P extends ArrayProperty ? (P["of"] extends Property ? InferPropertyType<P["of"]>[] :
|
|
43
|
+
export type InferPropertyType<P extends Property> = P extends StringProperty ? string : P extends NumberProperty ? number : P extends BooleanProperty ? boolean : P extends DateProperty ? Date : P extends GeopointProperty ? GeoPoint : P extends ReferenceProperty ? EntityReference : P extends RelationProperty ? EntityRelation | EntityRelation[] : P extends ArrayProperty ? (P["of"] extends Property ? InferPropertyType<P["of"]>[] : unknown[]) : P extends MapProperty ? (P["properties"] extends Properties ? InferEntityType<P["properties"]> : Record<string, unknown>) : never;
|
|
44
|
+
/**
|
|
45
|
+
* Helper type that determines whether a property is required.
|
|
46
|
+
* Uses direct structural matching against `{ validation: { required: true } }`
|
|
47
|
+
* (without the optional marker on `validation`), which correctly narrows
|
|
48
|
+
* literal `true` while treating widened `boolean` as not-required.
|
|
49
|
+
*/
|
|
50
|
+
type IsRequired<P extends Property> = P extends {
|
|
51
|
+
validation: {
|
|
52
|
+
required: true;
|
|
53
|
+
};
|
|
54
|
+
} ? true : false;
|
|
55
|
+
/**
|
|
56
|
+
* Extract keys from Properties where the property is required.
|
|
57
|
+
*/
|
|
58
|
+
type RequiredPropertyKeys<P extends Properties> = {
|
|
59
|
+
[K in keyof P]: IsRequired<P[K]> extends true ? K : never;
|
|
60
|
+
}[keyof P];
|
|
61
|
+
/**
|
|
62
|
+
* Extract keys from Properties where the property is optional.
|
|
63
|
+
*/
|
|
64
|
+
type OptionalPropertyKeys<P extends Properties> = {
|
|
65
|
+
[K in keyof P]: IsRequired<P[K]> extends true ? never : K;
|
|
66
|
+
}[keyof P];
|
|
46
67
|
/**
|
|
47
68
|
* A generic type that converts a `Properties` schema definition into a corresponding
|
|
48
69
|
* TypeScript entity type. It correctly handles required and optional properties.
|
|
49
70
|
*
|
|
71
|
+
* A property is considered required when it has `validation: { required: true }`.
|
|
72
|
+
* The `true` must be a literal type — if `required` is typed as `boolean`,
|
|
73
|
+
* the property will be treated as optional (use `as const` for literal inference).
|
|
74
|
+
*
|
|
50
75
|
* @example
|
|
51
76
|
* const productSchema = {
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* };
|
|
77
|
+
* name: { type: 'string', validation: { required: true } },
|
|
78
|
+
* price: { type: 'number' }
|
|
79
|
+
* } as const satisfies Properties;
|
|
55
80
|
* type Product = InferEntityType<typeof productSchema>;
|
|
56
81
|
* // Result: { name: string; price?: number; }
|
|
57
82
|
*/
|
|
58
83
|
export type InferEntityType<P extends Properties> = {
|
|
59
|
-
-readonly [K in
|
|
60
|
-
validation?: {
|
|
61
|
-
required: true;
|
|
62
|
-
};
|
|
63
|
-
} ? K : never]: InferPropertyType<P[K]>;
|
|
84
|
+
-readonly [K in RequiredPropertyKeys<P>]: InferPropertyType<P[K]>;
|
|
64
85
|
} & {
|
|
65
|
-
-readonly [K in
|
|
66
|
-
validation?: {
|
|
67
|
-
required: true;
|
|
68
|
-
};
|
|
69
|
-
} ? never : K]?: InferPropertyType<P[K]>;
|
|
86
|
+
-readonly [K in OptionalPropertyKeys<P>]?: InferPropertyType<P[K]>;
|
|
70
87
|
};
|
|
71
88
|
/**
|
|
72
89
|
* Interface including all common properties of a CMS property.
|
|
73
90
|
* @group Entity properties
|
|
74
91
|
*/
|
|
75
|
-
export interface BaseProperty<CustomProps =
|
|
92
|
+
export interface BaseProperty<CustomProps = unknown> {
|
|
76
93
|
/**
|
|
77
94
|
* Property name (e.g. Product)
|
|
78
95
|
*/
|
|
@@ -128,20 +145,6 @@ export interface BaseProperty<CustomProps = any> {
|
|
|
128
145
|
* or in `preview`.
|
|
129
146
|
*/
|
|
130
147
|
customProps?: CustomProps;
|
|
131
|
-
/**
|
|
132
|
-
* If you need to render a custom field, you can create a component that
|
|
133
|
-
* takes `FieldProps` as props. You receive the value, a function to
|
|
134
|
-
* update the value and additional utility props such as if there is an error.
|
|
135
|
-
* You can customize it by passing custom props that are received
|
|
136
|
-
* in the component.
|
|
137
|
-
*/
|
|
138
|
-
Field?: React.ComponentType<FieldProps<any, CustomProps>>;
|
|
139
|
-
/**
|
|
140
|
-
* Configure how a property is displayed as a preview, e.g. in the collection
|
|
141
|
-
* view. You can customize it by passing custom props that are received
|
|
142
|
-
* in the component.
|
|
143
|
-
*/
|
|
144
|
-
Preview?: React.ComponentType<PropertyPreviewProps<any, CustomProps>>;
|
|
145
148
|
/**
|
|
146
149
|
* Use this to define dynamic properties that change based on certain conditions
|
|
147
150
|
* or on the entity's values. For example, you can make a field read-only if
|
|
@@ -165,6 +168,16 @@ export interface BaseProperty<CustomProps = any> {
|
|
|
165
168
|
* Callbacks/Hooks for this property field to transform and sanitize data during its lifecycle.
|
|
166
169
|
*/
|
|
167
170
|
callbacks?: PropertyCallbacks;
|
|
171
|
+
/**
|
|
172
|
+
* Custom field component to render this property in forms.
|
|
173
|
+
* Used by the CMS layer.
|
|
174
|
+
*/
|
|
175
|
+
Field?: React.ComponentType<any>;
|
|
176
|
+
/**
|
|
177
|
+
* Custom preview component to render this property in previews/tables.
|
|
178
|
+
* Used by the CMS layer.
|
|
179
|
+
*/
|
|
180
|
+
Preview?: React.ComponentType<any>;
|
|
168
181
|
}
|
|
169
182
|
/**
|
|
170
183
|
* @group Entity properties
|
|
@@ -402,14 +415,79 @@ export interface RelationProperty extends BaseProperty {
|
|
|
402
415
|
*/
|
|
403
416
|
isId?: boolean;
|
|
404
417
|
/**
|
|
405
|
-
* The
|
|
406
|
-
*
|
|
407
|
-
*
|
|
418
|
+
* The target collection this relation points to.
|
|
419
|
+
* When set, the framework treats this property as a self-contained relation
|
|
420
|
+
* definition and no separate `relations[]` entry is needed.
|
|
408
421
|
*/
|
|
409
|
-
|
|
422
|
+
target?: () => EntityCollection;
|
|
410
423
|
/**
|
|
411
|
-
*
|
|
412
|
-
*
|
|
424
|
+
* Whether this property references one or many records.
|
|
425
|
+
* Defaults to `"one"`.
|
|
426
|
+
*/
|
|
427
|
+
cardinality?: "one" | "many";
|
|
428
|
+
/**
|
|
429
|
+
* Which side owns the persistence for this relationship.
|
|
430
|
+
* - `"owning"`: The foreign key (for one-to-one) or junction table (for many-to-many) is on this collection.
|
|
431
|
+
* - `"inverse"`: The foreign key is on the target collection's table.
|
|
432
|
+
* Defaults to `"owning"`.
|
|
433
|
+
*/
|
|
434
|
+
direction?: "owning" | "inverse";
|
|
435
|
+
/**
|
|
436
|
+
* The name of the corresponding relation on the target collection.
|
|
437
|
+
* Used for inverse relations to locate the owning side.
|
|
438
|
+
*/
|
|
439
|
+
inverseRelationName?: string;
|
|
440
|
+
/**
|
|
441
|
+
* Column on THIS table that stores the foreign key to the target.
|
|
442
|
+
* Required when `direction` is `"owning"` and `cardinality` is `"one"`.
|
|
443
|
+
* Auto-inferred if not set.
|
|
444
|
+
* @example "author_id"
|
|
445
|
+
*/
|
|
446
|
+
localKey?: string;
|
|
447
|
+
/**
|
|
448
|
+
* Column on the TARGET table that stores the foreign key back to this entity.
|
|
449
|
+
* Required when `direction` is `"inverse"`.
|
|
450
|
+
* Auto-inferred if not set.
|
|
451
|
+
* @example "post_id"
|
|
452
|
+
*/
|
|
453
|
+
foreignKeyOnTarget?: string;
|
|
454
|
+
/**
|
|
455
|
+
* Junction table configuration for many-to-many relationships.
|
|
456
|
+
* Required when `cardinality` is `"many"` and `direction` is `"owning"`.
|
|
457
|
+
* Auto-inferred if not set.
|
|
458
|
+
*/
|
|
459
|
+
through?: {
|
|
460
|
+
table: string;
|
|
461
|
+
sourceColumn: string;
|
|
462
|
+
targetColumn: string;
|
|
463
|
+
};
|
|
464
|
+
/**
|
|
465
|
+
* Explicit, ordered join path for advanced multi-hop relations.
|
|
466
|
+
* When set, overrides `localKey`, `foreignKeyOnTarget`, and `through`.
|
|
467
|
+
*/
|
|
468
|
+
joinPath?: JoinStep[];
|
|
469
|
+
/**
|
|
470
|
+
* Cascade action on update.
|
|
471
|
+
*/
|
|
472
|
+
onUpdate?: OnAction;
|
|
473
|
+
/**
|
|
474
|
+
* Cascade action on delete.
|
|
475
|
+
*/
|
|
476
|
+
onDelete?: OnAction;
|
|
477
|
+
/**
|
|
478
|
+
* Overrides applied to the target collection when rendered as a subcollection tab.
|
|
479
|
+
*/
|
|
480
|
+
overrides?: Partial<EntityCollection>;
|
|
481
|
+
/**
|
|
482
|
+
* Optional name for this relation. Defaults to the property key at runtime.
|
|
483
|
+
* Only needed when the relation name should differ from the property key,
|
|
484
|
+
* or for backward compatibility with existing `relations[]` entries.
|
|
485
|
+
*/
|
|
486
|
+
relationName?: string;
|
|
487
|
+
/**
|
|
488
|
+
* The resolved relation object, populated by the framework at normalization time.
|
|
489
|
+
* **Do not set manually** — it is computed from the inline fields above
|
|
490
|
+
* or looked up from the collection's `relations[]` array.
|
|
413
491
|
*/
|
|
414
492
|
relation?: Relation;
|
|
415
493
|
/**
|
|
@@ -452,7 +530,7 @@ export interface ArrayProperty extends BaseProperty {
|
|
|
452
530
|
* You can leave this field empty only if you are providing a custom field,
|
|
453
531
|
* or using the `oneOf` prop, otherwise an error will be thrown.
|
|
454
532
|
*/
|
|
455
|
-
of?: Property;
|
|
533
|
+
of?: Property | Property[];
|
|
456
534
|
/**
|
|
457
535
|
* Use this field if you would like to have an array of typed objects.
|
|
458
536
|
* It is useful if you need to have values of different types in the same
|
|
@@ -575,7 +653,7 @@ export interface MapProperty extends BaseProperty {
|
|
|
575
653
|
/**
|
|
576
654
|
* @group Entity properties
|
|
577
655
|
*/
|
|
578
|
-
export type PropertyBuilderProps<M extends Record<string,
|
|
656
|
+
export type PropertyBuilderProps<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
579
657
|
values: Partial<M>;
|
|
580
658
|
previousValues?: Partial<M>;
|
|
581
659
|
propertyValue?: unknown;
|
|
@@ -609,7 +687,7 @@ export interface PropertyDisabledConfig {
|
|
|
609
687
|
/**
|
|
610
688
|
* We use this type to define mapping between string or number values in
|
|
611
689
|
* the data source to a label (such in a select dropdown).
|
|
612
|
-
* The key in this Record is the value saved in the
|
|
690
|
+
* The key in this Record is the value saved in the driver, and the value in
|
|
613
691
|
* this record is the label displayed in the UI.
|
|
614
692
|
* You can add additional customization by assigning a {@link EnumValueConfig} for the
|
|
615
693
|
* label instead of a simple string (for enabling or disabling options and
|
|
@@ -726,12 +804,6 @@ export type StorageConfig = {
|
|
|
726
804
|
* accepts any image file, and so on.
|
|
727
805
|
*/
|
|
728
806
|
acceptedFiles?: FileType[];
|
|
729
|
-
/**
|
|
730
|
-
* Use client side image compression and resizing
|
|
731
|
-
* Will only be applied to these MIME types: image/jpeg, image/png and image/webp
|
|
732
|
-
* @deprecated Use `imageResize` instead
|
|
733
|
-
*/
|
|
734
|
-
imageCompression?: ImageResize;
|
|
735
807
|
/**
|
|
736
808
|
* Advanced image resizing and cropping configuration.
|
|
737
809
|
* Applied before upload to optimize storage and bandwidth.
|
|
@@ -777,14 +849,14 @@ export type StorageConfig = {
|
|
|
777
849
|
* When set to true, this flag indicates that the bucket name will be
|
|
778
850
|
* included in the saved storage path.
|
|
779
851
|
*
|
|
780
|
-
* E.g. `
|
|
852
|
+
* E.g. `s3://my-bucket/path/to/file.png` instead of just `path/to/file.png`
|
|
781
853
|
*
|
|
782
854
|
* Defaults to false.
|
|
783
855
|
*/
|
|
784
856
|
includeBucketUrl?: boolean;
|
|
785
857
|
/**
|
|
786
858
|
* When set to true, this flag indicates that the download URL of the file
|
|
787
|
-
* will be saved in the
|
|
859
|
+
* will be saved in the driver, instead of the storage path.
|
|
788
860
|
*
|
|
789
861
|
* Note that the generated URL may use a token that, if disabled, may
|
|
790
862
|
* make the URL unusable and lose the original reference to Cloud Storage,
|
|
@@ -872,7 +944,7 @@ export interface ImageResize {
|
|
|
872
944
|
* - `contain`: Scale down to fit within bounds, preserving aspect ratio (default)
|
|
873
945
|
* - `cover`: Scale to fill bounds, preserving aspect ratio (may crop)
|
|
874
946
|
*/
|
|
875
|
-
mode?:
|
|
947
|
+
mode?: "contain" | "cover";
|
|
876
948
|
/**
|
|
877
949
|
* Output format for the resized image.
|
|
878
950
|
* - `original`: Keep the original format (default)
|
|
@@ -880,7 +952,7 @@ export interface ImageResize {
|
|
|
880
952
|
* - `png`: Convert to PNG
|
|
881
953
|
* - `webp`: Convert to WebP
|
|
882
954
|
*/
|
|
883
|
-
format?:
|
|
955
|
+
format?: "original" | "jpeg" | "png" | "webp";
|
|
884
956
|
/**
|
|
885
957
|
* Quality for lossy formats (JPEG, WebP). Number between 0 and 100.
|
|
886
958
|
* Higher is better quality but larger file size. Defaults to 80.
|
|
@@ -1060,11 +1132,11 @@ export interface ConditionContext {
|
|
|
1060
1132
|
* Current form/entity values.
|
|
1061
1133
|
* Date values are converted to Unix timestamps (milliseconds).
|
|
1062
1134
|
*/
|
|
1063
|
-
values: Record<string,
|
|
1135
|
+
values: Record<string, unknown>;
|
|
1064
1136
|
/**
|
|
1065
1137
|
* Previous values before the current edit session.
|
|
1066
1138
|
*/
|
|
1067
|
-
previousValues: Record<string,
|
|
1139
|
+
previousValues: Record<string, unknown>;
|
|
1068
1140
|
/**
|
|
1069
1141
|
* Current value of this property specifically.
|
|
1070
1142
|
*/
|
|
@@ -1101,3 +1173,4 @@ export interface ConditionContext {
|
|
|
1101
1173
|
*/
|
|
1102
1174
|
now: number;
|
|
1103
1175
|
}
|
|
1176
|
+
export {};
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { ArrayProperty, MapProperty } from "./properties";
|
|
3
|
-
import {
|
|
2
|
+
import { ArrayProperty, MapProperty, StringProperty, NumberProperty, BooleanProperty, DateProperty, GeopointProperty, ReferenceProperty, RelationProperty } from "./properties";
|
|
3
|
+
import { BaseProperty } from "./properties";
|
|
4
|
+
type CMSBasePropertyNoName = Omit<BaseProperty, "name">;
|
|
4
5
|
export type ConfigProperty = (Omit<StringProperty, "name"> & {
|
|
5
6
|
name?: string;
|
|
6
|
-
}) | (Omit<NumberProperty, "name"> & {
|
|
7
|
+
} & CMSBasePropertyNoName) | (Omit<NumberProperty, "name"> & {
|
|
7
8
|
name?: string;
|
|
8
|
-
}) | (Omit<BooleanProperty, "name"> & {
|
|
9
|
+
} & CMSBasePropertyNoName) | (Omit<BooleanProperty, "name"> & {
|
|
9
10
|
name?: string;
|
|
10
|
-
}) | (Omit<DateProperty, "name"> & {
|
|
11
|
+
} & CMSBasePropertyNoName) | (Omit<DateProperty, "name"> & {
|
|
11
12
|
name?: string;
|
|
12
|
-
}) | (Omit<GeopointProperty, "name"> & {
|
|
13
|
+
} & CMSBasePropertyNoName) | (Omit<GeopointProperty, "name"> & {
|
|
13
14
|
name?: string;
|
|
14
|
-
}) | (Omit<ReferenceProperty, "name"> & {
|
|
15
|
+
} & CMSBasePropertyNoName) | (Omit<ReferenceProperty, "name"> & {
|
|
15
16
|
name?: string;
|
|
16
|
-
}) | (Omit<RelationProperty, "name"> & {
|
|
17
|
+
} & CMSBasePropertyNoName) | (Omit<RelationProperty, "name"> & {
|
|
17
18
|
name?: string;
|
|
18
|
-
}) | (Omit<ArrayProperty, "name" | "of" | "oneOf"> & {
|
|
19
|
+
} & CMSBasePropertyNoName) | (Omit<ArrayProperty, "name" | "of" | "oneOf"> & {
|
|
19
20
|
name?: string;
|
|
20
21
|
of?: ConfigProperty | ConfigProperty[];
|
|
21
22
|
oneOf?: {
|
|
@@ -24,10 +25,10 @@ export type ConfigProperty = (Omit<StringProperty, "name"> & {
|
|
|
24
25
|
valueField?: string;
|
|
25
26
|
propertiesOrder?: string[];
|
|
26
27
|
};
|
|
27
|
-
}) | (Omit<MapProperty, "name" | "properties"> & {
|
|
28
|
+
} & CMSBasePropertyNoName) | (Omit<MapProperty, "name" | "properties"> & {
|
|
28
29
|
name?: string;
|
|
29
30
|
properties?: Record<string, ConfigProperty>;
|
|
30
|
-
});
|
|
31
|
+
} & CMSBasePropertyNoName);
|
|
31
32
|
/**
|
|
32
33
|
* This is the configuration object for a property.
|
|
33
34
|
* These configs are generated by default for the properties defined in your
|
|
@@ -66,3 +67,4 @@ export type PropertyConfig = {
|
|
|
66
67
|
description?: string;
|
|
67
68
|
};
|
|
68
69
|
export type PropertyConfigId = "text_field" | "multiline" | "markdown" | "url" | "email" | "user_select" | "select" | "multi_select" | "number_input" | "number_select" | "multi_number_select" | "file_upload" | "multi_file_upload" | "group" | "key_value" | "reference" | "reference_as_string" | "multi_references" | "relation" | "switch" | "date_time" | "repeat" | "custom_array" | "block";
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { CollectionActionsProps, EntityTableController, SelectionController, EntityCollection } from "./collections";
|
|
3
|
+
import type { Entity } from "./entities";
|
|
4
|
+
import type { PluginFormActionProps, PluginGenericProps, PluginHomePageActionsProps, PluginHomePageAdditionalCardsProps } from "./plugins";
|
|
5
|
+
import type { Property } from "./properties";
|
|
6
|
+
import type { RebaseContext } from "../rebase_context";
|
|
7
|
+
/**
|
|
8
|
+
* Registry mapping slot names to their component prop types.
|
|
9
|
+
* Each key represents a UI extension point in the CMS.
|
|
10
|
+
* @group Plugins
|
|
11
|
+
*/
|
|
12
|
+
export interface SlotRegistry {
|
|
13
|
+
"home.actions": PluginGenericProps;
|
|
14
|
+
"home.cards": PluginHomePageAdditionalCardsProps;
|
|
15
|
+
"home.children.start": PluginGenericProps;
|
|
16
|
+
"home.children.end": PluginGenericProps;
|
|
17
|
+
/** Compact insight widget rendered inline in a home page collection card. */
|
|
18
|
+
"home.card.insight": HomeCardInsightSlotProps;
|
|
19
|
+
"home.collection.actions": PluginHomePageActionsProps;
|
|
20
|
+
/** Rendered below the logo in the sidebar drawer. */
|
|
21
|
+
"navigation.header": NavigationSlotProps;
|
|
22
|
+
/** Rendered above the collapse toggle at the bottom of the drawer. */
|
|
23
|
+
"navigation.footer": NavigationSlotProps;
|
|
24
|
+
"collection.actions": CollectionActionsProps;
|
|
25
|
+
"collection.actions.start": CollectionActionsProps;
|
|
26
|
+
"collection.header.action": CollectionHeaderActionProps;
|
|
27
|
+
"collection.add-column": CollectionAddColumnProps;
|
|
28
|
+
"collection.error": CollectionErrorProps;
|
|
29
|
+
/** Extra widgets rendered inside the collection toolbar row. */
|
|
30
|
+
"collection.toolbar": CollectionToolbarProps;
|
|
31
|
+
/** Custom empty-state component when a collection has no data. */
|
|
32
|
+
"collection.empty-state": CollectionEmptyStateProps;
|
|
33
|
+
/** Insight widgets rendered above the collection table. */
|
|
34
|
+
"collection.insights": CollectionInsightsSlotProps;
|
|
35
|
+
"form.actions": PluginFormActionProps;
|
|
36
|
+
"form.actions.top": PluginFormActionProps;
|
|
37
|
+
/** Rendered before the form title / field list. */
|
|
38
|
+
"form.before": PluginFormActionProps;
|
|
39
|
+
/** Rendered after the form field list. */
|
|
40
|
+
"form.after": PluginFormActionProps;
|
|
41
|
+
/** Per-row actions in entity tables (e.g. bulk actions, row context menus). */
|
|
42
|
+
"entity.row.actions": EntityRowActionsProps;
|
|
43
|
+
/** Inject UI before an individual form field. */
|
|
44
|
+
"entity.field.before": EntityFieldSlotProps;
|
|
45
|
+
/** Inject UI after an individual form field. */
|
|
46
|
+
"entity.field.after": EntityFieldSlotProps;
|
|
47
|
+
/** Custom filter sidebar for a collection. */
|
|
48
|
+
"collection.filter-panel": CollectionFilterPanelProps;
|
|
49
|
+
/** Widget rendered on the dashboard / home page. */
|
|
50
|
+
"dashboard.widget": DashboardWidgetProps;
|
|
51
|
+
/** Cross-collection search bar component. */
|
|
52
|
+
"global.search": GlobalSearchProps;
|
|
53
|
+
/** Top-level toolbar actions rendered in the shell toolbar area. */
|
|
54
|
+
"shell.toolbar": ShellToolbarProps;
|
|
55
|
+
"kanban.setup": KanbanSetupProps;
|
|
56
|
+
"kanban.add-column": KanbanAddColumnProps;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Valid slot names for UI extension points.
|
|
60
|
+
* @group Plugins
|
|
61
|
+
*/
|
|
62
|
+
export type SlotName = keyof SlotRegistry;
|
|
63
|
+
/**
|
|
64
|
+
* A single UI component contribution to a named slot.
|
|
65
|
+
* @group Plugins
|
|
66
|
+
*/
|
|
67
|
+
export interface SlotContribution<K extends SlotName = SlotName> {
|
|
68
|
+
/**
|
|
69
|
+
* Which slot to contribute to.
|
|
70
|
+
*/
|
|
71
|
+
slot: K;
|
|
72
|
+
/**
|
|
73
|
+
* The component to render in the slot.
|
|
74
|
+
* Typed loosely so mixed-slot arrays work.
|
|
75
|
+
* Type safety is provided at the `useSlot` call site.
|
|
76
|
+
*/
|
|
77
|
+
Component: React.ComponentType<any>;
|
|
78
|
+
/**
|
|
79
|
+
* Additional props to merge into the slot props before rendering.
|
|
80
|
+
*/
|
|
81
|
+
props?: Record<string, unknown>;
|
|
82
|
+
/**
|
|
83
|
+
* Ordering hint. Lower values render first. Defaults to 50.
|
|
84
|
+
*/
|
|
85
|
+
order?: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Props for `navigation.header` and `navigation.footer` slots.
|
|
89
|
+
* @group Plugins
|
|
90
|
+
*/
|
|
91
|
+
export interface NavigationSlotProps {
|
|
92
|
+
drawerOpen: boolean;
|
|
93
|
+
drawerHovered: boolean;
|
|
94
|
+
context: RebaseContext;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Props for the `collection.toolbar` slot.
|
|
98
|
+
* @group Plugins
|
|
99
|
+
*/
|
|
100
|
+
export interface CollectionToolbarProps {
|
|
101
|
+
path: string;
|
|
102
|
+
collection: EntityCollection;
|
|
103
|
+
parentCollectionIds: string[];
|
|
104
|
+
tableController: EntityTableController;
|
|
105
|
+
selectionController: SelectionController;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Props for the `collection.empty-state` slot.
|
|
109
|
+
* @group Plugins
|
|
110
|
+
*/
|
|
111
|
+
export interface CollectionEmptyStateProps {
|
|
112
|
+
path: string;
|
|
113
|
+
collection: EntityCollection;
|
|
114
|
+
parentCollectionIds: string[];
|
|
115
|
+
canCreate: boolean;
|
|
116
|
+
onNewClick?: () => void;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Props for the `collection.header.action` slot.
|
|
120
|
+
* @group Plugins
|
|
121
|
+
*/
|
|
122
|
+
export interface CollectionHeaderActionProps {
|
|
123
|
+
property: Property;
|
|
124
|
+
propertyKey: string;
|
|
125
|
+
path: string;
|
|
126
|
+
parentCollectionIds: string[];
|
|
127
|
+
onHover: boolean;
|
|
128
|
+
collection: EntityCollection;
|
|
129
|
+
tableController: EntityTableController;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Props for the `collection.add-column` slot.
|
|
133
|
+
* @group Plugins
|
|
134
|
+
*/
|
|
135
|
+
export interface CollectionAddColumnProps {
|
|
136
|
+
path: string;
|
|
137
|
+
parentCollectionIds: string[];
|
|
138
|
+
collection: EntityCollection;
|
|
139
|
+
tableController: EntityTableController;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Props for the `collection.error` slot.
|
|
143
|
+
* @group Plugins
|
|
144
|
+
*/
|
|
145
|
+
export interface CollectionErrorProps {
|
|
146
|
+
path: string;
|
|
147
|
+
collection: EntityCollection;
|
|
148
|
+
parentCollectionIds?: string[];
|
|
149
|
+
error: Error;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Props for the `kanban.setup` slot.
|
|
153
|
+
* @group Plugins
|
|
154
|
+
*/
|
|
155
|
+
export interface KanbanSetupProps {
|
|
156
|
+
collection: EntityCollection;
|
|
157
|
+
fullPath: string;
|
|
158
|
+
parentCollectionIds: string[];
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Props for the `kanban.add-column` slot.
|
|
162
|
+
* @group Plugins
|
|
163
|
+
*/
|
|
164
|
+
export interface KanbanAddColumnProps {
|
|
165
|
+
collection: EntityCollection;
|
|
166
|
+
fullPath: string;
|
|
167
|
+
parentCollectionIds: string[];
|
|
168
|
+
columnProperty: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Props for `entity.row.actions` slot.
|
|
172
|
+
* Rendered for each row in an entity collection table.
|
|
173
|
+
* @group Plugins
|
|
174
|
+
*/
|
|
175
|
+
export interface EntityRowActionsProps {
|
|
176
|
+
entity: Entity;
|
|
177
|
+
entityId: string;
|
|
178
|
+
path: string;
|
|
179
|
+
collection: EntityCollection;
|
|
180
|
+
parentCollectionIds: string[];
|
|
181
|
+
selectionController: SelectionController;
|
|
182
|
+
context: RebaseContext;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Props for `entity.field.before` and `entity.field.after` slots.
|
|
186
|
+
* Rendered around individual form fields in the entity edit view.
|
|
187
|
+
* @group Plugins
|
|
188
|
+
*/
|
|
189
|
+
export interface EntityFieldSlotProps {
|
|
190
|
+
propertyKey: string;
|
|
191
|
+
property: Property;
|
|
192
|
+
path: string;
|
|
193
|
+
entityId?: string | number;
|
|
194
|
+
collection: EntityCollection;
|
|
195
|
+
context: RebaseContext;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Props for `collection.filter-panel` slot.
|
|
199
|
+
* Custom filter sidebar rendered alongside the collection table.
|
|
200
|
+
* @group Plugins
|
|
201
|
+
*/
|
|
202
|
+
export interface CollectionFilterPanelProps {
|
|
203
|
+
path: string;
|
|
204
|
+
collection: EntityCollection;
|
|
205
|
+
parentCollectionIds: string[];
|
|
206
|
+
tableController: EntityTableController;
|
|
207
|
+
context: RebaseContext;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Props for `dashboard.widget` slot.
|
|
211
|
+
* Widgets rendered on the home / dashboard page.
|
|
212
|
+
* @group Plugins
|
|
213
|
+
*/
|
|
214
|
+
export interface DashboardWidgetProps {
|
|
215
|
+
context: RebaseContext;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Props for `global.search` slot.
|
|
219
|
+
* Cross-collection search bar rendered in the app shell.
|
|
220
|
+
* @group Plugins
|
|
221
|
+
*/
|
|
222
|
+
export interface GlobalSearchProps {
|
|
223
|
+
context: RebaseContext;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Props for `shell.toolbar` slot.
|
|
227
|
+
* Actions rendered in the top-level toolbar / app bar area.
|
|
228
|
+
* @group Plugins
|
|
229
|
+
*/
|
|
230
|
+
export interface ShellToolbarProps {
|
|
231
|
+
context: RebaseContext;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Props for `collection.insights` slot.
|
|
235
|
+
* Insight widgets rendered above the collection table.
|
|
236
|
+
* @group Plugins
|
|
237
|
+
*/
|
|
238
|
+
export interface CollectionInsightsSlotProps {
|
|
239
|
+
path: string;
|
|
240
|
+
collection: EntityCollection;
|
|
241
|
+
parentCollectionIds: string[];
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Props for `home.card.insight` slot.
|
|
245
|
+
* Compact insight rendered inline in a home page collection card.
|
|
246
|
+
* @group Plugins
|
|
247
|
+
*/
|
|
248
|
+
export interface HomeCardInsightSlotProps {
|
|
249
|
+
slug: string;
|
|
250
|
+
collection: EntityCollection;
|
|
251
|
+
context: RebaseContext;
|
|
252
|
+
}
|