@driveflux/api-functions 0.0.7-next.7 → 0.0.7-next.9

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 (52) hide show
  1. package/dist/auth/confirm.js +29 -24
  2. package/dist/auth/emails.js +13 -12
  3. package/dist/auth/formatter.js +5 -5
  4. package/dist/auth/otp.js +50 -66
  5. package/dist/auth/register.js +34 -42
  6. package/dist/auth/tokens.js +55 -58
  7. package/dist/auth/verifications.js +52 -53
  8. package/dist/constants.js +1 -0
  9. package/dist/mailjet/calls/manage-contacts-in-list.js +6 -5
  10. package/dist/mailjet/calls/manage-subscription-status.js +5 -4
  11. package/dist/mailjet/calls/request-service.js +6 -7
  12. package/dist/mailjet/refresh-email-preferences.js +12 -11
  13. package/dist/mailjet/set-contact.js +12 -11
  14. package/dist/mailjet/types.js +2 -1
  15. package/dist/mailjet/utils/convert-to-array.js +6 -8
  16. package/dist/mailjet/utils/extract-email-preferences.js +15 -14
  17. package/dist/mailjet/utils/lists.js +8 -7
  18. package/dist/mailjet/utils/update-email-references.js +15 -16
  19. package/dist/notion/client.js +19 -22
  20. package/dist/notion/helpful.js +9 -6
  21. package/dist/notion/schemas/block.js +48 -42
  22. package/dist/notion/schemas/common.js +14 -9
  23. package/dist/notion/schemas/database.js +60 -62
  24. package/dist/notion/schemas/emoji.js +2 -1
  25. package/dist/notion/schemas/file.js +9 -9
  26. package/dist/notion/schemas/kb.js +6 -5
  27. package/dist/notion/schemas/page.js +61 -72
  28. package/dist/notion/schemas/parent.js +5 -4
  29. package/dist/notion/schemas/user.js +19 -18
  30. package/dist/reservation/agree.js +7 -6
  31. package/dist/reservation/checks.js +4 -3
  32. package/dist/reservation/display-vehicle.d.ts +35 -35
  33. package/dist/reservation/fetch-or-create.d.ts +1 -1
  34. package/dist/reservation/fetch-or-create.d.ts.map +1 -1
  35. package/dist/reservation/fetch-or-create.js +62 -48
  36. package/dist/reservation/fetch-or-create.js.map +1 -1
  37. package/dist/reservation/invoice.d.ts +2 -2
  38. package/dist/reservation/invoice.d.ts.map +1 -1
  39. package/dist/reservation/invoice.js +76 -64
  40. package/dist/reservation/invoice.js.map +1 -1
  41. package/dist/reservation/payer.js +6 -5
  42. package/dist/reservation/reserve.js +4 -3
  43. package/dist/reservation/types.d.ts +1 -0
  44. package/dist/reservation/types.d.ts.map +1 -1
  45. package/dist/reservation/types.js +2 -1
  46. package/dist/reservation/vehicle.js +16 -13
  47. package/dist/slack.js +29 -24
  48. package/dist/validation.js +71 -69
  49. package/dist/vehicle/vehicle-pricing/constants.js +19 -22
  50. package/dist/vehicle/vehicle-pricing/index.js +42 -28
  51. package/dist/vehicle/vehicle-pricing/types.js +2 -1
  52. package/package.json +9 -9
@@ -5,17 +5,18 @@ import cloneDeep from 'lodash/cloneDeep.js';
5
5
  import { EMPTY_MATRIX } from './constants.js';
