sgerp-frontend-lib 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/connection-manager.d.ts +48 -0
- package/dist/connection-manager.d.ts.map +1 -0
- package/dist/connection-manager.js +156 -0
- package/dist/index.js +20 -2
- package/dist/locales/locale-server.d.ts +10 -0
- package/dist/locales/locale-server.d.ts.map +1 -0
- package/dist/locales/locale-server.js +49 -0
- package/dist/locales/locale.d.ts +23 -0
- package/dist/locales/locale.d.ts.map +1 -0
- package/dist/locales/locale.js +145 -0
- package/dist/locales/locale_en.d.ts.map +1 -1
- package/dist/locales/locale_en.js +84 -9
- package/dist/locales/locale_ja.d.ts.map +1 -1
- package/dist/locales/locale_ja.js +84 -9
- package/dist/locales/locale_ms.d.ts.map +1 -1
- package/dist/locales/locale_ms.js +84 -9
- package/dist/locales/useLocalization.d.ts +11 -0
- package/dist/locales/useLocalization.d.ts.map +1 -0
- package/dist/locales/useLocalization.js +64 -0
- package/dist/locales.d.ts +228 -0
- package/dist/locales.d.ts.map +1 -0
- package/dist/locales.js +229 -0
- package/dist/sgerp/api/client.d.ts +45 -0
- package/dist/sgerp/api/client.d.ts.map +1 -0
- package/dist/sgerp/api/client.js +141 -0
- package/dist/sgerp/client.js +341 -0
- package/dist/sgerp/collection.d.ts +391 -0
- package/dist/sgerp/collection.d.ts.map +1 -0
- package/dist/sgerp/collection.js +756 -0
- package/dist/sgerp/collections/account/user.d.ts +8 -0
- package/dist/sgerp/collections/account/user.d.ts.map +1 -0
- package/dist/sgerp/collections/account/user.js +10 -0
- package/dist/sgerp/collections/masstransit/building.d.ts +26 -0
- package/dist/sgerp/collections/masstransit/building.d.ts.map +1 -0
- package/dist/sgerp/collections/masstransit/building.js +53 -0
- package/dist/sgerp/collections/masstransit/transitstop.d.ts +15 -0
- package/dist/sgerp/collections/masstransit/transitstop.d.ts.map +1 -0
- package/dist/sgerp/collections/masstransit/transitstop.js +54 -0
- package/dist/sgerp/collections/masstransit/transitstopset.d.ts +10 -0
- package/dist/sgerp/collections/masstransit/transitstopset.d.ts.map +1 -0
- package/dist/sgerp/collections/masstransit/transitstopset.js +10 -0
- package/dist/sgerp/collections/sharing/organization-project.d.ts +11 -0
- package/dist/sgerp/collections/sharing/organization-project.d.ts.map +1 -0
- package/dist/sgerp/collections/sharing/organization-project.js +13 -0
- package/dist/sgerp/collections/sharing/organization.d.ts +11 -0
- package/dist/sgerp/collections/sharing/organization.d.ts.map +1 -0
- package/dist/sgerp/collections/sharing/organization.js +13 -0
- package/dist/sgerp/collections/sharing/pricing.d.ts +18 -0
- package/dist/sgerp/collections/sharing/pricing.d.ts.map +1 -0
- package/dist/sgerp/collections/sharing/pricing.js +23 -0
- package/dist/sgerp/collections/sharing/project-member.d.ts +8 -0
- package/dist/sgerp/collections/sharing/project-member.d.ts.map +1 -0
- package/dist/sgerp/collections/sharing/project-member.js +10 -0
- package/dist/sgerp/collections/sharing/project.d.ts +8 -0
- package/dist/sgerp/collections/sharing/project.d.ts.map +1 -0
- package/dist/sgerp/collections/sharing/project.js +10 -0
- package/dist/sgerp/collections/simulation/booking.d.ts +11 -0
- package/dist/sgerp/collections/simulation/booking.d.ts.map +1 -0
- package/dist/sgerp/collections/simulation/booking.js +13 -0
- package/dist/sgerp/collections/simulation/dataset.d.ts +14 -0
- package/dist/sgerp/collections/simulation/dataset.d.ts.map +1 -0
- package/dist/sgerp/collections/simulation/dataset.js +17 -0
- package/dist/sgerp/collections/simulation/driver.d.ts +12 -0
- package/dist/sgerp/collections/simulation/driver.d.ts.map +1 -0
- package/dist/sgerp/collections/simulation/driver.js +40 -0
- package/dist/sgerp/collections/simulation/geofence.d.ts +24 -0
- package/dist/sgerp/collections/simulation/geofence.d.ts.map +1 -0
- package/dist/sgerp/collections/simulation/geofence.js +66 -0
- package/dist/sgerp/collections/simulation/mapboxtoken.d.ts +18 -0
- package/dist/sgerp/collections/simulation/mapboxtoken.d.ts.map +1 -0
- package/dist/sgerp/collections/simulation/mapboxtoken.js +24 -0
- package/dist/sgerp/collections/simulation/node.js +13 -0
- package/dist/sgerp/collections/simulation/operationslocation.d.ts +28 -0
- package/dist/sgerp/collections/simulation/operationslocation.d.ts.map +1 -0
- package/dist/sgerp/collections/simulation/operationslocation.js +64 -0
- package/dist/sgerp/collections/simulation/operationslocationgroup.d.ts +12 -0
- package/dist/sgerp/collections/simulation/operationslocationgroup.d.ts.map +1 -0
- package/dist/sgerp/collections/simulation/operationslocationgroup.js +24 -0
- package/dist/sgerp/collections/simulation/routingprofile.d.ts +10 -0
- package/dist/sgerp/collections/simulation/routingprofile.d.ts.map +1 -0
- package/dist/sgerp/collections/simulation/routingprofile.js +10 -0
- package/dist/sgerp/collections/simulation/simulation.d.ts +12 -0
- package/dist/sgerp/collections/simulation/simulation.d.ts.map +1 -0
- package/dist/sgerp/collections/simulation/simulation.js +35 -0
- package/dist/sgerp/collections/simulation/simulationprocessor.d.ts +19 -0
- package/dist/sgerp/collections/simulation/simulationprocessor.d.ts.map +1 -0
- package/dist/sgerp/collections/simulation/simulationprocessor.js +27 -0
- package/dist/sgerp/collections/simulation/vehicle.js +13 -0
- package/dist/sgerp/collections/simulation/vehicletype.d.ts +11 -0
- package/dist/sgerp/collections/simulation/vehicletype.d.ts.map +1 -0
- package/dist/sgerp/collections/simulation/vehicletype.js +13 -0
- package/dist/sgerp/collections/sms_notify/smsscheduled.d.ts +11 -0
- package/dist/sgerp/collections/sms_notify/smsscheduled.d.ts.map +1 -0
- package/dist/sgerp/collections/sms_notify/smsscheduled.js +13 -0
- package/dist/sgerp/collections/transportation/passenger.d.ts +8 -0
- package/dist/sgerp/collections/transportation/passenger.d.ts.map +1 -0
- package/dist/sgerp/collections/transportation/passenger.js +10 -0
- package/dist/sgerp/collections/transportation/ticket.d.ts +11 -0
- package/dist/sgerp/collections/transportation/ticket.d.ts.map +1 -0
- package/dist/sgerp/collections/transportation/ticket.js +13 -0
- package/dist/sgerp/collections/transportation/transaction.d.ts +11 -0
- package/dist/sgerp/collections/transportation/transaction.d.ts.map +1 -0
- package/dist/sgerp/collections/transportation/transaction.js +13 -0
- package/dist/sgerp/constants/bulkoperations-enums.d.ts +71 -0
- package/dist/sgerp/constants/bulkoperations-enums.d.ts.map +1 -0
- package/dist/sgerp/constants/bulkoperations-enums.js +99 -0
- package/dist/sgerp/constants/messages-enums.d.ts +47 -0
- package/dist/sgerp/constants/messages-enums.d.ts.map +1 -0
- package/dist/sgerp/constants/messages-enums.js +67 -0
- package/dist/sgerp/constants/scheduling-enums.d.ts +42 -0
- package/dist/sgerp/constants/scheduling-enums.d.ts.map +1 -0
- package/dist/sgerp/constants/scheduling-enums.js +61 -0
- package/dist/sgerp/constants/simulation-enums.d.ts +93 -0
- package/dist/sgerp/constants/simulation-enums.d.ts.map +1 -0
- package/dist/sgerp/constants/simulation-enums.js +147 -0
- package/dist/sgerp/constants/solver-strategies.d.ts +75 -0
- package/dist/sgerp/constants/solver-strategies.d.ts.map +1 -0
- package/dist/sgerp/constants/solver-strategies.js +26 -0
- package/dist/sgerp/context/sgerp-context.js +134 -0
- package/dist/sgerp/domains.d.ts +47 -0
- package/dist/sgerp/domains.d.ts.map +1 -0
- package/dist/sgerp/domains.js +45 -0
- package/dist/sgerp/hooks/use-collection.js +122 -0
- package/dist/sgerp/hooks/use-live-updates.js +16 -13
- package/dist/sgerp/index.js +153 -0
- package/dist/sgerp/map-states/operations-location-state.d.ts +12 -0
- package/dist/sgerp/map-states/operations-location-state.d.ts.map +1 -0
- package/dist/sgerp/map-states/operations-location-state.js +86 -0
- package/dist/sgerp/routing/index.d.ts +51 -0
- package/dist/sgerp/routing/index.d.ts.map +1 -0
- package/dist/sgerp/routing/index.js +373 -0
- package/dist/sgerp/simulation-logic/fetchUtils.d.ts +8 -8
- package/dist/sgerp/simulation-logic/fetchUtils.d.ts.map +1 -1
- package/dist/sgerp/simulation-logic/fetchUtils.js +226 -0
- package/dist/sgerp/simulation-logic/index.js +27 -7
- package/dist/sgerp/simulation-logic/manualEditUtils.d.ts +1 -1
- package/dist/sgerp/simulation-logic/manualEditUtils.d.ts.map +1 -1
- package/dist/sgerp/simulation-logic/manualEditUtils.js +69 -0
- package/dist/sgerp/simulation-logic/mapUtils.js +58 -0
- package/dist/sgerp/simulation-logic/optimisticUpdateUtils.js +8 -5
- package/dist/sgerp/simulation-logic/referenceUtils.d.ts +3 -3
- package/dist/sgerp/simulation-logic/referenceUtils.d.ts.map +1 -1
- package/dist/sgerp/simulation-logic/referenceUtils.js +110 -0
- package/dist/sgerp/simulation-logic/routeCalculationUtils.d.ts +3 -3
- package/dist/sgerp/simulation-logic/routeCalculationUtils.d.ts.map +1 -1
- package/dist/sgerp/simulation-logic/routeCalculationUtils.js +43 -0
- package/dist/sgerp/simulation-logic/timeShiftUtils.d.ts +1 -1
- package/dist/sgerp/simulation-logic/timeShiftUtils.d.ts.map +1 -1
- package/dist/sgerp/simulation-logic/timeShiftUtils.js +63 -0
- package/dist/sgerp/types/account/user.d.ts +38 -0
- package/dist/sgerp/types/account/user.d.ts.map +1 -0
- package/dist/sgerp/types/account/user.js +2 -0
- package/dist/sgerp/types/bulkoperations/index.d.ts +37 -0
- package/dist/sgerp/types/bulkoperations/index.d.ts.map +1 -0
- package/dist/sgerp/types/bulkoperations/index.js +35 -0
- package/dist/sgerp/types/bulkoperations/vehicle-upload.d.ts +335 -0
- package/dist/sgerp/types/bulkoperations/vehicle-upload.d.ts.map +1 -0
- package/dist/sgerp/types/bulkoperations/vehicle-upload.js +49 -0
- package/dist/sgerp/types/config.d.ts +25 -0
- package/dist/sgerp/types/config.d.ts.map +1 -0
- package/dist/sgerp/types/config.js +2 -0
- package/dist/sgerp/types/geojson.d.ts +45 -0
- package/dist/sgerp/types/geojson.d.ts.map +1 -0
- package/dist/sgerp/types/geojson.js +6 -0
- package/dist/sgerp/types/map.d.ts +24 -0
- package/dist/sgerp/types/map.d.ts.map +1 -0
- package/dist/sgerp/types/map.js +2 -0
- package/dist/sgerp/types/masstransit/building.d.ts +24 -0
- package/dist/sgerp/types/masstransit/building.d.ts.map +1 -0
- package/dist/sgerp/types/masstransit/building.js +2 -0
- package/dist/sgerp/types/masstransit/transitstop.d.ts +35 -0
- package/dist/sgerp/types/masstransit/transitstop.d.ts.map +1 -0
- package/dist/sgerp/types/masstransit/transitstop.js +2 -0
- package/dist/sgerp/types/masstransit/transitstopset.d.ts +14 -0
- package/dist/sgerp/types/masstransit/transitstopset.d.ts.map +1 -0
- package/dist/sgerp/types/masstransit/transitstopset.js +2 -0
- package/dist/sgerp/types/sharing/organization-project.d.ts +14 -0
- package/dist/sgerp/types/sharing/organization-project.d.ts.map +1 -0
- package/dist/sgerp/types/sharing/organization-project.js +2 -0
- package/dist/sgerp/types/sharing/organization.d.ts +14 -0
- package/dist/sgerp/types/sharing/organization.d.ts.map +1 -0
- package/dist/sgerp/types/sharing/organization.js +2 -0
- package/dist/sgerp/types/sharing/pricing.d.ts +98 -0
- package/dist/sgerp/types/sharing/pricing.d.ts.map +1 -0
- package/dist/sgerp/types/sharing/pricing.js +2 -0
- package/dist/sgerp/types/sharing/project-member.d.ts +15 -0
- package/dist/sgerp/types/sharing/project-member.d.ts.map +1 -0
- package/dist/sgerp/types/sharing/project-member.js +2 -0
- package/dist/sgerp/types/sharing/project.d.ts +16 -0
- package/dist/sgerp/types/sharing/project.d.ts.map +1 -0
- package/dist/sgerp/types/sharing/project.js +2 -0
- package/dist/sgerp/types/simulation/booking.d.ts +128 -0
- package/dist/sgerp/types/simulation/booking.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/booking.js +24 -0
- package/dist/sgerp/types/simulation/calculation-params.d.ts +20 -0
- package/dist/sgerp/types/simulation/calculation-params.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/calculation-params.js +2 -0
- package/dist/sgerp/types/simulation/dataset.d.ts +16 -0
- package/dist/sgerp/types/simulation/dataset.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/dataset.js +2 -0
- package/dist/sgerp/types/simulation/driver.d.ts +19 -0
- package/dist/sgerp/types/simulation/driver.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/driver.js +2 -0
- package/dist/sgerp/types/simulation/geofence.d.ts +19 -0
- package/dist/sgerp/types/simulation/geofence.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/geofence.js +2 -0
- package/dist/sgerp/types/simulation/logistics-api-settings.d.ts +98 -0
- package/dist/sgerp/types/simulation/logistics-api-settings.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/logistics-api-settings.js +104 -0
- package/dist/sgerp/types/simulation/mapboxtoken.d.ts +13 -0
- package/dist/sgerp/types/simulation/mapboxtoken.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/mapboxtoken.js +2 -0
- package/dist/sgerp/types/simulation/node.js +5 -2
- package/dist/sgerp/types/simulation/operationslocation.d.ts +40 -0
- package/dist/sgerp/types/simulation/operationslocation.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/operationslocation.js +2 -0
- package/dist/sgerp/types/simulation/operationslocationgroup.d.ts +11 -0
- package/dist/sgerp/types/simulation/operationslocationgroup.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/operationslocationgroup.js +2 -0
- package/dist/sgerp/types/simulation/pricing.d.ts +171 -0
- package/dist/sgerp/types/simulation/pricing.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/pricing.js +2 -0
- package/dist/sgerp/types/simulation/route-cost-modification.d.ts +35 -0
- package/dist/sgerp/types/simulation/route-cost-modification.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/route-cost-modification.js +5 -0
- package/dist/sgerp/types/simulation/routing-engine-settings.d.ts +42 -0
- package/dist/sgerp/types/simulation/routing-engine-settings.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/routing-engine-settings.js +35 -0
- package/dist/sgerp/types/simulation/routingprofile.d.ts +32 -0
- package/dist/sgerp/types/simulation/routingprofile.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/routingprofile.js +37 -0
- package/dist/sgerp/types/simulation/simulation.d.ts +120 -0
- package/dist/sgerp/types/simulation/simulation.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/simulation.js +2 -0
- package/dist/sgerp/types/simulation/simulationprocessor.d.ts +31 -0
- package/dist/sgerp/types/simulation/simulationprocessor.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/simulationprocessor.js +2 -0
- package/dist/sgerp/types/simulation/vehicle.js +2 -1
- package/dist/sgerp/types/simulation/vehicletype.d.ts +33 -0
- package/dist/sgerp/types/simulation/vehicletype.d.ts.map +1 -0
- package/dist/sgerp/types/simulation/vehicletype.js +2 -0
- package/dist/sgerp/types/sms_notify/smsscheduled.d.ts +36 -0
- package/dist/sgerp/types/sms_notify/smsscheduled.d.ts.map +1 -0
- package/dist/sgerp/types/sms_notify/smsscheduled.js +6 -0
- package/dist/sgerp/types/transportation/passenger.d.ts +49 -0
- package/dist/sgerp/types/transportation/passenger.d.ts.map +1 -0
- package/dist/sgerp/types/transportation/passenger.js +13 -0
- package/dist/sgerp/types/transportation/ticket.d.ts +31 -0
- package/dist/sgerp/types/transportation/ticket.d.ts.map +1 -0
- package/dist/sgerp/types/transportation/ticket.js +2 -0
- package/dist/sgerp/types/transportation/transaction.d.ts +71 -0
- package/dist/sgerp/types/transportation/transaction.d.ts.map +1 -0
- package/dist/sgerp/types/transportation/transaction.js +54 -0
- package/dist/sgerp/utils/bookingPayload.d.ts +80 -0
- package/dist/sgerp/utils/bookingPayload.d.ts.map +1 -0
- package/dist/sgerp/utils/bookingPayload.js +44 -0
- package/dist/sgerp/utils/color.d.ts +30 -0
- package/dist/sgerp/utils/color.d.ts.map +1 -0
- package/dist/sgerp/utils/color.js +117 -0
- package/dist/sgerp/utils/enum-helpers.d.ts +41 -0
- package/dist/sgerp/utils/enum-helpers.d.ts.map +1 -0
- package/dist/sgerp/utils/enum-helpers.js +54 -0
- package/dist/sgerp/utils/routeUtils.d.ts +1 -1
- package/dist/sgerp/utils/routeUtils.d.ts.map +1 -1
- package/dist/sgerp/utils/routeUtils.js +171 -0
- package/package.json +1 -1
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SGERPClient = void 0;
|
|
4
|
+
exports.initializeSGERP = initializeSGERP;
|
|
5
|
+
const client_1 = require("./api/client");
|
|
6
|
+
const project_1 = require("./collections/sharing/project");
|
|
7
|
+
const project_member_1 = require("./collections/sharing/project-member");
|
|
8
|
+
const organization_1 = require("./collections/sharing/organization");
|
|
9
|
+
const organization_project_1 = require("./collections/sharing/organization-project");
|
|
10
|
+
const pricing_1 = require("./collections/sharing/pricing");
|
|
11
|
+
const passenger_1 = require("./collections/transportation/passenger");
|
|
12
|
+
const ticket_1 = require("./collections/transportation/ticket");
|
|
13
|
+
const transaction_1 = require("./collections/transportation/transaction");
|
|
14
|
+
const user_1 = require("./collections/account/user");
|
|
15
|
+
const simulation_1 = require("./collections/simulation/simulation");
|
|
16
|
+
const driver_1 = require("./collections/simulation/driver");
|
|
17
|
+
const vehicle_1 = require("./collections/simulation/vehicle");
|
|
18
|
+
const vehicletype_1 = require("./collections/simulation/vehicletype");
|
|
19
|
+
const booking_1 = require("./collections/simulation/booking");
|
|
20
|
+
const node_1 = require("./collections/simulation/node");
|
|
21
|
+
const dataset_1 = require("./collections/simulation/dataset");
|
|
22
|
+
const simulationprocessor_1 = require("./collections/simulation/simulationprocessor");
|
|
23
|
+
const operationslocation_1 = require("./collections/simulation/operationslocation");
|
|
24
|
+
const operationslocationgroup_1 = require("./collections/simulation/operationslocationgroup");
|
|
25
|
+
const routingprofile_1 = require("./collections/simulation/routingprofile");
|
|
26
|
+
const geofence_1 = require("./collections/simulation/geofence");
|
|
27
|
+
const mapboxtoken_1 = require("./collections/simulation/mapboxtoken");
|
|
28
|
+
const smsscheduled_1 = require("./collections/sms_notify/smsscheduled");
|
|
29
|
+
const transitstop_1 = require("./collections/masstransit/transitstop");
|
|
30
|
+
const building_1 = require("./collections/masstransit/building");
|
|
31
|
+
const transitstopset_1 = require("./collections/masstransit/transitstopset");
|
|
32
|
+
const DEFAULT_TIMEOUT = 30000; // 30 seconds
|
|
33
|
+
// Collection Registry - used for type inference only
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
35
|
+
const COLLECTION_REGISTRY = {
|
|
36
|
+
project: project_1.ProjectCollection,
|
|
37
|
+
projectmember: project_member_1.ProjectMemberCollection,
|
|
38
|
+
organization: organization_1.OrganizationCollection,
|
|
39
|
+
organizationproject: organization_project_1.OrganizationProjectCollection,
|
|
40
|
+
pricing: pricing_1.PricingCollection,
|
|
41
|
+
passenger: passenger_1.PassengerCollection,
|
|
42
|
+
ticket: ticket_1.TicketCollection,
|
|
43
|
+
transaction: transaction_1.TransactionCollection,
|
|
44
|
+
user: user_1.UserCollection,
|
|
45
|
+
simulation: simulation_1.SimulationCollection,
|
|
46
|
+
vehicle: vehicle_1.VehicleCollection,
|
|
47
|
+
vehicletype: vehicletype_1.VehicleTypeCollection,
|
|
48
|
+
booking: booking_1.BookingCollection,
|
|
49
|
+
node: node_1.NodeCollection,
|
|
50
|
+
driver: driver_1.DriverCollection,
|
|
51
|
+
dataset: dataset_1.DatasetCollection,
|
|
52
|
+
simulationprocessor: simulationprocessor_1.SimulationProcessorCollection,
|
|
53
|
+
operationslocation: operationslocation_1.OperationsLocationCollection,
|
|
54
|
+
operationslocationgroup: operationslocationgroup_1.OperationsLocationGroupCollection,
|
|
55
|
+
transitstop: transitstop_1.TransitStopCollection,
|
|
56
|
+
routingprofile: routingprofile_1.RoutingProfileCollection,
|
|
57
|
+
geofence: geofence_1.GeofenceCollection,
|
|
58
|
+
mapboxtoken: mapboxtoken_1.MapboxTokenCollection,
|
|
59
|
+
smsscheduled: smsscheduled_1.SMSScheduledCollection,
|
|
60
|
+
building: building_1.BuildingCollection,
|
|
61
|
+
transitstopset: transitstopset_1.TransitStopSetCollection,
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Main SGERP API Client
|
|
65
|
+
*/
|
|
66
|
+
class SGERPClient {
|
|
67
|
+
constructor(config) {
|
|
68
|
+
this._contextCollections = new Map();
|
|
69
|
+
// Validate that activeConnection exists
|
|
70
|
+
if (!config.connections[config.activeConnection]) {
|
|
71
|
+
throw new Error(`Active connection "${config.activeConnection}" not found in connections list`);
|
|
72
|
+
}
|
|
73
|
+
this.config = config;
|
|
74
|
+
// Set the active connection for APIClient to use
|
|
75
|
+
client_1.APIClient._getActiveConnection = () => this.getActiveConnection();
|
|
76
|
+
client_1.APIClient._getTimeout = () => this.getTimeout();
|
|
77
|
+
}
|
|
78
|
+
// ============================================
|
|
79
|
+
// Configuration Methods
|
|
80
|
+
// ============================================
|
|
81
|
+
/**
|
|
82
|
+
* Get the currently active connection
|
|
83
|
+
*/
|
|
84
|
+
getActiveConnection() {
|
|
85
|
+
const connection = this.config.connections[this.config.activeConnection];
|
|
86
|
+
if (!connection) {
|
|
87
|
+
throw new Error(`Active connection "${this.config.activeConnection}" not found`);
|
|
88
|
+
}
|
|
89
|
+
return connection;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get all available connections
|
|
93
|
+
*/
|
|
94
|
+
getAllConnections() {
|
|
95
|
+
return Object.values(this.config.connections);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get a specific connection by ID
|
|
99
|
+
*/
|
|
100
|
+
getConnection(connectionId) {
|
|
101
|
+
return this.config.connections[connectionId];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Switch to a different connection
|
|
105
|
+
*/
|
|
106
|
+
switchConnection(connectionId) {
|
|
107
|
+
if (!this.config.connections[connectionId]) {
|
|
108
|
+
throw new Error(`Connection "${connectionId}" not found`);
|
|
109
|
+
}
|
|
110
|
+
this.config.activeConnection = connectionId;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Add a new connection
|
|
114
|
+
*/
|
|
115
|
+
addConnection(connection) {
|
|
116
|
+
this.config.connections[connection.id] = connection;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Remove a connection
|
|
120
|
+
*/
|
|
121
|
+
removeConnection(connectionId) {
|
|
122
|
+
if (this.config.activeConnection === connectionId) {
|
|
123
|
+
throw new Error('Cannot remove the currently active connection');
|
|
124
|
+
}
|
|
125
|
+
delete this.config.connections[connectionId];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Update password for a connection
|
|
129
|
+
*/
|
|
130
|
+
updateConnectionPassword(connectionId, password) {
|
|
131
|
+
const connection = this.config.connections[connectionId];
|
|
132
|
+
if (!connection) {
|
|
133
|
+
throw new Error(`Connection "${connectionId}" not found`);
|
|
134
|
+
}
|
|
135
|
+
connection.password = password;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get the global timeout value
|
|
139
|
+
*/
|
|
140
|
+
getTimeout() {
|
|
141
|
+
return this.config.timeout || DEFAULT_TIMEOUT;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get the base URL for the active connection
|
|
145
|
+
*/
|
|
146
|
+
getBaseUrl() {
|
|
147
|
+
return this.getActiveConnection().baseUrl;
|
|
148
|
+
}
|
|
149
|
+
// ============================================
|
|
150
|
+
// Collections Access
|
|
151
|
+
// ============================================
|
|
152
|
+
/**
|
|
153
|
+
* Access collections via api.collections.project, api.collections.projectmember, api.collections.passenger, api.collections.user, or api.collections.simulation
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* const projects = api.collections.project;
|
|
157
|
+
* await projects.fetch({ limit: 20 });
|
|
158
|
+
* const project = projects.get(1);
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* const members = api.collections.projectmember;
|
|
162
|
+
* await members.fetch({ limit: 100 });
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* const passengers = api.collections.passenger;
|
|
166
|
+
* await passengers.fetch({ limit: 50 });
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* const simulations = api.collections.simulation;
|
|
170
|
+
* await simulations.fetch({ limit: 10 });
|
|
171
|
+
*/
|
|
172
|
+
get collections() {
|
|
173
|
+
if (!this._collections) {
|
|
174
|
+
this._collections = {
|
|
175
|
+
project: this.Collection('project'),
|
|
176
|
+
projectmember: this.Collection('projectmember'),
|
|
177
|
+
organization: this.Collection('organization'),
|
|
178
|
+
organizationproject: this.Collection('organizationproject'),
|
|
179
|
+
pricing: this.Collection('pricing'),
|
|
180
|
+
passenger: this.Collection('passenger'),
|
|
181
|
+
ticket: this.Collection('ticket'),
|
|
182
|
+
transaction: this.Collection('transaction'),
|
|
183
|
+
user: this.Collection('user'),
|
|
184
|
+
simulation: this.Collection('simulation'),
|
|
185
|
+
vehicle: this.Collection('vehicle'),
|
|
186
|
+
vehicletype: this.Collection('vehicletype'),
|
|
187
|
+
booking: this.Collection('booking'),
|
|
188
|
+
node: this.Collection('node'),
|
|
189
|
+
driver: this.Collection('driver'),
|
|
190
|
+
dataset: this.Collection('dataset'),
|
|
191
|
+
simulationprocessor: this.Collection('simulationprocessor'),
|
|
192
|
+
operationslocation: this.Collection('operationslocation'),
|
|
193
|
+
operationslocationgroup: this.Collection('operationslocationgroup'),
|
|
194
|
+
transitstop: this.Collection('transitstop'),
|
|
195
|
+
routingprofile: this.Collection('routingprofile'),
|
|
196
|
+
geofence: this.Collection('geofence'),
|
|
197
|
+
mapboxtoken: this.Collection('mapboxtoken'),
|
|
198
|
+
smsscheduled: this.Collection('smsscheduled'),
|
|
199
|
+
building: this.Collection('building'),
|
|
200
|
+
transitstopset: this.Collection('transitstopset'),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
return this._collections;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get or create a context-specific collection instance
|
|
207
|
+
* Allows multiple independent collections of the same type
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* // Get separate collections for services and templates
|
|
211
|
+
* const services = api.getCollection('simulation', 'services');
|
|
212
|
+
* const templates = api.getCollection('simulation', 'templates');
|
|
213
|
+
*
|
|
214
|
+
* // Each maintains its own data independently
|
|
215
|
+
* await services.fetch({ simulation_mode: 'service' });
|
|
216
|
+
* await templates.fetch({ simulation_mode: 'template' });
|
|
217
|
+
*/
|
|
218
|
+
getCollection(modelType, context) {
|
|
219
|
+
// If no context, return the default collection
|
|
220
|
+
if (!context) {
|
|
221
|
+
return this.collections[modelType];
|
|
222
|
+
}
|
|
223
|
+
// Check if context collection already exists
|
|
224
|
+
const key = `${modelType}:${context}`;
|
|
225
|
+
if (!this._contextCollections.has(key)) {
|
|
226
|
+
// @ts-expect-error - Complex overload resolution issue
|
|
227
|
+
this._contextCollections.set(key, this.Collection(modelType));
|
|
228
|
+
}
|
|
229
|
+
return this._contextCollections.get(key);
|
|
230
|
+
}
|
|
231
|
+
Collection(modelType) {
|
|
232
|
+
if (modelType === 'project') {
|
|
233
|
+
return new project_1.ProjectCollection((params, config) => this.getModels('project', params, config));
|
|
234
|
+
}
|
|
235
|
+
else if (modelType === 'projectmember') {
|
|
236
|
+
return new project_member_1.ProjectMemberCollection((params, config) => this.getModels('projectmember', params, config));
|
|
237
|
+
}
|
|
238
|
+
else if (modelType === 'organization') {
|
|
239
|
+
return new organization_1.OrganizationCollection((params, config) => this.getModels('organization', params, config));
|
|
240
|
+
}
|
|
241
|
+
else if (modelType === 'organizationproject') {
|
|
242
|
+
return new organization_project_1.OrganizationProjectCollection((params, config) => this.getModels('organizationproject', params, config));
|
|
243
|
+
}
|
|
244
|
+
else if (modelType === 'pricing') {
|
|
245
|
+
return new pricing_1.PricingCollection((params, config) => this.getModels('pricing', params, config));
|
|
246
|
+
}
|
|
247
|
+
else if (modelType === 'passenger') {
|
|
248
|
+
return new passenger_1.PassengerCollection((params, config) => this.getModels('passenger', params, config));
|
|
249
|
+
}
|
|
250
|
+
else if (modelType === 'ticket') {
|
|
251
|
+
return new ticket_1.TicketCollection((params, config) => this.getModels('ticket', params, config));
|
|
252
|
+
}
|
|
253
|
+
else if (modelType === 'transaction') {
|
|
254
|
+
return new transaction_1.TransactionCollection((params, config) => this.getModels('transaction', params, config));
|
|
255
|
+
}
|
|
256
|
+
else if (modelType === 'user') {
|
|
257
|
+
return new user_1.UserCollection((params, config) => this.getModels('user', params, config));
|
|
258
|
+
}
|
|
259
|
+
else if (modelType === 'simulation') {
|
|
260
|
+
return new simulation_1.SimulationCollection((params, config) => this.getModels('simulation', params, config), (params, config) => this.getModels('simulation', params, config), (params, config) => this.getModels('project', params, config));
|
|
261
|
+
}
|
|
262
|
+
else if (modelType === 'vehicle') {
|
|
263
|
+
return new vehicle_1.VehicleCollection((params, config) => this.getModels('vehicle', params, config));
|
|
264
|
+
}
|
|
265
|
+
else if (modelType === 'vehicletype') {
|
|
266
|
+
return new vehicletype_1.VehicleTypeCollection((params, config) => this.getModels('vehicletype', params, config));
|
|
267
|
+
}
|
|
268
|
+
else if (modelType === 'booking') {
|
|
269
|
+
return new booking_1.BookingCollection((params, config) => this.getModels('booking', params, config));
|
|
270
|
+
}
|
|
271
|
+
else if (modelType === 'node') {
|
|
272
|
+
return new node_1.NodeCollection((params, config) => this.getModels('node', params, config));
|
|
273
|
+
}
|
|
274
|
+
else if (modelType === 'driver') {
|
|
275
|
+
return new driver_1.DriverCollection((params, config) => this.getModels('driver', params, config), (params, config) => this.getModels('user', params, config), (params, config) => this.getModels('projectmember', params, config));
|
|
276
|
+
}
|
|
277
|
+
else if (modelType === 'dataset') {
|
|
278
|
+
return new dataset_1.DatasetCollection((params, config) => this.getModels('dataset', params, config));
|
|
279
|
+
}
|
|
280
|
+
else if (modelType === 'simulationprocessor') {
|
|
281
|
+
return new simulationprocessor_1.SimulationProcessorCollection((params, config) => this.getModels('simulationprocessor', params, config));
|
|
282
|
+
}
|
|
283
|
+
else if (modelType === 'operationslocation') {
|
|
284
|
+
return new operationslocation_1.OperationsLocationCollection((params, config) => this.getModels('operationslocation', params, config), (params, config) => this.getModels('project', params, config));
|
|
285
|
+
}
|
|
286
|
+
else if (modelType === 'operationslocationgroup') {
|
|
287
|
+
return new operationslocationgroup_1.OperationsLocationGroupCollection((params, config) => this.getModels('operationslocationgroup', params, config), (params, config) => this.getModels('project', params, config));
|
|
288
|
+
}
|
|
289
|
+
else if (modelType === 'transitstop') {
|
|
290
|
+
return new transitstop_1.TransitStopCollection((params, config) => this.getModels('transitstop', params, config));
|
|
291
|
+
}
|
|
292
|
+
else if (modelType === 'routingprofile') {
|
|
293
|
+
return new routingprofile_1.RoutingProfileCollection((params, config) => this.getModels('routingprofile', params, config));
|
|
294
|
+
}
|
|
295
|
+
else if (modelType === 'geofence') {
|
|
296
|
+
return new geofence_1.GeofenceCollection((params, config) => this.getModels('geofence', params, config));
|
|
297
|
+
}
|
|
298
|
+
else if (modelType === 'mapboxtoken') {
|
|
299
|
+
return new mapboxtoken_1.MapboxTokenCollection((params, config) => this.getModels('mapboxtoken', params, config));
|
|
300
|
+
}
|
|
301
|
+
else if (modelType === 'smsscheduled') {
|
|
302
|
+
return new smsscheduled_1.SMSScheduledCollection((params, config) => this.getModels('smsscheduled', params, config));
|
|
303
|
+
}
|
|
304
|
+
else if (modelType === 'building') {
|
|
305
|
+
return new building_1.BuildingCollection((params, config) => this.getModels('building', params, config));
|
|
306
|
+
}
|
|
307
|
+
else if (modelType === 'transitstopset') {
|
|
308
|
+
return new transitstopset_1.TransitStopSetCollection((params, config) => this.getModels('transitstopset', params, config));
|
|
309
|
+
}
|
|
310
|
+
throw new Error(`Unknown model type: ${modelType}`);
|
|
311
|
+
}
|
|
312
|
+
// ============================================
|
|
313
|
+
// Internal API Methods (used by Collections)
|
|
314
|
+
// ============================================
|
|
315
|
+
/**
|
|
316
|
+
* Generic method to fetch models from the API
|
|
317
|
+
* @private
|
|
318
|
+
*/
|
|
319
|
+
async getModels(modelType, params, config) {
|
|
320
|
+
const queryParams = {
|
|
321
|
+
model: modelType,
|
|
322
|
+
};
|
|
323
|
+
if (params && typeof params === 'object' && params !== null) {
|
|
324
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
325
|
+
if (value !== undefined) {
|
|
326
|
+
queryParams[key] = String(value);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
const searchParams = new URLSearchParams(queryParams);
|
|
331
|
+
const response = await client_1.APIClient.get(`/api/v2/microservices/get?${searchParams.toString()}`, config);
|
|
332
|
+
return response.data;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
exports.SGERPClient = SGERPClient;
|
|
336
|
+
/**
|
|
337
|
+
* Initialize SGERP library and return a client instance
|
|
338
|
+
*/
|
|
339
|
+
function initializeSGERP(config) {
|
|
340
|
+
return new SGERPClient(config);
|
|
341
|
+
}
|