@star-insure/sdk 4.3.2 → 4.3.3
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/index.d.ts +1 -0
- package/dist/sdk.cjs.development.js +93 -9
- 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 +93 -10
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/index.ts +1 -0
package/dist/lib/index.d.ts
CHANGED
|
@@ -1221,6 +1221,98 @@ function calcPurchaseOptionPricing(_ref3) {
|
|
|
1221
1221
|
};
|
|
1222
1222
|
}
|
|
1223
1223
|
|
|
1224
|
+
/**
|
|
1225
|
+
* A wrapper around Inertia's usePage function that gives better type-safety
|
|
1226
|
+
*/
|
|
1227
|
+
|
|
1228
|
+
function usePage() {
|
|
1229
|
+
// @ts-ignore
|
|
1230
|
+
return react.usePage();
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* A helper to return a fetch function including default headers and authorization.
|
|
1235
|
+
*/
|
|
1236
|
+
|
|
1237
|
+
function useFetch(_ref) {
|
|
1238
|
+
var baseUrl = _ref.url,
|
|
1239
|
+
_ref$method = _ref.method,
|
|
1240
|
+
method = _ref$method === void 0 ? 'GET' : _ref$method,
|
|
1241
|
+
_ref$params = _ref.params,
|
|
1242
|
+
params = _ref$params === void 0 ? {} : _ref$params,
|
|
1243
|
+
_ref$headers = _ref.headers,
|
|
1244
|
+
headers = _ref$headers === void 0 ? {} : _ref$headers;
|
|
1245
|
+
var access_token = usePage().props.access_token;
|
|
1246
|
+
var url = baseUrl;
|
|
1247
|
+
|
|
1248
|
+
if (method === 'GET') {
|
|
1249
|
+
var queryParams = new URLSearchParams(params);
|
|
1250
|
+
url = url + "?" + queryParams.toString();
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
return React__default.useMemo(function () {
|
|
1254
|
+
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1255
|
+
var res, ok, body, parsedBody, message, data;
|
|
1256
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1257
|
+
while (1) {
|
|
1258
|
+
switch (_context.prev = _context.next) {
|
|
1259
|
+
case 0:
|
|
1260
|
+
_context.next = 2;
|
|
1261
|
+
return fetch(url, {
|
|
1262
|
+
method: method,
|
|
1263
|
+
headers: _extends({
|
|
1264
|
+
'Content-Type': 'application/json',
|
|
1265
|
+
Accept: 'application/json',
|
|
1266
|
+
Authorization: access_token ? "Bearer " + access_token : ''
|
|
1267
|
+
}, headers),
|
|
1268
|
+
body: Object.keys(params).length > 0 && method !== 'GET' ? JSON.stringify(params) : null
|
|
1269
|
+
});
|
|
1270
|
+
|
|
1271
|
+
case 2:
|
|
1272
|
+
res = _context.sent;
|
|
1273
|
+
ok = res.ok;
|
|
1274
|
+
_context.next = 6;
|
|
1275
|
+
return res.text();
|
|
1276
|
+
|
|
1277
|
+
case 6:
|
|
1278
|
+
body = _context.sent;
|
|
1279
|
+
parsedBody = body;
|
|
1280
|
+
|
|
1281
|
+
try {
|
|
1282
|
+
parsedBody = JSON.parse(body);
|
|
1283
|
+
} catch (error) {// Response wasn't JSON, just use the text version.
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
message = typeof parsedBody === 'string' ? parsedBody : undefined;
|
|
1287
|
+
|
|
1288
|
+
if (ok) {
|
|
1289
|
+
_context.next = 12;
|
|
1290
|
+
break;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
return _context.abrupt("return", {
|
|
1294
|
+
ok: ok,
|
|
1295
|
+
message: message
|
|
1296
|
+
});
|
|
1297
|
+
|
|
1298
|
+
case 12:
|
|
1299
|
+
data = typeof parsedBody !== 'string' ? parsedBody : undefined;
|
|
1300
|
+
return _context.abrupt("return", {
|
|
1301
|
+
ok: ok,
|
|
1302
|
+
data: data,
|
|
1303
|
+
message: message
|
|
1304
|
+
});
|
|
1305
|
+
|
|
1306
|
+
case 14:
|
|
1307
|
+
case "end":
|
|
1308
|
+
return _context.stop();
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
}, _callee);
|
|
1312
|
+
}));
|
|
1313
|
+
}, [access_token, url, params, headers, method]);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1224
1316
|
function Button(_ref) {
|
|
1225
1317
|
var className = _ref.className,
|
|
1226
1318
|
href = _ref.href,
|
|
@@ -2332,15 +2424,6 @@ function ErrorList(_ref) {
|
|
|
2332
2424
|
}))));
|
|
2333
2425
|
}
|
|
2334
2426
|
|
|
2335
|
-
/**
|
|
2336
|
-
* A wrapper around Inertia's usePage function that gives better type-safety
|
|
2337
|
-
*/
|
|
2338
|
-
|
|
2339
|
-
function usePage() {
|
|
2340
|
-
// @ts-ignore
|
|
2341
|
-
return react.usePage();
|
|
2342
|
-
}
|
|
2343
|
-
|
|
2344
2427
|
function BackButton(_ref) {
|
|
2345
2428
|
var back = _ref.back,
|
|
2346
2429
|
className = _ref.className;
|
|
@@ -3226,6 +3309,7 @@ exports.sanitiseVehicleType = sanitiseVehicleType;
|
|
|
3226
3309
|
exports.subtractGst = subtractGst;
|
|
3227
3310
|
exports.useAuth = useAuth;
|
|
3228
3311
|
exports.useClickOutside = useClickOutside;
|
|
3312
|
+
exports.useFetch = useFetch;
|
|
3229
3313
|
exports.useInertiaOptions = useInertiaOptions;
|
|
3230
3314
|
exports.useLocalStorage = useLocalStorage;
|
|
3231
3315
|
exports.useQuoteRequestForm = useQuoteRequestForm;
|