@bringg/dashboard-sdk 9.91.0 → 9.91.1
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/Vehicle/v2/vehicles-api.d.ts +3 -3
- package/dist/Vehicle/v2/vehicles-api.js +32 -2
- package/dist/Vehicle/v2/vehicles-api.js.map +1 -1
- package/dist/bringg-dashboard-sdk-cjs2.js +184 -3
- package/dist/bringg-dashboard-sdk-cjs2.js.map +1 -1
- package/dist/bringg-dashboard-sdk.js +13 -2
- package/dist/bringg-dashboard-sdk.min.js +1 -1
- package/dist/bringg-dashboard-sdk.min.js.map +1 -1
- package/dist/utils/decorators/negative-cache.d.ts +27 -0
- package/dist/utils/decorators/negative-cache.js +144 -0
- package/dist/utils/decorators/negative-cache.js.map +1 -0
- package/package.json +1 -1
|
@@ -2668,7 +2668,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
2668
2668
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2669
2669
|
|
|
2670
2670
|
"use strict";
|
|
2671
|
-
eval("\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.AnonymousServiceRequest = exports.AuthorizedServiceRequest = exports.ResponseHandler = exports.RequestOptions = exports.logErrorResponse = void 0;\nvar axios_1 = __importDefault(__webpack_require__(/*! axios */ \"./node_modules/axios/index.js\"));\nvar lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar BringgException_1 = __webpack_require__(/*! ../Core/BringgException */ \"./dist/Core/BringgException.js\");\nvar client_page_1 = __webpack_require__(/*! ../Core/Http/client-page */ \"./dist/Core/Http/client-page.js\");\nvar Logger_1 = __importDefault(__webpack_require__(/*! ../Core/Logger */ \"./dist/Core/Logger.js\"));\nvar abort_1 = __webpack_require__(/*! ../utils/abort */ \"./dist/utils/abort.js\");\nvar version = '9.91.0';\nfunction logErrorResponse(response) {\n var data = response.data, status = response.status;\n try {\n Logger_1.default.error(response.config.method.toUpperCase(), response.config.url, status);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.info(response.config.method.toUpperCase(), response.config.url, status, data);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.debug(response);\n }\n catch (e) {\n //\n }\n}\nexports.logErrorResponse = logErrorResponse;\nvar DEFAULT_TIMEOUT = 120000;\nvar RequestOptions = /** @class */ (function () {\n function RequestOptions(clientId, timeout, queryString, authenticationToken, headers, responseType, signal) {\n // NiceToHave: move headers to HttpHeaders class\n this.headers = __assign(__assign({ 'Content-Type': 'application/json' }, headers), { 'sdk-version': version, Client: clientId });\n this.timeout = timeout;\n this.validateStatus = lodash_1.stubTrue;\n var clientPage = (0, client_page_1.currentClientPage)();\n if (clientPage) {\n this.headers[client_page_1.CLIENT_PAGE_HEADER] = clientPage;\n }\n if (queryString) {\n this.params = queryString;\n }\n if (authenticationToken) {\n this.headers['Authorization'] = \"Token token=\".concat(authenticationToken);\n }\n if (responseType) {\n this.responseType = responseType;\n }\n if (signal) {\n this.signal = signal;\n }\n }\n RequestOptions.new = function (_a) {\n var _b = _a === void 0 ? {} : _a, _c = _b.clientId, clientId = _c === void 0 ? 'Bringg Dashboard' : _c, _d = _b.timeout, timeout = _d === void 0 ? DEFAULT_TIMEOUT : _d, queryString = _b.queryString, authenticationToken = _b.authenticationToken, headers = _b.headers, responseType = _b.responseType, signal = _b.signal;\n return new RequestOptions(clientId, timeout || DEFAULT_TIMEOUT, queryString, authenticationToken, headers, responseType, signal);\n };\n return RequestOptions;\n}());\nexports.RequestOptions = RequestOptions;\nvar ResponseHandler = /** @class */ (function () {\n function ResponseHandler(response, signal) {\n this.axiosPromise = response;\n this.signal = signal;\n }\n ResponseHandler.prototype.handle = function (consumer) {\n return __awaiter(this, void 0, void 0, function () {\n var axiosResponse, e_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if ((0, lodash_1.isUndefined)(consumer)) {\n throw new Error('consumer must be defined');\n }\n _a.label = 1;\n case 1:\n _a.trys.push([1, 3, , 4]);\n return [4 /*yield*/, this.axiosPromise];\n case 2:\n axiosResponse = _a.sent();\n return [2 /*return*/, consumer(axiosResponse)];\n case 3:\n e_1 = _a.sent();\n if (axios_1.default.isCancel(e_1)) {\n (0, abort_1.throwAbortError)(this.signal, 'Request Aborted');\n }\n if (e_1 instanceof BringgException_1.BringgException) {\n throw e_1;\n }\n return [2 /*return*/, consumer(e_1)];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n return ResponseHandler;\n}());\nexports.ResponseHandler = ResponseHandler;\nfunction get(axiosInstance, host, uri, queryString, signal) {\n return new ResponseHandler(axiosInstance.get(\"\".concat(host).concat(uri), { params: queryString, signal: signal }), signal);\n}\nfunction post(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.post(\"\".concat(host).concat(uri), payload, { params: queryString, signal: signal }), signal);\n}\nfunction put(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.put(\"\".concat(host).concat(uri), payload, { params: queryString, signal: signal }), signal);\n}\nfunction patch(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.patch(\"\".concat(host).concat(uri), payload, { params: queryString, signal: signal }), signal);\n}\nfunction remove(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.delete(\"\".concat(host).concat(uri), { params: queryString, data: payload, signal: signal }), signal);\n}\nfunction routify(axiosInstance, endpoint, route, routeParams, queryString, payload, signal) {\n switch (route.httpMethod) {\n case 0 /* HttpMethod.GET */:\n return get(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, signal);\n case 1 /* HttpMethod.POST */:\n return post(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n case 2 /* HttpMethod.PUT */:\n return put(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n case 3 /* HttpMethod.PATCH */:\n return patch(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n case 4 /* HttpMethod.DELETE */:\n return remove(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n }\n}\nfunction wrapWithInterceptors(axios) {\n axios.interceptors.request.use(function (req) {\n var method = req.method, url = req.url, params = req.params, headers = req.headers, data = req.data;\n try {\n Logger_1.default.debug('REQUEST:', method.toUpperCase(), url);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.trace('REQUEST-query-string:', params);\n Logger_1.default.trace('REQUEST-headers:', headers);\n Logger_1.default.trace('REQUEST-data:', data);\n }\n catch (e) {\n //\n }\n return req;\n });\n axios.interceptors.response.use(function (res) {\n var statusText = res.statusText, status = res.status, headers = res.headers, data = res.data;\n try {\n Logger_1.default.debug('RESPONSE:', res.config.url, status, statusText);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.trace('RESPONSE-headers:', headers);\n Logger_1.default.trace('RESPONSE-data:', data);\n }\n catch (e) {\n //\n }\n return res;\n });\n return axios;\n}\nfunction axiosInstance(clientId, authenticationToken, headers, responseType, timeout, signal) {\n return wrapWithInterceptors(axios_1.default.create(RequestOptions.new({ clientId: clientId, authenticationToken: authenticationToken, headers: headers, responseType: responseType, timeout: timeout, signal: signal })));\n}\nfunction anonymousAxiosInstance(clientId, headers, signal) {\n return wrapWithInterceptors(axios_1.default.create(RequestOptions.new({ clientId: clientId, headers: headers, signal: signal })));\n}\nvar AuthorizedServiceRequest = /** @class */ (function () {\n function AuthorizedServiceRequest(clientId, authToken) {\n this.authToken = authToken;\n this.clientId = clientId;\n }\n AuthorizedServiceRequest.prototype.invoke = function (endpoint, route, routeParams, queryString, payload, headers, responseType, timeout, signal) {\n if (signal === null || signal === void 0 ? void 0 : signal.aborted) {\n (0, abort_1.throwAbortError)(signal, 'Request aborted (before even started the request)');\n }\n return routify(axiosInstance(this.clientId, this.authToken, headers, responseType, timeout), endpoint, route, routeParams, queryString, payload, signal);\n };\n return AuthorizedServiceRequest;\n}());\nexports.AuthorizedServiceRequest = AuthorizedServiceRequest;\nvar AnonymousServiceRequest = /** @class */ (function () {\n function AnonymousServiceRequest(clientId, headers) {\n this.clientId = clientId;\n this.headers = headers;\n }\n AnonymousServiceRequest.prototype.invoke = function (endpoint, route, routeParams, queryString, payload, signal) {\n if (signal === null || signal === void 0 ? void 0 : signal.aborted) {\n (0, abort_1.throwAbortError)(signal, 'Request aborted (before even started the request)');\n }\n return routify(anonymousAxiosInstance(this.clientId, this.headers, signal), endpoint, route, routeParams, queryString, payload);\n };\n return AnonymousServiceRequest;\n}());\nexports.AnonymousServiceRequest = AnonymousServiceRequest;\n//# sourceMappingURL=ServiceRequest.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Services/ServiceRequest.js?");
|
|
2671
|
+
eval("\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.AnonymousServiceRequest = exports.AuthorizedServiceRequest = exports.ResponseHandler = exports.RequestOptions = exports.logErrorResponse = void 0;\nvar axios_1 = __importDefault(__webpack_require__(/*! axios */ \"./node_modules/axios/index.js\"));\nvar lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar BringgException_1 = __webpack_require__(/*! ../Core/BringgException */ \"./dist/Core/BringgException.js\");\nvar client_page_1 = __webpack_require__(/*! ../Core/Http/client-page */ \"./dist/Core/Http/client-page.js\");\nvar Logger_1 = __importDefault(__webpack_require__(/*! ../Core/Logger */ \"./dist/Core/Logger.js\"));\nvar abort_1 = __webpack_require__(/*! ../utils/abort */ \"./dist/utils/abort.js\");\nvar version = '9.91.1';\nfunction logErrorResponse(response) {\n var data = response.data, status = response.status;\n try {\n Logger_1.default.error(response.config.method.toUpperCase(), response.config.url, status);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.info(response.config.method.toUpperCase(), response.config.url, status, data);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.debug(response);\n }\n catch (e) {\n //\n }\n}\nexports.logErrorResponse = logErrorResponse;\nvar DEFAULT_TIMEOUT = 120000;\nvar RequestOptions = /** @class */ (function () {\n function RequestOptions(clientId, timeout, queryString, authenticationToken, headers, responseType, signal) {\n // NiceToHave: move headers to HttpHeaders class\n this.headers = __assign(__assign({ 'Content-Type': 'application/json' }, headers), { 'sdk-version': version, Client: clientId });\n this.timeout = timeout;\n this.validateStatus = lodash_1.stubTrue;\n var clientPage = (0, client_page_1.currentClientPage)();\n if (clientPage) {\n this.headers[client_page_1.CLIENT_PAGE_HEADER] = clientPage;\n }\n if (queryString) {\n this.params = queryString;\n }\n if (authenticationToken) {\n this.headers['Authorization'] = \"Token token=\".concat(authenticationToken);\n }\n if (responseType) {\n this.responseType = responseType;\n }\n if (signal) {\n this.signal = signal;\n }\n }\n RequestOptions.new = function (_a) {\n var _b = _a === void 0 ? {} : _a, _c = _b.clientId, clientId = _c === void 0 ? 'Bringg Dashboard' : _c, _d = _b.timeout, timeout = _d === void 0 ? DEFAULT_TIMEOUT : _d, queryString = _b.queryString, authenticationToken = _b.authenticationToken, headers = _b.headers, responseType = _b.responseType, signal = _b.signal;\n return new RequestOptions(clientId, timeout || DEFAULT_TIMEOUT, queryString, authenticationToken, headers, responseType, signal);\n };\n return RequestOptions;\n}());\nexports.RequestOptions = RequestOptions;\nvar ResponseHandler = /** @class */ (function () {\n function ResponseHandler(response, signal) {\n this.axiosPromise = response;\n this.signal = signal;\n }\n ResponseHandler.prototype.handle = function (consumer) {\n return __awaiter(this, void 0, void 0, function () {\n var axiosResponse, e_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if ((0, lodash_1.isUndefined)(consumer)) {\n throw new Error('consumer must be defined');\n }\n _a.label = 1;\n case 1:\n _a.trys.push([1, 3, , 4]);\n return [4 /*yield*/, this.axiosPromise];\n case 2:\n axiosResponse = _a.sent();\n return [2 /*return*/, consumer(axiosResponse)];\n case 3:\n e_1 = _a.sent();\n if (axios_1.default.isCancel(e_1)) {\n (0, abort_1.throwAbortError)(this.signal, 'Request Aborted');\n }\n if (e_1 instanceof BringgException_1.BringgException) {\n throw e_1;\n }\n return [2 /*return*/, consumer(e_1)];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n return ResponseHandler;\n}());\nexports.ResponseHandler = ResponseHandler;\nfunction get(axiosInstance, host, uri, queryString, signal) {\n return new ResponseHandler(axiosInstance.get(\"\".concat(host).concat(uri), { params: queryString, signal: signal }), signal);\n}\nfunction post(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.post(\"\".concat(host).concat(uri), payload, { params: queryString, signal: signal }), signal);\n}\nfunction put(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.put(\"\".concat(host).concat(uri), payload, { params: queryString, signal: signal }), signal);\n}\nfunction patch(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.patch(\"\".concat(host).concat(uri), payload, { params: queryString, signal: signal }), signal);\n}\nfunction remove(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.delete(\"\".concat(host).concat(uri), { params: queryString, data: payload, signal: signal }), signal);\n}\nfunction routify(axiosInstance, endpoint, route, routeParams, queryString, payload, signal) {\n switch (route.httpMethod) {\n case 0 /* HttpMethod.GET */:\n return get(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, signal);\n case 1 /* HttpMethod.POST */:\n return post(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n case 2 /* HttpMethod.PUT */:\n return put(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n case 3 /* HttpMethod.PATCH */:\n return patch(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n case 4 /* HttpMethod.DELETE */:\n return remove(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n }\n}\nfunction wrapWithInterceptors(axios) {\n axios.interceptors.request.use(function (req) {\n var method = req.method, url = req.url, params = req.params, headers = req.headers, data = req.data;\n try {\n Logger_1.default.debug('REQUEST:', method.toUpperCase(), url);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.trace('REQUEST-query-string:', params);\n Logger_1.default.trace('REQUEST-headers:', headers);\n Logger_1.default.trace('REQUEST-data:', data);\n }\n catch (e) {\n //\n }\n return req;\n });\n axios.interceptors.response.use(function (res) {\n var statusText = res.statusText, status = res.status, headers = res.headers, data = res.data;\n try {\n Logger_1.default.debug('RESPONSE:', res.config.url, status, statusText);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.trace('RESPONSE-headers:', headers);\n Logger_1.default.trace('RESPONSE-data:', data);\n }\n catch (e) {\n //\n }\n return res;\n });\n return axios;\n}\nfunction axiosInstance(clientId, authenticationToken, headers, responseType, timeout, signal) {\n return wrapWithInterceptors(axios_1.default.create(RequestOptions.new({ clientId: clientId, authenticationToken: authenticationToken, headers: headers, responseType: responseType, timeout: timeout, signal: signal })));\n}\nfunction anonymousAxiosInstance(clientId, headers, signal) {\n return wrapWithInterceptors(axios_1.default.create(RequestOptions.new({ clientId: clientId, headers: headers, signal: signal })));\n}\nvar AuthorizedServiceRequest = /** @class */ (function () {\n function AuthorizedServiceRequest(clientId, authToken) {\n this.authToken = authToken;\n this.clientId = clientId;\n }\n AuthorizedServiceRequest.prototype.invoke = function (endpoint, route, routeParams, queryString, payload, headers, responseType, timeout, signal) {\n if (signal === null || signal === void 0 ? void 0 : signal.aborted) {\n (0, abort_1.throwAbortError)(signal, 'Request aborted (before even started the request)');\n }\n return routify(axiosInstance(this.clientId, this.authToken, headers, responseType, timeout), endpoint, route, routeParams, queryString, payload, signal);\n };\n return AuthorizedServiceRequest;\n}());\nexports.AuthorizedServiceRequest = AuthorizedServiceRequest;\nvar AnonymousServiceRequest = /** @class */ (function () {\n function AnonymousServiceRequest(clientId, headers) {\n this.clientId = clientId;\n this.headers = headers;\n }\n AnonymousServiceRequest.prototype.invoke = function (endpoint, route, routeParams, queryString, payload, signal) {\n if (signal === null || signal === void 0 ? void 0 : signal.aborted) {\n (0, abort_1.throwAbortError)(signal, 'Request aborted (before even started the request)');\n }\n return routify(anonymousAxiosInstance(this.clientId, this.headers, signal), endpoint, route, routeParams, queryString, payload);\n };\n return AnonymousServiceRequest;\n}());\nexports.AnonymousServiceRequest = AnonymousServiceRequest;\n//# sourceMappingURL=ServiceRequest.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Services/ServiceRequest.js?");
|
|
2672
2672
|
|
|
2673
2673
|
/***/ }),
|
|
2674
2674
|
|
|
@@ -3504,7 +3504,7 @@ eval("\nvar __assign = (this && this.__assign) || function () {\n __assign =
|
|
|
3504
3504
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3505
3505
|
|
|
3506
3506
|
"use strict";
|
|
3507
|
-
eval("\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar types_1 = __webpack_require__(/*! @bringg/types */ \"./node_modules/@bringg/types/index.js\");\nvar lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar data_entity_1 = __webpack_require__(/*! ../../data-entity */ \"./dist/data-entity.js\");\nvar data_store_1 = __importDefault(__webpack_require__(/*! ../../data-store */ \"./dist/data-store.js\"));\nvar storable_data_service_1 = __importDefault(__webpack_require__(/*! ../../storable-data-service */ \"./dist/storable-data-service.js\"));\nvar Vehicle_consts_1 = __webpack_require__(/*! ../Vehicle.consts */ \"./dist/Vehicle/Vehicle.consts.js\");\nvar vehicle_realtime_subscriptions_1 = __importDefault(__webpack_require__(/*! ./vehicle-realtime-subscriptions */ \"./dist/Vehicle/v2/vehicle-realtime-subscriptions.js\"));\nvar vehicles_service_1 = __importDefault(__webpack_require__(/*! ./vehicles-service */ \"./dist/Vehicle/v2/vehicles-service.js\"));\nvar VehiclesApi = /** @class */ (function () {\n function VehiclesApi(session) {\n var _this = this;\n var groupFilters = [\n { groupType: Vehicle_consts_1.VehicleGroup.Team, keyFunc: function (vehicle) { return vehicle.team_id; } },\n { groupType: Vehicle_consts_1.VehicleGroup.IsTrailer, keyFunc: function (vehicle) { return !!vehicle.is_trailer; } }\n ];\n this.vehiclesStore = new data_store_1.default(groupFilters);\n this.vehiclesService = new vehicles_service_1.default(session);\n this.storableDataService = new storable_data_service_1.default(this.vehiclesStore, function (vehicle) { return _this.mapVehicle(vehicle); });\n this.vehicleRealtimeSubscriptions = new vehicle_realtime_subscriptions_1.default(session, this.vehiclesStore, this.storableDataService);\n }\n VehiclesApi.prototype.load = function (id, options) {\n var _this = this;\n return this.storableDataService.load('load', function () { return _this.vehiclesService.load(id); }, id, options);\n };\n VehiclesApi.prototype.loadAll = function (options) {\n var _this = this;\n return this.storableDataService.loadAll('loadAll', function () { return _this.vehiclesService.loadAll(); }, options);\n };\n VehiclesApi.prototype.loadAllByTeam = function (teamId, options) {\n var _this = this;\n return this.storableDataService.loadAll('loadAllByTeam', function () { return _this.vehiclesService.loadAllByTeam(teamId); }, __assign(__assign({}, options), { groupType: Vehicle_consts_1.VehicleGroup.Team, groupValue: teamId }));\n };\n VehiclesApi.prototype.loadMany = function (ids, options) {\n if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }\n return __awaiter(this, void 0, void 0, function () {\n var optionsWithDefaults, chunkSize;\n var _this = this;\n return __generator(this, function (_a) {\n optionsWithDefaults = (0, lodash_1.defaults)({}, options, __assign(__assign({}, data_entity_1.DEFAULT_OPTIONS), { chunkSize: 500 }));\n chunkSize = optionsWithDefaults.chunkSize;\n return [2 /*return*/, this.storableDataService.loadMany('batchGet', function (idsToLoad) {\n if (idsToLoad.length === 0) {\n return Promise.resolve([]);\n }\n return _this.vehiclesService.loadMany(idsToLoad, chunkSize, {\n signal: optionsWithDefaults.signal\n });\n }, ids, optionsWithDefaults)];\n });\n });\n };\n // When requesting by team_ids we don't know how many results will be returned\n // If all pages requested from the API result in a very big array which is set to the store within one sync operation\n // This may choke the main thread.\n // Request / set to the store page by page and let the consumer decide if it loads the next page.\n VehiclesApi.prototype.loadAllByTeamsPaged = function (teamIds, options) {\n var _a;\n return __awaiter(this, void 0, void 0, function () {\n var optionsWithDefaults, shouldUseCache, isFirstPageRequest, teamsIdsToLoad, response;\n var _this = this;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n optionsWithDefaults = (0, lodash_1.defaults)(options, { useCache: true });\n shouldUseCache = Boolean(optionsWithDefaults.useCache);\n isFirstPageRequest = (0, lodash_1.isNil)(optionsWithDefaults.cursor);\n teamsIdsToLoad = shouldUseCache && isFirstPageRequest\n ? teamIds.filter(function (teamId) { return !_this.vehiclesStore.isGroupInitialized(Vehicle_consts_1.VehicleGroup.Team, teamId); })\n : teamIds;\n if (isFirstPageRequest && teamsIdsToLoad.length === 0) {\n return [2 /*return*/, {\n next_page_cursor: null,\n vehicles: this.vehiclesStore.getGroup(Vehicle_consts_1.VehicleGroup.Team, teamIds)\n }];\n }\n return [4 /*yield*/, this.vehiclesService.loadAllByTeamsPaged({\n team_ids: teamsIdsToLoad,\n cursor: optionsWithDefaults.cursor,\n limit: optionsWithDefaults.chunkSize,\n page_action: types_1.KeysetPaginationPageAction.NEXT_ONLY\n }, {\n signal: optionsWithDefaults.signal\n })];\n case 1:\n response = _b.sent();\n if ((_a = response.vehicles) === null || _a === void 0 ? void 0 : _a.length) {\n this.storableDataService.updateManyInStores(response.vehicles, 'loadAllByTeamsPaged');\n }\n if (!response.next_page_cursor) {\n this.vehiclesStore.setGroupInitialized(Vehicle_consts_1.VehicleGroup.Team, teamsIdsToLoad);\n }\n return [2 /*return*/, {\n next_page_cursor: response.next_page_cursor,\n vehicles: response.vehicles.map(function (vehicle) { return _this.vehiclesStore.get(vehicle.id); })\n }];\n }\n });\n });\n };\n VehiclesApi.prototype.delete = function (id) {\n var _this = this;\n return this.storableDataService.delete('delete', function () { return _this.vehiclesService.delete(id); }, id);\n };\n VehiclesApi.prototype.update = function (id, vehicleData) {\n var _this = this;\n return this.storableDataService.modify('update', function () { return _this.vehiclesService.update(id, vehicleData); });\n };\n VehiclesApi.prototype.batchUpdate = function (vehicles) {\n return this.vehiclesService.batchUpdate(vehicles);\n };\n VehiclesApi.prototype.create = function (vehicleData) {\n var _this = this;\n return this.storableDataService.modify('create', function () { return _this.vehiclesService.create(vehicleData); });\n };\n VehiclesApi.prototype.updateStoreOnEvents = function () {\n this.vehicleRealtimeSubscriptions.updateStoreOnEvents();\n };\n // `trailer` is a derived field the reconciler maintains on trucks. Realtime vehicle payloads don't\n // carry it, so a plain truck update would otherwise REPLACE the cached truck and wipe its trailer.\n // Preserve the cached `trailer` whenever the incoming payload omits the key; take it from the payload\n // only when explicitly present (HTTP loads, PUT responses, reconciler writes).\n VehiclesApi.prototype.mapVehicle = function (vehicle) {\n var existing = this.vehiclesStore.get(vehicle.id);\n var current = existing && 'trailer' in existing && !('trailer' in vehicle)\n ? __assign(__assign({}, vehicle), { trailer: existing.trailer }) : vehicle;\n return { current: current, diff: existing };\n };\n VehiclesApi.prototype.onUpdate = function (callback) {\n return this.vehicleRealtimeSubscriptions.onUpdate(callback);\n };\n VehiclesApi.prototype.onDelete = function (callback) {\n return this.vehicleRealtimeSubscriptions.onDelete(callback);\n };\n VehiclesApi.prototype.onUnassigned = function (callback) {\n return this.vehicleRealtimeSubscriptions.onUnassigned(callback);\n };\n VehiclesApi.prototype.get = function (id) {\n return this.vehiclesStore.get(id);\n };\n VehiclesApi.prototype.getAll = function () {\n return this.vehiclesStore.getAll();\n };\n VehiclesApi.prototype.getGroup = function (group, groupValue) {\n return this.vehiclesStore.getGroup(group, groupValue);\n };\n VehiclesApi.prototype.deleteMany = function (ids) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n return [2 /*return*/, Promise.all(ids.map(function (id) { return _this.delete(id); }))];\n });\n });\n };\n VehiclesApi.prototype.importVehiclesCsv = function (file) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.vehiclesService.importVehiclesCsv(file)];\n });\n });\n };\n VehiclesApi.prototype.getCsvUploadFields = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.vehiclesService.getCsvUploadFields()];\n });\n });\n };\n VehiclesApi.prototype.getAssignmentHistory = function (id, options) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.vehiclesService.getAssignmentHistory(id, options)];\n });\n });\n };\n VehiclesApi.prototype.loadPagedVehicles = function (cursor, limit, filters, page_action) {\n return __awaiter(this, void 0, void 0, function () {\n var response;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.vehiclesService.loadPagedVehicles(cursor, filters, limit, page_action)];\n case 1:\n response = _a.sent();\n if (response && response.vehicles) {\n this.storableDataService.updateManyInStores(response.vehicles);\n }\n return [2 /*return*/, response];\n }\n });\n });\n };\n return VehiclesApi;\n}());\nexports[\"default\"] = VehiclesApi;\n//# sourceMappingURL=vehicles-api.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Vehicle/v2/vehicles-api.js?");
|
|
3507
|
+
eval("\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.MISSING_VEHICLES_CACHE_TTL = void 0;\nvar types_1 = __webpack_require__(/*! @bringg/types */ \"./node_modules/@bringg/types/index.js\");\nvar lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar data_entity_1 = __webpack_require__(/*! ../../data-entity */ \"./dist/data-entity.js\");\nvar data_store_1 = __importDefault(__webpack_require__(/*! ../../data-store */ \"./dist/data-store.js\"));\nvar storable_data_service_1 = __importDefault(__webpack_require__(/*! ../../storable-data-service */ \"./dist/storable-data-service.js\"));\nvar negative_cache_1 = __importDefault(__webpack_require__(/*! ../../utils/decorators/negative-cache */ \"./dist/utils/decorators/negative-cache.js\"));\nvar Vehicle_consts_1 = __webpack_require__(/*! ../Vehicle.consts */ \"./dist/Vehicle/Vehicle.consts.js\");\nvar vehicle_realtime_subscriptions_1 = __importDefault(__webpack_require__(/*! ./vehicle-realtime-subscriptions */ \"./dist/Vehicle/v2/vehicle-realtime-subscriptions.js\"));\nvar vehicles_service_1 = __importDefault(__webpack_require__(/*! ./vehicles-service */ \"./dist/Vehicle/v2/vehicles-service.js\"));\n// How long a vehicle id the server did not return stays out of `batch_get` requests.\nexports.MISSING_VEHICLES_CACHE_TTL = 1000 * 60 * 10; // 10 minutes\nvar MAX_VEHICLES_CHUNK_SIZE = 500;\nvar SERVER_DEFAULT_VEHICLES_CHUNK_SIZE = 50;\nvar getSafeChunkSize = function (chunkSize) {\n if ((0, lodash_1.isNil)(chunkSize) || chunkSize > MAX_VEHICLES_CHUNK_SIZE) {\n return MAX_VEHICLES_CHUNK_SIZE;\n }\n if (chunkSize <= 0) {\n return SERVER_DEFAULT_VEHICLES_CHUNK_SIZE;\n }\n return chunkSize;\n};\nvar VehiclesApi = /** @class */ (function () {\n function VehiclesApi(session) {\n var _this = this;\n var groupFilters = [\n { groupType: Vehicle_consts_1.VehicleGroup.Team, keyFunc: function (vehicle) { return vehicle.team_id; } },\n { groupType: Vehicle_consts_1.VehicleGroup.IsTrailer, keyFunc: function (vehicle) { return !!vehicle.is_trailer; } }\n ];\n this.vehiclesStore = new data_store_1.default(groupFilters);\n this.vehiclesService = new vehicles_service_1.default(session);\n this.storableDataService = new storable_data_service_1.default(this.vehiclesStore, function (vehicle) { return _this.mapVehicle(vehicle); });\n this.vehicleRealtimeSubscriptions = new vehicle_realtime_subscriptions_1.default(session, this.vehiclesStore, this.storableDataService);\n }\n VehiclesApi.prototype.load = function (id, options) {\n var _this = this;\n return this.storableDataService.load('load', function () { return _this.vehiclesService.load(id); }, id, options);\n };\n VehiclesApi.prototype.loadAll = function (options) {\n var _this = this;\n return this.storableDataService.loadAll('loadAll', function () { return _this.vehiclesService.loadAll(); }, options);\n };\n VehiclesApi.prototype.loadAllByTeam = function (teamId, options) {\n var _this = this;\n return this.storableDataService.loadAll('loadAllByTeam', function () { return _this.vehiclesService.loadAllByTeam(teamId); }, __assign(__assign({}, options), { groupType: Vehicle_consts_1.VehicleGroup.Team, groupValue: teamId }));\n };\n // Suppression assumes an id absent from the response is ones the backend can not return for the current user.\n // Note! Items dropped by the server because of limit / chunkSize also fall in this bucket.\n VehiclesApi.prototype.loadMany = function (ids, options) {\n if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }\n return __awaiter(this, void 0, void 0, function () {\n var optionsWithDefaults, chunkSize;\n var _this = this;\n return __generator(this, function (_a) {\n optionsWithDefaults = (0, lodash_1.defaults)({}, options, __assign({}, data_entity_1.DEFAULT_OPTIONS));\n chunkSize = getSafeChunkSize(optionsWithDefaults.chunkSize);\n optionsWithDefaults.chunkSize = chunkSize;\n return [2 /*return*/, this.storableDataService.loadMany('batchGet', function (idsToLoad) {\n if (idsToLoad.length === 0) {\n return Promise.resolve([]);\n }\n return _this.vehiclesService.loadMany(idsToLoad, chunkSize, {\n signal: optionsWithDefaults.signal\n });\n }, ids, optionsWithDefaults)];\n });\n });\n };\n // When requesting by team_ids we don't know how many results will be returned\n // If all pages requested from the API result in a very big array which is set to the store within one sync operation\n // This may choke the main thread.\n // Request / set to the store page by page and let the consumer decide if it loads the next page.\n VehiclesApi.prototype.loadAllByTeamsPaged = function (teamIds, options) {\n var _a;\n return __awaiter(this, void 0, void 0, function () {\n var optionsWithDefaults, shouldUseCache, isFirstPageRequest, teamsIdsToLoad, response;\n var _this = this;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n optionsWithDefaults = (0, lodash_1.defaults)(options, { useCache: true });\n shouldUseCache = Boolean(optionsWithDefaults.useCache);\n isFirstPageRequest = (0, lodash_1.isNil)(optionsWithDefaults.cursor);\n teamsIdsToLoad = shouldUseCache && isFirstPageRequest\n ? teamIds.filter(function (teamId) { return !_this.vehiclesStore.isGroupInitialized(Vehicle_consts_1.VehicleGroup.Team, teamId); })\n : teamIds;\n if (isFirstPageRequest && teamsIdsToLoad.length === 0) {\n return [2 /*return*/, {\n next_page_cursor: null,\n vehicles: this.vehiclesStore.getGroup(Vehicle_consts_1.VehicleGroup.Team, teamIds)\n }];\n }\n return [4 /*yield*/, this.vehiclesService.loadAllByTeamsPaged({\n team_ids: teamsIdsToLoad,\n cursor: optionsWithDefaults.cursor,\n limit: optionsWithDefaults.chunkSize,\n page_action: types_1.KeysetPaginationPageAction.NEXT_ONLY\n }, {\n signal: optionsWithDefaults.signal\n })];\n case 1:\n response = _b.sent();\n if ((_a = response.vehicles) === null || _a === void 0 ? void 0 : _a.length) {\n this.storableDataService.updateManyInStores(response.vehicles, 'loadAllByTeamsPaged');\n }\n if (!response.next_page_cursor) {\n this.vehiclesStore.setGroupInitialized(Vehicle_consts_1.VehicleGroup.Team, teamsIdsToLoad);\n }\n return [2 /*return*/, {\n next_page_cursor: response.next_page_cursor,\n vehicles: response.vehicles.map(function (vehicle) { return _this.vehiclesStore.get(vehicle.id); })\n }];\n }\n });\n });\n };\n VehiclesApi.prototype.delete = function (id) {\n var _this = this;\n return this.storableDataService.delete('delete', function () { return _this.vehiclesService.delete(id); }, id);\n };\n VehiclesApi.prototype.update = function (id, vehicleData) {\n var _this = this;\n return this.storableDataService.modify('update', function () { return _this.vehiclesService.update(id, vehicleData); });\n };\n VehiclesApi.prototype.batchUpdate = function (vehicles) {\n return this.vehiclesService.batchUpdate(vehicles);\n };\n VehiclesApi.prototype.create = function (vehicleData) {\n var _this = this;\n return this.storableDataService.modify('create', function () { return _this.vehiclesService.create(vehicleData); });\n };\n VehiclesApi.prototype.updateStoreOnEvents = function () {\n this.vehicleRealtimeSubscriptions.updateStoreOnEvents();\n };\n // `trailer` is a derived field the reconciler maintains on trucks. Realtime vehicle payloads don't\n // carry it, so a plain truck update would otherwise REPLACE the cached truck and wipe its trailer.\n // Preserve the cached `trailer` whenever the incoming payload omits the key; take it from the payload\n // only when explicitly present (HTTP loads, PUT responses, reconciler writes).\n VehiclesApi.prototype.mapVehicle = function (vehicle) {\n var existing = this.vehiclesStore.get(vehicle.id);\n var current = existing && 'trailer' in existing && !('trailer' in vehicle)\n ? __assign(__assign({}, vehicle), { trailer: existing.trailer }) : vehicle;\n return { current: current, diff: existing };\n };\n VehiclesApi.prototype.onUpdate = function (callback) {\n return this.vehicleRealtimeSubscriptions.onUpdate(callback);\n };\n VehiclesApi.prototype.onDelete = function (callback) {\n return this.vehicleRealtimeSubscriptions.onDelete(callback);\n };\n VehiclesApi.prototype.onUnassigned = function (callback) {\n return this.vehicleRealtimeSubscriptions.onUnassigned(callback);\n };\n VehiclesApi.prototype.get = function (id) {\n return this.vehiclesStore.get(id);\n };\n VehiclesApi.prototype.getAll = function () {\n return this.vehiclesStore.getAll();\n };\n VehiclesApi.prototype.getGroup = function (group, groupValue) {\n return this.vehiclesStore.getGroup(group, groupValue);\n };\n VehiclesApi.prototype.deleteMany = function (ids) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n return [2 /*return*/, Promise.all(ids.map(function (id) { return _this.delete(id); }))];\n });\n });\n };\n VehiclesApi.prototype.importVehiclesCsv = function (file) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.vehiclesService.importVehiclesCsv(file)];\n });\n });\n };\n VehiclesApi.prototype.getCsvUploadFields = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.vehiclesService.getCsvUploadFields()];\n });\n });\n };\n VehiclesApi.prototype.getAssignmentHistory = function (id, options) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.vehiclesService.getAssignmentHistory(id, options)];\n });\n });\n };\n VehiclesApi.prototype.loadPagedVehicles = function (cursor, limit, filters, page_action) {\n return __awaiter(this, void 0, void 0, function () {\n var response;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.vehiclesService.loadPagedVehicles(cursor, filters, limit, page_action)];\n case 1:\n response = _a.sent();\n if (response && response.vehicles) {\n this.storableDataService.updateManyInStores(response.vehicles);\n }\n return [2 /*return*/, response];\n }\n });\n });\n };\n __decorate([\n (0, negative_cache_1.default)({\n ttlMs: exports.MISSING_VEHICLES_CACHE_TTL,\n hasItem: function (vehiclesApi, id) { return !(0, lodash_1.isNil)(vehiclesApi.get(id)); }\n })\n ], VehiclesApi.prototype, \"loadMany\", null);\n return VehiclesApi;\n}());\nexports[\"default\"] = VehiclesApi;\n//# sourceMappingURL=vehicles-api.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Vehicle/v2/vehicles-api.js?");
|
|
3508
3508
|
|
|
3509
3509
|
/***/ }),
|
|
3510
3510
|
|
|
@@ -3849,6 +3849,17 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nfunc
|
|
|
3849
3849
|
|
|
3850
3850
|
/***/ }),
|
|
3851
3851
|
|
|
3852
|
+
/***/ "./dist/utils/decorators/negative-cache.js":
|
|
3853
|
+
/*!*************************************************!*\
|
|
3854
|
+
!*** ./dist/utils/decorators/negative-cache.js ***!
|
|
3855
|
+
\*************************************************/
|
|
3856
|
+
/***/ (function(__unused_webpack_module, exports) {
|
|
3857
|
+
|
|
3858
|
+
"use strict";
|
|
3859
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.DEFAULT_NEGATIVE_CACHE_MAX_SIZE = void 0;\nexports.DEFAULT_NEGATIVE_CACHE_MAX_SIZE = 5000;\nvar instanceCaches = new WeakMap();\nvar getCache = function (instance) {\n var cache = instanceCaches.get(instance);\n if (!cache) {\n cache = { misses: new Map(), lastSweptAt: Date.now() };\n instanceCaches.set(instance, cache);\n }\n return cache;\n};\n// Entries are only ever added by the decorated method, so sweeping on call covers every growth path\n// without a timer that would pin the instance and defeat the WeakMap. An entry recorded just after a\n// sweep survives until the sweep after next, so worst-case lifetime is ~2x ttlMs.\nvar sweep = function (cache, ttlMs, now) {\n if (now - cache.lastSweptAt < ttlMs) {\n return;\n }\n var expired = [];\n cache.misses.forEach(function (missedAt, id) {\n if (now - missedAt >= ttlMs) {\n expired.push(id);\n }\n });\n expired.forEach(function (id) { return cache.misses.delete(id); });\n cache.lastSweptAt = now;\n};\n// A burst of distinct misses inside one ttl window has nothing to sweep - drop oldest first.\n// Map keeps insertion order and entries are inserted at miss time, so the front is the oldest.\n// Runs AFTER recording, so a single call that overshoots the cap is trimmed by that same call.\nvar enforceCap = function (cache, maxSize) {\n if (cache.misses.size <= maxSize) {\n return;\n }\n var overflow = cache.misses.size - maxSize;\n var oldestFirst = cache.misses.keys();\n for (var i = 0; i < overflow; i++) {\n cache.misses.delete(oldestFirst.next().value);\n }\n};\n/**\n * Suppresses ids the server repeatedly fails to return.\n *\n * Decorates a `loadMany(ids, options?)` method: ids the previous response omitted are dropped from the\n * next request until `ttlMs` elapses, so an id the backend cannot return (soft-deleted, scoped to another\n * team, external, other company) is requested once per TTL instead of on every call.\n *\n * TODO(TS 5.x): written as a legacy decorator (`experimentalDecorators`, TS 4.9 here - standard Stage 3\n * decorators need TS 5.0+). Upgrade when the repo moves to TS 5.x: a Stage 3 method decorator takes\n * `(originalMethod, context)` and returns the replacement function, so the `PropertyDescriptor`\n * plumbing below goes away. `./cached-promise.ts` needs the same treatment at that point.\n */\nfunction withNegativeCache(_a) {\n var ttlMs = _a.ttlMs, hasItem = _a.hasItem, _b = _a.maxSize, maxSize = _b === void 0 ? exports.DEFAULT_NEGATIVE_CACHE_MAX_SIZE : _b;\n return function (target, propertyName, propertyDescriptor) {\n var method = propertyDescriptor.value;\n propertyDescriptor.value = function (ids, options) {\n return __awaiter(this, void 0, void 0, function () {\n var instanceCache, cache, idsToLoad, items, returnedIds, now;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n // Nothing to load, and no instance to key the per-instance cache on when the method was\n // detached from it (`const { loadMany } = api`).\n if (!this || !(ids === null || ids === void 0 ? void 0 : ids.length)) {\n return [2 /*return*/, method.call(this, ids, options)];\n }\n instanceCache = getCache(this);\n cache = instanceCache.misses;\n sweep(instanceCache, ttlMs, Date.now());\n if ((options === null || options === void 0 ? void 0 : options.useCache) === false) {\n ids.forEach(function (id) { return cache.delete(id); });\n }\n idsToLoad = ids.filter(function (id) {\n var missedAt = cache.get(id);\n if (missedAt === undefined) {\n return true;\n }\n // Expired, or the item showed up by another route - either way it is requestable again.\n if (Date.now() - missedAt >= ttlMs || hasItem(_this, id)) {\n cache.delete(id);\n return true;\n }\n return false;\n });\n if (!idsToLoad.length) {\n return [2 /*return*/, []];\n }\n return [4 /*yield*/, method.call(this, idsToLoad, options)];\n case 1:\n items = _a.sent();\n returnedIds = new Set(items.map(function (item) { return item.id; }));\n now = Date.now();\n idsToLoad.forEach(function (id) { return (returnedIds.has(id) ? cache.delete(id) : cache.set(id, now)); });\n enforceCap(instanceCache, maxSize);\n return [2 /*return*/, items];\n }\n });\n });\n };\n return propertyDescriptor;\n };\n}\nexports[\"default\"] = withNegativeCache;\n//# sourceMappingURL=negative-cache.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/utils/decorators/negative-cache.js?");
|
|
3860
|
+
|
|
3861
|
+
/***/ }),
|
|
3862
|
+
|
|
3852
3863
|
/***/ "./dist/utils/promises.js":
|
|
3853
3864
|
/*!********************************!*\
|
|
3854
3865
|
!*** ./dist/utils/promises.js ***!
|