@ckirg/corelib 0.1.22 → 0.2.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.
@@ -4,22 +4,20 @@ import {
4
4
  MAX_RETRY_LIMIT,
5
5
  MAX_TIMEOUT_MS,
6
6
  MIN_TIMEOUT_MS,
7
- RequestUnlimited,
8
7
  clampNumber,
9
8
  endPoint,
10
9
  endPoints,
11
10
  fullJitterDelay
12
- } from "./chunk-PESRDNPD.js";
13
- import "./chunk-BAVE2JXI.js";
11
+ } from "./chunk-XMBLUMLS.js";
12
+ import "./chunk-OXH5SYQ5.js";
14
13
  import "./chunk-2DF4ADYX.js";
15
- import "./chunk-HPE2XSTW.js";
14
+ import "./chunk-FCSKKLB6.js";
16
15
  export {
17
16
  DEFAULT_REQUEST_OPTIONS,
18
17
  MAX_BACKOFF_LIMIT_MS,
19
18
  MAX_RETRY_LIMIT,
20
19
  MAX_TIMEOUT_MS,
21
20
  MIN_TIMEOUT_MS,
22
- RequestUnlimited,
23
21
  clampNumber,
24
22
  endPoint,
25
23
  endPoints,
package/dist/browser.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  nextCid
3
3
  } from "./chunk-2DF4ADYX.js";
4
+ import {
5
+ normalizeExtras
6
+ } from "./chunk-4F2GQ7EH.js";
4
7
 
5
8
  // src/loggers/implementations/browser.ts
6
9
  var LEVEL_MAP = {
@@ -32,7 +35,10 @@ var BrowserLogger = class _BrowserLogger {
32
35
  }
33
36
  emit(lvl, consoleFn, msg, extras) {
34
37
  if ((LEVEL_MAP[lvl] ?? 30) < this.levelVal) return;
35
- consoleFn(`[${lvl.toUpperCase()}]`, msg, { ...this.ctx, ...extras });
38
+ consoleFn(`[${lvl.toUpperCase()}]`, msg, {
39
+ ...this.ctx,
40
+ ...normalizeExtras(extras)
41
+ });
36
42
  }
37
43
  trace(msg, extras) {
38
44
  this.emit("trace", console.debug.bind(console), msg, extras);
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  StrictLoggerWrapper
3
- } from "./chunk-HOOAMOFY.js";
4
- import "./chunk-HPE2XSTW.js";
3
+ } from "./chunk-UUPM6JHJ.js";
4
+ import "./chunk-4F2GQ7EH.js";
5
+ import "./chunk-FCSKKLB6.js";
5
6
 
6
7
  // src/loggers/implementations/bun.ts
7
8
  import { Writable } from "stream";
@@ -0,0 +1,42 @@
1
+ // src/loggers/common/normalize-extras.ts
2
+ import { serializeError } from "serialize-error";
3
+ function isError(value) {
4
+ return value instanceof Error || Object.prototype.toString.call(value) === "[object Error]";
5
+ }
6
+ function isPlainObject(value) {
7
+ if (typeof value !== "object" || value === null) return false;
8
+ const proto = Object.getPrototypeOf(value);
9
+ return proto === Object.prototype || proto === null;
10
+ }
11
+ function normalizeExtras(extras) {
12
+ if (extras === void 0) return void 0;
13
+ if (isError(extras)) {
14
+ return { err: serializeError(extras) };
15
+ }
16
+ const seen = /* @__PURE__ */ new Map();
17
+ const walk = (value) => {
18
+ if (isError(value)) return serializeError(value);
19
+ if (Array.isArray(value)) {
20
+ const existing = seen.get(value);
21
+ if (existing) return existing;
22
+ const clone = [];
23
+ seen.set(value, clone);
24
+ for (const item of value) clone.push(walk(item));
25
+ return clone;
26
+ }
27
+ if (isPlainObject(value)) {
28
+ const existing = seen.get(value);
29
+ if (existing) return existing;
30
+ const clone = {};
31
+ seen.set(value, clone);
32
+ for (const [k, v] of Object.entries(value)) clone[k] = walk(v);
33
+ return clone;
34
+ }
35
+ return value;
36
+ };
37
+ return walk(extras);
38
+ }
39
+
40
+ export {
41
+ normalizeExtras
42
+ };
@@ -188,15 +188,8 @@ function getSysInfo() {
188
188
  return fallback();
189
189
  }
190
190
  }
