Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/contentstack-audit/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const config = {
Entries_Title_feild: 'Entries_Title_feild',
Entry_Missing_Locale_and_Env: 'Entry_Missing_Locale_and_Env',
Entry_Missing_Locale_and_Env_in_Publish_Details: 'Entry_Missing_Locale_and_Env_in_Publish_Details',
Entry_Multiple_Fields:"Entry_Multiple_Fields"
},
feild_level_modules: [
'Entries_Title_feild',
Expand Down
13 changes: 4 additions & 9 deletions packages/contentstack-audit/src/modules/content-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default class ContentType {
protected schema: ContentTypeStruct[] = [];
protected missingRefs: Record<string, any> = {};
public moduleName: keyof typeof auditConfig.moduleConfig;
public f:any = []
constructor({ log, fix, config, moduleName, ctSchema, gfSchema }: ModuleConstructorParam & CtConstructorParam) {
this.log = log;
this.config = config;
Expand Down Expand Up @@ -91,7 +90,7 @@ export default class ContentType {
this.currentTitle = schema.title;
this.missingRefs[this.currentUid] = [];
const { uid, title } = schema;
await this.lookForReference([{ uid, name: title }], schema, null);
await this.lookForReference([{ uid, name: title }], schema);
this.log(
$t(auditMsg.SCAN_CT_SUCCESS_MSG, { title, module: this.config.moduleConfig[this.moduleName].name }),
'info',
Expand Down Expand Up @@ -179,17 +178,13 @@ export default class ContentType {
async lookForReference(
tree: Record<string, unknown>[],
field: ContentTypeStruct | GlobalFieldDataType | ModularBlockType | GroupFieldDataType,
parent: any = null
): Promise<void> {
const fixTypes = this.config.flags['fix-only'] ?? this.config['fix-fields'];

if (this.fix) {
field.schema = this.runFixOnSchema(tree, field.schema as ContentTypeSchemaType[]);
}
for (let child of field.schema ?? []) {
if(parent) {
this.f.push(parent+"."+child.uid)
}

if (!fixTypes.includes(child.data_type) && child.data_type !== 'json') continue;

Expand Down Expand Up @@ -321,7 +316,7 @@ export default class ContentType {
return void 0;
}

await this.lookForReference(tree, field, field.uid);
await this.lookForReference(tree, field);
}

/**
Expand Down Expand Up @@ -355,7 +350,7 @@ export default class ContentType {
for (const block of blocks) {
const { uid, title } = block;

await this.lookForReference([...tree, { uid, name: title }], block, block.uid);
await this.lookForReference([...tree, { uid, name: title }], block);
}
}

Expand All @@ -371,7 +366,7 @@ export default class ContentType {
*/
async validateGroupField(tree: Record<string, unknown>[], field: GroupFieldDataType): Promise<void> {
// NOTE Any Group Field related logic can be added here (Ex data serialization or picking any metadata for report etc.,)
await this.lookForReference(tree, field, field.uid);
await this.lookForReference(tree, field);
}

/**
Expand Down
Loading