@cparra/apexdocs 3.0.0 → 3.1.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 (264) hide show
  1. package/README.md +11 -5
  2. package/dist/cli/generate.js +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/logger-BATX7-be.js +3278 -0
  5. package/package.json +4 -1
  6. package/.github/workflows/ci.yaml +0 -22
  7. package/.github/workflows/close_stale.yml +0 -22
  8. package/.prettierrc.js +0 -7
  9. package/__mocks__/chalk.js +0 -12
  10. package/__mocks__/log-update.js +0 -6
  11. package/eslint.config.mjs +0 -10
  12. package/examples/README.md +0 -5
  13. package/examples/docsify/README.md +0 -17
  14. package/examples/docsify/apexdocs.config.ts +0 -13
  15. package/examples/docsify/classes/ASampleClass.cls +0 -57
  16. package/examples/docsify/classes/CodeControl.cls +0 -19
  17. package/examples/docsify/classes/SampleClass.cls +0 -95
  18. package/examples/docsify/classes/SampleInterface.cls +0 -17
  19. package/examples/docsify/classes/SomeDto.cls +0 -122
  20. package/examples/docsify/docs/.nojekyll +0 -0
  21. package/examples/docsify/docs/README.md +0 -25
  22. package/examples/docsify/docs/_config.yml +0 -1
  23. package/examples/docsify/docs/index.html +0 -22
  24. package/examples/docsify/docs/miscellaneous/ASampleClass.md +0 -88
  25. package/examples/docsify/docs/miscellaneous/CodeControl.md +0 -107
  26. package/examples/docsify/docs/miscellaneous/SomeDto.md +0 -244
  27. package/examples/docsify/docs/sample-classes/SampleClass.md +0 -171
  28. package/examples/docsify/docs/sample-interfaces/SampleInterface.md +0 -36
  29. package/examples/docsify/package-lock.json +0 -2459
  30. package/examples/docsify/package.json +0 -14
  31. package/examples/imported/.forceignore +0 -12
  32. package/examples/imported/README.md +0 -6
  33. package/examples/imported/config/project-scratch-def.json +0 -5
  34. package/examples/imported/docs/index.md +0 -109
  35. package/examples/imported/docs/miscellaneous/BaseClass.md +0 -13
  36. package/examples/imported/docs/miscellaneous/MultiInheritanceClass.md +0 -69
  37. package/examples/imported/docs/miscellaneous/ParentInterface.md +0 -12
  38. package/examples/imported/docs/miscellaneous/ReferencedEnum.md +0 -5
  39. package/examples/imported/docs/miscellaneous/SampleException.md +0 -21
  40. package/examples/imported/docs/miscellaneous/SampleInterface.md +0 -113
  41. package/examples/imported/docs/miscellaneous/Url.md +0 -308
  42. package/examples/imported/docs/sample-enums/SampleEnum.md +0 -33
  43. package/examples/imported/docs/samplegroup/SampleClass.md +0 -167
  44. package/examples/imported/force-app/classes/BaseClass.cls +0 -3
  45. package/examples/imported/force-app/classes/MultiInheritanceClass.cls +0 -1
  46. package/examples/imported/force-app/classes/ParentInterface.cls +0 -3
  47. package/examples/imported/force-app/classes/ReferencedEnum.cls +0 -3
  48. package/examples/imported/force-app/classes/SampleClass.cls +0 -72
  49. package/examples/imported/force-app/classes/SampleEnum.cls +0 -30
  50. package/examples/imported/force-app/classes/SampleException.cls +0 -17
  51. package/examples/imported/force-app/classes/SampleInterface.cls +0 -50
  52. package/examples/imported/force-app/classes/Url.cls +0 -196
  53. package/examples/imported/package-lock.json +0 -665
  54. package/examples/imported/package.json +0 -6
  55. package/examples/imported/scripts/process-docs.mjs +0 -16
  56. package/examples/imported/sfdx-project.json +0 -12
  57. package/examples/markdown/.forceignore +0 -12
  58. package/examples/markdown/README.md +0 -7
  59. package/examples/markdown/config/project-scratch-def.json +0 -5
  60. package/examples/markdown/docs/index.md +0 -109
  61. package/examples/markdown/docs/miscellaneous/BaseClass.md +0 -16
  62. package/examples/markdown/docs/miscellaneous/MultiInheritanceClass.md +0 -72
  63. package/examples/markdown/docs/miscellaneous/ParentInterface.md +0 -15
  64. package/examples/markdown/docs/miscellaneous/ReferencedEnum.md +0 -8
  65. package/examples/markdown/docs/miscellaneous/SampleException.md +0 -24
  66. package/examples/markdown/docs/miscellaneous/SampleInterface.md +0 -116
  67. package/examples/markdown/docs/miscellaneous/Url.md +0 -311
  68. package/examples/markdown/docs/sample-enums/SampleEnum.md +0 -36
  69. package/examples/markdown/docs/samplegroup/SampleClass.md +0 -170
  70. package/examples/markdown/force-app/classes/BaseClass.cls +0 -3
  71. package/examples/markdown/force-app/classes/MultiInheritanceClass.cls +0 -1
  72. package/examples/markdown/force-app/classes/ParentInterface.cls +0 -3
  73. package/examples/markdown/force-app/classes/ReferencedEnum.cls +0 -3
  74. package/examples/markdown/force-app/classes/SampleClass.cls +0 -72
  75. package/examples/markdown/force-app/classes/SampleEnum.cls +0 -30
  76. package/examples/markdown/force-app/classes/SampleException.cls +0 -17
  77. package/examples/markdown/force-app/classes/SampleInterface.cls +0 -50
  78. package/examples/markdown/force-app/classes/Url.cls +0 -196
  79. package/examples/markdown/package-lock.json +0 -665
  80. package/examples/markdown/package.json +0 -20
  81. package/examples/markdown/sfdx-project.json +0 -12
  82. package/examples/markdown-jsconfig/.forceignore +0 -12
  83. package/examples/markdown-jsconfig/README.md +0 -9
  84. package/examples/markdown-jsconfig/apexdocs.config.mjs +0 -22
  85. package/examples/markdown-jsconfig/config/project-scratch-def.json +0 -5
  86. package/examples/markdown-jsconfig/docs/index.md +0 -12
  87. package/examples/markdown-jsconfig/docs/miscellaneous/Url.md +0 -315
  88. package/examples/markdown-jsconfig/force-app/classes/Url.cls +0 -196
  89. package/examples/markdown-jsconfig/package-lock.json +0 -665
  90. package/examples/markdown-jsconfig/package.json +0 -15
  91. package/examples/markdown-jsconfig/sfdx-project.json +0 -12
  92. package/examples/open-api/README.md +0 -5
  93. package/examples/open-api/config/project-scratch-def.json +0 -13
  94. package/examples/open-api/docs/openapi.json +0 -14
  95. package/examples/open-api/force-app/main/default/classes/ChildClass.cls +0 -42
  96. package/examples/open-api/force-app/main/default/classes/SampleClass.cls +0 -167
  97. package/examples/open-api/force-app/main/default/restapi/SampleRestResource.cls +0 -195
  98. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceToSkip.cls +0 -35
  99. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithInnerClass.cls +0 -24
  100. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithoutApexDocs.cls +0 -15
  101. package/examples/open-api/force-app/main/default/restapi/references/Reference1.cls +0 -9
  102. package/examples/open-api/force-app/main/default/restapi/references/Reference2.cls +0 -9
  103. package/examples/open-api/force-app/main/default/restapi/references/Reference3.cls +0 -3
  104. package/examples/open-api/force-app/main/default/restapi/references/Reference4.cls +0 -3
  105. package/examples/open-api/force-app/main/default/restapi/references/Reference5.cls +0 -3
  106. package/examples/open-api/force-app/main/default/restapi/references/Reference6.cls +0 -6
  107. package/examples/open-api/force-app/main/default/restapi/references/Reference7.cls +0 -3
  108. package/examples/open-api/package-lock.json +0 -724
  109. package/examples/open-api/package.json +0 -20
  110. package/examples/open-api/sfdx-project.json +0 -12
  111. package/examples/vitepress/.forceignore +0 -12
  112. package/examples/vitepress/README.md +0 -25
  113. package/examples/vitepress/apexdocs.config.ts +0 -113
  114. package/examples/vitepress/config/project-scratch-def.json +0 -13
  115. package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js +0 -259
  116. package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
  117. package/examples/vitepress/docs/.vitepress/cache/deps/_metadata.json +0 -40
  118. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js +0 -11474
  119. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js.map +0 -7
  120. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js +0 -9172
  121. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js.map +0 -7
  122. package/examples/vitepress/docs/.vitepress/cache/deps/package.json +0 -3
  123. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4339
  124. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
  125. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -567
  126. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
  127. package/examples/vitepress/docs/.vitepress/cache/deps/vue.js +0 -323
  128. package/examples/vitepress/docs/.vitepress/cache/deps/vue.js.map +0 -7
  129. package/examples/vitepress/docs/.vitepress/config.mts +0 -21
  130. package/examples/vitepress/docs/.vitepress/sidebar.json +0 -119
  131. package/examples/vitepress/docs/api-examples.md +0 -49
  132. package/examples/vitepress/docs/index-frontmatter.md +0 -16
  133. package/examples/vitepress/docs/index.md +0 -56
  134. package/examples/vitepress/docs/markdown-examples.md +0 -85
  135. package/examples/vitepress/docs/miscellaneous/BaseClass.md +0 -20
  136. package/examples/vitepress/docs/miscellaneous/MultiInheritanceClass.md +0 -76
  137. package/examples/vitepress/docs/miscellaneous/ParentInterface.md +0 -19
  138. package/examples/vitepress/docs/miscellaneous/ReferencedEnum.md +0 -15
  139. package/examples/vitepress/docs/miscellaneous/SampleException.md +0 -28
  140. package/examples/vitepress/docs/miscellaneous/SampleInterface.md +0 -116
  141. package/examples/vitepress/docs/miscellaneous/Url.md +0 -317
  142. package/examples/vitepress/docs/sample-enums/SampleEnum.md +0 -40
  143. package/examples/vitepress/docs/samplegroup/SampleClass.md +0 -174
  144. package/examples/vitepress/force-app/main/default/classes/BaseClass.cls +0 -3
  145. package/examples/vitepress/force-app/main/default/classes/MultiInheritanceClass.cls +0 -1
  146. package/examples/vitepress/force-app/main/default/classes/ParentInterface.cls +0 -3
  147. package/examples/vitepress/force-app/main/default/classes/ReferencedEnum.cls +0 -5
  148. package/examples/vitepress/force-app/main/default/classes/Url.cls +0 -198
  149. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleClass.cls +0 -73
  150. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleEnum.cls +0 -30
  151. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleException.cls +0 -17
  152. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleInterface.cls +0 -46
  153. package/examples/vitepress/package-lock.json +0 -2574
  154. package/examples/vitepress/package.json +0 -18
  155. package/examples/vitepress/sfdx-project.json +0 -12
  156. package/jest.config.js +0 -10
  157. package/jest.d.ts +0 -7
  158. package/src/application/Apexdocs.ts +0 -69
  159. package/src/application/__tests__/apex-file-reader.spec.ts +0 -128
  160. package/src/application/apex-file-reader.ts +0 -56
  161. package/src/application/file-system.ts +0 -69
  162. package/src/application/file-writer.ts +0 -43
  163. package/src/application/generators/markdown.ts +0 -45
  164. package/src/application/generators/openapi.ts +0 -75
  165. package/src/cli/args.ts +0 -55
  166. package/src/cli/commands/markdown.ts +0 -56
  167. package/src/cli/commands/openapi.ts +0 -36
  168. package/src/cli/generate.ts +0 -32
  169. package/src/core/__test__/manifest.spec.ts +0 -16
  170. package/src/core/manifest.ts +0 -90
  171. package/src/core/markdown/__test__/expect-extensions.ts +0 -32
  172. package/src/core/markdown/__test__/generating-class-docs.spec.ts +0 -362
  173. package/src/core/markdown/__test__/generating-docs.spec.ts +0 -378
  174. package/src/core/markdown/__test__/generating-enum-docs.spec.ts +0 -61
  175. package/src/core/markdown/__test__/generating-interface-docs.spec.ts +0 -169
  176. package/src/core/markdown/__test__/generating-reference-guide.spec.ts +0 -196
  177. package/src/core/markdown/__test__/inheritance-chain.test.ts +0 -54
  178. package/src/core/markdown/__test__/test-helpers.ts +0 -25
  179. package/src/core/markdown/adapters/__tests__/documentables.spec.ts +0 -109
  180. package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +0 -150
  181. package/src/core/markdown/adapters/__tests__/link-generator.spec.ts +0 -130
  182. package/src/core/markdown/adapters/__tests__/references.spec.ts +0 -136
  183. package/src/core/markdown/adapters/apex-types.ts +0 -238
  184. package/src/core/markdown/adapters/documentables.ts +0 -115
  185. package/src/core/markdown/adapters/fields-and-properties.ts +0 -45
  186. package/src/core/markdown/adapters/generate-link.ts +0 -82
  187. package/src/core/markdown/adapters/inline.ts +0 -143
  188. package/src/core/markdown/adapters/methods-and-constructors.ts +0 -133
  189. package/src/core/markdown/adapters/reference-guide.ts +0 -37
  190. package/src/core/markdown/adapters/renderable-bundle.ts +0 -61
  191. package/src/core/markdown/adapters/renderable-to-page-data.ts +0 -91
  192. package/src/core/markdown/adapters/type-utils.ts +0 -13
  193. package/src/core/markdown/adapters/types.d.ts +0 -180
  194. package/src/core/markdown/generate-docs.ts +0 -210
  195. package/src/core/markdown/reflection/__test__/filter-scope.spec.ts +0 -290
  196. package/src/core/markdown/reflection/__test__/helpers.ts +0 -18
  197. package/src/core/markdown/reflection/__test__/remove-excluded-tags.spec.ts +0 -200
  198. package/src/core/markdown/reflection/filter-scope.ts +0 -13
  199. package/src/core/markdown/reflection/inheritance-chain-expanion.ts +0 -22
  200. package/src/core/markdown/reflection/inheritance-chain.ts +0 -23
  201. package/src/core/markdown/reflection/inherited-member-expansion.ts +0 -105
  202. package/src/core/markdown/reflection/reflect-source.ts +0 -123
  203. package/src/core/markdown/reflection/remove-excluded-tags.ts +0 -168
  204. package/src/core/markdown/reflection/sort-types-and-members.ts +0 -61
  205. package/src/core/markdown/templates/class-template.ts +0 -75
  206. package/src/core/markdown/templates/constructors-partial-template.ts +0 -32
  207. package/src/core/markdown/templates/documentable-partial-template.ts +0 -26
  208. package/src/core/markdown/templates/enum-template.ts +0 -12
  209. package/src/core/markdown/templates/fieldsPartialTemplate.ts +0 -23
  210. package/src/core/markdown/templates/grouped-members-partial-template.ts +0 -6
  211. package/src/core/markdown/templates/hookable.ts +0 -7
  212. package/src/core/markdown/templates/interface-template.ts +0 -16
  213. package/src/core/markdown/templates/methods-partial-template.ts +0 -43
  214. package/src/core/markdown/templates/reference-guide.ts +0 -14
  215. package/src/core/markdown/templates/template.ts +0 -114
  216. package/src/core/markdown/templates/type-doc-partial.ts +0 -27
  217. package/src/core/markdown/utils.ts +0 -3
  218. package/src/core/openApiSettings.ts +0 -41
  219. package/src/core/openapi/__tests__/manifest-factory.spec.ts +0 -16
  220. package/src/core/openapi/__tests__/open-api-docs-processor.spec.ts +0 -59
  221. package/src/core/openapi/__tests__/open-api.spec.ts +0 -22
  222. package/src/core/openapi/apex-doc-types.ts +0 -26
  223. package/src/core/openapi/apex-type-wrappers/ClassMirrorWrapper.ts +0 -12
  224. package/src/core/openapi/apex-type-wrappers/MethodMirrorWrapper.ts +0 -11
  225. package/src/core/openapi/apex-type-wrappers/__tests__/ClassMirrorWrapper.spec.ts +0 -15
  226. package/src/core/openapi/file-container.ts +0 -13
  227. package/src/core/openapi/manifest-factory.ts +0 -16
  228. package/src/core/openapi/open-api-docs-processor.ts +0 -93
  229. package/src/core/openapi/open-api-types.ts +0 -119
  230. package/src/core/openapi/open-api.ts +0 -45
  231. package/src/core/openapi/openapi-type-file.ts +0 -12
  232. package/src/core/openapi/parser.ts +0 -163
  233. package/src/core/openapi/parsers/Builder.ts +0 -40
  234. package/src/core/openapi/parsers/MethodParser.ts +0 -249
  235. package/src/core/openapi/parsers/ParameterObjectBuilder.ts +0 -13
  236. package/src/core/openapi/parsers/ReferenceBuilder.ts +0 -299
  237. package/src/core/openapi/parsers/RequestBodyBuilder.ts +0 -19
  238. package/src/core/openapi/parsers/ResponsesBuilder.ts +0 -21
  239. package/src/core/openapi/parsers/__tests__/MethodParser.spec.ts +0 -44
  240. package/src/core/openapi/parsers/__tests__/ParameterObjectBuilder.spec.ts +0 -68
  241. package/src/core/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +0 -751
  242. package/src/core/openapi/parsers/__tests__/RequestBodyBuilder.spec.ts +0 -64
  243. package/src/core/openapi/parsers/__tests__/ResponsesBuilder.spec.ts +0 -55
  244. package/src/core/openapi/transpiler.ts +0 -17
  245. package/src/core/openapi/types-repository.ts +0 -54
  246. package/src/core/parse-apex-metadata.ts +0 -30
  247. package/src/core/shared/types.d.ts +0 -150
  248. package/src/core/shared/utils.ts +0 -5
  249. package/src/defaults.ts +0 -21
  250. package/src/index.ts +0 -110
  251. package/src/test-helpers/AnnotationBuilder.ts +0 -29
  252. package/src/test-helpers/ClassMirrorBuilder.ts +0 -69
  253. package/src/test-helpers/DocCommentAnnotationBuilder.ts +0 -24
  254. package/src/test-helpers/DocCommentBuilder.ts +0 -36
  255. package/src/test-helpers/FieldMirrorBuilder.ts +0 -59
  256. package/src/test-helpers/InterfaceMirrorBuilder.ts +0 -39
  257. package/src/test-helpers/MethodMirrorBuilder.ts +0 -77
  258. package/src/test-helpers/SettingsBuilder.ts +0 -17
  259. package/src/util/error-logger.ts +0 -92
  260. package/src/util/fp.ts +0 -3
  261. package/src/util/logger.ts +0 -51
  262. package/src/util/string-utils.ts +0 -7
  263. package/tsconfig.json +0 -25
  264. package/tslint.json +0 -6
