@rebasepro/plugin-data-enhancement 0.2.3 → 0.2.4

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,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { PreviewType } from "@rebasepro/types";
3
3
  import type { PreviewSize } from "../../types/components/PropertyPreviewProps";
4
+ export declare function sanitizeUrl(url: string | undefined): string;
4
5
  /**
5
6
  * @group Preview components
6
7
  */
@@ -8,7 +8,7 @@ export interface EntityFormActionsProps {
8
8
  entity?: Entity;
9
9
  layout: "bottom" | "side" | "responsive";
10
10
  savingError?: Error;
11
- formex: FormexController<any>;
11
+ formex: FormexController<Record<string, unknown>>;
12
12
  disabled: boolean;
13
13
  status: "new" | "existing" | "copy";
14
14
  pluginActions: React.ReactNode[];
@@ -40,10 +40,10 @@ export type EntityFormProps<M extends Record<string, unknown>> = {
40
40
  children?: React.ReactNode;
41
41
  };
42
42
  export type OnUpdateParams = {
43
- entity: Entity<any>;
43
+ entity: Entity<Record<string, unknown>>;
44
44
  status: EntityStatus;
45
45
  path: string;
46
46
  entityId?: string | number;
47
47
  selectedTab?: string;
48
- collection: EntityCollection<any>;
48
+ collection: EntityCollection<Record<string, unknown>>;
49
49
  };
@@ -9,7 +9,7 @@ export type DefaultFieldConfig = "text_field" | "multiline" | "markdown" | "url"
9
9
  *
10
10
  * @group Form custom fields
11
11
  */
12
- export interface FieldProps<P extends Property | Property = Property, CustomProps = any, M extends Record<string, any> = any> {
12
+ export interface FieldProps<P extends Property | Property = Property, CustomProps = unknown, M extends Record<string, unknown> = Record<string, unknown>> {
13
13
  /**
14
14
  * Key of the property
15
15
  * E.g. "user.name" for a property with path "user.name"
@@ -0,0 +1,12 @@
1
+ import { PostgresCollection } from "@rebasepro/types";
2
+ /**
3
+ * Default users collection definition.
4
+ *
5
+ * Shared between the admin UI (for navigation/display) and the backend
6
+ * (for schema generation). Both consumers prepend this to the developer's
7
+ * collections array and rely on generic slug-based deduplication
8
+ * (Map keyed by slug, last-write-wins) so that developer-defined
9
+ * collections with the same slug override this default — no hardcoded
10
+ * string checks required.
11
+ */
12
+ export declare const defaultUsersCollection: PostgresCollection;
@@ -1 +1,2 @@
1
1
  export * from "./CollectionRegistry";
2
+ export * from "./default-collections";
@@ -1,4 +1,5 @@
1
1
  import { AuthController, Entity, EntityCollection, User } from "@rebasepro/types";
2
+ export declare function checkOperation<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, entity: Entity<M> | null, targetOperation: "select" | "insert" | "update" | "delete"): boolean;
2
3
  export declare function canReadCollection<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>): boolean;
3
4
  export declare function canEditEntity<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, path: string, entity: Entity<M> | null): boolean;
4
5
  export declare function canCreateEntity<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, path: string, entity: Entity<M> | null): boolean;
