stitchkit 0.80.1 → 0.81.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/agent-runtime/provider-failure.d.ts.map +1 -1
- package/dist/agent-runtime-coding-tools.js +1 -1
- package/dist/agent-runtime-harness.js +7 -5
- package/dist/agent-runtime.js +15 -19
- package/dist/application/notification-outbox.d.ts +80 -0
- package/dist/application/notification-outbox.d.ts.map +1 -0
- package/dist/application/process-lifecycle.d.ts +166 -0
- package/dist/application/process-lifecycle.d.ts.map +1 -0
- package/dist/application/state-store.d.ts +18 -0
- package/dist/application/state-store.d.ts.map +1 -0
- package/dist/application.d.ts +3 -0
- package/dist/application.d.ts.map +1 -1
- package/dist/application.js +568 -11
- package/dist/browser/http.d.ts +14 -0
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/resumable.d.ts +6 -0
- package/dist/browser/resumable.d.ts.map +1 -1
- package/dist/cli.js +9 -7
- package/dist/contract/define.d.ts +27 -4
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/errors-factory.d.ts +22 -3
- package/dist/contract/errors-factory.d.ts.map +1 -1
- package/dist/contract/index.d.ts +2 -2
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/contract/index.js +1 -1
- package/dist/geo/index.d.ts +4 -0
- package/dist/geo/index.d.ts.map +1 -0
- package/dist/geo/maxmind.d.ts +4 -0
- package/dist/geo/maxmind.d.ts.map +1 -0
- package/dist/geo/resolver.d.ts +9 -0
- package/dist/geo/resolver.d.ts.map +1 -0
- package/dist/geo/types.d.ts +59 -0
- package/dist/geo/types.d.ts.map +1 -0
- package/dist/geo.d.ts +3 -0
- package/dist/geo.d.ts.map +1 -0
- package/dist/geo.js +245 -0
- package/dist/{index-9s6z8vgf.js → index-1dd82z59.js} +1 -1
- package/dist/{index-vwp69871.js → index-27487ay5.js} +4 -4
- package/dist/{index-7ag81v2f.js → index-27gm3d6g.js} +10 -321
- package/dist/{index-y01f4223.js → index-2bxcmqkb.js} +127 -43
- package/dist/{index-dxesg10d.js → index-3ds42w1w.js} +3 -3
- package/dist/index-3xwxfj4z.js +334 -0
- package/dist/{index-egaabxkz.js → index-5z8tezpx.js} +2 -2
- package/dist/{index-fxz0v7vg.js → index-7evdsyez.js} +1 -83
- package/dist/{index-xcetq6j3.js → index-90d7h2cr.js} +32 -13
- package/dist/{index-t0z5p5w6.js → index-apn8repm.js} +1 -1
- package/dist/{index-758zx2ha.js → index-dggwnnjv.js} +2 -2
- package/dist/{index-dwf1f2ap.js → index-f9mb610r.js} +1 -62
- package/dist/{index-5mtc969c.js → index-fwbkp2jn.js} +1 -1
- package/dist/index-p13mwz16.js +16 -0
- package/dist/{index-m9kzax52.js → index-p18f59zy.js} +21 -5
- package/dist/{index-hb5pf3s4.js → index-qmgs7y68.js} +1 -1
- package/dist/{index-2rwwmr7v.js → index-s4ckmrac.js} +1 -1
- package/dist/{index-h4pj6fta.js → index-s8cnx02s.js} +8 -5
- package/dist/{index-k9ay6v6d.js → index-vchzar7e.js} +74 -23
- package/dist/index-vsbzgd7b.js +84 -0
- package/dist/{index-dxjjv399.js → index-xbppf54a.js} +95 -15
- package/dist/index-y91ry9h2.js +4 -0
- package/dist/index-zcgf3gqf.js +83 -0
- package/dist/index.js +17 -13
- package/dist/internal/error-message.d.ts +3 -0
- package/dist/internal/error-message.d.ts.map +1 -0
- package/dist/internal/media-type.d.ts +8 -0
- package/dist/internal/media-type.d.ts.map +1 -0
- package/dist/internal/route-pattern.d.ts +21 -0
- package/dist/internal/route-pattern.d.ts.map +1 -1
- package/dist/node.js +9 -6
- package/dist/observability/audit.d.ts +28 -1
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/bounded-logger.d.ts +20 -0
- package/dist/observability/bounded-logger.d.ts.map +1 -0
- package/dist/observability/context.d.ts +12 -3
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/index.d.ts +3 -2
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/index.js +138 -8
- package/dist/observability/sanitize.d.ts +17 -0
- package/dist/observability/sanitize.d.ts.map +1 -1
- package/dist/primitives.js +1 -1
- package/dist/react/query-client.d.ts +33 -0
- package/dist/react/query-client.d.ts.map +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +83 -1
- package/dist/realtime/registry.d.ts +93 -0
- package/dist/realtime/registry.d.ts.map +1 -0
- package/dist/release/header.d.ts +9 -0
- package/dist/release/header.d.ts.map +1 -0
- package/dist/release/marker.d.ts +39 -0
- package/dist/release/marker.d.ts.map +1 -0
- package/dist/release/socket.d.ts +44 -0
- package/dist/release/socket.d.ts.map +1 -0
- package/dist/release/watcher.d.ts +66 -0
- package/dist/release/watcher.d.ts.map +1 -0
- package/dist/release.d.ts +15 -0
- package/dist/release.d.ts.map +1 -0
- package/dist/release.js +196 -0
- package/dist/remote.js +12 -7
- package/dist/server/context.d.ts +2 -1
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +17 -16
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/file-state-store.d.ts +23 -0
- package/dist/server/file-state-store.d.ts.map +1 -0
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/index.d.ts +5 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +469 -11
- package/dist/server/middleware/cookies.d.ts +33 -1
- package/dist/server/middleware/cookies.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +16 -1
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/openapi.d.ts.map +1 -1
- package/dist/server/release-signal.d.ts +35 -0
- package/dist/server/release-signal.d.ts.map +1 -0
- package/dist/server/router.d.ts.map +1 -1
- package/dist/server/types.d.ts +26 -2
- package/dist/server/types.d.ts.map +1 -1
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/testing.js +7 -4
- package/dist/tool-invoker.js +8 -6
- package/dist/tools/download-core.d.ts.map +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/view-file.d.ts.map +1 -1
- package/dist/tools.js +20 -16
- package/dist/tracking/attribution.d.ts +51 -0
- package/dist/tracking/attribution.d.ts.map +1 -0
- package/dist/tracking/beacon.d.ts +14 -0
- package/dist/tracking/beacon.d.ts.map +1 -0
- package/dist/tracking/clicks.d.ts +46 -0
- package/dist/tracking/clicks.d.ts.map +1 -0
- package/dist/tracking/client.d.ts +121 -0
- package/dist/tracking/client.d.ts.map +1 -0
- package/dist/tracking/contract.d.ts +46 -0
- package/dist/tracking/contract.d.ts.map +1 -0
- package/dist/tracking/delivery.d.ts +24 -0
- package/dist/tracking/delivery.d.ts.map +1 -0
- package/dist/tracking/host.d.ts +43 -0
- package/dist/tracking/host.d.ts.map +1 -0
- package/dist/tracking/once-per-page.d.ts +17 -0
- package/dist/tracking/once-per-page.d.ts.map +1 -0
- package/dist/tracking/outbox-storage-indexeddb.d.ts +12 -0
- package/dist/tracking/outbox-storage-indexeddb.d.ts.map +1 -0
- package/dist/tracking/outbox-storage-memory.d.ts +12 -0
- package/dist/tracking/outbox-storage-memory.d.ts.map +1 -0
- package/dist/tracking/outbox.d.ts +98 -0
- package/dist/tracking/outbox.d.ts.map +1 -0
- package/dist/tracking/schemas.d.ts +183 -0
- package/dist/tracking/schemas.d.ts.map +1 -0
- package/dist/tracking/scroll.d.ts +22 -0
- package/dist/tracking/scroll.d.ts.map +1 -0
- package/dist/tracking/sequence-reserve.d.ts +34 -0
- package/dist/tracking/sequence-reserve.d.ts.map +1 -0
- package/dist/tracking/server/active-interval.d.ts +26 -0
- package/dist/tracking/server/active-interval.d.ts.map +1 -0
- package/dist/tracking/server/bot.d.ts +9 -0
- package/dist/tracking/server/bot.d.ts.map +1 -0
- package/dist/tracking/server/disposition.d.ts +55 -0
- package/dist/tracking/server/disposition.d.ts.map +1 -0
- package/dist/tracking/server/hash.d.ts +13 -0
- package/dist/tracking/server/hash.d.ts.map +1 -0
- package/dist/tracking/server/presence.d.ts +27 -0
- package/dist/tracking/server/presence.d.ts.map +1 -0
- package/dist/tracking/server/visit-lease.d.ts +92 -0
- package/dist/tracking/server/visit-lease.d.ts.map +1 -0
- package/dist/tracking/visible-time.d.ts +38 -0
- package/dist/tracking/visible-time.d.ts.map +1 -0
- package/dist/tracking-server.d.ts +14 -0
- package/dist/tracking-server.d.ts.map +1 -0
- package/dist/tracking-server.js +173 -0
- package/dist/tracking.d.ts +24 -0
- package/dist/tracking.d.ts.map +1 -0
- package/dist/tracking.js +1090 -0
- package/llms-full.txt +938 -29
- package/llms.txt +4 -0
- package/package.json +25 -4
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getClientInfo,
|
|
3
|
+
resolveSocketIp
|
|
4
|
+
} from "./index-f9mb610r.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveTraceContext
|
|
7
|
+
} from "./index-zcgf3gqf.js";
|
|
8
|
+
import {
|
|
9
|
+
isUnsafeKey
|
|
10
|
+
} from "./index-kzfs85xp.js";
|
|
11
|
+
|
|
12
|
+
// src/observability/context.ts
|
|
13
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
14
|
+
var storage;
|
|
15
|
+
var requestStorage = () => {
|
|
16
|
+
storage ??= new AsyncLocalStorage;
|
|
17
|
+
return storage;
|
|
18
|
+
};
|
|
19
|
+
function runWithRequestContext(ctx, fn) {
|
|
20
|
+
return requestStorage().run(ctx, fn);
|
|
21
|
+
}
|
|
22
|
+
function getRequestContext() {
|
|
23
|
+
return requestStorage().getStore();
|
|
24
|
+
}
|
|
25
|
+
function getTraceId() {
|
|
26
|
+
return requestStorage().getStore()?.trace.traceId;
|
|
27
|
+
}
|
|
28
|
+
function getUserId() {
|
|
29
|
+
return requestStorage().getStore()?.userId;
|
|
30
|
+
}
|
|
31
|
+
function setRequestUser(userId) {
|
|
32
|
+
const ctx = requestStorage().getStore();
|
|
33
|
+
if (ctx)
|
|
34
|
+
ctx.userId = userId;
|
|
35
|
+
}
|
|
36
|
+
function setRequestEndpoint(serviceName, action) {
|
|
37
|
+
const ctx = requestStorage().getStore();
|
|
38
|
+
if (ctx) {
|
|
39
|
+
ctx.serviceName = serviceName;
|
|
40
|
+
if (action !== undefined)
|
|
41
|
+
ctx.action = action;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function setRequestDimensions(dimensions, options = {}) {
|
|
45
|
+
const ctx = requestStorage().getStore();
|
|
46
|
+
if (!ctx)
|
|
47
|
+
return;
|
|
48
|
+
const next = { ...ctx.dimensions };
|
|
49
|
+
for (const [key, value] of Object.entries(dimensions)) {
|
|
50
|
+
if (isUnsafeKey(key))
|
|
51
|
+
throw new Error('Request dimension name cannot be "__proto__"');
|
|
52
|
+
const exists = Object.hasOwn(next, key);
|
|
53
|
+
if (exists && options.collision === "preserve")
|
|
54
|
+
continue;
|
|
55
|
+
if (exists && options.collision === "error") {
|
|
56
|
+
throw new Error(`Request dimension "${key}" is already set`);
|
|
57
|
+
}
|
|
58
|
+
next[key] = value;
|
|
59
|
+
}
|
|
60
|
+
ctx.dimensions = next;
|
|
61
|
+
}
|
|
62
|
+
function setRequestError(error) {
|
|
63
|
+
const ctx = requestStorage().getStore();
|
|
64
|
+
if (ctx)
|
|
65
|
+
ctx.error = error;
|
|
66
|
+
}
|
|
67
|
+
function wrapInRequestContext(handler, options = {}) {
|
|
68
|
+
return (req, server) => {
|
|
69
|
+
const ctx = {
|
|
70
|
+
trace: resolveTraceContext(req),
|
|
71
|
+
source: "http",
|
|
72
|
+
method: req.method,
|
|
73
|
+
path: new URL(req.url, "http://localhost").pathname,
|
|
74
|
+
startedAt: process.hrtime.bigint(),
|
|
75
|
+
...getClientInfo(req, {
|
|
76
|
+
trustProxy: options.trustProxy,
|
|
77
|
+
socketIp: resolveSocketIp(req, server)
|
|
78
|
+
})
|
|
79
|
+
};
|
|
80
|
+
return runWithRequestContext(ctx, () => handler(req, server));
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { runWithRequestContext, getRequestContext, getTraceId, getUserId, setRequestUser, setRequestEndpoint, setRequestDimensions, setRequestError, wrapInRequestContext };
|
|
@@ -51,21 +51,62 @@ function isSensitiveKeyDefault(key) {
|
|
|
51
51
|
}
|
|
52
52
|
var DEFAULT_MAX_BYTES = 16000;
|
|
53
53
|
var DEFAULT_MAX_DEPTH = 20;
|
|
54
|
+
var DEFAULT_MAX_NODES = 20000;
|
|
54
55
|
var MASK = "[redacted]";
|
|
55
56
|
function redact(value, options = {}) {
|
|
56
57
|
const custom = options.sensitiveKeys;
|
|
57
58
|
const isSensitive = custom === undefined ? isSensitiveKeyDefault : (key) => {
|
|
58
59
|
custom.lastIndex = 0;
|
|
59
|
-
return custom.test(key);
|
|
60
|
+
return custom.test(key) || options.includeDefaultSensitiveKeys === true && isSensitiveKeyDefault(key);
|
|
60
61
|
};
|
|
61
62
|
const maxDepth = options.maxDepth ?? DEFAULT_MAX_DEPTH;
|
|
63
|
+
const maxStringLength = options.maxStringLength ?? Number.POSITIVE_INFINITY;
|
|
64
|
+
const maxCollectionLength = options.maxCollectionLength ?? Number.POSITIVE_INFINITY;
|
|
65
|
+
const pathMatchers = (options.sensitivePaths ?? []).map((pattern) => pattern.split("."));
|
|
66
|
+
const matchesPath = (matcher, path, patternIndex = 0, pathIndex = 0) => {
|
|
67
|
+
if (patternIndex === matcher.length)
|
|
68
|
+
return pathIndex === path.length;
|
|
69
|
+
const segment = matcher[patternIndex];
|
|
70
|
+
if (segment === "**") {
|
|
71
|
+
if (patternIndex + 1 === matcher.length)
|
|
72
|
+
return true;
|
|
73
|
+
for (let next = pathIndex;next <= path.length; next += 1) {
|
|
74
|
+
if (matchesPath(matcher, path, patternIndex + 1, next))
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (pathIndex === path.length || segment !== "*" && segment !== path[pathIndex])
|
|
80
|
+
return false;
|
|
81
|
+
return matchesPath(matcher, path, patternIndex + 1, pathIndex + 1);
|
|
82
|
+
};
|
|
83
|
+
const isSensitivePath = (path) => pathMatchers.some((matcher) => matchesPath(matcher, path));
|
|
84
|
+
const safeString = (input) => {
|
|
85
|
+
let output = input;
|
|
86
|
+
for (const pattern of options.sensitiveUrlPatterns ?? []) {
|
|
87
|
+
try {
|
|
88
|
+
const global = new RegExp(pattern.source, `${pattern.flags.replace(/[gy]/g, "")}g`);
|
|
89
|
+
output = output.replace(global, MASK);
|
|
90
|
+
} catch {}
|
|
91
|
+
}
|
|
92
|
+
if (output.length <= maxStringLength)
|
|
93
|
+
return output;
|
|
94
|
+
return `${output.slice(0, Math.max(0, maxStringLength))}…[truncated]`;
|
|
95
|
+
};
|
|
62
96
|
const ancestors = new Set;
|
|
63
|
-
const
|
|
97
|
+
const maxNodes = options.maxNodes ?? DEFAULT_MAX_NODES;
|
|
98
|
+
let visited = 0;
|
|
99
|
+
const walk = (input, depth, path = []) => {
|
|
64
100
|
if (depth > maxDepth)
|
|
65
101
|
return "[max depth]";
|
|
102
|
+
visited += 1;
|
|
103
|
+
if (visited > maxNodes)
|
|
104
|
+
return "[node budget]";
|
|
66
105
|
if (input === null || input === undefined)
|
|
67
106
|
return null;
|
|
68
|
-
if (typeof input === "string"
|
|
107
|
+
if (typeof input === "string")
|
|
108
|
+
return safeString(input);
|
|
109
|
+
if (typeof input === "number" || typeof input === "boolean") {
|
|
69
110
|
return input;
|
|
70
111
|
}
|
|
71
112
|
if (input instanceof Uint8Array || input instanceof ArrayBuffer) {
|
|
@@ -81,10 +122,17 @@ function redact(value, options = {}) {
|
|
|
81
122
|
if (ancestors.has(input))
|
|
82
123
|
return "[circular]";
|
|
83
124
|
ancestors.add(input);
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
typeof key === "string"
|
|
87
|
-
|
|
125
|
+
const entries = [...input.entries()];
|
|
126
|
+
const result = entries.slice(0, maxCollectionLength).map(([key, value2]) => {
|
|
127
|
+
const segment = typeof key === "string" ? key : String(key);
|
|
128
|
+
const childPath = [...path, segment];
|
|
129
|
+
return [
|
|
130
|
+
walk(key, depth + 1, [...path, "[key]"]),
|
|
131
|
+
typeof key === "string" && isSensitive(key) || isSensitivePath(childPath) ? MASK : walk(value2, depth + 1, childPath)
|
|
132
|
+
];
|
|
133
|
+
});
|
|
134
|
+
if (entries.length > maxCollectionLength)
|
|
135
|
+
result.push(["[truncated]", entries.length - maxCollectionLength]);
|
|
88
136
|
ancestors.delete(input);
|
|
89
137
|
return { _type: "map", entries: result };
|
|
90
138
|
}
|
|
@@ -92,23 +140,51 @@ function redact(value, options = {}) {
|
|
|
92
140
|
if (ancestors.has(input))
|
|
93
141
|
return "[circular]";
|
|
94
142
|
ancestors.add(input);
|
|
95
|
-
const
|
|
143
|
+
const entries = [...input];
|
|
144
|
+
const values = entries.slice(0, maxCollectionLength).map((item, index) => walk(item, depth + 1, [...path, String(index)]));
|
|
145
|
+
if (entries.length > maxCollectionLength)
|
|
146
|
+
values.push(`[truncated ${entries.length - maxCollectionLength} items]`);
|
|
96
147
|
ancestors.delete(input);
|
|
97
148
|
return { _type: "set", values };
|
|
98
149
|
}
|
|
150
|
+
if (input instanceof Date) {
|
|
151
|
+
return Number.isNaN(input.getTime()) ? "[invalid date]" : input.toISOString();
|
|
152
|
+
}
|
|
153
|
+
if (input instanceof URL)
|
|
154
|
+
return safeString(input.href);
|
|
99
155
|
if (input instanceof Error) {
|
|
156
|
+
const property = (name) => {
|
|
157
|
+
try {
|
|
158
|
+
return Reflect.get(input, name);
|
|
159
|
+
} catch {
|
|
160
|
+
return "[unreadable]";
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const stack = property("stack");
|
|
164
|
+
const cause = property("cause");
|
|
100
165
|
return {
|
|
101
166
|
_type: "error",
|
|
102
|
-
name:
|
|
103
|
-
message:
|
|
104
|
-
...
|
|
167
|
+
name: safeString(String(property("name"))),
|
|
168
|
+
message: safeString(String(property("message"))),
|
|
169
|
+
...stack !== undefined && { stack: safeString(String(stack)) },
|
|
170
|
+
...cause !== undefined && { cause: walk(cause, depth + 1, [...path, "cause"]) }
|
|
105
171
|
};
|
|
106
172
|
}
|
|
107
173
|
if (Array.isArray(input)) {
|
|
108
174
|
if (ancestors.has(input))
|
|
109
175
|
return "[circular]";
|
|
110
176
|
ancestors.add(input);
|
|
111
|
-
const result =
|
|
177
|
+
const result = [];
|
|
178
|
+
const count = Math.min(input.length, maxCollectionLength);
|
|
179
|
+
for (let index = 0;index < count; index += 1) {
|
|
180
|
+
try {
|
|
181
|
+
result.push(walk(Reflect.get(input, index), depth + 1, [...path, String(index)]));
|
|
182
|
+
} catch {
|
|
183
|
+
result.push("[unreadable]");
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (input.length > maxCollectionLength)
|
|
187
|
+
result.push(`[truncated ${input.length - maxCollectionLength} items]`);
|
|
112
188
|
ancestors.delete(input);
|
|
113
189
|
return result;
|
|
114
190
|
}
|
|
@@ -117,19 +193,23 @@ function redact(value, options = {}) {
|
|
|
117
193
|
return "[circular]";
|
|
118
194
|
ancestors.add(input);
|
|
119
195
|
const out = {};
|
|
120
|
-
|
|
196
|
+
const keys = Object.keys(input);
|
|
197
|
+
for (const key of keys.slice(0, maxCollectionLength)) {
|
|
121
198
|
if (isUnsafeKey(key))
|
|
122
199
|
continue;
|
|
123
|
-
|
|
200
|
+
const childPath = [...path, key];
|
|
201
|
+
if (isSensitive(key) || isSensitivePath(childPath)) {
|
|
124
202
|
out[key] = MASK;
|
|
125
203
|
continue;
|
|
126
204
|
}
|
|
127
205
|
try {
|
|
128
|
-
out[key] = walk(Reflect.get(input, key), depth + 1);
|
|
206
|
+
out[key] = walk(Reflect.get(input, key), depth + 1, childPath);
|
|
129
207
|
} catch {
|
|
130
208
|
out[key] = "[unreadable]";
|
|
131
209
|
}
|
|
132
210
|
}
|
|
211
|
+
if (keys.length > maxCollectionLength)
|
|
212
|
+
out["[truncated]"] = keys.length - maxCollectionLength;
|
|
133
213
|
ancestors.delete(input);
|
|
134
214
|
return out;
|
|
135
215
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// src/internal/random-hex.ts
|
|
2
|
+
function randomHex(bytes) {
|
|
3
|
+
const arr = new Uint8Array(bytes);
|
|
4
|
+
crypto.getRandomValues(arr);
|
|
5
|
+
let hex = "";
|
|
6
|
+
for (const byte of arr)
|
|
7
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
8
|
+
return hex;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// src/observability/trace.ts
|
|
12
|
+
var TRACEPARENT_RE = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(.*)$/i;
|
|
13
|
+
function createTraceContext() {
|
|
14
|
+
return { traceId: randomHex(16), spanId: randomHex(8) };
|
|
15
|
+
}
|
|
16
|
+
function parseTraceparent(header) {
|
|
17
|
+
if (!header)
|
|
18
|
+
return null;
|
|
19
|
+
const match = TRACEPARENT_RE.exec(header.trim());
|
|
20
|
+
if (!match?.[1] || !match[2] || !match[3] || !match[4] || match[5] === undefined)
|
|
21
|
+
return null;
|
|
22
|
+
const version = match[1].toLowerCase();
|
|
23
|
+
if (version === "ff")
|
|
24
|
+
return null;
|
|
25
|
+
const suffix = match[5];
|
|
26
|
+
if (version === "00" ? suffix !== "" : suffix !== "" && !/^(?:-[0-9a-f]{2,})+$/i.test(suffix)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const traceId = match[2].toLowerCase();
|
|
30
|
+
const parentSpanId = match[3].toLowerCase();
|
|
31
|
+
const traceFlags = match[4].toLowerCase();
|
|
32
|
+
if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId))
|
|
33
|
+
return null;
|
|
34
|
+
return { traceId, spanId: randomHex(8), parentSpanId, traceFlags };
|
|
35
|
+
}
|
|
36
|
+
function formatTraceparent(ctx) {
|
|
37
|
+
return `00-${ctx.traceId}-${ctx.spanId}-${ctx.traceFlags ?? "01"}`;
|
|
38
|
+
}
|
|
39
|
+
function resolveTraceContext(req) {
|
|
40
|
+
return parseTraceparent(req.headers.get("traceparent")) ?? createTraceContext();
|
|
41
|
+
}
|
|
42
|
+
function childSpan(parent) {
|
|
43
|
+
return {
|
|
44
|
+
traceId: parent.traceId,
|
|
45
|
+
spanId: randomHex(8),
|
|
46
|
+
parentSpanId: parent.spanId,
|
|
47
|
+
...parent.tracestate !== undefined && { tracestate: parent.tracestate },
|
|
48
|
+
...parent.baggage !== undefined && { baggage: parent.baggage },
|
|
49
|
+
...parent.traceFlags !== undefined && { traceFlags: parent.traceFlags }
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
var encoder = new TextEncoder;
|
|
53
|
+
function boundedPropagationValue(value, maxBytes, maxMembers) {
|
|
54
|
+
if (typeof value !== "string")
|
|
55
|
+
return;
|
|
56
|
+
const trimmed = value.trim();
|
|
57
|
+
if (!trimmed || encoder.encode(trimmed).byteLength > maxBytes)
|
|
58
|
+
return;
|
|
59
|
+
for (const character of trimmed) {
|
|
60
|
+
const code = character.charCodeAt(0);
|
|
61
|
+
if (code <= 31 || code === 127)
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const members = trimmed.split(",");
|
|
65
|
+
if (members.length > maxMembers || members.some((member) => !member.trim())) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
return trimmed;
|
|
69
|
+
}
|
|
70
|
+
function resolvePropagationContext(metadata, fallback) {
|
|
71
|
+
const traceparent = metadata?.traceparent;
|
|
72
|
+
const parsed = typeof traceparent === "string" ? parseTraceparent(traceparent) : null;
|
|
73
|
+
const trace = traceparent === undefined ? fallback ?? createTraceContext() : parsed ?? createTraceContext();
|
|
74
|
+
const tracestate = parsed ? boundedPropagationValue(metadata?.tracestate, 512, 32) : undefined;
|
|
75
|
+
const baggage = boundedPropagationValue(metadata?.baggage, 8192, 180);
|
|
76
|
+
return {
|
|
77
|
+
...trace,
|
|
78
|
+
...tracestate !== undefined && { tracestate },
|
|
79
|
+
...baggage !== undefined && { baggage }
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { randomHex, createTraceContext, parseTraceparent, formatTraceparent, resolveTraceContext, childSpan, resolvePropagationContext };
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
BackoffPolicySchema,
|
|
6
6
|
createBackoff,
|
|
7
7
|
resumableIterator
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-s8cnx02s.js";
|
|
9
9
|
import {
|
|
10
10
|
REALTIME_REJECTION_KEY,
|
|
11
11
|
asRealtimeRejection,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
isModuleNotFound,
|
|
14
14
|
parseRealtimeRequestAcknowledgement,
|
|
15
15
|
parseRealtimeRequestArguments
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-apn8repm.js";
|
|
17
17
|
import {
|
|
18
18
|
RealtimeRequestDisconnectedError,
|
|
19
19
|
RealtimeRequestInvalidAcknowledgementError,
|
|
@@ -30,29 +30,26 @@ import {
|
|
|
30
30
|
} from "./index-ywd0y6m1.js";
|
|
31
31
|
import"./index-7gnkny4z.js";
|
|
32
32
|
import {
|
|
33
|
-
ApiError,
|
|
34
33
|
contractEndpointMatchers,
|
|
35
34
|
createClient,
|
|
36
35
|
createClients,
|
|
37
|
-
createHttpClient,
|
|
38
36
|
createScopedClients,
|
|
39
37
|
createScopedUrlBuilders,
|
|
40
38
|
createUrlBuilder,
|
|
41
39
|
createUrlBuilders,
|
|
42
40
|
parseNDJSON
|
|
43
|
-
} from "./index-
|
|
41
|
+
} from "./index-27gm3d6g.js";
|
|
44
42
|
import {
|
|
45
43
|
parseSSE
|
|
46
|
-
} from "./index-
|
|
44
|
+
} from "./index-qmgs7y68.js";
|
|
45
|
+
import {
|
|
46
|
+
ApiError,
|
|
47
|
+
createHttpClient
|
|
48
|
+
} from "./index-3xwxfj4z.js";
|
|
47
49
|
import {
|
|
48
|
-
childSpan,
|
|
49
|
-
createTraceContext,
|
|
50
|
-
formatTraceparent,
|
|
51
50
|
formatZodError,
|
|
52
|
-
parseTraceparent,
|
|
53
|
-
randomHex,
|
|
54
51
|
zodIssues
|
|
55
|
-
} from "./index-
|
|
52
|
+
} from "./index-7evdsyez.js";
|
|
56
53
|
import {
|
|
57
54
|
ALL_TRANSPORTS,
|
|
58
55
|
ContractStreamFrameSchema,
|
|
@@ -63,7 +60,7 @@ import {
|
|
|
63
60
|
defineErrors,
|
|
64
61
|
encodeCursor,
|
|
65
62
|
paginatedSchema
|
|
66
|
-
} from "./index-
|
|
63
|
+
} from "./index-2bxcmqkb.js";
|
|
67
64
|
import {
|
|
68
65
|
ManagedFilePathSchema,
|
|
69
66
|
ManagedFileRefSchema
|
|
@@ -80,6 +77,13 @@ import {
|
|
|
80
77
|
rateLimited,
|
|
81
78
|
unauthorized
|
|
82
79
|
} from "./index-0w9abg87.js";
|
|
80
|
+
import {
|
|
81
|
+
childSpan,
|
|
82
|
+
createTraceContext,
|
|
83
|
+
formatTraceparent,
|
|
84
|
+
parseTraceparent,
|
|
85
|
+
randomHex
|
|
86
|
+
} from "./index-zcgf3gqf.js";
|
|
83
87
|
import"./index-kzfs85xp.js";
|
|
84
88
|
import"./index-77fekveh.js";
|
|
85
89
|
// src/retained.ts
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-message.d.ts","sourceRoot":"","sources":["../../src/internal/error-message.ts"],"names":[],"mappings":"AAEA,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKhD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The media type without its parameters, lower-cased — what the Fetch spec
|
|
3
|
+
* calls the essence. Compared whole, never as a substring: `text/plain;
|
|
4
|
+
* charset=application/json` is a `text/plain` body, and `application/JSON`
|
|
5
|
+
* is JSON.
|
|
6
|
+
*/
|
|
7
|
+
export declare function mediaTypeEssence(contentType: string | null | undefined): string;
|
|
8
|
+
//# sourceMappingURL=media-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-type.d.ts","sourceRoot":"","sources":["../../src/internal/media-type.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAE/E"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { type ZodType } from 'zod';
|
|
2
|
+
type RouteSegmentKey<TSegment extends string> = TSegment extends `:${infer TName}` ? TName : TSegment extends `*${infer TName}` ? TName : never;
|
|
3
|
+
type RouteParamKeys<TPath extends string> = TPath extends `${infer THead}/${infer TTail}` ? RouteSegmentKey<THead> | RouteParamKeys<TTail> : RouteSegmentKey<TPath>;
|
|
4
|
+
/** String params named by a route literal (`/:userId/*filePath`). */
|
|
5
|
+
export type PathParams<TPath extends string> = string extends TPath ? Record<string, string> : {
|
|
6
|
+
[TKey in RouteParamKeys<TPath>]: string;
|
|
7
|
+
};
|
|
1
8
|
/**
|
|
2
9
|
* Join route parts into one absolute path, tolerating stray slashes on either
|
|
3
10
|
* side of every part.
|
|
@@ -11,6 +18,20 @@ export interface TrailingWildcard {
|
|
|
11
18
|
name: string;
|
|
12
19
|
segmentIndex: number;
|
|
13
20
|
}
|
|
21
|
+
export interface RouteParameter {
|
|
22
|
+
name: string;
|
|
23
|
+
kind: 'segment' | 'wildcard';
|
|
24
|
+
segmentIndex: number;
|
|
25
|
+
}
|
|
26
|
+
/** Parse and validate every named parameter in one route pattern. */
|
|
27
|
+
export declare function parseRoutePattern(path: string): readonly RouteParameter[];
|
|
28
|
+
/**
|
|
29
|
+
* Resolve the runtime params schema from the same parser that owns route
|
|
30
|
+
* matching. An explicit schema keeps its coercion/validation, but must cover
|
|
31
|
+
* every name carried by the path.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveRouteParamsSchema(path: string, schema?: ZodType<unknown>): ZodType<unknown> | undefined;
|
|
14
34
|
/** Parse and validate the route's single named terminal wildcard, if present. */
|
|
15
35
|
export declare function parseTrailingWildcard(path: string): TrailingWildcard | null;
|
|
36
|
+
export {};
|
|
16
37
|
//# sourceMappingURL=route-pattern.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-pattern.d.ts","sourceRoot":"","sources":["../../src/internal/route-pattern.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route-pattern.d.ts","sourceRoot":"","sources":["../../src/internal/route-pattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAK,MAAM,KAAK,CAAC;AAKtC,KAAK,eAAe,CAAC,QAAQ,SAAS,MAAM,IAAI,QAAQ,SAAS,IAAI,MAAM,KAAK,EAAE,GAC9E,KAAK,GACL,QAAQ,SAAS,IAAI,MAAM,KAAK,EAAE,GAChC,KAAK,GACL,KAAK,CAAC;AAEZ,KAAK,cAAc,CAAC,KAAK,SAAS,MAAM,IAAI,KAAK,SAAS,GAAG,MAAM,KAAK,IAAI,MAAM,KAAK,EAAE,GACrF,eAAe,CAAC,KAAK,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,GAC9C,eAAe,CAAC,KAAK,CAAC,CAAC;AAE3B,qEAAqE;AACrE,MAAM,MAAM,UAAU,CAAC,KAAK,SAAS,MAAM,IAAI,MAAM,SAAS,KAAK,GAC/D,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtB;KAAG,IAAI,IAAI,cAAc,CAAC,KAAK,CAAC,GAAG,MAAM;CAAE,CAAC;AAEhD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAOzE;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,GAAG,UAAU,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,qEAAqE;AACrE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,cAAc,EAAE,CAwCzE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GACxB,OAAO,CAAC,OAAO,CAAC,GAAG,SAAS,CAwC9B;AAED,iFAAiF;AACjF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAG3E"}
|
package/dist/node.js
CHANGED
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
createHandler,
|
|
6
6
|
createSocketIOServer,
|
|
7
7
|
createUnixClientTransport
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-vchzar7e.js";
|
|
9
|
+
import"./index-y91ry9h2.js";
|
|
9
10
|
import {
|
|
10
11
|
ShutdownOptionsSchema,
|
|
11
12
|
ShutdownResultSchema,
|
|
@@ -13,7 +14,7 @@ import {
|
|
|
13
14
|
ShutdownStatusSchema,
|
|
14
15
|
createServerLifecycle
|
|
15
16
|
} from "./index-3z73fh2c.js";
|
|
16
|
-
import"./index-
|
|
17
|
+
import"./index-apn8repm.js";
|
|
17
18
|
import"./index-2qzskm8h.js";
|
|
18
19
|
import {
|
|
19
20
|
createImplement,
|
|
@@ -23,10 +24,11 @@ import {
|
|
|
23
24
|
createScopedImplementRegistry,
|
|
24
25
|
implement,
|
|
25
26
|
implementRegistry
|
|
26
|
-
} from "./index-
|
|
27
|
-
import"./index-
|
|
28
|
-
import"./index-
|
|
29
|
-
import"./index-
|
|
27
|
+
} from "./index-p18f59zy.js";
|
|
28
|
+
import"./index-vsbzgd7b.js";
|
|
29
|
+
import"./index-f9mb610r.js";
|
|
30
|
+
import"./index-7evdsyez.js";
|
|
31
|
+
import"./index-2bxcmqkb.js";
|
|
30
32
|
import"./index-6k1937bx.js";
|
|
31
33
|
import {
|
|
32
34
|
AppError,
|
|
@@ -38,6 +40,7 @@ import {
|
|
|
38
40
|
rateLimited,
|
|
39
41
|
unauthorized
|
|
40
42
|
} from "./index-0w9abg87.js";
|
|
43
|
+
import"./index-zcgf3gqf.js";
|
|
41
44
|
import"./index-kzfs85xp.js";
|
|
42
45
|
import"./index-77fekveh.js";
|
|
43
46
|
// src/server/node.ts
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-owned observability projections. HTTP completion is captured once
|
|
3
|
+
* by `createHandler`; tool completion comes from the canonical tool hooks.
|
|
4
|
+
* Both are normalised into `RequestEvent` without nested fetch wrappers.
|
|
5
|
+
*/
|
|
6
|
+
import type { RuntimeContext } from '../contract/index.js';
|
|
7
|
+
import type { MethodDef } from '../server/types.js';
|
|
1
8
|
import type { ToolCallHooks } from '../tools/execute.js';
|
|
2
|
-
import { type RequestContext } from './context.js';
|
|
9
|
+
import { type DimensionCollision, type RequestContext } from './context.js';
|
|
3
10
|
import type { RequestEvent } from './event.js';
|
|
4
11
|
import { type SanitizeOptions } from './sanitize.js';
|
|
5
12
|
import { type ObservabilityDrainReport, type ObservabilityStatus } from './status.js';
|
|
@@ -66,5 +73,25 @@ export interface Observability {
|
|
|
66
73
|
/** Stop admission and drain every previously accepted event. Idempotent. */
|
|
67
74
|
close(): Promise<ObservabilityDrainReport>;
|
|
68
75
|
}
|
|
76
|
+
export type ProjectedDimensions = Readonly<Record<string, string | undefined>>;
|
|
77
|
+
/** Typed, explicit attribution rules composed into an application's hooks. */
|
|
78
|
+
export interface DimensionsProjectorConfig<TContext extends RuntimeContext, TResult> {
|
|
79
|
+
request?: (ctx: TContext, endpoint: MethodDef) => ProjectedDimensions;
|
|
80
|
+
result?: (ctx: TContext, result: TResult, endpoint: MethodDef) => ProjectedDimensions;
|
|
81
|
+
error?: (ctx: TContext, error: unknown, endpoint?: MethodDef) => ProjectedDimensions;
|
|
82
|
+
/** Default `overwrite`: later phases own a repeated dimension. */
|
|
83
|
+
collision?: DimensionCollision;
|
|
84
|
+
}
|
|
85
|
+
export interface DimensionsProjector<TContext extends RuntimeContext, TResult> {
|
|
86
|
+
request(ctx: TContext, endpoint: MethodDef): void;
|
|
87
|
+
result(ctx: TContext, result: TResult, endpoint: MethodDef): TResult;
|
|
88
|
+
error(ctx: TContext, error: unknown, endpoint?: MethodDef): void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Build one typed dimensions projector without assigning semantics to
|
|
92
|
+
* `endpoint.meta`. Applications call these methods from their existing
|
|
93
|
+
* lifecycle hooks; every phase writes through the canonical request context.
|
|
94
|
+
*/
|
|
95
|
+
export declare function createDimensionsProjector<TContext extends RuntimeContext = RuntimeContext, TResult = unknown>(config: DimensionsProjectorConfig<TContext, TResult>): DimensionsProjector<TContext, TResult>;
|
|
69
96
|
export declare function createObservability(config: ObservabilityConfig): Observability;
|
|
70
97
|
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/observability/audit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/observability/audit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAOlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,kBAAkB,CAAC;AAClE,OAAO,EACL,KAAK,kBAAkB,EAEvB,KAAK,cAAc,EAEpB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC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E,kBAAkB,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB,CAAC,QAAQ,SAAS,cAAc,EAAE,OAAO;IAC3E,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IAClD,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC;IACrE,KAAK,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;CAClE;AAgBD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,SAAS,cAAc,GAAG,cAAc,EAChD,OAAO,GAAG,OAAO,EAEjB,MAAM,EAAE,yBAAyB,CAAC,QAAQ,EAAE,OAAO,CAAC,GACnD,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAcxC;AA2ED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CA8J9E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { StitchLogger } from '../logger.js';
|
|
2
|
+
export declare const DEFAULT_REDACT_PATHS: readonly string[];
|
|
3
|
+
export interface BoundedLoggerBounds {
|
|
4
|
+
readonly stringLength?: number;
|
|
5
|
+
readonly collectionLength?: number;
|
|
6
|
+
readonly depth?: number;
|
|
7
|
+
readonly entryBytes?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface BoundedLoggerOptions {
|
|
10
|
+
readonly sink: StitchLogger;
|
|
11
|
+
readonly redact?: {
|
|
12
|
+
readonly paths?: readonly string[];
|
|
13
|
+
readonly keys?: RegExp;
|
|
14
|
+
};
|
|
15
|
+
readonly bounds?: BoundedLoggerBounds;
|
|
16
|
+
readonly sensitiveUrlPatterns?: readonly RegExp[];
|
|
17
|
+
}
|
|
18
|
+
/** Decorate any canonical logger with context, redaction, and hard bounds. */
|
|
19
|
+
export declare function createBoundedLogger(options: BoundedLoggerOptions): StitchLogger;
|
|
20
|
+
//# sourceMappingURL=bounded-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounded-logger.d.ts","sourceRoot":"","sources":["../../src/observability/bounded-logger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAI9C,eAAO,MAAM,oBAAoB,mBAW/B,CAAC;AAEH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChB,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;QACnC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACnD;AAwDD,8EAA8E;AAC9E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,YAAY,CA8C/E"}
|
|
@@ -61,16 +61,25 @@ export declare function setRequestUser(userId: string): void;
|
|
|
61
61
|
* operation it targeted even when the request fails pre-handler. No-op outside a
|
|
62
62
|
* request context. → ADR 0022.
|
|
63
63
|
*/
|
|
64
|
-
export declare function setRequestEndpoint(serviceName: string, action
|
|
64
|
+
export declare function setRequestEndpoint(serviceName: string, action?: string): void;
|
|
65
|
+
/** What a repeated dimension name does: the later write wins, the earlier one stays, or it throws. */
|
|
66
|
+
export type DimensionCollision = 'overwrite' | 'preserve' | 'error';
|
|
67
|
+
export interface SetRequestDimensionsOptions {
|
|
68
|
+
/** Policy when an earlier phase already wrote the same dimension. */
|
|
69
|
+
collision?: DimensionCollision;
|
|
70
|
+
}
|
|
65
71
|
/**
|
|
66
72
|
* Merge app-defined domain dimensions (a tenant / project / entity id, …) onto
|
|
67
73
|
* the active context — an opaque bag the core gives no meaning to (→ ADR 0021),
|
|
68
74
|
* surfaced on `RequestEvent.dimensions`. Resolve them cheaply from `ctx.params` /
|
|
69
75
|
* headers in `beforeHandle` (success) or `onError` (a pre-handler failure) and
|
|
70
76
|
* they land on the audit event for the request, success or failure alike. Merges
|
|
71
|
-
* across calls; no-op outside a request context.
|
|
77
|
+
* across calls; no-op outside a request context. Two calls are programming
|
|
78
|
+
* errors and throw — they fail the request rather than record a lie: a key of
|
|
79
|
+
* `__proto__` (it would set the bag's prototype) and a repeated key under
|
|
80
|
+
* `collision: 'error'`.
|
|
72
81
|
*/
|
|
73
|
-
export declare function setRequestDimensions(dimensions: Record<string, string
|
|
82
|
+
export declare function setRequestDimensions(dimensions: Record<string, string>, options?: SetRequestDimensionsOptions): void;
|
|
74
83
|
/**
|
|
75
84
|
* Record the error outcome on the active context. Call this from the error
|
|
76
85
|
* handler — the audit hook reads it when the request completes. Optional
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/observability/context.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/observability/context.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAEjE,oDAAoD;AACpD,MAAM,WAAW,cAAc;IAC7B,s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