@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.
- package/dist/admin/src/collection_editor/ConfigControllerProvider.d.ts +0 -5
- package/dist/admin/src/collection_editor/index.d.ts +0 -1
- package/dist/admin/src/collection_editor/types/collection_editor_controller.d.ts +0 -2
- package/dist/admin/src/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +3 -3
- package/dist/admin/src/components/ArrayContainer.d.ts +2 -2
- package/dist/admin/src/components/DefaultAppBar.d.ts +18 -1
- package/dist/admin/src/components/DefaultDrawer.d.ts +51 -3
- package/dist/admin/src/components/EntityCollectionTable/fields/TableStorageUpload.d.ts +2 -2
- package/dist/admin/src/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
- package/dist/admin/src/components/EntityCollectionTable/table_bindings.d.ts +4 -3
- package/dist/admin/src/components/EntityCollectionView/hooks/useKanbanDragAndDrop.d.ts +4 -3
- package/dist/admin/src/components/EntityEditView.d.ts +2 -1
- package/dist/admin/src/components/HomePage/HomePageDnD.d.ts +3 -3
- package/dist/admin/src/components/PropertyCollectionView.d.ts +1 -1
- package/dist/admin/src/components/PropertyIdCopyTooltip.d.ts +1 -1
- package/dist/admin/src/components/SelectableTable/SelectionStore.d.ts +4 -1
- package/dist/admin/src/components/SelectableTable/filters/BooleanFilterField.d.ts +2 -2
- package/dist/admin/src/components/SelectableTable/filters/DateTimeFilterField.d.ts +2 -2
- package/dist/admin/src/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -2
- package/dist/admin/src/components/SelectableTable/filters/StringNumberFilterField.d.ts +2 -2
- package/dist/admin/src/components/admin/RolesView.d.ts +3 -3
- package/dist/admin/src/components/app/Drawer.d.ts +8 -1
- package/dist/admin/src/data_export/export/export.d.ts +3 -3
- package/dist/admin/src/editor/components/editor-bubble.d.ts +5 -1
- package/dist/admin/src/editor/components/image-bubble.d.ts +5 -1
- package/dist/admin/src/editor/components/index.d.ts +3 -3
- package/dist/admin/src/editor/components/table-bubble.d.ts +5 -1
- package/dist/admin/src/editor/nodeViews/ReactNodeView.d.ts +4 -1
- package/dist/admin/src/editor/utils/remove_classes.d.ts +1 -1
- package/dist/admin/src/form/EntityForm.d.ts +2 -2
- package/dist/admin/src/form/components/StorageUploadProgress.d.ts +2 -2
- package/dist/admin/src/form/field_bindings/MultiSelectFieldBinding.d.ts +1 -1
- package/dist/admin/src/form/field_bindings/StorageUploadFieldBinding.d.ts +1 -1
- package/dist/admin/src/form/validation.d.ts +3 -3
- package/dist/admin/src/hooks/navigation/useResolvedCollections.d.ts +6 -0
- package/dist/admin/src/hooks/navigation/useResolvedViews.d.ts +3 -4
- package/dist/admin/src/index.d.ts +1 -1
- package/dist/admin/src/preview/components/UrlComponentPreview.d.ts +1 -0
- package/dist/admin/src/types/components/EntityFormActionsProps.d.ts +1 -1
- package/dist/admin/src/types/components/EntityFormProps.d.ts +2 -2
- package/dist/admin/src/types/fields.d.ts +1 -1
- package/dist/common/src/collections/default-collections.d.ts +12 -0
- package/dist/common/src/collections/index.d.ts +1 -0
- package/dist/common/src/util/permissions.d.ts +1 -0
- package/dist/core/src/components/LoginView/LoginView.d.ts +17 -1
- package/dist/core/src/components/common/types.d.ts +10 -7
- package/dist/core/src/components/common/useDebouncedData.d.ts +1 -1
- package/dist/core/src/core/RebaseProps.d.ts +13 -2
- package/dist/core/src/core/RebaseRouter.d.ts +1 -1
- package/dist/core/src/hooks/index.d.ts +0 -1
- package/dist/core/src/util/entity_cache.d.ts +0 -5
- package/dist/core/src/util/index.d.ts +0 -2
- package/dist/core/src/util/useStorageUploadController.d.ts +2 -2
- package/dist/formex/src/utils.d.ts +2 -2
- package/dist/index.es.js +7 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +7 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/plugin-data-enhancement/src/api.d.ts +2 -2
- package/dist/plugin-data-enhancement/src/components/DataEnhancementControllerProvider.d.ts +1 -1
- package/dist/plugin-data-enhancement/src/index.d.ts +0 -1
- package/dist/plugin-data-enhancement/src/utils/suggestions.d.ts +1 -1
- package/dist/types/src/controllers/auth.d.ts +2 -24
- package/dist/types/src/controllers/client.d.ts +0 -3
- package/dist/types/src/controllers/collection_registry.d.ts +1 -1
- package/dist/types/src/controllers/data_driver.d.ts +18 -0
- package/dist/types/src/controllers/registry.d.ts +5 -4
- package/dist/types/src/rebase_context.d.ts +1 -1
- package/dist/types/src/types/auth_adapter.d.ts +2 -4
- package/dist/types/src/types/collections.d.ts +0 -4
- package/dist/types/src/types/component_ref.d.ts +1 -1
- package/dist/types/src/types/cron.d.ts +1 -1
- package/dist/types/src/types/entity_views.d.ts +1 -0
- package/dist/types/src/types/export_import.d.ts +1 -1
- package/dist/types/src/types/formex.d.ts +2 -2
- package/dist/types/src/types/properties.d.ts +2 -2
- package/dist/types/src/types/translations.d.ts +28 -12
- package/dist/types/src/types/user_management_delegate.d.ts +6 -4
- package/dist/types/src/users/roles.d.ts +0 -8
- package/dist/ui/src/components/Button.d.ts +2 -2
- package/dist/ui/src/components/ErrorBoundary.d.ts +25 -3
- package/dist/ui/src/components/VirtualTable/VirtualTable.d.ts +1 -1
- package/dist/ui/src/components/VirtualTable/VirtualTableCell.d.ts +6 -6
- package/dist/ui/src/components/VirtualTable/VirtualTableHeader.d.ts +8 -8
- package/dist/ui/src/components/VirtualTable/VirtualTableHeaderRow.d.ts +1 -1
- package/dist/ui/src/components/VirtualTable/VirtualTableProps.d.ts +11 -11
- package/dist/ui/src/components/VirtualTable/VirtualTableRow.d.ts +1 -1
- package/dist/ui/src/components/VirtualTable/types.d.ts +9 -9
- package/dist/ui/src/hooks/useDebounceCallback.d.ts +1 -1
- package/dist/ui/src/util/debounce.d.ts +1 -1
- package/package.json +7 -7
- package/src/api.ts +4 -4
- package/src/components/DataEnhancementControllerProvider.tsx +10 -7
- package/src/index.ts +0 -1
- package/src/tests/strings_counter.test.ts +101 -0
- package/src/tests/suggestions.test.ts +53 -0
- package/src/tests/values.test.ts +83 -0
- package/src/utils/properties.ts +3 -3
- package/src/utils/suggestions.ts +1 -1
- package/dist/admin/src/collection_editor/types/config_permissions.d.ts +0 -19
- package/dist/admin/src/components/admin/UsersView.d.ts +0 -4
- package/dist/core/src/hooks/useValidateAuthenticator.d.ts +0 -21
- package/dist/core/src/util/icon_synonyms.d.ts +0 -1
- package/dist/core/src/util/useTraceUpdate.d.ts +0 -2
- package/dist/plugin-data-enhancement/src/types/subscriptions_message_props.d.ts +0 -3
- package/src/types/subscriptions_message_props.tsx +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getAppendableSuggestion } from "../utils/suggestions";
|
|
2
|
+
|
|
3
|
+
describe("getAppendableSuggestion", () => {
|
|
4
|
+
it("returns the remaining part when suggestion starts with value", () => {
|
|
5
|
+
const result = getAppendableSuggestion("Hello World", "Hello");
|
|
6
|
+
expect(result).toBe(" World");
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("returns undefined when suggestion does not start with value", () => {
|
|
10
|
+
const result = getAppendableSuggestion("Goodbye World", "Hello");
|
|
11
|
+
expect(result).toBeUndefined();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("performs case-insensitive matching", () => {
|
|
15
|
+
const result = getAppendableSuggestion("Hello World", "hello");
|
|
16
|
+
expect(result).toBe(" World");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("returns undefined for number suggestion", () => {
|
|
20
|
+
const result = getAppendableSuggestion(42, "4");
|
|
21
|
+
expect(result).toBeUndefined();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("returns undefined for undefined suggestion", () => {
|
|
25
|
+
const result = getAppendableSuggestion(undefined, "hello");
|
|
26
|
+
expect(result).toBeUndefined();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("returns undefined for non-string value", () => {
|
|
30
|
+
const result = getAppendableSuggestion("Hello", 42);
|
|
31
|
+
expect(result).toBeUndefined();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("returns full suggestion when value is empty string", () => {
|
|
35
|
+
const result = getAppendableSuggestion("Hello World", "");
|
|
36
|
+
expect(result).toBe("Hello World");
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("handles whitespace trimming", () => {
|
|
40
|
+
const result = getAppendableSuggestion("Hello World", "Hello");
|
|
41
|
+
expect(result).toBe(" World");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("returns empty string when suggestion equals value", () => {
|
|
45
|
+
const result = getAppendableSuggestion("Hello", "Hello");
|
|
46
|
+
expect(result).toBe("");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("returns undefined when value is longer than suggestion", () => {
|
|
50
|
+
const result = getAppendableSuggestion("Hi", "Hello World");
|
|
51
|
+
expect(result).toBeUndefined();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { flatMapEntityValues } from "../utils/values";
|
|
2
|
+
|
|
3
|
+
describe("flatMapEntityValues", () => {
|
|
4
|
+
it("returns flat object unchanged", () => {
|
|
5
|
+
const values = { name: "John", age: 30 };
|
|
6
|
+
const result = flatMapEntityValues(values);
|
|
7
|
+
expect(result).toEqual({ name: "John", age: 30 });
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("flattens nested object to dot-notation keys", () => {
|
|
11
|
+
const values = {
|
|
12
|
+
address: { city: "NYC", zip: "10001" }
|
|
13
|
+
};
|
|
14
|
+
const result = flatMapEntityValues(values);
|
|
15
|
+
expect(result).toEqual({
|
|
16
|
+
"address.city": "NYC",
|
|
17
|
+
"address.zip": "10001"
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("flattens deeply nested objects", () => {
|
|
22
|
+
const values = {
|
|
23
|
+
a: { b: { c: { d: "deep" } } }
|
|
24
|
+
};
|
|
25
|
+
const result = flatMapEntityValues(values);
|
|
26
|
+
expect(result).toEqual({ "a.b.c.d": "deep" });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("returns empty object for empty input", () => {
|
|
30
|
+
expect(flatMapEntityValues({})).toEqual({});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("returns empty object for null input", () => {
|
|
34
|
+
expect(flatMapEntityValues(null as unknown as object)).toEqual({});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("returns empty object for undefined input", () => {
|
|
38
|
+
expect(flatMapEntityValues(undefined as unknown as object)).toEqual({});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("handles mixed nested and flat values", () => {
|
|
42
|
+
const values = {
|
|
43
|
+
name: "John",
|
|
44
|
+
address: { city: "NYC" },
|
|
45
|
+
active: true
|
|
46
|
+
};
|
|
47
|
+
const result = flatMapEntityValues(values);
|
|
48
|
+
expect(result).toEqual({
|
|
49
|
+
name: "John",
|
|
50
|
+
"address.city": "NYC",
|
|
51
|
+
active: true
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("handles multiple nested objects", () => {
|
|
56
|
+
const values = {
|
|
57
|
+
home: { city: "NYC" },
|
|
58
|
+
work: { city: "SF" }
|
|
59
|
+
};
|
|
60
|
+
const result = flatMapEntityValues(values);
|
|
61
|
+
expect(result).toEqual({
|
|
62
|
+
"home.city": "NYC",
|
|
63
|
+
"work.city": "SF"
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("handles numeric values in nested objects", () => {
|
|
68
|
+
const values = {
|
|
69
|
+
stats: { visits: 100, clicks: 50 }
|
|
70
|
+
};
|
|
71
|
+
const result = flatMapEntityValues(values);
|
|
72
|
+
expect(result).toEqual({
|
|
73
|
+
"stats.visits": 100,
|
|
74
|
+
"stats.clicks": 50
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("uses custom path prefix", () => {
|
|
79
|
+
const values = { name: "John" };
|
|
80
|
+
const result = flatMapEntityValues(values, "user");
|
|
81
|
+
expect(result).toEqual({ "user.name": "John" });
|
|
82
|
+
});
|
|
83
|
+
});
|
package/src/utils/properties.ts
CHANGED
|
@@ -35,7 +35,7 @@ function getSimpleProperty(property: Property): InputProperty {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function getSimplifiedProperty(property: Property, path: string, value?:
|
|
38
|
+
function getSimplifiedProperty(property: Property, path: string, value?: unknown): Record<string, InputProperty> {
|
|
39
39
|
if (isPropertyBuilder(property)) return {};
|
|
40
40
|
if (property.type === "array") {
|
|
41
41
|
|
|
@@ -115,7 +115,7 @@ function getSimplifiedProperty(property: Property, path: string, value?: any): R
|
|
|
115
115
|
if (property.properties) {
|
|
116
116
|
const mapProperties: Record<string, InputProperty> = Object.entries(property.properties)
|
|
117
117
|
.map(([key, childProperty]) => {
|
|
118
|
-
const childValue = value
|
|
118
|
+
const childValue = value && typeof value === "object" ? (value as Record<string, unknown>)[key] : undefined;
|
|
119
119
|
return getSimplifiedProperty(childProperty, key, childValue);
|
|
120
120
|
})
|
|
121
121
|
.map(o => attachPathToKeys(o, path))
|
|
@@ -149,7 +149,7 @@ function getSimplifiedProperty(property: Property, path: string, value?: any): R
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
// attach a path to every key in an object
|
|
152
|
-
function attachPathToKeys(obj: Record<string,
|
|
152
|
+
function attachPathToKeys(obj: Record<string, InputProperty>, path = ""): Record<string, InputProperty> {
|
|
153
153
|
return Object.entries(obj)
|
|
154
154
|
.map(([key, value]) => {
|
|
155
155
|
const fullKey = path ? `${path}.${key}` : key;
|
package/src/utils/suggestions.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function getAppendableSuggestion(suggestion: string | number | undefined, value:
|
|
1
|
+
export function getAppendableSuggestion(suggestion: string | number | undefined, value: unknown): string | undefined {
|
|
2
2
|
const suggestionIncludesValue = typeof suggestion === "string" && typeof value === "string" && suggestion.toLowerCase().trim().startsWith(value.toLowerCase().trim());
|
|
3
3
|
return (typeof value === "string" && suggestionIncludesValue)
|
|
4
4
|
? suggestion.substring(suggestion.toLowerCase().trim().indexOf(value.toLowerCase().trim()) + value.trim().length)
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { EntityCollection } from "@rebasepro/types";
|
|
2
|
-
export type CollectionEditorPermissionsBuilder<USER = any, EC extends EntityCollection = EntityCollection> = (params: {
|
|
3
|
-
user: USER | null;
|
|
4
|
-
collection?: EC;
|
|
5
|
-
}) => CollectionEditorPermissions;
|
|
6
|
-
export type CollectionEditorPermissions = {
|
|
7
|
-
/**
|
|
8
|
-
* Is the user allowed to create new collections.
|
|
9
|
-
*/
|
|
10
|
-
createCollections: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Is the user allowed to modify this collection
|
|
13
|
-
*/
|
|
14
|
-
editCollections: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Is the user allowed to delete this collection
|
|
17
|
-
*/
|
|
18
|
-
deleteCollections: boolean;
|
|
19
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { AuthController, Authenticator, RebaseData, StorageSource, User } from "@rebasepro/types";
|
|
2
|
-
/**
|
|
3
|
-
* This hook is used internally for validating an authenticator.
|
|
4
|
-
*
|
|
5
|
-
* @param authController
|
|
6
|
-
* @param authentication
|
|
7
|
-
* @param storageSource
|
|
8
|
-
* @param data
|
|
9
|
-
*/
|
|
10
|
-
export declare function useValidateAuthenticator<USER extends User = any>({ disabled, authController, authenticator, storageSource, data }: {
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
authController: AuthController<USER>;
|
|
13
|
-
authenticator?: boolean | Authenticator<USER>;
|
|
14
|
-
data: RebaseData;
|
|
15
|
-
storageSource: StorageSource;
|
|
16
|
-
}): {
|
|
17
|
-
canAccessMainView: boolean;
|
|
18
|
-
authLoading: boolean;
|
|
19
|
-
notAllowedError: any;
|
|
20
|
-
authVerified: boolean;
|
|
21
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const iconSynonyms: Record<string, string>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type SubscriptionMessageProps = { projectId: string };
|