6
6
  /**
7
7
  * This is a last moment feature the CEO asked for and was not properly designed
8
- */ export const getRecommendedMotorcycleDeposit = (baseline)=>{
8
+ */
9
+ export const getRecommendedMotorcycleDeposit = (baseline) => {
9
10
  return Math.max(Math.min(baseline * 5, 1500), 1000);
10
11
  };
11
- export const getHostsMatrix = (pricingData, baseline, tier, flatPricing)=>{
12
+ export const getHostsMatrix = (pricingData, baseline, tier, flatPricing) => {
12
13
  // Let's not mutate percentages
13
14
  const newMatrix = cloneDeep(pricingData.hostEarnings.matrixCoefficients);
14
15
  const baseCoefficients = cloneDeep(newMatrix.plan36);
15
16
  const plans = Object.keys(newMatrix);
16
- for (const plan of plans){
17
+ for (const plan of plans) {
17
18
  const mileagePackages = Object.keys(newMatrix[plan]);
18
- for (const mileagePackage of mileagePackages){
19
+ for (const mileagePackage of mileagePackages) {
19
20
  if (plan === 'plan1') {
20
21
  if (tier === 'tierCustom') {
21
22
  newMatrix[plan][mileagePackage] = 0;
@@ -24,23 +25,26 @@ export const getHostsMatrix = (pricingData, baseline, tier, flatPricing)=>{
24
25
  newMatrix[plan][mileagePackage] = Number(pricingData.hostEarnings.ultraTiers[tier]);
25
26
  continue;
26
27
  }
27
- newMatrix[plan][mileagePackage] = round(baseline * (flatPricing ? baseCoefficients[mileagePackage] : newMatrix[plan][mileagePackage]));
28
+ newMatrix[plan][mileagePackage] = round(baseline *
29
+ (flatPricing
30
+ ? baseCoefficients[mileagePackage]
31
+ : newMatrix[plan][mileagePackage]));
28
32
  }
29
33
  }
30
34
  return sortMatrix(newMatrix);
31
35
  };
32
- export const getHostExcessMileage = (pricingData, baseline)=>{
36
+ export const getHostExcessMileage = (pricingData, baseline) => {
33
37
  return decimals(Math.max(Math.min(baseline * pricingData.hostEarnings.excessMileage.coefficient, pricingData.hostEarnings.excessMileage.upperBound), pricingData.hostEarnings.excessMileage.lowerBound));
34
38
  };
35
- export const getEmptyMatrix = ()=>{
39
+ export const getEmptyMatrix = () => {
36
40
  return cloneDeep(EMPTY_MATRIX);
37
41
  };
38
- export const sortMatrix = (unorderedMatrix)=>{
42
+ export const sortMatrix = (unorderedMatrix) => {
39
43
  const ordered = {};
40
44
  const plans = getVehicleDataVariant(PLANS, 'car');
41
45
  const mileagePackages = getVehicleDataVariant(MILEAGE_PACKAGES, 'car');
42
- for (const plan of plans){
43
- for (const mileagePackage of mileagePackages){
46
+ for (const plan of plans) {
47
+ for (const mileagePackage of mileagePackages) {
44
48
  if (!ordered[plan]) {
45
49
  ordered[plan] = {};
46
50
  }
@@ -49,7 +53,7 @@ export const sortMatrix = (unorderedMatrix)=>{
49
53
  }
50
54
  return ordered;
51
55
  };
52
- const round = (number)=>{
56
+ const round = (number) => {
53
57
  return Math.round(number * 100) / 100;
54
58
  };
55
59
  /**
@@ -62,7 +66,8 @@ const round = (number)=>{
62
66
  * @param customLitePicing
63
67
  *
64
68
  * @see https://docs.google.com/spreadsheets/d/1lYYMdQgnzG53lCGf_dKJY9pEue5suJuo3O3-zegIOT0/edit#gid=819271234
65
- */ export const getFluxPiceMatrix = (pricingData, vehicleType, baseline, dealershipPriceMatrix, tier, flatPricing, customMileagePackage, customLitePicing)=>{
69
+ */
70
+ export const getFluxPiceMatrix = (pricingData, vehicleType, baseline, dealershipPriceMatrix, tier, flatPricing, customMileagePackage, customLitePicing) => {
66
71
  // Let's not mutate percentages
67
72
  const newMatrix = cloneDeep(pricingData.hostEarnings.matrixCoefficients);
68
73
  const plans = Object.keys(newMatrix);
@@ -70,7 +75,7 @@ const round = (number)=>{
70
75
  // if flat pricing, we order the plans by 36 months first, then the rest,
71
76
  // that's because we perform the operations on the same matrix, so 36 is the base
72
77
  // and should influence th rest of the plans
73
- plans.sort((a, _b)=>{
78
+ plans.sort((a, _b) => {
74
79
  if (a === 'plan36') {
75
80
  return -1;
76
81
  }
@@ -80,16 +85,16 @@ const round = (number)=>{
80
85
  // This code is highly vulnerable to order. The order **MUST** be sorted,
81
86
  // this is because it edits "lite" plan, then the other plans depend on the outcome of this one.
82
87
  // TODO: Fix this code so that it sorts lite package first.
83
- for (const plan of plans){
88
+ for (const plan of plans) {
84
89
  const mileagePackages = Object.keys(newMatrix[plan]);
85
- mileagePackages.sort((a)=>{
90
+ mileagePackages.sort((a) => {
86
91
  if (a === 'lite') {
87
92
  return -1;
88
93
  }
89
94
  return 0;
90
95
  });
91
96
  const baseMileagePackage = vehicleType === 'motorcycle' ? 'standard' : 'lite';
92
- for (const mileagePackage of mileagePackages){
97
+ for (const mileagePackage of mileagePackages) {
93
98
  const targetPlan = flatPricing ? 'plan36' : plan;
94
99
  if (plan === 'plan1') {
95
100
  if (tier === 'tierCustom') {
@@ -100,38 +105,42 @@ const round = (number)=>{
100
105
  continue;
101
106
  }
102
107
  if (mileagePackage === baseMileagePackage) {
103
- const baseMileagePackagePrice = Math.max(baseline * pricingData.fluxPricing.matrixCoefficients[targetPlan], Number(dealershipPriceMatrix[targetPlan][baseMileagePackage]) + pricingData.fluxPricing.minFluxTake);
108
+ const baseMileagePackagePrice = Math.max(baseline * pricingData.fluxPricing.matrixCoefficients[targetPlan], Number(dealershipPriceMatrix[targetPlan][baseMileagePackage]) +
109
+ pricingData.fluxPricing.minFluxTake);
104
110
  const custom = customLitePicing?.[plan];
105
111
  newMatrix[plan][baseMileagePackage] = decimals(typeof custom === 'undefined' ? baseMileagePackagePrice : custom);
106
112
  continue;
107
113
  }
108
- const mileagePackageAdd = baseline * pricingData.fluxPricing.matrixCoefficients.add[mileagePackage];
114
+ const mileagePackageAdd = baseline *
115
+ pricingData.fluxPricing.matrixCoefficients.add[mileagePackage];
109
116
  const cutomMileagePackageAdd = customMileagePackage?.[mileagePackage];
110
117
  const basePlanMileagePackagePricing = newMatrix[targetPlan][baseMileagePackage];
111
- newMatrix[plan][mileagePackage] = decimals(round(basePlanMileagePackagePricing + (cutomMileagePackageAdd || mileagePackageAdd)));
118
+ newMatrix[plan][mileagePackage] = decimals(round(basePlanMileagePackagePricing +
119
+ (cutomMileagePackageAdd || mileagePackageAdd)));
112
120
  }
113
121
  }
114
122
  return sortMatrix(newMatrix);
115
123
  };
116
- export const updateMatrixWithCustomPackages = (matrix, add)=>{
124
+ export const updateMatrixWithCustomPackages = (matrix, add) => {
117
125
  const newMatrix = cloneDeep(matrix);
118
126
  const plans = getVehicleDataVariant(PLANS, 'car');
119
127
  const mileagePackages = getVehicleDataVariant(MILEAGE_PACKAGES, 'car');
120
128
  const baseMileagePackage = mileagePackages[0];
121
- for (const plan of plans){
122
- for (const mileagePackage of mileagePackages){
129
+ for (const plan of plans) {
130
+ for (const mileagePackage of mileagePackages) {
123
131
  if (mileagePackage === baseMileagePackage) {
124
132
  continue;
125
133
  }
126
134
  const toAdd = add[mileagePackage];
127
135
  if (toAdd) {
128
- newMatrix[plan][mileagePackage] = (newMatrix[plan]?.[baseMileagePackage] || 0) + toAdd;
136
+ newMatrix[plan][mileagePackage] =
137
+ (newMatrix[plan]?.[baseMileagePackage] || 0) + toAdd;
129
138
  }
130
139
  }
131
140
  }
132
141
  return newMatrix;
133
142
  };
134
- export const getFluxExcessMileage = (pricingData, baseline)=>{
143
+ export const getFluxExcessMileage = (pricingData, baseline) => {
135
144
  return decimals(Math.max(Math.min(baseline * pricingData.fluxPricing.matrixCoefficients.excessMileage, pricingData.fluxPricing.excessMileage.upperBound), pricingData.fluxPricing.excessMileage.lowerBound));
136
145
  };
137
146
  /**
@@ -140,16 +149,21 @@ export const getFluxExcessMileage = (pricingData, baseline)=>{
140
149
  * @param coefficient
141
150
  *
142
151
  * @see https://docs.google.com/spreadsheets/d/1lYYMdQgnzG53lCGf_dKJY9pEue5suJuo3O3-zegIOT0/edit#gid=819271234
143
- */ export const getStartFeeMatrix = (pricingData, baseline, flatPricing)=>{
152
+ */
153
+ export const getStartFeeMatrix = (pricingData, baseline, flatPricing) => {
144
154
  // Let's not mutate percentages
145
155
  const newMatrix = cloneDeep(pricingData.startFee.matrixCoefficients);
146
156
  const baseCoefficients = cloneDeep(newMatrix.plan36);
147
157
  const plans = Object.keys(newMatrix);
148
- for (const plan of plans){
158
+ for (const plan of plans) {
149
159
  const mileagePackages = Object.keys(newMatrix[plan]);
150
- for (const mileagePackage of mileagePackages){
151
- newMatrix[plan][mileagePackage] = round(baseline * (flatPricing ? baseCoefficients[mileagePackage] : newMatrix[plan][mileagePackage]));
160
+ for (const mileagePackage of mileagePackages) {
161
+ newMatrix[plan][mileagePackage] = round(baseline *
162
+ (flatPricing
163
+ ? baseCoefficients[mileagePackage]
164
+ : newMatrix[plan][mileagePackage]));
152
165
  }
153
166
  }
154
167
  return sortMatrix(newMatrix);
155
168
  };
169
+ //# sourceMappingURL=index.js.map
@@ -1 +1,2 @@
1
- export { };
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driveflux/api-functions",
3
- "version": "0.0.7-next.7",
3
+ "version": "0.0.7-next.9",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./notion": {
@@ -74,21 +74,21 @@
74
74
  "dependencies": {
75
75
  "@casl/ability": "^6.7.3",
76
76
  "@driveflux/auth": "3.0.0-next.5",
77
- "@driveflux/billing": "7.0.0-develop.33",
77
+ "@driveflux/billing": "7.0.0-develop.38",
78
78
  "@driveflux/config": "2.1.0-next.1",
79
- "@driveflux/coupon": "8.0.0-develop.39",
80
- "@driveflux/db": "3.0.0-develop.58",
81
- "@driveflux/email": "6.0.0-develop.39",
82
- "@driveflux/email-templates": "0.0.2-develop.41",
83
- "@driveflux/engine": "0.1.2-develop.65",
79
+ "@driveflux/coupon": "8.0.0-develop.46",
80
+ "@driveflux/db": "3.0.0-develop.63",
81
+ "@driveflux/email": "6.0.0-develop.44",
82
+ "@driveflux/email-templates": "0.0.2-develop.47",
83
+ "@driveflux/engine": "0.1.2-develop.73",
84
84
  "@driveflux/fetch": "7.0.3",
85
85
  "@driveflux/format-money": "6.0.2",
86
86
  "@driveflux/problem": "5.0.3",
87
87
  "@driveflux/reporter": "6.0.4-next.2",
88
88
  "@driveflux/result": "5.0.3",
89
- "@driveflux/scheduler": "7.0.0-develop.39",
89
+ "@driveflux/scheduler": "7.0.0-develop.45",
90
90
  "@driveflux/singleton": "2.0.2",
91
- "@driveflux/subscription": "8.0.0-develop.28",
91
+ "@driveflux/subscription": "8.0.0-develop.30",
92
92
  "@driveflux/time": "5.0.2",
93
93
  "@driveflux/utils": "5.0.2",
94
94
  "@notionhq/client": "^4.0.2",