@rebasepro/types 0.0.1-canary.2 → 0.0.1-canary.4d4fb3e

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 (86) hide show
  1. package/README.md +1 -1
  2. package/dist/controllers/analytics_controller.d.ts +2 -2
  3. package/dist/controllers/auth.d.ts +50 -6
  4. package/dist/controllers/client.d.ts +58 -0
  5. package/dist/controllers/collection_registry.d.ts +44 -0
  6. package/dist/controllers/customization_controller.d.ts +5 -1
  7. package/dist/controllers/data.d.ts +141 -0
  8. package/dist/controllers/{datasource.d.ts → data_driver.d.ts} +25 -36
  9. package/dist/controllers/database_admin.d.ts +11 -0
  10. package/dist/controllers/effective_role.d.ts +4 -0
  11. package/dist/controllers/index.d.ts +11 -5
  12. package/dist/controllers/navigation.d.ts +9 -58
  13. package/dist/controllers/registry.d.ts +51 -0
  14. package/dist/controllers/side_entity_controller.d.ts +1 -2
  15. package/dist/index.d.ts +0 -1
  16. package/dist/index.es.js +113 -12
  17. package/dist/index.es.js.map +1 -1
  18. package/dist/index.umd.js +112 -11
  19. package/dist/index.umd.js.map +1 -1
  20. package/dist/rebase_context.d.ts +35 -25
  21. package/dist/types/backend.d.ts +296 -17
  22. package/dist/types/builders.d.ts +14 -0
  23. package/dist/types/collections.d.ts +166 -241
  24. package/dist/types/data_source.d.ts +64 -0
  25. package/dist/types/entities.d.ts +29 -24
  26. package/dist/types/entity_actions.d.ts +7 -7
  27. package/dist/types/entity_callbacks.d.ts +4 -4
  28. package/dist/types/entity_overrides.d.ts +6 -2
  29. package/dist/types/entity_views.d.ts +61 -0
  30. package/dist/types/index.d.ts +8 -5
  31. package/dist/types/plugins.d.ts +170 -221
  32. package/dist/types/properties.d.ts +17 -29
  33. package/dist/types/property_config.d.ts +13 -11
  34. package/dist/types/slots.d.ts +228 -0
  35. package/dist/types/translations.d.ts +826 -0
  36. package/dist/types/user_management_delegate.d.ts +42 -0
  37. package/dist/types/websockets.d.ts +45 -0
  38. package/dist/users/user.d.ts +4 -0
  39. package/package.json +7 -39
  40. package/src/controllers/analytics_controller.tsx +2 -2
  41. package/src/controllers/auth.tsx +53 -6
  42. package/src/controllers/client.ts +74 -0
  43. package/src/controllers/collection_registry.ts +53 -0
  44. package/src/controllers/customization_controller.tsx +6 -1
  45. package/src/controllers/data.ts +153 -0
  46. package/src/controllers/{datasource.ts → data_driver.ts} +41 -37
  47. package/src/controllers/database_admin.ts +22 -0
  48. package/src/controllers/effective_role.ts +4 -0
  49. package/src/controllers/index.ts +14 -5
  50. package/src/controllers/navigation.ts +9 -73
  51. package/src/controllers/registry.ts +62 -0
  52. package/src/controllers/side_entity_controller.tsx +1 -2
  53. package/src/index.ts +0 -1
  54. package/src/rebase_context.tsx +37 -33
  55. package/src/types/backend.ts +351 -19
  56. package/src/types/builders.ts +16 -0
  57. package/src/types/collections.ts +196 -259
  58. package/src/types/data_source.ts +156 -0
  59. package/src/types/entities.ts +35 -28
  60. package/src/types/entity_actions.tsx +6 -6
  61. package/src/types/entity_callbacks.ts +4 -4
  62. package/src/types/entity_overrides.tsx +6 -2
  63. package/src/types/entity_views.tsx +77 -0
  64. package/src/types/index.ts +9 -5
  65. package/src/types/plugins.tsx +198 -256
  66. package/src/types/properties.ts +22 -31
  67. package/src/types/property_config.tsx +11 -11
  68. package/src/types/slots.tsx +271 -0
  69. package/src/types/translations.ts +923 -0
  70. package/src/types/user_management_delegate.ts +43 -0
  71. package/src/types/websockets.ts +48 -0
  72. package/src/users/user.ts +5 -0
  73. package/dist/components/EntityFormActionsProps.d.ts +0 -17
  74. package/dist/components/EntityFormProps.d.ts +0 -46
  75. package/dist/components/PropertyPreviewProps.d.ts +0 -50
  76. package/dist/components/formex.d.ts +0 -40
  77. package/dist/components/index.d.ts +0 -3
  78. package/dist/types/fields.d.ts +0 -221
  79. package/dist/types/rebase.d.ts +0 -180
  80. package/src/components/EntityFormActionsProps.tsx +0 -18
  81. package/src/components/EntityFormProps.tsx +0 -52
  82. package/src/components/PropertyPreviewProps.tsx +0 -61
  83. package/src/components/formex.tsx +0 -46
  84. package/src/components/index.ts +0 -3
  85. package/src/types/fields.tsx +0 -298
  86. package/src/types/rebase.tsx +0 -211
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Describes the capabilities and features supported by a data source (driver).
3
+ *
4
+ * Each driver (Postgres, Firebase, MongoDB, etc.) declares which features it
5
+ * supports. The CMS uses this descriptor to:
6
+ * - Show/hide editor tabs (e.g. Relations for SQL, Subcollections for Firebase)
7
+ * - Filter the property type picker (e.g. `relation` for SQL, `reference` for Firebase)
8
+ * - Toggle driver-specific form controls (e.g. `columnType` for SQL)
9
+ *
10
+ * @group Models
11
+ */
12
+ export interface DataSourceCapabilities {
13
+ /** Unique driver key (e.g. "postgres", "firestore", "mongodb") */
14
+ key: string;
15
+ /** Human-readable label for the UI (e.g. "PostgreSQL", "Firebase / Firestore") */
16
+ label: string;
17
+ /** Does this source support SQL-style relations (JOINs)? */
18
+ supportsRelations: boolean;
19
+ /** Does this source support nested subcollections? */
20
+ supportsSubcollections: boolean;
21
+ /** Does this source support Row Level Security policies? */
22
+ supportsRLS: boolean;
23
+ /** Does this source support document references (Firebase-style)? */
24
+ supportsReferences: boolean;
25
+ /** Does this source support SQL column type annotations? */
26
+ supportsColumnTypes: boolean;
27
+ /** Does this source support real-time listeners? */
28
+ supportsRealtime: boolean;
29
+ /** Does this source support SQL admin operations (SQL editor, EXPLAIN, etc.)? */
30
+ supportsSQLAdmin: boolean;
31
+ /** Does this source support document admin operations (aggregation, stats)? */
32
+ supportsDocumentAdmin: boolean;
33
+ /** Does this source support schema admin (unmapped tables, table metadata)? */
34
+ supportsSchemaAdmin: boolean;
35
+ }
36
+ /**
37
+ * Subset of DataSourceCapabilities containing only feature flags.
38
+ * Useful when you only need to check capabilities without UI metadata.
39
+ * @group Models
40
+ */
41
+ export type DataSourceFeatures = Pick<DataSourceCapabilities, "supportsRelations" | "supportsSubcollections" | "supportsRLS" | "supportsReferences" | "supportsColumnTypes" | "supportsRealtime" | "supportsSQLAdmin" | "supportsDocumentAdmin" | "supportsSchemaAdmin">;
42
+ /** @group Models */
43
+ export declare const POSTGRES_CAPABILITIES: DataSourceCapabilities;
44
+ /** @group Models */
45
+ export declare const FIREBASE_CAPABILITIES: DataSourceCapabilities;
46
+ /** @group Models */
47
+ export declare const MONGODB_CAPABILITIES: DataSourceCapabilities;
48
+ /**
49
+ * Fallback capabilities when the driver is unknown.
50
+ * Enables everything so nothing is hidden unexpectedly.
51
+ * @group Models
52
+ */
53
+ export declare const DEFAULT_CAPABILITIES: DataSourceCapabilities;
54
+ /**
55
+ * Look up capabilities for a given driver key.
56
+ * If `driver` is undefined or not found, returns `DEFAULT_CAPABILITIES`.
57
+ * @group Models
58
+ */
59
+ export declare function getDataSourceCapabilities(driver?: string): DataSourceCapabilities;
60
+ /**
61
+ * Register custom capabilities for a third-party driver.
62
+ * @group Models
63
+ */
64
+ export declare function registerDataSourceCapabilities(capabilities: DataSourceCapabilities): void;
@@ -4,10 +4,10 @@
4
4
  */
