@driveflux/api-functions 0.0.7-next.18 → 0.0.7-next.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.
Files changed (90) hide show
  1. package/dist/auth/confirm.js +325 -66
  2. package/dist/auth/emails.js +210 -42
  3. package/dist/auth/formatter.js +9 -9
  4. package/dist/auth/otp.js +374 -120
  5. package/dist/auth/register.js +383 -95
  6. package/dist/auth/register.js.map +1 -1
  7. package/dist/auth/tokens.d.ts +3 -3
  8. package/dist/auth/tokens.js +426 -114
  9. package/dist/auth/verifications.js +581 -176
  10. package/dist/constants.js +4 -4
  11. package/dist/mailjet/calls/manage-contacts-in-list.d.ts +2 -2
  12. package/dist/mailjet/calls/manage-contacts-in-list.d.ts.map +1 -1
  13. package/dist/mailjet/calls/manage-contacts-in-list.js +167 -22
  14. package/dist/mailjet/calls/manage-contacts-in-list.js.map +1 -1
  15. package/dist/mailjet/calls/manage-subscription-status.d.ts +2 -2
  16. package/dist/mailjet/calls/manage-subscription-status.d.ts.map +1 -1
  17. package/dist/mailjet/calls/manage-subscription-status.js +154 -13
  18. package/dist/mailjet/calls/manage-subscription-status.js.map +1 -1
  19. package/dist/mailjet/calls/request-service.js +182 -18
  20. package/dist/mailjet/refresh-email-preferences.js +221 -21
  21. package/dist/mailjet/set-contact.d.ts +2 -2
  22. package/dist/mailjet/set-contact.d.ts.map +1 -1
  23. package/dist/mailjet/set-contact.js +213 -21
  24. package/dist/mailjet/set-contact.js.map +1 -1
  25. package/dist/mailjet/types.d.ts +2 -2
  26. package/dist/mailjet/types.d.ts.map +1 -1
  27. package/dist/mailjet/utils/convert-to-array.d.ts +1 -1
  28. package/dist/mailjet/utils/convert-to-array.d.ts.map +1 -1
  29. package/dist/mailjet/utils/convert-to-array.js +56 -9
  30. package/dist/mailjet/utils/extract-email-preferences.d.ts +1 -1
  31. package/dist/mailjet/utils/extract-email-preferences.d.ts.map +1 -1
  32. package/dist/mailjet/utils/extract-email-preferences.js +214 -37
  33. package/dist/mailjet/utils/lists.js +248 -28
  34. package/dist/mailjet/utils/update-email-references.d.ts +2 -2
  35. package/dist/mailjet/utils/update-email-references.d.ts.map +1 -1
  36. package/dist/mailjet/utils/update-email-references.js +207 -27
  37. package/dist/mailjet/utils/update-email-references.js.map +1 -1
  38. package/dist/notion/client.js +196 -50
  39. package/dist/notion/helpful.js +169 -25
  40. package/dist/notion/schemas/block.js +1 -1
  41. package/dist/notion/schemas/common.js +9 -7
  42. package/dist/notion/schemas/database.d.ts +1 -1
  43. package/dist/notion/schemas/database.js +100 -68
  44. package/dist/notion/schemas/emoji.js +1 -1
  45. package/dist/notion/schemas/file.js +1 -1
  46. package/dist/notion/schemas/kb.js +3 -3
  47. package/dist/notion/schemas/page.d.ts +1 -1
  48. package/dist/notion/schemas/page.js +103 -69
  49. package/dist/notion/schemas/parent.js +4 -4
  50. package/dist/notion/schemas/user.js +2 -2
  51. package/dist/reservation/agree.d.ts +1 -1
  52. package/dist/reservation/agree.d.ts.map +1 -1
  53. package/dist/reservation/agree.js +157 -17
  54. package/dist/reservation/checks.d.ts +1 -1
  55. package/dist/reservation/checks.d.ts.map +1 -1
  56. package/dist/reservation/checks.js +177 -21
  57. package/dist/reservation/display-vehicle.d.ts +1 -1
  58. package/dist/reservation/display-vehicle.js +500 -122
  59. package/dist/reservation/display-vehicle.js.map +1 -1
  60. package/dist/reservation/fetch-or-create.d.ts +2 -2
  61. package/dist/reservation/fetch-or-create.d.ts.map +1 -1
  62. package/dist/reservation/fetch-or-create.js +478 -188
  63. package/dist/reservation/fetch-or-create.js.map +1 -1
  64. package/dist/reservation/invoice.d.ts +3 -3
  65. package/dist/reservation/invoice.d.ts.map +1 -1
  66. package/dist/reservation/invoice.js +492 -182
  67. package/dist/reservation/invoice.js.map +1 -1
  68. package/dist/reservation/payer.d.ts +1 -1
  69. package/dist/reservation/payer.d.ts.map +1 -1
  70. package/dist/reservation/payer.js +175 -25
  71. package/dist/reservation/reserve.d.ts +1 -1
  72. package/dist/reservation/reserve.d.ts.map +1 -1
  73. package/dist/reservation/reserve.js +196 -35
  74. package/dist/reservation/reserve.js.map +1 -1
  75. package/dist/reservation/types.d.ts +0 -1
  76. package/dist/reservation/types.d.ts.map +1 -1
  77. package/dist/reservation/vehicle.d.ts +1 -1
  78. package/dist/reservation/vehicle.d.ts.map +1 -1
  79. package/dist/reservation/vehicle.js +188 -23
  80. package/dist/reservation/vehicle.js.map +1 -1
  81. package/dist/slack.js +268 -57
  82. package/dist/validation.js +98 -38
  83. package/dist/vehicle/vehicle-pricing/constants.d.ts +1 -1
  84. package/dist/vehicle/vehicle-pricing/constants.d.ts.map +1 -1
  85. package/dist/vehicle/vehicle-pricing/constants.js +16 -16
  86. package/dist/vehicle/vehicle-pricing/index.d.ts +1 -1
  87. package/dist/vehicle/vehicle-pricing/index.d.ts.map +1 -1
  88. package/dist/vehicle/vehicle-pricing/index.js +259 -87
  89. package/dist/vehicle/vehicle-pricing/index.js.map +1 -1
  90. package/package.json +21 -21
