ztechno_core 0.0.111 → 0.0.112

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 (39) hide show
  1. package/package.json +1 -1
  2. package/lib/crypto_service.d.ts +0 -23
  3. package/lib/crypto_service.js +0 -100
  4. package/lib/engine_base.d.ts +0 -11
  5. package/lib/engine_base.js +0 -9
  6. package/lib/express.d.ts +0 -1
  7. package/lib/express.js +0 -18
  8. package/lib/mail_service.d.ts +0 -85
  9. package/lib/mail_service.js +0 -156
  10. package/lib/orm/mail_blacklist_orm.d.ts +0 -22
  11. package/lib/orm/mail_blacklist_orm.js +0 -79
  12. package/lib/orm/orm.d.ts +0 -8
  13. package/lib/orm/orm.js +0 -26
  14. package/lib/scripts/docker-build.d.ts +0 -14
  15. package/lib/scripts/docker-build.js +0 -91
  16. package/lib/scripts/docker-publish.d.ts +0 -19
  17. package/lib/scripts/docker-publish.js +0 -114
  18. package/lib/scripts/docker-push.d.ts +0 -8
  19. package/lib/scripts/docker-push.js +0 -87
  20. package/lib/scripts/docker-update.d.ts +0 -27
  21. package/lib/scripts/docker-update.js +0 -207
  22. package/lib/scripts/encrypt.d.ts +0 -1
  23. package/lib/scripts/encrypt.js +0 -4
  24. package/lib/sql_service.d.ts +0 -123
  25. package/lib/sql_service.js +0 -234
  26. package/lib/translate_service.d.ts +0 -48
  27. package/lib/translate_service.js +0 -908
  28. package/lib/typings/crypto_types.d.ts +0 -4
  29. package/lib/typings/crypto_types.js +0 -2
  30. package/lib/typings/index.d.ts +0 -4
  31. package/lib/typings/index.js +0 -36
  32. package/lib/typings/mail_types.d.ts +0 -95
  33. package/lib/typings/mail_types.js +0 -2
  34. package/lib/typings/translate_types.d.ts +0 -69
  35. package/lib/typings/translate_types.js +0 -46
  36. package/lib/typings/user_types.d.ts +0 -41
  37. package/lib/typings/user_types.js +0 -2
  38. package/lib/user_service.d.ts +0 -80
  39. package/lib/user_service.js +0 -216
