@bisondesk/core-sdk 1.0.644 → 1.0.645

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.
Files changed (76) hide show
  1. package/lib/types/delivery-settings.d.ts +1 -0
  2. package/lib/types/delivery-settings.d.ts.map +1 -1
  3. package/lib/types/delivery-settings.js.map +1 -1
  4. package/lib/types/internal-events.d.ts +2 -1
  5. package/lib/types/internal-events.d.ts.map +1 -1
  6. package/lib/types/internal-events.js +1 -0
  7. package/lib/types/internal-events.js.map +1 -1
  8. package/lib/types/journeys.d.ts +1 -0
  9. package/lib/types/journeys.d.ts.map +1 -1
  10. package/lib/types/journeys.js.map +1 -1
  11. package/lib/types/offers.d.ts +1 -0
  12. package/lib/types/offers.d.ts.map +1 -1
  13. package/lib/types/offers.js.map +1 -1
  14. package/lib/types/quotes.d.ts +6 -0
  15. package/lib/types/quotes.d.ts.map +1 -1
  16. package/lib/types/quotes.js.map +1 -1
  17. package/lib/types/transports.d.ts +93 -21
  18. package/lib/types/transports.d.ts.map +1 -1
  19. package/lib/types/transports.js +18 -2
  20. package/lib/types/transports.js.map +1 -1
  21. package/lib/types/vehicles.d.ts +2 -0
  22. package/lib/types/vehicles.d.ts.map +1 -1
  23. package/lib/types/vehicles.js.map +1 -1
  24. package/lib/utils/search.d.ts +4 -2
  25. package/lib/utils/search.d.ts.map +1 -1
  26. package/lib/utils/search.js +19 -1
  27. package/lib/utils/search.js.map +1 -1
  28. package/lib/utils/transports.d.ts +9 -0
  29. package/lib/utils/transports.d.ts.map +1 -0
  30. package/lib/utils/transports.js +15 -0
  31. package/lib/utils/transports.js.map +1 -0
  32. package/package.json +1 -1
  33. package/src/types/comparables.js +2 -0
  34. package/src/types/comparables.js.map +1 -0
  35. package/src/types/crm.js +50 -0
  36. package/src/types/crm.js.map +1 -0
  37. package/src/types/delivery-settings.ts +1 -0
  38. package/src/types/fields.js +2 -0
  39. package/src/types/fields.js.map +1 -0
  40. package/src/types/insights.js +2 -0
  41. package/src/types/insights.js.map +1 -0
  42. package/src/types/internal-events.ts +1 -0
  43. package/src/types/internet-vehicles.js +2 -0
  44. package/src/types/internet-vehicles.js.map +1 -0
  45. package/src/types/journeys.js +2 -0
  46. package/src/types/journeys.js.map +1 -0
  47. package/src/types/journeys.ts +5 -0
  48. package/src/types/leasing-settings.js +7 -0
  49. package/src/types/leasing-settings.js.map +1 -0
  50. package/src/types/offers.js +56 -0
  51. package/src/types/offers.js.map +1 -0
  52. package/src/types/offers.ts +1 -0
  53. package/src/types/opportunities.js +106 -0
  54. package/src/types/opportunities.js.map +1 -0
  55. package/src/types/payments.js +7 -0
  56. package/src/types/payments.js.map +1 -0
  57. package/src/types/quotes.js +42 -0
  58. package/src/types/quotes.js.map +1 -0
  59. package/src/types/quotes.ts +6 -0
  60. package/src/types/reservations.js +5 -0
  61. package/src/types/reservations.js.map +1 -0
  62. package/src/types/search.js +2 -0
  63. package/src/types/search.js.map +1 -0
  64. package/src/types/tenants.js +20 -0
  65. package/src/types/tenants.js.map +1 -0
  66. package/src/types/transports.ts +153 -28
  67. package/src/types/utils.js +2 -0
  68. package/src/types/utils.js.map +1 -0
  69. package/src/types/vehicles.js +94 -0
  70. package/src/types/vehicles.js.map +1 -0
  71. package/src/types/vehicles.ts +2 -0
  72. package/src/utils/opportunities.js +48 -0
  73. package/src/utils/opportunities.js.map +1 -0
  74. package/src/utils/search.ts +31 -2
  75. package/src/utils/transports.ts +37 -0
  76. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,94 @@
