@xrystal/core 3.22.3 → 3.22.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.
- package/package.json +1 -1
- package/source/loader/controller/index.d.ts +3 -2
- package/source/loader/controller/index.js +66 -96
- package/source/loader/index.d.ts +1 -2
- package/source/loader/index.js +1 -2
- package/source/utils/helpers/locales/index.d.ts +20 -45
- package/source/utils/helpers/locales/index.js +29 -164
- package/source/utils/models/index.d.ts +1 -1
- package/source/utils/models/index.js +1 -1
- package/source/loader/service/index.d.ts +0 -12
- package/source/loader/service/index.js +0 -16
- /package/source/utils/models/classes/{class.services.d.ts → class.client.d.ts} +0 -0
- /package/source/utils/models/classes/{class.services.js → class.client.js} +0 -0
package/package.json
CHANGED
|
@@ -49,9 +49,10 @@ export declare abstract class BaseController {
|
|
|
49
49
|
export default abstract class Controller extends BaseController implements IProvide<any> {
|
|
50
50
|
constructor();
|
|
51
51
|
onInit(): Promise<void>;
|
|
52
|
-
|
|
52
|
+
private parseMessage;
|
|
53
|
+
schema<T = any>({ checks, logic, response }: {
|
|
53
54
|
checks?: (args: any) => Promise<any>;
|
|
54
|
-
logic?: (args: any) => Promise<any>;
|
|
55
|
+
logic?: (args: any) => Promise<T | boolean | string | any[]>;
|
|
55
56
|
response?: (args: any) => Promise<any>;
|
|
56
57
|
}): Promise<any>;
|
|
57
58
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import qs from 'qs';
|
|
1
2
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
3
|
import Logger from '../logger';
|
|
3
4
|
import System from '../system';
|
|
@@ -8,25 +9,17 @@ export class BaseController {
|
|
|
8
9
|
system = x.get(System);
|
|
9
10
|
logger = x.get(Logger);
|
|
10
11
|
supportedProtocols = [ProtocolEnum.HTTP, ProtocolEnum.WEBSOCKET];
|
|
11
|
-
get protocol() {
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
get currentStore() {
|
|
15
|
-
return getControllerCtx();
|
|
16
|
-
}
|
|
12
|
+
get protocol() { return this.currentStore?.protocol || ProtocolEnum.HTTP; }
|
|
13
|
+
get currentStore() { return getControllerCtx(); }
|
|
17
14
|
get req() {
|
|
18
15
|
const store = this.currentStore;
|
|
19
16
|
const identityT = (k) => k;
|
|
20
17
|
const ctx = store?.ctx || {};
|
|
18
|
+
const query = typeof ctx.query === 'string' ? qs.parse(ctx.query) : (ctx.query || {});
|
|
21
19
|
return {
|
|
22
|
-
url: ctx.url || '',
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
body: ctx.body || {},
|
|
26
|
-
query: ctx.query || {},
|
|
27
|
-
params: ctx.params || {},
|
|
28
|
-
lang: ctx.lang || 'en',
|
|
29
|
-
t: ctx.t || identityT,
|
|
20
|
+
url: ctx.url || '', method: ctx.method || '', headers: ctx.headers || {},
|
|
21
|
+
body: ctx.body || {}, query: query, params: ctx.params || {},
|
|
22
|
+
lang: ctx.lang || 'en', t: ctx.t || identityT,
|
|
30
23
|
accounts: ctx.accounts || store?.req?.accounts
|
|
31
24
|
};
|
|
32
25
|
}
|
|
@@ -54,115 +47,92 @@ export class BaseController {
|
|
|
54
47
|
return data;
|
|
55
48
|
if (data instanceof Response)
|
|
56
49
|
return data;
|
|
57
|
-
const
|
|
58
|
-
const isRaw = store.metadata?._isRaw || isBinary;
|
|
59
|
-
let contentType = store.metadata?._contentType;
|
|
60
|
-
if (!contentType) {
|
|
61
|
-
contentType = isRaw ? 'application/octet-stream' : 'application/json';
|
|
62
|
-
}
|
|
50
|
+
const isRaw = store.metadata?._isRaw || (data instanceof Blob || data instanceof Uint8Array || data instanceof ArrayBuffer);
|
|
63
51
|
const status = store.metadata?._code || 200;
|
|
64
|
-
const body = isRaw || typeof data === 'string'
|
|
65
|
-
|
|
66
|
-
: JSON.stringify(data?.getResponse ? data.getResponse : data);
|
|
67
|
-
return new Response(body, {
|
|
68
|
-
status,
|
|
69
|
-
headers: { 'content-type': contentType }
|
|
70
|
-
});
|
|
52
|
+
const body = isRaw || typeof data === 'string' ? data : JSON.stringify(data?.getResponse ? data.getResponse : data);
|
|
53
|
+
return new Response(body, { status, headers: { 'content-type': isRaw ? 'application/octet-stream' : 'application/json' } });
|
|
71
54
|
},
|
|
72
55
|
json(data) { return this.send(data); }
|
|
73
56
|
};
|
|
74
57
|
}
|
|
75
58
|
}
|
|
76
59
|
export default class Controller extends BaseController {
|
|
77
|
-
constructor() {
|
|
78
|
-
super();
|
|
79
|
-
}
|
|
60
|
+
constructor() { super(); }
|
|
80
61
|
async onInit() {
|
|
81
62
|
const protocols = this.system?.tmp?.configs?.loaders?.controller?.protocols;
|
|
82
63
|
this.supportedProtocols = Array.isArray(protocols) ? protocols : [protocols || ProtocolEnum.HTTP];
|
|
83
64
|
}
|
|
65
|
+
parseMessage(input, t) {
|
|
66
|
+
if (!input || typeof input !== 'string' || !input.startsWith('@'))
|
|
67
|
+
return input;
|
|
68
|
+
const parts = input.substring(1).split(' ').filter(p => p !== '');
|
|
69
|
+
const maybeMethod = parts[0];
|
|
70
|
+
const hasMethod = typeof responseMessageHelper[maybeMethod] === 'function';
|
|
71
|
+
const methodName = hasMethod ? maybeMethod : 'successfully';
|
|
72
|
+
const rawArgs = hasMethod ? parts.slice(1) : parts;
|
|
73
|
+
const translatedArgs = rawArgs.map(arg => {
|
|
74
|
+
const res = t(`keywords.${arg}`);
|
|
75
|
+
return res !== `keywords.${arg}` ? res : (t(arg) !== arg ? t(arg) : arg);
|
|
76
|
+
});
|
|
77
|
+
return responseMessageHelper[methodName](translatedArgs[0] || '', translatedArgs.slice(1).join(' '), t);
|
|
78
|
+
}
|
|
84
79
|
async schema({ checks, logic, response }) {
|
|
85
80
|
try {
|
|
86
81
|
const currentReq = this.req;
|
|
87
82
|
const currentRes = this.res;
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
body: currentReq.body,
|
|
92
|
-
query: currentReq.query,
|
|
93
|
-
params: currentReq.params,
|
|
94
|
-
t: currentReq.t
|
|
95
|
-
};
|
|
83
|
+
const store = this.currentStore;
|
|
84
|
+
const t = currentReq.t;
|
|
85
|
+
const p = { req: currentReq, res: currentRes, body: currentReq.body, query: currentReq.query, params: currentReq.params, locals: store?.metadata?.locals || {}, t };
|
|
96
86
|
if (checks) {
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
const
|
|
100
|
-
|
|
87
|
+
const checkRes = await checks(p);
|
|
88
|
+
if (checkRes !== true) {
|
|
89
|
+
const isObj = checkRes && typeof checkRes === 'object';
|
|
90
|
+
const code = isObj ? checkRes.code || 400 : 400;
|
|
91
|
+
const rawMsg = isObj ? checkRes.message : (typeof checkRes === 'string' ? checkRes : '@schemaMissingDataChecks');
|
|
92
|
+
const { message, status, code: _c, data, payload, ...extras } = isObj ? checkRes : {};
|
|
93
|
+
const coreData = data || payload;
|
|
94
|
+
return currentRes.status(code).send(new ResponseSchema({
|
|
101
95
|
status: false,
|
|
102
|
-
message:
|
|
103
|
-
|
|
96
|
+
message: this.parseMessage(rawMsg, t),
|
|
97
|
+
payload: (coreData !== undefined || Object.keys(extras).length > 0) ? { data: coreData, extraData: extras } : undefined,
|
|
98
|
+
code
|
|
104
99
|
}).getResponse);
|
|
105
100
|
}
|
|
106
101
|
}
|
|
107
|
-
let
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
if (logicResult instanceof Response || (logicResult?.constructor?.name === 'Response')) {
|
|
112
|
-
return logicResult;
|
|
102
|
+
let logicRes = logic ? await logic(p) : null;
|
|
103
|
+
if (logic && logicRes === false) {
|
|
104
|
+
return currentRes.status(400).send(new ResponseSchema({ status: false, message: this.parseMessage('@unsuccessful logic', t), code: 400 }).getResponse);
|
|
113
105
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
code: errorCode
|
|
120
|
-
}).getResponse);
|
|
106
|
+
let finalRes = response ? await response({ ...p, logicResult: logicRes }) : logicRes;
|
|
107
|
+
if (typeof finalRes === 'function')
|
|
108
|
+
finalRes = await finalRes(p);
|
|
109
|
+
if (Array.isArray(finalRes)) {
|
|
110
|
+
finalRes = { message: `@successfully ${finalRes.join(' ')}` };
|
|
121
111
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return resResult;
|
|
112
|
+
else if (typeof finalRes === 'string' && !finalRes.startsWith('@')) {
|
|
113
|
+
finalRes = { message: `@successfully ${finalRes}` };
|
|
125
114
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
finalMessage = responseMessageHelper.successFully(messageSource, '', currentReq.t);
|
|
141
|
-
rawMessageValue = messageSource;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
let finalPayload = undefined;
|
|
145
|
-
if (logic) {
|
|
146
|
-
finalPayload = logicResult?.payload !== undefined ? logicResult.payload : logicResult;
|
|
147
|
-
if (finalPayload === messageSource || (finalPayload && typeof finalPayload === 'object' && (finalPayload.message === rawMessageValue || finalPayload.message === finalMessage))) {
|
|
148
|
-
finalPayload = undefined;
|
|
149
|
-
}
|
|
115
|
+
if (finalRes instanceof Response || finalRes?.constructor?.name === 'Response')
|
|
116
|
+
return finalRes;
|
|
117
|
+
const isSuccess = finalRes?.status !== false;
|
|
118
|
+
const finalCode = finalRes?.code || store?.metadata?._code || 200;
|
|
119
|
+
let msgSource = finalRes?.message || (typeof finalRes === 'string' ? finalRes : '@successfully');
|
|
120
|
+
const rawOutput = (finalRes && typeof finalRes === 'object' && !Array.isArray(finalRes)) ? finalRes : { data: finalRes };
|
|
121
|
+
const { message, status, code, data, payload, ...extraData } = rawOutput;
|
|
122
|
+
const coreData = data !== undefined ? data : payload;
|
|
123
|
+
const responseData = {
|
|
124
|
+
status: isSuccess,
|
|
125
|
+
message: this.parseMessage(msgSource, t)
|
|
126
|
+
};
|
|
127
|
+
if (coreData !== undefined || Object.keys(extraData).length > 0) {
|
|
128
|
+
responseData.payload = { data: coreData, extraData: Object.keys(extraData).length > 0 ? extraData : undefined };
|
|
150
129
|
}
|
|
151
|
-
|
|
152
|
-
return currentRes.status(
|
|
153
|
-
status: true,
|
|
154
|
-
message: finalMessage,
|
|
155
|
-
...(finalPayload && { payload: finalPayload }),
|
|
156
|
-
code: successCode
|
|
157
|
-
}).getResponse);
|
|
130
|
+
responseData.code = finalCode;
|
|
131
|
+
return currentRes.status(finalCode).send(new ResponseSchema(responseData).getResponse);
|
|
158
132
|
}
|
|
159
133
|
catch (error) {
|
|
160
134
|
this.logger?.log(LoggerLayerEnum.ERROR, `Controller Error: ${error.message}`);
|
|
161
|
-
return this.res.status(500).send(new ResponseSchema({
|
|
162
|
-
status: false,
|
|
163
|
-
message: error.message,
|
|
164
|
-
code: 500
|
|
165
|
-
}).getResponse);
|
|
135
|
+
return this.res.status(500).send(new ResponseSchema({ status: false, message: error.message, code: 500 }).getResponse);
|
|
166
136
|
}
|
|
167
137
|
}
|
|
168
138
|
}
|
package/source/loader/index.d.ts
CHANGED
|
@@ -4,6 +4,5 @@ import Logger from "./logger";
|
|
|
4
4
|
import Events from "./events";
|
|
5
5
|
import Localizations from "./localizations";
|
|
6
6
|
import Controller from "./controller";
|
|
7
|
-
import Service from "./service";
|
|
8
7
|
import Clients from "./clients";
|
|
9
|
-
export { System, Configs, Logger, Events, Localizations, Controller,
|
|
8
|
+
export { System, Configs, Logger, Events, Localizations, Controller, Clients };
|
package/source/loader/index.js
CHANGED
|
@@ -4,6 +4,5 @@ import Logger from "./logger";
|
|
|
4
4
|
import Events from "./events";
|
|
5
5
|
import Localizations from "./localizations";
|
|
6
6
|
import Controller from "./controller";
|
|
7
|
-
import Service from "./service";
|
|
8
7
|
import Clients from "./clients";
|
|
9
|
-
export { System, Configs, Logger, Events, Localizations, Controller,
|
|
8
|
+
export { System, Configs, Logger, Events, Localizations, Controller, Clients };
|
|
@@ -1,53 +1,28 @@
|
|
|
1
1
|
declare const coreMessages: {
|
|
2
|
-
|
|
3
|
-
unsuccessful: (
|
|
4
|
-
notFound: (
|
|
5
|
-
notMatch: (
|
|
6
|
-
notUse: (
|
|
7
|
-
invalid: (
|
|
8
|
-
checked: (
|
|
9
|
-
process: (
|
|
10
|
-
missingData: (
|
|
11
|
-
allreadyHave: (
|
|
12
|
-
wrongFormat: (
|
|
13
|
-
externalApiError: (
|
|
14
|
-
unauthorizedUrl: (
|
|
2
|
+
successfully: (p?: string, e?: string, t?: any) => string;
|
|
3
|
+
unsuccessful: (p?: string, e?: string, t?: any) => string;
|
|
4
|
+
notFound: (p?: string, e?: string, t?: any) => string;
|
|
5
|
+
notMatch: (p?: string, e?: string, t?: any) => string;
|
|
6
|
+
notUse: (p?: string, e?: string, t?: any) => string;
|
|
7
|
+
invalid: (p?: string, e?: string, t?: any) => string;
|
|
8
|
+
checked: (p?: string, e?: string, t?: any) => string;
|
|
9
|
+
process: (p?: string, e?: string, t?: any) => string;
|
|
10
|
+
missingData: (p?: string, e?: string, t?: any) => string;
|
|
11
|
+
allreadyHave: (p?: string, e?: string, t?: any) => string;
|
|
12
|
+
wrongFormat: (p?: string, e?: string, t?: any) => string;
|
|
13
|
+
externalApiError: (p?: string, e?: string, t?: any) => string;
|
|
14
|
+
unauthorizedUrl: (p?: string, e?: string, t?: any) => string;
|
|
15
15
|
endpointNotWorking: (endpoint?: string, t?: any) => string;
|
|
16
16
|
schemaMissingDataChecks: (t?: any) => string;
|
|
17
17
|
schemaInvalidDataChecks: (t?: any) => string;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
serverError: (process?: string, event?: string, t?: any) => string;
|
|
25
|
-
emailWelcomeTemplateTitle: (t?: any) => string;
|
|
26
|
-
emailWelcomeTemplateExplanation: (t?: any) => string;
|
|
27
|
-
emailForgotPasswordTemplateTitle: (t?: any) => string;
|
|
28
|
-
emailForgotPasswordTemplateExplanation: (t?: any) => string;
|
|
29
|
-
allRightsReserved: (extra1?: string, extra2?: string, t?: any) => string;
|
|
30
|
-
emailButtonText: (t?: any) => string;
|
|
31
|
-
emailIgnoreText: (t?: any) => string;
|
|
32
|
-
welcomeMessage: (username?: string, t?: any) => string;
|
|
33
|
-
userIsBlocked: (extra1?: string, t?: any) => string;
|
|
34
|
-
passwordChangeCode: (username?: string, t?: any) => string;
|
|
35
|
-
notEnoughWalletBalance: (money?: string, currency?: string, t?: any) => string;
|
|
36
|
-
openAuthConsumerOverhang: (param1?: string, param2?: string, t?: any) => string;
|
|
37
|
-
thirdPartySystemOverhang: (param1?: string, param2?: string, t?: any) => string;
|
|
38
|
-
deviceOverhang: (param1?: string, param2?: string, t?: any) => string;
|
|
39
|
-
provisionOverhang: (money?: string, currency?: string, t?: any) => string;
|
|
40
|
-
balanceOverhang: (money?: string, currency?: string, t?: any) => string;
|
|
41
|
-
debtOverhang: (money?: string, currency?: string, t?: any) => string;
|
|
42
|
-
shipmentNotAccepted: (value1?: string, value2?: string, t?: any) => string;
|
|
43
|
-
optionsMethod: (methods?: string, t?: any) => string;
|
|
44
|
-
notAllowedCORS: (methods?: string, t?: any) => string;
|
|
45
|
-
missingCRSFToken: (t?: any) => string;
|
|
46
|
-
invalidCRSFToken: (t?: any) => string;
|
|
18
|
+
dbQueryError: (p?: string, e?: string, t?: any) => string;
|
|
19
|
+
unknowError: (p?: string, e?: string, t?: any) => string;
|
|
20
|
+
serverError: (p?: string, e?: string, t?: any) => string;
|
|
21
|
+
welcomeMessage: (u?: string, t?: any) => string;
|
|
22
|
+
userIsBlocked: (e?: string, t?: any) => string;
|
|
23
|
+
notEnoughWalletBalance: (m?: string, c?: string, t?: any) => string;
|
|
47
24
|
tooManyRequest: (t?: any) => string;
|
|
48
|
-
|
|
49
|
-
roleAccess: (error?: string, t?: any) => string;
|
|
50
|
-
authenticationRequiredTokenExpired: (t?: any) => string;
|
|
25
|
+
roleAccess: (e?: string, t?: any) => string;
|
|
51
26
|
authenticationRequired: (t?: any) => string;
|
|
52
27
|
};
|
|
53
28
|
export declare const responseMessageHelper: typeof coreMessages & Record<string, Function>;
|
|
@@ -1,173 +1,38 @@
|
|
|
1
|
+
const f = (...args) => args.filter(item => item && typeof item === 'string' && item.trim() !== '').join(' ').trim();
|
|
1
2
|
const coreMessages = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
},
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
return `${process + ' ' + event} ${t && t('responseMessage.missingData')}.`;
|
|
28
|
-
},
|
|
29
|
-
'allreadyHave': (process = '', event = '', t) => {
|
|
30
|
-
return `${process + ' ' + event} ${t && t('responseMessage.allreadyHave')}.`;
|
|
31
|
-
},
|
|
32
|
-
'wrongFormat': (process = '', event = '', t) => {
|
|
33
|
-
return `${process + ' ' + event} ${t && t('responseMessage.wrongFormat')}.`;
|
|
34
|
-
},
|
|
35
|
-
'externalApiError': (process = '', event = '', t) => {
|
|
36
|
-
return `${process + ' ' + event}, ${t && t('responseMessage.externalApiError')}.`;
|
|
37
|
-
},
|
|
38
|
-
'unauthorizedUrl': (process = '', event = '', t) => {
|
|
39
|
-
return `${process + ' ' + event}, ${t && t('responseMessage.unauthorizedUrl')}.`;
|
|
40
|
-
},
|
|
41
|
-
'endpointNotWorking': (endpoint = '', t) => {
|
|
42
|
-
return `${endpoint}, ${t && t('responseMessage.endpointNotWorking')}.`;
|
|
43
|
-
},
|
|
44
|
-
// schema
|
|
45
|
-
// => special
|
|
46
|
-
'schemaMissingDataChecks': (t) => {
|
|
47
|
-
return `${t && t('responseMessage.schemaMissingDataChecks')}.`;
|
|
48
|
-
},
|
|
49
|
-
'schemaInvalidDataChecks': (t) => {
|
|
50
|
-
return `${t && t('responseMessage.schemaInvalidDataChecks')}.`;
|
|
51
|
-
},
|
|
52
|
-
'schemaUnknowErrorChecks': (a, b, t) => {
|
|
53
|
-
return `${t && t('responseMessage.schemaUnknowErrorChecks')}. ${a}. ${t('responseMessage.schemaErrorExtraExplanation')}: ${b}`;
|
|
54
|
-
},
|
|
55
|
-
'schemaUnknowErrorLogic': (a, b, t) => {
|
|
56
|
-
return `${t && t('responseMessage.schemaUnknowErrorLogic')}. ${a}. ${t('responseMessage.schemaErrorExtraExplanation')}: ${b}`;
|
|
57
|
-
},
|
|
58
|
-
'schemaUnknowErrorResponse': (a, b, t) => {
|
|
59
|
-
return `${t && t('responseMessage.schemaUnknowErrorLogic')}. ${a}. ${t('responseMessage.schemaErrorExtraExplanation')}: ${b}`;
|
|
60
|
-
},
|
|
61
|
-
'schemaUnknowErrorMain': (a, b, t) => {
|
|
62
|
-
return `${t && t('responseMessage.schemaUnknowErrorMain')}. ${a}. ${t('responseMessage.schemaErrorExtraExplanation')}: ${b}`;
|
|
63
|
-
},
|
|
64
|
-
//
|
|
65
|
-
'dbQueryError': (process = '', event = '', t) => {
|
|
66
|
-
return `${t && t('responseMessage.dbQueryError')}. ${process + ' ' + event}`;
|
|
67
|
-
},
|
|
68
|
-
'unknowError': (process = '', event = '', t) => {
|
|
69
|
-
return `${t && t('responseMessage.unknowError')}. ${process + ' ' + event}`;
|
|
70
|
-
},
|
|
71
|
-
'serverError': (process = '', event = '', t) => {
|
|
72
|
-
return `${t && t('responseMessage.serverError')}. ${process + ' ' + event}`;
|
|
73
|
-
},
|
|
74
|
-
// specific
|
|
75
|
-
// => email
|
|
76
|
-
// => templates
|
|
77
|
-
'emailWelcomeTemplateTitle': (t) => {
|
|
78
|
-
return `${t && t('responseMessage.emailWelcomeTemplateTitle')}`;
|
|
79
|
-
},
|
|
80
|
-
'emailWelcomeTemplateExplanation': (t) => {
|
|
81
|
-
return `${t && t('responseMessage.emailWelcomeTemplateExplanation')}.`;
|
|
82
|
-
},
|
|
83
|
-
'emailForgotPasswordTemplateTitle': (t) => {
|
|
84
|
-
return `${t && t('responseMessage.emailForgotPasswordTemplateTitle')}`;
|
|
85
|
-
},
|
|
86
|
-
'emailForgotPasswordTemplateExplanation': (t) => {
|
|
87
|
-
return `${t && t('responseMessage.emailForgotPasswordTemplateExplanation')}.`;
|
|
88
|
-
},
|
|
89
|
-
//
|
|
90
|
-
'allRightsReserved': (extra1 = '', extra2 = '', t) => {
|
|
91
|
-
return `${extra1 + ' ' + extra2}, ${t && t('responseMessage.allRightsReserved')}.`;
|
|
92
|
-
},
|
|
93
|
-
'emailButtonText': (t) => {
|
|
94
|
-
return `${t && t('responseMessage.emailButtonText')}.`;
|
|
95
|
-
},
|
|
96
|
-
'emailIgnoreText': (t) => {
|
|
97
|
-
return `${t && t('responseMessage.emailIgnoreText')}.`;
|
|
98
|
-
},
|
|
99
|
-
//
|
|
100
|
-
'welcomeMessage': (username = '', t) => {
|
|
101
|
-
return `@${username} - ${t && t('responseMessage.welcome')}.`;
|
|
102
|
-
},
|
|
103
|
-
'userIsBlocked': (extra1 = '', t) => {
|
|
104
|
-
return `${extra1}, ${t && t('responseMessage.userIsBlocked')}.`;
|
|
105
|
-
},
|
|
106
|
-
'passwordChangeCode': (username = '', t) => {
|
|
107
|
-
return `@${username} - ${t && t('responseMessage.passwordChangeCode')}.`;
|
|
108
|
-
},
|
|
109
|
-
'notEnoughWalletBalance': (money = '', currency = '', t) => {
|
|
110
|
-
return `${money + ' ' + currency}, ${t && t('responseMessage.notEnoughWalletBalance')}.`;
|
|
111
|
-
},
|
|
112
|
-
'openAuthConsumerOverhang': (param1 = '', param2 = '', t) => {
|
|
113
|
-
return `${param1 + ' ' + param2}, ${t && t('responseMessage.openAuthConsumerOverhang')}.`;
|
|
114
|
-
},
|
|
115
|
-
'thirdPartySystemOverhang': (param1 = '', param2 = '', t) => {
|
|
116
|
-
return `${param1 + ' ' + param2}, ${t && t('responseMessage.thirdPartySystems')}.`;
|
|
117
|
-
},
|
|
118
|
-
'deviceOverhang': (param1 = '', param2 = '', t) => {
|
|
119
|
-
return `${param1 + ' ' + param2}, ${t && t('responseMessage.deviceOverhang')}.`;
|
|
120
|
-
},
|
|
121
|
-
'provisionOverhang': (money = '', currency = '', t) => {
|
|
122
|
-
return `${money + ' ' + currency}, ${t && t('responseMessage.provisionOverhang')}.`;
|
|
123
|
-
},
|
|
124
|
-
'balanceOverhang': (money = '', currency = '', t) => {
|
|
125
|
-
return `${money + ' ' + currency}, ${t && t('responseMessage.balanceOverhang')}.`;
|
|
126
|
-
},
|
|
127
|
-
'debtOverhang': (money = '', currency = '', t) => {
|
|
128
|
-
return `${money + ' ' + currency}, ${t && t('responseMessage.debtOverhang')}.`;
|
|
129
|
-
},
|
|
130
|
-
'shipmentNotAccepted': (value1 = '', value2 = '', t) => {
|
|
131
|
-
return `${t && t('responseMessage.shipmentNotAccepted')}. ${value1} ${value2}`;
|
|
132
|
-
},
|
|
133
|
-
// system
|
|
134
|
-
'optionsMethod': (methods = '', t) => {
|
|
135
|
-
return `${t && t('responseMessage.optionsMethod')}. ${methods}`;
|
|
136
|
-
},
|
|
137
|
-
'notAllowedCORS': (methods = '', t) => {
|
|
138
|
-
return `${t && t('responseMessage.notAllowedCORS')}. ${methods}`;
|
|
139
|
-
},
|
|
140
|
-
'missingCRSFToken': (t) => {
|
|
141
|
-
return `${t && t('responseMessage.missingCSRFToken')}.`;
|
|
142
|
-
},
|
|
143
|
-
'invalidCRSFToken': (t) => {
|
|
144
|
-
return `${t && t('responseMessage.invalidCSRFToken')}.`;
|
|
145
|
-
},
|
|
146
|
-
'tooManyRequest': (t) => {
|
|
147
|
-
return `${t && t('responseMessage.tooManyRequest')}.`;
|
|
148
|
-
},
|
|
149
|
-
'endpointNotFound': (t) => {
|
|
150
|
-
return `${t && t('responseMessage.endpointNotFound')}.`;
|
|
151
|
-
},
|
|
152
|
-
'roleAccess': (error = '', t) => {
|
|
153
|
-
return `${t && t('responseMessage.roleAccess')}. ${error}`;
|
|
154
|
-
},
|
|
155
|
-
'authenticationRequiredTokenExpired': (t) => {
|
|
156
|
-
return `${t && t('responseMessage.authenticationRequiredTokenExpired')}.`;
|
|
157
|
-
},
|
|
158
|
-
'authenticationRequired': (t) => {
|
|
159
|
-
return `${t && t('responseMessage.authenticationRequired')}.`;
|
|
160
|
-
},
|
|
3
|
+
successfully: (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.successfully')}.`.trim(),
|
|
4
|
+
unsuccessful: (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.unsuccessful')}.`.trim(),
|
|
5
|
+
notFound: (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.notFound')}.`.trim(),
|
|
6
|
+
notMatch: (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.notMatch')}.`.trim(),
|
|
7
|
+
notUse: (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.notUse')}.`.trim(),
|
|
8
|
+
invalid: (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.invalid')}.`.trim(),
|
|
9
|
+
checked: (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.checked')}.`.trim(),
|
|
10
|
+
process: (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.process')}.`.trim(),
|
|
11
|
+
missingData: (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.missingData')}.`.trim(),
|
|
12
|
+
allreadyHave: (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.allreadyHave')}.`.trim(),
|
|
13
|
+
wrongFormat: (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.wrongFormat')}.`.trim(),
|
|
14
|
+
externalApiError: (p = '', e = '', t) => `${f(p, e)}, ${t && t('responseMessage.externalApiError')}.`.trim(),
|
|
15
|
+
unauthorizedUrl: (p = '', e = '', t) => `${f(p, e)}, ${t && t('responseMessage.unauthorizedUrl')}.`.trim(),
|
|
16
|
+
endpointNotWorking: (endpoint = '', t) => `${endpoint}, ${t && t('responseMessage.endpointNotWorking')}.`.trim(),
|
|
17
|
+
schemaMissingDataChecks: (t) => `${t && t('responseMessage.schemaMissingDataChecks')}.`.trim(),
|
|
18
|
+
schemaInvalidDataChecks: (t) => `${t && t('responseMessage.schemaInvalidDataChecks')}.`.trim(),
|
|
19
|
+
dbQueryError: (p = '', e = '', t) => `${t && t('responseMessage.dbQueryError')}. ${f(p, e)}`.trim(),
|
|
20
|
+
unknowError: (p = '', e = '', t) => `${t && t('responseMessage.unknowError')}. ${f(p, e)}`.trim(),
|
|
21
|
+
serverError: (p = '', e = '', t) => `${t && t('responseMessage.serverError')}. ${f(p, e)}`.trim(),
|
|
22
|
+
welcomeMessage: (u = '', t) => `@${u} - ${t && t('responseMessage.welcome')}.`.trim(),
|
|
23
|
+
userIsBlocked: (e = '', t) => `${e}, ${t && t('responseMessage.userIsBlocked')}.`.trim(),
|
|
24
|
+
notEnoughWalletBalance: (m = '', c = '', t) => `${f(m, c)}, ${t && t('responseMessage.notEnoughWalletBalance')}.`.trim(),
|
|
25
|
+
tooManyRequest: (t) => `${t && t('responseMessage.tooManyRequest')}.`.trim(),
|
|
26
|
+
roleAccess: (e = '', t) => `${t && t('responseMessage.roleAccess')}. ${e}`.trim(),
|
|
27
|
+
authenticationRequired: (t) => `${t && t('responseMessage.authenticationRequired')}.`.trim()
|
|
161
28
|
};
|
|
162
29
|
export const responseMessageHelper = new Proxy(coreMessages, {
|
|
163
30
|
get(target, prop) {
|
|
164
|
-
if (prop in target)
|
|
31
|
+
if (prop in target)
|
|
165
32
|
return target[prop];
|
|
166
|
-
}
|
|
167
33
|
const local = globalThis.__LOCAL_MESSAGES__;
|
|
168
|
-
if (local && prop in local)
|
|
34
|
+
if (local && prop in local)
|
|
169
35
|
return local[prop];
|
|
170
|
-
}
|
|
171
|
-
return () => `[Message '${prop}' not found]`;
|
|
36
|
+
return (p = '', e = '', t) => `${f(p, e)} ${prop}.`.trim();
|
|
172
37
|
}
|
|
173
38
|
});
|
|
@@ -3,7 +3,7 @@ import x from './classes/class.x';
|
|
|
3
3
|
import locator from './classes/class.service-locator';
|
|
4
4
|
export * from './classes/class.tmp-file-loader';
|
|
5
5
|
export * from './classes/class.response';
|
|
6
|
-
export * from './classes/class.
|
|
6
|
+
export * from './classes/class.client';
|
|
7
7
|
export * from './classes/class.interfaces';
|
|
8
8
|
export * from './types';
|
|
9
9
|
export * from './enums';
|
|
@@ -3,7 +3,7 @@ import x from './classes/class.x';
|
|
|
3
3
|
import locator from './classes/class.service-locator';
|
|
4
4
|
export * from './classes/class.tmp-file-loader';
|
|
5
5
|
export * from './classes/class.response';
|
|
6
|
-
export * from './classes/class.
|
|
6
|
+
export * from './classes/class.client';
|
|
7
7
|
export * from './classes/class.interfaces';
|
|
8
8
|
export * from './types';
|
|
9
9
|
export * from './enums';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Logger from '../logger';
|
|
2
|
-
import System from '../system';
|
|
3
|
-
import { IProvide } from '../../utils';
|
|
4
|
-
export declare abstract class BaseService {
|
|
5
|
-
protected system: System;
|
|
6
|
-
protected logger: Logger;
|
|
7
|
-
constructor();
|
|
8
|
-
}
|
|
9
|
-
export default abstract class Service extends BaseService implements IProvide<any> {
|
|
10
|
-
constructor();
|
|
11
|
-
onInit(): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Logger from '../logger';
|
|
2
|
-
import System from '../system';
|
|
3
|
-
import { x } from '../../utils';
|
|
4
|
-
export class BaseService {
|
|
5
|
-
system = x.get(System);
|
|
6
|
-
logger = x.get(Logger);
|
|
7
|
-
constructor() {
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export default class Service extends BaseService {
|
|
11
|
-
constructor() {
|
|
12
|
-
super();
|
|
13
|
-
}
|
|
14
|
-
async onInit() {
|
|
15
|
-
}
|
|
16
|
-
}
|
|
File without changes
|
|
File without changes
|