@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,386 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
Collection,
|
|
5
|
+
CollectionCreateParams,
|
|
6
|
+
CollectionUpdateParams,
|
|
7
|
+
Mountaya,
|
|
8
|
+
ShareLink,
|
|
9
|
+
} from "@mountaya/client";
|
|
10
|
+
import { MountayaElementsError } from "@mountaya/elements/errors";
|
|
11
|
+
|
|
12
|
+
import { type DeclaredFields, declaredBody } from "../../data/rules/requestBody.js";
|
|
13
|
+
import { createdIdOf, reconcileMadeWrite } from "../../data/rules/restErrors.js";
|
|
14
|
+
|
|
15
|
+
/** The members a collection's create declares. */
|
|
16
|
+
const collectionCreateFields: DeclaredFields<CollectionCreateParams> = {
|
|
17
|
+
description: true,
|
|
18
|
+
is_private: true,
|
|
19
|
+
name: true,
|
|
20
|
+
organization_id: true,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** The members a collection's update declares. */
|
|
24
|
+
const collectionUpdateFields: DeclaredFields<CollectionUpdateParams> = {
|
|
25
|
+
description: true,
|
|
26
|
+
is_private: true,
|
|
27
|
+
name: true,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* collectionWriteEchoSchema is the narrow slice of the collection a create or an
|
|
32
|
+
* update echoes back that a caller actually consumes: the id it chains further
|
|
33
|
+
* writes against, and the organization whose listing the write reshaped (`null`
|
|
34
|
+
* for a personal collection, which belongs to no organization).
|
|
35
|
+
*
|
|
36
|
+
* It is parsed rather than cast, matching the read paths and the share fetchers.
|
|
37
|
+
* The organization is what makes that worth doing: it selects which cache entry
|
|
38
|
+
* gets evicted, so a wire that omitted it would silently leave the wrong listing
|
|
39
|
+
* stale rather than fail, and the collection would go missing from the sidebar
|
|
40
|
+
* until a reload. Null is a value here, not an omission: a personal collection's
|
|
41
|
+
* write is as successful as any other, and refusing its echo would report a
|
|
42
|
+
* persisted change as a failure.
|
|
43
|
+
*/
|
|
44
|
+
const collectionWriteEchoSchema = z.object({
|
|
45
|
+
id: z.string().min(1),
|
|
46
|
+
organization_id: z.string().min(1).nullable(),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* CollectionWriteEcho is the parsed create/update echo, derived from
|
|
51
|
+
* collectionWriteEchoSchema.
|
|
52
|
+
*/
|
|
53
|
+
export type CollectionWriteEcho = z.infer<typeof collectionWriteEchoSchema>;
|
|
54
|
+
|
|
55
|
+
const collectionWriteResponseSchema = z.object({ data: collectionWriteEchoSchema });
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* readWriteAnswer parses the answer of a write the API accepted.
|
|
59
|
+
*
|
|
60
|
+
* By the time there is an answer to read, the write has landed: the collection exists, holds
|
|
61
|
+
* its new name, or has a new share token. An answer the schema refuses is therefore no refusal
|
|
62
|
+
* of the request, and a schema error would read as one (the bus words it as the caller's input
|
|
63
|
+
* being invalid). So the miss is raised as an error of the package's family that names the
|
|
64
|
+
* operation, says the write landed and names what could not be read, with `nextStep` telling
|
|
65
|
+
* the caller how to see the state the write left. The schema's own error is its `cause`.
|
|
66
|
+
*
|
|
67
|
+
* @throws {MountayaElementsError} When `envelope` does not fit `schema`.
|
|
68
|
+
*/
|
|
69
|
+
const readWriteAnswer = <T>(
|
|
70
|
+
schema: z.ZodType<T>,
|
|
71
|
+
envelope: unknown,
|
|
72
|
+
operation: string,
|
|
73
|
+
nextStep: string,
|
|
74
|
+
): T => {
|
|
75
|
+
const parsed = schema.safeParse(envelope);
|
|
76
|
+
if (!parsed.success) {
|
|
77
|
+
// An issue with an empty path is about the answer itself (a body that is no envelope), and
|
|
78
|
+
// an empty name would say nothing was unread.
|
|
79
|
+
const unread = [
|
|
80
|
+
...new Set(
|
|
81
|
+
parsed.error.issues.map((issue) =>
|
|
82
|
+
issue.path.length === 0 ? "the whole answer" : issue.path.map(String).join("."),
|
|
83
|
+
),
|
|
84
|
+
),
|
|
85
|
+
].join(", ");
|
|
86
|
+
|
|
87
|
+
throw new MountayaElementsError(
|
|
88
|
+
`${operation}: the write landed, and its answer could not be read (${unread}). ${nextStep}`,
|
|
89
|
+
{ cause: parsed.error },
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return parsed.data;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/** What a caller does after a create or an update whose echo could not be read. */
|
|
97
|
+
const READ_COLLECTIONS_AGAIN = "Read the collections again before retrying.";
|
|
98
|
+
|
|
99
|
+
/** What a caller does after a mint or a rotate whose token could not be read. */
|
|
100
|
+
const MINT_AGAIN = "Mint the link again to read it.";
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* readCollection reads one collection's record as the API holds it now, `etag` included: the
|
|
104
|
+
* version a later update of it is made conditional on. A non-ok response throws.
|
|
105
|
+
*/
|
|
106
|
+
export const readCollection = async (client: Mountaya, collectionId: string): Promise<Collection> =>
|
|
107
|
+
(await client.studio.collections.getCollection({ collection_id: collectionId })).data;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* addItineraryToCollection adds one or more itineraries to a collection. The
|
|
111
|
+
* backend accepts a batch (`{ itinerary_ids }`), so the caller passes an array
|
|
112
|
+
* even for a single itinerary. The success envelope carries no data the caller
|
|
113
|
+
* needs, so this resolves to void; a non-ok response throws so the caller can
|
|
114
|
+
* skip its optimistic update.
|
|
115
|
+
*
|
|
116
|
+
* An add the API made and cannot answer again resolves as one that answered.
|
|
117
|
+
*/
|
|
118
|
+
export const addItineraryToCollection = async (
|
|
119
|
+
client: Mountaya,
|
|
120
|
+
collectionId: string,
|
|
121
|
+
itineraryIds: string[],
|
|
122
|
+
): Promise<void> =>
|
|
123
|
+
reconcileMadeWrite(
|
|
124
|
+
async () => {
|
|
125
|
+
await client.studio.collections.postCollectionItineraries({
|
|
126
|
+
body: { itinerary_ids: itineraryIds },
|
|
127
|
+
collection_id: collectionId,
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
() => undefined,
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* removeItineraryFromCollection removes one itinerary from a collection, which leaves the
|
|
135
|
+
* itinerary itself untouched. A removal names one itinerary, so a caller removing several sends
|
|
136
|
+
* one per itinerary. It resolves to void; a non-ok response throws, a 404 among them where the
|
|
137
|
+
* collection does not hold the itinerary.
|
|
138
|
+
*
|
|
139
|
+
* A removal the API made and cannot answer again resolves as one that answered.
|
|
140
|
+
*/
|
|
141
|
+
export const removeItineraryFromCollection = async (
|
|
142
|
+
client: Mountaya,
|
|
143
|
+
collectionId: string,
|
|
144
|
+
itineraryId: string,
|
|
145
|
+
): Promise<void> =>
|
|
146
|
+
reconcileMadeWrite(
|
|
147
|
+
async () => {
|
|
148
|
+
await client.studio.collections.deleteCollectionItinerary({
|
|
149
|
+
collection_id: collectionId,
|
|
150
|
+
itinerary_id: itineraryId,
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
() => undefined,
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* setItineraryPositionInCollection sets one itinerary's zero-based display
|
|
158
|
+
* position within a collection, so a reorder moves a single itinerary to a new
|
|
159
|
+
* slot and the backend resequences the rest. The success envelope carries no
|
|
160
|
+
* data the caller needs, so this resolves to void; a non-ok response throws so
|
|
161
|
+
* the caller can revert its optimistic reorder.
|
|
162
|
+
*
|
|
163
|
+
* A move the API made and cannot answer again resolves as one that answered.
|
|
164
|
+
*/
|
|
165
|
+
export const setItineraryPositionInCollection = async (
|
|
166
|
+
client: Mountaya,
|
|
167
|
+
collectionId: string,
|
|
168
|
+
itineraryId: string,
|
|
169
|
+
position: number,
|
|
170
|
+
): Promise<void> =>
|
|
171
|
+
reconcileMadeWrite(
|
|
172
|
+
async () => {
|
|
173
|
+
await client.studio.collections.patchCollectionItinerary({
|
|
174
|
+
body: { position },
|
|
175
|
+
collection_id: collectionId,
|
|
176
|
+
itinerary_id: itineraryId,
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
() => undefined,
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* createCollection creates a new collection from a name + description + privacy flag, in
|
|
184
|
+
* the organization the params name or, without one, in the caller's personal scope. It
|
|
185
|
+
* resolves to the echo's id and organization ({@link CollectionWriteEcho}), which is what a
|
|
186
|
+
* caller chains its next write against and keys its cache eviction on. A non-ok response
|
|
187
|
+
* throws (including the 409 a duplicate name produces, which the caller surfaces as a name
|
|
188
|
+
* conflict).
|
|
189
|
+
*
|
|
190
|
+
* A create the API made and cannot answer again is never sent again: it resolves to the
|
|
191
|
+
* collection its first answer's `Location` names, in the organization the params asked for, or
|
|
192
|
+
* to null where that answer named none. Null is a collection that was saved and that the caller
|
|
193
|
+
* cannot name, so it reads its collection listings again rather than creating it a second time.
|
|
194
|
+
*
|
|
195
|
+
* @throws {MountayaElementsError} When the create landed and its echo could not be read
|
|
196
|
+
* ({@link readWriteAnswer}).
|
|
197
|
+
*/
|
|
198
|
+
export const createCollection = async (
|
|
199
|
+
client: Mountaya,
|
|
200
|
+
params: CollectionCreateParams,
|
|
201
|
+
): Promise<CollectionWriteEcho | null> =>
|
|
202
|
+
reconcileMadeWrite<CollectionWriteEcho | null>(
|
|
203
|
+
async () => {
|
|
204
|
+
const envelope = await client.studio.collections.postCollection({
|
|
205
|
+
body: declaredBody(params, collectionCreateFields),
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
return readWriteAnswer(
|
|
209
|
+
collectionWriteResponseSchema,
|
|
210
|
+
envelope,
|
|
211
|
+
"create collection",
|
|
212
|
+
READ_COLLECTIONS_AGAIN,
|
|
213
|
+
).data;
|
|
214
|
+
},
|
|
215
|
+
(answer) => {
|
|
216
|
+
// The collection was made where the create asked for it: the organization the params
|
|
217
|
+
// name, or the personal scope, which names none.
|
|
218
|
+
const id = createdIdOf(answer);
|
|
219
|
+
|
|
220
|
+
return id === undefined ? null : { id, organization_id: params.organization_id ?? null };
|
|
221
|
+
},
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* updateCollection updates a collection's metadata (name + description +
|
|
226
|
+
* privacy) and resolves to the echo's id and organization ({@link CollectionWriteEcho}),
|
|
227
|
+
* which names the listing the write reshaped. Every field is optional: the backend
|
|
228
|
+
* `PATCH` keeps the current value of anything omitted, so an inline rename sends
|
|
229
|
+
* the name alone rather than re-sending the unchanged description + privacy. A
|
|
230
|
+
* non-ok response throws (including the 409 a duplicate name produces, which the
|
|
231
|
+
* caller surfaces as a name conflict). `ifMatch` is the `etag` the collection was read under:
|
|
232
|
+
* sent, the update lands only on that version, and a 412 says the collection changed since.
|
|
233
|
+
*
|
|
234
|
+
* An update the API made and cannot answer again resolves to the collection read again, and is
|
|
235
|
+
* never sent a second time.
|
|
236
|
+
*
|
|
237
|
+
* @throws {MountayaElementsError} When the update landed and its echo could not be read
|
|
238
|
+
* ({@link readWriteAnswer}).
|
|
239
|
+
*/
|
|
240
|
+
export const updateCollection = async (
|
|
241
|
+
client: Mountaya,
|
|
242
|
+
collectionId: string,
|
|
243
|
+
params: CollectionUpdateParams,
|
|
244
|
+
ifMatch?: string,
|
|
245
|
+
): Promise<CollectionWriteEcho> =>
|
|
246
|
+
reconcileMadeWrite(
|
|
247
|
+
async () => {
|
|
248
|
+
const envelope = await client.studio.collections.patchCollection({
|
|
249
|
+
body: declaredBody(params, collectionUpdateFields),
|
|
250
|
+
collection_id: collectionId,
|
|
251
|
+
ifMatch,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
return readWriteAnswer(
|
|
255
|
+
collectionWriteResponseSchema,
|
|
256
|
+
envelope,
|
|
257
|
+
"update collection",
|
|
258
|
+
READ_COLLECTIONS_AGAIN,
|
|
259
|
+
).data;
|
|
260
|
+
},
|
|
261
|
+
async () =>
|
|
262
|
+
readWriteAnswer(
|
|
263
|
+
collectionWriteResponseSchema,
|
|
264
|
+
await client.studio.collections.getCollection({ collection_id: collectionId }),
|
|
265
|
+
"update collection",
|
|
266
|
+
READ_COLLECTIONS_AGAIN,
|
|
267
|
+
).data,
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* deleteCollection permanently deletes a collection. Its itineraries and zones are
|
|
272
|
+
* not deleted: only the collection grouping is removed.
|
|
273
|
+
* The success envelope carries nothing the caller needs, so this resolves to
|
|
274
|
+
* void; a non-ok response throws.
|
|
275
|
+
*
|
|
276
|
+
* A delete the API made and cannot answer again resolves as one that answered.
|
|
277
|
+
*/
|
|
278
|
+
export const deleteCollection = async (client: Mountaya, collectionId: string): Promise<void> =>
|
|
279
|
+
reconcileMadeWrite(
|
|
280
|
+
async () => {
|
|
281
|
+
await client.studio.collections.deleteCollection({ collection_id: collectionId });
|
|
282
|
+
},
|
|
283
|
+
() => undefined,
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* collectionShareSchema is a collection's share link as a mint, a rotate or a read answers it.
|
|
288
|
+
* The token is validated at the boundary rather than cast, matching the repo's
|
|
289
|
+
* Zod-parse-at-the-edge norm for write responses.
|
|
290
|
+
*
|
|
291
|
+
* The non-empty bound is load-bearing, not decoration. An empty token parses as a
|
|
292
|
+
* perfectly good string, and a rotate that resolved one would report success while
|
|
293
|
+
* the dialog kept displaying the URL that write had just retired: the user copies a
|
|
294
|
+
* dead link believing the reset landed. An answer that does not fit throws instead
|
|
295
|
+
* ({@link readWriteAnswer}), which the bus classifies and the dialog surfaces as a
|
|
296
|
+
* failure, leaving the old link visible AND saying so.
|
|
297
|
+
*/
|
|
298
|
+
const collectionShareSchema = z.object({
|
|
299
|
+
created_at: z.date(),
|
|
300
|
+
share_token: z.string().min(1),
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
/** collectionShareResponseSchema is the REST envelope around a minted or rotated share link. */
|
|
304
|
+
const collectionShareResponseSchema = z.object({ data: collectionShareSchema });
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* mintCollectionShareLink gets-or-creates the share link for one collection and
|
|
308
|
+
* resolves it. The POST carries no body (the collection id in the path is the
|
|
309
|
+
* whole request) and answers the link already set where there is one, so reopening the share
|
|
310
|
+
* modal returns the same token rather than churning it. Unlike an itinerary link, the token it
|
|
311
|
+
* mints carries the collection's itineraries and zones with it, which is why the backend
|
|
312
|
+
* gates the mint on a grant the collection merely being public does not confer. It
|
|
313
|
+
* authenticates through the client's strategy and Zod-parses the envelope at the
|
|
314
|
+
* boundary; a non-ok response throws a typed API error carrying the status and
|
|
315
|
+
* the backend's own localized sentence, so the tool bus classifies the refusal (a 403
|
|
316
|
+
* becomes `forbidden`) instead of collapsing every failure into a generic internal one.
|
|
317
|
+
*/
|
|
318
|
+
export const mintCollectionShareLink = async (
|
|
319
|
+
client: Mountaya,
|
|
320
|
+
collectionId: string,
|
|
321
|
+
): Promise<ShareLink> => {
|
|
322
|
+
const envelope = await client.studio.collections.postCollectionShareLink({
|
|
323
|
+
collection_id: collectionId,
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
return readWriteAnswer(
|
|
327
|
+
collectionShareResponseSchema,
|
|
328
|
+
envelope,
|
|
329
|
+
"mint collection share link",
|
|
330
|
+
MINT_AGAIN,
|
|
331
|
+
).data;
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* rotateCollectionShareLink invalidates the current share token and resolves a fresh
|
|
336
|
+
* one, so the previous link stops authorizing reads immediately. Same bodyless POST +
|
|
337
|
+
* envelope-parse + structured-throw-on-non-ok contract as the mint, on the /rotate
|
|
338
|
+
* path. Rotating and minting both need a write role, so a member whose role is read-only
|
|
339
|
+
* meets a 403 on either, and the structured throw is what lets the bus say so. A collection
|
|
340
|
+
* with no link to rotate is a 409.
|
|
341
|
+
*/
|
|
342
|
+
export const rotateCollectionShareLink = async (
|
|
343
|
+
client: Mountaya,
|
|
344
|
+
collectionId: string,
|
|
345
|
+
): Promise<ShareLink> => {
|
|
346
|
+
const envelope = await client.studio.collections.postCollectionShareLinkRotate({
|
|
347
|
+
collection_id: collectionId,
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
return readWriteAnswer(
|
|
351
|
+
collectionShareResponseSchema,
|
|
352
|
+
envelope,
|
|
353
|
+
"rotate collection share link",
|
|
354
|
+
MINT_AGAIN,
|
|
355
|
+
).data;
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* disableCollectionShareLink revokes the collection's share link entirely: the token
|
|
360
|
+
* is cleared and every URL carrying it stops resolving. The success envelope carries
|
|
361
|
+
* nothing the caller needs, a collection with no link included, so this resolves to void; a
|
|
362
|
+
* non-ok response throws the same typed API error the mint and the rotate do.
|
|
363
|
+
*/
|
|
364
|
+
export const disableCollectionShareLink = async (
|
|
365
|
+
client: Mountaya,
|
|
366
|
+
collectionId: string,
|
|
367
|
+
): Promise<void> => {
|
|
368
|
+
await client.studio.collections.deleteCollectionShareLink({
|
|
369
|
+
collection_id: collectionId,
|
|
370
|
+
});
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* fetchCollectionShareLink reads the collection's share link without setting one: the link, or
|
|
375
|
+
* `null` where none is set. Reading it needs the write role a mint needs.
|
|
376
|
+
*/
|
|
377
|
+
export const fetchCollectionShareLink = async (
|
|
378
|
+
client: Mountaya,
|
|
379
|
+
collectionId: string,
|
|
380
|
+
): Promise<ShareLink | null> => {
|
|
381
|
+
const envelope = await client.studio.collections.getCollectionShareLink({
|
|
382
|
+
collection_id: collectionId,
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
return z.object({ data: collectionShareSchema.nullable() }).parse(envelope).data;
|
|
386
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
|
|
3
|
+
import type { RestSchema } from "@mountaya/client";
|
|
4
|
+
|
|
5
|
+
import { descriptionSchema, displayNameSchema } from "../../edit/rules/draftMetadata.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Who may act on a collection, and on what.
|
|
9
|
+
*
|
|
10
|
+
* The platform runs these gates server-side and will refuse a write that fails them. They are
|
|
11
|
+
* restated here so a surface can grey out an action rather than offer it and answer with a 403,
|
|
12
|
+
* and, more importantly, so a picker can be FILTERED to the folders a caller may actually write
|
|
13
|
+
* to, which is not something a per-row failure can express.
|
|
14
|
+
*
|
|
15
|
+
* Two gates, not one, and the difference is easy to get backwards: contributing to a collection
|
|
16
|
+
* is wider than managing it. A contributor fills a colleague's folder and cannot rename or
|
|
17
|
+
* delete it.
|
|
18
|
+
*
|
|
19
|
+
* Both are ALLOWLISTS, and that shape is load-bearing rather than incidental. A role the
|
|
20
|
+
* contract does not list (the ordinary state during a rolling deploy, where the platform has
|
|
21
|
+
* shipped a vocabulary this build has not regenerated against) grants nothing, so the surface
|
|
22
|
+
* renders the row read-only while the platform goes on enforcing. Refusing the whole response
|
|
23
|
+
* instead, which is what a runtime schema check would do, turns one unfamiliar row into a broken
|
|
24
|
+
* picker.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The roles permitted to add, remove or reorder a collection's contents.
|
|
29
|
+
*
|
|
30
|
+
* A viewer reads an organization's collections and writes nothing, so it is excluded, which is
|
|
31
|
+
* what lets a listing be narrowed to the folders an itinerary or a zone can actually be moved
|
|
32
|
+
* into.
|
|
33
|
+
*/
|
|
34
|
+
const collectionContentRoles: ReadonlySet<RestSchema.OrganizationRole> =
|
|
35
|
+
new Set<RestSchema.OrganizationRole>(["owner", "admin", "contributor"]);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The roles permitted to act on a collection ITSELF: renaming it, changing its description or
|
|
39
|
+
* privacy, deleting it.
|
|
40
|
+
*/
|
|
41
|
+
const collectionMetadataRoles: ReadonlySet<RestSchema.OrganizationRole> =
|
|
42
|
+
new Set<RestSchema.OrganizationRole>(["owner", "admin"]);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* canEditCollection reports whether a role may add, remove or reorder a collection's contents.
|
|
46
|
+
*
|
|
47
|
+
* The role is the caller's in the organization that OWNS the collection, which every collection
|
|
48
|
+
* the wire returns carries. A personal collection reports `"owner"`, because its author is the
|
|
49
|
+
* only caller who can reach it at all, so the same predicate answers both scopes and a surface
|
|
50
|
+
* never has to branch on whether a folder is personal.
|
|
51
|
+
*/
|
|
52
|
+
export const canEditCollection = (role: RestSchema.OrganizationRole): boolean =>
|
|
53
|
+
collectionContentRoles.has(role);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* canEditCollectionMetadata reports whether the caller may rename a collection or change its
|
|
57
|
+
* description or privacy.
|
|
58
|
+
*
|
|
59
|
+
* It mirrors the contract's gate: a write role, and on top of it either the collection's
|
|
60
|
+
* authorship or owner or admin in the owning organization. The author passes on any write role,
|
|
61
|
+
* which is what makes a personal collection manageable (its author reports `"owner"` there),
|
|
62
|
+
* and does NOT pass without one: authorship is on top of a write role, never instead of it, so an
|
|
63
|
+
* author demoted to viewer is answered 403 and is offered nothing here.
|
|
64
|
+
*
|
|
65
|
+
* @param role - The caller's role in the organization that owns the collection.
|
|
66
|
+
* @param isAuthor - Whether the caller created the collection.
|
|
67
|
+
*/
|
|
68
|
+
export const canEditCollectionMetadata = (
|
|
69
|
+
role: RestSchema.OrganizationRole,
|
|
70
|
+
isAuthor: boolean,
|
|
71
|
+
): boolean => collectionMetadataRoles.has(role) || (isAuthor && collectionContentRoles.has(role));
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* canDeleteCollection reports whether the caller may delete a collection.
|
|
75
|
+
*
|
|
76
|
+
* Deleting carries the same gate as editing the metadata (the platform runs one authorization
|
|
77
|
+
* for both), so this names the rule at the call site without inviting the two to drift. It
|
|
78
|
+
* takes what {@link canEditCollectionMetadata} takes.
|
|
79
|
+
*/
|
|
80
|
+
export const canDeleteCollection = canEditCollectionMetadata;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* collectionFormSchema is the create/edit collection form's validation contract: the package's
|
|
84
|
+
* display-name rule for the name ({@link displayNameSchema}), its description rule for the
|
|
85
|
+
* description ({@link descriptionSchema}), and a privacy flag. The collection tools validate
|
|
86
|
+
* the same name and description schemas, so an invalid form never reaches the bus.
|
|
87
|
+
*
|
|
88
|
+
* It is the one source of truth a form validates against, and it is here and not beside the
|
|
89
|
+
* form because a rule is not a rendering decision: a consumer wiring their own design system to
|
|
90
|
+
* `studio.collection.create` gets the same bounds without installing a component.
|
|
91
|
+
*/
|
|
92
|
+
export const collectionFormSchema = z.object({
|
|
93
|
+
description: descriptionSchema,
|
|
94
|
+
isPrivate: z.boolean(),
|
|
95
|
+
name: displayNameSchema,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* CollectionFormValues is the validated create/edit collection form payload, derived from
|
|
100
|
+
* {@link collectionFormSchema}. A form seeds, edits and submits this shape; the wrappers map it
|
|
101
|
+
* onto the create and update tool inputs.
|
|
102
|
+
*/
|
|
103
|
+
export type CollectionFormValues = z.infer<typeof collectionFormSchema>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* collectionCreateScope answers the `organizationId` a `studio.collection.create` carries for a
|
|
107
|
+
* collection filed in `organizationId`: undefined for the reader's own scope, and the id for an
|
|
108
|
+
* organization.
|
|
109
|
+
*
|
|
110
|
+
* The personal scope has one spelling on a create, the absent key, and the listing endpoints
|
|
111
|
+
* refuse a second. A resource's record may name that scope either way: `null`, or the id of an
|
|
112
|
+
* organization the host reads as the reader's own (a root organization). So every surface that
|
|
113
|
+
* creates a collection beside a resource folds the record's id through this rule, and the
|
|
114
|
+
* collection lands where the resource can be added to it.
|
|
115
|
+
*
|
|
116
|
+
* @param organizationId - The scope as the record or the surface names it.
|
|
117
|
+
* @param isPersonalScope - The host's predicate for the reader's own scope,
|
|
118
|
+
* `StudioScopeSeam.isPersonalScope`.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* import { collectionCreateScope } from "@mountaya/studio";
|
|
123
|
+
*
|
|
124
|
+
* declare const itinerary: { organization_id: string | null };
|
|
125
|
+
* declare const isPersonalScope: (organizationId: string | null | undefined) => boolean;
|
|
126
|
+
*
|
|
127
|
+
* const input = {
|
|
128
|
+
* isPrivate: true,
|
|
129
|
+
* name: "Alps",
|
|
130
|
+
* organizationId: collectionCreateScope(itinerary.organization_id, isPersonalScope),
|
|
131
|
+
* };
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export const collectionCreateScope = (
|
|
135
|
+
organizationId: string | null | undefined,
|
|
136
|
+
isPersonalScope: (organizationId: string | null | undefined) => boolean,
|
|
137
|
+
): string | undefined =>
|
|
138
|
+
isPersonalScope(organizationId) ? undefined : (organizationId ?? undefined);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Collection, OrganizationRole } from "../../rules/types.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* EntityCollection is one row of a collection membership picker: a collection's id and name,
|
|
5
|
+
* the caller's role in the organization that owns it, and whether the target entity is already
|
|
6
|
+
* in it.
|
|
7
|
+
*
|
|
8
|
+
* It is the shape both entity families' membership reads resolve to: the collections a reader
|
|
9
|
+
* can see, and the ones among them that hold the itinerary or the zone, folded by
|
|
10
|
+
* {@link projectEntityCollections} so one picker renders both families.
|
|
11
|
+
*/
|
|
12
|
+
export interface EntityCollection {
|
|
13
|
+
/** Whether the collection already holds the target entity. */
|
|
14
|
+
has: boolean;
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
/** The caller's role in the organization that owns the collection. */
|
|
18
|
+
role: OrganizationRole;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* projectEntityCollections folds the collections a reader can see onto the shared
|
|
23
|
+
* {@link EntityCollection} shape, each holding the target where `holding` lists it.
|
|
24
|
+
*
|
|
25
|
+
* The two are two listings: every collection the credential reaches, and the collections that
|
|
26
|
+
* hold one itinerary or one zone (`getCollections` filtered by `itinerary_id` or `zone_id`). A
|
|
27
|
+
* collection the second lists and the first does not is still a row, holding the target, so a
|
|
28
|
+
* picker never hides a membership it could remove.
|
|
29
|
+
*
|
|
30
|
+
* @param collections The collections the reader can see, in the order the picker shows them.
|
|
31
|
+
* @param holding The collections that hold the target.
|
|
32
|
+
* @returns One row per collection, each listed once.
|
|
33
|
+
*/
|
|
34
|
+
export const projectEntityCollections = (
|
|
35
|
+
collections: readonly Collection[],
|
|
36
|
+
holding: readonly Collection[],
|
|
37
|
+
): EntityCollection[] => {
|
|
38
|
+
const held = new Set(holding.map(({ id }) => id));
|
|
39
|
+
const rows = new Map<string, EntityCollection>();
|
|
40
|
+
|
|
41
|
+
for (const collection of [...collections, ...holding]) {
|
|
42
|
+
if (!rows.has(collection.id)) {
|
|
43
|
+
rows.set(collection.id, {
|
|
44
|
+
has: held.has(collection.id),
|
|
45
|
+
id: collection.id,
|
|
46
|
+
name: collection.name,
|
|
47
|
+
role: collection.role,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return [...rows.values()];
|
|
53
|
+
};
|