UNPKG

@finos/legend-application

Version:
82 lines 3.83 kB
/** * 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 { type MarkdownText, DocumentationEntry } from '@finos/legend-shared'; import type { GenericLegendApplicationStore } from './ApplicationStore.js'; import type { LegendApplicationLink } from '../application/LegendApplicationConfig.js'; export type DocumentationRegistryEntry = { url: string; /** * Sometimes, we don't need to expose an endpoint to get the documentation data * we support the `simple` mode where the endpoint is really just a JSON * * The caveat about this mode is that the endpoint must have CORS enabled * ideally, and setup with "Access-Control-Allow-Origin", "*" * (e.g. Github Pages - See https://stackoverflow.com/questions/26416727/cross-origin-resource-sharing-on-github-pages) * With that, the network client used to fetch this request must also be simplified to not include credential * See https://stackoverflow.com/questions/19743396/cors-cannot-use-wildcard-in-access-control-allow-origin-when-credentials-flag-i * * During development, an option is to use our mock-server or some sort of CORS proxies, for example `cors-anywhere` * See https://cors-anywhere.herokuapp.com/ */ simple?: boolean | undefined; /** * Optional list of wildcard patterns to be matched against documentation entries' keys to * narrow the scope of inclusion */ includes?: string[]; }; export type DocumentationRegistryData = { entries: Record<string, DocumentationEntryData>; }; export type DocumentationEntryData = { markdownText?: MarkdownText | undefined; title?: string | undefined; text?: string | undefined; url?: string | undefined; related?: string[] | undefined; }; export type KeyedDocumentationEntry = { key: string; content: DocumentationEntry; }; export type DocumentationLinkEntry = { key: string; label: string; url: string; }; export declare const collectKeyedDocumentationEntriesFromConfig: (rawEntries: Record<string, DocumentationEntryData>) => KeyedDocumentationEntry[]; export declare const collectDocumentationLinkEntryFromConfig: (rawEntries: Record<string, LegendApplicationLink>) => DocumentationLinkEntry[]; export type ContextualDocumentationConfig = Record<string, string>; export type ContextualDocumentationEntry = { context: string; documentationKey: string; }; export declare const collectContextualDocumentationEntries: (config: ContextualDocumentationConfig) => ContextualDocumentationEntry[]; export declare class DocumentationService { readonly url?: string | undefined; readonly links?: DocumentationLinkEntry[] | undefined; private readonly docRegistry; private readonly contextualDocIndex; constructor(applicationStore: GenericLegendApplicationStore); getDocEntry(key: string): DocumentationEntry | undefined; hasDocEntry(key: string): boolean; getContextualDocEntry(key: string): DocumentationEntry | undefined; hasContextualDocEntry(key: string): boolean; getAllDocEntries(): DocumentationEntry[]; publishDocRegistry(): Record<string, DocumentationEntryData>; publishContextualDocIndex(): ContextualDocumentationConfig; } //# sourceMappingURL=DocumentationService.d.ts.map