brass-runtime 1.15.0 → 1.16.1
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 +17 -0
- package/README.md +673 -136
- package/dist/agent/cli/main.cjs +40 -35
- package/dist/agent/cli/main.js +9 -4
- package/dist/agent/cli/main.mjs +9 -4
- package/dist/agent/index.cjs +8 -4
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +7 -3
- package/dist/agent/index.mjs +7 -3
- package/dist/chunk-2HQTDLHF.mjs +683 -0
- package/dist/chunk-36I3M4UC.mjs +370 -0
- package/dist/chunk-3AYM6WPJ.js +1629 -0
- package/dist/chunk-3LOYJFRR.cjs +300 -0
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/chunk-3Y2RIUMM.js +300 -0
- package/dist/{chunk-VEZNF5GZ.cjs → chunk-4ROBZFL6.cjs} +130 -126
- package/dist/{chunk-3QMOKAS5.js → chunk-52OB2ROS.js} +9 -5
- package/dist/chunk-52PPNNI4.cjs +416 -0
- package/dist/chunk-5EC274J5.cjs +2874 -0
- package/dist/chunk-5QC7LRZ3.js +229 -0
- package/dist/chunk-5VRJNBLZ.mjs +2874 -0
- package/dist/chunk-62AZW6UT.cjs +313 -0
- package/dist/chunk-6IXXWIUM.js +683 -0
- package/dist/chunk-74ZTY6CP.js +2871 -0
- package/dist/chunk-76YMRMH2.cjs +777 -0
- package/dist/chunk-7CMJS3QE.mjs +2871 -0
- package/dist/{chunk-4NHES7VK.mjs → chunk-7JIJOVCT.js} +27 -13
- package/dist/chunk-A2OM6NEH.mjs +194 -0
- package/dist/chunk-AGR5B2BC.cjs +683 -0
- package/dist/chunk-AVNQLJ5V.js +777 -0
- package/dist/chunk-B33ICAKP.js +313 -0
- package/dist/{chunk-ELOOF35R.mjs → chunk-B5JD23U7.mjs} +1 -1
- package/dist/chunk-BABBZK4Y.js +2024 -0
- package/dist/chunk-C3MDXTRZ.js +354 -0
- package/dist/chunk-CIZFIMK5.js +2193 -0
- package/dist/chunk-CZIVE6NT.cjs +354 -0
- package/dist/chunk-DNFJLJMW.mjs +354 -0
- package/dist/chunk-DNFO2EIZ.mjs +777 -0
- package/dist/chunk-EJ6BPYVR.mjs +416 -0
- package/dist/chunk-ENKODRU3.cjs +2193 -0
- package/dist/chunk-EOC4UHBS.mjs +229 -0
- package/dist/{chunk-BMH5AV44.js → chunk-FH2X7BVP.js} +756 -440
- package/dist/{chunk-PPUXIH5R.js → chunk-FHQGHPMO.mjs} +27 -13
- package/dist/{chunk-TGIFUAK4.cjs → chunk-GLE2WY7Z.cjs} +951 -635
- package/dist/{chunk-BDF4AMWX.mjs → chunk-GYM3LLGS.mjs} +756 -440
- package/dist/chunk-HLWLMW2F.mjs +2024 -0
- package/dist/chunk-JF5WGYJJ.cjs +194 -0
- package/dist/chunk-KH4SYAOS.mjs +1629 -0
- package/dist/chunk-KN32XNTH.mjs +313 -0
- package/dist/chunk-KQLYONSE.cjs +2871 -0
- package/dist/{chunk-STVLQ3XD.cjs → chunk-KZJQ723N.cjs} +92 -78
- package/dist/chunk-L2SYFEBS.js +194 -0
- package/dist/chunk-L6VB5N7Q.cjs +104 -0
- package/dist/{chunk-K6M7MDZ4.mjs → chunk-MBEJI5HF.mjs} +9 -5
- package/dist/chunk-MIIYDLGM.js +2874 -0
- package/dist/chunk-MOO4L7F4.mjs +104 -0
- package/dist/chunk-MT3OWDPC.mjs +2193 -0
- package/dist/chunk-MVGUEJ5Z.cjs +370 -0
- package/dist/chunk-OBGZSXTJ.cjs +10 -0
- package/dist/chunk-PD4EJTQC.cjs +229 -0
- package/dist/chunk-PWC3RBQE.mjs +300 -0
- package/dist/chunk-Q2I37RP3.cjs +1629 -0
- package/dist/chunk-RKGKFN2A.js +416 -0
- package/dist/{chunk-R3R2FVLG.cjs → chunk-SA6HUJVI.cjs} +5 -5
- package/dist/chunk-TRM4JUZQ.js +104 -0
- package/dist/chunk-UB4B6OFY.js +370 -0
- package/dist/{chunk-TO7IKXYT.js → chunk-UCUBNWM2.js} +1 -1
- package/dist/chunk-VN44DYYT.cjs +2024 -0
- package/dist/chunk-Y6FXYEAI.mjs +10 -0
- package/dist/client-CZHU674n.d.ts +820 -0
- package/dist/core/index.cjs +198 -4
- package/dist/core/index.d.ts +311 -212
- package/dist/core/index.js +237 -43
- package/dist/core/index.mjs +237 -43
- package/dist/{effect-CMOQKX8y.d.ts → effect-DIUHZ9IN.d.ts} +195 -1
- package/dist/effectRunner-CFLC32IK.cjs +8 -0
- package/dist/effectRunner-L4S7IPT3.js +8 -0
- package/dist/effectRunner-NNGG75QA.mjs +8 -0
- package/dist/http/index.cjs +1227 -2971
- package/dist/http/index.d.ts +826 -280
- package/dist/http/index.js +1089 -2833
- package/dist/http/index.mjs +1089 -2833
- package/dist/http/testing.cjs +161 -0
- package/dist/http/testing.d.ts +43 -0
- package/dist/http/testing.js +161 -0
- package/dist/http/testing.mjs +161 -0
- package/dist/index.cjs +486 -250
- package/dist/index.d.ts +87 -95
- package/dist/index.js +391 -155
- package/dist/index.mjs +391 -155
- package/dist/observability/index.cjs +162 -0
- package/dist/observability/index.d.ts +152 -0
- package/dist/observability/index.js +162 -0
- package/dist/observability/index.mjs +162 -0
- package/dist/perf/cli.cjs +401 -0
- package/dist/perf/cli.d.ts +1 -0
- package/dist/perf/cli.js +401 -0
- package/dist/perf/cli.mjs +401 -0
- package/dist/perf/index.cjs +141 -0
- package/dist/perf/index.d.ts +483 -0
- package/dist/perf/index.js +141 -0
- package/dist/perf/index.mjs +141 -0
- package/dist/schedule-CK3Ml_7p.d.ts +259 -0
- package/dist/schema/index.cjs +29 -0
- package/dist/schema/index.d.ts +179 -0
- package/dist/schema/index.js +29 -0
- package/dist/schema/index.mjs +29 -0
- package/dist/server-GJPg8ZSG.d.ts +675 -0
- package/dist/{stream-FQm9h4Mg.d.ts → stream-B4oK9JFP.d.ts} +1 -1
- package/dist/tracer-Hwt1cl7h.d.ts +189 -0
- package/dist/tracing-DqbTKGcf.d.ts +148 -0
- package/docs/ARCHITECTURE.md +292 -0
- package/docs/README.md +63 -0
- package/docs/adr/0001-ai-context-pack.md +32 -0
- package/docs/agent-apply-mode.md +104 -0
- package/docs/agent-approvals.md +110 -0
- package/docs/agent-batch.md +185 -0
- package/docs/agent-boundaries.md +112 -0
- package/docs/agent-chat-sessions.md +160 -0
- package/docs/agent-ci.md +17 -0
- package/docs/agent-cli.md +405 -0
- package/docs/agent-config.md +480 -0
- package/docs/agent-context-discovery.md +159 -0
- package/docs/agent-copilot-like-dx.md +126 -0
- package/docs/agent-declarative-optimized-planning.md +138 -0
- package/docs/agent-dx.md +224 -0
- package/docs/agent-env-files.md +126 -0
- package/docs/agent-follow-up-context.md +43 -0
- package/docs/agent-global-usage.md +180 -0
- package/docs/agent-init.md +109 -0
- package/docs/agent-install-and-configure.md +516 -0
- package/docs/agent-language-workspace-ux.md +99 -0
- package/docs/agent-llm-adapters.md +123 -0
- package/docs/agent-local-install.md +190 -0
- package/docs/agent-local-tests.md +51 -0
- package/docs/agent-observability.md +155 -0
- package/docs/agent-patch-quality-loop.md +162 -0
- package/docs/agent-presets.md +22 -0
- package/docs/agent-project-commands.md +237 -0
- package/docs/agent-project-intelligence.md +156 -0
- package/docs/agent-redaction.md +18 -0
- package/docs/agent-release-readiness.md +76 -0
- package/docs/agent-rollback-safety.md +162 -0
- package/docs/agent-rollback.md +23 -0
- package/docs/agent-run-artifacts.md +16 -0
- package/docs/agent-vscode-auto-discovery.md +137 -0
- package/docs/agent-vscode-batch-runner.md +100 -0
- package/docs/agent-vscode-chat-layout.md +90 -0
- package/docs/agent-vscode-clean-install.md +147 -0
- package/docs/agent-vscode-code-actions.md +70 -0
- package/docs/agent-vscode-diff-preview.md +45 -0
- package/docs/agent-vscode-inline-assist.md +56 -0
- package/docs/agent-vscode-install.md +186 -0
- package/docs/agent-vscode-model-setup.md +97 -0
- package/docs/agent-vscode-patch-preview.md +92 -0
- package/docs/agent-vscode-problems.md +79 -0
- package/docs/agent-vscode-project-dashboard.md +106 -0
- package/docs/agent-vscode-run-history.md +92 -0
- package/docs/agent-vscode-ux.md +73 -0
- package/docs/ai/INVARIANTS.md +84 -0
- package/docs/ai/PROJECT_MAP.md +338 -0
- package/docs/ai/PUBLIC_API.md +336 -0
- package/docs/ai/VALIDATION_MATRIX.md +67 -0
- package/docs/api-polish.md +37 -0
- package/docs/cancellation.md +162 -0
- package/docs/coverage.md +46 -0
- package/docs/getting-started.md +159 -0
- package/docs/guides/README.md +40 -0
- package/docs/guides/circuit-breaker.md +89 -0
- package/docs/guides/error-handling.md +91 -0
- package/docs/guides/getting-started.md +107 -0
- package/docs/guides/layers.md +189 -0
- package/docs/guides/metrics.md +101 -0
- package/docs/guides/resource-management.md +141 -0
- package/docs/guides/retry.md +215 -0
- package/docs/guides/semaphore.md +66 -0
- package/docs/guides/streams.md +117 -0
- package/docs/guides/supervisors.md +98 -0
- package/docs/guides/testing.md +162 -0
- package/docs/guides/tracing.md +71 -0
- package/docs/http-recipes.md +399 -0
- package/docs/http.md +749 -0
- package/docs/modules.md +285 -0
- package/docs/observability-collector-smoke.md +31 -0
- package/docs/observability-framework-examples.md +98 -0
- package/docs/observability.md +542 -0
- package/docs/otel-collector-smoke.yaml +27 -0
- package/docs/performance-profiler.md +199 -0
- package/docs/production-readiness.md +73 -0
- package/docs/recipes/README.md +12 -0
- package/docs/recipes/http-server.md +45 -0
- package/docs/recipes/layers.md +44 -0
- package/docs/recipes/performance.md +47 -0
- package/docs/recipes/runtime.md +41 -0
- package/docs/recipes/testing.md +41 -0
- package/docs/release.md +53 -0
- package/docs/wasm-bounded-queues.md +44 -0
- package/docs/wasm-engine-observability-benchmarks.md +85 -0
- package/docs/wasm-fiber-engine.md +117 -0
- package/docs/wasm-scheduler-state-machine.md +122 -0
- package/docs/wasm-stream-chunks.md +54 -0
- package/package.json +48 -2
- package/dist/chunk-AR22SXML.js +0 -1043
- package/dist/chunk-BDYEENHT.js +0 -224
- package/dist/chunk-JFPU5GQI.mjs +0 -1043
- package/dist/chunk-MS34J5LY.cjs +0 -224
- package/dist/chunk-UMAZLXAB.mjs +0 -224
- package/dist/chunk-XPZNXSVN.cjs +0 -1043
- package/dist/tracing-DNT9jEbr.d.ts +0 -106
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HTTP_PROFILE_VARIANTS,
|
|
3
|
+
captureMemorySnapshot,
|
|
4
|
+
comparePerfToBaseline,
|
|
5
|
+
compareRuntimeProfiles,
|
|
6
|
+
createPerfHistoryEntry,
|
|
7
|
+
defaultPerfHistoryDirectory,
|
|
8
|
+
diagnoseRuntimeProfile,
|
|
9
|
+
diffMemorySnapshots,
|
|
10
|
+
extractPerfMetrics,
|
|
11
|
+
forceGc,
|
|
12
|
+
formatHttpMemoryLabReport,
|
|
13
|
+
formatPerfBaselineComparison,
|
|
14
|
+
formatPerformanceReport,
|
|
15
|
+
formatRuntimeAbReport,
|
|
16
|
+
formatRuntimeSoakReport,
|
|
17
|
+
hasGc,
|
|
18
|
+
loadPerfBaseline,
|
|
19
|
+
makePerfRecorder,
|
|
20
|
+
profileHttpLayers,
|
|
21
|
+
profileHttpMemoryLab,
|
|
22
|
+
profileMemoryRetention,
|
|
23
|
+
profileRuntimeAb,
|
|
24
|
+
profileRuntimePrimitives,
|
|
25
|
+
profileRuntimeSoak,
|
|
26
|
+
readPerfHistory,
|
|
27
|
+
recommendPerformance,
|
|
28
|
+
recordPerfHistoryRun,
|
|
29
|
+
runBrassPerformanceProfile,
|
|
30
|
+
savePerfBaseline,
|
|
31
|
+
summarizePerfEvents,
|
|
32
|
+
writePerfHistoryEntry
|
|
33
|
+
} from "../chunk-HLWLMW2F.mjs";
|
|
34
|
+
import "../chunk-EOC4UHBS.mjs";
|
|
35
|
+
import "../chunk-7CMJS3QE.mjs";
|
|
36
|
+
import "../chunk-5VRJNBLZ.mjs";
|
|
37
|
+
import "../chunk-MOO4L7F4.mjs";
|
|
38
|
+
import "../chunk-FHQGHPMO.mjs";
|
|
39
|
+
import "../chunk-B5JD23U7.mjs";
|
|
40
|
+
import "../chunk-2HQTDLHF.mjs";
|
|
41
|
+
import "../chunk-A2OM6NEH.mjs";
|
|
42
|
+
import "../chunk-DNFO2EIZ.mjs";
|
|
43
|
+
import "../chunk-MT3OWDPC.mjs";
|
|
44
|
+
import "../chunk-EJ6BPYVR.mjs";
|
|
45
|
+
import "../chunk-PWC3RBQE.mjs";
|
|
46
|
+
import "../chunk-GYM3LLGS.mjs";
|
|
47
|
+
import "../chunk-36I3M4UC.mjs";
|
|
48
|
+
import "../chunk-DNFJLJMW.mjs";
|
|
49
|
+
import "../chunk-Y6FXYEAI.mjs";
|
|
50
|
+
|
|
51
|
+
// src/perf/budget.ts
|
|
52
|
+
async function runRuntimePerfBudget(options = {}) {
|
|
53
|
+
const ab = await profileRuntimeAb({
|
|
54
|
+
...options,
|
|
55
|
+
thresholds: {
|
|
56
|
+
maxRegressionPercent: options.thresholds?.maxRegressionPercent ?? 50,
|
|
57
|
+
minSignificantDeltaPercent: options.thresholds?.minSignificantDeltaPercent ?? 5
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const minOpsPerSecond = positiveNumber(options.minOpsPerSecond, 1e4);
|
|
61
|
+
const maxHeapDeltaMb = positiveNumber(options.maxHeapDeltaMb, 32);
|
|
62
|
+
const violations = [];
|
|
63
|
+
for (const violation of ab.budgetViolations) {
|
|
64
|
+
violations.push({ area: "regression", message: violation });
|
|
65
|
+
}
|
|
66
|
+
for (const result of ab.candidate.results) {
|
|
67
|
+
if (result.units >= 1e3 && result.operationsPerSecond < minOpsPerSecond) {
|
|
68
|
+
violations.push({
|
|
69
|
+
area: "throughput",
|
|
70
|
+
message: `${result.name} throughput ${result.operationsPerSecond} ops/s is below ${minOpsPerSecond} ops/s`
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (ab.memory.delta.heapUsedMb > maxHeapDeltaMb) {
|
|
75
|
+
violations.push({
|
|
76
|
+
area: "memory",
|
|
77
|
+
message: `runtime A/B heap delta ${ab.memory.delta.heapUsedMb}MB exceeds ${maxHeapDeltaMb}MB`
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return Object.freeze({
|
|
81
|
+
ab,
|
|
82
|
+
passed: violations.length === 0,
|
|
83
|
+
violations: Object.freeze(violations.map((item) => Object.freeze(item)))
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function formatRuntimePerfBudgetReport(report) {
|
|
87
|
+
const lines = [];
|
|
88
|
+
lines.push(`Runtime performance budget: ${report.passed ? "pass" : "fail"}`);
|
|
89
|
+
lines.push(`baseline=${report.ab.baselineVariant} candidate=${report.ab.candidateVariant}`);
|
|
90
|
+
for (const comparison of report.ab.comparisons) {
|
|
91
|
+
const sign = comparison.deltaPercent >= 0 ? "+" : "";
|
|
92
|
+
lines.push(`- ${comparison.primitive}: ${sign}${comparison.deltaPercent}%`);
|
|
93
|
+
}
|
|
94
|
+
if (report.violations.length > 0) {
|
|
95
|
+
lines.push("");
|
|
96
|
+
lines.push("Violations");
|
|
97
|
+
for (const violation of report.violations) {
|
|
98
|
+
lines.push(`- [${violation.area}] ${violation.message}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return lines.join("\n");
|
|
102
|
+
}
|
|
103
|
+
function positiveNumber(value, fallback) {
|
|
104
|
+
if (value === void 0 || !Number.isFinite(value)) return fallback;
|
|
105
|
+
return Math.max(0, value);
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
HTTP_PROFILE_VARIANTS,
|
|
109
|
+
captureMemorySnapshot,
|
|
110
|
+
comparePerfToBaseline,
|
|
111
|
+
compareRuntimeProfiles,
|
|
112
|
+
createPerfHistoryEntry,
|
|
113
|
+
defaultPerfHistoryDirectory,
|
|
114
|
+
diagnoseRuntimeProfile,
|
|
115
|
+
diffMemorySnapshots,
|
|
116
|
+
extractPerfMetrics,
|
|
117
|
+
forceGc,
|
|
118
|
+
formatHttpMemoryLabReport,
|
|
119
|
+
formatPerfBaselineComparison,
|
|
120
|
+
formatPerformanceReport,
|
|
121
|
+
formatRuntimeAbReport,
|
|
122
|
+
formatRuntimePerfBudgetReport,
|
|
123
|
+
formatRuntimeSoakReport,
|
|
124
|
+
hasGc,
|
|
125
|
+
loadPerfBaseline,
|
|
126
|
+
makePerfRecorder,
|
|
127
|
+
profileHttpLayers,
|
|
128
|
+
profileHttpMemoryLab,
|
|
129
|
+
profileMemoryRetention,
|
|
130
|
+
profileRuntimeAb,
|
|
131
|
+
profileRuntimePrimitives,
|
|
132
|
+
profileRuntimeSoak,
|
|
133
|
+
readPerfHistory,
|
|
134
|
+
recommendPerformance,
|
|
135
|
+
recordPerfHistoryRun,
|
|
136
|
+
runBrassPerformanceProfile,
|
|
137
|
+
runRuntimePerfBudget,
|
|
138
|
+
savePerfBaseline,
|
|
139
|
+
summarizePerfEvents,
|
|
140
|
+
writePerfHistoryEntry
|
|
141
|
+
};
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { A as Async, R as RuntimeHooks, a as RuntimeEmitContext } from './effect-DIUHZ9IN.js';
|
|
2
|
+
|
|
3
|
+
type CircuitBreakerState = "closed" | "open" | "half-open";
|
|
4
|
+
type CircuitBreakerError = {
|
|
5
|
+
readonly _tag: "CircuitBreakerOpen";
|
|
6
|
+
readonly openSince: number;
|
|
7
|
+
readonly failures: number;
|
|
8
|
+
};
|
|
9
|
+
type CircuitBreakerConfig = {
|
|
10
|
+
/** Number of consecutive failures before opening the circuit. Default: 5 */
|
|
11
|
+
readonly failureThreshold?: number;
|
|
12
|
+
/** Time in ms to wait before transitioning from OPEN to HALF_OPEN. Default: 30000 */
|
|
13
|
+
readonly resetTimeoutMs?: number;
|
|
14
|
+
/** Number of successes in HALF_OPEN needed to close the circuit. Default: 1 */
|
|
15
|
+
readonly successThreshold?: number;
|
|
16
|
+
/** Custom predicate: should this error count as a failure? Default: all errors count. */
|
|
17
|
+
readonly isFailure?: (error: unknown) => boolean;
|
|
18
|
+
/** Called on state transitions (for observability). */
|
|
19
|
+
readonly onStateChange?: (from: CircuitBreakerState, to: CircuitBreakerState) => void;
|
|
20
|
+
};
|
|
21
|
+
type CircuitBreakerStats = {
|
|
22
|
+
readonly state: CircuitBreakerState;
|
|
23
|
+
readonly failures: number;
|
|
24
|
+
readonly successes: number;
|
|
25
|
+
readonly totalRequests: number;
|
|
26
|
+
readonly totalFailures: number;
|
|
27
|
+
readonly totalSuccesses: number;
|
|
28
|
+
readonly totalRejected: number;
|
|
29
|
+
readonly lastFailureTime: number | null;
|
|
30
|
+
readonly lastSuccessTime: number | null;
|
|
31
|
+
};
|
|
32
|
+
type CircuitBreaker = {
|
|
33
|
+
/** Current state of the circuit breaker. */
|
|
34
|
+
readonly state: () => CircuitBreakerState;
|
|
35
|
+
/** Run an effect through the circuit breaker. */
|
|
36
|
+
readonly protect: <R, E, A>(effect: Async<R, E, A>) => Async<R, E | CircuitBreakerError, A>;
|
|
37
|
+
/** Get current stats. */
|
|
38
|
+
readonly stats: () => CircuitBreakerStats;
|
|
39
|
+
/** Manually reset to closed state. */
|
|
40
|
+
readonly reset: () => void;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Creates a circuit breaker.
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* const breaker = makeCircuitBreaker({ failureThreshold: 3, resetTimeoutMs: 10000 });
|
|
47
|
+
*
|
|
48
|
+
* // Protect an effect:
|
|
49
|
+
* const result = await run(breaker.protect(callExternalService()));
|
|
50
|
+
* // Throws CircuitBreakerOpen if circuit is open
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare function makeCircuitBreaker(config?: CircuitBreakerConfig): CircuitBreaker;
|
|
54
|
+
|
|
55
|
+
type RuntimeTimerId = unknown;
|
|
56
|
+
type RuntimeClock = {
|
|
57
|
+
readonly now: () => number;
|
|
58
|
+
readonly setTimeout: (task: () => void, ms: number) => RuntimeTimerId;
|
|
59
|
+
readonly clearTimeout: (timer: RuntimeTimerId) => void;
|
|
60
|
+
};
|
|
61
|
+
type RuntimeClockEnv = {
|
|
62
|
+
readonly brass?: {
|
|
63
|
+
readonly clock?: RuntimeClock;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
declare const liveClock: RuntimeClock;
|
|
67
|
+
declare function runtimeClockFromEnv(env: unknown): RuntimeClock;
|
|
68
|
+
|
|
69
|
+
type ScheduleDecision = {
|
|
70
|
+
readonly continue: boolean;
|
|
71
|
+
readonly delayMs: number;
|
|
72
|
+
readonly attempt?: number;
|
|
73
|
+
readonly elapsedMs?: number;
|
|
74
|
+
readonly reason?: string;
|
|
75
|
+
readonly name?: string;
|
|
76
|
+
};
|
|
77
|
+
type ScheduleJitterOptions = {
|
|
78
|
+
/** 1 means full jitter in [0, delay], 0.2 means +/-20% around delay. */
|
|
79
|
+
readonly factor?: number;
|
|
80
|
+
/** Deterministic hook for tests. Defaults to Math.random. */
|
|
81
|
+
readonly random?: () => number;
|
|
82
|
+
};
|
|
83
|
+
type ScheduleStepContext = {
|
|
84
|
+
readonly clock: RuntimeClock;
|
|
85
|
+
readonly startedAtMs: number;
|
|
86
|
+
readonly attempt: number;
|
|
87
|
+
readonly name?: string;
|
|
88
|
+
};
|
|
89
|
+
type ScheduleObserverEvent<I, O> = {
|
|
90
|
+
readonly name?: string;
|
|
91
|
+
readonly input: I;
|
|
92
|
+
readonly output: O;
|
|
93
|
+
readonly decision: ScheduleDecision;
|
|
94
|
+
readonly attempt: number;
|
|
95
|
+
readonly elapsedMs: number;
|
|
96
|
+
readonly state: unknown;
|
|
97
|
+
readonly nextState: unknown;
|
|
98
|
+
readonly timestamp: number;
|
|
99
|
+
};
|
|
100
|
+
type ScheduleObserver<I, O> = (event: ScheduleObserverEvent<I, O>) => void;
|
|
101
|
+
type ScheduleDriverDecision<O> = {
|
|
102
|
+
readonly continue: boolean;
|
|
103
|
+
readonly delayMs: number;
|
|
104
|
+
readonly output: O;
|
|
105
|
+
readonly decision: ScheduleDecision;
|
|
106
|
+
readonly attempt: number;
|
|
107
|
+
readonly elapsedMs: number;
|
|
108
|
+
readonly state: unknown;
|
|
109
|
+
};
|
|
110
|
+
type ScheduleDriverSnapshot<O = unknown> = {
|
|
111
|
+
readonly name?: string;
|
|
112
|
+
readonly attempt: number;
|
|
113
|
+
readonly elapsedMs: number;
|
|
114
|
+
readonly state: unknown;
|
|
115
|
+
readonly last?: ScheduleDriverDecision<O>;
|
|
116
|
+
};
|
|
117
|
+
type ScheduleDriverOptions<I = unknown, O = unknown> = {
|
|
118
|
+
readonly name?: string;
|
|
119
|
+
readonly clock?: RuntimeClock;
|
|
120
|
+
readonly startedAtMs?: number;
|
|
121
|
+
readonly onDecision?: ScheduleObserver<I, O>;
|
|
122
|
+
readonly hooks?: RuntimeHooks;
|
|
123
|
+
readonly emitContext?: RuntimeEmitContext;
|
|
124
|
+
readonly captureInput?: boolean;
|
|
125
|
+
readonly captureOutput?: boolean;
|
|
126
|
+
};
|
|
127
|
+
type ScheduleDriver<I, O> = {
|
|
128
|
+
readonly next: (input: I) => ScheduleDriverDecision<O>;
|
|
129
|
+
readonly reset: () => void;
|
|
130
|
+
readonly snapshot: () => ScheduleDriverSnapshot<O>;
|
|
131
|
+
readonly state: () => unknown;
|
|
132
|
+
readonly last: () => ScheduleDriverDecision<O> | undefined;
|
|
133
|
+
};
|
|
134
|
+
/** Retry/repeat up to N times with no delay. */
|
|
135
|
+
declare function recurs(n: number): Schedule<unknown, number>;
|
|
136
|
+
/** Continue forever with no delay. */
|
|
137
|
+
declare function forever(): Schedule<unknown, number>;
|
|
138
|
+
/** Never continue. */
|
|
139
|
+
declare function never(): Schedule<unknown, number>;
|
|
140
|
+
/** Continue exactly once. */
|
|
141
|
+
declare function once(): Schedule<unknown, number>;
|
|
142
|
+
/** Fixed delay between each retry/repeat. */
|
|
143
|
+
declare function fixed(delayMs: number): Schedule<unknown, number>;
|
|
144
|
+
/** Alias for fixed delay schedules. */
|
|
145
|
+
declare const spaced: typeof fixed;
|
|
146
|
+
/** Exponential backoff: delay doubles each time, capped at maxDelayMs. */
|
|
147
|
+
declare function exponential(baseMs: number, maxMs?: number): Schedule<unknown, number>;
|
|
148
|
+
/** Linear backoff: base, 2*base, 3*base... capped at maxDelayMs. */
|
|
149
|
+
declare function linear(baseMs: number, maxMs?: number): Schedule<unknown, number>;
|
|
150
|
+
/** Fibonacci backoff: base, base, 2*base, 3*base, 5*base, capped at maxDelayMs. */
|
|
151
|
+
declare function fibonacci(baseMs: number, maxMs?: number): Schedule<unknown, number>;
|
|
152
|
+
/** Exponential backoff with full jitter (random in [0, delay]). */
|
|
153
|
+
declare function jittered(baseMs: number, maxMs?: number): Schedule<unknown, number>;
|
|
154
|
+
/** Stop after a total elapsed time. */
|
|
155
|
+
declare function elapsed(maxMs: number): Schedule<unknown, number>;
|
|
156
|
+
/** Only continue while a predicate holds on the input. */
|
|
157
|
+
declare function whileInput<I>(pred: (input: I) => boolean): Schedule<I, I>;
|
|
158
|
+
/** Continue until the input predicate becomes true. */
|
|
159
|
+
declare function untilInput<I>(pred: (input: I) => boolean): Schedule<I, I>;
|
|
160
|
+
/** Limit a schedule to N repetitions. */
|
|
161
|
+
declare function take<I, O>(schedule: Schedule<I, O>, n: number): Schedule<I, O>;
|
|
162
|
+
/** Transform schedule output while preserving decisions and state. */
|
|
163
|
+
declare function map<I, O, O2>(schedule: Schedule<I, O>, f: (output: O) => O2): Schedule<I, O2>;
|
|
164
|
+
/** Transform schedule input before it reaches the wrapped schedule. */
|
|
165
|
+
declare function contramap<I0, I, O>(schedule: Schedule<I, O>, f: (input: I0) => I): Schedule<I0, O>;
|
|
166
|
+
/** Add jitter to any schedule's delay. */
|
|
167
|
+
declare function jitteredSchedule<I, O>(schedule: Schedule<I, O>, options?: number | ScheduleJitterOptions): Schedule<I, O>;
|
|
168
|
+
declare const jitter: typeof jitteredSchedule;
|
|
169
|
+
/**
|
|
170
|
+
* Reset a schedule's internal state after a rolling time window.
|
|
171
|
+
* Useful for retry/polling policies that should forgive old bursts.
|
|
172
|
+
*/
|
|
173
|
+
declare function windowed<I, O>(schedule: Schedule<I, O>, windowMs: number, clock?: () => number): Schedule<I, O>;
|
|
174
|
+
/** Cap a schedule's delay without changing its state or output. */
|
|
175
|
+
declare function maxDelay<I, O>(schedule: Schedule<I, O>, maxMs: number): Schedule<I, O>;
|
|
176
|
+
/** Stop a schedule after a total elapsed runtime-clock budget. */
|
|
177
|
+
declare function maxElapsed<I, O>(schedule: Schedule<I, O>, maxMs: number): Schedule<I, O>;
|
|
178
|
+
declare const upTo: typeof maxElapsed;
|
|
179
|
+
/** Continue while a predicate holds on the wrapped schedule output. */
|
|
180
|
+
declare function whileOutput<I, O>(schedule: Schedule<I, O>, pred: (output: O) => boolean): Schedule<I, O>;
|
|
181
|
+
/** Continue until a predicate holds on the wrapped schedule output. */
|
|
182
|
+
declare function untilOutput<I, O>(schedule: Schedule<I, O>, pred: (output: O) => boolean): Schedule<I, O>;
|
|
183
|
+
/** Attach an observability name to a schedule. */
|
|
184
|
+
declare function named<I, O>(name: string, schedule: Schedule<I, O>): Schedule<I, O>;
|
|
185
|
+
/** Observe each schedule decision without changing semantics. */
|
|
186
|
+
declare function tapDecision<I, O>(schedule: Schedule<I, O>, tap: ScheduleObserver<I, O>): Schedule<I, O>;
|
|
187
|
+
/** Compose two schedules: use the first, then switch to the second. */
|
|
188
|
+
declare function andThen<I, O1, O2>(first: Schedule<I, O1>, second: Schedule<I, O2>): Schedule<I, O1 | O2>;
|
|
189
|
+
/** Run both schedules and continue while BOTH say continue. Use max delay. */
|
|
190
|
+
declare function intersect<I, O1, O2>(left: Schedule<I, O1>, right: Schedule<I, O2>): Schedule<I, [O1, O2]>;
|
|
191
|
+
/** Run both schedules and continue while EITHER says continue. Use min delay. */
|
|
192
|
+
declare function union<I, O1, O2>(left: Schedule<I, O1>, right: Schedule<I, O2>): Schedule<I, [O1, O2]>;
|
|
193
|
+
declare function makeScheduleDriver<I, O>(schedule: Schedule<I, O>, options?: ScheduleDriverOptions<I, O>): ScheduleDriver<I, O>;
|
|
194
|
+
declare const scheduleDriver: typeof makeScheduleDriver;
|
|
195
|
+
declare function runSchedule<I, O>(schedule: Schedule<I, O>, inputs: Iterable<I>, options?: ScheduleDriverOptions<I, O>): ScheduleDriverDecision<O>[];
|
|
196
|
+
/**
|
|
197
|
+
* Retry an effect according to a schedule.
|
|
198
|
+
* The schedule receives the error as input on each failure.
|
|
199
|
+
*/
|
|
200
|
+
declare function retryWithSchedule<R, E, A, O>(effect: Async<R, E, A>, schedule: Schedule<E, O>, options?: ScheduleDriverOptions<E, O>): Async<R, E, A>;
|
|
201
|
+
declare const retry: typeof retryWithSchedule;
|
|
202
|
+
/**
|
|
203
|
+
* Repeat an effect according to a schedule.
|
|
204
|
+
* The schedule receives the success value as input on each iteration.
|
|
205
|
+
* Returns the last successful value.
|
|
206
|
+
*/
|
|
207
|
+
declare function repeatWithSchedule<R, E, A, O>(effect: Async<R, E, A>, schedule: Schedule<A, O>, options?: ScheduleDriverOptions<A, O>): Async<R, E, A>;
|
|
208
|
+
declare const repeat: typeof repeatWithSchedule;
|
|
209
|
+
declare const poll: typeof repeatWithSchedule;
|
|
210
|
+
/**
|
|
211
|
+
* A Schedule<I, O> takes an input I (typically the error or output of an effect)
|
|
212
|
+
* and decides whether to continue and with what delay.
|
|
213
|
+
*/
|
|
214
|
+
type Schedule<I, O> = {
|
|
215
|
+
readonly _tag: "Schedule";
|
|
216
|
+
readonly name?: string;
|
|
217
|
+
/** Initial state */
|
|
218
|
+
readonly initial: (context?: ScheduleStepContext) => any;
|
|
219
|
+
/** Given current state and input, produce a decision and next state */
|
|
220
|
+
readonly step: (state: any, input: I, context?: ScheduleStepContext) => [ScheduleDecision, any, O];
|
|
221
|
+
};
|
|
222
|
+
declare const Schedule: Readonly<{
|
|
223
|
+
driver: typeof makeScheduleDriver;
|
|
224
|
+
run: typeof runSchedule;
|
|
225
|
+
recurs: typeof recurs;
|
|
226
|
+
forever: typeof forever;
|
|
227
|
+
never: typeof never;
|
|
228
|
+
once: typeof once;
|
|
229
|
+
fixed: typeof fixed;
|
|
230
|
+
spaced: typeof fixed;
|
|
231
|
+
linear: typeof linear;
|
|
232
|
+
exponential: typeof exponential;
|
|
233
|
+
fibonacci: typeof fibonacci;
|
|
234
|
+
jittered: typeof jittered;
|
|
235
|
+
jitteredSchedule: typeof jitteredSchedule;
|
|
236
|
+
jitter: typeof jitteredSchedule;
|
|
237
|
+
elapsed: typeof elapsed;
|
|
238
|
+
whileInput: typeof whileInput;
|
|
239
|
+
untilInput: typeof untilInput;
|
|
240
|
+
whileOutput: typeof whileOutput;
|
|
241
|
+
untilOutput: typeof untilOutput;
|
|
242
|
+
take: typeof take;
|
|
243
|
+
map: typeof map;
|
|
244
|
+
contramap: typeof contramap;
|
|
245
|
+
maxDelay: typeof maxDelay;
|
|
246
|
+
maxElapsed: typeof maxElapsed;
|
|
247
|
+
upTo: typeof maxElapsed;
|
|
248
|
+
windowed: typeof windowed;
|
|
249
|
+
named: typeof named;
|
|
250
|
+
tapDecision: typeof tapDecision;
|
|
251
|
+
andThen: typeof andThen;
|
|
252
|
+
intersect: typeof intersect;
|
|
253
|
+
union: typeof union;
|
|
254
|
+
retry: typeof retryWithSchedule;
|
|
255
|
+
repeat: typeof repeatWithSchedule;
|
|
256
|
+
poll: typeof repeatWithSchedule;
|
|
257
|
+
}>;
|
|
258
|
+
|
|
259
|
+
export { upTo as $, liveClock as A, makeCircuitBreaker as B, type CircuitBreakerError as C, makeScheduleDriver as D, map as E, maxDelay as F, maxElapsed as G, named as H, never as I, once as J, poll as K, recurs as L, repeatWithSchedule as M, repeat as N, retryWithSchedule as O, retry as P, runSchedule as Q, type RuntimeClock as R, Schedule as S, runtimeClockFromEnv as T, scheduleDriver as U, spaced as V, take as W, tapDecision as X, union as Y, untilInput as Z, untilOutput as _, type ScheduleObserver as a, whileInput as a0, whileOutput as a1, windowed as a2, type CircuitBreakerStats as b, type CircuitBreaker as c, type CircuitBreakerConfig as d, type CircuitBreakerState as e, type RuntimeClockEnv as f, type RuntimeTimerId as g, type ScheduleDecision as h, type ScheduleDriver as i, type ScheduleDriverDecision as j, type ScheduleDriverOptions as k, type ScheduleDriverSnapshot as l, type ScheduleObserverEvent as m, type ScheduleStepContext as n, andThen as o, contramap as p, elapsed as q, exponential as r, fibonacci as s, fixed as t, forever as u, intersect as v, jitter as w, jittered as x, jitteredSchedule as y, linear as z };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _chunkCZIVE6NTcjs = require('../chunk-CZIVE6NT.cjs');
|
|
15
|
+
require('../chunk-OBGZSXTJ.cjs');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.ConfigValidationError = _chunkCZIVE6NTcjs.ConfigValidationError; exports.Schema = _chunkCZIVE6NTcjs.Schema; exports.SchemaValidationException = _chunkCZIVE6NTcjs.SchemaValidationException; exports.formatConfigError = _chunkCZIVE6NTcjs.formatConfigError; exports.formatIssues = _chunkCZIVE6NTcjs.formatIssues; exports.isConfigValidationError = _chunkCZIVE6NTcjs.isConfigValidationError; exports.isSchema = _chunkCZIVE6NTcjs.isSchema; exports.makeSchemaIssue = _chunkCZIVE6NTcjs.makeSchemaIssue; exports.parseConfig = _chunkCZIVE6NTcjs.parseConfig; exports.s = _chunkCZIVE6NTcjs.s; exports.schema = _chunkCZIVE6NTcjs.schema; exports.validateValue = _chunkCZIVE6NTcjs.validateValue;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
type SchemaPathPart = string | number;
|
|
2
|
+
type SchemaIssue = {
|
|
3
|
+
readonly path: readonly SchemaPathPart[];
|
|
4
|
+
readonly expected: string;
|
|
5
|
+
readonly received: string;
|
|
6
|
+
readonly message: string;
|
|
7
|
+
};
|
|
8
|
+
type SchemaResult<A> = {
|
|
9
|
+
readonly success: true;
|
|
10
|
+
readonly data: A;
|
|
11
|
+
} | {
|
|
12
|
+
readonly success: false;
|
|
13
|
+
readonly issues: readonly SchemaIssue[];
|
|
14
|
+
};
|
|
15
|
+
type AnySchema = Schema<any, any>;
|
|
16
|
+
type InferSchema<S> = S extends Schema<infer A, any> ? A : never;
|
|
17
|
+
type SchemaShape = Record<string, AnySchema>;
|
|
18
|
+
type OptionalKeys<Shape extends SchemaShape> = {
|
|
19
|
+
[K in keyof Shape]: Shape[K] extends Schema<any, true> ? K : never;
|
|
20
|
+
}[keyof Shape];
|
|
21
|
+
type RequiredKeys<Shape extends SchemaShape> = Exclude<keyof Shape, OptionalKeys<Shape>>;
|
|
22
|
+
type Simplify<T> = {
|
|
23
|
+
[K in keyof T]: T[K];
|
|
24
|
+
} & {};
|
|
25
|
+
type InferObject<Shape extends SchemaShape> = Simplify<{
|
|
26
|
+
[K in RequiredKeys<Shape>]: InferSchema<Shape[K]>;
|
|
27
|
+
} & {
|
|
28
|
+
[K in OptionalKeys<Shape>]?: Exclude<InferSchema<Shape[K]>, undefined>;
|
|
29
|
+
}>;
|
|
30
|
+
type JsonValidatorResult<A> = {
|
|
31
|
+
readonly success: true;
|
|
32
|
+
readonly data: A;
|
|
33
|
+
} | {
|
|
34
|
+
readonly success: false;
|
|
35
|
+
readonly error: string;
|
|
36
|
+
readonly issues?: readonly SchemaIssue[];
|
|
37
|
+
};
|
|
38
|
+
type JsonValidator<A> = (data: unknown) => JsonValidatorResult<A>;
|
|
39
|
+
type JsonSchemaLike<A> = Schema<A, any> | JsonValidator<A>;
|
|
40
|
+
type AnyJsonSchemaLike = JsonSchemaLike<any>;
|
|
41
|
+
type InferJsonSchema<V> = V extends Schema<infer A, any> ? A : V extends JsonValidator<infer A> ? A : never;
|
|
42
|
+
type StringSchemaOptions = {
|
|
43
|
+
readonly minLength?: number;
|
|
44
|
+
readonly maxLength?: number;
|
|
45
|
+
readonly pattern?: RegExp;
|
|
46
|
+
readonly name?: string;
|
|
47
|
+
};
|
|
48
|
+
type NumberSchemaOptions = {
|
|
49
|
+
readonly min?: number;
|
|
50
|
+
readonly max?: number;
|
|
51
|
+
readonly int?: boolean;
|
|
52
|
+
readonly finite?: boolean;
|
|
53
|
+
readonly name?: string;
|
|
54
|
+
};
|
|
55
|
+
type ObjectSchemaOptions = {
|
|
56
|
+
readonly unknownKeys?: "strip" | "passthrough" | "strict";
|
|
57
|
+
readonly name?: string;
|
|
58
|
+
};
|
|
59
|
+
declare class SchemaValidationException extends Error {
|
|
60
|
+
readonly issues: readonly SchemaIssue[];
|
|
61
|
+
constructor(issues: readonly SchemaIssue[]);
|
|
62
|
+
}
|
|
63
|
+
declare class ConfigValidationError extends Error {
|
|
64
|
+
readonly _tag = "ConfigValidationError";
|
|
65
|
+
readonly configName: string;
|
|
66
|
+
readonly issues: readonly SchemaIssue[];
|
|
67
|
+
constructor(configName: string, issues: readonly SchemaIssue[]);
|
|
68
|
+
}
|
|
69
|
+
declare function isConfigValidationError(error: unknown): error is ConfigValidationError;
|
|
70
|
+
declare function formatConfigError(error: unknown): string;
|
|
71
|
+
declare const makeSchemaIssue: (path: readonly SchemaPathPart[], expected: string, received: unknown, message?: string) => SchemaIssue;
|
|
72
|
+
declare function formatIssues(issues: readonly SchemaIssue[]): string;
|
|
73
|
+
declare function stringSchema(options?: StringSchemaOptions): Schema<string>;
|
|
74
|
+
declare function nonEmptyStringSchema(options?: Omit<StringSchemaOptions, "minLength">): Schema<string>;
|
|
75
|
+
declare function emailSchema(): Schema<string>;
|
|
76
|
+
declare function uuidSchema(): Schema<string>;
|
|
77
|
+
declare function urlSchema(): Schema<string>;
|
|
78
|
+
declare function dateIsoSchema(): Schema<string>;
|
|
79
|
+
declare function numberSchema(options?: NumberSchemaOptions): Schema<number>;
|
|
80
|
+
declare function intSchema(options?: Omit<NumberSchemaOptions, "int">): Schema<number>;
|
|
81
|
+
declare function positiveSchema(options?: NumberSchemaOptions): Schema<number>;
|
|
82
|
+
declare function booleanSchema(name?: string): Schema<boolean>;
|
|
83
|
+
declare function unknownSchema(): Schema<unknown>;
|
|
84
|
+
declare function anySchema(): Schema<any>;
|
|
85
|
+
declare function literalSchema<const Value extends string | number | boolean | null>(value: Value): Schema<Value>;
|
|
86
|
+
declare function enumSchema<const Values extends readonly [string | number, ...(string | number)[]]>(values: Values): Schema<Values[number]>;
|
|
87
|
+
declare function arraySchema<S extends AnySchema>(item: S): Schema<Array<InferSchema<S>>>;
|
|
88
|
+
declare function objectSchema<Shape extends SchemaShape>(shape: Shape, options?: ObjectSchemaOptions): Schema<InferObject<Shape>>;
|
|
89
|
+
declare function recordSchema<S extends AnySchema>(valueSchema: S): Schema<Record<string, InferSchema<S>>>;
|
|
90
|
+
declare function unionSchema<const Members extends readonly [AnySchema, AnySchema, ...AnySchema[]]>(members: Members): Schema<InferSchema<Members[number]>>;
|
|
91
|
+
declare function customSchema<A>(guard: (input: unknown) => input is A, expected: string, message?: string): Schema<A>;
|
|
92
|
+
declare const schema: Readonly<{
|
|
93
|
+
string: typeof stringSchema;
|
|
94
|
+
nonEmptyString: typeof nonEmptyStringSchema;
|
|
95
|
+
email: typeof emailSchema;
|
|
96
|
+
url: typeof urlSchema;
|
|
97
|
+
uuid: typeof uuidSchema;
|
|
98
|
+
dateIso: typeof dateIsoSchema;
|
|
99
|
+
number: typeof numberSchema;
|
|
100
|
+
int: typeof intSchema;
|
|
101
|
+
positive: typeof positiveSchema;
|
|
102
|
+
boolean: typeof booleanSchema;
|
|
103
|
+
literal: typeof literalSchema;
|
|
104
|
+
enum: typeof enumSchema;
|
|
105
|
+
array: typeof arraySchema;
|
|
106
|
+
object: typeof objectSchema;
|
|
107
|
+
record: typeof recordSchema;
|
|
108
|
+
union: typeof unionSchema;
|
|
109
|
+
optional: <S extends AnySchema>(inner: S) => Schema<InferSchema<S> | undefined, true>;
|
|
110
|
+
nullable: <S extends AnySchema>(inner: S) => Schema<InferSchema<S> | null, S["isOptional"]>;
|
|
111
|
+
unknown: typeof unknownSchema;
|
|
112
|
+
any: typeof anySchema;
|
|
113
|
+
custom: typeof customSchema;
|
|
114
|
+
}>;
|
|
115
|
+
declare const s: Readonly<{
|
|
116
|
+
string: typeof stringSchema;
|
|
117
|
+
nonEmptyString: typeof nonEmptyStringSchema;
|
|
118
|
+
email: typeof emailSchema;
|
|
119
|
+
url: typeof urlSchema;
|
|
120
|
+
uuid: typeof uuidSchema;
|
|
121
|
+
dateIso: typeof dateIsoSchema;
|
|
122
|
+
number: typeof numberSchema;
|
|
123
|
+
int: typeof intSchema;
|
|
124
|
+
positive: typeof positiveSchema;
|
|
125
|
+
boolean: typeof booleanSchema;
|
|
126
|
+
literal: typeof literalSchema;
|
|
127
|
+
enum: typeof enumSchema;
|
|
128
|
+
array: typeof arraySchema;
|
|
129
|
+
object: typeof objectSchema;
|
|
130
|
+
record: typeof recordSchema;
|
|
131
|
+
union: typeof unionSchema;
|
|
132
|
+
optional: <S extends AnySchema>(inner: S) => Schema<InferSchema<S> | undefined, true>;
|
|
133
|
+
nullable: <S extends AnySchema>(inner: S) => Schema<InferSchema<S> | null, S["isOptional"]>;
|
|
134
|
+
unknown: typeof unknownSchema;
|
|
135
|
+
any: typeof anySchema;
|
|
136
|
+
custom: typeof customSchema;
|
|
137
|
+
}>;
|
|
138
|
+
type Schema<A, Optional extends boolean = false> = {
|
|
139
|
+
readonly _tag: "Schema";
|
|
140
|
+
readonly kind: string;
|
|
141
|
+
readonly name?: string;
|
|
142
|
+
readonly isOptional: Optional;
|
|
143
|
+
readonly _parse: (input: unknown, path: readonly SchemaPathPart[]) => SchemaResult<A>;
|
|
144
|
+
readonly safeParse: (input: unknown) => SchemaResult<A>;
|
|
145
|
+
readonly parse: (input: unknown) => A;
|
|
146
|
+
readonly optional: () => Schema<A | undefined, true>;
|
|
147
|
+
readonly nullable: () => Schema<A | null, Optional>;
|
|
148
|
+
readonly array: () => Schema<A[], false>;
|
|
149
|
+
readonly refine: (predicate: (value: A) => boolean, message?: string) => Schema<A, Optional>;
|
|
150
|
+
readonly transform: <B>(fn: (value: A) => B, expected?: string) => Schema<B, false>;
|
|
151
|
+
};
|
|
152
|
+
declare const Schema: Readonly<{
|
|
153
|
+
string: typeof stringSchema;
|
|
154
|
+
nonEmptyString: typeof nonEmptyStringSchema;
|
|
155
|
+
email: typeof emailSchema;
|
|
156
|
+
url: typeof urlSchema;
|
|
157
|
+
uuid: typeof uuidSchema;
|
|
158
|
+
dateIso: typeof dateIsoSchema;
|
|
159
|
+
number: typeof numberSchema;
|
|
160
|
+
int: typeof intSchema;
|
|
161
|
+
positive: typeof positiveSchema;
|
|
162
|
+
boolean: typeof booleanSchema;
|
|
163
|
+
literal: typeof literalSchema;
|
|
164
|
+
enum: typeof enumSchema;
|
|
165
|
+
array: typeof arraySchema;
|
|
166
|
+
object: typeof objectSchema;
|
|
167
|
+
record: typeof recordSchema;
|
|
168
|
+
union: typeof unionSchema;
|
|
169
|
+
optional: <S extends AnySchema>(inner: S) => Schema<InferSchema<S> | undefined, true>;
|
|
170
|
+
nullable: <S extends AnySchema>(inner: S) => Schema<InferSchema<S> | null, S["isOptional"]>;
|
|
171
|
+
unknown: typeof unknownSchema;
|
|
172
|
+
any: typeof anySchema;
|
|
173
|
+
custom: typeof customSchema;
|
|
174
|
+
}>;
|
|
175
|
+
declare function isSchema(value: unknown): value is AnySchema;
|
|
176
|
+
declare function validateValue<A>(data: unknown, validator: JsonSchemaLike<A>): SchemaResult<A>;
|
|
177
|
+
declare function parseConfig<A>(configName: string, validator: JsonSchemaLike<A>, value: unknown): A;
|
|
178
|
+
|
|
179
|
+
export { type AnyJsonSchemaLike, type AnySchema, ConfigValidationError, type InferJsonSchema, type InferObject, type InferSchema, type JsonSchemaLike, type JsonValidator, type JsonValidatorResult, type NumberSchemaOptions, type ObjectSchemaOptions, Schema, type SchemaIssue, type SchemaPathPart, type SchemaResult, type SchemaShape, SchemaValidationException, type StringSchemaOptions, formatConfigError, formatIssues, isConfigValidationError, isSchema, makeSchemaIssue, parseConfig, s, schema, validateValue };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigValidationError,
|
|
3
|
+
Schema,
|
|
4
|
+
SchemaValidationException,
|
|
5
|
+
formatConfigError,
|
|
6
|
+
formatIssues,
|
|
7
|
+
isConfigValidationError,
|
|
8
|
+
isSchema,
|
|
9
|
+
makeSchemaIssue,
|
|
10
|
+
parseConfig,
|
|
11
|
+
s,
|
|
12
|
+
schema,
|
|
13
|
+
validateValue
|
|
14
|
+
} from "../chunk-C3MDXTRZ.js";
|
|
15
|
+
import "../chunk-3RG5ZIWI.js";
|
|
16
|
+
export {
|
|
17
|
+
ConfigValidationError,
|
|
18
|
+
Schema,
|
|
19
|
+
SchemaValidationException,
|
|
20
|
+
formatConfigError,
|
|
21
|
+
formatIssues,
|
|
22
|
+
isConfigValidationError,
|
|
23
|
+
isSchema,
|
|
24
|
+
makeSchemaIssue,
|
|
25
|
+
parseConfig,
|
|
26
|
+
s,
|
|
27
|
+
schema,
|
|
28
|
+
validateValue
|
|
29
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigValidationError,
|
|
3
|
+
Schema,
|
|
4
|
+
SchemaValidationException,
|
|
5
|
+
formatConfigError,
|
|
6
|
+
formatIssues,
|
|
7
|
+
isConfigValidationError,
|
|
8
|
+
isSchema,
|
|
9
|
+
makeSchemaIssue,
|
|
10
|
+
parseConfig,
|
|
11
|
+
s,
|
|
12
|
+
schema,
|
|
13
|
+
validateValue
|
|
14
|
+
} from "../chunk-DNFJLJMW.mjs";
|
|
15
|
+
import "../chunk-Y6FXYEAI.mjs";
|
|
16
|
+
export {
|
|
17
|
+
ConfigValidationError,
|
|
18
|
+
Schema,
|
|
19
|
+
SchemaValidationException,
|
|
20
|
+
formatConfigError,
|
|
21
|
+
formatIssues,
|
|
22
|
+
isConfigValidationError,
|
|
23
|
+
isSchema,
|
|
24
|
+
makeSchemaIssue,
|
|
25
|
+
parseConfig,
|
|
26
|
+
s,
|
|
27
|
+
schema,
|
|
28
|
+
validateValue
|
|
29
|
+
};
|