@driveflux/api-functions 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/confirm.js +327 -73
- package/dist/auth/emails.js +210 -43
- package/dist/auth/formatter.js +11 -11
- package/dist/auth/otp.js +392 -122
- package/dist/auth/register.js +396 -100
- package/dist/auth/tokens.js +430 -115
- package/dist/auth/verifications.js +512 -154
- package/dist/constants.js +4 -5
- package/dist/mailjet/calls/manage-contacts-in-list.js +166 -22
- package/dist/mailjet/calls/manage-subscription-status.js +153 -13
- package/dist/mailjet/calls/request-service.js +183 -18
- package/dist/mailjet/refresh-email-preferences.d.ts +10 -10
- package/dist/mailjet/refresh-email-preferences.d.ts.map +1 -1
- package/dist/mailjet/refresh-email-preferences.js +226 -27
- package/dist/mailjet/refresh-email-preferences.js.map +1 -1
- package/dist/mailjet/set-contact.d.ts +10 -10
- package/dist/mailjet/set-contact.d.ts.map +1 -1
- package/dist/mailjet/set-contact.js +215 -24
- package/dist/mailjet/set-contact.js.map +1 -1
- package/dist/mailjet/types.js +1 -2
- package/dist/mailjet/utils/convert-to-array.js +58 -9
- package/dist/mailjet/utils/extract-email-preferences.d.ts +8 -8
- package/dist/mailjet/utils/extract-email-preferences.d.ts.map +1 -1
- package/dist/mailjet/utils/extract-email-preferences.js +218 -42
- package/dist/mailjet/utils/extract-email-preferences.js.map +1 -1
- package/dist/mailjet/utils/lists.js +249 -30
- package/dist/mailjet/utils/update-email-references.js +208 -27
- package/dist/notion/client.js +197 -48
- package/dist/notion/helpful.js +170 -29
- package/dist/notion/schemas/block.js +43 -49
- package/dist/notion/schemas/common.js +14 -17
- package/dist/notion/schemas/database.js +159 -125
- package/dist/notion/schemas/emoji.js +2 -3
- package/dist/notion/schemas/file.js +10 -10
- package/dist/notion/schemas/kb.js +8 -9
- package/dist/notion/schemas/page.js +171 -126
- package/dist/notion/schemas/parent.js +8 -9
- package/dist/notion/schemas/user.js +20 -21
- package/dist/reservation/agree.js +158 -19
- package/dist/reservation/checks.js +178 -23
- package/dist/reservation/display-vehicle.js +514 -142
- package/dist/reservation/fetch-or-create.js +482 -197
- package/dist/reservation/invoice.js +496 -198
- package/dist/reservation/payer.js +177 -28
- package/dist/reservation/reserve.js +191 -31
- package/dist/reservation/types.js +1 -2
- package/dist/reservation/vehicle.js +186 -24
- package/dist/slack.js +273 -67
- package/dist/validation.d.ts +19 -13
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +144 -63
- package/dist/validation.js.map +1 -1
- package/dist/vehicle/vehicle-pricing/constants.js +36 -33
- package/dist/vehicle/vehicle-pricing/index.js +257 -99
- package/dist/vehicle/vehicle-pricing/types.js +1 -2
- package/package.json +9 -9
|
@@ -1,73 +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
|
-
import { prisma
|
|
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
|
|
6
|
-
export
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
})();
|
|
10
275
|
};
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
+
})();
|
|
45
334
|
};
|
|
46
|
-
export
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
+
})();
|
|
69
377
|
};
|
|
70
|
-
export
|
|
378
|
+
export var transformBasicVehicleData = function(dv) {
|
|
71
379
|
return {
|
|
72
380
|
registrationNumber: null,
|
|
73
381
|
featured: false,
|
|
@@ -83,19 +391,20 @@ export const transformBasicVehicleData = (dv) => {
|
|
|
83
391
|
variant: dv.variant,
|
|
84
392
|
year: dv.year,
|
|
85
393
|
type: dv.type,
|
|
86
|
-
niceName:
|
|
87
|
-
niceNameShort:
|
|
88
|
-
appliedCoupon: dv.appliedCoupon
|
|
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
|
|
89
397
|
};
|
|
90
398
|
};
|
|
91
|
-
export
|
|
399
|
+
export var transformImages = function(images) {
|
|
92
400
|
return [
|
|
93
401
|
transfromSingleImage(images.exterior[0].url, 'exterior'),
|
|
94
|
-
transfromSingleImage(images.interior[0].url, 'interior')
|
|
95
|
-
|
|
96
|
-
|
|
402
|
+
transfromSingleImage(images.interior[0].url, 'interior')
|
|
403
|
+
].concat(_to_consumable_array(images.gallery.map(function(i) {
|
|
404
|
+
return transfromSingleImage(i.url);
|
|
405
|
+
})));
|
|
97
406
|
};
|
|
98
|
-
|
|
407
|
+
var transfromSingleImage = function(imageUrl, inspectionType) {
|
|
99
408
|
return {
|
|
100
409
|
default: imageUrl,
|
|
101
410
|
blurBase64: null,
|
|
@@ -106,53 +415,51 @@ const transfromSingleImage = (imageUrl, inspectionType) => {
|
|
|
106
415
|
description: null,
|
|
107
416
|
inspection: !!inspectionType,
|
|
108
417
|
inspectionType: inspectionType || null,
|
|
109
|
-
notActualPhoto: true
|
|
418
|
+
notActualPhoto: true
|
|
110
419
|
};
|
|
111
420
|
};
|
|
112
|
-
|
|
421
|
+
var transformBasePrices = function(pricing) {
|
|
113
422
|
return {
|
|
114
423
|
basePrice: pricing.matrix.plan36.lite,
|
|
115
424
|
basePricePlan1: pricing.matrix.plan1.lite,
|
|
116
425
|
basePricePlan12: pricing.matrix.plan12.lite,
|
|
117
426
|
basePricePlan24: pricing.matrix.plan24.lite,
|
|
118
427
|
basePricePlan36: pricing.matrix.plan36.lite,
|
|
119
|
-
basePricePlan60: pricing.matrix.plan60.lite
|
|
428
|
+
basePricePlan60: pricing.matrix.plan60.lite
|
|
120
429
|
};
|
|
121
430
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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({
|
|
134
443
|
coefficient: fluxPriceCoefficient,
|
|
135
|
-
vehicleType
|
|
444
|
+
vehicleType: vehicleType
|
|
136
445
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
? getRecommendedMotorcycleDeposit(baseline)
|
|
144
|
-
: 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,
|
|
@@ -160,85 +467,150 @@ const transformPriceMatrix = (vehicleType, pricing) => {
|
|
|
160
467
|
excessMileage: fluxExcessMileage,
|
|
161
468
|
originalExcessMileage: fluxExcessMileage,
|
|
162
469
|
matrixComments: null,
|
|
163
|
-
add: null
|
|
470
|
+
add: null
|
|
164
471
|
},
|
|
165
472
|
hostTake: {
|
|
166
473
|
matrix: hostMatrix,
|
|
167
474
|
originalMatrix: hostMatrix,
|
|
168
475
|
excessMileage: hostExcessMileage,
|
|
169
476
|
originalExcessMileage: hostExcessMileage,
|
|
170
|
-
matrixComments: null
|
|
477
|
+
matrixComments: null
|
|
171
478
|
},
|
|
172
479
|
startFee: {
|
|
173
480
|
matrix: startFeeMatrix,
|
|
174
481
|
originalMatrix: startFeeMatrix,
|
|
175
|
-
matrixComments: null
|
|
176
|
-
}
|
|
482
|
+
matrixComments: null
|
|
483
|
+
}
|
|
177
484
|
};
|
|
178
485
|
};
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
availableMileagePackages: Array.from(mileageKeys)
|
|
540
|
+
availableMileagePackages: Array.from(mileageKeys)
|
|
197
541
|
};
|
|
198
542
|
};
|
|
199
|
-
|
|
543
|
+
var _getInspection = function() {
|
|
200
544
|
return {
|
|
201
545
|
exterior: 5,
|
|
202
546
|
interior: 5,
|
|
203
547
|
engine: 5,
|
|
204
548
|
frame: 5,
|
|
205
549
|
total: 5,
|
|
206
|
-
comment: 'COMMENT HERE'
|
|
550
|
+
comment: 'COMMENT HERE'
|
|
207
551
|
};
|
|
208
552
|
};
|
|
209
|
-
|
|
210
|
-
|
|
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,
|
|
214
558
|
bodyType: details.bodyType,
|
|
215
559
|
transmission: details.transmission,
|
|
216
560
|
engineType: details.fuelType,
|
|
217
|
-
engineCapacity: details.fuelType === 'electric'
|
|
218
|
-
? details.batteryCapacity
|
|
219
|
-
: details.engineCapacity,
|
|
561
|
+
engineCapacity: details.fuelType === 'electric' ? details.batteryCapacity : details.engineCapacity,
|
|
220
562
|
drivetrain: details.drivetrain,
|
|
221
563
|
accelerationTo100km: details.accelerationTo100km,
|
|
222
564
|
fuelConsumptionLitersPer100Km: details.fuelConsumptionLitersPer100Km,
|
|
223
|
-
color,
|
|
565
|
+
color: color,
|
|
224
566
|
features: details.features,
|
|
225
|
-
condition: 'new'
|
|
567
|
+
condition: 'new'
|
|
226
568
|
};
|
|
227
569
|
};
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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;
|
|
239
612
|
}
|
|
240
613
|
}
|
|
241
614
|
}
|
|
242
615
|
return matrix;
|
|
243
616
|
};
|
|
244
|
-
//# sourceMappingURL=display-vehicle.js.map
|