191
- var SysInfo = {
192
- /**
193
- * Gets system information.
194
- */
195
- get: getSysInfo
196
- };
197
191
 
198
192
  export {
199
193
  detectRuntime,
200
- getSysInfo,
201
- SysInfo
194
+ getSysInfo
202
195
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  detectRuntime
3
- } from "./chunk-HPE2XSTW.js";
3
+ } from "./chunk-FCSKKLB6.js";
4
4
 
5
5
  // src/loggers/index.ts
6
6
  var runtime = detectRuntime();
@@ -8,22 +8,22 @@ async function loadLogger() {
8
8
  let impl;
9
9
  switch (runtime) {
10
10
  case "cloudflare":
11
- impl = await import("./cloudflare-IOVZ3QEK.js");
11
+ impl = await import("./cloudflare-Q4ATXIHH.js");
12
12
  break;
13
13
  case "aws-lambda":
14
- impl = await import("./lambda-CQXJKGN5.js");
14
+ impl = await import("./lambda-KO2VPSU7.js");
15
15
  break;
16
16
  case "gcp-cloudrun":
17
- impl = await import("./gcp-TRX5BADQ.js");
17
+ impl = await import("./gcp-6P2RW5DC.js");
18
18
  break;
19
19
  case "bun":
20
- impl = await import("./bun-LDGTNQBK.js");
20
+ impl = await import("./bun-ZMWJTSFM.js");
21
21
  break;
22
22
  case "deno":
23
- impl = await import("./deno-MVIUW5GX.js");
23
+ impl = await import("./deno-QZMYHG4Q.js");
24
24
  break;
25
25
  default:
26
- impl = await import("./node-6V4FDE5Z.js");
26
+ impl = await import("./node-KZZQPTH2.js");
27
27
  break;
28
28
  }
29
29
  const loggerRaw = impl.default;
@@ -1,6 +1,9 @@
1
1
  import {
2
- SysInfo
3
- } from "./chunk-HPE2XSTW.js";
2
+ normalizeExtras
3
+ } from "./chunk-4F2GQ7EH.js";
4
+ import {
5
+ getSysInfo
6
+ } from "./chunk-FCSKKLB6.js";
4
7
 
5
8
  // src/loggers/common/index.ts
6
9
  var TELEMETRY_CACHE_TTL_MS = 5e3;
@@ -19,7 +22,7 @@ var StrictLoggerWrapper = class _StrictLoggerWrapper {
19
22
  const now = Date.now();
20
23
  if (!this.telemetryCache || now >= this.telemetryCache.expiresAt) {
21
24
  this.telemetryCache = {
22
- value: SysInfo.get(),
25
+ value: getSysInfo(),
23
26
  expiresAt: now + TELEMETRY_CACHE_TTL_MS
24
27
  };
25
28
  }
@@ -40,42 +43,66 @@ var StrictLoggerWrapper = class _StrictLoggerWrapper {
40
43
  trace(msg, extras) {
41
44
  this.validate(msg, extras);
42
45
  this.pinoInstance.trace(
43
- { ...this.context, ...extras, telemetry: this.getTelemetry() },
46
+ {
47
+ ...this.context,
48
+ ...normalizeExtras(extras),
49
+ telemetry: this.getTelemetry()
50
+ },
44
51
  msg
45
52
  );
46
53
  }
47
54
  debug(msg, extras) {
48
55
  this.validate(msg, extras);
49
56
  this.pinoInstance.debug(
50
- { ...this.context, ...extras, telemetry: this.getTelemetry() },
57
+ {
58
+ ...this.context,
59
+ ...normalizeExtras(extras),
60
+ telemetry: this.getTelemetry()
61
+ },
51
62
  msg
52
63
  );
53
64
  }
54
65
  info(msg, extras) {
55
66
  this.validate(msg, extras);
56
67
  this.pinoInstance.info(
57
- { ...this.context, ...extras, telemetry: this.getTelemetry() },
68
+ {
69
+ ...this.context,
70
+ ...normalizeExtras(extras),
71
+ telemetry: this.getTelemetry()
72
+ },
58
73
  msg
59
74
  );
60
75
  }
61
76
  warn(msg, extras) {
62
77
  this.validate(msg, extras);
63
78
  this.pinoInstance.warn(
64
- { ...this.context, ...extras, telemetry: this.getTelemetry() },
79
+ {
80
+ ...this.context,
81
+ ...normalizeExtras(extras),
82
+ telemetry: this.getTelemetry()
83
+ },
65
84
  msg
66
85
  );
67
86
  }
68
87
  error(msg, extras) {
69
88
  this.validate(msg, extras);
70
89
  this.pinoInstance.error(
71
- { ...this.context, ...extras, telemetry: this.getTelemetry() },
90
+ {
91
+ ...this.context,
92
+ ...normalizeExtras(extras),
93
+ telemetry: this.getTelemetry()
94
+ },
72
95
  msg
73
96
  );
74
97
  }
75
98
  fatal(msg, extras) {
76
99
  this.validate(msg, extras);
77
100
  this.pinoInstance.fatal(
78
- { ...this.context, ...extras, telemetry: this.getTelemetry() },
101
+ {
102
+ ...this.context,
103
+ ...normalizeExtras(extras),
104
+ telemetry: this.getTelemetry()
105
+ },
79
106
  msg
80
107
  );
81
108
  }
@@ -8,13 +8,13 @@ import {
8
8
  getRequire,
9
9
  loggers_default,
10
10
  readTextFileSync
11
- } from "./chunk-BAVE2JXI.js";
11
+ } from "./chunk-OXH5SYQ5.js";
12
12
  import {
13
13
  nextCid
14
14
  } from "./chunk-2DF4ADYX.js";
15
15
  import {
16
16
  detectRuntime
17
- } from "./chunk-HPE2XSTW.js";
17
+ } from "./chunk-FCSKKLB6.js";
18
18
 
