aves-sdk 1.8.0 → 2.0.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 CHANGED
@@ -5,6 +5,49 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.0.0] - 2026-08-05
9
+
10
+ ### Changed
11
+
12
+ - **Breaking:** flat operation aliases were removed; use namespaced domain clients only.
13
+ - **Breaking:** enum-typed fields now reject arbitrary strings at compile time.
14
+ - **Breaking:** `AvesError.status` retains AVES casing and `AvesError.code` is `number | undefined`.
15
+ - **Breaking:** master-record responses reflect the actual API payload, including server-only fields; `dynamicFields` is an array.
16
+ - Fixed AVES language codes (`01` Italian, `02` English), raw warning text preservation, and the `PaymentDetail` `@PaumentNote` wire spelling.
17
+
18
+ ### Migration
19
+
20
+ | Change | Symptom on upgrade | Fix |
21
+ | ------ | ------------------ | --- |
22
+ | Flat aliases removed | Runtime `TypeError` | Insert the domain namespace: `client.search` → `client.master.search` |
23
+ | Enum types narrowed | Compile errors for enum fields receiving `string` | Use exported enum objects or unions |
24
+ | `AvesError.status` casing | `err.status === "error"` no longer matches | Compare with `RsStatusValue` (`"OK"`, `"ERROR"`, `"WARNING"`, `"TIMEOUT"`) |
25
+ | `AvesError.code` | Absent codes are `undefined`, not `0` | Check for `undefined` |
26
+ | `MasterRecordDetailResponse` corrected | Type gains server-only fields | Remove local re-declarations |
27
+ | `dynamicFields` is an array | Single-object assignment fails | Wrap the field in an array |
28
+
29
+ ---
30
+
31
+ ## [1.9.0] - 2026-08-03
32
+
33
+ ### Changed
34
+
35
+ - **Breaking:** `upsertRecord` spreads `masterRecordDetail` into `data` — `result.data.recordCode`
36
+ - **Breaking:** booking create/mod/status spreads `bookingFileDetail` into `data` — `result.data.bookingFileCode`
37
+ - **Breaking:** `getPackageDetail` spreads `packageDetail` into `data` — `result.data.pCode`
38
+ - **Breaking:** response `*List` fields are flat Detail arrays (no inner `*Detail` wrapper) — e.g. `data.packageList?.[0]`, `data.masterRecordList`, `data.bookingFileList`, `data.bookedServiceList`
39
+ - **Breaking:** nested booking/catalog lists unwrapped the same way (`passengerList`, `serviceList`, `paxPriceList`, …)
40
+ - Input aliases: `customerRecordCode` ↔ `customerDetail`; `bookingFileStatus` / `fileStatus` as string or `{ value }`; `paxAssociated: string[]`; mod `selectedPackageList` ↔ `selectedPackageDetail`
41
+
42
+ ### Added
43
+
44
+ - Response helpers: `listDetailApiSchema`, `flattenResponseDetail`, `createFlattenedResponseSchema`, `createListResponseSchema`
45
+ - Request helpers: `createApiSchema`, `valueFieldSchema`, `coalesceCustomerRecordCode`, `coalesceListHead`, `coalesceWireAliases`
46
+ - Shared primitives: `LanguageCodeSchema`, `StringishSchema`, `DateRangeSchema`, `StatusOnlyResponseSchema`, `createWireSchemaPair`
47
+ - `yarn typecheck` script (`tsc --noEmit`)
48
+
49
+ ---
50
+
8
51
  ## [1.8.0] - 2026-08-03
9
52
 
10
53
  ### Added
package/README.md CHANGED
@@ -27,7 +27,7 @@ const client = new AvesClient({
27
27
  timeoutMs: 30_000, // optional
28
28
  });
29
29
 
