@treatwell/moleculer-essentials 1.2.0 → 1.2.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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var lodashEs = require('lodash-es');
3
+ var esToolkit = require('es-toolkit');
4
4
  var v4 = require('zod/v4');
5
5
  var bson = require('bson');
6
6
  var dateFns = require('date-fns');
@@ -45,7 +45,7 @@ function omitFields(schema, fields, refName) {
45
45
  ...schema,
46
46
  [SCHEMA_REF_NAME]: refName,
47
47
  required: schema.required.filter((f) => !fields.includes(f)),
48
- properties: lodashEs.omit(schema.properties, fields)
48
+ properties: esToolkit.omit(schema.properties, fields)
49
49
  };
50
50
  }
51
51
  function pickFields(schema, fields, refName) {
@@ -68,7 +68,7 @@ function pickFields(schema, fields, refName) {
68
68
  ...schema,
69
69
  [SCHEMA_REF_NAME]: refName,
70
70
  required: schema.required.filter((f) => fields.includes(f)),
71
- properties: lodashEs.pick(schema.properties, fields)
71
+ properties: esToolkit.pick(schema.properties, fields)
72
72
  };
73
73
  }
74
74
  function optionalExceptFields(schema, fields, refName) {
@@ -1,4 +1,4 @@
1
- import { omit, pick } from 'lodash-es';
1
+ import { omit, pick } from 'es-toolkit';
2
2
  import { z as z$1 } from 'zod/v4';
3
3
  import { ObjectId } from 'bson';
4
4
  import { parseISO } from 'date-fns';
package/dist/index.cjs CHANGED
@@ -1,15 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-BUXfgQp5.cjs');
3
+ var index = require('./index-CjA1_Io7.cjs');
4
4
  var v4 = require('zod/v4');
5
5
  var _2019_js = require('ajv/dist/2019.js');
6
6
  var moleculer = require('moleculer');
7
7
  var addFormats = require('ajv-formats');
8
8
  var addKeywords = require('ajv-keywords');
9
- var lodashEs = require('lodash-es');
9
+ var esToolkit = require('es-toolkit');
10
10
  var dateFns = require('date-fns');
11
11
  var bson = require('bson');
12
12
  var index$1 = require('./index-82e1CXJX.cjs');
13
+ var compat = require('es-toolkit/compat');
13
14
  var http = require('http');
14
15
  var pino = require('pino');
15
16
  var node_os = require('node:os');
@@ -63,12 +64,12 @@ class RefExtractor {
63
64
  if (!this.refs.has(schemaRefName)) {
64
65
  this.refs.set(schemaRefName, null);
65
66
  }
66
- const newSchema2 = walk(lodashEs.omit(curr, [index.SCHEMA_REF_NAME, "nullable"]), ref);
67
+ const newSchema2 = walk(esToolkit.omit(curr, [index.SCHEMA_REF_NAME, "nullable"]), ref);
67
68
  const registeredSchema = this.refs.get(schemaRefName);
68
69
  if (registeredSchema === null) {
69
70
  this.refs.set(schemaRefName, newSchema2);
70
71
  this.onNewRef(schemaRefName, newSchema2);
71
- } else if (!lodashEs.isEqual(newSchema2, registeredSchema)) {
72
+ } else if (!esToolkit.isEqual(newSchema2, registeredSchema)) {
72
73
  this.onError(
73
74
  `Schema ${schemaRefName} is already defined with different content`,
74
75
  { registeredSchema, newSchema: newSchema2 }
@@ -145,7 +146,7 @@ function generateOpenAPISpec({
145
146
  services,
146
147
  getSecuritySchemes
147
148
  }) {
148
- services.forEach((svc) => lodashEs.merge(doc, svc.settings?.openapi));
149
+ services.forEach((svc) => esToolkit.merge(doc, svc.settings?.openapi));
149
150
  const extractor = new OpenAPIExtractor(doc);
150
151
  if (doc.components?.schemas) {
151
152
  const { schemas } = doc.components;
@@ -223,13 +224,21 @@ function createOperationFromAlias(alias, extractor, url) {
223
224
  const responses = {};
224
225
  if (openapi.responses) {
225
226
  for (const [key, val] of Object.entries(openapi.responses)) {
226
- responses[key] = val;
227
- const content = val.content?.["application/json"];
228
- if (content && "zodInstance" in content && typeof content.zodInstance === "function") {
229
- content.schema = index.zodToOpenAPISchema(content.zodInstance(), extractor);
230
- } else if (content?.schema) {
231
- content.schema = extractor.extract(content.schema);
227
+ const res = { ...val };
228
+ if ("content" in res) {
229
+ res.content = { ...res.content };
230
+ let content = res.content["application/json"];
231
+ if (content) {
232
+ res.content["application/json"] = { ...content };
233
+ content = res.content["application/json"];
234
+ }
235
+ if (content && "zodInstance" in content && typeof content.zodInstance === "function") {
236
+ content.schema = index.zodToOpenAPISchema(content.zodInstance(), extractor);
237
+ } else if (content?.schema) {
238
+ content.schema = extractor.extract(content.schema);
239
+ }
232
240
  }
241
+ responses[key] = res;
233
242
  }
234
243
  }
235
244
  return {
@@ -331,8 +340,13 @@ function createOperationFromZodParams(params, pathParams, alias, extractor) {
331
340
  Object.fromEntries(parameters.map((p) => [p.name, true]))
332
341
  );
333
342
  }
334
- if (alias.action.bodySchemaRefName) {
335
- zodBody = zodBody.meta({ id: alias.action.bodySchemaRefName });
343
+ const { bodySchemaRefName } = alias.action;
344
+ if (bodySchemaRefName) {
345
+ if (v4.z.globalRegistry._idmap.has(bodySchemaRefName)) {
346
+ zodBody = v4.z.globalRegistry._idmap.get(bodySchemaRefName);
347
+ } else {
348
+ zodBody = zodBody.meta({ id: bodySchemaRefName });
349
+ }
336
350
  }
337
351
  requestBody = {
338
352
  required: true,
@@ -555,7 +569,7 @@ class LeafTransformerBase {
555
569
 
556
570
  class CoerceArrayTransformer extends LeafTransformerBase {
557
571
  beforeTransformer = (val) => {
558
- if (lodashEs.isArray(val) || val === null) {
572
+ if (Array.isArray(val) || val === null) {
559
573
  return val;
560
574
  }
561
575
  return [val];
@@ -573,11 +587,11 @@ class DateTransformer extends LeafTransformerBase {
573
587
  return val;
574
588
  };
575
589
  afterTransformer = (val) => {
576
- if (!lodashEs.isString(val)) {
590
+ if (typeof val !== "string") {
577
591
  return val;
578
592
  }
579
593
  const date = dateFns.parseISO(val);
580
- if (lodashEs.isNaN(date.getTime())) {
594
+ if (Number.isNaN(date.getTime())) {
581
595
  return val;
582
596
  }
583
597
  return date;
@@ -595,7 +609,7 @@ class ObjectIdTransformer extends LeafTransformerBase {
595
609
  return val;
596
610
  };
597
611
  afterTransformer = (val) => {
598
- if (lodashEs.isString(val) && /^[a-f\d]{24}$/i.test(val)) {
612
+ if (typeof val === "string" && /^[a-f\d]{24}$/i.test(val)) {
599
613
  return new bson.ObjectId(val);
600
614
  }
601
615
  return val;
@@ -612,7 +626,7 @@ function applyTransform(parent, dataKey, transformer, transformField, index) {
612
626
  const transformLevel = transformField[index];
613
627
  switch (transformLevel.type) {
614
628
  case "this": {
615
- if (!lodashEs.isPlainObject(parent) && !lodashEs.isArray(parent)) {
629
+ if (!esToolkit.isPlainObject(parent) && !Array.isArray(parent)) {
616
630
  return;
617
631
  }
618
632
  if (parent.hasOwnProperty(dataKey)) {
@@ -621,7 +635,7 @@ function applyTransform(parent, dataKey, transformer, transformField, index) {
621
635
  break;
622
636
  }
623
637
  case "access":
624
- if (!lodashEs.isPlainObject(parent[dataKey])) {
638
+ if (!esToolkit.isPlainObject(parent[dataKey])) {
625
639
  return;
626
640
  }
627
641
  applyTransform(
@@ -638,7 +652,7 @@ function applyTransform(parent, dataKey, transformer, transformField, index) {
638
652
  }
639
653
  break;
640
654
  case "loop": {
641
- if (!lodashEs.isArray(parent[dataKey])) {
655
+ if (!Array.isArray(parent[dataKey])) {
642
656
  return;
643
657
  }
644
658
  const cast = parent[dataKey];
@@ -744,7 +758,7 @@ class AjvValidator extends moleculer.Validators.Base {
744
758
  });
745
759
  validator.addFormat("object-id", {
746
760
  type: "string",
747
- validate: lodashEs.constant(true)
761
+ validate: () => true
748
762
  });
749
763
  }
750
764
  }
@@ -1108,11 +1122,11 @@ function getMetadataFromService(svc) {
1108
1122
  const res = {
1109
1123
  name: svc.name || "unknown"
1110
1124
  };
1111
- lodashEs.defaultsDeep(res, svc.metadata);
1125
+ compat.defaultsDeep(res, svc.metadata);
1112
1126
  svc.mixins?.forEach((mixin) => {
1113
- lodashEs.defaultsDeep(res, mixin.metadata);
1127
+ compat.defaultsDeep(res, mixin.metadata);
1114
1128
  mixin.mixins?.forEach((m) => {
1115
- lodashEs.defaultsDeep(res, getMetadataFromService(m));
1129
+ compat.defaultsDeep(res, getMetadataFromService(m));
1116
1130
  });
1117
1131
  });
1118
1132
  return res;
@@ -1125,7 +1139,7 @@ const DEFAULT_OPTIONS = {
1125
1139
  liveness: { path: "/live" }
1126
1140
  };
1127
1141
  function HealthCheckMiddleware(_opts) {
1128
- const opts = lodashEs.defaultsDeep(_opts, DEFAULT_OPTIONS);
1142
+ const opts = compat.defaultsDeep(_opts, DEFAULT_OPTIONS);
1129
1143
  let state = "down";
1130
1144
  let server;
1131
1145
  function handler(req, res) {
@@ -1293,7 +1307,7 @@ function flattenTags(obj, convertToString = false, path = "") {
1293
1307
  return Object.keys(obj).reduce((res, k) => {
1294
1308
  const o = obj[k];
1295
1309
  const pp = (path ? `${path}.` : "") + k;
1296
- if (lodashEs.isObject(o)) {
1310
+ if (compat.isObject(o)) {
1297
1311
  if ("toHexString" in o) {
1298
1312
  res[pp] = o.toString();
1299
1313
  } else {
@@ -1312,7 +1326,7 @@ class NewrelicTraceExporter extends moleculer.TracerExporters.Base {
1312
1326
  defaultTags = {};
1313
1327
  constructor(opts) {
1314
1328
  super(opts);
1315
- this.opts = lodashEs.defaultsDeep(this.opts, {
1329
+ this.opts = compat.defaultsDeep(this.opts, {
1316
1330
  baseURL: process.env.NEW_RELIC_TRACE_API_URL || "https://trace-api.newrelic.com",
1317
1331
  batchSize: 1e3,
1318
1332
  insertKey: "",
@@ -1330,7 +1344,7 @@ class NewrelicTraceExporter extends moleculer.TracerExporters.Base {
1330
1344
  this.timer = setInterval(() => this.flush(), this.opts.interval * 1e3);
1331
1345
  this.timer.unref();
1332
1346
  }
1333
- this.defaultTags = lodashEs.isFunction(this.opts.defaultTags) ? this.opts.defaultTags.call(this, tracer) : this.opts.defaultTags;
1347
+ this.defaultTags = typeof this.opts.defaultTags === "function" ? this.opts.defaultTags.call(this, tracer) : this.opts.defaultTags;
1334
1348
  if (this.defaultTags) {
1335
1349
  this.defaultTags = flattenTags(this.defaultTags, true);
1336
1350
  }
@@ -1430,7 +1444,7 @@ class NewrelicMetricsReporter extends moleculer.MetricReporters.Base {
1430
1444
  defaultTags = {};
1431
1445
  constructor(opts) {
1432
1446
  super(opts);
1433
- this.opts = lodashEs.defaultsDeep(this.opts, {
1447
+ this.opts = compat.defaultsDeep(this.opts, {
1434
1448
  baseURL: process.env.NEW_RELIC_METRICS_API_URL || "https://metric-api.newrelic.com",
1435
1449
  insertKey: "",
1436
1450
  interval: 10
@@ -1445,7 +1459,7 @@ class NewrelicMetricsReporter extends moleculer.MetricReporters.Base {
1445
1459
  this.timer = setInterval(() => this.flush(), this.opts.interval * 1e3);
1446
1460
  this.timer.unref();
1447
1461
  }
1448
- const defaultTags = lodashEs.isFunction(this.opts.defaultTags) ? this.opts.defaultTags.call(this, registry) : this.opts.defaultTags;
1462
+ const defaultTags = typeof this.opts.defaultTags === "function" ? this.opts.defaultTags.call(this, registry) : this.opts.defaultTags;
1449
1463
  if (defaultTags) {
1450
1464
  this.defaultTags = flattenTags(defaultTags, true);
1451
1465
  }
package/dist/index.mjs CHANGED
@@ -1,15 +1,16 @@
1
- import { S as SCHEMA_REF_NAME, z as zodToOpenAPISchema, o as omitFields, G as GetOpenApiParamsSchema, V as ValidationErrorSchema, F as FileTooBigSchema, a as FileNotExistSchema, U as UnauthorizedErrorSchema, b as ServerErrorSchema, C as COERCE_ARRAY_ATTRIBUTE } from './index-BmVULkqf.mjs';
2
- export { D as DATE_TYPE, E as EMPTY_OBJECT_SCHEMA, O as OBJECTID_TYPE, c as addFieldsToSchema, f as composeSchemas, j as createOpenAPIResponses, e as optionalExceptFields, d as optionalFields, p as pickFields, t as toPartialSchema, i as zodCoerceArray, g as zodDate, h as zodObjectId } from './index-BmVULkqf.mjs';
1
+ import { S as SCHEMA_REF_NAME, z as zodToOpenAPISchema, o as omitFields, G as GetOpenApiParamsSchema, V as ValidationErrorSchema, F as FileTooBigSchema, a as FileNotExistSchema, U as UnauthorizedErrorSchema, b as ServerErrorSchema, C as COERCE_ARRAY_ATTRIBUTE } from './index-yStjjADK.mjs';
2
+ export { D as DATE_TYPE, E as EMPTY_OBJECT_SCHEMA, O as OBJECTID_TYPE, c as addFieldsToSchema, f as composeSchemas, j as createOpenAPIResponses, e as optionalExceptFields, d as optionalFields, p as pickFields, t as toPartialSchema, i as zodCoerceArray, g as zodDate, h as zodObjectId } from './index-yStjjADK.mjs';
3
3
  import { ZodType, ZodObject, ZodOptional, z } from 'zod/v4';
4
4
  import { Ajv2019 } from 'ajv/dist/2019.js';
5
5
  import { Validators, Errors, Context, ServiceBroker, Service, TracerExporters, MetricReporters } from 'moleculer';
6
6
  import addFormats from 'ajv-formats';
7
7
  import addKeywords from 'ajv-keywords';
8
- import { omit, isEqual, merge, isArray, isString, isNaN, isPlainObject, constant, defaultsDeep, isObject, isFunction } from 'lodash-es';
8
+ import { omit, isEqual, merge, isPlainObject } from 'es-toolkit';
9
9
  import { parseISO } from 'date-fns';
10
10
  import { ObjectId } from 'bson';
11
11
  import { w as wrapMixin } from './index-DNJWwcZu.mjs';
12
12
  export { a as wrapService } from './index-DNJWwcZu.mjs';
13
+ import { defaultsDeep, isObject } from 'es-toolkit/compat';
13
14
  import http, { STATUS_CODES } from 'http';
14
15
  import { pino } from 'pino';
15
16
  import { hostname } from 'node:os';
@@ -223,13 +224,21 @@ function createOperationFromAlias(alias, extractor, url) {
223
224
  const responses = {};
224
225
  if (openapi.responses) {
225
226
  for (const [key, val] of Object.entries(openapi.responses)) {
226
- responses[key] = val;
227
- const content = val.content?.["application/json"];
228
- if (content && "zodInstance" in content && typeof content.zodInstance === "function") {
229
- content.schema = zodToOpenAPISchema(content.zodInstance(), extractor);
230
- } else if (content?.schema) {
231
- content.schema = extractor.extract(content.schema);
227
+ const res = { ...val };
228
+ if ("content" in res) {
229
+ res.content = { ...res.content };
230
+ let content = res.content["application/json"];
231
+ if (content) {
232
+ res.content["application/json"] = { ...content };
233
+ content = res.content["application/json"];
234
+ }
235
+ if (content && "zodInstance" in content && typeof content.zodInstance === "function") {
236
+ content.schema = zodToOpenAPISchema(content.zodInstance(), extractor);
237
+ } else if (content?.schema) {
238
+ content.schema = extractor.extract(content.schema);
239
+ }
232
240
  }
241
+ responses[key] = res;
233
242
  }
234
243
  }
235
244
  return {
@@ -331,8 +340,13 @@ function createOperationFromZodParams(params, pathParams, alias, extractor) {
331
340
  Object.fromEntries(parameters.map((p) => [p.name, true]))
332
341
  );
333
342
  }
334
- if (alias.action.bodySchemaRefName) {
335
- zodBody = zodBody.meta({ id: alias.action.bodySchemaRefName });
343
+ const { bodySchemaRefName } = alias.action;
344
+ if (bodySchemaRefName) {
345
+ if (z.globalRegistry._idmap.has(bodySchemaRefName)) {
346
+ zodBody = z.globalRegistry._idmap.get(bodySchemaRefName);
347
+ } else {
348
+ zodBody = zodBody.meta({ id: bodySchemaRefName });
349
+ }
336
350
  }
337
351
  requestBody = {
338
352
  required: true,
@@ -555,7 +569,7 @@ class LeafTransformerBase {
555
569
 
556
570
  class CoerceArrayTransformer extends LeafTransformerBase {
557
571
  beforeTransformer = (val) => {
558
- if (isArray(val) || val === null) {
572
+ if (Array.isArray(val) || val === null) {
559
573
  return val;
560
574
  }
561
575
  return [val];
@@ -573,11 +587,11 @@ class DateTransformer extends LeafTransformerBase {
573
587
  return val;
574
588
  };
575
589
  afterTransformer = (val) => {
576
- if (!isString(val)) {
590
+ if (typeof val !== "string") {
577
591
  return val;
578
592
  }
579
593
  const date = parseISO(val);
580
- if (isNaN(date.getTime())) {
594
+ if (Number.isNaN(date.getTime())) {
581
595
  return val;
582
596
  }
583
597
  return date;
@@ -595,7 +609,7 @@ class ObjectIdTransformer extends LeafTransformerBase {
595
609
  return val;
596
610
  };
597
611
  afterTransformer = (val) => {
598
- if (isString(val) && /^[a-f\d]{24}$/i.test(val)) {
612
+ if (typeof val === "string" && /^[a-f\d]{24}$/i.test(val)) {
599
613
  return new ObjectId(val);
600
614
  }
601
615
  return val;
@@ -612,7 +626,7 @@ function applyTransform(parent, dataKey, transformer, transformField, index) {
612
626
  const transformLevel = transformField[index];
613
627
  switch (transformLevel.type) {
614
628
  case "this": {
615
- if (!isPlainObject(parent) && !isArray(parent)) {
629
+ if (!isPlainObject(parent) && !Array.isArray(parent)) {
616
630
  return;
617
631
  }
618
632
  if (parent.hasOwnProperty(dataKey)) {
@@ -638,7 +652,7 @@ function applyTransform(parent, dataKey, transformer, transformField, index) {
638
652
  }
639
653
  break;
640
654
  case "loop": {
641
- if (!isArray(parent[dataKey])) {
655
+ if (!Array.isArray(parent[dataKey])) {
642
656
  return;
643
657
  }
644
658
  const cast = parent[dataKey];
@@ -744,7 +758,7 @@ class AjvValidator extends Validators.Base {
744
758
  });
745
759
  validator.addFormat("object-id", {
746
760
  type: "string",
747
- validate: constant(true)
761
+ validate: () => true
748
762
  });
749
763
  }
750
764
  }
@@ -1330,7 +1344,7 @@ class NewrelicTraceExporter extends TracerExporters.Base {
1330
1344
  this.timer = setInterval(() => this.flush(), this.opts.interval * 1e3);
1331
1345
  this.timer.unref();
1332
1346
  }
1333
- this.defaultTags = isFunction(this.opts.defaultTags) ? this.opts.defaultTags.call(this, tracer) : this.opts.defaultTags;
1347
+ this.defaultTags = typeof this.opts.defaultTags === "function" ? this.opts.defaultTags.call(this, tracer) : this.opts.defaultTags;
1334
1348
  if (this.defaultTags) {
1335
1349
  this.defaultTags = flattenTags(this.defaultTags, true);
1336
1350
  }
@@ -1445,7 +1459,7 @@ class NewrelicMetricsReporter extends MetricReporters.Base {
1445
1459
  this.timer = setInterval(() => this.flush(), this.opts.interval * 1e3);
1446
1460
  this.timer.unref();
1447
1461
  }
1448
- const defaultTags = isFunction(this.opts.defaultTags) ? this.opts.defaultTags.call(this, registry) : this.opts.defaultTags;
1462
+ const defaultTags = typeof this.opts.defaultTags === "function" ? this.opts.defaultTags.call(this, registry) : this.opts.defaultTags;
1449
1463
  if (defaultTags) {
1450
1464
  this.defaultTags = flattenTags(defaultTags, true);
1451
1465
  }
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  var v4 = require('zod/v4');
4
- var index = require('../index-BUXfgQp5.cjs');
4
+ var index = require('../index-CjA1_Io7.cjs');
5
5
  var moleculer = require('moleculer');
6
- var lodashEs = require('lodash-es');
6
+ var esToolkit = require('es-toolkit');
7
7
  var mongodb = require('mongodb');
8
8
  var index$1 = require('../index-82e1CXJX.cjs');
9
9
  var mixins_globalStore_mixin = require('./global-store.mixin.cjs');
10
+ var compat = require('es-toolkit/compat');
10
11
  require('bson');
11
12
  require('date-fns');
12
13
  require('zod');
@@ -835,14 +836,14 @@ function isIndexEqual(dbIdx, idx) {
835
836
  if (!dbIdx.collation || !opts?.collation) {
836
837
  return false;
837
838
  }
838
- if (!lodashEs.isMatch(dbIdx.collation, opts.collation)) {
839
+ if (!compat.isMatch(dbIdx.collation, opts.collation)) {
839
840
  return false;
840
841
  }
841
842
  }
842
843
  if (Boolean(dbIdx.sparse) !== Boolean(opts?.sparse)) {
843
844
  return false;
844
845
  }
845
- return dbIdx.expireAfterSeconds === opts?.expireAfterSeconds && dbIdx.unique === opts?.unique && lodashEs.isEqual(dbIdx.partialFilterExpression, opts?.partialFilterExpression);
846
+ return dbIdx.expireAfterSeconds === opts?.expireAfterSeconds && dbIdx.unique === opts?.unique && compat.isEqual(dbIdx.partialFilterExpression, opts?.partialFilterExpression);
846
847
  }
847
848
  function isOnAtlas() {
848
849
  return (MONGO_URL || MONGODB_URL).includes(".mongodb.net");
@@ -945,7 +946,7 @@ async function getIndexesDifference(collection, declaredIndexes = [], declaredSe
945
946
  });
946
947
  } else {
947
948
  const [dbIdx] = searchIndexes.splice(dbIdxPos, 1);
948
- if (!lodashEs.isEqual(dbIdx.latestDefinition, idx)) {
949
+ if (!esToolkit.isEqual(dbIdx.latestDefinition, idx)) {
949
950
  states.push({
950
951
  type: "searchIndex",
951
952
  name,
@@ -1115,18 +1116,18 @@ function filterObjectFields(obj, fields) {
1115
1116
  return obj;
1116
1117
  }
1117
1118
  let res = obj;
1118
- const [fieldsRemove, fieldsAdd] = lodashEs.partition(
1119
+ const [fieldsRemove, fieldsAdd] = esToolkit.partition(
1119
1120
  fields || [],
1120
1121
  (f) => f.startsWith("-")
1121
1122
  );
1122
1123
  if (fieldsRemove.length) {
1123
- res = lodashEs.omit(
1124
+ res = esToolkit.omit(
1124
1125
  res,
1125
1126
  fieldsRemove.map((f) => f.substring(1))
1126
1127
  );
1127
1128
  }
1128
1129
  if (fieldsAdd.length) {
1129
- res = lodashEs.pick(res, fieldsAdd);
1130
+ res = esToolkit.pick(res, fieldsAdd);
1130
1131
  }
1131
1132
  return res;
1132
1133
  }
@@ -1,10 +1,11 @@
1
1
  import { ZodType, z, ZodObject } from 'zod/v4';
2
- import { o as omitFields, d as optionalFields, S as SCHEMA_REF_NAME, O as OBJECTID_TYPE, C as COERCE_ARRAY_ATTRIBUTE, h as zodObjectId, i as zodCoerceArray, j as createOpenAPIResponses } from '../index-BmVULkqf.mjs';
2
+ import { o as omitFields, d as optionalFields, S as SCHEMA_REF_NAME, O as OBJECTID_TYPE, C as COERCE_ARRAY_ATTRIBUTE, h as zodObjectId, i as zodCoerceArray, j as createOpenAPIResponses } from '../index-yStjjADK.mjs';
3
3
  import { Errors } from 'moleculer';
4
- import { isMatch, isEqual, partition, omit, pick } from 'lodash-es';
4
+ import { isEqual as isEqual$1, partition, omit, pick } from 'es-toolkit';
5
5
  import { MongoClient } from 'mongodb';
6
6
  import { w as wrapMixin } from '../index-DNJWwcZu.mjs';
7
7
  import { GlobalStoreMixin } from './global-store.mixin.mjs';
8
+ import { isMatch, isEqual } from 'es-toolkit/compat';
8
9
  import 'bson';
9
10
  import 'date-fns';
10
11
  import 'zod';
@@ -943,7 +944,7 @@ async function getIndexesDifference(collection, declaredIndexes = [], declaredSe
943
944
  });
944
945
  } else {
945
946
  const [dbIdx] = searchIndexes.splice(dbIdxPos, 1);
946
- if (!isEqual(dbIdx.latestDefinition, idx)) {
947
+ if (!isEqual$1(dbIdx.latestDefinition, idx)) {
947
948
  states.push({
948
949
  type: "searchIndex",
949
950
  name,
@@ -2,7 +2,6 @@
2
2
 
3
3
  var moleculer = require('moleculer');
4
4
  var bullmq = require('bullmq');
5
- var lodashEs = require('lodash-es');
6
5
  var index = require('../index-82e1CXJX.cjs');
7
6
  var mixins_globalStore_mixin = require('./global-store.mixin.cjs');
8
7
  var ioredis = require('ioredis');
@@ -81,7 +80,7 @@ function QueueClient(queueName, opts) {
81
80
  `Queue client '${queueName}' already exists on service '${this.name}'`
82
81
  );
83
82
  }
84
- const key = lodashEs.isFunction(opts.brokerURL) ? await opts.brokerURL(this) : opts.brokerURL;
83
+ const key = typeof opts.brokerURL === "function" ? await opts.brokerURL(this) : opts.brokerURL;
85
84
  this[kKey] = key;
86
85
  let connection = this.getFromStore("redis", key);
87
86
  if (!connection) {
@@ -163,7 +162,7 @@ function QueueEventsClient(queueName, opts) {
163
162
  `Queue client '${queueName}' already exists on service '${this.name}'`
164
163
  );
165
164
  }
166
- const key = lodashEs.isFunction(opts.brokerURL) ? await opts.brokerURL(this) : opts.brokerURL;
165
+ const key = typeof opts.brokerURL === "function" ? await opts.brokerURL(this) : opts.brokerURL;
167
166
  this[kKey] = key;
168
167
  let connection = this.getFromStore("redis", key);
169
168
  if (!connection) {
@@ -214,7 +213,7 @@ function QueueFlowProducerMixin(opts) {
214
213
  `Queue Flow producer already exists on service '${this.name}'`
215
214
  );
216
215
  }
217
- const url = lodashEs.isFunction(opts.brokerURL) ? await opts.brokerURL(this) : opts.brokerURL;
216
+ const url = typeof opts.brokerURL === "function" ? await opts.brokerURL(this) : opts.brokerURL;
218
217
  const connection = createRedisConnection(url);
219
218
  this.$flowProducer = new bullmq.FlowProducer({ connection, ...opts });
220
219
  this[kConnection$1] = connection;
@@ -259,7 +258,7 @@ function QueueStaticRepeatableJobs(queueName, jobs, opts) {
259
258
  mixins: [mixins_globalStore_mixin.GlobalStoreMixin()],
260
259
  methods: {
261
260
  async registerRepeatableJobs() {
262
- const key = lodashEs.isFunction(opts.brokerURL) ? await opts.brokerURL(this) : opts.brokerURL;
261
+ const key = typeof opts.brokerURL === "function" ? await opts.brokerURL(this) : opts.brokerURL;
263
262
  this[kKey] = key;
264
263
  let connection = this.getFromStore("redis", key);
265
264
  if (!connection) {
@@ -384,7 +383,7 @@ function QueueWorker(queueName, opts, processorOptions = {}) {
384
383
  `A QueueWorker mixin was already on service '${this.name}'`
385
384
  );
386
385
  }
387
- const url = lodashEs.isFunction(opts.brokerURL) ? await opts.brokerURL(this) : opts.brokerURL;
386
+ const url = typeof opts.brokerURL === "function" ? await opts.brokerURL(this) : opts.brokerURL;
388
387
  const connection = createRedisConnection(url);
389
388
  const worker = new bullmq.Worker(queueName, this.processJob.bind(this), {
390
389
  connection,
@@ -1,6 +1,5 @@
1
1
  import { Errors } from 'moleculer';
2
2
  import { Queue, QueueEvents, FlowProducer, Worker } from 'bullmq';
3
- import { isFunction } from 'lodash-es';
4
3
  import { w as wrapMixin } from '../index-DNJWwcZu.mjs';
5
4
  import { GlobalStoreMixin } from './global-store.mixin.mjs';
6
5
  import { Redis } from 'ioredis';
@@ -79,7 +78,7 @@ function QueueClient(queueName, opts) {
79
78
  `Queue client '${queueName}' already exists on service '${this.name}'`
80
79
  );
81
80
  }
82
- const key = isFunction(opts.brokerURL) ? await opts.brokerURL(this) : opts.brokerURL;
81
+ const key = typeof opts.brokerURL === "function" ? await opts.brokerURL(this) : opts.brokerURL;
83
82
  this[kKey] = key;
84
83
  let connection = this.getFromStore("redis", key);
85
84
  if (!connection) {
@@ -161,7 +160,7 @@ function QueueEventsClient(queueName, opts) {
161
160
  `Queue client '${queueName}' already exists on service '${this.name}'`
162
161
  );
163
162
  }
164
- const key = isFunction(opts.brokerURL) ? await opts.brokerURL(this) : opts.brokerURL;
163
+ const key = typeof opts.brokerURL === "function" ? await opts.brokerURL(this) : opts.brokerURL;
165
164
  this[kKey] = key;
166
165
  let connection = this.getFromStore("redis", key);
167
166
  if (!connection) {
@@ -212,7 +211,7 @@ function QueueFlowProducerMixin(opts) {
212
211
  `Queue Flow producer already exists on service '${this.name}'`
213
212
  );
214
213
  }
215
- const url = isFunction(opts.brokerURL) ? await opts.brokerURL(this) : opts.brokerURL;
214
+ const url = typeof opts.brokerURL === "function" ? await opts.brokerURL(this) : opts.brokerURL;
216
215
  const connection = createRedisConnection(url);
217
216
  this.$flowProducer = new FlowProducer({ connection, ...opts });
218
217
  this[kConnection$1] = connection;
@@ -257,7 +256,7 @@ function QueueStaticRepeatableJobs(queueName, jobs, opts) {
257
256
  mixins: [GlobalStoreMixin()],
258
257
  methods: {
259
258
  async registerRepeatableJobs() {
260
- const key = isFunction(opts.brokerURL) ? await opts.brokerURL(this) : opts.brokerURL;
259
+ const key = typeof opts.brokerURL === "function" ? await opts.brokerURL(this) : opts.brokerURL;
261
260
  this[kKey] = key;
262
261
  let connection = this.getFromStore("redis", key);
263
262
  if (!connection) {
@@ -382,7 +381,7 @@ function QueueWorker(queueName, opts, processorOptions = {}) {
382
381
  `A QueueWorker mixin was already on service '${this.name}'`
383
382
  );
384
383
  }
385
- const url = isFunction(opts.brokerURL) ? await opts.brokerURL(this) : opts.brokerURL;
384
+ const url = typeof opts.brokerURL === "function" ? await opts.brokerURL(this) : opts.brokerURL;
386
385
  const connection = createRedisConnection(url);
387
386
  const worker = new Worker(queueName, this.processJob.bind(this), {
388
387
  connection,
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.2.0",
9
+ "version": "1.2.2",
10
10
  "main": "./dist/index.cjs",
11
11
  "module": "./dist/index.mjs",
12
12
  "types": "./dist/index.d.cts",
@@ -108,7 +108,7 @@
108
108
  "ajv-keywords": "^5.1.0",
109
109
  "bson": "^6.2.0",
110
110
  "date-fns": "^2.21.3",
111
- "lodash-es": "^4.17.21",
111
+ "es-toolkit": "^1.39.10",
112
112
  "pino": "^9.9.0",
113
113
  "pino-pretty": "^13.1.1"
114
114
  },
@@ -152,7 +152,6 @@
152
152
  "@treatwell/eslint-plugin-moleculer": "^1.1.0",
153
153
  "@tsconfig/node-lts": "^22.0.2",
154
154
  "@types/jsonwebtoken": "^9.0.10",
155
- "@types/lodash-es": "^4.17.12",
156
155
  "@types/node": "^24.3.0",
157
156
  "@types/redlock": "^4.0.7",
158
157
  "bullmq": "^5.12.10",