@contentstack/cli-audit 1.0.0 → 1.2.0

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.
@@ -1,8 +1,6 @@
1
1
  import { FlagInput } from '@contentstack/cli-utilities';
2
- import config from '../../../../config';
3
- import { BaseCommand } from '../../../../base-command';
4
- import { ContentTypeStruct } from '../../../../types';
5
- export default class Audit extends BaseCommand<typeof Audit> {
2
+ import { AuditBaseCommand } from '../../../../audit-base-command';
3
+ export default class Audit extends AuditBaseCommand {
6
4
  static aliases: string[];
7
5
  static description: string;
8
6
  static examples: string[];
@@ -12,51 +10,4 @@ export default class Audit extends BaseCommand<typeof Audit> {
12
10
  * (content-types, global-fields, entries) and generates a report.
13
11
  */
14
12
  run(): Promise<void>;
15
- /**
16
- * The `promptQueue` function prompts the user to enter a data directory path if the `data-dir` flag
17
- * is missing, and sets the `basePath` property of the `sharedConfig` object to the entered path.
18
- */
19
- promptQueue(): Promise<void>;
20
- /**
21
- * The function `getCtAndGfSchema` reads and parses JSON files containing content type and global
22
- * field schemas, and returns them as an object.
23
- * @returns The function `getCtAndGfSchema()` returns an object with two properties: `ctSchema` and
24
- * `gfSchema`. The values of these properties are the parsed JSON data from two different files.
25
- */
26
- getCtAndGfSchema(): {
27
- ctSchema: ContentTypeStruct[];
28
- gfSchema: ContentTypeStruct[];
29
- };
30
- /**
31
- * The function `showOutputOnScreen` displays missing references on the terminal screen if the
32
- * `showTerminalOutput` flag is set to true.
33
- * @param {{ module: string; missingRefs?: Record<string, any> }[]} allMissingRefs - An array of
34
- * objects, where each object has two properties:
35
- */
36
- showOutputOnScreen(allMissingRefs: {
37
- module: string;
38
- missingRefs?: Record<string, any>;
39
- }[]): void;
40
- /**
41
- * The function prepares a report by writing a JSON file and a CSV file with a list of missing
42
- * references for a given module.
43
- * @param moduleName - The `moduleName` parameter is a string that represents the name of a module.
44
- * It is used to generate the filename for the report.
45
- * @param listOfMissingRefs - The `listOfMissingRefs` parameter is a record object that contains
46
- * information about missing references. It is a key-value pair where the key represents the
47
- * reference name and the value represents additional information about the missing reference.
48
- * @returns The function `prepareReport` returns a Promise that resolves to `void`.
49
- */
50
- prepareReport(moduleName: keyof typeof config.moduleConfig, listOfMissingRefs: Record<string, any>): Promise<void>;
51
- /**
52
- * The function `prepareCSV` takes a module name and a list of missing references, and generates a
53
- * CSV file with the specified columns and filtered rows.
54
- * @param moduleName - The `moduleName` parameter is a string that represents the name of a module.
55
- * It is used to generate the name of the CSV file that will be created.
56
- * @param listOfMissingRefs - The `listOfMissingRefs` parameter is a record object that contains
57
- * information about missing references. Each key in the record represents a reference, and the
58
- * corresponding value is an array of objects that contain details about the missing reference.
59
- * @returns The function `prepareCSV` returns a Promise that resolves to `void`.
60
- */
61
- prepareCSV(moduleName: keyof typeof config.moduleConfig, listOfMissingRefs: Record<string, any>): Promise<void>;
62
13
  }
@@ -1,78 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
- const csv = tslib_1.__importStar(require("fast-csv"));
6
- const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
7
- const path_1 = require("path");
8
4
  const cli_utilities_1 = require("@contentstack/cli-utilities");
9
- const fs_1 = require("fs");
10
5
  const config_1 = tslib_1.__importDefault(require("../../../../config"));
11
- const log_1 = require("../../../../util/log");
12
6
  const messages_1 = require("../../../../messages");
13
- const base_command_1 = require("../../../../base-command");
14
- const modules_1 = require("../../../../modules");
15
- const types_1 = require("../../../../types");
16
- class Audit extends base_command_1.BaseCommand {
7
+ const audit_base_command_1 = require("../../../../audit-base-command");
8
+ class Audit extends audit_base_command_1.AuditBaseCommand {
17
9
  /**
18
10
  * The `run` function is an asynchronous function that performs an audit on different modules
19
11
  * (content-types, global-fields, entries) and generates a report.
20
12
  */
21
13
  async run() {
22
14
  try {
23
- await this.promptQueue();
24
- const reportPath = this.flags['report-path'] || process.cwd();
25
- this.sharedConfig.reportPath = (0, path_1.resolve)(reportPath, 'audit-report');
26
- let { ctSchema, gfSchema } = this.getCtAndGfSchema();
27
- let missingCtRefs, missingGfRefs, missingEntryRefs;
28
- for (const module of this.sharedConfig.flags.modules || this.sharedConfig.modules) {
29
- cli_utilities_1.ux.action.start(this.$t(this.messages.AUDIT_START_SPINNER, { module }));
30
- switch (module) {
31
- case 'content-types':
32
- missingCtRefs = await new modules_1.ContentType({
33
- ctSchema,
34
- gfSchema,
35
- log: this.log,
36
- moduleName: module,
37
- config: this.sharedConfig,
38
- }).run();
39
- await this.prepareReport(module, missingCtRefs);
40
- break;
41
- case 'global-fields':
42
- missingGfRefs = await new modules_1.GlobalField({
43
- ctSchema,
44
- gfSchema,
45
- log: this.log,
46
- moduleName: module,
47
- config: this.sharedConfig,
48
- }).run();
49
- await this.prepareReport(module, missingGfRefs);
50
- break;
51
- case 'entries':
52
- missingEntryRefs = await new modules_1.Entries({
53
- ctSchema,
54
- gfSchema,
55
- log: this.log,
56
- moduleName: module,
57
- config: this.sharedConfig,
58
- }).run();
59
- await this.prepareReport(module, missingEntryRefs);
60
- break;
61
- }
62
- cli_utilities_1.ux.action.stop();
63
- }
64
- this.showOutputOnScreen([
65
- { module: 'Content types', missingRefs: missingCtRefs },
66
- { module: 'Global Fields', missingRefs: missingGfRefs },
67
- { module: 'Entries', missingRefs: missingEntryRefs },
68
- ]);
69
- if (!(0, isEmpty_1.default)(missingCtRefs) || !(0, isEmpty_1.default)(missingGfRefs) || !(0, isEmpty_1.default)(missingEntryRefs)) {
70
- this.log(this.$t(messages_1.auditMsg.FINAL_REPORT_PATH, { path: this.sharedConfig.reportPath }), 'warn');
71
- }
72
- else {
73
- this.log(this.messages.NO_MISSING_REF_FOUND, 'info');
74
- this.log('');
75
- }
15
+ await this.start('cm:stacks:audit');
76
16
  }
77
17
  catch (error) {
78
18
  this.log(error instanceof Error ? error.message : error, 'error');
@@ -81,146 +21,10 @@ class Audit extends base_command_1.BaseCommand {
81
21
  this.exit(1);
82
22
  }
83
23
  }
84
- /**
85
- * The `promptQueue` function prompts the user to enter a data directory path if the `data-dir` flag
86
- * is missing, and sets the `basePath` property of the `sharedConfig` object to the entered path.
87
- */
88
- async promptQueue() {
89
- // NOTE get content path if data-dir flag is missing
90
- this.sharedConfig.basePath =
91
- this.flags['data-dir'] ||
92
- (await cli_utilities_1.cliux.inquire({
93
- type: 'input',
94
- name: 'data-dir',
95
- message: this.messages.DATA_DIR,
96
- }));
97
- }
98
- /**
99
- * The function `getCtAndGfSchema` reads and parses JSON files containing content type and global
100
- * field schemas, and returns them as an object.
101
- * @returns The function `getCtAndGfSchema()` returns an object with two properties: `ctSchema` and
102
- * `gfSchema`. The values of these properties are the parsed JSON data from two different files.
103
- */
104
- getCtAndGfSchema() {
105
- const ctPath = (0, path_1.join)(this.sharedConfig.basePath, this.sharedConfig.moduleConfig['content-types'].dirName, this.sharedConfig.moduleConfig['content-types'].fileName);
106
- const gfPath = (0, path_1.join)(this.sharedConfig.basePath, this.sharedConfig.moduleConfig['global-fields'].dirName, this.sharedConfig.moduleConfig['global-fields'].fileName);
107
- let ctSchema = (0, fs_1.existsSync)(ctPath) ? JSON.parse((0, fs_1.readFileSync)(ctPath, 'utf-8')) : [];
108
- let gfSchema = (0, fs_1.existsSync)(gfPath) ? JSON.parse((0, fs_1.readFileSync)(gfPath, 'utf-8')) : [];
109
- return { ctSchema, gfSchema };
110
- }
111
- /**
112
- * The function `showOutputOnScreen` displays missing references on the terminal screen if the
113
- * `showTerminalOutput` flag is set to true.
114
- * @param {{ module: string; missingRefs?: Record<string, any> }[]} allMissingRefs - An array of
115
- * objects, where each object has two properties:
116
- */
117
- showOutputOnScreen(allMissingRefs) {
118
- if (this.sharedConfig.showTerminalOutput) {
119
- this.log(''); // NOTE adding new line
120
- for (const { module, missingRefs } of allMissingRefs) {
121
- if (!(0, isEmpty_1.default)(missingRefs)) {
122
- (0, log_1.print)([
123
- {
124
- bold: true,
125
- color: 'cyan',
126
- message: ` ${module}`,
127
- },
128
- ]);
129
- cli_utilities_1.ux.table(Object.values(missingRefs).flat(), {
130
- name: {
131
- minWidth: 7,
132
- header: 'Title',
133
- },
134
- display_name: {
135
- minWidth: 7,
136
- header: 'Field name',
137
- },
138
- data_type: {
139
- minWidth: 7,
140
- header: 'Field type',
141
- },
142
- missingRefs: {
143
- minWidth: 7,
144
- header: 'Missing references',
145
- get: (row) => {
146
- return chalk_1.default.red(typeof row.missingRefs === 'object' ? JSON.stringify(row.missingRefs) : row.missingRefs);
147
- },
148
- },
149
- treeStr: {
150
- minWidth: 7,
151
- header: 'Path',
152
- },
153
- }, Object.assign({}, this.flags));
154
- this.log(''); // NOTE adding new line
155
- }
156
- }
157
- }
158
- }
159
- /**
160
- * The function prepares a report by writing a JSON file and a CSV file with a list of missing
161
- * references for a given module.
162
- * @param moduleName - The `moduleName` parameter is a string that represents the name of a module.
163
- * It is used to generate the filename for the report.
164
- * @param listOfMissingRefs - The `listOfMissingRefs` parameter is a record object that contains
165
- * information about missing references. It is a key-value pair where the key represents the
166
- * reference name and the value represents additional information about the missing reference.
167
- * @returns The function `prepareReport` returns a Promise that resolves to `void`.
168
- */
169
- prepareReport(moduleName, listOfMissingRefs) {
170
- if ((0, isEmpty_1.default)(listOfMissingRefs))
171
- return Promise.resolve(void 0);
172
- if (!(0, fs_1.existsSync)(this.sharedConfig.reportPath)) {
173
- (0, fs_1.mkdirSync)(this.sharedConfig.reportPath, { recursive: true });
174
- }
175
- // NOTE write int json
176
- (0, fs_1.writeFileSync)((0, path_1.join)(this.sharedConfig.reportPath, `${moduleName}.json`), JSON.stringify(listOfMissingRefs));
177
- // NOTE write into CSV
178
- return this.prepareCSV(moduleName, listOfMissingRefs);
179
- }
180
- /**
181
- * The function `prepareCSV` takes a module name and a list of missing references, and generates a
182
- * CSV file with the specified columns and filtered rows.
183
- * @param moduleName - The `moduleName` parameter is a string that represents the name of a module.
184
- * It is used to generate the name of the CSV file that will be created.
185
- * @param listOfMissingRefs - The `listOfMissingRefs` parameter is a record object that contains
186
- * information about missing references. Each key in the record represents a reference, and the
187
- * corresponding value is an array of objects that contain details about the missing reference.
188
- * @returns The function `prepareCSV` returns a Promise that resolves to `void`.
189
- */
190
- prepareCSV(moduleName, listOfMissingRefs) {
191
- const csvStream = csv.format({ headers: true });
192
- const csvPath = (0, path_1.join)(this.sharedConfig.reportPath, `${moduleName}.csv`);
193
- const assetFileStream = (0, fs_1.createWriteStream)(csvPath);
194
- assetFileStream.on('error', (error) => {
195
- throw error;
196
- });
197
- return new Promise((resolve, reject) => {
198
- csvStream.pipe(assetFileStream).on('close', resolve).on('error', reject);
199
- const defaultColumns = Object.keys(types_1.OutputColumn);
200
- const userDefinedColumns = this.sharedConfig.flags.columns ? this.sharedConfig.flags.columns.split(',') : null;
201
- let missingRefs = Object.values(listOfMissingRefs).flat();
202
- const columns = userDefinedColumns
203
- ? [...userDefinedColumns, ...defaultColumns.filter((val) => !userDefinedColumns.includes(val))]
204
- : defaultColumns;
205
- if (this.sharedConfig.flags.filter) {
206
- const [column, value] = this.sharedConfig.flags.filter.split('=');
207
- missingRefs = missingRefs.filter((row) => row[types_1.OutputColumn[column]] === value);
208
- }
209
- for (const issue of missingRefs) {
210
- let row = {};
211
- for (const column of columns) {
212
- row[column] = issue[types_1.OutputColumn[column]];
213
- row[column] = typeof row[column] === 'object' ? JSON.stringify(row[column]) : row[column];
214
- }
215
- csvStream.write(row);
216
- }
217
- csvStream.end();
218
- });
219
- }
220
24
  }
221
25
  exports.default = Audit;
222
- Audit.aliases = ['cm:stacks:audit'];
223
- Audit.description = 'Perform audits and find possible errors in the exported Contentstack data';
26
+ Audit.aliases = ['audit', 'cm:stacks:audit'];
27
+ Audit.description = messages_1.auditMsg.AUDIT_CMD_DESCRIPTION;
224
28
  Audit.examples = [
225
29
  '$ <%= config.bin %> <%= command.id %>',
226
30
  '$ <%= config.bin %> <%= command.id %> --report-path=<path>',
@@ -1,10 +1,8 @@
1
- declare const errors: {
2
- NOT_EMPTY: string;
3
- };
1
+ declare const errors: {};
4
2
  declare const commonMsg: {
5
3
  CONFIG: string;
6
- CURRENT_WORKING_DIR: string;
7
4
  DATA_DIR: string;
5
+ FIX_CONFIRMATION: string;
8
6
  };
9
7
  declare const auditMsg: {
10
8
  REPORT_PATH: string;
@@ -17,8 +15,16 @@ declare const auditMsg: {
17
15
  FINAL_REPORT_PATH: string;
18
16
  SCAN_CT_SUCCESS_MSG: string;
19
17
  SCAN_ENTRY_SUCCESS_MSG: string;
18
+ AUDIT_CMD_DESCRIPTION: string;
19
+ };
20
+ declare const auditFixMsg: {
21
+ COPY_DATA: string;
22
+ BKP_PATH: string;
23
+ FIXED_CONTENT_PATH_MAG: string;
24
+ EMPTY_FIX_MSG: string;
25
+ AUDIT_FIX_CMD_DESCRIPTION: string;
20
26
  };
21
- declare const messages: typeof errors & typeof commonMsg & typeof auditMsg;
27
+ declare const messages: typeof errors & typeof commonMsg & typeof auditMsg & typeof auditFixMsg;
22
28
  /**
23
29
  * The function `$t` is a TypeScript function that replaces placeholders in a string with corresponding
24
30
  * values from an object.
@@ -30,4 +36,4 @@ declare const messages: typeof errors & typeof commonMsg & typeof auditMsg;
30
36
  */
31
37
  declare function $t(msg: string, args: Record<string, string>): string;
32
38
  export default messages;
33
- export { $t, errors, commonMsg, auditMsg };
39
+ export { $t, errors, commonMsg, auditMsg, auditFixMsg };
@@ -1,19 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.auditMsg = exports.commonMsg = exports.errors = exports.$t = void 0;
4
- const errors = {
5
- NOT_EMPTY: '{value} cannot be empty.',
6
- };
3
+ exports.auditFixMsg = exports.auditMsg = exports.commonMsg = exports.errors = exports.$t = void 0;
4
+ const errors = {};
7
5
  exports.errors = errors;
8
6
  const commonMsg = {
9
- CONFIG: 'Path of the external config.',
10
- CURRENT_WORKING_DIR: 'Current working directory.',
11
- DATA_DIR: 'Path where the data is stored.',
7
+ CONFIG: 'Path of the external config',
8
+ DATA_DIR: 'Path where the data is stored',
9
+ FIX_CONFIRMATION: 'Would you like to overwrite existing file.?',
12
10
  };
13
11
  exports.commonMsg = commonMsg;
14
12
  const auditMsg = {
15
- REPORT_PATH: 'Path to store the audit reports.',
16
- MODULES: 'Provide the list of modules to be audited.',
13
+ REPORT_PATH: 'Path to store the audit reports',
14
+ MODULES: 'Provide the list of modules to be audited',
17
15
  AUDIT_START_SPINNER: '{module} scanning...',
18
16
  PREPARING_ENTRY_METADATA: 'Creating entry metadata...',
19
17
  REFERENCE_ONLY: 'Checks only for missing references.',
@@ -22,9 +20,18 @@ const auditMsg = {
22
20
  FINAL_REPORT_PATH: "Reports ready. Please find the reports at '{path}'.",
23
21
  SCAN_CT_SUCCESS_MSG: "Successfully completed the scanning of {module} '{title}'.",
24
22
  SCAN_ENTRY_SUCCESS_MSG: "Successfully completed the scanning of {module} ({local}) '{title}'.",
23
+ AUDIT_CMD_DESCRIPTION: 'Perform audits and find possible errors in the exported Contentstack data',
25
24
  };
26
25
  exports.auditMsg = auditMsg;
27
- const messages = Object.assign(Object.assign(Object.assign({}, errors), commonMsg), auditMsg);
26
+ const auditFixMsg = {
27
+ COPY_DATA: 'Create backup from the original data.',
28
+ BKP_PATH: 'Provide the path to backup the copied data',
29
+ FIXED_CONTENT_PATH_MAG: 'You can locate the fixed content at {path}.',
30
+ EMPTY_FIX_MSG: 'Successfully removed the empty field/block found at {path} from the schema.',
31
+ AUDIT_FIX_CMD_DESCRIPTION: 'Perform audits and fix possible errors in the exported Contentstack data.',
32
+ };
33
+ exports.auditFixMsg = auditFixMsg;
34
+ const messages = Object.assign(Object.assign(Object.assign(Object.assign({}, errors), commonMsg), auditMsg), auditFixMsg);
28
35
  /**
29
36
  * The function `$t` is a TypeScript function that replaces placeholders in a string with corresponding
30
37
  * values from an object.
@@ -1,7 +1,8 @@
1
- import { LogFn, ConfigType, ModularBlockType, ContentTypeStruct, GroupFieldDataType, RefErrorReturnType, CtConstructorParam, GlobalFieldDataType, JsonRTEFieldDataType, ModularBlocksDataType, ModuleConstructorParam, ReferenceFieldDataType } from '../types';
1
+ import { LogFn, ConfigType, ModularBlockType, ContentTypeStruct, GroupFieldDataType, RefErrorReturnType, CtConstructorParam, GlobalFieldDataType, JsonRTEFieldDataType, ModularBlocksDataType, ModuleConstructorParam, ReferenceFieldDataType, ContentTypeSchemaType } from '../types';
2
2
  import auditConfig from '../config';
3
3
  export default class ContentType {
4
4
  log: LogFn;
5
+ protected fix: boolean;
5
6
  fileName: string;
6
7
  config: ConfigType;
7
8
  folderPath: string;
@@ -12,13 +13,18 @@ export default class ContentType {
12
13
  protected schema: ContentTypeStruct[];
13
14
  protected missingRefs: Record<string, any>;
14
15
  moduleName: keyof typeof auditConfig.moduleConfig;
15
- constructor({ log, config, moduleName, ctSchema, gfSchema }: ModuleConstructorParam & CtConstructorParam);
16
+ constructor({ log, fix, config, moduleName, ctSchema, gfSchema }: ModuleConstructorParam & CtConstructorParam);
16
17
  /**
17
18
  * The `run` function checks if a folder path exists, sets the schema based on the module name,
18
19
  * iterates over the schema and looks for references, and returns a list of missing references.
19
20
  * @returns the `missingRefs` object.
20
21
  */
21
- run(): Promise<Record<string, any>>;
22
+ run(returnFixSchema?: boolean): Promise<Record<string, any>>;
23
+ /**
24
+ * The function checks if it can write the fix content to a file and if so, it writes the content as
25
+ * JSON to the specified file path.
26
+ */
27
+ writeFixContent(): Promise<void>;
22
28
  /**
23
29
  * The function `lookForReference` iterates through a given schema and performs validation checks
24
30
  * based on the data type of each field.
@@ -30,7 +36,7 @@ export default class ContentType {
30
36
  * `tree`: An array of objects representing the tree structure of the content type or field. Each
31
37
  * object in the array should have a `uid` and `name` property.
32
38
  */
33
- lookForReference(tree: Record<string, unknown>[], { schema }: ContentTypeStruct | GlobalFieldDataType | ModularBlockType | GroupFieldDataType): Promise<void>;
39
+ lookForReference(tree: Record<string, unknown>[], field: ContentTypeStruct | GlobalFieldDataType | ModularBlockType | GroupFieldDataType): Promise<void>;
34
40
  /**
35
41
  * The function validates a reference field in a tree data structure.
36
42
  * @param {Record<string, unknown>[]} tree - The "tree" parameter is an array of objects, where each
@@ -93,4 +99,53 @@ export default class ContentType {
93
99
  * objects.
94
100
  */
95
101
  validateReferenceToValues(tree: Record<string, unknown>[], field: ReferenceFieldDataType | JsonRTEFieldDataType): RefErrorReturnType[];
102
+ /**
103
+ * The function `runFixOnSchema` takes in a tree and a schema, and performs various fixes on the
104
+ * schema based on the data types of the fields.
105
+ * @param {Record<string, unknown>[]} tree - An array of objects representing the tree structure of
106
+ * the schema.
107
+ * @param {ContentTypeSchemaType[]} schema - The `schema` parameter is an array of
108
+ * `ContentTypeSchemaType` objects. Each object represents a field in a content type schema and
109
+ * contains properties such as `data_type`, `field_metadata`, `uid`, `name`, etc.
110
+ * @returns an array of ContentTypeSchemaType objects.
111
+ */
112
+ runFixOnSchema(tree: Record<string, unknown>[], schema: ContentTypeSchemaType[]): ContentTypeSchemaType[];
113
+ /**
114
+ * The function fixes global field references in a tree structure by adding missing references and
115
+ * returning the field if the reference exists, otherwise returning null.
116
+ * @param {Record<string, unknown>[]} tree - An array of objects representing a tree structure.
117
+ * @param {GlobalFieldDataType} field - The `field` parameter is an object that represents a global
118
+ * field. It has the following properties:
119
+ * @returns either the `field` object if `reference_to` exists in `this.gfSchema`, or `null` if it
120
+ * doesn't.
121
+ */
122
+ fixGlobalFieldReferences(tree: Record<string, unknown>[], field: GlobalFieldDataType): GlobalFieldDataType | null;
123
+ /**
124
+ * The function `fixModularBlocksReferences` takes in an array of tree objects and an array of
125
+ * modular blocks, and returns an array of modular blocks with fixed references.
126
+ * @param {Record<string, unknown>[]} tree - An array of objects representing the tree structure.
127
+ * @param {ModularBlockType[]} blocks - An array of objects representing modular blocks. Each object
128
+ * has properties such as "reference_to", "schema", "title", and "uid".
129
+ * @returns an array of `ModularBlockType` objects.
130
+ */
131
+ fixModularBlocksReferences(tree: Record<string, unknown>[], blocks: ModularBlockType[]): ModularBlockType[];
132
+ /**
133
+ * The function `fixMissingReferences` checks for missing references in a given tree and field, and
134
+ * attempts to fix them by removing the missing references from the field's `reference_to` array.
135
+ * @param {Record<string, unknown>[]} tree - An array of objects representing a tree structure. Each
136
+ * object in the array should have a "name" property.
137
+ * @param {ReferenceFieldDataType | JsonRTEFieldDataType} field - The `field` parameter is of type
138
+ * `ReferenceFieldDataType` or `JsonRTEFieldDataType`.
139
+ * @returns the `field` object.
140
+ */
141
+ fixMissingReferences(tree: Record<string, unknown>[], field: ReferenceFieldDataType | JsonRTEFieldDataType): ReferenceFieldDataType | JsonRTEFieldDataType;
142
+ /**
143
+ * The function `fixGroupField` takes in an array of objects and a field, and performs some
144
+ * operations on the field's schema property.
145
+ * @param {Record<string, unknown>[]} tree - An array of objects representing a tree structure.
146
+ * @param {GroupFieldDataType} field - The `field` parameter is an object that contains the following
147
+ * properties:
148
+ * @returns The function `fixGroupField` returns either `null` or the `field` object.
149
+ */
150
+ fixGroupField(tree: Record<string, unknown>[], field: GroupFieldDataType): GroupFieldDataType | null;
96
151
  }