dev #111
@@ -1828,19 +1828,27 @@ export class PL24FordLegacyService {
|
||||
this.logger.warn(`FORD-MAP L3 subs=${subs.length} realLeaf id=${realLeaf?.id} cap="${realLeaf?.caption}" subheader=${realLeaf?.subheader}`);
|
||||
// probe candidate parts endpoints for the leaf, derived from the json-sub-group URL
|
||||
if (realLeaf?.id) {
|
||||
const base = mgs[0].jsonUrl as string; // json-sub-group.action?catCode=...&mainGroupId=...&sharedCatCode=...
|
||||
const cands = [
|
||||
base.replace("json-sub-group.action", "group-detail.action") + `&subGroupId=${realLeaf.id}`,
|
||||
base.replace("json-sub-group.action", "group.action") + `&subGroupId=${realLeaf.id}`,
|
||||
base.replace("json-sub-group.action", "group-detail.action") + `&subGroup=${realLeaf.id}`,
|
||||
base.replace("json-sub-group.action", "json-positions.action") + `&subGroupId=${realLeaf.id}`,
|
||||
];
|
||||
for (const cu of cands) {
|
||||
const pr = await this.fetchP4Page(cu, serviceName, false);
|
||||
const act = cu.match(/\/([a-z-]+\.action)\?/i)?.[1] || cu.match(/(subGroupId|subGroup)=/)?.[1];
|
||||
const pnc = pr ? (pr.match(/json-bom-detail/g) || []).length : 0;
|
||||
const tc = pr ? (pr.match(/tc-data-row/g) || []).length : 0;
|
||||
this.logger.warn(`FORD-MAP parts-probe [${act}]: len=${pr?.length} tcRows=${tc} bomDetailLinks=${pnc} head=${pr?.slice(0, 120).replace(/\s+/g, " ")}`);
|
||||
const base = mgs[0].jsonUrl as string;
|
||||
const sel = await this.fetchP4Page(`${base}&subGroupId=${realLeaf.id}`, serviceName, false);
|
||||
let selj: any = null;
|
||||
try {
|
||||
selj = JSON.parse(sel as string);
|
||||
} catch {}
|
||||
if (selj) {
|
||||
const keys = Object.keys(selj);
|
||||
const arrays = keys.filter((k) => Array.isArray(selj[k])).map((k) => `${k}[${selj[k].length}]`);
|
||||
this.logger.warn(`FORD-MAP sel keys=${keys.join(",")} arrays=${arrays.join(",")}`);
|
||||
// dump first item of any non-subgroups array (potential parts)
|
||||
for (const k of keys) {
|
||||
if (k !== "subgroups" && Array.isArray(selj[k]) && selj[k].length) {
|
||||
this.logger.warn(`FORD-MAP sel.${k}[0]=${JSON.stringify(selj[k][0]).slice(0, 300)}`);
|
||||
}
|
||||
}
|
||||
// does the SELECTED subgroup object now carry parts/url?
|
||||
const selSub = (selj.subgroups || []).find((x: any) => x.id === realLeaf.id);
|
||||
this.logger.warn(`FORD-MAP selSub keys=${selSub ? Object.keys(selSub).join(",") : "none"} url=${selSub?.url} jsonUrl=${selSub?.jsonUrl}`);
|
||||
} else {
|
||||
this.logger.warn(`FORD-MAP sel not-json len=${sel?.length} head=${sel?.slice(0, 120).replace(/\s+/g, " ")}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user