Cambios
This commit is contained in:
parent
bf960bc3ac
commit
3042255fad
@ -52,7 +52,44 @@ export type CustomerPatchProps = Partial<Omit<CustomerProps, "companyId" | "addr
|
|||||||
address?: PostalAddressPatchProps;
|
address?: PostalAddressPatchProps;
|
||||||
};
|
};
|
||||||
|
|
||||||
export class Customer extends AggregateRoot<CustomerProps> {
|
// Customer
|
||||||
|
export interface ICustomer {
|
||||||
|
// comportamiento
|
||||||
|
update(partialCustomer: CustomerPatchProps): Result<Customer, Error>;
|
||||||
|
|
||||||
|
// propiedades (getters)
|
||||||
|
readonly isIndividual: boolean;
|
||||||
|
readonly isCompany: boolean;
|
||||||
|
readonly isActive: boolean;
|
||||||
|
|
||||||
|
readonly companyId: UniqueID;
|
||||||
|
|
||||||
|
readonly reference: Maybe<Name>;
|
||||||
|
readonly name: Name;
|
||||||
|
readonly tradeName: Maybe<Name>;
|
||||||
|
readonly tin: Maybe<TINNumber>;
|
||||||
|
|
||||||
|
readonly address: PostalAddress;
|
||||||
|
|
||||||
|
readonly emailPrimary: Maybe<EmailAddress>;
|
||||||
|
readonly emailSecondary: Maybe<EmailAddress>;
|
||||||
|
|
||||||
|
readonly phonePrimary: Maybe<PhoneNumber>;
|
||||||
|
readonly phoneSecondary: Maybe<PhoneNumber>;
|
||||||
|
readonly mobilePrimary: Maybe<PhoneNumber>;
|
||||||
|
readonly mobileSecondary: Maybe<PhoneNumber>;
|
||||||
|
readonly fax: Maybe<PhoneNumber>;
|
||||||
|
|
||||||
|
readonly website: Maybe<URLAddress>;
|
||||||
|
readonly legalRecord: Maybe<TextValue>;
|
||||||
|
|
||||||
|
readonly defaultTaxes: Collection<TaxCode>;
|
||||||
|
|
||||||
|
readonly languageCode: LanguageCode;
|
||||||
|
readonly currencyCode: CurrencyCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Customer extends AggregateRoot<CustomerProps> implements ICustomer {
|
||||||
static create(props: CustomerProps, id?: UniqueID): Result<Customer, Error> {
|
static create(props: CustomerProps, id?: UniqueID): Result<Customer, Error> {
|
||||||
const contact = new Customer(props, id);
|
const contact = new Customer(props, id);
|
||||||
|
|
||||||
@ -60,9 +97,9 @@ export class Customer extends AggregateRoot<CustomerProps> {
|
|||||||
// ...
|
// ...
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
// 🔹 Disparar evento de dominio "CustomerAuthenticatedEvent"
|
// Disparar eventos de dominio
|
||||||
//const { contact } = props;
|
// ...
|
||||||
//user.addDomainEvent(new CustomerAuthenticatedEvent(id, contact.toString()));
|
// ...
|
||||||
|
|
||||||
return Result.ok(contact);
|
return Result.ok(contact);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,12 +39,12 @@ export type CustomerListDTO = {
|
|||||||
|
|
||||||
address: PostalAddress;
|
address: PostalAddress;
|
||||||
|
|
||||||
email_primary: Maybe<EmailAddress>;
|
emailPrimary: Maybe<EmailAddress>;
|
||||||
email_secondary: Maybe<EmailAddress>;
|
emailSecondary: Maybe<EmailAddress>;
|
||||||
phone_primary: Maybe<PhoneNumber>;
|
phonePrimary: Maybe<PhoneNumber>;
|
||||||
phone_secondary: Maybe<PhoneNumber>;
|
phoneSecondary: Maybe<PhoneNumber>;
|
||||||
mobile_primary: Maybe<PhoneNumber>;
|
mobilePrimary: Maybe<PhoneNumber>;
|
||||||
mobile_secondary: Maybe<PhoneNumber>;
|
mobileSecondary: Maybe<PhoneNumber>;
|
||||||
|
|
||||||
fax: Maybe<PhoneNumber>;
|
fax: Maybe<PhoneNumber>;
|
||||||
website: Maybe<URLAddress>;
|
website: Maybe<URLAddress>;
|
||||||
@ -225,12 +225,12 @@ export class CustomerListMapper
|
|||||||
|
|
||||||
address: postalAddress!,
|
address: postalAddress!,
|
||||||
|
|
||||||
email_primary: emailPrimaryAddress!,
|
emailPrimary: emailPrimaryAddress!,
|
||||||
email_secondary: emailSecondaryAddress!,
|
emailSecondary: emailSecondaryAddress!,
|
||||||
phone_primary: phonePrimaryNumber!,
|
phonePrimary: phonePrimaryNumber!,
|
||||||
phone_secondary: phoneSecondaryNumber!,
|
phoneSecondary: phoneSecondaryNumber!,
|
||||||
mobile_primary: mobilePrimaryNumber!,
|
mobilePrimary: mobilePrimaryNumber!,
|
||||||
mobile_secondary: mobileSecondaryNumber!,
|
mobileSecondary: mobileSecondaryNumber!,
|
||||||
fax: faxNumber!,
|
fax: faxNumber!,
|
||||||
website: website!,
|
website: website!,
|
||||||
|
|
||||||
|
|||||||
@ -19,8 +19,12 @@ export const ListCustomersResponseSchema = createListViewResponseSchema(
|
|||||||
postal_code: z.string(),
|
postal_code: z.string(),
|
||||||
country: z.string(),
|
country: z.string(),
|
||||||
|
|
||||||
email: z.string(),
|
email_primary: z.string(),
|
||||||
phone: z.string(),
|
email_secondary: z.string(),
|
||||||
|
phone_primary: z.string(),
|
||||||
|
phone_secondary: z.string(),
|
||||||
|
mobile_primary: z.string(),
|
||||||
|
mobile_secondary: z.string(),
|
||||||
fax: z.string(),
|
fax: z.string(),
|
||||||
website: z.string(),
|
website: z.string(),
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ export abstract class AggregateRoot<T extends object> extends DomainEntity<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 🔹 Agregar un evento de dominio al agregado
|
* Agregar un evento de dominio al agregado
|
||||||
*/
|
*/
|
||||||
protected addDomainEvent(event: IDomainEvent): void {
|
protected addDomainEvent(event: IDomainEvent): void {
|
||||||
this._domainEvents.push(event);
|
this._domainEvents.push(event);
|
||||||
@ -20,14 +20,14 @@ export abstract class AggregateRoot<T extends object> extends DomainEntity<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 🔹 Obtener los eventos de dominio pendientes
|
* Obtener los eventos de dominio pendientes
|
||||||
*/
|
*/
|
||||||
get domainEvents(): IDomainEvent[] {
|
get domainEvents(): IDomainEvent[] {
|
||||||
return this._domainEvents;
|
return this._domainEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 🔹 Limpiar la lista de eventos después de procesarlos
|
* Limpiar la lista de eventos después de procesarlos
|
||||||
*/
|
*/
|
||||||
public clearDomainEvents(): void {
|
public clearDomainEvents(): void {
|
||||||
this._domainEvents.splice(0, this._domainEvents.length);
|
this._domainEvents.splice(0, this._domainEvents.length);
|
||||||
|
|||||||
@ -9,7 +9,16 @@
|
|||||||
* console.log(noValue.isSome()); // false
|
* console.log(noValue.isSome()); // false
|
||||||
**/
|
**/
|
||||||
|
|
||||||
export class Maybe<T> {
|
export interface IMaybe<T> {
|
||||||
|
isSome(): boolean;
|
||||||
|
isNone(): boolean;
|
||||||
|
unwrap(): T | undefined;
|
||||||
|
getOrUndefined(): T | undefined;
|
||||||
|
map<U>(fn: (value: T) => U): IMaybe<U>;
|
||||||
|
match<U>(someFn: (value: T) => U, noneFn: () => U): U;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Maybe<T> implements IMaybe<T> {
|
||||||
private constructor(private readonly value?: T) {}
|
private constructor(private readonly value?: T) {}
|
||||||
|
|
||||||
static fromNullable<T>(value?: T): Maybe<T> {
|
static fromNullable<T>(value?: T): Maybe<T> {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user