const stack = [
{
"name": "_id",
"type": "ObjectId"
},
{
"name": "createdAt",
"type": "Date"
},
{
"name": "updatedAt",
"type": "Date"
},
{
"name": "bid",
"type": "String"
},
{
"name": "scm",
"type": "String"
},
{
"name": "is_join_gray",
"type": "Boolean"
},
{
"name": "cover_rate",
"type": "String"
},
{
"name": "remark",
"type": "String"
},
{
"name": "is_valid",
"type": "Boolean"
},
{
"name": "is_block",
"type": "Boolean"
}
]
const filterArr = ["_id", "createdAt", "updatedAt"]
const stack_keys = stack.map(i => i.name).filter(i => !filterArr.includes(i))
let codeString = `
@Prop()
public name: string;
@Prop()
public bid: string;
@Prop()
public env: string;
@Prop()
public duty_id?: string;
@Prop()
public site_type: SiteType;
@Prop()
public container_type: ContainerType;
@Prop()
project_name: string;
@Prop()
watchers: Array<Watcher>;
@Prop()
chat_id: string;
@Prop()
region: 'cn' | 'mal';
@Prop()
slardar_site: 1 | 2;
@Prop()
lark_tmp_callback?: string;
@Prop()
alarm_reason_rule?: string;
@Prop()
project_owner?: Watcher | string;
@Prop()
pids?: Array<string>;
@Prop()
error_codes?: Array<string | number>;
@Prop()
status: PROJECT_STATUS;
@Prop()
pids_white_list?: Array<string>;
@Prop()
mera_events?: Array<string>;
@Prop()
bytetree?: string;
@Prop()
online_chat_id?: string;
@Prop()
chat_id_test?: string;
@Prop()
projectId: number;
@Prop()
slardar_dashboard_id?: string;
@Prop()
dashboard_url?: string;
@Prop()
publish_record_id?: string;
@Prop()
publish_record_ids?: Record<string, string | undefined>;
@Prop()
workcenter_id?: string;
@Prop()
parent_bid?: string;
@Prop()
department_id?: string;
@Prop()
business_id?: string;
@Prop()
group_id?: string;
@Prop()
auto_create_alarm?: boolean;
@Prop()
c_online_chat_ids?: Record<string, string | undefined>;
@Prop()
shield_location: string[];`
codeString = codeString.replace('public ','')
console.log(codeString)
function extractPropertyNames(str) {
const propRegex = /@Prop\(\)\s+(\w+)/g;
let match;
const properties = [];
while ((match = propRegex.exec(str)) !== null) {
properties.push(match[1]);
}
return properties;
}
function difference(a, b) {
return a.filter(item => !b.includes(item));
}
const new_keys = extractPropertyNames(codeString)
// console.log(difference(stack_keys, new_keys))
console