19
19
  // src/retrieve/RequestUnlimited.ts
20
20
  import { deepmergeCustom as deepmergeCustom2 } from "deepmerge-ts";
@@ -60,7 +60,7 @@ var ConfigManager_default = {
60
60
 
61
61
  // src/configs/ConfigUtils.ts
62
62
  async function decryptConfig(encryptedData) {
63
- const { getEnv } = await import("./utils-Q4C2EEPD.js");
63
+ const { getEnv } = await import("./utils-6JVET3A2.js");
64
64
  const crypto = (await import("crypto")).default;
65
65
  const password = getEnv("CORELIB_AES_PASSWORD");
66
66
  if (!password) {
@@ -372,7 +372,7 @@ var ConfigManager = class _ConfigManager extends EventEmitter {
372
372
  });
373
373
  let content;
374
374
  if (source.startsWith("http")) {
375
- const { endPoint: endPoint2 } = await import("./RequestUnlimited-CLB36IJX.js");
375
+ const { endPoint: endPoint2 } = await import("./RequestUnlimited-L7FSCS5O.js");
376
376
  const result = await endPoint2(source);
377
377
  if (result.status === "error") {
378
378
  throw new Error("Failed to fetch external config");
@@ -626,9 +626,6 @@ async function serializeResponse(response) {
626
626
  body
627
627
  };
628
628
  }
629
- var RequestResponseSerialize = {
630
- serialize: serializeResponse
631
- };
632
629
 
633
630
  // src/retrieve/RequestUnlimited.ts
634
631
  var requestUnlimitedLogger = loggers_default.child({ section: "RequestUnlimited" });
@@ -854,14 +851,8 @@ async function endPoints(urls, options = {}) {
854
851
  });
855
852
  return mapped;
856
853
  }
857
- var RequestUnlimited = {
858
- defaults: DEFAULT_REQUEST_OPTIONS,
859
- endPoint,
860
- endPoints
861
- };
862
854
 
863
855
  export {
864
- RequestResponseSerialize,
865
856
  MAX_RETRY_LIMIT,
866
857
  MIN_TIMEOUT_MS,
867
858
  MAX_TIMEOUT_MS,
@@ -871,6 +862,5 @@ export {
871
862
  DEFAULT_REQUEST_OPTIONS,
872
863
  endPoint,
873
864
  endPoints,
874
- RequestUnlimited,
875
865
  ConfigManager
876
866
  };
@@ -1,6 +1,9 @@
1
+ import {
2
+ normalizeExtras
3
+ } from "./chunk-4F2GQ7EH.js";
1
4
  import {
2
5
  getSysInfo
3
- } from "./chunk-HPE2XSTW.js";
6
+ } from "./chunk-FCSKKLB6.js";
4
7
 
5
8
  // src/loggers/implementations/cloudflare.ts
6
9
  var LEVEL_MAP = {
@@ -42,7 +45,7 @@ var CloudflareLogger = class _CloudflareLogger {
42
45
  level,
43
46
  time: Date.now(),
44
47
  ...this.context,
45
- ...extras,
48
+ ...normalizeExtras(extras),
46
49
  ...this.state.telemetryEnabled && { telemetry: this.getTelemetry() },
47
50
  msg
48
51
  };
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  StrictLoggerWrapper
3
- } from "./chunk-HOOAMOFY.js";
4
- import "./chunk-HPE2XSTW.js";
3
+ } from "./chunk-UUPM6JHJ.js";
4
+ import "./chunk-4F2GQ7EH.js";
5
+ import "./chunk-FCSKKLB6.js";
5
6
 
