brass-runtime 1.17.0 → 1.18.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.
Files changed (120) hide show
  1. package/README.md +36 -3
  2. package/dist/agent/cli/main.cjs +31 -32
  3. package/dist/agent/cli/main.js +3 -4
  4. package/dist/agent/cli/main.mjs +3 -4
  5. package/dist/agent/index.cjs +4 -5
  6. package/dist/agent/index.d.ts +1 -1
  7. package/dist/agent/index.js +3 -4
  8. package/dist/agent/index.mjs +3 -4
  9. package/dist/{chunk-GYM3LLGS.mjs → chunk-2QNREG6K.mjs} +188 -5
  10. package/dist/{chunk-4ROBZFL6.cjs → chunk-2SLT3X6G.cjs} +6 -8
  11. package/dist/{chunk-KZJQ723N.cjs → chunk-3PFZGP23.cjs} +13 -15
  12. package/dist/{chunk-VWIPB6I5.js → chunk-3PHU7FWS.js} +528 -23
  13. package/dist/{chunk-BKK77SBA.js → chunk-4YQHPIWJ.js} +32 -11
  14. package/dist/chunk-5XADBMSU.cjs +33 -0
  15. package/dist/{chunk-DNFJLJMW.mjs → chunk-6MLAZPBL.mjs} +48 -24
  16. package/dist/chunk-7TKI527D.cjs +123 -0
  17. package/dist/{chunk-AGR5B2BC.cjs → chunk-7TXQJFZX.cjs} +564 -12
  18. package/dist/{chunk-RKGKFN2A.js → chunk-AADFFVYS.js} +1 -1
  19. package/dist/{chunk-52PPNNI4.cjs → chunk-AJMKZXRB.cjs} +2 -2
  20. package/dist/{chunk-3AYM6WPJ.js → chunk-BG5RNEA2.js} +20 -299
  21. package/dist/{chunk-2HQTDLHF.mjs → chunk-ELLF55ER.mjs} +555 -3
  22. package/dist/{chunk-EOC4UHBS.mjs → chunk-G5JTCFMI.mjs} +2 -2
  23. package/dist/chunk-H5GYX7RZ.js +6126 -0
  24. package/dist/{chunk-C3MDXTRZ.js → chunk-HCJ4S3YB.js} +48 -24
  25. package/dist/{chunk-6IXXWIUM.js → chunk-IBRHSH5H.js} +555 -3
  26. package/dist/{chunk-Q2I37RP3.cjs → chunk-IFRBVMWJ.cjs} +44 -323
  27. package/dist/{chunk-52OB2ROS.js → chunk-ITG6I7ZS.js} +2 -4
  28. package/dist/chunk-ITZQ526U.mjs +33 -0
  29. package/dist/{chunk-7JIJOVCT.js → chunk-JH4GI3DW.js} +2 -4
  30. package/dist/{chunk-F6XWZQY4.cjs → chunk-KHACHFBQ.cjs} +583 -78
  31. package/dist/{chunk-4P2HHGAX.mjs → chunk-KRYP6CAE.mjs} +32 -11
  32. package/dist/chunk-KTGDLBLD.mjs +123 -0
  33. package/dist/{chunk-WBGRHGBP.cjs → chunk-LXBU5E77.cjs} +114 -93
  34. package/dist/{chunk-PD4EJTQC.cjs → chunk-N6QNSTWD.cjs} +5 -5
  35. package/dist/{chunk-6RY2FFN4.mjs → chunk-OI4ESUMC.mjs} +9 -11
  36. package/dist/{chunk-EJ6BPYVR.mjs → chunk-OT2TESZU.mjs} +1 -1
  37. package/dist/{chunk-7X3K5RMS.js → chunk-PSEU65ND.js} +9 -11
  38. package/dist/{chunk-SK7UZRNI.mjs → chunk-QCOLAHU3.mjs} +528 -23
  39. package/dist/{chunk-KH4SYAOS.mjs → chunk-QZ6QFJNM.mjs} +20 -299
  40. package/dist/{chunk-MBEJI5HF.mjs → chunk-R6WDSZA6.mjs} +2 -4
  41. package/dist/{chunk-FHQGHPMO.mjs → chunk-RREBJX2S.mjs} +2 -4
  42. package/dist/{chunk-5QC7LRZ3.js → chunk-S4HHFUYP.js} +2 -2
  43. package/dist/{chunk-GLE2WY7Z.cjs → chunk-SSQJKDN3.cjs} +194 -11
  44. package/dist/{chunk-CZIVE6NT.cjs → chunk-UUMKZJRJ.cjs} +48 -24
  45. package/dist/chunk-VIFA4DPN.cjs +6126 -0
  46. package/dist/chunk-W6WR37HN.js +33 -0
  47. package/dist/{chunk-FH2X7BVP.js → chunk-XSAHV5HQ.js} +188 -5
  48. package/dist/chunk-YM3EDNYD.js +123 -0
  49. package/dist/{chunk-7ZPEZ57L.cjs → chunk-YTX2JYYP.cjs} +18 -20
  50. package/dist/chunk-Z3PSSXP3.mjs +6126 -0
  51. package/dist/core/index.cjs +31 -9
  52. package/dist/core/index.d.ts +19 -152
  53. package/dist/core/index.js +80 -58
  54. package/dist/core/index.mjs +80 -58
  55. package/dist/defaultClient-DhpCQW9m.d.ts +1623 -0
  56. package/dist/{effect-DIUHZ9IN.d.ts → effect-CtUDl5M5.d.ts} +1 -1
  57. package/dist/http/index.cjs +202 -59
  58. package/dist/http/index.d.ts +55 -819
  59. package/dist/http/index.js +216 -73
  60. package/dist/http/index.mjs +216 -73
  61. package/dist/http/testing.cjs +31 -10
  62. package/dist/http/testing.d.ts +16 -5
  63. package/dist/http/testing.js +29 -8
  64. package/dist/http/testing.mjs +29 -8
  65. package/dist/index.cjs +110 -88
  66. package/dist/index.d.ts +9 -8
  67. package/dist/index.js +81 -59
  68. package/dist/index.mjs +81 -59
  69. package/dist/{schedule-CK3Ml_7p.d.ts → layer-BalPI6cN.d.ts} +176 -2
  70. package/dist/observability/index.cjs +20 -7
  71. package/dist/observability/index.d.ts +32 -8
  72. package/dist/observability/index.js +19 -6
  73. package/dist/observability/index.mjs +19 -6
  74. package/dist/perf/cli.cjs +26 -28
  75. package/dist/perf/cli.js +11 -13
  76. package/dist/perf/cli.mjs +11 -13
  77. package/dist/perf/index.cjs +13 -15
  78. package/dist/perf/index.js +11 -13
  79. package/dist/perf/index.mjs +11 -13
  80. package/dist/schema/index.cjs +2 -2
  81. package/dist/schema/index.js +1 -1
  82. package/dist/schema/index.mjs +1 -1
  83. package/dist/{server-D6JZ15_e.d.ts → server-C1zVmqE6.d.ts} +5 -5
  84. package/dist/{stream-B4oK9JFP.d.ts → stream-Bb4FTejt.d.ts} +1 -1
  85. package/dist/{tracer-Hwt1cl7h.d.ts → tracer-DzfuE6um.d.ts} +2 -2
  86. package/dist/{tracing-DqbTKGcf.d.ts → tracing-BABA5arE.d.ts} +1 -1
  87. package/docs/README.md +2 -0
  88. package/docs/ai/PUBLIC_API.md +28 -7
  89. package/docs/articles/brass-runtime-http-observability.md +467 -0
  90. package/docs/frameworks/angular.md +51 -0
  91. package/docs/frameworks/express.md +58 -0
  92. package/docs/frameworks/fastify.md +49 -0
  93. package/docs/frameworks/nestjs.md +53 -0
  94. package/docs/frameworks/nextjs.md +55 -0
  95. package/docs/frameworks/react.md +44 -0
  96. package/docs/frameworks/vanilla.md +56 -0
  97. package/docs/guides/layers.md +130 -0
  98. package/docs/http-recipes.md +31 -1
  99. package/docs/http.md +50 -1
  100. package/docs/observability.md +132 -0
  101. package/docs/performance-profiler.md +6 -2
  102. package/docs/recipes/layers.md +46 -2
  103. package/docs/recipes/testing.md +25 -0
  104. package/package.json +4 -1
  105. package/dist/chunk-3LOYJFRR.cjs +0 -300
  106. package/dist/chunk-3Y2RIUMM.js +0 -300
  107. package/dist/chunk-5EC274J5.cjs +0 -2874
  108. package/dist/chunk-5VRJNBLZ.mjs +0 -2874
  109. package/dist/chunk-62AZW6UT.cjs +0 -313
  110. package/dist/chunk-74ZTY6CP.js +0 -2871
  111. package/dist/chunk-7CMJS3QE.mjs +0 -2871
  112. package/dist/chunk-A2OM6NEH.mjs +0 -194
  113. package/dist/chunk-B33ICAKP.js +0 -313
  114. package/dist/chunk-JF5WGYJJ.cjs +0 -194
  115. package/dist/chunk-KN32XNTH.mjs +0 -313
  116. package/dist/chunk-KQLYONSE.cjs +0 -2871
  117. package/dist/chunk-L2SYFEBS.js +0 -194
  118. package/dist/chunk-MIIYDLGM.js +0 -2874
  119. package/dist/chunk-PWC3RBQE.mjs +0 -300
  120. package/dist/client-CZHU674n.d.ts +0 -820
