@voyant-travel/trips 0.110.2
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/LICENSE +201 -0
- package/README.md +38 -0
- package/dist/catalog-component-adapter.d.ts +16 -0
- package/dist/catalog-component-adapter.d.ts.map +1 -0
- package/dist/catalog-component-adapter.js +34 -0
- package/dist/cruise-extension.d.ts +48 -0
- package/dist/cruise-extension.d.ts.map +1 -0
- package/dist/cruise-extension.js +66 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/mcp-contract.d.ts +79 -0
- package/dist/mcp-contract.d.ts.map +1 -0
- package/dist/mcp-contract.js +21 -0
- package/dist/mcp-registry.d.ts +48 -0
- package/dist/mcp-registry.d.ts.map +1 -0
- package/dist/mcp-registry.js +88 -0
- package/dist/mcp-tools.d.ts +157 -0
- package/dist/mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools.js +109 -0
- package/dist/routes.d.ts +2068 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +280 -0
- package/dist/schema.d.ts +1897 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +255 -0
- package/dist/service-cancellation.d.ts +6 -0
- package/dist/service-cancellation.d.ts.map +1 -0
- package/dist/service-cancellation.js +251 -0
- package/dist/service-checkout.d.ts +6 -0
- package/dist/service-checkout.d.ts.map +1 -0
- package/dist/service-checkout.js +328 -0
- package/dist/service-helpers.d.ts +17 -0
- package/dist/service-helpers.d.ts.map +1 -0
- package/dist/service-helpers.js +161 -0
- package/dist/service-internals.d.ts +11 -0
- package/dist/service-internals.d.ts.map +1 -0
- package/dist/service-internals.js +72 -0
- package/dist/service-pricing.d.ts +8 -0
- package/dist/service-pricing.d.ts.map +1 -0
- package/dist/service-pricing.js +142 -0
- package/dist/service-reservation.d.ts +5 -0
- package/dist/service-reservation.d.ts.map +1 -0
- package/dist/service-reservation.js +493 -0
- package/dist/service-snapshots.d.ts +8 -0
- package/dist/service-snapshots.d.ts.map +1 -0
- package/dist/service-snapshots.js +115 -0
- package/dist/service-trips.d.ts +14 -0
- package/dist/service-trips.d.ts.map +1 -0
- package/dist/service-trips.js +378 -0
- package/dist/service-types.d.ts +285 -0
- package/dist/service-types.d.ts.map +1 -0
- package/dist/service-types.js +6 -0
- package/dist/service.d.ts +38 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +40 -0
- package/dist/traveler-party-validation.d.ts +3 -0
- package/dist/traveler-party-validation.d.ts.map +1 -0
- package/dist/traveler-party-validation.js +68 -0
- package/dist/validation.d.ts +449 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +261 -0
- package/package.json +83 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may accept and charge a
|
|
167
|
+
fee for, the acceptance of support, warranty, indemnity, or
|
|
168
|
+
other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 PixelMakers Studio SRL
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @voyant-travel/trips
|
|
2
|
+
|
|
3
|
+
Deterministic composition layer for customer-facing trips that group multiple
|
|
4
|
+
component bookings/orders into one itinerary, pricing, reserve, checkout, and
|
|
5
|
+
support experience.
|
|
6
|
+
|
|
7
|
+
This package is landing on the trips integration branch. It currently
|
|
8
|
+
includes the durable schema, Zod contracts, deterministic trip service,
|
|
9
|
+
catalog component adapter, price aggregation, reserve workflow, checkout
|
|
10
|
+
handoff, component-level cancellation preview/cancel operations, Cruise
|
|
11
|
+
Extension representation helpers, Hono routes, and MCP tools. Checkout and
|
|
12
|
+
cancellation are dependency-injected so app/runtime packages keep owning
|
|
13
|
+
payment-provider, bank-transfer, storefront URL, supplier, and staff-remediation
|
|
14
|
+
policy. See
|
|
15
|
+
`docs/architecture/trips-implementation-plan.md` for the full PR
|
|
16
|
+
sequence and remaining slices.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pnpm add @voyant-travel/trips
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Exports
|
|
25
|
+
|
|
26
|
+
| Entry | Description |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| `.` | Module export |
|
|
29
|
+
| `./schema` | Drizzle tables, added in the schema slice |
|
|
30
|
+
| `./validation` | Zod contracts |
|
|
31
|
+
| `./service` | Deterministic composer services |
|
|
32
|
+
| `./mcp-tools` | AI-safe trip planning, revision, price, and reserve tools |
|
|
33
|
+
| `./cruise-extension` | Cruise Extension link and selection helpers |
|
|
34
|
+
| `./routes` | Hono route factory/module routes |
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
Apache-2.0
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type BookingDraftV1, type TravelerEntryV1 } from "@voyant-travel/catalog/booking-engine/contracts";
|
|
2
|
+
import type { TripComponent } from "./schema.js";
|
|
3
|
+
export interface CatalogComponentBookingDraftOverrides {
|
|
4
|
+
configure?: Partial<BookingDraftV1["configure"]>;
|
|
5
|
+
billing?: Partial<BookingDraftV1["billing"]>;
|
|
6
|
+
travelers?: TravelerEntryV1[];
|
|
7
|
+
accommodation?: BookingDraftV1["accommodation"];
|
|
8
|
+
addons?: BookingDraftV1["addons"];
|
|
9
|
+
payment?: Partial<BookingDraftV1["payment"]>;
|
|
10
|
+
promotionCode?: string;
|
|
11
|
+
internalNotes?: string;
|
|
12
|
+
customerNotes?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function isCatalogBackedTripComponent(component: Pick<TripComponent, "kind" | "entityModule" | "entityId" | "sourceKind">): boolean;
|
|
15
|
+
export declare function toBookingDraftV1(component: Pick<TripComponent, "kind" | "entityModule" | "entityId" | "sourceKind" | "sourceConnectionId" | "sourceRef">, overrides?: CatalogComponentBookingDraftOverrides): BookingDraftV1;
|
|
16
|
+
//# sourceMappingURL=catalog-component-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-component-adapter.d.ts","sourceRoot":"","sources":["../src/catalog-component-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,eAAe,EACrB,MAAM,iDAAiD,CAAA;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGhD,MAAM,WAAW,qCAAqC;IACpD,SAAS,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAA;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAA;IAC5C,SAAS,CAAC,EAAE,eAAe,EAAE,CAAA;IAC7B,aAAa,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAA;IAC/C,MAAM,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAA;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,GAAG,UAAU,GAAG,YAAY,CAAC,GAClF,OAAO,CAOT;AAED,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,IAAI,CACb,aAAa,EACb,MAAM,GAAG,cAAc,GAAG,UAAU,GAAG,YAAY,GAAG,oBAAoB,GAAG,WAAW,CACzF,EACD,SAAS,GAAE,qCAA0C,GACpD,cAAc,CA4BhB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { bookingDraftV1, } from "@voyant-travel/catalog/booking-engine/contracts";
|
|
2
|
+
import { TripsInvariantError } from "./service.js";
|
|
3
|
+
export function isCatalogBackedTripComponent(component) {
|
|
4
|
+
return Boolean(component.kind === "catalog_booking" &&
|
|
5
|
+
component.entityModule &&
|
|
6
|
+
component.entityId &&
|
|
7
|
+
component.sourceKind);
|
|
8
|
+
}
|
|
9
|
+
export function toBookingDraftV1(component, overrides = {}) {
|
|
10
|
+
if (!isCatalogBackedTripComponent(component)) {
|
|
11
|
+
throw new TripsInvariantError("Trip component cannot be mapped to a booking draft without catalog entity refs");
|
|
12
|
+
}
|
|
13
|
+
return bookingDraftV1.parse({
|
|
14
|
+
entity: {
|
|
15
|
+
module: component.entityModule,
|
|
16
|
+
id: component.entityId,
|
|
17
|
+
sourceKind: component.sourceKind,
|
|
18
|
+
sourceConnectionId: component.sourceConnectionId ?? undefined,
|
|
19
|
+
sourceRef: component.sourceRef ?? undefined,
|
|
20
|
+
},
|
|
21
|
+
configure: {
|
|
22
|
+
pax: {},
|
|
23
|
+
...overrides.configure,
|
|
24
|
+
},
|
|
25
|
+
billing: overrides.billing,
|
|
26
|
+
travelers: overrides.travelers,
|
|
27
|
+
accommodation: overrides.accommodation,
|
|
28
|
+
addons: overrides.addons,
|
|
29
|
+
payment: overrides.payment,
|
|
30
|
+
promotionCode: overrides.promotionCode,
|
|
31
|
+
internalNotes: overrides.internalNotes,
|
|
32
|
+
customerNotes: overrides.customerNotes,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CreateTripComponentInput } from "./validation.js";
|
|
2
|
+
export declare const CRUISE_EXTENSION_METADATA_KIND = "cruise_extension";
|
|
3
|
+
export type CruiseExtensionTargetKind = "cruise" | "cruise_sailing";
|
|
4
|
+
export type CruiseExtensionPlacement = "pre" | "post" | "either";
|
|
5
|
+
export type CruiseExtensionLifecycle = "dependent_extra" | "independent_component";
|
|
6
|
+
export interface CruiseExtensionLinkInput {
|
|
7
|
+
extensionProductId: string;
|
|
8
|
+
targetKind: CruiseExtensionTargetKind;
|
|
9
|
+
targetId: string;
|
|
10
|
+
linkKey?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CruiseExtensionLinkCommand {
|
|
13
|
+
linkKey: string;
|
|
14
|
+
leftId: string;
|
|
15
|
+
rightId: string;
|
|
16
|
+
}
|
|
17
|
+
export interface CruiseExtensionSelection {
|
|
18
|
+
extensionProductId: string;
|
|
19
|
+
targetKind: CruiseExtensionTargetKind;
|
|
20
|
+
targetId: string;
|
|
21
|
+
placement: CruiseExtensionPlacement;
|
|
22
|
+
lifecycle: CruiseExtensionLifecycle;
|
|
23
|
+
quantity?: number;
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export interface CruiseExtensionExtra {
|
|
27
|
+
kind: typeof CRUISE_EXTENSION_METADATA_KIND;
|
|
28
|
+
productId: string;
|
|
29
|
+
targetKind: CruiseExtensionTargetKind;
|
|
30
|
+
targetId: string;
|
|
31
|
+
placement: CruiseExtensionPlacement;
|
|
32
|
+
quantity: number;
|
|
33
|
+
metadata: Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
export type CruiseExtensionRepresentation = {
|
|
36
|
+
mode: "nested_extra";
|
|
37
|
+
extra: CruiseExtensionExtra;
|
|
38
|
+
} | {
|
|
39
|
+
mode: "sibling_component";
|
|
40
|
+
component: CreateTripComponentInput;
|
|
41
|
+
};
|
|
42
|
+
export declare function cruiseExtensionLinkKey(targetKind: CruiseExtensionTargetKind): string;
|
|
43
|
+
export declare function createCruiseExtensionLinkCommand(input: CruiseExtensionLinkInput): CruiseExtensionLinkCommand;
|
|
44
|
+
export declare function createCruiseExtensionExtra(selection: CruiseExtensionSelection): CruiseExtensionExtra;
|
|
45
|
+
export declare function createCruiseExtensionComponent(envelopeId: string, selection: CruiseExtensionSelection, sequence?: number): CreateTripComponentInput;
|
|
46
|
+
export declare function representCruiseExtensionSelection(envelopeId: string, selection: CruiseExtensionSelection, sequence?: number): CruiseExtensionRepresentation;
|
|
47
|
+
export declare function groupCruiseExtensionLinksByProduct(links: CruiseExtensionLinkInput[]): Map<string, CruiseExtensionLinkInput[]>;
|
|
48
|
+
//# sourceMappingURL=cruise-extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cruise-extension.d.ts","sourceRoot":"","sources":["../src/cruise-extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAE/D,eAAO,MAAM,8BAA8B,qBAAqB,CAAA;AAEhE,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG,gBAAgB,CAAA;AACnE,MAAM,MAAM,wBAAwB,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAA;AAChE,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,GAAG,uBAAuB,CAAA;AAElF,MAAM,WAAW,wBAAwB;IACvC,kBAAkB,EAAE,MAAM,CAAA;IAC1B,UAAU,EAAE,yBAAyB,CAAA;IACrC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,kBAAkB,EAAE,MAAM,CAAA;IAC1B,UAAU,EAAE,yBAAyB,CAAA;IACrC,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,wBAAwB,CAAA;IACnC,SAAS,EAAE,wBAAwB,CAAA;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,OAAO,8BAA8B,CAAA;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,yBAAyB,CAAA;IACrC,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,wBAAwB,CAAA;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC;AAED,MAAM,MAAM,6BAA6B,GACrC;IACE,IAAI,EAAE,cAAc,CAAA;IACpB,KAAK,EAAE,oBAAoB,CAAA;CAC5B,GACD;IACE,IAAI,EAAE,mBAAmB,CAAA;IACzB,SAAS,EAAE,wBAAwB,CAAA;CACpC,CAAA;AAEL,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,yBAAyB,GAAG,MAAM,CAIpF;AAED,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,wBAAwB,GAC9B,0BAA0B,CAM5B;AAED,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,wBAAwB,GAClC,oBAAoB,CAUtB;AAED,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,wBAAwB,EACnC,QAAQ,SAAI,GACX,wBAAwB,CAoB1B;AAED,wBAAgB,iCAAiC,CAC/C,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,wBAAwB,EACnC,QAAQ,SAAI,GACX,6BAA6B,CAY/B;AAED,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,wBAAwB,EAAE,GAChC,GAAG,CAAC,MAAM,EAAE,wBAAwB,EAAE,CAAC,CAQzC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export const CRUISE_EXTENSION_METADATA_KIND = "cruise_extension";
|
|
2
|
+
export function cruiseExtensionLinkKey(targetKind) {
|
|
3
|
+
return targetKind === "cruise"
|
|
4
|
+
? "cruiseProductExtensionLink"
|
|
5
|
+
: "cruiseSailingProductExtensionLink";
|
|
6
|
+
}
|
|
7
|
+
export function createCruiseExtensionLinkCommand(input) {
|
|
8
|
+
return {
|
|
9
|
+
linkKey: input.linkKey ?? cruiseExtensionLinkKey(input.targetKind),
|
|
10
|
+
leftId: input.targetId,
|
|
11
|
+
rightId: input.extensionProductId,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export function createCruiseExtensionExtra(selection) {
|
|
15
|
+
return {
|
|
16
|
+
kind: CRUISE_EXTENSION_METADATA_KIND,
|
|
17
|
+
productId: selection.extensionProductId,
|
|
18
|
+
targetKind: selection.targetKind,
|
|
19
|
+
targetId: selection.targetId,
|
|
20
|
+
placement: selection.placement,
|
|
21
|
+
quantity: selection.quantity ?? 1,
|
|
22
|
+
metadata: selection.metadata ?? {},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function createCruiseExtensionComponent(envelopeId, selection, sequence = 0) {
|
|
26
|
+
return {
|
|
27
|
+
envelopeId,
|
|
28
|
+
sequence,
|
|
29
|
+
kind: "catalog_booking",
|
|
30
|
+
catalogRef: {
|
|
31
|
+
entityModule: "products",
|
|
32
|
+
entityId: selection.extensionProductId,
|
|
33
|
+
sourceKind: "owned",
|
|
34
|
+
},
|
|
35
|
+
metadata: {
|
|
36
|
+
kind: CRUISE_EXTENSION_METADATA_KIND,
|
|
37
|
+
targetKind: selection.targetKind,
|
|
38
|
+
targetId: selection.targetId,
|
|
39
|
+
placement: selection.placement,
|
|
40
|
+
lifecycle: selection.lifecycle,
|
|
41
|
+
quantity: selection.quantity ?? 1,
|
|
42
|
+
...(selection.metadata ?? {}),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function representCruiseExtensionSelection(envelopeId, selection, sequence = 0) {
|
|
47
|
+
if (selection.lifecycle === "dependent_extra") {
|
|
48
|
+
return {
|
|
49
|
+
mode: "nested_extra",
|
|
50
|
+
extra: createCruiseExtensionExtra(selection),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
mode: "sibling_component",
|
|
55
|
+
component: createCruiseExtensionComponent(envelopeId, selection, sequence),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export function groupCruiseExtensionLinksByProduct(links) {
|
|
59
|
+
const grouped = new Map();
|
|
60
|
+
for (const link of links) {
|
|
61
|
+
const existing = grouped.get(link.extensionProductId) ?? [];
|
|
62
|
+
existing.push(link);
|
|
63
|
+
grouped.set(link.extensionProductId, existing);
|
|
64
|
+
}
|
|
65
|
+
return grouped;
|
|
66
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Module } from "@voyant-travel/core";
|
|
2
|
+
import type { HonoModule } from "@voyant-travel/hono/module";
|
|
3
|
+
import { type TripsRoutesOptions } from "./routes.js";
|
|
4
|
+
export { type CatalogComponentBookingDraftOverrides, isCatalogBackedTripComponent, toBookingDraftV1, } from "./catalog-component-adapter.js";
|
|
5
|
+
export { CRUISE_EXTENSION_METADATA_KIND, type CruiseExtensionExtra, type CruiseExtensionLifecycle, type CruiseExtensionLinkCommand, type CruiseExtensionLinkInput, type CruiseExtensionPlacement, type CruiseExtensionRepresentation, type CruiseExtensionSelection, type CruiseExtensionTargetKind, createCruiseExtensionComponent, createCruiseExtensionExtra, createCruiseExtensionLinkCommand, cruiseExtensionLinkKey, groupCruiseExtensionLinksByProduct, representCruiseExtensionSelection, } from "./cruise-extension.js";
|
|
6
|
+
export type { TripsRoutes, TripsRoutesOptions } from "./routes.js";
|
|
7
|
+
export { createTripsRoutes } from "./routes.js";
|
|
8
|
+
export declare const tripsModule: Module;
|
|
9
|
+
export declare const tripsHonoModule: HonoModule;
|
|
10
|
+
export interface TripsHonoModuleOptions extends TripsRoutesOptions {
|
|
11
|
+
publicRoutes?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function createTripsHonoModule(options?: TripsHonoModuleOptions): HonoModule;
|
|
14
|
+
export type { McpToolContent, McpToolContext, McpToolDefinition, McpToolErrorCode, McpToolHandler, McpToolResult, } from "./mcp-contract.js";
|
|
15
|
+
export { McpToolError } from "./mcp-contract.js";
|
|
16
|
+
export { type CreateMcpToolRegistryOptions, createMcpToolRegistry, enforceAudienceAuthorization, type McpToolListEntry, type McpToolRegistry, requireService, } from "./mcp-registry.js";
|
|
17
|
+
export { type CreateTripArgs, createTripTool, type PriceTripArgs, priceTripTool, type ReserveTripArgs, type ReviseTripArgs, reserveTripTool, reviseTripTool, type TripsMcpServices, tripsMcpTools, } from "./mcp-tools.js";
|
|
18
|
+
export { tripsRoutes } from "./routes.js";
|
|
19
|
+
export type { NewTripComponent, NewTripComponentEvent, NewTripEnvelope, NewTripReservationPlan, NewTripSnapshot, TripComponent, TripComponentEvent, TripComponentPricingSnapshot, TripComponentTaxLineSnapshot, TripEnvelope, TripEnvelopePricingSnapshot, TripReservationPlan, TripReservationPlanCompensationSnapshot, TripReservationPlanComponentSnapshot, TripReservationPlanFailureSnapshot, TripSnapshot, TripSnapshotProposal, TripSnapshotProposalLine, } from "./schema.js";
|
|
20
|
+
export { tripComponentEvents, tripComponentEventTypeEnum, tripComponentKindEnum, tripComponentStatusEnum, tripComponents, tripEnvelopeStatusEnum, tripEnvelopes, tripReservationPlanStatusEnum, tripReservationPlans, tripSnapshots, } from "./schema.js";
|
|
21
|
+
export { aggregateComponentPricing, applyQuoteToComponent, assertTripComponentCanBeReserved, assertTripComponentCanBeUpdated, assertTripComponentCanReceiveRefs, assertTripComponentCanStartCheckout, buildTripSnapshotProposal, type CancelComponentInput, type CancelComponentResult, type CancelTripComponentsDeps, type CancelTripComponentsResult, type CatalogComponentQuoteInput, type CheckoutHandoffKind, type CompleteTripCheckoutInput, type CompleteTripCheckoutResult, type ComponentCancellationAction, type ComponentCancellationPreview, type ComponentCancellationPreviewInput, type ComponentCheckoutInput, type ComponentCheckoutResult, checkoutResultToComponentPatch, completeTripCheckout, freezeTripSnapshot, getTripSnapshotById, hasCommittedComponentReference, listTripSnapshots, type PreviewTripCancellationDeps, type PriceTripDeps, type PriceTripResult, pricingSnapshotFromBreakdown, type ReleaseReservedComponentInput, type ReleaseReservedComponentResult, type ReserveComponentInput, type ReserveComponentPreflightResult, type ReserveComponentPreflightStatus, type ReserveComponentResult, type ReserveTripDeps, type ReserveTripResult, reserveResultToComponentPatch, type StartCheckoutDeps, type StartCheckoutResult, type StartCheckoutTarget, type StartedTripComponentCheckout, type SubmitTripReservationPlanComponent, type SubmitTripReservationPlanInput, type SubmitTripReservationPlanResult, shouldReplayCheckout, shouldReplayReserve, type Trip, type TripCancellationPreviewResult, type TripCheckoutInput, type TripCheckoutResult, type TripListResult, type TripReservationPlanComponentKind, TripsInvariantError, taxLinesFromBreakdown, tripsService, } from "./service.js";
|
|
22
|
+
export { assertTripTravelerPartyComplete, validateTripTravelerParty, } from "./traveler-party-validation.js";
|
|
23
|
+
export { type CancelTripComponentsInput, type CreateTripComponentBodyInput, type CreateTripComponentInput, type CreateTripEnvelopeInput, type CreateTripSnapshotInput, cancelTripComponentsSchema, catalogComponentReferenceSchema, committedComponentReferenceSchema, createTripComponentBodySchema, createTripComponentSchema, createTripEnvelopeSchema, createTripSnapshotSchema, isAllowedTripComponentStatusTransition, isTerminalTripComponentStatus, type ListTripsQuery, listTripsQuerySchema, type PreviewTripCancellationInput, type PriceTripInput, previewTripCancellationSchema, priceTripSchema, type ReserveTripInput, reorderTripComponentsSchema, reserveTripSchema, type StartTripCheckoutInput, startTripCheckoutSchema, type TripComponentEventType, type TripComponentKind, type TripComponentStatus, type TripEnvelopeStatus, type TripsHealthCheck, type TripsListSortDir, type TripsListSortField, type TripsStatus, tripComponentEventTypeSchema, tripComponentKindSchema, tripComponentPricingSnapshotSchema, tripComponentStatusSchema, tripComponentStatusTransitionSchema, tripComponentTaxLineSchema, tripEnvelopePricingSnapshotSchema, tripEnvelopeStatusSchema, tripSnapshotProposalLineSchema, tripSnapshotProposalSchema, tripsHealthCheckSchema, tripsListSortDirSchema, tripsListSortFieldSchema, tripsStatusSchema, type UpdateTripComponentInput, updateTripComponentRefsSchema, updateTripComponentSchema, updateTripEnvelopeSchema, } from "./validation.js";
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAqB,KAAK,kBAAkB,EAAe,MAAM,aAAa,CAAA;AAErF,OAAO,EACL,KAAK,qCAAqC,EAC1C,4BAA4B,EAC5B,gBAAgB,GACjB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,8BAA8B,EAC9B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,8BAA8B,EAC9B,0BAA0B,EAC1B,gCAAgC,EAChC,sBAAsB,EACtB,kCAAkC,EAClC,iCAAiC,GAClC,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAE/C,eAAO,MAAM,WAAW,EAAE,MAEzB,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,UAG7B,CAAA;AAED,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,cAWzE;AAED,YAAY,EACV,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,aAAa,GACd,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CA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AAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,4BAA4B,EAC5B,uBAAuB,EACvB,kCAAkC,EAClC,yBAAyB,EACzB,mCAAmC,EACnC,0BAA0B,EAC1B,iCAAiC,EACjC,wBAAwB,EACxB,8BAA8B,EAC9B,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,6BAA6B,EAC7B,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,iBAAiB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createTripsRoutes, tripsRoutes } from "./routes.js";
|
|
2
|
+
export { isCatalogBackedTripComponent, toBookingDraftV1, } from "./catalog-component-adapter.js";
|
|
3
|
+
export { CRUISE_EXTENSION_METADATA_KIND, createCruiseExtensionComponent, createCruiseExtensionExtra, createCruiseExtensionLinkCommand, cruiseExtensionLinkKey, groupCruiseExtensionLinksByProduct, representCruiseExtensionSelection, } from "./cruise-extension.js";
|
|
4
|
+
export { createTripsRoutes } from "./routes.js";
|
|
5
|
+
export const tripsModule = {
|
|
6
|
+
name: "trips",
|
|
7
|
+
};
|
|
8
|
+
export const tripsHonoModule = {
|
|
9
|
+
module: tripsModule,
|
|
10
|
+
adminRoutes: tripsRoutes,
|
|
11
|
+
};
|
|
12
|
+
export function createTripsHonoModule(options = {}) {
|
|
13
|
+
const { publicRoutes = false, ...routeOptions } = options;
|
|
14
|
+
const routes = createTripsRoutes({ ...routeOptions, surface: "admin" });
|
|
15
|
+
const honoModule = {
|
|
16
|
+
module: tripsModule,
|
|
17
|
+
adminRoutes: routes,
|
|
18
|
+
};
|
|
19
|
+
if (publicRoutes) {
|
|
20
|
+
honoModule.publicRoutes = createTripsRoutes({ ...routeOptions, surface: "public" });
|
|
21
|
+
}
|
|
22
|
+
return honoModule;
|
|
23
|
+
}
|
|
24
|
+
export { McpToolError } from "./mcp-contract.js";
|
|
25
|
+
export { createMcpToolRegistry, enforceAudienceAuthorization, requireService, } from "./mcp-registry.js";
|
|
26
|
+
export { createTripTool, priceTripTool, reserveTripTool, reviseTripTool, tripsMcpTools, } from "./mcp-tools.js";
|
|
27
|
+
export { tripsRoutes } from "./routes.js";
|
|
28
|
+
export { tripComponentEvents, tripComponentEventTypeEnum, tripComponentKindEnum, tripComponentStatusEnum, tripComponents, tripEnvelopeStatusEnum, tripEnvelopes, tripReservationPlanStatusEnum, tripReservationPlans, tripSnapshots, } from "./schema.js";
|
|
29
|
+
export { aggregateComponentPricing, applyQuoteToComponent, assertTripComponentCanBeReserved, assertTripComponentCanBeUpdated, assertTripComponentCanReceiveRefs, assertTripComponentCanStartCheckout, buildTripSnapshotProposal, checkoutResultToComponentPatch, completeTripCheckout, freezeTripSnapshot, getTripSnapshotById, hasCommittedComponentReference, listTripSnapshots, pricingSnapshotFromBreakdown, reserveResultToComponentPatch, shouldReplayCheckout, shouldReplayReserve, TripsInvariantError, taxLinesFromBreakdown, tripsService, } from "./service.js";
|
|
30
|
+
export { assertTripTravelerPartyComplete, validateTripTravelerParty, } from "./traveler-party-validation.js";
|
|
31
|
+
export { cancelTripComponentsSchema, catalogComponentReferenceSchema, committedComponentReferenceSchema, createTripComponentBodySchema, createTripComponentSchema, createTripEnvelopeSchema, createTripSnapshotSchema, isAllowedTripComponentStatusTransition, isTerminalTripComponentStatus, listTripsQuerySchema, previewTripCancellationSchema, priceTripSchema, reorderTripComponentsSchema, reserveTripSchema, startTripCheckoutSchema, tripComponentEventTypeSchema, tripComponentKindSchema, tripComponentPricingSnapshotSchema, tripComponentStatusSchema, tripComponentStatusTransitionSchema, tripComponentTaxLineSchema, tripEnvelopePricingSnapshotSchema, tripEnvelopeStatusSchema, tripSnapshotProposalLineSchema, tripSnapshotProposalSchema, tripsHealthCheckSchema, tripsListSortDirSchema, tripsListSortFieldSchema, tripsStatusSchema, updateTripComponentRefsSchema, updateTripComponentSchema, updateTripEnvelopeSchema, } from "./validation.js";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport-agnostic tool contract for trips agent commands.
|
|
3
|
+
*
|
|
4
|
+
* Catalog agent access now goes through the catalog HTTP APIs directly; this
|
|
5
|
+
* small contract remains only for the trips command tools exposed by
|
|
6
|
+
* operator runtimes.
|
|
7
|
+
*/
|
|
8
|
+
import type { ResolverScope, Visibility } from "@voyant-travel/catalog";
|
|
9
|
+
import type { z } from "zod";
|
|
10
|
+
/**
|
|
11
|
+
* Per-request context passed to every tool handler.
|
|
12
|
+
*
|
|
13
|
+
* Templates construct this once per agent connection (typically derived
|
|
14
|
+
* from the agent's API key / OAuth token / session). The MCP transport
|
|
15
|
+
* passes the same context to every tool dispatch in that session.
|
|
16
|
+
*/
|
|
17
|
+
export interface McpToolContext {
|
|
18
|
+
/** The actor identity. Drives visibility filtering at every layer. */
|
|
19
|
+
actor: Visibility;
|
|
20
|
+
/** Tenant / operator identifier — usually synthesized into provenance. */
|
|
21
|
+
tenantId: string;
|
|
22
|
+
/** Default scope for tools that need locale / audience / market. */
|
|
23
|
+
defaultScope: ResolverScope;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* MCP tool definition. The name + description are surfaced to the LLM;
|
|
27
|
+
* `inputSchema` validates and types the args; `handler` is the actual
|
|
28
|
+
* implementation.
|
|
29
|
+
*
|
|
30
|
+
* MCP standardly uses JSON Schema for inputSchema; we use Zod here and
|
|
31
|
+
* the registry helper exports a `toJsonSchema` adapter consumers wire
|
|
32
|
+
* into their MCP transport.
|
|
33
|
+
*/
|
|
34
|
+
export interface McpToolDefinition<TArgs = unknown, TResult = McpToolResult> {
|
|
35
|
+
/** Tool name, surfaced to the LLM. Convention: snake_case. */
|
|
36
|
+
name: string;
|
|
37
|
+
/** Human-readable description shown to the LLM. */
|
|
38
|
+
description: string;
|
|
39
|
+
/** Zod schema for the args; the dispatcher parses + validates. */
|
|
40
|
+
inputSchema: z.ZodType<TArgs>;
|
|
41
|
+
/** Handler — receives parsed args + context, returns the result. */
|
|
42
|
+
handler: McpToolHandler<TArgs, TResult>;
|
|
43
|
+
}
|
|
44
|
+
export type McpToolHandler<TArgs, TResult> = (args: TArgs, context: McpToolContext) => Promise<TResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Standard MCP tool result envelope. Mirrors MCP's `CallToolResult` shape:
|
|
47
|
+
* a `content` array of typed items (text, structured data) plus an optional
|
|
48
|
+
* `isError` flag for soft errors that the LLM should see.
|
|
49
|
+
*/
|
|
50
|
+
export interface McpToolResult {
|
|
51
|
+
content: McpToolContent[];
|
|
52
|
+
isError?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Optional structured data the LLM can act on programmatically. Mirrors
|
|
55
|
+
* the MCP SDK's `structuredContent` field.
|
|
56
|
+
*/
|
|
57
|
+
structuredContent?: Record<string, unknown>;
|
|
58
|
+
}
|
|
59
|
+
export type McpToolContent = {
|
|
60
|
+
type: "text";
|
|
61
|
+
text: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: "resource";
|
|
64
|
+
resource: {
|
|
65
|
+
uri: string;
|
|
66
|
+
mimeType?: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Standard error class for tool failures. The dispatcher catches these
|
|
71
|
+
* and translates them into MCP's standard error envelope.
|
|
72
|
+
*/
|
|
73
|
+
export declare class McpToolError extends Error {
|
|
74
|
+
readonly code: McpToolErrorCode;
|
|
75
|
+
readonly meta?: Record<string, unknown> | undefined;
|
|
76
|
+
constructor(message: string, code: McpToolErrorCode, meta?: Record<string, unknown> | undefined);
|
|
77
|
+
}
|
|
78
|
+
export type McpToolErrorCode = "MISSING_SERVICE" | "AUTHORIZATION_DENIED" | "NOT_FOUND" | "INVALID_INPUT" | "PROVIDER_ERROR";
|
|
79
|
+
//# sourceMappingURL=mcp-contract.d.ts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AAE,UAAU,CAAC;IAAC,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAA;AAEtE;;;GAGG;AACH,qBAAa,YAAa,SAAQ,KAAK;aAGnB,IAAI,EAAE,gBAAgB;aACtB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAF9C,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,gBAAgB,EACtB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAKjD;AAED,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,sBAAsB,GACtB,WAAW,GACX,eAAe,GACf,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport-agnostic tool contract for trips agent commands.
|
|
3
|
+
*
|
|
4
|
+
* Catalog agent access now goes through the catalog HTTP APIs directly; this
|
|
5
|
+
* small contract remains only for the trips command tools exposed by
|
|
6
|
+
* operator runtimes.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Standard error class for tool failures. The dispatcher catches these
|
|
10
|
+
* and translates them into MCP's standard error envelope.
|
|
11
|
+
*/
|
|
12
|
+
export class McpToolError extends Error {
|
|
13
|
+
code;
|
|
14
|
+
meta;
|
|
15
|
+
constructor(message, code, meta) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.meta = meta;
|
|
19
|
+
this.name = "McpToolError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport-agnostic registry for trips agent tools.
|
|
3
|
+
*/
|
|
4
|
+
import type { z } from "zod";
|
|
5
|
+
import type { McpToolContext, McpToolDefinition, McpToolResult } from "./mcp-contract.js";
|
|
6
|
+
export interface McpToolRegistry {
|
|
7
|
+
/** The context used for all tool dispatches in this registry. */
|
|
8
|
+
readonly context: McpToolContext;
|
|
9
|
+
/** Register a tool definition. Throws on duplicate name. */
|
|
10
|
+
register<TArgs>(tool: McpToolDefinition<TArgs, McpToolResult>): void;
|
|
11
|
+
/** List registered tool names — useful for the MCP `ListTools` request. */
|
|
12
|
+
list(): McpToolListEntry[];
|
|
13
|
+
/** Dispatch a tool call by name. Validates args with the tool's zod schema. */
|
|
14
|
+
dispatchTool(name: string, args: unknown): Promise<McpToolResult>;
|
|
15
|
+
/** Look up a registered tool. Returns `undefined` if not registered. */
|
|
16
|
+
get(name: string): McpToolDefinition<any, McpToolResult> | undefined;
|
|
17
|
+
}
|
|
18
|
+
export interface McpToolListEntry {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
/**
|
|
22
|
+
* Zod schema serialized as a placeholder JSON Schema. Templates that
|
|
23
|
+
* need actual JSON Schema for the MCP SDK should call `zod-to-json-schema`
|
|
24
|
+
* (or equivalent) on the tool's `inputSchema` before publishing.
|
|
25
|
+
*/
|
|
26
|
+
inputSchemaPreview: {
|
|
27
|
+
type: "object";
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface CreateMcpToolRegistryOptions {
|
|
32
|
+
context: McpToolContext;
|
|
33
|
+
}
|
|
34
|
+
export declare function createMcpToolRegistry(options: CreateMcpToolRegistryOptions): McpToolRegistry;
|
|
35
|
+
/**
|
|
36
|
+
* Helper for tools to assert that a required service was injected
|
|
37
|
+
* into the context. Throws `MISSING_SERVICE` if not, which the dispatcher
|
|
38
|
+
* translates into a structured error.
|
|
39
|
+
*/
|
|
40
|
+
export declare function requireService<T>(service: T | undefined, name: string): T;
|
|
41
|
+
/**
|
|
42
|
+
* Helper for tools that need to enforce per-actor authorization. Customer/
|
|
43
|
+
* partner/supplier actors are pinned to their own audience pool — staff
|
|
44
|
+
* actors may federate across pools.
|
|
45
|
+
*/
|
|
46
|
+
export declare function enforceAudienceAuthorization(actor: McpToolContext["actor"], requestedAudiences?: string[]): void;
|
|
47
|
+
export type { z };
|
|
48
|
+
//# sourceMappingURL=mcp-registry.d.ts.map
|