@rtpaulino/entity 0.28.3 → 0.28.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/property.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-wrapper-object-types */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { isEqual } from 'lodash-es';\nimport {\n AnyCtor,\n type CtorLike,\n type InstanceOfCtorLike,\n PROPERTY_METADATA_KEY,\n PROPERTY_OPTIONS_METADATA_KEY,\n POLYMORPHIC_PROPERTY_METADATA_KEY,\n PropertyOptions,\n} from './types.js';\nimport {\n enumValidator,\n intValidator,\n minLengthValidator,\n maxLengthValidator,\n patternValidator,\n minValidator,\n maxValidator,\n arrayMinLengthValidator,\n arrayMaxLengthValidator,\n} from './validators.js';\nimport { PolymorphicRegistry } from './polymorphic-registry.js';\nimport { deserializeNumberFromBigInt } from './primitive-deserializers.js';\n\n/**\n * Property decorator that marks class properties with metadata.\n * This decorator can be used to identify and track properties within classes.\n *\n * @param options - Configuration for the property (type is required)\n *\n * @example\n * class User {\n * @Property({ type: () => String })\n * name: string;\n *\n * @Property({ type: () => String, equals: (a, b) => a.toLowerCase() === b.toLowerCase() })\n * email: string;\n *\n * @Property({ type: () => Number })\n * age: number;\n * }\n */\nexport function Property<T, C extends CtorLike<T>>(\n options: PropertyOptions<T, C>,\n): PropertyDecorator {\n return (target: object, propertyKey: string | symbol): void => {\n if (typeof propertyKey !== 'string') {\n return;\n }\n\n const existingProperties: string[] =\n Reflect.getOwnMetadata(PROPERTY_METADATA_KEY, target) || [];\n\n if (!existingProperties.includes(propertyKey)) {\n existingProperties.push(propertyKey);\n }\n\n Reflect.defineMetadata(PROPERTY_METADATA_KEY, existingProperties, target);\n\n if (options.passthrough === true) {\n if (options.array === true) {\n throw new Error(\n `Property '${propertyKey}' has passthrough: true and array: true. Passthrough cannot be combined with array.`,\n );\n }\n if (options.optional === true) {\n throw new Error(\n `Property '${propertyKey}' has passthrough: true and optional: true. Passthrough cannot be combined with optional.`,\n );\n }\n if (options.sparse === true) {\n throw new Error(\n `Property '${propertyKey}' has passthrough: true and sparse: true. Passthrough cannot be combined with sparse.`,\n );\n }\n if (\n options.serialize !== undefined ||\n options.deserialize !== undefined\n ) {\n throw new Error(\n `Property '${propertyKey}' has passthrough: true and custom serialize/deserialize functions. Passthrough cannot be combined with serialize or deserialize.`,\n );\n }\n }\n\n if (options.sparse === true && options.array !== true) {\n throw new Error(\n `Property '${propertyKey}' has sparse: true but array is not true. The sparse option only applies to arrays.`,\n );\n }\n\n if (options.arrayValidators && options.array !== true) {\n throw new Error(\n `Property '${propertyKey}' has arrayValidators defined but array is not true. The arrayValidators option only applies to arrays.`,\n );\n }\n\n // Validate serialize/deserialize pairing\n const hasSerialize = options.serialize !== undefined;\n const hasDeserialize = options.deserialize !== undefined;\n if (hasSerialize !== hasDeserialize) {\n throw new Error(\n `Property '${propertyKey}' must define both serialize and deserialize functions, or neither. Found only ${hasSerialize ? 'serialize' : 'deserialize'}.`,\n );\n }\n\n const existingOptions: Record<\n string,\n PropertyOptions<any, any>\n > = Reflect.getOwnMetadata(PROPERTY_OPTIONS_METADATA_KEY, target) || {};\n\n existingOptions[propertyKey] = options;\n\n Reflect.defineMetadata(\n PROPERTY_OPTIONS_METADATA_KEY,\n existingOptions,\n target,\n );\n };\n}\n\n/**\n * Helper decorator for string properties\n * @example\n * class User {\n * @StringProperty()\n * name!: string;\n *\n * @StringProperty({ optional: true })\n * nickname?: string;\n *\n * @StringProperty({ minLength: 3, maxLength: 50 })\n * username!: string;\n *\n * @StringProperty({ pattern: /^[a-z]+$/ })\n * slug!: string;\n * }\n */\n/**\n * Creates property options for a string property with optional validation\n * Used internally by StringProperty decorator and Props.String helper\n */\nexport function stringPropertyOptions(\n options?: Omit<PropertyOptions<string, StringConstructor>, 'type'> & {\n minLength?: number;\n maxLength?: number;\n pattern?: RegExp;\n patternMessage?: string;\n },\n): PropertyOptions<string, StringConstructor> {\n const validators = [...(options?.validators || [])];\n\n if (options?.minLength !== undefined) {\n validators.unshift(minLengthValidator(options.minLength));\n }\n if (options?.maxLength !== undefined) {\n validators.unshift(maxLengthValidator(options.maxLength));\n }\n if (options?.pattern !== undefined) {\n validators.unshift(\n patternValidator(options.pattern, options.patternMessage),\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { minLength, maxLength, pattern, patternMessage, ...restOptions } =\n options || {};\n\n return {\n ...restOptions,\n type: () => String,\n validators: validators.length > 0 ? validators : undefined,\n };\n}\n\n/**\n * Helper decorator for string properties\n * @example\n * class User {\n * @StringProperty()\n * name!: string;\n *\n * @StringProperty({ optional: true })\n * nickname?: string;\n *\n * @StringProperty({ minLength: 2, maxLength: 50 })\n * username!: string;\n *\n * @StringProperty({ pattern: /^[a-z]+$/, patternMessage: 'Must be lowercase letters only' })\n * slug!: string;\n * }\n */\nexport function StringProperty(\n options?: Omit<PropertyOptions<string, StringConstructor>, 'type'> & {\n minLength?: number;\n maxLength?: number;\n pattern?: RegExp;\n patternMessage?: string;\n },\n): PropertyDecorator {\n return Property(stringPropertyOptions(options));\n}\n\n/**\n * Creates property options for an enum property\n * Used internally by EnumProperty decorator and Props.Enum helper\n */\nexport function enumPropertyOptions<T extends Record<string, string>>(\n enumType: T,\n options?: Omit<PropertyOptions<string, StringConstructor>, 'type'>,\n): PropertyOptions<string, StringConstructor> {\n const validators = options?.validators\n ? [enumValidator(enumType), ...options.validators]\n : [enumValidator(enumType)];\n\n return { ...options, type: () => String, validators };\n}\n\n/**\n * Helper decorator for enum properties (string enums)\n * Validates that the string value matches one of the enum values\n * @param enumType - The enum object (e.g., MyEnum)\n * @param options - Additional property options\n * @example\n * enum Status {\n * Active = 'active',\n * Inactive = 'inactive'\n * }\n *\n * class User {\n * @EnumProperty(Status)\n * status!: Status;\n *\n * @EnumProperty(Status, { optional: true })\n * previousStatus?: Status;\n * }\n */\nexport function EnumProperty<T extends Record<string, string>>(\n enumType: T,\n options?: Omit<PropertyOptions<string, StringConstructor>, 'type'>,\n): PropertyDecorator {\n return Property(enumPropertyOptions(enumType, options));\n}\n\n/**\n * Creates property options for a number property\n * Used internally by NumberProperty decorator and Props.Number helper\n */\nexport function numberPropertyOptions(\n options?: Omit<PropertyOptions<number, NumberConstructor>, 'type'> & {\n min?: number;\n max?: number;\n\n /**\n * When `true`, `bigint` values and integer-formatted strings (e.g. `\"-42\"`) will\n * be coerced to `number` during deserialization.\n *\n * @warning Information may be lost if the `BigInt` value exceeds the safe integer\n * range for `number` (`Number.MAX_SAFE_INTEGER` / `Number.MIN_SAFE_INTEGER`).\n */\n parseBigInt?: boolean;\n },\n): PropertyOptions<number, NumberConstructor> {\n const validators = [...(options?.validators || [])];\n\n if (options?.min !== undefined) {\n validators.unshift(minValidator(options.min));\n }\n if (options?.max !== undefined) {\n validators.unshift(maxValidator(options.max));\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { min, max, parseBigInt, ...restOptions } = options || {};\n\n const deserialize = parseBigInt ? deserializeNumberFromBigInt : undefined;\n\n return {\n ...restOptions,\n type: () => Number,\n validators: validators.length > 0 ? validators : undefined,\n ...(deserialize ? { serialize: (v: number) => v, deserialize } : {}),\n };\n}\n\n/**\n * Helper decorator for number properties\n * @example\n * class User {\n * @NumberProperty()\n * age!: number;\n *\n * @NumberProperty({ optional: true })\n * score?: number;\n *\n * @NumberProperty({ min: 0, max: 100 })\n * percentage!: number;\n * }\n */\nexport function NumberProperty(\n options?: Omit<PropertyOptions<number, NumberConstructor>, 'type'> & {\n min?: number;\n max?: number;\n /**\n * When `true`, `bigint` values and integer-formatted strings (e.g. `\"-42\"`) will\n * be coerced to `number` during deserialization.\n *\n * @warning Information may be lost if the `BigInt` value exceeds the safe integer\n * range for `number` (`Number.MAX_SAFE_INTEGER` / `Number.MIN_SAFE_INTEGER`).\n */\n parseBigInt?: boolean;\n },\n): PropertyDecorator {\n return Property(numberPropertyOptions(options));\n}\n\n/**\n * Creates property options for an integer property\n * Used internally by IntProperty decorator and Props.Int helper\n */\nexport function intPropertyOptions(\n options?: Omit<PropertyOptions<number, NumberConstructor>, 'type'> & {\n min?: number;\n max?: number;\n /**\n * When `true`, `bigint` values and integer-formatted strings (e.g. `\"-42\"`) will\n * be coerced to `number` during deserialization.\n *\n * @warning Information may be lost if the `BigInt` value exceeds the safe integer\n * range for `number` (`Number.MAX_SAFE_INTEGER` / `Number.MIN_SAFE_INTEGER`).\n */\n parseBigInt?: boolean;\n },\n): PropertyOptions<number, NumberConstructor> {\n const validators = [...(options?.validators || [])];\n\n if (options?.min !== undefined) {\n validators.unshift(minValidator(options.min));\n }\n if (options?.max !== undefined) {\n validators.unshift(maxValidator(options.max));\n }\n\n validators.unshift(intValidator());\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { min, max, parseBigInt, ...restOptions } = options || {};\n\n const deserialize = parseBigInt ? deserializeNumberFromBigInt : undefined;\n\n return {\n ...restOptions,\n type: () => Number,\n validators: validators.length > 0 ? validators : undefined,\n ...(deserialize ? { serialize: (v: number) => v, deserialize } : {}),\n };\n}\n\n/**\n * Helper decorator for integer properties\n * Validates that the number is an integer (no decimal places)\n * @example\n * class User {\n * @IntProperty()\n * age!: number;\n *\n * @IntProperty({ optional: true })\n * count?: number;\n *\n * @IntProperty({ min: 0, max: 100 })\n * percentage!: number;\n * }\n */\nexport function IntProperty(\n options?: Omit<PropertyOptions<number, NumberConstructor>, 'type'> & {\n min?: number;\n max?: number;\n /**\n * When `true`, `bigint` values and integer-formatted strings (e.g. `\"-42\"`) will\n * be coerced to `number` during deserialization.\n *\n * @warning Information may be lost if the `BigInt` value exceeds the safe integer\n * range for `number` (`Number.MAX_SAFE_INTEGER` / `Number.MIN_SAFE_INTEGER`).\n */\n parseBigInt?: boolean;\n },\n): PropertyDecorator {\n return Property(intPropertyOptions(options));\n}\n\n/**\n * Creates property options for a boolean property\n * Used internally by BooleanProperty decorator and Props.Boolean helper\n */\nexport function booleanPropertyOptions(\n options?: Omit<PropertyOptions<boolean, BooleanConstructor>, 'type'>,\n): PropertyOptions<boolean, BooleanConstructor> {\n return { ...options, type: () => Boolean };\n}\n\n/**\n * Helper decorator for boolean properties\n * @example\n * class User {\n * @BooleanProperty()\n * active!: boolean;\n *\n * @BooleanProperty({ optional: true })\n * verified?: boolean;\n * }\n */\nexport function BooleanProperty(\n options?: Omit<PropertyOptions<boolean, BooleanConstructor>, 'type'>,\n): PropertyDecorator {\n return Property(booleanPropertyOptions(options));\n}\n\n/**\n * Creates property options for a Date property\n * Used internally by DateProperty decorator and Props.Date helper\n */\nexport function datePropertyOptions(\n options?: Omit<PropertyOptions<Date, DateConstructor>, 'type'>,\n): PropertyOptions<Date, DateConstructor> {\n return { ...options, type: () => Date };\n}\n\n/**\n * Helper decorator for Date properties\n * @example\n * class User {\n * @DateProperty()\n * createdAt!: Date;\n *\n * @DateProperty({ optional: true })\n * deletedAt?: Date;\n * }\n */\nexport function DateProperty(\n options?: Omit<PropertyOptions<Date, DateConstructor>, 'type'>,\n): PropertyDecorator {\n return Property(datePropertyOptions(options));\n}\n\n/**\n * Creates property options for a BigInt property\n * Used internally by BigIntProperty decorator and Props.BigInt helper\n */\nexport function bigIntPropertyOptions(\n options?: Omit<PropertyOptions<bigint, BigIntConstructor>, 'type'>,\n): PropertyOptions<bigint, BigIntConstructor> {\n return { ...options, type: () => BigInt };\n}\n\n/**\n * Helper decorator for BigInt properties\n * @example\n * class User {\n * @BigIntProperty()\n * id!: bigint;\n *\n * @BigIntProperty({ optional: true })\n * balance?: bigint;\n * }\n */\nexport function BigIntProperty(\n options?: Omit<PropertyOptions<bigint, BigIntConstructor>, 'type'>,\n): PropertyDecorator {\n return Property(bigIntPropertyOptions(options));\n}\n\n/**\n * Creates property options for an entity property\n * Used internally by EntityProperty decorator and Props.Entity helper\n */\nexport function entityPropertyOptions<\n T,\n C extends AnyCtor<T> & { new (data: any): T },\n>(\n type: () => C,\n options?: Omit<PropertyOptions<T, C>, 'type'>,\n): PropertyOptions<T, C> {\n return { ...options, type };\n}\n\n/**\n * Helper decorator for entity properties\n * @example\n * class User {\n * @EntityProperty(() => Address)\n * address!: Address;\n *\n * @EntityProperty(() => Profile, { optional: true })\n * profile?: Profile;\n * }\n */\nexport function EntityProperty<\n T,\n C extends AnyCtor<T> & { new (data: any): T },\n>(\n type: () => C,\n options?: Omit<PropertyOptions<T, C>, 'type'>,\n): PropertyDecorator {\n return Property<T, C>(entityPropertyOptions(type, options));\n}\n\n/**\n * Creates property options for an array property\n * Used internally by ArrayProperty decorator and Props.Array helper\n */\nexport function arrayPropertyOptions<T, C extends CtorLike<T>>(\n type: () => C,\n options?: Omit<PropertyOptions<T, C>, 'type' | 'array'> & {\n minLength?: number;\n maxLength?: number;\n },\n): PropertyOptions<T, C> {\n const validators = [...(options?.arrayValidators || [])];\n\n if (options?.minLength !== undefined) {\n validators.unshift(arrayMinLengthValidator(options.minLength));\n }\n if (options?.maxLength !== undefined) {\n validators.unshift(arrayMaxLengthValidator(options.maxLength));\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { minLength, maxLength, ...restOptions } = options || {};\n\n return {\n ...restOptions,\n type,\n array: true,\n arrayValidators: validators.length > 0 ? validators : undefined,\n };\n}\n\n/**\n * Helper decorator for array properties\n * @example\n * class User {\n * @ArrayProperty(() => String)\n * tags!: string[];\n *\n * @ArrayProperty(() => Phone)\n * phones!: Phone[];\n *\n * @ArrayProperty(() => Number, { optional: true })\n * scores?: number[];\n *\n * @ArrayProperty(() => String, { sparse: true })\n * sparseList!: (string | null)[];\n *\n * @ArrayProperty(() => String, { minLength: 1, maxLength: 10 })\n * limitedList!: string[];\n * }\n */\nexport function ArrayProperty<T, C extends CtorLike<T>>(\n type: () => C,\n options?: Omit<PropertyOptions<T, C>, 'type' | 'array'> & {\n minLength?: number;\n maxLength?: number;\n },\n): PropertyDecorator {\n const arrayValidators = [...(options?.arrayValidators || [])];\n\n if (options?.minLength !== undefined) {\n arrayValidators.unshift(arrayMinLengthValidator(options.minLength));\n }\n if (options?.maxLength !== undefined) {\n arrayValidators.unshift(arrayMaxLengthValidator(options.maxLength));\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { minLength, maxLength, ...restOptions } = options || {};\n\n return Property({\n ...restOptions,\n type,\n array: true,\n arrayValidators: arrayValidators.length > 0 ? arrayValidators : undefined,\n });\n}\n\n/**\n * Creates property options for a passthrough property\n * Used internally by PassthroughProperty decorator and Props.Passthrough helper\n */\nexport function passthroughPropertyOptions(\n options?: Omit<PropertyOptions, 'type' | 'passthrough'>,\n): PropertyOptions {\n return { ...options, type: () => Object, passthrough: true };\n}\n\n/**\n * Helper decorator for passthrough properties that bypass type validation.\n * Use this for generic types like Record<string, unknown>, any, or custom objects.\n * @example\n * class Config {\n * @PassthroughProperty()\n * metadata!: Record<string, unknown>;\n *\n * @PassthroughProperty()\n * customData!: any;\n * }\n */\nexport function PassthroughProperty(): PropertyDecorator {\n return Property(passthroughPropertyOptions());\n}\n\n/**\n * Property options for stringifiable types (types with toString() and static parse())\n * Used internally by StringifiableProperty decorator and EntityProps.Stringifiable helper\n */\nexport function stringifiablePropertyOptions<\n T extends { equals?(other: T): boolean; toString(): string },\n C extends CtorLike<T> & { parse(value: string): T },\n>(\n type: () => C,\n options?: Omit<\n PropertyOptions<T, C>,\n 'serialize' | 'deserialize' | 'passthrough' | 'type' | 'equals'\n >,\n): PropertyOptions<T, C> {\n return {\n ...options,\n type,\n equals: (a, b) => (a.equals ? a.equals(b) : a.toString() === b.toString()),\n serialize: (value) => value.toString(),\n deserialize: (value) => {\n if (typeof value === 'string') {\n return type().parse(value) as InstanceOfCtorLike<C>;\n }\n throw new Error(`Invalid value ${type().name}: ${String(value)}`);\n },\n };\n}\n\nexport const StringifiableProperty = <\n T extends { equals?(other: T): boolean; toString(): string },\n C extends CtorLike<T> & { parse(value: string): T },\n>(\n type: () => C,\n data: Omit<\n PropertyOptions<T, C>,\n 'serialize' | 'deserialize' | 'passthrough' | 'type' | 'equals'\n > = {},\n): PropertyDecorator =>\n Property<T, C>(stringifiablePropertyOptions(type, data));\n\nexport const SerializableProperty = <\n T extends { equals?(other: T): boolean; toJSON(): unknown },\n C extends CtorLike<T> & { parse(value: unknown): T },\n>(\n type: () => C,\n data: Omit<\n PropertyOptions<T, C>,\n 'serialize' | 'deserialize' | 'passthrough' | 'type' | 'equals'\n > = {},\n) =>\n Property({\n ...data,\n type,\n equals: (a: T, b: T) =>\n a.equals ? a.equals(b) : isEqual(a.toJSON(), b.toJSON()),\n serialize: (value: T) => value.toJSON(),\n deserialize: (value: unknown) => {\n return type().parse(value) as InstanceOfCtorLike<C>;\n },\n });\n\n/**\n * Helper decorator for discriminated entity properties.\n * The entity type is determined at runtime using a discriminator property.\n * Unlike EntityProperty, this does not require the type parameter upfront.\n *\n * @param options - Configuration for the discriminated property\n *\n * @example\n * ```typescript\n * // Define entity types\n * @Entity({ name: 'Circle' })\n * class Circle {\n * @StringProperty() readonly type = 'Circle';\n * @NumberProperty() radius!: number;\n * constructor(data: Partial<Circle>) { Object.assign(this, data); }\n * }\n *\n * @Entity({ name: 'Rectangle' })\n * class Rectangle {\n * @StringProperty() readonly type = 'Rectangle';\n * @NumberProperty() width!: number;\n * @NumberProperty() height!: number;\n * constructor(data: Partial<Rectangle>) { Object.assign(this, data); }\n * }\n *\n * // Use discriminated property\n * @Entity()\n * class Drawing {\n * @DiscriminatedEntityProperty()\n * shape!: Circle | Rectangle;\n *\n * @DiscriminatedEntityProperty({ discriminatorProperty: 'entityType' })\n * item!: BaseItem;\n * }\n *\n * // When serialized, the discriminator is included inline:\n * // { shape: { __type: 'Circle', radius: 5 } }\n *\n * // When deserialized, the discriminator is used to determine the type:\n * const drawing = await EntityUtils.parse(Drawing, {\n * shape: { __type: 'Circle', radius: 5 }\n * });\n * // drawing.shape is a Circle instance\n * ```\n */\n/**\n * Creates property options for a discriminated entity property\n * Used internally by DiscriminatedEntityProperty decorator and EntityProps.DiscriminatedEntity helper\n */\nexport function discriminatedEntityPropertyOptions(\n options?: Omit<PropertyOptions<any, any>, 'type' | 'discriminated'> & {\n discriminatorProperty?: string;\n },\n): PropertyOptions<any, any> {\n const discriminatorProperty = options?.discriminatorProperty ?? '__type';\n\n return {\n ...options,\n discriminated: true,\n discriminatorProperty,\n };\n}\n\nexport function DiscriminatedEntityProperty(\n options?: Omit<PropertyOptions<any, any>, 'type' | 'discriminated'> & {\n discriminatorProperty?: string;\n },\n): PropertyDecorator {\n return Property(discriminatedEntityPropertyOptions(options));\n}\n\n/**\n * Decorator that marks a property as a polymorphic discriminator.\n *\n * Used for class hierarchies where an abstract base class has multiple concrete implementations,\n * and the discriminator property value determines which subclass to instantiate.\n *\n * The discriminator is a regular class property (not injected during serialization like @DiscriminatedEntityProperty).\n *\n * This decorator can be used standalone (it will treat the property as a string) or combined\n * with another type decorator for more specific typing.\n *\n * @param enumType - Optional enum, union type, or stringifiable type for the discriminator (used for validation and schema generation)\n *\n * @example\n * ```typescript\n * // With regular enum\n * enum SchemaPropertyType {\n * STRING = 'string',\n * NUMBER = 'number',\n * }\n *\n * @Entity()\n * abstract class SchemaProperty {\n * @StringProperty({ minLength: 1 })\n * name!: string;\n *\n * @PolymorphicProperty(SchemaPropertyType)\n * type!: SchemaPropertyType;\n * }\n *\n * @Entity()\n * @PolymorphicVariant(SchemaProperty, SchemaPropertyType.STRING)\n * class StringSchemaProperty extends SchemaProperty {\n * type = SchemaPropertyType.STRING;\n *\n * @IntProperty({ optional: true })\n * minLength?: number;\n * }\n *\n * // With stringifiable type\n * class Status {\n * static ACTIVE = new Status('active');\n * static INACTIVE = new Status('inactive');\n *\n * constructor(private value: string) {}\n * toString() { return this.value; }\n * static parse(value: string) {\n * if (value === 'active') return Status.ACTIVE;\n * if (value === 'inactive') return Status.INACTIVE;\n * throw new Error('Invalid status');\n * }\n * }\n *\n * @Entity()\n * abstract class Record {\n * @PolymorphicProperty(() => Status)\n * status!: Status;\n * }\n *\n * // Parsing automatically instantiates the correct subclass\n * const data = { name: 'age', type: 'string', minLength: 5 };\n * const prop = await EntityUtils.parse(SchemaProperty, data);\n * // prop is StringSchemaProperty instance\n * ```\n */\nexport function PolymorphicProperty<\n T extends { equals?(other: T): boolean; toString(): string },\n C extends CtorLike<T> & { parse(value: string): T },\n>(enumTypeOrFactory?: Record<string, string> | (() => C)): PropertyDecorator {\n return (target: object, propertyKey: string | symbol): void => {\n if (typeof propertyKey !== 'string') {\n return;\n }\n\n // Store the polymorphic property metadata\n Reflect.defineMetadata(\n POLYMORPHIC_PROPERTY_METADATA_KEY,\n propertyKey,\n target.constructor,\n );\n\n // Register in PolymorphicRegistry\n PolymorphicRegistry.setDiscriminatorProperty(\n target.constructor,\n propertyKey,\n );\n\n // Check if property already has options (from another decorator)\n const existingOptions: PropertyOptions | undefined = Reflect.getOwnMetadata(\n PROPERTY_OPTIONS_METADATA_KEY,\n target,\n propertyKey,\n );\n\n if (existingOptions) {\n // Update existing options to add polymorphic flags\n const updatedOptions: PropertyOptions = {\n ...existingOptions,\n polymorphicDiscriminator: true,\n polymorphicEnumType: enumTypeOrFactory,\n };\n\n Reflect.defineMetadata(\n PROPERTY_OPTIONS_METADATA_KEY,\n updatedOptions,\n target,\n propertyKey,\n );\n } else {\n // No existing decorator - check if it's a stringifiable type or enum\n const isStringifiable = typeof enumTypeOrFactory === 'function';\n\n if (isStringifiable) {\n // Apply StringifiableProperty decorator with polymorphic flags\n const stringifiableOpts = stringifiablePropertyOptions(\n enumTypeOrFactory as () => C,\n );\n const options: PropertyOptions = {\n ...stringifiableOpts,\n polymorphicDiscriminator: true,\n polymorphicEnumType: enumTypeOrFactory,\n };\n\n Property(options)(target, propertyKey);\n } else {\n // Apply Property decorator with string type (for enum discriminators)\n const options: PropertyOptions = {\n type: () => String,\n polymorphicDiscriminator: true,\n polymorphicEnumType: enumTypeOrFactory,\n };\n\n Property(options)(target, propertyKey);\n }\n }\n };\n}\n"],"names":["isEqual","PROPERTY_METADATA_KEY","PROPERTY_OPTIONS_METADATA_KEY","POLYMORPHIC_PROPERTY_METADATA_KEY","enumValidator","intValidator","minLengthValidator","maxLengthValidator","patternValidator","minValidator","maxValidator","arrayMinLengthValidator","arrayMaxLengthValidator","PolymorphicRegistry","deserializeNumberFromBigInt","Property","options","target","propertyKey","existingProperties","Reflect","getOwnMetadata","includes","push","defineMetadata","passthrough","array","Error","optional","sparse","serialize","undefined","deserialize","arrayValidators","hasSerialize","hasDeserialize","existingOptions","stringPropertyOptions","validators","minLength","unshift","maxLength","pattern","patternMessage","restOptions","type","String","length","StringProperty","enumPropertyOptions","enumType","EnumProperty","numberPropertyOptions","min","max","parseBigInt","Number","v","NumberProperty","intPropertyOptions","IntProperty","booleanPropertyOptions","Boolean","BooleanProperty","datePropertyOptions","Date","DateProperty","bigIntPropertyOptions","BigInt","BigIntProperty","entityPropertyOptions","EntityProperty","arrayPropertyOptions","ArrayProperty","passthroughPropertyOptions","Object","PassthroughProperty","stringifiablePropertyOptions","equals","a","b","toString","value","parse","name","StringifiableProperty","data","SerializableProperty","toJSON","discriminatedEntityPropertyOptions","discriminatorProperty","discriminated","DiscriminatedEntityProperty","PolymorphicProperty","enumTypeOrFactory","setDiscriminatorProperty","updatedOptions","polymorphicDiscriminator","polymorphicEnumType","isStringifiable","stringifiableOpts"],"mappings":"AAAA,6DAA6D,GAC7D,qDAAqD,GACrD,SAASA,OAAO,QAAQ,YAAY;AACpC,SAIEC,qBAAqB,EACrBC,6BAA6B,EAC7BC,iCAAiC,QAE5B,aAAa;AACpB,SACEC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,kBAAkB,EAClBC,gBAAgB,EAChBC,YAAY,EACZC,YAAY,EACZC,uBAAuB,EACvBC,uBAAuB,QAClB,kBAAkB;AACzB,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,2BAA2B,QAAQ,+BAA+B;AAE3E;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASC,SACd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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgEC,GACD,OAAO,SAAS6E,oBAGdC,iBAAsD;IACtD,OAAO,CAAC7E,QAAgBC;QACtB,IAAI,OAAOA,gBAAgB,UAAU;YACnC;QACF;QAEA,0CAA0C;QAC1CE,QAAQI,cAAc,CACpBrB,mCACAe,aACAD,OAAO,WAAW;QAGpB,kCAAkC;QAClCJ,oBAAoBkF,wBAAwB,CAC1C9E,OAAO,WAAW,EAClBC;QAGF,iEAAiE;QACjE,MAAMkB,kBAA+ChB,QAAQC,cAAc,CACzEnB,+BACAe,QACAC;QAGF,IAAIkB,iBAAiB;YACnB,mDAAmD;YACnD,MAAM4D,iBAAkC;gBACtC,GAAG5D,eAAe;gBAClB6D,0BAA0B;gBAC1BC,qBAAqBJ;YACvB;YAEA1E,QAAQI,cAAc,CACpBtB,+BACA8F,gBACA/E,QACAC;QAEJ,OAAO;YACL,qEAAqE;YACrE,MAAMiF,kBAAkB,OAAOL,sBAAsB;YAErD,IAAIK,iBAAiB;gBACnB,+DAA+D;gBAC/D,MAAMC,oBAAoBvB,6BACxBiB;gBAEF,MAAM9E,UAA2B;oBAC/B,GAAGoF,iBAAiB;oBACpBH,0BAA0B;oBAC1BC,qBAAqBJ;gBACvB;gBAEA/E,SAASC,SAASC,QAAQC;YAC5B,OAAO;gBACL,sEAAsE;gBACtE,MAAMF,UAA2B;oBAC/B6B,MAAM,IAAMC;oBACZmD,0BAA0B;oBAC1BC,qBAAqBJ;gBACvB;gBAEA/E,SAASC,SAASC,QAAQC;YAC5B;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/lib/property.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-wrapper-object-types */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { isEqual } from 'lodash-es';\nimport {\n AnyCtor,\n type CtorLike,\n type InstanceOfCtorLike,\n PROPERTY_METADATA_KEY,\n PROPERTY_OPTIONS_METADATA_KEY,\n POLYMORPHIC_PROPERTY_METADATA_KEY,\n PropertyOptions,\n} from './types.js';\nimport {\n enumValidator,\n intValidator,\n minLengthValidator,\n maxLengthValidator,\n patternValidator,\n minValidator,\n maxValidator,\n arrayMinLengthValidator,\n arrayMaxLengthValidator,\n} from './validators.js';\nimport { PolymorphicRegistry } from './polymorphic-registry.js';\nimport { deserializeNumberFromBigInt } from './primitive-deserializers.js';\n\n/**\n * Property decorator that marks class properties with metadata.\n * This decorator can be used to identify and track properties within classes.\n *\n * @param options - Configuration for the property (type is required)\n *\n * @example\n * class User {\n * @Property({ type: () => String })\n * name: string;\n *\n * @Property({ type: () => String, equals: (a, b) => a.toLowerCase() === b.toLowerCase() })\n * email: string;\n *\n * @Property({ type: () => Number })\n * age: number;\n * }\n */\nexport function Property<T, C extends CtorLike<T>>(\n options: PropertyOptions<T, C>,\n): PropertyDecorator {\n return (target: object, propertyKey: string | symbol): void => {\n if (typeof propertyKey !== 'string') {\n return;\n }\n\n const existingProperties: string[] =\n Reflect.getOwnMetadata(PROPERTY_METADATA_KEY, target) || [];\n\n if (!existingProperties.includes(propertyKey)) {\n existingProperties.push(propertyKey);\n }\n\n Reflect.defineMetadata(PROPERTY_METADATA_KEY, existingProperties, target);\n\n if (options.passthrough === true) {\n if (options.array === true) {\n throw new Error(\n `Property '${propertyKey}' has passthrough: true and array: true. Passthrough cannot be combined with array.`,\n );\n }\n if (options.optional === true) {\n throw new Error(\n `Property '${propertyKey}' has passthrough: true and optional: true. Passthrough cannot be combined with optional.`,\n );\n }\n if (options.sparse === true) {\n throw new Error(\n `Property '${propertyKey}' has passthrough: true and sparse: true. Passthrough cannot be combined with sparse.`,\n );\n }\n if (\n options.serialize !== undefined ||\n options.deserialize !== undefined\n ) {\n throw new Error(\n `Property '${propertyKey}' has passthrough: true and custom serialize/deserialize functions. Passthrough cannot be combined with serialize or deserialize.`,\n );\n }\n }\n\n if (options.sparse === true && options.array !== true) {\n throw new Error(\n `Property '${propertyKey}' has sparse: true but array is not true. The sparse option only applies to arrays.`,\n );\n }\n\n if (options.arrayValidators && options.array !== true) {\n throw new Error(\n `Property '${propertyKey}' has arrayValidators defined but array is not true. The arrayValidators option only applies to arrays.`,\n );\n }\n\n // Validate serialize/deserialize pairing\n const hasSerialize = options.serialize !== undefined;\n const hasDeserialize = options.deserialize !== undefined;\n if (hasSerialize !== hasDeserialize) {\n throw new Error(\n `Property '${propertyKey}' must define both serialize and deserialize functions, or neither. Found only ${hasSerialize ? 'serialize' : 'deserialize'}.`,\n );\n }\n\n const existingOptions: Record<\n string,\n PropertyOptions<any, any>\n > = Reflect.getOwnMetadata(PROPERTY_OPTIONS_METADATA_KEY, target) || {};\n\n existingOptions[propertyKey] = options;\n\n Reflect.defineMetadata(\n PROPERTY_OPTIONS_METADATA_KEY,\n existingOptions,\n target,\n );\n };\n}\n\n/**\n * Helper decorator for string properties\n * @example\n * class User {\n * @StringProperty()\n * name!: string;\n *\n * @StringProperty({ optional: true })\n * nickname?: string;\n *\n * @StringProperty({ minLength: 3, maxLength: 50 })\n * username!: string;\n *\n * @StringProperty({ pattern: /^[a-z]+$/ })\n * slug!: string;\n * }\n */\n/**\n * Creates property options for a string property with optional validation\n * Used internally by StringProperty decorator and Props.String helper\n */\nexport function stringPropertyOptions(\n options?: Omit<PropertyOptions<string, StringConstructor>, 'type'> & {\n minLength?: number;\n maxLength?: number;\n pattern?: RegExp;\n patternMessage?: string;\n },\n): PropertyOptions<string, StringConstructor> {\n const validators = [...(options?.validators || [])];\n\n if (options?.minLength !== undefined) {\n validators.unshift(minLengthValidator(options.minLength));\n }\n if (options?.maxLength !== undefined) {\n validators.unshift(maxLengthValidator(options.maxLength));\n }\n if (options?.pattern !== undefined) {\n validators.unshift(\n patternValidator(options.pattern, options.patternMessage),\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { minLength, maxLength, pattern, patternMessage, ...restOptions } =\n options || {};\n\n return {\n ...restOptions,\n type: () => String,\n validators: validators.length > 0 ? validators : undefined,\n };\n}\n\n/**\n * Helper decorator for string properties\n * @example\n * class User {\n * @StringProperty()\n * name!: string;\n *\n * @StringProperty({ optional: true })\n * nickname?: string;\n *\n * @StringProperty({ minLength: 2, maxLength: 50 })\n * username!: string;\n *\n * @StringProperty({ pattern: /^[a-z]+$/, patternMessage: 'Must be lowercase letters only' })\n * slug!: string;\n * }\n */\nexport function StringProperty(\n options?: Omit<PropertyOptions<string, StringConstructor>, 'type'> & {\n minLength?: number;\n maxLength?: number;\n pattern?: RegExp;\n patternMessage?: string;\n },\n): PropertyDecorator {\n return Property(stringPropertyOptions(options));\n}\n\n/**\n * Creates property options for an enum property\n * Used internally by EnumProperty decorator and Props.Enum helper\n */\nexport function enumPropertyOptions<T extends Record<string, string>>(\n enumType: T,\n options?: Omit<PropertyOptions<string, StringConstructor>, 'type'>,\n): PropertyOptions<string, StringConstructor> {\n const validators = options?.validators\n ? [enumValidator(enumType), ...options.validators]\n : [enumValidator(enumType)];\n\n return { ...options, type: () => String, validators };\n}\n\n/**\n * Helper decorator for enum properties (string enums)\n * Validates that the string value matches one of the enum values\n * @param enumType - The enum object (e.g., MyEnum)\n * @param options - Additional property options\n * @example\n * enum Status {\n * Active = 'active',\n * Inactive = 'inactive'\n * }\n *\n * class User {\n * @EnumProperty(Status)\n * status!: Status;\n *\n * @EnumProperty(Status, { optional: true })\n * previousStatus?: Status;\n * }\n */\nexport function EnumProperty<T extends Record<string, string>>(\n enumType: T,\n options?: Omit<PropertyOptions<string, StringConstructor>, 'type'>,\n): PropertyDecorator {\n return Property(enumPropertyOptions(enumType, options));\n}\n\n/**\n * Creates property options for a number property\n * Used internally by NumberProperty decorator and Props.Number helper\n */\nexport function numberPropertyOptions(\n options?: Omit<PropertyOptions<number, NumberConstructor>, 'type'> & {\n min?: number;\n max?: number;\n\n /**\n * When `true`, `bigint` values and integer-formatted strings (e.g. `\"-42\"`) will\n * be coerced to `number` during deserialization.\n *\n * @warning Information may be lost if the `BigInt` value exceeds the safe integer\n * range for `number` (`Number.MAX_SAFE_INTEGER` / `Number.MIN_SAFE_INTEGER`).\n */\n parseBigInt?: boolean;\n },\n): PropertyOptions<number, NumberConstructor> {\n const validators = [...(options?.validators || [])];\n\n if (options?.min !== undefined) {\n validators.unshift(minValidator(options.min));\n }\n if (options?.max !== undefined) {\n validators.unshift(maxValidator(options.max));\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { min, max, parseBigInt, ...restOptions } = options || {};\n\n const deserialize = parseBigInt ? deserializeNumberFromBigInt : undefined;\n\n return {\n ...restOptions,\n type: () => Number,\n validators: validators.length > 0 ? validators : undefined,\n ...(deserialize ? { serialize: (v: number) => v, deserialize } : {}),\n };\n}\n\n/**\n * Helper decorator for number properties\n * @example\n * class User {\n * @NumberProperty()\n * age!: number;\n *\n * @NumberProperty({ optional: true })\n * score?: number;\n *\n * @NumberProperty({ min: 0, max: 100 })\n * percentage!: number;\n * }\n */\nexport function NumberProperty(\n options?: Omit<PropertyOptions<number, NumberConstructor>, 'type'> & {\n min?: number;\n max?: number;\n /**\n * When `true`, `bigint` values and integer-formatted strings (e.g. `\"-42\"`) will\n * be coerced to `number` during deserialization.\n *\n * @warning Information may be lost if the `BigInt` value exceeds the safe integer\n * range for `number` (`Number.MAX_SAFE_INTEGER` / `Number.MIN_SAFE_INTEGER`).\n */\n parseBigInt?: boolean;\n },\n): PropertyDecorator {\n return Property(numberPropertyOptions(options));\n}\n\n/**\n * Creates property options for an integer property\n * Used internally by IntProperty decorator and Props.Int helper\n */\nexport function intPropertyOptions(\n options?: Omit<PropertyOptions<number, NumberConstructor>, 'type'> & {\n min?: number;\n max?: number;\n /**\n * When `true`, `bigint` values and integer-formatted strings (e.g. `\"-42\"`) will\n * be coerced to `number` during deserialization.\n *\n * @warning Information may be lost if the `BigInt` value exceeds the safe integer\n * range for `number` (`Number.MAX_SAFE_INTEGER` / `Number.MIN_SAFE_INTEGER`).\n */\n parseBigInt?: boolean;\n },\n): PropertyOptions<number, NumberConstructor> {\n const validators = [...(options?.validators || [])];\n\n if (options?.min !== undefined) {\n validators.unshift(minValidator(options.min));\n }\n if (options?.max !== undefined) {\n validators.unshift(maxValidator(options.max));\n }\n\n validators.unshift(intValidator());\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { min, max, parseBigInt, ...restOptions } = options || {};\n\n const deserialize = parseBigInt ? deserializeNumberFromBigInt : undefined;\n\n return {\n ...restOptions,\n type: () => Number,\n validators: validators.length > 0 ? validators : undefined,\n ...(deserialize ? { serialize: (v: number) => v, deserialize } : {}),\n };\n}\n\n/**\n * Helper decorator for integer properties\n * Validates that the number is an integer (no decimal places)\n * @example\n * class User {\n * @IntProperty()\n * age!: number;\n *\n * @IntProperty({ optional: true })\n * count?: number;\n *\n * @IntProperty({ min: 0, max: 100 })\n * percentage!: number;\n * }\n */\nexport function IntProperty(\n options?: Omit<PropertyOptions<number, NumberConstructor>, 'type'> & {\n min?: number;\n max?: number;\n /**\n * When `true`, `bigint` values and integer-formatted strings (e.g. `\"-42\"`) will\n * be coerced to `number` during deserialization.\n *\n * @warning Information may be lost if the `BigInt` value exceeds the safe integer\n * range for `number` (`Number.MAX_SAFE_INTEGER` / `Number.MIN_SAFE_INTEGER`).\n */\n parseBigInt?: boolean;\n },\n): PropertyDecorator {\n return Property(intPropertyOptions(options));\n}\n\n/**\n * Creates property options for a boolean property\n * Used internally by BooleanProperty decorator and Props.Boolean helper\n */\nexport function booleanPropertyOptions(\n options?: Omit<PropertyOptions<boolean, BooleanConstructor>, 'type'>,\n): PropertyOptions<boolean, BooleanConstructor> {\n return { ...options, type: () => Boolean };\n}\n\n/**\n * Helper decorator for boolean properties\n * @example\n * class User {\n * @BooleanProperty()\n * active!: boolean;\n *\n * @BooleanProperty({ optional: true })\n * verified?: boolean;\n * }\n */\nexport function BooleanProperty(\n options?: Omit<PropertyOptions<boolean, BooleanConstructor>, 'type'>,\n): PropertyDecorator {\n return Property(booleanPropertyOptions(options));\n}\n\n/**\n * Creates property options for a Date property\n * Used internally by DateProperty decorator and Props.Date helper\n */\nexport function datePropertyOptions(\n options?: Omit<PropertyOptions<Date, DateConstructor>, 'type'>,\n): PropertyOptions<Date, DateConstructor> {\n return { ...options, type: () => Date };\n}\n\n/**\n * Helper decorator for Date properties\n * @example\n * class User {\n * @DateProperty()\n * createdAt!: Date;\n *\n * @DateProperty({ optional: true })\n * deletedAt?: Date;\n * }\n */\nexport function DateProperty(\n options?: Omit<PropertyOptions<Date, DateConstructor>, 'type'>,\n): PropertyDecorator {\n return Property(datePropertyOptions(options));\n}\n\n/**\n * Creates property options for a BigInt property\n * Used internally by BigIntProperty decorator and Props.BigInt helper\n */\nexport function bigIntPropertyOptions(\n options?: Omit<PropertyOptions<bigint, BigIntConstructor>, 'type'>,\n): PropertyOptions<bigint, BigIntConstructor> {\n return { ...options, type: () => BigInt };\n}\n\n/**\n * Helper decorator for BigInt properties\n * @example\n * class User {\n * @BigIntProperty()\n * id!: bigint;\n *\n * @BigIntProperty({ optional: true })\n * balance?: bigint;\n * }\n */\nexport function BigIntProperty(\n options?: Omit<PropertyOptions<bigint, BigIntConstructor>, 'type'>,\n): PropertyDecorator {\n return Property(bigIntPropertyOptions(options));\n}\n\n/**\n * Creates property options for a Buffer property\n * Used internally by BufferProperty decorator and Props.Buffer helper\n */\nexport function bufferPropertyOptions(\n options?: Omit<PropertyOptions<Buffer, BufferConstructor>, 'type'>,\n): PropertyOptions<Buffer, BufferConstructor> {\n return { ...options, type: () => Buffer };\n}\n\n/**\n * Helper decorator for Buffer properties.\n * Serialized to JSON as a base64 string; deserialized from a base64 string,\n * a Buffer or a Uint8Array.\n * @example\n * class Document {\n * @BufferProperty()\n * content!: Buffer;\n *\n * @BufferProperty({ optional: true })\n * thumbnail?: Buffer;\n * }\n */\nexport function BufferProperty(\n options?: Omit<PropertyOptions<Buffer, BufferConstructor>, 'type'>,\n): PropertyDecorator {\n return Property(bufferPropertyOptions(options));\n}\n\n/**\n * Creates property options for an entity property\n * Used internally by EntityProperty decorator and Props.Entity helper\n */\nexport function entityPropertyOptions<\n T,\n C extends AnyCtor<T> & { new (data: any): T },\n>(\n type: () => C,\n options?: Omit<PropertyOptions<T, C>, 'type'>,\n): PropertyOptions<T, C> {\n return { ...options, type };\n}\n\n/**\n * Helper decorator for entity properties\n * @example\n * class User {\n * @EntityProperty(() => Address)\n * address!: Address;\n *\n * @EntityProperty(() => Profile, { optional: true })\n * profile?: Profile;\n * }\n */\nexport function EntityProperty<\n T,\n C extends AnyCtor<T> & { new (data: any): T },\n>(\n type: () => C,\n options?: Omit<PropertyOptions<T, C>, 'type'>,\n): PropertyDecorator {\n return Property<T, C>(entityPropertyOptions(type, options));\n}\n\n/**\n * Creates property options for an array property\n * Used internally by ArrayProperty decorator and Props.Array helper\n */\nexport function arrayPropertyOptions<T, C extends CtorLike<T>>(\n type: () => C,\n options?: Omit<PropertyOptions<T, C>, 'type' | 'array'> & {\n minLength?: number;\n maxLength?: number;\n },\n): PropertyOptions<T, C> {\n const validators = [...(options?.arrayValidators || [])];\n\n if (options?.minLength !== undefined) {\n validators.unshift(arrayMinLengthValidator(options.minLength));\n }\n if (options?.maxLength !== undefined) {\n validators.unshift(arrayMaxLengthValidator(options.maxLength));\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { minLength, maxLength, ...restOptions } = options || {};\n\n return {\n ...restOptions,\n type,\n array: true,\n arrayValidators: validators.length > 0 ? validators : undefined,\n };\n}\n\n/**\n * Helper decorator for array properties\n * @example\n * class User {\n * @ArrayProperty(() => String)\n * tags!: string[];\n *\n * @ArrayProperty(() => Phone)\n * phones!: Phone[];\n *\n * @ArrayProperty(() => Number, { optional: true })\n * scores?: number[];\n *\n * @ArrayProperty(() => String, { sparse: true })\n * sparseList!: (string | null)[];\n *\n * @ArrayProperty(() => String, { minLength: 1, maxLength: 10 })\n * limitedList!: string[];\n * }\n */\nexport function ArrayProperty<T, C extends CtorLike<T>>(\n type: () => C,\n options?: Omit<PropertyOptions<T, C>, 'type' | 'array'> & {\n minLength?: number;\n maxLength?: number;\n },\n): PropertyDecorator {\n const arrayValidators = [...(options?.arrayValidators || [])];\n\n if (options?.minLength !== undefined) {\n arrayValidators.unshift(arrayMinLengthValidator(options.minLength));\n }\n if (options?.maxLength !== undefined) {\n arrayValidators.unshift(arrayMaxLengthValidator(options.maxLength));\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { minLength, maxLength, ...restOptions } = options || {};\n\n return Property({\n ...restOptions,\n type,\n array: true,\n arrayValidators: arrayValidators.length > 0 ? arrayValidators : undefined,\n });\n}\n\n/**\n * Creates property options for a passthrough property\n * Used internally by PassthroughProperty decorator and Props.Passthrough helper\n */\nexport function passthroughPropertyOptions(\n options?: Omit<PropertyOptions, 'type' | 'passthrough'>,\n): PropertyOptions {\n return { ...options, type: () => Object, passthrough: true };\n}\n\n/**\n * Helper decorator for passthrough properties that bypass type validation.\n * Use this for generic types like Record<string, unknown>, any, or custom objects.\n * @example\n * class Config {\n * @PassthroughProperty()\n * metadata!: Record<string, unknown>;\n *\n * @PassthroughProperty()\n * customData!: any;\n * }\n */\nexport function PassthroughProperty(): PropertyDecorator {\n return Property(passthroughPropertyOptions());\n}\n\n/**\n * Property options for stringifiable types (types with toString() and static parse())\n * Used internally by StringifiableProperty decorator and EntityProps.Stringifiable helper\n */\nexport function stringifiablePropertyOptions<\n T extends { equals?(other: T): boolean; toString(): string },\n C extends CtorLike<T> & { parse(value: string): T },\n>(\n type: () => C,\n options?: Omit<\n PropertyOptions<T, C>,\n 'serialize' | 'deserialize' | 'passthrough' | 'type' | 'equals'\n >,\n): PropertyOptions<T, C> {\n return {\n ...options,\n type,\n equals: (a, b) => (a.equals ? a.equals(b) : a.toString() === b.toString()),\n serialize: (value) => value.toString(),\n deserialize: (value) => {\n if (typeof value === 'string') {\n return type().parse(value) as InstanceOfCtorLike<C>;\n }\n throw new Error(`Invalid value ${type().name}: ${String(value)}`);\n },\n };\n}\n\nexport const StringifiableProperty = <\n T extends { equals?(other: T): boolean; toString(): string },\n C extends CtorLike<T> & { parse(value: string): T },\n>(\n type: () => C,\n data: Omit<\n PropertyOptions<T, C>,\n 'serialize' | 'deserialize' | 'passthrough' | 'type' | 'equals'\n > = {},\n): PropertyDecorator =>\n Property<T, C>(stringifiablePropertyOptions(type, data));\n\nexport const SerializableProperty = <\n T extends { equals?(other: T): boolean; toJSON(): unknown },\n C extends CtorLike<T> & { parse(value: unknown): T },\n>(\n type: () => C,\n data: Omit<\n PropertyOptions<T, C>,\n 'serialize' | 'deserialize' | 'passthrough' | 'type' | 'equals'\n > = {},\n) =>\n Property({\n ...data,\n type,\n equals: (a: T, b: T) =>\n a.equals ? a.equals(b) : isEqual(a.toJSON(), b.toJSON()),\n serialize: (value: T) => value.toJSON(),\n deserialize: (value: unknown) => {\n return type().parse(value) as InstanceOfCtorLike<C>;\n },\n });\n\n/**\n * Helper decorator for discriminated entity properties.\n * The entity type is determined at runtime using a discriminator property.\n * Unlike EntityProperty, this does not require the type parameter upfront.\n *\n * @param options - Configuration for the discriminated property\n *\n * @example\n * ```typescript\n * // Define entity types\n * @Entity({ name: 'Circle' })\n * class Circle {\n * @StringProperty() readonly type = 'Circle';\n * @NumberProperty() radius!: number;\n * constructor(data: Partial<Circle>) { Object.assign(this, data); }\n * }\n *\n * @Entity({ name: 'Rectangle' })\n * class Rectangle {\n * @StringProperty() readonly type = 'Rectangle';\n * @NumberProperty() width!: number;\n * @NumberProperty() height!: number;\n * constructor(data: Partial<Rectangle>) { Object.assign(this, data); }\n * }\n *\n * // Use discriminated property\n * @Entity()\n * class Drawing {\n * @DiscriminatedEntityProperty()\n * shape!: Circle | Rectangle;\n *\n * @DiscriminatedEntityProperty({ discriminatorProperty: 'entityType' })\n * item!: BaseItem;\n * }\n *\n * // When serialized, the discriminator is included inline:\n * // { shape: { __type: 'Circle', radius: 5 } }\n *\n * // When deserialized, the discriminator is used to determine the type:\n * const drawing = await EntityUtils.parse(Drawing, {\n * shape: { __type: 'Circle', radius: 5 }\n * });\n * // drawing.shape is a Circle instance\n * ```\n */\n/**\n * Creates property options for a discriminated entity property\n * Used internally by DiscriminatedEntityProperty decorator and EntityProps.DiscriminatedEntity helper\n */\nexport function discriminatedEntityPropertyOptions(\n options?: Omit<PropertyOptions<any, any>, 'type' | 'discriminated'> & {\n discriminatorProperty?: string;\n },\n): PropertyOptions<any, any> {\n const discriminatorProperty = options?.discriminatorProperty ?? '__type';\n\n return {\n ...options,\n discriminated: true,\n discriminatorProperty,\n };\n}\n\nexport function DiscriminatedEntityProperty(\n options?: Omit<PropertyOptions<any, any>, 'type' | 'discriminated'> & {\n discriminatorProperty?: string;\n },\n): PropertyDecorator {\n return Property(discriminatedEntityPropertyOptions(options));\n}\n\n/**\n * Decorator that marks a property as a polymorphic discriminator.\n *\n * Used for class hierarchies where an abstract base class has multiple concrete implementations,\n * and the discriminator property value determines which subclass to instantiate.\n *\n * The discriminator is a regular class property (not injected during serialization like @DiscriminatedEntityProperty).\n *\n * This decorator can be used standalone (it will treat the property as a string) or combined\n * with another type decorator for more specific typing.\n *\n * @param enumType - Optional enum, union type, or stringifiable type for the discriminator (used for validation and schema generation)\n *\n * @example\n * ```typescript\n * // With regular enum\n * enum SchemaPropertyType {\n * STRING = 'string',\n * NUMBER = 'number',\n * }\n *\n * @Entity()\n * abstract class SchemaProperty {\n * @StringProperty({ minLength: 1 })\n * name!: string;\n *\n * @PolymorphicProperty(SchemaPropertyType)\n * type!: SchemaPropertyType;\n * }\n *\n * @Entity()\n * @PolymorphicVariant(SchemaProperty, SchemaPropertyType.STRING)\n * class StringSchemaProperty extends SchemaProperty {\n * type = SchemaPropertyType.STRING;\n *\n * @IntProperty({ optional: true })\n * minLength?: number;\n * }\n *\n * // With stringifiable type\n * class Status {\n * static ACTIVE = new Status('active');\n * static INACTIVE = new Status('inactive');\n *\n * constructor(private value: string) {}\n * toString() { return this.value; }\n * static parse(value: string) {\n * if (value === 'active') return Status.ACTIVE;\n * if (value === 'inactive') return Status.INACTIVE;\n * throw new Error('Invalid status');\n * }\n * }\n *\n * @Entity()\n * abstract class Record {\n * @PolymorphicProperty(() => Status)\n * status!: Status;\n * }\n *\n * // Parsing automatically instantiates the correct subclass\n * const data = { name: 'age', type: 'string', minLength: 5 };\n * const prop = await EntityUtils.parse(SchemaProperty, data);\n * // prop is StringSchemaProperty instance\n * ```\n */\nexport function PolymorphicProperty<\n T extends { equals?(other: T): boolean; toString(): string },\n C extends CtorLike<T> & { parse(value: string): T },\n>(enumTypeOrFactory?: Record<string, string> | (() => C)): PropertyDecorator {\n return (target: object, propertyKey: string | symbol): void => {\n if (typeof propertyKey !== 'string') {\n return;\n }\n\n // Store the polymorphic property metadata\n Reflect.defineMetadata(\n POLYMORPHIC_PROPERTY_METADATA_KEY,\n propertyKey,\n target.constructor,\n );\n\n // Register in PolymorphicRegistry\n PolymorphicRegistry.setDiscriminatorProperty(\n target.constructor,\n propertyKey,\n );\n\n // Check if property already has options (from another decorator)\n const existingOptions: PropertyOptions | undefined = Reflect.getOwnMetadata(\n PROPERTY_OPTIONS_METADATA_KEY,\n target,\n propertyKey,\n );\n\n if (existingOptions) {\n // Update existing options to add polymorphic flags\n const updatedOptions: PropertyOptions = {\n ...existingOptions,\n polymorphicDiscriminator: true,\n polymorphicEnumType: enumTypeOrFactory,\n };\n\n Reflect.defineMetadata(\n PROPERTY_OPTIONS_METADATA_KEY,\n updatedOptions,\n target,\n propertyKey,\n );\n } else {\n // No existing decorator - check if it's a stringifiable type or enum\n const isStringifiable = typeof enumTypeOrFactory === 'function';\n\n if (isStringifiable) {\n // Apply StringifiableProperty decorator with polymorphic flags\n const stringifiableOpts = stringifiablePropertyOptions(\n enumTypeOrFactory as () => C,\n );\n const options: PropertyOptions = {\n ...stringifiableOpts,\n polymorphicDiscriminator: true,\n polymorphicEnumType: enumTypeOrFactory,\n };\n\n Property(options)(target, propertyKey);\n } else {\n // Apply Property decorator with string type (for enum discriminators)\n const options: PropertyOptions = {\n type: () => String,\n polymorphicDiscriminator: true,\n polymorphicEnumType: enumTypeOrFactory,\n };\n\n Property(options)(target, propertyKey);\n }\n }\n };\n}\n"],"names":["isEqual","PROPERTY_METADATA_KEY","PROPERTY_OPTIONS_METADATA_KEY","POLYMORPHIC_PROPERTY_METADATA_KEY","enumValidator","intValidator","minLengthValidator","maxLengthValidator","patternValidator","minValidator","maxValidator","arrayMinLengthValidator","arrayMaxLengthValidator","PolymorphicRegistry","deserializeNumberFromBigInt","Property","options","target","propertyKey","existingProperties","Reflect","getOwnMetadata","includes","push","defineMetadata","passthrough","array","Error","optional","sparse","serialize","undefined","deserialize","arrayValidators","hasSerialize","hasDeserialize","existingOptions","stringPropertyOptions","validators","minLength","unshift","maxLength","pattern","patternMessage","restOptions","type","String","length","StringProperty","enumPropertyOptions","enumType","EnumProperty","numberPropertyOptions","min","max","parseBigInt","Number","v","NumberProperty","intPropertyOptions","IntProperty","booleanPropertyOptions","Boolean","BooleanProperty","datePropertyOptions","Date","DateProperty","bigIntPropertyOptions","BigInt","BigIntProperty","bufferPropertyOptions","Buffer","BufferProperty","entityPropertyOptions","EntityProperty","arrayPropertyOptions","ArrayProperty","passthroughPropertyOptions","Object","PassthroughProperty","stringifiablePropertyOptions","equals","a","b","toString","value","parse","name","StringifiableProperty","data","SerializableProperty","toJSON","discriminatedEntityPropertyOptions","discriminatorProperty","discriminated","DiscriminatedEntityProperty","PolymorphicProperty","enumTypeOrFactory","setDiscriminatorProperty","updatedOptions","polymorphicDiscriminator","polymorphicEnumType","isStringifiable","stringifiableOpts"],"mappings":"AAAA,6DAA6D,GAC7D,qDAAqD,GACrD,SAASA,OAAO,QAAQ,YAAY;AACpC,SAIEC,qBAAqB,EACrBC,6BAA6B,EAC7BC,iCAAiC,QAE5B,aAAa;AACpB,SACEC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,kBAAkB,EAClBC,gBAAgB,EAChBC,YAAY,EACZC,YAAY,EACZC,uBAAuB,EACvBC,uBAAuB,QAClB,kBAAkB;A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AAMC;oBACZsD,0BAA0B;oBAC1BC,qBAAqBJ;gBACvB;gBAEAlF,SAASC,SAASC,QAAQC;YAC5B;QACF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/test-entities.ts"],"sourcesContent":["import 'reflect-metadata';\nimport { z } from 'zod';\nimport {\n Entity,\n CollectionEntity,\n Stringifiable,\n EntityValidator,\n} from './entity.js';\nimport {\n Property,\n StringProperty,\n NumberProperty,\n IntProperty,\n BooleanProperty,\n DateProperty,\n BigIntProperty,\n EnumProperty,\n EntityProperty,\n ArrayProperty,\n PassthroughProperty,\n SerializableProperty,\n StringifiableProperty,\n} from './property.js';\nimport { InjectedProperty } from './injected-property.js';\nimport { ZodProperty } from './zod-property.js';\nimport { Problem } from './problem.js';\n\n// ============================================================================\n// SIMPLE ENTITIES WITH PRIMITIVES\n// ============================================================================\n\n/**\n * Basic entity with common primitive types\n * Features: String, Number, Boolean properties\n */\n@Entity()\nexport class TestUser {\n @StringProperty() name!: string;\n @NumberProperty() age!: number;\n @BooleanProperty() active!: boolean;\n\n constructor(data: { name: string; age: number; active: boolean }) {\n this.name = data.name;\n this.age = data.age;\n this.active = data.active;\n }\n}\n\n/**\n * Entity with different primitive combinations\n * Features: String, Number, Int, Date properties\n */\n@Entity()\nexport class TestProduct {\n @StringProperty() id!: string;\n @StringProperty() name!: string;\n @NumberProperty() price!: number;\n @IntProperty() quantity!: number;\n @DateProperty() createdAt!: Date;\n\n constructor(data: {\n id: string;\n name: string;\n price: number;\n quantity: number;\n createdAt: Date;\n }) {\n this.id = data.id;\n this.name = data.name;\n this.price = data.price;\n this.quantity = data.quantity;\n this.createdAt = data.createdAt;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH SPECIAL TYPES\n// ============================================================================\n\n/**\n * Entity with Date and BigInt types\n * Features: DateProperty, BigIntProperty\n */\n@Entity()\nexport class EntityWithSpecialTypes {\n @DateProperty() timestamp!: Date;\n @BigIntProperty() largeNumber!: bigint;\n @StringProperty() label!: string;\n\n constructor(data: { timestamp: Date; largeNumber: bigint; label: string }) {\n this.timestamp = data.timestamp;\n this.largeNumber = data.largeNumber;\n this.label = data.label;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH VALIDATION\n// ============================================================================\n\n/**\n * Entity with property-level validators\n * Features: String validators (minLength, maxLength, pattern)\n */\n@Entity()\nexport class ValidatedEntity {\n @StringProperty({\n minLength: 3,\n maxLength: 20,\n })\n username!: string;\n\n @StringProperty({\n pattern: /^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}$/i,\n })\n email!: string;\n\n @NumberProperty({ min: 0, max: 150 })\n age!: number;\n\n constructor(data: { username: string; email: string; age: number }) {\n this.username = data.username;\n this.email = data.email;\n this.age = data.age;\n }\n}\n\n/**\n * Entity with cross-property validation\n * Features: @EntityValidator decorator\n */\n@Entity()\nexport class CrossValidatedEntity {\n @StringProperty() password!: string;\n @StringProperty() confirmPassword!: string;\n @DateProperty() startDate!: Date;\n @DateProperty() endDate!: Date;\n\n constructor(data: {\n password: string;\n confirmPassword: string;\n startDate: Date;\n endDate: Date;\n }) {\n this.password = data.password;\n this.confirmPassword = data.confirmPassword;\n this.startDate = data.startDate;\n this.endDate = data.endDate;\n }\n\n @EntityValidator()\n validatePasswords(): Problem[] {\n if (this.password !== this.confirmPassword) {\n return [\n new Problem({\n property: 'confirmPassword',\n message: 'Passwords do not match',\n }),\n ];\n }\n return [];\n }\n\n @EntityValidator()\n validateDates(): Problem[] {\n if (this.startDate >= this.endDate) {\n return [\n new Problem({\n property: 'endDate',\n message: 'End date must be after start date',\n }),\n ];\n }\n return [];\n }\n}\n\n// ============================================================================\n// ENTITIES WITH OPTIONAL/REQUIRED FIELDS\n// ============================================================================\n\n/**\n * Entity with mix of optional and required properties\n * Features: optional flag\n */\n@Entity()\nexport class OptionalFieldsEntity {\n @StringProperty() requiredField!: string;\n @StringProperty({ optional: true }) optionalField?: string;\n @NumberProperty({ optional: true }) optionalNumber?: number;\n @BooleanProperty() requiredBoolean!: boolean;\n\n constructor(data: {\n requiredField: string;\n optionalField?: string;\n optionalNumber?: number;\n requiredBoolean: boolean;\n }) {\n this.requiredField = data.requiredField;\n this.optionalField = data.optionalField;\n this.optionalNumber = data.optionalNumber;\n this.requiredBoolean = data.requiredBoolean;\n }\n}\n\n/**\n * Entity with properties whose serialized JSON key differs from the property name\n * Features: serializedKey option, optional property with serializedKey\n */\n@Entity()\nexport class EntityWithSerializedKey {\n @StringProperty({ serializedKey: 'first_name' })\n firstName!: string;\n\n @StringProperty({ serializedKey: 'last_name', optional: true })\n lastName?: string;\n\n @NumberProperty()\n age!: number;\n\n constructor(data: { firstName: string; lastName?: string; age: number }) {\n this.firstName = data.firstName;\n this.lastName = data.lastName;\n this.age = data.age;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH DEFAULT VALUES\n// ============================================================================\n\nlet factoryCallCount = 0;\n\n/**\n * Entity with various default value strategies\n * Features: Static defaults, factory defaults, async factory defaults\n */\n@Entity()\nexport class EntityWithDefaults {\n @StringProperty({ default: 'default-name' })\n name!: string;\n\n @NumberProperty({ default: () => factoryCallCount++ })\n counter!: number;\n\n @DateProperty({ default: () => new Date('2025-01-01') })\n timestamp!: Date;\n\n @StringProperty({ default: async () => 'async-value' })\n asyncField!: string;\n\n @BooleanProperty({ default: true })\n enabled!: boolean;\n\n constructor(data: {\n name?: string;\n counter?: number;\n timestamp?: Date;\n asyncField?: string;\n enabled?: boolean;\n }) {\n this.name = data.name!;\n this.counter = data.counter!;\n this.timestamp = data.timestamp!;\n this.asyncField = data.asyncField!;\n this.enabled = data.enabled!;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH ARRAYS\n// ============================================================================\n\n/**\n * Entity with various array configurations\n * Features: Regular arrays, sparse arrays, array validators\n */\n@Entity()\nexport class EntityWithArrays {\n @ArrayProperty(() => String)\n tags!: string[];\n\n @ArrayProperty(() => Number, {\n minLength: 1,\n maxLength: 5,\n })\n ratings!: number[];\n\n @ArrayProperty(() => String, { sparse: true })\n sparseArray!: (string | null | undefined)[];\n\n @ArrayProperty(() => TestUser)\n users!: TestUser[];\n\n constructor(data: {\n tags: string[];\n ratings: number[];\n sparseArray: (string | null | undefined)[];\n users: TestUser[];\n }) {\n this.tags = data.tags;\n this.ratings = data.ratings;\n this.sparseArray = data.sparseArray;\n this.users = data.users;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH ENUMS\n// ============================================================================\n\nexport enum UserRole {\n ADMIN = 'admin',\n USER = 'user',\n GUEST = 'guest',\n}\n\nexport enum ProductStatus {\n DRAFT = 'draft',\n PUBLISHED = 'published',\n ARCHIVED = 'archived',\n}\n\n/**\n * Entity with enum properties\n * Features: EnumProperty decorator\n */\n@Entity()\nexport class EntityWithEnum {\n @StringProperty() name!: string;\n @EnumProperty(UserRole) role!: UserRole;\n @EnumProperty(ProductStatus) status!: ProductStatus;\n\n constructor(data: { name: string; role: UserRole; status: ProductStatus }) {\n this.name = data.name;\n this.role = data.role;\n this.status = data.status;\n }\n}\n\n// ============================================================================\n// NESTED ENTITIES (2-3 LEVELS)\n// ============================================================================\n\n/**\n * Level 1: Simple address entity\n * Features: Basic nested entity\n */\n@Entity()\nexport class TestAddress {\n @StringProperty() street!: string;\n @StringProperty() city!: string;\n @StringProperty() country!: string;\n @IntProperty() zipCode!: number;\n\n constructor(data: {\n street: string;\n city: string;\n country: string;\n zipCode: number;\n }) {\n this.street = data.street;\n this.city = data.city;\n this.country = data.country;\n this.zipCode = data.zipCode;\n }\n}\n\n/**\n * Level 2: Company with nested address\n * Features: 1-level nesting\n */\n@Entity()\nexport class TestCompany {\n @StringProperty() name!: string;\n @EntityProperty(() => TestAddress) address!: TestAddress;\n @IntProperty() employeeCount!: number;\n\n constructor(data: {\n name: string;\n address: TestAddress;\n employeeCount: number;\n }) {\n this.name = data.name;\n this.address = data.address;\n this.employeeCount = data.employeeCount;\n }\n}\n\n/**\n * Level 3: Employee with nested company (which has nested address)\n * Features: 2-level nesting\n */\n@Entity()\nexport class TestEmployee {\n @StringProperty() name!: string;\n @StringProperty() email!: string;\n @EntityProperty(() => TestCompany) company!: TestCompany;\n @NumberProperty() salary!: number;\n @DateProperty() hireDate!: Date;\n\n constructor(data: {\n name: string;\n email: string;\n company: TestCompany;\n salary: number;\n hireDate: Date;\n }) {\n this.name = data.name;\n this.email = data.email;\n this.company = data.company;\n this.salary = data.salary;\n this.hireDate = data.hireDate;\n }\n}\n\n/**\n * Entity with optional nested entities\n * Features: Optional nested entities\n */\n@Entity()\nexport class EntityWithOptionalNested {\n @StringProperty() id!: string;\n @EntityProperty(() => TestAddress, { optional: true })\n billingAddress?: TestAddress;\n @EntityProperty(() => TestAddress, { optional: true })\n shippingAddress?: TestAddress;\n\n constructor(data: {\n id: string;\n billingAddress?: TestAddress;\n shippingAddress?: TestAddress;\n }) {\n this.id = data.id;\n this.billingAddress = data.billingAddress;\n this.shippingAddress = data.shippingAddress;\n }\n}\n\n// ============================================================================\n// COLLECTION ENTITIES\n// ============================================================================\n\n/**\n * Collection entity wrapping string array\n * Features: @CollectionEntity decorator, unwraps to array\n */\n@CollectionEntity()\nexport class TestTags {\n @ArrayProperty(() => String)\n readonly collection: string[];\n\n constructor(data: { collection: string[] }) {\n this.collection = data.collection;\n }\n}\n\n/**\n * Collection entity wrapping number array\n * Features: @CollectionEntity with numbers\n */\n@CollectionEntity()\nexport class TestIdList {\n @ArrayProperty(() => Number)\n readonly collection: number[];\n\n constructor(data: { collection: number[] }) {\n this.collection = data.collection;\n }\n}\n\n/**\n * Collection entity with entity items\n * Features: @CollectionEntity with nested entities\n */\n@CollectionEntity()\nexport class TestUserCollection {\n @ArrayProperty(() => TestUser)\n readonly collection: TestUser[];\n\n constructor(data: { collection: TestUser[] }) {\n this.collection = data.collection;\n }\n}\n\n// ============================================================================\n// STRINGIFIABLE ENTITIES\n// ============================================================================\n\n/**\n * Stringifiable entity for user IDs\n * Features: @Stringifiable decorator, unwraps to string\n */\n@Stringifiable()\nexport class TestUserId {\n @StringProperty() readonly value: string;\n\n constructor(data: { value: string }) {\n this.value = data.value;\n }\n}\n\n/**\n * Stringifiable entity for emails with validation\n * Features: @Stringifiable with validation\n */\n@Stringifiable()\nexport class TestEmail {\n @StringProperty({\n pattern: /^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}$/i,\n })\n readonly value: string;\n\n constructor(data: { value: string }) {\n this.value = data.value;\n }\n}\n\n/**\n * Entity using stringifiable properties\n * Features: Properties that are stringifiable entities\n */\n@Entity()\nexport class EntityWithStringifiable {\n @EntityProperty(() => TestUserId) userId!: TestUserId;\n @EntityProperty(() => TestEmail) email!: TestEmail;\n @StringProperty() name!: string;\n\n constructor(data: { userId: TestUserId; email: TestEmail; name: string }) {\n this.userId = data.userId;\n this.email = data.email;\n this.name = data.name;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH DEPENDENCY INJECTION\n// ============================================================================\n\nexport interface ILogger {\n log(message: string): void;\n}\n\nexport const LOGGER_TOKEN = Symbol('Logger');\n\n/**\n * Entity with injected properties\n * Features: @InjectedProperty decorator\n */\n@Entity()\nexport class EntityWithDI {\n @StringProperty() name!: string;\n @InjectedProperty(LOGGER_TOKEN) logger!: ILogger;\n\n constructor(data: { name: string; logger?: ILogger }) {\n this.name = data.name;\n if (data.logger) {\n this.logger = data.logger;\n }\n }\n\n logName(): void {\n this.logger.log(`Name is: ${this.name}`);\n }\n}\n\n// ============================================================================\n// ENTITIES WITH PASSTHROUGH\n// ============================================================================\n\n/**\n * Entity with passthrough properties\n * Features: @PassthroughProperty for unknown types\n */\n@Entity()\nexport class EntityWithPassthrough {\n @StringProperty() id!: string;\n @PassthroughProperty() metadata!: Record<string, unknown>;\n @PassthroughProperty() config!: unknown;\n\n constructor(data: {\n id: string;\n metadata: Record<string, unknown>;\n config: unknown;\n }) {\n this.id = data.id;\n this.metadata = data.metadata;\n this.config = data.config;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH CUSTOM SERIALIZATION\n// ============================================================================\n\n/**\n * Custom serializable class\n */\nexport class CustomValue {\n constructor(\n public x: number,\n public y: number,\n ) {}\n\n toData() {\n return { x: this.x, y: this.y };\n }\n\n static fromData(data: { x: number; y: number }): CustomValue {\n return new CustomValue(data.x, data.y);\n }\n}\n\n/**\n * Entity with custom serialize/deserialize\n * Features: Custom serialization functions\n */\n@Entity()\nexport class EntityWithCustomSerialization {\n @StringProperty() name!: string;\n\n @Property({\n type: () => CustomValue,\n serialize: (v: CustomValue) => v.toData(),\n deserialize: (d: unknown) =>\n CustomValue.fromData(d as { x: number; y: number }),\n })\n position!: CustomValue;\n\n constructor(data: { name: string; position: CustomValue }) {\n this.name = data.name;\n this.position = data.position;\n }\n}\n\n/**\n * Entity to verify serialize/deserialize context is passed correctly\n * Features: Context-aware serialization using propertyName and sibling values\n */\n@Entity()\nexport class EntityWithContextSerialization {\n @StringProperty() id!: string;\n\n @Property({\n type: () => String,\n serialize: (v: string, context) =>\n `${context.propertyName}:${v}:${context.entity['id']}`,\n deserialize: (raw: unknown, context) =>\n `${raw}-from-${context.rawObject['id']}`,\n })\n label!: string;\n\n constructor(data: { id: string; label: string }) {\n this.id = data.id;\n this.label = data.label;\n }\n}\n\n/**\n * Custom class with equals method\n */\nexport class CustomPoint {\n constructor(\n public x: number,\n public y: number,\n ) {}\n\n equals(other: CustomPoint): boolean {\n return this.x === other.x && this.y === other.y;\n }\n\n toString(): string {\n return `${this.x},${this.y}`;\n }\n\n static fromString(str: string): CustomPoint {\n const [x, y] = str.split(',').map(Number);\n return new CustomPoint(x, y);\n }\n}\n\n/**\n * Entity with custom equals function\n * Features: Custom equality comparison\n */\n@Entity()\nexport class EntityWithCustomEquals {\n @StringProperty() id!: string;\n\n @Property({\n type: () => CustomPoint,\n serialize: (v: CustomPoint) => v.toString(),\n deserialize: (d: unknown) => CustomPoint.fromString(d as string),\n equals: (a: CustomPoint, b: CustomPoint) => a.equals(b),\n })\n location!: CustomPoint;\n\n constructor(data: { id: string; location: CustomPoint }) {\n this.id = data.id;\n this.location = data.location;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH SERIALIZABLE/PARSEABLE PROPERTIES\n// ============================================================================\n\n/**\n * Custom class implementing Serializable interface\n */\nexport class SerializableValue {\n constructor(public data: string) {}\n\n toJSON(): string {\n return this.data;\n }\n\n equals(other: SerializableValue): boolean {\n return this.data === other.data;\n }\n\n static parse(json: unknown): SerializableValue {\n return new SerializableValue(json as string);\n }\n}\n\n/**\n * Entity using SerializableProperty\n * Features: @SerializableProperty decorator\n */\n@Entity()\nexport class EntityWithSerializable {\n @StringProperty() name!: string;\n @SerializableProperty(() => SerializableValue)\n value!: SerializableValue;\n\n constructor(data: { name: string; value: SerializableValue }) {\n this.name = data.name;\n this.value = data.value;\n }\n}\n\n/**\n * Custom class implementing Parseable interface\n */\nexport class ParseableValue {\n constructor(public data: number) {}\n\n toString(): string {\n return String(this.data);\n }\n\n equals(other: ParseableValue): boolean {\n return this.data === other.data;\n }\n\n static parse(str: string): ParseableValue {\n return new ParseableValue(Number(str));\n }\n}\n\n/**\n * Entity using StringifiableProperty\n * Features: @StringifiableProperty decorator\n */\n@Entity()\nexport class EntityWithParseable {\n @StringProperty() label!: string;\n @StringifiableProperty(() => ParseableValue)\n value!: ParseableValue;\n\n constructor(data: { label: string; value: ParseableValue }) {\n this.label = data.label;\n this.value = data.value;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH ZOD VALIDATION\n// ============================================================================\n\nconst emailSchema = z.string().email();\nconst positiveIntSchema = z.number().int().positive();\n\n/**\n * Entity with Zod validation\n * Features: @ZodProperty decorator\n */\n@Entity()\nexport class EntityWithZod {\n @ZodProperty(z.string().min(3).max(20))\n username!: string;\n\n @ZodProperty(emailSchema)\n email!: string;\n\n @ZodProperty(positiveIntSchema)\n count!: number;\n\n constructor(data: { username: string; email: string; count: number }) {\n this.username = data.username;\n this.email = data.email;\n this.count = data.count;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH IMMUTABLE PROPERTIES\n// ============================================================================\n\n/**\n * Entity with immutable (preventUpdates) properties\n * Features: preventUpdates flag\n */\n@Entity()\nexport class EntityWithImmutable {\n @StringProperty({ preventUpdates: true })\n readonly id: string;\n\n @StringProperty() name!: string;\n\n @DateProperty({ preventUpdates: true })\n readonly createdAt: Date;\n\n @NumberProperty() value!: number;\n\n constructor(data: {\n id: string;\n name: string;\n createdAt: Date;\n value: number;\n }) {\n this.id = data.id;\n this.name = data.name;\n this.createdAt = data.createdAt;\n this.value = data.value;\n }\n}\n\n// ============================================================================\n// COMPLEX ENTITY (COMBINING MULTIPLE FEATURES)\n// ============================================================================\n\n/**\n * Complex entity combining multiple features\n * Features: All common features in one entity\n * - Primitives, enums, nested entities, arrays\n * - Optional fields, defaults, validation\n * - Custom serialization, stringifiable properties\n */\n@Entity()\nexport class ComplexEntity {\n @StringProperty({ preventUpdates: true })\n readonly id: string;\n\n @StringProperty({ minLength: 2, maxLength: 50 })\n name!: string;\n\n @EnumProperty(UserRole)\n role!: UserRole;\n\n @EntityProperty(() => TestUserId)\n userId!: TestUserId;\n\n @EntityProperty(() => TestAddress)\n address!: TestAddress;\n\n @ArrayProperty(() => String, { minLength: 0, maxLength: 10 })\n tags!: string[];\n\n @ArrayProperty(() => TestProduct)\n products!: TestProduct[];\n\n @NumberProperty({ optional: true, min: 0 })\n score?: number;\n\n @DateProperty({ default: () => new Date() })\n createdAt!: Date;\n\n @DateProperty({ optional: true })\n updatedAt?: Date;\n\n @BooleanProperty({ default: true })\n active!: boolean;\n\n @PassthroughProperty()\n metadata!: Record<string, unknown>;\n\n constructor(data: {\n id: string;\n name: string;\n role: UserRole;\n userId: TestUserId;\n address: TestAddress;\n tags: string[];\n products: TestProduct[];\n score?: number;\n createdAt?: Date;\n updatedAt?: Date;\n active?: boolean;\n metadata: Record<string, unknown>;\n }) {\n this.id = data.id;\n this.name = data.name;\n this.role = data.role;\n this.userId = data.userId;\n this.address = data.address;\n this.tags = data.tags;\n this.products = data.products;\n this.score = data.score;\n this.createdAt = data.createdAt!;\n this.updatedAt = data.updatedAt;\n this.active = data.active!;\n this.metadata = data.metadata;\n }\n\n @EntityValidator()\n validateProducts(): Problem[] {\n if (this.products.length === 0 && this.active) {\n return [\n new Problem({\n property: 'products',\n message: 'Active entity must have at least one product',\n }),\n ];\n }\n return [];\n }\n}\n\n// ============================================================================\n// HELPER TO RESET FACTORY COUNTER (FOR TESTING)\n// ============================================================================\n\nexport function resetFactoryCallCount(): void {\n factoryCallCount = 0;\n}\n\n// ============================================================================\n// ENTITIES FOR parseBigInt TESTING\n// ============================================================================\n\n/**\n * Entity with NumberProperty and IntProperty configured with parseBigInt: true\n * Features: coercion from bigint / integer string to number\n */\n@Entity()\nexport class EntityWithParseBigInt {\n @NumberProperty({ parseBigInt: true }) amount!: number;\n @IntProperty({ parseBigInt: true }) count!: number;\n\n constructor(data: { amount: number; count: number }) {\n this.amount = data.amount;\n this.count = data.count;\n }\n}\n"],"names":["z","Entity","CollectionEntity","Stringifiable","EntityValidator","Property","StringProperty","NumberProperty","IntProperty","BooleanProperty","DateProperty","BigIntProperty","EnumProperty","EntityProperty","ArrayProperty","PassthroughProperty","SerializableProperty","StringifiableProperty","InjectedProperty","ZodProperty","Problem","TestUser","data","name","age","active","TestProduct","id","price","quantity","createdAt","EntityWithSpecialTypes","timestamp","largeNumber","label","ValidatedEntity","username","email","minLength","maxLength","pattern","min","max","CrossValidatedEntity","password","confirmPassword","startDate","endDate","validatePasswords","property","message","validateDates","OptionalFieldsEntity","requiredField","optionalField","optionalNumber","requiredBoolean","optional","EntityWithSerializedKey","firstName","lastName","serializedKey","factoryCallCount","EntityWithDefaults","counter","asyncField","enabled","default","Date","EntityWithArrays","tags","ratings","sparseArray","users","String","Number","sparse","UserRole","ProductStatus","EntityWithEnum","role","status","TestAddress","street","city","country","zipCode","TestCompany","address","employeeCount","TestEmployee","company","salary","hireDate","EntityWithOptionalNested","billingAddress","shippingAddress","TestTags","collection","TestIdList","TestUserCollection","TestUserId","value","TestEmail","EntityWithStringifiable","userId","LOGGER_TOKEN","Symbol","EntityWithDI","logger","logName","log","EntityWithPassthrough","metadata","config","CustomValue","x","y","toData","fromData","EntityWithCustomSerialization","position","type","serialize","v","deserialize","d","EntityWithContextSerialization","context","propertyName","entity","raw","rawObject","CustomPoint","equals","other","toString","fromString","str","split","map","EntityWithCustomEquals","location","a","b","SerializableValue","toJSON","parse","json","EntityWithSerializable","ParseableValue","EntityWithParseable","emailSchema","string","positiveIntSchema","number","int","positive","EntityWithZod","count","EntityWithImmutable","preventUpdates","ComplexEntity","products","score","updatedAt","validateProducts","length","resetFactoryCallCount","EntityWithParseBigInt","amount","parseBigInt"],"mappings":";;AAAA,OAAO,mBAAmB;AAC1B,SAASA,CAAC,QAAQ,MAAM;AACxB,SACEC,MAAM,EACNC,gBAAgB,EAChBC,aAAa,EACbC,eAAe,QACV,cAAc;AACrB,SACEC,QAAQ,EACRC,cAAc,EACdC,cAAc,EACdC,WAAW,EACXC,eAAe,EACfC,YAAY,EACZC,cAAc,EACdC,YAAY,EACZC,cAAc,EACdC,aAAa,EACbC,mBAAmB,EACnBC,oBAAoB,EACpBC,qBAAqB,QAChB,gBAAgB;AACvB,SAASC,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASC,OAAO,QAAQ,eAAe;AAWvC,OAAO,MAAMC;IAKX,YAAYC,IAAoD,CAAE;QAChE,IAAI,CAACC,IAAI,GAAGD,KAAKC,IAAI;QACrB,IAAI,CAACC,GAAG,GAAGF,KAAKE,GAAG;QACnB,IAAI,CAACC,MAAM,GAAGH,KAAKG,MAAM;IAC3B;AACF;;;;;;;;;;;;;;;;;;;;AAOA,OAAO,MAAMC;IAOX,YAAYJ,IAMX,CAAE;QACD,IAAI,CAACK,EAAE,GAAGL,KAAKK,EAAE;QACjB,IAAI,CAACJ,IAAI,GAAGD,KAAKC,IAAI;QACrB,IAAI,CAACK,KAAK,GAAGN,KAAKM,KAAK;QACvB,IAAI,CAACC,QAAQ,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AGH,KAAKG,MAAM;QACzB,IAAI,CAACwF,QAAQ,GAAG3F,KAAK2F,QAAQ;IAC/B;IAGAqD,mBAA8B;QAC5B,IAAI,IAAI,CAACH,QAAQ,CAACI,MAAM,KAAK,KAAK,IAAI,CAAC9I,MAAM,EAAE;YAC7C,OAAO;gBACL,IAAIL,QAAQ;oBACV6B,UAAU;oBACVC,SAAS;gBACX;aACD;QACH;QACA,OAAO,EAAE;IACX;AACF;;;QA5EoB+G,gBAAgB;;;;;;QAGhB3H,WAAW;QAAGC,WAAW;;;;;;;;;uBAMrB8D;;;;uBAGAnB;;;;sBAGDR;QAAUpC,WAAW;QAAGC,WAAW;;;;;sBAGnCb;;;;;QAGH+B,UAAU;QAAMhB,KAAK;;;;;;QAGvB0B,SAAS,IAAM,IAAIC;;;;;;QAGnBX,UAAU;;;;;;QAGPU,SAAS;;;;;;;;;;;;;;;;;;;;;AAgD9B,+EAA+E;AAC/E,gDAAgD;AAChD,+EAA+E;AAE/E,OAAO,SAASqG;IACd1G,mBAAmB;AACrB;AAWA,OAAO,MAAM2G;IAIX,YAAYnJ,IAAuC,CAAE;QACnD,IAAI,CAACoJ,MAAM,GAAGpJ,KAAKoJ,MAAM;QACzB,IAAI,CAACX,KAAK,GAAGzI,KAAKyI,KAAK;IACzB;AACF;;;QAPoBY,aAAa;;;;;;QAChBA,aAAa"}
1
+ {"version":3,"sources":["../../src/lib/test-entities.ts"],"sourcesContent":["import 'reflect-metadata';\nimport { z } from 'zod';\nimport {\n Entity,\n CollectionEntity,\n Stringifiable,\n EntityValidator,\n} from './entity.js';\nimport {\n Property,\n StringProperty,\n NumberProperty,\n IntProperty,\n BooleanProperty,\n DateProperty,\n BigIntProperty,\n EnumProperty,\n EntityProperty,\n ArrayProperty,\n PassthroughProperty,\n SerializableProperty,\n StringifiableProperty,\n} from './property.js';\nimport { InjectedProperty } from './injected-property.js';\nimport { ZodProperty } from './zod-property.js';\nimport { Problem } from './problem.js';\n\n// ============================================================================\n// SIMPLE ENTITIES WITH PRIMITIVES\n// ============================================================================\n\n/**\n * Basic entity with common primitive types\n * Features: String, Number, Boolean properties\n */\n@Entity()\nexport class TestUser {\n @StringProperty() name!: string;\n @NumberProperty() age!: number;\n @BooleanProperty() active!: boolean;\n\n constructor(data: { name: string; age: number; active: boolean }) {\n this.name = data.name;\n this.age = data.age;\n this.active = data.active;\n }\n}\n\n/**\n * Entity with different primitive combinations\n * Features: String, Number, Int, Date properties\n */\n@Entity()\nexport class TestProduct {\n @StringProperty() id!: string;\n @StringProperty() name!: string;\n @NumberProperty() price!: number;\n @IntProperty() quantity!: number;\n @DateProperty() createdAt!: Date;\n\n constructor(data: {\n id: string;\n name: string;\n price: number;\n quantity: number;\n createdAt: Date;\n }) {\n this.id = data.id;\n this.name = data.name;\n this.price = data.price;\n this.quantity = data.quantity;\n this.createdAt = data.createdAt;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH SPECIAL TYPES\n// ============================================================================\n\n/**\n * Entity with Date and BigInt types\n * Features: DateProperty, BigIntProperty\n */\n@Entity()\nexport class EntityWithSpecialTypes {\n @DateProperty() timestamp!: Date;\n @BigIntProperty() largeNumber!: bigint;\n @StringProperty() label!: string;\n\n constructor(data: { timestamp: Date; largeNumber: bigint; label: string }) {\n this.timestamp = data.timestamp;\n this.largeNumber = data.largeNumber;\n this.label = data.label;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH VALIDATION\n// ============================================================================\n\n/**\n * Entity with property-level validators\n * Features: String validators (minLength, maxLength, pattern)\n */\n@Entity()\nexport class ValidatedEntity {\n @StringProperty({\n minLength: 3,\n maxLength: 20,\n })\n username!: string;\n\n @StringProperty({\n pattern: /^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}$/i,\n })\n email!: string;\n\n @NumberProperty({ min: 0, max: 150 })\n age!: number;\n\n constructor(data: { username: string; email: string; age: number }) {\n this.username = data.username;\n this.email = data.email;\n this.age = data.age;\n }\n}\n\n/**\n * Entity with cross-property validation\n * Features: @EntityValidator decorator\n */\n@Entity()\nexport class CrossValidatedEntity {\n @StringProperty() password!: string;\n @StringProperty() confirmPassword!: string;\n @DateProperty() startDate!: Date;\n @DateProperty() endDate!: Date;\n\n constructor(data: {\n password: string;\n confirmPassword: string;\n startDate: Date;\n endDate: Date;\n }) {\n this.password = data.password;\n this.confirmPassword = data.confirmPassword;\n this.startDate = data.startDate;\n this.endDate = data.endDate;\n }\n\n @EntityValidator()\n validatePasswords(): Problem[] {\n if (this.password !== this.confirmPassword) {\n return [\n new Problem({\n property: 'confirmPassword',\n message: 'Passwords do not match',\n }),\n ];\n }\n return [];\n }\n\n @EntityValidator()\n validateDates(): Problem[] {\n if (this.startDate >= this.endDate) {\n return [\n new Problem({\n property: 'endDate',\n message: 'End date must be after start date',\n }),\n ];\n }\n return [];\n }\n}\n\n// ============================================================================\n// ENTITIES WITH OPTIONAL/REQUIRED FIELDS\n// ============================================================================\n\n/**\n * Entity with mix of optional and required properties\n * Features: optional flag\n */\n@Entity()\nexport class OptionalFieldsEntity {\n @StringProperty() requiredField!: string;\n @StringProperty({ optional: true }) optionalField?: string;\n @NumberProperty({ optional: true }) optionalNumber?: number;\n @BooleanProperty() requiredBoolean!: boolean;\n\n constructor(data: {\n requiredField: string;\n optionalField?: string;\n optionalNumber?: number;\n requiredBoolean: boolean;\n }) {\n this.requiredField = data.requiredField;\n this.optionalField = data.optionalField;\n this.optionalNumber = data.optionalNumber;\n this.requiredBoolean = data.requiredBoolean;\n }\n}\n\n/**\n * Entity with properties whose serialized JSON key differs from the property name\n * Features: serializedKey option, optional property with serializedKey\n */\n@Entity()\nexport class EntityWithSerializedKey {\n @StringProperty({ serializedKey: 'first_name' })\n firstName!: string;\n\n @StringProperty({ serializedKey: 'last_name', optional: true })\n lastName?: string;\n\n @NumberProperty()\n age!: number;\n\n constructor(data: { firstName: string; lastName?: string; age: number }) {\n this.firstName = data.firstName;\n this.lastName = data.lastName;\n this.age = data.age;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH DEFAULT VALUES\n// ============================================================================\n\nlet factoryCallCount = 0;\n\n/**\n * Entity with various default value strategies\n * Features: Static defaults, factory defaults, async factory defaults\n */\n@Entity()\nexport class EntityWithDefaults {\n @StringProperty({ default: 'default-name' })\n name!: string;\n\n @NumberProperty({ default: () => factoryCallCount++ })\n counter!: number;\n\n @DateProperty({ default: () => new Date('2025-01-01') })\n timestamp!: Date;\n\n @StringProperty({ default: async () => 'async-value' })\n asyncField!: string;\n\n @BooleanProperty({ default: true })\n enabled!: boolean;\n\n constructor(data: {\n name?: string;\n counter?: number;\n timestamp?: Date;\n asyncField?: string;\n enabled?: boolean;\n }) {\n this.name = data.name!;\n this.counter = data.counter!;\n this.timestamp = data.timestamp!;\n this.asyncField = data.asyncField!;\n this.enabled = data.enabled!;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH ARRAYS\n// ============================================================================\n\n/**\n * Entity with various array configurations\n * Features: Regular arrays, sparse arrays, array validators\n */\n@Entity()\nexport class EntityWithArrays {\n @ArrayProperty(() => String)\n tags!: string[];\n\n @ArrayProperty(() => Number, {\n minLength: 1,\n maxLength: 5,\n })\n ratings!: number[];\n\n @ArrayProperty(() => String, { sparse: true })\n sparseArray!: (string | null | undefined)[];\n\n @ArrayProperty(() => TestUser)\n users!: TestUser[];\n\n constructor(data: {\n tags: string[];\n ratings: number[];\n sparseArray: (string | null | undefined)[];\n users: TestUser[];\n }) {\n this.tags = data.tags;\n this.ratings = data.ratings;\n this.sparseArray = data.sparseArray;\n this.users = data.users;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH ENUMS\n// ============================================================================\n\nexport enum UserRole {\n ADMIN = 'admin',\n USER = 'user',\n GUEST = 'guest',\n}\n\nexport enum ProductStatus {\n DRAFT = 'draft',\n PUBLISHED = 'published',\n ARCHIVED = 'archived',\n}\n\n/**\n * Entity with enum properties\n * Features: EnumProperty decorator\n */\n@Entity()\nexport class EntityWithEnum {\n @StringProperty() name!: string;\n @EnumProperty(UserRole) role!: UserRole;\n @EnumProperty(ProductStatus) status!: ProductStatus;\n\n constructor(data: { name: string; role: UserRole; status: ProductStatus }) {\n this.name = data.name;\n this.role = data.role;\n this.status = data.status;\n }\n}\n\n// ============================================================================\n// NESTED ENTITIES (2-3 LEVELS)\n// ============================================================================\n\n/**\n * Level 1: Simple address entity\n * Features: Basic nested entity\n */\n@Entity()\nexport class TestAddress {\n @StringProperty() street!: string;\n @StringProperty() city!: string;\n @StringProperty() country!: string;\n @IntProperty() zipCode!: number;\n\n constructor(data: {\n street: string;\n city: string;\n country: string;\n zipCode: number;\n }) {\n this.street = data.street;\n this.city = data.city;\n this.country = data.country;\n this.zipCode = data.zipCode;\n }\n}\n\n/**\n * Level 2: Company with nested address\n * Features: 1-level nesting\n */\n@Entity()\nexport class TestCompany {\n @StringProperty() name!: string;\n @EntityProperty(() => TestAddress) address!: TestAddress;\n @IntProperty() employeeCount!: number;\n\n constructor(data: {\n name: string;\n address: TestAddress;\n employeeCount: number;\n }) {\n this.name = data.name;\n this.address = data.address;\n this.employeeCount = data.employeeCount;\n }\n}\n\n/**\n * Level 3: Employee with nested company (which has nested address)\n * Features: 2-level nesting\n */\n@Entity()\nexport class TestEmployee {\n @StringProperty() name!: string;\n @StringProperty() email!: string;\n @EntityProperty(() => TestCompany) company!: TestCompany;\n @NumberProperty() salary!: number;\n @DateProperty() hireDate!: Date;\n\n constructor(data: {\n name: string;\n email: string;\n company: TestCompany;\n salary: number;\n hireDate: Date;\n }) {\n this.name = data.name;\n this.email = data.email;\n this.company = data.company;\n this.salary = data.salary;\n this.hireDate = data.hireDate;\n }\n}\n\n/**\n * Entity with optional nested entities\n * Features: Optional nested entities\n */\n@Entity()\nexport class EntityWithOptionalNested {\n @StringProperty() id!: string;\n @EntityProperty(() => TestAddress, { optional: true })\n billingAddress?: TestAddress;\n @EntityProperty(() => TestAddress, { optional: true })\n shippingAddress?: TestAddress;\n\n constructor(data: {\n id: string;\n billingAddress?: TestAddress;\n shippingAddress?: TestAddress;\n }) {\n this.id = data.id;\n this.billingAddress = data.billingAddress;\n this.shippingAddress = data.shippingAddress;\n }\n}\n\n// ============================================================================\n// COLLECTION ENTITIES\n// ============================================================================\n\n/**\n * Collection entity wrapping string array\n * Features: @CollectionEntity decorator, unwraps to array\n */\n@CollectionEntity()\nexport class TestTags {\n @ArrayProperty(() => String)\n readonly collection: string[];\n\n constructor(data: { collection: string[] }) {\n this.collection = data.collection;\n }\n}\n\n/**\n * Collection entity wrapping number array\n * Features: @CollectionEntity with numbers\n */\n@CollectionEntity()\nexport class TestIdList {\n @ArrayProperty(() => Number)\n readonly collection: number[];\n\n constructor(data: { collection: number[] }) {\n this.collection = data.collection;\n }\n}\n\n/**\n * Collection entity with entity items\n * Features: @CollectionEntity with nested entities\n */\n@CollectionEntity()\nexport class TestUserCollection {\n @ArrayProperty(() => TestUser)\n readonly collection: TestUser[];\n\n constructor(data: { collection: TestUser[] }) {\n this.collection = data.collection;\n }\n}\n\n// ============================================================================\n// STRINGIFIABLE ENTITIES\n// ============================================================================\n\n/**\n * Stringifiable entity for user IDs\n * Features: @Stringifiable decorator, unwraps to string\n */\n@Stringifiable()\nexport class TestUserId {\n @StringProperty() readonly value: string;\n\n constructor(data: { value: string }) {\n this.value = data.value;\n }\n}\n\n/**\n * Stringifiable entity for emails with validation\n * Features: @Stringifiable with validation\n */\n@Stringifiable()\nexport class TestEmail {\n @StringProperty({\n pattern: /^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}$/i,\n })\n readonly value: string;\n\n constructor(data: { value: string }) {\n this.value = data.value;\n }\n}\n\n/**\n * Entity using stringifiable properties\n * Features: Properties that are stringifiable entities\n */\n@Entity()\nexport class EntityWithStringifiable {\n @EntityProperty(() => TestUserId) userId!: TestUserId;\n @EntityProperty(() => TestEmail) email!: TestEmail;\n @StringProperty() name!: string;\n\n constructor(data: { userId: TestUserId; email: TestEmail; name: string }) {\n this.userId = data.userId;\n this.email = data.email;\n this.name = data.name;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH DEPENDENCY INJECTION\n// ============================================================================\n\nexport interface ILogger {\n log(message: string): void;\n}\n\nexport const LOGGER_TOKEN = Symbol('Logger');\n\n/**\n * Entity with injected properties\n * Features: @InjectedProperty decorator\n */\n@Entity()\nexport class EntityWithDI {\n @StringProperty() name!: string;\n @InjectedProperty(LOGGER_TOKEN) logger!: ILogger;\n\n constructor(data: { name: string; logger?: ILogger }) {\n this.name = data.name;\n if (data.logger) {\n this.logger = data.logger;\n }\n }\n\n logName(): void {\n this.logger.log(`Name is: ${this.name}`);\n }\n}\n\n// ============================================================================\n// ENTITIES WITH PASSTHROUGH\n// ============================================================================\n\n/**\n * Entity with passthrough properties\n * Features: @PassthroughProperty for unknown types\n */\n@Entity()\nexport class EntityWithPassthrough {\n @StringProperty() id!: string;\n @PassthroughProperty() metadata!: Record<string, unknown>;\n @PassthroughProperty() config!: unknown;\n\n constructor(data: {\n id: string;\n metadata: Record<string, unknown>;\n config: unknown;\n }) {\n this.id = data.id;\n this.metadata = data.metadata;\n this.config = data.config;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH CUSTOM SERIALIZATION\n// ============================================================================\n\n/**\n * Custom serializable class\n */\nexport class CustomValue {\n constructor(\n public x: number,\n public y: number,\n ) {}\n\n toData() {\n return { x: this.x, y: this.y };\n }\n\n static fromData(data: { x: number; y: number }): CustomValue {\n return new CustomValue(data.x, data.y);\n }\n}\n\n/**\n * Entity with custom serialize/deserialize\n * Features: Custom serialization functions\n */\n@Entity()\nexport class EntityWithCustomSerialization {\n @StringProperty() name!: string;\n\n @Property({\n type: () => CustomValue,\n serialize: (v: CustomValue) => v.toData(),\n deserialize: (d: unknown) =>\n CustomValue.fromData(d as { x: number; y: number }),\n })\n position!: CustomValue;\n\n constructor(data: { name: string; position: CustomValue }) {\n this.name = data.name;\n this.position = data.position;\n }\n}\n\n/**\n * Entity to verify serialize/deserialize context is passed correctly\n * Features: Context-aware serialization using propertyName and sibling values\n */\n@Entity()\nexport class EntityWithContextSerialization {\n @StringProperty() id!: string;\n\n @Property({\n type: () => String,\n serialize: (v: string, context) =>\n `${context.propertyName}:${v}:${context.entity['id']}`,\n deserialize: (raw: unknown, context) =>\n `${raw}-from-${context.rawObject['id']}`,\n })\n label!: string;\n\n constructor(data: { id: string; label: string }) {\n this.id = data.id;\n this.label = data.label;\n }\n}\n\n/**\n * Custom class with equals method\n */\nexport class CustomPoint {\n constructor(\n public x: number,\n public y: number,\n ) {}\n\n equals(other: CustomPoint): boolean {\n return this.x === other.x && this.y === other.y;\n }\n\n toString(): string {\n return `${this.x},${this.y}`;\n }\n\n static fromString(str: string): CustomPoint {\n const [x, y] = str.split(',').map(Number);\n return new CustomPoint(x, y);\n }\n}\n\n/**\n * Entity with custom equals function\n * Features: Custom equality comparison\n */\n@Entity()\nexport class EntityWithCustomEquals {\n @StringProperty() id!: string;\n\n @Property({\n type: () => CustomPoint,\n serialize: (v: CustomPoint) => v.toString(),\n deserialize: (d: unknown) => CustomPoint.fromString(d as string),\n equals: (a: CustomPoint, b: CustomPoint) => a.equals(b),\n })\n location!: CustomPoint;\n\n constructor(data: { id: string; location: CustomPoint }) {\n this.id = data.id;\n this.location = data.location;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH SERIALIZABLE/PARSEABLE PROPERTIES\n// ============================================================================\n\n/**\n * Custom class implementing Serializable interface\n */\nexport class SerializableValue {\n constructor(public data: string) {}\n\n toJSON(): string {\n return this.data;\n }\n\n equals(other: SerializableValue): boolean {\n return this.data === other.data;\n }\n\n static parse(json: unknown): SerializableValue {\n return new SerializableValue(json as string);\n }\n}\n\n/**\n * Entity using SerializableProperty\n * Features: @SerializableProperty decorator\n */\n@Entity()\nexport class EntityWithSerializable {\n @StringProperty() name!: string;\n @SerializableProperty(() => SerializableValue)\n value!: SerializableValue;\n\n constructor(data: { name: string; value: SerializableValue }) {\n this.name = data.name;\n this.value = data.value;\n }\n}\n\n/**\n * Custom class implementing Parseable interface\n */\nexport class ParseableValue {\n constructor(public data: number) {}\n\n toString(): string {\n return String(this.data);\n }\n\n equals(other: ParseableValue): boolean {\n return this.data === other.data;\n }\n\n static parse(str: string): ParseableValue {\n return new ParseableValue(Number(str));\n }\n}\n\n/**\n * Entity using StringifiableProperty\n * Features: @StringifiableProperty decorator\n */\n@Entity()\nexport class EntityWithParseable {\n @StringProperty() label!: string;\n @StringifiableProperty(() => ParseableValue)\n value!: ParseableValue;\n\n constructor(data: { label: string; value: ParseableValue }) {\n this.label = data.label;\n this.value = data.value;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH ZOD VALIDATION\n// ============================================================================\n\nconst emailSchema = z.string().email();\nconst positiveIntSchema = z.number().int().positive();\n\n/**\n * Entity with Zod validation\n * Features: @ZodProperty decorator\n */\n@Entity()\nexport class EntityWithZod {\n @ZodProperty(z.string().min(3).max(20))\n username!: string;\n\n @ZodProperty(emailSchema)\n email!: string;\n\n @ZodProperty(positiveIntSchema)\n count!: number;\n\n constructor(data: { username: string; email: string; count: number }) {\n this.username = data.username;\n this.email = data.email;\n this.count = data.count;\n }\n}\n\n// ============================================================================\n// ENTITIES WITH IMMUTABLE PROPERTIES\n// ============================================================================\n\n/**\n * Entity with immutable (preventUpdates) properties\n * Features: preventUpdates flag\n */\n@Entity()\nexport class EntityWithImmutable {\n @StringProperty({ preventUpdates: true })\n readonly id: string;\n\n @StringProperty() name!: string;\n\n @DateProperty({ preventUpdates: true })\n readonly createdAt: Date;\n\n @NumberProperty() value!: number;\n\n constructor(data: {\n id: string;\n name: string;\n createdAt: Date;\n value: number;\n }) {\n this.id = data.id;\n this.name = data.name;\n this.createdAt = data.createdAt;\n this.value = data.value;\n }\n}\n\n// ============================================================================\n// COMPLEX ENTITY (COMBINING MULTIPLE FEATURES)\n// ============================================================================\n\n/**\n * Complex entity combining multiple features\n * Features: All common features in one entity\n * - Primitives, enums, nested entities, arrays\n * - Optional fields, defaults, validation\n * - Custom serialization, stringifiable properties\n */\n@Entity()\nexport class ComplexEntity {\n @StringProperty({ preventUpdates: true })\n readonly id: string;\n\n @StringProperty({ minLength: 2, maxLength: 50 })\n name!: string;\n\n @EnumProperty(UserRole)\n role!: UserRole;\n\n @EntityProperty(() => TestUserId)\n userId!: TestUserId;\n\n @EntityProperty(() => TestAddress)\n address!: TestAddress;\n\n @ArrayProperty(() => String, { minLength: 0, maxLength: 10 })\n tags!: string[];\n\n @ArrayProperty(() => TestProduct)\n products!: TestProduct[];\n\n @NumberProperty({ optional: true, min: 0 })\n score?: number;\n\n @DateProperty({ default: () => new Date() })\n createdAt!: Date;\n\n @DateProperty({ optional: true })\n updatedAt?: Date;\n\n @BooleanProperty({ default: true })\n active!: boolean;\n\n @PassthroughProperty()\n metadata!: Record<string, unknown>;\n\n constructor(data: {\n id: string;\n name: string;\n role: UserRole;\n userId: TestUserId;\n address: TestAddress;\n tags: string[];\n products: TestProduct[];\n score?: number;\n createdAt?: Date;\n updatedAt?: Date;\n active?: boolean;\n metadata: Record<string, unknown>;\n }) {\n this.id = data.id;\n this.name = data.name;\n this.role = data.role;\n this.userId = data.userId;\n this.address = data.address;\n this.tags = data.tags;\n this.products = data.products;\n this.score = data.score;\n this.createdAt = data.createdAt!;\n this.updatedAt = data.updatedAt;\n this.active = data.active!;\n this.metadata = data.metadata;\n }\n\n @EntityValidator()\n validateProducts(): Problem[] {\n if (this.products.length === 0 && this.active) {\n return [\n new Problem({\n property: 'products',\n message: 'Active entity must have at least one product',\n }),\n ];\n }\n return [];\n }\n}\n\n// ============================================================================\n// HELPER TO RESET FACTORY COUNTER (FOR TESTING)\n// ============================================================================\n\nexport function resetFactoryCallCount(): void {\n factoryCallCount = 0;\n}\n\n// ============================================================================\n// ENTITIES FOR parseBigInt TESTING\n// ============================================================================\n\n/**\n * Entity with NumberProperty and IntProperty configured with parseBigInt: true\n * Features: coercion from bigint / integer string to number\n */\n@Entity()\nexport class EntityWithParseBigInt {\n @NumberProperty({ parseBigInt: true }) amount!: number;\n @IntProperty({ parseBigInt: true }) count!: number;\n\n constructor(data: { amount: number; count: number }) {\n this.amount = data.amount;\n this.count = data.count;\n }\n}\n"],"names":["z","Entity","CollectionEntity","Stringifiable","EntityValidator","Property","StringProperty","NumberProperty","IntProperty","BooleanProperty","DateProperty","BigIntProperty","EnumProperty","EntityProperty","ArrayProperty","PassthroughProperty","SerializableProperty","StringifiableProperty","InjectedProperty","ZodProperty","Problem","TestUser","data","name","age","active","TestProduct","id","price","quantity","createdAt","EntityWithSpecialTypes","timestamp","largeNumber","label","ValidatedEntity","username","email","minLength","maxLength","pattern","min","max","CrossValidatedEntity","password","confirmPassword","startDate","endDate","validatePasswords","property","message","validateDates","OptionalFieldsEntity","requiredField","optionalField","optionalNumber","requiredBoolean","optional","EntityWithSerializedKey","firstName","lastName","serializedKey","factoryCallCount","EntityWithDefaults","counter","asyncField","enabled","default","Date","EntityWithArrays","tags","ratings","sparseArray","users","String","Number","sparse","UserRole","ProductStatus","EntityWithEnum","role","status","TestAddress","street","city","country","zipCode","TestCompany","address","employeeCount","TestEmployee","company","salary","hireDate","EntityWithOptionalNested","billingAddress","shippingAddress","TestTags","collection","TestIdList","TestUserCollection","TestUserId","value","TestEmail","EntityWithStringifiable","userId","LOGGER_TOKEN","Symbol","EntityWithDI","logger","logName","log","EntityWithPassthrough","metadata","config","CustomValue","x","y","toData","fromData","EntityWithCustomSerialization","position","type","serialize","v","deserialize","d","EntityWithContextSerialization","context","propertyName","entity","raw","rawObject","CustomPoint","equals","other","toString","fromString","str","split","map","EntityWithCustomEquals","location","a","b","SerializableValue","toJSON","parse","json","EntityWithSerializable","ParseableValue","EntityWithParseable","emailSchema","string","positiveIntSchema","number","int","positive","EntityWithZod","count","EntityWithImmutable","preventUpdates","ComplexEntity","products","score","updatedAt","validateProducts","length","resetFactoryCallCount","EntityWithParseBigInt","amount","parseBigInt"],"mappings":";;AAAA,OAAO,mBAAmB;AAC1B,SAASA,CAAC,QAAQ,MAAM;AACxB,SACEC,MAAM,EACNC,gBAAgB,EAChBC,aAAa,EACbC,e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;;;;;;;;;;;;;;;;;AAgD9B,+EAA+E;AAC/E,gDAAgD;AAChD,+EAA+E;AAE/E,OAAO,SAASqG;IACd1G,mBAAmB;AACrB;AAWA,OAAO,MAAM2G;IAIX,YAAYnJ,IAAuC,CAAE;QACnD,IAAI,CAACoJ,MAAM,GAAGpJ,KAAKoJ,MAAM;QACzB,IAAI,CAACX,KAAK,GAAGzI,KAAKyI,KAAK;IACzB;AACF;;;QAPoBY,aAAa;;;;;;QAChBA,aAAa"}
@@ -38,14 +38,14 @@ export declare const INJECTED_PROPERTY_OPTIONS_METADATA_KEY: unique symbol;
38
38
  export type AnyCtor<T = any> = Function & {
39
39
  prototype: T;
40
40
  };
41
- export type BuiltinCtors = StringConstructor | NumberConstructor | BooleanConstructor | BigIntConstructor | SymbolConstructor | DateConstructor;
41
+ export type BuiltinCtors = StringConstructor | NumberConstructor | BooleanConstructor | BigIntConstructor | SymbolConstructor | DateConstructor | BufferConstructor;
42
42
  /**
43
43
  * Type constructors for primitive types that can be deserialized
44
44
  * (excludes Symbol which cannot be deserialized from JSON)
45
45
  */
46
- export type PrimitiveConstructor = StringConstructor | NumberConstructor | BooleanConstructor | BigIntConstructor | DateConstructor;
46
+ export type PrimitiveConstructor = StringConstructor | NumberConstructor | BooleanConstructor | BigIntConstructor | DateConstructor | BufferConstructor;
47
47
  export type CtorLike<T> = AnyCtor<T> | BuiltinCtors;
48
- export type InstanceOfCtorLike<C> = C extends StringConstructor ? string : C extends NumberConstructor ? number : C extends BooleanConstructor ? boolean : C extends BigIntConstructor ? bigint : C extends SymbolConstructor ? symbol : C extends DateConstructor ? Date : C extends AnyCtor<infer T> ? T : never;
48
+ export type InstanceOfCtorLike<C> = C extends StringConstructor ? string : C extends NumberConstructor ? number : C extends BooleanConstructor ? boolean : C extends BigIntConstructor ? bigint : C extends SymbolConstructor ? symbol : C extends DateConstructor ? Date : C extends BufferConstructor ? Buffer : C extends AnyCtor<infer T> ? T : never;
49
49
  /**
50
50
  * Context passed to a custom serialize callback.
51
51
  */
@@ -124,6 +124,17 @@ export interface PropertyOptions<T = any, C extends CtorLike<T> = AnyCtor<T> | B
124
124
  * metadata!: Record<string, unknown>;
125
125
  */
126
126
  passthrough?: boolean;
127
+ /**
128
+ * Whether this property holds sensitive data (e.g. a password hash).
129
+ * When true, the message of every problem reported for this property during
130
+ * parse, update or validation is replaced with a redacted placeholder so
131
+ * the value cannot leak through error messages. The property path is kept.
132
+ * Defaults to false.
133
+ * @example
134
+ * @Property({ type: () => String, sensitive: true })
135
+ * passwordHash!: string;
136
+ */
137
+ sensitive?: boolean;
127
138
  /**
128
139
  * Whether to prevent this property from being updated via EntityUtils.update().
129
140
  * When true, this property cannot be modified through update operations.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,qBAAqB,eAA8B,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,6BAA6B,eAEzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,eAA4B,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,2BAA2B,eAAoC,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,6BAA6B,eAEzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iCAAiC,eAE7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gCAAgC,eAE5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B,eAE1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sCAAsC,eAElD,CAAC;AAEF,MAAM,MAAM,OAAO,CAAC,CAAC,GAAG,GAAG,IAAI,QAAQ,GAAG;IAAE,SAAS,EAAE,CAAC,CAAA;CAAE,CAAC;AAE3D,MAAM,MAAM,YAAY,GACpB,iBAAiB,GACjB,iBAAiB,GACjB,kBAAkB,GAClB,iBA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IAAI,EAAE,CAAC,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,GAC/C;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,CAC3D,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-function-type */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-wrapper-object-types */\nimport type { Problem } from './problem.js';\n\n/**\n * Metadata key used to store property information\n */\nexport const PROPERTY_METADATA_KEY = Symbol('property:metadata');\n\n/**\n * Metadata key used to store property options\n */\nexport const PROPERTY_OPTIONS_METADATA_KEY = Symbol(\n 'property:options:metadata',\n);\n\n/**\n * Metadata key used to store entity information\n */\nexport const ENTITY_METADATA_KEY = Symbol('entity:metadata');\n\n/**\n * Metadata key used to store entity options\n */\nexport const ENTITY_OPTIONS_METADATA_KEY = Symbol('entity:options:metadata');\n\n/**\n * Metadata key used to store entity validator methods\n */\nexport const ENTITY_VALIDATOR_METADATA_KEY = Symbol(\n 'entity:validator:metadata',\n);\n\n/**\n * Metadata key used to store polymorphic discriminator property information\n */\nexport const POLYMORPHIC_PROPERTY_METADATA_KEY = Symbol(\n 'polymorphic:property:metadata',\n);\n\n/**\n * Metadata key used to store polymorphic variant information\n */\nexport const POLYMORPHIC_VARIANT_METADATA_KEY = Symbol(\n 'polymorphic:variant:metadata',\n);\n\n/**\n * Metadata key used to store injected property information\n */\nexport const INJECTED_PROPERTY_METADATA_KEY = Symbol(\n 'injected-property:metadata',\n);\n\n/**\n * Metadata key used to store injected property options (tokens)\n */\nexport const INJECTED_PROPERTY_OPTIONS_METADATA_KEY = Symbol(\n 'injected-property:options:metadata',\n);\n\nexport type AnyCtor<T = any> = Function & { prototype: T };\n\nexport type BuiltinCtors =\n | StringConstructor\n | NumberConstructor\n | BooleanConstructor\n | BigIntConstructor\n | SymbolConstructor\n | DateConstructor;\n\n/**\n * Type constructors for primitive types that can be deserialized\n * (excludes Symbol which cannot be deserialized from JSON)\n */\nexport type PrimitiveConstructor =\n | StringConstructor\n | NumberConstructor\n | BooleanConstructor\n | BigIntConstructor\n | DateConstructor;\n\nexport type CtorLike<T> = AnyCtor<T> | BuiltinCtors;\n\nexport type InstanceOfCtorLike<C> = C extends StringConstructor\n ? string\n : C extends NumberConstructor\n ? number\n : C extends BooleanConstructor\n ? boolean\n : C extends BigIntConstructor\n ? bigint\n : C extends SymbolConstructor\n ? symbol\n : C extends DateConstructor\n ? Date\n : C extends AnyCtor<infer T>\n ? T\n : never;\n\n/**\n * Context passed to a custom serialize callback.\n */\nexport interface PropertySerializeContext {\n /** The property key being serialized */\n propertyName: string;\n /** The full entity instance being serialized */\n entity: Record<string, unknown>;\n}\n\n/**\n * Context passed to a custom deserialize callback.\n */\nexport interface PropertyDeserializeContext {\n /** The property key being deserialized */\n propertyName: string;\n /** The original raw input object (JSON) */\n rawObject: Record<string, unknown>;\n}\n\n/**\n * Options for the Property decorator\n */\nexport interface PropertyOptions<\n T = any,\n C extends CtorLike<T> = AnyCtor<T> | BuiltinCtors,\n> {\n /**\n * Custom equality comparison function for this property\n * @param a - First value to compare\n * @param b - Second value to compare\n * @returns true if values are equal, false otherwise\n */\n equals?: (a: InstanceOfCtorLike<C>, b: InstanceOfCtorLike<C>) => boolean;\n\n /**\n * Type constructor for this property. Required for EntityUtils.parse() support.\n * Use a function that returns the type constructor to support forward references.\n * Not required for discriminated entity properties nor passthrough properties.\n * @example\n * @Property({ type: () => String })\n * name!: string;\n *\n * @Property({ type: () => Address })\n * address!: Address;\n */\n type?: () => C;\n\n /**\n * Whether this property is an array. Defaults to false.\n * When true, the deserializer will map over array elements.\n * @example\n * @Property({ type: () => String, array: true })\n * tags!: string[];\n */\n array?: boolean;\n\n /**\n * Whether this property is optional. Defaults to false.\n * When true, the property can be undefined or null.\n * When false, the property must be present and not null/undefined.\n * @example\n * @Property({ type: () => String, optional: true })\n * nickname?: string;\n */\n optional?: boolean;\n\n /**\n * Whether the array can contain null/undefined elements. Defaults to false.\n * Only applicable when array is true.\n * When false (default), null/undefined elements will cause an error.\n * When true, null/undefined elements are allowed in the array.\n * @example\n * @Property({ type: () => String, array: true, sparse: true })\n * tags!: (string | null)[];\n */\n sparse?: boolean;\n\n /**\n * Whether to bypass type validation and pass values through as-is.\n * Use this for generic types like Record<string, unknown> or any.\n * When true, no type checking or transformation is performed.\n * Also bypasses any custom serialize/deserialize callbacks.\n * @example\n * @Property({ passthrough: true })\n * metadata!: Record<string, unknown>;\n */\n passthrough?: boolean;\n\n /**\n * Whether to prevent this property from being updated via EntityUtils.update().\n * When true, this property cannot be modified through update operations.\n * Defaults to false, allowing the property to be updated.\n * @example\n * @Property({ type: () => String, preventUpdates: true })\n * id!: string; // This property cannot be updated\n */\n preventUpdates?: boolean;\n\n /**\n * Default value for the property when not provided during deserialization.\n * Can be a static value or a function that returns the default value.\n * The function can be async and return a Promise.\n * @example\n * @Property({ type: () => String, default: 'N/A' })\n * nickname?: string;\n *\n * @Property({ type: () => Date, default: () => new Date() })\n * createdAt!: Date;\n *\n * @Property({ type: () => String, default: async () => await fetchDefaultValue() })\n * value!: string;\n */\n default?:\n | InstanceOfCtorLike<C>\n | (() => InstanceOfCtorLike<C> | Promise<InstanceOfCtorLike<C>>);\n\n /**\n * Custom serialization function to convert the property value to JSON-compatible format.\n * Must be paired with deserialize - both must be defined together or both omitted.\n * Not used when passthrough is true.\n * @example\n * @Property({\n * type: () => MyClass,\n * serialize: (value) => ({ data: value.toData() }),\n * deserialize: (json) => MyClass.fromData(json.data)\n * })\n * myProperty!: MyClass;\n */\n serialize?: (\n value: InstanceOfCtorLike<C>,\n context: PropertySerializeContext,\n ) => unknown;\n\n /**\n * Custom deserialization function to convert JSON data back to the property type.\n * Must be paired with serialize - both must be defined together or both omitted.\n * Not used when passthrough is true.\n * @example\n * @Property({\n * type: () => MyClass,\n * serialize: (value) => ({ data: value.toData() }),\n * deserialize: (json) => MyClass.fromData(json.data)\n * })\n * myProperty!: MyClass;\n */\n deserialize?: (\n serialized: unknown,\n context: PropertyDeserializeContext,\n ) => InstanceOfCtorLike<C>;\n\n /**\n * Array of validator functions for this property.\n * Each validator receives the property value and validation context.\n * Empty array means validation passed.\n * If the property is an array (array: true), these validators will run against each item.\n * Use arrayValidators instead to validate the array as a whole.\n * If passthrough is true, validators will run against the raw value.\n * @example\n * @Property({\n * type: () => String,\n * validators: [\n * (value, { createProblem }) =>\n * value.length > 10 ? [createProblem('Too long')] : []\n * ]\n * })\n * name!: string;\n */\n validators?: PropertyValidator<InstanceOfCtorLike<C>>[];\n\n /**\n * Array of validator functions for this property when it is an array.\n * Each validator receives the array value and validation context.\n * Empty array means validation passed.\n * Only applicable when array is true.\n * Not applicable when passthrough is true.\n * @example\n * @Property({\n * type: () => Number,\n * array: true,\n * arrayValidators: [\n * (value, { createProblem }) =>\n * value.length === 0 ? [createProblem('Array cannot be empty')] : []\n * ]\n * })\n * scores!: number[];\n */\n arrayValidators?: PropertyValidator<InstanceOfCtorLike<C>[]>[];\n\n /**\n * Indicates this property uses discriminated entity types.\n * The discriminator property name (e.g., '__type') is used to determine the entity type at runtime.\n * When true, serialization will include the discriminator inline with the entity.\n * During deserialization, the discriminator value is used to lookup the entity class in EntityRegistry.\n * @example\n * @DiscriminatedEntityProperty({ discriminatorProperty: '__type' })\n * item!: BaseItem; // Could be ItemA or ItemB at runtime\n */\n discriminated?: boolean;\n\n /**\n * The key to use for this property in the serialized JSON representation.\n * Defaults to the property's own name. Use this to map a property to a\n * differently-named field on the wire (e.g. camelCase in code, snake_case in JSON).\n * @example\n * @Property({ type: () => String, serializedKey: 'first_name' })\n * firstName!: string;\n */\n serializedKey?: string;\n\n /**\n * The property name to use as the discriminator for discriminated entity properties.\n * Defaults to '__type' if not specified.\n * Only applicable when discriminated is true.\n * @example\n * @DiscriminatedEntityProperty({ discriminatorProperty: 'entityType' })\n * item!: BaseItem;\n */\n discriminatorProperty?: string;\n\n /**\n * Indicates this property is a polymorphic discriminator.\n * The property value determines which subclass variant to instantiate during parsing.\n * Used for class hierarchies where the discriminator is part of the class definition.\n * @example\n * @PolymorphicProperty(SchemaPropertyType)\n * type!: SchemaPropertyType;\n */\n polymorphicDiscriminator?: boolean;\n\n /**\n * The enum or union type for the polymorphic discriminator.\n * Used for validation and schema generation (e.g., Zod enums).\n * @example\n * @PolymorphicProperty(SchemaPropertyType)\n * type!: SchemaPropertyType;\n */\n polymorphicEnumType?: any;\n}\n\n/**\n * A validator function for a property.\n * The validator receives the value and returns Problems with property paths relative to the value.\n * Can be synchronous or asynchronous.\n * The calling code will prepend the actual property key to all returned problems.\n *\n * @param data - Object containing the value to validate\n * @param data.value - The value to validate\n * @returns Array of Problems (empty if valid) or Promise resolving to Problems.\n * Problems should have empty property for the value itself,\n * or relative paths for nested properties (e.g., 'name', '[0]', 'address.street')\n *\n * @example\n * ```typescript\n * // Synchronous validator\n * (({ value }) =>\n * value.length < 3 ? [new Problem({ property: '', message: 'Too short' })] : [])\n *\n * // Asynchronous validator\n * async ({ value }) => {\n * const exists = await checkDatabase(value);\n * return exists ? [] : [new Problem({ property: '', message: 'Not found' })];\n * }\n * ```\n */\nexport type PropertyValidator<T> = (data: {\n value: T;\n}) => Problem[] | Promise<Problem[]>;\n\n/**\n * A validator function for an entity.\n * Can be synchronous or asynchronous.\n * @param instance - The entity instance to validate\n * @returns Array of Problems (empty if valid) or Promise resolving to Problems\n */\nexport type EntityValidatorFn<T = any> = (\n instance: T,\n) => Problem[] | Promise<Problem[]>;\n\nexport interface Type<T = any> extends Function {\n new (...args: any[]): T;\n}\n\nexport type EntityDIToken<T = any> =\n | string\n | symbol\n | Function\n | AnyCtor<T>\n | Type<T>;\n\nexport type EntityDIProvider<T = any> =\n | {\n provide: EntityDIToken<T>;\n useValue?: T;\n useFactory?: never;\n }\n | {\n provide: EntityDIToken<T>;\n useValue?: never;\n useFactory?: () => T | Promise<T>;\n };\n\nexport type EntityDIFallbackFn = (token: EntityDIToken) => Promise<any>;\n\n/**\n * Generic type for safe operation results that can succeed or fail\n * @template T - The data type on success\n */\nexport type SafeOperationResult<T> = Promise<\n | { success: true; data: T; problems: Problem[] }\n | { success: false; data: undefined; problems: Problem[] }\n>;\n\nexport type ParseOptions = { strict?: boolean };\n"],"names":["PROPERTY_METADATA_KEY","Symbol","PROPERTY_OPTIONS_METADATA_KEY","ENTITY_METADATA_KEY","ENTITY_OPTIONS_METADATA_KEY","ENTITY_VALIDATOR_METADATA_KEY","POLYMORPHIC_PROPERTY_METADATA_KEY","POLYMORPHIC_VARIANT_METADATA_KEY","INJECTED_PROPERTY_METADATA_KEY","INJECTED_PROPERTY_OPTIONS_METADATA_KEY"],"mappings":"AAAA,6DAA6D,GAC7D,qDAAqD,GACrD,6DAA6D,GAG7D;;CAEC,GACD,OAAO,MAAMA,wBAAwBC,OAAO,qBAAqB;AAEjE;;CAEC,GACD,OAAO,MAAMC,gCAAgCD,OAC3C,6BACA;AAEF;;CAEC,GACD,OAAO,MAAME,sBAAsBF,OAAO,mBAAmB;AAE7D;;CAEC,GACD,OAAO,MAAMG,8BAA8BH,OAAO,2BAA2B;AAE7E;;CAEC,GACD,OAAO,MAAMI,gCAAgCJ,OAC3C,6BACA;AAEF;;CAEC,GACD,OAAO,MAAMK,oCAAoCL,OAC/C,iCACA;AAEF;;CAEC,GACD,OAAO,MAAMM,mCAAmCN,OAC9C,gCACA;AAEF;;CAEC,GACD,OAAO,MAAMO,iCAAiCP,OAC5C,8BACA;AAEF;;CAEC,GACD,OAAO,MAAMQ,yCAAyCR,OACpD,sCACA"}
1
+ {"version":3,"sources":["../../src/lib/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-function-type */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-wrapper-object-types */\nimport type { Problem } from './problem.js';\n\n/**\n * Metadata key used to store property information\n */\nexport const PROPERTY_METADATA_KEY = Symbol('property:metadata');\n\n/**\n * Metadata key used to store property options\n */\nexport const PROPERTY_OPTIONS_METADATA_KEY = Symbol(\n 'property:options:metadata',\n);\n\n/**\n * Metadata key used to store entity information\n */\nexport const ENTITY_METADATA_KEY = Symbol('entity:metadata');\n\n/**\n * Metadata key used to store entity options\n */\nexport const ENTITY_OPTIONS_METADATA_KEY = Symbol('entity:options:metadata');\n\n/**\n * Metadata key used to store entity validator methods\n */\nexport const ENTITY_VALIDATOR_METADATA_KEY = Symbol(\n 'entity:validator:metadata',\n);\n\n/**\n * Metadata key used to store polymorphic discriminator property information\n */\nexport const POLYMORPHIC_PROPERTY_METADATA_KEY = Symbol(\n 'polymorphic:property:metadata',\n);\n\n/**\n * Metadata key used to store polymorphic variant information\n */\nexport const POLYMORPHIC_VARIANT_METADATA_KEY = Symbol(\n 'polymorphic:variant:metadata',\n);\n\n/**\n * Metadata key used to store injected property information\n */\nexport const INJECTED_PROPERTY_METADATA_KEY = Symbol(\n 'injected-property:metadata',\n);\n\n/**\n * Metadata key used to store injected property options (tokens)\n */\nexport const INJECTED_PROPERTY_OPTIONS_METADATA_KEY = Symbol(\n 'injected-property:options:metadata',\n);\n\nexport type AnyCtor<T = any> = Function & { prototype: T };\n\nexport type BuiltinCtors =\n | StringConstructor\n | NumberConstructor\n | BooleanConstructor\n | BigIntConstructor\n | SymbolConstructor\n | DateConstructor\n | BufferConstructor;\n\n/**\n * Type constructors for primitive types that can be deserialized\n * (excludes Symbol which cannot be deserialized from JSON)\n */\nexport type PrimitiveConstructor =\n | StringConstructor\n | NumberConstructor\n | BooleanConstructor\n | BigIntConstructor\n | DateConstructor\n | BufferConstructor;\n\nexport type CtorLike<T> = AnyCtor<T> | BuiltinCtors;\n\nexport type InstanceOfCtorLike<C> = C extends StringConstructor\n ? string\n : C extends NumberConstructor\n ? number\n : C extends BooleanConstructor\n ? boolean\n : C extends BigIntConstructor\n ? bigint\n : C extends SymbolConstructor\n ? symbol\n : C extends DateConstructor\n ? Date\n : C extends BufferConstructor\n ? Buffer\n : C extends AnyCtor<infer T>\n ? T\n : never;\n\n/**\n * Context passed to a custom serialize callback.\n */\nexport interface PropertySerializeContext {\n /** The property key being serialized */\n propertyName: string;\n /** The full entity instance being serialized */\n entity: Record<string, unknown>;\n}\n\n/**\n * Context passed to a custom deserialize callback.\n */\nexport interface PropertyDeserializeContext {\n /** The property key being deserialized */\n propertyName: string;\n /** The original raw input object (JSON) */\n rawObject: Record<string, unknown>;\n}\n\n/**\n * Options for the Property decorator\n */\nexport interface PropertyOptions<\n T = any,\n C extends CtorLike<T> = AnyCtor<T> | BuiltinCtors,\n> {\n /**\n * Custom equality comparison function for this property\n * @param a - First value to compare\n * @param b - Second value to compare\n * @returns true if values are equal, false otherwise\n */\n equals?: (a: InstanceOfCtorLike<C>, b: InstanceOfCtorLike<C>) => boolean;\n\n /**\n * Type constructor for this property. Required for EntityUtils.parse() support.\n * Use a function that returns the type constructor to support forward references.\n * Not required for discriminated entity properties nor passthrough properties.\n * @example\n * @Property({ type: () => String })\n * name!: string;\n *\n * @Property({ type: () => Address })\n * address!: Address;\n */\n type?: () => C;\n\n /**\n * Whether this property is an array. Defaults to false.\n * When true, the deserializer will map over array elements.\n * @example\n * @Property({ type: () => String, array: true })\n * tags!: string[];\n */\n array?: boolean;\n\n /**\n * Whether this property is optional. Defaults to false.\n * When true, the property can be undefined or null.\n * When false, the property must be present and not null/undefined.\n * @example\n * @Property({ type: () => String, optional: true })\n * nickname?: string;\n */\n optional?: boolean;\n\n /**\n * Whether the array can contain null/undefined elements. Defaults to false.\n * Only applicable when array is true.\n * When false (default), null/undefined elements will cause an error.\n * When true, null/undefined elements are allowed in the array.\n * @example\n * @Property({ type: () => String, array: true, sparse: true })\n * tags!: (string | null)[];\n */\n sparse?: boolean;\n\n /**\n * Whether to bypass type validation and pass values through as-is.\n * Use this for generic types like Record<string, unknown> or any.\n * When true, no type checking or transformation is performed.\n * Also bypasses any custom serialize/deserialize callbacks.\n * @example\n * @Property({ passthrough: true })\n * metadata!: Record<string, unknown>;\n */\n passthrough?: boolean;\n\n /**\n * Whether this property holds sensitive data (e.g. a password hash).\n * When true, the message of every problem reported for this property during\n * parse, update or validation is replaced with a redacted placeholder so\n * the value cannot leak through error messages. The property path is kept.\n * Defaults to false.\n * @example\n * @Property({ type: () => String, sensitive: true })\n * passwordHash!: string;\n */\n sensitive?: boolean;\n\n /**\n * Whether to prevent this property from being updated via EntityUtils.update().\n * When true, this property cannot be modified through update operations.\n * Defaults to false, allowing the property to be updated.\n * @example\n * @Property({ type: () => String, preventUpdates: true })\n * id!: string; // This property cannot be updated\n */\n preventUpdates?: boolean;\n\n /**\n * Default value for the property when not provided during deserialization.\n * Can be a static value or a function that returns the default value.\n * The function can be async and return a Promise.\n * @example\n * @Property({ type: () => String, default: 'N/A' })\n * nickname?: string;\n *\n * @Property({ type: () => Date, default: () => new Date() })\n * createdAt!: Date;\n *\n * @Property({ type: () => String, default: async () => await fetchDefaultValue() })\n * value!: string;\n */\n default?:\n | InstanceOfCtorLike<C>\n | (() => InstanceOfCtorLike<C> | Promise<InstanceOfCtorLike<C>>);\n\n /**\n * Custom serialization function to convert the property value to JSON-compatible format.\n * Must be paired with deserialize - both must be defined together or both omitted.\n * Not used when passthrough is true.\n * @example\n * @Property({\n * type: () => MyClass,\n * serialize: (value) => ({ data: value.toData() }),\n * deserialize: (json) => MyClass.fromData(json.data)\n * })\n * myProperty!: MyClass;\n */\n serialize?: (\n value: InstanceOfCtorLike<C>,\n context: PropertySerializeContext,\n ) => unknown;\n\n /**\n * Custom deserialization function to convert JSON data back to the property type.\n * Must be paired with serialize - both must be defined together or both omitted.\n * Not used when passthrough is true.\n * @example\n * @Property({\n * type: () => MyClass,\n * serialize: (value) => ({ data: value.toData() }),\n * deserialize: (json) => MyClass.fromData(json.data)\n * })\n * myProperty!: MyClass;\n */\n deserialize?: (\n serialized: unknown,\n context: PropertyDeserializeContext,\n ) => InstanceOfCtorLike<C>;\n\n /**\n * Array of validator functions for this property.\n * Each validator receives the property value and validation context.\n * Empty array means validation passed.\n * If the property is an array (array: true), these validators will run against each item.\n * Use arrayValidators instead to validate the array as a whole.\n * If passthrough is true, validators will run against the raw value.\n * @example\n * @Property({\n * type: () => String,\n * validators: [\n * (value, { createProblem }) =>\n * value.length > 10 ? [createProblem('Too long')] : []\n * ]\n * })\n * name!: string;\n */\n validators?: PropertyValidator<InstanceOfCtorLike<C>>[];\n\n /**\n * Array of validator functions for this property when it is an array.\n * Each validator receives the array value and validation context.\n * Empty array means validation passed.\n * Only applicable when array is true.\n * Not applicable when passthrough is true.\n * @example\n * @Property({\n * type: () => Number,\n * array: true,\n * arrayValidators: [\n * (value, { createProblem }) =>\n * value.length === 0 ? [createProblem('Array cannot be empty')] : []\n * ]\n * })\n * scores!: number[];\n */\n arrayValidators?: PropertyValidator<InstanceOfCtorLike<C>[]>[];\n\n /**\n * Indicates this property uses discriminated entity types.\n * The discriminator property name (e.g., '__type') is used to determine the entity type at runtime.\n * When true, serialization will include the discriminator inline with the entity.\n * During deserialization, the discriminator value is used to lookup the entity class in EntityRegistry.\n * @example\n * @DiscriminatedEntityProperty({ discriminatorProperty: '__type' })\n * item!: BaseItem; // Could be ItemA or ItemB at runtime\n */\n discriminated?: boolean;\n\n /**\n * The key to use for this property in the serialized JSON representation.\n * Defaults to the property's own name. Use this to map a property to a\n * differently-named field on the wire (e.g. camelCase in code, snake_case in JSON).\n * @example\n * @Property({ type: () => String, serializedKey: 'first_name' })\n * firstName!: string;\n */\n serializedKey?: string;\n\n /**\n * The property name to use as the discriminator for discriminated entity properties.\n * Defaults to '__type' if not specified.\n * Only applicable when discriminated is true.\n * @example\n * @DiscriminatedEntityProperty({ discriminatorProperty: 'entityType' })\n * item!: BaseItem;\n */\n discriminatorProperty?: string;\n\n /**\n * Indicates this property is a polymorphic discriminator.\n * The property value determines which subclass variant to instantiate during parsing.\n * Used for class hierarchies where the discriminator is part of the class definition.\n * @example\n * @PolymorphicProperty(SchemaPropertyType)\n * type!: SchemaPropertyType;\n */\n polymorphicDiscriminator?: boolean;\n\n /**\n * The enum or union type for the polymorphic discriminator.\n * Used for validation and schema generation (e.g., Zod enums).\n * @example\n * @PolymorphicProperty(SchemaPropertyType)\n * type!: SchemaPropertyType;\n */\n polymorphicEnumType?: any;\n}\n\n/**\n * A validator function for a property.\n * The validator receives the value and returns Problems with property paths relative to the value.\n * Can be synchronous or asynchronous.\n * The calling code will prepend the actual property key to all returned problems.\n *\n * @param data - Object containing the value to validate\n * @param data.value - The value to validate\n * @returns Array of Problems (empty if valid) or Promise resolving to Problems.\n * Problems should have empty property for the value itself,\n * or relative paths for nested properties (e.g., 'name', '[0]', 'address.street')\n *\n * @example\n * ```typescript\n * // Synchronous validator\n * (({ value }) =>\n * value.length < 3 ? [new Problem({ property: '', message: 'Too short' })] : [])\n *\n * // Asynchronous validator\n * async ({ value }) => {\n * const exists = await checkDatabase(value);\n * return exists ? [] : [new Problem({ property: '', message: 'Not found' })];\n * }\n * ```\n */\nexport type PropertyValidator<T> = (data: {\n value: T;\n}) => Problem[] | Promise<Problem[]>;\n\n/**\n * A validator function for an entity.\n * Can be synchronous or asynchronous.\n * @param instance - The entity instance to validate\n * @returns Array of Problems (empty if valid) or Promise resolving to Problems\n */\nexport type EntityValidatorFn<T = any> = (\n instance: T,\n) => Problem[] | Promise<Problem[]>;\n\nexport interface Type<T = any> extends Function {\n new (...args: any[]): T;\n}\n\nexport type EntityDIToken<T = any> =\n string | symbol | Function | AnyCtor<T> | Type<T>;\n\nexport type EntityDIProvider<T = any> =\n | {\n provide: EntityDIToken<T>;\n useValue?: T;\n useFactory?: never;\n }\n | {\n provide: EntityDIToken<T>;\n useValue?: never;\n useFactory?: () => T | Promise<T>;\n };\n\nexport type EntityDIFallbackFn = (token: EntityDIToken) => Promise<any>;\n\n/**\n * Generic type for safe operation results that can succeed or fail\n * @template T - The data type on success\n */\nexport type SafeOperationResult<T> = Promise<\n | { success: true; data: T; problems: Problem[] }\n | { success: false; data: undefined; problems: Problem[] }\n>;\n\nexport type ParseOptions = { strict?: boolean };\n"],"names":["PROPERTY_METADATA_KEY","Symbol","PROPERTY_OPTIONS_METADATA_KEY","ENTITY_METADATA_KEY","ENTITY_OPTIONS_METADATA_KEY","ENTITY_VALIDATOR_METADATA_KEY","POLYMORPHIC_PROPERTY_METADATA_KEY","POLYMORPHIC_VARIANT_METADATA_KEY","INJECTED_PROPERTY_METADATA_KEY","INJECTED_PROPERTY_OPTIONS_METADATA_KEY"],"mappings":"AAAA,6DAA6D,GAC7D,qDAAqD,GACrD,6DAA6D,GAG7D;;CAEC,GACD,OAAO,MAAMA,wBAAwBC,OAAO,qBAAqB;AAEjE;;CAEC,GACD,OAAO,MAAMC,gCAAgCD,OAC3C,6BACA;AAEF;;CAEC,GACD,OAAO,MAAME,sBAAsBF,OAAO,mBAAmB;AAE7D;;CAEC,GACD,OAAO,MAAMG,8BAA8BH,OAAO,2BAA2B;AAE7E;;CAEC,GACD,OAAO,MAAMI,gCAAgCJ,OAC3C,6BACA;AAEF;;CAEC,GACD,OAAO,MAAMK,oCAAoCL,OAC/C,iCACA;AAEF;;CAEC,GACD,OAAO,MAAMM,mCAAmCN,OAC9C,gCACA;AAEF;;CAEC,GACD,OAAO,MAAMO,iCAAiCP,OAC5C,8BACA;AAEF;;CAEC,GACD,OAAO,MAAMQ,yCAAyCR,OACpD,sCACA"}
@@ -83,4 +83,16 @@ export declare function prependPropertyPath(propertyPath: string, problems: Prob
83
83
  * ```
84
84
  */
85
85
  export declare function prependArrayIndex(index: number, error: ValidationError): Problem[];
86
+ /**
87
+ * Message used in place of any problem message for sensitive properties.
88
+ */
89
+ export declare const REDACTED_MESSAGE = "Invalid value [REDACTED]";
90
+ /**
91
+ * Replaces the message of every problem with a redacted placeholder,
92
+ * keeping the property path. Used for properties marked `sensitive`.
93
+ *
94
+ * @param problems - The problems to redact
95
+ * @returns New problems with redacted messages
96
+ */
97
+ export declare function redactProblems(problems: Problem[]): Problem[];
86
98
  //# sourceMappingURL=validation-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation-utils.d.ts","sourceRoot":"","sources":["../../src/lib/validation-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQ3E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAOtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,OAAO,EAAE,GAClB,OAAO,EAAE,CAOX;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,eAAe,GACrB,OAAO,EAAE,CAOX"}
1
+ {"version":3,"file":"validation-utils.d.ts","sourceRoot":"","sources":["../../src/lib/validation-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQ3E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAOtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,OAAO,EAAE,GAClB,OAAO,EAAE,CAOX;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,eAAe,GACrB,OAAO,EAAE,CAOX;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAK7D"}
@@ -108,5 +108,20 @@ import { ValidationError } from './validation-error.js';
108
108
  });
109
109
  });
110
110
  }
111
+ /**
112
+ * Message used in place of any problem message for sensitive properties.
113
+ */ export const REDACTED_MESSAGE = 'Invalid value [REDACTED]';
114
+ /**
115
+ * Replaces the message of every problem with a redacted placeholder,
116
+ * keeping the property path. Used for properties marked `sensitive`.
117
+ *
118
+ * @param problems - The problems to redact
119
+ * @returns New problems with redacted messages
120
+ */ export function redactProblems(problems) {
121
+ return problems.map((problem)=>new Problem({
122
+ property: problem.property,
123
+ message: REDACTED_MESSAGE
124
+ }));
125
+ }
111
126
 
112
127
  //# sourceMappingURL=validation-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/validation-utils.ts"],"sourcesContent":["import { Problem } from './problem.js';\nimport { ValidationError } from './validation-error.js';\n\n/**\n * Combines a property path prefix with a suffix according to deterministic rules:\n * - If suffix is empty, returns prefix\n * - If suffix starts with '[', concatenates without separator (e.g., 'items' + '[0]' → 'items[0]')\n * - Otherwise, concatenates with dot separator (e.g., 'user' + 'name' → 'user.name')\n *\n * @param prefix - The property path to prepend\n * @param suffix - The property path to append\n * @returns The combined property path\n *\n * @example\n * ```typescript\n * combinePropertyPaths('user', '') // 'user'\n * combinePropertyPaths('user', 'name') // 'user.name'\n * combinePropertyPaths('items', '[0]') // 'items[0]'\n * combinePropertyPaths('[0]', 'name') // '[0].name'\n * ```\n */\nexport function combinePropertyPaths(prefix: string, suffix: string): string {\n if (suffix === '') {\n return prefix;\n }\n if (suffix.startsWith('[')) {\n return `${prefix}${suffix}`;\n }\n return `${prefix}.${suffix}`;\n}\n\n/**\n * Creates a ValidationError with a single problem that has an empty property.\n * This is used when reporting errors at the current scope level, where the caller\n * will prepend the appropriate context path.\n *\n * @param message - The error message\n * @returns A ValidationError with a single problem with empty property\n *\n * @example\n * ```typescript\n * throw createValidationError('Expects a string but received number');\n * // Creates: ValidationError([{ property: '', message: 'Expects a string but received number' }])\n * ```\n */\nexport function createValidationError(message: string): ValidationError {\n return new ValidationError([\n new Problem({\n property: '',\n message,\n }),\n ]);\n}\n\n/**\n * Prepends a property path to all problems.\n * Problems with empty property names get the path directly.\n * Problems starting with '[' get the path without a dot separator.\n * Other problems get the path with a dot separator.\n *\n * @param propertyPath - The property path to prepend (e.g., 'user', 'items[0]')\n * @param problems - The array of Problems to process\n * @returns Array of Problems with the property path prepended\n *\n * @example\n * ```typescript\n * const problems = [\n * new Problem({ property: '', message: 'Invalid type' }),\n * new Problem({ property: 'name', message: 'Required' }),\n * new Problem({ property: '[0]', message: 'Invalid element' })\n * ];\n * const result = prependPropertyPath('user', problems);\n * // [\n * // { property: 'user', message: 'Invalid type' },\n * // { property: 'user.name', message: 'Required' },\n * // { property: 'user[0]', message: 'Invalid element' }\n * // ]\n * ```\n */\nexport function prependPropertyPath(\n propertyPath: string,\n problems: Problem[],\n): Problem[] {\n return problems.map((problem) => {\n return new Problem({\n property: combinePropertyPaths(propertyPath, problem.property),\n message: problem.message,\n });\n });\n}\n\n/**\n * Prepends an array index to all problems in a ValidationError.\n * Problems with empty property get `[index]` directly.\n * Problems with non-empty property get `[index].property` format.\n *\n * @param index - The array index to prepend\n * @param error - The ValidationError containing problems to process\n * @returns Array of Problems with the array index prepended\n *\n * @example\n * ```typescript\n * const error = new ValidationError([\n * new Problem({ property: '', message: 'Invalid type' }),\n * new Problem({ property: 'name', message: 'Required' })\n * ]);\n * const problems = prependArrayIndex(0, error);\n * // [\n * // { property: '[0]', message: 'Invalid type' },\n * // { property: '[0].name', message: 'Required' }\n * // ]\n * ```\n */\nexport function prependArrayIndex(\n index: number,\n error: ValidationError,\n): Problem[] {\n return error.problems.map((problem) => {\n return new Problem({\n property: combinePropertyPaths(`[${index}]`, problem.property),\n message: problem.message,\n });\n });\n}\n"],"names":["Problem","ValidationError","combinePropertyPaths","prefix","suffix","startsWith","createValidationError","message","property","prependPropertyPath","propertyPath","problems","map","problem","prependArrayIndex","index","error"],"mappings":"AAAA,SAASA,OAAO,QAAQ,eAAe;AACvC,SAASC,eAAe,QAAQ,wBAAwB;AAExD;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASC,qBAAqBC,MAAc,EAAEC,MAAc;IACjE,IAAIA,WAAW,IAAI;QACjB,OAAOD;IACT;IACA,IAAIC,OAAOC,UAAU,CAAC,MAAM;QAC1B,OAAO,GAAGF,SAASC,QAAQ;IAC7B;IACA,OAAO,GAAGD,OAAO,CAAC,EAAEC,QAAQ;AAC9B;AAEA;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASE,sBAAsBC,OAAe;IACnD,OAAO,IAAIN,gBAAgB;QACzB,IAAID,QAAQ;YACVQ,UAAU;YACVD;QACF;KACD;AACH;AAEA;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,SAASE,oBACdC,YAAoB,EACpBC,QAAmB;IAEnB,OAAOA,SAASC,GAAG,CAAC,CAACC;QACnB,OAAO,IAAIb,QAAQ;YACjBQ,UAAUN,qBAAqBQ,cAAcG,QAAQL,QAAQ;YAC7DD,SAASM,QAAQN,OAAO;QAC1B;IACF;AACF;AAEA;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASO,kBACdC,KAAa,EACbC,KAAsB;IAEtB,OAAOA,MAAML,QAAQ,CAACC,GAAG,CAAC,CAACC;QACzB,OAAO,IAAIb,QAAQ;YACjBQ,UAAUN,qBAAqB,CAAC,CAAC,EAAEa,MAAM,CAAC,CAAC,EAAEF,QAAQL,QAAQ;YAC7DD,SAASM,QAAQN,OAAO;QAC1B;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/lib/validation-utils.ts"],"sourcesContent":["import { Problem } from './problem.js';\nimport { ValidationError } from './validation-error.js';\n\n/**\n * Combines a property path prefix with a suffix according to deterministic rules:\n * - If suffix is empty, returns prefix\n * - If suffix starts with '[', concatenates without separator (e.g., 'items' + '[0]' → 'items[0]')\n * - Otherwise, concatenates with dot separator (e.g., 'user' + 'name' → 'user.name')\n *\n * @param prefix - The property path to prepend\n * @param suffix - The property path to append\n * @returns The combined property path\n *\n * @example\n * ```typescript\n * combinePropertyPaths('user', '') // 'user'\n * combinePropertyPaths('user', 'name') // 'user.name'\n * combinePropertyPaths('items', '[0]') // 'items[0]'\n * combinePropertyPaths('[0]', 'name') // '[0].name'\n * ```\n */\nexport function combinePropertyPaths(prefix: string, suffix: string): string {\n if (suffix === '') {\n return prefix;\n }\n if (suffix.startsWith('[')) {\n return `${prefix}${suffix}`;\n }\n return `${prefix}.${suffix}`;\n}\n\n/**\n * Creates a ValidationError with a single problem that has an empty property.\n * This is used when reporting errors at the current scope level, where the caller\n * will prepend the appropriate context path.\n *\n * @param message - The error message\n * @returns A ValidationError with a single problem with empty property\n *\n * @example\n * ```typescript\n * throw createValidationError('Expects a string but received number');\n * // Creates: ValidationError([{ property: '', message: 'Expects a string but received number' }])\n * ```\n */\nexport function createValidationError(message: string): ValidationError {\n return new ValidationError([\n new Problem({\n property: '',\n message,\n }),\n ]);\n}\n\n/**\n * Prepends a property path to all problems.\n * Problems with empty property names get the path directly.\n * Problems starting with '[' get the path without a dot separator.\n * Other problems get the path with a dot separator.\n *\n * @param propertyPath - The property path to prepend (e.g., 'user', 'items[0]')\n * @param problems - The array of Problems to process\n * @returns Array of Problems with the property path prepended\n *\n * @example\n * ```typescript\n * const problems = [\n * new Problem({ property: '', message: 'Invalid type' }),\n * new Problem({ property: 'name', message: 'Required' }),\n * new Problem({ property: '[0]', message: 'Invalid element' })\n * ];\n * const result = prependPropertyPath('user', problems);\n * // [\n * // { property: 'user', message: 'Invalid type' },\n * // { property: 'user.name', message: 'Required' },\n * // { property: 'user[0]', message: 'Invalid element' }\n * // ]\n * ```\n */\nexport function prependPropertyPath(\n propertyPath: string,\n problems: Problem[],\n): Problem[] {\n return problems.map((problem) => {\n return new Problem({\n property: combinePropertyPaths(propertyPath, problem.property),\n message: problem.message,\n });\n });\n}\n\n/**\n * Prepends an array index to all problems in a ValidationError.\n * Problems with empty property get `[index]` directly.\n * Problems with non-empty property get `[index].property` format.\n *\n * @param index - The array index to prepend\n * @param error - The ValidationError containing problems to process\n * @returns Array of Problems with the array index prepended\n *\n * @example\n * ```typescript\n * const error = new ValidationError([\n * new Problem({ property: '', message: 'Invalid type' }),\n * new Problem({ property: 'name', message: 'Required' })\n * ]);\n * const problems = prependArrayIndex(0, error);\n * // [\n * // { property: '[0]', message: 'Invalid type' },\n * // { property: '[0].name', message: 'Required' }\n * // ]\n * ```\n */\nexport function prependArrayIndex(\n index: number,\n error: ValidationError,\n): Problem[] {\n return error.problems.map((problem) => {\n return new Problem({\n property: combinePropertyPaths(`[${index}]`, problem.property),\n message: problem.message,\n });\n });\n}\n\n/**\n * Message used in place of any problem message for sensitive properties.\n */\nexport const REDACTED_MESSAGE = 'Invalid value [REDACTED]';\n\n/**\n * Replaces the message of every problem with a redacted placeholder,\n * keeping the property path. Used for properties marked `sensitive`.\n *\n * @param problems - The problems to redact\n * @returns New problems with redacted messages\n */\nexport function redactProblems(problems: Problem[]): Problem[] {\n return problems.map(\n (problem) =>\n new Problem({ property: problem.property, message: REDACTED_MESSAGE }),\n );\n}\n"],"names":["Problem","ValidationError","combinePropertyPaths","prefix","suffix","startsWith","createValidationError","message","property","prependPropertyPath","propertyPath","problems","map","problem","prependArrayIndex","index","error","REDACTED_MESSAGE","redactProblems"],"mappings":"AAAA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