@treatwell/moleculer-essentials 2.1.0-beta.1 → 2.1.0-beta.3

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.
@@ -248,7 +248,11 @@ function isZodSchema(schema, type) {
248
248
  if (!_isZodType(schema)) {
249
249
  return false;
250
250
  }
251
- return type ? schema.type === type : true;
251
+ if (!type) {
252
+ return true;
253
+ }
254
+ const sType = schema.type || schema._zod.def.type;
255
+ return sType === type;
252
256
  }
253
257
 
254
258
  const ServerErrorSchema = {
@@ -250,7 +250,11 @@ function isZodSchema(schema, type) {
250
250
  if (!_isZodType(schema)) {
251
251
  return false;
252
252
  }
253
- return type ? schema.type === type : true;
253
+ if (!type) {
254
+ return true;
255
+ }
256
+ const sType = schema.type || schema._zod.def.type;
257
+ return sType === type;
254
258
  }
255
259
 
256
260
  const ServerErrorSchema = {
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-CjPjJvVl.cjs');
3
+ var index = require('./index-lmnhNH-8.cjs');
4
4
  var _2019_js = require('ajv/dist/2019.js');
5
5
  var moleculer = require('moleculer');
6
6
  var addFormats = require('ajv-formats');
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-rbdpRATx.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-rbdpRATx.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 './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';
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, ServiceSchema, ServiceSettingSchema, 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, TracerExporters, Logger as Logger$1, Tracer, Span, MetricReporters, MetricRegistry } from 'moleculer';
7
7
  import { Logger } from 'pino';
8
8
  import 'pino-pretty';
9
9
 
@@ -205,7 +205,7 @@ declare function wrapMixin<Settings, Methods, Mixins>(svc: PartialCustomServiceS
205
205
  * type that extend the original one.
206
206
  * More on why: https://github.com/microsoft/TypeScript/pull/58176#issuecomment-2052698294
207
207
  */
208
- type _InferredServiceSchema = ServiceSchema;
208
+ type _InferredServiceSchema<TSettings = ServiceSettingSchema> = ServiceSchema<TSettings>;
209
209
  /**
210
210
  * This function is a NO-OP and is only useful for Typescript types.
211
211
  * Using Generic arguments allows TS to infer types directly from the object
@@ -214,7 +214,7 @@ type _InferredServiceSchema = ServiceSchema;
214
214
  * For the wrapService fn, it will return a moleculer ServiceSchema that will stripe
215
215
  * out every smart typing of methods. This should never be used inside a mixin.
216
216
  */
217
- declare function wrapService<Settings, Methods, Mixins>(svc: CustomServiceSchema<Settings, Methods, Mixins>): _InferredServiceSchema;
217
+ declare function wrapService<Settings, Methods, Mixins>(svc: CustomServiceSchema<Settings, Methods, Mixins>): _InferredServiceSchema<Settings>;
218
218
 
219
219
  /**
220
220
  * This class replace the default Service class in Moleculer to:
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-rbdpRATx.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-rbdpRATx.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 './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';
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, ServiceSchema, ServiceSettingSchema, 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, TracerExporters, Logger as Logger$1, Tracer, Span, MetricReporters, MetricRegistry } from 'moleculer';
7
7
  import { Logger } from 'pino';
8
8
  import 'pino-pretty';
9
9
 
@@ -205,7 +205,7 @@ declare function wrapMixin<Settings, Methods, Mixins>(svc: PartialCustomServiceS
205
205
  * type that extend the original one.
206
206
  * More on why: https://github.com/microsoft/TypeScript/pull/58176#issuecomment-2052698294
207
207
  */
208
- type _InferredServiceSchema = ServiceSchema;
208
+ type _InferredServiceSchema<TSettings = ServiceSettingSchema> = ServiceSchema<TSettings>;
209
209
  /**
210
210
  * This function is a NO-OP and is only useful for Typescript types.
211
211
  * Using Generic arguments allows TS to infer types directly from the object
@@ -214,7 +214,7 @@ type _InferredServiceSchema = ServiceSchema;
214
214
  * For the wrapService fn, it will return a moleculer ServiceSchema that will stripe
215
215
  * out every smart typing of methods. This should never be used inside a mixin.
216
216
  */
217
- declare function wrapService<Settings, Methods, Mixins>(svc: CustomServiceSchema<Settings, Methods, Mixins>): _InferredServiceSchema;
217
+ declare function wrapService<Settings, Methods, Mixins>(svc: CustomServiceSchema<Settings, Methods, Mixins>): _InferredServiceSchema<Settings>;
218
218
 
219
219
  /**
220
220
  * This class replace the default Service class in Moleculer to:
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SCHEMA_REF_NAME, i as isZodSchema, 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-DNiA_V_T.mjs';
2
- export { D as DATE_TYPE, E as EMPTY_OBJECT_SCHEMA, O as OBJECTID_TYPE, c as addFieldsToSchema, d as composeSchemas, e as createOpenAPIResponses, f as optionalExceptFields, g as optionalFields, p as pickFields, t as toPartialSchema, h as zodCoerceArray, j as zodDate, k as zodObjectId } from './index-DNiA_V_T.mjs';
1
+ import { S as SCHEMA_REF_NAME, i as isZodSchema, 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-8Cv0B4uH.mjs';
2
+ export { D as DATE_TYPE, E as EMPTY_OBJECT_SCHEMA, O as OBJECTID_TYPE, c as addFieldsToSchema, d as composeSchemas, e as createOpenAPIResponses, f as optionalExceptFields, g as optionalFields, p as pickFields, t as toPartialSchema, h as zodCoerceArray, j as zodDate, k as zodObjectId } from './index-8Cv0B4uH.mjs';
3
3
  import { Ajv2019 } from 'ajv/dist/2019.js';
4
4
  import { Validators, Errors, Context, ServiceBroker, Service, TracerExporters, MetricReporters } from 'moleculer';
5
5
  import addFormats from 'ajv-formats';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('../index-CjPjJvVl.cjs');
3
+ var index = require('../index-lmnhNH-8.cjs');
4
4
  var moleculer = require('moleculer');
5
5
  var esToolkit = require('es-toolkit');
6
6
  var v4 = require('zod/v4');
@@ -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-rbdpRATx.cjs';
4
+ import { Y as ValidationSchema, J as JSONSchemaType, C as CustomActionSchema, P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.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-rbdpRATx.mjs';
4
+ import { Y as ValidationSchema, J as JSONSchemaType, C as CustomActionSchema, P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.mjs';
5
5
  import { Readable } from 'stream';
6
6
  import 'bson';
7
7
  import 'ajv/dist/2019.js';
@@ -1,4 +1,4 @@
1
- import { g as optionalFields, o as omitFields, S as SCHEMA_REF_NAME, O as OBJECTID_TYPE, C as COERCE_ARRAY_ATTRIBUTE, i as isZodSchema, k as zodObjectId, h as zodCoerceArray, e as createOpenAPIResponses } from '../index-DNiA_V_T.mjs';
1
+ import { g as optionalFields, o as omitFields, S as SCHEMA_REF_NAME, O as OBJECTID_TYPE, C as COERCE_ARRAY_ATTRIBUTE, i as isZodSchema, k as zodObjectId, h as zodCoerceArray, e as createOpenAPIResponses } from '../index-8Cv0B4uH.mjs';
2
2
  import { Errors } from 'moleculer';
3
3
  import { isEqual as isEqual$1 } from 'es-toolkit';
4
4
  import { z } from 'zod/v4';
@@ -1,4 +1,4 @@
1
- import { P as PartialCustomServiceSchema } from '../types-rbdpRATx.cjs';
1
+ import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.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-rbdpRATx.mjs';
1
+ import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.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-rbdpRATx.cjs';
1
+ import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.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-rbdpRATx.mjs';
1
+ import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.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-rbdpRATx.cjs';
1
+ import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.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-rbdpRATx.mjs';
1
+ import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.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-rbdpRATx.cjs';
1
+ import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.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-rbdpRATx.mjs';
1
+ import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.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-rbdpRATx.cjs';
1
+ import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.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-rbdpRATx.mjs';
1
+ import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.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-rbdpRATx.cjs';
1
+ import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.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-rbdpRATx.mjs';
1
+ import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.mjs';
2
2
  import { Service } from 'moleculer';
3
3
  import { RedisOptions, Redis } from 'ioredis';
4
4
  import Redlock from 'redlock';
@@ -350,7 +350,7 @@ interface CustomActionSchema<T = unknown> extends Omit<ActionSchema, 'params' |
350
350
  openAPINames?: string[] | null;
351
351
  openapi?: OperationObject;
352
352
  bodySchemaRefName?: string;
353
- rest?: CustomRestSchema | CustomRestSchema[] | string | string[];
353
+ rest?: CustomRestSchema | CustomRestSchema[] | string | string[] | null;
354
354
  }
355
355
  type Alias = {
356
356
  actionName: string;
@@ -350,7 +350,7 @@ interface CustomActionSchema<T = unknown> extends Omit<ActionSchema, 'params' |
350
350
  openAPINames?: string[] | null;
351
351
  openapi?: OperationObject;
352
352
  bodySchemaRefName?: string;
353
- rest?: CustomRestSchema | CustomRestSchema[] | string | string[];
353
+ rest?: CustomRestSchema | CustomRestSchema[] | string | string[] | null;
354
354
  }
355
355
  type Alias = {
356
356
  actionName: string;
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-beta.1",
9
+ "version": "2.1.0-beta.3",
10
10
  "main": "./dist/index.cjs",
11
11
  "module": "./dist/index.mjs",
12
12
  "types": "./dist/index.d.cts",