@rtpaulino/entity 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/entity-registry.d.ts +32 -0
- package/dist/lib/entity-registry.d.ts.map +1 -0
- package/dist/lib/entity-registry.js +42 -0
- package/dist/lib/entity-registry.js.map +1 -0
- package/dist/lib/entity-utils.d.ts +23 -0
- package/dist/lib/entity-utils.d.ts.map +1 -1
- package/dist/lib/entity-utils.js +76 -4
- package/dist/lib/entity-utils.js.map +1 -1
- package/dist/lib/entity.d.ts +13 -2
- package/dist/lib/entity.d.ts.map +1 -1
- package/dist/lib/entity.js +22 -7
- package/dist/lib/entity.js.map +1 -1
- package/dist/lib/property.d.ts +48 -0
- package/dist/lib/property.d.ts.map +1 -1
- package/dist/lib/property.js +52 -2
- package/dist/lib/property.js.map +1 -1
- package/dist/lib/test-entities.d.ts +474 -0
- package/dist/lib/test-entities.d.ts.map +1 -0
- package/dist/lib/test-entities.js +987 -0
- package/dist/lib/test-entities.js.map +1 -0
- package/dist/lib/types.d.ts +21 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js.map +1 -1
- package/package.json +1 -1
package/dist/lib/property.js.map
CHANGED
|
@@ -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 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';\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 */\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 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 Property({\n ...restOptions,\n type: () => String,\n validators: validators.length > 0 ? validators : undefined,\n });\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 const validators = options?.validators\n ? [enumValidator(enumType), ...options.validators]\n : [enumValidator(enumType)];\n\n return Property({ ...options, type: () => String, validators });\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): PropertyDecorator {\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, ...restOptions } = options || {};\n\n return Property({\n ...restOptions,\n type: () => Number,\n validators: validators.length > 0 ? validators : undefined,\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): PropertyDecorator {\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, ...restOptions } = options || {};\n\n return Property({\n ...restOptions,\n type: () => Number,\n validators: validators.length > 0 ? validators : undefined,\n });\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({ ...options, type: () => Boolean });\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({ ...options, type: () => Date });\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({ ...options, type: () => BigInt });\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>({ ...options, type });\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 * 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 // Use a dummy type since type is mandatory but not used with passthrough\n return Property({ type: () => Object, passthrough: true });\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>({\n ...data,\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\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"],"names":["isEqual","PROPERTY_METADATA_KEY","PROPERTY_OPTIONS_METADATA_KEY","enumValidator","intValidator","minLengthValidator","maxLengthValidator","patternValidator","minValidator","maxValidator","arrayMinLengthValidator","arrayMaxLengthValidator","Property","options","target","propertyKey","existingProperties","Reflect","getOwnMetadata","includes","push","defineMetadata","passthrough","array","Error","optional","sparse","serialize","undefined","deserialize","arrayValidators","hasSerialize","hasDeserialize","existingOptions","StringProperty","validators","minLength","unshift","maxLength","pattern","patternMessage","restOptions","type","String","length","EnumProperty","enumType","NumberProperty","min","max","Number","IntProperty","BooleanProperty","Boolean","DateProperty","Date","BigIntProperty","BigInt","EntityProperty","ArrayProperty","PassthroughProperty","Object","StringifiableProperty","data","equals","a","b","toString","value","parse","name","SerializableProperty","toJSON"],"mappings":"AAAA,6DAA6D,GAC7D,qDAAqD,GACrD,SAASA,OAAO,QAAQ,YAAY;AACpC,SAIEC,qBAAqB,EACrBC,6BAA6B,QAExB,aAAa;AACpB,SACEC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,kBAAkB,EAClBC,gBAAgB,EAChBC,YAAY,EACZC,YAAY,EACZC,uBAAuB,EACvBC,uBAAuB,QAClB,kBAAkB;AAEzB;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASC,SACdC,OAA8B;IAE9B,OAAO,CAACC,QAAgBC;QACtB,IAAI,OAAOA,gBAAgB,UAAU;YACnC;QACF;QAEA,MAAMC,qBACJC,QAAQC,cAAc,CAACjB,uBAAuBa,WAAW,EAAE;QAE7D,IAAI,CAACE,mBAAmBG,QAAQ,CAACJ,cAAc;YAC7CC,mBAAmBI,IAAI,CAACL;QAC1B;QAEAE,QAAQI,cAAc,CAACpB,uBAAuBe,oBAAoBF;QAElE,IAAID,QAAQS,WAAW,KAAK,MAAM;YAChC,IAAIT,QAAQU,KAAK,KAAK,MAAM;gBAC1B,MAAM,IAAIC,MACR,CAAC,UAAU,EAAET,YAAY,mFAAmF,CAAC;YAEjH;YACA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AAa,CAACuC;YACZ,OAAO1B,OAAO2B,KAAK,CAACD;QACtB;IACF,GAAG"}
|
|
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 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';\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 */\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 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 Property({\n ...restOptions,\n type: () => String,\n validators: validators.length > 0 ? validators : undefined,\n });\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 const validators = options?.validators\n ? [enumValidator(enumType), ...options.validators]\n : [enumValidator(enumType)];\n\n return Property({ ...options, type: () => String, validators });\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): PropertyDecorator {\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, ...restOptions } = options || {};\n\n return Property({\n ...restOptions,\n type: () => Number,\n validators: validators.length > 0 ? validators : undefined,\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): PropertyDecorator {\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, ...restOptions } = options || {};\n\n return Property({\n ...restOptions,\n type: () => Number,\n validators: validators.length > 0 ? validators : undefined,\n });\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({ ...options, type: () => Boolean });\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({ ...options, type: () => Date });\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({ ...options, type: () => BigInt });\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>({ ...options, type });\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 * 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({ passthrough: true });\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>({\n ...data,\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\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 */\nexport function DiscriminatedEntityProperty(\n options?: Omit<PropertyOptions<any, any>, 'type' | 'discriminated'> & {\n discriminatorProperty?: string;\n },\n): PropertyDecorator {\n const discriminatorProperty = options?.discriminatorProperty ?? '__type';\n\n return Property({\n ...options,\n discriminated: true,\n discriminatorProperty,\n });\n}\n"],"names":["isEqual","PROPERTY_METADATA_KEY","PROPERTY_OPTIONS_METADATA_KEY","enumValidator","intValidator","minLengthValidator","maxLengthValidator","patternValidator","minValidator","maxValidator","arrayMinLengthValidator","arrayMaxLengthValidator","Property","options","target","propertyKey","existingProperties","Reflect","getOwnMetadata","includes","push","defineMetadata","passthrough","array","Error","optional","sparse","serialize","undefined","deserialize","arrayValidators","hasSerialize","hasDeserialize","existingOptions","StringProperty","validators","minLength","unshift","maxLength","pattern","patternMessage","restOptions","type","String","length","EnumProperty","enumType","NumberProperty","min","max","Number","IntProperty","BooleanProperty","Boolean","DateProperty","Date","BigIntProperty","BigInt","EntityProperty","ArrayProperty","PassthroughProperty","StringifiableProperty","data","equals","a","b","toString","value","parse","name","SerializableProperty","toJSON","DiscriminatedEntityProperty","discriminatorProperty","discriminated"],"mappings":"AAAA,6DAA6D,GAC7D,qDAAqD,GACrD,SAASA,OAAO,QAAQ,YAAY;AACpC,SAIEC,qBAAqB,EACrBC,6BAA6B,QAExB,aAAa;AACpB,SACEC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,kBAAkB,EAClBC,gBAAgB,EAChBC,YAAY,EACZC,YAAY,EACZC,uBAAuB,EACvBC,uBAAuB,QAClB,kBAAkB;AAEzB;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASC,SACdC,OAA8B;IAE9B,OAAO,CAACC,QAAgBC;QACtB,IAAI,OAAOA,gBAAgB,UAAU;YACnC;QACF;QAEA,MAAMC,qBACJC,QAAQC,cAAc,CAACjB,uBAAuBa,WAAW,EAAE;QAE7D,IAAI,CAACE,mBAAmBG,QAAQ,CAACJ,cAAc;YAC7CC,mBAAmBI,IAAI,CAACL;QAC1B;QAEAE,QAAQI,cAAc,CAACpB,uBAAuBe,oBAAoBF;QAElE,IAAID,QAAQS,WAAW,KAAK,MAAM;YAChC,IAAIT,QA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M,MAAM;QACvD5C,WAAW,CAACwC,QAAaA,MAAMI,MAAM;QACrC1C,aAAa,CAACsC;YACZ,OAAOzB,OAAO0B,KAAK,CAACD;QACtB;IACF,GAAG;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CC,GACD,OAAO,SAASK,4BACd3D,OAEC;IAED,MAAM4D,wBAAwB5D,SAAS4D,yBAAyB;IAEhE,OAAO7D,SAAS;QACd,GAAGC,OAAO;QACV6D,eAAe;QACfD;IACF;AACF"}
|
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { Problem } from './problem.js';
|
|
3
|
+
/**
|
|
4
|
+
* Basic entity with common primitive types
|
|
5
|
+
* Features: String, Number, Boolean properties
|
|
6
|
+
*/
|
|
7
|
+
export declare class TestUser {
|
|
8
|
+
name: string;
|
|
9
|
+
age: number;
|
|
10
|
+
active: boolean;
|
|
11
|
+
constructor(data: {
|
|
12
|
+
name: string;
|
|
13
|
+
age: number;
|
|
14
|
+
active: boolean;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Entity with different primitive combinations
|
|
19
|
+
* Features: String, Number, Int, Date properties
|
|
20
|
+
*/
|
|
21
|
+
export declare class TestProduct {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
price: number;
|
|
25
|
+
quantity: number;
|
|
26
|
+
createdAt: Date;
|
|
27
|
+
constructor(data: {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
price: number;
|
|
31
|
+
quantity: number;
|
|
32
|
+
createdAt: Date;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Entity with Date and BigInt types
|
|
37
|
+
* Features: DateProperty, BigIntProperty
|
|
38
|
+
*/
|
|
39
|
+
export declare class EntityWithSpecialTypes {
|
|
40
|
+
timestamp: Date;
|
|
41
|
+
largeNumber: bigint;
|
|
42
|
+
label: string;
|
|
43
|
+
constructor(data: {
|
|
44
|
+
timestamp: Date;
|
|
45
|
+
largeNumber: bigint;
|
|
46
|
+
label: string;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Entity with property-level validators
|
|
51
|
+
* Features: String validators (minLength, maxLength, pattern)
|
|
52
|
+
*/
|
|
53
|
+
export declare class ValidatedEntity {
|
|
54
|
+
username: string;
|
|
55
|
+
email: string;
|
|
56
|
+
age: number;
|
|
57
|
+
constructor(data: {
|
|
58
|
+
username: string;
|
|
59
|
+
email: string;
|
|
60
|
+
age: number;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Entity with cross-property validation
|
|
65
|
+
* Features: @EntityValidator decorator
|
|
66
|
+
*/
|
|
67
|
+
export declare class CrossValidatedEntity {
|
|
68
|
+
password: string;
|
|
69
|
+
confirmPassword: string;
|
|
70
|
+
startDate: Date;
|
|
71
|
+
endDate: Date;
|
|
72
|
+
constructor(data: {
|
|
73
|
+
password: string;
|
|
74
|
+
confirmPassword: string;
|
|
75
|
+
startDate: Date;
|
|
76
|
+
endDate: Date;
|
|
77
|
+
});
|
|
78
|
+
validatePasswords(): Problem[];
|
|
79
|
+
validateDates(): Problem[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Entity with mix of optional and required properties
|
|
83
|
+
* Features: optional flag
|
|
84
|
+
*/
|
|
85
|
+
export declare class OptionalFieldsEntity {
|
|
86
|
+
requiredField: string;
|
|
87
|
+
optionalField?: string;
|
|
88
|
+
optionalNumber?: number;
|
|
89
|
+
requiredBoolean: boolean;
|
|
90
|
+
constructor(data: {
|
|
91
|
+
requiredField: string;
|
|
92
|
+
optionalField?: string;
|
|
93
|
+
optionalNumber?: number;
|
|
94
|
+
requiredBoolean: boolean;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Entity with various default value strategies
|
|
99
|
+
* Features: Static defaults, factory defaults, async factory defaults
|
|
100
|
+
*/
|
|
101
|
+
export declare class EntityWithDefaults {
|
|
102
|
+
name: string;
|
|
103
|
+
counter: number;
|
|
104
|
+
timestamp: Date;
|
|
105
|
+
asyncField: string;
|
|
106
|
+
enabled: boolean;
|
|
107
|
+
constructor(data: {
|
|
108
|
+
name?: string;
|
|
109
|
+
counter?: number;
|
|
110
|
+
timestamp?: Date;
|
|
111
|
+
asyncField?: string;
|
|
112
|
+
enabled?: boolean;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Entity with various array configurations
|
|
117
|
+
* Features: Regular arrays, sparse arrays, array validators
|
|
118
|
+
*/
|
|
119
|
+
export declare class EntityWithArrays {
|
|
120
|
+
tags: string[];
|
|
121
|
+
ratings: number[];
|
|
122
|
+
sparseArray: (string | null | undefined)[];
|
|
123
|
+
users: TestUser[];
|
|
124
|
+
constructor(data: {
|
|
125
|
+
tags: string[];
|
|
126
|
+
ratings: number[];
|
|
127
|
+
sparseArray: (string | null | undefined)[];
|
|
128
|
+
users: TestUser[];
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
export declare enum UserRole {
|
|
132
|
+
ADMIN = "admin",
|
|
133
|
+
USER = "user",
|
|
134
|
+
GUEST = "guest"
|
|
135
|
+
}
|
|
136
|
+
export declare enum ProductStatus {
|
|
137
|
+
DRAFT = "draft",
|
|
138
|
+
PUBLISHED = "published",
|
|
139
|
+
ARCHIVED = "archived"
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Entity with enum properties
|
|
143
|
+
* Features: EnumProperty decorator
|
|
144
|
+
*/
|
|
145
|
+
export declare class EntityWithEnum {
|
|
146
|
+
name: string;
|
|
147
|
+
role: UserRole;
|
|
148
|
+
status: ProductStatus;
|
|
149
|
+
constructor(data: {
|
|
150
|
+
name: string;
|
|
151
|
+
role: UserRole;
|
|
152
|
+
status: ProductStatus;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Level 1: Simple address entity
|
|
157
|
+
* Features: Basic nested entity
|
|
158
|
+
*/
|
|
159
|
+
export declare class TestAddress {
|
|
160
|
+
street: string;
|
|
161
|
+
city: string;
|
|
162
|
+
country: string;
|
|
163
|
+
zipCode: number;
|
|
164
|
+
constructor(data: {
|
|
165
|
+
street: string;
|
|
166
|
+
city: string;
|
|
167
|
+
country: string;
|
|
168
|
+
zipCode: number;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Level 2: Company with nested address
|
|
173
|
+
* Features: 1-level nesting
|
|
174
|
+
*/
|
|
175
|
+
export declare class TestCompany {
|
|
176
|
+
name: string;
|
|
177
|
+
address: TestAddress;
|
|
178
|
+
employeeCount: number;
|
|
179
|
+
constructor(data: {
|
|
180
|
+
name: string;
|
|
181
|
+
address: TestAddress;
|
|
182
|
+
employeeCount: number;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Level 3: Employee with nested company (which has nested address)
|
|
187
|
+
* Features: 2-level nesting
|
|
188
|
+
*/
|
|
189
|
+
export declare class TestEmployee {
|
|
190
|
+
name: string;
|
|
191
|
+
email: string;
|
|
192
|
+
company: TestCompany;
|
|
193
|
+
salary: number;
|
|
194
|
+
hireDate: Date;
|
|
195
|
+
constructor(data: {
|
|
196
|
+
name: string;
|
|
197
|
+
email: string;
|
|
198
|
+
company: TestCompany;
|
|
199
|
+
salary: number;
|
|
200
|
+
hireDate: Date;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Entity with optional nested entities
|
|
205
|
+
* Features: Optional nested entities
|
|
206
|
+
*/
|
|
207
|
+
export declare class EntityWithOptionalNested {
|
|
208
|
+
id: string;
|
|
209
|
+
billingAddress?: TestAddress;
|
|
210
|
+
shippingAddress?: TestAddress;
|
|
211
|
+
constructor(data: {
|
|
212
|
+
id: string;
|
|
213
|
+
billingAddress?: TestAddress;
|
|
214
|
+
shippingAddress?: TestAddress;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Collection entity wrapping string array
|
|
219
|
+
* Features: @CollectionEntity decorator, unwraps to array
|
|
220
|
+
*/
|
|
221
|
+
export declare class TestTags {
|
|
222
|
+
readonly collection: string[];
|
|
223
|
+
constructor(data: {
|
|
224
|
+
collection: string[];
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Collection entity wrapping number array
|
|
229
|
+
* Features: @CollectionEntity with numbers
|
|
230
|
+
*/
|
|
231
|
+
export declare class TestIdList {
|
|
232
|
+
readonly collection: number[];
|
|
233
|
+
constructor(data: {
|
|
234
|
+
collection: number[];
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Collection entity with entity items
|
|
239
|
+
* Features: @CollectionEntity with nested entities
|
|
240
|
+
*/
|
|
241
|
+
export declare class TestUserCollection {
|
|
242
|
+
readonly collection: TestUser[];
|
|
243
|
+
constructor(data: {
|
|
244
|
+
collection: TestUser[];
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Stringifiable entity for user IDs
|
|
249
|
+
* Features: @Stringifiable decorator, unwraps to string
|
|
250
|
+
*/
|
|
251
|
+
export declare class TestUserId {
|
|
252
|
+
readonly value: string;
|
|
253
|
+
constructor(data: {
|
|
254
|
+
value: string;
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Stringifiable entity for emails with validation
|
|
259
|
+
* Features: @Stringifiable with validation
|
|
260
|
+
*/
|
|
261
|
+
export declare class TestEmail {
|
|
262
|
+
readonly value: string;
|
|
263
|
+
constructor(data: {
|
|
264
|
+
value: string;
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Entity using stringifiable properties
|
|
269
|
+
* Features: Properties that are stringifiable entities
|
|
270
|
+
*/
|
|
271
|
+
export declare class EntityWithStringifiable {
|
|
272
|
+
userId: TestUserId;
|
|
273
|
+
email: TestEmail;
|
|
274
|
+
name: string;
|
|
275
|
+
constructor(data: {
|
|
276
|
+
userId: TestUserId;
|
|
277
|
+
email: TestEmail;
|
|
278
|
+
name: string;
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
export interface ILogger {
|
|
282
|
+
log(message: string): void;
|
|
283
|
+
}
|
|
284
|
+
export declare const LOGGER_TOKEN: unique symbol;
|
|
285
|
+
/**
|
|
286
|
+
* Entity with injected properties
|
|
287
|
+
* Features: @InjectedProperty decorator
|
|
288
|
+
*/
|
|
289
|
+
export declare class EntityWithDI {
|
|
290
|
+
name: string;
|
|
291
|
+
logger: ILogger;
|
|
292
|
+
constructor(data: {
|
|
293
|
+
name: string;
|
|
294
|
+
logger?: ILogger;
|
|
295
|
+
});
|
|
296
|
+
logName(): void;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Entity with passthrough properties
|
|
300
|
+
* Features: @PassthroughProperty for unknown types
|
|
301
|
+
*/
|
|
302
|
+
export declare class EntityWithPassthrough {
|
|
303
|
+
id: string;
|
|
304
|
+
metadata: Record<string, unknown>;
|
|
305
|
+
config: unknown;
|
|
306
|
+
constructor(data: {
|
|
307
|
+
id: string;
|
|
308
|
+
metadata: Record<string, unknown>;
|
|
309
|
+
config: unknown;
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Custom serializable class
|
|
314
|
+
*/
|
|
315
|
+
export declare class CustomValue {
|
|
316
|
+
x: number;
|
|
317
|
+
y: number;
|
|
318
|
+
constructor(x: number, y: number);
|
|
319
|
+
toData(): {
|
|
320
|
+
x: number;
|
|
321
|
+
y: number;
|
|
322
|
+
};
|
|
323
|
+
static fromData(data: {
|
|
324
|
+
x: number;
|
|
325
|
+
y: number;
|
|
326
|
+
}): CustomValue;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Entity with custom serialize/deserialize
|
|
330
|
+
* Features: Custom serialization functions
|
|
331
|
+
*/
|
|
332
|
+
export declare class EntityWithCustomSerialization {
|
|
333
|
+
name: string;
|
|
334
|
+
position: CustomValue;
|
|
335
|
+
constructor(data: {
|
|
336
|
+
name: string;
|
|
337
|
+
position: CustomValue;
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Custom class with equals method
|
|
342
|
+
*/
|
|
343
|
+
export declare class CustomPoint {
|
|
344
|
+
x: number;
|
|
345
|
+
y: number;
|
|
346
|
+
constructor(x: number, y: number);
|
|
347
|
+
equals(other: CustomPoint): boolean;
|
|
348
|
+
toString(): string;
|
|
349
|
+
static fromString(str: string): CustomPoint;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Entity with custom equals function
|
|
353
|
+
* Features: Custom equality comparison
|
|
354
|
+
*/
|
|
355
|
+
export declare class EntityWithCustomEquals {
|
|
356
|
+
id: string;
|
|
357
|
+
location: CustomPoint;
|
|
358
|
+
constructor(data: {
|
|
359
|
+
id: string;
|
|
360
|
+
location: CustomPoint;
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Custom class implementing Serializable interface
|
|
365
|
+
*/
|
|
366
|
+
export declare class SerializableValue {
|
|
367
|
+
data: string;
|
|
368
|
+
constructor(data: string);
|
|
369
|
+
toJSON(): string;
|
|
370
|
+
equals(other: SerializableValue): boolean;
|
|
371
|
+
static parse(json: unknown): SerializableValue;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Entity using SerializableProperty
|
|
375
|
+
* Features: @SerializableProperty decorator
|
|
376
|
+
*/
|
|
377
|
+
export declare class EntityWithSerializable {
|
|
378
|
+
name: string;
|
|
379
|
+
value: SerializableValue;
|
|
380
|
+
constructor(data: {
|
|
381
|
+
name: string;
|
|
382
|
+
value: SerializableValue;
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Custom class implementing Parseable interface
|
|
387
|
+
*/
|
|
388
|
+
export declare class ParseableValue {
|
|
389
|
+
data: number;
|
|
390
|
+
constructor(data: number);
|
|
391
|
+
toString(): string;
|
|
392
|
+
equals(other: ParseableValue): boolean;
|
|
393
|
+
static parse(str: string): ParseableValue;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Entity using StringifiableProperty
|
|
397
|
+
* Features: @StringifiableProperty decorator
|
|
398
|
+
*/
|
|
399
|
+
export declare class EntityWithParseable {
|
|
400
|
+
label: string;
|
|
401
|
+
value: ParseableValue;
|
|
402
|
+
constructor(data: {
|
|
403
|
+
label: string;
|
|
404
|
+
value: ParseableValue;
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Entity with Zod validation
|
|
409
|
+
* Features: @ZodProperty decorator
|
|
410
|
+
*/
|
|
411
|
+
export declare class EntityWithZod {
|
|
412
|
+
username: string;
|
|
413
|
+
email: string;
|
|
414
|
+
count: number;
|
|
415
|
+
constructor(data: {
|
|
416
|
+
username: string;
|
|
417
|
+
email: string;
|
|
418
|
+
count: number;
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Entity with immutable (preventUpdates) properties
|
|
423
|
+
* Features: preventUpdates flag
|
|
424
|
+
*/
|
|
425
|
+
export declare class EntityWithImmutable {
|
|
426
|
+
readonly id: string;
|
|
427
|
+
name: string;
|
|
428
|
+
readonly createdAt: Date;
|
|
429
|
+
value: number;
|
|
430
|
+
constructor(data: {
|
|
431
|
+
id: string;
|
|
432
|
+
name: string;
|
|
433
|
+
createdAt: Date;
|
|
434
|
+
value: number;
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Complex entity combining multiple features
|
|
439
|
+
* Features: All common features in one entity
|
|
440
|
+
* - Primitives, enums, nested entities, arrays
|
|
441
|
+
* - Optional fields, defaults, validation
|
|
442
|
+
* - Custom serialization, stringifiable properties
|
|
443
|
+
*/
|
|
444
|
+
export declare class ComplexEntity {
|
|
445
|
+
readonly id: string;
|
|
446
|
+
name: string;
|
|
447
|
+
role: UserRole;
|
|
448
|
+
userId: TestUserId;
|
|
449
|
+
address: TestAddress;
|
|
450
|
+
tags: string[];
|
|
451
|
+
products: TestProduct[];
|
|
452
|
+
score?: number;
|
|
453
|
+
createdAt: Date;
|
|
454
|
+
updatedAt?: Date;
|
|
455
|
+
active: boolean;
|
|
456
|
+
metadata: Record<string, unknown>;
|
|
457
|
+
constructor(data: {
|
|
458
|
+
id: string;
|
|
459
|
+
name: string;
|
|
460
|
+
role: UserRole;
|
|
461
|
+
userId: TestUserId;
|
|
462
|
+
address: TestAddress;
|
|
463
|
+
tags: string[];
|
|
464
|
+
products: TestProduct[];
|
|
465
|
+
score?: number;
|
|
466
|
+
createdAt?: Date;
|
|
467
|
+
updatedAt?: Date;
|
|
468
|
+
active?: boolean;
|
|
469
|
+
metadata: Record<string, unknown>;
|
|
470
|
+
});
|
|
471
|
+
validateProducts(): Problem[];
|
|
472
|
+
}
|
|
473
|
+
export declare function resetFactoryCallCount(): void;
|
|
474
|
+
//# sourceMappingURL=test-entities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-entities.d.ts","sourceRoot":"","sources":["../../src/lib/test-entities.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAyB1B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAMvC;;;GAGG;AACH,qBACa,QAAQ;IACD,IAAI,EAAG,MAAM,CAAC;IACd,GAAG,EAAG,MAAM,CAAC;IACZ,MAAM,EAAG,OAAO,CAAC;gBAExB,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE;CAKjE;AAED;;;GAGG;AACH,qBACa,WAAW;IACJ,EAAE,EAAG,MAAM,CAAC;IACZ,I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