@ckirg/corelib 0.1.22
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/LICENSE +21 -0
- package/README.md +228 -0
- package/dist/RequestUnlimited-CLB36IJX.js +27 -0
- package/dist/browser.d.ts +6 -0
- package/dist/browser.js +75 -0
- package/dist/bun-LDGTNQBK.js +41 -0
- package/dist/chunk-2DF4ADYX.js +9 -0
- package/dist/chunk-BAVE2JXI.js +207 -0
- package/dist/chunk-HOOAMOFY.js +120 -0
- package/dist/chunk-HPE2XSTW.js +202 -0
- package/dist/chunk-PESRDNPD.js +876 -0
- package/dist/cloudflare-IOVZ3QEK.js +102 -0
- package/dist/deno-MVIUW5GX.js +41 -0
- package/dist/flight-recorder-BCSVZvWQ.d.ts +92 -0
- package/dist/gcp-TRX5BADQ.js +39 -0
- package/dist/index.d.ts +879 -0
- package/dist/index.js +975 -0
- package/dist/lambda-CQXJKGN5.js +32 -0
- package/dist/node-6V4FDE5Z.js +41 -0
- package/dist/utils-Q4C2EEPD.js +42 -0
- package/package.json +62 -0
- package/scripts/postinstall.js +74 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StrictLoggerWrapper
|
|
3
|
+
} from "./chunk-HOOAMOFY.js";
|
|
4
|
+
import "./chunk-HPE2XSTW.js";
|
|
5
|
+
|
|
6
|
+
// src/loggers/implementations/lambda.ts
|
|
7
|
+
import pino from "pino";
|
|
8
|
+
import pinoLambda from "pino-lambda";
|
|
9
|
+
function createLambdaLogger() {
|
|
10
|
+
const lambdaFnRaw = pinoLambda;
|
|
11
|
+
const lambdaFn = typeof lambdaFnRaw === "function" ? lambdaFnRaw : lambdaFnRaw.default || lambdaFnRaw.pinoLambda;
|
|
12
|
+
let destination;
|
|
13
|
+
if (typeof lambdaFn === "function") {
|
|
14
|
+
try {
|
|
15
|
+
destination = lambdaFn();
|
|
16
|
+
} catch (_e) {
|
|
17
|
+
console.warn("pino-lambda destination creation failed, using default");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const logger = pino(
|
|
21
|
+
{
|
|
22
|
+
level: process.env.LOG_LEVEL || "info",
|
|
23
|
+
timestamp: pino.stdTimeFunctions.isoTime,
|
|
24
|
+
redact: ["password", "secret", "token", "authorization"]
|
|
25
|
+
},
|
|
26
|
+
destination
|
|
27
|
+
);
|
|
28
|
+
return new StrictLoggerWrapper(logger);
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
createLambdaLogger as default
|
|
32
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StrictLoggerWrapper
|
|
3
|
+
} from "./chunk-HOOAMOFY.js";
|
|
4
|
+
import "./chunk-HPE2XSTW.js";
|
|
5
|
+
|
|
6
|
+
// src/loggers/implementations/node.ts
|
|
7
|
+
import { Writable } from "stream";
|
|
8
|
+
import pino from "pino";
|
|
9
|
+
import pretty from "pino-pretty";
|
|
10
|
+
var isPretty = process.env.LOG_PRETTY === "true" || process.env.NODE_ENV !== "production" && process.env.LOG_PRETTY !== "false";
|
|
11
|
+
var level = process.env.LOG_LEVEL || "info";
|
|
12
|
+
var wsProxy = new Writable({
|
|
13
|
+
write(chunk, _encoding, cb) {
|
|
14
|
+
const fn = globalThis.__wsLogWrite;
|
|
15
|
+
if (fn) fn(typeof chunk === "string" ? chunk : chunk.toString("utf8"));
|
|
16
|
+
cb();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var dest = pino.multistream([
|
|
20
|
+
{
|
|
21
|
+
level,
|
|
22
|
+
stream: isPretty ? pretty({
|
|
23
|
+
colorize: true,
|
|
24
|
+
translateTime: "SYS:standard",
|
|
25
|
+
ignore: "pid,hostname"
|
|
26
|
+
}) : process.stdout
|
|
27
|
+
},
|
|
28
|
+
{ level, stream: wsProxy }
|
|
29
|
+
]);
|
|
30
|
+
var pinoInstance = pino(
|
|
31
|
+
{
|
|
32
|
+
level,
|
|
33
|
+
redact: ["password", "secret", "token", "authorization", "apiKey"]
|
|
34
|
+
},
|
|
35
|
+
dest
|
|
36
|
+
);
|
|
37
|
+
var logger = new StrictLoggerWrapper(pinoInstance);
|
|
38
|
+
var node_default = logger;
|
|
39
|
+
export {
|
|
40
|
+
node_default as default
|
|
41
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Utils,
|
|
3
|
+
existsSync,
|
|
4
|
+
getAllEnv,
|
|
5
|
+
getCwd,
|
|
6
|
+
getDirname,
|
|
7
|
+
getEnv,
|
|
8
|
+
getMode,
|
|
9
|
+
getPlatform,
|
|
10
|
+
getRequire,
|
|
11
|
+
getTempDir,
|
|
12
|
+
includeExcludeCron,
|
|
13
|
+
readTextFileSync,
|
|
14
|
+
sleep
|
|
15
|
+
} from "./chunk-BAVE2JXI.js";
|
|
16
|
+
import {
|
|
17
|
+
nextCid
|
|
18
|
+
} from "./chunk-2DF4ADYX.js";
|
|
19
|
+
import {
|
|
20
|
+
SysInfo,
|
|
21
|
+
detectRuntime,
|
|
22
|
+
getSysInfo
|
|
23
|
+
} from "./chunk-HPE2XSTW.js";
|
|
24
|
+
export {
|
|
25
|
+
SysInfo,
|
|
26
|
+
Utils,
|
|
27
|
+
detectRuntime,
|
|
28
|
+
existsSync,
|
|
29
|
+
getAllEnv,
|
|
30
|
+
getCwd,
|
|
31
|
+
getDirname,
|
|
32
|
+
getEnv,
|
|
33
|
+
getMode,
|
|
34
|
+
getPlatform,
|
|
35
|
+
getRequire,
|
|
36
|
+
getSysInfo,
|
|
37
|
+
getTempDir,
|
|
38
|
+
includeExcludeCron,
|
|
39
|
+
nextCid,
|
|
40
|
+
readTextFileSync,
|
|
41
|
+
sleep
|
|
42
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ckirg/corelib",
|
|
3
|
+
"version": "0.1.22",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"browser": "./dist/browser.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"scripts",
|
|
19
|
+
"corelib-rust.node"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@google-cloud/pino-logging-gcp-config": "^1.3.5",
|
|
23
|
+
"@libsql/client": "^0.17.3",
|
|
24
|
+
"confbox": "^0.2.4",
|
|
25
|
+
"croner": "^10.0.1",
|
|
26
|
+
"deepmerge-ts": "^7.1.5",
|
|
27
|
+
"ky": "^2.0.2",
|
|
28
|
+
"luxon": "^3.7.2",
|
|
29
|
+
"pino": "^10.3.1",
|
|
30
|
+
"pino-lambda": "^4.4.1",
|
|
31
|
+
"pino-pretty": "^13.1.3",
|
|
32
|
+
"pino-socket": "^8.0.0",
|
|
33
|
+
"postgres": "^3.4.9",
|
|
34
|
+
"serialize-error": "^13.0.1"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@biomejs/biome": "^2.4.16",
|
|
38
|
+
"@types/bun": "^1.3.14",
|
|
39
|
+
"@types/deno": "^2.7.0",
|
|
40
|
+
"@types/node": "^25.9.2",
|
|
41
|
+
"bun-types": "^1.3.14",
|
|
42
|
+
"happy-dom": "^20.10.1",
|
|
43
|
+
"msw": "^2.14.6",
|
|
44
|
+
"pg-mem": "^3.0.14",
|
|
45
|
+
"tsx": "^4.22.4",
|
|
46
|
+
"typedoc": "^0.28.19",
|
|
47
|
+
"vitest": "^4.1.8"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"postinstall": "node scripts/postinstall.js",
|
|
51
|
+
"build": "tsup",
|
|
52
|
+
"watch": "tsup --watch",
|
|
53
|
+
"test": "vitest",
|
|
54
|
+
"test:run": "vitest run",
|
|
55
|
+
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
56
|
+
"typecheck": "tsc --noEmit",
|
|
57
|
+
"lint": "biome check . --write --unsafe --max-diagnostics=100",
|
|
58
|
+
"format": "biome format . --write",
|
|
59
|
+
"docs": "typedoc",
|
|
60
|
+
"clean": "del dist"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// =============================================
|
|
2
|
+
// FILE: ts-core/scripts/postinstall.js
|
|
3
|
+
// PURPOSE: Post-install script for downloading Rust binaries from GitHub Releases.
|
|
4
|
+
// Maps current OS/Arch to the correct prebuilt binary.
|
|
5
|
+
// Skips download if MODE=development (local dev).
|
|
6
|
+
// =============================================
|
|
7
|
+
|
|
8
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { resolve } from "node:path";
|
|
10
|
+
|
|
11
|
+
async function run() {
|
|
12
|
+
const MODE = process.env.MODE || "production";
|
|
13
|
+
const isDev = MODE === "development";
|
|
14
|
+
const isCI = !!process.env.GITHUB_ACTIONS;
|
|
15
|
+
|
|
16
|
+
console.log(`[POSTINSTALL] Running in ${MODE} mode (CI: ${isCI})`);
|
|
17
|
+
|
|
18
|
+
if (isDev || isCI) {
|
|
19
|
+
console.log("[POSTINSTALL] Local development or CI mode detected. Skipping binary download.");
|
|
20
|
+
process.exit(0);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const platform = process.platform;
|
|
24
|
+
const arch = process.arch;
|
|
25
|
+
let artifactName = "";
|
|
26
|
+
|
|
27
|
+
// Map the Node environment to the artifacts generated by our GitHub Action
|
|
28
|
+
if (platform === "win32" && arch === "x64") artifactName = "corelib-rust-win32-x64.node";
|
|
29
|
+
else if (platform === "linux" && arch === "x64") artifactName = "corelib-rust-linux-x64.node";
|
|
30
|
+
else if (platform === "darwin" && arch === "x64") artifactName = "corelib-rust-darwin-x64.node";
|
|
31
|
+
else if (platform === "darwin" && arch === "arm64") artifactName = "corelib-rust-darwin-arm64.node";
|
|
32
|
+
else {
|
|
33
|
+
console.warn(`[POSTINSTALL] Unsupported platform/arch: ${platform}/${arch}. You may need to build the native binary manually.`);
|
|
34
|
+
process.exit(0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
// 1. Get the package version dynamically so it matches the GitHub Release tag
|
|
39
|
+
const pkgPath = new URL("../package.json", import.meta.url);
|
|
40
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
41
|
+
const version = pkg.version;
|
|
42
|
+
|
|
43
|
+
// 2. Identify the Github Repo (Use GITHUB_REPOSITORY if in CI, or fallback to your hardcoded path)
|
|
44
|
+
// FIXED (2026-03-14): Ensure repo is correctly identified.
|
|
45
|
+
const repo = "ckir/corelib";
|
|
46
|
+
const url = `https://github.com/${repo}/releases/download/v${version}/${artifactName}`;
|
|
47
|
+
|
|
48
|
+
console.log(`[POSTINSTALL] Downloading binary from ${url}...`);
|
|
49
|
+
|
|
50
|
+
// 3. Fetch the binary using Node's native fetch
|
|
51
|
+
const response = await fetch(url);
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
throw new Error(`HTTP error! status: ${response.status} ${response.statusText}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 4. Save the binary directly to the expected location
|
|
57
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
58
|
+
const buffer = Buffer.from(arrayBuffer);
|
|
59
|
+
const dest = resolve(import.meta.dirname, "../corelib-rust.node");
|
|
60
|
+
|
|
61
|
+
writeFileSync(dest, buffer);
|
|
62
|
+
|
|
63
|
+
console.log(`[POSTINSTALL] Successfully downloaded ${artifactName} to ${dest}`);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error(`[POSTINSTALL] Failed to download binary:`, error);
|
|
66
|
+
console.warn("[POSTINSTALL] You may need to build the Rust binary manually using `pnpm run build` in the rust directory.");
|
|
67
|
+
|
|
68
|
+
// Exiting with 0 so it doesn't fail the entire module installation just because of a network block.
|
|
69
|
+
// The user can still run the Rust build manually if the download fails.
|
|
70
|
+
process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
run();
|