import mapValues from 'lodash/mapValues.js';
import omit from 'lodash/omit.js';
const migrate = async (_, projectSchema) => {
    const { indexedShapes, ...rest } = projectSchema;
    const migrated = {
        ...rest,
        schemaVersion: '3.22.0'
    };
    if (indexedShapes) {
        migrated.indexedShapes = mapValues(indexedShapes, (indexedShape) => {
            // objectDepthLimit SHOULD be the same, so prefer list query which is more likely to be used
            const { ignoreFields, objectDepthLimit } = indexedShape.queries.list ?? indexedShape.queries.get ?? {};
            return {
                ...indexedShape,
                query: {
                    ignoreFields,
                    maxDepth: objectDepthLimit
                },
                queries: mapValues(indexedShape.queries, (config) => config && omit(config, ['ignoreFields', 'objectDepthLimit']))
            };
        });
    }
    return migrated;
};
export default migrate;