@@ -1,234 +0,0 @@
1
- 'use strict';
2
- var __createBinding =
3
- (this && this.__createBinding) ||
4
- (Object.create
5
- ? function (o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = {
10
- enumerable: true,
11
- get: function () {
12
- return m[k];
13
- },
14
- };
15
- }
16
- Object.defineProperty(o, k2, desc);
17
- }
18
- : function (o, m, k, k2) {
19
- if (k2 === undefined) k2 = k;
20
- o[k2] = m[k];
21
- });
22
- var __setModuleDefault =
23
- (this && this.__setModuleDefault) ||
24
- (Object.create
25
- ? function (o, v) {
26
- Object.defineProperty(o, 'default', { enumerable: true, value: v });
27
- }
28
- : function (o, v) {
29
- o['default'] = v;
30
- });
31
- var __importStar =
32
- (this && this.__importStar) ||
33
- function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null)
37
- for (var k in mod)
38
- if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
39
- __setModuleDefault(result, mod);
40
- return result;
41
- };
42
- Object.defineProperty(exports, '__esModule', { value: true });
43
- exports.ZSQLService = void 0;
44
- const mysql = __importStar(require('mysql'));
45
- class ZSQLService {
46
- get database() {
47
- return this.databaseName;
48
- }
49
- /**
50
- * Creates a new ZSQLService instance with a MySQL connection pool.
51
- * @param options - MySQL pool configuration options including custom dateStringTimezone and parseBooleans settings
52
- */
53
- constructor(options) {
54
- this.options = options;
55
- this.defaultPoolconfig = {
56
- connectionLimit: 10,
57
- timeout: 20000,
58
- connectTimeout: 20000,
59
- acquireTimeout: 20000,
60
- };
61
- this.listeners = { err: [], log: [] };
62
- this.databaseName = options.database;
63
- this.pool = mysql.createPool(Object.assign({}, this.defaultPoolconfig, options));
64
- this.pool.on('connection', (connection) => {
65
- // connection.config.queryFormat = function (query, values) {
66
- // }
67
- connection.on('error', (err) => {
68
- this.triggerEvent('err', err);
69
- });
70
- connection.on('close', (err) => {
71
- this.triggerEvent('err', err);
72
- });
73
- });
74
- }
75
- on(eventName, listener) {
76
- if (!this.listeners.hasOwnProperty(eventName))
77
- throw new Error(`EventName not supported for ZSqlService.on(${eventName}, ...)`);
78
- this.listeners[eventName].push(listener);
79
- }
80
- triggerEvent(eventName, args) {
81
- this.listeners[eventName].map((listener) => {
82
- listener.apply(undefined, args);
83
- });
84
- }
85
- getPoolConnection() {
86
- return new Promise((resolve, reject) => {
87
- this.pool.getConnection((err, con) => (err ? reject(err) : resolve(con)));
88
- });
89
- }
90
- async exec(opt) {
91
- const { results, fields } = await this.queryWithFields(opt.query, opt.params);
92
- if (!Array.isArray(results)) {
93
- return results;
94
- }
95
- if (!this.options.dateStringTimezone && !this.options.parseBooleans) {
96
- return results;
97
- }
98
- // Build a set of column names that are TINYINT(1) for boolean conversion
99
- const booleanColumns = new Set();
100
- if (this.options.parseBooleans && fields) {
101
- fields.forEach((field) => {
102
- // Check if column is TINYINT(1) - type 1 is TINY, length 1 means TINYINT(1)
103
- if (field.type === 1 && field.length === 1) {
104
- booleanColumns.add(field.name);
105
- }
106
- });
107
- }
108
- return results.map((row) => {
109
- Object.keys(row).map((key) => {
110
- if (this.options.dateStringTimezone && this.isSqlDate(row[key])) {
111
- row[key] = new Date(row[key] + this.options.dateStringTimezone);
112
- }
113
- if (this.options.parseBooleans && booleanColumns.has(key) && (row[key] === 0 || row[key] === 1)) {
114
- row[key] = row[key] === 1;
115
- }
116
- });
117
- return row;
118
- });
119
- }
120
- async fetch(opt, params) {
121
- if (typeof opt === 'string') {
122
- return await this.exec({ query: opt, params });
123
- }
124
- return await this.exec({ query: opt.Query, params: opt.Params });
125
- }
126
- async query(sql, params) {
127
- try {
128
- const con = await this.getPoolConnection();
129
- try {
130
- const output = await new Promise((resolve, reject) => {
131
- if (Array.isArray(params)) {
132
- con.query(sql, params, (err, result) => (err ? reject(err) : resolve(result)));
133
- } else {
134
- sql = this.formatQueryParams(con, sql, params);
135
- con.query(sql, (err, result) => (err ? reject(err) : resolve(result)));
136
- }
137
- });
138
- con.release();
139
- return output;
140
- } catch (err) {
141
- con.release();
142
- throw err;
143
- }
144
- } catch (err) {
145
- throw err;
146
- }
147
- }
148
- async queryWithFields(sql, params) {
149
- try {
150
- const con = await this.getPoolConnection();
151
- try {
152
- const output = await new Promise((resolve, reject) => {
153
- if (Array.isArray(params)) {
154
- con.query(sql, params, (err, results, fields) => {
155
- if (err) {
156
- reject(err);
157
- } else {
158
- resolve({ results, fields });
159
- }
160
- });
161
- } else {
162
- sql = this.formatQueryParams(con, sql, params);
163
- con.query(sql, (err, results, fields) => {
164
- if (err) {
165
- reject(err);
166
- } else {
167
- resolve({ results, fields });
168
- }
169
- });
170
- }
171
- });
172
- con.release();
173
- return output;
174
- } catch (err) {
175
- con.release();
176
- throw err;
177
- }
178
- } catch (err) {
179
- throw err;
180
- }
181
- }
182
- formatQueryParams(con, query, values) {
183
- if (!values) {
184
- return query;
185
- }
186
- return query.replace(/\:(\w+)/g, (txt, key) => {
187
- return values.hasOwnProperty(key) ? con.escape(values[key]) : txt;
188
- });
189
- }
190
- isSqlDate(str) {
191
- if (
192
- str &&
193
- typeof str === 'string' &&
194
- str[4] === '-' &&
195
- str[7] === '-' &&
196
- str[10] === ' ' &&
197
- str[13] === ':' &&
198
- str[16] === ':'
199
- ) {
200
- return true;
201
- }
202
- return false;
203
- }
204
- /**
205
- * Changes the active database by closing the current connection pool and creating a new one.
206
- * All active connections will be gracefully closed before switching.
207
- * @param newDatabase - The name of the database to switch to
208
- * @returns Promise that resolves when the database has been changed successfully
209
- * @throws Error if the pool cannot be closed or new pool cannot be created
210
- */
211
- async changeDatabase(newDatabase) {
212
- return new Promise((resolve, reject) => {
213
- this.pool.end((err) => {
214
- if (err) {
215
- reject(err);
216
- return;
217
- }
218
- this.databaseName = newDatabase;
219
- const newOptions = { ...this.options, database: newDatabase };
220
- this.pool = mysql.createPool(Object.assign({}, this.defaultPoolconfig, newOptions));
221
- this.pool.on('connection', (connection) => {
222
- connection.on('error', (err) => {
223
- this.triggerEvent('err', err);
224
- });
225
- connection.on('close', (err) => {
226
- this.triggerEvent('err', err);
227
- });
228
- });
229
- resolve();
230
- });
231
- });
232
- }
233
- }
234
- exports.ZSQLService = ZSQLService;
@@ -1,48 +0,0 @@
1
- import { TranslateData, dbTranslationRow, ATranslateLang, TranslateServiceOptions } from './typings';
2
- export declare class ZTranslateService {
3
- private opt;
4
- private localCache;
5
- private get sql();
6
- surpressErrors: boolean;
7
- private maxRetries;
8
- private retryDelay;
9
- private fallbackText;
10
- getLanguages(): ATranslateLang[];
11
- getSourceLang(): string;
12
- getDefaultLang(): string;
13
- constructor(opt: TranslateServiceOptions);
14
- private codes;
15
- getLang(cookies: { [key: string]: string }): string;
16
- private sleep;
17
- private logError;
18
- private retryOperation;
19
- translateText(langOrReq: string | any, text: string): Promise<string>;
20
- private processHtmlEntities;
21
- translateHtml(
22
- html: string,
23
- cookies: {
24
- lang: string;
25
- } & {
26
- [key: string]: string;
27
- },
28
- ): Promise<string>;
29
- private translateHtmlRec;
30
- update(
31
- key: string,
32
- lang: string,
33
- data: TranslateData,
34
- ): Promise<{
35
- insertId: number;
36
- affectedRows: number;
37
- }>;
38
- private checkLocalCache;
39
- private insertLocalCache;
40
- private clearLocalCache;
41
- private fetch;
42
- private insert;
43
- private fetchLang;
44
- fetchAllGrouped(): Promise<{
45
- [key: string]: dbTranslationRow[];
46
- }>;
47
- private fetchAll;
48
- }