atriusmaps-node-sdk 3.3.990 → 3.3.991

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "3.3.990";
5
+ var version = "3.3.991";
6
6
  var pkg = {
7
7
  version: version};
8
8
 
@@ -0,0 +1,157 @@
1
+ 'use strict';
2
+
3
+ require('luxon');
4
+ var R = require('ramda');
5
+
6
+ function _interopNamespaceDefault(e) {
7
+ var n = Object.create(null);
8
+ if (e) {
9
+ Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default') {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n.default = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ var R__namespace = /*#__PURE__*/_interopNamespaceDefault(R);
24
+
25
+ function isOpen(weekdayPeriods, today) {
26
+ const currentWeekday = findWeekday(weekdayPeriods, today);
27
+ if (!currentWeekday) {
28
+ return false;
29
+ }
30
+ const hours = today.getHours();
31
+ const minutes = today.getMinutes();
32
+ const { from, to } = currentWeekday.timePeriod;
33
+ return isInTimePeriod(hours, minutes, from.hours, from.minutes, to.hours, to.minutes);
34
+ }
35
+ function isInTimePeriod(nowHours, nowMinutes, fromHours, fromMinutes, toHours, toMinutes) {
36
+ const isOvernightPeriod = isFirstTimeAfterSecond(fromHours, fromMinutes, toHours, toMinutes);
37
+ if (isOvernightPeriod) {
38
+ return isInTimePeriod(nowHours, nowMinutes, fromHours, fromMinutes, 24, 0) || isInTimePeriod(nowHours, nowMinutes, 0, 0, toHours, toMinutes);
39
+ } else {
40
+ const isAfterFrom = isFirstTimeAfterSecond(nowHours, nowMinutes, fromHours, fromMinutes);
41
+ const isBeforeTo = isFirstTimeAfterSecond(toHours, toMinutes, nowHours, nowMinutes);
42
+ return isAfterFrom && isBeforeTo;
43
+ }
44
+ }
45
+ function isFirstTimeAfterSecond(firstHours, firstMinutes, secondHours, secondMinutes) {
46
+ return firstHours > secondHours || firstHours === secondHours && firstMinutes >= secondMinutes;
47
+ }
48
+ function findWeekday(weekdayPeriods, today) {
49
+ return findWeekdayByDayIndex(weekdayPeriods, today.getDay());
50
+ }
51
+ function findWeekdayByDayIndex(weekdayPeriods, index) {
52
+ const currentWeekdayName = WEEKDAY_ARRAY[index];
53
+ return weekdayPeriods.find(({ weekday }) => weekday === currentWeekdayName);
54
+ }
55
+ function parseAndOrderWeekdays(rawWeekdayPeriods, today) {
56
+ const weekdays = parseWeekdayPeriods(rawWeekdayPeriods);
57
+ const orderedWeekdays = orderFromSunday(weekdays);
58
+ return markCurrentWeekday(orderedWeekdays, today);
59
+ }
60
+ const SHORT_WEEKDAY_TO_NUMERAL = {
61
+ Su: 0,
62
+ Mo: 1,
63
+ Tu: 2,
64
+ We: 3,
65
+ Th: 4,
66
+ Fr: 5,
67
+ Sa: 6
68
+ };
69
+ const WEEKDAY_ARRAY = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
70
+ const WEEKDAY_TO_NUMERAL = WEEKDAY_ARRAY.reduce(
71
+ (obj, weekday, index) => Object.assign(obj, { [weekday]: index }),
72
+ {}
73
+ );
74
+ const WEEKDAYS_DELIMITER = ";";
75
+ const WEEKDAY_AND_TIME_DELIMITER = /\s+/;
76
+ const WEEKDAY_DELIMITER = "-";
77
+ const TIME_PERIOD_DELIMITER = "-";
78
+ const TIME_DELIMITER = ":";
79
+ const AM = " AM";
80
+ const PM = " PM";
81
+ function parseWeekdayPeriods(rawWeekdayPeriods) {
82
+ return rawWeekdayPeriods.split(WEEKDAYS_DELIMITER).map((weekdayAndTimePeriod) => weekdayAndTimePeriod.trim()).map((weekdayAndTimePeriod) => weekdayAndTimePeriod.split(WEEKDAY_AND_TIME_DELIMITER)).flatMap(([weekdayPeriod, timePeriod]) => {
83
+ const weekdays = parseWeekdayPeriod(weekdayPeriod);
84
+ const formattedTimePeriod = prepareTimePeriodData(timePeriod);
85
+ return createWeekdayAndTimePeriodPairs(weekdays, formattedTimePeriod);
86
+ });
87
+ }
88
+ function parseWeekdayPeriod(weekdayPeriod) {
89
+ const [start, end] = weekdayPeriod.split(WEEKDAY_DELIMITER);
90
+ const startIndex = SHORT_WEEKDAY_TO_NUMERAL[start];
91
+ let weekdayIndices;
92
+ if (end) {
93
+ const endIndex = SHORT_WEEKDAY_TO_NUMERAL[end];
94
+ weekdayIndices = weekdayIndicesRange(startIndex, endIndex);
95
+ } else {
96
+ weekdayIndices = [startIndex];
97
+ }
98
+ return weekdayIndices.map((index) => WEEKDAY_ARRAY[index]);
99
+ }
100
+ function weekdayIndicesRange(startIndex, endIndex) {
101
+ const weekdayIndices = [startIndex];
102
+ let currentDayIndex = startIndex;
103
+ do {
104
+ currentDayIndex = (currentDayIndex + 1) % WEEKDAY_ARRAY.length;
105
+ weekdayIndices.push(currentDayIndex);
106
+ } while (currentDayIndex !== endIndex);
107
+ return weekdayIndices;
108
+ }
109
+ function prepareTimePeriodData(timePeriod) {
110
+ const [from, to] = timePeriod.split(TIME_PERIOD_DELIMITER);
111
+ const [fromTime, fromTimeFormatted] = getHoursMinutesAndFormatted(from);
112
+ const [toTime, toTimeFormatted] = getHoursMinutesAndFormatted(to);
113
+ const timePeriodFormatted = fromTimeFormatted + ` ${TIME_PERIOD_DELIMITER} ` + toTimeFormatted;
114
+ return {
115
+ from: fromTime,
116
+ to: toTime,
117
+ formatted: timePeriodFormatted
118
+ };
119
+ }
120
+ function getHoursMinutesAndFormatted(time) {
121
+ const [hours, minutes] = time.split(TIME_DELIMITER);
122
+ const timeFormatted = formatTimeAmPm(+hours, +minutes);
123
+ return [{ hours: +hours, minutes: +minutes }, timeFormatted];
124
+ }
125
+ function formatTimeAmPm(hours, minutes) {
126
+ const ampm = hours < 12 || hours === 24 ? AM : PM;
127
+ const h = hours % 12 || 12;
128
+ const minutesStr = minutes > 9 ? minutes : "0" + minutes;
129
+ return h + TIME_DELIMITER + minutesStr + ampm;
130
+ }
131
+ function createWeekdayAndTimePeriodPairs(weekdays, timePeriod) {
132
+ return weekdays.map((weekday) => ({ weekday, timePeriod }));
133
+ }
134
+ function orderFromSunday(weekdayPeriods) {
135
+ const startWeekdayIndex = 0;
136
+ const orderedWeekdays = [];
137
+ weekdayPeriods.forEach((weekday) => {
138
+ const weekdayIndex = WEEKDAY_TO_NUMERAL[weekday.weekday];
139
+ let order = weekdayIndex - startWeekdayIndex;
140
+ if (order < 0) {
141
+ order += WEEKDAY_ARRAY.length;
142
+ }
143
+ orderedWeekdays[order] = weekday;
144
+ });
145
+ return filterEmptyDays(orderedWeekdays);
146
+ }
147
+ function filterEmptyDays(weekdays) {
148
+ return weekdays.filter((x) => !!x);
149
+ }
150
+ function markCurrentWeekday(weekdays, today) {
151
+ const todayDayName = WEEKDAY_ARRAY[today.getDay()];
152
+ const addIsToday = R__namespace.converge(R__namespace.assoc("isToday"), [R__namespace.propEq(todayDayName, "weekday"), R__namespace.identity]);
153
+ return weekdays.map(addIsToday);
154
+ }
155
+
156
+ exports.isOpen = isOpen;
157
+ exports.parseAndOrderWeekdays = parseAndOrderWeekdays;
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var weekdayPeriodsParser = require('../../online/poiView/src/weekdayPeriodsParser.js');
4
+
5
+ function computeIsOpenNow(poi, today = /* @__PURE__ */ new Date()) {
6
+ if (poi.state === "permanently-closed") {
7
+ return false;
8
+ }
9
+ const dynamicOC = poi.dynamicData?.["open-closed-status"];
10
+ if (dynamicOC && dynamicOC.expiration > Date.now()) {
11
+ return dynamicOC.isOpen;
12
+ }
13
+ if (poi.operationHours) {
14
+ try {
15
+ const weekdayPeriods = weekdayPeriodsParser.parseAndOrderWeekdays(poi.operationHours, today);
16
+ if (!weekdayPeriods || weekdayPeriods.length === 0) {
17
+ return true;
18
+ }
19
+ return weekdayPeriodsParser.isOpen(weekdayPeriods, today);
20
+ } catch (err) {
21
+ console.warn(`computeIsOpenNow: failed to parse operationHours for POI (hours: "${poi.operationHours}")`, err);
22
+ return true;
23
+ }
24
+ }
25
+ return true;
26
+ }
27
+
28
+ exports.computeIsOpenNow = computeIsOpenNow;
@@ -5,6 +5,7 @@ var Zousan = require('zousan');
5
5
  var buildStructureLookup = require('../../../src/utils/buildStructureLookup.js');
6
6
  var configUtils = require('../../../src/utils/configUtils.js');
7
7
  var i18n = require('../../../src/utils/i18n.js');
8
+ var computeIsOpenNow = require('./computeIsOpenNow.js');
8
9
 
9
10
  function _interopNamespaceDefault(e) {
10
11
  var n = Object.create(null);
@@ -157,6 +158,9 @@ async function create(app) {
157
158
  }
158
159
  pois = filterBadPois(pois);
159
160
  await enhanceImages(pois);
161
+ Object.values(pois).forEach((poi) => {
162
+ poi.isOpenNow = computeIsOpenNow.computeIsOpenNow(poi);
163
+ });
160
164
  poisLoaded.resolve(pois);
161
165
  if (app.config.debug && app.env.isBrowser) {
162
166
  window._pois = pois;
@@ -260,6 +264,13 @@ async function create(app) {
260
264
  const newPoi = R__namespace.mergeRight(pois[poiId], { dynamicData });
261
265
  pois[poiId] = newPoi;
262
266
  }
267
+ if (plugin === "open-closed-status") {
268
+ Object.keys(idValuesMap).forEach((poiId) => {
269
+ if (pois[poiId]) {
270
+ pois[poiId].isOpenNow = computeIsOpenNow.computeIsOpenNow(pois[poiId]);
271
+ }
272
+ });
273
+ }
263
274
  });
264
275
  });
