@mountaya/studio 0.0.0-stage → 0.2.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 +69 -0
- package/LICENCE.fr.txt +280 -0
- package/LICENSE.txt +262 -0
- package/README.md +917 -2
- package/dist/agent/index.cjs +2600 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +1237 -0
- package/dist/agent/index.d.ts +1237 -0
- package/dist/agent/index.js +2581 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/chunk-3Oi_Zrtm.js +9 -0
- package/dist/chunk-3Oi_Zrtm.js.map +1 -0
- package/dist/chunk-B18OPIu_.js +6 -0
- package/dist/chunk-B18OPIu_.js.map +1 -0
- package/dist/chunk-B5Uz3Qct.cjs +15 -0
- package/dist/chunk-B5Uz3Qct.cjs.map +1 -0
- package/dist/chunk-BBEJwkd3.d.cts +839 -0
- package/dist/chunk-BIEc_SkR.cjs +29 -0
- package/dist/chunk-BIEc_SkR.cjs.map +1 -0
- package/dist/chunk-BKMFOe-N.js +171 -0
- package/dist/chunk-BKMFOe-N.js.map +1 -0
- package/dist/chunk-BP4uy7E1.d.ts +11583 -0
- package/dist/chunk-BSHTsFiB.js +1403 -0
- package/dist/chunk-BSHTsFiB.js.map +1 -0
- package/dist/chunk-BTUUABGI.js +17 -0
- package/dist/chunk-BTUUABGI.js.map +1 -0
- package/dist/chunk-BaPiaz5X.cjs +115 -0
- package/dist/chunk-BaPiaz5X.cjs.map +1 -0
- package/dist/chunk-BeCVpkYr.cjs +542 -0
- package/dist/chunk-BeCVpkYr.cjs.map +1 -0
- package/dist/chunk-BgngsvK8.cjs +6202 -0
- package/dist/chunk-BgngsvK8.cjs.map +1 -0
- package/dist/chunk-BhInd7CJ.d.cts +253 -0
- package/dist/chunk-Bn6ZbxkS.cjs +27 -0
- package/dist/chunk-By9ZnkVI.js +60 -0
- package/dist/chunk-By9ZnkVI.js.map +1 -0
- package/dist/chunk-BzqPhxsz.cjs +367 -0
- package/dist/chunk-BzqPhxsz.cjs.map +1 -0
- package/dist/chunk-C2mMX81q.d.ts +443 -0
- package/dist/chunk-C2rr9Q0V.cjs +1402 -0
- package/dist/chunk-C2rr9Q0V.cjs.map +1 -0
- package/dist/chunk-CDJCbwIQ.d.cts +78 -0
- package/dist/chunk-CLGvBOVH.d.cts +1654 -0
- package/dist/chunk-COdw1dc6.d.ts +525 -0
- package/dist/chunk-CQCJnT2i.d.ts +511 -0
- package/dist/chunk-CSyHY67q.cjs +353 -0
- package/dist/chunk-CSyHY67q.cjs.map +1 -0
- package/dist/chunk-CiK1Iqrv.js +950 -0
- package/dist/chunk-CiK1Iqrv.js.map +1 -0
- package/dist/chunk-CmJBgSwZ.cjs +24 -0
- package/dist/chunk-CmJBgSwZ.cjs.map +1 -0
- package/dist/chunk-CnrsRK2u.cjs +83 -0
- package/dist/chunk-CnrsRK2u.cjs.map +1 -0
- package/dist/chunk-Co782_9r.js +326 -0
- package/dist/chunk-Co782_9r.js.map +1 -0
- package/dist/chunk-Csr3KDpZ.cjs +32 -0
- package/dist/chunk-Csr3KDpZ.cjs.map +1 -0
- package/dist/chunk-CwkmccXv.js +89 -0
- package/dist/chunk-CwkmccXv.js.map +1 -0
- package/dist/chunk-D0Q4iL9B.cjs +255 -0
- package/dist/chunk-D0Q4iL9B.cjs.map +1 -0
- package/dist/chunk-DFwiSzUS.cjs +72 -0
- package/dist/chunk-DFwiSzUS.cjs.map +1 -0
- package/dist/chunk-DIFayl2P.d.cts +443 -0
- package/dist/chunk-DIGF58ux.d.cts +525 -0
- package/dist/chunk-DKuuuld5.js +101 -0
- package/dist/chunk-DKuuuld5.js.map +1 -0
- package/dist/chunk-DMePkFEo.js +5054 -0
- package/dist/chunk-DMePkFEo.js.map +1 -0
- package/dist/chunk-DO5SIBgu.js +305 -0
- package/dist/chunk-DO5SIBgu.js.map +1 -0
- package/dist/chunk-DOQ_7eE5.d.ts +6662 -0
- package/dist/chunk-DThaaNeb.d.cts +15 -0
- package/dist/chunk-DThaaNeb.d.ts +15 -0
- package/dist/chunk-DUQzjUJy.d.ts +78 -0
- package/dist/chunk-DX37IPhV.cjs +1903 -0
- package/dist/chunk-DX37IPhV.cjs.map +1 -0
- package/dist/chunk-Damps5Tk.cjs +155 -0
- package/dist/chunk-Damps5Tk.cjs.map +1 -0
- package/dist/chunk-DbK5PhpJ.d.ts +1654 -0
- package/dist/chunk-De0vAASv.d.ts +253 -0
- package/dist/chunk-DhSZ7YZt.d.cts +6662 -0
- package/dist/chunk-DjEvqvPA.cjs +43 -0
- package/dist/chunk-DjEvqvPA.cjs.map +1 -0
- package/dist/chunk-DkwDzwvu.d.cts +121 -0
- package/dist/chunk-DkwDzwvu.d.ts +121 -0
- package/dist/chunk-Dmszv9If.js +71 -0
- package/dist/chunk-Dmszv9If.js.map +1 -0
- package/dist/chunk-Dp_ftNWY.d.cts +511 -0
- package/dist/chunk-DsHQySz0.js +31 -0
- package/dist/chunk-DsHQySz0.js.map +1 -0
- package/dist/chunk-DwoUyHHh.js +281 -0
- package/dist/chunk-DwoUyHHh.js.map +1 -0
- package/dist/chunk-IaIDQflj.d.cts +2315 -0
- package/dist/chunk-IaIDQflj.d.ts +2315 -0
- package/dist/chunk-cVXLsZfL.d.ts +839 -0
- package/dist/chunk-mIaCX9EJ.d.cts +11583 -0
- package/dist/chunk-nJQxbOwQ.cjs +8962 -0
- package/dist/chunk-nJQxbOwQ.cjs.map +1 -0
- package/dist/chunk-o9jaxhCO.js +8852 -0
- package/dist/chunk-o9jaxhCO.js.map +1 -0
- package/dist/chunk-p-Tt_Lwz.js +14 -0
- package/dist/chunk-p-Tt_Lwz.js.map +1 -0
- package/dist/engines/index.cjs +2091 -0
- package/dist/engines/index.cjs.map +1 -0
- package/dist/engines/index.d.cts +2176 -0
- package/dist/engines/index.d.ts +2176 -0
- package/dist/engines/index.js +2075 -0
- package/dist/engines/index.js.map +1 -0
- package/dist/handlers/index.cjs +53 -0
- package/dist/handlers/index.cjs.map +1 -0
- package/dist/handlers/index.d.cts +403 -0
- package/dist/handlers/index.d.ts +403 -0
- package/dist/handlers/index.js +33 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/index.cjs +3511 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +3033 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/index.cjs +510 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.cts +296 -0
- package/dist/plugins/index.d.ts +296 -0
- package/dist/plugins/index.js +489 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/seams/index.cjs +89 -0
- package/dist/seams/index.cjs.map +1 -0
- package/dist/seams/index.d.cts +452 -0
- package/dist/seams/index.d.ts +452 -0
- package/dist/seams/index.js +49 -0
- package/dist/seams/index.js.map +1 -0
- package/dist/strings/fr/index.cjs +2135 -0
- package/dist/strings/fr/index.cjs.map +1 -0
- package/dist/strings/fr/index.d.cts +17 -0
- package/dist/strings/fr/index.d.ts +17 -0
- package/dist/strings/fr/index.js +2130 -0
- package/dist/strings/fr/index.js.map +1 -0
- package/dist/strings/index.cjs +2384 -0
- package/dist/strings/index.cjs.map +1 -0
- package/dist/strings/index.d.cts +3 -0
- package/dist/strings/index.d.ts +3 -0
- package/dist/strings/index.js +2353 -0
- package/dist/strings/index.js.map +1 -0
- package/dist/testing/index.cjs +230 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +246 -0
- package/dist/testing/index.d.ts +246 -0
- package/dist/testing/index.js +219 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/time/index.cjs +28 -0
- package/dist/time/index.cjs.map +1 -0
- package/dist/time/index.d.cts +41 -0
- package/dist/time/index.d.ts +41 -0
- package/dist/time/index.js +23 -0
- package/dist/time/index.js.map +1 -0
- package/package.json +224 -4
- package/src/agent/engines/agentThreads.ts +1601 -0
- package/src/agent/engines/directorChat.ts +500 -0
- package/src/agent/index.ts +67 -0
- package/src/agent/rules/agentEditLock.ts +115 -0
- package/src/agent/rules/agentErrorCopy.ts +44 -0
- package/src/agent/rules/copilotOrganization.ts +36 -0
- package/src/agent/rules/playbook.gen.ts +444 -0
- package/src/agent/rules/router.ts +518 -0
- package/src/agent/rules/stateDelta.ts +29 -0
- package/src/agent/rules/studioRouter.ts +123 -0
- package/src/agent/rules/surfaces.gen.ts +633 -0
- package/src/agent/rules/threadsUrl.ts +48 -0
- package/src/agent/rules/transcriptObserver.ts +90 -0
- package/src/agent/stores/agentThreads.ts +451 -0
- package/src/bus/contracts/noData.ts +18 -0
- package/src/bus/contracts/shared.ts +172 -0
- package/src/bus/contracts/studioTools.ts +224 -0
- package/src/bus/rules/bus.ts +857 -0
- package/src/bus/rules/confirmation.ts +22 -0
- package/src/bus/rules/defineRegistry.ts +24 -0
- package/src/bus/rules/errors.ts +401 -0
- package/src/bus/rules/handlerErrors.ts +103 -0
- package/src/bus/rules/handlerRegistry.ts +627 -0
- package/src/bus/rules/inputSchema.ts +232 -0
- package/src/bus/rules/invalidInput.ts +441 -0
- package/src/bus/rules/lateBoundTools.ts +100 -0
- package/src/bus/rules/studioRegistry.ts +324 -0
- package/src/bus/rules/studioToolBus.ts +73 -0
- package/src/bus/rules/types.ts +804 -0
- package/src/chrome/contracts/alert.ts +42 -0
- package/src/chrome/contracts/itinerary.ts +26 -0
- package/src/chrome/contracts/map.ts +23 -0
- package/src/chrome/contracts/overlay.ts +46 -0
- package/src/chrome/contracts/panel.ts +29 -0
- package/src/chrome/contracts/question.ts +52 -0
- package/src/chrome/contracts/selection.ts +26 -0
- package/src/chrome/contracts/sidenav.ts +23 -0
- package/src/chrome/contracts/snapshot.ts +319 -0
- package/src/chrome/contracts/state.ts +22 -0
- package/src/chrome/contracts/tabs.ts +56 -0
- package/src/chrome/handlers/alert.ts +91 -0
- package/src/chrome/handlers/introspection.ts +180 -0
- package/src/chrome/handlers/panels.ts +42 -0
- package/src/chrome/handlers/question.ts +24 -0
- package/src/chrome/handlers/sidenav.ts +116 -0
- package/src/chrome/handlers/snapshot.ts +451 -0
- package/src/chrome/handlers/stateDelta.ts +125 -0
- package/src/chrome/handlers/tabs.ts +143 -0
- package/src/chrome/handlers/timestamp.ts +19 -0
- package/src/chrome/rules/agentSelectors.ts +210 -0
- package/src/chrome/rules/mapAlert.ts +13 -0
- package/src/chrome/rules/question.ts +25 -0
- package/src/chrome/rules/tabs.ts +13 -0
- package/src/chrome/stores/activeDraftSession.ts +134 -0
- package/src/chrome/stores/chrome.ts +527 -0
- package/src/chrome/stores/uiStore.ts +575 -0
- package/src/collab/contracts/collab.ts +261 -0
- package/src/collab/handlers/collab.ts +468 -0
- package/src/collab/rules/toolNames.ts +33 -0
- package/src/collab/stores/collab.ts +899 -0
- package/src/collections/contracts/collection.ts +182 -0
- package/src/collections/handlers/collectionAttach.ts +141 -0
- package/src/collections/handlers/collections.ts +499 -0
- package/src/collections/handlers/heldCollection.ts +42 -0
- package/src/collections/handlers/restCollections.ts +386 -0
- package/src/collections/rules/collections.ts +138 -0
- package/src/collections/rules/entityCollections.ts +53 -0
- package/src/collections/stores/collections.ts +133 -0
- package/src/data/contracts/data.ts +233 -0
- package/src/data/contracts/itinerary.ts +71 -0
- package/src/data/handlers/activityResolve.ts +76 -0
- package/src/data/handlers/data.ts +200 -0
- package/src/data/handlers/graphql.ts +26 -0
- package/src/data/handlers/mutationSink.ts +1577 -0
- package/src/data/handlers/profile.ts +83 -0
- package/src/data/handlers/writeThrough.ts +417 -0
- package/src/data/rules/cache.ts +181 -0
- package/src/data/rules/dataTypes.ts +40 -0
- package/src/data/rules/keys.ts +106 -0
- package/src/data/rules/persistence.ts +1058 -0
- package/src/data/rules/requestBody.ts +43 -0
- package/src/data/rules/restErrors.ts +354 -0
- package/src/data/rules/sessionSurface.ts +156 -0
- package/src/data/rules/toolResultData.ts +73 -0
- package/src/data/rules/uuid.ts +24 -0
- package/src/edit/contracts/edit.ts +37 -0
- package/src/edit/contracts/itinerary.ts +57 -0
- package/src/edit/handlers/draftCommit.ts +257 -0
- package/src/edit/handlers/editDiscard.ts +34 -0
- package/src/edit/handlers/editLock.ts +949 -0
- package/src/edit/handlers/editor.ts +203 -0
- package/src/edit/handlers/formUnsaved.ts +24 -0
- package/src/edit/rules/draftMetadata.ts +117 -0
- package/src/edit/rules/editKeyboard.ts +222 -0
- package/src/edit/rules/editShortcuts.ts +102 -0
- package/src/edit/rules/editTooltip.ts +174 -0
- package/src/edit/rules/editorTaken.ts +49 -0
- package/src/edit/rules/history.ts +26 -0
- package/src/edit/rules/unsavedWork.ts +60 -0
- package/src/edit/stores/editorReservation.ts +70 -0
- package/src/edit/stores/formsUnsaved.ts +54 -0
- package/src/embed/contracts/embed.ts +48 -0
- package/src/embed/engines/embedFraming.ts +1329 -0
- package/src/embed/engines/embedReady.ts +353 -0
- package/src/embed/engines/framingPageSession.ts +169 -0
- package/src/embed/handlers/embed.ts +130 -0
- package/src/embed/rules/allowedDomains.ts +71 -0
- package/src/embed/rules/bridgeMessages.ts +224 -0
- package/src/embed/rules/defaults.ts +173 -0
- package/src/embed/rules/displaySeed.ts +115 -0
- package/src/embed/rules/embedAllowlist.ts +146 -0
- package/src/embed/rules/embedConstraints.ts +215 -0
- package/src/embed/rules/embedElements.ts +277 -0
- package/src/embed/rules/embedSectionFields.ts +126 -0
- package/src/embed/rules/embedSecurity.ts +116 -0
- package/src/embed/rules/fieldDependencies.ts +89 -0
- package/src/embed/rules/fieldOptions.ts +138 -0
- package/src/embed/rules/layerOptions.ts +161 -0
- package/src/embed/rules/readyProtocol.ts +66 -0
- package/src/embed/rules/safetyRules.ts +215 -0
- package/src/embed/rules/snippet.ts +531 -0
- package/src/embed/rules/tableCode.ts +270 -0
- package/src/embed/stores/embed.ts +60 -0
- package/src/embed/stores/embedContent.ts +77 -0
- package/src/engines/index.ts +81 -0
- package/src/handlers/index.ts +66 -0
- package/src/index.ts +1065 -0
- package/src/itinerary/contracts/itinerary.ts +705 -0
- package/src/itinerary/engines/itineraryPace.ts +612 -0
- package/src/itinerary/engines/profileMarker.ts +238 -0
- package/src/itinerary/handlers/importStaging.ts +352 -0
- package/src/itinerary/handlers/itinerary.ts +572 -0
- package/src/itinerary/handlers/itineraryDuplicate.ts +177 -0
- package/src/itinerary/handlers/itineraryExport.ts +117 -0
- package/src/itinerary/handlers/itineraryImport.ts +783 -0
- package/src/itinerary/handlers/itineraryPublish.ts +118 -0
- package/src/itinerary/handlers/itinerarySelection.ts +354 -0
- package/src/itinerary/handlers/itinerarySuggest.ts +1186 -0
- package/src/itinerary/handlers/itineraryUnpublish.ts +101 -0
- package/src/itinerary/handlers/publicationScope.ts +118 -0
- package/src/itinerary/handlers/restItineraries.ts +752 -0
- package/src/itinerary/handlers/restItineraryExport.ts +70 -0
- package/src/itinerary/handlers/restItineraryImport.ts +311 -0
- package/src/itinerary/handlers/restItineraryPace.ts +87 -0
- package/src/itinerary/handlers/restItineraryRecord.ts +36 -0
- package/src/itinerary/handlers/suggestParams.ts +379 -0
- package/src/itinerary/handlers/suggestStaging.ts +363 -0
- package/src/itinerary/handlers/surfaceOpen.ts +389 -0
- package/src/itinerary/rules/activity.ts +139 -0
- package/src/itinerary/rules/analysis.ts +42 -0
- package/src/itinerary/rules/ceiling.ts +49 -0
- package/src/itinerary/rules/createFlow.ts +107 -0
- package/src/itinerary/rules/densify.ts +440 -0
- package/src/itinerary/rules/draftSurface.ts +219 -0
- package/src/itinerary/rules/editorView.ts +83 -0
- package/src/itinerary/rules/export.ts +159 -0
- package/src/itinerary/rules/friendlyName.ts +77 -0
- package/src/itinerary/rules/import.ts +1050 -0
- package/src/itinerary/rules/importFiles.ts +140 -0
- package/src/itinerary/rules/importTotals.ts +77 -0
- package/src/itinerary/rules/liveSegment.ts +712 -0
- package/src/itinerary/rules/lngLat.ts +17 -0
- package/src/itinerary/rules/mapSync.ts +100 -0
- package/src/itinerary/rules/previewRender.ts +416 -0
- package/src/itinerary/rules/profileReadout.ts +216 -0
- package/src/itinerary/rules/routing.ts +707 -0
- package/src/itinerary/rules/suggest.ts +522 -0
- package/src/itinerary/rules/suggestionPreview.ts +119 -0
- package/src/itinerary/rules/view.ts +61 -0
- package/src/itinerary/stores/importSession.ts +319 -0
- package/src/itinerary/stores/itinerary.ts +331 -0
- package/src/itinerary/stores/itineraryDuplicate.ts +76 -0
- package/src/itinerary/stores/sessionIdentity.ts +43 -0
- package/src/itinerary/stores/suggestSession.ts +418 -0
- package/src/layers/contracts/itinerary.ts +46 -0
- package/src/layers/contracts/overlay.ts +132 -0
- package/src/layers/handlers/enrichment.ts +36 -0
- package/src/layers/handlers/overlay.ts +406 -0
- package/src/layers/handlers/restLayers.ts +94 -0
- package/src/layers/handlers/tiles.ts +25 -0
- package/src/layers/rules/layers.ts +212 -0
- package/src/layers/rules/overlayInstant.ts +12 -0
- package/src/layers/rules/reachabilityIcon.ts +18 -0
- package/src/layers/rules/readout.ts +102 -0
- package/src/layers/stores/layers.ts +262 -0
- package/src/map/contracts/contextmenu.ts +33 -0
- package/src/map/contracts/geolocate.ts +37 -0
- package/src/map/contracts/map.ts +146 -0
- package/src/map/contracts/streetview.ts +53 -0
- package/src/map/contracts/terrain.ts +152 -0
- package/src/map/handlers/contextMenu.ts +135 -0
- package/src/map/handlers/geolocate.ts +52 -0
- package/src/map/handlers/map.ts +391 -0
- package/src/map/handlers/streetview.ts +94 -0
- package/src/map/handlers/terrain.ts +663 -0
- package/src/map/rules/baseTerrain.ts +75 -0
- package/src/map/rules/clickTargets.ts +464 -0
- package/src/map/rules/constraints.ts +32 -0
- package/src/map/rules/contextMenuReadout.ts +67 -0
- package/src/map/rules/coordinates.ts +71 -0
- package/src/map/rules/itineraryFit.ts +8 -0
- package/src/map/rules/mapEvents.ts +64 -0
- package/src/map/rules/mapProjection.ts +476 -0
- package/src/map/rules/terrainReading.ts +62 -0
- package/src/plugins/contracts/ids.ts +66 -0
- package/src/plugins/contracts/plugin.ts +202 -0
- package/src/plugins/contracts/slots.ts +137 -0
- package/src/plugins/engines/studioPlugin.ts +1365 -0
- package/src/plugins/index.ts +111 -0
- package/src/plugins/rules/contributions.ts +152 -0
- package/src/plugins/rules/errors.ts +60 -0
- package/src/plugins/rules/ids.ts +42 -0
- package/src/plugins/rules/validation.ts +249 -0
- package/src/rules/listeners.ts +57 -0
- package/src/rules/origin.ts +13 -0
- package/src/rules/storeWrite.ts +37 -0
- package/src/rules/types.ts +136 -0
- package/src/seams/index.ts +79 -0
- package/src/seams/rules/clock.ts +28 -0
- package/src/seams/rules/formatters.ts +211 -0
- package/src/seams/rules/ids.ts +102 -0
- package/src/seams/rules/links.ts +66 -0
- package/src/seams/rules/navigation.ts +222 -0
- package/src/seams/rules/notify.ts +49 -0
- package/src/seams/rules/persistenceDrawer.ts +220 -0
- package/src/seams/rules/saveFile.ts +101 -0
- package/src/seams/rules/seams.ts +156 -0
- package/src/seams/rules/storage.ts +116 -0
- package/src/search/contracts/overlay.ts +74 -0
- package/src/search/contracts/search.ts +197 -0
- package/src/search/handlers/pois.ts +57 -0
- package/src/search/handlers/search.ts +280 -0
- package/src/search/rules/params.ts +925 -0
- package/src/search/rules/poiGroups.ts +138 -0
- package/src/search/rules/searchFetch.ts +139 -0
- package/src/search/rules/timeWindow.ts +30 -0
- package/src/search/stores/search.ts +51 -0
- package/src/segments/contracts/itinerary.ts +433 -0
- package/src/segments/contracts/segment.ts +35 -0
- package/src/segments/engines/segmentDraft.ts +926 -0
- package/src/segments/handlers/chainGuards.ts +67 -0
- package/src/segments/handlers/directions.ts +44 -0
- package/src/segments/handlers/itineraryEcho.ts +45 -0
- package/src/segments/handlers/roadAccessDialog.ts +34 -0
- package/src/segments/handlers/segment.ts +111 -0
- package/src/segments/handlers/segmentEdit.ts +1341 -0
- package/src/segments/handlers/segmentGroups.ts +347 -0
- package/src/segments/handlers/segmentStructure.ts +1144 -0
- package/src/segments/rules/chain.ts +196 -0
- package/src/segments/rules/chainModel.ts +217 -0
- package/src/segments/rules/colors.ts +11 -0
- package/src/segments/rules/commit.ts +76 -0
- package/src/segments/rules/draft.ts +90 -0
- package/src/segments/rules/draftDisposition.ts +43 -0
- package/src/segments/rules/draftSegmentEdit.ts +129 -0
- package/src/segments/rules/engine.ts +222 -0
- package/src/segments/rules/groupSave.ts +234 -0
- package/src/segments/rules/hazardPrompt.ts +60 -0
- package/src/segments/rules/itineraryEcho.ts +40 -0
- package/src/segments/rules/liveSegmentProjection.ts +55 -0
- package/src/segments/rules/merge.ts +51 -0
- package/src/segments/rules/metrics.ts +456 -0
- package/src/segments/rules/naming.ts +168 -0
- package/src/segments/rules/segmentArming.ts +144 -0
- package/src/segments/rules/splitPick.ts +84 -0
- package/src/segments/rules/viaSimplify.ts +230 -0
- package/src/segments/stores/directions.ts +77 -0
- package/src/segments/stores/roadAccessDialog.ts +58 -0
- package/src/segments/stores/segmentEdit.ts +922 -0
- package/src/segments/stores/segmentGroupEdit.ts +84 -0
- package/src/segments/stores/segmentSplit.ts +77 -0
- package/src/share/contracts/share.ts +39 -0
- package/src/share/contracts/shareLink.ts +63 -0
- package/src/share/engines/shareLink.ts +1053 -0
- package/src/share/handlers/share.ts +47 -0
- package/src/share/handlers/shareLink.ts +231 -0
- package/src/share/handlers/shareScope.ts +54 -0
- package/src/share/rules/link.ts +89 -0
- package/src/share/rules/shareLink.ts +218 -0
- package/src/share/rules/targets.ts +92 -0
- package/src/share/rules/viewConfig.ts +95 -0
- package/src/share/stores/share.ts +58 -0
- package/src/strings/fr/index.ts +18 -0
- package/src/strings/fr/rules/fr.ts +2368 -0
- package/src/strings/index.ts +98 -0
- package/src/strings/rules/confirmCopy.ts +156 -0
- package/src/strings/rules/draftToolNames.ts +94 -0
- package/src/strings/rules/en.ts +2519 -0
- package/src/strings/rules/failureAlert.ts +115 -0
- package/src/strings/rules/formError.ts +400 -0
- package/src/strings/rules/maneuvers.ts +107 -0
- package/src/strings/rules/outputOptions.ts +126 -0
- package/src/strings/rules/publicationState.ts +100 -0
- package/src/strings/rules/routeHazardCopy.ts +62 -0
- package/src/strings/rules/searchLabels.ts +50 -0
- package/src/strings/rules/segmentChainVerbs.ts +62 -0
- package/src/strings/rules/studioCopy.ts +130 -0
- package/src/strings/rules/unitOptions.ts +119 -0
- package/src/testing/checkedBus.ts +226 -0
- package/src/testing/index.ts +30 -0
- package/src/testing/plugins.ts +106 -0
- package/src/testing/studio.ts +267 -0
- package/src/testing/urlSeam.ts +153 -0
- package/src/time/index.ts +12 -0
- package/src/time/rules/sun.ts +78 -0
- package/src/video/contracts/cameraSchemas.ts +266 -0
- package/src/video/contracts/profileSchemas.ts +37 -0
- package/src/video/contracts/video.ts +601 -0
- package/src/video/handlers/video.ts +1638 -0
- package/src/video/handlers/videoDirector.ts +114 -0
- package/src/video/rules/previewRefresh.ts +76 -0
- package/src/video/rules/profileSource.ts +51 -0
- package/src/video/rules/routeSpans.ts +79 -0
- package/src/video/rules/shotDefaults.ts +28 -0
- package/src/video/rules/stepOrder.ts +17 -0
- package/src/video/rules/videoSnapshot.ts +136 -0
- package/src/video/stores/directorThreads.ts +167 -0
- package/src/video/stores/videoExport.ts +290 -0
- package/src/viewer/contracts/preferences.ts +40 -0
- package/src/viewer/handlers/preferences.ts +91 -0
- package/src/viewer/rules/capabilities.ts +42 -0
- package/src/viewer/rules/config.ts +266 -0
- package/src/viewer/rules/context.ts +375 -0
- package/src/viewer/rules/ownership.ts +134 -0
- package/src/viewer/rules/platformViewer.ts +199 -0
- package/src/viewer/rules/scope.ts +197 -0
- package/src/viewer/rules/url.ts +145 -0
- package/src/viewer/rules/viewer.ts +307 -0
- package/src/viewer/rules/viewerSeam.ts +49 -0
- package/src/viewer/rules/viewerUnits.ts +34 -0
- package/src/waypoints/contracts/itinerary.ts +417 -0
- package/src/waypoints/handlers/poiWaypointStyle.ts +32 -0
- package/src/waypoints/handlers/waypointDetailsDialog.ts +38 -0
- package/src/waypoints/handlers/waypointEdit.ts +1073 -0
- package/src/waypoints/rules/amenities.ts +30 -0
- package/src/waypoints/rules/defaults.ts +31 -0
- package/src/waypoints/rules/details.ts +213 -0
- package/src/waypoints/rules/detailsDraft.ts +312 -0
- package/src/waypoints/rules/detailsPreview.ts +76 -0
- package/src/waypoints/rules/detailsSave.ts +356 -0
- package/src/waypoints/rules/draftDirty.ts +45 -0
- package/src/waypoints/rules/icons.ts +32 -0
- package/src/waypoints/rules/liveWaypoint.ts +63 -0
- package/src/waypoints/rules/naming.ts +185 -0
- package/src/waypoints/rules/sections.ts +77 -0
- package/src/waypoints/rules/waypointDraft.ts +62 -0
- package/src/waypoints/stores/waypointDetails.ts +62 -0
- package/src/waypoints/stores/waypointEdit.ts +566 -0
- package/src/zones/contracts/collection.ts +37 -0
- package/src/zones/contracts/zone.ts +528 -0
- package/src/zones/engines/zoneForm.ts +1773 -0
- package/src/zones/handlers/restZones.ts +287 -0
- package/src/zones/handlers/zonePublish.ts +206 -0
- package/src/zones/handlers/zoneUnpublish.ts +56 -0
- package/src/zones/handlers/zones.ts +2254 -0
- package/src/zones/rules/geometry.ts +946 -0
- package/src/zones/rules/zoneDefaults.ts +34 -0
- package/src/zones/rules/zoneDraft.ts +54 -0
- package/src/zones/rules/zoneForm.ts +563 -0
- package/src/zones/rules/zoneMetadata.ts +29 -0
- package/src/zones/rules/zoneSource.ts +87 -0
- package/src/zones/rules/zoneSourceRefusal.ts +104 -0
- package/src/zones/stores/zoneEdit.ts +998 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { isConfirmationWithheld } from "../../bus/rules/confirmation.js";
|
|
2
|
+
import type { ToolResult } from "../../bus/rules/types.js";
|
|
3
|
+
import { MAP_ALERT_MESSAGE_MAX } from "../../chrome/rules/mapAlert.js";
|
|
4
|
+
import type { StudioStrings } from "./en.js";
|
|
5
|
+
import { codeSentence, keyedWriteOf, refusedForCreate, sentenceOf } from "./formError.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* failureAlertFor turns a refused dispatch into the alert to raise for it, or `null` for the
|
|
9
|
+
* cases that are not failures at all.
|
|
10
|
+
*
|
|
11
|
+
* The answer is what `studio.alert.show` takes: an `info` or `error` level and a message of at
|
|
12
|
+
* most 280 characters ({@link MAP_ALERT_MESSAGE_MAX}). A rule rather than a binding's own logic,
|
|
13
|
+
* because every surface that reports a refused dispatch asks the same question; a binding decides
|
|
14
|
+
* only where the alert goes, and a surface reading this can see the whole decision at once.
|
|
15
|
+
*
|
|
16
|
+
* The line is clamped to that limit, because it ends with the SERVER's own sentence, which
|
|
17
|
+
* carries no client-side length bound: a long refusal would otherwise fail the alert tool's own
|
|
18
|
+
* boundary parse and show the reader nothing at all. Clamping keeps the worst case a truncated
|
|
19
|
+
* sentence rather than a silent one.
|
|
20
|
+
*
|
|
21
|
+
* `action` is the already-localized sentence for what the user just tried ("This segment could
|
|
22
|
+
* not be saved."), resolved by the caller rather than named as a key here. A key would have to
|
|
23
|
+
* be a key of SOMETHING (one i18n namespace, one string table), and the callers do not share
|
|
24
|
+
* one: a map surface reads the published `ElementsStrings`, the studio's own surfaces read its
|
|
25
|
+
* copy bundle. A resolved string is the one shape both can supply.
|
|
26
|
+
*
|
|
27
|
+
* The reason is resolved most specific first:
|
|
28
|
+
*
|
|
29
|
+
* 1. `result.detail`, the server's own already-localized sentence lifted off the REST envelope.
|
|
30
|
+
* It names the actual refusal ("The split point is too close to the start or the end of the
|
|
31
|
+
* segment"), which no per-code copy can reproduce, so it wins when present and not blank;
|
|
32
|
+
* 2. `failure[code]` for the classified failure code: the category, when the server gave no
|
|
33
|
+
* prose;
|
|
34
|
+
* 3. `failure.generic`, when the failure carries no code, or a code the copy holds no sentence
|
|
35
|
+
* for (a host's own tool may answer one).
|
|
36
|
+
*
|
|
37
|
+
* These outcomes are handled apart from that chain, because none of them is something that went
|
|
38
|
+
* wrong:
|
|
39
|
+
*
|
|
40
|
+
* - a successful result answers `null`, so a caller can hand this every result rather than
|
|
41
|
+
* branching first;
|
|
42
|
+
* - a withheld confirmation answers `null` too, for the reason {@link isConfirmationWithheld}
|
|
43
|
+
* gives;
|
|
44
|
+
* - `edit-in-progress` is the one-edit-at-a-time gate refusing a second session. It answers at
|
|
45
|
+
* `info` with the shared "finish or cancel your current edit first" copy, so the block reads as
|
|
46
|
+
* a rule of the editor rather than a fault, and it drops the action prefix: the rule is the
|
|
47
|
+
* whole message, and naming what it refused would read as a fault report for something the
|
|
48
|
+
* editor is simply not doing yet.
|
|
49
|
+
* - a refusal met while a create's request is out ({@link refusedForCreate}: the one-edit
|
|
50
|
+
* refusal of a create, or the `conflict` of a staged draft's held session) answers at `info`
|
|
51
|
+
* with `failure.createInProgress`, since nothing is for the reader to finish, cancel or reload.
|
|
52
|
+
* - a refusal that answers the write's `Idempotency-Key` ({@link keyedWriteOf}) answers at
|
|
53
|
+
* `info` with `failure.writeRunning` for a write still being made and `failure.writeMade` for
|
|
54
|
+
* one the API made: the write is being saved, or was, so nothing is to be asked for again.
|
|
55
|
+
*
|
|
56
|
+
* It classifies on the structured `code` rather than on the message text, which is what lets the
|
|
57
|
+
* reason chain and the carve-outs read the same vocabulary the bus stamps; the one `error` it
|
|
58
|
+
* reads is that of a refusal met while a create is out ({@link refusedForCreate}), and the tag
|
|
59
|
+
* the bus opens a keyed write's refusal with ({@link keyedWriteOf}). The copy for
|
|
60
|
+
* that vocabulary is keyed by the code itself, and a code it holds no sentence for reads as
|
|
61
|
+
* `failure.generic`.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* declare const itineraryId: string;
|
|
66
|
+
* declare const segmentId: string;
|
|
67
|
+
*
|
|
68
|
+
* const result = await bus.dispatch(ctx, "studio.itinerary.segment.remove", {
|
|
69
|
+
* itineraryId,
|
|
70
|
+
* segmentId,
|
|
71
|
+
* });
|
|
72
|
+
* const alert = failureAlertFor(
|
|
73
|
+
* result,
|
|
74
|
+
* "This segment could not be deleted.",
|
|
75
|
+
* studioStrings.en.failure,
|
|
76
|
+
* );
|
|
77
|
+
* if (alert !== null) {
|
|
78
|
+
* void bus.dispatch(ctx, "studio.alert.show", alert);
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export const failureAlertFor = (
|
|
83
|
+
result: ToolResult,
|
|
84
|
+
action: string,
|
|
85
|
+
failure: StudioStrings["failure"],
|
|
86
|
+
): { level: "error" | "info"; message: string } | null => {
|
|
87
|
+
if (result.ok || isConfirmationWithheld(result)) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (refusedForCreate(result)) {
|
|
92
|
+
return { level: "info", message: failure.createInProgress };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const keyed = keyedWriteOf(result);
|
|
96
|
+
if (keyed !== undefined) {
|
|
97
|
+
return {
|
|
98
|
+
level: "info",
|
|
99
|
+
message: keyed === "running" ? failure.writeRunning : failure.writeMade,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (result.code === "edit-in-progress") {
|
|
104
|
+
return { level: "info", message: failure["edit-in-progress"] };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// A blank detail is treated as absent: the envelope was present but said nothing, and a
|
|
108
|
+
// trailing blank would read as a truncated sentence.
|
|
109
|
+
const reason =
|
|
110
|
+
sentenceOf(result.detail) ??
|
|
111
|
+
(result.code === undefined ? undefined : codeSentence(failure, result.code)) ??
|
|
112
|
+
failure.generic;
|
|
113
|
+
|
|
114
|
+
return { level: "error", message: `${action} ${reason}`.slice(0, MAP_ALERT_MESSAGE_MAX) };
|
|
115
|
+
};
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import {
|
|
2
|
+
codeForThrown,
|
|
3
|
+
failureFromThrown,
|
|
4
|
+
VERSION_MOVED,
|
|
5
|
+
WRITE_MADE,
|
|
6
|
+
WRITE_STILL_RUNNING,
|
|
7
|
+
} from "../../bus/rules/errors.js";
|
|
8
|
+
import type { ToolErrorCode, ToolResult } from "../../bus/rules/types.js";
|
|
9
|
+
import type { EditorReservation } from "../../edit/stores/editorReservation.js";
|
|
10
|
+
import type { StudioStrings } from "./en.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The alert/field split a studio form shows when an action did not take, resolved from the
|
|
14
|
+
* published copy.
|
|
15
|
+
*
|
|
16
|
+
* It sits beside the copy bundle it reads, and every import in this module resolves inside its
|
|
17
|
+
* own package. Nothing here renders. A refusal maps to a sentence and a field the same way for a
|
|
18
|
+
* React dialog, a Flutter form and a command-line tool, which is what makes this the studio's
|
|
19
|
+
* business rather than a binding's.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* FormErrorCopy is the `formError` section of the studio's published copy, and the whole of
|
|
24
|
+
* what these mappers read.
|
|
25
|
+
*
|
|
26
|
+
* Narrow rather than the whole bundle, and the copy rather than an i18next `t`: the section
|
|
27
|
+
* already has the shape the resolution needs (a message per code, plus a nested object per
|
|
28
|
+
* resource for the codes whose wording differs by entity), so a lookup reads a property
|
|
29
|
+
* instead of building a dotted key that nothing checks.
|
|
30
|
+
*/
|
|
31
|
+
export type FormErrorCopy = StudioStrings["formError"];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* FormErrorResource names the entity a form governs, which selects the
|
|
35
|
+
* resource-specific error copy when a code has a per-resource message (a name
|
|
36
|
+
* `conflict` reads differently for an itinerary than a collection). It is open to
|
|
37
|
+
* the families the studio forms and the dialogs cover; a resource with no
|
|
38
|
+
* specialized copy for a given code falls back to the generic per-code message.
|
|
39
|
+
*/
|
|
40
|
+
export type FormErrorResource = "collection" | "itinerary" | "organization" | "zone";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* FormErrorOptions carry the copy section the message resolves through and, where the form governs
|
|
44
|
+
* a resource's name, the resource it is specialized for. Kept a small config object (not React) so
|
|
45
|
+
* the mapper is a pure function a panel, a dialog, or a unit test can call the same way.
|
|
46
|
+
*/
|
|
47
|
+
export interface FormErrorOptions {
|
|
48
|
+
/** The section the message is read from. */
|
|
49
|
+
copy: FormErrorCopy;
|
|
50
|
+
/**
|
|
51
|
+
* The resource whose own `conflict` sentence a conflict reads: that sentence speaks of the
|
|
52
|
+
* resource's name. Omitted for a refusal about no resource's name (a share link), which reads
|
|
53
|
+
* the shared `conflict` line.
|
|
54
|
+
*/
|
|
55
|
+
resource?: FormErrorResource | undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* resolveCodeMessage turns a machine-readable code into the one human line a form
|
|
60
|
+
* shows, resolving copy most specific first: a resource-specific message for the
|
|
61
|
+
* code, then a generic message for the code, then the supplied fallback.
|
|
62
|
+
*
|
|
63
|
+
* The generic tier is guarded rather than indexed blind. A code the bus learns before the
|
|
64
|
+
* copy names it falls through to the caller's fallback rather than rendering the key itself,
|
|
65
|
+
* so a raw key never reaches a reader.
|
|
66
|
+
*/
|
|
67
|
+
const resolveCodeMessage = (
|
|
68
|
+
code: ToolErrorCode,
|
|
69
|
+
fallback: string,
|
|
70
|
+
{ copy, resource }: FormErrorOptions,
|
|
71
|
+
): string => {
|
|
72
|
+
// `conflict` is the only code whose wording differs by entity, and the copy says so by
|
|
73
|
+
// shape: each resource carries exactly that one key. Naming it here rather than probing
|
|
74
|
+
// for an arbitrary per-resource code keeps the specialization a fact of the type.
|
|
75
|
+
if (code === "conflict" && resource !== undefined) {
|
|
76
|
+
return copy[resource].conflict;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return codeSentence(copy, code) ?? fallback;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* codeSentence reads the copy's sentence for a refusal's code, or undefined where the section
|
|
84
|
+
* holds none.
|
|
85
|
+
*
|
|
86
|
+
* The copy names every code of the studio's vocabulary. A code from outside it, which a host's
|
|
87
|
+
* own tool, a JavaScript caller or a wire code the bus learns first may answer, is a member the
|
|
88
|
+
* section does not hold, so the lookup is guarded rather than indexed blind: a reader is never
|
|
89
|
+
* shown the key itself, nor `undefined`.
|
|
90
|
+
*/
|
|
91
|
+
export const codeSentence = (
|
|
92
|
+
section: Readonly<Record<string, unknown>>,
|
|
93
|
+
code: string,
|
|
94
|
+
): string | undefined => {
|
|
95
|
+
const sentence = Object.hasOwn(section, code) ? section[code] : undefined;
|
|
96
|
+
|
|
97
|
+
return typeof sentence === "string" ? sentence : undefined;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* CREATE_HOLDS_EDITOR is the `error` of the `edit-in-progress` refusal a verb meets while a
|
|
102
|
+
* create's request holds the editor: the lock's tag and the reservation's kind, as
|
|
103
|
+
* `editInProgressError` of the edit handlers writes it.
|
|
104
|
+
*
|
|
105
|
+
* Restated rather than imported, since a rule of the copy reads no handler. The kind is typed by
|
|
106
|
+
* the reservation, and the suites of both mappers build the refusal through
|
|
107
|
+
* `editInProgressError`, so a change to either half fails there.
|
|
108
|
+
*/
|
|
109
|
+
const CREATE_HOLDS_EDITOR = `edit-in-progress: ${"create" satisfies EditorReservation["kind"]}`;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* draftCommitHolds reads the `error` of the `conflict` refusal a verb meets while a staged
|
|
113
|
+
* draft's create holds its session, as `holdDuringDraftCommit` of the itinerary rules writes it:
|
|
114
|
+
* the verb's own words, then the draft that is being saved.
|
|
115
|
+
*
|
|
116
|
+
* Restated rather than imported, as {@link CREATE_HOLDS_EDITOR} is, and the suites of both
|
|
117
|
+
* mappers build the refusal through `holdDuringDraftCommit`, so a change to either half fails
|
|
118
|
+
* there.
|
|
119
|
+
*/
|
|
120
|
+
const draftCommitHolds = /: the [a-z-]+ draft is being saved; /;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* refusedForCreate reports whether a result is a refusal met while a create's request is out:
|
|
124
|
+
* the one-edit refusal of a create that holds the editor, or the `conflict` of a staged draft's
|
|
125
|
+
* session held while its create is out. Nothing is for the reader to finish, cancel or reload
|
|
126
|
+
* then, so the copy says the itinerary is being created.
|
|
127
|
+
*/
|
|
128
|
+
export const refusedForCreate = (result: ToolResult): boolean =>
|
|
129
|
+
!result.ok &&
|
|
130
|
+
((result.code === "edit-in-progress" && result.error === CREATE_HOLDS_EDITOR) ||
|
|
131
|
+
(result.code === "conflict" && draftCommitHolds.test(result.error)));
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* KeyedWrite names which of the two refusals answering a write's `Idempotency-Key` a result is:
|
|
135
|
+
* a write whose first request is still running, or one the API made and cannot answer again.
|
|
136
|
+
*/
|
|
137
|
+
type KeyedWrite = "running" | "made";
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* keyedWriteOf reads whether a result is a refusal that answers the write's `Idempotency-Key`
|
|
141
|
+
* rather than the write, and which: a `conflict` whose `error` the bus opened with the
|
|
142
|
+
* write-still-running or the write-made tag. Neither is a name another resource carries nor a
|
|
143
|
+
* change to reload over: the write is being saved, or was, and asking for it again under a new
|
|
144
|
+
* key would make it twice.
|
|
145
|
+
*
|
|
146
|
+
* @returns Which of the two the result is, or undefined for any other result.
|
|
147
|
+
*/
|
|
148
|
+
export const keyedWriteOf = (result: ToolResult): KeyedWrite | undefined => {
|
|
149
|
+
if (result.ok || result.code !== "conflict") {
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (result.error.startsWith(`${WRITE_STILL_RUNNING}: `)) {
|
|
154
|
+
return "running";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return result.error.startsWith(`${WRITE_MADE}: `) ? "made" : undefined;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* versionMoved reports whether a result is the refusal of a write made conditional on a version
|
|
162
|
+
* the resource has since moved past: a `conflict` whose `error` the bus opened with the
|
|
163
|
+
* version-moved tag. Somebody changed the resource since the reader opened it, so no field of the
|
|
164
|
+
* form is wrong, and no other name would get past it.
|
|
165
|
+
*/
|
|
166
|
+
export const versionMoved = (result: ToolResult): boolean =>
|
|
167
|
+
!result.ok && result.code === "conflict" && result.error.startsWith(`${VERSION_MOVED}: `);
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* sentenceOf reads the sentence a server wrote for a refusal: the text without the space around
|
|
171
|
+
* it, or undefined for a value that is no string, an empty one or a blank one.
|
|
172
|
+
*
|
|
173
|
+
* Both mappers read through it, so a blank sentence is none whichever way the refusal arrived: a
|
|
174
|
+
* blank line shown as a refusal's reason is a form that refused and would not say why.
|
|
175
|
+
*/
|
|
176
|
+
export const sentenceOf = (value: unknown): string | undefined => {
|
|
177
|
+
if (typeof value !== "string") {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const sentence = value.trim();
|
|
182
|
+
|
|
183
|
+
return sentence === "" ? undefined : sentence;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* mapToolError turns a failed `ToolResult` into the one sentence a form shows above its footer.
|
|
188
|
+
*
|
|
189
|
+
* It reads the failure's machine-readable `code` and its `detail`, most specific first:
|
|
190
|
+
*
|
|
191
|
+
* 1. for a refusal met while a create's request is out (the one-edit refusal of a create, or
|
|
192
|
+
* the `conflict` of a staged draft's held session), `formError.createInProgress`
|
|
193
|
+
* ({@link refusedForCreate});
|
|
194
|
+
* 2. for a refusal that answers the write's `Idempotency-Key` ({@link keyedWriteOf}),
|
|
195
|
+
* `formError.writeRunning` for a write still being made and `formError.writeMade` for one
|
|
196
|
+
* the API made, neither of which asks for the write again;
|
|
197
|
+
* 3. for a write made conditional on a version the resource has moved past ({@link
|
|
198
|
+
* versionMoved}), the shared `formError.conflict` line: the resource changed since the reader
|
|
199
|
+
* opened it, and no name of theirs is taken;
|
|
200
|
+
* 4. for any other `conflict`, the resource's own conflict copy, which names what the reader
|
|
201
|
+
* can correct (a taken name), whatever the server said of it; with no `resource`, the
|
|
202
|
+
* shared `formError.conflict` line;
|
|
203
|
+
* 5. the server's `detail`, its already-localized sentence for this refusal, which names the
|
|
204
|
+
* actual problem where a per-code line can only name the category;
|
|
205
|
+
* 6. the copy's sentence for the code, the same across every resource;
|
|
206
|
+
* 7. the last-resort line, `formError.generic`.
|
|
207
|
+
*
|
|
208
|
+
* {@link mapRestError} reads a thrown REST error by the same chain, the create hold aside (no
|
|
209
|
+
* request answers it), with the code the tool bus classifies that error by. So a refusal reads as
|
|
210
|
+
* one sentence whether a panel met it through a tool or a dialog through a request. A `detail`
|
|
211
|
+
* that is empty or blank is read as absent, there as here: a blank line is a form that refused and
|
|
212
|
+
* would not say why. The sentence is answered without the space around it.
|
|
213
|
+
*
|
|
214
|
+
* It never shows the result's own `error`, and reads it only to recognise a refusal met while a
|
|
215
|
+
* create is out ({@link refusedForCreate}) and the tags the bus opens a keyed write's refusal
|
|
216
|
+
* ({@link keyedWriteOf}) and a moved version's ({@link versionMoved}) with. That string is narration written for a model and an
|
|
217
|
+
* event log, in the one language this package has, so showing it to a reader is showing a French
|
|
218
|
+
* reader an English sentence in a voice written for something that is not a person.
|
|
219
|
+
*
|
|
220
|
+
* @param result The tool's result. A successful one answers the empty string, so a caller
|
|
221
|
+
* renders its alert only for a sentence that is not empty.
|
|
222
|
+
* @param options The `formError` copy, and the resource whose name the form governs where it
|
|
223
|
+
* governs one.
|
|
224
|
+
* @returns The sentence, or the empty string for a result that is no failure.
|
|
225
|
+
*/
|
|
226
|
+
export const mapToolError = (result: ToolResult, options: FormErrorOptions): string => {
|
|
227
|
+
if (result.ok) {
|
|
228
|
+
return "";
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (refusedForCreate(result)) {
|
|
232
|
+
return options.copy.createInProgress;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const keyed = keyedWriteOf(result);
|
|
236
|
+
if (keyed !== undefined) {
|
|
237
|
+
return keyed === "running" ? options.copy.writeRunning : options.copy.writeMade;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (versionMoved(result)) {
|
|
241
|
+
return options.copy.conflict;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (result.code === "conflict") {
|
|
245
|
+
return resolveCodeMessage("conflict", options.copy.generic, options);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const detail = sentenceOf(result.detail);
|
|
249
|
+
if (detail !== undefined) {
|
|
250
|
+
return detail;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return result.code === undefined
|
|
254
|
+
? options.copy.generic
|
|
255
|
+
: resolveCodeMessage(result.code, options.copy.generic, options);
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* RestFormError splits a mapped REST failure into the two slots a dialog surfaces
|
|
260
|
+
* it through: a `fieldError` shown under the offending input (a conflict-like
|
|
261
|
+
* rejection the user can correct in place) or a `formError` shown in the inline
|
|
262
|
+
* alert above the footer (everything else). Exactly one is non-null on a failure,
|
|
263
|
+
* matching how the studio panels split a tool failure between a field and the
|
|
264
|
+
* alert. The two slots let a dialog drive the same field/alert split a ToolResult
|
|
265
|
+
* caller gets, so a REST-backed dialog and a tool-backed panel read identically.
|
|
266
|
+
*/
|
|
267
|
+
export interface RestFormError {
|
|
268
|
+
fieldError: string | null;
|
|
269
|
+
formError: string | null;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** One entry of the API's error envelope, read for the two fields these mappers branch on. */
|
|
273
|
+
interface EnvelopeEntry {
|
|
274
|
+
readonly extensions?: { readonly code?: unknown } | null | undefined;
|
|
275
|
+
readonly message?: unknown;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** isEnvelopeEntry reports whether one member of an envelope's `errors` is an object to read. */
|
|
279
|
+
const isEnvelopeEntry = (entry: unknown): entry is EnvelopeEntry =>
|
|
280
|
+
typeof entry === "object" && entry !== null;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* apiEnvelope reads a thrown REST failure STRUCTURALLY, with no `instanceof`.
|
|
284
|
+
*
|
|
285
|
+
* `MountayaApiError` is a class in a package this one only PEERS, and a peer that resolves twice
|
|
286
|
+
* in a consumer's graph (a linked checkout beside a published copy) gives two constructor
|
|
287
|
+
* identities for one shape. `instanceof` then answers false for an error that is in every other
|
|
288
|
+
* respect the right one, the envelope branch below is skipped, and a duplicate-name conflict the
|
|
289
|
+
* user could have fixed in the field is reported as a generic failure instead. Nothing fails
|
|
290
|
+
* loudly at any point, which is why the read is structural rather than nominal.
|
|
291
|
+
*
|
|
292
|
+
* Reading `status` and `errors` is enough to identify the envelope: nothing else this seam meets
|
|
293
|
+
* carries both, and a value that does carries the two fields the mappers actually branch on.
|
|
294
|
+
*/
|
|
295
|
+
const apiEnvelope = (
|
|
296
|
+
error: unknown,
|
|
297
|
+
): { readonly entries: readonly EnvelopeEntry[]; readonly status: number } | undefined => {
|
|
298
|
+
if (
|
|
299
|
+
typeof error !== "object" ||
|
|
300
|
+
error === null ||
|
|
301
|
+
!("status" in error) ||
|
|
302
|
+
!("errors" in error) ||
|
|
303
|
+
typeof error.status !== "number" ||
|
|
304
|
+
!Array.isArray(error.errors)
|
|
305
|
+
) {
|
|
306
|
+
return undefined;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const entries: readonly unknown[] = error.errors;
|
|
310
|
+
|
|
311
|
+
// An entry that is no object states nothing these mappers read, and is skipped: a `null` in
|
|
312
|
+
// the list is a defect of whatever built the envelope, never a reason for the mapper to throw.
|
|
313
|
+
return { entries: entries.filter(isEnvelopeEntry), status: error.status };
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* isConflictEnvelope reports whether a REST envelope failure is a conflict the user
|
|
318
|
+
* can correct in place: an HTTP 409, or an entry whose machine-readable code names
|
|
319
|
+
* a conflict. Creating or renaming an itinerary, a collection or a zone under a name
|
|
320
|
+
* another one carries is exactly that 409, which is why the resource conflict copy
|
|
321
|
+
* names a taken name. A 400 is a validation refusal and is not treated as a conflict
|
|
322
|
+
* here; it surfaces as the envelope's own message in the alert, preserving the
|
|
323
|
+
* API's specific wording.
|
|
324
|
+
*
|
|
325
|
+
* Asked only after the two 409s that answer the request's `Idempotency-Key` are read out
|
|
326
|
+
* ({@link mapRestError}): those name no field the reader could correct, and reading one as a
|
|
327
|
+
* taken name would tell the reader to rename a write the API is making, or has made.
|
|
328
|
+
*/
|
|
329
|
+
const isConflictEnvelope = (envelope: {
|
|
330
|
+
readonly entries: readonly EnvelopeEntry[];
|
|
331
|
+
readonly status: number;
|
|
332
|
+
}): boolean =>
|
|
333
|
+
envelope.status === 409 ||
|
|
334
|
+
envelope.entries.some((entry) => entry.extensions?.code === "CONFLICT");
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* mapRestError turns a thrown REST mutation error into the field/alert split a dialog surfaces,
|
|
338
|
+
* so a REST-backed dialog reads as a tool-backed panel does through {@link mapToolError}. The
|
|
339
|
+
* classification, most specific first:
|
|
340
|
+
*
|
|
341
|
+
* 1. a 409 that answers the request's `Idempotency-Key` rather than the write maps, in the
|
|
342
|
+
* alert, to `formError.writeRunning` (coded `IDEMPOTENCY_KEY_IN_USE`: the first request is
|
|
343
|
+
* still running) or `formError.writeMade` (coded `IDEMPOTENCY_ANSWER_UNAVAILABLE`: the write
|
|
344
|
+
* was made and its answer cannot be given again), read through the classification the tool
|
|
345
|
+
* bus gives the same throw ({@link keyedWriteOf}). Neither asks for the write again, which
|
|
346
|
+
* under a new key would make it twice, and neither names a field;
|
|
347
|
+
* 2. a conflict-like envelope (a 409, or an entry coded CONFLICT) maps, on the field, to the
|
|
348
|
+
* resource's conflict copy (a taken name), or to the shared `formError.conflict` line where
|
|
349
|
+
* the options name no resource;
|
|
350
|
+
* 3. any other envelope surfaces, in the alert, the message of its first entry that is an
|
|
351
|
+
* object, without the space around it, so the API's specific wording (an invalid field,
|
|
352
|
+
* a refused value) reads as the server wrote it. A message that is absent, no string, empty
|
|
353
|
+
* or blank is read as none: a blank alert is a form that refused and would not say why;
|
|
354
|
+
* 4. an envelope with no sentence to read answers the copy's sentence for the code the tool bus
|
|
355
|
+
* classifies the thrown error by (`codeForThrown`: a 403 is `forbidden`, a 404 `not-found`,
|
|
356
|
+
* a 429 `rate-limited`), which is the line {@link mapToolError} answers for the same
|
|
357
|
+
* refusal met through a tool;
|
|
358
|
+
* 5. anything else (a network or parse failure, a status the bus names no code for, a code the
|
|
359
|
+
* copy holds no sentence for) falls to the generic alert line.
|
|
360
|
+
*
|
|
361
|
+
* Pure: it takes the copy, and a resource where the form governs one, and reads no React state,
|
|
362
|
+
* so every REST dialog shares one mapping.
|
|
363
|
+
*/
|
|
364
|
+
export const mapRestError = (error: unknown, options: FormErrorOptions): RestFormError => {
|
|
365
|
+
const envelope = apiEnvelope(error);
|
|
366
|
+
if (envelope) {
|
|
367
|
+
// Read before the conflict below, whose 409 both share: the bus tags the throw exactly as
|
|
368
|
+
// it tags the same refusal met through a tool, so the two surfaces answer one sentence.
|
|
369
|
+
const keyed = keyedWriteOf(failureFromThrown(error));
|
|
370
|
+
if (keyed !== undefined) {
|
|
371
|
+
return {
|
|
372
|
+
fieldError: null,
|
|
373
|
+
formError: keyed === "running" ? options.copy.writeRunning : options.copy.writeMade,
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (isConflictEnvelope(envelope)) {
|
|
378
|
+
return {
|
|
379
|
+
fieldError: resolveCodeMessage("conflict", options.copy.generic, options),
|
|
380
|
+
formError: null,
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// A non-conflict envelope carries the API's own wording, shown as the server wrote it.
|
|
385
|
+
// One with no entry to read, or whose first entry's message is no sentence, reads as the
|
|
386
|
+
// category its status names, and as the generic line where it names none.
|
|
387
|
+
const code = codeForThrown(error);
|
|
388
|
+
|
|
389
|
+
return {
|
|
390
|
+
fieldError: null,
|
|
391
|
+
formError:
|
|
392
|
+
sentenceOf(envelope.entries[0]?.message) ??
|
|
393
|
+
(code === undefined
|
|
394
|
+
? options.copy.generic
|
|
395
|
+
: resolveCodeMessage(code, options.copy.generic, options)),
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return { fieldError: null, formError: options.copy.generic };
|
|
400
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type NavigationInstruction,
|
|
3
|
+
type ManeuverType as NavigationManeuver,
|
|
4
|
+
stepInstruction,
|
|
5
|
+
} from "@mountaya/elements/navigation";
|
|
6
|
+
|
|
7
|
+
import type { ManeuverType } from "../../rules/types.js";
|
|
8
|
+
import type { StudioStrings } from "./en.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* ManeuverCopy is the `maneuver` section this module reads: one entry per maneuver, plus a
|
|
12
|
+
* `Plain` twin for the case where the router named no road.
|
|
13
|
+
*
|
|
14
|
+
* The named entries take the road name, so they are FUNCTIONS rather than strings with a
|
|
15
|
+
* token in them, which is what lets a language put the name somewhere English does not.
|
|
16
|
+
*/
|
|
17
|
+
export type ManeuverCopy = StudioStrings["maneuver"];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* ManeuverGlyph is the vector shape a maneuver renders as on the directions sheet:
|
|
21
|
+
* a set of 24x24 stroke paths and an optional clockwise rotation (degrees) applied
|
|
22
|
+
* about the icon center. Most maneuvers are one upward arrow rotated to the turn
|
|
23
|
+
* direction; the destination gets its own flag.
|
|
24
|
+
*/
|
|
25
|
+
export interface ManeuverGlyph {
|
|
26
|
+
paths: string[];
|
|
27
|
+
rotate?: number | undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// A single upward arrow (shaft + head) in a 24x24 box, stroked in the outline icon
|
|
31
|
+
// style. Rotating it about the center (12, 12) yields every turn direction, so the
|
|
32
|
+
// left/right/slight/sharp/keep maneuvers are one shape at different angles.
|
|
33
|
+
const ARROW: string[] = ["M12 19V6", "m6 12 6-6 6 6"];
|
|
34
|
+
|
|
35
|
+
// A destination flag for the arrival step, distinct from the directional arrows so
|
|
36
|
+
// the end of the route reads at a glance.
|
|
37
|
+
const FLAG: string[] = ["M5 21V4", "M5 4h12l-2.5 3.5L17 11H5"];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* maneuverIcon maps each ManeuverType to its glyph. It is exhaustive over
|
|
41
|
+
* ManeuverType (`Record<ManeuverType, …>`), so a maneuver added to the enum fails
|
|
42
|
+
* the type here until it is given a glyph. The turn family reuses ARROW at a compass
|
|
43
|
+
* angle (clockwise from straight up); depart/continue, the roundabout entries, and
|
|
44
|
+
* unknown fall back to a forward arrow with the instruction text carrying the nuance;
|
|
45
|
+
* goal is the flag.
|
|
46
|
+
*/
|
|
47
|
+
export const maneuverIcon: Record<ManeuverType, ManeuverGlyph> = {
|
|
48
|
+
continue: { paths: ARROW },
|
|
49
|
+
depart: { paths: ARROW },
|
|
50
|
+
"enter-roundabout": { paths: ARROW },
|
|
51
|
+
"exit-roundabout": { paths: ARROW },
|
|
52
|
+
goal: { paths: FLAG },
|
|
53
|
+
"keep-left": { paths: ARROW, rotate: 330 },
|
|
54
|
+
"keep-right": { paths: ARROW, rotate: 30 },
|
|
55
|
+
"sharp-left": { paths: ARROW, rotate: 225 },
|
|
56
|
+
"sharp-right": { paths: ARROW, rotate: 135 },
|
|
57
|
+
"slight-left": { paths: ARROW, rotate: 315 },
|
|
58
|
+
"slight-right": { paths: ARROW, rotate: 45 },
|
|
59
|
+
"turn-left": { paths: ARROW, rotate: 270 },
|
|
60
|
+
"turn-right": { paths: ARROW, rotate: 90 },
|
|
61
|
+
unknown: { paths: ARROW },
|
|
62
|
+
uturn: { paths: ARROW, rotate: 180 },
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* namesTheWay reports whether an instruction is said with its maneuver's own key, the one that
|
|
67
|
+
* takes the way's name: a routing maneuver's, or the waypoint's an itinerary's route says.
|
|
68
|
+
*/
|
|
69
|
+
const namesTheWay = (
|
|
70
|
+
instruction: NavigationInstruction,
|
|
71
|
+
): instruction is Extract<NavigationInstruction, { readonly key: NavigationManeuver }> =>
|
|
72
|
+
"name" in instruction.arguments && !("exit" in instruction.arguments);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* maneuverText resolves the localized instruction for a step from its maneuver
|
|
76
|
+
* type, way name, and (for a roundabout) the exit to take.
|
|
77
|
+
*
|
|
78
|
+
* Which sentence is said is the geo layer's rule, `stepInstruction` of
|
|
79
|
+
* `@mountaya/elements/navigation`, and this resolves the copy key it answers with the arguments
|
|
80
|
+
* it names. When the step names a way (not empty and not the "-" the router writes for an
|
|
81
|
+
* unnamed one) it reads the named sentence, `copy[type](name)` ("Turn left onto Main Street");
|
|
82
|
+
* otherwise the nameless variant ("Turn left"). A roundabout carrying an exit number surfaces it
|
|
83
|
+
* through the shared `roundaboutExit` pair ("At the roundabout, take exit 2 onto Main Street").
|
|
84
|
+
* The keys live under `maneuver.*`, one pair (`<TYPE>` / `<TYPE>Plain`) per ManeuverType, so
|
|
85
|
+
* every maneuver has both forms in every language.
|
|
86
|
+
*
|
|
87
|
+
* @param exitNumber The roundabout exit to take. 0, the default, names none.
|
|
88
|
+
*/
|
|
89
|
+
export const maneuverText = (
|
|
90
|
+
copy: ManeuverCopy,
|
|
91
|
+
type: ManeuverType,
|
|
92
|
+
name: string,
|
|
93
|
+
exitNumber = 0,
|
|
94
|
+
): string => {
|
|
95
|
+
const instruction = stepInstruction({ exitNumber, maneuver: type, name });
|
|
96
|
+
|
|
97
|
+
switch (instruction.key) {
|
|
98
|
+
case "roundaboutExit":
|
|
99
|
+
return copy.roundaboutExit(instruction.arguments.exit, instruction.arguments.name);
|
|
100
|
+
case "roundaboutExitPlain":
|
|
101
|
+
return copy.roundaboutExitPlain(instruction.arguments.exit);
|
|
102
|
+
default:
|
|
103
|
+
return namesTheWay(instruction)
|
|
104
|
+
? copy[instruction.key](instruction.arguments.name)
|
|
105
|
+
: copy[instruction.key];
|
|
106
|
+
}
|
|
107
|
+
};
|