Skip to content

Commit

Permalink
Fix incorrect imports (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleshchev authored Oct 3, 2023
1 parent 36882b9 commit c34deb3
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .snapshot/all/services.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Guid } from './Guid';
import { Guid, mapGuid } from './Guid';
import { BaseHttpService } from './base-http.service';
import { DownloadFileService, IDownloadResult } from './download.service';
import { getBasePath } from './utils';
Expand All @@ -21,14 +21,14 @@ export class CategoryService extends BaseHttpService {
return this.post<string>(
`AddCategory`,
category,
).pipe($mappers.mapGuid());
).pipe(mapGuid());
}

public upload(data: FormData): Observable<Guid> {
return this.post<string>(
`Upload`,
data,
).pipe($mappers.mapGuid());
).pipe(mapGuid());
}
}

Expand Down
6 changes: 3 additions & 3 deletions .snapshot/withRequestOptions/services.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Guid } from './Guid';
import { Guid, mapGuid } from './Guid';
import { BaseHttpService, IAngularHttpRequestOptions } from './base-http.service';
import { DownloadFileService, IDownloadResult } from './download.service';
import { getBasePath } from './utils';
Expand All @@ -22,15 +22,15 @@ export class CategoryService extends BaseHttpService {
`AddCategory`,
category,
options,
).pipe($mappers.mapGuid());
).pipe(mapGuid());
}

public upload(data: FormData, options?: $types.TypeOrUndefined<IAngularHttpRequestOptions>): Observable<Guid> {
return this.post<string>(
`Upload`,
data,
options,
).pipe($mappers.mapGuid());
).pipe(mapGuid());
}
}

Expand Down
7 changes: 7 additions & 0 deletions libs/Guid.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { OperatorFunction } from 'rxjs';
import { map } from 'rxjs/operators';

import type { TypeOrUndefined } from './types';

export class Guid {
Expand Down Expand Up @@ -66,3 +69,7 @@ export class Guid {
}
}
}

export function mapGuid(): OperatorFunction<string, Guid> {
return map((z: string) => (z ? new Guid(z) : Guid.empty));
}
5 changes: 0 additions & 5 deletions libs/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { OperatorFunction } from 'rxjs';
import { map } from 'rxjs/operators';

import { toDateIn } from './date-converters';
import { Guid } from './Guid';
import type { DTOIdentityType, TypeOrUndefined } from './types';

export function mapCollection<TDTO, TModel>(dtoMapper: { fromDTO(value: TDTO): TModel }): OperatorFunction<TDTO[], TModel[]> {
Expand All @@ -21,10 +20,6 @@ export function mapIdentitySingle<TModel>(identity: { new (id: TypeOrUndefined<s
return map((z: TypeOrUndefined<DTOIdentityType>) => (z ? new identity(z.id) : undefined));
}

export function mapGuid(): OperatorFunction<string, Guid> {
return map((z: string) => (z ? new Guid(z) : Guid.empty));
}

export function mapDate(): OperatorFunction<string, TypeOrUndefined<Date>> {
return map(toDateIn);
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@luxbss/gengen",
"version": "1.1.0",
"version": "1.1.1",
"description": "Tool for generating models and Angular services based on OpenAPIs and Swagger's JSON",
"bin": {
"gengen": "./bin/index.js"
Expand Down
2 changes: 1 addition & 1 deletion src/generators/angular/AngularServicesGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class AngularServicesGenerator {
{
kind: StructureKind.ImportDeclaration,
moduleSpecifier: `${path}/Guid`,
namedImports: [{ name: 'Guid' }]
namedImports: [{ name: 'Guid' }, { name: 'mapGuid' }]
},
{
kind: StructureKind.ImportDeclaration,
Expand Down
2 changes: 1 addition & 1 deletion src/generators/angular/AngularServicesMethodGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class AngularServicesMethodGenerator {
}
protected createPipe(returnType: ITypeInfo): string {
if (returnType.type.kind === PropertyKind.Guid) {
return `${MAPPERS_NAMESPACE}.mapGuid()`;
return 'mapGuid()';
}

if (returnType.type.kind === PropertyKind.Date) {
Expand Down

0 comments on commit c34deb3

Please sign in to comment.