-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
api_generator/src/renderers/render_types/ComponentTypesRenderer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
*/ | ||
|
||
import BaseRenderer from '../BaseRenderer' | ||
import FunctionTypesContainer from './FunctionTypesContainer' | ||
import TypesContainer from './TypesContainer' | ||
|
||
export default class ComponentTypesRenderer extends BaseRenderer { | ||
protected template_file = 'types.component_types.mustache' | ||
private readonly containers: TypesContainer[] | ||
|
||
constructor () { | ||
super() | ||
this.containers = [...TypesContainer.REPO.values()].filter((container) => container.folder_name === '_types') | ||
} | ||
|
||
view (): Record<string, any> { | ||
return { imports: this.#imports(), exports: this.#exports() } | ||
} | ||
|
||
#imports (): Array<{ name: string, path: string }> { | ||
return this.containers.map(container => { | ||
return { | ||
name: container.import_name, | ||
path: FunctionTypesContainer.import_path(container, { file_path: './_types/index.d.ts' }) | ||
} | ||
}) | ||
} | ||
|
||
#exports (): string[] { | ||
return this.containers.map(container => container.import_name) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
api_generator/src/renderers/templates/types.component_types.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{{opensearch_license}}} | ||
{{{generated_code_warning}}} | ||
|
||
{{#imports}} | ||
import * as {{{name}}} from '{{{path}}}' | ||
{{/imports}} | ||
|
||
export { | ||
{{#exports}} | ||
{{{.}}}, | ||
{{/exports}} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters