@rebasepro/types 0.10.0 → 0.10.1-canary.0a881d4

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.
Files changed (96) hide show
  1. package/dist/call_context.d.ts +51 -0
  2. package/dist/controllers/auth_state.d.ts +23 -0
  3. package/dist/controllers/client.d.ts +3 -1
  4. package/dist/controllers/collection_registry.d.ts +5 -1
  5. package/dist/controllers/data_driver.d.ts +31 -2
  6. package/dist/controllers/index.d.ts +1 -10
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.es.js +374 -1
  9. package/dist/index.es.js.map +1 -1
  10. package/dist/types/admin_block.d.ts +34 -0
  11. package/dist/types/backend.d.ts +30 -1
  12. package/dist/types/channel_bus.d.ts +192 -0
  13. package/dist/types/collection_contract.d.ts +43 -0
  14. package/dist/types/collections.d.ts +17 -789
  15. package/dist/types/component_ref.d.ts +39 -6
  16. package/dist/types/entity_callbacks.d.ts +1 -1
  17. package/dist/types/index.d.ts +7 -15
  18. package/dist/types/project_manifest.d.ts +336 -0
  19. package/dist/types/properties.d.ts +12 -157
  20. package/dist/types/schema_version.d.ts +18 -0
  21. package/dist/types/security_rules.d.ts +320 -0
  22. package/dist/types/storage_authorize.d.ts +74 -0
  23. package/package.json +3 -6
  24. package/src/call_context.ts +56 -0
  25. package/src/controllers/auth_state.ts +24 -0
  26. package/src/controllers/client.ts +3 -2
  27. package/src/controllers/collection_registry.ts +5 -1
  28. package/src/controllers/data_driver.ts +58 -2
  29. package/src/controllers/index.ts +1 -10
  30. package/src/index.ts +1 -1
  31. package/src/types/admin_block.ts +75 -0
  32. package/src/types/backend.ts +33 -1
  33. package/src/types/channel_bus.ts +202 -0
  34. package/src/types/collection_contract.ts +278 -0
  35. package/src/types/collections.ts +25 -848
  36. package/src/types/component_ref.ts +40 -6
  37. package/src/types/entity_callbacks.ts +1 -1
  38. package/src/types/index.ts +7 -15
  39. package/src/types/policy.ts +25 -11
  40. package/src/types/project_manifest.ts +362 -0
  41. package/src/types/properties.ts +11 -169
  42. package/src/types/schema_version.ts +112 -0
  43. package/src/types/security_rules.ts +344 -0
  44. package/src/types/storage_authorize.ts +77 -0
  45. package/dist/controllers/analytics_controller.d.ts +0 -7
  46. package/dist/controllers/auth.d.ts +0 -110
  47. package/dist/controllers/customization_controller.d.ts +0 -61
  48. package/dist/controllers/dialogs_controller.d.ts +0 -36
  49. package/dist/controllers/local_config_persistence.d.ts +0 -20
  50. package/dist/controllers/navigation.d.ts +0 -225
  51. package/dist/controllers/registry.d.ts +0 -80
  52. package/dist/controllers/side_dialogs_controller.d.ts +0 -67
  53. package/dist/controllers/side_panel_controller.d.ts +0 -97
  54. package/dist/controllers/snackbar.d.ts +0 -24
  55. package/dist/rebase_context.d.ts +0 -110
  56. package/dist/types/breadcrumbs.d.ts +0 -26
  57. package/dist/types/builders.d.ts +0 -15
  58. package/dist/types/component_overrides.d.ts +0 -196
  59. package/dist/types/entity_actions.d.ts +0 -104
  60. package/dist/types/entity_link_builder.d.ts +0 -7
  61. package/dist/types/entity_views.d.ts +0 -95
  62. package/dist/types/export_import.d.ts +0 -21
  63. package/dist/types/formex.d.ts +0 -40
  64. package/dist/types/locales.d.ts +0 -4
  65. package/dist/types/modify_collections.d.ts +0 -5
  66. package/dist/types/plugins.d.ts +0 -277
  67. package/dist/types/property_config.d.ts +0 -74
  68. package/dist/types/slots.d.ts +0 -262
  69. package/dist/types/translations.d.ts +0 -915
  70. package/dist/types/user_management_delegate.d.ts +0 -22
  71. package/src/controllers/analytics_controller.tsx +0 -57
  72. package/src/controllers/auth.tsx +0 -121
  73. package/src/controllers/customization_controller.tsx +0 -72
  74. package/src/controllers/dialogs_controller.tsx +0 -37
  75. package/src/controllers/local_config_persistence.tsx +0 -22
  76. package/src/controllers/navigation.ts +0 -267
  77. package/src/controllers/registry.ts +0 -95
  78. package/src/controllers/side_dialogs_controller.tsx +0 -82
  79. package/src/controllers/side_panel_controller.tsx +0 -112
  80. package/src/controllers/snackbar.ts +0 -29
  81. package/src/rebase_context.tsx +0 -130
  82. package/src/types/breadcrumbs.ts +0 -27
  83. package/src/types/builders.ts +0 -17
  84. package/src/types/component_overrides.ts +0 -244
  85. package/src/types/entity_actions.tsx +0 -125
  86. package/src/types/entity_link_builder.ts +0 -8
  87. package/src/types/entity_views.tsx +0 -114
  88. package/src/types/export_import.ts +0 -26
  89. package/src/types/formex.ts +0 -45
  90. package/src/types/locales.ts +0 -81
  91. package/src/types/modify_collections.tsx +0 -6
  92. package/src/types/plugins.tsx +0 -346
  93. package/src/types/property_config.tsx +0 -95
  94. package/src/types/slots.tsx +0 -307
  95. package/src/types/translations.ts +0 -1026
  96. package/src/types/user_management_delegate.ts +0 -23
