@cparra/apexdocs 3.0.0-rc.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -576
- package/dist/cli/generate.js +73 -3094
- package/dist/defaults-BcE8DTat.js +13 -0
- package/dist/defaults-D07y_bq4.js +40 -0
- package/dist/defaults-gPzwP66p.js +14 -0
- package/dist/index.d.ts +35 -3
- package/dist/index.js +90 -2
- package/dist/logger-BEbUIfqN.js +3282 -0
- package/dist/logger-BGuf1PnL.js +3281 -0
- package/dist/logger-CWBRF2za.js +3284 -0
- package/dist/logger-CdBmDEN1.js +3283 -0
- package/dist/logger-Ce4QqPFR.js +3278 -0
- package/dist/logger-CyEVYaAC.js +3284 -0
- package/dist/logger-D7a83ycP.js +3277 -0
- package/dist/logger-DGaHeBKk.js +3279 -0
- package/dist/logger-Dqhl_lO_.js +3278 -0
- package/dist/logger-aySSWi0G.js +3280 -0
- package/dist/logger-qLCcAtiy.js +3284 -0
- package/package.json +5 -2
- package/.github/workflows/ci.yaml +0 -22
- package/.github/workflows/close_stale.yml +0 -22
- package/.prettierrc.js +0 -7
- package/__mocks__/chalk.js +0 -12
- package/__mocks__/log-update.js +0 -6
- package/eslint.config.mjs +0 -10
- package/examples/markdown/.forceignore +0 -12
- package/examples/markdown/config/project-scratch-def.json +0 -5
- package/examples/markdown/docs/index.md +0 -109
- package/examples/markdown/docs/miscellaneous/BaseClass.md +0 -16
- package/examples/markdown/docs/miscellaneous/MultiInheritanceClass.md +0 -72
- package/examples/markdown/docs/miscellaneous/ParentInterface.md +0 -15
- package/examples/markdown/docs/miscellaneous/ReferencedEnum.md +0 -8
- package/examples/markdown/docs/miscellaneous/SampleException.md +0 -24
- package/examples/markdown/docs/miscellaneous/SampleInterface.md +0 -116
- package/examples/markdown/docs/miscellaneous/Url.md +0 -311
- package/examples/markdown/docs/sample-enums/SampleEnum.md +0 -36
- package/examples/markdown/docs/samplegroup/SampleClass.md +0 -170
- package/examples/markdown/force-app/classes/BaseClass.cls +0 -3
- package/examples/markdown/force-app/classes/MultiInheritanceClass.cls +0 -1
- package/examples/markdown/force-app/classes/ParentInterface.cls +0 -3
- package/examples/markdown/force-app/classes/ReferencedEnum.cls +0 -3
- package/examples/markdown/force-app/classes/SampleClass.cls +0 -72
- package/examples/markdown/force-app/classes/SampleEnum.cls +0 -30
- package/examples/markdown/force-app/classes/SampleException.cls +0 -17
- package/examples/markdown/force-app/classes/SampleInterface.cls +0 -50
- package/examples/markdown/force-app/classes/Url.cls +0 -196
- package/examples/markdown/package-lock.json +0 -665
- package/examples/markdown/package.json +0 -20
- package/examples/markdown/sfdx-project.json +0 -12
- package/examples/markdown-jsconfig/.forceignore +0 -12
- package/examples/markdown-jsconfig/apexdocs.config.mjs +0 -21
- package/examples/markdown-jsconfig/config/project-scratch-def.json +0 -5
- package/examples/markdown-jsconfig/docs/index.md +0 -12
- package/examples/markdown-jsconfig/docs/miscellaneous/Url.md +0 -315
- package/examples/markdown-jsconfig/force-app/classes/Url.cls +0 -196
- package/examples/markdown-jsconfig/package-lock.json +0 -665
- package/examples/markdown-jsconfig/package.json +0 -15
- package/examples/markdown-jsconfig/sfdx-project.json +0 -12
- package/examples/open-api/config/project-scratch-def.json +0 -13
- package/examples/open-api/docs/openapi.json +0 -582
- package/examples/open-api/force-app/main/default/classes/ChildClass.cls +0 -42
- package/examples/open-api/force-app/main/default/classes/SampleClass.cls +0 -167
- package/examples/open-api/force-app/main/default/restapi/SampleRestResource.cls +0 -195
- package/examples/open-api/force-app/main/default/restapi/SampleRestResourceToSkip.cls +0 -35
- package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithInnerClass.cls +0 -24
- package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithoutApexDocs.cls +0 -15
- package/examples/open-api/force-app/main/default/restapi/references/Reference1.cls +0 -9
- package/examples/open-api/force-app/main/default/restapi/references/Reference2.cls +0 -9
- package/examples/open-api/force-app/main/default/restapi/references/Reference3.cls +0 -3
- package/examples/open-api/force-app/main/default/restapi/references/Reference4.cls +0 -3
- package/examples/open-api/force-app/main/default/restapi/references/Reference5.cls +0 -3
- package/examples/open-api/force-app/main/default/restapi/references/Reference6.cls +0 -6
- package/examples/open-api/force-app/main/default/restapi/references/Reference7.cls +0 -3
- package/examples/open-api/package-lock.json +0 -724
- package/examples/open-api/package.json +0 -20
- package/examples/open-api/sfdx-project.json +0 -12
- package/examples/vitepress/.forceignore +0 -12
- package/examples/vitepress/apexdocs.config.ts +0 -111
- package/examples/vitepress/config/project-scratch-def.json +0 -13
- package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js +0 -259
- package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/_metadata.json +0 -40
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js +0 -11474
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js +0 -9172
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/package.json +0 -3
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4339
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -567
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/vue.js +0 -323
- package/examples/vitepress/docs/.vitepress/cache/deps/vue.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/config.mts +0 -21
- package/examples/vitepress/docs/.vitepress/sidebar.json +0 -119
- package/examples/vitepress/docs/api-examples.md +0 -49
- package/examples/vitepress/docs/index-frontmatter.md +0 -16
- package/examples/vitepress/docs/index.md +0 -56
- package/examples/vitepress/docs/markdown-examples.md +0 -85
- package/examples/vitepress/docs/miscellaneous/BaseClass.md +0 -20
- package/examples/vitepress/docs/miscellaneous/MultiInheritanceClass.md +0 -76
- package/examples/vitepress/docs/miscellaneous/ParentInterface.md +0 -19
- package/examples/vitepress/docs/miscellaneous/ReferencedEnum.md +0 -15
- package/examples/vitepress/docs/miscellaneous/SampleException.md +0 -28
- package/examples/vitepress/docs/miscellaneous/SampleInterface.md +0 -116
- package/examples/vitepress/docs/miscellaneous/Url.md +0 -317
- package/examples/vitepress/docs/sample-enums/SampleEnum.md +0 -40
- package/examples/vitepress/docs/samplegroup/SampleClass.md +0 -174
- package/examples/vitepress/force-app/main/default/classes/BaseClass.cls +0 -3
- package/examples/vitepress/force-app/main/default/classes/MultiInheritanceClass.cls +0 -1
- package/examples/vitepress/force-app/main/default/classes/ParentInterface.cls +0 -3
- package/examples/vitepress/force-app/main/default/classes/ReferencedEnum.cls +0 -5
- package/examples/vitepress/force-app/main/default/classes/SampleClass.cls +0 -72
- package/examples/vitepress/force-app/main/default/classes/SampleEnum.cls +0 -30
- package/examples/vitepress/force-app/main/default/classes/SampleException.cls +0 -17
- package/examples/vitepress/force-app/main/default/classes/SampleInterface.cls +0 -46
- package/examples/vitepress/force-app/main/default/classes/Url.cls +0 -198
- package/examples/vitepress/package-lock.json +0 -2574
- package/examples/vitepress/package.json +0 -18
- package/examples/vitepress/sfdx-project.json +0 -12
- package/jest.config.js +0 -10
- package/jest.d.ts +0 -7
- package/src/application/Apexdocs.ts +0 -72
- package/src/application/__tests__/apex-file-reader.spec.ts +0 -87
- package/src/application/apex-file-reader.ts +0 -55
- package/src/application/file-system.ts +0 -69
- package/src/application/file-writer.ts +0 -43
- package/src/application/generators/markdown.ts +0 -45
- package/src/application/generators/openapi.ts +0 -71
- package/src/cli/args.ts +0 -46
- package/src/cli/commands/markdown.ts +0 -51
- package/src/cli/commands/openapi.ts +0 -36
- package/src/cli/generate.ts +0 -16
- package/src/core/__test__/manifest.spec.ts +0 -16
- package/src/core/manifest.ts +0 -90
- package/src/core/markdown/__test__/expect-extensions.ts +0 -32
- package/src/core/markdown/__test__/generating-class-docs.spec.ts +0 -605
- package/src/core/markdown/__test__/generating-docs.spec.ts +0 -111
- package/src/core/markdown/__test__/generating-enum-docs.spec.ts +0 -321
- package/src/core/markdown/__test__/generating-interface-docs.spec.ts +0 -397
- package/src/core/markdown/__test__/generating-reference-guide.spec.ts +0 -180
- package/src/core/markdown/__test__/inheritance-chain.test.ts +0 -54
- package/src/core/markdown/__test__/test-helpers.ts +0 -23
- package/src/core/markdown/adapters/__tests__/documentables.spec.ts +0 -109
- package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +0 -148
- package/src/core/markdown/adapters/__tests__/link-generator.spec.ts +0 -130
- package/src/core/markdown/adapters/__tests__/references.spec.ts +0 -136
- package/src/core/markdown/adapters/apex-types.ts +0 -238
- package/src/core/markdown/adapters/documentables.ts +0 -115
- package/src/core/markdown/adapters/fields-and-properties.ts +0 -45
- package/src/core/markdown/adapters/generate-link.ts +0 -82
- package/src/core/markdown/adapters/inline.ts +0 -143
- package/src/core/markdown/adapters/methods-and-constructors.ts +0 -133
- package/src/core/markdown/adapters/reference-guide.ts +0 -37
- package/src/core/markdown/adapters/renderable-bundle.ts +0 -61
- package/src/core/markdown/adapters/renderable-to-page-data.ts +0 -89
- package/src/core/markdown/adapters/type-utils.ts +0 -13
- package/src/core/markdown/adapters/types.d.ts +0 -180
- package/src/core/markdown/generate-docs.ts +0 -212
- package/src/core/markdown/reflection/__test__/filter-scope.spec.ts +0 -306
- package/src/core/markdown/reflection/filter-scope.ts +0 -13
- package/src/core/markdown/reflection/inheritance-chain-expanion.ts +0 -22
- package/src/core/markdown/reflection/inheritance-chain.ts +0 -23
- package/src/core/markdown/reflection/inherited-member-expansion.ts +0 -105
- package/src/core/markdown/reflection/reflect-source.ts +0 -123
- package/src/core/markdown/reflection/sort-members.ts +0 -59
- package/src/core/markdown/templates/class-template.ts +0 -75
- package/src/core/markdown/templates/constructors-partial-template.ts +0 -32
- package/src/core/markdown/templates/documentable-partial-template.ts +0 -26
- package/src/core/markdown/templates/enum-template.ts +0 -12
- package/src/core/markdown/templates/fieldsPartialTemplate.ts +0 -23
- package/src/core/markdown/templates/grouped-members-partial-template.ts +0 -6
- package/src/core/markdown/templates/hookable.ts +0 -7
- package/src/core/markdown/templates/interface-template.ts +0 -16
- package/src/core/markdown/templates/methods-partial-template.ts +0 -43
- package/src/core/markdown/templates/reference-guide.ts +0 -14
- package/src/core/markdown/templates/template.ts +0 -114
- package/src/core/markdown/templates/type-doc-partial.ts +0 -27
- package/src/core/markdown/utils.ts +0 -3
- package/src/core/openApiSettings.ts +0 -41
- package/src/core/openapi/__tests__/manifest-factory.spec.ts +0 -16
- package/src/core/openapi/__tests__/open-api-docs-processor.spec.ts +0 -56
- package/src/core/openapi/__tests__/open-api.spec.ts +0 -22
- package/src/core/openapi/apex-doc-types.ts +0 -26
- package/src/core/openapi/apex-type-wrappers/ClassMirrorWrapper.ts +0 -12
- package/src/core/openapi/apex-type-wrappers/MethodMirrorWrapper.ts +0 -11
- package/src/core/openapi/apex-type-wrappers/__tests__/ClassMirrorWrapper.spec.ts +0 -15
- package/src/core/openapi/file-container.ts +0 -13
- package/src/core/openapi/manifest-factory.ts +0 -16
- package/src/core/openapi/open-api-docs-processor.ts +0 -93
- package/src/core/openapi/open-api-types.ts +0 -119
- package/src/core/openapi/open-api.ts +0 -45
- package/src/core/openapi/openapi-type-file.ts +0 -12
- package/src/core/openapi/parser.ts +0 -160
- package/src/core/openapi/parsers/Builder.ts +0 -40
- package/src/core/openapi/parsers/MethodParser.ts +0 -249
- package/src/core/openapi/parsers/ParameterObjectBuilder.ts +0 -13
- package/src/core/openapi/parsers/ReferenceBuilder.ts +0 -299
- package/src/core/openapi/parsers/RequestBodyBuilder.ts +0 -19
- package/src/core/openapi/parsers/ResponsesBuilder.ts +0 -21
- package/src/core/openapi/parsers/__tests__/MethodParser.spec.ts +0 -44
- package/src/core/openapi/parsers/__tests__/ParameterObjectBuilder.spec.ts +0 -68
- package/src/core/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +0 -751
- package/src/core/openapi/parsers/__tests__/RequestBodyBuilder.spec.ts +0 -64
- package/src/core/openapi/parsers/__tests__/ResponsesBuilder.spec.ts +0 -55
- package/src/core/openapi/transpiler.ts +0 -17
- package/src/core/openapi/types-repository.ts +0 -54
- package/src/core/parse-apex-metadata.ts +0 -30
- package/src/core/shared/types.d.ts +0 -148
- package/src/core/shared/utils.ts +0 -5
- package/src/defaults.ts +0 -9
- package/src/index.ts +0 -49
- package/src/test-helpers/AnnotationBuilder.ts +0 -29
- package/src/test-helpers/ClassMirrorBuilder.ts +0 -69
- package/src/test-helpers/DocCommentAnnotationBuilder.ts +0 -24
- package/src/test-helpers/DocCommentBuilder.ts +0 -36
- package/src/test-helpers/FieldMirrorBuilder.ts +0 -59
- package/src/test-helpers/InterfaceMirrorBuilder.ts +0 -39
- package/src/test-helpers/MethodMirrorBuilder.ts +0 -77
- package/src/test-helpers/SettingsBuilder.ts +0 -17
- package/src/util/error-logger.ts +0 -92
- package/src/util/fp.ts +0 -3
- package/src/util/logger.ts +0 -44
- package/src/util/string-utils.ts +0 -7
- package/tsconfig.json +0 -25
- package/tslint.json +0 -6
|
@@ -0,0 +1,3281 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _function = require('fp-ts/function');
|
|
4
|
+
var TE = require('fp-ts/TaskEither');
|
|
5
|
+
var yaml = require('js-yaml');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
var E = require('fp-ts/Either');
|
|
8
|
+
var T = require('fp-ts/Task');
|
|
9
|
+
var A = require('fp-ts/lib/Array');
|
|
10
|
+
var apexReflection = require('@cparra/apex-reflection');
|
|
11
|
+
var O = require('fp-ts/Option');
|
|
12
|
+
var fastXmlParser = require('fast-xml-parser');
|
|
13
|
+
var Handlebars = require('handlebars');
|
|
14
|
+
var boolean = require('fp-ts/boolean');
|
|
15
|
+
var fs = require('fs');
|
|
16
|
+
var TE$1 = require('fp-ts/lib/TaskEither');
|
|
17
|
+
var chalk = require('chalk');
|
|
18
|
+
|
|
19
|
+
function _interopNamespaceDefault(e) {
|
|
20
|
+
var n = Object.create(null);
|
|
21
|
+
if (e) {
|
|
22
|
+
Object.keys(e).forEach(function (k) {
|
|
23
|
+
if (k !== 'default') {
|
|
24
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
25
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return e[k]; }
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
n.default = e;
|
|
33
|
+
return Object.freeze(n);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var TE__namespace = /*#__PURE__*/_interopNamespaceDefault(TE);
|
|
37
|
+
var yaml__namespace = /*#__PURE__*/_interopNamespaceDefault(yaml);
|
|
38
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
39
|
+
var E__namespace = /*#__PURE__*/_interopNamespaceDefault(E);
|
|
40
|
+
var T__namespace = /*#__PURE__*/_interopNamespaceDefault(T);
|
|
41
|
+
var A__namespace = /*#__PURE__*/_interopNamespaceDefault(A);
|
|
42
|
+
var O__namespace = /*#__PURE__*/_interopNamespaceDefault(O);
|
|
43
|
+
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
44
|
+
var TE__namespace$1 = /*#__PURE__*/_interopNamespaceDefault(TE$1);
|
|
45
|
+
|
|
46
|
+
function apply(fn, ...front) {
|
|
47
|
+
return (...tailArgs) => fn(...front, ...tailArgs);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function defaultGetEmailByReference(email) {
|
|
51
|
+
return {
|
|
52
|
+
__type: "link",
|
|
53
|
+
title: email,
|
|
54
|
+
url: `mailto:${email}`
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function replaceInlineReferences(text, linkReplacer, emailReplacer = defaultGetEmailByReference) {
|
|
58
|
+
const inlineLinks = apply(replaceInlineLinks, linkReplacer);
|
|
59
|
+
const inlineEmails = apply(replaceInlineEmails, emailReplacer);
|
|
60
|
+
return _function.pipe(inlineCode$1([text]), inlineLinks, inlineEmails);
|
|
61
|
+
}
|
|
62
|
+
function inlineCode$1(renderableContents) {
|
|
63
|
+
return renderableContents.flatMap((renderableContent) => inlineCodeContent(renderableContent));
|
|
64
|
+
}
|
|
65
|
+
function inlineCodeContent(renderableContent) {
|
|
66
|
+
if (typeof renderableContent !== "string") {
|
|
67
|
+
return [renderableContent];
|
|
68
|
+
}
|
|
69
|
+
function inlineCodeLink(text2) {
|
|
70
|
+
return {
|
|
71
|
+
__type: "inline-code",
|
|
72
|
+
content: text2
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const text = renderableContent;
|
|
76
|
+
const codeFormatRegEx = "`([^`]*)`";
|
|
77
|
+
const matches = match(codeFormatRegEx, text);
|
|
78
|
+
return createRenderableContents(matches, text, inlineCodeLink);
|
|
79
|
+
}
|
|
80
|
+
function replaceInlineLinks(getLinkByTypeName, renderableContents) {
|
|
81
|
+
return renderableContents.flatMap((renderableContent) => inlineLinkContent(renderableContent, getLinkByTypeName));
|
|
82
|
+
}
|
|
83
|
+
function inlineLinkContent(renderableContent, getLinkByTypeName) {
|
|
84
|
+
if (typeof renderableContent !== "string") {
|
|
85
|
+
return [renderableContent];
|
|
86
|
+
}
|
|
87
|
+
const text = renderableContent;
|
|
88
|
+
const linkFormatRegEx = "{@link (.*?)}|<<([^>]+)>>";
|
|
89
|
+
const matches = match(linkFormatRegEx, text);
|
|
90
|
+
return createRenderableContents(matches, text, getLinkByTypeName);
|
|
91
|
+
}
|
|
92
|
+
function replaceInlineEmails(getLinkByTypeName, renderableContents) {
|
|
93
|
+
return renderableContents.flatMap((renderableContent) => inlineEmailContent(renderableContent, getLinkByTypeName));
|
|
94
|
+
}
|
|
95
|
+
function inlineEmailContent(renderableContent, getLinkByTypeName) {
|
|
96
|
+
if (typeof renderableContent !== "string") {
|
|
97
|
+
return [renderableContent];
|
|
98
|
+
}
|
|
99
|
+
const text = renderableContent;
|
|
100
|
+
const linkFormatRegEx = "{@email (.*?)}";
|
|
101
|
+
const matches = match(linkFormatRegEx, text);
|
|
102
|
+
return createRenderableContents(matches, text, getLinkByTypeName);
|
|
103
|
+
}
|
|
104
|
+
function match(regex, text) {
|
|
105
|
+
const expression = new RegExp(regex, "gi");
|
|
106
|
+
let match2;
|
|
107
|
+
const matches = [];
|
|
108
|
+
do {
|
|
109
|
+
match2 = expression.exec(text);
|
|
110
|
+
if (match2) {
|
|
111
|
+
matches.push(match2);
|
|
112
|
+
}
|
|
113
|
+
} while (match2);
|
|
114
|
+
return matches;
|
|
115
|
+
}
|
|
116
|
+
function createRenderableContents(matches, text, linker) {
|
|
117
|
+
if (matches.length === 0) {
|
|
118
|
+
return [text];
|
|
119
|
+
}
|
|
120
|
+
const result = [];
|
|
121
|
+
let lastIndex = 0;
|
|
122
|
+
for (const match2 of matches) {
|
|
123
|
+
const index = match2.index;
|
|
124
|
+
const length = match2[0].length;
|
|
125
|
+
const capturedGroup = match2.slice(1).find((group) => group);
|
|
126
|
+
if (!capturedGroup) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
result.push(text.slice(lastIndex, index));
|
|
130
|
+
result.push(linker(capturedGroup));
|
|
131
|
+
lastIndex = index + length;
|
|
132
|
+
}
|
|
133
|
+
if (lastIndex < text.length) {
|
|
134
|
+
result.push(text.slice(lastIndex));
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function isEmptyLine(content) {
|
|
140
|
+
return Object.keys(content).includes("__type") && content.__type === "empty-line";
|
|
141
|
+
}
|
|
142
|
+
function isCodeBlock(content) {
|
|
143
|
+
return Object.keys(content).includes("__type") && content.__type === "code-block";
|
|
144
|
+
}
|
|
145
|
+
function isInlineCode(content) {
|
|
146
|
+
return Object.keys(content).includes("__type") && content.__type === "inline-code";
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
var __defProp$h = Object.defineProperty;
|
|
150
|
+
var __defProps$h = Object.defineProperties;
|
|
151
|
+
var __getOwnPropDescs$h = Object.getOwnPropertyDescriptors;
|
|
152
|
+
var __getOwnPropSymbols$h = Object.getOwnPropertySymbols;
|
|
153
|
+
var __hasOwnProp$h = Object.prototype.hasOwnProperty;
|
|
154
|
+
var __propIsEnum$h = Object.prototype.propertyIsEnumerable;
|
|
155
|
+
var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
156
|
+
var __spreadValues$h = (a, b) => {
|
|
157
|
+
for (var prop in b || (b = {}))
|
|
158
|
+
if (__hasOwnProp$h.call(b, prop))
|
|
159
|
+
__defNormalProp$h(a, prop, b[prop]);
|
|
160
|
+
if (__getOwnPropSymbols$h)
|
|
161
|
+
for (var prop of __getOwnPropSymbols$h(b)) {
|
|
162
|
+
if (__propIsEnum$h.call(b, prop))
|
|
163
|
+
__defNormalProp$h(a, prop, b[prop]);
|
|
164
|
+
}
|
|
165
|
+
return a;
|
|
166
|
+
};
|
|
167
|
+
var __spreadProps$h = (a, b) => __defProps$h(a, __getOwnPropDescs$h(b));
|
|
168
|
+
function adaptDescribable(describable, linkGenerator) {
|
|
169
|
+
return {
|
|
170
|
+
description: describableToRenderableContent(describable, linkGenerator)
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function describableToRenderableContent(describable, linkGenerator) {
|
|
174
|
+
if (!describable) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
let content = [];
|
|
178
|
+
for (let i = 0; i < describable.length; i++) {
|
|
179
|
+
const line = describable[i];
|
|
180
|
+
const codeBlockMatch = line.match(/^```([a-zA-Z]*)$/);
|
|
181
|
+
if (codeBlockMatch) {
|
|
182
|
+
const language = codeBlockMatch[1] || "apex";
|
|
183
|
+
const codeBlockLines = [];
|
|
184
|
+
i++;
|
|
185
|
+
while (i < describable.length) {
|
|
186
|
+
const currentLine = describable[i];
|
|
187
|
+
if (currentLine.trim() === "```") {
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
codeBlockLines.push(currentLine);
|
|
191
|
+
i++;
|
|
192
|
+
}
|
|
193
|
+
content = [
|
|
194
|
+
...content,
|
|
195
|
+
{
|
|
196
|
+
__type: "code-block",
|
|
197
|
+
language,
|
|
198
|
+
content: codeBlockLines
|
|
199
|
+
},
|
|
200
|
+
{ __type: "empty-line" }
|
|
201
|
+
];
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
content = [
|
|
205
|
+
...content,
|
|
206
|
+
...replaceInlineReferences(line, linkGenerator),
|
|
207
|
+
{
|
|
208
|
+
__type: "empty-line"
|
|
209
|
+
}
|
|
210
|
+
];
|
|
211
|
+
}
|
|
212
|
+
return content.filter((line, index, lines) => !(isEmptyLine(line) && index === lines.length - 1));
|
|
213
|
+
}
|
|
214
|
+
function adaptDocumentable(documentable, linkGenerator, subHeadingLevel) {
|
|
215
|
+
var _a, _b, _c;
|
|
216
|
+
function extractCustomTags(type) {
|
|
217
|
+
var _a2, _b2;
|
|
218
|
+
const baseTags = ["description", "group", "author", "date", "see", "example", "throws", "exception"];
|
|
219
|
+
return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.filter((currentAnnotation) => !baseTags.includes(currentAnnotation.name.toLowerCase())).map((currentAnnotation) => __spreadProps$h(__spreadValues$h({}, adaptDescribable(currentAnnotation.bodyLines, linkGenerator)), {
|
|
220
|
+
name: currentAnnotation.name
|
|
221
|
+
}))) != null ? _b2 : [];
|
|
222
|
+
}
|
|
223
|
+
function extractAnnotationBody(type, annotationName) {
|
|
224
|
+
var _a2, _b2;
|
|
225
|
+
return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.find(
|
|
226
|
+
(currentAnnotation) => currentAnnotation.name.toLowerCase() === annotationName
|
|
227
|
+
)) == null ? void 0 : _b2.body;
|
|
228
|
+
}
|
|
229
|
+
function extractSeeAnnotations(type) {
|
|
230
|
+
var _a2, _b2;
|
|
231
|
+
return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.filter((currentAnnotation) => currentAnnotation.name.toLowerCase() === "see").map((currentAnnotation) => currentAnnotation.body)) != null ? _b2 : [];
|
|
232
|
+
}
|
|
233
|
+
return __spreadProps$h(__spreadValues$h({}, adaptDescribable((_a = documentable.docComment) == null ? void 0 : _a.descriptionLines, linkGenerator)), {
|
|
234
|
+
annotations: documentable.annotations.map((annotation) => annotation.type.toUpperCase()),
|
|
235
|
+
customTags: extractCustomTags(documentable),
|
|
236
|
+
example: {
|
|
237
|
+
headingLevel: subHeadingLevel,
|
|
238
|
+
heading: "Example",
|
|
239
|
+
value: describableToRenderableContent((_c = (_b = documentable.docComment) == null ? void 0 : _b.exampleAnnotation) == null ? void 0 : _c.bodyLines, linkGenerator)
|
|
240
|
+
},
|
|
241
|
+
group: extractAnnotationBody(documentable, "group"),
|
|
242
|
+
author: extractAnnotationBody(documentable, "author"),
|
|
243
|
+
date: extractAnnotationBody(documentable, "date"),
|
|
244
|
+
sees: extractSeeAnnotations(documentable).map(linkGenerator)
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
var __defProp$g = Object.defineProperty;
|
|
249
|
+
var __defProps$g = Object.defineProperties;
|
|
250
|
+
var __getOwnPropDescs$g = Object.getOwnPropertyDescriptors;
|
|
251
|
+
var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
|
|
252
|
+
var __hasOwnProp$g = Object.prototype.hasOwnProperty;
|
|
253
|
+
var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
|
|
254
|
+
var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
255
|
+
var __spreadValues$g = (a, b) => {
|
|
256
|
+
for (var prop in b || (b = {}))
|
|
257
|
+
if (__hasOwnProp$g.call(b, prop))
|
|
258
|
+
__defNormalProp$g(a, prop, b[prop]);
|
|
259
|
+
if (__getOwnPropSymbols$g)
|
|
260
|
+
for (var prop of __getOwnPropSymbols$g(b)) {
|
|
261
|
+
if (__propIsEnum$g.call(b, prop))
|
|
262
|
+
__defNormalProp$g(a, prop, b[prop]);
|
|
263
|
+
}
|
|
264
|
+
return a;
|
|
265
|
+
};
|
|
266
|
+
var __spreadProps$g = (a, b) => __defProps$g(a, __getOwnPropDescs$g(b));
|
|
267
|
+
function adaptMethod(method, linkGenerator, baseHeadingLevel) {
|
|
268
|
+
var _a, _b, _c;
|
|
269
|
+
function buildTitle(method2) {
|
|
270
|
+
const { name, parameters } = method2;
|
|
271
|
+
const parametersString = parameters.map((param) => param.name).join(", ");
|
|
272
|
+
return `${name}(${parametersString})`;
|
|
273
|
+
}
|
|
274
|
+
function buildSignature(method2) {
|
|
275
|
+
const { access_modifier, typeReference, name, memberModifiers } = method2;
|
|
276
|
+
const parameters = method2.parameters.map((param) => `${param.typeReference.rawDeclaration} ${param.name}`).join(", ");
|
|
277
|
+
const members = memberModifiers.length > 0 ? `${memberModifiers.join(" ")} ` : "";
|
|
278
|
+
return {
|
|
279
|
+
__type: "code-block",
|
|
280
|
+
language: "apex",
|
|
281
|
+
content: [`${access_modifier} ${members}${typeReference.rawDeclaration} ${name}(${parameters})`]
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
return {
|
|
285
|
+
headingLevel: baseHeadingLevel,
|
|
286
|
+
doc: adaptDocumentable(method, linkGenerator, baseHeadingLevel + 1),
|
|
287
|
+
heading: buildTitle(method),
|
|
288
|
+
signature: {
|
|
289
|
+
headingLevel: baseHeadingLevel + 1,
|
|
290
|
+
heading: "Signature",
|
|
291
|
+
value: buildSignature(method)
|
|
292
|
+
},
|
|
293
|
+
returnType: {
|
|
294
|
+
headingLevel: baseHeadingLevel + 1,
|
|
295
|
+
heading: "Return Type",
|
|
296
|
+
value: __spreadProps$g(__spreadValues$g({}, adaptDescribable((_b = (_a = method.docComment) == null ? void 0 : _a.returnAnnotation) == null ? void 0 : _b.bodyLines, linkGenerator)), {
|
|
297
|
+
type: linkGenerator(method.typeReference.rawDeclaration)
|
|
298
|
+
})
|
|
299
|
+
},
|
|
300
|
+
throws: {
|
|
301
|
+
headingLevel: baseHeadingLevel + 1,
|
|
302
|
+
heading: "Throws",
|
|
303
|
+
value: (_c = method.docComment) == null ? void 0 : _c.throwsAnnotations.map((thrown) => mapThrows(thrown, linkGenerator))
|
|
304
|
+
},
|
|
305
|
+
parameters: {
|
|
306
|
+
headingLevel: baseHeadingLevel + 1,
|
|
307
|
+
heading: "Parameters",
|
|
308
|
+
value: method.parameters.map((param) => mapParameters(method, param, linkGenerator))
|
|
309
|
+
},
|
|
310
|
+
inherited: method.inherited
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function adaptConstructor(typeName, constructor, linkGenerator, baseHeadingLevel) {
|
|
314
|
+
var _a;
|
|
315
|
+
function buildTitle(name, constructor2) {
|
|
316
|
+
const { parameters } = constructor2;
|
|
317
|
+
const parametersString = parameters.map((param) => param.name).join(", ");
|
|
318
|
+
return `${name}(${parametersString})`;
|
|
319
|
+
}
|
|
320
|
+
function buildSignature(name, constructor2) {
|
|
321
|
+
const { access_modifier } = constructor2;
|
|
322
|
+
const parameters = constructor2.parameters.map((param) => `${param.typeReference.rawDeclaration} ${param.name}`).join(", ");
|
|
323
|
+
return {
|
|
324
|
+
__type: "code-block",
|
|
325
|
+
language: "apex",
|
|
326
|
+
content: [`${access_modifier} ${name}(${parameters})`]
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
return {
|
|
330
|
+
doc: adaptDocumentable(constructor, linkGenerator, baseHeadingLevel + 1),
|
|
331
|
+
headingLevel: baseHeadingLevel,
|
|
332
|
+
heading: buildTitle(typeName, constructor),
|
|
333
|
+
signature: {
|
|
334
|
+
headingLevel: baseHeadingLevel + 1,
|
|
335
|
+
heading: "Signature",
|
|
336
|
+
value: buildSignature(typeName, constructor)
|
|
337
|
+
},
|
|
338
|
+
parameters: {
|
|
339
|
+
headingLevel: baseHeadingLevel + 1,
|
|
340
|
+
heading: "Parameters",
|
|
341
|
+
value: constructor.parameters.map((param) => mapParameters(constructor, param, linkGenerator))
|
|
342
|
+
},
|
|
343
|
+
throws: {
|
|
344
|
+
headingLevel: baseHeadingLevel + 1,
|
|
345
|
+
heading: "Throws",
|
|
346
|
+
value: (_a = constructor.docComment) == null ? void 0 : _a.throwsAnnotations.map((thrown) => mapThrows(thrown, linkGenerator))
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function mapParameters(documentable, param, linkGenerator) {
|
|
351
|
+
var _a;
|
|
352
|
+
const paramAnnotation = (_a = documentable.docComment) == null ? void 0 : _a.paramAnnotations.find(
|
|
353
|
+
(pa) => pa.paramName.toLowerCase() === param.name.toLowerCase()
|
|
354
|
+
);
|
|
355
|
+
return __spreadProps$g(__spreadValues$g({}, adaptDescribable(paramAnnotation == null ? void 0 : paramAnnotation.bodyLines, linkGenerator)), {
|
|
356
|
+
name: param.name,
|
|
357
|
+
type: linkGenerator(param.typeReference.rawDeclaration)
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
function mapThrows(thrown, linkGenerator) {
|
|
361
|
+
return __spreadProps$g(__spreadValues$g({}, adaptDescribable(thrown.bodyLines, linkGenerator)), {
|
|
362
|
+
type: linkGenerator(thrown.exceptionName)
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function adaptFieldOrProperty(field, linkGenerator, baseHeadingLevel) {
|
|
367
|
+
function buildSignature() {
|
|
368
|
+
const { access_modifier, name } = field;
|
|
369
|
+
const memberModifiers = field.memberModifiers.join(" ");
|
|
370
|
+
const codeContents = `${access_modifier} ${memberModifiers} ${name}`.replace(/ {2}/g, " ");
|
|
371
|
+
return {
|
|
372
|
+
__type: "code-block",
|
|
373
|
+
language: "apex",
|
|
374
|
+
content: [codeContents]
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
return {
|
|
378
|
+
headingLevel: baseHeadingLevel,
|
|
379
|
+
doc: adaptDocumentable(field, linkGenerator, baseHeadingLevel + 1),
|
|
380
|
+
heading: field.name,
|
|
381
|
+
type: {
|
|
382
|
+
headingLevel: baseHeadingLevel + 1,
|
|
383
|
+
heading: "Type",
|
|
384
|
+
value: linkGenerator(field.typeReference.rawDeclaration)
|
|
385
|
+
},
|
|
386
|
+
inherited: field.inherited,
|
|
387
|
+
accessModifier: field.access_modifier,
|
|
388
|
+
signature: {
|
|
389
|
+
headingLevel: baseHeadingLevel + 1,
|
|
390
|
+
heading: "Signature",
|
|
391
|
+
value: buildSignature()
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
var __defProp$f = Object.defineProperty;
|
|
397
|
+
var __defProps$f = Object.defineProperties;
|
|
398
|
+
var __getOwnPropDescs$f = Object.getOwnPropertyDescriptors;
|
|
399
|
+
var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
|
|
400
|
+
var __hasOwnProp$f = Object.prototype.hasOwnProperty;
|
|
401
|
+
var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
|
|
402
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
403
|
+
var __spreadValues$f = (a, b) => {
|
|
404
|
+
for (var prop in b || (b = {}))
|
|
405
|
+
if (__hasOwnProp$f.call(b, prop))
|
|
406
|
+
__defNormalProp$f(a, prop, b[prop]);
|
|
407
|
+
if (__getOwnPropSymbols$f)
|
|
408
|
+
for (var prop of __getOwnPropSymbols$f(b)) {
|
|
409
|
+
if (__propIsEnum$f.call(b, prop))
|
|
410
|
+
__defNormalProp$f(a, prop, b[prop]);
|
|
411
|
+
}
|
|
412
|
+
return a;
|
|
413
|
+
};
|
|
414
|
+
var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
|
|
415
|
+
function typeToRenderable(parsedFile, linkGenerator, config) {
|
|
416
|
+
function getRenderable() {
|
|
417
|
+
const { type } = parsedFile;
|
|
418
|
+
switch (type.type_name) {
|
|
419
|
+
case "enum":
|
|
420
|
+
return enumTypeToEnumSource(type, linkGenerator);
|
|
421
|
+
case "interface":
|
|
422
|
+
return interfaceTypeToInterfaceSource(type, linkGenerator);
|
|
423
|
+
case "class":
|
|
424
|
+
return classTypeToClassSource(type, linkGenerator);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return __spreadProps$f(__spreadValues$f({}, getRenderable()), {
|
|
428
|
+
filePath: parsedFile.source.filePath,
|
|
429
|
+
namespace: config.namespace
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
function baseTypeAdapter(type, linkGenerator, baseHeadingLevel) {
|
|
433
|
+
function getHeading(type2) {
|
|
434
|
+
const suffixMap = {
|
|
435
|
+
class: "Class",
|
|
436
|
+
interface: "Interface",
|
|
437
|
+
enum: "Enum"
|
|
438
|
+
};
|
|
439
|
+
return `${type2.name} ${suffixMap[type2.type_name]}`;
|
|
440
|
+
}
|
|
441
|
+
return {
|
|
442
|
+
headingLevel: baseHeadingLevel,
|
|
443
|
+
heading: getHeading(type),
|
|
444
|
+
doc: adaptDocumentable(type, linkGenerator, baseHeadingLevel + 1),
|
|
445
|
+
name: type.name,
|
|
446
|
+
meta: {
|
|
447
|
+
accessModifier: type.access_modifier
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function enumTypeToEnumSource(enumType, linkGenerator, baseHeadingLevel = 1) {
|
|
452
|
+
return __spreadProps$f(__spreadValues$f({
|
|
453
|
+
type: "enum"
|
|
454
|
+
}, baseTypeAdapter(enumType, linkGenerator, baseHeadingLevel)), {
|
|
455
|
+
values: {
|
|
456
|
+
headingLevel: baseHeadingLevel + 1,
|
|
457
|
+
heading: "Values",
|
|
458
|
+
value: enumType.values.map((value) => {
|
|
459
|
+
var _a;
|
|
460
|
+
return __spreadProps$f(__spreadValues$f({}, adaptDescribable((_a = value.docComment) == null ? void 0 : _a.descriptionLines, linkGenerator)), {
|
|
461
|
+
value: value.name
|
|
462
|
+
});
|
|
463
|
+
})
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function interfaceTypeToInterfaceSource(interfaceType, linkGenerator, baseHeadingLevel = 1) {
|
|
468
|
+
return __spreadProps$f(__spreadValues$f({
|
|
469
|
+
type: "interface"
|
|
470
|
+
}, baseTypeAdapter(interfaceType, linkGenerator, baseHeadingLevel)), {
|
|
471
|
+
extends: interfaceType.extended_interfaces.map(linkGenerator),
|
|
472
|
+
methods: {
|
|
473
|
+
headingLevel: baseHeadingLevel + 1,
|
|
474
|
+
heading: "Methods",
|
|
475
|
+
value: interfaceType.methods.map((method) => adaptMethod(method, linkGenerator, baseHeadingLevel + 2))
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
function classTypeToClassSource(classType, linkGenerator, baseHeadingLevel = 1) {
|
|
480
|
+
return __spreadProps$f(__spreadValues$f({
|
|
481
|
+
type: "class"
|
|
482
|
+
}, baseTypeAdapter(classType, linkGenerator, baseHeadingLevel)), {
|
|
483
|
+
classModifier: classType.classModifier,
|
|
484
|
+
sharingModifier: classType.sharingModifier,
|
|
485
|
+
implements: classType.implemented_interfaces.map(linkGenerator),
|
|
486
|
+
extends: classType.inheritanceChain.map(linkGenerator),
|
|
487
|
+
methods: adaptMembers("Methods", classType.methods, adaptMethod, linkGenerator, baseHeadingLevel + 1),
|
|
488
|
+
constructors: adaptMembers(
|
|
489
|
+
"Constructors",
|
|
490
|
+
classType.constructors,
|
|
491
|
+
(constructor, linkGenerator2, baseHeadingLevel2) => adaptConstructor(classType.name, constructor, linkGenerator2, baseHeadingLevel2),
|
|
492
|
+
linkGenerator,
|
|
493
|
+
baseHeadingLevel + 1
|
|
494
|
+
),
|
|
495
|
+
fields: adaptMembers(
|
|
496
|
+
"Fields",
|
|
497
|
+
classType.fields,
|
|
498
|
+
adaptFieldOrProperty,
|
|
499
|
+
linkGenerator,
|
|
500
|
+
baseHeadingLevel + 1
|
|
501
|
+
),
|
|
502
|
+
properties: adaptMembers(
|
|
503
|
+
"Properties",
|
|
504
|
+
classType.properties,
|
|
505
|
+
adaptFieldOrProperty,
|
|
506
|
+
linkGenerator,
|
|
507
|
+
baseHeadingLevel + 1
|
|
508
|
+
),
|
|
509
|
+
innerClasses: {
|
|
510
|
+
headingLevel: baseHeadingLevel + 1,
|
|
511
|
+
heading: "Classes",
|
|
512
|
+
value: classType.classes.map(
|
|
513
|
+
(innerClass) => classTypeToClassSource(__spreadProps$f(__spreadValues$f({}, innerClass), { inheritanceChain: [] }), linkGenerator, baseHeadingLevel + 2)
|
|
514
|
+
)
|
|
515
|
+
},
|
|
516
|
+
innerEnums: {
|
|
517
|
+
headingLevel: baseHeadingLevel + 1,
|
|
518
|
+
heading: "Enums",
|
|
519
|
+
value: classType.enums.map((innerEnum) => enumTypeToEnumSource(innerEnum, linkGenerator, baseHeadingLevel + 2))
|
|
520
|
+
},
|
|
521
|
+
innerInterfaces: {
|
|
522
|
+
headingLevel: baseHeadingLevel + 1,
|
|
523
|
+
heading: "Interfaces",
|
|
524
|
+
value: classType.interfaces.map(
|
|
525
|
+
(innerInterface) => interfaceTypeToInterfaceSource(innerInterface, linkGenerator, baseHeadingLevel + 2)
|
|
526
|
+
)
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
function adaptMembers(heading, members, adapter, linkFromTypeNameGenerator, headingLevel) {
|
|
531
|
+
return {
|
|
532
|
+
headingLevel,
|
|
533
|
+
heading,
|
|
534
|
+
isGrouped: hasGroup(members),
|
|
535
|
+
value: hasGroup(members) ? toGroupedMembers(members, adapter, linkFromTypeNameGenerator, headingLevel + 1) : toFlat(members, adapter, linkFromTypeNameGenerator, headingLevel + 1)
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
function hasGroup(members) {
|
|
539
|
+
return members.some((member) => member.group);
|
|
540
|
+
}
|
|
541
|
+
function toFlat(members, adapter, linkGenerator, baseHeadingLevel) {
|
|
542
|
+
return members.map((member) => adapter(member, linkGenerator, baseHeadingLevel));
|
|
543
|
+
}
|
|
544
|
+
function toGroupedMembers(members, adapter, linkGenerator, baseHeadingLevel) {
|
|
545
|
+
const groupedMembers = groupByGroupName(members);
|
|
546
|
+
return Object.entries(groupedMembers).map(
|
|
547
|
+
([groupName, members2]) => singleGroup(baseHeadingLevel, groupName, adapter, members2, linkGenerator)
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
function groupByGroupName(members) {
|
|
551
|
+
return members.reduce(
|
|
552
|
+
(acc, member) => {
|
|
553
|
+
var _a, _b;
|
|
554
|
+
const groupName = (_a = member.group) != null ? _a : "Other";
|
|
555
|
+
acc[groupName] = (_b = acc[groupName]) != null ? _b : [];
|
|
556
|
+
acc[groupName].push(member);
|
|
557
|
+
return acc;
|
|
558
|
+
},
|
|
559
|
+
{}
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
function singleGroup(headingLevel, groupName, adapter, members, linkGenerator) {
|
|
563
|
+
return {
|
|
564
|
+
headingLevel,
|
|
565
|
+
heading: groupName,
|
|
566
|
+
groupDescription: members[0].groupDescription,
|
|
567
|
+
// All fields in the group have the same description
|
|
568
|
+
value: toFlat(members, adapter, linkGenerator, headingLevel + 1)
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
const generateLink = (strategy) => {
|
|
573
|
+
switch (strategy) {
|
|
574
|
+
case "relative":
|
|
575
|
+
return generateRelativeLink;
|
|
576
|
+
case "no-link":
|
|
577
|
+
return generateNoLink;
|
|
578
|
+
case "none":
|
|
579
|
+
return returnReferenceAsIs;
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
const generateRelativeLink = (references, from, referenceName) => {
|
|
583
|
+
function getRelativePath(fromPath, toPath) {
|
|
584
|
+
return path.relative(path.parse(path.join("/", fromPath)).dir, path.join("/", toPath));
|
|
585
|
+
}
|
|
586
|
+
const referenceTo = references[referenceName];
|
|
587
|
+
if (!referenceTo) {
|
|
588
|
+
return referenceName;
|
|
589
|
+
}
|
|
590
|
+
if (referenceTo && from === "__base__") {
|
|
591
|
+
return {
|
|
592
|
+
__type: "link",
|
|
593
|
+
title: referenceTo.displayName,
|
|
594
|
+
url: getRelativePath("", referenceTo.referencePath)
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
const referenceFrom = references[from];
|
|
598
|
+
if (!referenceFrom) {
|
|
599
|
+
return referenceTo.displayName;
|
|
600
|
+
}
|
|
601
|
+
return {
|
|
602
|
+
__type: "link",
|
|
603
|
+
title: referenceTo.displayName,
|
|
604
|
+
url: getRelativePath(referenceFrom.referencePath, referenceTo.referencePath)
|
|
605
|
+
};
|
|
606
|
+
};
|
|
607
|
+
const generateNoLink = (references, _from, referenceName) => {
|
|
608
|
+
const referenceTo = references[referenceName];
|
|
609
|
+
return referenceTo ? referenceTo.displayName : referenceName;
|
|
610
|
+
};
|
|
611
|
+
const returnReferenceAsIs = (references, _from, referenceName) => {
|
|
612
|
+
const referenceTo = references[referenceName];
|
|
613
|
+
if (!referenceTo) {
|
|
614
|
+
return referenceName;
|
|
615
|
+
}
|
|
616
|
+
return {
|
|
617
|
+
__type: "link",
|
|
618
|
+
title: referenceTo.displayName,
|
|
619
|
+
url: referenceTo.referencePath
|
|
620
|
+
};
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
function parsedFilesToRenderableBundle(config, parsedFiles, references) {
|
|
624
|
+
const referenceFinder = apply(generateLink(config.linkingStrategy), references);
|
|
625
|
+
function toReferenceGuide(parsedFiles2) {
|
|
626
|
+
return parsedFiles2.reduce(
|
|
627
|
+
addToReferenceGuide(apply(referenceFinder, "__base__"), config, references),
|
|
628
|
+
{}
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
function toRenderables(parsedFiles2) {
|
|
632
|
+
return parsedFiles2.reduce((acc, parsedFile) => {
|
|
633
|
+
const renderable = typeToRenderable(parsedFile, apply(referenceFinder, parsedFile.source.name), config);
|
|
634
|
+
acc.push(renderable);
|
|
635
|
+
return acc;
|
|
636
|
+
}, []);
|
|
637
|
+
}
|
|
638
|
+
return {
|
|
639
|
+
referencesByGroup: toReferenceGuide(parsedFiles),
|
|
640
|
+
renderables: toRenderables(parsedFiles)
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
function addToReferenceGuide(findLinkFromHome, config, references) {
|
|
644
|
+
return (acc, parsedFile) => {
|
|
645
|
+
var _a, _b;
|
|
646
|
+
const group = getTypeGroup$1(parsedFile.type, config);
|
|
647
|
+
if (!acc[group]) {
|
|
648
|
+
acc[group] = [];
|
|
649
|
+
}
|
|
650
|
+
acc[group].push({
|
|
651
|
+
reference: references[parsedFile.type.name],
|
|
652
|
+
title: findLinkFromHome(parsedFile.type.name),
|
|
653
|
+
description: (_b = adaptDescribable((_a = parsedFile.type.docComment) == null ? void 0 : _a.descriptionLines, findLinkFromHome).description) != null ? _b : null
|
|
654
|
+
});
|
|
655
|
+
return acc;
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
function getTypeGroup$1(type, config) {
|
|
659
|
+
var _a, _b;
|
|
660
|
+
const groupAnnotation = (_a = type.docComment) == null ? void 0 : _a.annotations.find((annotation) => annotation.name.toLowerCase() === "group");
|
|
661
|
+
return (_b = groupAnnotation == null ? void 0 : groupAnnotation.body) != null ? _b : config.defaultGroupName;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function parseApexMetadata(input) {
|
|
665
|
+
return _function.pipe(input, parse, E__namespace.map(toMap));
|
|
666
|
+
}
|
|
667
|
+
function parse(input) {
|
|
668
|
+
return E__namespace.tryCatch(() => new fastXmlParser.XMLParser().parse(input), E__namespace.toError);
|
|
669
|
+
}
|
|
670
|
+
function toMap(metadata) {
|
|
671
|
+
const map = /* @__PURE__ */ new Map();
|
|
672
|
+
map.set("apiVersion", String(metadata.ApexClass.apiVersion));
|
|
673
|
+
if (metadata.ApexClass.status) {
|
|
674
|
+
map.set("status", String(metadata.ApexClass.status));
|
|
675
|
+
}
|
|
676
|
+
return map;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
var __defProp$e = Object.defineProperty;
|
|
680
|
+
var __defProps$e = Object.defineProperties;
|
|
681
|
+
var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
|
|
682
|
+
var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
|
|
683
|
+
var __hasOwnProp$e = Object.prototype.hasOwnProperty;
|
|
684
|
+
var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
|
|
685
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
686
|
+
var __spreadValues$e = (a, b) => {
|
|
687
|
+
for (var prop in b || (b = {}))
|
|
688
|
+
if (__hasOwnProp$e.call(b, prop))
|
|
689
|
+
__defNormalProp$e(a, prop, b[prop]);
|
|
690
|
+
if (__getOwnPropSymbols$e)
|
|
691
|
+
for (var prop of __getOwnPropSymbols$e(b)) {
|
|
692
|
+
if (__propIsEnum$e.call(b, prop))
|
|
693
|
+
__defNormalProp$e(a, prop, b[prop]);
|
|
694
|
+
}
|
|
695
|
+
return a;
|
|
696
|
+
};
|
|
697
|
+
var __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
|
|
698
|
+
var __async$5 = (__this, __arguments, generator) => {
|
|
699
|
+
return new Promise((resolve, reject) => {
|
|
700
|
+
var fulfilled = (value) => {
|
|
701
|
+
try {
|
|
702
|
+
step(generator.next(value));
|
|
703
|
+
} catch (e) {
|
|
704
|
+
reject(e);
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
var rejected = (value) => {
|
|
708
|
+
try {
|
|
709
|
+
step(generator.throw(value));
|
|
710
|
+
} catch (e) {
|
|
711
|
+
reject(e);
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
715
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
716
|
+
});
|
|
717
|
+
};
|
|
718
|
+
class ReflectionErrors {
|
|
719
|
+
constructor(errors) {
|
|
720
|
+
this.errors = errors;
|
|
721
|
+
this._tag = "ReflectionErrors";
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
class ReflectionError {
|
|
725
|
+
constructor(file, message) {
|
|
726
|
+
this.file = file;
|
|
727
|
+
this.message = message;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
function reflectAsync(rawSource) {
|
|
731
|
+
return __async$5(this, null, function* () {
|
|
732
|
+
return new Promise((resolve, reject) => {
|
|
733
|
+
const result = apexReflection.reflect(rawSource);
|
|
734
|
+
if (result.typeMirror) {
|
|
735
|
+
return resolve(result.typeMirror);
|
|
736
|
+
} else if (result.error) {
|
|
737
|
+
return reject(result.error);
|
|
738
|
+
} else {
|
|
739
|
+
return reject(new Error("Unknown error"));
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
function reflectBundles(apexBundles) {
|
|
745
|
+
const semiGroupReflectionError = {
|
|
746
|
+
concat: (x, y) => new ReflectionErrors([...x.errors, ...y.errors])
|
|
747
|
+
};
|
|
748
|
+
const Ap = TE__namespace.getApplicativeTaskValidation(T__namespace.ApplyPar, semiGroupReflectionError);
|
|
749
|
+
return _function.pipe(apexBundles, A__namespace.traverse(Ap)(reflectBundle));
|
|
750
|
+
}
|
|
751
|
+
function reflectBundle(apexBundle) {
|
|
752
|
+
const convertToParsedFile = apply(toParsedFile, apexBundle.filePath);
|
|
753
|
+
const withMetadata = apply(addMetadata, apexBundle.metadataContent);
|
|
754
|
+
return _function.pipe(apexBundle, reflectAsTask, TE__namespace.map(convertToParsedFile), TE__namespace.flatMap(withMetadata));
|
|
755
|
+
}
|
|
756
|
+
function reflectAsTask(apexBundle) {
|
|
757
|
+
return TE__namespace.tryCatch(
|
|
758
|
+
() => reflectAsync(apexBundle.content),
|
|
759
|
+
(error) => new ReflectionErrors([new ReflectionError(apexBundle.filePath, error.message)])
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
function toParsedFile(filePath, typeMirror) {
|
|
763
|
+
return {
|
|
764
|
+
source: {
|
|
765
|
+
filePath,
|
|
766
|
+
name: typeMirror.name,
|
|
767
|
+
type: typeMirror.type_name
|
|
768
|
+
},
|
|
769
|
+
type: typeMirror
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
function addMetadata(rawMetadataContent, parsedFile) {
|
|
773
|
+
return TE__namespace.fromEither(
|
|
774
|
+
_function.pipe(
|
|
775
|
+
parsedFile.type,
|
|
776
|
+
(type) => addFileMetadataToTypeAnnotation(type, rawMetadataContent),
|
|
777
|
+
E__namespace.map((type) => __spreadProps$e(__spreadValues$e({}, parsedFile), { type })),
|
|
778
|
+
E__namespace.mapLeft((error) => errorToReflectionErrors(error, parsedFile.source.filePath))
|
|
779
|
+
)
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
function errorToReflectionErrors(error, filePath) {
|
|
783
|
+
return new ReflectionErrors([new ReflectionError(filePath, error.message)]);
|
|
784
|
+
}
|
|
785
|
+
function addFileMetadataToTypeAnnotation(type, metadata) {
|
|
786
|
+
const concatAnnotationToType = apply(concatAnnotations, type);
|
|
787
|
+
return _function.pipe(
|
|
788
|
+
O__namespace.fromNullable(metadata),
|
|
789
|
+
O__namespace.map(concatAnnotationToType),
|
|
790
|
+
O__namespace.getOrElse(() => E__namespace.right(type))
|
|
791
|
+
);
|
|
792
|
+
}
|
|
793
|
+
function concatAnnotations(type, metadataInput) {
|
|
794
|
+
return _function.pipe(
|
|
795
|
+
metadataInput,
|
|
796
|
+
parseApexMetadata,
|
|
797
|
+
E__namespace.map((metadataMap) => __spreadProps$e(__spreadValues$e({}, type), {
|
|
798
|
+
annotations: [...type.annotations, ...mapToAnnotations(metadataMap)]
|
|
799
|
+
}))
|
|
800
|
+
);
|
|
801
|
+
}
|
|
802
|
+
function mapToAnnotations(metadata) {
|
|
803
|
+
return Array.from(metadata.entries()).map(([key, value]) => {
|
|
804
|
+
const declaration = `${key}: ${value}`;
|
|
805
|
+
return {
|
|
806
|
+
name: declaration,
|
|
807
|
+
type: declaration,
|
|
808
|
+
rawDeclaration: declaration
|
|
809
|
+
};
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
function createInheritanceChain(repository, classMirror) {
|
|
814
|
+
return _function.pipe(
|
|
815
|
+
O__namespace.fromNullable(classMirror.extended_class),
|
|
816
|
+
O__namespace.match(
|
|
817
|
+
() => [],
|
|
818
|
+
(extendedClassName) => inheritanceChainFromParentClassName(repository, extendedClassName)
|
|
819
|
+
)
|
|
820
|
+
);
|
|
821
|
+
}
|
|
822
|
+
function inheritanceChainFromParentClassName(repository, className) {
|
|
823
|
+
return _function.pipe(
|
|
824
|
+
O__namespace.fromNullable(repository.find((type) => type.name.toLowerCase() === className.toLowerCase())),
|
|
825
|
+
O__namespace.match(
|
|
826
|
+
() => [className],
|
|
827
|
+
(extendedClass) => [className, ...createInheritanceChain(repository, extendedClass)]
|
|
828
|
+
)
|
|
829
|
+
);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
const parsedFilesToTypes = (parsedFiles) => parsedFiles.map((parsedFile) => parsedFile.type);
|
|
833
|
+
|
|
834
|
+
var __defProp$d = Object.defineProperty;
|
|
835
|
+
var __defProps$d = Object.defineProperties;
|
|
836
|
+
var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
|
|
837
|
+
var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
|
|
838
|
+
var __hasOwnProp$d = Object.prototype.hasOwnProperty;
|
|
839
|
+
var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
|
|
840
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
841
|
+
var __spreadValues$d = (a, b) => {
|
|
842
|
+
for (var prop in b || (b = {}))
|
|
843
|
+
if (__hasOwnProp$d.call(b, prop))
|
|
844
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
845
|
+
if (__getOwnPropSymbols$d)
|
|
846
|
+
for (var prop of __getOwnPropSymbols$d(b)) {
|
|
847
|
+
if (__propIsEnum$d.call(b, prop))
|
|
848
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
849
|
+
}
|
|
850
|
+
return a;
|
|
851
|
+
};
|
|
852
|
+
var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
|
|
853
|
+
const addInheritanceChainToTypes = (parsedFiles) => parsedFiles.map((parsedFile) => __spreadProps$d(__spreadValues$d({}, parsedFile), {
|
|
854
|
+
type: addInheritanceChain(parsedFile.type, parsedFilesToTypes(parsedFiles))
|
|
855
|
+
}));
|
|
856
|
+
function addInheritanceChain(current, repository) {
|
|
857
|
+
if (current.type_name === "enum" || current.type_name === "interface") {
|
|
858
|
+
return current;
|
|
859
|
+
} else {
|
|
860
|
+
const inheritanceChain = createInheritanceChain(repository, current);
|
|
861
|
+
return __spreadProps$d(__spreadValues$d({}, current), {
|
|
862
|
+
inheritanceChain
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
var __defProp$c = Object.defineProperty;
|
|
868
|
+
var __defProps$c = Object.defineProperties;
|
|
869
|
+
var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
|
|
870
|
+
var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
|
|
871
|
+
var __hasOwnProp$c = Object.prototype.hasOwnProperty;
|
|
872
|
+
var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
|
|
873
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
874
|
+
var __spreadValues$c = (a, b) => {
|
|
875
|
+
for (var prop in b || (b = {}))
|
|
876
|
+
if (__hasOwnProp$c.call(b, prop))
|
|
877
|
+
__defNormalProp$c(a, prop, b[prop]);
|
|
878
|
+
if (__getOwnPropSymbols$c)
|
|
879
|
+
for (var prop of __getOwnPropSymbols$c(b)) {
|
|
880
|
+
if (__propIsEnum$c.call(b, prop))
|
|
881
|
+
__defNormalProp$c(a, prop, b[prop]);
|
|
882
|
+
}
|
|
883
|
+
return a;
|
|
884
|
+
};
|
|
885
|
+
var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
|
|
886
|
+
const addInheritedMembersToTypes = (parsedFiles) => parsedFiles.map((parsedFile) => addInheritedMembers(parsedFilesToTypes(parsedFiles), parsedFile));
|
|
887
|
+
function addInheritedMembers(repository, parsedFile) {
|
|
888
|
+
function addInheritedMembersToType(repository2, current) {
|
|
889
|
+
if (current.type_name === "enum") {
|
|
890
|
+
return current;
|
|
891
|
+
} else if (current.type_name === "interface") {
|
|
892
|
+
return addInheritedInterfaceMethods(current, repository2);
|
|
893
|
+
} else {
|
|
894
|
+
return addInheritedClassMembers(current, repository2);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
return __spreadProps$c(__spreadValues$c({}, parsedFile), {
|
|
898
|
+
type: addInheritedMembersToType(repository, parsedFile.type)
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
function addInheritedInterfaceMethods(interfaceMirror, repository) {
|
|
902
|
+
function methodAlreadyExists(memberName, members) {
|
|
903
|
+
return members.some((member) => member.name.toLowerCase() === memberName.toLowerCase());
|
|
904
|
+
}
|
|
905
|
+
function parentExtractor(interfaceMirror2) {
|
|
906
|
+
return interfaceMirror2.extended_interfaces;
|
|
907
|
+
}
|
|
908
|
+
const parents = getParents(parentExtractor, interfaceMirror, repository);
|
|
909
|
+
return __spreadProps$c(__spreadValues$c({}, interfaceMirror), {
|
|
910
|
+
methods: parents.reduce(
|
|
911
|
+
(acc, currentValue) => [
|
|
912
|
+
...acc,
|
|
913
|
+
...currentValue.methods.filter((method) => !methodAlreadyExists(method.name, acc)).map((method) => __spreadProps$c(__spreadValues$c({}, method), {
|
|
914
|
+
inherited: true
|
|
915
|
+
}))
|
|
916
|
+
],
|
|
917
|
+
interfaceMirror.methods
|
|
918
|
+
)
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
function addInheritedClassMembers(classMirror, repository) {
|
|
922
|
+
function memberAlreadyExists(memberName, members) {
|
|
923
|
+
return members.some((member) => member.name.toLowerCase() === memberName.toLowerCase());
|
|
924
|
+
}
|
|
925
|
+
function parentExtractor(classMirror2) {
|
|
926
|
+
return classMirror2.extended_class ? [classMirror2.extended_class] : [];
|
|
927
|
+
}
|
|
928
|
+
function filterMember(members, existing) {
|
|
929
|
+
return members.filter((member) => member.access_modifier.toLowerCase() !== "private").filter((member) => !memberAlreadyExists(member.name, existing)).map((member) => __spreadProps$c(__spreadValues$c({}, member), {
|
|
930
|
+
inherited: true
|
|
931
|
+
}));
|
|
932
|
+
}
|
|
933
|
+
const parents = getParents(parentExtractor, classMirror, repository);
|
|
934
|
+
return __spreadProps$c(__spreadValues$c({}, classMirror), {
|
|
935
|
+
fields: parents.reduce(
|
|
936
|
+
(acc, currentValue) => [...acc, ...filterMember(currentValue.fields, acc)],
|
|
937
|
+
classMirror.fields
|
|
938
|
+
),
|
|
939
|
+
properties: parents.reduce(
|
|
940
|
+
(acc, currentValue) => [...acc, ...filterMember(currentValue.properties, acc)],
|
|
941
|
+
classMirror.properties
|
|
942
|
+
),
|
|
943
|
+
methods: parents.reduce(
|
|
944
|
+
(acc, currentValue) => [...acc, ...filterMember(currentValue.methods, acc)],
|
|
945
|
+
classMirror.methods
|
|
946
|
+
)
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
function getParents(extendedNamesExtractor, current, repository) {
|
|
950
|
+
return _function.pipe(
|
|
951
|
+
extendedNamesExtractor(current),
|
|
952
|
+
(interfaces) => interfaces.map((interfaceName) => repository.find((type) => type.name === interfaceName)),
|
|
953
|
+
(interfaces = []) => interfaces.filter((type) => type !== void 0),
|
|
954
|
+
(interfaces) => interfaces.reduce(
|
|
955
|
+
(acc, current2) => [...acc, ...getParents(extendedNamesExtractor, current2, repository)],
|
|
956
|
+
interfaces
|
|
957
|
+
)
|
|
958
|
+
);
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
const typeDocPartial = `
|
|
962
|
+
{{#> documentablePartialTemplate}}
|
|
963
|
+
|
|
964
|
+
{{#if doc.group}}
|
|
965
|
+
**Group** {{doc.group}}
|
|
966
|
+
{{/if}}
|
|
967
|
+
|
|
968
|
+
{{#if doc.author}}
|
|
969
|
+
**Author** {{doc.author}}
|
|
970
|
+
{{/if}}
|
|
971
|
+
|
|
972
|
+
{{#if doc.date}}
|
|
973
|
+
**Date** {{doc.date}}
|
|
974
|
+
{{/if}}
|
|
975
|
+
|
|
976
|
+
{{#each doc.sees}}
|
|
977
|
+
**See** {{link this}}
|
|
978
|
+
|
|
979
|
+
{{/each}}
|
|
980
|
+
|
|
981
|
+
{{#if namespace}}
|
|
982
|
+
## Namespace
|
|
983
|
+
{{namespace}}
|
|
984
|
+
{{/if}}
|
|
985
|
+
|
|
986
|
+
{{/documentablePartialTemplate}}
|
|
987
|
+
`.trim();
|
|
988
|
+
|
|
989
|
+
const documentablePartialTemplate = `
|
|
990
|
+
{{#each doc.annotations}}
|
|
991
|
+
\`{{this}}\`
|
|
992
|
+
{{/each}}
|
|
993
|
+
|
|
994
|
+
{{{renderContent doc.description}}}
|
|
995
|
+
|
|
996
|
+
{{#each doc.customTags}}
|
|
997
|
+
**{{splitAndCapitalize name}}**
|
|
998
|
+
|
|
999
|
+
{{{renderContent description}}}
|
|
1000
|
+
|
|
1001
|
+
{{/each}}
|
|
1002
|
+
|
|
1003
|
+
{{> @partial-block}}
|
|
1004
|
+
|
|
1005
|
+
{{#if doc.mermaid.value}}
|
|
1006
|
+
{{ heading doc.mermaid.headingLevel doc.mermaid.heading }}
|
|
1007
|
+
{{code doc.mermaid.value}}
|
|
1008
|
+
{{/if}}
|
|
1009
|
+
|
|
1010
|
+
{{#if doc.example.value}}
|
|
1011
|
+
{{ heading doc.example.headingLevel doc.example.heading }}
|
|
1012
|
+
{{{renderContent doc.example.value}}}
|
|
1013
|
+
{{/if}}
|
|
1014
|
+
`.trim();
|
|
1015
|
+
|
|
1016
|
+
const methodsPartialTemplate = `
|
|
1017
|
+
{{ heading headingLevel heading }}
|
|
1018
|
+
{{#each value}}
|
|
1019
|
+
{{{ heading headingLevel (inlineCode heading) }}}
|
|
1020
|
+
|
|
1021
|
+
{{#if inherited}}
|
|
1022
|
+
*Inherited*
|
|
1023
|
+
{{/if}}
|
|
1024
|
+
|
|
1025
|
+
{{#> documentablePartialTemplate}}
|
|
1026
|
+
|
|
1027
|
+
{{ heading signature.headingLevel signature.heading }}
|
|
1028
|
+
{{ code signature.value }}
|
|
1029
|
+
|
|
1030
|
+
{{#if parameters.value}}
|
|
1031
|
+
{{ heading parameters.headingLevel parameters.heading }}
|
|
1032
|
+
| Name | Type | Description |
|
|
1033
|
+
|------|------|-------------|
|
|
1034
|
+
{{#each parameters.value}}
|
|
1035
|
+
| {{name}} | {{link type}} | {{{renderContent description}}} |
|
|
1036
|
+
{{/each}}
|
|
1037
|
+
{{/if}}
|
|
1038
|
+
|
|
1039
|
+
{{ heading returnType.headingLevel returnType.heading }}
|
|
1040
|
+
**{{link returnType.value.type}}**
|
|
1041
|
+
|
|
1042
|
+
{{#if returnType.value.description}}
|
|
1043
|
+
{{returnType.value.description}}
|
|
1044
|
+
{{/if}}
|
|
1045
|
+
|
|
1046
|
+
{{#if throws.value}}
|
|
1047
|
+
{{ heading throws.headingLevel throws.heading }}
|
|
1048
|
+
{{#each throws.value}}
|
|
1049
|
+
{{link this.type}}: {{this.description}}
|
|
1050
|
+
|
|
1051
|
+
{{/each}}
|
|
1052
|
+
{{/if}}
|
|
1053
|
+
{{/documentablePartialTemplate}}
|
|
1054
|
+
|
|
1055
|
+
{{#unless @last}}---{{/unless}}
|
|
1056
|
+
|
|
1057
|
+
{{/each}}
|
|
1058
|
+
`.trim();
|
|
1059
|
+
|
|
1060
|
+
const groupedMembersPartialTemplate = `
|
|
1061
|
+
{{ heading headingLevel heading }}
|
|
1062
|
+
{{#each value}}
|
|
1063
|
+
{{> (lookup .. "subTemplate") this}}
|
|
1064
|
+
{{/each}}
|
|
1065
|
+
`.trim();
|
|
1066
|
+
|
|
1067
|
+
const constructorsPartialTemplate = `
|
|
1068
|
+
{{ heading headingLevel heading }}
|
|
1069
|
+
{{#each value}}
|
|
1070
|
+
{{{ heading headingLevel (inlineCode heading) }}}
|
|
1071
|
+
|
|
1072
|
+
{{#> documentablePartialTemplate}}
|
|
1073
|
+
|
|
1074
|
+
{{ heading signature.headingLevel signature.heading }}
|
|
1075
|
+
{{ code signature.value }}
|
|
1076
|
+
|
|
1077
|
+
{{#if parameters.value}}
|
|
1078
|
+
{{ heading parameters.headingLevel parameters.heading }}
|
|
1079
|
+
| Name | Type | Description |
|
|
1080
|
+
|------|------|-------------|
|
|
1081
|
+
{{#each parameters.value}}
|
|
1082
|
+
| {{name}} | {{link type}} | {{description}} |
|
|
1083
|
+
{{/each}}
|
|
1084
|
+
{{/if}}
|
|
1085
|
+
|
|
1086
|
+
{{#if throws.value}}
|
|
1087
|
+
{{ heading throws.headingLevel throws.heading }}
|
|
1088
|
+
{{#each throws.value}}
|
|
1089
|
+
{{link this.type}}: {{this.description}}
|
|
1090
|
+
|
|
1091
|
+
{{/each}}
|
|
1092
|
+
{{/if}}
|
|
1093
|
+
{{/documentablePartialTemplate}}
|
|
1094
|
+
|
|
1095
|
+
{{#unless @last}}---{{/unless}}
|
|
1096
|
+
|
|
1097
|
+
{{/each}}
|
|
1098
|
+
`.trim();
|
|
1099
|
+
|
|
1100
|
+
const fieldsPartialTemplate = `
|
|
1101
|
+
{{ heading headingLevel heading }}
|
|
1102
|
+
{{#each value}}
|
|
1103
|
+
{{{ heading headingLevel (inlineCode heading) }}}
|
|
1104
|
+
|
|
1105
|
+
{{#if inherited}}
|
|
1106
|
+
*Inherited*
|
|
1107
|
+
{{/if}}
|
|
1108
|
+
|
|
1109
|
+
{{#> documentablePartialTemplate }}
|
|
1110
|
+
|
|
1111
|
+
{{ heading signature.headingLevel signature.heading }}
|
|
1112
|
+
{{ code signature.value }}
|
|
1113
|
+
|
|
1114
|
+
{{ heading type.headingLevel type.heading }}
|
|
1115
|
+
{{link type.value}}
|
|
1116
|
+
|
|
1117
|
+
{{/documentablePartialTemplate}}
|
|
1118
|
+
|
|
1119
|
+
{{#unless @last}}---{{/unless}}
|
|
1120
|
+
|
|
1121
|
+
{{/each}}
|
|
1122
|
+
`.trim();
|
|
1123
|
+
|
|
1124
|
+
const classMarkdownTemplate = `
|
|
1125
|
+
{{ heading headingLevel heading }}
|
|
1126
|
+
{{#if classModifier}}
|
|
1127
|
+
\`{{classModifier}}\`
|
|
1128
|
+
{{/if}}
|
|
1129
|
+
|
|
1130
|
+
{{> typeDocumentation}}
|
|
1131
|
+
|
|
1132
|
+
{{#if extends.length}}
|
|
1133
|
+
**Inheritance**
|
|
1134
|
+
|
|
1135
|
+
{{#each extends}}{{link this}}{{#unless @last}} < {{/unless}}{{/each}}
|
|
1136
|
+
{{/if}}
|
|
1137
|
+
|
|
1138
|
+
{{#if implements}}
|
|
1139
|
+
**Implements**
|
|
1140
|
+
|
|
1141
|
+
{{#each implements}}
|
|
1142
|
+
{{link this}}{{#unless @last}}, {{/unless}}
|
|
1143
|
+
{{/each}}
|
|
1144
|
+
{{/if}}
|
|
1145
|
+
|
|
1146
|
+
{{#if fields.value}}
|
|
1147
|
+
{{#if fields.isGrouped}}
|
|
1148
|
+
{{> groupedMembersPartialTemplate fields subTemplate="fieldsPartialTemplate"}}
|
|
1149
|
+
{{else}}
|
|
1150
|
+
{{> fieldsPartialTemplate fields}}
|
|
1151
|
+
{{/if}}
|
|
1152
|
+
{{/if}}
|
|
1153
|
+
|
|
1154
|
+
{{#if properties.value}}
|
|
1155
|
+
{{#if properties.isGrouped}}
|
|
1156
|
+
{{> groupedMembersPartialTemplate properties subTemplate="fieldsPartialTemplate"}}
|
|
1157
|
+
{{else}}
|
|
1158
|
+
{{> fieldsPartialTemplate properties}}
|
|
1159
|
+
{{/if}}
|
|
1160
|
+
{{/if}}
|
|
1161
|
+
|
|
1162
|
+
{{#if constructors.value}}
|
|
1163
|
+
{{#if constructors.isGrouped}}
|
|
1164
|
+
{{> groupedMembersPartialTemplate constructors subTemplate="constructorsPartialTemplate"}}
|
|
1165
|
+
{{else}}
|
|
1166
|
+
{{> constructorsPartialTemplate constructors}}
|
|
1167
|
+
{{/if}}
|
|
1168
|
+
{{/if}}
|
|
1169
|
+
|
|
1170
|
+
{{#if methods.value}}
|
|
1171
|
+
{{#if methods.isGrouped}}
|
|
1172
|
+
{{> groupedMembersPartialTemplate methods subTemplate="methodsPartialTemplate"}}
|
|
1173
|
+
{{else}}
|
|
1174
|
+
{{> methodsPartialTemplate methods}}
|
|
1175
|
+
{{/if}}
|
|
1176
|
+
{{/if}}
|
|
1177
|
+
|
|
1178
|
+
{{#if innerClasses.value}}
|
|
1179
|
+
{{ heading innerClasses.headingLevel innerClasses.heading }}
|
|
1180
|
+
{{#each innerClasses.value}}
|
|
1181
|
+
{{> classTemplate this}}
|
|
1182
|
+
{{/each}}
|
|
1183
|
+
{{/if}}
|
|
1184
|
+
|
|
1185
|
+
{{#if innerEnums.value}}
|
|
1186
|
+
{{ heading innerEnums.headingLevel innerEnums.heading }}
|
|
1187
|
+
{{#each innerEnums.value}}
|
|
1188
|
+
{{> enumTemplate this}}
|
|
1189
|
+
{{/each}}
|
|
1190
|
+
{{/if}}
|
|
1191
|
+
|
|
1192
|
+
{{#if innerInterfaces.value}}
|
|
1193
|
+
{{ heading innerInterfaces.headingLevel innerInterfaces.heading }}
|
|
1194
|
+
{{#each innerInterfaces.value}}
|
|
1195
|
+
{{> interfaceTemplate this}}
|
|
1196
|
+
{{/each}}
|
|
1197
|
+
{{/if}}
|
|
1198
|
+
`.trim();
|
|
1199
|
+
|
|
1200
|
+
const enumMarkdownTemplate = `
|
|
1201
|
+
{{ heading headingLevel heading }}
|
|
1202
|
+
|
|
1203
|
+
{{> typeDocumentation }}
|
|
1204
|
+
|
|
1205
|
+
{{ heading values.headingLevel values.heading }}
|
|
1206
|
+
| Value | Description |
|
|
1207
|
+
|-------|-------------|
|
|
1208
|
+
{{#each values.value}}
|
|
1209
|
+
| {{value}} | {{description}} |
|
|
1210
|
+
{{/each}}
|
|
1211
|
+
`.trim();
|
|
1212
|
+
|
|
1213
|
+
const interfaceMarkdownTemplate = `
|
|
1214
|
+
{{ heading headingLevel heading }}
|
|
1215
|
+
|
|
1216
|
+
{{> typeDocumentation }}
|
|
1217
|
+
|
|
1218
|
+
{{#if extends}}
|
|
1219
|
+
**Extends**
|
|
1220
|
+
{{#each extends}}
|
|
1221
|
+
{{link this}}{{#unless @last}}, {{/unless}}
|
|
1222
|
+
{{/each}}
|
|
1223
|
+
{{/if}}
|
|
1224
|
+
|
|
1225
|
+
{{#if methods}}
|
|
1226
|
+
{{> methodsPartialTemplate methods}}
|
|
1227
|
+
{{/if}}
|
|
1228
|
+
`.trim();
|
|
1229
|
+
|
|
1230
|
+
class Template {
|
|
1231
|
+
constructor() {
|
|
1232
|
+
Handlebars.registerPartial("typeDocumentation", typeDocPartial);
|
|
1233
|
+
Handlebars.registerPartial("documentablePartialTemplate", documentablePartialTemplate);
|
|
1234
|
+
Handlebars.registerPartial("methodsPartialTemplate", methodsPartialTemplate);
|
|
1235
|
+
Handlebars.registerPartial("constructorsPartialTemplate", constructorsPartialTemplate);
|
|
1236
|
+
Handlebars.registerPartial("groupedMembersPartialTemplate", groupedMembersPartialTemplate);
|
|
1237
|
+
Handlebars.registerPartial("fieldsPartialTemplate", fieldsPartialTemplate);
|
|
1238
|
+
Handlebars.registerPartial("classTemplate", classMarkdownTemplate);
|
|
1239
|
+
Handlebars.registerPartial("enumTemplate", enumMarkdownTemplate);
|
|
1240
|
+
Handlebars.registerPartial("interfaceTemplate", interfaceMarkdownTemplate);
|
|
1241
|
+
Handlebars.registerHelper("link", link);
|
|
1242
|
+
Handlebars.registerHelper("code", convertCodeBlock);
|
|
1243
|
+
Handlebars.registerHelper("renderContent", resolveRenderableContent);
|
|
1244
|
+
Handlebars.registerHelper("heading", heading);
|
|
1245
|
+
Handlebars.registerHelper("inlineCode", inlineCode);
|
|
1246
|
+
Handlebars.registerHelper("splitAndCapitalize", splitAndCapitalize);
|
|
1247
|
+
}
|
|
1248
|
+
static getInstance() {
|
|
1249
|
+
if (!Template.instance) {
|
|
1250
|
+
Template.instance = new Template();
|
|
1251
|
+
}
|
|
1252
|
+
return Template.instance;
|
|
1253
|
+
}
|
|
1254
|
+
compile(request) {
|
|
1255
|
+
const compiled = Handlebars.compile(request.template);
|
|
1256
|
+
return compiled(request.source).trim().replace(/\n{3,}/g, "\n\n");
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
const splitAndCapitalize = (text) => {
|
|
1260
|
+
const words = text.split(/[-_]+/);
|
|
1261
|
+
const capitalizedWords = [];
|
|
1262
|
+
for (const word of words) {
|
|
1263
|
+
capitalizedWords.push(word.charAt(0).toUpperCase() + word.slice(1));
|
|
1264
|
+
}
|
|
1265
|
+
return capitalizedWords.join(" ");
|
|
1266
|
+
};
|
|
1267
|
+
const heading = (level, text) => {
|
|
1268
|
+
return `${"#".repeat(level)} ${text}`;
|
|
1269
|
+
};
|
|
1270
|
+
const inlineCode = (text) => {
|
|
1271
|
+
return new Handlebars.SafeString(`\`${text}\``);
|
|
1272
|
+
};
|
|
1273
|
+
const convertCodeBlock = (codeBlock) => {
|
|
1274
|
+
return new Handlebars.SafeString(
|
|
1275
|
+
`
|
|
1276
|
+
\`\`\`${codeBlock.language}
|
|
1277
|
+
${codeBlock.content.join("\n")}
|
|
1278
|
+
\`\`\`
|
|
1279
|
+
`.trim()
|
|
1280
|
+
);
|
|
1281
|
+
};
|
|
1282
|
+
const resolveRenderableContent = (description) => {
|
|
1283
|
+
if (!description) {
|
|
1284
|
+
return "";
|
|
1285
|
+
}
|
|
1286
|
+
function reduceDescription(acc, curr) {
|
|
1287
|
+
if (isEmptyLine(curr)) {
|
|
1288
|
+
return acc + "\n";
|
|
1289
|
+
}
|
|
1290
|
+
if (isCodeBlock(curr)) {
|
|
1291
|
+
return acc + convertCodeBlock(curr) + "\n";
|
|
1292
|
+
}
|
|
1293
|
+
if (isInlineCode(curr)) {
|
|
1294
|
+
return acc + inlineCode(curr.content).toString() + " ";
|
|
1295
|
+
} else {
|
|
1296
|
+
return acc + Handlebars.escapeExpression(link(curr)).trim() + " ";
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
return description.reduce(reduceDescription, "").trim();
|
|
1300
|
+
};
|
|
1301
|
+
const link = (source) => {
|
|
1302
|
+
if (typeof source === "string") {
|
|
1303
|
+
return source;
|
|
1304
|
+
} else {
|
|
1305
|
+
return `[${source.title}](${source.url})`;
|
|
1306
|
+
}
|
|
1307
|
+
};
|
|
1308
|
+
|
|
1309
|
+
var __defProp$b = Object.defineProperty;
|
|
1310
|
+
var __defProps$b = Object.defineProperties;
|
|
1311
|
+
var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
|
|
1312
|
+
var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
|
|
1313
|
+
var __hasOwnProp$b = Object.prototype.hasOwnProperty;
|
|
1314
|
+
var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
|
|
1315
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1316
|
+
var __spreadValues$b = (a, b) => {
|
|
1317
|
+
for (var prop in b || (b = {}))
|
|
1318
|
+
if (__hasOwnProp$b.call(b, prop))
|
|
1319
|
+
__defNormalProp$b(a, prop, b[prop]);
|
|
1320
|
+
if (__getOwnPropSymbols$b)
|
|
1321
|
+
for (var prop of __getOwnPropSymbols$b(b)) {
|
|
1322
|
+
if (__propIsEnum$b.call(b, prop))
|
|
1323
|
+
__defNormalProp$b(a, prop, b[prop]);
|
|
1324
|
+
}
|
|
1325
|
+
return a;
|
|
1326
|
+
};
|
|
1327
|
+
var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
|
|
1328
|
+
const commonDefaults = {
|
|
1329
|
+
targetDir: "./docs/"
|
|
1330
|
+
};
|
|
1331
|
+
const markdownDefaults = __spreadProps$b(__spreadValues$b({}, commonDefaults), {
|
|
1332
|
+
scope: ["global"],
|
|
1333
|
+
defaultGroupName: "Miscellaneous",
|
|
1334
|
+
includeMetadata: false,
|
|
1335
|
+
sortAlphabetically: false,
|
|
1336
|
+
linkingStrategy: "relative",
|
|
1337
|
+
referenceGuideTitle: "Apex Reference Guide",
|
|
1338
|
+
excludedTags: []
|
|
1339
|
+
});
|
|
1340
|
+
const openApiDefaults = __spreadProps$b(__spreadValues$b({}, commonDefaults), {
|
|
1341
|
+
fileName: "openapi",
|
|
1342
|
+
title: "Apex REST API",
|
|
1343
|
+
apiVersion: "1.0.0"
|
|
1344
|
+
});
|
|
1345
|
+
|
|
1346
|
+
const convertToDocumentationBundle = (referenceGuideTitle, referenceGuideTemplate, { referencesByGroup, renderables }) => ({
|
|
1347
|
+
referenceGuide: {
|
|
1348
|
+
frontmatter: null,
|
|
1349
|
+
content: referencesToReferenceGuideContent(referenceGuideTitle, referencesByGroup, referenceGuideTemplate),
|
|
1350
|
+
outputDocPath: "index.md"
|
|
1351
|
+
},
|
|
1352
|
+
docs: renderables.map(
|
|
1353
|
+
(renderable) => renderableToPageData(Object.values(referencesByGroup).flat(), renderable)
|
|
1354
|
+
)
|
|
1355
|
+
});
|
|
1356
|
+
function referencesToReferenceGuideContent(referenceGuideTitle, references, template) {
|
|
1357
|
+
function alphabetizeReferences(references2) {
|
|
1358
|
+
return Object.keys(references2).sort((a, b) => a.localeCompare(b)).reduce((acc, key) => {
|
|
1359
|
+
acc[key] = references2[key].sort((a, b) => a.title.toString().localeCompare(b.title.toString()));
|
|
1360
|
+
return acc;
|
|
1361
|
+
}, {});
|
|
1362
|
+
}
|
|
1363
|
+
return _function.pipe(
|
|
1364
|
+
references,
|
|
1365
|
+
alphabetizeReferences,
|
|
1366
|
+
(references2) => compile({
|
|
1367
|
+
template,
|
|
1368
|
+
source: { referenceGuideTitle, references: references2 }
|
|
1369
|
+
})
|
|
1370
|
+
);
|
|
1371
|
+
}
|
|
1372
|
+
function renderableToPageData(referenceGuideReference, renderable) {
|
|
1373
|
+
function buildDocOutput(renderable2, docContents) {
|
|
1374
|
+
var _a;
|
|
1375
|
+
const reference = referenceGuideReference.find(
|
|
1376
|
+
(ref) => ref.reference.source.name.toLowerCase() === renderable2.name.toLowerCase()
|
|
1377
|
+
);
|
|
1378
|
+
return {
|
|
1379
|
+
source: {
|
|
1380
|
+
filePath: renderable2.filePath,
|
|
1381
|
+
name: renderable2.name,
|
|
1382
|
+
type: renderable2.type
|
|
1383
|
+
},
|
|
1384
|
+
outputDocPath: reference.reference.outputDocPath,
|
|
1385
|
+
frontmatter: null,
|
|
1386
|
+
content: docContents,
|
|
1387
|
+
group: (_a = renderable2.doc.group) != null ? _a : markdownDefaults.defaultGroupName
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
return _function.pipe(renderable, resolveApexTypeTemplate, compile, (docContents) => buildDocOutput(renderable, docContents));
|
|
1391
|
+
}
|
|
1392
|
+
function resolveApexTypeTemplate(renderable) {
|
|
1393
|
+
function getTemplate(renderable2) {
|
|
1394
|
+
switch (renderable2.type) {
|
|
1395
|
+
case "enum":
|
|
1396
|
+
return enumMarkdownTemplate;
|
|
1397
|
+
case "interface":
|
|
1398
|
+
return interfaceMarkdownTemplate;
|
|
1399
|
+
case "class":
|
|
1400
|
+
return classMarkdownTemplate;
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
return {
|
|
1404
|
+
template: getTemplate(renderable),
|
|
1405
|
+
source: renderable
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
function compile(request) {
|
|
1409
|
+
return Template.getInstance().compile(request);
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
var __defProp$a = Object.defineProperty;
|
|
1413
|
+
var __defProps$a = Object.defineProperties;
|
|
1414
|
+
var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
|
|
1415
|
+
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
1416
|
+
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
1417
|
+
var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
|
|
1418
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1419
|
+
var __spreadValues$a = (a, b) => {
|
|
1420
|
+
for (var prop in b || (b = {}))
|
|
1421
|
+
if (__hasOwnProp$a.call(b, prop))
|
|
1422
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
1423
|
+
if (__getOwnPropSymbols$a)
|
|
1424
|
+
for (var prop of __getOwnPropSymbols$a(b)) {
|
|
1425
|
+
if (__propIsEnum$a.call(b, prop))
|
|
1426
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
1427
|
+
}
|
|
1428
|
+
return a;
|
|
1429
|
+
};
|
|
1430
|
+
var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
|
|
1431
|
+
class Manifest {
|
|
1432
|
+
/**
|
|
1433
|
+
* Constructs a new Manifest object.
|
|
1434
|
+
* @param types List of types to be wrapped by this object.
|
|
1435
|
+
* @param isForInnerTypes Whether this manifest represent an inner type or not.
|
|
1436
|
+
*/
|
|
1437
|
+
constructor(types, isForInnerTypes = false) {
|
|
1438
|
+
this.types = types;
|
|
1439
|
+
this.isForInnerTypes = isForInnerTypes;
|
|
1440
|
+
}
|
|
1441
|
+
filteredByAccessModifierAndAnnotations(modifiers) {
|
|
1442
|
+
const filteredTypes = Manifest.filterAccessibleModifier(this.types, modifiers);
|
|
1443
|
+
const typesToReturn = [];
|
|
1444
|
+
for (const filteredType of filteredTypes) {
|
|
1445
|
+
typesToReturn.push(Manifest.filterSingleType(filteredType, modifiers, this.isForInnerTypes));
|
|
1446
|
+
}
|
|
1447
|
+
return typesToReturn;
|
|
1448
|
+
}
|
|
1449
|
+
static filterSingleType(currentType, modifiers, isForInnerTypes) {
|
|
1450
|
+
if (currentType.type_name === "enum") {
|
|
1451
|
+
return currentType;
|
|
1452
|
+
}
|
|
1453
|
+
if (currentType.type_name === "interface") {
|
|
1454
|
+
const currentInterface = currentType;
|
|
1455
|
+
return __spreadProps$a(__spreadValues$a({}, currentType), {
|
|
1456
|
+
methods: this.filterAccessibleModifier(currentInterface.methods, modifiers)
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
const currentClass = currentType;
|
|
1460
|
+
const filteredClass = __spreadProps$a(__spreadValues$a({}, currentType), {
|
|
1461
|
+
methods: this.filterAccessibleModifier(currentClass.methods, modifiers),
|
|
1462
|
+
properties: this.filterAccessibleModifier(currentClass.properties, modifiers),
|
|
1463
|
+
fields: this.filterAccessibleModifier(currentClass.fields, modifiers),
|
|
1464
|
+
constructors: this.filterAccessibleModifier(currentClass.constructors, modifiers)
|
|
1465
|
+
});
|
|
1466
|
+
if (!isForInnerTypes) {
|
|
1467
|
+
return __spreadProps$a(__spreadValues$a({}, filteredClass), {
|
|
1468
|
+
enums: this.filterAccessibleModifier(currentClass.enums, modifiers),
|
|
1469
|
+
interfaces: this.filterAccessibleModifier(currentClass.interfaces, modifiers),
|
|
1470
|
+
classes: new Manifest(currentClass.classes, true).filteredByAccessModifierAndAnnotations(
|
|
1471
|
+
modifiers
|
|
1472
|
+
)
|
|
1473
|
+
});
|
|
1474
|
+
}
|
|
1475
|
+
return filteredClass;
|
|
1476
|
+
}
|
|
1477
|
+
static filterAccessibleModifier(accessAndDocAware, modifiers) {
|
|
1478
|
+
return accessAndDocAware.filter((type) => this.shouldFilterType(type, modifiers));
|
|
1479
|
+
}
|
|
1480
|
+
static shouldFilterType(accessAndDocAware, modifiers) {
|
|
1481
|
+
var _a;
|
|
1482
|
+
const hasIgnoreDocAnnotation = (_a = accessAndDocAware.docComment) == null ? void 0 : _a.annotations.some(
|
|
1483
|
+
(annotation) => annotation.name.toLowerCase() === "ignore"
|
|
1484
|
+
);
|
|
1485
|
+
if (hasIgnoreDocAnnotation) {
|
|
1486
|
+
return false;
|
|
1487
|
+
}
|
|
1488
|
+
return modifiers.includes(accessAndDocAware.access_modifier) || accessAndDocAware.annotations.some((annotation) => modifiers.includes(annotation.type.toLowerCase()));
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
var __defProp$9 = Object.defineProperty;
|
|
1493
|
+
var __defProps$9 = Object.defineProperties;
|
|
1494
|
+
var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
|
|
1495
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
1496
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
1497
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
1498
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1499
|
+
var __spreadValues$9 = (a, b) => {
|
|
1500
|
+
for (var prop in b || (b = {}))
|
|
1501
|
+
if (__hasOwnProp$9.call(b, prop))
|
|
1502
|
+
__defNormalProp$9(a, prop, b[prop]);
|
|
1503
|
+
if (__getOwnPropSymbols$9)
|
|
1504
|
+
for (var prop of __getOwnPropSymbols$9(b)) {
|
|
1505
|
+
if (__propIsEnum$9.call(b, prop))
|
|
1506
|
+
__defNormalProp$9(a, prop, b[prop]);
|
|
1507
|
+
}
|
|
1508
|
+
return a;
|
|
1509
|
+
};
|
|
1510
|
+
var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
|
|
1511
|
+
function filterScope(scopes, parsedFiles) {
|
|
1512
|
+
return parsedFiles.filter(({ type }) => Manifest.shouldFilterType(type, scopes)).map((parsedFile) => {
|
|
1513
|
+
return __spreadProps$9(__spreadValues$9({}, parsedFile), {
|
|
1514
|
+
type: Manifest.filterSingleType(parsedFile.type, scopes, false)
|
|
1515
|
+
});
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
const hookableTemplate = `
|
|
1520
|
+
{{#if frontmatter}}
|
|
1521
|
+
{{{frontmatter}}}
|
|
1522
|
+
{{/if}}
|
|
1523
|
+
|
|
1524
|
+
{{{content}}}
|
|
1525
|
+
`.trim();
|
|
1526
|
+
|
|
1527
|
+
var __defProp$8 = Object.defineProperty;
|
|
1528
|
+
var __defProps$8 = Object.defineProperties;
|
|
1529
|
+
var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
|
|
1530
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
1531
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
1532
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
1533
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1534
|
+
var __spreadValues$8 = (a, b) => {
|
|
1535
|
+
for (var prop in b || (b = {}))
|
|
1536
|
+
if (__hasOwnProp$8.call(b, prop))
|
|
1537
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
1538
|
+
if (__getOwnPropSymbols$8)
|
|
1539
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
1540
|
+
if (__propIsEnum$8.call(b, prop))
|
|
1541
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
1542
|
+
}
|
|
1543
|
+
return a;
|
|
1544
|
+
};
|
|
1545
|
+
var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
|
|
1546
|
+
function sortTypesAndMembers(shouldSort, parsedFiles) {
|
|
1547
|
+
return parsedFiles.map((parsedFile) => __spreadProps$8(__spreadValues$8({}, parsedFile), {
|
|
1548
|
+
type: sortTypeMember(parsedFile.type, shouldSort)
|
|
1549
|
+
})).sort((a, b) => sortByNames(shouldSort, a.type, b.type));
|
|
1550
|
+
}
|
|
1551
|
+
function sortByNames(shouldSort, a, b) {
|
|
1552
|
+
if (shouldSort) {
|
|
1553
|
+
return a.name.localeCompare(b.name);
|
|
1554
|
+
}
|
|
1555
|
+
return 0;
|
|
1556
|
+
}
|
|
1557
|
+
function sortNamed(shouldSort, items) {
|
|
1558
|
+
return items.sort((a, b) => sortByNames(shouldSort, a, b));
|
|
1559
|
+
}
|
|
1560
|
+
function sortTypeMember(type, shouldSort) {
|
|
1561
|
+
switch (type.type_name) {
|
|
1562
|
+
case "enum":
|
|
1563
|
+
return sortEnumValues(shouldSort, type);
|
|
1564
|
+
case "interface":
|
|
1565
|
+
return sortInterfaceMethods(shouldSort, type);
|
|
1566
|
+
case "class":
|
|
1567
|
+
return sortClassMembers(shouldSort, type);
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
function sortEnumValues(shouldSort, enumType) {
|
|
1571
|
+
return __spreadProps$8(__spreadValues$8({}, enumType), {
|
|
1572
|
+
values: sortNamed(shouldSort, enumType.values)
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
function sortInterfaceMethods(shouldSort, interfaceType) {
|
|
1576
|
+
return __spreadProps$8(__spreadValues$8({}, interfaceType), {
|
|
1577
|
+
methods: sortNamed(shouldSort, interfaceType.methods)
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
function sortClassMembers(shouldSort, classType) {
|
|
1581
|
+
return __spreadProps$8(__spreadValues$8({}, classType), {
|
|
1582
|
+
fields: sortNamed(shouldSort, classType.fields),
|
|
1583
|
+
classes: sortNamed(shouldSort, classType.classes),
|
|
1584
|
+
enums: sortNamed(shouldSort, classType.enums),
|
|
1585
|
+
interfaces: sortNamed(shouldSort, classType.interfaces),
|
|
1586
|
+
methods: sortNamed(shouldSort, classType.methods),
|
|
1587
|
+
properties: sortNamed(shouldSort, classType.properties)
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
function isSkip(value) {
|
|
1592
|
+
return Object.prototype.hasOwnProperty.call(value, "_tag") && value._tag === "Skip";
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
function parsedFilesToReferenceGuide(config, parsedFiles) {
|
|
1596
|
+
return parsedFiles.reduce((acc, parsedFile) => {
|
|
1597
|
+
acc[parsedFile.type.name] = parsedFileToDocPageReference(config, parsedFile);
|
|
1598
|
+
return acc;
|
|
1599
|
+
}, {});
|
|
1600
|
+
}
|
|
1601
|
+
function parsedFileToDocPageReference(config, parsedFile) {
|
|
1602
|
+
const path = `${slugify(getTypeGroup(parsedFile.type, config))}/${parsedFile.type.name}.md`;
|
|
1603
|
+
return {
|
|
1604
|
+
source: parsedFile.source,
|
|
1605
|
+
displayName: parsedFile.type.name,
|
|
1606
|
+
outputDocPath: path,
|
|
1607
|
+
referencePath: path
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
function getTypeGroup(type, config) {
|
|
1611
|
+
var _a, _b;
|
|
1612
|
+
const groupAnnotation = (_a = type.docComment) == null ? void 0 : _a.annotations.find((annotation) => annotation.name.toLowerCase() === "group");
|
|
1613
|
+
return (_b = groupAnnotation == null ? void 0 : groupAnnotation.body) != null ? _b : config.defaultGroupName;
|
|
1614
|
+
}
|
|
1615
|
+
function slugify(text) {
|
|
1616
|
+
return text.toLowerCase().replace(/[^a-z0-9\s-]/g, "").trim().replace(/\s+/g, "-").replace(/-+/g, "-");
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
var __defProp$7 = Object.defineProperty;
|
|
1620
|
+
var __defProps$7 = Object.defineProperties;
|
|
1621
|
+
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
|
|
1622
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
1623
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
1624
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
1625
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1626
|
+
var __spreadValues$7 = (a, b) => {
|
|
1627
|
+
for (var prop in b || (b = {}))
|
|
1628
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
1629
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
1630
|
+
if (__getOwnPropSymbols$7)
|
|
1631
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
1632
|
+
if (__propIsEnum$7.call(b, prop))
|
|
1633
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
1634
|
+
}
|
|
1635
|
+
return a;
|
|
1636
|
+
};
|
|
1637
|
+
var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
|
|
1638
|
+
const removeExcludedTags = (excludedTags, parsedFiles) => {
|
|
1639
|
+
return parsedFiles.map((parsedFile) => {
|
|
1640
|
+
return __spreadProps$7(__spreadValues$7({}, parsedFile), {
|
|
1641
|
+
type: removeExcludedTagsFromType(excludedTags, parsedFile.type)
|
|
1642
|
+
});
|
|
1643
|
+
});
|
|
1644
|
+
};
|
|
1645
|
+
const removeExcludedTagsFromType = (excludedTags, type) => {
|
|
1646
|
+
return __spreadProps$7(__spreadValues$7({}, handleType(excludedTags, type)), {
|
|
1647
|
+
docComment: removeExcludedTagsFromDocComment(excludedTags, type.docComment)
|
|
1648
|
+
});
|
|
1649
|
+
};
|
|
1650
|
+
const handleType = (excludedTags, type) => {
|
|
1651
|
+
switch (type.type_name) {
|
|
1652
|
+
case "class":
|
|
1653
|
+
return handleClass(excludedTags, type);
|
|
1654
|
+
case "interface":
|
|
1655
|
+
return handleInterface(excludedTags, type);
|
|
1656
|
+
case "enum":
|
|
1657
|
+
return type;
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
const handleClass = (excludedTags, classMirror) => {
|
|
1661
|
+
return __spreadProps$7(__spreadValues$7({}, classMirror), {
|
|
1662
|
+
methods: classMirror.methods.map((method) => removeExcludedTagsFromDocumentable(excludedTags, method)),
|
|
1663
|
+
properties: classMirror.properties.map((property) => removeExcludedTagsFromDocumentable(excludedTags, property)),
|
|
1664
|
+
fields: classMirror.fields.map((field) => removeExcludedTagsFromDocumentable(excludedTags, field)),
|
|
1665
|
+
constructors: classMirror.constructors.map(
|
|
1666
|
+
(constructor) => removeExcludedTagsFromDocumentable(excludedTags, constructor)
|
|
1667
|
+
),
|
|
1668
|
+
enums: classMirror.enums.map((enumType) => removeExcludedTagsFromType(excludedTags, enumType)),
|
|
1669
|
+
interfaces: classMirror.interfaces.map((interfaceType) => removeExcludedTagsFromType(excludedTags, interfaceType)),
|
|
1670
|
+
classes: classMirror.classes.map((innerClass) => removeExcludedTagsFromType(excludedTags, innerClass))
|
|
1671
|
+
});
|
|
1672
|
+
};
|
|
1673
|
+
const handleInterface = (excludedTags, interfaceMirror) => {
|
|
1674
|
+
return __spreadProps$7(__spreadValues$7({}, interfaceMirror), {
|
|
1675
|
+
methods: interfaceMirror.methods.map((method) => removeExcludedTagsFromDocumentable(excludedTags, method))
|
|
1676
|
+
});
|
|
1677
|
+
};
|
|
1678
|
+
const removeExcludedTagsFromDocumentable = (excludedTags, documentable) => {
|
|
1679
|
+
return __spreadProps$7(__spreadValues$7({}, documentable), {
|
|
1680
|
+
docComment: removeExcludedTagsFromDocComment(excludedTags, documentable.docComment)
|
|
1681
|
+
});
|
|
1682
|
+
};
|
|
1683
|
+
const removeExcludedTagsFromDocComment = (excludedTags, docComment) => {
|
|
1684
|
+
const removerFn = apply(remove, excludedTags);
|
|
1685
|
+
return _function.pipe(
|
|
1686
|
+
O__namespace.fromNullable(docComment),
|
|
1687
|
+
O__namespace.map((docComment2) => removeExcludedTagsFromAnnotations(excludedTags, docComment2)),
|
|
1688
|
+
O__namespace.map((docComment2) => removeExampleTag(apply(removerFn, docComment2))),
|
|
1689
|
+
O__namespace.map((docComment2) => removeParamTags(apply(removerFn, docComment2))),
|
|
1690
|
+
O__namespace.map((docComment2) => removeReturnTag(apply(removerFn, docComment2))),
|
|
1691
|
+
O__namespace.map((docComment2) => removeThrowsTag(apply(removerFn, docComment2))),
|
|
1692
|
+
O__namespace.map((docComment2) => removeExceptionTag(apply(removerFn, docComment2))),
|
|
1693
|
+
O__namespace.map((docComment2) => removeDescription(apply(removerFn, docComment2))),
|
|
1694
|
+
O__namespace.fold(
|
|
1695
|
+
() => void 0,
|
|
1696
|
+
(updatedDocComment) => updatedDocComment
|
|
1697
|
+
)
|
|
1698
|
+
);
|
|
1699
|
+
};
|
|
1700
|
+
const removeExcludedTagsFromAnnotations = (excludedTags, docComment) => {
|
|
1701
|
+
return _function.pipe(
|
|
1702
|
+
O__namespace.some(docComment.annotations),
|
|
1703
|
+
O__namespace.map((annotations) => annotations.filter((annotation) => !includesIgnoreCase(excludedTags, annotation.name))),
|
|
1704
|
+
O__namespace.fold(
|
|
1705
|
+
() => docComment,
|
|
1706
|
+
(filteredAnnotations) => __spreadProps$7(__spreadValues$7({}, docComment), {
|
|
1707
|
+
annotations: filteredAnnotations
|
|
1708
|
+
})
|
|
1709
|
+
)
|
|
1710
|
+
);
|
|
1711
|
+
};
|
|
1712
|
+
const removeExampleTag = (remover) => {
|
|
1713
|
+
return remover("example", (docComment) => {
|
|
1714
|
+
return __spreadProps$7(__spreadValues$7({}, docComment), {
|
|
1715
|
+
exampleAnnotation: null
|
|
1716
|
+
});
|
|
1717
|
+
});
|
|
1718
|
+
};
|
|
1719
|
+
const removeParamTags = (remover) => {
|
|
1720
|
+
return remover("param", (docComment) => {
|
|
1721
|
+
return __spreadProps$7(__spreadValues$7({}, docComment), {
|
|
1722
|
+
paramAnnotations: []
|
|
1723
|
+
});
|
|
1724
|
+
});
|
|
1725
|
+
};
|
|
1726
|
+
const removeReturnTag = (remover) => {
|
|
1727
|
+
return remover("return", (docComment) => {
|
|
1728
|
+
return __spreadProps$7(__spreadValues$7({}, docComment), {
|
|
1729
|
+
returnAnnotation: null
|
|
1730
|
+
});
|
|
1731
|
+
});
|
|
1732
|
+
};
|
|
1733
|
+
const removeThrowsTag = (remover) => {
|
|
1734
|
+
return remover("throws", (docComment) => {
|
|
1735
|
+
return __spreadProps$7(__spreadValues$7({}, docComment), {
|
|
1736
|
+
throwsAnnotations: []
|
|
1737
|
+
});
|
|
1738
|
+
});
|
|
1739
|
+
};
|
|
1740
|
+
const removeExceptionTag = (remover) => {
|
|
1741
|
+
return remover("exception", (docComment) => {
|
|
1742
|
+
return __spreadProps$7(__spreadValues$7({}, docComment), {
|
|
1743
|
+
throwsAnnotations: []
|
|
1744
|
+
});
|
|
1745
|
+
});
|
|
1746
|
+
};
|
|
1747
|
+
const removeDescription = (remover) => {
|
|
1748
|
+
return remover("description", (docComment) => {
|
|
1749
|
+
return __spreadProps$7(__spreadValues$7({}, docComment), {
|
|
1750
|
+
description: "",
|
|
1751
|
+
descriptionLines: []
|
|
1752
|
+
});
|
|
1753
|
+
});
|
|
1754
|
+
};
|
|
1755
|
+
const remove = (excludedTags, docComment, tagName, removeFn) => {
|
|
1756
|
+
return boolean.match(
|
|
1757
|
+
() => docComment,
|
|
1758
|
+
() => removeFn(docComment)
|
|
1759
|
+
)(includesIgnoreCase(excludedTags, tagName) && !!docComment);
|
|
1760
|
+
};
|
|
1761
|
+
const includesIgnoreCase = (excluded, value) => {
|
|
1762
|
+
return excluded.some((element) => element.toLowerCase() === value.toLowerCase());
|
|
1763
|
+
};
|
|
1764
|
+
|
|
1765
|
+
var __defProp$6 = Object.defineProperty;
|
|
1766
|
+
var __defProps$6 = Object.defineProperties;
|
|
1767
|
+
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
|
1768
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
1769
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
1770
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
1771
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1772
|
+
var __spreadValues$6 = (a, b) => {
|
|
1773
|
+
for (var prop in b || (b = {}))
|
|
1774
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
1775
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
1776
|
+
if (__getOwnPropSymbols$6)
|
|
1777
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
1778
|
+
if (__propIsEnum$6.call(b, prop))
|
|
1779
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
1780
|
+
}
|
|
1781
|
+
return a;
|
|
1782
|
+
};
|
|
1783
|
+
var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
|
|
1784
|
+
var __async$4 = (__this, __arguments, generator) => {
|
|
1785
|
+
return new Promise((resolve, reject) => {
|
|
1786
|
+
var fulfilled = (value) => {
|
|
1787
|
+
try {
|
|
1788
|
+
step(generator.next(value));
|
|
1789
|
+
} catch (e) {
|
|
1790
|
+
reject(e);
|
|
1791
|
+
}
|
|
1792
|
+
};
|
|
1793
|
+
var rejected = (value) => {
|
|
1794
|
+
try {
|
|
1795
|
+
step(generator.throw(value));
|
|
1796
|
+
} catch (e) {
|
|
1797
|
+
reject(e);
|
|
1798
|
+
}
|
|
1799
|
+
};
|
|
1800
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
1801
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
1802
|
+
});
|
|
1803
|
+
};
|
|
1804
|
+
class HookError {
|
|
1805
|
+
constructor(error) {
|
|
1806
|
+
this.error = error;
|
|
1807
|
+
this._tag = "HookError";
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
function generateDocs(apexBundles, config) {
|
|
1811
|
+
const filterOutOfScope = apply(filterScope, config.scope);
|
|
1812
|
+
const convertToReferences = apply(parsedFilesToReferenceGuide, config);
|
|
1813
|
+
const convertToRenderableBundle = apply(parsedFilesToRenderableBundle, config);
|
|
1814
|
+
const convertToDocumentationBundleForTemplate = apply(
|
|
1815
|
+
convertToDocumentationBundle,
|
|
1816
|
+
config.referenceGuideTitle,
|
|
1817
|
+
config.referenceGuideTemplate
|
|
1818
|
+
);
|
|
1819
|
+
const sort = apply(sortTypesAndMembers, config.sortAlphabetically);
|
|
1820
|
+
console.log("excludeTags", config.excludeTags);
|
|
1821
|
+
const removeExcluded = apply(removeExcludedTags, config.excludeTags);
|
|
1822
|
+
return _function.pipe(
|
|
1823
|
+
apexBundles,
|
|
1824
|
+
reflectBundles,
|
|
1825
|
+
TE__namespace.map(filterOutOfScope),
|
|
1826
|
+
TE__namespace.map(addInheritedMembersToTypes),
|
|
1827
|
+
TE__namespace.map(addInheritanceChainToTypes),
|
|
1828
|
+
TE__namespace.map(sort),
|
|
1829
|
+
TE__namespace.map(removeExcluded),
|
|
1830
|
+
TE__namespace.bindTo("parsedFiles"),
|
|
1831
|
+
TE__namespace.bind("references", ({ parsedFiles }) => TE__namespace.right(convertToReferences(parsedFiles))),
|
|
1832
|
+
TE__namespace.flatMap(({ parsedFiles, references }) => transformReferenceHook(config)({ references, parsedFiles })),
|
|
1833
|
+
TE__namespace.map(({ parsedFiles, references }) => convertToRenderableBundle(parsedFiles, references)),
|
|
1834
|
+
TE__namespace.map(convertToDocumentationBundleForTemplate),
|
|
1835
|
+
TE__namespace.flatMap(transformDocumentationBundleHook(config)),
|
|
1836
|
+
TE__namespace.map(postHookCompile)
|
|
1837
|
+
);
|
|
1838
|
+
}
|
|
1839
|
+
function transformReferenceHook(config) {
|
|
1840
|
+
function _execute(references, parsedFiles, transformReference) {
|
|
1841
|
+
return __async$4(this, null, function* () {
|
|
1842
|
+
return {
|
|
1843
|
+
references: yield execTransformReferenceHook(Object.values(references), transformReference),
|
|
1844
|
+
parsedFiles
|
|
1845
|
+
};
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
return ({ references, parsedFiles }) => TE__namespace.tryCatch(
|
|
1849
|
+
() => _execute(references, parsedFiles, config.transformReference),
|
|
1850
|
+
(error) => new HookError(error)
|
|
1851
|
+
);
|
|
1852
|
+
}
|
|
1853
|
+
function transformDocumentationBundleHook(config) {
|
|
1854
|
+
return (bundle) => TE__namespace.tryCatch(
|
|
1855
|
+
() => documentationBundleHook(bundle, config),
|
|
1856
|
+
(error) => new HookError(error)
|
|
1857
|
+
);
|
|
1858
|
+
}
|
|
1859
|
+
function passThroughHook(value) {
|
|
1860
|
+
return value;
|
|
1861
|
+
}
|
|
1862
|
+
const execTransformReferenceHook = (_0, ..._1) => __async$4(void 0, [_0, ..._1], function* (references, hook = passThroughHook) {
|
|
1863
|
+
const hooked = references.map((reference) => __async$4(void 0, null, function* () {
|
|
1864
|
+
const hookedResult = yield hook(reference);
|
|
1865
|
+
return __spreadValues$6(__spreadValues$6({}, reference), hookedResult);
|
|
1866
|
+
}));
|
|
1867
|
+
const awaited = yield Promise.all(hooked);
|
|
1868
|
+
return awaited.reduce((acc, reference) => {
|
|
1869
|
+
acc[reference.source.name] = reference;
|
|
1870
|
+
return acc;
|
|
1871
|
+
}, {});
|
|
1872
|
+
});
|
|
1873
|
+
const documentationBundleHook = (bundle, config) => __async$4(void 0, null, function* () {
|
|
1874
|
+
return {
|
|
1875
|
+
referenceGuide: yield transformReferenceGuide(bundle.referenceGuide, config.transformReferenceGuide),
|
|
1876
|
+
docs: yield transformDocs(bundle.docs, config.transformDocs, config.transformDocPage)
|
|
1877
|
+
};
|
|
1878
|
+
});
|
|
1879
|
+
const transformReferenceGuide = (_0, ..._1) => __async$4(void 0, [_0, ..._1], function* (referenceGuide, hook = passThroughHook) {
|
|
1880
|
+
const result = yield hook(referenceGuide);
|
|
1881
|
+
if (isSkip(result)) {
|
|
1882
|
+
return result;
|
|
1883
|
+
}
|
|
1884
|
+
return __spreadValues$6(__spreadValues$6({}, referenceGuide), yield hook(referenceGuide));
|
|
1885
|
+
});
|
|
1886
|
+
const transformDocs = (_0, ..._1) => __async$4(void 0, [_0, ..._1], function* (docs, transformDocsHook = passThroughHook, transformDocPageHook = passThroughHook) {
|
|
1887
|
+
const transformed = yield transformDocsHook(docs);
|
|
1888
|
+
return Promise.all(transformed.map((doc) => transformDocPage(doc, transformDocPageHook)));
|
|
1889
|
+
});
|
|
1890
|
+
const transformDocPage = (_0, ..._1) => __async$4(void 0, [_0, ..._1], function* (doc, hook = passThroughHook) {
|
|
1891
|
+
return __spreadValues$6(__spreadValues$6({}, doc), yield hook(doc));
|
|
1892
|
+
});
|
|
1893
|
+
function postHookCompile(bundle) {
|
|
1894
|
+
return {
|
|
1895
|
+
referenceGuide: isSkip(bundle.referenceGuide) ? bundle.referenceGuide : __spreadProps$6(__spreadValues$6({}, bundle.referenceGuide), {
|
|
1896
|
+
content: Template.getInstance().compile({
|
|
1897
|
+
source: {
|
|
1898
|
+
frontmatter: toFrontmatterString(bundle.referenceGuide.frontmatter),
|
|
1899
|
+
content: bundle.referenceGuide.content
|
|
1900
|
+
},
|
|
1901
|
+
template: hookableTemplate
|
|
1902
|
+
})
|
|
1903
|
+
}),
|
|
1904
|
+
docs: bundle.docs.map((doc) => __spreadProps$6(__spreadValues$6({}, doc), {
|
|
1905
|
+
content: Template.getInstance().compile({
|
|
1906
|
+
source: {
|
|
1907
|
+
frontmatter: toFrontmatterString(doc.frontmatter),
|
|
1908
|
+
content: doc.content
|
|
1909
|
+
},
|
|
1910
|
+
template: hookableTemplate
|
|
1911
|
+
})
|
|
1912
|
+
}))
|
|
1913
|
+
};
|
|
1914
|
+
}
|
|
1915
|
+
function toFrontmatterString(frontmatter) {
|
|
1916
|
+
if (typeof frontmatter === "string") {
|
|
1917
|
+
return frontmatter;
|
|
1918
|
+
}
|
|
1919
|
+
if (!frontmatter) {
|
|
1920
|
+
return "";
|
|
1921
|
+
}
|
|
1922
|
+
const yamlString = yaml.dump(frontmatter);
|
|
1923
|
+
return `---
|
|
1924
|
+
${yamlString}---
|
|
1925
|
+
`;
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
const referenceGuideTemplate = `
|
|
1929
|
+
# {{referenceGuideTitle}}
|
|
1930
|
+
|
|
1931
|
+
{{#each references}}
|
|
1932
|
+
## {{@key}}
|
|
1933
|
+
|
|
1934
|
+
{{#each this}}
|
|
1935
|
+
### {{link title}}
|
|
1936
|
+
|
|
1937
|
+
{{{renderContent description}}}
|
|
1938
|
+
|
|
1939
|
+
{{/each}}
|
|
1940
|
+
{{/each}}
|
|
1941
|
+
`.trim();
|
|
1942
|
+
|
|
1943
|
+
var __defProp$5 = Object.defineProperty;
|
|
1944
|
+
var __defProps$5 = Object.defineProperties;
|
|
1945
|
+
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
1946
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
1947
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
1948
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
1949
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1950
|
+
var __spreadValues$5 = (a, b) => {
|
|
1951
|
+
for (var prop in b || (b = {}))
|
|
1952
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
1953
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
1954
|
+
if (__getOwnPropSymbols$5)
|
|
1955
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
1956
|
+
if (__propIsEnum$5.call(b, prop))
|
|
1957
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
1958
|
+
}
|
|
1959
|
+
return a;
|
|
1960
|
+
};
|
|
1961
|
+
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
1962
|
+
const mkdir = TE__namespace$1.taskify(fs__namespace.mkdir);
|
|
1963
|
+
const writeFile = TE__namespace$1.taskify(fs__namespace.writeFile);
|
|
1964
|
+
function writeFiles(files, outputDir, onWriteCallback) {
|
|
1965
|
+
return _function.pipe(
|
|
1966
|
+
files,
|
|
1967
|
+
TE__namespace$1.traverseArray((file) => writeSingle(file, outputDir, onWriteCallback))
|
|
1968
|
+
);
|
|
1969
|
+
}
|
|
1970
|
+
function writeSingle(file, outputDir, onWriteCallback) {
|
|
1971
|
+
const ensureDirectoryExists = ({ outputDocPath }) => mkdir(path__namespace.dirname(outputDocPath), { recursive: true });
|
|
1972
|
+
const writeContents = (file2) => writeFile(file2.outputDocPath, file2.content, "utf8");
|
|
1973
|
+
return _function.pipe(
|
|
1974
|
+
resolveTargetLocation(file, outputDir),
|
|
1975
|
+
(file2) => TE__namespace$1.right(file2),
|
|
1976
|
+
TE__namespace$1.tapIO(ensureDirectoryExists),
|
|
1977
|
+
TE__namespace$1.flatMap(writeContents),
|
|
1978
|
+
TE__namespace$1.map(() => onWriteCallback == null ? void 0 : onWriteCallback(file))
|
|
1979
|
+
);
|
|
1980
|
+
}
|
|
1981
|
+
function resolveTargetLocation(file, outputDir) {
|
|
1982
|
+
return __spreadProps$5(__spreadValues$5({}, file), {
|
|
1983
|
+
outputDocPath: path__namespace.join(outputDir, file.outputDocPath)
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
var __defProp$4 = Object.defineProperty;
|
|
1988
|
+
var __defProps$4 = Object.defineProperties;
|
|
1989
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
1990
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
1991
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
1992
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
1993
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1994
|
+
var __spreadValues$4 = (a, b) => {
|
|
1995
|
+
for (var prop in b || (b = {}))
|
|
1996
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
1997
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
1998
|
+
if (__getOwnPropSymbols$4)
|
|
1999
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
2000
|
+
if (__propIsEnum$4.call(b, prop))
|
|
2001
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
2002
|
+
}
|
|
2003
|
+
return a;
|
|
2004
|
+
};
|
|
2005
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
2006
|
+
class FileWritingError {
|
|
2007
|
+
constructor(message, error) {
|
|
2008
|
+
this.message = message;
|
|
2009
|
+
this.error = error;
|
|
2010
|
+
this._tag = "FileWritingError";
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
function generate(bundles, config) {
|
|
2014
|
+
console.log("config from generators/markdown", config);
|
|
2015
|
+
return _function.pipe(
|
|
2016
|
+
generateDocumentationBundle(bundles, config),
|
|
2017
|
+
TE__namespace.flatMap((files) => writeFilesToSystem(files, config.targetDir))
|
|
2018
|
+
);
|
|
2019
|
+
}
|
|
2020
|
+
function generateDocumentationBundle(bundles, config) {
|
|
2021
|
+
return generateDocs(bundles, __spreadProps$4(__spreadValues$4({}, config), {
|
|
2022
|
+
referenceGuideTemplate
|
|
2023
|
+
}));
|
|
2024
|
+
}
|
|
2025
|
+
function writeFilesToSystem(files, outputDir) {
|
|
2026
|
+
return _function.pipe(
|
|
2027
|
+
[files.referenceGuide, ...files.docs].filter((file) => !isSkip(file)),
|
|
2028
|
+
(files2) => writeFiles(files2, outputDir),
|
|
2029
|
+
TE__namespace.mapLeft((error) => {
|
|
2030
|
+
return new FileWritingError("An error occurred while writing files to the system.", error);
|
|
2031
|
+
})
|
|
2032
|
+
);
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
function createManifest(typeParser, reflect) {
|
|
2036
|
+
return new Manifest(typeParser.parse(reflect));
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
var __defProp$3 = Object.defineProperty;
|
|
2040
|
+
var __defProps$3 = Object.defineProperties;
|
|
2041
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
2042
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
2043
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
2044
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
2045
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2046
|
+
var __spreadValues$3 = (a, b) => {
|
|
2047
|
+
for (var prop in b || (b = {}))
|
|
2048
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
2049
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
2050
|
+
if (__getOwnPropSymbols$3)
|
|
2051
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
2052
|
+
if (__propIsEnum$3.call(b, prop))
|
|
2053
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
2054
|
+
}
|
|
2055
|
+
return a;
|
|
2056
|
+
};
|
|
2057
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
2058
|
+
class RawBodyParser {
|
|
2059
|
+
constructor(logger, typeBundles) {
|
|
2060
|
+
this.logger = logger;
|
|
2061
|
+
this.typeBundles = typeBundles;
|
|
2062
|
+
}
|
|
2063
|
+
parse(reflect) {
|
|
2064
|
+
const types = this.typeBundles.map((currentBundle) => {
|
|
2065
|
+
this.logger.log(`Parsing file: ${currentBundle.filePath}`);
|
|
2066
|
+
return reflect(currentBundle);
|
|
2067
|
+
}).filter((reflectionResult) => {
|
|
2068
|
+
return reflectionResult.typeMirror;
|
|
2069
|
+
}).map((reflectionResult) => reflectionResult.typeMirror);
|
|
2070
|
+
return this.addFieldsFromParent(types);
|
|
2071
|
+
}
|
|
2072
|
+
addFieldsFromParent(types) {
|
|
2073
|
+
const typesWithFields = [];
|
|
2074
|
+
for (const currentType of types) {
|
|
2075
|
+
if (currentType.type_name !== "class" && currentType.type_name !== "interface") {
|
|
2076
|
+
typesWithFields.push(currentType);
|
|
2077
|
+
continue;
|
|
2078
|
+
}
|
|
2079
|
+
if (currentType.type_name === "class") {
|
|
2080
|
+
let typeAsClass = currentType;
|
|
2081
|
+
if (!typeAsClass.extended_class) {
|
|
2082
|
+
typesWithFields.push(currentType);
|
|
2083
|
+
continue;
|
|
2084
|
+
}
|
|
2085
|
+
typeAsClass = this.addMembersFromParent(typeAsClass, types);
|
|
2086
|
+
typesWithFields.push(typeAsClass);
|
|
2087
|
+
continue;
|
|
2088
|
+
}
|
|
2089
|
+
let typeAsInterface = currentType;
|
|
2090
|
+
if (!typeAsInterface.extended_interfaces.length) {
|
|
2091
|
+
typesWithFields.push(currentType);
|
|
2092
|
+
continue;
|
|
2093
|
+
}
|
|
2094
|
+
typeAsInterface = this.addMethodsFromParent(typeAsInterface, types);
|
|
2095
|
+
typesWithFields.push(typeAsInterface);
|
|
2096
|
+
}
|
|
2097
|
+
return typesWithFields;
|
|
2098
|
+
}
|
|
2099
|
+
addMembersFromParent(currentClass, allTypes) {
|
|
2100
|
+
if (!currentClass.extended_class) {
|
|
2101
|
+
return currentClass;
|
|
2102
|
+
}
|
|
2103
|
+
const parent = allTypes.find((currentType) => currentType.name === currentClass.extended_class);
|
|
2104
|
+
if (!parent || parent.type_name !== "class") {
|
|
2105
|
+
return currentClass;
|
|
2106
|
+
}
|
|
2107
|
+
let parentAsClass = parent;
|
|
2108
|
+
if (parentAsClass.extended_class) {
|
|
2109
|
+
parentAsClass = this.addMembersFromParent(parentAsClass, allTypes);
|
|
2110
|
+
}
|
|
2111
|
+
currentClass.fields = [...currentClass.fields, ...this.getInheritedFields(parentAsClass, currentClass)];
|
|
2112
|
+
currentClass.properties = [...currentClass.properties, ...this.getInheritedProperties(parentAsClass, currentClass)];
|
|
2113
|
+
currentClass.methods = [...currentClass.methods, ...this.getInheritedMethods(parentAsClass, currentClass)];
|
|
2114
|
+
return currentClass;
|
|
2115
|
+
}
|
|
2116
|
+
addMethodsFromParent(currentInterface, allTypes) {
|
|
2117
|
+
if (!currentInterface.extended_interfaces.length) {
|
|
2118
|
+
return currentInterface;
|
|
2119
|
+
}
|
|
2120
|
+
const parents = [];
|
|
2121
|
+
for (const currentInterfaceName of currentInterface.extended_interfaces) {
|
|
2122
|
+
const parent = allTypes.find((currentType) => currentType.name === currentInterfaceName);
|
|
2123
|
+
if (parent) {
|
|
2124
|
+
parents.push(parent);
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
for (const parent of parents) {
|
|
2128
|
+
let parentAsInterface = parent;
|
|
2129
|
+
if (parentAsInterface.extended_interfaces.length) {
|
|
2130
|
+
parentAsInterface = this.addMethodsFromParent(parentAsInterface, allTypes);
|
|
2131
|
+
}
|
|
2132
|
+
currentInterface.methods = [
|
|
2133
|
+
...currentInterface.methods,
|
|
2134
|
+
...this.getInheritedMethods(parentAsInterface, currentInterface)
|
|
2135
|
+
];
|
|
2136
|
+
}
|
|
2137
|
+
return currentInterface;
|
|
2138
|
+
}
|
|
2139
|
+
getInheritedFields(parentAsClass, currentClass) {
|
|
2140
|
+
return parentAsClass.fields.filter((currentField) => currentField.access_modifier.toLowerCase() !== "private").filter((currentField) => !this.memberExists(currentClass.fields, currentField.name)).map((currentField) => __spreadProps$3(__spreadValues$3({}, currentField), {
|
|
2141
|
+
inherited: true
|
|
2142
|
+
}));
|
|
2143
|
+
}
|
|
2144
|
+
getInheritedProperties(parentAsClass, currentClass) {
|
|
2145
|
+
return parentAsClass.properties.filter((currentProperty) => currentProperty.access_modifier.toLowerCase() !== "private").filter((currentProperty) => !this.memberExists(currentClass.properties, currentProperty.name)).map((currentProperty) => __spreadProps$3(__spreadValues$3({}, currentProperty), {
|
|
2146
|
+
inherited: true
|
|
2147
|
+
}));
|
|
2148
|
+
}
|
|
2149
|
+
getInheritedMethods(parentAsClass, currentClass) {
|
|
2150
|
+
return parentAsClass.methods.filter((currentMethod) => currentMethod.access_modifier.toLowerCase() !== "private").filter((currentMethod) => !this.memberExists(currentClass.methods, currentMethod.name)).map((currentMethod) => __spreadProps$3(__spreadValues$3({}, currentMethod), {
|
|
2151
|
+
inherited: true
|
|
2152
|
+
}));
|
|
2153
|
+
}
|
|
2154
|
+
memberExists(members, fieldName) {
|
|
2155
|
+
const fieldNames = members.map((currentMember) => currentMember.name);
|
|
2156
|
+
return fieldNames.includes(fieldName);
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
class TypesRepository {
|
|
2161
|
+
constructor() {
|
|
2162
|
+
this.allTypes = [];
|
|
2163
|
+
}
|
|
2164
|
+
static getInstance() {
|
|
2165
|
+
if (!TypesRepository.instance) {
|
|
2166
|
+
TypesRepository.instance = new TypesRepository();
|
|
2167
|
+
}
|
|
2168
|
+
return TypesRepository.instance;
|
|
2169
|
+
}
|
|
2170
|
+
populateAll(types) {
|
|
2171
|
+
this.allTypes = types;
|
|
2172
|
+
}
|
|
2173
|
+
getFromAllByName(typeName) {
|
|
2174
|
+
if (typeName.includes(".")) {
|
|
2175
|
+
const [parentTypeName, childTypeName] = typeName.split(".");
|
|
2176
|
+
const parentReference = this.allTypes.find(
|
|
2177
|
+
(currentType) => currentType.name.toLowerCase() === parentTypeName.toLowerCase()
|
|
2178
|
+
);
|
|
2179
|
+
if (!parentReference || parentReference.type_name !== "class") {
|
|
2180
|
+
return void 0;
|
|
2181
|
+
}
|
|
2182
|
+
const parentReferenceAsClass = parentReference;
|
|
2183
|
+
const childTypes = [
|
|
2184
|
+
...parentReferenceAsClass.classes,
|
|
2185
|
+
...parentReferenceAsClass.interfaces,
|
|
2186
|
+
...parentReferenceAsClass.enums
|
|
2187
|
+
];
|
|
2188
|
+
const foundType2 = childTypes.find((currentType) => currentType.name.toLowerCase() === childTypeName);
|
|
2189
|
+
if (!foundType2) {
|
|
2190
|
+
return void 0;
|
|
2191
|
+
}
|
|
2192
|
+
return { type: foundType2, isChild: true, parentType: parentReference };
|
|
2193
|
+
}
|
|
2194
|
+
const foundType = this.allTypes.find(
|
|
2195
|
+
(currentType) => currentType.name.toLowerCase() === typeName.toLowerCase()
|
|
2196
|
+
);
|
|
2197
|
+
if (!foundType) {
|
|
2198
|
+
return void 0;
|
|
2199
|
+
}
|
|
2200
|
+
return { type: foundType, isChild: false };
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
|
|
2204
|
+
class Transpiler {
|
|
2205
|
+
static generate(types, processor) {
|
|
2206
|
+
var _a;
|
|
2207
|
+
const sortedTypes = types.sort((apexTypeA, apexTypeB) => {
|
|
2208
|
+
if (apexTypeA.name < apexTypeB.name) return -1;
|
|
2209
|
+
if (apexTypeA.name > apexTypeB.name) return 1;
|
|
2210
|
+
return 0;
|
|
2211
|
+
});
|
|
2212
|
+
sortedTypes.forEach((currentType) => {
|
|
2213
|
+
processor.onProcess(currentType);
|
|
2214
|
+
});
|
|
2215
|
+
(_a = processor.onAfterProcess) == null ? void 0 : _a.call(processor, sortedTypes);
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
class ErrorLogger {
|
|
2220
|
+
static logErrors(logger, types) {
|
|
2221
|
+
types.forEach((currentType) => {
|
|
2222
|
+
this.logErrorsForSingleType(logger, currentType);
|
|
2223
|
+
});
|
|
2224
|
+
}
|
|
2225
|
+
static logErrorsForSingleType(logger, currentType) {
|
|
2226
|
+
this.logTypeErrors(logger, currentType);
|
|
2227
|
+
if (currentType.type_name === "class") {
|
|
2228
|
+
this.logErrorsForClass(logger, currentType);
|
|
2229
|
+
} else if (currentType.type_name === "interface") {
|
|
2230
|
+
this.logErrorsForInterface(logger, currentType);
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
static logTypeErrors(logger, currentType, parentType) {
|
|
2234
|
+
var _a;
|
|
2235
|
+
if ((_a = currentType.docComment) == null ? void 0 : _a.error) {
|
|
2236
|
+
const typeName = parentType ? `${parentType.name}.${currentType.name}` : currentType.name;
|
|
2237
|
+
logger.error(`${typeName} - Doc comment parsing error. Level: Type`);
|
|
2238
|
+
logger.error(`Comment:
|
|
2239
|
+
${currentType.docComment.rawDeclaration}`);
|
|
2240
|
+
logger.error(currentType.docComment.error);
|
|
2241
|
+
logger.error("=================================");
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
static logErrorsForClass(logger, classMirror, parentType) {
|
|
2245
|
+
const typeName = parentType ? `${parentType.name}.${classMirror.name}` : classMirror.name;
|
|
2246
|
+
classMirror.constructors.forEach((currentConstructor) => {
|
|
2247
|
+
var _a;
|
|
2248
|
+
if ((_a = currentConstructor.docComment) == null ? void 0 : _a.error) {
|
|
2249
|
+
logger.error(`${typeName} - Doc comment parsing error. Level: Constructor`);
|
|
2250
|
+
logger.error(`Comment:
|
|
2251
|
+
${currentConstructor.docComment.rawDeclaration}`);
|
|
2252
|
+
logger.error(currentConstructor.docComment.error);
|
|
2253
|
+
logger.error("=================================");
|
|
2254
|
+
}
|
|
2255
|
+
});
|
|
2256
|
+
classMirror.fields.forEach((currentField) => {
|
|
2257
|
+
var _a;
|
|
2258
|
+
if ((_a = currentField.docComment) == null ? void 0 : _a.error) {
|
|
2259
|
+
logger.error(`${typeName} - Doc comment parsing error. Level: Field`);
|
|
2260
|
+
logger.error(`Comment:
|
|
2261
|
+
${currentField.docComment.rawDeclaration}`);
|
|
2262
|
+
logger.error(currentField.docComment.error);
|
|
2263
|
+
logger.error("=================================");
|
|
2264
|
+
}
|
|
2265
|
+
});
|
|
2266
|
+
classMirror.properties.forEach((currentProperty) => {
|
|
2267
|
+
var _a;
|
|
2268
|
+
if ((_a = currentProperty.docComment) == null ? void 0 : _a.error) {
|
|
2269
|
+
logger.error(`${typeName} - Doc comment parsing error. Level: Property`);
|
|
2270
|
+
logger.error(`Comment:
|
|
2271
|
+
${currentProperty.docComment.rawDeclaration}`);
|
|
2272
|
+
logger.error(currentProperty.docComment.error);
|
|
2273
|
+
logger.error("=================================");
|
|
2274
|
+
}
|
|
2275
|
+
});
|
|
2276
|
+
classMirror.methods.forEach((currentMethod) => {
|
|
2277
|
+
var _a;
|
|
2278
|
+
if ((_a = currentMethod.docComment) == null ? void 0 : _a.error) {
|
|
2279
|
+
logger.error(`${typeName} - Doc comment parsing error. Level: Method`);
|
|
2280
|
+
logger.error(`Comment:
|
|
2281
|
+
${currentMethod.docComment.rawDeclaration}`);
|
|
2282
|
+
logger.error(currentMethod.docComment.error);
|
|
2283
|
+
logger.error("=================================");
|
|
2284
|
+
}
|
|
2285
|
+
});
|
|
2286
|
+
classMirror.enums.forEach((currentEnum) => {
|
|
2287
|
+
this.logErrorsForSingleType(logger, currentEnum);
|
|
2288
|
+
});
|
|
2289
|
+
classMirror.interfaces.forEach((currentInterface) => {
|
|
2290
|
+
this.logErrorsForSingleType(logger, currentInterface);
|
|
2291
|
+
});
|
|
2292
|
+
classMirror.classes.forEach((currentClass) => {
|
|
2293
|
+
this.logErrorsForSingleType(logger, currentClass);
|
|
2294
|
+
});
|
|
2295
|
+
}
|
|
2296
|
+
static logErrorsForInterface(logger, interfaceMirror) {
|
|
2297
|
+
interfaceMirror.methods.forEach((currentMethod) => {
|
|
2298
|
+
var _a;
|
|
2299
|
+
if ((_a = currentMethod.docComment) == null ? void 0 : _a.error) {
|
|
2300
|
+
logger.error(`${interfaceMirror.name} - Doc comment parsing error. Level: Method`);
|
|
2301
|
+
logger.error(`Comment: ${currentMethod.docComment.rawDeclaration}`);
|
|
2302
|
+
logger.error(currentMethod.docComment.error);
|
|
2303
|
+
logger.error("=================================");
|
|
2304
|
+
}
|
|
2305
|
+
});
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
class FileContainer {
|
|
2310
|
+
constructor() {
|
|
2311
|
+
this._files = [];
|
|
2312
|
+
}
|
|
2313
|
+
files() {
|
|
2314
|
+
return this._files;
|
|
2315
|
+
}
|
|
2316
|
+
pushFile(file) {
|
|
2317
|
+
this._files.push(file);
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
const OPEN_API_VERSION = "3.1.0";
|
|
2322
|
+
const SERVER_URL = "/services/apexrest/";
|
|
2323
|
+
class OpenApi {
|
|
2324
|
+
constructor(title, version, namespace) {
|
|
2325
|
+
this.namespace = namespace;
|
|
2326
|
+
this.openapi = OPEN_API_VERSION;
|
|
2327
|
+
this.info = {
|
|
2328
|
+
title,
|
|
2329
|
+
version
|
|
2330
|
+
};
|
|
2331
|
+
this.servers = [
|
|
2332
|
+
{
|
|
2333
|
+
url: this.getServerUrl()
|
|
2334
|
+
}
|
|
2335
|
+
];
|
|
2336
|
+
this.paths = {};
|
|
2337
|
+
this.tags = [];
|
|
2338
|
+
}
|
|
2339
|
+
getServerUrl() {
|
|
2340
|
+
if (!this.namespace) {
|
|
2341
|
+
return SERVER_URL;
|
|
2342
|
+
}
|
|
2343
|
+
return `${SERVER_URL}${this.namespace}/`;
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
|
|
2347
|
+
class OpenApiSettings {
|
|
2348
|
+
constructor(config) {
|
|
2349
|
+
this.config = config;
|
|
2350
|
+
}
|
|
2351
|
+
static build(config) {
|
|
2352
|
+
OpenApiSettings.instance = new OpenApiSettings(config);
|
|
2353
|
+
}
|
|
2354
|
+
static getInstance() {
|
|
2355
|
+
if (!OpenApiSettings.instance) {
|
|
2356
|
+
throw new Error("Settings has not been initialized");
|
|
2357
|
+
}
|
|
2358
|
+
return OpenApiSettings.instance;
|
|
2359
|
+
}
|
|
2360
|
+
getOpenApiTitle() {
|
|
2361
|
+
return this.config.openApiTitle;
|
|
2362
|
+
}
|
|
2363
|
+
getNamespace() {
|
|
2364
|
+
return this.config.namespace;
|
|
2365
|
+
}
|
|
2366
|
+
openApiFileName() {
|
|
2367
|
+
return this.config.openApiFileName;
|
|
2368
|
+
}
|
|
2369
|
+
getVersion() {
|
|
2370
|
+
return this.config.version;
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
class ClassMirrorWrapper {
|
|
2375
|
+
constructor(classMirror) {
|
|
2376
|
+
this.classMirror = classMirror;
|
|
2377
|
+
this.hasAnnotation = (method, annotationName) => method.annotations.some((annotation) => annotation.name.toLowerCase() === annotationName);
|
|
2378
|
+
}
|
|
2379
|
+
getMethodsByAnnotation(annotation) {
|
|
2380
|
+
return this.classMirror.methods.filter((method) => this.hasAnnotation(method, annotation));
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
var __defProp$2 = Object.defineProperty;
|
|
2385
|
+
var __defProps$2 = Object.defineProperties;
|
|
2386
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
2387
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
2388
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
2389
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
2390
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2391
|
+
var __spreadValues$2 = (a, b) => {
|
|
2392
|
+
for (var prop in b || (b = {}))
|
|
2393
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
2394
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
2395
|
+
if (__getOwnPropSymbols$2)
|
|
2396
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
2397
|
+
if (__propIsEnum$2.call(b, prop))
|
|
2398
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
2399
|
+
}
|
|
2400
|
+
return a;
|
|
2401
|
+
};
|
|
2402
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
2403
|
+
class ReferenceBuilder {
|
|
2404
|
+
constructor() {
|
|
2405
|
+
this.isReferenceString = (targetObject) => {
|
|
2406
|
+
return typeof targetObject === "string" || targetObject instanceof String;
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
build(referencedTypeName) {
|
|
2410
|
+
const originalTypeName = referencedTypeName;
|
|
2411
|
+
const regexForSchemaOverrides = /\[(.*?)]/g;
|
|
2412
|
+
const schemaOverrides = referencedTypeName.match(regexForSchemaOverrides);
|
|
2413
|
+
let referenceOverrides = [];
|
|
2414
|
+
if (schemaOverrides && schemaOverrides.length > 0) {
|
|
2415
|
+
referenceOverrides = ReferenceOverrides.build(schemaOverrides[0]);
|
|
2416
|
+
referencedTypeName = referencedTypeName.replace(regexForSchemaOverrides, "");
|
|
2417
|
+
}
|
|
2418
|
+
const [parsedReferencedType, isCollection] = this.handlePossibleCollectionReference(referencedTypeName);
|
|
2419
|
+
const referencedTypeBundle = TypesRepository.getInstance().getFromAllByName(parsedReferencedType);
|
|
2420
|
+
if (!referencedTypeBundle) {
|
|
2421
|
+
throw new Error(`The referenced type ${referencedTypeName} was not found.`);
|
|
2422
|
+
}
|
|
2423
|
+
if (referencedTypeBundle.type.type_name !== "class") {
|
|
2424
|
+
throw new Error(
|
|
2425
|
+
`Expected the referenced type to be a class, but found a ${referencedTypeBundle.type.type_name}.`
|
|
2426
|
+
);
|
|
2427
|
+
}
|
|
2428
|
+
const typeBundleWithIsCollection = __spreadProps$2(__spreadValues$2({}, referencedTypeBundle), {
|
|
2429
|
+
originalTypeName,
|
|
2430
|
+
isCollection,
|
|
2431
|
+
referenceOverrides
|
|
2432
|
+
});
|
|
2433
|
+
return this.buildReferenceFromType(typeBundleWithIsCollection);
|
|
2434
|
+
}
|
|
2435
|
+
/**
|
|
2436
|
+
* Returns a tuple where the first value is the name of the reference without any collection related values
|
|
2437
|
+
* and the second is a boolean representing if we are dealing with a collection or not.
|
|
2438
|
+
* @param referencedTypeName The received raw type name.
|
|
2439
|
+
* @private
|
|
2440
|
+
*/
|
|
2441
|
+
handlePossibleCollectionReference(referencedTypeName) {
|
|
2442
|
+
referencedTypeName = referencedTypeName.toLowerCase();
|
|
2443
|
+
if (referencedTypeName.startsWith("list<") && referencedTypeName.endsWith(">")) {
|
|
2444
|
+
referencedTypeName = referencedTypeName.replace("list<", "");
|
|
2445
|
+
referencedTypeName = referencedTypeName.replace(">", "");
|
|
2446
|
+
return [referencedTypeName, true];
|
|
2447
|
+
}
|
|
2448
|
+
if (referencedTypeName.startsWith("set<") && referencedTypeName.endsWith(">")) {
|
|
2449
|
+
referencedTypeName = referencedTypeName.replace("set<", "");
|
|
2450
|
+
referencedTypeName = referencedTypeName.replace(">", "");
|
|
2451
|
+
return [referencedTypeName, true];
|
|
2452
|
+
}
|
|
2453
|
+
return [referencedTypeName, false];
|
|
2454
|
+
}
|
|
2455
|
+
buildReferenceFromType(typeBundle) {
|
|
2456
|
+
const propertiesAndFields = [
|
|
2457
|
+
...typeBundle.type.properties,
|
|
2458
|
+
...typeBundle.type.fields
|
|
2459
|
+
].filter((current) => !current.memberModifiers.includes("static")).filter((current) => !current.memberModifiers.includes("transient"));
|
|
2460
|
+
const properties = {};
|
|
2461
|
+
let referencedComponents = [];
|
|
2462
|
+
propertiesAndFields.forEach((current) => {
|
|
2463
|
+
var _a, _b;
|
|
2464
|
+
const referenceOverride = typeBundle.referenceOverrides.find((currentOverride) => {
|
|
2465
|
+
return currentOverride.propertyName.toLowerCase() === current.name.toLowerCase();
|
|
2466
|
+
});
|
|
2467
|
+
if (referenceOverride) {
|
|
2468
|
+
const reference = this.build(referenceOverride.referenceName);
|
|
2469
|
+
properties[current.name] = reference.entrypointReferenceObject;
|
|
2470
|
+
reference.referenceComponents.forEach((current2) => referencedComponents.push(current2));
|
|
2471
|
+
} else {
|
|
2472
|
+
const manuallyDefinedHttpSchema = (_a = current.docComment) == null ? void 0 : _a.annotations.find(
|
|
2473
|
+
(annotation) => annotation.name.toLowerCase() === "http-schema"
|
|
2474
|
+
);
|
|
2475
|
+
if (manuallyDefinedHttpSchema) {
|
|
2476
|
+
this.handleOverriddenSchema(manuallyDefinedHttpSchema, properties, current, referencedComponents);
|
|
2477
|
+
} else {
|
|
2478
|
+
const pair = this.getReferenceType(current.typeReference);
|
|
2479
|
+
properties[current.name] = pair.schema;
|
|
2480
|
+
referencedComponents.push(...pair.referenceComponents);
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2483
|
+
properties[current.name].description = (_b = current.docComment) == null ? void 0 : _b.description;
|
|
2484
|
+
});
|
|
2485
|
+
const mainReferenceComponents = this.buildMainReferenceComponent(typeBundle, properties);
|
|
2486
|
+
referencedComponents = [...mainReferenceComponents, ...referencedComponents];
|
|
2487
|
+
return {
|
|
2488
|
+
entrypointReferenceObject: {
|
|
2489
|
+
$ref: `#/components/schemas/${this.getReferenceName(typeBundle)}`
|
|
2490
|
+
},
|
|
2491
|
+
referenceComponents: referencedComponents
|
|
2492
|
+
};
|
|
2493
|
+
}
|
|
2494
|
+
handleOverriddenSchema(manuallyDefinedHttpSchema, properties, current, referencedComponents) {
|
|
2495
|
+
const inYaml = manuallyDefinedHttpSchema == null ? void 0 : manuallyDefinedHttpSchema.bodyLines.reduce((prev, current2) => prev + "\n" + current2);
|
|
2496
|
+
const asJson = yaml__namespace.load(inYaml);
|
|
2497
|
+
const isReferenceString = this.isReferenceString(asJson);
|
|
2498
|
+
if (isReferenceString) {
|
|
2499
|
+
const reference = this.build(asJson);
|
|
2500
|
+
properties[current.name] = reference.entrypointReferenceObject;
|
|
2501
|
+
reference.referenceComponents.forEach((current2) => referencedComponents.push(current2));
|
|
2502
|
+
} else {
|
|
2503
|
+
properties[current.name] = asJson;
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
getReferenceName(typeBundle) {
|
|
2507
|
+
var _a;
|
|
2508
|
+
let referenceName = typeBundle.type.name;
|
|
2509
|
+
if (typeBundle.isChild) {
|
|
2510
|
+
referenceName = `${(_a = typeBundle.parentType) == null ? void 0 : _a.name}.${typeBundle.type.name}`;
|
|
2511
|
+
}
|
|
2512
|
+
if (typeBundle.isCollection) {
|
|
2513
|
+
referenceName = `${referenceName}_array`;
|
|
2514
|
+
}
|
|
2515
|
+
if (typeBundle.referenceOverrides.length) {
|
|
2516
|
+
referenceName = `${referenceName}_${typeBundle.originalTypeName}`;
|
|
2517
|
+
}
|
|
2518
|
+
return referenceName;
|
|
2519
|
+
}
|
|
2520
|
+
buildMainReferenceComponent(typeBundle, properties) {
|
|
2521
|
+
const mainReferenceName = this.getReferenceName(__spreadProps$2(__spreadValues$2({}, typeBundle), { isCollection: false }));
|
|
2522
|
+
const mainReference = {
|
|
2523
|
+
referencedClass: mainReferenceName,
|
|
2524
|
+
schema: {
|
|
2525
|
+
type: "object",
|
|
2526
|
+
properties
|
|
2527
|
+
}
|
|
2528
|
+
};
|
|
2529
|
+
const referencedComponents = [mainReference];
|
|
2530
|
+
if (!typeBundle.isCollection) {
|
|
2531
|
+
return referencedComponents;
|
|
2532
|
+
}
|
|
2533
|
+
return [
|
|
2534
|
+
{
|
|
2535
|
+
referencedClass: this.getReferenceName(typeBundle),
|
|
2536
|
+
schema: {
|
|
2537
|
+
type: "array",
|
|
2538
|
+
items: {
|
|
2539
|
+
$ref: `#/components/schemas/${mainReferenceName}`
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
},
|
|
2543
|
+
...referencedComponents
|
|
2544
|
+
];
|
|
2545
|
+
}
|
|
2546
|
+
getReferenceType(typeInMirror) {
|
|
2547
|
+
const typeName = typeInMirror.type.toLowerCase();
|
|
2548
|
+
switch (typeName) {
|
|
2549
|
+
case "boolean":
|
|
2550
|
+
return { schema: { type: "boolean" }, referenceComponents: [] };
|
|
2551
|
+
case "date":
|
|
2552
|
+
return { schema: { type: "string", format: "date" }, referenceComponents: [] };
|
|
2553
|
+
case "datetime":
|
|
2554
|
+
return { schema: { type: "string", format: "date-time" }, referenceComponents: [] };
|
|
2555
|
+
case "decimal":
|
|
2556
|
+
return { schema: { type: "number" }, referenceComponents: [] };
|
|
2557
|
+
case "double":
|
|
2558
|
+
return { schema: { type: "number" }, referenceComponents: [] };
|
|
2559
|
+
case "id":
|
|
2560
|
+
return { schema: { type: "string" }, referenceComponents: [] };
|
|
2561
|
+
case "integer":
|
|
2562
|
+
return { schema: { type: "integer" }, referenceComponents: [] };
|
|
2563
|
+
case "long":
|
|
2564
|
+
return { schema: { type: "integer", format: "int64" }, referenceComponents: [] };
|
|
2565
|
+
case "string":
|
|
2566
|
+
return { schema: { type: "string" }, referenceComponents: [] };
|
|
2567
|
+
case "time":
|
|
2568
|
+
return { schema: { type: "string", format: "time" }, referenceComponents: [] };
|
|
2569
|
+
case "list":
|
|
2570
|
+
return this.buildCollectionPair(typeInMirror);
|
|
2571
|
+
case "set":
|
|
2572
|
+
return this.buildCollectionPair(typeInMirror);
|
|
2573
|
+
case "map":
|
|
2574
|
+
return { schema: { type: "object" }, referenceComponents: [] };
|
|
2575
|
+
case "object":
|
|
2576
|
+
return { schema: { type: "object" }, referenceComponents: [] };
|
|
2577
|
+
default: {
|
|
2578
|
+
const referencedType = TypesRepository.getInstance().getFromAllByName(typeName);
|
|
2579
|
+
if (!referencedType) {
|
|
2580
|
+
return { schema: { type: "object" }, referenceComponents: [] };
|
|
2581
|
+
}
|
|
2582
|
+
const reference = this.buildReferenceFromType(__spreadProps$2(__spreadValues$2({}, referencedType), {
|
|
2583
|
+
isCollection: false,
|
|
2584
|
+
referenceOverrides: [],
|
|
2585
|
+
originalTypeName: typeName
|
|
2586
|
+
}));
|
|
2587
|
+
return {
|
|
2588
|
+
schema: reference.entrypointReferenceObject,
|
|
2589
|
+
referenceComponents: [...reference.referenceComponents]
|
|
2590
|
+
};
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
buildCollectionPair(typeInMirror) {
|
|
2595
|
+
const innerReference = this.getReferenceType(typeInMirror.ofType);
|
|
2596
|
+
return {
|
|
2597
|
+
schema: { type: "array", items: innerReference.schema },
|
|
2598
|
+
referenceComponents: [...innerReference.referenceComponents]
|
|
2599
|
+
};
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
class ReferenceOverrides {
|
|
2603
|
+
static build(referenceAsString) {
|
|
2604
|
+
const cleanedUpReference = referenceAsString.replace(/[[\]]/g, "");
|
|
2605
|
+
const referenceStrings = cleanedUpReference.split(",").map((item) => item.replace(/\s/g, ""));
|
|
2606
|
+
return referenceStrings.map((item) => {
|
|
2607
|
+
const [propertyName, referenceName] = item.split(":");
|
|
2608
|
+
return { propertyName, referenceName };
|
|
2609
|
+
});
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
class Builder {
|
|
2614
|
+
constructor() {
|
|
2615
|
+
this.isReferenceString = (targetObject) => {
|
|
2616
|
+
return typeof targetObject === "string" || targetObject instanceof String;
|
|
2617
|
+
};
|
|
2618
|
+
}
|
|
2619
|
+
build(schemaAware) {
|
|
2620
|
+
let reference;
|
|
2621
|
+
if (this.isReferenceString(schemaAware.schema)) {
|
|
2622
|
+
reference = new ReferenceBuilder().build(schemaAware.schema);
|
|
2623
|
+
}
|
|
2624
|
+
return {
|
|
2625
|
+
reference,
|
|
2626
|
+
body: this.buildBody(schemaAware, reference)
|
|
2627
|
+
};
|
|
2628
|
+
}
|
|
2629
|
+
getOpenApiSchemaFromApexDocSchema(schemaAware, reference) {
|
|
2630
|
+
if (this.isReferenceString(schemaAware.schema)) {
|
|
2631
|
+
return reference.entrypointReferenceObject;
|
|
2632
|
+
}
|
|
2633
|
+
return schemaAware.schema;
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
var __defProp$1 = Object.defineProperty;
|
|
2638
|
+
var __defProps$1 = Object.defineProperties;
|
|
2639
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
2640
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
2641
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
2642
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
2643
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2644
|
+
var __spreadValues$1 = (a, b) => {
|
|
2645
|
+
for (var prop in b || (b = {}))
|
|
2646
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
2647
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
2648
|
+
if (__getOwnPropSymbols$1)
|
|
2649
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
2650
|
+
if (__propIsEnum$1.call(b, prop))
|
|
2651
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
2652
|
+
}
|
|
2653
|
+
return a;
|
|
2654
|
+
};
|
|
2655
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
2656
|
+
class ParameterObjectBuilder extends Builder {
|
|
2657
|
+
buildBody(apexDocObject, reference) {
|
|
2658
|
+
return __spreadProps$1(__spreadValues$1({}, apexDocObject), {
|
|
2659
|
+
schema: this.getOpenApiSchemaFromApexDocSchema(apexDocObject, reference)
|
|
2660
|
+
});
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
class ResponsesBuilder extends Builder {
|
|
2665
|
+
buildBody(apexDocResponseDefinition, reference) {
|
|
2666
|
+
let description = `Status code ${apexDocResponseDefinition.statusCode}`;
|
|
2667
|
+
if (apexDocResponseDefinition.description) {
|
|
2668
|
+
description = apexDocResponseDefinition.description;
|
|
2669
|
+
}
|
|
2670
|
+
return {
|
|
2671
|
+
description,
|
|
2672
|
+
content: {
|
|
2673
|
+
"application/json": {
|
|
2674
|
+
schema: this.getOpenApiSchemaFromApexDocSchema(apexDocResponseDefinition, reference)
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
};
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2681
|
+
class RequestBodyBuilder extends Builder {
|
|
2682
|
+
buildBody(apexRequestBody, reference) {
|
|
2683
|
+
return {
|
|
2684
|
+
description: apexRequestBody.description,
|
|
2685
|
+
content: {
|
|
2686
|
+
"application/json": { schema: this.getOpenApiSchemaFromApexDocSchema(apexRequestBody, reference) }
|
|
2687
|
+
},
|
|
2688
|
+
required: apexRequestBody.required
|
|
2689
|
+
};
|
|
2690
|
+
}
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2693
|
+
class MethodMirrorWrapper {
|
|
2694
|
+
constructor(methodMirror) {
|
|
2695
|
+
this.methodMirror = methodMirror;
|
|
2696
|
+
this.hasDocCommentAnnotation = (annotationName) => {
|
|
2697
|
+
var _a;
|
|
2698
|
+
return (_a = this.methodMirror.docComment) == null ? void 0 : _a.annotations.some((annotation) => annotation.name.toLowerCase() === annotationName);
|
|
2699
|
+
};
|
|
2700
|
+
this.getDocCommentAnnotation = (annotationName) => {
|
|
2701
|
+
var _a;
|
|
2702
|
+
return (_a = this.methodMirror.docComment) == null ? void 0 : _a.annotations.find((annotation) => annotation.name.toLowerCase() === annotationName);
|
|
2703
|
+
};
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2707
|
+
class MethodParser {
|
|
2708
|
+
constructor(openApiModel) {
|
|
2709
|
+
this.openApiModel = openApiModel;
|
|
2710
|
+
}
|
|
2711
|
+
parseMethod(classMirror, httpUrlEndpoint, httpMethodKey, tag) {
|
|
2712
|
+
var _a, _b;
|
|
2713
|
+
const classMirrorWrapper = new ClassMirrorWrapper(classMirror);
|
|
2714
|
+
const httpMethods = classMirrorWrapper.getMethodsByAnnotation(`http${httpMethodKey}`);
|
|
2715
|
+
if (!httpMethods.length) {
|
|
2716
|
+
return;
|
|
2717
|
+
}
|
|
2718
|
+
const httpMethod = httpMethods[0];
|
|
2719
|
+
this.openApiModel.paths[httpUrlEndpoint][httpMethodKey] = {};
|
|
2720
|
+
this.openApiModel.paths[httpUrlEndpoint][httpMethodKey].tags = [tag];
|
|
2721
|
+
if ((_a = httpMethod.docComment) == null ? void 0 : _a.description) {
|
|
2722
|
+
this.openApiModel.paths[httpUrlEndpoint][httpMethodKey].description = httpMethod.docComment.description;
|
|
2723
|
+
}
|
|
2724
|
+
const methodMirrorWrapper = new MethodMirrorWrapper(httpMethod);
|
|
2725
|
+
if (methodMirrorWrapper.hasDocCommentAnnotation("summary")) {
|
|
2726
|
+
this.openApiModel.paths[httpUrlEndpoint][httpMethodKey].summary = (_b = methodMirrorWrapper.getDocCommentAnnotation("summary")) == null ? void 0 : _b.body;
|
|
2727
|
+
}
|
|
2728
|
+
this.parseHttpAnnotation(
|
|
2729
|
+
httpMethod,
|
|
2730
|
+
httpUrlEndpoint,
|
|
2731
|
+
httpMethodKey,
|
|
2732
|
+
"http-request-body",
|
|
2733
|
+
this.addRequestBodyToOpenApi.bind(this),
|
|
2734
|
+
this.fallbackHttpRequestBodyParser(httpUrlEndpoint, httpMethodKey)
|
|
2735
|
+
);
|
|
2736
|
+
this.parseHttpAnnotation(
|
|
2737
|
+
httpMethod,
|
|
2738
|
+
httpUrlEndpoint,
|
|
2739
|
+
httpMethodKey,
|
|
2740
|
+
"http-parameter",
|
|
2741
|
+
this.addParametersToOpenApi.bind(this)
|
|
2742
|
+
);
|
|
2743
|
+
this.parseHttpAnnotation(
|
|
2744
|
+
httpMethod,
|
|
2745
|
+
httpUrlEndpoint,
|
|
2746
|
+
httpMethodKey,
|
|
2747
|
+
"http-response",
|
|
2748
|
+
this.addHttpResponsesToOpenApi.bind(this),
|
|
2749
|
+
this.getFallbackHttpResponseParser(httpUrlEndpoint, httpMethodKey)
|
|
2750
|
+
);
|
|
2751
|
+
}
|
|
2752
|
+
parseHttpAnnotation(httpMethod, urlValue, httpMethodKey, annotationName, addToOpenApi, fallbackParser) {
|
|
2753
|
+
var _a;
|
|
2754
|
+
const annotations = (_a = httpMethod.docComment) == null ? void 0 : _a.annotations.filter((annotation) => annotation.name === annotationName);
|
|
2755
|
+
if (!(annotations == null ? void 0 : annotations.length)) {
|
|
2756
|
+
if (fallbackParser) {
|
|
2757
|
+
fallbackParser(httpMethod);
|
|
2758
|
+
}
|
|
2759
|
+
return;
|
|
2760
|
+
}
|
|
2761
|
+
for (const annotation of annotations) {
|
|
2762
|
+
const inYaml = annotation == null ? void 0 : annotation.bodyLines.reduce((prev, current) => prev + "\n" + current);
|
|
2763
|
+
if (!inYaml) {
|
|
2764
|
+
return;
|
|
2765
|
+
}
|
|
2766
|
+
this.addToOpenApiStrategy(inYaml, urlValue, httpMethodKey, addToOpenApi);
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
addToOpenApiStrategy(inYaml, urlValue, httpMethodKey, addToOpenApi) {
|
|
2770
|
+
const inJson = yaml__namespace.load(inYaml);
|
|
2771
|
+
const requestBodyResponse = new RequestBodyBuilder().build(inJson);
|
|
2772
|
+
addToOpenApi(inJson, urlValue, httpMethodKey);
|
|
2773
|
+
this.addReference(requestBodyResponse);
|
|
2774
|
+
}
|
|
2775
|
+
addRequestBodyToOpenApi(input, urlValue, httpMethodKey) {
|
|
2776
|
+
const requestBodyResponse = new RequestBodyBuilder().build(input);
|
|
2777
|
+
this.openApiModel.paths[urlValue][httpMethodKey].requestBody = requestBodyResponse.body;
|
|
2778
|
+
}
|
|
2779
|
+
addParametersToOpenApi(input, urlValue, httpMethodKey) {
|
|
2780
|
+
const parameterObjectResponse = new ParameterObjectBuilder().build(input);
|
|
2781
|
+
if (this.openApiModel.paths[urlValue][httpMethodKey].parameters === void 0) {
|
|
2782
|
+
this.openApiModel.paths[urlValue][httpMethodKey].parameters = [];
|
|
2783
|
+
}
|
|
2784
|
+
this.openApiModel.paths[urlValue][httpMethodKey].parameters.push(parameterObjectResponse.body);
|
|
2785
|
+
}
|
|
2786
|
+
addHttpResponsesToOpenApi(input, urlValue, httpMethodKey) {
|
|
2787
|
+
const responseObjectResponse = new ResponsesBuilder().build(input);
|
|
2788
|
+
if (this.openApiModel.paths[urlValue][httpMethodKey].responses === void 0) {
|
|
2789
|
+
this.openApiModel.paths[urlValue][httpMethodKey].responses = {};
|
|
2790
|
+
}
|
|
2791
|
+
this.openApiModel.paths[urlValue][httpMethodKey].responses[input.statusCode] = responseObjectResponse.body;
|
|
2792
|
+
}
|
|
2793
|
+
fallbackHttpRequestBodyParser(httpUrlEndpoint, httpMethodKey) {
|
|
2794
|
+
return (methodMirror) => {
|
|
2795
|
+
const parameters = methodMirror.parameters;
|
|
2796
|
+
if (!parameters.length) {
|
|
2797
|
+
return;
|
|
2798
|
+
}
|
|
2799
|
+
const propertiesObject = {};
|
|
2800
|
+
parameters.forEach((currentParameter) => {
|
|
2801
|
+
const propertyKey = currentParameter.name;
|
|
2802
|
+
const propertyReference = new ReferenceBuilder().getReferenceType(currentParameter.typeReference);
|
|
2803
|
+
propertiesObject[propertyKey] = propertyReference.schema;
|
|
2804
|
+
this.addReference({
|
|
2805
|
+
reference: {
|
|
2806
|
+
entrypointReferenceObject: propertyReference.schema,
|
|
2807
|
+
referenceComponents: propertyReference.referenceComponents
|
|
2808
|
+
}
|
|
2809
|
+
});
|
|
2810
|
+
});
|
|
2811
|
+
this.openApiModel.paths[httpUrlEndpoint][httpMethodKey].requestBody = {
|
|
2812
|
+
content: {
|
|
2813
|
+
"application/json": {
|
|
2814
|
+
schema: {
|
|
2815
|
+
type: "object",
|
|
2816
|
+
properties: propertiesObject
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
}
|
|
2820
|
+
};
|
|
2821
|
+
};
|
|
2822
|
+
}
|
|
2823
|
+
getFallbackHttpResponseParser(httpUrlEndpoint, httpMethodKey) {
|
|
2824
|
+
return (methodMirror) => {
|
|
2825
|
+
var _a, _b;
|
|
2826
|
+
const returnType = methodMirror.typeReference;
|
|
2827
|
+
if (returnType.type.toLowerCase() === "void") {
|
|
2828
|
+
return;
|
|
2829
|
+
}
|
|
2830
|
+
const reference = new ReferenceBuilder().getReferenceType(returnType);
|
|
2831
|
+
this.addReference({
|
|
2832
|
+
reference: {
|
|
2833
|
+
entrypointReferenceObject: reference.schema,
|
|
2834
|
+
referenceComponents: reference.referenceComponents
|
|
2835
|
+
}
|
|
2836
|
+
});
|
|
2837
|
+
if (this.openApiModel.paths[httpUrlEndpoint][httpMethodKey].responses === void 0) {
|
|
2838
|
+
this.openApiModel.paths[httpUrlEndpoint][httpMethodKey].responses = {};
|
|
2839
|
+
}
|
|
2840
|
+
this.openApiModel.paths[httpUrlEndpoint][httpMethodKey].responses["200"] = {
|
|
2841
|
+
description: (_b = (_a = methodMirror.docComment) == null ? void 0 : _a.description) != null ? _b : "Status code 200",
|
|
2842
|
+
content: {
|
|
2843
|
+
"application/json": { schema: reference.schema }
|
|
2844
|
+
}
|
|
2845
|
+
};
|
|
2846
|
+
};
|
|
2847
|
+
}
|
|
2848
|
+
addReference(referenceHolder) {
|
|
2849
|
+
if (referenceHolder.reference) {
|
|
2850
|
+
if (this.openApiModel.components === void 0) {
|
|
2851
|
+
this.openApiModel.components = {
|
|
2852
|
+
schemas: {}
|
|
2853
|
+
};
|
|
2854
|
+
}
|
|
2855
|
+
if (!referenceHolder.reference.referenceComponents.length) {
|
|
2856
|
+
return;
|
|
2857
|
+
}
|
|
2858
|
+
referenceHolder.reference.referenceComponents.forEach((current) => {
|
|
2859
|
+
this.openApiModel.components.schemas[current.referencedClass] = current.schema;
|
|
2860
|
+
});
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
|
|
2865
|
+
const camel2title = (camelCase) => camelCase.replace(/\//g, " ").replace(/([A-Z])/g, (match) => ` ${match}`).replace(/\b\w/g, (match) => match.toUpperCase()).replace(/^./, (match) => match.toUpperCase()).trim();
|
|
2866
|
+
|
|
2867
|
+
var __defProp = Object.defineProperty;
|
|
2868
|
+
var __defProps = Object.defineProperties;
|
|
2869
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2870
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
2871
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2872
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
2873
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2874
|
+
var __spreadValues = (a, b) => {
|
|
2875
|
+
for (var prop in b || (b = {}))
|
|
2876
|
+
if (__hasOwnProp.call(b, prop))
|
|
2877
|
+
__defNormalProp(a, prop, b[prop]);
|
|
2878
|
+
if (__getOwnPropSymbols)
|
|
2879
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
2880
|
+
if (__propIsEnum.call(b, prop))
|
|
2881
|
+
__defNormalProp(a, prop, b[prop]);
|
|
2882
|
+
}
|
|
2883
|
+
return a;
|
|
2884
|
+
};
|
|
2885
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
2886
|
+
function createOpenApiFile(fileName, openApiModel) {
|
|
2887
|
+
const content = JSON.stringify(__spreadProps(__spreadValues({}, openApiModel), { namespace: void 0 }), null, 2);
|
|
2888
|
+
return {
|
|
2889
|
+
outputDocPath: `${fileName}.json`,
|
|
2890
|
+
content,
|
|
2891
|
+
frontmatter: null,
|
|
2892
|
+
group: null
|
|
2893
|
+
};
|
|
2894
|
+
}
|
|
2895
|
+
|
|
2896
|
+
class OpenApiDocsProcessor {
|
|
2897
|
+
constructor(logger) {
|
|
2898
|
+
this.logger = logger;
|
|
2899
|
+
this.onAfterProcess = () => {
|
|
2900
|
+
const page = createOpenApiFile(OpenApiSettings.getInstance().openApiFileName(), this.openApiModel);
|
|
2901
|
+
this._fileContainer.pushFile(page);
|
|
2902
|
+
};
|
|
2903
|
+
this._fileContainer = new FileContainer();
|
|
2904
|
+
const title = OpenApiSettings.getInstance().getOpenApiTitle();
|
|
2905
|
+
if (!title) {
|
|
2906
|
+
throw Error("No OpenApi title was provided.");
|
|
2907
|
+
}
|
|
2908
|
+
this.openApiModel = new OpenApi(
|
|
2909
|
+
title,
|
|
2910
|
+
OpenApiSettings.getInstance().getVersion(),
|
|
2911
|
+
OpenApiSettings.getInstance().getNamespace()
|
|
2912
|
+
);
|
|
2913
|
+
}
|
|
2914
|
+
fileBuilder() {
|
|
2915
|
+
return this._fileContainer;
|
|
2916
|
+
}
|
|
2917
|
+
onProcess(type) {
|
|
2918
|
+
var _a, _b;
|
|
2919
|
+
this.logger.logSingle(`Processing ${type.name}`, "green");
|
|
2920
|
+
const endpointPath = this.getEndpointPath(type);
|
|
2921
|
+
if (!endpointPath) {
|
|
2922
|
+
return;
|
|
2923
|
+
}
|
|
2924
|
+
this.openApiModel.paths[endpointPath] = {};
|
|
2925
|
+
if ((_a = type.docComment) == null ? void 0 : _a.description) {
|
|
2926
|
+
this.openApiModel.paths[endpointPath].description = type.docComment.description;
|
|
2927
|
+
}
|
|
2928
|
+
const typeAsClass = type;
|
|
2929
|
+
const tagName = camel2title(endpointPath);
|
|
2930
|
+
this.openApiModel.tags.push({
|
|
2931
|
+
name: tagName,
|
|
2932
|
+
description: (_b = type.docComment) == null ? void 0 : _b.description
|
|
2933
|
+
});
|
|
2934
|
+
const parser = new MethodParser(this.openApiModel);
|
|
2935
|
+
parser.parseMethod(typeAsClass, endpointPath, "get", tagName);
|
|
2936
|
+
parser.parseMethod(typeAsClass, endpointPath, "patch", tagName);
|
|
2937
|
+
parser.parseMethod(typeAsClass, endpointPath, "post", tagName);
|
|
2938
|
+
parser.parseMethod(typeAsClass, endpointPath, "put", tagName);
|
|
2939
|
+
parser.parseMethod(typeAsClass, endpointPath, "delete", tagName);
|
|
2940
|
+
}
|
|
2941
|
+
getEndpointPath(type) {
|
|
2942
|
+
var _a;
|
|
2943
|
+
const restResourceAnnotation = type.annotations.find((element) => element.name.toLowerCase() === "restresource");
|
|
2944
|
+
const urlMapping = (_a = restResourceAnnotation == null ? void 0 : restResourceAnnotation.elementValues) == null ? void 0 : _a.find(
|
|
2945
|
+
(element) => element.key.toLowerCase() === "urlmapping"
|
|
2946
|
+
);
|
|
2947
|
+
if (!urlMapping) {
|
|
2948
|
+
this.logger.error(`Type does not contain urlMapping annotation ${type.name}`);
|
|
2949
|
+
return null;
|
|
2950
|
+
}
|
|
2951
|
+
let endpointPath = urlMapping.value.replaceAll('"', "").replaceAll("'", "").replaceAll("/*", "/");
|
|
2952
|
+
if (endpointPath.startsWith("/")) {
|
|
2953
|
+
endpointPath = endpointPath.substring(1);
|
|
2954
|
+
}
|
|
2955
|
+
return endpointPath;
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
var __async$3 = (__this, __arguments, generator) => {
|
|
2960
|
+
return new Promise((resolve, reject) => {
|
|
2961
|
+
var fulfilled = (value) => {
|
|
2962
|
+
try {
|
|
2963
|
+
step(generator.next(value));
|
|
2964
|
+
} catch (e) {
|
|
2965
|
+
reject(e);
|
|
2966
|
+
}
|
|
2967
|
+
};
|
|
2968
|
+
var rejected = (value) => {
|
|
2969
|
+
try {
|
|
2970
|
+
step(generator.throw(value));
|
|
2971
|
+
} catch (e) {
|
|
2972
|
+
reject(e);
|
|
2973
|
+
}
|
|
2974
|
+
};
|
|
2975
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2976
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
2977
|
+
});
|
|
2978
|
+
};
|
|
2979
|
+
function openApi(logger, fileBodies, config) {
|
|
2980
|
+
return __async$3(this, null, function* () {
|
|
2981
|
+
OpenApiSettings.build({
|
|
2982
|
+
sourceDirectory: config.sourceDir,
|
|
2983
|
+
outputDir: config.targetDir,
|
|
2984
|
+
openApiFileName: config.fileName,
|
|
2985
|
+
openApiTitle: config.title,
|
|
2986
|
+
namespace: config.namespace,
|
|
2987
|
+
version: config.apiVersion
|
|
2988
|
+
});
|
|
2989
|
+
const manifest = createManifest(new RawBodyParser(logger, fileBodies), apply(reflectionWithLogger, logger));
|
|
2990
|
+
TypesRepository.getInstance().populateAll(manifest.types);
|
|
2991
|
+
const filteredTypes = filterByScopes(logger, manifest);
|
|
2992
|
+
const processor = new OpenApiDocsProcessor(logger);
|
|
2993
|
+
Transpiler.generate(filteredTypes, processor);
|
|
2994
|
+
const generatedFiles = processor.fileBuilder().files();
|
|
2995
|
+
yield _function.pipe(
|
|
2996
|
+
writeFiles(generatedFiles, config.targetDir, (file) => {
|
|
2997
|
+
logger.logSingle(`${file.outputDocPath} processed.`, "green");
|
|
2998
|
+
}),
|
|
2999
|
+
TE__namespace.mapError((error) => logger.error(error))
|
|
3000
|
+
)();
|
|
3001
|
+
ErrorLogger.logErrors(logger, filteredTypes);
|
|
3002
|
+
});
|
|
3003
|
+
}
|
|
3004
|
+
function reflectionWithLogger(logger, apexBundle) {
|
|
3005
|
+
var _a;
|
|
3006
|
+
const result = apexReflection.reflect(apexBundle.content);
|
|
3007
|
+
if (result.error) {
|
|
3008
|
+
logger.error(`${apexBundle.filePath} - Parsing error ${(_a = result.error) == null ? void 0 : _a.message}`);
|
|
3009
|
+
}
|
|
3010
|
+
return result;
|
|
3011
|
+
}
|
|
3012
|
+
function filterByScopes(logger, manifest) {
|
|
3013
|
+
const filteredTypes = manifest.filteredByAccessModifierAndAnnotations([
|
|
3014
|
+
"restresource",
|
|
3015
|
+
"httpdelete",
|
|
3016
|
+
"httpget",
|
|
3017
|
+
"httppatch",
|
|
3018
|
+
"httppost",
|
|
3019
|
+
"httpput"
|
|
3020
|
+
]);
|
|
3021
|
+
const filteredLogMessage = `Filtered ${manifest.types.length - filteredTypes.length} file(s), only keeping classes annotated as @RestResource.`;
|
|
3022
|
+
logger.logSingle(filteredLogMessage, "green");
|
|
3023
|
+
logger.logSingle(`Creating documentation for ${filteredTypes.length} file(s)`, "green");
|
|
3024
|
+
return filteredTypes;
|
|
3025
|
+
}
|
|
3026
|
+
|
|
3027
|
+
var __async$2 = (__this, __arguments, generator) => {
|
|
3028
|
+
return new Promise((resolve, reject) => {
|
|
3029
|
+
var fulfilled = (value) => {
|
|
3030
|
+
try {
|
|
3031
|
+
step(generator.next(value));
|
|
3032
|
+
} catch (e) {
|
|
3033
|
+
reject(e);
|
|
3034
|
+
}
|
|
3035
|
+
};
|
|
3036
|
+
var rejected = (value) => {
|
|
3037
|
+
try {
|
|
3038
|
+
step(generator.throw(value));
|
|
3039
|
+
} catch (e) {
|
|
3040
|
+
reject(e);
|
|
3041
|
+
}
|
|
3042
|
+
};
|
|
3043
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3044
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
3045
|
+
});
|
|
3046
|
+
};
|
|
3047
|
+
const APEX_FILE_EXTENSION = ".cls";
|
|
3048
|
+
class ApexFileReader {
|
|
3049
|
+
/**
|
|
3050
|
+
* Reads from .cls files and returns their raw body.
|
|
3051
|
+
*/
|
|
3052
|
+
static processFiles(fileSystem, rootPath, includeMetadata) {
|
|
3053
|
+
return __async$2(this, null, function* () {
|
|
3054
|
+
const filePaths = yield this.getFilePaths(fileSystem, rootPath);
|
|
3055
|
+
const apexFilePaths = filePaths.filter((filePath) => this.isApexFile(filePath));
|
|
3056
|
+
const filePromises = apexFilePaths.map((filePath) => this.processFile(fileSystem, filePath, includeMetadata));
|
|
3057
|
+
return Promise.all(filePromises);
|
|
3058
|
+
});
|
|
3059
|
+
}
|
|
3060
|
+
static getFilePaths(fileSystem, rootPath) {
|
|
3061
|
+
return __async$2(this, null, function* () {
|
|
3062
|
+
const directoryContents = yield fileSystem.readDirectory(rootPath);
|
|
3063
|
+
const paths = [];
|
|
3064
|
+
for (const filePath of directoryContents) {
|
|
3065
|
+
const currentPath = fileSystem.joinPath(rootPath, filePath);
|
|
3066
|
+
if (yield fileSystem.isDirectory(currentPath)) {
|
|
3067
|
+
paths.push(...yield this.getFilePaths(fileSystem, currentPath));
|
|
3068
|
+
return paths;
|
|
3069
|
+
}
|
|
3070
|
+
paths.push(currentPath);
|
|
3071
|
+
}
|
|
3072
|
+
return paths;
|
|
3073
|
+
});
|
|
3074
|
+
}
|
|
3075
|
+
static processFile(fileSystem, filePath, includeMetadata) {
|
|
3076
|
+
return __async$2(this, null, function* () {
|
|
3077
|
+
const rawTypeContent = yield fileSystem.readFile(filePath);
|
|
3078
|
+
const metadataPath = `${filePath}-meta.xml`;
|
|
3079
|
+
let rawMetadataContent = null;
|
|
3080
|
+
if (includeMetadata) {
|
|
3081
|
+
rawMetadataContent = fileSystem.exists(metadataPath) ? yield fileSystem.readFile(metadataPath) : null;
|
|
3082
|
+
}
|
|
3083
|
+
return { filePath, content: rawTypeContent, metadataContent: rawMetadataContent };
|
|
3084
|
+
});
|
|
3085
|
+
}
|
|
3086
|
+
static isApexFile(currentFile) {
|
|
3087
|
+
return currentFile.endsWith(APEX_FILE_EXTENSION);
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
|
|
3091
|
+
var __async$1 = (__this, __arguments, generator) => {
|
|
3092
|
+
return new Promise((resolve, reject) => {
|
|
3093
|
+
var fulfilled = (value) => {
|
|
3094
|
+
try {
|
|
3095
|
+
step(generator.next(value));
|
|
3096
|
+
} catch (e) {
|
|
3097
|
+
reject(e);
|
|
3098
|
+
}
|
|
3099
|
+
};
|
|
3100
|
+
var rejected = (value) => {
|
|
3101
|
+
try {
|
|
3102
|
+
step(generator.throw(value));
|
|
3103
|
+
} catch (e) {
|
|
3104
|
+
reject(e);
|
|
3105
|
+
}
|
|
3106
|
+
};
|
|
3107
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3108
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
3109
|
+
});
|
|
3110
|
+
};
|
|
3111
|
+
function stat(path2) {
|
|
3112
|
+
return new Promise((resolve, reject) => {
|
|
3113
|
+
fs__namespace.stat(path2, (err, stats) => {
|
|
3114
|
+
if (err) {
|
|
3115
|
+
reject(err);
|
|
3116
|
+
} else {
|
|
3117
|
+
resolve(stats);
|
|
3118
|
+
}
|
|
3119
|
+
});
|
|
3120
|
+
});
|
|
3121
|
+
}
|
|
3122
|
+
function readdir(path2) {
|
|
3123
|
+
return new Promise((resolve, reject) => {
|
|
3124
|
+
fs__namespace.readdir(path2, (err, files) => {
|
|
3125
|
+
if (err) {
|
|
3126
|
+
reject(err);
|
|
3127
|
+
} else {
|
|
3128
|
+
resolve(files);
|
|
3129
|
+
}
|
|
3130
|
+
});
|
|
3131
|
+
});
|
|
3132
|
+
}
|
|
3133
|
+
function readFile(path2) {
|
|
3134
|
+
return new Promise((resolve, reject) => {
|
|
3135
|
+
fs__namespace.readFile(path2, (err, data) => {
|
|
3136
|
+
if (err) {
|
|
3137
|
+
reject(err);
|
|
3138
|
+
} else {
|
|
3139
|
+
resolve(data.toString());
|
|
3140
|
+
}
|
|
3141
|
+
});
|
|
3142
|
+
});
|
|
3143
|
+
}
|
|
3144
|
+
class DefaultFileSystem {
|
|
3145
|
+
isDirectory(pathToRead) {
|
|
3146
|
+
return __async$1(this, null, function* () {
|
|
3147
|
+
const stats = yield stat(pathToRead);
|
|
3148
|
+
return stats.isDirectory();
|
|
3149
|
+
});
|
|
3150
|
+
}
|
|
3151
|
+
readDirectory(sourceDirectory) {
|
|
3152
|
+
return readdir(sourceDirectory);
|
|
3153
|
+
}
|
|
3154
|
+
readFile(pathToRead) {
|
|
3155
|
+
return readFile(pathToRead);
|
|
3156
|
+
}
|
|
3157
|
+
joinPath(...paths) {
|
|
3158
|
+
return path__namespace.join(...paths);
|
|
3159
|
+
}
|
|
3160
|
+
exists(path2) {
|
|
3161
|
+
return fs__namespace.existsSync(path2);
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3164
|
+
|
|
3165
|
+
var __async = (__this, __arguments, generator) => {
|
|
3166
|
+
return new Promise((resolve, reject) => {
|
|
3167
|
+
var fulfilled = (value) => {
|
|
3168
|
+
try {
|
|
3169
|
+
step(generator.next(value));
|
|
3170
|
+
} catch (e) {
|
|
3171
|
+
reject(e);
|
|
3172
|
+
}
|
|
3173
|
+
};
|
|
3174
|
+
var rejected = (value) => {
|
|
3175
|
+
try {
|
|
3176
|
+
step(generator.throw(value));
|
|
3177
|
+
} catch (e) {
|
|
3178
|
+
reject(e);
|
|
3179
|
+
}
|
|
3180
|
+
};
|
|
3181
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3182
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
3183
|
+
});
|
|
3184
|
+
};
|
|
3185
|
+
class Apexdocs {
|
|
3186
|
+
/**
|
|
3187
|
+
* Generates documentation out of Apex source files.
|
|
3188
|
+
*/
|
|
3189
|
+
static generate(config, logger) {
|
|
3190
|
+
return __async(this, null, function* () {
|
|
3191
|
+
logger.logSingle(`Generating ${config.targetGenerator} documentation...`);
|
|
3192
|
+
try {
|
|
3193
|
+
const fileBodies = yield ApexFileReader.processFiles(
|
|
3194
|
+
new DefaultFileSystem(),
|
|
3195
|
+
config.sourceDir,
|
|
3196
|
+
config.targetGenerator === "markdown" ? config.includeMetadata : false
|
|
3197
|
+
);
|
|
3198
|
+
console.log("config from Apexdocs", config);
|
|
3199
|
+
switch (config.targetGenerator) {
|
|
3200
|
+
case "markdown":
|
|
3201
|
+
return yield generateMarkdownDocumentation(fileBodies, config)();
|
|
3202
|
+
case "openapi":
|
|
3203
|
+
yield openApi(logger, fileBodies, config);
|
|
3204
|
+
return E__namespace.right("\u2714\uFE0F Documentation generated successfully!");
|
|
3205
|
+
}
|
|
3206
|
+
} catch (error) {
|
|
3207
|
+
return E__namespace.left([error]);
|
|
3208
|
+
}
|
|
3209
|
+
});
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
function generateMarkdownDocumentation(fileBodies, config) {
|
|
3213
|
+
return _function.pipe(
|
|
3214
|
+
generate(fileBodies, config),
|
|
3215
|
+
TE__namespace.map(() => "\u2714\uFE0F Documentation generated successfully!"),
|
|
3216
|
+
TE__namespace.mapLeft((error) => {
|
|
3217
|
+
if (error._tag === "HookError") {
|
|
3218
|
+
return ["Error(s) occurred while processing hooks. Please review the following issues:", error.error];
|
|
3219
|
+
}
|
|
3220
|
+
if (error._tag === "FileWritingError") {
|
|
3221
|
+
return ["Error(s) occurred while writing files. Please review the following issues:", error.error];
|
|
3222
|
+
}
|
|
3223
|
+
return [
|
|
3224
|
+
"Error(s) occurred while parsing files. Please review the following issues:",
|
|
3225
|
+
...error.errors.map(formatReflectionError)
|
|
3226
|
+
];
|
|
3227
|
+
})
|
|
3228
|
+
);
|
|
3229
|
+
}
|
|
3230
|
+
function formatReflectionError(error) {
|
|
3231
|
+
return `Source file: ${error.file}
|
|
3232
|
+
${error.message}
|
|
3233
|
+
`;
|
|
3234
|
+
}
|
|
3235
|
+
|
|
3236
|
+
class StdOutLogger {
|
|
3237
|
+
/**
|
|
3238
|
+
* Logs a message with optional arguments.
|
|
3239
|
+
* @param message The message to log.
|
|
3240
|
+
* @param args Optional arguments.
|
|
3241
|
+
*/
|
|
3242
|
+
log(message, ...args) {
|
|
3243
|
+
this.logSingle(message);
|
|
3244
|
+
args.forEach((arg) => {
|
|
3245
|
+
this.logSingle(arg);
|
|
3246
|
+
});
|
|
3247
|
+
}
|
|
3248
|
+
/**
|
|
3249
|
+
* Logs an error message with optional arguments.
|
|
3250
|
+
* @param message The error message to log.
|
|
3251
|
+
* @param args Optional arguments.
|
|
3252
|
+
*/
|
|
3253
|
+
error(message, ...args) {
|
|
3254
|
+
this.logSingle(message, "red");
|
|
3255
|
+
args.forEach(() => {
|
|
3256
|
+
this.logSingle(message, "red");
|
|
3257
|
+
});
|
|
3258
|
+
}
|
|
3259
|
+
logSingle(text, color = "green") {
|
|
3260
|
+
const logMessage = `${this.getChalkFn(color)((/* @__PURE__ */ new Date()).toLocaleString() + ": ")}${text}
|
|
3261
|
+
`;
|
|
3262
|
+
process.stdout.write(logMessage);
|
|
3263
|
+
}
|
|
3264
|
+
getChalkFn(color) {
|
|
3265
|
+
return color === "green" ? chalk.green : chalk.red;
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
class NoLogger {
|
|
3269
|
+
log() {
|
|
3270
|
+
}
|
|
3271
|
+
error() {
|
|
3272
|
+
}
|
|
3273
|
+
logSingle() {
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3277
|
+
exports.Apexdocs = Apexdocs;
|
|
3278
|
+
exports.NoLogger = NoLogger;
|
|
3279
|
+
exports.StdOutLogger = StdOutLogger;
|
|
3280
|
+
exports.markdownDefaults = markdownDefaults;
|
|
3281
|
+
exports.openApiDefaults = openApiDefaults;
|