@@ -1,64 +0,0 @@
1
- import { RequestBodyBuilder } from '../RequestBodyBuilder';
2
- import { Reference } from '../ReferenceBuilder';
3
- import { ReferenceObject } from '../../../../core/openapi/open-api-types';
4
- import { ApexDocHttpRequestBody } from '../../../../core/openapi/apex-doc-types';
5
-
6
- jest.mock('../ReferenceBuilder', () => {
7
- return {
8
- ReferenceBuilder: jest.fn().mockImplementation(() => {
9
- return {
10
- // eslint-disable-next-line @typescript-eslint/no-empty-function
11
- build: (): Reference => {
12
- return {
13
- referenceComponents: [
14
- {
15
- referencedClass: 'MySampleClass',
16
- schema: {
17
- type: 'string',
18
- },
19
- },
20
- ],
21
- entrypointReferenceObject: {
22
- $ref: '/mySampleClass',
23
- },
24
- };
25
- },
26
- };
27
- }),
28
- };
29
- });
30
-
31
- it('should build a RequestBody based on the received schema', function () {
32
- const apexRequestBody: ApexDocHttpRequestBody = {
33
- description: 'Sample Request Body Description',
34
- required: true,
35
- schema: {
36
- type: 'object',
37
- properties: {
38
- Prop1: {
39
- type: 'string',
40
- description: 'A Property',
41
- },
42
- },
43
- },
44
- };
45
-
46
- const response = new RequestBodyBuilder().build(apexRequestBody);
47
-
48
- expect(response.reference).toBeUndefined();
49
- expect(response.body.description).toBe('Sample Request Body Description');
50
- expect(response.body.required).toBe(true);
51
- expect(response.body.content).toHaveProperty('application/json');
52
- expect(response.body.content['application/json'].schema).toBe(apexRequestBody.schema);
53
- });
54
-
55
- it('should build a RequestBody with a reference when receiving a reference class name', function () {
56
- const apexRequestBody: ApexDocHttpRequestBody = {
57
- schema: 'MyClassName',
58
- };
59
-
60
- const response = new RequestBodyBuilder().build(apexRequestBody);
61
-
62
- expect(response.reference).not.toBeUndefined();
63
- expect((response.body.content['application/json']?.schema as ReferenceObject).$ref).toBe('/mySampleClass');
64
- });
@@ -1,55 +0,0 @@
1
- import { ResponsesBuilder } from '../ResponsesBuilder';
2
- import { Reference } from '../ReferenceBuilder';
3
- import { ApexDocHttpResponse } from '../../../../core/openapi/apex-doc-types';
4
-
5
- jest.mock('../ReferenceBuilder', () => {
6
- return {
7
- ReferenceBuilder: jest.fn().mockImplementation(() => {
8
- return {
9
- // eslint-disable-next-line @typescript-eslint/no-empty-function
10
- build: (): Reference => {
11
- return {
12
- referenceComponents: [
13
- {
14
- referencedClass: 'MySampleClass',
15
- schema: {
16
- type: 'string',
17
- },
18
- },
19
- ],
20
- entrypointReferenceObject: {
21
- $ref: '/mySampleClass',
22
- },
23
- };
24
- },
25
- };
26
- }),
27
- };
28
- });
29
-
30
- it('should build a ResponseObject based on the received schema', function () {
31
- const apexDocResponse: ApexDocHttpResponse = {
32
- statusCode: 200,
33
- schema: {
34
- type: 'string',
35
- },
36
- };
37
-
38
- const response = new ResponsesBuilder().build(apexDocResponse);
39
-
40
- expect(response.reference).toBeUndefined();
41
- expect(response.body.description).toContain('200');
42
- expect(response.body.content).toHaveProperty('application/json');
43
- expect(response.body.content!['application/json'].schema).toBe(apexDocResponse.schema);
44
- });
45
-
46
- it('should build a ResponseObject with a reference', function () {
47
- const apexDocResponse: ApexDocHttpResponse = {
48
- statusCode: 200,
49
- schema: 'SomeClass',
50
- };
51
-
52
- const response = new ResponsesBuilder().build(apexDocResponse);
53
-
54
- expect(response.reference).not.toBeUndefined();
55
- });
@@ -1,17 +0,0 @@
1
- import { Type } from '@cparra/apex-reflection';
2
- import { OpenApiDocsProcessor } from './open-api-docs-processor';
3
-
4
- export default class Transpiler {
5
- static generate(types: Type[], processor: OpenApiDocsProcessor): void {
6
- const sortedTypes = types.sort((apexTypeA, apexTypeB) => {
7
- if (apexTypeA.name < apexTypeB.name) return -1;
8
- if (apexTypeA.name > apexTypeB.name) return 1;
9
- return 0;
10
- });
11
-
12
- sortedTypes.forEach((currentType) => {
13
- processor.onProcess(currentType);
14
- });
15
- processor.onAfterProcess?.(sortedTypes);
16
- }
17
- }
@@ -1,54 +0,0 @@
1
- import { ClassMirror, Type } from '@cparra/apex-reflection';
2
-
3
- export type TypeBundle = { type: Type; isChild: boolean; parentType?: Type };
4
-
5
- export class TypesRepository {
6
- private static instance: TypesRepository;
7
- private allTypes: Type[] = [];
8
-
9
- public static getInstance(): TypesRepository {
10
- if (!TypesRepository.instance) {
11
- TypesRepository.instance = new TypesRepository();
12
- }
13
- return TypesRepository.instance;
14
- }
15
-
16
- public populateAll(types: Type[]) {
17
- this.allTypes = types;
18
- }
19
-
20
- public getFromAllByName(typeName: string): TypeBundle | undefined {
21
- if (typeName.includes('.')) {
22
- // If it includes a dot we are assuming we are dealing with an inner class.
23
- const [parentTypeName, childTypeName] = typeName.split('.');
24
- const parentReference = this.allTypes.find(
25
- (currentType: Type) => currentType.name.toLowerCase() === parentTypeName.toLowerCase(),
26
- );
27
- if (!parentReference || parentReference.type_name !== 'class') {
28
- // If the parent is not found, no reason to keep searching, instead we return undefined.
29
- // Similarly, if the parent is not a class, it means it cannot have children, so we return early.
30
- return undefined;
31
- }
32
-
33
- const parentReferenceAsClass = parentReference as ClassMirror;
34
- const childTypes = [
35
- ...parentReferenceAsClass.classes,
36
- ...parentReferenceAsClass.interfaces,
37
- ...parentReferenceAsClass.enums,
38
- ];
39
- const foundType = childTypes.find((currentType: Type) => currentType.name.toLowerCase() === childTypeName);
40
- if (!foundType) {
41
- return undefined;
42
- }
43
- return { type: foundType, isChild: true, parentType: parentReference };
44
- }
45
-
46
- const foundType = this.allTypes.find(
47
- (currentType: Type) => currentType.name.toLowerCase() === typeName.toLowerCase(),
48
- );
49
- if (!foundType) {
50
- return undefined;
51
- }
52
- return { type: foundType, isChild: false };
53
- }
54
- }
@@ -1,30 +0,0 @@
1
- import { XMLParser } from 'fast-xml-parser';
2
- import * as E from 'fp-ts/Either';
3
- import { pipe } from 'fp-ts/function';
4
-
5
- type ApexMetadata = {
6
- ApexClass: ApexClassMetadata;
7
- };
8
-
9
- type ApexClassMetadata = {
10
- apiVersion: string;
11
- status?: string;
12
- };
13
-
14
- export function parseApexMetadata(input: string) {
15
- return pipe(input, parse, E.map(toMap));
16
- }
17
-
18
- function parse(input: string): E.Either<Error, ApexMetadata> {
19
- return E.tryCatch(() => new XMLParser().parse(input), E.toError);
20
- }
21
-
22
- function toMap(metadata: ApexMetadata): Map<string, string> {
23
- const map = new Map<string, string>();
24
- map.set('apiVersion', String(metadata.ApexClass.apiVersion));
25
- if (metadata.ApexClass.status) {
26
- map.set('status', String(metadata.ApexClass.status));
27
- }
28
-
29
- return map;
30
- }
@@ -1,150 +0,0 @@
1
- import { Type } from '@cparra/apex-reflection';
2
-
3
- type LinkingStrategy =
4
- // Links will be generated using relative paths.
5
- | 'relative'
6
- // No links will be generated.
7
- // If the reference is found, the display name will be used.
8
- // Otherwise, the name
9
- // of the reference itself will be used.
10
- | 'no-link'
11
- // No logic will be applied, the reference path will be used as is.
12
- | 'none';
13
-
14
- export type UserDefinedMarkdownConfig = {
15
- sourceDir: string;
16
- targetGenerator: 'markdown';
17
- targetDir: string;
18
- scope: string[];
19
- namespace?: string;
20
- defaultGroupName: string;
21
- sortAlphabetically: boolean;
22
- includeMetadata: boolean;
23
- linkingStrategy: LinkingStrategy;
24
- excludeTags: string[];
25
- referenceGuideTitle: string;
26
- } & Partial<ConfigurableHooks>;
27
-
28
- export type UserDefinedOpenApiConfig = {
29
- targetGenerator: 'openapi';
30
- sourceDir: string;
31
- targetDir: string;
32
- fileName: string;
33
- namespace?: string;
34
- title: string;
35
- apiVersion: string;
36
- };
37
-
38
- export type UserDefinedConfig = UserDefinedMarkdownConfig | UserDefinedOpenApiConfig;
39
-
40
- export type UnparsedSourceFile = {
41
- filePath: string;
42
- content: string;
43
- metadataContent: string | null;
44
- };
45
-
46
- export type SourceFileMetadata = {
47
- filePath: string;
48
- name: string;
49
- type: 'interface' | 'class' | 'enum';
50
- };
51
-
52
- export type ParsedFile = {
53
- source: SourceFileMetadata;
54
- type: Type;
55
- };
56
-
57
- export type DocPageReference = {
58
- source: SourceFileMetadata;
59
- // The name under which the type should be displayed in the documentation.
60
- // By default, this will match the source.name, but it can be configured by the user.
61
- displayName: string;
62
- // The location where the file will be written.
63
- outputDocPath: string;
64
- // The path to the file relative to the documentation root directory. This is used when linking to the file.
65
- // Usually the value will be the same as outputDocPath. However, some site generators may have a different way of
66
- // organizing the files, so this allows for the flexibility of having a path from linking that is different from
67
- // the path where the file is written.
68
- referencePath: string;
69
- };
70
-
71
- type Frontmatter = string | Record<string, unknown> | null;
72
-
73
- export type ReferenceGuidePageData = {
74
- frontmatter: Frontmatter;
75
- content: string;
76
- outputDocPath: string;
77
- };
78
-
79
- export type DocPageData = {
80
- source: SourceFileMetadata;
81
- group: string | null;
82
- outputDocPath: string;
83
- frontmatter: Frontmatter;
84
- content: string;
85
- };
86
-
87
- export type OpenApiPageData = Omit<DocPageData, 'source'>;
88
-
89
- export type PageData = DocPageData | OpenApiPageData | ReferenceGuidePageData;
90
-
91
- export type DocumentationBundle = {
92
- referenceGuide: ReferenceGuidePageData;
93
- docs: DocPageData[];
94
- };
95
-
96
- /**
97
- * Represents a file to be skipped.
98
- */
99
- export type Skip = {
100
- readonly _tag: 'Skip';
101
- };
102
-
103
- export type PostHookDocumentationBundle = {
104
- referenceGuide: ReferenceGuidePageData | Skip;
105
- docs: DocPageData[];
106
- };
107
-
108
- // CONFIGURABLE HOOKS
109
-
110
- /**
111
- * The configurable hooks that can be used to modify the output of the generator.
112
- */
113
- export type ConfigurableHooks = {
114
- transformReferenceGuide: TransformReferenceGuide;
115
- transformDocs: TransformDocs;
116
- transformDocPage: TransformDocPage;
117
- transformReference: TransformReference;
118
- };
119
-
120
- export type ConfigurableDocPageReference = Omit<DocPageReference, 'source'>;
121
-
122
- export type ConfigurableDocPageData = Omit<DocPageData, 'source' | 'outputDocPath'>;
123
-
124
- /**
125
- * Allows changing where the files are written to.
126
- */
127
- export type TransformReference = (
128
- reference: DocPageReference,
129
- ) => Partial<ConfigurableDocPageReference> | Promise<ConfigurableDocPageReference>;
130
-
131
- /**
132
- * Allows changing the frontmatter and content of the reference guide, or even if creating a reference
133
- * guide will be skipped altogether.
134
- */
135
- export type TransformReferenceGuide = (
136
- referenceGuide: ReferenceGuidePageData,
137
- ) => Partial<ReferenceGuidePageData> | Skip | Promise<Partial<ReferenceGuidePageData> | Skip>;
138
-
139
- /**
140
- * The main purpose if for allowing for doc pages to be skipped, but it can also be used to change the frontmatter
141
- * and content of the doc pages.
142
- */
143
- export type TransformDocs = (docs: DocPageData[]) => DocPageData[] | Promise<DocPageData[]>;
144
-
145
- /**
146
- * Allows changing the frontmatter and content of the doc pages.
147
- */
148
- export type TransformDocPage = (
149
- doc: DocPageData,
150
- ) => Partial<ConfigurableDocPageData> | Promise<Partial<ConfigurableDocPageData>>;
@@ -1,5 +0,0 @@
1
- import { Skip } from './types';
2
-
3
- export function isSkip(value: unknown): value is Skip {
4
- return Object.prototype.hasOwnProperty.call(value, '_tag') && (value as Skip)._tag === 'Skip';
5
- }
package/src/defaults.ts DELETED
@@ -1,21 +0,0 @@
1
- const commonDefaults = {
2
- targetDir: './docs/',
3
- };
4
-
5
- export const markdownDefaults = {
6
- ...commonDefaults,
7
- scope: ['global'],
8
- defaultGroupName: 'Miscellaneous',
9
- includeMetadata: false,
10
- sortAlphabetically: false,
11
- linkingStrategy: 'relative' as const,
12
- referenceGuideTitle: 'Apex Reference Guide',
13
- excludeTags: [],
14
- };
15
-
16
- export const openApiDefaults = {
17
- ...commonDefaults,
18
- fileName: 'openapi',
19
- title: 'Apex REST API',
20
- apiVersion: '1.0.0',
21
- };
package/src/index.ts DELETED
@@ -1,110 +0,0 @@
1
- import type {
2
- ConfigurableHooks,
3
- Skip,
4
- UserDefinedMarkdownConfig,
5
- ReferenceGuidePageData,
6
- DocPageData,
7
- DocPageReference,
8
- ConfigurableDocPageData,
9
- TransformReferenceGuide,
10
- TransformDocs,
11
- TransformDocPage,
12
- TransformReference,
13
- ConfigurableDocPageReference,
14
- UserDefinedOpenApiConfig,
15
- UserDefinedConfig,
16
- } from './core/shared/types';
17
- import { markdownDefaults, openApiDefaults } from './defaults';
18
- import { NoLogger } from '#utils/logger';
19
- import { Apexdocs } from './application/Apexdocs';
20
- import * as E from 'fp-ts/Either';
21
-
22
- type ConfigurableMarkdownConfig = Omit<Partial<UserDefinedMarkdownConfig>, 'targetGenerator'>;
23
-
24
- /**
25
- * Helper function to define a configuration to generate Markdown documentation.
26
- * @param config The configuration to use.
27
- */
28
- function defineMarkdownConfig(config: ConfigurableMarkdownConfig): Partial<UserDefinedMarkdownConfig> {
29
- return {
30
- ...markdownDefaults,
31
- ...config,
32
- targetGenerator: 'markdown' as const,
33
- };
34
- }
35
-
36
- type ConfigurableOpenApiConfig = Omit<Partial<UserDefinedOpenApiConfig>, 'targetGenerator'>;
37
-
38
- /**
39
- * Helper function to define a configuration to generate OpenAPI documentation.
40
- * @param config The configuration to use.
41
- */
42
- function defineOpenApiConfig(config: ConfigurableOpenApiConfig): Partial<UserDefinedOpenApiConfig> {
43
- return {
44
- ...openApiDefaults,
45
- ...config,
46
- targetGenerator: 'openapi' as const,
47
- };
48
- }
49
-
50
- /**
51
- * Represents a file to be skipped.
52
- */
53
- function skip(): Skip {
54
- return {
55
- _tag: 'Skip',
56
- };
57
- }
58
-
59
- type CallableConfig = Partial<UserDefinedConfig> & { sourceDir: string; targetGenerator: 'markdown' | 'openapi' };
60
-
61
- async function process(config: CallableConfig): Promise<void> {
62
- const logger = new NoLogger();
63
- const configWithDefaults = {
64
- ...getDefault(config),
65
- ...config,
66
- };
67
-
68
- if (!configWithDefaults.sourceDir) {
69
- throw new Error('sourceDir is required');
70
- }
71
-
72
- const result = await Apexdocs.generate(configWithDefaults as UserDefinedConfig, logger);
73
- E.match(
74
- (errors) => {
75
- throw errors;
76
- },
77
- () => {},
78
- )(result);
79
- }
80
-
81
- function getDefault(config: CallableConfig) {
82
- switch (config.targetGenerator) {
83
- case 'markdown':
84
- return markdownDefaults;
85
- case 'openapi':
86
- return openApiDefaults;
87
- default:
88
- throw new Error('Unknown target generator');
89
- }
90
- }
91
-
92
- export {
93
- defineMarkdownConfig,
94
- ConfigurableMarkdownConfig,
95
- defineOpenApiConfig,
96
- ConfigurableOpenApiConfig,
97
- skip,
98
- TransformReferenceGuide,
99
- TransformDocs,
100
- TransformDocPage,
101
- TransformReference,
102
- ConfigurableHooks,
103
- ReferenceGuidePageData,
104
- DocPageData,
105
- DocPageReference,
106
- Skip,
107
- ConfigurableDocPageData,
108
- ConfigurableDocPageReference,
109
- process,
110
- };
@@ -1,29 +0,0 @@
1
- import { Annotation, AnnotationElementValue } from '@cparra/apex-reflection';
2
-
3
- /**
4
- * Builder class to create Annotation objects.
5
- * For testing purposes only.
6
- */
7
- export class AnnotationBuilder {
8
- private name = 'restresource';
9
- private elementValues: AnnotationElementValue[] = [];
10
-
11
- withName(name: string): AnnotationBuilder {
12
- this.name = name;
13
- return this;
14
- }
15
-
16
- addElementValue(elementValue: AnnotationElementValue): AnnotationBuilder {
17
- this.elementValues.push(elementValue);
18
- return this;
19
- }
20
-
21
- build(): Annotation {
22
- return {
23
- rawDeclaration: '',
24
- name: this.name,
25
- type: this.name,
26
- elementValues: this.elementValues,
27
- };
28
- }
29
- }
@@ -1,69 +0,0 @@
1
- import { Annotation, ClassMirror, DocComment, FieldMirror, MethodMirror } from '@cparra/apex-reflection';
2
-
3
- /**
4
- * Builder class to create ClassMirror objects.
5
- * For testing purposes only.
6
- */
7
- export class ClassMirrorBuilder {
8
- private name = 'SampleClass';
9
- private annotations: Annotation[] = [];
10
- private docComment?: DocComment;
11
- private methods: MethodMirror[] = [];
12
- private fields: FieldMirror[] = [];
13
- private innerClasses: ClassMirror[] = [];
14
- private extendedClass: string | undefined;
15
-
16
- withName(name: string): ClassMirrorBuilder {
17
- this.name = name;
18
- return this;
19
- }
20
-
21
- addAnnotation(annotation: Annotation): ClassMirrorBuilder {
22
- this.annotations.push(annotation);
23
- return this;
24
- }
25
-
26
- withDocComment(docComment: DocComment): ClassMirrorBuilder {
27
- this.docComment = docComment;
28
- return this;
29
- }
30
-
31
- addMethod(method: MethodMirror): ClassMirrorBuilder {
32
- this.methods.push(method);
33
- return this;
34
- }
35
-
36
- addFiled(field: FieldMirror): ClassMirrorBuilder {
37
- this.fields.push(field);
38
- return this;
39
- }
40
-
41
- addInnerClass(innerClass: ClassMirror): ClassMirrorBuilder {
42
- this.innerClasses.push(innerClass);
43
- return this;
44
- }
45
-
46
- withExtendedClass(extendedClass: string): ClassMirrorBuilder {
47
- this.extendedClass = extendedClass;
48
- return this;
49
- }
50
-
51
- build(): ClassMirror {
52
- return {
53
- annotations: this.annotations,
54
- name: this.name,
55
- type_name: 'class',
56
- methods: this.methods,
57
- implemented_interfaces: [],
58
- properties: [],
59
- fields: this.fields,
60
- constructors: [],
61
- enums: [],
62
- interfaces: [],
63
- classes: this.innerClasses,
64
- access_modifier: 'public',
65
- docComment: this.docComment,
66
- extended_class: this.extendedClass,
67
- };
68
- }
69
- }
@@ -1,24 +0,0 @@
1
- import { DocCommentAnnotation } from '@cparra/apex-reflection';
2
-
3
- export class DocCommentAnnotationBuilder {
4
- private name = '';
5
- private bodyLines: string[] = [];
6
-
7
- withName(name: string): DocCommentAnnotationBuilder {
8
- this.name = name;
9
- return this;
10
- }
11
-
12
- withBodyLines(bodyLines: string[]): DocCommentAnnotationBuilder {
13
- this.bodyLines = bodyLines;
14
- return this;
15
- }
16
-
17
- build(): DocCommentAnnotation {
18
- return {
19
- name: this.name,
20
- body: '',
21
- bodyLines: this.bodyLines,
22
- };
23
- }
24
- }
@@ -1,36 +0,0 @@
1
- import { DocComment, DocCommentAnnotation } from '@cparra/apex-reflection';
2
-
3
- /**
4
- * Builder class to create DocComment objects.
5
- * For testing purposes only.
6
- */
7
- export class DocCommentBuilder {
8
- private description?: string;
9
- private annotations: DocCommentAnnotation[] = [];
10
-
11
- addAnnotation(annotation: DocCommentAnnotation): DocCommentBuilder {
12
- this.annotations.push(annotation);
13
- return this;
14
- }
15
-
16
- withDescription(description: string): DocCommentBuilder {
17
- this.description = description;
18
- return this;
19
- }
20
-
21
- build(): DocComment {
22
- return {
23
- paramAnnotations: [],
24
- returnAnnotation: {
25
- bodyLines: [],
26
- },
27
- exampleAnnotation: {
28
- bodyLines: [],
29
- },
30
- throwsAnnotations: [],
31
- annotations: this.annotations,
32
- descriptionLines: [],
33
- description: this.description ?? 'Sample Description',
34
- };
35
- }
36
- }