@luvio/compiler 0.78.0 → 0.82.1
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/dist/codegen/adapter/adapter-network-cache-policy.js +5 -1
- package/dist/codegen/adapter/adapter-network-cache-policy.js.map +1 -1
- package/dist/codegen/adapter/adapter-param-type-check.js +2 -1
- package/dist/codegen/adapter/adapter-param-type-check.js.map +1 -1
- package/dist/codegen/adapter/index.d.ts +4 -0
- package/dist/codegen/adapter/index.js +5 -1
- package/dist/codegen/adapter/index.js.map +1 -1
- package/dist/codegen/adapter-tests/index.js +1 -1
- package/dist/codegen/adapter-tests/index.js.map +1 -1
- package/dist/codegen/graphql/enum/index.d.ts +2 -2
- package/dist/codegen/graphql/enum/index.js +6 -5
- package/dist/codegen/graphql/enum/index.js.map +1 -1
- package/dist/codegen/graphql/enum/interface.d.ts +4 -0
- package/dist/codegen/graphql/enum/interface.js +32 -0
- package/dist/codegen/graphql/enum/interface.js.map +1 -0
- package/dist/codegen/graphql/source-printer/graphql-adapter-source-printer.d.ts +7 -0
- package/dist/codegen/graphql/source-printer/graphql-adapter-source-printer.js +11 -0
- package/dist/codegen/graphql/source-printer/graphql-adapter-source-printer.js.map +1 -0
- package/dist/codegen/graphql/source-printer/graphql-resource-source-printer.d.ts +7 -0
- package/dist/codegen/graphql/source-printer/graphql-resource-source-printer.js +11 -0
- package/dist/codegen/graphql/source-printer/graphql-resource-source-printer.js.map +1 -0
- package/dist/codegen/graphql/source-printer/graphql-source-printer.d.ts +27 -0
- package/dist/codegen/graphql/source-printer/graphql-source-printer.js +50 -0
- package/dist/codegen/graphql/source-printer/graphql-source-printer.js.map +1 -0
- package/dist/codegen/graphql/source-printer/graphql-type-source-printer.d.ts +13 -0
- package/dist/codegen/graphql/source-printer/graphql-type-source-printer.js +65 -0
- package/dist/codegen/graphql/source-printer/graphql-type-source-printer.js.map +1 -0
- package/dist/codegen/graphql/source-printer/index.d.ts +5 -0
- package/dist/codegen/graphql/source-printer/index.js +12 -0
- package/dist/codegen/graphql/source-printer/index.js.map +1 -0
- package/dist/codegen/graphql/type/constants.d.ts +7 -0
- package/dist/codegen/graphql/type/constants.js +11 -0
- package/dist/codegen/graphql/type/constants.js.map +1 -0
- package/dist/codegen/graphql/type/index.d.ts +3 -2
- package/dist/codegen/graphql/type/index.js +30 -5
- package/dist/codegen/graphql/type/index.js.map +1 -1
- package/dist/codegen/graphql/type/ingest.d.ts +9 -0
- package/dist/codegen/graphql/type/ingest.js +131 -0
- package/dist/codegen/graphql/type/ingest.js.map +1 -0
- package/dist/codegen/graphql/type/interface.d.ts +3 -3
- package/dist/codegen/graphql/type/interface.js +2 -48
- package/dist/codegen/graphql/type/interface.js.map +1 -1
- package/dist/codegen/graphql/union/index.d.ts +2 -2
- package/dist/codegen/graphql/union/index.js +6 -5
- package/dist/codegen/graphql/union/index.js.map +1 -1
- package/dist/codegen/graphql/union/interface.d.ts +4 -0
- package/dist/codegen/graphql/union/interface.js +30 -0
- package/dist/codegen/graphql/union/interface.js.map +1 -0
- package/dist/codegen/graphql/utils/index.d.ts +1 -0
- package/dist/codegen/graphql/utils/index.js +8 -0
- package/dist/codegen/graphql/utils/index.js.map +1 -0
- package/dist/codegen/graphql/utils/types.d.ts +10 -0
- package/dist/codegen/graphql/utils/types.js +45 -0
- package/dist/codegen/graphql/utils/types.js.map +1 -0
- package/dist/codegen/resource/create-resource-request.js +2 -2
- package/dist/codegen/resource/create-resource-request.js.map +1 -1
- package/dist/codegen/rest/source-printer/rest-adapter-source-printer.d.ts +12 -0
- package/dist/codegen/rest/source-printer/rest-adapter-source-printer.js +60 -0
- package/dist/codegen/rest/source-printer/rest-adapter-source-printer.js.map +1 -0
- package/dist/codegen/rest/source-printer/rest-source-printer.d.ts +12 -0
- package/dist/codegen/rest/source-printer/rest-source-printer.js +78 -0
- package/dist/codegen/rest/source-printer/rest-source-printer.js.map +1 -0
- package/dist/codegen/source-writer/file-system-source-writer.d.ts +14 -0
- package/dist/codegen/source-writer/file-system-source-writer.js +31 -0
- package/dist/codegen/source-writer/file-system-source-writer.js.map +1 -0
- package/dist/compiler/raml-compiler.d.ts +15 -0
- package/dist/compiler/raml-compiler.js +34 -0
- package/dist/compiler/raml-compiler.js.map +1 -0
- package/dist/generate.d.ts +3 -5
- package/dist/generate.js +0 -134
- package/dist/generate.js.map +1 -1
- package/dist/interfaces/compiler.d.ts +4 -0
- package/dist/interfaces/compiler.js +3 -0
- package/dist/interfaces/compiler.js.map +1 -0
- package/dist/interfaces/index.d.ts +5 -0
- package/dist/interfaces/index.js +3 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/source-printers/graphql/graphql-adapter-printer.d.ts +6 -0
- package/dist/interfaces/source-printers/graphql/graphql-adapter-printer.js +3 -0
- package/dist/interfaces/source-printers/graphql/graphql-adapter-printer.js.map +1 -0
- package/dist/interfaces/source-printers/graphql/graphql-resource-printer.d.ts +6 -0
- package/dist/interfaces/source-printers/graphql/graphql-resource-printer.js +3 -0
- package/dist/interfaces/source-printers/graphql/graphql-resource-printer.js.map +1 -0
- package/dist/interfaces/source-printers/graphql/graphql-type-printer.d.ts +6 -0
- package/dist/interfaces/source-printers/graphql/graphql-type-printer.js +3 -0
- package/dist/interfaces/source-printers/graphql/graphql-type-printer.js.map +1 -0
- package/dist/interfaces/source-printers/index.d.ts +5 -0
- package/dist/interfaces/source-printers/index.js +3 -0
- package/dist/interfaces/source-printers/index.js.map +1 -0
- package/dist/interfaces/source-printers/rest/rest-adapter-printer.d.ts +5 -0
- package/dist/interfaces/source-printers/rest/rest-adapter-printer.js +3 -0
- package/dist/interfaces/source-printers/rest/rest-adapter-printer.js.map +1 -0
- package/dist/interfaces/source-printers/source-printer.d.ts +6 -0
- package/dist/interfaces/source-printers/source-printer.js +3 -0
- package/dist/interfaces/source-printers/source-printer.js.map +1 -0
- package/dist/interfaces/source-writer.d.ts +6 -0
- package/dist/interfaces/source-writer.js +3 -0
- package/dist/interfaces/source-writer.js.map +1 -0
- package/dist/main.d.ts +8 -3
- package/dist/main.js +16 -5
- package/dist/main.js.map +1 -1
- package/dist/parser/main.d.ts +8 -1
- package/dist/parser/main.js +186 -180
- package/dist/parser/main.js.map +1 -1
- package/dist/utils/files.d.ts +0 -8
- package/dist/utils/files.js +1 -16
- package/dist/utils/files.js.map +1 -1
- package/dist/utils/generation.js +5 -5
- package/dist/utils/generation.js.map +1 -1
- package/dist/utils/imports.js +4 -3
- package/dist/utils/imports.js.map +1 -1
- package/package.json +4 -4
- package/dist/codegen/graphql/index.d.ts +0 -13
- package/dist/codegen/graphql/index.js +0 -87
- package/dist/codegen/graphql/index.js.map +0 -1
- package/dist/parse.d.ts +0 -2
- package/dist/parse.js +0 -14
- package/dist/parse.js.map +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CompilerSourceWriter } from '../../interfaces';
|
|
2
|
+
export declare class FileSystemSourceWriter implements CompilerSourceWriter {
|
|
3
|
+
outputDirectory: string;
|
|
4
|
+
constructor(outputDirectory: string);
|
|
5
|
+
writeModules(modules: {
|
|
6
|
+
[name: string]: string;
|
|
7
|
+
}): void;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param outputDir : Output directory path
|
|
11
|
+
* @param modules : Codegen modules, <relative path>: <string content>
|
|
12
|
+
*/
|
|
13
|
+
private writeModulesSync;
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FileSystemSourceWriter = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
class FileSystemSourceWriter {
|
|
10
|
+
constructor(outputDirectory) {
|
|
11
|
+
this.outputDirectory = outputDirectory;
|
|
12
|
+
}
|
|
13
|
+
writeModules(modules) {
|
|
14
|
+
this.writeModulesSync(this.outputDirectory, modules);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param outputDir : Output directory path
|
|
19
|
+
* @param modules : Codegen modules, <relative path>: <string content>
|
|
20
|
+
*/
|
|
21
|
+
writeModulesSync(outputDir, modules) {
|
|
22
|
+
for (const [relPath, code] of Object.entries(modules)) {
|
|
23
|
+
const fullPath = path_1.default.join(outputDir, relPath);
|
|
24
|
+
const moduleDir = path_1.default.dirname(fullPath);
|
|
25
|
+
fs_1.default.mkdirSync(moduleDir, { recursive: true });
|
|
26
|
+
fs_1.default.writeFileSync(fullPath, code);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.FileSystemSourceWriter = FileSystemSourceWriter;
|
|
31
|
+
//# sourceMappingURL=file-system-source-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-system-source-writer.js","sourceRoot":"","sources":["../../../src/codegen/source-writer/file-system-source-writer.ts"],"names":[],"mappings":";;;;;;AACA,gDAAwB;AACxB,4CAAoB;AAEpB,MAAa,sBAAsB;IAG/B,YAAY,eAAuB;QAC/B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IAC3C,CAAC;IAED,YAAY,CAAC,OAAmC;QAC5C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;IAED;;;;OAIG;IACK,gBAAgB,CAAC,SAAiB,EAAE,OAAmC;QAC3E,KAAK,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YACnD,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC/C,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAEzC,YAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC7C,YAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;SACpC;IACL,CAAC;CACJ;AAzBD,wDAyBC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CompilerEnvironment } from '../generate';
|
|
2
|
+
import type { Parser, SourcePrinter } from '../interfaces';
|
|
3
|
+
import type { CompilerConfig, LuvioCompiler, ParseError } from '../main';
|
|
4
|
+
export interface LuvioRamlCompilerConfig extends CompilerConfig {
|
|
5
|
+
parser: Parser;
|
|
6
|
+
}
|
|
7
|
+
export interface LuvioRamlCompilerEnvironment extends CompilerEnvironment {
|
|
8
|
+
config: LuvioRamlCompilerConfig;
|
|
9
|
+
}
|
|
10
|
+
export declare class LuvioRamlCompiler implements LuvioCompiler {
|
|
11
|
+
sourcePrinters: SourcePrinter[];
|
|
12
|
+
compilerEnvironment: LuvioRamlCompilerEnvironment;
|
|
13
|
+
constructor(compilerEnvironment: LuvioRamlCompilerEnvironment, sourcePrinters: SourcePrinter[]);
|
|
14
|
+
generate(): Promise<void | ParseError[]>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LuvioRamlCompiler = void 0;
|
|
4
|
+
const generation_1 = require("../utils/generation");
|
|
5
|
+
class LuvioRamlCompiler {
|
|
6
|
+
constructor(compilerEnvironment, sourcePrinters) {
|
|
7
|
+
this.compilerEnvironment = compilerEnvironment;
|
|
8
|
+
this.sourcePrinters = sourcePrinters;
|
|
9
|
+
}
|
|
10
|
+
async generate() {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const compilerConfig = this.compilerEnvironment.config;
|
|
13
|
+
const parser = compilerConfig.parser;
|
|
14
|
+
const { modelInfo, errors } = await parser.parse();
|
|
15
|
+
if (modelInfo === undefined) {
|
|
16
|
+
return Promise.resolve(errors);
|
|
17
|
+
}
|
|
18
|
+
if ((_a = this.compilerEnvironment.plugin) === null || _a === void 0 ? void 0 : _a.validate) {
|
|
19
|
+
const pluginResult = await this.compilerEnvironment.plugin.validate(modelInfo);
|
|
20
|
+
if (pluginResult.hasErrors === true) {
|
|
21
|
+
return Promise.resolve(pluginResult.errors);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
this.sourcePrinters.forEach((printer) => {
|
|
25
|
+
const generatedModules = printer.generateModules(modelInfo);
|
|
26
|
+
this.compilerEnvironment.config.sourceWriter.writeModules(generatedModules);
|
|
27
|
+
});
|
|
28
|
+
if ((_b = this.compilerEnvironment.plugin) === null || _b === void 0 ? void 0 : _b.afterGenerate) {
|
|
29
|
+
await this.compilerEnvironment.plugin.afterGenerate(compilerConfig, modelInfo, (0, generation_1.createCodeGenerationContext)(this.compilerEnvironment.plugin, compilerConfig));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.LuvioRamlCompiler = LuvioRamlCompiler;
|
|
34
|
+
//# sourceMappingURL=raml-compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raml-compiler.js","sourceRoot":"","sources":["../../src/compiler/raml-compiler.ts"],"names":[],"mappings":";;;AAGA,oDAAkE;AAUlE,MAAa,iBAAiB;IAI1B,YACI,mBAAiD,EACjD,cAA+B;QAE/B,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAC/C,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,QAAQ;;QACV,MAAM,cAAc,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC;QACvD,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC;QAErC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACnD,IAAI,SAAS,KAAK,SAAS,EAAE;YACzB,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAClC;QAED,IAAI,MAAA,IAAI,CAAC,mBAAmB,CAAC,MAAM,0CAAE,QAAQ,EAAE;YAC3C,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAE/E,IAAI,YAAY,CAAC,SAAS,KAAK,IAAI,EAAE;gBACjC,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;aAC/C;SACJ;QAED,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,MAAM,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;YAC5D,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;QAChF,CAAC,CAAC,CAAC;QAEH,IAAI,MAAA,IAAI,CAAC,mBAAmB,CAAC,MAAM,0CAAE,aAAa,EAAE;YAChD,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,aAAa,CAC/C,cAAc,EACd,SAAS,EACT,IAAA,wCAA2B,EAAC,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,cAAc,CAAC,CAC/E,CAAC;SACL;IACL,CAAC;CACJ;AA1CD,8CA0CC"}
|
package/dist/generate.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import type { ParseError } from './parser/logger';
|
|
2
|
+
import type path from 'path';
|
|
4
3
|
import type { CompilerPlugin } from './plugin';
|
|
4
|
+
import type { CompilerSourceWriter } from './interfaces';
|
|
5
5
|
export interface CompilerConfig {
|
|
6
|
-
|
|
7
|
-
outputDir: string;
|
|
6
|
+
sourceWriter: CompilerSourceWriter;
|
|
8
7
|
}
|
|
9
8
|
export interface CompilerEnvironment {
|
|
10
9
|
plugin?: CompilerPlugin;
|
|
@@ -14,4 +13,3 @@ export declare type CodeGenerationEnvironment = {
|
|
|
14
13
|
compiler: CompilerEnvironment;
|
|
15
14
|
output: path.ParsedPath;
|
|
16
15
|
};
|
|
17
|
-
export declare function generate(inputFile: string, outputDir: string, plugin?: CompilerPlugin): Promise<void | ParseError[]>;
|
package/dist/generate.js
CHANGED
|
@@ -1,137 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generate = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const adapter_1 = require("./codegen/adapter");
|
|
9
|
-
const adapter_utils_1 = require("./codegen/adapter-utils");
|
|
10
|
-
const resource_1 = require("./codegen/resource");
|
|
11
|
-
const shape_1 = require("./codegen/shape");
|
|
12
|
-
const adapter_tests_1 = require("./codegen/adapter-tests");
|
|
13
|
-
const utils_1 = require("./intermediate/utils");
|
|
14
|
-
const main_1 = require("./parser/main");
|
|
15
|
-
const imports_1 = require("./utils/imports");
|
|
16
|
-
const files_1 = require("./utils/files");
|
|
17
|
-
const generation_1 = require("./utils/generation");
|
|
18
|
-
const cursor_based_1 = require("./codegen/pagination-utils/cursor-based");
|
|
19
|
-
const synthetic_cursor_1 = require("./codegen/pagination-utils/synthetic-cursor");
|
|
20
|
-
const pagination_1 = require("./intermediate/pagination");
|
|
21
|
-
const index_1 = require("./codegen/graphql/index");
|
|
22
|
-
const RESOURCES_DIRECTORY_NAME = 'resources';
|
|
23
|
-
const TYPES_DIRECTORY_NAME = 'types';
|
|
24
|
-
const ADAPTERS_DIRECTORY_NAME = 'adapters';
|
|
25
|
-
const PAGINATION_DIRECTORY_NAME = 'pagination';
|
|
26
|
-
const GRAPHQL_DIRECTORY_NAME = 'graphql';
|
|
27
|
-
const DEFAULT_GRAPHQL_SCALAR_TO_PRIMITIVE_MAP = {
|
|
28
|
-
String: 'string',
|
|
29
|
-
ID: 'string',
|
|
30
|
-
Boolean: 'boolean',
|
|
31
|
-
Int: 'number',
|
|
32
|
-
Float: 'number',
|
|
33
|
-
};
|
|
34
|
-
function generateModules(env, modelInfo) {
|
|
35
|
-
const { config: compilerConfig, plugin } = env;
|
|
36
|
-
const { resources, declaredShapeDefinitions } = modelInfo;
|
|
37
|
-
const modules = {};
|
|
38
|
-
for (const resource of resources) {
|
|
39
|
-
if (resource.resourceType === 'GraphQL') {
|
|
40
|
-
const result = (0, index_1.generate)({
|
|
41
|
-
schema: resource.graphqlRepresentation.schema,
|
|
42
|
-
adapter: resource.adapter,
|
|
43
|
-
outDirName: GRAPHQL_DIRECTORY_NAME,
|
|
44
|
-
env,
|
|
45
|
-
scalarToPrimitiveMap: DEFAULT_GRAPHQL_SCALAR_TO_PRIMITIVE_MAP,
|
|
46
|
-
});
|
|
47
|
-
Object.keys(result).forEach((key) => {
|
|
48
|
-
modules[key] = result[key];
|
|
49
|
-
});
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
const resourceRelPath = `${RESOURCES_DIRECTORY_NAME}/${resource.name}.ts`;
|
|
53
|
-
const resourceAbsPath = path_1.default.resolve(compilerConfig.outputDir, resourceRelPath);
|
|
54
|
-
const resourceConfig = {
|
|
55
|
-
compiler: env,
|
|
56
|
-
output: path_1.default.parse(resourceAbsPath),
|
|
57
|
-
};
|
|
58
|
-
modules[resourceRelPath] = (0, resource_1.generateResource)(resourceConfig, resource, modelInfo, resourceRelPath);
|
|
59
|
-
// generate adapter factories for any resources with adapter annotation
|
|
60
|
-
const { adapter } = resource;
|
|
61
|
-
if (adapter !== undefined) {
|
|
62
|
-
const adapterRelPath = `${ADAPTERS_DIRECTORY_NAME}/${adapter.name}.ts`;
|
|
63
|
-
const adapterAbsPath = path_1.default.resolve(compilerConfig.outputDir, adapterRelPath);
|
|
64
|
-
const adapterConfig = {
|
|
65
|
-
compiler: env,
|
|
66
|
-
output: path_1.default.parse(adapterAbsPath),
|
|
67
|
-
};
|
|
68
|
-
modules[adapterRelPath] = (0, adapter_1.generateAdapter)(adapterConfig, adapter, resource, modelInfo);
|
|
69
|
-
// generate adapter tests as well
|
|
70
|
-
const testModules = (0, adapter_tests_1.generateAdapterTestModules)(compilerConfig, adapter, resource, ADAPTERS_DIRECTORY_NAME, plugin);
|
|
71
|
-
for (const key of Object.keys(testModules)) {
|
|
72
|
-
modules[key] = testModules[key];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
modules['adapters/adapter-utils.ts'] = (0, adapter_utils_1.generateAdapterUtils)(modelInfo);
|
|
77
|
-
for (const shape of Object.values(declaredShapeDefinitions)) {
|
|
78
|
-
if ((0, utils_1.isNodeShape)(shape)) {
|
|
79
|
-
const relPath = `${TYPES_DIRECTORY_NAME}/${shape.name}.ts`;
|
|
80
|
-
const shapeAbsPath = path_1.default.resolve(compilerConfig.outputDir, relPath);
|
|
81
|
-
const shapeConfig = {
|
|
82
|
-
shape,
|
|
83
|
-
modelInfo,
|
|
84
|
-
shapeLocation: relPath,
|
|
85
|
-
importContext: (0, imports_1.createImportContext)({
|
|
86
|
-
compiler: env,
|
|
87
|
-
output: path_1.default.parse(shapeAbsPath),
|
|
88
|
-
}),
|
|
89
|
-
};
|
|
90
|
-
modules[relPath] = (0, shape_1.generateModule)(shapeConfig);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
modules[`${TYPES_DIRECTORY_NAME}/type-utils.ts`] = (0, shape_1.generateTypeUtils)();
|
|
94
|
-
if (Object.keys(modelInfo.shapePaginated).length > 0) {
|
|
95
|
-
// Only cursor-based for now. When we support more strategies,
|
|
96
|
-
// collect declared pagination strategies, then generate needed utils
|
|
97
|
-
modules[`${PAGINATION_DIRECTORY_NAME}/cursor.ts`] = (0, cursor_based_1.generatePaginationUtils)();
|
|
98
|
-
const hasSyntheticCursor = Object.values(modelInfo.shapePaginated).find((shapePaginated) => {
|
|
99
|
-
return shapePaginated.strategy === pagination_1.Strategy.SyntheticCursor;
|
|
100
|
-
});
|
|
101
|
-
if (hasSyntheticCursor !== undefined) {
|
|
102
|
-
modules[`${PAGINATION_DIRECTORY_NAME}/syntheticCursor.ts`] =
|
|
103
|
-
(0, synthetic_cursor_1.generatePaginationUtils)();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return modules;
|
|
107
|
-
}
|
|
108
|
-
async function generate(inputFile, outputDir, plugin) {
|
|
109
|
-
var _a, _b;
|
|
110
|
-
const input = path_1.default.resolve(inputFile);
|
|
111
|
-
const output = path_1.default.resolve(outputDir);
|
|
112
|
-
const compilerConfig = {
|
|
113
|
-
input,
|
|
114
|
-
outputDir: output,
|
|
115
|
-
};
|
|
116
|
-
const { modelInfo, errors } = await (0, main_1.parse)(input);
|
|
117
|
-
if (modelInfo === undefined) {
|
|
118
|
-
return Promise.resolve(errors);
|
|
119
|
-
}
|
|
120
|
-
const env = {
|
|
121
|
-
plugin,
|
|
122
|
-
config: compilerConfig,
|
|
123
|
-
};
|
|
124
|
-
if ((_a = env.plugin) === null || _a === void 0 ? void 0 : _a.validate) {
|
|
125
|
-
const pluginResult = await env.plugin.validate(modelInfo);
|
|
126
|
-
if (pluginResult.hasErrors === true) {
|
|
127
|
-
return Promise.resolve(pluginResult.errors);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
const modules = generateModules(env, modelInfo);
|
|
131
|
-
(0, files_1.writeModulesSync)(output, modules);
|
|
132
|
-
if ((_b = env.plugin) === null || _b === void 0 ? void 0 : _b.afterGenerate) {
|
|
133
|
-
await env.plugin.afterGenerate(compilerConfig, modelInfo, (0, generation_1.createCodeGenerationContext)(env.plugin, compilerConfig));
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
exports.generate = generate;
|
|
137
3
|
//# sourceMappingURL=generate.js.map
|
package/dist/generate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../src/interfaces/compiler.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LuvioCompiler } from './compiler';
|
|
2
|
+
import { CompilerSourceWriter } from './source-writer';
|
|
3
|
+
import { Parser } from '../parser/main';
|
|
4
|
+
import { SourcePrinter, GraphQLTypePrinter, GraphQLAdapterPrinter, GraphQLResourcePrinter } from './source-printers';
|
|
5
|
+
export { LuvioCompiler, Parser, CompilerSourceWriter, SourcePrinter, GraphQLTypePrinter, GraphQLAdapterPrinter, GraphQLResourcePrinter, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GraphQLCodegenMetadata, GraphQLGenerateState } from '../../../codegen/graphql/source-printer/graphql-source-printer';
|
|
2
|
+
export interface GraphQLAdapterPrinter {
|
|
3
|
+
generate(state: GraphQLGenerateState, metadata: GraphQLCodegenMetadata): {
|
|
4
|
+
[path: string]: string;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-adapter-printer.js","sourceRoot":"","sources":["../../../../src/interfaces/source-printers/graphql/graphql-adapter-printer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GraphQLCodegenMetadata, GraphQLGenerateState } from '../../../codegen/graphql/source-printer/graphql-source-printer';
|
|
2
|
+
export interface GraphQLResourcePrinter {
|
|
3
|
+
generate(state: GraphQLGenerateState, metadata: GraphQLCodegenMetadata): {
|
|
4
|
+
[path: string]: string;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-resource-printer.js","sourceRoot":"","sources":["../../../../src/interfaces/source-printers/graphql/graphql-resource-printer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GraphQLGenerateState, GraphQLCodegenMetadata } from '../../../codegen/graphql/source-printer/graphql-source-printer';
|
|
2
|
+
export interface GraphQLTypePrinter {
|
|
3
|
+
generate(state: GraphQLGenerateState, metadata: GraphQLCodegenMetadata): {
|
|
4
|
+
[path: string]: string;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-type-printer.js","sourceRoot":"","sources":["../../../../src/interfaces/source-printers/graphql/graphql-type-printer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SourcePrinter } from './source-printer';
|
|
2
|
+
import { GraphQLTypePrinter } from './graphql/graphql-type-printer';
|
|
3
|
+
import { GraphQLAdapterPrinter } from './graphql/graphql-adapter-printer';
|
|
4
|
+
import { GraphQLResourcePrinter } from './graphql/graphql-resource-printer';
|
|
5
|
+
export { SourcePrinter, GraphQLTypePrinter, GraphQLAdapterPrinter, GraphQLResourcePrinter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/source-printers/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest-adapter-printer.js","sourceRoot":"","sources":["../../../../src/interfaces/source-printers/rest/rest-adapter-printer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-printer.js","sourceRoot":"","sources":["../../../src/interfaces/source-printers/source-printer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-writer.js","sourceRoot":"","sources":["../../src/interfaces/source-writer.ts"],"names":[],"mappings":""}
|
package/dist/main.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { parse } from './parse';
|
|
1
|
+
export { CompilerConfig } from './generate';
|
|
3
2
|
export { ParseError } from './parser/logger';
|
|
4
|
-
export { ParseResults } from './parser/main';
|
|
3
|
+
export { ParseResults, LuvioRamlFileParser } from './parser/main';
|
|
5
4
|
export { ModelInfo, ShapePrivate } from './intermediate/model-info';
|
|
6
5
|
export { ShapeTypes, ParameterDefinition, ShapeDefinition, PropertyShapeDefinition, NodeShapeDefinition, ArrayShapeDefinition, UnionShapeDefinition, ScalarShapeDefinition, } from './intermediate/definitions';
|
|
7
6
|
export { CompilerPlugin, PluginResult } from './plugin';
|
|
7
|
+
export { LuvioRamlCompiler, LuvioRamlCompilerEnvironment } from './compiler/raml-compiler';
|
|
8
|
+
export { CompilerSourceWriter, LuvioCompiler, Parser } from './interfaces';
|
|
9
|
+
export { FileSystemSourceWriter } from './codegen/source-writer/file-system-source-writer';
|
|
10
|
+
export { GraphQLSourcePrinter, GraphQLTypeSourcePrinter, GraphQLResourceSourcePrinter, GraphQLAdapterSourcePrinter, } from './codegen/graphql/source-printer';
|
|
11
|
+
export { RestSourcePrinter } from './codegen/rest/source-printer/rest-source-printer';
|
|
12
|
+
export { RestAdapterSourcePrinter } from './codegen/rest/source-printer/rest-adapter-source-printer';
|
package/dist/main.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
var parse_1 = require("./parse");
|
|
7
|
-
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parse_1.parse; } });
|
|
3
|
+
exports.RestAdapterSourcePrinter = exports.RestSourcePrinter = exports.GraphQLAdapterSourcePrinter = exports.GraphQLResourceSourcePrinter = exports.GraphQLTypeSourcePrinter = exports.GraphQLSourcePrinter = exports.FileSystemSourceWriter = exports.LuvioRamlCompiler = exports.ShapeTypes = exports.LuvioRamlFileParser = void 0;
|
|
4
|
+
var main_1 = require("./parser/main");
|
|
5
|
+
Object.defineProperty(exports, "LuvioRamlFileParser", { enumerable: true, get: function () { return main_1.LuvioRamlFileParser; } });
|
|
8
6
|
var definitions_1 = require("./intermediate/definitions");
|
|
9
7
|
Object.defineProperty(exports, "ShapeTypes", { enumerable: true, get: function () { return definitions_1.ShapeTypes; } });
|
|
8
|
+
var raml_compiler_1 = require("./compiler/raml-compiler");
|
|
9
|
+
Object.defineProperty(exports, "LuvioRamlCompiler", { enumerable: true, get: function () { return raml_compiler_1.LuvioRamlCompiler; } });
|
|
10
|
+
var file_system_source_writer_1 = require("./codegen/source-writer/file-system-source-writer");
|
|
11
|
+
Object.defineProperty(exports, "FileSystemSourceWriter", { enumerable: true, get: function () { return file_system_source_writer_1.FileSystemSourceWriter; } });
|
|
12
|
+
var source_printer_1 = require("./codegen/graphql/source-printer");
|
|
13
|
+
Object.defineProperty(exports, "GraphQLSourcePrinter", { enumerable: true, get: function () { return source_printer_1.GraphQLSourcePrinter; } });
|
|
14
|
+
Object.defineProperty(exports, "GraphQLTypeSourcePrinter", { enumerable: true, get: function () { return source_printer_1.GraphQLTypeSourcePrinter; } });
|
|
15
|
+
Object.defineProperty(exports, "GraphQLResourceSourcePrinter", { enumerable: true, get: function () { return source_printer_1.GraphQLResourceSourcePrinter; } });
|
|
16
|
+
Object.defineProperty(exports, "GraphQLAdapterSourcePrinter", { enumerable: true, get: function () { return source_printer_1.GraphQLAdapterSourcePrinter; } });
|
|
17
|
+
var rest_source_printer_1 = require("./codegen/rest/source-printer/rest-source-printer");
|
|
18
|
+
Object.defineProperty(exports, "RestSourcePrinter", { enumerable: true, get: function () { return rest_source_printer_1.RestSourcePrinter; } });
|
|
19
|
+
var rest_adapter_source_printer_1 = require("./codegen/rest/source-printer/rest-adapter-source-printer");
|
|
20
|
+
Object.defineProperty(exports, "RestAdapterSourcePrinter", { enumerable: true, get: function () { return rest_adapter_source_printer_1.RestAdapterSourcePrinter; } });
|
|
10
21
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;AAEA,sCAAkE;AAA3C,2GAAA,mBAAmB,OAAA;AAE1C,0DASoC;AARhC,yGAAA,UAAU,OAAA;AAUd,0DAA2F;AAAlF,kHAAA,iBAAiB,OAAA;AAE1B,+FAA2F;AAAlF,mIAAA,sBAAsB,OAAA;AAC/B,mEAK0C;AAJtC,sHAAA,oBAAoB,OAAA;AACpB,0HAAA,wBAAwB,OAAA;AACxB,8HAAA,4BAA4B,OAAA;AAC5B,6HAAA,2BAA2B,OAAA;AAE/B,yFAAsF;AAA7E,wHAAA,iBAAiB,OAAA;AAC1B,yGAAqG;AAA5F,uIAAA,wBAAwB,OAAA"}
|
package/dist/parser/main.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { model as amf } from 'amf-client-js';
|
|
2
2
|
import type { ModelInfo } from '../intermediate/model-info';
|
|
3
3
|
import type { ParseError } from './logger';
|
|
4
|
+
export interface Parser {
|
|
5
|
+
parse(): Promise<ParseResults>;
|
|
6
|
+
}
|
|
4
7
|
export declare type ShapeKeyFields = {
|
|
5
8
|
[key: string]: {
|
|
6
9
|
valuePath: string;
|
|
@@ -18,4 +21,8 @@ export declare type ParseResults = {
|
|
|
18
21
|
modelInfo: undefined;
|
|
19
22
|
errors: ParseError[];
|
|
20
23
|
};
|
|
21
|
-
export declare
|
|
24
|
+
export declare class LuvioRamlFileParser implements Parser {
|
|
25
|
+
private ramlPath;
|
|
26
|
+
constructor(ramlPath: string);
|
|
27
|
+
parse(): Promise<ParseResults>;
|
|
28
|
+
}
|