@star-insure/sdk 0.3.21 → 0.3.24
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/lib/dates.d.ts +2 -2
- package/dist/sdk.cjs.development.js +8 -3
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +8 -3
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/models/quotes/RedbookVehicle.d.ts +31 -0
- package/package.json +1 -1
- package/src/lib/dates.ts +4 -3
- package/src/types/models/quotes/RedbookVehicle.ts +35 -0
package/dist/lib/dates.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Formats a date like "Jan 1, 2022"
|
|
2
|
+
* Formats a date like "Jan 1, 2022 at 9:50am"
|
|
3
3
|
*/
|
|
4
|
-
export declare function formatDateNice(date: string): string;
|
|
4
|
+
export declare function formatDateNice(date: string, includeTime?: boolean): string;
|
|
5
5
|
/**
|
|
6
6
|
* Formats a date like "01/01/2022 9:50AM"
|
|
7
7
|
*/
|
|
@@ -5,11 +5,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var dateFns = require('date-fns');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Formats a date like "Jan 1, 2022"
|
|
8
|
+
* Formats a date like "Jan 1, 2022 at 9:50am"
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
function formatDateNice(date) {
|
|
12
|
-
|
|
11
|
+
function formatDateNice(date, includeTime) {
|
|
12
|
+
if (includeTime === void 0) {
|
|
13
|
+
includeTime = true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
var formatString = includeTime ? "MMM d, yyyy 'at' h:mma" : 'MMM d, yyyy';
|
|
17
|
+
return dateFns.format(new Date(date), formatString);
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
15
20
|
* Formats a date like "01/01/2022 9:50AM"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.cjs.development.js","sources":["../src/lib/dates.ts","../src/lib/money.ts","../src/lib/vehicles.ts"],"sourcesContent":["import { format } from \"date-fns\";\n\n/**\n * Formats a date like \"Jan 1, 2022\"\n */\nexport function formatDateNice(date: string) {\n
|
|
1
|
+
{"version":3,"file":"sdk.cjs.development.js","sources":["../src/lib/dates.ts","../src/lib/money.ts","../src/lib/vehicles.ts"],"sourcesContent":["import { format } from \"date-fns\";\n\n/**\n * Formats a date like \"Jan 1, 2022 at 9:50am\"\n */\nexport function formatDateNice(date: string, includeTime: boolean = true) {\n const formatString = includeTime ? \"MMM d, yyyy 'at' h:mma\" : 'MMM d, yyyy';\n return format(new Date(date), formatString);\n}\n\n/**\n * Formats a date like \"01/01/2022 9:50AM\"\n */\nexport function formatDateForTable(date: string, includeTime: boolean = true) {\n const formatString = includeTime ? 'dd/MM/yyyy h:mma' : 'dd/MM/yyyy';\n return format(new Date(date), formatString);\n}\n","/**\n * Safely rounds a number\n */\nexport function round(value: number): number {\n return Number(Math.round(parseFloat(value + 'e' + 2)) + 'e-' + 2)\n}\n\n/**\n * Gets the GST value from a number\n */\nexport function getGst(value: number): number {\n return round(value * 3 / 23);\n}\n\n/**\n * Adds GST to a number\n */\nexport function addGst(value: number): number {\n return round(value * 1.15);\n}\n\n/**\n * Subtracts GST from a number\n */\nexport function subtractGst(value: number): number {\n return round(value - getGst(value));\n}\n\n/**\n * Calculates the various GST values on a figure\n */\nexport function gstCalc(input: number|string): {\n gst: number,\n amountInclusive: number,\n amountExclusive: number\n} {\n let value = input;\n\n if (typeof value === 'string') {\n value = parseFloat(value.replace(/[^0-9.]/g, ''));\n }\n\n value = round(value);\n\n return {\n gst: getGst(value),\n amountInclusive: addGst(value),\n amountExclusive: subtractGst(value)\n }\n}\n\n/**\n * Formats a value nicely\n */\n export function formatMoney(value: string|number, decimals: number = 2): string {\n let toFormat = value;\n if (typeof value === 'string') {\n toFormat = value.replace(/[^\\d.-]/g, '')\n }\n\n return Number(toFormat).toLocaleString('en', {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n });\n}\n\n/**\n * Turns a formatted value in to a float\n */\nexport function formatNumber(value: string): number {\n return parseFloat(value.replace(/[^0-9.]/g, ''));\n}\n","import { VehicleType } from \"../types\";\n\nexport function sanitiseVehicleType(inputType: string): VehicleType {\n let type: VehicleType;\n\n switch (inputType) {\n case 'TRAILER_CARAVAN':\n case 'TRAILER_NOT_DESIGNED_FOR_HIGHWAY_USE':\n case 'MOBILE_MACHINE':\n case 'GOODS_VAN_TRUCK_UTILITY':\n case 'BUS':\n case 'MOTOR_CARAVAN': {\n type = 'motorhome';\n break;\n }\n case 'MOTORCYCLE':\n case 'ATV':\n case 'MOPED':\n case 'TRACTOR':\n case 'AGRICULTURAL_MACHINE':\n case 'HIGH_SPEED_AGRICULTURAL_VEHICLE': {\n type = 'motorcycle';\n break;\n }\n case 'PASSENGER_CAR_VAN':\n case 'SPECIAL_PURPOSE_VEHICLE':\n case 'UNKNOWN':\n default:\n type = 'car';\n }\n\n return type;\n}\n"],"names":["formatDateNice","date","includeTime","formatString","format","Date","formatDateForTable","round","value","Number","Math","parseFloat","getGst","addGst","subtractGst","gstCalc","input","replace","gst","amountInclusive","amountExclusive","formatMoney","decimals","toFormat","toLocaleString","minimumFractionDigits","maximumFractionDigits","formatNumber","sanitiseVehicleType","inputType","type"],"mappings":";;;;;;AAEA;;;;SAGgBA,eAAeC,MAAcC;MAAAA;IAAAA,cAAuB;;;EAChE,IAAMC,YAAY,GAAGD,WAAW,GAAG,wBAAH,GAA8B,aAA9D;EACA,OAAOE,cAAM,CAAC,IAAIC,IAAJ,CAASJ,IAAT,CAAD,EAAiBE,YAAjB,CAAb;AACH;AAED;;;;SAGgBG,mBAAmBL,MAAcC;MAAAA;IAAAA,cAAuB;;;EACpE,IAAMC,YAAY,GAAGD,WAAW,GAAG,kBAAH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jB,CAAgC,IAAhC,EAAsC;IACzCC,qBAAqB,EAAEH,QADkB;IAEzCI,qBAAqB,EAAEJ;GAFpB,CAAP;AAIH;AAED;;;;AAGA,SAAgBK,aAAanB;EACzB,OAAOG,UAAU,CAACH,KAAK,CAACS,OAAN,CAAc,UAAd,EAA0B,EAA1B,CAAD,CAAjB;AACH;;SCrEeW,oBAAoBC;EAChC,IAAIC,IAAJ;;EAEA,QAAQD,SAAR;IACI,KAAK,iBAAL;IACA,KAAK,sCAAL;IACA,KAAK,gBAAL;IACA,KAAK,yBAAL;IACA,KAAK,KAAL;IACA,KAAK,eAAL;MAAsB;QAClBC,IAAI,GAAG,WAAP;QACA;;;IAEJ,KAAK,YAAL;IACA,KAAK,KAAL;IACA,KAAK,OAAL;IACA,KAAK,SAAL;IACA,KAAK,sBAAL;IACA,KAAK,iCAAL;MAAwC;QACpCA,IAAI,GAAG,YAAP;QACA;;;IAEJ,KAAK,mBAAL;IACA,KAAK,yBAAL;IACA,KAAK,SAAL;IACA;MACIA,IAAI,GAAG,KAAP;;;EAGR,OAAOA,IAAP;AACH;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("date-fns");function t(e){return Number(Math.round(parseFloat(e+"e2"))+"e-2")}function r(e){return t(3*e/23)}function a(e){return t(1.15*e)}function o(e){return t(e-r(e))}exports.addGst=a,exports.formatDateForTable=function(t,r){void 0===r&&(r=!0);var a=r?"dd/MM/yyyy h:mma":"dd/MM/yyyy";return e.format(new Date(t),a)},exports.formatDateNice=function(t){return e.format(new Date(t),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("date-fns");function t(e){return Number(Math.round(parseFloat(e+"e2"))+"e-2")}function r(e){return t(3*e/23)}function a(e){return t(1.15*e)}function o(e){return t(e-r(e))}exports.addGst=a,exports.formatDateForTable=function(t,r){void 0===r&&(r=!0);var a=r?"dd/MM/yyyy h:mma":"dd/MM/yyyy";return e.format(new Date(t),a)},exports.formatDateNice=function(t,r){void 0===r&&(r=!0);var a=r?"MMM d, yyyy 'at' h:mma":"MMM d, yyyy";return e.format(new Date(t),a)},exports.formatMoney=function(e,t){void 0===t&&(t=2);var r=e;return"string"==typeof e&&(r=e.replace(/[^\d.-]/g,"")),Number(r).toLocaleString("en",{minimumFractionDigits:t,maximumFractionDigits:t})},exports.formatNumber=function(e){return parseFloat(e.replace(/[^0-9.]/g,""))},exports.getGst=r,exports.gstCalc=function(e){var n=e;return"string"==typeof n&&(n=parseFloat(n.replace(/[^0-9.]/g,""))),{gst:r(n=t(n)),amountInclusive:a(n),amountExclusive:o(n)}},exports.round=t,exports.sanitiseVehicleType=function(e){var t;switch(e){case"TRAILER_CARAVAN":case"TRAILER_NOT_DESIGNED_FOR_HIGHWAY_USE":case"MOBILE_MACHINE":case"GOODS_VAN_TRUCK_UTILITY":case"BUS":case"MOTOR_CARAVAN":t="motorhome";break;case"MOTORCYCLE":case"ATV":case"MOPED":case"TRACTOR":case"AGRICULTURAL_MACHINE":case"HIGH_SPEED_AGRICULTURAL_VEHICLE":t="motorcycle";break;case"PASSENGER_CAR_VAN":case"SPECIAL_PURPOSE_VEHICLE":case"UNKNOWN":default:t="car"}return t},exports.subtractGst=o;
|
|
2
2
|
//# sourceMappingURL=sdk.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.cjs.production.min.js","sources":["../src/lib/money.ts","../src/lib/dates.ts","../src/lib/vehicles.ts"],"sourcesContent":["/**\n * Safely rounds a number\n */\nexport function round(value: number): number {\n return Number(Math.round(parseFloat(value + 'e' + 2)) + 'e-' + 2)\n}\n\n/**\n * Gets the GST value from a number\n */\nexport function getGst(value: number): number {\n return round(value * 3 / 23);\n}\n\n/**\n * Adds GST to a number\n */\nexport function addGst(value: number): number {\n return round(value * 1.15);\n}\n\n/**\n * Subtracts GST from a number\n */\nexport function subtractGst(value: number): number {\n return round(value - getGst(value));\n}\n\n/**\n * Calculates the various GST values on a figure\n */\nexport function gstCalc(input: number|string): {\n gst: number,\n amountInclusive: number,\n amountExclusive: number\n} {\n let value = input;\n\n if (typeof value === 'string') {\n value = parseFloat(value.replace(/[^0-9.]/g, ''));\n }\n\n value = round(value);\n\n return {\n gst: getGst(value),\n amountInclusive: addGst(value),\n amountExclusive: subtractGst(value)\n }\n}\n\n/**\n * Formats a value nicely\n */\n export function formatMoney(value: string|number, decimals: number = 2): string {\n let toFormat = value;\n if (typeof value === 'string') {\n toFormat = value.replace(/[^\\d.-]/g, '')\n }\n\n return Number(toFormat).toLocaleString('en', {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n });\n}\n\n/**\n * Turns a formatted value in to a float\n */\nexport function formatNumber(value: string): number {\n return parseFloat(value.replace(/[^0-9.]/g, ''));\n}\n","import { format } from \"date-fns\";\n\n/**\n * Formats a date like \"Jan 1, 2022\"\n */\nexport function formatDateNice(date: string) {\n
|
|
1
|
+
{"version":3,"file":"sdk.cjs.production.min.js","sources":["../src/lib/money.ts","../src/lib/dates.ts","../src/lib/vehicles.ts"],"sourcesContent":["/**\n * Safely rounds a number\n */\nexport function round(value: number): number {\n return Number(Math.round(parseFloat(value + 'e' + 2)) + 'e-' + 2)\n}\n\n/**\n * Gets the GST value from a number\n */\nexport function getGst(value: number): number {\n return round(value * 3 / 23);\n}\n\n/**\n * Adds GST to a number\n */\nexport function addGst(value: number): number {\n return round(value * 1.15);\n}\n\n/**\n * Subtracts GST from a number\n */\nexport function subtractGst(value: number): number {\n return round(value - getGst(value));\n}\n\n/**\n * Calculates the various GST values on a figure\n */\nexport function gstCalc(input: number|string): {\n gst: number,\n amountInclusive: number,\n amountExclusive: number\n} {\n let value = input;\n\n if (typeof value === 'string') {\n value = parseFloat(value.replace(/[^0-9.]/g, ''));\n }\n\n value = round(value);\n\n return {\n gst: getGst(value),\n amountInclusive: addGst(value),\n amountExclusive: subtractGst(value)\n }\n}\n\n/**\n * Formats a value nicely\n */\n export function formatMoney(value: string|number, decimals: number = 2): string {\n let toFormat = value;\n if (typeof value === 'string') {\n toFormat = value.replace(/[^\\d.-]/g, '')\n }\n\n return Number(toFormat).toLocaleString('en', {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n });\n}\n\n/**\n * Turns a formatted value in to a float\n */\nexport function formatNumber(value: string): number {\n return parseFloat(value.replace(/[^0-9.]/g, ''));\n}\n","import { format } from \"date-fns\";\n\n/**\n * Formats a date like \"Jan 1, 2022 at 9:50am\"\n */\nexport function formatDateNice(date: string, includeTime: boolean = true) {\n const formatString = includeTime ? \"MMM d, yyyy 'at' h:mma\" : 'MMM d, yyyy';\n return format(new Date(date), formatString);\n}\n\n/**\n * Formats a date like \"01/01/2022 9:50AM\"\n */\nexport function formatDateForTable(date: string, includeTime: boolean = true) {\n const formatString = includeTime ? 'dd/MM/yyyy h:mma' : 'dd/MM/yyyy';\n return format(new Date(date), formatString);\n}\n","import { VehicleType } from \"../types\";\n\nexport function sanitiseVehicleType(inputType: string): VehicleType {\n let type: VehicleType;\n\n switch (inputType) {\n case 'TRAILER_CARAVAN':\n case 'TRAILER_NOT_DESIGNED_FOR_HIGHWAY_USE':\n case 'MOBILE_MACHINE':\n case 'GOODS_VAN_TRUCK_UTILITY':\n case 'BUS':\n case 'MOTOR_CARAVAN': {\n type = 'motorhome';\n break;\n }\n case 'MOTORCYCLE':\n case 'ATV':\n case 'MOPED':\n case 'TRACTOR':\n case 'AGRICULTURAL_MACHINE':\n case 'HIGH_SPEED_AGRICULTURAL_VEHICLE': {\n type = 'motorcycle';\n break;\n }\n case 'PASSENGER_CAR_VAN':\n case 'SPECIAL_PURPOSE_VEHICLE':\n case 'UNKNOWN':\n default:\n type = 'car';\n }\n\n return type;\n}\n"],"names":["round","value","Number","Math","parseFloat","getGst","addGst","subtractGst","date","includeTime","formatString","format","Date","decimals","toFormat","replace","toLocaleString","minimumFractionDigits","maximumFractionDigits","input","gst","amountInclusive","amountEx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
1
|
import { format } from 'date-fns';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Formats a date like "Jan 1, 2022"
|
|
4
|
+
* Formats a date like "Jan 1, 2022 at 9:50am"
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
function formatDateNice(date) {
|
|
8
|
-
|
|
7
|
+
function formatDateNice(date, includeTime) {
|
|
8
|
+
if (includeTime === void 0) {
|
|
9
|
+
includeTime = true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
var formatString = includeTime ? "MMM d, yyyy 'at' h:mma" : 'MMM d, yyyy';
|
|
13
|
+
return format(new Date(date), formatString);
|
|
9
14
|
}
|
|
10
15
|
/**
|
|
11
16
|
* Formats a date like "01/01/2022 9:50AM"
|
package/dist/sdk.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.esm.js","sources":["../src/lib/dates.ts","../src/lib/money.ts","../src/lib/vehicles.ts"],"sourcesContent":["import { format } from \"date-fns\";\n\n/**\n * Formats a date like \"Jan 1, 2022\"\n */\nexport function formatDateNice(date: string) {\n
|
|
1
|
+
{"version":3,"file":"sdk.esm.js","sources":["../src/lib/dates.ts","../src/lib/money.ts","../src/lib/vehicles.ts"],"sourcesContent":["import { format } from \"date-fns\";\n\n/**\n * Formats a date like \"Jan 1, 2022 at 9:50am\"\n */\nexport function formatDateNice(date: string, includeTime: boolean = true) {\n const formatString = includeTime ? \"MMM d, yyyy 'at' h:mma\" : 'MMM d, yyyy';\n return format(new Date(date), formatString);\n}\n\n/**\n * Formats a date like \"01/01/2022 9:50AM\"\n */\nexport function formatDateForTable(date: string, includeTime: boolean = true) {\n const formatString = includeTime ? 'dd/MM/yyyy h:mma' : 'dd/MM/yyyy';\n return format(new Date(date), formatString);\n}\n","/**\n * Safely rounds a number\n */\nexport function round(value: number): number {\n return Number(Math.round(parseFloat(value + 'e' + 2)) + 'e-' + 2)\n}\n\n/**\n * Gets the GST value from a number\n */\nexport function getGst(value: number): number {\n return round(value * 3 / 23);\n}\n\n/**\n * Adds GST to a number\n */\nexport function addGst(value: number): number {\n return round(value * 1.15);\n}\n\n/**\n * Subtracts GST from a number\n */\nexport function subtractGst(value: number): number {\n return round(value - getGst(value));\n}\n\n/**\n * Calculates the various GST values on a figure\n */\nexport function gstCalc(input: number|string): {\n gst: number,\n amountInclusive: number,\n amountExclusive: number\n} {\n let value = input;\n\n if (typeof value === 'string') {\n value = parseFloat(value.replace(/[^0-9.]/g, ''));\n }\n\n value = round(value);\n\n return {\n gst: getGst(value),\n amountInclusive: addGst(value),\n amountExclusive: subtractGst(value)\n }\n}\n\n/**\n * Formats a value nicely\n */\n export function formatMoney(value: string|number, decimals: number = 2): string {\n let toFormat = value;\n if (typeof value === 'string') {\n toFormat = value.replace(/[^\\d.-]/g, '')\n }\n\n return Number(toFormat).toLocaleString('en', {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n });\n}\n\n/**\n * Turns a formatted value in to a float\n */\nexport function formatNumber(value: string): number {\n return parseFloat(value.replace(/[^0-9.]/g, ''));\n}\n","import { VehicleType } from \"../types\";\n\nexport function sanitiseVehicleType(inputType: string): VehicleType {\n let type: VehicleType;\n\n switch (inputType) {\n case 'TRAILER_CARAVAN':\n case 'TRAILER_NOT_DESIGNED_FOR_HIGHWAY_USE':\n case 'MOBILE_MACHINE':\n case 'GOODS_VAN_TRUCK_UTILITY':\n case 'BUS':\n case 'MOTOR_CARAVAN': {\n type = 'motorhome';\n break;\n }\n case 'MOTORCYCLE':\n case 'ATV':\n case 'MOPED':\n case 'TRACTOR':\n case 'AGRICULTURAL_MACHINE':\n case 'HIGH_SPEED_AGRICULTURAL_VEHICLE': {\n type = 'motorcycle';\n break;\n }\n case 'PASSENGER_CAR_VAN':\n case 'SPECIAL_PURPOSE_VEHICLE':\n case 'UNKNOWN':\n default:\n type = 'car';\n }\n\n return type;\n}\n"],"names":["formatDateNice","date","includeTime","formatString","format","Date","formatDateForTable","round","value","Number","Math","parseFloat","getGst","addGst","subtractGst","gstCalc","input","replace","gst","amountInclusive","amountExclusive","formatMoney","decimals","toFormat","toLocaleString","minimumFractionDigits","maximumFractionDigits","formatNumber","sanitiseVehicleType","inputType","type"],"mappings":";;AAEA;;;;SAGgBA,eAAeC,MAAcC;MAAAA;IAAAA,cAAuB;;;EAChE,IAAMC,YAAY,GAAGD,WAAW,GAAG,wBAAH,GAA8B,aAA9D;EACA,OAAOE,MAAM,CAAC,IAAIC,IAAJ,CAASJ,IAAT,CAAD,EAAiBE,YAAjB,CAAb;AACH;AAED;;;;SAGgBG,mBAAmBL,MAAcC;MAAAA;IAAAA,cAAuB;;;EACpE,IAAMC,YAAY,GAAGD,WAAW,GAAG,kBAAH,GAAwB,YAAxD;EACA,OAAOE,MAAM,CAAC,IAAIC,IAAJ,CAASJ,IAAT,CAAD,EAAiBE,YAAjB,CAAb;AACH;;AChBD;;;AAGA,SAAgBI,MAAMC;EAClB,OAAOC,MAAM,CAACC,IAAI,CAACH,KAAL,CAAWI,UAAU,CAACH,KAAK,GAAG,GAAR,GAAc,CAAf,CAArB,IAA0C,IAA1C,GAAiD,CAAlD,CAAb;AACH;AAED;;;;AAGA,SAAgBI,OAAOJ;EACnB,OAAOD,KAAK,CAACC,KAAK,GAAG,CAAR,GAAY,EAAb,CAAZ;AACH;AAED;;;;AAGA,SAAgBK,OAAOL;EACnB,OAAOD,KAAK,CAACC,KAAK,GAAG,IAAT,CAAZ;AACH;AAED;;;;AAGA,SAAgBM,YAAYN;EACxB,OAAOD,KAAK,CAACC,KAAK,GAAGI,MAAM,CAACJ,KAAD,CAAf,CAAZ;AACH;AAED;;;;AAGA,SAAgBO,QAAQC;EAKpB,IAAIR,KAAK,GAAGQ,KAAZ;;EAEA,IAAI,OAAOR,KAAP,KAAiB,QAArB,EAA+B;IAC3BA,KAAK,GAAGG,UAAU,CAACH,KAAK,CAACS,OAAN,CAAc,UAAd,EAA0B,EAA1B,CAAD,CAAlB;;;EAGJT,KAAK,GAAGD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number | null;
|
|
24
|
+
valuation_details: Valuation[] | null;
|
|
25
|
+
chassis_number: string | null;
|
|
26
|
+
fuel_type: string | null;
|
|
27
|
+
previous_registered_country: string | null;
|
|
28
|
+
overseas_first_registered_year: number | null;
|
|
29
|
+
overseas_first_registered_month: number | null;
|
|
30
|
+
}
|
|
31
|
+
export interface Valuation {
|
|
32
|
+
matchedRedbookVehicle: MatchedRedbookVehicle;
|
|
33
|
+
valuationDetail: ValuationDetail;
|
|
34
|
+
}
|
|
35
|
+
export interface MatchedRedbookVehicle {
|
|
36
|
+
make?: string;
|
|
37
|
+
model?: string;
|
|
38
|
+
year?: number;
|
|
39
|
+
description?: string;
|
|
40
|
+
redbookCode: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ValuationDetail {
|
|
43
|
+
newRetailValue: number;
|
|
44
|
+
targetConditionTypeAvailable: boolean;
|
|
45
|
+
newValueAvailable: boolean;
|
|
46
|
+
pricingBandAvailable: boolean;
|
|
47
|
+
retailValueList: RetailValueList[];
|
|
48
|
+
}
|
|
49
|
+
export interface RetailValueList {
|
|
50
|
+
condition: string;
|
|
51
|
+
lowerPricingRange: number;
|
|
52
|
+
upperPricingRange: number;
|
|
53
|
+
value: number;
|
|
54
|
+
kilometers: number;
|
|
24
55
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@star-insure/sdk",
|
|
3
3
|
"description": "The SDK for Star Insure client apps with shared helper functions and TypeScript definitions.",
|
|
4
4
|
"author": "alexclark_nz",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.24",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
package/src/lib/dates.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { format } from "date-fns";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Formats a date like "Jan 1, 2022"
|
|
4
|
+
* Formats a date like "Jan 1, 2022 at 9:50am"
|
|
5
5
|
*/
|
|
6
|
-
export function formatDateNice(date: string) {
|
|
7
|
-
|
|
6
|
+
export function formatDateNice(date: string, includeTime: boolean = true) {
|
|
7
|
+
const formatString = includeTime ? "MMM d, yyyy 'at' h:mma" : 'MMM d, yyyy';
|
|
8
|
+
return format(new Date(date), formatString);
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -21,4 +21,39 @@ export interface RedbookVehicle {
|
|
|
21
21
|
vin: string | null;
|
|
22
22
|
weight: number | null;
|
|
23
23
|
year: number | null;
|
|
24
|
+
valuation_details: Valuation[] | null;
|
|
25
|
+
chassis_number: string | null;
|
|
26
|
+
fuel_type: string | null;
|
|
27
|
+
previous_registered_country: string | null;
|
|
28
|
+
overseas_first_registered_year: number | null;
|
|
29
|
+
overseas_first_registered_month: number | null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface Valuation {
|
|
33
|
+
matchedRedbookVehicle: MatchedRedbookVehicle;
|
|
34
|
+
valuationDetail: ValuationDetail;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export interface MatchedRedbookVehicle {
|
|
38
|
+
make?: string;
|
|
39
|
+
model?: string;
|
|
40
|
+
year?: number;
|
|
41
|
+
description?: string;
|
|
42
|
+
redbookCode: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ValuationDetail {
|
|
46
|
+
newRetailValue: number;
|
|
47
|
+
targetConditionTypeAvailable: boolean;
|
|
48
|
+
newValueAvailable: boolean;
|
|
49
|
+
pricingBandAvailable: boolean;
|
|
50
|
+
retailValueList: RetailValueList[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface RetailValueList {
|
|
54
|
+
condition: string;
|
|
55
|
+
lowerPricingRange: number;
|
|
56
|
+
upperPricingRange: number;
|
|
57
|
+
value: number;
|
|
58
|
+
kilometers: number;
|
|
24
59
|
}
|