@@ -1,75 +1,381 @@
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
+ }
1
235
  import { config } from '@driveflux/config/backend';
2
236
  import { prisma } from '@driveflux/db';
3
237
  import { generateId } from '@driveflux/db/id';
4
238
  import { createPricingController } from '@driveflux/db/models/vehicle';
5
- import { getFluxExcessMileage, getFluxPiceMatrix, getHostExcessMileage, getHostsMatrix, getRecommendedMotorcycleDeposit, getStartFeeMatrix } from '../vehicle/vehicle-pricing/index.js';
6
- export const fetchDisplayVehicle = async (displayVehicle)=>{
7
- return typeof displayVehicle === 'string' ? await prisma.displayVehicle.findFirst({
8
- where: {
9
- id: displayVehicle
10
- }
11
- }) : displayVehicle;
12
- };
13
- export const createVehicleFromDisplayVehicle = async (displayVehicle, selectedColor)=>{
14
- const dv = await fetchDisplayVehicle(displayVehicle);
15
- if (!dv || typeof dv !== 'object') return;
16
- if (!dv.details) 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 ? [
23
- transfromSingleImage(mainImage)
24
- ] : [],
25
- ...transformImages(dv.images)
26
- ],
27
- ...transformBasePrices(dv.pricing),
28
- pricing: transformPriceMatrix(dv.type, dv.pricing),
29
- details: transformDetails(dv.details, selectedColor),
30
- host: {
31
- connect: {
32
- id: dv.defaultHostId
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
+ ];
33
272
  }
34
- },
35
- displayVehicle: {
36
- connect: {
37
- id: dv.id
273
+ });
274
+ })();
275
+ };
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
+ ];
38
331
  }
