@resolveio/server-lib 22.3.224 → 22.3.226
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,38 @@ 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
|
+
' if (/\\b(id_part|part|Parts|checkin|checkout|inventory-daily-snapshots|warehouse_location)\\b/i.test(around)) partIds.add(String(match[0]).toLowerCase());',
|
|
1742
|
+
' if (/\\b(id_yard|yard|Kermit|Midland)\\b/i.test(around)) yardIds.add(String(match[0]).toLowerCase());',
|
|
1743
|
+
' }',
|
|
1744
|
+
' }',
|
|
1745
|
+
' return { partIds: Array.from(partIds).slice(0, 16), yardIds: Array.from(yardIds).slice(0, 16), dayKeys: Array.from(dayKeys).slice(0, 12) };',
|
|
1746
|
+
'}',
|
|
1747
|
+
'',
|
|
1712
1748
|
'function isUsefulSeedIdentifier(value) {',
|
|
1713
1749
|
' const cleaned = String(value || "").trim().replace(/^[#:\\-]+|[.,;:)\\]]+$/g, "");',
|
|
1714
1750
|
' if (!cleaned) return false;',
|
|
@@ -2074,6 +2110,50 @@ function buildResolveIORunnerQaLiveDataSeederScript() {
|
|
|
2074
2110
|
' return [...interchangeables, ...chemicals, ...items, ...treatmentPlans];',
|
|
2075
2111
|
'}',
|
|
2076
2112
|
'',
|
|
2113
|
+
'async function copyPartInventorySnapshotContext(sourceDb, targetDb, summary) {',
|
|
2114
|
+
' if (!shouldSeedPartInventorySnapshotContext()) return [];',
|
|
2115
|
+
' const hints = extractPartInventorySnapshotHints();',
|
|
2116
|
+
' const snapshotOr = [];',
|
|
2117
|
+
' if (hints.partIds.length) {',
|
|
2118
|
+
' snapshotOr.push({ "metadata.id_part": { $in: hints.partIds } });',
|
|
2119
|
+
' snapshotOr.push({ id_part: { $in: hints.partIds } });',
|
|
2120
|
+
' }',
|
|
2121
|
+
' if (hints.dayKeys.length) snapshotOr.push({ day_key: { $in: hints.dayKeys } });',
|
|
2122
|
+
' const snapshotQuery = snapshotOr.length ? { section: "Parts", $or: snapshotOr } : { section: "Parts" };',
|
|
2123
|
+
' const snapshots = await copyQuery(sourceDb, targetDb, "inventory-daily-snapshots", snapshotQuery, summary, 120, { day_key: -1, updatedAt: -1 });',
|
|
2124
|
+
' const snapshotPartIds = unique([...hints.partIds, ...collectNestedStringValues(snapshots, ["id_part"])]);',
|
|
2125
|
+
' const snapshotDayKeys = unique([...hints.dayKeys, ...snapshots.map((doc) => String(doc && doc.day_key || "")).filter(Boolean)]);',
|
|
2126
|
+
' const checkinQuery = snapshotPartIds.length ? { "items.id": { $in: snapshotPartIds }, type: { $in: ["part", "manual_part"] } } : { type: { $in: ["part", "manual_part"] } };',
|
|
2127
|
+
' const checkoutQuery = snapshotPartIds.length ? { "items.id": { $in: snapshotPartIds }, type: "part" } : { type: "part" };',
|
|
2128
|
+
' const checkins = await copyQuery(sourceDb, targetDb, "checkins", checkinQuery, summary, 240, { date: -1, updatedAt: -1 });',
|
|
2129
|
+
' const checkouts = await copyQuery(sourceDb, targetDb, "checkouts", checkoutQuery, summary, 160, { date: -1, updatedAt: -1 });',
|
|
2130
|
+
' const yardIds = unique([',
|
|
2131
|
+
' ...hints.yardIds,',
|
|
2132
|
+
' ...idValues(checkins, ["id_yard"]),',
|
|
2133
|
+
' ...idValues(checkouts, ["id_warehouse_location"]),',
|
|
2134
|
+
' ...collectNestedStringValues(snapshots, ["id_yard"])',
|
|
2135
|
+
' ]);',
|
|
2136
|
+
' await copyByIds(sourceDb, targetDb, "yards", yardIds, summary, 80);',
|
|
2137
|
+
' if (!yardIds.length || /\\b(Kermit|Midland)\\b/i.test(readSeedHintText())) {',
|
|
2138
|
+
' await copyQuery(sourceDb, targetDb, "yards", { name: { $in: [/^Kermit$/i, /^Midland$/i] } }, summary, 20, { name: 1 });',
|
|
2139
|
+
' }',
|
|
2140
|
+
' if (snapshotPartIds.length) await copyByIds(sourceDb, targetDb, "items", snapshotPartIds, summary, 80);',
|
|
2141
|
+
' summary.selected.part_inventory_snapshot_context = {',
|
|
2142
|
+
' part_ids: snapshotPartIds,',
|
|
2143
|
+
' day_keys: snapshotDayKeys,',
|
|
2144
|
+
' yard_ids: yardIds,',
|
|
2145
|
+
' snapshot_count: snapshots.length,',
|
|
2146
|
+
' checkin_count: checkins.length,',
|
|
2147
|
+
' checkout_count: checkouts.length',
|
|
2148
|
+
' };',
|
|
2149
|
+
' if (snapshots.length || checkins.length || checkouts.length) {',
|
|
2150
|
+
' 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"}.`);',
|
|
2151
|
+
' } else {',
|
|
2152
|
+
' summary.notes.push("Part inventory snapshot context was requested by diagnosis proof, but no matching live snapshot/checkin/checkout documents were found.");',
|
|
2153
|
+
' }',
|
|
2154
|
+
' return [...snapshots, ...checkins, ...checkouts];',
|
|
2155
|
+
'}',
|
|
2156
|
+
'',
|
|
2077
2157
|
'async function copyTicketAssetContext(sourceDb, targetDb, summary) {',
|
|
2078
2158
|
' if (!shouldAutoDiscoverAssetContext()) return [];',
|
|
2079
2159
|
' const assetIdentifiers = extractAssetIdentifiers();',
|
|
@@ -2281,6 +2361,7 @@ function buildResolveIORunnerQaLiveDataSeederScript() {
|
|
|
2281
2361
|
' const truckTreatingBolContextDocs = await copyTruckTreatingBolContext(sourceDb, targetDb, summary);',
|
|
2282
2362
|
' const ticketAssetContextDocs = await copyTicketAssetContext(sourceDb, targetDb, summary);',
|
|
2283
2363
|
' const productionInterchangeablesContextDocs = await copyProductionInterchangeablesContext(sourceDb, targetDb, summary);',
|
|
2364
|
+
' const partInventorySnapshotContextDocs = await copyPartInventorySnapshotContext(sourceDb, targetDb, summary);',
|
|
2284
2365
|
' const pricingImportWorkbookContextDocs = includePricingImportFixtures ? await copyPricingImportWorkbookContext(sourceDb, targetDb, summary) : [];',
|
|
2285
2366
|
' if (!includeBillingFixtures) {',
|
|
2286
2367
|
' 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 +2404,7 @@ function buildResolveIORunnerQaLiveDataSeederScript() {
|
|
|
2323
2404
|
' summary.notes.push("No live billable delivery or truck-treatment records matched the Billing Dashboard awaiting-invoice filters.");',
|
|
2324
2405
|
' }',
|
|
2325
2406
|
'',
|
|
2326
|
-
' const sourceDocs = [...qaIdentityUsers, ...truckTreatingBolContextDocs, ...ticketAssetContextDocs, ...productionInterchangeablesContextDocs, ...pricingImportWorkbookContextDocs, ...productionDeliveries, ...truckTreatingDeliveries];',
|
|
2407
|
+
' const sourceDocs = [...qaIdentityUsers, ...truckTreatingBolContextDocs, ...ticketAssetContextDocs, ...productionInterchangeablesContextDocs, ...partInventorySnapshotContextDocs, ...pricingImportWorkbookContextDocs, ...productionDeliveries, ...truckTreatingDeliveries];',
|
|
2327
2408
|
' const pricingImportContext = summary.selected.pricing_import_workbook_context || {};',
|
|
2328
2409
|
' const customerIds = unique([...idValues(sourceDocs, ["id_customer"]), ...(Array.isArray(pricingImportContext.customer_ids) ? pricingImportContext.customer_ids : [])]);',
|
|
2329
2410
|
' const locationIds = idValues(sourceDocs, ["id_location"]);',
|
|
@@ -2386,7 +2467,7 @@ function buildResolveIORunnerQaLiveDataSeederScript() {
|
|
|
2386
2467
|
' ] }, summary, 120, { date: -1, updatedAt: -1 });',
|
|
2387
2468
|
' }',
|
|
2388
2469
|
'',
|
|
2389
|
-
' summary.ready = pricingImportWorkbookContextDocs.length > 0 || truckTreatingBolContextDocs.length > 0 || ticketAssetContextDocs.length > 0 || productionInterchangeablesContextDocs.length > 0 || productionDeliveries.length > 0 || truckTreatingDeliveries.length > 0;',
|
|
2470
|
+
' summary.ready = pricingImportWorkbookContextDocs.length > 0 || truckTreatingBolContextDocs.length > 0 || ticketAssetContextDocs.length > 0 || productionInterchangeablesContextDocs.length > 0 || partInventorySnapshotContextDocs.length > 0 || productionDeliveries.length > 0 || truckTreatingDeliveries.length > 0;',
|
|
2390
2471
|
' return summary;',
|
|
2391
2472
|
'}',
|
|
2392
2473
|
'',
|