@ontrails/core 1.0.0-beta.43 → 1.0.0-beta.45
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/CHANGELOG.md +14 -0
- package/README.md +1 -1
- package/package.json +6 -1
- package/src/error-rendering.ts +36 -0
- package/src/index.ts +5 -1
- package/src/transport-error-map.ts +10 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ontrails/core
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.45
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`f9533a4`](https://github.com/outfitter-dev/trails/commit/f9533a4ef7392201c71d7f751361b4f7177eeacb): Keep public error projection shared and redacted while using transport-neutral CLI vocabulary and preserving safe topo diagnostics in structured output.
|
|
8
|
+
|
|
9
|
+
## 1.0.0-beta.44
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`b1fbe57`](https://github.com/outfitter-dev/trails/commit/b1fbe574e6f44d1fecb5e3a000270955c0a77b7b): Publish Bun-validated package tarballs through an npm trusted-publishing adapter
|
|
14
|
+
binding, add exact repository metadata for each public workspace package, and
|
|
15
|
+
correct the native Bun release descriptor to its pack-only runtime boundary.
|
|
16
|
+
|
|
3
17
|
## 1.0.0-beta.43
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -139,7 +139,7 @@ Dynamic classes:
|
|
|
139
139
|
- `RetryExhaustedError` inherits category and surface codes from its wrapped `TrailsError`; retryable is always No.
|
|
140
140
|
<!-- error-taxonomy:end -->
|
|
141
141
|
|
|
142
|
-
Public
|
|
142
|
+
Public surfaces share one redacted rendering contract before applying surface codes. Sensitive substrings are removed from non-internal `TrailsError` messages. Internal-category `TrailsError` instances and unknown native errors remain opaque: HTTP, MCP, and library boundaries use `Internal server error`, while CLI uses the transport-neutral `Internal error`. Diagnostics and serialized payloads keep their useful structure while redacting messages, context, and stack strings.
|
|
143
143
|
|
|
144
144
|
The developer returns `Result.err(new NotFoundError(...))`. The framework maps it to the right code on every surface.
|
|
145
145
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ontrails/core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.45",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/outfitter-dev/trails.git",
|
|
7
|
+
"directory": "packages/core"
|
|
8
|
+
},
|
|
4
9
|
"files": [
|
|
5
10
|
"src/**/*.ts",
|
|
6
11
|
"!src/**/__tests__/**",
|
package/src/error-rendering.ts
CHANGED
|
@@ -15,6 +15,13 @@ export interface ErrorDiagnosticsRendering {
|
|
|
15
15
|
readonly stack?: string | undefined;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
export interface PublicErrorRendering {
|
|
19
|
+
readonly category: ErrorCategory;
|
|
20
|
+
readonly message: string;
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly retryable: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
18
25
|
export const redactErrorString = (value: string): string =>
|
|
19
26
|
errorRedactor.redact(value);
|
|
20
27
|
|
|
@@ -49,3 +56,32 @@ export const renderErrorDiagnostics = (
|
|
|
49
56
|
...(stack === undefined ? {} : { stack }),
|
|
50
57
|
};
|
|
51
58
|
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Project an error through the shared public redaction policy.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const rendering = renderPublicError(new NotFoundError('missing'));
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export const renderPublicError = (error: Error): PublicErrorRendering => {
|
|
69
|
+
if (isTrailsError(error)) {
|
|
70
|
+
return {
|
|
71
|
+
category: error.category,
|
|
72
|
+
message:
|
|
73
|
+
error.category === 'internal'
|
|
74
|
+
? INTERNAL_ERROR_PUBLIC_MESSAGE
|
|
75
|
+
: redactErrorString(error.message),
|
|
76
|
+
name: error.name,
|
|
77
|
+
retryable: error.retryable,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
category: 'internal',
|
|
83
|
+
message: INTERNAL_ERROR_PUBLIC_MESSAGE,
|
|
84
|
+
name: 'InternalError',
|
|
85
|
+
retryable: false,
|
|
86
|
+
};
|
|
87
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -63,11 +63,15 @@ export type {
|
|
|
63
63
|
export {
|
|
64
64
|
INTERNAL_ERROR_PUBLIC_MESSAGE,
|
|
65
65
|
renderErrorDiagnostics,
|
|
66
|
+
renderPublicError,
|
|
66
67
|
redactErrorContext,
|
|
67
68
|
redactErrorStack,
|
|
68
69
|
redactErrorString,
|
|
69
70
|
} from './error-rendering.js';
|
|
70
|
-
export type {
|
|
71
|
+
export type {
|
|
72
|
+
ErrorDiagnosticsRendering,
|
|
73
|
+
PublicErrorRendering,
|
|
74
|
+
} from './error-rendering.js';
|
|
71
75
|
export type {
|
|
72
76
|
DiagnosticBase,
|
|
73
77
|
DiagnosticSeverity,
|
|
@@ -9,14 +9,12 @@ import {
|
|
|
9
9
|
codesByCategory,
|
|
10
10
|
errorClasses,
|
|
11
11
|
exitCodeMap,
|
|
12
|
-
isTrailsError,
|
|
13
12
|
jsonRpcCodeMap,
|
|
14
13
|
statusCodeMap,
|
|
15
14
|
} from './errors.js';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from './error-rendering.js';
|
|
15
|
+
import { renderPublicError } from './error-rendering.js';
|
|
16
|
+
|
|
17
|
+
const CLI_INTERNAL_ERROR_PUBLIC_MESSAGE = 'Internal error';
|
|
20
18
|
|
|
21
19
|
export const surfaceNames = ['cli', 'http', 'jsonRpc', 'mcp'] as const;
|
|
22
20
|
|
|
@@ -118,23 +116,14 @@ export const renderPublicSurfaceError = (
|
|
|
118
116
|
surface: SurfaceName,
|
|
119
117
|
error: Error
|
|
120
118
|
): SurfaceErrorRendering => {
|
|
121
|
-
|
|
122
|
-
const rendering = renderSurfaceError(surface, error);
|
|
123
|
-
return {
|
|
124
|
-
...rendering,
|
|
125
|
-
message:
|
|
126
|
-
rendering.category === 'internal'
|
|
127
|
-
? INTERNAL_ERROR_PUBLIC_MESSAGE
|
|
128
|
-
: redactErrorString(rendering.message),
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
119
|
+
const rendering = renderPublicError(error);
|
|
132
120
|
return {
|
|
133
|
-
|
|
134
|
-
code: codesByCategory.
|
|
135
|
-
message:
|
|
136
|
-
|
|
137
|
-
|
|
121
|
+
...rendering,
|
|
122
|
+
code: codesByCategory[rendering.category][surfaceCodeKeys[surface]],
|
|
123
|
+
message:
|
|
124
|
+
surface === 'cli' && rendering.category === 'internal'
|
|
125
|
+
? CLI_INTERNAL_ERROR_PUBLIC_MESSAGE
|
|
126
|
+
: rendering.message,
|
|
138
127
|
surface,
|
|
139
128
|
};
|
|
140
129
|
};
|