@driveflux/api-functions 0.0.6 → 0.0.7-next.1

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 (53) hide show
  1. package/dist/auth/confirm.js +73 -327
  2. package/dist/auth/emails.js +43 -210
  3. package/dist/auth/formatter.js +11 -11
  4. package/dist/auth/otp.js +122 -392
  5. package/dist/auth/register.js +100 -396
  6. package/dist/auth/tokens.d.ts +3 -3
  7. package/dist/auth/tokens.js +115 -430
  8. package/dist/auth/verifications.d.ts.map +1 -1
  9. package/dist/auth/verifications.js +191 -514
  10. package/dist/auth/verifications.js.map +1 -1
  11. package/dist/constants.js +5 -4
  12. package/dist/mailjet/calls/manage-contacts-in-list.js +22 -166
  13. package/dist/mailjet/calls/manage-subscription-status.js +13 -153
  14. package/dist/mailjet/calls/request-service.d.ts +1 -1
  15. package/dist/mailjet/calls/request-service.d.ts.map +1 -1
  16. package/dist/mailjet/calls/request-service.js +18 -183
  17. package/dist/mailjet/refresh-email-preferences.js +26 -225
  18. package/dist/mailjet/set-contact.js +23 -214
  19. package/dist/mailjet/types.js +2 -1
  20. package/dist/mailjet/utils/convert-to-array.js +9 -58
  21. package/dist/mailjet/utils/extract-email-preferences.js +41 -217
  22. package/dist/mailjet/utils/lists.js +30 -249
  23. package/dist/mailjet/utils/update-email-references.js +27 -208
  24. package/dist/notion/client.js +48 -197
  25. package/dist/notion/helpful.js +29 -170
  26. package/dist/notion/schemas/block.js +49 -43
  27. package/dist/notion/schemas/common.js +17 -14
  28. package/dist/notion/schemas/database.js +125 -159
  29. package/dist/notion/schemas/emoji.js +3 -2
  30. package/dist/notion/schemas/file.js +10 -10
  31. package/dist/notion/schemas/kb.js +9 -8
  32. package/dist/notion/schemas/page.js +126 -171
  33. package/dist/notion/schemas/parent.js +9 -8
  34. package/dist/notion/schemas/user.js +21 -20
  35. package/dist/reservation/agree.js +19 -158
  36. package/dist/reservation/checks.js +23 -178
  37. package/dist/reservation/display-vehicle.d.ts +37 -37
  38. package/dist/reservation/display-vehicle.d.ts.map +1 -1
  39. package/dist/reservation/display-vehicle.js +142 -514
  40. package/dist/reservation/fetch-or-create.js +197 -482
  41. package/dist/reservation/invoice.js +198 -496
  42. package/dist/reservation/payer.js +28 -177
  43. package/dist/reservation/reserve.js +31 -191
  44. package/dist/reservation/types.js +2 -1
  45. package/dist/reservation/vehicle.js +24 -186
  46. package/dist/slack.d.ts +2 -2
  47. package/dist/slack.d.ts.map +1 -1
  48. package/dist/slack.js +67 -273
  49. package/dist/validation.js +81 -139
  50. package/dist/vehicle/vehicle-pricing/constants.js +33 -36
  51. package/dist/vehicle/vehicle-pricing/index.js +99 -257
  52. package/dist/vehicle/vehicle-pricing/types.js +2 -1
  53. package/package.json +12 -12
