@treatwell/moleculer-essentials 1.0.0

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.
Files changed (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/dist/context-factory-BWO3xPWE.d.cts +520 -0
  4. package/dist/context-factory-BWO3xPWE.d.mts +520 -0
  5. package/dist/index-82e1CXJX.cjs +11 -0
  6. package/dist/index-BV1ZqQrU.mjs +351 -0
  7. package/dist/index-DNJWwcZu.mjs +8 -0
  8. package/dist/index-rZl77S1z.cjs +375 -0
  9. package/dist/index.cjs +1570 -0
  10. package/dist/index.d.cts +373 -0
  11. package/dist/index.d.mts +373 -0
  12. package/dist/index.mjs +1535 -0
  13. package/dist/mixins/database.mixin.cjs +1673 -0
  14. package/dist/mixins/database.mixin.d.cts +958 -0
  15. package/dist/mixins/database.mixin.d.mts +958 -0
  16. package/dist/mixins/database.mixin.mjs +1645 -0
  17. package/dist/mixins/encryptor.mixin.cjs +84 -0
  18. package/dist/mixins/encryptor.mixin.d.cts +31 -0
  19. package/dist/mixins/encryptor.mixin.d.mts +31 -0
  20. package/dist/mixins/encryptor.mixin.mjs +81 -0
  21. package/dist/mixins/global-store.mixin.cjs +56 -0
  22. package/dist/mixins/global-store.mixin.d.cts +39 -0
  23. package/dist/mixins/global-store.mixin.d.mts +39 -0
  24. package/dist/mixins/global-store.mixin.mjs +54 -0
  25. package/dist/mixins/jwt.mixin.cjs +118 -0
  26. package/dist/mixins/jwt.mixin.d.cts +43 -0
  27. package/dist/mixins/jwt.mixin.d.mts +43 -0
  28. package/dist/mixins/jwt.mixin.mjs +115 -0
  29. package/dist/mixins/queue.mixin.cjs +420 -0
  30. package/dist/mixins/queue.mixin.d.cts +150 -0
  31. package/dist/mixins/queue.mixin.d.mts +150 -0
  32. package/dist/mixins/queue.mixin.mjs +414 -0
  33. package/dist/mixins/redis.mixin.cjs +50 -0
  34. package/dist/mixins/redis.mixin.d.cts +27 -0
  35. package/dist/mixins/redis.mixin.d.mts +27 -0
  36. package/dist/mixins/redis.mixin.mjs +48 -0
  37. package/dist/mixins/redlock.mixin.cjs +76 -0
  38. package/dist/mixins/redlock.mixin.d.cts +30 -0
  39. package/dist/mixins/redlock.mixin.d.mts +30 -0
  40. package/dist/mixins/redlock.mixin.mjs +74 -0
  41. package/package.json +181 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Treatwell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # moleculer-essentials
@@ -0,0 +1,520 @@
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
+ import { ObjectId } from 'bson';
3
+ import { ZodType, z } from 'zod/v4';
4
+ import { Options, ErrorObject } from 'ajv/dist/2019.js';
5
+
6
+ type UnionToIntersection$1<U> = (U extends any ? (_: U) => void : never) extends (_: infer I) => void ? I : never;
7
+ type SomeJSONSchema = JSONSchemaType<Known, true>;
8
+ type PartialSchema<T> = Partial<JSONSchemaType<T, true>>;
9
+ type JSONType<T extends string, IsPartial extends boolean> = IsPartial extends true ? T | undefined : T;
10
+ interface NumberKeywords {
11
+ minimum?: number;
12
+ maximum?: number;
13
+ exclusiveMinimum?: number;
14
+ exclusiveMaximum?: number;
15
+ multipleOf?: number;
16
+ format?: string;
17
+ }
18
+ interface StringKeywords {
19
+ minLength?: number;
20
+ maxLength?: number;
21
+ pattern?: string;
22
+ format?: string;
23
+ }
24
+ type JSONSchemaType<T, IsPartial extends boolean = false> = (// these two unions allow arbitrary unions of types
25
+ {
26
+ anyOf: readonly JSONSchemaType<T, IsPartial>[];
27
+ } | {
28
+ oneOf: readonly JSONSchemaType<T, IsPartial>[];
29
+ } | {
30
+ allOf: readonly JSONSchemaType<T, true>[];
31
+ } | ({
32
+ type: readonly (T extends number ? JSONType<'number' | 'integer', IsPartial> : T extends string ? JSONType<'string', IsPartial> : T extends boolean ? JSONType<'boolean', IsPartial> : never)[];
33
+ } & UnionToIntersection$1<T extends number ? NumberKeywords : T extends string ? StringKeywords : T extends boolean ? {} : never>) | ((T extends number ? {
34
+ type: JSONType<'number' | 'integer', IsPartial>;
35
+ } & NumberKeywords : T extends string ? {
36
+ type: JSONType<'string', IsPartial>;
37
+ } & StringKeywords : T extends boolean ? {
38
+ type: JSONType<'boolean', IsPartial>;
39
+ } : T extends Date ? {
40
+ type: JSONType<'string', IsPartial>;
41
+ format: 'date-time' | 'date';
42
+ } : T extends Buffer ? {
43
+ instanceof: 'Buffer';
44
+ } : T extends null ? {
45
+ type: JSONType<'null', IsPartial>;
46
+ } | {
47
+ nullable?: true;
48
+ } : T extends ObjectId ? {
49
+ type: JSONType<'string', IsPartial>;
50
+ format: 'object-id';
51
+ } : T extends [any, ...any[]] ? {
52
+ type: JSONType<'array', IsPartial>;
53
+ items: {
54
+ readonly [K in keyof T]-?: JSONSchemaType<T[K]> & Nullable<T[K]>;
55
+ } & {
56
+ length: T['length'];
57
+ };
58
+ minItems: T['length'];
59
+ } & ({
60
+ maxItems: T['length'];
61
+ } | {
62
+ additionalItems: false;
63
+ }) : T extends readonly any[] ? {
64
+ type: JSONType<'array', IsPartial>;
65
+ items: JSONSchemaType<T[0]>;
66
+ contains?: PartialSchema<T[0]>;
67
+ minItems?: number;
68
+ maxItems?: number;
69
+ minContains?: number;
70
+ maxContains?: number;
71
+ uniqueItems?: true;
72
+ additionalItems?: never;
73
+ } : T extends Record<string, any> ? {
74
+ type: JSONType<'object', IsPartial>;
75
+ required: IsPartial extends true ? Readonly<(keyof T)[]> : Readonly<RequiredMembers<T>[]>;
76
+ additionalProperties?: boolean | JSONSchemaType<T[string]>;
77
+ unevaluatedProperties?: boolean | JSONSchemaType<T[string]>;
78
+ discriminator?: {
79
+ propertyName: keyof T;
80
+ };
81
+ properties?: IsPartial extends true ? Partial<PropertiesSchema<T>> : PropertiesSchema<T>;
82
+ patternProperties?: Record<string, JSONSchemaType<T[string]>>;
83
+ propertyNames?: Omit<JSONSchemaType<string>, 'type'> & {
84
+ type?: 'string';
85
+ };
86
+ dependencies?: {
87
+ [K in keyof T]?: Readonly<(keyof T)[]> | PartialSchema<T>;
88
+ };
89
+ dependentRequired?: {
90
+ [K in keyof T]?: Readonly<(keyof T)[]>;
91
+ };
92
+ dependentSchemas?: {
93
+ [K in keyof T]?: PartialSchema<T>;
94
+ };
95
+ minProperties?: number;
96
+ maxProperties?: number;
97
+ } : T extends null ? {
98
+ type: JSONType<'null', IsPartial>;
99
+ nullable: true;
100
+ } : never) & {
101
+ allOf?: Readonly<PartialSchema<T>[]>;
102
+ anyOf?: Readonly<PartialSchema<T>[]>;
103
+ oneOf?: Readonly<PartialSchema<T>[]>;
104
+ if?: PartialSchema<T>;
105
+ then?: PartialSchema<T>;
106
+ else?: PartialSchema<T>;
107
+ not?: PartialSchema<T>;
108
+ })) & {
109
+ [keyword: string]: any;
110
+ $id?: string;
111
+ $ref?: string;
112
+ $defs?: Record<string, JSONSchemaType<Known, true>>;
113
+ definitions?: Record<string, JSONSchemaType<Known, true>>;
114
+ };
115
+ type Known = {
116
+ [key: string]: Known;
117
+ } | [Known, ...Known[]] | Known[] | number | string | boolean | null;
118
+ type PropertiesSchema<T> = {
119
+ [K in keyof T]-?: (JSONSchemaType<T[K]> & Nullable<T[K]>) | {
120
+ $ref: string;
121
+ };
122
+ };
123
+ type RequiredMembers<T> = {
124
+ [K in keyof T]-?: undefined extends T[K] ? never : K;
125
+ }[keyof T];
126
+ type Nullable<T> = undefined extends T ? {
127
+ nullable?: true;
128
+ const?: never;
129
+ enum?: Readonly<(T | null)[]>;
130
+ default?: T | null;
131
+ } : {
132
+ const?: T;
133
+ enum?: Readonly<T[]>;
134
+ default?: T;
135
+ };
136
+
137
+ interface ContactObject {
138
+ name?: string;
139
+ url?: string;
140
+ email?: string;
141
+ }
142
+ interface LicenseObject {
143
+ name: string;
144
+ url?: string;
145
+ }
146
+ interface InfoObject {
147
+ title: string;
148
+ description?: string;
149
+ termsOfService?: string;
150
+ contact?: ContactObject;
151
+ license?: LicenseObject;
152
+ version: string;
153
+ }
154
+ interface ServerVariableObject {
155
+ enum?: string[];
156
+ default: string;
157
+ description?: string;
158
+ }
159
+ interface ServerObject {
160
+ url: string;
161
+ description?: string;
162
+ variables?: Record<string, ServerVariableObject>;
163
+ }
164
+ type PathsObject = Record<string, PathItemObject>;
165
+ interface ExternalDocumentationObject {
166
+ description?: string;
167
+ url: string;
168
+ }
169
+ interface ParameterObject extends ParameterBaseObject {
170
+ name: string;
171
+ in: string;
172
+ }
173
+ type HeaderObject = ParameterBaseObject;
174
+ interface ParameterBaseObject {
175
+ description?: string;
176
+ required?: boolean;
177
+ deprecated?: boolean;
178
+ allowEmptyValue?: boolean;
179
+ style?: string;
180
+ explode?: boolean;
181
+ allowReserved?: boolean;
182
+ schema?: ReferenceObject | SchemaObject;
183
+ example?: any;
184
+ examples?: Record<string, ReferenceObject | ExampleObject>;
185
+ content?: Record<string, MediaTypeObject>;
186
+ }
187
+ type SchemaObject<T = any, _partial extends boolean = false> = JSONSchemaType<T, _partial>;
188
+ interface ReferenceObject {
189
+ $ref: string;
190
+ }
191
+ interface ExampleObject {
192
+ summary?: string;
193
+ description?: string;
194
+ value?: any;
195
+ externalValue?: string;
196
+ }
197
+ interface EncodingObject {
198
+ contentType?: string;
199
+ headers?: Record<string, ReferenceObject | HeaderObject>;
200
+ style?: string;
201
+ explode?: boolean;
202
+ allowReserved?: boolean;
203
+ }
204
+ interface MediaTypeObject {
205
+ schema?: ReferenceObject | SchemaObject;
206
+ example?: any;
207
+ examples?: Record<string, ReferenceObject | ExampleObject>;
208
+ encoding?: Record<string, EncodingObject>;
209
+ }
210
+ interface RequestBodyObject {
211
+ description?: string;
212
+ content: Record<string, MediaTypeObject>;
213
+ required?: boolean;
214
+ }
215
+ interface LinkObject {
216
+ operationRef?: string;
217
+ operationId?: string;
218
+ parameters?: Record<string, any>;
219
+ requestBody?: any;
220
+ description?: string;
221
+ server?: ServerObject;
222
+ }
223
+ interface ResponseObject {
224
+ description: string;
225
+ headers?: Record<string, ReferenceObject | HeaderObject>;
226
+ content?: Record<string, MediaTypeObject>;
227
+ links?: Record<string, ReferenceObject | LinkObject>;
228
+ }
229
+ type ResponsesObject = Record<string, ReferenceObject | ResponseObject>;
230
+ type SecurityRequirementObject = Record<string, string[]>;
231
+ interface HttpSecurityScheme {
232
+ type: 'http';
233
+ description?: string;
234
+ scheme: string;
235
+ bearerFormat?: string;
236
+ }
237
+ interface ApiKeySecurityScheme {
238
+ type: 'apiKey';
239
+ description?: string;
240
+ name: string;
241
+ in: string;
242
+ }
243
+ interface OAuth2SecurityScheme {
244
+ type: 'oauth2';
245
+ flows: {
246
+ implicit?: {
247
+ authorizationUrl: string;
248
+ refreshUrl?: string;
249
+ scopes: Record<string, string>;
250
+ };
251
+ password?: {
252
+ tokenUrl: string;
253
+ refreshUrl?: string;
254
+ scopes: Record<string, string>;
255
+ };
256
+ clientCredentials?: {
257
+ tokenUrl: string;
258
+ refreshUrl?: string;
259
+ scopes: Record<string, string>;
260
+ };
261
+ authorizationCode?: {
262
+ authorizationUrl: string;
263
+ tokenUrl: string;
264
+ refreshUrl?: string;
265
+ scopes: Record<string, string>;
266
+ };
267
+ };
268
+ }
269
+ interface OpenIdSecurityScheme {
270
+ type: 'openIdConnect';
271
+ description?: string;
272
+ openIdConnectUrl: string;
273
+ }
274
+ type SecuritySchemeObject = HttpSecurityScheme | ApiKeySecurityScheme | OAuth2SecurityScheme | OpenIdSecurityScheme;
275
+ type CallbackObject = Record<string, PathItemObject>;
276
+ interface ComponentsObject {
277
+ schemas?: Record<string, ReferenceObject | SchemaObject>;
278
+ responses?: Record<string, ReferenceObject | ResponseObject>;
279
+ parameters?: Record<string, ReferenceObject | ParameterObject>;
280
+ examples?: Record<string, ReferenceObject | ExampleObject>;
281
+ requestBodies?: Record<string, ReferenceObject | RequestBodyObject>;
282
+ headers?: Record<string, ReferenceObject | HeaderObject>;
283
+ securitySchemes?: Record<string, ReferenceObject | SecuritySchemeObject>;
284
+ links?: Record<string, ReferenceObject | LinkObject>;
285
+ callbacks?: Record<string, ReferenceObject | CallbackObject>;
286
+ }
287
+ interface TagObject {
288
+ name: string;
289
+ description?: string;
290
+ externalDocs?: ExternalDocumentationObject;
291
+ }
292
+ interface OperationObject {
293
+ tags?: string[];
294
+ summary?: string;
295
+ description?: string;
296
+ externalDocs?: ExternalDocumentationObject;
297
+ operationId?: string;
298
+ parameters?: (ReferenceObject | ParameterObject)[];
299
+ requestBody?: ReferenceObject | RequestBodyObject;
300
+ responses?: ResponsesObject;
301
+ callbacks?: Record<string, ReferenceObject | CallbackObject>;
302
+ deprecated?: boolean;
303
+ security?: SecurityRequirementObject[];
304
+ servers?: ServerObject[];
305
+ }
306
+ interface PathItemObject {
307
+ $ref?: string;
308
+ summary?: string;
309
+ description?: string;
310
+ get?: OperationObject;
311
+ put?: OperationObject;
312
+ post?: OperationObject;
313
+ delete?: OperationObject;
314
+ options?: OperationObject;
315
+ head?: OperationObject;
316
+ patch?: OperationObject;
317
+ trace?: OperationObject;
318
+ servers?: ServerObject[];
319
+ parameters?: (ReferenceObject | ParameterObject)[];
320
+ }
321
+ interface Document {
322
+ openapi: string;
323
+ info: InfoObject;
324
+ servers?: ServerObject[];
325
+ paths: PathsObject;
326
+ components?: ComponentsObject;
327
+ security?: SecurityRequirementObject[];
328
+ tags?: TagObject[];
329
+ externalDocs?: ExternalDocumentationObject;
330
+ 'x-express-openapi-additional-middleware'?: (((request: any, response: any, next: any) => Promise<void>) | ((request: any, response: any, next: any) => void))[];
331
+ 'x-express-openapi-validation-strict'?: boolean;
332
+ }
333
+
334
+ interface CustomActionSchema<T = unknown> {
335
+ name?: string;
336
+ rest?: RestSchema | RestSchema[] | string | string[];
337
+ visibility?: ActionVisibility;
338
+ service?: Service;
339
+ cache?: boolean | ActionCacheOptions;
340
+ handler?: (ctx: Context<never, never>) => Promise<T> | T;
341
+ tracing?: boolean | TracingActionOptions;
342
+ bulkhead?: BulkheadOptions;
343
+ circuitBreaker?: BrokerCircuitBreakerOptions;
344
+ retryPolicy?: RetryPolicyOptions;
345
+ fallback?: string | FallbackHandler;
346
+ hooks?: ActionHooks;
347
+ params?: unknown;
348
+ disableTransforms?: boolean;
349
+ rateLimiter?: string;
350
+ rateLimiterCountTowardDefault?: boolean;
351
+ openAPINames?: string[] | null;
352
+ openapi?: OperationObject;
353
+ bodySchemaRefName?: string;
354
+ }
355
+ type Alias = {
356
+ actionName: string;
357
+ path: string;
358
+ fullPath: string;
359
+ methods: string;
360
+ routePath: string;
361
+ action: CustomActionSchema;
362
+ };
363
+
364
+ type ValidationSchema = JSONSchemaType<any>;
365
+ type Transform<T, U> = (val: T) => U;
366
+ type TransformLevel = {
367
+ type: 'access';
368
+ key: string;
369
+ } | {
370
+ type: 'this';
371
+ } | {
372
+ type: 'loop';
373
+ } | {
374
+ type: 'select';
375
+ subTransforms: TransformField[];
376
+ };
377
+ type TransformField = TransformLevel[];
378
+ type TransformMap = WeakMap<ValidationSchema, TransformField[]>;
379
+ interface Transformer<T, U> {
380
+ transformMap: TransformMap;
381
+ beforeTransformer: Transform<unknown | T, unknown | U>;
382
+ afterTransformer: Transform<unknown | U, unknown | T>;
383
+ findTransforms: (schema: ValidationSchema) => TransformField[];
384
+ }
385
+
386
+ /**
387
+ * Use zod for schema validation.
388
+ * DO NOT support Async refinements/transforms yet.
389
+ *
390
+ * Transforms MUST BE handled by the consumer directly.
391
+ */
392
+ declare class ZodValidator extends Validators.Base {
393
+ compile(): () => void;
394
+ validate<S extends ZodType>(params: unknown, schema: S, ctx?: Context): z.output<S>;
395
+ /**
396
+ * Override BaseValidator middleware to handle our custom compile function.
397
+ */
398
+ middleware(): (handler: ActionHandler, action: ActionSchema) => unknown;
399
+ }
400
+ declare module 'moleculer' {
401
+ interface BaseValidator {
402
+ validate<S extends ZodType>(params: unknown, schema: S): z.output<S>;
403
+ }
404
+ }
405
+
406
+ /**
407
+ * Moleculer validator using Ajv/zod for schema validation.
408
+ *
409
+ * It also supports some additional features:
410
+ * - Property transformations depending on the schema (Dates, ObjectIds, array coercion)
411
+ * - Ref extractor, used to optimize schema compilation, and generate better OpenAPI specs
412
+ *
413
+ * Some config can be done at the action level:
414
+ * - disableTransforms: Disable all transformations for this action
415
+ * - validatorMode: Use a different validator mode for this action
416
+ */
417
+ declare class AjvValidator<Mode extends string> extends Validators.Base {
418
+ private readonly modes;
419
+ private readonly defaultMode;
420
+ private readonly broker;
421
+ readonly zodValidator?: ZodValidator;
422
+ /**
423
+ * Cache of compiled validation functions.
424
+ * This is because compiling a schema is quite expensive for Ajv.
425
+ */
426
+ private compiledFns;
427
+ constructor(opts: Record<Mode, Options>, defaultMode: Mode, zodValidator?: ZodValidator);
428
+ /**
429
+ * Validate a set of parameters against a schema.
430
+ *
431
+ * May have a small performance hit on the first call for a specific schema,
432
+ * as it will compile the schema.
433
+ */
434
+ validate(params: unknown, schema: ValidationSchema): true;
435
+ validate<S extends ZodType>(params: unknown, schema: S): z.output<S>;
436
+ /**
437
+ * This method compiles a schema into a validation function.
438
+ *
439
+ * Compiling a schema is quite expensive, so it will only be done once per schema.
440
+ */
441
+ compile(schema: ValidationSchema, mode?: Mode): (params: unknown, ctx?: Context) => boolean;
442
+ /**
443
+ * For debugging purposes, log the validation errors.
444
+ * This is only enabled if the DETAILED_AJV_VALIDATION_ERRORS env var is set to 'yes'.
445
+ */
446
+ logError(name: string, schema: ValidationSchema, errors?: null | ErrorObject[]): void;
447
+ /**
448
+ * We wrap the localAction and localEvent methods to add validation to the actions and events handlers.
449
+ * Note that we lazy compile schemas in order to avoid a performance hit on startup.
450
+ */
451
+ middleware(): (handler: ActionHandler, action: ActionSchema) => unknown;
452
+ }
453
+ declare module 'moleculer' {
454
+ interface BaseValidator {
455
+ validate(params: unknown, schema: ValidationSchema): true;
456
+ }
457
+ }
458
+
459
+ type Unpacked<T> = T extends (infer U)[] ? U : never;
460
+ type UnionToIntersection<U> = (U extends unknown ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never;
461
+ type OptionallyArray<T> = T | T[];
462
+
463
+ type ServiceEventSchema = ServiceEvent & {
464
+ params?: unknown;
465
+ };
466
+
467
+ /**
468
+ * This type represent what is accessible from the `this` in a service file.
469
+ */
470
+ type ServiceThis<Settings, Methods, Mixins, AdditionalProperties> = {
471
+ actions: never;
472
+ settings: Settings;
473
+ } & Methods & AdditionalProperties & Service & UnionToIntersection<Unpacked<Mixins>>['methods'] & Record<string | symbol, unknown>;
474
+ /**
475
+ * Type used for injecting `this` in an object.
476
+ */
477
+ type ObjectServiceThis<T, Settings, Methods, Mixins, AdditionalProperties> = T & ThisType<ServiceThis<Settings, Methods, Mixins, AdditionalProperties>>;
478
+ /**
479
+ * Type used for injecting `this` in a simple function.
480
+ */
481
+ type CallbackServiceThis<Return, Settings, Methods, Mixins, AdditionalProperties, Parameters extends unknown[] = []> = (this: ServiceThis<Settings, Methods, Mixins, AdditionalProperties>, ...params: Parameters) => Return;
482
+ interface CustomServiceSchema<Settings, Methods, Mixins, AdditionalProperties> {
483
+ name: string;
484
+ version?: string | number;
485
+ dependencies?: OptionallyArray<string | ServiceDependency>;
486
+ metadata?: Record<string, unknown>;
487
+ settings?: Settings;
488
+ hooks?: ServiceHooks;
489
+ mixins?: Mixins;
490
+ methods?: ObjectServiceThis<Methods, Settings, Methods, Mixins, AdditionalProperties>;
491
+ actions?: Record<string, ObjectServiceThis<CustomActionSchema, Settings, Methods, Mixins, AdditionalProperties>>;
492
+ events?: Record<string, ObjectServiceThis<ServiceEventSchema, Settings, Methods, Mixins, AdditionalProperties>>;
493
+ created?: OptionallyArray<CallbackServiceThis<void, Settings, Methods, Mixins, AdditionalProperties>>;
494
+ started?: OptionallyArray<CallbackServiceThis<Promise<void> | void, Settings, Methods, Mixins, AdditionalProperties>>;
495
+ stopped?: OptionallyArray<CallbackServiceThis<Promise<void> | void, Settings, Methods, Mixins, AdditionalProperties>>;
496
+ merged?: OptionallyArray<CallbackServiceThis<Promise<void> | void, Settings, Methods, Mixins, AdditionalProperties, [
497
+ CustomServiceSchema<Settings, Methods, Mixins, AdditionalProperties>
498
+ ]>>;
499
+ }
500
+
501
+ /**
502
+ * This class replace the default Context class in Moleculer to:
503
+ * - Add a ctx.logger instance with the trace.id and span.id in the bindings
504
+ */
505
+ declare class ContextFactory<P = unknown, M extends object = {}, L = GenericObject> extends Context<P, M, L> {
506
+ constructor(broker: ServiceBroker, endpoint: Endpoint);
507
+ startSpan(name: string, opts?: Moleculer__default.GenericObject): Moleculer__default.Span;
508
+ /**
509
+ * Get a logger for this specific span of the context.
510
+ */
511
+ setLogger(): void;
512
+ }
513
+ declare module 'moleculer' {
514
+ interface Context {
515
+ logger: Moleculer__default.LoggerInstance;
516
+ }
517
+ }
518
+
519
+ export { ZodValidator as Z, AjvValidator as d, ContextFactory as i };
520
+ 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, ReferenceObject as R, SomeJSONSchema as S, Transformer as T, 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 };