@star-insure/sdk 0.1.0

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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.js +8 -0
  5. package/dist/lib/dates.d.ts +8 -0
  6. package/dist/lib/index.d.ts +2 -0
  7. package/dist/lib/money.d.ts +32 -0
  8. package/dist/sdk.cjs.development.js +104 -0
  9. package/dist/sdk.cjs.development.js.map +1 -0
  10. package/dist/sdk.cjs.production.min.js +2 -0
  11. package/dist/sdk.cjs.production.min.js.map +1 -0
  12. package/dist/sdk.esm.js +92 -0
  13. package/dist/sdk.esm.js.map +1 -0
  14. package/dist/types/api/auth.d.ts +8 -0
  15. package/dist/types/api/enums.d.ts +3 -0
  16. package/dist/types/api/index.d.ts +30 -0
  17. package/dist/types/index.d.ts +3 -0
  18. package/dist/types/misc/index.d.ts +8 -0
  19. package/dist/types/misc/inertia.d.ts +8 -0
  20. package/dist/types/models/auth/Group.d.ts +10 -0
  21. package/dist/types/models/auth/Permission.d.ts +4 -0
  22. package/dist/types/models/auth/Role.d.ts +6 -0
  23. package/dist/types/models/auth/User.d.ts +12 -0
  24. package/dist/types/models/auth/index.d.ts +4 -0
  25. package/dist/types/models/claims/ClaimRequest.d.ts +267 -0
  26. package/dist/types/models/claims/index.d.ts +1 -0
  27. package/dist/types/models/index.d.ts +3 -0
  28. package/dist/types/models/oracle/Risk.d.ts +7 -0
  29. package/dist/types/models/oracle/TableData.d.ts +8 -0
  30. package/dist/types/models/oracle/index.d.ts +2 -0
  31. package/dist/types/models/quotes/QuoteRequest.d.ts +130 -0
  32. package/dist/types/models/quotes/index.d.ts +1 -0
  33. package/package.json +65 -0
  34. package/src/index.ts +2 -0
  35. package/src/lib/dates.ts +15 -0
  36. package/src/lib/index.ts +2 -0
  37. package/src/lib/money.ts +72 -0
  38. package/src/types/api/auth.ts +10 -0
  39. package/src/types/api/enums.ts +5 -0
  40. package/src/types/api/index.ts +34 -0
  41. package/src/types/index.ts +3 -0
  42. package/src/types/misc/index.ts +10 -0
  43. package/src/types/misc/inertia.ts +9 -0
  44. package/src/types/models/auth/Group.ts +11 -0
  45. package/src/types/models/auth/Permission.ts +4 -0
  46. package/src/types/models/auth/Role.ts +7 -0
  47. package/src/types/models/auth/User.ts +13 -0
  48. package/src/types/models/auth/index.ts +4 -0
  49. package/src/types/models/claims/ClaimRequest.ts +278 -0
  50. package/src/types/models/claims/index.ts +1 -0
  51. package/src/types/models/index.ts +3 -0
  52. package/src/types/models/oracle/Risk.ts +7 -0
  53. package/src/types/models/oracle/TableData.ts +8 -0
  54. package/src/types/models/oracle/index.ts +2 -0
  55. package/src/types/models/quotes/QuoteRequest.ts +148 -0
  56. package/src/types/models/quotes/index.ts +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 alexclark_nz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Star Insure - SDK
