@rebasepro/plugin-data-enhancement 0.2.3 → 0.3.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 (106) hide show
  1. package/dist/admin/src/collection_editor/ConfigControllerProvider.d.ts +0 -5
  2. package/dist/admin/src/collection_editor/index.d.ts +0 -1
  3. package/dist/admin/src/collection_editor/types/collection_editor_controller.d.ts +0 -2
  4. package/dist/admin/src/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +3 -3
  5. package/dist/admin/src/components/ArrayContainer.d.ts +2 -2
  6. package/dist/admin/src/components/DefaultAppBar.d.ts +18 -1
  7. package/dist/admin/src/components/DefaultDrawer.d.ts +51 -3
  8. package/dist/admin/src/components/EntityCollectionTable/fields/TableStorageUpload.d.ts +2 -2
  9. package/dist/admin/src/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
  10. package/dist/admin/src/components/EntityCollectionTable/table_bindings.d.ts +4 -3
  11. package/dist/admin/src/components/EntityCollectionView/hooks/useKanbanDragAndDrop.d.ts +4 -3
  12. package/dist/admin/src/components/EntityEditView.d.ts +2 -1
  13. package/dist/admin/src/components/HomePage/HomePageDnD.d.ts +3 -3
  14. package/dist/admin/src/components/PropertyCollectionView.d.ts +1 -1
  15. package/dist/admin/src/components/PropertyIdCopyTooltip.d.ts +1 -1
  16. package/dist/admin/src/components/SelectableTable/SelectionStore.d.ts +4 -1
  17. package/dist/admin/src/components/SelectableTable/filters/BooleanFilterField.d.ts +2 -2
  18. package/dist/admin/src/components/SelectableTable/filters/DateTimeFilterField.d.ts +2 -2
  19. package/dist/admin/src/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -2
  20. package/dist/admin/src/components/SelectableTable/filters/StringNumberFilterField.d.ts +2 -2
  21. package/dist/admin/src/components/admin/RolesView.d.ts +3 -3
  22. package/dist/admin/src/components/app/Drawer.d.ts +8 -1
  23. package/dist/admin/src/data_export/export/export.d.ts +3 -3
  24. package/dist/admin/src/editor/components/editor-bubble.d.ts +5 -1
  25. package/dist/admin/src/editor/components/image-bubble.d.ts +5 -1
  26. package/dist/admin/src/editor/components/index.d.ts +3 -3
  27. package/dist/admin/src/editor/components/table-bubble.d.ts +5 -1
  28. package/dist/admin/src/editor/nodeViews/ReactNodeView.d.ts +4 -1
  29. package/dist/admin/src/editor/utils/remove_classes.d.ts +1 -1
  30. package/dist/admin/src/form/EntityForm.d.ts +2 -2
  31. package/dist/admin/src/form/components/StorageUploadProgress.d.ts +2 -2
  32. package/dist/admin/src/form/field_bindings/MultiSelectFieldBinding.d.ts +1 -1
  33. package/dist/admin/src/form/field_bindings/StorageUploadFieldBinding.d.ts +1 -1
  34. package/dist/admin/src/form/validation.d.ts +3 -3
  35. package/dist/admin/src/hooks/navigation/useResolvedCollections.d.ts +6 -0
  36. package/dist/admin/src/hooks/navigation/useResolvedViews.d.ts +3 -4
  37. package/dist/admin/src/index.d.ts +1 -1
  38. package/dist/admin/src/preview/components/UrlComponentPreview.d.ts +1 -0
  39. package/dist/admin/src/types/components/EntityFormActionsProps.d.ts +1 -1
  40. package/dist/admin/src/types/components/EntityFormProps.d.ts +2 -2
  41. package/dist/admin/src/types/fields.d.ts +1 -1
  42. package/dist/common/src/collections/default-collections.d.ts +12 -0
  43. package/dist/common/src/collections/index.d.ts +1 -0
  44. package/dist/common/src/util/permissions.d.ts +1 -0
  45. package/dist/core/src/components/LoginView/LoginView.d.ts +17 -1
  46. package/dist/core/src/components/common/types.d.ts +10 -7
  47. package/dist/core/src/components/common/useDebouncedData.d.ts +1 -1
  48. package/dist/core/src/core/RebaseProps.d.ts +13 -2
  49. package/dist/core/src/core/RebaseRouter.d.ts +1 -1
  50. package/dist/core/src/hooks/index.d.ts +0 -1
  51. package/dist/core/src/util/entity_cache.d.ts +0 -5
  52. package/dist/core/src/util/index.d.ts +0 -2
  53. package/dist/core/src/util/useStorageUploadController.d.ts +2 -2
  54. package/dist/formex/src/utils.d.ts +2 -2
  55. package/dist/index.es.js +7 -4
  56. package/dist/index.es.js.map +1 -1
  57. package/dist/index.umd.js +7 -4
  58. package/dist/index.umd.js.map +1 -1
  59. package/dist/plugin-data-enhancement/src/api.d.ts +2 -2
  60. package/dist/plugin-data-enhancement/src/components/DataEnhancementControllerProvider.d.ts +1 -1
  61. package/dist/plugin-data-enhancement/src/index.d.ts +0 -1
  62. package/dist/plugin-data-enhancement/src/utils/suggestions.d.ts +1 -1
  63. package/dist/types/src/controllers/auth.d.ts +2 -24
  64. package/dist/types/src/controllers/client.d.ts +0 -3
  65. package/dist/types/src/controllers/collection_registry.d.ts +1 -1
  66. package/dist/types/src/controllers/data_driver.d.ts +18 -0
  67. package/dist/types/src/controllers/registry.d.ts +5 -4
  68. package/dist/types/src/rebase_context.d.ts +1 -1
  69. package/dist/types/src/types/auth_adapter.d.ts +2 -4
  70. package/dist/types/src/types/collections.d.ts +0 -4
  71. package/dist/types/src/types/component_ref.d.ts +1 -1
  72. package/dist/types/src/types/cron.d.ts +1 -1
  73. package/dist/types/src/types/entity_views.d.ts +1 -0
  74. package/dist/types/src/types/export_import.d.ts +1 -1
  75. package/dist/types/src/types/formex.d.ts +2 -2
  76. package/dist/types/src/types/properties.d.ts +2 -2
  77. package/dist/types/src/types/translations.d.ts +28 -12
  78. package/dist/types/src/types/user_management_delegate.d.ts +6 -4
  79. package/dist/types/src/users/roles.d.ts +0 -8
  80. package/dist/ui/src/components/Button.d.ts +2 -2
  81. package/dist/ui/src/components/ErrorBoundary.d.ts +25 -3
  82. package/dist/ui/src/components/VirtualTable/VirtualTable.d.ts +1 -1
  83. package/dist/ui/src/components/VirtualTable/VirtualTableCell.d.ts +6 -6
  84. package/dist/ui/src/components/VirtualTable/VirtualTableHeader.d.ts +8 -8
  85. package/dist/ui/src/components/VirtualTable/VirtualTableHeaderRow.d.ts +1 -1
  86. package/dist/ui/src/components/VirtualTable/VirtualTableProps.d.ts +11 -11
  87. package/dist/ui/src/components/VirtualTable/VirtualTableRow.d.ts +1 -1
  88. package/dist/ui/src/components/VirtualTable/types.d.ts +9 -9
  89. package/dist/ui/src/hooks/useDebounceCallback.d.ts +1 -1
  90. package/dist/ui/src/util/debounce.d.ts +1 -1
  91. package/package.json +7 -7
  92. package/src/api.ts +4 -4
  93. package/src/components/DataEnhancementControllerProvider.tsx +10 -7
  94. package/src/index.ts +0 -1
  95. package/src/tests/strings_counter.test.ts +101 -0
  96. package/src/tests/suggestions.test.ts +53 -0
  97. package/src/tests/values.test.ts +83 -0
  98. package/src/utils/properties.ts +3 -3
  99. package/src/utils/suggestions.ts +1 -1
  100. package/dist/admin/src/collection_editor/types/config_permissions.d.ts +0 -19
  101. package/dist/admin/src/components/admin/UsersView.d.ts +0 -4
  102. package/dist/core/src/hooks/useValidateAuthenticator.d.ts +0 -21
  103. package/dist/core/src/util/icon_synonyms.d.ts +0 -1
  104. package/dist/core/src/util/useTraceUpdate.d.ts +0 -2
  105. package/dist/plugin-data-enhancement/src/types/subscriptions_message_props.d.ts +0 -3
  106. package/src/types/subscriptions_message_props.tsx +0 -1
