@driveflux/api-functions 0.0.7-next.0 → 0.0.7-next.10
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.d.ts +3 -17
- package/dist/auth/confirm.js +66 -325
- package/dist/auth/emails.js +42 -210
- package/dist/auth/formatter.js +9 -9
- package/dist/auth/otp.js +120 -374
- package/dist/auth/register.js +95 -383
- package/dist/auth/register.js.map +1 -1
- package/dist/auth/tokens.js +114 -426
- package/dist/auth/verifications.d.ts +2 -8
- package/dist/auth/verifications.js +176 -581
- package/dist/constants.js +4 -4
- package/dist/mailjet/calls/manage-contacts-in-list.d.ts +2 -2
- package/dist/mailjet/calls/manage-contacts-in-list.d.ts.map +1 -1
- package/dist/mailjet/calls/manage-contacts-in-list.js +22 -167
- package/dist/mailjet/calls/manage-contacts-in-list.js.map +1 -1
- package/dist/mailjet/calls/manage-subscription-status.d.ts +2 -2
- package/dist/mailjet/calls/manage-subscription-status.d.ts.map +1 -1
- package/dist/mailjet/calls/manage-subscription-status.js +13 -154
- package/dist/mailjet/calls/manage-subscription-status.js.map +1 -1
- package/dist/mailjet/calls/request-service.js +18 -182
- package/dist/mailjet/refresh-email-preferences.js +21 -221
- package/dist/mailjet/set-contact.d.ts +2 -2
- package/dist/mailjet/set-contact.d.ts.map +1 -1
- package/dist/mailjet/set-contact.js +21 -213
- package/dist/mailjet/set-contact.js.map +1 -1
- package/dist/mailjet/types.d.ts +2 -2
- package/dist/mailjet/types.d.ts.map +1 -1
- package/dist/mailjet/utils/convert-to-array.d.ts +1 -1
- package/dist/mailjet/utils/convert-to-array.d.ts.map +1 -1
- package/dist/mailjet/utils/convert-to-array.js +9 -56
- package/dist/mailjet/utils/extract-email-preferences.d.ts +1 -1
- package/dist/mailjet/utils/extract-email-preferences.d.ts.map +1 -1
- package/dist/mailjet/utils/extract-email-preferences.js +37 -214
- package/dist/mailjet/utils/lists.js +28 -248
- package/dist/mailjet/utils/update-email-references.d.ts +2 -2
- package/dist/mailjet/utils/update-email-references.d.ts.map +1 -1
- package/dist/mailjet/utils/update-email-references.js +27 -207
- package/dist/mailjet/utils/update-email-references.js.map +1 -1
- package/dist/notion/client.js +50 -196
- package/dist/notion/helpful.js +25 -169
- package/dist/notion/schemas/block.js +1 -1
- package/dist/notion/schemas/common.d.ts +13 -10
- package/dist/notion/schemas/common.js +7 -9
- package/dist/notion/schemas/database.js +68 -100
- package/dist/notion/schemas/emoji.d.ts +1 -7
- package/dist/notion/schemas/emoji.js +1 -1
- package/dist/notion/schemas/file.d.ts +7 -34
- package/dist/notion/schemas/file.js +1 -1
- package/dist/notion/schemas/kb.js +3 -3
- package/dist/notion/schemas/page.js +69 -103
- package/dist/notion/schemas/parent.d.ts +4 -28
- package/dist/notion/schemas/parent.js +4 -4
- package/dist/notion/schemas/user.d.ts +13 -67
- package/dist/notion/schemas/user.js +2 -2
- package/dist/reservation/agree.d.ts +1 -1
- package/dist/reservation/agree.d.ts.map +1 -1
- package/dist/reservation/agree.js +17 -157
- package/dist/reservation/checks.d.ts +1 -1
- package/dist/reservation/checks.d.ts.map +1 -1
- package/dist/reservation/checks.js +21 -177
- package/dist/reservation/display-vehicle.js +122 -500
- package/dist/reservation/display-vehicle.js.map +1 -1
- package/dist/reservation/fetch-or-create.d.ts +2 -2
- package/dist/reservation/fetch-or-create.d.ts.map +1 -1
- package/dist/reservation/fetch-or-create.js +193 -478
- package/dist/reservation/fetch-or-create.js.map +1 -1
- package/dist/reservation/invoice.d.ts +3 -3
- package/dist/reservation/invoice.d.ts.map +1 -1
- package/dist/reservation/invoice.js +182 -492
- package/dist/reservation/invoice.js.map +1 -1
- package/dist/reservation/payer.d.ts +1 -1
- package/dist/reservation/payer.d.ts.map +1 -1
- package/dist/reservation/payer.js +25 -175
- package/dist/reservation/reserve.d.ts +1 -1
- package/dist/reservation/reserve.d.ts.map +1 -1
- package/dist/reservation/reserve.js +35 -196
- package/dist/reservation/reserve.js.map +1 -1
- package/dist/reservation/types.d.ts +1 -0
- package/dist/reservation/types.d.ts.map +1 -1
- package/dist/reservation/vehicle.d.ts +1 -1
- package/dist/reservation/vehicle.d.ts.map +1 -1
- package/dist/reservation/vehicle.js +23 -188
- package/dist/reservation/vehicle.js.map +1 -1
- package/dist/slack.js +57 -268
- package/dist/validation.js +38 -98
- package/dist/vehicle/vehicle-pricing/constants.d.ts +1 -1
- package/dist/vehicle/vehicle-pricing/constants.d.ts.map +1 -1
- package/dist/vehicle/vehicle-pricing/constants.js +16 -16
- package/dist/vehicle/vehicle-pricing/index.d.ts +1 -1
- package/dist/vehicle/vehicle-pricing/index.d.ts.map +1 -1
- package/dist/vehicle/vehicle-pricing/index.js +87 -259
- package/dist/vehicle/vehicle-pricing/index.js.map +1 -1
- package/package.json +12 -12
|
@@ -1,381 +1,75 @@
|
|
|
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
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
|
|
241
|
-
return
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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/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;
|
|
275
12
|
};
|
|
276
|
-
export
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
-
];
|
|
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
|
|
331
33
|
}
|
|
332
|
-
}
|
|
333
|
-
|
|
34
|
+
},
|
|
35
|
+
displayVehicle: {
|
|
36
|
+
connect: {
|
|
37
|
+
id: dv.id
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return await prisma.vehicle.create({
|
|
42
|
+
data: vehicleData,
|
|
43
|
+
include: {
|
|
44
|
+
host: true
|
|
45
|
+
}
|
|
46
|
+
});
|
|
334
47
|
};
|
|
335
|
-
export
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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
|
-
];
|
|
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'
|
|
374
68
|
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
377
71
|
};
|
|
378
|
-
export
|
|
72
|
+
export const transformBasicVehicleData = (dv)=>{
|
|
379
73
|
return {
|
|
380
74
|
registrationNumber: null,
|
|
381
75
|
featured: false,
|
|
@@ -391,20 +85,19 @@ export var transformBasicVehicleData = function(dv) {
|
|
|
391
85
|
variant: dv.variant,
|
|
392
86
|
year: dv.year,
|
|
393
87
|
type: dv.type,
|
|
394
|
-
niceName:
|
|
395
|
-
niceNameShort:
|
|
88
|
+
niceName: `${dv.make} ${dv.vehicleModel} ${dv.variant} ${dv.year}`,
|
|
89
|
+
niceNameShort: `${dv.make} ${dv.vehicleModel}`,
|
|
396
90
|
appliedCoupon: dv.appliedCoupon
|
|
397
91
|
};
|
|
398
92
|
};
|
|
399
|
-
export
|
|
93
|
+
export const transformImages = (images)=>{
|
|
400
94
|
return [
|
|
401
95
|
transfromSingleImage(images.exterior[0].url, 'exterior'),
|
|
402
|
-
transfromSingleImage(images.interior[0].url, 'interior')
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
})));
|
|
96
|
+
transfromSingleImage(images.interior[0].url, 'interior'),
|
|
97
|
+
...images.gallery.map((i)=>transfromSingleImage(i.url))
|
|
98
|
+
];
|
|
406
99
|
};
|
|
407
|
-
|
|
100
|
+
const transfromSingleImage = (imageUrl, inspectionType)=>{
|
|
408
101
|
return {
|
|
409
102
|
default: imageUrl,
|
|
410
103
|
blurBase64: null,
|
|
@@ -418,7 +111,7 @@ var transfromSingleImage = function(imageUrl, inspectionType) {
|
|
|
418
111
|
notActualPhoto: true
|
|
419
112
|
};
|
|
420
113
|
};
|
|
421
|
-
|
|
114
|
+
const transformBasePrices = (pricing)=>{
|
|
422
115
|
return {
|
|
423
116
|
basePrice: pricing.matrix.plan36.lite,
|
|
424
117
|
basePricePlan1: pricing.matrix.plan1.lite,
|
|
@@ -428,38 +121,38 @@ var transformBasePrices = function(pricing) {
|
|
|
428
121
|
basePricePlan60: pricing.matrix.plan60.lite
|
|
429
122
|
};
|
|
430
123
|
};
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
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({
|
|
443
136
|
coefficient: fluxPriceCoefficient,
|
|
444
|
-
vehicleType
|
|
137
|
+
vehicleType
|
|
445
138
|
});
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
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;
|
|
452
145
|
return {
|
|
453
|
-
tmv
|
|
454
|
-
gfv
|
|
455
|
-
gfvNotApplicable
|
|
456
|
-
ultraTier
|
|
146
|
+
tmv,
|
|
147
|
+
gfv,
|
|
148
|
+
gfvNotApplicable,
|
|
149
|
+
ultraTier,
|
|
457
150
|
baseline: baseline,
|
|
458
|
-
recommendedDeposit
|
|
459
|
-
availableMileagePackages
|
|
460
|
-
availablePlans
|
|
461
|
-
bought
|
|
462
|
-
flatPricing
|
|
151
|
+
recommendedDeposit,
|
|
152
|
+
availableMileagePackages,
|
|
153
|
+
availablePlans,
|
|
154
|
+
bought,
|
|
155
|
+
flatPricing,
|
|
463
156
|
fluxPrice: {
|
|
464
157
|
coefficient: fluxPriceCoefficient,
|
|
465
158
|
matrix: fluxPriceMatrix,
|
|
@@ -483,64 +176,27 @@ var transformPriceMatrix = function(vehicleType, pricing) {
|
|
|
483
176
|
}
|
|
484
177
|
};
|
|
485
178
|
};
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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
196
|
availableMileagePackages: Array.from(mileageKeys)
|
|
541
197
|
};
|
|
542
198
|
};
|
|
543
|
-
|
|
199
|
+
const _getInspection = ()=>{
|
|
544
200
|
return {
|
|
545
201
|
exterior: 5,
|
|
546
202
|
interior: 5,
|
|
@@ -550,8 +206,8 @@ var _getInspection = function() {
|
|
|
550
206
|
comment: 'COMMENT HERE'
|
|
551
207
|
};
|
|
552
208
|
};
|
|
553
|
-
|
|
554
|
-
|
|
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,
|
|
@@ -562,53 +218,19 @@ var transformDetails = function(details, selectColor) {
|
|
|
562
218
|
drivetrain: details.drivetrain,
|
|
563
219
|
accelerationTo100km: details.accelerationTo100km,
|
|
564
220
|
fuelConsumptionLitersPer100Km: details.fuelConsumptionLitersPer100Km,
|
|
565
|
-
color
|
|
221
|
+
color,
|
|
566
222
|
features: details.features,
|
|
567
223
|
condition: 'new'
|
|
568
224
|
};
|
|
569
225
|
};
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
if (
|
|
577
|
-
|
|
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;
|
|
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);
|
|
612
234
|
}
|
|
613
235
|
}
|
|
614
236
|
}
|