feat: remove FM feature from Vector
CI / Lint · Typecheck · Test · Build (push) Failing after 36s
CI / Playwright (smoke) (push) Has been skipped
CI / Build & push images (push) Has been skipped

FMs move to a separate application. Drops Fm/FmPart tables + Repair.fmId
column, deletes FM_OPENED/FM_CLOSED PartEvent rows, strips FM enums +
webhook events + shared contracts, removes FM routes/services/pages/UI,
and collapses dashboard admin ops to Repairs 7d/30d + trend + custody
backlog.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-19 18:46:40 -04:00
parent d739411510
commit db8e86b749
32 changed files with 137 additions and 2192 deletions
-4
View File
@@ -30,10 +30,7 @@ export interface PartModelEolSummary {
export interface OperationsAnalytics {
repairs7d: number;
repairs30d: number;
newFms7d: number;
avgFmCloseHours30d: number | null;
repairsTrend30d: { date: string; count: number }[];
openFmsByHost: { hostId: string; hostName: string; count: number }[];
custodyBacklog: { userId: string; username: string; count: number }[];
}
@@ -44,6 +41,5 @@ export interface DashboardAnalytics {
topBins: BinCount[];
deployedPastEol: PartModelEolSummary[];
upcomingEol: PartModelEolSummary[];
openFms: number;
operations?: OperationsAnalytics;
}
-7
View File
@@ -25,8 +25,6 @@ export const PartEventType = z.enum([
'STATE_CHANGED',
'LOCATION_CHANGED',
'FIELD_UPDATED',
'FM_OPENED',
'FM_CLOSED',
'PART_SWAPPED',
'TAG_ADDED',
'TAG_REMOVED',
@@ -41,9 +39,6 @@ export const HostEventType = z.enum([
]);
export type HostEventType = z.infer<typeof HostEventType>;
export const FmStatus = z.enum(['OPEN', 'CLOSED']);
export type FmStatus = z.infer<typeof FmStatus>;
export const CsvImportStatus = z.enum([
'PENDING',
'STAGED',
@@ -60,8 +55,6 @@ export const WebhookEventName = z.enum([
'part.deleted',
'part.state_changed',
'part.location_changed',
'fm.opened',
'fm.closed',
'repair.logged',
'tag.assigned',
'tag.removed',
-52
View File
@@ -1,52 +0,0 @@
import { z } from 'zod';
import { FmStatus } from './enums.js';
import { PaginationQuery } from './pagination.js';
// Host lookup accepts either a uuid `hostId` or a string `assetId` — exactly one.
const hostSelector = {
hostId: z.string().uuid().optional(),
assetId: z.string().trim().min(1).max(128).optional(),
};
function hostSelectorRefine<T extends { hostId?: string; assetId?: string }>(
v: T,
ctx: z.RefinementCtx,
) {
const has = [v.hostId, v.assetId].filter((x) => x !== undefined && x !== '').length;
if (has !== 1) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'Provide exactly one of hostId or assetId',
path: ['hostId'],
});
}
}
export const CreateFmRequest = z
.object({
...hostSelector,
problem: z.string().trim().min(1, 'Problem is required').max(2000),
problemPartIds: z.array(z.string().uuid()).max(100).optional(),
})
.superRefine(hostSelectorRefine);
export type CreateFmRequest = z.infer<typeof CreateFmRequest>;
export const UpdateFmRequest = z
.object({
status: FmStatus.optional(),
problem: z.string().trim().min(1).max(2000).optional(),
problemPartIds: z.array(z.string().uuid()).max(100).optional(),
})
.refine((v) => Object.keys(v).length > 0, { message: 'At least one field required' });
export type UpdateFmRequest = z.infer<typeof UpdateFmRequest>;
export const FmListQuery = PaginationQuery.extend({
status: FmStatus.optional(),
hostId: z.string().uuid().optional(),
problemPartId: z.string().uuid().optional(),
openOnly: z
.union([z.literal('true'), z.literal('false'), z.boolean()])
.transform((v) => v === true || v === 'true')
.optional(),
});
export type FmListQuery = z.infer<typeof FmListQuery>;
-1
View File
@@ -9,7 +9,6 @@ export * from './env.js';
export * from './pagination.js';
export * from './hosts.js';
export * from './host-events.js';
export * from './fms.js';
export * from './repairs.js';
export * from './custody.js';
export * from './tags.js';
-2
View File
@@ -14,7 +14,6 @@ export const LogRepairRequest = z
brokenMpn: z.string().trim().min(1).max(128).optional(),
brokenManufacturerId: z.string().uuid().optional(),
replacementSerial: z.string().trim().min(1).max(128),
fmId: z.string().uuid().optional(),
})
.superRefine((v, ctx) => {
const hostHas = [v.hostId, v.assetId].filter((x) => x !== undefined && x !== '').length;
@@ -33,7 +32,6 @@ export type LogRepairRequest = z.infer<typeof LogRepairRequest>;
export const RepairListQuery = PaginationQuery.extend({
hostId: z.string().uuid().optional(),
performedById: z.string().uuid().optional(),
fmId: z.string().uuid().optional(),
since: z.string().datetime().optional(),
});
export type RepairListQuery = z.infer<typeof RepairListQuery>;