ztechno_core 0.0.64 → 0.0.66
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/lib/crypto_service.d.ts +1 -1
- package/lib/engine_base.d.ts +2 -2
- package/lib/index.d.ts +3 -13
- package/lib/index.js +33 -3
- package/lib/mail_service.d.ts +72 -3
- package/lib/mail_service.js +81 -0
- package/lib/orm/mail_blacklist_orm.d.ts +21 -0
- package/lib/orm/mail_blacklist_orm.js +68 -0
- package/lib/orm/orm.d.ts +8 -0
- package/lib/orm/orm.js +26 -0
- package/lib/sql_service.d.ts +1 -1
- package/lib/sql_service.js +3 -3
- package/lib/translate_service.d.ts +8 -2
- package/lib/translate_service.js +603 -144
- package/lib/typings/index.d.ts +4 -0
- package/lib/typings/index.js +36 -0
- package/lib/typings/mail_types.d.ts +31 -2
- package/lib/typings/translate_types.d.ts +22 -2
- package/lib/typings/translate_types.js +44 -0
- package/lib/user_service.d.ts +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
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 __exportStar =
|
|
23
|
+
(this && this.__exportStar) ||
|
|
24
|
+
function (m, exports) {
|
|
25
|
+
for (var p in m)
|
|
26
|
+
if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
29
|
+
// Crypto types
|
|
30
|
+
__exportStar(require('./crypto_types'), exports);
|
|
31
|
+
// Mail types
|
|
32
|
+
__exportStar(require('./mail_types'), exports);
|
|
33
|
+
// Translate types
|
|
34
|
+
__exportStar(require('./translate_types'), exports);
|
|
35
|
+
// User types
|
|
36
|
+
__exportStar(require('./user_types'), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import SMTPTransport from 'nodemailer/lib/smtp-transport';
|
|
2
|
-
import {
|
|
2
|
+
import { ZSQLService } from '../sql_service';
|
|
3
3
|
interface OptionalOptions {
|
|
4
4
|
cacheDir?:
|
|
5
5
|
| string
|
|
@@ -34,7 +34,8 @@ export type MailServiceOptions = {
|
|
|
34
34
|
};
|
|
35
35
|
mailSender: string;
|
|
36
36
|
dkim?: SingleDKIMKeyOptions;
|
|
37
|
-
sqlService
|
|
37
|
+
sqlService: ZSQLService;
|
|
38
|
+
hashSalt?: string;
|
|
38
39
|
};
|
|
39
40
|
export type MailOptionsBase = {
|
|
40
41
|
recipient: string;
|
|
@@ -53,4 +54,32 @@ export type MailOptions = MailOptionsBase & {
|
|
|
53
54
|
body?: string;
|
|
54
55
|
html?: string;
|
|
55
56
|
};
|
|
57
|
+
export type ZMailSendOptTemplate = MailOptionsBase & {
|
|
58
|
+
template: 'template.html';
|
|
59
|
+
inject: {
|
|
60
|
+
title: string;
|
|
61
|
+
content: string;
|
|
62
|
+
} & {
|
|
63
|
+
[key: string]: string | number;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export type ZMailSendOptAll = MailOptionsBase & {
|
|
67
|
+
body: string;
|
|
68
|
+
html: string;
|
|
69
|
+
template: 'template.html' | string;
|
|
70
|
+
inject: {
|
|
71
|
+
title: string;
|
|
72
|
+
content: string;
|
|
73
|
+
} & {
|
|
74
|
+
[key: string]: string | number;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export type ZMailBlacklist = {
|
|
78
|
+
email: string;
|
|
79
|
+
hash?: string;
|
|
80
|
+
is_blacklisted: 0 | 1;
|
|
81
|
+
updated_at: string;
|
|
82
|
+
created_at: string;
|
|
83
|
+
};
|
|
84
|
+
export type ZMailBlacklistSearch = Pick<ZMailBlacklist, 'email' | 'is_blacklisted'>;
|
|
56
85
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ZSQLService } from '../sql_service';
|
|
2
2
|
export type Dom = {} & Node;
|
|
3
3
|
export type Node = {
|
|
4
4
|
getAttribute: (attr: string) => string;
|
|
@@ -38,7 +38,7 @@ export type ATranslateLang = {
|
|
|
38
38
|
text: string;
|
|
39
39
|
};
|
|
40
40
|
export type TranslateServiceOptions = {
|
|
41
|
-
sqlService:
|
|
41
|
+
sqlService: ZSQLService;
|
|
42
42
|
googleApiKey: string;
|
|
43
43
|
languages?: ATranslateLang[];
|
|
44
44
|
defaultLang?: string;
|
|
@@ -46,4 +46,24 @@ export type TranslateServiceOptions = {
|
|
|
46
46
|
surpressErrors?: boolean;
|
|
47
47
|
log?: (data: any, context: any) => any;
|
|
48
48
|
verbose?: (data: any, context: any) => any;
|
|
49
|
+
maxRetries?: number;
|
|
50
|
+
retryDelay?: number;
|
|
51
|
+
fallbackText?: string;
|
|
49
52
|
};
|
|
53
|
+
export declare class TranslateError extends Error {
|
|
54
|
+
code: string;
|
|
55
|
+
context?: any;
|
|
56
|
+
constructor(message: string, code: string, context?: any);
|
|
57
|
+
}
|
|
58
|
+
export declare class HtmlEntityError extends TranslateError {
|
|
59
|
+
constructor(code: string, text: string);
|
|
60
|
+
}
|
|
61
|
+
export declare class ApiTranslationError extends TranslateError {
|
|
62
|
+
constructor(originalError: any, text: string, lang: string);
|
|
63
|
+
}
|
|
64
|
+
export declare class DatabaseError extends TranslateError {
|
|
65
|
+
constructor(originalError: any, operation: string);
|
|
66
|
+
}
|
|
67
|
+
export declare class ValidationError extends TranslateError {
|
|
68
|
+
constructor(field: string, value: any);
|
|
69
|
+
}
|
|
@@ -1,2 +1,46 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.ValidationError =
|
|
4
|
+
exports.DatabaseError =
|
|
5
|
+
exports.ApiTranslationError =
|
|
6
|
+
exports.HtmlEntityError =
|
|
7
|
+
exports.TranslateError =
|
|
8
|
+
void 0;
|
|
9
|
+
// Custom error types for better error handling
|
|
10
|
+
class TranslateError extends Error {
|
|
11
|
+
constructor(message, code, context) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.context = context;
|
|
15
|
+
this.name = 'TranslateError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.TranslateError = TranslateError;
|
|
19
|
+
class HtmlEntityError extends TranslateError {
|
|
20
|
+
constructor(code, text) {
|
|
21
|
+
super(`Cannot recognize character code="${code}" for text="${text}"`, 'HTML_ENTITY_ERROR', { code, text });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.HtmlEntityError = HtmlEntityError;
|
|
25
|
+
class ApiTranslationError extends TranslateError {
|
|
26
|
+
constructor(originalError, text, lang) {
|
|
27
|
+
super(`Translation API failed for text="${text}" to language="${lang}"`, 'API_TRANSLATION_ERROR', {
|
|
28
|
+
originalError,
|
|
29
|
+
text,
|
|
30
|
+
lang,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.ApiTranslationError = ApiTranslationError;
|
|
35
|
+
class DatabaseError extends TranslateError {
|
|
36
|
+
constructor(originalError, operation) {
|
|
37
|
+
super(`Database operation failed: ${operation}`, 'DATABASE_ERROR', { originalError, operation });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.DatabaseError = DatabaseError;
|
|
41
|
+
class ValidationError extends TranslateError {
|
|
42
|
+
constructor(field, value) {
|
|
43
|
+
super(`Invalid ${field}: ${value}`, 'VALIDATION_ERROR', { field, value });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.ValidationError = ValidationError;
|
package/lib/user_service.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ZRequiredUserColumns, ZUser, ZUserSession, ZUserCredentials } from './typings
|
|
1
|
+
import { ZSQLService } from './sql_service';
|
|
2
|
+
import { ZRequiredUserColumns, ZUser, ZUserSession, ZUserCredentials } from './typings';
|
|
3
3
|
export declare class ZUserService {
|
|
4
4
|
private tableName;
|
|
5
5
|
private sqlService;
|
|
6
6
|
private salt;
|
|
7
|
-
constructor({ sqlService, tableName }: { sqlService:
|
|
7
|
+
constructor({ sqlService, tableName }: { sqlService: ZSQLService; tableName?: string });
|
|
8
8
|
private checkTableExists;
|
|
9
9
|
checkTableHasAdmin(): Promise<boolean>;
|
|
10
10
|
private createTable;
|