@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,121 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CSPOrderCreateValidation,
|
|
3
|
+
CSPOrderRetrieveValidation,
|
|
4
|
+
CSPOrderListValidation,
|
|
5
|
+
CSPOrderUpdateValidation,
|
|
6
|
+
CSPOrderTrackingValidation,
|
|
7
|
+
CSPOrderCancelValidation,
|
|
8
|
+
CSPOrderTimelineValidation,
|
|
9
|
+
CSPOrderReportExceptionValidation,
|
|
10
|
+
CSPOrderListExceptionsValidation,
|
|
11
|
+
CSPOrderResolveExceptionValidation,
|
|
12
|
+
CSPOrderDispatchValidation,
|
|
13
|
+
CSPOrderSplitValidation,
|
|
14
|
+
CSPOrderUpdateStatusValidation
|
|
15
|
+
} from '@de./types/csp/order'
|
|
16
|
+
import { qs, type Http, type Res, type Data } from '../../utils'
|
|
17
|
+
|
|
18
|
+
// ── CSP Orders ────────────────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
export default class CSPOrders {
|
|
21
|
+
constructor( private http: Http ){}
|
|
22
|
+
|
|
23
|
+
async create( body: CSPOrderCreateValidation['body'] ): Promise<CSPOrderCreateValidation['response']> {
|
|
24
|
+
return await this.http.request<CSPOrderCreateValidation['response']>({
|
|
25
|
+
url: '/csp/orders',
|
|
26
|
+
method: 'POST',
|
|
27
|
+
body
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async retrieve( reference: string ): Promise<CSPOrderRetrieveValidation['response']> {
|
|
32
|
+
return await this.http.request<CSPOrderRetrieveValidation['response']>({
|
|
33
|
+
url: `/csp/orders/${reference}`,
|
|
34
|
+
method: 'GET'
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async list( querystring?: CSPOrderListValidation['querystring'] ): Promise<CSPOrderListValidation['response']> {
|
|
39
|
+
return await this.http.request<CSPOrderListValidation['response']>({
|
|
40
|
+
url: `/csp/orders${qs( querystring )}`,
|
|
41
|
+
method: 'GET'
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async update( reference: string, body: CSPOrderUpdateValidation['body'] ): Promise<CSPOrderUpdateValidation['response']> {
|
|
46
|
+
return await this.http.request<CSPOrderUpdateValidation['response']>({
|
|
47
|
+
url: `/csp/orders/${reference}`,
|
|
48
|
+
method: 'PATCH',
|
|
49
|
+
body
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async tracking( reference: string ): Promise<CSPOrderTrackingValidation['response']> {
|
|
54
|
+
return await this.http.request<CSPOrderTrackingValidation['response']>({
|
|
55
|
+
url: `/csp/orders/${reference}/tracking`,
|
|
56
|
+
method: 'GET'
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async cancel( reference: string, body: CSPOrderCancelValidation['body'] ): Promise<CSPOrderCancelValidation['response']> {
|
|
61
|
+
return await this.http.request<CSPOrderCancelValidation['response']>({
|
|
62
|
+
url: `/csp/orders/${reference}/cancel`,
|
|
63
|
+
method: 'POST',
|
|
64
|
+
body
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async timeline( reference: string ): Promise<CSPOrderTimelineValidation['response']> {
|
|
69
|
+
return await this.http.request<CSPOrderTimelineValidation['response']>({
|
|
70
|
+
url: `/csp/orders/${reference}/timeline`,
|
|
71
|
+
method: 'GET'
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async reportException( reference: string, body: CSPOrderReportExceptionValidation['body'] ): Promise<CSPOrderReportExceptionValidation['response']> {
|
|
76
|
+
return await this.http.request<CSPOrderReportExceptionValidation['response']>({
|
|
77
|
+
url: `/csp/orders/${reference}/exceptions`,
|
|
78
|
+
method: 'POST',
|
|
79
|
+
body
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async listExceptions( reference: string ): Promise<CSPOrderListExceptionsValidation['response']> {
|
|
84
|
+
return await this.http.request<CSPOrderListExceptionsValidation['response']>({
|
|
85
|
+
url: `/csp/orders/${reference}/exceptions`,
|
|
86
|
+
method: 'GET'
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async resolveException( reference: string, exceptionId: string, body: CSPOrderResolveExceptionValidation['body'] ): Promise<CSPOrderResolveExceptionValidation['response']> {
|
|
91
|
+
return await this.http.request<CSPOrderResolveExceptionValidation['response']>({
|
|
92
|
+
url: `/csp/orders/${reference}/exceptions/${exceptionId}/resolve`,
|
|
93
|
+
method: 'POST',
|
|
94
|
+
body
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async dispatch( reference: string, body: CSPOrderDispatchValidation['body'] ): Promise<CSPOrderDispatchValidation['response']> {
|
|
99
|
+
return await this.http.request<CSPOrderDispatchValidation['response']>({
|
|
100
|
+
url: `/csp/orders/${reference}/dispatch`,
|
|
101
|
+
method: 'POST',
|
|
102
|
+
body
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async split( reference: string, body: CSPOrderSplitValidation['body'] ): Promise<CSPOrderSplitValidation['response']> {
|
|
107
|
+
return await this.http.request<CSPOrderSplitValidation['response']>({
|
|
108
|
+
url: `/csp/orders/${reference}/split`,
|
|
109
|
+
method: 'POST',
|
|
110
|
+
body
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async updateStatus( reference: string, body: CSPOrderUpdateStatusValidation['body'] ): Promise<CSPOrderUpdateStatusValidation['response']> {
|
|
115
|
+
return await this.http.request<CSPOrderUpdateStatusValidation['response']>({
|
|
116
|
+
url: `/csp/orders/${reference}/status`,
|
|
117
|
+
method: 'PATCH',
|
|
118
|
+
body
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CSPWebhookCreateValidation,
|
|
3
|
+
CSPWebhookListValidation,
|
|
4
|
+
CSPWebhookRetrieveValidation,
|
|
5
|
+
CSPWebhookUpdateValidation,
|
|
6
|
+
CSPWebhookRemoveValidation,
|
|
7
|
+
CSPWebhookLogsValidation,
|
|
8
|
+
CSPWebhookTestValidation
|
|
9
|
+
} from '@de./types/csp/webhook'
|
|
10
|
+
import { qs, type Http, type Res, type Data } from '../../utils'
|
|
11
|
+
|
|
12
|
+
// ── CSP Webhooks ──────────────────────────────────────────────────────────
|
|
13
|
+
|
|
14
|
+
export default class CSPWebhooks {
|
|
15
|
+
constructor( private http: Http ){}
|
|
16
|
+
|
|
17
|
+
async create( body: CSPWebhookCreateValidation['body'] ): Promise<CSPWebhookCreateValidation['response']> {
|
|
18
|
+
return await this.http.request<CSPWebhookCreateValidation['response']>({
|
|
19
|
+
url: '/csp/webhooks',
|
|
20
|
+
method: 'POST',
|
|
21
|
+
body
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async list( querystring?: CSPWebhookListValidation['querystring'] ): Promise<CSPWebhookListValidation['response']> {
|
|
26
|
+
return await this.http.request<CSPWebhookListValidation['response']>({
|
|
27
|
+
url: `/csp/webhooks${qs( querystring )}`,
|
|
28
|
+
method: 'GET'
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async retrieve( id: string ): Promise<CSPWebhookRetrieveValidation['response']> {
|
|
33
|
+
return await this.http.request<CSPWebhookRetrieveValidation['response']>({
|
|
34
|
+
url: `/csp/webhooks/${id}`,
|
|
35
|
+
method: 'GET'
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async update( id: string, body: CSPWebhookUpdateValidation['body'] ): Promise<CSPWebhookUpdateValidation['response']> {
|
|
40
|
+
return await this.http.request<CSPWebhookUpdateValidation['response']>({
|
|
41
|
+
url: `/csp/webhooks/${id}`,
|
|
42
|
+
method: 'PATCH',
|
|
43
|
+
body
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async remove( id: string ): Promise<CSPWebhookRemoveValidation['response']> {
|
|
48
|
+
return await this.http.request<CSPWebhookRemoveValidation['response']>({
|
|
49
|
+
url: `/csp/webhooks/${id}`,
|
|
50
|
+
method: 'DELETE'
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async logs( id: string, querystring?: CSPWebhookLogsValidation['querystring'] ): Promise<CSPWebhookLogsValidation['response']> {
|
|
55
|
+
return await this.http.request<CSPWebhookLogsValidation['response']>({
|
|
56
|
+
url: `/csp/webhooks/${id}/logs${qs( querystring )}`,
|
|
57
|
+
method: 'GET'
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async test( id: string, body?: CSPWebhookTestValidation['body'] ): Promise<CSPWebhookTestValidation['response']> {
|
|
62
|
+
return await this.http.request<CSPWebhookTestValidation['response']>({
|
|
63
|
+
url: `/csp/webhooks/${id}/test`,
|
|
64
|
+
method: 'POST',
|
|
65
|
+
body
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { AccessOptions, UserSession } from '../../types/access'
|
|
2
|
+
import AccessManager from '../Access'
|
|
3
|
+
import CustomerIntents from './intents'
|
|
4
|
+
import CustomerOrders from './orders'
|
|
5
|
+
import CustomerRides from './rides'
|
|
6
|
+
|
|
7
|
+
export type CustomerConfig = {
|
|
8
|
+
context: string
|
|
9
|
+
accessToken: string
|
|
10
|
+
env?: 'dev' | 'staging' | 'prod'
|
|
11
|
+
platform?: 'web' | 'mobile' | 'server' | 'proxy'
|
|
12
|
+
remoteOrigin?: string
|
|
13
|
+
/** Per-request deadline in ms. See `AccessOptions.timeout`. */
|
|
14
|
+
timeout?: number
|
|
15
|
+
/** Explicit service origin, overriding the env table. See `AccessOptions.baseUrl`. */
|
|
16
|
+
baseUrl?: string
|
|
17
|
+
/**
|
|
18
|
+
* The signed-in customer, when the client acts on their behalf rather
|
|
19
|
+
* than as the integration itself.
|
|
20
|
+
*/
|
|
21
|
+
session?: UserSession
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
25
|
+
//
|
|
26
|
+
// Customer: Customer Operation Interfaces — de.arch AUX/customer routes.
|
|
27
|
+
// Covers intents, orders, and rides.
|
|
28
|
+
//
|
|
29
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
30
|
+
|
|
31
|
+
export default class Customer extends AccessManager {
|
|
32
|
+
intents: CustomerIntents
|
|
33
|
+
orders: CustomerOrders
|
|
34
|
+
rides: CustomerRides
|
|
35
|
+
|
|
36
|
+
constructor( config: CustomerConfig ){
|
|
37
|
+
if( !config.context ) throw new Error('Undefined context. See https://doc.dedot.io/sdk/aux')
|
|
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
|
+
session: config.session
|
|
49
|
+
}
|
|
50
|
+
super( access, 'API' )
|
|
51
|
+
|
|
52
|
+
this.intents = new CustomerIntents( this )
|
|
53
|
+
this.orders = new CustomerOrders( this )
|
|
54
|
+
this.rides = new CustomerRides( this )
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CustomerIntentCreateValidation,
|
|
3
|
+
CustomerIntentGetValidation,
|
|
4
|
+
CustomerIntentAddWaypointsValidation,
|
|
5
|
+
CustomerIntentAddPackagesValidation,
|
|
6
|
+
CustomerIntentSubmitValidation,
|
|
7
|
+
CustomerIntentCancelValidation
|
|
8
|
+
} from '@de./types'
|
|
9
|
+
import { type Http, type Res, type Data } from '../../utils'
|
|
10
|
+
|
|
11
|
+
// ─── Customer Intents ─────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
export default class CustomerIntents {
|
|
14
|
+
constructor( private http: Http ){}
|
|
15
|
+
|
|
16
|
+
async create( body: CustomerIntentCreateValidation['body'] ): Promise<CustomerIntentCreateValidation['response']> {
|
|
17
|
+
return await this.http.request<CustomerIntentCreateValidation['response']>({
|
|
18
|
+
url: '/customer/intents',
|
|
19
|
+
method: 'POST',
|
|
20
|
+
body
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async get( intentToken: string ): Promise<CustomerIntentGetValidation['response']> {
|
|
25
|
+
return await this.http.request<CustomerIntentGetValidation['response']>({
|
|
26
|
+
url: '/customer/intents',
|
|
27
|
+
method: 'GET',
|
|
28
|
+
headers: { 'x-intent-token': intentToken }
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async addWaypoints( intentToken: string, body: CustomerIntentAddWaypointsValidation['body'] ): Promise<CustomerIntentAddWaypointsValidation['response']> {
|
|
33
|
+
return await this.http.request<CustomerIntentAddWaypointsValidation['response']>({
|
|
34
|
+
url: '/customer/intents/waypoints',
|
|
35
|
+
method: 'POST',
|
|
36
|
+
headers: { 'x-intent-token': intentToken },
|
|
37
|
+
body
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async addPackages( intentToken: string, body: CustomerIntentAddPackagesValidation['body'] ): Promise<CustomerIntentAddPackagesValidation['response']> {
|
|
42
|
+
return await this.http.request<CustomerIntentAddPackagesValidation['response']>({
|
|
43
|
+
url: '/customer/intents/packages',
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: { 'x-intent-token': intentToken },
|
|
46
|
+
body
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async submit( intentToken: string, body: CustomerIntentSubmitValidation['body'] ): Promise<CustomerIntentSubmitValidation['response']> {
|
|
51
|
+
return await this.http.request<CustomerIntentSubmitValidation['response']>({
|
|
52
|
+
url: '/customer/intents/submit',
|
|
53
|
+
method: 'POST',
|
|
54
|
+
headers: { 'x-intent-token': intentToken },
|
|
55
|
+
body
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async cancel( intentToken: string ): Promise<CustomerIntentCancelValidation['response']> {
|
|
60
|
+
return await this.http.request<CustomerIntentCancelValidation['response']>({
|
|
61
|
+
url: '/customer/intents',
|
|
62
|
+
method: 'DELETE',
|
|
63
|
+
headers: { 'x-intent-token': intentToken }
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CustomerOrderListValidation,
|
|
3
|
+
CustomerOrderGetValidation,
|
|
4
|
+
CustomerOrderTrackingValidation,
|
|
5
|
+
CustomerOrderCancelValidation,
|
|
6
|
+
CustomerOrderRatingValidation
|
|
7
|
+
} from '@de./types'
|
|
8
|
+
import { qs, type Http, type Res, type Data } from '../../utils'
|
|
9
|
+
|
|
10
|
+
// ─── Customer Orders ──────────────────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
export default class CustomerOrders {
|
|
13
|
+
constructor( private http: Http ){}
|
|
14
|
+
|
|
15
|
+
async list( querystring?: CustomerOrderListValidation['querystring'] ): Promise<CustomerOrderListValidation['response']> {
|
|
16
|
+
return await this.http.request<CustomerOrderListValidation['response']>({
|
|
17
|
+
url: `/customer/orders${qs( querystring )}`,
|
|
18
|
+
method: 'GET'
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async get( reference: string, querystring?: CustomerOrderGetValidation['querystring'] ): Promise<CustomerOrderGetValidation['response']> {
|
|
23
|
+
return await this.http.request<CustomerOrderGetValidation['response']>({
|
|
24
|
+
url: `/customer/orders/${reference}${qs( querystring )}`,
|
|
25
|
+
method: 'GET'
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async tracking( reference: string ): Promise<CustomerOrderTrackingValidation['response']> {
|
|
30
|
+
return await this.http.request<CustomerOrderTrackingValidation['response']>({
|
|
31
|
+
url: `/customer/orders/${reference}/tracking`,
|
|
32
|
+
method: 'GET'
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async cancel( reference: string, body: CustomerOrderCancelValidation['body'] ): Promise<CustomerOrderCancelValidation['response']> {
|
|
37
|
+
return await this.http.request<CustomerOrderCancelValidation['response']>({
|
|
38
|
+
url: `/customer/orders/${reference}/cancel`,
|
|
39
|
+
method: 'POST',
|
|
40
|
+
body
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async rating( reference: string, body: CustomerOrderRatingValidation['body'] ): Promise<CustomerOrderRatingValidation['response']> {
|
|
45
|
+
return await this.http.request<CustomerOrderRatingValidation['response']>({
|
|
46
|
+
url: `/customer/orders/${reference}/rating`,
|
|
47
|
+
method: 'POST',
|
|
48
|
+
body
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CustomerRideRequestValidation,
|
|
3
|
+
CustomerRideListValidation,
|
|
4
|
+
CustomerRideGetValidation,
|
|
5
|
+
CustomerRideTrackingValidation,
|
|
6
|
+
CustomerRideCancelValidation,
|
|
7
|
+
CustomerRideRatingValidation
|
|
8
|
+
} from '@de./types'
|
|
9
|
+
import { qs, type Http, type Res, type Data } from '../../utils'
|
|
10
|
+
|
|
11
|
+
// ─── Customer Rides ───────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
export default class CustomerRides {
|
|
14
|
+
constructor( private http: Http ){}
|
|
15
|
+
|
|
16
|
+
async request( body: CustomerRideRequestValidation['body'] ): Promise<CustomerRideRequestValidation['response']> {
|
|
17
|
+
return await this.http.request<CustomerRideRequestValidation['response']>({
|
|
18
|
+
url: '/customer/rides',
|
|
19
|
+
method: 'POST',
|
|
20
|
+
body
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async list( querystring?: CustomerRideListValidation['querystring'] ): Promise<CustomerRideListValidation['response']> {
|
|
25
|
+
return await this.http.request<CustomerRideListValidation['response']>({
|
|
26
|
+
url: `/customer/rides${qs( querystring )}`,
|
|
27
|
+
method: 'GET'
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async get( reference: string ): Promise<CustomerRideGetValidation['response']> {
|
|
32
|
+
return await this.http.request<CustomerRideGetValidation['response']>({
|
|
33
|
+
url: `/customer/rides/${reference}`,
|
|
34
|
+
method: 'GET'
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async tracking( reference: string ): Promise<CustomerRideTrackingValidation['response']> {
|
|
39
|
+
return await this.http.request<CustomerRideTrackingValidation['response']>({
|
|
40
|
+
url: `/customer/rides/${reference}/tracking`,
|
|
41
|
+
method: 'GET'
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async cancel( reference: string, body: CustomerRideCancelValidation['body'] ): Promise<CustomerRideCancelValidation['response']> {
|
|
46
|
+
return await this.http.request<CustomerRideCancelValidation['response']>({
|
|
47
|
+
url: `/customer/rides/${reference}/cancel`,
|
|
48
|
+
method: 'POST',
|
|
49
|
+
body
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async rating( reference: string, body: CustomerRideRatingValidation['body'] ): Promise<CustomerRideRatingValidation['response']> {
|
|
54
|
+
return await this.http.request<CustomerRideRatingValidation['response']>({
|
|
55
|
+
url: `/customer/rides/${reference}/rating`,
|
|
56
|
+
method: 'POST',
|
|
57
|
+
body
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { APIResponseBase } from '@de./types'
|
|
2
|
+
import type {
|
|
3
|
+
DEVDeveloperRetrieveValidation,
|
|
4
|
+
DEVDeveloperFetchValidation,
|
|
5
|
+
DEVDeveloperUpdateValidation
|
|
6
|
+
} from '@de./types/dev/developer'
|
|
7
|
+
import { type Http, type Res, type Data } from '../../utils'
|
|
8
|
+
|
|
9
|
+
// ── DEV Developers ──────────────────────────────────────────────────────────────
|
|
10
|
+
|
|
11
|
+
export default class DEVDevelopers {
|
|
12
|
+
constructor( private http: Http ){}
|
|
13
|
+
|
|
14
|
+
async list(): Promise<DEVDeveloperFetchValidation['response']> {
|
|
15
|
+
return await this.http.request<DEVDeveloperFetchValidation['response']>({
|
|
16
|
+
url: '/dev/developers',
|
|
17
|
+
method: 'GET'
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async retrieve( id: string ): Promise<DEVDeveloperRetrieveValidation['response']> {
|
|
22
|
+
return await this.http.request<DEVDeveloperRetrieveValidation['response']>({
|
|
23
|
+
url: `/dev/developers/${id}`,
|
|
24
|
+
method: 'GET'
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async update( id: string, body: DEVDeveloperUpdateValidation['body'] ): Promise<DEVDeveloperUpdateValidation['response']> {
|
|
29
|
+
return await this.http.request<DEVDeveloperUpdateValidation['response']>({
|
|
30
|
+
url: `/dev/developers/${id}`,
|
|
31
|
+
method: 'PATCH',
|
|
32
|
+
body
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async remove( id: string ): Promise<APIResponseBase> {
|
|
37
|
+
return await this.http.request<APIResponseBase>({
|
|
38
|
+
url: `/dev/developers/${id}`,
|
|
39
|
+
method: 'DELETE'
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AccessOptions } from '../../types/access'
|
|
2
|
+
import SharedContextClient from '../Shared/context'
|
|
3
|
+
import SharedOperators from '../Shared/operators'
|
|
4
|
+
import DEVDevelopers from './developers'
|
|
5
|
+
|
|
6
|
+
export type DEVConfig = {
|
|
7
|
+
context: string
|
|
8
|
+
accessToken: string
|
|
9
|
+
env?: 'dev' | 'staging' | 'prod'
|
|
10
|
+
platform?: 'web' | 'mobile' | 'server' | 'proxy'
|
|
11
|
+
remoteOrigin?: string
|
|
12
|
+
/** Per-request deadline in ms. See `AccessOptions.timeout`. */
|
|
13
|
+
timeout?: number
|
|
14
|
+
/** Explicit service origin, overriding the env table. See `AccessOptions.baseUrl`. */
|
|
15
|
+
baseUrl?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
19
|
+
//
|
|
20
|
+
// DEV: Developer Service Provider API — de.arch /v1/dev routes.
|
|
21
|
+
// Covers developers, plus shared faqs/users/account/invitation (SharedContextClient)
|
|
22
|
+
// and operators.
|
|
23
|
+
//
|
|
24
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
25
|
+
|
|
26
|
+
export default class DEV extends SharedContextClient<'DEV'> {
|
|
27
|
+
readonly operators: SharedOperators<'DEV'>
|
|
28
|
+
readonly developers: DEVDevelopers
|
|
29
|
+
|
|
30
|
+
constructor( config: DEVConfig ){
|
|
31
|
+
if( !config.context ) throw new Error('Undefined context. See https://doc.dedot.io/sdk/dev')
|
|
32
|
+
if( !config.accessToken ) throw new Error('Undefined accessToken. See https://doc.dedot.io/sdk/auth')
|
|
33
|
+
|
|
34
|
+
const access: AccessOptions = {
|
|
35
|
+
context: config.context,
|
|
36
|
+
accessToken: config.accessToken,
|
|
37
|
+
env: config.env || 'dev',
|
|
38
|
+
platform: config.platform || 'proxy',
|
|
39
|
+
remoteOrigin: config.remoteOrigin,
|
|
40
|
+
timeout: config.timeout,
|
|
41
|
+
baseUrl: config.baseUrl
|
|
42
|
+
}
|
|
43
|
+
super( access, 'DEV' )
|
|
44
|
+
|
|
45
|
+
this.operators = new SharedOperators( this, 'DEV' )
|
|
46
|
+
this.developers = new DEVDevelopers( this )
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { io, type Socket } from 'socket.io-client'
|
|
2
|
+
import { baseURL as resolveBaseURL } from '../../baseUrl'
|
|
3
|
+
|
|
4
|
+
// ─── Config ───────────────────────────────────────────────────────────────────
|
|
5
|
+
|
|
6
|
+
export type IoTBackendConfig = {
|
|
7
|
+
channel: string
|
|
8
|
+
accessToken: string
|
|
9
|
+
env?: 'dev' | 'staging' | 'prod'
|
|
10
|
+
/** Host to substitute for `localhost` in `dev` (Eg. a native emulator) */
|
|
11
|
+
devHostname?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ─── Record API ───────────────────────────────────────────────────────────────
|
|
15
|
+
//
|
|
16
|
+
// Thin wrapper around the socket-based IoT record operations.
|
|
17
|
+
// All methods return promises that resolve with the broker's ack payload.
|
|
18
|
+
|
|
19
|
+
export class Records {
|
|
20
|
+
constructor( private socket: Socket ){}
|
|
21
|
+
|
|
22
|
+
get( id: string ): Promise<any> {
|
|
23
|
+
return new Promise(( resolve, reject ) => {
|
|
24
|
+
if( !this.socket.connected )
|
|
25
|
+
return reject( new Error('Socket disconnected') )
|
|
26
|
+
|
|
27
|
+
this.socket.emit('@record:get', id, ( error: string, response: any ) =>
|
|
28
|
+
error ? reject( new Error( error ) ) : resolve( response )
|
|
29
|
+
)
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fetch( params: { limit?: number, page?: number } = {} ): Promise<any> {
|
|
34
|
+
return new Promise(( resolve, reject ) => {
|
|
35
|
+
if( !this.socket.connected )
|
|
36
|
+
return reject( new Error('Socket disconnected') )
|
|
37
|
+
|
|
38
|
+
this.socket.emit('@record:fetch', params, ( error: string, response: any ) =>
|
|
39
|
+
error ? reject( new Error( error ) ) : resolve( response )
|
|
40
|
+
)
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
find( query: string ): Promise<any> {
|
|
45
|
+
return new Promise(( resolve, reject ) => {
|
|
46
|
+
if( !this.socket.connected )
|
|
47
|
+
return reject( new Error('Socket disconnected') )
|
|
48
|
+
|
|
49
|
+
this.socket.emit('@record:find', query, ( error: string, response: any ) =>
|
|
50
|
+
error ? reject( new Error( error ) ) : resolve( response )
|
|
51
|
+
)
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
delete( id: string ): Promise<any> {
|
|
56
|
+
return new Promise(( resolve, reject ) => {
|
|
57
|
+
if( !this.socket.connected )
|
|
58
|
+
return reject( new Error('Socket disconnected') )
|
|
59
|
+
|
|
60
|
+
this.socket.emit('@record:del', id, ( error: string, response: any ) =>
|
|
61
|
+
error ? reject( new Error( error ) ) : resolve( response )
|
|
62
|
+
)
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
68
|
+
//
|
|
69
|
+
// IoT: realtime socket client for de.iotb channels.
|
|
70
|
+
//
|
|
71
|
+
// const iot = new IoT({ channel: 'fleet-1', accessToken: token })
|
|
72
|
+
// const { socket, records } = iot.connect()
|
|
73
|
+
//
|
|
74
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
75
|
+
|
|
76
|
+
export default class IoTBackend {
|
|
77
|
+
private config: IoTBackendConfig
|
|
78
|
+
private socket?: Socket
|
|
79
|
+
|
|
80
|
+
constructor( config: IoTBackendConfig ){
|
|
81
|
+
if( !config.channel ) throw new Error('Undefined channel. See https://doc.dedot.io/sdk/iot')
|
|
82
|
+
if( !config.accessToken ) throw new Error('Undefined accessToken. See https://doc.dedot.io/sdk/auth')
|
|
83
|
+
|
|
84
|
+
this.config = config
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
connect(): { socket: Socket, records: Records } {
|
|
88
|
+
const
|
|
89
|
+
host = resolveBaseURL('IOT', this.config.env || 'dev', this.config.devHostname ),
|
|
90
|
+
socket = io(`${host}/${this.config.channel}`, {
|
|
91
|
+
auth: { accessToken: this.config.accessToken }
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
socket,
|
|
96
|
+
records: new Records( socket )
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
disconnect(){
|
|
101
|
+
this.socket?.disconnect()
|
|
102
|
+
}
|
|
103
|
+
}
|