@@ -29,6 +29,7 @@ function formatConfigError(error) {
29
29
  }
30
30
  var ok = (data) => ({ success: true, data });
31
31
  var fail = (issues) => ({ success: false, issues });
32
+ var EMPTY_PATH = Object.freeze([]);
32
33
  var receivedKind = (value) => {
33
34
  if (value === null) return "null";
34
35
  if (value === void 0) return "undefined";
@@ -37,12 +38,16 @@ var receivedKind = (value) => {
37
38
  return typeof value;
38
39
  };
39
40
  var pathLabel = (path) => path.length === 0 ? "$" : path.reduce((acc, part) => typeof part === "number" ? `${acc}[${part}]` : `${acc}.${part}`, "$");
40
- var makeSchemaIssue = (path, expected, received, message) => ({
41
- path,
42
- expected,
43
- received: receivedKind(received),
44
- message: message ?? `Expected ${expected} at ${pathLabel(path)}, received ${receivedKind(received)}`
45
- });
41
+ var makeSchemaIssue = (path, expected, received, message) => {
42
+ const issuePath = path.length === 0 ? EMPTY_PATH : [...path];
43
+ const receivedLabel = receivedKind(received);
44
+ return {
45
+ path: issuePath,
46
+ expected,
47
+ received: receivedLabel,
48
+ message: message ?? `Expected ${expected} at ${pathLabel(issuePath)}, received ${receivedLabel}`
49
+ };
50
+ };
46
51
  function formatIssues(issues) {
47
52
  if (issues.length === 0) return "Validation failed";
48
53
  const preview = issues.slice(0, 3).map((issue) => `${pathLabel(issue.path)}: ${issue.message}`).join("; ");
@@ -55,9 +60,9 @@ function makeSchema(kind, isOptional, parser, name) {
55
60
  name,
56
61
  isOptional,
57
62
  _parse: parser,
58
- safeParse: (input) => parser(input, []),
63
+ safeParse: (input) => parser(input, EMPTY_PATH),
59
64
  parse: (input) => {
60
- const result = parser(input, []);
65
+ const result = parser(input, EMPTY_PATH);
61
66
  if (result.success) return result.data;
62
67
  throw new SchemaValidationException(result.issues);
63
68
  },
@@ -212,50 +217,65 @@ function arraySchema(item) {
212
217
  return makeSchema("array", false, (input, path) => {
213
218
  if (!Array.isArray(input)) return fail([makeSchemaIssue(path, "array", input)]);
214
219
  const out = [];
215
- const issues = [];
216
- input.forEach((value, index) => {
217
- const result = item._parse(value, [...path, index]);
220
+ const childPath = path.length === 0 ? [] : [...path];
221
+ let issues;
222
+ for (let index = 0; index < input.length; index += 1) {
223
+ if (!(index in input)) continue;
224
+ childPath.push(index);
225
+ const result = item._parse(input[index], childPath);
226
+ childPath.pop();
218
227
  if (result.success) {
219
228
  out.push(result.data);
220
229
  } else {
230
+ issues ??= [];
221
231
  issues.push(...result.issues);
222
232
  }
223
- });
224
- return issues.length > 0 ? fail(issues) : ok(out);
233
+ }
234
+ return issues ? fail(issues) : ok(out);
225
235
  });
226
236
  }
227
237
  function objectSchema(shape, options = {}) {
228
238
  const unknownKeys = options.unknownKeys ?? "strip";
239
+ const shapeEntries = Object.entries(shape);
240
+ const knownKeys = unknownKeys === "strict" ? new Set(shapeEntries.map(([key]) => key)) : void 0;
229
241
  return makeSchema("object", false, (input, path) => {
230
242
  if (typeof input !== "object" || input === null || Array.isArray(input)) {
231
243
  return fail([makeSchemaIssue(path, options.name ?? "object", input)]);
232
244
  }
233
245
  const source = input;
234
246
  const out = unknownKeys === "passthrough" ? { ...source } : {};
235
- const issues = [];
236
- const knownKeys = new Set(Object.keys(shape));
237
- for (const [key, fieldSchema] of Object.entries(shape)) {
247
+ const childPath = path.length === 0 ? [] : [...path];
248
+ let issues;
249
+ for (const [key, fieldSchema] of shapeEntries) {
250
+ childPath.push(key);
238
251
  if (!(key in source)) {
239
252
  if (!fieldSchema.isOptional) {
240
- issues.push(makeSchemaIssue([...path, key], fieldSchema.name ?? fieldSchema.kind, void 0, "Required field is missing"));
253
+ issues ??= [];
254
+ issues.push(makeSchemaIssue(childPath, fieldSchema.name ?? fieldSchema.kind, void 0, "Required field is missing"));
241
255
  }
256
+ childPath.pop();
242
257
  continue;
243
258
  }
244
- const result = fieldSchema._parse(source[key], [...path, key]);
259
+ const result = fieldSchema._parse(source[key], childPath);
260
+ childPath.pop();
245
261
  if (result.success) {
246
262
  out[key] = result.data;
247
263
  } else {
264
+ issues ??= [];
248
265
  issues.push(...result.issues);
249
266
  }
250
267
  }
251
- if (unknownKeys === "strict") {
268
+ if (knownKeys) {
252
269
  for (const key of Object.keys(source)) {
253
270
  if (!knownKeys.has(key)) {
254
- issues.push(makeSchemaIssue([...path, key], "known key", source[key], "Unknown key is not allowed"));
271
+ childPath.push(key);
272
+ issues ??= [];
273
+ issues.push(makeSchemaIssue(childPath, "known key", source[key], "Unknown key is not allowed"));
274
+ childPath.pop();
255
275
  }
256
276
  }
257
277
  }
258
- return issues.length > 0 ? fail(issues) : ok(out);
278
+ return issues ? fail(issues) : ok(out);
259
279
  }, options.name);
260
280
  }
261
281
  function recordSchema(valueSchema) {
@@ -264,16 +284,20 @@ function recordSchema(valueSchema) {
264
284
  return fail([makeSchemaIssue(path, "record", input)]);
265
285
  }
266
286
  const out = {};
267
- const issues = [];
287
+ const childPath = path.length === 0 ? [] : [...path];
288
+ let issues;
268
289
  for (const [key, value] of Object.entries(input)) {
269
- const result = valueSchema._parse(value, [...path, key]);
290
+ childPath.push(key);
291
+ const result = valueSchema._parse(value, childPath);
292
+ childPath.pop();
270
293
  if (result.success) {
271
294
  out[key] = result.data;
272
295
  } else {
296
+ issues ??= [];
273
297
  issues.push(...result.issues);
274
298
  }
275
299
  }
276
- return issues.length > 0 ? fail(issues) : ok(out);
300
+ return issues ? fail(issues) : ok(out);
277
301
  });
278
302
  }
279
303
  function unionSchema(members) {