1
+ export var VehicleRoles;
2
+ (function (VehicleRoles) {
3
+ VehicleRoles["SALE"] = "SALE";
4
+ VehicleRoles["OWN_USE"] = "OWN_USE";
5
+ VehicleRoles["RENTAL"] = "RENTAL";
6
+ VehicleRoles["BUILD"] = "BUILD";
7
+ VehicleRoles["UNKNOWN"] = "UNKNOWN";
8
+ VehicleRoles["BANK_FINANCE"] = "BANK_FINANCE";
9
+ })(VehicleRoles || (VehicleRoles = {}));
10
+ export var VehicleFuelType;
11
+ (function (VehicleFuelType) {
12
+ VehicleFuelType["Petrol"] = "PETROL";
13
+ VehicleFuelType["Diesel"] = "DIESEL";
14
+ VehicleFuelType["LPG"] = "LPG";
15
+ VehicleFuelType["LPG_G3"] = "LPG_G3";
16
+ VehicleFuelType["Electric"] = "ELECTRIC";
17
+ VehicleFuelType["CNG"] = "CNG";
18
+ VehicleFuelType["Hydrogen"] = "HYDROGEN";
19
+ VehicleFuelType["BioEthanol"] = "BIO_ETHANOL";
20
+ VehicleFuelType["BioDiesel"] = "BIO_DIESEL";
21
+ VehicleFuelType["E85"] = "E85";
22
+ VehicleFuelType["HCNG"] = "HCNG";
23
+ VehicleFuelType["LPG_Petrol"] = "LPG_PETROL";
24
+ VehicleFuelType["LPG_Diesel"] = "LPG_DIESEL";
25
+ VehicleFuelType["LPG_G3_Petrol"] = "LPG_G3_PETROL";
26
+ VehicleFuelType["LPG_G3_Diesel"] = "LPG_G3_DIESEL";
27
+ VehicleFuelType["Electric_Diesel"] = "ELECTRIC_DIESEL";
28
+ VehicleFuelType["Electric_Petrol"] = "ELECTRIC_PETROL";
29
+ VehicleFuelType["Hybrid"] = "HYBRID";
30
+ VehicleFuelType["Other"] = "OTHER";
31
+ })(VehicleFuelType || (VehicleFuelType = {}));
32
+ export var VehicleTachoTypes;
33
+ (function (VehicleTachoTypes) {
34
+ VehicleTachoTypes["Analog"] = "ANALOG";
35
+ VehicleTachoTypes["Digital"] = "DIGITAL";
36
+ VehicleTachoTypes["SmartTacho1"] = "SMART_TACHO_1";
37
+ VehicleTachoTypes["SmartTacho2"] = "SMART_TACHO_2";
38
+ })(VehicleTachoTypes || (VehicleTachoTypes = {}));
39
+ export var SearchVehicleSaleDealStatus;
40
+ (function (SearchVehicleSaleDealStatus) {
41
+ SearchVehicleSaleDealStatus["NotSold"] = "NOT_SOLD";
42
+ SearchVehicleSaleDealStatus["Reserved"] = "RESERVED";
43
+ SearchVehicleSaleDealStatus["Sold"] = "SOLD";
44
+ })(SearchVehicleSaleDealStatus || (SearchVehicleSaleDealStatus = {}));
45
+ export var VehiclePurchaseDealStatus;
46
+ (function (VehiclePurchaseDealStatus) {
47
+ VehiclePurchaseDealStatus["Marketing"] = "MARKETING";
48
+ VehiclePurchaseDealStatus["PurchaseEvaluation"] = "PURCHASE_EVALUATION";
49
+ VehiclePurchaseDealStatus["PurchaseAgreed"] = "PURCHASE_AGREED";
50
+ VehiclePurchaseDealStatus["FirstPaymentAllowed"] = "FIRST_PAYMENT_ALLOWED";
51
+ VehiclePurchaseDealStatus["FirstPaymentSent"] = "FIRST_PAYMENT_SENT";
52
+ VehiclePurchaseDealStatus["FullPaymentAllowed"] = "FULL_PAYMENT_ALLOWED";
53
+ VehiclePurchaseDealStatus["FullPaymentSent"] = "FULL_PAYMENT_SENT";
54
+ })(VehiclePurchaseDealStatus || (VehiclePurchaseDealStatus = {}));
55
+ export var VehiclePurchaseLogisticsStatus;
56
+ (function (VehiclePurchaseLogisticsStatus) {
57
+ VehiclePurchaseLogisticsStatus["AtOrigin"] = "AT_ORIGIN";
58
+ VehiclePurchaseLogisticsStatus["Arrived"] = "ARRIVED";
59
+ VehiclePurchaseLogisticsStatus["CheckedIn"] = "CHECKED_IN";
60
+ })(VehiclePurchaseLogisticsStatus || (VehiclePurchaseLogisticsStatus = {}));
61
+ export var VehiclePurchaseDeliveryType;
62
+ (function (VehiclePurchaseDeliveryType) {
63
+ VehiclePurchaseDeliveryType["PickUp"] = "PICK_UP";
64
+ VehiclePurchaseDeliveryType["DropOff"] = "DROP_OFF";
65
+ })(VehiclePurchaseDeliveryType || (VehiclePurchaseDeliveryType = {}));
66
+ export var VehicleActions;
67
+ (function (VehicleActions) {
68
+ VehicleActions["EditAdminDocs"] = "edit_admin_docs";
69
+ VehicleActions["EditEngineeringDocs"] = "edit_engineering_docs";
70
+ VehicleActions["EditMarketing"] = "edit_marketing";
71
+ VehicleActions["EditMedia"] = "edit_media";
72
+ VehicleActions["EditPictures"] = "edit_pictures";
73
+ VehicleActions["EditPrices"] = "edit_prices";
74
+ VehicleActions["EditPurchaseDeal"] = "edit_purchase_deal";
75
+ VehicleActions["EditPurchaseLogistics"] = "edit_purchase_logistics";
76
+ VehicleActions["EditSpecs"] = "edit_specs";
77
+ VehicleActions["EditVideos"] = "edit_videos";
78
+ VehicleActions["ViewLeads"] = "view_leads";
79
+ VehicleActions["ViewSimilarOnline"] = "view_similar_online";
80
+ VehicleActions["ViewPurchase"] = "view_purchase";
81
+ VehicleActions["ViewPriceHistory"] = "view_price_history";
82
+ VehicleActions["DeleteVehicle"] = "delete_vehicle";
83
+ })(VehicleActions || (VehicleActions = {}));
84
+ export var PurchaseActions;
85
+ (function (PurchaseActions) {
86
+ PurchaseActions["ViewDeal"] = "view_deal";
87
+ PurchaseActions["ViewSupplierOrganization"] = "view_supplier_organization";
88
+ PurchaseActions["ViewContact"] = "view_contact";
89
+ PurchaseActions["ViewLegalAddress"] = "view_legal_address";
90
+ PurchaseActions["ViewPickupAddress"] = "view_pickup_address";
91
+ PurchaseActions["ViewEstimatedCosts"] = "view_estimated_costs";
92
+ PurchaseActions["ViewFinanceDocuments"] = "view_finance_documents";
93
+ })(PurchaseActions || (PurchaseActions = {}));
94
+ //# sourceMappingURL=vehicles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vehicles.js","sourceRoot":"","sources":["vehicles.ts"],"names":[],"mappings":"AAeA,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,mCAAmB,CAAA;IACnB,iCAAiB,CAAA;IACjB,+BAAe,CAAA;IACf,mCAAmB,CAAA;IACnB,6CAA6B,CAAA;AAC/B,CAAC,EAPW,YAAY,KAAZ,YAAY,QAOvB;AAED,MAAM,CAAN,IAAY,eAoBX;AApBD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,8BAAW,CAAA;IACX,oCAAiB,CAAA;IACjB,wCAAqB,CAA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M,CAAN,IAAY,cAgBX;AAhBD,WAAY,cAAc;IACxB,mDAAiC,CAAA;IACjC,+DAA6C,CAAA;IAC7C,kDAAgC,CAAA;IAChC,0CAAwB,CAAA;IACxB,gDAA8B,CAAA;IAC9B,4CAA0B,CAAA;IAC1B,yDAAuC,CAAA;IACvC,mEAAiD,CAAA;IACjD,0CAAwB,CAAA;IACxB,4CAA0B,CAAA;IAC1B,0CAAwB,CAAA;IACxB,2DAAyC,CAAA;IACzC,gDAA8B,CAAA;IAC9B,yDAAuC,CAAA;IACvC,kDAAgC,CAAA;AAClC,CAAC,EAhBW,cAAc,KAAd,cAAc,QAgBzB;AAED,MAAM,CAAN,IAAY,eAQX;AARD,WAAY,eAAe;IACzB,yCAAsB,CAAA;IACtB,0EAAuD,CAAA;IACvD,+CAA4B,CAAA;IAC5B,0DAAuC,CAAA;IACvC,4DAAyC,CAAA;IACzC,8DAA2C,CAAA;IAC3C,kEAA+C,CAAA;AACjD,CAAC,EARW,eAAe,KAAf,eAAe,QAQ1B"}
@@ -142,6 +142,7 @@ export type NewVehicleRequest = {
142
142
  deliveryType?: VehiclePurchaseDeliveryType;
143
143
  pickupAddress?: LocationValue;
144
144
  status: VehiclePurchaseLogisticsStatus;
145
+ transportWithoutPayment?: boolean;
145
146
  };
