@agent-cards/commerce-sdk 0.18.10 → 0.18.11
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/dist/client.d.ts +2 -0
- package/dist/client.js +2 -1
- package/dist/model-view.d.ts +3 -2
- package/dist/model-view.js +11 -3
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -507,6 +507,8 @@ export interface BuyFlightItinerary {
|
|
|
507
507
|
export interface BuyFlightParty {
|
|
508
508
|
adults: number;
|
|
509
509
|
children: number;
|
|
510
|
+
/** How many of `children` fly on an adult's lap, under 2. Absent when none, and from an older API. */
|
|
511
|
+
infants?: number;
|
|
510
512
|
totalCents: number;
|
|
511
513
|
perPassengerCents?: number[];
|
|
512
514
|
}
|
package/dist/client.js
CHANGED
|
@@ -292,7 +292,8 @@ function partyOf(value) {
|
|
|
292
292
|
if (adults === null || children === null || totalCents === null || adults + children < 2)
|
|
293
293
|
return {};
|
|
294
294
|
const each = Array.isArray(value.perPassengerCents) ? value.perPassengerCents.map(num) : null;
|
|
295
|
-
|
|
295
|
+
const infants = num(value.infants);
|
|
296
|
+
return { party: { adults, children, ...(infants !== null && infants > 0 && infants <= children ? { infants } : {}), totalCents, ...(each && each.length === adults + children && each.every((c) => c !== null) ? { perPassengerCents: each } : {}) } };
|
|
296
297
|
}
|
|
297
298
|
function catalogOf(v) {
|
|
298
299
|
if (!isRecord(v))
|
package/dist/model-view.d.ts
CHANGED
|
@@ -213,8 +213,9 @@ export declare function productPrice(product: {
|
|
|
213
213
|
};
|
|
214
214
|
}): string | null;
|
|
215
215
|
/**
|
|
216
|
-
* Who a party's flight price covers, as every app shows it after the price: `for 2`,
|
|
217
|
-
* children fly. `$1,610 for 2` is the price of both
|
|
216
|
+
* Who a party's flight price covers, as every app shows it after the price: `for 2`, `for 2 adults and 1 child` when
|
|
217
|
+
* children fly, and `for 2 adults, 1 child, 1 infant` when an infant flies on a lap. `$1,610 for 2` is the price of both
|
|
218
|
+
* seats together. Every traveller is named, so a card never reads as a price for fewer people than fly.
|
|
218
219
|
*/
|
|
219
220
|
export declare function flightPartyWords(party: BuyFlightParty): string;
|
|
220
221
|
export declare function money(minor: number | null | undefined, currency: string | null | undefined): string | null;
|
package/dist/model-view.js
CHANGED
|
@@ -115,13 +115,21 @@ export function productPrice(product) {
|
|
|
115
115
|
return price !== null && product.priceFrom ? `from ${price}` : price;
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
|
-
* Who a party's flight price covers, as every app shows it after the price: `for 2`,
|
|
119
|
-
* children fly. `$1,610 for 2` is the price of both
|
|
118
|
+
* Who a party's flight price covers, as every app shows it after the price: `for 2`, `for 2 adults and 1 child` when
|
|
119
|
+
* children fly, and `for 2 adults, 1 child, 1 infant` when an infant flies on a lap. `$1,610 for 2` is the price of both
|
|
120
|
+
* seats together. Every traveller is named, so a card never reads as a price for fewer people than fly.
|
|
120
121
|
*/
|
|
121
122
|
export function flightPartyWords(party) {
|
|
122
123
|
if (party.children === 0)
|
|
123
124
|
return `for ${party.adults}`;
|
|
124
|
-
|
|
125
|
+
const lap = Math.min(Math.max(0, party.infants ?? 0), party.children);
|
|
126
|
+
const kids = party.children - lap;
|
|
127
|
+
const groups = [
|
|
128
|
+
`${party.adults} adult${party.adults === 1 ? '' : 's'}`,
|
|
129
|
+
...(kids ? [`${kids} ${kids === 1 ? 'child' : 'children'}`] : []),
|
|
130
|
+
...(lap ? [`${lap} infant${lap === 1 ? '' : 's'}`] : []),
|
|
131
|
+
];
|
|
132
|
+
return `for ${groups.length === 2 ? groups.join(' and ') : groups.join(', ')}`;
|
|
125
133
|
}
|
|
126
134
|
export function money(minor, currency) {
|
|
127
135
|
if (typeof minor !== 'number' || !Number.isFinite(minor))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-cards/commerce-sdk",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.11",
|
|
4
4
|
"description": "Give your agent one tool that buys for your shoppers at real stores, and post each purchase update Agentcard sends into the shopper's chat, over a connection your server opens or a webhook endpoint.",
|
|
5
5
|
"homepage": "https://opencommerce.sh",
|
|
6
6
|
"type": "module",
|