@rebasepro/server-postgresql 0.5.0 → 0.6.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 (165) hide show
  1. package/dist/{server-postgresql/src/PostgresAdapter.d.ts → PostgresAdapter.d.ts} +1 -1
  2. package/dist/{server-postgresql/src/PostgresBackendDriver.d.ts → PostgresBackendDriver.d.ts} +2 -2
  3. package/dist/{server-postgresql/src/PostgresBootstrapper.d.ts → PostgresBootstrapper.d.ts} +11 -1
  4. package/dist/{server-postgresql/src/collections → collections}/PostgresCollectionRegistry.d.ts +4 -0
  5. package/dist/index.es.js +10168 -11145
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/index.umd.js +10735 -11429
  8. package/dist/index.umd.js.map +1 -1
  9. package/dist/{server-postgresql/src/services → services}/EntityPersistService.d.ts +0 -14
  10. package/dist/utils/pg-error-utils.d.ts +55 -0
  11. package/package.json +24 -21
  12. package/src/PostgresAdapter.ts +9 -10
  13. package/src/PostgresBackendDriver.ts +134 -121
  14. package/src/PostgresBootstrapper.ts +86 -13
  15. package/src/auth/ensure-tables.ts +28 -5
  16. package/src/auth/services.ts +28 -18
  17. package/src/cli.ts +99 -96
  18. package/src/collections/PostgresCollectionRegistry.ts +7 -0
  19. package/src/connection.ts +11 -6
  20. package/src/data-transformer.ts +16 -14
  21. package/src/databasePoolManager.ts +3 -2
  22. package/src/history/HistoryService.ts +3 -2
  23. package/src/history/ensure-history-table.ts +5 -4
  24. package/src/schema/auth-schema.ts +1 -2
  25. package/src/schema/doctor-cli.ts +2 -1
  26. package/src/schema/doctor.ts +40 -37
  27. package/src/schema/generate-drizzle-schema-logic.ts +56 -18
  28. package/src/schema/generate-drizzle-schema.ts +11 -11
  29. package/src/schema/introspect-db-inference.ts +25 -25
  30. package/src/schema/introspect-db-logic.ts +38 -38
  31. package/src/schema/introspect-db.ts +28 -27
  32. package/src/services/BranchService.ts +14 -0
  33. package/src/services/EntityFetchService.ts +28 -25
  34. package/src/services/EntityPersistService.ts +11 -141
  35. package/src/services/RelationService.ts +57 -37
  36. package/src/services/entity-helpers.ts +6 -2
  37. package/src/services/realtimeService.ts +45 -32
  38. package/src/utils/drizzle-conditions.ts +31 -15
  39. package/src/utils/pg-error-utils.ts +211 -0
  40. package/src/websocket.ts +15 -12
  41. package/test/auth-services.test.ts +36 -19
  42. package/test/batch-many-to-many-regression.test.ts +119 -39
  43. package/test/data-transformer-hardening.test.ts +67 -33
  44. package/test/data-transformer.test.ts +4 -2
  45. package/test/doctor.test.ts +10 -5
  46. package/test/drizzle-conditions.test.ts +59 -6
  47. package/test/generate-drizzle-schema.test.ts +65 -40
  48. package/test/introspect-db-generation.test.ts +179 -81
  49. package/test/introspect-db-utils.test.ts +92 -37
  50. package/test/mocks/chalk.cjs +7 -0
  51. package/test/pg-error-utils.test.ts +221 -0
  52. package/test/postgresDataDriver.test.ts +14 -5
  53. package/test/property-ordering.test.ts +126 -79
  54. package/test/realtimeService.test.ts +6 -2
  55. package/test/relation-pipeline-gaps.test.ts +84 -36
  56. package/test/relations.test.ts +247 -0
  57. package/test/unmapped-tables-safety.test.ts +14 -6
  58. package/test/websocket.test.ts +1 -1
  59. package/tsconfig.json +5 -0
  60. package/tsconfig.prod.json +3 -0
  61. package/vite.config.ts +5 -5
  62. package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
  63. package/dist/common/src/collections/default-collections.d.ts +0 -9
  64. package/dist/common/src/collections/index.d.ts +0 -2
  65. package/dist/common/src/data/buildRebaseData.d.ts +0 -14
  66. package/dist/common/src/data/query_builder.d.ts +0 -55
  67. package/dist/common/src/index.d.ts +0 -4
  68. package/dist/common/src/util/builders.d.ts +0 -57
  69. package/dist/common/src/util/callbacks.d.ts +0 -6
  70. package/dist/common/src/util/collections.d.ts +0 -11
  71. package/dist/common/src/util/common.d.ts +0 -2
  72. package/dist/common/src/util/conditions.d.ts +0 -26
  73. package/dist/common/src/util/entities.d.ts +0 -58
  74. package/dist/common/src/util/enums.d.ts +0 -3
  75. package/dist/common/src/util/index.d.ts +0 -16
  76. package/dist/common/src/util/navigation_from_path.d.ts +0 -34
  77. package/dist/common/src/util/navigation_utils.d.ts +0 -20
  78. package/dist/common/src/util/parent_references_from_path.d.ts +0 -6
  79. package/dist/common/src/util/paths.d.ts +0 -14
  80. package/dist/common/src/util/permissions.d.ts +0 -14
  81. package/dist/common/src/util/references.d.ts +0 -2
  82. package/dist/common/src/util/relations.d.ts +0 -22
  83. package/dist/common/src/util/resolutions.d.ts +0 -72
  84. package/dist/common/src/util/storage.d.ts +0 -24
  85. package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
  86. package/dist/types/src/controllers/auth.d.ts +0 -104
  87. package/dist/types/src/controllers/client.d.ts +0 -168
  88. package/dist/types/src/controllers/collection_registry.d.ts +0 -46
  89. package/dist/types/src/controllers/customization_controller.d.ts +0 -60
  90. package/dist/types/src/controllers/data.d.ts +0 -207
  91. package/dist/types/src/controllers/data_driver.d.ts +0 -218
  92. package/dist/types/src/controllers/database_admin.d.ts +0 -11
  93. package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
  94. package/dist/types/src/controllers/effective_role.d.ts +0 -4
  95. package/dist/types/src/controllers/email.d.ts +0 -36
  96. package/dist/types/src/controllers/index.d.ts +0 -18
  97. package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
  98. package/dist/types/src/controllers/navigation.d.ts +0 -225
  99. package/dist/types/src/controllers/registry.d.ts +0 -63
  100. package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
  101. package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
  102. package/dist/types/src/controllers/snackbar.d.ts +0 -24
  103. package/dist/types/src/controllers/storage.d.ts +0 -171
  104. package/dist/types/src/index.d.ts +0 -4
  105. package/dist/types/src/rebase_context.d.ts +0 -122
  106. package/dist/types/src/types/auth_adapter.d.ts +0 -301
  107. package/dist/types/src/types/backend.d.ts +0 -571
  108. package/dist/types/src/types/backend_hooks.d.ts +0 -172
  109. package/dist/types/src/types/builders.d.ts +0 -15
  110. package/dist/types/src/types/chips.d.ts +0 -5
  111. package/dist/types/src/types/collections.d.ts +0 -961
  112. package/dist/types/src/types/component_ref.d.ts +0 -47
  113. package/dist/types/src/types/cron.d.ts +0 -102
  114. package/dist/types/src/types/data_source.d.ts +0 -64
  115. package/dist/types/src/types/database_adapter.d.ts +0 -94
  116. package/dist/types/src/types/entities.d.ts +0 -145
  117. package/dist/types/src/types/entity_actions.d.ts +0 -104
  118. package/dist/types/src/types/entity_callbacks.d.ts +0 -173
  119. package/dist/types/src/types/entity_link_builder.d.ts +0 -7
  120. package/dist/types/src/types/entity_overrides.d.ts +0 -10
  121. package/dist/types/src/types/entity_views.d.ts +0 -87
  122. package/dist/types/src/types/export_import.d.ts +0 -21
  123. package/dist/types/src/types/formex.d.ts +0 -40
  124. package/dist/types/src/types/index.d.ts +0 -28
  125. package/dist/types/src/types/locales.d.ts +0 -4
  126. package/dist/types/src/types/modify_collections.d.ts +0 -5
  127. package/dist/types/src/types/plugins.d.ts +0 -282
  128. package/dist/types/src/types/properties.d.ts +0 -1173
  129. package/dist/types/src/types/property_config.d.ts +0 -74
  130. package/dist/types/src/types/relations.d.ts +0 -336
  131. package/dist/types/src/types/slots.d.ts +0 -262
  132. package/dist/types/src/types/translations.d.ts +0 -900
  133. package/dist/types/src/types/user_management_delegate.d.ts +0 -86
  134. package/dist/types/src/types/websockets.d.ts +0 -78
  135. package/dist/types/src/users/index.d.ts +0 -1
  136. package/dist/types/src/users/user.d.ts +0 -50
  137. /package/dist/{server-postgresql/src/auth → auth}/ensure-tables.d.ts +0 -0
  138. /package/dist/{server-postgresql/src/auth → auth}/services.d.ts +0 -0
  139. /package/dist/{server-postgresql/src/cli.d.ts → cli.d.ts} +0 -0
  140. /package/dist/{server-postgresql/src/connection.d.ts → connection.d.ts} +0 -0
  141. /package/dist/{server-postgresql/src/data-transformer.d.ts → data-transformer.d.ts} +0 -0
  142. /package/dist/{server-postgresql/src/databasePoolManager.d.ts → databasePoolManager.d.ts} +0 -0
  143. /package/dist/{server-postgresql/src/history → history}/HistoryService.d.ts +0 -0
  144. /package/dist/{server-postgresql/src/history → history}/ensure-history-table.d.ts +0 -0
  145. /package/dist/{server-postgresql/src/index.d.ts → index.d.ts} +0 -0
  146. /package/dist/{server-postgresql/src/interfaces.d.ts → interfaces.d.ts} +0 -0
  147. /package/dist/{server-postgresql/src/schema → schema}/auth-schema.d.ts +0 -0
  148. /package/dist/{server-postgresql/src/schema → schema}/doctor-cli.d.ts +0 -0
  149. /package/dist/{server-postgresql/src/schema → schema}/doctor.d.ts +0 -0
  150. /package/dist/{server-postgresql/src/schema → schema}/generate-drizzle-schema-logic.d.ts +0 -0
  151. /package/dist/{server-postgresql/src/schema → schema}/generate-drizzle-schema.d.ts +0 -0
  152. /package/dist/{server-postgresql/src/schema → schema}/introspect-db-inference.d.ts +0 -0
  153. /package/dist/{server-postgresql/src/schema → schema}/introspect-db-logic.d.ts +0 -0
  154. /package/dist/{server-postgresql/src/schema → schema}/introspect-db.d.ts +0 -0
  155. /package/dist/{server-postgresql/src/schema → schema}/test-schema.d.ts +0 -0
  156. /package/dist/{server-postgresql/src/services → services}/BranchService.d.ts +0 -0
  157. /package/dist/{server-postgresql/src/services → services}/EntityFetchService.d.ts +0 -0
  158. /package/dist/{server-postgresql/src/services → services}/RelationService.d.ts +0 -0
  159. /package/dist/{server-postgresql/src/services → services}/entity-helpers.d.ts +0 -0
  160. /package/dist/{server-postgresql/src/services → services}/entityService.d.ts +0 -0
  161. /package/dist/{server-postgresql/src/services → services}/index.d.ts +0 -0
  162. /package/dist/{server-postgresql/src/services → services}/realtimeService.d.ts +0 -0
  163. /package/dist/{server-postgresql/src/types.d.ts → types.d.ts} +0 -0
  164. /package/dist/{server-postgresql/src/utils → utils}/drizzle-conditions.d.ts +0 -0
  165. /package/dist/{server-postgresql/src/websocket.d.ts → websocket.d.ts} +0 -0
