aves-sdk 1.6.0 → 1.7.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 +224 -0
- package/README.md +228 -76
- package/dist/index.d.mts +4633 -689
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- package/docs/guida-implementazione-booking-ops.md +0 -528
- package/docs/spike-api-aves-analisi.md +0 -196
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.7.0] - 2026-08-03
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Package / Program catalog APIs: `searchPackages`, `searchTopServices`, `getPackageDetail`, `commitPackage`
|
|
13
|
+
- `searchBookingFiles` (`FILE_CODE` | `PAX_NAME` | `PACKAGE_CODE` | `OTHER`)
|
|
14
|
+
- Domain clients with DI: `AvesTransport`, `MasterRecordsClient`, `BookingClient`, `PackageCatalogClient`, `AvesClientDeps`
|
|
15
|
+
- Per-request `WireShape` model (`src/utils/wire-shapes.ts`)
|
|
16
|
+
- Flat method aliases auto-bound from domain prototypes (`client/flat-aliases.ts`)
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- `AvesClient` is a thin facade; prefer `client.booking.*` / `client.packages.*` / `client.master.*`
|
|
21
|
+
- Single outbound wire path: `createApiSchema` / `toWireBody` / `invokeOp` (optional `bodyKey`)
|
|
22
|
+
- XML helpers moved to `src/xml/`
|
|
23
|
+
- Master search/upsert routed through `invokeOp`
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- InsertFilePaymentList root `paymentUser` emitted as `@PaymentUser` (not a child element)
|
|
28
|
+
|
|
29
|
+
### Removed
|
|
30
|
+
|
|
31
|
+
- Global `ATTRIBUTE_FIELDS` registry
|
|
32
|
+
- Versioned docs under `docs/` from git (`docs/` gitignored)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## [1.6.0] - 2026-07-29
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- **Breaking:** booking `*List` SDK inputs are flat `Detail[]`; SDK wraps to AVES List/Detail XML
|
|
41
|
+
- Shared `PaymentTypeSchema` across booking ops
|
|
42
|
+
- README refreshed for constructor, `Result` / `AvesError`, and flat list examples
|
|
43
|
+
- Documented additional package managers in README
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## [1.5.1] - 2026-07-29
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
- Added `fast-xml-builder` dependency
|
|
52
|
+
- Dependency / `tsdown` config maintenance
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## [1.5.0] - 2026-07-29
|
|
57
|
+
|
|
58
|
+
### Added
|
|
59
|
+
|
|
60
|
+
- `insertFilePaymentList` (InsertFilePaymentList) for payment registration
|
|
61
|
+
- Tighter `invokeOp` schema inference
|
|
62
|
+
- Booking ops documentation updates
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## [1.4.0] - 2026-07-29
|
|
67
|
+
|
|
68
|
+
### Added
|
|
69
|
+
|
|
70
|
+
- Booking ops: ModBookingFileServices, ModBookingFileHeader, CancelBookingFile, SetStatus / SetStatusService
|
|
71
|
+
- Shared transforms and typed BOOKEDFILE responses
|
|
72
|
+
- Unit coverage for booking ops
|
|
73
|
+
|
|
74
|
+
### Changed
|
|
75
|
+
|
|
76
|
+
- Dependency updates
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## [1.3.4] - 2026-03-09
|
|
81
|
+
|
|
82
|
+
### Added
|
|
83
|
+
|
|
84
|
+
- Create-booking related input schemas: financial deadlines, payments, selected packages/services, notes, passengers
|
|
85
|
+
|
|
86
|
+
### Fixed
|
|
87
|
+
|
|
88
|
+
- Union formatting in `SelectedServiceListInputSchema`
|
|
89
|
+
|
|
90
|
+
### Changed
|
|
91
|
+
|
|
92
|
+
- Error handling via `isOk`
|
|
93
|
+
- Schema / quote standardization across client and types
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## [1.3.3] - 2026-02-26
|
|
98
|
+
|
|
99
|
+
### Fixed
|
|
100
|
+
|
|
101
|
+
- `package.json` packaging fix
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## [1.3.2] - 2026-02-10
|
|
106
|
+
|
|
107
|
+
### Added
|
|
108
|
+
|
|
109
|
+
- `createBooking` (CreateBookingFile) with tests
|
|
110
|
+
- Migrated bundler from `tsup` to `tsdown`
|
|
111
|
+
|
|
112
|
+
### Changed
|
|
113
|
+
|
|
114
|
+
- Package configuration updates
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## [1.3.1] - 2026-02-01
|
|
119
|
+
|
|
120
|
+
### Changed
|
|
121
|
+
|
|
122
|
+
- Error-handling path formatting simplified
|
|
123
|
+
- String-quote standardization
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## [1.3.0] - 2026-02-01
|
|
128
|
+
|
|
129
|
+
### Added
|
|
130
|
+
|
|
131
|
+
- Biome linting
|
|
132
|
+
- Undici-based mock improvements in tests
|
|
133
|
+
- Additional master-record properties and attribute-schema refactor
|
|
134
|
+
- Broader test coverage
|
|
135
|
+
|
|
136
|
+
### Changed
|
|
137
|
+
|
|
138
|
+
- Consolidated XML root element definitions and utilities
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## [1.2.16] - 2026-01-27
|
|
143
|
+
|
|
144
|
+
### Changed
|
|
145
|
+
|
|
146
|
+
- Removed unnecessary `as any` casts
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## [1.2.15] - 2026-01-27
|
|
151
|
+
|
|
152
|
+
### Fixed
|
|
153
|
+
|
|
154
|
+
- XML / validation follow-up fixes
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## [1.2.14] - 2026-01-27
|
|
159
|
+
|
|
160
|
+
### Changed
|
|
161
|
+
|
|
162
|
+
- XML ↔ JSON conversion and validation schema improvements
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## [1.2.13] - 2026-01-27
|
|
167
|
+
|
|
168
|
+
### Added
|
|
169
|
+
|
|
170
|
+
- Request timeout handling with clear timeout vs other errors
|
|
171
|
+
- `isAbortError` utility
|
|
172
|
+
|
|
173
|
+
### Changed
|
|
174
|
+
|
|
175
|
+
- `AvesClientOptions` moved to `types.ts`
|
|
176
|
+
- Request method uses Valibot `BaseSchema` more consistently
|
|
177
|
+
- Upsert response schema and error detail improvements
|
|
178
|
+
- `recordCode` length validation tests
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## [1.2.12] - 2026-01-26
|
|
183
|
+
|
|
184
|
+
### Added
|
|
185
|
+
|
|
186
|
+
- Export `AvesClientOptions` for external usage
|
|
187
|
+
- Mapped profiling record support
|
|
188
|
+
|
|
189
|
+
### Changed
|
|
190
|
+
|
|
191
|
+
- Restructured `AvesError` handling and client initialization
|
|
192
|
+
- Optional `insertCriteria` on upsert flow
|
|
193
|
+
|
|
194
|
+
### Fixed
|
|
195
|
+
|
|
196
|
+
- Misc client fixes
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## [1.2.11] - 2026-01-21
|
|
201
|
+
|
|
202
|
+
### Fixed
|
|
203
|
+
|
|
204
|
+
- Error code handling uses numeric values instead of strings
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## [1.0.3] - 2025-10-04
|
|
209
|
+
|
|
210
|
+
Early tagged releases (`v1.0.0` … `v1.0.3`) from the initial NestJS-oriented AVES SDK work. Detailed commit notes for those tags are limited in the current branch history.
|
|
211
|
+
|
|
212
|
+
### Added
|
|
213
|
+
|
|
214
|
+
- Initial AVES SDK implementation with XML/REST interfaces (2025-10-03)
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Links
|
|
219
|
+
|
|
220
|
+
- [npm](https://www.npmjs.com/package/aves-sdk)
|
|
221
|
+
- [GitHub](https://github.com/simoneguglielmi/aves-sdk)
|
|
222
|
+
- Tags: [v1.0.0](https://github.com/simoneguglielmi/aves-sdk/releases/tag/v1.0.0) … [v1.0.3](https://github.com/simoneguglielmi/aves-sdk/releases/tag/v1.0.3)
|
|
223
|
+
|
|
224
|
+
> Git tags after `v1.0.3` were not present when this file was generated; version sections follow `package.json` bumps and commit messages.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AVES SDK
|
|
2
2
|
|
|
3
|
-
Type-safe TypeScript SDK for the AVES XML REST API. Handles XML parsing, Valibot validation, camelCase ↔ PascalCase, and returns `Result` instead of throwing.
|
|
3
|
+
Type-safe TypeScript SDK for the AVES XML REST API. Handles XML parsing, Valibot validation, camelCase ↔ PascalCase / `@` attrs, and returns `Result` instead of throwing.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ pnpm add aves-sdk
|
|
|
14
14
|
bun add aves-sdk
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
## Quick
|
|
17
|
+
## Quick start
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
20
|
import { AvesClient } from 'aves-sdk';
|
|
@@ -27,67 +27,99 @@ const client = new AvesClient({
|
|
|
27
27
|
timeoutMs: 30_000, // optional
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
const
|
|
30
|
+
const result = await client.search({
|
|
31
31
|
searchType: 'CODE',
|
|
32
32
|
recordCode: '508558',
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
if (
|
|
36
|
-
console.log(
|
|
35
|
+
if (result.success) {
|
|
36
|
+
console.log(result.data.masterRecordList);
|
|
37
37
|
} else {
|
|
38
|
-
console.error(
|
|
39
|
-
searchResult.error.kind,
|
|
40
|
-
searchResult.error.message,
|
|
41
|
-
searchResult.error.code,
|
|
42
|
-
);
|
|
38
|
+
console.error(result.error.kind, result.error.message, result.error.code);
|
|
43
39
|
}
|
|
44
40
|
```
|
|
45
41
|
|
|
46
|
-
##
|
|
42
|
+
## Client shape
|
|
43
|
+
|
|
44
|
+
`AvesClient` is a facade over domain clients. **Prefer namespaces.** Flat methods are auto-bound from domain prototypes (no hand-maintained forwarders).
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
// canonical
|
|
48
|
+
await client.booking.createBooking(params);
|
|
49
|
+
await client.packages.searchPackages(params);
|
|
50
|
+
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
|
+
```
|
|
47
57
|
|
|
48
|
-
|
|
58
|
+
| Namespace | Methods |
|
|
59
|
+
| --------- | ------- |
|
|
60
|
+
| `master` | `search`, `upsertRecord` |
|
|
61
|
+
| `booking` | `createBooking`, `modBookingServices`, `modBookingHeader`, `cancelBooking`, `setBookingStatus`, `setBookingServiceStatus`, `insertFilePaymentList`, `searchBookingFiles` |
|
|
62
|
+
| `packages` | `searchPackages`, `searchTopServices`, `getPackageDetail`, `commitPackage` |
|
|
49
63
|
|
|
50
|
-
|
|
64
|
+
### Constructor
|
|
51
65
|
|
|
52
66
|
```typescript
|
|
53
|
-
new AvesClient(options: AvesClientOptions)
|
|
67
|
+
new AvesClient(options: AvesClientOptions, deps?: AvesClientDeps)
|
|
54
68
|
```
|
|
55
69
|
|
|
56
|
-
| Option
|
|
57
|
-
|
|
|
58
|
-
| `baseURL`
|
|
59
|
-
| `hostID`
|
|
60
|
-
| `xtoken`
|
|
70
|
+
| Option | Description |
|
|
71
|
+
| ------ | ----------- |
|
|
72
|
+
| `baseURL` | AVES API base URL |
|
|
73
|
+
| `hostID` | 6-digit host id |
|
|
74
|
+
| `xtoken` | Auth token |
|
|
61
75
|
| `languageCode` | Optional 2-digit language code |
|
|
62
|
-
| `timeoutMs`
|
|
76
|
+
| `timeoutMs` | Optional request timeout (default 30000) |
|
|
63
77
|
|
|
64
|
-
|
|
78
|
+
Optional DI (tests / custom transport):
|
|
65
79
|
|
|
66
80
|
```typescript
|
|
67
|
-
|
|
81
|
+
import {
|
|
82
|
+
AvesClient,
|
|
83
|
+
AvesTransport,
|
|
84
|
+
BookingClient,
|
|
85
|
+
} from 'aves-sdk';
|
|
86
|
+
|
|
87
|
+
const transport = new AvesTransport(options);
|
|
88
|
+
new AvesClient(options, {
|
|
89
|
+
transport,
|
|
90
|
+
booking: new BookingClient(transport),
|
|
91
|
+
});
|
|
68
92
|
```
|
|
69
93
|
|
|
70
|
-
|
|
94
|
+
### Result type
|
|
95
|
+
|
|
96
|
+
All methods return `Result<T, AvesError>` — they do **not** throw.
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
type Result<T, E> =
|
|
100
|
+
| { success: true; data: T }
|
|
101
|
+
| { success: false; error: E };
|
|
102
|
+
```
|
|
71
103
|
|
|
72
|
-
|
|
104
|
+
---
|
|
73
105
|
|
|
74
|
-
|
|
106
|
+
## Master records
|
|
75
107
|
|
|
76
|
-
|
|
108
|
+
### `search(params)` / `client.master.search`
|
|
77
109
|
|
|
78
|
-
| `searchType`
|
|
79
|
-
|
|
|
80
|
-
| `'CODE'`
|
|
81
|
-
| `'NAME'`
|
|
82
|
-
| `'VATCODE'`
|
|
83
|
-
| `'ZONE'`
|
|
84
|
-
| `'CATEGORY'`
|
|
85
|
-
| `'EMAIL'`
|
|
86
|
-
| `'LASTMODDATE'`
|
|
87
|
-
| `'SEARCH_FIELD'` / `'EXTERNAL_REF_CODE'` | `searchFieldValue`
|
|
110
|
+
| `searchType` | Required fields |
|
|
111
|
+
| ------------ | --------------- |
|
|
112
|
+
| `'CODE'` | `recordCode` |
|
|
113
|
+
| `'NAME'` | `name` (+ optional `city`) |
|
|
114
|
+
| `'VATCODE'` | `vatCode` (+ optional `phoneNumber`) |
|
|
115
|
+
| `'ZONE'` | `zipCode`, `countyCode` (+ optional `city`) |
|
|
116
|
+
| `'CATEGORY'` | `categoryCode` |
|
|
117
|
+
| `'EMAIL'` | `email` |
|
|
118
|
+
| `'LASTMODDATE'` | `lastModificationDate: { minDate, maxDate }` |
|
|
119
|
+
| `'SEARCH_FIELD'` / `'EXTERNAL_REF_CODE'` | `searchFieldValue` |
|
|
88
120
|
|
|
89
121
|
```typescript
|
|
90
|
-
const byCode = await client.search({
|
|
122
|
+
const byCode = await client.master.search({
|
|
91
123
|
searchType: 'CODE',
|
|
92
124
|
recordCode: '508558',
|
|
93
125
|
});
|
|
@@ -98,23 +130,14 @@ const byEmail = await client.search({
|
|
|
98
130
|
});
|
|
99
131
|
```
|
|
100
132
|
|
|
101
|
-
|
|
133
|
+
### `upsertRecord(record)` / `client.master.upsertRecord`
|
|
102
134
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
- `'S'` — always insert
|
|
106
|
-
- `'N'` — do not update if exists
|
|
107
|
-
- `'T'` — update all fields if exists (default)
|
|
108
|
-
- `'M'` — update secondary fields only
|
|
135
|
+
`insertCriteria`: `'S'` always insert · `'N'` skip if exists · `'T'` update all (default) · `'M'` secondary fields only.
|
|
109
136
|
|
|
110
137
|
```typescript
|
|
111
138
|
const result = await client.upsertRecord({
|
|
112
139
|
name: 'Jane Smith',
|
|
113
140
|
email: 'jane@example.com',
|
|
114
|
-
address: '456 Oak Ave',
|
|
115
|
-
zipCode: '67890',
|
|
116
|
-
cityName: 'Los Angeles',
|
|
117
|
-
stateCode: 'USA',
|
|
118
141
|
languageCode: '02',
|
|
119
142
|
insertCriteria: 'T',
|
|
120
143
|
});
|
|
@@ -126,24 +149,25 @@ if (result.success) {
|
|
|
126
149
|
|
|
127
150
|
---
|
|
128
151
|
|
|
129
|
-
|
|
152
|
+
## Booking
|
|
130
153
|
|
|
131
|
-
`*List` request fields are **flat arrays of Detail objects**. The SDK wraps them to AVES List/Detail XML
|
|
154
|
+
`*List` request fields are **flat arrays of Detail objects**. The SDK wraps them to AVES List/Detail XML.
|
|
132
155
|
|
|
133
|
-
| Method
|
|
134
|
-
|
|
|
135
|
-
| `createBooking`
|
|
136
|
-
| `modBookingServices`
|
|
137
|
-
| `modBookingHeader`
|
|
138
|
-
| `cancelBooking`
|
|
139
|
-
| `setBookingStatus`
|
|
140
|
-
| `setBookingServiceStatus` | Nullify a single service line
|
|
141
|
-
| `insertFilePaymentList`
|
|
156
|
+
| Method | Purpose |
|
|
157
|
+
| ------ | ------- |
|
|
158
|
+
| `createBooking` | Create booking file |
|
|
159
|
+
| `modBookingServices` | Add/replace services, assign package, delete/nullify lines |
|
|
160
|
+
| `modBookingHeader` | Header only (pax, notes, billing) — no costs |
|
|
161
|
+
| `cancelBooking` | Delete booking file |
|
|
162
|
+
| `setBookingStatus` | Change file status (`CANCELED` / `NULLIFIED` / …) |
|
|
163
|
+
| `setBookingServiceStatus` | Nullify a single service line |
|
|
164
|
+
| `insertFilePaymentList` | Register payments |
|
|
165
|
+
| `searchBookingFiles` | Search practices (`FILE_CODE`, `PAX_NAME`, `PACKAGE_CODE`, `OTHER`) |
|
|
142
166
|
|
|
143
|
-
|
|
167
|
+
### Create
|
|
144
168
|
|
|
145
169
|
```typescript
|
|
146
|
-
const created = await client.createBooking({
|
|
170
|
+
const created = await client.booking.createBooking({
|
|
147
171
|
customerDetail: { recordCode: '138311' },
|
|
148
172
|
bookingFileStatus: { value: 'QUOTATION' },
|
|
149
173
|
startDate: '2015-01-22T00:00:00',
|
|
@@ -178,10 +202,10 @@ if (created.success) {
|
|
|
178
202
|
}
|
|
179
203
|
```
|
|
180
204
|
|
|
181
|
-
|
|
205
|
+
### Modify services / package / overwrite lines
|
|
182
206
|
|
|
183
207
|
```typescript
|
|
184
|
-
|
|
208
|
+
await client.booking.modBookingServices({
|
|
185
209
|
customerRecordCode: '138311',
|
|
186
210
|
bookingFileCode: '14/036654',
|
|
187
211
|
selectedPackageDetail: {
|
|
@@ -213,13 +237,16 @@ const result = await client.modBookingServices({
|
|
|
213
237
|
});
|
|
214
238
|
```
|
|
215
239
|
|
|
216
|
-
|
|
240
|
+
### Payments
|
|
217
241
|
|
|
218
242
|
Requires `bookingFileCode` **or** `bookingFileRefCode`.
|
|
219
243
|
|
|
244
|
+
`paymentUser` is serialized as an XML **attribute** on `FilePaymentListRQ` (`PaymentUser="…"`), not as a child element.
|
|
245
|
+
|
|
220
246
|
```typescript
|
|
221
|
-
|
|
247
|
+
await client.booking.insertFilePaymentList({
|
|
222
248
|
bookingFileCode: '18/000172',
|
|
249
|
+
paymentUser: 'MLDN',
|
|
223
250
|
enableMultiplePayments: true,
|
|
224
251
|
operationType: 'AbsoluteAmountsInsertion',
|
|
225
252
|
filePaymentList: [
|
|
@@ -233,38 +260,94 @@ const paid = await client.insertFilePaymentList({
|
|
|
233
260
|
});
|
|
234
261
|
```
|
|
235
262
|
|
|
236
|
-
|
|
263
|
+
### Header, status, cancel, search practices
|
|
237
264
|
|
|
238
265
|
```typescript
|
|
239
|
-
await client.modBookingHeader({
|
|
266
|
+
await client.booking.modBookingHeader({
|
|
240
267
|
bookingFileCode: '14/000043',
|
|
241
268
|
bookingFileStartDate: '2014-04-28',
|
|
242
269
|
customerRecordCode: '103737',
|
|
243
270
|
passengerList: [{ rph: '001', name: 'ADULTI 001', sex: 'M' }],
|
|
244
271
|
});
|
|
245
272
|
|
|
246
|
-
await client.setBookingStatus({
|
|
273
|
+
await client.booking.setBookingStatus({
|
|
247
274
|
customerRecordCode: '000170',
|
|
248
275
|
bookingFileCode: '14/000081',
|
|
249
276
|
fileStatus: { value: 'CANCELED' },
|
|
250
277
|
});
|
|
251
278
|
|
|
252
|
-
await client.setBookingServiceStatus({
|
|
279
|
+
await client.booking.setBookingServiceStatus({
|
|
253
280
|
customerRecordCode: '000001',
|
|
254
281
|
bookingFileCode: '18/000252',
|
|
255
282
|
bookingServiceRef: '002',
|
|
256
283
|
bookingFileServiceStatus: 'NULLIFIED',
|
|
257
284
|
});
|
|
258
285
|
|
|
259
|
-
await client.cancelBooking({
|
|
286
|
+
await client.booking.cancelBooking({
|
|
260
287
|
bookingFileCode: '14/000081',
|
|
261
288
|
customerRecordCode: '000170',
|
|
262
289
|
});
|
|
290
|
+
|
|
291
|
+
await client.booking.searchBookingFiles({
|
|
292
|
+
searchType: 'PACKAGE_CODE',
|
|
293
|
+
customerRecordCode: '138311',
|
|
294
|
+
packageCode: '2014MDE0000010',
|
|
295
|
+
});
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Package / Program catalog
|
|
301
|
+
|
|
302
|
+
There is **no** Create Package API in AVES XML 1.8.0. Search, detail, and commit (publish) are supported.
|
|
303
|
+
|
|
304
|
+
| Method | Purpose |
|
|
305
|
+
| ------ | ------- |
|
|
306
|
+
| `searchPackages` | Search programs (`avesSearchType`: `PACKAGE` / `PROGRAM`) |
|
|
307
|
+
| `searchTopServices` | Search TOP services (`avesSearchType`: `SERVICE`) |
|
|
308
|
+
| `getPackageDetail` | Package base info + service list |
|
|
309
|
+
| `commitPackage` | Publish existing package (`packageCode` only) |
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
const packages = await client.packages.searchPackages({
|
|
313
|
+
baseSearch: {
|
|
314
|
+
customerRecordCode: '138311',
|
|
315
|
+
languageCode: '01',
|
|
316
|
+
currencyCode: 'EUR',
|
|
317
|
+
startDate: '2014-12-27T00:00:00',
|
|
318
|
+
endDate: '2015-01-03T00:00:00',
|
|
319
|
+
passengerList: [
|
|
320
|
+
{
|
|
321
|
+
rph: '001',
|
|
322
|
+
roomRph: '001',
|
|
323
|
+
name: 'ADULTI 001',
|
|
324
|
+
categoryCode: 'AD',
|
|
325
|
+
sex: 'M',
|
|
326
|
+
},
|
|
327
|
+
],
|
|
328
|
+
},
|
|
329
|
+
avesSearchType: 'PACKAGE',
|
|
330
|
+
paxQty: '1',
|
|
331
|
+
paxQtyCriteria: 'GREATER_OR_EQUAL',
|
|
332
|
+
servOrPackCode: '2014MDE0000010',
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
const detail = await client.packages.getPackageDetail({
|
|
336
|
+
customerRecordCode: '001692',
|
|
337
|
+
packageCode: '2015F042',
|
|
338
|
+
startDate: '2015-05-02T00:00:00',
|
|
339
|
+
endDate: '2015-05-05T00:00:00',
|
|
340
|
+
selectedServiceList: [
|
|
341
|
+
{ serviceCode: 'PFRM04 PAR', packageRow: '01' },
|
|
342
|
+
],
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
await client.packages.commitPackage({ packageCode: '14/PACKAGE001' });
|
|
263
346
|
```
|
|
264
347
|
|
|
265
348
|
---
|
|
266
349
|
|
|
267
|
-
##
|
|
350
|
+
## Errors
|
|
268
351
|
|
|
269
352
|
```typescript
|
|
270
353
|
import { AvesClient, AvesError } from 'aves-sdk';
|
|
@@ -275,24 +358,74 @@ const result = await client.search({
|
|
|
275
358
|
});
|
|
276
359
|
|
|
277
360
|
if (!result.success) {
|
|
278
|
-
//
|
|
361
|
+
// kind: 'validation' | 'api' | 'unknown'
|
|
279
362
|
console.error(result.error.kind, result.error.message, result.error.code);
|
|
280
363
|
}
|
|
281
364
|
```
|
|
282
365
|
|
|
283
|
-
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
## Case transformation & wire shapes
|
|
284
369
|
|
|
285
|
-
- **Input**: camelCase (`recordCode`, `selectedServiceList`)
|
|
286
|
-
- **Wire**: PascalCase
|
|
370
|
+
- **Input**: camelCase (`recordCode`, `selectedServiceList`, `paymentUser`)
|
|
371
|
+
- **Wire**: PascalCase keys; `@`-prefixed keys become XML attributes
|
|
287
372
|
- **Output**: camelCase again
|
|
288
373
|
|
|
289
|
-
You do not handle XML attribute prefixes yourself.
|
|
374
|
+
You do not handle XML attribute prefixes yourself. Attr vs element is decided by a **per-request `WireShape`** (`src/utils/wire-shapes.ts`), not a global field set.
|
|
375
|
+
|
|
376
|
+
### Pipeline
|
|
377
|
+
|
|
378
|
+
One outbound path for all ops:
|
|
379
|
+
|
|
380
|
+
1. Valibot validates camelCase input
|
|
381
|
+
2. `createApiSchema(schema, shape, wrap?)` → `toWireBody` (optional list wrap + empty `paxAssociated` normalize + `camelToPascalKeys`)
|
|
382
|
+
3. `AvesTransport.invokeOp` adds `RqHeader`, optional `bodyKey` nest, POSTs XML
|
|
383
|
+
|
|
384
|
+
Element-only roots use `elementOnlyWire` (`{}`). Master upsert nests under `bodyKey: "MasterRecordDetail"`; master search and booking spread fields at the RQ root.
|
|
385
|
+
|
|
386
|
+
### Request shapes (one family per op)
|
|
387
|
+
|
|
388
|
+
| Shape | Used by |
|
|
389
|
+
| ----- | ------- |
|
|
390
|
+
| `masterRecordWire` / `searchMasterWire` | Upsert / Search master |
|
|
391
|
+
| `bookingFileWire` | CreateBooking, ModFileServices, ModFileHeader |
|
|
392
|
+
| `filePaymentListRequestWire` | InsertFilePaymentList (`paymentUser` root attr) |
|
|
393
|
+
| `searchFileWire` | SearchBookingFiles (date ranges / insurance attrs) |
|
|
394
|
+
| `setFileStatusWire` | SetBookingFileStatus |
|
|
395
|
+
| `packageDetailRequestWire` | GetPackageDetail |
|
|
396
|
+
| `baseSearchWire` + `avesSearchWire` | SearchAvesPackages / SearchTopServices |
|
|
397
|
+
| `elementOnlyWire` | CancelFile, SetFileServiceStatus, CommitPackage |
|
|
398
|
+
|
|
399
|
+
Editing CreateBooking shapes does not affect SearchFile or AvesSearch.
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Architecture
|
|
404
|
+
|
|
405
|
+
`AvesClient` (`src/client.ts`) is a thin facade over DI-friendly domain clients:
|
|
406
|
+
|
|
407
|
+
| Module | Role |
|
|
408
|
+
| ------ | ---- |
|
|
409
|
+
| `AvesTransport` | HTTP + XML encode/decode + `invokeOp` (optional `bodyKey`) |
|
|
410
|
+
| `MasterRecordsClient` | search / upsert |
|
|
411
|
+
| `BookingClient` | booking file ops + search practices |
|
|
412
|
+
| `PackageCatalogClient` | package/program catalog |
|
|
413
|
+
| `client/types.ts` | `AvesClientDeps` / `AvesClientFlat` |
|
|
414
|
+
| `client/flat-aliases.ts` | bind flat compat methods from domain prototypes |
|
|
415
|
+
| `src/xml/` | XML root helpers + JSON ↔ XML |
|
|
416
|
+
|
|
417
|
+
Flat aliases (`client.createBooking`, …) are attached in the constructor — add a domain method once and both surfaces work.
|
|
418
|
+
|
|
419
|
+
Outbound path: validate → `createApiSchema` / `toWireBody` → `invokeOp` → XML POST.
|
|
420
|
+
|
|
421
|
+
---
|
|
290
422
|
|
|
291
423
|
## Types
|
|
292
424
|
|
|
293
425
|
```typescript
|
|
294
426
|
import type {
|
|
295
427
|
AvesClientOptions,
|
|
428
|
+
AvesClientDeps,
|
|
296
429
|
SearchMasterRecord,
|
|
297
430
|
SearchMasterRecordRS,
|
|
298
431
|
MasterRecordDetail,
|
|
@@ -306,6 +439,24 @@ import type {
|
|
|
306
439
|
SetFileServiceStatusRQ,
|
|
307
440
|
FilePaymentListRQ,
|
|
308
441
|
BookingStatusOnlyRS,
|
|
442
|
+
SearchBookingFileRQ,
|
|
443
|
+
SearchBookingFileRS,
|
|
444
|
+
AvesSearchRQ,
|
|
445
|
+
SearchPackageRS,
|
|
446
|
+
SearchServicesRS,
|
|
447
|
+
PackageDetailRQ,
|
|
448
|
+
PackageDetailRS,
|
|
449
|
+
CommitPackageRQ,
|
|
450
|
+
CommitPackageRS,
|
|
451
|
+
} from 'aves-sdk';
|
|
452
|
+
|
|
453
|
+
import {
|
|
454
|
+
AvesClient,
|
|
455
|
+
AvesTransport,
|
|
456
|
+
MasterRecordsClient,
|
|
457
|
+
BookingClient,
|
|
458
|
+
PackageCatalogClient,
|
|
459
|
+
AvesError,
|
|
309
460
|
} from 'aves-sdk';
|
|
310
461
|
```
|
|
311
462
|
|
|
@@ -315,6 +466,7 @@ MIT
|
|
|
315
466
|
|
|
316
467
|
## Links
|
|
317
468
|
|
|
469
|
+
- [Changelog](./CHANGELOG.md)
|
|
318
470
|
- [GitHub Repository](https://github.com/simoneguglielmi/aves-sdk)
|
|
319
471
|
- [NPM Package](https://npmjs.com/package/aves-sdk)
|
|
320
472
|
- [Issue Tracker](https://github.com/simoneguglielmi/aves-sdk/issues)
|