@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
package/src/users/user.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* and
|
|
7
|
-
*
|
|
8
|
-
*
|
|
3
|
+
* The canonical representation of an authenticated user in the Rebase ecosystem.
|
|
4
|
+
*
|
|
5
|
+
* Used by {@link AuthController}, collections, callbacks, and both the
|
|
6
|
+
* `@rebasepro/client` and `@rebasepro/auth` packages. All other user types
|
|
7
|
+
* (`RebaseUser`, `UserInfo`) are deprecated aliases of this type.
|
|
8
|
+
*
|
|
9
|
+
* **Backend-managed fields** (`uid`, `email`, `roles`, `metadata`, `createdAt`)
|
|
10
|
+
* are populated by the server. **Client-visible fields** (`displayName`,
|
|
11
|
+
* `photoURL`, `providerId`, `isAnonymous`, `emailVerified`) may be set during
|
|
12
|
+
* authentication or profile updates.
|
|
13
|
+
*
|
|
14
|
+
* @see AdminUser — the admin-API DTO, which adds audit fields (`createdAt`,
|
|
15
|
+
* `updatedAt`) and required `roles`.
|
|
9
16
|
*
|
|
10
17
|
* @group Models
|
|
11
18
|
*/
|
|
@@ -27,16 +34,22 @@ export type User = {
|
|
|
27
34
|
*/
|
|
28
35
|
readonly photoURL: string | null;
|
|
29
36
|
/**
|
|
30
|
-
* The provider used to authenticate the user.
|
|
37
|
+
* The provider used to authenticate the user (e.g. `"password"`,
|
|
38
|
+
* `"google"`, `"github"`).
|
|
31
39
|
*/
|
|
32
40
|
readonly providerId: string;
|
|
33
41
|
/**
|
|
34
|
-
*
|
|
42
|
+
* Whether the user is anonymous (created via anonymous sign-in).
|
|
35
43
|
*/
|
|
36
44
|
readonly isAnonymous: boolean;
|
|
37
45
|
|
|
38
46
|
/**
|
|
39
|
-
*
|
|
47
|
+
* Whether the user's email address has been verified.
|
|
48
|
+
*/
|
|
49
|
+
readonly emailVerified?: boolean;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Role IDs assigned to this user (e.g. `["admin", "editor"]`).
|
|
40
53
|
*/
|
|
41
54
|
roles?: string[];
|
|
42
55
|
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context passed to every backend hook.
|
|
3
|
-
* Provides information about the request that triggered the hook.
|
|
4
|
-
* @group Backend Hooks
|
|
5
|
-
*/
|
|
6
|
-
export interface BackendHookContext {
|
|
7
|
-
/** The currently authenticated user making the request (if any) */
|
|
8
|
-
requestUser?: {
|
|
9
|
-
userId: string;
|
|
10
|
-
roles: string[];
|
|
11
|
-
};
|
|
12
|
-
/** The HTTP method of the request */
|
|
13
|
-
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Hooks for intercepting collection entity data at the REST API boundary.
|
|
17
|
-
*
|
|
18
|
-
* These run **after** per-collection `EntityCallbacks` (which execute inside
|
|
19
|
-
* the DataDriver) and provide a single cross-cutting interception point for
|
|
20
|
-
* ALL collections flowing through the REST API.
|
|
21
|
-
*
|
|
22
|
-
* Every callback receives the collection `slug` so you can target specific
|
|
23
|
-
* collections or apply logic globally.
|
|
24
|
-
*
|
|
25
|
-
* @group Backend Hooks
|
|
26
|
-
*/
|
|
27
|
-
export interface DataHooks {
|
|
28
|
-
/**
|
|
29
|
-
* Transform an entity after it's read from the database,
|
|
30
|
-
* before it's returned to the client.
|
|
31
|
-
*
|
|
32
|
-
* Runs for both list (GET /:slug) and single (GET /:slug/:id) fetches.
|
|
33
|
-
* Return the modified entity, or `null` to filter it out.
|
|
34
|
-
*
|
|
35
|
-
* @param slug - The collection slug (e.g. "orders", "products")
|
|
36
|
-
* @param entity - The flattened entity object (id + values merged)
|
|
37
|
-
* @param context - Request context (authenticated user, HTTP method)
|
|
38
|
-
*/
|
|
39
|
-
afterRead?(slug: string, entity: Record<string, unknown>, context: BackendHookContext): Record<string, unknown> | null | Promise<Record<string, unknown> | null>;
|
|
40
|
-
/**
|
|
41
|
-
* Transform entity values before they are written to the database.
|
|
42
|
-
* Runs on POST (create) and PUT (update).
|
|
43
|
-
*
|
|
44
|
-
* Return the (possibly modified) values. Throw to abort the save.
|
|
45
|
-
*
|
|
46
|
-
* @param slug - The collection slug
|
|
47
|
-
* @param values - The raw request body values
|
|
48
|
-
* @param entityId - The entity ID (only present on updates)
|
|
49
|
-
* @param context - Request context
|
|
50
|
-
*/
|
|
51
|
-
beforeSave?(slug: string, values: Record<string, unknown>, entityId: string | undefined, context: BackendHookContext): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
52
|
-
/**
|
|
53
|
-
* Called after an entity is successfully saved (created or updated).
|
|
54
|
-
* Useful for side-effects like syncing to external systems.
|
|
55
|
-
*
|
|
56
|
-
* @param slug - The collection slug
|
|
57
|
-
* @param entity - The saved entity (flattened)
|
|
58
|
-
* @param context - Request context
|
|
59
|
-
*/
|
|
60
|
-
afterSave?(slug: string, entity: Record<string, unknown>, context: BackendHookContext): void | Promise<void>;
|
|
61
|
-
/**
|
|
62
|
-
* Called before an entity is deleted. Throw to prevent deletion.
|
|
63
|
-
*
|
|
64
|
-
* @param slug - The collection slug
|
|
65
|
-
* @param entityId - The entity ID being deleted
|
|
66
|
-
* @param context - Request context
|
|
67
|
-
*/
|
|
68
|
-
beforeDelete?(slug: string, entityId: string, context: BackendHookContext): void | Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* Called after an entity is successfully deleted.
|
|
71
|
-
*
|
|
72
|
-
* @param slug - The collection slug
|
|
73
|
-
* @param entityId - The deleted entity ID
|
|
74
|
-
* @param context - Request context
|
|
75
|
-
*/
|
|
76
|
-
afterDelete?(slug: string, entityId: string, context: BackendHookContext): void | Promise<void>;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Backend-level hooks for intercepting data at the API boundary.
|
|
80
|
-
*
|
|
81
|
-
* These hooks run server-side after database operations complete and before
|
|
82
|
-
* API responses are sent.
|
|
83
|
-
*
|
|
84
|
-
* `data` hooks complement per-collection `EntityCallbacks`. Entity callbacks
|
|
85
|
-
* run inside the DataDriver (close to the DB); data hooks run at the HTTP
|
|
86
|
-
* boundary (close to the client). Use data hooks for cross-cutting concerns
|
|
87
|
-
* like audit logging, response enrichment, or field masking.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```typescript
|
|
91
|
-
* const hooks: BackendHooks = {
|
|
92
|
-
* data: {
|
|
93
|
-
* afterRead(slug, entity, ctx) {
|
|
94
|
-
* // Mask PII for non-admin users across all collections
|
|
95
|
-
* if (!ctx.requestUser?.roles.includes("admin") && entity.email) {
|
|
96
|
-
* return { ...entity, email: "***" };
|
|
97
|
-
* }
|
|
98
|
-
* return entity;
|
|
99
|
-
* }
|
|
100
|
-
* }
|
|
101
|
-
* };
|
|
102
|
-
* ```
|
|
103
|
-
*
|
|
104
|
-
* @group Backend Hooks
|
|
105
|
-
*/
|
|
106
|
-
export interface BackendHooks {
|
|
107
|
-
/** Hooks for intercepting ALL collection entity data via the REST API */
|
|
108
|
-
data?: DataHooks;
|
|
109
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { DataDriver } from "../controllers/data_driver";
|
|
2
|
-
import type { StorageSource } from "../controllers/storage";
|
|
3
|
-
export type EntityOverrides = {
|
|
4
|
-
/**
|
|
5
|
-
* Internal driver override for this collection.
|
|
6
|
-
* Used by the CMS engine to route data operations.
|
|
7
|
-
*/
|
|
8
|
-
driver?: DataDriver;
|
|
9
|
-
storageSource?: StorageSource;
|
|
10
|
-
};
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Context passed to every backend hook.
|
|
4
|
-
* Provides information about the request that triggered the hook.
|
|
5
|
-
* @group Backend Hooks
|
|
6
|
-
*/
|
|
7
|
-
export interface BackendHookContext {
|
|
8
|
-
/** The currently authenticated user making the request (if any) */
|
|
9
|
-
requestUser?: { userId: string; roles: string[] };
|
|
10
|
-
/** The HTTP method of the request */
|
|
11
|
-
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Hooks for intercepting collection entity data at the REST API boundary.
|
|
17
|
-
*
|
|
18
|
-
* These run **after** per-collection `EntityCallbacks` (which execute inside
|
|
19
|
-
* the DataDriver) and provide a single cross-cutting interception point for
|
|
20
|
-
* ALL collections flowing through the REST API.
|
|
21
|
-
*
|
|
22
|
-
* Every callback receives the collection `slug` so you can target specific
|
|
23
|
-
* collections or apply logic globally.
|
|
24
|
-
*
|
|
25
|
-
* @group Backend Hooks
|
|
26
|
-
*/
|
|
27
|
-
export interface DataHooks {
|
|
28
|
-
/**
|
|
29
|
-
* Transform an entity after it's read from the database,
|
|
30
|
-
* before it's returned to the client.
|
|
31
|
-
*
|
|
32
|
-
* Runs for both list (GET /:slug) and single (GET /:slug/:id) fetches.
|
|
33
|
-
* Return the modified entity, or `null` to filter it out.
|
|
34
|
-
*
|
|
35
|
-
* @param slug - The collection slug (e.g. "orders", "products")
|
|
36
|
-
* @param entity - The flattened entity object (id + values merged)
|
|
37
|
-
* @param context - Request context (authenticated user, HTTP method)
|
|
38
|
-
*/
|
|
39
|
-
afterRead?(slug: string, entity: Record<string, unknown>, context: BackendHookContext): Record<string, unknown> | null | Promise<Record<string, unknown> | null>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Transform entity values before they are written to the database.
|
|
43
|
-
* Runs on POST (create) and PUT (update).
|
|
44
|
-
*
|
|
45
|
-
* Return the (possibly modified) values. Throw to abort the save.
|
|
46
|
-
*
|
|
47
|
-
* @param slug - The collection slug
|
|
48
|
-
* @param values - The raw request body values
|
|
49
|
-
* @param entityId - The entity ID (only present on updates)
|
|
50
|
-
* @param context - Request context
|
|
51
|
-
*/
|
|
52
|
-
beforeSave?(slug: string, values: Record<string, unknown>, entityId: string | undefined, context: BackendHookContext): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Called after an entity is successfully saved (created or updated).
|
|
56
|
-
* Useful for side-effects like syncing to external systems.
|
|
57
|
-
*
|
|
58
|
-
* @param slug - The collection slug
|
|
59
|
-
* @param entity - The saved entity (flattened)
|
|
60
|
-
* @param context - Request context
|
|
61
|
-
*/
|
|
62
|
-
afterSave?(slug: string, entity: Record<string, unknown>, context: BackendHookContext): void | Promise<void>;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Called before an entity is deleted. Throw to prevent deletion.
|
|
66
|
-
*
|
|
67
|
-
* @param slug - The collection slug
|
|
68
|
-
* @param entityId - The entity ID being deleted
|
|
69
|
-
* @param context - Request context
|
|
70
|
-
*/
|
|
71
|
-
beforeDelete?(slug: string, entityId: string, context: BackendHookContext): void | Promise<void>;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Called after an entity is successfully deleted.
|
|
75
|
-
*
|
|
76
|
-
* @param slug - The collection slug
|
|
77
|
-
* @param entityId - The deleted entity ID
|
|
78
|
-
* @param context - Request context
|
|
79
|
-
*/
|
|
80
|
-
afterDelete?(slug: string, entityId: string, context: BackendHookContext): void | Promise<void>;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Backend-level hooks for intercepting data at the API boundary.
|
|
85
|
-
*
|
|
86
|
-
* These hooks run server-side after database operations complete and before
|
|
87
|
-
* API responses are sent.
|
|
88
|
-
*
|
|
89
|
-
* `data` hooks complement per-collection `EntityCallbacks`. Entity callbacks
|
|
90
|
-
* run inside the DataDriver (close to the DB); data hooks run at the HTTP
|
|
91
|
-
* boundary (close to the client). Use data hooks for cross-cutting concerns
|
|
92
|
-
* like audit logging, response enrichment, or field masking.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```typescript
|
|
96
|
-
* const hooks: BackendHooks = {
|
|
97
|
-
* data: {
|
|
98
|
-
* afterRead(slug, entity, ctx) {
|
|
99
|
-
* // Mask PII for non-admin users across all collections
|
|
100
|
-
* if (!ctx.requestUser?.roles.includes("admin") && entity.email) {
|
|
101
|
-
* return { ...entity, email: "***" };
|
|
102
|
-
* }
|
|
103
|
-
* return entity;
|
|
104
|
-
* }
|
|
105
|
-
* }
|
|
106
|
-
* };
|
|
107
|
-
* ```
|
|
108
|
-
*
|
|
109
|
-
* @group Backend Hooks
|
|
110
|
-
*/
|
|
111
|
-
export interface BackendHooks {
|
|
112
|
-
/** Hooks for intercepting ALL collection entity data via the REST API */
|
|
113
|
-
data?: DataHooks;
|
|
114
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { DataDriver } from "../controllers/data_driver";
|
|
2
|
-
import type { StorageSource } from "../controllers/storage";
|
|
3
|
-
|
|
4
|
-
export type EntityOverrides = {
|
|
5
|
-
/**
|
|
6
|
-
* Internal driver override for this collection.
|
|
7
|
-
* Used by the CMS engine to route data operations.
|
|
8
|
-
*/
|
|
9
|
-
driver?: DataDriver;
|
|
10
|
-
storageSource?: StorageSource;
|
|
11
|
-
};
|