@burdenoff/microfe-movethewheels 2026.1031.6 → 2026.1101.1
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/MoveTheWheelsRoot.js +141 -133
- package/dist/MoveTheWheelsRoutes.js +29 -25
- package/dist/hooks/useCarrierIntegrations.js +141 -0
- package/dist/movethewheels/hooks/useCarrierIntegrations.d.ts +39 -0
- package/dist/movethewheels/pages/IntegrationsPage.d.ts +6 -0
- package/dist/movethewheels/utils/carrierIntegrations.d.ts +88 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/copy.js +16 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/pause.js +19 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/play.js +8 -0
- package/dist/pages/IntegrationsPage.js +616 -0
- package/dist/pages/SettingsPage.js +168 -150
- package/dist/utils/carrierIntegrations.js +105 -0
- package/package.json +3 -2
- package/src/movethewheels/MoveTheWheelsRoot.tsx +8 -0
- package/src/movethewheels/MoveTheWheelsRoutes.tsx +4 -0
- package/src/movethewheels/hooks/useCarrierIntegrations.ts +221 -0
- package/src/movethewheels/pages/IntegrationsPage.tsx +752 -0
- package/src/movethewheels/pages/SettingsPage.tsx +19 -3
- package/src/movethewheels/utils/carrierIntegrations.ts +252 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { useMoveTheWheels as e } from "../providers/MoveTheWheelsProvider.js";
|
|
2
|
+
import { executeGraphQL as t } from "../utils/graphqlClient.js";
|
|
3
|
+
import { CREATE_INTEGRATION_MUTATION as n, DELETE_INTEGRATION_MUTATION as r, INTEGRATION_COUNTS_QUERY as i, INTEGRATION_EVENTS_QUERY as a, LIST_INTEGRATIONS_QUERY as o, UPDATE_INTEGRATION_MUTATION as s } from "../utils/carrierIntegrations.js";
|
|
4
|
+
import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
5
|
+
//#region src/movethewheels/hooks/useCarrierIntegrations.ts
|
|
6
|
+
function p() {
|
|
7
|
+
let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId: i, tenantId: a, currentUser: o } = e();
|
|
8
|
+
return u(() => ({
|
|
9
|
+
apiGatewayUrl: t,
|
|
10
|
+
authToken: n,
|
|
11
|
+
workspaceToken: r,
|
|
12
|
+
workspaceId: i,
|
|
13
|
+
tenantId: a,
|
|
14
|
+
actorId: o?.id
|
|
15
|
+
}), [
|
|
16
|
+
t,
|
|
17
|
+
n,
|
|
18
|
+
r,
|
|
19
|
+
i,
|
|
20
|
+
a,
|
|
21
|
+
o?.id
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
function m(e, t) {
|
|
25
|
+
return e instanceof Error ? e : Error(t);
|
|
26
|
+
}
|
|
27
|
+
function h(e) {
|
|
28
|
+
let n = p(), { status: r, limit: i, offset: a } = e, [s, u] = f([]), [h, g] = f(0), [_, v] = f(!1), [y, b] = f(null), x = d(0), S = c(async () => {
|
|
29
|
+
let e = ++x.current;
|
|
30
|
+
v(!0), b(null);
|
|
31
|
+
try {
|
|
32
|
+
let s = await t(n, o, {
|
|
33
|
+
filter: r ? { status: r } : void 0,
|
|
34
|
+
pagination: {
|
|
35
|
+
limit: i,
|
|
36
|
+
offset: a
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
if (e !== x.current) return;
|
|
40
|
+
u(s.integrations), g(s.integrationsCount);
|
|
41
|
+
} catch (t) {
|
|
42
|
+
if (e !== x.current) return;
|
|
43
|
+
b(m(t, "Failed to load integrations"));
|
|
44
|
+
} finally {
|
|
45
|
+
e === x.current && v(!1);
|
|
46
|
+
}
|
|
47
|
+
}, [
|
|
48
|
+
n,
|
|
49
|
+
r,
|
|
50
|
+
i,
|
|
51
|
+
a
|
|
52
|
+
]);
|
|
53
|
+
l(() => (S(), () => {
|
|
54
|
+
x.current += 1;
|
|
55
|
+
}), [S]);
|
|
56
|
+
let C = d(S);
|
|
57
|
+
return l(() => {
|
|
58
|
+
C.current = S;
|
|
59
|
+
}, [S]), {
|
|
60
|
+
integrations: s,
|
|
61
|
+
total: h,
|
|
62
|
+
isLoading: _,
|
|
63
|
+
error: y,
|
|
64
|
+
refetch: c(() => C.current(), [])
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function g() {
|
|
68
|
+
let e = p(), [n, r] = f({
|
|
69
|
+
all: 0,
|
|
70
|
+
active: 0
|
|
71
|
+
}), a = d(0), o = c(async () => {
|
|
72
|
+
let n = ++a.current;
|
|
73
|
+
try {
|
|
74
|
+
let o = await t(e, i, {});
|
|
75
|
+
n === a.current && r({
|
|
76
|
+
all: o.all,
|
|
77
|
+
active: o.active
|
|
78
|
+
});
|
|
79
|
+
} catch {}
|
|
80
|
+
}, [e]);
|
|
81
|
+
return l(() => (o(), () => {
|
|
82
|
+
a.current += 1;
|
|
83
|
+
}), [o]), {
|
|
84
|
+
...n,
|
|
85
|
+
refetch: o
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function _(e, n, r = 20) {
|
|
89
|
+
let i = p(), [o, s] = f([]), [c, u] = f(!1), [d, h] = f(null);
|
|
90
|
+
return l(() => {
|
|
91
|
+
if (!e) {
|
|
92
|
+
s([]);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
let n = !1;
|
|
96
|
+
return u(!0), h(null), t(i, a, {
|
|
97
|
+
integrationId: e,
|
|
98
|
+
pagination: {
|
|
99
|
+
limit: r,
|
|
100
|
+
offset: 0
|
|
101
|
+
}
|
|
102
|
+
}).then((e) => {
|
|
103
|
+
n || s(e.integrationEvents);
|
|
104
|
+
}).catch((e) => {
|
|
105
|
+
n || h(m(e, "Failed to load deliveries"));
|
|
106
|
+
}).finally(() => {
|
|
107
|
+
n || u(!1);
|
|
108
|
+
}), () => {
|
|
109
|
+
n = !0;
|
|
110
|
+
};
|
|
111
|
+
}, [
|
|
112
|
+
i,
|
|
113
|
+
e,
|
|
114
|
+
n,
|
|
115
|
+
r
|
|
116
|
+
]), {
|
|
117
|
+
events: o,
|
|
118
|
+
isLoading: c,
|
|
119
|
+
error: d
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function v() {
|
|
123
|
+
let e = p();
|
|
124
|
+
return u(() => ({
|
|
125
|
+
create: async (r) => (await t(e, n, { input: {
|
|
126
|
+
...r,
|
|
127
|
+
name: r.name.trim(),
|
|
128
|
+
status: "ACTIVE"
|
|
129
|
+
} }, "SINGLE_ATTEMPT")).createIntegration,
|
|
130
|
+
update: async (n, r) => (await t(e, s, {
|
|
131
|
+
id: n,
|
|
132
|
+
input: r.name === void 0 ? r : {
|
|
133
|
+
...r,
|
|
134
|
+
name: r.name.trim()
|
|
135
|
+
}
|
|
136
|
+
})).updateIntegration,
|
|
137
|
+
remove: async (n) => (await t(e, r, { id: n })).deleteIntegration
|
|
138
|
+
}), [e]);
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
export { v as useCarrierIntegrationActions, g as useCarrierIntegrationCounts, _ as useCarrierIntegrationEvents, h as useCarrierIntegrations };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CarrierIntegration, CarrierIntegrationEvent, IntegrationStatus, SupportedProvider } from '../utils/carrierIntegrations';
|
|
2
|
+
export interface CreateCarrierIntegrationInput {
|
|
3
|
+
provider: SupportedProvider;
|
|
4
|
+
name: string;
|
|
5
|
+
apiSecret: string;
|
|
6
|
+
}
|
|
7
|
+
export interface UpdateCarrierIntegrationInput {
|
|
8
|
+
name?: string;
|
|
9
|
+
status?: IntegrationStatus;
|
|
10
|
+
apiSecret?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function useCarrierIntegrations(options: {
|
|
13
|
+
status?: IntegrationStatus;
|
|
14
|
+
limit: number;
|
|
15
|
+
offset: number;
|
|
16
|
+
}): {
|
|
17
|
+
integrations: CarrierIntegration[];
|
|
18
|
+
total: number;
|
|
19
|
+
isLoading: boolean;
|
|
20
|
+
error: Error | null;
|
|
21
|
+
refetch: () => Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
/** Workspace-wide feed counts (all and active) in one request, independent of the list filter. */
|
|
24
|
+
export declare function useCarrierIntegrationCounts(): {
|
|
25
|
+
refetch: () => Promise<void>;
|
|
26
|
+
all: number;
|
|
27
|
+
active: number;
|
|
28
|
+
};
|
|
29
|
+
/** The most recent deliveries for one integration, newest first. */
|
|
30
|
+
export declare function useCarrierIntegrationEvents(integrationId: string | null, refreshKey: number, limit?: number): {
|
|
31
|
+
events: CarrierIntegrationEvent[];
|
|
32
|
+
isLoading: boolean;
|
|
33
|
+
error: Error | null;
|
|
34
|
+
};
|
|
35
|
+
export declare function useCarrierIntegrationActions(): {
|
|
36
|
+
create: (input: CreateCarrierIntegrationInput) => Promise<CarrierIntegration>;
|
|
37
|
+
update: (id: string, input: UpdateCarrierIntegrationInput) => Promise<CarrierIntegration>;
|
|
38
|
+
remove: (id: string) => Promise<boolean>;
|
|
39
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remounts the page whenever the host switches tenant or workspace, so no
|
|
3
|
+
* server state, filter, page, pending reveal or in-flight mutation from the
|
|
4
|
+
* previous workspace survives into the next one.
|
|
5
|
+
*/
|
|
6
|
+
export default function IntegrationsPage(): import('react').JSX.Element;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** Providers the service can ingest today. Vendor adapters are refused by the API. */
|
|
2
|
+
export declare const SUPPORTED_PROVIDERS: readonly ["GENERIC_WEBHOOK"];
|
|
3
|
+
export type SupportedProvider = (typeof SUPPORTED_PROVIDERS)[number];
|
|
4
|
+
/** Named networks that need a signed vendor agreement before an adapter can ship. */
|
|
5
|
+
export declare const ROADMAP_PROVIDERS: readonly [{
|
|
6
|
+
readonly id: "PROJECT44";
|
|
7
|
+
readonly label: "project44";
|
|
8
|
+
}, {
|
|
9
|
+
readonly id: "FOURKITES";
|
|
10
|
+
readonly label: "FourKites";
|
|
11
|
+
}, {
|
|
12
|
+
readonly id: "DESCARTES";
|
|
13
|
+
readonly label: "Descartes";
|
|
14
|
+
}];
|
|
15
|
+
export declare const INTEGRATION_STATUSES: readonly ["ACTIVE", "PAUSED", "DISABLED"];
|
|
16
|
+
export type IntegrationStatus = (typeof INTEGRATION_STATUSES)[number];
|
|
17
|
+
export type IntegrationProvider = 'GENERIC_WEBHOOK' | 'PROJECT44' | 'FOURKITES' | 'DESCARTES';
|
|
18
|
+
export type IntegrationEventStatus = 'RECEIVED' | 'ACCEPTED' | 'PARTIAL' | 'REJECTED' | 'DUPLICATE' | 'CONFLICT';
|
|
19
|
+
/** Tracking event types a delivery may carry (the service's TrackingEventType). */
|
|
20
|
+
export declare const TRACKING_EVENT_TYPES: readonly ["CREATED", "PICKED_UP", "IN_TRANSIT", "ARRIVED", "DEPARTED", "OUT_FOR_DELIVERY", "DELIVERED", "FAILED", "RETURNED"];
|
|
21
|
+
/** The service refuses shorter secrets; the generator always produces 64 hex characters. */
|
|
22
|
+
export declare const MIN_SECRET_LENGTH = 32;
|
|
23
|
+
/** Header the workspace gateway forwards; custom headers do not survive the gateway. */
|
|
24
|
+
export declare const SIGNATURE_HEADER = "x-webhook-signature";
|
|
25
|
+
/** Updates accepted in one delivery (a JSON array of at most this many objects). */
|
|
26
|
+
export declare const MAX_UPDATES_PER_DELIVERY = 5;
|
|
27
|
+
export interface CarrierIntegration {
|
|
28
|
+
id: string;
|
|
29
|
+
workspaceId: string;
|
|
30
|
+
provider: IntegrationProvider;
|
|
31
|
+
name: string;
|
|
32
|
+
status: IntegrationStatus;
|
|
33
|
+
lastSyncAt: string | null;
|
|
34
|
+
lastErrorAt: string | null;
|
|
35
|
+
lastErrorMessage: string | null;
|
|
36
|
+
createdAt: string;
|
|
37
|
+
updatedAt: string;
|
|
38
|
+
}
|
|
39
|
+
export interface CarrierIntegrationEvent {
|
|
40
|
+
id: string;
|
|
41
|
+
integrationId: string;
|
|
42
|
+
externalEventId: string | null;
|
|
43
|
+
shipmentId: string | null;
|
|
44
|
+
eventType: string | null;
|
|
45
|
+
status: IntegrationEventStatus;
|
|
46
|
+
errorMessage: string | null;
|
|
47
|
+
receivedAt: string;
|
|
48
|
+
processedAt: string | null;
|
|
49
|
+
}
|
|
50
|
+
export declare const LIST_INTEGRATIONS_QUERY = "\n query MtwCarrierIntegrations($filter: IntegrationFilterInput, $pagination: PaginationInput) {\n integrations(filter: $filter, pagination: $pagination) {\n \n id\n workspaceId\n provider\n name\n status\n lastSyncAt\n lastErrorAt\n lastErrorMessage\n createdAt\n updatedAt\n\n }\n integrationsCount(filter: $filter)\n }\n";
|
|
51
|
+
export declare const INTEGRATION_COUNTS_QUERY = "\n query MtwCarrierIntegrationCounts {\n all: integrationsCount\n active: integrationsCount(filter: { status: ACTIVE })\n }\n";
|
|
52
|
+
export declare const INTEGRATION_EVENTS_QUERY = "\n query MtwCarrierIntegrationEvents($integrationId: ID, $pagination: PaginationInput) {\n integrationEvents(integrationId: $integrationId, pagination: $pagination) {\n id\n integrationId\n externalEventId\n shipmentId\n eventType\n status\n errorMessage\n receivedAt\n processedAt\n }\n }\n";
|
|
53
|
+
export declare const CREATE_INTEGRATION_MUTATION = "\n mutation CreateMtwCarrierIntegration($input: CreateIntegrationInput!) {\n createIntegration(input: $input) {\n \n id\n workspaceId\n provider\n name\n status\n lastSyncAt\n lastErrorAt\n lastErrorMessage\n createdAt\n updatedAt\n\n }\n }\n";
|
|
54
|
+
export declare const UPDATE_INTEGRATION_MUTATION = "\n mutation UpdateMtwCarrierIntegration($id: ID!, $input: UpdateIntegrationInput!) {\n updateIntegration(id: $id, input: $input) {\n \n id\n workspaceId\n provider\n name\n status\n lastSyncAt\n lastErrorAt\n lastErrorMessage\n createdAt\n updatedAt\n\n }\n }\n";
|
|
55
|
+
export declare const DELETE_INTEGRATION_MUTATION = "\n mutation DeleteMtwCarrierIntegration($id: ID!) {\n deleteIntegration(id: $id)\n }\n";
|
|
56
|
+
/** Minimal source of randomness, so tests can supply a deterministic one. */
|
|
57
|
+
export interface RandomSource {
|
|
58
|
+
getRandomValues<T extends ArrayBufferView>(array: T): T;
|
|
59
|
+
}
|
|
60
|
+
/** A fresh 256-bit signing secret as 64 lowercase hex characters. */
|
|
61
|
+
export declare function generateSigningSecret(random?: RandomSource): string;
|
|
62
|
+
/** Returns an error message for an unusable secret, or null when it is fine. */
|
|
63
|
+
export declare function signingSecretError(secret: string): string | null;
|
|
64
|
+
/** Returns an error message for an unusable name, or null when it is fine. */
|
|
65
|
+
export declare function integrationNameError(name: string): string | null;
|
|
66
|
+
/**
|
|
67
|
+
* The public URL a carrier posts deliveries to. It lives on the same workspace
|
|
68
|
+
* gateway host the app already talks to: `/api/integrations/webhook/<workspace>/<integration>`.
|
|
69
|
+
* A relative gateway URL (local development behind the dev proxy) resolves
|
|
70
|
+
* against `fallbackOrigin`.
|
|
71
|
+
*/
|
|
72
|
+
export declare function webhookUrl(apiGatewayUrl: string | undefined, workspaceId: string, integrationId: string, fallbackOrigin: string): string;
|
|
73
|
+
/** An example delivery body for the setup instructions. */
|
|
74
|
+
export declare function examplePayload(now?: Date): string;
|
|
75
|
+
/** Quotes a value for a POSIX shell: single quotes, with embedded ones escaped. */
|
|
76
|
+
export declare function shellQuote(value: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* A copy-paste shell example that signs and sends one delivery. The secret is
|
|
79
|
+
* referenced as an environment variable so it never appears in the snippet.
|
|
80
|
+
*/
|
|
81
|
+
export declare function curlExample(url: string): string;
|
|
82
|
+
/** "OUT_FOR_DELIVERY" → "Out for delivery". */
|
|
83
|
+
export declare function humanize(value: string): string;
|
|
84
|
+
export type BadgeTone = 'default' | 'secondary' | 'outline' | 'destructive';
|
|
85
|
+
export declare function integrationStatusTone(status: IntegrationStatus): BadgeTone;
|
|
86
|
+
export declare function eventStatusTone(status: IntegrationEventStatus): BadgeTone;
|
|
87
|
+
/** What a webhook sender sees for each status, shown next to the status control. */
|
|
88
|
+
export declare function statusExplanation(status: IntegrationStatus): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createLucideIcon as e } from "../createLucideIcon.js";
|
|
2
|
+
//#region node_modules/lucide-react/dist/esm/icons/copy.js
|
|
3
|
+
var t = e("Copy", [["rect", {
|
|
4
|
+
width: "14",
|
|
5
|
+
height: "14",
|
|
6
|
+
x: "8",
|
|
7
|
+
y: "8",
|
|
8
|
+
rx: "2",
|
|
9
|
+
ry: "2",
|
|
10
|
+
key: "17jyea"
|
|
11
|
+
}], ["path", {
|
|
12
|
+
d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",
|
|
13
|
+
key: "zix9uf"
|
|
14
|
+
}]]);
|
|
15
|
+
//#endregion
|
|
16
|
+
export { t as Copy };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createLucideIcon as e } from "../createLucideIcon.js";
|
|
2
|
+
//#region node_modules/lucide-react/dist/esm/icons/pause.js
|
|
3
|
+
var t = e("Pause", [["rect", {
|
|
4
|
+
x: "14",
|
|
5
|
+
y: "4",
|
|
6
|
+
width: "4",
|
|
7
|
+
height: "16",
|
|
8
|
+
rx: "1",
|
|
9
|
+
key: "zuxfzm"
|
|
10
|
+
}], ["rect", {
|
|
11
|
+
x: "6",
|
|
12
|
+
y: "4",
|
|
13
|
+
width: "4",
|
|
14
|
+
height: "16",
|
|
15
|
+
rx: "1",
|
|
16
|
+
key: "1okwgv"
|
|
17
|
+
}]]);
|
|
18
|
+
//#endregion
|
|
19
|
+
export { t as Pause };
|