39
- }
40
- };
41
- return await prisma.vehicle.create({
42
- data: vehicleData,
43
- include: {
44
- host: true
45
- }
46
- });
332
+ });
333
+ })();
47
334
  };
48
- export const transfromVehicleDisplayToVehicle = async (displayVehicle, selectedColor)=>{
49
- const dv = await fetchDisplayVehicle(displayVehicle);
50
- if (!dv || typeof dv !== 'object') return;
51
- if (!dv.details) 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 ? [
58
- transfromSingleImage(mainImage)
59
- ] : [],
60
- ...transformImages(dv.images)
61
- ],
62
- ...transformBasePrices(dv.pricing),
63
- pricing: transformPriceMatrix(dv.type, dv.pricing),
64
- details: transformDetails(dv.details, selectedColor),
65
- host: {
66
- address: {
67
- state: 'Kuala Lumpur'
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
+ ];
68
374
  }
69
- }
70
- };
375
+ });
376
+ })();
71
377
  };
72
- export const transformBasicVehicleData = (dv)=>{
378
+ export var transformBasicVehicleData = function(dv) {
73
379
  return {
74
380
  registrationNumber: null,
75
381
  featured: false,
@@ -85,19 +391,20 @@ export const transformBasicVehicleData = (dv)=>{
85
391
  variant: dv.variant,
86
392
  year: dv.year,
87
393
  type: dv.type,
88
- niceName: `${dv.make} ${dv.vehicleModel} ${dv.variant} ${dv.year}`,
89
- niceNameShort: `${dv.make} ${dv.vehicleModel}`,
394
+ niceName: "".concat(dv.make, " ").concat(dv.vehicleModel, " ").concat(dv.variant, " ").concat(dv.year),
395
+ niceNameShort: "".concat(dv.make, " ").concat(dv.vehicleModel),
90
396
  appliedCoupon: dv.appliedCoupon
91
397
  };
92
398
  };
93
- export const transformImages = (images)=>{
399
+ export var transformImages = function(images) {
94
400
  return [
95
401
  transfromSingleImage(images.exterior[0].url, 'exterior'),
96
- transfromSingleImage(images.interior[0].url, 'interior'),
97
- ...images.gallery.map((i)=>transfromSingleImage(i.url))
98
- ];
402
+ transfromSingleImage(images.interior[0].url, 'interior')
403
+ ].concat(_to_consumable_array(images.gallery.map(function(i) {
404
+ return transfromSingleImage(i.url);
405
+ })));
99
406
  };
100
- const transfromSingleImage = (imageUrl, inspectionType)=>{
407
+ var transfromSingleImage = function(imageUrl, inspectionType) {
101
408
  return {
102
409
  default: imageUrl,
103
410
  blurBase64: null,
@@ -111,7 +418,7 @@ const transfromSingleImage = (imageUrl, inspectionType)=>{
111
418
  notActualPhoto: true
112
419
  };
113
420
  };
114
- const transformBasePrices = (pricing)=>{
421
+ var transformBasePrices = function(pricing) {
115
422
  return {
116
423
  basePrice: pricing.matrix.plan36.lite,
117
424
  basePricePlan1: pricing.matrix.plan1.lite,
@@ -121,38 +428,38 @@ const transformBasePrices = (pricing)=>{
121
428
  basePricePlan60: pricing.matrix.plan60.lite
122
429
  };
123
430
  };
124
- const transformPriceMatrix = (vehicleType, pricing)=>{
125
- const baseline = pricing?.matrix.plan36.lite;
126
- const ultraTier = 'tier1';
127
- const fluxPriceCoefficient = 25;
128
- const priceMatrix = pricing.matrix;
129
- const flatPricing = false;
130
- const bought = false;
131
- const tmv = pricing.tmv;
132
- const gfv = null;
133
- const gfvNotApplicable = true;
134
- const { availablePlans, availableMileagePackages } = getNonZeroKeys(priceMatrix);
135
- const pricingController = createPricingController({
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({
136
443
  coefficient: fluxPriceCoefficient,
137
- vehicleType
444
+ vehicleType: vehicleType
138
445
  });
139
- const startFeeMatrix = excludeServiceFeesFrom(getStartFeeMatrix(pricingController, baseline, flatPricing));
140
- const hostMatrix = excludeServiceFeesFrom(getHostsMatrix(pricingController, baseline, ultraTier, flatPricing));
141
- const hostExcessMileage = getHostExcessMileage(pricingController, baseline);
142
- const fluxPriceMatrix = excludeServiceFeesFrom(getFluxPiceMatrix(pricingController, vehicleType, baseline, hostMatrix, ultraTier, flatPricing));
143
- const fluxExcessMileage = getFluxExcessMileage(pricingController, baseline);
144
- const recommendedDeposit = pricing.refundableDeposit || vehicleType === 'motorcycle' ? getRecommendedMotorcycleDeposit(baseline) : null;
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;
145
452
  return {
146
- tmv,
147
- gfv,
148
- gfvNotApplicable,
149
- ultraTier,
453
+ tmv: tmv,
454
+ gfv: gfv,
455
+ gfvNotApplicable: gfvNotApplicable,
456
+ ultraTier: ultraTier,
150
457
  baseline: baseline,
151
- recommendedDeposit,
152
- availableMileagePackages,
153
- availablePlans,
154
- bought,
155
- flatPricing,
458
+ recommendedDeposit: recommendedDeposit,
459
+ availableMileagePackages: availableMileagePackages,
460
+ availablePlans: availablePlans,
461
+ bought: bought,
462
+ flatPricing: flatPricing,
156
463
  fluxPrice: {
157
464
  coefficient: fluxPriceCoefficient,
158
465
  matrix: fluxPriceMatrix,
@@ -176,27 +483,64 @@ const transformPriceMatrix = (vehicleType, pricing)=>{
176
483
  }
177
484
  };
178
485
  };
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);
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
+ }
190
521
  }
191
522
  }
192
523
  }
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
+ }
193
537
  }
194
538
  return {
195
539
  availablePlans: Array.from(planKeys),
196
540
  availableMileagePackages: Array.from(mileageKeys)
197
541
  };
198
542
  };
199
- const _getInspection = ()=>{
543
+ var _getInspection = function() {
200
544
  return {
201
545
  exterior: 5,
202
546
  interior: 5,
@@ -206,8 +550,8 @@ const _getInspection = ()=>{
206
550
  comment: 'COMMENT HERE'
207
551
  };
208
552
  };
209
- const transformDetails = (details, selectColor)=>{
210
- const color = selectColor || details.colors[0].name || '';
553
+ var transformDetails = function(details, selectColor) {
554
+ var color = selectColor || details.colors[0].name || '';
211
555
  return {
212
556
  numberOfSeats: details.numberOfSeats,
213
557
  doors: details.doors,
@@ -218,19 +562,53 @@ const transformDetails = (details, selectColor)=>{
218
562
  drivetrain: details.drivetrain,
219
563
  accelerationTo100km: details.accelerationTo100km,
220
564
  fuelConsumptionLitersPer100Km: details.fuelConsumptionLitersPer100Km,
221
- color,
565
+ color: color,
222
566
  features: details.features,
223
567
  condition: 'new'
224
568
  };
225
569
  };
226
- const excludeServiceFeesFrom = (originalMatrix)=>{
227
- const matrix = {};
228
- for (const [planKey, planValue] of Object.entries(originalMatrix)){
229
- if (!planValue) continue;
230
- if (!matrix[planKey]) matrix[planKey] = {};
231
- for (const [mileageKey, price] of Object.entries(planValue)){
232
- if (typeof price === 'number') {
233
- matrix[planKey][mileageKey] = price / (1 + config.serviceRate);
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;
234
612
  }
235
613
  }
236
614
  }