@treatwell/moleculer-essentials 1.3.1 → 2.0.0-beta.1

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
@@ -10,10 +10,10 @@ var dateFns = require('date-fns');
10
10
  var bson = require('bson');
11
11
  var v4 = require('zod/v4');
12
12
  var index$1 = require('./index-82e1CXJX.cjs');
13
- var compat = require('es-toolkit/compat');
14
- var http = require('http');
15
13
  var pino = require('pino');
16
14
  var node_os = require('node:os');
15
+ var compat = require('es-toolkit/compat');
16
+ var http = require('http');
17
17
 
18
18
  function getSchemaFromMoleculer(schema) {
19
19
  if (!schema) {
@@ -1017,10 +1017,148 @@ class ServiceFactory extends moleculer.Service {
1017
1017
  }
1018
1018
  }
1019
1019
 
1020
+ function createPinoPrettyTransport(opts) {
1021
+ return {
1022
+ // Building with pkgroll (rollup) will bundle the file into the root index.js so we keep
1023
+ // `logger/` in the path.
1024
+ target: "./logger/pino-pretty-transport.cjs",
1025
+ options: {
1026
+ singleLine: true,
1027
+ ignore: [
1028
+ "hostname",
1029
+ // Hide req and res in logs as it will be included in the pretty message
1030
+ // or is not useful in development
1031
+ "req",
1032
+ "res",
1033
+ "responseTime",
1034
+ "span\\.id"
1035
+ ].join(","),
1036
+ ...opts
1037
+ }
1038
+ };
1039
+ }
1040
+
1041
+ function pinoLogMethod(args, method) {
1042
+ const mergingObject = {};
1043
+ let msg = "";
1044
+ for (const arg of args) {
1045
+ if (arg instanceof Error) {
1046
+ mergingObject.err = arg;
1047
+ } else if (typeof arg === "string") {
1048
+ msg += (msg ? " " : "") + arg;
1049
+ } else if (arg && "msg" in arg && typeof arg.msg === "string") {
1050
+ msg += (msg ? " " : "") + arg.msg;
1051
+ Object.assign(mergingObject, arg);
1052
+ } else {
1053
+ Object.assign(mergingObject, arg);
1054
+ }
1055
+ }
1056
+ mergingObject.msg = msg;
1057
+ return method.apply(this, [mergingObject]);
1058
+ }
1059
+ function wrapLogMethodWithFilter(original, filter) {
1060
+ const isMatch = (arg) => {
1061
+ let msg;
1062
+ if (arg instanceof Error) {
1063
+ msg = arg.message;
1064
+ } else if (typeof arg === "string") {
1065
+ msg = arg;
1066
+ } else if (arg && "msg" in arg && typeof arg.msg === "string") {
1067
+ msg = arg.msg;
1068
+ }
1069
+ return msg ? filter.test(msg) : false;
1070
+ };
1071
+ return function(args, method, level) {
1072
+ if (args.some(isMatch)) {
1073
+ return;
1074
+ }
1075
+ return original.apply(this, [args, method, level]);
1076
+ };
1077
+ }
1078
+
1079
+ const DEFAULT_REDACT_PATHS = [
1080
+ // Request headers
1081
+ "req.headers.authorization",
1082
+ 'req.headers["device-useragent"]',
1083
+ "req.headers.connection",
1084
+ 'req.headers["content-type"]',
1085
+ 'req.headers["accept"]',
1086
+ 'req.headers["keep-alive"]',
1087
+ 'req.headers["dnt"]',
1088
+ 'req.headers["accept-encoding"]',
1089
+ 'req.headers["accept-language"]',
1090
+ 'req.headers["sec-fetch-site"]',
1091
+ 'req.headers["sec-fetch-mode"]',
1092
+ 'req.headers["sec-fetch-dest"]',
1093
+ 'req.headers["sec-fetch-user"]',
1094
+ 'req.headers["sec-ch-ua"]',
1095
+ 'req.headers["sec-ch-ua-mobile"]',
1096
+ 'req.headers["upgrade-insecure-requests"]',
1097
+ 'req.headers["if-none-match"]',
1098
+ 'req.headers["cookie"]',
1099
+ "req.headers.referer",
1100
+ // Response headers
1101
+ "res.headers.allow",
1102
+ "res.headers.vary",
1103
+ 'res.headers["x-powered-by"]',
1104
+ 'res.headers["access-control-allow-origin"]',
1105
+ 'res.headers["content-type"]',
1106
+ 'res.headers["content-encoding"]'
1107
+ ];
1108
+ function createLogger(opts = {}) {
1109
+ const { prettyOptions, filter, ...pinoOpts } = opts;
1110
+ let transport = void 0;
1111
+ if ("transport" in opts) {
1112
+ transport = opts.transport;
1113
+ } else if (prettyOptions?.enabled ?? process.stdout.isTTY) {
1114
+ transport = createPinoPrettyTransport(prettyOptions);
1115
+ }
1116
+ const redact = {
1117
+ paths: DEFAULT_REDACT_PATHS,
1118
+ remove: true
1119
+ };
1120
+ if (Array.isArray(opts.redact)) {
1121
+ redact.paths = opts.redact;
1122
+ } else if (opts.redact) {
1123
+ Object.assign(redact, opts.redact);
1124
+ }
1125
+ return pino.pino({
1126
+ ...pinoOpts,
1127
+ transport,
1128
+ base: { hostname: node_os.hostname(), ...pinoOpts.base },
1129
+ hooks: {
1130
+ logMethod: filter ? wrapLogMethodWithFilter(pinoLogMethod, filter) : pinoLogMethod,
1131
+ ...pinoOpts.hooks
1132
+ },
1133
+ redact
1134
+ });
1135
+ }
1136
+ function createLoggerConfig(opts = {}) {
1137
+ const {
1138
+ traceIdField = "trace.id",
1139
+ spanIdField = "span.id",
1140
+ logger = createLogger()
1141
+ } = opts;
1142
+ return {
1143
+ type: "Pino",
1144
+ options: {
1145
+ createLogger: (level, bindings) => {
1146
+ const childBindings = { label: bindings.mod };
1147
+ if (traceIdField !== false) {
1148
+ childBindings[traceIdField] = bindings.traceID;
1149
+ }
1150
+ if (spanIdField !== false) {
1151
+ childBindings[spanIdField] = bindings.spanID;
1152
+ }
1153
+ return logger.child(childBindings, { level });
1154
+ }
1155
+ }
1156
+ };
1157
+ }
1158
+
1020
1159
  function createServiceBroker(opts = {}) {
1021
1160
  return new CustomServiceBroker({
1022
- logger: process.env.NODE_ENV === "test" ? false : void 0,
1023
- // TODO Add default logger
1161
+ logger: process.env.NODE_ENV === "test" ? false : createLoggerConfig(),
1024
1162
  validator: new AjvValidator(
1025
1163
  {
1026
1164
  default: {
@@ -1196,111 +1334,6 @@ function HealthCheckMiddleware(_opts) {
1196
1334
  };
1197
1335
  }
1198
1336
 
1199
- const FILTER_SERVICE_LOGS_REGEX = /('[^']*' service is registered\.)|(Service '[^']*' started\.)|('[^']*' finished starting\.)/;
1200
- let transport;
1201
- if (process.env.NODE_ENV !== "production") {
1202
- transport = {
1203
- // Building with pkgroll (rollup) will bundle the file into the root index.js so we keep
1204
- // `logger/` in the path.
1205
- target: "./logger/pino-pretty-transport.cjs",
1206
- options: {
1207
- colorize: true,
1208
- singleLine: true,
1209
- ignore: [
1210
- "hostname",
1211
- // Hide req and res in logs as it will be included in the pretty message
1212
- // or is not useful in development
1213
- "req",
1214
- "res",
1215
- "responseTime",
1216
- "span\\.id"
1217
- ].join(",")
1218
- }
1219
- };
1220
- }
1221
- const logger = pino.pino({
1222
- base: {
1223
- hostname: node_os.hostname(),
1224
- // Need to set this to allow logs in context of traces
1225
- // Note that this will not work with dotenv loaded environment variables.
1226
- "service.name": process.env.NEWRELIC_APP_NAME
1227
- },
1228
- transport,
1229
- hooks: {
1230
- /**
1231
- * This function allow logs like `logger.info('str 1', {a: 1}, 'str 2', ...)` to
1232
- * be formatted correctly (every string are concatenated into one and objects are merged in the log).
1233
- */
1234
- logMethod(args, method) {
1235
- const mergingObject = {};
1236
- let msg = "";
1237
- for (const arg of args) {
1238
- if (arg instanceof Error) {
1239
- mergingObject.err = arg;
1240
- } else if (typeof arg === "string") {
1241
- msg += (msg ? " " : "") + arg;
1242
- } else if (arg && "msg" in arg && typeof arg.msg === "string") {
1243
- msg += (msg ? " " : "") + arg.msg;
1244
- Object.assign(mergingObject, arg);
1245
- } else {
1246
- Object.assign(mergingObject, arg);
1247
- }
1248
- }
1249
- if (process.env.FILTER_SERVICE_LOGS === "yes" && FILTER_SERVICE_LOGS_REGEX.test(msg)) {
1250
- return void 0;
1251
- }
1252
- mergingObject.msg = msg;
1253
- return method.apply(this, [mergingObject]);
1254
- }
1255
- },
1256
- redact: {
1257
- paths: [
1258
- // Request headers
1259
- "req.headers.authorization",
1260
- 'req.headers["device-useragent"]',
1261
- "req.headers.connection",
1262
- 'req.headers["content-type"]',
1263
- 'req.headers["accept"]',
1264
- 'req.headers["keep-alive"]',
1265
- 'req.headers["dnt"]',
1266
- 'req.headers["accept-encoding"]',
1267
- 'req.headers["accept-language"]',
1268
- 'req.headers["sec-fetch-site"]',
1269
- 'req.headers["sec-fetch-mode"]',
1270
- 'req.headers["sec-fetch-dest"]',
1271
- 'req.headers["sec-fetch-user"]',
1272
- 'req.headers["sec-ch-ua"]',
1273
- 'req.headers["sec-ch-ua-mobile"]',
1274
- 'req.headers["upgrade-insecure-requests"]',
1275
- 'req.headers["if-none-match"]',
1276
- 'req.headers["cookie"]',
1277
- "req.headers.referer",
1278
- // Response headers
1279
- "res.headers.allow",
1280
- "res.headers.vary",
1281
- 'res.headers["x-powered-by"]',
1282
- 'res.headers["access-control-allow-origin"]',
1283
- 'res.headers["content-type"]',
1284
- 'res.headers["content-encoding"]'
1285
- ],
1286
- remove: true
1287
- }
1288
- });
1289
- const createLogger = (bindings) => logger.child(bindings);
1290
- function createLoggerConfig() {
1291
- return {
1292
- type: "Pino",
1293
- options: {
1294
- createLogger: (level, bindings) => createLogger({
1295
- label: bindings.mod,
1296
- "trace.id": bindings.traceID,
1297
- "span.id": bindings.spanID
1298
- })
1299
- }
1300
- };
1301
- }
1302
- const defaultLogger = createLogger({ label: "default" });
1303
-
1304
1337
  function flattenTags(obj, convertToString = false, path = "") {
1305
1338
  if (!obj) return null;
1306
1339
  return Object.keys(obj).reduce((res, k) => {
@@ -1627,6 +1660,5 @@ exports.ZodValidator = ZodValidator;
1627
1660
  exports.createLogger = createLogger;
1628
1661
  exports.createLoggerConfig = createLoggerConfig;
1629
1662
  exports.createServiceBroker = createServiceBroker;
1630
- exports.defaultLogger = defaultLogger;
1631
1663
  exports.getMetadataFromService = getMetadataFromService;
1632
1664
  exports.isServiceSelected = isServiceSelected;
package/dist/index.d.cts CHANGED
@@ -1,11 +1,12 @@
1
- import { J as JSONSchemaType, S as SomeJSONSchema, C as CustomActionSchema, A as Alias, a as CustomServiceSchema, D as Document, b as SchemaObject, O as OperationObject, R as ReferenceObject } from './index-TXVFWos4.cjs';
2
- export { d as AjvValidator, x as ApiKeySecurityScheme, F as CallbackObject, G as ComponentsObject, j as ContactObject, i as ContextFactory, q as EncodingObject, p as ExampleObject, E as ExternalDocumentationObject, H as HeaderObject, w as HttpSecurityScheme, I as InfoObject, U as InternalCallbackServiceThis, Q as InternalObjectServiceThis, L as LicenseObject, s as LinkObject, M as MediaTypeObject, y as OAuth2SecurityScheme, z as OpenIdSecurityScheme, o as ParameterBaseObject, n as ParameterObject, N as PathItemObject, m as PathsObject, P as PropertiesSchema, r as RequestBodyObject, c as RequiredMembers, t as ResponseObject, u as ResponsesObject, v as SecurityRequirementObject, B as SecuritySchemeObject, l as ServerObject, k as ServerVariableObject, K as TagObject, e as Transform, h as TransformField, f as TransformLevel, g as TransformMap, T as Transformer, V as ValidationSchema, Z as ZodValidator, W as createLogger, X as createLoggerConfig, Y as defaultLogger } from './index-TXVFWos4.cjs';
1
+ import { J as JSONSchemaType, S as SomeJSONSchema, C as CustomActionSchema, A as Alias, a as CustomServiceSchema, D as Document, b as SchemaObject, O as OperationObject, R as ReferenceObject, c as CreateLoggerOptions, M as MoleculerLoggerConfigOptions } from './types-BEknQmfU.cjs';
2
+ export { e as AjvValidator, z as ApiKeySecurityScheme, K as CallbackObject, N as ComponentsObject, k as ContactObject, j as ContextFactory, r as EncodingObject, q as ExampleObject, E as ExternalDocumentationObject, H as HeaderObject, y as HttpSecurityScheme, I as InfoObject, X as InternalCallbackServiceThis, W as InternalObjectServiceThis, L as LicenseObject, u as LinkObject, s as MediaTypeObject, B as OAuth2SecurityScheme, F as OpenIdSecurityScheme, p as ParameterBaseObject, o as ParameterObject, U as PathItemObject, n as PathsObject, P as PropertiesSchema, t as RequestBodyObject, d as RequiredMembers, v as ResponseObject, w as ResponsesObject, x as SecurityRequirementObject, G as SecuritySchemeObject, m as ServerObject, l as ServerVariableObject, Q as TagObject, f as Transform, i as TransformField, g as TransformLevel, h as TransformMap, T as Transformer, V as ValidationSchema, Z as ZodValidator } from './types-BEknQmfU.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
6
  import * as Moleculer from 'moleculer';
7
- import { Context, ServiceSchema, ServiceSettingSchema, Service, ServiceBroker, BrokerOptions, Middleware, TracerExporters, LoggerInstance, Tracer, Span, MetricReporters, MetricRegistry, MetricReporterOptions } from 'moleculer';
8
- import 'pino';
7
+ import { Context, ServiceSchema, ServiceSettingSchema, Service, ServiceBroker, BrokerOptions, Middleware, LoggerConfig, TracerExporters, LoggerInstance, Tracer, Span, MetricReporters, MetricRegistry, MetricReporterOptions } from 'moleculer';
8
+ import { Logger } from 'pino';
9
+ import 'pino-pretty';
9
10
 
10
11
  declare function omitFields<T extends Record<string, unknown>, F extends keyof T>(schema: JSONSchemaType<T>, fields: F[], refName?: string): JSONSchemaType<Omit<T, F>>;
11
12
  declare function pickFields<T extends Record<string, unknown>, F extends keyof T>(schema: JSONSchemaType<T>, fields: F[], refName?: string): JSONSchemaType<Pick<T, F>>;
@@ -254,6 +255,21 @@ type HealthCheckOptions = {
254
255
  */
255
256
  declare function HealthCheckMiddleware(_opts: Partial<HealthCheckOptions>): Middleware;
256
257
 
258
+ /**
259
+ * Create a Pino logger with multiple customization by default (can be overridden):
260
+ * - A more open `logMethod` function that allows mixed string/object arguments
261
+ * - Add hostname as base prop
262
+ * - Enable pino-pretty on TTY terminals (with some basic http support)
263
+ * - Some default redaction of paths related to req&res props
264
+ */
265
+ declare function createLogger(opts?: CreateLoggerOptions): Logger;
266
+ /**
267
+ * Create moleculer logger config.
268
+ * This returns a Pino config with a couple of customization:
269
+ * - Trace ID and Span ID is automatically added to the ctx.logger (only with this package's ContextFactory)
270
+ */
271
+ declare function createLoggerConfig(opts?: MoleculerLoggerConfigOptions): LoggerConfig;
272
+
257
273
  type NewrelicTraceExporterOptions = {
258
274
  logger?: LoggerInstance;
259
275
  safetyTags?: boolean;
@@ -365,5 +381,5 @@ declare class NewrelicMetricsReporter extends MetricReporters.Base {
365
381
  generateMetricsPayload(): unknown[];
366
382
  }
367
383
 
368
- export { AjvExtractor, Alias, COERCE_ARRAY_ATTRIBUTE, CustomActionSchema, CustomServiceSchema, DATE_TYPE, Document, EMPTY_OBJECT_SCHEMA, HealthCheckMiddleware, JSONSchemaType, NewrelicMetricsReporter, NewrelicTraceExporter, OBJECTID_TYPE, OpenAPIExtractor, OpenAPIMixin, OperationObject, RefExtractor, ReferenceObject, SCHEMA_REF_NAME, SchemaObject, ServiceFactory, SomeJSONSchema, addFieldsToSchema, composeSchemas, createOpenAPIResponses, createServiceBroker, getMetadataFromService, isServiceSelected, isZodSchema, omitFields, optionalExceptFields, optionalFields, pickFields, toPartialSchema, wrapMixin, wrapService, zodCoerceArray, zodDate, zodObjectId, zodToOpenAPISchema };
384
+ export { AjvExtractor, Alias, COERCE_ARRAY_ATTRIBUTE, CustomActionSchema, CustomServiceSchema, DATE_TYPE, Document, EMPTY_OBJECT_SCHEMA, HealthCheckMiddleware, JSONSchemaType, NewrelicMetricsReporter, NewrelicTraceExporter, OBJECTID_TYPE, OpenAPIExtractor, OpenAPIMixin, OperationObject, 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 };
369
385
  export type { OpenAPIMixinOptions, OpenAPIResponses, Selector };
package/dist/index.d.mts CHANGED
@@ -1,11 +1,12 @@
1
- import { J as JSONSchemaType, S as SomeJSONSchema, C as CustomActionSchema, A as Alias, a as CustomServiceSchema, D as Document, b as SchemaObject, O as OperationObject, R as ReferenceObject } from './index-TXVFWos4.mjs';
2
- export { d as AjvValidator, x as ApiKeySecurityScheme, F as CallbackObject, G as ComponentsObject, j as ContactObject, i as ContextFactory, q as EncodingObject, p as ExampleObject, E as ExternalDocumentationObject, H as HeaderObject, w as HttpSecurityScheme, I as InfoObject, U as InternalCallbackServiceThis, Q as InternalObjectServiceThis, L as LicenseObject, s as LinkObject, M as MediaTypeObject, y as OAuth2SecurityScheme, z as OpenIdSecurityScheme, o as ParameterBaseObject, n as ParameterObject, N as PathItemObject, m as PathsObject, P as PropertiesSchema, r as RequestBodyObject, c as RequiredMembers, t as ResponseObject, u as ResponsesObject, v as SecurityRequirementObject, B as SecuritySchemeObject, l as ServerObject, k as ServerVariableObject, K as TagObject, e as Transform, h as TransformField, f as TransformLevel, g as TransformMap, T as Transformer, V as ValidationSchema, Z as ZodValidator, W as createLogger, X as createLoggerConfig, Y as defaultLogger } from './index-TXVFWos4.mjs';
1
+ import { J as JSONSchemaType, S as SomeJSONSchema, C as CustomActionSchema, A as Alias, a as CustomServiceSchema, D as Document, b as SchemaObject, O as OperationObject, R as ReferenceObject, c as CreateLoggerOptions, M as MoleculerLoggerConfigOptions } from './types-BEknQmfU.mjs';
2
+ export { e as AjvValidator, z as ApiKeySecurityScheme, K as CallbackObject, N as ComponentsObject, k as ContactObject, j as ContextFactory, r as EncodingObject, q as ExampleObject, E as ExternalDocumentationObject, H as HeaderObject, y as HttpSecurityScheme, I as InfoObject, X as InternalCallbackServiceThis, W as InternalObjectServiceThis, L as LicenseObject, u as LinkObject, s as MediaTypeObject, B as OAuth2SecurityScheme, F as OpenIdSecurityScheme, p as ParameterBaseObject, o as ParameterObject, U as PathItemObject, n as PathsObject, P as PropertiesSchema, t as RequestBodyObject, d as RequiredMembers, v as ResponseObject, w as ResponsesObject, x as SecurityRequirementObject, G as SecuritySchemeObject, m as ServerObject, l as ServerVariableObject, Q as TagObject, f as Transform, i as TransformField, g as TransformLevel, h as TransformMap, T as Transformer, V as ValidationSchema, Z as ZodValidator } from './types-BEknQmfU.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
6
  import * as Moleculer from 'moleculer';
7
- import { Context, ServiceSchema, ServiceSettingSchema, Service, ServiceBroker, BrokerOptions, Middleware, TracerExporters, LoggerInstance, Tracer, Span, MetricReporters, MetricRegistry, MetricReporterOptions } from 'moleculer';
8
- import 'pino';
7
+ import { Context, ServiceSchema, ServiceSettingSchema, Service, ServiceBroker, BrokerOptions, Middleware, LoggerConfig, TracerExporters, LoggerInstance, Tracer, Span, MetricReporters, MetricRegistry, MetricReporterOptions } from 'moleculer';
8
+ import { Logger } from 'pino';
9
+ import 'pino-pretty';
9
10
 
10
11
  declare function omitFields<T extends Record<string, unknown>, F extends keyof T>(schema: JSONSchemaType<T>, fields: F[], refName?: string): JSONSchemaType<Omit<T, F>>;
11
12
  declare function pickFields<T extends Record<string, unknown>, F extends keyof T>(schema: JSONSchemaType<T>, fields: F[], refName?: string): JSONSchemaType<Pick<T, F>>;
@@ -254,6 +255,21 @@ type HealthCheckOptions = {
254
255
  */
255
256
  declare function HealthCheckMiddleware(_opts: Partial<HealthCheckOptions>): Middleware;
256
257
 
258
+ /**
259
+ * Create a Pino logger with multiple customization by default (can be overridden):
260
+ * - A more open `logMethod` function that allows mixed string/object arguments
261
+ * - Add hostname as base prop
262
+ * - Enable pino-pretty on TTY terminals (with some basic http support)
263
+ * - Some default redaction of paths related to req&res props
264
+ */
265
+ declare function createLogger(opts?: CreateLoggerOptions): Logger;
266
+ /**
267
+ * Create moleculer logger config.
268
+ * This returns a Pino config with a couple of customization:
269
+ * - Trace ID and Span ID is automatically added to the ctx.logger (only with this package's ContextFactory)
270
+ */
271
+ declare function createLoggerConfig(opts?: MoleculerLoggerConfigOptions): LoggerConfig;
272
+
257
273
  type NewrelicTraceExporterOptions = {
258
274
  logger?: LoggerInstance;
259
275
  safetyTags?: boolean;
@@ -365,5 +381,5 @@ declare class NewrelicMetricsReporter extends MetricReporters.Base {
365
381
  generateMetricsPayload(): unknown[];
366
382
  }
367
383
 
368
- export { AjvExtractor, Alias, COERCE_ARRAY_ATTRIBUTE, CustomActionSchema, CustomServiceSchema, DATE_TYPE, Document, EMPTY_OBJECT_SCHEMA, HealthCheckMiddleware, JSONSchemaType, NewrelicMetricsReporter, NewrelicTraceExporter, OBJECTID_TYPE, OpenAPIExtractor, OpenAPIMixin, OperationObject, RefExtractor, ReferenceObject, SCHEMA_REF_NAME, SchemaObject, ServiceFactory, SomeJSONSchema, addFieldsToSchema, composeSchemas, createOpenAPIResponses, createServiceBroker, getMetadataFromService, isServiceSelected, isZodSchema, omitFields, optionalExceptFields, optionalFields, pickFields, toPartialSchema, wrapMixin, wrapService, zodCoerceArray, zodDate, zodObjectId, zodToOpenAPISchema };
384
+ export { AjvExtractor, Alias, COERCE_ARRAY_ATTRIBUTE, CustomActionSchema, CustomServiceSchema, DATE_TYPE, Document, EMPTY_OBJECT_SCHEMA, HealthCheckMiddleware, JSONSchemaType, NewrelicMetricsReporter, NewrelicTraceExporter, OBJECTID_TYPE, OpenAPIExtractor, OpenAPIMixin, OperationObject, 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 };
369
385
  export type { OpenAPIMixinOptions, OpenAPIResponses, Selector };
package/dist/index.mjs CHANGED
@@ -10,10 +10,10 @@ import { ObjectId } from 'bson';
10
10
  import { z } from 'zod/v4';
11
11
  import { w as wrapMixin } from './index-DNJWwcZu.mjs';
12
12
  export { a as wrapService } from './index-DNJWwcZu.mjs';
13
- import { merge, defaultsDeep, isObject } from 'es-toolkit/compat';
14
- import http, { STATUS_CODES } from 'http';
15
13
  import { pino } from 'pino';
16
14
  import { hostname } from 'node:os';
15
+ import { merge, defaultsDeep, isObject } from 'es-toolkit/compat';
16
+ import http, { STATUS_CODES } from 'http';
17
17
 
18
18
  function getSchemaFromMoleculer(schema) {
19
19
  if (!schema) {
@@ -1017,10 +1017,148 @@ class ServiceFactory extends Service {
1017
1017
  }
1018
1018
  }
1019
1019
 
1020
+ function createPinoPrettyTransport(opts) {
1021
+ return {
1022
+ // Building with pkgroll (rollup) will bundle the file into the root index.js so we keep
1023
+ // `logger/` in the path.
1024
+ target: "./logger/pino-pretty-transport.cjs",
1025
+ options: {
1026
+ singleLine: true,
1027
+ ignore: [
1028
+ "hostname",
1029
+ // Hide req and res in logs as it will be included in the pretty message
1030
+ // or is not useful in development
1031
+ "req",
1032
+ "res",
1033
+ "responseTime",
1034
+ "span\\.id"
1035
+ ].join(","),
1036
+ ...opts
1037
+ }
1038
+ };
1039
+ }
1040
+
1041
+ function pinoLogMethod(args, method) {
1042
+ const mergingObject = {};
1043
+ let msg = "";
1044
+ for (const arg of args) {
1045
+ if (arg instanceof Error) {
1046
+ mergingObject.err = arg;
1047
+ } else if (typeof arg === "string") {
1048
+ msg += (msg ? " " : "") + arg;
1049
+ } else if (arg && "msg" in arg && typeof arg.msg === "string") {
1050
+ msg += (msg ? " " : "") + arg.msg;
1051
+ Object.assign(mergingObject, arg);
1052
+ } else {
1053
+ Object.assign(mergingObject, arg);
1054
+ }
1055
+ }
1056
+ mergingObject.msg = msg;
1057
+ return method.apply(this, [mergingObject]);
1058
+ }
1059
+ function wrapLogMethodWithFilter(original, filter) {
1060
+ const isMatch = (arg) => {
1061
+ let msg;
1062
+ if (arg instanceof Error) {
1063
+ msg = arg.message;
1064
+ } else if (typeof arg === "string") {
1065
+ msg = arg;
1066
+ } else if (arg && "msg" in arg && typeof arg.msg === "string") {
1067
+ msg = arg.msg;
1068
+ }
1069
+ return msg ? filter.test(msg) : false;
1070
+ };
1071
+ return function(args, method, level) {
1072
+ if (args.some(isMatch)) {
1073
+ return;
1074
+ }
1075
+ return original.apply(this, [args, method, level]);
1076
+ };
1077
+ }
1078
+
1079
+ const DEFAULT_REDACT_PATHS = [
1080
+ // Request headers
1081
+ "req.headers.authorization",
1082
+ 'req.headers["device-useragent"]',
1083
+ "req.headers.connection",
1084
+ 'req.headers["content-type"]',
1085
+ 'req.headers["accept"]',
1086
+ 'req.headers["keep-alive"]',
1087
+ 'req.headers["dnt"]',
1088
+ 'req.headers["accept-encoding"]',
1089
+ 'req.headers["accept-language"]',
1090
+ 'req.headers["sec-fetch-site"]',
1091
+ 'req.headers["sec-fetch-mode"]',
1092
+ 'req.headers["sec-fetch-dest"]',
1093
+ 'req.headers["sec-fetch-user"]',
1094
+ 'req.headers["sec-ch-ua"]',
1095
+ 'req.headers["sec-ch-ua-mobile"]',
1096
+ 'req.headers["upgrade-insecure-requests"]',
1097
+ 'req.headers["if-none-match"]',
1098
+ 'req.headers["cookie"]',
1099
+ "req.headers.referer",
1100
+ // Response headers
1101
+ "res.headers.allow",
1102
+ "res.headers.vary",
1103
+ 'res.headers["x-powered-by"]',
1104
+ 'res.headers["access-control-allow-origin"]',
1105
+ 'res.headers["content-type"]',
1106
+ 'res.headers["content-encoding"]'
1107
+ ];
1108
+ function createLogger(opts = {}) {
1109
+ const { prettyOptions, filter, ...pinoOpts } = opts;
1110
+ let transport = void 0;
1111
+ if ("transport" in opts) {
1112
+ transport = opts.transport;
1113
+ } else if (prettyOptions?.enabled ?? process.stdout.isTTY) {
1114
+ transport = createPinoPrettyTransport(prettyOptions);
1115
+ }
1116
+ const redact = {
1117
+ paths: DEFAULT_REDACT_PATHS,
1118
+ remove: true
1119
+ };
1120
+ if (Array.isArray(opts.redact)) {
1121
+ redact.paths = opts.redact;
1122
+ } else if (opts.redact) {
1123
+ Object.assign(redact, opts.redact);
1124
+ }
1125
+ return pino({
1126
+ ...pinoOpts,
1127
+ transport,
1128
+ base: { hostname: hostname(), ...pinoOpts.base },
1129
+ hooks: {
1130
+ logMethod: filter ? wrapLogMethodWithFilter(pinoLogMethod, filter) : pinoLogMethod,
1131
+ ...pinoOpts.hooks
1132
+ },
1133
+ redact
1134
+ });
1135
+ }
1136
+ function createLoggerConfig(opts = {}) {
1137
+ const {
1138
+ traceIdField = "trace.id",
1139
+ spanIdField = "span.id",
1140
+ logger = createLogger()
1141
+ } = opts;
1142
+ return {
1143
+ type: "Pino",
1144
+ options: {
1145
+ createLogger: (level, bindings) => {
1146
+ const childBindings = { label: bindings.mod };
1147
+ if (traceIdField !== false) {
1148
+ childBindings[traceIdField] = bindings.traceID;
1149
+ }
1150
+ if (spanIdField !== false) {
1151
+ childBindings[spanIdField] = bindings.spanID;
1152
+ }
1153
+ return logger.child(childBindings, { level });
1154
+ }
1155
+ }
1156
+ };
1157
+ }
1158
+
1020
1159
  function createServiceBroker(opts = {}) {
1021
1160
  return new CustomServiceBroker({
1022
- logger: process.env.NODE_ENV === "test" ? false : void 0,
1023
- // TODO Add default logger
1161
+ logger: process.env.NODE_ENV === "test" ? false : createLoggerConfig(),
1024
1162
  validator: new AjvValidator(
1025
1163
  {
1026
1164
  default: {
@@ -1196,111 +1334,6 @@ function HealthCheckMiddleware(_opts) {
1196
1334
  };
1197
1335
  }
1198
1336
 
1199
- const FILTER_SERVICE_LOGS_REGEX = /('[^']*' service is registered\.)|(Service '[^']*' started\.)|('[^']*' finished starting\.)/;
1200
- let transport;
1201
- if (process.env.NODE_ENV !== "production") {
1202
- transport = {
1203
- // Building with pkgroll (rollup) will bundle the file into the root index.js so we keep
1204
- // `logger/` in the path.
1205
- target: "./logger/pino-pretty-transport.cjs",
1206
- options: {
1207
- colorize: true,
1208
- singleLine: true,
1209
- ignore: [
1210
- "hostname",
1211
- // Hide req and res in logs as it will be included in the pretty message
1212
- // or is not useful in development
1213
- "req",
1214
- "res",
1215
- "responseTime",
1216
- "span\\.id"
1217
- ].join(",")
1218
- }
1219
- };
1220
- }
1221
- const logger = pino({
1222
- base: {
1223
- hostname: hostname(),
1224
- // Need to set this to allow logs in context of traces
1225
- // Note that this will not work with dotenv loaded environment variables.
1226
- "service.name": process.env.NEWRELIC_APP_NAME
1227
- },
1228
- transport,
1229
- hooks: {
1230
- /**
1231
- * This function allow logs like `logger.info('str 1', {a: 1}, 'str 2', ...)` to
1232
- * be formatted correctly (every string are concatenated into one and objects are merged in the log).
1233
- */
1234
- logMethod(args, method) {
1235
- const mergingObject = {};
1236
- let msg = "";
1237
- for (const arg of args) {
1238
- if (arg instanceof Error) {
1239
- mergingObject.err = arg;
1240
- } else if (typeof arg === "string") {
1241
- msg += (msg ? " " : "") + arg;
1242
- } else if (arg && "msg" in arg && typeof arg.msg === "string") {
1243
- msg += (msg ? " " : "") + arg.msg;
1244
- Object.assign(mergingObject, arg);
1245
- } else {
1246
- Object.assign(mergingObject, arg);
1247
- }
1248
- }
1249
- if (process.env.FILTER_SERVICE_LOGS === "yes" && FILTER_SERVICE_LOGS_REGEX.test(msg)) {
1250
- return void 0;
1251
- }
1252
- mergingObject.msg = msg;
1253
- return method.apply(this, [mergingObject]);
1254
- }
1255
- },
1256
- redact: {
1257
- paths: [
1258
- // Request headers
1259
- "req.headers.authorization",
1260
- 'req.headers["device-useragent"]',
1261
- "req.headers.connection",
1262
- 'req.headers["content-type"]',
1263
- 'req.headers["accept"]',
1264
- 'req.headers["keep-alive"]',
1265
- 'req.headers["dnt"]',
1266
- 'req.headers["accept-encoding"]',
1267
- 'req.headers["accept-language"]',
1268
- 'req.headers["sec-fetch-site"]',
1269
- 'req.headers["sec-fetch-mode"]',
1270
- 'req.headers["sec-fetch-dest"]',
1271
- 'req.headers["sec-fetch-user"]',
1272
- 'req.headers["sec-ch-ua"]',
1273
- 'req.headers["sec-ch-ua-mobile"]',
1274
- 'req.headers["upgrade-insecure-requests"]',
1275
- 'req.headers["if-none-match"]',
1276
- 'req.headers["cookie"]',
1277
- "req.headers.referer",
1278
- // Response headers
1279
- "res.headers.allow",
1280
- "res.headers.vary",
1281
- 'res.headers["x-powered-by"]',
1282
- 'res.headers["access-control-allow-origin"]',
1283
- 'res.headers["content-type"]',
1284
- 'res.headers["content-encoding"]'
1285
- ],
1286
- remove: true
1287
- }
1288
- });
1289
- const createLogger = (bindings) => logger.child(bindings);
1290
- function createLoggerConfig() {
1291
- return {
1292
- type: "Pino",
1293
- options: {
1294
- createLogger: (level, bindings) => createLogger({
1295
- label: bindings.mod,
1296
- "trace.id": bindings.traceID,
1297
- "span.id": bindings.spanID
1298
- })
1299
- }
1300
- };
1301
- }
1302
- const defaultLogger = createLogger({ label: "default" });
1303
-
1304
1337
  function flattenTags(obj, convertToString = false, path = "") {
1305
1338
  if (!obj) return null;
1306
1339
  return Object.keys(obj).reduce((res, k) => {
@@ -1593,4 +1626,4 @@ class NewrelicMetricsReporter extends MetricReporters.Base {
1593
1626
  }
1594
1627
  }
1595
1628
 
1596
- export { AjvExtractor, AjvValidator, COERCE_ARRAY_ATTRIBUTE, ContextFactory, HealthCheckMiddleware, NewrelicMetricsReporter, NewrelicTraceExporter, OpenAPIExtractor, OpenAPIMixin, RefExtractor, SCHEMA_REF_NAME, ServiceFactory, ZodValidator, createLogger, createLoggerConfig, createServiceBroker, defaultLogger, getMetadataFromService, isServiceSelected, isZodSchema, omitFields, wrapMixin, zodToOpenAPISchema };
1629
+ export { AjvExtractor, AjvValidator, COERCE_ARRAY_ATTRIBUTE, ContextFactory, HealthCheckMiddleware, NewrelicMetricsReporter, NewrelicTraceExporter, OpenAPIExtractor, OpenAPIMixin, RefExtractor, SCHEMA_REF_NAME, ServiceFactory, ZodValidator, createLogger, createLoggerConfig, createServiceBroker, getMetadataFromService, isServiceSelected, isZodSchema, omitFields, wrapMixin, zodToOpenAPISchema };
@@ -1,11 +1,12 @@
1
1
  import { Document, WithoutId, InferIdType, ObjectId, Filter, WithId, OptionalId, FindOptions, CountDocumentsOptions, FindOneAndUpdateOptions, BulkWriteOptions, UpdateOptions, FindOneAndReplaceOptions, FindOneAndDeleteOptions, DeleteOptions, CollationOptions, CreateCollectionOptions, MongoClient, CollectionOptions, Collection, UpdateFilter, FindCursor, UpdateResult } from 'mongodb';
2
2
  import { ActionVisibility, BaseValidator, Errors, Context } from 'moleculer';
3
3
  import { ZodType, ZodObject } from 'zod/v4';
4
- import { V as ValidationSchema, J as JSONSchemaType, C as CustomActionSchema, a as CustomServiceSchema } from '../index-TXVFWos4.cjs';
4
+ import { V as ValidationSchema, J as JSONSchemaType, C as CustomActionSchema, a as CustomServiceSchema } from '../types-BEknQmfU.cjs';
5
5
  import { Readable } from 'stream';
6
6
  import 'bson';
7
7
  import 'ajv/dist/2019.js';
8
8
  import 'pino';
9
+ import 'pino-pretty';
9
10
 
10
11
  declare enum QueryOp {
11
12
  GT = "$gt",
@@ -1,11 +1,12 @@
1
1
  import { Document, WithoutId, InferIdType, ObjectId, Filter, WithId, OptionalId, FindOptions, CountDocumentsOptions, FindOneAndUpdateOptions, BulkWriteOptions, UpdateOptions, FindOneAndReplaceOptions, FindOneAndDeleteOptions, DeleteOptions, CollationOptions, CreateCollectionOptions, MongoClient, CollectionOptions, Collection, UpdateFilter, FindCursor, UpdateResult } from 'mongodb';
2
2
  import { ActionVisibility, BaseValidator, Errors, Context } from 'moleculer';
3
3
  import { ZodType, ZodObject } from 'zod/v4';
4
- import { V as ValidationSchema, J as JSONSchemaType, C as CustomActionSchema, a as CustomServiceSchema } from '../index-TXVFWos4.mjs';
4
+ import { V as ValidationSchema, J as JSONSchemaType, C as CustomActionSchema, a as CustomServiceSchema } from '../types-BEknQmfU.mjs';
5
5
  import { Readable } from 'stream';
6
6
  import 'bson';
7
7
  import 'ajv/dist/2019.js';
8
8
  import 'pino';
9
+ import 'pino-pretty';
9
10
 
10
11
  declare enum QueryOp {
11
12
  GT = "$gt",
@@ -1,10 +1,11 @@
1
- import { a as CustomServiceSchema } from '../index-TXVFWos4.cjs';
1
+ import { a as CustomServiceSchema } from '../types-BEknQmfU.cjs';
2
2
  import { buildClient, NodeCachingMaterialsManager } from '@aws-crypto/client-node';
3
3
  import 'moleculer';
4
4
  import 'bson';
5
5
  import 'zod/v4';
6
6
  import 'ajv/dist/2019.js';
7
7
  import 'pino';
8
+ import 'pino-pretty';
8
9
 
9
10
  declare const kCmm: unique symbol;
10
11
  type EncryptorMixinSettings = {
@@ -1,10 +1,11 @@
1
- import { a as CustomServiceSchema } from '../index-TXVFWos4.mjs';
1
+ import { a as CustomServiceSchema } from '../types-BEknQmfU.mjs';
2
2
  import { buildClient, NodeCachingMaterialsManager } from '@aws-crypto/client-node';
3
3
  import 'moleculer';
4
4
  import 'bson';
5
5
  import 'zod/v4';
6
6
  import 'ajv/dist/2019.js';
7
7
  import 'pino';
8
+ import 'pino-pretty';
8
9
 
9
10
  declare const kCmm: unique symbol;
10
11
  type EncryptorMixinSettings = {
@@ -1,9 +1,10 @@
1
- import { a as CustomServiceSchema } from '../index-TXVFWos4.cjs';
1
+ import { a as CustomServiceSchema } from '../types-BEknQmfU.cjs';
2
2
  import 'moleculer';
3
3
  import 'bson';
4
4
  import 'zod/v4';
5
5
  import 'ajv/dist/2019.js';
6
6
  import 'pino';
7
+ import 'pino-pretty';
7
8
 
8
9
  type Wrapper<T> = {
9
10
  services: Set<unknown>;
@@ -1,9 +1,10 @@
1
- import { a as CustomServiceSchema } from '../index-TXVFWos4.mjs';
1
+ import { a as CustomServiceSchema } from '../types-BEknQmfU.mjs';
2
2
  import 'moleculer';
3
3
  import 'bson';
4
4
  import 'zod/v4';
5
5
  import 'ajv/dist/2019.js';
6
6
  import 'pino';
7
+ import 'pino-pretty';
7
8
 
8
9
  type Wrapper<T> = {
9
10
  services: Set<unknown>;
@@ -1,4 +1,4 @@
1
- import { a as CustomServiceSchema } from '../index-TXVFWos4.cjs';
1
+ import { a as CustomServiceSchema } from '../types-BEknQmfU.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';
@@ -6,6 +6,7 @@ import 'bson';
6
6
  import 'zod/v4';
7
7
  import 'ajv/dist/2019.js';
8
8
  import 'pino';
9
+ import 'pino-pretty';
9
10
 
10
11
  type JwtSignerMixinSettings = {
11
12
  signOptions: SignOptions;
@@ -1,4 +1,4 @@
1
- import { a as CustomServiceSchema } from '../index-TXVFWos4.mjs';
1
+ import { a as CustomServiceSchema } from '../types-BEknQmfU.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';
@@ -6,6 +6,7 @@ import 'bson';
6
6
  import 'zod/v4';
7
7
  import 'ajv/dist/2019.js';
8
8
  import 'pino';
9
+ import 'pino-pretty';
9
10
 
10
11
  type JwtSignerMixinSettings = {
11
12
  signOptions: SignOptions;
@@ -5,7 +5,7 @@ var bullmq = require('bullmq');
5
5
  var index = require('../index-82e1CXJX.cjs');
6
6
  var mixins_globalStore_mixin = require('./global-store.mixin.cjs');
7
7
  var ioredis = require('ioredis');
8
- var utils = require('ioredis/built/utils');
8
+ var index_js = require('ioredis/built/utils/index.js');
9
9
 
10
10
  function createRedisConnection(url) {
11
11
  let tls;
@@ -13,7 +13,7 @@ function createRedisConnection(url) {
13
13
  tls = {};
14
14
  }
15
15
  const connection = new ioredis.Redis({
16
- ...utils.parseURL(url),
16
+ ...index_js.parseURL(url),
17
17
  tls,
18
18
  maxRetriesPerRequest: null,
19
19
  connectTimeout: 1e3 * 60
@@ -1,4 +1,4 @@
1
- import { a as CustomServiceSchema } from '../index-TXVFWos4.cjs';
1
+ import { a as CustomServiceSchema } from '../types-BEknQmfU.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';
@@ -6,6 +6,7 @@ import 'bson';
6
6
  import 'zod/v4';
7
7
  import 'ajv/dist/2019.js';
8
8
  import 'pino';
9
+ import 'pino-pretty';
9
10
 
10
11
  type QueueMixinOptions = {
11
12
  brokerURL: string | (<TService extends Service = Service>(svc: TService) => Promise<string>);
@@ -1,4 +1,4 @@
1
- import { a as CustomServiceSchema } from '../index-TXVFWos4.mjs';
1
+ import { a as CustomServiceSchema } from '../types-BEknQmfU.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';
@@ -6,6 +6,7 @@ import 'bson';
6
6
  import 'zod/v4';
7
7
  import 'ajv/dist/2019.js';
8
8
  import 'pino';
9
+ import 'pino-pretty';
9
10
 
10
11
  type QueueMixinOptions = {
11
12
  brokerURL: string | (<TService extends Service = Service>(svc: TService) => Promise<string>);
@@ -3,7 +3,7 @@ import { Queue, QueueEvents, FlowProducer, Worker } from 'bullmq';
3
3
  import { w as wrapMixin } from '../index-DNJWwcZu.mjs';
4
4
  import { GlobalStoreMixin } from './global-store.mixin.mjs';
5
5
  import { Redis } from 'ioredis';
6
- import { parseURL } from 'ioredis/built/utils';
6
+ import { parseURL } from 'ioredis/built/utils/index.js';
7
7
 
8
8
  function createRedisConnection(url) {
9
9
  let tls;
@@ -1,10 +1,11 @@
1
- import { a as CustomServiceSchema } from '../index-TXVFWos4.cjs';
1
+ import { a as CustomServiceSchema } from '../types-BEknQmfU.cjs';
2
2
  import { RedisOptions, Redis } from 'ioredis';
3
3
  import { Service } from 'moleculer';
4
4
  import 'bson';
5
5
  import 'zod/v4';
6
6
  import 'ajv/dist/2019.js';
7
7
  import 'pino';
8
+ import 'pino-pretty';
8
9
 
9
10
  type AllowedOptions = Omit<RedisOptions, 'lazyConnect'>;
10
11
  type RedisMixinOptions = {
@@ -1,10 +1,11 @@
1
- import { a as CustomServiceSchema } from '../index-TXVFWos4.mjs';
1
+ import { a as CustomServiceSchema } from '../types-BEknQmfU.mjs';
2
2
  import { RedisOptions, Redis } from 'ioredis';
3
3
  import { Service } from 'moleculer';
4
4
  import 'bson';
5
5
  import 'zod/v4';
6
6
  import 'ajv/dist/2019.js';
7
7
  import 'pino';
8
+ import 'pino-pretty';
8
9
 
9
10
  type AllowedOptions = Omit<RedisOptions, 'lazyConnect'>;
10
11
  type RedisMixinOptions = {
@@ -1,4 +1,4 @@
1
- import { a as CustomServiceSchema } from '../index-TXVFWos4.cjs';
1
+ import { a as CustomServiceSchema } from '../types-BEknQmfU.cjs';
2
2
  import { Service } from 'moleculer';
3
3
  import { RedisOptions, Redis } from 'ioredis';
4
4
  import Redlock from 'redlock';
@@ -6,6 +6,7 @@ import 'bson';
6
6
  import 'zod/v4';
7
7
  import 'ajv/dist/2019.js';
8
8
  import 'pino';
9
+ import 'pino-pretty';
9
10
 
10
11
  type AllowedOptions = Omit<RedisOptions, 'lazyConnect'>;
11
12
  type RedlockMixinOptions = {
@@ -1,4 +1,4 @@
1
- import { a as CustomServiceSchema } from '../index-TXVFWos4.mjs';
1
+ import { a as CustomServiceSchema } from '../types-BEknQmfU.mjs';
2
2
  import { Service } from 'moleculer';
3
3
  import { RedisOptions, Redis } from 'ioredis';
4
4
  import Redlock from 'redlock';
@@ -6,6 +6,7 @@ import 'bson';
6
6
  import 'zod/v4';
7
7
  import 'ajv/dist/2019.js';
8
8
  import 'pino';
9
+ import 'pino-pretty';
9
10
 
10
11
  type AllowedOptions = Omit<RedisOptions, 'lazyConnect'>;
11
12
  type RedlockMixinOptions = {
@@ -1,8 +1,9 @@
1
- import Moleculer__default, { RestSchema, ActionVisibility, Service, ActionCacheOptions, Context, TracingActionOptions, BulkheadOptions, BrokerCircuitBreakerOptions, RetryPolicyOptions, FallbackHandler, ActionHooks, Validators, ActionHandler, ActionSchema, ServiceEvent, ServiceDependency, ServiceHooks, GenericObject, ServiceBroker, Endpoint, LoggerConfig } from 'moleculer';
1
+ import Moleculer__default, { RestSchema, ActionVisibility, Service, ActionCacheOptions, Context, TracingActionOptions, BulkheadOptions, BrokerCircuitBreakerOptions, RetryPolicyOptions, FallbackHandler, ActionHooks, Validators, ActionHandler, ActionSchema, ServiceEvent, ServiceDependency, ServiceHooks, GenericObject, ServiceBroker, Endpoint } 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';
5
- import { Logger } from 'pino';
5
+ import { LoggerOptions, Logger } from 'pino';
6
+ import { PrettyOptions } from 'pino-pretty';
6
7
 
7
8
  type UnionToIntersection$1<U> = (U extends any ? (_: U) => void : never) extends (_: infer I) => void ? I : never;
8
9
  type SomeJSONSchema = JSONSchemaType<Known, true>;
@@ -516,9 +517,46 @@ declare module 'moleculer' {
516
517
  }
517
518
  }
518
519
 
519
- declare const createLogger: (bindings: Record<string, unknown>) => Logger;
520
- declare function createLoggerConfig(): LoggerConfig;
521
- declare const defaultLogger: Logger;
520
+ type CreateLoggerOptions = LoggerOptions & {
521
+ /**
522
+ * Allow filtering messages, should only be used during development.
523
+ */
524
+ filter?: RegExp;
525
+ /**
526
+ * Options related to the included prettifier (pino-pretty).
527
+ */
528
+ prettyOptions?: {
529
+ /**
530
+ * Enable/Disable the prettifier transport.
531
+ * If transport is specified, the default prettifier will be disabled.
532
+ *
533
+ * @default process.stdout.isTTY
534
+ */
535
+ enabled?: boolean;
536
+ /**
537
+ * Options to be forwarded to pino-pretty.
538
+ */
539
+ options?: PrettyOptions;
540
+ };
541
+ };
542
+ type MoleculerLoggerConfigOptions = {
543
+ /**
544
+ * Pino logger instance to use.
545
+ *
546
+ * @default createLogger()
547
+ */
548
+ logger?: Logger;
549
+ /**
550
+ * Name of the field added for context logging. `false` disable the field
551
+ * @default 'trace.id'
552
+ */
553
+ traceIdField?: string | false;
554
+ /**
555
+ * Name of the field added for context logging. `false` disable the field
556
+ * @default 'span.id'
557
+ */
558
+ spanIdField?: string | false;
559
+ };
522
560
  /**
523
561
  * Augment pino to something closer to what Moleculer is using.
524
562
  */
@@ -528,5 +566,5 @@ declare module 'pino' {
528
566
  }
529
567
  }
530
568
 
531
- export { createLogger as W, createLoggerConfig as X, defaultLogger as Y, ZodValidator as Z, AjvValidator as d, ContextFactory as i };
532
- export type { Alias as A, SecuritySchemeObject as B, CustomActionSchema as C, Document as D, ExternalDocumentationObject as E, CallbackObject as F, ComponentsObject as G, HeaderObject as H, InfoObject as I, JSONSchemaType as J, TagObject as K, LicenseObject as L, MediaTypeObject as M, PathItemObject as N, OperationObject as O, PropertiesSchema as P, ObjectServiceThis as Q, ReferenceObject as R, SomeJSONSchema as S, Transformer as T, CallbackServiceThis as U, ValidationSchema as V, CustomServiceSchema as a, SchemaObject as b, RequiredMembers as c, Transform as e, TransformLevel as f, TransformMap as g, TransformField as h, ContactObject as j, ServerVariableObject as k, ServerObject as l, PathsObject as m, ParameterObject as n, ParameterBaseObject as o, ExampleObject as p, EncodingObject as q, RequestBodyObject as r, LinkObject as s, ResponseObject as t, ResponsesObject as u, SecurityRequirementObject as v, HttpSecurityScheme as w, ApiKeySecurityScheme as x, OAuth2SecurityScheme as y, OpenIdSecurityScheme as z };
569
+ export { ZodValidator as Z, AjvValidator as e, ContextFactory as j };
570
+ export type { Alias as A, OAuth2SecurityScheme as B, CustomActionSchema as C, Document as D, ExternalDocumentationObject as E, OpenIdSecurityScheme as F, SecuritySchemeObject as G, HeaderObject as H, InfoObject as I, JSONSchemaType as J, CallbackObject as K, LicenseObject as L, MoleculerLoggerConfigOptions as M, ComponentsObject as N, OperationObject as O, PropertiesSchema as P, TagObject as Q, ReferenceObject as R, SomeJSONSchema as S, Transformer as T, PathItemObject as U, ValidationSchema as V, ObjectServiceThis as W, CallbackServiceThis as X, CustomServiceSchema as a, SchemaObject as b, CreateLoggerOptions as c, RequiredMembers as d, Transform as f, TransformLevel as g, TransformMap as h, TransformField as i, ContactObject as k, ServerVariableObject as l, ServerObject as m, PathsObject as n, ParameterObject as o, ParameterBaseObject as p, ExampleObject as q, EncodingObject as r, MediaTypeObject as s, RequestBodyObject as t, LinkObject as u, ResponseObject as v, ResponsesObject as w, SecurityRequirementObject as x, HttpSecurityScheme as y, ApiKeySecurityScheme as z };
@@ -1,8 +1,9 @@
1
- import Moleculer__default, { RestSchema, ActionVisibility, Service, ActionCacheOptions, Context, TracingActionOptions, BulkheadOptions, BrokerCircuitBreakerOptions, RetryPolicyOptions, FallbackHandler, ActionHooks, Validators, ActionHandler, ActionSchema, ServiceEvent, ServiceDependency, ServiceHooks, GenericObject, ServiceBroker, Endpoint, LoggerConfig } from 'moleculer';
1
+ import Moleculer__default, { RestSchema, ActionVisibility, Service, ActionCacheOptions, Context, TracingActionOptions, BulkheadOptions, BrokerCircuitBreakerOptions, RetryPolicyOptions, FallbackHandler, ActionHooks, Validators, ActionHandler, ActionSchema, ServiceEvent, ServiceDependency, ServiceHooks, GenericObject, ServiceBroker, Endpoint } 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';
5
- import { Logger } from 'pino';
5
+ import { LoggerOptions, Logger } from 'pino';
6
+ import { PrettyOptions } from 'pino-pretty';
6
7
 
7
8
  type UnionToIntersection$1<U> = (U extends any ? (_: U) => void : never) extends (_: infer I) => void ? I : never;
8
9
  type SomeJSONSchema = JSONSchemaType<Known, true>;
@@ -516,9 +517,46 @@ declare module 'moleculer' {
516
517
  }
517
518
  }
518
519
 
519
- declare const createLogger: (bindings: Record<string, unknown>) => Logger;
520
- declare function createLoggerConfig(): LoggerConfig;
521
- declare const defaultLogger: Logger;
520
+ type CreateLoggerOptions = LoggerOptions & {
521
+ /**
522
+ * Allow filtering messages, should only be used during development.
523
+ */
524
+ filter?: RegExp;
525
+ /**
526
+ * Options related to the included prettifier (pino-pretty).
527
+ */
528
+ prettyOptions?: {
529
+ /**
530
+ * Enable/Disable the prettifier transport.
531
+ * If transport is specified, the default prettifier will be disabled.
532
+ *
533
+ * @default process.stdout.isTTY
534
+ */
535
+ enabled?: boolean;
536
+ /**
537
+ * Options to be forwarded to pino-pretty.
538
+ */
539
+ options?: PrettyOptions;
540
+ };
541
+ };
542
+ type MoleculerLoggerConfigOptions = {
543
+ /**
544
+ * Pino logger instance to use.
545
+ *
546
+ * @default createLogger()
547
+ */
548
+ logger?: Logger;
549
+ /**
550
+ * Name of the field added for context logging. `false` disable the field
551
+ * @default 'trace.id'
552
+ */
553
+ traceIdField?: string | false;
554
+ /**
555
+ * Name of the field added for context logging. `false` disable the field
556
+ * @default 'span.id'
557
+ */
558
+ spanIdField?: string | false;
559
+ };
522
560
  /**
523
561
  * Augment pino to something closer to what Moleculer is using.
524
562
  */
@@ -528,5 +566,5 @@ declare module 'pino' {
528
566
  }
529
567
  }
530
568
 
531
- export { createLogger as W, createLoggerConfig as X, defaultLogger as Y, ZodValidator as Z, AjvValidator as d, ContextFactory as i };
532
- export type { Alias as A, SecuritySchemeObject as B, CustomActionSchema as C, Document as D, ExternalDocumentationObject as E, CallbackObject as F, ComponentsObject as G, HeaderObject as H, InfoObject as I, JSONSchemaType as J, TagObject as K, LicenseObject as L, MediaTypeObject as M, PathItemObject as N, OperationObject as O, PropertiesSchema as P, ObjectServiceThis as Q, ReferenceObject as R, SomeJSONSchema as S, Transformer as T, CallbackServiceThis as U, ValidationSchema as V, CustomServiceSchema as a, SchemaObject as b, RequiredMembers as c, Transform as e, TransformLevel as f, TransformMap as g, TransformField as h, ContactObject as j, ServerVariableObject as k, ServerObject as l, PathsObject as m, ParameterObject as n, ParameterBaseObject as o, ExampleObject as p, EncodingObject as q, RequestBodyObject as r, LinkObject as s, ResponseObject as t, ResponsesObject as u, SecurityRequirementObject as v, HttpSecurityScheme as w, ApiKeySecurityScheme as x, OAuth2SecurityScheme as y, OpenIdSecurityScheme as z };
569
+ export { ZodValidator as Z, AjvValidator as e, ContextFactory as j };
570
+ export type { Alias as A, OAuth2SecurityScheme as B, CustomActionSchema as C, Document as D, ExternalDocumentationObject as E, OpenIdSecurityScheme as F, SecuritySchemeObject as G, HeaderObject as H, InfoObject as I, JSONSchemaType as J, CallbackObject as K, LicenseObject as L, MoleculerLoggerConfigOptions as M, ComponentsObject as N, OperationObject as O, PropertiesSchema as P, TagObject as Q, ReferenceObject as R, SomeJSONSchema as S, Transformer as T, PathItemObject as U, ValidationSchema as V, ObjectServiceThis as W, CallbackServiceThis as X, CustomServiceSchema as a, SchemaObject as b, CreateLoggerOptions as c, RequiredMembers as d, Transform as f, TransformLevel as g, TransformMap as h, TransformField as i, ContactObject as k, ServerVariableObject as l, ServerObject as m, PathsObject as n, ParameterObject as o, ParameterBaseObject as p, ExampleObject as q, EncodingObject as r, MediaTypeObject as s, RequestBodyObject as t, LinkObject as u, ResponseObject as v, ResponsesObject as w, SecurityRequirementObject as x, HttpSecurityScheme as y, ApiKeySecurityScheme 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": "1.3.1",
9
+ "version": "2.0.0-beta.1",
10
10
  "main": "./dist/index.cjs",
11
11
  "module": "./dist/index.mjs",
12
12
  "types": "./dist/index.d.cts",