ondc-code-generator 0.0.3 → 0.0.5

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.
Files changed (72) hide show
  1. package/dist/constants/operations.d.ts +6 -0
  2. package/dist/constants/syntax.d.ts +15 -0
  3. package/dist/generator/config-compiler.d.ts +23 -0
  4. package/dist/generator/generators/classes/abstract-generator.d.ts +11 -0
  5. package/dist/generator/generators/documentation/markdown-message-generator.d.ts +2 -0
  6. package/dist/generator/generators/documentation/md-generator.d.ts +9 -0
  7. package/dist/generator/generators/typescript/templates/json-path-utils.d.ts +5 -0
  8. package/dist/generator/generators/typescript/templates/validation-utils.d.ts +21 -0
  9. package/dist/generator/generators/typescript/ts-ast.d.ts +1 -0
  10. package/dist/generator/generators/typescript/ts-generator.d.ts +17 -0
  11. package/dist/generator/validators/abstract-validator.d.ts +17 -0
  12. package/dist/generator/validators/config-validator.d.ts +11 -0
  13. package/dist/generator/validators/session-data-config/session-data-validator.d.ts +9 -0
  14. package/dist/generator/validators/tests-config/sub-validations.d.ts +38 -0
  15. package/dist/generator/validators/tests-config/test-list-validator.d.ts +10 -0
  16. package/dist/generator/validators/tests-config/test-validator.d.ts +7 -0
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.js +39 -1
  19. package/dist/services/return-complier/ast-functions/compile-to-markdown.d.ts +2 -0
  20. package/dist/services/return-complier/ast-functions/semantic-validations.d.ts +2 -0
  21. package/dist/services/return-complier/ast.d.ts +42 -0
  22. package/dist/services/return-complier/combined.d.ts +2 -0
  23. package/dist/services/return-complier/parser.d.ts +14 -0
  24. package/dist/services/return-complier/tokens.d.ts +22 -0
  25. package/dist/services/schema-service.d.ts +6 -0
  26. package/dist/types/build.d.ts +48 -0
  27. package/dist/types/compiler-types.d.ts +3 -0
  28. package/dist/types/config-types.d.ts +21 -0
  29. package/dist/types/error-codes.d.ts +6 -0
  30. package/dist/types/general-types.d.ts +2 -0
  31. package/dist/utils/config-utils/json-schema-utils.d.ts +7 -0
  32. package/dist/utils/config-utils/yaml.d.ts +1 -0
  33. package/dist/utils/fs-utils.d.ts +3 -0
  34. package/dist/utils/general-utils/string-utils.d.ts +27 -0
  35. package/dist/utils/general-utils/test-object-utils.d.ts +2 -0
  36. package/dist/utils/general-utils/validation-utils.d.ts +5 -0
  37. package/dist/utils/json-path-utils/extract-string-paths.d.ts +8 -0
  38. package/dist/utils/json-path-utils/paths.d.ts +9 -0
  39. package/dist/utils/logger.d.ts +3 -0
  40. package/package.json +2 -2
  41. package/generated/L1-validations/api-tests/cancel.ts +0 -569
  42. package/generated/L1-validations/api-tests/confirm.ts +0 -1162
  43. package/generated/L1-validations/api-tests/init.ts +0 -1063
  44. package/generated/L1-validations/api-tests/on_cancel.ts +0 -2069
  45. package/generated/L1-validations/api-tests/on_confirm.ts +0 -2219
  46. package/generated/L1-validations/api-tests/on_init.ts +0 -1949
  47. package/generated/L1-validations/api-tests/on_search.ts +0 -1574
  48. package/generated/L1-validations/api-tests/on_select.ts +0 -1723
  49. package/generated/L1-validations/api-tests/on_status.ts +0 -2221
  50. package/generated/L1-validations/api-tests/on_update.ts +0 -1969
  51. package/generated/L1-validations/api-tests/search.ts +0 -695
  52. package/generated/L1-validations/api-tests/select.ts +0 -994
  53. package/generated/L1-validations/api-tests/status.ts +0 -443
  54. package/generated/L1-validations/api-tests/update.ts +0 -898
  55. package/generated/L1-validations/error.ts +0 -64
  56. package/generated/L1-validations/index.ts +0 -138
  57. package/generated/L1-validations/page/index.html +0 -2118
  58. package/generated/L1-validations/page/style.css +0 -225
  59. package/generated/L1-validations/readme.md +0 -1779
  60. package/generated/L1-validations/types/test-config.ts +0 -27
  61. package/generated/L1-validations/utils/json-path-utils.ts +0 -17
  62. package/generated/L1-validations/utils/validation-utils.ts +0 -116
  63. package/generated-structure/api-tests/search.ts +0 -24
  64. package/generated-structure/types/test-config.ts +0 -21
  65. package/samples/build.yaml +0 -24799
  66. package/samples/output.md +0 -91
  67. package/samples/output.ts +0 -27
  68. package/samples/selections.json +0 -216
  69. package/samples/validation-config.json +0 -3422
  70. package/samples/x-validations.yaml +0 -2893
  71. /package/{generated-structure/error.ts → dist/example.d.ts} +0 -0
  72. /package/{generated-structure/index.ts → dist/generator/generators/python/py-generator.d.ts} +0 -0
