@driveflux/api-functions 0.0.7-next.2 → 0.0.7-next.21
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 +73 -327
- package/dist/auth/emails.js +43 -210
- package/dist/auth/formatter.js +11 -11
- package/dist/auth/otp.js +122 -392
- package/dist/auth/register.d.ts +1 -1
- package/dist/auth/register.js +102 -398
- package/dist/auth/register.js.map +1 -1
- package/dist/auth/tokens.js +115 -430
- package/dist/auth/verifications.js +177 -583
- package/dist/constants.js +5 -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 +24 -168
- 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 +14 -154
- package/dist/mailjet/calls/manage-subscription-status.js.map +1 -1
- package/dist/mailjet/calls/request-service.d.ts +1 -1
- package/dist/mailjet/calls/request-service.d.ts.map +1 -1
- package/dist/mailjet/calls/request-service.js +18 -183
- package/dist/mailjet/refresh-email-preferences.js +26 -225
- 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 +26 -217
- 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/types.js +2 -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 -58
- 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 +41 -217
- package/dist/mailjet/utils/lists.js +30 -249
- 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 -208
- package/dist/mailjet/utils/update-email-references.js.map +1 -1
- package/dist/notion/client.js +48 -197
- package/dist/notion/helpful.js +29 -170
- package/dist/notion/schemas/block.js +49 -43
- package/dist/notion/schemas/common.js +17 -14
- package/dist/notion/schemas/database.js +125 -159
- package/dist/notion/schemas/emoji.js +3 -2
- package/dist/notion/schemas/file.js +10 -10
- package/dist/notion/schemas/kb.js +9 -8
- package/dist/notion/schemas/page.js +126 -171
- package/dist/notion/schemas/parent.js +9 -8
- package/dist/notion/schemas/user.js +21 -20
- package/dist/reservation/agree.d.ts +1 -1
- package/dist/reservation/agree.d.ts.map +1 -1
- package/dist/reservation/agree.js +19 -158
- package/dist/reservation/checks.d.ts +1 -1
- package/dist/reservation/checks.d.ts.map +1 -1
- package/dist/reservation/checks.js +23 -178
- package/dist/reservation/display-vehicle.d.ts +17 -17
- package/dist/reservation/display-vehicle.js +142 -514
- 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 +199 -482
- 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 +198 -496
- 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 +28 -177
- package/dist/reservation/reserve.d.ts +1 -1
- package/dist/reservation/reserve.d.ts.map +1 -1
- package/dist/reservation/reserve.js +36 -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/types.js +2 -1
- package/dist/reservation/vehicle.d.ts +1 -1
- package/dist/reservation/vehicle.d.ts.map +1 -1
- package/dist/reservation/vehicle.js +26 -188
- package/dist/reservation/vehicle.js.map +1 -1
- package/dist/slack.d.ts +2 -2
- package/dist/slack.d.ts.map +1 -1
- package/dist/slack.js +67 -273
- package/dist/validation.d.ts +4 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +89 -139
- package/dist/validation.js.map +1 -1
- 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 +33 -36
- 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 +101 -259
- package/dist/vehicle/vehicle-pricing/index.js.map +1 -1
- package/dist/vehicle/vehicle-pricing/types.js +2 -1
- package/package.json +21 -21
|
@@ -1,183 +1,28 @@
|
|
|
1
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
-
try {
|
|
3
|
-
var info = gen[key](arg);
|
|
4
|
-
var value = info.value;
|
|
5
|
-
} catch (error) {
|
|
6
|
-
reject(error);
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
if (info.done) {
|
|
10
|
-
resolve(value);
|
|
11
|
-
} else {
|
|
12
|
-
Promise.resolve(value).then(_next, _throw);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function _async_to_generator(fn) {
|
|
16
|
-
return function() {
|
|
17
|
-
var self = this, args = arguments;
|
|
18
|
-
return new Promise(function(resolve, reject) {
|
|
19
|
-
var gen = fn.apply(self, args);
|
|
20
|
-
function _next(value) {
|
|
21
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
-
}
|
|
23
|
-
function _throw(err) {
|
|
24
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
-
}
|
|
26
|
-
_next(undefined);
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function _ts_generator(thisArg, body) {
|
|
31
|
-
var f, y, t, _ = {
|
|
32
|
-
label: 0,
|
|
33
|
-
sent: function() {
|
|
34
|
-
if (t[0] & 1) throw t[1];
|
|
35
|
-
return t[1];
|
|
36
|
-
},
|
|
37
|
-
trys: [],
|
|
38
|
-
ops: []
|
|
39
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
40
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
41
|
-
return this;
|
|
42
|
-
}), g;
|
|
43
|
-
function verb(n) {
|
|
44
|
-
return function(v) {
|
|
45
|
-
return step([
|
|
46
|
-
n,
|
|
47
|
-
v
|
|
48
|
-
]);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function step(op) {
|
|
52
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
53
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
54
|
-
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;
|
|
55
|
-
if (y = 0, t) op = [
|
|
56
|
-
op[0] & 2,
|
|
57
|
-
t.value
|
|
58
|
-
];
|
|
59
|
-
switch(op[0]){
|
|
60
|
-
case 0:
|
|
61
|
-
case 1:
|
|
62
|
-
t = op;
|
|
63
|
-
break;
|
|
64
|
-
case 4:
|
|
65
|
-
_.label++;
|
|
66
|
-
return {
|
|
67
|
-
value: op[1],
|
|
68
|
-
done: false
|
|
69
|
-
};
|
|
70
|
-
case 5:
|
|
71
|
-
_.label++;
|
|
72
|
-
y = op[1];
|
|
73
|
-
op = [
|
|
74
|
-
0
|
|
75
|
-
];
|
|
76
|
-
continue;
|
|
77
|
-
case 7:
|
|
78
|
-
op = _.ops.pop();
|
|
79
|
-
_.trys.pop();
|
|
80
|
-
continue;
|
|
81
|
-
default:
|
|
82
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
-
_ = 0;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
-
_.label = op[1];
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
-
_.label = t[1];
|
|
92
|
-
t = op;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
if (t && _.label < t[2]) {
|
|
96
|
-
_.label = t[2];
|
|
97
|
-
_.ops.push(op);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
if (t[2]) _.ops.pop();
|
|
101
|
-
_.trys.pop();
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
op = body.call(thisArg, _);
|
|
105
|
-
} catch (e) {
|
|
106
|
-
op = [
|
|
107
|
-
6,
|
|
108
|
-
e
|
|
109
|
-
];
|
|
110
|
-
y = 0;
|
|
111
|
-
} finally{
|
|
112
|
-
f = t = 0;
|
|
113
|
-
}
|
|
114
|
-
if (op[0] & 5) throw op[1];
|
|
115
|
-
return {
|
|
116
|
-
value: op[0] ? op[1] : void 0,
|
|
117
|
-
done: true
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
1
|
import { ForbiddenError, subject } from '@casl/ability';
|
|
122
2
|
import { buildOrDefineAbility } from '@driveflux/auth/authorization';
|
|
123
|
-
import { makeProblem, PROBLEM_CONDITION_FAILED, PROBLEM_RESOURCE_BUSY } from '@driveflux/problem';
|
|
3
|
+
import { makeProblem, PROBLEM_CONDITION_FAILED, PROBLEM_RESOURCE_BUSY, } from '@driveflux/problem';
|
|
124
4
|
import { Err, Ok } from '@driveflux/result';
|
|
125
|
-
export
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
case 0:
|
|
132
|
-
return [
|
|
133
|
-
4,
|
|
134
|
-
buildOrDefineAbility(requestUser)
|
|
135
|
-
];
|
|
136
|
-
case 1:
|
|
137
|
-
requestUserAbility = _state.sent();
|
|
138
|
-
// Check if user can reserve
|
|
139
|
-
ForbiddenError.from(requestUserAbility).throwUnlessCan('reserveVehicle', subject('User', subscribingUser));
|
|
140
|
-
return [
|
|
141
|
-
2,
|
|
142
|
-
requestUserAbility
|
|
143
|
-
];
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
})();
|
|
5
|
+
export const checkIfUserCanReserve = async ({ requestUser, subscribingUser, }) => {
|
|
6
|
+
// Check if the user can reserve
|
|
7
|
+
const requestUserAbility = await buildOrDefineAbility(requestUser);
|
|
8
|
+
// Check if user can reserve
|
|
9
|
+
ForbiddenError.from(requestUserAbility).throwUnlessCan('reserveVehicle', subject('User', subscribingUser));
|
|
10
|
+
return requestUserAbility;
|
|
147
11
|
};
|
|
148
|
-
export
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
];
|
|
164
|
-
}
|
|
165
|
-
if (((_vehicle_details = vehicle.details) === null || _vehicle_details === void 0 ? void 0 : _vehicle_details.condition) === 'new' && plan === 'plan1') {
|
|
166
|
-
return [
|
|
167
|
-
2,
|
|
168
|
-
new Err(makeProblem(PROBLEM_CONDITION_FAILED, 'This vehicle is not available for monthl-to-month subscription'))
|
|
169
|
-
];
|
|
170
|
-
}
|
|
171
|
-
if (!vehicle.host) {
|
|
172
|
-
return [
|
|
173
|
-
2,
|
|
174
|
-
new Err(makeProblem(PROBLEM_CONDITION_FAILED, 'This vehicle is not associated to a host'))
|
|
175
|
-
];
|
|
176
|
-
}
|
|
177
|
-
return [
|
|
178
|
-
2,
|
|
179
|
-
new Ok(vehicle)
|
|
180
|
-
];
|
|
181
|
-
});
|
|
182
|
-
})();
|
|
12
|
+
export const checkIfVehicleIsAvailableForReservation = async (vehicle, plan, allowDelisted) => {
|
|
13
|
+
if (!vehicle.pricing) {
|
|
14
|
+
return new Err(makeProblem(PROBLEM_RESOURCE_BUSY, 'This vehicle is not available for reservation'));
|
|
15
|
+
}
|
|
16
|
+
// Check if the vehicle has no previous reservations
|
|
17
|
+
if (vehicle.status !== 'listed' && !allowDelisted) {
|
|
18
|
+
return new Err(makeProblem(PROBLEM_RESOURCE_BUSY, 'This vehicle is not available for reservation'));
|
|
19
|
+
}
|
|
20
|
+
if (vehicle.details?.condition === 'new' && plan === 'plan1') {
|
|
21
|
+
return new Err(makeProblem(PROBLEM_CONDITION_FAILED, 'This vehicle is not available for monthl-to-month subscription'));
|
|
22
|
+
}
|
|
23
|
+
if (!vehicle.host) {
|
|
24
|
+
return new Err(makeProblem(PROBLEM_CONDITION_FAILED, 'This vehicle is not associated to a host'));
|
|
25
|
+
}
|
|
26
|
+
return new Ok(vehicle);
|
|
183
27
|
};
|
|
28
|
+
//# sourceMappingURL=checks.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type DisplayVehicle, type MileagePackage, type PlanType, type UltraTier, type Vehicle, type VehicleType } from '@driveflux/db';
|
|
2
2
|
export declare const fetchDisplayVehicle: (displayVehicle: DisplayVehicle | string) => Promise<{
|
|
3
3
|
object: import("@driveflux/db").DisplayVehicleObject;
|
|
4
|
+
type: VehicleType;
|
|
4
5
|
id: string;
|
|
5
6
|
createdAt: Date;
|
|
6
7
|
updatedAt: Date;
|
|
@@ -8,11 +9,10 @@ export declare const fetchDisplayVehicle: (displayVehicle: DisplayVehicle | stri
|
|
|
8
9
|
vehicleModel: string;
|
|
9
10
|
variant: string;
|
|
10
11
|
year: number;
|
|
11
|
-
|
|
12
|
+
brandSlug: string;
|
|
12
13
|
brandId: string;
|
|
13
14
|
defaultHostId: string;
|
|
14
15
|
vehicleSlug: string;
|
|
15
|
-
brandSlug: string;
|
|
16
16
|
saveValue: number | null;
|
|
17
17
|
details: ({
|
|
18
18
|
features: string[];
|
|
@@ -191,20 +191,20 @@ export declare const fetchDisplayVehicle: (displayVehicle: DisplayVehicle | stri
|
|
|
191
191
|
export declare const createVehicleFromDisplayVehicle: (displayVehicle: DisplayVehicle | string, selectedColor?: string) => Promise<({
|
|
192
192
|
host: {
|
|
193
193
|
object: import("@driveflux/db").HostObject;
|
|
194
|
-
|
|
194
|
+
phoneNumber: string | null;
|
|
195
|
+
type: import("@driveflux/db").HostType | null;
|
|
195
196
|
id: string;
|
|
196
197
|
metadata: PrismaJson.AnyMetadata | null;
|
|
198
|
+
name: string;
|
|
197
199
|
createdAt: Date;
|
|
198
200
|
updatedAt: Date;
|
|
199
|
-
registrationNumber: string | null;
|
|
200
|
-
type: import("@driveflux/db").HostType | null;
|
|
201
|
-
active: boolean;
|
|
202
201
|
email: string | null;
|
|
203
|
-
phoneNumber: string | null;
|
|
204
202
|
race: import("@driveflux/db").Race | null;
|
|
205
203
|
emergencyContactName: string | null;
|
|
206
204
|
emergencyPhoneNumber: string | null;
|
|
205
|
+
active: boolean;
|
|
207
206
|
commencementDate: Date | null;
|
|
207
|
+
registrationNumber: string | null;
|
|
208
208
|
stripeAccountId: string | null;
|
|
209
209
|
isStripeConnected: boolean;
|
|
210
210
|
serviceCenterIds: string[];
|
|
@@ -262,11 +262,15 @@ export declare const createVehicleFromDisplayVehicle: (displayVehicle: DisplayVe
|
|
|
262
262
|
};
|
|
263
263
|
} & {
|
|
264
264
|
object: import("@driveflux/db").VehicleObject;
|
|
265
|
+
type: VehicleType;
|
|
265
266
|
id: string;
|
|
266
|
-
status: import("@driveflux/db").VehicleStatus;
|
|
267
267
|
metadata: PrismaJson.AnyMetadata | null;
|
|
268
268
|
createdAt: Date;
|
|
269
269
|
updatedAt: Date;
|
|
270
|
+
status: import("@driveflux/db").VehicleStatus;
|
|
271
|
+
temporary: boolean;
|
|
272
|
+
registrationNumber: string | null;
|
|
273
|
+
hostId: string;
|
|
270
274
|
make: string;
|
|
271
275
|
vehicleModel: string;
|
|
272
276
|
variant: string;
|
|
@@ -276,7 +280,6 @@ export declare const createVehicleFromDisplayVehicle: (displayVehicle: DisplayVe
|
|
|
276
280
|
compositeSearchScore: number;
|
|
277
281
|
registrationDate: Date | null;
|
|
278
282
|
mileage: number | null;
|
|
279
|
-
registrationNumber: string | null;
|
|
280
283
|
vin: string | null;
|
|
281
284
|
engineNumber: string | null;
|
|
282
285
|
availability: import("@driveflux/db").VehicleAvailablity | null;
|
|
@@ -291,8 +294,6 @@ export declare const createVehicleFromDisplayVehicle: (displayVehicle: DisplayVe
|
|
|
291
294
|
delistedAt: Date | null;
|
|
292
295
|
imagesNotActual: boolean;
|
|
293
296
|
imagesNotActualMessage: string | null;
|
|
294
|
-
hostId: string;
|
|
295
|
-
type: VehicleType;
|
|
296
297
|
allowedServiceCenterIds: string[];
|
|
297
298
|
displayVehicleId: string | null;
|
|
298
299
|
isHostConfirmed: boolean | null;
|
|
@@ -305,7 +306,6 @@ export declare const createVehicleFromDisplayVehicle: (displayVehicle: DisplayVe
|
|
|
305
306
|
featureOnLandingPage: boolean;
|
|
306
307
|
lastMileageRecordedAt: Date | null;
|
|
307
308
|
locationAvailability: string[];
|
|
308
|
-
temporary: boolean;
|
|
309
309
|
hotDeal: boolean | null;
|
|
310
310
|
activeSubscriptionId: string | null;
|
|
311
311
|
addresses: {
|
|
@@ -689,11 +689,15 @@ export declare const createVehicleFromDisplayVehicle: (displayVehicle: DisplayVe
|
|
|
689
689
|
}) | undefined>;
|
|
690
690
|
export declare const transfromVehicleDisplayToVehicle: (displayVehicle: DisplayVehicle | string, selectedColor: string) => Promise<({
|
|
691
691
|
object: import("@driveflux/db").VehicleObject;
|
|
692
|
+
type: VehicleType;
|
|
692
693
|
id: string;
|
|
693
|
-
status: import("@driveflux/db").VehicleStatus;
|
|
694
694
|
metadata: PrismaJson.AnyMetadata | null;
|
|
695
695
|
createdAt: Date;
|
|
696
696
|
updatedAt: Date;
|
|
697
|
+
status: import("@driveflux/db").VehicleStatus;
|
|
698
|
+
temporary: boolean;
|
|
699
|
+
registrationNumber: string | null;
|
|
700
|
+
hostId: string;
|
|
697
701
|
make: string;
|
|
698
702
|
vehicleModel: string;
|
|
699
703
|
variant: string;
|
|
@@ -703,7 +707,6 @@ export declare const transfromVehicleDisplayToVehicle: (displayVehicle: DisplayV
|
|
|
703
707
|
compositeSearchScore: number;
|
|
704
708
|
registrationDate: Date | null;
|
|
705
709
|
mileage: number | null;
|
|
706
|
-
registrationNumber: string | null;
|
|
707
710
|
vin: string | null;
|
|
708
711
|
engineNumber: string | null;
|
|
709
712
|
availability: import("@driveflux/db").VehicleAvailablity | null;
|
|
@@ -718,8 +721,6 @@ export declare const transfromVehicleDisplayToVehicle: (displayVehicle: DisplayV
|
|
|
718
721
|
delistedAt: Date | null;
|
|
719
722
|
imagesNotActual: boolean;
|
|
720
723
|
imagesNotActualMessage: string | null;
|
|
721
|
-
hostId: string;
|
|
722
|
-
type: VehicleType;
|
|
723
724
|
allowedServiceCenterIds: string[];
|
|
724
725
|
displayVehicleId: string | null;
|
|
725
726
|
isHostConfirmed: boolean | null;
|
|
@@ -732,7 +733,6 @@ export declare const transfromVehicleDisplayToVehicle: (displayVehicle: DisplayV
|
|
|
732
733
|
featureOnLandingPage: boolean;
|
|
733
734
|
lastMileageRecordedAt: Date | null;
|
|
734
735
|
locationAvailability: string[];
|
|
735
|
-
temporary: boolean;
|
|
736
736
|
hotDeal: boolean | null;
|
|
737
737
|
activeSubscriptionId: string | null;
|
|
738
738
|
addresses: {
|