@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.
Files changed (63) hide show
  1. package/cjs/BasicTable/basicTableViewState.d.ts +63 -15
  2. package/cjs/BasicTable/basicTableViewState.js +38 -20
  3. package/cjs/BasicTable/basicTableViewState.test.js +20 -0
  4. package/cjs/contexts/ProfileTablesContext/index.d.ts +6 -0
  5. package/cjs/contexts/ProfileTablesContext/index.js +8 -0
  6. package/cjs/helpers/basicTable.d.ts +3 -1
  7. package/cjs/helpers/basicTable.js +12 -1
  8. package/cjs/hooks/useMarkers/helpers.d.ts +8 -0
  9. package/cjs/hooks/useMarkers/helpers.js +56 -0
  10. package/cjs/hooks/useMarkers/index.d.ts +2 -0
  11. package/cjs/hooks/useMarkers/index.js +7 -0
  12. package/cjs/hooks/useMarkers/nestedHelpers.d.ts +2 -0
  13. package/cjs/hooks/useMarkers/nestedHelpers.js +31 -0
  14. package/cjs/hooks/useMarkers/nestedHelpers.test.d.ts +1 -0
  15. package/cjs/hooks/useMarkers/nestedHelpers.test.js +235 -0
  16. package/cjs/hooks/useMarkers/referenceHelpers.d.ts +2 -0
  17. package/cjs/hooks/useMarkers/referenceHelpers.js +180 -0
  18. package/cjs/hooks/useMarkers/referenceHelpers.test.d.ts +1 -0
  19. package/cjs/hooks/useMarkers/referenceHelpers.test.js +490 -0
  20. package/cjs/hooks/useMarkers/resolveHelpers.d.ts +8 -0
  21. package/cjs/hooks/useMarkers/resolveHelpers.js +70 -0
  22. package/cjs/hooks/useMarkers/useMarkers.d.ts +5 -0
  23. package/cjs/hooks/useMarkers/useMarkers.js +30 -0
  24. package/cjs/hooks/useSavedState/useSavedState.d.ts +1 -1
  25. package/cjs/hooks/useSavedStateForEntityType/useSavedStateForEntityType.d.ts +1 -1
  26. package/cjs/index.d.ts +5 -2
  27. package/cjs/index.js +9 -2
  28. package/cjs/test-utils/index.js +1 -1
  29. package/cjs/types/basicTable.d.ts +5 -0
  30. package/cjs/types/preferences.d.ts +8 -0
  31. package/cjs/types/preferences.js +2 -0
  32. package/esm/BasicTable/basicTableViewState.d.ts +63 -15
  33. package/esm/BasicTable/basicTableViewState.js +37 -19
  34. package/esm/BasicTable/basicTableViewState.test.js +20 -0
  35. package/esm/contexts/ProfileTablesContext/index.d.ts +6 -0
  36. package/esm/contexts/ProfileTablesContext/index.js +5 -0
  37. package/esm/helpers/basicTable.d.ts +3 -1
  38. package/esm/helpers/basicTable.js +10 -0
  39. package/esm/hooks/useMarkers/helpers.d.ts +8 -0
  40. package/esm/hooks/useMarkers/helpers.js +49 -0
  41. package/esm/hooks/useMarkers/index.d.ts +2 -0
  42. package/esm/hooks/useMarkers/index.js +2 -0
  43. package/esm/hooks/useMarkers/nestedHelpers.d.ts +2 -0
  44. package/esm/hooks/useMarkers/nestedHelpers.js +27 -0
  45. package/esm/hooks/useMarkers/nestedHelpers.test.d.ts +1 -0
  46. package/esm/hooks/useMarkers/nestedHelpers.test.js +233 -0
  47. package/esm/hooks/useMarkers/referenceHelpers.d.ts +2 -0
  48. package/esm/hooks/useMarkers/referenceHelpers.js +176 -0
  49. package/esm/hooks/useMarkers/referenceHelpers.test.d.ts +1 -0
  50. package/esm/hooks/useMarkers/referenceHelpers.test.js +488 -0
  51. package/esm/hooks/useMarkers/resolveHelpers.d.ts +8 -0
  52. package/esm/hooks/useMarkers/resolveHelpers.js +66 -0
  53. package/esm/hooks/useMarkers/useMarkers.d.ts +5 -0
  54. package/esm/hooks/useMarkers/useMarkers.js +26 -0
  55. package/esm/hooks/useSavedState/useSavedState.d.ts +1 -1
  56. package/esm/hooks/useSavedStateForEntityType/useSavedStateForEntityType.d.ts +1 -1
  57. package/esm/index.d.ts +5 -2
  58. package/esm/index.js +4 -1
  59. package/esm/test-utils/index.js +1 -1
  60. package/esm/types/basicTable.d.ts +5 -0
  61. package/esm/types/preferences.d.ts +8 -0
  62. package/esm/types/preferences.js +1 -0
  63. package/package.json +15 -12
