generate-dac 1.0.0 → 1.0.2

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.
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ presets: [
3
+ ['@babel/preset-env', { targets: { node: 'current' } }],
4
+ '@babel/preset-typescript',
5
+ ],
6
+ };
package/dist/DAC_Utils.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.DAC_Generate_From_XLSX = exports.DAC_Generate_From_XLSX_Sheet = exports.dac_generate_table_schema = exports.dac_generate_structure = exports.dac_generate_conversions = exports.dac_generate_dataServiceObject = exports.dac_generate_sql = exports.get_output_filepath = exports.dac_generate_data_access = exports.repeat = exports.get_SqlDbType = exports.binding_template = void 0;
7
7
  var dayjs_1 = __importDefault(require("dayjs"));
8
8
  var excel_utils_1 = require("./utils/excel-utils");
9
+ var str_utils_1 = require("./utils/str-utils");
9
10
  var file_utils_1 = require("./utils/file_utils");
10
11
  var OUTPUT_DIR = './output/';
11
12
  var TEMPLATE_DIR = (0, file_utils_1.__parent_dir)(__dirname) + '/';
@@ -347,9 +348,13 @@ function dac_generate_structure(tableName, schemas) {
347
348
  updated_by_user = "public User_AccountInfo UpdatedByUser;";
348
349
  }
349
350
  var className = tableName.replace(/[_ ]+/g, '');
