@luvio/compiler 0.82.1 → 0.83.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.
Files changed (116) hide show
  1. package/dist/codegen/adapter/index.d.ts +8 -6
  2. package/dist/codegen/adapter/index.js +13 -13
  3. package/dist/codegen/adapter/index.js.map +1 -1
  4. package/dist/codegen/adapter-tests/index.d.ts +3 -2
  5. package/dist/codegen/adapter-tests/index.js +3 -7
  6. package/dist/codegen/adapter-tests/index.js.map +1 -1
  7. package/dist/codegen/graphql/enum/index.d.ts +2 -2
  8. package/dist/codegen/graphql/enum/index.js +2 -2
  9. package/dist/codegen/graphql/enum/index.js.map +1 -1
  10. package/dist/codegen/graphql/enum/interface.d.ts +2 -2
  11. package/dist/codegen/graphql/enum/interface.js +1 -1
  12. package/dist/codegen/graphql/enum/interface.js.map +1 -1
  13. package/dist/codegen/graphql/graphql-dsl.d.ts +13 -0
  14. package/dist/codegen/graphql/graphql-dsl.js +26 -0
  15. package/dist/codegen/graphql/graphql-dsl.js.map +1 -0
  16. package/dist/codegen/graphql/source-printer/graphql-adapter-source-printer.d.ts +7 -4
  17. package/dist/codegen/graphql/source-printer/graphql-adapter-source-printer.js +31 -3
  18. package/dist/codegen/graphql/source-printer/graphql-adapter-source-printer.js.map +1 -1
  19. package/dist/codegen/graphql/source-printer/graphql-resource-source-printer.d.ts +6 -2
  20. package/dist/codegen/graphql/source-printer/graphql-resource-source-printer.js +15 -3
  21. package/dist/codegen/graphql/source-printer/graphql-resource-source-printer.js.map +1 -1
  22. package/dist/codegen/graphql/source-printer/graphql-source-printer.d.ts +12 -17
  23. package/dist/codegen/graphql/source-printer/graphql-source-printer.js +16 -19
  24. package/dist/codegen/graphql/source-printer/graphql-source-printer.js.map +1 -1
  25. package/dist/codegen/graphql/source-printer/graphql-type-source-printer.d.ts +6 -3
  26. package/dist/codegen/graphql/source-printer/graphql-type-source-printer.js +14 -18
  27. package/dist/codegen/graphql/source-printer/graphql-type-source-printer.js.map +1 -1
  28. package/dist/codegen/graphql/source-printer/index.d.ts +2 -2
  29. package/dist/codegen/graphql/source-printer/index.js.map +1 -1
  30. package/dist/codegen/graphql/type/index.d.ts +5 -3
  31. package/dist/codegen/graphql/type/index.js +13 -5
  32. package/dist/codegen/graphql/type/index.js.map +1 -1
  33. package/dist/codegen/graphql/type/ingest.d.ts +5 -4
  34. package/dist/codegen/graphql/type/ingest.js +27 -13
  35. package/dist/codegen/graphql/type/ingest.js.map +1 -1
  36. package/dist/codegen/graphql/type/interface.d.ts +2 -2
  37. package/dist/codegen/graphql/type/interface.js +1 -1
  38. package/dist/codegen/graphql/type/interface.js.map +1 -1
  39. package/dist/codegen/graphql/type/ttl.d.ts +4 -0
  40. package/dist/codegen/graphql/type/ttl.js +18 -0
  41. package/dist/codegen/graphql/type/ttl.js.map +1 -0
  42. package/dist/codegen/graphql/union/index.d.ts +2 -2
  43. package/dist/codegen/graphql/union/index.js +2 -2
  44. package/dist/codegen/graphql/union/index.js.map +1 -1
  45. package/dist/codegen/graphql/union/interface.d.ts +2 -2
  46. package/dist/codegen/graphql/union/interface.js +1 -1
  47. package/dist/codegen/graphql/union/interface.js.map +1 -1
  48. package/dist/codegen/graphql/utils/index.d.ts +1 -1
  49. package/dist/codegen/graphql/utils/index.js +2 -1
  50. package/dist/codegen/graphql/utils/index.js.map +1 -1
  51. package/dist/codegen/graphql/utils/types.d.ts +9 -3
  52. package/dist/codegen/graphql/utils/types.js +13 -1
  53. package/dist/codegen/graphql/utils/types.js.map +1 -1
  54. package/dist/codegen/package-renderer/index.d.ts +2 -0
  55. package/dist/codegen/package-renderer/index.js +6 -0
  56. package/dist/codegen/package-renderer/index.js.map +1 -0
  57. package/dist/codegen/package-renderer/package-renderer.d.ts +16 -0
  58. package/dist/codegen/package-renderer/package-renderer.js +72 -0
  59. package/dist/codegen/package-renderer/package-renderer.js.map +1 -0
  60. package/dist/codegen/package-renderer/text-file.d.ts +6 -0
  61. package/dist/{generate.js → codegen/package-renderer/text-file.js} +1 -1
  62. package/dist/codegen/package-renderer/text-file.js.map +1 -0
  63. package/dist/codegen/resource/create-resource-request.d.ts +3 -2
  64. package/dist/codegen/resource/create-resource-request.js +4 -5
  65. package/dist/codegen/resource/create-resource-request.js.map +1 -1
  66. package/dist/codegen/resource/index.d.ts +4 -2
  67. package/dist/codegen/resource/index.js +3 -3
  68. package/dist/codegen/resource/index.js.map +1 -1
  69. package/dist/codegen/rest/source-printer/rest-adapter-source-printer.d.ts +7 -4
  70. package/dist/codegen/rest/source-printer/rest-adapter-source-printer.js +11 -15
  71. package/dist/codegen/rest/source-printer/rest-adapter-source-printer.js.map +1 -1
  72. package/dist/codegen/rest/source-printer/rest-source-printer.d.ts +6 -3
  73. package/dist/codegen/rest/source-printer/rest-source-printer.js +8 -14
  74. package/dist/codegen/rest/source-printer/rest-source-printer.js.map +1 -1
  75. package/dist/codegen/shape/shape-select-paginated.js +6 -16
  76. package/dist/codegen/shape/shape-select-paginated.js.map +1 -1
  77. package/dist/codegen/typescript/index.d.ts +3 -0
  78. package/dist/codegen/typescript/index.js +15 -0
  79. package/dist/codegen/typescript/index.js.map +1 -0
  80. package/dist/codegen/typescript/typescript-import.d.ts +93 -0
  81. package/dist/codegen/typescript/typescript-import.js +110 -0
  82. package/dist/codegen/typescript/typescript-import.js.map +1 -0
  83. package/dist/codegen/typescript/typescript-package.d.ts +13 -0
  84. package/dist/codegen/typescript/typescript-package.js +85 -0
  85. package/dist/codegen/typescript/typescript-package.js.map +1 -0
  86. package/dist/codegen/typescript/typescript-source-file-id.d.ts +13 -0
  87. package/dist/codegen/typescript/typescript-source-file-id.js +21 -0
  88. package/dist/codegen/typescript/typescript-source-file-id.js.map +1 -0
  89. package/dist/codegen/typescript/typescript-source-file.d.ts +10 -0
  90. package/dist/codegen/typescript/typescript-source-file.js +19 -0
  91. package/dist/codegen/typescript/typescript-source-file.js.map +1 -0
  92. package/dist/compiler/raml-compiler.d.ts +11 -12
  93. package/dist/compiler/raml-compiler.js +17 -10
  94. package/dist/compiler/raml-compiler.js.map +1 -1
  95. package/dist/interfaces/source-printers/graphql/graphql-adapter-printer.d.ts +5 -2
  96. package/dist/interfaces/source-printers/graphql/graphql-resource-printer.d.ts +5 -2
  97. package/dist/interfaces/source-printers/graphql/graphql-type-printer.d.ts +5 -2
  98. package/dist/interfaces/source-writer.d.ts +0 -1
  99. package/dist/intermediate/graphql-annotation.d.ts +1 -1
  100. package/dist/intermediate/graphql.d.ts +10 -3
  101. package/dist/intermediate/resource.d.ts +2 -2
  102. package/dist/main.d.ts +2 -3
  103. package/dist/main.js.map +1 -1
  104. package/dist/parser/annotation-graphql.d.ts +2 -2
  105. package/dist/parser/resource.js +13 -11
  106. package/dist/parser/resource.js.map +1 -1
  107. package/dist/plugin.d.ts +4 -2
  108. package/dist/utils/generation.d.ts +4 -2
  109. package/dist/utils/generation.js +5 -11
  110. package/dist/utils/generation.js.map +1 -1
  111. package/dist/utils/imports.d.ts +4 -2
  112. package/dist/utils/imports.js +27 -31
  113. package/dist/utils/imports.js.map +1 -1
  114. package/package.json +4 -4
  115. package/dist/generate.d.ts +0 -15
  116. package/dist/generate.js.map +0 -1
