b2m-utils 0.0.113 → 0.0.115

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.
@@ -0,0 +1,2 @@
1
+ import { DomainSlaContract, SlaFreight } from "../../types";
2
+ export declare const getContractFromFreight: (contracts: DomainSlaContract[], freight: SlaFreight) => DomainSlaContract | undefined;
@@ -0,0 +1,2 @@
1
+ import { DomainSlaContract, SlaFreight } from "../../types";
2
+ export declare const getContractRouteFromFreight: (contracts: DomainSlaContract[], freight: SlaFreight) => false | import("../../types").DomainSlaRoute;
@@ -1,3 +1,5 @@
1
+ export * from './getContractFromFreight';
2
+ export * from './getContractRouteFromFreight';
1
3
  export * from './formatDateString';
2
4
  export * from './getConfigurationFromDomain';
3
5
  export * from './getCookies';
@@ -1,256 +1,3 @@
1
- var formatDateString = function (dateString, staticTime) {
2
- if (staticTime === void 0) { staticTime = false; }
3
- if (dateString.includes('.000Z')) {
4
- var firstSplit = dateString === null || dateString === void 0 ? void 0 : dateString.split('.000Z')[0];
5
- var secondSplit = firstSplit === null || firstSplit === void 0 ? void 0 : firstSplit.split('T');
6
- if (secondSplit === null || secondSplit === void 0 ? void 0 : secondSplit.length) {
7
- if (staticTime) {
8
- return "".concat(secondSplit[0], " 12:00:00");
9
- }
10
- else {
11
- return "".concat(secondSplit[0], " ").concat(secondSplit[1]);
12
- }
13
- }
14
- }
15
- else if (dateString.includes(' ')) {
16
- if (staticTime) {
17
- return "".concat(dateString.split(' ')[0], " 12:00:00");
18
- }
19
- else {
20
- return dateString;
21
- }
22
- }
23
- return '';
24
- };
25
-
26
- function getConfigurationFromDomain(domainConfigurations, configurationName) {
27
- return domainConfigurations.find(function (i) { return i.name === configurationName; });
28
- }
29
-
30
- var getCookies = function (cookies) {
31
- if (cookies) {
32
- var data_1 = {};
33
- cookies
34
- .split(';')
35
- .map(function (item) { return item.trim().split('='); })
36
- .forEach(function (item) { return (data_1[item[0]] = item[1]); });
37
- return data_1;
38
- }
39
- else {
40
- return {};
41
- }
42
- };
43
-
44
- function getDataFromToken(token) {
45
- var jwtDataBase64 = token.split('.')[1];
46
- var data = JSON.parse(Buffer.from(jwtDataBase64, 'base64').toString());
47
- if (data.exp * 1000 < Date.now()) {
48
- throw new Error('Token expirado.');
49
- }
50
- return data;
51
- }
52
-
53
- var ApplicationColumnNameEnum;
54
- (function (ApplicationColumnNameEnum) {
55
- ApplicationColumnNameEnum["DEPARTURE_AT"] = "departureAt";
56
- ApplicationColumnNameEnum["ARRIVAL_AT"] = "arrivalAt";
57
- ApplicationColumnNameEnum["CLEARANCE_AT"] = "clearanceAt";
58
- ApplicationColumnNameEnum["DELIVERY_AT"] = "deliveryAt";
59
- ApplicationColumnNameEnum["CREATED_AT"] = "createdAt";
60
- })(ApplicationColumnNameEnum || (ApplicationColumnNameEnum = {}));
61
-
62
- var ApplicationEnum;
63
- (function (ApplicationEnum) {
64
- ApplicationEnum[ApplicationEnum["B2M_CORE"] = 1] = "B2M_CORE";
65
- ApplicationEnum[ApplicationEnum["TMS"] = 2] = "TMS";
66
- ApplicationEnum[ApplicationEnum["SPOT"] = 3] = "SPOT";
67
- ApplicationEnum[ApplicationEnum["TRACK_PROCESSES"] = 4] = "TRACK_PROCESSES";
68
- ApplicationEnum[ApplicationEnum["RATECARD_MANAGEMENT"] = 5] = "RATECARD_MANAGEMENT";
69
- ApplicationEnum[ApplicationEnum["SLA"] = 6] = "SLA";
70
- ApplicationEnum[ApplicationEnum["AUDIT"] = 7] = "AUDIT";
71
- })(ApplicationEnum || (ApplicationEnum = {}));
72
-
73
- var CountryEnum;
74
- (function (CountryEnum) {
75
- CountryEnum[CountryEnum["BRAZIL"] = 1] = "BRAZIL";
76
- })(CountryEnum || (CountryEnum = {}));
77
-
78
- var CurrencyEnum;
79
- (function (CurrencyEnum) {
80
- CurrencyEnum[CurrencyEnum["REAL"] = 1] = "REAL";
81
- CurrencyEnum[CurrencyEnum["DOLAR"] = 2] = "DOLAR";
82
- CurrencyEnum[CurrencyEnum["EURO"] = 3] = "EURO";
83
- CurrencyEnum[CurrencyEnum["IENE"] = 4] = "IENE";
84
- })(CurrencyEnum || (CurrencyEnum = {}));
85
-
86
- var DomainConfigurationEnum;
87
- (function (DomainConfigurationEnum) {
88
- DomainConfigurationEnum["CLEARANCE_DAYS"] = "CLEARANCE_DAYS";
89
- DomainConfigurationEnum["CARGO_REMOVAL_DAYS"] = "CARGO_REMOVAL_DAYS";
90
- DomainConfigurationEnum["DELIVERY_DAYS"] = "DELIVERY_DAYS";
91
- DomainConfigurationEnum["DEMURRAGE_EXPIRY_NOTIFICATION_DAYS"] = "DEMURRAGE_EXPIRY_NOTIFICATION_DAYS";
92
- DomainConfigurationEnum["INVOICE_EXPIRY_NOTIFICATION_DAYS"] = "INVOICE_EXPIRY_NOTIFICATION_DAYS";
93
- })(DomainConfigurationEnum || (DomainConfigurationEnum = {}));
94
-
95
- var DomainTypeEnum;
96
- (function (DomainTypeEnum) {
97
- DomainTypeEnum[DomainTypeEnum["TMS"] = 1] = "TMS";
98
- DomainTypeEnum[DomainTypeEnum["SPOT"] = 2] = "SPOT";
99
- DomainTypeEnum[DomainTypeEnum["PROVIDER"] = 3] = "PROVIDER";
100
- DomainTypeEnum[DomainTypeEnum["FREIGHT_FORWARDER"] = 4] = "FREIGHT_FORWARDER";
101
- DomainTypeEnum[DomainTypeEnum["DISPATCHER"] = 5] = "DISPATCHER";
102
- DomainTypeEnum[DomainTypeEnum["B2M_CLIENT"] = 6] = "B2M_CLIENT";
103
- })(DomainTypeEnum || (DomainTypeEnum = {}));
104
-
105
- var FeeCalculationTypeEnum;
106
- (function (FeeCalculationTypeEnum) {
107
- FeeCalculationTypeEnum[FeeCalculationTypeEnum["FIXED"] = 1] = "FIXED";
108
- FeeCalculationTypeEnum[FeeCalculationTypeEnum["TAXED_WEIGHT"] = 2] = "TAXED_WEIGHT";
109
- FeeCalculationTypeEnum[FeeCalculationTypeEnum["INTERNATIONAL_CHARGE"] = 3] = "INTERNATIONAL_CHARGE";
110
- FeeCalculationTypeEnum[FeeCalculationTypeEnum["CONVERSION_TAX"] = 4] = "CONVERSION_TAX";
111
- FeeCalculationTypeEnum[FeeCalculationTypeEnum["CUBED_WEIGHT"] = 5] = "CUBED_WEIGHT";
112
- FeeCalculationTypeEnum[FeeCalculationTypeEnum["COMMODITY_VALUE"] = 6] = "COMMODITY_VALUE";
113
- FeeCalculationTypeEnum[FeeCalculationTypeEnum["FRACTIONED"] = 7] = "FRACTIONED";
114
- FeeCalculationTypeEnum[FeeCalculationTypeEnum["FREIGHT"] = 8] = "FREIGHT";
115
- FeeCalculationTypeEnum[FeeCalculationTypeEnum["TOTAL_PERCENTAGE"] = 9] = "TOTAL_PERCENTAGE";
116
- FeeCalculationTypeEnum[FeeCalculationTypeEnum["MIN_VALUE"] = 10] = "MIN_VALUE";
117
- FeeCalculationTypeEnum[FeeCalculationTypeEnum["SUM_CONTAINERS"] = 11] = "SUM_CONTAINERS";
118
- })(FeeCalculationTypeEnum || (FeeCalculationTypeEnum = {}));
119
-
120
- var FeeCategoryEnum;
121
- (function (FeeCategoryEnum) {
122
- FeeCategoryEnum[FeeCategoryEnum["ORIGIN"] = 1] = "ORIGIN";
123
- FeeCategoryEnum[FeeCategoryEnum["INTERNATIONAL"] = 2] = "INTERNATIONAL";
124
- FeeCategoryEnum[FeeCategoryEnum["DESTINATION"] = 3] = "DESTINATION";
125
- FeeCategoryEnum[FeeCategoryEnum["DELIVERY"] = 4] = "DELIVERY";
126
- FeeCategoryEnum[FeeCategoryEnum["ADDITIONAL"] = 5] = "ADDITIONAL";
127
- FeeCategoryEnum[FeeCategoryEnum["PICKUP"] = 6] = "PICKUP";
128
- FeeCategoryEnum[FeeCategoryEnum["FREIGHT"] = 7] = "FREIGHT";
129
- FeeCategoryEnum[FeeCategoryEnum["FEES"] = 8] = "FEES";
130
- FeeCategoryEnum[FeeCategoryEnum["TAXES"] = 9] = "TAXES";
131
- })(FeeCategoryEnum || (FeeCategoryEnum = {}));
132
-
133
- var ModalEnum;
134
- (function (ModalEnum) {
135
- ModalEnum[ModalEnum["AIR"] = 1] = "AIR";
136
- ModalEnum[ModalEnum["OCEAN_FCL"] = 2] = "OCEAN_FCL";
137
- ModalEnum[ModalEnum["OCEAN_LCL"] = 3] = "OCEAN_LCL";
138
- ModalEnum[ModalEnum["ROAD_FTL"] = 4] = "ROAD_FTL";
139
- ModalEnum[ModalEnum["ROAD_LTL"] = 5] = "ROAD_LTL";
140
- })(ModalEnum || (ModalEnum = {}));
141
-
142
- var NotificationTypeEnum;
143
- (function (NotificationTypeEnum) {
144
- NotificationTypeEnum[NotificationTypeEnum["USER_NOTIFICATION"] = 1] = "USER_NOTIFICATION";
145
- NotificationTypeEnum[NotificationTypeEnum["DOMAIN_NOTIFICATION"] = 2] = "DOMAIN_NOTIFICATION";
146
- })(NotificationTypeEnum || (NotificationTypeEnum = {}));
147
-
148
- var PermissionEnum;
149
- (function (PermissionEnum) {
150
- PermissionEnum[PermissionEnum["B2M_ADMIN"] = 1] = "B2M_ADMIN";
151
- PermissionEnum[PermissionEnum["DOMAIN_ADMIN"] = 2] = "DOMAIN_ADMIN";
152
- PermissionEnum[PermissionEnum["TMS"] = 3] = "TMS";
153
- PermissionEnum[PermissionEnum["SPOT"] = 4] = "SPOT";
154
- PermissionEnum[PermissionEnum["SPOT_PROVIDER"] = 5] = "SPOT_PROVIDER";
155
- PermissionEnum[PermissionEnum["TRACK_PROCESSES"] = 6] = "TRACK_PROCESSES";
156
- PermissionEnum[PermissionEnum["DISPATCHER"] = 7] = "DISPATCHER";
157
- PermissionEnum[PermissionEnum["RATECARD_MANAGEMENT"] = 8] = "RATECARD_MANAGEMENT";
158
- PermissionEnum[PermissionEnum["SLA"] = 9] = "SLA";
159
- })(PermissionEnum || (PermissionEnum = {}));
160
-
161
- var SpotStatusEnum;
162
- (function (SpotStatusEnum) {
163
- SpotStatusEnum[SpotStatusEnum["DRAFT"] = 1] = "DRAFT";
164
- SpotStatusEnum[SpotStatusEnum["OPEN"] = 2] = "OPEN";
165
- SpotStatusEnum[SpotStatusEnum["CLOSED"] = 3] = "CLOSED";
166
- SpotStatusEnum[SpotStatusEnum["FINISHED"] = 4] = "FINISHED";
167
- })(SpotStatusEnum || (SpotStatusEnum = {}));
168
-
169
- var TrackProcessProviderTypeEnum;
170
- (function (TrackProcessProviderTypeEnum) {
171
- TrackProcessProviderTypeEnum[TrackProcessProviderTypeEnum["FREIGHT_FORWARDER"] = 1] = "FREIGHT_FORWARDER";
172
- TrackProcessProviderTypeEnum[TrackProcessProviderTypeEnum["DISPATCHER"] = 2] = "DISPATCHER";
173
- TrackProcessProviderTypeEnum[TrackProcessProviderTypeEnum["TERMINAL"] = 3] = "TERMINAL";
174
- TrackProcessProviderTypeEnum[TrackProcessProviderTypeEnum["SHIPPING_COMPANY"] = 4] = "SHIPPING_COMPANY";
175
- TrackProcessProviderTypeEnum[TrackProcessProviderTypeEnum["OTHERS"] = 5] = "OTHERS";
176
- })(TrackProcessProviderTypeEnum || (TrackProcessProviderTypeEnum = {}));
177
-
178
- var getFormattedFreightPlaceName = function (freightPlace, modalId, complete, sqlVersion) {
179
- var _a, _b;
180
- if (complete === void 0) { complete = false; }
181
- if (sqlVersion === void 0) { sqlVersion = false; }
182
- if (sqlVersion) {
183
- var iataText = freightPlace.iata ? "(".concat(freightPlace.iata, ") ") : '';
184
- var locationText = freightPlace.location ? " ".concat(freightPlace.location) : '';
185
- var countryText = [ModalEnum.OCEAN_FCL, ModalEnum.OCEAN_LCL].includes(modalId) ? "".concat(freightPlace.freightPlaceCountryName, ", ") : '';
186
- return "".concat(iataText).concat(freightPlace.name).concat(locationText).concat(complete ? " - ".concat(countryText).concat(freightPlace.freightPlaceRegionName) : '');
187
- }
188
- else {
189
- var iataText = freightPlace.iata ? "(".concat(freightPlace.iata, ") ") : '';
190
- var locationText = freightPlace.location ? " ".concat(freightPlace.location) : '';
191
- var countryText = [ModalEnum.OCEAN_FCL, ModalEnum.OCEAN_LCL].includes(modalId) ? "".concat((_a = freightPlace.freightPlaceCountry) === null || _a === void 0 ? void 0 : _a.name, ", ") : '';
192
- return "".concat(iataText).concat(freightPlace.name).concat(locationText).concat(complete ? " - ".concat(countryText).concat((_b = freightPlace.freightPlaceRegion) === null || _b === void 0 ? void 0 : _b.name) : '');
193
- }
194
- };
195
-
196
- /******************************************************************************
197
- Copyright (c) Microsoft Corporation.
198
-
199
- Permission to use, copy, modify, and/or distribute this software for any
200
- purpose with or without fee is hereby granted.
201
-
202
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
203
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
204
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
205
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
206
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
207
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
208
- PERFORMANCE OF THIS SOFTWARE.
209
- ***************************************************************************** */
210
-
211
- function __awaiter(thisArg, _arguments, P, generator) {
212
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
213
- return new (P || (P = Promise))(function (resolve, reject) {
214
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
215
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
216
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
217
- step((generator = generator.apply(thisArg, _arguments || [])).next());
218
- });
219
- }
220
-
221
- function __generator(thisArg, body) {
222
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
223
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
224
- function verb(n) { return function (v) { return step([n, v]); }; }
225
- function step(op) {
226
- if (f) throw new TypeError("Generator is already executing.");
227
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
228
- 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;
229
- if (y = 0, t) op = [op[0] & 2, t.value];
230
- switch (op[0]) {
231
- case 0: case 1: t = op; break;
232
- case 4: _.label++; return { value: op[1], done: false };
233
- case 5: _.label++; y = op[1]; op = [0]; continue;
234
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
235
- default:
236
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
237
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
238
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
239
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
240
- if (t[2]) _.ops.pop();
241
- _.trys.pop(); continue;
242
- }
243
- op = body.call(thisArg, _);
244
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
245
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
246
- }
247
- }
248
-
249
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
250
- var e = new Error(message);
251
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
252
- };
253
-
254
1
  /**
255
2
  * @name toDate
256
3
  * @category Common Helpers
@@ -6156,6 +5903,355 @@ const ptBR = {
6156
5903
  },
6157
5904
  };
6158
5905
 
5906
+ var formatDateString = function (dateString, staticTime) {
5907
+ if (staticTime === void 0) { staticTime = false; }
5908
+ if (dateString.includes('.000Z')) {
5909
+ var firstSplit = dateString === null || dateString === void 0 ? void 0 : dateString.split('.000Z')[0];
5910
+ var secondSplit = firstSplit === null || firstSplit === void 0 ? void 0 : firstSplit.split('T');
5911
+ if (secondSplit === null || secondSplit === void 0 ? void 0 : secondSplit.length) {
5912
+ if (staticTime) {
5913
+ return "".concat(secondSplit[0], " 12:00:00");
5914
+ }
5915
+ else {
5916
+ return "".concat(secondSplit[0], " ").concat(secondSplit[1]);
5917
+ }
5918
+ }
5919
+ }
5920
+ else if (dateString.includes(' ')) {
5921
+ if (staticTime) {
5922
+ return "".concat(dateString.split(' ')[0], " 12:00:00");
5923
+ }
5924
+ else {
5925
+ return dateString;
5926
+ }
5927
+ }
5928
+ return '';
5929
+ };
5930
+
5931
+ var getContractFromFreight = function (contracts, freight) {
5932
+ return contracts.find(function (item) {
5933
+ if (item.shippingCompanyId === freight.shippingCompanyId) {
5934
+ var formattedCteAt = format(parse(formatDateString(freight.cteAt), "yyyy-MM-dd HH:mm:ss", new Date()), "yyyy-MM-dd", {
5935
+ locale: ptBR,
5936
+ });
5937
+ var formattedStartsAt = format(parse(formatDateString(item.startsAt), "yyyy-MM-dd HH:mm:ss", new Date()), "yyyy-MM-dd", {
5938
+ locale: ptBR,
5939
+ });
5940
+ var formattedEndsAt = format(parse(formatDateString(item.endsAt), "yyyy-MM-dd HH:mm:ss", new Date()), "yyyy-MM-dd", {
5941
+ locale: ptBR,
5942
+ });
5943
+ if (formattedCteAt >= formattedStartsAt && formattedCteAt <= formattedEndsAt) {
5944
+ return true;
5945
+ }
5946
+ }
5947
+ return false;
5948
+ });
5949
+ };
5950
+
5951
+ var getContractRouteFromFreight = function (contracts, freight) {
5952
+ var _a;
5953
+ var contract = getContractFromFreight(contracts, freight);
5954
+ if (contract) {
5955
+ var routesToStateDestination = (_a = contract.DomainSlaRoute) === null || _a === void 0 ? void 0 : _a.filter(function (it) { var _a; return it.stateDestinationId === ((_a = freight.cityDestination) === null || _a === void 0 ? void 0 : _a.state.id); });
5956
+ console.log({
5957
+ routesToStateDestination: routesToStateDestination,
5958
+ });
5959
+ if (routesToStateDestination === null || routesToStateDestination === void 0 ? void 0 : routesToStateDestination.length) {
5960
+ var routesToCityDestination = routesToStateDestination.filter(function (it) { return it.cityDestinationId === freight.cityDestinationId; });
5961
+ if (routesToCityDestination === null || routesToCityDestination === void 0 ? void 0 : routesToCityDestination.length) {
5962
+ console.log({
5963
+ routesToCityDestination: routesToCityDestination,
5964
+ });
5965
+ var routeFromCityOriginAndToCityDestination = routesToCityDestination.find(function (it) { return it.cityOriginId === freight.cityOriginId; });
5966
+ if (routeFromCityOriginAndToCityDestination) {
5967
+ console.log({
5968
+ routeFromCityOriginAndToCityDestination: routeFromCityOriginAndToCityDestination,
5969
+ });
5970
+ return routeFromCityOriginAndToCityDestination;
5971
+ }
5972
+ else {
5973
+ var routeFromStateOriginWithoutCity = routesToCityDestination.find(function (it) { var _a, _b; return it.stateOriginId === ((_b = (_a = freight.cityOrigin) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.id) && it.cityOriginId === null; });
5974
+ if (routeFromStateOriginWithoutCity) {
5975
+ console.log({
5976
+ routeFromStateOriginWithoutCity: routeFromStateOriginWithoutCity,
5977
+ });
5978
+ return routeFromStateOriginWithoutCity;
5979
+ }
5980
+ else {
5981
+ var routeWithoutCityAndStateOrigin = routesToCityDestination.find(function (it) { return it.stateOriginId === null && it.cityOriginId === null; });
5982
+ if (routeWithoutCityAndStateOrigin) {
5983
+ console.log({
5984
+ routeWithoutCityAndStateOrigin: routeWithoutCityAndStateOrigin,
5985
+ });
5986
+ return routeWithoutCityAndStateOrigin;
5987
+ }
5988
+ }
5989
+ }
5990
+ }
5991
+ else {
5992
+ var routesWithoutCityDestination = routesToStateDestination.filter(function (it) { return it.cityDestinationId === null; });
5993
+ var routesFromStateOrigin = routesWithoutCityDestination.filter(function (it) { var _a, _b; return it.stateOriginId === ((_b = (_a = freight.cityOrigin) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.id); });
5994
+ if (routesFromStateOrigin === null || routesFromStateOrigin === void 0 ? void 0 : routesFromStateOrigin.length) {
5995
+ var routeFromCityOrigin = routesFromStateOrigin.find(function (it) { return it.cityOriginId === freight.cityOriginId; });
5996
+ if (routeFromCityOrigin) {
5997
+ console.log({
5998
+ routeFromCityOrigin: routeFromCityOrigin,
5999
+ });
6000
+ return routeFromCityOrigin;
6001
+ }
6002
+ else {
6003
+ var routeFromStateOrigin = routesFromStateOrigin.find(function (it) { var _a, _b; return it.stateOriginId === ((_b = (_a = freight.cityOrigin) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.id) && it.cityOriginId === null; });
6004
+ if (routeFromStateOrigin) {
6005
+ console.log({
6006
+ routeFromStateOrigin: routeFromStateOrigin
6007
+ });
6008
+ return routeFromStateOrigin;
6009
+ }
6010
+ }
6011
+ }
6012
+ else {
6013
+ var routeFromStateDestination = routesToStateDestination.find(function (it) { var _a, _b; return it.stateDestinationId === ((_b = (_a = freight.cityDestination) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.id) && it.cityDestinationId === null && it.cityOriginId === null && it.stateOriginId === null; });
6014
+ if (routeFromStateDestination) {
6015
+ console.log({
6016
+ routeFromStateDestination: routeFromStateDestination,
6017
+ });
6018
+ return routeFromStateDestination;
6019
+ }
6020
+ }
6021
+ }
6022
+ }
6023
+ }
6024
+ return false;
6025
+ };
6026
+
6027
+ function getConfigurationFromDomain(domainConfigurations, configurationName) {
6028
+ return domainConfigurations.find(function (i) { return i.name === configurationName; });
6029
+ }
6030
+
6031
+ var getCookies = function (cookies) {
6032
+ if (cookies) {
6033
+ var data_1 = {};
6034
+ cookies
6035
+ .split(';')
6036
+ .map(function (item) { return item.trim().split('='); })
6037
+ .forEach(function (item) { return (data_1[item[0]] = item[1]); });
6038
+ return data_1;
6039
+ }
6040
+ else {
6041
+ return {};
6042
+ }
6043
+ };
6044
+
6045
+ function getDataFromToken(token) {
6046
+ var jwtDataBase64 = token.split('.')[1];
6047
+ var data = JSON.parse(Buffer.from(jwtDataBase64, 'base64').toString());
6048
+ if (data.exp * 1000 < Date.now()) {
6049
+ throw new Error('Token expirado.');
6050
+ }
6051
+ return data;
6052
+ }
6053
+
6054
+ var ApplicationColumnNameEnum;
6055
+ (function (ApplicationColumnNameEnum) {
6056
+ ApplicationColumnNameEnum["DEPARTURE_AT"] = "departureAt";
6057
+ ApplicationColumnNameEnum["ARRIVAL_AT"] = "arrivalAt";
6058
+ ApplicationColumnNameEnum["CLEARANCE_AT"] = "clearanceAt";
6059
+ ApplicationColumnNameEnum["DELIVERY_AT"] = "deliveryAt";
6060
+ ApplicationColumnNameEnum["CREATED_AT"] = "createdAt";
6061
+ })(ApplicationColumnNameEnum || (ApplicationColumnNameEnum = {}));
6062
+
6063
+ var ApplicationEnum;
6064
+ (function (ApplicationEnum) {
6065
+ ApplicationEnum[ApplicationEnum["B2M_CORE"] = 1] = "B2M_CORE";
6066
+ ApplicationEnum[ApplicationEnum["TMS"] = 2] = "TMS";
6067
+ ApplicationEnum[ApplicationEnum["SPOT"] = 3] = "SPOT";
6068
+ ApplicationEnum[ApplicationEnum["TRACK_PROCESSES"] = 4] = "TRACK_PROCESSES";
6069
+ ApplicationEnum[ApplicationEnum["RATECARD_MANAGEMENT"] = 5] = "RATECARD_MANAGEMENT";
6070
+ ApplicationEnum[ApplicationEnum["SLA"] = 6] = "SLA";
6071
+ ApplicationEnum[ApplicationEnum["AUDIT"] = 7] = "AUDIT";
6072
+ })(ApplicationEnum || (ApplicationEnum = {}));
6073
+
6074
+ var CountryEnum;
6075
+ (function (CountryEnum) {
6076
+ CountryEnum[CountryEnum["BRAZIL"] = 1] = "BRAZIL";
6077
+ })(CountryEnum || (CountryEnum = {}));
6078
+
6079
+ var CurrencyEnum;
6080
+ (function (CurrencyEnum) {
6081
+ CurrencyEnum[CurrencyEnum["REAL"] = 1] = "REAL";
6082
+ CurrencyEnum[CurrencyEnum["DOLAR"] = 2] = "DOLAR";
6083
+ CurrencyEnum[CurrencyEnum["EURO"] = 3] = "EURO";
6084
+ CurrencyEnum[CurrencyEnum["IENE"] = 4] = "IENE";
6085
+ })(CurrencyEnum || (CurrencyEnum = {}));
6086
+
6087
+ var DomainConfigurationEnum;
6088
+ (function (DomainConfigurationEnum) {
6089
+ DomainConfigurationEnum["CLEARANCE_DAYS"] = "CLEARANCE_DAYS";
6090
+ DomainConfigurationEnum["CARGO_REMOVAL_DAYS"] = "CARGO_REMOVAL_DAYS";
6091
+ DomainConfigurationEnum["DELIVERY_DAYS"] = "DELIVERY_DAYS";
6092
+ DomainConfigurationEnum["DEMURRAGE_EXPIRY_NOTIFICATION_DAYS"] = "DEMURRAGE_EXPIRY_NOTIFICATION_DAYS";
6093
+ DomainConfigurationEnum["INVOICE_EXPIRY_NOTIFICATION_DAYS"] = "INVOICE_EXPIRY_NOTIFICATION_DAYS";
6094
+ })(DomainConfigurationEnum || (DomainConfigurationEnum = {}));
6095
+
6096
+ var DomainTypeEnum;
6097
+ (function (DomainTypeEnum) {
6098
+ DomainTypeEnum[DomainTypeEnum["TMS"] = 1] = "TMS";
6099
+ DomainTypeEnum[DomainTypeEnum["SPOT"] = 2] = "SPOT";
6100
+ DomainTypeEnum[DomainTypeEnum["PROVIDER"] = 3] = "PROVIDER";
6101
+ DomainTypeEnum[DomainTypeEnum["FREIGHT_FORWARDER"] = 4] = "FREIGHT_FORWARDER";
6102
+ DomainTypeEnum[DomainTypeEnum["DISPATCHER"] = 5] = "DISPATCHER";
6103
+ DomainTypeEnum[DomainTypeEnum["B2M_CLIENT"] = 6] = "B2M_CLIENT";
6104
+ })(DomainTypeEnum || (DomainTypeEnum = {}));
6105
+
6106
+ var FeeCalculationTypeEnum;
6107
+ (function (FeeCalculationTypeEnum) {
6108
+ FeeCalculationTypeEnum[FeeCalculationTypeEnum["FIXED"] = 1] = "FIXED";
6109
+ FeeCalculationTypeEnum[FeeCalculationTypeEnum["TAXED_WEIGHT"] = 2] = "TAXED_WEIGHT";
6110
+ FeeCalculationTypeEnum[FeeCalculationTypeEnum["INTERNATIONAL_CHARGE"] = 3] = "INTERNATIONAL_CHARGE";
6111
+ FeeCalculationTypeEnum[FeeCalculationTypeEnum["CONVERSION_TAX"] = 4] = "CONVERSION_TAX";
6112
+ FeeCalculationTypeEnum[FeeCalculationTypeEnum["CUBED_WEIGHT"] = 5] = "CUBED_WEIGHT";
6113
+ FeeCalculationTypeEnum[FeeCalculationTypeEnum["COMMODITY_VALUE"] = 6] = "COMMODITY_VALUE";
6114
+ FeeCalculationTypeEnum[FeeCalculationTypeEnum["FRACTIONED"] = 7] = "FRACTIONED";
6115
+ FeeCalculationTypeEnum[FeeCalculationTypeEnum["FREIGHT"] = 8] = "FREIGHT";
6116
+ FeeCalculationTypeEnum[FeeCalculationTypeEnum["TOTAL_PERCENTAGE"] = 9] = "TOTAL_PERCENTAGE";
6117
+ FeeCalculationTypeEnum[FeeCalculationTypeEnum["MIN_VALUE"] = 10] = "MIN_VALUE";
6118
+ FeeCalculationTypeEnum[FeeCalculationTypeEnum["SUM_CONTAINERS"] = 11] = "SUM_CONTAINERS";
6119
+ })(FeeCalculationTypeEnum || (FeeCalculationTypeEnum = {}));
6120
+
6121
+ var FeeCategoryEnum;
6122
+ (function (FeeCategoryEnum) {
6123
+ FeeCategoryEnum[FeeCategoryEnum["ORIGIN"] = 1] = "ORIGIN";
6124
+ FeeCategoryEnum[FeeCategoryEnum["INTERNATIONAL"] = 2] = "INTERNATIONAL";
6125
+ FeeCategoryEnum[FeeCategoryEnum["DESTINATION"] = 3] = "DESTINATION";
6126
+ FeeCategoryEnum[FeeCategoryEnum["DELIVERY"] = 4] = "DELIVERY";
6127
+ FeeCategoryEnum[FeeCategoryEnum["ADDITIONAL"] = 5] = "ADDITIONAL";
6128
+ FeeCategoryEnum[FeeCategoryEnum["PICKUP"] = 6] = "PICKUP";
6129
+ FeeCategoryEnum[FeeCategoryEnum["FREIGHT"] = 7] = "FREIGHT";
6130
+ FeeCategoryEnum[FeeCategoryEnum["FEES"] = 8] = "FEES";
6131
+ FeeCategoryEnum[FeeCategoryEnum["TAXES"] = 9] = "TAXES";
6132
+ })(FeeCategoryEnum || (FeeCategoryEnum = {}));
6133
+
6134
+ var ModalEnum;
6135
+ (function (ModalEnum) {
6136
+ ModalEnum[ModalEnum["AIR"] = 1] = "AIR";
6137
+ ModalEnum[ModalEnum["OCEAN_FCL"] = 2] = "OCEAN_FCL";
6138
+ ModalEnum[ModalEnum["OCEAN_LCL"] = 3] = "OCEAN_LCL";
6139
+ ModalEnum[ModalEnum["ROAD_FTL"] = 4] = "ROAD_FTL";
6140
+ ModalEnum[ModalEnum["ROAD_LTL"] = 5] = "ROAD_LTL";
6141
+ })(ModalEnum || (ModalEnum = {}));
6142
+
6143
+ var NotificationTypeEnum;
6144
+ (function (NotificationTypeEnum) {
6145
+ NotificationTypeEnum[NotificationTypeEnum["USER_NOTIFICATION"] = 1] = "USER_NOTIFICATION";
6146
+ NotificationTypeEnum[NotificationTypeEnum["DOMAIN_NOTIFICATION"] = 2] = "DOMAIN_NOTIFICATION";
6147
+ })(NotificationTypeEnum || (NotificationTypeEnum = {}));
6148
+
6149
+ var PermissionEnum;
6150
+ (function (PermissionEnum) {
6151
+ PermissionEnum[PermissionEnum["B2M_ADMIN"] = 1] = "B2M_ADMIN";
6152
+ PermissionEnum[PermissionEnum["DOMAIN_ADMIN"] = 2] = "DOMAIN_ADMIN";
6153
+ PermissionEnum[PermissionEnum["TMS"] = 3] = "TMS";
6154
+ PermissionEnum[PermissionEnum["SPOT"] = 4] = "SPOT";
6155
+ PermissionEnum[PermissionEnum["SPOT_PROVIDER"] = 5] = "SPOT_PROVIDER";
6156
+ PermissionEnum[PermissionEnum["TRACK_PROCESSES"] = 6] = "TRACK_PROCESSES";
6157
+ PermissionEnum[PermissionEnum["DISPATCHER"] = 7] = "DISPATCHER";
6158
+ PermissionEnum[PermissionEnum["RATECARD_MANAGEMENT"] = 8] = "RATECARD_MANAGEMENT";
6159
+ PermissionEnum[PermissionEnum["SLA"] = 9] = "SLA";
6160
+ })(PermissionEnum || (PermissionEnum = {}));
6161
+
6162
+ var SpotStatusEnum;
6163
+ (function (SpotStatusEnum) {
6164
+ SpotStatusEnum[SpotStatusEnum["DRAFT"] = 1] = "DRAFT";
6165
+ SpotStatusEnum[SpotStatusEnum["OPEN"] = 2] = "OPEN";
6166
+ SpotStatusEnum[SpotStatusEnum["CLOSED"] = 3] = "CLOSED";
6167
+ SpotStatusEnum[SpotStatusEnum["FINISHED"] = 4] = "FINISHED";
6168
+ })(SpotStatusEnum || (SpotStatusEnum = {}));
6169
+
6170
+ var TrackProcessProviderTypeEnum;
6171
+ (function (TrackProcessProviderTypeEnum) {
6172
+ TrackProcessProviderTypeEnum[TrackProcessProviderTypeEnum["FREIGHT_FORWARDER"] = 1] = "FREIGHT_FORWARDER";
6173
+ TrackProcessProviderTypeEnum[TrackProcessProviderTypeEnum["DISPATCHER"] = 2] = "DISPATCHER";
6174
+ TrackProcessProviderTypeEnum[TrackProcessProviderTypeEnum["TERMINAL"] = 3] = "TERMINAL";
6175
+ TrackProcessProviderTypeEnum[TrackProcessProviderTypeEnum["SHIPPING_COMPANY"] = 4] = "SHIPPING_COMPANY";
6176
+ TrackProcessProviderTypeEnum[TrackProcessProviderTypeEnum["OTHERS"] = 5] = "OTHERS";
6177
+ })(TrackProcessProviderTypeEnum || (TrackProcessProviderTypeEnum = {}));
6178
+
6179
+ var getFormattedFreightPlaceName = function (freightPlace, modalId, complete, sqlVersion) {
6180
+ var _a, _b;
6181
+ if (complete === void 0) { complete = false; }
6182
+ if (sqlVersion === void 0) { sqlVersion = false; }
6183
+ if (sqlVersion) {
6184
+ var iataText = freightPlace.iata ? "(".concat(freightPlace.iata, ") ") : '';
6185
+ var locationText = freightPlace.location ? " ".concat(freightPlace.location) : '';
6186
+ var countryText = [ModalEnum.OCEAN_FCL, ModalEnum.OCEAN_LCL].includes(modalId) ? "".concat(freightPlace.freightPlaceCountryName, ", ") : '';
6187
+ return "".concat(iataText).concat(freightPlace.name).concat(locationText).concat(complete ? " - ".concat(countryText).concat(freightPlace.freightPlaceRegionName) : '');
6188
+ }
6189
+ else {
6190
+ var iataText = freightPlace.iata ? "(".concat(freightPlace.iata, ") ") : '';
6191
+ var locationText = freightPlace.location ? " ".concat(freightPlace.location) : '';
6192
+ var countryText = [ModalEnum.OCEAN_FCL, ModalEnum.OCEAN_LCL].includes(modalId) ? "".concat((_a = freightPlace.freightPlaceCountry) === null || _a === void 0 ? void 0 : _a.name, ", ") : '';
6193
+ return "".concat(iataText).concat(freightPlace.name).concat(locationText).concat(complete ? " - ".concat(countryText).concat((_b = freightPlace.freightPlaceRegion) === null || _b === void 0 ? void 0 : _b.name) : '');
6194
+ }
6195
+ };
6196
+
6197
+ /******************************************************************************
6198
+ Copyright (c) Microsoft Corporation.
6199
+
6200
+ Permission to use, copy, modify, and/or distribute this software for any
6201
+ purpose with or without fee is hereby granted.
6202
+
6203
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
6204
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
6205
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
6206
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
6207
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
6208
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
6209
+ PERFORMANCE OF THIS SOFTWARE.
6210
+ ***************************************************************************** */
6211
+
6212
+ function __awaiter(thisArg, _arguments, P, generator) {
6213
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6214
+ return new (P || (P = Promise))(function (resolve, reject) {
6215
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6216
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6217
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6218
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
6219
+ });
6220
+ }
6221
+
6222
+ function __generator(thisArg, body) {
6223
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6224
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6225
+ function verb(n) { return function (v) { return step([n, v]); }; }
6226
+ function step(op) {
6227
+ if (f) throw new TypeError("Generator is already executing.");
6228
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
6229
+ 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;
6230
+ if (y = 0, t) op = [op[0] & 2, t.value];
6231
+ switch (op[0]) {
6232
+ case 0: case 1: t = op; break;
6233
+ case 4: _.label++; return { value: op[1], done: false };
6234
+ case 5: _.label++; y = op[1]; op = [0]; continue;
6235
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
6236
+ default:
6237
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6238
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6239
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6240
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6241
+ if (t[2]) _.ops.pop();
6242
+ _.trys.pop(); continue;
6243
+ }
6244
+ op = body.call(thisArg, _);
6245
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6246
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6247
+ }
6248
+ }
6249
+
6250
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
6251
+ var e = new Error(message);
6252
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
6253
+ };
6254
+
6159
6255
  var setFormattedDatesInObjects = function (objectFormat) { return __awaiter(void 0, void 0, void 0, function () {
6160
6256
  var _a, _b, _c, _i, key, formattedDate, _d, _e, _f, _g;
6161
6257
  return __generator(this, function (_h) {
@@ -6216,5 +6312,5 @@ var setFormattedDatesInObjects = function (objectFormat) { return __awaiter(void
6216
6312
  });
6217
6313
  }); };
6218
6314
 
6219
- export { ApplicationColumnNameEnum, ApplicationEnum, CountryEnum, CurrencyEnum, DomainConfigurationEnum, DomainTypeEnum, FeeCalculationTypeEnum, FeeCategoryEnum, ModalEnum, NotificationTypeEnum, PermissionEnum, SpotStatusEnum, TrackProcessProviderTypeEnum, formatDateString, getConfigurationFromDomain, getCookies, getDataFromToken, getFormattedFreightPlaceName, setFormattedDatesInObjects };
6315
+ export { ApplicationColumnNameEnum, ApplicationEnum, CountryEnum, CurrencyEnum, DomainConfigurationEnum, DomainTypeEnum, FeeCalculationTypeEnum, FeeCategoryEnum, ModalEnum, NotificationTypeEnum, PermissionEnum, SpotStatusEnum, TrackProcessProviderTypeEnum, formatDateString, getConfigurationFromDomain, getContractFromFreight, getContractRouteFromFreight, getCookies, getDataFromToken, getFormattedFreightPlaceName, setFormattedDatesInObjects };
6220
6316
  //# sourceMappingURL=index.esm.js.map
Binary file