Skip to content

Commit

Permalink
chore: update now
Browse files Browse the repository at this point in the history
  • Loading branch information
xwchris committed Jan 2, 2025
1 parent c560051 commit 5e69a02
Showing 1 changed file with 81 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,89 +10,87 @@ const isJSONStringifyLegal = v => {
};

function transformSchemaValue(value) {
if (!value) return '';
const keysOfValue = Object.keys(value);
if (!Array.isArray(keysOfValue)) return '';

let res = [];

keysOfValue.forEach(key => {
const v = value[key] ? JSON.parse(value[key]) : null;
const { type, value: scheme_value } = v || {};

let realValue = scheme_value;
if (Array.isArray(scheme_value) && type === C_TYPE_NEW_ISV.listContainer.value) {
realValue = scheme_value.map(i => {
if (i && i.type === C_TYPE_NEW_ISV.objectContainer.value && i.value) {
const res = {
c_type: i.type,
name: i.name,
reject_info: null,
scheme_value: {},
};
Object.keys(i.value).forEach(j => {
const vForObj = i.value[j];
res.scheme_value[j] = {
c_type: vForObj?.type,
scheme_value: vForObj && vForObj.value ? JSON.stringify(vForObj.value) : '',
name: j,
reject_info: null,
};
});
res.scheme_value = JSON.stringify(res.scheme_value);
return res;
if (!value) return '';
const keysOfValue = Object.keys(value);
if (!Array.isArray(keysOfValue)) return '';
let res = [];
keysOfValue.forEach(key => {
const v = value[key] ? JSON.parse(value[key]) : null;
const { type, value: scheme_value, fe_cfg } = v || {};
let realValue = scheme_value;
if (Array.isArray(scheme_value) && type === C_TYPE_NEW_ISV.listContainer.value) {
realValue = scheme_value.map(i => {
if (i && i.type === C_TYPE_NEW_ISV.objectContainer.value && i.value) {
const res = {
c_type: i.type,
name: i.name,
reject_info: null,
scheme_value: {},
...(i?.fe_cfg && { fe_cfg: i.fe_cfg })
};
Object.keys(i.value).forEach(j => {
const vForObj = i.value[j];
res.scheme_value[j] = {
c_type: vForObj?.type,
scheme_value: vForObj?.value ? JSON.stringify(vForObj.value) : '',
name: j,
reject_info: null,
...(vForObj?.fe_cfg && { fe_cfg: vForObj.fe_cfg })
};
});
res.scheme_value = JSON.stringify(res.scheme_value);
return res;
}
return {
c_type: i?.type,
name: i?.name,
reject_info: null,
scheme_value: i?.value ? JSON.stringify(i.value) : '',
...(i?.fe_cfg && { fe_cfg: i.fe_cfg })
};
});
}

return {
c_type: i?.type,
name: i?.name,
reject_info: null,
scheme_value: i && i.value ? JSON.stringify(i.value) : '',
};
});
}

if (type === C_TYPE_NEW_ISV.objectContainer.value) {
const res = {};
Object.keys(scheme_value).forEach(j => {
const vForObj = scheme_value[j];
res[j] = {
c_type: vForObj?.type,
scheme_value: vForObj?.value ? JSON.stringify(vForObj.value) : '',
name: j,
reject_info: null,
};
});
realValue = res;
}

res.push({
c_type: type,
scheme_value: isJSONStringifyLegal(realValue) ? JSON.stringify(realValue) : '',
name: key,
reject_info: null,
if (type === C_TYPE_NEW_ISV.objectContainer.value) {
const res = {};
Object.keys(scheme_value).forEach(j => {
const vForObj = scheme_value[j];
res[j] = {
c_type: vForObj?.type,
scheme_value: vForObj?.value ? JSON.stringify(vForObj.value) : '',
name: j,
reject_info: null,
...(vForObj?.fe_cfg && { fe_cfg: vForObj.fe_cfg })
};
});
realValue = res;
}
res.push({
c_type: type,
scheme_value: isJSONStringifyLegal(realValue) ? JSON.stringify(realValue) : '',
name: key,
reject_info: null,
...(fe_cfg && { fe_cfg })
});
});
});

return res;
};

return res;
}
;
module.exports = function finalData(value) {
if (!value) return '';
const keysOfValue = Object.keys(value);
if (!Array.isArray(keysOfValue)) return '';

let res = [];

value.forEach(key => {
const item = {
componentId: key.component_id,
componentVersion: key.version,
}
const componentValue = transformSchemaValue(key.data.value)
item.value = JSON.stringify(componentValue)
res.push(item)
})

return JSON.stringify(res)
}
if (!value)
return '';
const keysOfValue = Object.keys(value);
if (!Array.isArray(keysOfValue))
return '';
let res = [];
value.forEach(key => {
const item = {
...(key?.materialId && {materialId: key.materialId}),
componentId: key.component_id,
componentVersion: key.version,
};
const componentValue = transformSchemaValue(key.data.value);
item.value = JSON.stringify(componentValue);
res.push(item);
});
return JSON.stringify(res);
};

0 comments on commit 5e69a02

Please sign in to comment.