Skip to content

Commit

Permalink
[JS] Fix code généré pour correspondre à prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
JabX committed Sep 1, 2024
1 parent 7d8abdb commit 0c13a00
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private void WriteSubModule(FileWriter fw, string lang, IEnumerable<IProperty> p
}
else
{
fw.WriteLine(level, $@"""{submodule.Key.Split('.').First().ToCamelCase()}"": {{");
fw.WriteLine(level, $@"{Quote(submodule.Key.Split('.').First().ToCamelCase())}: {{");
WriteSubModule(fw, lang, submodule.SelectMany(m => m), isComment, level + 1);
if (isLast)
{
Expand Down
23 changes: 9 additions & 14 deletions TopModel.Generator.Javascript/TypescriptDefinitionGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected override void HandleClass(string fileName, Class classe, string tag)

if (Config.EntityMode == EntityMode.TYPED)
{
fw.WriteLine($"export type {classe.NamePascal} = EntityToType<{classe.NamePascal}EntityType>");
fw.WriteLine($"export type {classe.NamePascal} = EntityToType<{classe.NamePascal}EntityType>;");

fw.Write($"export interface {classe.NamePascal}EntityType ");

Expand Down Expand Up @@ -113,10 +113,10 @@ protected override void HandleClass(string fileName, Class classe, string tag)
switch (property)
{
case CompositionProperty { Domain: null } cp:
fw.Write($"ObjectEntry<{cp.Composition.NamePascal}EntityType>");
fw.Write($"ObjectEntry<{cp.Composition.NamePascal}EntityType>;");
break;
case AliasProperty { Property: CompositionProperty { Domain: null } cp }:
fw.Write($"ObjectEntry<{cp.Composition.NamePascal}EntityType>");
fw.Write($"ObjectEntry<{cp.Composition.NamePascal}EntityType>;");
break;
case CompositionProperty cp when Config.IsListComposition(cp):
if (cp.Composition.Name == classe.Name)
Expand All @@ -125,34 +125,29 @@ protected override void HandleClass(string fileName, Class classe, string tag)
}
else
{
fw.Write($"ListEntry<{cp.Composition.NamePascal}EntityType>");
fw.Write($"ListEntry<{cp.Composition.NamePascal}EntityType>;");
}

break;
case AliasProperty { Property: CompositionProperty cp } when Config.IsListComposition(cp):
if (cp.Composition.Name == classe.Name)
{
fw.Write($"RecursiveListEntry");
fw.Write($"RecursiveListEntry;");
}
else
{
fw.Write($"ListEntry<{cp.Composition.NamePascal}EntityType>");
fw.Write($"ListEntry<{cp.Composition.NamePascal}EntityType>;");
}

break;
default:
fw.Write($"FieldEntry2<typeof {property.Domain.Name}, {Config.GetType(property, Classes)}>");
fw.Write($"FieldEntry2<typeof {property.Domain.Name}, {Config.GetType(property, Classes)}>;");
break;
}
}
else
{
fw.Write(Config.GetType(property, Classes));
}

if (property != classe.Properties.Last())
{
fw.Write(",");
fw.Write($"{Config.GetType(property, Classes)};");
}

fw.Write("\r\n");
Expand Down Expand Up @@ -275,7 +270,7 @@ protected override void HandleClass(string fileName, Class classe, string tag)
fw.WriteLine();
}

fw.WriteLine($"}}{(Config.EntityMode == EntityMode.TYPED ? string.Empty : " as const")}");
fw.WriteLine($"}}{(Config.EntityMode == EntityMode.TYPED ? string.Empty : " as const")};");

if (classe.Reference)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import {DO_ENTIER, DO_ID, DO_LIBELLE} from "@domains";

export interface ProfilItem {
id?: number,
libelle?: string,
nombreUtilisateurs?: number
id?: number;
libelle?: string;
nombreUtilisateurs?: number;
}

export const ProfilItemEntity = {
Expand All @@ -32,4 +32,4 @@ export const ProfilItemEntity = {
isRequired: true,
label: "securite.profil.profilItem.nombreUtilisateurs"
}
} as const
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import {UtilisateurItemEntity, UtilisateurItem} from "../utilisateur/utilisateur
import {DroitCode} from "./references";

export interface ProfilRead {
id?: number,
libelle?: string,
droits?: DroitCode[],
dateCreation?: string,
dateModification?: string,
utilisateurs?: UtilisateurItem[]
id?: number;
libelle?: string;
droits?: DroitCode[];
dateCreation?: string;
dateModification?: string;
utilisateurs?: UtilisateurItem[];
}

export const ProfilReadEntity = {
Expand Down Expand Up @@ -56,4 +56,4 @@ export const ProfilReadEntity = {
type: "list",
entity: UtilisateurItemEntity
}
} as const
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {DO_CODE_LISTE, DO_LIBELLE} from "@domains";
import {DroitCode} from "./references";

export interface ProfilWrite {
libelle?: string,
droits?: DroitCode[]
libelle?: string;
droits?: DroitCode[];
}

export const ProfilWriteEntity = {
Expand All @@ -26,4 +26,4 @@ export const ProfilWriteEntity = {
isRequired: false,
label: "securite.profil.profil.droits"
}
} as const
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {DO_CODE, DO_EMAIL, DO_ID, DO_LIBELLE} from "@domains";
import {TypeUtilisateurCode} from "./references";

export interface UtilisateurItem {
id?: number,
nom?: string,
prenom?: string,
email?: string,
typeUtilisateurCode?: TypeUtilisateurCode
id?: number;
nom?: string;
prenom?: string;
email?: string;
typeUtilisateurCode?: TypeUtilisateurCode;
}

export const UtilisateurItemEntity = {
Expand Down Expand Up @@ -51,4 +51,4 @@ export const UtilisateurItemEntity = {
isRequired: true,
label: "securite.utilisateur.utilisateur.typeUtilisateurCode"
}
} as const
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import {DO_BOOLEEN, DO_CODE, DO_DATE, DO_DATE_HEURE, DO_EMAIL, DO_ID, DO_LIBELLE
import {TypeUtilisateurCode} from "./references";

export interface UtilisateurRead {
id?: number,
nom?: string,
prenom?: string,
email?: string,
dateNaissance?: string,
adresse?: string,
actif?: boolean,
profilId?: number,
typeUtilisateurCode?: TypeUtilisateurCode,
dateCreation?: string,
dateModification?: string
id?: number;
nom?: string;
prenom?: string;
email?: string;
dateNaissance?: string;
adresse?: string;
actif?: boolean;
profilId?: number;
typeUtilisateurCode?: TypeUtilisateurCode;
dateCreation?: string;
dateModification?: string;
}

export const UtilisateurReadEntity = {
Expand Down Expand Up @@ -100,4 +100,4 @@ export const UtilisateurReadEntity = {
isRequired: false,
label: "common.entityListeners.dateModification"
}
} as const
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {DO_BOOLEEN, DO_CODE, DO_DATE, DO_EMAIL, DO_ID, DO_LIBELLE} from "@domain
import {TypeUtilisateurCode} from "./references";

export interface UtilisateurWrite {
nom?: string,
prenom?: string,
email?: string,
dateNaissance?: string,
adresse?: string,
actif?: boolean,
profilId?: number,
typeUtilisateurCode?: TypeUtilisateurCode
nom?: string;
prenom?: string;
email?: string;
dateNaissance?: string;
adresse?: string;
actif?: boolean;
profilId?: number;
typeUtilisateurCode?: TypeUtilisateurCode;
}

export const UtilisateurWriteEntity = {
Expand Down Expand Up @@ -76,4 +76,4 @@ export const UtilisateurWriteEntity = {
isRequired: true,
label: "securite.utilisateur.utilisateur.typeUtilisateurCode"
}
} as const
} as const;
4 changes: 2 additions & 2 deletions samples/generators/focus/src/locale/securite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
////

export const securite = {
"profil": {
profil: {
droit: {
code: "Droit",
libelle: "Droit",
Expand All @@ -25,7 +25,7 @@ export const securite = {
libelle: "Libelle"
}
},
"utilisateur": {
utilisateur: {
typeUtilisateur: {
code: "Type d'utilisateur",
libelle: "Libelle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import {EntityToType, FieldEntry2} from "@focus4/stores";
import {DO_ENTIER, DO_ID, DO_LIBELLE} from "../../../domains";

export type ProfilItem = EntityToType<ProfilItemEntityType>
export type ProfilItem = EntityToType<ProfilItemEntityType>;
export interface ProfilItemEntityType {
id: FieldEntry2<typeof DO_ID, number>,
libelle: FieldEntry2<typeof DO_LIBELLE, string>,
nombreUtilisateurs: FieldEntry2<typeof DO_ENTIER, number>
id: FieldEntry2<typeof DO_ID, number>;
libelle: FieldEntry2<typeof DO_LIBELLE, string>;
nombreUtilisateurs: FieldEntry2<typeof DO_ENTIER, number>;
}

export const ProfilItemEntity: ProfilItemEntityType = {
Expand All @@ -34,4 +34,4 @@ export const ProfilItemEntity: ProfilItemEntityType = {
isRequired: true,
label: "securite.profil.profilItem.nombreUtilisateurs"
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {DO_CODE_LISTE, DO_DATE_HEURE, DO_ID, DO_LIBELLE} from "../../../domains"
import {UtilisateurItemEntity, UtilisateurItemEntityType} from "../utilisateur/utilisateur-item";
import {DroitCode} from "./references";

export type ProfilRead = EntityToType<ProfilReadEntityType>
export type ProfilRead = EntityToType<ProfilReadEntityType>;
export interface ProfilReadEntityType {
id: FieldEntry2<typeof DO_ID, number>,
libelle: FieldEntry2<typeof DO_LIBELLE, string>,
droits: FieldEntry2<typeof DO_CODE_LISTE, DroitCode[]>,
dateCreation: FieldEntry2<typeof DO_DATE_HEURE, string>,
dateModification: FieldEntry2<typeof DO_DATE_HEURE, string>,
utilisateurs: ListEntry<UtilisateurItemEntityType>
id: FieldEntry2<typeof DO_ID, number>;
libelle: FieldEntry2<typeof DO_LIBELLE, string>;
droits: FieldEntry2<typeof DO_CODE_LISTE, DroitCode[]>;
dateCreation: FieldEntry2<typeof DO_DATE_HEURE, string>;
dateModification: FieldEntry2<typeof DO_DATE_HEURE, string>;
utilisateurs: ListEntry<UtilisateurItemEntityType>;
}

export const ProfilReadEntity: ProfilReadEntityType = {
Expand Down Expand Up @@ -60,4 +60,4 @@ export const ProfilReadEntity: ProfilReadEntityType = {
isRequired: true,
label: "securite.profil.profilRead.utilisateurs"
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {DO_CODE_LISTE, DO_LIBELLE} from "../../../domains";

import {DroitCode} from "./references";

export type ProfilWrite = EntityToType<ProfilWriteEntityType>
export type ProfilWrite = EntityToType<ProfilWriteEntityType>;
export interface ProfilWriteEntityType {
libelle: FieldEntry2<typeof DO_LIBELLE, string>,
droits: FieldEntry2<typeof DO_CODE_LISTE, DroitCode[]>
libelle: FieldEntry2<typeof DO_LIBELLE, string>;
droits: FieldEntry2<typeof DO_CODE_LISTE, DroitCode[]>;
}

export const ProfilWriteEntity: ProfilWriteEntityType = {
Expand All @@ -28,4 +28,4 @@ export const ProfilWriteEntity: ProfilWriteEntityType = {
isRequired: false,
label: "securite.profil.profil.droits"
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {DO_CODE, DO_EMAIL, DO_ID, DO_LIBELLE} from "../../../domains";

import {TypeUtilisateurCode} from "./references";

export type UtilisateurItem = EntityToType<UtilisateurItemEntityType>
export type UtilisateurItem = EntityToType<UtilisateurItemEntityType>;
export interface UtilisateurItemEntityType {
id: FieldEntry2<typeof DO_ID, number>,
nom: FieldEntry2<typeof DO_LIBELLE, string>,
prenom: FieldEntry2<typeof DO_LIBELLE, string>,
email: FieldEntry2<typeof DO_EMAIL, string>,
typeUtilisateurCode: FieldEntry2<typeof DO_CODE, TypeUtilisateurCode>
id: FieldEntry2<typeof DO_ID, number>;
nom: FieldEntry2<typeof DO_LIBELLE, string>;
prenom: FieldEntry2<typeof DO_LIBELLE, string>;
email: FieldEntry2<typeof DO_EMAIL, string>;
typeUtilisateurCode: FieldEntry2<typeof DO_CODE, TypeUtilisateurCode>;
}

export const UtilisateurItemEntity: UtilisateurItemEntityType = {
Expand Down Expand Up @@ -53,4 +53,4 @@ export const UtilisateurItemEntity: UtilisateurItemEntityType = {
isRequired: true,
label: "securite.utilisateur.utilisateur.typeUtilisateurCode"
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import {DO_BOOLEEN, DO_CODE, DO_DATE, DO_DATE_HEURE, DO_EMAIL, DO_ID, DO_LIBELLE

import {TypeUtilisateurCode} from "./references";

export type UtilisateurRead = EntityToType<UtilisateurReadEntityType>
export type UtilisateurRead = EntityToType<UtilisateurReadEntityType>;
export interface UtilisateurReadEntityType {
id: FieldEntry2<typeof DO_ID, number>,
nom: FieldEntry2<typeof DO_LIBELLE, string>,
prenom: FieldEntry2<typeof DO_LIBELLE, string>,
email: FieldEntry2<typeof DO_EMAIL, string>,
dateNaissance: FieldEntry2<typeof DO_DATE, string>,
adresse: FieldEntry2<typeof DO_LIBELLE, string>,
actif: FieldEntry2<typeof DO_BOOLEEN, boolean>,
profilId: FieldEntry2<typeof DO_ID, number>,
typeUtilisateurCode: FieldEntry2<typeof DO_CODE, TypeUtilisateurCode>,
dateCreation: FieldEntry2<typeof DO_DATE_HEURE, string>,
dateModification: FieldEntry2<typeof DO_DATE_HEURE, string>
id: FieldEntry2<typeof DO_ID, number>;
nom: FieldEntry2<typeof DO_LIBELLE, string>;
prenom: FieldEntry2<typeof DO_LIBELLE, string>;
email: FieldEntry2<typeof DO_EMAIL, string>;
dateNaissance: FieldEntry2<typeof DO_DATE, string>;
adresse: FieldEntry2<typeof DO_LIBELLE, string>;
actif: FieldEntry2<typeof DO_BOOLEEN, boolean>;
profilId: FieldEntry2<typeof DO_ID, number>;
typeUtilisateurCode: FieldEntry2<typeof DO_CODE, TypeUtilisateurCode>;
dateCreation: FieldEntry2<typeof DO_DATE_HEURE, string>;
dateModification: FieldEntry2<typeof DO_DATE_HEURE, string>;
}

export const UtilisateurReadEntity: UtilisateurReadEntityType = {
Expand Down Expand Up @@ -102,4 +102,4 @@ export const UtilisateurReadEntity: UtilisateurReadEntityType = {
isRequired: false,
label: "common.entityListeners.dateModification"
}
}
};
Loading

0 comments on commit 0c13a00

Please sign in to comment.