@mountaya/studio 0.0.0-stage → 0.1.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 +39 -0
- package/LICENCE.fr.txt +280 -0
- package/LICENSE.txt +262 -0
- package/README.md +917 -2
- package/dist/agent/index.cjs +2854 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +1257 -0
- package/dist/agent/index.d.ts +1257 -0
- package/dist/agent/index.js +2818 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/bus-BwiNiXdH.d.ts +514 -0
- package/dist/bus-DzmhPwdK.d.cts +514 -0
- package/dist/chainModel-B23pEP_1.d.cts +127 -0
- package/dist/chainModel-B23pEP_1.d.ts +127 -0
- package/dist/chunk-2HFY7ETU.js +5721 -0
- package/dist/chunk-2HFY7ETU.js.map +1 -0
- package/dist/chunk-355TOXSB.js +72 -0
- package/dist/chunk-355TOXSB.js.map +1 -0
- package/dist/chunk-4ZCUZVSV.js +10275 -0
- package/dist/chunk-4ZCUZVSV.js.map +1 -0
- package/dist/chunk-6HEKY3NF.js +95 -0
- package/dist/chunk-6HEKY3NF.js.map +1 -0
- package/dist/chunk-7GFLGGBX.cjs +8 -0
- package/dist/chunk-7GFLGGBX.cjs.map +1 -0
- package/dist/chunk-7NBRCENN.cjs +19 -0
- package/dist/chunk-7NBRCENN.cjs.map +1 -0
- package/dist/chunk-AF5GCXE3.js +8 -0
- package/dist/chunk-AF5GCXE3.js.map +1 -0
- package/dist/chunk-CJDIFRGZ.cjs +2005 -0
- package/dist/chunk-CJDIFRGZ.cjs.map +1 -0
- package/dist/chunk-CNPZY7N3.js +349 -0
- package/dist/chunk-CNPZY7N3.js.map +1 -0
- package/dist/chunk-DZJHTWSF.cjs +45 -0
- package/dist/chunk-DZJHTWSF.cjs.map +1 -0
- package/dist/chunk-EABIHHWA.js +42 -0
- package/dist/chunk-EABIHHWA.js.map +1 -0
- package/dist/chunk-EKZWV6RS.cjs +415 -0
- package/dist/chunk-EKZWV6RS.cjs.map +1 -0
- package/dist/chunk-EOKRXXAC.cjs +24 -0
- package/dist/chunk-EOKRXXAC.cjs.map +1 -0
- package/dist/chunk-F73W2ZTJ.js +1126 -0
- package/dist/chunk-F73W2ZTJ.js.map +1 -0
- package/dist/chunk-H4DVOZ5O.js +1897 -0
- package/dist/chunk-H4DVOZ5O.js.map +1 -0
- package/dist/chunk-HI52PBFT.cjs +10314 -0
- package/dist/chunk-HI52PBFT.cjs.map +1 -0
- package/dist/chunk-IDBXFBLG.cjs +1225 -0
- package/dist/chunk-IDBXFBLG.cjs.map +1 -0
- package/dist/chunk-LBWTJZUJ.js +297 -0
- package/dist/chunk-LBWTJZUJ.js.map +1 -0
- package/dist/chunk-NCLA6DKD.cjs +310 -0
- package/dist/chunk-NCLA6DKD.cjs.map +1 -0
- package/dist/chunk-O4MC5DPD.js +19 -0
- package/dist/chunk-O4MC5DPD.js.map +1 -0
- package/dist/chunk-OP37FKW6.cjs +98 -0
- package/dist/chunk-OP37FKW6.cjs.map +1 -0
- package/dist/chunk-OQSYFH3Z.cjs +5945 -0
- package/dist/chunk-OQSYFH3Z.cjs.map +1 -0
- package/dist/chunk-PACIO4NS.cjs +26 -0
- package/dist/chunk-PACIO4NS.cjs.map +1 -0
- package/dist/chunk-PSZ2R3TC.cjs +75 -0
- package/dist/chunk-PSZ2R3TC.cjs.map +1 -0
- package/dist/chunk-QFO5CZG2.cjs +136 -0
- package/dist/chunk-QFO5CZG2.cjs.map +1 -0
- package/dist/chunk-QL63MUEW.cjs +140 -0
- package/dist/chunk-QL63MUEW.cjs.map +1 -0
- package/dist/chunk-RFUPPVZO.js +17 -0
- package/dist/chunk-RFUPPVZO.js.map +1 -0
- package/dist/chunk-RPG2LWMP.js +23 -0
- package/dist/chunk-RPG2LWMP.js.map +1 -0
- package/dist/chunk-TIBXK6B7.cjs +12 -0
- package/dist/chunk-TIBXK6B7.cjs.map +1 -0
- package/dist/chunk-UU65VNEV.js +381 -0
- package/dist/chunk-UU65VNEV.js.map +1 -0
- package/dist/chunk-VGX6TR2I.js +209 -0
- package/dist/chunk-VGX6TR2I.js.map +1 -0
- package/dist/chunk-WUTDDBVP.js +130 -0
- package/dist/chunk-WUTDDBVP.js.map +1 -0
- package/dist/chunk-WVQQLKCI.cjs +224 -0
- package/dist/chunk-WVQQLKCI.cjs.map +1 -0
- package/dist/chunk-WZYXG3SE.js +111 -0
- package/dist/chunk-WZYXG3SE.js.map +1 -0
- package/dist/chunk-XDI2X3KE.js +6 -0
- package/dist/chunk-XDI2X3KE.js.map +1 -0
- package/dist/chunk-XKHLRIC7.cjs +381 -0
- package/dist/chunk-XKHLRIC7.cjs.map +1 -0
- package/dist/context-DNtd2WUv.d.cts +11666 -0
- package/dist/context-DgB72Bur.d.ts +11666 -0
- package/dist/directorThreads-CqmvsV8b.d.cts +80 -0
- package/dist/directorThreads-CqmvsV8b.d.ts +80 -0
- package/dist/en-Bu4Ti9Ev.d.cts +2315 -0
- package/dist/en-Bu4Ti9Ev.d.ts +2315 -0
- package/dist/engines/index.cjs +3446 -0
- package/dist/engines/index.cjs.map +1 -0
- package/dist/engines/index.d.cts +2216 -0
- package/dist/engines/index.d.ts +2216 -0
- package/dist/engines/index.js +3416 -0
- package/dist/engines/index.js.map +1 -0
- package/dist/handlers/index.cjs +99 -0
- package/dist/handlers/index.cjs.map +1 -0
- package/dist/handlers/index.d.cts +445 -0
- package/dist/handlers/index.d.ts +445 -0
- package/dist/handlers/index.js +42 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/index.cjs +4562 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7297 -0
- package/dist/index.d.ts +7297 -0
- package/dist/index.js +3223 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/index.cjs +977 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.cts +313 -0
- package/dist/plugins/index.d.ts +313 -0
- package/dist/plugins/index.js +933 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/saveFile-j-1kkApx.d.cts +123 -0
- package/dist/saveFile-j-1kkApx.d.ts +123 -0
- package/dist/seams/index.cjs +152 -0
- package/dist/seams/index.cjs.map +1 -0
- package/dist/seams/index.d.cts +485 -0
- package/dist/seams/index.d.ts +485 -0
- package/dist/seams/index.js +79 -0
- package/dist/seams/index.js.map +1 -0
- package/dist/shareLink-B6hlt942.d.ts +144 -0
- package/dist/shareLink-C7rIMb7x.d.ts +527 -0
- package/dist/shareLink-CnTxxXjp.d.cts +144 -0
- package/dist/shareLink-DyZVYH2V.d.cts +527 -0
- package/dist/strings/fr/index.cjs +2121 -0
- package/dist/strings/fr/index.cjs.map +1 -0
- package/dist/strings/fr/index.d.cts +19 -0
- package/dist/strings/fr/index.d.ts +19 -0
- package/dist/strings/fr/index.js +2119 -0
- package/dist/strings/fr/index.js.map +1 -0
- package/dist/strings/index.cjs +2678 -0
- package/dist/strings/index.cjs.map +1 -0
- package/dist/strings/index.d.cts +731 -0
- package/dist/strings/index.d.ts +731 -0
- package/dist/strings/index.js +2644 -0
- package/dist/strings/index.js.map +1 -0
- package/dist/studioPlugin-C3C7VjMy.d.ts +847 -0
- package/dist/studioPlugin-Cf3OBNUv.d.cts +847 -0
- package/dist/tabs-B2nRO4p_.d.cts +15 -0
- package/dist/tabs-B2nRO4p_.d.ts +15 -0
- package/dist/testing/index.cjs +292 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +306 -0
- package/dist/testing/index.d.ts +306 -0
- package/dist/testing/index.js +284 -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 +43 -0
- package/dist/time/index.d.ts +43 -0
- package/dist/time/index.js +26 -0
- package/dist/time/index.js.map +1 -0
- package/dist/types-BzJRV6UI.d.cts +845 -0
- package/dist/types-BzJRV6UI.d.ts +845 -0
- package/dist/zoneForm-CdYNtnnA.d.cts +320 -0
- package/dist/zoneForm-mG85yt5e.d.ts +320 -0
- package/package.json +225 -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 +28 -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 +454 -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 +858 -0
- package/src/bus/rules/confirmation.ts +22 -0
- package/src/bus/rules/defineRegistry.ts +26 -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 +805 -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 +573 -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 +87 -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 +213 -0
- package/src/embed/rules/snippet.ts +531 -0
- package/src/embed/rules/tableCode.ts +269 -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 +1086 -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 +1052 -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 +200 -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 +209 -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 +34 -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 +198 -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,783 @@
|
|
|
1
|
+
import { failureFromThrown } from "../../bus/rules/handlerErrors.js";
|
|
2
|
+
import type { ToolFailure } from "../../bus/rules/types.js";
|
|
3
|
+
import { selectImportSession } from "../../chrome/stores/uiStore.js";
|
|
4
|
+
import { teardownActiveEditSession } from "../../edit/handlers/editLock.js";
|
|
5
|
+
import { selectUnsavedWork } from "../../edit/rules/unsavedWork.js";
|
|
6
|
+
import type { ImportGranularity } from "../../rules/types.js";
|
|
7
|
+
import { studioSeamAbsences } from "../../seams/rules/seams.js";
|
|
8
|
+
import type { StudioToolContext, StudioToolDefinition } from "../../viewer/rules/context.js";
|
|
9
|
+
import { draftSurfaceNames, holdDraftWrite, holdDuringDraftCommit } from "../rules/draftSurface.js";
|
|
10
|
+
import {
|
|
11
|
+
type ImportSession,
|
|
12
|
+
type ImportSubmissionStatus,
|
|
13
|
+
previewToDraft,
|
|
14
|
+
} from "../rules/import.js";
|
|
15
|
+
import { dropDraftSelection } from "./itinerarySelection.js";
|
|
16
|
+
import { previewItineraryImport } from "./restItineraryImport.js";
|
|
17
|
+
import {
|
|
18
|
+
askToDropDraft,
|
|
19
|
+
endDraftSession,
|
|
20
|
+
leaveForSurface,
|
|
21
|
+
openItinerarySurface,
|
|
22
|
+
} from "./surfaceOpen.js";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* open opens the import shell on a provider, seeding a fresh import session and
|
|
26
|
+
* flipping the studio sidenav body to the import surface. The import surface mounts
|
|
27
|
+
* off the store's open-content slot, and the open writes nothing else: the open itinerary's
|
|
28
|
+
* slot and the url's detail keys (`creating`, `itinerary_id`) stand behind the surface as
|
|
29
|
+
* `studio.itinerary.createOpen` leaves them. A discard is then back on the itinerary the reader
|
|
30
|
+
* came from with no click, and a confirm lands on the itinerary it made.
|
|
31
|
+
*
|
|
32
|
+
* Over the import surface that shows it keeps the session as it is, its file, its preview and its
|
|
33
|
+
* draft included: another source is `setProvider`'s to choose. An import session ends as its
|
|
34
|
+
* surface leaves the screen, so every other open seeds a fresh one. Mounting the surface unbinds
|
|
35
|
+
* a zone the body slot was showing.
|
|
36
|
+
*
|
|
37
|
+
* What the slot was showing is left through {@link leaveForSurface}: a suggestion that shows ends
|
|
38
|
+
* with its session, and a staged draft or an armed edit (a zone's create or reshape, or an edit of
|
|
39
|
+
* the itinerary behind) is asked about first. A decline answers `confirmation-denied` and opens
|
|
40
|
+
* nothing, and a draft whose commit is out answers `conflict`.
|
|
41
|
+
*/
|
|
42
|
+
export const open: StudioToolDefinition<"studio.itinerary.import.open"> = {
|
|
43
|
+
handler: async (ctx, input) => {
|
|
44
|
+
// Re-opening the import that shows keeps it as it is, as the suggest surface does. Seeding a
|
|
45
|
+
// fresh session would drop the file, the preview and the draft under review with no word,
|
|
46
|
+
// and leave an edit of that draft armed on a segment that no longer exists. A caller that
|
|
47
|
+
// wants another source says so with setProvider.
|
|
48
|
+
const session = selectImportSession(ctx.ui.getState());
|
|
49
|
+
if (session !== null && ctx.ui.getState().openContent === "import") {
|
|
50
|
+
const standing = `The ${draftSurfaceNames.import} surface is already open on ${session.provider}`;
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
data: { seeded: false, shown: false },
|
|
54
|
+
ok: true,
|
|
55
|
+
summary:
|
|
56
|
+
input.provider === undefined || input.provider === session.provider
|
|
57
|
+
? `${standing}.`
|
|
58
|
+
: `${standing}: switch its source with studio.itinerary.import.setProvider.`,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const kept = await leaveForSurface(ctx, "studio.itinerary.import.open", "import", input);
|
|
63
|
+
if (kept) {
|
|
64
|
+
return kept;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
ctx.ui.getState().openImport(input.provider ?? "gpx");
|
|
68
|
+
openItinerarySurface(ctx, "import");
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
data: { seeded: true, shown: true },
|
|
72
|
+
ok: true,
|
|
73
|
+
summary: `Opened the ${draftSurfaceNames.import} surface on ${input.provider ?? "gpx"}.`,
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* requireImportSession is the gate every verb of an open import starts with: null while an
|
|
80
|
+
* import is open and no commit of its draft is out, the `no-session` refusal while none is open,
|
|
81
|
+
* and the `conflict` refusal while its commit is out ({@link holdDuringDraftCommit}).
|
|
82
|
+
*
|
|
83
|
+
* The store's setters write nothing while the shell is closed, so a verb that answered `ok`
|
|
84
|
+
* there told its caller that a write which went nowhere had worked. A verb aimed at a closed
|
|
85
|
+
* import is an ordering mistake, and the refusal names the verb to call first. A write made
|
|
86
|
+
* while the commit is out reaches no itinerary, since the commit sent the session as it stood.
|
|
87
|
+
*
|
|
88
|
+
* @param verb - The verb's own words for the refusal, as in `import preview`.
|
|
89
|
+
*/
|
|
90
|
+
export const requireImportSession = (ctx: StudioToolContext, verb: string): ToolFailure | null =>
|
|
91
|
+
selectImportSession(ctx.ui.getState()) === null
|
|
92
|
+
? {
|
|
93
|
+
code: "no-session",
|
|
94
|
+
error: `${verb}: no import is open; open one with studio.itinerary.import.open first`,
|
|
95
|
+
ok: false,
|
|
96
|
+
}
|
|
97
|
+
: holdDuringDraftCommit(ctx, "import", verb);
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* setProvider switches the chosen provider on the open import session. Switching
|
|
101
|
+
* the provider changes which payload reaches the preview endpoint, so the prior
|
|
102
|
+
* preview + draft are now stale: the handler clears them (status back to idle)
|
|
103
|
+
* and tears down the non-persisted map preview, so the shell shows the fresh
|
|
104
|
+
* provider's input rather than the previous source's draft.
|
|
105
|
+
*
|
|
106
|
+
* A draft that stands is dropped with the change, so it is asked about first, as `clearDraft`
|
|
107
|
+
* asks: the shared unsaved-changes prompt whenever a draft exists and the confirm seam is wired.
|
|
108
|
+
* A decline answers `confirmation-denied` and keeps the provider, the draft and any edit of it.
|
|
109
|
+
* On a yes, or with no seam, an edit armed on the draft is ended before the draft goes, so none
|
|
110
|
+
* stays armed on a segment of a draft that is gone. Setting the provider the session already
|
|
111
|
+
* holds changes no payload: it keeps everything and asks nothing.
|
|
112
|
+
*
|
|
113
|
+
* While a commit of the draft is out the verb answers `conflict`, before the prompt and again
|
|
114
|
+
* once it is answered ({@link holdDuringDraftCommit}).
|
|
115
|
+
*/
|
|
116
|
+
export const setProvider: StudioToolDefinition<"studio.itinerary.import.setProvider"> = {
|
|
117
|
+
handler: async (ctx, input) => {
|
|
118
|
+
const closed = requireImportSession(ctx, "set import provider");
|
|
119
|
+
if (closed) {
|
|
120
|
+
return closed;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const session = selectImportSession(ctx.ui.getState());
|
|
124
|
+
if (session?.provider === input.provider) {
|
|
125
|
+
return { ok: true, summary: `The import provider is already ${input.provider}.` };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (session?.draft != null) {
|
|
129
|
+
const kept = await askToDropDraft(
|
|
130
|
+
ctx,
|
|
131
|
+
"import",
|
|
132
|
+
"set import provider",
|
|
133
|
+
"studio.itinerary.import.setProvider",
|
|
134
|
+
input,
|
|
135
|
+
`set import provider declined: kept the draft and the ${session.provider} source`,
|
|
136
|
+
);
|
|
137
|
+
if (kept) {
|
|
138
|
+
return kept;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// An edit armed over the staged draft is an edit of that draft, which goes below.
|
|
142
|
+
teardownActiveEditSession(ctx);
|
|
143
|
+
dropDraftSelection(ctx, session.draft);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const ui = ctx.ui.getState();
|
|
147
|
+
ui.setImportProvider(input.provider);
|
|
148
|
+
ui.setImportPreview(null);
|
|
149
|
+
ui.setImportDraft(null);
|
|
150
|
+
ui.setImportStatus({ kind: "idle" });
|
|
151
|
+
ctx.map?.setItineraryPreview(null);
|
|
152
|
+
|
|
153
|
+
return { ok: true, summary: `Set the import provider to ${input.provider}.` };
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* PREVIEW_SETTLE_MS is how long the options of an open import stay unchanged before the preview
|
|
159
|
+
* they ask for is sent, in milliseconds.
|
|
160
|
+
*
|
|
161
|
+
* A preview is the costliest request the API takes and a counted one, and an option is seldom
|
|
162
|
+
* changed once: a reader steps through the choices, and a caller sets two of them in a row.
|
|
163
|
+
* Changes each made within this time of the one before are one request, sent this long after the
|
|
164
|
+
* last of them. A change made later than that comes after the preview of the ones before was
|
|
165
|
+
* sent: it stops that preview if it is still out, and its own is sent this long after it. Longer
|
|
166
|
+
* than the gap between two steps through the choices, and short against a preview, which takes
|
|
167
|
+
* seconds. The session reads `settling` for the wait, so the surface shows it from the change.
|
|
168
|
+
*/
|
|
169
|
+
const PREVIEW_SETTLE_MS = 750;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* supersededPreview is what a preview answers once another write of the session replaced it,
|
|
173
|
+
* before it was sent or before it answered: nothing of it was written.
|
|
174
|
+
*/
|
|
175
|
+
const supersededPreview = {
|
|
176
|
+
code: "no-session",
|
|
177
|
+
error:
|
|
178
|
+
"import preview: a later preview, a change of option or of provider, a step back or a discard replaced this one before it answered",
|
|
179
|
+
ok: false,
|
|
180
|
+
} as const;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* previewFailureStatus is the status a refused preview leaves on the session: an `error` the
|
|
184
|
+
* import's surfaces say. The message is the API's own sentence where the refusal brought one, so
|
|
185
|
+
* a reader is told what to do rather than which operation failed, and a spent budget names its
|
|
186
|
+
* reason, which the surfaces answer with advice the API cannot give.
|
|
187
|
+
*/
|
|
188
|
+
const previewFailureStatus = (failure: ToolFailure): ImportSubmissionStatus => ({
|
|
189
|
+
kind: "error",
|
|
190
|
+
message: failure.detail ?? failure.error ?? "import preview failed",
|
|
191
|
+
reason: failure.code === "timeout" ? "timeout" : undefined,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* previewAgain previews the open import again from its retained file, once its options have
|
|
196
|
+
* stopped changing. The verbs that change an option a preview depends on (the granularity, the
|
|
197
|
+
* activity) end here, each with its change already on the session.
|
|
198
|
+
*
|
|
199
|
+
* It marks the session `settling` at once, a status object of its own. That replaces whatever the
|
|
200
|
+
* change made stale: a preview in flight answers for options the session no longer holds, so it
|
|
201
|
+
* is told to stop (submitPreview ends a request whose status was replaced), and a change still
|
|
202
|
+
* settling sends nothing. The request itself is sent {@link PREVIEW_SETTLE_MS} after the change,
|
|
203
|
+
* with the options the session holds then, unless another change came first. So a run of changes
|
|
204
|
+
* each made within that time of the one before sends one preview, for where the run stops; a
|
|
205
|
+
* change made after a longer pause stops the preview the run sent, if it is still out, and
|
|
206
|
+
* settles again. A wait is chosen over sending at once and aborting on the next change, because
|
|
207
|
+
* an aborted preview has already been counted against the caller's rate and may have run part of
|
|
208
|
+
* its routing.
|
|
209
|
+
*
|
|
210
|
+
* `settling` is not `previewing`, so a surface can tell a change still open to another from a
|
|
211
|
+
* request already out. Both mean the staged draft is the one the pending preview replaces, and a
|
|
212
|
+
* confirm is refused with `conflict` through both.
|
|
213
|
+
*
|
|
214
|
+
* A change another one followed, or that a step back, a change of provider, another file or a
|
|
215
|
+
* discard overtook, sends nothing and answers `no-session`, as a preview replaced in flight does.
|
|
216
|
+
*
|
|
217
|
+
* The preview is dispatched through the bus, so it is the one submitPreview path (same API call,
|
|
218
|
+
* same draft projection, same map sync) rather than a parallel copy. A preview the bus refuses
|
|
219
|
+
* before its handler runs (a capability the context lacks, an input it refuses, a host's own
|
|
220
|
+
* refusal, a bus that throws) writes nothing, so the refusal is written here as a refused
|
|
221
|
+
* preview is ({@link previewFailureStatus}), while the session still carries this change's own
|
|
222
|
+
* `settling`: a status left pending would hold the confirm for good.
|
|
223
|
+
*/
|
|
224
|
+
export const previewAgain = async (
|
|
225
|
+
ctx: StudioToolContext,
|
|
226
|
+
bus: NonNullable<StudioToolContext["bus"]>,
|
|
227
|
+
) => {
|
|
228
|
+
// The store keeps this exact object until something else writes the status, so it says
|
|
229
|
+
// whether this change is still the last one once the wait is over.
|
|
230
|
+
const settling: ImportSubmissionStatus = { kind: "settling" };
|
|
231
|
+
ctx.ui.getState().setImportStatus(settling);
|
|
232
|
+
|
|
233
|
+
await new Promise<void>((resolve) => {
|
|
234
|
+
(ctx.clock ?? studioSeamAbsences.clock).after(PREVIEW_SETTLE_MS, resolve);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
const session = selectImportSession(ctx.ui.getState());
|
|
238
|
+
if (session?.status !== settling || !session.file) {
|
|
239
|
+
return supersededPreview;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const answer = await bus
|
|
243
|
+
.dispatch(ctx, "studio.itinerary.import.submitPreview", {
|
|
244
|
+
activityId: session.activityId,
|
|
245
|
+
file: session.file,
|
|
246
|
+
granularity: session.granularity,
|
|
247
|
+
provider: session.provider,
|
|
248
|
+
})
|
|
249
|
+
.catch(failureFromThrown);
|
|
250
|
+
|
|
251
|
+
// A handler that ran wrote its own status, `previewing` and then its answer, and a later write
|
|
252
|
+
// replaced this one: either way the status is no longer this change's, and stays as it is.
|
|
253
|
+
// Still this change's, the preview was refused before anything wrote one. An `error` rather
|
|
254
|
+
// than the status before the change: that one may be a preview this change stopped, which
|
|
255
|
+
// would stand pending for good in its turn, and the reader is told why the change did not
|
|
256
|
+
// land. The draft that stands is confirmed as it is, and the same option set again asks again.
|
|
257
|
+
if (!answer.ok && selectImportSession(ctx.ui.getState())?.status === settling) {
|
|
258
|
+
ctx.ui.getState().setImportStatus(previewFailureStatus(answer));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return answer;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* ImportOptions are the options of an open import a preview is sent with, and that a staged
|
|
266
|
+
* draft was built from.
|
|
267
|
+
*/
|
|
268
|
+
interface ImportOptions {
|
|
269
|
+
readonly activityId: string | null;
|
|
270
|
+
readonly granularity: ImportGranularity;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* OptionChange is what setting an option of the open import asks for: `nothing` (no write, no
|
|
275
|
+
* preview), `draft` (written, and the draft on screen stands for it with no preview) or `preview`
|
|
276
|
+
* (written, and previewed again).
|
|
277
|
+
*/
|
|
278
|
+
type OptionChange = "draft" | "nothing" | "preview";
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* optionChange answers what setting an option of the open import asks for, from `next`, the
|
|
282
|
+
* options the session holds once the value is written.
|
|
283
|
+
*
|
|
284
|
+
* A value both the session and the draft on screen already say asks for nothing. A value the
|
|
285
|
+
* session already holds while a preview of it is pending asks for nothing either: that preview is
|
|
286
|
+
* for it. A value that brings the session back to the options the draft on screen was built from
|
|
287
|
+
* previews nothing: it is written, any preview still pending for the options it replaces ends,
|
|
288
|
+
* and the draft stands as it is, with what the reader changed on it. Any other value previews,
|
|
289
|
+
* and so does a value the session already holds while the draft on screen was built from other
|
|
290
|
+
* options: the draft does not match the choice, which is how a reader retries a refused preview.
|
|
291
|
+
* A refused confirm changes no option, so the same value asks for nothing after it.
|
|
292
|
+
*
|
|
293
|
+
* With no draft staged, the same value asks for nothing, except after a refused first preview,
|
|
294
|
+
* which it retries. The draft's activity is the one it carries, which a session naming none
|
|
295
|
+
* takes as it is; its granularity is the session's `draftGranularity`, and a draft staged
|
|
296
|
+
* without one answers for no granularity.
|
|
297
|
+
*/
|
|
298
|
+
export const optionChange = (session: ImportSession, next: ImportOptions): OptionChange => {
|
|
299
|
+
const same = next.activityId === session.activityId && next.granularity === session.granularity;
|
|
300
|
+
const draft = session.draft;
|
|
301
|
+
const answered =
|
|
302
|
+
draft !== null &&
|
|
303
|
+
(next.activityId === null || draft.activityId === next.activityId) &&
|
|
304
|
+
session.draftGranularity === next.granularity;
|
|
305
|
+
|
|
306
|
+
if (!same) {
|
|
307
|
+
return answered ? "draft" : "preview";
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const pending = session.status.kind === "settling" || session.status.kind === "previewing";
|
|
311
|
+
if (answered || pending || (draft === null && session.status.kind !== "error")) {
|
|
312
|
+
return "nothing";
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return "preview";
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* standDraft ends a preview pending for options the session no longer holds, the draft on screen
|
|
320
|
+
* answering for the ones it does: the session reads `ready` again, which stops a preview still
|
|
321
|
+
* settling and one already out, and clears the refusal of one that was refused.
|
|
322
|
+
*/
|
|
323
|
+
export const standDraft = (ctx: StudioToolContext): void => {
|
|
324
|
+
if (selectImportSession(ctx.ui.getState())?.status.kind !== "ready") {
|
|
325
|
+
ctx.ui.getState().setImportStatus({ kind: "ready" });
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* setGranularity sets how the server slices the source into segments (`auto`
|
|
331
|
+
* splits on the source's own structure, `single` collapses to one segment). The
|
|
332
|
+
* granularity changes only the segmentation, not the underlying source, so it
|
|
333
|
+
* RESHAPES rather than erases: it writes the new granularity onto the session, then
|
|
334
|
+
* previews again from the RETAINED file (the name, activity,
|
|
335
|
+
* and privacy on the session survive untouched), replacing only the segment list.
|
|
336
|
+
* That preview is {@link previewAgain}'s: sent once the options have stopped changing, in place
|
|
337
|
+
* of the one in flight. When nothing has been submitted yet (no file) it just
|
|
338
|
+
* records the granularity for the eventual first preview; absent the bus seam (a
|
|
339
|
+
* render-free test) it likewise records the granularity without previewing again,
|
|
340
|
+
* never erasing the upload.
|
|
341
|
+
*
|
|
342
|
+
* Whether a value previews is {@link optionChange}'s rule. A granularity the session and the
|
|
343
|
+
* draft on screen already say answers `ok` and writes nothing, so a preview the session waits on
|
|
344
|
+
* goes on; one that brings the session back to the options the draft was built from is written
|
|
345
|
+
* and previews nothing; one the session holds while the draft was built from others (a refused
|
|
346
|
+
* preview) previews again, as a retry.
|
|
347
|
+
*/
|
|
348
|
+
export const setGranularity: StudioToolDefinition<"studio.itinerary.import.setGranularity"> = {
|
|
349
|
+
handler: async (ctx, input) => {
|
|
350
|
+
const closed = requireImportSession(ctx, "set import granularity");
|
|
351
|
+
if (closed) {
|
|
352
|
+
return closed;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const held = selectImportSession(ctx.ui.getState());
|
|
356
|
+
const change = held
|
|
357
|
+
? optionChange(held, { activityId: held.activityId, granularity: input.granularity })
|
|
358
|
+
: "preview";
|
|
359
|
+
if (change === "nothing") {
|
|
360
|
+
return { ok: true, summary: `The import granularity is already ${input.granularity}.` };
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const ui = ctx.ui.getState();
|
|
364
|
+
ui.setImportGranularity(input.granularity);
|
|
365
|
+
|
|
366
|
+
if (change === "draft") {
|
|
367
|
+
standDraft(ctx);
|
|
368
|
+
|
|
369
|
+
return {
|
|
370
|
+
ok: true,
|
|
371
|
+
summary: `Set the import granularity to ${input.granularity}, which the staged draft was previewed under.`,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const session = selectImportSession(ctx.ui.getState());
|
|
376
|
+
// Preview again from the retained file so the upload survives the toggle: the held File
|
|
377
|
+
// handle and the session's name/activity/privacy are kept (submitPreview never touches
|
|
378
|
+
// them), and only the segment list is replaced.
|
|
379
|
+
if (session?.file && ctx.bus) {
|
|
380
|
+
return previewAgain(ctx, ctx.bus);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
return { ok: true, summary: `Set the import granularity to ${input.granularity}.` };
|
|
384
|
+
},
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* submitPreview previews the import against the server without persisting anything.
|
|
389
|
+
*
|
|
390
|
+
* It records the file handle on the session, marks the
|
|
391
|
+
* session `previewing`, then calls the preview endpoint. The owning `organization_id` is read off
|
|
392
|
+
* the session (the shell's OrganizationSelect set it), not the input, so a preview run again by
|
|
393
|
+
* an activity/granularity change keeps the chosen owner without threading it through every
|
|
394
|
+
* dispatch; a null owner is omitted so the server previews against the caller's organization. On
|
|
395
|
+
* success it stores the raw preview, projects it into the editable draft, and marks the session
|
|
396
|
+
* `ready`; the map paint and the camera fit happen reactively through the studio's preview-sync
|
|
397
|
+
* hook, so the handler never touches the map. On failure it marks the session with the error
|
|
398
|
+
* message and returns a structured failure.
|
|
399
|
+
*
|
|
400
|
+
* It is human-only: an itinerary is imported from a file, and an agent cannot supply a File
|
|
401
|
+
* handle. It calls the server, so it needs the api seam;
|
|
402
|
+
* absent it, it returns a failure rather than dropping the request. It needs an open import
|
|
403
|
+
* session too, and with none it answers `no-session` before any request.
|
|
404
|
+
*
|
|
405
|
+
* Only the latest preview lands. An answer, success or failure, is written only while
|
|
406
|
+
* the session still carries the `previewing` status this request wrote: a later
|
|
407
|
+
* preview writes its own, and a change of option, a step back, a provider switch or a discard
|
|
408
|
+
* replaces it, so a slow earlier answer can neither put one source's segments beside another's
|
|
409
|
+
* nor undo a cancel. A superseded request writes nothing and answers `no-session`.
|
|
410
|
+
*
|
|
411
|
+
* A superseded request is also told to stop: it is sent under a signal that aborts as soon as
|
|
412
|
+
* its status is replaced, so a preview nothing will read is not left running. The rejection an
|
|
413
|
+
* abort brings is the import's own doing and reads as the request superseded, never as a
|
|
414
|
+
* failure of the import. A late answer the transport still delivers lands nowhere, by the rule
|
|
415
|
+
* above.
|
|
416
|
+
*
|
|
417
|
+
* The request is sent once: a refusal for a spent rate (a 429), a gateway failure or a dropped
|
|
418
|
+
* connection is not waited on or sent again by the client. It comes back at once and is shown as
|
|
419
|
+
* every refusal is, with the API's sentence, and the reader asks again by setting the option
|
|
420
|
+
* again or picking the file again.
|
|
421
|
+
*/
|
|
422
|
+
export const submitPreview: StudioToolDefinition<"studio.itinerary.import.submitPreview"> = {
|
|
423
|
+
handler: async (ctx, input) => {
|
|
424
|
+
if (!ctx.api) {
|
|
425
|
+
return { code: "no-api", error: "import preview: no persistence seam", ok: false };
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// A preview lands in the open import session, so with none there is nothing to send for.
|
|
429
|
+
const closed = requireImportSession(ctx, "import preview");
|
|
430
|
+
if (closed) {
|
|
431
|
+
return closed;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const ui = ctx.ui.getState();
|
|
435
|
+
|
|
436
|
+
// Persist the file onto the session so the shell reflects what was submitted
|
|
437
|
+
// (and a confirm/retry reads it back) before the request resolves.
|
|
438
|
+
ui.setImportFile(input.file);
|
|
439
|
+
|
|
440
|
+
// The store keeps this exact object until something else writes the status, so it is
|
|
441
|
+
// the request's identity: every answer below checks it is still the session's status
|
|
442
|
+
// before writing anything.
|
|
443
|
+
const previewing: ImportSubmissionStatus = { kind: "previewing" };
|
|
444
|
+
const isLatest = () => selectImportSession(ctx.ui.getState())?.status === previewing;
|
|
445
|
+
|
|
446
|
+
ui.setImportStatus(previewing);
|
|
447
|
+
|
|
448
|
+
// The request lives as long as the status it wrote. Whatever replaces that status has no use
|
|
449
|
+
// for the answer, so the request is told to stop there, in one place for every way a
|
|
450
|
+
// preview is replaced: a later preview, a change of option or of provider, a step back, a
|
|
451
|
+
// discard, the surface leaving the screen.
|
|
452
|
+
const request = new AbortController();
|
|
453
|
+
const unwatch = ctx.ui.subscribe(() => {
|
|
454
|
+
if (!isLatest()) {
|
|
455
|
+
request.abort();
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
// The owning organization rides on the session (the shell's OrganizationSelect wrote
|
|
460
|
+
// it), not the per-call input, so a re-preview keeps the chosen owner; null
|
|
461
|
+
// means the API previews against the caller's own organization.
|
|
462
|
+
const organizationId = selectImportSession(ctx.ui.getState())?.organizationId ?? null;
|
|
463
|
+
|
|
464
|
+
try {
|
|
465
|
+
const preview = await previewItineraryImport(ctx.api.client, {
|
|
466
|
+
activityId: input.activityId ?? null,
|
|
467
|
+
file: input.file,
|
|
468
|
+
granularity: input.granularity,
|
|
469
|
+
organizationId,
|
|
470
|
+
provider: input.provider,
|
|
471
|
+
signal: request.signal,
|
|
472
|
+
});
|
|
473
|
+
unwatch();
|
|
474
|
+
|
|
475
|
+
if (!isLatest()) {
|
|
476
|
+
return supersededPreview;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
const after = ctx.ui.getState();
|
|
480
|
+
after.setImportPreview(preview);
|
|
481
|
+
// Staged, never set: a preview read again builds another draft under the same positional
|
|
482
|
+
// ids, and the session's `draftId` is what tells the two apart.
|
|
483
|
+
// The granularity it answers for: the contract reads a request that names none as `auto`.
|
|
484
|
+
after.stageImportDraft(previewToDraft(preview), input.granularity ?? "auto");
|
|
485
|
+
after.setImportStatus({ kind: "ready" });
|
|
486
|
+
|
|
487
|
+
const segmentCount = preview.segments.length;
|
|
488
|
+
// A fallback is a segment the server recommended freehand over routing: its
|
|
489
|
+
// recommendation_reason names why directions could not be used, and the
|
|
490
|
+
// count surfaces how much of the source could not be routed faithfully.
|
|
491
|
+
const fallbackCount = preview.segments.filter(
|
|
492
|
+
(segment) => segment.recommendation === "linestring",
|
|
493
|
+
).length;
|
|
494
|
+
|
|
495
|
+
return {
|
|
496
|
+
data: { fallbackCount, segmentCount },
|
|
497
|
+
ok: true,
|
|
498
|
+
summary: `Previewed ${segmentCount} segment${segmentCount === 1 ? "" : "s"}${
|
|
499
|
+
fallbackCount > 0 ? ` (${fallbackCount} fell back to a freehand line)` : ""
|
|
500
|
+
}.`,
|
|
501
|
+
};
|
|
502
|
+
} catch (error) {
|
|
503
|
+
unwatch();
|
|
504
|
+
|
|
505
|
+
// An aborted request rejects with the signal's reason, and only a replaced status aborts
|
|
506
|
+
// one: it is answered here, before anything reads the rejection as a failure.
|
|
507
|
+
if (!isLatest()) {
|
|
508
|
+
return supersededPreview;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
const failure = failureFromThrown(error);
|
|
512
|
+
|
|
513
|
+
// The session message is what the input step renders, so it carries the
|
|
514
|
+
// API's own already-localized sentence when the throw brought one. Its
|
|
515
|
+
// absence would leave the technical `postItineraryPreview: 400` on screen,
|
|
516
|
+
// which names an operation rather than telling anyone what to do about it.
|
|
517
|
+
//
|
|
518
|
+
// A spent budget is the exception: its sentence is opaque by construction,
|
|
519
|
+
// so the reason travels alongside and the step answers it with advice the
|
|
520
|
+
// API has no way to give.
|
|
521
|
+
ctx.ui.getState().setImportStatus(previewFailureStatus(failure));
|
|
522
|
+
|
|
523
|
+
return failure;
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* toggleMode flips a draft segment's chosen mode between directions and linestring, BUT only
|
|
530
|
+
* when both candidates exist. A segment whose source cannot route carries no directions
|
|
531
|
+
* candidate, so there is nothing to toggle to and the handler returns a structured failure (it
|
|
532
|
+
* never writes a mode the draft cannot render). When both candidates exist it rewrites the
|
|
533
|
+
* segment's mode through setImportDraft; the map preview paints again reactively through the
|
|
534
|
+
* preview-sync hook, so the handler never touches the map. It edits the in-memory draft, not the
|
|
535
|
+
* server.
|
|
536
|
+
*
|
|
537
|
+
* While the draft is being committed, or a preview that replaces it is pending, it answers
|
|
538
|
+
* `conflict` and writes nothing ({@link holdDraftWrite}).
|
|
539
|
+
*/
|
|
540
|
+
export const toggleMode: StudioToolDefinition<"studio.itinerary.import.toggleMode"> = {
|
|
541
|
+
handler: (ctx, input) => {
|
|
542
|
+
const session = selectImportSession(ctx.ui.getState());
|
|
543
|
+
if (!session?.draft) {
|
|
544
|
+
return { code: "no-session", error: "toggle import mode: no import draft", ok: false };
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const held = holdDraftWrite(ctx, "import", "toggle import mode");
|
|
548
|
+
if (held) {
|
|
549
|
+
return held;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
const segment = session.draft.segments.find((entry) => entry.id === input.segmentId);
|
|
553
|
+
if (!segment) {
|
|
554
|
+
return {
|
|
555
|
+
code: "not-found",
|
|
556
|
+
error: `toggle import mode: no segment ${input.segmentId}`,
|
|
557
|
+
ok: false,
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// Both candidates must exist for a flip to land a renderable geometry; a
|
|
562
|
+
// segment with no directions candidate has nothing to toggle to.
|
|
563
|
+
if (!segment.directions) {
|
|
564
|
+
return {
|
|
565
|
+
code: "invalid-input",
|
|
566
|
+
error: `toggle import mode: segment ${input.segmentId} has no routed candidate`,
|
|
567
|
+
ok: false,
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const nextMode = segment.mode === "directions" ? "linestring" : "directions";
|
|
572
|
+
ctx.ui.getState().setImportDraft({
|
|
573
|
+
...session.draft,
|
|
574
|
+
segments: session.draft.segments.map((entry) =>
|
|
575
|
+
entry.id === input.segmentId ? { ...entry, mode: nextMode } : entry,
|
|
576
|
+
),
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
return { ok: true, summary: `Set segment ${input.segmentId} to ${nextMode}.` };
|
|
580
|
+
},
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* setSegmentModes assigns each named draft segment its mode in ONE store write.
|
|
585
|
+
*
|
|
586
|
+
* It is the agent's arrangement primitive. The panel offers the choice one row at a
|
|
587
|
+
* time (deliberately, so a reader is never asked the same question twice), and a
|
|
588
|
+
* co-pilot asked to "keep the ridge on my recording" would otherwise have to fire one
|
|
589
|
+
* dispatch per segment, each re-rendering the preview. One call, one write, one paint.
|
|
590
|
+
*
|
|
591
|
+
* A named segment that carries no routed candidate cannot be set to directions: the
|
|
592
|
+
* same rule toggleMode enforces, for the same reason (a mode the draft cannot render).
|
|
593
|
+
* Unknown ids and unroutable assignments both fail the whole call rather than landing
|
|
594
|
+
* half of it, so a restore either returns the draft to where it was or leaves it
|
|
595
|
+
* untouched. Segments the batch does not name keep their mode. It edits the in-memory
|
|
596
|
+
* draft, not the server.
|
|
597
|
+
*
|
|
598
|
+
* While the draft is being committed, or a preview that replaces it is pending, it answers
|
|
599
|
+
* `conflict` and writes nothing ({@link holdDraftWrite}).
|
|
600
|
+
*/
|
|
601
|
+
export const setSegmentModes: StudioToolDefinition<"studio.itinerary.import.setSegmentModes"> = {
|
|
602
|
+
handler: (ctx, input) => {
|
|
603
|
+
const session = selectImportSession(ctx.ui.getState());
|
|
604
|
+
if (!session?.draft) {
|
|
605
|
+
return { code: "no-session", error: "set import segment modes: no import draft", ok: false };
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
const held = holdDraftWrite(ctx, "import", "set import segment modes");
|
|
609
|
+
if (held) {
|
|
610
|
+
return held;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
const wanted = new Map(input.modes.map((entry) => [entry.segmentId, entry.mode]));
|
|
614
|
+
const known = new Set(session.draft.segments.map((segment) => segment.id));
|
|
615
|
+
|
|
616
|
+
for (const segmentId of wanted.keys()) {
|
|
617
|
+
if (!known.has(segmentId)) {
|
|
618
|
+
return {
|
|
619
|
+
code: "not-found",
|
|
620
|
+
error: `set import segment modes: no segment ${segmentId}`,
|
|
621
|
+
ok: false,
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
for (const segment of session.draft.segments) {
|
|
627
|
+
if (wanted.get(segment.id) === "directions" && !segment.directions) {
|
|
628
|
+
return {
|
|
629
|
+
code: "invalid-input",
|
|
630
|
+
error: `set import segment modes: segment ${segment.id} has no routed candidate`,
|
|
631
|
+
ok: false,
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// Count the segments the batch actually moves, so the write is skipped when it
|
|
637
|
+
// asks for what the draft already is.
|
|
638
|
+
let changed = 0;
|
|
639
|
+
const segments = session.draft.segments.map((segment) => {
|
|
640
|
+
const mode = wanted.get(segment.id);
|
|
641
|
+
if (mode === undefined || mode === segment.mode) {
|
|
642
|
+
return segment;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
changed += 1;
|
|
646
|
+
|
|
647
|
+
return { ...segment, mode };
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
if (changed > 0) {
|
|
651
|
+
ctx.ui.getState().setImportDraft({ ...session.draft, segments });
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
return {
|
|
655
|
+
ok: true,
|
|
656
|
+
summary:
|
|
657
|
+
changed === 0
|
|
658
|
+
? "Every named segment already carries that mode."
|
|
659
|
+
: `Set the mode on ${changed} segment${changed === 1 ? "" : "s"}.`,
|
|
660
|
+
};
|
|
661
|
+
},
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* discard abandons the open import: it closes the session, and while the import surface shows,
|
|
666
|
+
* ends the edit armed on its draft, drops the map's preview and a selection of one of the draft's
|
|
667
|
+
* entities, and frees the body slot ({@link endDraftSession}). It is the cancel path the shell's
|
|
668
|
+
* close and the co-pilot both route through.
|
|
669
|
+
*
|
|
670
|
+
* While the surface shows a staged draft, or an edit of it is armed, it first asks with the
|
|
671
|
+
* shared unsaved-changes prompt ({@link askToDropDraft}); a decline answers `confirmation-denied`
|
|
672
|
+
* and keeps the draft, any edit of it and the surface. With no confirm seam it goes on, as the
|
|
673
|
+
* embed's non-interactive contract does.
|
|
674
|
+
*
|
|
675
|
+
* While a commit of the draft is out the verb answers `conflict`, before the prompt and again
|
|
676
|
+
* once it is answered ({@link holdDuringDraftCommit}).
|
|
677
|
+
*
|
|
678
|
+
* It writes nothing to the url: the detail keys the open left standing still name what was
|
|
679
|
+
* behind the surface, so the sidenav falls through to the itinerary the reader came from, or to
|
|
680
|
+
* the list when there was none.
|
|
681
|
+
*/
|
|
682
|
+
export const discard: StudioToolDefinition<"studio.itinerary.import.discard"> = {
|
|
683
|
+
handler: async (ctx) => {
|
|
684
|
+
// With no import open there is nothing of this verb's to abandon, and what follows would
|
|
685
|
+
// end an edit of the open itinerary and close whichever surface stands.
|
|
686
|
+
const closed = requireImportSession(ctx, "discard import");
|
|
687
|
+
if (closed) {
|
|
688
|
+
return closed;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
// A draft on screen, and a change made while the import surface shows, are the reader's
|
|
692
|
+
// unsaved work.
|
|
693
|
+
const ui = ctx.ui.getState();
|
|
694
|
+
const unsaved = ui.importSession?.draft != null || selectUnsavedWork(ui);
|
|
695
|
+
|
|
696
|
+
if (unsaved) {
|
|
697
|
+
const kept = await askToDropDraft(
|
|
698
|
+
ctx,
|
|
699
|
+
"import",
|
|
700
|
+
"discard import",
|
|
701
|
+
"studio.itinerary.import.discard",
|
|
702
|
+
{},
|
|
703
|
+
"discard declined: kept the draft and stayed in the import",
|
|
704
|
+
);
|
|
705
|
+
if (kept) {
|
|
706
|
+
return kept;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
endDraftSession(ctx, "import");
|
|
711
|
+
|
|
712
|
+
return { ok: true, summary: "Discarded the itinerary import." };
|
|
713
|
+
},
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* clearDraft steps the import surface back from its staging step (the metadata form and the
|
|
718
|
+
* content review the panel shows once a preview lands) to the file step, keeping the open
|
|
719
|
+
* session, its provider, the chosen activity and the held file, so the user can preview again
|
|
720
|
+
* without picking the source again. It is the back affordance of the staging step: where
|
|
721
|
+
* discard abandons the whole import, clearDraft steps back to the provider/file input the
|
|
722
|
+
* preview came from.
|
|
723
|
+
*
|
|
724
|
+
* It raises the shared unsaved-changes confirm whenever a draft EXISTS (not only when a geometry
|
|
725
|
+
* edit is armed) AND the confirm seam is wired: stepping back drops the whole staging draft
|
|
726
|
+
* (name, segments, metadata), so the user is asked before that work is lost, as the router
|
|
727
|
+
* blocker and discard ask. A decline answers `confirmation-denied` and leaves the draft and any
|
|
728
|
+
* armed edit intact. On a yes, or with no draft or no seam, it tears any armed engine down,
|
|
729
|
+
* clears the non-persisted map preview, and clears the import preview and the draft (status
|
|
730
|
+
* back to idle). The input shell shows again at the file step (openContent stays "import", so
|
|
731
|
+
* the surface does not return to the list), and it never navigates.
|
|
732
|
+
*
|
|
733
|
+
* While a commit of the draft is out the verb answers `conflict`, before the prompt and again
|
|
734
|
+
* once it is answered ({@link holdDuringDraftCommit}).
|
|
735
|
+
*/
|
|
736
|
+
export const clearDraft: StudioToolDefinition<"studio.itinerary.import.clearDraft"> = {
|
|
737
|
+
handler: async (ctx) => {
|
|
738
|
+
// As discard: with no import open the teardown below would end an edit that is not this
|
|
739
|
+
// verb's, with no prompt.
|
|
740
|
+
const closed = requireImportSession(ctx, "clear import draft");
|
|
741
|
+
if (closed) {
|
|
742
|
+
return closed;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
const draft = selectImportSession(ctx.ui.getState())?.draft ?? null;
|
|
746
|
+
const hasDraft = draft !== null;
|
|
747
|
+
|
|
748
|
+
// Prompt whenever a draft exists, not only on an armed geometry edit: stepping
|
|
749
|
+
// back to the file step discards the whole staging draft (name, segments,
|
|
750
|
+
// metadata), so it must raise the shared unsaved-changes confirm the one way
|
|
751
|
+
// every leave-an-edit path does when a seam is wired. Absent the seam (embed, a
|
|
752
|
+
// render-free test) proceed with teardown so the surface is never wedged.
|
|
753
|
+
if (hasDraft) {
|
|
754
|
+
const kept = await askToDropDraft(
|
|
755
|
+
ctx,
|
|
756
|
+
"import",
|
|
757
|
+
"clear import draft",
|
|
758
|
+
"studio.itinerary.import.clearDraft",
|
|
759
|
+
{},
|
|
760
|
+
"clear draft declined: kept the draft and stayed in the import staging",
|
|
761
|
+
);
|
|
762
|
+
if (kept) {
|
|
763
|
+
return kept;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
// Drop the non-persisted overlay, then clear the preview + draft back to the
|
|
768
|
+
// file step. The provider, activity, name, and held file all survive on the
|
|
769
|
+
// session so the user re-previews without re-picking the source; the status
|
|
770
|
+
// returns to idle so the file step shows fresh rather than the previous source's
|
|
771
|
+
// draft.
|
|
772
|
+
teardownActiveEditSession(ctx);
|
|
773
|
+
ctx.map?.setItineraryPreview(null);
|
|
774
|
+
dropDraftSelection(ctx, draft);
|
|
775
|
+
|
|
776
|
+
const ui = ctx.ui.getState();
|
|
777
|
+
ui.setImportPreview(null);
|
|
778
|
+
ui.setImportDraft(null);
|
|
779
|
+
ui.setImportStatus({ kind: "idle" });
|
|
780
|
+
|
|
781
|
+
return { ok: true, summary: "Returned to the import file step." };
|
|
782
|
+
},
|
|
783
|
+
};
|