@artaio/arta-browser 2.0.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 (42) hide show
  1. package/README.md +1 -0
  2. package/dist/MetadataTypes.d.ts +110 -0
  3. package/dist/MetadataTypes.js +2 -0
  4. package/dist/ModalStatus.d.ts +7 -0
  5. package/dist/ModalStatus.js +11 -0
  6. package/dist/arta.d.ts +14 -0
  7. package/dist/arta.js +45 -0
  8. package/dist/bundle.js +1 -0
  9. package/dist/components/Destination/countriesWithoutPostalCode.d.ts +1 -0
  10. package/dist/components/Destination/countriesWithoutPostalCode.js +64 -0
  11. package/dist/components/Destination/index.d.ts +26 -0
  12. package/dist/components/Destination/index.js +59 -0
  13. package/dist/components/Disqualified/index.d.ts +28 -0
  14. package/dist/components/Disqualified/index.js +35 -0
  15. package/dist/components/Footer/index.d.ts +6 -0
  16. package/dist/components/Footer/index.js +20 -0
  17. package/dist/components/Header/index.d.ts +6 -0
  18. package/dist/components/Header/index.js +20 -0
  19. package/dist/components/Loading/index.d.ts +5 -0
  20. package/dist/components/Loading/index.js +20 -0
  21. package/dist/components/Modal/index.css +738 -0
  22. package/dist/components/Modal/index.d.ts +9 -0
  23. package/dist/components/Modal/index.js +133 -0
  24. package/dist/components/Quotes/currencies.d.ts +6 -0
  25. package/dist/components/Quotes/currencies.js +25 -0
  26. package/dist/components/Quotes/index.d.ts +33 -0
  27. package/dist/components/Quotes/index.js +51 -0
  28. package/dist/estimate.d.ts +11 -0
  29. package/dist/estimate.js +72 -0
  30. package/dist/estimateConfig.d.ts +52 -0
  31. package/dist/estimateConfig.js +77 -0
  32. package/dist/fixtures/countries.d.ts +6 -0
  33. package/dist/fixtures/countries.js +250 -0
  34. package/dist/helper.d.ts +23 -0
  35. package/dist/helper.js +71 -0
  36. package/dist/index.d.ts +6 -0
  37. package/dist/index.js +28 -0
  38. package/dist/requests.d.ts +25 -0
  39. package/dist/requests.js +152 -0
  40. package/dist/typing.d.ts +1 -0
  41. package/dist/typing.js +1 -0
  42. package/package.json +49 -0
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.countries = void 0;
4
+ exports.countries = [
5
+ { code: 'AF', name: 'Afghanistan' },
6
+ { code: 'AX', name: 'Aland Islands' },
7
+ { code: 'AL', name: 'Albania' },
8
+ { code: 'DZ', name: 'Algeria' },
9
+ { code: 'AS', name: 'American Samoa' },
10
+ { code: 'AD', name: 'Andorra' },
11
+ { code: 'AO', name: 'Angola' },
12
+ { code: 'AI', name: 'Anguilla' },
13
+ { code: 'AQ', name: 'Antarctica' },
14
+ { code: 'AG', name: 'Antigua And Barbuda' },
15
+ { code: 'AR', name: 'Argentina' },
16
+ { code: 'AM', name: 'Armenia' },
17
+ { code: 'AW', name: 'Aruba' },
18
+ { code: 'AU', name: 'Australia' },
19
+ { code: 'AT', name: 'Austria' },
20
+ { code: 'AZ', name: 'Azerbaijan' },
21
+ { code: 'BS', name: 'Bahamas' },
22
+ { code: 'BH', name: 'Bahrain' },
23
+ { code: 'BD', name: 'Bangladesh' },
24
+ { code: 'BB', name: 'Barbados' },
25
+ { code: 'BY', name: 'Belarus' },
26
+ { code: 'BE', name: 'Belgium' },
27
+ { code: 'BZ', name: 'Belize' },
28
+ { code: 'BJ', name: 'Benin' },
29
+ { code: 'BM', name: 'Bermuda' },
30
+ { code: 'BT', name: 'Bhutan' },
31
+ { code: 'BO', name: 'Bolivia' },
32
+ { code: 'BA', name: 'Bosnia And Herzegovina' },
33
+ { code: 'BW', name: 'Botswana' },
34
+ { code: 'BV', name: 'Bouvet Island' },
35
+ { code: 'BR', name: 'Brazil' },
36
+ { code: 'IO', name: 'British Indian Ocean Territory' },
37
+ { code: 'BN', name: 'Brunei Darussalam' },
38
+ { code: 'BG', name: 'Bulgaria' },
39
+ { code: 'BF', name: 'Burkina Faso' },
40
+ { code: 'BI', name: 'Burundi' },
41
+ { code: 'KH', name: 'Cambodia' },
42
+ { code: 'CM', name: 'Cameroon' },
43
+ { code: 'CA', name: 'Canada' },
44
+ { code: 'CV', name: 'Cape Verde' },
45
+ { code: 'KY', name: 'Cayman Islands' },
46
+ { code: 'CF', name: 'Central African Republic' },
47
+ { code: 'TD', name: 'Chad' },
48
+ { code: 'CL', name: 'Chile' },
49
+ { code: 'CN', name: 'China' },
50
+ { code: 'CX', name: 'Christmas Island' },
51
+ { code: 'CC', name: 'Cocos (Keeling) Islands' },
52
+ { code: 'CO', name: 'Colombia' },
53
+ { code: 'KM', name: 'Comoros' },
54
+ { code: 'CG', name: 'Congo' },
55
+ { code: 'CD', name: 'Congo, Democratic Republic' },
56
+ { code: 'CK', name: 'Cook Islands' },
57
+ { code: 'CR', name: 'Costa Rica' },
58
+ { code: 'CI', name: "Cote D'Ivoire" },
59
+ { code: 'HR', name: 'Croatia' },
60
+ { code: 'CU', name: 'Cuba' },
61
+ { code: 'CY', name: 'Cyprus' },
62
+ { code: 'CZ', name: 'Czech Republic' },
63
+ { code: 'DK', name: 'Denmark' },
64
+ { code: 'DJ', name: 'Djibouti' },
65
+ { code: 'DM', name: 'Dominica' },
66
+ { code: 'DO', name: 'Dominican Republic' },
67
+ { code: 'EC', name: 'Ecuador' },
68
+ { code: 'EG', name: 'Egypt' },
69
+ { code: 'SV', name: 'El Salvador' },
70
+ { code: 'GQ', name: 'Equatorial Guinea' },
71
+ { code: 'ER', name: 'Eritrea' },
72
+ { code: 'EE', name: 'Estonia' },
73
+ { code: 'ET', name: 'Ethiopia' },
74
+ { code: 'FK', name: 'Falkland Islands (Malvinas)' },
75
+ { code: 'FO', name: 'Faroe Islands' },
76
+ { code: 'FJ', name: 'Fiji' },
77
+ { code: 'FI', name: 'Finland' },
78
+ { code: 'FR', name: 'France' },
79
+ { code: 'GF', name: 'French Guiana' },
80
+ { code: 'PF', name: 'French Polynesia' },
81
+ { code: 'TF', name: 'French Southern Territories' },
82
+ { code: 'GA', name: 'Gabon' },
83
+ { code: 'GM', name: 'Gambia' },
84
+ { code: 'GE', name: 'Georgia' },
85
+ { code: 'DE', name: 'Germany' },
86
+ { code: 'GH', name: 'Ghana' },
87
+ { code: 'GI', name: 'Gibraltar' },
88
+ { code: 'GR', name: 'Greece' },
89
+ { code: 'GL', name: 'Greenland' },
90
+ { code: 'GD', name: 'Grenada' },
91
+ { code: 'GP', name: 'Guadeloupe' },
92
+ { code: 'GU', name: 'Guam' },
93
+ { code: 'GT', name: 'Guatemala' },
94
+ { code: 'GG', name: 'Guernsey' },
95
+ { code: 'GN', name: 'Guinea' },
96
+ { code: 'GW', name: 'Guinea-Bissau' },
97
+ { code: 'GY', name: 'Guyana' },
98
+ { code: 'HT', name: 'Haiti' },
99
+ { code: 'HM', name: 'Heard Island & Mcdonald Islands' },
100
+ { code: 'VA', name: 'Holy See (Vatican City State)' },
101
+ { code: 'HN', name: 'Honduras' },
102
+ { code: 'HK', name: 'Hong Kong' },
103
+ { code: 'HU', name: 'Hungary' },
104
+ { code: 'IS', name: 'Iceland' },
105
+ { code: 'IN', name: 'India' },
106
+ { code: 'ID', name: 'Indonesia' },
107
+ { code: 'IR', name: 'Iran, Islamic Republic Of' },
108
+ { code: 'IQ', name: 'Iraq' },
109
+ { code: 'IE', name: 'Ireland' },
110
+ { code: 'IM', name: 'Isle Of Man' },
111
+ { code: 'IL', name: 'Israel' },
112
+ { code: 'IT', name: 'Italy' },
113
+ { code: 'JM', name: 'Jamaica' },
114
+ { code: 'JP', name: 'Japan' },
115
+ { code: 'JE', name: 'Jersey' },
116
+ { code: 'JO', name: 'Jordan' },
117
+ { code: 'KZ', name: 'Kazakhstan' },
118
+ { code: 'KE', name: 'Kenya' },
119
+ { code: 'KI', name: 'Kiribati' },
120
+ { code: 'KR', name: 'Korea' },
121
+ { code: 'KW', name: 'Kuwait' },
122
+ { code: 'KG', name: 'Kyrgyzstan' },
123
+ { code: 'LA', name: "Lao People's Democratic Republic" },
124
+ { code: 'LV', name: 'Latvia' },
125
+ { code: 'LB', name: 'Lebanon' },
126
+ { code: 'LS', name: 'Lesotho' },
127
+ { code: 'LR', name: 'Liberia' },
128
+ { code: 'LY', name: 'Libyan Arab Jamahiriya' },
129
+ { code: 'LI', name: 'Liechtenstein' },
130
+ { code: 'LT', name: 'Lithuania' },
131
+ { code: 'LU', name: 'Luxembourg' },
132
+ { code: 'MO', name: 'Macao' },
133
+ { code: 'MK', name: 'Macedonia' },
134
+ { code: 'MG', name: 'Madagascar' },
135
+ { code: 'MW', name: 'Malawi' },
136
+ { code: 'MY', name: 'Malaysia' },
137
+ { code: 'MV', name: 'Maldives' },
138
+ { code: 'ML', name: 'Mali' },
139
+ { code: 'MT', name: 'Malta' },
140
+ { code: 'MH', name: 'Marshall Islands' },
141
+ { code: 'MQ', name: 'Martinique' },
142
+ { code: 'MR', name: 'Mauritania' },
143
+ { code: 'MU', name: 'Mauritius' },
144
+ { code: 'YT', name: 'Mayotte' },
145
+ { code: 'MX', name: 'Mexico' },
146
+ { code: 'FM', name: 'Micronesia, Federated States Of' },
147
+ { code: 'MD', name: 'Moldova' },
148
+ { code: 'MC', name: 'Monaco' },
149
+ { code: 'MN', name: 'Mongolia' },
150
+ { code: 'ME', name: 'Montenegro' },
151
+ { code: 'MS', name: 'Montserrat' },
152
+ { code: 'MA', name: 'Morocco' },
153
+ { code: 'MZ', name: 'Mozambique' },
154
+ { code: 'MM', name: 'Myanmar' },
155
+ { code: 'NA', name: 'Namibia' },
156
+ { code: 'NR', name: 'Nauru' },
157
+ { code: 'NP', name: 'Nepal' },
158
+ { code: 'NL', name: 'Netherlands' },
159
+ { code: 'AN', name: 'Netherlands Antilles' },
160
+ { code: 'NC', name: 'New Caledonia' },
161
+ { code: 'NZ', name: 'New Zealand' },
162
+ { code: 'NI', name: 'Nicaragua' },
163
+ { code: 'NE', name: 'Niger' },
164
+ { code: 'NG', name: 'Nigeria' },
165
+ { code: 'NU', name: 'Niue' },
166
+ { code: 'NF', name: 'Norfolk Island' },
167
+ { code: 'MP', name: 'Northern Mariana Islands' },
168
+ { code: 'NO', name: 'Norway' },
169
+ { code: 'OM', name: 'Oman' },
170
+ { code: 'PK', name: 'Pakistan' },
171
+ { code: 'PW', name: 'Palau' },
172
+ { code: 'PS', name: 'Palestinian Territory, Occupied' },
173
+ { code: 'PA', name: 'Panama' },
174
+ { code: 'PG', name: 'Papua New Guinea' },
175
+ { code: 'PY', name: 'Paraguay' },
176
+ { code: 'PE', name: 'Peru' },
177
+ { code: 'PH', name: 'Philippines' },
178
+ { code: 'PN', name: 'Pitcairn' },
179
+ { code: 'PL', name: 'Poland' },
180
+ { code: 'PT', name: 'Portugal' },
181
+ { code: 'PR', name: 'Puerto Rico' },
182
+ { code: 'QA', name: 'Qatar' },
183
+ { code: 'RE', name: 'Reunion' },
184
+ { code: 'RO', name: 'Romania' },
185
+ { code: 'RU', name: 'Russian Federation' },
186
+ { code: 'RW', name: 'Rwanda' },
187
+ { code: 'BL', name: 'Saint Barthelemy' },
188
+ { code: 'SH', name: 'Saint Helena' },
189
+ { code: 'KN', name: 'Saint Kitts And Nevis' },
190
+ { code: 'LC', name: 'Saint Lucia' },
191
+ { code: 'MF', name: 'Saint Martin' },
192
+ { code: 'PM', name: 'Saint Pierre And Miquelon' },
193
+ { code: 'VC', name: 'Saint Vincent And Grenadines' },
194
+ { code: 'WS', name: 'Samoa' },
195
+ { code: 'SM', name: 'San Marino' },
196
+ { code: 'ST', name: 'Sao Tome And Principe' },
197
+ { code: 'SA', name: 'Saudi Arabia' },
198
+ { code: 'SN', name: 'Senegal' },
199
+ { code: 'RS', name: 'Serbia' },
200
+ { code: 'SC', name: 'Seychelles' },
201
+ { code: 'SL', name: 'Sierra Leone' },
202
+ { code: 'SG', name: 'Singapore' },
203
+ { code: 'SK', name: 'Slovakia' },
204
+ { code: 'SI', name: 'Slovenia' },
205
+ { code: 'SB', name: 'Solomon Islands' },
206
+ { code: 'SO', name: 'Somalia' },
207
+ { code: 'ZA', name: 'South Africa' },
208
+ { code: 'GS', name: 'South Georgia And Sandwich Isl.' },
209
+ { code: 'ES', name: 'Spain' },
210
+ { code: 'LK', name: 'Sri Lanka' },
211
+ { code: 'SD', name: 'Sudan' },
212
+ { code: 'SR', name: 'Suriname' },
213
+ { code: 'SJ', name: 'Svalbard And Jan Mayen' },
214
+ { code: 'SZ', name: 'Swaziland' },
215
+ { code: 'SE', name: 'Sweden' },
216
+ { code: 'CH', name: 'Switzerland' },
217
+ { code: 'SY', name: 'Syrian Arab Republic' },
218
+ { code: 'TW', name: 'Taiwan' },
219
+ { code: 'TJ', name: 'Tajikistan' },
220
+ { code: 'TZ', name: 'Tanzania' },
221
+ { code: 'TH', name: 'Thailand' },
222
+ { code: 'TL', name: 'Timor-Leste' },
223
+ { code: 'TG', name: 'Togo' },
224
+ { code: 'TK', name: 'Tokelau' },
225
+ { code: 'TO', name: 'Tonga' },
226
+ { code: 'TT', name: 'Trinidad And Tobago' },
227
+ { code: 'TN', name: 'Tunisia' },
228
+ { code: 'TR', name: 'Turkey' },
229
+ { code: 'TM', name: 'Turkmenistan' },
230
+ { code: 'TC', name: 'Turks And Caicos Islands' },
231
+ { code: 'TV', name: 'Tuvalu' },
232
+ { code: 'UG', name: 'Uganda' },
233
+ { code: 'UA', name: 'Ukraine' },
234
+ { code: 'AE', name: 'United Arab Emirates' },
235
+ { code: 'GB', name: 'United Kingdom' },
236
+ { code: 'US', name: 'United States' },
237
+ { code: 'UM', name: 'United States Outlying Islands' },
238
+ { code: 'UY', name: 'Uruguay' },
239
+ { code: 'UZ', name: 'Uzbekistan' },
240
+ { code: 'VU', name: 'Vanuatu' },
241
+ { code: 'VE', name: 'Venezuela' },
242
+ { code: 'VN', name: 'Viet Nam' },
243
+ { code: 'VG', name: 'Virgin Islands, British' },
244
+ { code: 'VI', name: 'Virgin Islands, U.S.' },
245
+ { code: 'WF', name: 'Wallis And Futuna' },
246
+ { code: 'EH', name: 'Western Sahara' },
247
+ { code: 'YE', name: 'Yemen' },
248
+ { code: 'ZM', name: 'Zambia' },
249
+ { code: 'ZW', name: 'Zimbabwe' },
250
+ ];
@@ -0,0 +1,23 @@
1
+ import { DestinationFullTextConfig } from './components/Destination';
2
+ import { DisqualifiedFullTextConfig } from './components/Disqualified';
3
+ import { QuoteFullTextConfig } from './components/Quotes';
4
+ import { EstimateFullConfig } from './estimateConfig';
5
+ import { ArtaLocation } from './MetadataTypes';
6
+ export declare const parseEstimatedLocation: (loc: ArtaLocation) => string;
7
+ export declare const parseErrors: (errors: {
8
+ [key: string]: string;
9
+ }) => string[];
10
+ export declare const getQuoteConfig: (config: EstimateFullConfig) => QuoteFullTextConfig;
11
+ export declare const getDisqualifiedConfig: (config: EstimateFullConfig) => DisqualifiedFullTextConfig;
12
+ export declare const getDestinationConfig: (config: EstimateFullConfig) => DestinationFullTextConfig;
13
+ export declare const getStyle: (config: EstimateFullConfig) => {
14
+ '--primary-color': string;
15
+ '--primary-unfocused-color': string;
16
+ '--secondary-color': string;
17
+ '--error-color': string;
18
+ '--background-color': string;
19
+ '--font-family': string;
20
+ '--font-size': string;
21
+ '--width': string;
22
+ '--height': string;
23
+ };
package/dist/helper.js ADDED
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getStyle = exports.getDestinationConfig = exports.getDisqualifiedConfig = exports.getQuoteConfig = exports.parseErrors = exports.parseEstimatedLocation = void 0;
15
+ var parseEstimatedLocation = function (loc) {
16
+ if (!loc) {
17
+ return '';
18
+ }
19
+ if (!loc.estimated_country || !loc.estimated_city) {
20
+ return "".concat(loc.postal_code, ", ").concat(loc.country);
21
+ }
22
+ var region = loc.estimated_country === 'US' && loc.estimated_region
23
+ ? loc.estimated_region
24
+ : '';
25
+ var city = loc.estimated_city.toLowerCase();
26
+ return region === ''
27
+ ? "".concat(city, ", ").concat(loc.estimated_country)
28
+ : "".concat(city, ", ").concat(region, ", ").concat(loc.estimated_country);
29
+ };
30
+ exports.parseEstimatedLocation = parseEstimatedLocation;
31
+ var parseErrors = function (errors) {
32
+ var errorMessages = [];
33
+ var keys = Object.keys(errors);
34
+ if (keys.includes('destination')) {
35
+ errorMessages.push('Invalid location details. Please check your destination address info and try again.');
36
+ }
37
+ else if (keys.includes('origin')) {
38
+ errorMessages.push('Invalid location details. Please check your origin address info and try again.');
39
+ }
40
+ else {
41
+ errorMessages.push('We have encountered an error.\nPlease try submitting the form again.');
42
+ }
43
+ return errorMessages;
44
+ };
45
+ exports.parseErrors = parseErrors;
46
+ var getQuoteConfig = function (config) {
47
+ return __assign(__assign({}, config.text.quoted), { detailOriginLabel: config.text.detailOriginLabel, detailDestinationLabel: config.text.detailDestinationLabel, returnLinkLabel: config.text.returnLinkLabel });
48
+ };
49
+ exports.getQuoteConfig = getQuoteConfig;
50
+ var getDisqualifiedConfig = function (config) {
51
+ return __assign(__assign({}, config.text.disqualified), { detailOriginLabel: config.text.detailOriginLabel, detailDestinationLabel: config.text.detailDestinationLabel, returnLinkLabel: config.text.returnLinkLabel });
52
+ };
53
+ exports.getDisqualifiedConfig = getDisqualifiedConfig;
54
+ var getDestinationConfig = function (config) {
55
+ return __assign(__assign({}, config.text.destination), { detailOriginLabel: config.text.detailOriginLabel, backgroundColor: config.style.color.backgroundColor });
56
+ };
57
+ exports.getDestinationConfig = getDestinationConfig;
58
+ var getStyle = function (config) {
59
+ return {
60
+ '--primary-color': config.style.color.primaryColor,
61
+ '--primary-unfocused-color': config.style.color.primaryUnfocusedColor,
62
+ '--secondary-color': config.style.color.secondaryColor,
63
+ '--error-color': config.style.color.errorColor,
64
+ '--background-color': config.style.color.backgroundColor,
65
+ '--font-family': config.style.fontFamily,
66
+ '--font-size': "".concat(config.style.fontSize, "px"),
67
+ '--width': "".concat(config.style.width, "px"),
68
+ '--height': "".concat(config.style.height, "px"),
69
+ };
70
+ };
71
+ exports.getStyle = getStyle;
@@ -0,0 +1,6 @@
1
+ import Arta from './arta';
2
+ import './components/Modal/index.css';
3
+ export * from './arta';
4
+ export * from './estimate';
5
+ declare const _default: Arta;
6
+ export default _default;
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ var arta_1 = __importDefault(require("./arta"));
21
+ require("./components/Modal/index.css");
22
+ var init = function () {
23
+ window.Arta = new arta_1.default();
24
+ };
25
+ init();
26
+ __exportStar(require("./arta"), exports);
27
+ __exportStar(require("./estimate"), exports);
28
+ exports.default = window.Arta;
@@ -0,0 +1,25 @@
1
+ import { ArtaJsFullConfig } from './arta';
2
+ import { EstimateBody } from './estimateConfig';
3
+ import { ArtaLocation, Insurance, Quote, SupportedCurrency } from './MetadataTypes';
4
+ export interface HostedSession {
5
+ id: string;
6
+ private_token: string;
7
+ origin: ArtaLocation;
8
+ }
9
+ export interface QuoteRequest {
10
+ quotes: Quote[];
11
+ currency: SupportedCurrency;
12
+ destination: ArtaLocation;
13
+ origin: ArtaLocation;
14
+ insurance: Insurance | null;
15
+ err?: ArtaError;
16
+ }
17
+ export interface ArtaError {
18
+ status: number;
19
+ errors: {
20
+ [key: string]: string;
21
+ };
22
+ }
23
+ export declare const loadHostedSessions: (config: ArtaJsFullConfig, estimateBody: EstimateBody) => Promise<HostedSession>;
24
+ export declare const loadQuoteRequests: (config: ArtaJsFullConfig, hostedSession: HostedSession, estimateBody: EstimateBody) => Promise<QuoteRequest>;
25
+ export declare const validateEstimateBody: (config: ArtaJsFullConfig, estimateBody: EstimateBody) => Promise<boolean>;
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.validateEstimateBody = exports.loadQuoteRequests = exports.loadHostedSessions = void 0;
51
+ var AUTH_KEY = 'ARTA_APIKey';
52
+ var logError = function (_a) {
53
+ var status = _a.status, errors = _a.errors;
54
+ console.log(errors);
55
+ var keys = Object.keys(errors);
56
+ if (status === 403) {
57
+ console.error('Invalid API Key');
58
+ }
59
+ else if (status === 401) {
60
+ console.error('Private API Key');
61
+ }
62
+ else if (status === 422) {
63
+ keys.map(function (key) {
64
+ console.error("".concat(key, " ").concat(errors[key]));
65
+ });
66
+ }
67
+ else if (status === 400) {
68
+ keys.map(function (key) {
69
+ console.error("".concat(key, " ").concat(errors[key]));
70
+ });
71
+ }
72
+ else {
73
+ console.error('Unkonwn error', status, errors);
74
+ }
75
+ };
76
+ var artaRequest = function (path, config, body, headers) { return __awaiter(void 0, void 0, void 0, function () {
77
+ var res, resBody, err;
78
+ return __generator(this, function (_a) {
79
+ switch (_a.label) {
80
+ case 0: return [4 /*yield*/, fetch("https://".concat(config.host).concat(path), {
81
+ method: 'POST',
82
+ body: body,
83
+ headers: __assign(__assign({}, headers), { Authorization: "".concat(AUTH_KEY, " ").concat(config.apiKey), 'Content-Type': 'application/json' }),
84
+ })];
85
+ case 1:
86
+ res = _a.sent();
87
+ return [4 /*yield*/, res.json()];
88
+ case 2:
89
+ resBody = _a.sent();
90
+ if (!res.ok) {
91
+ err = Object.assign({}, {
92
+ errors: resBody['errors'],
93
+ status: res.status,
94
+ statusText: res.statusText,
95
+ });
96
+ logError(err);
97
+ return [2 /*return*/, { err: err }];
98
+ }
99
+ return [2 /*return*/, resBody];
100
+ }
101
+ });
102
+ }); };
103
+ var loadHostedSessions = function (config, estimateBody) { return __awaiter(void 0, void 0, void 0, function () {
104
+ var path, body, res;
105
+ return __generator(this, function (_a) {
106
+ switch (_a.label) {
107
+ case 0:
108
+ path = '/estimate/hosted_sessions';
109
+ body = JSON.stringify({ hosted_session: estimateBody });
110
+ return [4 /*yield*/, artaRequest(path, config, body)];
111
+ case 1:
112
+ res = _a.sent();
113
+ return [2 /*return*/, res];
114
+ }
115
+ });
116
+ }); };
117
+ exports.loadHostedSessions = loadHostedSessions;
118
+ var loadQuoteRequests = function (config, hostedSession, estimateBody) { return __awaiter(void 0, void 0, void 0, function () {
119
+ var path, body, headers, res;
120
+ return __generator(this, function (_a) {
121
+ switch (_a.label) {
122
+ case 0:
123
+ path = '/estimate/requests';
124
+ body = JSON.stringify({ request: estimateBody });
125
+ headers = {
126
+ 'hosted-session-id': hostedSession.id,
127
+ 'hosted-session-private-token': hostedSession.private_token,
128
+ };
129
+ return [4 /*yield*/, artaRequest(path, config, body, headers)];
130
+ case 1:
131
+ res = _a.sent();
132
+ res.quotes && res.quotes.forEach(function (q) { return (q.total = parseFloat(q.total)); });
133
+ return [2 /*return*/, res];
134
+ }
135
+ });
136
+ }); };
137
+ exports.loadQuoteRequests = loadQuoteRequests;
138
+ var validateEstimateBody = function (config, estimateBody) { return __awaiter(void 0, void 0, void 0, function () {
139
+ var path, body, res;
140
+ return __generator(this, function (_a) {
141
+ switch (_a.label) {
142
+ case 0:
143
+ path = '/estimate/validate';
144
+ body = JSON.stringify({ estimate: estimateBody });
145
+ return [4 /*yield*/, artaRequest(path, config, body)];
146
+ case 1:
147
+ res = _a.sent();
148
+ return [2 /*return*/, !res.errors || res.errors.length === 0];
149
+ }
150
+ });
151
+ }); };
152
+ exports.validateEstimateBody = validateEstimateBody;
@@ -0,0 +1 @@
1
+ declare module '*.css';
package/dist/typing.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@artaio/arta-browser",
3
+ "version": "2.0.0",
4
+ "description": "",
5
+ "source": "lib/index.ts",
6
+ "exports": "./dist/arta.modern.js",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/arta.module.js",
9
+ "unpkg": "./dist/arta.umd.js",
10
+ "files": [
11
+ "dist/**/*"
12
+ ],
13
+ "scripts": {
14
+ "test": "npm run lint",
15
+ "build": "npm run build:cdn && npm run build:npm",
16
+ "build:npm": "./build-npm.sh && copyfiles -u 1 \"./lib/**/*.css\" \"./dist/\"",
17
+ "build:cdn": "microbundle -i lib/index.ts -o dist/bundle.js --external none --no-pkg-main -f umd --no-sourcemap --css inline",
18
+ "lint": "eslint .",
19
+ "lint:fix": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|tsx|jsx|json)\""
20
+ },
21
+ "devDependencies": {
22
+ "@typescript-eslint/eslint-plugin": "^5.39.0",
23
+ "@typescript-eslint/parser": "^5.40.1",
24
+ "copyfiles": "^2.4.1",
25
+ "eslint": "^8.24.0",
26
+ "eslint-config-preact": "^1.3.0",
27
+ "eslint-config-prettier": "^8.5.0",
28
+ "eslint-plugin-import": "^2.26.0",
29
+ "eslint-plugin-n": "^15.3.0",
30
+ "eslint-plugin-promise": "^6.0.1",
31
+ "microbundle": "^0.15.1",
32
+ "prettier": "2.7.1",
33
+ "typescript": "^4.8.4",
34
+ "typescript-plugin-css-modules": "^4.1.1"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/artaio/arta-browser.git"
39
+ },
40
+ "author": "",
41
+ "license": "ISC",
42
+ "bugs": {
43
+ "url": "https://github.com/artaio/arta-browser/issues"
44
+ },
45
+ "homepage": "https://github.com/artaio/arta-browser#readme",
46
+ "dependencies": {
47
+ "preact": "^10.11.3"
48
+ }
49
+ }