@autobusal/providers 1.37.10 → 1.37.12

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.37.11
4
+
5
+ ### Added
6
+
7
+ - Saved-passenger types and the account query, shared by the checkout chooser and the account manager so both read one shape.
8
+
3
9
  ## 1.37.10
4
10
 
5
11
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/providers",
3
- "version": "1.37.10",
3
+ "version": "1.37.12",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"
@@ -17,12 +17,28 @@ export interface CountryStats {
17
17
 
18
18
  export interface CountryData {
19
19
  id: number
20
+
21
+ /**
22
+ * The name in the caller's language, already resolved server-side.
23
+ *
24
+ * Edited: Claude - Date: 2026-08-21
25
+ * Comes from ICU/CLDR keyed by `iso2`, so all 15 locales are answered
26
+ * without anybody storing anything - `translations` below is only for the
27
+ * handful CLDR cannot serve (England, Scotland and Wales are not ISO
28
+ * countries) or where a brand overrules it.
29
+ */
20
30
  name: string
21
- name_en?: string
22
- name_sq?: string
31
+
32
+ /** Hand-written overrides only, and almost always empty. ADMIN READS ONLY. */
33
+ translations?: Record<string, string>
34
+
23
35
  slug?: string
24
36
  cities?: CityData[]
25
37
  iso_code: string
38
+
39
+ /** ISO 3166-1 alpha-2 - what the CLDR name lookup is keyed by */
40
+ iso2?: string | null
41
+
26
42
  available?: number
27
43
  stats?: CountryStats
28
44
 
@@ -64,9 +80,36 @@ export interface CityDestination {
64
80
 
65
81
  export interface CityData {
66
82
  id: number
83
+
84
+ /**
85
+ * The name in the caller's language, already resolved server-side.
86
+ *
87
+ * Edited: Claude - Date: 2026-08-21
88
+ * This used to be an SQL alias for `name_en`/`name_sq`, the only two
89
+ * columns the table had, so 13 of the 15 UI locales silently read English.
90
+ * It is now resolved from a per-locale map with the English column as the
91
+ * fallback - the field is the same, the answer is right in every language.
92
+ * The ADMIN endpoints deliberately still answer with English here: it is
93
+ * the canonical value their form edits.
94
+ */
67
95
  name: string
68
- name_en?: string
69
- name_sq?: string
96
+
97
+ /**
98
+ * {locale: name} for the other 14 languages. ADMIN READS ONLY - the public
99
+ * endpoints resolve `name` and omit this.
100
+ */
101
+ translations?: Record<string, string>
102
+
103
+ /**
104
+ * Every name this place is known by, in any language or script, for
105
+ * MATCHING what a visitor types - never for display. Served only by
106
+ * /api/cities/browse, the one list the search box filters against.
107
+ */
108
+ aliases?: string[]
109
+
110
+ /** e.g. "Q17151" - what the admin picker stores so the backfill can re-run */
111
+ wikidata_id?: string | null
112
+
70
113
  location: string[]
71
114
  slug: string
72
115
  douane?: number
package/types/persons.ts CHANGED
@@ -14,4 +14,68 @@ export interface BillingData {
14
14
  bill_nipt: string
15
15
  comments: string
16
16
  terms: string
17
- }
17
+ }
18
+ /**
19
+ * A traveller this account has asked us to remember.
20
+ *
21
+ * Edited: Claude - Date: 2026-08-20
22
+ *
23
+ * Here rather than in either package that uses it, because BOTH do: the
24
+ * checkout chooser (@autobusal/routes-order) and the account manager
25
+ * (@autobusal/account-passengers) read the same rows from the same
26
+ * endpoints, and two copies of this shape would be free to disagree about
27
+ * the one field that matters most - which of them carries a passport number.
28
+ *
29
+ * THE LIST NEVER CARRIES THE NUMBER. `passport_masked` is the last few
30
+ * characters, enough to tell two of your own documents apart;
31
+ * `has_passport` is the yes/no. The raw value exists only on
32
+ * SavedPassengerRecord, which is what /get answers with - see obtapi's
33
+ * Account\PassengersController for why the split is there.
34
+ */
35
+ export interface SavedPassenger {
36
+ id: number
37
+
38
+ first_name: string
39
+ last_name: string
40
+ /** d/m/Y, the format every date field in this app is typed in */
41
+ dob: string
42
+
43
+ /** what this person was last ticketed as - a record, never a price */
44
+ type: string | null
45
+ /** the fare band they fall into TODAY, derived from `dob` by the server */
46
+ age_type: 'adult' | 'child' | 'baby'
47
+
48
+ sex: number | null
49
+
50
+ passport_masked: string | null
51
+ has_passport: boolean
52
+
53
+ phone: string | null
54
+ whatsapp: string | null
55
+ telegram: string | null
56
+ email: string | null
57
+
58
+ /**
59
+ * What the journey being booked would still have to ask for - the option
60
+ * keys of routes_trip.passenger_fields (sex, passport, phone, whatsapp,
61
+ * telegram).
62
+ *
63
+ * ABSENT, not empty, when no journey was named: the account page asks for
64
+ * the list with no price ids and gets no `missing` at all, and reading
65
+ * that as "nothing missing" would be a promise about a route nobody has
66
+ * chosen yet. Hence optional, and hence every reader tests for an array
67
+ * rather than for length.
68
+ */
69
+ missing?: string[]
70
+ }
71
+
72
+ /** One traveller, passport included - the answer /get alone gives */
73
+ export interface SavedPassengerRecord extends SavedPassenger {
74
+ passport: string | null
75
+ }
76
+
77
+ export interface SavedPassengersData {
78
+ data: SavedPassenger[]
79
+ /** how many one account may keep, so a UI can say so before refusing */
80
+ max: number
81
+ }