atriusmaps-node-sdk 3.3.864 → 3.3.866

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var name = "web-engine";
6
- var version = "3.3.864";
6
+ var version = "3.3.866";
7
7
  var license = "UNLICENSED";
8
8
  var type = "module";
9
9
  var main = "src/main.js";
@@ -164,7 +164,7 @@ var devDependencies = {
164
164
  storybook: "^8.6.15",
165
165
  typescript: "^5.8.2",
166
166
  vite: "^7.3.2",
167
- vitest: "4.1.6",
167
+ vitest: "^4.1.8",
168
168
  "webpack-merge": "^6.0.1"
169
169
  };
170
170
  var packageManager = "yarn@4.13.0";
@@ -72,6 +72,10 @@ function create(app, config = {}) {
72
72
  REFRESH_FREQUENCY = config._overrideRefreshFrequency;
73
73
  }
74
74
 
75
+ // Tracks the last-emitted name override per POI to detect changes across poll cycles.
76
+ // poiId (string) -> string | null
77
+ const previousNameOverrides = new Map();
78
+
75
79
  // by returning this dynamicDataLoaded promise, we hold sdkReady event until this is resolved
76
80
  app.bus.on('system/readywhenyouare', () => state.dynamicDataNotPending);
77
81
  app.bus.on('dynamicPois/getSecurityWaitTimes', getSecurityWaitTimes);
@@ -110,7 +114,7 @@ function create(app, config = {}) {
110
114
  }
111
115
  };
112
116
 
113
- return updateFromAPI()
117
+ await updateFromAPI()
114
118
  .then(() => {
115
119
  fetchIntervalHandle = setInterval(updateFromAPI, REFRESH_FREQUENCY);
116
120
  if (typeof fetchIntervalHandle.unref === 'function') {
@@ -118,6 +122,8 @@ function create(app, config = {}) {
118
122
  } // Node only - do not keep-alive Lambda or other short-term environments
119
123
  })
120
124
  .finally(() => state.dynamicDataNotPending.resolve(true)); // even in case of failure, we don't want to hold up the UI
125
+
126
+ return () => clearInterval(fetchIntervalHandle);
121
127
  };
122
128
 
123
129
  async function processDynamicPois(pois) {
@@ -125,6 +131,47 @@ function create(app, config = {}) {
125
131
  processOpenClosedPois(pois);
126
132
  processSecurityWaitTimes(pois);
127
133
  processDynamicRouting(pois);
134
+ processDynamicAttributes(pois);
135
+ }
136
+
137
+ /**
138
+ * Extracts `dynamicAttributes.name` overrides from each POI in the API response and emits
139
+ * `poi/setCoreAttributes` for any changes. A `null` name signals a revert to the original value.
140
+ * Only emits when a value actually changes to avoid unnecessary downstream updates.
141
+ *
142
+ * @param {Object} poiDataMap - The `data` map from the /dynamic-poi API response
143
+ */
144
+ function processDynamicAttributes(poiDataMap) {
145
+ const updates = {};
146
+
147
+ for (const [poiId, poiData] of Object.entries(poiDataMap)) {
148
+ const name = poiData?.dynamicAttributes?.name ?? null;
149
+ const previous = previousNameOverrides.get(poiId); // undefined if never tracked
150
+
151
+ if (previous === undefined) {
152
+ // First time seeing this POI: only track and emit if there's an actual name override
153
+ if (name !== null) {
154
+ updates[poiId] = { name };
155
+ previousNameOverrides.set(poiId, name);
156
+ }
157
+ } else if (previous !== name) {
158
+ // Value changed (including override → null revert)
159
+ updates[poiId] = { name };
160
+ previousNameOverrides.set(poiId, name);
161
+ }
162
+ }
163
+
164
+ // Emit null for any POIs that were previously overridden but are no longer in the response
165
+ for (const [poiId, prevName] of previousNameOverrides.entries()) {
166
+ if (!(poiId in poiDataMap) && prevName !== null) {
167
+ updates[poiId] = { name: null };
168
+ previousNameOverrides.set(poiId, null);
169
+ }
170
+ }
171
+
172
+ if (Object.keys(updates).length > 0) {
173
+ app.bus.send('poi/setCoreAttributes', updates);
174
+ }
128
175
  }
129
176
 
130
177
  function processParkingPOIS(poiMap) {
@@ -318,6 +318,16 @@ async function create(app, config) {
318
318
  });
319
319
  });
320
320
 
321
+ // Applies or reverts dynamic name overrides on POIs.
322
+ // A null name value reverts to the original name stashed before the first override.
323
+ app.bus.on('poi/setCoreAttributes', idAttributesMap => {
324
+ poisLoaded.then(pois => {
325
+ for (const poiId in idAttributesMap) {
326
+ applyCorePoiAttributes(pois, poiId, idAttributesMap[poiId]);
327
+ }
328
+ });
329
+ });
330
+
321
331
  const runTest = async testRoutine => {
322
332
  await testRoutine();
323
333
  return poisLoaded;
@@ -329,10 +339,38 @@ async function create(app, config) {
329
339
  internal: {
330
340
  addImages,
331
341
  pseudoTransPoi,
342
+ applyCorePoiAttributes,
332
343
  },
333
344
  };
334
345
  }
