/*
 * Copyright 2026, Jaime Terrats.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { basename, dirname } from 'node:path';
export const objectParser = {
    type: 'CustomObject',
    glob: '**/objects/*/*.object-meta.xml',
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    parse(filePath, _content) {
        // Object directory name is the API name (e.g., objects/Account/Account.object-meta.xml)
        const objectDir = basename(dirname(filePath));
        if (!objectDir)
            return null;
        return {
            apiName: objectDir,
            type: 'CustomObject',
            path: filePath,
            category: objectDir.endsWith('__c') ? 'custom' : 'standard',
            dependencies: [],
        };
    },
    extractDependencies(_entry, content) {
        const deps = new Set();
        // Lookup and Master-Detail relationships in inline field definitions
        const referencePattern = /<referenceTo>([A-Za-z][A-Za-z0-9_]+)<\/referenceTo>/g;
        let match = referencePattern.exec(content);
        while (match) {
            deps.add(match[1]);
            match = referencePattern.exec(content);
        }
        return [...deps];
    },
};
//# sourceMappingURL=object-parser.js.map