@@ -1,381 +1,73 @@
1
- function _array_like_to_array(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
5
- }
6
- function _array_with_holes(arr) {
7
- if (Array.isArray(arr)) return arr;
8
- }
9
- function _array_without_holes(arr) {
10
- if (Array.isArray(arr)) return _array_like_to_array(arr);
11
- }
12
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
13
- try {
14
- var info = gen[key](arg);
15
- var value = info.value;
16
- } catch (error) {
17
- reject(error);
18
- return;
19
- }
20
- if (info.done) {
21
- resolve(value);
22
- } else {
23
- Promise.resolve(value).then(_next, _throw);
24
- }
25
- }
26
- function _async_to_generator(fn) {
27
- return function() {
28
- var self = this, args = arguments;
29
- return new Promise(function(resolve, reject) {
30
- var gen = fn.apply(self, args);
31
- function _next(value) {
32
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
33
- }
34
- function _throw(err) {
35
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
36
- }
37
- _next(undefined);
38
- });
39
- };
40
- }
41
- function _define_property(obj, key, value) {
42
- if (key in obj) {
43
- Object.defineProperty(obj, key, {
44
- value: value,
45
- enumerable: true,
46
- configurable: true,
47
- writable: true
48
- });
49
- } else {
50
- obj[key] = value;
51
- }
52
- return obj;
53
- }
54
- function _iterable_to_array(iter) {
55
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
56
- }
57
- function _iterable_to_array_limit(arr, i) {
58
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
59
- if (_i == null) return;
60
- var _arr = [];
61
- var _n = true;
62
- var _d = false;
63
- var _s, _e;
64
- try {
65
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
66
- _arr.push(_s.value);
67
- if (i && _arr.length === i) break;
68
- }
69
- } catch (err) {
70
- _d = true;
71
- _e = err;
72
- } finally{
73
- try {
74
- if (!_n && _i["return"] != null) _i["return"]();
75
- } finally{
76
- if (_d) throw _e;
77
- }
78
- }
79
- return _arr;
80
- }
81
- function _non_iterable_rest() {
82
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
83
- }
84
- function _non_iterable_spread() {
85
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
86
- }
87
- function _object_spread(target) {
88
- for(var i = 1; i < arguments.length; i++){
89
- var source = arguments[i] != null ? arguments[i] : {};
90
- var ownKeys = Object.keys(source);
91
- if (typeof Object.getOwnPropertySymbols === "function") {
92
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
93
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
94
- }));
95
- }
96
- ownKeys.forEach(function(key) {
97
- _define_property(target, key, source[key]);
98
- });
99
- }
100
- return target;
101
- }
102
- function ownKeys(object, enumerableOnly) {
103
- var keys = Object.keys(object);
104
- if (Object.getOwnPropertySymbols) {
105
- var symbols = Object.getOwnPropertySymbols(object);
106
- if (enumerableOnly) {
107
- symbols = symbols.filter(function(sym) {
108
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
109
- });
110
- }
111
- keys.push.apply(keys, symbols);
112
- }
113
- return keys;
114
- }
115
- function _object_spread_props(target, source) {
116
- source = source != null ? source : {};
117
- if (Object.getOwnPropertyDescriptors) {
118
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
119
- } else {
120
- ownKeys(Object(source)).forEach(function(key) {
121
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
122
- });
123
- }
124
- return target;
125
- }
126
- function _sliced_to_array(arr, i) {
127
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
128
- }
129
- function _to_consumable_array(arr) {
130
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
131
- }
132
- function _type_of(obj) {
133
- "@swc/helpers - typeof";
134
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
135
- }
136
- function _unsupported_iterable_to_array(o, minLen) {
137
- if (!o) return;
138
- if (typeof o === "string") return _array_like_to_array(o, minLen);
139
- var n = Object.prototype.toString.call(o).slice(8, -1);
140
- if (n === "Object" && o.constructor) n = o.constructor.name;
141
- if (n === "Map" || n === "Set") return Array.from(n);
142
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
143
- }
144
- function _ts_generator(thisArg, body) {
145
- var f, y, t, _ = {
146
- label: 0,
147
- sent: function() {
148
- if (t[0] & 1) throw t[1];
149
- return t[1];
150
- },
151
- trys: [],
152
- ops: []
153
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
154
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
155
- return this;
156
- }), g;
157
- function verb(n) {
158
- return function(v) {
159
- return step([
160
- n,
161
- v
162
- ]);
163
- };
164
- }
165
- function step(op) {
166
- if (f) throw new TypeError("Generator is already executing.");
167
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
168
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
169
- if (y = 0, t) op = [
170
- op[0] & 2,
171
- t.value
172
- ];
173
- switch(op[0]){
174
- case 0:
175
- case 1:
176
- t = op;
177
- break;
178
- case 4:
179
- _.label++;
180
- return {
181
- value: op[1],
182
- done: false
183
- };
184
- case 5:
185
- _.label++;
186
- y = op[1];
187
- op = [
188
- 0
189
- ];
190
- continue;
191
- case 7:
192
- op = _.ops.pop();
193
- _.trys.pop();
194
- continue;
195
- default:
196
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
197
- _ = 0;
198
- continue;
199
- }
200
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
201
- _.label = op[1];
202
- break;
203
- }
204
- if (op[0] === 6 && _.label < t[1]) {
205
- _.label = t[1];
206
- t = op;
207
- break;
208
- }
209
- if (t && _.label < t[2]) {
210
- _.label = t[2];
211
- _.ops.push(op);
212
- break;
213
- }
214
- if (t[2]) _.ops.pop();
215
- _.trys.pop();
216
- continue;
217
- }
218
- op = body.call(thisArg, _);
219
- } catch (e) {
220
- op = [
221
- 6,
222
- e
223
- ];
224
- y = 0;
225
- } finally{
226
- f = t = 0;
227
- }
228
- if (op[0] & 5) throw op[1];
229
- return {
230
- value: op[0] ? op[1] : void 0,
231
- done: true
232
- };
233
- }
234
- }
235
1
  import { config } from '@driveflux/config/backend';
