Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
97 lines
3.2 KiB
TypeScript
97 lines
3.2 KiB
TypeScript
type ScheduleEntryLike = {
|
|
entry_id: string;
|
|
work_item_type?: string | null;
|
|
work_item_id?: string | null;
|
|
status?: string | null;
|
|
assigned_user_ids?: string[] | null;
|
|
};
|
|
|
|
function normalizeStatus(status: string | null | undefined): string {
|
|
return String(status ?? '').trim().toLowerCase();
|
|
}
|
|
|
|
export function isTechnicianEnRouteStatus(status: string | null | undefined): boolean {
|
|
const s = normalizeStatus(status);
|
|
return s === 'en_route' || s === 'en-route' || s === 'en route' || s === 'enroute';
|
|
}
|
|
|
|
export function isTechnicianArrivedStatus(status: string | null | undefined): boolean {
|
|
const s = normalizeStatus(status);
|
|
return s === 'arrived' || s === 'on_site' || s === 'on-site' || s === 'on site' || s === 'onsite';
|
|
}
|
|
|
|
export function isTechnicianCheckedOutStatus(status: string | null | undefined): boolean {
|
|
const s = normalizeStatus(status);
|
|
return s === 'checked_out' || s === 'checked-out' || s === 'checked out' || s === 'checkedout';
|
|
}
|
|
|
|
export function shouldEmitTechnicianDispatchEvents(entry: ScheduleEntryLike): boolean {
|
|
return entry.work_item_type === 'appointment_request' || entry.work_item_type === 'ticket';
|
|
}
|
|
|
|
export function getTechnicianUserIds(entry: ScheduleEntryLike): string[] {
|
|
const ids = entry.assigned_user_ids ?? [];
|
|
return Array.from(new Set(ids.filter((id): id is string => typeof id === 'string' && id.length > 0)));
|
|
}
|
|
|
|
export function buildTechnicianDispatchedPayload(params: {
|
|
appointmentId: string;
|
|
ticketId?: string;
|
|
technicianUserId: string;
|
|
dispatchedByUserId?: string;
|
|
}): Record<string, unknown> {
|
|
return {
|
|
appointmentId: params.appointmentId,
|
|
...(params.ticketId ? { ticketId: params.ticketId } : {}),
|
|
technicianUserId: params.technicianUserId,
|
|
...(params.dispatchedByUserId ? { dispatchedByUserId: params.dispatchedByUserId } : {}),
|
|
dispatchedAt: new Date().toISOString(),
|
|
};
|
|
}
|
|
|
|
export function buildTechnicianEnRoutePayload(params: {
|
|
appointmentId: string;
|
|
ticketId?: string;
|
|
technicianUserId: string;
|
|
eta?: string;
|
|
}): Record<string, unknown> {
|
|
return {
|
|
appointmentId: params.appointmentId,
|
|
...(params.ticketId ? { ticketId: params.ticketId } : {}),
|
|
technicianUserId: params.technicianUserId,
|
|
startedAt: new Date().toISOString(),
|
|
...(params.eta ? { eta: params.eta } : {}),
|
|
};
|
|
}
|
|
|
|
export function buildTechnicianArrivedPayload(params: {
|
|
appointmentId: string;
|
|
ticketId?: string;
|
|
technicianUserId: string;
|
|
location?: string;
|
|
}): Record<string, unknown> {
|
|
return {
|
|
appointmentId: params.appointmentId,
|
|
...(params.ticketId ? { ticketId: params.ticketId } : {}),
|
|
technicianUserId: params.technicianUserId,
|
|
arrivedAt: new Date().toISOString(),
|
|
...(params.location ? { location: params.location } : {}),
|
|
};
|
|
}
|
|
|
|
export function buildTechnicianCheckedOutPayload(params: {
|
|
appointmentId: string;
|
|
ticketId?: string;
|
|
technicianUserId: string;
|
|
workSummary?: string;
|
|
}): Record<string, unknown> {
|
|
return {
|
|
appointmentId: params.appointmentId,
|
|
...(params.ticketId ? { ticketId: params.ticketId } : {}),
|
|
technicianUserId: params.technicianUserId,
|
|
checkedOutAt: new Date().toISOString(),
|
|
...(params.workSummary ? { workSummary: params.workSummary } : {}),
|
|
};
|
|
}
|
|
|