@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
@@ -1,5 +1,21 @@
1
1
  import { Role, User } from "../users";
2
2
 
3
+ /**
4
+ * Result of creating a new user via admin flow.
5
+ * Contains the created user plus information about how credentials were delivered.
6
+ */
7
+ export interface UserCreationResult<USER extends User = User> {
8
+ /** The created user */
9
+ user: USER;
10
+ /** Whether an invitation email was sent to the user */
11
+ invitationSent: boolean;
12
+ /**
13
+ * Temporary password (only present when email service is not configured).
14
+ * This is returned one-time and should be shown to the admin to share manually.
15
+ */
16
+ temporaryPassword?: string;
17
+ }
18
+
3
19
 
4
20
  /**
5
21
  * Delegate to manage users, roles, and their permissions.
@@ -32,12 +48,39 @@ export interface UserManagementDelegate<USER extends User = User> {
32
48
  */
33
49
  getUser: (uid: string) => USER | null;
34
50
 
51
+ /**
52
+ * Search users with server-side pagination.
53
+ * When provided, the CMS will use this for the users table
54
+ * instead of loading all users into memory.
55
+ */
56
+ searchUsers?: (options: {
57
+ search?: string;
58
+ limit?: number;
59
+ offset?: number;
60
+ orderBy?: string;
61
+ orderDir?: "asc" | "desc";
62
+ }) => Promise<{ users: USER[]; total: number }>;
63
+
35
64
  /**
36
65
  * Save a user (create or update)
37
66
  * @param user
38
67
  */
39
68
  saveUser?: (user: USER) => Promise<USER>;
40
69
 
70
+ /**
71
+ * Create a new user with invitation/password generation support.
72
+ * Returns additional info about how the credentials were delivered.
73
+ * Falls back to saveUser if not provided.
74
+ */
75
+ createUser?: (user: USER) => Promise<UserCreationResult<USER>>;
76
+
77
+ /**
78
+ * Reset the password for an existing user.
79
+ * Returns a temporary password if no email service is configured,
80
+ * or a flag indicating an email invitation was sent.
81
+ */
82
+ resetPassword?: (user: USER) => Promise<UserCreationResult<USER>>;
83
+
41
84
  /**
42
85
  * Delete a user
43
86
  * @param user
@@ -1,5 +1,11 @@
1
1
  import { Entity } from "./entities";
2
2
 
3
+ export interface WebSocketErrorPayload {
4
+ error?: string | { message: string; code?: string };
5
+ message?: string;
6
+ code?: string;
7
+ }
8
+
3
9
  export interface WebSocketMessage {
4
10
  type: string;
5
11
  payload?: unknown;
@@ -22,6 +28,20 @@ export interface EntityUpdateMessage extends WebSocketMessage {
22
28
  entity: Entity<Record<string, unknown>> | null;
23
29
  }
24
30
 
31
+ /**
32
+ * Lightweight patch message sent to collection subscribers when a single
33
+ * entity is created, updated, or deleted. The client can merge this into
34
+ * its cached collection data for near-instant cross-tab updates without
35
+ * waiting for a full collection refetch.
36
+ */
37
+ export interface CollectionEntityPatchMessage extends WebSocketMessage {
38
+ type: "collection_entity_patch";
39
+ subscriptionId: string;
40
+ entityId: string;
41
+ /** The updated entity, or null if deleted */
42
+ entity: Entity<Record<string, unknown>> | null;
43
+ }
44
+
25
45
  /**
26
46
  * Column metadata returned by table introspection.
27
47
  */
@@ -35,3 +55,31 @@ export interface TableColumnInfo {
35
55
  /** Enum values, populated for USER-DEFINED (enum) columns */
36
56
  enum_values?: string[];
37
57
  }
58
+
59
+ export interface TableForeignKeyInfo {
60
+ column_name: string;
61
+ foreign_table_name: string;
62
+ foreign_column_name: string;
63
+ }
64
+
65
+ export interface TableJunctionInfo {
66
+ junction_table_name: string;
67
+ source_column_name: string;
68
+ target_table_name: string;
69
+ target_column_name: string;
70
+ }
71
+
72
+ export interface TablePolicyInfo {
73
+ policy_name: string;
74
+ roles: string[];
75
+ cmd: string;
76
+ qual?: string;
77
+ with_check?: string;
78
+ }
79
+
80
+ export interface TableMetadata {
81
+ columns: TableColumnInfo[];
82
+ foreignKeys: TableForeignKeyInfo[];
83
+ junctions: TableJunctionInfo[];
84
+ policies: TablePolicyInfo[];
85
+ }
package/src/users/user.ts CHANGED
@@ -41,6 +41,11 @@ export type User = {
41
41
  */
42
42
  roles?: string[];
43
43
 
44
+ /**
45
+ * The date and time when the user was created.
46
+ */
47
+ createdAt?: Date | string | null;
48
+
44
49
  getIdToken?: (forceRefresh?: boolean) => Promise<string>;
45
50
 
46
51
  };