146
147
  prices: {
147
148
  minimum?: string;
@@ -855,6 +856,7 @@ export type VehiclePurchase = {
855
856
  deliveryType?: VehiclePurchaseDeliveryType;
856
857
  pickupAddress?: LocationValue;
857
858
  availableWeek?: string; // ISOWEEK, e.g. 2016-W02
859
+ transportWithoutPayment?: boolean;
858
860
  };
859
861
  };
860
862
 
@@ -0,0 +1,48 @@
1
+ import { OpportunityStatus, OpportunityStatusOrder } from '../types/opportunities.js';
2
+ const compareOpportunityStatus = (input) => {
3
+ const { currentStatus, referenceStatus } = input;
4
+ const currentStatusIdx = OpportunityStatusOrder.indexOf(currentStatus);
5
+ const referenceStatusIdx = OpportunityStatusOrder.indexOf(referenceStatus);
6
+ return {
7
+ currentStatusIdx,
8
+ referenceStatusIdx,
9
+ };
10
+ };
11
+ export const getPreviousStatus = (currentStatus) => {
12
+ const currentIndex = OpportunityStatusOrder.indexOf(currentStatus);
13
+ if (currentIndex === 0) {
14
+ return;
15
+ }
16
+ return OpportunityStatusOrder[currentIndex - 1];
17
+ };
18
+ export const getNextStatus = (status) => {
19
+ const statusIndex = OpportunityStatusOrder.indexOf(status);
20
+ if (statusIndex >= OpportunityStatusOrder.length - 1) {
21
+ return;
22
+ }
23
+ return OpportunityStatusOrder[statusIndex + 1];
24
+ };
25
+ export const isSameOrAfterReferenceOpportunityStatus = (input) => {
26
+ const { currentStatusIdx, referenceStatusIdx } = compareOpportunityStatus(input);
27
+ return currentStatusIdx >= referenceStatusIdx;
28
+ };
29
+ export const isAfterReferenceOpportunityStatus = (input) => {
30
+ const { currentStatusIdx, referenceStatusIdx } = compareOpportunityStatus(input);
31
+ return currentStatusIdx > referenceStatusIdx;
32
+ };
33
+ export const isSameOrBeforeReferenceOpportunityStatus = (input) => {
34
+ const { currentStatusIdx, referenceStatusIdx } = compareOpportunityStatus(input);
35
+ return currentStatusIdx <= referenceStatusIdx;
36
+ };
37
+ export const isBeforeReferenceOpportunityStatus = (input) => {
38
+ const { currentStatusIdx, referenceStatusIdx } = compareOpportunityStatus(input);
39
+ return currentStatusIdx < referenceStatusIdx;
40
+ };
41
+ export const isOpportunityLost = (input) => input.lostAt != null;
42
+ export const getOpportunityReservedStatus = () => [
43
+ OpportunityStatus.REVIEW,
44
+ OpportunityStatus.PREPARATION,
45
+ OpportunityStatus.DELIVERY,
46
+ ];
47
+ export const isOpportunityReserved = (input) => getOpportunityReservedStatus().includes(input.status);
48
+ //# sourceMappingURL=opportunities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opportunities.js","sourceRoot":"","sources":["opportunities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAOnG,MAAM,w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,CAAC;IAEjF,OAAO,gBAAgB,GAAG,kBAAkB,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wCAAwC,GAAG,CAAC,KAAmB,EAAW,EAAE;IACvF,MAAM,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAEjF,OAAO,gBAAgB,IAAI,kBAAkB,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,KAAmB,EAAW,EAAE;IACjF,MAAM,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAEjF,OAAO,gBAAgB,GAAG,kBAAkB,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAkB,EAAW,EAAE,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC;AAEvF,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAwB,EAAE,CAAC;IACrE,iBAAiB,CAAC,MAAM;IACxB,iBAAiB,CAAC,WAAW;IAC7B,iBAAiB,CAAC,QAAQ;CAC3B,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAkB,EAAW,EAAE,CACnE,4BAA4B,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC"}
@@ -5,6 +5,7 @@ import { LeasingContract } from '../types/leasing.js';
5
5
  import { DebtorsDossier, SearchDebtorsDossier } from '../types/leasing-debtors.js';