@@ -0,0 +1,233 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
21
+ import { getPointsFromNested } from './nestedHelpers';
22
+ describe('from nested strategy test', function () {
23
+ var metadata = {
24
+ entityTypes: [
25
+ {
26
+ uri: 'configuration/entityTypes/EntityWithNestedAddress',
27
+ geoLocationAttributes: [
28
+ {
29
+ latitude: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Latitude',
30
+ longitude: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Longitude'
31
+ }
32
+ ],
33
+ attributes: [
34
+ {
35
+ name: 'Location',
36
+ type: 'Nested',
37
+ uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location',
38
+ attributes: [
39
+ {
40
+ name: 'GeoLocation',
41
+ uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation',
42
+ type: 'Nested',
43
+ attributes: [
44
+ {
45
+ name: 'Latitude',
46
+ type: 'String',
47
+ uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Latitude'
48
+ },
49
+ {
50
+ name: 'Longitude',
51
+ type: 'String',
52
+ uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Longitude'
53
+ }
54
+ ]
55
+ }
56
+ ]
57
+ }
58
+ ]
59
+ }
60
+ ]
61
+ };
62
+ var entities = [
63
+ {
64
+ label: 'label',
65
+ uri: 'entities/1SfTJYdD',
66
+ ov: true,
67
+ type: 'configuration/entityTypes/EntityWithNestedAddress',
68
+ attributes: {
69
+ Location: [
70
+ {
71
+ type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location',
72
+ ov: true,
73
+ uri: 'entities/1SfTJYdD/attributes/Location/3GXtYP63L',
74
+ value: {
75
+ GeoLocation: [
76
+ {
77
+ type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation',
78
+ uri: 'entities/1SfTJYdD/attributes/Location/3GXtYP63L/GeoLocation/3GXtYPAJb',
79
+ ov: true,
80
+ value: {
81
+ Longitude: [
82
+ {
83
+ type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Longitude',
84
+ value: '123',
85
+ ov: true,
86
+ uri: 'entities/1SfTJYdD/attributes/Location/3GXtYP63L/GeoLocation/3GXtYPAJb/Longitude/3GXtYPEZr'
87
+ }
88
+ ],
89
+ Latitude: [
90
+ {
91
+ type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Latitude',
92
+ value: '321',
93
+ ov: true,
94
+ uri: 'entities/1SfTJYdD/attributes/Location/3GXtYP63L/GeoLocation/3GXtYPAJb/Latitude/3GXtYPIq7'
95
+ }
96
+ ]
97
+ }
98
+ }
99
+ ]
100
+ }
101
+ },
102
+ {
103
+ type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location',
104
+ ov: true,
105
+ uri: 'entities/1SfTJYdD/attributes/Location/3GXtdfg3L',
106
+ value: {
107
+ GeoLocation: [
108
+ {
109
+ type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation',
110
+ uri: 'entities/1SfTJYdD/attributes/Location/3GXtdfg3L/GeoLocation/3GXcvb1234',
111
+ ov: true,
112
+ value: {
113
+ Longitude: [
114
+ {
115
+ type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Longitude',
116
+ value: '456',
117
+ ov: true,
118
+ uri: 'entities/1SfTJYdD/attributes/Location/3GXtdfg3L/GeoLocation/3GXcvb1234/Longitude/3GedY1235'
119
+ }
120
+ ],
121
+ Latitude: [
122
+ {
123
+ type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Latitude',
124
+ value: '654',
125
+ ov: true,
126
+ uri: 'entities/1SfTJYdD/attributes/Location/3GXtdfg3L/GeoLocation/3GXcvb1234/Latitude/3GXt4ki77'
127
+ }
128
+ ]
129
+ }
130
+ }
131
+ ]
132
+ }
133
+ },
134
+ {
135
+ type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location',
136
+ ov: false,
137
+ uri: 'entities/1SfTJYdD/attributes/Location/3GXektg3L',
138
+ value: {
139
+ GeoLocation: [
140
+ {
141
+ type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation',
142
+ uri: 'entities/1SfTJYdD/attributes/Location/3GXektg3L/GeoLocation/3Goke1234',
143
+ ov: true,
144
+ value: {
145
+ Longitude: [
146
+ {
147
+ type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Longitude',
148
+ value: '456',
149
+ ov: true,
150
+ uri: 'entities/1SfTJYdD/attributes/Location/3GXektg3L/GeoLocation/3Goke1234/Longitude/3hedY1235'
151
+ }
152
+ ],
153
+ Latitude: [
154
+ {
155
+ type: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Latitude',
156
+ value: '654',
157
+ ov: true,
158
+ uri: 'entities/1SfTJYdD/attributes/Location/3GXektg3L/GeoLocation/3Goke1234/Latitude/6GXt4ki77'
159
+ }
160
+ ]
161
+ }
162
+ }
163
+ ]
164
+ }
165
+ }
166
+ ]
167
+ }
168
+ }
169
+ ];
170
+ it('should get geo location attributes from nested address', function () {
171
+ var points = getPointsFromNested(metadata, entities);
172
+ expect(points.length).toBe(2);
173
+ expect(points[0].entity).toEqual(entities[0]);
174
+ expect(points[0].label).toBe('label');
175
+ expect(points[0].point).toEqual({ lat: 321, lng: 123 });
176
+ expect(points[1].entity).toEqual(entities[0]);
177
+ expect(points[1].label).toBe('label');
178
+ expect(points[1].point).toEqual({ lat: 654, lng: 456 });
179
+ expect(points[0].id).not.toBe(points[1].id);
180
+ });
181
+ it('should add only uniq points', function () {
182
+ var points = getPointsFromNested(metadata, [
183
+ __assign(__assign({}, entities[0]), { attributes: __assign(__assign({}, entities[0].attributes), { Location: __spreadArray(__spreadArray([], entities[0].attributes.Location, true), entities[0].attributes.Location, true) }) })
184
+ ]);
185
+ expect(points.length).toBe(2);
186
+ });
187
+ it('should not fail if entity type is not found', function () {
188
+ var points = getPointsFromNested(metadata, [{}]);
189
+ expect(points.length).toBe(0);
190
+ });
191
+ it('should return empty array if geoLocationAttributes is not exists', function () {
192
+ var points = getPointsFromNested({
193
+ entityTypes: [
194
+ {
195
+ uri: 'configuration/entityTypes/EntityWithNestedAddress',
196
+ attributes: [
197
+ {
198
+ name: 'Location',
199
+ type: 'Nested',
200
+ uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location',
201
+ attributes: [
202
+ {
203
+ name: 'GeoLocation',
204
+ uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation',
205
+ type: 'Nested',
206
+ attributes: [
207
+ {
208
+ name: 'Latitude',
209
+ type: 'String',
210
+ uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Latitude'
211
+ },
212
+ {
213
+ name: 'Longitude',
214
+ type: 'String',
215
+ uri: 'configuration/entityTypes/EntityWithNestedAddress/attributes/Location/attributes/GeoLocation/attributes/Longitude'
216
+ }
217
+ ]
218
+ }
219
+ ]
220
+ }
221
+ ]
222
+ }
223
+ ]
224
+ }, entities);
225
+ expect(points).toEqual([]);
226
+ });
227
+ it('should not consider attributes with masking while constructing point', function () {
228
+ var maskedMetadata = JSON.parse(JSON.stringify(metadata));
229
+ maskedMetadata.entityTypes[0].attributes[0].attributes[0].attributes[0].masking = { regex: '***' };
230
+ var points = getPointsFromNested(maskedMetadata, entities);
231
+ expect(points.length).toBe(0);
232
+ });
233
+ });
@@ -0,0 +1,2 @@
1
+ import { Entity, GeoPoint, Metadata } from '@reltio/mdm-sdk';
2
+ export declare const getPointsFromReference: (servicesPath: string, metadata: Metadata, entities?: Entity[]) => Promise<GeoPoint[]>;
@@ -0,0 +1,176 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import { identity, flatten } from 'ramda';
49
+ import { decodeAddress, getEntityType, wrapInArrayIfNeeded } from '@reltio/mdm-sdk';
50
+ import { hasMaskingByUris } from '@reltio/mdm-sdk/src/metadata/masking';
51
+ import { getPointsFromAttributes, isSet } from './helpers';
52
+ var getGeoLocation = function (servicesPath, entity, attributes, metadata, refAttribute, name) { return __awaiter(void 0, void 0, void 0, function () {
53
+ var entityType, results, geoLocation, results, response, _a;
54
+ var _b;
55
+ return __generator(this, function (_c) {
56
+ switch (_c.label) {
57
+ case 0:
58
+ if (entity && entity.type) {
59
+ entityType = getEntityType(metadata, entity.type);
60
+ if (refAttribute) {
61
+ entity = __assign(__assign({}, entity), { attributes: (_b = {}, _b[name] = [refAttribute], _b) });
62
+ }
63
+ results = (entityType.geoLocationAttributes || [])
64
+ .map(function (geoAttr) { return getPointsFromAttributes(metadata, entity, geoAttr); })
65
+ .filter(identity);
66
+ if (results.length > 0) {
67
+ return [2 /*return*/, Promise.resolve(results[0])];
68
+ }
69
+ }
70
+ geoLocation = attributes['GeoLocation'];
71
+ if (geoLocation) {
72
+ results = geoLocation
73
+ .map(function (loc) {
74
+ var lat = loc.value['Latitude'];
75
+ var lon = loc.value['Longitude'];
76
+ if (isSet(lat) && lat[0].value && isSet(lon) && lon[0].value) {
77
+ var hasMasking = hasMaskingByUris(metadata, [lat[0].type, lon[0].type]);
78
+ return hasMasking ? null : { id: loc.uri, lat: Number(lat[0].value), lng: Number(lon[0].value) };
79
+ }
80
+ })
81
+ .filter(identity);
82
+ if (results.length > 0) {
83
+ return [2 /*return*/, Promise.resolve(results)];
84
+ }
85
+ }
86
+ if (!(refAttribute && refAttribute.label)) return [3 /*break*/, 4];
87
+ _c.label = 1;
88
+ case 1:
89
+ _c.trys.push([1, 3, , 4]);
90
+ return [4 /*yield*/, decodeAddress({ servicesPath: servicesPath, address: refAttribute.label })];
91
+ case 2:
92
+ response = _c.sent();
93
+ return [2 /*return*/, response.location];
94
+ case 3:
95
+ _a = _c.sent();
96
+ return [2 /*return*/, null];
97
+ case 4: return [2 /*return*/, Promise.resolve(null)];
98
+ }
99
+ });
100
+ }); };
101
+ var prepareData = function (metadata, entities) {
102
+ var map = {};
103
+ return flatten(entities.map(function (entity) {
104
+ var _a;
105
+ if (entity.type === 'configuration/entityTypes/Location') {
106
+ return { id: entity.uri, label: entity.label, entity: entity, pointSource: entity.attributes };
107
+ }
108
+ else {
109
+ map[entity.type] =
110
+ map[entity.type] ||
111
+ (((_a = getEntityType(metadata, entity.type)) === null || _a === void 0 ? void 0 : _a.attributes) || [])
112
+ .filter(function (attribute) { return attribute.referencedEntityTypeURI === 'configuration/entityTypes/Location'; })
113
+ .map(function (_a) {
114
+ var name = _a.name;
115
+ return name;
116
+ });
117
+ return map[entity.type]
118
+ .map(function (attrName) { return [attrName, entity.attributes[attrName]]; })
119
+ .filter(function (_a) {
120
+ var value = _a[1];
121
+ return value;
122
+ })
123
+ .flatMap(function (_a) {
124
+ var name = _a[0], attributes = _a[1];
125
+ return attributes.map(function (attribute) { return ({
126
+ id: attribute.uri,
127
+ label: attribute.label,
128
+ entity: entity,
129
+ pointSource: attribute.value,
130
+ refAttribute: attribute,
131
+ name: name
132
+ }); });
133
+ });
134
+ }
135
+ }));
136
+ };
137
+ export var getPointsFromReference = function (servicesPath, metadata, entities) {
138
+ if (entities === void 0) { entities = []; }
139
+ return __awaiter(void 0, void 0, void 0, function () {
140
+ var data, results;
141
+ return __generator(this, function (_a) {
142
+ switch (_a.label) {
143
+ case 0:
144
+ data = prepareData(metadata, entities);
145
+ return [4 /*yield*/, Promise.all(data.map(function (_a) {
146
+ var id = _a.id, label = _a.label, entity = _a.entity, pointSource = _a.pointSource, refAttribute = _a.refAttribute, name = _a.name;
147
+ return getGeoLocation(servicesPath, entity, pointSource, metadata, refAttribute, name)
148
+ .then(function (points) {
149
+ if (!points && entity.label) {
150
+ return decodeAddress({ servicesPath: servicesPath, address: entity.label })
151
+ .then(function (response) { return response.location; })
152
+ .catch(function () { return null; });
153
+ }
154
+ else {
155
+ return points;
156
+ }
157
+ })
158
+ .then(function (points) {
159
+ return wrapInArrayIfNeeded(points)
160
+ .filter(identity)
161
+ .map(function (point) { return ({
162
+ id: point.id || id,
163
+ label: label,
164
+ entity: entity,
165
+ point: point
166
+ }); });
167
+ })
168
+ .catch(function () { return null; });
169
+ }))];
170
+ case 1:
171
+ results = _a.sent();
172
+ return [2 /*return*/, results.flat(Infinity).filter(identity)];
173
+ }
174
+ });
175
+ });
176
+ };
@@ -0,0 +1 @@
1
+ export {};