@buka/nestjs-kit 3.0.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/mikro-orm/models/base-entity.ts","../src/mikro-orm/models/timestamped-entity.ts","../src/mikro-orm/decorators/entity-property.decorator.ts","../src/mikro-orm/decorators/api-entity-property.decorator.ts","../src/mikro-orm/decorators/api-scalar-entity-property.decorator.ts","../src/decorators/nested-property.decorator.ts","../src/decorators/model/model.register.ts","../src/decorators/model/model.decorator.ts","../src/exceptions/exceptions.ts","../src/exceptions/type-exception.ts","../src/decorators/model/property.decorator.ts","../src/decorators/model/relation.decorator.ts","../src/decorators/model/nested.decorator.ts","../src/decorators/model/list.decorator.ts","../src/decorators/reference-property.decorator.ts","../src/decorators/class-validator/has-any-key.ts","../src/decorators/class-validator/match-json-schema.ts","../src/decorators/page-query.ts","../src/pipes/page-query-validation.pipe.ts","../src/utils/logger.ts","../src/utils/nestjs-swagger-utils.ts","../src/utils/mikro-orm-utils.ts","../src/mikro-orm/converters/entity-ref-type/entity-ref-type.ts","../src/mikro-orm/converters/entity-dto-type/entity-dto-type.ts","../src/mikro-orm/decorators/entity-enum.decorator.ts","../src/mikro-orm/decorators/entity-transient.decorator.ts","../src/mikro-orm/decorators/entity-one-to-one.decorator.ts","../src/mikro-orm/decorators/entity-one-to-many.decorator.ts","../src/mikro-orm/decorators/entity-many-to-one.decorator.ts","../src/mikro-orm/decorators/entity-many-to-many.decorator.ts","../src/mikro-orm/database.config.ts","../src/swagger/is-reference-object.ts","../src/swagger/deep-dereference.ts","../src/swagger/for-each-parameter.ts","../src/swagger/deep-objectify-queries.ts","../src/pipes/validation.pipe.ts","../src/converters/filter-query-type/filter-query-type.ts","../src/utils/class-validator-utils.ts","../src/utils/class-transformer-utils.ts","../src/converters/filter-query-type/decorators/filter-query-operators.decorator.ts","../src/converters/filter-query-type/utils/get-collection-operators.ts","../src/converters/filter-query-type/utils/get-property-operators.ts","../src/converters/filter-query-type/utils/swagger-metadata-to-json-schema.ts","../src/converters/filter-query-type/get-filter-query-schema.ts","../src/converters/pick-type/pick-type.ts","../src/converters/omit-type/omit-type.ts","../src/converters/partial-type/partial-type.ts","../src/converters/order-query-type/get-order-query-schema.ts","../src/converters/order-query-type/order-query-type.ts","../src/ro/offset-pagination.ro.ts","../src/ro/cursor-pagination.ro.ts","../src/converters/list-response-body-type/list-response-body-type.ts","../src/converters/response-body-type/response-body-type.ts","../src/models/offset-pagination.ts","../src/models/cursor-pagination.ts","../src/models/slice.ts"],"sourcesContent":["import { BigIntType, Config, DefineConfig, PrimaryKey, PrimaryKeyProp } from '@mikro-orm/core'\nimport { ApiProperty } from '@nestjs/swagger'\nimport { IsNumberString } from 'class-validator'\nimport { TimestampedEntity } from './timestamped-entity.js'\n\n\nexport abstract class BaseEntity<Optional = never> extends TimestampedEntity<Optional> {\n // [Config]?: DefineConfig<{ forceObject: true }>;\n [PrimaryKeyProp]?: 'id'\n\n @ApiProperty({\n type: 'string',\n description: 'PK',\n example: '1',\n required: true,\n })\n @PrimaryKey({\n type: new BigIntType('string'),\n comment: '主键',\n })\n @IsNumberString()\n id!: string\n}\n","import { Config, DefineConfig, OptionalProps } from '@mikro-orm/core'\nimport { EntityProperty } from '../decorators/entity-property.decorator'\n\n\nexport abstract class TimestampedEntity<Optional = never> {\n [Config]?: DefineConfig<{ forceObject: true }>;\n [OptionalProps]?: 'createdAt' | 'updatedAt' | Optional\n\n @EntityProperty({\n type: 'datetime',\n onCreate: () => new Date(),\n defaultRaw: 'CURRENT_TIMESTAMP',\n comment: '创建时间',\n })\n createdAt: Date = new Date()\n\n @EntityProperty({\n type: 'datetime',\n onUpdate: () => new Date(),\n defaultRaw: 'CURRENT_TIMESTAMP',\n comment: '更新时间',\n })\n updatedAt: Date = new Date()\n}\n","import { Property as OrmProperty, PropertyOptions } from '@mikro-orm/core'\nimport { ApiPropertyOptions } from '@nestjs/swagger'\nimport { ApiEntityProperty } from './api-entity-property.decorator'\nimport { ColumnTypeRequired } from '../types/column-type-required'\n\n\nexport function EntityProperty<T extends object>(\n options?: PropertyOptions<T> & Pick<ApiPropertyOptions, 'example'> & ColumnTypeRequired<T>,\n): PropertyDecorator {\n return (target, propertyKey) => {\n if (typeof propertyKey !== 'string') throw new TypeError('@EntityProperty() can only be used on string property')\n\n OrmProperty(options)(target, propertyKey)\n ApiEntityProperty({ example: options?.example })(target, propertyKey)\n }\n}\n","import { ApiHideProperty, getSchemaPath } from '@nestjs/swagger'\nimport { EntityProperty, MetadataStorage, ReferenceKind } from '@mikro-orm/core'\nimport { ApiScalarEntityProperty } from './api-scalar-entity-property.decorator'\nimport { EntityRefType } from '../converters/entity-ref-type/entity-ref-type'\nimport { NestedProperty, Property, Relation } from '~/decorators'\nimport { Type } from '@nestjs/common'\n\n\ninterface ApiEntityPropertyOptions {\n example?: any\n enumName?: string\n}\n\nexport function ApiEntityProperty<T extends object>(options?: ApiEntityPropertyOptions): PropertyDecorator {\n return (target, propertyKey) => {\n const meta = MetadataStorage.getMetadataFromDecorator(target.constructor as T)\n const prop = meta.properties[propertyKey] as EntityProperty<T> | undefined\n if (!prop) return\n\n if (prop.hidden === true) {\n ApiHideProperty()(target, propertyKey)\n return\n }\n\n if (prop.kind === ReferenceKind.EMBEDDED) {\n return\n }\n\n if (prop.kind === ReferenceKind.SCALAR) {\n ApiScalarEntityProperty({\n meta: prop,\n schema: options,\n })(target, propertyKey)\n return\n }\n\n const getType = (): Type => {\n const ent = prop.entity()\n if (prop.eager === true) return ent as Type\n\n if (typeof ent === 'function') {\n return EntityRefType(ent as any)\n }\n\n return Object\n }\n\n if (prop.kind === ReferenceKind.ONE_TO_ONE || prop.kind === ReferenceKind.MANY_TO_ONE) {\n Property({\n type: () => getType(),\n relation: {\n kind: prop.kind,\n type: () => getType(),\n },\n schema: {\n description: prop.comment,\n required: !prop.nullable,\n },\n })(target, propertyKey)\n\n return\n }\n\n if (prop.kind === ReferenceKind.ONE_TO_MANY || prop.kind === ReferenceKind.MANY_TO_MANY) {\n NestedProperty(\n () => getType(),\n {\n each: true,\n optional: prop.nullable,\n schema: {\n description: prop.comment,\n type: 'array',\n items: {\n type: getSchemaPath(() => getType()),\n },\n },\n },\n )(target, propertyKey)\n\n Relation({\n kind: prop.kind,\n type: () => getType(),\n })(target, propertyKey)\n return\n }\n }\n}\n\n","import { BigIntType, EntityProperty } from '@mikro-orm/core'\nimport { applyDecorators } from '@nestjs/common'\nimport { IsBoolean, IsCurrency, IsInt, IsISO8601, IsNumber, IsString, MaxLength, MinLength } from 'class-validator'\nimport { Property } from '~/decorators'\nimport { logger } from '~/utils/logger'\n\n\ninterface ApiScalarEntityPropertyOptions {\n meta: EntityProperty\n unverified?: boolean\n schema?: {\n example?: any\n enumName?: string\n }\n}\n\nexport function ApiScalarEntityProperty(options: ApiScalarEntityPropertyOptions): PropertyDecorator {\n const { meta } = options\n\n if (typeof meta['columnType'] === 'string') {\n const columnType = meta['columnType'].toLowerCase()\n\n if (columnType.startsWith('varchar')) {\n const length = Number(meta['columnType'].match(/\\d+/)?.[0])\n return VarcharProperty(length, options)\n }\n\n if (columnType.startsWith('char')) {\n const length = Number(meta['columnType'].match(/\\d+/)?.[0])\n return CharProperty(length, options)\n }\n\n if (columnType === 'text') return TextProperty(options)\n if (columnType === 'money') return MoneyProperty(options)\n if (columnType.startsWith('int')) return IntProperty(options)\n if (columnType.startsWith('smallint')) return IntProperty(options)\n if (columnType.startsWith('tinyint')) return TinyintProperty(options)\n if (columnType.startsWith('double')) return DoubleProperty(options)\n if (columnType.startsWith('decimal') || columnType.startsWith('numeric')) return DecimalProperty(options)\n if (columnType === 'datetime') return DatetimeProperty(options)\n }\n\n if (meta.type === 'varchar') return VarcharProperty(meta.length, options)\n if (meta.type === 'char') return CharProperty(meta.length, options)\n if (meta.type === 'text') return TextProperty(options)\n if (meta.type === 'money') return MoneyProperty(options)\n if (meta.type === 'int') return IntProperty(options)\n if (meta.type === 'smallint') return IntProperty(options)\n if (meta.type === 'tinyint') return TinyintProperty(options)\n if (meta.type === 'double') return DoubleProperty(options)\n if (meta.type === 'decimal' || meta.type === 'numeric') return DecimalProperty(options)\n if (meta.type === 'datetime') return DatetimeProperty(options)\n if (meta.type === 'boolean' || meta.type === 'bool') return BooleanProperty(options)\n if (meta.type === 'bigint') return BigIntProperty(options)\n if ((meta.type as any) instanceof BigIntType) return BigIntProperty(options)\n\n logger.warn(`No decorator founded for type ${meta.type} for property ${meta.name}.`)\n\n return () => {}\n}\n\nfunction getEnumOptions(options: ApiScalarEntityPropertyOptions): { enum?: (string | number)[]; enumName?: string } {\n if (options.meta.enum !== true) return {}\n\n const items = options.meta.items as ((() => (string | number)[]) | (string | number)[])\n const values = typeof items === 'function' ? items() : items\n const enumName = options.schema?.enumName\n\n return {\n enum: values,\n enumName,\n }\n}\n\n\nfunction VarcharProperty(length: number | undefined, options: ApiScalarEntityPropertyOptions): PropertyDecorator {\n const decorators: PropertyDecorator[] = []\n\n if (!options.unverified) {\n decorators.push(IsString())\n if (length) decorators.push(MaxLength(length))\n }\n\n decorators.push(Property({\n type: () => String,\n optional: options.meta.nullable,\n schema: {\n type: 'string',\n maxLength: length,\n ...(options.schema || {}),\n ...getEnumOptions(options),\n required: !options.meta.nullable,\n description: options.meta.comment,\n },\n }))\n\n return applyDecorators(...decorators)\n}\n\nfunction CharProperty(length: number | undefined, options: ApiScalarEntityPropertyOptions): PropertyDecorator {\n const decorators: PropertyDecorator[] = []\n\n if (!options.unverified) {\n decorators.push(IsString())\n if (length) decorators.push(MaxLength(length), MinLength(length))\n }\n\n decorators.push(Property({\n type: () => String,\n optional: options.meta.nullable,\n schema: {\n type: 'string',\n maxLength: length,\n minimum: length,\n ...(options.schema || {}),\n ...getEnumOptions(options),\n required: !options.meta.nullable,\n description: options.meta.comment,\n },\n }))\n\n return applyDecorators(...decorators)\n}\n\nfunction TextProperty(options: ApiScalarEntityPropertyOptions): PropertyDecorator {\n const decorators: PropertyDecorator[] = []\n if (!options.unverified) {\n decorators.push(IsString())\n }\n\n decorators.push(Property({\n type: () => String,\n optional: options.meta.nullable,\n schema: {\n type: 'string',\n ...(options.schema || {}),\n ...getEnumOptions(options),\n required: !options.meta.nullable,\n description: options.meta.comment,\n },\n }))\n\n return applyDecorators(...decorators)\n}\n\n\nexport function MoneyProperty(options: ApiScalarEntityPropertyOptions): PropertyDecorator {\n const decorators: PropertyDecorator[] = []\n\n if (!options.unverified) {\n decorators.push(IsCurrency({ symbol: '' }))\n }\n\n decorators.push(Property({\n type: () => String,\n optional: options.meta.nullable,\n schema: {\n type: 'string',\n format: 'money',\n ...(options.schema || {}),\n required: !options.meta.nullable,\n description: options.meta.comment,\n },\n }))\n\n return applyDecorators(...decorators)\n}\n\nexport function BigIntProperty(options: ApiScalarEntityPropertyOptions): PropertyDecorator {\n const { meta } = options\n\n let mode: 'string' | 'number'\n if (meta.type === 'bigint') {\n mode = 'string'\n } else if ((meta.type as any) instanceof BigIntType) {\n const metaType = meta.type as unknown as BigIntType\n mode = (metaType.mode as any) === 'string' ? 'string' : 'number'\n } else {\n throw new Error(`Unsupported type for BigIntProperty: ${meta.type}`)\n }\n\n const decorators: PropertyDecorator[] = []\n\n if (mode === 'string') {\n if (!options.unverified) {\n decorators.push(IsString())\n }\n\n decorators.push(Property({\n type: () => String,\n optional: options.meta.nullable,\n schema: {\n type: 'string',\n ...(options.schema || {}),\n ...getEnumOptions(options),\n required: !options.meta.nullable,\n description: options.meta.comment,\n },\n }))\n } else {\n if (!options.unverified) {\n decorators.push(IsInt())\n }\n\n decorators.push(Property({\n type: () => Number,\n optional: options.meta.nullable,\n schema: {\n type: 'integer',\n format: 'int64',\n ...(options.schema || {}),\n ...getEnumOptions(options),\n required: !options.meta.nullable,\n description: options.meta.comment,\n },\n }))\n }\n\n\n return applyDecorators(...decorators)\n}\n\nexport function IntProperty(options: ApiScalarEntityPropertyOptions): PropertyDecorator {\n const decorators: PropertyDecorator[] = []\n\n if (!options.unverified) {\n decorators.push(IsInt())\n // if (options.meta.nullable) decorators.push(IsOptional())\n }\n\n decorators.push(Property({\n type: () => Number,\n optional: options.meta.nullable,\n schema: {\n type: 'integer',\n minimum: options.meta.unsigned ? 0 : -2147483647,\n maximum: options.meta.unsigned ? 4294967295 : 2147483647,\n ...(options.schema || {}),\n ...getEnumOptions(options),\n required: !options.meta.nullable,\n description: options.meta.comment,\n },\n }))\n\n return applyDecorators(...decorators)\n}\n\nexport function TinyintProperty(options: ApiScalarEntityPropertyOptions): PropertyDecorator {\n const decorators: PropertyDecorator[] = []\n\n if (!options.unverified) {\n decorators.push(IsInt())\n // if (options.meta.nullable) decorators.push(IsOptional())\n }\n\n decorators.push(Property({\n type: () => Number,\n optional: options.meta.nullable,\n schema: {\n type: 'integer',\n minimum: options.meta.unsigned ? 0 : -128,\n maximum: options.meta.unsigned ? 255 : 127,\n ...(options.schema || {}),\n ...getEnumOptions(options),\n required: !options.meta.nullable,\n description: options.meta.comment,\n },\n }))\n\n return applyDecorators(...decorators)\n}\n\nexport function DoubleProperty(options: ApiScalarEntityPropertyOptions): PropertyDecorator {\n const decorators: PropertyDecorator[] = []\n\n if (!options.unverified) {\n decorators.push(IsNumber())\n // if (options.meta.nullable) decorators.push(IsOptional())\n }\n\n decorators.push(Property({\n type: () => Number,\n optional: options.meta.nullable,\n schema: {\n type: 'number',\n format: 'double',\n minimum: options.meta.unsigned ? 0 : undefined,\n ...(options.schema || {}),\n ...getEnumOptions(options),\n required: !options.meta.nullable,\n description: options.meta.comment,\n },\n }))\n\n return applyDecorators(...decorators)\n}\n\nexport function DecimalProperty(options: ApiScalarEntityPropertyOptions): PropertyDecorator {\n const decorators: PropertyDecorator[] = []\n\n if (!options.unverified) {\n if (options.meta.scale) decorators.push(IsNumber({ maxDecimalPlaces: options.meta.scale }))\n else decorators.push(IsNumber())\n\n // if (options.meta.nullable) decorators.push(IsOptional())\n }\n\n decorators.push(Property({\n type: () => Number,\n optional: options.meta.nullable,\n schema: {\n type: 'number',\n format: 'double',\n minimum: options.meta.unsigned ? 0 : undefined,\n ...(options.schema || {}),\n ...getEnumOptions(options),\n required: !options.meta.nullable,\n description: options.meta.comment,\n },\n }))\n\n return applyDecorators(...decorators)\n}\n\nexport function DatetimeProperty(options: ApiScalarEntityPropertyOptions): PropertyDecorator {\n const decorators: PropertyDecorator[] = []\n\n if (!options.unverified) {\n decorators.push(IsISO8601())\n // if (options.meta.nullable) decorators.push(IsOptional())\n }\n\n decorators.push(Property({\n type: () => Date,\n optional: options.meta.nullable,\n schema: {\n type: 'string',\n format: 'date-time',\n ...(options.schema || {}),\n required: !options.meta.nullable,\n description: options.meta.comment,\n },\n }))\n\n return applyDecorators(...decorators)\n}\n\nexport function BooleanProperty(options: ApiScalarEntityPropertyOptions): PropertyDecorator {\n const decorators: PropertyDecorator[] = []\n\n if (!options.unverified) {\n decorators.push(IsBoolean())\n // if (options.meta.nullable) decorators.push(IsOptional())\n }\n\n decorators.push(Property({\n type: () => Boolean,\n optional: options.meta.nullable,\n schema: {\n type: 'boolean',\n ...(options.schema || {}),\n required: !options.meta.nullable,\n description: options.meta.comment,\n },\n }))\n\n return applyDecorators(...decorators)\n}\n","import * as R from 'ramda'\nimport { applyDecorators } from '@nestjs/common'\nimport { ApiPropertyOptions } from '@nestjs/swagger'\nimport { Type as ClassType } from 'class-transformer'\nimport { IsNotEmpty, ValidateNested } from 'class-validator'\nimport { Nested, PropertyMetadata } from './model'\nimport { List } from './model/list.decorator'\nimport { Class } from 'type-fest'\n\ninterface NestedPropertiesOptions extends Pick<PropertyMetadata, 'relation' | 'optional' | 'schema'> {\n each?: boolean\n}\n\nexport function NestedProperty(type: () => Class<object>, options: NestedPropertiesOptions = {}): PropertyDecorator {\n const decorators = [\n ValidateNested({ each: !!options.each }),\n ClassType(type),\n ]\n\n /**\n * 这里不能写成 ({ type: type })\n * 否则 swagger 会无法识别到正确的类型\n * 因为 @nestjs/swagger 中通过 `fn.name === 'type'` 来判断 type 是函数还是对象\n */\n const schema: ApiPropertyOptions = options.schema || { type: () => type() }\n const propertyMetadata = R.pick(['relation', 'optional'], options)\n\n if (options.each) {\n decorators.push(List({ type, schema, ...propertyMetadata }))\n } else {\n decorators.push(Nested({ type, schema, ...propertyMetadata }))\n }\n\n if (!options.optional) {\n decorators.push(...[\n // 如果不添加 IsNotEmpty,ValidateNested 在没有 IsOptional 的情况下也会允许 undefined 值通过验证\n // https://github.com/typestack/class-validator/issues/717\n IsNotEmpty({ each: options.each, message: '$property is required' }),\n ])\n }\n\n return applyDecorators(...decorators)\n}\n","import * as R from 'ramda'\nimport { Class } from 'type-fest'\nimport { ModelKind, ModelMetadata } from './model.decorator'\nimport { PropertyMetadata } from './property.decorator'\n\n\nconst MODEL_METADATA_KEY = 'buka:model'\nconst PROPERTY_METADATA_KEY = 'buka:property'\n\nexport class ModelRegister {\n static setModel(target: Class<any>, metadata: ModelMetadata): void {\n Reflect.defineMetadata(MODEL_METADATA_KEY, metadata, target)\n }\n\n static getModel(target: Class<any>): ModelMetadata | undefined {\n return Reflect.getMetadata(MODEL_METADATA_KEY, target) as ModelMetadata | undefined\n }\n\n static setProperty(target: Class<any>, propertyName: string | symbol, metadata: PropertyMetadata): void {\n Reflect.defineMetadata(PROPERTY_METADATA_KEY, metadata, target.prototype, propertyName)\n }\n\n static getProperty(target: Class<any>, propertyName: string | symbol): PropertyMetadata | undefined {\n return Reflect.getMetadata(PROPERTY_METADATA_KEY, target.prototype, propertyName) as PropertyMetadata | undefined\n }\n\n static copyProperty(source: Class<any>, target: Class<any>, propertyName: string | symbol): void {\n const metadata = this.getProperty(source, propertyName)\n if (metadata) {\n const modelMetadata = this.addModel(target)\n\n if (!modelMetadata.propertyKeys.includes(propertyName)) {\n modelMetadata.propertyKeys.push(propertyName)\n }\n\n this.setProperty(target, propertyName, metadata)\n }\n }\n\n static addModel(target: Class<any>, kind: ModelKind = 'model'): ModelMetadata {\n const metadata = this.getModel(target)\n\n if (!metadata) {\n const metadata: ModelMetadata = {\n kind,\n propertyKeys: [],\n }\n\n this.setModel(target, metadata)\n return metadata\n }\n\n return metadata\n }\n\n static addProperty(target: Class<any>, propertyName: string | symbol, metadata: Partial<PropertyMetadata> = {}): void {\n const modelMetadata = this.addModel(target)\n\n if (!modelMetadata.propertyKeys.includes(propertyName)) {\n modelMetadata.propertyKeys.push(propertyName)\n }\n\n const propertyMetadata: PropertyMetadata = {\n type() {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return Reflect.getMetadata('design:type', target.prototype, propertyName)\n },\n ...(this.getProperty(target, propertyName) || {}),\n ...R.omit(['schema'], metadata),\n }\n\n this.setProperty(target, propertyName, propertyMetadata)\n }\n\n /**\n * 判断是否为已注册的 Model\n *\n * @example\n * ```typescript\n * const isModel = ModelRegister.isModel(Class.prototype)\n * ```\n */\n static isModel(target: Class<any>): boolean {\n return !!this.getModel(target)\n }\n\n /**\n * 获取 Model 的所有属性\n *\n * @example\n * ```typescript\n * const properties = ModelRegister.getProperties(Class.prototype)\n * ```\n */\n static getModelPropertyKeys(target: Class<any>): (string | symbol)[] {\n const metadata = this.getModel(target)\n return metadata ? metadata.propertyKeys : []\n }\n\n static getProperties(target: Class<any>): PropertyMetadata[] {\n const propertyKeys = this.getModelPropertyKeys(target)\n\n return propertyKeys\n .map((propertyKey) => this.getProperty(target, propertyKey))\n .filter((property): property is PropertyMetadata => !!property)\n }\n}\n","import { Class } from 'type-fest'\nimport { ModelRegister } from './model.register'\n\n\nexport type ModelKind = 'model' | 'entity' | 'dto' | 'bo' | 'ro'\n\nexport interface ModelMetadata {\n kind: ModelKind\n propertyKeys: (string | symbol)[]\n}\n\nexport function Model(): ClassDecorator {\n return (target: Function) => {\n ModelRegister.addModel(target as Class<any>)\n }\n}\n","import { CustomError } from 'ts-custom-error'\n\n\nexport class Exception extends CustomError {\n constructor(message: string) {\n super(`[@buka/nestjs] ${message}`)\n\n Object.defineProperty(this, 'name', { value: 'Exception' })\n }\n}\n","import { Exception } from './exceptions'\n\nexport class TypeException extends Exception {\n constructor(message: string) {\n super(message)\n Object.defineProperty(this, 'name', { value: 'TypeException' })\n }\n}\n","import { TypeException } from '~/exceptions'\nimport { ModelRegister } from './model.register'\nimport { Class } from 'type-fest'\nimport { RelationMetadata } from './relation.decorator'\nimport { IsOptional } from 'class-validator'\nimport { ApiPropertyOptions, ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'\n\n\nexport type PropertyKind = 'nested' | 'dictionary' | 'list'\n\nexport interface PropertyMetadata {\n kind?: PropertyKind\n optional?: boolean\n type: () => Function\n relation?: RelationMetadata\n schema?: ApiPropertyOptions\n}\n\n\nexport function Property(options?: Partial<PropertyMetadata>): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n if (!('constructor' in target)) {\n throw new TypeException('@Property decorator can only be applied to class properties.')\n }\n\n if (options?.optional) {\n IsOptional()(target, propertyKey)\n }\n\n if (options?.schema) {\n if (options?.optional) {\n ApiPropertyOptional(options.schema)(target, propertyKey)\n } else {\n ApiProperty(options.schema)(target, propertyKey)\n }\n }\n\n ModelRegister.addProperty(target.constructor as Class<any>, propertyKey, options)\n }\n}\n","import { Class } from 'type-fest'\nimport { ModelRegister } from './model.register'\n\nexport const RELATION_METADATA_KEY = 'buka:relation'\n\n\nexport type RelationKind = '1:1' | '1:m' | 'm:1' | 'm:n'\n\nexport interface RelationMetadata {\n kind: RelationKind\n type: () => Class<object>\n}\n\nexport function Relation(metadata: RelationMetadata): PropertyDecorator {\n return (target, propertyKey) => {\n ModelRegister.addProperty(target.constructor as Class<any>, propertyKey, { relation: metadata })\n }\n}\n","import { Property, PropertyMetadata } from './property.decorator'\n\ntype NestedOptions = Pick<PropertyMetadata, 'type' | 'optional' | 'schema' | 'relation'>\n\nexport function Nested(options: NestedOptions): PropertyDecorator {\n return (target, propertyKey) => {\n Property({\n kind: 'nested',\n ...options,\n })(target, propertyKey)\n }\n}\n","import { Property, PropertyMetadata } from './property.decorator'\n\n\ntype ListOptions = Pick<PropertyMetadata, 'optional' | 'type' | 'schema' | 'relation'>\n\nexport function List(options: ListOptions): PropertyDecorator {\n return (target, propertyKey) => {\n Property({\n kind: 'list',\n ...options,\n })(target, propertyKey)\n }\n}\n","import { applyDecorators } from '@nestjs/common'\nimport { Allow } from 'class-validator'\nimport { EntityRefType } from '~/mikro-orm'\nimport { Class } from 'type-fest'\nimport { NestedProperty } from './nested-property.decorator'\n\nexport const ReferencePropertiesMetadataKey = 'buka:reference-properties'\n\n\n/**\n *\n * @param entity MikroORM Entity\n */\nexport function ReferenceProperty(entity: () => Class<object>): PropertyDecorator {\n return applyDecorators(\n Allow(),\n NestedProperty(() => EntityRefType(entity()),\n {\n relation: {\n kind: '1:1',\n type: () => entity(),\n },\n },\n ),\n )\n}\n","import { registerDecorator, ValidationOptions } from 'class-validator'\n\n\nexport const HAS_ANY_KEY = 'hasAnyKey'\n\nexport function HasAnyKey(keys: readonly string[], validationOptions?: ValidationOptions) {\n return function (object: object, propertyName: string) {\n registerDecorator({\n name: HAS_ANY_KEY,\n target: object.constructor,\n propertyName: propertyName,\n constraints: [keys],\n options: validationOptions,\n validator: {\n validate(value: any) {\n if (typeof value !== 'object' || value === null) return false\n for (const key of keys) {\n if (key in value) return true\n }\n return false\n },\n defaultMessage() {\n return `$property must have at least one of the keys: ${keys.join(', ')}`\n },\n },\n })\n }\n}\n","import { registerDecorator, ValidationOptions, ValidationArguments } from 'class-validator'\nimport { validate } from 'jsonschema'\n\n\nexport const MATCH_JSON_SCHEMA = 'matchJsonSchema'\n\n\nexport function MatchJsonSchema(schema: any, validationOptions?: ValidationOptions) {\n return function (object: object, propertyName: string) {\n registerDecorator({\n name: MATCH_JSON_SCHEMA,\n target: object.constructor,\n propertyName: propertyName,\n constraints: [schema],\n options: validationOptions,\n validator: {\n validate(value: any, args: ValidationArguments) {\n const [schema] = args.constraints\n\n const results = validate(value, schema)\n return results.valid\n },\n defaultMessage({ value, constraints }: ValidationArguments) {\n return `${propertyName} must match the JSON schema`\n },\n },\n })\n }\n}\n\n","import { Query } from '@nestjs/common'\nimport { ApiQuery } from '@nestjs/swagger'\nimport { BukaPageQueryValidationPipe } from '~/pipes/page-query-validation.pipe'\n\n\nconst OffsetPageSchema = {\n type: 'object',\n properties: {\n limit: { type: 'number' },\n offset: { type: 'number' },\n },\n required: ['limit', 'offset'],\n}\n\nconst NextCursorPageSchema = {\n type: 'object',\n properties: {\n after: { type: 'string' },\n first: { type: 'number' },\n },\n required: ['after', 'first'],\n}\n\nconst PreviousCursorPageSchema = {\n type: 'object',\n properties: {\n before: { type: 'string' },\n last: { type: 'number' },\n },\n required: ['before', 'last'],\n}\n\n\nexport function PageQuery(mode?: 'cursor' | 'offset'): ParameterDecorator {\n return (target: object, propertyKey: string | symbol | undefined, parameterIndex: number) => {\n if (!propertyKey) {\n throw new Error('@PageQuery decorator can only be used on method parameters.')\n }\n\n const descriptor = Reflect.getOwnPropertyDescriptor(target, propertyKey)!\n\n if (mode === 'offset') {\n ApiQuery({\n name: 'page',\n required: true,\n schema: OffsetPageSchema,\n })(target, propertyKey, descriptor)\n } else if (mode === 'cursor') {\n ApiQuery({\n name: 'page',\n required: true,\n schema: {\n oneOf: [\n NextCursorPageSchema,\n PreviousCursorPageSchema,\n ],\n },\n })(target, propertyKey, descriptor)\n } else {\n ApiQuery({\n name: 'page',\n required: true,\n schema: {\n oneOf: [\n OffsetPageSchema,\n NextCursorPageSchema,\n PreviousCursorPageSchema,\n ],\n },\n })(target, propertyKey, descriptor)\n }\n\n Query(new BukaPageQueryValidationPipe({ mode }))(target, propertyKey, parameterIndex)\n }\n}\n\nexport function OptionalPageQuery(mode?: 'cursor' | 'offset'): ParameterDecorator {\n return (target: object, propertyKey: string | symbol | undefined, parameterIndex: number) => {\n if (!propertyKey) {\n throw new Error('@PageQuery decorator can only be used on method parameters.')\n }\n\n const descriptor = Reflect.getOwnPropertyDescriptor(target, propertyKey)!\n\n if (mode === 'offset') {\n ApiQuery({\n name: 'page',\n required: false,\n schema: OffsetPageSchema,\n })\n } else if (mode === 'cursor') {\n ApiQuery({\n name: 'page',\n required: false,\n schema: {\n oneOf: [\n NextCursorPageSchema,\n PreviousCursorPageSchema,\n ],\n },\n })(target, propertyKey, descriptor)\n } else {\n ApiQuery({\n name: 'page',\n required: false,\n schema: {\n oneOf: [\n OffsetPageSchema,\n NextCursorPageSchema,\n PreviousCursorPageSchema,\n ],\n },\n })(target, propertyKey, descriptor)\n }\n\n Query(new BukaPageQueryValidationPipe({ mode, optional: true }))(target, propertyKey, parameterIndex)\n }\n}\n","import { ArgumentMetadata, BadRequestException, Injectable, InternalServerErrorException, PipeTransform } from '@nestjs/common'\n\n\ninterface BukaPageQueryValidationPipeOptions {\n mode?: 'cursor' | 'offset'\n optional?: boolean\n}\n\nconst mixedOffsetAndCursorError = 'Invalid page query: cannot mix offset-based and cursor-based pagination parameters.'\nconst mixedNextAndLastCursorError = 'Invalid page query: cannot mix next and last cursor pagination parameters.'\n\n@Injectable()\nexport class BukaPageQueryValidationPipe implements PipeTransform {\n constructor(\n private readonly options: BukaPageQueryValidationPipeOptions = { optional: false },\n ) {}\n\n transform(value: any, metadata: ArgumentMetadata): any {\n if (metadata.type !== 'query') {\n throw new InternalServerErrorException('BukaPageQueryValidationPipe can only be used to validate query parameters.')\n }\n\n if (!value.page) {\n if (this.options.optional) {\n return value\n } else {\n throw new BadRequestException('Missing required query parameter: page')\n }\n }\n\n const mode = this.options.mode\n\n if ((!mode || mode === 'offset') && ('limit' in value.page || 'offset' in value.page)) {\n if ('after' in value.page || 'first' in value.page || 'before' in value.page || 'last' in value.page) {\n throw new BadRequestException(mixedOffsetAndCursorError)\n }\n\n const limit = parseInt(value.page.limit, 10)\n const offset = parseInt(value.page.offset, 10)\n\n if (isNaN(limit) || limit <= 0) {\n throw new BadRequestException('Invalid page query: limit must be a positive integer.')\n }\n\n if (isNaN(offset) || offset < 0) {\n throw new BadRequestException('Invalid page query: offset must be a non-negative integer.')\n }\n\n return { page: { limit, offset } }\n }\n\n if (!mode || mode === 'cursor') {\n if ('after' in value.page || 'first' in value.page) {\n if ('limit' in value.page || 'offset' in value.page) {\n throw new BadRequestException(mixedOffsetAndCursorError)\n }\n\n if ('before' in value.page || 'last' in value.page) {\n throw new BadRequestException(mixedNextAndLastCursorError)\n }\n\n const after = value.page.after\n const first = parseInt(value.page.first, 10)\n\n if (typeof after !== 'string') {\n throw new BadRequestException('Invalid page query: after must be a string.')\n }\n\n if (isNaN(first) || first <= 0) {\n throw new BadRequestException('Invalid page query: first must be a positive integer.')\n }\n\n return { page: { after, first } }\n }\n\n if ('before' in value.page || 'last' in value.page) {\n if ('limit' in value.page || 'offset' in value.page) {\n throw new BadRequestException(mixedOffsetAndCursorError)\n }\n\n if ('after' in value.page || 'first' in value.page) {\n throw new BadRequestException(mixedNextAndLastCursorError)\n }\n\n const before = value.page.before\n const last = parseInt(value.page.last, 10)\n\n if (typeof before !== 'string') {\n throw new BadRequestException('Invalid page query: before must be a string.')\n }\n\n if (isNaN(last) || last <= 0) {\n throw new BadRequestException('Invalid page query: last must be a positive integer.')\n }\n\n return { page: { before, last } }\n }\n }\n\n throw new BadRequestException('Invalid page query: missing pagination parameters.')\n }\n}\n","import { Logger } from '@nestjs/common'\n\nexport const logger = new Logger('@buka/nestjs-kits')\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport * as R from 'ramda'\nimport { ModelPropertiesAccessor } from '@nestjs/swagger/dist/services/model-properties-accessor'\nimport { DECORATORS } from '@nestjs/swagger/dist/constants'\nimport { SchemaObjectMetadata } from '@nestjs/swagger/dist/interfaces/schema-object-metadata.interface'\nimport { METADATA_FACTORY_NAME } from '@nestjs/swagger/dist/plugin/plugin-constants'\nimport { Type } from '@nestjs/common'\nimport { clonePluginMetadataFactory } from '@nestjs/swagger/dist/type-helpers/mapped-types.utils'\nimport { ApiProperty } from '@nestjs/swagger'\nimport { isFunction } from '@nestjs/common/utils/shared.utils'\nimport { isBuiltInType } from '@nestjs/swagger/dist/utils/is-built-in-type.util'\n\nexport { SchemaObjectMetadata } from '@nestjs/swagger/dist/interfaces/schema-object-metadata.interface'\n\n\nconst modelPropertiesAccessor = new ModelPropertiesAccessor()\n\n/**\n * 克隆 @nestjs/swagger Plugin 添加的元数据\n */\n// export const cloneSwaggerPluginMetadataFactory = clonePluginMetadataFactory\n\nexport function cloneMetadata(target: Function, source: Type<unknown>, keys: string[]): void {\n clonePluginMetadataFactory(\n target as Type<unknown>,\n source.prototype,\n (metadata: Record<string, any>) => R.pick(keys, metadata),\n )\n\n for (const propertyKey of keys) {\n const metadata = getMetadataOfDecorator(source, propertyKey)\n if (metadata) {\n ApiProperty(metadata)(target.prototype, propertyKey)\n }\n }\n}\n\n/**\n * 获取 @ApiProperty 添加的 Metadata\n */\nexport function getMetadataOfDecorator(classRef: Type<any>): Record<string, SchemaObjectMetadata>\nexport function getMetadataOfDecorator(classRef: Type<any>, propertyKey: string): SchemaObjectMetadata | undefined\nexport function getMetadataOfDecorator(classRef: Type<any>, propertyKey?: string): SchemaObjectMetadata | undefined | Record<string, SchemaObjectMetadata> {\n if (propertyKey) {\n return Reflect.getMetadata(DECORATORS.API_MODEL_PROPERTIES, classRef.prototype, propertyKey)\n }\n\n const props = modelPropertiesAccessor\n .getModelProperties(classRef.prototype)\n\n return R.fromPairs(\n props.map((prop) => [\n prop,\n Reflect.getMetadata(DECORATORS.API_MODEL_PROPERTIES, classRef.prototype, prop),\n ]),\n )\n}\n\n/**\n * 获取 @nestjs/swagger Plugin 添加的 Schema\n */\n\nfunction getMetadataOfPlugin(classRef: Type<any>): Record<string, SchemaObjectMetadata>\nfunction getMetadataOfPlugin(classRef: Type<any>, propertyKey: string): SchemaObjectMetadata | undefined\nfunction getMetadataOfPlugin(classRef: Type<any>, propertyKey?: string): SchemaObjectMetadata | undefined | Record<string, SchemaObjectMetadata> {\n const propsInPlugin = typeof classRef[METADATA_FACTORY_NAME] === 'function' ? classRef[METADATA_FACTORY_NAME]() : {}\n\n if (propertyKey) return propsInPlugin[propertyKey]\n return propsInPlugin\n}\n\n/**\n * Get all metadata of @ApiProperty() defined on the class.\n *\n * 可以利用这个函数,遍历 Dto/Entity 上定义的所有属性,而不需要去实例化一个对象\n */\nexport function getMetadata(classRef: Type<any>): Record<string, SchemaObjectMetadata>\nexport function getMetadata(classRef: Type<any>, propertyKey: string): SchemaObjectMetadata | undefined\nexport function getMetadata(classRef: Type<any>, propertyKey?: string): SchemaObjectMetadata | Record<string, SchemaObjectMetadata> {\n const propsInDecorator = getMetadataOfDecorator(classRef)\n const propsInPlugin = getMetadataOfPlugin(classRef)\n\n const metadataMap = R.mergeRight(propsInPlugin, propsInDecorator)\n if (propertyKey) return metadataMap[propertyKey]\n return metadataMap\n}\n\n/**\n * Set @ApiProperty() to all properties of the class.\n */\nexport function overridePluginMetadata(classRef: Type<any>, props: Record<string, SchemaObjectMetadata>): void {\n classRef[METADATA_FACTORY_NAME] = () => props\n}\n\n\nexport function getMetadataType(metadata: SchemaObjectMetadata): string | Function {\n if (isFunction(metadata.type) && metadata.type.name === 'type') {\n return getMetadataType((<any>metadata.type)())\n } else if (isFunction(metadata.type) && isBuiltInType(metadata.type)) {\n return metadata.type.name.toLowerCase()\n }\n\n return metadata.type as (string | Function)\n}\n\n/**\n * 判断 type 是否是 lazy type function\n */\nexport function isLazyTypeFunc(\n type: any,\n): type is { type: Function } & Function {\n return isFunction(type) && type.name == 'type'\n}\n","import * as R from 'ramda'\nimport { EntityMetadata, MetadataStorage, EntityProperty } from '@mikro-orm/core'\nimport { Type } from '@nestjs/common'\n\n\nexport function getMetadata<T>(classRef: Type<T>): EntityProperty<T>[] {\n const metadatas: EntityMetadata<T>[] = []\n\n let parent: any = classRef\n do {\n const meta = MetadataStorage.getMetadataFromDecorator(parent)\n if (meta instanceof EntityMetadata) metadatas.push(meta)\n parent = Object.getPrototypeOf(parent)\n } while (parent && parent !== Object.prototype)\n\n return R.unnest(metadatas.map((meta) => R.values(meta.properties)))\n}\n","\nimport { IEntityRef } from './types/index.js'\nimport * as SwaggerUtils from '~/utils/nestjs-swagger-utils'\nimport * as MikroOrmUtils from '~/utils/mikro-orm-utils'\nimport { inheritTransformationMetadata, inheritValidationMetadata } from '@nestjs/mapped-types'\nimport { Class } from 'type-fest'\n\n\nexport const EntityRefTypeClassMetadataPropertyKey = Symbol('EntityRefTypeClassMetadataPropertyKey')\n\nconst storage = new WeakMap<Class<object>, Class<IEntityRef<any>>>()\n\nexport function EntityRefType<T extends object>(classRef: Class<T>): Class<IEntityRef<T>> {\n if (storage.has(classRef)) {\n return storage.get(classRef)!\n }\n\n const properties = MikroOrmUtils.getMetadata(classRef)\n\n const primaryProperties: string[] = properties.filter((prop) => prop.primary)\n .map((prop) => prop.name)\n\n if (!primaryProperties.length) {\n throw new Error(`Cannot create EntityRefType for ${classRef.name} because it has no primary properties.`)\n }\n\n class EntityRefTypeClass {}\n\n EntityRefTypeClass[EntityRefTypeClassMetadataPropertyKey] = {}\n\n SwaggerUtils.cloneMetadata(EntityRefTypeClass, classRef, primaryProperties)\n inheritValidationMetadata(classRef, EntityRefTypeClass, (key) => primaryProperties.includes(key))\n inheritTransformationMetadata(classRef, EntityRefTypeClass, (key) => primaryProperties.includes(key))\n\n storage.set(classRef, EntityRefTypeClass as Class<IEntityRef<T>>)\n return EntityRefTypeClass as Class<IEntityRef<T>>\n}\n","import * as R from 'ramda'\nimport { Type } from '@nestjs/common'\nimport { inheritTransformationMetadata, inheritValidationMetadata } from '@nestjs/mapped-types'\nimport * as ApiPropertyUtils from '~/utils/nestjs-swagger-utils'\nimport { IEntityDto } from './types/entity-dto'\nimport * as MikroOrmUtils from '~/utils/mikro-orm-utils'\nimport { ModelRegister } from '~/decorators'\nimport { wrap } from '@mikro-orm/core'\nimport { Class } from 'type-fest'\n\n\nexport type IEntityDtoClass<T> = Class<IEntityDto<T>> & {\n from(entity: T): IEntityDto<T>\n}\n\nexport function EntityDtoType<T extends object>(entity: Class<T>): IEntityDtoClass<T> {\n const properties = MikroOrmUtils.getMetadata(entity)\n\n if (!properties.length) {\n throw new Error(`Cannot create EntityDtoType for ${entity.name} because it isn't an MikroORM Entity.`)\n }\n\n // const keys = R.pluck('name', properties.filter((prop) => !prop.hidden))\n const keys = properties\n .filter((prop) => {\n if (prop.hidden) return false\n if (prop.kind === 'scalar' && prop.ref) return false\n return true\n })\n .map((prop) => prop.name)\n\n class EntityDtoTypeClass {\n static from(entity: T): EntityDtoTypeClass {\n const dto = new EntityDtoTypeClass()\n const json = wrap(entity).toPOJO()\n\n for (const property of properties) {\n if (property.hidden) continue\n if (property.kind === 'scalar' && !property.ref) {\n dto[property.name as any] = json[property.name as any]\n }\n if (property.kind === 'm:n' || property.kind === '1:m') {\n // array\n dto[property.name as any] = json[property.name as any]\n }\n\n if ((property.kind === '1:1' || property.kind === 'm:1')) {\n dto[property.name as any] = json[property.name as any]\n }\n }\n\n return dto\n }\n }\n\n inheritValidationMetadata(entity, EntityDtoTypeClass, (key) => keys.includes(key as any))\n inheritTransformationMetadata(entity, EntityDtoTypeClass, (key) => keys.includes(key as any))\n\n ApiPropertyUtils.cloneMetadata(EntityDtoTypeClass, entity, keys)\n\n for (const property of keys) {\n ModelRegister.copyProperty(entity, EntityDtoTypeClass, property)\n }\n\n return EntityDtoTypeClass as unknown as IEntityDtoClass<T>\n}\n","import { AnyEntity, Enum, EnumOptions } from '@mikro-orm/core'\nimport { ColumnTypeRequired } from '../types/column-type-required'\nimport { ApiEntityProperty } from './api-entity-property.decorator'\n\n\nexport function EntityEnum<T extends object>(\n options: EnumOptions<AnyEntity> & ColumnTypeRequired<T> & {\n example?: any\n enumName?: string\n },\n): PropertyDecorator {\n return (target, propertyKey) => {\n if (typeof propertyKey !== 'string') throw new TypeError('@EntityEnum() can only be used on string property')\n\n Enum<T>(options)(target, propertyKey)\n ApiEntityProperty({ example: options.example, enumName: options.enumName })(target, propertyKey)\n }\n}\n","import { Property } from '@mikro-orm/core'\n\n\nexport function EntityTransient(): PropertyDecorator {\n return Property({ persist: false }) as PropertyDecorator\n}\n\n","import { EntityName, OneToOne as OrmOneToOne, OneToOneOptions } from '@mikro-orm/core'\nimport { ApiEntityProperty } from './api-entity-property.decorator'\n\n\nexport function EntityOneToOne<Target, Owner>(\n entity?: OneToOneOptions<Owner, Target> | string | ((e: Owner) => EntityName<Target>),\n mappedByOrOptions?: (string & keyof Target) | ((e: Target) => any) | Partial<OneToOneOptions<Owner, Target>>,\n options?: Partial<OneToOneOptions<Owner, Target>>,\n): PropertyDecorator {\n return (target, propertyKey) => {\n if (typeof propertyKey !== 'string') throw new TypeError('@EntityOneToOne() can only be used on string property')\n\n OrmOneToOne(entity, mappedByOrOptions, options)(target, propertyKey)\n ApiEntityProperty()(target, propertyKey)\n }\n}\n","import { OneToMany as OrmOneToMany, OneToManyOptions } from '@mikro-orm/core'\nimport { ApiEntityProperty } from './api-entity-property.decorator'\n\nexport function EntityOneToMany<Target, Owner>(options: OneToManyOptions<Owner, Target>): PropertyDecorator {\n return (target, propertyKey) => {\n if (typeof propertyKey !== 'string') throw new TypeError('@EntityOneToMany() can only be used on string property')\n\n OrmOneToMany(options)(target, propertyKey)\n ApiEntityProperty()(target, propertyKey)\n }\n}\n","import { EntityName, ManyToOne as OrmManyToOne, ManyToOneOptions } from '@mikro-orm/core'\nimport { ApiEntityProperty } from './api-entity-property.decorator'\n\n\nexport function EntityManyToOne<T extends object, O>(\n entity?: ManyToOneOptions<T, O> | string | ((e?: any) => EntityName<T>),\n options?: Partial<ManyToOneOptions<T, O>>,\n): PropertyDecorator {\n return (target, propertyKey) => {\n if (typeof propertyKey !== 'string') throw new TypeError('@EntityManyToOne() can only be used on string property')\n\n OrmManyToOne(entity, options)(target, propertyKey)\n ApiEntityProperty()(target, propertyKey)\n }\n}\n","import { EntityName, ManyToMany, ManyToManyOptions } from '@mikro-orm/core'\nimport { ApiEntityProperty } from './api-entity-property.decorator'\n\nexport function EntityManyToMany<T extends object, O>(\n entity?: ManyToManyOptions<T, O> | string | (() => EntityName<T>),\n mappedBy?: (string & keyof T) | ((e: T) => any),\n options?: Partial<ManyToManyOptions<T, O>>,\n): PropertyDecorator {\n return (target, propertyKey) => {\n if (typeof propertyKey !== 'string') throw new TypeError('@EntityManyToMany() can only be used on string property')\n\n ManyToMany(entity, mappedBy, options)(target, propertyKey)\n ApiEntityProperty()(target, propertyKey)\n }\n}\n","import { ToNumber } from '@buka/class-transformer-extra'\nimport { IsBoolean, IsNumber, IsString } from 'class-validator'\n\nimport * as R from 'ramda'\nimport * as util from 'util'\nimport { Migrator } from '@mikro-orm/migrations'\nimport { FlushMode, Options } from '@mikro-orm/core'\nimport { BadRequestException } from '@nestjs/common'\n\n\nexport class DatabaseConfig {\n @IsBoolean()\n debug = false\n\n @IsBoolean()\n migration: boolean = false\n\n @IsString()\n dbName!: string\n\n @IsString()\n host!: string\n\n @ToNumber()\n @IsNumber({ allowNaN: false })\n port!: number\n\n @IsString()\n user!: string\n\n @IsString()\n password!: string\n\n @IsString()\n timezone? = '+08:00'\n\n toMikroOrmOptions(config?: Partial<Options>): Options {\n let options: Options = {\n host: this.host,\n port: this.port,\n user: this.user,\n password: this.password,\n dbName: this.dbName,\n debug: this.debug,\n timezone: this.timezone,\n\n forceUndefined: true,\n flushMode: FlushMode.COMMIT,\n serialization: {\n forceObject: true,\n },\n\n findOneOrFailHandler: (entityName, where) => new BadRequestException(`Cannot find ${entityName} where ${util.inspect(where)}`),\n }\n\n if (this.migration) {\n options = R.mergeDeepRight(options, {\n extensions: [Migrator],\n migrations: {\n snapshotName: 'snapshot',\n path: 'migrations',\n fileName: (timestamp) => `migration-${timestamp}`,\n },\n } satisfies Options)\n }\n\n return R.mergeDeepRight(options, config || {})\n }\n}\n","import { ReferenceObject } from './types/index.js'\n\n\nexport function isReferenceObject(obj: any): obj is ReferenceObject {\n return !!obj && typeof obj === 'object' && typeof obj.$ref === 'string'\n}\n","import { OpenAPIObject } from '@nestjs/swagger'\nimport { isReferenceObject } from './is-reference-object'\nimport { ReferenceObject } from './types/index.js'\n\n\nexport function deepDereference<T>(openapi: OpenAPIObject, reference: ReferenceObject): T | undefined {\n let current = reference\n\n const stack: string[] = []\n\n while (isReferenceObject(current)) {\n const refPath = current.$ref\n\n if (stack.includes(refPath)) return undefined\n stack.push(refPath)\n\n const parts = refPath.replace(/^#\\//, '').split('/')\n let next: any = openapi\n for (const part of parts) {\n next = next[part]\n }\n if (!next) return undefined\n\n current = next\n }\n\n return current as T\n}\n\n","import { OpenAPIObject } from '@nestjs/swagger'\nimport { ParameterObject } from './types/index.js'\n\n\nexport function forEachParameter(openapi: OpenAPIObject, callback: (parameter: ParameterObject) => void): void {\n for (const pathItem of Object.values(openapi.paths)) {\n for (const operation of Object.values(pathItem)) {\n if (operation && operation.parameters) {\n for (const parameter of operation.parameters) {\n if (!('$ref' in parameter)) {\n callback(parameter)\n }\n }\n }\n }\n }\n\n for (const parameter of Object.values(openapi.components?.parameters || {})) {\n if (!('$ref' in parameter)) {\n callback(parameter)\n }\n }\n}\n\n","import { OpenAPIObject } from '@nestjs/swagger'\nimport { isReferenceObject } from './is-reference-object'\nimport { SchemaObject } from './types/index.js'\nimport { deepDereference } from './deep-dereference.js'\nimport { forEachParameter } from './for-each-parameter.js'\n\n\nexport function deepObjectifyQueries(openapi: OpenAPIObject): void {\n forEachParameter(openapi, (parameter) => {\n if (parameter.in === 'query' && parameter.schema && parameter.style === undefined && (parameter.explode === undefined || parameter.explode === true)) {\n const schema = isReferenceObject(parameter.schema)\n ? deepDereference<SchemaObject>(openapi, parameter.schema)\n : parameter.schema\n\n if (schema && (schema.type === 'object' || schema.type === 'array')) {\n parameter.style = 'deepObject'\n }\n }\n })\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport { MikroORM, EntityManager, Ref } from '@mikro-orm/core'\nimport { ValidationPipe, ValidationPipeOptions } from '@nestjs/common'\nimport { ArgumentMetadata, Injectable, Logger, PipeTransform, Type } from '@nestjs/common'\nimport { Class } from 'type-fest'\nimport { ModelRegister } from '~/decorators'\nimport { EntityRefTypeClassMetadataPropertyKey } from '~/mikro-orm'\nimport * as MikroOrmUtils from '~/utils/mikro-orm-utils'\n\n\nfunction deepMap(obj: any, fn: (value: any) => any): any {\n if (Array.isArray(obj)) {\n return obj.map((item) => deepMap(item, fn))\n } else {\n return fn(obj)\n }\n}\n\n\nfunction transformReference(em: EntityManager, value: any, metatype: Class<object>): any {\n if (typeof value !== 'object' || value === null) return value\n\n const entityProperties = MikroOrmUtils.getMetadata(metatype)\n const primaryProperties = entityProperties.filter((p) => p.primary)\n\n if (primaryProperties.length === 1) {\n const propertyKey = primaryProperties[0].name\n const ref = em.getReference(metatype, value[propertyKey], { wrapped: true })\n return ref\n } else if (primaryProperties.length > 1) {\n const propertyKeys = primaryProperties.map((p) => p.name)\n const ref = em.getReference(metatype, propertyKeys.map((key) => value[key]), { wrapped: true })\n return ref\n }\n\n return value\n}\n\n\nfunction deepTransform(em: EntityManager, value: any, metatype: Class<any>): any {\n // value = transformReferenceProperties(em, value, metatype)\n\n if (typeof value !== 'object' || value === null) {\n // transform 不需要做 validate,其他的格式也可能是合法的,交给 class-validator 处理\n return value\n }\n\n const propertyKeys = ModelRegister.getModelPropertyKeys(metatype)\n\n const result = { ...value }\n\n for (const propertyKey of propertyKeys) {\n const propertyMetadata = ModelRegister.getProperty(metatype, propertyKey)\n if (!propertyMetadata) continue\n if (!(propertyKey in value)) continue\n\n const propertyValue = value[propertyKey]\n\n if (propertyMetadata.kind === 'nested') {\n const ctor = propertyMetadata.type() as Type<any>\n\n if (EntityRefTypeClassMetadataPropertyKey in ctor) {\n // 是 EntityRefType\n result[propertyKey] = transformReference(em, propertyValue, ctor)\n } else {\n const v = deepTransform(em, propertyValue, ctor)\n result[propertyKey] = v\n }\n } else if (propertyMetadata.kind === 'list') {\n result[propertyKey] = deepMap(\n propertyValue,\n (item) => deepTransform(em, item, propertyMetadata.type() as Type<any>),\n )\n } else if (propertyMetadata.kind === 'dictionary') {\n // result[propertyKey] = deepMap(propertyValue, (item) => deepTransform(em, item, ctor))\n result[propertyKey] = Object.fromEntries(\n Object.entries(propertyValue)\n .map(([k, v]) => [k, deepTransform(em, v, propertyMetadata.type() as Type<any>)]),\n )\n }\n }\n\n return result\n}\n\n\n@Injectable()\nexport class BukaValidationPipe extends ValidationPipe implements PipeTransform {\n private readonly logger = new Logger(BukaValidationPipe.name)\n\n constructor(\n private readonly orm: MikroORM,\n private readonly em: EntityManager,\n ) {\n super()\n }\n\n async transform(value: any, metadata: ArgumentMetadata): Promise<any> {\n value = await super.transform(value, metadata)\n\n if (!metadata.metatype || typeof metadata.metatype !== 'function') {\n return value\n }\n\n const metatype = metadata.metatype\n\n const result = await deepTransform(this.em, value, metatype)\n return result\n }\n\n static withParams(options: ValidationPipeOptions): Type<PipeTransform> {\n @Injectable()\n class BukaParametrizedValidationPipe extends ValidationPipe implements PipeTransform {\n private readonly logger = new Logger(BukaParametrizedValidationPipe.name)\n\n constructor(\n private readonly orm: MikroORM,\n private readonly em: EntityManager,\n ) {\n super(options)\n }\n\n async transform(value: any, metadata: ArgumentMetadata): Promise<any> {\n value = await super.transform(value, metadata)\n\n if (!options.transform) return value\n\n if (!metadata.metatype || typeof metadata.metatype !== 'function') {\n return value\n }\n\n const metatype = metadata.metatype\n\n const result = await deepTransform(this.em, value, metatype)\n return result\n }\n }\n\n return BukaParametrizedValidationPipe\n }\n}\n","import * as R from 'ramda'\nimport type { IFilterQueryObject, IFilterQuery } from './types'\nimport * as ClassValidatorUtils from '~/utils/class-validator-utils'\nimport * as ClassTransformerUtils from '~/utils/class-transformer-utils'\nimport { getFilterQueryOperators } from './decorators'\nimport { HasAnyKey, ModelRegister, NestedProperty } from '~/decorators'\nimport { ArrayMinSize, IS_OPTIONAL, IsArray, IsOptional } from 'class-validator'\nimport { Class } from 'type-fest'\nimport { TypeException } from '~/exceptions'\nimport { getPropertyOperators, getCollectionOperators } from './utils'\nimport { getFilterQuerySchema } from './get-filter-query-schema'\n\n\nfunction createFilterQueryPropertyClassRef(classRef: Class<any>, propertyKey: string): Class<any> {\n const propertyClass = class FilterQueryPropertyClass {}\n ModelRegister.addModel(propertyClass)\n // ModelRegister.addProperty(FilterQueryObjectClass, propertyKey, { type: () => propertyClass, optional: propertyMetadata?.optional })\n\n const propertyMetadata = ModelRegister.getProperty(classRef, propertyKey)\n\n const validationMetadataList = ClassValidatorUtils.getMetadata(classRef, propertyKey)\n // 跳过 IsOptional,手动添加\n // 这不仅仅是为了避免重复添加\n // 也是因为 IsOptional 复制无法被复制\n // 详见 https://github.com/typestack/class-validator/blob/develop/src/decorator/common/IsOptional.ts\n .filter((metadata) => metadata.name !== IS_OPTIONAL)\n\n const transformerMetadataList = ClassTransformerUtils.getTransformMetadata(classRef, propertyKey) || []\n const operators = getPropertyOperators(classRef, propertyKey)\n\n for (const operator of operators) {\n if (['$in', '$nin'].includes(operator)) {\n // $in, $nin\n ModelRegister.addProperty(propertyClass, operator, { ...propertyMetadata, kind: 'list', optional: true })\n\n IsArray()(propertyClass.prototype, operator)\n ArrayMinSize(1)(propertyClass.prototype, operator)\n\n for (const metadata of validationMetadataList) {\n ClassValidatorUtils.setMetadata(propertyClass, operator, { ...metadata, each: true })\n }\n\n for (const metadata of transformerMetadataList) {\n // 需要将 transformFn 修改为数组版本\n const transformFn = metadata.transformFn\n ClassTransformerUtils.setTransformMetadata(propertyClass, operator, {\n ...metadata,\n transformFn: function FilterQueryPropertyTransformer(params) {\n if (Array.isArray(params.value)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return params.value.map((v, i, arr) => transformFn({ ...params, value: v, key: i, obj: arr }))\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return params.value\n },\n })\n }\n } else {\n // $eq, $ne, $lt, $gt, $lte, $gte\n ModelRegister.addProperty(propertyClass, operator, { ...propertyMetadata, optional: true })\n\n for (const metadata of validationMetadataList) {\n ClassValidatorUtils.setMetadata(propertyClass, operator, metadata)\n }\n\n for (const metadata of transformerMetadataList) {\n ClassTransformerUtils.setTransformMetadata(propertyClass, operator, metadata)\n }\n }\n\n IsOptional()(propertyClass.prototype, operator)\n }\n\n return propertyClass\n}\n\nfunction createFilterQueryObjectClassRef(classRef: Class<any>): Class<any> {\n class FilterQueryObjectClass {}\n ModelRegister.addModel(FilterQueryObjectClass)\n\n for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {\n if (typeof propertyKey !== 'string') continue\n\n const propertyMetadata = ModelRegister.getProperty(classRef, propertyKey)\n const isCollection = propertyMetadata?.relation?.kind === '1:m' || propertyMetadata?.relation?.kind === 'm:n'\n const isRelation = !!propertyMetadata?.relation\n const isOptional = !!propertyMetadata?.optional\n\n if (isRelation) {\n if (isCollection) {\n // $some, $none, $every\n class FilterQueryCollectionClass {}\n ModelRegister.addModel(FilterQueryCollectionClass)\n\n const sub = createFilterQueryObjectClassRef(propertyMetadata.relation!.type() as Class<any>)\n const operators = getCollectionOperators(classRef, propertyKey)\n\n for (const operator of operators) {\n NestedProperty(() => sub, { optional: true })(FilterQueryCollectionClass.prototype, operator)\n if (!isOptional) {\n HasAnyKey(getFilterQueryOperators(classRef, propertyKey))(FilterQueryCollectionClass.prototype, operator)\n }\n\n IsOptional()(FilterQueryCollectionClass.prototype, operator)\n }\n NestedProperty(() => FilterQueryCollectionClass, { optional: isOptional })(FilterQueryObjectClass.prototype, propertyKey)\n if (!isOptional) HasAnyKey(operators)(FilterQueryObjectClass.prototype, propertyKey)\n } else {\n const sub = createFilterQueryObjectClassRef(propertyMetadata.relation!.type() as Class<any>)\n NestedProperty(() => sub, { optional: isOptional })(FilterQueryObjectClass.prototype, propertyKey)\n }\n } else {\n // $eq, $ne, $lt, $gt, $lte, $gte, $in, $nin\n const propertyClass = createFilterQueryPropertyClassRef(classRef, propertyKey)\n\n NestedProperty(\n () => propertyClass,\n {\n optional: isOptional,\n },\n )(FilterQueryObjectClass.prototype, propertyKey)\n\n if (!isOptional) {\n const operators = getPropertyOperators(classRef, propertyKey)\n HasAnyKey(operators)(FilterQueryObjectClass.prototype, propertyKey)\n }\n }\n }\n\n return FilterQueryObjectClass\n}\n\nexport function FilterQueryType<T>(classRef: Class<T>): Class<IFilterQuery<T>> {\n if (!ModelRegister.isModel(classRef)) {\n throw new TypeException('FilterQueryType only accepts a class annotated with @Model().')\n }\n\n const FilterQueryObjectClass = createFilterQueryObjectClassRef(classRef)\n\n const properties = ModelRegister.getProperties(FilterQueryObjectClass)\n const isRequired = R.any((p) => !p.optional, properties)\n\n class FilterQueryClass {\n filter!: IFilterQueryObject<T>\n }\n\n ModelRegister.addModel(FilterQueryObjectClass)\n NestedProperty(\n () => FilterQueryObjectClass,\n {\n optional: !isRequired,\n schema: getFilterQuerySchema(classRef),\n },\n )(FilterQueryClass.prototype, 'filter')\n\n return FilterQueryClass as Class<IFilterQuery<T>>\n}\n","import * as R from 'ramda'\nimport { Type } from '@nestjs/common'\nimport { getMetadataStorage } from 'class-validator'\nimport { ValidationMetadata } from 'class-validator/types/metadata/ValidationMetadata'\n\n\nexport function hasMetadata(source: Type<any>, propertyKey: string): boolean {\n const items = getMetadata(source, propertyKey)\n return items.length > 0\n}\n\nexport function getMetadata(source: Type<any>): Map<string, ValidationMetadata[]>\nexport function getMetadata(source: Type<any>, propertyKey: string): ValidationMetadata[]\nexport function getMetadata(source: Type<any>, propertyKey?: string): Map<string, ValidationMetadata[]> | ValidationMetadata[] | undefined {\n const metadataStorage = getMetadataStorage()\n const arr = metadataStorage.getTargetValidationMetadatas(source, null!, false, false)\n\n if (!propertyKey) {\n const grouped = R.groupBy(\n (m) => m.propertyName,\n arr,\n )\n\n const result = new Map<string, ValidationMetadata[]>()\n for (const key in grouped) {\n result.set(key, grouped[key] || [])\n }\n\n return result\n }\n\n\n return arr.filter((item) => item.propertyName === propertyKey)\n}\n\nexport function setMetadata(target: Type<any>, propertyKey: string, metadata: ValidationMetadata): void {\n const metadataStorage = getMetadataStorage()\n metadataStorage.addValidationMetadata({\n ...metadata,\n target: target,\n propertyName: propertyKey,\n })\n}\n\nexport function copyMetadata(\n { source, propertyKey: sourcePropertyKey }: { source: Type<any>; propertyKey: string },\n { target, propertyKey: targetPropertyKey }: { target: Type<any>; propertyKey: string },\n): void {\n const metadataList = getMetadata(source, sourcePropertyKey)\n for (const metadata of metadataList) {\n setMetadata(target, targetPropertyKey, metadata)\n }\n}\n\n","/**\n * This file contains utility functions for working with `@Transform()` decorator of class-transformer.\n */\n\nimport { Type } from '@nestjs/common'\nimport * as classTransformer from 'class-transformer/cjs/storage'\n\n\n// ---------------------------------- @Transform() ----------------------------------\n\nexport function cloneTransformMetadata(target: Function, source: Type<unknown>, keys: string[]): void {\n for (const propertyKey of keys) {\n const transformerMetadata = getTransformMetadata(source, propertyKey)\n if (transformerMetadata) {\n for (const metadata of transformerMetadata) {\n setTransformMetadata(target as Type<any>, propertyKey, metadata)\n }\n }\n }\n}\n\nexport function copyTransformMetadata(\n { source, propertyKey: sourcePropertyKey }: { source: Type<any>; propertyKey: string },\n { target, propertyKey: targetPropertyKey }: { target: Type<any>; propertyKey: string },\n): void {\n const metadataList = getTransformMetadata(source, sourcePropertyKey)\n if (!metadataList) return\n\n for (const metadata of metadataList) {\n setTransformMetadata(target, targetPropertyKey, metadata)\n }\n}\n\n\ninterface TransformMetadata {\n target: Function\n propertyName: string\n transformFn: (params: any) => any\n options?: Record<string, any>\n}\n\nexport function getTransformMetadata(classRef: Type<any>): Map<string, TransformMetadata[]> | undefined\nexport function getTransformMetadata(classRef: Type<any>, prop: string): TransformMetadata[] | undefined\nexport function getTransformMetadata(classRef: Type<any>, prop?: string): Map<string, TransformMetadata[]> | TransformMetadata[] | undefined {\n const metadataStorage = classTransformer.defaultMetadataStorage\n const metadataMap = metadataStorage['_transformMetadatas']\n\n const classMetadata: Map<string, TransformMetadata[]> | undefined = metadataMap.get(classRef)\n if (!classMetadata) return\n\n if (!prop) return classMetadata\n\n const propertyMetadata = classMetadata.get(prop)\n if (!propertyMetadata) return undefined\n return Array.isArray(propertyMetadata) ? propertyMetadata : [propertyMetadata]\n}\n\n\nexport function setTransformMetadata(classRef: Type<any>, prop: string, metadata: TransformMetadata): void {\n const meta = { ...metadata, target: classRef, propertyName: prop }\n\n const metadataStorage = classTransformer.defaultMetadataStorage\n const metadataMap = metadataStorage['_transformMetadatas']\n\n\n if (metadataMap.has(classRef)) {\n const classMetadata = metadataMap.get(classRef)\n const propertyMetadata = classMetadata.get(prop)\n\n if (propertyMetadata) {\n classMetadata.set(prop, propertyMetadata.concat(meta))\n } else {\n classMetadata.set(prop, [meta])\n }\n } else {\n metadataMap.set(classRef, new Map([[prop, [meta]]]))\n }\n}\n\n\nexport function hasTransformMetadata(classRef: Type<any>, prop: string): boolean {\n const metadata = getTransformMetadata(classRef, prop)\n return !!metadata && metadata.length > 0\n}\n\n// ---------------------------------- @Type() ----------------------------------\n\n/**\n * Get the metadata of `@Type()` decorator of class-transformer.\n */\nexport function getTypeMetadata(classRef: Type<any>, prop: any): any | undefined {\n const metadataStorage = classTransformer.defaultMetadataStorage\n const metadataMap = metadataStorage['_typeMetadatas']\n\n let parentClassRef = classRef\n\n while (parentClassRef && parentClassRef !== Object) {\n const classMetadata = metadataMap.get(parentClassRef)\n if (classMetadata) {\n const value = classMetadata.get(prop)\n if (value) return value\n }\n\n parentClassRef = Object.getPrototypeOf(parentClassRef)\n }\n}\n\nexport function setTypeMetadata(classRef: Type<any>, prop: any, metadata: any): void {\n const meta = { ...metadata, target: classRef, propertyName: prop }\n\n const metadataStorage = classTransformer.defaultMetadataStorage\n const metadataMap = metadataStorage['_typeMetadatas']\n\n metadataMap.set(classRef, meta)\n}\n\nexport function cloneTypeMetadata(target: Type<any>, source: Type<any>, keys: string[]): void {\n for (const propertyKey of keys) {\n const metadata = getTypeMetadata(source, propertyKey)\n if (metadata) setTypeMetadata(target, propertyKey, metadata)\n }\n}\n","export type FilterQueryOperator = '$eq' | '$ne' | '$lt' | '$gt' | '$lte' | '$gte' | '$in' | '$nin' | '$some' | '$every' | '$none'\n\n\nexport const FilterQueryOperatorsMetadataKey = 'buka:filter-query-operators'\n\nexport function FilterQueryOperators(operators: FilterQueryOperator[]): PropertyDecorator {\n if (!operators || operators.length === 0) {\n throw new TypeError('FilterQueryOperators: operators array must not be empty')\n }\n\n return function FilterQueryOperatorsDecorator(target: object, propertyKey: string | symbol): void {\n Reflect.defineMetadata(FilterQueryOperatorsMetadataKey, operators, target, propertyKey)\n }\n}\n\nexport function getFilterQueryOperators(target: object, propertyKey: string | symbol): readonly FilterQueryOperator[] {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return Reflect.getMetadata(FilterQueryOperatorsMetadataKey, target, propertyKey)\n}\n","import { Class } from 'type-fest'\nimport { FilterQueryOperator, getFilterQueryOperators } from '../decorators'\n\n\nconst FilterQueryCollectionOperators: readonly FilterQueryOperator[] = ['$some', '$every', '$none'] as const\n\n\nexport function getCollectionOperators(target: Class<any>, propertyKey: string | symbol): readonly FilterQueryOperator[] {\n const operators = getFilterQueryOperators(target.prototype, propertyKey)\n if (!operators) return FilterQueryCollectionOperators\n\n return operators.filter((op) => FilterQueryCollectionOperators.includes(op))\n}\n","import { Class } from 'type-fest'\nimport { FilterQueryOperator, getFilterQueryOperators } from '../decorators'\n\n\nconst FilterQueryPropertyOperators: readonly FilterQueryOperator[] = ['$eq', '$ne', '$lt', '$gt', '$lte', '$gte', '$in', '$nin'] as const\n\n\nexport function getPropertyOperators(target: Class<any>, propertyKey: string | symbol): readonly FilterQueryOperator[] {\n const operators = getFilterQueryOperators(target.prototype, propertyKey)\n if (!operators) return FilterQueryPropertyOperators\n\n return operators.filter((op) => FilterQueryPropertyOperators.includes(op))\n}\n\n","import * as R from 'ramda'\nimport { getSchemaPath } from '@nestjs/swagger'\nimport { Class } from 'type-fest'\nimport * as NestjsSwaggerUtils from '~/utils/nestjs-swagger-utils'\n\n\nfunction scalarType(type: Class<any> | string | typeof String | typeof Number | typeof Boolean): any {\n if (typeof type === 'string') return { type: type as any }\n if (type === String) return { type: 'string' }\n if (type === Number) return { type: 'number' }\n if (type === Boolean) return { type: 'boolean' }\n\n return {\n $ref: getSchemaPath(type),\n }\n}\n\nexport function swaggerMetadataToJsonSchema(metadata: NestjsSwaggerUtils.SchemaObjectMetadata): any {\n const base = R.omit(['type', 'required'], metadata)\n if (NestjsSwaggerUtils.isLazyTypeFunc(metadata.type)) {\n return { ...base, ...scalarType(metadata.type()) }\n }\n\n return {\n ...base,\n ...scalarType(metadata.type as any),\n }\n}\n","\nimport { ApiPropertyOptions } from '@nestjs/swagger'\nimport { Class } from 'type-fest'\nimport { ModelRegister } from '~/decorators'\nimport * as NestjsSwaggerUtils from '~/utils/nestjs-swagger-utils'\nimport { getPropertyOperators, getCollectionOperators, swaggerMetadataToJsonSchema } from './utils'\nimport { SchemaObject } from '~/swagger/types'\n\n\nfunction getObjectSchema(classRef: Class<any>): SchemaObject {\n const properties = {}\n const schema: SchemaObject = {\n type: 'object',\n properties,\n }\n\n for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {\n if (typeof propertyKey !== 'string') continue\n\n const propertyMetadata = ModelRegister.getProperty(classRef, propertyKey)\n const isCollection = propertyMetadata?.relation?.kind === '1:m' || propertyMetadata?.relation?.kind === 'm:n'\n const isRelation = !!propertyMetadata?.relation\n const isOptional = !!propertyMetadata?.optional\n\n if (isRelation) {\n if (isCollection) {\n // $some, $none, $every\n const sub = getObjectSchema(propertyMetadata.relation!.type() as Class<any>)\n const operators = getCollectionOperators(classRef, propertyKey)\n\n for (const operator of operators) {\n properties[operator] = sub\n }\n } else {\n const sub = getObjectSchema(propertyMetadata.relation!.type() as Class<any>)\n properties[propertyKey] = sub\n }\n } else {\n // $eq, $ne, $lt, $gt, $lte, $gte\n // const propertyClass = propertyMetadata?.type as Class<any>\n const propertySchema: ApiPropertyOptions = {\n type: 'object',\n properties: {},\n }\n\n const originalSchema = NestjsSwaggerUtils.getMetadata(classRef, propertyKey)\n\n const operators = getPropertyOperators(classRef, propertyKey)\n\n for (const operator of operators) {\n if (['$in', '$nin'].includes(operator)) {\n propertySchema.properties[operator] = {\n type: 'array',\n items: originalSchema\n ? swaggerMetadataToJsonSchema(originalSchema)\n : { type: 'string' },\n }\n } else {\n propertySchema.properties[operator] = originalSchema\n ? swaggerMetadataToJsonSchema(originalSchema)\n : { type: 'string' }\n }\n }\n\n properties[propertyKey] = propertySchema\n }\n }\n\n return schema\n}\n\nexport function getFilterQuerySchema(classRef: Class<any>): ApiPropertyOptions {\n return {\n ...getObjectSchema(classRef),\n description: `Filter query for ${classRef.name}`,\n required: false,\n } as ApiPropertyOptions\n}\n","import { PickType as SwaggerPickType } from '@nestjs/swagger'\nimport { Class } from 'type-fest'\nimport { ModelRegister } from '~/decorators'\nimport { TypeException } from '~/exceptions'\n\nexport function PickType<T, K extends keyof T>(classRef: Class<T>, keys: K[]): Class<Pick<T, typeof keys[number]>> {\n if (!ModelRegister.isModel(classRef)) {\n throw new TypeException('PickType only accepts a class annotated with @Model().')\n }\n\n const PickTypeClass = SwaggerPickType(classRef, keys)\n\n\n for (const key of keys) {\n ModelRegister.copyProperty(classRef, PickTypeClass, key as string)\n\n const metadataKeys = Reflect.getMetadataKeys(classRef.prototype, key as string)\n\n for (const metadataKey of metadataKeys) {\n const metadata = Reflect.getMetadata(metadataKey, classRef.prototype, key as string)\n if (Reflect.hasMetadata(metadataKey, PickTypeClass.prototype, key as string)) continue\n Reflect.defineMetadata(metadataKey, metadata, PickTypeClass.prototype, key as string)\n }\n }\n\n return PickTypeClass\n}\n","import { OmitType as SwaggerOmitType } from '@nestjs/swagger'\nimport { Class } from 'type-fest'\nimport { ModelRegister } from '~/decorators'\nimport { TypeException } from '~/exceptions'\n\n\nexport function OmitType<T, K extends keyof T>(classRef: Class<T>, keys: K[]): Class<Omit<T, typeof keys[number]>> {\n if (!ModelRegister.isModel(classRef)) {\n throw new TypeException('OmitType only accepts a class annotated with @Model().')\n }\n\n const OmitTypeClass = SwaggerOmitType(classRef, keys)\n\n for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {\n if (keys.includes(propertyKey as K)) continue\n\n ModelRegister.copyProperty(classRef, OmitTypeClass, propertyKey)\n\n const metadataKeys = Reflect.getMetadataKeys(classRef.prototype, propertyKey)\n\n for (const metadataKey of metadataKeys) {\n const metadata = Reflect.getMetadata(metadataKey, classRef.prototype, propertyKey)\n if (Reflect.hasMetadata(metadataKey, OmitTypeClass.prototype, propertyKey)) continue\n Reflect.defineMetadata(metadataKey, metadata, OmitTypeClass.prototype, propertyKey)\n }\n }\n\n return OmitTypeClass\n}\n","import { PartialType as SwaggerPartialType } from '@nestjs/swagger'\nimport { Class } from 'type-fest'\nimport { ModelRegister } from '~/decorators'\n\nexport function PartialType<T>(classRef: Class<T>): Class<Partial<T>> {\n const PartialTypeClass = SwaggerPartialType(classRef)\n\n for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {\n ModelRegister.copyProperty(classRef, PartialTypeClass, propertyKey)\n\n const metadataKeys = Reflect.getMetadataKeys(classRef.prototype, propertyKey as string)\n\n for (const metadataKey of metadataKeys) {\n const metadata = Reflect.getMetadata(metadataKey, classRef.prototype, propertyKey as string)\n if (Reflect.hasMetadata(metadataKey, PartialTypeClass.prototype, propertyKey as string)) continue\n Reflect.defineMetadata(metadataKey, metadata, PartialTypeClass.prototype, propertyKey as string)\n }\n }\n\n return PartialTypeClass\n}\n","import { ApiPropertyOptions } from '@nestjs/swagger'\nimport { Class } from 'type-fest'\nimport { ModelRegister } from '~/decorators'\nimport { SchemaObject } from '~/swagger/types'\n\n\nfunction getOrderQueryEnum(): SchemaObject {\n return {\n type: 'string',\n enum: [\n 'asc',\n 'asc nulls last',\n 'asc nulls first',\n 'desc',\n 'desc nulls last',\n 'desc nulls first',\n ],\n }\n}\n\nfunction getOrderQueryMapSchema(classRef: Class<any>): SchemaObject {\n const properties = {}\n const schema: SchemaObject = {\n type: 'object',\n properties,\n required: [],\n }\n\n for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {\n const propertyMetadata = ModelRegister.getProperty(classRef, propertyKey)\n // const isCollection = propertyMetadata?.relation?.kind === '1:m' || propertyMetadata?.relation?.kind === 'm:n'\n const isRelation = !!propertyMetadata?.relation\n // const isOptional = !!propertyMetadata?.optional\n\n if (isRelation) {\n properties[propertyKey] = getOrderQueryMapSchema(propertyMetadata.relation!.type() as Class<any>)\n } else {\n properties[propertyKey] = getOrderQueryEnum()\n }\n\n // if (!isOptional) schema.required!.push(propertyKey)\n }\n\n return schema\n}\n\n\nexport function getOrderQuerySchema(classRef: Class<any>): ApiPropertyOptions {\n const orderQueryMapSchema = getOrderQueryMapSchema(classRef)\n\n return {\n description: `Order query for ${classRef.name}`,\n oneOf: [\n {\n type: 'array',\n items: orderQueryMapSchema,\n },\n orderQueryMapSchema,\n ],\n required: false,\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport { Class } from 'type-fest'\nimport { IOrderQuery } from './types'\nimport { getOrderQuerySchema } from './get-order-query-schema'\nimport { Property, MatchJsonSchema } from '~/decorators'\n\nexport function OrderQueryType<T>(classRef: Class<T>): Class<IOrderQuery<T>> {\n const schema = getOrderQuerySchema(classRef)\n\n class OrderQueryClass {\n orderBy!: ''\n }\n\n Property({ optional: true, schema })(OrderQueryClass.prototype, 'orderBy')\n\n MatchJsonSchema(schema, { message: 'Invalid order query' })(OrderQueryClass.prototype, 'orderBy')\n\n return OrderQueryClass as any\n}\n","import { Model, Property } from '~/decorators'\n\n\n@Model()\nexport class OffsetPaginationRo {\n @Property({\n schema: {\n type: 'number',\n description: '总数',\n },\n })\n total!: number\n\n @Property({\n schema: {\n type: 'number',\n description: '每页数量',\n },\n })\n limit!: number\n\n @Property({\n schema: {\n type: 'number',\n description: '偏移量',\n },\n })\n offset!: number\n}\n","import { Model, Property } from '~/decorators'\n\n\n@Model()\nexport class CursorPaginationRo {\n @Property({\n schema: {\n type: 'number',\n description: '总数',\n },\n })\n total?: number\n\n @Property({\n schema: {\n type: 'number',\n description: '每页数量',\n },\n })\n limit!: number\n\n @Property({\n schema: {\n type: 'string',\n description: '开始游标',\n },\n })\n startCursor!: string\n\n @Property({\n schema: {\n type: 'string',\n description: '结束游标',\n },\n })\n endCursor!: string\n\n @Property({\n schema: {\n type: 'boolean',\n description: '是否有下一页',\n },\n })\n hasNextPage!: boolean\n\n @Property({\n schema: {\n type: 'boolean',\n description: '是否有上一页',\n },\n })\n hasPrevPage!: boolean\n}\n","import { Type } from '@nestjs/common'\nimport { Class } from 'type-fest'\nimport { IListResponseBody } from './types/list-response-body'\nimport { NestedProperty } from '~/decorators'\nimport { CursorPaginationRo, OffsetPaginationRo } from '~/ro'\nimport { Slice } from '~/models'\n\n\ntype IListResponseBodyClass<T extends object, MODE extends 'offset' | 'cursor'> = Class<IListResponseBody<T, MODE>> & {\n fromSlice(slice: Slice<T>): IListResponseBody<T, MODE>\n}\n\nexport function ListResponseBodyType<T extends object, MODE extends 'offset' | 'cursor' = 'offset' | 'cursor'>(classRef: Type<T>, mode?: MODE): IListResponseBodyClass<T, MODE> {\n class ResponseBodyMeta {\n pagination\n }\n\n if (mode === 'cursor') {\n NestedProperty(() => CursorPaginationRo)(ResponseBodyMeta.prototype, 'pagination')\n } else if (mode === 'offset') {\n NestedProperty(() => OffsetPaginationRo)(ResponseBodyMeta.prototype, 'pagination')\n }\n\n class ListResponseBody {\n @NestedProperty(() => classRef, { each: true })\n data!: T[]\n\n @NestedProperty(() => ResponseBodyMeta)\n meta!: ResponseBodyMeta\n\n constructor(data: T[], meta: ResponseBodyMeta) {\n this.data = data\n this.meta = meta\n }\n\n static fromSlice(slice: Slice<T>): ListResponseBody {\n const data = slice.data\n const meta = {\n pagination: slice.pagination,\n }\n\n const res = new ListResponseBody(data, meta)\n return res\n }\n }\n\n return ListResponseBody as IListResponseBodyClass<T, MODE>\n}\n\n","import { Class } from 'type-fest'\nimport { IResponseBody } from './types/index.js'\nimport { Property } from '~/decorators/index.js'\n\n\ntype IResponseBodyClass<T> = Class<IResponseBody<T>> & {\n from(data: T): IResponseBody<T>\n}\n\n\nexport function ResponseBodyType<T>(classRef: Class<T>): IResponseBodyClass<T> {\n class ResponseBodyClass {\n constructor(public data: T) {}\n\n static from(data: T, meta: Record<string, any>): ResponseBodyClass {\n const instance = new ResponseBodyClass(data)\n return instance\n }\n }\n\n Property({\n type: () => classRef,\n schema: {\n type: () => classRef,\n },\n })(ResponseBodyClass.prototype, 'data')\n\n Property({\n type: () => Object,\n schema: {\n additionalProperties: true,\n },\n })\n\n return ResponseBodyClass as IResponseBodyClass<T>\n}\n","import { Model, Property } from '~/decorators'\n\n\n@Model()\nexport class OffsetPagination {\n @Property({\n schema: {\n type: 'number',\n description: '总数',\n },\n })\n total!: number\n\n @Property({\n schema: {\n type: 'number',\n description: '每页数量',\n },\n })\n limit!: number\n\n @Property({\n schema: {\n type: 'number',\n description: '偏移量',\n },\n })\n offset!: number\n\n constructor(total: number, parameters: { limit: number; offset: number }) {\n this.total = total\n this.limit = parameters.limit\n this.offset = parameters.offset\n }\n}\n","import { Cursor } from '@mikro-orm/core'\nimport { Model, Property } from '~/decorators'\n\n\n@Model()\nexport class CursorPagination {\n @Property({\n schema: {\n type: 'number',\n description: '总数',\n },\n })\n total?: number\n\n @Property({\n schema: {\n type: 'number',\n description: '每页数量',\n },\n })\n limit!: number\n\n @Property({\n schema: {\n type: 'string',\n description: '开始游标',\n nullable: true,\n },\n })\n startCursor!: string | null\n\n @Property({\n schema: {\n type: 'string',\n description: '结束游标',\n nullable: true,\n },\n })\n endCursor!: string | null\n\n @Property({\n schema: {\n type: 'boolean',\n description: '是否有下一页',\n },\n })\n hasNextPage!: boolean\n\n @Property({\n schema: {\n type: 'boolean',\n description: '是否有上一页',\n },\n })\n hasPrevPage!: boolean\n\n constructor(cursor: Cursor<any>) {\n this.total = cursor.totalCount\n this.limit = cursor.length\n this.startCursor = cursor.startCursor\n this.endCursor = cursor.endCursor\n this.hasNextPage = cursor.hasNextPage\n this.hasPrevPage = cursor.hasPrevPage\n }\n}\n","import { Cursor } from '@mikro-orm/core'\nimport { IOffsetPageParameters } from '~/types'\nimport { OffsetPagination } from './offset-pagination'\nimport { CursorPagination } from './cursor-pagination'\n\n\nexport class Slice<T extends object> {\n data!: Array<T>\n\n pagination!: OffsetPagination | CursorPagination\n\n constructor(data: Array<T>, pagination: OffsetPagination | CursorPagination) {\n this.data = data\n this.pagination = pagination\n }\n\n *[Symbol.iterator](): Iterator<T> {\n for (const item of this.data) {\n yield item\n }\n }\n\n static fromOffset<T extends object>(data: Array<T>, total: number, parameters: IOffsetPageParameters): Slice<T> {\n const pagination = new OffsetPagination(total, parameters)\n\n return new Slice<T>(data, pagination)\n }\n\n static fromCursor<T extends object>(cursor: Cursor<T>): Slice<T> {\n const pagination = new CursorPagination(cursor)\n return new Slice<T>(cursor.items, pagination)\n }\n\n map<R extends object>(fn: (item: T, index: number) => R): Slice<R> {\n const mappedData = this.data.map(fn)\n return new Slice<R>(mappedData, this.pagination)\n }\n}\n"],"mappings":";;;;AAAA,SAASA,cAAAA,aAAkCC,YAAYC,sBAAsB;AAC7E,SAASC,eAAAA,oBAAmB;AAC5B,SAASC,sBAAsB;;;ACF/B,SAASC,QAAsBC,qBAAqB;;;ACApD,SAASC,YAAYC,mBAAoC;;;ACAzD,SAASC,iBAAiBC,qBAAqB;AAC/C,SAAyBC,mBAAAA,kBAAiBC,qBAAqB;;;ACD/D,SAASC,kBAAkC;AAC3C,SAASC,mBAAAA,wBAAuB;AAChC,SAASC,WAAWC,YAAYC,OAAOC,WAAWC,UAAUC,UAAUC,WAAWC,iBAAiB;;;ACFlG,YAAYC,QAAO;AACnB,SAASC,uBAAuB;AAEhC,SAASC,QAAQC,iBAAiB;AAClC,SAASC,YAAYC,sBAAsB;;;ACJ3C,YAAYC,OAAO;AAMnB,IAAMC,qBAAqB;AAC3B,IAAMC,wBAAwB;AAEvB,IAAMC,gBAAN,MAAMA;EATb,OASaA;;;EACX,OAAOC,SAASC,QAAoBC,UAA+B;AACjEC,YAAQC,eAAeP,oBAAoBK,UAAUD,MAAAA;EACvD;EAEA,OAAOI,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perty","IsNumberString","Config","OptionalProps","Property","OrmProperty","ApiHideProperty","getSchemaPath","MetadataStorage","ReferenceKind","BigIntType","applyDecorators","IsBoolean","IsCurrency","IsInt","IsISO8601","IsNumber","IsString","MaxLength","MinLength","R","applyDecorators","Type","ClassType","IsNotEmpty","ValidateNested","R","MODEL_METADATA_KEY","PROPERTY_METADATA_KEY","ModelRegister","setModel","target","metadata","Reflect","defineMetadata","getModel","getMetadata","setProperty","propertyName","prototype","getProperty","copyProperty","source","modelMetadata","addModel","propertyKeys","includes","push","kind","addProperty","propertyMetadata","type","omit","isModel","getModelPropertyKeys","getProperties","map","propertyKey","filter","property","Model","target","ModelRegister","addModel","CustomError","Exception","CustomError","message","Object","defineProperty","value","TypeException","Exception","message","Object","defineProperty","value","IsOptional","ApiProperty","ApiPropertyOptional","Property","options","target","propertyKey","TypeException","optional","IsOptional","schema","ApiPropertyOptional","ApiProperty","ModelRegister","addProperty","RELATION_METADATA_KEY","Relation","metadata","target","propertyKey","ModelRegister","addProperty","relation","Nested","options","target","propertyKey","Property","kind","List","options","target","propertyKey","Property","kind","NestedProperty","type","options","decorators","ValidateNested","each","ClassType","schema","propertyMetadata","pick","push","List","Nested","optional","IsNotEmpty","message","applyDecorators","applyDecorators","Allow","ReferencePropertiesMetadataKey","ReferenceProperty","entity","applyDecorators","Allow","NestedProperty","EntityRefType","relation","kind","type","registerDecorator","HAS_ANY_KEY","HasAnyKey","keys","validationOptions","object","propertyName","registerDecorator","name","target","constraints","options","validator","validate","value","key","defaultMessage","join","registerDecorator","validate","MATCH_JSON_SCHEMA","MatchJsonSchema","schema","validationOptions","object","propertyName","registerDecorator","name","target","constraints","options","validator","validate","value","args","results","valid","defaultMessage","Query","ApiQuery","BadRequestException","Injectable","InternalServerErrorException","mixedOffsetAndCursorError","mixedNextAndLastCursorError","BukaPageQueryValidationPipe","options","optional","transform","value","metadata","type","InternalServerErrorException","page","BadRequestException","mode","limit","parseInt","offset","isNaN","after","first","before","last","OffsetPageSchema","type","properties","limit","offset","required","NextCursorPageSchema","after","first","PreviousCursorPageSchema","before","last","PageQuery","mode","target","propertyKey","parameterIndex","Error","descriptor","Reflect","getOwnPropertyDescriptor","ApiQuery","name","schema","oneOf","Query","BukaPageQueryValidationPipe","OptionalPageQuery","optional","Logger","logger","ApiScalarEntityProperty","options","meta","columnType","toLowerCase","startsWith","length","Number","match","VarcharProperty","CharProperty","TextProperty","MoneyProperty","IntProperty","TinyintProperty","DoubleProperty","DecimalProperty","DatetimeProperty","type","BooleanProperty","BigIntProperty","BigIntType","logger","warn","name","getEnumOptions","enum","items","values","enumName","schema","decorators","unverified","push","IsString","MaxLength","Property","String","optional","nullable","maxLength","required","description","comment","applyDecorators","MinLength","minimum","IsCurrency","symbol","format","mode","metaType","Error","IsInt","unsigned","maximum","IsNumber","undefined","scale","maxDecimalPlaces","IsISO8601","Date","IsBoolean","Boolean","R","ModelPropertiesAccessor","DECORATORS","METADATA_FACTORY_NAME","clonePluginMetadataFactory","ApiProperty","isFunction","isBuiltInType","SchemaObjectMetadata","modelPropertiesAccessor","ModelPropertiesAccessor","cloneMetadata","target","source","keys","clonePluginMetadataFactory","prototype","metadata","pick","propertyKey","getMetadataOfDecorator","ApiProperty","classRef","Reflect","getMetadata","DECORATORS","API_MODEL_PROPERTIES","props","getModelProperties","fromPairs","map","prop","getMetadataOfPlugin","propsInPlugin","METADATA_FACTORY_NAME","propsInDecorator","metadataMap","mergeRight","isLazyTypeFunc","type","isFunction","name","R","EntityMetadata","MetadataStorage","getMetadata","classRef","metadatas","parent","meta","MetadataStorage","getMetadataFromDecorator","EntityMetadata","push","Object","getPrototypeOf","prototype","unnest","map","values","properties","inheritTransformationMetadata","inheritValidationMetadata","EntityRefTypeClassMetadataPropertyKey","Symbol","storage","WeakMap","EntityRefType","classRef","has","get","properties","getMetadata","primaryProperties","filter","prop","primary","map","name","length","Error","EntityRefTypeClass","SwaggerUtils","cloneMetadata","inheritValidationMetadata","key","includes","inheritTransformationMetadata","set","ApiEntityProperty","options","target","propertyKey","meta","MetadataStorage","getMetadataFromDecorator","prop","properties","hidden","ApiHideProperty","kind","ReferenceKind","EMBEDDED","SCALAR","ApiScalarEntityProperty","schema","getType","ent","entity","eager","EntityRefType","Object","ONE_TO_ONE","MANY_TO_ONE","Property","type","relation","description","comment","required","nullable","ONE_TO_MANY","MANY_TO_MANY","NestedProperty","each","optional","items","getSchemaPath","Relation","EntityProperty","options","target","propertyKey","TypeError","OrmProperty","ApiEntityProperty","example","TimestampedEntity","Config","OptionalProps","createdAt","Date","updatedAt","type","onCreate","defaultRaw","comment","onUpdate","BaseEntity","TimestampedEntity","PrimaryKeyProp","id","type","description","example","required","BigIntType","comment","inheritTransformationMetadata","inheritValidationMetadata","wrap","EntityDtoType","entity","properties","getMetadata","length","Error","name","keys","filter","prop","hidden","kind","ref","map","EntityDtoTypeClass","from","dto","json","wrap","toPOJO","property","inheritValidationMetadata","key","includes","inheritTransformationMetadata","ApiPropertyUtils","cloneMetadata","ModelRegister","copyProperty","Enum","EntityEnum","options","target","propertyKey","TypeError","Enum","ApiEntityProperty","example","enumName","Property","EntityTransient","Property","persist","OneToOne","OrmOneToOne","EntityOneToOne","entity","mappedByOrOptions","options","target","propertyKey","TypeError","OrmOneToOne","ApiEntityProperty","OneToMany","OrmOneToMany","EntityOneToMany","options","target","propertyKey","TypeError","OrmOneToMany","ApiEntityProperty","ManyToOne","OrmManyToOne","EntityManyToOne","entity","options","target","propertyKey","TypeError","OrmManyToOne","ApiEntityProperty","ManyToMany","EntityManyToMany","entity","mappedBy","options","target","propertyKey","TypeError","ManyToMany","ApiEntityProperty","ToNumber","IsBoolean","IsNumber","IsString","R","util","Migrator","FlushMode","BadRequestException","DatabaseConfig","debug","migration","dbName","host","port","user","password","timezone","toMikroOrmOptions","config","options","forceUndefined","flushMode","FlushMode","COMMIT","serialization","forceObject","findOneOrFailHandler","entityName","where","BadRequestException","inspect","mergeDeepRight","extensions","Migrator","migrations","snapshotName","path","fileName","timestamp","allowNaN","isReferenceObject","obj","$ref","deepDereference","openapi","reference","current","stack","isReferenceObject","refPath","$ref","includes","undefined","push","parts","replace","split","next","part","forEachParameter","openapi","callback","pathItem","Object","values","paths","operation","parameters","parameter","components","deepObjectifyQueries","openapi","forEachParameter","parameter","in","schema","style","undefined","explode","isReferenceObject","deepDereference","type","MikroORM","EntityManager","ValidationPipe","Injectable","Logger","deepMap","obj","fn","Array","isArray","map","item","transformReference","em","value","metatype","entityProperties","getMetadata","primaryProperties","filter","p","primary","length","propertyKey","name","ref","getReference","wrapped","propertyKeys","key","deepTransform","ModelRegister","getModelPropertyKeys","result","propertyMetadata","getProperty","propertyValue","kind","ctor","type","EntityRefTypeClassMetadataPropertyKey","v","Object","fromEntries","entries","k","BukaValidationPipe","ValidationPipe","logger","Logger","orm","transform","metadata","withParams","options","BukaParametrizedValidationPipe","R","R","getMetadataStorage","getMetadata","source","propertyKey","metadataStorage","getMetadataStorage","arr","getTargetValidationMetadatas","grouped","groupBy","m","propertyName","result","Map","key","set","filter","item","setMetadata","target","metadata","addValidationMetadata","classTransformer","getTransformMetadata","classRef","prop","metadataStorage","defaultMetadataStorage","metadataMap","classMetadata","get","propertyMetadata","undefined","Array","isArray","setTransformMetadata","metadata","meta","target","propertyName","has","set","concat","Map","FilterQueryOperatorsMetadataKey","FilterQueryOperators","operators","length","TypeError","FilterQueryOperatorsDecorator","target","propertyKey","Reflect","defineMetadata","getFilterQueryOperators","getMetadata","ArrayMinSize","IS_OPTIONAL","IsArray","IsOptional","FilterQueryCollectionOperators","getCollectionOperators","target","propertyKey","operators","getFilterQueryOperators","prototype","filter","op","includes","FilterQueryPropertyOperators","getPropertyOperators","target","propertyKey","operators","getFilterQueryOperators","prototype","filter","op","includes","R","getSchemaPath","scalarType","type","String","Number","Boolean","$ref","getSchemaPath","swaggerMetadataToJsonSchema","metadata","base","omit","isLazyTypeFunc","getObjectSchema","classRef","properties","schema","type","propertyKey","ModelRegister","getModelPropertyKeys","propertyMetadata","getProperty","isCollection","relation","kind","isRelation","isOptional","optional","sub","operators","getCollectionOperators","operator","propertySchema","originalSchema","getMetadata","getPropertyOperators","includes","items","swaggerMetadataToJsonSchema","getFilterQuerySchema","description","name","required","createFilterQueryPropertyClassRef","classRef","propertyKey","propertyClass","FilterQueryPropertyClass","ModelRegister","addModel","propertyMetadata","getProperty","validationMetadataList","getMetadata","filter","metadata","name","IS_OPTIONAL","transformerMetadataList","getTransformMetadata","operators","getPropertyOperators","operator","includes","addProperty","kind","optional","IsArray","prototype","ArrayMinSize","ClassValidatorUtils","setMetadata","each","transformFn","ClassTransformerUtils","setTransformMetadata","FilterQueryPropertyTransformer","params","Array","isArray","value","map","v","i","arr","key","obj","IsOptional","createFilterQueryObjectClassRef","FilterQueryObjectClass","getModelPropertyKeys","isCollection","relation","isRelation","isOptional","FilterQueryCollectionClass","sub","type","getCollectionOperators","NestedProperty","HasAnyKey","getFilterQueryOperators","FilterQueryType","isModel","TypeException","properties","getProperties","isRequired","any","p","FilterQueryClass","schema","getFilterQuerySchema","PickType","SwaggerPickType","PickType","classRef","keys","ModelRegister","isModel","TypeException","PickTypeClass","SwaggerPickType","key","copyProperty","metadataKeys","Reflect","getMetadataKeys","prototype","metadataKey","metadata","getMetadata","hasMetadata","defineMetadata","OmitType","SwaggerOmitType","OmitType","classRef","keys","ModelRegister","isModel","TypeException","OmitTypeClass","SwaggerOmitType","propertyKey","getModelPropertyKeys","includes","copyProperty","metadataKeys","Reflect","getMetadataKeys","prototype","metadataKey","metadata","getMetadata","hasMetadata","defineMetadata","PartialType","SwaggerPartialType","PartialType","classRef","PartialTypeClass","SwaggerPartialType","propertyKey","ModelRegister","getModelPropertyKeys","copyProperty","metadataKeys","Reflect","getMetadataKeys","prototype","metadataKey","metadata","getMetadata","hasMetadata","defineMetadata","getOrderQueryEnum","type","enum","getOrderQueryMapSchema","classRef","properties","schema","required","propertyKey","ModelRegister","getModelPropertyKeys","propertyMetadata","getProperty","isRelation","relation","getOrderQuerySchema","orderQueryMapSchema","description","name","oneOf","items","OrderQueryType","classRef","schema","getOrderQuerySchema","OrderQueryClass","orderBy","Property","optional","prototype","MatchJsonSchema","message","OffsetPaginationRo","total","limit","offset","schema","type","description","CursorPaginationRo","total","limit","startCursor","endCursor","hasNextPage","hasPrevPage","schema","type","description","ListResponseBodyType","classRef","mode","ResponseBodyMeta","pagination","NestedProperty","CursorPaginationRo","prototype","OffsetPaginationRo","ListResponseBody","data","meta","fromSlice","slice","res","each","ResponseBodyType","classRef","ResponseBodyClass","data","from","meta","instance","Property","type","schema","prototype","Object","additionalProperties","OffsetPagination","total","limit","offset","parameters","schema","type","description","Cursor","CursorPagination","total","limit","startCursor","endCursor","hasNextPage","hasPrevPage","cursor","totalCount","length","schema","type","description","nullable","Slice","data","pagination","Symbol","iterator","item","fromOffset","total","parameters","OffsetPagination","fromCursor","cursor","CursorPagination","items","map","fn","mappedData"]}
@@ -0,0 +1,18 @@
1
+ import buka from '@buka/eslint-config';
2
+ import { defineConfig } from "eslint/config";
3
+
4
+ export default defineConfig([
5
+ {
6
+ ignores: ['dist'],
7
+ },
8
+ {
9
+ files: ["**/*.ts"],
10
+ extends: [buka.nestjs.recommended],
11
+ },
12
+ {
13
+ rules: {
14
+ '@typescript-eslint/no-explicit-any': 'off',
15
+ '@typescript-eslint/no-unsafe-function-type': 'off',
16
+ },
17
+ },
18
+ ])
@@ -0,0 +1,23 @@
1
+ import type { JestConfigWithTsJest } from 'ts-jest'
2
+ import { pathsToModuleNameMapper } from 'ts-jest'
3
+ import { compilerOptions } from './tsconfig.json'
4
+
5
+ const jestConfig: JestConfigWithTsJest = {
6
+ preset: 'ts-jest',
7
+ testMatch: [
8
+ '<rootDir>/__tests__/**/*.spec.ts',
9
+ '<rootDir>/src/**/*.spec.ts',
10
+ ],
11
+ testEnvironment: 'node',
12
+ collectCoverage: true,
13
+ collectCoverageFrom: ['./src/**'],
14
+ coverageReporters: ['text', 'cobertura'],
15
+ coveragePathIgnorePatterns: [
16
+ '.*__snapshots__/.*',
17
+ ],
18
+ setupFilesAfterEnv: ['<rootDir>/__tests__/setup.ts'],
19
+ moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths),
20
+ passWithNoTests: true,
21
+ }
22
+
23
+ export default jestConfig
package/package.json ADDED
@@ -0,0 +1,100 @@
1
+ {
2
+ "name": "@buka/nestjs-kit",
3
+ "version": "3.0.1",
4
+ "description": "An easy to use nestjs config module",
5
+ "packageManager": "pnpm@10.24.0+sha512.01ff8ae71b4419903b65c60fb2dc9d34cf8bb6e06d03bde112ef38f7a34d6904c424ba66bea5cdcf12890230bf39f9580473140ed9c946fef328b6e5238a345a",
6
+ "types": "dist/index.d.ts",
7
+ "main": "dist/index.js",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "require": "./dist/index.js",
12
+ "import": "./dist/index.mjs"
13
+ },
14
+ "./plugin": {
15
+ "types": "./dist/plugin/index.d.ts",
16
+ "require": "./dist/plugin/index.js"
17
+ }
18
+ },
19
+ "scripts": {
20
+ "build": "tsup",
21
+ "dev": "tsup --watch",
22
+ "prepare": "is-ci || husky",
23
+ "prepublishOnly": "npm run build",
24
+ "test": "jest",
25
+ "commit": "cz"
26
+ },
27
+ "keywords": [
28
+ "nestjs",
29
+ "nest",
30
+ "mikro-orm",
31
+ "mikro",
32
+ "orm",
33
+ "mikroorm",
34
+ "pagination",
35
+ "page",
36
+ "query",
37
+ "filter"
38
+ ],
39
+ "author": "Val.istar.Guo <val.istar.guo@gmail.com>",
40
+ "license": "MIT",
41
+ "homepage": "https://github.com/buka-lnc/npm.nestjs-type-helper/#readme",
42
+ "bugs": {
43
+ "url": "https://github.com/buka-lnc/npm.nestjs-type-helper/issues"
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "https://github.com/buka-inc/npm.nestjs-type-helper"
48
+ },
49
+ "devDependencies": {
50
+ "@buka/class-transformer-extra": "^2.1.4",
51
+ "@buka/eslint-config": "^3.0.3",
52
+ "@commitlint/cli": "^20.2.0",
53
+ "@commitlint/config-conventional": "^20.2.0",
54
+ "@jest/globals": "^30.2.0",
55
+ "@mikro-orm/core": "^6.6.2",
56
+ "@mikro-orm/migrations": "^6.6.2",
57
+ "@nestjs/common": "^11.1.11",
58
+ "@nestjs/core": "^11.1.11",
59
+ "@nestjs/mapped-types": "^2.1.0",
60
+ "@nestjs/swagger": "^11.2.3",
61
+ "@nestjs/testing": "^11.1.11",
62
+ "@swc/core": "^1.15.8",
63
+ "@types/express": "^5.0.6",
64
+ "@types/node": "^22.19.3",
65
+ "@types/object-path": "^0.11.4",
66
+ "class-transformer": "^0.5.1",
67
+ "class-validator": "^0.14.3",
68
+ "commitizen": "^4.3.1",
69
+ "cz-conventional-changelog": "^3.3.0",
70
+ "eslint": "^9.39.2",
71
+ "husky": "^9.1.7",
72
+ "is-ci": "^4.1.0",
73
+ "jest": "^30.2.0",
74
+ "jest-mock": "^30.2.0",
75
+ "ts-jest": "^29.4.6",
76
+ "ts-jest-resolver": "^2.0.1",
77
+ "ts-node": "^10.9.2",
78
+ "tsup": "^8.5.1",
79
+ "typescript": "^5.9.3"
80
+ },
81
+ "dependencies": {
82
+ "@types/ramda": "^0.31.1",
83
+ "jsonschema": "^1.5.0",
84
+ "ramda": "^0.32.0",
85
+ "ts-custom-error": "^3.3.1",
86
+ "type-fest": "^5.3.1"
87
+ },
88
+ "peerDependencies": {
89
+ "@buka/class-transformer-extra": "^2",
90
+ "@mikro-orm/core": "^6",
91
+ "@mikro-orm/migrations": "^6",
92
+ "@nestjs/common": "^10 || ^11",
93
+ "@nestjs/core": "^10 || ^11",
94
+ "@nestjs/mapped-types": "^2",
95
+ "@nestjs/swagger": "^10 || ^11",
96
+ "@types/express": "*",
97
+ "class-transformer": "*",
98
+ "class-validator": "*"
99
+ }
100
+ }
@@ -0,0 +1,4 @@
1
+ onlyBuiltDependencies:
2
+ - '@nestjs/core'
3
+ - '@swc/core'
4
+ - esbuild