@burdenoff/microfe-movethewheels 2026.1107.2 → 2026.1107.4
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/MoveTheWheelsRoutes.js +9 -5
- package/dist/components/DispatchDecisionCard.js +203 -0
- package/dist/generated/tracking-quality-operations.d.ts +138 -1
- package/dist/generated/wspace-types.d.ts +448 -8
- package/dist/hooks/useDispatchPlan.js +88 -0
- package/dist/movethewheels/components/DispatchDecisionCard.d.ts +16 -0
- package/dist/movethewheels/hooks/useCarrierIntegrations.d.ts +2 -0
- package/dist/movethewheels/hooks/useDispatchPlan.d.ts +79 -0
- package/dist/movethewheels/pages/DispatchPlanPage.d.ts +14 -0
- package/dist/movethewheels/utils/carrierIntegrations.d.ts +38 -4
- package/dist/node_modules/lucide-react/dist/esm/icons/wand-sparkles.js +38 -0
- package/dist/pages/DispatchPlanPage.js +374 -0
- package/dist/pages/IntegrationsPage.js +324 -129
- package/dist/pages/RoutesPage.js +85 -80
- package/dist/utils/carrierIntegrations.js +62 -23
- package/package.json +1 -1
- package/src/generated/tracking-quality-operations.ts +157 -0
- package/src/generated/wspace-types.ts +518 -8
- package/src/movethewheels/MoveTheWheelsRoutes.tsx +2 -0
- package/src/movethewheels/components/DispatchDecisionCard.tsx +243 -0
- package/src/movethewheels/hooks/useCarrierIntegrations.ts +2 -0
- package/src/movethewheels/hooks/useDispatchPlan.ts +286 -0
- package/src/movethewheels/pages/DispatchPlanPage.tsx +505 -0
- package/src/movethewheels/pages/IntegrationsPage.tsx +266 -44
- package/src/movethewheels/pages/RoutesPage.tsx +9 -2
- package/src/movethewheels/utils/carrierIntegrations.ts +76 -8
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { useMoveTheWheels as e } from "../providers/MoveTheWheelsProvider.js";
|
|
2
|
+
import { executeGraphQL as t } from "../utils/graphqlClient.js";
|
|
3
|
+
import { useCallback as n, useEffect as r, useMemo as i, useState as a } from "react";
|
|
4
|
+
//#region src/movethewheels/hooks/useDispatchPlan.ts
|
|
5
|
+
var o = "\n id\n status\n method\n aiStatus\n aiSummary\n aiModel\n assignments {\n id\n sequence\n shipmentId\n shipmentNumber\n estimatedDelivery\n vehicleId\n vehicleNumber\n vehicleType\n driverId\n driverName\n confidence\n reasons\n rationale\n aiRationale\n estimatedDistanceKm\n estimatedDurationMinutes\n decision\n decisionReason\n routeId\n }\n unassigned {\n shipmentId\n shipmentNumber\n reason\n }\n acceptedCount\n rejectedCount\n staleCount\n pendingCount\n expiresAt\n decidedAt\n createdAt\n", s = `
|
|
6
|
+
query LatestDispatchPlan {
|
|
7
|
+
mtwLatestDispatchPlan {
|
|
8
|
+
${o}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`, c = `
|
|
12
|
+
mutation PlanDispatch($input: MtwPlanDispatchInput) {
|
|
13
|
+
mtwPlanDispatch(input: $input) {
|
|
14
|
+
${o}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`, l = `
|
|
18
|
+
mutation ApplyDispatchPlan($planId: ID!, $accept: [ID!]!) {
|
|
19
|
+
mtwApplyDispatchPlan(planId: $planId, accept: $accept) {
|
|
20
|
+
${o}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`, u = `
|
|
24
|
+
mutation RejectDispatchPlan($planId: ID!) {
|
|
25
|
+
mtwRejectDispatchPlan(planId: $planId) {
|
|
26
|
+
${o}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
function d() {
|
|
31
|
+
let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId: a, tenantId: o, currentUser: s } = e();
|
|
32
|
+
return i(() => ({
|
|
33
|
+
apiGatewayUrl: t,
|
|
34
|
+
authToken: n,
|
|
35
|
+
workspaceToken: r,
|
|
36
|
+
workspaceId: a,
|
|
37
|
+
tenantId: o,
|
|
38
|
+
actorId: s?.id
|
|
39
|
+
}), [
|
|
40
|
+
t,
|
|
41
|
+
n,
|
|
42
|
+
r,
|
|
43
|
+
a,
|
|
44
|
+
o,
|
|
45
|
+
s?.id
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
function f() {
|
|
49
|
+
let e = d(), [i, o] = a(null), [f, p] = a(!0), [m, h] = a(null), [g, _] = a(null), v = n(async () => {
|
|
50
|
+
p(!0), h(null);
|
|
51
|
+
try {
|
|
52
|
+
o((await t(e, s)).mtwLatestDispatchPlan);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
h(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load the dispatch plan"));
|
|
55
|
+
} finally {
|
|
56
|
+
p(!1);
|
|
57
|
+
}
|
|
58
|
+
}, [e]);
|
|
59
|
+
r(() => {
|
|
60
|
+
v();
|
|
61
|
+
}, [v]);
|
|
62
|
+
let y = n(async (e, t, n) => {
|
|
63
|
+
_(e);
|
|
64
|
+
try {
|
|
65
|
+
let e = n(await t());
|
|
66
|
+
return o(e), e;
|
|
67
|
+
} catch (e) {
|
|
68
|
+
throw v(), e;
|
|
69
|
+
} finally {
|
|
70
|
+
_(null);
|
|
71
|
+
}
|
|
72
|
+
}, [v]);
|
|
73
|
+
return {
|
|
74
|
+
plan: i,
|
|
75
|
+
isLoading: f,
|
|
76
|
+
error: m,
|
|
77
|
+
pendingAction: g,
|
|
78
|
+
refetch: () => void v(),
|
|
79
|
+
propose: n((n = {}) => y("propose", () => t(e, c, { input: n }, "SINGLE_ATTEMPT"), (e) => e.mtwPlanDispatch), [e, y]),
|
|
80
|
+
apply: n((n, r) => y("apply", () => t(e, l, {
|
|
81
|
+
planId: n,
|
|
82
|
+
accept: r
|
|
83
|
+
}, "SINGLE_ATTEMPT"), (e) => e.mtwApplyDispatchPlan), [e, y]),
|
|
84
|
+
reject: n((n) => y("reject", () => t(e, u, { planId: n }, "SINGLE_ATTEMPT"), (e) => e.mtwRejectDispatchPlan), [e, y])
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { f as useDispatchPlan };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DispatchAssignment } from '../hooks/useDispatchPlan';
|
|
2
|
+
export type DispatchChoice = 'accept' | 'reject' | null;
|
|
3
|
+
type Translate = (key: string, fallback: string) => string;
|
|
4
|
+
export declare function reasonLabel(reason: string, t: Translate): string;
|
|
5
|
+
interface DispatchDecisionCardProps {
|
|
6
|
+
assignment: DispatchAssignment;
|
|
7
|
+
/** True while the plan can still be decided. */
|
|
8
|
+
open: boolean;
|
|
9
|
+
choice: DispatchChoice;
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
onChoose: (choice: DispatchChoice) => void;
|
|
12
|
+
onOpenRoute: (routeId: string) => void;
|
|
13
|
+
t: Translate;
|
|
14
|
+
}
|
|
15
|
+
export declare function DispatchDecisionCard({ assignment, open, choice, disabled, onChoose, onOpenRoute, t, }: DispatchDecisionCardProps): import('react').JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -3,6 +3,8 @@ export interface CreateCarrierIntegrationInput {
|
|
|
3
3
|
provider: SupportedProvider;
|
|
4
4
|
name: string;
|
|
5
5
|
apiSecret: string;
|
|
6
|
+
/** Provider mapping settings (e.g. Samsara's shipment external id key). Never secrets. */
|
|
7
|
+
config?: Record<string, string>;
|
|
6
8
|
}
|
|
7
9
|
export interface UpdateCarrierIntegrationInput {
|
|
8
10
|
name?: string;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dispatch decision proposals (BOFF-10562).
|
|
3
|
+
*
|
|
4
|
+
* Reads the workspace's latest dispatch plan and drives its three decisions:
|
|
5
|
+
*
|
|
6
|
+
* - `propose` calls `mtwPlanDispatch`, which proposes vehicle + driver pairings
|
|
7
|
+
* for PLANNED shipments and writes no route.
|
|
8
|
+
* - `apply(acceptIds)` calls `mtwApplyDispatchPlan`: one PLANNED route per
|
|
9
|
+
* accepted assignment, every other assignment rejected. Partial accept is the
|
|
10
|
+
* normal case.
|
|
11
|
+
* - `reject` calls `mtwRejectDispatchPlan`, which writes nothing else.
|
|
12
|
+
*
|
|
13
|
+
* The server decides everything (eligibility, staleness, expiry, AI credit
|
|
14
|
+
* gating). This hook only reflects the plan the server returns after each
|
|
15
|
+
* call, so what a person sees is always the stored record.
|
|
16
|
+
*/
|
|
17
|
+
export type DispatchPlanStatus = 'PROPOSED' | 'APPLYING' | 'APPLIED' | 'PARTIALLY_APPLIED' | 'REJECTED' | 'EXPIRED';
|
|
18
|
+
export type DispatchAssignmentDecision = 'PENDING' | 'ACCEPTED' | 'REJECTED' | 'STALE';
|
|
19
|
+
export type DecisionRationaleStatus = 'AVAILABLE' | 'NOT_NEEDED' | 'AI_DISABLED' | 'CREDITS_EXHAUSTED' | 'DAILY_CAP_REACHED' | 'UNAVAILABLE';
|
|
20
|
+
export interface DispatchAssignment {
|
|
21
|
+
id: string;
|
|
22
|
+
sequence: number;
|
|
23
|
+
shipmentId: string;
|
|
24
|
+
shipmentNumber: string | null;
|
|
25
|
+
estimatedDelivery: string | null;
|
|
26
|
+
vehicleId: string;
|
|
27
|
+
vehicleNumber: string | null;
|
|
28
|
+
vehicleType: string | null;
|
|
29
|
+
driverId: string;
|
|
30
|
+
driverName: string | null;
|
|
31
|
+
confidence: number;
|
|
32
|
+
reasons: string[];
|
|
33
|
+
rationale: string;
|
|
34
|
+
aiRationale: string | null;
|
|
35
|
+
estimatedDistanceKm: number | null;
|
|
36
|
+
estimatedDurationMinutes: number | null;
|
|
37
|
+
decision: DispatchAssignmentDecision;
|
|
38
|
+
decisionReason: string | null;
|
|
39
|
+
routeId: string | null;
|
|
40
|
+
}
|
|
41
|
+
export interface UnassignedShipment {
|
|
42
|
+
shipmentId: string;
|
|
43
|
+
shipmentNumber: string | null;
|
|
44
|
+
reason: string;
|
|
45
|
+
}
|
|
46
|
+
export interface DispatchPlan {
|
|
47
|
+
id: string;
|
|
48
|
+
status: DispatchPlanStatus;
|
|
49
|
+
method: string;
|
|
50
|
+
aiStatus: DecisionRationaleStatus;
|
|
51
|
+
aiSummary: string | null;
|
|
52
|
+
aiModel: string | null;
|
|
53
|
+
assignments: DispatchAssignment[];
|
|
54
|
+
unassigned: UnassignedShipment[];
|
|
55
|
+
acceptedCount: number;
|
|
56
|
+
rejectedCount: number;
|
|
57
|
+
staleCount: number;
|
|
58
|
+
pendingCount: number;
|
|
59
|
+
expiresAt: string;
|
|
60
|
+
decidedAt: string | null;
|
|
61
|
+
createdAt: string;
|
|
62
|
+
}
|
|
63
|
+
export interface PlanDispatchOptions {
|
|
64
|
+
/** ISO date-time: only shipments due at or after this. */
|
|
65
|
+
from?: string;
|
|
66
|
+
/** ISO date-time: only shipments due at or before this. */
|
|
67
|
+
to?: string;
|
|
68
|
+
maxAssignments?: number;
|
|
69
|
+
}
|
|
70
|
+
export declare function useDispatchPlan(): {
|
|
71
|
+
plan: DispatchPlan | null;
|
|
72
|
+
isLoading: boolean;
|
|
73
|
+
error: Error | null;
|
|
74
|
+
pendingAction: "reject" | "propose" | "apply" | null;
|
|
75
|
+
refetch: () => undefined;
|
|
76
|
+
propose: (options?: PlanDispatchOptions) => Promise<DispatchPlan>;
|
|
77
|
+
apply: (planId: string, accept: string[]) => Promise<DispatchPlan>;
|
|
78
|
+
reject: (planId: string) => Promise<DispatchPlan>;
|
|
79
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dispatch planner (BOFF-10562)
|
|
3
|
+
*
|
|
4
|
+
* Decision cards for `mtwPlanDispatch` proposals. The planner proposes a
|
|
5
|
+
* vehicle + driver for each PLANNED shipment without a route; nothing is
|
|
6
|
+
* written until the dispatcher accepts. Accepting some cards and applying
|
|
7
|
+
* creates one PLANNED route per accepted card (partial accept); everything not
|
|
8
|
+
* accepted is rejected. Rejecting the plan writes nothing.
|
|
9
|
+
*
|
|
10
|
+
* Graceful degradation: when AI is switched off, the workspace's AI credits are
|
|
11
|
+
* spent or the model fails, the plan is the same and only the AI-written text
|
|
12
|
+
* is missing; manual route creation is always one click away.
|
|
13
|
+
*/
|
|
14
|
+
export default function DispatchPlanPage(): import('react').JSX.Element;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Providers this page can connect. The service also ingests SHIPROCKET, which
|
|
3
|
+
* is set up from the Shiprocket carrier flow rather than here.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SUPPORTED_PROVIDERS: readonly ["GENERIC_WEBHOOK", "SAMSARA"];
|
|
3
6
|
export type SupportedProvider = (typeof SUPPORTED_PROVIDERS)[number];
|
|
4
|
-
/** Named networks
|
|
7
|
+
/** Named networks without an adapter yet; the service refuses the reserved ones. */
|
|
5
8
|
export declare const ROADMAP_PROVIDERS: readonly [{
|
|
6
9
|
readonly id: "PROJECT44";
|
|
7
10
|
readonly label: "project44";
|
|
@@ -12,9 +15,40 @@ export declare const ROADMAP_PROVIDERS: readonly [{
|
|
|
12
15
|
readonly id: "DESCARTES";
|
|
13
16
|
readonly label: "Descartes";
|
|
14
17
|
}];
|
|
18
|
+
/** ELD networks planned after Samsara (BOFF-10703 follow-ups); not in the schema yet. */
|
|
19
|
+
export declare const PLANNED_ELD_PROVIDERS: readonly ["Motive", "Geotab"];
|
|
15
20
|
export declare const INTEGRATION_STATUSES: readonly ["ACTIVE", "PAUSED", "DISABLED"];
|
|
16
21
|
export type IntegrationStatus = (typeof INTEGRATION_STATUSES)[number];
|
|
17
|
-
export type IntegrationProvider = 'GENERIC_WEBHOOK' | 'PROJECT44' | 'FOURKITES' | 'DESCARTES';
|
|
22
|
+
export type IntegrationProvider = 'GENERIC_WEBHOOK' | 'SAMSARA' | 'SHIPROCKET' | 'PROJECT44' | 'FOURKITES' | 'DESCARTES';
|
|
23
|
+
/** How each provider is named on the page. */
|
|
24
|
+
export declare function providerLabel(provider: IntegrationProvider): string;
|
|
25
|
+
/** Samsara webhook event types the service turns into tracking events. */
|
|
26
|
+
export declare const SAMSARA_EVENT_TYPES: readonly [{
|
|
27
|
+
readonly type: "RouteStopArrival";
|
|
28
|
+
readonly becomes: "ARRIVED";
|
|
29
|
+
}, {
|
|
30
|
+
readonly type: "RouteStopDeparture";
|
|
31
|
+
readonly becomes: "DEPARTED";
|
|
32
|
+
}, {
|
|
33
|
+
readonly type: "GeofenceEntry";
|
|
34
|
+
readonly becomes: "ARRIVED";
|
|
35
|
+
}, {
|
|
36
|
+
readonly type: "GeofenceExit";
|
|
37
|
+
readonly becomes: "DEPARTED";
|
|
38
|
+
}];
|
|
39
|
+
/** Route or stop external id key the service reads the shipment reference from by default. */
|
|
40
|
+
export declare const DEFAULT_SAMSARA_SHIPMENT_KEY = "mtwShipment";
|
|
41
|
+
/** The service refuses Samsara secrets that decode to fewer bytes than this. */
|
|
42
|
+
export declare const MIN_SAMSARA_SECRET_BYTES = 16;
|
|
43
|
+
/**
|
|
44
|
+
* Returns an error message for an unusable Samsara webhook secret, or null.
|
|
45
|
+
* Samsara shows the secret Base64-encoded; it must be pasted exactly.
|
|
46
|
+
*/
|
|
47
|
+
export declare function samsaraSecretError(secret: string): string | null;
|
|
48
|
+
/** Returns an error message for an unusable external id key, or null. */
|
|
49
|
+
export declare function externalIdKeyError(key: string): string | null;
|
|
50
|
+
/** Headers Samsara signs each delivery with; the workspace gateway forwards both. */
|
|
51
|
+
export declare const SAMSARA_SIGNATURE_HEADERS: readonly ["X-Samsara-Signature", "X-Samsara-Timestamp"];
|
|
18
52
|
export type IntegrationEventStatus = 'RECEIVED' | 'ACCEPTED' | 'PARTIAL' | 'REJECTED' | 'DUPLICATE' | 'CONFLICT';
|
|
19
53
|
/** Tracking event types a delivery may carry (the service's TrackingEventType). */
|
|
20
54
|
export declare const TRACKING_EVENT_TYPES: readonly ["CREATED", "PICKED_UP", "IN_TRANSIT", "ARRIVED", "DEPARTED", "OUT_FOR_DELIVERY", "DELIVERED", "FAILED", "RETURNED"];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createLucideIcon as e } from "../createLucideIcon.js";
|
|
2
|
+
//#region node_modules/lucide-react/dist/esm/icons/wand-sparkles.js
|
|
3
|
+
var t = e("WandSparkles", [
|
|
4
|
+
["path", {
|
|
5
|
+
d: "m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",
|
|
6
|
+
key: "ul74o6"
|
|
7
|
+
}],
|
|
8
|
+
["path", {
|
|
9
|
+
d: "m14 7 3 3",
|
|
10
|
+
key: "1r5n42"
|
|
11
|
+
}],
|
|
12
|
+
["path", {
|
|
13
|
+
d: "M5 6v4",
|
|
14
|
+
key: "ilb8ba"
|
|
15
|
+
}],
|
|
16
|
+
["path", {
|
|
17
|
+
d: "M19 14v4",
|
|
18
|
+
key: "blhpug"
|
|
19
|
+
}],
|
|
20
|
+
["path", {
|
|
21
|
+
d: "M10 2v2",
|
|
22
|
+
key: "7u0qdc"
|
|
23
|
+
}],
|
|
24
|
+
["path", {
|
|
25
|
+
d: "M7 8H3",
|
|
26
|
+
key: "zfb6yr"
|
|
27
|
+
}],
|
|
28
|
+
["path", {
|
|
29
|
+
d: "M21 16h-4",
|
|
30
|
+
key: "1cnmox"
|
|
31
|
+
}],
|
|
32
|
+
["path", {
|
|
33
|
+
d: "M11 3H9",
|
|
34
|
+
key: "1obp7u"
|
|
35
|
+
}]
|
|
36
|
+
]);
|
|
37
|
+
//#endregion
|
|
38
|
+
export { t as WandSparkles };
|