Skip to content

Commit 5e8a28d

Browse files
committed
union types generate update
1 parent e8a14d9 commit 5e8a28d

16 files changed

+595
-481
lines changed

.snapshot/all/models.ts

+18-17
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,29 @@ export enum ProductStatus {
1313
UnderTheOrder = 1
1414
}
1515

16+
export type CategoryUnion = Category | CategoryElectronicsDto | CategoryMotorsDto;
17+
export type ICategoryUnion = ICategory | ICategoryElectronicsDto | ICategoryMotorsDto;
18+
19+
export interface ICategory {
20+
name: $types.TypeOrUndefinedNullable<string>;
21+
type: $types.TypeOrUndefined<string>;
22+
}
23+
1624
interface ICategoryElectronicsDtoBaseInterface {
1725
syntheticTest: $types.TypeOrUndefinedNullable<number>;
1826
}
1927

28+
export type ICategoryElectronicsDto = ICategoryElectronicsDtoBaseInterface & ICategory;
29+
2030
interface ICategoryMotorsDtoBaseInterface {
2131
volume: $types.TypeOrUndefinedNullable<number>;
2232
}
2333

24-
export interface ICategory {
25-
name: $types.TypeOrUndefinedNullable<string>;
26-
type: $types.TypeOrUndefined<string>;
27-
}
28-
29-
export type ICategoryElectronicsDto = ICategoryElectronicsDtoBaseInterface & ICategory;
3034
export type ICategoryMotorsDto = ICategoryMotorsDtoBaseInterface & ICategory;
3135

3236
export interface IProduct {
33-
categories: $types.TypeOrUndefinedNullable<ICategory[]>;
34-
category: $types.TypeOrUndefinedNullable<ICategory>;
37+
categories: $types.TypeOrUndefined<ICategoryUnion[]>;
38+
category: $types.TypeOrUndefined<ICategoryUnion>;
3539
colors: $types.TypeOrUndefined<string[]>;
3640
expireDate: $types.TypeOrUndefined<string>;
3741
externalId: $types.TypeOrUndefinedNullable<string>;
@@ -45,9 +49,6 @@ export interface IProductIdentityDTO {
4549
id: $types.TypeOrUndefined<string>;
4650
}
4751

48-
export type CategoryUnion = Category | CategoryElectronicsDto | CategoryMotorsDto;
49-
export type ICategoryUnion = ICategory | ICategoryElectronicsDto | ICategoryMotorsDto;
50-
5152
export class CategoryUnionClass {
5253
public static fromDTO(dto: ICategoryUnion): CategoryUnion {
5354
if (this.isCategoryElectronicsDto(dto)) {
@@ -166,8 +167,8 @@ export class CategoryMotorsDto {
166167
}
167168

168169
export class Product {
169-
public categories: CategoryUnionClass[] = [];
170-
public category: $types.TypeOrUndefinedNullable<CategoryUnionClass> = undefined;
170+
public categories: CategoryUnion[] = [];
171+
public category: $types.TypeOrUndefined<CategoryUnion> = undefined;
171172
public colors: string[] = [];
172173
public expireDate: $types.TypeOrUndefined<Date> = undefined;
173174
public externalId: $types.TypeOrUndefinedNullable<Guid> = undefined;
@@ -179,8 +180,8 @@ export class Product {
179180

180181
public static toDTO(model: Partial<Product>): IProduct {
181182
return {
182-
categories: model.categories ? model.categories.map(x => Category.toDTO(x)) : undefined,
183-
category: model.category ? Category.toDTO(model.category) : undefined,
183+
categories: model.categories ? model.categories.map(x => CategoryUnionClass.toDTO(x)) : undefined,
184+
category: model.category ? CategoryUnionClass.toDTO(model.category) : undefined,
184185
colors: model.colors,
185186
expireDate: toDateOut(model.expireDate),
186187
externalId: model.externalId ? model.externalId.toString() : null,
@@ -193,8 +194,8 @@ export class Product {
193194

194195
public static fromDTO(dto: IProduct): Product {
195196
const model = new Product();
196-
model.categories = dto.categories ? dto.categories.map(x => Category.fromDTO(x)) : [];
197-
model.category = dto.category ? Category.fromDTO(dto.category) : undefined;
197+
model.categories = dto.categories ? dto.categories.map(x => CategoryUnionClass.fromDTO(x)) : [];
198+
model.category = dto.category ? CategoryUnionClass.fromDTO(dto.category) : undefined;
198199
model.colors = dto.colors ? dto.colors : [];
199200
model.expireDate = toDateIn(dto.expireDate);
200201
model.externalId = dto.externalId ? new Guid(dto.externalId) : null;

0 commit comments

Comments
 (0)