mirror of
https://github.com/Sea-Haven-Industries/sh-mcp.git
synced 2026-10-01 09:23:16 +00:00
125 lines
3.4 KiB
TypeScript
125 lines
3.4 KiB
TypeScript
|
|
/**
|
||
|
|
* InMemoryInternalDataClient — deterministic in-memory InternalDataClient.
|
||
|
|
*
|
||
|
|
* Holds a few FAKE work orders, purchase orders, and sites in memory. Returns
|
||
|
|
* null for unknown ids, matching the real client's contract. No AWS, no
|
||
|
|
* network.
|
||
|
|
*
|
||
|
|
* This is for build-plan §4 "in-memory dev clients (tools return real data
|
||
|
|
* locally)".
|
||
|
|
*/
|
||
|
|
|
||
|
|
import type {
|
||
|
|
InternalDataClient,
|
||
|
|
PurchaseOrderRecord,
|
||
|
|
SiteRecord,
|
||
|
|
WorkOrderRecord,
|
||
|
|
} from './client.js';
|
||
|
|
|
||
|
|
function seedWorkOrders(): Map<string, WorkOrderRecord> {
|
||
|
|
return new Map<string, WorkOrderRecord>([
|
||
|
|
[
|
||
|
|
'WO-1001',
|
||
|
|
{
|
||
|
|
workOrderId: 'WO-1001',
|
||
|
|
title: 'Replace dock lighting circuit',
|
||
|
|
status: 'in_progress',
|
||
|
|
siteId: 'SITE-01',
|
||
|
|
assignedTo: 'lauren@seahavenind.com',
|
||
|
|
createdAt: '2026-06-18T08:00:00Z',
|
||
|
|
updatedAt: '2026-06-22T16:30:00Z',
|
||
|
|
description: 'Pier B lighting circuit tripping under load; replace breaker and run.',
|
||
|
|
},
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'WO-1002',
|
||
|
|
{
|
||
|
|
workOrderId: 'WO-1002',
|
||
|
|
title: 'Quarterly HVAC inspection',
|
||
|
|
status: 'open',
|
||
|
|
siteId: 'SITE-02',
|
||
|
|
createdAt: '2026-06-20T10:15:00Z',
|
||
|
|
updatedAt: '2026-06-20T10:15:00Z',
|
||
|
|
},
|
||
|
|
],
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
function seedPurchaseOrders(): Map<string, PurchaseOrderRecord> {
|
||
|
|
return new Map<string, PurchaseOrderRecord>([
|
||
|
|
[
|
||
|
|
'PO-2001',
|
||
|
|
{
|
||
|
|
purchaseOrderId: 'PO-2001',
|
||
|
|
vendor: 'Coastal Supply & Hardware',
|
||
|
|
status: 'approved',
|
||
|
|
totalAmount: 1842.5,
|
||
|
|
currency: 'USD',
|
||
|
|
issuedAt: '2026-06-15T12:00:00Z',
|
||
|
|
updatedAt: '2026-06-16T09:00:00Z',
|
||
|
|
lineItems: [
|
||
|
|
{ description: 'Marine-grade breaker 30A', quantity: 4, unitPrice: 210.0 },
|
||
|
|
{ description: 'THWN wire, 250ft spool', quantity: 1, unitPrice: 1002.5 },
|
||
|
|
],
|
||
|
|
},
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'PO-2002',
|
||
|
|
{
|
||
|
|
purchaseOrderId: 'PO-2002',
|
||
|
|
vendor: 'Tidewater Plumbing LLC',
|
||
|
|
status: 'pending',
|
||
|
|
totalAmount: 640.0,
|
||
|
|
currency: 'USD',
|
||
|
|
issuedAt: '2026-06-19T15:30:00Z',
|
||
|
|
updatedAt: '2026-06-19T15:30:00Z',
|
||
|
|
},
|
||
|
|
],
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
function seedSites(): Map<string, SiteRecord> {
|
||
|
|
return new Map<string, SiteRecord>([
|
||
|
|
[
|
||
|
|
'SITE-01',
|
||
|
|
{
|
||
|
|
siteId: 'SITE-01',
|
||
|
|
name: 'Marina Pier Complex',
|
||
|
|
address: '88 Marina Way, Sea Haven, NY 11790',
|
||
|
|
region: 'North Shore',
|
||
|
|
status: 'active',
|
||
|
|
assignedTechnicians: ['lauren@seahavenind.com'],
|
||
|
|
},
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'SITE-02',
|
||
|
|
{
|
||
|
|
siteId: 'SITE-02',
|
||
|
|
name: 'Bayfront Warehouse',
|
||
|
|
address: '23 Bayfront Rd, Sea Haven, NY 11790',
|
||
|
|
region: 'North Shore',
|
||
|
|
status: 'active',
|
||
|
|
},
|
||
|
|
],
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** In-memory InternalDataClient seeded with a few fake records. */
|
||
|
|
export class InMemoryInternalDataClient implements InternalDataClient {
|
||
|
|
private readonly workOrders = seedWorkOrders();
|
||
|
|
private readonly purchaseOrders = seedPurchaseOrders();
|
||
|
|
private readonly sites = seedSites();
|
||
|
|
|
||
|
|
async getWorkOrder(workOrderId: string): Promise<WorkOrderRecord | null> {
|
||
|
|
return this.workOrders.get(workOrderId) ?? null;
|
||
|
|
}
|
||
|
|
|
||
|
|
async getPurchaseOrder(purchaseOrderId: string): Promise<PurchaseOrderRecord | null> {
|
||
|
|
return this.purchaseOrders.get(purchaseOrderId) ?? null;
|
||
|
|
}
|
||
|
|
|
||
|
|
async getSite(siteId: string): Promise<SiteRecord | null> {
|
||
|
|
return this.sites.get(siteId) ?? null;
|
||
|
|
}
|
||
|
|
}
|