first commit
This commit is contained in:
34
templates/api.repository.contract.mustache
Normal file
34
templates/api.repository.contract.mustache
Normal file
@@ -0,0 +1,34 @@
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
import { InjectionToken } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
{{#imports}}
|
||||
import { {{classname}} } from '@/entities/models/{{classFilename}}.model';
|
||||
{{/imports}}
|
||||
|
||||
/**
|
||||
* {{classname}} Repository Contract
|
||||
* Generated from OpenAPI tag: {{classname}}
|
||||
*/
|
||||
export interface {{classname}}Repository {
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{summary}}
|
||||
{{#notes}}
|
||||
* {{notes}}
|
||||
{{/notes}}
|
||||
{{#allParams}}
|
||||
* @param {{paramName}} {{description}}
|
||||
{{/allParams}}
|
||||
*/
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{dataType}}{{^-last}}, {{/-last}}{{/allParams}}): Observable<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}>;
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
export const {{constantName}}_REPOSITORY = new InjectionToken<{{classname}}Repository>('{{constantName}}_REPOSITORY');
|
||||
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
61
templates/api.repository.impl.mustache
Normal file
61
templates/api.repository.impl.mustache
Normal file
@@ -0,0 +1,61 @@
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { environment } from '@environment';
|
||||
|
||||
import { MRepository } from '@mercadona/core/utils/repository';
|
||||
|
||||
import { {{classname}}Repository } from '../../../domain/repositories/{{classFilename}}.repository.contract';
|
||||
{{#imports}}
|
||||
import { {{classname}}Dto } from '@/dtos/{{classFilename}}/{{classFilename}}.dto';
|
||||
import { {{classname}} } from '@/entities/models/{{classFilename}}.model';
|
||||
import { {{classVarName}}Mapper } from '@/mappers/{{classFilename}}/{{classFilename}}.mapper';
|
||||
{{/imports}}
|
||||
|
||||
/**
|
||||
* {{classname}} Repository Implementation
|
||||
* Generated from OpenAPI tag: {{classname}}
|
||||
*/
|
||||
@Injectable()
|
||||
export class {{classname}}RepositoryImpl extends MRepository implements {{classname}}Repository {
|
||||
constructor() {
|
||||
super(`${environment.modapApi.url}`);
|
||||
}
|
||||
|
||||
{{#operation}}
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{dataType}}{{^-last}}, {{/-last}}{{/allParams}}): Observable<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
|
||||
{{#isListContainer}}
|
||||
return this.{{httpMethod}}<{{returnBaseType}}Dto>('{{path}}'{{#hasQueryParams}}, {
|
||||
params: { {{#queryParams}}{{paramName}}{{^-last}}, {{/-last}}{{/queryParams}} }
|
||||
}{{/hasQueryParams}}{{#hasBodyParam}}, {{bodyParam}}{{/hasBodyParam}})
|
||||
.pipe(
|
||||
map((response) => response.{{#vendorExtensions}}{{x-response-property}}{{/vendorExtensions}}{{^vendorExtensions}}items{{/vendorExtensions}}.map({{returnBaseType}}Mapper))
|
||||
);
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{#returnType}}
|
||||
return this.{{httpMethod}}<{{returnType}}Dto>('{{path}}'{{#hasQueryParams}}, {
|
||||
params: { {{#queryParams}}{{paramName}}{{^-last}}, {{/-last}}{{/queryParams}} }
|
||||
}{{/hasQueryParams}}{{#hasBodyParam}}, {{bodyParam}}{{/hasBodyParam}})
|
||||
.pipe(
|
||||
map({{returnType}}Mapper)
|
||||
);
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
return this.{{httpMethod}}<void>('{{path}}'{{#hasQueryParams}}, {
|
||||
params: { {{#queryParams}}{{paramName}}{{^-last}}, {{/-last}}{{/queryParams}} }
|
||||
}{{/hasQueryParams}}{{#hasBodyParam}}, {{bodyParam}}{{/hasBodyParam}});
|
||||
{{/returnType}}
|
||||
{{/isListContainer}}
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
34
templates/api.use-cases.contract.mustache
Normal file
34
templates/api.use-cases.contract.mustache
Normal file
@@ -0,0 +1,34 @@
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
import { InjectionToken } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
{{#imports}}
|
||||
import { {{classname}} } from '@/entities/models/{{classFilename}}.model';
|
||||
{{/imports}}
|
||||
|
||||
/**
|
||||
* {{classname}} Use Cases Contract
|
||||
* Generated from OpenAPI tag: {{classname}}
|
||||
*/
|
||||
export interface {{classname}}UseCases {
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{summary}}
|
||||
{{#notes}}
|
||||
* {{notes}}
|
||||
{{/notes}}
|
||||
{{#allParams}}
|
||||
* @param {{paramName}} {{description}}
|
||||
{{/allParams}}
|
||||
*/
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{dataType}}{{^-last}}, {{/-last}}{{/allParams}}): Observable<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}>;
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
export const {{constantName}}_USE_CASES = new InjectionToken<{{classname}}UseCases>('{{constantName}}_USE_CASES');
|
||||
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
32
templates/api.use-cases.impl.mustache
Normal file
32
templates/api.use-cases.impl.mustache
Normal file
@@ -0,0 +1,32 @@
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { {{classname}}UseCases } from './{{classFilename}}.use-cases.contract';
|
||||
|
||||
import { {{constantName}}_REPOSITORY, {{classname}}Repository } from '@/domain/repositories/{{classFilename}}.repository.contract';
|
||||
{{#imports}}
|
||||
import { {{classname}} } from '@/entities/models/{{classFilename}}.model';
|
||||
{{/imports}}
|
||||
|
||||
/**
|
||||
* {{classname}} Use Cases Implementation
|
||||
* Generated from OpenAPI tag: {{classname}}
|
||||
*/
|
||||
@Injectable()
|
||||
export class {{classname}}UseCasesImpl implements {{classname}}UseCases {
|
||||
#{{classVarName}}Repository: {{classname}}Repository = inject({{constantName}}_REPOSITORY);
|
||||
|
||||
{{#operation}}
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{dataType}}{{^-last}}, {{/-last}}{{/allParams}}): Observable<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
|
||||
return this.#{{classVarName}}Repository.{{nickname}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
28
templates/mapper.mustache
Normal file
28
templates/mapper.mustache
Normal file
@@ -0,0 +1,28 @@
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
import { MapFromFn } from '@mercadona/common/public';
|
||||
import { Builder } from '@mercadona/common/utils';
|
||||
|
||||
import { {{classname}}Dto } from '@/dtos/{{classFilename}}/{{classFilename}}.dto';
|
||||
import { {{classname}} } from '@/entities/models/{{classFilename}}.model';
|
||||
|
||||
/**
|
||||
* {{classname}} Mapper
|
||||
* Converts DTO to Domain Entity
|
||||
* Generated from OpenAPI schema: {{classname}}
|
||||
*/
|
||||
export const {{classVarName}}Mapper: MapFromFn<{{classname}}Dto, {{classname}}> = (dto: {{classname}}Dto): {{classname}} =>
|
||||
Builder.forModel({{classname}})
|
||||
{{#allModels}}
|
||||
{{#model}}
|
||||
{{#vars}}
|
||||
.{{name}}(dto.{{name}})
|
||||
{{/vars}}
|
||||
{{/model}}
|
||||
{{/allModels}}
|
||||
.build();
|
||||
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
24
templates/model-entity.mustache
Normal file
24
templates/model-entity.mustache
Normal file
@@ -0,0 +1,24 @@
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
{{#imports}}
|
||||
import { {{classname}} } from './{{classFilename}}.model';
|
||||
{{/imports}}
|
||||
|
||||
/**
|
||||
* {{classname}} Entity
|
||||
* {{#description}}{{description}}{{/description}}
|
||||
* Generated from OpenAPI schema
|
||||
*/
|
||||
export class {{classname}} {
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
/**
|
||||
* {{description}}
|
||||
*/
|
||||
{{/description}}
|
||||
{{name}}{{^required}}?{{/required}}: {{dataType}};
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
20
templates/model.mustache
Normal file
20
templates/model.mustache
Normal file
@@ -0,0 +1,20 @@
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
/**
|
||||
* {{classname}} DTO
|
||||
* {{#description}}{{description}}{{/description}}
|
||||
* Generated from OpenAPI specification
|
||||
*/
|
||||
export interface {{classname}}Dto {
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
/**
|
||||
* {{description}}
|
||||
*/
|
||||
{{/description}}
|
||||
{{name}}{{^required}}?{{/required}}: {{dataType}};
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
20
templates/repository.provider.mustache
Normal file
20
templates/repository.provider.mustache
Normal file
@@ -0,0 +1,20 @@
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
import { Provider } from '@angular/core';
|
||||
|
||||
import { {{constantName}}_REPOSITORY } from '@/domain/repositories/{{classFilename}}.repository.contract';
|
||||
import { {{classname}}RepositoryImpl } from '@/data/repositories/{{classFilename}}.repository.impl';
|
||||
|
||||
/**
|
||||
* {{classname}} Repository Provider
|
||||
* Binds the repository contract with its implementation
|
||||
*/
|
||||
export const {{classname}}RepositoryProvider: Provider = {
|
||||
provide: {{constantName}}_REPOSITORY,
|
||||
useClass: {{classname}}RepositoryImpl
|
||||
};
|
||||
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
20
templates/use-cases.provider.mustache
Normal file
20
templates/use-cases.provider.mustache
Normal file
@@ -0,0 +1,20 @@
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
import { Provider } from '@angular/core';
|
||||
|
||||
import { {{constantName}}_USE_CASES } from '@/domain/use-cases/{{classFilename}}/{{classFilename}}.use-cases.contract';
|
||||
import { {{classname}}UseCasesImpl } from '@/domain/use-cases/{{classFilename}}/{{classFilename}}.use-cases.impl';
|
||||
|
||||
/**
|
||||
* {{classname}} Use Cases Provider
|
||||
* Binds the use cases contract with its implementation
|
||||
*/
|
||||
export const {{classname}}UseCasesProvider: Provider = {
|
||||
provide: {{constantName}}_USE_CASES,
|
||||
useClass: {{classname}}UseCasesImpl
|
||||
};
|
||||
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
Reference in New Issue
Block a user