@de./sdk 1.0.4 → 2.0.0
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/allend/Access.d.ts +39 -3
- package/dist/allend/Access.js +147 -114
- package/dist/allend/Access.js.map +1 -1
- package/dist/allend/Agent/consolidation.d.ts +16 -0
- package/dist/allend/Agent/consolidation.js +38 -0
- package/dist/allend/Agent/consolidation.js.map +1 -0
- package/dist/allend/Agent/delivery.d.ts +11 -0
- package/dist/allend/Agent/delivery.js +43 -0
- package/dist/allend/Agent/delivery.js.map +1 -0
- package/dist/allend/Agent/dispatch.d.ts +8 -0
- package/dist/allend/Agent/dispatch.js +24 -0
- package/dist/allend/Agent/dispatch.js.map +1 -0
- package/dist/allend/Agent/index.d.ts +49 -0
- package/dist/allend/Agent/index.js +74 -0
- package/dist/allend/Agent/index.js.map +1 -0
- package/dist/allend/Agent/navigation.d.ts +8 -0
- package/dist/allend/Agent/navigation.js +25 -0
- package/dist/allend/Agent/navigation.js.map +1 -0
- package/dist/allend/Agent/origin.d.ts +9 -0
- package/dist/allend/Agent/origin.js +31 -0
- package/dist/allend/Agent/origin.js.map +1 -0
- package/dist/allend/Agent/reallocation.d.ts +7 -0
- package/dist/allend/Agent/reallocation.js +17 -0
- package/dist/allend/Agent/reallocation.js.map +1 -0
- package/dist/allend/Agent/realtime.d.ts +36 -0
- package/dist/allend/Agent/realtime.js +111 -0
- package/dist/allend/Agent/realtime.js.map +1 -0
- package/dist/allend/Agent/rides.d.ts +12 -0
- package/dist/allend/Agent/rides.js +51 -0
- package/dist/allend/Agent/rides.js.map +1 -0
- package/dist/allend/Agent/shipping.d.ts +11 -0
- package/dist/allend/Agent/shipping.js +43 -0
- package/dist/allend/Agent/shipping.js.map +1 -0
- package/dist/allend/CSP/analytics.d.ts +12 -0
- package/dist/allend/CSP/analytics.js +51 -0
- package/dist/allend/CSP/analytics.js.map +1 -0
- package/dist/allend/CSP/index.d.ts +25 -0
- package/dist/allend/CSP/index.js +43 -0
- package/dist/allend/CSP/index.js.map +1 -0
- package/dist/allend/CSP/inventory.d.ts +16 -0
- package/dist/allend/CSP/inventory.js +78 -0
- package/dist/allend/CSP/inventory.js.map +1 -0
- package/dist/allend/CSP/orders.d.ts +19 -0
- package/dist/allend/CSP/orders.js +97 -0
- package/dist/allend/CSP/orders.js.map +1 -0
- package/dist/allend/CSP/webhooks.d.ts +13 -0
- package/dist/allend/CSP/webhooks.js +56 -0
- package/dist/allend/CSP/webhooks.js.map +1 -0
- package/dist/allend/Customer/index.d.ts +27 -0
- package/dist/allend/Customer/index.js +39 -0
- package/dist/allend/Customer/index.js.map +1 -0
- package/dist/allend/Customer/intents.d.ts +12 -0
- package/dist/allend/Customer/intents.js +55 -0
- package/dist/allend/Customer/intents.js.map +1 -0
- package/dist/allend/Customer/orders.d.ts +11 -0
- package/dist/allend/Customer/orders.js +43 -0
- package/dist/allend/Customer/orders.js.map +1 -0
- package/dist/allend/Customer/rides.d.ts +12 -0
- package/dist/allend/Customer/rides.js +50 -0
- package/dist/allend/Customer/rides.js.map +1 -0
- package/dist/allend/DEV/developers.d.ts +11 -0
- package/dist/allend/DEV/developers.js +35 -0
- package/dist/allend/DEV/developers.js.map +1 -0
- package/dist/allend/DEV/index.d.ts +19 -0
- package/dist/allend/DEV/index.js +37 -0
- package/dist/allend/DEV/index.js.map +1 -0
- package/dist/allend/IoTClient.js +29 -35
- package/dist/allend/IoTClient.js.map +1 -1
- package/dist/allend/IoTSP/backend.d.ts +29 -0
- package/dist/allend/IoTSP/backend.js +75 -0
- package/dist/allend/IoTSP/backend.js.map +1 -0
- package/dist/allend/IoTSP/devices.d.ts +14 -0
- package/dist/allend/IoTSP/devices.js +61 -0
- package/dist/allend/IoTSP/devices.js.map +1 -0
- package/dist/allend/IoTSP/index.d.ts +28 -0
- package/dist/allend/IoTSP/index.js +84 -0
- package/dist/allend/IoTSP/index.js.map +1 -0
- package/dist/allend/IoTSP/rules.d.ts +17 -0
- package/dist/allend/IoTSP/rules.js +81 -0
- package/dist/allend/IoTSP/rules.js.map +1 -0
- package/dist/allend/IoTSP/topics.d.ts +17 -0
- package/dist/allend/IoTSP/topics.js +81 -0
- package/dist/allend/IoTSP/topics.js.map +1 -0
- package/dist/allend/LSP/agents.d.ts +20 -0
- package/dist/allend/LSP/agents.js +89 -0
- package/dist/allend/LSP/agents.js.map +1 -0
- package/dist/allend/LSP/carriers.d.ts +54 -0
- package/dist/allend/LSP/carriers.js +315 -0
- package/dist/allend/LSP/carriers.js.map +1 -0
- package/dist/allend/LSP/coverage.d.ts +44 -0
- package/dist/allend/LSP/coverage.js +135 -0
- package/dist/allend/LSP/coverage.js.map +1 -0
- package/dist/allend/LSP/fleets.d.ts +66 -0
- package/dist/allend/LSP/fleets.js +381 -0
- package/dist/allend/LSP/fleets.js.map +1 -0
- package/dist/allend/LSP/hubs.d.ts +39 -0
- package/dist/allend/LSP/hubs.js +186 -0
- package/dist/allend/LSP/hubs.js.map +1 -0
- package/dist/allend/LSP/index.d.ts +37 -0
- package/dist/allend/LSP/index.js +55 -0
- package/dist/allend/LSP/index.js.map +1 -0
- package/dist/allend/LSP/inventory.d.ts +13 -0
- package/dist/allend/LSP/inventory.js +56 -0
- package/dist/allend/LSP/inventory.js.map +1 -0
- package/dist/allend/LSP/operations.d.ts +47 -0
- package/dist/allend/LSP/operations.js +156 -0
- package/dist/allend/LSP/operations.js.map +1 -0
- package/dist/allend/LSP/orders.d.ts +69 -0
- package/dist/allend/LSP/orders.js +303 -0
- package/dist/allend/LSP/orders.js.map +1 -0
- package/dist/allend/LSP/pods.d.ts +26 -0
- package/dist/allend/LSP/pods.js +137 -0
- package/dist/allend/LSP/pods.js.map +1 -0
- package/dist/allend/LSP/pricing.d.ts +35 -0
- package/dist/allend/LSP/pricing.js +151 -0
- package/dist/allend/LSP/pricing.js.map +1 -0
- package/dist/allend/LSP/psl.d.ts +15 -0
- package/dist/allend/LSP/psl.js +68 -0
- package/dist/allend/LSP/psl.js.map +1 -0
- package/dist/allend/LSP/warehouses.d.ts +23 -0
- package/dist/allend/LSP/warehouses.js +94 -0
- package/dist/allend/LSP/warehouses.js.map +1 -0
- package/dist/allend/MSI/Controls.d.ts +9 -5
- package/dist/allend/MSI/Controls.js +269 -297
- package/dist/allend/MSI/Controls.js.map +1 -1
- package/dist/allend/MSI/Handles.d.ts +5 -4
- package/dist/allend/MSI/Handles.js +136 -233
- package/dist/allend/MSI/Handles.js.map +1 -1
- package/dist/allend/MSI/Plugins.d.ts +2 -2
- package/dist/allend/MSI/Plugins.js +12 -15
- package/dist/allend/MSI/Plugins.js.map +1 -1
- package/dist/allend/MSI/index.d.ts +4 -3
- package/dist/allend/MSI/index.js +123 -87
- package/dist/allend/MSI/index.js.map +1 -1
- package/dist/allend/MSI/native.d.ts +32 -0
- package/dist/allend/MSI/native.js +246 -0
- package/dist/allend/MSI/native.js.map +1 -0
- package/dist/allend/MSI/token.d.ts +12 -0
- package/dist/allend/MSI/token.js +21 -0
- package/dist/allend/MSI/token.js.map +1 -0
- package/dist/allend/OTPAuth/index.d.ts +77 -0
- package/dist/allend/OTPAuth/index.js +69 -0
- package/dist/allend/OTPAuth/index.js.map +1 -0
- package/dist/allend/Pipelines/analytics.d.ts +8 -0
- package/dist/allend/Pipelines/analytics.js +24 -0
- package/dist/allend/Pipelines/analytics.js.map +1 -0
- package/dist/allend/Pipelines/escalations.d.ts +8 -0
- package/dist/allend/Pipelines/escalations.js +25 -0
- package/dist/allend/Pipelines/escalations.js.map +1 -0
- package/dist/allend/Pipelines/executions.d.ts +11 -0
- package/dist/allend/Pipelines/executions.js +44 -0
- package/dist/allend/Pipelines/executions.js.map +1 -0
- package/dist/allend/Pipelines/index.d.ts +42 -0
- package/dist/allend/Pipelines/index.js +88 -0
- package/dist/allend/Pipelines/index.js.map +1 -0
- package/dist/allend/Pipelines/interventions.d.ts +8 -0
- package/dist/allend/Pipelines/interventions.js +25 -0
- package/dist/allend/Pipelines/interventions.js.map +1 -0
- package/dist/allend/Pipelines/monitor.d.ts +9 -0
- package/dist/allend/Pipelines/monitor.js +30 -0
- package/dist/allend/Pipelines/monitor.js.map +1 -0
- package/dist/allend/Pipelines/queries.d.ts +8 -0
- package/dist/allend/Pipelines/queries.js +25 -0
- package/dist/allend/Pipelines/queries.js.map +1 -0
- package/dist/allend/Pipelines/templates.d.ts +11 -0
- package/dist/allend/Pipelines/templates.js +46 -0
- package/dist/allend/Pipelines/templates.js.map +1 -0
- package/dist/allend/Pipelines/utils.d.ts +0 -0
- package/dist/allend/Pipelines/utils.js +2 -0
- package/dist/allend/Pipelines/utils.js.map +1 -0
- package/dist/allend/Pipelines/webhooks.d.ts +9 -0
- package/dist/allend/Pipelines/webhooks.js +35 -0
- package/dist/allend/Pipelines/webhooks.js.map +1 -0
- package/dist/allend/Pipelines/workers.d.ts +11 -0
- package/dist/allend/Pipelines/workers.js +45 -0
- package/dist/allend/Pipelines/workers.js.map +1 -0
- package/dist/allend/Queries/capacity.d.ts +11 -0
- package/dist/allend/Queries/capacity.js +44 -0
- package/dist/allend/Queries/capacity.js.map +1 -0
- package/dist/allend/Queries/discovery.d.ts +11 -0
- package/dist/allend/Queries/discovery.js +45 -0
- package/dist/allend/Queries/discovery.js.map +1 -0
- package/dist/allend/Queries/index.d.ts +27 -0
- package/dist/allend/Queries/index.js +40 -0
- package/dist/allend/Queries/index.js.map +1 -0
- package/dist/allend/Queries/matching.d.ts +7 -0
- package/dist/allend/Queries/matching.js +18 -0
- package/dist/allend/Queries/matching.js.map +1 -0
- package/dist/allend/Queries/performance.d.ts +9 -0
- package/dist/allend/Queries/performance.js +31 -0
- package/dist/allend/Queries/performance.js.map +1 -0
- package/dist/allend/Queries/pricing.d.ts +11 -0
- package/dist/allend/Queries/pricing.js +43 -0
- package/dist/allend/Queries/pricing.js.map +1 -0
- package/dist/allend/{DClient/Event.d.ts → Realtime/index.d.ts} +2 -6
- package/dist/allend/Realtime/index.js +62 -0
- package/dist/allend/Realtime/index.js.map +1 -0
- package/dist/allend/Shared/account.d.ts +10 -0
- package/dist/allend/Shared/account.js +22 -0
- package/dist/allend/Shared/account.js.map +1 -0
- package/dist/allend/Shared/buckets.d.ts +21 -0
- package/dist/allend/Shared/buckets.js +95 -0
- package/dist/allend/Shared/buckets.js.map +1 -0
- package/dist/allend/Shared/context.d.ts +14 -0
- package/dist/allend/Shared/context.js +33 -0
- package/dist/allend/Shared/context.js.map +1 -0
- package/dist/allend/Shared/faqs.d.ts +20 -0
- package/dist/allend/Shared/faqs.js +87 -0
- package/dist/allend/Shared/faqs.js.map +1 -0
- package/dist/allend/Shared/invitation.d.ts +42 -0
- package/dist/allend/Shared/invitation.js +40 -0
- package/dist/allend/Shared/invitation.js.map +1 -0
- package/dist/allend/Shared/operators.d.ts +39 -0
- package/dist/allend/Shared/operators.js +37 -0
- package/dist/allend/Shared/operators.js.map +1 -0
- package/dist/allend/Shared/users.d.ts +11 -0
- package/dist/allend/Shared/users.js +29 -0
- package/dist/allend/Shared/users.js.map +1 -0
- package/dist/allend/Tracking/index.d.ts +17 -0
- package/dist/allend/Tracking/index.js +39 -0
- package/dist/allend/Tracking/index.js.map +1 -0
- package/dist/allend/Utilities/common.d.ts +12 -0
- package/dist/allend/Utilities/common.js +53 -0
- package/dist/allend/Utilities/common.js.map +1 -0
- package/dist/allend/Utilities/fares.d.ts +10 -0
- package/dist/allend/Utilities/fares.js +39 -0
- package/dist/allend/Utilities/fares.js.map +1 -0
- package/dist/allend/Utilities/index.d.ts +23 -0
- package/dist/allend/Utilities/index.js +36 -0
- package/dist/allend/Utilities/index.js.map +1 -0
- package/dist/allend/Utilities/nearby.d.ts +9 -0
- package/dist/allend/Utilities/nearby.js +32 -0
- package/dist/allend/Utilities/nearby.js.map +1 -0
- package/dist/allend/Workflows/Client.d.ts +17 -0
- package/dist/allend/Workflows/Client.js +50 -0
- package/dist/allend/Workflows/Client.js.map +1 -0
- package/dist/allend/Workflows/Delivery.d.ts +36 -0
- package/dist/allend/Workflows/Delivery.js +16 -0
- package/dist/allend/Workflows/Delivery.js.map +1 -0
- package/dist/allend/Workflows/index.d.ts +11 -0
- package/dist/allend/Workflows/index.js +25 -0
- package/dist/allend/Workflows/index.js.map +1 -0
- package/dist/allend/Workspace/index.d.ts +162 -0
- package/dist/allend/Workspace/index.js +220 -0
- package/dist/allend/Workspace/index.js.map +1 -0
- package/dist/allend/index.d.ts +8 -5
- package/dist/allend/index.js +15 -8
- package/dist/allend/index.js.map +1 -1
- package/dist/backend/Auth.d.ts +28 -4
- package/dist/backend/Auth.js +125 -245
- package/dist/backend/Auth.js.map +1 -1
- package/dist/baseUrl.d.ts +56 -0
- package/dist/baseUrl.js +72 -4
- package/dist/baseUrl.js.map +1 -1
- package/dist/core.d.ts +88 -0
- package/dist/core.js +121 -0
- package/dist/core.js.map +1 -0
- package/dist/error.d.ts +17 -0
- package/dist/error.js +26 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +30 -12
- package/dist/index.js +38 -14
- package/dist/index.js.map +1 -1
- package/dist/react-native.d.ts +30 -0
- package/dist/react-native.js +55 -0
- package/dist/react-native.js.map +1 -0
- package/dist/types/access.d.ts +64 -7
- package/dist/types/auth.d.ts +17 -17
- package/dist/types/channel.d.ts +45 -0
- package/dist/types/index.d.ts +379 -237
- package/dist/utils/index.d.ts +25 -0
- package/dist/utils/index.js +11 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/stream.js +25 -26
- package/dist/utils/stream.js.map +1 -1
- package/package.json +38 -18
- package/src/allend/Access.ts +143 -13
- package/src/allend/Agent/consolidation.ts +43 -0
- package/src/allend/Agent/delivery.ts +51 -0
- package/src/allend/Agent/dispatch.ts +27 -0
- package/src/allend/Agent/index.ts +113 -0
- package/src/allend/Agent/navigation.ts +27 -0
- package/src/allend/Agent/origin.ts +36 -0
- package/src/allend/Agent/reallocation.ts +16 -0
- package/src/allend/Agent/realtime.ts +140 -0
- package/src/allend/Agent/rides.ts +61 -0
- package/src/allend/Agent/shipping.ts +51 -0
- package/src/allend/CSP/analytics.ts +61 -0
- package/src/allend/CSP/index.ts +57 -0
- package/src/allend/CSP/inventory.ts +96 -0
- package/src/allend/CSP/orders.ts +121 -0
- package/src/allend/CSP/webhooks.ts +68 -0
- package/src/allend/Customer/index.ts +56 -0
- package/src/allend/Customer/intents.ts +66 -0
- package/src/allend/Customer/orders.ts +51 -0
- package/src/allend/Customer/rides.ts +60 -0
- package/src/allend/DEV/developers.ts +42 -0
- package/src/allend/DEV/index.ts +48 -0
- package/src/allend/IoTSP/backend.ts +103 -0
- package/src/allend/IoTSP/devices.ts +74 -0
- package/src/allend/IoTSP/index.ts +69 -0
- package/src/allend/IoTSP/rules.ts +99 -0
- package/src/allend/IoTSP/topics.ts +99 -0
- package/src/allend/LSP/agents.ts +115 -0
- package/src/allend/LSP/carriers.ts +408 -0
- package/src/allend/LSP/coverage.ts +212 -0
- package/src/allend/LSP/fleets.ts +505 -0
- package/src/allend/LSP/hubs.ts +245 -0
- package/src/allend/LSP/index.ts +75 -0
- package/src/allend/LSP/inventory.ts +65 -0
- package/src/allend/LSP/operations.ts +202 -0
- package/src/allend/LSP/orders.ts +397 -0
- package/src/allend/LSP/pods.ts +176 -0
- package/src/allend/LSP/pricing.ts +192 -0
- package/src/allend/LSP/psl.ts +81 -0
- package/src/allend/LSP/warehouses.ts +118 -0
- package/src/allend/MSI/Controls.ts +109 -90
- package/src/allend/MSI/Handles.ts +24 -15
- package/src/allend/MSI/Plugins.ts +3 -3
- package/src/allend/MSI/index.ts +85 -16
- package/src/allend/MSI/native.tsx +314 -0
- package/src/allend/MSI/token.ts +20 -0
- package/src/allend/OTPAuth/index.ts +130 -0
- package/src/allend/Pipelines/analytics.ts +25 -0
- package/src/allend/Pipelines/escalations.ts +26 -0
- package/src/allend/Pipelines/executions.ts +51 -0
- package/src/allend/Pipelines/index.ts +125 -0
- package/src/allend/Pipelines/interventions.ts +27 -0
- package/src/allend/Pipelines/monitor.ts +33 -0
- package/src/allend/Pipelines/queries.ts +27 -0
- package/src/allend/Pipelines/templates.ts +51 -0
- package/src/allend/Pipelines/utils.ts +0 -0
- package/src/allend/Pipelines/webhooks.ts +36 -0
- package/src/allend/Pipelines/workers.ts +49 -0
- package/src/allend/Queries/capacity.ts +51 -0
- package/src/allend/Queries/discovery.ts +53 -0
- package/src/allend/Queries/index.ts +58 -0
- package/src/allend/Queries/matching.ts +16 -0
- package/src/allend/Queries/performance.ts +35 -0
- package/src/allend/Queries/pricing.ts +51 -0
- package/src/allend/{DClient/Event.ts → Realtime/index.ts} +23 -22
- package/src/allend/Shared/account.ts +24 -0
- package/src/allend/Shared/buckets.ts +117 -0
- package/src/allend/Shared/context.ts +36 -0
- package/src/allend/Shared/faqs.ts +106 -0
- package/src/allend/Shared/invitation.ts +77 -0
- package/src/allend/Shared/operators.ts +84 -0
- package/src/allend/Shared/users.ts +32 -0
- package/src/allend/Tracking/index.ts +48 -0
- package/src/allend/Utilities/common.ts +63 -0
- package/src/allend/Utilities/fares.ts +45 -0
- package/src/allend/Utilities/index.ts +52 -0
- package/src/allend/Utilities/nearby.ts +36 -0
- package/src/allend/{DClient → Workflows}/Client.ts +12 -22
- package/src/allend/Workflows/Delivery.ts +94 -0
- package/src/allend/Workflows/index.ts +31 -0
- package/src/allend/Workspace/index.ts +302 -0
- package/src/allend/index.ts +23 -10
- package/src/backend/Auth.ts +68 -35
- package/src/baseUrl.ts +81 -7
- package/src/core.ts +145 -0
- package/src/error.ts +27 -0
- package/src/index.ts +25 -17
- package/src/react-native.ts +43 -0
- package/src/types/access.d.ts +64 -7
- package/src/types/auth.d.ts +17 -17
- package/src/types/channel.d.ts +45 -0
- package/src/types/index.d.ts +379 -237
- package/src/utils/index.ts +33 -1
- package/dist/allend/DAuth/index.d.ts +0 -20
- package/dist/allend/DAuth/index.js +0 -92
- package/dist/allend/DAuth/index.js.map +0 -1
- package/dist/allend/DClient/Client.d.ts +0 -10
- package/dist/allend/DClient/Client.js +0 -144
- package/dist/allend/DClient/Client.js.map +0 -1
- package/dist/allend/DClient/Event.js +0 -100
- package/dist/allend/DClient/Event.js.map +0 -1
- package/dist/allend/DClient/Order.d.ts +0 -49
- package/dist/allend/DClient/Order.js +0 -601
- package/dist/allend/DClient/Order.js.map +0 -1
- package/dist/bundle.js +0 -1
- package/src/allend/DAuth/index.ts +0 -39
- package/src/allend/DClient/Order.ts +0 -452
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { AccessOptions, UserSession } from '../../types/access'
|
|
2
|
+
import type {
|
|
3
|
+
AgentInfoValidation,
|
|
4
|
+
AgentAvailabilityValidation,
|
|
5
|
+
AgentUpdateValidation
|
|
6
|
+
} from '@de./types'
|
|
7
|
+
import AccessManager from '../Access'
|
|
8
|
+
import { type Res, type Data } from '../../utils'
|
|
9
|
+
import AgentRides from './rides'
|
|
10
|
+
import AgentDelivery from './delivery'
|
|
11
|
+
import AgentShipping from './shipping'
|
|
12
|
+
import AgentNavigation from './navigation'
|
|
13
|
+
import AgentConsolidation from './consolidation'
|
|
14
|
+
import AgentReallocation from './reallocation'
|
|
15
|
+
import AgentDispatch from './dispatch'
|
|
16
|
+
import AgentOrigin from './origin'
|
|
17
|
+
import AgentRealtime from './realtime'
|
|
18
|
+
|
|
19
|
+
export type AgentConfig = {
|
|
20
|
+
context: string
|
|
21
|
+
accessToken: string
|
|
22
|
+
env?: 'dev' | 'staging' | 'prod'
|
|
23
|
+
platform?: 'web' | 'mobile' | 'server' | 'proxy'
|
|
24
|
+
remoteOrigin?: string
|
|
25
|
+
/** Per-request deadline in ms. See `AccessOptions.timeout`. */
|
|
26
|
+
timeout?: number
|
|
27
|
+
/** Explicit service origin, overriding the env table. See `AccessOptions.baseUrl`. */
|
|
28
|
+
baseUrl?: string
|
|
29
|
+
/** Host to substitute for `localhost` in `dev` (Eg. a native emulator) */
|
|
30
|
+
devHostname?: string
|
|
31
|
+
/**
|
|
32
|
+
* The signed-in rider.
|
|
33
|
+
*
|
|
34
|
+
* Required in practice: AUX agent routes authenticate the caller with
|
|
35
|
+
* `isConnected` + `isAgent`, which read `de-auth-token` / `de-auth-device`
|
|
36
|
+
* and ignore the bearer token entirely. Without this, every call here
|
|
37
|
+
* fails authorization no matter how valid the access token is.
|
|
38
|
+
*/
|
|
39
|
+
session?: UserSession
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
43
|
+
//
|
|
44
|
+
// Agent: Agent Operation Interfaces — de.arch AUX/agent routes.
|
|
45
|
+
// Covers profile, availability, orders (ride/delivery/shipping),
|
|
46
|
+
// navigation, consolidation, reallocation, dispatch, and origin — plus the
|
|
47
|
+
// realtime socket channel (order rooms + proactive-consolidation responses).
|
|
48
|
+
//
|
|
49
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
export default class Agent extends AccessManager {
|
|
52
|
+
readonly rides: AgentRides
|
|
53
|
+
readonly delivery: AgentDelivery
|
|
54
|
+
readonly shipping: AgentShipping
|
|
55
|
+
readonly navigation: AgentNavigation
|
|
56
|
+
readonly consolidation: AgentConsolidation
|
|
57
|
+
readonly reallocation: AgentReallocation
|
|
58
|
+
readonly dispatch: AgentDispatch
|
|
59
|
+
readonly origin: AgentOrigin
|
|
60
|
+
readonly realtime: AgentRealtime
|
|
61
|
+
|
|
62
|
+
constructor( config: AgentConfig ){
|
|
63
|
+
if( !config.context ) throw new Error('Undefined context. See https://doc.dedot.io/sdk/aux')
|
|
64
|
+
if( !config.accessToken ) throw new Error('Undefined accessToken. See https://doc.dedot.io/sdk/auth')
|
|
65
|
+
|
|
66
|
+
const access: AccessOptions = {
|
|
67
|
+
context: config.context,
|
|
68
|
+
accessToken: config.accessToken,
|
|
69
|
+
env: config.env || 'dev',
|
|
70
|
+
platform: config.platform || 'proxy',
|
|
71
|
+
remoteOrigin: config.remoteOrigin,
|
|
72
|
+
timeout: config.timeout,
|
|
73
|
+
baseUrl: config.baseUrl,
|
|
74
|
+
devHostname: config.devHostname,
|
|
75
|
+
session: config.session
|
|
76
|
+
}
|
|
77
|
+
super( access, 'API' )
|
|
78
|
+
|
|
79
|
+
this.rides = new AgentRides( this )
|
|
80
|
+
this.delivery = new AgentDelivery( this )
|
|
81
|
+
this.shipping = new AgentShipping( this )
|
|
82
|
+
this.navigation = new AgentNavigation( this )
|
|
83
|
+
this.consolidation = new AgentConsolidation( this )
|
|
84
|
+
this.reallocation = new AgentReallocation( this )
|
|
85
|
+
this.dispatch = new AgentDispatch( this )
|
|
86
|
+
this.origin = new AgentOrigin( this )
|
|
87
|
+
this.realtime = new AgentRealtime( access )
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ── Agent profile ─────────────────────────────────────────────────────────
|
|
91
|
+
|
|
92
|
+
async info(): Promise<AgentInfoValidation['response']> {
|
|
93
|
+
return await this.request<AgentInfoValidation['response']>({
|
|
94
|
+
url: '/agent',
|
|
95
|
+
method: 'GET'
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async update( body: AgentUpdateValidation['body'] ): Promise<AgentUpdateValidation['response']> {
|
|
100
|
+
return await this.request<AgentUpdateValidation['response']>({
|
|
101
|
+
url: '/agent',
|
|
102
|
+
method: 'PATCH',
|
|
103
|
+
body
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async availability( status: AgentAvailabilityValidation['params']['availability'] ): Promise<AgentAvailabilityValidation['response']> {
|
|
108
|
+
return await this.request<AgentAvailabilityValidation['response']>({
|
|
109
|
+
url: `/agent/${status}`,
|
|
110
|
+
method: 'GET'
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AgentLocationValidation,
|
|
3
|
+
AgentNearbyValidation
|
|
4
|
+
} from '@de./types'
|
|
5
|
+
import { qs, type Http, type Res, type Data } from '../../utils'
|
|
6
|
+
|
|
7
|
+
// ─── Agent Navigation ─────────────────────────────────────────────────────────
|
|
8
|
+
|
|
9
|
+
export default class AgentNavigation {
|
|
10
|
+
constructor( private http: Http ){}
|
|
11
|
+
|
|
12
|
+
async location( body: AgentLocationValidation['body'] ): Promise<AgentLocationValidation['response']> {
|
|
13
|
+
return await this.http.request<AgentLocationValidation['response']>({
|
|
14
|
+
url: '/agent/navigation/location',
|
|
15
|
+
method: 'POST',
|
|
16
|
+
body
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async nearby( body: AgentNearbyValidation['body'], querystring?: AgentNearbyValidation['querystring'] ): Promise<AgentNearbyValidation['response']> {
|
|
21
|
+
return await this.http.request<AgentNearbyValidation['response']>({
|
|
22
|
+
url: `/agent/navigation/nearby${qs( querystring )}`,
|
|
23
|
+
method: 'POST',
|
|
24
|
+
body
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AgentOriginStatusReportValidation,
|
|
3
|
+
AgentRegisterPoiValidation,
|
|
4
|
+
AgentAddPoiNoteValidation
|
|
5
|
+
} from '@de./types'
|
|
6
|
+
import { type Http, type Res, type Data } from '../../utils'
|
|
7
|
+
|
|
8
|
+
// ─── Agent Origin ─────────────────────────────────────────────────────────────
|
|
9
|
+
|
|
10
|
+
export default class AgentOrigin {
|
|
11
|
+
constructor( private http: Http ){}
|
|
12
|
+
|
|
13
|
+
async statusReport( body: AgentOriginStatusReportValidation['body'] ): Promise<AgentOriginStatusReportValidation['response']> {
|
|
14
|
+
return await this.http.request<AgentOriginStatusReportValidation['response']>({
|
|
15
|
+
url: '/agent/origin/status',
|
|
16
|
+
method: 'POST',
|
|
17
|
+
body
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async registerPoi( body: AgentRegisterPoiValidation['body'] ): Promise<AgentRegisterPoiValidation['response']> {
|
|
22
|
+
return await this.http.request<AgentRegisterPoiValidation['response']>({
|
|
23
|
+
url: '/agent/origin/poi/register',
|
|
24
|
+
method: 'POST',
|
|
25
|
+
body
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async addPoiNote( body: AgentAddPoiNoteValidation['body'] ): Promise<AgentAddPoiNoteValidation['response']> {
|
|
30
|
+
return await this.http.request<AgentAddPoiNoteValidation['response']>({
|
|
31
|
+
url: '/agent/origin/poi/note',
|
|
32
|
+
method: 'POST',
|
|
33
|
+
body
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AgentReallocationRespondValidation } from '@de./types'
|
|
2
|
+
import { type Http, type Res, type Data } from '../../utils'
|
|
3
|
+
|
|
4
|
+
// ─── Agent Reallocation ───────────────────────────────────────────────────────
|
|
5
|
+
|
|
6
|
+
export default class AgentReallocation {
|
|
7
|
+
constructor( private http: Http ){}
|
|
8
|
+
|
|
9
|
+
async respond( body: AgentReallocationRespondValidation['body'] ): Promise<AgentReallocationRespondValidation['response']> {
|
|
10
|
+
return await this.http.request<AgentReallocationRespondValidation['response']>({
|
|
11
|
+
url: '/agent/reallocation/respond',
|
|
12
|
+
method: 'POST',
|
|
13
|
+
body
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { OrderTrackingEvent } from '@de./types'
|
|
2
|
+
import type { RTLocation, Message, Peer } from '../../types'
|
|
3
|
+
import type { SocketAuthCredentials } from '../../types/auth'
|
|
4
|
+
import type { AccessOptions } from '../../types/access'
|
|
5
|
+
|
|
6
|
+
import io, { Socket } from 'socket.io-client'
|
|
7
|
+
import AccessManager from '../Access'
|
|
8
|
+
import { baseURL } from '../../baseUrl'
|
|
9
|
+
|
|
10
|
+
// ─── Agent Realtime ───────────────────────────────────────────────────────────
|
|
11
|
+
//
|
|
12
|
+
// Socket channel for riders. Two jobs:
|
|
13
|
+
//
|
|
14
|
+
// 1. Order rooms — after `join(jrtoken)` (token from the platform's tracking
|
|
15
|
+
// session, role=agent) the rider streams LOCATION-CHANGE / MESSAGE into
|
|
16
|
+
// the room and receives ORDER_UPDATE events for the order.
|
|
17
|
+
//
|
|
18
|
+
// 2. Proactive-consolidation responses — CONSOLIDATION_ACK / NACK / POSITION
|
|
19
|
+
// go over the socket, NOT the REST respond endpoints (those serve relay
|
|
20
|
+
// and dispatch offers). See de.arch consolidation README: response channels.
|
|
21
|
+
//
|
|
22
|
+
// NOTE — dispatch/consolidation OFFERS do not arrive on this socket: De.
|
|
23
|
+
// emits RALLY_EVENT to service connections only, and the operating platform
|
|
24
|
+
// (e.g. its backend SSE) relays offers to the rider app. Respond to relayed
|
|
25
|
+
// offers via `agent.dispatch.respond(...)` / `agent.consolidation.respond(...)`.
|
|
26
|
+
//
|
|
27
|
+
// Distinct from `Realtime` (allend/Realtime), which is the client-role socket.
|
|
28
|
+
|
|
29
|
+
export type AgentRealtimeContext = {
|
|
30
|
+
wid: string
|
|
31
|
+
type: string
|
|
32
|
+
xcode: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default class AgentRealtime extends AccessManager {
|
|
36
|
+
private nsp?: Socket
|
|
37
|
+
private iosHost: string
|
|
38
|
+
private agentId?: string
|
|
39
|
+
|
|
40
|
+
constructor( access: AccessOptions ){
|
|
41
|
+
super( access, 'API' )
|
|
42
|
+
|
|
43
|
+
// Socket.io is served by the same de.arch API server, so an explicit
|
|
44
|
+
// origin governs the socket exactly as it governs the requests — without
|
|
45
|
+
// this, a client pointed at a self-hosted De. still opened its socket
|
|
46
|
+
// against the environment table's host.
|
|
47
|
+
this.iosHost = access.baseUrl?.replace( /\/+$/, '' )
|
|
48
|
+
|| baseURL('API', access.env || 'dev', access.devHostname )
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
connect( agentId: string ): Promise<void> {
|
|
52
|
+
return new Promise( ( resolve, reject ) => {
|
|
53
|
+
const auth: SocketAuthCredentials = {
|
|
54
|
+
utype: 'agent',
|
|
55
|
+
id: agentId,
|
|
56
|
+
remoteOrigin: this.remoteOrigin as string,
|
|
57
|
+
accessToken: this.accessToken as string
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this.agentId = agentId
|
|
61
|
+
this.nsp = io( this.iosHost, { auth } )
|
|
62
|
+
this.nsp.on('connect', resolve )
|
|
63
|
+
this.nsp.on('connect_error', reject )
|
|
64
|
+
} )
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
disconnect(){
|
|
68
|
+
this.nsp?.disconnect()
|
|
69
|
+
return true
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Join an order tracking room with a Join Room Token issued by
|
|
74
|
+
* GET /v1/tracking/:reference (role must match this socket's utype)
|
|
75
|
+
*/
|
|
76
|
+
join( jrtoken: string ): Promise<boolean> {
|
|
77
|
+
return new Promise( ( resolve, reject ) => {
|
|
78
|
+
this.nsp?.emit('JOIN', jrtoken, ( errmess?: string ) => {
|
|
79
|
+
errmess ? reject( new Error( errmess ) ) : resolve( true )
|
|
80
|
+
} )
|
|
81
|
+
} )
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ── Order room streams (after join) ─────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
sendLocation( location: RTLocation ){
|
|
87
|
+
this.nsp?.emit('LOCATION-CHANGE', location )
|
|
88
|
+
return this
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
sendMessage( message: Message ){
|
|
92
|
+
this.nsp?.emit('MESSAGE', message )
|
|
93
|
+
return this
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
onOrderUpdate( fn: ( event: OrderTrackingEvent ) => void ){
|
|
97
|
+
this.nsp?.on('ORDER_UPDATE', fn )
|
|
98
|
+
return this
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
onMessage( fn: ( message: Message ) => void ){
|
|
102
|
+
this.nsp?.on('MESSAGE', fn )
|
|
103
|
+
return this
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
onConnected( fn: ( peer: Peer ) => void ){
|
|
107
|
+
this.nsp?.on('CONNECTED', fn )
|
|
108
|
+
return this
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
onDisconnected( fn: ( peer: Peer ) => void ){
|
|
112
|
+
this.nsp?.on('DISCONNECTED', fn )
|
|
113
|
+
return this
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ── Proactive consolidation channel (socket-only responses) ─────────────
|
|
117
|
+
|
|
118
|
+
ackConsolidation( context: AgentRealtimeContext, offerId: string ){
|
|
119
|
+
if( !this.agentId ) throw new Error('Not connected')
|
|
120
|
+
this.nsp?.emit('CONSOLIDATION_ACK', { context, offerId, agentId: this.agentId } )
|
|
121
|
+
return this
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
nackConsolidation( context: AgentRealtimeContext, offerId: string, nackReason?: string ){
|
|
125
|
+
if( !this.agentId ) throw new Error('Not connected')
|
|
126
|
+
this.nsp?.emit('CONSOLIDATION_NACK', { context, offerId, agentId: this.agentId, nackReason } )
|
|
127
|
+
return this
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Stream the rider's position into the proactive consolidation engine —
|
|
132
|
+
* feeds trajectory tracking (ARRIVED / DIVERGING / STATIONARY) for
|
|
133
|
+
* committed handoffs. Distinct from order-room sendLocation().
|
|
134
|
+
*/
|
|
135
|
+
positionUpdate( context: AgentRealtimeContext, location: RTLocation, status?: string ){
|
|
136
|
+
if( !this.agentId ) throw new Error('Not connected')
|
|
137
|
+
this.nsp?.emit('CONSOLIDATION_POSITION', { context, agentId: this.agentId, location, status } )
|
|
138
|
+
return this
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AgentRideListValidation,
|
|
3
|
+
AgentRideGetValidation,
|
|
4
|
+
AgentRideAcceptValidation,
|
|
5
|
+
AgentRideStartValidation,
|
|
6
|
+
AgentRideCompleteValidation,
|
|
7
|
+
AgentRideCancelValidation
|
|
8
|
+
} from '@de./types'
|
|
9
|
+
import { qs, type Http, type Res, type Data } from '../../utils'
|
|
10
|
+
|
|
11
|
+
// ─── Agent Ride Orders ────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
export default class AgentRides {
|
|
14
|
+
constructor( private http: Http ){}
|
|
15
|
+
|
|
16
|
+
async list( querystring?: AgentRideListValidation['querystring'] ): Promise<AgentRideListValidation['response']> {
|
|
17
|
+
return await this.http.request<AgentRideListValidation['response']>({
|
|
18
|
+
url: `/agent/ride/orders${qs( querystring )}`,
|
|
19
|
+
method: 'GET'
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async get( reference: string ): Promise<AgentRideGetValidation['response']> {
|
|
24
|
+
return await this.http.request<AgentRideGetValidation['response']>({
|
|
25
|
+
url: `/agent/ride/orders/${reference}`,
|
|
26
|
+
method: 'GET'
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async accept( reference: string, body: AgentRideAcceptValidation['body'] ): Promise<AgentRideAcceptValidation['response']> {
|
|
31
|
+
return await this.http.request<AgentRideAcceptValidation['response']>({
|
|
32
|
+
url: `/agent/ride/orders/${reference}/accept`,
|
|
33
|
+
method: 'POST',
|
|
34
|
+
body
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async start( reference: string, body: AgentRideStartValidation['body'] ): Promise<AgentRideStartValidation['response']> {
|
|
39
|
+
return await this.http.request<AgentRideStartValidation['response']>({
|
|
40
|
+
url: `/agent/ride/orders/${reference}/start`,
|
|
41
|
+
method: 'POST',
|
|
42
|
+
body
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async complete( reference: string, body: AgentRideCompleteValidation['body'] ): Promise<AgentRideCompleteValidation['response']> {
|
|
47
|
+
return await this.http.request<AgentRideCompleteValidation['response']>({
|
|
48
|
+
url: `/agent/ride/orders/${reference}/complete`,
|
|
49
|
+
method: 'POST',
|
|
50
|
+
body
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async cancel( reference: string, body: AgentRideCancelValidation['body'] ): Promise<AgentRideCancelValidation['response']> {
|
|
55
|
+
return await this.http.request<AgentRideCancelValidation['response']>({
|
|
56
|
+
url: `/agent/ride/orders/${reference}/cancel`,
|
|
57
|
+
method: 'POST',
|
|
58
|
+
body
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AgentShippingListValidation,
|
|
3
|
+
AgentShippingGetValidation,
|
|
4
|
+
AgentShippingAcceptValidation,
|
|
5
|
+
AgentShippingUpdateStatusValidation,
|
|
6
|
+
AgentShippingReportIssueValidation
|
|
7
|
+
} from '@de./types'
|
|
8
|
+
import { qs, type Http, type Res, type Data } from '../../utils'
|
|
9
|
+
|
|
10
|
+
// ─── Agent Shipping Orders ────────────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
export default class AgentShipping {
|
|
13
|
+
constructor( private http: Http ){}
|
|
14
|
+
|
|
15
|
+
async list( querystring?: AgentShippingListValidation['querystring'] ): Promise<AgentShippingListValidation['response']> {
|
|
16
|
+
return await this.http.request<AgentShippingListValidation['response']>({
|
|
17
|
+
url: `/agent/shipping/orders${qs( querystring )}`,
|
|
18
|
+
method: 'GET'
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async get( reference: string ): Promise<AgentShippingGetValidation['response']> {
|
|
23
|
+
return await this.http.request<AgentShippingGetValidation['response']>({
|
|
24
|
+
url: `/agent/shipping/orders/${reference}`,
|
|
25
|
+
method: 'GET'
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async accept( reference: string ): Promise<AgentShippingAcceptValidation['response']> {
|
|
30
|
+
return await this.http.request<AgentShippingAcceptValidation['response']>({
|
|
31
|
+
url: `/agent/shipping/orders/${reference}/accept`,
|
|
32
|
+
method: 'POST'
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async updateStatus( reference: string, body: AgentShippingUpdateStatusValidation['body'] ): Promise<AgentShippingUpdateStatusValidation['response']> {
|
|
37
|
+
return await this.http.request<AgentShippingUpdateStatusValidation['response']>({
|
|
38
|
+
url: `/agent/shipping/orders/${reference}/status`,
|
|
39
|
+
method: 'PATCH',
|
|
40
|
+
body
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async reportIssue( reference: string, body: AgentShippingReportIssueValidation['body'] ): Promise<AgentShippingReportIssueValidation['response']> {
|
|
45
|
+
return await this.http.request<AgentShippingReportIssueValidation['response']>({
|
|
46
|
+
url: `/agent/shipping/orders/${reference}/issue`,
|
|
47
|
+
method: 'POST',
|
|
48
|
+
body
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CSPAnalyticsOrdersValidation,
|
|
3
|
+
CSPAnalyticsFulfillmentValidation,
|
|
4
|
+
CSPAnalyticsProvidersValidation,
|
|
5
|
+
CSPAnalyticsGenerateReportValidation,
|
|
6
|
+
CSPAnalyticsGetReportValidation,
|
|
7
|
+
CSPAnalyticsListReportsValidation
|
|
8
|
+
} from '@de./types/csp/analytics'
|
|
9
|
+
import { qs, type Http, type Res, type Data } from '../../utils'
|
|
10
|
+
|
|
11
|
+
// ── CSP Analytics ─────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
export default class CSPAnalytics {
|
|
14
|
+
constructor( private http: Http ){}
|
|
15
|
+
|
|
16
|
+
async orders( body: CSPAnalyticsOrdersValidation['body'] ): Promise<CSPAnalyticsOrdersValidation['response']> {
|
|
17
|
+
return await this.http.request<CSPAnalyticsOrdersValidation['response']>({
|
|
18
|
+
url: '/csp/analytics/orders',
|
|
19
|
+
method: 'POST',
|
|
20
|
+
body
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async fulfillment( body: CSPAnalyticsFulfillmentValidation['body'] ): Promise<CSPAnalyticsFulfillmentValidation['response']> {
|
|
25
|
+
return await this.http.request<CSPAnalyticsFulfillmentValidation['response']>({
|
|
26
|
+
url: '/csp/analytics/fulfillment',
|
|
27
|
+
method: 'POST',
|
|
28
|
+
body
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async providers( body: CSPAnalyticsProvidersValidation['body'] ): Promise<CSPAnalyticsProvidersValidation['response']> {
|
|
33
|
+
return await this.http.request<CSPAnalyticsProvidersValidation['response']>({
|
|
34
|
+
url: '/csp/analytics/providers',
|
|
35
|
+
method: 'POST',
|
|
36
|
+
body
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async generateReport( body: CSPAnalyticsGenerateReportValidation['body'] ): Promise<CSPAnalyticsGenerateReportValidation['response']> {
|
|
41
|
+
return await this.http.request<CSPAnalyticsGenerateReportValidation['response']>({
|
|
42
|
+
url: '/csp/analytics/reports',
|
|
43
|
+
method: 'POST',
|
|
44
|
+
body
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async getReport( id: string ): Promise<CSPAnalyticsGetReportValidation['response']> {
|
|
49
|
+
return await this.http.request<CSPAnalyticsGetReportValidation['response']>({
|
|
50
|
+
url: `/csp/analytics/reports/${id}`,
|
|
51
|
+
method: 'GET'
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async listReports( querystring?: CSPAnalyticsListReportsValidation['querystring'] ): Promise<CSPAnalyticsListReportsValidation['response']> {
|
|
56
|
+
return await this.http.request<CSPAnalyticsListReportsValidation['response']>({
|
|
57
|
+
url: `/csp/analytics/reports${qs( querystring )}`,
|
|
58
|
+
method: 'GET'
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { AccessOptions } from '../../types/access'
|
|
2
|
+
import SharedContextClient from '../Shared/context'
|
|
3
|
+
import SharedOperators from '../Shared/operators'
|
|
4
|
+
import CSPOrders from './orders'
|
|
5
|
+
import CSPWebhooks from './webhooks'
|
|
6
|
+
import CSPAnalytics from './analytics'
|
|
7
|
+
import CSPInventory from './inventory'
|
|
8
|
+
|
|
9
|
+
export type CSPConfig = {
|
|
10
|
+
context: string
|
|
11
|
+
accessToken: string
|
|
12
|
+
env?: 'dev' | 'staging' | 'prod'
|
|
13
|
+
platform?: 'web' | 'mobile' | 'server' | 'proxy'
|
|
14
|
+
remoteOrigin?: string
|
|
15
|
+
/** Per-request deadline in ms. See `AccessOptions.timeout`. */
|
|
16
|
+
timeout?: number
|
|
17
|
+
/** Explicit service origin, overriding the env table. See `AccessOptions.baseUrl`. */
|
|
18
|
+
baseUrl?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
22
|
+
//
|
|
23
|
+
// CSP: Commerce Service Provider API — de.arch /csp routes.
|
|
24
|
+
// Covers orders, inventory, webhooks, analytics, plus shared faqs/users/account/
|
|
25
|
+
// invitation (SharedContextClient) and operators.
|
|
26
|
+
//
|
|
27
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
export default class CSP extends SharedContextClient<'CSP'> {
|
|
30
|
+
readonly operators: SharedOperators<'CSP'>
|
|
31
|
+
readonly orders: CSPOrders
|
|
32
|
+
readonly webhooks: CSPWebhooks
|
|
33
|
+
readonly analytics: CSPAnalytics
|
|
34
|
+
readonly inventory: CSPInventory
|
|
35
|
+
|
|
36
|
+
constructor( config: CSPConfig ){
|
|
37
|
+
if( !config.context ) throw new Error('Undefined context. See https://doc.dedot.io/sdk/csp')
|
|
38
|
+
if( !config.accessToken ) throw new Error('Undefined accessToken. See https://doc.dedot.io/sdk/auth')
|
|
39
|
+
|
|
40
|
+
const access: AccessOptions = {
|
|
41
|
+
context: config.context,
|
|
42
|
+
accessToken: config.accessToken,
|
|
43
|
+
env: config.env || 'dev',
|
|
44
|
+
platform: config.platform || 'proxy',
|
|
45
|
+
remoteOrigin: config.remoteOrigin,
|
|
46
|
+
timeout: config.timeout,
|
|
47
|
+
baseUrl: config.baseUrl
|
|
48
|
+
}
|
|
49
|
+
super( access, 'CSP' )
|
|
50
|
+
|
|
51
|
+
this.operators = new SharedOperators( this, 'CSP' )
|
|
52
|
+
this.orders = new CSPOrders( this )
|
|
53
|
+
this.webhooks = new CSPWebhooks( this )
|
|
54
|
+
this.analytics = new CSPAnalytics( this )
|
|
55
|
+
this.inventory = new CSPInventory( this )
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CSPInventorySyncCatalogValidation,
|
|
3
|
+
CSPInventoryCheckAvailabilityValidation,
|
|
4
|
+
CSPInventoryBulkPushValidation,
|
|
5
|
+
CSPInventoryBulkPullValidation,
|
|
6
|
+
CSPInventoryGetSyncStatusValidation,
|
|
7
|
+
CSPInventoryReserveValidation,
|
|
8
|
+
CSPInventoryCommitValidation,
|
|
9
|
+
CSPInventoryReleaseValidation,
|
|
10
|
+
CSPInventoryListReservationsValidation,
|
|
11
|
+
CSPInventoryGetReservationValidation
|
|
12
|
+
} from '@de./types/csp/inventory'
|
|
13
|
+
import { qs, type Http, type Res, type Data } from '../../utils'
|
|
14
|
+
|
|
15
|
+
// ── CSP Inventory ────────────────────────────────────────────────────────
|
|
16
|
+
|
|
17
|
+
export default class CSPInventory {
|
|
18
|
+
constructor( private http: Http ){}
|
|
19
|
+
|
|
20
|
+
async syncCatalog( body: CSPInventorySyncCatalogValidation['body'] ): Promise<CSPInventorySyncCatalogValidation['response']> {
|
|
21
|
+
return await this.http.request<CSPInventorySyncCatalogValidation['response']>({
|
|
22
|
+
url: '/csp/inventory/sync',
|
|
23
|
+
method: 'POST',
|
|
24
|
+
body
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async checkAvailability( body: CSPInventoryCheckAvailabilityValidation['body'] ): Promise<CSPInventoryCheckAvailabilityValidation['response']> {
|
|
29
|
+
return await this.http.request<CSPInventoryCheckAvailabilityValidation['response']>({
|
|
30
|
+
url: '/csp/inventory/availability',
|
|
31
|
+
method: 'POST',
|
|
32
|
+
body
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async bulkPush( body: CSPInventoryBulkPushValidation['body'] ): Promise<CSPInventoryBulkPushValidation['response']> {
|
|
37
|
+
return await this.http.request<CSPInventoryBulkPushValidation['response']>({
|
|
38
|
+
url: '/csp/inventory/bulk/push',
|
|
39
|
+
method: 'POST',
|
|
40
|
+
body
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async bulkPull( body: CSPInventoryBulkPullValidation['body'] ): Promise<CSPInventoryBulkPullValidation['response']> {
|
|
45
|
+
return await this.http.request<CSPInventoryBulkPullValidation['response']>({
|
|
46
|
+
url: '/csp/inventory/bulk/pull',
|
|
47
|
+
method: 'POST',
|
|
48
|
+
body
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async getSyncStatus( syncId: string ): Promise<CSPInventoryGetSyncStatusValidation['response']> {
|
|
53
|
+
return await this.http.request<CSPInventoryGetSyncStatusValidation['response']>({
|
|
54
|
+
url: `/csp/inventory/sync/${syncId}`,
|
|
55
|
+
method: 'GET'
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async reserve( body: CSPInventoryReserveValidation['body'] ): Promise<CSPInventoryReserveValidation['response']> {
|
|
60
|
+
return await this.http.request<CSPInventoryReserveValidation['response']>({
|
|
61
|
+
url: '/csp/inventory/reservations',
|
|
62
|
+
method: 'POST',
|
|
63
|
+
body
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async commit( body: CSPInventoryCommitValidation['body'] ): Promise<CSPInventoryCommitValidation['response']> {
|
|
68
|
+
return await this.http.request<CSPInventoryCommitValidation['response']>({
|
|
69
|
+
url: '/csp/inventory/reservations/commit',
|
|
70
|
+
method: 'POST',
|
|
71
|
+
body
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async release( body: CSPInventoryReleaseValidation['body'] ): Promise<CSPInventoryReleaseValidation['response']> {
|
|
76
|
+
return await this.http.request<CSPInventoryReleaseValidation['response']>({
|
|
77
|
+
url: '/csp/inventory/reservations/release',
|
|
78
|
+
method: 'POST',
|
|
79
|
+
body
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async listReservations( querystring?: CSPInventoryListReservationsValidation['querystring'] ): Promise<CSPInventoryListReservationsValidation['response']> {
|
|
84
|
+
return await this.http.request<CSPInventoryListReservationsValidation['response']>({
|
|
85
|
+
url: `/csp/inventory/reservations${qs( querystring )}`,
|
|
86
|
+
method: 'GET'
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async getReservation( id: string ): Promise<CSPInventoryGetReservationValidation['response']> {
|
|
91
|
+
return await this.http.request<CSPInventoryGetReservationValidation['response']>({
|
|
92
|
+
url: `/csp/inventory/reservations/${id}`,
|
|
93
|
+
method: 'GET'
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
}
|