@xrystal/core 3.50.0 → 3.51.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 +2 -2
- package/x/dist/loader/configs/index.d.ts +1 -1
- package/x/dist/loader/configs/index.js +1 -1
- package/x/dist/loader/index.d.ts +1 -2
- package/x/dist/loader/index.js +1 -1
- package/x/dist/loader/registry/index.d.ts +1 -24
- package/x/dist/loader/registry/index.js +1 -1
- package/x/dist/utils/helpers/registry/index.d.ts +9 -3
- package/x/dist/utils/helpers/registry/index.js +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Yusuf Yasir KAYGUSUZ",
|
|
3
3
|
"name": "@xrystal/core",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.51.1",
|
|
5
5
|
"description": "microservice runtime library",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -122,4 +122,4 @@
|
|
|
122
122
|
"typescript": "~5.9.3",
|
|
123
123
|
"typescript-eslint": "^8.62.1"
|
|
124
124
|
}
|
|
125
|
-
}
|
|
125
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Q from"node:path";import H from"lodash";import{pathToFileURL as W}from"node:url";import{Constants as I}from "../../utils/constants/index.js";import{resolveTmpLoadPath as X}from "../../utils/helpers/path/resolve-alias-path.js";import{bindLoaderTmpSync as Y}from "../../utils/helpers/tmp/loader-tmp-sync.js";export default class Configs{publicFolderName=I.publicFolderName;kafkaLogsTopic=I.kafkaLogsTopic;#z;#q;constructor({system:z}){this.#z=z;return new Proxy(this,{get:(A,B)=>{return A[B]||A.config?.[B]}})}onInit=async()=>{await this.syncFromTmp();Y(this)};syncFromTmp=async()=>{const z=process.cwd(),q=this.#z.tmp,A=q.configs.service.loaders.configs.loadPath,B=X(A,q,z),J=import(W(B).href);this.#q={worker:process.env.WORKER==="true"?!0:!1,mode:process.env.MODE,nodeEnv:"development",debug:process.env.SYSTEM_LOGGER_LAYER??"",https:process.env.HTTPS??"false",httpsfileEncoding:process.env.ENCODING||"utf8",httpsCertfile:process.env.HTTPS_CERT_FILE??"",httpsKeyfile:process.env.HTTPS_KEY_FILE??"",rootFolderPath:q.configs.rootFolderPath||"x",projectName:q.project.name,serviceName:q.configs.service.name??"",projectNamePrefixEnv:process.env.PROJECT_NAME_PREFIX||"",projectNameEnv:process.env.PROJECT_NAME||"",projectNameSuffixEnv:process.env.PROJECT_NAME_SUFFIX||"",systemStaticFolderPath:Q.resolve(q.configs.rootFolderPath,this.publicFolderName),systemLoggerLayer:process.env.SYSTEM_LOGGER_LAYER??"info",isKafkaPassive:process.env.IS_KAFKA_PASSIVE==="true"?!0:!1,kafkaClientId:q.configs.service.name??"",kafkaBrokers:process.env.KAFKA_BROKERS??"",kafkaUsername:process.env.KAFKA_USERNAME??"",kafkaPassword:process.env.KAFKA_PASSWORD??"",kafkaTopics:[],kafkaLogsTopic:this.kafkaLogsTopic,isRedisPassive:process.env.IS_REDIS_PASSIVE==="true"?!0:!1,redisUri:process.env.REDIS_URI??"",isMongoPassive:process.env.IS_MONGODB_PASSIVE==="true"?!0:!1,mongodbUri:process.env.MONGODB_URI??"",
|
|
1
|
+
import Q from"node:path";import H from"lodash";import{pathToFileURL as W}from"node:url";import{Constants as I}from "../../utils/constants/index.js";import{resolveTmpLoadPath as X}from "../../utils/helpers/path/resolve-alias-path.js";import{bindLoaderTmpSync as Y}from "../../utils/helpers/tmp/loader-tmp-sync.js";export default class Configs{publicFolderName=I.publicFolderName;kafkaLogsTopic=I.kafkaLogsTopic;#z;#q;constructor({system:z}){this.#z=z;return new Proxy(this,{get:(A,B)=>{return A[B]||A.config?.[B]}})}onInit=async()=>{await this.syncFromTmp();Y(this)};syncFromTmp=async()=>{const z=process.cwd(),q=this.#z.tmp,A=q.configs.service.loaders.configs.loadPath,B=X(A,q,z),J=import(W(B).href);this.#q={worker:process.env.WORKER==="true"?!0:!1,mode:process.env.MODE,nodeEnv:"development",debug:process.env.SYSTEM_LOGGER_LAYER??"",https:process.env.HTTPS??"false",httpsfileEncoding:process.env.ENCODING||"utf8",httpsCertfile:process.env.HTTPS_CERT_FILE??"",httpsKeyfile:process.env.HTTPS_KEY_FILE??"",rootFolderPath:q.configs.rootFolderPath||"x",projectName:q.project.name,serviceName:q.configs.service.name??"",projectNamePrefixEnv:process.env.PROJECT_NAME_PREFIX||"",projectNameEnv:process.env.PROJECT_NAME||"",projectNameSuffixEnv:process.env.PROJECT_NAME_SUFFIX||"",systemStaticFolderPath:Q.resolve(q.configs.rootFolderPath,this.publicFolderName),systemLoggerLayer:process.env.SYSTEM_LOGGER_LAYER??"info",isKafkaPassive:process.env.IS_KAFKA_PASSIVE==="true"?!0:!1,kafkaClientId:q.configs.service.name??"",kafkaBrokers:process.env.KAFKA_BROKERS??"",kafkaUsername:process.env.KAFKA_USERNAME??"",kafkaPassword:process.env.KAFKA_PASSWORD??"",kafkaTopics:[],kafkaLogsTopic:this.kafkaLogsTopic,isRedisPassive:process.env.IS_REDIS_PASSIVE==="true"?!0:!1,redisUri:process.env.REDIS_URI??"",isMongoPassive:process.env.IS_MONGODB_PASSIVE==="true"?!0:!1,mongodbUri:process.env.MONGODB_URI??"",isRegistryEnabled:process.env.IS_REGISTRY_ENABLED==="true",registryMongodbUri:process.env.REGISTRY_MONGODB_URI??"",baseApiUri:process.env.HTTPS==="true"?process.env.SYSTEM_HTTPS_BASE_API_URI??"":process.env.SYSTEM_BASE_API_URI??"",port:Number(process.env.PORT),internalSecret:process.env.INTERNAL_SECRET??"",secret:process.env.SECRET??"",cwd:z,env:"development"};try{const E=await J,K=E?.default||E?.configs||E||{},M=H.mergeWith({},this.#q,K,(G,N)=>{if(H.isArray(G))return G.concat(N)});this.#q=Object.freeze(M)}catch{this.#q=Object.freeze(this.#q)}};setConfig(z){const q=Object.assign(this.#q,z);this.#q=Object.freeze(q)}_(z){return this.#q[z]}get all(){return this.#q}}
|
package/x/dist/loader/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import Configs from "./configs";
|
|
|
3
3
|
import KafkaForCore from "./kafka";
|
|
4
4
|
import RedisForCore from "./redis";
|
|
5
5
|
import MongoForCore from "./mongo";
|
|
6
|
-
import ServiceRegistry from "./registry";
|
|
7
6
|
import Logger from "./logger";
|
|
8
7
|
import Events from "./events";
|
|
9
8
|
import Localizations from "./localizations";
|
|
@@ -11,4 +10,4 @@ import DtoRuntime from "./dto";
|
|
|
11
10
|
import Controller from "./controller";
|
|
12
11
|
import Service from "./service";
|
|
13
12
|
import Clients from "./clients";
|
|
14
|
-
export { System, Configs, Logger, Events, Localizations, DtoRuntime, Controller, Service, Clients, KafkaForCore, RedisForCore, MongoForCore
|
|
13
|
+
export { System, Configs, Logger, Events, Localizations, DtoRuntime, Controller, Service, Clients, KafkaForCore, RedisForCore, MongoForCore };
|
package/x/dist/loader/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import System from "./system/index.js";import Configs from "./configs/index.js";import KafkaForCore from "./kafka/index.js";import RedisForCore from "./redis/index.js";import MongoForCore from "./mongo/index.js";import
|
|
1
|
+
import System from "./system/index.js";import Configs from "./configs/index.js";import KafkaForCore from "./kafka/index.js";import RedisForCore from "./redis/index.js";import MongoForCore from "./mongo/index.js";import Logger from "./logger/index.js";import Events from "./events/index.js";import Localizations from "./localizations/index.js";import DtoRuntime from "./dto/index.js";import Controller from "./controller/index.js";import Service from "./service/index.js";import Clients from "./clients/index.js";export{System,Configs,Logger,Events,Localizations,DtoRuntime,Controller,Service,Clients,KafkaForCore,RedisForCore,MongoForCore};
|
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import Logger from '../../loader/logger';
|
|
3
|
-
import { type RegistryEntry } from '../../utils/helpers/registry';
|
|
4
|
-
import { IProvide } from '../../utils/models/classes/class.interfaces';
|
|
5
|
-
type RedisLike = {
|
|
6
|
-
hGetAll?: (key: string) => Promise<Record<string, string>>;
|
|
7
|
-
hSet?: (key: string, field: string, value: string) => Promise<number>;
|
|
8
|
-
};
|
|
9
|
-
export default class ServiceRegistry implements IProvide<any> {
|
|
10
|
-
#private;
|
|
11
|
-
constructor({ logger, configs, cache, }: {
|
|
12
|
-
logger: Logger;
|
|
13
|
-
configs: Configs;
|
|
14
|
-
cache?: {
|
|
15
|
-
rawRedis?: RedisLike | null;
|
|
16
|
-
redis?: RedisLike | null;
|
|
17
|
-
} | null;
|
|
18
|
-
});
|
|
19
|
-
onInit: () => Promise<void>;
|
|
20
|
-
onAfterInit: () => Promise<void>;
|
|
21
|
-
refreshSnapshot: () => Promise<Record<string, RegistryEntry>>;
|
|
22
|
-
resolveInternalUrl: (target: string) => string | undefined;
|
|
23
|
-
getSnapshot: () => Record<string, RegistryEntry>;
|
|
24
|
-
}
|
|
1
|
+
/** Registry helpers only — Mongo/Redis I/O lives in each *-svc loader/registry */
|
|
25
2
|
export * from '../../utils/helpers/registry';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from "../../utils/helpers/registry/index.js";
|
|
@@ -3,19 +3,25 @@ export declare const REGISTRY_COLLECTION = "registry";
|
|
|
3
3
|
export declare const LEGACY_TARGET_KEY_TO_SERVICE: Record<string, string>;
|
|
4
4
|
/** Alias names in targets (e.g. root) → registry name / Hedef alias */
|
|
5
5
|
export declare const TARGET_SERVICE_ALIASES: Record<string, string>;
|
|
6
|
+
export interface RegistryEntryOthers {
|
|
7
|
+
created?: Date | string;
|
|
8
|
+
updated?: Date | string;
|
|
9
|
+
}
|
|
10
|
+
/** Mongo registry doc — env omitted (DB per env: dev_registry_db / prod_registry_db) */
|
|
6
11
|
export interface RegistryEntry {
|
|
7
|
-
|
|
12
|
+
_id?: string;
|
|
8
13
|
name: string;
|
|
9
14
|
internalBaseUrl: string;
|
|
10
|
-
registeredAt?: Date;
|
|
11
|
-
lastSeenAt?: Date;
|
|
12
15
|
version?: string;
|
|
16
|
+
others?: RegistryEntryOthers;
|
|
13
17
|
}
|
|
14
18
|
export declare function buildInternalBaseUrl(serviceName: string, port?: number): string;
|
|
15
19
|
export declare function registryRedisHashKey(nodeEnv: string): string;
|
|
16
20
|
export declare function normalizeRegistryServiceName(name: string): string;
|
|
17
21
|
export declare function isAbsoluteHttpUrl(value: string): boolean;
|
|
18
22
|
export declare function looksLikeLegacyConfigTargetKey(key: string): boolean;
|
|
23
|
+
/** Normalize Mongo doc (supports legacy registeredAt/lastSeenAt/env) / Mongo doc normalize */
|
|
24
|
+
export declare function normalizeRegistryDoc(doc: Record<string, unknown> | null | undefined): RegistryEntry | null;
|
|
19
25
|
export declare function serializeRegistryEntry(entry: RegistryEntry): string;
|
|
20
26
|
export declare function parseRegistryEntry(raw: string | null | undefined): RegistryEntry | null;
|
|
21
27
|
export declare function snapshotFromHash(fields: Record<string, string>): Record<string, RegistryEntry>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const REGISTRY_COLLECTION="registry",LEGACY_TARGET_KEY_TO_SERVICE={coreTargetUri:"core",rootTargetUri:"core",iamTargetUri:"iam",websocketTargetUri:"websocket",mqttTargetUri:"mqtt"},TARGET_SERVICE_ALIASES={root:"core"};export function buildInternalBaseUrl(b,
|
|
1
|
+
export const REGISTRY_COLLECTION="registry",LEGACY_TARGET_KEY_TO_SERVICE={coreTargetUri:"core",rootTargetUri:"core",iamTargetUri:"iam",websocketTargetUri:"websocket",mqttTargetUri:"mqtt"},TARGET_SERVICE_ALIASES={root:"core"};export function buildInternalBaseUrl(b,j=3000){const q=String(b??"").trim();if(!q)return"";return`http://${q}-service:${j}`}export function registryRedisHashKey(b){return`${b}:registry`}export function normalizeRegistryServiceName(b){const j=String(b??"").trim();if(!j)return"";return TARGET_SERVICE_ALIASES[j]??j}export function isAbsoluteHttpUrl(b){return/^https?:\/\//i.test(String(b??"").trim())}export function looksLikeLegacyConfigTargetKey(b){return/TargetUri$/i.test(String(b??"").trim())}export function normalizeRegistryDoc(b){if(!b)return null;const j=String(b.name??"").trim(),q=String(b.internalBaseUrl??"").trim();if(!j||!q)return null;const{others:x,registeredAt:F,lastSeenAt:H}=b;return{...b._id?{_id:String(b._id)}:{},name:j,internalBaseUrl:q,...b.version?{version:String(b.version)}:{},others:{created:x?.created??F,updated:x?.updated??H}}}export function serializeRegistryEntry(b){const j=b.others??{};return JSON.stringify({...b._id?{_id:b._id}:{},name:b.name,internalBaseUrl:b.internalBaseUrl,...b.version?{version:b.version}:{},others:{created:j.created instanceof Date?j.created.toISOString():j.created,updated:j.updated instanceof Date?j.updated.toISOString():j.updated}})}export function parseRegistryEntry(b){if(!b)return null;try{return normalizeRegistryDoc(JSON.parse(b))}catch{return null}}export function snapshotFromHash(b){const j={};for(const[q,x]of Object.entries(b??{})){const F=parseRegistryEntry(x);if(F)j[q]=F}return j}
|