@cparra/apexdocs 3.24.0 → 3.24.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/generate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var errorCollector = require('../error-collector-
|
|
4
|
+
var errorCollector = require('../error-collector-BbdZNqzo.js');
|
|
5
5
|
var cosmiconfig = require('cosmiconfig');
|
|
6
6
|
var yargs = require('yargs');
|
|
7
7
|
var E = require('fp-ts/Either');
|
|
@@ -26,7 +26,7 @@ require('fs');
|
|
|
26
26
|
require('fp-ts/lib/TaskEither.js');
|
|
27
27
|
require('minimatch');
|
|
28
28
|
require('@salesforce/source-deploy-retrieve');
|
|
29
|
-
require('
|
|
29
|
+
require('node:util');
|
|
30
30
|
|
|
31
31
|
function _interopNamespaceDefault(e) {
|
|
32
32
|
var n = Object.create(null);
|
|
@@ -21,7 +21,7 @@ var fs$1 = require('fs');
|
|
|
21
21
|
var TE$1 = require('fp-ts/lib/TaskEither.js');
|
|
22
22
|
var minimatch = require('minimatch');
|
|
23
23
|
var sourceDeployRetrieve = require('@salesforce/source-deploy-retrieve');
|
|
24
|
-
var
|
|
24
|
+
var node_util = require('node:util');
|
|
25
25
|
|
|
26
26
|
function _interopNamespaceDefault(e) {
|
|
27
27
|
var n = Object.create(null);
|
|
@@ -4692,6 +4692,11 @@ class MethodMirrorWrapper {
|
|
|
4692
4692
|
var _a;
|
|
4693
4693
|
return (_a = this.methodMirror.docComment) == null ? void 0 : _a.annotations.find((annotation) => annotation.name.toLowerCase() === annotationName);
|
|
4694
4694
|
};
|
|
4695
|
+
/** The body of these annotations is expected to be in YAML format. */
|
|
4696
|
+
this.getDocCommentAnnotationsAs = (annotationName) => {
|
|
4697
|
+
var _a, _b;
|
|
4698
|
+
return ((_b = (_a = this.methodMirror.docComment) == null ? void 0 : _a.annotations) != null ? _b : []).filter((annotation) => annotation.name.toLowerCase() === annotationName).map((annotation) => yaml__namespace.load(annotation.bodyLines.join("\n"))).filter((parsed) => parsed !== void 0);
|
|
4699
|
+
};
|
|
4695
4700
|
}
|
|
4696
4701
|
}
|
|
4697
4702
|
|
|
@@ -4907,16 +4912,16 @@ class OpenApiDocsProcessor {
|
|
|
4907
4912
|
}
|
|
4908
4913
|
onProcess(type) {
|
|
4909
4914
|
var _a, _b;
|
|
4910
|
-
const
|
|
4911
|
-
|
|
4915
|
+
const typeAsClass = type;
|
|
4916
|
+
const endpoint = this.getEndpoint(typeAsClass);
|
|
4917
|
+
if (!endpoint) {
|
|
4912
4918
|
return;
|
|
4913
4919
|
}
|
|
4920
|
+
const { path: endpointPath, tagName } = endpoint;
|
|
4914
4921
|
this.openApiModel.paths[endpointPath] = {};
|
|
4915
4922
|
if ((_a = type.docComment) == null ? void 0 : _a.description) {
|
|
4916
4923
|
this.openApiModel.paths[endpointPath].description = type.docComment.description;
|
|
4917
4924
|
}
|
|
4918
|
-
const typeAsClass = type;
|
|
4919
|
-
const tagName = camel2title(endpointPath);
|
|
4920
4925
|
this.openApiModel.tags.push({
|
|
4921
4926
|
name: tagName,
|
|
4922
4927
|
description: (_b = type.docComment) == null ? void 0 : _b.description
|
|
@@ -4928,7 +4933,7 @@ class OpenApiDocsProcessor {
|
|
|
4928
4933
|
parser.parseMethod(typeAsClass, endpointPath, "put", tagName);
|
|
4929
4934
|
parser.parseMethod(typeAsClass, endpointPath, "delete", tagName);
|
|
4930
4935
|
}
|
|
4931
|
-
|
|
4936
|
+
getEndpoint(type) {
|
|
4932
4937
|
var _a;
|
|
4933
4938
|
const restResourceAnnotation = type.annotations.find((element) => element.name.toLowerCase() === "restresource");
|
|
4934
4939
|
const urlMapping = (_a = restResourceAnnotation == null ? void 0 : restResourceAnnotation.elementValues) == null ? void 0 : _a.find(
|
|
@@ -4938,7 +4943,28 @@ class OpenApiDocsProcessor {
|
|
|
4938
4943
|
this.logger.error(`Type does not contain urlMapping annotation ${type.name}`);
|
|
4939
4944
|
return null;
|
|
4940
4945
|
}
|
|
4941
|
-
|
|
4946
|
+
const rawPath = urlMapping.value.replaceAll('"', "").replaceAll("'", "");
|
|
4947
|
+
const segments = rawPath.split("/");
|
|
4948
|
+
const parameterNames = segments.includes("*") ? this.getPathParameterNames(type) : [];
|
|
4949
|
+
let wildcardIndex = 0;
|
|
4950
|
+
let fallbackIndex = 0;
|
|
4951
|
+
const path = segments.map(
|
|
4952
|
+
(segment) => {
|
|
4953
|
+
var _a2;
|
|
4954
|
+
return segment === "*" ? `{${(_a2 = parameterNames[wildcardIndex++]) != null ? _a2 : `param${++fallbackIndex}`}}` : segment;
|
|
4955
|
+
}
|
|
4956
|
+
).join("/");
|
|
4957
|
+
return { path, tagName: camel2title(segments.filter((segment) => segment !== "*").join("/")) };
|
|
4958
|
+
}
|
|
4959
|
+
/**
|
|
4960
|
+
* Returns the names of all parameters declared as `in: path` through @http-parameter
|
|
4961
|
+
* doc annotations on the class's methods, in the order the methods are declared.
|
|
4962
|
+
*/
|
|
4963
|
+
getPathParameterNames(type) {
|
|
4964
|
+
const names = type.methods.flatMap(
|
|
4965
|
+
(method) => new MethodMirrorWrapper(method).getDocCommentAnnotationsAs("http-parameter")
|
|
4966
|
+
).filter((parameter) => parameter.in === "path" && parameter.name).map((parameter) => parameter.name);
|
|
4967
|
+
return [...new Set(names)];
|
|
4942
4968
|
}
|
|
4943
4969
|
}
|
|
4944
4970
|
|
|
@@ -6539,12 +6565,10 @@ class StdOutLogger {
|
|
|
6539
6565
|
});
|
|
6540
6566
|
}
|
|
6541
6567
|
logSingle(text, color = "green") {
|
|
6542
|
-
const
|
|
6543
|
-
|
|
6544
|
-
process.stdout.write(
|
|
6545
|
-
|
|
6546
|
-
getChalkFn(color) {
|
|
6547
|
-
return color === "green" ? chalk.green : chalk.red;
|
|
6568
|
+
const timestamp = (/* @__PURE__ */ new Date()).toLocaleString() + ": ";
|
|
6569
|
+
const styled = typeof node_util.styleText === "function" ? node_util.styleText(color, timestamp) : timestamp;
|
|
6570
|
+
process.stdout.write(`${styled}${text}
|
|
6571
|
+
`);
|
|
6548
6572
|
}
|
|
6549
6573
|
}
|
|
6550
6574
|
class NoLogger {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var errorCollector = require('./error-collector-
|
|
4
|
+
var errorCollector = require('./error-collector-BbdZNqzo.js');
|
|
5
5
|
var E = require('fp-ts/Either');
|
|
6
6
|
require('fp-ts/function');
|
|
7
7
|
require('fp-ts/TaskEither');
|
|
@@ -23,7 +23,7 @@ require('fs');
|
|
|
23
23
|
require('fp-ts/lib/TaskEither.js');
|
|
24
24
|
require('minimatch');
|
|
25
25
|
require('@salesforce/source-deploy-retrieve');
|
|
26
|
-
require('
|
|
26
|
+
require('node:util');
|
|
27
27
|
|
|
28
28
|
function _interopNamespaceDefault(e) {
|
|
29
29
|
var n = Object.create(null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cparra/apexdocs",
|
|
3
|
-
"version": "3.24.
|
|
3
|
+
"version": "3.24.2",
|
|
4
4
|
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.12.0"
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"test:cov": "npm run build && vitest run --coverage",
|
|
27
27
|
"build": "wireit",
|
|
28
28
|
"lint": "wireit",
|
|
29
|
+
"format": "prettier --write src",
|
|
29
30
|
"prepare": "npm run build",
|
|
30
31
|
"version": "npm run format && git add -A src",
|
|
31
32
|
"postversion": "git push && git push --tags"
|
|
@@ -72,12 +73,12 @@
|
|
|
72
73
|
},
|
|
73
74
|
"devDependencies": {
|
|
74
75
|
"@eslint/js": "^9.34.0",
|
|
76
|
+
"@types/js-yaml": "^4.0.9",
|
|
75
77
|
"@types/node": "^24.3.0",
|
|
78
|
+
"@types/yargs": "^17.0.32",
|
|
76
79
|
"@vitest/coverage-v8": "^4.1.8",
|
|
77
80
|
"eslint": "^9.34.0",
|
|
78
81
|
"eslint-config-prettier": "^9.1.0",
|
|
79
|
-
"husky": "^9.0.11",
|
|
80
|
-
"lint-staged": "^15.2.7",
|
|
81
82
|
"pkgroll": "^2.4.2",
|
|
82
83
|
"prettier": "^3.3.2",
|
|
83
84
|
"typescript": "^5.9.2",
|
|
@@ -85,22 +86,9 @@
|
|
|
85
86
|
"vitest": "^4.1.8",
|
|
86
87
|
"wireit": "^0.14.12"
|
|
87
88
|
},
|
|
88
|
-
"husky": {
|
|
89
|
-
"hooks": {
|
|
90
|
-
"pre-commit": "lint-staged"
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
"lint-staged": {
|
|
94
|
-
"*.{js,ts,tsx}": [
|
|
95
|
-
"eslint --fix"
|
|
96
|
-
]
|
|
97
|
-
},
|
|
98
89
|
"dependencies": {
|
|
99
90
|
"@cparra/apex-reflection": "4.0.0",
|
|
100
91
|
"@salesforce/source-deploy-retrieve": "^12.20.1",
|
|
101
|
-
"@types/js-yaml": "^4.0.9",
|
|
102
|
-
"@types/yargs": "^17.0.32",
|
|
103
|
-
"chalk": "^4.1.2",
|
|
104
92
|
"cosmiconfig": "^9.0.0",
|
|
105
93
|
"cosmiconfig-typescript-loader": "^5.0.0",
|
|
106
94
|
"fast-xml-parser": "^5.5.9",
|