@silexpert/core 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/importInterfaces.ts +21 -24
  2. package/package.json +1 -2
@@ -1,12 +1,13 @@
1
- import * as ejs from 'ejs';
2
- const convertTable = require('./table.json');
3
- const models = require('./export-models.json');
1
+ import { compile } from 'ejs';
2
+
4
3
  const { resolve } = require('path');
5
4
  const { readFileSync, writeFileSync } = require('fs');
5
+ const convertTable = require('./table.json');
6
+ const models = require('./export-models.json');
6
7
 
7
8
  const interfaceTemplate = readFileSync(resolve(__dirname, '.templates/interface.ejs')).toString();
8
9
 
9
- const interfaceRender = ejs.compile(interfaceTemplate);
10
+ const interfaceRender = compile(interfaceTemplate);
10
11
 
11
12
  const tables = Object.entries(models);
12
13
 
@@ -31,16 +32,14 @@ const convertType = (type: string, allowNull?: boolean) => {
31
32
 
32
33
  const convertFields = (model: any) => {
33
34
  const fields = Object.entries(model.fields);
34
- const output = fields.map(([name, value]: [string, any]) => {
35
- return {
36
- name: value.primaryKey ? 'id' : name,
37
- type: convertType(value.type,['deletedAt', 'createdAt', 'updatedAt'].includes(name) || value.allowNull)
38
- };
39
- });
35
+ const output = fields.map(([name, value]: [string, any]) => ({
36
+ name: value.primaryKey ? 'id' : name,
37
+ type: convertType(value.type, ['deletedAt', 'createdAt', 'updatedAt'].includes(name) || value.allowNull),
38
+ }));
40
39
  if (model.paranoid && !output.find(({ name }) => name === 'deletedAt')) {
41
40
  output.push({
42
41
  name: 'deletedAt',
43
- type: 'Date | null'
42
+ type: 'Date | null',
44
43
  });
45
44
  }
46
45
  return output;
@@ -59,24 +58,22 @@ const convertAssociations = (model: any) => {
59
58
  [sanitizedName]: {
60
59
  entity: `I${convertTable[value.target]}`,
61
60
  target,
62
- name: sanitizedName
63
- }
61
+ name: sanitizedName,
62
+ },
64
63
  };
65
64
  }, {}));
66
65
  };
67
66
 
68
- const convertImports = (name: string, associations: any[]) => {
69
- return Object.values(associations.filter(({ entity }) => entity !== name).reduce((acc, { entity }) => {
70
- return {
71
- ...acc,
72
- [entity]: {
73
- target: entity,
74
- path: `./${entity}`
75
- }};
76
- }, {}));
77
- };
67
+ const convertImports = (name: string, associations: any[]) => Object.values(associations.filter(({ entity }) => entity !== name).reduce((acc, { entity }) => ({
68
+ ...acc,
69
+ [entity]: {
70
+ target: entity,
71
+ path: `./${entity}`,
72
+ },
73
+ }), {}));
78
74
 
79
- for (let [tableName, tableValues] of tables) {
75
+ // eslint-disable-next-line no-restricted-syntax
76
+ for (const [tableName, tableValues] of tables) {
80
77
  const name = `I${convertTable[tableName]}`;
81
78
  const fields = convertFields(tableValues);
82
79
  const associations = convertAssociations(tableValues);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silexpert/core",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Silex Core perform HTTP Request and object binding. Silex core helps developers to retrieve and return formatted object",
5
5
  "homepage": "https://gitlab.compta-clementine.fr/dev/silex-api",
6
6
  "main": "js/index.js",
@@ -78,7 +78,6 @@
78
78
  "class-validator": "^0.13.1",
79
79
  "dayjs": "^1.10.4",
80
80
  "eslint-config-airbnb": "^18.2.1",
81
- "fs-extra": "^10.0.0",
82
81
  "mailparser": "^3.4.0",
83
82
  "readme-md-generator": "^1.0.0",
84
83
  "rxjs": "^7.0.1",