Fix type NamingStrategy

This commit is contained in:
CatsMiaow 2020-02-20 13:26:47 +09:00
parent 8a09320345
commit be9d8925bf
2 changed files with 13 additions and 16 deletions

View File

@ -4,20 +4,13 @@ import { Entity } from "./models/Entity";
import IGenerationOptions from "./IGenerationOptions";
import * as NamingStrategy from "./NamingStrategy";
import * as TomgUtils from "./Utils";
import { Relation } from "./models/Relation";
import { RelationId } from "./models/RelationId";
import { Column } from "./models/Column";
type NamingStrategy = {
enablePluralization: (value: boolean) => void;
relationIdName: (
relationId: RelationId,
relation: Relation,
owner: Entity
) => string;
relationName: (relation: Relation, owner: Entity) => string;
columnName: (columnName: string, column?: Column) => string;
entityName: (entityName: string, entity?: Entity) => string;
enablePluralization: typeof NamingStrategy.enablePluralization;
relationIdName: typeof NamingStrategy.relationIdName;
relationName: typeof NamingStrategy.relationName;
columnName: typeof NamingStrategy.columnName;
entityName: typeof NamingStrategy.entityName;
};
export default function modelCustomizationPhase(

View File

@ -1,7 +1,10 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { plural } from "pluralize";
import * as changeCase from "change-case";
import { Relation } from "./models/Relation";
import { RelationId } from "./models/RelationId";
import { Entity } from "./models/Entity";
import { Column } from "./models/Column";
let pluralize: boolean;
@ -11,7 +14,8 @@ export function enablePluralization(value: boolean) {
export function relationIdName(
relationId: RelationId,
relation: Relation
relation: Relation,
owner?: Entity
): string {
const columnOldName = relationId.fieldName;
@ -35,7 +39,7 @@ export function relationIdName(
return newColumnName;
}
export function relationName(relation: Relation): string {
export function relationName(relation: Relation, owner?: Entity): string {
const columnOldName = relation.fieldName;
const isRelationToMany =
@ -66,10 +70,10 @@ export function relationName(relation: Relation): string {
return newColumnName;
}
export function entityName(oldEntityName: string): string {
export function entityName(oldEntityName: string, entity?: Entity): string {
return oldEntityName;
}
export function columnName(oldColumnName: string): string {
export function columnName(oldColumnName: string, column?: Column): string {
return oldColumnName;
}