@@ -1,5 +1,5 @@
1
1
  import React, { FormEvent } from "react";
2
- export type FormexController<T = any> = {
2
+ export type FormexController<T = unknown> = {
3
3
  values: T;
4
4
  initialValues: T;
5
5
  setValues: (values: T) => void;
@@ -32,7 +32,7 @@ export type FormexController<T = any> = {
32
32
  canUndo: boolean;
33
33
  canRedo: boolean;
34
34
  };
35
- export type FormexResetProps<T = any> = {
35
+ export type FormexResetProps<T = unknown> = {
36
36
  values?: T;
37
37
  submitCount?: number;
38
38
  errors?: Record<string, string>;
@@ -104,8 +104,8 @@ export interface BaseUIConfig<CustomProps = unknown> {
104
104
  disabled?: boolean | PropertyDisabledConfig;
105
105
  widthPercentage?: number;
106
106
  customProps?: CustomProps;
107
- Field?: ComponentRef<any>;
108
- Preview?: ComponentRef<any>;
107
+ Field?: ComponentRef;
108
+ Preview?: ComponentRef;
109
109
  }
110
110
  export interface BaseProperty<CustomProps = unknown> {
111
111
  ui?: BaseUIConfig<CustomProps>;
@@ -105,6 +105,12 @@ export interface RebaseTranslations {
105
105
  navigation_drawer: string;
106
106
  collapse: string;
107
107
  expand: string;
108
+ /** Tooltip for the language switcher in the drawer footer */
109
+ change_language?: string;
110
+ /** Tooltip for the theme toggle in the drawer footer */
111
+ toggle_theme?: string;
112
+ /** Aria label for the user menu trigger in the drawer footer */
113
+ user_menu?: string;
108
114
  error: string;
109
115
  error_uploading_file: string;
110
116
  error_deleting: string;
@@ -426,18 +432,28 @@ export interface RebaseTranslations {
426
432
  deleted: string;
427
433
  select_reference: string;
428
434
  select_references: string;
429
- account_settings: string;
430
- profile: string;
431
- sessions: string;
432
- display_name: string;
433
- photo_url: string;
434
- save_profile: string;
435
- saving: string;
436
- no_active_sessions: string;
437
- revoking: string;
438
- revoke_all_sessions: string;
439
- unknown_device: string;
440
- current: string;
435
+ account_settings?: string;
436
+ profile?: string;
437
+ sessions?: string;
438
+ security?: string;
439
+ change_password?: string;
440
+ current_password?: string;
441
+ new_password?: string;
442
+ confirm_password?: string;
443
+ password_changed?: string;
444
+ passwords_dont_match?: string;
445
+ password_too_short?: string;
446
+ password_change_not_available?: string;
447
+ changing_password?: string;
448
+ display_name?: string;
449
+ photo_url?: string;
450
+ save_profile?: string;
451
+ saving?: string;
452
+ no_active_sessions?: string;
453
+ revoking?: string;
454
+ revoke_all_sessions?: string;
455
+ unknown_device?: string;
456
+ current?: string;
441
457
  role_id: string;
442
458
  role_name: string;
443
459
  add_reference: string;
@@ -104,15 +104,17 @@ export interface UserManagementDelegate<USER extends User = User> {
104
104
  * If true, the UI will allow the user to create the default roles (admin, editor, viewer).
105
105
  */
106
106
  allowDefaultRolesCreation?: boolean;
107
- /**
108
- * Should collection config permissions be included?
109
- */
110
- includeCollectionConfigPermissions?: boolean;
111
107
  /**
112
108
  * Optionally define roles for a given user. This is useful when the roles
113
109
  * are coming from a separate provider than the one issuing the tokens.
114
110
  */
115
111
  defineRolesFor?: (user: USER) => Promise<Role[] | undefined> | Role[] | undefined;
112
+ /**
113
+ * Whether any admin users exist. Used by the bootstrap banner to decide
114
+ * whether to prompt. Populated via a lightweight check (e.g. `limit=1`
115
+ * query) instead of loading all users.
116
+ */
117
+ hasAdminUsers?: boolean;
116
118
  /**
117
119
  * Optional function to bootstrap an admin user.
118
120
  * Often used when the database is empty.
@@ -11,12 +11,4 @@ export type Role = {
11
11
  * If this flag is true, the user can perform any action
12
12
  */
13
13
  isAdmin?: boolean;
14
- /**
15
- * Permissions related to editing the collections
16
- */
17
- config?: {
18
- createCollections?: boolean;
19
- editCollections?: boolean | "own";
20
- deleteCollections?: boolean | "own";
21
- };
22
14
  };
@@ -9,6 +9,6 @@ export type ButtonProps<C extends React.ElementType = "button"> = {
9
9
  fullWidth?: boolean;
10
10
  className?: string;
11
11
  component?: C;
12
- onClick?: React.MouseEventHandler<any>;
12
+ onClick?: React.MouseEventHandler<HTMLElement>;
13
13
  } & React.ComponentPropsWithoutRef<C>;
14
- export declare const Button: React.FC<ButtonProps<any>>;
14
+ export declare const Button: React.FC<ButtonProps<React.ElementType>>;
@@ -1,11 +1,33 @@
1
1
  import React, { ErrorInfo, PropsWithChildren } from "react";
2
- export declare class ErrorBoundary extends React.Component<PropsWithChildren<Record<string, unknown>>, {
2
+ export interface ErrorBoundaryProps {
3
+ /**
4
+ * When true, renders a full-page centered error screen instead of the
5
+ * compact inline error. Intended for wrapping top-level app roots or
6
+ * major route sections.
7
+ */
8
+ fullPage?: boolean;
9
+ /**
10
+ * Optional callback invoked when the user clicks "Try again". If provided,
11
+ * the boundary resets its error state and calls this handler. If omitted,
12
+ * the "Try again" button resets the boundary state, re-mounting children.
13
+ */
14
+ onReset?: () => void;
15
+ }
16
+ interface ErrorBoundaryState {
3
17
  error: Error | null;
4
- }> {
5
- constructor(props: any);
18
+ showDetails: boolean;
19
+ }
20
+ export declare class ErrorBoundary extends React.Component<PropsWithChildren<ErrorBoundaryProps>, ErrorBoundaryState> {
21
+ constructor(props: PropsWithChildren<ErrorBoundaryProps>);
6
22
  static getDerivedStateFromError(error: Error): {
7
23
  error: Error;
8
24
  };
9
25
  componentDidCatch(error: Error, _errorInfo: ErrorInfo): void;
26
+ private handleReset;
27
+ private handleReload;
28
+ private toggleDetails;
10
29
  render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
30
+ private renderInline;
31
+ private renderFullPage;
11
32
  }
33
+ export {};
@@ -8,4 +8,4 @@ import { VirtualTableProps } from "./VirtualTableProps";
8
8
  *
9
9
  * @group Components
10
10
  */
11
- export declare const VirtualTable: React.NamedExoticComponent<VirtualTableProps<any>>;
11
+ export declare const VirtualTable: React.NamedExoticComponent<VirtualTableProps<Record<string, unknown>>>;
@@ -4,18 +4,18 @@ type VirtualTableCellProps<T> = {
4
4
  dataKey: string;
5
5
  column: VirtualTableColumn;
6
6
  columns: VirtualTableColumn[];
7
- rowData: any;
8
- cellData: any;
9
- rowIndex: any;
7
+ rowData: T;
8
+ cellData: unknown;
9
+ rowIndex: number;
10
10
  columnIndex: number;
11
11
  cellRenderer: (props: CellRendererParams<T>) => React.ReactNode;
12
12
  sortableNodeRef?: (node: HTMLElement | null) => void;
13
13
  sortableStyle?: React.CSSProperties;
14
- sortableAttributes?: Record<string, any>;
14
+ sortableAttributes?: Record<string, unknown>;
15
15
  isDragging?: boolean;
16
16
  isDraggable?: boolean;
17
17
  frozen?: boolean;
18
- extraData?: any;
18
+ extraData?: unknown;
19
19
  };
20
- export declare const VirtualTableCell: React.NamedExoticComponent<VirtualTableCellProps<any>>;
20
+ export declare const VirtualTableCell: React.NamedExoticComponent<VirtualTableCellProps<unknown>>;
21
21
  export {};
@@ -2,28 +2,28 @@ import React from "react";
2
2
  import { VirtualTableColumn, VirtualTableSort, VirtualTableWhereFilterOp } from "./VirtualTableProps";
3
3
  export type FilterFormFieldProps<CustomProps> = {
4
4
  id: React.Key;
5
- filterValue: [VirtualTableWhereFilterOp, any] | undefined;
6
- setFilterValue: (filterValue?: [VirtualTableWhereFilterOp, any]) => void;
5
+ filterValue: [VirtualTableWhereFilterOp, unknown] | undefined;
6
+ setFilterValue: (filterValue?: [VirtualTableWhereFilterOp, unknown]) => void;
7
7
  column: VirtualTableColumn<CustomProps>;
8
8
  hidden: boolean;
9
9
  setHidden: (hidden: boolean) => void;
10
10
  };
11
- type VirtualTableHeaderProps<M extends Record<string, any>> = {
11
+ type VirtualTableHeaderProps<M extends Record<string, unknown>> = {
12
12
  resizeHandleRef: React.Ref<HTMLDivElement>;
13
13
  columnIndex: number;
14
14
  isResizingIndex: number;
15
- column: VirtualTableColumn<any>;
15
+ column: VirtualTableColumn<unknown>;
16
16
  onColumnSort: (key: Extract<keyof M, string>) => void;
17
- filter?: [VirtualTableWhereFilterOp, any];
17
+ filter?: [VirtualTableWhereFilterOp, unknown];
18
18
  sort: VirtualTableSort;
19
- onFilterUpdate: (column: VirtualTableColumn, filterForProperty?: [VirtualTableWhereFilterOp, any]) => void;
19
+ onFilterUpdate: (column: VirtualTableColumn, filterForProperty?: [VirtualTableWhereFilterOp, unknown]) => void;
20
20
  onClickResizeColumn?: (columnIndex: number, column: VirtualTableColumn) => void;
21
- createFilterField?: (props: FilterFormFieldProps<any>) => React.ReactNode;
21
+ createFilterField?: (props: FilterFormFieldProps<unknown>) => React.ReactNode;
22
22
  AdditionalHeaderWidget?: (props: {
23
23
  onHover: boolean;
24
24
  }) => React.ReactNode;
25
25
  isDragging?: boolean;
26
26
  isDraggable?: boolean;
27
27
  };
28
- export declare const VirtualTableHeader: React.FunctionComponent<VirtualTableHeaderProps<any>>;
28
+ export declare const VirtualTableHeader: React.FunctionComponent<VirtualTableHeaderProps<Record<string, unknown>>>;
29
29
  export {};
@@ -1,2 +1,2 @@
1
1
  import { VirtualTableContextProps } from "./types";
2
- export declare const VirtualTableHeaderRow: ({ columns, currentSort, onColumnSort, onFilterUpdate, sortByProperty, filter, onColumnResize, onColumnResizeEnd, createFilterField, AddColumnComponent, onColumnsOrderChange, data, cellRenderer: CellRenderer, rowHeight, draggingColumnId, headerHeight }: VirtualTableContextProps<any>) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const VirtualTableHeaderRow: ({ columns, currentSort, onColumnSort, onFilterUpdate, sortByProperty, filter, onColumnResize, onColumnResizeEnd, createFilterField, AddColumnComponent, onColumnsOrderChange, data, cellRenderer: CellRenderer, rowHeight, draggingColumnId, headerHeight }: VirtualTableContextProps<Record<string, unknown>>) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { FilterFormFieldProps } from "./VirtualTableHeader";
3
- export type OnRowClickParams<T extends Record<string, any>> = {
3
+ export type OnRowClickParams<T extends Record<string, unknown>> = {
4
4
  rowData: T;
5
5
  rowIndex: number;
6
6
  event: React.SyntheticEvent;
@@ -9,7 +9,7 @@ export type OnRowClickParams<T extends Record<string, any>> = {
9
9
  * @see Table
10
10
  * @group Components
11
11
  */
12
- export interface VirtualTableProps<T extends Record<string, any>> {
12
+ export interface VirtualTableProps<T extends Record<string, unknown>> {
13
13
  /**
14
14
  * Array of arbitrary data
15
15
  */
@@ -61,12 +61,12 @@ export interface VirtualTableProps<T extends Record<string, any>> {
61
61
  /**
62
62
  * In case this table should have some filters set by default
63
63
  */
64
- filter?: VirtualTableFilterValues<any>;
64
+ filter?: VirtualTableFilterValues<string>;
65
65
  /**
66
66
  * Callback used when filters are updated
67
67
  * @param filter
68
68
  */
69
- onFilterUpdate?: (filter?: VirtualTableFilterValues<any> | undefined) => void;
69
+ onFilterUpdate?: (filter?: VirtualTableFilterValues<string> | undefined) => void;
70
70
  /**
71
71
  * Callback when the table is scrolled
72
72
  * @param props
@@ -111,7 +111,7 @@ export interface VirtualTableProps<T extends Record<string, any>> {
111
111
  * Callback to create a filter field, displayed in the header as a dropdown
112
112
  * @param props
113
113
  */
114
- createFilterField?: (props: FilterFormFieldProps<any>) => React.ReactNode;
114
+ createFilterField?: (props: FilterFormFieldProps<unknown>) => React.ReactNode;
115
115
  /**
116
116
  * Class name applied to the table
117
117
  */
@@ -141,9 +141,9 @@ export interface VirtualTableProps<T extends Record<string, any>> {
141
141
  /**
142
142
  * Extra data passed to the cell renderer
143
143
  */
144
- extraData?: any;
144
+ extraData?: unknown;
145
145
  }
146
- export type CellRendererParams<T = any> = {
146
+ export type CellRendererParams<T = unknown> = {
147
147
  column: VirtualTableColumn;
148
148
  columns: VirtualTableColumn[];
149
149
  columnIndex: number;
@@ -153,17 +153,17 @@ export type CellRendererParams<T = any> = {
153
153
  isScrolling?: boolean;
154
154
  sortableNodeRef?: (node: HTMLElement | null) => void;
155
155
  sortableStyle?: React.CSSProperties;
156
- sortableAttributes?: Record<string, any>;
156
+ sortableAttributes?: Record<string, unknown>;
157
157
  isDragging?: boolean;
158
158
  isDraggable?: boolean;
159
159
  frozen?: boolean;
160
- extraData?: any;
160
+ extraData?: unknown;
161
161
  };
162
162
  /**
163
163
  * @see Table
164
164
  * @group Components
165
165
  */
166
- export interface VirtualTableColumn<CustomProps = any> {
166
+ export interface VirtualTableColumn<CustomProps = unknown> {
167
167
  /**
168
168
  * Data key for the cell value, could be "a.b.c"
169
169
  */
@@ -233,7 +233,7 @@ export type VirtualTableSort = "asc" | "desc" | undefined;
233
233
  * @see Table
234
234
  * @group Components
235
235
  */
236
- export type VirtualTableFilterValues<Key extends string> = Partial<Record<Key, [VirtualTableWhereFilterOp, any]>>;
236
+ export type VirtualTableFilterValues<Key extends string> = Partial<Record<Key, [VirtualTableWhereFilterOp, unknown]>>;
237
237
  /**
238
238
  * Filter conditions in a `Query.where()` clause are specified using the
239
239
  * strings `<`, `<=`, `==`, `>=`, `>`, `array-contains`, `in`, and `array-contains-any`.
@@ -1,3 +1,3 @@
1
1
  import React from "react";
2
2
  import { VirtualTableRowProps } from "./types";
3
- export declare const VirtualTableRow: React.NamedExoticComponent<VirtualTableRowProps<any>>;
3
+ export declare const VirtualTableRow: React.NamedExoticComponent<VirtualTableRowProps<Record<string, unknown>>>;
@@ -1,12 +1,12 @@
1
1
  import React from "react";
2
2
  import { CellRendererParams, OnRowClickParams, OnVirtualTableColumnResizeParams, VirtualTableColumn, VirtualTableFilterValues, VirtualTableWhereFilterOp } from "./VirtualTableProps";
3
3
  import { FilterFormFieldProps } from "./VirtualTableHeader";
4
- export type VirtualTableRowProps<T> = {
5
- style: any;
4
+ export type VirtualTableRowProps<T extends Record<string, unknown>> = {
5
+ style: React.CSSProperties;
6
6
  rowHeight: number;
7
7
  rowData: T;
8
8
  rowIndex: number;
9
- onRowClick?: (props: OnRowClickParams<any>) => void;
9
+ onRowClick?: (props: OnRowClickParams<Record<string, unknown>>) => void;
10
10
  children: React.ReactNode[];
11
11
  columns: VirtualTableColumn[];
12
12
  hoverRow?: boolean;
@@ -19,20 +19,20 @@ export type VirtualTableContextProps<T> = {
19
19
  columns: VirtualTableColumn[];
20
20
  cellRenderer: React.ComponentType<CellRendererParams<T>>;
21
21
  currentSort: "asc" | "desc" | undefined;
22
- filter?: VirtualTableFilterValues<any>;
23
- onRowClick?: (props: OnRowClickParams<any>) => void;
24
- onColumnSort: (key: string) => any;
22
+ filter?: VirtualTableFilterValues<string>;
23
+ onRowClick?: (props: OnRowClickParams<Record<string, unknown>>) => void;
24
+ onColumnSort: (key: string) => void;
25
25
  onColumnResize: (params: OnVirtualTableColumnResizeParams) => void;
26
26
  onColumnResizeEnd: (params: OnVirtualTableColumnResizeParams) => void;
27
- onFilterUpdate: (column: VirtualTableColumn, filterForProperty?: [VirtualTableWhereFilterOp, any]) => void;
27
+ onFilterUpdate: (column: VirtualTableColumn, filterForProperty?: [VirtualTableWhereFilterOp, unknown]) => void;
28
28
  sortByProperty?: string;
29
29
  customView?: React.ReactNode;
30
30
  hoverRow: boolean;
31
- createFilterField?: (props: FilterFormFieldProps<any>) => React.ReactNode;
31
+ createFilterField?: (props: FilterFormFieldProps<unknown>) => React.ReactNode;
32
32
  rowClassName?: (rowData: T) => string | undefined;
33
33
  endAdornment?: React.ReactNode;
34
34
  AddColumnComponent?: React.ComponentType;
35
35
  onColumnsOrderChange?: (columns: VirtualTableColumn[]) => void;
36
36
  draggingColumnId?: string | null;
37
- extraData?: Record<string, any>;
37
+ extraData?: unknown;
38
38
  };
@@ -1 +1 @@
1
- export declare function useDebounceCallback<T extends (...args: any[]) => any>(callback?: T, delay?: number): T;
1
+ export declare function useDebounceCallback<T extends (...args: any[]) => unknown>(callback?: T, delay?: number): T;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @ignore
3
3
  */
4
- export declare function debounce<T extends (...args: any[]) => any>(func: T, wait?: number): T & Cancelable;
4
+ export declare function debounce<T extends (...args: any[]) => unknown>(func: T, wait?: number): T & Cancelable;
5
5
  /**
6
6
  * @ignore
7
7
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebasepro/plugin-data-enhancement",
3
3
  "type": "module",
4
- "version": "0.2.3",
4
+ "version": "0.3.0",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
7
7
  "types": "./dist/index.d.ts",
@@ -16,12 +16,12 @@
16
16
  "./package.json": "./package.json"
17
17
  },
18
18
  "dependencies": {
19
- "@rebasepro/admin": "0.2.3",
20
- "@rebasepro/common": "0.2.3",
21
- "@rebasepro/types": "0.2.3",
22
- "@rebasepro/ui": "0.2.3",
23
- "@rebasepro/core": "0.2.3",
24
- "@rebasepro/utils": "0.2.3"
19
+ "@rebasepro/admin": "0.3.0",
20
+ "@rebasepro/common": "0.3.0",
21
+ "@rebasepro/ui": "0.3.0",
22
+ "@rebasepro/utils": "0.3.0",
23
+ "@rebasepro/types": "0.3.0",
24
+ "@rebasepro/core": "0.3.0"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "react": ">=19.0.0",
package/src/api.ts CHANGED
@@ -25,8 +25,8 @@ export async function enhanceDataAPIStream<M extends Record<string, unknown>>(pr
25
25
 
26
26
  instructions?: string,
27
27
  firebaseToken: string,
28
- onUpdate: (suggestions: Record<string, any>) => void;
29
- onUpdateDelta: (propertyKey: string, partialValue: any) => void;
28
+ onUpdate: (suggestions: Record<string, string | number>) => void;
29
+ onUpdateDelta: (propertyKey: string, partialValue: string) => void;
30
30
  onError: (error: Error) => void;
31
31
  onEnd: (result: EnhancedDataResult) => void;
32
32
  host?: string;
@@ -89,10 +89,10 @@ export async function enhanceDataAPIStream<M extends Record<string, unknown>>(pr
89
89
  props.onEnd(data.data);
90
90
  }
91
91
  });
92
- } catch (e: any) {
92
+ } catch (e: unknown) {
93
93
  console.error("str", str);
94
94
  console.error("Error parsing stream", e);
95
- props.onError(e);
95
+ props.onError(e instanceof Error ? e : new Error(String(e)));
96
96
  }
97
97
  }
98
98
 
@@ -58,7 +58,7 @@ export function DataEnhancementControllerProvider({
58
58
  path,
59
59
  collection,
60
60
  formContext
61
- }: PropsWithChildren<DataEnhancementControllerProviderProps & PluginFormActionProps<any>>) {
61
+ }: PropsWithChildren<DataEnhancementControllerProviderProps & PluginFormActionProps>) {
62
62
 
63
63
  const [enabled, setEnabled] = useState(false);
64
64
  const [suggestions, setSuggestions] = useState<Record<string, string | number>>({});
@@ -193,7 +193,7 @@ export function DataEnhancementControllerProvider({
193
193
  }));
194
194
  }, [properties, formContext]);
195
195
 
196
- const displayNeededSubscriptionSnackbar = useCallback((projectId: any) => {
196
+ const displayNeededSubscriptionSnackbar = useCallback((projectId: unknown) => {
197
197
  snackbarController.open({
198
198
  type: "warning",
199
199
  message: "A valid subscription is needed in order to use this function.",
@@ -207,7 +207,7 @@ export function DataEnhancementControllerProvider({
207
207
  setSuggestions({});
208
208
  }, []);
209
209
 
210
- const enhance = useCallback(async (props: EnhanceParams<any>): Promise<EnhancedDataResult | null> => {
210
+ const enhance = useCallback(async (props: EnhanceParams<Record<string, unknown>>): Promise<EnhancedDataResult | null> => {
211
211
 
212
212
  if (!authController.user) {
213
213
  snackbarController.open({
@@ -232,10 +232,13 @@ export function DataEnhancementControllerProvider({
232
232
  const currentValues = valuesRef.current ?? {};
233
233
 
234
234
  return new Promise((resolve, reject) => {
235
- function onError(e: any) {
235
+ function onError(e: unknown) {
236
236
  setLoadingSuggestions([]);
237
- if (e.code === "payment-required") {
238
- const projectId = e.data.projectId;
237
+ const err = e instanceof Error ? e : typeof e === "object" && e !== null ? e : new Error(String(e));
238
+ const errorObj = err as Record<string, unknown>;
239
+ if (errorObj.code === "payment-required") {
240
+ const data = errorObj.data as Record<string, unknown> | undefined;
241
+ const projectId = data?.projectId;
239
242
  displayNeededSubscriptionSnackbar(projectId);
240
243
  } else {
241
244
  console.error("Enhance error", e);
@@ -286,7 +289,7 @@ export function DataEnhancementControllerProvider({
286
289
  enhancingInProgress.current = false;
287
290
  }
288
291
  }).catch(onError);
289
- } catch (e: any) {
292
+ } catch (e: unknown) {
290
293
  onError(e);
291
294
  }
292
295
  });
package/src/index.ts CHANGED
@@ -5,6 +5,5 @@ export type {
5
5
  DataEnhancementPluginProps
6
6
  } from "./useDataEnhancementPlugin";
7
7
 
8
- export type { SubscriptionMessageProps } from "./types/subscriptions_message_props";
9
8
 
10
9
  export * from "./editor/useEditorAIController";
@@ -0,0 +1,101 @@
1
+ import { countStringCharacters } from "../utils/strings_counter";
2
+ import type { Properties } from "@rebasepro/types";
3
+
4
+ describe("countStringCharacters", () => {
5
+ it("counts characters in a string property", () => {
6
+ const values = { title: "Hello World" };
7
+ const properties: Properties = {
8
+ title: { name: "title", type: "string" }
9
+ };
10
+ expect(countStringCharacters(values, properties)).toBe(11);
11
+ });
12
+
13
+ it("counts characters in a number property (stringified)", () => {
14
+ const values = { price: 12345 };
15
+ const properties: Properties = {
16
+ price: { name: "price", type: "number" }
17
+ };
18
+ expect(countStringCharacters(values, properties)).toBe(5);
19
+ });
20
+
21
+ it("skips disabled properties", () => {
22
+ const values = { title: "Hello", hidden: "Secret" };
23
+ const properties: Properties = {
24
+ title: { name: "title", type: "string" },
25
+ hidden: { name: "hidden", type: "string", ui: { disabled: true } }
26
+ };
27
+ expect(countStringCharacters(values, properties)).toBe(5);
28
+ });
29
+
30
+ it("counts array of strings", () => {
31
+ const values = { tags: ["hello", "world", "test"] };
32
+ const properties: Properties = {
33
+ tags: {
34
+ name: "tags",
35
+ type: "array",
36
+ of: { name: "tag", type: "string" }
37
+ }
38
+ };
39
+ // "hello" (5) + "world" (5) + "test" (4) = 14
40
+ expect(countStringCharacters(values, properties)).toBe(14);
41
+ });
42
+
43
+ it("recurses into map properties", () => {
44
+ const values = {
45
+ address: { city: "New York", country: "USA" }
46
+ };
47
+ const properties: Properties = {
48
+ address: {
49
+ name: "address",
50
+ type: "map",
51
+ properties: {
52
+ city: { name: "city", type: "string" },
53
+ country: { name: "country", type: "string" }
54
+ }
55
+ }
56
+ };
57
+ // "New York" (8) + "USA" (3) = 11
58
+ expect(countStringCharacters(values, properties)).toBe(11);
59
+ });
60
+
61
+ it("returns 0 for empty values", () => {
62
+ const properties: Properties = {
63
+ title: { name: "title", type: "string" }
64
+ };
65
+ expect(countStringCharacters({}, properties)).toBe(0);
66
+ });
67
+
68
+ it("handles mixed property types", () => {
69
+ const values = {
70
+ title: "Hello",
71
+ count: 42,
72
+ active: true,
73
+ tags: ["a", "bb"]
74
+ };
75
+ const properties: Properties = {
76
+ title: { name: "title", type: "string" },
77
+ count: { name: "count", type: "number" },
78
+ active: { name: "active", type: "boolean" },
79
+ tags: {
80
+ name: "tags",
81
+ type: "array",
82
+ of: { name: "tag", type: "string" }
83
+ }
84
+ };
85
+ // "Hello" (5) + "42" (2) + "a" (1) + "bb" (2) = 10
86
+ expect(countStringCharacters(values, properties)).toBe(10);
87
+ });
88
+
89
+ it("handles null values in array gracefully", () => {
90
+ const values = { tags: [null, "hello", null] };
91
+ const properties: Properties = {
92
+ tags: {
93
+ name: "tags",
94
+ type: "array",
95
+ of: { name: "tag", type: "string" }
96
+ }
97
+ };
98
+ // null?.length = 0, "hello" = 5, null?.length = 0
99
+ expect(countStringCharacters(values, properties)).toBe(5);
100
+ });
101
+ });