@xrystal/core 3.51.5 → 3.51.6

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.51.5",
4
+ "version": "3.51.6",
5
5
  "description": "microservice runtime library",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -14,7 +14,13 @@ export interface RegistryEntry {
14
14
  }
15
15
  export declare function buildInternalBaseUrl(serviceName: string, port?: number): string;
16
16
  export declare function registryRedisHashKey(nodeEnv: string): string;
17
+ export declare const REGISTRY_TARGET_PREFIX = "&";
17
18
  export declare function normalizeRegistryServiceName(name: string): string;
19
+ /** Gateway/mongo target ref — `&iam` means resolve internalBaseUrl from registry. */
20
+ export declare function isRegistryTargetRef(value: string): boolean;
21
+ /** Strip leading `&` and normalize service name (`&root` → `core`). */
22
+ export declare function parseRegistryTargetRef(value: string): string;
23
+ export declare function resolveRegistryTargetRef(target: string, resolveService?: (name: string) => string | undefined): string | undefined;
18
24
  export declare function isAbsoluteHttpUrl(value: string): boolean;
19
25
  export declare function looksLikeLegacyConfigTargetKey(key: string): boolean;
20
26
  export declare function normalizeRegistryDoc(doc: Record<string, unknown> | null | undefined): RegistryEntry | null;
@@ -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(t,r=3000){const e=String(t??"").trim();if(!e)return"";return`http://${e}-service:${r}`}export function registryRedisHashKey(t){return`${t}:registry`}export function normalizeRegistryServiceName(t){const r=String(t??"").trim();if(!r)return"";return TARGET_SERVICE_ALIASES[r]??r}export function isAbsoluteHttpUrl(t){return/^https?:\/\//i.test(String(t??"").trim())}export function looksLikeLegacyConfigTargetKey(t){return/TargetUri$/i.test(String(t??"").trim())}export function normalizeRegistryDoc(t){if(!t)return null;const r=String(t.name??"").trim(),e=String(t.internalBaseUrl??"").trim();if(!r||!e)return null;const{others:n,registeredAt:i,lastSeenAt:o}=t;return{...t._id?{_id:String(t._id)}:{},name:r,internalBaseUrl:e,...t.version?{version:String(t.version)}:{},others:{created:n?.created??i,updated:n?.updated??o}}}export function serializeRegistryEntry(t){const r=t.others??{};return JSON.stringify({...t._id?{_id:t._id}:{},name:t.name,internalBaseUrl:t.internalBaseUrl,...t.version?{version:t.version}:{},others:{created:r.created instanceof Date?r.created.toISOString():r.created,updated:r.updated instanceof Date?r.updated.toISOString():r.updated}})}export function parseRegistryEntry(t){if(!t)return null;try{return normalizeRegistryDoc(JSON.parse(t))}catch{return null}}export function snapshotFromHash(t){const r={};for(const[e,n]of Object.entries(t??{})){const i=parseRegistryEntry(n);if(i)r[e]=i}return r}
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 const REGISTRY_TARGET_PREFIX="&";export function normalizeRegistryServiceName(b){const j=String(b??"").trim();if(!j)return"";return TARGET_SERVICE_ALIASES[j]??j}export function isRegistryTargetRef(b){return String(b??"").trim().startsWith(REGISTRY_TARGET_PREFIX)}export function parseRegistryTargetRef(b){const j=String(b??"").trim();if(!j.startsWith(REGISTRY_TARGET_PREFIX))return normalizeRegistryServiceName(j);return normalizeRegistryServiceName(j.slice(REGISTRY_TARGET_PREFIX.length))}export function resolveRegistryTargetRef(b,j){if(!isRegistryTargetRef(b)||!j)return;return j(parseRegistryTargetRef(b))}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:H,lastSeenAt:J}=b;return{...b._id?{_id:String(b._id)}:{},name:j,internalBaseUrl:q,...b.version?{version:String(b.version)}:{},others:{created:x?.created??H,updated:x?.updated??J}}}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 H=parseRegistryEntry(x);if(H)j[q]=H}return j}