@@ -1,961 +0,0 @@
1
- import React from "react";
2
- import type { Entity, EntityStatus } from "./entities";
3
- import type { EntityCallbacks } from "./entity_callbacks";
4
- import type { Properties } from "./properties";
5
- import type { ExportConfig } from "./export_import";
6
- import type { EntityOverrides } from "./entity_overrides";
7
- import type { User } from "../users";
8
- import type { RebaseContext } from "../rebase_context";
9
- import type { Relation } from "./relations";
10
- import type { EntityCustomView, FormViewConfig } from "./entity_views";
11
- import type { EntityAction } from "./entity_actions";
12
- import type { ComponentRef } from "./component_ref";
13
- /**
14
- * Base interface containing all driver-agnostic collection properties.
15
- * Use {@link PostgresCollection} or {@link FirebaseCollection} for
16
- * driver-specific type safety, or {@link EntityCollection} when you
17
- * need to handle any collection regardless of backend.
18
- *
19
- * @group Models
20
- */
21
- export interface BaseEntityCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
22
- /**
23
- * You can set an alias that will be used internally instead of the collection name.
24
- * The `slug` value will be used to determine the URL of the collection.
25
- * Note that you can use this value in reference properties too.
26
- */
27
- slug: string;
28
- /**
29
- * Name of the collection, typically plural.
30
- * E.g. `Products`, `Blog`
31
- */
32
- name: string;
33
- /**
34
- * Singular name of an entry in this collection
35
- * E.g. `Product`, `Blog entry`
36
- */
37
- singularName?: string;
38
- /**
39
- * Optional description of this view. You can use Markdown.
40
- */
41
- description?: string;
42
- /**
43
- * Child collections nested under entities of this collection.
44
- * Populated automatically during normalization from driver-specific fields
45
- * (e.g. Firebase `subcollections`, Postgres `relations` with many-cardinality).
46
- *
47
- * Custom drivers can set this directly to expose child collections to the UI.
48
- */
49
- childCollections?: () => EntityCollection<Record<string, unknown>>[];
50
- /**
51
- * Which driver handles this collection.
52
- * Use this to route collections to different backends:
53
- * - `"postgres"` - Route to PostgreSQL backend
54
- * - `"firestore"` - Route to Firestore (client-side)
55
- * - `"mongodb"` - Route to MongoDB backend
56
- * - Custom IDs for your own driver implementations
57
- *
58
- * If not specified, the default driver `"(default)"` is used.
59
- *
60
- * @example
61
- * // Simple - no driver needed for default
62
- * { slug: "products" }
63
- *
64
- * // Firestore collection (client-side real-time)
65
- * { slug: "analytics", driver: "firestore" }
66
- *
67
- * // Multiple databases within a driver
68
- * { slug: "orders", driver: "postgres", databaseId: "orders_db" }
69
- */
70
- driver?: string;
71
- /**
72
- * Which database within the driver.
73
- * - For Firestore: The Firestore database ID (e.g., for multi-database projects)
74
- * - For PostgreSQL: Schema or database name
75
- * - For MongoDB: Database name
76
- *
77
- * If not specified, the default database of the driver is used.
78
- */
79
- databaseId?: string;
80
- /**
81
- * Set of properties that compose an entity
82
- */
83
- properties: Properties;
84
- /**
85
- * Icon for the navigation sidebar or cards.
86
- */
87
- icon?: string | React.ReactNode;
88
- /**
89
- * Navigation group for this collection.
90
- * Collections sharing the same group name will be visually grouped
91
- * together in the drawer and home page. If not set, the collection
92
- * falls into the default "Views" group.
93
- */
94
- group?: string;
95
- /**
96
- * Array of entity views that this collection has.
97
- * Can be an array of `EntityCustomView` or a string representing the key of a global `EntityCustomView`.
98
- */
99
- entityViews?: (string | EntityCustomView<Record<string, unknown>>)[];
100
- /**
101
- * Default preview properties displayed when this collection is referenced to.
102
- */
103
- previewProperties?: string[];
104
- /**
105
- * Properties to display as columns in the list view.
106
- * If not specified, the list view uses a smart default (Title, Status, Date).
107
- */
108
- listProperties?: string[];
109
- /**
110
- * Title property of the entity. This is the property that will be used
111
- * as the title in entity related views and references.
112
- * If not specified, the first property simple text property will be used.
113
- */
114
- readonly titleProperty?: Extract<keyof M, string> | (string & {});
115
- /**
116
- * When editing an entity, you can choose to open the entity in a side dialog
117
- * or in a full screen dialog. Defaults to `full_screen`.
118
- */
119
- openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
120
- /**
121
- * Controls what happens when a user clicks on an entity in the collection view.
122
- * - `"edit"` (default): Opens the entity in the edit form.
123
- * - `"view"`: Opens a read-only detail view with an "Edit" button.
124
- */
125
- defaultEntityAction?: "view" | "edit";
126
- /**
127
- * Replace the default entity form with a custom component.
128
- * The Builder receives the same props as entity view tabs
129
- * (entity, formContext, collection, etc.) and has full control over the UI.
130
- *
131
- * Works in both edit mode and read-only mode (when `defaultEntityAction`
132
- * is `"view"`). In read-only mode, `formContext.readOnly` will be `true`.
133
- */
134
- formView?: FormViewConfig;
135
- /**
136
- * Prevent default actions from being displayed or executed on this collection.
137
- */
138
- disableDefaultActions?: ("edit" | "copy" | "delete")[];
139
- /**
140
- * Order in which the properties are displayed.
141
- * If you are specifying your collection as code, the order is the same as the
142
- * one you define in `properties`. Additional columns are added at the
143
- * end of the list, if the order is not specified.
144
- * You can use this prop to hide some properties from the table view.
145
- * Note that if you set this prop, other ways to hide fields, like
146
- * `hidden` in the property definition, will be ignored.
147
- * `propertiesOrder` has precedence over `hidden`.
148
- * - For properties use the property key.
149
- * - For additional fields use the field key.
150
- * - If you have subcollections, you get a column for each subcollection,
151
- * with the path (or alias) as the subcollection, prefixed with
152
- * `subcollection:`. e.g. `subcollection:orders`.
153
- * You can use this prop to hide some properties from the table view.
154
- * Note that if you set this prop, other ways to hide fields, like
155
- * `hidden` in the property definition,will be ignored.
156
- * `propertiesOrder` has precedence over `hidden`.
157
- */
158
- propertiesOrder?: (Extract<keyof M, string> | (string & {}) | string | `subcollection:${string}`)[];
159
- /**
160
- * If enabled, content is loaded in batches. If `false` all entities in the
161
- * collection are loaded. This means that when reaching the end of the
162
- * collection, the CMS will load more entities.
163
- * You can specify a number to specify the pagination size (50 by default)
164
- * Defaults to `true`
165
- */
166
- pagination?: boolean | number;
167
- selectionEnabled?: boolean;
168
- /**
169
- * This interface defines all the callbacks that can be used when an entity
170
- * is being created, updated or deleted.
171
- * Useful for adding your own logic or blocking the execution of the operation.
172
- */
173
- readonly callbacks?: EntityCallbacks<M, USER>;
174
- /**
175
- * Pass your own selection controller if you want to control selected
176
- * entities externally.
177
- * @see useSelectionController
178
- */
179
- selectionController?: SelectionController<M>;
180
- /**
181
- * Force a filter in this view. If applied, the rest of the filters will
182
- * be disabled. Filters applied with this prop cannot be changed.
183
- * e.g. `fixedFilter: { age: [">", 18] }`
184
- * e.g. `fixedFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
185
- */
186
- readonly fixedFilter?: FilterValues<Extract<keyof M, string> | (string & {})>;
187
- /**
188
- * Initial filters applied to the collection this collection is related to.
189
- * Defaults to none. Filters applied with this prop can be changed.
190
- * e.g. `defaultFilter: { age: [">", 18] }`
191
- * e.g. `defaultFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
192
- */
193
- readonly defaultFilter?: FilterValues<Extract<keyof M, string> | (string & {})>;
194
- /**
195
- * Pre-defined filter presets that appear as quick-access options in the
196
- * collection toolbar. Each preset applies a set of filters (and
197
- * optionally a sort order) with a single click.
198
- *
199
- * ```ts
200
- * filterPresets: [
201
- * {
202
- * label: "Shipped this month",
203
- * filterValues: {
204
- * status: ["==", "shipped"],
205
- * order_date: [">=", new Date(Date.now() - 30 * 86400000)]
206
- * }
207
- * }
208
- * ]
209
- * ```
210
- */
211
- readonly filterPresets?: FilterPreset<Extract<keyof M, string> | (string & {})>[];
212
- /**
213
- * Default sort applied to this collection.
214
- * When setting this prop, entities will have a default order
215
- * applied in the collection.
216
- * e.g. `sort: ["order", "asc"]`
217
- */
218
- readonly sort?: [Extract<keyof M, string> | (string & {}), "asc" | "desc"];
219
- /**
220
- * You can add additional fields to the collection view by implementing
221
- * an additional field delegate.
222
- */
223
- readonly additionalFields?: AdditionalFieldDelegate<M, USER>[];
224
- /**
225
- * Default size of the rendered collection
226
- */
227
- defaultSize?: CollectionSize;
228
- /**
229
- * Can the elements in this collection be edited inline in the collection
230
- * view. If this flag is set to false but `permissions.edit` is `true`, entities
231
- * can still be edited in the side panel
232
- */
233
- inlineEditing?: boolean;
234
- /**
235
- * Should this collection be hidden from the main navigation panel, if
236
- * it is at the root level, or in the entity side panel if it's a
237
- * subcollection.
238
- * It will still be accessible if you reach the specified path.
239
- * You can also use this collection as a reference target.
240
- */
241
- hideFromNavigation?: boolean;
242
- /**
243
- * If you want to open custom views or subcollections by default when opening the edit
244
- * view of an entity, you can specify the path to the view here.
245
- * The path is relative to the current collection. For example if you have a collection
246
- * that has a custom view as well as a subcollection that refers to another entity, you can
247
- * either specify the path to the custom view or the path to the subcollection.
248
- */
249
- defaultSelectedView?: string | DefaultSelectedViewBuilder;
250
- /**
251
- * Should the ID of this collection be hidden from the form view.
252
- */
253
- hideIdFromForm?: boolean;
254
- /**
255
- * Should the ID of this collection be hidden from the grid view.
256
- */
257
- hideIdFromCollection?: boolean;
258
- /**
259
- * If set to true, the form will be auto-saved when the user changes
260
- * the value of a field.
261
- * Defaults to false.
262
- * When a new entity is created, this property can be updated to generated a new ID
263
- */
264
- formAutoSave?: boolean;
265
- /**
266
- *
267
- */
268
- exportable?: boolean | ExportConfig<USER>;
269
- /**
270
- * User id of the owner of this collection. This is used only by plugins, or if you
271
- * are writing custom code
272
- */
273
- ownerId?: string;
274
- /**
275
- * Overrides for the entity view, like the data source or the storage source.
276
- */
277
- overrides?: EntityOverrides;
278
- /**
279
- * Width of the side dialog (in pixels) when opening an entity in this collection.
280
- */
281
- sideDialogWidth?: number | string;
282
- /**
283
- * If set to true, the default values of the properties will be applied
284
- * to the entity every time the entity is updated (not only when created).
285
- * Defaults to false.
286
- */
287
- alwaysApplyDefaultValues?: boolean;
288
- /**
289
- * If set to true, a tab including the JSON representation of the entity will be included.
290
- */
291
- includeJsonView?: boolean;
292
- /**
293
- * If set to true, changes to the entity will be saved in a subcollection.
294
- * This prop has no effect if the history plugin is not enabled
295
- */
296
- history?: boolean;
297
- /**
298
- * Should local changes be backed up in local storage, to prevent data loss on
299
- * accidental navigations.
300
- * - `manual_apply`: When the user navigates back to an entity with local changes,
301
- * they will be prompted to restore the changes.
302
- * - `auto_apply`: When the user navigates back to an entity with local changes,
303
- * the changes will be automatically applied.
304
- * - `false`: Local changes will not be backed up.
305
- * Defaults to `manual_apply`.
306
- */
307
- localChangesBackup?: "manual_apply" | "auto_apply" | false;
308
- /**
309
- * Default view mode for displaying this collection.
310
- * - "table": Display entities in a table with inline editing (default)
311
- * - "cards": Display entities as a grid of cards with thumbnails
312
- * - "kanban": Display entities in a Kanban board grouped by a property
313
- * Defaults to "table".
314
- */
315
- defaultViewMode?: ViewMode;
316
- /**
317
- * Which view modes are available for this collection.
318
- * Possible values: "table", "cards", "kanban".
319
- * Defaults to all three: ["table", "cards", "kanban"].
320
- * Note: "kanban" will only be available if the collection has at least
321
- * one string property with enumValues defined, regardless of this setting.
322
- */
323
- enabledViews?: ViewMode[];
324
- /**
325
- * Configuration for Kanban board view mode.
326
- * When set, the Kanban view mode becomes available.
327
- */
328
- kanban?: KanbanConfig<M>;
329
- /**
330
- * Property key to use for ordering items.
331
- * Must reference a string/text property. When items are reordered,
332
- * this property will be updated with lexicographic sort keys
333
- * (e.g. "a0", "a1", "a0V") using string-based fractional indexing.
334
- * Used by Kanban view for ordering within columns
335
- * and can be used for general ordering purposes.
336
- */
337
- readonly orderProperty?: Extract<keyof M, string> | (string & {});
338
- /**
339
- * Actions that can be performed on the entities in this collection.
340
- */
341
- entityActions?: EntityAction<M, USER>[];
342
- /**
343
- * Builder for the collection actions rendered in the toolbar
344
- */
345
- Actions?: ComponentRef<CollectionActionsProps>[];
346
- /**
347
- * The database table name for this collection.
348
- * Automatically set for PostgreSQL collections.
349
- * For non-SQL backends, this may be undefined.
350
- */
351
- table?: string;
352
- /**
353
- * Relations defined for this collection.
354
- * Populated at normalization time from inline relation properties
355
- * or explicit relation definitions.
356
- */
357
- relations?: Relation[];
358
- /**
359
- * Security rules for this collection (Row Level Security).
360
- * When defined, the backend enforces access control policies.
361
- */
362
- securityRules?: SecurityRule[];
363
- }
364
- /**
365
- * A collection backed by PostgreSQL (or any SQL database).
366
- * Adds support for SQL-style relations (JOINs) and Row Level Security.
367
- *
368
- * Use this type instead of {@link EntityCollection} when you want
369
- * compile-time safety that only SQL-relevant fields appear.
370
- *
371
- * @group Models
372
- */
373
- export interface PostgresCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> extends BaseEntityCollection<M, USER> {
374
- properties: Properties;
375
- /**
376
- * The driver for this collection. For Postgres collections this
377
- * can be omitted (Postgres is the default) or set to `"postgres"`.
378
- */
379
- driver?: "postgres" | undefined;
380
- /**
381
- * The PostgreSQL table name for this collection.
382
- */
383
- table: string;
384
- /**
385
- * The PostgreSQL schema name for this table.
386
- * E.g. "public", "rebase", "auth".
387
- * If not specified, "public" is used (or the default search path).
388
- */
389
- schema?: string;
390
- /**
391
- * For SQL databases, you can define the relations between collections here.
392
- * Relations describe JOINs, foreign keys, and junction tables.
393
- */
394
- relations?: Relation[];
395
- /**
396
- * Security rules for this collection (Supabase-style Row Level Security).
397
- * When defined, the schema generator will enable RLS on the table and
398
- * create the corresponding PostgreSQL policies.
399
- *
400
- * Supports three levels of expressiveness:
401
- * 1. **Convenience shortcuts** — `ownerField`, `access`, `roles`
402
- * 2. **Raw SQL** — `using` and `withCheck` for full PostgreSQL power
403
- * 3. **Combined** — mix shortcuts with `roles` for common patterns
404
- *
405
- * The authenticated user context is available in raw SQL via:
406
- * - `auth.uid()` — the current user's ID
407
- * - `auth.roles()` — comma-separated app role IDs
408
- * - `auth.jwt()` — full JWT claims as JSONB
409
- */
410
- securityRules?: SecurityRule[];
411
- }
412
- /**
413
- * A collection backed by Firebase / Firestore.
414
- * Adds support for subcollections (nested document collections).
415
- *
416
- * Use this type instead of {@link EntityCollection} when you want
417
- * compile-time safety that only Firestore-relevant fields appear.
418
- *
419
- * @group Models
420
- */
421
- export interface FirebaseCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> extends BaseEntityCollection<M, USER> {
422
- /**
423
- * The driver for this collection. Must be set to `"firestore"`.
424
- */
425
- driver: "firestore";
426
- /**
427
- * You can add subcollections to your entity in the same way you define the root
428
- * collections. The collections added here will be displayed when opening
429
- * the side dialog of an entity.
430
- */
431
- subcollections?: () => EntityCollection<Record<string, unknown>>[];
432
- }
433
- /**
434
- * A collection backed by MongoDB.
435
- *
436
- * Use this type instead of {@link EntityCollection} when you want
437
- * compile-time safety that only MongoDB-relevant fields appear.
438
- *
439
- * @group Models
440
- */
441
- export interface MongoDBCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> extends BaseEntityCollection<M, USER> {
442
- /**
443
- * The driver for this collection. Must be set to `"mongodb"`.
444
- */
445
- driver: "mongodb";
446
- }
447
- /**
448
- * A collection backed by any data source.
449
- * This is a discriminated union — use {@link PostgresCollection},
450
- * {@link FirebaseCollection}, or {@link MongoDBCollection} for
451
- * driver-specific type safety.
452
- *
453
- * @group Models
454
- */
455
- export type EntityCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = PostgresCollection<M, USER> | FirebaseCollection<M, USER> | MongoDBCollection<M, USER>;
456
- /**
457
- * An EntityCollection that supports SQL-style relations (e.g. Postgres).
458
- * @deprecated Use `EntityCollection` directly — `table`, `relations`, and `securityRules` are now on `BaseEntityCollection`.
459
- */
460
- export type CollectionWithRelations<M extends Record<string, unknown> = Record<string, unknown>> = EntityCollection<M> & {
461
- table?: string;
462
- relations?: Relation[];
463
- securityRules?: SecurityRule[];
464
- };
465
- /** An EntityCollection that supports subcollections (e.g. Firestore). */
466
- export type CollectionWithSubcollections<M extends Record<string, unknown> = Record<string, unknown>> = EntityCollection<M> & {
467
- subcollections?: () => EntityCollection<Record<string, unknown>>[];
468
- };
469
- /**
470
- * Type guard for PostgreSQL collections.
471
- * Returns true if the collection uses the Postgres driver (or the default driver).
472
- * @group Models
473
- */
474
- export declare function isPostgresCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: EntityCollection<M, USER>): collection is PostgresCollection<M, USER>;
475
- /**
476
- * Type guard for Firebase / Firestore collections.
477
- * @group Models
478
- */
479
- export declare function isFirebaseCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: EntityCollection<M, USER>): collection is FirebaseCollection<M, USER>;
480
- /**
481
- * Type guard for MongoDB collections.
482
- * @group Models
483
- */
484
- export declare function isMongoDBCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: EntityCollection<M, USER>): collection is MongoDBCollection<M, USER>;
485
- /**
486
- * Configuration for Kanban board view mode.
487
- * @group Collections
488
- */
489
- export interface KanbanConfig<M extends Record<string, unknown> = Record<string, unknown>> {
490
- /**
491
- * Property key to use for Kanban board columns.
492
- * Must reference a string property with enumValues defined.
493
- * Entities will be grouped into columns based on this property's value.
494
- * The column order is determined by the order of enumValues in the property.
495
- */
496
- columnProperty: Extract<keyof M, string> | (string & {});
497
- }
498
- /**
499
- * View mode for displaying a collection.
500
- * - "list": Simple, clean list view — the classic CMS default
501
- * - "table": Table with inline editing
502
- * - "cards": Grid of visual cards with thumbnails
503
- * - "kanban": Board view grouped by a property
504
- * @group Collections
505
- */
506
- export type ViewMode = "list" | "table" | "cards" | "kanban";
507
- /**
508
- * Parameter passed to the `Actions` prop in the collection configuration.
509
- * The component will receive this prop when it is rendered in the collection
510
- * toolbar.
511
- *
512
- * @group Models
513
- */
514
- export interface CollectionActionsProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
515
- /**
516
- * Full collection path of this entity. This is the full path, like
517
- * `users/1234/addresses`
518
- */
519
- path: string;
520
- /**
521
- * Path of the last collection, like `addresses`
522
- */
523
- relativePath: string;
524
- /**
525
- * Array of the parent path segments like `['users']`
526
- */
527
- parentCollectionSlugs: string[];
528
- parentEntityIds: string[];
529
- /**
530
- * The collection configuration
531
- */
532
- collection: EC;
533
- /**
534
- * Use this controller to get the selected entities and to update the
535
- * selected entities state.
536
- */
537
- selectionController: SelectionController<M>;
538
- /**
539
- * Use this controller to get the table controller and to update the
540
- * table controller state.
541
- */
542
- tableController: EntityTableController<M>;
543
- /**
544
- * Context of the app status
545
- */
546
- context: RebaseContext<USER>;
547
- /**
548
- * Count of the entities in this collection.
549
- * undefined means the count is still loading.
550
- */
551
- collectionEntitiesCount?: number;
552
- /**
553
- * Programmatically open the new-document form for this collection,
554
- * optionally pre-populating it with initial field values.
555
- * The form opens in the same mode configured for the collection
556
- * (side panel, full screen, or split).
557
- *
558
- * This is the primary hook for workflows that need to create a document
559
- * from external data — e.g. fetching content from a URL, importing from
560
- * a third-party API, or duplicating from another system.
561
- *
562
- * @example
563
- * // Inside a custom CollectionAction component:
564
- * openNewDocument({ title: "Fetched title", body: "..." });
565
- */
566
- openNewDocument: (defaultValues?: Record<string, unknown>) => void;
567
- }
568
- /**
569
- * Use this controller to retrieve the selected entities or modify them in
570
- * an {@link EntityCollection}
571
- * @group Models
572
- */
573
- export interface SelectionController<M extends Record<string, unknown> = Record<string, unknown>> {
574
- selectedEntities: Entity<M>[];
575
- setSelectedEntities(entities: Entity<M>[]): void;
576
- setSelectedEntities(action: (prev: Entity<M>[]) => Entity<M>[]): void;
577
- isEntitySelected(entity: Entity<M>): boolean;
578
- toggleEntitySelection(entity: Entity<M>, newSelectedState?: boolean): void;
579
- }
580
- /**
581
- * Filter conditions in a `Query.where()` clause are specified using the
582
- * strings `<`, `<=`, `==`, `>=`, `>`, `array-contains`, `in`, and `array-contains-any`.
583
- * @group Models
584
- */
585
- export type WhereFilterOp = "<" | "<=" | "==" | "!=" | ">=" | ">" | "array-contains" | "in" | "not-in" | "array-contains-any";
586
- /**
587
- * Used to define filters applied in collections
588
- *
589
- * e.g. `{ age: [">=", 18] }`
590
- *
591
- * @group Models
592
- */
593
- export type FilterValues<Key extends string> = Partial<Record<Key, [WhereFilterOp, unknown] | [WhereFilterOp, unknown][]>>;
594
- /**
595
- * A pre-defined filter preset for quick access in the collection toolbar.
596
- * Users can select a preset to instantly apply a set of filters and
597
- * optionally a sort order.
598
- *
599
- * @group Models
600
- */
601
- export interface FilterPreset<Key extends string = string> {
602
- /**
603
- * Display label shown in the preset menu.
604
- * If omitted, a summary is auto-generated from the filter keys.
605
- */
606
- label?: string;
607
- /**
608
- * The filter values to apply when this preset is selected.
609
- */
610
- filterValues: FilterValues<Key>;
611
- /**
612
- * Optional sort override to apply alongside the filter values.
613
- */
614
- sort?: [Key, "asc" | "desc"];
615
- }
616
- /**
617
- * Used to indicate valid filter combinations (e.g. created in Firestore)
618
- * If the user selects a specific filter/sort combination, the CMS checks if it's
619
- * valid, otherwise it reverts to the simpler valid case
620
- * @group Models
621
- */
622
- export type FilterCombination<Key extends string> = Partial<Record<Key, "asc" | "desc">>;
623
- /**
624
- * Sizes in which a collection can be rendered
625
- * @group Models
626
- */
627
- export type CollectionSize = "xs" | "s" | "m" | "l" | "xl";
628
- export type AdditionalFieldDelegateProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = {
629
- entity: Entity<M>;
630
- context: RebaseContext<USER>;
631
- };
632
- /**
633
- * Use this interface for adding additional fields to entity collection views and forms.
634
- * @group Models
635
- */
636
- export interface AdditionalFieldDelegate<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
637
- /**
638
- * ID of this column. You can use this id in the `properties` field of the
639
- * collection in any order you want
640
- */
641
- key: string;
642
- /**
643
- * Header of this column
644
- */
645
- name: string;
646
- /**
647
- * Width of the generated column in pixels
648
- */
649
- width?: number;
650
- /**
651
- * Builder for the custom field
652
- */
653
- Builder?(props: {
654
- entity: Entity<M>;
655
- context: RebaseContext<USER>;
656
- }): React.ReactNode;
657
- /**
658
- * If this column needs to update dynamically based on other properties,
659
- * you can define an array of keys as strings with the
660
- * `dependencies` prop.
661
- * e.g. ["name", "surname"]
662
- * This is a performance optimization, if you don't define dependencies
663
- * it will be updated in every render.
664
- */
665
- dependencies?: NoInfer<Extract<keyof M, string>> | NoInfer<Extract<keyof M, string>>[] | (string & {}) | (string & {})[];
666
- /**
667
- * Use this prop to define the value of the column as a string or number.
668
- * This is the value that will be used for exporting the collection.
669
- * If `Builder` is defined, this prop will be ignored in the collection
670
- * view.
671
- * @param entity
672
- */
673
- value?(props: {
674
- entity: Entity<M>;
675
- context: RebaseContext;
676
- }): string | number | Promise<string | number> | undefined;
677
- }
678
- export type InferCollectionType<S extends EntityCollection> = S extends EntityCollection<infer M> ? M : never;
679
- /**
680
- * Used in the {@link EntityCollection#defaultSelectedView} to define the default
681
- * @group Models
682
- */
683
- export type DefaultSelectedViewBuilder = (params: DefaultSelectedViewParams) => string | undefined;
684
- /**
685
- * Used in the {@link EntityCollection#defaultSelectedView} to define the default
686
- * @group Models
687
- */
688
- export type DefaultSelectedViewParams = {
689
- status?: EntityStatus;
690
- entityId?: string | number;
691
- };
692
- /**
693
- * You can use this controller to control the table view of a collection.
694
- */
695
- export type EntityTableController<M extends Record<string, unknown> = Record<string, unknown>> = {
696
- data: Entity<M>[];
697
- dataLoading: boolean;
698
- noMoreToLoad: boolean;
699
- dataLoadingError?: Error;
700
- filterValues?: FilterValues<Extract<keyof M, string> | (string & {})>;
701
- setFilterValues?: (filterValues: FilterValues<Extract<keyof M, string> | (string & {})>) => void;
702
- sortBy?: [Extract<keyof M, string> | (string & {}), "asc" | "desc"];
703
- setSortBy?: (sortBy?: [Extract<keyof M, string> | (string & {}), "asc" | "desc"]) => void;
704
- searchString?: string;
705
- setSearchString?: (searchString?: string) => void;
706
- clearFilter?: () => void;
707
- itemCount?: number;
708
- setItemCount?: (itemCount: number) => void;
709
- initialScroll?: number;
710
- onScroll?: (props: {
711
- scrollDirection: "forward" | "backward";
712
- scrollOffset: number;
713
- scrollUpdateWasRequested: boolean;
714
- }) => void;
715
- paginationEnabled?: boolean;
716
- pageSize?: number;
717
- checkFilterCombination?: (filterValues: FilterValues<string>, sortBy?: [string, "asc" | "desc"]) => boolean;
718
- popupCell?: SelectedCellProps<M>;
719
- setPopupCell?: (popupCell?: SelectedCellProps<M>) => void;
720
- onAddColumn?: (column: string) => void;
721
- };
722
- export type SelectedCellProps<M extends Record<string, unknown> = Record<string, unknown>> = {
723
- propertyKey: Extract<keyof M, string> | (string & {});
724
- cellRect: DOMRect;
725
- width: number;
726
- height: number;
727
- entityPath: string;
728
- entityId: string | number;
729
- };
730
- /**
731
- * SQL operation that a policy applies to.
732
- * @group Models
733
- */
734
- export type SecurityOperation = "select" | "insert" | "update" | "delete" | "all";
735
- /**
736
- * Flexible Row Level Security rule for a collection.
737
- *
738
- * Inspired by Supabase's approach to PostgreSQL RLS. Rules can range from
739
- * simple convenience shortcuts to fully custom SQL expressions, giving you the
740
- * full power of PostgreSQL Row Level Security.
741
- *
742
- * The authenticated user's identity is available in raw SQL via:
743
- * - `auth.uid()` — the user's ID
744
- * - `auth.roles()` — comma-separated app role IDs
745
- * - `auth.jwt()` — full JWT claims as JSONB
746
- *
747
- * These are set automatically per-transaction by the backend.
748
- *
749
- * **How rules combine:** PostgreSQL evaluates all matching policies for an
750
- * operation. Permissive rules are OR'd together (any one passing is enough).
751
- * Restrictive rules are AND'd (all must pass). This mirrors Supabase behavior.
752
- *
753
- * **Mutual exclusivity:** `ownerField`, `access`, and raw SQL (`using`/`withCheck`)
754
- * cannot be combined. The type system enforces this — attempting to set
755
- * conflicting fields will produce a compile-time error.
756
- *
757
- * @group Models
758
- */
759
- export type SecurityRule = OwnerSecurityRule | PublicSecurityRule | RawSQLSecurityRule | RolesOnlySecurityRule;
760
- /**
761
- * Shared fields for all SecurityRule variants.
762
- * @group Models
763
- */
764
- export interface SecurityRuleBase {
765
- /**
766
- * Optional human-readable name for the policy.
767
- * If not provided, one will be auto-generated from the table name and operation.
768
- * Must be unique per table.
769
- *
770
- * When using `operations` (array), each generated policy will have the
771
- * operation name appended, e.g. `"owner_access_select"`, `"owner_access_update"`.
772
- */
773
- name?: string;
774
- /**
775
- * Which SQL operation this policy applies to.
776
- * Use this when the policy targets a single operation or all operations.
777
- *
778
- * For multiple specific operations, use `operations` (array) instead.
779
- * If neither is specified, defaults to `"all"`.
780
- *
781
- * @default "all"
782
- */
783
- operation?: SecurityOperation;
784
- /**
785
- * Array of SQL operations this policy applies to.
786
- * The compiler will generate one PostgreSQL policy per operation, sharing
787
- * the same configuration.
788
- *
789
- * This reduces boilerplate when the same rule applies to multiple (but not all)
790
- * operations.
791
- *
792
- * Takes precedence over `operation` (singular) if both are specified.
793
- *
794
- * @example
795
- * // Same rule for select and update
796
- * { operations: ["select", "update"], ownerField: "user_id" }
797
- *
798
- * @example
799
- * // Equivalent to operation: "all"
800
- * { operations: ["all"], ownerField: "user_id" }
801
- */
802
- operations?: SecurityOperation[];
803
- /**
804
- * Whether this policy is `"permissive"` (default) or `"restrictive"`.
805
- *
806
- * - **permissive**: Multiple permissive policies for the same operation are
807
- * OR'd together — if *any* passes, access is granted.
808
- * - **restrictive**: Restrictive policies are AND'd with all permissive
809
- * policies — they act as additional gates that *must* also pass.
810
- *
811
- * This is the same model as PostgreSQL / Supabase.
812
- *
813
- * @default "permissive"
814
- */
815
- mode?: "permissive" | "restrictive";
816
- /**
817
- * **Shortcut.** Restrict this rule to users that have one of these
818
- * application-level roles.
819
- *
820
- * **Important:** These are NOT native PostgreSQL database roles. They are
821
- * application roles managed by Rebase, stored in the `rebase.user_roles`
822
- * table, and injected into each transaction via `auth.roles()`.
823
- *
824
- * Generates a condition like:
825
- * `auth.roles() ~ '<role1>|<role2>'`
826
- *
827
- * Can be combined with `ownerField`, `access`, or raw `using`/`withCheck`.
828
- * When combined, the role check is AND'd with the other condition.
829
- *
830
- * @example
831
- * // Only admins can delete
832
- * { operation: "delete", roles: ["admin"] }
833
- *
834
- * @example
835
- * // Admins have unfiltered read access to all rows
836
- * { operation: "select", roles: ["admin"], using: "true" }
837
- */
838
- roles?: string[];
839
- /**
840
- * **Advanced.** Native PostgreSQL database roles the policy applies to.
841
- *
842
- * By default, all generated policies target the `public` role (i.e.
843
- * every database connection). This is correct for most setups where
844
- * a single database role is used for all connections.
845
- *
846
- * **Important:** These are NOT the same as the application-level `roles`
847
- * (admin, editor, viewer, etc.) — those are enforced in the USING/WITH
848
- * CHECK clauses via `auth.roles()`. This field controls the PostgreSQL
849
- * `TO` clause in `CREATE POLICY ... TO role_name`.
850
- *
851
- * Use this if you have dedicated PostgreSQL roles (e.g. `app_read`,
852
- * `app_write`) and want policies to target specific ones.
853
- *
854
- * @default ["public"]
855
- *
856
- * @example
857
- * // Only apply this policy when connected as `app_role`
858
- * { operation: "select", access: "public", pgRoles: ["app_role"] }
859
- */
860
- pgRoles?: string[];
861
- }
862
- /**
863
- * Security rule that grants access based on row ownership.
864
- * Generates a USING/WITH CHECK clause like: `<column> = auth.uid()`
865
- *
866
- * Cannot be combined with `using`, `withCheck`, or `access`.
867
- *
868
- * @example
869
- * { operation: "all", ownerField: "user_id" }
870
- *
871
- * @group Models
872
- */
873
- export interface OwnerSecurityRule extends SecurityRuleBase {
874
- /** The property (column) that stores the owner's user ID. */
875
- ownerField: string;
876
- access?: never;
877
- using?: never;
878
- withCheck?: never;
879
- }
880
- /**
881
- * Security rule that grants unrestricted row access (no row filtering).
882
- * Generates `USING (true)`.
883
- *
884
- * This means "no row-level filter", NOT "anonymous/unauthenticated access".
885
- * Authentication is still enforced at the API layer — this only controls which
886
- * *rows* authenticated users can see.
887
- *
888
- * Cannot be combined with `using`, `withCheck`, or `ownerField`.
889
- *
890
- * @example
891
- * // Public read (any authenticated user sees all rows)
892
- * { operation: "select", access: "public" }
893
- *
894
- * @group Models
895
- */
896
- export interface PublicSecurityRule extends SecurityRuleBase {
897
- /** Grant unrestricted row access for this operation. */
898
- access: "public";
899
- ownerField?: never;
900
- using?: never;
901
- withCheck?: never;
902
- }
903
- /**
904
- * Security rule using raw SQL expressions for full PostgreSQL RLS power.
905
- *
906
- * Cannot be combined with `ownerField` or `access`.
907
- *
908
- * You can reference columns via `{column_name}` which will be resolved to
909
- * `table.column_name` in the generated Drizzle code.
910
- *
911
- * @example
912
- * // Rows published in the last 30 days are visible
913
- * { operation: "select", using: "{published_at} > now() - interval '30 days'" }
914
- *
915
- * @example
916
- * // Only the owner, or users with 'moderator' role
917
- * {
918
- * operation: "select",
919
- * using: "{user_id} = auth.uid() OR auth.roles() ~ 'moderator'"
920
- * }
921
- *
922
- * @group Models
923
- */
924
- export interface RawSQLSecurityRule extends SecurityRuleBase {
925
- /**
926
- * Raw SQL expression for the `USING` clause.
927
- * This controls which *existing* rows are visible / can be modified / deleted.
928
- * Applied to SELECT, UPDATE, and DELETE.
929
- */
930
- using: string;
931
- /**
932
- * Raw SQL expression for the `WITH CHECK` clause.
933
- * This controls which *new/updated* row values are allowed.
934
- * Applied to INSERT and UPDATE.
935
- *
936
- * If not provided on INSERT/UPDATE policies, falls back to `using`
937
- * (which matches PostgreSQL's own default behavior).
938
- */
939
- withCheck?: string;
940
- ownerField?: never;
941
- access?: never;
942
- }
943
- /**
944
- * Security rule that only filters by application roles, without any
945
- * row-level condition (USING/WITH CHECK).
946
- *
947
- * Useful for simple "only admins can access this table" rules where
948
- * no per-row filtering is needed.
949
- *
950
- * @example
951
- * // Only admins can delete
952
- * { operation: "delete", roles: ["admin"] }
953
- *
954
- * @group Models
955
- */
956
- export interface RolesOnlySecurityRule extends SecurityRuleBase {
957
- ownerField?: never;
958
- access?: never;
959
- using?: never;
960
- withCheck?: never;
961
- }