@substrat-run/contracts 0.149.0 → 0.151.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/dist/control-plane.d.ts +4 -0
- package/dist/control-plane.d.ts.map +1 -1
- package/dist/deploy.d.ts +52 -5
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +129 -8
- package/dist/deploy.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/operations.d.ts +34 -0
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations.js +36 -0
- package/dist/operations.js.map +1 -1
- package/dist/permission.d.ts +8 -0
- package/dist/permission.d.ts.map +1 -1
- package/dist/permission.js +7 -0
- package/dist/permission.js.map +1 -1
- package/dist/request-trace.d.ts +295 -0
- package/dist/request-trace.d.ts.map +1 -0
- package/dist/request-trace.js +127 -0
- package/dist/request-trace.js.map +1 -0
- package/dist/trace-sink.d.ts +199 -0
- package/dist/trace-sink.d.ts.map +1 -0
- package/dist/trace-sink.js +50 -0
- package/dist/trace-sink.js.map +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** The `globalThis` slot a host reads its sink from. A registered symbol, so two copies of a package agree. */
|
|
2
|
+
export const TRACE_SINK_KEY = Symbol.for('substrat.trace-sink');
|
|
3
|
+
/** The most steps one trace keeps; later ones are counted in `stepsDropped`, not stored. */
|
|
4
|
+
export const TRACE_STEP_CAP = 500;
|
|
5
|
+
/** The step kinds, in the order a reader lists them. */
|
|
6
|
+
export const TRACE_STEP_TYPES = [
|
|
7
|
+
'check',
|
|
8
|
+
'sql',
|
|
9
|
+
'emit',
|
|
10
|
+
'log',
|
|
11
|
+
'validation',
|
|
12
|
+
'outbound',
|
|
13
|
+
'store',
|
|
14
|
+
'error',
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* One time axis per invocation, shared by whoever records a step.
|
|
18
|
+
*
|
|
19
|
+
* The HTTP layer starts the request and the scope host runs inside it, so each used to count
|
|
20
|
+
* from its own zero and a step from one could sort before the step that caused it. The layer
|
|
21
|
+
* that starts the request calls {@link markTraceStart}; every step is stamped with
|
|
22
|
+
* {@link traceOffsetMs}, which counts from that mark, or from its own first call when nothing
|
|
23
|
+
* marked one (a call that did not come through HTTP). {@link forgetTraceStart} releases it.
|
|
24
|
+
* Held on a `globalThis` slot, like the sink, so two copies of a package agree.
|
|
25
|
+
*/
|
|
26
|
+
const STARTS_KEY = Symbol.for('substrat.trace-starts');
|
|
27
|
+
function starts() {
|
|
28
|
+
const slots = globalThis;
|
|
29
|
+
return (slots[STARTS_KEY] ??= new Map());
|
|
30
|
+
}
|
|
31
|
+
/** Note that an invocation started now (or at `at`, on the `performance.now()` clock). */
|
|
32
|
+
export function markTraceStart(invocationId, at = performance.now()) {
|
|
33
|
+
const map = starts();
|
|
34
|
+
if (!map.has(invocationId))
|
|
35
|
+
map.set(invocationId, at);
|
|
36
|
+
}
|
|
37
|
+
/** Milliseconds since the invocation started, starting it now when nothing has. */
|
|
38
|
+
export function traceOffsetMs(invocationId) {
|
|
39
|
+
markTraceStart(invocationId);
|
|
40
|
+
return Math.max(0, Math.round(performance.now() - starts().get(invocationId)));
|
|
41
|
+
}
|
|
42
|
+
/** The invocation is over: release its start. */
|
|
43
|
+
export function forgetTraceStart(invocationId) {
|
|
44
|
+
starts().delete(invocationId);
|
|
45
|
+
}
|
|
46
|
+
/** The sink installed on this runtime, or `undefined` when tracing is off. */
|
|
47
|
+
export function installedTraceSink() {
|
|
48
|
+
return globalThis[TRACE_SINK_KEY];
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=trace-sink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-sink.js","sourceRoot":"","sources":["../src/trace-sink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AC9E,MAAM,UAAU,kBAAkB;IAChC,OAAQ,UAAsC,CAAC,cAAc,CAA0B,CAAC;AAC1F,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrat-run/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.151.0",
|
|
4
4
|
"description": "Substrat kernel contract schemas — Zod is the source of truth (master plan D-22); OAS/JSON Schema are emitted artifacts",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"./assistant-stream": {
|
|
37
37
|
"types": "./dist/assistant-stream.d.ts",
|
|
38
38
|
"default": "./dist/assistant-stream.js"
|
|
39
|
+
},
|
|
40
|
+
"./trace-sink": {
|
|
41
|
+
"types": "./dist/trace-sink.d.ts",
|
|
42
|
+
"default": "./dist/trace-sink.js"
|
|
39
43
|
}
|
|
40
44
|
},
|
|
41
45
|
"files": [
|
|
@@ -44,7 +48,7 @@
|
|
|
44
48
|
"devDependencies": {
|
|
45
49
|
"@types/node": "^22.20.5",
|
|
46
50
|
"typescript": "^7.0.0",
|
|
47
|
-
"vitest": "^5.0.
|
|
51
|
+
"vitest": "^5.0.5",
|
|
48
52
|
"zod": "^4.4.3"
|
|
49
53
|
},
|
|
50
54
|
"publishConfig": {
|