@cparra/apexdocs 2.8.2 → 2.9.0-alpha.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.
Files changed (167) hide show
  1. package/docs/openapi.json +474 -0
  2. package/examples/force-app/main/default/classes/ChildClass.cls +3 -1
  3. package/examples/force-app/main/default/classes/ParentClass.cls +4 -4
  4. package/examples/force-app/main/default/classes/SampleClass.cls +3 -0
  5. package/examples/force-app/main/default/restapi/SampleRestResource.cls +195 -0
  6. package/examples/force-app/main/default/restapi/SampleRestResourceWithInnerClass.cls +24 -0
  7. package/examples/force-app/main/default/restapi/references/Reference1.cls +9 -0
  8. package/examples/force-app/main/default/restapi/references/Reference2.cls +3 -0
  9. package/examples/force-app/main/default/restapi/references/Reference3.cls +3 -0
  10. package/examples/force-app/main/default/restapi/references/Reference4.cls +3 -0
  11. package/examples/force-app/main/default/restapi/references/Reference5.cls +3 -0
  12. package/examples/force-app/main/default/restapi/references/Reference6.cls +6 -0
  13. package/lib/application/Apexdocs.d.ts +1 -0
  14. package/lib/application/Apexdocs.js +33 -9
  15. package/lib/application/Apexdocs.js.map +1 -1
  16. package/lib/cli/generate.js +11 -3
  17. package/lib/cli/generate.js.map +1 -1
  18. package/lib/index.js +6 -2
  19. package/lib/index.js.map +1 -1
  20. package/lib/model/apex-type-wrappers/ClassMirrorWrapper.d.ts +7 -0
  21. package/lib/model/apex-type-wrappers/ClassMirrorWrapper.js +14 -0
  22. package/lib/model/apex-type-wrappers/ClassMirrorWrapper.js.map +1 -0
  23. package/lib/model/inheritance.d.ts +5 -5
  24. package/lib/model/manifest.d.ts +1 -1
  25. package/lib/model/markdown-file.d.ts +2 -2
  26. package/lib/model/markdown-file.js +2 -2
  27. package/lib/model/markdown-file.js.map +1 -1
  28. package/lib/model/markdown-generation-util/doc-comment-annotation-util.js.map +1 -1
  29. package/lib/model/markdown-generation-util/field-declaration-util.js +2 -2
  30. package/lib/model/markdown-generation-util/field-declaration-util.js.map +1 -1
  31. package/lib/model/markdown-generation-util/index.js +6 -2
  32. package/lib/model/markdown-generation-util/index.js.map +1 -1
  33. package/lib/model/markdown-generation-util/method-declaration-util.js +4 -4
  34. package/lib/model/markdown-generation-util/method-declaration-util.js.map +1 -1
  35. package/lib/model/markdown-generation-util/type-declaration-util.js +2 -2
  36. package/lib/model/markdown-generation-util/type-declaration-util.js.map +1 -1
  37. package/lib/model/markdown-home-file.js +1 -1
  38. package/lib/model/markdown-home-file.js.map +1 -1
  39. package/lib/model/markdown-type-file.js +5 -5
  40. package/lib/model/markdown-type-file.js.map +1 -1
  41. package/lib/model/openapi/apex-doc-types.d.ts +18 -0
  42. package/lib/model/openapi/apex-doc-types.js +5 -0
  43. package/lib/model/openapi/apex-doc-types.js.map +1 -0
  44. package/lib/model/openapi/open-api-types.d.ts +87 -0
  45. package/lib/model/openapi/open-api-types.js +3 -0
  46. package/lib/model/openapi/open-api-types.js.map +1 -0
  47. package/lib/model/openapi/open-api.d.ts +15 -0
  48. package/lib/model/openapi/open-api.js +33 -0
  49. package/lib/model/openapi/open-api.js.map +1 -0
  50. package/lib/model/openapi/openapi-type-file.d.ts +7 -0
  51. package/lib/model/openapi/openapi-type-file.js +16 -0
  52. package/lib/model/openapi/openapi-type-file.js.map +1 -0
  53. package/lib/model/{file.d.ts → outputFile.d.ts} +1 -1
  54. package/lib/model/{file.js → outputFile.js} +4 -4
  55. package/lib/model/outputFile.js.map +1 -0
  56. package/lib/model/types-repository.d.ts +11 -3
  57. package/lib/model/types-repository.js +37 -5
  58. package/lib/model/types-repository.js.map +1 -1
  59. package/lib/service/file-writer.d.ts +2 -2
  60. package/lib/service/file-writer.js.map +1 -1
  61. package/lib/service/metadata-processor.js.map +1 -1
  62. package/lib/service/parser.d.ts +1 -1
  63. package/lib/settings.d.ts +4 -5
  64. package/lib/settings.js +5 -23
  65. package/lib/settings.js.map +1 -1
  66. package/lib/test-helpers/AnnotationBuilder.d.ts +12 -0
  67. package/lib/test-helpers/AnnotationBuilder.js +31 -0
  68. package/lib/test-helpers/AnnotationBuilder.js.map +1 -0
  69. package/lib/test-helpers/ClassMirrorBuilder.d.ts +18 -0
  70. package/lib/test-helpers/ClassMirrorBuilder.js +54 -0
  71. package/lib/test-helpers/ClassMirrorBuilder.js.map +1 -0
  72. package/lib/test-helpers/DocCommentAnnotationBuilder.d.ts +6 -0
  73. package/lib/test-helpers/DocCommentAnnotationBuilder.js +21 -0
  74. package/lib/test-helpers/DocCommentAnnotationBuilder.js.map +1 -0
  75. package/lib/test-helpers/DocCommentBuilder.d.ts +12 -0
  76. package/lib/test-helpers/DocCommentBuilder.js +38 -0
  77. package/lib/test-helpers/DocCommentBuilder.js.map +1 -0
  78. package/lib/test-helpers/FieldMirrorBuilder.d.ts +16 -0
  79. package/lib/test-helpers/FieldMirrorBuilder.js +48 -0
  80. package/lib/test-helpers/FieldMirrorBuilder.js.map +1 -0
  81. package/lib/test-helpers/MethodMirrorBuilder.d.ts +10 -0
  82. package/lib/test-helpers/MethodMirrorBuilder.js +37 -0
  83. package/lib/test-helpers/MethodMirrorBuilder.js.map +1 -0
  84. package/lib/test-helpers/SettingsBuilder.d.ts +8 -0
  85. package/lib/test-helpers/SettingsBuilder.js +24 -0
  86. package/lib/test-helpers/SettingsBuilder.js.map +1 -0
  87. package/lib/transpiler/factory.d.ts +6 -0
  88. package/lib/transpiler/factory.js +32 -0
  89. package/lib/transpiler/factory.js.map +1 -0
  90. package/lib/transpiler/file-container.d.ts +4 -4
  91. package/lib/transpiler/file-container.js.map +1 -1
  92. package/lib/transpiler/generator-choices.d.ts +1 -0
  93. package/lib/transpiler/generator-choices.js +3 -0
  94. package/lib/transpiler/generator-choices.js.map +1 -0
  95. package/lib/transpiler/markdown/class-file-generatorHelper.js +4 -2
  96. package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -1
  97. package/lib/transpiler/openapi/open-api-docs-processor.d.ts +12 -0
  98. package/lib/transpiler/openapi/open-api-docs-processor.js +62 -0
  99. package/lib/transpiler/openapi/open-api-docs-processor.js.map +1 -0
  100. package/lib/transpiler/openapi/parsers/Builder.d.ts +16 -0
  101. package/lib/transpiler/openapi/parsers/Builder.js +30 -0
  102. package/lib/transpiler/openapi/parsers/Builder.js.map +1 -0
  103. package/lib/transpiler/openapi/parsers/MethodParser.d.ts +17 -0
  104. package/lib/transpiler/openapi/parsers/MethodParser.js +106 -0
  105. package/lib/transpiler/openapi/parsers/MethodParser.js.map +1 -0
  106. package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.d.ts +7 -0
  107. package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.js +11 -0
  108. package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.js.map +1 -0
  109. package/lib/transpiler/openapi/parsers/ReferenceBuilder.d.ts +31 -0
  110. package/lib/transpiler/openapi/parsers/ReferenceBuilder.js +161 -0
  111. package/lib/transpiler/openapi/parsers/ReferenceBuilder.js.map +1 -0
  112. package/lib/transpiler/openapi/parsers/RequestBodyBuilder.d.ts +10 -0
  113. package/lib/transpiler/openapi/parsers/RequestBodyBuilder.js +20 -0
  114. package/lib/transpiler/openapi/parsers/RequestBodyBuilder.js.map +1 -0
  115. package/lib/transpiler/openapi/parsers/ResponsesBuilder.d.ts +7 -0
  116. package/lib/transpiler/openapi/parsers/ResponsesBuilder.js +18 -0
  117. package/lib/transpiler/openapi/parsers/ResponsesBuilder.js.map +1 -0
  118. package/lib/transpiler/processor-type-transpiler.d.ts +2 -2
  119. package/lib/transpiler/processor-type-transpiler.js +3 -0
  120. package/lib/transpiler/processor-type-transpiler.js.map +1 -1
  121. package/lib/transpiler/transpiler.js.map +1 -1
  122. package/lib/util/error-logger.js.map +1 -1
  123. package/package.json +8 -5
  124. package/src/application/Apexdocs.ts +37 -16
  125. package/src/cli/generate.ts +13 -4
  126. package/src/model/apex-type-wrappers/ClassMirrorWrapper.ts +12 -0
  127. package/src/model/apex-type-wrappers/__tests__/ClassMirrorWrapper.spec.ts +15 -0
  128. package/src/model/markdown-file.ts +2 -2
  129. package/src/model/markdown-generation-util/field-declaration-util.ts +5 -2
  130. package/src/model/markdown-generation-util/method-declaration-util.ts +5 -3
  131. package/src/model/markdown-generation-util/type-declaration-util.ts +1 -1
  132. package/src/model/openapi/__tests__/open-api.spec.ts +22 -0
  133. package/src/model/openapi/apex-doc-types.ts +25 -0
  134. package/src/model/openapi/open-api-types.ts +112 -0
  135. package/src/model/openapi/open-api.ts +39 -0
  136. package/src/model/openapi/openapi-type-file.ts +13 -0
  137. package/src/model/{file.ts → outputFile.ts} +1 -1
  138. package/src/model/types-repository.ts +48 -6
  139. package/src/service/file-writer.ts +2 -2
  140. package/src/settings.ts +8 -29
  141. package/src/test-helpers/AnnotationBuilder.ts +29 -0
  142. package/src/test-helpers/ClassMirrorBuilder.ts +56 -0
  143. package/src/test-helpers/DocCommentAnnotationBuilder.ts +18 -0
  144. package/src/test-helpers/DocCommentBuilder.ts +36 -0
  145. package/src/test-helpers/FieldMirrorBuilder.ts +52 -0
  146. package/src/test-helpers/MethodMirrorBuilder.ts +37 -0
  147. package/src/test-helpers/SettingsBuilder.ts +21 -0
  148. package/src/transpiler/factory.ts +33 -0
  149. package/src/transpiler/file-container.ts +4 -4
  150. package/src/transpiler/generator-choices.ts +1 -0
  151. package/src/transpiler/markdown/class-file-generatorHelper.ts +4 -2
  152. package/src/transpiler/openapi/__tests__/open-api-docs-processor.spec.ts +41 -0
  153. package/src/transpiler/openapi/open-api-docs-processor.ts +76 -0
  154. package/src/transpiler/openapi/parsers/Builder.ts +40 -0
  155. package/src/transpiler/openapi/parsers/MethodParser.ts +142 -0
  156. package/src/transpiler/openapi/parsers/ParameterObjectBuilder.ts +13 -0
  157. package/src/transpiler/openapi/parsers/ReferenceBuilder.ts +205 -0
  158. package/src/transpiler/openapi/parsers/RequestBodyBuilder.ts +19 -0
  159. package/src/transpiler/openapi/parsers/ResponsesBuilder.ts +17 -0
  160. package/src/transpiler/openapi/parsers/__tests__/MethodParser.spec.ts +44 -0
  161. package/src/transpiler/openapi/parsers/__tests__/ParameterObjectBuilder.spec.ts +68 -0
  162. package/src/transpiler/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +622 -0
  163. package/src/transpiler/openapi/parsers/__tests__/RequestBodyBuilder.spec.ts +64 -0
  164. package/src/transpiler/openapi/parsers/__tests__/ResponsesBuilder.spec.ts +55 -0
  165. package/src/transpiler/processor-type-transpiler.ts +3 -1
  166. package/tsconfig.json +4 -1
  167. package/lib/model/file.js.map +0 -1
