tspace-mysql 1.1.3 → 1.1.4

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.
package/dist/cli/index.js CHANGED
@@ -3,36 +3,37 @@
3
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
6
7
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const fs_1 = __importDefault(require("fs"));
8
- const make_1 = __importDefault(require("./models/make"));
9
- const make_2 = __importDefault(require("./tables/make"));
10
- const make_3 = __importDefault(require("./migrate/make"));
11
- const commands = {
8
+ var fs_1 = __importDefault(require("fs"));
9
+ var make_1 = __importDefault(require("./models/make"));
10
+ var make_2 = __importDefault(require("./tables/make"));
11
+ var make_3 = __importDefault(require("./migrate/make"));
12
+ var commands = {
12
13
  'make:model': make_1.default,
13
14
  'make:table': make_2.default,
14
15
  'make:migration': make_2.default,
15
16
  'migrate': make_3.default
16
17
  };
17
18
  try {
18
- const name = process.argv.slice(2)?.find(data => {
19
- return data?.includes('--name=');
20
- })?.replace('--name=', '') ?? null;
21
- const migrate = process.argv.slice(2)?.includes('--m') ?? false;
22
- const dir = process.argv.slice(2)?.find(data => {
23
- return data?.includes('--dir=');
24
- })?.replace('--dir=', '/') ?? null;
25
- let type = process.argv.slice(2)?.find(data => {
26
- return data?.includes('--type=');
27
- })?.replace('--type=', '.') ?? '.ts';
19
+ var name = (_c = (_b = (_a = process.argv.slice(2)) === null || _a === void 0 ? void 0 : _a.find(function (data) {
20
+ return data === null || data === void 0 ? void 0 : data.includes('--name=');
21
+ })) === null || _b === void 0 ? void 0 : _b.replace('--name=', '')) !== null && _c !== void 0 ? _c : null;
22
+ var migrate = (_e = (_d = process.argv.slice(2)) === null || _d === void 0 ? void 0 : _d.includes('--m')) !== null && _e !== void 0 ? _e : false;
23
+ var dir = (_h = (_g = (_f = process.argv.slice(2)) === null || _f === void 0 ? void 0 : _f.find(function (data) {
24
+ return data === null || data === void 0 ? void 0 : data.includes('--dir=');
25
+ })) === null || _g === void 0 ? void 0 : _g.replace('--dir=', '/')) !== null && _h !== void 0 ? _h : null;
26
+ var type = (_l = (_k = (_j = process.argv.slice(2)) === null || _j === void 0 ? void 0 : _j.find(function (data) {
27
+ return data === null || data === void 0 ? void 0 : data.includes('--type=');
28
+ })) === null || _k === void 0 ? void 0 : _k.replace('--type=', '.')) !== null && _l !== void 0 ? _l : '.ts';
28
29
  type = ['.js', '.ts'].includes(type) ? type : '.ts';
29
- const file = process.argv.slice(3)?.shift() ?? '';
30
- const cmd = {
31
- name,
32
- file,
33
- dir,
34
- migrate,
35
- type,
30
+ var file = (_o = (_m = process.argv.slice(3)) === null || _m === void 0 ? void 0 : _m.shift()) !== null && _o !== void 0 ? _o : '';
31
+ var cmd = {
32
+ name: name,
33
+ file: file,
34
+ dir: dir,
35
+ migrate: migrate,
36
+ type: type,
36
37
  cwd: process.cwd(),
37
38
  fs: fs_1.default,
38
39
  npm: 'tspace-mysql'
@@ -40,5 +41,5 @@ try {
40
41
  commands[process.argv[2]](cmd);
41
42
  }
42
43
  catch (err) {
43
- console.log(`readme https://www.npmjs.com/package/tspace-mysql`);
44
+ console.log("readme https://www.npmjs.com/package/tspace-mysql");
44
45
  }
@@ -1,29 +1,52 @@
1
1
  "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const child_process_1 = require("child_process");
4
- exports.default = (formCommand) => {
5
- const { type, dir, cwd, fs } = formCommand;
14
+ var child_process_1 = require("child_process");
15
+ exports.default = (function (formCommand) {
16
+ var e_1, _a;
17
+ var _b, _c, _d;
18
+ var type = formCommand.type, dir = formCommand.dir, cwd = formCommand.cwd, fs = formCommand.fs;
6
19
  try {
7
20
  if (dir == null)
8
21
  throw new Error('Not found directory');
9
- const path = `${cwd}/${dir}`;
10
- const files = fs.readdirSync(path) ?? [];
11
- if (!files?.length)
22
+ var path = "".concat(cwd, "/").concat(dir);
23
+ var files = (_b = fs.readdirSync(path)) !== null && _b !== void 0 ? _b : [];
24
+ if (!(files === null || files === void 0 ? void 0 : files.length))
12
25
  console.log('this folder is empty');
13
- const cmd = type === '.js' ? 'node' : 'ts-node';
14
- for (const _file of files) {
15
- const run = (0, child_process_1.exec)(`${cmd} ${path}/${_file}`);
16
- run?.stdout?.on('data', (data) => {
17
- if (data)
18
- console.log(data);
19
- });
20
- run?.stderr?.on('data', (err) => {
21
- if (err)
22
- console.error(err);
23
- });
26
+ var cmd = type === '.js' ? 'node' : 'ts-node';
27
+ try {
28
+ for (var files_1 = __values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) {
29
+ var _file = files_1_1.value;
30
+ var run = (0, child_process_1.exec)("".concat(cmd, " ").concat(path, "/").concat(_file));
31
+ (_c = run === null || run === void 0 ? void 0 : run.stdout) === null || _c === void 0 ? void 0 : _c.on('data', function (data) {
32
+ if (data)
33
+ console.log(data);
34
+ });
35
+ (_d = run === null || run === void 0 ? void 0 : run.stderr) === null || _d === void 0 ? void 0 : _d.on('data', function (err) {
36
+ if (err)
37
+ console.error(err);
38
+ });
39
+ }
40
+ }
41
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
42
+ finally {
43
+ try {
44
+ if (files_1_1 && !files_1_1.done && (_a = files_1.return)) _a.call(files_1);
45
+ }
46
+ finally { if (e_1) throw e_1.error; }
24
47
  }
25
48
  }
26
49
  catch (err) {
27
50
  console.log(err.message);
28
51
  }
29
- };
52
+ });
@@ -3,33 +3,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const model_1 = __importDefault(require("./model"));
7
- const table_1 = __importDefault(require("../tables/table"));
8
- const pluralize_1 = __importDefault(require("pluralize"));
9
- exports.default = (formCommand) => {
10
- const { file, migrate, dir, type, cwd, fs, npm } = formCommand;
6
+ var model_1 = __importDefault(require("./model"));
7
+ var table_1 = __importDefault(require("../tables/table"));
8
+ var pluralize_1 = __importDefault(require("pluralize"));
9
+ exports.default = (function (formCommand) {
10
+ var file = formCommand.file, migrate = formCommand.migrate, dir = formCommand.dir, type = formCommand.type, cwd = formCommand.cwd, fs = formCommand.fs, npm = formCommand.npm;
11
11
  if (dir) {
12
12
  try {
13
- fs.accessSync(cwd + `/${dir}`, fs.F_OK, {
13
+ fs.accessSync(cwd + "/".concat(dir), fs.F_OK, {
14
14
  recursive: true
15
15
  });
16
16
  }
17
17
  catch (e) {
18
- fs.mkdirSync(cwd + `/${dir}`, {
18
+ fs.mkdirSync(cwd + "/".concat(dir), {
19
19
  recursive: true
20
20
  });
21
21
  }
22
22
  }
23
- const model = dir ? `${cwd}/${dir}/${file}${type}` : `${cwd}/${file}${type}`;
24
- const data = (0, model_1.default)(file, npm);
25
- fs.writeFile(model, data, (err) => {
23
+ var model = dir ? "".concat(cwd, "/").concat(dir, "/").concat(file).concat(type) : "".concat(cwd, "/").concat(file).concat(type);
24
+ var data = (0, model_1.default)(file, npm);
25
+ fs.writeFile(model, data, function (err) {
26
26
  if (err)
27
27
  throw err.message;
28
28
  });
29
- console.log(`Model : '${file}' created successfully`);
29
+ console.log("Model : '".concat(file, "' created successfully"));
30
30
  if (migrate) {
31
- const tableName = (0, pluralize_1.default)(file.replace(/([A-Z])/g, (str) => '_' + str.toLowerCase()).slice(1));
32
- const folder = dir ? `${dir}/Migrations` : `/Migrations`;
31
+ var tableName = (0, pluralize_1.default)(file.replace(/([A-Z])/g, function (str) { return '_' + str.toLowerCase(); }).slice(1));
32
+ var folder = dir ? "".concat(dir, "/Migrations") : "/Migrations";
33
33
  try {
34
34
  fs.accessSync(cwd + folder, fs.F_OK, {
35
35
  recursive: true
@@ -40,12 +40,12 @@ exports.default = (formCommand) => {
40
40
  recursive: true
41
41
  });
42
42
  }
43
- const folderMigrate = `${cwd}/${folder}/create_${tableName}_table${type}`;
44
- const table = (0, table_1.default)(tableName, npm);
45
- fs.writeFile(folderMigrate, table, (err) => {
43
+ var folderMigrate = "".concat(cwd, "/").concat(folder, "/create_").concat(tableName, "_table").concat(type);
44
+ var table = (0, table_1.default)(tableName, npm);
45
+ fs.writeFile(folderMigrate, table, function (err) {
46
46
  if (err)
47
47
  throw err;
48
48
  });
49
- console.log(`Migration : '${tableName}' created successfully`);
49
+ console.log("Migration : '".concat(tableName, "' created successfully"));
50
50
  }
51
- };
51
+ });
@@ -1,31 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Model = (model, npm) => {
4
- return `import { Model } from '${npm}'
5
- class ${model} extends Model {
6
- constructor(){
7
- super()
8
- /**
9
- *
10
- * Assign setting global in your model
11
- * @useMethod
12
- *
13
- * this.useDebug() // => runing a uuid (universally unique identifier) when insert new data
14
- * this.usePrimaryKey('id') // => runing a uuid (universally unique identifier) when insert new data
15
- * this.useTimestamp({ createdAt : 'created_at' , updatedAt : 'updated_at' }) // runing a timestamp when insert or update
16
- * this.useSoftDelete()
17
- * this.useDisableSoftDeleteInRelations()
18
- * this.useTable('Users')
19
- * this.useTableSingular()
20
- * this.useTablePlural()
21
- * this.usePattern('snake_case')
22
- * this.useUUID('uuid')
23
- * this.useRegistry()
24
- */
25
- }
26
- }
27
- export { ${model} }
28
- export default ${model}
29
- `;
3
+ var Model = function (model, npm) {
4
+ return "import { Model } from '".concat(npm, "'\nclass ").concat(model, " extends Model {\n constructor(){\n super()\n /**\n * \n * Assign setting global in your model\n * @useMethod\n *\n * this.useDebug() // => runing a uuid (universally unique identifier) when insert new data\n * this.usePrimaryKey('id') // => runing a uuid (universally unique identifier) when insert new data\n * this.useTimestamp({ createdAt : 'created_at' , updatedAt : 'updated_at' }) // runing a timestamp when insert or update\n * this.useSoftDelete()\n * this.useDisableSoftDeleteInRelations()\n * this.useTable('Users')\n * this.useTableSingular()\n * this.useTablePlural()\n * this.usePattern('snake_case') \n * this.useUUID('uuid')\n * this.useRegistry()\n */\n }\n}\nexport { ").concat(model, " }\nexport default ").concat(model, "\n");
30
5
  };
31
6
  exports.default = Model;
@@ -3,24 +3,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const table_1 = __importDefault(require("./table"));
7
- exports.default = (formCommand) => {
8
- const { file, type, cwd, dir, fs, npm } = formCommand;
6
+ var table_1 = __importDefault(require("./table"));
7
+ exports.default = (function (formCommand) {
8
+ var file = formCommand.file, type = formCommand.type, cwd = formCommand.cwd, dir = formCommand.dir, fs = formCommand.fs, npm = formCommand.npm;
9
9
  try {
10
- fs.accessSync(cwd + `/${file}`, fs.F_OK, {
10
+ fs.accessSync(cwd + "/".concat(file), fs.F_OK, {
11
11
  recursive: true
12
12
  });
13
13
  }
14
14
  catch (e) {
15
- fs.mkdirSync(cwd + `/${file}`, {
15
+ fs.mkdirSync(cwd + "/".concat(file), {
16
16
  recursive: true
17
17
  });
18
18
  }
19
- const folderMigrate = dir ? `${cwd}/${dir}/create_${file}_table${type}` : `${cwd}/create_${file}_table${type}`;
20
- const table = (0, table_1.default)(file, npm);
21
- fs.writeFile(folderMigrate, table, (err) => {
19
+ var folderMigrate = dir ? "".concat(cwd, "/").concat(dir, "/create_").concat(file, "_table").concat(type) : "".concat(cwd, "/create_").concat(file, "_table").concat(type);
20
+ var table = (0, table_1.default)(file, npm);
21
+ fs.writeFile(folderMigrate, table, function (err) {
22
22
  if (err)
23
23
  console.log(err.message);
24
24
  });
25
- console.log(`Migration : ${file} created successfully`);
26
- };
25
+ console.log("Migration : ".concat(file, " created successfully"));
26
+ });
@@ -1,26 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Table = (table, npm) => {
4
- return `import { Schema , Blueprint , DB } from '${npm}'
5
- (async () => {
6
- await new Schema().table('${table}',{
7
- id : new Blueprint().int().notNull().primary().autoIncrement(),
8
- uuid : new Blueprint().varchar(50),
9
- name : new Blueprint().varchar(120).default('my name'),
10
- email : new Blueprint().varchar(120).unique(),
11
- email_verify : new Blueprint().tinyInt(),
12
- password : new Blueprint().varchar(120),
13
- birthdate : new Blueprint().date(),
14
- created_at : new Blueprint().null().timestamp(),
15
- updated_at : new Blueprint().null().timestamp()
16
- })
17
-
18
- /**
19
- *
20
- * @Faker data
21
- * await new DB().table('${table}').faker(5)
22
- */
23
- })()
24
- `;
3
+ var Table = function (table, npm) {
4
+ return "import { Schema , Blueprint , DB } from '".concat(npm, "'\n(async () => {\n await new Schema().table('").concat(table, "',{ \n id : new Blueprint().int().notNull().primary().autoIncrement(),\n uuid : new Blueprint().varchar(50),\n name : new Blueprint().varchar(120).default('my name'),\n email : new Blueprint().varchar(120).unique(),\n email_verify : new Blueprint().tinyInt(),\n password : new Blueprint().varchar(120),\n birthdate : new Blueprint().date(),\n created_at : new Blueprint().null().timestamp(),\n updated_at : new Blueprint().null().timestamp()\n })\n\n /**\n * \n * @Faker data\n * await new DB().table('").concat(table, "').faker(5)\n */\n})()\n");
25
5
  };
26
6
  exports.default = Table;
@@ -4,13 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.env = void 0;
7
- const dotenv_1 = __importDefault(require("dotenv"));
8
- const path_1 = __importDefault(require("path"));
9
- const fs_1 = __importDefault(require("fs"));
10
- const environment = () => {
11
- const NODE_ENV = process.env?.NODE_ENV;
12
- const envWithoutEnviroment = path_1.default.join(path_1.default.resolve(), '.env');
13
- const envWithEnviroment = path_1.default.join(path_1.default.resolve(), `.env.${NODE_ENV}`);
7
+ var dotenv_1 = __importDefault(require("dotenv"));
8
+ var path_1 = __importDefault(require("path"));
9
+ var fs_1 = __importDefault(require("fs"));
10
+ var environment = function () {
11
+ var _a;
12
+ var NODE_ENV = (_a = process.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV;
13
+ var envWithoutEnviroment = path_1.default.join(path_1.default.resolve(), '.env');
14
+ var envWithEnviroment = path_1.default.join(path_1.default.resolve(), ".env.".concat(NODE_ENV));
14
15
  if (NODE_ENV == null)
15
16
  return envWithoutEnviroment;
16
17
  if (fs_1.default.existsSync(envWithEnviroment))
@@ -18,7 +19,7 @@ const environment = () => {
18
19
  return envWithoutEnviroment;
19
20
  };
20
21
  dotenv_1.default.config({ path: environment() });
21
- const env = Object.freeze({
22
+ var env = Object.freeze({
22
23
  DB_HOST: process.env.DB_HOST,
23
24
  DB_PORT: process.env.DB_PORT,
24
25
  DB_USERNAME: process.env.DB_USERNAME,
@@ -1,21 +1,29 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
17
  exports.Pool = exports.PoolConnection = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const env_1 = require("../config/env");
10
- const mysql_1 = require("mysql");
11
- class PoolConnection {
12
- OPTIONS = this._getJsonOptions();
13
- constructor(options) {
18
+ var fs_1 = __importDefault(require("fs"));
19
+ var path_1 = __importDefault(require("path"));
20
+ var env_1 = require("../config/env");
21
+ var mysql_1 = require("mysql");
22
+ var PoolConnection = /** @class */ (function () {
23
+ function PoolConnection(options) {
24
+ this.OPTIONS = this._getJsonOptions();
14
25
  if (options) {
15
- this.OPTIONS = new Map(Object.entries({
16
- ...Object.fromEntries(this.OPTIONS),
17
- ...JSON.parse(JSON.stringify(options))
18
- }));
26
+ this.OPTIONS = new Map(Object.entries(__assign(__assign({}, Object.fromEntries(this.OPTIONS)), JSON.parse(JSON.stringify(options)))));
19
27
  }
20
28
  }
21
29
  /**
@@ -23,22 +31,23 @@ class PoolConnection {
23
31
  * Set a options connection pool
24
32
  * @return {this} this
25
33
  */
26
- options(options) {
34
+ PoolConnection.prototype.options = function (options) {
27
35
  this.OPTIONS = new Map(Object.entries(options));
28
36
  return this;
29
- }
37
+ };
30
38
  /**
31
39
  *
32
40
  * Get a connection pool
33
41
  * @return {Connection} Connection
34
42
  */
35
- connection() {
36
- const pool = (0, mysql_1.createPool)(Object.fromEntries(this.OPTIONS));
37
- pool.getConnection((err, connection) => {
43
+ PoolConnection.prototype.connection = function () {
44
+ var _this = this;
45
+ var pool = (0, mysql_1.createPool)(Object.fromEntries(this.OPTIONS));
46
+ pool.getConnection(function (err, connection) {
38
47
  if (err) {
39
- const message = this._messageError.bind(this);
40
- process.nextTick(() => {
41
- console.log(message());
48
+ var message_1 = _this._messageError.bind(_this);
49
+ process.nextTick(function () {
50
+ console.log(message_1());
42
51
  return process.exit();
43
52
  });
44
53
  }
@@ -46,44 +55,45 @@ class PoolConnection {
46
55
  connection.release();
47
56
  });
48
57
  return {
49
- query: (sql) => {
50
- return new Promise((resolve, reject) => {
51
- pool.query(sql, (err, results) => {
58
+ query: function (sql) {
59
+ return new Promise(function (resolve, reject) {
60
+ pool.query(sql, function (err, results) {
52
61
  if (err)
53
62
  return reject(err);
54
63
  return resolve(results);
55
64
  });
56
65
  });
57
66
  },
58
- connection: () => {
59
- return new Promise((resolve, reject) => {
60
- pool.getConnection((err, connection) => {
67
+ connection: function () {
68
+ return new Promise(function (resolve, reject) {
69
+ pool.getConnection(function (err, connection) {
61
70
  if (err)
62
71
  return reject(err);
63
- const query = (sql) => {
64
- return new Promise((resolve, reject) => {
65
- connection.query(sql, (err, result) => {
72
+ var query = function (sql) {
73
+ return new Promise(function (resolve, reject) {
74
+ connection.query(sql, function (err, result) {
66
75
  if (err)
67
76
  return reject(err);
68
77
  return resolve(result);
69
78
  });
70
79
  });
71
80
  };
72
- const startTransaction = () => query('START TRANSACTION');
73
- const commit = () => query('COMMIT');
74
- const rollback = () => query('ROLLBACK');
81
+ var startTransaction = function () { return query('START TRANSACTION'); };
82
+ var commit = function () { return query('COMMIT'); };
83
+ var rollback = function () { return query('ROLLBACK'); };
75
84
  return resolve({
76
- query,
77
- startTransaction,
78
- commit,
79
- rollback
85
+ query: query,
86
+ startTransaction: startTransaction,
87
+ commit: commit,
88
+ rollback: rollback
80
89
  });
81
90
  });
82
91
  });
83
92
  }
84
93
  };
85
- }
86
- _defaultOptions() {
94
+ };
95
+ PoolConnection.prototype._defaultOptions = function () {
96
+ var _a, _b, _c, _d, _e, _f;
87
97
  return new Map(Object.entries({
88
98
  connectionLimit: 10,
89
99
  dateStrings: true,
@@ -91,22 +101,22 @@ class PoolConnection {
91
101
  acquireTimeout: 1000 * 30,
92
102
  waitForConnections: false,
93
103
  charset: 'utf8mb4',
94
- host: String(env_1.env.DB_HOST ?? env_1.env.TSPACE_MYSQL_HOST),
95
- port: Number.isNaN(Number(env_1.env.DB_PORT ?? env_1.env.TSPACE_MYSQL_PORT))
104
+ host: String((_a = env_1.env.DB_HOST) !== null && _a !== void 0 ? _a : env_1.env.TSPACE_MYSQL_HOST),
105
+ port: Number.isNaN(Number((_b = env_1.env.DB_PORT) !== null && _b !== void 0 ? _b : env_1.env.TSPACE_MYSQL_PORT))
96
106
  ? 3306
97
- : Number(env_1.env.DB_PORT ?? env_1.env.TSPACE_MYSQL_PORT),
98
- database: String(env_1.env.DB_DATABASE ?? env_1.env.TSPACE_MYSQL_DATABASE),
99
- user: String(env_1.env.DB_USERNAME ?? env_1.env.TSPACE_MYSQL_USERNAME),
100
- password: String(env_1.env.DB_PASSWORD ?? env_1.env.TSPACE_MYSQL_PASSWORD)
107
+ : Number((_c = env_1.env.DB_PORT) !== null && _c !== void 0 ? _c : env_1.env.TSPACE_MYSQL_PORT),
108
+ database: String((_d = env_1.env.DB_DATABASE) !== null && _d !== void 0 ? _d : env_1.env.TSPACE_MYSQL_DATABASE),
109
+ user: String((_e = env_1.env.DB_USERNAME) !== null && _e !== void 0 ? _e : env_1.env.TSPACE_MYSQL_USERNAME),
110
+ password: String((_f = env_1.env.DB_PASSWORD) !== null && _f !== void 0 ? _f : env_1.env.TSPACE_MYSQL_PASSWORD)
101
111
  }));
102
- }
103
- _getJsonOptions() {
112
+ };
113
+ PoolConnection.prototype._getJsonOptions = function () {
104
114
  try {
105
- const jsonPath = path_1.default.join(path_1.default.resolve(), 'tspace-mysql.json');
106
- const jsonOptionsExists = fs_1.default.existsSync(jsonPath);
115
+ var jsonPath = path_1.default.join(path_1.default.resolve(), 'tspace-mysql.json');
116
+ var jsonOptionsExists = fs_1.default.existsSync(jsonPath);
107
117
  if (jsonOptionsExists) {
108
- const jsonOptions = fs_1.default.readFileSync(jsonPath, 'utf8');
109
- const options = JSON.parse(jsonOptions);
118
+ var jsonOptions = fs_1.default.readFileSync(jsonPath, 'utf8');
119
+ var options = JSON.parse(jsonOptions);
110
120
  return new Map(Object.entries(options));
111
121
  }
112
122
  return this._defaultOptions();
@@ -114,22 +124,13 @@ class PoolConnection {
114
124
  catch (e) {
115
125
  return this._defaultOptions();
116
126
  }
117
- }
118
- _messageError() {
119
- return `
120
- \x1b[1m\x1b[31m
121
- Connection lost to database ! \x1b[0m
122
- --------------------------------- \x1b[33m
123
- DB_HOST : ${this.OPTIONS.get('host')}
124
- DB_PORT : ${this.OPTIONS.get('port')}
125
- DB_DATABASE : ${this.OPTIONS.get('database')}
126
- DB_USERNAME : ${this.OPTIONS.get('user')}
127
- DB_PASSWORD : ${this.OPTIONS.get('password')} \x1b[0m
128
- ---------------------------------
129
- `;
130
- }
131
- }
127
+ };
128
+ PoolConnection.prototype._messageError = function () {
129
+ return "\n \u001B[1m\u001B[31m\n Connection lost to database ! \u001B[0m\n --------------------------------- \u001B[33m\n DB_HOST : ".concat(this.OPTIONS.get('host'), " \n DB_PORT : ").concat(this.OPTIONS.get('port'), " \n DB_DATABASE : ").concat(this.OPTIONS.get('database'), " \n DB_USERNAME : ").concat(this.OPTIONS.get('user'), " \n DB_PASSWORD : ").concat(this.OPTIONS.get('password'), " \u001B[0m \n ---------------------------------\n ");
130
+ };
131
+ return PoolConnection;
132
+ }());
132
133
  exports.PoolConnection = PoolConnection;
133
- const Pool = new PoolConnection().connection();
134
+ var Pool = new PoolConnection().connection();
134
135
  exports.Pool = Pool;
135
136
  exports.default = Pool;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const constant = {
3
+ var constant = {
4
4
  ID: 'ID',
5
5
  SHOW: 'SHOW',
6
6
  FIELDS: 'FIELDS',
@@ -43,9 +43,11 @@ const constant = {
43
43
  NOT: 'NOT',
44
44
  DUPLICATE: 'DUPLICATE',
45
45
  KEY: 'KEY',
46
+ RAW: 'RAW',
46
47
  WHEN: 'WHEN',
47
48
  THEN: 'THEN',
48
49
  ELSE: 'ELSE',
50
+ CASE: 'CASE',
49
51
  END: 'END',
50
52
  WHERE_NOT_EXISTS: 'WHERE NOT EXISTS',
51
53
  EXISTS: 'EXISTS',
@@ -71,10 +73,7 @@ const constant = {
71
73
  camelCase: 'camelCase'
72
74
  },
73
75
  DB: {
74
- TRANSACTION: { query: [{
75
- table: '',
76
- id: ''
77
- }] },
76
+ PRIMARY_KEY: 'id',
78
77
  RESULT: null,
79
78
  DISTINCT: '',
80
79
  PLUCK: '',
package/dist/lib/index.js CHANGED
@@ -31,6 +31,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
31
31
  *
32
32
  * @module tspace-mysql
33
33
  */
34
- const tspace = __importStar(require("./tspace"));
34
+ var tspace = __importStar(require("./tspace"));
35
35
  __exportStar(require("./tspace"), exports);
36
36
  exports.default = tspace;
@@ -1,11 +1,31 @@
1
1
  "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
2
17
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
19
  };
5
20
  Object.defineProperty(exports, "__esModule", { value: true });
6
21
  exports.AbstractDB = void 0;
7
- const Database_1 = __importDefault(require("./Database"));
8
- class AbstractDB extends Database_1.default {
9
- }
22
+ var Database_1 = __importDefault(require("./Database"));
23
+ var AbstractDB = /** @class */ (function (_super) {
24
+ __extends(AbstractDB, _super);
25
+ function AbstractDB() {
26
+ return _super !== null && _super.apply(this, arguments) || this;
27
+ }
28
+ return AbstractDB;
29
+ }(Database_1.default));
10
30
  exports.AbstractDB = AbstractDB;
11
31
  exports.default = AbstractDB;