@@ -0,0 +1,344 @@
1
+ /**
2
+ * Row-level security rules for a collection.
3
+ *
4
+ * 325 lines of RLS policy contract that used to sit in the middle of
5
+ * `collections.ts`, between the admin panel's table view-models and the auth
6
+ * collection config. It has no relationship to the shape of a collection — it is
7
+ * the most-read part of the BaaS surface, and it now reads on its own.
8
+ *
9
+ * A rule is compiled to Postgres `CREATE POLICY` DDL and, for the structured
10
+ * flavour, independently evaluated in JavaScript, so the admin UI's idea of what
11
+ * a user may do derives from the same expression the database enforces.
12
+ *
13
+ * Note that rule *names* are not what you write: an unnamed rule compiles to
14
+ * `<table>_<op>_<sha1[0:7]>`, plus an injected `default_admin` baseline. Derive
15
+ * them with `getPolicyNamesForRule`/`getEffectiveSecurityRules` rather than
16
+ * matching on `rule.name`.
17
+ */
18
+ import type { PolicyExpression } from "./policy";
19
+
20
+ /**
21
+ * SQL operation that a policy applies to.
22
+ * @group Models
23
+ */
24
+ export type SecurityOperation = "select" | "insert" | "update" | "delete" | "all";
25
+
26
+ /**
27
+ * Flexible Row Level Security rule for a collection.
28
+ *
29
+ * Built on PostgreSQL Row Level Security. Rules can range from
30
+ * simple convenience shortcuts to fully custom SQL expressions, giving you the
31
+ * full power of PostgreSQL Row Level Security.
32
+ *
33
+ * The authenticated user's identity is available in raw SQL via:
34
+ * - `auth.uid()` — the user's ID
35
+ * - `auth.roles()` — comma-separated app role IDs
36
+ * - `auth.jwt()` — full JWT claims as JSONB
37
+ *
38
+ * These are set automatically per-transaction by the backend.
39
+ *
40
+ * **How rules combine:** PostgreSQL evaluates all matching policies for an
41
+ * operation. Permissive rules are OR'd together (any one passing is enough).
42
+ * Restrictive rules are AND'd (all must pass). This is standard PostgreSQL RLS behavior.
43
+ *
44
+ * **Mutual exclusivity:** `ownerField`, `access`, structured `condition`, and
45
+ * raw SQL (`using`/`withCheck`) cannot be combined. The type system enforces
46
+ * this — attempting to set conflicting fields will produce a compile-time
47
+ * error.
48
+ *
49
+ * **Which form to reach for:** prefer the structured {@link StructuredSecurityRule}
50
+ * (`condition`/`check`) or the shortcuts (`ownerField`, `access`, `roles`). These
51
+ * are engine-agnostic and evaluated identically by the database and the admin UI,
52
+ * so the UI never shows an action the database will reject. Raw SQL
53
+ * ({@link RawSQLSecurityRule}) keeps full PostgreSQL power but is Postgres-only
54
+ * and server-authoritative (the UI cannot evaluate arbitrary SQL locally).
55
+ *
56
+ * @group Models
57
+ */
58
+ export type SecurityRule =
59
+ | OwnerSecurityRule
60
+ | PublicSecurityRule
61
+ | StructuredSecurityRule
62
+ | RawSQLSecurityRule
63
+ | RolesOnlySecurityRule;
64
+
65
+ /**
66
+ * Shared fields for all SecurityRule variants.
67
+ * @group Models
68
+ */
69
+ export interface SecurityRuleBase {
70
+ /**
71
+ * Optional human-readable name for the policy.
72
+ * If not provided, one will be auto-generated from the table name and operation.
73
+ * Must be unique per table.
74
+ *
75
+ * When using `operations` (array), each generated policy will have the
76
+ * operation name appended, e.g. `"owner_access_select"`, `"owner_access_update"`.
77
+ */
78
+ name?: string;
79
+
80
+ /**
81
+ * Which SQL operation this policy applies to.
82
+ * Use this when the policy targets a single operation or all operations.
83
+ *
84
+ * For multiple specific operations, use `operations` (array) instead.
85
+ * If neither is specified, defaults to `"all"`.
86
+ *
87
+ * @default "all"
88
+ */
89
+ operation?: SecurityOperation;
90
+
91
+ /**
92
+ * Array of SQL operations this policy applies to.
93
+ * The compiler will generate one PostgreSQL policy per operation, sharing
94
+ * the same configuration.
95
+ *
96
+ * This reduces boilerplate when the same rule applies to multiple (but not all)
97
+ * operations.
98
+ *
99
+ * Takes precedence over `operation` (singular) if both are specified.
100
+ *
101
+ * @example
102
+ * // Same rule for select and update
103
+ * { operations: ["select", "update"], ownerField: "user_id" }
104
+ *
105
+ * @example
106
+ * // Equivalent to operation: "all"
107
+ * { operations: ["all"], ownerField: "user_id" }
108
+ */
109
+ operations?: readonly SecurityOperation[];
110
+
111
+ /**
112
+ * Whether this policy is `"permissive"` (default) or `"restrictive"`.
113
+ *
114
+ * - **permissive**: Multiple permissive policies for the same operation are
115
+ * OR'd together — if *any* passes, access is granted.
116
+ * - **restrictive**: Restrictive policies are AND'd with all permissive
117
+ * policies — they act as additional gates that *must* also pass.
118
+ *
119
+ * This is the standard PostgreSQL RLS model.
120
+ *
121
+ * @default "permissive"
122
+ */
123
+ mode?: "permissive" | "restrictive";
124
+
125
+ /**
126
+ * **Shortcut.** Restrict this rule to users that have one of these
127
+ * application-level roles.
128
+ *
129
+ * **Important:** These are NOT native PostgreSQL database roles — names
130
+ * like `public`, `anon` or `authenticated` belong to {@link pgRoles} and
131
+ * produce a condition no user can satisfy if used here. These are
132
+ * application roles managed by Rebase, stored as an inline `roles TEXT[]`
133
+ * column on the users table, and injected into each transaction as
134
+ * `app.user_roles` — which `auth.roles()` reads.
135
+ *
136
+ * There is no roles registry: a role exists once it is assigned to a user.
137
+ *
138
+ * Generates a safe array-overlap condition — the user passes if they hold
139
+ * *any* of the listed roles:
140
+ * `string_to_array(auth.roles(), ',') && ARRAY['<role1>', '<role2>']`
141
+ *
142
+ * (Note: this is a true set intersection, NOT a regex/substring match, so
143
+ * a role named `admin` never matches `nonadmin` or `superadmin`.)
144
+ *
145
+ * Can be combined with `ownerField`, `access`, `condition`, or raw
146
+ * `using`/`withCheck`. When combined, the role check is AND'd with the
147
+ * other condition.
148
+ *
149
+ * @example
150
+ * // Only admins can delete
151
+ * { operation: "delete", roles: ["admin"] }
152
+ *
153
+ * @example
154
+ * // Admins have unfiltered read access to all rows
155
+ * { operation: "select", roles: ["admin"], using: "true" }
156
+ */
157
+ roles?: readonly string[];
158
+
159
+ // ── Advanced: native PostgreSQL role targeting ───────────────────────
160
+
161
+ /**
162
+ * **Advanced.** Native PostgreSQL database roles the policy applies to.
163
+ *
164
+ * By default, all generated policies target the `public` role (i.e.
165
+ * every database connection). This is correct for most setups where
166
+ * a single database role is used for all connections.
167
+ *
168
+ * **Important:** These are NOT the same as the application-level
169
+ * {@link roles} (admin, editor, viewer, etc.) — those are enforced in the
170
+ * USING/WITH CHECK clauses via `auth.roles()`. This field controls the
171
+ * PostgreSQL `TO` clause in `CREATE POLICY ... TO role_name`.
172
+ *
173
+ * Use this if you have dedicated PostgreSQL roles (e.g. `app_read`,
174
+ * `app_write`) and want policies to target specific ones.
175
+ *
176
+ * @default ["public"]
177
+ *
178
+ * @example
179
+ * // Only apply this policy when connected as `app_role`
180
+ * { operation: "select", access: "public", pgRoles: ["app_role"] }
181
+ */
182
+ pgRoles?: readonly string[];
183
+ }
184
+
185
+ /**
186
+ * Security rule that grants access based on row ownership.
187
+ * Generates a USING/WITH CHECK clause like: `<column> = auth.uid()`
188
+ *
189
+ * Cannot be combined with `using`, `withCheck`, or `access`.
190
+ *
191
+ * @example
192
+ * { operation: "all", ownerField: "user_id" }
193
+ *
194
+ * @group Models
195
+ */
196
+ export interface OwnerSecurityRule extends SecurityRuleBase {
197
+ /** The property (column) that stores the owner's user ID. */
198
+ ownerField: string;
199
+ access?: never;
200
+ using?: never;
201
+ withCheck?: never;
202
+ condition?: never;
203
+ check?: never;
204
+ }
205
+
206
+ /**
207
+ * Security rule that grants unrestricted row access (no row filtering).
208
+ * Generates `USING (true)`.
209
+ *
210
+ * This means "no row-level filter", NOT "anonymous/unauthenticated access".
211
+ * Authentication is still enforced at the API layer — this only controls which
212
+ * *rows* authenticated users can see.
213
+ *
214
+ * Cannot be combined with `using`, `withCheck`, or `ownerField`.
215
+ *
216
+ * @example
217
+ * // Public read (any authenticated user sees all rows)
218
+ * { operation: "select", access: "public" }
219
+ *
220
+ * @group Models
221
+ */
222
+ export interface PublicSecurityRule extends SecurityRuleBase {
223
+ /** Grant unrestricted row access for this operation. */
224
+ access: "public";
225
+ ownerField?: never;
226
+ using?: never;
227
+ withCheck?: never;
228
+ condition?: never;
229
+ check?: never;
230
+ }
231
+
232
+ /**
233
+ * Security rule expressed as a structured, engine-agnostic
234
+ * {@link PolicyExpression}. This is the **recommended** way to write a
235
+ * non-trivial condition: it compiles to PostgreSQL `USING`/`WITH CHECK` SQL
236
+ * *and* is evaluated identically by the admin UI, so the UI can never show an
237
+ * action the database will reject.
238
+ *
239
+ * Cannot be combined with `ownerField`, `access`, or raw `using`/`withCheck`.
240
+ *
241
+ * @example
242
+ * // Owner, or any user holding the `moderator` role
243
+ * {
244
+ * operation: "update",
245
+ * condition: policy.or(
246
+ * policy.compare(policy.field("user_id"), "eq", policy.authUid()),
247
+ * policy.rolesOverlap(["moderator"])
248
+ * )
249
+ * }
250
+ *
251
+ * @group Models
252
+ */
253
+ export interface StructuredSecurityRule extends SecurityRuleBase {
254
+ /**
255
+ * Structured condition for the `USING` clause — which *existing* rows are
256
+ * visible / can be modified / deleted (SELECT, UPDATE, DELETE).
257
+ */
258
+ condition: PolicyExpression;
259
+
260
+ /**
261
+ * Structured condition for the `WITH CHECK` clause — which *new/updated*
262
+ * row values are allowed (INSERT, UPDATE). Defaults to `condition` when
263
+ * omitted, mirroring PostgreSQL's own behavior.
264
+ */
265
+ check?: PolicyExpression;
266
+
267
+ ownerField?: never;
268
+ access?: never;
269
+ using?: never;
270
+ withCheck?: never;
271
+ }
272
+
273
+ /**
274
+ * Security rule using raw SQL expressions for full PostgreSQL RLS power.
275
+ *
276
+ * **Postgres-only and server-authoritative.** Arbitrary SQL cannot be
277
+ * evaluated by the admin UI, so a rule using this form is treated as *unknown*
278
+ * client-side (never silently allowed) and its effect on visible actions is
279
+ * reflected from the server. For conditions that should also drive the UI
280
+ * precisely, prefer the structured {@link StructuredSecurityRule}.
281
+ *
282
+ * Cannot be combined with `ownerField`, `access`, or structured `condition`.
283
+ *
284
+ * You can reference columns via `{column_name}` which will be resolved to
285
+ * `table.column_name` in the generated Drizzle code.
286
+ *
287
+ * @example
288
+ * // Rows published in the last 30 days are visible
289
+ * { operation: "select", using: "{published_at} > now() - interval '30 days'" }
290
+ *
291
+ * @example
292
+ * // Only the owner, or users with 'moderator' role
293
+ * {
294
+ * operation: "select",
295
+ * using: "{user_id} = auth.uid() OR auth.roles() ~ 'moderator'"
296
+ * }
297
+ *
298
+ * @group Models
299
+ */
300
+ export interface RawSQLSecurityRule extends SecurityRuleBase {
301
+ /**
302
+ * Raw SQL expression for the `USING` clause.
303
+ * This controls which *existing* rows are visible / can be modified / deleted.
304
+ * Applied to SELECT, UPDATE, and DELETE.
305
+ */
306
+ using: string;
307
+
308
+ /**
309
+ * Raw SQL expression for the `WITH CHECK` clause.
310
+ * This controls which *new/updated* row values are allowed.
311
+ * Applied to INSERT and UPDATE.
312
+ *
313
+ * If not provided on INSERT/UPDATE policies, falls back to `using`
314
+ * (which matches PostgreSQL's own default behavior).
315
+ */
316
+ withCheck?: string;
317
+
318
+ ownerField?: never;
319
+ access?: never;
320
+ condition?: never;
321
+ check?: never;
322
+ }
323
+
324
+ /**
325
+ * Security rule that only filters by application roles, without any
326
+ * row-level condition (USING/WITH CHECK).
327
+ *
328
+ * Useful for simple "only admins can access this table" rules where
329
+ * no per-row filtering is needed.
330
+ *
331
+ * @example
332
+ * // Only admins can delete
333
+ * { operation: "delete", roles: ["admin"] }
334
+ *
335
+ * @group Models
336
+ */
337
+ export interface RolesOnlySecurityRule extends SecurityRuleBase {
338
+ ownerField?: never;
339
+ access?: never;
340
+ using?: never;
341
+ withCheck?: never;
342
+ condition?: never;
343
+ check?: never;
344
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The storage access-control contract.
3
+ *
4
+ * Lives here rather than in `@rebasepro/server` because a project declares its
5
+ * `storageAuthorize` hook from its **config package**, and a config package
6
+ * depends on `@rebasepro/types` alone. A type the contract requires but the
7
+ * contract's author cannot import is not much of a contract.
8
+ *
9
+ * `@rebasepro/server` re-exports all of this, so existing imports keep working.
10
+ */
11
+
12
+ export type StorageOperation = "read" | "write" | "delete" | "list";
13
+
14
+ /** The caller, as resolved by whichever auth middleware ran. */
15
+ export interface StorageAuthorizeUser {
16
+ uid: string;
17
+ email?: string;
18
+ roles?: string[];
19
+ }
20
+
21
+ export interface StorageAuthorizeContext {
22
+ /** Object key, bucket prefix stripped and traversal already sanitized. */
23
+ key: string;
24
+ bucket: string;
25
+ operation: StorageOperation;
26
+ /** Null when the route allows unauthenticated access. */
27
+ user: StorageAuthorizeUser | null;
28
+ /** Named backend the request targeted, when one was given. */
29
+ storageId?: string;
30
+ /**
31
+ * Trusted, RLS-bypassing data access, so the hook can answer the question it
32
+ * actually has to answer: *who owns this object?*
33
+ *
34
+ * Without it the hook can only do prefix arithmetic on the key, which
35
+ * expresses no real multi-tenant rule — ownership lives in a row, not in a
36
+ * string. And it cannot simply import the server to get one: a project
37
+ * declares this hook from its **config** package, which depends on
38
+ * `@rebasepro/types` alone and cannot resolve `@rebasepro/server` at
39
+ * runtime. So the accessor is handed in.
40
+ *
41
+ * It bypasses row-level security on purpose. The hook IS the authorization
42
+ * decision; asking it to make that decision through a reader that has
43
+ * already been narrowed by the caller's own permissions is circular.
44
+ */
45
+ data?: StorageAuthorizeData;
46
+ }
47
+
48
+ /**
49
+ * The slice of the data API a storage hook needs: read a collection, in the
50
+ * trusted server context.
51
+ *
52
+ * Deliberately read-only and deliberately tiny. A hook that can write is a hook
53
+ * that can be tricked into writing, and an authorization check has no business
54
+ * mutating anything.
55
+ */
56
+ export interface StorageAuthorizeData {
57
+ collection(slug: string): {
58
+ find(query?: Record<string, unknown>): Promise<{ data: Record<string, unknown>[] }>;
59
+ findById(id: string): Promise<Record<string, unknown> | null>;
60
+ };
61
+ }
62
+
63
+ /**
64
+ * Per-object access control for storage, the analogue of an RLS policy on a
65
+ * collection.
66
+ *
67
+ * Without it, storage routes authenticate but do not authorize: `requireAuth`
68
+ * and `publicRead` are global switches, so any signed-in user could read any
69
+ * key they could name. That is fine for a single-tenant app and useless for a
70
+ * multi-tenant one, where the only thing separating two tenants' files would be
71
+ * key unguessability — not an access-control model. Multi-tenant apps were
72
+ * left to route every byte through a custom function to get an ownership check
73
+ * in, and each of them had to invent it.
74
+ *
75
+ * Return false (or throw) to deny. Denials surface as 403.
76
+ */
77
+ export type StorageAuthorize = (ctx: StorageAuthorizeContext) => boolean | Promise<boolean>;
@@ -1,7 +0,0 @@
1
- export type AnalyticsController = {
2
- /**
3
- * Callback used to get analytics events from the CMS
4
- */
5
- onAnalyticsEvent?: (event: AnalyticsEvent, data?: object) => void;
6
- };
7
- export type AnalyticsEvent = "entity_click" | "entity_click_from_reference" | "reference_selection_clear" | "reference_selection_toggle" | "reference_selected_single" | "reference_selection_new_entity" | "edit_entity_clicked" | "entity_edited" | "new_entity_click" | "new_entity_saved" | "copy_entity_click" | "entity_copied" | "single_delete_dialog_open" | "multiple_delete_dialog_open" | "single_entity_deleted" | "multiple_entities_deleted" | "drawer_navigate_to_home" | "drawer_navigate_to_collection" | "drawer_navigate_to_view" | "home_navigate_to_collection" | "home_favorite_navigate_to_collection" | "home_navigate_to_view" | "home_navigate_to_admin_view" | "home_favorite_navigate_to_view" | "home_move_card" | "home_move_group" | "home_drop_new_group" | "collection_inline_editing" | "view_mode_changed" | "kanban_card_moved" | "kanban_column_reorder" | "kanban_property_changed" | "kanban_new_entity_in_column" | "kanban_backfill_order" | "card_view_entity_click" | "unmapped_event";
@@ -1,110 +0,0 @@
1
- import type { User } from "../users";
2
- /**
3
- * Capabilities advertised by an auth provider.
4
- * UI components use this to show/hide features dynamically
5
- * (e.g. password reset, registration, session management).
6
- * @group Hooks and utilities
7
- */
8
- export interface AuthCapabilities {
9
- emailPasswordLogin?: boolean;
10
- googleLogin?: boolean;
11
- registration?: boolean;
12
- /** Self-service password reset (emailing a reset link) is available. */
13
- passwordReset?: boolean;
14
- /**
15
- * An admin can reset another user's password. Gates the "Reset Password"
16
- * entity action in the admin UI. See `AuthAdapterCapabilities`.
17
- */
18
- adminPasswordReset?: boolean;
19
- sessionManagement?: boolean;
20
- profileUpdate?: boolean;
21
- emailVerification?: boolean;
22
- /** List of enabled OAuth provider IDs (e.g. ["google", "github", "discord"]) */
23
- enabledProviders?: string[];
24
- }
25
- /**
26
- * Controller for retrieving the logged user or performing auth related operations.
27
- * Note that if you are implementing your AuthController, you probably will want
28
- * to do it as the result of a hook.
29
- * @group Hooks and utilities
30
- */
31
- export type AuthController<USER extends User = User, ExtraData = unknown> = {
32
- /**
33
- * The user currently logged in
34
- * The values can be: the user object, null if they skipped login
35
- */
36
- user: USER | null;
37
- /**
38
- * Initial loading flag. It is used not to display the login screen
39
- * when the app first loads, and it has not been checked whether the user
40
- * is logged in or not.
41
- */
42
- initialLoading?: boolean;
43
- /**
44
- * Loading flag. It is used to display a loading screen when the user is
45
- * logging in or out.
46
- */
47
- authLoading: boolean;
48
- /**
49
- * Sign out
50
- */
51
- signOut: () => Promise<void>;
52
- /**
53
- * Error initializing the authentication
54
- */
55
- authError?: unknown;
56
- /**
57
- * Error dispatched by the auth provider
58
- */
59
- authProviderError?: unknown;
60
- /**
61
- * You can use this method to retrieve the auth token for the current user.
62
- */
63
- getAuthToken: () => Promise<string>;
64
- /**
65
- * Has the user skipped the login process
66
- */
67
- loginSkipped: boolean;
68
- extra: ExtraData;
69
- setExtra: (extra: ExtraData) => void;
70
- setUser?(user: USER | null): void;
71
- setUserRoles?(roles: string[]): void;
72
- /**
73
- * Capabilities advertised by the auth provider.
74
- * UI components use this to feature-detect what the backend supports.
75
- */
76
- capabilities?: AuthCapabilities;
77
- };
78
- /**
79
- * Extended auth controller with common optional auth methods.
80
- * Backend implementations (Rebase backend, Firebase, etc.)
81
- * extend this with their own backend-specific extras.
82
- * @group Hooks and utilities
83
- */
84
- export interface AuthControllerExtended<USER extends User = User, ExtraData = unknown> extends AuthController<USER, ExtraData> {
85
- /** Login with email and password */
86
- emailPasswordLogin?(email: string, password: string): Promise<void>;
87
- /** Login with Google — accepts an ID token, access token, or authorization code payload */
88
- googleLogin?: (payload: {
89
- idToken: string;
90
- } | {
91
- accessToken: string;
92
- } | {
93
- code: string;
94
- redirectUri: string;
95
- }) => Promise<void>;
96
- /** Generic OAuth login — works with any provider. Posts payload to /auth/{providerId}. */
97
- oauthLogin?: (providerId: string, payload: Record<string, unknown>) => Promise<void>;
98
- /** Register a new user */
99
- register?(email: string, password: string, displayName?: string): Promise<void>;
100
- /** Skip login (for anonymous access if enabled) */
101
- skipLogin?(): void;
102
- /** Request password reset email */
103
- forgotPassword?(email: string): Promise<void>;
104
- /** Reset password using a token */
105
- resetPassword?(token: string, password: string): Promise<void>;
106
- /** Change password for the authenticated user */
107
- changePassword?(oldPassword: string, newPassword: string): Promise<void>;
108
- /** Update user profile */
109
- updateProfile?(displayName?: string, photoURL?: string): Promise<USER>;
110
- }
@@ -1,61 +0,0 @@
1
- import type { EntityLinkBuilder } from "../types/entity_link_builder";
2
- import type { Locale } from "../types/locales";
3
- import type { EntityAction } from "../types/entity_actions";
4
- import type { EntityCustomView } from "../types/entity_views";
5
- import type { RebasePlugin } from "../types/plugins";
6
- import type { PropertyConfig } from "../types/property_config";
7
- import type { SlotContribution } from "../types/slots";
8
- import type { ComponentOverrideMap } from "../types/component_overrides";
9
- export type CustomizationController = {
10
- /**
11
- * Builder for generating utility links for entities
12
- */
13
- entityLinkBuilder?: EntityLinkBuilder;
14
- /**
15
- * Use plugins to modify the behaviour of the CMS.
16
- */
17
- plugins?: RebasePlugin[];
18
- /**
19
- * Pre-merged slots from plugins + direct slot contributions.
20
- */
21
- resolvedSlots: SlotContribution[];
22
- /**
23
- * List of additional custom views for entities.
24
- * You can use the key to reference the custom view in
25
- * the `entityViews` prop of a collection.
26
- *
27
- * You can also define a entity view from the UI.
28
- */
29
- entityViews?: EntityCustomView[];
30
- /**
31
- * List of actions that can be performed on entities.
32
- * These actions are displayed in the entity view and in the collection view.
33
- * You can later reuse these actions in the `entityActions` prop of a collection,
34
- * by specifying the `key` of the action.
35
- */
36
- entityActions?: EntityAction[];
37
- /**
38
- * Format of the dates in the CMS.
39
- * Defaults to 'MMMM dd, yyyy, HH:mm:ss'
40
- */
41
- dateTimeFormat?: string;
42
- /**
43
- * Locale of the CMS, currently only affecting dates
44
- */
45
- locale?: Locale;
46
- /**
47
- * Record of custom form fields to be used in the CMS.
48
- * You can use the key to reference the custom field in
49
- * the `propertyConfig` prop of a property in a collection.
50
- */
51
- propertyConfigs: Record<string, PropertyConfig>;
52
- /**
53
- * Global component overrides. Keys are component names from
54
- * {@link OverridableComponentName}. Values replace the default
55
- * implementation everywhere in the app.
56
- *
57
- * Collection-scoped overrides (set on individual collections)
58
- * take precedence over global overrides.
59
- */
60
- components?: ComponentOverrideMap;
61
- };
@@ -1,36 +0,0 @@
1
- import React from "react";
2
- /**
3
- * Controller to open the side dialog
4
- * @group Hooks and utilities
5
- */
6
- export interface DialogsController {
7
- /**
8
- * Close the last dialog
9
- */
10
- close: () => void;
11
- /**
12
- * Open a dialog
13
- * @param props
14
- */
15
- open: <T extends object = object>(props: DialogControllerEntryProps<T>) => {
16
- closeDialog: () => void;
17
- };
18
- }
19
- /**
20
- * Props used to open a side dialog
21
- * @group Hooks and utilities
22
- */
23
- export interface DialogControllerEntryProps<T extends object = object> {
24
- key: string;
25
- /**
26
- * The component type that will be rendered
27
- */
28
- Component: React.ComponentType<{
29
- open: boolean;
30
- closeDialog: () => void;
31
- } & T>;
32
- /**
33
- * Props to pass to the dialog component
34
- */
35
- props?: T;
36
- }
@@ -1,20 +0,0 @@
1
- import type { CollectionConfig } from "../types/collections";
2
- /**
3
- * @group Models
4
- */
5
- export type PartialCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>> = Partial<CollectionConfig<M>>;
6
- /**
7
- * This interface is in charge of defining the controller that persists
8
- * modifications to a collection or collection, and retrieves them back from
9
- * a data source, such as local storage or Firestore.
10
- */
11
- export interface UserConfigurationPersistence {
12
- onCollectionModified: <M extends Record<string, unknown> = Record<string, unknown>>(path: string, partialCollection: PartialCollectionConfig<M>) => void;
13
- getCollectionConfig: <M extends Record<string, unknown> = Record<string, unknown>>(path: string) => PartialCollectionConfig<M>;
14
- recentlyVisitedPaths: string[];
15
- setRecentlyVisitedPaths: (paths: string[]) => void;
16
- favouritePaths: string[];
17
- setFavouritePaths: (paths: string[]) => void;
18
- collapsedGroups: string[];
19
- setCollapsedGroups: (paths: string[]) => void;
20
- }