@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,499 @@
|
|
|
1
|
+
import { codeForThrown } from "../../bus/rules/handlerErrors.js";
|
|
2
|
+
import { evictResources, invalidateLanded } from "../../data/rules/cache.js";
|
|
3
|
+
import { isPreconditionFailed } from "../../data/rules/restErrors.js";
|
|
4
|
+
import type { StudioToolContext, StudioToolDefinition } from "../../viewer/rules/context.js";
|
|
5
|
+
import { requireWritableScope } from "../../viewer/rules/scope.js";
|
|
6
|
+
import { refreshHeldCollection } from "./heldCollection.js";
|
|
7
|
+
import {
|
|
8
|
+
addItineraryToCollection,
|
|
9
|
+
createCollection as createCollectionRequest,
|
|
10
|
+
deleteCollection as deleteCollectionRequest,
|
|
11
|
+
removeItineraryFromCollection,
|
|
12
|
+
setItineraryPositionInCollection,
|
|
13
|
+
updateCollection as updateCollectionRequest,
|
|
14
|
+
} from "./restCollections.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* invalidateMembership invalidates the entries a collection-membership change reshapes: every
|
|
18
|
+
* collection listing, since each serves the collection's record and its counts and the picker
|
|
19
|
+
* of the collections holding the itinerary moves with it; the collection's own record and its
|
|
20
|
+
* contents; every itinerary listing, since a listing filtered by `in_collection` holds the
|
|
21
|
+
* itinerary or not by this write; and the collection's tile SPECIFICATION.
|
|
22
|
+
*
|
|
23
|
+
* The specification is the collection's render-layer set, so adding or removing an itinerary
|
|
24
|
+
* changes exactly what the embed and share surfaces draw. Left warm, a route filed into a shared
|
|
25
|
+
* folder stays off the map every visitor of that folder sees. The invalidations are
|
|
26
|
+
* independent, so they run together.
|
|
27
|
+
*
|
|
28
|
+
* A membership change moves the collection's version, so the collection's record, where the
|
|
29
|
+
* studio holds one, is read again ({@link refreshHeldCollection}): a later update of the
|
|
30
|
+
* collection is then conditional on the version the change left.
|
|
31
|
+
*
|
|
32
|
+
* It runs once the membership write has landed, so a cache that fails to invalidate fails
|
|
33
|
+
* nothing ({@link invalidateLanded}).
|
|
34
|
+
*/
|
|
35
|
+
const invalidateMembership = async (
|
|
36
|
+
api: NonNullable<StudioToolContext["api"]>,
|
|
37
|
+
collectionId: string,
|
|
38
|
+
): Promise<void> => {
|
|
39
|
+
await invalidateLanded(
|
|
40
|
+
api.cache,
|
|
41
|
+
{ kind: "collections" },
|
|
42
|
+
{ id: collectionId, kind: "collection" },
|
|
43
|
+
{ id: collectionId, kind: "collectionItineraries" },
|
|
44
|
+
{ kind: "itineraries" },
|
|
45
|
+
{ id: collectionId, kind: "collectionSpecification" },
|
|
46
|
+
);
|
|
47
|
+
await refreshHeldCollection(api.client, api.cache, collectionId);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* invalidateCollectionListing invalidates the entries the existence or the metadata of a
|
|
52
|
+
* collection makes stale, the one class of write where a listing row genuinely changes
|
|
53
|
+
* (create, update, delete): every collection listing, and every itinerary listing, since a
|
|
54
|
+
* listing filtered by `in_collection` holds an itinerary by the collections that exist.
|
|
55
|
+
*
|
|
56
|
+
* Every collection listing rather than the one the reader has open: a listing covers the
|
|
57
|
+
* key's organization whatever it is filtered by, so a collection created, renamed or deleted
|
|
58
|
+
* reaches each of them. ctx is the first positional parameter.
|
|
59
|
+
*
|
|
60
|
+
* It runs once the collection's write has landed, so a cache that fails to invalidate fails
|
|
61
|
+
* nothing ({@link invalidateLanded}).
|
|
62
|
+
*/
|
|
63
|
+
const invalidateCollectionListing = async (ctx: StudioToolContext): Promise<void> => {
|
|
64
|
+
if (!ctx.api) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
await invalidateLanded(ctx.api.cache, { kind: "collections" }, { kind: "itineraries" });
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* openForEdit points the studio's collection surface at one collection, so
|
|
73
|
+
* activating a search-result collection lands the user on it directly. There is
|
|
74
|
+
* no per-collection GET in the REST layer (the listing surface fans out a single
|
|
75
|
+
* fetch the manage screens then filter by id), so the handler sets the active
|
|
76
|
+
* collection slot in the UI store; the consuming component reads it through a
|
|
77
|
+
* narrow selector and renders the collection's contents.
|
|
78
|
+
*/
|
|
79
|
+
export const openForEdit: StudioToolDefinition<"studio.collection.openForEdit"> = {
|
|
80
|
+
handler: (ctx, input) => {
|
|
81
|
+
ctx.ui.getState().setActiveCollectionId(input.collectionId);
|
|
82
|
+
|
|
83
|
+
return { ok: true, summary: `Opened collection ${input.collectionId}.` };
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* openManageCollections opens the manage-collections modal for one entity (an
|
|
89
|
+
* itinerary or a zone) by setting the entity-typed collections target in the UI
|
|
90
|
+
* store. The parsed input IS the store's CollectionsTarget, so the handler
|
|
91
|
+
* forwards it unchanged. The shared modal reads the target, loads the user's
|
|
92
|
+
* editable collections, and dispatches the family's add/remove tools (the
|
|
93
|
+
* itinerary or the zone variant) plus the shared create. ctx is the first
|
|
94
|
+
* positional parameter.
|
|
95
|
+
*/
|
|
96
|
+
export const openManageCollections: StudioToolDefinition<"studio.collection.manage.open"> = {
|
|
97
|
+
handler: (ctx, input) => {
|
|
98
|
+
ctx.ui.getState().setCollectionsTarget(input);
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
ok: true,
|
|
102
|
+
summary: `Opened collection management for ${input.entity} ${input.entityId}.`,
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* closeManageCollections closes the manage-collections modal by clearing the
|
|
109
|
+
* collections target.
|
|
110
|
+
*/
|
|
111
|
+
export const closeManageCollections: StudioToolDefinition<"studio.collection.manage.close"> = {
|
|
112
|
+
handler: (ctx) => {
|
|
113
|
+
ctx.ui.getState().setCollectionsTarget(null);
|
|
114
|
+
|
|
115
|
+
return { ok: true, summary: "Closed collection management." };
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* addItinerary adds one itinerary to a collection, then invalidates the caches a
|
|
121
|
+
* membership change reshapes ({@link invalidateMembership}) so the picker, the listings
|
|
122
|
+
* and the collection's rendered layers reflect the new membership. Persisting,
|
|
123
|
+
* so it needs the api seam: without one it answers a `no-api` failure.
|
|
124
|
+
*/
|
|
125
|
+
export const addItinerary: StudioToolDefinition<"studio.collection.addItinerary"> = {
|
|
126
|
+
handler: async (ctx, input) => {
|
|
127
|
+
if (!ctx.api) {
|
|
128
|
+
return {
|
|
129
|
+
code: "no-api",
|
|
130
|
+
error: "add itinerary to collection: no persistence seam",
|
|
131
|
+
ok: false,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
await addItineraryToCollection(ctx.api.client, input.collectionId, [input.itineraryId]);
|
|
136
|
+
await invalidateMembership(ctx.api, input.collectionId);
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
ok: true,
|
|
140
|
+
summary: `Added itinerary ${input.itineraryId} to collection ${input.collectionId}.`,
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* removeItinerary removes one itinerary from a collection, then invalidates the
|
|
147
|
+
* same caches as the add so the membership picker and sidebar both update.
|
|
148
|
+
* Persisting, so it needs the api seam: without one it answers a `no-api` failure.
|
|
149
|
+
*/
|
|
150
|
+
export const removeItinerary: StudioToolDefinition<"studio.collection.removeItinerary"> = {
|
|
151
|
+
handler: async (ctx, input) => {
|
|
152
|
+
if (!ctx.api) {
|
|
153
|
+
return {
|
|
154
|
+
code: "no-api",
|
|
155
|
+
error: "remove itinerary from collection: no persistence seam",
|
|
156
|
+
ok: false,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
await removeItineraryFromCollection(ctx.api.client, input.collectionId, input.itineraryId);
|
|
161
|
+
await invalidateMembership(ctx.api, input.collectionId);
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
ok: true,
|
|
165
|
+
summary: `Removed itinerary ${input.itineraryId} from collection ${input.collectionId}.`,
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* reorderItinerary moves one itinerary to a new display position within a
|
|
172
|
+
* collection, then invalidates the collection's contents so a listing of them reflects
|
|
173
|
+
* the new order. A reorder leaves an itinerary's membership and every listing untouched, so
|
|
174
|
+
* none of those caches is invalidated. It does move the collection's version, so its record is
|
|
175
|
+
* marked stale too, and read again where the studio holds one ({@link refreshHeldCollection}),
|
|
176
|
+
* so a later update is conditional on the version the reorder left. Persisting, so it needs the
|
|
177
|
+
* api seam: without one it answers a `no-api` failure.
|
|
178
|
+
*/
|
|
179
|
+
export const reorderItinerary: StudioToolDefinition<"studio.collection.reorderItinerary"> = {
|
|
180
|
+
handler: async (ctx, input) => {
|
|
181
|
+
if (!ctx.api) {
|
|
182
|
+
return {
|
|
183
|
+
code: "no-api",
|
|
184
|
+
error: "reorder itinerary in collection: no persistence seam",
|
|
185
|
+
ok: false,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
await setItineraryPositionInCollection(
|
|
190
|
+
ctx.api.client,
|
|
191
|
+
input.collectionId,
|
|
192
|
+
input.itineraryId,
|
|
193
|
+
input.position,
|
|
194
|
+
);
|
|
195
|
+
await invalidateLanded(
|
|
196
|
+
ctx.api.cache,
|
|
197
|
+
{ id: input.collectionId, kind: "collectionItineraries" },
|
|
198
|
+
{ id: input.collectionId, kind: "collection" },
|
|
199
|
+
);
|
|
200
|
+
await refreshHeldCollection(ctx.api.client, ctx.api.cache, input.collectionId);
|
|
201
|
+
|
|
202
|
+
return {
|
|
203
|
+
ok: true,
|
|
204
|
+
summary: `Moved itinerary ${input.itineraryId} to position ${input.position} in collection ${input.collectionId}.`,
|
|
205
|
+
};
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* createCollection creates a new collection and, when an itinerary id is
|
|
211
|
+
* given, adds that itinerary into it immediately: the "create a collection in
|
|
212
|
+
* the process of organizing an itinerary" flow. It then invalidates the
|
|
213
|
+
* listings and the membership caches so the new collection (already containing
|
|
214
|
+
* the itinerary) appears pre-checked in the reopened picker.
|
|
215
|
+
* Persisting, so it needs the api seam: without one it answers a `no-api` failure. A
|
|
216
|
+
* 409 from a duplicate name surfaces to the modal, which maps it onto the name field.
|
|
217
|
+
*
|
|
218
|
+
* The create and the add are separate requests, and the add can be refused by itself: a
|
|
219
|
+
* personal collection takes no organization's itinerary. A collection that was created is
|
|
220
|
+
* reported as created whatever the add answered, since a failure would leave it out of every
|
|
221
|
+
* listing and send a retry into the name conflict of the collection the first attempt left. So
|
|
222
|
+
* when the add is refused the result is still a success that carries the new id, names the
|
|
223
|
+
* refusal's code in its summary, and lists the collection under `failedCollectionIds`, the
|
|
224
|
+
* member every create flow reports a failed attach by and `failedCollectionIdsOf` reads, which
|
|
225
|
+
* is otherwise empty. The listings are invalidated either way, and the membership caches only
|
|
226
|
+
* when the itinerary went in.
|
|
227
|
+
*
|
|
228
|
+
* A scope that takes no collection ({@link requireWritableScope}) is refused before anything is
|
|
229
|
+
* sent: an organization whose agreement does not include Map Studio answers `upgrade-required`.
|
|
230
|
+
*
|
|
231
|
+
* A create the API made and could not answer again is saved, and reconciled as one. Where
|
|
232
|
+
* nothing names the collection it made, the answer is `ok` with an empty `collectionId`, the
|
|
233
|
+
* answer a surface already reads as a collection that exists and that it cannot act on, and the
|
|
234
|
+
* listings are read again. It is never answered as a taken name nor sent again.
|
|
235
|
+
*/
|
|
236
|
+
export const createCollection: StudioToolDefinition<"studio.collection.create"> = {
|
|
237
|
+
handler: async (ctx, input) => {
|
|
238
|
+
if (!ctx.api) {
|
|
239
|
+
return { code: "no-api", error: "create collection: no persistence seam", ok: false };
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const refused = requireWritableScope(ctx, "collection", input.organizationId);
|
|
243
|
+
if (refused) {
|
|
244
|
+
return refused;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const collection = await createCollectionRequest(ctx.api.client, {
|
|
248
|
+
// Optional on the wire as well as here: an absent or empty description is
|
|
249
|
+
// "none", which a create says by leaving the field out.
|
|
250
|
+
description: input.description ? input.description : undefined,
|
|
251
|
+
is_private: input.isPrivate,
|
|
252
|
+
name: input.name,
|
|
253
|
+
// Absent means the caller's personal scope; a surface filing an
|
|
254
|
+
// organization's resource sends that organization so the collection is
|
|
255
|
+
// created where the resource can actually be added.
|
|
256
|
+
organization_id: input.organizationId,
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
if (collection === null) {
|
|
260
|
+
// Saved, and nothing names the collection it made: the API made the create and could not
|
|
261
|
+
// answer it again. It is never sent again. The listings are read again, so it shows there,
|
|
262
|
+
// and the itinerary asked for is not in it, since no id is left to add it under.
|
|
263
|
+
await invalidateCollectionListing(ctx);
|
|
264
|
+
|
|
265
|
+
return {
|
|
266
|
+
data: { collectionId: "", failedCollectionIds: [] },
|
|
267
|
+
ok: true,
|
|
268
|
+
summary:
|
|
269
|
+
`Saved collection “${input.name}”. Its answer could not be given again, so the ` +
|
|
270
|
+
"collection listings are read again and it shows once they answer" +
|
|
271
|
+
(input.itineraryId ? `; itinerary ${input.itineraryId} was not added to it.` : "."),
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// The code the add was refused under, or null when it landed or none was asked for.
|
|
276
|
+
let refusedAdd: string | null = null;
|
|
277
|
+
if (input.itineraryId) {
|
|
278
|
+
try {
|
|
279
|
+
await addItineraryToCollection(ctx.api.client, collection.id, [input.itineraryId]);
|
|
280
|
+
} catch (error) {
|
|
281
|
+
// The collection exists. The refusal is the add's, and it is reported beside the
|
|
282
|
+
// creation and never in its place.
|
|
283
|
+
refusedAdd = codeForThrown(error) ?? "internal";
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// The new collection has to show up in every collection listing, whether or not an
|
|
288
|
+
// itinerary went in with it.
|
|
289
|
+
await invalidateCollectionListing(ctx);
|
|
290
|
+
|
|
291
|
+
if (input.itineraryId && refusedAdd === null) {
|
|
292
|
+
await invalidateMembership(ctx.api, collection.id);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (refusedAdd !== null) {
|
|
296
|
+
return {
|
|
297
|
+
data: { collectionId: collection.id, failedCollectionIds: [collection.id] },
|
|
298
|
+
ok: true,
|
|
299
|
+
summary:
|
|
300
|
+
`Created collection “${input.name}” (${collection.id}). Itinerary ` +
|
|
301
|
+
`${input.itineraryId} was not added to it: ${refusedAdd}.`,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Return the new collection id so a caller that could not use the atomic
|
|
306
|
+
// itinerary-add (a zone target) can chain its own add against it.
|
|
307
|
+
return {
|
|
308
|
+
data: { collectionId: collection.id, failedCollectionIds: [] },
|
|
309
|
+
ok: true,
|
|
310
|
+
summary: `Created collection “${input.name}”.`,
|
|
311
|
+
};
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* createOpen opens the dedicated new-collection modal: a minimal name + privacy
|
|
317
|
+
* form distinct from the manage-collections dialog (which is keyed to an
|
|
318
|
+
* itinerary's membership and offers an inline create-in-the-process flow). It
|
|
319
|
+
* sets the openModal slot to `"newCollection"` so the studio root mounts the
|
|
320
|
+
* modal; submission dispatches studio.collection.create with no itineraryId,
|
|
321
|
+
* which only creates the collection. The modal slot is decoupled from the
|
|
322
|
+
* sidenav body so opening this modal leaves the sidenav chrome visible.
|
|
323
|
+
*/
|
|
324
|
+
export const createOpen: StudioToolDefinition<"studio.collection.createOpen"> = {
|
|
325
|
+
handler: (ctx) => {
|
|
326
|
+
ctx.ui.getState().setOpenModal("newCollection");
|
|
327
|
+
|
|
328
|
+
return { ok: true, summary: "Opened the new-collection modal." };
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* createClose closes the dedicated new-collection modal by clearing the
|
|
334
|
+
* openModal slot. Pairing the open and close on the bus keeps the modal's
|
|
335
|
+
* lifecycle on the single mutation surface: a human cancel and an agent
|
|
336
|
+
* close drive the same path.
|
|
337
|
+
*/
|
|
338
|
+
export const createClose: StudioToolDefinition<"studio.collection.createClose"> = {
|
|
339
|
+
handler: (ctx) => {
|
|
340
|
+
ctx.ui.getState().setOpenModal(null);
|
|
341
|
+
|
|
342
|
+
return { ok: true, summary: "Closed the new-collection modal." };
|
|
343
|
+
},
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* updateCollection updates a collection's metadata (name + description + privacy), then
|
|
348
|
+
* invalidates the listings so the renamed collection appears everywhere it shows. The update
|
|
349
|
+
* is conditional on the `etag` of the collection the studio holds, where it holds one: a
|
|
350
|
+
* collection somebody changed since answers 412, a `conflict` the bus tags as a moved version, so
|
|
351
|
+
* a form reads it as a change since the reader opened the collection and never as a taken name,
|
|
352
|
+
* and its record is read again ({@link refreshHeldCollection}), so the next attempt is
|
|
353
|
+
* conditional on the version it would overwrite. Persisting, so it needs the api seam: without
|
|
354
|
+
* one it answers a `no-api` failure. A 409 from a duplicate name surfaces to the caller, which
|
|
355
|
+
* maps it onto the name field. The backend authorizes it for a write role in the organization
|
|
356
|
+
* that owns the collection, and on top of it the collection's authorship or the owner or admin
|
|
357
|
+
* role there (`canEditCollectionMetadata`); a personal collection, for its author.
|
|
358
|
+
*
|
|
359
|
+
* It also invalidates the collection's own entry (`{ kind: "collection", id }`), which no
|
|
360
|
+
* listing ref reaches. A surface holding only an id reads that entry (the embed wizard titles
|
|
361
|
+
* itself from it, and its private/public notice reads the privacy flag), so a warm entry would
|
|
362
|
+
* keep showing the name and the privacy this write just replaced. The ref names no credential,
|
|
363
|
+
* so a cache that keys its entries by credential (`createStudioCache` of
|
|
364
|
+
* `@mountaya/studio-react`) marks every credential's copy, and a share visitor's copy of the
|
|
365
|
+
* record drops with the owner's. The update moved the collection's version, and the echo names
|
|
366
|
+
* only the collection and its organization, so the record this credential holds is read again
|
|
367
|
+
* ({@link refreshHeldCollection}): a second rename is conditional on the version the first left,
|
|
368
|
+
* and never refused for a change nobody else made.
|
|
369
|
+
*/
|
|
370
|
+
export const updateCollection: StudioToolDefinition<"studio.collection.update"> = {
|
|
371
|
+
handler: async (ctx, input) => {
|
|
372
|
+
if (!ctx.api) {
|
|
373
|
+
return { code: "no-api", error: "update collection: no persistence seam", ok: false };
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// Conditional on the version the studio read, where it holds the record: an update of a
|
|
377
|
+
// collection somebody changed since is refused as a conflict rather than overwriting it.
|
|
378
|
+
const held = ctx.api.cache.get({ id: input.collectionId, kind: "collection" });
|
|
379
|
+
try {
|
|
380
|
+
await updateCollectionRequest(
|
|
381
|
+
ctx.api.client,
|
|
382
|
+
input.collectionId,
|
|
383
|
+
{ description: input.description, is_private: input.isPrivate, name: input.name },
|
|
384
|
+
held?.etag,
|
|
385
|
+
);
|
|
386
|
+
} catch (error) {
|
|
387
|
+
// The version the studio held is not the collection's any more: the record is read again
|
|
388
|
+
// before the conflict is answered, so a retry is made over what it would replace.
|
|
389
|
+
if (isPreconditionFailed(error)) {
|
|
390
|
+
await invalidateLanded(ctx.api.cache, { id: input.collectionId, kind: "collection" });
|
|
391
|
+
await refreshHeldCollection(ctx.api.client, ctx.api.cache, input.collectionId);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
throw error;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
await Promise.all([
|
|
398
|
+
invalidateCollectionListing(ctx),
|
|
399
|
+
invalidateLanded(ctx.api.cache, { id: input.collectionId, kind: "collection" }),
|
|
400
|
+
]);
|
|
401
|
+
await refreshHeldCollection(ctx.api.client, ctx.api.cache, input.collectionId);
|
|
402
|
+
|
|
403
|
+
// A rename is summarized by the new name. An update of the description or the privacy
|
|
404
|
+
// alone carries none, so it names the collection by its id.
|
|
405
|
+
return {
|
|
406
|
+
ok: true,
|
|
407
|
+
summary:
|
|
408
|
+
input.name === undefined
|
|
409
|
+
? `Updated collection ${input.collectionId}.`
|
|
410
|
+
: `Updated collection “${input.name}”.`,
|
|
411
|
+
};
|
|
412
|
+
},
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* deleteCollection permanently deletes a collection (its itineraries and zones are not
|
|
417
|
+
* deleted, only the grouping). It is destructive, so it sets
|
|
418
|
+
* requiresConfirmation: the bus gate prompts through ctx.confirm before the handler
|
|
419
|
+
* runs, the same flow the itinerary/zone deletes use. After the delete it clears the
|
|
420
|
+
* active collection slot when the deleted collection is the one being viewed, then
|
|
421
|
+
* invalidates the listings. Persisting, so it needs
|
|
422
|
+
* the api seam. The backend authorizes it as it authorizes a rename (`canDeleteCollection`): a
|
|
423
|
+
* write role in the owning organization, and on top of it the collection's authorship or the
|
|
424
|
+
* owner or admin role there; a personal collection, for its author.
|
|
425
|
+
*
|
|
426
|
+
* It also invalidates the collection's own entry (`{ kind: "collection", id }`), for the same
|
|
427
|
+
* reason the update does: no listing ref reaches it. Left standing, the record of a deleted
|
|
428
|
+
* collection would go on answering a surface holding only the id (the embed wizard, the share
|
|
429
|
+
* dialog), which would title and gate itself from a deleted folder until the entry aged out on
|
|
430
|
+
* its own.
|
|
431
|
+
*
|
|
432
|
+
* An invalidated entry is stale and may still answer, so where the cache states an `evict` the
|
|
433
|
+
* handler removes the entry as well ({@link evictResources}), and a read of the id then
|
|
434
|
+
* answers nothing.
|
|
435
|
+
*/
|
|
436
|
+
export const deleteCollection: StudioToolDefinition<"studio.collection.delete"> = {
|
|
437
|
+
// Deleting a whole collection is high-stakes, so it gates behind an "I
|
|
438
|
+
// understand…" acknowledge and carries its own title/body/confirm copy for the
|
|
439
|
+
// shared confirm dialog ("Delete collection" rather than the generic prompt).
|
|
440
|
+
confirmation: {
|
|
441
|
+
acknowledgeLabel: "confirm.deleteCollectionAcknowledge",
|
|
442
|
+
confirmLabel: "confirm.delete",
|
|
443
|
+
descriptionLabel: "confirm.deleteCollection.body",
|
|
444
|
+
titleLabel: "confirm.deleteCollection.title",
|
|
445
|
+
},
|
|
446
|
+
handler: async (ctx, input) => {
|
|
447
|
+
if (!ctx.api) {
|
|
448
|
+
return { code: "no-api", error: "delete collection: no persistence seam", ok: false };
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
await deleteCollectionRequest(ctx.api.client, input.collectionId);
|
|
452
|
+
|
|
453
|
+
if (ctx.ui.getState().activeCollectionId === input.collectionId) {
|
|
454
|
+
ctx.ui.getState().setActiveCollectionId(null);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// The server has confirmed the delete, and no read will replace the collection's own
|
|
458
|
+
// entry: a cache that can remove it does, beside the invalidation below.
|
|
459
|
+
evictResources(ctx.api.cache, { id: input.collectionId, kind: "collection" });
|
|
460
|
+
|
|
461
|
+
// The collection's own entry is named without a credential, so a cache that keys its
|
|
462
|
+
// entries by credential drops every credential's copy, not only the one of the session that
|
|
463
|
+
// deleted it.
|
|
464
|
+
await Promise.all([
|
|
465
|
+
invalidateCollectionListing(ctx),
|
|
466
|
+
invalidateLanded(ctx.api.cache, { id: input.collectionId, kind: "collection" }),
|
|
467
|
+
]);
|
|
468
|
+
|
|
469
|
+
return { ok: true, summary: `Deleted collection ${input.collectionId}.` };
|
|
470
|
+
},
|
|
471
|
+
requiresConfirmation: true,
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* editOpen opens the edit-collection modal bound to one collection by setting
|
|
476
|
+
* the edit-collection slot (its id + seed metadata). The shared modal reads the
|
|
477
|
+
* slot, seeds its fields, and dispatches studio.collection.update on submit. The
|
|
478
|
+
* input is the store's EditingCollection shape, forwarded unchanged.
|
|
479
|
+
*/
|
|
480
|
+
export const editOpen: StudioToolDefinition<"studio.collection.editOpen"> = {
|
|
481
|
+
handler: (ctx, input) => {
|
|
482
|
+
ctx.ui.getState().setCollectionToEdit(input);
|
|
483
|
+
|
|
484
|
+
return { ok: true, summary: `Opened edit for collection ${input.id}.` };
|
|
485
|
+
},
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* editClose closes the edit-collection modal by clearing the edit-collection
|
|
490
|
+
* slot. Pairing open and close on the bus keeps the modal lifecycle on the
|
|
491
|
+
* single mutation surface.
|
|
492
|
+
*/
|
|
493
|
+
export const editClose: StudioToolDefinition<"studio.collection.editClose"> = {
|
|
494
|
+
handler: (ctx) => {
|
|
495
|
+
ctx.ui.getState().setCollectionToEdit(null);
|
|
496
|
+
|
|
497
|
+
return { ok: true, summary: "Closed the edit-collection dialog." };
|
|
498
|
+
},
|
|
499
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Mountaya } from "@mountaya/client";
|
|
2
|
+
|
|
3
|
+
import type { StudioCache } from "../../data/rules/cache.js";
|
|
4
|
+
import { readCollection } from "./restCollections.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* refreshHeldCollection reads a collection's record again and seeds it, where the studio holds
|
|
8
|
+
* one, once a write that moved the collection's version has landed or a conditional update was
|
|
9
|
+
* refused for a version the collection has moved past.
|
|
10
|
+
*
|
|
11
|
+
* The record is what a collection's update is made conditional on: its `etag` rides `If-Match`.
|
|
12
|
+
* Marking the entry stale does not move it, since a cache keeps an entry nothing observes as it
|
|
13
|
+
* was until a read replaces it. A rename after an earlier rename, a membership change or a
|
|
14
|
+
* reorder would then send the version the studio read first, and be refused as a change somebody
|
|
15
|
+
* else made, every time, until the entry aged out. Read again, the entry holds the version the API
|
|
16
|
+
* holds now, so the next update is conditional on what it would replace. Evicting it instead would
|
|
17
|
+
* make that update unconditional, and it would overwrite a change it never saw.
|
|
18
|
+
*
|
|
19
|
+
* A collection the studio holds no record of is read nowhere: the next update sends no `If-Match`,
|
|
20
|
+
* as it would have. It never rejects: a read that fails leaves the entry as the write's
|
|
21
|
+
* invalidation marked it, and the next update meets the 412 and reads it then.
|
|
22
|
+
*
|
|
23
|
+
* @param client The client the write was made through.
|
|
24
|
+
* @param cache The cache the write's handler was handed.
|
|
25
|
+
* @param collectionId The collection whose version moved.
|
|
26
|
+
*/
|
|
27
|
+
export const refreshHeldCollection = async (
|
|
28
|
+
client: Mountaya,
|
|
29
|
+
cache: StudioCache,
|
|
30
|
+
collectionId: string,
|
|
31
|
+
): Promise<void> => {
|
|
32
|
+
const ref = { id: collectionId, kind: "collection" } as const;
|
|
33
|
+
if (cache.get(ref) === undefined) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
cache.set(ref, await readCollection(client, collectionId));
|
|
39
|
+
} catch {
|
|
40
|
+
// Left as the write's invalidation marked it: the next update reads it on its 412.
|
|
41
|
+
}
|
|
42
|
+
};
|