236
- import { prisma } from '@driveflux/db';
2
+ import { prisma, } from '@driveflux/db';
237
3
  import { generateId } from '@driveflux/db/id';
238
4
  import { createPricingController } from '@driveflux/db/models/vehicle';
239
- import { getFluxExcessMileage, getFluxPiceMatrix, getHostExcessMileage, getHostsMatrix, getRecommendedMotorcycleDeposit, getStartFeeMatrix } from '../vehicle/vehicle-pricing';
240
- export var fetchDisplayVehicle = function(displayVehicle) {
241
- return _async_to_generator(function() {
242
- var _tmp;
243
- return _ts_generator(this, function(_state) {
244
- switch(_state.label){
245
- case 0:
246
- if (!(typeof displayVehicle === 'string')) return [
247
- 3,
248
- 2
249
- ];
250
- return [
251
- 4,
252
- prisma.displayVehicle.findFirst({
253
- where: {
254
- id: displayVehicle
255
- }
256
- })
257
- ];
258
- case 1:
259
- _tmp = _state.sent();
260
- return [
261
- 3,
262
- 3
263
- ];
264
- case 2:
265
- _tmp = displayVehicle;
266
- _state.label = 3;
267
- case 3:
268
- return [
269
- 2,
270
- _tmp
271
- ];
272
- }
273
- });
274
- })();
5
+ import { getFluxExcessMileage, getFluxPiceMatrix, getHostExcessMileage, getHostsMatrix, getRecommendedMotorcycleDeposit, getStartFeeMatrix, } from '../vehicle/vehicle-pricing';
6
+ export const fetchDisplayVehicle = async (displayVehicle) => {
7
+ return typeof displayVehicle === 'string'
8
+ ? await prisma.displayVehicle.findFirst({ where: { id: displayVehicle } })
9
+ : displayVehicle;
275
10
  };
276
- export var createVehicleFromDisplayVehicle = function(displayVehicle, selectedColor) {
277
- return _async_to_generator(function() {
278
- var _dv_images_main_find, dv, mainImage, vehicleData;
279
- return _ts_generator(this, function(_state) {
280
- switch(_state.label){
281
- case 0:
282
- return [
283
- 4,
284
- fetchDisplayVehicle(displayVehicle)
285
- ];
286
- case 1:
287
- dv = _state.sent();
288
- if (!dv || (typeof dv === "undefined" ? "undefined" : _type_of(dv)) !== 'object') return [
289
- 2
290
- ];
291
- if (!dv.details) return [
292
- 2
293
- ];
294
- mainImage = (_dv_images_main_find = dv.images.main.find(function(m) {
295
- return m.variant === selectedColor;
296
- })) === null || _dv_images_main_find === void 0 ? void 0 : _dv_images_main_find.url;
297
- vehicleData = _object_spread_props(_object_spread(_object_spread_props(_object_spread({
298
- id: generateId('Vehicle')
299
- }, transformBasicVehicleData(dv)), {
300
- images: _to_consumable_array(mainImage ? [
301
- transfromSingleImage(mainImage)
302
- ] : []).concat(_to_consumable_array(transformImages(dv.images)))
303
- }), transformBasePrices(dv.pricing)), {
304
- pricing: transformPriceMatrix(dv.type, dv.pricing),
305
- details: transformDetails(dv.details, selectedColor),
306
- host: {
307
- connect: {
308
- id: dv.defaultHostId
309
- }
310
- },
311
- displayVehicle: {
312
- connect: {
313
- id: dv.id
314
- }
315
- }
316
- });
317
- return [
318
- 4,
319
- prisma.vehicle.create({
320
- data: vehicleData,
321
- include: {
322
- host: true
323
- }
324
- })
325
- ];
326
- case 2:
327
- return [
328
- 2,
329
- _state.sent()
330
- ];
331
- }
332
- });
333
- })();
11
+ export const createVehicleFromDisplayVehicle = async (displayVehicle, selectedColor) => {
12
+ const dv = await fetchDisplayVehicle(displayVehicle);
13
+ if (!dv || typeof dv !== 'object')
14
+ return;
15
+ if (!dv.details)
16
+ return;
17
+ const mainImage = dv.images.main.find((m) => m.variant === selectedColor)?.url;
18
+ const vehicleData = {
19
+ id: generateId('Vehicle'),
20
+ ...transformBasicVehicleData(dv),
21
+ images: [
22
+ ...(mainImage ? [transfromSingleImage(mainImage)] : []),
23
+ ...transformImages(dv.images),
24
+ ],
25
+ ...transformBasePrices(dv.pricing),
26
+ pricing: transformPriceMatrix(dv.type, dv.pricing),
27
+ details: transformDetails(dv.details, selectedColor),
28
+ host: {
29
+ connect: {
30
+ id: dv.defaultHostId,
31
+ },
32
+ },
33
+ displayVehicle: {
34
+ connect: {
35
+ id: dv.id,
36
+ },
37
+ },
38
+ };
39
+ return await prisma.vehicle.create({
40
+ data: vehicleData,
41
+ include: {
42
+ host: true,
43
+ },
44
+ });
334
45
  };
335
- export var transfromVehicleDisplayToVehicle = function(displayVehicle, selectedColor) {
336
- return _async_to_generator(function() {
337
- var _dv_images_main_find, dv, mainImage;
338
- return _ts_generator(this, function(_state) {
339
- switch(_state.label){
340
- case 0:
341
- return [
342
- 4,
343
- fetchDisplayVehicle(displayVehicle)
344
- ];
345
- case 1:
346
- dv = _state.sent();
347
- if (!dv || (typeof dv === "undefined" ? "undefined" : _type_of(dv)) !== 'object') return [
348
- 2
349
- ];
350
- if (!dv.details) return [
351
- 2
352
- ];
353
- mainImage = (_dv_images_main_find = dv.images.main.find(function(m) {
354
- return m.variant === selectedColor;
355
- })) === null || _dv_images_main_find === void 0 ? void 0 : _dv_images_main_find.url;
356
- return [
357
- 2,
358
- _object_spread_props(_object_spread(_object_spread_props(_object_spread({
359
- id: dv.id
360
- }, transformBasicVehicleData(dv)), {
361
- images: _to_consumable_array(mainImage ? [
362
- transfromSingleImage(mainImage)
363
- ] : []).concat(_to_consumable_array(transformImages(dv.images)))
364
- }), transformBasePrices(dv.pricing)), {
365
- pricing: transformPriceMatrix(dv.type, dv.pricing),
366
- details: transformDetails(dv.details, selectedColor),
367
- host: {
368
- address: {
369
- state: 'Kuala Lumpur'
370
- }
371
- }
372
- })
373
- ];
374
- }
375
- });
376
- })();
46
+ export const transfromVehicleDisplayToVehicle = async (displayVehicle, selectedColor) => {
47
+ const dv = await fetchDisplayVehicle(displayVehicle);
48
+ if (!dv || typeof dv !== 'object')
49
+ return;
50
+ if (!dv.details)
51
+ return;
52
+ const mainImage = dv.images.main.find((m) => m.variant === selectedColor)?.url;
53
+ return {
54
+ id: dv.id,
55
+ ...transformBasicVehicleData(dv),
56
+ images: [
57
+ ...(mainImage ? [transfromSingleImage(mainImage)] : []),
58
+ ...transformImages(dv.images),
59
+ ],
60
+ ...transformBasePrices(dv.pricing),
61
+ pricing: transformPriceMatrix(dv.type, dv.pricing),
62
+ details: transformDetails(dv.details, selectedColor),
63
+ host: {
64
+ address: {
65
+ state: 'Kuala Lumpur',
66
+ },
67
+ },
68
+ };
377
69
  };
378
- export var transformBasicVehicleData = function(dv) {
70
+ export const transformBasicVehicleData = (dv) => {
379
71
  return {
380
72
  registrationNumber: null,
381
73
  featured: false,
@@ -391,20 +83,19 @@ export var transformBasicVehicleData = function(dv) {
391
83
  variant: dv.variant,
392
84
  year: dv.year,
393
85
  type: dv.type,
394
- niceName: "".concat(dv.make, " ").concat(dv.vehicleModel, " ").concat(dv.variant, " ").concat(dv.year),
395
- niceNameShort: "".concat(dv.make, " ").concat(dv.vehicleModel),
396
- appliedCoupon: dv.appliedCoupon
86
+ niceName: `${dv.make} ${dv.vehicleModel} ${dv.variant} ${dv.year}`,
87
+ niceNameShort: `${dv.make} ${dv.vehicleModel}`,
88
+ appliedCoupon: dv.appliedCoupon,
397
89
  };
398
90
  };
399
- export var transformImages = function(images) {
91
+ export const transformImages = (images) => {
400
92
  return [
401
93
  transfromSingleImage(images.exterior[0].url, 'exterior'),
402
- transfromSingleImage(images.interior[0].url, 'interior')
403
- ].concat(_to_consumable_array(images.gallery.map(function(i) {
404
- return transfromSingleImage(i.url);
405
- })));
94
+ transfromSingleImage(images.interior[0].url, 'interior'),
95
+ ...images.gallery.map((i) => transfromSingleImage(i.url)),
96
+ ];
406
97
  };
407
- var transfromSingleImage = function(imageUrl, inspectionType) {
98
+ const transfromSingleImage = (imageUrl, inspectionType) => {
408
99
  return {
409
100
  default: imageUrl,
410
101
  blurBase64: null,
@@ -415,51 +106,53 @@ var transfromSingleImage = function(imageUrl, inspectionType) {
415
106
  description: null,
416
107
  inspection: !!inspectionType,
417
108
  inspectionType: inspectionType || null,
418
- notActualPhoto: true
109
+ notActualPhoto: true,
419
110
  };
420
111
  };
421
- var transformBasePrices = function(pricing) {
112
+ const transformBasePrices = (pricing) => {
422
113
  return {
423
114
  basePrice: pricing.matrix.plan36.lite,
424
115
  basePricePlan1: pricing.matrix.plan1.lite,
425
116
  basePricePlan12: pricing.matrix.plan12.lite,
426
117
  basePricePlan24: pricing.matrix.plan24.lite,
427
118
  basePricePlan36: pricing.matrix.plan36.lite,
428
- basePricePlan60: pricing.matrix.plan60.lite
119
+ basePricePlan60: pricing.matrix.plan60.lite,
429
120
  };
430
121
  };
431
- var transformPriceMatrix = function(vehicleType, pricing) {
432
- var baseline = pricing === null || pricing === void 0 ? void 0 : pricing.matrix.plan36.lite;
433
- var ultraTier = 'tier1';
434
- var fluxPriceCoefficient = 25;
435
- var priceMatrix = pricing.matrix;
436
- var flatPricing = false;
437
- var bought = false;
438
- var tmv = pricing.tmv;
439
- var gfv = null;
440
- var gfvNotApplicable = true;
441
- var _getNonZeroKeys = getNonZeroKeys(priceMatrix), availablePlans = _getNonZeroKeys.availablePlans, availableMileagePackages = _getNonZeroKeys.availableMileagePackages;
442
- var pricingController = createPricingController({
122
+ const transformPriceMatrix = (vehicleType, pricing) => {
123
+ const baseline = pricing?.matrix.plan36.lite;
124
+ const ultraTier = 'tier1';
125
+ const fluxPriceCoefficient = 25;
126
+ const priceMatrix = pricing.matrix;
127
+ const flatPricing = false;
128
+ const bought = false;
129
+ const tmv = pricing.tmv;
130
+ const gfv = null;
131
+ const gfvNotApplicable = true;
132
+ const { availablePlans, availableMileagePackages } = getNonZeroKeys(priceMatrix);
133
+ const pricingController = createPricingController({
443
134
  coefficient: fluxPriceCoefficient,
444
- vehicleType: vehicleType
135
+ vehicleType,
445
136
  });
446
- var startFeeMatrix = excludeServiceFeesFrom(getStartFeeMatrix(pricingController, baseline, flatPricing));
447
- var hostMatrix = excludeServiceFeesFrom(getHostsMatrix(pricingController, baseline, ultraTier, flatPricing));
448
- var hostExcessMileage = getHostExcessMileage(pricingController, baseline);
449
- var fluxPriceMatrix = excludeServiceFeesFrom(getFluxPiceMatrix(pricingController, vehicleType, baseline, hostMatrix, ultraTier, flatPricing));
450
- var fluxExcessMileage = getFluxExcessMileage(pricingController, baseline);
451
- var recommendedDeposit = pricing.refundableDeposit || vehicleType === 'motorcycle' ? getRecommendedMotorcycleDeposit(baseline) : null;
137
+ const startFeeMatrix = excludeServiceFeesFrom(getStartFeeMatrix(pricingController, baseline, flatPricing));
138
+ const hostMatrix = excludeServiceFeesFrom(getHostsMatrix(pricingController, baseline, ultraTier, flatPricing));
139
+ const hostExcessMileage = getHostExcessMileage(pricingController, baseline);
140
+ const fluxPriceMatrix = excludeServiceFeesFrom(getFluxPiceMatrix(pricingController, vehicleType, baseline, hostMatrix, ultraTier, flatPricing));
141
+ const fluxExcessMileage = getFluxExcessMileage(pricingController, baseline);
142
+ const recommendedDeposit = pricing.refundableDeposit || vehicleType === 'motorcycle'
143
+ ? getRecommendedMotorcycleDeposit(baseline)
144
+ : null;
452
145
  return {
453
- tmv: tmv,
454
- gfv: gfv,
455
- gfvNotApplicable: gfvNotApplicable,
456
- ultraTier: ultraTier,
146
+ tmv,
147
+ gfv,
148
+ gfvNotApplicable,
149
+ ultraTier,
457
150
  baseline: baseline,
458
- recommendedDeposit: recommendedDeposit,
459
- availableMileagePackages: availableMileagePackages,
460
- availablePlans: availablePlans,
461
- bought: bought,
462
- flatPricing: flatPricing,
151
+ recommendedDeposit,
152
+ availableMileagePackages,
153
+ availablePlans,
154
+ bought,
155
+ flatPricing,
463
156
  fluxPrice: {
464
157
  coefficient: fluxPriceCoefficient,
465
158
  matrix: fluxPriceMatrix,
@@ -467,150 +160,85 @@ var transformPriceMatrix = function(vehicleType, pricing) {
467
160
  excessMileage: fluxExcessMileage,
468
161
  originalExcessMileage: fluxExcessMileage,
469
162
  matrixComments: null,
470
- add: null
163
+ add: null,
471
164
  },
472
165
  hostTake: {
473
166
  matrix: hostMatrix,
474
167
  originalMatrix: hostMatrix,
475
168
  excessMileage: hostExcessMileage,
476
169
  originalExcessMileage: hostExcessMileage,
477
- matrixComments: null
170
+ matrixComments: null,
478
171
  },
479
172
  startFee: {
480
173
  matrix: startFeeMatrix,
481
174
  originalMatrix: startFeeMatrix,
482
- matrixComments: null
483
- }
175
+ matrixComments: null,
176
+ },
484
177
  };
485
178
  };
486
- var getNonZeroKeys = function(matrix) {
487
- var planKeys = new Set();
488
- var mileageKeys = new Set();
489
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
490
- try {
491
- for(var _iterator = Object.entries(matrix)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
492
- var _step_value = _sliced_to_array(_step.value, 2), plan = _step_value[0], mileageMap = _step_value[1];
493
- var entries = Object.entries(mileageMap !== null && mileageMap !== void 0 ? mileageMap : {});
494
- var hasNonZero = entries.some(function(param) {
495
- var _param = _sliced_to_array(param, 2), _ = _param[0], value = _param[1];
496
- return (value !== null && value !== void 0 ? value : 0) > 0;
497
- });
498
- if (hasNonZero) {
499
- planKeys.add(plan);
500
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
501
- try {
502
- for(var _iterator1 = entries[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
503
- var _step_value1 = _sliced_to_array(_step1.value, 2), mileage = _step_value1[0], value = _step_value1[1];
504
- if ((value !== null && value !== void 0 ? value : 0) > 0) {
505
- mileageKeys.add(mileage);
506
- }
507
- }
508
- } catch (err) {
509
- _didIteratorError1 = true;
510
- _iteratorError1 = err;
511
- } finally{
512
- try {
513
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
514
- _iterator1.return();
515
- }
516
- } finally{
517
- if (_didIteratorError1) {
518
- throw _iteratorError1;
519
- }
520
- }
179
+ const getNonZeroKeys = (matrix) => {
180
+ const planKeys = new Set();
181
+ const mileageKeys = new Set();
182
+ for (const [plan, mileageMap] of Object.entries(matrix)) {
183
+ const entries = Object.entries(mileageMap ?? {});
184
+ const hasNonZero = entries.some(([_, value]) => (value ?? 0) > 0);
185
+ if (hasNonZero) {
186
+ planKeys.add(plan);
187
+ for (const [mileage, value] of entries) {
188
+ if ((value ?? 0) > 0) {
189
+ mileageKeys.add(mileage);
521
190
  }
522
191
  }
523
192
  }
524
- } catch (err) {
525
- _didIteratorError = true;
526
- _iteratorError = err;
527
- } finally{
528
- try {
529
- if (!_iteratorNormalCompletion && _iterator.return != null) {
530
- _iterator.return();
531
- }
532
- } finally{
533
- if (_didIteratorError) {
534
- throw _iteratorError;
535
- }
536
- }
537
193
  }
538
194
  return {
539
195
  availablePlans: Array.from(planKeys),
540
- availableMileagePackages: Array.from(mileageKeys)
196
+ availableMileagePackages: Array.from(mileageKeys),
541
197
  };
542
198
  };
543
- var _getInspection = function() {
199
+ const _getInspection = () => {
544
200
  return {
545
201
  exterior: 5,
546
202
  interior: 5,
547
203
  engine: 5,
548
204
  frame: 5,
549
205
  total: 5,
550
- comment: 'COMMENT HERE'
206
+ comment: 'COMMENT HERE',
551
207
  };
552
208
  };
553
- var transformDetails = function(details, selectColor) {
554
- var color = selectColor || details.colors[0].name || '';
209
+ const transformDetails = (details, selectColor) => {
210
+ const color = selectColor || details.colors[0].name || '';
555
211
  return {
556
212
  numberOfSeats: details.numberOfSeats,
557
213
  doors: details.doors,
558
214
  bodyType: details.bodyType,
559
215
  transmission: details.transmission,
560
216
  engineType: details.fuelType,
561
- engineCapacity: details.fuelType === 'electric' ? details.batteryCapacity : details.engineCapacity,
217
+ engineCapacity: details.fuelType === 'electric'
218
+ ? details.batteryCapacity
219
+ : details.engineCapacity,
562
220
  drivetrain: details.drivetrain,
563
221
  accelerationTo100km: details.accelerationTo100km,
564
222
  fuelConsumptionLitersPer100Km: details.fuelConsumptionLitersPer100Km,
565
- color: color,
223
+ color,
566
224
  features: details.features,
567
- condition: 'new'
225
+ condition: 'new',
568
226
  };
569
227
  };
570
- var excludeServiceFeesFrom = function(originalMatrix) {
571
- var matrix = {};
572
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
573
- try {
574
- for(var _iterator = Object.entries(originalMatrix)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
575
- var _step_value = _sliced_to_array(_step.value, 2), planKey = _step_value[0], planValue = _step_value[1];
576
- if (!planValue) continue;
577
- if (!matrix[planKey]) matrix[planKey] = {};
578
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
579
- try {
580
- for(var _iterator1 = Object.entries(planValue)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
581
- var _step_value1 = _sliced_to_array(_step1.value, 2), mileageKey = _step_value1[0], price = _step_value1[1];
582
- if (typeof price === 'number') {
583
- matrix[planKey][mileageKey] = price / (1 + config.serviceRate);
584
- }
585
- }
586
- } catch (err) {
587
- _didIteratorError1 = true;
588
- _iteratorError1 = err;
589
- } finally{
590
- try {
591
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
592
- _iterator1.return();
593
- }
594
- } finally{
595
- if (_didIteratorError1) {
596
- throw _iteratorError1;
597
- }
598
- }
599
- }
600
- }
601
- } catch (err) {
602
- _didIteratorError = true;
603
- _iteratorError = err;
604
- } finally{
605
- try {
606
- if (!_iteratorNormalCompletion && _iterator.return != null) {
607
- _iterator.return();
608
- }
609
- } finally{
610
- if (_didIteratorError) {
611
- throw _iteratorError;
228
+ const excludeServiceFeesFrom = (originalMatrix) => {
229
+ const matrix = {};
230
+ for (const [planKey, planValue] of Object.entries(originalMatrix)) {
231
+ if (!planValue)
232
+ continue;
233
+ if (!matrix[planKey])
234
+ matrix[planKey] = {};
235
+ for (const [mileageKey, price] of Object.entries(planValue)) {
236
+ if (typeof price === 'number') {
237
+ matrix[planKey][mileageKey] =
238
+ price / (1 + config.serviceRate);
612
239
  }
613
240
  }
614
241
  }
615
242
  return matrix;
616
243
  };
244
+ //# sourceMappingURL=display-vehicle.js.map