2
+
3
+ The SDK for Star Insure client apps with shared helper functions and TypeScript definitions.
4
+
5
+ ## Installation
6
+ ```
7
+ npm install @star-insure/sdk
8
+ ```
9
+
10
+ ## Development
11
+ ```bash
12
+ npm start
13
+ ```
14
+ ### Testing
15
+ ```
16
+ npm run test
17
+ ```
18
+
19
+ ## Publishing to NPM
20
+ Suggest that you use [np](https://github.com/sindresorhus/np) for publishing.
21
+
22
+ From the command line just run:
23
+ ```
24
+ np
25
+ ```
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './lib';
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./sdk.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./sdk.cjs.development.js')
8
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Formats a date like "Jan 1, 2022"
3
+ */
4
+ export declare function formatDateNice(date: string): string;
5
+ /**
6
+ * Formats a date like "01/01/2022 9:50AM"
7
+ */
8
+ export declare function formatDateForTable(date: string): string;
@@ -0,0 +1,2 @@
1
+ export * from './dates';
2
+ export * from './money';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Safely rounds a number
3
+ */
4
+ export declare function round(value: number): number;
5
+ /**
6
+ * Gets the GST value from a number
7
+ */
8
+ export declare function getGst(value: number): number;
9
+ /**
10
+ * Adds GST to a number
11
+ */
12
+ export declare function addGst(value: number): number;
13
+ /**
14
+ * Subtracts GST from a number
15
+ */
16
+ export declare function subtractGst(value: number): number;
17
+ /**
18
+ * Calculates the various GST values on a figure
19
+ */
20
+ export declare function gstCalc(input: number | string): {
21
+ gst: number;
22
+ amountInclusive: number;
23
+ amountExclusive: number;
24
+ };
25
+ /**
26
+ * Formats a value nicely
27
+ */
28
+ export declare function formatMoney(value: string | number, decimals?: number): string;
29
+ /**
30
+ * Turns a formatted value in to a float
31
+ */
32
+ export declare function formatNumber(value: string): number;
@@ -0,0 +1,104 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var dateFns = require('date-fns');
6
+
7
+ /**
8
+ * Formats a date like "Jan 1, 2022"
9
+ */
10
+
11
+ function formatDateNice(date) {
12
+ return dateFns.format(new Date(date), "MMM d, yyyy");
13
+ }
14
+ /**
15
+ * Formats a date like "01/01/2022 9:50AM"
16
+ */
17
+
18
+ function formatDateForTable(date) {
19
+ return dateFns.format(new Date(date), 'dd/MM/yyyy h:mma');
20
+ }
21
+
22
+ /**
23
+ * Safely rounds a number
24
+ */
25
+ function round(value) {
26
+ return Number(Math.round(parseFloat(value + 'e' + 2)) + 'e-' + 2);
27
+ }
28
+ /**
29
+ * Gets the GST value from a number
30
+ */
31
+
32
+ function getGst(value) {
33
+ return round(value * 3 / 23);
34
+ }
35
+ /**
36
+ * Adds GST to a number
37
+ */
38
+
39
+ function addGst(value) {
40
+ return round(value * 1.15);
41
+ }
42
+ /**
43
+ * Subtracts GST from a number
44
+ */
45
+
46
+ function subtractGst(value) {
47
+ return round(value - getGst(value));
48
+ }
49
+ /**
50
+ * Calculates the various GST values on a figure
51
+ */
52
+
53
+ function gstCalc(input) {
54
+ var value = input;
55
+
56
+ if (typeof value === 'string') {
57
+ value = parseFloat(value.replace(/[^0-9.]/g, ''));
58
+ }
59
+
60
+ value = round(value);
61
+ return {
62
+ gst: getGst(value),
63
+ amountInclusive: addGst(value),
64
+ amountExclusive: subtractGst(value)
65
+ };
66
+ }
67
+ /**
68
+ * Formats a value nicely
69
+ */
70
+
71
+ function formatMoney(value, decimals) {
72
+ if (decimals === void 0) {
73
+ decimals = 2;
74
+ }
75
+
76
+ var toFormat = value;
77
+
78
+ if (typeof value === 'string') {
79
+ toFormat = value.replace(/[^\d.-]/g, '');
80
+ }
81
+
82
+ return Number(toFormat).toLocaleString('en', {
83
+ minimumFractionDigits: decimals,
84
+ maximumFractionDigits: decimals
85
+ });
86
+ }
87
+ /**
88
+ * Turns a formatted value in to a float
89
+ */
90
+
91
+ function formatNumber(value) {
92
+ return parseFloat(value.replace(/[^0-9.]/g, ''));
93
+ }
94
+
95
+ exports.addGst = addGst;
96
+ exports.formatDateForTable = formatDateForTable;
97
+ exports.formatDateNice = formatDateNice;
98
+ exports.formatMoney = formatMoney;
99
+ exports.formatNumber = formatNumber;
100
+ exports.getGst = getGst;
101
+ exports.gstCalc = gstCalc;
102
+ exports.round = round;
103
+ exports.subtractGst = subtractGst;
104
+ //# sourceMappingURL=sdk.cjs.development.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.cjs.development.js","sources":["../src/lib/dates.ts","../src/lib/money.ts"],"sourcesContent":["import { format } from \"date-fns\";\n\n/**\n * Formats a date like \"Jan 1, 2022\"\n */\nexport function formatDateNice(date: string) {\n return format(new Date(date), \"MMM d, yyyy\");\n}\n\n/**\n * Formats a date like \"01/01/2022 9:50AM\"\n */\nexport function formatDateForTable(date: string) {\n return format(new Date(date), 'dd/MM/yyyy h:mma');\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"],"names":["formatDateNice","date","format","Date","formatDateForTable","round","value","Number","Math","parseFloat","getGst","addGst","subtractGst","gstCalc","input","replace","gst","amountInclusive","amountExclusive","formatMoney","decimals","toFormat","toLocaleString","minimumFractionDigits","maximumFractionDigits","formatNumber"],"mappings":";;;;;;AAEA;;;;SAGgBA,eAAeC;EAC3B,OAAOC,cAAM,CAAC,IAAIC,IAAJ,CAASF,IAAT,CAAD,EAAiB,aAAjB,CAAb;AACH;AAED;;;;SAGgBG,mBAAmBH;EAC/B,OAAOC,cAAM,CAAC,IAAIC,IAAJ,CAASF,IAAT,CAAD,EAAiB,kBAAjB,CAAb;AACH;;ACdD;;;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,KAAK,CAACC,KAAD,CAAb;EAEA,OAAO;IACHU,GAAG,EAAEN,MAAM,CAACJ,KAAD,CADR;IAEHW,eAAe,EAAEN,MAAM,CAACL,KAAD,CAFpB;IAGHY,eAAe,EAAEN,WAAW,CAACN,KAAD;GAHhC;AAKH;AAED;;;;AAGC,SAAgBa,YAAYb,OAAsBc;MAAAA;IAAAA,WAAmB;;;EAClE,IAAIC,QAAQ,GAAGf,KAAf;;EACA,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;IAC3Be,QAAQ,GAAGf,KAAK,CAACS,OAAN,CAAc,UAAd,EAA0B,EAA1B,CAAX;;;EAGJ,OAAOR,MAAM,CAACc,QAAD,CAAN,CAAiBC,cAAjB,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;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("date-fns");function e(t){return Number(Math.round(parseFloat(t+"e2"))+"e-2")}function r(t){return e(3*t/23)}function n(t){return e(1.15*t)}function o(t){return e(t-r(t))}exports.addGst=n,exports.formatDateForTable=function(e){return t.format(new Date(e),"dd/MM/yyyy h:mma")},exports.formatDateNice=function(e){return t.format(new Date(e),"MMM d, yyyy")},exports.formatMoney=function(t,e){void 0===e&&(e=2);var r=t;return"string"==typeof t&&(r=t.replace(/[^\d.-]/g,"")),Number(r).toLocaleString("en",{minimumFractionDigits:e,maximumFractionDigits:e})},exports.formatNumber=function(t){return parseFloat(t.replace(/[^0-9.]/g,""))},exports.getGst=r,exports.gstCalc=function(t){var a=t;return"string"==typeof a&&(a=parseFloat(a.replace(/[^0-9.]/g,""))),{gst:r(a=e(a)),amountInclusive:n(a),amountExclusive:o(a)}},exports.round=e,exports.subtractGst=o;
2
+ //# sourceMappingURL=sdk.cjs.production.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.cjs.production.min.js","sources":["../src/lib/money.ts","../src/lib/dates.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 return format(new Date(date), \"MMM d, yyyy\");\n}\n\n/**\n * Formats a date like \"01/01/2022 9:50AM\"\n */\nexport function formatDateForTable(date: string) {\n return format(new Date(date), 'dd/MM/yyyy h:mma');\n}\n"],"names":["round","value","Number","Math","parseFloat","getGst","addGst","subtractGst","date","format","Date","decimals","toFormat","replace","toLocaleString","minimumFractionDigits","maximumFractionDigits","input","gst","amountInclusive","amountExclusive"],"mappings":"uGAGgBA,EAAMC,GAClB,OAAOC,OAAOC,KAAKH,MAAMI,WAAWH,EAAAA,OAAtBE,gBAMFE,EAAOJ,GACnB,OAAOD,EAAc,EAARC,EAAY,aAMbK,EAAOL,GACnB,OAAOD,EAAc,KAARC,YAMDM,EAAYN,GACxB,OAAOD,EAAMC,EAAQI,EAAOJ,yDCbGO,GAC/B,OAAOC,SAAO,IAAIC,KAAKF,GAAO,qDARHA,GAC3B,OAAOC,SAAO,IAAIC,KAAKF,GAAO,6CDgDLP,EAAsBU,YAAAA,IAAAA,EAAmB,GAClE,IAAIC,EAAWX,EAKf,MAJqB,iBAAVA,IACPW,EAAWX,EAAMY,QAAQ,WAAY,KAGlCX,OAAOU,GAAUE,eAAe,KAAM,CACzCC,sBAAuBJ,EACvBK,sBAAuBL,mCAOFV,GACzB,OAAOG,WAAWH,EAAMY,QAAQ,WAAY,gDAvCxBI,GAKpB,IAAIhB,EAAQgB,EAQZ,MANqB,iBAAVhB,IACPA,EAAQG,WAAWH,EAAMY,QAAQ,WAAY,MAK1C,CACHK,IAAKb,EAHTJ,EAAQD,EAAMC,IAIVkB,gBAAiBb,EAAOL,GACxBmB,gBAAiBb,EAAYN"}
@@ -0,0 +1,92 @@
1
+ import { format } from 'date-fns';
2
+
3
+ /**
4
+ * Formats a date like "Jan 1, 2022"
5
+ */
6
+
7
+ function formatDateNice(date) {
8
+ return format(new Date(date), "MMM d, yyyy");
9
+ }
10
+ /**
11
+ * Formats a date like "01/01/2022 9:50AM"
12
+ */
13
+
14
+ function formatDateForTable(date) {
15
+ return format(new Date(date), 'dd/MM/yyyy h:mma');
16
+ }
17
+
18
+ /**
19
+ * Safely rounds a number
20
+ */
21
+ function round(value) {
22
+ return Number(Math.round(parseFloat(value + 'e' + 2)) + 'e-' + 2);
23
+ }
24
+ /**
25
+ * Gets the GST value from a number
26
+ */
27
+
28
+ function getGst(value) {
29
+ return round(value * 3 / 23);
30
+ }
31
+ /**
32
+ * Adds GST to a number
33
+ */
34
+
35
+ function addGst(value) {
36
+ return round(value * 1.15);
37
+ }
38
+ /**
39
+ * Subtracts GST from a number
40
+ */
41
+
42
+ function subtractGst(value) {
43
+ return round(value - getGst(value));
44
+ }
45
+ /**
46
+ * Calculates the various GST values on a figure
47
+ */
48
+
49
+ function gstCalc(input) {
50
+ var value = input;
51
+
52
+ if (typeof value === 'string') {
53
+ value = parseFloat(value.replace(/[^0-9.]/g, ''));
54
+ }
55
+
56
+ value = round(value);
57
+ return {
58
+ gst: getGst(value),
59
+ amountInclusive: addGst(value),
60
+ amountExclusive: subtractGst(value)
61
+ };
62
+ }
63
+ /**
64
+ * Formats a value nicely
65
+ */
66
+
67
+ function formatMoney(value, decimals) {
68
+ if (decimals === void 0) {
69
+ decimals = 2;
70
+ }
71
+
72
+ var toFormat = value;
73
+
74
+ if (typeof value === 'string') {
75
+ toFormat = value.replace(/[^\d.-]/g, '');
76
+ }
77
+
78
+ return Number(toFormat).toLocaleString('en', {
79
+ minimumFractionDigits: decimals,
80
+ maximumFractionDigits: decimals
81
+ });
82
+ }
83
+ /**
84
+ * Turns a formatted value in to a float
85
+ */
86
+
87
+ function formatNumber(value) {
88
+ return parseFloat(value.replace(/[^0-9.]/g, ''));
89
+ }
90
+
91
+ export { addGst, formatDateForTable, formatDateNice, formatMoney, formatNumber, getGst, gstCalc, round, subtractGst };
92
+ //# sourceMappingURL=sdk.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.esm.js","sources":["../src/lib/dates.ts","../src/lib/money.ts"],"sourcesContent":["import { format } from \"date-fns\";\n\n/**\n * Formats a date like \"Jan 1, 2022\"\n */\nexport function formatDateNice(date: string) {\n return format(new Date(date), \"MMM d, yyyy\");\n}\n\n/**\n * Formats a date like \"01/01/2022 9:50AM\"\n */\nexport function formatDateForTable(date: string) {\n return format(new Date(date), 'dd/MM/yyyy h:mma');\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"],"names":["formatDateNice","date","format","Date","formatDateForTable","round","value","Number","Math","parseFloat","getGst","addGst","subtractGst","gstCalc","input","replace","gst","amountInclusive","amountExclusive","formatMoney","decimals","toFormat","toLocaleString","minimumFractionDigits","maximumFractionDigits","formatNumber"],"mappings":";;AAEA;;;;SAGgBA,eAAeC;EAC3B,OAAOC,MAAM,CAAC,IAAIC,IAAJ,CAASF,IAAT,CAAD,EAAiB,aAAjB,CAAb;AACH;AAED;;;;SAGgBG,mBAAmBH;EAC/B,OAAOC,MAAM,CAAC,IAAIC,IAAJ,CAASF,IAAT,CAAD,EAAiB,kBAAjB,CAAb;AACH;;ACdD;;;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,KAAK,CAACC,KAAD,CAAb;EAEA,OAAO;IACHU,GAAG,EAAEN,MAAM,CAACJ,KAAD,CADR;IAEHW,eAAe,EAAEN,MAAM,CAACL,KAAD,CAFpB;IAGHY,eAAe,EAAEN,WAAW,CAACN,KAAD;GAHhC;AAKH;AAED;;;;AAGC,SAAgBa,YAAYb,OAAsBc;MAAAA;IAAAA,WAAmB;;;EAClE,IAAIC,QAAQ,GAAGf,KAAf;;EACA,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;IAC3Be,QAAQ,GAAGf,KAAK,CAACS,OAAN,CAAc,UAAd,EAA0B,EAA1B,CAAX;;;EAGJ,OAAOR,MAAM,CAACc,QAAD,CAAN,CAAiBC,cAAjB,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;;;;"}
@@ -0,0 +1,8 @@
1
+ import { User, Group } from "../models";
2
+ export declare type Audience = 'administrator' | 'staff' | 'broker' | 'agent';
3
+ export interface AuthContext {
4
+ user?: User;
5
+ audience?: Audience;
6
+ group?: Group;
7
+ permissions: string[];
8
+ }
@@ -0,0 +1,3 @@
1
+ export declare type VehicleType = 'car' | 'motorcycle' | 'motorhome';
2
+ export declare type Frequency = 'daily' | 'weekly' | 'fortnightly' | 'monthly' | 'quarterly' | 'annually';
3
+ export declare type Condition = 'poor' | 'fair' | 'good';
@@ -0,0 +1,30 @@
1
+ export * from './auth';
2
+ export * from './enums';
3
+ export interface ApiResponse<T = any> {
4
+ data: T;
5
+ meta: Meta;
6
+ links: Links;
7
+ status: number;
8
+ ok: boolean;
9
+ }
10
+ export interface Meta {
11
+ current_page: number;
12
+ from: number;
13
+ last_page: number;
14
+ links: PaginationLink[];
15
+ path: string;
16
+ per_page: number;
17
+ to: number;
18
+ total: number;
19
+ }
20
+ export interface Links {
21
+ first: string;
22
+ last: string;
23
+ prev: string | null;
24
+ next: string | null;
25
+ }
26
+ export interface PaginationLink {
27
+ url: string | null;
28
+ label: string;
29
+ active: boolean;
30
+ }
@@ -0,0 +1,3 @@
1
+ export * from './models';
2
+ export * from './api';
3
+ export * from './misc';
@@ -0,0 +1,8 @@
1
+ export * from './inertia';
2
+ export declare type FormStatus = 'idle' | 'processing' | 'success' | 'error';
3
+ export interface Toast {
4
+ _id?: string;
5
+ message: string;
6
+ status?: 'success' | 'error' | 'default' | 'warning';
7
+ timeout?: number;
8
+ }
@@ -0,0 +1,8 @@
1
+ import type { ErrorBag, Errors, Page, PageProps as PagePropsInterface } from "@inertiajs/inertia";
2
+ import { AuthContext } from '../..';
3
+ export interface PageProps extends Page<PagePropsInterface> {
4
+ props: {
5
+ auth: AuthContext;
6
+ errors: Errors & ErrorBag;
7
+ };
8
+ }
@@ -0,0 +1,10 @@
1
+ import { Role, Permission, User } from ".";
2
+ export interface Group {
3
+ id: number;
4
+ name: string;
5
+ code: string;
6
+ 'x_code': string;
7
+ role?: Role;
8
+ permissions?: Permission[];
9
+ users?: User[];
10
+ }
@@ -0,0 +1,4 @@
1
+ export interface Permission {
2
+ id: number;
3
+ name: string;
4
+ }
@@ -0,0 +1,6 @@
1
+ import { Permission } from ".";
2
+ export interface Role {
3
+ id: number;
4
+ name: string;
5
+ permissions?: Permission[];
6
+ }
@@ -0,0 +1,12 @@
1
+ import { Group } from ".";
2
+ export interface User {
3
+ id: number;
4
+ name: string;
5
+ email: string;
6
+ mobile?: string;
7
+ direct_dial?: string;
8
+ position?: string;
9
+ group_admin?: boolean;
10
+ umbrella_filter?: string;
11
+ groups?: Group[];
12
+ }
@@ -0,0 +1,4 @@
1
+ export * from './User';
2
+ export * from './Group';
3
+ export * from './Role';
4
+ export * from './Permission';