@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,490 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ var ramda_1 = require("ramda");
51
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
52
+ var referenceHelpers_1 = require("./referenceHelpers");
53
+ jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { decodeAddress: jest.fn() })); });
54
+ describe('from reference strategy test', function () {
55
+ var servicesPath = '/nui/services';
56
+ var defaultMetadata = {
57
+ entityTypes: [
58
+ {
59
+ uri: 'configuration/entityTypes/Location',
60
+ attributes: [
61
+ {
62
+ name: 'GeoLocation',
63
+ uri: 'configuration/entityTypes/Location/attributes/GeoLocation',
64
+ type: 'Nested',
65
+ attributes: [
66
+ {
67
+ name: 'Latitude',
68
+ type: 'String',
69
+ uri: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude'
70
+ },
71
+ {
72
+ name: 'Longitude',
73
+ type: 'String',
74
+ uri: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude'
75
+ }
76
+ ]
77
+ }
78
+ ],
79
+ geoLocationAttributes: [
80
+ {
81
+ latitude: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude',
82
+ longitude: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude'
83
+ }
84
+ ]
85
+ },
86
+ {
87
+ uri: 'configuration/entityTypes/EntityTypeWithLocation',
88
+ attributes: [
89
+ {
90
+ uri: 'configuration/entityTypes/EntityTypeWithLocation/attributes/Address',
91
+ referencedEntityTypeURI: 'configuration/entityTypes/Location',
92
+ name: 'Address',
93
+ type: 'String'
94
+ }
95
+ ]
96
+ },
97
+ {
98
+ uri: 'configuration/entityTypes/EntityTypeWithLocationAndAttribute',
99
+ attributes: [
100
+ {
101
+ uri: 'configuration/entityTypes/EntityTypeWithLocationAndAttribute/attributes/Address',
102
+ referencedEntityTypeURI: 'configuration/entityTypes/Location',
103
+ name: 'Address',
104
+ type: 'String'
105
+ }
106
+ ],
107
+ geoLocationAttributes: [
108
+ {
109
+ latitude: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude',
110
+ longitude: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude'
111
+ }
112
+ ]
113
+ }
114
+ ]
115
+ };
116
+ var defaultEntities = [
117
+ {
118
+ uri: 'entities/111',
119
+ label: 'label',
120
+ type: 'configuration/entityTypes/Location',
121
+ attributes: {
122
+ GeoLocation: [
123
+ {
124
+ uri: 'entities/111/attributes/GeoLocation/222',
125
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation',
126
+ ov: true,
127
+ value: {
128
+ Longitude: [
129
+ {
130
+ uri: 'entities/111/attributes/GeoLocation/222/Longitude/333',
131
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude',
132
+ ov: true,
133
+ value: '123'
134
+ }
135
+ ],
136
+ Latitude: [
137
+ {
138
+ uri: 'entities/111/attributes/GeoLocation/222/Latitude/444',
139
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude',
140
+ ov: true,
141
+ value: '321'
142
+ }
143
+ ]
144
+ }
145
+ }
146
+ ]
147
+ }
148
+ }
149
+ ];
150
+ beforeEach(function () {
151
+ jest.resetAllMocks();
152
+ });
153
+ it('should work well for Location entities with geolocation attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
154
+ var points;
155
+ return __generator(this, function (_a) {
156
+ switch (_a.label) {
157
+ case 0: return [4 /*yield*/, (0, referenceHelpers_1.getPointsFromReference)(servicesPath, defaultMetadata, defaultEntities)];
158
+ case 1:
159
+ points = _a.sent();
160
+ expect(points[0].id).toBe('entities/111');
161
+ expect(points[0].entity).toEqual(defaultEntities[0]);
162
+ expect(points[0].label).toBe('label');
163
+ expect(points[0].point).toEqual({ lat: 321, lng: 123 });
164
+ return [2 /*return*/];
165
+ }
166
+ });
167
+ }); });
168
+ it('should work well if an attribute has more than one value', function () { return __awaiter(void 0, void 0, void 0, function () {
169
+ var entities, points, lisbonLocation, berlinLocation;
170
+ return __generator(this, function (_a) {
171
+ switch (_a.label) {
172
+ case 0:
173
+ entities = [
174
+ {
175
+ uri: 'entities/111',
176
+ label: 'label',
177
+ attributes: {
178
+ Address: [
179
+ {
180
+ uri: 'entities/111/attributes/Address/222',
181
+ label: 'Lisbon',
182
+ value: {
183
+ GeoLocation: [
184
+ {
185
+ uri: 'entities/111/attributes/Address/222/GeoLocation/333',
186
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation',
187
+ value: {
188
+ Longitude: [
189
+ {
190
+ uri: 'entities/111/attributes/Address/222/GeoLocation/333/Longitude/123',
191
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude',
192
+ value: '123'
193
+ }
194
+ ],
195
+ Latitude: [
196
+ {
197
+ uri: 'entities/111/attributes/Address/222/GeoLocation/333/Latitude/321',
198
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude',
199
+ value: '321'
200
+ }
201
+ ]
202
+ }
203
+ }
204
+ ]
205
+ }
206
+ },
207
+ {
208
+ uri: 'entities/111/attributes/Address/123',
209
+ label: 'Berlin',
210
+ value: {
211
+ GeoLocation: [
212
+ {
213
+ uri: 'entities/111/attributes/Address/123/GeoLocation/444',
214
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation',
215
+ value: {
216
+ Longitude: [
217
+ {
218
+ uri: 'entities/111/attributes/Address/123/GeoLocation/444/Longitude/124',
219
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude',
220
+ value: '124'
221
+ }
222
+ ],
223
+ Latitude: [
224
+ {
225
+ uri: 'entities/111/attributes/Address/123/GeoLocation/444/Latitude/320',
226
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude',
227
+ value: '320'
228
+ }
229
+ ]
230
+ }
231
+ }
232
+ ]
233
+ }
234
+ }
235
+ ]
236
+ },
237
+ type: 'configuration/entityTypes/EntityTypeWithLocationAndAttribute'
238
+ }
239
+ ];
240
+ return [4 /*yield*/, (0, referenceHelpers_1.getPointsFromReference)(servicesPath, defaultMetadata, entities)];
241
+ case 1:
242
+ points = _a.sent();
243
+ expect(points.length).toBe(2);
244
+ lisbonLocation = points[0], berlinLocation = points[1];
245
+ expect(lisbonLocation.label).toBe('Lisbon');
246
+ expect(lisbonLocation.point).toEqual({ lat: 321, lng: 123 });
247
+ expect(berlinLocation.label).toBe('Berlin');
248
+ expect(berlinLocation.point).toEqual({ lat: 320, lng: 124 });
249
+ return [2 /*return*/];
250
+ }
251
+ });
252
+ }); });
253
+ it('should get geo location attributes from geo location section even it is not defined in metadata', function () { return __awaiter(void 0, void 0, void 0, function () {
254
+ var entities, points;
255
+ return __generator(this, function (_a) {
256
+ switch (_a.label) {
257
+ case 0:
258
+ entities = [
259
+ {
260
+ uri: 'entities/111',
261
+ label: 'label',
262
+ attributes: {
263
+ Address: [
264
+ {
265
+ uri: 'entities/111/attributes/Address/123',
266
+ label: 'label',
267
+ value: {
268
+ GeoLocation: [
269
+ {
270
+ uri: 'entities/111/attributes/Address/123/GeoLocation/444',
271
+ type: 'configuration/entityTypes/EntityTypeWithLocation/attributes/Address/attributes/GeoLocation',
272
+ value: {
273
+ Longitude: [
274
+ {
275
+ uri: 'entities/111/attributes/Address/123/GeoLocation/444/Longitude/124',
276
+ type: 'configuration/entityTypes/EntityTypeWithLocation/attributes/Address/attributes/GeoLocation/attributes/Longitude',
277
+ value: '123'
278
+ }
279
+ ],
280
+ Latitude: [
281
+ {
282
+ uri: 'entities/111/attributes/Address/123/GeoLocation/444/Latitude/320',
283
+ type: 'configuration/entityTypes/EntityTypeWithLocation/attributes/Address/attributes/GeoLocation/attributes/Latitude',
284
+ value: '321'
285
+ }
286
+ ]
287
+ }
288
+ }
289
+ ]
290
+ }
291
+ }
292
+ ]
293
+ },
294
+ type: 'configuration/entityTypes/EntityTypeWithLocation'
295
+ }
296
+ ];
297
+ return [4 /*yield*/, (0, referenceHelpers_1.getPointsFromReference)(servicesPath, defaultMetadata, entities)];
298
+ case 1:
299
+ points = _a.sent();
300
+ expect(points[0].id).toBe('entities/111/attributes/Address/123/GeoLocation/444');
301
+ expect(points[0].entity).toEqual(entities[0]);
302
+ expect(points[0].label).toBe('label');
303
+ expect(points[0].point).toEqual({
304
+ id: 'entities/111/attributes/Address/123/GeoLocation/444',
305
+ lat: 321,
306
+ lng: 123
307
+ });
308
+ return [2 /*return*/];
309
+ }
310
+ });
311
+ }); });
312
+ it('should try to resolve it by entity label if there are no geolocation attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
313
+ var entities, points;
314
+ return __generator(this, function (_a) {
315
+ switch (_a.label) {
316
+ case 0:
317
+ entities = [
318
+ {
319
+ label: 'label',
320
+ attributes: {},
321
+ type: 'configuration/entityTypes/Location',
322
+ uri: 'entities/111'
323
+ }
324
+ ];
325
+ mdm_sdk_1.decodeAddress.mockImplementation(function (_a) {
326
+ var address = _a.address;
327
+ if (address === 'label') {
328
+ return Promise.resolve({ success: true, location: { lat: 321, lng: 123 } });
329
+ }
330
+ else {
331
+ return Promise.reject('error');
332
+ }
333
+ });
334
+ return [4 /*yield*/, (0, referenceHelpers_1.getPointsFromReference)(servicesPath, defaultMetadata, entities)];
335
+ case 1:
336
+ points = _a.sent();
337
+ expect(points[0].id).toBe('entities/111');
338
+ expect(points[0].entity).toEqual(entities[0]);
339
+ expect(points[0].label).toBe('label');
340
+ expect(points[0].point).toEqual({ lat: 321, lng: 123 });
341
+ return [2 /*return*/];
342
+ }
343
+ });
344
+ }); });
345
+ it('should not fail if entity type is not found in metadata', function () { return __awaiter(void 0, void 0, void 0, function () {
346
+ var entities, points;
347
+ return __generator(this, function (_a) {
348
+ switch (_a.label) {
349
+ case 0:
350
+ entities = [
351
+ {
352
+ label: 'label',
353
+ attributes: {},
354
+ type: 'configuration/entityTypes/LocationNotFromMD',
355
+ uri: 'entities/111'
356
+ }
357
+ ];
358
+ return [4 /*yield*/, (0, referenceHelpers_1.getPointsFromReference)(servicesPath, defaultMetadata, entities)];
359
+ case 1:
360
+ points = _a.sent();
361
+ expect(points).toEqual([]);
362
+ return [2 /*return*/];
363
+ }
364
+ });
365
+ }); });
366
+ it('should try to resolve it by ref entity label if no geolocation attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
367
+ var entities, points;
368
+ return __generator(this, function (_a) {
369
+ switch (_a.label) {
370
+ case 0:
371
+ entities = [
372
+ {
373
+ uri: 'entities/111',
374
+ label: 'label',
375
+ attributes: {
376
+ Address: [{ label: 'addressLabel', value: {}, uri: 'entities/111/attributes/Address/123' }]
377
+ },
378
+ type: 'configuration/entityTypes/EntityTypeWithLocation'
379
+ }
380
+ ];
381
+ mdm_sdk_1.decodeAddress.mockImplementation(function (_a) {
382
+ var address = _a.address;
383
+ if (address === 'addressLabel') {
384
+ return Promise.resolve({ success: true, location: { lat: 321, lng: 123 } });
385
+ }
386
+ else if (address === 'label') {
387
+ return Promise.resolve({ success: true, location: { lat: 321, lng: 123 } });
388
+ }
389
+ else {
390
+ return Promise.reject('error');
391
+ }
392
+ });
393
+ return [4 /*yield*/, (0, referenceHelpers_1.getPointsFromReference)(servicesPath, defaultMetadata, entities)];
394
+ case 1:
395
+ points = _a.sent();
396
+ expect(points[0].id).toBe('entities/111/attributes/Address/123');
397
+ expect(points[0].entity).toEqual(entities[0]);
398
+ expect(points[0].label).toBe('addressLabel');
399
+ expect(points[0].point).toEqual({ lat: 321, lng: 123 });
400
+ return [2 /*return*/];
401
+ }
402
+ });
403
+ }); });
404
+ it('should work well for Location entities with multiple geolocation attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
405
+ var metadata, entities, points;
406
+ return __generator(this, function (_a) {
407
+ switch (_a.label) {
408
+ case 0:
409
+ metadata = {
410
+ entityTypes: [{ uri: 'configuration/entityTypes/Location', attributes: [] }]
411
+ };
412
+ entities = [
413
+ {
414
+ uri: 'entities/111',
415
+ label: 'label',
416
+ attributes: {
417
+ GeoLocation: [
418
+ {
419
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation',
420
+ uri: 'entities/111/attributes/GeoLocation/111',
421
+ value: {
422
+ Longitude: [
423
+ {
424
+ uri: 'entities/111/attributes/GeoLocation/111/Longitude/222',
425
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude',
426
+ value: '222'
427
+ }
428
+ ],
429
+ Latitude: [
430
+ {
431
+ uri: 'entities/111/attributes/GeoLocation/111/Latitude/111',
432
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude',
433
+ value: '111'
434
+ }
435
+ ]
436
+ }
437
+ },
438
+ {
439
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation',
440
+ uri: 'entities/111/attributes/GeoLocation/222',
441
+ value: {
442
+ Longitude: [
443
+ {
444
+ uri: 'entities/111/attributes/GeoLocation/222/Longitude/444',
445
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude',
446
+ value: '444'
447
+ }
448
+ ],
449
+ Latitude: [
450
+ {
451
+ uri: 'entities/111/attributes/GeoLocation/222/Latitude/333',
452
+ type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude',
453
+ value: '333'
454
+ }
455
+ ]
456
+ }
457
+ }
458
+ ]
459
+ },
460
+ type: 'configuration/entityTypes/Location'
461
+ }
462
+ ];
463
+ return [4 /*yield*/, (0, referenceHelpers_1.getPointsFromReference)(servicesPath, metadata, entities)];
464
+ case 1:
465
+ points = _a.sent();
466
+ expect(points[0].id).toEqual('entities/111/attributes/GeoLocation/111');
467
+ expect(points[0].entity).toEqual(entities[0]);
468
+ expect(points[0].point).toEqual({ id: 'entities/111/attributes/GeoLocation/111', lat: 111, lng: 222 });
469
+ expect(points[1].id).toEqual('entities/111/attributes/GeoLocation/222');
470
+ expect(points[1].entity).toEqual(entities[0]);
471
+ expect(points[1].point).toEqual({ id: 'entities/111/attributes/GeoLocation/222', lat: 333, lng: 444 });
472
+ return [2 /*return*/];
473
+ }
474
+ });
475
+ }); });
476
+ it('should not consider attributes with masking while constructing point', function () { return __awaiter(void 0, void 0, void 0, function () {
477
+ var metadata, points;
478
+ return __generator(this, function (_a) {
479
+ switch (_a.label) {
480
+ case 0:
481
+ metadata = (0, ramda_1.assocPath)(['entityTypes', 0, 'attributes', 0, 'attributes', 0, 'masking'], { regex: '***' }, defaultMetadata);
482
+ return [4 /*yield*/, (0, referenceHelpers_1.getPointsFromReference)(servicesPath, metadata, defaultEntities)];
483
+ case 1:
484
+ points = _a.sent();
485
+ expect(points).toEqual([]);
486
+ return [2 /*return*/];
487
+ }
488
+ });
489
+ }); });
490
+ });
@@ -0,0 +1,8 @@
1
+ import { Entity, GeoPoint, Metadata } from '@reltio/mdm-sdk';
2
+ type Props = {
3
+ servicesPath: string;
4
+ metadata: Metadata;
5
+ entities: Entity[];
6
+ };
7
+ export declare const resolveMarkers: ({ servicesPath, metadata, entities }: Props) => Promise<GeoPoint[]>;
8
+ export {};
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
+ if (ar || !(i in from)) {
41
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
+ ar[i] = from[i];
43
+ }
44
+ }
45
+ return to.concat(ar || Array.prototype.slice.call(from));
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.resolveMarkers = void 0;
49
+ var nestedHelpers_1 = require("./nestedHelpers");
50
+ var referenceHelpers_1 = require("./referenceHelpers");
51
+ var helpers_1 = require("./helpers");
52
+ var resolveMarkers = function (_a) {
53
+ var servicesPath = _a.servicesPath, metadata = _a.metadata, entities = _a.entities;
54
+ return __awaiter(void 0, void 0, void 0, function () {
55
+ var nestedResult, refResult;
56
+ return __generator(this, function (_b) {
57
+ switch (_b.label) {
58
+ case 0:
59
+ nestedResult = (0, nestedHelpers_1.getPointsFromNested)(metadata, entities);
60
+ return [4 /*yield*/, (0, referenceHelpers_1.getPointsFromReference)(servicesPath, metadata, entities)];
61
+ case 1:
62
+ refResult = _b.sent();
63
+ return [2 /*return*/, __spreadArray(__spreadArray([], nestedResult, true), refResult.filter(function (geoPoint) {
64
+ return !nestedResult.some(function (nestedPoint) { return (0, helpers_1.isEqualGeoPoints)(geoPoint, nestedPoint); });
65
+ }), true)];
66
+ }
67
+ });
68
+ });
69
+ };
70
+ exports.resolveMarkers = resolveMarkers;
@@ -0,0 +1,5 @@
1
+ import { Entity, GeoPoint } from '@reltio/mdm-sdk';
2
+ export declare const useMarkers: (entities: Entity[]) => {
3
+ markers: GeoPoint[];
4
+ loading: boolean;
5
+ };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMarkers = void 0;
4
+ var react_1 = require("react");
5
+ var useSafePromise_1 = require("../useSafePromise");
6
+ var MdmModuleContext_1 = require("../../contexts/MdmModuleContext");
7
+ var helpers_1 = require("./helpers");
8
+ var resolveHelpers_1 = require("./resolveHelpers");
9
+ var useMarkers = function (entities) {
10
+ var _a = (0, react_1.useState)([]), markers = _a[0], setMarkers = _a[1];
11
+ var _b = (0, react_1.useState)(false), loading = _b[0], setLoading = _b[1];
12
+ var safePromise = (0, useSafePromise_1.useSafePromise)();
13
+ var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
14
+ var servicesPath = (0, MdmModuleContext_1.useMdmServicesPath)();
15
+ (0, react_1.useEffect)(function () {
16
+ setLoading(true);
17
+ safePromise((0, resolveHelpers_1.resolveMarkers)({ metadata: metadata, servicesPath: servicesPath, entities: entities }))
18
+ .then(function (markers) {
19
+ setMarkers(markers.filter(helpers_1.filterWrongLat));
20
+ })
21
+ .catch(function () {
22
+ setMarkers([]);
23
+ })
24
+ .finally(function () {
25
+ setLoading(false);
26
+ });
27
+ }, [metadata, servicesPath, entities, resolveHelpers_1.resolveMarkers, safePromise]);
28
+ return { markers: markers, loading: loading };
29
+ };
30
+ exports.useMarkers = useMarkers;
@@ -1,4 +1,4 @@
1
1
  export declare const useSavedState: <T>(getSavedState: () => Promise<T>) => {
2
2
  isLoaded: boolean;
3
- savedState: T | Record<string, never>;
3
+ savedState: Record<string, never> | T;
4
4
  };
@@ -1,5 +1,5 @@
1
1
  type SavedState<T> = {
2
- [entityType: string]: T;
2
+ [entityTypeUri: string]: T;
3
3
  };
4
4
  type Props<T> = {
5
5
  getSavedState: () => Promise<SavedState<T>>;
package/cjs/index.d.ts CHANGED
@@ -222,6 +222,7 @@ export { MaskedAttributesProvider, useMaskAttributeValue, useUnmaskAttributeValu
222
222
  export { RowCollapseContext as BasicTableRowCollapseContext } from './contexts/RowCollapseContext';
223
223
  export { BasicTableContext } from './contexts/BasicTableContext';
224
224
  export { HiddenAttributesContext } from './contexts/HiddenAttributesContext';
225
+ export { ProfileTablesContext } from './contexts/ProfileTablesContext';
225
226
  export { useScrollToAttributeError } from './hooks/useScrollToAttributeError';
226
227
  export { useMatchesColumnsData } from './hooks/useMatchesColumnsData';
227
228
  export { useActions } from './hooks/useActions';
@@ -260,7 +261,8 @@ export { useClickableChartStyle as useClickableStyle } from './hooks/useClickabl
260
261
  export { useDynamicRowCellHeight } from './hooks/useDynamicRowCellHeight';
261
262
  export { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
262
263
  export { useMaskedAttribute } from './hooks/useMaskedAttribute';
263
- export { buildColumnsFilter, columnFilterToMdmFilter, defaultGetRowCellHeight, defaultRenderRowCell } from './helpers/basicTable';
264
+ export { useMarkers, resolveMarkers } from './hooks/useMarkers';
265
+ export { buildColumnsFilter, buildColumnsSizeById, columnFilterToMdmFilter, defaultGetRowCellHeight, defaultRenderRowCell } from './helpers/basicTable';
264
266
  export { enrichDataWithPercents } from './helpers/charts';
265
267
  export { showDefaultErrorMessage, showErrorMessage } from './helpers/errors';
266
268
  export { getChecked, getValue, isControlOrCommandPressed } from './helpers/events';
@@ -268,7 +270,8 @@ export { mergeClasses } from './helpers/classes';
268
270
  export type { AttributeFiltersComponentProps } from './AttributesFiltersBuilder';
269
271
  export type { ChartData } from './types/charts';
270
272
  export type { AddInlineAttributeEvent, DeleteInlineAttributeEvent, EditInlineAttributeEvent, IgnoreInlineAttributeEvent, PinInlineAttributeEvent } from './types/inlineAttributes';
271
- export type { ColumnData, ColumnFilter, Sorting, GroupedColumnsData, GroupedColumns, RenderRowCellProps, RowId, ElementsRowsData, TableRowsData, RowValue } from './types/basicTable';
273
+ export type { ColumnData, ColumnSize, ColumnFilter, Sorting, GroupedColumnsData, GroupedColumns, RenderRowCellProps, RowId, ElementsRowsData, TableRowsData, RowValue } from './types/basicTable';
274
+ export * from './types/preferences';
272
275
  export * from './types';
273
276
  export * from './constants';
274
277
  export { TestPerspectivesSettingsProvider } from './test-utils/TestPerspectiveSettingsProvider';