@luvio/compiler 0.82.1 → 0.85.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/dist/codegen/adapter/graphql/adapter-config-interface.d.ts +3 -0
- package/dist/codegen/adapter/graphql/adapter-config-interface.js +24 -0
- package/dist/codegen/adapter/graphql/adapter-config-interface.js.map +1 -0
- package/dist/codegen/adapter/graphql/index.d.ts +7 -0
- package/dist/codegen/adapter/graphql/index.js +54 -0
- package/dist/codegen/adapter/graphql/index.js.map +1 -0
- package/dist/codegen/adapter/index.d.ts +9 -7
- package/dist/codegen/adapter/index.js +10 -30
- package/dist/codegen/adapter/index.js.map +1 -1
- package/dist/codegen/adapter-tests/expected-responses.js +3 -3
- package/dist/codegen/adapter-tests/expected-responses.js.map +1 -1
- package/dist/codegen/adapter-tests/index.d.ts +3 -2
- package/dist/codegen/adapter-tests/index.js +3 -7
- 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 +2 -2
- package/dist/codegen/graphql/enum/index.js.map +1 -1
- package/dist/codegen/graphql/enum/interface.d.ts +2 -2
- package/dist/codegen/graphql/enum/interface.js +1 -1
- package/dist/codegen/graphql/enum/interface.js.map +1 -1
- package/dist/codegen/graphql/graphql-dsl.d.ts +13 -0
- package/dist/codegen/graphql/graphql-dsl.js +26 -0
- package/dist/codegen/graphql/graphql-dsl.js.map +1 -0
- package/dist/codegen/graphql/source-printer/graphql-adapter-source-printer.d.ts +8 -4
- package/dist/codegen/graphql/source-printer/graphql-adapter-source-printer.js +31 -3
- package/dist/codegen/graphql/source-printer/graphql-adapter-source-printer.js.map +1 -1
- package/dist/codegen/graphql/source-printer/graphql-resource-source-printer.d.ts +6 -2
- package/dist/codegen/graphql/source-printer/graphql-resource-source-printer.js +15 -3
- package/dist/codegen/graphql/source-printer/graphql-resource-source-printer.js.map +1 -1
- package/dist/codegen/graphql/source-printer/graphql-source-printer.d.ts +14 -17
- package/dist/codegen/graphql/source-printer/graphql-source-printer.js +17 -19
- package/dist/codegen/graphql/source-printer/graphql-source-printer.js.map +1 -1
- package/dist/codegen/graphql/source-printer/graphql-type-source-printer.d.ts +9 -3
- package/dist/codegen/graphql/source-printer/graphql-type-source-printer.js +37 -18
- package/dist/codegen/graphql/source-printer/graphql-type-source-printer.js.map +1 -1
- package/dist/codegen/graphql/source-printer/index.d.ts +2 -2
- package/dist/codegen/graphql/source-printer/index.js.map +1 -1
- package/dist/codegen/graphql/type/index.d.ts +5 -3
- package/dist/codegen/graphql/type/index.js +13 -5
- package/dist/codegen/graphql/type/index.js.map +1 -1
- package/dist/codegen/graphql/type/ingest.d.ts +5 -4
- package/dist/codegen/graphql/type/ingest.js +67 -27
- package/dist/codegen/graphql/type/ingest.js.map +1 -1
- package/dist/codegen/graphql/type/interface.d.ts +2 -2
- package/dist/codegen/graphql/type/interface.js +1 -1
- package/dist/codegen/graphql/type/interface.js.map +1 -1
- package/dist/codegen/graphql/type/ttl.d.ts +4 -0
- package/dist/codegen/graphql/type/ttl.js +18 -0
- package/dist/codegen/graphql/type/ttl.js.map +1 -0
- package/dist/codegen/graphql/union/index.d.ts +2 -2
- package/dist/codegen/graphql/union/index.js +2 -2
- package/dist/codegen/graphql/union/index.js.map +1 -1
- package/dist/codegen/graphql/union/interface.d.ts +2 -2
- package/dist/codegen/graphql/union/interface.js +1 -1
- package/dist/codegen/graphql/union/interface.js.map +1 -1
- package/dist/codegen/graphql/utils/index.d.ts +1 -1
- package/dist/codegen/graphql/utils/index.js +2 -1
- package/dist/codegen/graphql/utils/index.js.map +1 -1
- package/dist/codegen/graphql/utils/types.d.ts +9 -3
- package/dist/codegen/graphql/utils/types.js +13 -1
- package/dist/codegen/graphql/utils/types.js.map +1 -1
- package/dist/codegen/package-renderer/index.d.ts +2 -0
- package/dist/codegen/package-renderer/index.js +6 -0
- package/dist/codegen/package-renderer/index.js.map +1 -0
- package/dist/codegen/package-renderer/package-renderer.d.ts +16 -0
- package/dist/codegen/package-renderer/package-renderer.js +72 -0
- package/dist/codegen/package-renderer/package-renderer.js.map +1 -0
- package/dist/codegen/package-renderer/text-file.d.ts +6 -0
- package/dist/{generate.js → codegen/package-renderer/text-file.js} +1 -1
- package/dist/codegen/package-renderer/text-file.js.map +1 -0
- package/dist/codegen/resource/create-resource-request.d.ts +6 -2
- package/dist/codegen/resource/create-resource-request.js +11 -17
- package/dist/codegen/resource/create-resource-request.js.map +1 -1
- package/dist/codegen/resource/graphql/create-resource-request.d.ts +4 -0
- package/dist/codegen/resource/graphql/create-resource-request.js +30 -0
- package/dist/codegen/resource/graphql/create-resource-request.js.map +1 -0
- package/dist/codegen/resource/graphql/index.d.ts +6 -0
- package/dist/codegen/resource/graphql/index.js +30 -0
- package/dist/codegen/resource/graphql/index.js.map +1 -0
- package/dist/codegen/resource/graphql/ingest-error.d.ts +5 -0
- package/dist/codegen/resource/graphql/ingest-error.js +63 -0
- package/dist/codegen/resource/graphql/ingest-error.js.map +1 -0
- package/dist/codegen/resource/graphql/ingest-success.d.ts +4 -0
- package/dist/codegen/resource/graphql/ingest-success.js +56 -0
- package/dist/codegen/resource/graphql/ingest-success.js.map +1 -0
- package/dist/codegen/resource/graphql/key-builder.d.ts +3 -0
- package/dist/codegen/resource/graphql/key-builder.js +25 -0
- package/dist/codegen/resource/graphql/key-builder.js.map +1 -0
- package/dist/codegen/resource/graphql/resource-params.d.ts +4 -0
- package/dist/codegen/resource/graphql/resource-params.js +25 -0
- package/dist/codegen/resource/graphql/resource-params.js.map +1 -0
- package/dist/codegen/resource/graphql/response-cache-keys.d.ts +4 -0
- package/dist/codegen/resource/graphql/response-cache-keys.js +33 -0
- package/dist/codegen/resource/graphql/response-cache-keys.js.map +1 -0
- package/dist/codegen/resource/index.d.ts +5 -3
- package/dist/codegen/resource/index.js +5 -5
- package/dist/codegen/resource/index.js.map +1 -1
- package/dist/codegen/resource/ingest-error.d.ts +2 -2
- package/dist/codegen/resource/ingest-error.js.map +1 -1
- package/dist/codegen/resource/ingest-success.js +5 -3
- package/dist/codegen/resource/ingest-success.js.map +1 -1
- package/dist/codegen/resource/key-builder.d.ts +1 -0
- package/dist/codegen/resource/key-builder.js +2 -1
- package/dist/codegen/resource/key-builder.js.map +1 -1
- package/dist/codegen/resource/resource-params.d.ts +2 -2
- package/dist/codegen/resource/resource-params.js.map +1 -1
- package/dist/codegen/rest/source-printer/rest-adapter-source-printer.d.ts +7 -4
- package/dist/codegen/rest/source-printer/rest-adapter-source-printer.js +11 -15
- package/dist/codegen/rest/source-printer/rest-adapter-source-printer.js.map +1 -1
- package/dist/codegen/rest/source-printer/rest-source-printer.d.ts +6 -3
- package/dist/codegen/rest/source-printer/rest-source-printer.js +9 -15
- package/dist/codegen/rest/source-printer/rest-source-printer.js.map +1 -1
- package/dist/codegen/shape/graphql/index.d.ts +3 -0
- package/dist/codegen/shape/graphql/index.js +29 -0
- package/dist/codegen/shape/graphql/index.js.map +1 -0
- package/dist/codegen/shape/graphql/key-builder.d.ts +5 -0
- package/dist/codegen/shape/graphql/key-builder.js +26 -0
- package/dist/codegen/shape/graphql/key-builder.js.map +1 -0
- package/dist/codegen/shape/graphql/shape-ingest.d.ts +3 -0
- package/dist/codegen/shape/graphql/shape-ingest.js +67 -0
- package/dist/codegen/shape/graphql/shape-ingest.js.map +1 -0
- package/dist/codegen/shape/graphql/shape-type-definition.d.ts +3 -0
- package/dist/codegen/shape/graphql/shape-type-definition.js +28 -0
- package/dist/codegen/shape/graphql/shape-type-definition.js.map +1 -0
- package/dist/codegen/shape/shape-select-paginated.js +6 -16
- package/dist/codegen/shape/shape-select-paginated.js.map +1 -1
- package/dist/codegen/shape/shape-utils-ingest.js +22 -0
- package/dist/codegen/shape/shape-utils-ingest.js.map +1 -1
- package/dist/codegen/shared/constants.d.ts +5 -0
- package/dist/codegen/shared/constants.js +7 -1
- package/dist/codegen/shared/constants.js.map +1 -1
- package/dist/codegen/typescript/index.d.ts +3 -0
- package/dist/codegen/typescript/index.js +15 -0
- package/dist/codegen/typescript/index.js.map +1 -0
- package/dist/codegen/typescript/typescript-import.d.ts +93 -0
- package/dist/codegen/typescript/typescript-import.js +110 -0
- package/dist/codegen/typescript/typescript-import.js.map +1 -0
- package/dist/codegen/typescript/typescript-package.d.ts +13 -0
- package/dist/codegen/typescript/typescript-package.js +85 -0
- package/dist/codegen/typescript/typescript-package.js.map +1 -0
- package/dist/codegen/typescript/typescript-source-file-id.d.ts +13 -0
- package/dist/codegen/typescript/typescript-source-file-id.js +21 -0
- package/dist/codegen/typescript/typescript-source-file-id.js.map +1 -0
- package/dist/codegen/typescript/typescript-source-file.d.ts +10 -0
- package/dist/codegen/typescript/typescript-source-file.js +19 -0
- package/dist/codegen/typescript/typescript-source-file.js.map +1 -0
- package/dist/compiler/raml-compiler.d.ts +11 -12
- package/dist/compiler/raml-compiler.js +17 -10
- package/dist/compiler/raml-compiler.js.map +1 -1
- package/dist/interfaces/source-printers/graphql/graphql-adapter-printer.d.ts +6 -2
- package/dist/interfaces/source-printers/graphql/graphql-resource-printer.d.ts +5 -2
- package/dist/interfaces/source-printers/graphql/graphql-type-printer.d.ts +7 -2
- package/dist/interfaces/source-writer.d.ts +0 -1
- package/dist/intermediate/graphql-annotation.d.ts +1 -1
- package/dist/intermediate/graphql.d.ts +13 -3
- package/dist/intermediate/model-info.d.ts +2 -0
- package/dist/intermediate/resource.d.ts +2 -4
- package/dist/intermediate/resource.js.map +1 -1
- package/dist/main.d.ts +2 -3
- package/dist/main.js.map +1 -1
- package/dist/parser/annotation-adapter.d.ts +2 -1
- package/dist/parser/annotation-adapter.js +30 -28
- package/dist/parser/annotation-adapter.js.map +1 -1
- package/dist/parser/annotation-graphql.d.ts +2 -2
- package/dist/parser/annotation-graphql.js +1 -0
- package/dist/parser/annotation-graphql.js.map +1 -1
- package/dist/parser/main.js +9 -3
- package/dist/parser/main.js.map +1 -1
- package/dist/parser/resource.js +16 -15
- package/dist/parser/resource.js.map +1 -1
- package/dist/plugin.d.ts +4 -2
- package/dist/utils/aml.js +5 -1
- package/dist/utils/aml.js.map +1 -1
- package/dist/utils/generation.d.ts +4 -2
- package/dist/utils/generation.js +5 -11
- package/dist/utils/generation.js.map +1 -1
- package/dist/utils/imports.d.ts +4 -2
- package/dist/utils/imports.js +27 -31
- package/dist/utils/imports.js.map +1 -1
- package/package.json +4 -4
- package/dist/generate.d.ts +0 -15
- package/dist/generate.js.map +0 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypescriptPackage = void 0;
|
|
4
|
+
class TypescriptPackage {
|
|
5
|
+
constructor(sourceFiles) {
|
|
6
|
+
this.sourceFiles = sourceFiles;
|
|
7
|
+
this.sourceFileIdToFileMap = {};
|
|
8
|
+
this.sourceFiles.forEach((file) => {
|
|
9
|
+
this.sourceFileIdToFileMap[file.id.getIdString()] = file;
|
|
10
|
+
});
|
|
11
|
+
if (Object.keys(this.sourceFileIdToFileMap).length !== sourceFiles.length) {
|
|
12
|
+
throw new Error('Files must all have unique identifiers.');
|
|
13
|
+
}
|
|
14
|
+
this.validatePackage();
|
|
15
|
+
}
|
|
16
|
+
getModuleById(id) {
|
|
17
|
+
return this.getModuleByIdString(id.getIdString());
|
|
18
|
+
}
|
|
19
|
+
getModuleByIdString(id) {
|
|
20
|
+
const sourceFile = this.sourceFileIdToFileMap[id];
|
|
21
|
+
if (!sourceFile) {
|
|
22
|
+
throw new Error(`File not found for ID: ${id}`);
|
|
23
|
+
}
|
|
24
|
+
return sourceFile;
|
|
25
|
+
}
|
|
26
|
+
validatePackage() {
|
|
27
|
+
this.sourceFiles.forEach((file) => {
|
|
28
|
+
this.validateSourceFileImports(file);
|
|
29
|
+
file.imports.forEach((sourceImport) => {
|
|
30
|
+
if (sourceImport.local) {
|
|
31
|
+
if (sourceImport.importType === 'default') {
|
|
32
|
+
this.validateLocalDefaultImport(sourceImport);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.validateLocalNamedImport(sourceImport);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
validateSourceFileImports(sourceFile) {
|
|
42
|
+
const importNameSet = new Set();
|
|
43
|
+
const defaultImportClausesSetByModuleId = {};
|
|
44
|
+
const namedImportClausesSetByModuleId = {};
|
|
45
|
+
const defaultImportClausesArrayByModuleId = {};
|
|
46
|
+
const namedImportClausesArrayByModuleId = {};
|
|
47
|
+
sourceFile.imports.forEach((sourceImport) => {
|
|
48
|
+
importNameSet.add(sourceImport.importName);
|
|
49
|
+
const clauseSetMap = sourceImport.importType === 'default'
|
|
50
|
+
? defaultImportClausesSetByModuleId
|
|
51
|
+
: namedImportClausesSetByModuleId;
|
|
52
|
+
const clauseArrayMap = sourceImport.importType === 'default'
|
|
53
|
+
? defaultImportClausesArrayByModuleId
|
|
54
|
+
: namedImportClausesArrayByModuleId;
|
|
55
|
+
if (!clauseSetMap[sourceImport.moduleId]) {
|
|
56
|
+
clauseSetMap[sourceImport.moduleId] = new Set();
|
|
57
|
+
clauseArrayMap[sourceImport.moduleId] = [];
|
|
58
|
+
}
|
|
59
|
+
clauseSetMap[sourceImport.moduleId].add(sourceImport.importClause);
|
|
60
|
+
clauseArrayMap[sourceImport.moduleId].push(sourceImport.importClause);
|
|
61
|
+
});
|
|
62
|
+
if (importNameSet.size !== sourceFile.imports.length) {
|
|
63
|
+
throw new Error(`Imports in file with ID ${sourceFile.id.getIdString()} must use unique names.`);
|
|
64
|
+
}
|
|
65
|
+
Object.values(defaultImportClausesSetByModuleId).forEach((defaultImportClauseSet) => {
|
|
66
|
+
if (defaultImportClauseSet.size > 1) {
|
|
67
|
+
throw new Error(`Only one default import name can be specified for file ID ${sourceFile.id.getIdString()}, found: ${Array.from(defaultImportClauseSet)}`);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
validateLocalDefaultImport(sourceImport) {
|
|
72
|
+
const importedFile = this.getModuleByIdString(sourceImport.moduleId);
|
|
73
|
+
if (!importedFile.defaultExport) {
|
|
74
|
+
throw new Error(`Import with ID ${sourceImport.moduleId} expected a default export.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
validateLocalNamedImport(sourceImport) {
|
|
78
|
+
const importedFile = this.getModuleByIdString(sourceImport.moduleId);
|
|
79
|
+
if (!importedFile.namedExports.includes(sourceImport.defaultImportName)) {
|
|
80
|
+
throw new Error(`Source file with ID ${importedFile.id.getIdString()} does not export ${sourceImport.defaultImportName}.`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.TypescriptPackage = TypescriptPackage;
|
|
85
|
+
//# sourceMappingURL=typescript-package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-package.js","sourceRoot":"","sources":["../../../src/codegen/typescript/typescript-package.ts"],"names":[],"mappings":";;;AAIA,MAAa,iBAAiB;IAG1B,YAAmB,WAAmC;QAAnC,gBAAW,GAAX,WAAW,CAAwB;QAF9C,0BAAqB,GAAyC,EAAE,CAAC;QAGrE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC9B,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC;QAC7D,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,EAAE;YACvE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;SAC9D;QAED,IAAI,CAAC,eAAe,EAAE,CAAC;IAC3B,CAAC;IAED,aAAa,CAAC,EAA0B;QACpC,OAAO,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CA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,wBAAwB,CAAC,YAA8B;QAC3D,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACrE,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC,iBAAiB,CAAC,EAAE;YACrE,MAAM,IAAI,KAAK,CACX,uBAAuB,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,oBAChD,YAAY,CAAC,iBACjB,GAAG,CACN,CAAC;SACL;IACL,CAAC;CACJ;AArGD,8CAqGC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export interface TypescriptSourceFileId {
|
|
4
|
+
getIdString(): string;
|
|
5
|
+
generateFilePath(): path.ParsedPath;
|
|
6
|
+
}
|
|
7
|
+
export declare class LuvioTypescriptSourceFileId implements TypescriptSourceFileId {
|
|
8
|
+
readonly type: 'adapters' | 'resources' | 'types';
|
|
9
|
+
readonly identifier: string;
|
|
10
|
+
constructor(type: 'adapters' | 'resources' | 'types', identifier: string);
|
|
11
|
+
getIdString(): string;
|
|
12
|
+
generateFilePath(): path.ParsedPath;
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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.LuvioTypescriptSourceFileId = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
class LuvioTypescriptSourceFileId {
|
|
9
|
+
constructor(type, identifier) {
|
|
10
|
+
this.type = type;
|
|
11
|
+
this.identifier = identifier;
|
|
12
|
+
}
|
|
13
|
+
getIdString() {
|
|
14
|
+
return `${this.type}:${this.identifier}`;
|
|
15
|
+
}
|
|
16
|
+
generateFilePath() {
|
|
17
|
+
return path_1.default.parse(`${this.type}/${this.identifier}.ts`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.LuvioTypescriptSourceFileId = LuvioTypescriptSourceFileId;
|
|
21
|
+
//# sourceMappingURL=typescript-source-file-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-source-file-id.js","sourceRoot":"","sources":["../../../src/codegen/typescript/typescript-source-file-id.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAOxB,MAAa,2BAA2B;IACpC,YACoB,IAAwC,EACxC,UAAkB;QADlB,SAAI,GAAJ,IAAI,CAAoC;QACxC,eAAU,GAAV,UAAU,CAAQ;IACnC,CAAC;IACJ,WAAW;QACP,OAAO,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;IAC7C,CAAC;IACD,gBAAgB;QACZ,OAAO,cAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC;IAC5D,CAAC;CACJ;AAXD,kEAWC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TypescriptImport } from './typescript-import';
|
|
2
|
+
import type { TypescriptSourceFileId } from './typescript-source-file-id';
|
|
3
|
+
export declare class TypescriptSourceFile {
|
|
4
|
+
readonly id: TypescriptSourceFileId;
|
|
5
|
+
readonly imports: TypescriptImport[];
|
|
6
|
+
readonly namedExports: string[];
|
|
7
|
+
readonly defaultExport: boolean;
|
|
8
|
+
readonly code: string;
|
|
9
|
+
constructor(id: TypescriptSourceFileId, imports: TypescriptImport[], namedExports: string[], defaultExport: boolean, code: string);
|
|
10
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypescriptSourceFile = void 0;
|
|
4
|
+
class TypescriptSourceFile {
|
|
5
|
+
constructor(id, imports, namedExports, defaultExport, code) {
|
|
6
|
+
this.id = id;
|
|
7
|
+
this.imports = imports;
|
|
8
|
+
this.namedExports = namedExports;
|
|
9
|
+
this.defaultExport = defaultExport;
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.imports.forEach((sourceImport) => {
|
|
12
|
+
if (sourceImport.moduleId === this.id.getIdString()) {
|
|
13
|
+
throw new Error(`File with ID ${id.getIdString()} is trying to import itself.`);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.TypescriptSourceFile = TypescriptSourceFile;
|
|
19
|
+
//# sourceMappingURL=typescript-source-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-source-file.js","sourceRoot":"","sources":["../../../src/codegen/typescript/typescript-source-file.ts"],"names":[],"mappings":";;;AAGA,MAAa,oBAAoB;IAC7B,YACoB,EAA0B,EAC1B,OAA2B,EAC3B,YAAsB,EACtB,aAAsB,EACtB,IAAY;QAJZ,OAAE,GAAF,EAAE,CAAwB;QAC1B,YAAO,GAAP,OAAO,CAAoB;QAC3B,iBAAY,GAAZ,YAAY,CAAU;QACtB,kBAAa,GAAb,aAAa,CAAS;QACtB,SAAI,GAAJ,IAAI,CAAQ;QAE5B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;YAClC,IAAI,YAAY,CAAC,QAAQ,KAAK,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,EAAE;gBACjD,MAAM,IAAI,KAAK,CAAC,gBAAgB,EAAE,CAAC,WAAW,EAAE,8BAA8B,CAAC,CAAC;aACnF;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAdD,oDAcC"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import type { Parser, SourcePrinter } from '../interfaces';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export interface LuvioRamlCompilerEnvironment extends CompilerEnvironment {
|
|
8
|
-
config: LuvioRamlCompilerConfig;
|
|
9
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { CompilerSourceWriter, Parser, SourcePrinter } from '../interfaces';
|
|
3
|
+
import type { LuvioCompiler, ParseError } from '../main';
|
|
4
|
+
import type { CompilerPlugin } from '../plugin';
|
|
5
|
+
import path from 'path';
|
|
10
6
|
export declare class LuvioRamlCompiler implements LuvioCompiler {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
private parser;
|
|
8
|
+
private sourceWriter;
|
|
9
|
+
private sourcePrinters;
|
|
10
|
+
private compilerBaseOutputDir;
|
|
11
|
+
private plugin?;
|
|
12
|
+
constructor(parser: Parser, sourceWriter: CompilerSourceWriter, sourcePrinters: SourcePrinter[], compilerBaseOutputDir: path.ParsedPath, plugin?: CompilerPlugin | undefined);
|
|
14
13
|
generate(): Promise<void | ParseError[]>;
|
|
15
14
|
}
|
|
@@ -1,32 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.LuvioRamlCompiler = void 0;
|
|
4
7
|
const generation_1 = require("../utils/generation");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
5
9
|
class LuvioRamlCompiler {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
10
|
+
constructor(parser, sourceWriter, sourcePrinters, compilerBaseOutputDir, plugin) {
|
|
11
|
+
this.parser = parser;
|
|
12
|
+
this.sourceWriter = sourceWriter;
|
|
8
13
|
this.sourcePrinters = sourcePrinters;
|
|
14
|
+
this.compilerBaseOutputDir = compilerBaseOutputDir;
|
|
15
|
+
this.plugin = plugin;
|
|
9
16
|
}
|
|
10
17
|
async generate() {
|
|
11
18
|
var _a, _b;
|
|
12
|
-
const
|
|
13
|
-
const parser = compilerConfig.parser;
|
|
14
|
-
const { modelInfo, errors } = await parser.parse();
|
|
19
|
+
const { modelInfo, errors } = await this.parser.parse();
|
|
15
20
|
if (modelInfo === undefined) {
|
|
16
21
|
return Promise.resolve(errors);
|
|
17
22
|
}
|
|
18
|
-
if ((_a = this.
|
|
19
|
-
const pluginResult = await this.
|
|
23
|
+
if ((_a = this.plugin) === null || _a === void 0 ? void 0 : _a.validate) {
|
|
24
|
+
const pluginResult = await this.plugin.validate(modelInfo);
|
|
20
25
|
if (pluginResult.hasErrors === true) {
|
|
21
26
|
return Promise.resolve(pluginResult.errors);
|
|
22
27
|
}
|
|
23
28
|
}
|
|
24
29
|
this.sourcePrinters.forEach((printer) => {
|
|
25
30
|
const generatedModules = printer.generateModules(modelInfo);
|
|
26
|
-
this.
|
|
31
|
+
this.sourceWriter.writeModules(generatedModules);
|
|
27
32
|
});
|
|
28
|
-
if ((_b = this.
|
|
29
|
-
await this.
|
|
33
|
+
if ((_b = this.plugin) === null || _b === void 0 ? void 0 : _b.afterGenerate) {
|
|
34
|
+
await this.plugin.afterGenerate({
|
|
35
|
+
outputDir: path_1.default.format(this.compilerBaseOutputDir),
|
|
36
|
+
}, modelInfo, (0, generation_1.createCodeGenerationContext)(this.plugin, this.compilerBaseOutputDir, this.sourceWriter));
|
|
30
37
|
}
|
|
31
38
|
}
|
|
32
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raml-compiler.js","sourceRoot":"","sources":["../../src/compiler/raml-compiler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"raml-compiler.js","sourceRoot":"","sources":["../../src/compiler/raml-compiler.ts"],"names":[],"mappings":";;;;;;AAGA,oDAAkE;AAClE,gDAAwB;AACxB,MAAa,iBAAiB;IAC1B,YACY,MAAc,EACd,YAAkC,EAClC,cAA+B,EAC/B,qBAAsC,EACtC,MAAmC;QAJnC,WA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-1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ModelInfo } from '../../../main';
|
|
3
|
+
import type { GraphQLResource } from '../../../intermediate/resource';
|
|
4
|
+
import type path from 'path';
|
|
5
|
+
import type { CompilerPlugin } from '../../../plugin';
|
|
2
6
|
export interface GraphQLAdapterPrinter {
|
|
3
|
-
generate(
|
|
7
|
+
generate(modelInfo: ModelInfo, resource: GraphQLResource, compilerBaseOutputDir: path.ParsedPath, plugin: CompilerPlugin): {
|
|
4
8
|
[path: string]: string;
|
|
5
9
|
};
|
|
6
10
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ModelInfo } from '../../../main';
|
|
3
|
+
import type { GraphQLResource } from '../../../intermediate/resource';
|
|
4
|
+
import type path from 'path';
|
|
2
5
|
export interface GraphQLResourcePrinter {
|
|
3
|
-
generate(
|
|
6
|
+
generate(modelInfo: ModelInfo, resource: GraphQLResource, compilerBaseOutputDir: path.ParsedPath): {
|
|
4
7
|
[path: string]: string;
|
|
5
8
|
};
|
|
6
9
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { GraphQLResource } from '../../../intermediate/resource';
|
|
3
|
+
import type { GraphQLCodegenMetadata } from '../../../codegen/graphql/source-printer/graphql-source-printer';
|
|
4
|
+
import type path from 'path';
|
|
5
|
+
import type { ModelInfo } from '../../../main';
|
|
6
|
+
import type { CompilerPlugin } from '../../../plugin';
|
|
2
7
|
export interface GraphQLTypePrinter {
|
|
3
|
-
generate(
|
|
8
|
+
generate(graphQLResource: GraphQLResource, compilerBaseOutputDir: path.ParsedPath, metadata: GraphQLCodegenMetadata, modelInfo: ModelInfo, plugin: CompilerPlugin): {
|
|
4
9
|
[path: string]: string;
|
|
5
10
|
};
|
|
6
11
|
}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GraphQLSchema, GraphQLScalarType } from '@luvio/graphql-parser';
|
|
2
|
+
export interface LuvioGraphQLDSLParams {
|
|
3
|
+
schema: GraphQLSchema;
|
|
4
|
+
schemaName: string;
|
|
5
|
+
typeExtensions: Record<string, GraphQLTypeExtension>;
|
|
6
|
+
}
|
|
2
7
|
export interface GraphQLTypeExtension {
|
|
3
8
|
ttl: number;
|
|
4
9
|
line: number;
|
|
5
10
|
col: number;
|
|
6
11
|
}
|
|
7
|
-
export interface
|
|
8
|
-
schema:
|
|
12
|
+
export interface LuvioGraphQLDSL {
|
|
13
|
+
schema: Readonly<GraphQLSchema>;
|
|
14
|
+
schemaName: Readonly<string>;
|
|
15
|
+
customScalars: GraphQLScalarType[];
|
|
9
16
|
typeExtensions: Record<string, GraphQLTypeExtension>;
|
|
10
17
|
}
|
|
18
|
+
export interface GraphQLShapeContext {
|
|
19
|
+
operationId: string;
|
|
20
|
+
}
|
|
@@ -4,6 +4,7 @@ import type { ShapeInheritance, ShapeDiscriminatorTypesIntermediate } from './in
|
|
|
4
4
|
import type { Resource } from './resource';
|
|
5
5
|
import type { CompositeResourceMap } from './composite-resource';
|
|
6
6
|
import type { ShapePaginated, ShapePaginatedContainer } from './pagination';
|
|
7
|
+
import type { GraphQLShapeContext } from './graphql';
|
|
7
8
|
export declare type ShapeTtls = {
|
|
8
9
|
[shapeId: string]: number;
|
|
9
10
|
};
|
|
@@ -37,4 +38,5 @@ export interface ModelInfo {
|
|
|
37
38
|
compositeResources: CompositeResourceMap;
|
|
38
39
|
shapeDiscriminatorTypes: ShapeDiscriminatorTypesIntermediate;
|
|
39
40
|
resources: Resource[];
|
|
41
|
+
graphQLShapes: Record<string, GraphQLShapeContext>;
|
|
40
42
|
}
|
|
@@ -4,7 +4,7 @@ import type { AdapterAnnotation } from './adapter-annotation';
|
|
|
4
4
|
import type { NodeShapeDefinition, ParameterDefinition } from './definitions';
|
|
5
5
|
import type { MockPayload } from './mock-payload';
|
|
6
6
|
import type { StringMap } from './utils';
|
|
7
|
-
import type {
|
|
7
|
+
import type { LuvioGraphQLDSL } from './graphql';
|
|
8
8
|
export declare type HTTPStatusCode = 200 | 201 | 304 | 400 | 404 | 500;
|
|
9
9
|
export interface ResourceReturnShapeDefinition {
|
|
10
10
|
statusCode: HTTPStatusCode;
|
|
@@ -36,8 +36,6 @@ export interface BaseResource {
|
|
|
36
36
|
adapter?: AdapterAnnotation;
|
|
37
37
|
/** The HTTP headers to send with the resource request */
|
|
38
38
|
headers: ParameterDefinition[];
|
|
39
|
-
/** The network fulfillment predicate if any */
|
|
40
|
-
fulfill?: string;
|
|
41
39
|
/** The shape definition to generate resource config */
|
|
42
40
|
configShapeDefinition: NodeShapeDefinition;
|
|
43
41
|
/** The flatten resource param definition for adapter to generate resource config */
|
|
@@ -60,7 +58,7 @@ export interface RestResource extends BaseResource {
|
|
|
60
58
|
}
|
|
61
59
|
export interface GraphQLResource extends BaseResource {
|
|
62
60
|
resourceType: 'GraphQL';
|
|
63
|
-
|
|
61
|
+
graphqlDSL: LuvioGraphQLDSL;
|
|
64
62
|
}
|
|
65
63
|
export declare type Resource = RestResource | GraphQLResource;
|
|
66
64
|
export declare function isPurePost(resource: Resource): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../src/intermediate/resource.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../src/intermediate/resource.ts"],"names":[],"mappings":";;;AAsEA,SAAgB,UAAU,CAAC,QAAkB;IACzC,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,QAAQ,CAAC;IAC/C,OAAO,MAAM,KAAK,MAAM,IAAI,iBAAiB,KAAK,SAAS,CAAC;AAChE,CAAC;AAHD,gCAGC;AAEY,QAAA,0BAA0B,GAAG,WAAW,CAAC;AACzC,QAAA,4BAA4B,GAAG,aAAa,CAAC;AAC7C,QAAA,oBAAoB,GAAG,MAAM,CAAC;AAC9B,QAAA,uBAAuB,GAAG,SAAS,CAAC"}
|
package/dist/main.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export { CompilerConfig } from './generate';
|
|
2
1
|
export { ParseError } from './parser/logger';
|
|
3
2
|
export { ParseResults, LuvioRamlFileParser } from './parser/main';
|
|
4
3
|
export { ModelInfo, ShapePrivate } from './intermediate/model-info';
|
|
5
4
|
export { ShapeTypes, ParameterDefinition, ShapeDefinition, PropertyShapeDefinition, NodeShapeDefinition, ArrayShapeDefinition, UnionShapeDefinition, ScalarShapeDefinition, } from './intermediate/definitions';
|
|
6
|
-
export { CompilerPlugin, PluginResult } from './plugin';
|
|
7
|
-
export { LuvioRamlCompiler
|
|
5
|
+
export { CompilerPlugin, CompilerPluginConfig, PluginResult } from './plugin';
|
|
6
|
+
export { LuvioRamlCompiler } from './compiler/raml-compiler';
|
|
8
7
|
export { CompilerSourceWriter, LuvioCompiler, Parser } from './interfaces';
|
|
9
8
|
export { FileSystemSourceWriter } from './codegen/source-writer/file-system-source-writer';
|
|
10
9
|
export { GraphQLSourcePrinter, GraphQLTypeSourcePrinter, GraphQLResourceSourcePrinter, GraphQLAdapterSourcePrinter, } from './codegen/graphql/source-printer';
|
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":";;;AACA,sCAAkE;AAA3C,2GAAA,mBAAmB,OAAA;AAE1C,0DASoC;AARhC,yGAAA,UAAU,OAAA;AAUd,0DAA6D;AAApD,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"}
|
|
@@ -5,5 +5,6 @@ import type { MockPayload } from '../intermediate/mock-payload';
|
|
|
5
5
|
import type { ShapeCoerceFunction, ShapeTtls } from '../intermediate/model-info';
|
|
6
6
|
import type { ShapeKeys } from './main';
|
|
7
7
|
import type { StringMap } from '../intermediate/utils';
|
|
8
|
+
import type { ResourceType } from '../intermediate/resource';
|
|
8
9
|
export declare const ADAPTER_ANNOTATION_NAME = "adapter";
|
|
9
|
-
export declare function collectAdapterAnnotation(document: amf.document.Document, operation: amf.domain.Operation, method: string, adapterNames: string[], shapeCoerceFunction: ShapeCoerceFunction, shapeKeys: ShapeKeys, shapeTtls: ShapeTtls, rootTtl: number | undefined, resourceKeys: StringMap | undefined, successReturnShape: ShapeDefinition | undefined, mockPaylaods: MockPayload[], resourceConfigShape: NodeShapeDefinition): AdapterAnnotation | undefined;
|
|
10
|
+
export declare function collectAdapterAnnotation(document: amf.document.Document, operation: amf.domain.Operation, method: string, adapterNames: string[], shapeCoerceFunction: ShapeCoerceFunction, shapeKeys: ShapeKeys, shapeTtls: ShapeTtls, rootTtl: number | undefined, resourceKeys: StringMap | undefined, successReturnShape: ShapeDefinition | undefined, mockPaylaods: MockPayload[], resourceConfigShape: NodeShapeDefinition, resourceType: ResourceType): AdapterAnnotation | undefined;
|
|
@@ -6,7 +6,7 @@ const logger_1 = require("./logger");
|
|
|
6
6
|
const annotation_key_1 = require("./annotation-key");
|
|
7
7
|
const annotation_1 = require("../utils/annotation");
|
|
8
8
|
exports.ADAPTER_ANNOTATION_NAME = 'adapter';
|
|
9
|
-
function collectAdapterAnnotation(document, operation, method, adapterNames, shapeCoerceFunction, shapeKeys, shapeTtls, rootTtl, resourceKeys, successReturnShape, mockPaylaods, resourceConfigShape) {
|
|
9
|
+
function collectAdapterAnnotation(document, operation, method, adapterNames, shapeCoerceFunction, shapeKeys, shapeTtls, rootTtl, resourceKeys, successReturnShape, mockPaylaods, resourceConfigShape, resourceType) {
|
|
10
10
|
const annotation = (0, annotation_1.getAnnotation)(operation, exports.ADAPTER_ANNOTATION_NAME);
|
|
11
11
|
if (annotation === undefined) {
|
|
12
12
|
return;
|
|
@@ -54,36 +54,38 @@ function collectAdapterAnnotation(document, operation, method, adapterNames, sha
|
|
|
54
54
|
return member.value.value();
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
if (rootTtl === undefined &&
|
|
63
|
-
successReturnShape !== undefined &&
|
|
64
|
-
shapeTtls[successReturnShape.id] === undefined) {
|
|
65
|
-
(0, logger_1.logError)(`Invalid adapter "${name}". Return shape must have TTL specified.`, adapterLine, adapterColumn);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (method === 'delete') {
|
|
69
|
-
// delete adapters must have a key annotation.
|
|
70
|
-
// NOTE: key annotation validation ensures that a DELETE resource with
|
|
71
|
-
// a key has a sibling GET response type with a key, so we don't need to
|
|
72
|
-
// check that here
|
|
73
|
-
if (resourceKeys === undefined) {
|
|
74
|
-
(0, logger_1.logError)(`DELETE adapter '${name}' missing required key annotation on its DELETE resource.`, adapterLine, adapterColumn);
|
|
57
|
+
if (resourceType === 'Rest') {
|
|
58
|
+
// validate successReturnShape
|
|
59
|
+
if (successReturnShape === undefined && method !== 'delete') {
|
|
60
|
+
(0, logger_1.logError)(`Invalid adapter "${name}". Non-DELETE adapters must specify a 2xx response shape.`, adapterLine, adapterColumn);
|
|
75
61
|
return;
|
|
76
62
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
63
|
+
if (rootTtl === undefined &&
|
|
64
|
+
successReturnShape !== undefined &&
|
|
65
|
+
shapeTtls[successReturnShape.id] === undefined) {
|
|
66
|
+
(0, logger_1.logError)(`Invalid adapter "${name}". Return shape must have TTL specified.`, adapterLine, adapterColumn);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (method === 'delete') {
|
|
70
|
+
// delete adapters must have a key annotation.
|
|
71
|
+
// NOTE: key annotation validation ensures that a DELETE resource with
|
|
72
|
+
// a key has a sibling GET response type with a key, so we don't need to
|
|
73
|
+
// check that here
|
|
74
|
+
if (resourceKeys === undefined) {
|
|
75
|
+
(0, logger_1.logError)(`DELETE adapter '${name}' missing required key annotation on its DELETE resource.`, adapterLine, adapterColumn);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
82
78
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
if (method === 'patch' || method === 'put' || method === 'post') {
|
|
80
|
+
const uppercaseMethod = method.toUpperCase();
|
|
81
|
+
if (shapeKeys[successReturnShape.id] === undefined) {
|
|
82
|
+
(0, logger_1.logError)(`Invalid ${uppercaseMethod} adapter "${name}". 2xx return shape "${successReturnShape.name}" does not define a (key)`, adapterLine, adapterColumn);
|
|
83
|
+
}
|
|
84
|
+
const keyAnnotation = (0, annotation_1.getAnnotation)(operation, annotation_key_1.KEY_ANNOTATION_NAME);
|
|
85
|
+
if (keyAnnotation !== undefined) {
|
|
86
|
+
const { line: keyAnnotationLine, column: keyAnnotationColumn } = keyAnnotation.position.start;
|
|
87
|
+
(0, logger_1.logError)(`Invalid (key) on ${uppercaseMethod} adapter "${name}". ${uppercaseMethod} adapters cannot specify (key).`, keyAnnotationLine, keyAnnotationColumn);
|
|
88
|
+
}
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
// tests declaration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotation-adapter.js","sourceRoot":"","sources":["../../src/parser/annotation-adapter.ts"],"names":[],"mappings":";;;AACA,yEAA2E;AAK3E,qCAAoC;AAEpC,qDAAuD;AACvD,oDAAoD;
|
|
1
|
+
{"version":3,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AC,QAAQ,CAAC,KAAK,CAAC;gBACjC,IAAA,iBAAQ,EACJ,oBAAoB,eAAe,aAAa,IAAI,MAAM,eAAe,iCAAiC,EAC1G,iBAAiB,EACjB,mBAAmB,CACtB,CAAC;aACL;SACJ;KACJ;IAED,oBAAoB;IACpB,MAAM,KAAK,GAAG,IAAA,wDAA6B,EACvC,IAAI,EACJ,OAAO,CAAC,UAAU,CAAC,KAA8B,EACjD,YAAY,EACZ,mBAAmB,CACtB,CAAC;IAEF,OAAO;QACH,EAAE,EAAE,GAAG,QAAQ,CAAC,EAAE,oBAAoB,IAAI,EAAE;QAC5C,IAAI;QACJ,aAAa;QACb,WAAW;QACX,KAAK;KACR,CAAC;AACN,CAAC;AA3JD,4DA2JC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { model as amf } from 'amf-client-js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { GraphQLAnnotation } from '../intermediate/graphql-annotation';
|
|
3
3
|
export declare const GRAPHQL_ANNOTATION_NAME = "graphql";
|
|
4
4
|
export declare const SCHEMA_FILE_EXTENSION = ".graphql";
|
|
5
|
-
export declare function collectGraphqlAnnotation(operation: amf.domain.Operation, document: amf.document.Document):
|
|
5
|
+
export declare function collectGraphqlAnnotation(operation: amf.domain.Operation, document: amf.document.Document): GraphQLAnnotation | undefined;
|
|
@@ -29,6 +29,7 @@ function collectGraphqlAnnotation(operation, document) {
|
|
|
29
29
|
(0, logger_1.logError)(`Invalid schema file name. Schema file must end with '.graphql' extension`, line, column);
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
+
//TODO(W-11086107): Validate that the resource has proper request+response shapes.
|
|
32
33
|
const typeExtensionsNode = annotationValue.properties.typeExtensions;
|
|
33
34
|
return {
|
|
34
35
|
schemaPath: (0, files_1.resolveFileLocation)(schemaPath, document),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotation-graphql.js","sourceRoot":"","sources":["../../src/parser/annotation-graphql.ts"],"names":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CAAC;YACF,OAAO,GAAG,CAAC;SACd;aAAM,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YACzD,IAAA,iBAAQ,EACJ,2BAA2B,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,qCAAqC,EAC1F,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EACjC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CACtC,CAAC;YACF,OAAO,GAAG,CAAC;SACd;aAAM,IAAI,CAAC,IAAA,kBAAY,EAAC,GAAG,CAAC,IAAI,CAAC,IAAA,kBAAS,EAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE;YAC5D,IAAA,iBAAQ,EACJ,0CAA0C,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,6BAA6B,EACjG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EACvB,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAC5B,CAAC;YACF,OAAO,GAAG,CAAC;SACd;QAED,OAAO;YACH,GAAG,GAAG;YACN,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE;gBAC1B,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC;gBACpC,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI;gBACvC,GAAG,EAAE,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM;aAC3C;SACJ,CAAC;IACN,CAAC,EACD,EAAE,CACL,CAAC;AACN,CAAC"}
|
package/dist/parser/main.js
CHANGED
|
@@ -59,14 +59,15 @@ function validateNodeShape(shape, normalizableShapes) {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
function validateUnionShape(shape) {
|
|
62
|
+
var _a;
|
|
62
63
|
const nonScalarShapes = shape.anyOf.filter((s) => !(0, aml_1.isScalarShape)(s) && !(0, aml_1.isNilShape)(s));
|
|
63
64
|
// If the union contains one or more shapes that are non scalar report an error.
|
|
64
65
|
// Note: Supporting union between multiple non scalar types requires a type check to know which
|
|
65
66
|
// normalization routine need to be invoked.
|
|
66
67
|
if (nonScalarShapes.length > 1) {
|
|
67
68
|
const formattedShapes = nonScalarShapes.map((s) => s.linkTarget ? s.linkTarget.name.value() : s.name.value());
|
|
68
|
-
const
|
|
69
|
-
(0, logger_1.logError)(`Unsupported complex normalization between ${formattedShapes.join(', ')}`, line, column);
|
|
69
|
+
const startPosition = (_a = shape.anyOf[0].position) === null || _a === void 0 ? void 0 : _a.start;
|
|
70
|
+
(0, logger_1.logError)(`Unsupported complex normalization between ${formattedShapes.join(', ')}`, startPosition === null || startPosition === void 0 ? void 0 : startPosition.line, startPosition === null || startPosition === void 0 ? void 0 : startPosition.column);
|
|
70
71
|
return;
|
|
71
72
|
}
|
|
72
73
|
}
|
|
@@ -198,10 +199,14 @@ class LuvioRamlFileParser {
|
|
|
198
199
|
errors: (0, logger_1.getLogErrors)(),
|
|
199
200
|
};
|
|
200
201
|
}
|
|
201
|
-
// collect paginated container types
|
|
202
|
+
// collect paginated container types and GraphQL Shapes
|
|
202
203
|
const shapePaginatedContainer = {};
|
|
204
|
+
const graphQLShapes = {};
|
|
203
205
|
resources.forEach((resource) => {
|
|
204
206
|
const { paginationParams, returnShape } = resource;
|
|
207
|
+
if (resource.resourceType === 'GraphQL' && returnShape !== undefined) {
|
|
208
|
+
graphQLShapes[returnShape.id] = { operationId: resource.id };
|
|
209
|
+
}
|
|
205
210
|
if (paginationParams === undefined ||
|
|
206
211
|
returnShape === undefined ||
|
|
207
212
|
shapePaginatedContainer[returnShape.id] !== undefined) {
|
|
@@ -269,6 +274,7 @@ class LuvioRamlFileParser {
|
|
|
269
274
|
compositeResources,
|
|
270
275
|
shapeDiscriminatorTypes: (0, shape_inheritance_1.convertShapeDiscriminatorTypes)(shapeDiscriminatorTypes),
|
|
271
276
|
shapeInheritance,
|
|
277
|
+
graphQLShapes,
|
|
272
278
|
};
|
|
273
279
|
const errors = (0, logger_1.getLogErrors)();
|
|
274
280
|
if (errors.length > 0) {
|