265
276
  app.bus.on("poi/setCoreAttributes", (idAttributesMap) => {
@@ -69,9 +69,10 @@ function create(app, config) {
69
69
  app.bus.send("search/showCategory", { pois, category, categoryName });
70
70
  return pois;
71
71
  });
72
- app.bus.on("search/query", ({ term }) => {
72
+ app.bus.on("search/query", ({ term, openNow }) => {
73
73
  return state.indexesCreated.then(() => {
74
- const pois = state.poiSearch.search({ query: term });
74
+ const allResults = state.poiSearch.search({ query: term });
75
+ const pois = openNow === true ? allResults.filter((poi) => poi.isOpenNow !== false) : allResults;
75
76
  app.bus.send("search/showSearchResults", { results: pois, term });
76
77
  return pois;
77
78
  });
@@ -121,8 +122,9 @@ function create(app, config) {
121
122
  );
122
123
  app.bus.on(
123
124
  "search/typeahead",
124
- ({ term, limit }) => state.indexesCreated.then(() => {
125
- const { keywords, pois } = state.typeahead.query(term, limit);
125
+ ({ term, limit, openNow }) => state.indexesCreated.then(() => {
126
+ const { keywords, pois: allPois } = state.typeahead.query(term, limit);
127
+ const pois = openNow === true ? allPois.filter((poi) => poi.isOpenNow !== false) : allPois;
126
128
  return { keywords, pois, term };
127
129
  })
128
130
  );
@@ -1 +1 @@
1
- var a="3.3.990",e={version:a};export{e as default,a as version};
1
+ var a="3.3.991",e={version:a};export{e as default,a as version};
@@ -0,0 +1 @@
1
+ import"luxon";import*as t from"ramda";function n(t,n){const e=function(t,n){return function(t,n){const r=i[n];return t.find(({weekday:t})=>t===r)}(t,n.getDay())}(t,n);if(!e)return!1;const o=n.getHours(),u=n.getMinutes(),{from:s,to:c}=e.timePeriod;return r(o,u,s.hours,s.minutes,c.hours,c.minutes)}function r(t,n,o,u,i,s){if(e(o,u,i,s))return r(t,n,o,u,24,0)||r(t,n,0,0,i,s);{const r=e(t,n,o,u),c=e(i,s,t,n);return r&&c}}function e(t,n,r,e){return t>r||t===r&&n>=e}function o(n,r){const e=function(t){return t.split(c).map(t=>t.trim()).map(t=>t.split(a)).flatMap(([t,n])=>{const r=function(t){const[n,r]=t.split(f),e=u[n];let o;if(r){o=function(t,n){const r=[t];let e=t;do{e=(e+1)%i.length,r.push(e)}while(e!==n);return r}(e,u[r])}else o=[e];return o.map(t=>i[t])}(t),e=function(t){const[n,r]=t.split(d),[e,o]=y(n),[u,i]=y(r);return{from:e,to:u,formatted:o+` ${d} `+i}}(n);return function(t,n){return t.map(t=>({weekday:t,timePeriod:n}))}(r,e)})}(n),o=function(t){const n=0,r=[];return t.forEach(t=>{let e=s[t.weekday]-n;e<0&&(e+=i.length),r[e]=t}),function(t){return t.filter(t=>!!t)}(r)}(e);return function(n,r){const e=i[r.getDay()],o=t.converge(t.assoc("isToday"),[t.propEq(e,"weekday"),t.identity]);return n.map(o)}(o,r)}const u={Su:0,Mo:1,Tu:2,We:3,Th:4,Fr:5,Sa:6},i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],s=i.reduce((t,n,r)=>Object.assign(t,{[n]:r}),{}),c=";",a=/\s+/,f="-",d="-",m=":",p=" AM",l=" PM";function y(t){const[n,r]=t.split(m),e=function(t,n){const r=t<12||24===t?p:l,e=t%12||12,o=n>9?n:"0"+n;return e+m+o+r}(+n,+r);return[{hours:+n,minutes:+r},e]}export{n as isOpen,o as parseAndOrderWeekdays};
@@ -0,0 +1 @@
1
+ import{parseAndOrderWeekdays as e,isOpen as o}from"../../online/poiView/src/weekdayPeriodsParser.js";function r(r,t=new Date){if("permanently-closed"===r.state)return!1;const n=r.dynamicData?.["open-closed-status"];if(n&&n.expiration>Date.now())return n.isOpen;if(r.operationHours)try{const n=e(r.operationHours,t);return!n||0===n.length||o(n,t)}catch(e){return console.warn(`computeIsOpenNow: failed to parse operationHours for POI (hours: "${r.operationHours}")`,e),!0}return!0}export{r as computeIsOpenNow};
@@ -1 +1 @@
1
- import*as e from"ramda";import o from"zousan";import{buildStructuresLookup as t}from"../../../src/utils/buildStructureLookup.js";import{debugIsTrue as a}from"../../../src/utils/configUtils.js";import{toLang as i}from"../../../src/utils/i18n.js";async function n(i){const n=i.log.sublog("poiDataManager"),u=()=>{i.bus.send("venueData/loadPoiData")};let p=new o;const d=(e,o)=>{const{position:t}=e,a=o.floorIdToStructure(t.floorId);if(!a)return n.error(`No structure found for floorId: ${t.floorId} for POI ${e.poiId}`),{...e};const i=o.floorIdToFloor(t.floorId),r={...t,structureName:a.name,buildingId:a.id,floorName:i.name,floorOrdinal:i.ordinal};return{...e,position:r}},l=(e,o)=>{e.roomInfo||(e.roomInfo=[]),e.roomInfo.push(o)},c=e.pipe(e.propOr([],"externalIds"),e.find(e.propEq("roomId","type")),e.prop("id"),e.unless(e.isNil,e.tail));i.bus.on("venueData/poiDataLoaded",async({pois:o,structures:r})=>{if(o=((o,t)=>e.pipe(e.values,e.map(e=>{e.distance=null,e.staticName=e.name,e.isNavigable=void 0===e.isNavigable||!0===e.isNavigable,e.capacity&&l(e,{name:`Seats ${e.capacity.join("-")}`,svgId:"number-of-seats"}),e.category.startsWith("meeting")&&l(e,{name:i.gt()("poiView:Conference Room"),svgId:"conference-room"});const o=c(e);return o&&(e.roomId=o),[e.poiId,d(e,t)]}),e.fromPairs)(o))(o,t(r)),a(i,"pseudoTransPois"))for(const e in o)o[e]=s(o[e],i.i18n().language);o=function(e){const o=[];return Object.values(e).forEach(e=>{try{const t=e.position;t?["buildingId","structureName","floorId","floorName","floorOrdinal","latitude","longitude"].forEach(a=>{null!==t[a]&&void 0!==t[a]||o.push({id:e.poiId,e:`invalid position property: ${a}: ${t[a]}`})}):o.push({poi:e,e:"No position information"})}catch(t){n.error(t),o.push({id:e.poiId,e:t.message})}}),o.length&&(n.warn("badPois:",o),o.forEach(o=>{delete e[o.id]})),e}(o),await async function(e){for(const o of Object.values(e))await I(o);return e}(o),p.resolve(o),i.config.debug&&i.env.isBrowser&&(window._pois=o),i.config.debug&&async function(e){const o=Date.now(),t=[],a=await i.bus.get("wayfinder/_getNavGraph");Object.values(e).forEach(e=>{try{const o=e.position;a.findClosestNode(o.floorId,o.latitude,o.longitude)||t.push({id:e.poiId,e:"No closest Navgraph Node"})}catch(o){n.error(o),t.push({id:e.poiId,e:o.message})}}),t.length&&n.warn("badPois:",t),n(`Total time for navgraph POI check: ${Date.now()-o}ms`)}(o)}),i.bus.on("poi/getById",async({id:e})=>p.then(o=>o[e])),i.bus.on("poi/getByFloorId",async({floorId:o})=>p.then(e.pickBy(e.pathEq(o,["position","floorId"])))),i.bus.on("poi/getByCategoryId",async({categoryId:o})=>p.then(e.pickBy(e=>e.category===o||e.category.startsWith(o+".")))),i.bus.on("poi/getAll",async()=>p);const m=["queue","primaryQueueId"],f=(o,t,a)=>{const i=e.path(["queue","queueType"],t);if(!i)return null;const n=o[i],r=e.path(m,t);return a.filter(e.pathEq(r,m)).filter(e=>e.poiId!==t.poiId).map(o=>{const t=e.path(["queue","queueSubtype"],o),a=g(t)(n);return{poiId:o.poiId,...a}})},g=o=>{return e.pipe(e.find(e.propEq(o,"id")),(t=`No queue found with ID: ${o}`,e=>{if(null!=e)return e;throw Error(t)}),e.pick(["displayText","imageId"]));var t};i.bus.on("poi/addOtherSecurityLanes",({poi:o})=>(async o=>{if(!e.path(m,o))return o;const t=await i.bus.get("venueData/getQueueTypes"),a=await i.bus.get("poi/getByCategoryId",{categoryId:"security"}),n=Object.values(a);return o.queue.otherQueues=f(t,o,n),o})(o));const y=e=>!!e?.startsWith("https:");async function I(t){if(!t)return;const a="undefined"==typeof window?1:window.devicePixelRatio||1,n=`${Math.round(351*a)}x${Math.round(197*a)}`;return e.length(t.images)?y(t.images[0])||(t.images=await o.all(t.images.map(e=>i.bus.get("venueData/getPoiImageUrl",{imageName:e,size:n})))):t.images=[],e.length(t.fullImages)?y(t.fullImages[0]?.url)||(t.fullImages=await o.all(t.fullImages.map(async({url:e,...o})=>({url:await i.bus.get("venueData/getPoiImageUrl",{imageName:e,size:n}),...o})))):t.fullImages=[],t}const h=e.memoizeWith(e.identity,e.pipe(e.pluck("category"),e.values,e.uniq));i.bus.on("poi/getAllCategories",async()=>p.then(h)),i.bus.on("venueData/loadNewVenue",()=>{p=new o,u()}),i.bus.on("poi/setDynamicData",({plugin:o,idValuesMap:t})=>{p.then(a=>{for(const i in t){const n=a[i].dynamicData||{};n[o]={...t[i]};const r=e.mergeRight(a[i],{dynamicData:n});a[i]=r}})}),i.bus.on("poi/setCoreAttributes",e=>{p.then(o=>{const t=[];for(const a in e){r(o,a,e[a]?.name)&&(i.bus.send("map/mutateFeature",{poiId:a,name:o[a].name}),t.push(o[a]))}t.length>0&&i.bus.send("poi/updated",{pois:t})})});return{init:u,runTest:async e=>(await e(),p),internal:{addImages:I,pseudoTransPoi:s,applyPoiNameOverride:r}}}function r(e,o,t){return!!e[o]&&(e[o].name=t||e[o].staticName,!0)}function s(e,o){return["description","nearbyLandmark","name","phone","operationHours"].forEach(t=>{e[t]&&(e[t]=i(e[t],o))}),e.keywords&&(e.keywords=e.keywords.map(e=>(e.name=i(e.name,o),e))),e.position.floorName&&(e.position.floorName=i(e.position.floorName,o)),e.position.structureName&&(e.position.structureName=i(e.position.structureName,o)),e}export{r as applyPoiNameOverride,n as create};
1
+ import*as e from"ramda";import o from"zousan";import{buildStructuresLookup as t}from"../../../src/utils/buildStructureLookup.js";import{debugIsTrue as a}from"../../../src/utils/configUtils.js";import{toLang as i}from"../../../src/utils/i18n.js";import{computeIsOpenNow as n}from"./computeIsOpenNow.js";async function r(i){const r=i.log.sublog("poiDataManager"),p=()=>{i.bus.send("venueData/loadPoiData")};let c=new o;const d=(e,o)=>{const{position:t}=e,a=o.floorIdToStructure(t.floorId);if(!a)return r.error(`No structure found for floorId: ${t.floorId} for POI ${e.poiId}`),{...e};const i=o.floorIdToFloor(t.floorId),n={...t,structureName:a.name,buildingId:a.id,floorName:i.name,floorOrdinal:i.ordinal};return{...e,position:n}},l=(e,o)=>{e.roomInfo||(e.roomInfo=[]),e.roomInfo.push(o)},m=e.pipe(e.propOr([],"externalIds"),e.find(e.propEq("roomId","type")),e.prop("id"),e.unless(e.isNil,e.tail));i.bus.on("venueData/poiDataLoaded",async({pois:o,structures:s})=>{if(o=((o,t)=>e.pipe(e.values,e.map(e=>{e.distance=null,e.staticName=e.name,e.isNavigable=void 0===e.isNavigable||!0===e.isNavigable,e.capacity&&l(e,{name:`Seats ${e.capacity.join("-")}`,svgId:"number-of-seats"}),e.category.startsWith("meeting")&&l(e,{name:i.gt()("poiView:Conference Room"),svgId:"conference-room"});const o=m(e);return o&&(e.roomId=o),[e.poiId,d(e,t)]}),e.fromPairs)(o))(o,t(s)),a(i,"pseudoTransPois"))for(const e in o)o[e]=u(o[e],i.i18n().language);o=function(e){const o=[];return Object.values(e).forEach(e=>{try{const t=e.position;t?["buildingId","structureName","floorId","floorName","floorOrdinal","latitude","longitude"].forEach(a=>{null!==t[a]&&void 0!==t[a]||o.push({id:e.poiId,e:`invalid position property: ${a}: ${t[a]}`})}):o.push({poi:e,e:"No position information"})}catch(t){r.error(t),o.push({id:e.poiId,e:t.message})}}),o.length&&(r.warn("badPois:",o),o.forEach(o=>{delete e[o.id]})),e}(o),await async function(e){for(const o of Object.values(e))await h(o);return e}(o),Object.values(o).forEach(e=>{e.isOpenNow=n(e)}),c.resolve(o),i.config.debug&&i.env.isBrowser&&(window._pois=o),i.config.debug&&async function(e){const o=Date.now(),t=[],a=await i.bus.get("wayfinder/_getNavGraph");Object.values(e).forEach(e=>{try{const o=e.position;a.findClosestNode(o.floorId,o.latitude,o.longitude)||t.push({id:e.poiId,e:"No closest Navgraph Node"})}catch(o){r.error(o),t.push({id:e.poiId,e:o.message})}}),t.length&&r.warn("badPois:",t),r(`Total time for navgraph POI check: ${Date.now()-o}ms`)}(o)}),i.bus.on("poi/getById",async({id:e})=>c.then(o=>o[e])),i.bus.on("poi/getByFloorId",async({floorId:o})=>c.then(e.pickBy(e.pathEq(o,["position","floorId"])))),i.bus.on("poi/getByCategoryId",async({categoryId:o})=>c.then(e.pickBy(e=>e.category===o||e.category.startsWith(o+".")))),i.bus.on("poi/getAll",async()=>c);const f=["queue","primaryQueueId"],g=(o,t,a)=>{const i=e.path(["queue","queueType"],t);if(!i)return null;const n=o[i],r=e.path(f,t);return a.filter(e.pathEq(r,f)).filter(e=>e.poiId!==t.poiId).map(o=>{const t=e.path(["queue","queueSubtype"],o),a=y(t)(n);return{poiId:o.poiId,...a}})},y=o=>{return e.pipe(e.find(e.propEq(o,"id")),(t=`No queue found with ID: ${o}`,e=>{if(null!=e)return e;throw Error(t)}),e.pick(["displayText","imageId"]));var t};i.bus.on("poi/addOtherSecurityLanes",({poi:o})=>(async o=>{if(!e.path(f,o))return o;const t=await i.bus.get("venueData/getQueueTypes"),a=await i.bus.get("poi/getByCategoryId",{categoryId:"security"}),n=Object.values(a);return o.queue.otherQueues=g(t,o,n),o})(o));const I=e=>!!e?.startsWith("https:");async function h(t){if(!t)return;const a="undefined"==typeof window?1:window.devicePixelRatio||1,n=`${Math.round(351*a)}x${Math.round(197*a)}`;return e.length(t.images)?I(t.images[0])||(t.images=await o.all(t.images.map(e=>i.bus.get("venueData/getPoiImageUrl",{imageName:e,size:n})))):t.images=[],e.length(t.fullImages)?I(t.fullImages[0]?.url)||(t.fullImages=await o.all(t.fullImages.map(async({url:e,...o})=>({url:await i.bus.get("venueData/getPoiImageUrl",{imageName:e,size:n}),...o})))):t.fullImages=[],t}const b=e.memoizeWith(e.identity,e.pipe(e.pluck("category"),e.values,e.uniq));i.bus.on("poi/getAllCategories",async()=>c.then(b)),i.bus.on("venueData/loadNewVenue",()=>{c=new o,p()}),i.bus.on("poi/setDynamicData",({plugin:o,idValuesMap:t})=>{c.then(a=>{for(const i in t){const n=a[i].dynamicData||{};n[o]={...t[i]};const r=e.mergeRight(a[i],{dynamicData:n});a[i]=r}"open-closed-status"===o&&Object.keys(t).forEach(e=>{a[e]&&(a[e].isOpenNow=n(a[e]))})})}),i.bus.on("poi/setCoreAttributes",e=>{c.then(o=>{const t=[];for(const a in e){s(o,a,e[a]?.name)&&(i.bus.send("map/mutateFeature",{poiId:a,name:o[a].name}),t.push(o[a]))}t.length>0&&i.bus.send("poi/updated",{pois:t})})});return{init:p,runTest:async e=>(await e(),c),internal:{addImages:h,pseudoTransPoi:u,applyPoiNameOverride:s}}}function s(e,o,t){return!!e[o]&&(e[o].name=t||e[o].staticName,!0)}function u(e,o){return["description","nearbyLandmark","name","phone","operationHours"].forEach(t=>{e[t]&&(e[t]=i(e[t],o))}),e.keywords&&(e.keywords=e.keywords.map(e=>(e.name=i(e.name,o),e))),e.position.floorName&&(e.position.floorName=i(e.position.floorName,o)),e.position.structureName&&(e.position.structureName=i(e.position.structureName,o)),e}export{s as applyPoiNameOverride,r as create};
@@ -1 +1 @@
1
- import*as e from"ramda";import a from"zousan";import{getLocalized as r}from"../../../src/utils/configUtils.js";import{randomizeArray as s,arrayPick as t}from"../../../src/utils/rand.js";import n from"./poiSearch.js";import o from"./searchTypeahead.js";function i(i,c){const u={poiSearch:null,typeahead:null,indexesCreated:new a,defaultSearchTerms:null,specialQueryTerms:{}},d=async()=>{const e=await i.bus.get("poi/getAll");u.poiSearch=n(e,i.i18n().language),u.typeahead=o(e,u.poiSearch.search,i.i18n().language),u.defaultSearchTerms=r(c,"defaultSearchTerms",i.i18n().language),u.indexesCreated.resolve()};async function h(){const a=await i.bus.getFirst("user/getPhysicalLocation");if(!a?.floorId)return[];const r=await i.bus.get("poi/getByFloorId",{floorId:a?.floorId}),s=Object.values(e.pickBy(e=>-1===e.category.indexOf("portal")&&"element.door"!==e.category,r)),t=await i.bus.get("wayfinder/addPathTimeMultiple",{pois:s,startLocation:a});return Object.values(t).slice(0,50)}i.bus.on("search/queryNearby",async()=>{const e=await h();return i.bus.send("search/showNearby",{pois:e,term:"Nearby"}),e}),i.bus.on("search/queryNearbyAsync",h),i.bus.on("search/queryCategory",async({category:e,categoryName:a,searchTerm:r})=>{const s=await u.indexesCreated.then(()=>u.poiSearch.search({query:r||e}));return i.bus.send("search/showCategory",{pois:s,category:e,categoryName:a}),s}),i.bus.on("search/query",({term:e})=>u.indexesCreated.then(()=>{const a=u.poiSearch.search({query:e});return i.bus.send("search/showSearchResults",{results:a,term:e}),a})),i.bus.on("search/queryAsync",({term:e})=>u.indexesCreated.then(()=>u.poiSearch.search({query:e}))),i.bus.on("search/queryWithSpecial",({term:e})=>{if(u.specialQueryTerms[e]){const{event:a,params:r}=u.specialQueryTerms[e];return i.bus.send(a,r)}return i.bus.get("search/query",{term:e})}),i.bus.on("search/getDefaultSearchTerms",async({limit:e=5}={})=>{const a=u.defaultSearchTerms,r=a&&a.length?a:await async function(e){const a=(await i.bus.send("poi/getAllCategories"))[0],r=Array.from(new Set(a));return s(r).slice(0,e)}(e);return i.bus.send("search/showDefaultSearchKeywords",{keywords:r}),r}),i.bus.on("search/getDefaultSearchPois",async({limit:a=5}={})=>{const r=await i.bus.get("poi/getAll"),s=e.pickBy(e=>e.isNavigable,r);return t(Object.values(s),a)}),i.bus.on("search/registerSpecialQuery",({term:e,event:a,params:r,addKeyword:s=!0})=>{u.indexesCreated.then(()=>{s&&u.typeahead.addKeyword(e),u.specialQueryTerms[e]={event:a,params:r}})}),i.bus.on("search/addKeywords",({keywords:e})=>u.indexesCreated.then(()=>e.forEach(e=>u.typeahead.addKeyword(e)))),i.bus.on("search/typeahead",({term:e,limit:a})=>u.indexesCreated.then(()=>{const{keywords:r,pois:s}=u.typeahead.query(e,a);return{keywords:r,pois:s,term:e}})),i.bus.on("venueData/loadNewVenue",()=>{u.indexesCreated=new a,d()}),i.bus.on("poi/setDynamicData",async({plugin:e,idValuesMap:a})=>{if("grab"!==e)return;const r=Object.keys(a).map(e=>i.bus.get("poi/getById",{id:e}));return Promise.all(r).then(e=>u.indexesCreated.then(()=>u.poiSearch.updateMultiple(e)))}),i.bus.on("poi/updated",async({pois:e})=>{e&&0!==e.length&&(await u.indexesCreated,u.poiSearch.updateMultiple(e),u.typeahead.updatePOIs(e),i.bus.send("search/typeaheadChanged",{pois:e}))});return{init:d,runTest:async(e,a)=>(await a(),u)}}export{i as create};
1
+ import*as e from"ramda";import a from"zousan";import{getLocalized as r}from"../../../src/utils/configUtils.js";import{randomizeArray as s,arrayPick as t}from"../../../src/utils/rand.js";import n from"./poiSearch.js";import o from"./searchTypeahead.js";function i(i,c){const u={poiSearch:null,typeahead:null,indexesCreated:new a,defaultSearchTerms:null,specialQueryTerms:{}},d=async()=>{const e=await i.bus.get("poi/getAll");u.poiSearch=n(e,i.i18n().language),u.typeahead=o(e,u.poiSearch.search,i.i18n().language),u.defaultSearchTerms=r(c,"defaultSearchTerms",i.i18n().language),u.indexesCreated.resolve()};async function h(){const a=await i.bus.getFirst("user/getPhysicalLocation");if(!a?.floorId)return[];const r=await i.bus.get("poi/getByFloorId",{floorId:a?.floorId}),s=Object.values(e.pickBy(e=>-1===e.category.indexOf("portal")&&"element.door"!==e.category,r)),t=await i.bus.get("wayfinder/addPathTimeMultiple",{pois:s,startLocation:a});return Object.values(t).slice(0,50)}i.bus.on("search/queryNearby",async()=>{const e=await h();return i.bus.send("search/showNearby",{pois:e,term:"Nearby"}),e}),i.bus.on("search/queryNearbyAsync",h),i.bus.on("search/queryCategory",async({category:e,categoryName:a,searchTerm:r})=>{const s=await u.indexesCreated.then(()=>u.poiSearch.search({query:r||e}));return i.bus.send("search/showCategory",{pois:s,category:e,categoryName:a}),s}),i.bus.on("search/query",({term:e,openNow:a})=>u.indexesCreated.then(()=>{const r=u.poiSearch.search({query:e}),s=!0===a?r.filter(e=>!1!==e.isOpenNow):r;return i.bus.send("search/showSearchResults",{results:s,term:e}),s})),i.bus.on("search/queryAsync",({term:e})=>u.indexesCreated.then(()=>u.poiSearch.search({query:e}))),i.bus.on("search/queryWithSpecial",({term:e})=>{if(u.specialQueryTerms[e]){const{event:a,params:r}=u.specialQueryTerms[e];return i.bus.send(a,r)}return i.bus.get("search/query",{term:e})}),i.bus.on("search/getDefaultSearchTerms",async({limit:e=5}={})=>{const a=u.defaultSearchTerms,r=a&&a.length?a:await async function(e){const a=(await i.bus.send("poi/getAllCategories"))[0],r=Array.from(new Set(a));return s(r).slice(0,e)}(e);return i.bus.send("search/showDefaultSearchKeywords",{keywords:r}),r}),i.bus.on("search/getDefaultSearchPois",async({limit:a=5}={})=>{const r=await i.bus.get("poi/getAll"),s=e.pickBy(e=>e.isNavigable,r);return t(Object.values(s),a)}),i.bus.on("search/registerSpecialQuery",({term:e,event:a,params:r,addKeyword:s=!0})=>{u.indexesCreated.then(()=>{s&&u.typeahead.addKeyword(e),u.specialQueryTerms[e]={event:a,params:r}})}),i.bus.on("search/addKeywords",({keywords:e})=>u.indexesCreated.then(()=>e.forEach(e=>u.typeahead.addKeyword(e)))),i.bus.on("search/typeahead",({term:e,limit:a,openNow:r})=>u.indexesCreated.then(()=>{const{keywords:s,pois:t}=u.typeahead.query(e,a);return{keywords:s,pois:!0===r?t.filter(e=>!1!==e.isOpenNow):t,term:e}})),i.bus.on("venueData/loadNewVenue",()=>{u.indexesCreated=new a,d()}),i.bus.on("poi/setDynamicData",async({plugin:e,idValuesMap:a})=>{if("grab"!==e)return;const r=Object.keys(a).map(e=>i.bus.get("poi/getById",{id:e}));return Promise.all(r).then(e=>u.indexesCreated.then(()=>u.poiSearch.updateMultiple(e)))}),i.bus.on("poi/updated",async({pois:e})=>{e&&0!==e.length&&(await u.indexesCreated,u.poiSearch.updateMultiple(e),u.typeahead.updatePOIs(e),i.bus.send("search/typeaheadChanged",{pois:e}))});return{init:d,runTest:async(e,a)=>(await a(),u)}}export{i as create};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atriusmaps-node-sdk",
3
- "version": "3.3.990",
3
+ "version": "3.3.991",
4
4
  "description": "This project provides an API to Atrius Personal Wayfinder maps within a Node environment. See the README.md for more information",
5
5
  "keywords": [
6
6
  "map",