@@ -0,0 +1,110 @@
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.ExternalTypescriptNamedImport = exports.ExternalTypescriptDefaultImport = exports.ExternalTypescriptImport = exports.LocalTypescriptNamedImport = exports.LocalTypescriptDefaultImport = exports.LocalTypescriptImport = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ class LocalTypescriptImport {
9
+ constructor(id, importType) {
10
+ this.id = id;
11
+ this.importType = importType;
12
+ this.local = true;
13
+ }
14
+ generateImportModule(sourceFileId) {
15
+ const sourceFilePath = sourceFileId.generateFilePath();
16
+ const importFilePath = this.id.generateFilePath();
17
+ const modulePath = sourceFilePath.dir === importFilePath.dir
18
+ ? `./${importFilePath.name}${importFilePath.ext}`
19
+ : path_1.default.relative(sourceFilePath.dir, path_1.default.format(importFilePath));
20
+ // Cut off the .ts extension
21
+ return modulePath.slice(0, -3);
22
+ }
23
+ get moduleId() {
24
+ return this.id.getIdString();
25
+ }
26
+ }
27
+ exports.LocalTypescriptImport = LocalTypescriptImport;
28
+ class LocalTypescriptDefaultImport extends LocalTypescriptImport {
29
+ constructor(id, asName) {
30
+ super(id, 'default');
31
+ this.id = id;
32
+ this.asName = asName;
33
+ }
34
+ get importName() {
35
+ return this.asName;
36
+ }
37
+ get defaultImportName() {
38
+ return this.asName;
39
+ }
40
+ get importClause() {
41
+ return this.importName;
42
+ }
43
+ }
44
+ exports.LocalTypescriptDefaultImport = LocalTypescriptDefaultImport;
45
+ class LocalTypescriptNamedImport extends LocalTypescriptImport {
46
+ constructor(id, defaultImportName, asAlias) {
47
+ super(id, 'named');
48
+ this.id = id;
49
+ this.defaultImportName = defaultImportName;
50
+ this.asAlias = asAlias;
51
+ }
52
+ get importName() {
53
+ return this.asAlias ? this.asAlias : this.defaultImportName;
54
+ }
55
+ get importClause() {
56
+ return this.asAlias
57
+ ? `${this.defaultImportName} as ${this.asAlias}`
58
+ : this.defaultImportName;
59
+ }
60
+ }
61
+ exports.LocalTypescriptNamedImport = LocalTypescriptNamedImport;
62
+ class ExternalTypescriptImport {
63
+ constructor(moduleName, importType) {
64
+ this.moduleName = moduleName;
65
+ this.importType = importType;
66
+ this.local = false;
67
+ }
68
+ generateImportModule() {
69
+ return this.moduleName;
70
+ }
71
+ get moduleId() {
72
+ return this.moduleName;
73
+ }
74
+ }
75
+ exports.ExternalTypescriptImport = ExternalTypescriptImport;
76
+ class ExternalTypescriptDefaultImport extends ExternalTypescriptImport {
77
+ constructor(moduleName, asName) {
78
+ super(moduleName, 'default');
79
+ this.moduleName = moduleName;
80
+ this.asName = asName;
81
+ }
82
+ get importClause() {
83
+ return this.importName;
84
+ }
85
+ get importName() {
86
+ return this.asName;
87
+ }
88
+ get defaultImportName() {
89
+ return this.asName;
90
+ }
91
+ }
92
+ exports.ExternalTypescriptDefaultImport = ExternalTypescriptDefaultImport;
93
+ class ExternalTypescriptNamedImport extends ExternalTypescriptImport {
94
+ constructor(moduleName, defaultImportName, asAlias) {
95
+ super(moduleName, 'named');
96
+ this.moduleName = moduleName;
97
+ this.defaultImportName = defaultImportName;
98
+ this.asAlias = asAlias;
99
+ }
100
+ get importName() {
101
+ return this.asAlias ? this.asAlias : this.defaultImportName;
102
+ }
103
+ get importClause() {
104
+ return this.asAlias
105
+ ? `${this.defaultImportName} as ${this.asAlias}`
106
+ : this.defaultImportName;
107
+ }
108
+ }
109
+ exports.ExternalTypescriptNamedImport = ExternalTypescriptNamedImport;
110
+ //# sourceMappingURL=typescript-import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript-import.js","sourceRoot":"","sources":["../../../src/codegen/typescript/typescript-import.ts"],"names":[],"mappings":";;;;;;AACA,gDAAwB;AAyCxB,MAAsB,qBAAqB;IAMvC,YACoB,EAA0B,EAC1B,UAA+B;QAD/B,OAAE,GAAF,EAAE,CAAwB;QAC1B,eAAU,GAAV,UAAU,CAAqB;QAPnD,UAAK,GAAG,IAAI,CAAC;IAQV,CAAC;IAEJ,oBAAoB,CAAC,YAAoC;QACrD,MAAM,cAAc,GAAG,YAAY,CAAC,gBAAgB,EAAE,CAAC;QACvD,MAAM,cAAc,GAAG,IAAI,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC;QAElD,MAAM,UAAU,GACZ,cAAc,CAAC,GAAG,KAAK,cAAc,CAAC,GAAG;YACrC,CAAC,CAAC,KAAK,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,GAAG,EAAE;YACjD,CAAC,CAAC,cAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,EAAE,cAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;QAEzE,4BAA4B;QAC5B,OAAO,UAAU,C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AkBC"}
@@ -0,0 +1,13 @@
1
+ import type { TypescriptSourceFile } from './typescript-source-file';
2
+ import type { TypescriptSourceFileId } from './typescript-source-file-id';
3
+ export declare class TypescriptPackage {
4
+ sourceFiles: TypescriptSourceFile[];
5
+ private sourceFileIdToFileMap;
6
+ constructor(sourceFiles: TypescriptSourceFile[]);
7
+ getModuleById(id: TypescriptSourceFileId): TypescriptSourceFile;
8
+ private getModuleByIdString;
9
+ private validatePackage;
10
+ private validateSourceFileImports;
11
+ private validateLocalDefaultImport;
12
+ private validateLocalNamedImport;
13
+ }
@@ -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":"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AAE;YAClD,MAAM,IAAI,KAAK,CACX,2BAA2B,UAAU,CAAC,EAAE,CAAC,WAAW,EAAE,yBAAyB,CAClF,CAAC;SACL;QAED,MAAM,CAAC,MAAM,CAAC,iCAAiC,CAAC,CAAC,OAAO,CAAC,CAAC,sBAAsB,EAAE,EAAE;YAChF,IAAI,sBAAsB,CAAC,IAAI,GAAG,CAAC,EAAE;gBACjC,MAAM,IAAI,KAAK,CACX,6DAA6D,UAAU,CAAC,EAAE,CAAC,WAAW,EAAE,YAAY,KAAK,CAAC,IAAI,CAC1G,sBAAsB,CACzB,EAAE,CACN,CAAC;aACL;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,0BAA0B,CAAC,YAA8B;QAC7D,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACrE,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,kBAAkB,YAAY,CAAC,QAAQ,6BAA6B,CAAC,CAAC;SACzF;IACL,CAAC;IAEO,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
- 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
- }
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
- sourcePrinters: SourcePrinter[];
12
- compilerEnvironment: LuvioRamlCompilerEnvironment;
13
- constructor(compilerEnvironment: LuvioRamlCompilerEnvironment, sourcePrinters: SourcePrinter[]);
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(compilerEnvironment, sourcePrinters) {
7
- this.compilerEnvironment = compilerEnvironment;
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 compilerConfig = this.compilerEnvironment.config;
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.compilerEnvironment.plugin) === null || _a === void 0 ? void 0 : _a.validate) {
19
- const pluginResult = await this.compilerEnvironment.plugin.validate(modelInfo);
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.compilerEnvironment.config.sourceWriter.writeModules(generatedModules);
31
+ this.sourceWriter.writeModules(generatedModules);
27
32
  });
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));
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":";;;AAGA,oDAAkE;AAUlE,MAAa,iBAAiB;IAI1B,YACI,mBAAiD,EACjD,cAA+B;QAE/B,IAAI,CAAC,mBAAmB,GAAG,mB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AC,qBAAqB,CAAC;aACrD,EACD,SAAS,EACT,IAAA,wCAA2B,EACvB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,qBAAqB,EAC1B,IAAI,CAAC,YAAY,CACpB,CACJ,CAAC;SACL;IACL,CAAC;CACJ;AA1CD,8CA0CC"}
@@ -1,6 +1,9 @@
1
- import type { GraphQLCodegenMetadata, GraphQLGenerateState } from '../../../codegen/graphql/source-printer/graphql-source-printer';
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 GraphQLAdapterPrinter {
3
- generate(state: GraphQLGenerateState, metadata: GraphQLCodegenMetadata): {
6
+ generate(modelInfo: ModelInfo, resource: GraphQLResource, compilerBaseOutputDir: path.ParsedPath): {
4
7
  [path: string]: string;
5
8
  };
6
9
  }
@@ -1,6 +1,9 @@
1
- import type { GraphQLCodegenMetadata, GraphQLGenerateState } from '../../../codegen/graphql/source-printer/graphql-source-printer';
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(state: GraphQLGenerateState, metadata: GraphQLCodegenMetadata): {
6
+ generate(modelInfo: ModelInfo, resource: GraphQLResource, compilerBaseOutputDir: path.ParsedPath): {
4
7
  [path: string]: string;
5
8
  };
6
9
  }
@@ -1,6 +1,9 @@
1
- import type { GraphQLGenerateState, GraphQLCodegenMetadata } from '../../../codegen/graphql/source-printer/graphql-source-printer';
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';
2
5
  export interface GraphQLTypePrinter {
3
- generate(state: GraphQLGenerateState, metadata: GraphQLCodegenMetadata): {
6
+ generate(graphQLResource: GraphQLResource, compilerBaseOutputDir: path.ParsedPath, metadata: GraphQLCodegenMetadata): {
4
7
  [path: string]: string;
5
8
  };
6
9
  }
@@ -1,5 +1,4 @@
1
1
  export interface CompilerSourceWriter {
2
- outputDirectory: string;
3
2
  writeModules: (modules: {
4
3
  [name: string]: string;
5
4
  }) => void;
@@ -1,5 +1,5 @@
1
1
  import type { GraphQLTypeExtension } from './graphql';
2
- export interface GraphqlAnnotation {
2
+ export interface GraphQLAnnotation {
3
3
  schemaPath: string;
4
4
  typeExtensions: Record<string, GraphQLTypeExtension>;
5
5
  }
@@ -1,10 +1,17 @@
1
- import type { LuvioGraphQLSchema } from '@luvio/graphql-parser';
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 GraphQLRepresentation {
8
- schema: LuvioGraphQLSchema;
12
+ export interface LuvioGraphQLDSL {
13
+ schema: Readonly<GraphQLSchema>;
14
+ schemaName: Readonly<string>;
15
+ customScalars: GraphQLScalarType[];
9
16
  typeExtensions: Record<string, GraphQLTypeExtension>;
10
17
  }
@@ -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 { GraphQLRepresentation } from './graphql';
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;
@@ -60,7 +60,7 @@ export interface RestResource extends BaseResource {
60
60
  }
61
61
  export interface GraphQLResource extends BaseResource {
62
62
  resourceType: 'GraphQL';
63
- graphqlRepresentation: GraphQLRepresentation;
63
+ graphqlDSL: LuvioGraphQLDSL;
64
64
  }
65
65
  export declare type Resource = RestResource | GraphQLResource;
66
66
  export declare function isPurePost(resource: Resource): boolean;
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, LuvioRamlCompilerEnvironment } from './compiler/raml-compiler';
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":";;;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"}
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"}
@@ -1,5 +1,5 @@
1
1
  import type { model as amf } from 'amf-client-js';
2
- import type { GraphqlAnnotation } from '../intermediate/graphql-annotation';
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): GraphqlAnnotation | undefined;
5
+ export declare function collectGraphqlAnnotation(operation: amf.domain.Operation, document: amf.document.Document): GraphQLAnnotation | undefined;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.collectResources = exports.getEndpointBody = exports.resolveShapeLink = exports.buildResourceName = exports.getJSONPayloadShape = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const amf_client_js_1 = require("amf-client-js");
6
- const graphql_parser_1 = require("@luvio/graphql-parser");
7
6
  const resource_1 = require("../intermediate/resource");
8
7
  const aml_1 = require("../utils/aml");
9
8
  const files_1 = require("../utils/files");
@@ -15,6 +14,7 @@ const annotation_1 = require("../utils/annotation");
15
14
  const annotation_key_1 = require("./annotation-key");
16
15
  const annotation_paginationParams_1 = require("./annotation-paginationParams");
17
16
  const annotation_graphql_1 = require("./annotation-graphql");
17
+ const graphql_dsl_1 = require("../codegen/graphql/graphql-dsl");
18
18
  const JSON_MIME_TYPE = 'application/json';
19
19
  function getJSONPayloadShape(response) {
20
20
  for (let i = 0, len = response.payloads.length; i < len; i++) {
@@ -398,16 +398,18 @@ function collectResources(api, document, rootTtl, shapeKeys, shapeTtls, shapeCoe
398
398
  if (graphqlAnnotation !== undefined) {
399
399
  const graphqlSchemaLocation = (0, files_1.resolveFileLocation)(graphqlAnnotation.schemaPath, document);
400
400
  const graphqlSchemaString = (0, fs_1.readFileSync)(graphqlSchemaLocation).toString();
401
- const schema = (0, graphql_parser_1.parseLuvioSchema)(graphqlSchemaString, (0, files_1.getFileName)(graphqlSchemaLocation, annotation_graphql_1.SCHEMA_FILE_EXTENSION));
402
- validateSchemaTypes(schema, graphqlSchemaLocation);
403
- const validatedTypeExtensions = validateTypeExtensions(graphqlAnnotation.typeExtensions, schema);
401
+ const graphqlSchemaAST = (0, graphql_dsl_1.interpretGraphQLSchema)(graphqlSchemaString);
402
+ const validatedTypeExtensions = validateTypeExtensions(graphqlAnnotation.typeExtensions, graphqlSchemaAST);
403
+ const graphqlDSL = new graphql_dsl_1.GraphQLDSL({
404
+ schema: graphqlSchemaAST,
405
+ schemaName: (0, files_1.getFileName)(graphqlSchemaLocation, annotation_graphql_1.SCHEMA_FILE_EXTENSION),
406
+ typeExtensions: validatedTypeExtensions,
407
+ });
408
+ validateSchemaTypes(graphqlDSL, graphqlSchemaLocation);
404
409
  resource = {
405
410
  ...resource,
406
411
  resourceType: 'GraphQL',
407
- graphqlRepresentation: {
408
- schema,
409
- typeExtensions: validatedTypeExtensions,
410
- },
412
+ graphqlDSL,
411
413
  };
412
414
  }
413
415
  resources.push(resource);
@@ -425,7 +427,7 @@ function validateTypeExtensions(typeExtensions, schema) {
425
427
  const validatedTypeExtensions = {};
426
428
  Object.keys(typeExtensions).forEach((typeName) => {
427
429
  const typeExtension = typeExtensions[typeName];
428
- if (schema.schema.getType(typeName) !== undefined) {
430
+ if (schema.getType(typeName) !== undefined) {
429
431
  validatedTypeExtensions[typeName] = typeExtension;
430
432
  return;
431
433
  }
@@ -433,9 +435,9 @@ function validateTypeExtensions(typeExtensions, schema) {
433
435
  });
434
436
  return validatedTypeExtensions;
435
437
  }
436
- function validateSchemaTypes(luvioSchema, graphqlSchemaLocation) {
438
+ function validateSchemaTypes(graphqlDsl, graphqlSchemaLocation) {
437
439
  var _a, _b, _c, _d, _e, _f, _g, _h;
438
- const schema = luvioSchema.schema;
440
+ const { schema } = graphqlDsl;
439
441
  const subscriptionType = schema.getSubscriptionType();
440
442
  const graphqlSchemaFileName = graphqlSchemaLocation.split('/').pop();
441
443
  if (subscriptionType !== undefined) {