@breadstone-tools/openapi-app 0.0.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Cli/Cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=Cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cli.d.ts","sourceRoot":"","sources":["../../src/Cli/Cli.ts"],"names":[],"mappings":""}
package/Cli/Cli.js ADDED
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ // // #region Requires
3
+ // import { File, LogLevelAppender, Logger, Program, String, type ILogLevelAppenderConfig } from '@breadstone-infrastructure/utilities';
4
+ // import type { OpenApiParser, TemplateBuilder, TemplateEngine } from '@breadstone-tools/openapi-core';
5
+ // import { ArgumentParser } from 'argparse';
6
+ // import path from 'path';
7
+ // import { CliArgs } from './CliArgs';
8
+ // import { CliConfig } from './CliConfig';
9
+ // // #endregion
10
+ // /**
11
+ // * @class Program
12
+ // */
13
+ // export class Cli extends Program {
14
+ // // #region Fields
15
+ // private readonly _config: CliConfig;
16
+ // private readonly _logger!: Logger;
17
+ // private readonly _templateEngine: TemplateEngine | null;
18
+ // private readonly _openApiParser: OpenApiParser | null;
19
+ // private readonly _templateBuilder: TemplateBuilder | null;
20
+ // // #endregion
21
+ // // #region Ctor
22
+ // /**
23
+ // * @private
24
+ // * @hidde
25
+ // */
26
+ // private constructor(config: CliConfig) {
27
+ // super();
28
+ // Logger.configure({
29
+ // overrideConsole: false,
30
+ // appender: [
31
+ // [LogLevelAppender, {
32
+ // name: 'LogLevelAppender',
33
+ // logFormat: '',
34
+ // exceptionFormat: '',
35
+ // style: 'tag',
36
+ // maxLength: 7
37
+ // } as ILogLevelAppenderConfig]
38
+ // ]
39
+ // }, true);
40
+ // this._config = new CliConfig(config);
41
+ // this._templateEngine = null;
42
+ // this._openApiParser = null;
43
+ // this._templateBuilder = null;
44
+ // }
45
+ // // #endregion
46
+ // // #region Methods
47
+ // /**
48
+ // * Setup the cli from configuration path.
49
+ // * @public
50
+ // * @static
51
+ // * @param {string} p The configuration path.
52
+ // * @returns {Cli}
53
+ // */
54
+ // public static fromPath(p: string): Cli {
55
+ // const config = File.readAllJson<CliConfig>(p);
56
+ // return new Cli(config);
57
+ // }
58
+ // /**
59
+ // * Setup the cli from configuration.
60
+ // * @public
61
+ // * @static
62
+ // * @param {CliConfig} config The configuration.
63
+ // * @returns {Cli}
64
+ // */
65
+ // public static fromConfig(config: CliConfig): Cli {
66
+ // return new Cli(config);
67
+ // }
68
+ // /**
69
+ // * Setup the cli from command line args.
70
+ // * @public
71
+ // * @static
72
+ // * @returns {Cli}
73
+ // */
74
+ // public static fromArgs(): Cli {
75
+ // const args = new CliArgs();
76
+ // const parser = new ArgumentParser({
77
+ // epilog: '1.0.0',
78
+ // // eslint-disable-next-line camelcase
79
+ // add_help: true,
80
+ // description: 'openapi',
81
+ // usage: '(alpha)'
82
+ // });
83
+ // args.toArgumentOptions().forEach((x) => parser.add_argument(x[0], x[1]));
84
+ // args.assign(parser.parse_args());
85
+ // return new Cli(args);
86
+ // }
87
+ // /**
88
+ // * @internal
89
+ // * @hidden
90
+ // * @static
91
+ // * @returns {void}
92
+ // */
93
+ // public static start(): void {
94
+ // const catchAction = (error: Error | any): void => {
95
+ // console.error('UNKNOWN ERROR', error);
96
+ // };
97
+ // let cli = null;
98
+ // try {
99
+ // cli = Cli.fromArgs();
100
+ // } catch (error) {
101
+ // catchAction(error);
102
+ // return;
103
+ // }
104
+ // try {
105
+ // void cli.init();
106
+ // } catch (error) {
107
+ // catchAction(error);
108
+ // return;
109
+ // }
110
+ // cli.run().catch(catchAction);
111
+ // }
112
+ // /**
113
+ // * @public
114
+ // * @override
115
+ // * @returns {Promise<number>}
116
+ // */
117
+ // public override async run(): Promise<number> {
118
+ // return super.run();
119
+ // }
120
+ // /**
121
+ // * @hidden
122
+ // * @protected
123
+ // * @override
124
+ // * @returns {Promise<number>}
125
+ // */
126
+ // protected override async process(done: (error: Error | null, stdout: string, stderr: string) => void): Promise<number> {
127
+ // try {
128
+ // const tplPath = path.join(__dirname, '/../../templates');
129
+ // // TODO: remove the last param!!!!!!!!!!!!!!!!!!!
130
+ // const abstracts = await this._openApiParser?.parse(this._config.endpoint);
131
+ // this._templateEngine?.compose(tplPath);
132
+ // await this._templateBuilder?.build(abstracts ?? [], {
133
+ // preferedComplexType: 'class',
134
+ // preferedSimpleType: 'enum',
135
+ // target: this._config.target
136
+ // });
137
+ // const hasErrorCode = false;
138
+ // done(hasErrorCode ? new Error('Oops something went wrong') : null, '', '');
139
+ // return 0;
140
+ // } catch (error) {
141
+ // if (error instanceof Error) {
142
+ // this._logger.logError(
143
+ // `${error.message +
144
+ // String.newLine
145
+ // }${this._config.debug ? error.stack : ''}`
146
+ // );
147
+ // } else {
148
+ // this._logger.logError(error);
149
+ // }
150
+ // process.exit(-1);
151
+ // }
152
+ // }
153
+ // // #endregion
154
+ // }
155
+ //# sourceMappingURL=Cli.js.map
package/Cli/Cli.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cli.js","sourceRoot":"","sources":["../../src/Cli/Cli.ts"],"names":[],"mappings":";AAAA,sBAAsB;AAEtB,wIAAwI;AACxI,wGAAwG;AACxG,6CAA6C;AAC7C,2BAA2B;AAC3B,uCAAuC;AACvC,2CAA2C;AAE3C,gBAAgB;AAEhB,MAAM;AACN,oBAAoB;AACpB,MAAM;AACN,qCAAqC;AAErC,wBAAwB;AAExB,2CAA2C;AAC3C,yCAAyC;AACzC,+DAA+D;AAC/D,6DAA6D;AAC7D,iEAAiE;AAEjE,oBAAoB;AAEpB,sBAAsB;AAEtB,UAAU;AACV,kBAAkB;AAClB,gBAAgB;AAChB,UAAU;AACV,+CAA+C;AAC/C,mBAAmB;AACnB,6BAA6B;AAC7B,sCAAsC;AACtC,0BAA0B;AAC1B,uCAAuC;AACvC,gDAAgD;AAChD,qCAAqC;AACrC,2CAA2C;AAC3C,oCAAoC;AACpC,mC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AACpC,UAAU;AACV,+HAA+H;AAC/H,gBAAgB;AAChB,wEAAwE;AACxE,gEAAgE;AAChE,yFAAyF;AACzF,sDAAsD;AACtD,oEAAoE;AACpE,gDAAgD;AAChD,8CAA8C;AAC9C,8CAA8C;AAC9C,kBAAkB;AAElB,0CAA0C;AAC1C,0FAA0F;AAC1F,wBAAwB;AACxB,4BAA4B;AAC5B,4CAA4C;AAC5C,yCAAyC;AACzC,yCAAyC;AACzC,qCAAqC;AACrC,iEAAiE;AACjE,qBAAqB;AACrB,uBAAuB;AACvB,gDAAgD;AAChD,gBAAgB;AAChB,gCAAgC;AAChC,YAAY;AACZ,QAAQ;AAER,oBAAoB;AAEpB,IAAI"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=CliArgs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliArgs.d.ts","sourceRoot":"","sources":["../../src/Cli/CliArgs.ts"],"names":[],"mappings":""}
package/Cli/CliArgs.js ADDED
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ // // #region Imports
3
+ // import { Boolean } from '@breadstone-infrastructure/utilities';
4
+ // import type { ArgumentOptions } from 'argparse';
5
+ // import { toLowerCaseFirstChar } from '../Utils';
6
+ // import { CliConfig } from './CliConfig';
7
+ // // #endregion
8
+ // export class CliArgs extends CliConfig {
9
+ // // #region Ctor
10
+ // public constructor(value?: Partial<CliArgs>) {
11
+ // super(value);
12
+ // }
13
+ // // #endregion
14
+ // // #region Methods
15
+ // public toArgumentOptions(): Array<[Array<string>, ArgumentOptions]> {
16
+ // const options = new Array<[Array<string>, ArgumentOptions]>();
17
+ // options.push([['-p', '--Project'], {
18
+ // required: true,
19
+ // default: this.project,
20
+ // help: 'The path to the *.json configuration file.'
21
+ // }]);
22
+ // options.push([['-cwd', '--Cwd'], {
23
+ // required: false,
24
+ // default: this.cwd,
25
+ // help: 'The path of the current working directory.'
26
+ // }]);
27
+ // options.push([['-e', '--Emoji'], {
28
+ // // eslint-disable-next-line @typescript-eslint/unbound-method
29
+ // type: Boolean.parse,
30
+ // required: false,
31
+ // default: this.emoji,
32
+ // help: 'The emoji parameter ensures that Emoji will displayed. (breaks with windows update)'
33
+ // }]);
34
+ // // options.push([['-se', '--SkipError'], { type: Boolean.parse, required: false, defaultValue: this._skipError, help: 'The skip error parameter ensures that the process is not terminated when the process trows an error.', }]);
35
+ // // options.push([['-d', '--Debug'], { type: Boolean.parse, required: false, defaultValue: this._debug, help: 'The debug parameter shows extended debug logging.', }]);
36
+ // // options.push([['-ex', '--Excludes'], { type: parseArray, required: false, defaultValue: this._excludes, help: 'Excludes files or folders that are matching the given glob pattern.', }]);
37
+ // // options.push([['-r', '--Report'], { type: Boolean.parse, required: false, defaultValue: this._report, help: 'Create a summary report at the end of the execution.', }]);
38
+ // return options;
39
+ // }
40
+ // public override toString(): string {
41
+ // // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
42
+ // const argumentKeys = this.toArgumentOptions().map((x) => x[0] ? x[0].pop() : '')
43
+ // .map((x) => toLowerCaseFirstChar(x ?? ''.replace('--', '-')));
44
+ // const argumentOptions = this.toArgumentOptions().map((x) => x[1]);
45
+ // const propertyKeys = argumentKeys.map((x) => toLowerCaseFirstChar(x.replace('-', '')));
46
+ // const argumentPropertyMapping = new Map<string, any>();
47
+ // // eslint-disable-next-line @typescript-eslint/ban-ts-comment
48
+ // // @ts-ignore
49
+ // argumentKeys.forEach((_, i) => argumentPropertyMapping.set(argumentKeys[i], this[propertyKeys[i]]));
50
+ // const argumentPropertyString = Array.from(argumentPropertyMapping.entries()).map((x, i) => {
51
+ // const option = argumentOptions[i];
52
+ // // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
53
+ // if (option) {
54
+ // switch (typeof x[1]) {
55
+ // case 'string':
56
+ // return x[1] !== '' ? `${x[0]} ${x[1]}` : '';
57
+ // case 'boolean':
58
+ // return x[1] ? x[0] : '';
59
+ // case 'number':
60
+ // return x[1] > 0 ? `${x[0]} ${x[1]}` : '';
61
+ // case 'object':
62
+ // return JSON.stringify(x[1]);
63
+ // default:
64
+ // throw new Error(`Invalid argument type '${x[1]}'.`);
65
+ // }
66
+ // }
67
+ // throw new Error();
68
+ // });
69
+ // return argumentPropertyString.join(' ');
70
+ // }
71
+ // // #endregion
72
+ // }
73
+ //# sourceMappingURL=CliArgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliArgs.js","sourceRoot":"","sources":["../../src/Cli/CliArgs.ts"],"names":[],"mappings":";AAAA,qBAAqB;AAErB,kEAAkE;AAClE,mDAAmD;AACnD,mDAAmD;AACnD,2CAA2C;AAE3C,gBAAgB;AAEhB,2CAA2C;AAE3C,sBAAsB;AAEtB,qDAAqD;AACrD,wBAAwB;AACxB,QAAQ;AAER,oBAAoB;AAEpB,yBAAyB;AAEzB,4EAA4E;AAC5E,yEAAyE;AACzE,+CAA+C;AAC/C,8BAA8B;AAC9B,qCAAqC;AACrC,iEAAiE;AACjE,eAAe;AACf,6CAA6C;AAC7C,+BAA+B;AAC/B,iCAAiC;AACjC,iEAAiE;AACjE,eAAe;AACf,6CAA6C;AAC7C,4EAA4E;AAC5E,mCAAmC;AACnC,+BAA+B;AAC/B,mCAAmC;AACnC,0GAA0G;AAC1G,eAAe;AACf,6OAA6O;AAC7O,iLAAiL;AACjL,uMAAuM;AACvM,sLAAsL;AAEtL,0BAA0B;AAC1B,QAAQ;AAER,2CAA2C;AAC3C,kFAAkF;AAClF,2FAA2F;AAC3F,6EAA6E;AAC7E,6EAA6E;AAC7E,kGAAkG;AAClG,kEAAkE;AAElE,wEAAwE;AACxE,wBAAwB;AACxB,+GAA+G;AAC/G,uGAAuG;AACvG,iDAAiD;AACjD,sFAAsF;AACtF,4BAA4B;AAC5B,yCAAyC;AACzC,qCAAqC;AACrC,uEAAuE;AACvE,sCAAsC;AACtC,mDAAmD;AACnD,qCAAqC;AACrC,oEAAoE;AACpE,qCAAqC;AACrC,uDAAuD;AACvD,+BAA+B;AAC/B,+EAA+E;AAC/E,oBAAoB;AACpB,gBAAgB;AAChB,iCAAiC;AACjC,cAAc;AAEd,mDAAmD;AACnD,QAAQ;AAER,oBAAoB;AAEpB,IAAI"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=CliConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliConfig.d.ts","sourceRoot":"","sources":["../../src/Cli/CliConfig.ts"],"names":[],"mappings":""}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ // // #region Imports
3
+ // import type { TemplateType } from '@breadstone-tools/openapi-core';
4
+ // import { toLowerCaseFirstChar } from '../Utils';
5
+ // // #endregion
6
+ // export class CliConfig {
7
+ // // #region Fields
8
+ // private _endpoint: string;
9
+ // private _templates: Map<TemplateType, string>;
10
+ // private _target: string;
11
+ // private _project: string;
12
+ // private _cwd: string;
13
+ // private _emoji: boolean;
14
+ // private _debug: boolean;
15
+ // // #endregion
16
+ // // #region Ctor
17
+ // /**
18
+ // * @param {CliConfig} value The optional cli config value.
19
+ // */
20
+ // public constructor(value?: Partial<CliConfig>) {
21
+ // this._endpoint = '';
22
+ // this._templates = new Map();
23
+ // this._target = '';
24
+ // this._project = '';
25
+ // this._cwd = '';
26
+ // this._emoji = false;
27
+ // this._debug = false;
28
+ // this.assign(value);
29
+ // }
30
+ // // #endregion
31
+ // // #region Properties
32
+ // public get endpoint(): string {
33
+ // return this._endpoint;
34
+ // }
35
+ // public set endpoint(value: string) {
36
+ // this._endpoint = value;
37
+ // }
38
+ // public get templates(): Map<TemplateType, string> {
39
+ // return this._templates;
40
+ // }
41
+ // public set templates(value: Map<TemplateType, string>) {
42
+ // this._templates = value;
43
+ // }
44
+ // public get target(): string {
45
+ // return this._target;
46
+ // }
47
+ // public set target(value: string) {
48
+ // this._target = value;
49
+ // }
50
+ // public get project(): string {
51
+ // return this._project;
52
+ // }
53
+ // public set project(value: string) {
54
+ // this._project = value;
55
+ // }
56
+ // public get cwd(): string {
57
+ // return this._cwd;
58
+ // }
59
+ // public set cwd(value: string) {
60
+ // this._cwd = value;
61
+ // }
62
+ // public get emoji(): boolean {
63
+ // return this._emoji;
64
+ // }
65
+ // public set emoji(value: boolean) {
66
+ // this._emoji = value;
67
+ // }
68
+ // public get debug(): boolean {
69
+ // return this._debug;
70
+ // }
71
+ // public set debug(value: boolean) {
72
+ // this._debug = value;
73
+ // }
74
+ // // #endregion
75
+ // // #region Methods
76
+ // public assign(value?: Partial<CliConfig>): this {
77
+ // if (value) {
78
+ // Object.keys(value).forEach((key) => {
79
+ // // eslint-disable-next-line @typescript-eslint/ban-ts-comment
80
+ // // @ts-ignore
81
+ // this[toLowerCaseFirstChar(key)] = value[key];
82
+ // });
83
+ // }
84
+ // return this;
85
+ // }
86
+ // // #endregion
87
+ // }
88
+ // export function defaultCliConfig(): CliConfig {
89
+ // return new CliConfig();
90
+ // }
91
+ //# sourceMappingURL=CliConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliConfig.js","sourceRoot":"","sources":["../../src/Cli/CliConfig.ts"],"names":[],"mappings":";AAAA,qBAAqB;AAErB,sEAAsE;AACtE,mDAAmD;AAEnD,gBAAgB;AAEhB,2BAA2B;AAE3B,wBAAwB;AAExB,iCAAiC;AACjC,qDAAqD;AACrD,+BAA+B;AAC/B,gCAAgC;AAChC,4BAA4B;AAC5B,+BAA+B;AAC/B,+BAA+B;AAE/B,oBAAoB;AAEpB,sBAAsB;AAEtB,UAAU;AACV,iEAAiE;AACjE,UAAU;AACV,uDAAuD;AACvD,+BAA+B;AAC/B,uCAAuC;AACvC,6BAA6B;AAC7B,8BAA8B;AAC9B,0BAA0B;AAC1B,+BAA+B;AAC/B,+BAA+B;AAE/B,8BAA8B;AAC9B,QAAQ;AAER,oBAAoB;AAEpB,4BAA4B;AAE5B,sCAAsC;AACtC,iCAAiC;AACjC,QAAQ;AAER,2CAA2C;AAC3C,kCAAkC;AAClC,QAAQ;AAER,0DAA0D;AAC1D,kCAAkC;AAClC,QAAQ;AAER,+DAA+D;AAC/D,mCAAmC;AACnC,QAAQ;AAER,oCAAoC;AACpC,+BAA+B;AAC/B,QAAQ;AAER,yCAAyC;AACzC,gCAAgC;AAChC,QAAQ;AAER,qCAAqC;AACrC,gCAAgC;AAChC,QAAQ;AAER,0CAA0C;AAC1C,iCAAiC;AACjC,QAAQ;AAER,iCAAiC;AACjC,4BAA4B;AAC5B,QAAQ;AAER,sCAAsC;AACtC,6BAA6B;AAC7B,QAAQ;AAER,oCAAoC;AACpC,8BAA8B;AAC9B,QAAQ;AAER,yCAAyC;AACzC,+BAA+B;AAC/B,QAAQ;AAER,oCAAoC;AACpC,8BAA8B;AAC9B,QAAQ;AAER,yCAAyC;AACzC,+BAA+B;AAC/B,QAAQ;AAER,oBAAoB;AAEpB,yBAAyB;AAEzB,wDAAwD;AACxD,uBAAuB;AACvB,oDAAoD;AACpD,gFAAgF;AAChF,gCAAgC;AAChC,gEAAgE;AAChE,kBAAkB;AAClB,YAAY;AACZ,uBAAuB;AACvB,QAAQ;AAER,oBAAoB;AAEpB,IAAI;AAEJ,kDAAkD;AAClD,8BAA8B;AAC9B,IAAI"}
package/Index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { run } from './Run.js';
2
+ export type { IRunConfig, IRunResult } from './Run.js';
3
+ //# sourceMappingURL=Index.d.ts.map
package/Index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Index.d.ts","sourceRoot":"","sources":["../src/Index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
package/Index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.run = void 0;
4
+ // export { Cli } from './Cli/Cli';
5
+ // export { CliArgs } from './Cli/CliArgs';
6
+ // export { CliConfig, defaultCliConfig } from './Cli/CliConfig';
7
+ var Run_js_1 = require("./Run.js");
8
+ Object.defineProperty(exports, "run", { enumerable: true, get: function () { return Run_js_1.run; } });
9
+ //# sourceMappingURL=Index.js.map
package/Index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Index.js","sourceRoot":"","sources":["../src/Index.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,2CAA2C;AAC3C,iEAAiE;AACjE,mCAA+B;AAAtB,6FAAA,GAAG,OAAA"}
package/Run.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { type ITypeScriptOptions } from '@breadstone-tools/openapi-core';
2
+ import { type TemplateKind } from '@breadstone-tools/openapi-templates';
3
+ export interface IRunConfig {
4
+ cwd: string;
5
+ output: string;
6
+ endpoints?: Array<string> | string;
7
+ parser?: ITypeScriptOptions;
8
+ debug?: boolean;
9
+ dryRun?: boolean;
10
+ clearRun?: boolean;
11
+ templates?: Array<{
12
+ kind: TemplateKind;
13
+ template: string;
14
+ }>;
15
+ quiet?: boolean;
16
+ }
17
+ export interface IRunResult {
18
+ target: string;
19
+ }
20
+ export declare function run(config: IRunConfig): Promise<IRunResult>;
21
+ //# sourceMappingURL=Run.d.ts.map
package/Run.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Run.d.ts","sourceRoot":"","sources":["../src/Run.ts"],"names":[],"mappings":"AAGA,OAAO,EAA4E,KAAK,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACnJ,OAAO,EAAoB,KAAK,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAI1F,MAAM,WAAW,UAAU;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IACnC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,YAAY,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAiEjE"}
package/Run.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ // #region Imports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.run = run;
5
+ const utilities_1 = require("@breadstone-infrastructure/utilities");
6
+ const openapi_core_1 = require("@breadstone-tools/openapi-core");
7
+ const openapi_templates_1 = require("@breadstone-tools/openapi-templates");
8
+ async function run(config) {
9
+ const logger = new utilities_1.ConsoleLogger();
10
+ const templateEngine = new openapi_core_1.TemplateEngine({
11
+ debug: config.debug ?? false
12
+ });
13
+ const templateBuilder = new openapi_core_1.TemplateBuilder(logger, {
14
+ debug: config.debug ?? false,
15
+ test: config.dryRun ?? false,
16
+ emoji: true
17
+ }, templateEngine);
18
+ const openApiParser = new openapi_core_1.OpenApiParser(logger, {
19
+ debug: config.debug ?? false,
20
+ fetchTimeout: config.parser?.fetchTimeout,
21
+ emoji: true
22
+ });
23
+ if (Array.isArray(config.endpoints)) {
24
+ throw new Error('Multiple endpoints are not supported yet.');
25
+ }
26
+ if (!config.endpoints) {
27
+ throw new Error('No endpoints provided.');
28
+ }
29
+ const target = utilities_1.Path.combine(config.cwd, config.output);
30
+ if (config.clearRun) {
31
+ const serviceTarget = utilities_1.Path.combine(config.cwd, config.parser?.serviceRoot ?? openapi_core_1.defaultTypeScriptOptions.serviceRoot);
32
+ const modelTarget = utilities_1.Path.combine(config.cwd, config.parser?.modelRoot ?? openapi_core_1.defaultTypeScriptOptions.modelRoot);
33
+ utilities_1.Directory.delete(serviceTarget);
34
+ logger.log(`Deleted directory '${serviceTarget}'.`);
35
+ utilities_1.Directory.delete(modelTarget);
36
+ logger.log(`Deleted directory '${modelTarget}'.`);
37
+ if (config.parser?.indexFile) {
38
+ const indexTarget = utilities_1.Path.combine(config.cwd, 'Index.ts');
39
+ utilities_1.Directory.delete(indexTarget);
40
+ logger.log(`Deleted file '${indexTarget}'.`);
41
+ }
42
+ }
43
+ const api = await openApiParser.parse(config.endpoints, {
44
+ ...openapi_core_1.defaultTypeScriptOptions,
45
+ ...config.parser
46
+ });
47
+ templateEngine.compose((0, openapi_templates_1.templateResolver)().mapping);
48
+ // array to map
49
+ const tplMap = new Map();
50
+ config.templates?.forEach((x) => {
51
+ tplMap.set(x.kind, utilities_1.Path.combine(config.cwd, x.template));
52
+ });
53
+ templateEngine.compose(tplMap);
54
+ await templateBuilder.build(api, {
55
+ preferedComplexType: 'interface',
56
+ preferedSimpleType: 'type',
57
+ target: target
58
+ });
59
+ return {
60
+ target: target
61
+ };
62
+ }
63
+ //# sourceMappingURL=Run.js.map
package/Run.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Run.js","sourceRoot":"","sources":["../src/Run.ts"],"names":[],"mappings":";AAAA,kBAAkB;;AA2BlB,kBAiEC;AA1FD,oEAAsF;AACtF,iEAAmJ;AACnJ,2EAA0F;AAuBnF,KAAK,UAAU,GAAG,CAAC,MAAkB;IACxC,MAAM,MAAM,GAAG,IAAI,yBAAa,EAAE,CAAC;IAEnC,MAAM,cAAc,GAAG,IAAI,6BAAc,CAAC;QACtC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,KAAK;KAC/B,CAAC,CAAC;IACH,MAAM,eAAe,GAAG,IAAI,8BAAe,CAAC,MAAM,EAAE;QAChD,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,KAAK;QAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,IAAI,KAAK;QAC5B,KAAK,EAAE,IAAI;KACd,EAAE,cAAc,CAAC,CAAC;IACnB,M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AC;YACzD,qBAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAC9B,MAAM,CAAC,GAAG,CAAC,iBAAiB,WAAW,IAAI,CAAC,CAAC;QACjD,CAAC;IACL,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE;QACpD,GAAG,uCAAwB;QAC3B,GAAG,MAAM,CAAC,MAAM;KACnB,CAAC,CAAC;IACH,cAAc,CAAC,OAAO,CAAC,IAAA,oCAAgB,GAAE,CAAC,OAAO,CAAC,CAAC;IAEnD,eAAe;IACf,MAAM,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC/C,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAC5B,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,gBAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/B,MAAM,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE;QAC7B,mBAAmB,EAAE,WAAW;QAChC,kBAAkB,EAAE,MAAM;QAC1B,MAAM,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,OAAO;QACH,MAAM,EAAE,MAAM;KACjB,CAAC;AACN,CAAC"}
package/Utils.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Utils.d.ts.map
package/Utils.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":""}
package/Utils.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseArray = parseArray;
4
+ exports.toLowerCaseFirstChar = toLowerCaseFirstChar;
5
+ exports.emoji2 = emoji2;
6
+ /**
7
+ * @internal
8
+ * @hidden
9
+ */
10
+ function parseArray(value) {
11
+ return value.split(' ');
12
+ }
13
+ /**
14
+ * @internal
15
+ * @hidden
16
+ */
17
+ function toLowerCaseFirstChar(value) {
18
+ return value.charAt(0).toLowerCase() + value.slice(1);
19
+ }
20
+ /**
21
+ * @internal
22
+ * @hidden
23
+ */
24
+ function emoji2(value, isEnabled = true) {
25
+ if (isEnabled) {
26
+ return `${value} `;
27
+ }
28
+ return '';
29
+ }
30
+ //# sourceMappingURL=Utils.js.map
package/Utils.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":";;AAIA,gCAEC;AAMD,oDAEC;AAMD,wBAKC;AAzBD;;;GAGG;AACH,SAAgB,UAAU,CAAC,KAAa;IACpC,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,KAAa;IAC9C,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED;;;GAGG;AACH,SAAgB,MAAM,CAAC,KAAa,EAAE,YAAqB,IAAI;IAC3D,IAAI,SAAS,EAAE,CAAC;QACZ,OAAO,GAAG,KAAK,GAAG,CAAC;IACvB,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC"}
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@breadstone-tools/openapi-app",
3
+ "description": "Open API Model generator cli",
4
+ "version": "0.0.2-beta.0",
5
+ "license": "MIT",
6
+ "author": "andre.wehlert <awehlert@breadstone.de> (https://www.breadstone.de)",
7
+ "repository": {
8
+ "url": "git+ssh://git@github.com/RueDeRennes/mosaik.git"
9
+ },
10
+ "type": "commonjs",
11
+ "main": "./Index.js",
12
+ "commonjs": "./Index.js",
13
+ "module": "./Index.js",
14
+ "types": "./Index.d.ts",
15
+ "bin": {
16
+ "cli": "./bin/cli"
17
+ },
18
+ "dependencies": {
19
+ "@breadstone-infrastructure/utilities": "^0.0.2-beta.0",
20
+ "@breadstone-tools/openapi-core": "^0.0.2-beta.0",
21
+ "@breadstone-tools/openapi-templates": "^0.0.2-beta.0",
22
+ "fs-extra": "^11.3.0"
23
+ }
24
+ }