@rebasepro/types 0.3.0 → 0.4.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/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 +2 -2
- package/dist/types/backend_hooks.d.ts +2 -17
- package/dist/types/collections.d.ts +9 -5
- package/dist/types/entity_views.d.ts +19 -28
- package/dist/types/properties.d.ts +9 -7
- 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 +2 -2
- package/src/types/backend_hooks.ts +2 -18
- package/src/types/collections.ts +9 -5
- package/src/types/entity_views.tsx +19 -29
- package/src/types/properties.ts +20 -31
- 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
|
@@ -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)
|
|
@@ -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