@@ -1,17 +0,0 @@
1
- import { Entity, EntityCollection, FormContext } from "../types";
2
- import { FormexController } from "./formex";
3
- export interface EntityFormActionsProps {
4
- path: string;
5
- collection: EntityCollection;
6
- entity?: Entity;
7
- layout: "bottom" | "side";
8
- savingError?: Error;
9
- formex: FormexController<any>;
10
- disabled: boolean;
11
- status: "new" | "existing" | "copy";
12
- pluginActions: React.ReactNode[];
13
- openEntityMode: "side_panel" | "full_screen";
14
- showDefaultActions?: boolean;
15
- navigateBack: () => void;
16
- formContext: FormContext;
17
- }
@@ -1,46 +0,0 @@
1
- import { Entity, EntityCollection, EntityCustomViewParams, EntityStatus, FormContext } from "../types";
2
- import { FormexController } from "./formex";
3
- import { EntityFormActionsProps } from "./EntityFormActionsProps";
4
- export type EntityFormProps<M extends Record<string, any>> = {
5
- path: string;
6
- fullIdPath?: string;
7
- collection: EntityCollection<M>;
8
- entityId?: string | number;
9
- entity?: Entity<M>;
10
- databaseId?: string;
11
- onIdChange?: (id: string | number) => void;
12
- onValuesModified?: (modified: boolean, values: M) => void;
13
- onSaved?: (params: OnUpdateParams) => void;
14
- initialDirtyValues?: Partial<M>;
15
- onFormContextReady?: (formContext: FormContext) => void;
16
- forceActionsAtTheBottom?: boolean;
17
- className?: string;
18
- initialStatus: EntityStatus;
19
- onStatusChange?: (status: EntityStatus) => void;
20
- onEntityChange?: (entity: Entity<M>) => void;
21
- formex?: FormexController<M>;
22
- openEntityMode?: "side_panel" | "full_screen";
23
- /**
24
- * If true, the form will be disabled and no actions will be available
25
- */
26
- disabled?: boolean;
27
- /**
28
- * Include the copy and delete actions in the form
29
- */
30
- showDefaultActions?: boolean;
31
- /**
32
- * Display the entity path in the form
33
- */
34
- showEntityPath?: boolean;
35
- EntityFormActionsComponent?: React.FC<EntityFormActionsProps>;
36
- Builder?: React.ComponentType<EntityCustomViewParams<M>>;
37
- children?: React.ReactNode;
38
- };
39
- export type OnUpdateParams = {
40
- entity: Entity<any>;
41
- status: EntityStatus;
42
- path: string;
43
- entityId?: string | number;
44
- selectedTab?: string;
45
- collection: EntityCollection<any>;
46
- };
@@ -1,50 +0,0 @@
1
- import { InferPropertyType, Property } from "../types";
2
- /**
3
- * @group Preview components
4
- */
5
- export type PreviewSize = "small" | "medium" | "large";
6
- /**
7
- * @group Preview components
8
- */
9
- export interface PropertyPreviewProps<P extends Property, CustomProps = unknown> {
10
- /**
11
- * Name of the property
12
- */
13
- propertyKey?: string;
14
- /**
15
- * Current value of the property, inferred from the property schema P
16
- */
17
- value: InferPropertyType<P>;
18
- /**
19
- * Property this display is related to, now strongly typed to P
20
- */
21
- property: P;
22
- /**
23
- * Desired size of the preview, depending on the context.
24
- */
25
- size: PreviewSize;
26
- /**
27
- * Max height assigned to the preview, depending on the context.
28
- * It may be undefined if unlimited.
29
- */
30
- height?: number;
31
- /**
32
- * Max height width to the preview, depending on the context.
33
- * It may be undefined if unlimited.
34
- */
35
- width?: number;
36
- /**
37
- * Additional properties set by the developer
38
- */
39
- customProps?: CustomProps;
40
- /**
41
- * If the preview should be interactive or not.
42
- * This applies only to videos.
43
- */
44
- interactive?: boolean;
45
- /**
46
- * If true, image previews will fill their container completely.
47
- * Only applies to image type properties.
48
- */
49
- fill?: boolean;
50
- }
@@ -1,40 +0,0 @@
1
- import React, { FormEvent } from "react";
2
- export type FormexController<T extends object> = {
3
- values: T;
4
- initialValues: T;
5
- setValues: (values: T) => void;
6
- setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
7
- touched: Record<string, boolean>;
8
- setFieldTouched: (key: string, touched: boolean, shouldValidate?: boolean) => void;
9
- setTouched: (touched: Record<string, boolean>) => void;
10
- dirty: boolean;
11
- setDirty: (dirty: boolean) => void;
12
- setSubmitCount: (submitCount: number) => void;
13
- errors: Record<string, string>;
14
- setFieldError: (key: string, error?: string) => void;
15
- handleChange: (event: React.SyntheticEvent) => void;
16
- handleBlur: (event: React.FocusEvent) => void;
17
- handleSubmit: (event?: FormEvent<HTMLFormElement>) => void;
18
- validate: () => void;
19
- resetForm: (props?: FormexResetProps<T>) => void;
20
- submitCount: number;
21
- isSubmitting: boolean;
22
- setSubmitting: (isSubmitting: boolean) => void;
23
- isValidating: boolean;
24
- /**
25
- * The version of the form. This is incremented every time the form is reset
26
- * or the form is submitted.
27
- */
28
- version: number;
29
- debugId?: string;
30
- undo: () => void;
31
- redo: () => void;
32
- canUndo: boolean;
33
- canRedo: boolean;
34
- };
35
- export type FormexResetProps<T extends object> = {
36
- values?: T;
37
- submitCount?: number;
38
- errors?: Record<string, string>;
39
- touched?: Record<string, boolean>;
40
- };
@@ -1,3 +0,0 @@
1
- export * from "./PropertyPreviewProps";
2
- export * from "./EntityFormProps";
3
- export * from "./EntityFormActionsProps";
@@ -1,221 +0,0 @@
1
- import { InferPropertyType, Property } from "./properties";
2
- import { Entity } from "./entities";
3
- import { FormexController } from "../components/formex";
4
- import { EntityCollection } from "./collections";
5
- export type DefaultFieldConfig = "text_field" | "multiline" | "markdown" | "url" | "email" | "switch" | "select" | "multi_select" | "user_select" | "number_input" | "number_select" | "multi_number_select" | "file_upload" | "multi_file_upload" | "reference_as_string" | "reference" | "multi_references" | "relation" | "date_time" | "group" | "key_value" | "repeat" | "custom_array" | "block";
6
- /**
7
- * When building a custom field you need to create a React component that takes
8
- * this interface as props.
9
- *
10
- * @group Form custom fields
11
- */
12
- export interface FieldProps<P extends Property = Property, CustomProps = any, M extends Record<string, any> = any> {
13
- /**
14
- * Key of the property
15
- * E.g. "user.name" for a property with path "user.name"
16
- */
17
- propertyKey: string;
18
- /**
19
- * Current value of this field, inferred from the property type P
20
- */
21
- value: InferPropertyType<P>;
22
- /**
23
- * Set value of field directly
24
- */
25
- setValue: (value: InferPropertyType<P> | null, shouldValidate?: boolean) => void;
26
- /**
27
- * Set value of a different field directly
28
- * @param propertyKey
29
- * @param value
30
- * @param shouldValidate
31
- */
32
- setFieldValue: (propertyKey: string, value: unknown, shouldValidate?: boolean) => void;
33
- /**
34
- * Is the form currently submitting
35
- */
36
- isSubmitting?: boolean;
37
- /**
38
- * Should this field show the error indicator.
39
- * Note that there might be an error (like an empty field that should be
40
- * filled) but we don't want to show the error until the user has tried
41
- * saving.
42
- */
43
- showError?: boolean;
44
- /**
45
- * Is there an error in this field. The error field has the same shape as
46
- * the field, replacing values with a string containing the error.
47
- * It takes the value `null` if there is no error
48
- */
49
- error?: string;
50
- /**
51
- * Has this field been touched
52
- */
53
- touched?: boolean;
54
- /**
55
- * Property related to this field, now strongly typed to P
56
- */
57
- property: P;
58
- /**
59
- * Should this field include a description
60
- */
61
- includeDescription?: boolean;
62
- /**
63
- * Flag to indicate that the underlying value has been updated in the
64
- * datasource
65
- */
66
- underlyingValueHasChanged?: boolean;
67
- /**
68
- * Is this field part of an array
69
- */
70
- partOfArray?: boolean;
71
- /**
72
- * Is this field part of a block
73
- */
74
- partOfBlock?: boolean;
75
- /**
76
- * Display the child properties directly, without being wrapped in an
77
- * extendable panel. Note that this will also hide the title of this property.
78
- */
79
- minimalistView?: boolean;
80
- /**
81
- * Should this field autofocus on mount
82
- */
83
- autoFocus?: boolean;
84
- /**
85
- * Additional properties set by the developer
86
- */
87
- customProps: CustomProps;
88
- /**
89
- * Additional values related to the state of the form or the entity
90
- */
91
- context: FormContext<M>;
92
- /**
93
- * Flag to indicate if this field should be disabled
94
- */
95
- disabled?: boolean;
96
- /**
97
- * Size of the field
98
- */
99
- size?: "small" | "medium" | "large";
100
- /**
101
- * Some properties might change internal state (like expanding a panel).
102
- * This function should be called when the internal state changes.
103
- * This is used to preserve state in array containers.
104
- *
105
- * @param property
106
- */
107
- onPropertyChange?: (property: Partial<Property>) => void;
108
- }
109
- /**
110
- * Context passed to custom fields
111
- * @group Form custom fields
112
- */
113
- export interface FormContext<M extends Record<string, any> = any> {
114
- /**
115
- * Current values of the entity
116
- */
117
- values: M;
118
- /**
119
- * Update the value of a field
120
- * @param key
121
- * @param value
122
- * @param shouldValidate
123
- */
124
- setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
125
- /**
126
- * Save the entity.
127
- */
128
- save: (values: M) => void;
129
- /**
130
- * Collection of the entity being modified
131
- */
132
- collection?: EntityCollection<M>;
133
- /**
134
- * Entity id, it can be undefined if it's a new entity
135
- */
136
- entityId?: string | number;
137
- /**
138
- * Path this entity is located at
139
- */
140
- path?: string;
141
- status: "new" | "existing" | "copy";
142
- entity?: Entity<M>;
143
- savingError?: Error;
144
- openEntityMode: "side_panel" | "full_screen";
145
- /**
146
- * This is the underlying formex controller that powers the form.
147
- * If you are in a red only mode, the formex controller is there, but you can't
148
- * operate with it
149
- */
150
- formex: FormexController<M>;
151
- disabled: boolean;
152
- }
153
- /**
154
- * In case you need to render a field bound to a Property inside your
155
- * custom field you can use {@link PropertyFieldBinding} with these props.
156
- * @group Form custom fields
157
- */
158
- export interface PropertyFieldBindingProps<M extends Record<string, any> = any> {
159
- /**
160
- * The key/path of the property, such as `age`. You can use nested and array
161
- * indexed such as `address.street` or `people[3]`
162
- */
163
- propertyKey: string;
164
- /**
165
- * The CMS property you are binding this field to
166
- */
167
- property: Property;
168
- /**
169
- * The context where this field is being rendered. You get a context as a
170
- * prop when creating a custom field.
171
- */
172
- context: FormContext<M>;
173
- /**
174
- * Should the description be included in this field
175
- */
176
- includeDescription?: boolean;
177
- /**
178
- * Has the value of this property been updated in the database while this
179
- * field is being edited
180
- */
181
- underlyingValueHasChanged?: boolean;
182
- /**
183
- * Is this field part of an array
184
- */
185
- partOfArray?: boolean;
186
- /**
187
- * Is this field part of a block
188
- */
189
- partOfBlock?: boolean;
190
- /**
191
- * Display the child properties directly, without being wrapped in an
192
- * extendable panel. Note that this will also hide the title of this property.
193
- */
194
- minimalistView?: boolean;
195
- /**
196
- * Should the field take focus when rendered. When opening the popup view
197
- * in table mode, it makes sense to put the focus on the only field rendered.
198
- */
199
- autoFocus?: boolean;
200
- /**
201
- * Should this field be disabled
202
- */
203
- disabled?: boolean;
204
- /**
205
- * Index of the field in the array.
206
- * Only used when the field is part of an array.
207
- */
208
- index?: number;
209
- /**
210
- * The size of the field
211
- */
212
- size?: "small" | "medium" | "large";
213
- /**
214
- * Some properties might change internal state (like expanding a panel).
215
- * This function should be called when the internal state changes.
216
- * This is used to preserve state in array containers.
217
- *
218
- * @param property
219
- */
220
- onPropertyChange?: (property: Partial<Property>) => void;
221
- }