mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 15:17:30 +00:00
feat(tours): a city walk prepared from a briefing over MCP, and the station fields an assistant reads spelled out (CW-10, CW-11)
An assistant connected over MCP can now prepare a city walk from what the traveller tells it. propose_city_walk takes a start (and an end), a time frame on a day of the trip, the themes of CW-05, the stations the traveller wishes for, the places of the trip it may use and fixed appointments with their times, and saves nothing. Places for the themes come from the search along a tour, at most eight, each with the theme, category and source that brought it; nothing is made up. The stations are ordered on estimates over the straight distance, and a place of a theme or of the trip goes in only where it is open on arrival, keeps the frame and the appointments, and leaves every station already on the walk open when the walk gets there. The walk in that order is then planned on foot by the router the road trip uses (the traveller's own routing server where they set one), and its legs give the walking distance and time from one station to the next. Where the router cannot be reached, or a station lies more than 300 m off every way (the planner's limit, now shared with the server), the times are estimates over the straight distance with an allowance for streets at 4.5 km/h, and the answer says so and why. The answer gives the arrival and leave times, the stay where the traveller gave it and unknown otherwise, which makes every later arrival the earliest one, and the opening hours checked against the arrival on that day with the helpers the planner uses. Walking and stays are counted apart, the total is complete only when every stay is known, and the minutes the frame leaves for the unknown stays are named. Free time before an appointment or at the end, wishes and appointments that cannot be kept as asked, and places left out with their reason are listed; a tour of the trip offered as a station is named as a tour. A wish or an appointment is never dropped; an appointment is a must and protected. A place's default duration is not read as a stay: every place carries one, so it says nothing. Once the traveller confirms, create_city_walk saves the walk through the same creation the planner's save uses: one write, a key for every station, the links to the trip's places checked, the trip told, with place editing permission on the trip. Its way on foot is planned by the same router and saved with the walk, together with its distance and walking time. Where the router gives no way, the walk is saved with its stations only and the answer says why: no line, no distance and no walking time. The tours list says so (route_pending), the tour detail says in one line that the way is planned in the planner, and opening the walk in the planner plans its way at once and offers to save it, with a note once it is planned that it was just planned. Such a walk can be saved as a new tour and taken over into another trip, starting at its first stop, and is never offered as a place to stay. A tour without a line needs two points of its own. get_tour_plan now spells out every field of a city walk's stations: key, name, stay (null when not known), importance (null for normal), protection (false when not set) and opening hours (null when none are known); list_tours names the station count and whether a walk waits for its way, get_city_walk_progress gives each station's key and opening hours, and take_over_tour says a walk keeps its stations with their protection. No tool changes a walk's stations; deleting a walk's place takes its stations along, protected ones included, and both delete tools now ask the assistant to name those and ask the traveller first. REST answers the stations as before. A tour create refused for a type that is switched off, a description that is too long or planned times out of range is a domain refusal now, so an assistant gets the same text REST sends; REST still answers it as an error at 400.
This commit is contained in:
@@ -542,6 +542,8 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'المشي',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'كيف يُحسب وقت المشي',
|
||||
'tours.walk.timeEstimatedInfo': 'وقت المسار سيرًا بين المحطات، دون مدد البقاء.',
|
||||
'tours.walk.routePending': 'حُفظت الجولة بمحطاتها فقط. يُخطَّط الطريق بينها عند فتح الجولة في المخطِّط وحفظها.',
|
||||
'tours.walk.routePendingPlanner': 'حُفظت الجولة بمحطاتها فقط. خُطِّط الطريق بينها للتو؛ احفظ الجولة للاحتفاظ به.',
|
||||
'tours.walk.stays': 'مدد البقاء',
|
||||
'tours.walk.totalAtLeast': '{time} على الأقل',
|
||||
'tours.walk.totalComputed': 'محسوب',
|
||||
|
||||
@@ -535,6 +535,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Yürüş',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Yürüş vaxtı necə hesablanır',
|
||||
'tours.walk.timeEstimatedInfo': 'Dayanacaqlar arasında marşrutlaşdırıcının piyada vaxtı, qalma müddətləri olmadan.',
|
||||
'tours.walk.routePending':
|
||||
'Yalnız dayanacaqları ilə yadda saxlanılıb. Aralarındakı yol gəzinti planlayıcıda açılıb yadda saxlananda planlaşdırılır.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Yalnız dayanacaqları ilə yadda saxlanılıb. Aralarındakı yol indicə planlaşdırıldı; onu saxlamaq üçün gəzintini yadda saxla.',
|
||||
'tours.walk.stays': 'Qalmalar',
|
||||
'tours.walk.totalAtLeast': 'ən azı {time}',
|
||||
'tours.walk.totalComputed': 'Hesablanmış',
|
||||
|
||||
@@ -542,6 +542,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Caminhada',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Como o tempo de caminhada é calculado',
|
||||
'tours.walk.timeEstimatedInfo': 'O tempo a pé do roteador entre as paradas, sem as permanências.',
|
||||
'tours.walk.routePending':
|
||||
'Salvo só com as paradas. O caminho entre elas é traçado quando o passeio é aberto no planejador e salvo.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Salvo só com as paradas. O caminho entre elas acabou de ser traçado; salve o passeio para mantê-lo.',
|
||||
'tours.walk.stays': 'Permanências',
|
||||
'tours.walk.totalAtLeast': 'pelo menos {time}',
|
||||
'tours.walk.totalComputed': 'Calculado',
|
||||
|
||||
@@ -543,6 +543,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'A peu',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Com es calcula el temps a peu',
|
||||
'tours.walk.timeEstimatedInfo': 'El temps a peu del càlcul de ruta entre parades, sense les estades.',
|
||||
'tours.walk.routePending':
|
||||
"Desada només amb les parades. El camí entre elles es traça quan la ruta s'obre al planificador i es desa.",
|
||||
'tours.walk.routePendingPlanner':
|
||||
"Desada només amb les parades. El camí entre elles s'acaba de traçar; desa la ruta per conservar-lo.",
|
||||
'tours.walk.stays': 'Estades',
|
||||
'tours.walk.totalAtLeast': 'com a mínim {time}',
|
||||
'tours.walk.totalComputed': 'Calculat',
|
||||
|
||||
@@ -532,6 +532,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Chůze',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Jak se počítá doba chůze',
|
||||
'tours.walk.timeEstimatedInfo': 'Doba chůze mezi zastávkami podle plánovače trasy, bez pobytů.',
|
||||
'tours.walk.routePending':
|
||||
'Uloženo jen se zastávkami. Cesta mezi nimi se naplánuje, až se procházka otevře v plánovači a uloží.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Uloženo jen se zastávkami. Cesta mezi nimi se právě naplánovala; ulož procházku, aby zůstala.',
|
||||
'tours.walk.stays': 'Pobyty',
|
||||
'tours.walk.totalAtLeast': 'nejméně {time}',
|
||||
'tours.walk.totalComputed': 'Vypočteno',
|
||||
|
||||
@@ -546,6 +546,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Gehzeit',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Wie die Gehzeit entsteht',
|
||||
'tours.walk.timeEstimatedInfo': 'Die Zeit des Routers zu Fuß zwischen den Stationen, ohne die Aufenthalte.',
|
||||
'tours.walk.routePending':
|
||||
'Nur mit seinen Stationen gespeichert. Der Weg dazwischen wird geplant, sobald der Walk im Planer geöffnet und gespeichert wird.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Nur mit seinen Stationen gespeichert. Der Weg dazwischen wurde eben geplant; speichere den Walk, um ihn zu behalten.',
|
||||
'tours.walk.stays': 'Aufenthalte',
|
||||
'tours.walk.totalAtLeast': 'mindestens {time}',
|
||||
'tours.walk.totalComputed': 'Berechnet',
|
||||
|
||||
@@ -533,6 +533,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Walking',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'How the walking time is worked out',
|
||||
'tours.walk.timeEstimatedInfo': "The router's time on foot between the stops, without the stays.",
|
||||
'tours.walk.routePending':
|
||||
'Saved with its stops only. The way between them is planned when the walk is opened in the planner and saved.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Saved with its stops only. The way between them was planned just now; save the walk to keep it.',
|
||||
'tours.walk.stays': 'Stays',
|
||||
'tours.walk.totalAtLeast': 'at least {time}',
|
||||
'tours.walk.totalComputed': 'Computed',
|
||||
|
||||
@@ -541,6 +541,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'A pie',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Cómo se calcula el tiempo a pie',
|
||||
'tours.walk.timeEstimatedInfo': 'El tiempo a pie del planificador entre paradas, sin las estancias.',
|
||||
'tours.walk.routePending':
|
||||
'Guardado solo con sus paradas. El camino entre ellas se traza al abrir el paseo en el planificador y guardarlo.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Guardado solo con sus paradas. El camino entre ellas se acaba de trazar; guarda el paseo para conservarlo.',
|
||||
'tours.walk.stays': 'Estancias',
|
||||
'tours.walk.totalAtLeast': 'al menos {time}',
|
||||
'tours.walk.totalComputed': 'Calculado',
|
||||
|
||||
@@ -534,6 +534,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Kõnd',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Kuidas kõndimisaeg arvutatakse',
|
||||
'tours.walk.timeEstimatedInfo': 'Marsruutija kõndimisaeg peatuste vahel, ilma peatumisteta.',
|
||||
'tours.walk.routePending':
|
||||
'Salvestatud ainult peatustega. Tee nende vahel planeeritakse, kui jalutus planeerijas avatakse ja salvestatakse.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Salvestatud ainult peatustega. Tee nende vahel planeeriti just praegu; salvesta jalutus, et see alles jääks.',
|
||||
'tours.walk.stays': 'Peatumised',
|
||||
'tours.walk.totalAtLeast': 'vähemalt {time}',
|
||||
'tours.walk.totalComputed': 'Arvutatud',
|
||||
|
||||
@@ -550,6 +550,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Marche',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Comment le temps de marche est calculé',
|
||||
'tours.walk.timeEstimatedInfo': "Le temps à pied du calcul d'itinéraire entre les étapes, sans les arrêts.",
|
||||
'tours.walk.routePending':
|
||||
'Enregistrée avec ses étapes seulement. Le chemin entre elles est tracé quand la balade est ouverte dans le planificateur et enregistrée.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
"Enregistrée avec ses étapes seulement. Le chemin entre elles vient d'être tracé ; enregistre la balade pour le garder.",
|
||||
'tours.walk.stays': 'Arrêts',
|
||||
'tours.walk.totalAtLeast': 'au moins {time}',
|
||||
'tours.walk.totalComputed': 'Calculé',
|
||||
|
||||
@@ -552,6 +552,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Περπάτημα',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Πώς υπολογίζεται ο χρόνος περπατήματος',
|
||||
'tours.walk.timeEstimatedInfo': 'Ο χρόνος με τα πόδια του δρομολογητή ανάμεσα στις στάσεις, χωρίς τις παραμονές.',
|
||||
'tours.walk.routePending':
|
||||
'Αποθηκεύτηκε μόνο με τις στάσεις της. Η διαδρομή ανάμεσά τους σχεδιάζεται όταν η βόλτα ανοίξει στον σχεδιαστή και αποθηκευτεί.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Αποθηκεύτηκε μόνο με τις στάσεις της. Η διαδρομή ανάμεσά τους μόλις σχεδιάστηκε· αποθήκευσε τη βόλτα για να την κρατήσεις.',
|
||||
'tours.walk.stays': 'Παραμονές',
|
||||
'tours.walk.totalAtLeast': 'τουλάχιστον {time}',
|
||||
'tours.walk.totalComputed': 'Υπολογισμένο',
|
||||
|
||||
@@ -542,6 +542,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Gyaloglás',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Hogyan számoljuk a gyaloglási időt',
|
||||
'tours.walk.timeEstimatedInfo': 'Az útvonaltervező gyalogos ideje a megállók között, a tartózkodások nélkül.',
|
||||
'tours.walk.routePending':
|
||||
'Csak a megállóival mentve. A köztük lévő utat a TREK akkor tervezi meg, amikor a sétát megnyitják a tervezőben és mentik.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Csak a megállóival mentve. A köztük lévő utat épp most tervezte meg a TREK; mentsd a sétát, hogy megmaradjon.',
|
||||
'tours.walk.stays': 'Tartózkodások',
|
||||
'tours.walk.totalAtLeast': 'legalább {time}',
|
||||
'tours.walk.totalComputed': 'Számított',
|
||||
|
||||
@@ -536,6 +536,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Berjalan',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Cara waktu jalan dihitung',
|
||||
'tours.walk.timeEstimatedInfo': 'Waktu jalan kaki dari perute di antara titik singgah, tanpa lama singgah.',
|
||||
'tours.walk.routePending':
|
||||
'Disimpan hanya dengan titik singgahnya. Jalan di antaranya direncanakan saat rute dibuka di perencana lalu disimpan.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Disimpan hanya dengan titik singgahnya. Jalan di antaranya baru saja direncanakan; simpan rute ini untuk mempertahankannya.',
|
||||
'tours.walk.stays': 'Lama singgah',
|
||||
'tours.walk.totalAtLeast': 'setidaknya {time}',
|
||||
'tours.walk.totalComputed': 'Dihitung',
|
||||
|
||||
@@ -543,6 +543,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'A piedi',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Come si calcola il tempo a piedi',
|
||||
'tours.walk.timeEstimatedInfo': 'Il tempo a piedi del calcolo percorso tra le tappe, senza le soste.',
|
||||
'tours.walk.routePending':
|
||||
'Salvato solo con le tappe. Il cammino tra di esse viene tracciato quando il percorso viene aperto nel pianificatore e salvato.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Salvato solo con le tappe. Il cammino tra di esse è stato appena tracciato; salva il percorso per tenerlo.',
|
||||
'tours.walk.stays': 'Soste',
|
||||
'tours.walk.totalAtLeast': 'almeno {time}',
|
||||
'tours.walk.totalComputed': 'Calcolato',
|
||||
|
||||
@@ -524,6 +524,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': '歩行',
|
||||
'tours.walk.timeEstimatedInfoLabel': '歩行時間の求め方',
|
||||
'tours.walk.timeEstimatedInfo': 'ルート計算による立ち寄り先間の徒歩時間。滞在時間は含みません。',
|
||||
'tours.walk.routePending':
|
||||
'立ち寄り先だけで保存されています。間の道は、街歩きをプランナーで開いて保存すると計画されます。',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'立ち寄り先だけで保存されていました。間の道をいま計画しました。残すには街歩きを保存してください。',
|
||||
'tours.walk.stays': '滞在',
|
||||
'tours.walk.totalAtLeast': '{time} 以上',
|
||||
'tours.walk.totalComputed': '計算値',
|
||||
|
||||
@@ -521,6 +521,9 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': '도보',
|
||||
'tours.walk.timeEstimatedInfoLabel': '도보 시간 계산 방법',
|
||||
'tours.walk.timeEstimatedInfo': '경로 계산기가 낸 정류지 사이 도보 시간이며, 머무는 시간은 빠져 있습니다.',
|
||||
'tours.walk.routePending': '정류지만 저장되어 있습니다. 그 사이의 길은 산책을 플래너에서 열고 저장하면 계획됩니다.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'정류지만 저장되어 있었습니다. 그 사이의 길을 방금 계획했습니다. 유지하려면 산책을 저장하세요.',
|
||||
'tours.walk.stays': '머무는 시간',
|
||||
'tours.walk.totalAtLeast': '최소 {time}',
|
||||
'tours.walk.totalComputed': '계산값',
|
||||
|
||||
@@ -544,6 +544,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Lopen',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Hoe de looptijd wordt berekend',
|
||||
'tours.walk.timeEstimatedInfo': 'De looptijd van de routeplanner tussen de haltes, zonder het verblijf.',
|
||||
'tours.walk.routePending':
|
||||
'Alleen met de haltes opgeslagen. De weg ertussen wordt gepland zodra de wandeling in de planner wordt geopend en opgeslagen.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Alleen met de haltes opgeslagen. De weg ertussen is net gepland; sla de wandeling op om hem te bewaren.',
|
||||
'tours.walk.stays': 'Verblijven',
|
||||
'tours.walk.totalAtLeast': 'minstens {time}',
|
||||
'tours.walk.totalComputed': 'Berekend',
|
||||
|
||||
@@ -551,6 +551,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Marsz',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Jak liczony jest czas marszu',
|
||||
'tours.walk.timeEstimatedInfo': 'Czas marszu między przystankami według planera trasy, bez postojów.',
|
||||
'tours.walk.routePending':
|
||||
'Zapisano tylko z przystankami. Droga między nimi zostanie wyznaczona, gdy trasa zostanie otwarta w planerze i zapisana.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Zapisano tylko z przystankami. Droga między nimi została właśnie wyznaczona; zapisz trasę, aby ją zachować.',
|
||||
'tours.walk.stays': 'Postoje',
|
||||
'tours.walk.totalAtLeast': 'co najmniej {time}',
|
||||
'tours.walk.totalComputed': 'Obliczono',
|
||||
|
||||
@@ -553,6 +553,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Пешком',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Как считается время в пути',
|
||||
'tours.walk.timeEstimatedInfo': 'Время пешком между остановками по расчёту маршрута, без остановок на месте.',
|
||||
'tours.walk.routePending':
|
||||
'Сохранена только с остановками. Путь между ними прокладывается, когда прогулку открывают в планировщике и сохраняют.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Сохранена только с остановками. Путь между ними только что проложен; сохрани прогулку, чтобы его оставить.',
|
||||
'tours.walk.stays': 'Остановки',
|
||||
'tours.walk.totalAtLeast': 'не меньше {time}',
|
||||
'tours.walk.totalComputed': 'Расчёт',
|
||||
|
||||
@@ -534,6 +534,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Chôdza',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Ako sa počíta čas chôdze',
|
||||
'tours.walk.timeEstimatedInfo': 'Čas chôdze medzi zastávkami podľa plánovača trasy, bez pobytov.',
|
||||
'tours.walk.routePending':
|
||||
'Uložené len so zastávkami. Cesta medzi nimi sa naplánuje, keď sa prechádzka otvorí v plánovači a uloží.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Uložené len so zastávkami. Cesta medzi nimi sa práve naplánovala; ulož prechádzku, aby zostala.',
|
||||
'tours.walk.stays': 'Pobyty',
|
||||
'tours.walk.totalAtLeast': 'najmenej {time}',
|
||||
'tours.walk.totalComputed': 'Vypočítané',
|
||||
|
||||
@@ -533,6 +533,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Gång',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Hur gångtiden räknas fram',
|
||||
'tours.walk.timeEstimatedInfo': 'Ruttplanerarens gångtid mellan stoppen, utan vistelserna.',
|
||||
'tours.walk.routePending':
|
||||
'Sparad med bara sina stopp. Vägen mellan dem planeras när promenaden öppnas i planeraren och sparas.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Sparad med bara sina stopp. Vägen mellan dem har just planerats; spara promenaden för att behålla den.',
|
||||
'tours.walk.stays': 'Vistelser',
|
||||
'tours.walk.totalAtLeast': 'minst {time}',
|
||||
'tours.walk.totalComputed': 'Beräknad',
|
||||
|
||||
@@ -512,6 +512,8 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'เดิน',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'วิธีคำนวณเวลาเดิน',
|
||||
'tours.walk.timeEstimatedInfo': 'เวลาเดินระหว่างจุดแวะจากตัวคำนวณเส้นทาง ไม่รวมเวลาแวะพัก',
|
||||
'tours.walk.routePending': 'บันทึกไว้เพียงจุดแวะ ทางระหว่างจุดแวะจะถูกวางแผนเมื่อเปิดทริปในตัววางแผนและบันทึก',
|
||||
'tours.walk.routePendingPlanner': 'บันทึกไว้เพียงจุดแวะ ทางระหว่างจุดแวะเพิ่งถูกวางแผน บันทึกทริปเพื่อเก็บไว้',
|
||||
'tours.walk.stays': 'เวลาแวะพัก',
|
||||
'tours.walk.totalAtLeast': 'อย่างน้อย {time}',
|
||||
'tours.walk.totalComputed': 'ค่าคำนวณ',
|
||||
|
||||
@@ -20,7 +20,7 @@ const tokens = (value: string) => [...value.matchAll(/\{[^{}]+\}/g)].map((match)
|
||||
// placeholder spec; here only the general keys are.
|
||||
const groups = pluralGroups(Object.keys(english));
|
||||
const generalKeys = (keys: string[]) => keys.filter((key) => !pluralFormOf(key, groups));
|
||||
const GENERAL_KEY_COUNT = 825;
|
||||
const GENERAL_KEY_COUNT = 827;
|
||||
|
||||
function literalKeys(source: string): string[] {
|
||||
const tree = ts.createSourceFile('locale.ts', source, ts.ScriptTarget.Latest, true);
|
||||
|
||||
@@ -536,6 +536,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Yürüme',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Yürüme süresi nasıl hesaplanır',
|
||||
'tours.walk.timeEstimatedInfo': 'Rota hesaplayıcının duraklar arasındaki yürüme süresi, kalışlar hariç.',
|
||||
'tours.walk.routePending':
|
||||
'Yalnızca duraklarıyla kaydedildi. Aralarındaki yol, yürüyüş planlayıcıda açılıp kaydedildiğinde planlanır.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Yalnızca duraklarıyla kaydedildi. Aralarındaki yol az önce planlandı; korumak için yürüyüşü kaydet.',
|
||||
'tours.walk.stays': 'Kalışlar',
|
||||
'tours.walk.totalAtLeast': 'en az {time}',
|
||||
'tours.walk.totalComputed': 'Hesaplanan',
|
||||
|
||||
@@ -549,6 +549,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Ходьба',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Як рахується час ходьби',
|
||||
'tours.walk.timeEstimatedInfo': 'Час пішки між зупинками за розрахунком маршруту, без перебування.',
|
||||
'tours.walk.routePending':
|
||||
'Збережено лише із зупинками. Дорогу між ними прокладають, коли прогулянку відкривають у планувальнику й зберігають.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Збережено лише із зупинками. Дорогу між ними щойно прокладено; збережи прогулянку, щоб її залишити.',
|
||||
'tours.walk.stays': 'Перебування',
|
||||
'tours.walk.totalAtLeast': 'щонайменше {time}',
|
||||
'tours.walk.totalComputed': 'Розрахунок',
|
||||
|
||||
@@ -532,6 +532,10 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': 'Đi bộ',
|
||||
'tours.walk.timeEstimatedInfoLabel': 'Cách tính thời gian đi bộ',
|
||||
'tours.walk.timeEstimatedInfo': 'Thời gian đi bộ giữa các điểm dừng do bộ định tuyến tính, không gồm thời gian dừng.',
|
||||
'tours.walk.routePending':
|
||||
'Chỉ được lưu cùng các điểm dừng. Đường đi giữa chúng sẽ được lên khi lộ trình được mở trong trình lập kế hoạch và lưu lại.',
|
||||
'tours.walk.routePendingPlanner':
|
||||
'Chỉ được lưu cùng các điểm dừng. Đường đi giữa chúng vừa được lên; hãy lưu lộ trình để giữ lại.',
|
||||
'tours.walk.stays': 'Thời gian dừng',
|
||||
'tours.walk.totalAtLeast': 'ít nhất {time}',
|
||||
'tours.walk.totalComputed': 'Đã tính',
|
||||
|
||||
@@ -492,6 +492,8 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': '步行',
|
||||
'tours.walk.timeEstimatedInfoLabel': '步行時間如何計算',
|
||||
'tours.walk.timeEstimatedInfo': '路線規劃給出的站點間步行時間,不含停留時間。',
|
||||
'tours.walk.routePending': '僅儲存了站點。站點之間的道路會在規劃器中開啟並儲存漫步時規劃。',
|
||||
'tours.walk.routePendingPlanner': '先前僅儲存了站點。站點之間的道路剛剛規劃好;儲存漫步即可保留。',
|
||||
'tours.walk.stays': '停留',
|
||||
'tours.walk.totalAtLeast': '至少 {time}',
|
||||
'tours.walk.totalComputed': '計算值',
|
||||
|
||||
@@ -493,6 +493,8 @@ const tours: TranslationStrings = {
|
||||
'tours.walk.timeEstimatedShort': '步行',
|
||||
'tours.walk.timeEstimatedInfoLabel': '步行时间如何计算',
|
||||
'tours.walk.timeEstimatedInfo': '路线规划给出的站点间步行时间,不含停留时间。',
|
||||
'tours.walk.routePending': '仅保存了站点。站点之间的道路会在规划器中打开并保存漫步时规划。',
|
||||
'tours.walk.routePendingPlanner': '此前仅保存了站点。站点之间的道路刚刚规划好;保存漫步即可保留。',
|
||||
'tours.walk.stays': '停留',
|
||||
'tours.walk.totalAtLeast': '至少 {time}',
|
||||
'tours.walk.totalComputed': '计算值',
|
||||
|
||||
@@ -61,6 +61,7 @@ export * from './tours/tour-poi-search.schema';
|
||||
export * from './tours/tour-trail-grade.schema';
|
||||
export * from './tours/tour-walk.schema';
|
||||
export * from './tours/tour-walk';
|
||||
export * from './tours/tour-walk-briefing.schema';
|
||||
export * from './tours/walk-hours';
|
||||
export * from './tours/tours.metrics';
|
||||
export * from './tours/tour-gpx-import.schema';
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { hasPlaceHours, parsePlaceHours, placeEmailField, placeOpeningHoursField } from './place-hours';
|
||||
import {
|
||||
clockTimeSchema,
|
||||
hasPlaceHours,
|
||||
parsePlaceHours,
|
||||
placeEmailField,
|
||||
placeOpeningHoursField,
|
||||
} from './place-hours';
|
||||
import { placeCreateRequestSchema, placeUpdateRequestSchema } from './place.schema';
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
@@ -36,4 +42,15 @@ describe('place hours and e-mail (#2472)', () => {
|
||||
expect(placeCreateRequestSchema.safeParse({ name: 'X', email: 'nope' }).success).toBe(false);
|
||||
expect(placeUpdateRequestSchema.safeParse({ opening_hours: WEEK, email: null }).success).toBe(true);
|
||||
});
|
||||
|
||||
it('reads a time of day on the 24-hour clock, HH:MM, and nothing else', () => {
|
||||
expect(['00:00', '09:30', '23:59'].map((time) => clockTimeSchema.safeParse(time).success)).toEqual([
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
]);
|
||||
expect(
|
||||
['9:30', '24:00', '12:60', '09:30:00', 'noon'].map((time) => clockTimeSchema.safeParse(time).success),
|
||||
).toEqual([false, false, false, false, false]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,12 +11,13 @@ import { z } from 'zod';
|
||||
*/
|
||||
export const PLACE_HOURS_DAYS = 7;
|
||||
|
||||
const TIME = /^([01]\d|2[0-3]):[0-5]\d$/;
|
||||
/** A time of day on the 24-hour clock, `HH:MM`. */
|
||||
export const clockTimeSchema = z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/);
|
||||
|
||||
export const placeHoursDaySchema = z.object({
|
||||
closed: z.boolean(),
|
||||
open: z.string().regex(TIME).optional(),
|
||||
close: z.string().regex(TIME).optional(),
|
||||
open: clockTimeSchema.optional(),
|
||||
close: clockTimeSchema.optional(),
|
||||
});
|
||||
export type PlaceHoursDay = z.infer<typeof placeHoursDaySchema>;
|
||||
|
||||
|
||||
@@ -44,14 +44,15 @@ export const TOUR_POI_CATEGORIES_BY_TYPE: Record<PlannableTourType, readonly Tou
|
||||
* walk's own categories. A suggestion says which theme and category brought
|
||||
* it; nothing is claimed beyond what the source tags say.
|
||||
*/
|
||||
export const WALK_THEME_KEYS = ['culture', 'parks', 'food', 'mixed'] as const;
|
||||
export const walkThemeSchema = z.enum(WALK_THEME_KEYS);
|
||||
export type WalkTheme = z.infer<typeof walkThemeSchema>;
|
||||
export const WALK_THEMES = {
|
||||
culture: ['museum', 'sights'],
|
||||
parks: ['park', 'viewpoint'],
|
||||
food: ['cafe', 'restaurant', 'market'],
|
||||
mixed: ['sights', 'museum', 'park', 'viewpoint', 'cafe', 'market'],
|
||||
} as const satisfies Record<string, readonly TourPoiCategory[]>;
|
||||
export type WalkTheme = keyof typeof WALK_THEMES;
|
||||
export const WALK_THEME_KEYS = Object.keys(WALK_THEMES) as WalkTheme[];
|
||||
} as const satisfies Record<WalkTheme, readonly TourPoiCategory[]>;
|
||||
|
||||
/** How far from the line a place may lie, the choices offered, in metres. */
|
||||
export const TOUR_POI_CORRIDORS_M = [250, 500, 1000, 2000] as const;
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
import { walkThemeSchema, WALK_THEME_KEYS, WALK_THEMES } from './tour-poi-search.schema';
|
||||
import {
|
||||
CITY_WALK_BRIEFING_LIMITS,
|
||||
CITY_WALK_MAX_STATIONS,
|
||||
cityWalkBriefingRequestSchema,
|
||||
cityWalkCreateRequestSchema,
|
||||
} from './tour-walk-briefing.schema';
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const briefing = {
|
||||
start: { lat: 48.1, lng: 11.5 },
|
||||
start_time: '10:00',
|
||||
end_time: '13:00',
|
||||
};
|
||||
|
||||
const spot = (index: number) => ({ name: `Stop ${index}`, lat: 48.1, lng: 11.5 });
|
||||
|
||||
describe('a city walk prepared from a briefing (CW-11)', () => {
|
||||
it('takes the four themes of a city walk, by their keys', () => {
|
||||
expect(walkThemeSchema.options).toEqual([...WALK_THEME_KEYS]);
|
||||
expect(Object.keys(WALK_THEMES)).toEqual([...WALK_THEME_KEYS]);
|
||||
expect(walkThemeSchema.safeParse('nightlife').success).toBe(false);
|
||||
});
|
||||
|
||||
it('reads a start, a frame and nothing else as a briefing, and every part the traveller can add', () => {
|
||||
expect(cityWalkBriefingRequestSchema.safeParse(briefing).success).toBe(true);
|
||||
const full = {
|
||||
...briefing,
|
||||
start: { name: 'Hotel', lat: 48.1, lng: 11.5 },
|
||||
end: { lat: 48.12, lng: 11.52 },
|
||||
day_id: 3,
|
||||
themes: ['culture', 'food'],
|
||||
wished: [{ ...spot(1), stay_minutes: 30, opening_hours: 'Mo-Su 09:00-18:00' }],
|
||||
trip_places: [{ place_id: 4, stay_minutes: null }],
|
||||
appointments: [{ ...spot(2), time: '11:30', stay_minutes: 60, place_id: 5 }],
|
||||
theme_places_max: 0,
|
||||
corridor_m: 500,
|
||||
lang: 'de',
|
||||
};
|
||||
expect(cityWalkBriefingRequestSchema.parse(full)).toEqual(full);
|
||||
});
|
||||
|
||||
it('refuses a time that is no time of day, a field it does not know and more than its limits', () => {
|
||||
const refused = [
|
||||
{ ...briefing, start_time: '9:00' },
|
||||
{ ...briefing, end_time: '24:00' },
|
||||
{ ...briefing, appointments: [{ ...spot(1), time: 'noon' }] },
|
||||
{ ...briefing, start: { ...briefing.start, address: 'Main square' } },
|
||||
{ ...briefing, route: [] },
|
||||
{ ...briefing, themes: [] },
|
||||
{ ...briefing, themes: ['culture', 'parks', 'food', 'mixed'] },
|
||||
{ ...briefing, wished: Array.from({ length: CITY_WALK_BRIEFING_LIMITS.wished + 1 }, (_, i) => spot(i)) },
|
||||
{
|
||||
...briefing,
|
||||
trip_places: Array.from({ length: CITY_WALK_BRIEFING_LIMITS.tripPlaces + 1 }, (_, i) => ({ place_id: i + 1 })),
|
||||
},
|
||||
{
|
||||
...briefing,
|
||||
appointments: Array.from({ length: CITY_WALK_BRIEFING_LIMITS.appointments + 1 }, (_, i) => ({
|
||||
...spot(i),
|
||||
time: '11:00',
|
||||
})),
|
||||
},
|
||||
{ ...briefing, theme_places_max: CITY_WALK_BRIEFING_LIMITS.themePlaces + 1 },
|
||||
{ ...briefing, corridor_m: 5000 },
|
||||
];
|
||||
expect(refused.map((body) => cityWalkBriefingRequestSchema.safeParse(body).success)).toEqual(
|
||||
refused.map(() => false),
|
||||
);
|
||||
});
|
||||
|
||||
it('creates a walk with room for every station a proposal can hold', () => {
|
||||
const { wished, tripPlaces, appointments, themePlaces } = CITY_WALK_BRIEFING_LIMITS;
|
||||
// The start and the end besides.
|
||||
expect(wished + tripPlaces + appointments + themePlaces + 2).toBeLessThanOrEqual(CITY_WALK_MAX_STATIONS);
|
||||
});
|
||||
|
||||
it('creates from two stations up, each with its own fields and no key, which the server gives', () => {
|
||||
const station = { lat: 48.1, lng: 11.5, name: 'Gate', stay_minutes: 15, importance: 'must', protected: true };
|
||||
expect(cityWalkCreateRequestSchema.safeParse({ name: ' Old town ', stations: [station, station] })).toMatchObject({
|
||||
success: true,
|
||||
data: { name: 'Old town' },
|
||||
});
|
||||
const refused = [
|
||||
{ name: 'Old town', stations: [station] },
|
||||
{ name: '', stations: [station, station] },
|
||||
{ name: 'Old town', stations: [{ ...station, key: 'stop-gate' }, station] },
|
||||
{ name: 'Old town', stations: [{ ...station, role: 'start' }, station] },
|
||||
{ name: 'Old town', stations: Array.from({ length: CITY_WALK_MAX_STATIONS + 1 }, () => station) },
|
||||
{ name: 'Old town', stations: [station, station], route_geometry: [] },
|
||||
];
|
||||
expect(refused.map((body) => cityWalkCreateRequestSchema.safeParse(body).success)).toEqual(
|
||||
refused.map(() => false),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,132 @@
|
||||
import { idSchema } from '../common/primitives.schema';
|
||||
import { clockTimeSchema } from '../place/place-hours';
|
||||
import { tourPoiSearchRequestSchema, walkThemeSchema } from './tour-poi-search.schema';
|
||||
import { TOUR_STATION_NAME_MAX, tourDescriptionSchema, tourNameSchema, tourWaypointSchema } from './tours.schema';
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
/**
|
||||
* CW-11: a city walk an assistant prepares from a traveller's briefing. The
|
||||
* proposal reads only; the walk is created once the traveller confirmed it,
|
||||
* through the same creation the planner's save uses. Nothing here carries a
|
||||
* route: the server plans the way on foot through the stations, for the
|
||||
* proposal and again for the creation.
|
||||
*/
|
||||
|
||||
/** How much one briefing may name, and how many places of its themes a proposal offers at most. */
|
||||
export const CITY_WALK_BRIEFING_LIMITS = {
|
||||
wished: 10,
|
||||
tripPlaces: 12,
|
||||
appointments: 5,
|
||||
themes: 3,
|
||||
themePlaces: 8,
|
||||
} as const;
|
||||
|
||||
/** The most stations a city walk created from a briefing has: everything a proposal can hold, start and end included. */
|
||||
export const CITY_WALK_MAX_STATIONS = 40;
|
||||
|
||||
const stationName = z.string().trim().min(1).max(TOUR_STATION_NAME_MAX);
|
||||
const { lat, lng, stay_minutes, opening_hours } = tourWaypointSchema.shape;
|
||||
|
||||
const walkEndSchema = z.object({ name: stationName.optional(), lat, lng }).strict();
|
||||
|
||||
const wishedStationSchema = z
|
||||
.object({
|
||||
name: stationName,
|
||||
lat,
|
||||
lng,
|
||||
stay_minutes: stay_minutes.describe(
|
||||
'How long the traveller wants to stay, in minutes; left out when they did not say',
|
||||
),
|
||||
opening_hours: opening_hours.describe('Its opening hours as OpenStreetMap writes them, where known'),
|
||||
})
|
||||
.strict();
|
||||
|
||||
const tripPlaceChoiceSchema = z
|
||||
.object({
|
||||
place_id: idSchema.describe('A place of this trip, as list_places gives it'),
|
||||
stay_minutes: stay_minutes.describe(
|
||||
'How long the traveller wants to stay there, in minutes; left out when they did not say',
|
||||
),
|
||||
})
|
||||
.strict();
|
||||
|
||||
const appointmentSchema = z
|
||||
.object({
|
||||
name: stationName,
|
||||
lat,
|
||||
lng,
|
||||
time: clockTimeSchema.describe('When the traveller has to be there, HH:MM'),
|
||||
stay_minutes: stay_minutes.describe('How long it takes, in minutes; left out when they did not say'),
|
||||
place_id: idSchema.optional().describe('The place of this trip it is at, if it is one'),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export const cityWalkBriefingRequestSchema = z
|
||||
.object({
|
||||
start: walkEndSchema.describe('Where the walk starts'),
|
||||
end: walkEndSchema.optional().describe('Where it has to end; left out, it ends at its last station'),
|
||||
day_id: idSchema
|
||||
.optional()
|
||||
.describe('The day of the trip it is for, as get_trip_summary gives it: its date decides the opening hours'),
|
||||
start_time: clockTimeSchema.describe('When it starts, HH:MM'),
|
||||
end_time: clockTimeSchema.describe('When it has to be over, HH:MM, later the same day'),
|
||||
themes: z
|
||||
.array(walkThemeSchema)
|
||||
.min(1)
|
||||
.max(CITY_WALK_BRIEFING_LIMITS.themes)
|
||||
.optional()
|
||||
.describe('What the traveller is interested in: culture, parks, food or mixed; mixed when left out'),
|
||||
wished: z
|
||||
.array(wishedStationSchema)
|
||||
.max(CITY_WALK_BRIEFING_LIMITS.wished)
|
||||
.optional()
|
||||
.describe('The stations the traveller asked for by name and position'),
|
||||
trip_places: z
|
||||
.array(tripPlaceChoiceSchema)
|
||||
.max(CITY_WALK_BRIEFING_LIMITS.tripPlaces)
|
||||
.optional()
|
||||
.describe('The places of this trip the walk may use; none when left out'),
|
||||
appointments: z
|
||||
.array(appointmentSchema)
|
||||
.max(CITY_WALK_BRIEFING_LIMITS.appointments)
|
||||
.optional()
|
||||
.describe('Fixed appointments the traveller told you, with their time'),
|
||||
theme_places_max: z
|
||||
.number()
|
||||
.int()
|
||||
.min(0)
|
||||
.max(CITY_WALK_BRIEFING_LIMITS.themePlaces)
|
||||
.optional()
|
||||
.describe('How many places of the themes to offer at most; 0 searches none'),
|
||||
corridor_m: tourPoiSearchRequestSchema.shape.corridor_m
|
||||
.optional()
|
||||
.describe('How far from the start, the wishes and the appointments to search, in metres; 1000 when left out'),
|
||||
lang: tourPoiSearchRequestSchema.shape.lang,
|
||||
})
|
||||
.strict();
|
||||
export type CityWalkBriefingRequest = z.infer<typeof cityWalkBriefingRequestSchema>;
|
||||
|
||||
/** One station of a city walk created from a briefing, in its order: no key, the server gives each one. */
|
||||
export const cityWalkStationSchema = tourWaypointSchema
|
||||
.pick({
|
||||
lat: true,
|
||||
lng: true,
|
||||
name: true,
|
||||
stay_minutes: true,
|
||||
importance: true,
|
||||
protected: true,
|
||||
opening_hours: true,
|
||||
linked_place_id: true,
|
||||
})
|
||||
.strict();
|
||||
export type CityWalkStation = z.infer<typeof cityWalkStationSchema>;
|
||||
|
||||
export const cityWalkCreateRequestSchema = z
|
||||
.object({
|
||||
name: tourNameSchema,
|
||||
description: tourDescriptionSchema,
|
||||
stations: z.array(cityWalkStationSchema).min(2).max(CITY_WALK_MAX_STATIONS),
|
||||
})
|
||||
.strict();
|
||||
export type CityWalkCreateRequest = z.infer<typeof cityWalkCreateRequestSchema>;
|
||||
@@ -9,9 +9,12 @@ import {
|
||||
recommendedPaddleSpeedKmh,
|
||||
plannedTourDurationMinutesSchema,
|
||||
stationKeySchema,
|
||||
tourCopyRequestSchema,
|
||||
tourCreateRequestSchema,
|
||||
tourDescriptionSchema,
|
||||
tourListItemSchema,
|
||||
tourMaxHikingDifficultySchema,
|
||||
tourNameSchema,
|
||||
tourWebsiteSchema,
|
||||
} from './tours.schema';
|
||||
|
||||
@@ -487,27 +490,47 @@ describe('city walks (CW-01 to CW-03, CW-10)', () => {
|
||||
}
|
||||
});
|
||||
|
||||
const listed = {
|
||||
place_id: 1,
|
||||
name: 'Old town',
|
||||
tour_type: 'walk',
|
||||
distance: null,
|
||||
elevation_gain: null,
|
||||
elevation_loss: null,
|
||||
duration: null,
|
||||
difficulty: null,
|
||||
wanderer_ref: null,
|
||||
match_confidence: null,
|
||||
max_hiking_difficulty: null,
|
||||
planned: false,
|
||||
caution: false,
|
||||
has_waypoints: true,
|
||||
station_count: 3,
|
||||
};
|
||||
|
||||
it("lists a walk's station count, and reads an item cached before it existed", () => {
|
||||
const item = tourListItemSchema.parse({
|
||||
place_id: 1,
|
||||
name: 'Old town',
|
||||
tour_type: 'walk',
|
||||
distance: null,
|
||||
elevation_gain: null,
|
||||
elevation_loss: null,
|
||||
duration: null,
|
||||
difficulty: null,
|
||||
wanderer_ref: null,
|
||||
match_confidence: null,
|
||||
max_hiking_difficulty: null,
|
||||
planned: false,
|
||||
caution: false,
|
||||
has_waypoints: true,
|
||||
station_count: 3,
|
||||
});
|
||||
const item = tourListItemSchema.parse(listed);
|
||||
expect(item.station_count).toBe(3);
|
||||
const { station_count: _count, ...cached } = item;
|
||||
expect(tourListItemSchema.parse(cached).station_count).toBeUndefined();
|
||||
expect(tourListItemSchema.safeParse({ ...item, station_count: -1 }).success).toBe(false);
|
||||
});
|
||||
|
||||
it('lists whether a walk still waits for its way, and reads a list cached before it was said (CW-11)', () => {
|
||||
expect(tourListItemSchema.parse({ ...listed, route_pending: true }).route_pending).toBe(true);
|
||||
expect(tourListItemSchema.parse(listed).route_pending).toBeUndefined();
|
||||
expect(tourListItemSchema.safeParse({ ...listed, route_pending: 1 }).success).toBe(false);
|
||||
});
|
||||
|
||||
it('holds a create, an edit and a copy to one name and one description', () => {
|
||||
expect(tourNameSchema.parse(' Old town ')).toBe('Old town');
|
||||
expect(['', ' ', 'x'.repeat(256)].map((name) => tourNameSchema.safeParse(name).success)).toEqual([
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
]);
|
||||
expect(tourCopyRequestSchema.safeParse({ name: 'x'.repeat(256) }).success).toBe(false);
|
||||
expect(tourDescriptionSchema.parse(null)).toBeNull();
|
||||
expect(tourDescriptionSchema.safeParse('x'.repeat(2001)).success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -241,6 +241,12 @@ export const tourListItemSchema = tourSchema.extend({
|
||||
station_stay_minutes: z.number().int().nonnegative().nullable().optional(),
|
||||
/** CW-02: how many of a city walk's stations have no stay entered yet; null for any other type. */
|
||||
station_stays_unknown: z.number().int().nonnegative().nullable().optional(),
|
||||
/**
|
||||
* CW-11: a tour saved with its points only, its way not planned yet (a city
|
||||
* walk an assistant created). The planner plans the way when the tour is
|
||||
* opened, and a save keeps it. Absent in a list cached before it existed.
|
||||
*/
|
||||
route_pending: z.boolean().optional(),
|
||||
});
|
||||
export type TourListItem = z.infer<typeof tourListItemSchema>;
|
||||
|
||||
@@ -300,6 +306,12 @@ export const MAX_STATION_STAY_MINUTES = 24 * 60;
|
||||
export const TOUR_STATION_NAME_MAX = 200;
|
||||
/** The longest opening hours a station keeps, as OpenStreetMap writes them. */
|
||||
export const TOUR_STATION_HOURS_MAX = 500;
|
||||
/**
|
||||
* How far a router may move a point of a tour onto its way before the point
|
||||
* counts as one no way of the tour's type reaches: the planner's limit, and
|
||||
* the server's for a city walk it plans on foot (CW-11).
|
||||
*/
|
||||
export const TOUR_MAX_SNAP_M = 300;
|
||||
/** CW-03: a station's key, the same across saves. */
|
||||
export const stationKeySchema = z.string().regex(/^[A-Za-z0-9_-]{6,64}$/);
|
||||
/** CW-03: how much a station matters, besides normal (null). */
|
||||
@@ -307,6 +319,11 @@ export const STATION_IMPORTANCES = ['optional', 'must'] as const;
|
||||
export const stationImportanceSchema = z.enum(STATION_IMPORTANCES);
|
||||
export type StationImportance = z.infer<typeof stationImportanceSchema>;
|
||||
|
||||
/** A tour's name, as a create, an edit and a copy take it. */
|
||||
export const tourNameSchema = z.string().trim().min(1).max(255);
|
||||
/** A tour's description, as a create and an edit take it. */
|
||||
export const tourDescriptionSchema = z.string().trim().max(2000).nullable().optional();
|
||||
|
||||
export const tourWaypointSchema = z.object({
|
||||
lat: z.number().finite().min(-90).max(90),
|
||||
lng: z.number().finite().min(-180).max(180),
|
||||
@@ -367,7 +384,7 @@ const enrichedRoutePointSchema = z.tuple([
|
||||
|
||||
export const tourCreateRequestSchema = z
|
||||
.object({
|
||||
name: z.string().trim().min(1).max(255),
|
||||
name: tourNameSchema,
|
||||
tour_type: plannableTourTypeSchema.default('hike'),
|
||||
route_geometry: z.array(enrichedRoutePointSchema).min(2),
|
||||
waypoints: z.array(tourWaypointSchema).min(2),
|
||||
@@ -385,7 +402,7 @@ export const tourCreateRequestSchema = z
|
||||
duration_seconds: z.number().finite().nonnegative().nullable().optional(),
|
||||
planned_duration_minutes: plannedTourDurationMinutesSchema.optional(),
|
||||
break_additional_minutes: plannedTourDurationMinutesSchema.optional(),
|
||||
description: z.string().trim().max(2000).nullable().optional(),
|
||||
description: tourDescriptionSchema,
|
||||
website: tourWebsiteSchema.nullable().optional(),
|
||||
/**
|
||||
* Creating only: the import of this trip the tour was planned from. It is
|
||||
@@ -538,7 +555,7 @@ export type TourCreateResponse = z.infer<typeof tourCreateResponseSchema>;
|
||||
* points, and no days.
|
||||
*/
|
||||
export const tourCopyRequestSchema = z.object({
|
||||
name: z.string().trim().min(1).max(255),
|
||||
name: tourNameSchema,
|
||||
});
|
||||
export type TourCopyRequest = z.infer<typeof tourCopyRequestSchema>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user