@cparra/apexdocs 3.17.0-beta.1 → 3.17.0-beta.3
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 logger$1 = require('../logger-
|
|
4
|
+
var logger$1 = require('../logger-DK9lGHPu.js');
|
|
5
5
|
var cosmiconfig = require('cosmiconfig');
|
|
6
6
|
var yargs = require('yargs');
|
|
7
7
|
var E = require('fp-ts/Either');
|
|
@@ -15,6 +15,10 @@ require('fp-ts/lib/Array');
|
|
|
15
15
|
require('@cparra/apex-reflection');
|
|
16
16
|
require('fp-ts/Option');
|
|
17
17
|
require('fast-xml-parser');
|
|
18
|
+
require('node:worker_threads');
|
|
19
|
+
require('node:path');
|
|
20
|
+
require('node:os');
|
|
21
|
+
require('node:fs');
|
|
18
22
|
require('handlebars');
|
|
19
23
|
require('fp-ts/boolean');
|
|
20
24
|
require('fp-ts/Array');
|
|
@@ -152,10 +156,15 @@ const markdownOptions = {
|
|
|
152
156
|
describe: "Enable experimental support for documenting Lightning Web Components (LWC).",
|
|
153
157
|
default: logger$1.markdownDefaults.experimentalLwcSupport
|
|
154
158
|
},
|
|
155
|
-
|
|
159
|
+
parallelReflection: {
|
|
156
160
|
type: "boolean",
|
|
157
|
-
describe: "
|
|
158
|
-
default: logger$1.markdownDefaults.
|
|
161
|
+
describe: "Parallelize CPU-heavy reflection via worker threads.",
|
|
162
|
+
default: logger$1.markdownDefaults.parallelReflection
|
|
163
|
+
},
|
|
164
|
+
parallelReflectionMaxWorkers: {
|
|
165
|
+
type: "number",
|
|
166
|
+
describe: "Maximum number of worker threads to use for parallel reflection. Defaults to a reasonable value based on CPU count.",
|
|
167
|
+
default: logger$1.markdownDefaults.parallelReflectionMaxWorkers
|
|
159
168
|
}
|
|
160
169
|
};
|
|
161
170
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_worker_threads_1 = require("node:worker_threads");
|
|
4
|
+
const apex_reflection_1 = require("@cparra/apex-reflection");
|
|
5
|
+
function isRequestMessage(msg) {
|
|
6
|
+
if (!msg || typeof msg !== 'object')
|
|
7
|
+
return false;
|
|
8
|
+
const m = msg;
|
|
9
|
+
if (typeof m.id !== 'number')
|
|
10
|
+
return false;
|
|
11
|
+
if (!m.payload || typeof m.payload !== 'object')
|
|
12
|
+
return false;
|
|
13
|
+
const p = m.payload;
|
|
14
|
+
return typeof p.content === 'string';
|
|
15
|
+
}
|
|
16
|
+
function post(msg) {
|
|
17
|
+
// `parentPort` should always exist in a worker, but guard anyway.
|
|
18
|
+
if (!node_worker_threads_1.parentPort) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
node_worker_threads_1.parentPort.postMessage(msg);
|
|
22
|
+
}
|
|
23
|
+
function reflectOrThrow(rawSource) {
|
|
24
|
+
const result = (0, apex_reflection_1.reflect)(rawSource);
|
|
25
|
+
if (result.typeMirror) {
|
|
26
|
+
return result.typeMirror;
|
|
27
|
+
}
|
|
28
|
+
if (result.error) {
|
|
29
|
+
throw result.error;
|
|
30
|
+
}
|
|
31
|
+
throw new Error('Unknown reflection failure: no typeMirror or error returned.');
|
|
32
|
+
}
|
|
33
|
+
if (!node_worker_threads_1.parentPort) {
|
|
34
|
+
throw new Error('apex-reflection.worker started without a parentPort');
|
|
35
|
+
}
|
|
36
|
+
node_worker_threads_1.parentPort.on('message', (msg) => {
|
|
37
|
+
if (!isRequestMessage(msg)) {
|
|
38
|
+
// Can't correlate without a valid id; ignore.
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const { id, payload } = msg;
|
|
42
|
+
try {
|
|
43
|
+
const typeMirror = reflectOrThrow(payload.content);
|
|
44
|
+
post({ id, ok: true, result: typeMirror });
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
const message = (e === null || e === void 0 ? void 0 : e.message) &&
|
|
48
|
+
typeof e.message === 'string'
|
|
49
|
+
? e.message
|
|
50
|
+
: 'Unknown error';
|
|
51
|
+
post({
|
|
52
|
+
id,
|
|
53
|
+
ok: false,
|
|
54
|
+
error: { message },
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -400,7 +400,18 @@ type CliConfigurableMarkdownConfig = {
|
|
|
400
400
|
includeFieldSecurityMetadata: boolean;
|
|
401
401
|
includeInlineHelpTextMetadata: boolean;
|
|
402
402
|
experimentalLwcSupport: boolean;
|
|
403
|
-
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Whether to parallelize CPU-heavy reflection steps via worker threads.
|
|
406
|
+
* Defaults to true.
|
|
407
|
+
*/
|
|
408
|
+
parallelReflection: boolean;
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Max number of worker threads to use for parallel reflection.
|
|
412
|
+
* Defaults to a reasonable value based on CPU count.
|
|
413
|
+
*/
|
|
414
|
+
parallelReflectionMaxWorkers?: number;
|
|
404
415
|
};
|
|
405
416
|
|
|
406
417
|
type UserDefinedMarkdownConfig = {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var logger = require('./logger-
|
|
4
|
+
var logger = require('./logger-DK9lGHPu.js');
|
|
5
5
|
var E = require('fp-ts/Either');
|
|
6
6
|
require('fp-ts/function');
|
|
7
7
|
require('fp-ts/TaskEither');
|
|
@@ -12,6 +12,10 @@ require('fp-ts/lib/Array');
|
|
|
12
12
|
require('@cparra/apex-reflection');
|
|
13
13
|
require('fp-ts/Option');
|
|
14
14
|
require('fast-xml-parser');
|
|
15
|
+
require('node:worker_threads');
|
|
16
|
+
require('node:path');
|
|
17
|
+
require('node:os');
|
|
18
|
+
require('node:fs');
|
|
15
19
|
require('handlebars');
|
|
16
20
|
require('fp-ts/boolean');
|
|
17
21
|
require('fp-ts/Array');
|
|
@@ -10,10 +10,14 @@ var A = require('fp-ts/lib/Array');
|
|
|
10
10
|
var apexReflection = require('@cparra/apex-reflection');
|
|
11
11
|
var O = require('fp-ts/Option');
|
|
12
12
|
var fastXmlParser = require('fast-xml-parser');
|
|
13
|
+
var node_worker_threads = require('node:worker_threads');
|
|
14
|
+
var path$1 = require('node:path');
|
|
15
|
+
var os = require('node:os');
|
|
16
|
+
var fs = require('node:fs');
|
|
13
17
|
var Handlebars = require('handlebars');
|
|
14
18
|
var boolean = require('fp-ts/boolean');
|
|
15
19
|
var A$1 = require('fp-ts/Array');
|
|
16
|
-
var fs = require('fs');
|
|
20
|
+
var fs$1 = require('fs');
|
|
17
21
|
var TE$1 = require('fp-ts/lib/TaskEither');
|
|
18
22
|
var minimatch = require('minimatch');
|
|
19
23
|
var sourceDeployRetrieve = require('@salesforce/source-deploy-retrieve');
|
|
@@ -44,7 +48,7 @@ var T__namespace = /*#__PURE__*/_interopNamespaceDefault(T);
|
|
|
44
48
|
var A__namespace = /*#__PURE__*/_interopNamespaceDefault(A);
|
|
45
49
|
var O__namespace = /*#__PURE__*/_interopNamespaceDefault(O);
|
|
46
50
|
var A__namespace$1 = /*#__PURE__*/_interopNamespaceDefault(A$1);
|
|
47
|
-
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
51
|
+
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs$1);
|
|
48
52
|
var TE__namespace$1 = /*#__PURE__*/_interopNamespaceDefault(TE$1);
|
|
49
53
|
|
|
50
54
|
function apply(fn, ...front) {
|
|
@@ -179,19 +183,19 @@ const defaultTranslations = {
|
|
|
179
183
|
}
|
|
180
184
|
};
|
|
181
185
|
|
|
182
|
-
var __defProp$
|
|
183
|
-
var __getOwnPropSymbols$
|
|
184
|
-
var __hasOwnProp$
|
|
185
|
-
var __propIsEnum$
|
|
186
|
-
var __defNormalProp$
|
|
187
|
-
var __spreadValues$
|
|
186
|
+
var __defProp$r = Object.defineProperty;
|
|
187
|
+
var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
|
|
188
|
+
var __hasOwnProp$r = Object.prototype.hasOwnProperty;
|
|
189
|
+
var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
|
|
190
|
+
var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
191
|
+
var __spreadValues$r = (a, b) => {
|
|
188
192
|
for (var prop in b || (b = {}))
|
|
189
|
-
if (__hasOwnProp$
|
|
190
|
-
__defNormalProp$
|
|
191
|
-
if (__getOwnPropSymbols$
|
|
192
|
-
for (var prop of __getOwnPropSymbols$
|
|
193
|
-
if (__propIsEnum$
|
|
194
|
-
__defNormalProp$
|
|
193
|
+
if (__hasOwnProp$r.call(b, prop))
|
|
194
|
+
__defNormalProp$r(a, prop, b[prop]);
|
|
195
|
+
if (__getOwnPropSymbols$r)
|
|
196
|
+
for (var prop of __getOwnPropSymbols$r(b)) {
|
|
197
|
+
if (__propIsEnum$r.call(b, prop))
|
|
198
|
+
__defNormalProp$r(a, prop, b[prop]);
|
|
195
199
|
}
|
|
196
200
|
return a;
|
|
197
201
|
};
|
|
@@ -207,7 +211,7 @@ function isObjectWithStringKeys(value) {
|
|
|
207
211
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
208
212
|
}
|
|
209
213
|
function deepMerge(target, source) {
|
|
210
|
-
const result = __spreadValues$
|
|
214
|
+
const result = __spreadValues$r({}, target);
|
|
211
215
|
for (const key in source) {
|
|
212
216
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
213
217
|
const sourceValue = source[key];
|
|
@@ -321,25 +325,25 @@ function isInlineCode(content) {
|
|
|
321
325
|
return Object.keys(content).includes("__type") && content.__type === "inline-code";
|
|
322
326
|
}
|
|
323
327
|
|
|
324
|
-
var __defProp$
|
|
325
|
-
var __defProps$
|
|
326
|
-
var __getOwnPropDescs$
|
|
327
|
-
var __getOwnPropSymbols$
|
|
328
|
-
var __hasOwnProp$
|
|
329
|
-
var __propIsEnum$
|
|
330
|
-
var __defNormalProp$
|
|
331
|
-
var __spreadValues$
|
|
328
|
+
var __defProp$q = Object.defineProperty;
|
|
329
|
+
var __defProps$p = Object.defineProperties;
|
|
330
|
+
var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
|
|
331
|
+
var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
|
|
332
|
+
var __hasOwnProp$q = Object.prototype.hasOwnProperty;
|
|
333
|
+
var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
|
|
334
|
+
var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
335
|
+
var __spreadValues$q = (a, b) => {
|
|
332
336
|
for (var prop in b || (b = {}))
|
|
333
|
-
if (__hasOwnProp$
|
|
334
|
-
__defNormalProp$
|
|
335
|
-
if (__getOwnPropSymbols$
|
|
336
|
-
for (var prop of __getOwnPropSymbols$
|
|
337
|
-
if (__propIsEnum$
|
|
338
|
-
__defNormalProp$
|
|
337
|
+
if (__hasOwnProp$q.call(b, prop))
|
|
338
|
+
__defNormalProp$q(a, prop, b[prop]);
|
|
339
|
+
if (__getOwnPropSymbols$q)
|
|
340
|
+
for (var prop of __getOwnPropSymbols$q(b)) {
|
|
341
|
+
if (__propIsEnum$q.call(b, prop))
|
|
342
|
+
__defNormalProp$q(a, prop, b[prop]);
|
|
339
343
|
}
|
|
340
344
|
return a;
|
|
341
345
|
};
|
|
342
|
-
var __spreadProps$
|
|
346
|
+
var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
|
|
343
347
|
function adaptDescribable(describable, linkGenerator) {
|
|
344
348
|
return {
|
|
345
349
|
description: describableToRenderableContent(describable, linkGenerator)
|
|
@@ -391,7 +395,7 @@ function adaptDocumentable(documentable, linkGenerator, subHeadingLevel) {
|
|
|
391
395
|
function extractCustomTags(type) {
|
|
392
396
|
var _a2, _b2;
|
|
393
397
|
const baseTags = ["description", "group", "author", "date", "see", "example", "throws", "exception"];
|
|
394
|
-
return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.filter((currentAnnotation) => !baseTags.includes(currentAnnotation.name.toLowerCase())).map((currentAnnotation) => __spreadProps$
|
|
398
|
+
return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.filter((currentAnnotation) => !baseTags.includes(currentAnnotation.name.toLowerCase())).map((currentAnnotation) => __spreadProps$p(__spreadValues$q({}, adaptDescribable(currentAnnotation.bodyLines, linkGenerator)), {
|
|
395
399
|
name: currentAnnotation.name
|
|
396
400
|
}))) != null ? _b2 : [];
|
|
397
401
|
}
|
|
@@ -405,7 +409,7 @@ function adaptDocumentable(documentable, linkGenerator, subHeadingLevel) {
|
|
|
405
409
|
var _a2, _b2;
|
|
406
410
|
return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.filter((currentAnnotation) => currentAnnotation.name.toLowerCase() === "see").map((currentAnnotation) => currentAnnotation.body)) != null ? _b2 : [];
|
|
407
411
|
}
|
|
408
|
-
return __spreadProps$
|
|
412
|
+
return __spreadProps$p(__spreadValues$q({}, adaptDescribable((_a = documentable.docComment) == null ? void 0 : _a.descriptionLines, linkGenerator)), {
|
|
409
413
|
annotations: documentable.annotations.map((annotation) => annotation.type.toUpperCase()),
|
|
410
414
|
customTags: extractCustomTags(documentable),
|
|
411
415
|
example: {
|
|
@@ -420,25 +424,25 @@ function adaptDocumentable(documentable, linkGenerator, subHeadingLevel) {
|
|
|
420
424
|
});
|
|
421
425
|
}
|
|
422
426
|
|
|
423
|
-
var __defProp$
|
|
424
|
-
var __defProps$
|
|
425
|
-
var __getOwnPropDescs$
|
|
426
|
-
var __getOwnPropSymbols$
|
|
427
|
-
var __hasOwnProp$
|
|
428
|
-
var __propIsEnum$
|
|
429
|
-
var __defNormalProp$
|
|
430
|
-
var __spreadValues$
|
|
427
|
+
var __defProp$p = Object.defineProperty;
|
|
428
|
+
var __defProps$o = Object.defineProperties;
|
|
429
|
+
var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
|
|
430
|
+
var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
|
|
431
|
+
var __hasOwnProp$p = Object.prototype.hasOwnProperty;
|
|
432
|
+
var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
|
|
433
|
+
var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
434
|
+
var __spreadValues$p = (a, b) => {
|
|
431
435
|
for (var prop in b || (b = {}))
|
|
432
|
-
if (__hasOwnProp$
|
|
433
|
-
__defNormalProp$
|
|
434
|
-
if (__getOwnPropSymbols$
|
|
435
|
-
for (var prop of __getOwnPropSymbols$
|
|
436
|
-
if (__propIsEnum$
|
|
437
|
-
__defNormalProp$
|
|
436
|
+
if (__hasOwnProp$p.call(b, prop))
|
|
437
|
+
__defNormalProp$p(a, prop, b[prop]);
|
|
438
|
+
if (__getOwnPropSymbols$p)
|
|
439
|
+
for (var prop of __getOwnPropSymbols$p(b)) {
|
|
440
|
+
if (__propIsEnum$p.call(b, prop))
|
|
441
|
+
__defNormalProp$p(a, prop, b[prop]);
|
|
438
442
|
}
|
|
439
443
|
return a;
|
|
440
444
|
};
|
|
441
|
-
var __spreadProps$
|
|
445
|
+
var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
|
|
442
446
|
function adaptMethod(method, linkGenerator, baseHeadingLevel, translations) {
|
|
443
447
|
var _a, _b, _c;
|
|
444
448
|
function buildTitle(method2) {
|
|
@@ -468,7 +472,7 @@ function adaptMethod(method, linkGenerator, baseHeadingLevel, translations) {
|
|
|
468
472
|
returnType: {
|
|
469
473
|
headingLevel: baseHeadingLevel + 1,
|
|
470
474
|
heading: translations.markdown.details.returnType,
|
|
471
|
-
value: __spreadProps$
|
|
475
|
+
value: __spreadProps$o(__spreadValues$p({}, adaptDescribable((_b = (_a = method.docComment) == null ? void 0 : _a.returnAnnotation) == null ? void 0 : _b.bodyLines, linkGenerator)), {
|
|
472
476
|
type: linkGenerator(method.typeReference.rawDeclaration)
|
|
473
477
|
})
|
|
474
478
|
},
|
|
@@ -527,13 +531,13 @@ function mapParameters(documentable, param, linkGenerator) {
|
|
|
527
531
|
const paramAnnotation = (_a = documentable.docComment) == null ? void 0 : _a.paramAnnotations.find(
|
|
528
532
|
(pa) => pa.paramName.toLowerCase() === param.name.toLowerCase()
|
|
529
533
|
);
|
|
530
|
-
return __spreadProps$
|
|
534
|
+
return __spreadProps$o(__spreadValues$p({}, adaptDescribable(paramAnnotation == null ? void 0 : paramAnnotation.bodyLines, linkGenerator)), {
|
|
531
535
|
name: param.name,
|
|
532
536
|
type: linkGenerator(param.typeReference.rawDeclaration)
|
|
533
537
|
});
|
|
534
538
|
}
|
|
535
539
|
function mapThrows(thrown, linkGenerator) {
|
|
536
|
-
return __spreadProps$
|
|
540
|
+
return __spreadProps$o(__spreadValues$p({}, adaptDescribable(thrown.bodyLines, linkGenerator)), {
|
|
537
541
|
type: linkGenerator(thrown.exceptionName)
|
|
538
542
|
});
|
|
539
543
|
}
|
|
@@ -626,25 +630,25 @@ ${yamlString}---
|
|
|
626
630
|
`;
|
|
627
631
|
}
|
|
628
632
|
|
|
629
|
-
var __defProp$
|
|
630
|
-
var __defProps$
|
|
631
|
-
var __getOwnPropDescs$
|
|
632
|
-
var __getOwnPropSymbols$
|
|
633
|
-
var __hasOwnProp$
|
|
634
|
-
var __propIsEnum$
|
|
635
|
-
var __defNormalProp$
|
|
636
|
-
var __spreadValues$
|
|
633
|
+
var __defProp$o = Object.defineProperty;
|
|
634
|
+
var __defProps$n = Object.defineProperties;
|
|
635
|
+
var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
|
|
636
|
+
var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
|
|
637
|
+
var __hasOwnProp$o = Object.prototype.hasOwnProperty;
|
|
638
|
+
var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
|
|
639
|
+
var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
640
|
+
var __spreadValues$o = (a, b) => {
|
|
637
641
|
for (var prop in b || (b = {}))
|
|
638
|
-
if (__hasOwnProp$
|
|
639
|
-
__defNormalProp$
|
|
640
|
-
if (__getOwnPropSymbols$
|
|
641
|
-
for (var prop of __getOwnPropSymbols$
|
|
642
|
-
if (__propIsEnum$
|
|
643
|
-
__defNormalProp$
|
|
642
|
+
if (__hasOwnProp$o.call(b, prop))
|
|
643
|
+
__defNormalProp$o(a, prop, b[prop]);
|
|
644
|
+
if (__getOwnPropSymbols$o)
|
|
645
|
+
for (var prop of __getOwnPropSymbols$o(b)) {
|
|
646
|
+
if (__propIsEnum$o.call(b, prop))
|
|
647
|
+
__defNormalProp$o(a, prop, b[prop]);
|
|
644
648
|
}
|
|
645
649
|
return a;
|
|
646
650
|
};
|
|
647
|
-
var __spreadProps$
|
|
651
|
+
var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
|
|
648
652
|
function typeToRenderable$1(parsedFile, linkGenerator, config, translations) {
|
|
649
653
|
function getRenderable() {
|
|
650
654
|
const { type } = parsedFile;
|
|
@@ -663,7 +667,7 @@ function typeToRenderable$1(parsedFile, linkGenerator, config, translations) {
|
|
|
663
667
|
return lwcMetadataToRenderable(type, config, translations);
|
|
664
668
|
}
|
|
665
669
|
}
|
|
666
|
-
return __spreadProps$
|
|
670
|
+
return __spreadProps$n(__spreadValues$o({}, getRenderable()), {
|
|
667
671
|
filePath: isInSource(parsedFile.source) ? parsedFile.source.filePath : void 0,
|
|
668
672
|
namespace: config.namespace
|
|
669
673
|
});
|
|
@@ -688,7 +692,7 @@ function baseTypeAdapter(type, linkGenerator, baseHeadingLevel, translations) {
|
|
|
688
692
|
};
|
|
689
693
|
}
|
|
690
694
|
function enumTypeToEnumSource(enumType, linkGenerator, baseHeadingLevel = 1, translations) {
|
|
691
|
-
return __spreadProps$
|
|
695
|
+
return __spreadProps$n(__spreadValues$o({
|
|
692
696
|
type: "enum"
|
|
693
697
|
}, baseTypeAdapter(enumType, linkGenerator, baseHeadingLevel, translations)), {
|
|
694
698
|
values: {
|
|
@@ -696,7 +700,7 @@ function enumTypeToEnumSource(enumType, linkGenerator, baseHeadingLevel = 1, tra
|
|
|
696
700
|
heading: translations.markdown.sections.values,
|
|
697
701
|
value: enumType.values.map((value) => {
|
|
698
702
|
var _a;
|
|
699
|
-
return __spreadProps$
|
|
703
|
+
return __spreadProps$n(__spreadValues$o({}, adaptDescribable((_a = value.docComment) == null ? void 0 : _a.descriptionLines, linkGenerator)), {
|
|
700
704
|
value: value.name
|
|
701
705
|
});
|
|
702
706
|
})
|
|
@@ -704,7 +708,7 @@ function enumTypeToEnumSource(enumType, linkGenerator, baseHeadingLevel = 1, tra
|
|
|
704
708
|
});
|
|
705
709
|
}
|
|
706
710
|
function interfaceTypeToInterfaceSource(interfaceType, linkGenerator, baseHeadingLevel = 1, translations) {
|
|
707
|
-
return __spreadProps$
|
|
711
|
+
return __spreadProps$n(__spreadValues$o({
|
|
708
712
|
type: "interface"
|
|
709
713
|
}, baseTypeAdapter(interfaceType, linkGenerator, baseHeadingLevel, translations)), {
|
|
710
714
|
extends: interfaceType.extended_interfaces.map(linkGenerator),
|
|
@@ -718,7 +722,7 @@ function interfaceTypeToInterfaceSource(interfaceType, linkGenerator, baseHeadin
|
|
|
718
722
|
});
|
|
719
723
|
}
|
|
720
724
|
function classTypeToClassSource(classType, linkGenerator, baseHeadingLevel = 1, translations) {
|
|
721
|
-
return __spreadProps$
|
|
725
|
+
return __spreadProps$n(__spreadValues$o({
|
|
722
726
|
type: "class"
|
|
723
727
|
}, baseTypeAdapter(classType, linkGenerator, baseHeadingLevel, translations)), {
|
|
724
728
|
classModifier: classType.classModifier,
|
|
@@ -762,7 +766,7 @@ function classTypeToClassSource(classType, linkGenerator, baseHeadingLevel = 1,
|
|
|
762
766
|
heading: translations.markdown.sections.classes,
|
|
763
767
|
value: classType.classes.map(
|
|
764
768
|
(innerClass) => classTypeToClassSource(
|
|
765
|
-
__spreadProps$
|
|
769
|
+
__spreadProps$n(__spreadValues$o({}, innerClass), { inheritanceChain: [] }),
|
|
766
770
|
linkGenerator,
|
|
767
771
|
baseHeadingLevel + 2,
|
|
768
772
|
translations
|
|
@@ -1133,25 +1137,6 @@ function toMap(metadata) {
|
|
|
1133
1137
|
return map;
|
|
1134
1138
|
}
|
|
1135
1139
|
|
|
1136
|
-
var __defProp$o = Object.defineProperty;
|
|
1137
|
-
var __defProps$n = Object.defineProperties;
|
|
1138
|
-
var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
|
|
1139
|
-
var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
|
|
1140
|
-
var __hasOwnProp$o = Object.prototype.hasOwnProperty;
|
|
1141
|
-
var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
|
|
1142
|
-
var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1143
|
-
var __spreadValues$o = (a, b) => {
|
|
1144
|
-
for (var prop in b || (b = {}))
|
|
1145
|
-
if (__hasOwnProp$o.call(b, prop))
|
|
1146
|
-
__defNormalProp$o(a, prop, b[prop]);
|
|
1147
|
-
if (__getOwnPropSymbols$o)
|
|
1148
|
-
for (var prop of __getOwnPropSymbols$o(b)) {
|
|
1149
|
-
if (__propIsEnum$o.call(b, prop))
|
|
1150
|
-
__defNormalProp$o(a, prop, b[prop]);
|
|
1151
|
-
}
|
|
1152
|
-
return a;
|
|
1153
|
-
};
|
|
1154
|
-
var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
|
|
1155
1140
|
var __async$6 = (__this, __arguments, generator) => {
|
|
1156
1141
|
return new Promise((resolve, reject) => {
|
|
1157
1142
|
var fulfilled = (value) => {
|
|
@@ -1172,89 +1157,248 @@ var __async$6 = (__this, __arguments, generator) => {
|
|
|
1172
1157
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
1173
1158
|
});
|
|
1174
1159
|
};
|
|
1175
|
-
|
|
1176
|
-
|
|
1160
|
+
class WorkerPool {
|
|
1161
|
+
constructor(createWorker, options = {}) {
|
|
1162
|
+
this.nextTaskId = 1;
|
|
1163
|
+
this.terminating = false;
|
|
1164
|
+
this.idleWorkers = [];
|
|
1165
|
+
this.busyWorkers = /* @__PURE__ */ new Set();
|
|
1166
|
+
this.allWorkers = /* @__PURE__ */ new Set();
|
|
1167
|
+
this.queue = [];
|
|
1168
|
+
this.inFlightByWorker = /* @__PURE__ */ new Map();
|
|
1169
|
+
this.createdWorkers = 0;
|
|
1170
|
+
this.completedTasks = 0;
|
|
1171
|
+
this.failedTasks = 0;
|
|
1172
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1173
|
+
this.createWorker = createWorker;
|
|
1174
|
+
const cpuCount = Math.max(1, (_b = (_a = os.cpus()) == null ? void 0 : _a.length) != null ? _b : 1);
|
|
1175
|
+
this.maxWorkers = Math.max(1, (_c = options.maxWorkers) != null ? _c : cpuCount);
|
|
1176
|
+
this.maxQueueSize = (_d = options.maxQueueSize) != null ? _d : Number.POSITIVE_INFINITY;
|
|
1177
|
+
this.drainOnTerminate = (_e = options.drainOnTerminate) != null ? _e : false;
|
|
1178
|
+
this.unrefWorkers = (_f = options.unrefWorkers) != null ? _f : false;
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Enqueue a task and resolve with the worker's response `result`.
|
|
1182
|
+
*/
|
|
1183
|
+
run(payload) {
|
|
1184
|
+
if (this.terminating) {
|
|
1185
|
+
return Promise.reject(new Error("WorkerPool is terminating; cannot accept new tasks."));
|
|
1186
|
+
}
|
|
1187
|
+
if (this.queue.length >= this.maxQueueSize) {
|
|
1188
|
+
return Promise.reject(
|
|
1189
|
+
new Error(`WorkerPool queue limit exceeded (maxQueueSize=${this.maxQueueSize}).`)
|
|
1190
|
+
);
|
|
1191
|
+
}
|
|
1192
|
+
const id = this.nextTaskId++;
|
|
1177
1193
|
return new Promise((resolve, reject) => {
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
}
|
|
1194
|
+
this.queue.push({
|
|
1195
|
+
id,
|
|
1196
|
+
payload,
|
|
1197
|
+
resolve,
|
|
1198
|
+
reject
|
|
1199
|
+
});
|
|
1200
|
+
this.pump();
|
|
1186
1201
|
});
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
};
|
|
1193
|
-
const Ap = TE__namespace.getApplicativeTaskValidation(T__namespace.ApplyPar, semiGroupReflectionError);
|
|
1194
|
-
return _function.pipe(apexBundles, A__namespace.traverse(Ap)(reflectBundle$2));
|
|
1195
|
-
}
|
|
1196
|
-
function reflectBundle$2(apexBundle) {
|
|
1197
|
-
const convertToParsedFile = apply(toParsedFile$6, apexBundle.filePath);
|
|
1198
|
-
const withMetadata = apply(addMetadata, apexBundle.metadataContent);
|
|
1199
|
-
return _function.pipe(apexBundle, reflectAsTask$1, TE__namespace.map(convertToParsedFile), TE__namespace.flatMap(withMetadata));
|
|
1200
|
-
}
|
|
1201
|
-
function reflectAsTask$1(apexBundle) {
|
|
1202
|
-
return TE__namespace.tryCatch(
|
|
1203
|
-
() => reflectAsync$2(apexBundle.content),
|
|
1204
|
-
(error) => new ReflectionErrors([new ReflectionError(apexBundle.filePath, error.message)])
|
|
1205
|
-
);
|
|
1206
|
-
}
|
|
1207
|
-
function toParsedFile$6(filePath, typeMirror) {
|
|
1208
|
-
return {
|
|
1209
|
-
source: {
|
|
1210
|
-
filePath,
|
|
1211
|
-
name: typeMirror.name,
|
|
1212
|
-
type: typeMirror.type_name
|
|
1213
|
-
},
|
|
1214
|
-
type: typeMirror
|
|
1215
|
-
};
|
|
1216
|
-
}
|
|
1217
|
-
function addMetadata(rawMetadataContent, parsedFile) {
|
|
1218
|
-
return TE__namespace.fromEither(
|
|
1219
|
-
_function.pipe(
|
|
1220
|
-
parsedFile.type,
|
|
1221
|
-
(type) => addFileMetadataToTypeAnnotation$1(type, rawMetadataContent),
|
|
1222
|
-
E__namespace.map((type) => __spreadProps$n(__spreadValues$o({}, parsedFile), { type })),
|
|
1223
|
-
E__namespace.mapLeft(
|
|
1224
|
-
(error) => errorToReflectionErrors$1(error, isInSource(parsedFile.source) ? parsedFile.source.filePath : "")
|
|
1225
|
-
)
|
|
1226
|
-
)
|
|
1227
|
-
);
|
|
1228
|
-
}
|
|
1229
|
-
function errorToReflectionErrors$1(error, filePath) {
|
|
1230
|
-
return new ReflectionErrors([new ReflectionError(filePath, error.message)]);
|
|
1231
|
-
}
|
|
1232
|
-
function addFileMetadataToTypeAnnotation$1(type, metadata) {
|
|
1233
|
-
const concatAnnotationToType = apply(concatAnnotations$1, type);
|
|
1234
|
-
return _function.pipe(
|
|
1235
|
-
O__namespace.fromNullable(metadata),
|
|
1236
|
-
O__namespace.map(concatAnnotationToType),
|
|
1237
|
-
O__namespace.getOrElse(() => E__namespace.right(type))
|
|
1238
|
-
);
|
|
1239
|
-
}
|
|
1240
|
-
function concatAnnotations$1(type, metadataInput) {
|
|
1241
|
-
return _function.pipe(
|
|
1242
|
-
metadataInput,
|
|
1243
|
-
parseApexMetadata,
|
|
1244
|
-
E__namespace.map((metadataMap) => __spreadProps$n(__spreadValues$o({}, type), {
|
|
1245
|
-
annotations: [...type.annotations, ...mapToAnnotations$1(metadataMap)]
|
|
1246
|
-
}))
|
|
1247
|
-
);
|
|
1248
|
-
}
|
|
1249
|
-
function mapToAnnotations$1(metadata) {
|
|
1250
|
-
return Array.from(metadata.entries()).map(([key, value]) => {
|
|
1251
|
-
const declaration = `${key}: ${value}`;
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Returns current pool stats.
|
|
1205
|
+
*/
|
|
1206
|
+
stats() {
|
|
1252
1207
|
return {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1208
|
+
maxWorkers: this.maxWorkers,
|
|
1209
|
+
activeWorkers: this.allWorkers.size,
|
|
1210
|
+
idleWorkers: this.idleWorkers.length,
|
|
1211
|
+
queuedTasks: this.queue.length,
|
|
1212
|
+
inFlightTasks: this.inFlightByWorker.size,
|
|
1213
|
+
createdWorkers: this.createdWorkers,
|
|
1214
|
+
completedTasks: this.completedTasks,
|
|
1215
|
+
failedTasks: this.failedTasks
|
|
1256
1216
|
};
|
|
1257
|
-
}
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Terminates all workers and rejects queued tasks (unless drainOnTerminate=true).
|
|
1220
|
+
*
|
|
1221
|
+
* - If `drainOnTerminate` is false (default), queued tasks are rejected immediately,
|
|
1222
|
+
* and in-flight tasks are rejected when each worker is terminated.
|
|
1223
|
+
* - If `drainOnTerminate` is true, the pool stops accepting new tasks and will attempt
|
|
1224
|
+
* to finish queued + in-flight tasks before terminating workers.
|
|
1225
|
+
*/
|
|
1226
|
+
terminate() {
|
|
1227
|
+
return __async$6(this, null, function* () {
|
|
1228
|
+
if (this.terminating) {
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
this.terminating = true;
|
|
1232
|
+
if (!this.drainOnTerminate) {
|
|
1233
|
+
while (this.queue.length) {
|
|
1234
|
+
const task = this.queue.shift();
|
|
1235
|
+
task.reject(new Error("WorkerPool terminated before task could start."));
|
|
1236
|
+
this.failedTasks++;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
if (this.drainOnTerminate) {
|
|
1240
|
+
yield this.waitForDrain();
|
|
1241
|
+
}
|
|
1242
|
+
const terminations = Array.from(this.allWorkers).map((w) => __async$6(this, null, function* () {
|
|
1243
|
+
this.rejectInFlight(w, new Error("WorkerPool terminated with task still in flight."));
|
|
1244
|
+
try {
|
|
1245
|
+
yield w.terminate();
|
|
1246
|
+
} catch (e) {
|
|
1247
|
+
}
|
|
1248
|
+
}));
|
|
1249
|
+
yield Promise.all(terminations);
|
|
1250
|
+
this.idleWorkers.length = 0;
|
|
1251
|
+
this.busyWorkers.clear();
|
|
1252
|
+
this.allWorkers.clear();
|
|
1253
|
+
this.inFlightByWorker.clear();
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
/**
|
|
1257
|
+
* Wait until all queued tasks have been processed and no tasks are in flight.
|
|
1258
|
+
* This does NOT terminate workers.
|
|
1259
|
+
*/
|
|
1260
|
+
drain() {
|
|
1261
|
+
return __async$6(this, null, function* () {
|
|
1262
|
+
yield this.waitForDrain();
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
pump() {
|
|
1266
|
+
if (this.terminating && !this.drainOnTerminate) {
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
while (this.queue.length > 0) {
|
|
1270
|
+
const worker = this.getIdleOrCreateWorker();
|
|
1271
|
+
if (!worker) {
|
|
1272
|
+
return;
|
|
1273
|
+
}
|
|
1274
|
+
const task = this.queue.shift();
|
|
1275
|
+
this.assign(worker, task);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
getIdleOrCreateWorker() {
|
|
1279
|
+
const idle = this.idleWorkers.pop();
|
|
1280
|
+
if (idle) return idle;
|
|
1281
|
+
if (this.allWorkers.size < this.maxWorkers) {
|
|
1282
|
+
const w = this.spawnWorker();
|
|
1283
|
+
return w;
|
|
1284
|
+
}
|
|
1285
|
+
return null;
|
|
1286
|
+
}
|
|
1287
|
+
spawnWorker() {
|
|
1288
|
+
const worker = this.createWorker();
|
|
1289
|
+
this.createdWorkers++;
|
|
1290
|
+
this.allWorkers.add(worker);
|
|
1291
|
+
if (this.unrefWorkers) {
|
|
1292
|
+
worker.unref();
|
|
1293
|
+
}
|
|
1294
|
+
worker.on("message", (msg) => this.onWorkerMessage(worker, msg));
|
|
1295
|
+
worker.on("error", (err) => this.onWorkerError(worker, err));
|
|
1296
|
+
worker.on("exit", (code) => this.onWorkerExit(worker, code));
|
|
1297
|
+
this.idleWorkers.push(worker);
|
|
1298
|
+
return worker;
|
|
1299
|
+
}
|
|
1300
|
+
assign(worker, task) {
|
|
1301
|
+
this.idleWorkersRemove(worker);
|
|
1302
|
+
this.busyWorkers.add(worker);
|
|
1303
|
+
this.inFlightByWorker.set(worker, {
|
|
1304
|
+
id: task.id,
|
|
1305
|
+
resolve: task.resolve,
|
|
1306
|
+
reject: task.reject
|
|
1307
|
+
});
|
|
1308
|
+
try {
|
|
1309
|
+
worker.postMessage({ id: task.id, payload: task.payload });
|
|
1310
|
+
} catch (e) {
|
|
1311
|
+
this.inFlightByWorker.delete(worker);
|
|
1312
|
+
this.busyWorkers.delete(worker);
|
|
1313
|
+
this.idleWorkers.push(worker);
|
|
1314
|
+
task.reject(e);
|
|
1315
|
+
this.failedTasks++;
|
|
1316
|
+
this.pump();
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
onWorkerMessage(worker, msg) {
|
|
1320
|
+
var _a;
|
|
1321
|
+
const inFlight = this.inFlightByWorker.get(worker);
|
|
1322
|
+
if (!inFlight) {
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
const m = msg;
|
|
1326
|
+
const sameId = typeof (m == null ? void 0 : m.id) === "number" && m.id === inFlight.id;
|
|
1327
|
+
const okFlag = typeof (m == null ? void 0 : m.ok) === "boolean";
|
|
1328
|
+
if (!sameId || !okFlag) {
|
|
1329
|
+
this.finishTask(worker);
|
|
1330
|
+
inFlight.reject(
|
|
1331
|
+
new Error("WorkerPool received an invalid response message for the in-flight task.")
|
|
1332
|
+
);
|
|
1333
|
+
this.failedTasks++;
|
|
1334
|
+
this.pump();
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
1337
|
+
this.finishTask(worker);
|
|
1338
|
+
if (m.ok) {
|
|
1339
|
+
this.completedTasks++;
|
|
1340
|
+
inFlight.resolve(m.result);
|
|
1341
|
+
} else {
|
|
1342
|
+
this.failedTasks++;
|
|
1343
|
+
inFlight.reject((_a = m.error) != null ? _a : new Error("Worker indicated failure without an error payload."));
|
|
1344
|
+
}
|
|
1345
|
+
this.pump();
|
|
1346
|
+
}
|
|
1347
|
+
onWorkerError(worker, err) {
|
|
1348
|
+
this.rejectInFlight(worker, err);
|
|
1349
|
+
this.removeWorker(worker);
|
|
1350
|
+
this.pump();
|
|
1351
|
+
}
|
|
1352
|
+
onWorkerExit(worker, code) {
|
|
1353
|
+
this.rejectInFlight(worker, new Error(`Worker exited unexpectedly (code=${code}).`));
|
|
1354
|
+
this.removeWorker(worker);
|
|
1355
|
+
this.pump();
|
|
1356
|
+
}
|
|
1357
|
+
finishTask(worker) {
|
|
1358
|
+
this.inFlightByWorker.delete(worker);
|
|
1359
|
+
this.busyWorkers.delete(worker);
|
|
1360
|
+
if (!this.terminating || this.drainOnTerminate) {
|
|
1361
|
+
this.idleWorkers.push(worker);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
rejectInFlight(worker, reason) {
|
|
1365
|
+
const inFlight = this.inFlightByWorker.get(worker);
|
|
1366
|
+
if (!inFlight) return;
|
|
1367
|
+
this.inFlightByWorker.delete(worker);
|
|
1368
|
+
this.busyWorkers.delete(worker);
|
|
1369
|
+
inFlight.reject(reason);
|
|
1370
|
+
this.failedTasks++;
|
|
1371
|
+
}
|
|
1372
|
+
removeWorker(worker) {
|
|
1373
|
+
this.inFlightByWorker.delete(worker);
|
|
1374
|
+
this.busyWorkers.delete(worker);
|
|
1375
|
+
this.idleWorkersRemove(worker);
|
|
1376
|
+
this.allWorkers.delete(worker);
|
|
1377
|
+
}
|
|
1378
|
+
idleWorkersRemove(worker) {
|
|
1379
|
+
const idx = this.idleWorkers.indexOf(worker);
|
|
1380
|
+
if (idx !== -1) {
|
|
1381
|
+
this.idleWorkers.splice(idx, 1);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
waitForDrain() {
|
|
1385
|
+
return __async$6(this, null, function* () {
|
|
1386
|
+
if (this.queue.length === 0 && this.inFlightByWorker.size === 0) {
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
yield new Promise((resolve) => {
|
|
1390
|
+
const tick = () => {
|
|
1391
|
+
this.pump();
|
|
1392
|
+
if (this.queue.length === 0 && this.inFlightByWorker.size === 0) {
|
|
1393
|
+
resolve();
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
setTimeout(tick, 10);
|
|
1397
|
+
};
|
|
1398
|
+
tick();
|
|
1399
|
+
});
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1258
1402
|
}
|
|
1259
1403
|
|
|
1260
1404
|
var __defProp$n = Object.defineProperty;
|
|
@@ -1310,51 +1454,109 @@ function reflectAsync$1(rawSource) {
|
|
|
1310
1454
|
});
|
|
1311
1455
|
});
|
|
1312
1456
|
}
|
|
1313
|
-
function
|
|
1457
|
+
function supportsWorkerThreads() {
|
|
1458
|
+
try {
|
|
1459
|
+
return typeof node_worker_threads.Worker === "function";
|
|
1460
|
+
} catch (e) {
|
|
1461
|
+
return false;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
function isWorkerReflectionEnabled(config) {
|
|
1465
|
+
var _a, _b;
|
|
1466
|
+
const env = ((_a = process.env.APEXDOCS_WORKER_REFLECTION) != null ? _a : "").toLowerCase();
|
|
1467
|
+
if (env === "true" || env === "1") return true;
|
|
1468
|
+
if (env === "false" || env === "0") return false;
|
|
1469
|
+
return (_b = config == null ? void 0 : config.parallelReflection) != null ? _b : true;
|
|
1470
|
+
}
|
|
1471
|
+
function getWorkerEntrypointPath() {
|
|
1472
|
+
const candidate1 = path$1.resolve(__dirname, "./apex-reflection.worker.js");
|
|
1473
|
+
if (fs.existsSync(candidate1)) {
|
|
1474
|
+
return candidate1;
|
|
1475
|
+
}
|
|
1476
|
+
const candidate1b = path$1.resolve(__dirname, "../apex-reflection.worker.js");
|
|
1477
|
+
if (fs.existsSync(candidate1b)) {
|
|
1478
|
+
return candidate1b;
|
|
1479
|
+
}
|
|
1480
|
+
let dir = __dirname;
|
|
1481
|
+
for (let i = 0; i < 10; i++) {
|
|
1482
|
+
const maybeDist1 = path$1.resolve(dir, "../../..");
|
|
1483
|
+
const candidate2a = path$1.resolve(maybeDist1, "core", "reflection", "apex", "apex-reflection.worker.js");
|
|
1484
|
+
if (fs.existsSync(candidate2a)) {
|
|
1485
|
+
return candidate2a;
|
|
1486
|
+
}
|
|
1487
|
+
const maybeDist2 = path$1.resolve(dir, "../../../..");
|
|
1488
|
+
const candidate2b = path$1.resolve(maybeDist2, "core", "reflection", "apex", "apex-reflection.worker.js");
|
|
1489
|
+
if (fs.existsSync(candidate2b)) {
|
|
1490
|
+
return candidate2b;
|
|
1491
|
+
}
|
|
1492
|
+
const parent = path$1.dirname(dir);
|
|
1493
|
+
if (parent === dir) break;
|
|
1494
|
+
dir = parent;
|
|
1495
|
+
}
|
|
1496
|
+
return candidate1;
|
|
1497
|
+
}
|
|
1498
|
+
function reflectAsTaskParallel(apexBundles, config) {
|
|
1314
1499
|
return TE__namespace.tryCatch(
|
|
1315
1500
|
() => __async$5(null, null, function* () {
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
const
|
|
1320
|
-
const
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1501
|
+
var _a, _b, _c;
|
|
1502
|
+
const cpu = (_b = (_a = os.cpus()) == null ? void 0 : _a.length) != null ? _b : 1;
|
|
1503
|
+
const defaultMax = Math.max(1, Math.min(cpu, 8));
|
|
1504
|
+
const maxWorkers = Math.max(1, (_c = config == null ? void 0 : config.parallelReflectionMaxWorkers) != null ? _c : defaultMax);
|
|
1505
|
+
const pool = new WorkerPool(() => new node_worker_threads.Worker(getWorkerEntrypointPath()), {
|
|
1506
|
+
maxWorkers
|
|
1507
|
+
// Keep default queue size (Infinity) unless we later decide to bound it via config.
|
|
1508
|
+
});
|
|
1509
|
+
try {
|
|
1510
|
+
const results = yield Promise.all(
|
|
1511
|
+
apexBundles.map((bundle) => __async$5(null, null, function* () {
|
|
1512
|
+
const typeMirror = yield pool.run({ content: bundle.content });
|
|
1513
|
+
return typeMirror;
|
|
1514
|
+
}))
|
|
1515
|
+
);
|
|
1516
|
+
return results;
|
|
1517
|
+
} finally {
|
|
1518
|
+
yield pool.terminate();
|
|
1331
1519
|
}
|
|
1332
|
-
return parsedFiles;
|
|
1333
1520
|
}),
|
|
1334
1521
|
(error) => {
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
}
|
|
1338
|
-
return new ReflectionErrors([new ReflectionError("", error.message)]);
|
|
1522
|
+
const message = error == null ? void 0 : error.message;
|
|
1523
|
+
return new ReflectionErrors([new ReflectionError("", typeof message === "string" ? message : "Worker failure")]);
|
|
1339
1524
|
}
|
|
1340
1525
|
);
|
|
1341
1526
|
}
|
|
1342
|
-
function
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
)
|
|
1356
|
-
|
|
1357
|
-
|
|
1527
|
+
function reflectApexSource(apexBundles, config) {
|
|
1528
|
+
const semiGroupReflectionError = {
|
|
1529
|
+
concat: (x, y) => new ReflectionErrors([...x.errors, ...y.errors])
|
|
1530
|
+
};
|
|
1531
|
+
const Ap = TE__namespace.getApplicativeTaskValidation(T__namespace.ApplyPar, semiGroupReflectionError);
|
|
1532
|
+
if (!isWorkerReflectionEnabled(config) || !supportsWorkerThreads()) {
|
|
1533
|
+
return _function.pipe(apexBundles, A__namespace.traverse(Ap)(reflectBundle$2));
|
|
1534
|
+
}
|
|
1535
|
+
return _function.pipe(
|
|
1536
|
+
reflectAsTaskParallel(apexBundles, config),
|
|
1537
|
+
TE__namespace.map((typeMirrors) => typeMirrors.map((t, idx) => ({ t, idx }))),
|
|
1538
|
+
TE__namespace.mapLeft((errs) => errs),
|
|
1539
|
+
TE__namespace.flatMap((pairs) => {
|
|
1540
|
+
const parsedTasks = pairs.map(({ t, idx }) => {
|
|
1541
|
+
const bundle = apexBundles[idx];
|
|
1542
|
+
const convertToParsedFile = apply(toParsedFile$5, bundle.filePath);
|
|
1543
|
+
const withMetadata = apply(addMetadata, bundle.metadataContent);
|
|
1544
|
+
return _function.pipe(TE__namespace.right(t), TE__namespace.map(convertToParsedFile), TE__namespace.flatMap(withMetadata));
|
|
1545
|
+
});
|
|
1546
|
+
return _function.pipe(parsedTasks, A__namespace.sequence(Ap));
|
|
1547
|
+
})
|
|
1548
|
+
);
|
|
1549
|
+
}
|
|
1550
|
+
function reflectBundle$2(apexBundle) {
|
|
1551
|
+
const convertToParsedFile = apply(toParsedFile$5, apexBundle.filePath);
|
|
1552
|
+
const withMetadata = apply(addMetadata, apexBundle.metadataContent);
|
|
1553
|
+
return _function.pipe(apexBundle, reflectAsTask$1, TE__namespace.map(convertToParsedFile), TE__namespace.flatMap(withMetadata));
|
|
1554
|
+
}
|
|
1555
|
+
function reflectAsTask$1(apexBundle) {
|
|
1556
|
+
return TE__namespace.tryCatch(
|
|
1557
|
+
() => reflectAsync$1(apexBundle.content),
|
|
1558
|
+
(error) => new ReflectionErrors([new ReflectionError(apexBundle.filePath, error.message)])
|
|
1559
|
+
);
|
|
1358
1560
|
}
|
|
1359
1561
|
function toParsedFile$5(filePath, typeMirror) {
|
|
1360
1562
|
return {
|
|
@@ -1366,17 +1568,17 @@ function toParsedFile$5(filePath, typeMirror) {
|
|
|
1366
1568
|
type: typeMirror
|
|
1367
1569
|
};
|
|
1368
1570
|
}
|
|
1369
|
-
function
|
|
1370
|
-
return
|
|
1371
|
-
|
|
1571
|
+
function addMetadata(rawMetadataContent, parsedFile) {
|
|
1572
|
+
return TE__namespace.fromEither(
|
|
1573
|
+
_function.pipe(
|
|
1372
1574
|
parsedFile.type,
|
|
1373
1575
|
(type) => addFileMetadataToTypeAnnotation(type, rawMetadataContent),
|
|
1374
1576
|
E__namespace.map((type) => __spreadProps$m(__spreadValues$n({}, parsedFile), { type })),
|
|
1375
1577
|
E__namespace.mapLeft(
|
|
1376
1578
|
(error) => errorToReflectionErrors(error, isInSource(parsedFile.source) ? parsedFile.source.filePath : "")
|
|
1377
1579
|
)
|
|
1378
|
-
)
|
|
1379
|
-
|
|
1580
|
+
)
|
|
1581
|
+
);
|
|
1380
1582
|
}
|
|
1381
1583
|
function errorToReflectionErrors(error, filePath) {
|
|
1382
1584
|
return new ReflectionErrors([new ReflectionError(filePath, error.message)]);
|
|
@@ -2006,7 +2208,10 @@ const markdownDefaults = __spreadProps$j(__spreadValues$k({}, markdownAndChangel
|
|
|
2006
2208
|
includeFieldSecurityMetadata: false,
|
|
2007
2209
|
includeInlineHelpTextMetadata: false,
|
|
2008
2210
|
experimentalLwcSupport: false,
|
|
2009
|
-
|
|
2211
|
+
// Performance: parallel reflection via worker threads (enabled by default).
|
|
2212
|
+
parallelReflection: true,
|
|
2213
|
+
// Default is computed at runtime if not provided.
|
|
2214
|
+
parallelReflectionMaxWorkers: void 0
|
|
2010
2215
|
});
|
|
2011
2216
|
const openApiDefaults = __spreadProps$j(__spreadValues$k({}, commonDefaults), {
|
|
2012
2217
|
fileName: "openapi",
|
|
@@ -3426,10 +3631,12 @@ function replaceMacros(unparsedBundles, macros) {
|
|
|
3426
3631
|
function generateForApex(apexBundles, config) {
|
|
3427
3632
|
const filterOutOfScope = apply(filterScope, config.scope);
|
|
3428
3633
|
const removeExcluded = apply(removeExcludedTags, config.excludeTags);
|
|
3429
|
-
const reflectFn = config.useParallelProcessing ? reflectApexSourceParallel : reflectApexSource;
|
|
3430
3634
|
return _function.pipe(
|
|
3431
3635
|
apexBundles,
|
|
3432
|
-
|
|
3636
|
+
(bundles) => reflectApexSource(bundles, {
|
|
3637
|
+
parallelReflection: config.parallelReflection,
|
|
3638
|
+
parallelReflectionMaxWorkers: config.parallelReflectionMaxWorkers
|
|
3639
|
+
}),
|
|
3433
3640
|
TE__namespace.map(filterOutOfScope),
|
|
3434
3641
|
TE__namespace.map(addInheritedMembersToTypes),
|
|
3435
3642
|
TE__namespace.map(addInheritanceChainToTypes),
|
|
@@ -5251,6 +5458,9 @@ var __async$1 = (__this, __arguments, generator) => {
|
|
|
5251
5458
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
5252
5459
|
});
|
|
5253
5460
|
};
|
|
5461
|
+
const changelogReflectionConfig = {
|
|
5462
|
+
parallelReflection: false
|
|
5463
|
+
};
|
|
5254
5464
|
function generateChangeLog(oldBundles, newBundles, config) {
|
|
5255
5465
|
const convertToPageData = apply(toPageData, config.fileName);
|
|
5256
5466
|
function handleConversion({ changelog, newManifest }) {
|
|
@@ -5281,7 +5491,7 @@ function generateChangeLog(oldBundles, newBundles, config) {
|
|
|
5281
5491
|
function reflect(bundles, config) {
|
|
5282
5492
|
const filterOutOfScopeApex = apply(filterScope, config.scope);
|
|
5283
5493
|
function reflectApexFiles(sourceFiles) {
|
|
5284
|
-
return _function.pipe(reflectApexSource(sourceFiles), TE__namespace.map(filterOutOfScopeApex));
|
|
5494
|
+
return _function.pipe(reflectApexSource(sourceFiles, changelogReflectionConfig), TE__namespace.map(filterOutOfScopeApex));
|
|
5285
5495
|
}
|
|
5286
5496
|
return _function.pipe(
|
|
5287
5497
|
// Filter out LWC. These will be implemented at a later date
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cparra/apexdocs",
|
|
3
|
-
"version": "3.17.0-beta.
|
|
3
|
+
"version": "3.17.0-beta.3",
|
|
4
4
|
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apex",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"output": []
|
|
37
37
|
},
|
|
38
38
|
"build": {
|
|
39
|
-
"command": "tsc --noEmit --pretty && pkgroll",
|
|
39
|
+
"command": "tsc --noEmit --pretty && pkgroll --target node18 && node -e \"const fs=require('fs'); const path=require('path'); const src=path.join(__dirname,'src','core','reflection','apex','apex-reflection.worker.ts'); const distRoot=path.join(__dirname,'dist'); const candidates=[]; (function walk(dir){ for (const ent of fs.readdirSync(dir,{withFileTypes:true})) { const p=path.join(dir,ent.name); if (ent.isDirectory()) walk(p); else if (ent.isFile() && ent.name==='generate.js') candidates.push(p); } })(distRoot); if (!candidates.length) throw new Error('Could not locate dist bundle to determine worker output location'); const distEntry=candidates[0]; const destDir=path.join(path.dirname(distEntry),'..','core','reflection','apex'); fs.mkdirSync(destDir,{recursive:true}); const out=path.join(destDir,'apex-reflection.worker.js'); const ts=require('typescript'); const input=fs.readFileSync(src,'utf8'); const res=ts.transpileModule(input,{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2018,esModuleInterop:true}}); fs.writeFileSync(out,res.outputText,'utf8'); if (!fs.existsSync(out)) throw new Error('Failed to write worker entrypoint');\"",
|
|
40
40
|
"dependencies": [
|
|
41
41
|
"lint"
|
|
42
42
|
],
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
]
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@cparra/apex-reflection": "2.
|
|
95
|
+
"@cparra/apex-reflection": "2.21.1",
|
|
96
96
|
"@salesforce/source-deploy-retrieve": "^12.20.1",
|
|
97
97
|
"@types/js-yaml": "^4.0.9",
|
|
98
98
|
"@types/yargs": "^17.0.32",
|