@xrystal/core 3.9.8 → 3.10.1
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/index.d.ts +1 -2
- package/source/index.js +1 -3
- package/source/project/index.d.ts +4 -5
- package/source/project/index.js +16 -7
- package/source/utils/helpers/tmp/index.d.ts +5 -0
- package/source/utils/helpers/tmp/index.js +9 -1
- package/source/utils/models/classes/class.services.js +7 -3
package/package.json
CHANGED
package/source/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export default tmp;
|
|
1
|
+
export {};
|
package/source/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
export declare const getTmpFile: () => {
|
|
2
|
+
_: any;
|
|
3
|
+
};
|
|
1
4
|
export declare const coreInit: (params: {
|
|
2
5
|
locales?: Record<string, any>;
|
|
3
6
|
}) => Promise<void>;
|
|
4
|
-
declare const coreLoader: ({}: {}) => Promise<{
|
|
5
|
-
_?: undefined;
|
|
6
|
-
} | {
|
|
7
|
-
_: any;
|
|
8
|
-
}>;
|
|
7
|
+
declare const coreLoader: ({}: {}) => Promise<{}>;
|
|
9
8
|
export default coreLoader;
|
package/source/project/index.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
// => import dependencies
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { SystemService, ConfigsService, LoggerService, EventsService, LocalizationsService, ClientsService } from '../loader/index';
|
|
4
|
-
import { packageName, tmpFileDefaultName, tmpFileDefaultExt, findFileRecursively,
|
|
4
|
+
import { packageName, tmpFileDefaultName, tmpFileDefaultExt, findFileRecursively, x, kafkaBrokers, systemLoggerLayer, getTmpConfig, } from '../utils/index';
|
|
5
5
|
//
|
|
6
6
|
let coreHasRun = false;
|
|
7
|
+
export const getTmpFile = () => {
|
|
8
|
+
const ownerTmpFilePath = findFileRecursively(".", tmpFileDefaultName, tmpFileDefaultExt);
|
|
9
|
+
if (!ownerTmpFilePath) {
|
|
10
|
+
throw new Error(`${tmpFileDefaultName} file not found`);
|
|
11
|
+
}
|
|
12
|
+
const tmpFileObject = getTmpConfig({});
|
|
13
|
+
return {
|
|
14
|
+
_: tmpFileObject
|
|
15
|
+
};
|
|
16
|
+
};
|
|
7
17
|
export const coreInit = async (params) => {
|
|
8
18
|
const { locales } = params;
|
|
9
19
|
if (locales)
|
|
@@ -17,9 +27,8 @@ const coreLoader = async ({}) => {
|
|
|
17
27
|
if (!ownerTmpFilePath) {
|
|
18
28
|
throw new Error(`${tmpFileDefaultName} file not found`);
|
|
19
29
|
}
|
|
20
|
-
const tmpFileObject =
|
|
21
|
-
const
|
|
22
|
-
const { configs } = r;
|
|
30
|
+
const tmpFileObject = getTmpConfig({});
|
|
31
|
+
const { configs } = tmpFileObject;
|
|
23
32
|
const rootFolderPath = configs.rootFolderPath;
|
|
24
33
|
const services = [
|
|
25
34
|
SystemService,
|
|
@@ -37,10 +46,10 @@ const coreLoader = async ({}) => {
|
|
|
37
46
|
const i18n = x.get(LocalizationsService);
|
|
38
47
|
const clientsService = x.get(ClientsService);
|
|
39
48
|
await system.load({
|
|
40
|
-
tmp:
|
|
49
|
+
tmp: tmpFileObject
|
|
41
50
|
});
|
|
42
51
|
configService.load({
|
|
43
|
-
tmp:
|
|
52
|
+
tmp: tmpFileObject,
|
|
44
53
|
systemService: system,
|
|
45
54
|
...(configs.loaders.configs.globalEnvFileName && { globalEnvFileName: configs.loaders.configs.globalEnvFileName })
|
|
46
55
|
});
|
|
@@ -64,7 +73,7 @@ const coreLoader = async ({}) => {
|
|
|
64
73
|
configs: configService,
|
|
65
74
|
});
|
|
66
75
|
coreHasRun = true;
|
|
67
|
-
return {
|
|
76
|
+
return {};
|
|
68
77
|
}
|
|
69
78
|
catch (error) {
|
|
70
79
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export declare const getTmpConfig: ({ root, tmpFileName, ext }: {
|
|
2
|
+
root?: string;
|
|
3
|
+
tmpFileName?: string;
|
|
4
|
+
ext?: string;
|
|
5
|
+
}) => any;
|
|
1
6
|
export declare function resolveObjWithHandlebars(obj: any, context: any): any;
|
|
2
7
|
export declare function findFileRecursively(startDir: string, baseName: string, extName?: string, excludedDirs?: string[]): string | null;
|
|
3
8
|
export declare const argvsConverter: (argvs: string) => {
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import Handlebars from 'handlebars';
|
|
4
|
-
import { SupportFileExtensionsEnum } from "../../index.js";
|
|
4
|
+
import { SupportFileExtensionsEnum, tmpFileDefaultName, TmpFileLoader } from "../../index.js";
|
|
5
|
+
export const getTmpConfig = ({ root = '.', tmpFileName = tmpFileDefaultName, ext = '.yml' }) => {
|
|
6
|
+
const path = findFileRecursively(root, tmpFileName, ext);
|
|
7
|
+
if (!path) {
|
|
8
|
+
throw new Error(`${name}.${ext} file not found`);
|
|
9
|
+
}
|
|
10
|
+
const loader = new TmpFileLoader({ filePath: path });
|
|
11
|
+
return loader.getResolvedTmpFile();
|
|
12
|
+
};
|
|
5
13
|
export function resolveObjWithHandlebars(obj, context) {
|
|
6
14
|
if (typeof obj === "string") {
|
|
7
15
|
const compileResult = Handlebars.compile(obj);
|
|
@@ -106,16 +106,20 @@ export class BaseApiClient extends Client {
|
|
|
106
106
|
}
|
|
107
107
|
const isDebugMode = options.debug !== undefined ? options.debug : this.debug;
|
|
108
108
|
if (isDebugMode) {
|
|
109
|
-
|
|
109
|
+
const logPayload = {
|
|
110
110
|
method: options.method || 'GET',
|
|
111
111
|
url,
|
|
112
112
|
headers: Object.fromEntries(headers.entries()),
|
|
113
|
-
body: options.body ? (typeof options.body === 'string' ? JSON.parse(options.body) :
|
|
114
|
-
}
|
|
113
|
+
body: options.body ? (typeof options.body === 'string' ? JSON.parse(options.body) : options.body) : null
|
|
114
|
+
};
|
|
115
|
+
this.logger.winston.info(`${this.clientName} Request Details: ${JSON.stringify(logPayload, null, 2)}`);
|
|
115
116
|
}
|
|
116
117
|
const controller = new AbortController();
|
|
117
118
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
118
119
|
const { version, retries, debug, ...fetchOptions } = options;
|
|
120
|
+
if (fetchOptions.body && typeof fetchOptions.body === 'object') {
|
|
121
|
+
fetchOptions.body = JSON.stringify(fetchOptions.body);
|
|
122
|
+
}
|
|
119
123
|
const response = await fetch(url, { ...fetchOptions, headers, signal: controller.signal });
|
|
120
124
|
clearTimeout(timeoutId);
|
|
121
125
|
return response;
|