@duffel/components 3.1.3 → 3.1.4
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/components/DuffelAncillaries/Card.d.ts +14 -0
- package/components/DuffelAncillaries/Counter.d.ts +10 -0
- package/components/DuffelAncillaries/DuffelAncillaries.d.ts +3 -0
- package/components/DuffelAncillaries/DuffelAncillariesCustomElement.d.ts +12 -0
- package/components/DuffelAncillaries/bags/BaggageSelectionCard.d.ts +11 -0
- package/components/DuffelAncillaries/bags/BaggageSelectionController.d.ts +13 -0
- package/components/DuffelAncillaries/bags/BaggageSelectionModal.d.ts +11 -0
- package/components/DuffelAncillaries/bags/BaggageSelectionModalBody.d.ts +11 -0
- package/components/DuffelAncillaries/bags/BaggageSelectionModalBodyPassenger.d.ts +13 -0
- package/components/DuffelAncillaries/bags/BaggageSelectionModalFooter.d.ts +14 -0
- package/components/DuffelAncillaries/bags/BaggageSelectionModalHeader.d.ts +9 -0
- package/components/DuffelAncillaries/bags/IncludedBaggageBanner.d.ts +7 -0
- package/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionCard.d.ts +10 -0
- package/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModal.d.ts +11 -0
- package/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBody.d.ts +7 -0
- package/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBodyListItem.d.ts +4 -0
- package/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalFooter.d.ts +11 -0
- package/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalHeader.d.ts +2 -0
- package/components/DuffelAncillaries/seats/Amenity.d.ts +6 -0
- package/components/DuffelAncillaries/seats/DeckSelect.d.ts +15 -0
- package/components/DuffelAncillaries/seats/Element.d.ts +15 -0
- package/components/DuffelAncillaries/seats/EmptyElement.d.ts +2 -0
- package/components/DuffelAncillaries/seats/ExitElement.d.ts +6 -0
- package/components/DuffelAncillaries/seats/Legend.d.ts +12 -0
- package/components/DuffelAncillaries/seats/Row.d.ts +13 -0
- package/components/DuffelAncillaries/seats/RowSection.d.ts +17 -0
- package/components/DuffelAncillaries/seats/SeatElement.d.ts +13 -0
- package/components/DuffelAncillaries/seats/SeatInfo.d.ts +7 -0
- package/components/DuffelAncillaries/seats/SeatMap.d.ts +12 -0
- package/components/DuffelAncillaries/seats/SeatMapUnavailable.d.ts +2 -0
- package/components/DuffelAncillaries/seats/SeatSelectionCard.d.ts +13 -0
- package/components/DuffelAncillaries/seats/SeatSelectionModal.d.ts +13 -0
- package/components/DuffelAncillaries/seats/SeatSelectionModalBody.d.ts +4 -0
- package/components/DuffelAncillaries/seats/SeatSelectionModalFooter.d.ts +16 -0
- package/components/DuffelAncillaries/seats/SeatSelectionModalHeader.d.ts +10 -0
- package/components/DuffelAncillaries/seats/SeatUnavailable.d.ts +5 -0
- package/components/DuffelPayments/DuffelPayments.d.ts +11 -0
- package/components/DuffelPayments/DuffelPaymentsCustomElement.d.ts +13 -0
- package/components/PlacesLookup/PlacesLookup.d.ts +20 -0
- package/components/shared/AnimatedLoaderEllipsis.d.ts +2 -0
- package/components/shared/Button.d.ts +23 -0
- package/components/shared/ErrorBoundary.d.ts +13 -0
- package/components/shared/FetchOfferErrorState.d.ts +5 -0
- package/components/shared/Icon.d.ts +46 -0
- package/components/shared/IconButton.d.ts +16 -0
- package/components/shared/Modal.d.ts +11 -0
- package/components/shared/NonIdealState.d.ts +4 -0
- package/components/shared/Stamp.d.ts +7 -0
- package/components/shared/Tabs.d.ts +16 -0
- package/custom-elements.d.ts +6 -0
- package/custom-elements.js +40 -0
- package/custom-elements.js.map +7 -0
- package/index.js +40 -0
- package/index.js.map +7 -0
- package/lib/captureErrorInSentry.d.ts +1 -0
- package/lib/compileCreateOrderPayload.d.ts +14 -0
- package/lib/createPriceFormatters.d.ts +12 -0
- package/lib/fetchFromDuffelAPI.d.ts +8 -0
- package/lib/fetchFromFixtures.d.ts +4 -0
- package/lib/formatAvailableServices.d.ts +12 -0
- package/lib/formatDate.d.ts +2 -0
- package/lib/formatSeatMaps.d.ts +4 -0
- package/lib/getBaggageServiceDescription.d.ts +2 -0
- package/lib/getCabinsForSegmentAndDeck.d.ts +2 -0
- package/lib/getCurrencyForSeatMaps.d.ts +10 -0
- package/lib/getCurrencyForServices.d.ts +11 -0
- package/lib/getFirstSeatElementMatchingCriteria.d.ts +3 -0
- package/lib/getPassengerBySegmentList.d.ts +6 -0
- package/lib/getPassengerInitials.d.ts +1 -0
- package/lib/getPassengerMapById.d.ts +3 -0
- package/lib/getPassengerName.d.ts +3 -0
- package/lib/getRowNumber.d.ts +2 -0
- package/lib/getSegmentList.d.ts +2 -0
- package/lib/getServicePriceMapById.d.ts +3 -0
- package/lib/getSymbols.d.ts +2 -0
- package/lib/getTotalAmountForServices.d.ts +6 -0
- package/lib/getTotalQuantity.d.ts +2 -0
- package/lib/hasHighLuminance.d.ts +1 -0
- package/lib/hasService.d.ts +2 -0
- package/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.d.ts +3 -0
- package/lib/hasWings.d.ts +2 -0
- package/lib/isBaggageService.d.ts +2 -0
- package/lib/isCancelForAnyReasonService.d.ts +2 -0
- package/lib/isFixtureOfferId.d.ts +2 -0
- package/lib/isPayloadComplete.d.ts +2 -0
- package/lib/isSeatElement.d.ts +2 -0
- package/lib/logging.d.ts +46 -0
- package/lib/moneyStringFormatter.d.ts +8 -0
- package/lib/offerIsExpired.d.ts +2 -0
- package/lib/retrieveOffer.d.ts +2 -0
- package/lib/retrieveOfferFromDuffelAPI.d.ts +1 -0
- package/lib/retrieveSeatMaps.d.ts +2 -0
- package/lib/retrieveSeatMapsFromDuffelAPI.d.ts +1 -0
- package/lib/setBodyScrollability.d.ts +1 -0
- package/lib/validateProps.d.ts +7 -0
- package/lib/withPlural.d.ts +1 -0
- package/package.json +84 -134
- package/tsconfig.tsbuildinfo +1 -0
- package/types/Aircraft.d.ts +14 -0
- package/types/Airline.d.ts +14 -0
- package/types/Airport.d.ts +44 -0
- package/types/City.d.ts +18 -0
- package/types/CreateOrderPayload.d.ts +72 -0
- package/types/CurrencyConversion.d.ts +10 -0
- package/types/DuffelAncillariesProps.d.ts +70 -0
- package/types/Offer.d.ts +711 -0
- package/types/Order.d.ts +8 -0
- package/types/Place.d.ts +8 -0
- package/types/SeatMap.d.ts +190 -0
- package/.circleci/config.yml +0 -67
- package/.eslintrc.js +0 -47
- package/.github/CODEOWNERS +0 -4
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -29
- package/.github/renovate.json +0 -12
- package/.github/workflows/autoapprove.yml +0 -18
- package/.github/workflows/release.yml +0 -89
- package/.husky/post-commit +0 -4
- package/.husky/pre-commit +0 -4
- package/.nvmrc +0 -1
- package/.prettierignore +0 -2
- package/.storybook/Storyshots.test.js +0 -3
- package/.storybook/__snapshots__/Storyshots.test.js.snap +0 -67984
- package/.storybook/main.ts +0 -33
- package/.storybook/preview.tsx +0 -28
- package/.tool-versions +0 -1
- package/CONTRIBUTING.md +0 -83
- package/README.md +0 -68
- package/__mocks__/styleMock.js +0 -6
- package/babel.config.js +0 -20
- package/commitlint.config.js +0 -4
- package/config/esbuild.base.config.js +0 -18
- package/config/esbuild.cdn.config.js +0 -51
- package/config/esbuild.dev.config.js +0 -46
- package/config/esbuild.react.config.js +0 -42
- package/data/airports.csv +0 -9084
- package/data/cities.csv +0 -256
- package/jest.config.ts +0 -14
- package/react-dist/index.js +0 -37
- package/scripts/generate-fixture.ts +0 -200
- package/scripts/setup-suggestion-data.ts +0 -100
- package/scripts/upload-to-cdn.sh +0 -34
- package/scripts.tsconfig.json +0 -11
- package/src/components/DuffelAncillaries/Card.tsx +0 -126
- package/src/components/DuffelAncillaries/Counter.tsx +0 -40
- package/src/components/DuffelAncillaries/DuffelAncillaries.tsx +0 -350
- package/src/components/DuffelAncillaries/DuffelAncillariesCustomElement.tsx +0 -124
- package/src/components/DuffelAncillaries/bags/BaggageSelectionCard.tsx +0 -101
- package/src/components/DuffelAncillaries/bags/BaggageSelectionController.tsx +0 -88
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModal.tsx +0 -81
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModalBody.tsx +0 -60
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModalBodyPassenger.tsx +0 -122
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModalFooter.tsx +0 -88
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModalHeader.tsx +0 -82
- package/src/components/DuffelAncillaries/bags/IncludedBaggageBanner.tsx +0 -51
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionCard.tsx +0 -90
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModal.tsx +0 -63
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBody.tsx +0 -56
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBodyListItem.tsx +0 -11
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalFooter.tsx +0 -74
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalHeader.tsx +0 -9
- package/src/components/DuffelAncillaries/seats/Amenity.tsx +0 -21
- package/src/components/DuffelAncillaries/seats/DeckSelect.tsx +0 -27
- package/src/components/DuffelAncillaries/seats/Element.tsx +0 -52
- package/src/components/DuffelAncillaries/seats/EmptyElement.tsx +0 -5
- package/src/components/DuffelAncillaries/seats/ExitElement.tsx +0 -17
- package/src/components/DuffelAncillaries/seats/Legend.tsx +0 -60
- package/src/components/DuffelAncillaries/seats/Row.tsx +0 -47
- package/src/components/DuffelAncillaries/seats/RowSection.tsx +0 -78
- package/src/components/DuffelAncillaries/seats/SeatElement.tsx +0 -120
- package/src/components/DuffelAncillaries/seats/SeatInfo.tsx +0 -32
- package/src/components/DuffelAncillaries/seats/SeatMap.tsx +0 -85
- package/src/components/DuffelAncillaries/seats/SeatMapUnavailable.tsx +0 -21
- package/src/components/DuffelAncillaries/seats/SeatSelectionCard.tsx +0 -103
- package/src/components/DuffelAncillaries/seats/SeatSelectionModal.tsx +0 -142
- package/src/components/DuffelAncillaries/seats/SeatSelectionModalBody.tsx +0 -13
- package/src/components/DuffelAncillaries/seats/SeatSelectionModalFooter.tsx +0 -89
- package/src/components/DuffelAncillaries/seats/SeatSelectionModalHeader.tsx +0 -97
- package/src/components/DuffelAncillaries/seats/SeatUnavailable.tsx +0 -14
- package/src/components/DuffelPayments/DuffelPayments.tsx +0 -224
- package/src/components/DuffelPayments/DuffelPaymentsCustomElement.tsx +0 -130
- package/src/components/PlacesLookup/PlacesLookup.tsx +0 -123
- package/src/components/shared/AnimatedLoaderEllipsis.tsx +0 -5
- package/src/components/shared/Button.tsx +0 -63
- package/src/components/shared/ErrorBoundary.tsx +0 -54
- package/src/components/shared/FetchOfferErrorState.tsx +0 -35
- package/src/components/shared/Icon.tsx +0 -151
- package/src/components/shared/IconButton.tsx +0 -42
- package/src/components/shared/Modal.tsx +0 -40
- package/src/components/shared/NonIdealState.tsx +0 -28
- package/src/components/shared/Stamp.tsx +0 -29
- package/src/components/shared/Tabs.tsx +0 -36
- package/src/custom-elements.ts +0 -13
- package/src/examples/client-side/README.md +0 -30
- package/src/examples/client-side/index.html +0 -57
- package/src/examples/full-stack/README.md +0 -34
- package/src/examples/full-stack/index.html +0 -48
- package/src/examples/full-stack/server.mjs +0 -158
- package/src/examples/just-typescript/README.md +0 -37
- package/src/examples/just-typescript/package.json +0 -16
- package/src/examples/just-typescript/src/index.html +0 -23
- package/src/examples/just-typescript/src/index.ts +0 -36
- package/src/examples/next/README.md +0 -28
- package/src/examples/next/next-env.d.ts +0 -5
- package/src/examples/next/next.config.js +0 -4
- package/src/examples/next/package.json +0 -24
- package/src/examples/next/src/app/DuffelComponents.tsx +0 -40
- package/src/examples/next/src/app/layout.tsx +0 -18
- package/src/examples/next/src/app/page.tsx +0 -9
- package/src/examples/next/tsconfig.json +0 -27
- package/src/examples/payments-custom-element/README.md +0 -17
- package/src/examples/payments-custom-element/index.html +0 -43
- package/src/examples/payments-just-typescript/README.md +0 -37
- package/src/examples/payments-just-typescript/package.json +0 -16
- package/src/examples/payments-just-typescript/src/index.html +0 -23
- package/src/examples/payments-just-typescript/src/index.ts +0 -18
- package/src/examples/react-app/README.md +0 -37
- package/src/examples/react-app/package.json +0 -20
- package/src/examples/react-app/src/index.html +0 -19
- package/src/examples/react-app/src/index.tsx +0 -48
- package/src/fixtures/offers/off_0000AUde3KwTztSRK1cznH.json +0 -497
- package/src/fixtures/offers/off_0000AVx4lUFFKW8PsPeQeQ.json +0 -307
- package/src/fixtures/offers/off_1.json +0 -488
- package/src/fixtures/passengers/mock_passengers.ts +0 -26
- package/src/fixtures/seat-maps/off_0000AUde3KwTztSRK1cznH.json +0 -6852
- package/src/fixtures/seat-maps/off_0000AVx4lUFFKW8PsPeQeQ.json +0 -1
- package/src/fixtures/seat-maps/off_1.json +0 -6852
- package/src/lib/captureErrorInSentry.ts +0 -42
- package/src/lib/compileCreateOrderPayload.ts +0 -63
- package/src/lib/createPriceFormatters.ts +0 -73
- package/src/lib/fetchFromDuffelAPI.ts +0 -54
- package/src/lib/fetchFromFixtures.ts +0 -18
- package/src/lib/formatAvailableServices.ts +0 -91
- package/src/lib/formatDate.ts +0 -20
- package/src/lib/formatSeatMaps.ts +0 -81
- package/src/lib/getBaggageServiceDescription.ts +0 -39
- package/src/lib/getCabinsForSegmentAndDeck.ts +0 -4
- package/src/lib/getCurrencyForSeatMaps.ts +0 -22
- package/src/lib/getCurrencyForServices.ts +0 -24
- package/src/lib/getFirstSeatElementMatchingCriteria.ts +0 -22
- package/src/lib/getPassengerBySegmentList.ts +0 -10
- package/src/lib/getPassengerInitials.ts +0 -6
- package/src/lib/getPassengerMapById.ts +0 -17
- package/src/lib/getPassengerName.ts +0 -41
- package/src/lib/getRowNumber.ts +0 -16
- package/src/lib/getSegmentList.ts +0 -7
- package/src/lib/getServicePriceMapById.ts +0 -20
- package/src/lib/getSymbols.ts +0 -22
- package/src/lib/getTotalAmountForServices.ts +0 -72
- package/src/lib/getTotalQuantity.ts +0 -5
- package/src/lib/hasHighLuminance.ts +0 -9
- package/src/lib/hasService.ts +0 -24
- package/src/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.ts +0 -35
- package/src/lib/hasWings.ts +0 -8
- package/src/lib/isBaggageService.ts +0 -8
- package/src/lib/isCancelForAnyReasonService.ts +0 -9
- package/src/lib/isFixtureOfferId.ts +0 -4
- package/src/lib/isPayloadComplete.ts +0 -11
- package/src/lib/isSeatElement.ts +0 -10
- package/src/lib/logging.ts +0 -120
- package/src/lib/moneyStringFormatter.ts +0 -34
- package/src/lib/offerIsExpired.ts +0 -5
- package/src/lib/retrieveOffer.ts +0 -56
- package/src/lib/retrieveOfferFromDuffelAPI.ts +0 -13
- package/src/lib/retrieveSeatMaps.ts +0 -55
- package/src/lib/retrieveSeatMapsFromDuffelAPI.ts +0 -13
- package/src/lib/setBodyScrollability.ts +0 -7
- package/src/lib/validateProps.ts +0 -37
- package/src/lib/withPlural.ts +0 -8
- package/src/stories/BaggageSelectionModalHeader.stories.tsx +0 -21
- package/src/stories/Button.stories.tsx +0 -91
- package/src/stories/DuffelAncillaries.stories.tsx +0 -166
- package/src/stories/DuffelPayments.stories.tsx +0 -34
- package/src/stories/Icon.stories.tsx +0 -35
- package/src/stories/IconButton.stories.tsx +0 -25
- package/src/stories/PlacesLookup.stories.tsx +0 -22
- package/src/styles/colors.css +0 -22
- package/src/styles/components/Amenity.css +0 -23
- package/src/styles/components/BaggageDisplay.css +0 -25
- package/src/styles/components/Button.css +0 -169
- package/src/styles/components/Card.css +0 -52
- package/src/styles/components/CfarSelectionModal.css +0 -34
- package/src/styles/components/Counter.css +0 -18
- package/src/styles/components/DuffelPayments.css +0 -42
- package/src/styles/components/IconButton.css +0 -63
- package/src/styles/components/Legend.css +0 -62
- package/src/styles/components/Loader.css +0 -37
- package/src/styles/components/LoadingState.css +0 -87
- package/src/styles/components/Modal.css +0 -84
- package/src/styles/components/PassengerSelect.css +0 -99
- package/src/styles/components/PassengersLayout.css +0 -90
- package/src/styles/components/PlacesLookup.css +0 -36
- package/src/styles/components/Row.css +0 -70
- package/src/styles/components/Seat.css +0 -59
- package/src/styles/components/SeatInfo.css +0 -61
- package/src/styles/components/SeatMap.css +0 -24
- package/src/styles/components/SeatSelect.css +0 -92
- package/src/styles/components/Segment.css +0 -17
- package/src/styles/components/SelectionSegment.css +0 -10
- package/src/styles/components/Summary.css +0 -70
- package/src/styles/components/Tabs.css +0 -52
- package/src/styles/flex.css +0 -5
- package/src/styles/font-families.css +0 -47
- package/src/styles/global.css +0 -52
- package/src/styles/margin.css +0 -3
- package/src/styles/spacing.css +0 -18
- package/src/styles/transitions.css +0 -3
- package/src/styles/typography.css +0 -13
- package/src/tests/components/DuffelAncillaries.test.tsx +0 -342
- package/src/tests/lib/createPriceFormatters.test.tsx +0 -152
- package/src/tests/lib/formatAvailableServices.test.tsx +0 -79
- package/src/tests/lib/formatSeatMaps.test.tsx +0 -49
- package/src/tests/lib/getCurrencyForServices.test.tsx +0 -44
- package/src/tests/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.test.ts +0 -86
- package/src/tests/lib/logging.test.tsx +0 -32
- package/src/tests/lib/moneyStringFormatter.test.tsx +0 -12
- package/src/tests/lib/validateProps.test.tsx +0 -57
- package/src/types/Aircraft.ts +0 -16
- package/src/types/Airline.ts +0 -16
- package/src/types/Airport.ts +0 -54
- package/src/types/City.ts +0 -21
- package/src/types/CreateOrderPayload.ts +0 -99
- package/src/types/CurrencyConversion.ts +0 -10
- package/src/types/DuffelAncillariesProps.ts +0 -108
- package/src/types/Offer.ts +0 -851
- package/src/types/Order.ts +0 -6
- package/src/types/Place.ts +0 -6
- package/src/types/SeatMap.ts +0 -231
- package/tsconfig.json +0 -52
- /package/{src/index.ts → index.d.ts} +0 -0
- /package/{src/types/index.ts → types/index.d.ts} +0 -0
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { config } from "dotenv";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import prompts from "prompts";
|
|
4
|
-
import { withPlural } from "../src/lib/withPlural";
|
|
5
|
-
import { Offer } from "../src/types/Offer";
|
|
6
|
-
|
|
7
|
-
config({ path: ".env.local" });
|
|
8
|
-
|
|
9
|
-
const DUFFEL_API_TOKEN = process.env.DUFFEL_API_TOKEN || "";
|
|
10
|
-
const DUFFEL_API_URL = process.env.DUFFEL_API_URL || "";
|
|
11
|
-
const VERBOSE = process.env.VERBOSE === "true";
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line
|
|
14
|
-
const log = console.log;
|
|
15
|
-
|
|
16
|
-
if (DUFFEL_API_URL.includes("localhost"))
|
|
17
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
18
|
-
|
|
19
|
-
const duffelHeaders = {
|
|
20
|
-
"Duffel-Version": "v1",
|
|
21
|
-
"Accept-Encoding": "gzip",
|
|
22
|
-
Accept: "application/json",
|
|
23
|
-
"Content-Type": "application/json",
|
|
24
|
-
Authorization: `Bearer ${DUFFEL_API_TOKEN}`,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const makeMockDateInTheFuture = (daysAhead) => {
|
|
28
|
-
const now = new Date(Date.now());
|
|
29
|
-
now.setDate(now.getDate() + daysAhead);
|
|
30
|
-
return now;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const createOfferRequest = async (
|
|
34
|
-
sliceInput: [string, string][],
|
|
35
|
-
adults: number,
|
|
36
|
-
requestedSources?: string[]
|
|
37
|
-
) => {
|
|
38
|
-
const data = {
|
|
39
|
-
slices: sliceInput.map(([origin, destination], index) => ({
|
|
40
|
-
origin,
|
|
41
|
-
destination,
|
|
42
|
-
departure_date: makeMockDateInTheFuture(7 * (index + 1))
|
|
43
|
-
.toISOString()
|
|
44
|
-
.split("T")[0],
|
|
45
|
-
})),
|
|
46
|
-
passengers: Array(adults).fill({ type: "adult" }),
|
|
47
|
-
...(requestedSources && { requested_sources: requestedSources }),
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const response = await fetch(
|
|
51
|
-
DUFFEL_API_URL + "/air/offer_requests?return_offers=true",
|
|
52
|
-
{
|
|
53
|
-
method: "POST",
|
|
54
|
-
headers: duffelHeaders,
|
|
55
|
-
body: JSON.stringify({ data }),
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
return await response.json();
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const getOffer = async (offerId: string): Promise<{ data: Offer }> => {
|
|
63
|
-
const response = await fetch(
|
|
64
|
-
process.env.DUFFEL_API_URL +
|
|
65
|
-
`/air/offers/${offerId}/?return_available_services=true`,
|
|
66
|
-
{ headers: duffelHeaders }
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
return await response.json();
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const getSeatMaps = async (offerId: string) => {
|
|
73
|
-
const response = await fetch(
|
|
74
|
-
process.env.DUFFEL_API_URL + `/air/seat_maps?offer_id=${offerId}`,
|
|
75
|
-
{ headers: duffelHeaders }
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
return await response.json();
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const main = async () => {
|
|
82
|
-
try {
|
|
83
|
-
// prompt user for how many slices they want
|
|
84
|
-
const { sliceCount } = await prompts({
|
|
85
|
-
type: "number",
|
|
86
|
-
name: "sliceCount",
|
|
87
|
-
message: "How many slices do you want?",
|
|
88
|
-
initial: 2,
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// for each slice, prompt for origin and destination
|
|
92
|
-
const sliceInput = new Array<[string, string]>(sliceCount);
|
|
93
|
-
for (let i = 0; i < sliceCount; i++) {
|
|
94
|
-
let origin = sliceInput[i - 1]?.[0];
|
|
95
|
-
|
|
96
|
-
log(`\nSlice #${i + 1}`);
|
|
97
|
-
const { value } = await prompts({
|
|
98
|
-
type: "text",
|
|
99
|
-
name: "value",
|
|
100
|
-
message: "What is the origin?",
|
|
101
|
-
limit: 3,
|
|
102
|
-
});
|
|
103
|
-
origin = value;
|
|
104
|
-
|
|
105
|
-
const { destination } = await prompts({
|
|
106
|
-
type: "text",
|
|
107
|
-
name: "destination",
|
|
108
|
-
message: "What is the destination?",
|
|
109
|
-
limit: 3,
|
|
110
|
-
});
|
|
111
|
-
sliceInput[i] = [origin, destination];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// ask how many adults
|
|
115
|
-
log(`\n`);
|
|
116
|
-
const { adultCount } = await prompts({
|
|
117
|
-
type: "number",
|
|
118
|
-
name: "adultCount",
|
|
119
|
-
message: "How many adults traveling?",
|
|
120
|
-
initial: 1,
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// ask for requested sources
|
|
124
|
-
log(`\n`);
|
|
125
|
-
const { requestedSources } = await prompts({
|
|
126
|
-
type: "text",
|
|
127
|
-
name: "requestedSources",
|
|
128
|
-
message: "What sources do you want to request?",
|
|
129
|
-
initial: "duffel_airways",
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
// run search
|
|
133
|
-
const { data: offerRequest } = await createOfferRequest(
|
|
134
|
-
sliceInput,
|
|
135
|
-
adultCount,
|
|
136
|
-
requestedSources ? requestedSources.split(",") : undefined
|
|
137
|
-
);
|
|
138
|
-
if (VERBOSE) {
|
|
139
|
-
const airlines = new Set(
|
|
140
|
-
offerRequest.offers.map((offer) => offer.owner.iata_code)
|
|
141
|
-
);
|
|
142
|
-
log(
|
|
143
|
-
`Received ${withPlural(
|
|
144
|
-
offerRequest.offers.length,
|
|
145
|
-
"offer",
|
|
146
|
-
"offers"
|
|
147
|
-
)} back ` +
|
|
148
|
-
`from ${withPlural(
|
|
149
|
-
airlines.size,
|
|
150
|
-
"airline",
|
|
151
|
-
"airlines"
|
|
152
|
-
)}(${Array.from(airlines.values()).join(",")})`
|
|
153
|
-
);
|
|
154
|
-
log(
|
|
155
|
-
`Search completed, offer request ID: ${offerRequest.id}.\nUsing first offer to get services: ${offerRequest.offers[0].id}\n`
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// get offer
|
|
160
|
-
const { data: firstOffer } = await getOffer(offerRequest.offers[0].id);
|
|
161
|
-
|
|
162
|
-
// save to src/fixtures/offer
|
|
163
|
-
const _description =
|
|
164
|
-
`This fixture was generated by scripts/generate-fixture.ts. ` +
|
|
165
|
-
`It includes an offer with ${withPlural(
|
|
166
|
-
adultCount,
|
|
167
|
-
"passenger",
|
|
168
|
-
"passengers"
|
|
169
|
-
)} and ` +
|
|
170
|
-
`${withPlural(sliceCount, "slice", "slices")}: ${sliceInput.join(" ⇢ ")}`;
|
|
171
|
-
|
|
172
|
-
// Set offer to expire in 10 years so that this fixture won't trigger the
|
|
173
|
-
// "expired" error in the future.
|
|
174
|
-
const expires_at = makeMockDateInTheFuture(365 * 10).toISOString();
|
|
175
|
-
|
|
176
|
-
fs.writeFileSync(
|
|
177
|
-
`src/fixtures/offers/${firstOffer.id}.json`,
|
|
178
|
-
JSON.stringify({ _description, ...firstOffer, expires_at }, null, 2)
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
// get seat maps
|
|
182
|
-
const { data: seatMaps } = await getSeatMaps(firstOffer.id);
|
|
183
|
-
|
|
184
|
-
// save to src/fixtures/seat-maps
|
|
185
|
-
fs.writeFileSync(
|
|
186
|
-
`src/fixtures/seat-maps/${firstOffer.id}.json`,
|
|
187
|
-
JSON.stringify(seatMaps, null, 2)
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
log(`\n🐄 Fixtures saved for ${firstOffer.id}`);
|
|
191
|
-
log(` ↳ /src/fixtures/offer/${firstOffer.id}.json`);
|
|
192
|
-
log(` ↳ /src/fixtures/seat-maps/${firstOffer.id}.json\n`);
|
|
193
|
-
} catch (err) {
|
|
194
|
-
// eslint-disable-next-line
|
|
195
|
-
console.error(err);
|
|
196
|
-
process.exit(1);
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
export default main();
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import readline from "readline";
|
|
3
|
-
|
|
4
|
-
async function readCSVIntoMatrix(
|
|
5
|
-
filePath: string,
|
|
6
|
-
linePrefix: string,
|
|
7
|
-
keys: string[]
|
|
8
|
-
): Promise<string[]> {
|
|
9
|
-
const rl = readline.createInterface({
|
|
10
|
-
input: fs.createReadStream(filePath),
|
|
11
|
-
crlfDelay: Infinity,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// this will map a key into the index
|
|
15
|
-
let keyNameToIndexMap: Record<string, number> = {};
|
|
16
|
-
const matrix = new Array<string>();
|
|
17
|
-
|
|
18
|
-
rl.on("line", (line) => {
|
|
19
|
-
if (Object.keys(keyNameToIndexMap).length === 0) {
|
|
20
|
-
// it's the header line
|
|
21
|
-
keyNameToIndexMap = line
|
|
22
|
-
.split(",")
|
|
23
|
-
.reduce((acc, key, index) => ({ ...acc, [key]: index }), {});
|
|
24
|
-
} else {
|
|
25
|
-
// it's a data line
|
|
26
|
-
const row = line.split(",");
|
|
27
|
-
const rowObject =
|
|
28
|
-
linePrefix +
|
|
29
|
-
keys
|
|
30
|
-
.map((key) => {
|
|
31
|
-
const index = keyNameToIndexMap[key];
|
|
32
|
-
return row[index];
|
|
33
|
-
})
|
|
34
|
-
.join(`,`);
|
|
35
|
-
matrix.push(rowObject);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
await new Promise((res) => rl.once("close", res));
|
|
40
|
-
return matrix;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface CityCsvRow {
|
|
44
|
-
id: string;
|
|
45
|
-
iata_code: string;
|
|
46
|
-
iata_country_code: string;
|
|
47
|
-
name: string;
|
|
48
|
-
inserted_at: string;
|
|
49
|
-
updated_at: string;
|
|
50
|
-
metropolitan_area: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async function loadCities() {
|
|
54
|
-
return await readCSVIntoMatrix("./data/cities.csv", "C,", [
|
|
55
|
-
"name",
|
|
56
|
-
"iata_code",
|
|
57
|
-
]);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface AirportCsvRow {
|
|
61
|
-
id: string;
|
|
62
|
-
iata_code: string;
|
|
63
|
-
iata_city_code: string;
|
|
64
|
-
iata_country_code: string;
|
|
65
|
-
name: string;
|
|
66
|
-
inserted_at: string;
|
|
67
|
-
updated_at: string;
|
|
68
|
-
source_type: string;
|
|
69
|
-
alternative_names: string;
|
|
70
|
-
icao_code: string;
|
|
71
|
-
disabled_at: string;
|
|
72
|
-
city_name: string;
|
|
73
|
-
latitude: string;
|
|
74
|
-
longitude: string;
|
|
75
|
-
time_zone: string;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async function loadAirports() {
|
|
79
|
-
return await readCSVIntoMatrix("./data/airports.csv", "A,", [
|
|
80
|
-
"name",
|
|
81
|
-
"iata_code",
|
|
82
|
-
"latitude",
|
|
83
|
-
"longitude",
|
|
84
|
-
]);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async function main() {
|
|
88
|
-
// load airports csv
|
|
89
|
-
const airports = await loadAirports();
|
|
90
|
-
|
|
91
|
-
// load cities csv
|
|
92
|
-
const cities = await loadCities();
|
|
93
|
-
|
|
94
|
-
fs.writeFileSync(
|
|
95
|
-
"./data/__generated__iata-lookup.json",
|
|
96
|
-
JSON.stringify([...cities, ...airports])
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export default main();
|
package/scripts/upload-to-cdn.sh
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
# Exit if a command fails
|
|
4
|
-
set -e
|
|
5
|
-
|
|
6
|
-
# Define where to upload files too
|
|
7
|
-
GCP_PREFIX=gs://duffel-assets/components
|
|
8
|
-
|
|
9
|
-
# Gets current version from package.json
|
|
10
|
-
VERSION=$(jq '.version' package.json -r)
|
|
11
|
-
|
|
12
|
-
# Check if version is empty
|
|
13
|
-
if [ -z "$VERSION" ]; then
|
|
14
|
-
echo "Error: version is empty"
|
|
15
|
-
exit 1
|
|
16
|
-
fi
|
|
17
|
-
|
|
18
|
-
# Check if folder exists
|
|
19
|
-
if gsutil -q stat "$GCP_PREFIX/$VERSION/duffel-ancillaries.js"; then
|
|
20
|
-
# Confirm with user before overriding
|
|
21
|
-
read -p "Version \`$VERSION\` already exists. Do you want to override it? (\`Y\` to continue) " -n 1 -r
|
|
22
|
-
echo
|
|
23
|
-
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
24
|
-
# Delete old version from GCP
|
|
25
|
-
gcloud storage rm -r "$GCP_PREFIX/$VERSION"
|
|
26
|
-
else
|
|
27
|
-
echo "Aborting script."
|
|
28
|
-
exit 1
|
|
29
|
-
fi
|
|
30
|
-
fi
|
|
31
|
-
|
|
32
|
-
# Uploads fixtures
|
|
33
|
-
gcloud storage cp -r cdn-dist "$GCP_PREFIX/$VERSION"
|
|
34
|
-
|
package/scripts.tsconfig.json
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { Icon, IconName } from "@components/shared/Icon";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
|
|
5
|
-
export interface CardProps {
|
|
6
|
-
buttonTitle: string;
|
|
7
|
-
title: string;
|
|
8
|
-
icon: IconName;
|
|
9
|
-
onClick?: (() => void) | null;
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
copy: string;
|
|
12
|
-
isLoading?: boolean;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
isSelected?: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const Card: React.FC<CardProps> = ({
|
|
18
|
-
buttonTitle,
|
|
19
|
-
title,
|
|
20
|
-
icon,
|
|
21
|
-
copy,
|
|
22
|
-
onClick,
|
|
23
|
-
children,
|
|
24
|
-
isLoading,
|
|
25
|
-
disabled,
|
|
26
|
-
isSelected,
|
|
27
|
-
}) => {
|
|
28
|
-
const hasChildren = React.Children.toArray(children).length > 0;
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<button
|
|
32
|
-
title={buttonTitle}
|
|
33
|
-
{...(onClick && { onClick })}
|
|
34
|
-
disabled={disabled}
|
|
35
|
-
className={classNames(
|
|
36
|
-
"ancillary-card",
|
|
37
|
-
isLoading && "ancillary-card--loading"
|
|
38
|
-
)}
|
|
39
|
-
// We are using inline styles here because
|
|
40
|
-
// we don't want the cards to appear unstyled
|
|
41
|
-
// before the CSS stylesheet loads.
|
|
42
|
-
// This is important for this component since it
|
|
43
|
-
// be on visible on the page when it loads.
|
|
44
|
-
style={{
|
|
45
|
-
cursor: "pointer",
|
|
46
|
-
background: "transparent",
|
|
47
|
-
color: "var(--GREY-900)",
|
|
48
|
-
border: "solid 1px rgba(226, 226, 232, 1)",
|
|
49
|
-
display: "flex",
|
|
50
|
-
rowGap: "4px",
|
|
51
|
-
padding: "20px",
|
|
52
|
-
borderRadius: "8px",
|
|
53
|
-
justifyContent: "space-between",
|
|
54
|
-
flexWrap: "wrap",
|
|
55
|
-
flexDirection: "column",
|
|
56
|
-
width: "100%",
|
|
57
|
-
boxSizing: "border-box",
|
|
58
|
-
fontSize: "16px",
|
|
59
|
-
fontWeight: "400",
|
|
60
|
-
lineHeight: "24px",
|
|
61
|
-
letterSpacing: "0em",
|
|
62
|
-
transition:
|
|
63
|
-
"border-color 0.3s var(--TRANSITION-CUBIC-BEZIER) background-color 0.3s var(--TRANSITION-CUBIC-BEZIER)",
|
|
64
|
-
}}
|
|
65
|
-
>
|
|
66
|
-
<div
|
|
67
|
-
style={{
|
|
68
|
-
display: "flex",
|
|
69
|
-
alignItems: "flex-start",
|
|
70
|
-
marginBlock: "0",
|
|
71
|
-
textAlign: "start",
|
|
72
|
-
marginTop: "2px",
|
|
73
|
-
columnGap: "12px",
|
|
74
|
-
width: "100%",
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
<div>
|
|
78
|
-
{isSelected ? (
|
|
79
|
-
<Icon name="check" className="ancillary-card__selected-icon" />
|
|
80
|
-
) : (
|
|
81
|
-
<Icon name={icon} />
|
|
82
|
-
)}
|
|
83
|
-
</div>
|
|
84
|
-
|
|
85
|
-
<div
|
|
86
|
-
style={{
|
|
87
|
-
display: "flex",
|
|
88
|
-
justifyContent: "space-between",
|
|
89
|
-
alignItems: "start",
|
|
90
|
-
width: "100%",
|
|
91
|
-
}}
|
|
92
|
-
>
|
|
93
|
-
<p
|
|
94
|
-
className="p1--semibold"
|
|
95
|
-
style={{
|
|
96
|
-
marginBlock: "0",
|
|
97
|
-
}}
|
|
98
|
-
>
|
|
99
|
-
{title}
|
|
100
|
-
</p>
|
|
101
|
-
<div className="ancillary-card__children">
|
|
102
|
-
{hasChildren ? (
|
|
103
|
-
children
|
|
104
|
-
) : (
|
|
105
|
-
<Icon
|
|
106
|
-
name="expand_content"
|
|
107
|
-
className="ancillary-card__expand-icon"
|
|
108
|
-
/>
|
|
109
|
-
)}
|
|
110
|
-
</div>
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
113
|
-
<p
|
|
114
|
-
className="p1--regular"
|
|
115
|
-
style={{
|
|
116
|
-
textAlign: "start",
|
|
117
|
-
color: "var(--GREY-600)",
|
|
118
|
-
marginLeft: "34px",
|
|
119
|
-
marginBlock: "0",
|
|
120
|
-
}}
|
|
121
|
-
>
|
|
122
|
-
{copy}
|
|
123
|
-
</p>
|
|
124
|
-
</button>
|
|
125
|
-
);
|
|
126
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { IconButton } from "@components/shared/IconButton";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
interface CounterProps {
|
|
5
|
-
id: string;
|
|
6
|
-
min: number;
|
|
7
|
-
max: number;
|
|
8
|
-
value: number;
|
|
9
|
-
onChange: (value: number) => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const Counter: React.FC<CounterProps> = ({
|
|
13
|
-
id,
|
|
14
|
-
min,
|
|
15
|
-
max,
|
|
16
|
-
value,
|
|
17
|
-
onChange,
|
|
18
|
-
}) => (
|
|
19
|
-
<div className="counter" id={id}>
|
|
20
|
-
<IconButton
|
|
21
|
-
icon="minus"
|
|
22
|
-
title="Remove one"
|
|
23
|
-
id={`${id}-minus`}
|
|
24
|
-
data-testid={`${id}-minus`}
|
|
25
|
-
variant="outlined"
|
|
26
|
-
disabled={value <= min}
|
|
27
|
-
onClick={() => onChange(Math.max(value - 1, min))}
|
|
28
|
-
/>
|
|
29
|
-
<div className="counter__count-label">{value}</div>
|
|
30
|
-
<IconButton
|
|
31
|
-
icon="add"
|
|
32
|
-
title="Add one"
|
|
33
|
-
id={`${id}-plus`}
|
|
34
|
-
data-testid={`${id}-plus`}
|
|
35
|
-
variant="outlined"
|
|
36
|
-
disabled={value >= max}
|
|
37
|
-
onClick={() => onChange(Math.min(value + 1, max))}
|
|
38
|
-
/>
|
|
39
|
-
</div>
|
|
40
|
-
);
|