@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,83 @@
|
|
|
1
|
+
import type { StudioToolDefinition } from "../../viewer/rules/context.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* setProfileMarker drops (or clears) the map marker that echoes the elevation
|
|
5
|
+
* profile's hovered position, so the point under the chart cursor is shown on
|
|
6
|
+
* the map. The follow-marker is available to every viewer: no entitlement
|
|
7
|
+
* gates this seam, and the surfaces `profile-insights` gates (the elevation
|
|
8
|
+
* panel's enrichment-derived surface and way-type rows and bars) live in their
|
|
9
|
+
* own components and tools. This handler is a thin pass-through: it guards on a
|
|
10
|
+
* mounted map and drives ctx.map.setProfileMarker, returning a structured
|
|
11
|
+
* failure rather than throwing when no map is present. ctx is the first
|
|
12
|
+
* positional parameter.
|
|
13
|
+
*/
|
|
14
|
+
export const setProfileMarker: StudioToolDefinition<"studio.itinerary.profileMarker.set"> = {
|
|
15
|
+
handler: (ctx, input) => {
|
|
16
|
+
if (!ctx.map) {
|
|
17
|
+
return { code: "no-map", error: "no map is currently mounted", ok: false };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
ctx.map.setProfileMarker(input.lngLat, input.icon ?? null);
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
ok: true,
|
|
24
|
+
summary: input.lngLat ? "Placed the profile marker." : "Cleared the profile marker.",
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* setProfileSheet opens the elevation profile's bottom sheet to a snap point on a
|
|
31
|
+
* compact viewport: `peek` (the characteristics strip alone), `half` (+ the
|
|
32
|
+
* elevation chart), or `full` (+ the surface and way-type analysis bars).
|
|
33
|
+
*
|
|
34
|
+
* It is the touch-reachable replacement for the desktop profile's hover reveal: a
|
|
35
|
+
* phone has no hover, so the analysis bars would otherwise be unreachable. It writes
|
|
36
|
+
* only the UI store, and is inert on a desktop layout, which renders the fixed dock.
|
|
37
|
+
* ctx is the first positional parameter.
|
|
38
|
+
*/
|
|
39
|
+
export const setProfileSheet: StudioToolDefinition<"studio.itinerary.profile.sheet.set"> = {
|
|
40
|
+
handler: (ctx, input) => {
|
|
41
|
+
ctx.ui.getState().setProfileSheetSnap(input.snap);
|
|
42
|
+
|
|
43
|
+
return { ok: true, summary: `Opened the elevation profile to ${input.snap}.` };
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* setProfilePace sets, or clears, the reader's own travel pace for the open
|
|
49
|
+
* itinerary, so the profile's duration, its per-segment rows and its hover speed
|
|
50
|
+
* cell are all read at a rate THEY named rather than the one the author committed.
|
|
51
|
+
*
|
|
52
|
+
* It writes the UI store and nothing else. No itinerary is mutated, no request is
|
|
53
|
+
* made from here (the surface watches the override and asks the server for the
|
|
54
|
+
* re-time), and nothing is persisted, which is what makes this safe to offer an
|
|
55
|
+
* anonymous embed visitor. A null pace is the way back: the committed figures are
|
|
56
|
+
* still in the itinerary store, so dropping the override restores them with no
|
|
57
|
+
* refetch.
|
|
58
|
+
*
|
|
59
|
+
* The override is keyed to the itinerary it was entered against, read off the
|
|
60
|
+
* active itinerary here, so opening a different route shows the author's pace
|
|
61
|
+
* without anything having to clear it. A pace set with no itinerary open is
|
|
62
|
+
* refused as `no-session` rather than stored against nothing: it is an ordering
|
|
63
|
+
* mistake, not a fault. Clearing one is accepted either way, so a surface
|
|
64
|
+
* unmounting never has to check first. ctx is the first positional parameter.
|
|
65
|
+
*/
|
|
66
|
+
export const setProfilePace: StudioToolDefinition<"studio.itinerary.profile.pace.set"> = {
|
|
67
|
+
handler: (ctx, input) => {
|
|
68
|
+
if (input.speedKmh === null) {
|
|
69
|
+
ctx.ui.getState().setProfilePace(null);
|
|
70
|
+
|
|
71
|
+
return { ok: true, summary: "Cleared the reader's pace; showing the author's figures." };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const itineraryId = ctx.ui.getState().activeItinerary?.id;
|
|
75
|
+
if (!itineraryId) {
|
|
76
|
+
return { code: "no-session", error: "no itinerary is currently open", ok: false };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
ctx.ui.getState().setProfilePace({ itineraryId, speedKmh: input.speedKmh });
|
|
80
|
+
|
|
81
|
+
return { ok: true, summary: `Reading the itinerary at ${input.speedKmh} km/h.` };
|
|
82
|
+
},
|
|
83
|
+
};
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import type { ItineraryWithDetails } from "@mountaya/client";
|
|
2
|
+
|
|
3
|
+
import { failureFromThrown } from "../../bus/rules/handlerErrors.js";
|
|
4
|
+
import type { ToolResult } from "../../bus/rules/types.js";
|
|
5
|
+
import { isOlderItinerary } from "../../segments/rules/itineraryEcho.js";
|
|
6
|
+
import type { StudioApi, StudioToolContext } from "../../viewer/rules/context.js";
|
|
7
|
+
import { refuseUngrantedItinerary } from "../../viewer/rules/ownership.js";
|
|
8
|
+
import {
|
|
9
|
+
isAnswerUnavailable,
|
|
10
|
+
isKeyInUse,
|
|
11
|
+
isRevisionConflict,
|
|
12
|
+
isSegmentDeleteNotEdge,
|
|
13
|
+
} from "../rules/restErrors.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* WriteThroughOptions describe one optimistic write against the active itinerary.
|
|
17
|
+
* itineraryId scopes the query-cache eviction (its detail key) so the
|
|
18
|
+
* StudioProvider's useItinerary refetch reconciles the active slot with the
|
|
19
|
+
* persisted truth. optimistic applies the local patch the user sees immediately
|
|
20
|
+
* (append a segment, recolor, drop a waypoint) before the request resolves; pass
|
|
21
|
+
* a no-op for a write whose result only the refetch can show (a geometry edit
|
|
22
|
+
* cascades to neighbours server-side, so it patches no neighbour optimistically).
|
|
23
|
+
* persist runs the mutation against the resolved api seam (passed in so the
|
|
24
|
+
* caller needs no null check, since writeThrough has already proved it present) and
|
|
25
|
+
* resolves the value the success summary describes (or void). summary renders that
|
|
26
|
+
* value into the human/LLM-readable success line. conflictSummary, when present,
|
|
27
|
+
* is surfaced on a lost-revision conflict instead of the generic conflict message:
|
|
28
|
+
* the caller names the operation that lost the race.
|
|
29
|
+
*/
|
|
30
|
+
interface WriteThroughOptions<T> {
|
|
31
|
+
conflictSummary?: string | undefined;
|
|
32
|
+
itineraryId: string;
|
|
33
|
+
optimistic: () => void;
|
|
34
|
+
persist: (api: StudioApi) => Promise<T>;
|
|
35
|
+
/**
|
|
36
|
+
* skipTileRefresh suppresses the post-persist itinerary tile bust. A geometry
|
|
37
|
+
* edit-commit sets it because the bust must run AFTER the edit engine tears
|
|
38
|
+
* down: the dual-render is active mid-commit and MapLibre does not repaint the
|
|
39
|
+
* just-saved geometry at the current zoom while the edit styling is applied
|
|
40
|
+
* (the same bust runs fine once the map is idle, and the editCommit tool fires it
|
|
41
|
+
* after endSegmentEdit/endWaypointEdit). Other writes (recolor, delete, speed)
|
|
42
|
+
* run while the map is idle, so they leave it unset and refresh here.
|
|
43
|
+
*/
|
|
44
|
+
skipTileRefresh?: boolean | undefined;
|
|
45
|
+
summary: (value: T) => string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** An itinerary entity a write can patch, by the id it keeps across the patch. */
|
|
49
|
+
interface Identified {
|
|
50
|
+
readonly id: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* rollBackFields answers `now` with each field the patch changed, and nothing has changed since,
|
|
55
|
+
* back at its `before` value, or absent where `before` lacks it; `now` itself when no field is.
|
|
56
|
+
*/
|
|
57
|
+
const rollBackFields = <R extends object>(before: R, after: R, now: R): R => {
|
|
58
|
+
let restored: R | undefined;
|
|
59
|
+
|
|
60
|
+
// The assertion holds because `before` and `after` are both R by the signature, so each key
|
|
61
|
+
// they enumerate indexes an R. Object.keys is typed string[] and cannot say so.
|
|
62
|
+
for (const key of new Set([...Object.keys(before), ...Object.keys(after)]) as Set<keyof R>) {
|
|
63
|
+
if (Object.is(after[key], before[key]) || !Object.is(now[key], after[key])) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
restored ??= { ...now };
|
|
67
|
+
if (Object.hasOwn(before, key)) {
|
|
68
|
+
restored[key] = before[key];
|
|
69
|
+
} else {
|
|
70
|
+
Reflect.deleteProperty(restored, key);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return restored ?? now;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* rollBackEntities undoes one write's patch on a list of entities and keeps every change made
|
|
79
|
+
* since, for the reason {@link rollBack} gives. It answers `now` itself when it keeps every entity
|
|
80
|
+
* as it stands and puts none back.
|
|
81
|
+
*/
|
|
82
|
+
const rollBackEntities = <E extends Identified>(
|
|
83
|
+
before: readonly E[],
|
|
84
|
+
after: readonly E[],
|
|
85
|
+
now: E[],
|
|
86
|
+
): E[] => {
|
|
87
|
+
const originals = new Map(before.map((entity) => [entity.id, entity]));
|
|
88
|
+
const patched = new Map(after.map((entity) => [entity.id, entity]));
|
|
89
|
+
const present = new Set(now.map((entity) => entity.id));
|
|
90
|
+
const entities: E[] = [];
|
|
91
|
+
|
|
92
|
+
for (const entity of now) {
|
|
93
|
+
const original = originals.get(entity.id);
|
|
94
|
+
const patch = patched.get(entity.id);
|
|
95
|
+
if (patch === undefined || patch === original) {
|
|
96
|
+
// Not the patch's: untouched by it, or added since.
|
|
97
|
+
entities.push(entity);
|
|
98
|
+
} else if (original === undefined) {
|
|
99
|
+
// The patch created this one: gone again, unless something has touched it since.
|
|
100
|
+
if (patch !== entity) {
|
|
101
|
+
entities.push(entity);
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
entities.push(patch === entity ? original : rollBackFields(original, patch, entity));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// An entity the patch removed, and nothing has brought back since, returns where it stood.
|
|
109
|
+
for (const [index, original] of before.entries()) {
|
|
110
|
+
if (!patched.has(original.id) && !present.has(original.id)) {
|
|
111
|
+
entities.splice(Math.min(index, entities.length), 0, original);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const kept =
|
|
116
|
+
entities.length === now.length && entities.every((entity, index) => entity === now[index]);
|
|
117
|
+
|
|
118
|
+
return kept ? now : entities;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* rollBack undoes one write's optimistic patch on the active itinerary as the store holds it
|
|
123
|
+
* now, and keeps every change made since.
|
|
124
|
+
*
|
|
125
|
+
* `before` and `after` are the active itinerary either side of the patch, and `now` is what the
|
|
126
|
+
* store holds when the write fails. Store updates are immutable, so whatever the patch did not
|
|
127
|
+
* touch keeps its identity across the patch, and whatever nothing has touched since is the same
|
|
128
|
+
* value in `now`. Each field the patch changed, on the itinerary or on one of its segments,
|
|
129
|
+
* waypoints or groups, goes back to its `before` value only while `now` still holds the patched
|
|
130
|
+
* value, so a concurrent write that succeeded, or a collaborator's change mirrored in from the
|
|
131
|
+
* change feed, stands, on the entity the patch touched as much as on any other. An entity the
|
|
132
|
+
* patch added goes, and one it removed returns, unless a later change touched it. When `now` is
|
|
133
|
+
* still `after`, the answer is `before` exactly. When the reader has moved to another itinerary
|
|
134
|
+
* or closed it, nothing of the patch is on screen and `now` stands. When later changes replaced
|
|
135
|
+
* everything the patch set, or the patch set nothing, the answer is `now` itself, so the store
|
|
136
|
+
* never re-seats an equal copy of what it holds.
|
|
137
|
+
*/
|
|
138
|
+
const rollBack = (
|
|
139
|
+
before: ItineraryWithDetails | null,
|
|
140
|
+
after: ItineraryWithDetails | null,
|
|
141
|
+
now: ItineraryWithDetails | null,
|
|
142
|
+
): ItineraryWithDetails | null => {
|
|
143
|
+
if (now === after) {
|
|
144
|
+
return before;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (
|
|
148
|
+
before === null ||
|
|
149
|
+
after === null ||
|
|
150
|
+
now === null ||
|
|
151
|
+
now.id !== after.id ||
|
|
152
|
+
before.id !== after.id
|
|
153
|
+
) {
|
|
154
|
+
return now;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// The lists are rolled back entity by entity, so their own entries override the field rule's.
|
|
158
|
+
const fields = rollBackFields(before, after, now);
|
|
159
|
+
const groups = rollBackEntities(before.groups, after.groups, now.groups);
|
|
160
|
+
const segments = rollBackEntities(before.segments, after.segments, now.segments);
|
|
161
|
+
const waypoints = rollBackEntities(before.waypoints, after.waypoints, now.waypoints);
|
|
162
|
+
if (
|
|
163
|
+
fields === now &&
|
|
164
|
+
groups === now.groups &&
|
|
165
|
+
segments === now.segments &&
|
|
166
|
+
waypoints === now.waypoints
|
|
167
|
+
) {
|
|
168
|
+
return now;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return { ...fields, groups, segments, waypoints };
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* settled runs one step of the reconciliation that follows a landed write, and waits for it
|
|
176
|
+
* whatever it does.
|
|
177
|
+
*
|
|
178
|
+
* A step reaches a seam a host wrote (the cache, the persistence's read, the map). A cache
|
|
179
|
+
* whose eviction refetches and fails, a read that rejects and a map whose style is reloading
|
|
180
|
+
* each fail a step, and none of them says anything about the write, which is saved. So the
|
|
181
|
+
* failure ends here: reported, it would read as a failed write and roll back a patch that is
|
|
182
|
+
* true. The view keeps its optimistic patch, and the seam that failed has its own way to say
|
|
183
|
+
* so to its host.
|
|
184
|
+
*/
|
|
185
|
+
const settled = async (step: () => unknown): Promise<void> => {
|
|
186
|
+
try {
|
|
187
|
+
await step();
|
|
188
|
+
} catch {
|
|
189
|
+
// The edit is saved. Reconciling the view is the part that did not happen.
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/** What {@link failedWrite} reads of the write that failed. */
|
|
194
|
+
interface FailedWrite {
|
|
195
|
+
/** The active itinerary once the optimistic patch was applied. */
|
|
196
|
+
readonly after: ItineraryWithDetails | null;
|
|
197
|
+
/** The active itinerary before the optimistic patch. */
|
|
198
|
+
readonly before: ItineraryWithDetails | null;
|
|
199
|
+
/** What the write's request failed with. */
|
|
200
|
+
readonly error: unknown;
|
|
201
|
+
/** The cache entry the write's itinerary is held under. */
|
|
202
|
+
readonly itinerary: { readonly id: string; readonly kind: "itinerary" };
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* failedWrite answers a write whose request failed and did not make the write: it undoes the
|
|
207
|
+
* write's patch and nothing else, then answers the two failures the studio classifies itself
|
|
208
|
+
* and re-throws every other for the bus to classify, once the rollback is done.
|
|
209
|
+
*
|
|
210
|
+
* A lost revision reads the itinerary again and answers a conflict; a delete the chain's shape
|
|
211
|
+
* forbids reads it again and answers its own refusal. See {@link writeThrough}.
|
|
212
|
+
*/
|
|
213
|
+
const failedWrite = async <T>(
|
|
214
|
+
{ api, ui }: Pick<StudioToolContext, "ui"> & { readonly api: StudioApi },
|
|
215
|
+
options: WriteThroughOptions<T>,
|
|
216
|
+
{ after, before, error, itinerary }: FailedWrite,
|
|
217
|
+
): Promise<ToolResult<undefined>> => {
|
|
218
|
+
// Undo this write's patch and nothing else.
|
|
219
|
+
const now = ui.getState().activeItinerary;
|
|
220
|
+
const restored = rollBack(before, after, now);
|
|
221
|
+
if (restored !== now) {
|
|
222
|
+
ui.getState().setActiveItinerary(restored);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (isRevisionConflict(error)) {
|
|
226
|
+
// The revision the edit was built on is stale; the local copy can no longer
|
|
227
|
+
// be trusted, so refetch the persisted truth before surfacing the conflict. The
|
|
228
|
+
// conflict is the answer whatever the eviction does.
|
|
229
|
+
await settled(() => api.cache.invalidate(itinerary));
|
|
230
|
+
|
|
231
|
+
return {
|
|
232
|
+
code: "conflict",
|
|
233
|
+
error:
|
|
234
|
+
options.conflictSummary ??
|
|
235
|
+
"The itinerary changed since this edit started. Reloaded the latest version.",
|
|
236
|
+
ok: false,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (isSegmentDeleteNotEdge(error)) {
|
|
241
|
+
// The chain the edit was built on is not the itinerary's: the API holds an interior
|
|
242
|
+
// segment where the editor offered an end. Read it again, as a conflict is, and tell the
|
|
243
|
+
// person. Classified here rather than re-thrown, because a host's bus may not carry the
|
|
244
|
+
// studio's recognizers, and without them a chain-shape refusal would read as `internal`.
|
|
245
|
+
// The classifier carries the refusal's own `detail`, as the bus's does for any domain error.
|
|
246
|
+
await settled(() => api.cache.invalidate(itinerary));
|
|
247
|
+
|
|
248
|
+
return failureFromThrown(error);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// The rollback is done; the classification is the bus's. See writeThrough's header.
|
|
252
|
+
throw error;
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* writeThrough is the single optimistic-write mechanism every mutating
|
|
257
|
+
* itinerary tool builds on. It holds the active itinerary either side of the
|
|
258
|
+
* caller's optimistic patch, which shows the change instantly, awaits the
|
|
259
|
+
* REST mutation, then on success evicts the itinerary's detail query, so the
|
|
260
|
+
* StudioProvider's useItinerary refetch re-mirrors the persisted itinerary
|
|
261
|
+
* into the active slot, reconciling any server-side cascade (a geometry edit
|
|
262
|
+
* re-routes the edited segment's neighbours, so the optimistic patch only
|
|
263
|
+
* ever touches the edited feature and the refetch fills in the rest).
|
|
264
|
+
*
|
|
265
|
+
* A write is failed by its request alone. Once the request has answered, the eviction, the
|
|
266
|
+
* read-back, the tile refresh and the caller's summary run outside the rollback: a seam that
|
|
267
|
+
* throws there leaves the result ok and the patch on screen (see {@link settled}), and a
|
|
268
|
+
* summary that throws is replaced by a plain one.
|
|
269
|
+
*
|
|
270
|
+
* On failure it undoes its own patch and nothing else, field by field (see
|
|
271
|
+
* {@link rollBack}): each field the patch set goes back unless a later change
|
|
272
|
+
* replaced it, so a concurrent write that succeeded, or a collaborator's
|
|
273
|
+
* change that arrived meanwhile, stands. A lost-revision conflict then still
|
|
274
|
+
* evicts the cache (the stale revision must be replaced by a refetch) and
|
|
275
|
+
* answers a conflict failure, and a not-an-edge segment delete answers its
|
|
276
|
+
* own message, with the server's sentence as its detail. Anything else it
|
|
277
|
+
* RE-THROWS, once the rollback is done.
|
|
278
|
+
*
|
|
279
|
+
* Two failures answer the write's `Idempotency-Key` rather than the write, and neither is a
|
|
280
|
+
* write that failed, so neither is rolled back. One says the write was made and its answer
|
|
281
|
+
* cannot be given again: it is reconciled as a landed write, read again, and answered `ok`. The
|
|
282
|
+
* other says the write's first request is still running, past the client's own repeats under
|
|
283
|
+
* the same key: the itinerary is read again and the failure re-thrown, which the bus answers as a
|
|
284
|
+
* conflict tagged as a write still being made, never as a taken name. Taking either for a failed
|
|
285
|
+
* write would undo a write the API holds, and a caller that repeated it would make it twice.
|
|
286
|
+
*
|
|
287
|
+
* Classifying a throw can need the host's own recognizers (a domain error
|
|
288
|
+
* the host throws is a fact only the host knows), and the bus is where those
|
|
289
|
+
* live. Its dispatch boundary catches, classifies and returns the same
|
|
290
|
+
* structured failure, so a caller still never faces a rejection; doing it
|
|
291
|
+
* here as well would mean either a second copy of the recognizer list or a
|
|
292
|
+
* classification made without it. ctx is the first positional parameter. The
|
|
293
|
+
* api seam must be wired: a render-free context returns a failure rather than
|
|
294
|
+
* dropping the write.
|
|
295
|
+
*
|
|
296
|
+
* A write on the open itinerary from a reader who holds no write grant on it is refused with
|
|
297
|
+
* `forbidden` before the patch or the request ({@link refuseUngrantedItinerary}).
|
|
298
|
+
*
|
|
299
|
+
* It answers a summary and no data, so its result is the answer of a verb that states no data.
|
|
300
|
+
* A verb that states data builds its own answer from this one.
|
|
301
|
+
*/
|
|
302
|
+
export const writeThrough = async <T>(
|
|
303
|
+
ctx: StudioToolContext,
|
|
304
|
+
options: WriteThroughOptions<T>,
|
|
305
|
+
): Promise<ToolResult<undefined>> => {
|
|
306
|
+
if (!ctx.api) {
|
|
307
|
+
return { code: "no-api", error: "write-through: no persistence seam", ok: false };
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// A reader who may not edit the open itinerary is refused before the patch shows and before
|
|
311
|
+
// anything is sent, as the API would refuse the write.
|
|
312
|
+
const ungranted = refuseUngrantedItinerary(ctx, options.itineraryId);
|
|
313
|
+
if (ungranted) {
|
|
314
|
+
return ungranted;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const { api, ui } = ctx;
|
|
318
|
+
const itinerary = { id: options.itineraryId, kind: "itinerary" } as const;
|
|
319
|
+
|
|
320
|
+
// Hold the active itinerary either side of the patch: store updates are immutable,
|
|
321
|
+
// so the two references are what rollBack compares the store against on a failed
|
|
322
|
+
// write. The selection is left untouched, since the patch never moves it.
|
|
323
|
+
const before = ui.getState().activeItinerary;
|
|
324
|
+
options.optimistic();
|
|
325
|
+
const after = ui.getState().activeItinerary;
|
|
326
|
+
|
|
327
|
+
// What the write answered, held apart from whether it landed: a write the API made may have no
|
|
328
|
+
// answer to give again.
|
|
329
|
+
let answer: { readonly value: T } | undefined;
|
|
330
|
+
try {
|
|
331
|
+
answer = { value: await options.persist(api) };
|
|
332
|
+
} catch (error) {
|
|
333
|
+
if (isKeyInUse(error)) {
|
|
334
|
+
// The first request with the write's key is still running, and may yet make the write, so
|
|
335
|
+
// nothing is undone: the itinerary is read again, and the refusal is the bus's to classify,
|
|
336
|
+
// a conflict tagged as a write still being made, which asks for a read rather than the
|
|
337
|
+
// write again under a new key.
|
|
338
|
+
await settled(() => api.cache.invalidate(itinerary));
|
|
339
|
+
|
|
340
|
+
throw error;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (!isAnswerUnavailable(error)) {
|
|
344
|
+
return await failedWrite({ api, ui }, options, { after, before, error, itinerary });
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// The write was made, and the API cannot give its answer again. Nothing is undone, and the
|
|
348
|
+
// reconciliation below reads the itinerary as the write left it.
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// The write has landed. Everything below reconciles the view with it, and none of it can
|
|
352
|
+
// turn a saved edit into a reported failure or roll its patch back: each step is settled by
|
|
353
|
+
// itself (see `settled`).
|
|
354
|
+
|
|
355
|
+
// Evict the detail query so the StudioProvider refetch reconciles the
|
|
356
|
+
// active slot with the persisted itinerary (including any neighbour cascade).
|
|
357
|
+
await settled(() => api.cache.invalidate(itinerary));
|
|
358
|
+
|
|
359
|
+
/*
|
|
360
|
+
* An untiled seam reconciles ITSELF, because the refetch the eviction above counts on is
|
|
361
|
+
* not going to happen.
|
|
362
|
+
*
|
|
363
|
+
* The eviction is only half a reconciliation: it makes a query stale, and something else
|
|
364
|
+
* (`useStudioItinerary`, keyed on an `itineraryId` the host passed) has to re-read and mirror
|
|
365
|
+
* the result into the active slot. Several writes depend on that and patch nothing
|
|
366
|
+
* optimistically, `segment.editCommit` among them, because a geometry commit cascades to its
|
|
367
|
+
* neighbours server-side and a caller cannot guess the cascade. A studio with no `itineraryId`
|
|
368
|
+
* never re-reads, so on a local seam the write landed in storage and the rail kept showing the
|
|
369
|
+
* itinerary as it was before it: measured, a committed segment was in `localStorage` and
|
|
370
|
+
* absent from the segment list, the profile and the map at once.
|
|
371
|
+
*
|
|
372
|
+
* Reading it back from the SAME seam closes that, and only for a seam that says it is not in
|
|
373
|
+
* the tiles: a remote one keeps exactly the behaviour it had, refetch and all. Best-effort,
|
|
374
|
+
* because the write has already succeeded: a read that fails must not turn a landed edit into
|
|
375
|
+
* a reported failure, and the surface still has its optimistic patch either way.
|
|
376
|
+
*/
|
|
377
|
+
if (!api.persistence.tiled) {
|
|
378
|
+
await settled(async () => {
|
|
379
|
+
const persisted = await api.persistence.fetchItineraryRecord(options.itineraryId);
|
|
380
|
+
const view = ui.getState().activeItinerary;
|
|
381
|
+
// Only onto the same itinerary, and never over a newer one: a later write's
|
|
382
|
+
// read-back may have landed first.
|
|
383
|
+
if (view?.id === persisted.id && !isOlderItinerary(persisted, view)) {
|
|
384
|
+
ui.getState().setActiveItinerary(persisted);
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// Tell MapLibre to refetch the itinerary vector tiles in place so the
|
|
390
|
+
// persisted geometry shows at the current zoom without a pan or a zoom-
|
|
391
|
+
// change to evict the cache. Render-free contexts (no map mounted, no
|
|
392
|
+
// itinerary tiles attached) treat this as a no-op. A geometry edit-commit
|
|
393
|
+
// skips it here (skipTileRefresh) and refreshes after the edit engine tears
|
|
394
|
+
// down: a bust fired mid-edit does not repaint the saved geometry at the
|
|
395
|
+
// current zoom.
|
|
396
|
+
if (!options.skipTileRefresh) {
|
|
397
|
+
await settled(() => ctx.map?.refreshItineraryTiles());
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const saved = `Saved the change to itinerary ${options.itineraryId}.`;
|
|
401
|
+
if (answer === undefined) {
|
|
402
|
+
// The write was made and its answer is not there to describe: the summary says what is
|
|
403
|
+
// known, and the itinerary read again shows the rest.
|
|
404
|
+
return {
|
|
405
|
+
ok: true,
|
|
406
|
+
summary: `${saved} Its answer could not be given again, so it was read again.`,
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
try {
|
|
411
|
+
return { ok: true, summary: options.summary(answer.value) };
|
|
412
|
+
} catch {
|
|
413
|
+
// The caller's summary read something the answer did not hold. The edit is saved all the
|
|
414
|
+
// same, so the result says that much in words of its own.
|
|
415
|
+
return { ok: true, summary: saved };
|
|
416
|
+
}
|
|
417
|
+
};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The studio's server-state cache, named by RESOURCE rather than by query key.
|
|
3
|
+
*
|
|
4
|
+
* A studio tool writes to the platform and then has to make the affected reads stale. A handler
|
|
5
|
+
* that built query keys would know the key SHAPE, and a shape that gains a segment would silently
|
|
6
|
+
* orphan every reader still building the old one: a key is an array, two arrays that differ are
|
|
7
|
+
* simply two entries, and nothing anywhere fails.
|
|
8
|
+
*
|
|
9
|
+
* So the seam is semantic. A handler says WHICH RESOURCE it changed (`{ kind: "itinerary", id }`)
|
|
10
|
+
* and the host decides what that is in its cache. Three consequences follow:
|
|
11
|
+
*
|
|
12
|
+
* 1. **A handler cannot build a key, so it cannot build a wrong one.** The vocabulary is the
|
|
13
|
+
* client's {@link ResourceRef}, which is closed, so naming a resource that does not exist is a
|
|
14
|
+
* compile error.
|
|
15
|
+
* 2. **A host that caches differently still works.** `createStudioCache` of
|
|
16
|
+
* `@mountaya/studio-react` binds this seam to TanStack Query over the published operation
|
|
17
|
+
* keys. A consumer with their own data layer implements these few functions instead of
|
|
18
|
+
* adopting a key convention.
|
|
19
|
+
* 3. **A key-shape change is one edit.** The binding moves; the handlers do not.
|
|
20
|
+
*
|
|
21
|
+
* The vocabulary is the client's because the resources are the CONTRACT's (an itinerary, a zone,
|
|
22
|
+
* a collection), and the seam is the studio's because a handler is what writes through it.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type {
|
|
26
|
+
CategoryActivities,
|
|
27
|
+
Collection,
|
|
28
|
+
ItineraryWithDetails,
|
|
29
|
+
Layers,
|
|
30
|
+
ResourceRef,
|
|
31
|
+
Zone,
|
|
32
|
+
} from "@mountaya/client";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* StudioCacheValues is what the studio reads and seeds under each kind of resource: the record
|
|
36
|
+
* the client answers for it.
|
|
37
|
+
*
|
|
38
|
+
* It types {@link StudioCache.get} and {@link StudioCache.set} by the key, so a read names no type
|
|
39
|
+
* of its own and a seed of another shape under a kind does not compile. A kind the studio only
|
|
40
|
+
* marks stale (a listing, read a page at a time and narrowed by its filters, or a collection's
|
|
41
|
+
* contents) has no entry: it is named to `invalidate` and `evict` alone.
|
|
42
|
+
*/
|
|
43
|
+
export interface StudioCacheValues {
|
|
44
|
+
/** The activity catalog. */
|
|
45
|
+
activities: CategoryActivities[];
|
|
46
|
+
/** One collection's own record. */
|
|
47
|
+
collection: Collection;
|
|
48
|
+
/** One itinerary, as the editor holds it or as it is published. */
|
|
49
|
+
itinerary: ItineraryWithDetails;
|
|
50
|
+
/** The layers manifest the credential may draw. */
|
|
51
|
+
layers: Layers;
|
|
52
|
+
/** One zone. */
|
|
53
|
+
zone: Zone;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* StudioCacheRef names one entry the studio reads or seeds: a {@link ResourceRef} whose kind
|
|
58
|
+
* {@link StudioCacheValues} holds a record for.
|
|
59
|
+
*/
|
|
60
|
+
export type StudioCacheRef<Kind extends keyof StudioCacheValues = keyof StudioCacheValues> =
|
|
61
|
+
Extract<ResourceRef, { kind: Kind }>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* StudioCache is what a studio tool may do to the cache: read one entry, seed one entry, mark
|
|
65
|
+
* several stale, and, where the cache states it, remove one ({@link StudioCache.evict}). A read
|
|
66
|
+
* and a seed are typed by the kind of resource their key names ({@link StudioCacheValues}).
|
|
67
|
+
*
|
|
68
|
+
* The verbs are deliberately few. A handler that could reach a real cache client would
|
|
69
|
+
* reach for `fetchQuery`, `cancelQueries`, or a subscription, and each of those is a data-layer
|
|
70
|
+
* decision the surface owns, made from inside a handler that cannot see the surface.
|
|
71
|
+
*
|
|
72
|
+
* `invalidate` is VARIADIC because a write is almost never one resource: creating an itinerary
|
|
73
|
+
* inside a collection touches the itinerary, its listing and the collection's contents, and
|
|
74
|
+
* passing them together is what makes that one awaited round rather than one per resource.
|
|
75
|
+
*/
|
|
76
|
+
export interface StudioCache {
|
|
77
|
+
/**
|
|
78
|
+
* Remove a resource's entry, so a later `get` of it answers `undefined`.
|
|
79
|
+
*
|
|
80
|
+
* `invalidate` marks an entry stale, and a cache that keeps stale data goes on answering it
|
|
81
|
+
* until a read replaces it. A deleted resource has no such read to wait for, so a delete calls
|
|
82
|
+
* this for what it deleted, beside its `invalidate` and never in its place. Its reach is
|
|
83
|
+
* `invalidate`'s for the same key: every entry that verb would mark stale is removed.
|
|
84
|
+
*
|
|
85
|
+
* Optional, and a property, so a host forwards one it may not hold. A cache that leaves it
|
|
86
|
+
* out is told `invalidate` alone and may go on answering the deleted record, which a handler
|
|
87
|
+
* that must not read one back guards against with a record of its own.
|
|
88
|
+
*/
|
|
89
|
+
evict?: ((key: ResourceRef) => void) | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* The value currently cached for a resource, or `undefined` when nothing has read it yet.
|
|
92
|
+
*
|
|
93
|
+
* The synchronous read a handler uses to answer from what the surface already holds, which
|
|
94
|
+
* is the difference between a tool that repaints instantly and one that spends a request
|
|
95
|
+
* to receive what is on screen. It never fetches: an empty cache answers `undefined` and the
|
|
96
|
+
* handler decides whether that is a reason to write or a reason to stop.
|
|
97
|
+
*/
|
|
98
|
+
get: <Kind extends keyof StudioCacheValues>(
|
|
99
|
+
key: StudioCacheRef<Kind>,
|
|
100
|
+
) => StudioCacheValues[Kind] | undefined;
|
|
101
|
+
/** Mark these resources stale, so the next read fetches the persisted truth. */
|
|
102
|
+
invalidate: (...keys: readonly ResourceRef[]) => Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Seed a resource with a value the handler already has.
|
|
105
|
+
*
|
|
106
|
+
* The seam a write-through uses after a create: the response IS the persisted record, so
|
|
107
|
+
* writing it here means the effect that fires next reads the same value the store holds
|
|
108
|
+
* rather than racing the query that is about to resolve.
|
|
109
|
+
*/
|
|
110
|
+
set: <Kind extends keyof StudioCacheValues>(
|
|
111
|
+
key: StudioCacheRef<Kind>,
|
|
112
|
+
value: StudioCacheValues[Kind],
|
|
113
|
+
) => void;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* evictResources removes the entries of resources that no longer exist, through a cache that
|
|
118
|
+
* states {@link StudioCache.evict}.
|
|
119
|
+
*
|
|
120
|
+
* A delete runs it once the server has confirmed, for each entry that names what it deleted. It
|
|
121
|
+
* stands beside the delete's `invalidate` and replaces none of it: the listings the resource
|
|
122
|
+
* appeared in still hold a truth to read again, and the resource's own entries do not.
|
|
123
|
+
*
|
|
124
|
+
* It never throws. The delete has landed by the time the cache is told, and a cache that fails
|
|
125
|
+
* to remove an entry says nothing about that write: thrown from here, the fault would be
|
|
126
|
+
* reported as the delete's failure, over a resource the server no longer holds.
|
|
127
|
+
*
|
|
128
|
+
* @param cache The cache the delete writes to.
|
|
129
|
+
* @param keys The entries to remove, each named as an `invalidate` names it.
|
|
130
|
+
* @returns Whether the cache removed them all. False for a cache that states no `evict`, and for
|
|
131
|
+
* one whose `evict` threw for an entry: such an entry may stand, and a `get` may still answer
|
|
132
|
+
* it.
|
|
133
|
+
*/
|
|
134
|
+
export const evictResources = (cache: StudioCache, ...keys: readonly ResourceRef[]): boolean => {
|
|
135
|
+
if (cache.evict === undefined) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
let removed = true;
|
|
140
|
+
for (const key of keys) {
|
|
141
|
+
try {
|
|
142
|
+
// Called on the cache, so one written as a class reads its own `this`.
|
|
143
|
+
cache.evict(key);
|
|
144
|
+
} catch {
|
|
145
|
+
// The entry may stand, which the answer says. The other entries are removed all the same.
|
|
146
|
+
removed = false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return removed;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* invalidateLanded marks resources stale once the write that changed them has landed.
|
|
155
|
+
*
|
|
156
|
+
* It never rejects. The server has confirmed the write by the time the cache is told, and a
|
|
157
|
+
* cache that fails to mark an entry stale (one that refetches at once and meets a failed read,
|
|
158
|
+
* say) says nothing about that write: thrown from here, the fault would be reported as the
|
|
159
|
+
* write's failure, and a retry would send again a create or a delete that is done. The entries
|
|
160
|
+
* are read again by whatever reads them next.
|
|
161
|
+
*
|
|
162
|
+
* An invalidation that runs ahead of a write, or with none, is the cache's own verb: a fault
|
|
163
|
+
* there is the caller's to hear.
|
|
164
|
+
*
|
|
165
|
+
* @param cache The cache the write's handler was handed.
|
|
166
|
+
* @param keys The resources to mark stale, in one round.
|
|
167
|
+
* @returns Whether the cache marked them stale.
|
|
168
|
+
*/
|
|
169
|
+
export const invalidateLanded = async (
|
|
170
|
+
cache: StudioCache,
|
|
171
|
+
...keys: readonly ResourceRef[]
|
|
172
|
+
): Promise<boolean> => {
|
|
173
|
+
try {
|
|
174
|
+
// Called on the cache, so one written as a class reads its own `this`.
|
|
175
|
+
await cache.invalidate(...keys);
|
|
176
|
+
|
|
177
|
+
return true;
|
|
178
|
+
} catch {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
};
|