@rebasepro/types 0.0.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 (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +174 -0
  3. package/dist/components/EntityFormActionsProps.d.ts +17 -0
  4. package/dist/components/EntityFormProps.d.ts +46 -0
  5. package/dist/components/PropertyPreviewProps.d.ts +50 -0
  6. package/dist/components/formex.d.ts +40 -0
  7. package/dist/components/index.d.ts +3 -0
  8. package/dist/controllers/analytics_controller.d.ts +7 -0
  9. package/dist/controllers/auth.d.ts +73 -0
  10. package/dist/controllers/customization_controller.d.ts +50 -0
  11. package/dist/controllers/datasource.d.ts +179 -0
  12. package/dist/controllers/dialogs_controller.d.ts +36 -0
  13. package/dist/controllers/index.d.ts +11 -0
  14. package/dist/controllers/local_config_persistence.d.ts +20 -0
  15. package/dist/controllers/navigation.d.ts +262 -0
  16. package/dist/controllers/side_dialogs_controller.d.ts +67 -0
  17. package/dist/controllers/side_entity_controller.d.ts +90 -0
  18. package/dist/controllers/snackbar.d.ts +24 -0
  19. package/dist/controllers/storage.d.ts +173 -0
  20. package/dist/index.d.ts +5 -0
  21. package/dist/index.es.js +113 -0
  22. package/dist/index.es.js.map +1 -0
  23. package/dist/index.umd.js +117 -0
  24. package/dist/index.umd.js.map +1 -0
  25. package/dist/rebase_context.d.ts +91 -0
  26. package/dist/types/backend.d.ts +254 -0
  27. package/dist/types/chips.d.ts +5 -0
  28. package/dist/types/collections.d.ts +887 -0
  29. package/dist/types/entities.d.ts +140 -0
  30. package/dist/types/entity_actions.d.ts +98 -0
  31. package/dist/types/entity_callbacks.d.ts +173 -0
  32. package/dist/types/entity_link_builder.d.ts +7 -0
  33. package/dist/types/entity_overrides.d.ts +5 -0
  34. package/dist/types/export_import.d.ts +21 -0
  35. package/dist/types/fields.d.ts +221 -0
  36. package/dist/types/index.d.ts +19 -0
  37. package/dist/types/locales.d.ts +4 -0
  38. package/dist/types/modify_collections.d.ts +5 -0
  39. package/dist/types/plugins.d.ts +276 -0
  40. package/dist/types/properties.d.ts +1103 -0
  41. package/dist/types/property_config.d.ts +68 -0
  42. package/dist/types/rebase.d.ts +180 -0
  43. package/dist/types/relations.d.ts +336 -0
  44. package/dist/types/user_management_delegate.d.ts +78 -0
  45. package/dist/types/websockets.d.ts +33 -0
  46. package/dist/users/index.d.ts +2 -0
  47. package/dist/users/roles.d.ts +22 -0
  48. package/dist/users/user.d.ts +42 -0
  49. package/package.json +137 -0
  50. package/src/components/EntityFormActionsProps.tsx +18 -0
  51. package/src/components/EntityFormProps.tsx +52 -0
  52. package/src/components/PropertyPreviewProps.tsx +61 -0
  53. package/src/components/formex.tsx +46 -0
  54. package/src/components/index.ts +3 -0
  55. package/src/controllers/analytics_controller.tsx +57 -0
  56. package/src/controllers/auth.tsx +94 -0
  57. package/src/controllers/customization_controller.tsx +61 -0
  58. package/src/controllers/datasource.ts +218 -0
  59. package/src/controllers/dialogs_controller.tsx +37 -0
  60. package/src/controllers/index.ts +11 -0
  61. package/src/controllers/local_config_persistence.tsx +22 -0
  62. package/src/controllers/navigation.ts +317 -0
  63. package/src/controllers/side_dialogs_controller.tsx +82 -0
  64. package/src/controllers/side_entity_controller.tsx +104 -0
  65. package/src/controllers/snackbar.ts +29 -0
  66. package/src/controllers/storage.ts +196 -0
  67. package/src/index.ts +5 -0
  68. package/src/rebase_context.tsx +122 -0
  69. package/src/types/backend.ts +385 -0
  70. package/src/types/chips.ts +46 -0
  71. package/src/types/collections.ts +1013 -0
  72. package/src/types/entities.ts +207 -0
  73. package/src/types/entity_actions.tsx +118 -0
  74. package/src/types/entity_callbacks.ts +217 -0
  75. package/src/types/entity_link_builder.ts +8 -0
  76. package/src/types/entity_overrides.tsx +6 -0
  77. package/src/types/export_import.ts +26 -0
  78. package/src/types/fields.tsx +298 -0
  79. package/src/types/index.ts +20 -0
  80. package/src/types/locales.ts +81 -0
  81. package/src/types/modify_collections.tsx +6 -0
  82. package/src/types/plugins.tsx +328 -0
  83. package/src/types/properties.ts +1270 -0
  84. package/src/types/property_config.tsx +93 -0
  85. package/src/types/rebase.tsx +211 -0
  86. package/src/types/relations.ts +351 -0
  87. package/src/types/user_management_delegate.ts +98 -0
  88. package/src/types/websockets.ts +37 -0
  89. package/src/users/index.ts +2 -0
  90. package/src/users/roles.ts +33 -0
  91. package/src/users/user.ts +46 -0
@@ -0,0 +1,1270 @@
1
+ import React from "react";
2
+ import { FieldProps } from "./fields";
3
+ import { EntityReference, EntityRelation, EntityValues, GeoPoint, Entity } from "./entities";
4
+ import { FilterValues } from "./collections";
5
+ import { PropertyPreviewProps } from "../components";
6
+ import { ColorKey, ColorScheme } from "./chips";
7
+ import { AuthController } from "../controllers";
8
+ import { Relation } from "./relations";
9
+ import { EntityAfterReadProps, EntityBeforeSaveProps } from "./entity_callbacks";
10
+ import { User } from "../users";
11
+ import { RebaseContext } from "../rebase_context";
12
+
13
+ /**
14
+ * Callbacks/Hooks for individual property fields
15
+ * @group Entity properties
16
+ */
17
+ export type PropertyCallbacks<T = any, M extends Record<string, any> = any, USER extends User = User> = {
18
+ /**
19
+ * Callback used after fetching data, to transform the value before rendering
20
+ */
21
+ afterRead?(props: Omit<EntityAfterReadProps<M, USER>, 'entity'> & {
22
+ value: T;
23
+ entity: Entity<M> | undefined;
24
+ }): Promise<T> | T;
25
+
26
+
27
+ /**
28
+ * Callback used before saving, after validation.
29
+ * You can modify the value before it's saved.
30
+ */
31
+ beforeSave?(props: Omit<EntityBeforeSaveProps<M, USER>, 'values'> & {
32
+ value: T;
33
+ previousValue: T | undefined;
34
+ values: Partial<M>;
35
+ }): Promise<T> | T;
36
+ }
37
+
38
+ /**
39
+ * @group Entity properties
40
+ */
41
+ export type DataType =
42
+ | "string"
43
+ | "number"
44
+ | "boolean"
45
+ | "date"
46
+ | "geopoint"
47
+ | "reference"
48
+ | "relation"
49
+ | "array"
50
+ | "map";
51
+
52
+ export type Property =
53
+ | StringProperty
54
+ | NumberProperty
55
+ | BooleanProperty
56
+ | DateProperty
57
+ | GeopointProperty
58
+ | ReferenceProperty
59
+ | RelationProperty
60
+ | ArrayProperty
61
+ | MapProperty;
62
+
63
+ export type Properties = {
64
+ [key: string]: Property;
65
+ };
66
+
67
+ /**
68
+ * A helper type to infer the underlying data type from a Property definition.
69
+ * This is the core of the type inference system.
70
+ */
71
+ export type InferPropertyType<P extends Property> =
72
+ P extends StringProperty ? string :
73
+ P extends NumberProperty ? number :
74
+ P extends BooleanProperty ? boolean :
75
+ P extends DateProperty ? Date :
76
+ P extends GeopointProperty ? GeoPoint :
77
+ P extends ReferenceProperty ? EntityReference :
78
+ P extends RelationProperty ? EntityRelation | EntityRelation[] :
79
+ P extends ArrayProperty ? (P["of"] extends Property ? InferPropertyType<P["of"]>[] : any[]) :
80
+ P extends MapProperty ? (P["properties"] extends Properties ? InferEntityType<P["properties"]> : Record<string, any>) :
81
+ never;
82
+
83
+ /**
84
+ * A generic type that converts a `Properties` schema definition into a corresponding
85
+ * TypeScript entity type. It correctly handles required and optional properties.
86
+ *
87
+ * @example
88
+ * const productSchema = {
89
+ * name: { type: 'string', validation: { required: true } },
90
+ * price: { type: 'number' }
91
+ * };
92
+ * type Product = InferEntityType<typeof productSchema>;
93
+ * // Result: { name: string; price?: number; }
94
+ */
95
+ export type InferEntityType<P extends Properties> = {
96
+ -readonly [K in keyof P as P[K] extends { validation?: { required: true } } ? K : never]: InferPropertyType<P[K]>;
97
+ } & {
98
+ -readonly [K in keyof P as P[K] extends { validation?: { required: true } } ? never : K]?: InferPropertyType<P[K]>;
99
+ };
100
+
101
+ /**
102
+ * Interface including all common properties of a CMS property.
103
+ * @group Entity properties
104
+ */
105
+ export interface BaseProperty<CustomProps = any> {
106
+ /**
107
+ * Property name (e.g. Product)
108
+ */
109
+ name: string;
110
+
111
+ /**
112
+ * Property description, always displayed under the field
113
+ */
114
+ description?: string;
115
+
116
+ /**
117
+ * You can use this prop to reuse a property that has been defined
118
+ * in the top level of the CMS in the prop `fields`.
119
+ * All the configuration will be taken from the inherited config, and
120
+ * overwritten by the current property config.
121
+ */
122
+ propertyConfig?: string;
123
+
124
+ /**
125
+ * Width in pixels of this column in the collection view. If not set
126
+ * the width is inferred based on the other configurations
127
+ */
128
+ columnWidth?: number;
129
+
130
+ /**
131
+ * Do not show this property in the collection view
132
+ */
133
+ hideFromCollection?: boolean;
134
+
135
+ /**
136
+ * Is this a read only property. When set to true, it gets rendered as a
137
+ * preview.
138
+ */
139
+ readOnly?: boolean;
140
+
141
+ /**
142
+ * Is this field disabled.
143
+ * When set to true, it gets rendered as a
144
+ * disabled field. You can also specify a configuration for defining the
145
+ * behaviour of disabled properties (including custom messages, clear value on
146
+ * disabled or hide the field completely)
147
+ */
148
+ disabled?: boolean | PropertyDisabledConfig;
149
+
150
+ /**
151
+ * Rules for validating this property
152
+ */
153
+ validation?: PropertyValidationSchema;
154
+
155
+ /**
156
+ * This value will be set by default for new entities.
157
+ */
158
+ defaultValue?: unknown;
159
+
160
+ /**
161
+ * A number between 0 and 100 that indicates the width of the field in the form view.
162
+ * It defaults to 100, but you can set it to 50 to have two fields in the same row.
163
+ */
164
+ widthPercentage?: number;
165
+
166
+ /**
167
+ * Additional props that are passed to the components defined in `field`
168
+ * or in `preview`.
169
+ */
170
+ customProps?: CustomProps;
171
+
172
+ /**
173
+ * If you need to render a custom field, you can create a component that
174
+ * takes `FieldProps` as props. You receive the value, a function to
175
+ * update the value and additional utility props such as if there is an error.
176
+ * You can customize it by passing custom props that are received
177
+ * in the component.
178
+ */
179
+ Field?: React.ComponentType<FieldProps<any, CustomProps>>;
180
+
181
+ /**
182
+ * Configure how a property is displayed as a preview, e.g. in the collection
183
+ * view. You can customize it by passing custom props that are received
184
+ * in the component.
185
+ */
186
+ Preview?: React.ComponentType<PropertyPreviewProps<any, CustomProps>>;
187
+
188
+ /**
189
+ * Use this to define dynamic properties that change based on certain conditions
190
+ * or on the entity's values. For example, you can make a field read-only if
191
+ * another field has a certain value.
192
+ * This function receives the same props as a `PropertyBuilder` and should return a partial `Property` object.
193
+ */
194
+ dynamicProps?: (props: PropertyBuilderProps) => Partial<Property>;
195
+
196
+ /**
197
+ * Declarative conditions for dynamic property behavior using JSON Logic.
198
+ *
199
+ * An alternative to PropertyBuilder functions that can be:
200
+ * - Stored in the database as JSON
201
+ * - Edited via the collection editor UI
202
+ * - Evaluated at runtime like property builders
203
+ *
204
+ * @see PropertyConditions for available condition options
205
+ * @see https://jsonlogic.com/ for JSON Logic syntax
206
+ */
207
+ conditions?: PropertyConditions;
208
+
209
+ /**
210
+ * Callbacks/Hooks for this property field to transform and sanitize data during its lifecycle.
211
+ */
212
+ callbacks?: PropertyCallbacks;
213
+ }
214
+
215
+ /**
216
+ * @group Entity properties
217
+ */
218
+ export interface StringProperty extends BaseProperty {
219
+ type: "string";
220
+ /**
221
+ * Optional database column type. If not set, it defaults to `varchar` or `uuid` depending on `isId` configuration.
222
+ * Use `text` for strings with unbound length, `char` for fixed-length strings, or `varchar` for variable-length strings with a limit.
223
+ */
224
+ columnType?: "varchar" | "text" | "char";
225
+ /**
226
+ * Rules for validating this property
227
+ */
228
+ validation?: StringPropertyValidationSchema;
229
+ /**
230
+ * Marks this field as a Primary Key / Unique Identifier.
231
+ * Framework behavior: Auto-maps to `collection.primaryKeys` internally if not explicitly set.
232
+ * Drizzle append: `.primaryKey()`
233
+ * UI behavior: Field value cannot be changed after creation.
234
+ *
235
+ * You can set this to `"manual"` for a user-defined ID, or specify a generation strategy:
236
+ * 'uuid' -> Drizzle `.defaultRandom()` (Postgres gen_random_uuid())
237
+ * 'cuid' -> Drizzle `.default(sql\`cuid()\`)`
238
+ * Or any other random string to act as a raw SQL default expression: e.g. `nanoid()`
239
+ *
240
+ * On the UI side, the field automatically gets disabled on new entities if a string strategy is provided.
241
+ */
242
+ isId?: boolean | "manual" | "uuid" | "cuid" | string;
243
+ /**
244
+ * You can use the enum values providing a map of possible
245
+ * exclusive values the property can take, mapped to the label that it is
246
+ * displayed in the dropdown. You can use a simple object with the format
247
+ * `value` => `label`, or with the format `value` => `EnumValueConfig` if you
248
+ * need extra customization, (like disabling specific options or assigning
249
+ * colors). If you need to ensure the order of the elements, you can pass
250
+ * a `Map` instead of a plain object.
251
+ *
252
+ */
253
+ enum?: EnumValues;
254
+ /**
255
+ * Is this string property long enough so it should be displayed in
256
+ * a multiple line field. Defaults to false. If set to true,
257
+ * the number of lines adapts to the content
258
+ */
259
+ multiline?: boolean;
260
+ /**
261
+ * Should this string property be displayed as a markdown field. If true,
262
+ * the field is rendered as a text editors that supports markdown highlight
263
+ * syntax. It also includes a preview of the result.
264
+ */
265
+ markdown?: boolean;
266
+ /**
267
+ * You can specify a `Storage` configuration. It is used to
268
+ * indicate that this string refers to a path in your storage provider.
269
+ */
270
+ storage?: StorageConfig;
271
+
272
+ /**
273
+ * This property is used to indicate that the string is a user ID, and
274
+ * it will be rendered as a user picker.
275
+ * Note that the user ID needs to be the one used in your authentication
276
+ * provider, e.g. Firebase Auth.
277
+ * You can also use a property builder to specify the user path dynamically
278
+ * based on other values of the entity.
279
+ */
280
+ userSelect?: boolean;
281
+
282
+ /**
283
+ * If the value of this property is a URL, you can set this flag to true
284
+ * to add a link, or one of the supported media types to render a preview
285
+ */
286
+ url?: boolean | PreviewType;
287
+ /**
288
+ * Does this field include an email
289
+ */
290
+ email?: boolean;
291
+ /**
292
+ * Should this string be rendered as a tag instead of just text.
293
+ */
294
+ previewAsTag?: boolean;
295
+ /**
296
+ * Add an icon to clear the value and set it to `null`. Defaults to `false`
297
+ */
298
+ clearable?: boolean;
299
+
300
+ /**
301
+ * You can use this property (a string) to behave as a reference to another
302
+ * collection. The stored value is the ID of the entity in the
303
+ * collection, and the `path` prop is used to
304
+ * define the collection this reference points to.
305
+ */
306
+ reference?: ReferenceProperty;
307
+ }
308
+
309
+ /**
310
+ * @group Entity properties
311
+ */
312
+ export interface NumberProperty extends BaseProperty {
313
+ type: "number";
314
+ /**
315
+ * Optional database column type. Allows specifying exact database numeric types.
316
+ * If not provided, integer fields (where validation.integer is true or isId is true) default to `integer`, others to `numeric`.
317
+ */
318
+ columnType?: "integer" | "real" | "double precision" | "numeric" | "bigint" | "serial" | "bigserial";
319
+ /**
320
+ * Rules for validating this property
321
+ */
322
+ validation?: NumberPropertyValidationSchema;
323
+ /**
324
+ * Marks this field as a Primary Key / Unique Identifier.
325
+ * Framework behavior: Auto-maps to `collection.primaryKeys` internally if not explicitly set.
326
+ * Drizzle append: `.primaryKey()`
327
+ * UI behavior: Field value cannot be changed after creation.
328
+ *
329
+ * You can set this to `"manual"` for a user-defined ID, or specify a generation strategy:
330
+ * 'increment' -> PostgreSQL `GENERATED BY DEFAULT AS IDENTITY` or auto-incrementing integer.
331
+ * Or any other random string to act as a raw SQL default expression.
332
+ */
333
+ isId?: boolean | "manual" | "increment" | string;
334
+ /**
335
+ * You can use the enum values providing a map of possible
336
+ * exclusive values the property can take, mapped to the label that it is
337
+ * displayed in the dropdown.
338
+ */
339
+ enum?: EnumValues;
340
+ /**
341
+ * Add an icon to clear the value and set it to `null`. Defaults to `false`
342
+ */
343
+ clearable?: boolean;
344
+ }
345
+
346
+ /**
347
+ * @group Entity properties
348
+ */
349
+ export interface BooleanProperty extends BaseProperty {
350
+ type: "boolean";
351
+ /**
352
+ * Rules for validating this property
353
+ */
354
+ validation?: PropertyValidationSchema;
355
+ }
356
+
357
+ /**
358
+ * @group Entity properties
359
+ */
360
+ export interface DateProperty extends BaseProperty {
361
+ type: "date";
362
+ /**
363
+ * Optional database column type. If not set, defaults to `timestamp` with timezone.
364
+ */
365
+ columnType?: "timestamp" | "date" | "time";
366
+ /**
367
+ * Rules for validating this property
368
+ */
369
+ validation?: DatePropertyValidationSchema;
370
+ /**
371
+ * Set the granularity of the field to a date or date + time.
372
+ * Defaults to `date_time`.
373
+ *
374
+ */
375
+ mode?: "date" | "date_time";
376
+ /**
377
+ * Timezone string to evaluate the date in.
378
+ */
379
+ timezone?: string;
380
+ /**
381
+ * If this flag is set to `on_create` or `on_update` this timestamp is
382
+ * updated automatically on creation of the entity only or on every
383
+ * update (including creation). Useful for creating `created_on` or
384
+ * `updated_on` fields
385
+ */
386
+ autoValue?: "on_create" | "on_update";
387
+ /**
388
+ * Add an icon to clear the value and set it to `null`. Defaults to `false`
389
+ */
390
+ clearable?: boolean;
391
+ }
392
+
393
+ /**
394
+ * @group Entity properties
395
+ */
396
+ export interface GeopointProperty extends BaseProperty {
397
+ type: "geopoint";
398
+ /**
399
+ * Rules for validating this property
400
+ */
401
+ validation?: PropertyValidationSchema;
402
+ }
403
+
404
+ /**
405
+ * @group Entity properties
406
+ */
407
+ export interface ReferenceProperty extends BaseProperty {
408
+ type: "reference";
409
+ /**
410
+ * Marks this field as a Primary Key / Unique Identifier.
411
+ * Framework behavior: Auto-maps to `collection.primaryKeys` internally if not explicitly set.
412
+ * Drizzle append: `.primaryKey()`
413
+ * UI behavior: Field value cannot be changed after creation.
414
+ */
415
+ isId?: boolean;
416
+ /**
417
+ * Absolute collection path of the collection this reference points to.
418
+ * The collection of the entity is inferred based on the root navigation, so
419
+ * the filters and search delegate existing there are applied to this view
420
+ * as well.
421
+ * You can leave this prop undefined if the path is not yet know, e.g.
422
+ * you are using a property builder and the path depends on a different
423
+ * property.
424
+ */
425
+ path?: string;
426
+ /**
427
+ * Allow selection of entities that pass the given filter only.
428
+ * e.g. `forceFilter: { age: [">=", 18] }`
429
+ */
430
+ forceFilter?: FilterValues<string>;
431
+ /**
432
+ * Properties that need to be rendered when displaying a preview of this
433
+ * reference. If not specified the first 3 are used. Only the first 3
434
+ * specified values are considered.
435
+ */
436
+ previewProperties?: string[];
437
+ /**
438
+ * Should the reference include the ID of the entity. Defaults to `true`
439
+ */
440
+ includeId?: boolean;
441
+ /**
442
+ * Should the reference include a link to the entity (open the entity details). Defaults to `true`
443
+ */
444
+ includeEntityLink?: boolean;
445
+ }
446
+
447
+ /**
448
+ * @group Entity properties
449
+ */
450
+ export interface RelationProperty extends BaseProperty {
451
+ type: "relation";
452
+ /**
453
+ * Marks this field as a Primary Key / Unique Identifier.
454
+ * Framework behavior: Auto-maps to `collection.primaryKeys` internally if not explicitly set.
455
+ * Drizzle append: `.primaryKey()`
456
+ * UI behavior: Field value cannot be changed after creation.
457
+ */
458
+ isId?: boolean;
459
+ /**
460
+ * The name of the relation this property refers to. This name must match
461
+ * one of the `relationName`s defined in the top-level `relations` array
462
+ * of the collection.
463
+ */
464
+ relationName: string;
465
+
466
+ /**
467
+ * The resolved relation object.
468
+ * This is set by the framework
469
+ */
470
+ relation?: Relation;
471
+ /**
472
+ * Allow selection of entities that pass the given filter only.
473
+ * e.g. `forceFilter: { age: [">=", 18] }`
474
+ */
475
+ forceFilter?: FilterValues<string>;
476
+ /**
477
+ * Properties that need to be rendered when displaying a preview of this
478
+ * reference. If not specified the first 3 are used. Only the first 3
479
+ * specified values are considered.
480
+ */
481
+ previewProperties?: string[];
482
+ /**
483
+ * Should the reference include the ID of the entity. Defaults to `true`
484
+ */
485
+ includeId?: boolean;
486
+ /**
487
+ * Should the reference include a link to the entity (open the entity details). Defaults to `true`
488
+ */
489
+ includeEntityLink?: boolean;
490
+
491
+ /**
492
+ * Choose the widget to use for selecting the relation.
493
+ * Defaults to `select`.
494
+ */
495
+ widget?: "select" | "dialog";
496
+ }
497
+
498
+ /**
499
+ * @group Entity properties
500
+ */
501
+ export interface ArrayProperty extends BaseProperty {
502
+ type: "array";
503
+ /**
504
+ * Optional database column type. Defaults to `jsonb`.
505
+ */
506
+ columnType?: "json" | "jsonb";
507
+ /**
508
+ * The property of this array.
509
+ * You can specify any property (except another Array property)
510
+ * You can leave this field empty only if you are providing a custom field,
511
+ * or using the `oneOf` prop, otherwise an error will be thrown.
512
+ */
513
+ of?: Property;
514
+ /**
515
+ * Use this field if you would like to have an array of typed objects.
516
+ * It is useful if you need to have values of different types in the same
517
+ * array.
518
+ * Each entry of the array is an object with the shape:
519
+ * ```
520
+ * { type: "YOUR_TYPE", value: "YOUR_VALUE"}
521
+ * ```
522
+ * Note that you can use any property so `value` can take any value (strings,
523
+ * numbers, array, objects...)
524
+ * You can customise the `type` and `value` fields to suit your needs.
525
+ *
526
+ * An example use case for this feature may be a blog entry, where you have
527
+ * images and text blocks using markdown.
528
+ */
529
+ oneOf?: {
530
+ /**
531
+ * Record of properties, where the key is the `type` and the value
532
+ * is the corresponding property
533
+ */
534
+ properties: Properties;
535
+ /**
536
+ * Order in which the properties are displayed.
537
+ * If you are specifying your collection as code, the order is the same as the
538
+ * one you define in `properties`, and you don't need to specify this prop.
539
+ */
540
+ propertiesOrder?: string[];
541
+ /**
542
+ * Name of the field to use as the discriminator for type
543
+ * Defaults to `type`
544
+ */
545
+ typeField?: string;
546
+ /**
547
+ * Name of the field to use as the value
548
+ * Defaults to `value`
549
+ */
550
+ valueField?: string;
551
+ };
552
+ /**
553
+ * Rules for validating this property
554
+ */
555
+ validation?: ArrayPropertyValidationSchema;
556
+ /**
557
+ * Should the field be initially expanded. Defaults to `true`
558
+ */
559
+ expanded?: boolean;
560
+ /**
561
+ * Display the child properties directly, without being wrapped in an
562
+ * extendable panel.
563
+ */
564
+ minimalistView?: boolean;
565
+ /**
566
+ * Can the elements in this array be reordered. Defaults to `true`.
567
+ * This prop has no effect if `disabled` is set to true.
568
+ */
569
+ sortable?: boolean;
570
+ /**
571
+ * Can the elements in this array be added. Defaults to `true`
572
+ * This prop has no effect if `disabled` is set to true.
573
+ */
574
+ canAddElements?: boolean;
575
+ }
576
+
577
+ /**
578
+ * @group Entity properties
579
+ */
580
+ export interface MapProperty extends BaseProperty {
581
+ type: "map";
582
+ /**
583
+ * Optional database column type. Defaults to `jsonb`.
584
+ */
585
+ columnType?: "json" | "jsonb";
586
+ /**
587
+ * Record of properties included in this map.
588
+ */
589
+ properties?: Properties;
590
+ /**
591
+ * Order in which the properties are displayed.
592
+ * If you are specifying your collection as code, the order is the same as the
593
+ * one you define in `properties`, and you don't need to specify this prop.
594
+ */
595
+ propertiesOrder?: string[];
596
+ /**
597
+ * Rules for validating this property.
598
+ * NOTE: If you don't set `required` in the map property, an empty object
599
+ * will be considered valid, even if you set `required` in the properties.
600
+ */
601
+ validation?: PropertyValidationSchema;
602
+ /**
603
+ * Properties that are displayed when rendered as a preview
604
+ */
605
+ previewProperties?: string[];
606
+ /**
607
+ * Allow the user to add only some keys in this map.
608
+ * By default, all properties of the map have the corresponding field in
609
+ * the form view. Setting this flag to true allows to pick only some.
610
+ * Useful for map that can have a lot of sub-properties that may not be
611
+ * needed
612
+ */
613
+ pickOnlySomeKeys?: boolean;
614
+ /**
615
+ * Display the child properties as independent columns in the collection
616
+ * view
617
+ */
618
+ spreadChildren?: boolean;
619
+ /**
620
+ * Display the child properties directly, without being wrapped in an
621
+ * extendable panel. Note that this will also hide the title of this property.
622
+ */
623
+ minimalistView?: boolean;
624
+ /**
625
+ * Should the field be initially expanded. Defaults to `true`
626
+ */
627
+ expanded?: boolean;
628
+ /**
629
+ * Render this map as a key-value table that allows to use
630
+ * arbitrary keys. You don't need to define the properties in this case.
631
+ */
632
+ keyValue?: boolean;
633
+ }
634
+
635
+ /**
636
+ * @group Entity properties
637
+ */
638
+ export type PropertyBuilderProps<M extends Record<string, any> = any> = {
639
+ values: Partial<M>;
640
+ previousValues?: Partial<M>;
641
+ propertyValue?: unknown;
642
+ index?: number;
643
+ path: string;
644
+ entityId?: string | number;
645
+ authController: AuthController;
646
+ };
647
+
648
+ /**
649
+ * @group Entity properties
650
+ */
651
+ export interface PropertyDisabledConfig {
652
+ /**
653
+ * Enable this flag if you would like to clear the value of the field
654
+ * when the corresponding property gets disabled.
655
+ *
656
+ * This is useful for keeping data consistency when you have conditional
657
+ * properties.
658
+ */
659
+ clearOnDisabled?: boolean;
660
+
661
+ /**
662
+ * Explanation of why this property is disabled (e.g. a different field
663
+ * needs to be enabled)
664
+ */
665
+ disabledMessage?: string;
666
+
667
+ /**
668
+ * Set this flag to true if you want to hide this field when disabled
669
+ */
670
+ hidden?: boolean;
671
+ }
672
+
673
+ /**
674
+ * We use this type to define mapping between string or number values in
675
+ * the data source to a label (such in a select dropdown).
676
+ * The key in this Record is the value saved in the datasource, and the value in
677
+ * this record is the label displayed in the UI.
678
+ * You can add additional customization by assigning a {@link EnumValueConfig} for the
679
+ * label instead of a simple string (for enabling or disabling options and
680
+ * choosing colors).
681
+ * If you need to ensure the order of the elements use an array of {@link EnumValueConfig}
682
+ * @group Entity properties
683
+ */
684
+ export type EnumValues = EnumValueConfig[] | Record<string | number, string | EnumValueConfig>;
685
+
686
+ /**
687
+ * Configuration for a particular entry in an `EnumValues`
688
+ * @group Entity properties
689
+ */
690
+ export type EnumValueConfig = {
691
+ /**
692
+ * Value stored in the data source.
693
+ */
694
+ id: string | number;
695
+ /**
696
+ * Displayed label
697
+ */
698
+ label: string;
699
+ /**
700
+ * This value will not be selectable
701
+ */
702
+ disabled?: boolean;
703
+ /**
704
+ * You can pick from a list of predefined color combinations or define
705
+ * your own {@link ColorScheme}
706
+ */
707
+ color?: ColorKey | ColorScheme;
708
+ }
709
+
710
+ /**
711
+ * Rules to validate any property. Some properties have specific rules
712
+ * additionally to these.
713
+ * @group Entity properties
714
+ */
715
+ export interface PropertyValidationSchema {
716
+ /**
717
+ * Is this field required
718
+ */
719
+ required?: boolean;
720
+
721
+ /**
722
+ * Customize the required message when the property is not set
723
+ */
724
+ requiredMessage?: string;
725
+
726
+ /**
727
+ * If the unique flag is set to `true`, you can only have one entity in the
728
+ * collection with this value.
729
+ */
730
+ unique?: boolean;
731
+
732
+ /**
733
+ * If the uniqueInArray flag is set to `true`, you can only have this value
734
+ * once per entry in the parent `ArrayProperty`. It has no effect if this
735
+ * property is not a child of an `ArrayProperty`. It works on direct
736
+ * children of an `ArrayProperty` or first level children of `MapProperty`
737
+ */
738
+ uniqueInArray?: boolean;
739
+ }
740
+
741
+ /**
742
+ * Validation rules for numbers
743
+ * @group Entity properties
744
+ */
745
+ export interface NumberPropertyValidationSchema extends PropertyValidationSchema {
746
+ min?: number;
747
+ max?: number;
748
+ lessThan?: number;
749
+ moreThan?: number;
750
+ positive?: boolean;
751
+ negative?: boolean;
752
+ integer?: boolean;
753
+ }
754
+
755
+ /**
756
+ * Validation rules for strings
757
+ * @group Entity properties
758
+ */
759
+ export interface StringPropertyValidationSchema extends PropertyValidationSchema {
760
+ length?: number;
761
+ min?: number;
762
+ max?: number;
763
+ matches?: string | RegExp;
764
+ /**
765
+ * Message displayed when the input does not satisfy the regex in `matches`
766
+ */
767
+ matchesMessage?: string;
768
+ trim?: boolean;
769
+ lowercase?: boolean;
770
+ uppercase?: boolean;
771
+ }
772
+
773
+ /**
774
+ * Validation rules for dates
775
+ * @group Entity properties
776
+ */
777
+ export interface DatePropertyValidationSchema extends PropertyValidationSchema {
778
+ min?: Date;
779
+ max?: Date;
780
+ }
781
+
782
+ /**
783
+ * Validation rules for arrays
784
+ * @group Entity properties
785
+ */
786
+ export interface ArrayPropertyValidationSchema extends PropertyValidationSchema {
787
+ min?: number;
788
+ max?: number;
789
+ }
790
+
791
+ /**
792
+ * Additional configuration related to Storage related fields
793
+ * @group Entity properties
794
+ */
795
+ export type StorageConfig = {
796
+ /**
797
+ * File MIME types that can be uploaded to this reference. Don't specify for
798
+ * all.
799
+ * Note that you can also use the asterisk notation, so `image/*`
800
+ * accepts any image file, and so on.
801
+ */
802
+ acceptedFiles?: FileType[];
803
+
804
+ /**
805
+ * Use client side image compression and resizing
806
+ * Will only be applied to these MIME types: image/jpeg, image/png and image/webp
807
+ * @deprecated Use `imageResize` instead
808
+ */
809
+ imageCompression?: ImageResize;
810
+
811
+ /**
812
+ * Advanced image resizing and cropping configuration.
813
+ * Applied before upload to optimize storage and bandwidth.
814
+ * Only applies to image MIME types: image/jpeg, image/png, image/webp
815
+ */
816
+ imageResize?: ImageResize;
817
+
818
+ /**
819
+ * Specific metadata set in your uploaded file.
820
+ * For the default Firebase implementation, the values passed here are of type
821
+ * `firebase.storage.UploadMetadata`
822
+ */
823
+ metadata?: Record<string, unknown>,
824
+
825
+ /**
826
+ * You can use this prop to customize the uploaded filename.
827
+ * You can use a function as a callback or a string where you
828
+ * specify some placeholders that get replaced with the corresponding values.
829
+ * - `{file}` - Full file name
830
+ * - `{file.name}` - Name of the file without extension
831
+ * - `{file.ext}` - Extension of the file
832
+ * - `{rand}` - Random value used to avoid name collisions
833
+ * - `{entityId}` - ID of the entity
834
+ * - `{propertyKey}` - ID of this property
835
+ * - `{path}` - Path of this entity
836
+ *
837
+ * @param context
838
+ */
839
+ fileName?: string | ((context: UploadedFileContext) => string | Promise<string>);
840
+
841
+ /**
842
+ * Absolute path in your bucket.
843
+ *
844
+ * You can use a function as a callback or a string where you
845
+ * specify some placeholders that get replaced with the corresponding values.
846
+ * - `{file}` - Full file name
847
+ * - `{file.name}` - Name of the file without extension
848
+ * - `{file.ext}` - Extension of the file
849
+ * - `{rand}` - Random value used to avoid name collisions
850
+ * - `{entityId}` - ID of the entity
851
+ * - `{propertyKey}` - ID of this property
852
+ * - `{path}` - Path of this entity
853
+ */
854
+ storagePath: string | ((context: UploadedFileContext) => string);
855
+
856
+ /**
857
+ * When set to true, this flag indicates that the bucket name will be
858
+ * included in the saved storage path.
859
+ *
860
+ * E.g. `gs://my-bucket/path/to/file.png` instead of just `path/to/file.png`
861
+ *
862
+ * Defaults to false.
863
+ */
864
+ includeBucketUrl?: boolean;
865
+
866
+ /**
867
+ * When set to true, this flag indicates that the download URL of the file
868
+ * will be saved in the datasource, instead of the storage path.
869
+ *
870
+ * Note that the generated URL may use a token that, if disabled, may
871
+ * make the URL unusable and lose the original reference to Cloud Storage,
872
+ * so it is not encouraged to use this flag.
873
+ *
874
+ * Defaults to false.
875
+ */
876
+ storeUrl?: boolean,
877
+
878
+ /**
879
+ * Define maximal file size in bytes
880
+ */
881
+ maxSize?: number,
882
+
883
+ /**
884
+ * Use this callback to process the file before uploading it to the storage.
885
+ * If nothing is returned, the file is uploaded as it is.
886
+ * @param file
887
+ */
888
+ processFile?: (file: File) => Promise<File> | undefined;
889
+
890
+ /**
891
+ * Postprocess the saved value (storage path or URL)
892
+ * after it has been resolved.
893
+ */
894
+ postProcess?: (pathOrUrl: string) => Promise<string>;
895
+
896
+ /**
897
+ * You can use this prop in order to provide a custom preview URL.
898
+ * Useful when the file's path is different from the original field value
899
+ */
900
+ previewUrl?: (fileName: string) => string;
901
+ }
902
+
903
+ /**
904
+ * @group Entity properties
905
+ */
906
+ export interface UploadedFileContext {
907
+ /**
908
+ * Uploaded file
909
+ */
910
+ file: File;
911
+
912
+ /**
913
+ * Property field name
914
+ */
915
+ propertyKey: string;
916
+
917
+ /**
918
+ * Property related to this upload
919
+ */
920
+ property: StringProperty | ArrayProperty;
921
+
922
+ /**
923
+ * Entity ID
924
+ */
925
+ entityId?: string | number;
926
+
927
+ /**
928
+ * Entity path. E.g. `products/PID/locales`
929
+ */
930
+ path?: string;
931
+
932
+ /**
933
+ * Values of the current entity
934
+ */
935
+ values: EntityValues<any>;
936
+
937
+ /**
938
+ * Storage meta specified by the developer
939
+ */
940
+ storage: StorageConfig;
941
+ }
942
+
943
+ /**
944
+ * Used for previewing urls if the download file is known
945
+ * @group Entity properties
946
+ */
947
+ export type PreviewType = "image" | "video" | "audio" | "file";
948
+
949
+ /**
950
+ * MIME types for storage fields
951
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
952
+ * @group Entity properties
953
+ */
954
+ export type FileType =
955
+ | "image/*"
956
+ | "video/*"
957
+ | "audio/*"
958
+ | "application/*"
959
+ | "text/*"
960
+ | "font/*"
961
+ | string;
962
+
963
+ export interface ImageResize {
964
+ /**
965
+ * Maximum width in pixels. Image will be scaled down proportionally if wider.
966
+ */
967
+ maxWidth?: number;
968
+
969
+ /**
970
+ * Maximum height in pixels. Image will be scaled down proportionally if taller.
971
+ */
972
+ maxHeight?: number;
973
+
974
+ /**
975
+ * Resize mode determines how the image fits within maxWidth/maxHeight bounds.
976
+ * - `contain`: Scale down to fit within bounds, preserving aspect ratio (default)
977
+ * - `cover`: Scale to fill bounds, preserving aspect ratio (may crop)
978
+ */
979
+ mode?: 'contain' | 'cover';
980
+
981
+ /**
982
+ * Output format for the resized image.
983
+ * - `original`: Keep the original format (default)
984
+ * - `jpeg`: Convert to JPEG
985
+ * - `png`: Convert to PNG
986
+ * - `webp`: Convert to WebP
987
+ */
988
+ format?: 'original' | 'jpeg' | 'png' | 'webp';
989
+
990
+ /**
991
+ * Quality for lossy formats (JPEG, WebP). Number between 0 and 100.
992
+ * Higher is better quality but larger file size. Defaults to 80.
993
+ */
994
+ quality?: number;
995
+ }
996
+
997
+ /**
998
+ * A JSON Logic rule that gets evaluated at runtime.
999
+ * @see https://jsonlogic.com/
1000
+ *
1001
+ * Common operators:
1002
+ * - Comparison: ==, !=, ===, !==, >, <, >=, <=
1003
+ * - Logic: and, or, !, !!
1004
+ * - Data access: var, missing, missing_some
1005
+ * - Array: in, map, filter, reduce, all, some, none, merge
1006
+ * - String: substr, cat
1007
+ * - Numeric: +, -, *, /, %, min, max
1008
+ *
1009
+ * Custom operators:
1010
+ * - hasRole(roleId) - check if user has role by ID
1011
+ * - hasAnyRole([roleIds]) - check if user has any of the roles
1012
+ * - isToday(timestamp) - check if timestamp is today
1013
+ * - isPast(timestamp) - check if timestamp is in the past
1014
+ * - isFuture(timestamp) - check if timestamp is in the future
1015
+ *
1016
+ * @group Entity properties
1017
+ */
1018
+ export type JsonLogicRule = Record<string, any>;
1019
+
1020
+ /**
1021
+ * Conditions for individual enum values within a property.
1022
+ * @group Entity properties
1023
+ */
1024
+ export interface EnumValueConditions {
1025
+ /**
1026
+ * Disable this enum option when condition is true.
1027
+ * The option appears grayed out and cannot be selected.
1028
+ */
1029
+ disabled?: JsonLogicRule;
1030
+
1031
+ /**
1032
+ * Message explaining why this option is disabled.
1033
+ */
1034
+ disabledMessage?: string;
1035
+
1036
+ /**
1037
+ * Completely hide this enum option when condition is true.
1038
+ * The option is removed from the dropdown/list.
1039
+ */
1040
+ hidden?: JsonLogicRule;
1041
+ }
1042
+
1043
+ /**
1044
+ * Declarative conditions for dynamic property behavior.
1045
+ * All conditions are JSON Logic rules evaluated against ConditionContext.
1046
+ *
1047
+ * An alternative to PropertyBuilder functions that can be:
1048
+ * - Stored in the database as JSON
1049
+ * - Edited via the collection editor UI
1050
+ * - Evaluated at runtime like property builders
1051
+ *
1052
+ * @see https://jsonlogic.com/ for JSON Logic syntax
1053
+ * @group Entity properties
1054
+ */
1055
+ export interface PropertyConditions {
1056
+
1057
+ // ═══════════════════════════════════════════════════════════════════════
1058
+ // FIELD STATE CONDITIONS
1059
+ // ═══════════════════════════════════════════════════════════════════════
1060
+
1061
+ /**
1062
+ * Disable the field when this condition evaluates to true.
1063
+ * The field becomes non-editable but still visible (unless also hidden).
1064
+ *
1065
+ * @example Disable when another field has a specific value
1066
+ * \`\`\`json
1067
+ * { "==": [{ "var": "values.status" }, "archived"] }
1068
+ * \`\`\`
1069
+ */
1070
+ disabled?: JsonLogicRule;
1071
+
1072
+ /**
1073
+ * Message to display when the field is disabled by a condition.
1074
+ */
1075
+ disabledMessage?: string;
1076
+
1077
+ /**
1078
+ * Clear the field's value when it becomes disabled.
1079
+ * @default false
1080
+ */
1081
+ clearOnDisabled?: boolean;
1082
+
1083
+ /**
1084
+ * Hide the field completely when this condition evaluates to true.
1085
+ * The field is removed from the form (not just visually hidden).
1086
+ */
1087
+ hidden?: JsonLogicRule;
1088
+
1089
+ /**
1090
+ * Make the field read-only when this condition evaluates to true.
1091
+ * Renders as a preview instead of an input.
1092
+ */
1093
+ readOnly?: JsonLogicRule;
1094
+
1095
+ // ═══════════════════════════════════════════════════════════════════════
1096
+ // VALIDATION CONDITIONS
1097
+ // ═══════════════════════════════════════════════════════════════════════
1098
+
1099
+ /**
1100
+ * Make the field required when this condition evaluates to true.
1101
+ * Overrides the static `validation.required` setting.
1102
+ */
1103
+ required?: JsonLogicRule;
1104
+
1105
+ /**
1106
+ * Custom message when conditional required validation fails.
1107
+ */
1108
+ requiredMessage?: string;
1109
+
1110
+ /**
1111
+ * Dynamic minimum value for number/string length.
1112
+ * Should evaluate to a number.
1113
+ */
1114
+ min?: JsonLogicRule;
1115
+
1116
+ /**
1117
+ * Dynamic maximum value for number/string length.
1118
+ * Should evaluate to a number.
1119
+ */
1120
+ max?: JsonLogicRule;
1121
+
1122
+ // ═══════════════════════════════════════════════════════════════════════
1123
+ // VALUE CONDITIONS
1124
+ // ═══════════════════════════════════════════════════════════════════════
1125
+
1126
+ /**
1127
+ * Dynamic default value for new entities.
1128
+ * Should evaluate to a value of the appropriate type for the field.
1129
+ * Only applied when entityId is empty (new entity).
1130
+ */
1131
+ defaultValue?: JsonLogicRule;
1132
+
1133
+ // ═══════════════════════════════════════════════════════════════════════
1134
+ // ENUM CONDITIONS (for string/number properties with enumValues)
1135
+ // ═══════════════════════════════════════════════════════════════════════
1136
+
1137
+ /**
1138
+ * Conditions for individual enum values.
1139
+ * Keys are the enum value IDs, values are condition configs.
1140
+ *
1141
+ * @example Disable certain enum options based on user role
1142
+ * \`\`\`json
1143
+ * {
1144
+ * "admin": {
1145
+ * "disabled": { "!": { "hasRole": "admin" } },
1146
+ * "disabledMessage": "Admin option requires admin role"
1147
+ * }
1148
+ * }
1149
+ * \`\`\`
1150
+ */
1151
+ enumConditions?: Record<string | number, EnumValueConditions>;
1152
+
1153
+ /**
1154
+ * Filter which enum values are available.
1155
+ * Should evaluate to an array of allowed enum value IDs.
1156
+ */
1157
+ allowedEnumValues?: JsonLogicRule;
1158
+
1159
+ /**
1160
+ * Exclude specific enum values.
1161
+ * Should evaluate to an array of enum value IDs to exclude.
1162
+ */
1163
+ excludedEnumValues?: JsonLogicRule;
1164
+
1165
+ // ═══════════════════════════════════════════════════════════════════════
1166
+ // REFERENCE CONDITIONS (for reference properties)
1167
+ // ═══════════════════════════════════════════════════════════════════════
1168
+
1169
+ /**
1170
+ * Dynamic path for reference properties.
1171
+ * Should evaluate to a collection path string.
1172
+ */
1173
+ referencePath?: JsonLogicRule;
1174
+
1175
+ /**
1176
+ * Dynamic filter for reference selection.
1177
+ * Should evaluate to a FilterValues object.
1178
+ */
1179
+ referenceFilter?: JsonLogicRule;
1180
+
1181
+ // ═══════════════════════════════════════════════════════════════════════
1182
+ // ARRAY CONDITIONS (for array properties)
1183
+ // ═══════════════════════════════════════════════════════════════════════
1184
+
1185
+ /**
1186
+ * Can elements be added to the array?
1187
+ */
1188
+ canAddElements?: JsonLogicRule;
1189
+
1190
+ /**
1191
+ * Can elements be reordered in the array?
1192
+ */
1193
+ sortable?: JsonLogicRule;
1194
+
1195
+ // ═══════════════════════════════════════════════════════════════════════
1196
+ // STORAGE CONDITIONS (for file upload properties)
1197
+ // ═══════════════════════════════════════════════════════════════════════
1198
+
1199
+ /**
1200
+ * Dynamic accepted file types.
1201
+ * Should evaluate to an array of MIME types.
1202
+ */
1203
+ acceptedFiles?: JsonLogicRule;
1204
+
1205
+ /**
1206
+ * Dynamic maximum file size in bytes.
1207
+ * Should evaluate to a number.
1208
+ */
1209
+ maxFileSize?: JsonLogicRule;
1210
+ }
1211
+
1212
+ /**
1213
+ * Context available during JSON Logic condition evaluation.
1214
+ * Mirrors PropertyBuilderProps but adapted for JSON serialization.
1215
+ * @group Entity properties
1216
+ */
1217
+ export interface ConditionContext {
1218
+ /**
1219
+ * Current form/entity values.
1220
+ * Date values are converted to Unix timestamps (milliseconds).
1221
+ */
1222
+ values: Record<string, any>;
1223
+
1224
+ /**
1225
+ * Previous values before the current edit session.
1226
+ */
1227
+ previousValues: Record<string, any>;
1228
+
1229
+ /**
1230
+ * Current value of this property specifically.
1231
+ */
1232
+ propertyValue: unknown;
1233
+
1234
+ /**
1235
+ * Collection path (e.g., "products", "users/uid123/orders")
1236
+ */
1237
+ path: string;
1238
+
1239
+ /**
1240
+ * Entity ID. Undefined for new entities.
1241
+ */
1242
+ entityId?: string;
1243
+
1244
+ /**
1245
+ * Whether this is a new entity being created.
1246
+ */
1247
+ isNew: boolean;
1248
+
1249
+ /**
1250
+ * Index of this property (only for array items).
1251
+ */
1252
+ index?: number;
1253
+
1254
+ /**
1255
+ * Current authenticated user information.
1256
+ */
1257
+ user: {
1258
+ uid: string;
1259
+ email: string | null;
1260
+ displayName: string | null;
1261
+ photoURL: string | null;
1262
+ /** Role IDs the user has (extracted from Role[].id) */
1263
+ roles: string[];
1264
+ };
1265
+
1266
+ /**
1267
+ * Current timestamp as Unix milliseconds.
1268
+ */
1269
+ now: number;
1270
+ }