@skmtc/core 0.36.1 → 0.38.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/_dnt.polyfills.d.ts +6 -6
- package/esm/anchors/postPass.d.ts +6 -3
- package/esm/anchors/postPass.js +6 -3
- package/esm/context/CoreContext.d.ts +10 -2
- package/esm/context/CoreContext.js +158 -87
- package/esm/context/GenerateContext.d.ts +11 -0
- package/esm/context/GenerateContext.js +44 -16
- package/esm/context/LogLinesHandler.d.ts +28 -0
- package/esm/context/LogLinesHandler.js +65 -0
- package/esm/context/ParseContext.js +23 -4
- package/esm/context/ParseIssue.d.ts +12 -9
- package/esm/context/ParseIssue.js +7 -6
- package/esm/context/RenderContext.js +47 -65
- package/esm/context/ResultsHandler.d.ts +5 -3
- package/esm/context/ResultsHandler.js +11 -5
- package/esm/context/StackTrail.d.ts +14 -6
- package/esm/context/StackTrail.js +77 -29
- package/esm/context/documentTrail.d.ts +7 -3
- package/esm/context/documentTrail.js +6 -2
- package/esm/context/generateTypes.d.ts +21 -2
- package/esm/context/generateTypes.js +2 -1
- package/esm/helpers/ResultsLog.d.ts +2 -2
- package/esm/helpers/ResultsLog.js +7 -4
- package/esm/mod.d.ts +2 -0
- package/esm/mod.js +2 -0
- package/esm/run/toArtifacts.d.ts +9 -1
- package/esm/run/toArtifacts.js +4 -4
- package/esm/types/LogLine.d.ts +36 -0
- package/esm/types/LogLine.js +26 -0
- package/esm/types/Manifest.d.ts +1 -1
- package/esm/types/Manifest.js +16 -4
- package/esm/types/SerializedError.d.ts +25 -0
- package/esm/types/SerializedError.js +50 -0
- package/package.json +1 -1
- package/script/_dnt.polyfills.d.ts +6 -6
- package/script/anchors/postPass.d.ts +6 -3
- package/script/anchors/postPass.js +6 -3
- package/script/context/CoreContext.d.ts +10 -2
- package/script/context/CoreContext.js +158 -87
- package/script/context/GenerateContext.d.ts +11 -0
- package/script/context/GenerateContext.js +44 -16
- package/script/context/LogLinesHandler.d.ts +28 -0
- package/script/context/LogLinesHandler.js +69 -0
- package/script/context/ParseContext.js +23 -4
- package/script/context/ParseIssue.d.ts +12 -9
- package/script/context/ParseIssue.js +7 -6
- package/script/context/RenderContext.js +47 -65
- package/script/context/ResultsHandler.d.ts +5 -3
- package/script/context/ResultsHandler.js +11 -5
- package/script/context/StackTrail.d.ts +14 -6
- package/script/context/StackTrail.js +76 -28
- package/script/context/documentTrail.d.ts +7 -3
- package/script/context/documentTrail.js +9 -3
- package/script/context/generateTypes.d.ts +21 -2
- package/script/context/generateTypes.js +2 -1
- package/script/helpers/ResultsLog.d.ts +2 -2
- package/script/helpers/ResultsLog.js +7 -4
- package/script/mod.d.ts +2 -0
- package/script/mod.js +2 -0
- package/script/run/toArtifacts.d.ts +9 -1
- package/script/run/toArtifacts.js +4 -4
- package/script/types/LogLine.d.ts +36 -0
- package/script/types/LogLine.js +62 -0
- package/script/types/Manifest.d.ts +1 -1
- package/script/types/Manifest.js +16 -4
- package/script/types/SerializedError.d.ts +25 -0
- package/script/types/SerializedError.js +87 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* One structured log line that `toArtifacts` returns in `logs`.
|
|
4
|
+
*
|
|
5
|
+
* A line logged while a subject is generated carries the subject's stack
|
|
6
|
+
* trail in `trail`. That is the same string `manifest.results` is keyed
|
|
7
|
+
* by, so an `ERROR` line joins to the `'error'` leaf of its subject.
|
|
8
|
+
*
|
|
9
|
+
* @module LogLine
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
+
var ownKeys = function(o) {
|
|
29
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
+
var ar = [];
|
|
31
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
+
return ar;
|
|
33
|
+
};
|
|
34
|
+
return ownKeys(o);
|
|
35
|
+
};
|
|
36
|
+
return function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.logLine = exports.logLineLevel = void 0;
|
|
46
|
+
const v = __importStar(require("valibot"));
|
|
47
|
+
const SerializedError_js_1 = require("./SerializedError.js");
|
|
48
|
+
/** Valibot schema for {@link LogLineLevel}. */
|
|
49
|
+
exports.logLineLevel = v.picklist(['DEBUG', 'INFO', 'WARN', 'ERROR']);
|
|
50
|
+
const _logLineLevelDriftCheck = exports.logLineLevel;
|
|
51
|
+
void _logLineLevelDriftCheck;
|
|
52
|
+
/** Valibot schema for {@link LogLine}. */
|
|
53
|
+
exports.logLine = v.object({
|
|
54
|
+
seq: v.number(),
|
|
55
|
+
level: exports.logLineLevel,
|
|
56
|
+
trail: v.optional(v.string()),
|
|
57
|
+
message: v.string(),
|
|
58
|
+
error: v.optional(SerializedError_js_1.serializedError),
|
|
59
|
+
time: v.number()
|
|
60
|
+
});
|
|
61
|
+
const _logLineDriftCheck = exports.logLine;
|
|
62
|
+
void _logLineDriftCheck;
|
package/script/types/Manifest.js
CHANGED
|
@@ -112,13 +112,25 @@ const Preview_js_1 = require("./Preview.js");
|
|
|
112
112
|
const EnrichmentWarning_js_1 = require("../enrichments/EnrichmentWarning.js");
|
|
113
113
|
const generateTypes_js_1 = require("../context/generateTypes.js");
|
|
114
114
|
const ParseIssue_js_1 = require("../context/ParseIssue.js");
|
|
115
|
+
const SerializedError_js_1 = require("./SerializedError.js");
|
|
115
116
|
const v = __importStar(require("valibot"));
|
|
117
|
+
/**
|
|
118
|
+
* The `cause` of an error issue. Manifests written before core stored a
|
|
119
|
+
* {@link SerializedError} hold `{}` (an `Error` after `JSON.stringify`)
|
|
120
|
+
* or a string; those are read and converted with {@link toSerializedError}.
|
|
121
|
+
*/
|
|
122
|
+
const legacyCause = v.union([v.string(), v.looseObject({})]);
|
|
123
|
+
const issueCause = v.union([
|
|
124
|
+
SerializedError_js_1.serializedError,
|
|
125
|
+
v.pipe(legacyCause, v.transform((legacy) => (0, SerializedError_js_1.toSerializedError)(legacy)))
|
|
126
|
+
]);
|
|
116
127
|
/**
|
|
117
128
|
* Valibot schema for the unified {@link ParseIssue} discriminated union.
|
|
118
129
|
*
|
|
119
130
|
* The TS type and this schema stay in sync via the
|
|
120
|
-
* `v.GenericSchema<ParseIssue>` annotation — adding a variant on
|
|
121
|
-
* side without the other fails to type-check.
|
|
131
|
+
* `v.GenericSchema<unknown, ParseIssue>` annotation — adding a variant on
|
|
132
|
+
* one side without the other fails to type-check. The input is `unknown`
|
|
133
|
+
* because a legacy `cause` is converted while it is read.
|
|
122
134
|
*/
|
|
123
135
|
const parseIssue = v.variant('protocol', [
|
|
124
136
|
v.variant('level', [
|
|
@@ -128,7 +140,7 @@ const parseIssue = v.variant('protocol', [
|
|
|
128
140
|
type: generateTypes_js_1.oasIssueType,
|
|
129
141
|
location: v.string(),
|
|
130
142
|
message: v.string(),
|
|
131
|
-
cause: v.optional(
|
|
143
|
+
cause: v.optional(issueCause)
|
|
132
144
|
}),
|
|
133
145
|
v.object({
|
|
134
146
|
protocol: v.literal('oas'),
|
|
@@ -152,7 +164,7 @@ const parseIssue = v.variant('protocol', [
|
|
|
152
164
|
type: ParseIssue_js_1.gqlIssueType,
|
|
153
165
|
location: v.string(),
|
|
154
166
|
message: v.string(),
|
|
155
|
-
cause: v.optional(
|
|
167
|
+
cause: v.optional(issueCause)
|
|
156
168
|
}),
|
|
157
169
|
v.object({
|
|
158
170
|
protocol: v.literal('gql'),
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error as data: the name, message, stack and cause chain of a thrown
|
|
3
|
+
* value, in a shape that survives `JSON.stringify` and structured clone.
|
|
4
|
+
* `JSON.stringify(new Error('x'))` gives `{}`, because an `Error`'s own
|
|
5
|
+
* properties are not enumerable.
|
|
6
|
+
*
|
|
7
|
+
* @module SerializedError
|
|
8
|
+
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
/** A thrown value as data. A non-`Error` value has the name `'NonError'`. */
|
|
11
|
+
export type SerializedError = {
|
|
12
|
+
name: string;
|
|
13
|
+
message: string;
|
|
14
|
+
stack?: string;
|
|
15
|
+
cause?: SerializedError;
|
|
16
|
+
};
|
|
17
|
+
/** Valibot schema for {@link SerializedError}. */
|
|
18
|
+
export declare const serializedError: v.GenericSchema<SerializedError>;
|
|
19
|
+
/**
|
|
20
|
+
* Converts a thrown value to a {@link SerializedError}. An `Error` keeps its
|
|
21
|
+
* name, message, stack and up to five levels of `cause`. Any other value
|
|
22
|
+
* becomes `{ name: 'NonError', message }`, where `message` is the string
|
|
23
|
+
* itself or the value as JSON.
|
|
24
|
+
*/
|
|
25
|
+
export declare const toSerializedError: (error: unknown, depth?: number) => SerializedError;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* An error as data: the name, message, stack and cause chain of a thrown
|
|
4
|
+
* value, in a shape that survives `JSON.stringify` and structured clone.
|
|
5
|
+
* `JSON.stringify(new Error('x'))` gives `{}`, because an `Error`'s own
|
|
6
|
+
* properties are not enumerable.
|
|
7
|
+
*
|
|
8
|
+
* @module SerializedError
|
|
9
|
+
*/
|
|
10
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
+
}) : function(o, v) {
|
|
24
|
+
o["default"] = v;
|
|
25
|
+
});
|
|
26
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
27
|
+
var ownKeys = function(o) {
|
|
28
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
29
|
+
var ar = [];
|
|
30
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
31
|
+
return ar;
|
|
32
|
+
};
|
|
33
|
+
return ownKeys(o);
|
|
34
|
+
};
|
|
35
|
+
return function (mod) {
|
|
36
|
+
if (mod && mod.__esModule) return mod;
|
|
37
|
+
var result = {};
|
|
38
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
39
|
+
__setModuleDefault(result, mod);
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.toSerializedError = exports.serializedError = void 0;
|
|
45
|
+
const v = __importStar(require("valibot"));
|
|
46
|
+
/** Valibot schema for {@link SerializedError}. */
|
|
47
|
+
exports.serializedError = v.object({
|
|
48
|
+
name: v.string(),
|
|
49
|
+
message: v.string(),
|
|
50
|
+
stack: v.optional(v.string()),
|
|
51
|
+
cause: v.optional(v.lazy(() => exports.serializedError))
|
|
52
|
+
});
|
|
53
|
+
const _serializedErrorDriftCheck = exports.serializedError;
|
|
54
|
+
void _serializedErrorDriftCheck;
|
|
55
|
+
/** How many `cause` links are followed. Also ends a cycle such as `e.cause = e`. */
|
|
56
|
+
const MAX_CAUSE_DEPTH = 5;
|
|
57
|
+
/**
|
|
58
|
+
* Converts a thrown value to a {@link SerializedError}. An `Error` keeps its
|
|
59
|
+
* name, message, stack and up to five levels of `cause`. Any other value
|
|
60
|
+
* becomes `{ name: 'NonError', message }`, where `message` is the string
|
|
61
|
+
* itself or the value as JSON.
|
|
62
|
+
*/
|
|
63
|
+
const toSerializedError = (error, depth = 0) => {
|
|
64
|
+
if (error instanceof Error) {
|
|
65
|
+
return {
|
|
66
|
+
name: error.name,
|
|
67
|
+
message: error.message,
|
|
68
|
+
...(error.stack ? { stack: error.stack } : {}),
|
|
69
|
+
...(error.cause !== undefined && depth < MAX_CAUSE_DEPTH
|
|
70
|
+
? { cause: (0, exports.toSerializedError)(error.cause, depth + 1) }
|
|
71
|
+
: {})
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return { name: 'NonError', message: toNonErrorMessage(error) };
|
|
75
|
+
};
|
|
76
|
+
exports.toSerializedError = toSerializedError;
|
|
77
|
+
const toNonErrorMessage = (value) => {
|
|
78
|
+
if (typeof value === 'string') {
|
|
79
|
+
return value;
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
return JSON.stringify(value) ?? String(value);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return String(value);
|
|
86
|
+
}
|
|
87
|
+
};
|