@skmtc/core 0.49.1 → 0.50.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/esm/context/CoreContext.js +80 -3
- package/esm/context/GenerateContext.d.ts +6 -1
- package/esm/context/GenerateContext.js +149 -81
- package/esm/context/LogLinesHandler.d.ts +1 -1
- package/esm/context/LogLinesHandler.js +3 -0
- package/esm/context/ParseContext.d.ts +3 -0
- package/esm/context/ParseContext.js +36 -14
- package/esm/helpers/toCountPhrase.d.ts +11 -0
- package/esm/helpers/toCountPhrase.js +11 -0
- package/esm/types/LogLine.d.ts +40 -1
- package/esm/types/LogLine.js +25 -0
- package/package.json +1 -1
- package/script/context/CoreContext.js +80 -3
- package/script/context/GenerateContext.d.ts +6 -1
- package/script/context/GenerateContext.js +149 -81
- package/script/context/LogLinesHandler.d.ts +1 -1
- package/script/context/LogLinesHandler.js +3 -0
- package/script/context/ParseContext.d.ts +3 -0
- package/script/context/ParseContext.js +36 -14
- package/script/helpers/toCountPhrase.d.ts +11 -0
- package/script/helpers/toCountPhrase.js +15 -0
- package/script/types/LogLine.d.ts +40 -1
- package/script/types/LogLine.js +27 -1
package/esm/types/LogLine.d.ts
CHANGED
|
@@ -13,15 +13,48 @@ import { type SerializedError } from './SerializedError.js';
|
|
|
13
13
|
export type LogLineLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
|
|
14
14
|
/** Valibot schema for {@link LogLineLevel}. */
|
|
15
15
|
export declare const logLineLevel: v.PicklistSchema<["DEBUG", "INFO", "WARN", "ERROR"], undefined>;
|
|
16
|
+
/** The fields of the parse issue a {@link LogLine} reports. */
|
|
17
|
+
export type LogLineIssue = {
|
|
18
|
+
/**
|
|
19
|
+
* The issue's type. A string, not the closed list of types: a reader on
|
|
20
|
+
* an older core must still read a line with a type added since.
|
|
21
|
+
*/
|
|
22
|
+
type: string;
|
|
23
|
+
level: 'error' | 'warning' | 'debug';
|
|
24
|
+
/** The issue's `location`, as `manifest.parseIssues` has it. */
|
|
25
|
+
location: string;
|
|
26
|
+
/** The object around the issue, as JSON. */
|
|
27
|
+
parent?: string;
|
|
28
|
+
};
|
|
29
|
+
/** Valibot schema for {@link LogLineIssue}. */
|
|
30
|
+
export declare const logLineIssue: v.ObjectSchema<{
|
|
31
|
+
readonly type: v.StringSchema<undefined>;
|
|
32
|
+
readonly level: v.PicklistSchema<["error", "warning", "debug"], undefined>;
|
|
33
|
+
readonly location: v.StringSchema<undefined>;
|
|
34
|
+
readonly parent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
35
|
+
}, undefined>;
|
|
36
|
+
/**
|
|
37
|
+
* A log argument that gives its line an `issue` field. Parse logs one with
|
|
38
|
+
* each issue it records.
|
|
39
|
+
*/
|
|
40
|
+
export declare class LogLineIssueArg {
|
|
41
|
+
issue: LogLineIssue;
|
|
42
|
+
constructor(issue: LogLineIssue);
|
|
43
|
+
}
|
|
16
44
|
export type LogLine = {
|
|
17
45
|
/** Position of the line in the run, from 0. */
|
|
18
46
|
seq: number;
|
|
19
47
|
level: LogLineLevel;
|
|
20
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* The subject's stack trail, or the generator's on the line a generator
|
|
50
|
+
* logs after it ran. Absent outside a generator (parse, render).
|
|
51
|
+
*/
|
|
21
52
|
trail?: string;
|
|
22
53
|
message: string;
|
|
23
54
|
/** The first `Error` the line was logged with. */
|
|
24
55
|
error?: SerializedError;
|
|
56
|
+
/** The parse issue the line reports. */
|
|
57
|
+
issue?: LogLineIssue;
|
|
25
58
|
/** When the line was logged, in milliseconds since the epoch. */
|
|
26
59
|
time: number;
|
|
27
60
|
};
|
|
@@ -32,5 +65,11 @@ export declare const logLine: v.ObjectSchema<{
|
|
|
32
65
|
readonly trail: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
33
66
|
readonly message: v.StringSchema<undefined>;
|
|
34
67
|
readonly error: v.OptionalSchema<v.GenericSchema<SerializedError>, undefined>;
|
|
68
|
+
readonly issue: v.OptionalSchema<v.ObjectSchema<{
|
|
69
|
+
readonly type: v.StringSchema<undefined>;
|
|
70
|
+
readonly level: v.PicklistSchema<["error", "warning", "debug"], undefined>;
|
|
71
|
+
readonly location: v.StringSchema<undefined>;
|
|
72
|
+
readonly parent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
73
|
+
}, undefined>, undefined>;
|
|
35
74
|
readonly time: v.NumberSchema<undefined>;
|
|
36
75
|
}, undefined>;
|
package/esm/types/LogLine.js
CHANGED
|
@@ -13,6 +13,30 @@ import { serializedError } from './SerializedError.js';
|
|
|
13
13
|
export const logLineLevel = v.picklist(['DEBUG', 'INFO', 'WARN', 'ERROR']);
|
|
14
14
|
const _logLineLevelDriftCheck = logLineLevel;
|
|
15
15
|
void _logLineLevelDriftCheck;
|
|
16
|
+
/** Valibot schema for {@link LogLineIssue}. */
|
|
17
|
+
export const logLineIssue = v.object({
|
|
18
|
+
type: v.string(),
|
|
19
|
+
level: v.picklist(['error', 'warning', 'debug']),
|
|
20
|
+
location: v.string(),
|
|
21
|
+
parent: v.optional(v.string())
|
|
22
|
+
});
|
|
23
|
+
const _logLineIssueDriftCheck = logLineIssue;
|
|
24
|
+
void _logLineIssueDriftCheck;
|
|
25
|
+
/**
|
|
26
|
+
* A log argument that gives its line an `issue` field. Parse logs one with
|
|
27
|
+
* each issue it records.
|
|
28
|
+
*/
|
|
29
|
+
export class LogLineIssueArg {
|
|
30
|
+
constructor(issue) {
|
|
31
|
+
Object.defineProperty(this, "issue", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
this.issue = issue;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
16
40
|
/** Valibot schema for {@link LogLine}. */
|
|
17
41
|
export const logLine = v.object({
|
|
18
42
|
seq: v.number(),
|
|
@@ -20,6 +44,7 @@ export const logLine = v.object({
|
|
|
20
44
|
trail: v.optional(v.string()),
|
|
21
45
|
message: v.string(),
|
|
22
46
|
error: v.optional(serializedError),
|
|
47
|
+
issue: v.optional(logLineIssue),
|
|
23
48
|
time: v.number()
|
|
24
49
|
});
|
|
25
50
|
const _logLineDriftCheck = logLine;
|
package/package.json
CHANGED
|
@@ -43,7 +43,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
43
43
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
44
44
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
45
45
|
};
|
|
46
|
-
var _CoreContext_instances, _CoreContext_phase, _CoreContext_results, _CoreContext_logLines, _CoreContext_phaseName, _CoreContext_parseIssues, _CoreContext_enrichmentWarnings, _CoreContext_setupLogger, _CoreContext_toLogTrail, _CoreContext_closeFileHandlers, _CoreContext_toRunFailedIssue, _CoreContext_setupParsePhase, _CoreContext_setupGeneratePhase, _CoreContext_setupRenderPhase;
|
|
46
|
+
var _CoreContext_instances, _CoreContext_phase, _CoreContext_results, _CoreContext_logLines, _CoreContext_logsPhaseLines, _CoreContext_phaseName, _CoreContext_parseIssues, _CoreContext_enrichmentWarnings, _CoreContext_setupLogger, _CoreContext_toLogTrail, _CoreContext_logInfo, _CoreContext_logParseLine, _CoreContext_closeFileHandlers, _CoreContext_toRunFailedIssue, _CoreContext_setupParsePhase, _CoreContext_setupGeneratePhase, _CoreContext_setupRenderPhase;
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
48
|
exports.CoreContext = void 0;
|
|
49
49
|
exports.skmtcFormatter = skmtcFormatter;
|
|
@@ -53,6 +53,7 @@ const toInspection_js_1 = require("../run/toInspection.js");
|
|
|
53
53
|
const RenderContext_js_1 = require("./RenderContext.js");
|
|
54
54
|
const ParseContext_js_1 = require("./ParseContext.js");
|
|
55
55
|
const log = __importStar(require("../deps/jsr.io/@std/log/0.224.14/mod.js"));
|
|
56
|
+
const levels_js_1 = require("../deps/jsr.io/@std/log/0.224.14/levels.js");
|
|
56
57
|
const ResultsHandler_js_1 = require("./ResultsHandler.js");
|
|
57
58
|
const LogLinesHandler_js_1 = require("./LogLinesHandler.js");
|
|
58
59
|
const StackTrail_js_1 = require("./StackTrail.js");
|
|
@@ -61,6 +62,7 @@ const join_js_1 = require("../deps/jsr.io/@std/path/1.1.6/join.js");
|
|
|
61
62
|
const colors_js_1 = require("../deps/jsr.io/@std/fmt/1.0.10/colors.js");
|
|
62
63
|
const SerializedError_js_1 = require("../types/SerializedError.js");
|
|
63
64
|
const toGenerationFailure_js_1 = require("./toGenerationFailure.js");
|
|
65
|
+
const toCountPhrase_js_1 = require("../helpers/toCountPhrase.js");
|
|
64
66
|
/**
|
|
65
67
|
* The main orchestration class for the SKMTC transformation pipeline.
|
|
66
68
|
*
|
|
@@ -154,6 +156,12 @@ class CoreContext {
|
|
|
154
156
|
});
|
|
155
157
|
/** Keeps this run's log lines for `toArtifacts` to return. */
|
|
156
158
|
_CoreContext_logLines.set(this, void 0);
|
|
159
|
+
/**
|
|
160
|
+
* Whether the run logs its phase lines at INFO: when it is not silent and
|
|
161
|
+
* its `logLevel` keeps INFO lines. At the default `'WARN'` it logs none,
|
|
162
|
+
* so the console of a CLI run does not change.
|
|
163
|
+
*/
|
|
164
|
+
_CoreContext_logsPhaseLines.set(this, void 0);
|
|
157
165
|
/**
|
|
158
166
|
* The phase that is running. Set when a phase starts, before its
|
|
159
167
|
* context is set up, so a failure names the phase it happened in.
|
|
@@ -210,6 +218,7 @@ class CoreContext {
|
|
|
210
218
|
}), "f");
|
|
211
219
|
this.logger = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupLogger).call(this, { spanId, logsPath, logLines: __classPrivateFieldGet(this, _CoreContext_logLines, "f") });
|
|
212
220
|
this.silent = silent;
|
|
221
|
+
__classPrivateFieldSet(this, _CoreContext_logsPhaseLines, !silent && levels_js_1.LogLevels[logLevel] <= levels_js_1.LogLevels.INFO, "f");
|
|
213
222
|
}
|
|
214
223
|
/**
|
|
215
224
|
* The trail of the subject being generated, or `undefined` outside one
|
|
@@ -326,6 +335,7 @@ class CoreContext {
|
|
|
326
335
|
* @throws Will throw an error if any phase of the pipeline fails
|
|
327
336
|
*/
|
|
328
337
|
toArtifacts({ document, settings, toGeneratorConfigMap, stackTrail, attribution, inspect }) {
|
|
338
|
+
const runStartedAt = performance.now();
|
|
329
339
|
try {
|
|
330
340
|
// Parse phase: one unified ParseContext handles both protocols
|
|
331
341
|
// via its internal protocol-discriminated state. `parse()` returns
|
|
@@ -338,6 +348,7 @@ class CoreContext {
|
|
|
338
348
|
__classPrivateFieldSet(this, _CoreContext_phase, phase, "f");
|
|
339
349
|
__classPrivateFieldSet(this, _CoreContext_parseIssues, phase.context.issues, "f");
|
|
340
350
|
const parsedDocument = stackTrail.trace('parse', st => phase.context.parse(st));
|
|
351
|
+
__classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_logParseLine).call(this, parsedDocument, phase.context.issues, runStartedAt);
|
|
341
352
|
// The shared attribution capture channel: snippets constructed
|
|
342
353
|
// during generate hold the GenerateContext, whose `captureSink`
|
|
343
354
|
// reads this slot; RenderContext flips it around the one capturing
|
|
@@ -367,6 +378,7 @@ class CoreContext {
|
|
|
367
378
|
// map (folded into `RenderContext.render`). No separate pre-render
|
|
368
379
|
// post-pass, no re-render — the old `_rendered` cache that faked
|
|
369
380
|
// "render once" across two passes is gone.
|
|
381
|
+
const renderStartedAt = performance.now();
|
|
370
382
|
const renderOutput = stackTrail.trace('render', st => {
|
|
371
383
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'render', "f");
|
|
372
384
|
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupRenderPhase).call(this, {
|
|
@@ -378,6 +390,14 @@ class CoreContext {
|
|
|
378
390
|
}), "f");
|
|
379
391
|
return __classPrivateFieldGet(this, _CoreContext_phase, "f").context.render(st);
|
|
380
392
|
});
|
|
393
|
+
if (__classPrivateFieldGet(this, _CoreContext_logsPhaseLines, "f")) {
|
|
394
|
+
const fileCount = (0, toCountPhrase_js_1.toCountPhrase)(Object.keys(renderOutput.artifacts).length, 'file');
|
|
395
|
+
const byteCount = (0, toCountPhrase_js_1.toCountPhrase)(toByteCount(renderOutput.artifacts), 'byte');
|
|
396
|
+
this.logger.info(`render: ${fileCount}, ${byteCount}, ${toElapsedMs(renderStartedAt)} ms`);
|
|
397
|
+
this.logger.info(`toArtifacts: ${(0, toCountPhrase_js_1.toCountPhrase)(Object.keys(toGeneratorConfigMap()).length, 'generator')}, ` +
|
|
398
|
+
`${fileCount}, ${byteCount}, ${toIssueCounts(phase.context.issues)}, ` +
|
|
399
|
+
`${toElapsedMs(runStartedAt)} ms`);
|
|
400
|
+
}
|
|
381
401
|
return {
|
|
382
402
|
...renderOutput,
|
|
383
403
|
results: __classPrivateFieldGet(this, _CoreContext_results, "f").toTree(),
|
|
@@ -423,6 +443,7 @@ class CoreContext {
|
|
|
423
443
|
* no render. Returns the subjects each generator supports, plus parse issues.
|
|
424
444
|
*/
|
|
425
445
|
toSupportedSubjects({ document, settings, toGeneratorConfigMap, stackTrail }) {
|
|
446
|
+
const runStartedAt = performance.now();
|
|
426
447
|
try {
|
|
427
448
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'parse', "f");
|
|
428
449
|
__classPrivateFieldSet(this, _CoreContext_parseIssues, [], "f");
|
|
@@ -430,6 +451,7 @@ class CoreContext {
|
|
|
430
451
|
__classPrivateFieldSet(this, _CoreContext_phase, phase, "f");
|
|
431
452
|
__classPrivateFieldSet(this, _CoreContext_parseIssues, phase.context.issues, "f");
|
|
432
453
|
const parsedDocument = stackTrail.trace('parse', st => phase.context.parse(st));
|
|
454
|
+
__classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_logParseLine).call(this, parsedDocument, phase.context.issues, runStartedAt);
|
|
433
455
|
const subjects = stackTrail.trace('generate', () => {
|
|
434
456
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'generate', "f");
|
|
435
457
|
// Capability probing never renders, so the capture interval never
|
|
@@ -443,6 +465,8 @@ class CoreContext {
|
|
|
443
465
|
__classPrivateFieldSet(this, _CoreContext_phase, generatePhase, "f");
|
|
444
466
|
return generatePhase.context.toSupportedSubjects();
|
|
445
467
|
});
|
|
468
|
+
__classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_logInfo).call(this, `toSupportedSubjects: ${(0, toCountPhrase_js_1.toCountPhrase)(Object.keys(subjects).length, 'generator')}, ` +
|
|
469
|
+
`${toIssueCounts(phase.context.issues)}, ${toElapsedMs(runStartedAt)} ms`);
|
|
446
470
|
return { subjects, parseIssues: phase.context.issues };
|
|
447
471
|
}
|
|
448
472
|
catch (error) {
|
|
@@ -469,6 +493,7 @@ class CoreContext {
|
|
|
469
493
|
* defaults map is returned empty.
|
|
470
494
|
*/
|
|
471
495
|
toEnrichmentDefaults({ document, settings, toGeneratorConfigMap, stackTrail }) {
|
|
496
|
+
const runStartedAt = performance.now();
|
|
472
497
|
try {
|
|
473
498
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'parse', "f");
|
|
474
499
|
__classPrivateFieldSet(this, _CoreContext_parseIssues, [], "f");
|
|
@@ -476,6 +501,7 @@ class CoreContext {
|
|
|
476
501
|
__classPrivateFieldSet(this, _CoreContext_phase, phase, "f");
|
|
477
502
|
__classPrivateFieldSet(this, _CoreContext_parseIssues, phase.context.issues, "f");
|
|
478
503
|
const parsedDocument = stackTrail.trace('parse', st => phase.context.parse(st));
|
|
504
|
+
__classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_logParseLine).call(this, parsedDocument, phase.context.issues, runStartedAt);
|
|
479
505
|
const enrichmentDefaults = stackTrail.trace('generate', () => {
|
|
480
506
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'generate', "f");
|
|
481
507
|
// Seeding never renders, so the capture interval never opens — a
|
|
@@ -489,6 +515,8 @@ class CoreContext {
|
|
|
489
515
|
__classPrivateFieldSet(this, _CoreContext_phase, generatePhase, "f");
|
|
490
516
|
return generatePhase.context.toEnrichmentDefaults();
|
|
491
517
|
});
|
|
518
|
+
__classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_logInfo).call(this, `toEnrichmentDefaults: ${(0, toCountPhrase_js_1.toCountPhrase)(Object.keys(enrichmentDefaults).length, 'generator')} with defaults, ` +
|
|
519
|
+
`${toIssueCounts(phase.context.issues)}, ${toElapsedMs(runStartedAt)} ms`);
|
|
492
520
|
return { enrichmentDefaults, parseIssues: phase.context.issues };
|
|
493
521
|
}
|
|
494
522
|
catch (error) {
|
|
@@ -526,7 +554,7 @@ class CoreContext {
|
|
|
526
554
|
}
|
|
527
555
|
}
|
|
528
556
|
exports.CoreContext = CoreContext;
|
|
529
|
-
_CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreContext_logLines = new WeakMap(), _CoreContext_phaseName = new WeakMap(), _CoreContext_parseIssues = new WeakMap(), _CoreContext_enrichmentWarnings = new WeakMap(), _CoreContext_instances = new WeakSet(), _CoreContext_setupLogger = function _CoreContext_setupLogger({ spanId, logsPath, logLines }) {
|
|
557
|
+
_CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreContext_logLines = new WeakMap(), _CoreContext_logsPhaseLines = new WeakMap(), _CoreContext_phaseName = new WeakMap(), _CoreContext_parseIssues = new WeakMap(), _CoreContext_enrichmentWarnings = new WeakMap(), _CoreContext_instances = new WeakSet(), _CoreContext_setupLogger = function _CoreContext_setupLogger({ spanId, logsPath, logLines }) {
|
|
530
558
|
const fileHandlers = logsPath
|
|
531
559
|
? [
|
|
532
560
|
new log.FileHandler('DEBUG', {
|
|
@@ -553,6 +581,36 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
553
581
|
});
|
|
554
582
|
}, _CoreContext_toLogTrail = function _CoreContext_toLogTrail() {
|
|
555
583
|
return this.currentSubjectTrail?.toString() ?? 'SKIPPED';
|
|
584
|
+
}, _CoreContext_logInfo = function _CoreContext_logInfo(message) {
|
|
585
|
+
if (__classPrivateFieldGet(this, _CoreContext_logsPhaseLines, "f")) {
|
|
586
|
+
this.logger.info(message);
|
|
587
|
+
}
|
|
588
|
+
}, _CoreContext_logParseLine = function _CoreContext_logParseLine(document, issues, startedAt) {
|
|
589
|
+
if (!__classPrivateFieldGet(this, _CoreContext_logsPhaseLines, "f")) {
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
const issueCounts = toIssueCounts(issues);
|
|
593
|
+
const milliseconds = toElapsedMs(startedAt);
|
|
594
|
+
switch (document.type) {
|
|
595
|
+
case 'oas': {
|
|
596
|
+
const { openapi, operations, webhooks, components } = document.value;
|
|
597
|
+
const webhookCount = webhooks.length > 0 ? `${(0, toCountPhrase_js_1.toCountPhrase)(webhooks.length, 'webhook')}, ` : '';
|
|
598
|
+
const modelCount = components?.toSchemasRefNames().length ?? 0;
|
|
599
|
+
__classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_logInfo).call(this, `parse: OpenAPI ${openapi}, ${(0, toCountPhrase_js_1.toCountPhrase)(operations.length, 'operation')}, ${webhookCount}` +
|
|
600
|
+
`${(0, toCountPhrase_js_1.toCountPhrase)(modelCount, 'model')}, ${issueCounts}, ${milliseconds} ms`);
|
|
601
|
+
break;
|
|
602
|
+
}
|
|
603
|
+
case 'gql': {
|
|
604
|
+
const { operations, registry } = document.value;
|
|
605
|
+
__classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_logInfo).call(this, `parse: GraphQL, ${(0, toCountPhrase_js_1.toCountPhrase)(operations.length, 'operation')}, ` +
|
|
606
|
+
`${(0, toCountPhrase_js_1.toCountPhrase)(registry.toSchemasRefNames().length, 'model')}, ${issueCounts}, ${milliseconds} ms`);
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
default: {
|
|
610
|
+
const _exhaustive = document;
|
|
611
|
+
throw new Error(`Unhandled protocol type: ${JSON.stringify(_exhaustive)}`);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
556
614
|
}, _CoreContext_closeFileHandlers = function _CoreContext_closeFileHandlers() {
|
|
557
615
|
this.logger.handlers.forEach(handler => {
|
|
558
616
|
if (handler instanceof log.FileHandler) {
|
|
@@ -593,7 +651,8 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
593
651
|
logger: this.logger,
|
|
594
652
|
captureCurrentResult: this.captureCurrentResult.bind(this),
|
|
595
653
|
toGeneratorConfigMap,
|
|
596
|
-
captureChannel
|
|
654
|
+
captureChannel,
|
|
655
|
+
logsGeneratorLines: __classPrivateFieldGet(this, _CoreContext_logsPhaseLines, "f")
|
|
597
656
|
});
|
|
598
657
|
return { type: 'generate', context: generateContext };
|
|
599
658
|
}, _CoreContext_setupRenderPhase = function _CoreContext_setupRenderPhase({ files, previews, basePath, attribution, captureChannel }) {
|
|
@@ -608,6 +667,24 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
608
667
|
});
|
|
609
668
|
return { type: 'render', context: renderContext };
|
|
610
669
|
};
|
|
670
|
+
/** Milliseconds since `startedAt`, a `performance.now()` reading, rounded. */
|
|
671
|
+
const toElapsedMs = (startedAt) => Math.round(performance.now() - startedAt);
|
|
672
|
+
/** The size of the artifacts in UTF-8 bytes. */
|
|
673
|
+
const toByteCount = (artifacts) => {
|
|
674
|
+
const encoder = new TextEncoder();
|
|
675
|
+
return Object.values(artifacts).reduce((total, content) => total + encoder.encode(content).length, 0);
|
|
676
|
+
};
|
|
677
|
+
/** The issues by level: `0 errors, 1 warning, 2 debug`. */
|
|
678
|
+
const toIssueCounts = (issues) => {
|
|
679
|
+
const errors = issues.filter(issue => issue.level === 'error').length;
|
|
680
|
+
const warnings = issues.filter(issue => issue.level === 'warning').length;
|
|
681
|
+
const debug = issues.filter(issue => issue.level === 'debug').length;
|
|
682
|
+
return [
|
|
683
|
+
(0, toCountPhrase_js_1.toCountPhrase)(errors, 'error'),
|
|
684
|
+
(0, toCountPhrase_js_1.toCountPhrase)(warnings, 'warning'),
|
|
685
|
+
(0, toCountPhrase_js_1.toCountPhrase)(debug, 'debug', 'debug')
|
|
686
|
+
].join(', ');
|
|
687
|
+
};
|
|
611
688
|
/**
|
|
612
689
|
* Custom pretty-print formatter for SKMTC log entries.
|
|
613
690
|
*
|
|
@@ -50,6 +50,11 @@ type ConstructorArgs = {
|
|
|
50
50
|
* (tests, capture-less runs) `captureSink` is always `undefined`.
|
|
51
51
|
*/
|
|
52
52
|
captureChannel?: CaptureChannel;
|
|
53
|
+
/**
|
|
54
|
+
* Whether each generator logs an INFO line after it ran. Defaults to
|
|
55
|
+
* `false`; `CoreContext` turns it on when the run keeps INFO lines.
|
|
56
|
+
*/
|
|
57
|
+
logsGeneratorLines?: boolean;
|
|
53
58
|
};
|
|
54
59
|
/**
|
|
55
60
|
* Arguments for applying package imports to a generated file.
|
|
@@ -154,7 +159,7 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
154
159
|
toGeneratorConfigMap: <EnrichmentType = undefined>() => GeneratorsMapContainer<EnrichmentType>;
|
|
155
160
|
/** The pending models, outermost first: the last is the model whose projection constructor is running. */
|
|
156
161
|
pendingStack: PendingDefinition[];
|
|
157
|
-
constructor({ document, settings, logger, captureCurrentResult, toGeneratorConfigMap, captureChannel }: ConstructorArgs);
|
|
162
|
+
constructor({ document, settings, logger, captureCurrentResult, toGeneratorConfigMap, captureChannel, logsGeneratorLines }: ConstructorArgs);
|
|
158
163
|
/**
|
|
159
164
|
* The recording enrichment accessor — the single choke point every
|
|
160
165
|
* enrichment lookup routes through (dispatch loops, projection-base
|