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'; 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'; import { ObjectId } from 'bson'; import { z, ZodType } from 'zod/v4'; import { Ajv2019 } from 'ajv/dist/2019.js'; import { Errors, Context, ServiceSettingSchema, ServiceSchema, Service, ServiceBroker, BrokerOptions, Middleware, LoggerConfig, TracerExporters, Logger as Logger$1, Tracer, Span, MetricReporters, MetricRegistry } from 'moleculer'; import { Logger } from 'pino'; import 'pino-pretty'; declare function omitFields, F extends keyof T>(schema: JSONSchemaType, fields: F[], refName?: string): JSONSchemaType>; declare function pickFields, F extends keyof T>(schema: JSONSchemaType, fields: F[], refName?: string): JSONSchemaType>; declare function optionalExceptFields, F extends keyof T>(schema: JSONSchemaType, fields: F[], refName?: string): JSONSchemaType> & Pick>; declare function optionalFields, F extends keyof T>(schema: JSONSchemaType, fields: F[], refName?: string): JSONSchemaType & Partial>>; declare function toPartialSchema>(schema: JSONSchemaType, refName?: string): JSONSchemaType, true>; declare function addFieldsToSchema, F extends Record>(schema: JSONSchemaType, newFields: F, refName?: string): JSONSchemaType; declare function composeSchemas, U extends Record>(schemaRefName: string | null, schema1: JSONSchemaType, schema2: JSONSchemaType): JSONSchemaType; declare function composeSchemas, U extends Record, V extends Record>(schemaRefName: string | null, schema1: JSONSchemaType, schema2: JSONSchemaType, schema3: JSONSchemaType): JSONSchemaType; declare function composeSchemas, U extends Record, V extends Record, W extends Record>(schemaRefName: string | null, schema1: JSONSchemaType, schema2: JSONSchemaType, schema3: JSONSchemaType, schema4: JSONSchemaType): JSONSchemaType; declare const COERCE_ARRAY_ATTRIBUTE = "x-coerce-array"; declare const SCHEMA_REF_NAME = "$id"; declare const EMPTY_OBJECT_SCHEMA: JSONSchemaType>; declare const DATE_TYPE: JSONSchemaType; declare const OBJECTID_TYPE: JSONSchemaType; type OpenAPIMixinOptions = { /** * OpenAPI Tags to be applied to this mixin actions */ tags?: string[]; swaggerUI?: { version?: string; }; /** * Default kinds to be used when no kind is specified in the service or action */ defaultKinds?: string[]; /** * Additional options to be set on actions generated by this mixin. */ actionOptions?: CustomActionSchema; /** * Gives the list of security schemes to apply for a specific action. */ getSecuritySchemes?: (action: Alias) => string[] | undefined | false; }; declare function OpenAPIMixin(options: OpenAPIMixinOptions): PartialCustomServiceSchema<{ openapi: { openapi: string; info: { description: string; version: string; title: string; }; paths: {}; components: { responses: { ServerError: { description: string; content: { 'application/json': { schema: JSONSchemaType>; }; }; }; UnauthorizedError: { description: string; content: { 'application/json': { schema: JSONSchemaType>; }; }; }; FileNotExist: { description: string; content: { 'application/json': { schema: JSONSchemaType>; }; }; }; FileTooBig: { description: string; content: { 'application/json': { schema: JSONSchemaType>; }; }; }; ValidationError: { description: string; content: { 'application/json': { schema: JSONSchemaType>; }; }; }; }; schemas: { OpenAPIModel: { type: string; properties: { openapi: { example: string; type: string; description: string; }; info: { type: string; properties: { description: { type: string; }; }; }; tags: { type: string; items: { type: string; }; }; }; required: string[]; }; }; }; }; }, { matchesKind(openAPINames: string[] | null | undefined, kind: string | undefined): boolean; /** * Generate the OpenAPI schema for the specified kind. */ generateSchema(ctx: Context, kind?: string): Promise; }, unknown>; /** * This class walks through a JSON schema and extracts all the refs. * When a ref is found, it calls the onNewRef child method, and replace the schema with the ref. */ declare abstract class RefExtractor { private refs; protected meta: Record; /** * Allows to translate the ref name to a new ref name. * The walk method will use the response to decide if a ref was already extracted or not. */ protected abstract refReplacer(ref: string): string; /** * Called when a new ref is found. Allows to store the ref in a map or do something else. */ protected abstract onNewRef(originalRef: string, schema: SomeJSONSchema): unknown; protected onError(message: string, other?: Record): void; setMeta(meta: Record): void; extract(schemaToExtract: SomeJSONSchema, initialRef?: string | undefined, skipRoot?: boolean): SomeJSONSchema; } declare class OpenAPIExtractor extends RefExtractor { private readonly doc; constructor(doc: Document); refReplacer(ref: string): string; onNewRef(originalRef: string, schema: SomeJSONSchema): void; } type OpenAPIResponses = SchemaObject> | z.ZodType; declare function createOpenAPIResponses(model: OpenAPIResponses, description?: string): OperationObject; /** * Convert a zod schema to a JSON Schema with an OpenAPI spec (for refs). * * We always take the input version of a Zod schema, before transforms. * It means that we don't support inputs not JSON schemas compatible, including dates, objectIds. * For this, you should use helpers provided by this package. */ declare function zodToOpenAPISchema(schema: ZodType, extractor: OpenAPIExtractor): SchemaObject | ReferenceObject; declare const zodDate: z.ZodPipe, z.ZodDate>; declare const zodObjectId: z.ZodPipe, z.ZodCustom>; declare function zodCoerceArray(element: T, params?: Parameters[1]): z.ZodPipe, z.ZodArray>; declare function isZodSchema(schema: unknown, type?: S['type']): schema is S; declare class AjvExtractor extends RefExtractor { private readonly ajv; constructor(ajv: Ajv2019); protected refReplacer(ref: string): string; protected onNewRef(originalRef: string, schema: SomeJSONSchema): void; } /** * This function is a NO-OP and is only useful for Typescript types. * Using Generic arguments allows TS to infer types directly from the object * passed as input. * * For the wrapMixin fn, it will return the exact type of the object passed * in order to generate smart typings for services using the mixin. * * In case of a mixin using options (a function that will return the mixin), * for types to work, you must NOT specify the return type and let TS infer * the return type. * * For now, only methods are typed. */ declare function wrapMixin(svc: PartialCustomServiceSchema): typeof svc; /** * In order to let TS emit types for inferred services, we return our own * type that extend the original one. * More on why: https://github.com/microsoft/TypeScript/pull/58176#issuecomment-2052698294 */ type _InferredServiceSchema = ServiceSchema; /** * This function is a NO-OP and is only useful for Typescript types. * Using Generic arguments allows TS to infer types directly from the object * passed as input. * * For the wrapService fn, it will return a moleculer ServiceSchema that will stripe * out every smart typing of methods. This should never be used inside a mixin. */ declare function wrapService(svc: CustomServiceSchema): _InferredServiceSchema; /** * This class replace the default Service class in Moleculer to: * - Replace the params of actions with functions that return the params in * order to prevent moleculer from merging them. */ declare class ServiceFactory extends Service { constructor(broker: ServiceBroker, schema?: ServiceSchema); } declare function createServiceBroker(opts?: BrokerOptions): ServiceBroker; type LabelValue = string; type Operator = 'in' | 'notin' | 'exists' | 'doesnotexists'; type Rule = Op extends 'in' | 'notin' ? { key: string; operator: Op; values: LabelValue[]; } : { key: string; operator: Op; }; type Selector = { matchLabels?: Record; matchExpressions: Rule[]; }; type ServiceMetadata = Record | undefined; declare function isServiceSelected(metadata: ServiceMetadata, selector: Partial): boolean; declare function getMetadataFromService(svc: Partial): ServiceMetadata; type HealthCheckOptions = { port: number; startDebounce: number; readiness: { path: string; }; liveness: { path: string; }; }; /** * Inspired from https://gist.github.com/icebob/c717ae22002b9ecaa4b253a67952da3a */ declare function HealthCheckMiddleware(_opts: Partial): Middleware; /** * Create a Pino logger with multiple customization by default (can be overridden): * - A more open `logMethod` function that allows mixed string/object arguments * - Add hostname as base prop * - Enable pino-pretty on TTY terminals (with some basic http support) * - Some default redaction of paths related to req&res props */ declare function createLogger(opts?: CreateLoggerOptions): Logger; /** * Create moleculer logger config. * This returns a Pino config with a couple of customization: * - Trace ID and Span ID is automatically added to the ctx.logger (only with this package's ContextFactory) */ declare function createLoggerConfig(opts?: MoleculerLoggerConfigOptions): LoggerConfig; type NewrelicTraceExporterOptions = { logger?: Logger$1; safetyTags?: boolean; /** * Base URL for NewRelic server. */ baseURL?: string; /** * Maximum number of spans to be sent in one time. */ batchSize?: number; /** * NewRelic Insert API Key. */ insertKey?: string; /** * Batch send time interval in seconds. */ interval?: number; /** * Default span tags. */ defaultTags?: Record | ((tracer?: unknown) => Record); }; /** * >>> Hard copy of the moleculer NewRelic provider. It didn't handle errors correctly * * Trace Exporter for NewRelic using Zipkin data. * * NewRelic zipkin tracer: https://docs.newrelic.com/docs/understand-dependencies/distributed-tracing/trace-api/report-zipkin-format-traces-trace-api * API v2: https://zipkin.io/zipkin-api/#/ */ declare class NewrelicTraceExporter extends TracerExporters.Base { private readonly opts; private queue; private timer; private defaultTags; constructor(opts: NewrelicTraceExporterOptions); /** * Initialize Trace Exporter. */ init(tracer: Tracer): void; /** * Stop Trace exporter */ stop(): Promise; /** * Span is finished. */ spanFinished(span: Span): void; /** * Flush tracing data to NewRelic Zipkin api endpoint */ flush(): Promise; /** * Generate tracing data for NewRelic */ generateTracingData(): unknown[]; /** * Create NewRelic v1 payload */ makePayload(span: Span): unknown; } type DefaultTags = Record | ((registry: MetricRegistry) => Record); type NewrelicMetricsOptions = MetricReporters.Base.MetricReporterOptions & { /** * Base URL for NewRelic server. */ baseURL?: string; /** * NewRelic Insert API Key */ insertKey?: string; /** * Batch send time interval in seconds. */ interval?: number; /** * Default tags to be added to all metrics. */ defaultTags?: DefaultTags; }; /** * NewRelic metrics reporter. * * NewRelic API: https://docs.newrelic.com/docs/data-apis/understand-data/metric-data/metric-data-type/ */ declare class NewrelicMetricsReporter extends MetricReporters.Base { private readonly opts; private timer; private defaultTags; constructor(opts: NewrelicMetricsOptions); /** * Initialize Trace Exporter. */ init(registry: MetricRegistry): void; /** * Stop Trace exporter */ stop(): Promise; /** * Flush tracing data to NewRelic Zipkin api endpoint */ flush(): Promise; /** * Generate metrics data for NewRelic */ generateMetricsPayload(): unknown[]; } export { AjvExtractor, Alias, COERCE_ARRAY_ATTRIBUTE, CustomActionSchema, CustomServiceSchema, DATE_TYPE, Document, EMPTY_OBJECT_SCHEMA, HealthCheckMiddleware, JSONSchemaType, NewrelicMetricsReporter, NewrelicTraceExporter, OBJECTID_TYPE, OpenAPIExtractor, OpenAPIMixin, OperationObject, PartialCustomServiceSchema, RefExtractor, ReferenceObject, SCHEMA_REF_NAME, SchemaObject, ServiceFactory, SomeJSONSchema, addFieldsToSchema, composeSchemas, createLogger, createLoggerConfig, createOpenAPIResponses, createServiceBroker, getMetadataFromService, isServiceSelected, isZodSchema, omitFields, optionalExceptFields, optionalFields, pickFields, toPartialSchema, wrapMixin, wrapService, zodCoerceArray, zodDate, zodObjectId, zodToOpenAPISchema }; export type { OpenAPIMixinOptions, OpenAPIResponses, Selector, _InferredServiceSchema };