@treatwell/moleculer-essentials 2.1.0 → 2.1.1-beta.2

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.cjs CHANGED
@@ -14,6 +14,8 @@ var pino = require('pino');
14
14
  var node_os = require('node:os');
15
15
  var compat = require('es-toolkit/compat');
16
16
  var http = require('http');
17
+ var node_zlib = require('node:zlib');
18
+ var node_util = require('node:util');
17
19
 
18
20
  function getSchemaFromMoleculer(schema) {
19
21
  if (!schema) {
@@ -1376,8 +1378,8 @@ function flattenTags(obj, convertToString = false, path = "") {
1376
1378
  );
1377
1379
  }
1378
1380
 
1381
+ const gzipPromise = node_util.promisify(node_zlib.gzip);
1379
1382
  class NewrelicTraceExporter extends moleculer.TracerExporters.Base {
1380
- opts = {};
1381
1383
  queue;
1382
1384
  timer = null;
1383
1385
  defaultTags = {};
@@ -1436,9 +1438,10 @@ class NewrelicTraceExporter extends moleculer.TracerExporters.Base {
1436
1438
  try {
1437
1439
  const res = await fetch(`${this.opts.baseURL}/trace/v1`, {
1438
1440
  method: "post",
1439
- body: JSON.stringify(data),
1441
+ body: await gzipPromise(JSON.stringify(data)),
1440
1442
  headers: {
1441
1443
  "Content-Type": "application/json",
1444
+ "Content-Encoding": "gzip",
1442
1445
  "Api-Key": this.opts.insertKey,
1443
1446
  "Data-Format": "newrelic",
1444
1447
  "Data-Format-Version": "1"
@@ -1493,7 +1496,6 @@ class NewrelicTraceExporter extends moleculer.TracerExporters.Base {
1493
1496
  }
1494
1497
 
1495
1498
  class NewrelicMetricsReporter extends moleculer.MetricReporters.Base {
1496
- opts = {};
1497
1499
  timer = null;
1498
1500
  defaultTags = {};
1499
1501
  constructor(opts) {
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { S as SomeJSONSchema, J as JSONSchemaType, C as CustomActionSchema, A as Alias, P as PartialCustomServiceSchema, D as Document, a as SchemaObject, O as OperationObject, R as ReferenceObject, b as CustomServiceSchema, c as CreateLoggerOptions, M as MoleculerLoggerConfigOptions } from './types-Cdh7thEZ.cjs';
2
- export { d as AjvValidator, e as ApiKeySecurityScheme, f as CallbackObject, g as ComponentsObject, h as ContactObject, i as ContextFactory, E as EncodingObject, j as ExampleObject, k as ExternalDocumentationObject, H as HeaderObject, l as HttpSecurityScheme, I as InfoObject, m as InternalCallbackServiceThis, n as InternalObjectServiceThis, L as LicenseObject, o as LinkObject, p as MediaTypeObject, q as OAuth2SecurityScheme, r as OpenIdSecurityScheme, s as ParameterBaseObject, t as ParameterObject, u as PathItemObject, v as PathsObject, w as PropertiesSchema, x as RequestBodyObject, y as RequiredMembers, z as ResponseObject, B as ResponsesObject, F as SecurityRequirementObject, G as SecuritySchemeObject, K as ServerObject, N as ServerVariableObject, T as TagObject, Q as Transform, U as TransformField, V as TransformLevel, W as TransformMap, X as Transformer, Y as ValidationSchema, Z as ZodValidator } from './types-Cdh7thEZ.cjs';
1
+ import { S as SomeJSONSchema, J as JSONSchemaType, C as CustomActionSchema, A as Alias, P as PartialCustomServiceSchema, D as Document, a as SchemaObject, O as OperationObject, R as ReferenceObject, b as CustomServiceSchema, c as CreateLoggerOptions, M as MoleculerLoggerConfigOptions } from './newrelic-metrics-reporter-CmRMT4LG.cjs';
2
+ export { d as AjvValidator, e as ApiKeySecurityScheme, f as CallbackObject, g as ComponentsObject, h as ContactObject, i as ContextFactory, E as EncodingObject, j as ExampleObject, k as ExternalDocumentationObject, H as HeaderObject, l as HttpSecurityScheme, I as InfoObject, m as InternalCallbackServiceThis, n as InternalObjectServiceThis, L as LicenseObject, o as LinkObject, p as MediaTypeObject, N as NewrelicMetricsReporter, q as NewrelicTraceExporter, r as OAuth2SecurityScheme, s as OpenIdSecurityScheme, t as ParameterBaseObject, u as ParameterObject, v as PathItemObject, w as PathsObject, x as PropertiesSchema, y as RequestBodyObject, z as RequiredMembers, B as ResponseObject, F as ResponsesObject, G as SecurityRequirementObject, K as SecuritySchemeObject, Q as ServerObject, T as ServerVariableObject, U as TagObject, V as Transform, W as TransformField, X as TransformLevel, Y as TransformMap, Z as Transformer, _ as ValidationSchema, $ as ZodValidator } from './newrelic-metrics-reporter-CmRMT4LG.cjs';
3
3
  import { ObjectId } from 'bson';
4
4
  import { z, ZodType } from 'zod/v4';
5
5
  import { Ajv2019 } from 'ajv/dist/2019.js';
6
- import { Errors, Context, ServiceSettingSchema, ServiceSchema, Service, ServiceBroker, BrokerOptions, Middleware, LoggerConfig, TracerExporters, Logger as Logger$1, Tracer, Span, MetricReporters, MetricRegistry } from 'moleculer';
6
+ import { Errors, Context, ServiceSettingSchema, ServiceSchema, Service, ServiceBroker, BrokerOptions, Middleware, LoggerConfig } from 'moleculer';
7
7
  import { Logger } from 'pino';
8
8
  import 'pino-pretty';
9
9
 
@@ -275,116 +275,5 @@ declare function createLogger(opts?: CreateLoggerOptions): Logger;
275
275
  */
276
276
  declare function createLoggerConfig(opts?: MoleculerLoggerConfigOptions): LoggerConfig;
277
277
 
278
- type NewrelicTraceExporterOptions = {
279
- logger?: Logger$1;
280
- safetyTags?: boolean;
281
- /**
282
- * Base URL for NewRelic server.
283
- */
284
- baseURL?: string;
285
- /**
286
- * Maximum number of spans to be sent in one time.
287
- */
288
- batchSize?: number;
289
- /**
290
- * NewRelic Insert API Key.
291
- */
292
- insertKey?: string;
293
- /**
294
- * Batch send time interval in seconds.
295
- */
296
- interval?: number;
297
- /**
298
- * Default span tags.
299
- */
300
- defaultTags?: Record<string, unknown> | ((tracer?: unknown) => Record<string, unknown>);
301
- };
302
- /**
303
- * >>> Hard copy of the moleculer NewRelic provider. It didn't handle errors correctly
304
- *
305
- * Trace Exporter for NewRelic using Zipkin data.
306
- *
307
- * NewRelic zipkin tracer: https://docs.newrelic.com/docs/understand-dependencies/distributed-tracing/trace-api/report-zipkin-format-traces-trace-api
308
- * API v2: https://zipkin.io/zipkin-api/#/
309
- */
310
- declare class NewrelicTraceExporter extends TracerExporters.Base {
311
- private readonly opts;
312
- private queue;
313
- private timer;
314
- private defaultTags;
315
- constructor(opts: NewrelicTraceExporterOptions);
316
- /**
317
- * Initialize Trace Exporter.
318
- */
319
- init(tracer: Tracer): void;
320
- /**
321
- * Stop Trace exporter
322
- */
323
- stop(): Promise<void>;
324
- /**
325
- * Span is finished.
326
- */
327
- spanFinished(span: Span): void;
328
- /**
329
- * Flush tracing data to NewRelic Zipkin api endpoint
330
- */
331
- flush(): Promise<void>;
332
- /**
333
- * Generate tracing data for NewRelic
334
- */
335
- generateTracingData(): unknown[];
336
- /**
337
- * Create NewRelic v1 payload
338
- */
339
- makePayload(span: Span): unknown;
340
- }
341
-
342
- type DefaultTags = Record<string, unknown> | ((registry: MetricRegistry) => Record<string, unknown>);
343
- type NewrelicMetricsOptions = MetricReporters.Base.MetricReporterOptions & {
344
- /**
345
- * Base URL for NewRelic server.
346
- */
347
- baseURL?: string;
348
- /**
349
- * NewRelic Insert API Key
350
- */
351
- insertKey?: string;
352
- /**
353
- * Batch send time interval in seconds.
354
- */
355
- interval?: number;
356
- /**
357
- * Default tags to be added to all metrics.
358
- */
359
- defaultTags?: DefaultTags;
360
- };
361
- /**
362
- * NewRelic metrics reporter.
363
- *
364
- * NewRelic API: https://docs.newrelic.com/docs/data-apis/understand-data/metric-data/metric-data-type/
365
- */
366
- declare class NewrelicMetricsReporter extends MetricReporters.Base {
367
- private readonly opts;
368
- private timer;
369
- private defaultTags;
370
- constructor(opts: NewrelicMetricsOptions);
371
- /**
372
- * Initialize Trace Exporter.
373
- */
374
- init(registry: MetricRegistry): void;
375
- /**
376
- * Stop Trace exporter
377
- */
378
- stop(): Promise<void>;
379
- /**
380
- * Flush tracing data to NewRelic Zipkin api endpoint
381
- */
382
- flush(): Promise<void>;
383
- /**
384
- * Generate metrics data for NewRelic
385
- */
386
- generateMetricsPayload(): unknown[];
387
- }
388
-
389
- export { AjvExtractor, Alias, COERCE_ARRAY_ATTRIBUTE, CustomActionSchema, CustomServiceSchema, DATE_TYPE, Document, EMPTY_OBJECT_SCHEMA, HealthCheckMiddleware, JSONSchemaType, NewrelicMetricsReporter, NewrelicTraceExporter, OBJECTID_TYPE, OpenAPIExtractor, OpenAPIMixin, OperationObject, PartialCustomServiceSchema, RefExtractor, ReferenceObject, SCHEMA_REF_NAME, SchemaObject, ServiceFactory, SomeJSONSchema, addFieldsToSchema, composeSchemas, createLogger, createLoggerConfig, createOpenAPIResponses, createServiceBroker, getMetadataFromService, isServiceSelected, isZodSchema, omitFields, optionalExceptFields, optionalFields, pickFields, toPartialSchema, wrapMixin, wrapService, zodCoerceArray, zodDate, zodObjectId, zodToOpenAPISchema };
278
+ export { AjvExtractor, Alias, COERCE_ARRAY_ATTRIBUTE, CustomActionSchema, CustomServiceSchema, DATE_TYPE, Document, EMPTY_OBJECT_SCHEMA, HealthCheckMiddleware, JSONSchemaType, OBJECTID_TYPE, OpenAPIExtractor, OpenAPIMixin, OperationObject, PartialCustomServiceSchema, RefExtractor, ReferenceObject, SCHEMA_REF_NAME, SchemaObject, ServiceFactory, SomeJSONSchema, addFieldsToSchema, composeSchemas, createLogger, createLoggerConfig, createOpenAPIResponses, createServiceBroker, getMetadataFromService, isServiceSelected, isZodSchema, omitFields, optionalExceptFields, optionalFields, pickFields, toPartialSchema, wrapMixin, wrapService, zodCoerceArray, zodDate, zodObjectId, zodToOpenAPISchema };
390
279
  export type { OpenAPIMixinOptions, OpenAPIResponses, Selector, _InferredServiceSchema };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import { S as SomeJSONSchema, J as JSONSchemaType, C as CustomActionSchema, A as Alias, P as PartialCustomServiceSchema, D as Document, a as SchemaObject, O as OperationObject, R as ReferenceObject, b as CustomServiceSchema, c as CreateLoggerOptions, M as MoleculerLoggerConfigOptions } from './types-Cdh7thEZ.mjs';
2
- export { d as AjvValidator, e as ApiKeySecurityScheme, f as CallbackObject, g as ComponentsObject, h as ContactObject, i as ContextFactory, E as EncodingObject, j as ExampleObject, k as ExternalDocumentationObject, H as HeaderObject, l as HttpSecurityScheme, I as InfoObject, m as InternalCallbackServiceThis, n as InternalObjectServiceThis, L as LicenseObject, o as LinkObject, p as MediaTypeObject, q as OAuth2SecurityScheme, r as OpenIdSecurityScheme, s as ParameterBaseObject, t as ParameterObject, u as PathItemObject, v as PathsObject, w as PropertiesSchema, x as RequestBodyObject, y as RequiredMembers, z as ResponseObject, B as ResponsesObject, F as SecurityRequirementObject, G as SecuritySchemeObject, K as ServerObject, N as ServerVariableObject, T as TagObject, Q as Transform, U as TransformField, V as TransformLevel, W as TransformMap, X as Transformer, Y as ValidationSchema, Z as ZodValidator } from './types-Cdh7thEZ.mjs';
1
+ import { S as SomeJSONSchema, J as JSONSchemaType, C as CustomActionSchema, A as Alias, P as PartialCustomServiceSchema, D as Document, a as SchemaObject, O as OperationObject, R as ReferenceObject, b as CustomServiceSchema, c as CreateLoggerOptions, M as MoleculerLoggerConfigOptions } from './newrelic-metrics-reporter-CmRMT4LG.mjs';
2
+ export { d as AjvValidator, e as ApiKeySecurityScheme, f as CallbackObject, g as ComponentsObject, h as ContactObject, i as ContextFactory, E as EncodingObject, j as ExampleObject, k as ExternalDocumentationObject, H as HeaderObject, l as HttpSecurityScheme, I as InfoObject, m as InternalCallbackServiceThis, n as InternalObjectServiceThis, L as LicenseObject, o as LinkObject, p as MediaTypeObject, N as NewrelicMetricsReporter, q as NewrelicTraceExporter, r as OAuth2SecurityScheme, s as OpenIdSecurityScheme, t as ParameterBaseObject, u as ParameterObject, v as PathItemObject, w as PathsObject, x as PropertiesSchema, y as RequestBodyObject, z as RequiredMembers, B as ResponseObject, F as ResponsesObject, G as SecurityRequirementObject, K as SecuritySchemeObject, Q as ServerObject, T as ServerVariableObject, U as TagObject, V as Transform, W as TransformField, X as TransformLevel, Y as TransformMap, Z as Transformer, _ as ValidationSchema, $ as ZodValidator } from './newrelic-metrics-reporter-CmRMT4LG.mjs';
3
3
  import { ObjectId } from 'bson';
4
4
  import { z, ZodType } from 'zod/v4';
5
5
  import { Ajv2019 } from 'ajv/dist/2019.js';
6
- import { Errors, Context, ServiceSettingSchema, ServiceSchema, Service, ServiceBroker, BrokerOptions, Middleware, LoggerConfig, TracerExporters, Logger as Logger$1, Tracer, Span, MetricReporters, MetricRegistry } from 'moleculer';
6
+ import { Errors, Context, ServiceSettingSchema, ServiceSchema, Service, ServiceBroker, BrokerOptions, Middleware, LoggerConfig } from 'moleculer';
7
7
  import { Logger } from 'pino';
8
8
  import 'pino-pretty';
9
9
 
@@ -275,116 +275,5 @@ declare function createLogger(opts?: CreateLoggerOptions): Logger;
275
275
  */
276
276
  declare function createLoggerConfig(opts?: MoleculerLoggerConfigOptions): LoggerConfig;
277
277
 
278
- type NewrelicTraceExporterOptions = {
279
- logger?: Logger$1;
280
- safetyTags?: boolean;
281
- /**
282
- * Base URL for NewRelic server.
283
- */
284
- baseURL?: string;
285
- /**
286
- * Maximum number of spans to be sent in one time.
287
- */
288
- batchSize?: number;
289
- /**
290
- * NewRelic Insert API Key.
291
- */
292
- insertKey?: string;
293
- /**
294
- * Batch send time interval in seconds.
295
- */
296
- interval?: number;
297
- /**
298
- * Default span tags.
299
- */
300
- defaultTags?: Record<string, unknown> | ((tracer?: unknown) => Record<string, unknown>);
301
- };
302
- /**
303
- * >>> Hard copy of the moleculer NewRelic provider. It didn't handle errors correctly
304
- *
305
- * Trace Exporter for NewRelic using Zipkin data.
306
- *
307
- * NewRelic zipkin tracer: https://docs.newrelic.com/docs/understand-dependencies/distributed-tracing/trace-api/report-zipkin-format-traces-trace-api
308
- * API v2: https://zipkin.io/zipkin-api/#/
309
- */
310
- declare class NewrelicTraceExporter extends TracerExporters.Base {
311
- private readonly opts;
312
- private queue;
313
- private timer;
314
- private defaultTags;
315
- constructor(opts: NewrelicTraceExporterOptions);
316
- /**
317
- * Initialize Trace Exporter.
318
- */
319
- init(tracer: Tracer): void;
320
- /**
321
- * Stop Trace exporter
322
- */
323
- stop(): Promise<void>;
324
- /**
325
- * Span is finished.
326
- */
327
- spanFinished(span: Span): void;
328
- /**
329
- * Flush tracing data to NewRelic Zipkin api endpoint
330
- */
331
- flush(): Promise<void>;
332
- /**
333
- * Generate tracing data for NewRelic
334
- */
335
- generateTracingData(): unknown[];
336
- /**
337
- * Create NewRelic v1 payload
338
- */
339
- makePayload(span: Span): unknown;
340
- }
341
-
342
- type DefaultTags = Record<string, unknown> | ((registry: MetricRegistry) => Record<string, unknown>);
343
- type NewrelicMetricsOptions = MetricReporters.Base.MetricReporterOptions & {
344
- /**
345
- * Base URL for NewRelic server.
346
- */
347
- baseURL?: string;
348
- /**
349
- * NewRelic Insert API Key
350
- */
351
- insertKey?: string;
352
- /**
353
- * Batch send time interval in seconds.
354
- */
355
- interval?: number;
356
- /**
357
- * Default tags to be added to all metrics.
358
- */
359
- defaultTags?: DefaultTags;
360
- };
361
- /**
362
- * NewRelic metrics reporter.
363
- *
364
- * NewRelic API: https://docs.newrelic.com/docs/data-apis/understand-data/metric-data/metric-data-type/
365
- */
366
- declare class NewrelicMetricsReporter extends MetricReporters.Base {
367
- private readonly opts;
368
- private timer;
369
- private defaultTags;
370
- constructor(opts: NewrelicMetricsOptions);
371
- /**
372
- * Initialize Trace Exporter.
373
- */
374
- init(registry: MetricRegistry): void;
375
- /**
376
- * Stop Trace exporter
377
- */
378
- stop(): Promise<void>;
379
- /**
380
- * Flush tracing data to NewRelic Zipkin api endpoint
381
- */
382
- flush(): Promise<void>;
383
- /**
384
- * Generate metrics data for NewRelic
385
- */
386
- generateMetricsPayload(): unknown[];
387
- }
388
-
389
- export { AjvExtractor, Alias, COERCE_ARRAY_ATTRIBUTE, CustomActionSchema, CustomServiceSchema, DATE_TYPE, Document, EMPTY_OBJECT_SCHEMA, HealthCheckMiddleware, JSONSchemaType, NewrelicMetricsReporter, NewrelicTraceExporter, OBJECTID_TYPE, OpenAPIExtractor, OpenAPIMixin, OperationObject, PartialCustomServiceSchema, RefExtractor, ReferenceObject, SCHEMA_REF_NAME, SchemaObject, ServiceFactory, SomeJSONSchema, addFieldsToSchema, composeSchemas, createLogger, createLoggerConfig, createOpenAPIResponses, createServiceBroker, getMetadataFromService, isServiceSelected, isZodSchema, omitFields, optionalExceptFields, optionalFields, pickFields, toPartialSchema, wrapMixin, wrapService, zodCoerceArray, zodDate, zodObjectId, zodToOpenAPISchema };
278
+ export { AjvExtractor, Alias, COERCE_ARRAY_ATTRIBUTE, CustomActionSchema, CustomServiceSchema, DATE_TYPE, Document, EMPTY_OBJECT_SCHEMA, HealthCheckMiddleware, JSONSchemaType, OBJECTID_TYPE, OpenAPIExtractor, OpenAPIMixin, OperationObject, PartialCustomServiceSchema, RefExtractor, ReferenceObject, SCHEMA_REF_NAME, SchemaObject, ServiceFactory, SomeJSONSchema, addFieldsToSchema, composeSchemas, createLogger, createLoggerConfig, createOpenAPIResponses, createServiceBroker, getMetadataFromService, isServiceSelected, isZodSchema, omitFields, optionalExceptFields, optionalFields, pickFields, toPartialSchema, wrapMixin, wrapService, zodCoerceArray, zodDate, zodObjectId, zodToOpenAPISchema };
390
279
  export type { OpenAPIMixinOptions, OpenAPIResponses, Selector, _InferredServiceSchema };
package/dist/index.mjs CHANGED
@@ -14,6 +14,8 @@ import { pino } from 'pino';
14
14
  import { hostname } from 'node:os';
15
15
  import { merge, defaultsDeep, isObject } from 'es-toolkit/compat';
16
16
  import http, { STATUS_CODES } from 'http';
17
+ import { gzip } from 'node:zlib';
18
+ import { promisify } from 'node:util';
17
19
 
18
20
  function getSchemaFromMoleculer(schema) {
19
21
  if (!schema) {
@@ -1376,8 +1378,8 @@ function flattenTags(obj, convertToString = false, path = "") {
1376
1378
  );
1377
1379
  }
1378
1380
 
1381
+ const gzipPromise = promisify(gzip);
1379
1382
  class NewrelicTraceExporter extends TracerExporters.Base {
1380
- opts = {};
1381
1383
  queue;
1382
1384
  timer = null;
1383
1385
  defaultTags = {};
@@ -1436,9 +1438,10 @@ class NewrelicTraceExporter extends TracerExporters.Base {
1436
1438
  try {
1437
1439
  const res = await fetch(`${this.opts.baseURL}/trace/v1`, {
1438
1440
  method: "post",
1439
- body: JSON.stringify(data),
1441
+ body: await gzipPromise(JSON.stringify(data)),
1440
1442
  headers: {
1441
1443
  "Content-Type": "application/json",
1444
+ "Content-Encoding": "gzip",
1442
1445
  "Api-Key": this.opts.insertKey,
1443
1446
  "Data-Format": "newrelic",
1444
1447
  "Data-Format-Version": "1"
@@ -1493,7 +1496,6 @@ class NewrelicTraceExporter extends TracerExporters.Base {
1493
1496
  }
1494
1497
 
1495
1498
  class NewrelicMetricsReporter extends MetricReporters.Base {
1496
- opts = {};
1497
1499
  timer = null;
1498
1500
  defaultTags = {};
1499
1501
  constructor(opts) {
@@ -1,7 +1,7 @@
1
1
  import { Document, ObjectId, WithoutId, InferIdType, Filter, OptionalId, WithId, CountDocumentsOptions, DeleteOptions, FindOneAndDeleteOptions, FindOptions, BulkWriteOptions, FindOneAndUpdateOptions, UpdateOptions, FindOneAndReplaceOptions, CollationOptions, CreateCollectionOptions, MongoClient, CollectionOptions, Collection, UpdateFilter, FindCursor, UpdateResult } from 'mongodb';
2
2
  import { ActionVisibility, Validators, Errors, Context } from 'moleculer';
3
3
  import { ZodType, ZodObject } from 'zod/v4';
4
- import { Y as ValidationSchema, J as JSONSchemaType, C as CustomActionSchema, P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.cjs';
4
+ import { _ as ValidationSchema, J as JSONSchemaType, C as CustomActionSchema, P as PartialCustomServiceSchema } from '../newrelic-metrics-reporter-CmRMT4LG.cjs';
5
5
  import { Readable } from 'stream';
6
6
  import 'bson';
7
7
  import 'ajv/dist/2019.js';
@@ -1,7 +1,7 @@
1
1
  import { Document, ObjectId, WithoutId, InferIdType, Filter, OptionalId, WithId, CountDocumentsOptions, DeleteOptions, FindOneAndDeleteOptions, FindOptions, BulkWriteOptions, FindOneAndUpdateOptions, UpdateOptions, FindOneAndReplaceOptions, CollationOptions, CreateCollectionOptions, MongoClient, CollectionOptions, Collection, UpdateFilter, FindCursor, UpdateResult } from 'mongodb';
2
2
  import { ActionVisibility, Validators, Errors, Context } from 'moleculer';
3
3
  import { ZodType, ZodObject } from 'zod/v4';
4
- import { Y as ValidationSchema, J as JSONSchemaType, C as CustomActionSchema, P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.mjs';
4
+ import { _ as ValidationSchema, J as JSONSchemaType, C as CustomActionSchema, P as PartialCustomServiceSchema } from '../newrelic-metrics-reporter-CmRMT4LG.mjs';
5
5
  import { Readable } from 'stream';
6
6
  import 'bson';
7
7
  import 'ajv/dist/2019.js';
@@ -1,4 +1,4 @@
1
- import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.cjs';
1
+ import { P as PartialCustomServiceSchema } from '../newrelic-metrics-reporter-CmRMT4LG.cjs';
2
2
  import { buildClient, NodeCachingMaterialsManager } from '@aws-crypto/client-node';
3
3
  import 'moleculer';
4
4
  import 'bson';
@@ -1,4 +1,4 @@
1
- import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.mjs';
1
+ import { P as PartialCustomServiceSchema } from '../newrelic-metrics-reporter-CmRMT4LG.mjs';
2
2
  import { buildClient, NodeCachingMaterialsManager } from '@aws-crypto/client-node';
3
3
  import 'moleculer';
4
4
  import 'bson';
@@ -1,4 +1,4 @@
1
- import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.cjs';
1
+ import { P as PartialCustomServiceSchema } from '../newrelic-metrics-reporter-CmRMT4LG.cjs';
2
2
  import 'moleculer';
3
3
  import 'bson';
4
4
  import 'zod/v4';
@@ -1,4 +1,4 @@
1
- import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.mjs';
1
+ import { P as PartialCustomServiceSchema } from '../newrelic-metrics-reporter-CmRMT4LG.mjs';
2
2
  import 'moleculer';
3
3
  import 'bson';
4
4
  import 'zod/v4';
@@ -1,4 +1,4 @@
1
- import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.cjs';
1
+ import { P as PartialCustomServiceSchema } from '../newrelic-metrics-reporter-CmRMT4LG.cjs';
2
2
  import { SignOptions, PrivateKey, VerifyOptions, JwtHeader, SigningKeyCallback } from 'jsonwebtoken';
3
3
  import { Options, JwksClient } from 'jwks-rsa';
4
4
  import { Context } from 'moleculer';
@@ -1,4 +1,4 @@
1
- import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.mjs';
1
+ import { P as PartialCustomServiceSchema } from '../newrelic-metrics-reporter-CmRMT4LG.mjs';
2
2
  import { SignOptions, PrivateKey, VerifyOptions, JwtHeader, SigningKeyCallback } from 'jsonwebtoken';
3
3
  import { Options, JwksClient } from 'jwks-rsa';
4
4
  import { Context } from 'moleculer';
@@ -1,4 +1,4 @@
1
- import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.cjs';
1
+ import { P as PartialCustomServiceSchema } from '../newrelic-metrics-reporter-CmRMT4LG.cjs';
2
2
  import { Redis } from 'ioredis';
3
3
  import { QueueOptions, Queue, JobsOptions, Job, QueueEventsOptions, QueueEvents, QueueBaseOptions, FlowProducer, RepeatOptions, WorkerOptions, Worker } from 'bullmq';
4
4
  import { Service } from 'moleculer';
@@ -1,4 +1,4 @@
1
- import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.mjs';
1
+ import { P as PartialCustomServiceSchema } from '../newrelic-metrics-reporter-CmRMT4LG.mjs';
2
2
  import { Redis } from 'ioredis';
3
3
  import { QueueOptions, Queue, JobsOptions, Job, QueueEventsOptions, QueueEvents, QueueBaseOptions, FlowProducer, RepeatOptions, WorkerOptions, Worker } from 'bullmq';
4
4
  import { Service } from 'moleculer';
@@ -1,4 +1,4 @@
1
- import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.cjs';
1
+ import { P as PartialCustomServiceSchema } from '../newrelic-metrics-reporter-CmRMT4LG.cjs';
2
2
  import { RedisOptions, Redis } from 'ioredis';
3
3
  import { Service } from 'moleculer';
4
4
  import 'bson';
@@ -1,4 +1,4 @@
1
- import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.mjs';
1
+ import { P as PartialCustomServiceSchema } from '../newrelic-metrics-reporter-CmRMT4LG.mjs';
2
2
  import { RedisOptions, Redis } from 'ioredis';
3
3
  import { Service } from 'moleculer';
4
4
  import 'bson';
@@ -1,4 +1,4 @@
1
- import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.cjs';
1
+ import { P as PartialCustomServiceSchema } from '../newrelic-metrics-reporter-CmRMT4LG.cjs';
2
2
  import { Service } from 'moleculer';
3
3
  import { RedisOptions, Redis } from 'ioredis';
4
4
  import Redlock from 'redlock';
@@ -1,4 +1,4 @@
1
- import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.mjs';
1
+ import { P as PartialCustomServiceSchema } from '../newrelic-metrics-reporter-CmRMT4LG.mjs';
2
2
  import { Service } from 'moleculer';
3
3
  import { RedisOptions, Redis } from 'ioredis';
4
4
  import Redlock from 'redlock';
@@ -1,4 +1,4 @@
1
- import { ActionSchema, Context, Validators, Middleware, EventSchema, Service, ServiceHooks, Logger, ServiceBroker, ActionEndpoint, EventEndpoint, Span } from 'moleculer';
1
+ import { ActionSchema, Context, Validators, Middleware, EventSchema, Service, ServiceHooks, Logger, ServiceBroker, ActionEndpoint, EventEndpoint, Span, TracerExporters, Tracer, MetricReporters, MetricRegistry } from 'moleculer';
2
2
  import { ObjectId } from 'bson';
3
3
  import { ZodType, z } from 'zod/v4';
4
4
  import { Options, ErrorObject } from 'ajv/dist/2019.js';
@@ -615,5 +615,128 @@ declare module 'pino' {
615
615
  }
616
616
  }
617
617
 
618
- export { ZodValidator as Z, AjvValidator as d, ContextFactory as i };
619
- export type { Alias as A, ResponsesObject as B, CustomActionSchema as C, Document as D, EncodingObject as E, SecurityRequirementObject as F, SecuritySchemeObject as G, HeaderObject as H, InfoObject as I, JSONSchemaType as J, ServerObject as K, LicenseObject as L, MoleculerLoggerConfigOptions as M, ServerVariableObject as N, OperationObject as O, PartialCustomServiceSchema as P, Transform as Q, ReferenceObject as R, SomeJSONSchema as S, TagObject as T, TransformField as U, TransformLevel as V, TransformMap as W, Transformer as X, ValidationSchema as Y, SchemaObject as a, CustomServiceSchema as b, CreateLoggerOptions as c, ApiKeySecurityScheme as e, CallbackObject as f, ComponentsObject as g, ContactObject as h, ExampleObject as j, ExternalDocumentationObject as k, HttpSecurityScheme as l, CallbackServiceThis as m, ObjectServiceThis as n, LinkObject as o, MediaTypeObject as p, OAuth2SecurityScheme as q, OpenIdSecurityScheme as r, ParameterBaseObject as s, ParameterObject as t, PathItemObject as u, PathsObject as v, PropertiesSchema as w, RequestBodyObject as x, RequiredMembers as y, ResponseObject as z };
618
+ type NewrelicTraceExporterOptions = {
619
+ logger?: Logger;
620
+ safetyTags?: boolean;
621
+ /**
622
+ * Base URL for NewRelic server.
623
+ */
624
+ baseURL?: string;
625
+ /**
626
+ * Maximum number of spans to be sent in one time.
627
+ */
628
+ batchSize?: number;
629
+ /**
630
+ * NewRelic Insert API Key.
631
+ */
632
+ insertKey?: string;
633
+ /**
634
+ * Batch send time interval in seconds.
635
+ */
636
+ interval?: number;
637
+ /**
638
+ * Default span tags.
639
+ */
640
+ defaultTags?: Record<string, unknown> | ((tracer?: unknown) => Record<string, unknown>);
641
+ };
642
+ /**
643
+ * >>> Hard copy of the moleculer NewRelic provider. It didn't handle errors correctly
644
+ *
645
+ * Trace Exporter for NewRelic using Zipkin data.
646
+ *
647
+ * NewRelic zipkin tracer: https://docs.newrelic.com/docs/understand-dependencies/distributed-tracing/trace-api/report-zipkin-format-traces-trace-api
648
+ * API v2: https://zipkin.io/zipkin-api/#/
649
+ */
650
+ declare class NewrelicTraceExporter extends TracerExporters.Base {
651
+ private queue;
652
+ private timer;
653
+ private defaultTags;
654
+ constructor(opts: NewrelicTraceExporterOptions);
655
+ /**
656
+ * Initialize Trace Exporter.
657
+ */
658
+ init(tracer: Tracer): void;
659
+ /**
660
+ * Stop Trace exporter
661
+ */
662
+ stop(): Promise<void>;
663
+ /**
664
+ * Span is finished.
665
+ */
666
+ spanFinished(span: Span): void;
667
+ /**
668
+ * Flush tracing data to NewRelic Zipkin api endpoint
669
+ */
670
+ flush(): Promise<void>;
671
+ /**
672
+ * Generate tracing data for NewRelic
673
+ */
674
+ generateTracingData(): unknown[];
675
+ /**
676
+ * Create NewRelic v1 payload
677
+ */
678
+ makePayload(span: Span): unknown;
679
+ }
680
+ declare module 'moleculer' {
681
+ namespace TracerExporters {
682
+ interface Base {
683
+ opts: NewrelicTraceExporterOptions;
684
+ }
685
+ }
686
+ }
687
+
688
+ type DefaultTags = Record<string, unknown> | ((registry: MetricRegistry) => Record<string, unknown>);
689
+ type NewrelicMetricsOptions = MetricReporters.Base.MetricReporterOptions & {
690
+ /**
691
+ * Base URL for NewRelic server.
692
+ */
693
+ baseURL?: string;
694
+ /**
695
+ * NewRelic Insert API Key
696
+ */
697
+ insertKey?: string;
698
+ /**
699
+ * Batch send time interval in seconds.
700
+ */
701
+ interval?: number;
702
+ /**
703
+ * Default tags to be added to all metrics.
704
+ */
705
+ defaultTags?: DefaultTags;
706
+ };
707
+ /**
708
+ * NewRelic metrics reporter.
709
+ *
710
+ * NewRelic API: https://docs.newrelic.com/docs/data-apis/understand-data/metric-data/metric-data-type/
711
+ */
712
+ declare class NewrelicMetricsReporter extends MetricReporters.Base {
713
+ private timer;
714
+ private defaultTags;
715
+ constructor(opts: NewrelicMetricsOptions);
716
+ /**
717
+ * Initialize Trace Exporter.
718
+ */
719
+ init(registry: MetricRegistry): void;
720
+ /**
721
+ * Stop Trace exporter
722
+ */
723
+ stop(): Promise<void>;
724
+ /**
725
+ * Flush tracing data to NewRelic Zipkin api endpoint
726
+ */
727
+ flush(): Promise<void>;
728
+ /**
729
+ * Generate metrics data for NewRelic
730
+ */
731
+ generateMetricsPayload(): unknown[];
732
+ }
733
+ declare module 'moleculer' {
734
+ namespace MetricReporters {
735
+ interface Base {
736
+ opts: NewrelicMetricsOptions;
737
+ }
738
+ }
739
+ }
740
+
741
+ export { ZodValidator as $, NewrelicMetricsReporter as N, AjvValidator as d, ContextFactory as i, NewrelicTraceExporter as q };
742
+ export type { Alias as A, ResponseObject as B, CustomActionSchema as C, Document as D, EncodingObject as E, ResponsesObject as F, SecurityRequirementObject as G, HeaderObject as H, InfoObject as I, JSONSchemaType as J, SecuritySchemeObject as K, LicenseObject as L, MoleculerLoggerConfigOptions as M, OperationObject as O, PartialCustomServiceSchema as P, ServerObject as Q, ReferenceObject as R, SomeJSONSchema as S, ServerVariableObject as T, TagObject as U, Transform as V, TransformField as W, TransformLevel as X, TransformMap as Y, Transformer as Z, ValidationSchema as _, SchemaObject as a, CustomServiceSchema as b, CreateLoggerOptions as c, ApiKeySecurityScheme as e, CallbackObject as f, ComponentsObject as g, ContactObject as h, ExampleObject as j, ExternalDocumentationObject as k, HttpSecurityScheme as l, CallbackServiceThis as m, ObjectServiceThis as n, LinkObject as o, MediaTypeObject as p, OAuth2SecurityScheme as r, OpenIdSecurityScheme as s, ParameterBaseObject as t, ParameterObject as u, PathItemObject as v, PathsObject as w, PropertiesSchema as x, RequestBodyObject as y, RequiredMembers as z };
@@ -1,4 +1,4 @@
1
- import { ActionSchema, Context, Validators, Middleware, EventSchema, Service, ServiceHooks, Logger, ServiceBroker, ActionEndpoint, EventEndpoint, Span } from 'moleculer';
1
+ import { ActionSchema, Context, Validators, Middleware, EventSchema, Service, ServiceHooks, Logger, ServiceBroker, ActionEndpoint, EventEndpoint, Span, TracerExporters, Tracer, MetricReporters, MetricRegistry } from 'moleculer';
2
2
  import { ObjectId } from 'bson';
3
3
  import { ZodType, z } from 'zod/v4';
4
4
  import { Options, ErrorObject } from 'ajv/dist/2019.js';
@@ -615,5 +615,128 @@ declare module 'pino' {
615
615
  }
616
616
  }
617
617
 
618
- export { ZodValidator as Z, AjvValidator as d, ContextFactory as i };
619
- export type { Alias as A, ResponsesObject as B, CustomActionSchema as C, Document as D, EncodingObject as E, SecurityRequirementObject as F, SecuritySchemeObject as G, HeaderObject as H, InfoObject as I, JSONSchemaType as J, ServerObject as K, LicenseObject as L, MoleculerLoggerConfigOptions as M, ServerVariableObject as N, OperationObject as O, PartialCustomServiceSchema as P, Transform as Q, ReferenceObject as R, SomeJSONSchema as S, TagObject as T, TransformField as U, TransformLevel as V, TransformMap as W, Transformer as X, ValidationSchema as Y, SchemaObject as a, CustomServiceSchema as b, CreateLoggerOptions as c, ApiKeySecurityScheme as e, CallbackObject as f, ComponentsObject as g, ContactObject as h, ExampleObject as j, ExternalDocumentationObject as k, HttpSecurityScheme as l, CallbackServiceThis as m, ObjectServiceThis as n, LinkObject as o, MediaTypeObject as p, OAuth2SecurityScheme as q, OpenIdSecurityScheme as r, ParameterBaseObject as s, ParameterObject as t, PathItemObject as u, PathsObject as v, PropertiesSchema as w, RequestBodyObject as x, RequiredMembers as y, ResponseObject as z };
618
+ type NewrelicTraceExporterOptions = {
619
+ logger?: Logger;
620
+ safetyTags?: boolean;
621
+ /**
622
+ * Base URL for NewRelic server.
623
+ */
624
+ baseURL?: string;
625
+ /**
626
+ * Maximum number of spans to be sent in one time.
627
+ */
628
+ batchSize?: number;
629
+ /**
630
+ * NewRelic Insert API Key.
631
+ */
632
+ insertKey?: string;
633
+ /**
634
+ * Batch send time interval in seconds.
635
+ */
636
+ interval?: number;
637
+ /**
638
+ * Default span tags.
639
+ */
640
+ defaultTags?: Record<string, unknown> | ((tracer?: unknown) => Record<string, unknown>);
641
+ };
642
+ /**
643
+ * >>> Hard copy of the moleculer NewRelic provider. It didn't handle errors correctly
644
+ *
645
+ * Trace Exporter for NewRelic using Zipkin data.
646
+ *
647
+ * NewRelic zipkin tracer: https://docs.newrelic.com/docs/understand-dependencies/distributed-tracing/trace-api/report-zipkin-format-traces-trace-api
648
+ * API v2: https://zipkin.io/zipkin-api/#/
649
+ */
650
+ declare class NewrelicTraceExporter extends TracerExporters.Base {
651
+ private queue;
652
+ private timer;
653
+ private defaultTags;
654
+ constructor(opts: NewrelicTraceExporterOptions);
655
+ /**
656
+ * Initialize Trace Exporter.
657
+ */
658
+ init(tracer: Tracer): void;
659
+ /**
660
+ * Stop Trace exporter
661
+ */
662
+ stop(): Promise<void>;
663
+ /**
664
+ * Span is finished.
665
+ */
666
+ spanFinished(span: Span): void;
667
+ /**
668
+ * Flush tracing data to NewRelic Zipkin api endpoint
669
+ */
670
+ flush(): Promise<void>;
671
+ /**
672
+ * Generate tracing data for NewRelic
673
+ */
674
+ generateTracingData(): unknown[];
675
+ /**
676
+ * Create NewRelic v1 payload
677
+ */
678
+ makePayload(span: Span): unknown;
679
+ }
680
+ declare module 'moleculer' {
681
+ namespace TracerExporters {
682
+ interface Base {
683
+ opts: NewrelicTraceExporterOptions;
684
+ }
685
+ }
686
+ }
687
+
688
+ type DefaultTags = Record<string, unknown> | ((registry: MetricRegistry) => Record<string, unknown>);
689
+ type NewrelicMetricsOptions = MetricReporters.Base.MetricReporterOptions & {
690
+ /**
691
+ * Base URL for NewRelic server.
692
+ */
693
+ baseURL?: string;
694
+ /**
695
+ * NewRelic Insert API Key
696
+ */
697
+ insertKey?: string;
698
+ /**
699
+ * Batch send time interval in seconds.
700
+ */
701
+ interval?: number;
702
+ /**
703
+ * Default tags to be added to all metrics.
704
+ */
705
+ defaultTags?: DefaultTags;
706
+ };
707
+ /**
708
+ * NewRelic metrics reporter.
709
+ *
710
+ * NewRelic API: https://docs.newrelic.com/docs/data-apis/understand-data/metric-data/metric-data-type/
711
+ */
712
+ declare class NewrelicMetricsReporter extends MetricReporters.Base {
713
+ private timer;
714
+ private defaultTags;
715
+ constructor(opts: NewrelicMetricsOptions);
716
+ /**
717
+ * Initialize Trace Exporter.
718
+ */
719
+ init(registry: MetricRegistry): void;
720
+ /**
721
+ * Stop Trace exporter
722
+ */
723
+ stop(): Promise<void>;
724
+ /**
725
+ * Flush tracing data to NewRelic Zipkin api endpoint
726
+ */
727
+ flush(): Promise<void>;
728
+ /**
729
+ * Generate metrics data for NewRelic
730
+ */
731
+ generateMetricsPayload(): unknown[];
732
+ }
733
+ declare module 'moleculer' {
734
+ namespace MetricReporters {
735
+ interface Base {
736
+ opts: NewrelicMetricsOptions;
737
+ }
738
+ }
739
+ }
740
+
741
+ export { ZodValidator as $, NewrelicMetricsReporter as N, AjvValidator as d, ContextFactory as i, NewrelicTraceExporter as q };
742
+ export type { Alias as A, ResponseObject as B, CustomActionSchema as C, Document as D, EncodingObject as E, ResponsesObject as F, SecurityRequirementObject as G, HeaderObject as H, InfoObject as I, JSONSchemaType as J, SecuritySchemeObject as K, LicenseObject as L, MoleculerLoggerConfigOptions as M, OperationObject as O, PartialCustomServiceSchema as P, ServerObject as Q, ReferenceObject as R, SomeJSONSchema as S, ServerVariableObject as T, TagObject as U, Transform as V, TransformField as W, TransformLevel as X, TransformMap as Y, Transformer as Z, ValidationSchema as _, SchemaObject as a, CustomServiceSchema as b, CreateLoggerOptions as c, ApiKeySecurityScheme as e, CallbackObject as f, ComponentsObject as g, ContactObject as h, ExampleObject as j, ExternalDocumentationObject as k, HttpSecurityScheme as l, CallbackServiceThis as m, ObjectServiceThis as n, LinkObject as o, MediaTypeObject as p, OAuth2SecurityScheme as r, OpenIdSecurityScheme as s, ParameterBaseObject as t, ParameterObject as u, PathItemObject as v, PathsObject as w, PropertiesSchema as x, RequestBodyObject as y, RequiredMembers as z };
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "type": "git",
7
7
  "url": "https://github.com/treatwell/moleculer-essentials"
8
8
  },
9
- "version": "2.1.0",
9
+ "version": "2.1.1-beta.2",
10
10
  "main": "./dist/index.cjs",
11
11
  "module": "./dist/index.mjs",
12
12
  "types": "./dist/index.d.cts",