@@ -0,0 +1,6 @@
1
+ export declare const LOGICAL_OPERATORS: string[];
2
+ export declare const COMPARISON_OPERATORS: string[];
3
+ export declare const ARITHMETIC_OPERATORS: string[];
4
+ export declare const UNARY_OPERATORS: string[];
5
+ export declare const PREDEFINED_CONDITIONS: string[];
6
+ export declare const OPERATORS: string[];
@@ -0,0 +1,15 @@
1
+ export declare enum TestObjectSyntax {
2
+ Name = "_NAME_",
3
+ Return = "_RETURN_",
4
+ Scope = "_SCOPE_",
5
+ Continue = "_CONTINUE_",
6
+ ErrorCode = "_ERROR_CODE_",
7
+ SuccessCode = "_SUCCESS_CODE_"
8
+ }
9
+ export declare const ExternalDataSyntax = "_EXTERNAL";
10
+ export declare enum ConfigSyntax {
11
+ Tests = "_TESTS_",
12
+ SessionData = "_SESSION_DATA_"
13
+ }
14
+ export declare const ConfigKeyWords: (TestObjectSyntax | ConfigSyntax)[];
15
+ export declare const nodeReservedKeywords: Set<string>;
@@ -0,0 +1,23 @@
1
+ import { JSONSchema7 } from "json-schema";
2
+ import { BUILD_TYPE } from "../types/build.js";
3
+ import { ErrorDefinition } from "../types/error-codes.js";
4
+ import { ValidationConfig } from "../types/config-types.js";
5
+ import { SupportedLanguages } from "../types/compiler-types.js";
6
+ type CodeGeneratorConfig = {
7
+ removeRequiredfromSchema: boolean;
8
+ removeEnumsfromSchema: boolean;
9
+ };
10
+ export declare class ConfigCompiler {
11
+ buildData: BUILD_TYPE | undefined;
12
+ jsonSchemas: Record<string, JSONSchema7> | undefined;
13
+ possibleJsonPaths: Record<string, string[]> | undefined;
14
+ errorDefinitions: ErrorDefinition[] | undefined;
15
+ language: SupportedLanguages;
16
+ private SchemaExtactionService;
17
+ constructor(language: SupportedLanguages);
18
+ initialize: (buildYaml: string, generatorConfig?: Partial<CodeGeneratorConfig>) => Promise<void>;
19
+ performValidations: (valConfig: ValidationConfig) => Promise<void>;
20
+ generateCode: (valConfig: ValidationConfig) => Promise<void>;
21
+ generateL0Schema: () => Promise<void>;
22
+ }
23
+ export {};
@@ -0,0 +1,11 @@
1
+ import { ValidationConfig } from "../../../types/config-types";
2
+ import { ErrorDefinition } from "../../../types/error-codes";
3
+ export declare abstract class CodeGenerator {
4
+ validationConfig: ValidationConfig;
5
+ rootPath: string;
6
+ errorCodes: ErrorDefinition[];
7
+ constructor(validationConfig: ValidationConfig, errorCodes: ErrorDefinition[], rootPath?: string);
8
+ abstract generateSessionDataCode(): Promise<void>;
9
+ abstract generateValidationCode(): Promise<void>;
10
+ abstract generateCode(): Promise<void>;
11
+ }
@@ -0,0 +1,2 @@
1
+ import { TestObject } from "../../../types/config-types.js";
2
+ export declare function markdownMessageGenerator(returnInput: string, variableValues: TestObject, startingPointer: string, skipInput?: string[]): string;
@@ -0,0 +1,9 @@
1
+ import { TestObject } from "../../../types/config-types.js";
2
+ import { CodeGenerator } from "../classes/abstract-generator.js";
3
+ export declare class MarkdownDocGenerator extends CodeGenerator {
4
+ generateSessionDataCode(): Promise<void>;
5
+ generateValidationCode: () => Promise<void>;
6
+ generateCode: () => Promise<void>;
7
+ generateMarkdownForTest: (testObject: TestObject) => string;
8
+ generateHtmlCode: (markdownData: string) => Promise<string>;
9
+ }
@@ -0,0 +1,5 @@
1
+ declare function getJsonPath(payload: any, path: string): any[];
2
+ declare const _default: {
3
+ getJsonPath: typeof getJsonPath;
4
+ };
5
+ export default _default;
@@ -0,0 +1,21 @@
1
+ declare function areUnique(operand: string[]): boolean;
2
+ declare function arePresent(operand: string[]): boolean;
3
+ declare function allIn(left: string[], right: string[]): boolean;
4
+ declare function anyIn(left: string[], right: string[]): boolean;
5
+ declare function noneIn(left: string[], right: string[]): boolean;
6
+ declare function equalTo(left: string[], right: string[]): boolean;
7
+ declare function greaterThan(left: string[], right: string[]): boolean;
8
+ declare function lessThan(left: string[], right: string[]): boolean;
9
+ declare function followRegex(left: string[], regexArray: string[]): boolean;
10
+ declare const _default: {
11
+ areUnique: typeof areUnique;
12
+ arePresent: typeof arePresent;
13
+ allIn: typeof allIn;
14
+ anyIn: typeof anyIn;
15
+ noneIn: typeof noneIn;
16
+ equalTo: typeof equalTo;
17
+ followRegex: typeof followRegex;
18
+ greaterThan: typeof greaterThan;
19
+ lessThan: typeof lessThan;
20
+ };
21
+ export default _default;
@@ -0,0 +1 @@
1
+ export declare const compileInputToTs: (input: string) => string;
@@ -0,0 +1,17 @@
1
+ import { TestObject } from "../../../types/config-types.js";
2
+ import { CodeGenerator } from "../classes/abstract-generator.js";
3
+ export declare class TypescriptGenerator extends CodeGenerator {
4
+ generateSessionDataCode: () => Promise<never>;
5
+ generateValidationCode: () => Promise<void>;
6
+ generateCode: () => Promise<void>;
7
+ generateTestFunction: (testObject: TestObject) => Promise<{
8
+ funcName: string;
9
+ code: string;
10
+ }>;
11
+ private CreateErrorMarkdown;
12
+ private createVariablesCode;
13
+ private createValidationLogicCode;
14
+ private generateErrorFile;
15
+ private getExternalKeys;
16
+ private generateIndexFile;
17
+ }
@@ -0,0 +1,17 @@
1
+ import { TestObject } from "../../types/config-types";
2
+ import { ErrorDefinition } from "../../types/error-codes";
3
+ export interface IValidator {
4
+ validationPath: string;
5
+ validate(): Promise<void>;
6
+ }
7
+ export declare abstract class TestObjectValidator implements IValidator {
8
+ targetObject: TestObject;
9
+ validationPath: string;
10
+ abstract validate(): Promise<void>;
11
+ constructor(testObject: TestObject, path: string);
12
+ }
13
+ export interface TestsValidatorDependencies {
14
+ stringJsonPaths: string[];
15
+ errorDefinitions: ErrorDefinition[];
16
+ externalVariables: string[];
17
+ }
@@ -0,0 +1,11 @@
1
+ import { ValidationConfig } from "../../types/config-types.js";
2
+ import { ErrorDefinition } from "../../types/error-codes.js";
3
+ import { IValidator } from "./abstract-validator.js";
4
+ export declare class ConfigValidator implements IValidator {
5
+ validationPath: string;
6
+ config: ValidationConfig;
7
+ stringJsonPaths: Record<string, string[]>;
8
+ errorDefinitions: ErrorDefinition[];
9
+ constructor(validationPath: string, config: ValidationConfig, stringJsonPaths: Record<string, string[]>, errorDefinitions: ErrorDefinition[]);
10
+ validate: () => Promise<void>;
11
+ }
@@ -0,0 +1,9 @@
1
+ import { SessionDataApi } from "../../../types/config-types.js";
2
+ import { IValidator } from "../abstract-validator.js";
3
+ export declare class SessionDataValidator implements IValidator {
4
+ validationPath: string;
5
+ sessionData: Record<string, SessionDataApi>;
6
+ constructor(validtionPath: string, sessionData: Record<string, SessionDataApi>);
7
+ validate: () => Promise<void>;
8
+ private validateSessionData;
9
+ }
@@ -0,0 +1,38 @@
1
+ import { TestObject } from "../../../types/config-types.js";
2
+ import { ErrorDefinition } from "../../../types/error-codes.js";
3
+ import { TestObjectValidator, TestsValidatorDependencies } from "../abstract-validator.js";
4
+ export declare class RequiredFieldsValidator extends TestObjectValidator {
5
+ validate: () => Promise<void>;
6
+ }
7
+ export declare class NameValidator extends TestObjectValidator {
8
+ validate: () => Promise<void>;
9
+ }
10
+ export declare class ScopeValidator extends TestObjectValidator {
11
+ impossiblePaths: string[];
12
+ constructor(testObject: TestObject, path: string, impossiblePaths: string[]);
13
+ validate: () => Promise<void>;
14
+ }
15
+ export declare class ErrorCodeValidator extends TestObjectValidator {
16
+ possibleErrorCodes: ErrorDefinition[];
17
+ constructor(testObject: TestObject, path: string, possibleErrorCodes: ErrorDefinition[]);
18
+ validate: () => Promise<void>;
19
+ }
20
+ export declare class VariableValidator extends TestObjectValidator {
21
+ possibleJsonPaths: string[];
22
+ externalVariables: string[];
23
+ constructor(testObject: TestObject, path: string, posibleJsonPaths: string[], externalVariables: string[]);
24
+ validate: () => Promise<void>;
25
+ validateKey(key: string): void;
26
+ validateExternalData(path: string, definedExternalValues: string[]): void;
27
+ }
28
+ export declare class ContinueValidator extends TestObjectValidator {
29
+ definedVariables: string[];
30
+ constructor(testObject: TestObject, path: string);
31
+ validate: () => Promise<void>;
32
+ }
33
+ export declare class ReturnValidator extends TestObjectValidator {
34
+ definedVariables: string[];
35
+ dependencies: TestsValidatorDependencies;
36
+ constructor(testObject: TestObject, path: string, dependencies: TestsValidatorDependencies);
37
+ validate: () => Promise<void>;
38
+ }
@@ -0,0 +1,10 @@
1
+ import { TestObject } from "../../../types/config-types.js";
2
+ import { IValidator, TestsValidatorDependencies } from "../abstract-validator.js";
3
+ export declare class TestsValidator implements IValidator {
4
+ tests: TestObject[];
5
+ validationPath: string;
6
+ dependencies: TestsValidatorDependencies;
7
+ constructor(tests: TestObject[], configPath: string, dependencies: TestsValidatorDependencies);
8
+ validate: () => Promise<void>;
9
+ validateDuplicateNames: () => void;
10
+ }
@@ -0,0 +1,7 @@
1
+ import { TestObject } from "../../../types/config-types.js";
2
+ import { TestObjectValidator, TestsValidatorDependencies } from "../abstract-validator.js";
3
+ export declare class CompleteTestObjectValidator extends TestObjectValidator {
4
+ dependencies: TestsValidatorDependencies;
5
+ constructor(testObject: TestObject, path: string, dependencies: TestsValidatorDependencies);
6
+ validate: () => Promise<void>;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.js CHANGED
@@ -1,2 +1,40 @@
1
+ import { readFileSync } from "fs";
2
+ import path from "path";
3
+ import { fileURLToPath } from "url";
4
+ import { SupportedLanguages } from "./types/compiler-types.js";
1
5
  import { ConfigCompiler } from "./generator/config-compiler.js";
2
- export { ConfigCompiler };
6
+ // Get __dirname equivalent
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+ const main = async () => {
10
+ const compiler = new ConfigCompiler(SupportedLanguages.Typescript);
11
+ const buildPath = path.resolve(__dirname, "../samples/build.yaml");
12
+ const valConfigPath = path.resolve(__dirname, "../samples/validation-config.json");
13
+ const buildYaml = readFileSync(buildPath, "utf-8");
14
+ const valConfig = JSON.parse(readFileSync(valConfigPath, "utf-8"));
15
+ await compiler.initialize(buildYaml);
16
+ await compiler.generateCode(valConfig);
17
+ // await compiler.generateL0Schema();
18
+ // await compiler.performValidations(valConfig);
19
+ // const inputs = [
20
+ // "a are unique && b are unique",
21
+ // "a are unique",
22
+ // "(a are unique && b are unique) || c are unique",
23
+ // "a are unique && b are unique || c are unique",
24
+ // "a are unique && (b are unique || c are unique)",
25
+ // "a are unique && b are unique && c are unique && d are unique",
26
+ // "a are unique && !(b are unique || !(c are unique))",
27
+ // "a are unique && (b are unique || !(!(c are unique))) && !(d are unique)",
28
+ // ];
29
+ // let output = "";
30
+ // for (const input of inputs) {
31
+ // const cst = parseReturnInput(input);
32
+ // const ast = buildAst(cst);
33
+ // const out = CompileToMarkdown(ast, "A", 0, false);
34
+ // output += `\n## ${input}\n\n${out}\n`;
35
+ // }
36
+ // writeFileSync(path.resolve(__dirname, "../samples/output.md"), output);
37
+ };
38
+ (async () => {
39
+ await main();
40
+ })();
@@ -0,0 +1,2 @@
1
+ import { AstNode } from "../ast.js";
2
+ export declare function CompileToMarkdown(ast: AstNode, pointer: string, depth: number | undefined, forNot: boolean): string;
@@ -0,0 +1,2 @@
1
+ import { AstNode } from "../ast";
2
+ export declare function checkValidVariables(ast: AstNode, validVariables: string[], path?: string): void;
@@ -0,0 +1,42 @@
1
+ import { CstNode } from "chevrotain";
2
+ export interface AstNode {
3
+ type: "returnStatement" | "binaryOperator" | "notOperator" | "customBinaryFunction" | "customUniaryFunction" | "identifier";
4
+ }
5
+ export interface ReturnStatementNode extends AstNode {
6
+ expression: AstNode;
7
+ }
8
+ export interface BinaryOperatorNode extends AstNode {
9
+ operator: "&&" | "||";
10
+ lhs: AstNode;
11
+ rhs: AstNode;
12
+ }
13
+ export interface NotOperatorNode extends AstNode {
14
+ operator: "!";
15
+ expression: AstNode;
16
+ }
17
+ export interface CustomBinaryFunction extends AstNode {
18
+ customFunction: string;
19
+ lhs: IdentifierNode;
20
+ rhs: IdentifierNode;
21
+ }
22
+ export interface CustomUniaryFunction extends AstNode {
23
+ customFunction: string;
24
+ expression: IdentifierNode;
25
+ }
26
+ export interface IdentifierNode extends AstNode {
27
+ name: string;
28
+ }
29
+ declare const AstBuilder_base: new (...args: any[]) => import("chevrotain").ICstVisitor<any, any>;
30
+ export declare class AstBuilder extends AstBuilder_base {
31
+ constructor();
32
+ returnStatement(ctx: any): ReturnStatementNode;
33
+ orExpression(ctx: any): BinaryOperatorNode | AstNode;
34
+ andExpression(ctx: any): BinaryOperatorNode | AstNode;
35
+ notExpression(ctx: any): NotOperatorNode | AstNode;
36
+ primaryExpression(ctx: any): ReturnStatementNode | CustomBinaryFunction | CustomUniaryFunction;
37
+ parentheisizedExpression(ctx: any): ReturnStatementNode;
38
+ atomicCustomExpression(ctx: any): CustomBinaryFunction | CustomUniaryFunction;
39
+ visitIdentifier(token: any): IdentifierNode;
40
+ }
41
+ export declare function buildAst(cst: CstNode): AstNode;
42
+ export {};
@@ -0,0 +1,2 @@
1
+ import { AstNode } from "./ast.js";
2
+ export declare function buildAstFromInput(input: string): AstNode;
@@ -0,0 +1,14 @@
1
+ import { CstNode, CstParser } from "chevrotain";
2
+ declare class ReturnParser extends CstParser {
3
+ returnStatement: () => CstNode;
4
+ orExpression: () => CstNode;
5
+ andExpression: () => CstNode;
6
+ notExpression: () => CstNode;
7
+ primaryExpression: () => CstNode;
8
+ atomicCustomExpression: () => CstNode;
9
+ parentheisizedExpression: () => CstNode;
10
+ constructor();
11
+ }
12
+ export declare const ReturnParserInstance: ReturnParser;
13
+ export declare function parseReturnInput(inputText: string): CstNode;
14
+ export {};
@@ -0,0 +1,22 @@
1
+ import { ILexingResult } from "chevrotain";
2
+ export declare const Identifier: import("chevrotain").TokenType;
3
+ export declare const CustomBinaryFunctions: import("chevrotain").TokenType;
4
+ export declare const CustomUniaryFunctions: import("chevrotain").TokenType;
5
+ export declare const AllIn: import("chevrotain").TokenType;
6
+ export declare const AnyIn: import("chevrotain").TokenType;
7
+ export declare const AreUnique: import("chevrotain").TokenType;
8
+ export declare const ArePresent: import("chevrotain").TokenType;
9
+ export declare const FollowRegex: import("chevrotain").TokenType;
10
+ export declare const NoneIn: import("chevrotain").TokenType;
11
+ export declare const EqualTo: import("chevrotain").TokenType;
12
+ export declare const GreaterThan: import("chevrotain").TokenType;
13
+ export declare const LessThan: import("chevrotain").TokenType;
14
+ export declare const WhiteSpace: import("chevrotain").TokenType;
15
+ export declare const LParen: import("chevrotain").TokenType;
16
+ export declare const RParen: import("chevrotain").TokenType;
17
+ export declare const BinaryOperator: import("chevrotain").TokenType;
18
+ export declare const AndOperator: import("chevrotain").TokenType;
19
+ export declare const OrOperator: import("chevrotain").TokenType;
20
+ export declare const NotOperator: import("chevrotain").TokenType;
21
+ export declare const allTokens: import("chevrotain").TokenType[];
22
+ export declare function ReturnTokenize(inputText: string): ILexingResult;
@@ -0,0 +1,6 @@
1
+ import { JSONSchema7 } from "json-schema";
2
+ import { BUILD_TYPE } from "../types/build.js";
3
+ export declare class SchemaExtactionService {
4
+ extractSchemas: (data: BUILD_TYPE, removeRequired: boolean, removeEnums: boolean) => Promise<Record<string, JSONSchema7>>;
5
+ extractPossiblePaths: (schemas: Record<string, JSONSchema7>) => Record<string, string[]>;
6
+ }
@@ -0,0 +1,48 @@
1
+ import { ErrorDefinition } from "./error-codes";
2
+ export interface Xattributes {
3
+ [key: string]: AttributeSet;
4
+ }
5
+ export interface AttributeSet {
6
+ attribute_set: AttributeSection;
7
+ }
8
+ export interface Attribute {
9
+ required?: string;
10
+ usage?: any;
11
+ description?: string;
12
+ owner?: string;
13
+ type?: string;
14
+ }
15
+ export interface AttributeSection {
16
+ [key: string]: Attribute | AttributeSection;
17
+ }
18
+ export type BuildPath = {
19
+ [key: string]: {
20
+ post: {
21
+ description: string;
22
+ requestBody: {
23
+ content: {
24
+ "application/json": {
25
+ schema: any;
26
+ };
27
+ };
28
+ };
29
+ responses: {
30
+ default: {
31
+ content: {
32
+ "application/json": {
33
+ schema: any;
34
+ };
35
+ };
36
+ };
37
+ };
38
+ };
39
+ };
40
+ };
41
+ export interface BUILD_TYPE {
42
+ paths: BuildPath;
43
+ "x-enum": any;
44
+ "x-attributes": Xattributes;
45
+ "x-errorcodes": {
46
+ code: ErrorDefinition[];
47
+ };
48
+ }
@@ -0,0 +1,3 @@
1
+ export declare enum SupportedLanguages {
2
+ Typescript = "typescript"
3
+ }
@@ -0,0 +1,21 @@
1
+ import { ConfigSyntax, TestObjectSyntax } from "../constants/syntax.js";
2
+ import { Primitive } from "./general-types.js";
3
+ export type TestObject = {
4
+ [TestObjectSyntax.Name]: string;
5
+ [TestObjectSyntax.Return]: string | TestObject[];
6
+ [TestObjectSyntax.Scope]?: string;
7
+ [TestObjectSyntax.ErrorCode]?: number;
8
+ [TestObjectSyntax.SuccessCode]?: number;
9
+ [TestObjectSyntax.Continue]?: string;
10
+ [key: string]: ConfigVariable | number | TestObject[] | undefined;
11
+ };
12
+ export type ConfigVariable = string | Primitive[];
13
+ export type TestArray = TestObject[];
14
+ export type SessionDataValue = string | Primitive[] | null;
15
+ export type SessionDataApi = {
16
+ [key: string]: SessionDataValue;
17
+ };
18
+ export type ValidationConfig = {
19
+ [ConfigSyntax.Tests]: Record<string, TestArray>;
20
+ [ConfigSyntax.SessionData]: Record<string, SessionDataApi>;
21
+ };
@@ -0,0 +1,6 @@
1
+ export type ErrorDefinition = {
2
+ code: number;
3
+ Description: string;
4
+ From?: string;
5
+ Event?: string;
6
+ };
@@ -0,0 +1,2 @@
1
+ export type Primitive = number | string | boolean | null;
2
+ export type ValidVariableLine = string | Primitive[];
@@ -0,0 +1,7 @@
1
+ import { JSONSchema7 } from "json-schema";
2
+ /**
3
+ * Recursively removes all "required" and "enum" properties from a JSON Schema.
4
+ * @param schema - The JSON Schema object to process.
5
+ * @returns A new JSON Schema object with "required" and "enum" properties removed.
6
+ */
7
+ export declare function removeRequiredAndEnum(schema: JSONSchema7 | boolean, removeEnums?: boolean, removeRequired?: boolean): JSONSchema7 | boolean;
@@ -0,0 +1 @@
1
+ export declare function loadAndDereferenceYaml<T>(yamlData: string): Promise<T>;
@@ -0,0 +1,3 @@
1
+ export declare function writeFileWithFsExtra(rootPath: string, relativeFilePath: string, content: string): void;
2
+ export declare function formatCode(code: string, lang: string): Promise<string>;
3
+ export declare function writeAndFormatCode(rootPath: string, relativeFilePath: string, content: string, lang: string): Promise<void>;
@@ -0,0 +1,27 @@
1
+ import { TestObject } from "../../types/config-types.js";
2
+ /**
3
+ * Check if the string matches the pattern: lowercase letters and underscores only, no leading or trailing underscores
4
+ *
5
+ * @param str
6
+ * @returns true if the string is in snake_case, false otherwise
7
+ */
8
+ export declare function isSnakeCase(str: string): boolean;
9
+ export declare function isValidVariableName(input: string): boolean;
10
+ /**
11
+ * Adds '>' at the beginning of each line in the given Markdown string.
12
+ *
13
+ * @param {string} markdown - The input Markdown string.
14
+ * @returns {string} - The modified Markdown string with '>' added to each line.
15
+ */
16
+ export declare function addBlockquoteToMarkdown(markdown: string): string;
17
+ export declare function ConvertArrayToStringsInTestObject(testObject: TestObject): {
18
+ [x: string]: number | TestObject[] | import("../../types/config-types.js").ConfigVariable | undefined;
19
+ _NAME_: string;
20
+ _RETURN_: string | TestObject[];
21
+ _SCOPE_?: string;
22
+ _ERROR_CODE_?: number;
23
+ _SUCCESS_CODE_?: number;
24
+ _CONTINUE_?: string;
25
+ };
26
+ export declare function ConvertArrayToString(arr: any[]): string;
27
+ export declare function addTabToMarkdown(markdown: string): string;
@@ -0,0 +1,2 @@
1
+ import { TestObject } from "../../types/config-types.js";
2
+ export declare function getVariablesFromTest(testObject: TestObject): string[];
@@ -0,0 +1,5 @@
1
+ import { SessionDataApi } from "../../types/config-types.js";
2
+ import { Primitive, ValidVariableLine } from "../../types/general-types.js";
3
+ export declare function isPrimitive(value: unknown): value is Primitive;
4
+ export declare function isValidVariableValueType(line: any): line is ValidVariableLine;
5
+ export declare function getExternalVariables(sessionData: Record<string, SessionDataApi>): string[];
@@ -0,0 +1,8 @@
1
+ import { JSONSchema7 } from "json-schema";
2
+ /**
3
+ * Extracts all possible JSON paths from a given JSON Schema Draft-07.
4
+ *
5
+ * @param schema - The JSON Schema Draft-07 object.
6
+ * @returns An array of JSON paths as strings.
7
+ */
8
+ export declare function getAllJsonPaths(schema: JSONSchema7): string[];
@@ -0,0 +1,9 @@
1
+ export declare function isValidJsonPath(jsonPath: string): boolean;
2
+ /**
3
+ * Replaces all content inside square brackets in a JSONPath with an asterisk '*',
4
+ * handling nested brackets if they occur.
5
+ *
6
+ * @param jsonPath - The JSONPath string to transform.
7
+ * @returns The transformed JSONPath string with contents inside brackets replaced by '*'.
8
+ */
9
+ export declare function replaceBracketsWithAsteriskNested(jsonPath: string): string;
@@ -0,0 +1,3 @@
1
+ import winston from "winston";
2
+ declare const logger: winston.Logger;
3
+ export default logger;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "ondc-code-generator",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "generate code from build.yaml ",
5
5
  "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
6
+ "type": "module",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
9
  "start": "node ./dist/index.js",