← back to Desktop Dotbar

dw-segment.js

27 lines

'use strict';
// DW vs Non-DW segmentation for the bar's ticket-state row (Steve 2026-09-25: "add dw and non dw here").
//
// SOURCE OF TRUTH is the Fleet board's own classifier, ~/Projects/ticket-system/board.html
// (DW_DENY/DW_RE/DW_KW/DW_VENDOR/DW_EXTRA + autoDW/isDW). The board is client-side HTML with no
// requireable module, so the five constants below are copied VERBATIM. That copy is the drift
// hazard, so test/dw-segment.test.js re-reads board.html and fails if the two ever diverge —
// a silent divergence would make the bar's "dw 121" disagree with what the board shows when you
// click it, which is exactly the kind of number-that-means-nothing this row exists to avoid.
//
// A hand-set `segment` on the ticket ('dw' | 'nondw') always wins over the auto guess, same as
// the board — that is the whole point of the board's per-ticket segment dropdown.
//
// NOT the same thing as realm.js, and deliberately so: realm.js sorts live SESSIONS into dw/other
// by free-text signals (ticket title, `doing` label, process cwd) to scope the bar's dot groups.
// This sorts TICKETS, and its only job is to agree with the board it links to. Do not merge them.
const DW_DENY=new Set(['wallpapersback','abramsego','pattern-vault']); // look wallpaper-ish but are SEPARATE businesses
const DW_RE=/designerwallcoverings|designer-wallcoverings|dw_unified|(^|[^a-z])dw($|[^a-z])|(^|[^a-z])dw-/i;
const DW_KW=/wallcover|wallpaper/i;                                    // DW wallcovering sister-sites (architectural/contract/hospitality/goldleaf)
const DW_VENDOR=/(^|[^a-z])(sanderson|stroheim|muralsource|kravet|greenland|malibu|gracie|astek|fabricut|groundworks|rebel-walls|thibaut|schumacher|koroseal|scalamandre|maya-?romanoff|winfield|phillip-?jeffries|brewster|wallquest|carnegie|designtex|momentum|versa|elitis|fromental|fentucci|hollywood|novasuede|philipperomano|mdc)($|[^a-z])/i;
const DW_EXTRA=new Set(['norma','greenland-onboard','sample-followup','sample-followup-sweep','interiordesignershowroom','marketing-command-center','all-designerwallcoverings','consulting-designerwallcoverings-com','mfr-review-viewer','mfr-review-viewer-corruption','designersalesreps','vendor-command-center','discontinued-agent']);

function autoDW(t){const p=String((t&&t.project)||'').toLowerCase().trim();if(!p||DW_DENY.has(p))return false;return DW_EXTRA.has(p)||DW_RE.test(p)||DW_VENDOR.test(p)||DW_KW.test(p);}
function isDW(t){if(!t)return false;if(t.segment==='dw')return true;if(t.segment==='nondw')return false;return autoDW(t);}

module.exports = { isDW, autoDW, DW_DENY, DW_RE, DW_KW, DW_VENDOR, DW_EXTRA };