30
- const result = await client.search({
30
+ const result = await client.master.search({
31
31
  searchType: 'CODE',
32
32
  recordCode: '508558',
33
33
  });
@@ -41,20 +41,17 @@ if (result.success) {
41
41
 
42
42
  ## Client shape
43
43
 
44
- `AvesClient` is a facade over domain clients. **Prefer namespaces.** Flat methods are auto-bound from domain prototypes (no hand-maintained forwarders).
44
+ `AvesClient` is a facade over domain clients. Operations are namespaced by domain.
45
45
 
46
46
  ```typescript
47
- // canonical
48
47
  await client.booking.createBooking(params);
49
48
  await client.packages.searchPackages(params);
50
49
  await client.master.search({ searchType: 'CODE', recordCode: '508558' });
51
-
52
- // flat compat (same implementations)
53
- await client.createBooking(params);
54
- await client.searchPackages(params);
55
- await client.search({ searchType: 'CODE', recordCode: '508558' });
56
50
  ```
57
51
 
52
+ Migration from 1.x: insert the appropriate domain namespace (for example,
53
+ `client.search` → `client.master.search`). See the [2.0.0 migration notes](./CHANGELOG.md).
54
+
58
55
  | Namespace | Methods |
59
56
  | --------- | ------- |
60
57
  | `master` | `search`, `upsertRecord` |
@@ -105,7 +102,7 @@ type Result<T, E> =
105
102
 
106
103
  ## Master records
107
104
 
108
- ### `search(params)` / `client.master.search`
105
+ ### `client.master.search(params)`
109
106
 
110
107
  | `searchType` | Required fields |
111
108
  | ------------ | --------------- |
@@ -124,18 +121,18 @@ const byCode = await client.master.search({
124
121
  recordCode: '508558',
125
122
  });
126
123
 
127
- const byEmail = await client.search({
124
+ const byEmail = await client.master.search({
128
125
  searchType: 'EMAIL',
129
126
  email: 'user@example.com',
130
127
  });
131
128
  ```
132
129
 
133
- ### `upsertRecord(record)` / `client.master.upsertRecord`
130
+ ### `client.master.upsertRecord(record)`
134
131
 
135
132
  `insertCriteria`: `'S'` always insert · `'N'` skip if exists · `'T'` update all (default) · `'M'` secondary fields only.
136
133
 
137
134
  ```typescript
138
- const result = await client.upsertRecord({
135
+ const result = await client.master.upsertRecord({
139
136
  name: 'Jane Smith',
140
137
  email: 'jane@example.com',
141
138
  languageCode: '02',
@@ -143,7 +140,7 @@ const result = await client.upsertRecord({
143
140
  });
144
141
 
145
142
  if (result.success) {
146
- console.log(result.data.masterRecordDetail?.recordCode);
143
+ console.log(result.data.recordCode);
147
144
  }
148
145
  ```
149
146
 
@@ -168,8 +165,8 @@ if (result.success) {
168
165
 
169
166
  ```typescript
170
167
  const created = await client.booking.createBooking({
171
- customerDetail: { recordCode: '138311' },
172
- bookingFileStatus: { value: 'QUOTATION' },
168
+ customerRecordCode: '138311', // or customerDetail: { recordCode: '138311' }
169
+ bookingFileStatus: 'QUOTATION', // or { value: 'QUOTATION', expiredDate? }
173
170
  startDate: '2015-01-22T00:00:00',
174
171
  endDate: '2015-01-25T00:00:00',
175
172
  selectedServiceList: [
@@ -182,7 +179,7 @@ const created = await client.booking.createBooking({
182
179
  endDate: '2015-01-25T00:00:00',
183
180
  qty: '1',
184
181
  pax: '2',
185
- paxAssociated: [],
182
+ paxAssociated: [], // or string[] like ['001','002']
186
183
  avesSession: '1',
187
184
  },
188
185
  ],
@@ -198,7 +195,8 @@ const created = await client.booking.createBooking({
198
195
  });
199
196
 
200
197
  if (created.success) {
201
- console.log(created.data.bookingFileDetail?.bookingFileCode);
198
+ console.log(created.data.bookingFileCode);
199
+ console.log(created.data.bookedServiceList?.[0]?.serviceStatus);
202
200
  }
203
201
  ```
204
202
 
@@ -273,7 +271,7 @@ await client.booking.modBookingHeader({
273
271
  await client.booking.setBookingStatus({
274
272
  customerRecordCode: '000170',
275
273
  bookingFileCode: '14/000081',
276
- fileStatus: { value: 'CANCELED' },
274
+ fileStatus: 'CANCELED', // or { value: 'CANCELED' }
277
275
  });
278
276
 
279
277
  await client.booking.setBookingServiceStatus({
@@ -340,6 +338,9 @@ const detail = await client.packages.getPackageDetail({
340
338
  });
341
339
 
342
340
  await client.packages.commitPackage({ packageCode: '14/PACKAGE001' });
341
+
342
+ if (packages.success) console.log(packages.data.packageList?.[0]?.pCode);
343
+ if (detail.success) console.log(detail.data.pCode, detail.data.serviceList?.[0]);
343
344
  ```
344
345
 
345
346
  ---
@@ -349,7 +350,7 @@ await client.packages.commitPackage({ packageCode: '14/PACKAGE001' });
349
350
  ```typescript
350
351
  import { AvesClient, AvesError } from 'aves-sdk';
351
352
 
352
- const result = await client.search({
353
+ const result = await client.master.search({
353
354
  searchType: 'CODE',
354
355
  recordCode: '508558',
355
356
  });
@@ -375,9 +376,11 @@ You do not handle XML attribute prefixes yourself. Attr vs element is decided by
375
376
  One outbound path for all ops:
376
377
 
377
378
  1. Valibot validates camelCase input
378
- 2. `createApiSchema(schema, shape, wrap?)` → `toWireBody` (optional list wrap + empty `paxAssociated` normalize + `camelToPascalKeys`)
379
+ 2. `createApiSchema(schema, shape, wrap?)` → `toWireBody` (optional list wrap + `paxAssociated` string[]/empty normalize + `camelToPascalKeys`)
379
380
  3. `AvesTransport.invokeOp` adds `RqHeader`, optional `bodyKey` nest, POSTs XML
380
381
 
382
+ Inbound: `createResponseSchema` / `createFlattenedResponseSchema` / `createListResponseSchema` → camelCase + optional detail spread or typed list RS; `listDetailApiSchema` unwraps wire `*List`/`*Detail` to flat arrays; `coalesceWireAliases` normalizes dialect attrs. Input aliases: `valueFieldSchema`, `coalesceCustomerRecordCode`, `coalesceListHead`. Shared primitives: `LanguageCodeSchema`, `StringishSchema`, `DateRangeSchema`, `StatusOnlyResponseSchema`.
383
+
381
384
  Element-only roots use `elementOnlyWire` (`{}`). Master upsert nests under `bodyKey: "MasterRecordDetail"`; master search and booking spread fields at the RQ root.
382
385
 
383
386
  ### Request shapes (one family per op)
@@ -407,18 +410,19 @@ Editing CreateBooking shapes does not affect SearchFile or AvesSearch.
407
410
  | `MasterRecordsClient` | search / upsert |
408
411
  | `BookingClient` | booking file ops + search practices |
409
412
  | `PackageCatalogClient` | package/program catalog |
410
- | `client/types.ts` | `AvesClientDeps` / `AvesClientFlat` |
411
- | `client/flat-aliases.ts` | bind flat compat methods from domain prototypes |
413
+ | `client/types.ts` | `AvesClientDeps` |
412
414
  | `src/xml/` | XML root helpers + JSON ↔ XML |
413
415
 
414
- Flat aliases (`client.createBooking`, …) are attached in the constructor — add a domain method once and both surfaces work.
415
-
416
416
  Outbound path: validate → `createApiSchema` / `toWireBody` → `invokeOp` → XML POST.
417
417
 
418
418
  ---
419
419
 
420
420
  ## Types
421
421
 
422
+ Operations are available only through `client.master`, `client.booking`, and
423
+ `client.packages`; flat aliases were removed in 2.0.0. See the
424
+ [migration notes](./CHANGELOG.md) when upgrading.
425
+
422
426
  ```typescript
423
427
  import type {
424
428
  AvesClientOptions,