ztechno_core 0.0.4 → 0.0.5

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.
@@ -1,7 +1,8 @@
1
1
  import * as mysql from 'mysql';
2
2
  export declare class ZSqlService {
3
- static init(credentials: mysql.ConnectionConfig): void;
3
+ private credentials;
4
+ constructor(credentials: mysql.ConnectionConfig);
4
5
  connect(): Promise<mysql.Connection>;
5
6
  query(sql: string, escaped?: any[]): Promise<any>;
6
- static get(): ZSqlService;
7
+ static get(credentials?: mysql.ConnectionConfig): ZSqlService;
7
8
  }
@@ -169,15 +169,14 @@ var instance = null;
169
169
  var logError = function (err) {
170
170
  if (err) throw err;
171
171
  };
172
- var creds;
173
172
  var ZSqlService = /** @class */ (function () {
174
- function ZSqlService() {}
175
- ZSqlService.init = function (credentials) {
176
- creds = credentials;
177
- };
173
+ function ZSqlService(credentials) {
174
+ this.credentials = credentials;
175
+ }
178
176
  ZSqlService.prototype.connect = function () {
177
+ var _this = this;
179
178
  return new Promise(function (resolve, reject) {
180
- var con = mysql.createConnection(creds);
179
+ var con = mysql.createConnection(_this.credentials);
181
180
  con.connect(function (err) {
182
181
  if (err) return reject(err);
183
182
  resolve(con);
@@ -213,9 +212,9 @@ var ZSqlService = /** @class */ (function () {
213
212
  });
214
213
  });
215
214
  };
216
- ZSqlService.get = function () {
215
+ ZSqlService.get = function (credentials) {
217
216
  if (instance == null) {
218
- instance = new ZSqlService();
217
+ instance = new ZSqlService(credentials);
219
218
  }
220
219
  return instance;
221
220
  };
@@ -138,15 +138,15 @@ var ZTranslateService = /** @class */ (function () {
138
138
  this.surpressErrors = true;
139
139
  this.codes =
140
140
  ((_a = {}),
141
- (_a['&#39;'] = "'"),
142
- (_a['&#34;'] = '"'),
143
- (_a['&#8220;'] = '\u201C'),
144
- (_a['&#8221;'] = '\u201D'),
145
- (_a['&#169;'] = '\u00A9'),
146
- (_a['&#174;'] = '\u00AE'),
147
- (_a['&#8364;'] = '\u20AC'),
148
- (_a['&#163;'] = '\u00A3'),
149
- (_a['&#8482;'] = '\u2122'),
141
+ (_a['&#39'] = "'"),
142
+ (_a['&#34'] = '"'),
143
+ (_a['&#8220'] = '\u201C'),
144
+ (_a['&#8221'] = '\u201D'),
145
+ (_a['&#169'] = '\u00A9'),
146
+ (_a['&#174'] = '\u00AE'),
147
+ (_a['&#8364'] = '\u20AC'),
148
+ (_a['&#163'] = '\u00A3'),
149
+ (_a['&#8482'] = '\u2122'),
150
150
  _a);
151
151
  this.getLanguages().map(function (lang) {
152
152
  return (_this.localCache[lang] = {});
@@ -191,7 +191,7 @@ var ZTranslateService = /** @class */ (function () {
191
191
  while (text.includes('&#')) {
192
192
  codeIndexStart = text.indexOf('&#');
193
193
  first = text.substring(codeIndexStart);
194
- codeLength = first.indexOf(';') + 1;
194
+ codeLength = first.indexOf('') + 1;
195
195
  code = first.substring(0, codeLength);
196
196
  if (this.codes[code] === undefined) {
197
197
  throw new Error('Cant recognize character code="'.concat(code, '"\n for text=').concat(text, '\n\n'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztechno_core",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Core files for ztechno framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",