@rebasepro/sdk-generator 0.0.1-canary.4d4fb3e
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/LICENSE +6 -0
- package/dist/common/src/collections/CollectionRegistry.d.ts +48 -0
- package/dist/common/src/collections/index.d.ts +1 -0
- package/dist/common/src/data/buildRebaseData.d.ts +14 -0
- package/dist/common/src/index.d.ts +3 -0
- package/dist/common/src/util/builders.d.ts +57 -0
- package/dist/common/src/util/callbacks.d.ts +6 -0
- package/dist/common/src/util/collections.d.ts +11 -0
- package/dist/common/src/util/common.d.ts +2 -0
- package/dist/common/src/util/conditions.d.ts +26 -0
- package/dist/common/src/util/entities.d.ts +36 -0
- package/dist/common/src/util/enums.d.ts +3 -0
- package/dist/common/src/util/index.d.ts +16 -0
- package/dist/common/src/util/navigation_from_path.d.ts +34 -0
- package/dist/common/src/util/navigation_utils.d.ts +20 -0
- package/dist/common/src/util/parent_references_from_path.d.ts +6 -0
- package/dist/common/src/util/paths.d.ts +14 -0
- package/dist/common/src/util/permissions.d.ts +5 -0
- package/dist/common/src/util/references.d.ts +2 -0
- package/dist/common/src/util/relations.d.ts +12 -0
- package/dist/common/src/util/resolutions.d.ts +72 -0
- package/dist/common/src/util/storage.d.ts +24 -0
- package/dist/index.cjs +211 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.es.js +208 -0
- package/dist/index.es.js.map +1 -0
- package/dist/sdk-generator/src/generate-types.d.ts +2 -0
- package/dist/sdk-generator/src/index.d.ts +19 -0
- package/dist/sdk-generator/src/utils.d.ts +22 -0
- package/dist/types/src/controllers/analytics_controller.d.ts +7 -0
- package/dist/types/src/controllers/auth.d.ts +117 -0
- package/dist/types/src/controllers/client.d.ts +58 -0
- package/dist/types/src/controllers/collection_registry.d.ts +44 -0
- package/dist/types/src/controllers/customization_controller.d.ts +54 -0
- package/dist/types/src/controllers/data.d.ts +141 -0
- package/dist/types/src/controllers/data_driver.d.ts +168 -0
- package/dist/types/src/controllers/database_admin.d.ts +11 -0
- package/dist/types/src/controllers/dialogs_controller.d.ts +36 -0
- package/dist/types/src/controllers/effective_role.d.ts +4 -0
- package/dist/types/src/controllers/index.d.ts +17 -0
- package/dist/types/src/controllers/local_config_persistence.d.ts +20 -0
- package/dist/types/src/controllers/navigation.d.ts +213 -0
- package/dist/types/src/controllers/registry.d.ts +51 -0
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/types/src/controllers/side_entity_controller.d.ts +89 -0
- package/dist/types/src/controllers/snackbar.d.ts +24 -0
- package/dist/types/src/controllers/storage.d.ts +173 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/rebase_context.d.ts +101 -0
- package/dist/types/src/types/backend.d.ts +533 -0
- package/dist/types/src/types/builders.d.ts +14 -0
- package/dist/types/src/types/chips.d.ts +5 -0
- package/dist/types/src/types/collections.d.ts +812 -0
- package/dist/types/src/types/data_source.d.ts +64 -0
- package/dist/types/src/types/entities.d.ts +145 -0
- package/dist/types/src/types/entity_actions.d.ts +98 -0
- package/dist/types/src/types/entity_callbacks.d.ts +173 -0
- package/dist/types/src/types/entity_link_builder.d.ts +7 -0
- package/dist/types/src/types/entity_overrides.d.ts +9 -0
- package/dist/types/src/types/entity_views.d.ts +61 -0
- package/dist/types/src/types/export_import.d.ts +21 -0
- package/dist/types/src/types/index.d.ts +22 -0
- package/dist/types/src/types/locales.d.ts +4 -0
- package/dist/types/src/types/modify_collections.d.ts +5 -0
- package/dist/types/src/types/plugins.d.ts +225 -0
- package/dist/types/src/types/properties.d.ts +1091 -0
- package/dist/types/src/types/property_config.d.ts +70 -0
- package/dist/types/src/types/relations.d.ts +336 -0
- package/dist/types/src/types/slots.d.ts +228 -0
- package/dist/types/src/types/translations.d.ts +826 -0
- package/dist/types/src/types/user_management_delegate.d.ts +120 -0
- package/dist/types/src/types/websockets.d.ts +78 -0
- package/dist/types/src/users/index.d.ts +2 -0
- package/dist/types/src/users/roles.d.ts +22 -0
- package/dist/types/src/users/user.d.ts +46 -0
- package/jest.config.cjs +13 -0
- package/package.json +51 -0
- package/src/generate-types.ts +176 -0
- package/src/index.ts +71 -0
- package/src/json-logic-js.d.ts +8 -0
- package/src/utils.ts +42 -0
- package/test/sdk-generator.test.ts +78 -0
- package/tsconfig.json +26 -0
- package/vite.config.ts +49 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Describes the capabilities and features supported by a data source (driver).
|
|
3
|
+
*
|
|
4
|
+
* Each driver (Postgres, Firebase, MongoDB, etc.) declares which features it
|
|
5
|
+
* supports. The CMS uses this descriptor to:
|
|
6
|
+
* - Show/hide editor tabs (e.g. Relations for SQL, Subcollections for Firebase)
|
|
7
|
+
* - Filter the property type picker (e.g. `relation` for SQL, `reference` for Firebase)
|
|
8
|
+
* - Toggle driver-specific form controls (e.g. `columnType` for SQL)
|
|
9
|
+
*
|
|
10
|
+
* @group Models
|
|
11
|
+
*/
|
|
12
|
+
export interface DataSourceCapabilities {
|
|
13
|
+
/** Unique driver key (e.g. "postgres", "firestore", "mongodb") */
|
|
14
|
+
key: string;
|
|
15
|
+
/** Human-readable label for the UI (e.g. "PostgreSQL", "Firebase / Firestore") */
|
|
16
|
+
label: string;
|
|
17
|
+
/** Does this source support SQL-style relations (JOINs)? */
|
|
18
|
+
supportsRelations: boolean;
|
|
19
|
+
/** Does this source support nested subcollections? */
|
|
20
|
+
supportsSubcollections: boolean;
|
|
21
|
+
/** Does this source support Row Level Security policies? */
|
|
22
|
+
supportsRLS: boolean;
|
|
23
|
+
/** Does this source support document references (Firebase-style)? */
|
|
24
|
+
supportsReferences: boolean;
|
|
25
|
+
/** Does this source support SQL column type annotations? */
|
|
26
|
+
supportsColumnTypes: boolean;
|
|
27
|
+
/** Does this source support real-time listeners? */
|
|
28
|
+
supportsRealtime: boolean;
|
|
29
|
+
/** Does this source support SQL admin operations (SQL editor, EXPLAIN, etc.)? */
|
|
30
|
+
supportsSQLAdmin: boolean;
|
|
31
|
+
/** Does this source support document admin operations (aggregation, stats)? */
|
|
32
|
+
supportsDocumentAdmin: boolean;
|
|
33
|
+
/** Does this source support schema admin (unmapped tables, table metadata)? */
|
|
34
|
+
supportsSchemaAdmin: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Subset of DataSourceCapabilities containing only feature flags.
|
|
38
|
+
* Useful when you only need to check capabilities without UI metadata.
|
|
39
|
+
* @group Models
|
|
40
|
+
*/
|
|
41
|
+
export type DataSourceFeatures = Pick<DataSourceCapabilities, "supportsRelations" | "supportsSubcollections" | "supportsRLS" | "supportsReferences" | "supportsColumnTypes" | "supportsRealtime" | "supportsSQLAdmin" | "supportsDocumentAdmin" | "supportsSchemaAdmin">;
|
|
42
|
+
/** @group Models */
|
|
43
|
+
export declare const POSTGRES_CAPABILITIES: DataSourceCapabilities;
|
|
44
|
+
/** @group Models */
|
|
45
|
+
export declare const FIREBASE_CAPABILITIES: DataSourceCapabilities;
|
|
46
|
+
/** @group Models */
|
|
47
|
+
export declare const MONGODB_CAPABILITIES: DataSourceCapabilities;
|
|
48
|
+
/**
|
|
49
|
+
* Fallback capabilities when the driver is unknown.
|
|
50
|
+
* Enables everything so nothing is hidden unexpectedly.
|
|
51
|
+
* @group Models
|
|
52
|
+
*/
|
|
53
|
+
export declare const DEFAULT_CAPABILITIES: DataSourceCapabilities;
|
|
54
|
+
/**
|
|
55
|
+
* Look up capabilities for a given driver key.
|
|
56
|
+
* If `driver` is undefined or not found, returns `DEFAULT_CAPABILITIES`.
|
|
57
|
+
* @group Models
|
|
58
|
+
*/
|
|
59
|
+
export declare function getDataSourceCapabilities(driver?: string): DataSourceCapabilities;
|
|
60
|
+
/**
|
|
61
|
+
* Register custom capabilities for a third-party driver.
|
|
62
|
+
* @group Models
|
|
63
|
+
*/
|
|
64
|
+
export declare function registerDataSourceCapabilities(capabilities: DataSourceCapabilities): void;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* New or existing status
|
|
3
|
+
* @group Models
|
|
4
|
+
*/
|
|
5
|
+
export type EntityStatus = "new" | "existing" | "copy";
|
|
6
|
+
/**
|
|
7
|
+
* Representation of an entity fetched from the driver
|
|
8
|
+
* @group Models
|
|
9
|
+
*/
|
|
10
|
+
export interface Entity<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
11
|
+
/**
|
|
12
|
+
* ID of the entity
|
|
13
|
+
*/
|
|
14
|
+
id: string | number;
|
|
15
|
+
/**
|
|
16
|
+
* A string representing the path of the referenced document (relative
|
|
17
|
+
* to the root of the database).
|
|
18
|
+
*/
|
|
19
|
+
path: string;
|
|
20
|
+
/**
|
|
21
|
+
* Current values
|
|
22
|
+
*/
|
|
23
|
+
values: EntityValues<M>;
|
|
24
|
+
/**
|
|
25
|
+
* Which driver this entity belongs to (e.g., 'postgres', 'firestore').
|
|
26
|
+
* If not specified, the default driver is assumed.
|
|
27
|
+
*/
|
|
28
|
+
driver?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Which database within the driver (e.g., for Firestore multi-database).
|
|
31
|
+
* If not specified, the default database of the driver is used.
|
|
32
|
+
*/
|
|
33
|
+
databaseId?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* This type represents a record of key value pairs as described in an
|
|
37
|
+
* entity collection.
|
|
38
|
+
* @group Models
|
|
39
|
+
*/
|
|
40
|
+
export type EntityValues<M extends Record<string, unknown>> = M;
|
|
41
|
+
/**
|
|
42
|
+
* Props for creating an EntityReference
|
|
43
|
+
*/
|
|
44
|
+
export interface EntityReferenceProps {
|
|
45
|
+
/** ID of the entity */
|
|
46
|
+
id: string;
|
|
47
|
+
/** Path of the collection (relative to the root of the database) */
|
|
48
|
+
path: string;
|
|
49
|
+
/** Which driver (e.g., 'postgres', 'firestore'). Defaults to "(default)" */
|
|
50
|
+
driver?: string;
|
|
51
|
+
/** Which database within the driver. Defaults to "(default)" */
|
|
52
|
+
databaseId?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Class used to create a reference to an entity in a different path.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // Simple reference (most common case - single driver, single db)
|
|
59
|
+
* new EntityReference({ id: "123", path: "users" })
|
|
60
|
+
*
|
|
61
|
+
* // Reference to a different driver (e.g., Firestore)
|
|
62
|
+
* new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
|
|
63
|
+
*
|
|
64
|
+
* // Reference to a specific database within a driver
|
|
65
|
+
* new EntityReference({ id: "123", path: "orders", driver: "postgres", databaseId: "orders_db" })
|
|
66
|
+
*/
|
|
67
|
+
export declare class EntityReference {
|
|
68
|
+
readonly __type = "reference";
|
|
69
|
+
/**
|
|
70
|
+
* ID of the entity
|
|
71
|
+
*/
|
|
72
|
+
readonly id: string;
|
|
73
|
+
/**
|
|
74
|
+
* A string representing the path of the referenced document (relative
|
|
75
|
+
* to the root of the database).
|
|
76
|
+
*/
|
|
77
|
+
readonly path: string;
|
|
78
|
+
/**
|
|
79
|
+
* Which driver (e.g., 'postgres', 'firestore').
|
|
80
|
+
* Defaults to "(default)" if not specified.
|
|
81
|
+
*/
|
|
82
|
+
readonly driver?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Which database within the driver.
|
|
85
|
+
* Defaults to "(default)" if not specified.
|
|
86
|
+
*/
|
|
87
|
+
readonly databaseId?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Create a reference to an entity.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* // Simple reference (most common case)
|
|
93
|
+
* new EntityReference({ id: "123", path: "users" })
|
|
94
|
+
*
|
|
95
|
+
* // With driver
|
|
96
|
+
* new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
|
|
97
|
+
*/
|
|
98
|
+
constructor(props: EntityReferenceProps);
|
|
99
|
+
get pathWithId(): string;
|
|
100
|
+
/**
|
|
101
|
+
* Get the full path including driver and database prefixes if specified.
|
|
102
|
+
* For the common case (single driver, single db), this just returns pathWithId.
|
|
103
|
+
*/
|
|
104
|
+
get fullPath(): string;
|
|
105
|
+
isEntityReference(): boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Class used to create a reference to an entity in a different path
|
|
109
|
+
*/
|
|
110
|
+
export declare class EntityRelation {
|
|
111
|
+
readonly __type = "relation";
|
|
112
|
+
/**
|
|
113
|
+
* ID of the entity
|
|
114
|
+
*/
|
|
115
|
+
readonly id: string | number;
|
|
116
|
+
/**
|
|
117
|
+
* A string representing the path of the referenced document (relative
|
|
118
|
+
* to the root of the database).
|
|
119
|
+
*/
|
|
120
|
+
readonly path: string;
|
|
121
|
+
/**
|
|
122
|
+
* Pre-fetched data payload to eliminate N+1 queries.
|
|
123
|
+
* When present, clients can use this directly instead of fetching.
|
|
124
|
+
*/
|
|
125
|
+
readonly data?: Entity;
|
|
126
|
+
constructor(id: string | number, path: string, data?: Entity);
|
|
127
|
+
get pathWithId(): string;
|
|
128
|
+
isEntityReference(): boolean;
|
|
129
|
+
isEntityRelation(): boolean;
|
|
130
|
+
}
|
|
131
|
+
export declare class GeoPoint {
|
|
132
|
+
/**
|
|
133
|
+
* The latitude of this GeoPoint instance.
|
|
134
|
+
*/
|
|
135
|
+
readonly latitude: number;
|
|
136
|
+
/**
|
|
137
|
+
* The longitude of this GeoPoint instance.
|
|
138
|
+
*/
|
|
139
|
+
readonly longitude: number;
|
|
140
|
+
constructor(latitude: number, longitude: number);
|
|
141
|
+
}
|
|
142
|
+
export declare class Vector {
|
|
143
|
+
readonly value: number[];
|
|
144
|
+
constructor(value: number[]);
|
|
145
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Entity } from "./entities";
|
|
3
|
+
import { EntityCollection, SelectionController } from "./collections";
|
|
4
|
+
import { FormContext } from "./entity_views";
|
|
5
|
+
import { User } from "../users";
|
|
6
|
+
import { RebaseContext } from "../rebase_context";
|
|
7
|
+
import { SideEntityController } from "../controllers";
|
|
8
|
+
/**
|
|
9
|
+
* An entity action is a custom action that can be performed on an entity.
|
|
10
|
+
* They are displayed in the entity view and in the collection view.
|
|
11
|
+
*/
|
|
12
|
+
export interface EntityAction<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
13
|
+
/**
|
|
14
|
+
* Title of the action
|
|
15
|
+
*/
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* Key of the action. You only need to provide this if you want to
|
|
19
|
+
* override the default actions, or if you are not passing the action
|
|
20
|
+
* directly to the `entityActions` prop of a collection.
|
|
21
|
+
* You can define your actions at the app level, in which case you
|
|
22
|
+
* must provide a key.
|
|
23
|
+
* The default actions are:
|
|
24
|
+
* - edit
|
|
25
|
+
* - delete
|
|
26
|
+
* - copy
|
|
27
|
+
*/
|
|
28
|
+
key?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Icon of the action
|
|
31
|
+
*/
|
|
32
|
+
icon?: React.ReactElement;
|
|
33
|
+
/**
|
|
34
|
+
* Callback when the action is clicked
|
|
35
|
+
* @param props
|
|
36
|
+
*/
|
|
37
|
+
onClick(props: EntityActionClickProps<M, USER>): Promise<void> | void;
|
|
38
|
+
/**
|
|
39
|
+
* Optional callback in case you want to disable the action
|
|
40
|
+
* @param props
|
|
41
|
+
*/
|
|
42
|
+
isEnabled?(props: EntityActionClickProps<M, USER>): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Show this action collapsed in the menu of the collection view.
|
|
45
|
+
* Defaults to true
|
|
46
|
+
* If false, the action will be shown in the menu
|
|
47
|
+
*/
|
|
48
|
+
collapsed?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Show this action in the form, defaults to true
|
|
51
|
+
*/
|
|
52
|
+
includeInForm?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export type EntityActionClickProps<M extends Record<string, unknown>, USER extends User = User> = {
|
|
55
|
+
entity?: Entity<M>;
|
|
56
|
+
context: RebaseContext<USER>;
|
|
57
|
+
path?: string;
|
|
58
|
+
collection?: EntityCollection<Record<string, unknown>, any>;
|
|
59
|
+
/**
|
|
60
|
+
* Optional form context, present if the action is being called from a form.
|
|
61
|
+
* This allows you to access the form state and methods, including modifying the form values.
|
|
62
|
+
*/
|
|
63
|
+
formContext?: FormContext;
|
|
64
|
+
/**
|
|
65
|
+
* Present if this actions is being called from a side dialog only
|
|
66
|
+
*/
|
|
67
|
+
sideEntityController?: SideEntityController;
|
|
68
|
+
/**
|
|
69
|
+
* Is the action being called from the collection view or from the entity form view?
|
|
70
|
+
*/
|
|
71
|
+
view: "collection" | "form";
|
|
72
|
+
/**
|
|
73
|
+
* If the action is rendered in the form, is it open in a side panel or full screen?
|
|
74
|
+
*/
|
|
75
|
+
openEntityMode: "side_panel" | "full_screen";
|
|
76
|
+
/**
|
|
77
|
+
* Optional selection controller, present if the action is being called from a collection view
|
|
78
|
+
*/
|
|
79
|
+
selectionController?: SelectionController;
|
|
80
|
+
/**
|
|
81
|
+
* Optional highlight function to highlight the entity in the collection view
|
|
82
|
+
* @param entity
|
|
83
|
+
*/
|
|
84
|
+
highlightEntity?: (entity: Entity<Record<string, unknown>>) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Optional unhighlight function to remove the highlight from the entity in the collection view
|
|
87
|
+
* @param entity
|
|
88
|
+
*/
|
|
89
|
+
unhighlightEntity?: (entity: Entity<Record<string, unknown>>) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Optional function to navigate back (e.g. when deleting an entity or navigating from a form)
|
|
92
|
+
*/
|
|
93
|
+
navigateBack?: () => void;
|
|
94
|
+
/**
|
|
95
|
+
* Callback to be called when the collection changes, e.g. after an entity is deleted or created.
|
|
96
|
+
*/
|
|
97
|
+
onCollectionChange?: () => void;
|
|
98
|
+
};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { EntityCollection } from "./collections";
|
|
2
|
+
import { Entity, EntityStatus, EntityValues } from "./entities";
|
|
3
|
+
import { User } from "../users";
|
|
4
|
+
import { RebaseCallContext } from "../rebase_context";
|
|
5
|
+
/**
|
|
6
|
+
* This interface defines all the callbacks that can be used when an entity
|
|
7
|
+
* is being created, updated or deleted.
|
|
8
|
+
* Useful for adding your own logic or blocking the execution of the operation.
|
|
9
|
+
* @group Models
|
|
10
|
+
*/
|
|
11
|
+
export type EntityCallbacks<M extends Record<string, any> = any, USER extends User = User> = {
|
|
12
|
+
/**
|
|
13
|
+
* Callback used after fetching data
|
|
14
|
+
* @param props
|
|
15
|
+
*/
|
|
16
|
+
afterRead?(props: EntityAfterReadProps<M, USER>): Promise<Entity<M>> | Entity<M>;
|
|
17
|
+
/**
|
|
18
|
+
* Callback used before saving, you need to return the values that will get
|
|
19
|
+
* saved. If you throw an error in this method the process stops, and an
|
|
20
|
+
* error snackbar gets displayed.
|
|
21
|
+
* This runs after schema validation.
|
|
22
|
+
* @param props
|
|
23
|
+
*/
|
|
24
|
+
beforeSave?(props: EntityBeforeSaveProps<M, USER>): Promise<Partial<EntityValues<M>>> | Partial<EntityValues<M>>;
|
|
25
|
+
/**
|
|
26
|
+
* Callback used when save is successful
|
|
27
|
+
* @param props
|
|
28
|
+
*/
|
|
29
|
+
afterSave?(props: EntityAfterSaveProps<M, USER>): Promise<void> | void;
|
|
30
|
+
/**
|
|
31
|
+
* Callback used when saving fails
|
|
32
|
+
* @param props
|
|
33
|
+
*/
|
|
34
|
+
afterSaveError?(props: EntityAfterSaveErrorProps<M, USER>): Promise<void> | void;
|
|
35
|
+
/**
|
|
36
|
+
* Callback used before the entity is deleted.
|
|
37
|
+
* If you throw an error in this method the process stops, and an
|
|
38
|
+
* error snackbar gets displayed.
|
|
39
|
+
*
|
|
40
|
+
* @param props
|
|
41
|
+
*/
|
|
42
|
+
beforeDelete?(props: EntityBeforeDeleteProps<M, USER>): void;
|
|
43
|
+
/**
|
|
44
|
+
* Callback used after the entity is deleted.
|
|
45
|
+
*
|
|
46
|
+
* @param props
|
|
47
|
+
*/
|
|
48
|
+
afterDelete?(props: EntityAfterDeleteProps<M, USER>): void;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Parameters passed to hooks when an entity is fetched
|
|
52
|
+
* @group Models
|
|
53
|
+
*/
|
|
54
|
+
export interface EntityAfterReadProps<M extends Record<string, any> = any, USER extends User = User> {
|
|
55
|
+
/**
|
|
56
|
+
* Collection of the entity
|
|
57
|
+
*/
|
|
58
|
+
collection: EntityCollection<Record<string, unknown>, any>;
|
|
59
|
+
/**
|
|
60
|
+
* Full path of the CMS where this collection is being fetched.
|
|
61
|
+
* Might contain unresolved aliases.
|
|
62
|
+
*/
|
|
63
|
+
path: string;
|
|
64
|
+
/**
|
|
65
|
+
* Fetched entity
|
|
66
|
+
*/
|
|
67
|
+
entity: Entity<M>;
|
|
68
|
+
/**
|
|
69
|
+
* Context of the app status
|
|
70
|
+
*/
|
|
71
|
+
context: RebaseCallContext<USER>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Parameters passed to hooks before an entity is saved
|
|
75
|
+
* @group Models
|
|
76
|
+
*/
|
|
77
|
+
export type EntityBeforeSaveProps<M extends Record<string, any> = any, USER extends User = User> = Omit<EntityAfterSaveProps<M, USER>, "entityId"> & {
|
|
78
|
+
entityId?: string | number;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Parameters passed to hooks before an entity is saved
|
|
82
|
+
* @group Models
|
|
83
|
+
*/
|
|
84
|
+
export type EntityAfterSaveErrorProps<M extends Record<string, any> = any, USER extends User = User> = Omit<EntityAfterSaveProps<M, USER>, "entityId"> & {
|
|
85
|
+
entityId?: string | number;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Parameters passed to hooks when an entity is saved
|
|
89
|
+
* @group Models
|
|
90
|
+
*/
|
|
91
|
+
export interface EntityAfterSaveProps<M extends Record<string, any> = any, USER extends User = User> {
|
|
92
|
+
/**
|
|
93
|
+
* Resolved collection of the entity
|
|
94
|
+
*/
|
|
95
|
+
collection: EntityCollection<Record<string, unknown>, any>;
|
|
96
|
+
/**
|
|
97
|
+
* Full path of the CMS where this entity is being saved.
|
|
98
|
+
* Might contain unresolved aliases.
|
|
99
|
+
*/
|
|
100
|
+
path: string;
|
|
101
|
+
/**
|
|
102
|
+
* ID of the entity
|
|
103
|
+
*/
|
|
104
|
+
entityId: string | number;
|
|
105
|
+
/**
|
|
106
|
+
* Values being saved
|
|
107
|
+
*/
|
|
108
|
+
values: Partial<EntityValues<M>>;
|
|
109
|
+
/**
|
|
110
|
+
* Previous values
|
|
111
|
+
*/
|
|
112
|
+
previousValues?: Partial<EntityValues<M>>;
|
|
113
|
+
/**
|
|
114
|
+
* New or existing entity
|
|
115
|
+
*/
|
|
116
|
+
status: EntityStatus;
|
|
117
|
+
/**
|
|
118
|
+
* Context of the app status
|
|
119
|
+
*/
|
|
120
|
+
context: RebaseCallContext<USER>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Parameters passed to hooks when an entity is deleted
|
|
124
|
+
* @group Models
|
|
125
|
+
*/
|
|
126
|
+
export interface EntityBeforeDeleteProps<M extends Record<string, any> = any, USER extends User = User> {
|
|
127
|
+
/**
|
|
128
|
+
* collection of the entity being deleted
|
|
129
|
+
*/
|
|
130
|
+
collection: EntityCollection<Record<string, unknown>, any>;
|
|
131
|
+
/**
|
|
132
|
+
* Path of the parent collection
|
|
133
|
+
*/
|
|
134
|
+
path: string;
|
|
135
|
+
/**
|
|
136
|
+
* Deleted entity id
|
|
137
|
+
*/
|
|
138
|
+
entityId: string | number;
|
|
139
|
+
/**
|
|
140
|
+
* Deleted entity
|
|
141
|
+
*/
|
|
142
|
+
entity: Entity<M>;
|
|
143
|
+
/**
|
|
144
|
+
* Context of the app status
|
|
145
|
+
*/
|
|
146
|
+
context: RebaseCallContext<USER>;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Parameters passed to hooks after an entity is deleted
|
|
150
|
+
* @group Models
|
|
151
|
+
*/
|
|
152
|
+
export interface EntityAfterDeleteProps<M extends Record<string, any> = any, USER extends User = User> {
|
|
153
|
+
/**
|
|
154
|
+
* collection of the entity being deleted
|
|
155
|
+
*/
|
|
156
|
+
collection: EntityCollection<Record<string, unknown>, any>;
|
|
157
|
+
/**
|
|
158
|
+
* Path of the parent collection
|
|
159
|
+
*/
|
|
160
|
+
path: string;
|
|
161
|
+
/**
|
|
162
|
+
* Deleted entity id
|
|
163
|
+
*/
|
|
164
|
+
entityId: string | number;
|
|
165
|
+
/**
|
|
166
|
+
* Deleted entity
|
|
167
|
+
*/
|
|
168
|
+
entity: Entity<M>;
|
|
169
|
+
/**
|
|
170
|
+
* Context of the app status
|
|
171
|
+
*/
|
|
172
|
+
context: RebaseCallContext<USER>;
|
|
173
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataDriver, StorageSource } from "../controllers";
|
|
2
|
+
export type EntityOverrides = {
|
|
3
|
+
/**
|
|
4
|
+
* Internal driver override for this collection.
|
|
5
|
+
* Used by the CMS engine to route data operations.
|
|
6
|
+
*/
|
|
7
|
+
driver?: DataDriver;
|
|
8
|
+
storageSource?: StorageSource;
|
|
9
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Entity, EntityValues } from "./entities";
|
|
3
|
+
import { EntityCollection } from "./collections";
|
|
4
|
+
/**
|
|
5
|
+
* Context passed to custom fields and entity views.
|
|
6
|
+
* This is the base definition — `@rebasepro/cms` re-exports a
|
|
7
|
+
* fully-typed version that narrows the `formex` field.
|
|
8
|
+
* @group Form custom fields
|
|
9
|
+
*/
|
|
10
|
+
export interface FormContext<M extends Record<string, any> = any> {
|
|
11
|
+
/**
|
|
12
|
+
* Current values of the entity
|
|
13
|
+
*/
|
|
14
|
+
values: M;
|
|
15
|
+
/**
|
|
16
|
+
* Update the value of a field
|
|
17
|
+
*/
|
|
18
|
+
setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Save the entity.
|
|
21
|
+
*/
|
|
22
|
+
save: (values: M) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Collection of the entity being modified
|
|
25
|
+
*/
|
|
26
|
+
collection?: EntityCollection<M>;
|
|
27
|
+
/**
|
|
28
|
+
* Entity id, it can be undefined if it's a new entity
|
|
29
|
+
*/
|
|
30
|
+
entityId?: string | number;
|
|
31
|
+
/**
|
|
32
|
+
* Path this entity is located at
|
|
33
|
+
*/
|
|
34
|
+
path?: string;
|
|
35
|
+
status: "new" | "existing" | "copy";
|
|
36
|
+
entity?: Entity<M>;
|
|
37
|
+
savingError?: Error;
|
|
38
|
+
openEntityMode: "side_panel" | "full_screen";
|
|
39
|
+
/**
|
|
40
|
+
* The underlying formex controller that powers the form.
|
|
41
|
+
* Prefer importing `FormContext` from `@rebasepro/cms` for the
|
|
42
|
+
* fully-typed `FormexController<M>` version.
|
|
43
|
+
*/
|
|
44
|
+
formex: Record<string, unknown>;
|
|
45
|
+
disabled: boolean;
|
|
46
|
+
}
|
|
47
|
+
export type EntityCustomView<M extends Record<string, any> = any> = {
|
|
48
|
+
key: string;
|
|
49
|
+
name: string;
|
|
50
|
+
tabComponent?: React.ReactNode;
|
|
51
|
+
includeActions?: boolean | "bottom";
|
|
52
|
+
Builder?: React.ComponentType<EntityCustomViewParams<M>>;
|
|
53
|
+
position?: "start" | "end";
|
|
54
|
+
};
|
|
55
|
+
export interface EntityCustomViewParams<M extends Record<string, any> = any> {
|
|
56
|
+
collection: EntityCollection<M>;
|
|
57
|
+
entity?: Entity<M>;
|
|
58
|
+
modifiedValues?: EntityValues<M>;
|
|
59
|
+
formContext: FormContext<M>;
|
|
60
|
+
parentCollectionIds?: string[];
|
|
61
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Entity } from "./entities";
|
|
2
|
+
import { User } from "../users";
|
|
3
|
+
import { RebaseContext } from "../rebase_context";
|
|
4
|
+
/**
|
|
5
|
+
* You can use this configuration to add additional fields to the data
|
|
6
|
+
* exports
|
|
7
|
+
* @group Models
|
|
8
|
+
*/
|
|
9
|
+
export interface ExportConfig<USER extends User = User> {
|
|
10
|
+
additionalFields: ExportMappingFunction<USER>[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @group Models
|
|
14
|
+
*/
|
|
15
|
+
export interface ExportMappingFunction<USER extends User = User> {
|
|
16
|
+
key: string;
|
|
17
|
+
builder: ({ entity, context }: {
|
|
18
|
+
entity: Entity<any>;
|
|
19
|
+
context: RebaseContext<USER>;
|
|
20
|
+
}) => Promise<string> | string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from "./entities";
|
|
2
|
+
export * from "./chips";
|
|
3
|
+
export * from "./properties";
|
|
4
|
+
export * from "./collections";
|
|
5
|
+
export * from "./relations";
|
|
6
|
+
export * from "./locales";
|
|
7
|
+
export * from "./entity_link_builder";
|
|
8
|
+
export * from "./user_management_delegate";
|
|
9
|
+
export * from "./entity_callbacks";
|
|
10
|
+
export * from "./entity_overrides";
|
|
11
|
+
export * from "./export_import";
|
|
12
|
+
export * from "./modify_collections";
|
|
13
|
+
export * from "./websockets";
|
|
14
|
+
export * from "./backend";
|
|
15
|
+
export * from "./translations";
|
|
16
|
+
export * from "./plugins";
|
|
17
|
+
export * from "./builders";
|
|
18
|
+
export * from "./slots";
|
|
19
|
+
export * from "./entity_actions";
|
|
20
|
+
export * from "./property_config";
|
|
21
|
+
export * from "./entity_views";
|
|
22
|
+
export * from "./data_source";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @group Models
|
|
3
|
+
*/
|
|
4
|
+
export type Locale = "af" | "ar" | "arDZ" | "arMA" | "arSA" | "az" | "be" | "bg" | "bn" | "ca" | "cs" | "cy" | "da" | "de" | "el" | "enAU" | "enCA" | "enGB" | "enIN" | "enNZ" | "enUS" | "eo" | "es" | "et" | "eu" | "faIR" | "fi" | "fil" | "fr" | "frCA" | "frCH" | "gd" | "gl" | "gu" | "he" | "hi" | "hr" | "hu" | "hy" | "id" | "is" | "it" | "ja" | "ka" | "kk" | "kn" | "ko" | "lb" | "lt" | "lv" | "mk" | "ms" | "mt" | "nb" | "nl" | "nlBE" | "nn" | "pl" | "pt" | "ptBR" | "ro" | "ru" | "sk" | "sl" | "sr" | "srLatn" | "sv" | "ta" | "te" | "th" | "tr" | "ug" | "uk" | "uz" | "vi" | "zhCN" | "zhTW";
|