6
7
  // src/loggers/implementations/deno.ts
7
8
  import { Writable } from "stream";
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  StrictLoggerWrapper
3
- } from "./chunk-HOOAMOFY.js";
4
- import "./chunk-HPE2XSTW.js";
3
+ } from "./chunk-UUPM6JHJ.js";
4
+ import "./chunk-4F2GQ7EH.js";
5
+ import "./chunk-FCSKKLB6.js";
5
6
 
6
7
  // src/loggers/implementations/gcp.ts
7
8
  import * as gcpConfig from "@google-cloud/pino-logging-gcp-config";
package/dist/index.d.ts CHANGED
@@ -599,21 +599,6 @@ interface SerializedResponse<T = unknown> {
599
599
  type: string;
600
600
  body: T | string;
601
601
  }
602
- /**
603
- * Serializes a Fetch API Response object into a plain structure.
604
- * Attempts to parse the body as JSON if the Content-Type indicates it; otherwise, treats as text.
605
- * Falls back to raw text on JSON parse errors. Logs warnings if body reading fails.
606
- * @param response - The Response object to serialize (or null/undefined).
607
- * @returns A Promise resolving to the SerializedResponse or null if no response provided.
608
- * @template T - The expected type of the body if JSON-parsed.
609
- */
610
- declare function serializeResponse<T = unknown>(response: Response | null | undefined): Promise<SerializedResponse<T> | null>;
611
- /**
612
- * @deprecated Use serializeResponse instead.
613
- */
614
- declare const RequestResponseSerialize: {
615
- serialize: typeof serializeResponse;
616
- };
617
602
 
618
603
  /**
619
604
  * Discriminated union for request results, ensuring type-safe success/error handling.
@@ -642,14 +627,6 @@ declare function endPoint<T = unknown>(url: string | URL | Request, options?: Op
642
627
  * @template T - The expected response body type for each request.
643
628
  */
644
629
  declare function endPoints<T = unknown>(urls: (string | URL | Request)[], options?: Options): Promise<RequestResult<T>[]>;
645
- /**
646
- * @deprecated Use endPoint/endPoints functions directly.
647
- */
648
- declare const RequestUnlimited: {
649
- defaults: Options;
650
- endPoint: typeof endPoint;
651
- endPoints: typeof endPoints;
652
- };
653
630
 
654
631
  /**
655
632
  * Proxied HTTP client with automatic rotation, fallback, and load-balancing.
@@ -790,15 +767,6 @@ declare function getSysInfo(): {
790
767
  };
791
768
  env: Record<string, string>;
792
769
  };
793
- /**
794
- * @deprecated Use getSysInfo or detectRuntime instead.
795
- */
796
- declare const SysInfo: {
797
- /**
798
- * Gets system information.
799
- */
800
- get: typeof getSysInfo;
801
- };
802
770
 
803
771
  /**
804
772
  * Gets a `require` function suitable for the current runtime.
@@ -876,4 +844,4 @@ declare const getTempDir: () => string;
876
844
  */
877
845
  declare const sleep: (ms: number) => Promise<void>;
878
846
 
