@rebasepro/types 0.3.0 → 0.5.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 +83 -232
- package/dist/controllers/auth.d.ts +2 -2
- package/dist/controllers/client.d.ts +25 -40
- package/dist/controllers/data.d.ts +21 -3
- package/dist/controllers/data_driver.d.ts +5 -0
- package/dist/controllers/email.d.ts +2 -0
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/auth_adapter.d.ts +3 -56
- package/dist/types/backend.d.ts +38 -3
- package/dist/types/backend_hooks.d.ts +2 -17
- package/dist/types/collections.d.ts +30 -6
- package/dist/types/entity_views.d.ts +19 -28
- package/dist/types/properties.d.ts +9 -15
- package/dist/types/user_management_delegate.d.ts +16 -53
- package/dist/users/index.d.ts +0 -1
- package/dist/users/user.d.ts +0 -1
- package/package.json +1 -1
- package/src/controllers/auth.tsx +2 -2
- package/src/controllers/client.ts +23 -22
- package/src/controllers/data.ts +26 -3
- package/src/controllers/data_driver.ts +6 -0
- package/src/controllers/email.ts +2 -0
- package/src/types/auth_adapter.ts +5 -63
- package/src/types/backend.ts +41 -3
- package/src/types/backend_hooks.ts +2 -18
- package/src/types/collections.ts +31 -6
- package/src/types/entity_views.tsx +19 -29
- package/src/types/properties.ts +20 -40
- package/src/types/user_management_delegate.ts +16 -67
- package/src/users/index.ts +1 -1
- package/src/users/user.ts +0 -1
- package/dist/users/roles.d.ts +0 -14
- package/src/users/roles.ts +0 -22
package/src/types/backend.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Entity } from "./entities";
|
|
2
2
|
import type { EntityCollection, FilterValues, WhereFilterOp } from "./collections";
|
|
3
|
+
import type { AuthAdapter } from "./auth_adapter";
|
|
3
4
|
|
|
4
5
|
// =============================================================================
|
|
5
6
|
// DATABASE CONNECTION INTERFACES
|
|
@@ -281,6 +282,24 @@ export interface RealtimeProvider {
|
|
|
281
282
|
entity: Entity | null,
|
|
282
283
|
databaseId?: string
|
|
283
284
|
): Promise<void>;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Called when the HTTP server is ready and listening.
|
|
288
|
+
* Useful for providers that need the server address for callbacks.
|
|
289
|
+
*/
|
|
290
|
+
onServerReady?(serverInfo: { port: number; hostname?: string }): void;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Gracefully shut down the realtime provider.
|
|
294
|
+
* Called during server shutdown to clean up resources.
|
|
295
|
+
*/
|
|
296
|
+
destroy?(): Promise<void>;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Stop the internal LISTEN client (e.g., PostgreSQL LISTEN/NOTIFY).
|
|
300
|
+
* Called during graceful shutdown before closing database connections.
|
|
301
|
+
*/
|
|
302
|
+
stopListening?(): Promise<void>;
|
|
284
303
|
}
|
|
285
304
|
|
|
286
305
|
// =============================================================================
|
|
@@ -638,6 +657,25 @@ export interface BackendBootstrapper {
|
|
|
638
657
|
*/
|
|
639
658
|
type: string;
|
|
640
659
|
|
|
660
|
+
/**
|
|
661
|
+
* Unique identifier for this bootstrapper instance.
|
|
662
|
+
* Used to register the driver in the driver registry.
|
|
663
|
+
* Defaults to `type` if not set.
|
|
664
|
+
*/
|
|
665
|
+
id?: string;
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Whether this bootstrapper provides the default driver.
|
|
669
|
+
* When true, the coordinator uses this driver as the primary one.
|
|
670
|
+
*/
|
|
671
|
+
isDefault?: boolean;
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Run database migrations for this driver.
|
|
675
|
+
* Called by the coordinator after all drivers are initialized.
|
|
676
|
+
*/
|
|
677
|
+
runMigrations?(config: unknown, driverResult: InitializedDriver): Promise<void>;
|
|
678
|
+
|
|
641
679
|
/**
|
|
642
680
|
* Create a DataDriver from the given config.
|
|
643
681
|
* This is the only **required** method.
|
|
@@ -676,7 +714,7 @@ export interface BackendBootstrapper {
|
|
|
676
714
|
/**
|
|
677
715
|
* Initialize WebSocket server for realtime operations.
|
|
678
716
|
*/
|
|
679
|
-
initializeWebsockets?(server: unknown, realtimeService: RealtimeProvider, driver: import("../controllers/data_driver").DataDriver, config?: unknown): Promise<void> | void;
|
|
717
|
+
initializeWebsockets?(server: unknown, realtimeService: RealtimeProvider, driver: import("../controllers/data_driver").DataDriver, config?: unknown, authAdapter?: AuthAdapter): Promise<void> | void;
|
|
680
718
|
}
|
|
681
719
|
|
|
682
720
|
/**
|
|
@@ -711,8 +749,8 @@ export interface InitializedDriver {
|
|
|
711
749
|
export interface BootstrappedAuth {
|
|
712
750
|
/** User management service. */
|
|
713
751
|
userService: unknown;
|
|
714
|
-
/** Role management service. */
|
|
715
|
-
roleService
|
|
752
|
+
/** Role management service (optional, roles are now simple strings). */
|
|
753
|
+
roleService?: unknown;
|
|
716
754
|
/** Email service (optional). */
|
|
717
755
|
emailService?: unknown;
|
|
718
756
|
/** Combined Auth Repository for unified token and user management. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AdminUser
|
|
1
|
+
import type { AdminUser } from "../controllers/client";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Context passed to every backend hook.
|
|
@@ -56,20 +56,6 @@ export interface UserHooks {
|
|
|
56
56
|
afterDelete?(userId: string, context: BackendHookContext): void | Promise<void>;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
/**
|
|
60
|
-
* Hooks for intercepting Admin Role data at the API boundary.
|
|
61
|
-
* @group Backend Hooks
|
|
62
|
-
*/
|
|
63
|
-
export interface RoleHooks {
|
|
64
|
-
/**
|
|
65
|
-
* Transform a role record after it's read from the database,
|
|
66
|
-
* before it's returned to the client.
|
|
67
|
-
*
|
|
68
|
-
* Return the modified role, or `null` to filter it out entirely.
|
|
69
|
-
*/
|
|
70
|
-
afterRead?(role: AdminRole, context: BackendHookContext): AdminRole | null | Promise<AdminRole | null>;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
59
|
/**
|
|
74
60
|
* Hooks for intercepting collection entity data at the REST API boundary.
|
|
75
61
|
*
|
|
@@ -144,7 +130,7 @@ export interface DataHooks {
|
|
|
144
130
|
* These hooks run server-side after database operations complete and before
|
|
145
131
|
* API responses are sent.
|
|
146
132
|
*
|
|
147
|
-
* - `users`
|
|
133
|
+
* - `users` — intercept admin user management endpoints
|
|
148
134
|
* - `data` — intercept ALL collection entity data flowing through the REST API
|
|
149
135
|
*
|
|
150
136
|
* `data` hooks complement per-collection `EntityCallbacks`. Entity callbacks
|
|
@@ -178,8 +164,6 @@ export interface DataHooks {
|
|
|
178
164
|
export interface BackendHooks {
|
|
179
165
|
/** Hooks for intercepting user management data */
|
|
180
166
|
users?: UserHooks;
|
|
181
|
-
/** Hooks for intercepting role management data */
|
|
182
|
-
roles?: RoleHooks;
|
|
183
167
|
/** Hooks for intercepting ALL collection entity data via the REST API */
|
|
184
168
|
data?: DataHooks;
|
|
185
169
|
}
|
package/src/types/collections.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { EntityOverrides } from "./entity_overrides";
|
|
|
8
8
|
import type { User } from "../users";
|
|
9
9
|
import type { RebaseContext } from "../rebase_context";
|
|
10
10
|
import type { Relation } from "./relations";
|
|
11
|
-
import type { EntityCustomView,
|
|
11
|
+
import type { EntityCustomView, FormViewConfig } from "./entity_views";
|
|
12
12
|
import type { EntityAction } from "./entity_actions";
|
|
13
13
|
import type { ComponentRef } from "./component_ref";
|
|
14
14
|
|
|
@@ -144,10 +144,14 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
144
144
|
defaultEntityAction?: "view" | "edit";
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
147
|
+
* Replace the default entity form with a custom component.
|
|
148
|
+
* The Builder receives the same props as entity view tabs
|
|
149
|
+
* (entity, formContext, collection, etc.) and has full control over the UI.
|
|
150
|
+
*
|
|
151
|
+
* Works in both edit mode and read-only mode (when `defaultEntityAction`
|
|
152
|
+
* is `"view"`). In read-only mode, `formContext.readOnly` will be `true`.
|
|
149
153
|
*/
|
|
150
|
-
|
|
154
|
+
formView?: FormViewConfig;
|
|
151
155
|
|
|
152
156
|
/**
|
|
153
157
|
* Prevent default actions from being displayed or executed on this collection.
|
|
@@ -395,7 +399,25 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
395
399
|
*/
|
|
396
400
|
Actions?: ComponentRef<CollectionActionsProps>[];
|
|
397
401
|
|
|
402
|
+
/**
|
|
403
|
+
* The database table name for this collection.
|
|
404
|
+
* Automatically set for PostgreSQL collections.
|
|
405
|
+
* For non-SQL backends, this may be undefined.
|
|
406
|
+
*/
|
|
407
|
+
table?: string;
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Relations defined for this collection.
|
|
411
|
+
* Populated at normalization time from inline relation properties
|
|
412
|
+
* or explicit relation definitions.
|
|
413
|
+
*/
|
|
414
|
+
relations?: Relation[];
|
|
398
415
|
|
|
416
|
+
/**
|
|
417
|
+
* Security rules for this collection (Row Level Security).
|
|
418
|
+
* When defined, the backend enforces access control policies.
|
|
419
|
+
*/
|
|
420
|
+
securityRules?: SecurityRule[];
|
|
399
421
|
}
|
|
400
422
|
|
|
401
423
|
// ── Driver-specific collection types ──────────────────────────────────
|
|
@@ -513,7 +535,10 @@ export type EntityCollection<M extends Record<string, unknown> = Record<string,
|
|
|
513
535
|
// Use these after a `getDataSourceCapabilities()` guard to safely access
|
|
514
536
|
// driver-specific fields without coupling to a concrete driver type.
|
|
515
537
|
|
|
516
|
-
/**
|
|
538
|
+
/**
|
|
539
|
+
* An EntityCollection that supports SQL-style relations (e.g. Postgres).
|
|
540
|
+
* @deprecated Use `EntityCollection` directly — `table`, `relations`, and `securityRules` are now on `BaseEntityCollection`.
|
|
541
|
+
*/
|
|
517
542
|
export type CollectionWithRelations<M extends Record<string, unknown> = Record<string, unknown>> =
|
|
518
543
|
EntityCollection<M> & { table?: string; relations?: Relation[]; securityRules?: SecurityRule[] };
|
|
519
544
|
|
|
@@ -689,7 +714,7 @@ export type WhereFilterOp =
|
|
|
689
714
|
* @group Models
|
|
690
715
|
*/
|
|
691
716
|
export type FilterValues<Key extends string> =
|
|
692
|
-
Partial<Record<Key, [WhereFilterOp, unknown]>>;
|
|
717
|
+
Partial<Record<Key, [WhereFilterOp, unknown] | [WhereFilterOp, unknown][]>>;
|
|
693
718
|
|
|
694
719
|
/**
|
|
695
720
|
* A pre-defined filter preset for quick access in the collection toolbar.
|
|
@@ -73,43 +73,33 @@ export type EntityCustomView<M extends Record<string, unknown> = Record<string,
|
|
|
73
73
|
position?: "start" | "end";
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
77
|
-
collection: EntityCollection<M>;
|
|
78
|
-
entity?: Entity<M>;
|
|
79
|
-
modifiedValues?: EntityValues<M>;
|
|
80
|
-
formContext: FormContext<M>;
|
|
81
|
-
parentCollectionSlugs?: string[];
|
|
82
|
-
parentEntityIds?: string[];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
76
|
/**
|
|
86
|
-
* Configuration
|
|
87
|
-
*
|
|
77
|
+
* Configuration to replace the default entity form with a custom component.
|
|
78
|
+
* The Builder receives the same props as entity view tabs (entity, formContext, etc.)
|
|
79
|
+
* and has full control over the UI.
|
|
80
|
+
*
|
|
81
|
+
* The form tab still appears in the tab bar but renders your Builder
|
|
82
|
+
* instead of the auto-generated field form.
|
|
83
|
+
*
|
|
88
84
|
* @group Models
|
|
89
85
|
*/
|
|
90
|
-
export type
|
|
91
|
-
/**
|
|
92
|
-
* Custom component rendered above the property display in the detail view.
|
|
93
|
-
*/
|
|
94
|
-
Header?: ComponentRef<EntityDetailViewParams<M>>;
|
|
86
|
+
export type FormViewConfig<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
95
87
|
/**
|
|
96
|
-
* Custom component
|
|
88
|
+
* Custom component that replaces the default form.
|
|
97
89
|
*/
|
|
98
|
-
|
|
90
|
+
Builder: ComponentRef<EntityCustomViewParams<M>>;
|
|
99
91
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
92
|
+
* If true, the save/delete action bar is rendered alongside the custom view.
|
|
93
|
+
* Defaults to true.
|
|
102
94
|
*/
|
|
103
|
-
|
|
95
|
+
includeActions?: boolean;
|
|
104
96
|
};
|
|
105
97
|
|
|
106
|
-
|
|
107
|
-
* Props passed to detail view customization components (Header, Footer, Builder).
|
|
108
|
-
* @group Models
|
|
109
|
-
*/
|
|
110
|
-
export interface EntityDetailViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
98
|
+
export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
111
99
|
collection: EntityCollection<M>;
|
|
112
|
-
entity
|
|
113
|
-
|
|
114
|
-
|
|
100
|
+
entity?: Entity<M>;
|
|
101
|
+
modifiedValues?: EntityValues<M>;
|
|
102
|
+
formContext: FormContext<M>;
|
|
103
|
+
parentCollectionSlugs?: string[];
|
|
104
|
+
parentEntityIds?: string[];
|
|
115
105
|
}
|
package/src/types/properties.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
1
|
import type { ComponentRef } from "./component_ref";
|
|
4
2
|
|
|
5
|
-
import type { EntityReference, EntityRelation, EntityValues, GeoPoint,
|
|
6
|
-
import type {
|
|
3
|
+
import type { Entity, EntityReference, EntityRelation, EntityValues, GeoPoint, Vector } from "./entities";
|
|
4
|
+
import type { JoinStep, OnAction, Relation } from "./relations";
|
|
7
5
|
import type { EntityCollection, FilterValues } from "./collections";
|
|
8
6
|
import type { ColorKey, ColorScheme } from "./chips";
|
|
9
7
|
import type { AuthController } from "../controllers/auth";
|
|
10
8
|
import type { EntityAfterReadProps, EntityBeforeSaveProps } from "./entity_callbacks";
|
|
11
9
|
import type { User } from "../users";
|
|
12
|
-
import type { RebaseContext } from "../rebase_context";
|
|
13
10
|
|
|
14
11
|
/**
|
|
15
12
|
* Callbacks/Hooks for individual property fields
|
|
@@ -24,7 +21,6 @@ export type PropertyCallbacks<T = unknown, M extends Record<string, unknown> = R
|
|
|
24
21
|
entity: Entity<M> | undefined;
|
|
25
22
|
}): Promise<T> | T;
|
|
26
23
|
|
|
27
|
-
|
|
28
24
|
/**
|
|
29
25
|
* Callback used before saving, after validation.
|
|
30
26
|
* You can modify the value before it's saved.
|
|
@@ -85,17 +81,17 @@ export type FirebaseProperties = {
|
|
|
85
81
|
*/
|
|
86
82
|
export type InferPropertyType<P extends Property> =
|
|
87
83
|
P extends StringProperty ? string :
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
84
|
+
P extends NumberProperty ? number :
|
|
85
|
+
P extends BooleanProperty ? boolean :
|
|
86
|
+
P extends DateProperty ? Date :
|
|
87
|
+
P extends GeopointProperty ? GeoPoint :
|
|
88
|
+
P extends ReferenceProperty ? EntityReference :
|
|
89
|
+
P extends RelationProperty ? EntityRelation | EntityRelation[] :
|
|
90
|
+
P extends ArrayProperty ? (P["of"] extends Property ? InferPropertyType<P["of"]>[] : unknown[]) :
|
|
91
|
+
P extends MapProperty ? (P["properties"] extends Properties ? InferEntityType<P["properties"]> : Record<string, unknown>) :
|
|
92
|
+
P extends VectorProperty ? Vector :
|
|
93
|
+
P extends BinaryProperty ? string :
|
|
94
|
+
never;
|
|
99
95
|
|
|
100
96
|
/**
|
|
101
97
|
* Helper type that determines whether a property is required.
|
|
@@ -152,8 +148,8 @@ export interface BaseUIConfig<CustomProps = unknown> {
|
|
|
152
148
|
disabled?: boolean | PropertyDisabledConfig;
|
|
153
149
|
widthPercentage?: number;
|
|
154
150
|
customProps?: CustomProps;
|
|
155
|
-
Field?: ComponentRef
|
|
156
|
-
Preview?: ComponentRef
|
|
151
|
+
Field?: ComponentRef<any>;
|
|
152
|
+
Preview?: ComponentRef<any>;
|
|
157
153
|
}
|
|
158
154
|
|
|
159
155
|
export interface BaseProperty<CustomProps = unknown> {
|
|
@@ -189,10 +185,6 @@ export interface BaseProperty<CustomProps = unknown> {
|
|
|
189
185
|
*/
|
|
190
186
|
columnName?: string;
|
|
191
187
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
188
|
/**
|
|
197
189
|
* Rules for validating this property
|
|
198
190
|
*/
|
|
@@ -203,9 +195,6 @@ export interface BaseProperty<CustomProps = unknown> {
|
|
|
203
195
|
*/
|
|
204
196
|
defaultValue?: unknown;
|
|
205
197
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
198
|
/**
|
|
210
199
|
* Use this to define dynamic properties that change based on certain conditions
|
|
211
200
|
* or on the entity's values. For example, you can make a field read-only if
|
|
@@ -232,7 +221,6 @@ export interface BaseProperty<CustomProps = unknown> {
|
|
|
232
221
|
*/
|
|
233
222
|
callbacks?: PropertyCallbacks;
|
|
234
223
|
|
|
235
|
-
|
|
236
224
|
}
|
|
237
225
|
|
|
238
226
|
/**
|
|
@@ -253,7 +241,7 @@ export interface StringProperty extends BaseProperty {
|
|
|
253
241
|
* Optional database column type. If not set, it defaults to `varchar` or `uuid` depending on `isId` configuration.
|
|
254
242
|
* Use `text` for strings with unbound length, `char` for fixed-length strings, or `varchar` for variable-length strings with a limit.
|
|
255
243
|
*/
|
|
256
|
-
columnType?: "varchar" | "text" | "char";
|
|
244
|
+
columnType?: "varchar" | "text" | "char" | "uuid";
|
|
257
245
|
/**
|
|
258
246
|
* Rules for validating this property
|
|
259
247
|
*/
|
|
@@ -325,7 +313,6 @@ export interface StringProperty extends BaseProperty {
|
|
|
325
313
|
*/
|
|
326
314
|
previewAsTag?: boolean;
|
|
327
315
|
|
|
328
|
-
|
|
329
316
|
/**
|
|
330
317
|
* You can use this property (a string) to behave as a reference to another
|
|
331
318
|
* collection. The stored value is the ID of the entity in the
|
|
@@ -655,9 +642,11 @@ export interface ArrayProperty extends BaseProperty {
|
|
|
655
642
|
ui?: ArrayUIConfig;
|
|
656
643
|
type: "array";
|
|
657
644
|
/**
|
|
658
|
-
* Optional database column type.
|
|
645
|
+
* Optional database column type. By default, maps to a native Postgres array
|
|
646
|
+
* (e.g. `text[]`, `integer[]`/`numeric[]`, `boolean[]`) if the element type
|
|
647
|
+
* is a primitive, otherwise defaults to `jsonb`.
|
|
659
648
|
*/
|
|
660
|
-
columnType?: "json" | "jsonb";
|
|
649
|
+
columnType?: "json" | "jsonb" | "text[]" | "integer[]" | "boolean[]" | "numeric[]";
|
|
661
650
|
/**
|
|
662
651
|
* The property of this array.
|
|
663
652
|
* You can specify any property (except another Array property)
|
|
@@ -756,15 +745,6 @@ export interface MapProperty extends BaseProperty {
|
|
|
756
745
|
* Properties that are displayed when rendered as a preview
|
|
757
746
|
*/
|
|
758
747
|
previewProperties?: string[];
|
|
759
|
-
/**
|
|
760
|
-
* Allow the user to add only some keys in this map.
|
|
761
|
-
* By default, all properties of the map have the corresponding field in
|
|
762
|
-
* the form view. Setting this flag to true allows to pick only some.
|
|
763
|
-
* Useful for map that can have a lot of sub-properties that may not be
|
|
764
|
-
* needed
|
|
765
|
-
*/
|
|
766
|
-
pickOnlySomeKeys?: boolean;
|
|
767
|
-
|
|
768
748
|
/**
|
|
769
749
|
* Render this map as a key-value table that allows to use
|
|
770
750
|
* arbitrary keys. You don't need to define the properties in this case.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { User } from "../users";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Result of creating a new user via admin flow.
|
|
@@ -18,60 +18,45 @@ export interface UserCreationResult<USER extends User = User> {
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* Delegate to manage
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* Delegate to manage auth-specific user operations.
|
|
22
|
+
*
|
|
23
|
+
* This interface allows the CMS to be agnostic of the underlying
|
|
24
|
+
* authentication provider or backend. User/role CRUD is now handled
|
|
25
|
+
* by the collection system; this delegate only exposes auth-specific
|
|
26
|
+
* operations (password hashing, invitations, bootstrap).
|
|
24
27
|
*
|
|
25
28
|
* @group Models
|
|
26
29
|
*/
|
|
27
30
|
export interface UserManagementDelegate<USER extends User = User> {
|
|
28
31
|
|
|
29
32
|
/**
|
|
30
|
-
* Are
|
|
33
|
+
* Are auth-related operations currently loading?
|
|
31
34
|
*/
|
|
32
35
|
loading: boolean;
|
|
33
36
|
|
|
34
37
|
/**
|
|
35
|
-
*
|
|
38
|
+
* In-memory list of users (used for client-side filtering fallback).
|
|
36
39
|
*/
|
|
37
|
-
users
|
|
40
|
+
users?: USER[];
|
|
38
41
|
|
|
39
42
|
/**
|
|
40
|
-
*
|
|
43
|
+
* Error from fetching the users list, if any.
|
|
41
44
|
*/
|
|
42
45
|
usersError?: Error;
|
|
43
46
|
|
|
44
47
|
/**
|
|
45
|
-
*
|
|
46
|
-
* user information when assigning ownership of an entity.
|
|
47
|
-
* @param uid
|
|
48
|
-
*/
|
|
49
|
-
getUser: (uid: string) => USER | null;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Search users with server-side pagination.
|
|
53
|
-
* When provided, the CMS will use this for the users table
|
|
54
|
-
* instead of loading all users into memory.
|
|
48
|
+
* Look up a single user by UID from the in-memory cache.
|
|
55
49
|
*/
|
|
56
|
-
|
|
57
|
-
search?: string;
|
|
58
|
-
limit?: number;
|
|
59
|
-
offset?: number;
|
|
60
|
-
orderBy?: string;
|
|
61
|
-
orderDir?: "asc" | "desc";
|
|
62
|
-
roleId?: string;
|
|
63
|
-
}) => Promise<{ users: USER[]; total: number }>;
|
|
50
|
+
getUser?: (uid: string) => USER | null;
|
|
64
51
|
|
|
65
52
|
/**
|
|
66
|
-
*
|
|
67
|
-
* @param user
|
|
53
|
+
* Server-side user search with pagination.
|
|
68
54
|
*/
|
|
69
|
-
|
|
55
|
+
searchUsers?: (params: { search?: string; limit?: number; offset?: number }) => Promise<{ users: USER[]; total: number }>;
|
|
70
56
|
|
|
71
57
|
/**
|
|
72
58
|
* Create a new user with invitation/password generation support.
|
|
73
59
|
* Returns additional info about how the credentials were delivered.
|
|
74
|
-
* Falls back to saveUser if not provided.
|
|
75
60
|
*/
|
|
76
61
|
createUser?: (user: USER) => Promise<UserCreationResult<USER>>;
|
|
77
62
|
|
|
@@ -82,52 +67,16 @@ export interface UserManagementDelegate<USER extends User = User> {
|
|
|
82
67
|
*/
|
|
83
68
|
resetPassword?: (user: USER) => Promise<UserCreationResult<USER>>;
|
|
84
69
|
|
|
85
|
-
/**
|
|
86
|
-
* Delete a user
|
|
87
|
-
* @param user
|
|
88
|
-
*/
|
|
89
|
-
deleteUser?: (user: USER) => Promise<void>;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* List of roles defined in the CMS.
|
|
93
|
-
*/
|
|
94
|
-
roles?: Role[];
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Optional error if roles failed to load.
|
|
98
|
-
*/
|
|
99
|
-
rolesError?: Error;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Save a role (create or update)
|
|
103
|
-
* @param role
|
|
104
|
-
*/
|
|
105
|
-
saveRole?: (role: Role) => Promise<void>;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Delete a role
|
|
109
|
-
* @param role
|
|
110
|
-
*/
|
|
111
|
-
deleteRole?: (role: Role) => Promise<void>;
|
|
112
|
-
|
|
113
70
|
/**
|
|
114
71
|
* Is the currently logged in user an admin?
|
|
115
72
|
*/
|
|
116
73
|
isAdmin?: boolean;
|
|
117
74
|
|
|
118
|
-
/**
|
|
119
|
-
* If true, the UI will allow the user to create the default roles (admin, editor, viewer).
|
|
120
|
-
*/
|
|
121
|
-
allowDefaultRolesCreation?: boolean;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
75
|
/**
|
|
127
76
|
* Optionally define roles for a given user. This is useful when the roles
|
|
128
77
|
* are coming from a separate provider than the one issuing the tokens.
|
|
129
78
|
*/
|
|
130
|
-
defineRolesFor?: (user: USER) => Promise<
|
|
79
|
+
defineRolesFor?: (user: USER) => Promise<string[] | undefined> | string[] | undefined;
|
|
131
80
|
|
|
132
81
|
/**
|
|
133
82
|
* Whether any admin users exist. Used by the bootstrap banner to decide
|
package/src/users/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./user";
|
|
2
|
-
|
|
2
|
+
|
package/src/users/user.ts
CHANGED
package/dist/users/roles.d.ts
DELETED
package/src/users/roles.ts
DELETED