@rebasepro/admin-types 0.10.1-canary.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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/dist/admin_collection.d.ts +464 -0
  3. package/dist/augment.d.ts +66 -0
  4. package/dist/collections.d.ts +226 -0
  5. package/dist/controllers/analytics_controller.d.ts +7 -0
  6. package/dist/controllers/auth.d.ts +110 -0
  7. package/dist/controllers/customization_controller.d.ts +61 -0
  8. package/dist/controllers/dialogs_controller.d.ts +36 -0
  9. package/dist/controllers/index.d.ts +10 -0
  10. package/dist/controllers/local_config_persistence.d.ts +20 -0
  11. package/dist/controllers/navigation.d.ts +225 -0
  12. package/dist/controllers/registry.d.ts +80 -0
  13. package/dist/controllers/side_dialogs_controller.d.ts +67 -0
  14. package/dist/controllers/side_panel_controller.d.ts +97 -0
  15. package/dist/controllers/snackbar.d.ts +24 -0
  16. package/dist/index.d.ts +18 -0
  17. package/dist/index.es.js +92 -0
  18. package/dist/index.es.js.map +1 -0
  19. package/dist/react_component_ref.d.ts +43 -0
  20. package/dist/rebase_context.d.ts +68 -0
  21. package/dist/types/breadcrumbs.d.ts +26 -0
  22. package/dist/types/builders.d.ts +15 -0
  23. package/dist/types/component_overrides.d.ts +196 -0
  24. package/dist/types/entity_actions.d.ts +105 -0
  25. package/dist/types/entity_link_builder.d.ts +7 -0
  26. package/dist/types/entity_views.d.ts +95 -0
  27. package/dist/types/export_import.d.ts +21 -0
  28. package/dist/types/formex.d.ts +40 -0
  29. package/dist/types/index.d.ts +15 -0
  30. package/dist/types/locales.d.ts +4 -0
  31. package/dist/types/modify_collections.d.ts +5 -0
  32. package/dist/types/plugins.d.ts +277 -0
  33. package/dist/types/property_config.d.ts +74 -0
  34. package/dist/types/property_options.d.ts +154 -0
  35. package/dist/types/slots.d.ts +263 -0
  36. package/dist/types/translations.d.ts +915 -0
  37. package/dist/types/user_management_delegate.d.ts +22 -0
  38. package/package.json +103 -0
  39. package/src/admin_collection.ts +582 -0
  40. package/src/augment.ts +60 -0
  41. package/src/collections.ts +256 -0
  42. package/src/controllers/analytics_controller.tsx +57 -0
  43. package/src/controllers/auth.ts +121 -0
  44. package/src/controllers/customization_controller.tsx +72 -0
  45. package/src/controllers/dialogs_controller.tsx +37 -0
  46. package/src/controllers/index.ts +10 -0
  47. package/src/controllers/local_config_persistence.tsx +22 -0
  48. package/src/controllers/navigation.ts +264 -0
  49. package/src/controllers/registry.ts +96 -0
  50. package/src/controllers/side_dialogs_controller.tsx +82 -0
  51. package/src/controllers/side_panel_controller.tsx +112 -0
  52. package/src/controllers/snackbar.ts +29 -0
  53. package/src/index.ts +20 -0
  54. package/src/react_component_ref.ts +52 -0
  55. package/src/rebase_context.ts +81 -0
  56. package/src/types/breadcrumbs.ts +27 -0
  57. package/src/types/builders.ts +18 -0
  58. package/src/types/component_overrides.ts +244 -0
  59. package/src/types/entity_actions.tsx +127 -0
  60. package/src/types/entity_link_builder.ts +8 -0
  61. package/src/types/entity_views.tsx +114 -0
  62. package/src/types/export_import.ts +26 -0
  63. package/src/types/formex.ts +45 -0
  64. package/src/types/index.ts +15 -0
  65. package/src/types/locales.ts +81 -0
  66. package/src/types/modify_collections.tsx +6 -0
  67. package/src/types/plugins.tsx +346 -0
  68. package/src/types/property_config.tsx +95 -0
  69. package/src/types/property_options.ts +169 -0
  70. package/src/types/slots.tsx +309 -0
  71. package/src/types/translations.ts +1026 -0
  72. package/src/types/user_management_delegate.ts +23 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rebase
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,464 @@
1
+ /**
2
+ * The typed admin block, and the type you author a collection against.
3
+ *
4
+ * A collection is one file. Schema, security rules and callbacks sit at the top
5
+ * level, where the backend reads them; everything the admin panel renders sits
6
+ * under `admin`. `@rebasepro/types` does not declare that field at all — naming a
7
+ * kanban column definition would drag `React.ReactNode` back into the BaaS
8
+ * contract, and a server has no use for one. `augment.ts` in this package declares
9
+ * it, by declaration merging, onto core's `CollectionConfig`. So this is the other
10
+ * side of that boundary: the 38 fields, fully typed, in the package where React
11
+ * exists, and reachable only by a program that has opted in.
12
+ *
13
+ * Each field is declared exactly once, here. Core does not carry a React-free
14
+ * skeleton of the same shape; two definitions that agree only by luck is the
15
+ * `WhereFilterOp` mistake, and this block is far bigger than one union.
16
+ */
17
+ import type React from "react";
18
+ import type { CollectionConfig, ComponentRef, FilterPreset, FilterValues, FirebaseCollectionConfig, FirebaseProperties, InferEntityType, MongoDBCollectionConfig, MongoProperties, OrderByTuple, PostgresCollectionConfig, PostgresProperties, User } from "@rebasepro/types";
19
+ import type { AdditionalFieldDelegate, CollectionActionsProps, CollectionSize, DefaultSelectedViewBuilder, KanbanConfig, SelectionController, ViewMode } from "./collections";
20
+ import type { EntityCustomView, FormViewConfig } from "./types/entity_views";
21
+ import type { EntityAction } from "./types/entity_actions";
22
+ import type { ExportConfig } from "./types/export_import";
23
+ import type { CollectionComponentOverrideMap } from "./types/component_overrides";
24
+ /**
25
+ * Admin-panel presentation and behaviour for a collection.
26
+ *
27
+ * A `type` rather than an `interface`, and that is load-bearing: TypeScript gives
28
+ * an implicit index signature to an object *type alias* but not to an interface.
29
+ * `toAdminCollectionConfig` has to widen a collection carrying this block to
30
+ * `Record<string, unknown>` in order to move the flattened keys back under
31
+ * `admin`, and as an interface that conversion is an error (TS2352, "index
32
+ * signature for type 'string' is missing"). Flipping it and running
33
+ * `pnpm typecheck` reproduces that in one line.
34
+ *
35
+ * Declaration merging is not wanted here anyway; a plugin adding fields to the
36
+ * block would have nothing reading them.
37
+ *
38
+ * @group Models
39
+ */
40
+ export type AdminCollectionOptions<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = {
41
+ /**
42
+ * Icon for the navigation sidebar or cards.
43
+ *
44
+ * Either a Lucide icon name (`"FileText"`, `"ShoppingCart"`) or a rendered
45
+ * element. Prefer the name: it survives serialization, so the collection file
46
+ * stays loadable by the backend and by `rebase generate-sdk`, and it is what
47
+ * the schema editor writes back.
48
+ */
49
+ icon?: string | React.ReactNode;
50
+ /**
51
+ * Navigation group for this collection.
52
+ * Collections sharing the same group name will be visually grouped
53
+ * together in the drawer and home page. If not set, the collection
54
+ * falls into the default "Views" group.
55
+ */
56
+ group?: string;
57
+ /**
58
+ * Array of entity views that this collection has.
59
+ * Can be an array of `EntityCustomView` or a string representing the key of a global `EntityCustomView`.
60
+ */
61
+ entityViews?: (string | EntityCustomView<Record<string, unknown>>)[];
62
+ /**
63
+ * Default preview properties displayed when this collection is referenced to.
64
+ */
65
+ previewProperties?: string[];
66
+ /**
67
+ * Properties to display as columns in the list view.
68
+ * If not specified, the list view uses a smart default (Title, Status, Date).
69
+ */
70
+ listProperties?: string[];
71
+ /**
72
+ * Title property of the entity. This is the property that will be used
73
+ * as the title in entity related views and references.
74
+ * If not specified, the first property simple text property will be used.
75
+ */
76
+ readonly titleProperty?: Extract<keyof M, string> | (string & {});
77
+ /**
78
+ * When editing a entity, you can choose to open the entity in a side dialog
79
+ * or in a full screen dialog. Defaults to `full_screen`.
80
+ */
81
+ openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
82
+ /**
83
+ * Controls what happens when a user clicks on a entity in the collection view.
84
+ * - `"edit"` (default): Opens the entity in the edit form.
85
+ * - `"view"`: Opens a read-only detail view with an "Edit" button.
86
+ */
87
+ defaultEntityAction?: "view" | "edit";
88
+ /**
89
+ * Replace the default entity form with a custom component.
90
+ * The Builder receives the same props as entity view tabs
91
+ * (entity, formContext, collection, etc.) and has full control over the UI.
92
+ *
93
+ * Works in both edit mode and read-only mode (when `defaultEntityAction`
94
+ * is `"view"`). In read-only mode, `formContext.readOnly` will be `true`.
95
+ */
96
+ formView?: FormViewConfig;
97
+ /**
98
+ * Prevent default actions from being displayed or executed on this collection.
99
+ */
100
+ disableDefaultActions?: ("edit" | "copy" | "delete")[];
101
+ /**
102
+ * Order in which the properties are displayed.
103
+ * If you are specifying your collection as code, the order is the same as the
104
+ * one you define in `properties`. Additional columns are added at the
105
+ * end of the list, if the order is not specified.
106
+ *
107
+ * You can use this prop to hide some properties from the table view.
108
+ * Note that if you set this prop, other ways to hide fields, like
109
+ * `hidden` in the property definition, will be ignored.
110
+ * `propertiesOrder` has precedence over `hidden`.
111
+ *
112
+ * Supported entry formats:
113
+ * - For properties, use the property key.
114
+ * - For additional fields, use the field key.
115
+ * - Child collections (Firestore subcollections, or Postgres relations
116
+ * with `many` cardinality) each get a column with id
117
+ * `subcollection:<slug>`, e.g. `subcollection:orders`.
118
+ */
119
+ propertiesOrder?: (Extract<keyof M, string> | (string & {}) | string | `subcollection:${string}`)[];
120
+ /**
121
+ * If enabled, content is loaded in batches. If `false` all entities in the
122
+ * collection are loaded. This means that when reaching the end of the
123
+ * collection, the CMS will load more entities.
124
+ * You can specify a number to specify the pagination size (50 by default)
125
+ * Defaults to `true`
126
+ */
127
+ pagination?: boolean | number;
128
+ selectionEnabled?: boolean;
129
+ /**
130
+ * Pass your own selection controller if you want to control selected
131
+ * entities externally.
132
+ * @see useSelectionController
133
+ */
134
+ selectionController?: SelectionController<M>;
135
+ /**
136
+ * Force a filter in this view. If applied, the rest of the filters will
137
+ * be disabled. Filters applied with this prop cannot be changed.
138
+ * e.g. `fixedFilter: { age: [">", 18] }`
139
+ * e.g. `fixedFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
140
+ */
141
+ readonly fixedFilter?: FilterValues<Extract<keyof M, string> | (string & {})>;
142
+ /**
143
+ * Initial filters applied to the collection this collection is related to.
144
+ * Defaults to none. Filters applied with this prop can be changed.
145
+ * e.g. `defaultFilter: { age: [">", 18] }`
146
+ * e.g. `defaultFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
147
+ */
148
+ readonly defaultFilter?: FilterValues<Extract<keyof M, string> | (string & {})>;
149
+ /**
150
+ * Pre-defined filter presets that appear as quick-access options in the
151
+ * collection toolbar. Each preset applies a set of filters (and
152
+ * optionally a sort order) with a single click.
153
+ *
154
+ * ```ts
155
+ * filterPresets: [
156
+ * {
157
+ * label: "Shipped this month",
158
+ * filterValues: {
159
+ * status: ["==", "shipped"],
160
+ * order_date: [">=", new Date(Date.now() - 30 * 86400000)]
161
+ * }
162
+ * }
163
+ * ]
164
+ * ```
165
+ */
166
+ readonly filterPresets?: FilterPreset<Extract<keyof M, string> | (string & {})>[];
167
+ /**
168
+ * Default sort applied to this collection.
169
+ * When setting this prop, entities will have a default order
170
+ * applied in the collection.
171
+ * e.g. `sort: ["order", "asc"]`
172
+ */
173
+ readonly sort?: OrderByTuple<Extract<keyof M, string> | (string & {})>;
174
+ /**
175
+ * You can add additional fields to the collection view by implementing
176
+ * an additional field delegate.
177
+ */
178
+ readonly additionalFields?: AdditionalFieldDelegate<M, USER>[];
179
+ /**
180
+ * Default size of the rendered collection
181
+ */
182
+ defaultSize?: CollectionSize;
183
+ /**
184
+ * Can the elements in this collection be edited inline in the collection
185
+ * view. Even when inline editing is disabled, entities can still be
186
+ * edited in the side panel (subject to `securityRules`).
187
+ */
188
+ inlineEditing?: boolean;
189
+ /**
190
+ * Should this collection be hidden from the main navigation panel, if
191
+ * it is at the root level, or in the entity side panel if it's a
192
+ * subcollection.
193
+ * It will still be accessible if you reach the specified path.
194
+ * You can also use this collection as a reference target.
195
+ */
196
+ hideFromNavigation?: boolean;
197
+ /**
198
+ * If you want to open custom views or subcollections by default when opening the edit
199
+ * view of a entity, you can specify the path to the view here.
200
+ * The path is relative to the current collection. For example if you have a collection
201
+ * that has a custom view as well as a subcollection that refers to another entity, you can
202
+ * either specify the path to the custom view or the path to the subcollection.
203
+ */
204
+ defaultSelectedView?: string | DefaultSelectedViewBuilder;
205
+ /**
206
+ * Should the ID of this collection be hidden from the form view.
207
+ */
208
+ hideIdFromForm?: boolean;
209
+ /**
210
+ * Should the ID of this collection be hidden from the grid view.
211
+ */
212
+ hideIdFromCollection?: boolean;
213
+ /**
214
+ * If set to true, the form will be auto-saved when the user changes
215
+ * the value of a field.
216
+ * Defaults to false.
217
+ * When a new entity is created, this property can be updated to generated a new ID
218
+ */
219
+ formAutoSave?: boolean;
220
+ /**
221
+ *
222
+ */
223
+ exportable?: boolean | ExportConfig<USER>;
224
+ /**
225
+ * Width of the side dialog (in pixels) when opening a entity in this collection.
226
+ */
227
+ sideDialogWidth?: number | string;
228
+ /**
229
+ * If set to true, the default values of the properties will be applied
230
+ * to the entity every time the entity is updated (not only when created).
231
+ * Defaults to false.
232
+ */
233
+ alwaysApplyDefaultValues?: boolean;
234
+ /**
235
+ * If set to true, a tab including the JSON representation of the entity will be included.
236
+ */
237
+ includeJsonView?: boolean;
238
+ /**
239
+ * Should local changes be backed up in local storage, to prevent data loss on
240
+ * accidental navigations.
241
+ * - `manual_apply`: When the user navigates back to a entity with local changes,
242
+ * they will be prompted to restore the changes.
243
+ * - `auto_apply`: When the user navigates back to a entity with local changes,
244
+ * the changes will be automatically applied.
245
+ * - `false`: Local changes will not be backed up.
246
+ * Defaults to `manual_apply`.
247
+ */
248
+ localChangesBackup?: "manual_apply" | "auto_apply" | false;
249
+ /**
250
+ * Default view mode for displaying this collection.
251
+ * - "table": Display entities in a table with inline editing (default)
252
+ * - "cards": Display entities as a grid of cards with thumbnails
253
+ * - "kanban": Display entities in a Kanban board grouped by a property
254
+ * Defaults to "table".
255
+ */
256
+ defaultViewMode?: ViewMode;
257
+ /**
258
+ * Which view modes are available for this collection.
259
+ * Possible values: "table", "cards", "kanban".
260
+ * Defaults to all three: ["table", "cards", "kanban"].
261
+ * Note: "kanban" will only be available if the collection has at least
262
+ * one string property with `enum` defined, regardless of this setting.
263
+ */
264
+ enabledViews?: ViewMode[];
265
+ /**
266
+ * Configuration for Kanban board view mode.
267
+ * When set, the Kanban view mode becomes available.
268
+ */
269
+ kanban?: KanbanConfig<M>;
270
+ /**
271
+ * Property key to use for ordering items.
272
+ * Must reference a string/text property. When items are reordered,
273
+ * this property will be updated with lexicographic sort keys
274
+ * (e.g. "a0", "a1", "a0V") using string-based fractional indexing.
275
+ * Used by Kanban view for ordering within columns
276
+ * and can be used for general ordering purposes.
277
+ */
278
+ readonly orderProperty?: Extract<keyof M, string> | (string & {});
279
+ /**
280
+ * Actions that can be performed on the entities in this collection.
281
+ */
282
+ entityActions?: EntityAction<M, USER>[];
283
+ /**
284
+ * Builder for the collection actions rendered in the toolbar
285
+ */
286
+ Actions?: ComponentRef<CollectionActionsProps>[];
287
+ /**
288
+ * Collection-scoped component overrides. These take precedence over
289
+ * global overrides set on `<Rebase>`, but only within this collection's
290
+ * views (entity form, detail view, table, empty state, etc.).
291
+ *
292
+ * Only collection-scoped components (like `Entity.Form`, `Collection.EmptyState`,
293
+ * `Collection.Card`, etc.) can be overridden here. App-level components
294
+ * (like `Shell.AppBar`, `HomePage`) can only be overridden at the `<Rebase>` level.
295
+ *
296
+ * @example
297
+ * ```tsx
298
+ * const productsCollection: PostgresCollectionConfig = {
299
+ * name: "Products",
300
+ * slug: "products",
301
+ * table: "products",
302
+ * components: {
303
+ * "Entity.Form": { Component: ProductCustomForm },
304
+ * "Collection.Card": { Component: ProductCard },
305
+ * },
306
+ * properties: { ... }
307
+ * };
308
+ * ```
309
+ */
310
+ components?: CollectionComponentOverrideMap;
311
+ };
312
+ /**
313
+ * There is deliberately no `AdminCollectionConfig` here any more.
314
+ *
315
+ * It used to be `Omit<CollectionConfig, "admin"> & { admin?: AdminCollectionOptions }`,
316
+ * a wrapper that existed because core typed the block opaquely. Now that `augment.ts`
317
+ * declares `admin` directly on `BaseCollectionConfig`, `CollectionConfig` *is* the
318
+ * authoring type — the wrapper would be an alias of it, and a second name for one thing
319
+ * is what this whole refactor has been removing.
320
+ *
321
+ * A project opts its program in with one line, once:
322
+ *
323
+ * ```ts
324
+ * /// <reference types="@rebasepro/admin-types" />
325
+ * ```
326
+ *
327
+ * after which `admin` is typed on every collection and every property. Without it,
328
+ * writing one is an error — which is the guarantee a BaaS install depends on.
329
+ */
330
+ /**
331
+ * Define a collection with the admin block type-checked.
332
+ *
333
+ * The same identity function as `defineCollection` in `@rebasepro/common` — which
334
+ * is what a BaaS or headless project uses, and where `admin` does not exist at all
335
+ * — with one difference: importing this one brings the augmentation with it, so
336
+ * `admin: { icon, listProperties, kanban }` gets completion and a typo is an
337
+ * error. See {@link AdminCollectionOptions}.
338
+ *
339
+ * Import it from the layer you are in. A project with an admin panel wants this
340
+ * one; a project without one has no `admin` block to check.
341
+ *
342
+ * `const P` captures the literal property types, which is what gives
343
+ * `admin.titleProperty`, `admin.sort` and `admin.propertiesOrder` completion over
344
+ * the collection's own property keys rather than plain `string`.
345
+ *
346
+ * @example
347
+ * export default defineCollection({
348
+ * slug: "posts",
349
+ * table: "posts",
350
+ * properties: {
351
+ * title: { name: "Title", type: "string" },
352
+ * status: { name: "Status", type: "string" }
353
+ * },
354
+ * admin: {
355
+ * icon: "FileText",
356
+ * titleProperty: "title", // completion: "title" | "status"
357
+ * listProperties: ["title", "status"]
358
+ * }
359
+ * });
360
+ *
361
+ * @group Builder
362
+ */
363
+ export declare function defineCollection<const P extends PostgresProperties, USER extends User = User>(collection: Omit<PostgresCollectionConfig<InferEntityType<P>, USER>, "properties"> & {
364
+ properties: P;
365
+ }): PostgresCollectionConfig<InferEntityType<P>, USER> & {
366
+ properties: P;
367
+ };
368
+ /** Define a Firestore-backed collection with the admin block checked. @group Builder */
369
+ export declare function defineCollection<const P extends FirebaseProperties, USER extends User = User>(collection: Omit<FirebaseCollectionConfig<InferEntityType<P>, USER>, "properties"> & {
370
+ properties: P;
371
+ }): FirebaseCollectionConfig<InferEntityType<P>, USER> & {
372
+ properties: P;
373
+ };
374
+ /** Define a MongoDB-backed collection with the admin block checked. @group Builder */
375
+ export declare function defineCollection<const P extends MongoProperties, USER extends User = User>(collection: Omit<MongoDBCollectionConfig<InferEntityType<P>, USER>, "properties"> & {
376
+ properties: P;
377
+ }): MongoDBCollectionConfig<InferEntityType<P>, USER> & {
378
+ properties: P;
379
+ };
380
+ /**
381
+ * Re-exported from `@rebasepro/types`, where the list has to live: the ts-morph
382
+ * schema editor in `@rebasepro/server` needs it to know which keys go inside the
383
+ * block when it rewrites a collection file, and a core package may not import
384
+ * this one. The list is plain data, so core is a fine home for it.
385
+ *
386
+ * What core *cannot* do is check the list against the type. That happens here.
387
+ *
388
+ * @group Models
389
+ */
390
+ export type { AdminCollectionKey } from "@rebasepro/types";
391
+ /**
392
+ * Core's list, re-exported through a `satisfies` clause that is the agreement
393
+ * check: a key core names that is not an option here fails to compile, and
394
+ * `satisfies` keeps the literal tuple type rather than widening it to `string[]`.
395
+ *
396
+ * The reverse direction — an option missing from core's list — has no type-level
397
+ * expression, since there is no exhaustiveness check over an optional-property
398
+ * keyof. `test/admin_collection.test.ts` counts them instead.
399
+ */
400
+ export declare const ADMIN_COLLECTION_KEYS: readonly ["Actions", "additionalFields", "alwaysApplyDefaultValues", "components", "defaultEntityAction", "defaultFilter", "defaultSelectedView", "defaultSize", "defaultViewMode", "disableDefaultActions", "enabledViews", "entityActions", "entityViews", "exportable", "filterPresets", "fixedFilter", "formAutoSave", "formView", "group", "hideFromNavigation", "hideIdFromCollection", "hideIdFromForm", "icon", "includeJsonView", "inlineEditing", "kanban", "listProperties", "localChangesBackup", "openEntityMode", "orderProperty", "pagination", "previewProperties", "propertiesOrder", "selectionController", "selectionEnabled", "sideDialogWidth", "sort", "titleProperty"];
401
+ /**
402
+ * A collection as the admin panel works with it: the contract with the `admin`
403
+ * block flattened onto the top level.
404
+ *
405
+ * The panel reads presentation fields in a few hundred places, and threading
406
+ * `collection.admin?.propertiesOrder` through all of them would be noise that
407
+ * buys nothing — the panel has already resolved the collection by then, merging
408
+ * the declared config with the user's per-collection overrides from local
409
+ * storage. So the panel gets a flat *view model*, exactly as it already does for
410
+ * entities (`Entity` is an admin view model over flat rows, not a wire type).
411
+ *
412
+ * The distinction that matters is direction:
413
+ *
414
+ * - **Reading** a resolved collection → `AdminCollection` (flat, convenient).
415
+ * - **Authoring or persisting** one → core's `CollectionConfig`, with the `admin`
416
+ * block this package augments onto it (nested, which is what the file on disk
417
+ * and the wire both look like).
418
+ *
419
+ * `admin` is kept alongside the flattened fields so the collection editor can
420
+ * still see the block it has to write back.
421
+ *
422
+ * @group Models
423
+ */
424
+ export type AdminCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = WithFlatAdmin<CollectionConfig<M, USER>, M, USER>;
425
+ /**
426
+ * Flatten the admin block onto one member of the collection union at a time.
427
+ *
428
+ * `CollectionConfig` is a union discriminated on `engine`
429
+ * (Postgres | Firestore | MongoDB), and a bare `Omit<Union, "admin">` collapses it
430
+ * into a single object type with the discriminant widened. The result stops being
431
+ * assignable back to `CollectionConfig`, so every call that hands a resolved
432
+ * collection to a core function fails — which is exactly what happened. The
433
+ * `C extends unknown` clause makes the mapping distributive, so each member keeps
434
+ * its literal `engine` and stays assignable to its counterpart.
435
+ */
436
+ type WithFlatAdmin<C, M extends Record<string, unknown>, USER extends User> = C extends unknown ? Omit<C, "admin"> & AdminCollectionOptions<M, USER> & {
437
+ admin?: AdminCollectionOptions<M, USER>;
438
+ } : never;
439
+ /** {@link AdminCollection} for a Postgres collection. @group Models */
440
+ export type AdminPostgresCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = Omit<PostgresCollectionConfig<M, USER>, "admin"> & AdminCollectionOptions<M, USER> & {
441
+ admin?: AdminCollectionOptions<M, USER>;
442
+ };
443
+ /**
444
+ * Flatten a collection's `admin` block onto it, producing the panel's view model.
445
+ *
446
+ * Shallow by design: the block's fields are independent, so a deep merge would
447
+ * only create opportunities for a nested object to be half from one source and
448
+ * half from the other. `admin` survives on the result.
449
+ *
450
+ * Idempotent — flattening an already-flat collection returns an equivalent one —
451
+ * because the panel resolves collections at more than one entry point (the
452
+ * registry, `<Rebase collections>`, a plugin's `modifyCollection`) and they must
453
+ * not fight over which has run.
454
+ */
455
+ export declare function resolveAdminCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: CollectionConfig<M, USER> | AdminCollection<M, USER>): AdminCollection<M, USER>;
456
+ /**
457
+ * The inverse: lift flattened admin fields back into the block.
458
+ *
459
+ * Used on the way out — persisting from the collection editor, or handing a
460
+ * collection to anything that expects the authoring shape. Any key in
461
+ * {@link ADMIN_COLLECTION_KEYS} found at the top level is moved down, so a
462
+ * round trip through the panel does not leave the file flat.
463
+ */
464
+ export declare function toAdminCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: AdminCollection<M, USER> | CollectionConfig<M, USER>): CollectionConfig<M, USER>;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The admin block, added back onto the core types by declaration merging.
3
+ *
4
+ * `@rebasepro/types` declares no `admin` field — not on `BaseCollectionConfig`, not on
5
+ * any property. A BaaS install therefore cannot write one: `admin: { … }` on a property
6
+ * there is a type error, which is the whole point. Installing this package is what makes
7
+ * the surface exist.
8
+ *
9
+ * This works because every target is an `interface`. Interfaces merge; `type` aliases do
10
+ * not, so `BaseProperty` and the ten concrete property types must stay interfaces in core
11
+ * for this file to be possible at all.
12
+ *
13
+ * Two consequences worth knowing:
14
+ *
15
+ * - The augmentation applies to the whole **program**, not to the files that import it.
16
+ * `config/` and `frontend/` are separate tsconfig programs, so a collection file needs
17
+ * this package in *its* program. The templates do that with one line in one file —
18
+ * `config/admin.d.ts`, holding `/// <reference types="@rebasepro/admin-types" />` —
19
+ * which is why no collection file has to import anything from here to write `admin`.
20
+ * That reference resolves through `typeRoots`, so the project must also depend on this
21
+ * package; `scripts/check-templates.mjs` asserts both halves.
22
+ * - Each concrete property narrows the block to its own options type
23
+ * (`AdminStringOptions` on `StringProperty`, and so on). That is legal because each
24
+ * extends `AdminPropertyOptions`, exactly as it was declared when these lived in core.
25
+ */
26
+ import type { AdminArrayOptions, AdminDateOptions, AdminMapOptions, AdminNumberOptions, AdminPropertyOptions, AdminReferenceOptions, AdminRelationOptions, AdminStringOptions, AdminVectorOptions } from "./types/property_options";
27
+ import type { AdminCollectionOptions } from "./admin_collection";
28
+ declare module "@rebasepro/types" {
29
+ /** Presentation and behaviour for a collection in the admin panel. */
30
+ interface BaseCollectionConfig {
31
+ admin?: AdminCollectionOptions;
32
+ }
33
+ interface BaseProperty<CustomProps = unknown> {
34
+ admin?: AdminPropertyOptions<CustomProps>;
35
+ }
36
+ interface StringProperty {
37
+ admin?: AdminStringOptions;
38
+ }
39
+ interface NumberProperty {
40
+ admin?: AdminNumberOptions;
41
+ }
42
+ interface BooleanProperty {
43
+ admin?: AdminPropertyOptions;
44
+ }
45
+ interface VectorProperty {
46
+ admin?: AdminVectorOptions;
47
+ }
48
+ interface DateProperty {
49
+ admin?: AdminDateOptions;
50
+ }
51
+ interface GeopointProperty {
52
+ admin?: AdminPropertyOptions;
53
+ }
54
+ interface ReferenceProperty {
55
+ admin?: AdminReferenceOptions;
56
+ }
57
+ interface RelationProperty {
58
+ admin?: AdminRelationOptions;
59
+ }
60
+ interface ArrayProperty {
61
+ admin?: AdminArrayOptions;
62
+ }
63
+ interface MapProperty {
64
+ admin?: AdminMapOptions;
65
+ }
66
+ }