@rebasepro/types 0.7.0 → 0.9.0
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 +10 -10
- package/dist/controllers/auth.d.ts +1 -1
- package/dist/controllers/client.d.ts +237 -7
- package/dist/controllers/collection_registry.d.ts +3 -3
- package/dist/controllers/customization_controller.d.ts +1 -1
- package/dist/controllers/data.d.ts +285 -81
- package/dist/controllers/data_driver.d.ts +50 -37
- package/dist/controllers/index.d.ts +1 -1
- package/dist/controllers/local_config_persistence.d.ts +4 -4
- package/dist/controllers/navigation.d.ts +2 -2
- package/dist/controllers/registry.d.ts +17 -6
- package/dist/controllers/{side_entity_controller.d.ts → side_panel_controller.d.ts} +7 -7
- package/dist/controllers/storage.d.ts +39 -0
- package/dist/errors.d.ts +64 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +290 -16
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +305 -18
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +8 -4
- package/dist/types/auth_adapter.d.ts +9 -6
- package/dist/types/backend.d.ts +30 -26
- package/dist/types/builders.d.ts +2 -2
- package/dist/types/collections.d.ts +211 -136
- package/dist/types/component_overrides.d.ts +61 -3
- package/dist/types/cron.d.ts +10 -1
- package/dist/types/data_source.d.ts +18 -5
- package/dist/types/database_adapter.d.ts +4 -3
- package/dist/types/entities.d.ts +7 -7
- package/dist/types/entity_actions.d.ts +7 -7
- package/dist/types/entity_callbacks.d.ts +55 -43
- package/dist/types/entity_views.d.ts +3 -3
- package/dist/types/filter-operators.d.ts +153 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/modify_collections.d.ts +2 -2
- package/dist/types/plugins.d.ts +9 -9
- package/dist/types/policy.d.ts +191 -0
- package/dist/types/properties.d.ts +153 -43
- package/dist/types/property_config.d.ts +1 -1
- package/dist/types/relations.d.ts +3 -3
- package/dist/types/slots.d.ts +14 -14
- package/dist/types/storage_source.d.ts +83 -0
- package/dist/types/websockets.d.ts +12 -13
- package/dist/users/user.d.ts +21 -9
- package/package.json +1 -1
- package/src/controllers/auth.tsx +1 -1
- package/src/controllers/client.ts +275 -7
- package/src/controllers/collection_registry.ts +3 -3
- package/src/controllers/customization_controller.tsx +1 -1
- package/src/controllers/data.ts +309 -97
- package/src/controllers/data_driver.ts +49 -40
- package/src/controllers/index.ts +1 -1
- package/src/controllers/local_config_persistence.tsx +4 -4
- package/src/controllers/navigation.ts +2 -2
- package/src/controllers/registry.ts +18 -6
- package/src/controllers/{side_entity_controller.tsx → side_panel_controller.tsx} +7 -7
- package/src/controllers/storage.ts +60 -1
- package/src/errors.ts +80 -0
- package/src/index.ts +1 -0
- package/src/rebase_context.tsx +8 -4
- package/src/types/auth_adapter.ts +9 -6
- package/src/types/backend.ts +41 -36
- package/src/types/builders.ts +2 -2
- package/src/types/collections.ts +256 -172
- package/src/types/component_overrides.ts +72 -5
- package/src/types/cron.ts +10 -1
- package/src/types/data_source.ts +29 -7
- package/src/types/database_adapter.ts +4 -3
- package/src/types/entities.ts +7 -7
- package/src/types/entity_actions.tsx +7 -7
- package/src/types/entity_callbacks.ts +58 -47
- package/src/types/entity_views.tsx +3 -3
- package/src/types/filter-operators.ts +240 -0
- package/src/types/index.ts +3 -2
- package/src/types/modify_collections.tsx +2 -2
- package/src/types/plugins.tsx +9 -9
- package/src/types/policy.ts +229 -0
- package/src/types/properties.ts +164 -44
- package/src/types/property_config.tsx +0 -1
- package/src/types/relations.ts +3 -3
- package/src/types/slots.tsx +14 -14
- package/src/types/storage_source.ts +90 -0
- package/src/types/websockets.ts +12 -14
- package/src/users/user.ts +22 -9
- package/dist/types/backend_hooks.d.ts +0 -109
- package/dist/types/entity_overrides.d.ts +0 -10
- package/src/types/backend_hooks.ts +0 -114
- package/src/types/entity_overrides.tsx +0 -11
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
+
import type { Property } from "./properties";
|
|
3
|
+
import type { WhereFilterOp } from "./filter-operators";
|
|
2
4
|
/**
|
|
3
5
|
* Components that can only be overridden at the **app level** via the
|
|
4
6
|
* `components` prop on `<Rebase>`.
|
|
@@ -20,12 +22,68 @@ export type AppComponentName = "Shell.AppBar" | "Shell.Drawer" | "Shell.DrawerNa
|
|
|
20
22
|
*
|
|
21
23
|
* @group Component Overrides
|
|
22
24
|
*/
|
|
23
|
-
export type CollectionComponentName = "Collection.View" | "Collection.Table" | "Collection.Card" | "Collection.EmptyState" | "Collection.Actions" | "Entity.Form" | "
|
|
25
|
+
export type CollectionComponentName = "Collection.View" | "Collection.Table" | "Collection.Card" | "Collection.EmptyState" | "Collection.Actions" | "Collection.FilterField" | "Entity.Form" | "EditView.FormActions" | "DetailView" | "Entity.SidePanel" | "EntityPreview" | "Entity.MissingReference";
|
|
24
26
|
/**
|
|
25
27
|
* All overridable component names across all scopes.
|
|
26
28
|
* @group Component Overrides
|
|
27
29
|
*/
|
|
28
30
|
export type OverridableComponentName = AppComponentName | CollectionComponentName;
|
|
31
|
+
/**
|
|
32
|
+
* Props received by a filter field component — whether it is a built-in
|
|
33
|
+
* per-type field, a property-level replacement (`property.ui.Filter`), or a
|
|
34
|
+
* `"Collection.FilterField"` override.
|
|
35
|
+
*
|
|
36
|
+
* The `operators` list is **already resolved**: it is the intersection of the
|
|
37
|
+
* engine's {@link DataSourceCapabilities.filterOperators}, the property-type
|
|
38
|
+
* defaults, and any `property.ui.filterOperators` narrowing. A custom field
|
|
39
|
+
* should only offer operators from this list — anything else may throw at
|
|
40
|
+
* query time on engines that cannot execute it.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* function MyStatusFilter({ value, setValue, operators }: FilterFieldBindingProps) {
|
|
45
|
+
* return (
|
|
46
|
+
* <select
|
|
47
|
+
* value={value?.[1] as string ?? ""}
|
|
48
|
+
* onChange={e => setValue(e.target.value ? ["==", e.target.value] : undefined)}>
|
|
49
|
+
* <option value="">Any</option>
|
|
50
|
+
* <option value="active">Active</option>
|
|
51
|
+
* <option value="archived">Archived</option>
|
|
52
|
+
* </select>
|
|
53
|
+
* );
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @group Component Overrides
|
|
58
|
+
*/
|
|
59
|
+
export interface FilterFieldBindingProps {
|
|
60
|
+
/** Key of the property being filtered (the column id). */
|
|
61
|
+
propertyKey: string;
|
|
62
|
+
/**
|
|
63
|
+
* The resolved property. For array properties this is the **item**
|
|
64
|
+
* property (`property.of`), with `isArray` set to true.
|
|
65
|
+
*/
|
|
66
|
+
property: Property;
|
|
67
|
+
/** True when the underlying property is an array of `property`. */
|
|
68
|
+
isArray: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Operators this field may offer, already narrowed by engine
|
|
71
|
+
* capabilities, property-type defaults, and `property.ui.filterOperators`.
|
|
72
|
+
*/
|
|
73
|
+
operators: readonly WhereFilterOp[];
|
|
74
|
+
/** Current filter condition for this property, if any. */
|
|
75
|
+
value?: [WhereFilterOp, unknown];
|
|
76
|
+
/** Set (or clear, with `undefined`) the filter condition. */
|
|
77
|
+
setValue: (value?: [WhereFilterOp, unknown]) => void;
|
|
78
|
+
/** Display title for the field (usually the property name). */
|
|
79
|
+
title?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Coordination flags used by fields that open their own dialogs
|
|
82
|
+
* (e.g. the reference picker hides the parent filters dialog).
|
|
83
|
+
*/
|
|
84
|
+
hidden?: boolean;
|
|
85
|
+
setHidden?: (hidden: boolean) => void;
|
|
86
|
+
}
|
|
29
87
|
/**
|
|
30
88
|
* A single component override entry.
|
|
31
89
|
*
|
|
@@ -55,7 +113,7 @@ export type OverridableComponentName = AppComponentName | CollectionComponentNam
|
|
|
55
113
|
*
|
|
56
114
|
* @group Component Overrides
|
|
57
115
|
*/
|
|
58
|
-
export interface ComponentOverride<P =
|
|
116
|
+
export interface ComponentOverride<P = Record<string, unknown>> {
|
|
59
117
|
/**
|
|
60
118
|
* The replacement component. Receives the same props as the built-in
|
|
61
119
|
* component it replaces.
|
|
@@ -122,7 +180,7 @@ export type CollectionComponentOverrideMap = {
|
|
|
122
180
|
* "HomePage": { Component: MyDashboard },
|
|
123
181
|
*
|
|
124
182
|
* // Collection defaults: apply to ALL collections
|
|
125
|
-
* "
|
|
183
|
+
* "EditView.FormActions": {
|
|
126
184
|
* Component: MyFormActions,
|
|
127
185
|
* wrap: true
|
|
128
186
|
* },
|
package/dist/types/cron.d.ts
CHANGED
|
@@ -43,7 +43,16 @@ export interface CronJobContext {
|
|
|
43
43
|
scheduledAt: Date;
|
|
44
44
|
/** A simple logger scoped to this job run. */
|
|
45
45
|
log: (...args: unknown[]) => void;
|
|
46
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* The server-side {@link RebaseClient}. This is the **same singleton**
|
|
48
|
+
* exposed as `rebase` (imported from `@rebasepro/server-core`) and as
|
|
49
|
+
* `context` in collection callbacks — it is only named `client` here.
|
|
50
|
+
*
|
|
51
|
+
* Its data plane (`client.data`) runs with **admin privileges and bypasses
|
|
52
|
+
* RLS** (`{ uid: "service", roles: ["admin"] }`). There is no per-request
|
|
53
|
+
* user in a cron, so treat every query as fully trusted and scope your own
|
|
54
|
+
* filters explicitly.
|
|
55
|
+
*/
|
|
47
56
|
client: RebaseClient;
|
|
48
57
|
}
|
|
49
58
|
export type CronJobRunState = "idle" | "running" | "success" | "error" | "disabled";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WhereFilterOp } from "./filter-operators";
|
|
1
2
|
/**
|
|
2
3
|
* Describes the capabilities and features supported by a data source (driver).
|
|
3
4
|
*
|
|
@@ -26,6 +27,16 @@ export interface DataSourceCapabilities {
|
|
|
26
27
|
supportsColumnTypes: boolean;
|
|
27
28
|
/** Does this source support real-time listeners? */
|
|
28
29
|
supportsRealtime: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Canonical filter operators this engine can execute.
|
|
32
|
+
*
|
|
33
|
+
* The admin UI intersects this set with the property-type defaults and
|
|
34
|
+
* any per-property narrowing (`property.ui.filterOperators`) to decide
|
|
35
|
+
* which operators to offer in filter fields — so an engine that cannot
|
|
36
|
+
* run `ilike` (e.g. Firestore) never shows a "Contains" filter that
|
|
37
|
+
* would throw at query time.
|
|
38
|
+
*/
|
|
39
|
+
filterOperators: readonly WhereFilterOp[];
|
|
29
40
|
/** Does this source support SQL admin operations (SQL editor, EXPLAIN, etc.)? */
|
|
30
41
|
supportsSQLAdmin: boolean;
|
|
31
42
|
/** Does this source support document admin operations (aggregation, stats)? */
|
|
@@ -84,9 +95,11 @@ export interface DataSourceDefinition {
|
|
|
84
95
|
*/
|
|
85
96
|
engine: string;
|
|
86
97
|
/**
|
|
87
|
-
* How the frontend reaches this source.
|
|
98
|
+
* How the frontend reaches this source. Optional — when omitted it is
|
|
99
|
+
* inferred: `"direct"` if the definition carries a client-side driver,
|
|
100
|
+
* `"server"` otherwise.
|
|
88
101
|
*/
|
|
89
|
-
transport
|
|
102
|
+
transport?: DataSourceTransport;
|
|
90
103
|
/**
|
|
91
104
|
* The physical database/schema/Firestore-database within the engine.
|
|
92
105
|
* Threaded to drivers/adapters as the existing `databaseId` runtime
|
|
@@ -128,11 +141,11 @@ export declare const MONGODB_CAPABILITIES: DataSourceCapabilities;
|
|
|
128
141
|
*/
|
|
129
142
|
export declare const DEFAULT_CAPABILITIES: DataSourceCapabilities;
|
|
130
143
|
/**
|
|
131
|
-
* Look up capabilities for a given
|
|
132
|
-
* If `
|
|
144
|
+
* Look up capabilities for a given engine key.
|
|
145
|
+
* If `engine` is undefined or not found, returns `DEFAULT_CAPABILITIES`.
|
|
133
146
|
* @group Models
|
|
134
147
|
*/
|
|
135
|
-
export declare function getDataSourceCapabilities(
|
|
148
|
+
export declare function getDataSourceCapabilities(engine?: string): DataSourceCapabilities;
|
|
136
149
|
/**
|
|
137
150
|
* Register custom capabilities for a third-party driver.
|
|
138
151
|
* @group Models
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
* @group Backend
|
|
21
21
|
*/
|
|
22
22
|
import type { DataDriver } from "../controllers/data_driver";
|
|
23
|
-
import type {
|
|
23
|
+
import type { CollectionConfig } from "./collections";
|
|
24
24
|
import type { CollectionRegistryInterface, DatabaseAdmin, InitializedDriver, RealtimeProvider, BootstrappedAuth } from "./backend";
|
|
25
|
+
import type { HistoryConfig } from "../controllers/client";
|
|
25
26
|
/**
|
|
26
27
|
* A `DatabaseAdapter` provides data persistence for Rebase.
|
|
27
28
|
*
|
|
@@ -59,7 +60,7 @@ export interface DatabaseAdapter {
|
|
|
59
60
|
*
|
|
60
61
|
* Return `undefined` if the database does not support history.
|
|
61
62
|
*/
|
|
62
|
-
initializeHistory?(config:
|
|
63
|
+
initializeHistory?(config: HistoryConfig, driverResult: InitializedDriver): Promise<{
|
|
63
64
|
historyService: unknown;
|
|
64
65
|
} | undefined>;
|
|
65
66
|
/**
|
|
@@ -88,7 +89,7 @@ export interface DatabaseAdapter {
|
|
|
88
89
|
*/
|
|
89
90
|
export interface DatabaseAdapterInitConfig {
|
|
90
91
|
/** Registered collection definitions. */
|
|
91
|
-
collections:
|
|
92
|
+
collections: CollectionConfig[];
|
|
92
93
|
/** The shared collection registry to register into. */
|
|
93
94
|
collectionRegistry: CollectionRegistryInterface;
|
|
94
95
|
}
|
package/dist/types/entities.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export type EntityStatus = "new" | "existing" | "copy";
|
|
6
6
|
/**
|
|
7
|
-
* Representation of
|
|
7
|
+
* Representation of a entity fetched from the driver
|
|
8
8
|
* @group Models
|
|
9
9
|
*/
|
|
10
10
|
export interface Entity<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
@@ -39,7 +39,7 @@ export interface Entity<M extends Record<string, unknown> = Record<string, unkno
|
|
|
39
39
|
*/
|
|
40
40
|
export type EntityValues<M extends Record<string, unknown>> = M;
|
|
41
41
|
/**
|
|
42
|
-
* Props for creating
|
|
42
|
+
* Props for creating a EntityReference
|
|
43
43
|
*/
|
|
44
44
|
export interface EntityReferenceProps {
|
|
45
45
|
/** ID of the entity */
|
|
@@ -52,7 +52,7 @@ export interface EntityReferenceProps {
|
|
|
52
52
|
databaseId?: string;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
* Class used to create a reference to
|
|
55
|
+
* Class used to create a reference to a entity in a different path.
|
|
56
56
|
*
|
|
57
57
|
* @example
|
|
58
58
|
* // Simple reference (most common case - single driver, single db)
|
|
@@ -86,7 +86,7 @@ export declare class EntityReference {
|
|
|
86
86
|
*/
|
|
87
87
|
readonly databaseId?: string;
|
|
88
88
|
/**
|
|
89
|
-
* Create a reference to
|
|
89
|
+
* Create a reference to a entity.
|
|
90
90
|
*
|
|
91
91
|
* @example
|
|
92
92
|
* // Simple reference (most common case)
|
|
@@ -105,7 +105,7 @@ export declare class EntityReference {
|
|
|
105
105
|
isEntityReference(): boolean;
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
|
-
* Class used to create a reference to
|
|
108
|
+
* Class used to create a reference to a entity in a different path
|
|
109
109
|
*/
|
|
110
110
|
export declare class EntityRelation {
|
|
111
111
|
readonly __type = "relation";
|
|
@@ -122,8 +122,8 @@ export declare class EntityRelation {
|
|
|
122
122
|
* Pre-fetched data payload to eliminate N+1 queries.
|
|
123
123
|
* When present, clients can use this directly instead of fetching.
|
|
124
124
|
*/
|
|
125
|
-
readonly data?:
|
|
126
|
-
constructor(id: string | number, path: string, data?:
|
|
125
|
+
readonly data?: Record<string, unknown>;
|
|
126
|
+
constructor(id: string | number, path: string, data?: Record<string, unknown>);
|
|
127
127
|
get pathWithId(): string;
|
|
128
128
|
isEntityReference(): boolean;
|
|
129
129
|
isEntityRelation(): boolean;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { Entity } from "./entities";
|
|
3
|
-
import type {
|
|
3
|
+
import type { CollectionConfig, SelectionController } from "./collections";
|
|
4
4
|
import type { FormContext } from "./entity_views";
|
|
5
5
|
import type { User } from "../users";
|
|
6
6
|
import type { RebaseContext } from "../rebase_context";
|
|
7
|
-
import type {
|
|
7
|
+
import type { SidePanelController } from "../controllers/side_panel_controller";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* A entity action is a custom action that can be performed on a entity.
|
|
10
10
|
* They are displayed in the entity view and in the collection view.
|
|
11
11
|
*/
|
|
12
12
|
export interface EntityAction<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
@@ -61,7 +61,7 @@ export type EntityActionClickProps<M extends Record<string, unknown>, USER exten
|
|
|
61
61
|
entity?: Entity<M>;
|
|
62
62
|
context?: RebaseContext<USER>;
|
|
63
63
|
path?: string;
|
|
64
|
-
collection?:
|
|
64
|
+
collection?: CollectionConfig<M>;
|
|
65
65
|
/**
|
|
66
66
|
* Optional form context, present if the action is being called from a form.
|
|
67
67
|
* This allows you to access the form state and methods, including modifying the form values.
|
|
@@ -70,7 +70,7 @@ export type EntityActionClickProps<M extends Record<string, unknown>, USER exten
|
|
|
70
70
|
/**
|
|
71
71
|
* Present if this actions is being called from a side dialog only
|
|
72
72
|
*/
|
|
73
|
-
|
|
73
|
+
sidePanelController?: SidePanelController;
|
|
74
74
|
/**
|
|
75
75
|
* Is the action being called from the collection view or from the entity form view?
|
|
76
76
|
*/
|
|
@@ -94,11 +94,11 @@ export type EntityActionClickProps<M extends Record<string, unknown>, USER exten
|
|
|
94
94
|
*/
|
|
95
95
|
unhighlightEntity?: (entity: Entity<Record<string, unknown>>) => void;
|
|
96
96
|
/**
|
|
97
|
-
* Optional function to navigate back (e.g. when deleting
|
|
97
|
+
* Optional function to navigate back (e.g. when deleting a entity or navigating from a form)
|
|
98
98
|
*/
|
|
99
99
|
navigateBack?: () => void;
|
|
100
100
|
/**
|
|
101
|
-
* Callback to be called when the collection changes, e.g. after
|
|
101
|
+
* Callback to be called when the collection changes, e.g. after a entity is deleted or created.
|
|
102
102
|
*/
|
|
103
103
|
onCollectionChange?: () => void;
|
|
104
104
|
};
|
|
@@ -1,98 +1,110 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { CollectionConfig } from "./collections";
|
|
2
|
+
import type { EntityStatus, EntityValues } from "./entities";
|
|
3
3
|
import type { User } from "../users";
|
|
4
4
|
import type { RebaseCallContext } from "../rebase_context";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Lifecycle callbacks for entity CRUD operations.
|
|
7
|
+
*
|
|
8
|
+
* Register per-collection on the collection's `callbacks` field, or globally
|
|
9
|
+
* via `initializeRebaseBackend({ callbacks })`. Fires on **every** data path — REST API,
|
|
10
|
+
* WebSocket / realtime subscriptions, and server-side `rebase.data`.
|
|
11
|
+
*
|
|
12
|
+
* When both global and per-collection callbacks are registered, execution
|
|
13
|
+
* order is: **global → collection → property callbacks**.
|
|
14
|
+
*
|
|
9
15
|
* @group Models
|
|
10
16
|
*/
|
|
11
|
-
export type
|
|
17
|
+
export type CollectionCallbacks<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = {
|
|
12
18
|
/**
|
|
13
|
-
* Callback used after fetching data
|
|
19
|
+
* Callback used after fetching data.
|
|
20
|
+
*
|
|
21
|
+
* Fires on every read path. Use this for security-critical redaction
|
|
22
|
+
* (PII masking, row filtering) — no read path bypasses it.
|
|
23
|
+
*
|
|
14
24
|
* @param props
|
|
15
25
|
*/
|
|
16
|
-
afterRead?(props:
|
|
26
|
+
afterRead?(props: AfterReadProps<M, USER>): Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
17
27
|
/**
|
|
18
28
|
* Callback used before saving, you need to return the values that will get
|
|
19
29
|
* saved. If you throw an error in this method the process stops, and an
|
|
20
|
-
* error
|
|
30
|
+
* HTTP error response is returned to the client.
|
|
21
31
|
* This runs after schema validation.
|
|
32
|
+
*
|
|
22
33
|
* @param props
|
|
23
34
|
*/
|
|
24
|
-
beforeSave?(props:
|
|
35
|
+
beforeSave?(props: BeforeSaveProps<M, USER>): Promise<Partial<EntityValues<M>>> | Partial<EntityValues<M>>;
|
|
25
36
|
/**
|
|
26
|
-
* Callback used when save is successful
|
|
37
|
+
* Callback used when save is successful.
|
|
38
|
+
*
|
|
27
39
|
* @param props
|
|
28
40
|
*/
|
|
29
|
-
afterSave?(props:
|
|
41
|
+
afterSave?(props: AfterSaveProps<M, USER>): Promise<void> | void;
|
|
30
42
|
/**
|
|
31
43
|
* Callback used when saving fails
|
|
32
44
|
* @param props
|
|
33
45
|
*/
|
|
34
|
-
afterSaveError?(props:
|
|
46
|
+
afterSaveError?(props: AfterSaveErrorProps<M, USER>): Promise<void> | void;
|
|
35
47
|
/**
|
|
36
48
|
* Callback used before the entity is deleted.
|
|
37
49
|
* If you throw an error in this method the process stops, and an
|
|
38
|
-
* error
|
|
50
|
+
* HTTP error response is returned to the client.
|
|
39
51
|
*
|
|
40
52
|
* @param props
|
|
41
53
|
*/
|
|
42
|
-
beforeDelete?(props:
|
|
54
|
+
beforeDelete?(props: BeforeDeleteProps<M, USER>): Promise<boolean | void> | boolean | void;
|
|
43
55
|
/**
|
|
44
56
|
* Callback used after the entity is deleted.
|
|
45
57
|
*
|
|
46
58
|
* @param props
|
|
47
59
|
*/
|
|
48
|
-
afterDelete?(props:
|
|
60
|
+
afterDelete?(props: AfterDeleteProps<M, USER>): Promise<void> | void;
|
|
49
61
|
};
|
|
50
62
|
/**
|
|
51
|
-
* Parameters passed to hooks when
|
|
63
|
+
* Parameters passed to hooks when a entity is fetched
|
|
52
64
|
* @group Models
|
|
53
65
|
*/
|
|
54
|
-
export interface
|
|
66
|
+
export interface AfterReadProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
55
67
|
/**
|
|
56
68
|
* Collection of the entity
|
|
57
69
|
*/
|
|
58
|
-
collection:
|
|
70
|
+
collection: CollectionConfig<M>;
|
|
59
71
|
/**
|
|
60
72
|
* Full path of the CMS where this collection is being fetched.
|
|
61
73
|
* Might contain unresolved aliases.
|
|
62
74
|
*/
|
|
63
75
|
path: string;
|
|
64
76
|
/**
|
|
65
|
-
* Fetched
|
|
77
|
+
* Fetched row (flat — `{ id, ...columns }`)
|
|
66
78
|
*/
|
|
67
|
-
|
|
79
|
+
row: Record<string, unknown>;
|
|
68
80
|
/**
|
|
69
81
|
* Context of the app status
|
|
70
82
|
*/
|
|
71
83
|
context: RebaseCallContext<USER>;
|
|
72
84
|
}
|
|
73
85
|
/**
|
|
74
|
-
* Parameters passed to hooks before
|
|
86
|
+
* Parameters passed to hooks before a entity is saved
|
|
75
87
|
* @group Models
|
|
76
88
|
*/
|
|
77
|
-
export type
|
|
78
|
-
|
|
89
|
+
export type BeforeSaveProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = Omit<AfterSaveProps<M, USER>, "id"> & {
|
|
90
|
+
id?: string | number;
|
|
79
91
|
};
|
|
80
92
|
/**
|
|
81
|
-
* Parameters passed to hooks before
|
|
93
|
+
* Parameters passed to hooks before a entity is saved
|
|
82
94
|
* @group Models
|
|
83
95
|
*/
|
|
84
|
-
export type
|
|
85
|
-
|
|
96
|
+
export type AfterSaveErrorProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = Omit<AfterSaveProps<M, USER>, "id"> & {
|
|
97
|
+
id?: string | number;
|
|
86
98
|
};
|
|
87
99
|
/**
|
|
88
|
-
* Parameters passed to hooks when
|
|
100
|
+
* Parameters passed to hooks when a entity is saved
|
|
89
101
|
* @group Models
|
|
90
102
|
*/
|
|
91
|
-
export interface
|
|
103
|
+
export interface AfterSaveProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
92
104
|
/**
|
|
93
105
|
* Resolved collection of the entity
|
|
94
106
|
*/
|
|
95
|
-
collection:
|
|
107
|
+
collection: CollectionConfig<M>;
|
|
96
108
|
/**
|
|
97
109
|
* Full path of the CMS where this entity is being saved.
|
|
98
110
|
* Might contain unresolved aliases.
|
|
@@ -101,7 +113,7 @@ export interface EntityAfterSaveProps<M extends Record<string, unknown> = Record
|
|
|
101
113
|
/**
|
|
102
114
|
* ID of the entity
|
|
103
115
|
*/
|
|
104
|
-
|
|
116
|
+
id: string | number;
|
|
105
117
|
/**
|
|
106
118
|
* Values being saved
|
|
107
119
|
*/
|
|
@@ -120,14 +132,14 @@ export interface EntityAfterSaveProps<M extends Record<string, unknown> = Record
|
|
|
120
132
|
context: RebaseCallContext<USER>;
|
|
121
133
|
}
|
|
122
134
|
/**
|
|
123
|
-
* Parameters passed to hooks when
|
|
135
|
+
* Parameters passed to hooks when a entity is deleted
|
|
124
136
|
* @group Models
|
|
125
137
|
*/
|
|
126
|
-
export interface
|
|
138
|
+
export interface BeforeDeleteProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
127
139
|
/**
|
|
128
140
|
* collection of the entity being deleted
|
|
129
141
|
*/
|
|
130
|
-
collection:
|
|
142
|
+
collection: CollectionConfig<M>;
|
|
131
143
|
/**
|
|
132
144
|
* Path of the parent collection
|
|
133
145
|
*/
|
|
@@ -135,25 +147,25 @@ export interface EntityBeforeDeleteProps<M extends Record<string, unknown> = Rec
|
|
|
135
147
|
/**
|
|
136
148
|
* Deleted entity id
|
|
137
149
|
*/
|
|
138
|
-
|
|
150
|
+
id: string | number;
|
|
139
151
|
/**
|
|
140
|
-
* Deleted
|
|
152
|
+
* Deleted row (flat — `{ id, ...columns }`)
|
|
141
153
|
*/
|
|
142
|
-
|
|
154
|
+
row: Record<string, unknown>;
|
|
143
155
|
/**
|
|
144
156
|
* Context of the app status
|
|
145
157
|
*/
|
|
146
158
|
context: RebaseCallContext<USER>;
|
|
147
159
|
}
|
|
148
160
|
/**
|
|
149
|
-
* Parameters passed to hooks after
|
|
161
|
+
* Parameters passed to hooks after a entity is deleted
|
|
150
162
|
* @group Models
|
|
151
163
|
*/
|
|
152
|
-
export interface
|
|
164
|
+
export interface AfterDeleteProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
153
165
|
/**
|
|
154
166
|
* collection of the entity being deleted
|
|
155
167
|
*/
|
|
156
|
-
collection:
|
|
168
|
+
collection: CollectionConfig<M>;
|
|
157
169
|
/**
|
|
158
170
|
* Path of the parent collection
|
|
159
171
|
*/
|
|
@@ -161,11 +173,11 @@ export interface EntityAfterDeleteProps<M extends Record<string, unknown> = Reco
|
|
|
161
173
|
/**
|
|
162
174
|
* Deleted entity id
|
|
163
175
|
*/
|
|
164
|
-
|
|
176
|
+
id: string | number;
|
|
165
177
|
/**
|
|
166
|
-
* Deleted
|
|
178
|
+
* Deleted row (flat — `{ id, ...columns }`)
|
|
167
179
|
*/
|
|
168
|
-
|
|
180
|
+
row: Record<string, unknown>;
|
|
169
181
|
/**
|
|
170
182
|
* Context of the app status
|
|
171
183
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { Entity, EntityValues } from "./entities";
|
|
3
|
-
import type {
|
|
3
|
+
import type { CollectionConfig } from "./collections";
|
|
4
4
|
import type { FormexController } from "./formex";
|
|
5
5
|
import type { ComponentRef } from "./component_ref";
|
|
6
6
|
/**
|
|
@@ -31,7 +31,7 @@ export interface FormContext<M extends Record<string, unknown> = Record<string,
|
|
|
31
31
|
/**
|
|
32
32
|
* Collection of the entity being modified
|
|
33
33
|
*/
|
|
34
|
-
collection?:
|
|
34
|
+
collection?: CollectionConfig<M>;
|
|
35
35
|
/**
|
|
36
36
|
* Entity id, it can be undefined if it's a new entity
|
|
37
37
|
*/
|
|
@@ -86,7 +86,7 @@ export type FormViewConfig<M extends Record<string, unknown> = Record<string, un
|
|
|
86
86
|
includeActions?: boolean;
|
|
87
87
|
};
|
|
88
88
|
export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
89
|
-
collection:
|
|
89
|
+
collection: CollectionConfig<M>;
|
|
90
90
|
entity?: Entity<M>;
|
|
91
91
|
modifiedValues?: EntityValues<M>;
|
|
92
92
|
formContext: FormContext<M>;
|