351
+ var classNamePlural = (0, str_utils_1.str_plural)(className);
352
+ var tableNamePlural = (0, str_utils_1.str_plural)(tableName);
353
+ var tableNameLower = tableName.toLowerCase();
350
354
  var classStr = binding_template(classItemTemplate, {
351
355
  table_name: tableName,
352
- table_name_lower: tableName.toLowerCase(),
356
+ table_name_plural: tableNamePlural,
357
+ table_name_lower: tableNameLower,
353
358
  class_name: className,
354
359
  properties: strProperties,
355
360
  datetime: CREATED_DATETIME,
@@ -359,7 +364,8 @@ function dac_generate_structure(tableName, schemas) {
359
364
  result.classes.push(classStr);
360
365
  var content = binding_template(DataAccess_Structure_Template, {
361
366
  table_name: tableName,
362
- table_name_lower: tableName.toLowerCase(),
367
+ table_name_plural: tableNamePlural,
368
+ table_name_lower: tableNameLower,
363
369
  class_name: className,
364
370
  datetime: CREATED_DATETIME,
365
371
  content: classStr,
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.str_key = exports.str_clean = exports.str_insert = exports.str_upper_first_letter = exports.str_className = exports.str_capitalize = exports.str_slug = exports.str_guid = exports.str_uuid = exports.str_ucfirst = void 0;
26
+ exports.str_plural = exports.str_key = exports.str_clean = exports.str_insert = exports.str_upper_first_letter = exports.str_className = exports.str_capitalize = exports.str_slug = exports.str_guid = exports.str_uuid = exports.str_ucfirst = void 0;
27
27
  var uuid = __importStar(require("uuid"));
28
28
  function str_ucfirst(str) {
29
29
  if (!str)
@@ -95,3 +95,24 @@ function str_key(str) {
95
95
  return str.trim().toLowerCase().replace(/\s+/gi, '_').replace(/[\.]/i, '');
96
96
  }
97
97
  exports.str_key = str_key;
98
+ function str_plural(singularNoun) {
99
+ if (!singularNoun)
100
+ return '';
101
+ var exceptions = {
102
+ child: 'children',
103
+ };
104
+ if (exceptions[singularNoun.toLowerCase()]) {
105
+ return exceptions[singularNoun];
106
+ }
107
+ var lastChar = singularNoun.slice(-1);
108
+ if (lastChar === 'y' && !['a', 'e', 'i', 'o', 'u'].includes(singularNoun.charAt(singularNoun.length - 2))) {
109
+ return singularNoun.slice(0, -1) + 'ies';
110
+ }
111
+ else if (['s', 'x', 'z'].includes(lastChar) || (lastChar === 'h' && ['c', 's'].includes(singularNoun.charAt(singularNoun.length - 2)))) {
112
+ return singularNoun + 'es';
113
+ }
114
+ else {
115
+ return singularNoun + 's';
116
+ }
117
+ }
118
+ exports.str_plural = str_plural;
package/jest.config.js ADDED
@@ -0,0 +1,5 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: 'ts-jest',
4
+ testEnvironment: 'node',
5
+ };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "generate-dac",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1",
7
+ "test": "jest",
8
8
  "start": "ts-node ./src/index.ts",
9
9
  "build": "tsc --skipLibCheck",
10
10
  "test-build": "node ./dist/index.js"
@@ -28,7 +28,14 @@
28
28
  "xlsx": "^0.18.5"
29
29
  },
30
30
  "devDependencies": {
31
+ "@babel/preset-typescript": "^7.23.3",
32
+ "@jest/globals": "^29.7.0",
31
33
  "@types/command-line-args": "^5.2.0",
32
- "@types/node": "^17.0.35"
34
+ "@types/jest": "^29.5.12",
35
+ "@types/node": "^17.0.35",
36
+ "cross-env": "^7.0.3",
37
+ "jest": "^29.7.0",
38
+ "ts-jest": "^29.1.2",
39
+ "ts-node": "^10.9.2"
33
40
  }
34
- }
41
+ }
package/readme.md ADDED
@@ -0,0 +1,17 @@
1
+ * How to generate DAC with new WAY
2
+
3
+ ** Requirement:
4
+ - nodejs
5
+ - https://nodejs.org/en/download
6
+
7
+ ** Steps to generate dac
8
+
9
+ 1. Create a new folder with any name. Example "generate-dac".
10
+ 2. Go new folder and create other folder with name "input".
11
+ 3. Put excel file with correct schema format. See example file.
12
+ 4. Open command line in root folder. In this case "generate-dac".
13
+ 5. Run "npx generate-dac"
14
+ 6. Processing...
15
+ 7. Done. Check output folder.
16
+ 8. Enjoy. Any issue contact me to get support.
17
+ 9. Donate me a coffee cup. Thanks.
package/src/DAC_Utils.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import dayjs from "dayjs";
2
2
  import { SheetData, json_read_all_sheets_from_excel} from "./utils/excel-utils";
3
- import { str_className } from "./utils/str-utils";
3
+ import { str_className, str_plural } from "./utils/str-utils";
4
4
  import { ColumnSchema } from "./interface";
5
5
  import { __parent_dir, dir_create, file_exists, get_filename_without_extension, str_to_file, text_from_file } from "./utils/file_utils";
6
6
  import { IFile } from "./utils/UtilsInterface";
@@ -143,6 +143,8 @@ export function dac_generate_data_access(tableName: string, schemas: ColumnSchem
143
143
  columnEnumStr+= ",\n\t\t\t" + createUserStr;
144
144
  }
145
145
 
146
+ const tableNamePlural = str_plural(tableName);
147
+
146
148
  const insertParamsStart = schemas.filter(e =>
147
149
  e.col_name !== 'ID'
148
150
  && e.col_name !== 'Create_DateTime'
@@ -150,9 +152,9 @@ export function dac_generate_data_access(tableName: string, schemas: ColumnSchem
150
152
  ).map((e, i) => {
151
153
  const types = get_SqlDbType(e.type);
152
154
  if(types.type === 'DateTime'){
153
- return `CreateParameter(dbCommand, "@${e.col_name}", SqlDbType.${types.type}, FixDBDateTime(obj${tableName}s.Collection[i].${e.col_name}));`;
155
+ return `CreateParameter(dbCommand, "@${e.col_name}", SqlDbType.${types.type}, FixDBDateTime(obj${tableNamePlural}.Collection[i].${e.col_name}));`;
154
156
  }
155
- return `CreateParameter(dbCommand, "@${e.col_name}", SqlDbType.${types.type}, obj${tableName}s.Collection[i].${e.col_name});`;
157
+ return `CreateParameter(dbCommand, "@${e.col_name}", SqlDbType.${types.type}, obj${tableNamePlural}.Collection[i].${e.col_name});`;
156
158
  }).join("\n" + repeat("\t", 5));
157
159
 
158
160
  const updateParamsStart = schemas.filter(e =>
@@ -162,10 +164,10 @@ export function dac_generate_data_access(tableName: string, schemas: ColumnSchem
162
164
  ).map((e, i) => {
163
165
  const types = get_SqlDbType(e.type);
164
166
  if(types.type === 'DateTime'){
165
- return `CreateParameter(dbCommand, "@${e.col_name}", SqlDbType.${types.type}, FixDBDateTime(obj${tableName}s.Collection[i].${e.col_name}));`;
167
+ return `CreateParameter(dbCommand, "@${e.col_name}", SqlDbType.${types.type}, FixDBDateTime(obj${tableNamePlural}.Collection[i].${e.col_name}));`;
166
168
  }
167
169
 
168
- return `CreateParameter(dbCommand, "@${e.col_name}", SqlDbType.${types.type}, obj${tableName}s.Collection[i].${e.col_name});`;
170
+ return `CreateParameter(dbCommand, "@${e.col_name}", SqlDbType.${types.type}, obj${tableNamePlural}.Collection[i].${e.col_name});`;
169
171
  }).join("\n" + repeat("\t", 5));
170
172
 
171
173
  const fillStr = schemas.map((e, i) => {
@@ -183,9 +185,10 @@ export function dac_generate_data_access(tableName: string, schemas: ColumnSchem
183
185
  if(updateColumn){
184
186
  updateField = `obj${tableName}.UpdatedByUser = ReadUserAccount(objDataReader, (int)${tableName}Column.Update_User_Account_ID, (int)${tableName}Column.UpdatedByLogonName, (int)${tableName}Column.UpdatedByFirstName, (int)${tableName}Column.UpdatedByLastName);`
185
187
  }
186
-
188
+
187
189
  const dacTemplateGeneratedContentOutput = binding_template(dacTemplateGeneratedContent, {
188
190
  Table_Name: tableName,
191
+ Table_Name_Plural: tableNamePlural,
189
192
  table_name_lower: tableName.toLowerCase(),
190
193
  table_column_enum: columnEnumStr,
191
194
  insert_params: insertParamsStart,
@@ -325,11 +328,14 @@ export function dac_generate_dataServiceObject(tableName: string, schemas: Colum
325
328
  }
326
329
 
327
330
  const className = get_className(tableName);
331
+ const tableNameLower = tableName.toLowerCase();
332
+ const classNamePlural = str_plural(className);
328
333
 
329
334
  const classStr = binding_template(classTemplate, {
330
335
  table_name: tableName,
331
- table_name_lower: tableName.toLowerCase(),
336
+ table_name_lower: tableNameLower,
332
337
  class_name: className,
338
+ class_name_plural: classNamePlural,
333
339
  properties: strProperties,
334
340
  created_by_user: created_by_user,
335
341
  updated_by_user: updated_by_user,
@@ -340,8 +346,9 @@ export function dac_generate_dataServiceObject(tableName: string, schemas: Colum
340
346
 
341
347
  const content = binding_template(DataServiceObjects_Template, {
342
348
  table_name: tableName,
343
- table_name_lower: tableName.toLowerCase(),
349
+ table_name_lower: tableNameLower,
344
350
  class_name: className,
351
+ class_name_plural: classNamePlural,
345
352
  datetime: CREATED_DATETIME,
346
353
  content: classStr
347
354
  });
@@ -450,12 +457,14 @@ export function dac_generate_structure(tableName: string, schemas: ColumnSchema[
450
457
  }
451
458
 
452
459
  const className = tableName.replace(/[_ ]+/g, '');
453
- // hardcord
454
- // const classNames = 'RPM_Reservation_Statuses';
460
+ const classNamePlural = str_plural(className);
461
+ const tableNamePlural = str_plural(tableName);
462
+ const tableNameLower = tableName.toLowerCase();
455
463
 
456
464
  const classStr = binding_template(classItemTemplate, {
457
465
  table_name: tableName,
458
- table_name_lower: tableName.toLowerCase(),
466
+ table_name_plural: tableNamePlural,
467
+ table_name_lower: tableNameLower,
459
468
  class_name: className,
460
469
  properties: strProperties,
461
470
  datetime: CREATED_DATETIME,
@@ -467,7 +476,8 @@ export function dac_generate_structure(tableName: string, schemas: ColumnSchema[
467
476
 
468
477
  const content = binding_template(DataAccess_Structure_Template, {
469
478
  table_name: tableName,
470
- table_name_lower: tableName.toLowerCase(),
479
+ table_name_plural: tableNamePlural,
480
+ table_name_lower: tableNameLower,
471
481
  class_name: className,
472
482
  datetime: CREATED_DATETIME,
473
483
  content: classStr,
@@ -0,0 +1,24 @@
1
+ import dayjs from "dayjs";
2
+ import { DAC_Generate_From_XLSX } from "../DAC_Utils";
3
+ import { fileName_in_folder, file_exists } from "../utils/file_utils";
4
+
5
+ export function start_generate_dac_for_new_table(INPUT_DIR: string) {
6
+ if (!file_exists(INPUT_DIR)) {
7
+ console.log(`There's no input folder. Please create input folder and put excel file to generate.`.red);
8
+ return;
9
+ }
10
+ const files = fileName_in_folder(INPUT_DIR);
11
+
12
+ if (!files || !files.length) {
13
+ console.log(`No input files.`.red);
14
+ return;
15
+ }
16
+
17
+ const now = dayjs().format('DD-ddd-YYYY HH:mm');
18
+ console.log(`Process Generate DAC ${now}`.green);
19
+
20
+ files.forEach((file, i) => {
21
+ console.log(`Begin to process file ${file.name}`.yellow);
22
+ DAC_Generate_From_XLSX(file.path);
23
+ })
24
+ }
@@ -0,0 +1,12 @@
1
+ import commandLineArgs from "command-line-args";
2
+
3
+ export interface StartProcessOptions{
4
+ inputFolder: string
5
+ }
6
+ export function startProcess(options: StartProcessOptions){
7
+ const optionDefinitions = [
8
+ { name: 'args', type: String, multiple: true, defaultOption: true }
9
+ ]
10
+ const commands = commandLineArgs(optionDefinitions)
11
+ console.log(commands);
12
+ }
package/src/index.ts CHANGED
@@ -3,31 +3,16 @@
3
3
  import colors from 'colors';
4
4
  import { DAC_Generate_From_XLSX } from './DAC_Utils';
5
5
  import dayjs from 'dayjs';
6
+ import commandLineArgs from 'command-line-args';
7
+
6
8
  import { __parent_dir, fileName_in_folder, file_exists } from './utils/file_utils';
9
+ import { start_generate_dac_for_new_table } from './generate-table-dac';
10
+ import { startProcess } from './handle-command-line';
7
11
 
8
12
  colors.enable();
9
13
 
10
14
  const INPUT_DIR = './input/';
11
15
 
12
- start();
13
-
14
- function start() {
15
- if(!file_exists(INPUT_DIR)){
16
- console.log(`There's no input folder. Please create input folder and put excel file to generate.`.red);
17
- return;
18
- }
19
- const files = fileName_in_folder(INPUT_DIR);
20
-
21
- if (!files || !files.length) {
22
- console.log(`No input files.`.red);
23
- return;
24
- }
25
-
26
- const now = dayjs().format('DD-ddd-YYYY HH:mm');
27
- console.log(`Process Generate DAC ${now}`.green);
16
+ start_generate_dac_for_new_table(INPUT_DIR);
28
17
 
29
- files.forEach((file, i) => {
30
- console.log(`Begin to process file ${file.name}`.yellow);
31
- DAC_Generate_From_XLSX(file.path);
32
- })
33
- }
18
+ // startProcess({inputFolder: INPUT_DIR});
@@ -0,0 +1 @@
1
+ export type CommandAction = 'table' | 'backend' | 'store';
@@ -1,16 +1,16 @@
1
1
  import * as uuid from 'uuid';
2
2
 
3
- export function str_ucfirst(str: string): string{
4
- if(!str) return str;
3
+ export function str_ucfirst(str: string): string {
4
+ if (!str) return str;
5
5
  str = str.toLowerCase();
6
6
  return str.charAt(0).toUpperCase() + str.slice(1);
7
7
  }
8
8
 
9
- export function str_uuid(firstKey?: string){
10
- if(!firstKey) {
9
+ export function str_uuid(firstKey?: string) {
10
+ if (!firstKey) {
11
11
  return uuid.v4();
12
12
  }
13
- else{
13
+ else {
14
14
  let str = uuid.v4();
15
15
 
16
16
  const ars = str.split('-');
@@ -20,12 +20,12 @@ export function str_uuid(firstKey?: string){
20
20
  }
21
21
  }
22
22
 
23
- export function str_guid(){
24
- return uuid.v4().replace(/-/g, '');
23
+ export function str_guid() {
24
+ return uuid.v4().replace(/-/g, '');
25
25
  }
26
26
 
27
- export function str_slug(str: string): string{
28
- if(!str) return '';
27
+ export function str_slug(str: string): string {
28
+ if (!str) return '';
29
29
 
30
30
  str = str.toLowerCase().trim();
31
31
  str = str.replace(/[ \.,\(\)\-\\\*]+/g, '_');
@@ -40,14 +40,14 @@ export function str_capitalize(str: string): string {
40
40
  return lowerCaseStr.replace(/(?:^|\s)\S/g, match => match.toUpperCase());
41
41
  }
42
42
 
43
- export function str_className(str: string): string{
43
+ export function str_className(str: string): string {
44
44
  return str_capitalize(str).replace(/[ \-_]+/ig, '');
45
45
  }
46
46
 
47
- export function str_upper_first_letter(str: string): string{
48
- if(!str) return '';
47
+ export function str_upper_first_letter(str: string): string {
48
+ if (!str) return '';
49
49
 
50
- if(str.length === 1){
50
+ if (str.length === 1) {
51
51
  return str.toUpperCase();
52
52
  }
53
53
 
@@ -58,18 +58,41 @@ export function str_insert(original: string, index: number, insertString: string
58
58
  return original.slice(0, index) + insertString + original.slice(index);
59
59
  }
60
60
 
61
- export function str_clean(str: any): string{
62
- if(!str) return str;
61
+ export function str_clean(str: any): string {
62
+ if (!str) return str;
63
63
 
64
- if(typeof str === 'string'){
64
+ if (typeof str === 'string') {
65
65
  return str.trim();
66
66
  }
67
67
 
68
68
  return str;
69
69
  }
70
70
 
71
- export function str_key(str: string): string{
72
- if(!str) return '';
71
+ export function str_key(str: string): string {
72
+ if (!str) return '';
73
73
 
74
74
  return str.trim().toLowerCase().replace(/\s+/gi, '_').replace(/[\.]/i, '');
75
+ }
76
+
77
+ export function str_plural(singularNoun: string): string {
78
+ if (!singularNoun) return '';
79
+
80
+ const exceptions: { [key: string]: string } = {
81
+ child: 'children',
82
+ };
83
+
84
+ // Check for irregular plurals
85
+ if (exceptions[singularNoun.toLowerCase()]) {
86
+ return exceptions[singularNoun];
87
+ }
88
+
89
+ // Check for common rules
90
+ const lastChar = singularNoun.slice(-1);
91
+ if (lastChar === 'y' && !['a', 'e', 'i', 'o', 'u'].includes(singularNoun.charAt(singularNoun.length - 2))) {
92
+ return singularNoun.slice(0, -1) + 'ies';
93
+ } else if (['s', 'x', 'z'].includes(lastChar) || (lastChar === 'h' && ['c', 's'].includes(singularNoun.charAt(singularNoun.length - 2)))) {
94
+ return singularNoun + 'es';
95
+ } else {
96
+ return singularNoun + 's';
97
+ }
75
98
  }
@@ -36,11 +36,11 @@ namespace XHS.DataAccess
36
36
 
37
37
  }
38
38
 
39
- public int Insert({Table_Name}s obj{Table_Name}s)
39
+ public int Insert({Table_Name_Plural} obj{Table_Name_Plural})
40
40
  {
41
41
  int intRowsAffected = 0;
42
42
 
43
- if (obj{Table_Name}s.Collection.Length == 0)
43
+ if (obj{Table_Name_Plural}.Collection.Length == 0)
44
44
  return 0;
45
45
 
46
46
  SqlTransaction dbTransaction = objDBConnection.BeginTransaction();
@@ -55,7 +55,7 @@ namespace XHS.DataAccess
55
55
  dbCommand.CommandText = "xhs_sp_ins_{table_name_lower}";
56
56
  dbCommand.Transaction = dbTransaction;
57
57
 
58
- for (int i = 0; i < obj{Table_Name}s.Collection.Length; i++)
58
+ for (int i = 0; i < obj{Table_Name_Plural}.Collection.Length; i++)
59
59
  {
60
60
  dbCommand.Parameters.Clear();
61
61
 
@@ -65,7 +65,7 @@ namespace XHS.DataAccess
65
65
 
66
66
  intRowsAffected += dbCommand.ExecuteNonQuery();
67
67
 
68
- obj{Table_Name}s.Collection[i].ID = Convert.ToInt32(dpIdentity.Value.ToString());
68
+ obj{Table_Name_Plural}.Collection[i].ID = Convert.ToInt32(dpIdentity.Value.ToString());
69
69
  }
70
70
 
71
71
  dbTransaction.Commit();
@@ -79,11 +79,11 @@ namespace XHS.DataAccess
79
79
  }
80
80
  }
81
81
 
82
- public int Update({Table_Name}s obj{Table_Name}s)
82
+ public int Update({Table_Name_Plural} obj{Table_Name_Plural})
83
83
  {
84
84
  int intRowsAffected = 0;
85
85
 
86
- if (obj{Table_Name}s.Collection.Length == 0)
86
+ if (obj{Table_Name_Plural}.Collection.Length == 0)
87
87
  return 0;
88
88
 
89
89
  SqlTransaction dbTransaction = objDBConnection.BeginTransaction();
@@ -98,7 +98,7 @@ namespace XHS.DataAccess
98
98
  dbCommand.CommandText = "xhs_sp_upd_{table_name_lower}";
99
99
  dbCommand.Transaction = dbTransaction;
100
100
 
101
- for (int i = 0; i < obj{Table_Name}s.Collection.Length; i++)
101
+ for (int i = 0; i < obj{Table_Name_Plural}.Collection.Length; i++)
102
102
  {
103
103
  dbCommand.Parameters.Clear();
104
104
 
@@ -120,11 +120,11 @@ namespace XHS.DataAccess
120
120
 
121
121
  }
122
122
 
123
- public int Delete({Table_Name}s obj{Table_Name}s)
123
+ public int Delete({Table_Name_Plural} obj{Table_Name_Plural})
124
124
  {
125
125
  int intRowsAffected = 0;
126
126
 
127
- if (obj{Table_Name}s.Collection.Length == 0)
127
+ if (obj{Table_Name_Plural}.Collection.Length == 0)
128
128
  return 0;
129
129
 
130
130
  SqlTransaction dbTransaction = objDBConnection.BeginTransaction();
@@ -139,11 +139,11 @@ namespace XHS.DataAccess
139
139
  dbCommand.CommandText = "xhs_sp_del_{table_name_lower}";
140
140
  dbCommand.Transaction = dbTransaction;
141
141
 
142
- for (int i = 0; i < obj{Table_Name}s.Collection.Length; i++)
142
+ for (int i = 0; i < obj{Table_Name_Plural}.Collection.Length; i++)
143
143
  {
144
144
  dbCommand.Parameters.Clear();
145
145
 
146
- CreateParameter(dbCommand, "@ID", SqlDbType.Int, obj{Table_Name}s.Collection[i].ID);
146
+ CreateParameter(dbCommand, "@ID", SqlDbType.Int, obj{Table_Name_Plural}.Collection[i].ID);
147
147
 
148
148
  intRowsAffected += dbCommand.ExecuteNonQuery();
149
149
  }
@@ -213,7 +213,7 @@ namespace XHS.DataAccess
213
213
  }
214
214
  }
215
215
 
216
- public int FindAll(ref {Table_Name}s obj{Table_Name}s)
216
+ public int FindAll(ref {Table_Name_Plural} obj{Table_Name_Plural})
217
217
  {
218
218
  int intRowsReturned = 0;
219
219
 
@@ -230,7 +230,7 @@ namespace XHS.DataAccess
230
230
 
231
231
  if (!objDataReader.HasRows)
232
232
  {
233
- obj{Table_Name}s.Collection = new {Table_Name}[0];
233
+ obj{Table_Name_Plural}.Collection = new {Table_Name}[0];
234
234
  objDataReader.Close();
235
235
  return 0;
236
236
  }
@@ -250,10 +250,10 @@ namespace XHS.DataAccess
250
250
 
251
251
  objDataReader.Close();
252
252
 
253
- obj{Table_Name}s.Collection = new {Table_Name}[al{Table_Name}.Count];
253
+ obj{Table_Name_Plural}.Collection = new {Table_Name}[al{Table_Name}.Count];
254
254
 
255
255
  for (int i = 0; i < al{Table_Name}.Count; i++)
256
- obj{Table_Name}s.Collection[i] = ({Table_Name})al{Table_Name}[i];
256
+ obj{Table_Name_Plural}.Collection[i] = ({Table_Name})al{Table_Name}[i];
257
257
 
258
258
  return intRowsReturned;
259
259
  }
@@ -1,4 +1,4 @@
1
- public class {table_name}s
1
+ public class {table_name_plural}
2
2
  {
3
3
  public {table_name}[] Collection { get; set; }
4
4
  }
@@ -1,5 +1,5 @@
1
1
  [Serializable]
2
- public class {class_name}s
2
+ public class {class_name_plural}
3
3
  {
4
4
  public {class_name}[] Collection;
5
5
  }
@@ -0,0 +1,33 @@
1
+ import {describe, expect, test} from '@jest/globals';
2
+ import { TestCase } from "./test-interface";
3
+ import { str_plural, str_slug } from "../src/utils/str-utils";
4
+
5
+
6
+ describe("StrUtilsTests", () => {
7
+ const testCaseStrPlurals: TestCase[] = [{
8
+ input: 'cat',
9
+ output: 'cats'
10
+ }, {
11
+ input: 'Hotel_Booking_Reservation_Status',
12
+ output: 'Hotel_Booking_Reservation_Statuses'
13
+ }, {
14
+ input: 'RPM_Reservation_Status',
15
+ output: 'RPM_Reservation_Statuses'
16
+ }, {
17
+ input: 'Hotel_Booking',
18
+ output: 'Hotel_Bookings'
19
+ }, {
20
+ input: 'HotelBookingReservationStatus',
21
+ output: 'HotelBookingReservationStatuses'
22
+ }, {
23
+ input: 'child',
24
+ output: 'children'
25
+ }];
26
+
27
+ testCaseStrPlurals.forEach((t, i) => {
28
+ test(`should return ${t.output} when input=${t.input}`, () => {
29
+ const result = str_plural(t.input);
30
+ expect(result).toBe(t.output);
31
+ });
32
+ })
33
+ });
@@ -0,0 +1,4 @@
1
+ export interface TestCase{
2
+ input: any,
3
+ output: any
4
+ }
package/tsconfig.json CHANGED
@@ -7,5 +7,8 @@
7
7
  "sourceMap": false,
8
8
  "outDir": "dist",
9
9
  "esModuleInterop": true
10
- }
10
+ },
11
+ "exclude": [
12
+ "tests"
13
+ ]
11
14
  }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var DAC_Utils_1 = require("./DAC_Utils");
7
- var dayjs_1 = __importDefault(require("dayjs"));
8
- var path = "./input/Apply_To_Approve_Steps_Schema.xlsx";
9
- var now = (0, dayjs_1.default)().format('DD-ddd-YYYY HH:mm');
10
- console.log("Process Generate DAC ".concat(now).green);
11
- (0, DAC_Utils_1.DAC_Generate_From_XLSX)(path);