@v-office/website-sdk 2.16.2 → 2.17.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.
@@ -0,0 +1,207 @@
1
+ # Migration: 2.16.3 to 2.17.0
2
+
3
+ 2.17.0 adds presentation-ready prices to legacy-v9 initial availability days
4
+ and structured rooms to legacy-v9 rental output. It also represents source bed
5
+ amounts consistently on v9 and v10 by returning one public entry per bed.
6
+
7
+ Service inputs, configuration, and public TypeScript shapes are unchanged.
8
+
9
+ ## 1. Render Initial Calendar Prices Directly
10
+
11
+ For v9, `getInitialAvailability` can now return a non-null `formattedPrice` on
12
+ valid start dates:
13
+
14
+ ```ts
15
+ const availability = await sdk.live.availability.getInitialAvailability(input);
16
+
17
+ for (const [date, day] of Object.entries(availability.calendarDays)) {
18
+ renderCalendarDay({
19
+ date,
20
+ status: day.status,
21
+ price: day.formattedPrice,
22
+ });
23
+ }
24
+ ```
25
+
26
+ `formattedPrice` is already localized for the input locale and formatted in the
27
+ unit's configured booking currency. Render it directly. Do not parse it for
28
+ arithmetic and do not replace its currency based on site assumptions.
29
+
30
+ The field remains `null` when:
31
+
32
+ - the day cannot be used as a start date
33
+ - the calendar marks the day unavailable
34
+ - the v1 calendar supplies no numeric price
35
+ - the unit currency is missing or cannot be loaded
36
+
37
+ ## 2. Account for the Unit-Currency Request
38
+
39
+ When no successful unit lookup is cached, a v9 initial-availability call loads
40
+ two resources:
41
+
42
+ 1. the v1 unit calendar
43
+ 2. the v1 unit record used to read its booking currency
44
+
45
+ Successful unit responses are cached by unit ID for the lifetime of the SDK
46
+ instance, including responses without a currency. Failed unit requests are not
47
+ cached and are retried by later initial-availability calls. A failed currency
48
+ request does not fail availability; calendar prices remain `null` instead.
49
+
50
+ Update HTTP mocks, request-count assertions, and service-worker fixtures that
51
+ previously expected only the calendar request.
52
+
53
+ No additional config is required. The lookup uses the existing `v1ApiBaseUrl`
54
+ and `apiKey`.
55
+
56
+ ## 3. Read Structured v9 Rooms
57
+
58
+ When vOffice supplies `roomDetails`, v9 rentals can now contain `rooms`:
59
+
60
+ ```ts
61
+ const rentals = await sdk.static.rentals.getRentals({ locale: "de-DE" });
62
+
63
+ for (const rental of rentals) {
64
+ for (const room of rental.rooms ?? []) {
65
+ renderRoomHeading(room.type);
66
+ renderRoomAttributes(room.attributes ?? []);
67
+
68
+ for (const bed of room.beds ?? []) {
69
+ renderBed({
70
+ type: bed.type,
71
+ kind: bed.kind,
72
+ attributes: bed.attributes ?? [],
73
+ });
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ Room types, bed types, bed kinds, and attributes are already localized. Render
80
+ them directly rather than comparing their visible text.
81
+
82
+ The v9 source supports these per-room Boolean attributes:
83
+
84
+ - `hasPrivateBathroom`
85
+ - `roomDarkeningOption`
86
+ - `wardrobe`
87
+
88
+ It supports these per-bed Boolean attributes:
89
+
90
+ - `childrenOnly`
91
+ - `extraLongBeds`
92
+ - `openFootsection`
93
+ - `raisedBeds`
94
+
95
+ Translation overrides use the same stable keys as v10:
96
+
97
+ ```text
98
+ Room.type.option.<TYPE>
99
+ RoomAttributes.<attribute>.label
100
+ Bed.type.option.<TYPE>
101
+ Bed.kind.option.<KIND>
102
+ Bed.<attribute>.label
103
+ ```
104
+
105
+ `rooms` remains optional. Keep an absent array valid when vOffice has no
106
+ structured room details or no usable room remains after validation.
107
+
108
+ ## 4. Treat Repeated Beds as Quantity
109
+
110
+ The public room-bed shape has no `amount` property. From 2.17.0, the SDK expands
111
+ the source amount:
112
+
113
+ ```ts
114
+ // Source
115
+ { type: "ORDINARY", kind: "SINGLE", amount: 2 }
116
+
117
+ // Public rooms[].beds
118
+ [
119
+ { type: "Standard bed", kind: "Single bed" },
120
+ { type: "Standard bed", kind: "Single bed" },
121
+ ]
122
+ ```
123
+
124
+ Each public entry represents one bed. Do not deduplicate entries merely because
125
+ their type, kind, and attributes are identical.
126
+
127
+ This behavior applies to both backends:
128
+
129
+ - v9 expands `roomDetails[].beds[].amount`
130
+ - v10 expands `rooms[].beds[].amount`
131
+
132
+ The v10 change is delivered by `@v-office/sdk-core`. Refresh the lockfile when
133
+ upgrading the website SDK so it resolves the coordinated core version shipped
134
+ for 2.17.0.
135
+
136
+ Invalid, missing, zero, negative, and fractional v9 amounts do not produce bed
137
+ entries. Other usable rooms and beds remain available.
138
+
139
+ ## 5. Keep Unsupported v9 Room Fields Optional
140
+
141
+ The v9 source does not provide every v10 room capability. In particular, public
142
+ v9 rooms do not currently expose:
143
+
144
+ - per-room descriptions
145
+ - source `maxGuests`
146
+ - a structured bed amount; source quantities are represented by repeated entries
147
+ - room IDs or room-image associations
148
+ - `roomSummary`
149
+
150
+ Do not derive these values from translated room labels or property-description
151
+ prose. Existing top-level `attributes` and `highlights` remain the supported
152
+ display sources for aggregate v9 facts such as bedrooms, bathrooms, rooms, and
153
+ sleeping accommodations.
154
+
155
+ ## 6. Update Snapshots and Complete-Object Assertions
156
+
157
+ Update expectations that previously assumed:
158
+
159
+ ```ts
160
+ day.formattedPrice === null;
161
+ rental.rooms === undefined;
162
+ room.beds?.length === sourceRoom.beds.length;
163
+ ```
164
+
165
+ New valid behavior includes:
166
+
167
+ ```ts
168
+ day.formattedPrice; // localized string on a priced, valid v9 start date
169
+ rental.rooms; // localized structured v9 rooms when roomDetails exists
170
+ room.beds?.length; // total expanded bed amount, not source record count
171
+ ```
172
+
173
+ Keep both `formattedPrice: null` and missing `rooms` valid because they still
174
+ represent legitimate backend data.
175
+
176
+ ## Required Consumer Work
177
+
178
+ Applications that use only selected fields and ignore the new output require no
179
+ code changes.
180
+
181
+ Applications that render or snapshot these areas should:
182
+
183
+ 1. Render `formattedPrice` directly when non-null.
184
+ 2. Account for the first v9 initial-availability currency request in mocks.
185
+ 3. Render `rental.rooms` as optional structured content.
186
+ 4. Treat every `rooms[].beds` entry as one bed and avoid value-based
187
+ deduplication.
188
+ 5. Refresh the lockfile so v10 resolves the coordinated core release.
189
+ 6. Update complete-output fixtures and snapshots.
190
+
191
+ ## Recommended Verification
192
+
193
+ 1. Load v9 initial availability for a non-EUR rental and confirm the configured
194
+ currency is used.
195
+ 2. Confirm a missing or failed currency lookup keeps calendar prices `null`
196
+ without failing availability.
197
+ 3. Confirm unavailable, non-start, and price-less dates retain
198
+ `formattedPrice: null`.
199
+ 4. Call initial availability twice for the same rental and confirm a successful
200
+ unit response is reused; confirm a failed unit request is retried.
201
+ 5. Fetch v9 rentals with populated `roomDetails` in both supported locales.
202
+ 6. Confirm room and bed labels are localized.
203
+ 7. Confirm a source bed amount of two produces two public bed entries on v9 and
204
+ v10.
205
+ 8. Confirm incomplete v9 rooms do not remove other usable rooms or fail the
206
+ rental.
207
+ 9. Confirm rentals without structured source rooms still omit `rooms`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v-office/website-sdk",
3
- "version": "2.16.2",
3
+ "version": "2.17.0",
4
4
  "description": "Website-facing SDK facade backed by @v-office/sdk-core",
5
5
  "bin": {
6
6
  "website-sdk": "./dist/cli.mjs"
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@graphql-typed-document-node/core": "3.2.0",
45
- "@v-office/sdk-core": "^1.16.1",
45
+ "@v-office/sdk-core": "^1.18.0",
46
46
  "effect": "4.0.0-beta.85",
47
47
  "graphql": "17.0.2",
48
48
  "yaml": "^2.9.0"
@@ -77,8 +77,9 @@
77
77
  "fmt": "oxfmt",
78
78
  "fmt:check": "oxfmt --check",
79
79
  "check": "pnpm run typecheck && pnpm run lint && pnpm run fmt:check",
80
- "test": "pnpm run test:v9:properties && pnpm run build && node --test test/*.test.mjs",
81
- "test:v9:properties": "node --test codegen/v9/heuristic-generation/generate/property.test.ts src/legacy-v9/parser/rentals/render-property-attribute.test.ts",
80
+ "test": "pnpm run test:v9:properties && pnpm run test:v9:availability && pnpm run build && node --test test/*.test.mjs",
81
+ "test:v9:properties": "node --test codegen/v9/heuristic-generation/generate/property.test.ts src/legacy-v9/parser/rentals/render-property-attribute.test.ts src/legacy-v9/parser/rentals/to-rooms.test.ts",
82
+ "test:v9:availability": "node --test src/legacy-v9/parser/availability/to-initial-availability-calendar-days.test.ts",
82
83
  "playground:custom-attributes": "pnpm run build && node --env-file=.env playground/custom-attributes.ts"
83
84
  }
84
85
  }