@xrystal/core 3.24.7 → 3.25.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Yusuf Yasir KAYGUSUZ",
3
3
  "name": "@xrystal/core",
4
- "version": "3.24.7",
4
+ "version": "3.25.0",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -79,28 +79,24 @@ export default class Controller extends BaseController {
79
79
  this.supportedProtocols = Array.isArray(protocols) ? protocols : [protocols || ProtocolEnum.HTTP];
80
80
  }
81
81
  parseMessage(msg, t, isError = false) {
82
- const content = String(msg || (isError ? 'unsuccessful' : 'success_process'));
82
+ const content = String(msg || '');
83
+ if (!content)
84
+ return isError ? responseMessageHelper.unsuccessful('', '', t) : responseMessageHelper.successfully('', '', t);
83
85
  let method = isError ? 'unsuccessful' : 'successfully';
84
86
  let payloadString = content;
85
87
  if (content.startsWith('@')) {
86
- const firstSpace = content.indexOf(' ');
87
- if (firstSpace !== -1) {
88
- method = content.substring(1, firstSpace);
89
- payloadString = content.substring(firstSpace + 1);
90
- }
91
- else {
92
- method = content.substring(1);
93
- payloadString = '';
94
- }
95
- }
96
- else if (content === 'unsuccessful' || content === 'success_process') {
97
- payloadString = '';
88
+ const parts = content.split(' ');
89
+ method = parts[0].substring(1);
90
+ payloadString = parts.slice(1).join(' ');
98
91
  }
99
92
  const params = payloadString.split('-').map(p => p.trim()).filter(p => p !== '');
100
- const p1 = params[0] ? t(params[0]) : '';
101
- const p2 = params.slice(1).map(v => t(v)).join(' ');
102
- if (responseMessageHelper[method])
93
+ // Kritik Düzeltme: Çiftlemeyi önlemek için parametreleri helper'a t() ile sarmadan gönderiyoruz
94
+ // Çünkü helper zaten kendi içinde t() kullanıyor
95
+ const p1 = params[0] || '';
96
+ const p2 = params.slice(1).join(' ');
97
+ if (responseMessageHelper[method]) {
103
98
  return responseMessageHelper[method](p1, p2, t);
99
+ }
104
100
  return isError ? responseMessageHelper.unsuccessful(p1, p2, t) : responseMessageHelper.successfully(p1, p2, t);
105
101
  }
106
102
  async schema({ checks, logic, response }) {
@@ -177,7 +173,7 @@ export default class Controller extends BaseController {
177
173
  else {
178
174
  extractData(resResult !== undefined ? resResult : logicResult);
179
175
  }
180
- let bizSuccessCode = store?.metadata?._code || 200;
176
+ const bizSuccessCode = store?.metadata?._code || 200;
181
177
  let payload = undefined;
182
178
  if (finalData !== undefined || finalExtraData !== undefined) {
183
179
  payload = {};
@@ -13,15 +13,13 @@ export class ResponseSchema {
13
13
  return this.payload;
14
14
  }
15
15
  statusCodeGenerator() {
16
- if (this.status === false && (this.code === 401 || this.code === 403)) {
17
- return Number(this.code);
18
- }
19
- else if (this.status === true) {
20
- return 0;
21
- }
22
- else {
16
+ if (this.status === false) {
17
+ if (this.code !== 0 && this.code !== 1) {
18
+ return Number(this.code);
19
+ }
23
20
  return 1;
24
21
  }
22
+ return 0;
25
23
  }
26
24
  get getResponse() {
27
25
  const response = {