"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.createDocumentForEntity = exports.generateManifest = void 0;
const cdmStatusLevel_1 = require("../../../Cdm/cdmStatusLevel");
const internal_1 = require("../../../internal");
const Storage_1 = require("../../../Storage");
function generateManifest(localRootPath) {
    const cdmCorpus = new internal_1.CdmCorpusDefinition();
    cdmCorpus.storage.defaultNamespace = 'local';
    // tslint:disable-next-line: no-empty
    cdmCorpus.setEventCallback(() => { }, cdmStatusLevel_1.cdmStatusLevel.error);
    cdmCorpus.storage.mount('local', new Storage_1.LocalAdapter(localRootPath));
    // add cdm namespace
    cdmCorpus.storage.mount('cdm', new Storage_1.LocalAdapter(localRootPath));
    const manifest = new internal_1.CdmManifestDefinition(cdmCorpus.ctx, 'manifest');
    manifest.folderPath = '/';
    manifest.namespace = 'local';
    return manifest;
}
exports.generateManifest = generateManifest;
function createDocumentForEntity(cdmCorpus, entity, nameSpace) {
    if (!nameSpace) {
        nameSpace = 'local';
    }
    const cdmFolderDef = cdmCorpus.storage.fetchRootFolder(nameSpace);
    const entityDoc = cdmCorpus.MakeObject(internal_1.cdmObjectType.documentDef, `${entity.entityName}.cdm.json`, false);
    cdmFolderDef.documents.push(entityDoc);
    entityDoc.definitions.push(entity);
    return entityDoc;
}
exports.createDocumentForEntity = createDocumentForEntity;
//# sourceMappingURL=CdmCollectionHelperFunctions.js.map