6
6
  import { SearchLeasingContract } from '../types/leasing-search.js';
7
7
  import { Opportunity, SearchOpportunity } from '../types/opportunities.js';
8
+ import { SearchTransport, Transport } from '../types/transports.js';
8
9
  import { SearchVehicle, Vehicle } from '../types/vehicles.js';
9
10
 
10
11
  export type GlobalBusinessEntity =
@@ -12,13 +13,15 @@ export type GlobalBusinessEntity =
12
13
  | Vehicle
13
14
  | Organization
14
15
  | LeasingContract
15
- | DebtorsDossier;
16
+ | DebtorsDossier
17
+ | Transport;
16
18
  export type GlobalSearchEntity =
17
19
  | SearchOpportunity
18
20
  | SearchVehicle
19
21
  | SearchOrganization
20
22
  | SearchLeasingContract
21
- | SearchDebtorsDossier;
23
+ | SearchDebtorsDossier
24
+ | SearchTransport;
22
25
 
23
26
  export const getCustomerInformation = (org?: Organization, contact?: Contact) => {
24
27
  if (org != null) {
@@ -41,6 +44,7 @@ export const mappings: {
41
44
  [key in BusinessEntityIds]?: {
42
45
  getMainEntity: (entity: any) => GlobalBusinessEntity;
43
46
  getTitle: (entity: any) => string;
47
+ getTitleForSearchEntity?: (entity: any) => string;
44
48
  getTags: (entity: any) => string[];
45
49
  getTagsForSearchEntity?: (entity: any) => string[];
46
50
  getDescription?: (entity: any) => string;
@@ -123,6 +127,30 @@ export const mappings: {
123
127
  getTitle: (dossier: DebtorsDossier) => dossier.id,
124
128
  getTags: (dossier: DebtorsDossier) => [dossier.id].filter(Boolean) as string[],
125
129
  },
130
+ // A transport on its own knows only ids, so the readable title and description come from the
131
+ // search entity (vehicle + customer). The bare-record variants stay on the id as a fallback.
132
+ [BusinessEntityIds.Transports]: {
133
+ getMainEntity: (entity: SearchTransport) => entity.transport,
134
+ getTitle: (transport: Transport) => transport.id,
135
+ getTitleForSearchEntity: (entity: SearchTransport) =>
136
+ entity.vehicle?.external.identification?.stockNumber ?? entity.transport.id,
137
+ getDescription: (entity: SearchTransport) => {
138
+ const customer = getCustomerInformation(entity.org);
139
+ const parts = [customer?.code, customer?.title].filter(Boolean) as string[];
140
+ // The API rejects an empty association description, so never return one.
141
+ return parts.length > 0 ? joinWithSeparator(parts) : entity.transport.id;
142
+ },
143
+ getTags: (transport: Transport) => [transport.id],
144
+ getTagsForSearchEntity: (entity: SearchTransport) => {
145
+ const vehicleTags =
146
+ entity.vehicle != null
147
+ ? getTagsForBusinessEntity(BusinessEntityIds.Vehicles, entity.vehicle)
148
+ : [];
149
+ return [...vehicleTags, entity.transport.id, entity.transport.opportunityId].filter(
150
+ Boolean,
151
+ ) as string[];
152
+ },
153
+ },
126
154
  };
127
155
 
128
156
  const getMapping = (businessEntityId: BusinessEntityIds) => {
@@ -186,6 +214,7 @@ export const getTitleForSearchBusinessEntity = (
186
214
  businessEntityId: BusinessEntityIds,
187
215
  searchEntity: GlobalSearchEntity,
188
216
  ) =>
217
+ getMapping(businessEntityId).getTitleForSearchEntity?.(searchEntity) ??
189
218
  getTitleForBusinessEntity(
190
219
  businessEntityId,
191
220
  getMainEntityFromSearchEntity(businessEntityId, searchEntity),
@@ -0,0 +1,37 @@
1
+ import { Opportunity } from '../types/opportunities.js';
2
+ import { SearchTransport, Transport, TransportType } from '../types/transports.js';
3
+ import { VehiclePurchase, VehiclePurchaseLogisticsStatus } from '../types/vehicles.js';
4
+
5
+ /**
6
+ * A transport is finished when the journey it describes has demonstrably happened: the customer has
7
+ * the vehicle for a sale delivery, the vehicle is on our park for a purchase pick-up. From then on
8
+ * the record is history and the server refuses edits to it.
9
+ *
10
+ * Not the same thing as the transport's own `doneAt`. Delivery can be declared on the opportunity
11
+ * (a CMR, a delivery confirmation) and arrival on the purchase, without the transport ever being
12
+ * moved — and reversing either of those is what unlocks the transport again, which a status stamped
13
+ * on the transport itself could not express.
14
+ *
15
+ * Shared so the board, the drawer and the server all answer the question the same way.
16
+ */
17
+ export const isTransportCompleted = (
18
+ transport: Transport,
19
+ context: { opportunity?: Opportunity; purchase?: VehiclePurchase },
20
+ ): boolean => {
21
+ if (transport.type === TransportType.SaleDelivery) {
22
+ return context.opportunity?.deliveredAt != null;
23
+ }
24
+
25
+ const status = context.purchase?.logistics.status;
26
+ return (
27
+ status === VehiclePurchaseLogisticsStatus.Arrived ||
28
+ status === VehiclePurchaseLogisticsStatus.CheckedIn
29
+ );
30
+ };
31
+
32
+ /** The same question asked of a search document, which already carries both sides. */
33
+ export const isSearchTransportCompleted = (record: SearchTransport): boolean =>
34
+ isTransportCompleted(record.transport, {
35
+ opportunity: record.opportunity,
36
+ purchase: record.purchase,
37
+ });