@reltio/components 1.4.1928 → 1.4.1930
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/cjs/BasicTable/basicTableViewState.d.ts +63 -15
- package/cjs/BasicTable/basicTableViewState.js +38 -20
- package/cjs/BasicTable/basicTableViewState.test.js +20 -0
- package/cjs/contexts/ProfileTablesContext/index.d.ts +6 -0
- package/cjs/contexts/ProfileTablesContext/index.js +8 -0
- package/cjs/helpers/basicTable.d.ts +3 -1
- package/cjs/helpers/basicTable.js +12 -1
- package/cjs/hooks/useMarkers/helpers.d.ts +8 -0
- package/cjs/hooks/useMarkers/helpers.js +56 -0
- package/cjs/hooks/useMarkers/index.d.ts +2 -0
- package/cjs/hooks/useMarkers/index.js +7 -0
- package/cjs/hooks/useMarkers/nestedHelpers.d.ts +2 -0
- package/cjs/hooks/useMarkers/nestedHelpers.js +31 -0
- package/cjs/hooks/useMarkers/nestedHelpers.test.d.ts +1 -0
- package/cjs/hooks/useMarkers/nestedHelpers.test.js +235 -0
- package/cjs/hooks/useMarkers/referenceHelpers.d.ts +2 -0
- package/cjs/hooks/useMarkers/referenceHelpers.js +180 -0
- package/cjs/hooks/useMarkers/referenceHelpers.test.d.ts +1 -0
- package/cjs/hooks/useMarkers/referenceHelpers.test.js +490 -0
- package/cjs/hooks/useMarkers/resolveHelpers.d.ts +8 -0
- package/cjs/hooks/useMarkers/resolveHelpers.js +70 -0
- package/cjs/hooks/useMarkers/useMarkers.d.ts +5 -0
- package/cjs/hooks/useMarkers/useMarkers.js +30 -0
- package/cjs/hooks/useSavedState/useSavedState.d.ts +1 -1
- package/cjs/hooks/useSavedStateForEntityType/useSavedStateForEntityType.d.ts +1 -1
- package/cjs/index.d.ts +5 -2
- package/cjs/index.js +9 -2
- package/cjs/test-utils/index.js +1 -1
- package/cjs/types/basicTable.d.ts +5 -0
- package/cjs/types/preferences.d.ts +8 -0
- package/cjs/types/preferences.js +2 -0
- package/esm/BasicTable/basicTableViewState.d.ts +63 -15
- package/esm/BasicTable/basicTableViewState.js +37 -19
- package/esm/BasicTable/basicTableViewState.test.js +20 -0
- package/esm/contexts/ProfileTablesContext/index.d.ts +6 -0
- package/esm/contexts/ProfileTablesContext/index.js +5 -0
- package/esm/helpers/basicTable.d.ts +3 -1
- package/esm/helpers/basicTable.js +10 -0
- package/esm/hooks/useMarkers/helpers.d.ts +8 -0
- package/esm/hooks/useMarkers/helpers.js +49 -0
- package/esm/hooks/useMarkers/index.d.ts +2 -0
- package/esm/hooks/useMarkers/index.js +2 -0
- package/esm/hooks/useMarkers/nestedHelpers.d.ts +2 -0
- package/esm/hooks/useMarkers/nestedHelpers.js +27 -0
- package/esm/hooks/useMarkers/nestedHelpers.test.d.ts +1 -0
- package/esm/hooks/useMarkers/nestedHelpers.test.js +233 -0
- package/esm/hooks/useMarkers/referenceHelpers.d.ts +2 -0
- package/esm/hooks/useMarkers/referenceHelpers.js +176 -0
- package/esm/hooks/useMarkers/referenceHelpers.test.d.ts +1 -0
- package/esm/hooks/useMarkers/referenceHelpers.test.js +488 -0
- package/esm/hooks/useMarkers/resolveHelpers.d.ts +8 -0
- package/esm/hooks/useMarkers/resolveHelpers.js +66 -0
- package/esm/hooks/useMarkers/useMarkers.d.ts +5 -0
- package/esm/hooks/useMarkers/useMarkers.js +26 -0
- package/esm/hooks/useSavedState/useSavedState.d.ts +1 -1
- package/esm/hooks/useSavedStateForEntityType/useSavedStateForEntityType.d.ts +1 -1
- package/esm/index.d.ts +5 -2
- package/esm/index.js +4 -1
- package/esm/test-utils/index.js +1 -1
- package/esm/types/basicTable.d.ts +5 -0
- package/esm/types/preferences.d.ts +8 -0
- package/esm/types/preferences.js +1 -0
- package/package.json +15 -12
|
@@ -1,34 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { createStandardAction } from '@reltio/mdm-sdk';
|
|
2
|
+
import { ColumnData, ColumnFilter, ColumnSize, Sorting } from '../types/basicTable';
|
|
3
|
+
export declare enum ActionTypes {
|
|
4
|
+
CHANGE_COLUMNS = "CHANGE_COLUMNS",
|
|
5
|
+
TOGGLE_FILTERS = "TOGGLE_FILTERS",
|
|
6
|
+
CHANGE_FILTER = "CHANGE_FILTER",
|
|
7
|
+
TOGGLE_SORT = "TOGGLE_SORT",
|
|
8
|
+
CHANGE_PAGE = "CHANGE_PAGE",
|
|
9
|
+
CHANGE_ROWS_PER_PAGE = "CHANGE_ROWS_PER_PAGE"
|
|
10
|
+
}
|
|
11
|
+
export type BasicTableState = {
|
|
12
|
+
visibleColumns: ColumnData['id'][];
|
|
13
|
+
columnsSize?: ColumnSize[];
|
|
14
|
+
filters?: Record<ColumnData['id'], ColumnFilter>;
|
|
15
|
+
sorting?: Sorting;
|
|
16
|
+
page: number;
|
|
17
|
+
rowsPerPage: number;
|
|
18
|
+
rowsPerPageOptions?: number[];
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
export type BasicTableAction = ReturnType<ReturnType<typeof createStandardAction>>;
|
|
22
|
+
export type BasicTableReducer = <TableState extends BasicTableState, TableAction extends BasicTableAction>(state: TableState, action: TableAction) => TableState;
|
|
23
|
+
export declare const actions: {
|
|
24
|
+
changeColumns: (payload: any) => {
|
|
3
25
|
type: any;
|
|
4
26
|
payload: any;
|
|
5
27
|
};
|
|
6
|
-
|
|
28
|
+
toggleFilters: (payload: any) => {
|
|
7
29
|
type: any;
|
|
8
30
|
payload: any;
|
|
9
31
|
};
|
|
10
|
-
|
|
32
|
+
changeFilter: (payload: any) => {
|
|
11
33
|
type: any;
|
|
12
34
|
payload: any;
|
|
13
35
|
};
|
|
14
|
-
|
|
36
|
+
toggleSort: (payload: any) => {
|
|
15
37
|
type: any;
|
|
16
38
|
payload: any;
|
|
17
39
|
};
|
|
18
|
-
|
|
40
|
+
changePage: (payload: any) => {
|
|
19
41
|
type: any;
|
|
20
42
|
payload: any;
|
|
21
43
|
};
|
|
22
|
-
|
|
44
|
+
changeRowsPerPage: (payload: any) => {
|
|
23
45
|
type: any;
|
|
24
46
|
payload: any;
|
|
25
47
|
};
|
|
26
|
-
}
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
declare
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
};
|
|
49
|
+
export declare const changeVisibleColumns: (state: BasicTableState, nextVisibleColumns?: BasicTableState['visibleColumns']) => any;
|
|
50
|
+
export declare const reducer: BasicTableReducer;
|
|
51
|
+
declare const _default: {
|
|
52
|
+
reducer: BasicTableReducer;
|
|
53
|
+
actions: {
|
|
54
|
+
changeColumns: (payload: any) => {
|
|
55
|
+
type: any;
|
|
56
|
+
payload: any;
|
|
57
|
+
};
|
|
58
|
+
toggleFilters: (payload: any) => {
|
|
59
|
+
type: any;
|
|
60
|
+
payload: any;
|
|
61
|
+
};
|
|
62
|
+
changeFilter: (payload: any) => {
|
|
63
|
+
type: any;
|
|
64
|
+
payload: any;
|
|
65
|
+
};
|
|
66
|
+
toggleSort: (payload: any) => {
|
|
67
|
+
type: any;
|
|
68
|
+
payload: any;
|
|
69
|
+
};
|
|
70
|
+
changePage: (payload: any) => {
|
|
71
|
+
type: any;
|
|
72
|
+
payload: any;
|
|
73
|
+
};
|
|
74
|
+
changeRowsPerPage: (payload: any) => {
|
|
75
|
+
type: any;
|
|
76
|
+
payload: any;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
ActionTypes: typeof ActionTypes;
|
|
80
|
+
changeVisibleColumns: (state: BasicTableState, nextVisibleColumns?: string[]) => any;
|
|
81
|
+
};
|
|
34
82
|
export default _default;
|
|
@@ -11,28 +11,42 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.reducer = exports.changeVisibleColumns = exports.actions = void 0;
|
|
14
|
+
exports.reducer = exports.changeVisibleColumns = exports.actions = exports.ActionTypes = void 0;
|
|
15
15
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
16
16
|
var ramda_1 = require("ramda");
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
var ActionTypes;
|
|
18
|
+
(function (ActionTypes) {
|
|
19
|
+
ActionTypes["CHANGE_COLUMNS"] = "CHANGE_COLUMNS";
|
|
20
|
+
ActionTypes["TOGGLE_FILTERS"] = "TOGGLE_FILTERS";
|
|
21
|
+
ActionTypes["CHANGE_FILTER"] = "CHANGE_FILTER";
|
|
22
|
+
ActionTypes["TOGGLE_SORT"] = "TOGGLE_SORT";
|
|
23
|
+
ActionTypes["CHANGE_PAGE"] = "CHANGE_PAGE";
|
|
24
|
+
ActionTypes["CHANGE_ROWS_PER_PAGE"] = "CHANGE_ROWS_PER_PAGE";
|
|
25
|
+
})(ActionTypes || (exports.ActionTypes = ActionTypes = {}));
|
|
23
26
|
exports.actions = {
|
|
24
|
-
changeColumns: (0, mdm_sdk_1.createStandardAction)(CHANGE_COLUMNS),
|
|
25
|
-
toggleFilters: (0, mdm_sdk_1.createStandardAction)(TOGGLE_FILTERS),
|
|
26
|
-
changeFilter: (0, mdm_sdk_1.createStandardAction)(CHANGE_FILTER),
|
|
27
|
-
toggleSort: (0, mdm_sdk_1.createStandardAction)(TOGGLE_SORT),
|
|
28
|
-
changePage: (0, mdm_sdk_1.createStandardAction)(CHANGE_PAGE),
|
|
29
|
-
changeRowsPerPage: (0, mdm_sdk_1.createStandardAction)(CHANGE_ROWS_PER_PAGE)
|
|
27
|
+
changeColumns: (0, mdm_sdk_1.createStandardAction)(ActionTypes.CHANGE_COLUMNS),
|
|
28
|
+
toggleFilters: (0, mdm_sdk_1.createStandardAction)(ActionTypes.TOGGLE_FILTERS),
|
|
29
|
+
changeFilter: (0, mdm_sdk_1.createStandardAction)(ActionTypes.CHANGE_FILTER),
|
|
30
|
+
toggleSort: (0, mdm_sdk_1.createStandardAction)(ActionTypes.TOGGLE_SORT),
|
|
31
|
+
changePage: (0, mdm_sdk_1.createStandardAction)(ActionTypes.CHANGE_PAGE),
|
|
32
|
+
changeRowsPerPage: (0, mdm_sdk_1.createStandardAction)(ActionTypes.CHANGE_ROWS_PER_PAGE)
|
|
30
33
|
};
|
|
31
34
|
var changeVisibleColumns = function (state, nextVisibleColumns) {
|
|
35
|
+
if (nextVisibleColumns === void 0) { nextVisibleColumns = []; }
|
|
32
36
|
var removedColumns = (0, ramda_1.difference)(state.visibleColumns, nextVisibleColumns);
|
|
33
37
|
var isRemovedColumn = function (columnId) { return removedColumns.includes(columnId); };
|
|
34
38
|
return (0, ramda_1.evolve)({
|
|
35
39
|
visibleColumns: (0, ramda_1.always)(nextVisibleColumns),
|
|
40
|
+
columnsSize: function (columnsSize) {
|
|
41
|
+
if (columnsSize === void 0) { columnsSize = []; }
|
|
42
|
+
return nextVisibleColumns.map(function (columnId) {
|
|
43
|
+
var columnSize = columnsSize.find(function (_a) {
|
|
44
|
+
var id = _a.id;
|
|
45
|
+
return id === columnId;
|
|
46
|
+
});
|
|
47
|
+
return __assign({ id: columnId, size: (columnSize === null || columnSize === void 0 ? void 0 : columnSize.manuallyChanged) ? columnSize.size : 0 }, ((columnSize === null || columnSize === void 0 ? void 0 : columnSize.manuallyChanged) ? { manuallyChanged: true } : {}));
|
|
48
|
+
});
|
|
49
|
+
},
|
|
36
50
|
sorting: (0, ramda_1.when)(function (sorting) {
|
|
37
51
|
if (sorting === void 0) { sorting = {}; }
|
|
38
52
|
return isRemovedColumn(sorting.field);
|
|
@@ -41,26 +55,29 @@ var changeVisibleColumns = function (state, nextVisibleColumns) {
|
|
|
41
55
|
return { field: nextSortField, order: 'asc' };
|
|
42
56
|
}),
|
|
43
57
|
filters: function (filters) {
|
|
44
|
-
|
|
58
|
+
if (filters === void 0) { filters = {}; }
|
|
59
|
+
return (0, ramda_1.keys)(filters).reduce(function (acc, columnId) {
|
|
60
|
+
return isRemovedColumn(columnId) ? (0, ramda_1.dissoc)(columnId, acc) : acc;
|
|
61
|
+
}, filters);
|
|
45
62
|
}
|
|
46
63
|
}, state);
|
|
47
64
|
};
|
|
48
65
|
exports.changeVisibleColumns = changeVisibleColumns;
|
|
49
66
|
var reducer = function (state, action) {
|
|
50
67
|
switch (action.type) {
|
|
51
|
-
case CHANGE_COLUMNS: {
|
|
68
|
+
case ActionTypes.CHANGE_COLUMNS: {
|
|
52
69
|
var columnIds = action.payload;
|
|
53
70
|
return (0, exports.changeVisibleColumns)(state, columnIds);
|
|
54
71
|
}
|
|
55
|
-
case TOGGLE_FILTERS: {
|
|
72
|
+
case ActionTypes.TOGGLE_FILTERS: {
|
|
56
73
|
var enableFilters = !state.filters;
|
|
57
74
|
return __assign(__assign({}, state), { filters: enableFilters ? {} : null, page: enableFilters ? state.page : 0 });
|
|
58
75
|
}
|
|
59
|
-
case CHANGE_FILTER: {
|
|
76
|
+
case ActionTypes.CHANGE_FILTER: {
|
|
60
77
|
var _a = action.payload, columnId = _a.columnId, filter = _a.filter;
|
|
61
78
|
return (0, ramda_1.evolve)({ filters: filter ? (0, ramda_1.assoc)(columnId, filter) : (0, ramda_1.dissoc)(columnId), page: (0, ramda_1.always)(0) }, state);
|
|
62
79
|
}
|
|
63
|
-
case TOGGLE_SORT: {
|
|
80
|
+
case ActionTypes.TOGGLE_SORT: {
|
|
64
81
|
var nextSortField = action.payload;
|
|
65
82
|
var prevSortField = (0, ramda_1.path)(['sorting', 'field'], state);
|
|
66
83
|
var prevSortOrder = (0, ramda_1.path)(['sorting', 'order'], state);
|
|
@@ -69,9 +86,9 @@ var reducer = function (state, action) {
|
|
|
69
86
|
order: (0, mdm_sdk_1.toggleSortOrder)(nextSortField === prevSortField ? prevSortOrder : null)
|
|
70
87
|
}, page: 0 });
|
|
71
88
|
}
|
|
72
|
-
case CHANGE_PAGE:
|
|
89
|
+
case ActionTypes.CHANGE_PAGE:
|
|
73
90
|
return __assign(__assign({}, state), { page: action.payload });
|
|
74
|
-
case CHANGE_ROWS_PER_PAGE:
|
|
91
|
+
case ActionTypes.CHANGE_ROWS_PER_PAGE:
|
|
75
92
|
return __assign(__assign({}, state), { rowsPerPage: action.payload });
|
|
76
93
|
default:
|
|
77
94
|
return state;
|
|
@@ -81,5 +98,6 @@ exports.reducer = reducer;
|
|
|
81
98
|
exports.default = {
|
|
82
99
|
reducer: exports.reducer,
|
|
83
100
|
actions: exports.actions,
|
|
101
|
+
ActionTypes: ActionTypes,
|
|
84
102
|
changeVisibleColumns: exports.changeVisibleColumns
|
|
85
103
|
};
|
|
@@ -13,6 +13,26 @@ describe('basicTableViewState tests', function () {
|
|
|
13
13
|
};
|
|
14
14
|
expect((0, basicTableViewState_1.changeVisibleColumns)(prevState, visibleColumns)).toEqual(nextState);
|
|
15
15
|
});
|
|
16
|
+
it('should update columns size on changing visible columns', function () {
|
|
17
|
+
var prevState = {
|
|
18
|
+
visibleColumns: ['column1', 'column2', 'column3', 'column4'],
|
|
19
|
+
columnsSize: [
|
|
20
|
+
{ id: 'column1', size: 100, manuallyChanged: true },
|
|
21
|
+
{ id: 'column2', size: 200 },
|
|
22
|
+
{ id: 'column3', size: 300, manuallyChanged: true },
|
|
23
|
+
{ id: 'column4', size: 400 }
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
var visibleColumns = ['column1', 'column4'];
|
|
27
|
+
var nextState = {
|
|
28
|
+
visibleColumns: visibleColumns,
|
|
29
|
+
columnsSize: [
|
|
30
|
+
{ id: 'column1', size: 100, manuallyChanged: true },
|
|
31
|
+
{ id: 'column4', size: 0 }
|
|
32
|
+
]
|
|
33
|
+
};
|
|
34
|
+
expect((0, basicTableViewState_1.changeVisibleColumns)(prevState, visibleColumns)).toEqual(nextState);
|
|
35
|
+
});
|
|
16
36
|
it('should remove filters for columns that are no longer visible', function () {
|
|
17
37
|
var prevState = {
|
|
18
38
|
visibleColumns: ['column1', 'column2'],
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ProfileTablesPreferences } from '../../types/preferences';
|
|
3
|
+
export declare const ProfileTablesContext: import("react").Context<{
|
|
4
|
+
profileTablesPreferences: ProfileTablesPreferences;
|
|
5
|
+
setProfileTablesPreferences: (profileTablesPreferences: ProfileTablesPreferences) => void;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProfileTablesContext = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
exports.ProfileTablesContext = (0, react_1.createContext)({
|
|
6
|
+
profileTablesPreferences: {},
|
|
7
|
+
setProfileTablesPreferences: function () { }
|
|
8
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FacetFilter } from '@reltio/mdm-sdk';
|
|
2
|
-
import { ColumnData, ColumnFilter } from '../types/basicTable';
|
|
2
|
+
import { ColumnData, ColumnFilter, ColumnSize } from '../types/basicTable';
|
|
3
|
+
import { ColumnsSizeById } from '../types/preferences';
|
|
3
4
|
export declare const defaultGetRowCellHeight: ({ columnData, cell }: {
|
|
4
5
|
columnData: any;
|
|
5
6
|
cell: any;
|
|
@@ -11,3 +12,4 @@ export declare const defaultRenderRowCell: ({ cell, CellValueRenderer, ...otherP
|
|
|
11
12
|
}) => any;
|
|
12
13
|
export declare const columnFilterToMdmFilter: (columnData: Pick<ColumnData, 'id' | 'dataTypeDefinition'>, columnFilter?: ColumnFilter) => FacetFilter;
|
|
13
14
|
export declare const buildColumnsFilter: (columnsData: ColumnData[], filters?: Record<string, ColumnFilter>) => string;
|
|
15
|
+
export declare const buildColumnsSizeById: (columnsSize?: ColumnSize[]) => ColumnsSizeById;
|
|
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.buildColumnsFilter = exports.columnFilterToMdmFilter = exports.defaultRenderRowCell = exports.defaultGetRowCellHeight = void 0;
|
|
28
|
+
exports.buildColumnsSizeById = exports.buildColumnsFilter = exports.columnFilterToMdmFilter = exports.defaultRenderRowCell = exports.defaultGetRowCellHeight = void 0;
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
30
|
var ramda_1 = require("ramda");
|
|
31
31
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
@@ -76,3 +76,14 @@ var buildColumnsFilter = function (columnsData, filters) {
|
|
|
76
76
|
.orSome('');
|
|
77
77
|
};
|
|
78
78
|
exports.buildColumnsFilter = buildColumnsFilter;
|
|
79
|
+
var buildColumnsSizeById = function (columnsSize) {
|
|
80
|
+
if (columnsSize === void 0) { columnsSize = []; }
|
|
81
|
+
return columnsSize.reduce(function (columnsSizeById, _a) {
|
|
82
|
+
var id = _a.id, size = _a.size, manuallyChanged = _a.manuallyChanged;
|
|
83
|
+
if (manuallyChanged) {
|
|
84
|
+
columnsSizeById[id] = size;
|
|
85
|
+
}
|
|
86
|
+
return columnsSizeById;
|
|
87
|
+
}, {});
|
|
88
|
+
};
|
|
89
|
+
exports.buildColumnsSizeById = buildColumnsSizeById;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Entity, GeoPoint, Metadata, Point, PrimitiveValue, TEntityType } from '@reltio/mdm-sdk';
|
|
2
|
+
export declare const filterWrongLat: any;
|
|
3
|
+
export declare const isEqualGeoPoints: (aPoint: GeoPoint, bPoint: GeoPoint) => boolean;
|
|
4
|
+
export declare const isSet: (variable: Array<unknown>) => boolean;
|
|
5
|
+
export declare const getAttributeValuesByUri: (entity: Entity, attrTypeUri: string) => PrimitiveValue[];
|
|
6
|
+
type GeoAttribute = TEntityType['geoLocationAttributes'][0];
|
|
7
|
+
export declare const getPointsFromAttributes: (metadata: Metadata, entity: Entity, geoAttr: GeoAttribute) => Point[];
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPointsFromAttributes = exports.getAttributeValuesByUri = exports.isSet = exports.isEqualGeoPoints = exports.filterWrongLat = void 0;
|
|
4
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
5
|
+
var mdm_sdk_2 = require("@reltio/mdm-sdk");
|
|
6
|
+
var ramda_1 = require("ramda");
|
|
7
|
+
var getAttributeValue = function (attr) {
|
|
8
|
+
var value = attr.label || attr.value || '';
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
value = value.join(', ');
|
|
11
|
+
}
|
|
12
|
+
else if ((0, ramda_1.is)(Object, value)) {
|
|
13
|
+
value = '';
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
var parseAttributeValues = function (attributes, attrTypeUri) {
|
|
18
|
+
return Object.values(attributes)
|
|
19
|
+
.filter(Array.isArray)
|
|
20
|
+
.flat(Infinity)
|
|
21
|
+
.filter(mdm_sdk_1.isOv)
|
|
22
|
+
.flatMap(function (attribute) {
|
|
23
|
+
var result;
|
|
24
|
+
if (attribute.type == attrTypeUri) {
|
|
25
|
+
result = [getAttributeValue(attribute)];
|
|
26
|
+
}
|
|
27
|
+
if ((0, ramda_1.is)(Object, attribute.value)) {
|
|
28
|
+
result = (result || []).concat(parseAttributeValues(attribute.value, attrTypeUri));
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.filterWrongLat = (0, ramda_1.pipe)((0, ramda_1.path)(['point', 'lat']), (0, ramda_1.both)((0, ramda_1.gt)(90), (0, ramda_1.lt)(-90)));
|
|
34
|
+
var isEqualGeoPoints = function (aPoint, bPoint) {
|
|
35
|
+
return (aPoint.entity === bPoint.entity &&
|
|
36
|
+
aPoint.point.lat === bPoint.point.lat &&
|
|
37
|
+
aPoint.point.lng === bPoint.point.lng);
|
|
38
|
+
};
|
|
39
|
+
exports.isEqualGeoPoints = isEqualGeoPoints;
|
|
40
|
+
var isSet = function (variable) { return variable && variable.length > 0; };
|
|
41
|
+
exports.isSet = isSet;
|
|
42
|
+
var getAttributeValuesByUri = function (entity, attrTypeUri) {
|
|
43
|
+
return [].concat((entity === null || entity === void 0 ? void 0 : entity.attributes) ? parseAttributeValues(entity.attributes, attrTypeUri) : []).filter(ramda_1.identity);
|
|
44
|
+
};
|
|
45
|
+
exports.getAttributeValuesByUri = getAttributeValuesByUri;
|
|
46
|
+
var getPointsFromAttributes = function (metadata, entity, geoAttr) {
|
|
47
|
+
if ((0, mdm_sdk_2.hasMaskingByUris)(metadata, [geoAttr.latitude, geoAttr.longitude]))
|
|
48
|
+
return null;
|
|
49
|
+
var lat = (0, exports.getAttributeValuesByUri)(entity, geoAttr.latitude);
|
|
50
|
+
var lng = (0, exports.getAttributeValuesByUri)(entity, geoAttr.longitude);
|
|
51
|
+
if ((0, exports.isSet)(lat) && (0, exports.isSet)(lng)) {
|
|
52
|
+
return (0, ramda_1.zipWith)(function (lat, lng) { return ({ lat: Number(lat), lng: Number(lng) }); }, lat, lng);
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
exports.getPointsFromAttributes = getPointsFromAttributes;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveMarkers = exports.useMarkers = void 0;
|
|
4
|
+
var useMarkers_1 = require("./useMarkers");
|
|
5
|
+
Object.defineProperty(exports, "useMarkers", { enumerable: true, get: function () { return useMarkers_1.useMarkers; } });
|
|
6
|
+
var resolveHelpers_1 = require("./resolveHelpers");
|
|
7
|
+
Object.defineProperty(exports, "resolveMarkers", { enumerable: true, get: function () { return resolveHelpers_1.resolveMarkers; } });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPointsFromNested = void 0;
|
|
4
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
5
|
+
var ramda_1 = require("ramda");
|
|
6
|
+
var helpers_1 = require("./helpers");
|
|
7
|
+
var getPointsFromNested = function (metadata, entities) {
|
|
8
|
+
if (entities === void 0) { entities = []; }
|
|
9
|
+
return (0, ramda_1.pipe)((0, ramda_1.chain)(function (entity) {
|
|
10
|
+
var entityType = (0, mdm_sdk_1.getEntityType)(metadata, entity.type);
|
|
11
|
+
return ((entityType === null || entityType === void 0 ? void 0 : entityType.geoLocationAttributes) || []).flatMap(function (geoAttr) {
|
|
12
|
+
if ((0, mdm_sdk_1.findAttributeTypeByUri)(metadata, geoAttr.latitude, entity.type) &&
|
|
13
|
+
(0, mdm_sdk_1.findAttributeTypeByUri)(metadata, geoAttr.longitude, entity.type)) {
|
|
14
|
+
var points = (0, helpers_1.getPointsFromAttributes)(metadata, entity, geoAttr);
|
|
15
|
+
return points === null || points === void 0 ? void 0 : points.map(function (_a) {
|
|
16
|
+
var lat = _a.lat, lng = _a.lng;
|
|
17
|
+
return ({
|
|
18
|
+
id: "".concat(entity.uri, "_nested_").concat(lat, "_").concat(lng),
|
|
19
|
+
entity: entity,
|
|
20
|
+
label: entity.label,
|
|
21
|
+
point: {
|
|
22
|
+
lat: Number(lat),
|
|
23
|
+
lng: Number(lng)
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}), (0, ramda_1.filter)(ramda_1.identity), (0, ramda_1.uniqBy)((0, ramda_1.prop)('id')))(entities);
|
|
30
|
+
};
|
|
31
|
+
exports.getPointsFromNested = getPointsFromNested;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
var nestedHelpers_1 = require("./nestedHelpers");
|
|
24
|
+
describe('from nested strategy test', function () {
|
|
25
|
+
var metadata = {
|
|
26
|
+
entityTypes: [
|
|
27
|
+
{
|
|
28
|
+
uri: 'configuration/entityTypes/EntityWithNestedAddress',
|
|
29
|
+
geoLocationAttributes: [
|
|
30
|
+
{
|
|
31
|
+
latitude: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Latitude',
|
|
32
|
+
longitude: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Longitude'
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
attributes: [
|
|
36
|
+
{
|
|
37
|
+
name: 'Location',
|
|
38
|
+
type: 'Nested',
|
|
39
|
+
uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location',
|
|
40
|
+
attributes: [
|
|
41
|
+
{
|
|
42
|
+
name: 'GeoLocation',
|
|
43
|
+
uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation',
|
|
44
|
+
type: 'Nested',
|
|
45
|
+
attributes: [
|
|
46
|
+
{
|
|
47
|
+
name: 'Latitude',
|
|
48
|
+
type: 'String',
|
|
49
|
+
uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Latitude'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'Longitude',
|
|
53
|
+
type: 'String',
|
|
54
|
+
uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Longitude'
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
var entities = [
|
|
65
|
+
{
|
|
66
|
+
label: 'label',
|
|
67
|
+
uri: 'entities/1SfTJYdD',
|
|
68
|
+
ov: true,
|
|
69
|
+
type: 'configuration/entityTypes/EntityWithNestedAddress',
|
|
70
|
+
attributes: {
|
|
71
|
+
Location: [
|
|
72
|
+
{
|
|
73
|
+
type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location',
|
|
74
|
+
ov: true,
|
|
75
|
+
uri: 'entities/1SfTJYdD/attributes/Location/3GXtYP63L',
|
|
76
|
+
value: {
|
|
77
|
+
GeoLocation: [
|
|
78
|
+
{
|
|
79
|
+
type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation',
|
|
80
|
+
uri: 'entities/1SfTJYdD/attributes/Location/3GXtYP63L/GeoLocation/3GXtYPAJb',
|
|
81
|
+
ov: true,
|
|
82
|
+
value: {
|
|
83
|
+
Longitude: [
|
|
84
|
+
{
|
|
85
|
+
type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Longitude',
|
|
86
|
+
value: '123',
|
|
87
|
+
ov: true,
|
|
88
|
+
uri: 'entities/1SfTJYdD/attributes/Location/3GXtYP63L/GeoLocation/3GXtYPAJb/Longitude/3GXtYPEZr'
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
Latitude: [
|
|
92
|
+
{
|
|
93
|
+
type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Latitude',
|
|
94
|
+
value: '321',
|
|
95
|
+
ov: true,
|
|
96
|
+
uri: 'entities/1SfTJYdD/attributes/Location/3GXtYP63L/GeoLocation/3GXtYPAJb/Latitude/3GXtYPIq7'
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location',
|
|
106
|
+
ov: true,
|
|
107
|
+
uri: 'entities/1SfTJYdD/attributes/Location/3GXtdfg3L',
|
|
108
|
+
value: {
|
|
109
|
+
GeoLocation: [
|
|
110
|
+
{
|
|
111
|
+
type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation',
|
|
112
|
+
uri: 'entities/1SfTJYdD/attributes/Location/3GXtdfg3L/GeoLocation/3GXcvb1234',
|
|
113
|
+
ov: true,
|
|
114
|
+
value: {
|
|
115
|
+
Longitude: [
|
|
116
|
+
{
|
|
117
|
+
type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Longitude',
|
|
118
|
+
value: '456',
|
|
119
|
+
ov: true,
|
|
120
|
+
uri: 'entities/1SfTJYdD/attributes/Location/3GXtdfg3L/GeoLocation/3GXcvb1234/Longitude/3GedY1235'
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
Latitude: [
|
|
124
|
+
{
|
|
125
|
+
type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Latitude',
|
|
126
|
+
value: '654',
|
|
127
|
+
ov: true,
|
|
128
|
+
uri: 'entities/1SfTJYdD/attributes/Location/3GXtdfg3L/GeoLocation/3GXcvb1234/Latitude/3GXt4ki77'
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location',
|
|
138
|
+
ov: false,
|
|
139
|
+
uri: 'entities/1SfTJYdD/attributes/Location/3GXektg3L',
|
|
140
|
+
value: {
|
|
141
|
+
GeoLocation: [
|
|
142
|
+
{
|
|
143
|
+
type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation',
|
|
144
|
+
uri: 'entities/1SfTJYdD/attributes/Location/3GXektg3L/GeoLocation/3Goke1234',
|
|
145
|
+
ov: true,
|
|
146
|
+
value: {
|
|
147
|
+
Longitude: [
|
|
148
|
+
{
|
|
149
|
+
type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Longitude',
|
|
150
|
+
value: '456',
|
|
151
|
+
ov: true,
|
|
152
|
+
uri: 'entities/1SfTJYdD/attributes/Location/3GXektg3L/GeoLocation/3Goke1234/Longitude/3hedY1235'
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
Latitude: [
|
|
156
|
+
{
|
|
157
|
+
type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Latitude',
|
|
158
|
+
value: '654',
|
|
159
|
+
ov: true,
|
|
160
|
+
uri: 'entities/1SfTJYdD/attributes/Location/3GXektg3L/GeoLocation/3Goke1234/Latitude/6GXt4ki77'
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
];
|
|
172
|
+
it('should get geo location attributes from nested address', function () {
|
|
173
|
+
var points = (0, nestedHelpers_1.getPointsFromNested)(metadata, entities);
|
|
174
|
+
expect(points.length).toBe(2);
|
|
175
|
+
expect(points[0].entity).toEqual(entities[0]);
|
|
176
|
+
expect(points[0].label).toBe('label');
|
|
177
|
+
expect(points[0].point).toEqual({ lat: 321, lng: 123 });
|
|
178
|
+
expect(points[1].entity).toEqual(entities[0]);
|
|
179
|
+
expect(points[1].label).toBe('label');
|
|
180
|
+
expect(points[1].point).toEqual({ lat: 654, lng: 456 });
|
|
181
|
+
expect(points[0].id).not.toBe(points[1].id);
|
|
182
|
+
});
|
|
183
|
+
it('should add only uniq points', function () {
|
|
184
|
+
var points = (0, nestedHelpers_1.getPointsFromNested)(metadata, [
|
|
185
|
+
__assign(__assign({}, entities[0]), { attributes: __assign(__assign({}, entities[0].attributes), { Location: __spreadArray(__spreadArray([], entities[0].attributes.Location, true), entities[0].attributes.Location, true) }) })
|
|
186
|
+
]);
|
|
187
|
+
expect(points.length).toBe(2);
|
|
188
|
+
});
|
|
189
|
+
it('should not fail if entity type is not found', function () {
|
|
190
|
+
var points = (0, nestedHelpers_1.getPointsFromNested)(metadata, [{}]);
|
|
191
|
+
expect(points.length).toBe(0);
|
|
192
|
+
});
|
|
193
|
+
it('should return empty array if geoLocationAttributes is not exists', function () {
|
|
194
|
+
var points = (0, nestedHelpers_1.getPointsFromNested)({
|
|
195
|
+
entityTypes: [
|
|
196
|
+
{
|
|
197
|
+
uri: 'configuration/entityTypes/EntityWithNestedAddress',
|
|
198
|
+
attributes: [
|
|
199
|
+
{
|
|
200
|
+
name: 'Location',
|
|
201
|
+
type: 'Nested',
|
|
202
|
+
uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location',
|
|
203
|
+
attributes: [
|
|
204
|
+
{
|
|
205
|
+
name: 'GeoLocation',
|
|
206
|
+
uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation',
|
|
207
|
+
type: 'Nested',
|
|
208
|
+
attributes: [
|
|
209
|
+
{
|
|
210
|
+
name: 'Latitude',
|
|
211
|
+
type: 'String',
|
|
212
|
+
uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Latitude'
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: 'Longitude',
|
|
216
|
+
type: 'String',
|
|
217
|
+
uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Longitude'
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
}, entities);
|
|
227
|
+
expect(points).toEqual([]);
|
|
228
|
+
});
|
|
229
|
+
it('should not consider attributes with masking while constructing point', function () {
|
|
230
|
+
var maskedMetadata = JSON.parse(JSON.stringify(metadata));
|
|
231
|
+
maskedMetadata.entityTypes[0].attributes[0].attributes[0].attributes[0].masking = { regex: '***' };
|
|
232
|
+
var points = (0, nestedHelpers_1.getPointsFromNested)(maskedMetadata, entities);
|
|
233
|
+
expect(points.length).toBe(0);
|
|
234
|
+
});
|
|
235
|
+
});
|