From c34deb356c249aaa915cea3afaf87043c87d669e Mon Sep 17 00:00:00 2001 From: Leshchev Artem Date: Tue, 3 Oct 2023 08:45:34 +0200 Subject: [PATCH] Fix incorrect imports (#126) --- .snapshot/all/services.ts | 6 +++--- .snapshot/withRequestOptions/services.ts | 6 +++--- libs/Guid.ts | 7 +++++++ libs/mappers.ts | 5 ----- package-lock.json | 4 ++-- package.json | 2 +- src/generators/angular/AngularServicesGenerator.ts | 2 +- src/generators/angular/AngularServicesMethodGenerator.ts | 2 +- 8 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.snapshot/all/services.ts b/.snapshot/all/services.ts index 7dacf3d..2630e96 100644 --- a/.snapshot/all/services.ts +++ b/.snapshot/all/services.ts @@ -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'; @@ -21,14 +21,14 @@ export class CategoryService extends BaseHttpService { return this.post( `AddCategory`, category, - ).pipe($mappers.mapGuid()); + ).pipe(mapGuid()); } public upload(data: FormData): Observable { return this.post( `Upload`, data, - ).pipe($mappers.mapGuid()); + ).pipe(mapGuid()); } } diff --git a/.snapshot/withRequestOptions/services.ts b/.snapshot/withRequestOptions/services.ts index d045750..1ee6d25 100644 --- a/.snapshot/withRequestOptions/services.ts +++ b/.snapshot/withRequestOptions/services.ts @@ -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'; @@ -22,7 +22,7 @@ export class CategoryService extends BaseHttpService { `AddCategory`, category, options, - ).pipe($mappers.mapGuid()); + ).pipe(mapGuid()); } public upload(data: FormData, options?: $types.TypeOrUndefined): Observable { @@ -30,7 +30,7 @@ export class CategoryService extends BaseHttpService { `Upload`, data, options, - ).pipe($mappers.mapGuid()); + ).pipe(mapGuid()); } } diff --git a/libs/Guid.ts b/libs/Guid.ts index 4a0bcf3..76ac245 100644 --- a/libs/Guid.ts +++ b/libs/Guid.ts @@ -1,3 +1,6 @@ +import { OperatorFunction } from 'rxjs'; +import { map } from 'rxjs/operators'; + import type { TypeOrUndefined } from './types'; export class Guid { @@ -66,3 +69,7 @@ export class Guid { } } } + +export function mapGuid(): OperatorFunction { + return map((z: string) => (z ? new Guid(z) : Guid.empty)); +} diff --git a/libs/mappers.ts b/libs/mappers.ts index 2c8d267..d13fa22 100644 --- a/libs/mappers.ts +++ b/libs/mappers.ts @@ -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(dtoMapper: { fromDTO(value: TDTO): TModel }): OperatorFunction { @@ -21,10 +20,6 @@ export function mapIdentitySingle(identity: { new (id: TypeOrUndefined) => (z ? new identity(z.id) : undefined)); } -export function mapGuid(): OperatorFunction { - return map((z: string) => (z ? new Guid(z) : Guid.empty)); -} - export function mapDate(): OperatorFunction> { return map(toDateIn); } diff --git a/package-lock.json b/package-lock.json index 750b55f..187f6a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@luxbss/gengen", - "version": "1.1.0", + "version": "1.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@luxbss/gengen", - "version": "1.1.0", + "version": "1.1.1", "license": "MIT", "dependencies": { "commander": "9.0.0", diff --git a/package.json b/package.json index 3ce76d0..aed31b8 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/generators/angular/AngularServicesGenerator.ts b/src/generators/angular/AngularServicesGenerator.ts index 9da6301..a85c5ca 100644 --- a/src/generators/angular/AngularServicesGenerator.ts +++ b/src/generators/angular/AngularServicesGenerator.ts @@ -56,7 +56,7 @@ export class AngularServicesGenerator { { kind: StructureKind.ImportDeclaration, moduleSpecifier: `${path}/Guid`, - namedImports: [{ name: 'Guid' }] + namedImports: [{ name: 'Guid' }, { name: 'mapGuid' }] }, { kind: StructureKind.ImportDeclaration, diff --git a/src/generators/angular/AngularServicesMethodGenerator.ts b/src/generators/angular/AngularServicesMethodGenerator.ts index 48a3c79..a1dadf2 100644 --- a/src/generators/angular/AngularServicesMethodGenerator.ts +++ b/src/generators/angular/AngularServicesMethodGenerator.ts @@ -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) {