definition-generator-framework 1.2.2 → 1.2.3

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.
@@ -0,0 +1,7 @@
1
+ import { Context, FileInfo, LocationInFile } from '../framework/framework.model';
2
+ export declare function getMockContext(): Context;
3
+ export declare function getMockContextFromContents(contents: string[]): Context;
4
+ export declare function getMockFileInfo(content: string): FileInfo;
5
+ export declare const SampleLocation1: LocationInFile;
6
+ export declare const SampleLocation2: LocationInFile;
7
+ export declare const SampleLocation3: LocationInFile;
@@ -0,0 +1,21 @@
1
+ import Joi from 'joi';
2
+ import { Output } from './framework.model';
3
+ export type DefinitionComponentClassType<T> = new (...args: any[]) => DefinitionComponent<T>;
4
+ export interface DefinitionComponentMeta {
5
+ definitionName: string;
6
+ singleton?: boolean;
7
+ validationSchema: Joi.Schema;
8
+ }
9
+ export declare function DefinitionComponentDecorator(meta: DefinitionComponentMeta): (ComponentClass: DefinitionComponentClassType<any>) => any;
10
+ export declare abstract class DefinitionComponent<T> {
11
+ abstract process(definitions: T, context: Output): Promise<void>;
12
+ }
13
+ interface DefinitionModuleMeta {
14
+ modules: DefinitionComponentClassType<any>[];
15
+ interfaces: string;
16
+ }
17
+ export declare function DefinitionModuleDecorator(meta: DefinitionModuleMeta): (ModuleClass: DefinitionModuleClassType) => any;
18
+ export type DefinitionModuleClassType = new (...args: any[]) => DefinitionModule;
19
+ export declare abstract class DefinitionModule {
20
+ }
21
+ export {};
@@ -0,0 +1,6 @@
1
+ import { DefinitionComponentClassType } from './framework';
2
+ export declare class FrameworkData {
3
+ static readonly definitionNames: Set<string>;
4
+ static readonly modules: DefinitionComponentClassType<any>[];
5
+ static interfaces: string;
6
+ }
@@ -0,0 +1,40 @@
1
+ export interface FileSystem {
2
+ existsSync: (path: string) => boolean;
3
+ }
4
+ export interface FileInfo {
5
+ path: string;
6
+ content: string;
7
+ }
8
+ export interface LocationInFile {
9
+ readonly path: string;
10
+ readonly line: number;
11
+ }
12
+ export interface ErrorLog {
13
+ readonly description: string;
14
+ readonly location: LocationInFile;
15
+ }
16
+ export interface Config {
17
+ projectRoot: string;
18
+ }
19
+ export type RawData = undefined | string | ParsedStructure[] | Record<string, ParsedStructure>;
20
+ export interface ParsedStructure {
21
+ readonly rawData: RawData;
22
+ readonly line: number;
23
+ }
24
+ export interface RawDefinition {
25
+ readonly type: string;
26
+ readonly parsedStructure: ParsedStructure;
27
+ readonly location: LocationInFile;
28
+ }
29
+ export interface Context {
30
+ readonly root: string;
31
+ readonly config: Config;
32
+ readonly rawDefinitions: RawDefinition[];
33
+ readonly files: FileInfo[];
34
+ readonly output: FileInfo[];
35
+ readonly errorLogs: ErrorLog[];
36
+ }
37
+ export interface Output {
38
+ addFile: (fileInfo: FileInfo) => void;
39
+ addError: (errorLog: ErrorLog) => void;
40
+ }
@@ -0,0 +1,5 @@
1
+ export declare class Kernel {
2
+ static process(): Promise<void>;
3
+ private static generateOutputFiles;
4
+ private static getOutputFiles;
5
+ }
@@ -0,0 +1,10 @@
1
+ declare class CommonFunctionsClass {
2
+ decorateDefinitionName(name: string, definitionType: string): string;
3
+ kebabCaseToCamelCase(string: string): string;
4
+ lowerCaseFirstLetter(string: string): string;
5
+ upperCaseFirstLetter(string: string): string;
6
+ removeWhiteSpace(row: string): string;
7
+ removeComments(row: string): string;
8
+ }
9
+ export declare const CommonFunctions: CommonFunctionsClass;
10
+ export {};
@@ -0,0 +1,11 @@
1
+ import { Context, LocationInFile } from '../../framework/framework.model';
2
+ export declare class DuplicateHelper {
3
+ private group;
4
+ private identifiers;
5
+ private identifierToLocation;
6
+ private addedIdentifiers;
7
+ private duplicates;
8
+ constructor(group: string);
9
+ newEntry(identifier: string, location: LocationInFile): boolean;
10
+ flush(context: Context): void;
11
+ }
@@ -0,0 +1,18 @@
1
+ declare class OutputHelperClass {
2
+ generateArrayOutput(options: {
3
+ preText?: string;
4
+ variableName: string;
5
+ variableType: string;
6
+ variable: any[];
7
+ }): Promise<string>;
8
+ generateOutput(options: {
9
+ preText?: string;
10
+ variableName: string;
11
+ variableType?: string;
12
+ variable: any;
13
+ }): Promise<string>;
14
+ private format;
15
+ private stringify;
16
+ }
17
+ export declare const OutputHelper: OutputHelperClass;
18
+ export {};
@@ -0,0 +1,7 @@
1
+ import { RawDefinition } from '../../framework/framework.model';
2
+ export declare class RawDefinitionHelper {
3
+ static findLine(rawDefinition: RawDefinition, path: (string | number)[]): number;
4
+ static flatten(rawDefinition: RawDefinition): any;
5
+ private static findLineRawData;
6
+ private static flattenRawData;
7
+ }
@@ -0,0 +1,23 @@
1
+ import * as Joi from 'joi';
2
+ import { FileSystem, Context } from '../../framework/framework.model';
3
+ import { DefinitionComponentClassType } from '../../framework/framework';
4
+ declare module 'joi' {
5
+ interface StringSchema {
6
+ uniqueNameGroup(definitionComponentClass: DefinitionComponentClassType<any>): Joi.StringSchema;
7
+ path(): Joi.StringSchema;
8
+ reference(definitionComponentClass: DefinitionComponentClassType<any> | DefinitionComponentClassType<any>[]): Joi.StringSchema;
9
+ }
10
+ }
11
+ export declare class JoiCustomValidators {
12
+ private static rootDirectory;
13
+ private static definitionNames;
14
+ private static duplicateHelpers;
15
+ static logDuplicates(context: Context): void;
16
+ static setRootDirectory(rootDirectory: string): void;
17
+ static decorate(fs: FileSystem): void;
18
+ private static getDefinitionTypesFromArray;
19
+ private static getValidationState;
20
+ private static getPathAndRawDefinition;
21
+ private static getDefinitionNames;
22
+ private static getDuplicateHelper;
23
+ }
@@ -0,0 +1,12 @@
1
+ import * as Joi from 'joi';
2
+ import { Context, RawDefinition } from '../../framework/framework.model';
3
+ export interface GroupDefinition {
4
+ name: string;
5
+ group: string[];
6
+ }
7
+ export declare class Validator {
8
+ static definitionToRawDefintion: Map<any, RawDefinition>;
9
+ static convert<T>(definitionType: string, schema: Joi.AnySchema, context: Context): T[];
10
+ static convertSingular<T>(definitionType: string, schema: Joi.AnySchema, context: Context): T | undefined;
11
+ static validate<T>(rawDefinition: RawDefinition, schema: Joi.AnySchema, context: Context, logErrors?: boolean): T | undefined;
12
+ }
@@ -0,0 +1,5 @@
1
+ export { Validator } from './helpers/validator/validator';
2
+ export { JoiCustomValidators } from './helpers/validator/joi-custom-validators';
3
+ export { DefinitionModule, DefinitionModuleDecorator, DefinitionComponent, DefinitionComponentDecorator } from './framework/framework';
4
+ export { OutputHelper } from './helpers/output-helper/output-helper';
5
+ export { Output, ErrorLog } from './framework/framework.model';
@@ -0,0 +1,20 @@
1
+ import { FileInfo, LocationInFile, ErrorLog } from '../framework/framework.model';
2
+ export interface DefinitionPlaneText {
3
+ readonly type: string;
4
+ readonly content: string[];
5
+ readonly location: LocationInFile;
6
+ }
7
+ export interface SelectDefinitionsResult {
8
+ definitionPlaneTexts: DefinitionPlaneText[];
9
+ errorLogs: ErrorLog[];
10
+ }
11
+ export declare class SelectDefinitionsHelper {
12
+ private definitionsStarted;
13
+ private currentItem;
14
+ private definitionPlaneTexts;
15
+ private errorLogs;
16
+ private currentFilePath;
17
+ process(file: FileInfo): SelectDefinitionsResult;
18
+ private flushCurrentItem;
19
+ private onDeclarationEncountered;
20
+ }
@@ -0,0 +1,11 @@
1
+ import { DefinitionPlaneText } from './1-select-definitions-helper';
2
+ import { LocationInFile, ErrorLog, RawDefinition, ParsedStructure } from '../framework/framework.model';
3
+ export interface StructureParserResult {
4
+ readonly rawDefinitions: RawDefinition[];
5
+ readonly errorLogs: ErrorLog[];
6
+ }
7
+ export declare class StructureParserHelper {
8
+ static getParsedStructure(content: string[], location: LocationInFile): ParsedStructure;
9
+ private static getStructureType;
10
+ process(definitionPlaneTexts: DefinitionPlaneText[]): StructureParserResult;
11
+ }
@@ -0,0 +1,10 @@
1
+ import * as Joi from 'joi';
2
+ import { Context } from '../framework/framework.model';
3
+ export declare const ConfigDefinitionName = "CONFIG";
4
+ export declare class Config {
5
+ static $meta: {
6
+ definitionName: string;
7
+ validationSchema: Joi.ObjectSchema<any>;
8
+ };
9
+ static process(context: Context): void;
10
+ }
@@ -0,0 +1,13 @@
1
+ import { DefinitionPlaneText } from '../1-select-definitions-helper';
2
+ import { LocationInFile, ErrorLog, RawData, RawDefinition, ParsedStructure } from '../../framework/framework.model';
3
+ export declare function getBaseStructure(location: LocationInFile, parsedStructure: ParsedStructure): RawDefinition;
4
+ export declare function getMockDefinitionPlaneText(content: string[]): DefinitionPlaneText;
5
+ export declare function getExpectedStructure(expected: RawData, offset: number, location: LocationInFile): RawDefinition;
6
+ export declare function getExpectedParsedStructure(content: string | undefined, location: LocationInFile): ParsedStructure;
7
+ export declare class ExpectErrorHelper {
8
+ private parser;
9
+ constructor(parser: {
10
+ parse: (content: string[], location: LocationInFile) => ParsedStructure;
11
+ });
12
+ expect(content: string[], expectedError: ErrorLog): void;
13
+ }
@@ -0,0 +1,4 @@
1
+ import { LocationInFile, ParsedStructure } from '../../framework/framework.model';
2
+ export declare class ArrayParser {
3
+ static parse(content: string[], location: LocationInFile): ParsedStructure;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { LocationInFile, ParsedStructure } from '../../framework/framework.model';
2
+ export declare class ObjectParser {
3
+ static parse(content: string[], location: LocationInFile): ParsedStructure;
4
+ }
@@ -0,0 +1,7 @@
1
+ import { LocationInFile, ParsedStructure } from '../../framework/framework.model';
2
+ export declare class PrimitiveParser {
3
+ static parse(content: string[], location: LocationInFile): ParsedStructure;
4
+ private static parsePlaneString;
5
+ private static parseQuotedString;
6
+ private static parseMultilineString;
7
+ }
@@ -0,0 +1,6 @@
1
+ import { Context } from '../framework/framework.model';
2
+ export declare class RawDataParser {
3
+ private static selectDefinitionsHelper;
4
+ private static structureParserHelper;
5
+ static process(context: Context): void;
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "definition-generator-framework",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Definition Generator Framework",
5
5
  "main": "dist/index.js",
6
6
  "repository": {