@resolveio/server-lib 22.3.225 → 22.3.227
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/package.json
CHANGED
|
@@ -1686,6 +1686,10 @@ function buildResolveIORunnerQaLiveDataSeederScript() {
|
|
|
1686
1686
|
' const candidates = [',
|
|
1687
1687
|
' path.join(artifactDir, "qa-coverage-matrix.json"),',
|
|
1688
1688
|
' path.join(artifactDir, "qa-row-lock.json"),',
|
|
1689
|
+
' path.join(artifactDir, "runner-evidence", "diagnosis-gate.json"),',
|
|
1690
|
+
' path.join(artifactDir, "runner-evidence", "support-diagnosis-gate.json"),',
|
|
1691
|
+
' path.join(projectRoot, "runner-evidence", "diagnosis-gate.json"),',
|
|
1692
|
+
' path.join(projectRoot, "runner-evidence", "support-diagnosis-gate.json"),',
|
|
1689
1693
|
' path.join(repoRoot, ".resolveio-support-context", "manual-ticket.request.txt"),',
|
|
1690
1694
|
' path.join(projectRoot, ".resolveio-support-context", "manual-ticket.request.txt"),',
|
|
1691
1695
|
' path.join(repoRoot, ".resolveio-context", "manual-ticket.request.txt"),',
|
|
@@ -1709,6 +1713,40 @@ function buildResolveIORunnerQaLiveDataSeederScript() {
|
|
|
1709
1713
|
' return chunks.filter(Boolean).join("\\n");',
|
|
1710
1714
|
'}',
|
|
1711
1715
|
'',
|
|
1716
|
+
'function shouldSeedPartInventorySnapshotContext() {',
|
|
1717
|
+
' const text = readSeedHintText();',
|
|
1718
|
+
' const snapshotSurface = /\\b(reportDailyInventorySnapshot|inventory-daily-snapshots|daily\\s+inventory\\s+snapshot|inventory\\s+snapshot|saved\\s+Part\\s+rows|Part\\s+rows|warehouse_location)\\b/i.test(text);',
|
|
1719
|
+
' const partSurface = /\\b(id_part|part\\s+inventory|affected\\s+part|Parts|Kermit|Midland|warehouse|yard)\\b/i.test(text);',
|
|
1720
|
+
' return snapshotSurface && partSurface;',
|
|
1721
|
+
'}',
|
|
1722
|
+
'',
|
|
1723
|
+
'function extractPartInventorySnapshotHints() {',
|
|
1724
|
+
' const text = readSeedHintText();',
|
|
1725
|
+
' const partIds = new Set();',
|
|
1726
|
+
' const yardIds = new Set();',
|
|
1727
|
+
' const dayKeys = new Set();',
|
|
1728
|
+
' let match;',
|
|
1729
|
+
' const partPattern = /\\b(?:id_part|part\\s*id|affected\\s+part)\\b[^0-9a-f]{0,100}([0-9a-f]{24})\\b/gi;',
|
|
1730
|
+
' while ((match = partPattern.exec(text)) !== null) partIds.add(String(match[1]).toLowerCase());',
|
|
1731
|
+
' const yardPattern = /\\b(?:id_yard|yard\\s*id)\\b[^0-9a-f]{0,100}([0-9a-f]{24})\\b/gi;',
|
|
1732
|
+
' while ((match = yardPattern.exec(text)) !== null) yardIds.add(String(match[1]).toLowerCase());',
|
|
1733
|
+
' const dayKeyPattern = /\\b(?:day_key|snapshot\\s+date|report\\s+date|date)\\b\\s*[=:]?\\s*[`\\\'"]?(\\d{4}-\\d{2}-\\d{2})\\b/gi;',
|
|
1734
|
+
' while ((match = dayKeyPattern.exec(text)) !== null) dayKeys.add(match[1]);',
|
|
1735
|
+
' if (shouldSeedPartInventorySnapshotContext()) {',
|
|
1736
|
+
' const contextualHex = /\\b[0-9a-f]{24}\\b/gi;',
|
|
1737
|
+
' while ((match = contextualHex.exec(text)) !== null && partIds.size < 12) {',
|
|
1738
|
+
' const start = Math.max(0, match.index - 120);',
|
|
1739
|
+
' const end = Math.min(text.length, match.index + 144);',
|
|
1740
|
+
' const around = text.slice(start, end);',
|
|
1741
|
+
' const before = text.slice(Math.max(0, match.index - 48), match.index);',
|
|
1742
|
+
' const after = text.slice(match.index, Math.min(text.length, match.index + 72));',
|
|
1743
|
+
' if (/\\b(id_yard|yard\\s*id)\\b/i.test(before)) { yardIds.add(String(match[0]).toLowerCase()); continue; }',
|
|
1744
|
+
' if (/\\b(id_part|part\\s*id|affected\\s+part)\\b/i.test(before + after)) partIds.add(String(match[0]).toLowerCase());',
|
|
1745
|
+
' }',
|
|
1746
|
+
' }',
|
|
1747
|
+
' return { partIds: Array.from(partIds).slice(0, 16), yardIds: Array.from(yardIds).slice(0, 16), dayKeys: Array.from(dayKeys).slice(0, 12) };',
|
|
1748
|
+
'}',
|
|
1749
|
+
'',
|
|
1712
1750
|
'function isUsefulSeedIdentifier(value) {',
|
|
1713
1751
|
' const cleaned = String(value || "").trim().replace(/^[#:\\-]+|[.,;:)\\]]+$/g, "");',
|
|
1714
1752
|
' if (!cleaned) return false;',
|
|
@@ -1804,7 +1842,10 @@ function buildResolveIORunnerQaLiveDataSeederScript() {
|
|
|
1804
1842
|
' if (/^(true|1|yes|on)$/i.test(explicit)) return true;',
|
|
1805
1843
|
' if (/^(false|0|no|off)$/i.test(explicit)) return false;',
|
|
1806
1844
|
' const text = readSeedHintText();',
|
|
1807
|
-
'
|
|
1845
|
+
' const billingSurface = /\\b(invoice|invoicing|billing|billable|tax|taxes|surcharge|checkout|check\\s*out|pick\\s*ticket)\\b/i.test(text);',
|
|
1846
|
+
' if (billingSurface) return true;',
|
|
1847
|
+
' if (shouldSeedPartInventorySnapshotContext()) return false;',
|
|
1848
|
+
' return /\\binventory\\b/i.test(text);',
|
|
1808
1849
|
'}',
|
|
1809
1850
|
'',
|
|
1810
1851
|
'function shouldSeedPricingImportFixtures() {',
|
|
@@ -2074,6 +2115,50 @@ function buildResolveIORunnerQaLiveDataSeederScript() {
|
|
|
2074
2115
|
' return [...interchangeables, ...chemicals, ...items, ...treatmentPlans];',
|
|
2075
2116
|
'}',
|
|
2076
2117
|
'',
|
|
2118
|
+
'async function copyPartInventorySnapshotContext(sourceDb, targetDb, summary) {',
|
|
2119
|
+
' if (!shouldSeedPartInventorySnapshotContext()) return [];',
|
|
2120
|
+
' const hints = extractPartInventorySnapshotHints();',
|
|
2121
|
+
' const snapshotOr = [];',
|
|
2122
|
+
' if (hints.partIds.length) {',
|
|
2123
|
+
' snapshotOr.push({ "metadata.id_part": { $in: hints.partIds } });',
|
|
2124
|
+
' snapshotOr.push({ id_part: { $in: hints.partIds } });',
|
|
2125
|
+
' }',
|
|
2126
|
+
' if (hints.dayKeys.length) snapshotOr.push({ day_key: { $in: hints.dayKeys } });',
|
|
2127
|
+
' const snapshotQuery = snapshotOr.length ? { section: "Parts", $or: snapshotOr } : { section: "Parts" };',
|
|
2128
|
+
' const snapshots = await copyQuery(sourceDb, targetDb, "inventory-daily-snapshots", snapshotQuery, summary, 120, { day_key: -1, updatedAt: -1 });',
|
|
2129
|
+
' const snapshotPartIds = unique([...hints.partIds, ...collectNestedStringValues(snapshots, ["id_part"])]);',
|
|
2130
|
+
' const snapshotDayKeys = unique([...hints.dayKeys, ...snapshots.map((doc) => String(doc && doc.day_key || "")).filter(Boolean)]);',
|
|
2131
|
+
' const checkinQuery = snapshotPartIds.length ? { "items.id": { $in: snapshotPartIds }, type: { $in: ["part", "manual_part"] } } : { type: { $in: ["part", "manual_part"] } };',
|
|
2132
|
+
' const checkoutQuery = snapshotPartIds.length ? { "items.id": { $in: snapshotPartIds }, type: "part" } : { type: "part" };',
|
|
2133
|
+
' const checkins = await copyQuery(sourceDb, targetDb, "checkins", checkinQuery, summary, 240, { date: -1, updatedAt: -1 });',
|
|
2134
|
+
' const checkouts = await copyQuery(sourceDb, targetDb, "checkouts", checkoutQuery, summary, 160, { date: -1, updatedAt: -1 });',
|
|
2135
|
+
' const yardIds = unique([',
|
|
2136
|
+
' ...hints.yardIds,',
|
|
2137
|
+
' ...idValues(checkins, ["id_yard"]),',
|
|
2138
|
+
' ...idValues(checkouts, ["id_warehouse_location"]),',
|
|
2139
|
+
' ...collectNestedStringValues(snapshots, ["id_yard"])',
|
|
2140
|
+
' ]);',
|
|
2141
|
+
' await copyByIds(sourceDb, targetDb, "yards", yardIds, summary, 80);',
|
|
2142
|
+
' if (!yardIds.length || /\\b(Kermit|Midland)\\b/i.test(readSeedHintText())) {',
|
|
2143
|
+
' await copyQuery(sourceDb, targetDb, "yards", { name: { $in: [/^Kermit$/i, /^Midland$/i] } }, summary, 20, { name: 1 });',
|
|
2144
|
+
' }',
|
|
2145
|
+
' if (snapshotPartIds.length) await copyByIds(sourceDb, targetDb, "items", snapshotPartIds, summary, 80);',
|
|
2146
|
+
' summary.selected.part_inventory_snapshot_context = {',
|
|
2147
|
+
' part_ids: snapshotPartIds,',
|
|
2148
|
+
' day_keys: snapshotDayKeys,',
|
|
2149
|
+
' yard_ids: yardIds,',
|
|
2150
|
+
' snapshot_count: snapshots.length,',
|
|
2151
|
+
' checkin_count: checkins.length,',
|
|
2152
|
+
' checkout_count: checkouts.length',
|
|
2153
|
+
' };',
|
|
2154
|
+
' if (snapshots.length || checkins.length || checkouts.length) {',
|
|
2155
|
+
' summary.notes.push(`Seeded Part inventory snapshot context: ${snapshots.length} saved snapshot row(s), ${checkins.length} checkin(s), ${checkouts.length} checkout(s), part ids=${snapshotPartIds.join(", ") || "none"}.`);',
|
|
2156
|
+
' } else {',
|
|
2157
|
+
' summary.notes.push("Part inventory snapshot context was requested by diagnosis proof, but no matching live snapshot/checkin/checkout documents were found.");',
|
|
2158
|
+
' }',
|
|
2159
|
+
' return [...snapshots, ...checkins, ...checkouts];',
|
|
2160
|
+
'}',
|
|
2161
|
+
'',
|
|
2077
2162
|
'async function copyTicketAssetContext(sourceDb, targetDb, summary) {',
|
|
2078
2163
|
' if (!shouldAutoDiscoverAssetContext()) return [];',
|
|
2079
2164
|
' const assetIdentifiers = extractAssetIdentifiers();',
|
|
@@ -2281,6 +2366,7 @@ function buildResolveIORunnerQaLiveDataSeederScript() {
|
|
|
2281
2366
|
' const truckTreatingBolContextDocs = await copyTruckTreatingBolContext(sourceDb, targetDb, summary);',
|
|
2282
2367
|
' const ticketAssetContextDocs = await copyTicketAssetContext(sourceDb, targetDb, summary);',
|
|
2283
2368
|
' const productionInterchangeablesContextDocs = await copyProductionInterchangeablesContext(sourceDb, targetDb, summary);',
|
|
2369
|
+
' const partInventorySnapshotContextDocs = await copyPartInventorySnapshotContext(sourceDb, targetDb, summary);',
|
|
2284
2370
|
' const pricingImportWorkbookContextDocs = includePricingImportFixtures ? await copyPricingImportWorkbookContext(sourceDb, targetDb, summary) : [];',
|
|
2285
2371
|
' if (!includeBillingFixtures) {',
|
|
2286
2372
|
' summary.notes.push("Billing dashboard fixtures are disabled because ticket context does not require billing, invoices, taxes, inventory, surcharges, checkout, or pick tickets.");',
|
|
@@ -2323,7 +2409,7 @@ function buildResolveIORunnerQaLiveDataSeederScript() {
|
|
|
2323
2409
|
' summary.notes.push("No live billable delivery or truck-treatment records matched the Billing Dashboard awaiting-invoice filters.");',
|
|
2324
2410
|
' }',
|
|
2325
2411
|
'',
|
|
2326
|
-
' const sourceDocs = [...qaIdentityUsers, ...truckTreatingBolContextDocs, ...ticketAssetContextDocs, ...productionInterchangeablesContextDocs, ...pricingImportWorkbookContextDocs, ...productionDeliveries, ...truckTreatingDeliveries];',
|
|
2412
|
+
' const sourceDocs = [...qaIdentityUsers, ...truckTreatingBolContextDocs, ...ticketAssetContextDocs, ...productionInterchangeablesContextDocs, ...partInventorySnapshotContextDocs, ...pricingImportWorkbookContextDocs, ...productionDeliveries, ...truckTreatingDeliveries];',
|
|
2327
2413
|
' const pricingImportContext = summary.selected.pricing_import_workbook_context || {};',
|
|
2328
2414
|
' const customerIds = unique([...idValues(sourceDocs, ["id_customer"]), ...(Array.isArray(pricingImportContext.customer_ids) ? pricingImportContext.customer_ids : [])]);',
|
|
2329
2415
|
' const locationIds = idValues(sourceDocs, ["id_location"]);',
|
|
@@ -2386,7 +2472,7 @@ function buildResolveIORunnerQaLiveDataSeederScript() {
|
|
|
2386
2472
|
' ] }, summary, 120, { date: -1, updatedAt: -1 });',
|
|
2387
2473
|
' }',
|
|
2388
2474
|
'',
|
|
2389
|
-
' summary.ready = pricingImportWorkbookContextDocs.length > 0 || truckTreatingBolContextDocs.length > 0 || ticketAssetContextDocs.length > 0 || productionInterchangeablesContextDocs.length > 0 || productionDeliveries.length > 0 || truckTreatingDeliveries.length > 0;',
|
|
2475
|
+
' summary.ready = pricingImportWorkbookContextDocs.length > 0 || truckTreatingBolContextDocs.length > 0 || ticketAssetContextDocs.length > 0 || productionInterchangeablesContextDocs.length > 0 || partInventorySnapshotContextDocs.length > 0 || productionDeliveries.length > 0 || truckTreatingDeliveries.length > 0;',
|
|
2390
2476
|
' return summary;',
|
|
2391
2477
|
'}',
|
|
2392
2478
|
'',
|