335
346
 
347
+ /**
348
+ * Applies or reverts a single POI's core attributes.
349
+ *
350
+ * - A `null` name reverts the POI to the original name stashed before the first override.
351
+ * - Any other name value stashes the original (if not already stashed) then applies the override.
352
+ *
353
+ * @param {Object} pois - Mutable map of POI id → POI object.
354
+ * @param {string} poiId - ID of the POI to update.
355
+ * @param {Object} attributes - Attributes to apply (currently supports `name`).
356
+ */
357
+ function applyCorePoiAttributes(pois, poiId, attributes) {
358
+ if (!pois[poiId]) return;
359
+ const { name } = attributes;
360
+ if (name === null) {
361
+ // Revert: restore original name from before first override
362
+ pois[poiId] = R__namespace.mergeRight(pois[poiId], {
363
+ name: pois[poiId]._originalName ?? pois[poiId].name,
364
+ });
365
+ } else {
366
+ // First override: stash original name before clobbering
367
+ if (!pois[poiId]._originalName) {
368
+ pois[poiId] = R__namespace.mergeRight(pois[poiId], { _originalName: pois[poiId].name });
369
+ }
370
+ pois[poiId] = R__namespace.mergeRight(pois[poiId], { name });
371
+ }
372
+ }
373
+
336
374
  function pseudoTransPoi(poi, lang) {
337
375
  ['description', 'nearbyLandmark', 'name', 'phone', 'operationHours'].forEach(p => {
338
376
  if (poi[p]) {
@@ -1 +1 @@
1
- var e="web-engine",t="3.3.864",s="UNLICENSED",r="module",o="src/main.js",i=["demo","deploy","nodesdk","src/extModules/flexapi","services/*","libraries/*"],a={"build-storybook":"storybook build",colors:"cat utils/colors1.txt && node utils/processColors.js | pbcopy && cat utils/colors2.txt",demo:"cd demo/ && yarn start",dev:"yarn mol e2e","format:check":"yarn prettier . --check","format:fix":"yarn prettier . --write",goProd:"cd deploy && scripts/goProd.sh",goStaging:"deploy/scripts/goStaging.sh","icons:convert":"node scripts/convertSvgToJsx.mjs",lint:"eslint . --ext .js,.jsx,.ts,.tsx",mod:"demo/startMod.sh",mol:"demo/startMol.sh","mol:build":"demo/startMolBuild.sh",molProd:"cd deploy && yarn buildAndRunMol","playwright:ci":"yarn playwright test --grep-invert sdk","playwright:ci:failed":"yarn playwright test --last-failed --grep-invert sdk","playwright:sdk":"yarn start-server-and-test 'cd ./deploy && yarn buildDev && yarn serveLocal' 8085 'cd ./test/sdk && npx http-server' 8080 'yarn playwright test sdk --ui'","playwright:ui":"yarn playwright test --ui --grep-invert sdk",prepare:"husky",storybook:"storybook dev -p 6006",test:"vitest run --project unit","test-watch":"vitest --watch","test:comp":"vitest run --project browser","test:comp:ci":"vitest run --project browser --reporter=dot","test:comp:ui":"VITE_COMP_UI=1 vitest --project browser --ui --browser.headless=false","test:all":"yarn lint && yarn format:check && yarn test && yarn playwright:ci","test:mod":"playwright test --config=playwright.mod.config.ts",typecheck:"tsc -p tsconfig.checkjs.json"},l=["defaults"],n={"@azure/event-hubs":"^5.12.2","@csstools/normalize.css":"^11.0.1","@dnd-kit/core":"^6.3.1","@dnd-kit/modifiers":"^9.0.0","@dnd-kit/sortable":"^10.0.0","@dnd-kit/utilities":"^3.2.2","@locus-labs/mod-badge":"^0.1.102","@locus-labs/mod-footer":"^0.0.111","@locus-labs/mod-header":"^0.0.105","@locus-labs/mod-location-marker":"^0.0.104","@locus-labs/mod-map-legend":"^0.0.104","@locus-labs/mod-offscreen-indicator":"^0.0.104","@locus-labs/mod-pin":"^0.0.104","@locus-labs/mod-qr-code-card":"^0.0.104","@locus-labs/mod-qr-code-window":"^0.0.105","@locus-labs/mod-walk-time-matrix":"^0.0.103","@mapbox/mapbox-gl-draw":"^1.5.0","@mapbox/mapbox-gl-draw-static-mode":"^1.0.1","@microsoft/applicationinsights-web":"^3.3.6","@turf/area":"^7.2.0","@turf/bbox-clip":"^7.2.0","@turf/bbox-polygon":"^7.2.0","@turf/bearing":"^7.2.0","@turf/circle":"^7.2.0","@turf/helpers":"^7.2.0","@turf/point-to-line-distance":"^7.2.0","@vitejs/plugin-react":"^5.2.0","@zumer/snapdom":"^2.9.0","axe-core":"^4.10.3",browserslist:"^4.27.0","crypto-browserify":"^3.12.1",dompurify:"^3.3.3","file-loader":"^6.2.0",flexsearch:"^0.7.43","h3-js":"^4.1.0",i18next:"^26.0.0","i18next-browser-languagedetector":"^6.1.1",jsdom:"^25.0.1",jsonschema:"^1.5.0",luxon:"^3.5.0","maplibre-gl":"^4.7.1","mini-css-extract-plugin":"^2.9.2","node-polyfill-webpack-plugin":"^4.1.0","path-browserify":"^1.0.1",pmtiles:"^4.4.0","prop-types":"^15.8.1","qrcode.react":"^4.2.0",ramda:"^0.30.1",react:"^19.2.4","react-compound-slider":"^3.4.0","react-dom":"^19.2.4","react-json-editor-ajrm":"^2.5.14","react-svg":"^16.3.0","react-virtualized-auto-sizer":"^1.0.25","react-window":"^1.8.11","smoothscroll-polyfill":"^0.4.4","styled-components":"^6.1.15","styled-normalize":"^8.1.1","throttle-debounce":"^5.0.2",trackjs:"^3.10.4","ua-parser-js":"^0.7.40",uuid:"^11.1.0",zousan:"^3.0.1","zousan-plus":"^4.0.1"},c={"@applitools/eyes-playwright":"^1.46.8","@axe-core/playwright":"^4.10.2","@azure/identity":"^4.13.0","@azure/playwright":"^1.0.0","@percy/cli":"^1.31.11","@percy/playwright":"^1.1.0","@playwright/test":"^1.59.1","@storybook/addon-essentials":"^8.6.15","@storybook/blocks":"^8.6.15","@storybook/react":"^8.6.15","@storybook/react-vite":"^8.6.15","@testing-library/dom":"^10.4.1","@testing-library/jest-dom":"^6.6.3","@testing-library/react":"^16.3.0","@testing-library/user-event":"^14.5.2","@types/react":"^19.0.10","@types/react-dom":"^19.0.4","@typescript-eslint/eslint-plugin":"^8.26.1","@typescript-eslint/parser":"^8.26.1","@vitest/browser":"4.1.6","@vitest/browser-playwright":"4.1.6","@vitest/ui":"4.1.6","chai-colors":"^1.0.1","css-loader":"^7.1.2",eslint:"^8.57.1","eslint-config-prettier":"^10.1.8","eslint-config-standard":"^17.1.0","eslint-import-resolver-alias":"^1.1.2","eslint-plugin-n":"^17.16.2","eslint-plugin-node":"^11.1.0","eslint-plugin-playwright":"^2.2.2","eslint-plugin-promise":"^5.2.0","eslint-plugin-react":"^7.37.4","eslint-plugin-standard":"^5.0.0","eslint-plugin-vitest":"^0.5.4","fetch-mock":"^12.6.0",glob:"^11.0.1",husky:"^9.1.7","lint-staged":"^16.4.0","node-fetch":"^2.7.0","null-loader":"^4.0.1",nx:"19.8.14","nx-remotecache-azure":"^19.0.0","os-browserify":"^0.3.0",prettier:"^3.8.3","start-server-and-test":"^2.0.11",storybook:"^8.6.15",typescript:"^5.8.2",vite:"^7.3.2",vitest:"4.1.6","webpack-merge":"^6.0.1"},d="yarn@4.13.0",p={node:"24.x"},y={},u={name:e,version:t,private:!0,license:s,type:r,main:o,workspaces:i,scripts:a,"lint-staged":{"*.js":["eslint --fix","prettier --check"],"*.{json,md,css,ts,tsx,jsx}":["prettier --check"],"src/i18n/**/*.json":["node utils/sort-json.js","prettier --write"]},browserslist:l,dependencies:n,devDependencies:c,packageManager:d,engines:p,nx:y};export{l as browserslist,u as default,n as dependencies,c as devDependencies,p as engines,s as license,o as main,e as name,y as nx,d as packageManager,a as scripts,r as type,t as version,i as workspaces};
1
+ var e="web-engine",t="3.3.866",s="UNLICENSED",r="module",o="src/main.js",i=["demo","deploy","nodesdk","src/extModules/flexapi","services/*","libraries/*"],a={"build-storybook":"storybook build",colors:"cat utils/colors1.txt && node utils/processColors.js | pbcopy && cat utils/colors2.txt",demo:"cd demo/ && yarn start",dev:"yarn mol e2e","format:check":"yarn prettier . --check","format:fix":"yarn prettier . --write",goProd:"cd deploy && scripts/goProd.sh",goStaging:"deploy/scripts/goStaging.sh","icons:convert":"node scripts/convertSvgToJsx.mjs",lint:"eslint . --ext .js,.jsx,.ts,.tsx",mod:"demo/startMod.sh",mol:"demo/startMol.sh","mol:build":"demo/startMolBuild.sh",molProd:"cd deploy && yarn buildAndRunMol","playwright:ci":"yarn playwright test --grep-invert sdk","playwright:ci:failed":"yarn playwright test --last-failed --grep-invert sdk","playwright:sdk":"yarn start-server-and-test 'cd ./deploy && yarn buildDev && yarn serveLocal' 8085 'cd ./test/sdk && npx http-server' 8080 'yarn playwright test sdk --ui'","playwright:ui":"yarn playwright test --ui --grep-invert sdk",prepare:"husky",storybook:"storybook dev -p 6006",test:"vitest run --project unit","test-watch":"vitest --watch","test:comp":"vitest run --project browser","test:comp:ci":"vitest run --project browser --reporter=dot","test:comp:ui":"VITE_COMP_UI=1 vitest --project browser --ui --browser.headless=false","test:all":"yarn lint && yarn format:check && yarn test && yarn playwright:ci","test:mod":"playwright test --config=playwright.mod.config.ts",typecheck:"tsc -p tsconfig.checkjs.json"},l=["defaults"],n={"@azure/event-hubs":"^5.12.2","@csstools/normalize.css":"^11.0.1","@dnd-kit/core":"^6.3.1","@dnd-kit/modifiers":"^9.0.0","@dnd-kit/sortable":"^10.0.0","@dnd-kit/utilities":"^3.2.2","@locus-labs/mod-badge":"^0.1.102","@locus-labs/mod-footer":"^0.0.111","@locus-labs/mod-header":"^0.0.105","@locus-labs/mod-location-marker":"^0.0.104","@locus-labs/mod-map-legend":"^0.0.104","@locus-labs/mod-offscreen-indicator":"^0.0.104","@locus-labs/mod-pin":"^0.0.104","@locus-labs/mod-qr-code-card":"^0.0.104","@locus-labs/mod-qr-code-window":"^0.0.105","@locus-labs/mod-walk-time-matrix":"^0.0.103","@mapbox/mapbox-gl-draw":"^1.5.0","@mapbox/mapbox-gl-draw-static-mode":"^1.0.1","@microsoft/applicationinsights-web":"^3.3.6","@turf/area":"^7.2.0","@turf/bbox-clip":"^7.2.0","@turf/bbox-polygon":"^7.2.0","@turf/bearing":"^7.2.0","@turf/circle":"^7.2.0","@turf/helpers":"^7.2.0","@turf/point-to-line-distance":"^7.2.0","@vitejs/plugin-react":"^5.2.0","@zumer/snapdom":"^2.9.0","axe-core":"^4.10.3",browserslist:"^4.27.0","crypto-browserify":"^3.12.1",dompurify:"^3.3.3","file-loader":"^6.2.0",flexsearch:"^0.7.43","h3-js":"^4.1.0",i18next:"^26.0.0","i18next-browser-languagedetector":"^6.1.1",jsdom:"^25.0.1",jsonschema:"^1.5.0",luxon:"^3.5.0","maplibre-gl":"^4.7.1","mini-css-extract-plugin":"^2.9.2","node-polyfill-webpack-plugin":"^4.1.0","path-browserify":"^1.0.1",pmtiles:"^4.4.0","prop-types":"^15.8.1","qrcode.react":"^4.2.0",ramda:"^0.30.1",react:"^19.2.4","react-compound-slider":"^3.4.0","react-dom":"^19.2.4","react-json-editor-ajrm":"^2.5.14","react-svg":"^16.3.0","react-virtualized-auto-sizer":"^1.0.25","react-window":"^1.8.11","smoothscroll-polyfill":"^0.4.4","styled-components":"^6.1.15","styled-normalize":"^8.1.1","throttle-debounce":"^5.0.2",trackjs:"^3.10.4","ua-parser-js":"^0.7.40",uuid:"^11.1.0",zousan:"^3.0.1","zousan-plus":"^4.0.1"},c={"@applitools/eyes-playwright":"^1.46.8","@axe-core/playwright":"^4.10.2","@azure/identity":"^4.13.0","@azure/playwright":"^1.0.0","@percy/cli":"^1.31.11","@percy/playwright":"^1.1.0","@playwright/test":"^1.59.1","@storybook/addon-essentials":"^8.6.15","@storybook/blocks":"^8.6.15","@storybook/react":"^8.6.15","@storybook/react-vite":"^8.6.15","@testing-library/dom":"^10.4.1","@testing-library/jest-dom":"^6.6.3","@testing-library/react":"^16.3.0","@testing-library/user-event":"^14.5.2","@types/react":"^19.0.10","@types/react-dom":"^19.0.4","@typescript-eslint/eslint-plugin":"^8.26.1","@typescript-eslint/parser":"^8.26.1","@vitest/browser":"4.1.6","@vitest/browser-playwright":"4.1.6","@vitest/ui":"4.1.6","chai-colors":"^1.0.1","css-loader":"^7.1.2",eslint:"^8.57.1","eslint-config-prettier":"^10.1.8","eslint-config-standard":"^17.1.0","eslint-import-resolver-alias":"^1.1.2","eslint-plugin-n":"^17.16.2","eslint-plugin-node":"^11.1.0","eslint-plugin-playwright":"^2.2.2","eslint-plugin-promise":"^5.2.0","eslint-plugin-react":"^7.37.4","eslint-plugin-standard":"^5.0.0","eslint-plugin-vitest":"^0.5.4","fetch-mock":"^12.6.0",glob:"^11.0.1",husky:"^9.1.7","lint-staged":"^16.4.0","node-fetch":"^2.7.0","null-loader":"^4.0.1",nx:"19.8.14","nx-remotecache-azure":"^19.0.0","os-browserify":"^0.3.0",prettier:"^3.8.3","start-server-and-test":"^2.0.11",storybook:"^8.6.15",typescript:"^5.8.2",vite:"^7.3.2",vitest:"^4.1.8","webpack-merge":"^6.0.1"},d="yarn@4.13.0",p={node:"24.x"},y={},u={name:e,version:t,private:!0,license:s,type:r,main:o,workspaces:i,scripts:a,"lint-staged":{"*.js":["eslint --fix","prettier --check"],"*.{json,md,css,ts,tsx,jsx}":["prettier --check"],"src/i18n/**/*.json":["node utils/sort-json.js","prettier --write"]},browserslist:l,dependencies:n,devDependencies:c,packageManager:d,engines:p,nx:y};export{l as browserslist,u as default,n as dependencies,c as devDependencies,p as engines,s as license,o as main,e as name,y as nx,d as packageManager,a as scripts,r as type,t as version,i as workspaces};
@@ -1 +1 @@
1
- import e from"zousan";import{processParkingPOIS as t,processOpenClosedPois as n,processSecurityWaitTimes as a,mutateSecurityCheckpointLabel as s,processRoutingPois as i}from"./processors.js";let o=3e4;const c="x-account-id";function r(r,u={}){const y={dynamicDataNotPending:new e},d=r.gt();u._overrideRefreshFrequency&&(o=u._overrideRefreshFrequency),r.bus.on("system/readywhenyouare",()=>y.dynamicDataNotPending),r.bus.on("dynamicPois/getSecurityWaitTimes",async({isOpen:e}={})=>{const t=await r.bus.get("poi/getAll");return Object.values(t).filter(t=>{return"security.checkpoint"===t.category&&t?.dynamicData?.security&&(n=t?.dynamicData?.security,"object"==typeof n&&null!==n&&!Array.isArray(n))&&(void 0===e||t?.dynamicData?.security?.isTemporarilyClosed!==e);var n}).map(e=>({id:e.poiId,name:e.name,...e.dynamicData.security}))});const l=async e=>{const t={};for(const n of e){const e=await r.bus.get("poi/getById",{id:n});e&&(t[n]=e.name)}return t};return{init:async()=>{const[e,u]=await Promise.all([r.bus.get("venueData/getAccountId"),r.bus.get("venueData/getVenueId")]),p=`https://marketplace.locuslabs.com/venueId/${u}/dynamic-poi`;let m,f=0,g=0;const D=async()=>{const o=await fetch(p,{headers:{[c]:e}});if(o.ok)return o.json().then(({data:e})=>async function(e){(function(e){const n=t(e);r.bus.send("poi/setDynamicData",{plugin:"parking",idValuesMap:n})})(e),function(e){const t=n(e);r.bus.send("poi/setDynamicData",{plugin:"open-closed-status",idValuesMap:t})}(e),async function(e){const t=a(e);r.bus.send("poi/setDynamicData",{plugin:"security",idValuesMap:t});const n=await l(Object.keys(t));r.bus.send("map/mutateFeature",{functor:s(d,t,n)})}(e),async function(e){const t=await i(e);r.bus.send("poi/setDynamicRouting",{plugin:"routing",idValuesMap:t})}(e)}(e)).then(()=>{g++}).catch(console.error);console.warn("dynamicPois: fetch response status not ok",o),f++,f>=3&&f>g&&clearInterval(m)};return D().then(()=>{m=setInterval(D,o),"function"==typeof m.unref&&m.unref()}).finally(()=>y.dynamicDataNotPending.resolve(!0))}}}export{r as create};
1
+ import e from"zousan";import{processParkingPOIS as t,processOpenClosedPois as n,processSecurityWaitTimes as a,mutateSecurityCheckpointLabel as s,processRoutingPois as o}from"./processors.js";let i=3e4;const c="x-account-id";function r(r,u={}){const l={dynamicDataNotPending:new e},y=r.gt();u._overrideRefreshFrequency&&(i=u._overrideRefreshFrequency);const d=new Map;r.bus.on("system/readywhenyouare",()=>l.dynamicDataNotPending),r.bus.on("dynamicPois/getSecurityWaitTimes",async({isOpen:e}={})=>{const t=await r.bus.get("poi/getAll");return Object.values(t).filter(t=>{return"security.checkpoint"===t.category&&t?.dynamicData?.security&&(n=t?.dynamicData?.security,"object"==typeof n&&null!==n&&!Array.isArray(n))&&(void 0===e||t?.dynamicData?.security?.isTemporarilyClosed!==e);var n}).map(e=>({id:e.poiId,name:e.name,...e.dynamicData.security}))});const m=async e=>{const t={};for(const n of e){const e=await r.bus.get("poi/getById",{id:n});e&&(t[n]=e.name)}return t};return{init:async()=>{const[e,u]=await Promise.all([r.bus.get("venueData/getAccountId"),r.bus.get("venueData/getVenueId")]),p=`https://marketplace.locuslabs.com/venueId/${u}/dynamic-poi`;let f,g=0,b=0;const D=async()=>{const i=await fetch(p,{headers:{[c]:e}});if(i.ok)return i.json().then(({data:e})=>async function(e){(function(e){const n=t(e);r.bus.send("poi/setDynamicData",{plugin:"parking",idValuesMap:n})})(e),function(e){const t=n(e);r.bus.send("poi/setDynamicData",{plugin:"open-closed-status",idValuesMap:t})}(e),async function(e){const t=a(e);r.bus.send("poi/setDynamicData",{plugin:"security",idValuesMap:t});const n=await m(Object.keys(t));r.bus.send("map/mutateFeature",{functor:s(y,t,n)})}(e),async function(e){const t=await o(e);r.bus.send("poi/setDynamicRouting",{plugin:"routing",idValuesMap:t})}(e),function(e){const t={};for(const[n,a]of Object.entries(e)){const e=a?.dynamicAttributes?.name??null,s=d.get(n);void 0===s?null!==e&&(t[n]={name:e},d.set(n,e)):s!==e&&(t[n]={name:e},d.set(n,e))}for(const[n,a]of d.entries())n in e||null===a||(t[n]={name:null},d.set(n,null));Object.keys(t).length>0&&r.bus.send("poi/setCoreAttributes",t)}(e)}(e)).then(()=>{b++}).catch(console.error);console.warn("dynamicPois: fetch response status not ok",i),g++,g>=3&&g>b&&clearInterval(f)};return await D().then(()=>{f=setInterval(D,i),"function"==typeof f.unref&&f.unref()}).finally(()=>l.dynamicDataNotPending.resolve(!0)),()=>clearInterval(f)}}}export{r as create};
@@ -1 +1 @@
1
- import*as o from"ramda";import e 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,n){const s=i.log.sublog("poiDataManager"),u=()=>{i.bus.send("venueData/loadPoiData")};let p=new e;const d=(o,e)=>{const{position:t}=o,a=e.floorIdToStructure(t.floorId);if(!a)return s.error(`No structure found for floorId: ${t.floorId} for POI ${o.poiId}`),{...o};const i=e.floorIdToFloor(t.floorId),n={...t,structureName:a.name,buildingId:a.id,floorName:i.name,floorOrdinal:i.ordinal};return{...o,position:n}},l=(o,e)=>{o.roomInfo||(o.roomInfo=[]),o.roomInfo.push(e)},c=o.pipe(o.propOr([],"externalIds"),o.find(o.propEq("roomId","type")),o.prop("id"),o.unless(o.isNil,o.tail));i.bus.on("venueData/poiDataLoaded",async({pois:e,structures:n})=>{if(e=((e,t)=>o.pipe(o.values,o.map(o=>{o.distance=null,o.isNavigable=void 0===o.isNavigable||!0===o.isNavigable,o.capacity&&l(o,{name:`Seats ${o.capacity.join("-")}`,svgId:"number-of-seats"}),o.category.startsWith("meeting")&&l(o,{name:i.gt()("poiView:Conference Room"),svgId:"conference-room"});const e=c(o);return e&&(o.roomId=e),[o.poiId,d(o,t)]}),o.fromPairs)(e))(e,t(n)),a(i,"pseudoTransPois"))for(const o in e)e[o]=r(e[o],i.i18n().language);e=function(o){const e=[];return Object.values(o).forEach(o=>{try{const t=o.position;t?["buildingId","structureName","floorId","floorName","floorOrdinal","latitude","longitude"].forEach(a=>{null!==t[a]&&void 0!==t[a]||e.push({id:o.poiId,e:`invalid position property: ${a}: ${t[a]}`})}):e.push({poi:o,e:"No position information"})}catch(t){s.error(t),e.push({id:o.poiId,e:t.message})}}),e.length&&(s.warn("badPois:",e),e.forEach(e=>{delete o[e.id]})),o}(e),await async function(o){for(const e of Object.values(o))await I(e);return o}(e),p.resolve(e),i.config.debug&&i.env.isBrowser&&(window._pois=e),i.config.debug&&async function(o){const e=Date.now(),t=[],a=await i.bus.get("wayfinder/_getNavGraph");Object.values(o).forEach(o=>{try{const e=o.position;a.findClosestNode(e.floorId,e.latitude,e.longitude)||t.push({id:o.poiId,e:"No closest Navgraph Node"})}catch(e){s.error(e),t.push({id:o.poiId,e:e.message})}}),t.length&&s.warn("badPois:",t),s(`Total time for navgraph POI check: ${Date.now()-e}ms`)}(e)}),i.bus.on("poi/getById",async({id:o})=>p.then(e=>e[o])),i.bus.on("poi/getByFloorId",async({floorId:e})=>p.then(o.pickBy(o.pathEq(e,["position","floorId"])))),i.bus.on("poi/getByCategoryId",async({categoryId:e})=>p.then(o.pickBy(o=>o.category===e||o.category.startsWith(e+".")))),i.bus.on("poi/getAll",async()=>p);const m=["queue","primaryQueueId"],f=(e,t,a)=>{const i=o.path(["queue","queueType"],t);if(!i)return null;const n=e[i],r=o.path(m,t);return a.filter(o.pathEq(r,m)).filter(o=>o.poiId!==t.poiId).map(e=>{const t=o.path(["queue","queueSubtype"],e),a=g(t)(n);return{poiId:e.poiId,...a}})},g=e=>{return o.pipe(o.find(o.propEq(e,"id")),(t=`No queue found with ID: ${e}`,o=>{if(null!=o)return o;throw Error(t)}),o.pick(["displayText","imageId"]));var t};i.bus.on("poi/addOtherSecurityLanes",({poi:e})=>(async e=>{if(!o.path(m,e))return e;const t=await i.bus.get("venueData/getQueueTypes"),a=await i.bus.get("poi/getByCategoryId",{categoryId:"security"}),n=Object.values(a);return e.queue.otherQueues=f(t,e,n),e})(e));const y=o=>!!o?.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 o.length(t.images)?y(t.images[0])||(t.images=await e.all(t.images.map(o=>i.bus.get("venueData/getPoiImageUrl",{imageName:o,size:n})))):t.images=[],o.length(t.fullImages)?y(t.fullImages[0]?.url)||(t.fullImages=await e.all(t.fullImages.map(async({url:o,...e})=>({url:await i.bus.get("venueData/getPoiImageUrl",{imageName:o,size:n}),...e})))):t.fullImages=[],t}const h=o.memoizeWith(o.identity,o.pipe(o.pluck("category"),o.values,o.uniq));i.bus.on("poi/getAllCategories",async()=>p.then(h)),i.bus.on("venueData/loadNewVenue",()=>{p=new e,u()}),i.bus.on("poi/setDynamicData",({plugin:e,idValuesMap:t})=>{p.then(a=>{for(const i in t){const n=a[i].dynamicData||{};n[e]={...t[i]};const r=o.mergeRight(a[i],{dynamicData:n});a[i]=r}})});return{init:u,runTest:async o=>(await o(),p),internal:{addImages:I,pseudoTransPoi:r}}}function r(o,e){return["description","nearbyLandmark","name","phone","operationHours"].forEach(t=>{o[t]&&(o[t]=i(o[t],e))}),o.keywords&&(o.keywords=o.keywords.map(o=>(o.name=i(o.name,e),o))),o.position.floorName&&(o.position.floorName=i(o.position.floorName,e)),o.position.structureName&&(o.position.structureName=i(o.position.structureName,e)),o}export{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 i}from"../../../src/utils/configUtils.js";import{toLang as a}from"../../../src/utils/i18n.js";async function n(a,n){const u=a.log.sublog("poiDataManager"),l=()=>{a.bus.send("venueData/loadPoiData")};let p=new o;const d=(e,o)=>{const{position:t}=e,i=o.floorIdToStructure(t.floorId);if(!i)return u.error(`No structure found for floorId: ${t.floorId} for POI ${e.poiId}`),{...e};const a=o.floorIdToFloor(t.floorId),n={...t,structureName:i.name,buildingId:i.id,floorName:a.name,floorOrdinal:a.ordinal};return{...e,position:n}},c=(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));a.bus.on("venueData/poiDataLoaded",async({pois:o,structures:n})=>{if(o=((o,t)=>e.pipe(e.values,e.map(e=>{e.distance=null,e.isNavigable=void 0===e.isNavigable||!0===e.isNavigable,e.capacity&&c(e,{name:`Seats ${e.capacity.join("-")}`,svgId:"number-of-seats"}),e.category.startsWith("meeting")&&c(e,{name:a.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(n)),i(a,"pseudoTransPois"))for(const e in o)o[e]=s(o[e],a.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(i=>{null!==t[i]&&void 0!==t[i]||o.push({id:e.poiId,e:`invalid position property: ${i}: ${t[i]}`})}):o.push({poi:e,e:"No position information"})}catch(t){u.error(t),o.push({id:e.poiId,e:t.message})}}),o.length&&(u.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),a.config.debug&&a.env.isBrowser&&(window._pois=o),a.config.debug&&async function(e){const o=Date.now(),t=[],i=await a.bus.get("wayfinder/_getNavGraph");Object.values(e).forEach(e=>{try{const o=e.position;i.findClosestNode(o.floorId,o.latitude,o.longitude)||t.push({id:e.poiId,e:"No closest Navgraph Node"})}catch(o){u.error(o),t.push({id:e.poiId,e:o.message})}}),t.length&&u.warn("badPois:",t),u(`Total time for navgraph POI check: ${Date.now()-o}ms`)}(o)}),a.bus.on("poi/getById",async({id:e})=>p.then(o=>o[e])),a.bus.on("poi/getByFloorId",async({floorId:o})=>p.then(e.pickBy(e.pathEq(o,["position","floorId"])))),a.bus.on("poi/getByCategoryId",async({categoryId:o})=>p.then(e.pickBy(e=>e.category===o||e.category.startsWith(o+".")))),a.bus.on("poi/getAll",async()=>p);const g=["queue","primaryQueueId"],f=(o,t,i)=>{const a=e.path(["queue","queueType"],t);if(!a)return null;const n=o[a],r=e.path(g,t);return i.filter(e.pathEq(r,g)).filter(e=>e.poiId!==t.poiId).map(o=>{const t=e.path(["queue","queueSubtype"],o),i=y(t)(n);return{poiId:o.poiId,...i}})},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};a.bus.on("poi/addOtherSecurityLanes",({poi:o})=>(async o=>{if(!e.path(g,o))return o;const t=await a.bus.get("venueData/getQueueTypes"),i=await a.bus.get("poi/getByCategoryId",{categoryId:"security"}),n=Object.values(i);return o.queue.otherQueues=f(t,o,n),o})(o));const h=e=>!!e?.startsWith("https:");async function I(t){if(!t)return;const i="undefined"==typeof window?1:window.devicePixelRatio||1,n=`${Math.round(351*i)}x${Math.round(197*i)}`;return e.length(t.images)?h(t.images[0])||(t.images=await o.all(t.images.map(e=>a.bus.get("venueData/getPoiImageUrl",{imageName:e,size:n})))):t.images=[],e.length(t.fullImages)?h(t.fullImages[0]?.url)||(t.fullImages=await o.all(t.fullImages.map(async({url:e,...o})=>({url:await a.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));a.bus.on("poi/getAllCategories",async()=>p.then(b)),a.bus.on("venueData/loadNewVenue",()=>{p=new o,l()}),a.bus.on("poi/setDynamicData",({plugin:o,idValuesMap:t})=>{p.then(i=>{for(const a in t){const n=i[a].dynamicData||{};n[o]={...t[a]};const r=e.mergeRight(i[a],{dynamicData:n});i[a]=r}})}),a.bus.on("poi/setCoreAttributes",e=>{p.then(o=>{for(const t in e)r(o,t,e[t])})});return{init:l,runTest:async e=>(await e(),p),internal:{addImages:I,pseudoTransPoi:s,applyCorePoiAttributes:r}}}function r(o,t,i){if(!o[t])return;const{name:a}=i;null===a?o[t]=e.mergeRight(o[t],{name:o[t]._originalName??o[t].name}):(o[t]._originalName||(o[t]=e.mergeRight(o[t],{_originalName:o[t].name})),o[t]=e.mergeRight(o[t],{name:a}))}function s(e,o){return["description","nearbyLandmark","name","phone","operationHours"].forEach(t=>{e[t]&&(e[t]=a(e[t],o))}),e.keywords&&(e.keywords=e.keywords.map(e=>(e.name=a(e.name,o),e))),e.position.floorName&&(e.position.floorName=a(e.position.floorName,o)),e.position.structureName&&(e.position.structureName=a(e.position.structureName,o)),e}export{n as create};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atriusmaps-node-sdk",
3
- "version": "3.3.864",
3
+ "version": "3.3.866",
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",
@@ -58,6 +58,6 @@
58
58
  "@rollup/plugin-json": "^6.1.0",
59
59
  "@rollup/plugin-terser": "^1.0.0",
60
60
  "rollup": "^4.36.0",
61
- "vitest": "^4.1.2"
61
+ "vitest": "^4.1.8"
62
62
  }
63
63
  }