sgerp-frontend-lib 0.1.3 → 0.1.5
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/constants/timezones.d.ts +23 -0
- package/dist/constants/timezones.d.ts.map +1 -0
- package/dist/constants/timezones.js +107 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/locales/locale-server.d.ts +1 -1
- package/dist/locales/locale-server.d.ts.map +1 -1
- package/dist/locales/locale-server.js +5 -0
- package/dist/locales/locale.d.ts +1 -1
- package/dist/locales/locale.d.ts.map +1 -1
- package/dist/locales/locale.js +6 -2
- package/dist/locales/locale_en.d.ts.map +1 -1
- package/dist/locales/locale_en.js +77 -1
- package/dist/locales/locale_id.d.ts +2 -0
- package/dist/locales/locale_id.d.ts.map +1 -0
- package/dist/locales/locale_id.js +2473 -0
- package/dist/locales/locale_ja.d.ts.map +1 -1
- package/dist/locales/locale_ja.js +76 -1
- package/dist/locales/locale_ms.d.ts.map +1 -1
- package/dist/locales/locale_ms.js +60 -1
- package/dist/locales/locale_tl.d.ts +2 -0
- package/dist/locales/locale_tl.d.ts.map +1 -0
- package/dist/locales/locale_tl.js +1122 -0
- package/dist/markdown.d.ts +33 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +117 -0
- package/dist/sgerp/collection.d.ts.map +1 -1
- package/dist/sgerp/collection.js +18 -4
- package/dist/sgerp/domains.d.ts +16 -2
- package/dist/sgerp/domains.d.ts.map +1 -1
- package/dist/sgerp/domains.js +47 -1
- package/dist/sgerp/hooks/use-selection-state.d.ts +37 -0
- package/dist/sgerp/hooks/use-selection-state.d.ts.map +1 -0
- package/dist/sgerp/hooks/use-selection-state.js +121 -0
- package/dist/sgerp/hooks/use-simulation-data.d.ts +105 -0
- package/dist/sgerp/hooks/use-simulation-data.d.ts.map +1 -0
- package/dist/sgerp/hooks/use-simulation-data.js +146 -0
- package/dist/sgerp/hooks/use-simulation-state.d.ts +80 -0
- package/dist/sgerp/hooks/use-simulation-state.d.ts.map +1 -0
- package/dist/sgerp/hooks/use-simulation-state.js +161 -0
- package/dist/sgerp/index.d.ts +24 -2
- package/dist/sgerp/index.d.ts.map +1 -1
- package/dist/sgerp/index.js +62 -2
- package/dist/sgerp/simulation-logic/fetchUtils.d.ts.map +1 -1
- package/dist/sgerp/simulation-logic/fetchUtils.js +2 -0
- package/dist/sgerp/simulation-logic/index.d.ts +3 -1
- package/dist/sgerp/simulation-logic/index.d.ts.map +1 -1
- package/dist/sgerp/simulation-logic/index.js +10 -1
- package/dist/sgerp/simulation-logic/liveUpdates.d.ts +102 -0
- package/dist/sgerp/simulation-logic/liveUpdates.d.ts.map +1 -0
- package/dist/sgerp/simulation-logic/liveUpdates.js +87 -0
- package/dist/sgerp/simulation-logic/prepareSimulationData.d.ts +36 -0
- package/dist/sgerp/simulation-logic/prepareSimulationData.d.ts.map +1 -0
- package/dist/sgerp/simulation-logic/prepareSimulationData.js +34 -0
- package/dist/sgerp/simulation-logic/routeCalculationUtils.d.ts +7 -1
- package/dist/sgerp/simulation-logic/routeCalculationUtils.d.ts.map +1 -1
- package/dist/sgerp/simulation-logic/routeCalculationUtils.js +81 -0
- package/dist/utils/countries.d.ts +15 -0
- package/dist/utils/countries.d.ts.map +1 -0
- package/dist/utils/countries.js +112 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +8 -0
- package/dist/vrptoolbox/collection.d.ts +16 -0
- package/dist/vrptoolbox/collection.d.ts.map +1 -0
- package/dist/vrptoolbox/collection.js +62 -0
- package/dist/vrptoolbox/index.d.ts +6 -0
- package/dist/vrptoolbox/index.d.ts.map +1 -0
- package/dist/vrptoolbox/index.js +8 -0
- package/dist/vrptoolbox/types/job.d.ts +46 -0
- package/dist/vrptoolbox/types/job.d.ts.map +1 -0
- package/dist/vrptoolbox/types/job.js +5 -0
- package/package.json +7 -4
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Inspired by dashviewer's SimulationPage/logic structure
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.processUnassignResponse = exports.hasRouteChanged = exports.calculateVehicleRoute = exports.shiftWaypointTimestamps = exports.shiftNodeTimestamps = exports.buildVehicleRouteMap = exports.vehicleComplexRearrange = exports.calculateBoundingBoxCenter = exports.attachReferences = exports.createIndexMaps = exports.fetchSimulationData = exports.fetchOperationsLocationsByProject = exports.fetchDriversByProject = exports.fetchDrivers = exports.fetchNodes = exports.fetchBookings = exports.fetchVehicles = void 0;
|
|
7
|
+
exports.triggerAllSimulationUpdates = exports.getProcessorLiveUpdateConfig = exports.getNodeLiveUpdateConfig = exports.getBookingLiveUpdateConfig = exports.getVehicleLiveUpdateConfig = exports.PROCESSOR_LIVE_UPDATE_PARAMS = exports.LIVE_UPDATE_INTERVALS = exports.processUnassignResponse = exports.recalculateVehicleRoute = exports.hasRouteChanged = exports.calculateVehicleRoute = exports.shiftWaypointTimestamps = exports.shiftNodeTimestamps = exports.buildVehicleRouteMap = exports.vehicleComplexRearrange = exports.calculateBoundingBoxCenter = exports.attachReferences = exports.createIndexMaps = exports.fetchSimulationData = exports.fetchOperationsLocationsByProject = exports.fetchDriversByProject = exports.fetchDrivers = exports.fetchNodes = exports.fetchBookings = exports.fetchVehicles = void 0;
|
|
8
8
|
var fetchUtils_1 = require("./fetchUtils");
|
|
9
9
|
Object.defineProperty(exports, "fetchVehicles", { enumerable: true, get: function () { return fetchUtils_1.fetchVehicles; } });
|
|
10
10
|
Object.defineProperty(exports, "fetchBookings", { enumerable: true, get: function () { return fetchUtils_1.fetchBookings; } });
|
|
@@ -27,5 +27,14 @@ Object.defineProperty(exports, "shiftWaypointTimestamps", { enumerable: true, ge
|
|
|
27
27
|
var routeCalculationUtils_1 = require("./routeCalculationUtils");
|
|
28
28
|
Object.defineProperty(exports, "calculateVehicleRoute", { enumerable: true, get: function () { return routeCalculationUtils_1.calculateVehicleRoute; } });
|
|
29
29
|
Object.defineProperty(exports, "hasRouteChanged", { enumerable: true, get: function () { return routeCalculationUtils_1.hasRouteChanged; } });
|
|
30
|
+
Object.defineProperty(exports, "recalculateVehicleRoute", { enumerable: true, get: function () { return routeCalculationUtils_1.recalculateVehicleRoute; } });
|
|
30
31
|
var optimisticUpdateUtils_1 = require("./optimisticUpdateUtils");
|
|
31
32
|
Object.defineProperty(exports, "processUnassignResponse", { enumerable: true, get: function () { return optimisticUpdateUtils_1.processUnassignResponse; } });
|
|
33
|
+
var liveUpdates_1 = require("./liveUpdates");
|
|
34
|
+
Object.defineProperty(exports, "LIVE_UPDATE_INTERVALS", { enumerable: true, get: function () { return liveUpdates_1.LIVE_UPDATE_INTERVALS; } });
|
|
35
|
+
Object.defineProperty(exports, "PROCESSOR_LIVE_UPDATE_PARAMS", { enumerable: true, get: function () { return liveUpdates_1.PROCESSOR_LIVE_UPDATE_PARAMS; } });
|
|
36
|
+
Object.defineProperty(exports, "getVehicleLiveUpdateConfig", { enumerable: true, get: function () { return liveUpdates_1.getVehicleLiveUpdateConfig; } });
|
|
37
|
+
Object.defineProperty(exports, "getBookingLiveUpdateConfig", { enumerable: true, get: function () { return liveUpdates_1.getBookingLiveUpdateConfig; } });
|
|
38
|
+
Object.defineProperty(exports, "getNodeLiveUpdateConfig", { enumerable: true, get: function () { return liveUpdates_1.getNodeLiveUpdateConfig; } });
|
|
39
|
+
Object.defineProperty(exports, "getProcessorLiveUpdateConfig", { enumerable: true, get: function () { return liveUpdates_1.getProcessorLiveUpdateConfig; } });
|
|
40
|
+
Object.defineProperty(exports, "triggerAllSimulationUpdates", { enumerable: true, get: function () { return liveUpdates_1.triggerAllSimulationUpdates; } });
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live updates configuration for simulation pages
|
|
3
|
+
* Encapsulates polling intervals and params for vehicle, booking, node, and processor updates
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for simulation live updates
|
|
7
|
+
*/
|
|
8
|
+
export interface SimulationLiveUpdatesConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Simulation ID to poll updates for
|
|
11
|
+
*/
|
|
12
|
+
simulationId: number | string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether live updates are enabled (typically disabled during initial loading)
|
|
15
|
+
*/
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Callback when any collection receives updates
|
|
19
|
+
*/
|
|
20
|
+
onUpdate?: (hasUpdates: boolean) => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Standard intervals for different collection types
|
|
24
|
+
*/
|
|
25
|
+
export declare const LIVE_UPDATE_INTERVALS: {
|
|
26
|
+
readonly VEHICLE: 5000;
|
|
27
|
+
readonly BOOKING: 5000;
|
|
28
|
+
readonly NODE: 5000;
|
|
29
|
+
readonly PROCESSOR: 3000;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Standard parameters for processor live updates
|
|
33
|
+
*/
|
|
34
|
+
export declare const PROCESSOR_LIVE_UPDATE_PARAMS: {
|
|
35
|
+
readonly processor_lifecycle_type: "one_shot";
|
|
36
|
+
readonly only_fields: "id,simulation_id,created_at,modified_at,start_time,state,processor_lifecycle_type,username";
|
|
37
|
+
readonly order_by: "-id";
|
|
38
|
+
readonly limit: 100;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Setup configuration for vehicle live updates
|
|
42
|
+
*/
|
|
43
|
+
export declare function getVehicleLiveUpdateConfig(config: SimulationLiveUpdatesConfig): {
|
|
44
|
+
enabled: boolean;
|
|
45
|
+
params: {
|
|
46
|
+
simulation_id: string | number;
|
|
47
|
+
};
|
|
48
|
+
interval: 5000;
|
|
49
|
+
onUpdate: ((hasUpdates: boolean) => void) | undefined;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Setup configuration for booking live updates
|
|
53
|
+
*/
|
|
54
|
+
export declare function getBookingLiveUpdateConfig(config: SimulationLiveUpdatesConfig): {
|
|
55
|
+
enabled: boolean;
|
|
56
|
+
params: {
|
|
57
|
+
simulation_id: string | number;
|
|
58
|
+
};
|
|
59
|
+
interval: 5000;
|
|
60
|
+
onUpdate: ((hasUpdates: boolean) => void) | undefined;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Setup configuration for node live updates
|
|
64
|
+
*/
|
|
65
|
+
export declare function getNodeLiveUpdateConfig(config: SimulationLiveUpdatesConfig): {
|
|
66
|
+
enabled: boolean;
|
|
67
|
+
params: {
|
|
68
|
+
simulation_id: string | number;
|
|
69
|
+
};
|
|
70
|
+
interval: 5000;
|
|
71
|
+
onUpdate: ((hasUpdates: boolean) => void) | undefined;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Setup configuration for processor live updates
|
|
75
|
+
*/
|
|
76
|
+
export declare function getProcessorLiveUpdateConfig(config: SimulationLiveUpdatesConfig): {
|
|
77
|
+
enabled: boolean;
|
|
78
|
+
params: {
|
|
79
|
+
processor_lifecycle_type: "one_shot";
|
|
80
|
+
only_fields: "id,simulation_id,created_at,modified_at,start_time,state,processor_lifecycle_type,username";
|
|
81
|
+
order_by: "-id";
|
|
82
|
+
limit: 100;
|
|
83
|
+
simulation_id: string | number;
|
|
84
|
+
};
|
|
85
|
+
interval: 3000;
|
|
86
|
+
onUpdate: ((hasUpdates: boolean) => void) | undefined;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Trigger functions for manual updates
|
|
90
|
+
*/
|
|
91
|
+
export interface SimulationLiveUpdateTriggers {
|
|
92
|
+
triggerVehicleUpdate?: () => Promise<void>;
|
|
93
|
+
triggerBookingUpdate?: () => Promise<void>;
|
|
94
|
+
triggerNodeUpdate?: () => Promise<void>;
|
|
95
|
+
triggerProcessorUpdate?: () => Promise<void>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Trigger all simulation live updates manually
|
|
99
|
+
* Useful after operations like autoplan, import, or bulk edits
|
|
100
|
+
*/
|
|
101
|
+
export declare function triggerAllSimulationUpdates(triggers: SimulationLiveUpdateTriggers): Promise<void>;
|
|
102
|
+
//# sourceMappingURL=liveUpdates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liveUpdates.d.ts","sourceRoot":"","sources":["../../../sgerplib/sgerp/simulation-logic/liveUpdates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;CAKxB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,4BAA4B;;;;;CAK/B,CAAC;AAEX;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,2BAA2B;;;;;;4BA1BpD,OAAO,KAAK,IAAI;EAiCzC;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,2BAA2B;;;;;;4BAtCpD,OAAO,KAAK,IAAI;EA6CzC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,2BAA2B;;;;;;4BAlDjD,OAAO,KAAK,IAAI;EAyDzC;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,2BAA2B;;;;;;;;;;4BA9DtD,OAAO,KAAK,IAAI;EAwEzC;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,oBAAoB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,oBAAoB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,sBAAsB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAAC,QAAQ,EAAE,4BAA4B,iBAOvF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Live updates configuration for simulation pages
|
|
4
|
+
* Encapsulates polling intervals and params for vehicle, booking, node, and processor updates
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.PROCESSOR_LIVE_UPDATE_PARAMS = exports.LIVE_UPDATE_INTERVALS = void 0;
|
|
8
|
+
exports.getVehicleLiveUpdateConfig = getVehicleLiveUpdateConfig;
|
|
9
|
+
exports.getBookingLiveUpdateConfig = getBookingLiveUpdateConfig;
|
|
10
|
+
exports.getNodeLiveUpdateConfig = getNodeLiveUpdateConfig;
|
|
11
|
+
exports.getProcessorLiveUpdateConfig = getProcessorLiveUpdateConfig;
|
|
12
|
+
exports.triggerAllSimulationUpdates = triggerAllSimulationUpdates;
|
|
13
|
+
/**
|
|
14
|
+
* Standard intervals for different collection types
|
|
15
|
+
*/
|
|
16
|
+
exports.LIVE_UPDATE_INTERVALS = {
|
|
17
|
+
VEHICLE: 5000, // 5 seconds
|
|
18
|
+
BOOKING: 5000, // 5 seconds
|
|
19
|
+
NODE: 5000, // 5 seconds
|
|
20
|
+
PROCESSOR: 3000, // 3 seconds (more frequent to catch state changes quickly)
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Standard parameters for processor live updates
|
|
24
|
+
*/
|
|
25
|
+
exports.PROCESSOR_LIVE_UPDATE_PARAMS = {
|
|
26
|
+
processor_lifecycle_type: 'one_shot',
|
|
27
|
+
only_fields: 'id,simulation_id,created_at,modified_at,start_time,state,processor_lifecycle_type,username',
|
|
28
|
+
order_by: '-id',
|
|
29
|
+
limit: 100,
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Setup configuration for vehicle live updates
|
|
33
|
+
*/
|
|
34
|
+
function getVehicleLiveUpdateConfig(config) {
|
|
35
|
+
return {
|
|
36
|
+
enabled: config.enabled,
|
|
37
|
+
params: { simulation_id: config.simulationId },
|
|
38
|
+
interval: exports.LIVE_UPDATE_INTERVALS.VEHICLE,
|
|
39
|
+
onUpdate: config.onUpdate,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Setup configuration for booking live updates
|
|
44
|
+
*/
|
|
45
|
+
function getBookingLiveUpdateConfig(config) {
|
|
46
|
+
return {
|
|
47
|
+
enabled: config.enabled,
|
|
48
|
+
params: { simulation_id: config.simulationId },
|
|
49
|
+
interval: exports.LIVE_UPDATE_INTERVALS.BOOKING,
|
|
50
|
+
onUpdate: config.onUpdate,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Setup configuration for node live updates
|
|
55
|
+
*/
|
|
56
|
+
function getNodeLiveUpdateConfig(config) {
|
|
57
|
+
return {
|
|
58
|
+
enabled: config.enabled,
|
|
59
|
+
params: { simulation_id: config.simulationId },
|
|
60
|
+
interval: exports.LIVE_UPDATE_INTERVALS.NODE,
|
|
61
|
+
onUpdate: config.onUpdate,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Setup configuration for processor live updates
|
|
66
|
+
*/
|
|
67
|
+
function getProcessorLiveUpdateConfig(config) {
|
|
68
|
+
return {
|
|
69
|
+
enabled: config.enabled,
|
|
70
|
+
params: Object.assign({ simulation_id: config.simulationId }, exports.PROCESSOR_LIVE_UPDATE_PARAMS),
|
|
71
|
+
interval: exports.LIVE_UPDATE_INTERVALS.PROCESSOR,
|
|
72
|
+
onUpdate: config.onUpdate,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Trigger all simulation live updates manually
|
|
77
|
+
* Useful after operations like autoplan, import, or bulk edits
|
|
78
|
+
*/
|
|
79
|
+
async function triggerAllSimulationUpdates(triggers) {
|
|
80
|
+
var _a, _b, _c, _d;
|
|
81
|
+
await Promise.all([
|
|
82
|
+
(_a = triggers.triggerVehicleUpdate) === null || _a === void 0 ? void 0 : _a.call(triggers),
|
|
83
|
+
(_b = triggers.triggerBookingUpdate) === null || _b === void 0 ? void 0 : _b.call(triggers),
|
|
84
|
+
(_c = triggers.triggerNodeUpdate) === null || _c === void 0 ? void 0 : _c.call(triggers),
|
|
85
|
+
(_d = triggers.triggerProcessorUpdate) === null || _d === void 0 ? void 0 : _d.call(triggers),
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { SGERPClient } from '../client';
|
|
2
|
+
import type { Simulation } from '../types/simulation/simulation';
|
|
3
|
+
import type { Booking } from '../types/simulation/booking';
|
|
4
|
+
import type { Vehicle } from '../types/simulation/vehicle';
|
|
5
|
+
import type { Driver } from '../types/simulation/driver';
|
|
6
|
+
import type { Geofence } from '../types/simulation/geofence';
|
|
7
|
+
import type { RouteNode } from '../utils/routeUtils';
|
|
8
|
+
export interface SimulationDataResult {
|
|
9
|
+
vehicles: Vehicle[];
|
|
10
|
+
bookings: Booking[];
|
|
11
|
+
nodes: RouteNode[];
|
|
12
|
+
drivers: Driver[];
|
|
13
|
+
geofences: Geofence[];
|
|
14
|
+
mainGeofence: Geofence | null;
|
|
15
|
+
vehicleRoutes: Map<number, {
|
|
16
|
+
waypoints: any[];
|
|
17
|
+
polyline?: any;
|
|
18
|
+
}>;
|
|
19
|
+
vehicleData: Map<number, {
|
|
20
|
+
assigned_nodes: RouteNode[];
|
|
21
|
+
completed_nodes: RouteNode[];
|
|
22
|
+
assigned_booking_uids: Set<string>;
|
|
23
|
+
completed_booking_uids: Set<string>;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Prepare all simulation data: fetch, attach references, generate routes
|
|
28
|
+
* This is a comprehensive function that handles the entire data preparation pipeline
|
|
29
|
+
*
|
|
30
|
+
* @param api - SGERP client instance
|
|
31
|
+
* @param simulationId - Simulation ID to fetch data for
|
|
32
|
+
* @param simulation - Optional simulation object (for fetching main geofence)
|
|
33
|
+
* @returns Complete simulation data with references attached and routes generated
|
|
34
|
+
*/
|
|
35
|
+
export declare function prepareSimulationData(api: SGERPClient, simulationId: number | string, simulation?: Simulation | null): Promise<SimulationDataResult>;
|
|
36
|
+
//# sourceMappingURL=prepareSimulationData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareSimulationData.d.ts","sourceRoot":"","sources":["../../../sgerplib/sgerp/simulation-logic/prepareSimulationData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKrD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,YAAY,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,GAAG,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;IACjE,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE;QACvB,cAAc,EAAE,SAAS,EAAE,CAAC;QAC5B,eAAe,EAAE,SAAS,EAAE,CAAC;QAC7B,qBAAqB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QACnC,sBAAsB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;KACrC,CAAC,CAAC;CACJ;AAED;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,WAAW,EAChB,YAAY,EAAE,MAAM,GAAG,MAAM,EAC7B,UAAU,GAAE,UAAU,GAAG,IAAW,GACnC,OAAO,CAAC,oBAAoB,CAAC,CAyB/B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prepareSimulationData = prepareSimulationData;
|
|
4
|
+
const fetchUtils_1 = require("./fetchUtils");
|
|
5
|
+
const referenceUtils_1 = require("./referenceUtils");
|
|
6
|
+
const routeUtils_1 = require("../utils/routeUtils");
|
|
7
|
+
/**
|
|
8
|
+
* Prepare all simulation data: fetch, attach references, generate routes
|
|
9
|
+
* This is a comprehensive function that handles the entire data preparation pipeline
|
|
10
|
+
*
|
|
11
|
+
* @param api - SGERP client instance
|
|
12
|
+
* @param simulationId - Simulation ID to fetch data for
|
|
13
|
+
* @param simulation - Optional simulation object (for fetching main geofence)
|
|
14
|
+
* @returns Complete simulation data with references attached and routes generated
|
|
15
|
+
*/
|
|
16
|
+
async function prepareSimulationData(api, simulationId, simulation = null) {
|
|
17
|
+
// Step 1: Fetch all data
|
|
18
|
+
const { vehicles, bookings, nodes, drivers, geofences, mainGeofence } = await (0, fetchUtils_1.fetchSimulationData)(api, simulationId, simulation);
|
|
19
|
+
// Step 2: Attach references between models
|
|
20
|
+
const { vehicleData } = (0, referenceUtils_1.attachReferences)(bookings, vehicles, nodes);
|
|
21
|
+
// Step 3: Generate vehicle routes from nodes
|
|
22
|
+
const vehicleIds = vehicles.map(v => v.id);
|
|
23
|
+
const vehicleRoutes = (0, routeUtils_1.createVehicleRoutesFromNodes)(nodes, vehicleIds);
|
|
24
|
+
return {
|
|
25
|
+
vehicles,
|
|
26
|
+
bookings,
|
|
27
|
+
nodes: nodes,
|
|
28
|
+
drivers,
|
|
29
|
+
geofences,
|
|
30
|
+
mainGeofence,
|
|
31
|
+
vehicleRoutes,
|
|
32
|
+
vehicleData
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Vehicle } from '../types/simulation/vehicle';
|
|
2
|
-
import type { RouteNode } from '../utils/routeUtils';
|
|
2
|
+
import type { RouteNode, Waypoint } from '../utils/routeUtils';
|
|
3
3
|
import { Route } from '../routing';
|
|
4
|
+
import type { Connection } from '../types/config';
|
|
4
5
|
/**
|
|
5
6
|
* Calculate OSRM route for a vehicle based on its assigned nodes
|
|
6
7
|
*/
|
|
@@ -9,4 +10,9 @@ export declare function calculateVehicleRoute(vehicle: Vehicle, sortedNodes: Rou
|
|
|
9
10
|
* Check if a vehicle's route has changed by comparing node IDs
|
|
10
11
|
*/
|
|
11
12
|
export declare function hasRouteChanged(existingNodes: RouteNode[] | undefined, newNodes: RouteNode[]): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Recalculate route for a vehicle when waypoints change
|
|
15
|
+
* Handles route calculation and scheduled timestamp updates
|
|
16
|
+
*/
|
|
17
|
+
export declare function recalculateVehicleRoute(vehicle: Vehicle, updatedWaypoints: Waypoint[], activeConnection: Connection | null): Promise<Route | null>;
|
|
12
18
|
//# sourceMappingURL=routeCalculationUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routeCalculationUtils.d.ts","sourceRoot":"","sources":["../../../sgerplib/sgerp/simulation-logic/routeCalculationUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"routeCalculationUtils.d.ts","sourceRoot":"","sources":["../../../sgerplib/sgerp/simulation-logic/routeCalculationUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAiB,KAAK,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,SAAS,EAAE,EACxB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAuCvB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,aAAa,EAAE,SAAS,EAAE,GAAG,SAAS,EACtC,QAAQ,EAAE,SAAS,EAAE,GACpB,OAAO,CAIT;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,QAAQ,EAAE,EAC5B,gBAAgB,EAAE,UAAU,GAAG,IAAI,GAClC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAgHvB"}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculateVehicleRoute = calculateVehicleRoute;
|
|
4
4
|
exports.hasRouteChanged = hasRouteChanged;
|
|
5
|
+
exports.recalculateVehicleRoute = recalculateVehicleRoute;
|
|
5
6
|
const routing_1 = require("../routing");
|
|
7
|
+
const domains_1 = require("../domains");
|
|
6
8
|
/**
|
|
7
9
|
* Calculate OSRM route for a vehicle based on its assigned nodes
|
|
8
10
|
*/
|
|
@@ -41,3 +43,82 @@ function hasRouteChanged(existingNodes, newNodes) {
|
|
|
41
43
|
const newNodeIds = newNodes.map(n => n.id).join(',');
|
|
42
44
|
return existingNodeIds !== newNodeIds;
|
|
43
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Recalculate route for a vehicle when waypoints change
|
|
48
|
+
* Handles route calculation and scheduled timestamp updates
|
|
49
|
+
*/
|
|
50
|
+
async function recalculateVehicleRoute(vehicle, updatedWaypoints, activeConnection) {
|
|
51
|
+
// console.log('Recalculating route for vehicle', vehicle.id, 'with', updatedWaypoints.length, 'waypoints')
|
|
52
|
+
// Extract all nodes from updated waypoints and flatten
|
|
53
|
+
const updatedNodes = [];
|
|
54
|
+
updatedWaypoints.forEach((waypoint) => {
|
|
55
|
+
waypoint.nodes.forEach((node) => {
|
|
56
|
+
updatedNodes.push(node);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
// Sort nodes by sequence (they should already be in order from waypoints)
|
|
60
|
+
const sortedNodes = updatedNodes.filter((n) => n.lat && n.lon);
|
|
61
|
+
let calculatedRoute = null;
|
|
62
|
+
// Calculate OSRM route if we have enough waypoints
|
|
63
|
+
if (sortedNodes.length >= 2) {
|
|
64
|
+
const coordinates = sortedNodes.map((node) => [node.lat, node.lon]);
|
|
65
|
+
// Get routing engine settings from vehicle or use defaults
|
|
66
|
+
const settings = vehicle.routing_engine_settings || {};
|
|
67
|
+
const routingEngineName = settings.routing_engine_name || "osrm";
|
|
68
|
+
const url = settings.url || "http://mapbox-osrm-proxy";
|
|
69
|
+
const roadNetwork = settings.road_network || "van";
|
|
70
|
+
const key = settings.key || "dmVyeSBzZWNyZXQga2V5";
|
|
71
|
+
const curb = settings.curb !== undefined ? settings.curb : false;
|
|
72
|
+
// Determine backend from active connection
|
|
73
|
+
let defaultBackend = "production"; // default
|
|
74
|
+
if (activeConnection === null || activeConnection === void 0 ? void 0 : activeConnection.baseUrl) {
|
|
75
|
+
defaultBackend = (0, domains_1.detectBackendFromUrl)(activeConnection.baseUrl);
|
|
76
|
+
}
|
|
77
|
+
// Create routing engine with vehicle-specific settings
|
|
78
|
+
const routingEngine = new routing_1.RoutingEngine(routingEngineName, url, roadNetwork, key, defaultBackend, settings.speed ? { speed: settings.speed } : null);
|
|
79
|
+
await new Promise((resolve) => {
|
|
80
|
+
routingEngine.route(coordinates, curb, (result, status, message) => {
|
|
81
|
+
if (status === "ok" && (result === null || result === void 0 ? void 0 : result.osrmRoute)) {
|
|
82
|
+
calculatedRoute = result.osrmRoute;
|
|
83
|
+
// console.log('Route calculated successfully', result.osrmRoute)
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
console.error(`Failed to recalculate route for vehicle ${vehicle.id}:`, message);
|
|
87
|
+
}
|
|
88
|
+
resolve();
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
// Recalculate scheduled_ts for all nodes based on route legs
|
|
93
|
+
if (calculatedRoute &&
|
|
94
|
+
calculatedRoute.legs) {
|
|
95
|
+
const route = calculatedRoute;
|
|
96
|
+
if (sortedNodes.length > 0 && sortedNodes[0].scheduled_ts) {
|
|
97
|
+
let cumulativeDurationSeconds = 0;
|
|
98
|
+
const startTime = new Date(sortedNodes[0].scheduled_ts).getTime();
|
|
99
|
+
sortedNodes.forEach((node, index) => {
|
|
100
|
+
if (index === 0) {
|
|
101
|
+
// Keep first node's scheduled_ts as is (it's the starting point)
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
// Add duration from previous leg
|
|
105
|
+
if (route.legs[index - 1]) {
|
|
106
|
+
cumulativeDurationSeconds += route.legs[index - 1].duration || 0;
|
|
107
|
+
}
|
|
108
|
+
// Calculate new scheduled_ts
|
|
109
|
+
const newScheduledTime = new Date(startTime + cumulativeDurationSeconds * 1000);
|
|
110
|
+
node.scheduled_ts = newScheduledTime.toISOString();
|
|
111
|
+
});
|
|
112
|
+
// Update waypoints with new scheduled_ts
|
|
113
|
+
updatedWaypoints.forEach((waypoint) => {
|
|
114
|
+
waypoint.nodes.forEach((waypointNode) => {
|
|
115
|
+
const updatedNode = sortedNodes.find((n) => n.id === waypointNode.id);
|
|
116
|
+
if (updatedNode && updatedNode.scheduled_ts) {
|
|
117
|
+
waypointNode.scheduled_ts = updatedNode.scheduled_ts;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return calculatedRoute;
|
|
124
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comprehensive list of countries with their phone codes and flag emojis
|
|
3
|
+
*/
|
|
4
|
+
export interface Country {
|
|
5
|
+
code: string;
|
|
6
|
+
name: string;
|
|
7
|
+
flag: string;
|
|
8
|
+
dialCode: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const COUNTRIES: Country[];
|
|
11
|
+
export declare const POPULAR_COUNTRIES: string[];
|
|
12
|
+
export declare const getCountryByDialCode: (dialCode: string) => Country | undefined;
|
|
13
|
+
export declare const getCountryByCode: (code: string) => Country | undefined;
|
|
14
|
+
export declare const getLocalizedCountryName: (country: Country, getText: (key: string) => string) => string;
|
|
15
|
+
//# sourceMappingURL=countries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countries.d.ts","sourceRoot":"","sources":["../../sgerplib/utils/countries.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,SAAS,EAAE,OAAO,EAoF9B,CAAC;AAMF,eAAO,MAAM,iBAAiB,UAE7B,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,KAAG,OAAO,GAAG,SAEjE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,OAAO,GAAG,SAEzD,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,SAAS,OAAO,EAChB,SAAS,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,KAC/B,MAKF,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Comprehensive list of countries with their phone codes and flag emojis
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getLocalizedCountryName = exports.getCountryByCode = exports.getCountryByDialCode = exports.POPULAR_COUNTRIES = exports.COUNTRIES = void 0;
|
|
7
|
+
exports.COUNTRIES = [
|
|
8
|
+
{ code: 'US', name: 'United States', flag: '🇺🇸', dialCode: '+1' },
|
|
9
|
+
{ code: 'CA', name: 'Canada', flag: '🇨🇦', dialCode: '+1' },
|
|
10
|
+
{ code: 'GB', name: 'United Kingdom', flag: '🇬🇧', dialCode: '+44' },
|
|
11
|
+
{ code: 'AU', name: 'Australia', flag: '🇦🇺', dialCode: '+61' },
|
|
12
|
+
{ code: 'NZ', name: 'New Zealand', flag: '🇳🇿', dialCode: '+64' },
|
|
13
|
+
{ code: 'SG', name: 'Singapore', flag: '🇸🇬', dialCode: '+65' },
|
|
14
|
+
{ code: 'MY', name: 'Malaysia', flag: '🇲🇾', dialCode: '+60' },
|
|
15
|
+
{ code: 'TH', name: 'Thailand', flag: '🇹🇭', dialCode: '+66' },
|
|
16
|
+
{ code: 'ID', name: 'Indonesia', flag: '🇮🇩', dialCode: '+62' },
|
|
17
|
+
{ code: 'PH', name: 'Philippines', flag: '🇵🇭', dialCode: '+63' },
|
|
18
|
+
{ code: 'VN', name: 'Vietnam', flag: '🇻🇳', dialCode: '+84' },
|
|
19
|
+
{ code: 'JP', name: 'Japan', flag: '🇯🇵', dialCode: '+81' },
|
|
20
|
+
{ code: 'KR', name: 'South Korea', flag: '🇰🇷', dialCode: '+82' },
|
|
21
|
+
{ code: 'CN', name: 'China', flag: '🇨🇳', dialCode: '+86' },
|
|
22
|
+
{ code: 'HK', name: 'Hong Kong', flag: '🇭🇰', dialCode: '+852' },
|
|
23
|
+
{ code: 'TW', name: 'Taiwan', flag: '🇹🇼', dialCode: '+886' },
|
|
24
|
+
{ code: 'IN', name: 'India', flag: '🇮🇳', dialCode: '+91' },
|
|
25
|
+
{ code: 'PK', name: 'Pakistan', flag: '🇵🇰', dialCode: '+92' },
|
|
26
|
+
{ code: 'BD', name: 'Bangladesh', flag: '🇧🇩', dialCode: '+880' },
|
|
27
|
+
{ code: 'LK', name: 'Sri Lanka', flag: '🇱🇰', dialCode: '+94' },
|
|
28
|
+
{ code: 'AE', name: 'United Arab Emirates', flag: '🇦🇪', dialCode: '+971' },
|
|
29
|
+
{ code: 'SA', name: 'Saudi Arabia', flag: '🇸🇦', dialCode: '+966' },
|
|
30
|
+
{ code: 'IL', name: 'Israel', flag: '🇮🇱', dialCode: '+972' },
|
|
31
|
+
{ code: 'TR', name: 'Turkey', flag: '🇹🇷', dialCode: '+90' },
|
|
32
|
+
{ code: 'RU', name: 'Russia', flag: '🇷🇺', dialCode: '+7' },
|
|
33
|
+
{ code: 'DE', name: 'Germany', flag: '🇩🇪', dialCode: '+49' },
|
|
34
|
+
{ code: 'FR', name: 'France', flag: '🇫🇷', dialCode: '+33' },
|
|
35
|
+
{ code: 'IT', name: 'Italy', flag: '🇮🇹', dialCode: '+39' },
|
|
36
|
+
{ code: 'ES', name: 'Spain', flag: '🇪🇸', dialCode: '+34' },
|
|
37
|
+
{ code: 'PT', name: 'Portugal', flag: '🇵🇹', dialCode: '+351' },
|
|
38
|
+
{ code: 'NL', name: 'Netherlands', flag: '🇳🇱', dialCode: '+31' },
|
|
39
|
+
{ code: 'BE', name: 'Belgium', flag: '🇧🇪', dialCode: '+32' },
|
|
40
|
+
{ code: 'CH', name: 'Switzerland', flag: '🇨🇭', dialCode: '+41' },
|
|
41
|
+
{ code: 'AT', name: 'Austria', flag: '🇦🇹', dialCode: '+43' },
|
|
42
|
+
{ code: 'SE', name: 'Sweden', flag: '🇸🇪', dialCode: '+46' },
|
|
43
|
+
{ code: 'NO', name: 'Norway', flag: '🇳🇴', dialCode: '+47' },
|
|
44
|
+
{ code: 'DK', name: 'Denmark', flag: '🇩🇰', dialCode: '+45' },
|
|
45
|
+
{ code: 'FI', name: 'Finland', flag: '🇫🇮', dialCode: '+358' },
|
|
46
|
+
{ code: 'PL', name: 'Poland', flag: '🇵🇱', dialCode: '+48' },
|
|
47
|
+
{ code: 'CZ', name: 'Czech Republic', flag: '🇨🇿', dialCode: '+420' },
|
|
48
|
+
{ code: 'GR', name: 'Greece', flag: '🇬🇷', dialCode: '+30' },
|
|
49
|
+
{ code: 'IE', name: 'Ireland', flag: '🇮🇪', dialCode: '+353' },
|
|
50
|
+
{ code: 'ZA', name: 'South Africa', flag: '🇿🇦', dialCode: '+27' },
|
|
51
|
+
{ code: 'EG', name: 'Egypt', flag: '🇪🇬', dialCode: '+20' },
|
|
52
|
+
{ code: 'NG', name: 'Nigeria', flag: '🇳🇬', dialCode: '+234' },
|
|
53
|
+
{ code: 'KE', name: 'Kenya', flag: '🇰🇪', dialCode: '+254' },
|
|
54
|
+
{ code: 'BR', name: 'Brazil', flag: '🇧🇷', dialCode: '+55' },
|
|
55
|
+
{ code: 'MX', name: 'Mexico', flag: '🇲🇽', dialCode: '+52' },
|
|
56
|
+
{ code: 'AR', name: 'Argentina', flag: '🇦🇷', dialCode: '+54' },
|
|
57
|
+
{ code: 'CL', name: 'Chile', flag: '🇨🇱', dialCode: '+56' },
|
|
58
|
+
{ code: 'CO', name: 'Colombia', flag: '🇨🇴', dialCode: '+57' },
|
|
59
|
+
{ code: 'PE', name: 'Peru', flag: '🇵🇪', dialCode: '+51' },
|
|
60
|
+
{ code: 'VE', name: 'Venezuela', flag: '🇻🇪', dialCode: '+58' },
|
|
61
|
+
{ code: 'KH', name: 'Cambodia', flag: '🇰🇭', dialCode: '+855' },
|
|
62
|
+
{ code: 'LA', name: 'Laos', flag: '🇱🇦', dialCode: '+856' },
|
|
63
|
+
{ code: 'MM', name: 'Myanmar', flag: '🇲🇲', dialCode: '+95' },
|
|
64
|
+
{ code: 'BN', name: 'Brunei', flag: '🇧🇳', dialCode: '+673' },
|
|
65
|
+
{ code: 'NP', name: 'Nepal', flag: '🇳🇵', dialCode: '+977' },
|
|
66
|
+
{ code: 'MV', name: 'Maldives', flag: '🇲🇻', dialCode: '+960' },
|
|
67
|
+
{ code: 'AF', name: 'Afghanistan', flag: '🇦🇫', dialCode: '+93' },
|
|
68
|
+
{ code: 'IQ', name: 'Iraq', flag: '🇮🇶', dialCode: '+964' },
|
|
69
|
+
{ code: 'IR', name: 'Iran', flag: '🇮🇷', dialCode: '+98' },
|
|
70
|
+
{ code: 'JO', name: 'Jordan', flag: '🇯🇴', dialCode: '+962' },
|
|
71
|
+
{ code: 'KW', name: 'Kuwait', flag: '🇰🇼', dialCode: '+965' },
|
|
72
|
+
{ code: 'LB', name: 'Lebanon', flag: '🇱🇧', dialCode: '+961' },
|
|
73
|
+
{ code: 'OM', name: 'Oman', flag: '🇴🇲', dialCode: '+968' },
|
|
74
|
+
{ code: 'QA', name: 'Qatar', flag: '🇶🇦', dialCode: '+974' },
|
|
75
|
+
{ code: 'BH', name: 'Bahrain', flag: '🇧🇭', dialCode: '+973' },
|
|
76
|
+
{ code: 'UA', name: 'Ukraine', flag: '🇺🇦', dialCode: '+380' },
|
|
77
|
+
{ code: 'RO', name: 'Romania', flag: '🇷🇴', dialCode: '+40' },
|
|
78
|
+
{ code: 'HU', name: 'Hungary', flag: '🇭🇺', dialCode: '+36' },
|
|
79
|
+
{ code: 'BG', name: 'Bulgaria', flag: '🇧🇬', dialCode: '+359' },
|
|
80
|
+
{ code: 'HR', name: 'Croatia', flag: '🇭🇷', dialCode: '+385' },
|
|
81
|
+
{ code: 'RS', name: 'Serbia', flag: '🇷🇸', dialCode: '+381' },
|
|
82
|
+
{ code: 'SI', name: 'Slovenia', flag: '🇸🇮', dialCode: '+386' },
|
|
83
|
+
{ code: 'SK', name: 'Slovakia', flag: '🇸🇰', dialCode: '+421' },
|
|
84
|
+
{ code: 'EE', name: 'Estonia', flag: '🇪🇪', dialCode: '+372' },
|
|
85
|
+
{ code: 'LV', name: 'Latvia', flag: '🇱🇻', dialCode: '+371' },
|
|
86
|
+
{ code: 'LT', name: 'Lithuania', flag: '🇱🇹', dialCode: '+370' },
|
|
87
|
+
{ code: 'IS', name: 'Iceland', flag: '🇮🇸', dialCode: '+354' },
|
|
88
|
+
{ code: 'LU', name: 'Luxembourg', flag: '🇱🇺', dialCode: '+352' },
|
|
89
|
+
{ code: 'MT', name: 'Malta', flag: '🇲🇹', dialCode: '+356' },
|
|
90
|
+
{ code: 'CY', name: 'Cyprus', flag: '🇨🇾', dialCode: '+357' },
|
|
91
|
+
];
|
|
92
|
+
// Sort by name by default
|
|
93
|
+
exports.COUNTRIES.sort((a, b) => a.name.localeCompare(b.name));
|
|
94
|
+
// Popular countries (shown at top)
|
|
95
|
+
exports.POPULAR_COUNTRIES = [
|
|
96
|
+
'US', 'GB', 'SG', 'AU', 'JP', 'CN', 'IN', 'TH', 'MY', 'ID'
|
|
97
|
+
];
|
|
98
|
+
const getCountryByDialCode = (dialCode) => {
|
|
99
|
+
return exports.COUNTRIES.find(c => c.dialCode === dialCode);
|
|
100
|
+
};
|
|
101
|
+
exports.getCountryByDialCode = getCountryByDialCode;
|
|
102
|
+
const getCountryByCode = (code) => {
|
|
103
|
+
return exports.COUNTRIES.find(c => c.code === code);
|
|
104
|
+
};
|
|
105
|
+
exports.getCountryByCode = getCountryByCode;
|
|
106
|
+
const getLocalizedCountryName = (country, getText) => {
|
|
107
|
+
const key = `country.${country.code.toLowerCase()}`;
|
|
108
|
+
const translated = getText(key);
|
|
109
|
+
// If translation key is returned as-is, it means no translation exists, fallback to English name
|
|
110
|
+
return translated === key ? country.name : translated;
|
|
111
|
+
};
|
|
112
|
+
exports.getLocalizedCountryName = getLocalizedCountryName;
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../sgerplib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAG5C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cn = cn;
|
|
4
|
+
const clsx_1 = require("clsx");
|
|
5
|
+
const tailwind_merge_1 = require("tailwind-merge");
|
|
6
|
+
function cn(...inputs) {
|
|
7
|
+
return (0, tailwind_merge_1.twMerge)((0, clsx_1.clsx)(inputs));
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { OptimizationJob } from './types/job';
|
|
2
|
+
import { Collection } from '../sgerp/collection';
|
|
3
|
+
/**
|
|
4
|
+
* Collection class for VRP Toolbox Optimization Jobs
|
|
5
|
+
*/
|
|
6
|
+
export declare class OptimizationJobCollection extends Collection<OptimizationJob> {
|
|
7
|
+
private baseUrl;
|
|
8
|
+
private username?;
|
|
9
|
+
private password?;
|
|
10
|
+
constructor(baseUrl: string, username?: string, password?: string);
|
|
11
|
+
/**
|
|
12
|
+
* Set authentication credentials
|
|
13
|
+
*/
|
|
14
|
+
setCredentials(username: string, password: string): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../sgerplib/vrptoolbox/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA0B,MAAM,aAAa,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAqBjD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,UAAU,CAAC,eAAe,CAAC;IACxE,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAS;gBAEd,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAqCjE;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;CAIzD"}
|