879
- export { type AsyncLocalStorageLike, type BaseDbConfig, ConfigManager, Core, type Database, type DatabaseResult, DatabaseSection, type DbDriver, type DbMode, type LibraryLogger, type ParamRedactor, type PostgresConfig, PostgresDb, PostgresDriver, type PreparedDriverStatement, type QueryParams, type QueryResponse, RequestProxied, RequestResponseSerialize, type RequestResult, RequestUnlimited, Retrieve, type Runtime, type SerializedResponse, type SqliteConfig, SqliteDb, SqliteDriver, StrictLogger, SysInfo, Utils, coreFFI, createDatabase, defaultRedactor, detectRuntime, endPoint, endPoints, existsSync, getActiveTransaction, getActiveTxId, getAllEnv, getCwd, getDirname, getEnv, getMode, getPlatform, getRequire, getSysInfo, getTempDir, getVersion, handleDbError, includeExcludeCron, isFfiAvailable, logAndDouble, _default as logger, readTextFileSync, redactParams, runInTransaction, sleep, transactionStorage, wrapError, wrapSuccess };
847
+ export { type AsyncLocalStorageLike, type BaseDbConfig, ConfigManager, Core, type Database, type DatabaseResult, DatabaseSection, type DbDriver, type DbMode, type LibraryLogger, type ParamRedactor, type PostgresConfig, PostgresDb, PostgresDriver, type PreparedDriverStatement, type QueryParams, type QueryResponse, RequestProxied, type RequestResult, Retrieve, type Runtime, type SerializedResponse, type SqliteConfig, SqliteDb, SqliteDriver, StrictLogger, Utils, coreFFI, createDatabase, defaultRedactor, detectRuntime, endPoint, endPoints, existsSync, getActiveTransaction, getActiveTxId, getAllEnv, getCwd, getDirname, getEnv, getMode, getPlatform, getRequire, getSysInfo, getTempDir, getVersion, handleDbError, includeExcludeCron, isFfiAvailable, logAndDouble, _default as logger, readTextFileSync, redactParams, runInTransaction, sleep, transactionStorage, wrapError, wrapSuccess };
package/dist/index.js CHANGED
@@ -1,10 +1,8 @@
1
1
  import {
2
2
  ConfigManager,
3
- RequestResponseSerialize,
4
- RequestUnlimited,
5
3
  endPoint,
6
4
  endPoints
7
- } from "./chunk-PESRDNPD.js";
5
+ } from "./chunk-XMBLUMLS.js";
8
6
  import {
9
7
  Utils,
10
8
  existsSync,
@@ -20,15 +18,14 @@ import {
20
18
  loggers_default,
21
19
  readTextFileSync,
22
20
  sleep
23
- } from "./chunk-BAVE2JXI.js";
21
+ } from "./chunk-OXH5SYQ5.js";
24
22
  import {
25
23
  nextCid
26
24
  } from "./chunk-2DF4ADYX.js";
27
25
  import {
28
- SysInfo,
29
26
  detectRuntime,
30
27
  getSysInfo
31
- } from "./chunk-HPE2XSTW.js";
28
+ } from "./chunk-FCSKKLB6.js";
32
29
 
33
30
  // src/core/index.ts
34
31
  import { serializeError } from "serialize-error";
@@ -933,12 +930,9 @@ export {
933
930
  PostgresDb,
934
931
  PostgresDriver,
935
932
  RequestProxied,
936
- RequestResponseSerialize,
937
- RequestUnlimited,
938
933
  Retrieve,
939
934
  SqliteDb,
940
935
  SqliteDriver,
941
- SysInfo,
942
936
  Utils,
943
937
  coreFFI,
944
938
  createDatabase,
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  StrictLoggerWrapper
3
- } from "./chunk-HOOAMOFY.js";
4
- import "./chunk-HPE2XSTW.js";
3
+ } from "./chunk-UUPM6JHJ.js";
4
+ import "./chunk-4F2GQ7EH.js";
5
+ import "./chunk-FCSKKLB6.js";
5
6
 
6
7
  // src/loggers/implementations/lambda.ts
7
8
  import pino from "pino";
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  StrictLoggerWrapper
3
- } from "./chunk-HOOAMOFY.js";
4
- import "./chunk-HPE2XSTW.js";
3
+ } from "./chunk-UUPM6JHJ.js";
4
+ import "./chunk-4F2GQ7EH.js";
5
+ import "./chunk-FCSKKLB6.js";
5
6
 
6
7
  // src/loggers/implementations/node.ts
7
8
  import { Writable } from "stream";
@@ -12,17 +12,15 @@ import {
12
12
  includeExcludeCron,
13
13
  readTextFileSync,
14
14
  sleep
15
- } from "./chunk-BAVE2JXI.js";
15
+ } from "./chunk-OXH5SYQ5.js";
16
16
  import {
17
17
  nextCid
18
18
  } from "./chunk-2DF4ADYX.js";
19
19
  import {
20
- SysInfo,
21
20
  detectRuntime,
22
21
  getSysInfo
23
- } from "./chunk-HPE2XSTW.js";
22
+ } from "./chunk-FCSKKLB6.js";
24
23
  export {
25
- SysInfo,
26
24
  Utils,
27
25
  detectRuntime,
28
26
  existsSync,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckirg/corelib",
3
- "version": "0.1.22",
3
+ "version": "0.2.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },