@blaze-cms/plugin-google-maps-fe 0.123.0-alpha.8 → 0.123.1-alpha.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/CHANGELOG.md +243 -832
- package/lib/GoogleMaps/GoogleMaps.js +68 -40
- package/lib/GoogleMaps/GoogleMaps.js.map +1 -1
- package/lib/GoogleMaps/GoogleMapsFactory.js +8 -4
- package/lib/GoogleMaps/GoogleMapsFactory.js.map +1 -1
- package/lib/GoogleMaps/GoogleMapsRender.js +24 -41
- package/lib/GoogleMaps/GoogleMapsRender.js.map +1 -1
- package/lib/GoogleMaps/helpers/add-zoom-listener.js +3 -50
- package/lib/GoogleMaps/helpers/add-zoom-listener.js.map +1 -1
- package/lib/GoogleMaps/helpers/build-map-shapes.js +97 -0
- package/lib/GoogleMaps/helpers/build-map-shapes.js.map +1 -0
- package/lib/GoogleMaps/helpers/build-query.js +24 -14
- package/lib/GoogleMaps/helpers/build-query.js.map +1 -1
- package/lib/GoogleMaps/helpers/build-shapes-configs.js +196 -0
- package/lib/GoogleMaps/helpers/build-shapes-configs.js.map +1 -0
- package/lib/GoogleMaps/helpers/get-center-coordinates.js +49 -0
- package/lib/GoogleMaps/helpers/get-center-coordinates.js.map +1 -0
- package/lib/GoogleMaps/helpers/get-image-ids.js +16 -14
- package/lib/GoogleMaps/helpers/get-image-ids.js.map +1 -1
- package/lib/GoogleMaps/helpers/index.js +21 -5
- package/lib/GoogleMaps/helpers/index.js.map +1 -1
- package/lib/GoogleMaps/helpers/set-shapes.js +213 -200
- package/lib/GoogleMaps/helpers/set-shapes.js.map +1 -1
- package/lib/GoogleMaps/hooks/use-get-images.js +3 -2
- package/lib/GoogleMaps/hooks/use-get-images.js.map +1 -1
- package/lib/GoogleMaps/queries.js +22 -4
- package/lib/GoogleMaps/queries.js.map +1 -1
- package/lib-es/GoogleMaps/GoogleMaps.js +51 -25
- package/lib-es/GoogleMaps/GoogleMaps.js.map +1 -1
- package/lib-es/GoogleMaps/GoogleMapsFactory.js +10 -6
- package/lib-es/GoogleMaps/GoogleMapsFactory.js.map +1 -1
- package/lib-es/GoogleMaps/GoogleMapsRender.js +24 -32
- package/lib-es/GoogleMaps/GoogleMapsRender.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/add-zoom-listener.js +3 -23
- package/lib-es/GoogleMaps/helpers/add-zoom-listener.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/build-map-shapes.js +86 -0
- package/lib-es/GoogleMaps/helpers/build-map-shapes.js.map +1 -0
- package/lib-es/GoogleMaps/helpers/build-query.js +17 -8
- package/lib-es/GoogleMaps/helpers/build-query.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/build-shapes-configs.js +134 -0
- package/lib-es/GoogleMaps/helpers/build-shapes-configs.js.map +1 -0
- package/lib-es/GoogleMaps/helpers/get-center-coordinates.js +31 -0
- package/lib-es/GoogleMaps/helpers/get-center-coordinates.js.map +1 -0
- package/lib-es/GoogleMaps/helpers/get-image-ids.js +9 -14
- package/lib-es/GoogleMaps/helpers/get-image-ids.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/index.js +4 -2
- package/lib-es/GoogleMaps/helpers/index.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/set-shapes.js +80 -125
- package/lib-es/GoogleMaps/helpers/set-shapes.js.map +1 -1
- package/lib-es/GoogleMaps/hooks/use-get-images.js +4 -3
- package/lib-es/GoogleMaps/hooks/use-get-images.js.map +1 -1
- package/lib-es/GoogleMaps/queries.js +23 -2
- package/lib-es/GoogleMaps/queries.js.map +1 -1
- package/package.json +4 -4
- package/src/GoogleMaps/GoogleMaps.js +40 -27
- package/src/GoogleMaps/GoogleMapsFactory.js +11 -4
- package/src/GoogleMaps/GoogleMapsRender.js +22 -21
- package/src/GoogleMaps/helpers/add-zoom-listener.js +3 -22
- package/src/GoogleMaps/helpers/build-map-shapes.js +70 -0
- package/src/GoogleMaps/helpers/build-query.js +25 -10
- package/src/GoogleMaps/helpers/build-shapes-configs.js +110 -0
- package/src/GoogleMaps/helpers/get-center-coordinates.js +24 -0
- package/src/GoogleMaps/helpers/get-image-ids.js +6 -15
- package/src/GoogleMaps/helpers/index.js +12 -2
- package/src/GoogleMaps/helpers/set-shapes.js +87 -123
- package/src/GoogleMaps/hooks/use-get-images.js +4 -3
- package/src/GoogleMaps/queries.js +30 -3
- package/lib/GoogleMaps/helpers/set-entity-configs.js +0 -144
- package/lib/GoogleMaps/helpers/set-entity-configs.js.map +0 -1
- package/lib-es/GoogleMaps/helpers/set-entity-configs.js +0 -94
- package/lib-es/GoogleMaps/helpers/set-entity-configs.js.map +0 -1
- package/src/GoogleMaps/helpers/set-entity-configs.js +0 -84
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/es.object.define-property.js");
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports["default"] = void 0;
|
|
11
|
-
|
|
12
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
-
|
|
14
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
-
|
|
16
|
-
require("core-js/modules/es.string.trim.js");
|
|
17
|
-
|
|
18
|
-
require("core-js/modules/es.array.reduce.js");
|
|
19
|
-
|
|
20
|
-
require("core-js/modules/es.object.to-string.js");
|
|
21
|
-
|
|
22
|
-
require("core-js/modules/es.array.includes.js");
|
|
23
|
-
|
|
24
|
-
require("core-js/modules/es.string.includes.js");
|
|
25
|
-
|
|
26
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
27
|
-
|
|
28
|
-
require("core-js/modules/es.string.split.js");
|
|
29
|
-
|
|
30
|
-
require("core-js/modules/es.array.concat.js");
|
|
31
|
-
|
|
32
|
-
require("core-js/modules/es.array.map.js");
|
|
33
|
-
|
|
34
|
-
require("core-js/modules/es.array.filter.js");
|
|
35
|
-
|
|
36
|
-
require("core-js/modules/es.object.keys.js");
|
|
37
|
-
|
|
38
|
-
var _lodash = _interopRequireDefault(require("lodash.flatten"));
|
|
39
|
-
|
|
40
|
-
var _constants = require("../../constants");
|
|
41
|
-
|
|
42
|
-
var getPropValues = function getPropValues(properties) {
|
|
43
|
-
return properties.reduce(function (acc, property) {
|
|
44
|
-
if (property.includes('.')) {
|
|
45
|
-
var _property$split = property.split('.'),
|
|
46
|
-
_property$split2 = (0, _slicedToArray2["default"])(_property$split, 2),
|
|
47
|
-
relationName = _property$split2[0],
|
|
48
|
-
relationProp = _property$split2[1];
|
|
49
|
-
|
|
50
|
-
return "".concat(acc, " ").concat(relationName, " { ").concat(relationProp, " }");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return "".concat(acc, " ").concat(property);
|
|
54
|
-
}, '').trim();
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
var buildEntityValues = function buildEntityValues(shapes, dataSummaries) {
|
|
58
|
-
var imageIds = [];
|
|
59
|
-
var dataSummaryProps = dataSummaries.reduce(function (acc, _ref) {
|
|
60
|
-
var propsToDisplay = _ref.propsToDisplay;
|
|
61
|
-
var propsToDisplayValues = (0, _lodash["default"])(propsToDisplay.map(function (_ref2) {
|
|
62
|
-
var propertiesToDisplay = _ref2.propertiesToDisplay;
|
|
63
|
-
return propertiesToDisplay;
|
|
64
|
-
}));
|
|
65
|
-
var propsToDisplayString = getPropValues(propsToDisplayValues);
|
|
66
|
-
return "".concat(acc, " ").concat(propsToDisplayString);
|
|
67
|
-
}, '').trim();
|
|
68
|
-
var propsQuery = dataSummaryProps ? "".concat(dataSummaryProps) : '';
|
|
69
|
-
var ids = shapes.reduce(function (accVal, _ref3) {
|
|
70
|
-
var imageId = _ref3.imageId,
|
|
71
|
-
displayItems = _ref3.displayItems;
|
|
72
|
-
if (displayItems && displayItems.length) accVal.push(displayItems[0]);
|
|
73
|
-
if (imageId) imageIds.push(imageId);
|
|
74
|
-
return accVal;
|
|
75
|
-
}, []);
|
|
76
|
-
return {
|
|
77
|
-
propsQuery: propsQuery,
|
|
78
|
-
ids: ids,
|
|
79
|
-
imageIds: imageIds
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
var getUpdatedPropsQuery = function getUpdatedPropsQuery(propsQuery, entityData) {
|
|
84
|
-
var _entityData$propertie = entityData.properties,
|
|
85
|
-
properties = _entityData$propertie === void 0 ? {} : _entityData$propertie,
|
|
86
|
-
_entityData$dynamicPr = entityData.dynamicProperties,
|
|
87
|
-
dynamicProperties = _entityData$dynamicPr === void 0 ? {} : _entityData$dynamicPr;
|
|
88
|
-
|
|
89
|
-
var _Object$keys$filter = Object.keys(dynamicProperties).filter(function (prop) {
|
|
90
|
-
return prop === _constants.URL;
|
|
91
|
-
}),
|
|
92
|
-
_Object$keys$filter2 = (0, _slicedToArray2["default"])(_Object$keys$filter, 1),
|
|
93
|
-
url = _Object$keys$filter2[0];
|
|
94
|
-
|
|
95
|
-
var hasImage = !!Object.keys(properties).filter(function (prop) {
|
|
96
|
-
return prop === _constants.IMAGE_ID;
|
|
97
|
-
}).length;
|
|
98
|
-
var updatedPropsQuery = hasImage ? "".concat(propsQuery, " ").concat(_constants.IMAGE_ID) : propsQuery;
|
|
99
|
-
updatedPropsQuery = url ? "".concat(updatedPropsQuery, " ").concat(_constants.URL) : updatedPropsQuery;
|
|
100
|
-
return updatedPropsQuery;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
var setEntityConfigs = function setEntityConfigs(schemas, entityGroups) {
|
|
104
|
-
if (!schemas) return {};
|
|
105
|
-
return entityGroups.reduce(function (acc, entityGroup) {
|
|
106
|
-
var entity = entityGroup.entity,
|
|
107
|
-
shapes = entityGroup.shapes,
|
|
108
|
-
_entityGroup$dataSumm = entityGroup.dataSummaries,
|
|
109
|
-
dataSummaries = _entityGroup$dataSumm === void 0 ? [] : _entityGroup$dataSumm;
|
|
110
|
-
|
|
111
|
-
if (entity) {
|
|
112
|
-
var entityData = schemas[entity] || {};
|
|
113
|
-
var actions = entityData.actions;
|
|
114
|
-
var action = actions ? actions.getAllPublished || actions.getAll : '';
|
|
115
|
-
|
|
116
|
-
var _buildEntityValues = buildEntityValues(shapes.filter(Boolean), dataSummaries),
|
|
117
|
-
propsQuery = _buildEntityValues.propsQuery,
|
|
118
|
-
ids = _buildEntityValues.ids,
|
|
119
|
-
imageIds = _buildEntityValues.imageIds;
|
|
120
|
-
|
|
121
|
-
propsQuery = getUpdatedPropsQuery(propsQuery, entityData);
|
|
122
|
-
|
|
123
|
-
if (acc[entity]) {
|
|
124
|
-
propsQuery = "".concat(acc[entity].propsQuery, " ").concat(propsQuery);
|
|
125
|
-
ids = [].concat((0, _toConsumableArray2["default"])(acc[entity].ids), (0, _toConsumableArray2["default"])(ids));
|
|
126
|
-
imageIds = [].concat((0, _toConsumableArray2["default"])(acc[entity].imageIds), (0, _toConsumableArray2["default"])(imageIds));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (ids.length && !propsQuery.includes(_constants.ID)) propsQuery = "".concat(propsQuery.trim(), " ").concat(_constants.ID);
|
|
130
|
-
acc[entity] = {
|
|
131
|
-
propsQuery: propsQuery,
|
|
132
|
-
ids: ids,
|
|
133
|
-
action: action,
|
|
134
|
-
imageIds: imageIds
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return acc;
|
|
139
|
-
}, {});
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
var _default = setEntityConfigs;
|
|
143
|
-
exports["default"] = _default;
|
|
144
|
-
//# sourceMappingURL=set-entity-configs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/GoogleMaps/helpers/set-entity-configs.js"],"names":["getPropValues","properties","reduce","acc","property","includes","split","relationName","relationProp","trim","buildEntityValues","shapes","dataSummaries","imageIds","dataSummaryProps","propsToDisplay","propsToDisplayValues","map","propertiesToDisplay","propsToDisplayString","propsQuery","ids","accVal","imageId","displayItems","length","push","getUpdatedPropsQuery","entityData","dynamicProperties","Object","keys","filter","prop","URL","url","hasImage","IMAGE_ID","updatedPropsQuery","setEntityConfigs","schemas","entityGroups","entityGroup","entity","actions","action","getAllPublished","getAll","Boolean","ID"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAAAC,UAAU;AAAA,SAC9BA,UAAU,CACPC,MADH,CACU,UAACC,GAAD,EAAMC,QAAN,EAAmB;AACzB,QAAIA,QAAQ,CAACC,QAAT,CAAkB,GAAlB,CAAJ,EAA4B;AAC1B,4BAAqCD,QAAQ,CAACE,KAAT,CAAe,GAAf,CAArC;AAAA;AAAA,UAAOC,YAAP;AAAA,UAAqBC,YAArB;;AACA,uBAAUL,GAAV,cAAiBI,YAAjB,gBAAmCC,YAAnC;AACD;;AACD,qBAAUL,GAAV,cAAiBC,QAAjB;AACD,GAPH,EAOK,EAPL,EAQGK,IARH,EAD8B;AAAA,CAAhC;;AAWA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,MAAD,EAASC,aAAT,EAA2B;AACnD,MAAMC,QAAQ,GAAG,EAAjB;AAEA,MAAMC,gBAAgB,GAAGF,aAAa,CACnCV,MADsB,CACf,UAACC,GAAD,QAA6B;AAAA,QAArBY,cAAqB,QAArBA,cAAqB;AACnC,QAAMC,oBAAoB,GAAG,wBAC3BD,cAAc,CAACE,GAAf,CAAmB;AAAA,UAAGC,mBAAH,SAAGA,mBAAH;AAAA,aAA6BA,mBAA7B;AAAA,KAAnB,CAD2B,CAA7B;AAGA,QAAMC,oBAAoB,GAAGnB,aAAa,CAACgB,oBAAD,CAA1C;AAEA,qBAAUb,GAAV,cAAiBgB,oBAAjB;AAC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uCAA2BA,GAA3B,EAAH;AACAR,QAAAA,QAAQ,iDAAOV,GAAG,CAACwC,MAAD,CAAH,CAAY9B,QAAnB,uCAAgCA,QAAhC,EAAR;AACD;;AAED,UAAIQ,GAAG,CAACI,MAAJ,IAAc,CAACL,UAAU,CAACf,QAAX,CAAoB4C,aAApB,CAAnB,EAA4C7B,UAAU,aAAMA,UAAU,CAACX,IAAX,EAAN,cAA2BwC,aAA3B,CAAV;AAE5C9C,MAAAA,GAAG,CAACwC,MAAD,CAAH,GAAc;AACZvB,QAAAA,UAAU,EAAVA,UADY;AAEZC,QAAAA,GAAG,EAAHA,GAFY;AAGZwB,QAAAA,MAAM,EAANA,MAHY;AAIZhC,QAAAA,QAAQ,EAARA;AAJY,OAAd;AAMD;;AACD,WAAOV,GAAP;AACD,GA1BM,EA0BJ,EA1BI,CAAP;AA2BD,CA9BD;;eAgCeoC,gB","sourcesContent":["import flatten from 'lodash.flatten';\nimport { IMAGE_ID, URL, ID } from '../../constants';\n\nconst getPropValues = properties =>\n properties\n .reduce((acc, property) => {\n if (property.includes('.')) {\n const [relationName, relationProp] = property.split('.');\n return `${acc} ${relationName} { ${relationProp} }`;\n }\n return `${acc} ${property}`;\n }, '')\n .trim();\n\nconst buildEntityValues = (shapes, dataSummaries) => {\n const imageIds = [];\n\n const dataSummaryProps = dataSummaries\n .reduce((acc, { propsToDisplay }) => {\n const propsToDisplayValues = flatten(\n propsToDisplay.map(({ propertiesToDisplay }) => propertiesToDisplay)\n );\n const propsToDisplayString = getPropValues(propsToDisplayValues);\n\n return `${acc} ${propsToDisplayString}`;\n }, '')\n .trim();\n\n const propsQuery = dataSummaryProps ? `${dataSummaryProps}` : '';\n\n const ids = shapes.reduce((accVal, { imageId, displayItems }) => {\n if (displayItems && displayItems.length) accVal.push(displayItems[0]);\n if (imageId) imageIds.push(imageId);\n return accVal;\n }, []);\n\n return { propsQuery, ids, imageIds };\n};\n\nconst getUpdatedPropsQuery = (propsQuery, entityData) => {\n const { properties = {}, dynamicProperties = {} } = entityData;\n\n const [url] = Object.keys(dynamicProperties).filter(prop => prop === URL);\n const hasImage = !!Object.keys(properties).filter(prop => prop === IMAGE_ID).length;\n\n let updatedPropsQuery = hasImage ? `${propsQuery} ${IMAGE_ID}` : propsQuery;\n updatedPropsQuery = url ? `${updatedPropsQuery} ${URL}` : updatedPropsQuery;\n\n return updatedPropsQuery;\n};\n\nconst setEntityConfigs = (schemas, entityGroups) => {\n if (!schemas) return {};\n\n return entityGroups.reduce((acc, entityGroup) => {\n const { entity, shapes, dataSummaries = [] } = entityGroup;\n if (entity) {\n const entityData = schemas[entity] || {};\n const { actions } = entityData;\n const action = actions ? actions.getAllPublished || actions.getAll : '';\n\n let { propsQuery, ids, imageIds } = buildEntityValues(shapes.filter(Boolean), dataSummaries);\n propsQuery = getUpdatedPropsQuery(propsQuery, entityData);\n\n if (acc[entity]) {\n propsQuery = `${acc[entity].propsQuery} ${propsQuery}`;\n ids = [...acc[entity].ids, ...ids];\n imageIds = [...acc[entity].imageIds, ...imageIds];\n }\n\n if (ids.length && !propsQuery.includes(ID)) propsQuery = `${propsQuery.trim()} ${ID}`;\n\n acc[entity] = {\n propsQuery,\n ids,\n action,\n imageIds\n };\n }\n return acc;\n }, {});\n};\n\nexport default setEntityConfigs;\n"],"file":"set-entity-configs.js"}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import flatten from 'lodash.flatten';
|
|
2
|
-
import { IMAGE_ID, URL, ID } from '../../constants';
|
|
3
|
-
|
|
4
|
-
const getPropValues = properties => properties.reduce((acc, property) => {
|
|
5
|
-
if (property.includes('.')) {
|
|
6
|
-
const [relationName, relationProp] = property.split('.');
|
|
7
|
-
return `${acc} ${relationName} { ${relationProp} }`;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return `${acc} ${property}`;
|
|
11
|
-
}, '').trim();
|
|
12
|
-
|
|
13
|
-
const buildEntityValues = (shapes, dataSummaries) => {
|
|
14
|
-
const imageIds = [];
|
|
15
|
-
const dataSummaryProps = dataSummaries.reduce((acc, {
|
|
16
|
-
propsToDisplay
|
|
17
|
-
}) => {
|
|
18
|
-
const propsToDisplayValues = flatten(propsToDisplay.map(({
|
|
19
|
-
propertiesToDisplay
|
|
20
|
-
}) => propertiesToDisplay));
|
|
21
|
-
const propsToDisplayString = getPropValues(propsToDisplayValues);
|
|
22
|
-
return `${acc} ${propsToDisplayString}`;
|
|
23
|
-
}, '').trim();
|
|
24
|
-
const propsQuery = dataSummaryProps ? `${dataSummaryProps}` : '';
|
|
25
|
-
const ids = shapes.reduce((accVal, {
|
|
26
|
-
imageId,
|
|
27
|
-
displayItems
|
|
28
|
-
}) => {
|
|
29
|
-
if (displayItems && displayItems.length) accVal.push(displayItems[0]);
|
|
30
|
-
if (imageId) imageIds.push(imageId);
|
|
31
|
-
return accVal;
|
|
32
|
-
}, []);
|
|
33
|
-
return {
|
|
34
|
-
propsQuery,
|
|
35
|
-
ids,
|
|
36
|
-
imageIds
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const getUpdatedPropsQuery = (propsQuery, entityData) => {
|
|
41
|
-
const {
|
|
42
|
-
properties = {},
|
|
43
|
-
dynamicProperties = {}
|
|
44
|
-
} = entityData;
|
|
45
|
-
const [url] = Object.keys(dynamicProperties).filter(prop => prop === URL);
|
|
46
|
-
const hasImage = !!Object.keys(properties).filter(prop => prop === IMAGE_ID).length;
|
|
47
|
-
let updatedPropsQuery = hasImage ? `${propsQuery} ${IMAGE_ID}` : propsQuery;
|
|
48
|
-
updatedPropsQuery = url ? `${updatedPropsQuery} ${URL}` : updatedPropsQuery;
|
|
49
|
-
return updatedPropsQuery;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const setEntityConfigs = (schemas, entityGroups) => {
|
|
53
|
-
if (!schemas) return {};
|
|
54
|
-
return entityGroups.reduce((acc, entityGroup) => {
|
|
55
|
-
const {
|
|
56
|
-
entity,
|
|
57
|
-
shapes,
|
|
58
|
-
dataSummaries = []
|
|
59
|
-
} = entityGroup;
|
|
60
|
-
|
|
61
|
-
if (entity) {
|
|
62
|
-
const entityData = schemas[entity] || {};
|
|
63
|
-
const {
|
|
64
|
-
actions
|
|
65
|
-
} = entityData;
|
|
66
|
-
const action = actions ? actions.getAllPublished || actions.getAll : '';
|
|
67
|
-
let {
|
|
68
|
-
propsQuery,
|
|
69
|
-
ids,
|
|
70
|
-
imageIds
|
|
71
|
-
} = buildEntityValues(shapes.filter(Boolean), dataSummaries);
|
|
72
|
-
propsQuery = getUpdatedPropsQuery(propsQuery, entityData);
|
|
73
|
-
|
|
74
|
-
if (acc[entity]) {
|
|
75
|
-
propsQuery = `${acc[entity].propsQuery} ${propsQuery}`;
|
|
76
|
-
ids = [...acc[entity].ids, ...ids];
|
|
77
|
-
imageIds = [...acc[entity].imageIds, ...imageIds];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (ids.length && !propsQuery.includes(ID)) propsQuery = `${propsQuery.trim()} ${ID}`;
|
|
81
|
-
acc[entity] = {
|
|
82
|
-
propsQuery,
|
|
83
|
-
ids,
|
|
84
|
-
action,
|
|
85
|
-
imageIds
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return acc;
|
|
90
|
-
}, {});
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export default setEntityConfigs;
|
|
94
|
-
//# sourceMappingURL=set-entity-configs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/GoogleMaps/helpers/set-entity-configs.js"],"names":["flatten","IMAGE_ID","URL","ID","getPropValues","properties","reduce","acc","property","includes","relationName","relationProp","split","trim","buildEntityValues","shapes","dataSummaries","imageIds","dataSummaryProps","propsToDisplay","propsToDisplayValues","map","propertiesToDisplay","propsToDisplayString","propsQuery","ids","accVal","imageId","displayItems","length","push","getUpdatedPropsQuery","entityData","dynamicProperties","url","Object","keys","filter","prop","hasImage","updatedPropsQuery","setEntityConfigs","sch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C,gBAAf","sourcesContent":["import flatten from 'lodash.flatten';\nimport { IMAGE_ID, URL, ID } from '../../constants';\n\nconst getPropValues = properties =>\n properties\n .reduce((acc, property) => {\n if (property.includes('.')) {\n const [relationName, relationProp] = property.split('.');\n return `${acc} ${relationName} { ${relationProp} }`;\n }\n return `${acc} ${property}`;\n }, '')\n .trim();\n\nconst buildEntityValues = (shapes, dataSummaries) => {\n const imageIds = [];\n\n const dataSummaryProps = dataSummaries\n .reduce((acc, { propsToDisplay }) => {\n const propsToDisplayValues = flatten(\n propsToDisplay.map(({ propertiesToDisplay }) => propertiesToDisplay)\n );\n const propsToDisplayString = getPropValues(propsToDisplayValues);\n\n return `${acc} ${propsToDisplayString}`;\n }, '')\n .trim();\n\n const propsQuery = dataSummaryProps ? `${dataSummaryProps}` : '';\n\n const ids = shapes.reduce((accVal, { imageId, displayItems }) => {\n if (displayItems && displayItems.length) accVal.push(displayItems[0]);\n if (imageId) imageIds.push(imageId);\n return accVal;\n }, []);\n\n return { propsQuery, ids, imageIds };\n};\n\nconst getUpdatedPropsQuery = (propsQuery, entityData) => {\n const { properties = {}, dynamicProperties = {} } = entityData;\n\n const [url] = Object.keys(dynamicProperties).filter(prop => prop === URL);\n const hasImage = !!Object.keys(properties).filter(prop => prop === IMAGE_ID).length;\n\n let updatedPropsQuery = hasImage ? `${propsQuery} ${IMAGE_ID}` : propsQuery;\n updatedPropsQuery = url ? `${updatedPropsQuery} ${URL}` : updatedPropsQuery;\n\n return updatedPropsQuery;\n};\n\nconst setEntityConfigs = (schemas, entityGroups) => {\n if (!schemas) return {};\n\n return entityGroups.reduce((acc, entityGroup) => {\n const { entity, shapes, dataSummaries = [] } = entityGroup;\n if (entity) {\n const entityData = schemas[entity] || {};\n const { actions } = entityData;\n const action = actions ? actions.getAllPublished || actions.getAll : '';\n\n let { propsQuery, ids, imageIds } = buildEntityValues(shapes.filter(Boolean), dataSummaries);\n propsQuery = getUpdatedPropsQuery(propsQuery, entityData);\n\n if (acc[entity]) {\n propsQuery = `${acc[entity].propsQuery} ${propsQuery}`;\n ids = [...acc[entity].ids, ...ids];\n imageIds = [...acc[entity].imageIds, ...imageIds];\n }\n\n if (ids.length && !propsQuery.includes(ID)) propsQuery = `${propsQuery.trim()} ${ID}`;\n\n acc[entity] = {\n propsQuery,\n ids,\n action,\n imageIds\n };\n }\n return acc;\n }, {});\n};\n\nexport default setEntityConfigs;\n"],"file":"set-entity-configs.js"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import flatten from 'lodash.flatten';
|
|
2
|
-
import { IMAGE_ID, URL, ID } from '../../constants';
|
|
3
|
-
|
|
4
|
-
const getPropValues = properties =>
|
|
5
|
-
properties
|
|
6
|
-
.reduce((acc, property) => {
|
|
7
|
-
if (property.includes('.')) {
|
|
8
|
-
const [relationName, relationProp] = property.split('.');
|
|
9
|
-
return `${acc} ${relationName} { ${relationProp} }`;
|
|
10
|
-
}
|
|
11
|
-
return `${acc} ${property}`;
|
|
12
|
-
}, '')
|
|
13
|
-
.trim();
|
|
14
|
-
|
|
15
|
-
const buildEntityValues = (shapes, dataSummaries) => {
|
|
16
|
-
const imageIds = [];
|
|
17
|
-
|
|
18
|
-
const dataSummaryProps = dataSummaries
|
|
19
|
-
.reduce((acc, { propsToDisplay }) => {
|
|
20
|
-
const propsToDisplayValues = flatten(
|
|
21
|
-
propsToDisplay.map(({ propertiesToDisplay }) => propertiesToDisplay)
|
|
22
|
-
);
|
|
23
|
-
const propsToDisplayString = getPropValues(propsToDisplayValues);
|
|
24
|
-
|
|
25
|
-
return `${acc} ${propsToDisplayString}`;
|
|
26
|
-
}, '')
|
|
27
|
-
.trim();
|
|
28
|
-
|
|
29
|
-
const propsQuery = dataSummaryProps ? `${dataSummaryProps}` : '';
|
|
30
|
-
|
|
31
|
-
const ids = shapes.reduce((accVal, { imageId, displayItems }) => {
|
|
32
|
-
if (displayItems && displayItems.length) accVal.push(displayItems[0]);
|
|
33
|
-
if (imageId) imageIds.push(imageId);
|
|
34
|
-
return accVal;
|
|
35
|
-
}, []);
|
|
36
|
-
|
|
37
|
-
return { propsQuery, ids, imageIds };
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const getUpdatedPropsQuery = (propsQuery, entityData) => {
|
|
41
|
-
const { properties = {}, dynamicProperties = {} } = entityData;
|
|
42
|
-
|
|
43
|
-
const [url] = Object.keys(dynamicProperties).filter(prop => prop === URL);
|
|
44
|
-
const hasImage = !!Object.keys(properties).filter(prop => prop === IMAGE_ID).length;
|
|
45
|
-
|
|
46
|
-
let updatedPropsQuery = hasImage ? `${propsQuery} ${IMAGE_ID}` : propsQuery;
|
|
47
|
-
updatedPropsQuery = url ? `${updatedPropsQuery} ${URL}` : updatedPropsQuery;
|
|
48
|
-
|
|
49
|
-
return updatedPropsQuery;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const setEntityConfigs = (schemas, entityGroups) => {
|
|
53
|
-
if (!schemas) return {};
|
|
54
|
-
|
|
55
|
-
return entityGroups.reduce((acc, entityGroup) => {
|
|
56
|
-
const { entity, shapes, dataSummaries = [] } = entityGroup;
|
|
57
|
-
if (entity) {
|
|
58
|
-
const entityData = schemas[entity] || {};
|
|
59
|
-
const { actions } = entityData;
|
|
60
|
-
const action = actions ? actions.getAllPublished || actions.getAll : '';
|
|
61
|
-
|
|
62
|
-
let { propsQuery, ids, imageIds } = buildEntityValues(shapes.filter(Boolean), dataSummaries);
|
|
63
|
-
propsQuery = getUpdatedPropsQuery(propsQuery, entityData);
|
|
64
|
-
|
|
65
|
-
if (acc[entity]) {
|
|
66
|
-
propsQuery = `${acc[entity].propsQuery} ${propsQuery}`;
|
|
67
|
-
ids = [...acc[entity].ids, ...ids];
|
|
68
|
-
imageIds = [...acc[entity].imageIds, ...imageIds];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (ids.length && !propsQuery.includes(ID)) propsQuery = `${propsQuery.trim()} ${ID}`;
|
|
72
|
-
|
|
73
|
-
acc[entity] = {
|
|
74
|
-
propsQuery,
|
|
75
|
-
ids,
|
|
76
|
-
action,
|
|
77
|
-
imageIds
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
return acc;
|
|
81
|
-
}, {});
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export default setEntityConfigs;
|