@finos/legend-application
Version:
Legend application core
59 lines • 2.86 kB
JavaScript
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* 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 { guaranteeNonEmptyString, guaranteeNonNullable, URL_SEPARATOR, } from '@finos/legend-shared';
import { collectKeyedDocumentationEntriesFromConfig, collectContextualDocumentationEntries, collectDocumentationLinkEntryFromConfig, } from '../stores/DocumentationService.js';
export class LegendApplicationConfig {
appName;
baseAddress;
env;
applicationStorageKey;
// documentation
documentationUrl;
documentationLinkEntries = [];
documentationRegistryEntries = [];
keyedDocumentationEntries = [];
contextualDocEntries = [];
// version
appVersion;
appVersionBuildTime;
appVersionCommitId;
constructor(input) {
this.baseAddress = input.baseAddress;
this.appName = guaranteeNonEmptyString(input.configData.appName, `Can't configure application: 'appName' field is missing or empty`);
this.env = guaranteeNonEmptyString(input.configData.env, `Can't configure application: 'env' field is missing or empty`);
this.applicationStorageKey =
input.configData.application?.storageKey ??
this.getDefaultApplicationStorageKey();
// Documentation
this.documentationUrl = input.configData.documentation?.url;
this.documentationLinkEntries = collectDocumentationLinkEntryFromConfig(input.configData.documentation?.links ?? {});
this.documentationRegistryEntries =
input.configData.documentation?.registry ?? [];
this.keyedDocumentationEntries = collectKeyedDocumentationEntriesFromConfig(input.configData.documentation?.entries ?? {});
this.contextualDocEntries = collectContextualDocumentationEntries(input.configData.documentation?.contextualEntries ?? {});
// Version
this.appVersion = guaranteeNonNullable(input.versionData.version, `Can't collect application version: 'version' field is missing`);
this.appVersionBuildTime = input.versionData.buildTime;
this.appVersionCommitId = input.versionData.commitSHA;
}
static resolveAbsoluteUrl(url) {
if (url.trim().startsWith(URL_SEPARATOR)) {
return window.location.origin + url;
}
return url;
}
}
//# sourceMappingURL=LegendApplicationConfig.js.map