atriusmaps-node-sdk 3.3.632 → 3.3.634
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/LICENSE.md +1 -2
- package/README.md +15 -16
- package/dist/cjs/deploy/prepareSDKConfig.js +73 -57
- package/dist/cjs/nodesdk/nodeEntry.js +51 -44
- package/dist/cjs/package.json.js +4 -1
- package/dist/cjs/plugins/clientAPI/src/clientAPI.js +6 -4
- package/dist/cjs/plugins/dynamicPois/src/dynamicPois.js +32 -26
- package/dist/cjs/plugins/dynamicPois/src/processors.js +41 -35
- package/dist/cjs/plugins/poiDataManager/src/poiDataManager.js +102 -95
- package/dist/cjs/plugins/sdkServer/src/sdkHeadless.js +52 -26
- package/dist/cjs/plugins/sdkServer/src/sdkServer.js +86 -66
- package/dist/cjs/plugins/searchService/src/flexsearchExports/lang.js +16 -16
- package/dist/cjs/plugins/searchService/src/flexsearchExports/simple.js +31 -8
- package/dist/cjs/plugins/searchService/src/poiSearch.js +14 -17
- package/dist/cjs/plugins/searchService/src/searchService.js +41 -39
- package/dist/cjs/plugins/searchService/src/searchTypeahead.js +14 -19
- package/dist/cjs/plugins/searchService/src/utils.js +4 -5
- package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +145 -127
- package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +37 -39
- package/dist/cjs/plugins/wayfinder/src/findRoute.js +11 -18
- package/dist/cjs/plugins/wayfinder/src/minPriorityQueue.js +18 -19
- package/dist/cjs/plugins/wayfinder/src/navGraph.js +111 -91
- package/dist/cjs/plugins/wayfinder/src/navGraphDebug.js +19 -16
- package/dist/cjs/plugins/wayfinder/src/segmentBadges.js +1 -1
- package/dist/cjs/plugins/wayfinder/src/segmentBuilder.js +79 -76
- package/dist/cjs/plugins/wayfinder/src/segmentCategories.js +1 -1
- package/dist/cjs/plugins/wayfinder/src/stepBuilder.js +147 -107
- package/dist/cjs/plugins/wayfinder/src/wayfinder.js +178 -148
- package/dist/cjs/src/app.js +64 -44
- package/dist/cjs/src/configs/postproc-mol-url-parms.js +22 -21
- package/dist/cjs/src/configs/postproc-stateTracking.js +5 -8
- package/dist/cjs/src/controller.js +11 -6
- package/dist/cjs/src/debugTools.js +61 -34
- package/dist/cjs/src/env.js +7 -4
- package/dist/cjs/src/extModules/bustle.js +35 -45
- package/dist/cjs/src/extModules/flexapi/src/help.js +16 -8
- package/dist/cjs/src/extModules/flexapi/src/index.js +39 -18
- package/dist/cjs/src/extModules/flexapi/src/validate.js +129 -87
- package/dist/cjs/src/extModules/geohasher.js +7 -7
- package/dist/cjs/src/extModules/log.js +20 -22
- package/dist/cjs/src/historyManager.js +2 -2
- package/dist/cjs/src/utils/bounds.js +6 -6
- package/dist/cjs/src/utils/buildStructureLookup.js +3 -3
- package/dist/cjs/src/utils/configUtils.js +14 -18
- package/dist/cjs/src/utils/dom.js +12 -18
- package/dist/cjs/src/utils/funcs.js +12 -15
- package/dist/cjs/src/utils/geodesy.js +7 -9
- package/dist/cjs/src/utils/geom.js +52 -40
- package/dist/cjs/src/utils/i18n.js +47 -36
- package/dist/cjs/src/utils/location.js +12 -13
- package/dist/cjs/src/utils/observable.js +27 -28
- package/dist/cjs/src/utils/rand.js +9 -10
- package/dist/package.json.js +1 -1
- package/package.json +1 -1
|
@@ -26,13 +26,13 @@ function _interopNamespaceDefault(e) {
|
|
|
26
26
|
|
|
27
27
|
var R__namespace = /*#__PURE__*/_interopNamespaceDefault(R);
|
|
28
28
|
|
|
29
|
-
function create
|
|
29
|
+
function create(app, config) {
|
|
30
30
|
const state = {
|
|
31
31
|
poiSearch: null,
|
|
32
32
|
typeahead: null,
|
|
33
33
|
indexesCreated: new Zousan(), // re-initialize this when changing venues
|
|
34
34
|
defaultSearchTerms: null,
|
|
35
|
-
specialQueryTerms: {}
|
|
35
|
+
specialQueryTerms: {},
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
const init = async () => {
|
|
@@ -50,7 +50,7 @@ function create (app, config) {
|
|
|
50
50
|
app.bus.on('search/queryNearby', async () => {
|
|
51
51
|
const pois = await searchNearby();
|
|
52
52
|
app.bus.send('search/showNearby', { pois, term: 'Nearby' });
|
|
53
|
-
return pois
|
|
53
|
+
return pois;
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
/**
|
|
@@ -59,14 +59,19 @@ function create (app, config) {
|
|
|
59
59
|
*/
|
|
60
60
|
app.bus.on('search/queryNearbyAsync', searchNearby);
|
|
61
61
|
|
|
62
|
-
async function searchNearby
|
|
62
|
+
async function searchNearby() {
|
|
63
63
|
const startLocation = await app.bus.getFirst('user/getPhysicalLocation');
|
|
64
|
-
if (!startLocation?.floorId) return []
|
|
65
|
-
const poisSameFloor = await app.bus.get('poi/getByFloorId', {
|
|
64
|
+
if (!startLocation?.floorId) return [];
|
|
65
|
+
const poisSameFloor = await app.bus.get('poi/getByFloorId', {
|
|
66
|
+
floorId: startLocation?.floorId,
|
|
67
|
+
});
|
|
66
68
|
const isNotPortal = poi => poi.category.indexOf('portal') === -1 && poi.category !== 'element.door';
|
|
67
69
|
const noPortalPois = Object.values(R__namespace.pickBy(isNotPortal, poisSameFloor));
|
|
68
|
-
const poisWithDistance = await app.bus.get('wayfinder/addPathTimeMultiple', {
|
|
69
|
-
|
|
70
|
+
const poisWithDistance = await app.bus.get('wayfinder/addPathTimeMultiple', {
|
|
71
|
+
pois: noPortalPois,
|
|
72
|
+
startLocation,
|
|
73
|
+
});
|
|
74
|
+
return R__namespace.sortBy(R__namespace.prop('distance'), Object.values(poisWithDistance)).slice(0, 50);
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
/**
|
|
@@ -78,10 +83,9 @@ function create (app, config) {
|
|
|
78
83
|
* @param {string} categoryName - label to display in search results input view
|
|
79
84
|
*/
|
|
80
85
|
app.bus.on('search/queryCategory', async ({ category, categoryName, searchTerm }) => {
|
|
81
|
-
const pois = await state.indexesCreated.then(() =>
|
|
82
|
-
state.poiSearch.search({ query: searchTerm || category }));
|
|
86
|
+
const pois = await state.indexesCreated.then(() => state.poiSearch.search({ query: searchTerm || category }));
|
|
83
87
|
app.bus.send('search/showCategory', { pois, category, categoryName });
|
|
84
|
-
return pois
|
|
88
|
+
return pois;
|
|
85
89
|
});
|
|
86
90
|
|
|
87
91
|
/**
|
|
@@ -95,8 +99,8 @@ function create (app, config) {
|
|
|
95
99
|
return state.indexesCreated.then(() => {
|
|
96
100
|
const pois = state.poiSearch.search({ query: term });
|
|
97
101
|
app.bus.send('search/showSearchResults', { results: pois, term });
|
|
98
|
-
return pois
|
|
99
|
-
})
|
|
102
|
+
return pois;
|
|
103
|
+
});
|
|
100
104
|
});
|
|
101
105
|
|
|
102
106
|
/**
|
|
@@ -106,7 +110,7 @@ function create (app, config) {
|
|
|
106
110
|
* @returns Array.<POI>
|
|
107
111
|
*/
|
|
108
112
|
app.bus.on('search/queryAsync', ({ term }) =>
|
|
109
|
-
state.indexesCreated.then(() => state.poiSearch.search({ query: term }))
|
|
113
|
+
state.indexesCreated.then(() => state.poiSearch.search({ query: term })),
|
|
110
114
|
);
|
|
111
115
|
|
|
112
116
|
/**
|
|
@@ -120,9 +124,9 @@ function create (app, config) {
|
|
|
120
124
|
if (state.specialQueryTerms[term]) {
|
|
121
125
|
const { event, params } = state.specialQueryTerms[term];
|
|
122
126
|
// use "send" as we can't gaurentee this event is a "get" or even returns POIs
|
|
123
|
-
return app.bus.send(event, params)
|
|
127
|
+
return app.bus.send(event, params);
|
|
124
128
|
} else {
|
|
125
|
-
return app.bus.get('search/query', { term })
|
|
129
|
+
return app.bus.get('search/query', { term });
|
|
126
130
|
}
|
|
127
131
|
});
|
|
128
132
|
|
|
@@ -137,18 +141,16 @@ function create (app, config) {
|
|
|
137
141
|
app.bus.on('search/getDefaultSearchTerms', async ({ limit = 5 } = {}) => {
|
|
138
142
|
const defaultSearchTerms = state.defaultSearchTerms;
|
|
139
143
|
const hasDefaultSearchTerms = defaultSearchTerms && defaultSearchTerms.length;
|
|
140
|
-
const keywords = hasDefaultSearchTerms
|
|
141
|
-
? defaultSearchTerms
|
|
142
|
-
: await getUniqueRandomCategories(limit);
|
|
144
|
+
const keywords = hasDefaultSearchTerms ? defaultSearchTerms : await getUniqueRandomCategories(limit);
|
|
143
145
|
app.bus.send('search/showDefaultSearchKeywords', { keywords });
|
|
144
|
-
return keywords
|
|
146
|
+
return keywords;
|
|
145
147
|
});
|
|
146
148
|
|
|
147
|
-
async function getUniqueRandomCategories
|
|
149
|
+
async function getUniqueRandomCategories(limit) {
|
|
148
150
|
const allCategories = (await app.bus.send('poi/getAllCategories'))[0];
|
|
149
151
|
const uniqueCategories = Array.from(new Set(allCategories));
|
|
150
152
|
const shuffledUniqueCategories = rand.randomizeArray(uniqueCategories);
|
|
151
|
-
return shuffledUniqueCategories.slice(0, limit)
|
|
153
|
+
return shuffledUniqueCategories.slice(0, limit);
|
|
152
154
|
}
|
|
153
155
|
|
|
154
156
|
/**
|
|
@@ -161,7 +163,7 @@ function create (app, config) {
|
|
|
161
163
|
const allPois = await app.bus.get('poi/getAll');
|
|
162
164
|
const navigablePred = (val, key) => val.isNavigable;
|
|
163
165
|
const navigablePois = R__namespace.pickBy(navigablePred, allPois);
|
|
164
|
-
return rand.arrayPick(Object.values(navigablePois), limit)
|
|
166
|
+
return rand.arrayPick(Object.values(navigablePois), limit);
|
|
165
167
|
});
|
|
166
168
|
|
|
167
169
|
/**
|
|
@@ -188,8 +190,8 @@ function create (app, config) {
|
|
|
188
190
|
* @param {Array.<string>} keywords - list of new keywords
|
|
189
191
|
*/
|
|
190
192
|
app.bus.on('search/addKeywords', ({ keywords }) =>
|
|
191
|
-
state.indexesCreated.then(() =>
|
|
192
|
-
|
|
193
|
+
state.indexesCreated.then(() => keywords.forEach(keyword => state.typeahead.addKeyword(keyword))),
|
|
194
|
+
);
|
|
193
195
|
|
|
194
196
|
/**
|
|
195
197
|
* Returns lists of keywords and POIs matching search term.
|
|
@@ -202,10 +204,12 @@ function create (app, config) {
|
|
|
202
204
|
* @param {number} limit - maximum number of results
|
|
203
205
|
* @returns {{ pois: Array.<POI>, keywords: Array.<String>, term: string }} - list of keywords, list of POIs, search term
|
|
204
206
|
*/
|
|
205
|
-
app.bus.on('search/typeahead', ({ term, limit }) =>
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
app.bus.on('search/typeahead', ({ term, limit }) =>
|
|
208
|
+
state.indexesCreated.then(() => {
|
|
209
|
+
const { keywords, pois } = state.typeahead.query(term, limit);
|
|
210
|
+
return { keywords, pois, term };
|
|
211
|
+
}),
|
|
212
|
+
);
|
|
209
213
|
|
|
210
214
|
/**
|
|
211
215
|
* Resets plugin state.
|
|
@@ -222,27 +226,25 @@ function create (app, config) {
|
|
|
222
226
|
* @param {Object<string, Object>} - dictionary of POI id to dynamic data object
|
|
223
227
|
*/
|
|
224
228
|
app.bus.on('poi/setDynamicData', async ({ plugin, idValuesMap }) => {
|
|
225
|
-
if (plugin !== 'grab') return
|
|
229
|
+
if (plugin !== 'grab') return;
|
|
226
230
|
|
|
227
|
-
const dynamicPoisPromises = Object.keys(idValuesMap)
|
|
228
|
-
.map(id => app.bus.get('poi/getById', { id }));
|
|
231
|
+
const dynamicPoisPromises = Object.keys(idValuesMap).map(id => app.bus.get('poi/getById', { id }));
|
|
229
232
|
|
|
230
|
-
return Promise.all(dynamicPoisPromises)
|
|
231
|
-
.then(
|
|
232
|
-
|
|
233
|
-
state.poiSearch.updateMultiple(pois)))
|
|
233
|
+
return Promise.all(dynamicPoisPromises).then(pois =>
|
|
234
|
+
state.indexesCreated.then(() => state.poiSearch.updateMultiple(pois)),
|
|
235
|
+
);
|
|
234
236
|
});
|
|
235
237
|
|
|
236
238
|
const runTest = async (initialState, testRoutine) => {
|
|
237
239
|
// state = { ...initialState }
|
|
238
240
|
await testRoutine();
|
|
239
|
-
return state
|
|
241
|
+
return state;
|
|
240
242
|
};
|
|
241
243
|
|
|
242
244
|
return {
|
|
243
245
|
init,
|
|
244
|
-
runTest
|
|
245
|
-
}
|
|
246
|
+
runTest,
|
|
247
|
+
};
|
|
246
248
|
}
|
|
247
249
|
|
|
248
250
|
exports.create = create;
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
var R = require('ramda');
|
|
4
4
|
var utils = require('./utils.js');
|
|
5
5
|
|
|
6
|
-
function createSearchTypeahead
|
|
6
|
+
function createSearchTypeahead(pois, poiSearch, lang) {
|
|
7
7
|
const suggestedKeywordsSearch = createSuggestedKeywordsSearch(pois, lang);
|
|
8
8
|
|
|
9
|
-
function queryPois
|
|
9
|
+
function queryPois(query, limit) {
|
|
10
10
|
const matches = poiSearch({ query, limit });
|
|
11
11
|
const withSuggestions = poiSearch({ query, suggest: true, limit });
|
|
12
12
|
const matchedIds = matches.map(poi => poi.poiId);
|
|
13
13
|
const filteredSuggestions = withSuggestions.filter(poi => matchedIds.indexOf(poi.poiId) === -1);
|
|
14
|
-
return matches.concat(filteredSuggestions)
|
|
14
|
+
return matches.concat(filteredSuggestions);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const query = (query, limit) => {
|
|
@@ -20,46 +20,41 @@ function createSearchTypeahead (pois, poiSearch, lang) {
|
|
|
20
20
|
const shouldQueryPois = !queryLengthUnderLimit && suggestedKeywords.length;
|
|
21
21
|
const poisLimit = limit - suggestedKeywords.length;
|
|
22
22
|
const pois = shouldQueryPois ? queryPois(query, poisLimit) : [];
|
|
23
|
-
return { keywords: suggestedKeywords, pois }
|
|
23
|
+
return { keywords: suggestedKeywords, pois };
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
const addKeyword =
|
|
26
|
+
const addKeyword = keyword => {
|
|
27
27
|
suggestedKeywordsSearch.add(keyword);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
return { query, addKeyword }
|
|
30
|
+
return { query, addKeyword };
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function createSuggestedKeywordsSearch
|
|
33
|
+
function createSuggestedKeywordsSearch(pois, lang) {
|
|
34
34
|
const categories = extractParentCategories(pois);
|
|
35
|
-
const poisKeywords = R.pipe(
|
|
36
|
-
R.values,
|
|
37
|
-
R.chain(R.prop('keywords')),
|
|
38
|
-
R.filter(R.prop('isUserSearchable')),
|
|
39
|
-
R.pluck('name')
|
|
40
|
-
)(pois);
|
|
35
|
+
const poisKeywords = R.pipe(R.values, R.chain(R.prop('keywords')), R.filter(R.prop('isUserSearchable')), R.pluck('name'))(pois);
|
|
41
36
|
const allPotentialKeywords = [...categories, ...poisKeywords];
|
|
42
37
|
const keywords = Array.from(new Set([...allPotentialKeywords]));
|
|
43
38
|
const index = utils.getFlexSearchInstance({ lang, type: 'typeahead' });
|
|
44
39
|
|
|
45
40
|
keywords.forEach((keyword, i) => index.add(i, keyword));
|
|
46
41
|
|
|
47
|
-
const search =
|
|
42
|
+
const search = queryParams => {
|
|
48
43
|
const ids = index.search(queryParams);
|
|
49
|
-
return ids.map(index => keywords[index])
|
|
44
|
+
return ids.map(index => keywords[index]);
|
|
50
45
|
};
|
|
51
|
-
const add =
|
|
46
|
+
const add = newKeyword => {
|
|
52
47
|
keywords.push(newKeyword);
|
|
53
48
|
index.add(keywords.length - 1, newKeyword);
|
|
54
49
|
};
|
|
55
|
-
return { search, add }
|
|
50
|
+
return { search, add };
|
|
56
51
|
}
|
|
57
52
|
|
|
58
|
-
function extractParentCategories
|
|
53
|
+
function extractParentCategories(pois) {
|
|
59
54
|
return Object.values(pois)
|
|
60
55
|
.map(poi => poi.category)
|
|
61
56
|
.map(fullCategory => fullCategory.split('.'))
|
|
62
|
-
.map(subcategories => subcategories[0])
|
|
57
|
+
.map(subcategories => subcategories[0]);
|
|
63
58
|
}
|
|
64
59
|
|
|
65
60
|
module.exports = createSearchTypeahead;
|
|
@@ -12,17 +12,16 @@ const getFlexSearchInstance = ({ lang, type = 'standard' }) => {
|
|
|
12
12
|
stemmer: {
|
|
13
13
|
s: '',
|
|
14
14
|
es: '',
|
|
15
|
-
ies: 'y'
|
|
15
|
+
ies: 'y',
|
|
16
16
|
},
|
|
17
|
-
encode: simple.encode
|
|
17
|
+
encode: simple.encode,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
// Use the full tokenizer for non-ASCII languages and for standard searching
|
|
21
21
|
// but use "forward" for typeahead
|
|
22
|
-
if (NON_ASCII_LANGUAGES.includes(lang))
|
|
23
|
-
options.tokenize = 'full';
|
|
22
|
+
if (NON_ASCII_LANGUAGES.includes(lang)) options.tokenize = 'full';
|
|
24
23
|
|
|
25
|
-
return new FlexSearch.Index(options)
|
|
24
|
+
return new FlexSearch.Index(options);
|
|
26
25
|
};
|
|
27
26
|
|
|
28
27
|
exports.getFlexSearchInstance = getFlexSearchInstance;
|