@@ -0,0 +1,16 @@
1
+ import { FieldMirror } from '@cparra/apex-reflection';
2
+ import { ReferencedType } from '@cparra/apex-reflection/index';
3
+ type MemberModifier = 'static' | 'webservice' | 'final' | 'override' | 'testmethod' | 'transient';
4
+ export declare class FieldMirrorBuilder {
5
+ private accessModifier;
6
+ private name;
7
+ private memberModifiers;
8
+ private type;
9
+ withAccessModifier(accessModifier: string): FieldMirrorBuilder;
10
+ withName(name: string): FieldMirrorBuilder;
11
+ withType(type: string): FieldMirrorBuilder;
12
+ withReferencedType(type: ReferencedType): FieldMirrorBuilder;
13
+ addMemberModifier(memberModifier: MemberModifier): FieldMirrorBuilder;
14
+ build(): FieldMirror;
15
+ }
16
+ export {};
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldMirrorBuilder = void 0;
4
+ class FieldMirrorBuilder {
5
+ constructor() {
6
+ this.accessModifier = 'public';
7
+ this.name = 'fieldName';
8
+ this.memberModifiers = [];
9
+ this.type = {
10
+ type: 'String',
11
+ rawDeclaration: 'String',
12
+ };
13
+ }
14
+ withAccessModifier(accessModifier) {
15
+ this.accessModifier = accessModifier;
16
+ return this;
17
+ }
18
+ withName(name) {
19
+ this.name = name;
20
+ return this;
21
+ }
22
+ withType(type) {
23
+ this.type = {
24
+ rawDeclaration: type,
25
+ type: type,
26
+ };
27
+ return this;
28
+ }
29
+ withReferencedType(type) {
30
+ this.type = type;
31
+ return this;
32
+ }
33
+ addMemberModifier(memberModifier) {
34
+ this.memberModifiers.push(memberModifier);
35
+ return this;
36
+ }
37
+ build() {
38
+ return {
39
+ access_modifier: this.accessModifier,
40
+ annotations: [],
41
+ name: this.name,
42
+ memberModifiers: this.memberModifiers,
43
+ typeReference: this.type,
44
+ };
45
+ }
46
+ }
47
+ exports.FieldMirrorBuilder = FieldMirrorBuilder;
48
+ //# sourceMappingURL=FieldMirrorBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldMirrorBuilder.js","sourceRoot":"","sources":["../../src/test-helpers/FieldMirrorBuilder.ts"],"names":[],"mappings":";;;AAKA,MAAa,kBAAkB;IAA/B;QACU,mBAAc,GAAG,QAAQ,CAAC;QAC1B,SAAI,GAAG,WAAW,CAAC;QACnB,oBAAe,GAAqB,EAAE,CAAC;QACvC,SAAI,GAAmB;YAC7B,IAAI,EAAE,QAAQ;YACd,cAAc,EAAE,QAAQ;SACzB,CAAC;IAuCJ,CAAC;IArCC,kBAAkB,CAAC,cAAsB;QACvC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,IAAI,CAAC,IAAI,GAAG;YACV,cAAc,EAAE,IAAI;YACpB,IAAI,EAAE,IAAI;SACX,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,kBAAkB,CAAC,IAAoB;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iBAAiB,CAAC,cAA8B;QAC9C,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,cAAc;YACpC,WAAW,EAAE,EAAE;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,aAAa,EAAE,IAAI,CAAC,IAAI;SACzB,CAAC;IACJ,CAAC;CACF;AA9CD,gDA8CC"}
@@ -0,0 +1,10 @@
1
+ import { Annotation, DocComment, MethodMirror } from '@cparra/apex-reflection';
2
+ export declare class MethodMirrorBuilder {
3
+ private name;
4
+ private annotations;
5
+ private docComment?;
6
+ withName(name: string): MethodMirrorBuilder;
7
+ addAnnotation(annotation: Annotation): MethodMirrorBuilder;
8
+ withDocComment(docComment: DocComment): MethodMirrorBuilder;
9
+ build(): MethodMirror;
10
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MethodMirrorBuilder = void 0;
4
+ class MethodMirrorBuilder {
5
+ constructor() {
6
+ this.name = 'sampleMethod';
7
+ this.annotations = [];
8
+ }
9
+ withName(name) {
10
+ this.name = name;
11
+ return this;
12
+ }
13
+ addAnnotation(annotation) {
14
+ this.annotations.push(annotation);
15
+ return this;
16
+ }
17
+ withDocComment(docComment) {
18
+ this.docComment = docComment;
19
+ return this;
20
+ }
21
+ build() {
22
+ return {
23
+ access_modifier: 'public',
24
+ annotations: this.annotations,
25
+ name: this.name,
26
+ memberModifiers: [],
27
+ typeReference: {
28
+ type: 'void',
29
+ rawDeclaration: 'void',
30
+ },
31
+ parameters: [],
32
+ docComment: this.docComment,
33
+ };
34
+ }
35
+ }
36
+ exports.MethodMirrorBuilder = MethodMirrorBuilder;
37
+ //# sourceMappingURL=MethodMirrorBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MethodMirrorBuilder.js","sourceRoot":"","sources":["../../src/test-helpers/MethodMirrorBuilder.ts"],"names":[],"mappings":";;;AAEA,MAAa,mBAAmB;IAAhC;QACU,SAAI,GAAG,cAAc,CAAC;QACtB,gBAAW,GAAiB,EAAE,CAAC;IAgCzC,CAAC;IA7BC,QAAQ,CAAC,IAAY;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,UAAsB;QAClC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc,CAAC,UAAsB;QACnC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,OAAO;YACL,eAAe,EAAE,QAAQ;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,eAAe,EAAE,EAAE;YACnB,aAAa,EAAE;gBACb,IAAI,EAAE,MAAM;gBACZ,cAAc,EAAE,MAAM;aACvB;YACD,UAAU,EAAE,EAAE;YACd,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC;IACJ,CAAC;CACF;AAlCD,kDAkCC"}
@@ -0,0 +1,8 @@
1
+ import { SettingsConfig } from '../settings';
2
+ /**
3
+ * Builder class to create SettingsConfig objects.
4
+ * For testing purposes only.
5
+ */
6
+ export declare class SettingsBuilder {
7
+ build(): SettingsConfig;
8
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SettingsBuilder = void 0;
4
+ /**
5
+ * Builder class to create SettingsConfig objects.
6
+ * For testing purposes only.
7
+ */
8
+ class SettingsBuilder {
9
+ build() {
10
+ return {
11
+ sourceDirectory: './',
12
+ recursive: true,
13
+ scope: [],
14
+ outputDir: './',
15
+ targetGenerator: 'openapi',
16
+ indexOnly: false,
17
+ defaultGroupName: 'Misc',
18
+ sanitizeHtml: true,
19
+ openApiTitle: 'Apex API',
20
+ };
21
+ }
22
+ }
23
+ exports.SettingsBuilder = SettingsBuilder;
24
+ //# sourceMappingURL=SettingsBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SettingsBuilder.js","sourceRoot":"","sources":["../../src/test-helpers/SettingsBuilder.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,MAAa,eAAe;IAC1B,KAAK;QACH,OAAO;YACL,eAAe,EAAE,IAAI;YACrB,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,EAAE;YACT,SAAS,EAAE,IAAI;YACf,eAAe,EAAE,SAAS;YAC1B,SAAS,EAAE,KAAK;YAChB,gBAAgB,EAAE,MAAM;YACxB,YAAY,EAAE,IAAI;YAClB,YAAY,EAAE,UAAU;SACzB,CAAC;IACJ,CAAC;CACF;AAdD,0CAcC"}
@@ -0,0 +1,6 @@
1
+ import ProcessorTypeTranspiler from './processor-type-transpiler';
2
+ import { GeneratorChoices } from './generator-choices';
3
+ export declare class TypeTranspilerFactory {
4
+ private static typeTranspilerCache?;
5
+ static get(generator: GeneratorChoices): ProcessorTypeTranspiler;
6
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeTranspilerFactory = void 0;
4
+ const jekyll_docsProcessor_1 = require("./markdown/jekyll/jekyll-docsProcessor");
5
+ const docsify_docs_processor_1 = require("./markdown/docsify/docsify-docs-processor");
6
+ const plain_docsProcessor_1 = require("./markdown/plain-markdown/plain-docsProcessor");
7
+ const open_api_docs_processor_1 = require("./openapi/open-api-docs-processor");
8
+ class TypeTranspilerFactory {
9
+ static get(generator) {
10
+ if (this.typeTranspilerCache) {
11
+ return this.typeTranspilerCache;
12
+ }
13
+ switch (generator) {
14
+ case 'jekyll':
15
+ this.typeTranspilerCache = new jekyll_docsProcessor_1.JekyllDocsProcessor();
16
+ return this.typeTranspilerCache;
17
+ case 'docsify':
18
+ this.typeTranspilerCache = new docsify_docs_processor_1.default();
19
+ return this.typeTranspilerCache;
20
+ case 'plain-markdown':
21
+ this.typeTranspilerCache = new plain_docsProcessor_1.PlainMarkdownDocsProcessor();
22
+ return this.typeTranspilerCache;
23
+ case 'openapi':
24
+ this.typeTranspilerCache = new open_api_docs_processor_1.OpenApiDocsProcessor();
25
+ return this.typeTranspilerCache;
26
+ default:
27
+ throw Error('Invalid target generator');
28
+ }
29
+ }
30
+ }
31
+ exports.TypeTranspilerFactory = TypeTranspilerFactory;
32
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/transpiler/factory.ts"],"names":[],"mappings":";;;AAEA,iFAA6E;AAC7E,sFAA6E;AAC7E,uFAA2F;AAC3F,+EAAyE;AAEzE,MAAa,qBAAqB;IAGzB,MAAM,CAAC,GAAG,CAAC,SAA2B;QAC3C,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAC5B,OAAO,IAAI,CAAC,mBAAmB,CAAC;SACjC;QAED,QAAQ,SAAS,EAAE;YACjB,KAAK,QAAQ;gBACX,IAAI,CAAC,mBAAmB,GAAG,IAAI,0CAAmB,EAAE,CAAC;gBACrD,OAAO,IAAI,CAAC,mBAAmB,CAAC;YAClC,KAAK,SAAS;gBACZ,IAAI,CAAC,mBAAmB,GAAG,IAAI,gCAAoB,EAAE,CAAC;gBACtD,OAAO,IAAI,CAAC,mBAAmB,CAAC;YAClC,KAAK,gBAAgB;gBACnB,IAAI,CAAC,mBAAmB,GAAG,IAAI,gDAA0B,EAAE,CAAC;gBAC5D,OAAO,IAAI,CAAC,mBAAmB,CAAC;YAClC,KAAK,SAAS;gBACZ,IAAI,CAAC,mBAAmB,GAAG,IAAI,8CAAoB,EAAE,CAAC;gBACtD,OAAO,IAAI,CAAC,mBAAmB,CAAC;YAClC;gBACE,MAAM,KAAK,CAAC,0BAA0B,CAAC,CAAC;SAC3C;IACH,CAAC;CACF;AAzBD,sDAyBC"}
@@ -1,6 +1,6 @@
1
- import { File } from '../model/file';
1
+ import { OutputFile } from '../model/outputFile';
2
2
  export declare class FileContainer {
3
- _files: File[];
4
- files(): File[];
5
- pushFile(file: File): void;
3
+ _files: OutputFile[];
4
+ files(): OutputFile[];
5
+ pushFile(file: OutputFile): void;
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"file-container.js","sourceRoot":"","sources":["../../src/transpiler/file-container.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IAA1B;QACE,WAAM,GAAW,EAAE,CAAC;IAStB,CAAC;IAPC,KAAK;QACH,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,QAAQ,CAAC,IAAU;QACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CACF;AAVD,sCAUC"}
1
+ {"version":3,"file":"file-container.js","sourceRoot":"","sources":["../../src/transpiler/file-container.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IAA1B;QACE,WAAM,GAAiB,EAAE,CAAC;IAS5B,CAAC;IAPC,KAAK;QACH,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,QAAQ,CAAC,IAAgB;QACvB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CACF;AAVD,sCAUC"}
@@ -0,0 +1 @@
1
+ export type GeneratorChoices = 'jekyll' | 'docsify' | 'plain-markdown' | 'openapi';
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generator-choices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator-choices.js","sourceRoot":"","sources":["../../src/transpiler/generator-choices.ts"],"names":[],"mappings":""}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const types_repository_1 = require("../../model/types-repository");
4
4
  const settings_1 = require("../../settings");
5
5
  const state_1 = require("../../service/state");
6
+ const factory_1 = require("../factory");
6
7
  class ClassFileGeneratorHelper {
7
8
  static getSanitizedGroup(classModel) {
8
9
  return this.getClassGroup(classModel).replace(/ /g, '-').replace('.', '');
@@ -12,7 +13,7 @@ class ClassFileGeneratorHelper {
12
13
  return `[${classModel.name}](${directoryRoot}${classModel.name}.md)`;
13
14
  }
14
15
  static getFileLinkByTypeName(typeName) {
15
- const type = types_repository_1.TypesRepository.getInstance().getByName(typeName);
16
+ const type = types_repository_1.TypesRepository.getInstance().getFromScopedByName(typeName);
16
17
  if (!type) {
17
18
  // If the type is not found we return a Markdown hyperlink with whatever we received.
18
19
  return `[${typeName}](${typeName})`;
@@ -21,7 +22,8 @@ class ClassFileGeneratorHelper {
21
22
  }
22
23
  static getDirectoryRoot(classModel) {
23
24
  // root-relative links start from the root by using a leading '/'
24
- if (settings_1.Settings.getInstance().typeTranspiler.getLinkingStrategy() === 'root-relative') {
25
+ const generator = settings_1.Settings.getInstance().targetGenerator;
26
+ if (factory_1.TypeTranspilerFactory.get(generator).getLinkingStrategy() === 'root-relative') {
25
27
  return `/${this.getSanitizedGroup(classModel)}/`;
26
28
  }
27
29
  // path-relative links traverse the directory structure
@@ -1 +1 @@
1
- {"version":3,"file":"class-file-generatorHelper.js","sourceRoot":"","sources":["../../../src/transpiler/markdown/class-file-generatorHelper.ts"],"names":[],"mappings":";;AACA,mEAA+D;AAC/D,6CAA0C;AAC1C,+CAAwC;AAExC,MAAqB,wBAAwB;IACpC,MAAM,CAAC,iBAAiB,CAAC,UAAgB;QAC9C,OAAO,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC5E,CAAC;IAEM,MAAM,CAAC,WAAW,CAAC,UAAgB;QACxC,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACxD,OAAO,IAAI,UAAU,CAAC,IAAI,KAAK,aAAa,GAAG,UAAU,CAAC,IAAI,MAAM,CAAC;IACvE,CAAC;IAEM,MAAM,CAAC,qBAAq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CAAC,WAAW,EAAE,CAAC,mBAAmB,EAAE,CAAC;IAC/E,CAAC;CACF;AAhDD,2CAgDC"}
1
+ {"version":3,"file":"class-file-generatorHelper.js","sourceRoot":"","sources":["../../../src/transpiler/markdown/class-file-generatorHelper.ts"],"names":[],"mappings":";;AACA,mEAA+D;AAC/D,6CAA0C;AAC1C,+CAAwC;AACxC,wCAAmD;AAEnD,MAAqB,wBAAwB;IACpC,MAAM,CAAC,iBAAiB,CAAC,UAAgB;QAC9C,OAAO,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC5E,CAAC;IAEM,MAAM,CAAC,WAAW,CAAC,UAAgB;QACxC,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACxD,OAAO,IAAI,UAAU,CAAC,IAAI,KAAK,aAAa,GAAG,UAAU,CAAC,IAAI,MAAM,CAAC;IACvE,CAAC;IAEM,MAAM,CAAC,qBAAqB,CAAC,QAAgB;QAClD,MAAM,IAAI,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QACzE,IAAI,CAAC,IAAI,EAAE;YACT,qFAAqF;YACrF,OAAO,IAAI,QAAQ,KAAK,QAAQ,GAAG,CAAC;SACrC;QAED,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,UAAgB;QAC9C,iEAAiE;QACjE,MAAM,SAAS,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC,eAAe,CAAC;QACzD,IAAI,+BAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,kBAAkB,EAAE,KAAK,eAAe,EAAE;YACjF,OAAO,IAAI,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,GAAG,CAAC;SAClD;QAED,uDAAuD;QACvD,MAAM,kBAAkB,GAAG,eAAK,CAAC,WAAW,EAAE,CAAC,qBAAqB,EAAE,CAAC;QACvE,IAAI,kBAAkB,EAAE;YACtB,IAAI,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE;gBAC7E,yEAAyE;gBACzE,OAAO,IAAI,CAAC;aACb;iBAAM;gBACL,uEAAuE;gBACvE,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,GAAG,CAAC;aACpD;SACF;aAAM;YACL,sGAAsG;YACtG,OAAO,KAAK,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,GAAG,CAAC;SACnD;IACH,CAAC;IAEO,MAAM,CAAC,aAAa,CAAC,UAAgB;;QAC3C,MAAM,eAAe,GAAG,MAAA,UAAU,CAAC,UAAU,0CAAE,WAAW,CAAC,IAAI,CAC7D,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,OAAO,CAC1D,CAAC;QACF,OAAO,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,IAAI,mCAAI,mBAAQ,CAAC,WAAW,EAAE,CAAC,mBAAmB,EAAE,CAAC;IAC/E,CAAC;CACF;AAjDD,2CAiDC"}
@@ -0,0 +1,12 @@
1
+ import ProcessorTypeTranspiler from '../processor-type-transpiler';
2
+ import { FileContainer } from '../file-container';
3
+ import { Type } from '@cparra/apex-reflection';
4
+ import { OpenApi } from '../../model/openapi/open-api';
5
+ export declare class OpenApiDocsProcessor extends ProcessorTypeTranspiler {
6
+ protected readonly _fileContainer: FileContainer;
7
+ openApiModel: OpenApi;
8
+ constructor();
9
+ fileBuilder(): FileContainer;
10
+ onProcess(type: Type): void;
11
+ private getEndpointPath;
12
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenApiDocsProcessor = void 0;
4
+ const processor_type_transpiler_1 = require("../processor-type-transpiler");
5
+ const file_container_1 = require("../file-container");
6
+ const openapi_type_file_1 = require("../../model/openapi/openapi-type-file");
7
+ const logger_1 = require("../../util/logger");
8
+ const open_api_1 = require("../../model/openapi/open-api");
9
+ const settings_1 = require("../../settings");
10
+ const MethodParser_1 = require("./parsers/MethodParser");
11
+ class OpenApiDocsProcessor extends processor_type_transpiler_1.default {
12
+ constructor() {
13
+ super();
14
+ this._fileContainer = new file_container_1.FileContainer();
15
+ const title = settings_1.Settings.getInstance().getOpenApiTitle();
16
+ if (!title) {
17
+ throw Error('No OpenApi title was provided.');
18
+ }
19
+ this.openApiModel = new open_api_1.OpenApi(title, '1.0.0');
20
+ }
21
+ fileBuilder() {
22
+ return this._fileContainer;
23
+ }
24
+ onProcess(type) {
25
+ var _a;
26
+ logger_1.Logger.logSingle(`Processing ${type.name}`, false, 'green', false);
27
+ const endpointPath = this.getEndpointPath(type);
28
+ if (!endpointPath) {
29
+ return;
30
+ }
31
+ this.openApiModel.paths[endpointPath] = {};
32
+ if ((_a = type.docComment) === null || _a === void 0 ? void 0 : _a.description) {
33
+ this.openApiModel.paths[endpointPath].description = type.docComment.description;
34
+ }
35
+ // We can safely cast to a ClassMirror, since only these support the @RestResource annotation
36
+ const typeAsClass = type;
37
+ const parser = new MethodParser_1.MethodParser(this.openApiModel);
38
+ // GET
39
+ parser.parseMethod(typeAsClass, endpointPath, 'get');
40
+ // PATCH
41
+ parser.parseMethod(typeAsClass, endpointPath, 'patch');
42
+ // POST
43
+ parser.parseMethod(typeAsClass, endpointPath, 'post');
44
+ // PUT
45
+ parser.parseMethod(typeAsClass, endpointPath, 'put');
46
+ // DELETE
47
+ parser.parseMethod(typeAsClass, endpointPath, 'delete');
48
+ this._fileContainer.pushFile(new openapi_type_file_1.OpenapiTypeFile(this.openApiModel));
49
+ }
50
+ getEndpointPath(type) {
51
+ var _a;
52
+ const restResourceAnnotation = type.annotations.find((element) => element.name.toLowerCase() === 'restresource');
53
+ const urlMapping = (_a = restResourceAnnotation === null || restResourceAnnotation === void 0 ? void 0 : restResourceAnnotation.elementValues) === null || _a === void 0 ? void 0 : _a.find((element) => element.key.toLowerCase() === 'urlmapping');
54
+ if (!urlMapping) {
55
+ logger_1.Logger.error(`Type does not contain urlMapping annotation ${type.name}`);
56
+ return null;
57
+ }
58
+ return urlMapping.value.replaceAll('"', '').replaceAll("'", '');
59
+ }
60
+ }
61
+ exports.OpenApiDocsProcessor = OpenApiDocsProcessor;
62
+ //# sourceMappingURL=open-api-docs-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-api-docs-processor.js","sourceRoot":"","sources":["../../../src/transpiler/openapi/open-api-docs-processor.ts"],"names":[],"mappings":";;;AAAA,4EAAmE;AACnE,sDAAkD;AAElD,6EAAwE;AACxE,8CAA2C;AAC3C,2DAAuD;AACvD,6CAA0C;AAC1C,yDAAsD;AAEtD,MAAa,oBAAqB,SAAQ,mCAAuB;IAI/D;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,cAAc,GAAG,IAAI,8BAAa,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC,eAAe,EAAE,CAAC;QACvD,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,KAAK,CAAC,gCAAgC,CAAC,CAAC;SAC/C;QACD,IAAI,CAAC,YAAY,GAAG,IAAI,kBAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,SAAS,CAAC,IAAU;;QAClB,eAAM,CAAC,SAAS,CAAC,cAAc,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEnE,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,YAAY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C,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,YAAY,CACxD,CAAC;QACF,IAAI,CAAC,UAAU,EAAE;YACf,eAAM,CAAC,KAAK,CAAC,+CAA+C,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACzE,OAAO,IAAI,CAAC;SACb;QAED,OAAO,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;CACF;AAlED,oDAkEC"}
@@ -0,0 +1,16 @@
1
+ import { Reference } from './ReferenceBuilder';
2
+ import { ApexDocSchemaObject } from '../../../model/openapi/apex-doc-types';
3
+ import { SchemaObject } from '../../../model/openapi/open-api-types';
4
+ export type ApexDocSchemaAware = {
5
+ schema: ApexDocSchemaObject;
6
+ };
7
+ export declare abstract class Builder<T, K> {
8
+ build(schemaAware: ApexDocSchemaAware): Response<T>;
9
+ abstract buildBody(apexDocObject: K, reference?: Reference): T;
10
+ protected getOpenApiSchemaFromApexDocSchema(schemaAware: ApexDocSchemaAware, reference?: Reference): SchemaObject;
11
+ private isReferenceString;
12
+ }
13
+ export interface Response<T> {
14
+ reference?: Reference;
15
+ body: T;
16
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Builder = void 0;
4
+ const ReferenceBuilder_1 = require("./ReferenceBuilder");
5
+ class Builder {
6
+ constructor() {
7
+ this.isReferenceString = (targetObject) => {
8
+ return typeof targetObject === 'string' || targetObject instanceof String;
9
+ };
10
+ }
11
+ build(schemaAware) {
12
+ let reference;
13
+ if (this.isReferenceString(schemaAware.schema)) {
14
+ reference = new ReferenceBuilder_1.ReferenceBuilder().build(schemaAware.schema);
15
+ }
16
+ return {
17
+ reference: reference,
18
+ body: this.buildBody(schemaAware, reference),
19
+ };
20
+ }
21
+ getOpenApiSchemaFromApexDocSchema(schemaAware, reference) {
22
+ if (this.isReferenceString(schemaAware.schema)) {
23
+ // We are dealing with a reference
24
+ return reference.entrypointReferenceObject;
25
+ }
26
+ return schemaAware.schema;
27
+ }
28
+ }
29
+ exports.Builder = Builder;
30
+ //# sourceMappingURL=Builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Builder.js","sourceRoot":"","sources":["../../../../src/transpiler/openapi/parsers/Builder.ts"],"names":[],"mappings":";;;AAAA,yDAAiE;AAQjE,MAAsB,OAAO;IAA7B;QAuBU,sBAAiB,GAAG,CAAC,YAAiB,EAA0B,EAAE;YACxE,OAAO,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,YAAY,MAAM,CAAC;QAC5E,CAAC,CAAC;IACJ,CAAC;IAzBC,KAAK,CAAC,WAA+B;QACnC,IAAI,SAAgC,CAAC;QACrC,IAAI,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE;YAC9C,SAAS,GAAG,IAAI,mCAAgB,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;SAC9D;QAED,OAAO;YACL,SAAS,EAAE,SAAS;YACpB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,WAAgB,EAAE,SAAS,CAAC;SAClD,CAAC;IACJ,CAAC;IAIS,iCAAiC,CAAC,WAA+B,EAAE,SAAqB;QAChG,IAAI,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE;YAC9C,kCAAkC;YAClC,OAAO,SAAU,CAAC,yBAAyB,CAAC;SAC7C;QACD,OAAO,WAAW,CAAC,MAAM,CAAC;IAC5B,CAAC;CAKF;AA1BD,0BA0BC"}
@@ -0,0 +1,17 @@
1
+ import { ClassMirror } from '@cparra/apex-reflection';
2
+ import { OpenApi } from '../../../model/openapi/open-api';
3
+ type HttpOperations = 'get' | 'put' | 'post' | 'delete' | 'patch';
4
+ /**
5
+ * Parses ApexDocs with HTTP REST annotations and turns them into an OpenApi specification.
6
+ */
7
+ export declare class MethodParser {
8
+ openApiModel: OpenApi;
9
+ constructor(openApiModel: OpenApi);
10
+ parseMethod(classMirror: ClassMirror, httpUrlEndpoint: string, httpMethodKey: HttpOperations): void;
11
+ private parseHttpAnnotation;
12
+ private addRequestBodyToOpenApi;
13
+ private addParametersToOpenApi;
14
+ private addHttpResponsesToOpenApi;
15
+ private addReference;
16
+ }
17
+ export {};
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MethodParser = void 0;
4
+ const yaml = require("js-yaml");
5
+ const ClassMirrorWrapper_1 = require("../../../model/apex-type-wrappers/ClassMirrorWrapper");
6
+ const ParameterObjectBuilder_1 = require("./ParameterObjectBuilder");
7
+ const ResponsesBuilder_1 = require("./ResponsesBuilder");
8
+ const RequestBodyBuilder_1 = require("./RequestBodyBuilder");
9
+ /**
10
+ * Parses ApexDocs with HTTP REST annotations and turns them into an OpenApi specification.
11
+ */
12
+ class MethodParser {
13
+ constructor(openApiModel) {
14
+ this.openApiModel = openApiModel;
15
+ }
16
+ parseMethod(classMirror, httpUrlEndpoint, httpMethodKey) {
17
+ var _a;
18
+ const classMirrorWrapper = new ClassMirrorWrapper_1.ClassMirrorWrapper(classMirror);
19
+ // Apex supports HttpGet, HttpPut, HttpPost, HttpDelete, and HttpPatch, so we search for a method
20
+ // that has one of those annotations.
21
+ const httpMethods = classMirrorWrapper.getMethodsByAnnotation(`http${httpMethodKey}`);
22
+ if (!httpMethods.length) {
23
+ return;
24
+ }
25
+ // We can assume there is at most one method per annotation, as this is an Apex rule.
26
+ const httpMethod = httpMethods[0];
27
+ this.openApiModel.paths[httpUrlEndpoint][httpMethodKey] = {};
28
+ if ((_a = httpMethod.docComment) === null || _a === void 0 ? void 0 : _a.description) {
29
+ this.openApiModel.paths[httpUrlEndpoint][httpMethodKey].description = httpMethod.docComment.description;
30
+ }
31
+ this.parseHttpAnnotation(httpMethod, httpUrlEndpoint, 'http-request-body', (inYaml, urlValue) => this.addRequestBodyToOpenApi(inYaml, urlValue, httpMethodKey));
32
+ this.parseHttpAnnotation(httpMethod, httpUrlEndpoint, 'http-parameter', (inYaml, urlValue) => this.addParametersToOpenApi(inYaml, urlValue, httpMethodKey));
33
+ this.parseHttpAnnotation(httpMethod, httpUrlEndpoint, 'http-response', (inYaml, urlValue) => this.addHttpResponsesToOpenApi(inYaml, urlValue, httpMethodKey));
34
+ }
35
+ parseHttpAnnotation(httpGetMethod, urlValue, annotationName, addToOpenApi) {
36
+ var _a;
37
+ const annotations = (_a = httpGetMethod.docComment) === null || _a === void 0 ? void 0 : _a.annotations.filter((annotation) => annotation.name === annotationName);
38
+ if (!(annotations === null || annotations === void 0 ? void 0 : annotations.length)) {
39
+ return;
40
+ }
41
+ for (const annotation of annotations) {
42
+ // We expect the ApexDoc data representing this to be in YAML format.
43
+ const inYaml = annotation === null || annotation === void 0 ? void 0 : annotation.bodyLines.reduce((prev, current, _) => prev + '\n' + current);
44
+ if (!inYaml) {
45
+ return;
46
+ }
47
+ addToOpenApi(inYaml, urlValue);
48
+ }
49
+ }
50
+ addRequestBodyToOpenApi(inYaml, urlValue, httpMethodKey) {
51
+ // Convert the YAML into a JSON object.
52
+ const inJson = yaml.load(inYaml);
53
+ const requestBodyResponse = new RequestBodyBuilder_1.RequestBodyBuilder().build(inJson);
54
+ this.openApiModel.paths[urlValue][httpMethodKey].requestBody = requestBodyResponse.body;
55
+ if (requestBodyResponse.reference) {
56
+ // If a reference is returned, we want to make sure to add it to the OpenApi object as well
57
+ this.addReference(requestBodyResponse.reference);
58
+ }
59
+ }
60
+ addParametersToOpenApi(inYaml, urlValue, httpMethodKey) {
61
+ // Convert the YAML into a JSON object.
62
+ const inJson = yaml.load(inYaml);
63
+ const parameterObjectResponse = new ParameterObjectBuilder_1.ParameterObjectBuilder().build(inJson);
64
+ if (this.openApiModel.paths[urlValue][httpMethodKey].parameters === undefined) {
65
+ // If no parameters have been defined yet, initialize the list.
66
+ this.openApiModel.paths[urlValue][httpMethodKey].parameters = [];
67
+ }
68
+ this.openApiModel.paths[urlValue][httpMethodKey].parameters.push(parameterObjectResponse.body);
69
+ if (parameterObjectResponse.reference) {
70
+ // If a reference is returned, we want to make sure to add it to the OpenApi object as well
71
+ this.addReference(parameterObjectResponse.reference);
72
+ }
73
+ }
74
+ addHttpResponsesToOpenApi(inYaml, urlValue, httpMethodKey) {
75
+ // Convert the YAML into a JSON object.
76
+ const inJson = yaml.load(inYaml);
77
+ const responseObjectResponse = new ResponsesBuilder_1.ResponsesBuilder().build(inJson);
78
+ if (this.openApiModel.paths[urlValue][httpMethodKey].responses === undefined) {
79
+ this.openApiModel.paths[urlValue][httpMethodKey].responses = {};
80
+ }
81
+ this.openApiModel.paths[urlValue][httpMethodKey].responses[inJson.statusCode] = responseObjectResponse.body;
82
+ // TODO: There's some duplication with the next 3 lines, because we do the same in all 3 places
83
+ if (responseObjectResponse.reference) {
84
+ // If a reference is returned, we want to make sure to add it to the OpenApi object as well
85
+ this.addReference(responseObjectResponse.reference);
86
+ }
87
+ }
88
+ addReference(reference) {
89
+ // Add to "component" section if it hasn't been already
90
+ if (this.openApiModel.components === undefined) {
91
+ this.openApiModel.components = {
92
+ schemas: {},
93
+ };
94
+ }
95
+ if (!reference.referenceComponents.length) {
96
+ return;
97
+ }
98
+ // Add all received references to the OpenApi components section.
99
+ reference.referenceComponents.forEach((current) => {
100
+ // Check if the referenced object is already part of the OpenApi object
101
+ this.openApiModel.components.schemas[current.referencedClass] = current.schema;
102
+ });
103
+ }
104
+ }
105
+ exports.MethodParser = MethodParser;
106
+ //# sourceMappingURL=MethodParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MethodParser.js","sourceRoot":"","sources":["../../../../src/transpiler/openapi/parsers/MethodParser.ts"],"names":[],"mappings":";;;AAEA,gCAAgC;AAChC,6FAA0F;AAE1F,qEAAkE;AAClE,yDAAsD;AAMtD,6DAA0D;AAM1D;;GAEG;AACH,MAAa,YAAY;IACvB,YAAmB,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AAG,sBAAsB,CAAC,IAAI,CAAC;QAC9G,+FAA+F;QAC/F,IAAI,sBAAsB,CAAC,SAAS,EAAE;YACpC,2FAA2F;YAC3F,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC;SACrD;IACH,CAAC;IAEO,YAAY,CAAC,SAAoB;QACvC,uDAAuD;QACvD,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,KAAK,SAAS,EAAE;YAC9C,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG;gBAC7B,OAAO,EAAE,EAAE;aACZ,CAAC;SACH;QAED,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE;YACzC,OAAO;SACR;QAED,iEAAiE;QACjE,SAAS,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAChD,uEAAuE;YACvE,IAAI,CAAC,YAAY,CAAC,UAAW,CAAC,OAAQ,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;QACnF,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAxHD,oCAwHC"}
@@ -0,0 +1,7 @@
1
+ import { ParameterObject } from '../../../model/openapi/open-api-types';
2
+ import { Reference } from './ReferenceBuilder';
3
+ import { ApexDocParameterObject } from '../../../model/openapi/apex-doc-types';
4
+ import { Builder } from './Builder';
5
+ export declare class ParameterObjectBuilder extends Builder<ParameterObject, ApexDocParameterObject> {
6
+ buildBody(apexDocObject: ApexDocParameterObject, reference?: Reference): ParameterObject;
7
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParameterObjectBuilder = void 0;
4
+ const Builder_1 = require("./Builder");
5
+ class ParameterObjectBuilder extends Builder_1.Builder {
6
+ buildBody(apexDocObject, reference) {
7
+ return Object.assign(Object.assign({}, apexDocObject), { schema: this.getOpenApiSchemaFromApexDocSchema(apexDocObject, reference) });
8
+ }
9
+ }
10
+ exports.ParameterObjectBuilder = ParameterObjectBuilder;
11
+ //# sourceMappingURL=ParameterObjectBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParameterObjectBuilder.js","sourceRoot":"","sources":["../../../../src/transpiler/openapi/parsers/ParameterObjectBuilder.ts"],"names":[],"mappings":";;;AAGA,uCAAoC;AAEpC,MAAa,sBAAuB,SAAQ,iBAAgD;IAC1F,SAAS,CAAC,aAAqC,EAAE,SAAqB;QACpE,uCACK,aAAa,KAChB,MAAM,EAAE,IAAI,CAAC,iCAAiC,CAAC,aAAa,EAAE,SAAS,CAAC,IACxE;IACJ,CAAC;CACF;AAPD,wDAOC"}
@@ -0,0 +1,31 @@
1
+ import { ReferenceObject, SchemaObjectArray, SchemaObjectObject } from '../../../model/openapi/open-api-types';
2
+ export declare class ReferenceBuilder {
3
+ build(referencedTypeName: string): Reference;
4
+ /**
5
+ * Returns a tuple where the first value is the name of the reference without any collection related values
6
+ * and the second is a boolean representing if we are dealing with a collection or not.
7
+ * @param referencedTypeName The received raw type name.
8
+ * @private
9
+ */
10
+ private handlePossibleCollectionReference;
11
+ private buildReferenceFromType;
12
+ private getReferenceName;
13
+ private buildMainReferenceComponent;
14
+ private getReferenceType;
15
+ private buildCollectionPair;
16
+ }
17
+ /**
18
+ * In case where the Request Body contains a reference, this contains information about the handled reference
19
+ */
20
+ export type Reference = {
21
+ /** OpenApi style reference object for the parent caller */
22
+ entrypointReferenceObject: ReferenceObject;
23
+ /** List of objects that contain all component references identified by a call to this builder **/
24
+ referenceComponents: ReferenceComponent[];
25
+ };
26
+ export type ReferenceComponent = {
27
+ /** Name of the class being referenced */
28
+ referencedClass: string;
29
+ /** Parsed representation of the referenced object as an OpenApi Schema object */
30
+ schema: SchemaObjectObject | SchemaObjectArray;
31
+ };