@@ -66,6 +66,22 @@ export interface LoginViewProps {
66
66
  * Required when Google login is enabled via ID token flow.
67
67
  */
68
68
  googleClientId?: string;
69
+ /**
70
+ * GitHub client ID for GitHub OAuth.
71
+ */
72
+ githubClientId?: string;
73
+ /**
74
+ * LinkedIn client ID for LinkedIn OAuth.
75
+ */
76
+ linkedinClientId?: string;
77
+ /**
78
+ * Optional custom title shown above options
79
+ */
80
+ title?: string;
81
+ /**
82
+ * Optional custom subtitle shown above options
83
+ */
84
+ subtitle?: string;
69
85
  /**
70
86
  * When true, shows bootstrap/setup UI (first-user creation).
71
87
  * If not set, derived from `authController` if it exposes `needsSetup`.
@@ -82,4 +98,4 @@ export interface LoginViewProps {
82
98
  * Feature-detects capabilities to show/hide login methods.
83
99
  * @group Core
84
100
  */
85
- export declare function LoginView({ logo, authController, noUserComponent, disableSignupScreen, disabled, notAllowedError, googleClientId, needsSetup, registrationEnabled }: LoginViewProps): import("react/jsx-runtime").JSX.Element;
101
+ export declare function LoginView({ logo, authController, noUserComponent, disableSignupScreen, disabled, notAllowedError, googleClientId, githubClientId, linkedinClientId, title, subtitle, needsSetup, registrationEnabled, additionalComponent }: LoginViewProps): import("react/jsx-runtime").JSX.Element;
@@ -1,14 +1,17 @@
1
1
  import type { Property } from "@rebasepro/types";
2
2
  import { CollectionSize, SelectedCellProps } from "@rebasepro/types";
3
- export type EntityCollectionTableController<M extends Record<string, any>> = {
3
+ export type EntityCollectionTableController<M extends Record<string, unknown>> = {
4
4
  /**
5
5
  * This cell is displayed as selected
6
6
  */
7
- selectedCell?: SelectedCellProps<any>;
7
+ selectedCell?: SelectedCellProps;
8
8
  /**
9
9
  * Store used to sync selection state across cells efficiently.
10
10
  */
11
- selectionStore?: any;
11
+ selectionStore?: {
12
+ getSnapshot: () => SelectedCellProps | undefined;
13
+ subscribe: (cb: () => void) => () => void;
14
+ };
12
15
  /**
13
16
  * Select a table cell
14
17
  * @param cell
@@ -23,7 +26,7 @@ export type EntityCollectionTableController<M extends Record<string, any>> = {
23
26
  * Callback used when the value of a cell has changed.
24
27
  * @param params
25
28
  */
26
- onValueChange?: (params: OnCellValueChangeParams<any, M>) => void;
29
+ onValueChange?: (params: OnCellValueChangeParams<unknown, M>) => void;
27
30
  /**
28
31
  * Size of the elements in the collection
29
32
  */
@@ -33,7 +36,7 @@ export type EntityCollectionTableController<M extends Record<string, any>> = {
33
36
  * Props passed in a callback when the content of a cell in a table has been edited
34
37
  * @group Collection components
35
38
  */
36
- export interface OnCellValueChangeParams<T = any, D = any> {
39
+ export interface OnCellValueChangeParams<T = unknown, D = unknown> {
37
40
  value: T;
38
41
  propertyKey: string;
39
42
  data?: D;
@@ -45,7 +48,7 @@ export interface OnCellValueChangeParams<T = any, D = any> {
45
48
  */
46
49
  export type UniqueFieldValidator = (props: {
47
50
  name: string;
48
- value: any;
51
+ value: unknown;
49
52
  property: Property;
50
53
  entityId?: string | number;
51
54
  }) => Promise<boolean>;
@@ -53,7 +56,7 @@ export type UniqueFieldValidator = (props: {
53
56
  * Callback when a cell has changed in a table
54
57
  * @group Collection components
55
58
  */
56
- export type OnCellValueChange<T, M extends Record<string, any>> = (params: OnCellValueChangeParams<T, M>) => Promise<void> | void;
59
+ export type OnCellValueChange<T, M extends Record<string, unknown>> = (params: OnCellValueChangeParams<T, M>) => Promise<void> | void;
57
60
  /**
58
61
  * @group Collection components
59
62
  */
@@ -6,4 +6,4 @@
6
6
  * @param deps
7
7
  * @param timeoutMs
8
8
  */
9
- export declare function useDebouncedData<T>(data: T[], deps: any, timeoutMs?: number): T[];
9
+ export declare function useDebouncedData<T>(data: T[], deps: unknown, timeoutMs?: number): T[];
@@ -1,5 +1,9 @@
1
1
  import React from "react";
2
- import { Locale, User, AuthController, AnalyticsEvent, DataDriver, StorageSource, UserConfigurationPersistence, DatabaseAdmin, RebaseData, RebaseClient, RebaseContext, UserManagementDelegate, EntityLinkBuilder, RebasePlugin, SlotContribution, PropertyConfig, EntityCustomView, EntityAction } from "@rebasepro/types";
2
+ import { Locale, User, AuthController, AnalyticsEvent, DataDriver, StorageSource, UserConfigurationPersistence, DatabaseAdmin, RebaseData, RebaseClient, RebaseContext, UserManagementDelegate, EntityLinkBuilder, RebasePlugin, SlotContribution, PropertyConfig, EntityCustomView, EntityAction, RebaseTranslations } from "@rebasepro/types";
3
+ /** DeepPartial helper — allows partial overrides at any nesting level */
4
+ type DeepPartial<T> = T extends object ? {
5
+ [K in keyof T]?: DeepPartial<T[K]>;
6
+ } : T;
3
7
  /**
4
8
  * Controller to simulate different roles when dev mode is active.
5
9
  * @group Models
@@ -116,7 +120,7 @@ export type RebaseProps<USER extends User> = {
116
120
  /**
117
121
  * Entity Views
118
122
  */
119
- entityViews?: EntityCustomView<any>[];
123
+ entityViews?: EntityCustomView[];
120
124
  /**
121
125
  * Entity Actions
122
126
  */
@@ -133,4 +137,11 @@ export type RebaseProps<USER extends User> = {
133
137
  * Controller to simulate different roles when dev mode is active.
134
138
  */
135
139
  effectiveRoleController?: EffectiveRoleController;
140
+ /**
141
+ * Override or extend any Rebase UI string, keyed by locale.
142
+ */
143
+ translations?: {
144
+ [locale: string]: DeepPartial<RebaseTranslations>;
145
+ };
136
146
  };
147
+ export {};
@@ -1,4 +1,4 @@
1
1
  export declare function RebaseRouter({ children, basePath }: {
2
- children: any;
2
+ children: React.ReactNode;
3
3
  basePath?: string;
4
4
  }): import("react/jsx-runtime").JSX.Element;
@@ -26,7 +26,6 @@ export * from "./useSlot";
26
26
  export * from "./useCustomizationController";
27
27
  export * from "./useBuildLocalConfigurationPersistence";
28
28
  export * from "./useBuildModeController";
29
- export * from "./useValidateAuthenticator";
30
29
  export * from "./useRebaseRegistry";
31
30
  export * from "./useBackendStorageSource";
32
31
  export * from "./usePermissions";
@@ -7,7 +7,6 @@ export declare function saveEntityToCache(path: string, data: object): void;
7
7
  export declare function removeEntityFromMemoryCache(path: string): void;
8
8
  export declare function saveEntityToMemoryCache(path: string, data: object): void;
9
9
  export declare function getEntityFromMemoryCache(path: string): object | undefined;
10
- export declare function hasEntityInCache(path: string): boolean;
11
10
  /**
12
11
  * Retrieves an entity from the in-memory cache or `sessionStorage`.
13
12
  * If the entity is not in the cache but exists in `sessionStorage`, it loads it into the cache.
@@ -20,8 +19,4 @@ export declare function getEntityFromCache(path: string): object | undefined;
20
19
  * @param path - The unique path/key for the entity to remove.
21
20
  */
22
21
  export declare function removeEntityFromCache(path: string): void;
23
- /**
24
- * Clears the entire in-memory cache and removes all related entities from `sessionStorage`.
25
- */
26
- export declare function clearEntityCache(): void;
27
22
  export declare function flattenKeys(obj: Record<string, unknown> | unknown[], prefix?: string, result?: string[]): string[];
@@ -1,10 +1,8 @@
1
1
  export * from "./icon_list";
2
- export * from "./icon_synonyms";
3
2
  export * from "./icons";
4
3
  export * from "./createFormexStub";
5
4
  export * from "./entity_cache";
6
5
  export * from "./useStorageUploadController";
7
- export * from "./useTraceUpdate";
8
6
  export * from "./previews";
9
7
  export * from "./enums";
10
8
  export * from "./constants";
@@ -12,7 +12,7 @@ export interface StorageFieldItem {
12
12
  storagePathOrDownloadUrl?: string;
13
13
  file?: File;
14
14
  fileName?: string;
15
- metadata?: any;
15
+ metadata?: Record<string, unknown>;
16
16
  size: StorageFieldSize;
17
17
  }
18
18
  export declare function useStorageUploadController<M extends Record<string, unknown>>({ entityId, entityValues, path, value, property, propertyKey, storageSource, disabled, onChange }: {
@@ -31,7 +31,7 @@ export declare function useStorageUploadController<M extends Record<string, unkn
31
31
  storage: StorageConfig;
32
32
  fileNameBuilder: (file: File) => Promise<string>;
33
33
  storagePathBuilder: (file: File) => string;
34
- onFileUploadComplete: (uploadedPath: string, entry: StorageFieldItem, metadata?: any, uploadedUrl?: string) => Promise<void>;
34
+ onFileUploadComplete: (uploadedPath: string, entry: StorageFieldItem, metadata?: Record<string, unknown>, uploadedUrl?: string) => Promise<void>;
35
35
  onFileUploadError: (entry: StorageFieldItem) => void;
36
36
  onFilesAdded: (acceptedFiles: File[]) => Promise<void>;
37
37
  multipleFilesSupported: boolean;
@@ -11,6 +11,6 @@ export declare const isNaN: (obj: unknown) => boolean;
11
11
  /**
12
12
  * Deeply get a value from an object via its path.
13
13
  */
14
- export declare function getIn(obj: any, key: string | string[], def?: unknown, p?: number): any;
15
- export declare function setIn(obj: any, path: string, value: unknown): any;
14
+ export declare function getIn(obj: unknown, key: string | string[], def?: unknown, p?: number): unknown;
15
+ export declare function setIn(obj: unknown, path: string, value: unknown): unknown;
16
16
  export declare function clone(value: unknown): unknown;
package/dist/index.es.js CHANGED
@@ -73,7 +73,7 @@ async function enhanceDataAPIStream(props) {
73
73
  } catch (e) {
74
74
  console.error("str", str);
75
75
  console.error("Error parsing stream", e);
76
- props.onError(e);
76
+ props.onError(e instanceof Error ? e : new Error(String(e)));
77
77
  }
78
78
  }
79
79
  });
@@ -246,7 +246,7 @@ function getSimplifiedProperty(property, path, value) {
246
246
  } else if (property.type === "map") {
247
247
  if (property.properties) {
248
248
  const mapProperties = Object.entries(property.properties).map(([key, childProperty]) => {
249
- const childValue = value?.[key];
249
+ const childValue = value && typeof value === "object" ? value[key] : void 0;
250
250
  return getSimplifiedProperty(childProperty, key, childValue);
251
251
  }).map((o) => attachPathToKeys(o, path)).reduce((a, b) => ({
252
252
  ...a,
@@ -472,8 +472,11 @@ function DataEnhancementControllerProvider({
472
472
  return new Promise((resolve, reject) => {
473
473
  function onError(e) {
474
474
  setLoadingSuggestions([]);
475
- if (e.code === "payment-required") {
476
- const projectId_0 = e.data.projectId;
475
+ const err = e instanceof Error ? e : typeof e === "object" && e !== null ? e : new Error(String(e));
476
+ const errorObj = err;
477
+ if (errorObj.code === "payment-required") {
478
+ const data = errorObj.data;
479
+ const projectId_0 = data?.projectId;
477
480
  displayNeededSubscriptionSnackbar(projectId_0);
478
481
  } else {
479
482
  console.error("Enhance error", e);