5
5
  export type EntityStatus = "new" | "existing" | "copy";
6
6
  /**
7
- * Representation of an entity fetched from the datasource
7
+ * Representation of an entity fetched from the driver
8
8
  * @group Models
9
9
  */
10
- export interface Entity<M extends object = object> {
10
+ export interface Entity<M extends Record<string, unknown> = Record<string, unknown>> {
11
11
  /**
12
12
  * ID of the entity
13
13
  */
@@ -22,13 +22,13 @@ export interface Entity<M extends object = object> {
22
22
  */
23
23
  values: EntityValues<M>;
24
24
  /**
25
- * Which datasource this entity belongs to (e.g., 'postgres', 'firestore').
26
- * If not specified, the default datasource is assumed.
25
+ * Which driver this entity belongs to (e.g., 'postgres', 'firestore').
26
+ * If not specified, the default driver is assumed.
27
27
  */
28
- datasource?: string;
28
+ driver?: string;
29
29
  /**
30
- * Which database within the datasource (e.g., for Firestore multi-database).
31
- * If not specified, the default database of the datasource is used.
30
+ * Which database within the driver (e.g., for Firestore multi-database).
31
+ * If not specified, the default database of the driver is used.
32
32
  */
33
33
  databaseId?: string;
34
34
  }
@@ -37,7 +37,7 @@ export interface Entity<M extends object = object> {
37
37
  * entity collection.
38
38
  * @group Models
39
39
  */
40
- export type EntityValues<M extends object> = M;
40
+ export type EntityValues<M extends Record<string, unknown>> = M;
41
41
  /**
42
42
  * Props for creating an EntityReference
43
43
  */
@@ -46,23 +46,23 @@ export interface EntityReferenceProps {
46
46
  id: string;
47
47
  /** Path of the collection (relative to the root of the database) */
48
48
  path: string;
49
- /** Which datasource (e.g., 'postgres', 'firestore'). Defaults to "(default)" */
50
- datasource?: string;
51
- /** Which database within the datasource. Defaults to "(default)" */
49
+ /** Which driver (e.g., 'postgres', 'firestore'). Defaults to "(default)" */
50
+ driver?: string;
51
+ /** Which database within the driver. Defaults to "(default)" */
52
52
  databaseId?: string;
53
53
  }
54
54
  /**
55
55
  * Class used to create a reference to an entity in a different path.
56
56
  *
57
57
  * @example
58
- * // Simple reference (most common case - single datasource, single db)
58
+ * // Simple reference (most common case - single driver, single db)
59
59
  * new EntityReference({ id: "123", path: "users" })
60
60
  *
61
- * // Reference to a different datasource (e.g., Firestore)
62
- * new EntityReference({ id: "123", path: "analytics", datasource: "firestore" })
61
+ * // Reference to a different driver (e.g., Firestore)
62
+ * new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
63
63
  *
64
- * // Reference to a specific database within a datasource
65
- * new EntityReference({ id: "123", path: "orders", datasource: "postgres", databaseId: "orders_db" })
64
+ * // Reference to a specific database within a driver
65
+ * new EntityReference({ id: "123", path: "orders", driver: "postgres", databaseId: "orders_db" })
66
66
  */
67
67
  export declare class EntityReference {
68
68
  readonly __type = "reference";
@@ -76,12 +76,12 @@ export declare class EntityReference {
76
76
  */
77
77
  readonly path: string;
78
78
  /**
79
- * Which datasource (e.g., 'postgres', 'firestore').
79
+ * Which driver (e.g., 'postgres', 'firestore').
80
80
  * Defaults to "(default)" if not specified.
81
81
  */
82
- readonly datasource?: string;
82
+ readonly driver?: string;
83
83
  /**
84
- * Which database within the datasource.
84
+ * Which database within the driver.
85
85
  * Defaults to "(default)" if not specified.
86
86
  */
87
87
  readonly databaseId?: string;
@@ -92,14 +92,14 @@ export declare class EntityReference {
92
92
  * // Simple reference (most common case)
93
93
  * new EntityReference({ id: "123", path: "users" })
94
94
  *
95
- * // With datasource
96
- * new EntityReference({ id: "123", path: "analytics", datasource: "firestore" })
95
+ * // With driver
96
+ * new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
97
97
  */
98
98
  constructor(props: EntityReferenceProps);
99
99
  get pathWithId(): string;
100
100
  /**
101
- * Get the full path including datasource and database prefixes if specified.
102
- * For the common case (single datasource, single db), this just returns pathWithId.
101
+ * Get the full path including driver and database prefixes if specified.
102
+ * For the common case (single driver, single db), this just returns pathWithId.
103
103
  */
104
104
  get fullPath(): string;
105
105
  isEntityReference(): boolean;
@@ -118,7 +118,12 @@ export declare class EntityRelation {
118
118
  * to the root of the database).
119
119
  */
120
120
  readonly path: string;
121
- constructor(id: string | number, path: string);
121
+ /**
122
+ * Pre-fetched data payload to eliminate N+1 queries.
123
+ * When present, clients can use this directly instead of fetching.
124
+ */
125
+ readonly data?: Entity;
126
+ constructor(id: string | number, path: string, data?: Entity);
122
127
  get pathWithId(): string;
123
128
  isEntityReference(): boolean;
124
129
  isEntityRelation(): boolean;
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { Entity } from "./entities";
3
3
  import { EntityCollection, SelectionController } from "./collections";
4
- import { FormContext } from "./fields";
4
+ import { FormContext } from "./entity_views";
5
5
  import { User } from "../users";
6
6
  import { RebaseContext } from "../rebase_context";
7
7
  import { SideEntityController } from "../controllers";
@@ -9,7 +9,7 @@ import { SideEntityController } from "../controllers";
9
9
  * An entity action is a custom action that can be performed on an entity.
10
10
  * They are displayed in the entity view and in the collection view.
11
11
  */
12
- export type EntityAction<M extends object = any, USER extends User = User> = {
12
+ export interface EntityAction<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
13
13
  /**
14
14
  * Title of the action
15
15
  */
@@ -34,12 +34,12 @@ export type EntityAction<M extends object = any, USER extends User = User> = {
34
34
  * Callback when the action is clicked
35
35
  * @param props
36
36
  */
37
- onClick: (props: EntityActionClickProps<M, USER>) => Promise<void> | void;
37
+ onClick(props: EntityActionClickProps<M, USER>): Promise<void> | void;
38
38
  /**
39
39
  * Optional callback in case you want to disable the action
40
40
  * @param props
41
41
  */
42
- isEnabled?: (props: EntityActionClickProps<M, USER>) => boolean;
42
+ isEnabled?(props: EntityActionClickProps<M, USER>): boolean;
43
43
  /**
44
44
  * Show this action collapsed in the menu of the collection view.
45
45
  * Defaults to true
@@ -50,12 +50,12 @@ export type EntityAction<M extends object = any, USER extends User = User> = {
50
50
  * Show this action in the form, defaults to true
51
51
  */
52
52
  includeInForm?: boolean;
53
- };
54
- export type EntityActionClickProps<M extends object, USER extends User = User> = {
53
+ }
54
+ export type EntityActionClickProps<M extends Record<string, unknown>, USER extends User = User> = {
55
55
  entity?: Entity<M>;
56
56
  context: RebaseContext<USER>;
57
57
  path?: string;
58
- collection?: EntityCollection<M>;
58
+ collection?: EntityCollection<Record<string, unknown>, any>;
59
59
  /**
60
60
  * Optional form context, present if the action is being called from a form.
61
61
  * This allows you to access the form state and methods, including modifying the form values.
@@ -55,7 +55,7 @@ export interface EntityAfterReadProps<M extends Record<string, any> = any, USER
55
55
  /**
56
56
  * Collection of the entity
57
57
  */
58
- collection: EntityCollection<M, USER>;
58
+ collection: EntityCollection<Record<string, unknown>, any>;
59
59
  /**
60
60
  * Full path of the CMS where this collection is being fetched.
61
61
  * Might contain unresolved aliases.
@@ -92,7 +92,7 @@ export interface EntityAfterSaveProps<M extends Record<string, any> = any, USER
92
92
  /**
93
93
  * Resolved collection of the entity
94
94
  */
95
- collection: EntityCollection<M>;
95
+ collection: EntityCollection<Record<string, unknown>, any>;
96
96
  /**
97
97
  * Full path of the CMS where this entity is being saved.
98
98
  * Might contain unresolved aliases.
@@ -127,7 +127,7 @@ export interface EntityBeforeDeleteProps<M extends Record<string, any> = any, US
127
127
  /**
128
128
  * collection of the entity being deleted
129
129
  */
130
- collection: EntityCollection<M>;
130
+ collection: EntityCollection<Record<string, unknown>, any>;
131
131
  /**
132
132
  * Path of the parent collection
133
133
  */
@@ -153,7 +153,7 @@ export interface EntityAfterDeleteProps<M extends Record<string, any> = any, USE
153
153
  /**
154
154
  * collection of the entity being deleted
155
155
  */
156
- collection: EntityCollection<M>;
156
+ collection: EntityCollection<Record<string, unknown>, any>;
157
157
  /**
158
158
  * Path of the parent collection
159
159
  */
@@ -1,5 +1,9 @@
1
- import { DataSource, StorageSource } from "../controllers";
1
+ import { DataDriver, StorageSource } from "../controllers";
2
2
  export type EntityOverrides = {
3
- dataSource?: DataSource;
3
+ /**
4
+ * Internal driver override for this collection.
5
+ * Used by the CMS engine to route data operations.
6
+ */
7
+ driver?: DataDriver;
4
8
  storageSource?: StorageSource;
5
9
  };
@@ -0,0 +1,61 @@
1
+ import React from "react";
2
+ import { Entity, EntityValues } from "./entities";
3
+ import { EntityCollection } from "./collections";
4
+ /**
5
+ * Context passed to custom fields and entity views.
6
+ * This is the base definition — `@rebasepro/cms` re-exports a
7
+ * fully-typed version that narrows the `formex` field.
8
+ * @group Form custom fields
9
+ */
10
+ export interface FormContext<M extends Record<string, any> = any> {
11
+ /**
12
+ * Current values of the entity
13
+ */
14
+ values: M;
15
+ /**
16
+ * Update the value of a field
17
+ */
18
+ setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
19
+ /**
20
+ * Save the entity.
21
+ */
22
+ save: (values: M) => void;
23
+ /**
24
+ * Collection of the entity being modified
25
+ */
26
+ collection?: EntityCollection<M>;
27
+ /**
28
+ * Entity id, it can be undefined if it's a new entity
29
+ */
30
+ entityId?: string | number;
31
+ /**
32
+ * Path this entity is located at
33
+ */
34
+ path?: string;
35
+ status: "new" | "existing" | "copy";
36
+ entity?: Entity<M>;
37
+ savingError?: Error;
38
+ openEntityMode: "side_panel" | "full_screen";
39
+ /**
40
+ * The underlying formex controller that powers the form.
41
+ * Prefer importing `FormContext` from `@rebasepro/cms` for the
42
+ * fully-typed `FormexController<M>` version.
43
+ */
44
+ formex: Record<string, unknown>;
45
+ disabled: boolean;
46
+ }
47
+ export type EntityCustomView<M extends Record<string, any> = any> = {
48
+ key: string;
49
+ name: string;
50
+ tabComponent?: React.ReactNode;
51
+ includeActions?: boolean | "bottom";
52
+ Builder?: React.ComponentType<EntityCustomViewParams<M>>;
53
+ position?: "start" | "end";
54
+ };
55
+ export interface EntityCustomViewParams<M extends Record<string, any> = any> {
56
+ collection: EntityCollection<M>;
57
+ entity?: Entity<M>;
58
+ modifiedValues?: EntityValues<M>;
59
+ formContext: FormContext<M>;
60
+ parentCollectionIds?: string[];
61
+ }
@@ -1,19 +1,22 @@
1
1
  export * from "./entities";
2
2
  export * from "./chips";
3
- export * from "./entity_actions";
4
3
  export * from "./properties";
5
4
  export * from "./collections";
6
5
  export * from "./relations";
7
6
  export * from "./locales";
8
- export * from "./fields";
9
- export * from "./property_config";
10
7
  export * from "./entity_link_builder";
11
8
  export * from "./user_management_delegate";
12
9
  export * from "./entity_callbacks";
13
10
  export * from "./entity_overrides";
14
- export * from "./plugins";
15
- export * from "./rebase";
16
11
  export * from "./export_import";
17
12
  export * from "./modify_collections";
18
13
  export * from "./websockets";
19
14
  export * from "./backend";
15
+ export * from "./translations";
16
+ export * from "./plugins";
17
+ export * from "./builders";
18
+ export * from "./slots";
19
+ export * from "./entity_actions";
20
+ export * from "./property_config";
21
+ export * from "./entity_views";
22
+ export * from "./data_source";