@rsdk/nats.producer 6.0.0-next.29 → 6.0.0-next.30

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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { EventsFactory } from './event-factory.abstract';
2
2
  export { EnsureStreamOptions, NatsProducer, PublishOptions, ProducerOptions, EventMetadata, } from './interfaces';
3
3
  export { NatsProducerConfig } from './producer.config';
4
+ export { withTracingMetadata } from './tracing-metadata';
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NatsProducerConfig = exports.EventsFactory = void 0;
3
+ exports.withTracingMetadata = exports.NatsProducerConfig = exports.EventsFactory = void 0;
4
4
  var event_factory_abstract_1 = require("./event-factory.abstract");
5
5
  Object.defineProperty(exports, "EventsFactory", { enumerable: true, get: function () { return event_factory_abstract_1.EventsFactory; } });
6
6
  var producer_config_1 = require("./producer.config");
7
7
  Object.defineProperty(exports, "NatsProducerConfig", { enumerable: true, get: function () { return producer_config_1.NatsProducerConfig; } });
8
+ var tracing_metadata_1 = require("./tracing-metadata");
9
+ Object.defineProperty(exports, "withTracingMetadata", { enumerable: true, get: function () { return tracing_metadata_1.withTracingMetadata; } });
8
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mEAAyD;AAAhD,uHAAA,aAAa,OAAA;AAStB,qDAAuD;AAA9C,qHAAA,kBAAkB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mEAAyD;AAAhD,uHAAA,aAAa,OAAA;AAStB,qDAAuD;AAA9C,qHAAA,kBAAkB,OAAA;AAC3B,uDAAyD;AAAhD,uHAAA,mBAAmB,OAAA"}
@@ -0,0 +1,11 @@
1
+ import type { EventMetadata } from './interfaces';
2
+ /**
3
+ * Egress-проброс трейсинга: домешивает текущие заголовки трассировки
4
+ * (`TracingHeaders` из контекста) в metadata исходящего сообщения.
5
+ *
6
+ * Зеркало ингресса (`IngressContext` / `TracingEnricher`): то, что положили
7
+ * в контекст на входе (requestId + additionalMappings + плагинные), уезжает
8
+ * дальше по цепочке. Заголовки трейсинга перетирают одноимённые явные значения
9
+ * — та же семантика, что у request-мидлвары.
10
+ */
11
+ export declare const withTracingMetadata: (metadata?: EventMetadata) => EventMetadata;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withTracingMetadata = void 0;
4
+ const core_1 = require("@rsdk/core");
5
+ /**
6
+ * Egress-проброс трейсинга: домешивает текущие заголовки трассировки
7
+ * (`TracingHeaders` из контекста) в metadata исходящего сообщения.
8
+ *
9
+ * Зеркало ингресса (`IngressContext` / `TracingEnricher`): то, что положили
10
+ * в контекст на входе (requestId + additionalMappings + плагинные), уезжает
11
+ * дальше по цепочке. Заголовки трейсинга перетирают одноимённые явные значения
12
+ * — та же семантика, что у request-мидлвары.
13
+ */
14
+ const withTracingMetadata = (metadata) => {
15
+ const tracing = core_1.TracingHeaders.get();
16
+ return tracing ? { ...metadata, ...tracing } : { ...metadata };
17
+ };
18
+ exports.withTracingMetadata = withTracingMetadata;
19
+ //# sourceMappingURL=tracing-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracing-metadata.js","sourceRoot":"","sources":["../src/tracing-metadata.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAI5C;;;;;;;;GAQG;AACI,MAAM,mBAAmB,GAAG,CACjC,QAAwB,EACT,EAAE;IACjB,MAAM,OAAO,GAAG,qBAAc,CAAC,GAAG,EAAE,CAAC;IAErC,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC;AACjE,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdk/nats.producer",
3
- "version": "6.0.0-next.29",
3
+ "version": "6.0.0-next.30",
4
4
  "description": "Publishers for Nats",
5
5
  "license": "Apache License 2.0",
6
6
  "publishConfig": {
@@ -24,5 +24,5 @@
24
24
  "reflect-metadata": "^0.1.12 || ^0.2.0",
25
25
  "rxjs": "^7.8.1"
26
26
  },
27
- "gitHead": "c9daf2934e4d1dbb88a5955d8869179b0846976f"
27
+ "gitHead": "b3508ef34ae639383ce55056f597f2783303bd9f"
28
28
  }
package/src/index.ts CHANGED
@@ -8,3 +8,4 @@ export {
8
8
  EventMetadata,
9
9
  } from './interfaces';
10
10
  export { NatsProducerConfig } from './producer.config';
11
+ export { withTracingMetadata } from './tracing-metadata';
@@ -0,0 +1,20 @@
1
+ import { TracingHeaders } from '@rsdk/core';
2
+
3
+ import type { EventMetadata } from './interfaces';
4
+
5
+ /**
6
+ * Egress-проброс трейсинга: домешивает текущие заголовки трассировки
7
+ * (`TracingHeaders` из контекста) в metadata исходящего сообщения.
8
+ *
9
+ * Зеркало ингресса (`IngressContext` / `TracingEnricher`): то, что положили
10
+ * в контекст на входе (requestId + additionalMappings + плагинные), уезжает
11
+ * дальше по цепочке. Заголовки трейсинга перетирают одноимённые явные значения
12
+ * — та же семантика, что у request-мидлвары.
13
+ */
14
+ export const withTracingMetadata = (
15
+ metadata?: EventMetadata,
16
+ ): EventMetadata => {
17
+ const tracing = TracingHeaders.get();
18
+
19
+ return tracing ? { ...metadata, ...tracing } : { ...metadata };
20
+ };