@ultimat3/core 21.0.0 → 22.1.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/CLAUDE.md +189 -527
- package/README.md +39 -1
- package/package.json +2 -2
- package/src/address-class.ts +143 -0
- package/src/canonical-json.ts +24 -1
- package/src/client-flight.ts +5 -2
- package/src/config-count.ts +19 -0
- package/src/config-fixes.ts +23 -0
- package/src/config-merge.ts +36 -0
- package/src/config.ts +122 -65
- package/src/core-error-codes.ts +1 -0
- package/src/dev-secrets.ts +45 -0
- package/src/exports/secrets.ts +1 -0
- package/src/host-rules.ts +71 -0
- package/src/image/exif-orientation.ts +40 -0
- package/src/image/probe.ts +13 -1
- package/src/in-process-fetch.ts +39 -0
- package/src/index.ts +31 -29
- package/src/iso-date.ts +5 -0
- package/src/lifecycle-grace.ts +44 -0
- package/src/lifecycle-signals.ts +35 -0
- package/src/lifecycle.ts +44 -36
- package/src/logger.ts +22 -3
- package/src/measurement-actor.ts +52 -0
- package/src/metrics-text.ts +10 -2
- package/src/metrics.ts +8 -5
- package/src/otlp-metric-exporter.ts +39 -12
- package/src/otlp-span-exporter.ts +38 -15
- package/src/same-origin.ts +51 -0
- package/src/secrets-store.ts +51 -5
- package/src/source-mask.ts +30 -0
- package/src/type-pins.ts +9 -0
- package/src/result.ts +0 -78
package/src/result.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// Single responsibility: `Result<T, E>` for boundaries where throwing is wrong —
|
|
2
|
-
// validation seams, driver probes, CLI commands that must render `--json` either way.
|
|
3
|
-
|
|
4
|
-
import { toUltimateError, type UltimateError } from './errors';
|
|
5
|
-
|
|
6
|
-
export interface Ok<T> {
|
|
7
|
-
readonly ok: true;
|
|
8
|
-
readonly value: T;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface Err<E> {
|
|
12
|
-
readonly ok: false;
|
|
13
|
-
readonly error: E;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type Result<T, E = UltimateError> = Ok<T> | Err<E>;
|
|
17
|
-
|
|
18
|
-
export function ok<T>(value: T): Ok<T> {
|
|
19
|
-
return { ok: true, value };
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function err<E>(error: E): Err<E> {
|
|
23
|
-
return { ok: false, error };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function isOk<T, E>(result: Result<T, E>): result is Ok<T> {
|
|
27
|
-
return result.ok;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function isErr<T, E>(result: Result<T, E>): result is Err<E> {
|
|
31
|
-
return !result.ok;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function map<T, E, U>(result: Result<T, E>, fn: (value: T) => U): Result<U, E> {
|
|
35
|
-
return result.ok ? ok(fn(result.value)) : result;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function mapErr<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F> {
|
|
39
|
-
return result.ok ? result : err(fn(result.error));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function unwrapOr<T, E>(result: Result<T, E>, fallback: T): T {
|
|
43
|
-
return result.ok ? result.value : fallback;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Throws the contained error — use only where a throw is genuinely correct. */
|
|
47
|
-
export function unwrap<T, E>(result: Result<T, E>): T {
|
|
48
|
-
if (result.ok) return result.value;
|
|
49
|
-
throw toUltimateError(result.error);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function tryCatch<T>(fn: () => Promise<T>): Promise<Result<T, UltimateError>>;
|
|
53
|
-
export function tryCatch<T>(fn: () => T): Result<T, UltimateError>;
|
|
54
|
-
export function tryCatch<T>(
|
|
55
|
-
fn: () => T | Promise<T>,
|
|
56
|
-
): Result<T, UltimateError> | Promise<Result<T, UltimateError>> {
|
|
57
|
-
try {
|
|
58
|
-
const value = fn();
|
|
59
|
-
if (isPromiseLike(value)) {
|
|
60
|
-
return value.then(
|
|
61
|
-
(resolved) => ok(resolved),
|
|
62
|
-
(reason: unknown) => err(toUltimateError(reason)),
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
return ok(value);
|
|
66
|
-
} catch (thrown) {
|
|
67
|
-
return err(toUltimateError(thrown));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function isPromiseLike<T>(value: T | Promise<T>): value is Promise<T> {
|
|
72
|
-
return (
|
|
73
|
-
typeof value === 'object' &&
|
|
74
|
-
value !== null &&
|
|
75
|
-
'then' in value &&
|
|
76
|
-
typeof (value as { then: unknown }).then === 'function'
|
|
77
|
-
);
|
|
78
|
-
}
|