@veryfront/ext-observability-opentelemetry 0.1.1032 → 0.1.1035
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/esm/_dnt.polyfills.d.ts +7 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +1 -0
- package/esm/deno.d.ts +440 -0
- package/esm/deno.d.ts.map +1 -0
- package/esm/deno.js +526 -0
- package/esm/{index.d.ts → extensions/ext-observability-opentelemetry/src/index.d.ts} +21 -0
- package/esm/extensions/ext-observability-opentelemetry/src/index.d.ts.map +1 -0
- package/esm/{index.js → extensions/ext-observability-opentelemetry/src/index.js} +255 -28
- package/esm/src/config/defaults.d.ts +39 -0
- package/esm/src/config/defaults.d.ts.map +1 -0
- package/esm/src/config/defaults.js +65 -0
- package/esm/src/errors/error-registry/agent.d.ts +18 -0
- package/esm/src/errors/error-registry/agent.d.ts.map +1 -0
- package/esm/src/errors/error-registry/agent.js +60 -0
- package/esm/src/errors/error-registry/boundary.d.ts +16 -0
- package/esm/src/errors/error-registry/boundary.d.ts.map +1 -0
- package/esm/src/errors/error-registry/boundary.js +52 -0
- package/esm/src/errors/error-registry/build.d.ts +20 -0
- package/esm/src/errors/error-registry/build.d.ts.map +1 -0
- package/esm/src/errors/error-registry/build.js +68 -0
- package/esm/src/errors/error-registry/config.d.ts +22 -0
- package/esm/src/errors/error-registry/config.d.ts.map +1 -0
- package/esm/src/errors/error-registry/config.js +70 -0
- package/esm/src/errors/error-registry/deploy.d.ts +12 -0
- package/esm/src/errors/error-registry/deploy.d.ts.map +1 -0
- package/esm/src/errors/error-registry/deploy.js +36 -0
- package/esm/src/errors/error-registry/dev.d.ts +14 -0
- package/esm/src/errors/error-registry/dev.d.ts.map +1 -0
- package/esm/src/errors/error-registry/dev.js +44 -0
- package/esm/src/errors/error-registry/general.d.ts +29 -0
- package/esm/src/errors/error-registry/general.d.ts.map +1 -0
- package/esm/src/errors/error-registry/general.js +92 -0
- package/esm/src/errors/error-registry/module.d.ts +16 -0
- package/esm/src/errors/error-registry/module.d.ts.map +1 -0
- package/esm/src/errors/error-registry/module.js +52 -0
- package/esm/src/errors/error-registry/route.d.ts +16 -0
- package/esm/src/errors/error-registry/route.d.ts.map +1 -0
- package/esm/src/errors/error-registry/route.js +52 -0
- package/esm/src/errors/error-registry/runtime.d.ts +18 -0
- package/esm/src/errors/error-registry/runtime.d.ts.map +1 -0
- package/esm/src/errors/error-registry/runtime.js +60 -0
- package/esm/src/errors/error-registry/server.d.ts +39 -0
- package/esm/src/errors/error-registry/server.d.ts.map +1 -0
- package/esm/src/errors/error-registry/server.js +129 -0
- package/esm/src/errors/error-registry-helpers.d.ts +6 -0
- package/esm/src/errors/error-registry-helpers.d.ts.map +1 -0
- package/esm/src/errors/error-registry-helpers.js +9 -0
- package/esm/src/errors/error-registry.d.ts +114 -0
- package/esm/src/errors/error-registry.d.ts.map +1 -0
- package/esm/src/errors/error-registry.js +60 -0
- package/esm/src/errors/types.d.ts +84 -0
- package/esm/src/errors/types.d.ts.map +1 -0
- package/esm/src/errors/types.js +69 -0
- package/esm/src/errors/veryfront-error.d.ts +149 -0
- package/esm/src/errors/veryfront-error.d.ts.map +1 -0
- package/esm/src/errors/veryfront-error.js +61 -0
- package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.d.ts +13 -0
- package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.d.ts.map +1 -0
- package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.js +55 -0
- package/esm/src/observability/tracing/api-shim.d.ts +191 -0
- package/esm/src/observability/tracing/api-shim.d.ts.map +1 -0
- package/esm/src/observability/tracing/api-shim.js +281 -0
- package/esm/src/observability/tracing/otlp-setup.d.ts +61 -0
- package/esm/src/observability/tracing/otlp-setup.d.ts.map +1 -0
- package/esm/src/observability/tracing/otlp-setup.js +213 -0
- package/esm/src/observability/tracing/telemetry-env.d.ts +3 -0
- package/esm/src/observability/tracing/telemetry-env.d.ts.map +1 -0
- package/esm/src/observability/tracing/telemetry-env.js +10 -0
- package/esm/src/platform/adapters/base.d.ts +193 -0
- package/esm/src/platform/adapters/base.d.ts.map +1 -0
- package/esm/src/platform/adapters/base.js +15 -0
- package/esm/src/platform/compat/constants.d.ts +13 -0
- package/esm/src/platform/compat/constants.d.ts.map +1 -0
- package/esm/src/platform/compat/constants.js +12 -0
- package/esm/src/platform/compat/dynamic-import.d.ts +11 -0
- package/esm/src/platform/compat/dynamic-import.d.ts.map +1 -0
- package/esm/src/platform/compat/dynamic-import.js +10 -0
- package/esm/src/platform/compat/fs.d.ts +71 -0
- package/esm/src/platform/compat/fs.d.ts.map +1 -0
- package/esm/src/platform/compat/fs.js +277 -0
- package/esm/src/platform/compat/path/resolution.d.ts +6 -0
- package/esm/src/platform/compat/path/resolution.d.ts.map +1 -0
- package/esm/src/platform/compat/path/resolution.js +121 -0
- package/esm/src/platform/compat/path/runtime.d.ts +8 -0
- package/esm/src/platform/compat/path/runtime.d.ts.map +1 -0
- package/esm/src/platform/compat/path/runtime.js +20 -0
- package/esm/src/platform/compat/path/types.d.ts +22 -0
- package/esm/src/platform/compat/path/types.d.ts.map +1 -0
- package/esm/src/platform/compat/path/types.js +1 -0
- package/esm/src/platform/compat/process/command.d.ts +31 -0
- package/esm/src/platform/compat/process/command.d.ts.map +1 -0
- package/esm/src/platform/compat/process/command.js +194 -0
- package/esm/src/platform/compat/process/env.d.ts +35 -0
- package/esm/src/platform/compat/process/env.d.ts.map +1 -0
- package/esm/src/platform/compat/process/env.js +194 -0
- package/esm/src/platform/compat/process/lifecycle.d.ts +99 -0
- package/esm/src/platform/compat/process/lifecycle.d.ts.map +1 -0
- package/esm/src/platform/compat/process/lifecycle.js +327 -0
- package/esm/src/platform/compat/process/runtime-process.d.ts +10 -0
- package/esm/src/platform/compat/process/runtime-process.d.ts.map +1 -0
- package/esm/src/platform/compat/process/runtime-process.js +25 -0
- package/esm/src/platform/compat/process.d.ts +5 -0
- package/esm/src/platform/compat/process.d.ts.map +1 -0
- package/esm/src/platform/compat/process.js +4 -0
- package/esm/src/platform/compat/runtime.d.ts +51 -0
- package/esm/src/platform/compat/runtime.d.ts.map +1 -0
- package/esm/src/platform/compat/runtime.js +101 -0
- package/esm/src/transforms/import-rewriter/url-builder.d.ts +70 -0
- package/esm/src/transforms/import-rewriter/url-builder.d.ts.map +1 -0
- package/esm/src/transforms/import-rewriter/url-builder.js +152 -0
- package/esm/src/utils/base64url.d.ts +6 -0
- package/esm/src/utils/base64url.d.ts.map +1 -0
- package/esm/src/utils/base64url.js +12 -0
- package/esm/src/utils/bundle-manifest.d.ts +63 -0
- package/esm/src/utils/bundle-manifest.d.ts.map +1 -0
- package/esm/src/utils/bundle-manifest.js +96 -0
- package/esm/src/utils/constants/buffers.d.ts +24 -0
- package/esm/src/utils/constants/buffers.d.ts.map +1 -0
- package/esm/src/utils/constants/buffers.js +23 -0
- package/esm/src/utils/constants/build.d.ts +8 -0
- package/esm/src/utils/constants/build.d.ts.map +1 -0
- package/esm/src/utils/constants/build.js +7 -0
- package/esm/src/utils/constants/cache.d.ts +74 -0
- package/esm/src/utils/constants/cache.d.ts.map +1 -0
- package/esm/src/utils/constants/cache.js +133 -0
- package/esm/src/utils/constants/cdn.d.ts +29 -0
- package/esm/src/utils/constants/cdn.d.ts.map +1 -0
- package/esm/src/utils/constants/cdn.js +58 -0
- package/esm/src/utils/constants/crypto.d.ts +10 -0
- package/esm/src/utils/constants/crypto.d.ts.map +1 -0
- package/esm/src/utils/constants/crypto.js +9 -0
- package/esm/src/utils/constants/env.d.ts +16 -0
- package/esm/src/utils/constants/env.d.ts.map +1 -0
- package/esm/src/utils/constants/env.js +20 -0
- package/esm/src/utils/constants/hash.d.ts +5 -0
- package/esm/src/utils/constants/hash.d.ts.map +1 -0
- package/esm/src/utils/constants/hash.js +4 -0
- package/esm/src/utils/constants/hmr.d.ts +24 -0
- package/esm/src/utils/constants/hmr.d.ts.map +1 -0
- package/esm/src/utils/constants/hmr.js +26 -0
- package/esm/src/utils/constants/html.d.ts +13 -0
- package/esm/src/utils/constants/html.d.ts.map +1 -0
- package/esm/src/utils/constants/html.js +12 -0
- package/esm/src/utils/constants/http.d.ts +77 -0
- package/esm/src/utils/constants/http.d.ts.map +1 -0
- package/esm/src/utils/constants/http.js +76 -0
- package/esm/src/utils/constants/index.d.ts +23 -0
- package/esm/src/utils/constants/index.d.ts.map +1 -0
- package/esm/src/utils/constants/index.js +22 -0
- package/esm/src/utils/constants/limits.d.ts +27 -0
- package/esm/src/utils/constants/limits.d.ts.map +1 -0
- package/esm/src/utils/constants/limits.js +26 -0
- package/esm/src/utils/constants/metrics.d.ts +10 -0
- package/esm/src/utils/constants/metrics.d.ts.map +1 -0
- package/esm/src/utils/constants/metrics.js +34 -0
- package/esm/src/utils/constants/network.d.ts +23 -0
- package/esm/src/utils/constants/network.d.ts.map +1 -0
- package/esm/src/utils/constants/network.js +27 -0
- package/esm/src/utils/constants/priorities.d.ts +31 -0
- package/esm/src/utils/constants/priorities.d.ts.map +1 -0
- package/esm/src/utils/constants/priorities.js +30 -0
- package/esm/src/utils/constants/retry.d.ts +14 -0
- package/esm/src/utils/constants/retry.d.ts.map +1 -0
- package/esm/src/utils/constants/retry.js +13 -0
- package/esm/src/utils/constants/security.d.ts +16 -0
- package/esm/src/utils/constants/security.d.ts.map +1 -0
- package/esm/src/utils/constants/security.js +15 -0
- package/esm/src/utils/constants/server.d.ts +107 -0
- package/esm/src/utils/constants/server.d.ts.map +1 -0
- package/esm/src/utils/constants/server.js +120 -0
- package/esm/src/utils/feature-flags.d.ts +7 -0
- package/esm/src/utils/feature-flags.d.ts.map +1 -0
- package/esm/src/utils/feature-flags.js +8 -0
- package/esm/src/utils/hash-utils.d.ts +19 -0
- package/esm/src/utils/hash-utils.d.ts.map +1 -0
- package/esm/src/utils/hash-utils.js +42 -0
- package/esm/src/utils/import-lockfile.d.ts +52 -0
- package/esm/src/utils/import-lockfile.d.ts.map +1 -0
- package/esm/src/utils/import-lockfile.js +187 -0
- package/esm/src/utils/index.d.ts +27 -0
- package/esm/src/utils/index.d.ts.map +1 -0
- package/esm/src/utils/index.js +25 -0
- package/esm/src/utils/logger/components.d.ts +73 -0
- package/esm/src/utils/logger/components.d.ts.map +1 -0
- package/esm/src/utils/logger/components.js +81 -0
- package/esm/src/utils/logger/core.d.ts +73 -0
- package/esm/src/utils/logger/core.d.ts.map +1 -0
- package/esm/src/utils/logger/core.js +143 -0
- package/esm/src/utils/logger/index.d.ts +10 -0
- package/esm/src/utils/logger/index.d.ts.map +1 -0
- package/esm/src/utils/logger/index.js +9 -0
- package/esm/src/utils/logger/logger.d.ts +179 -0
- package/esm/src/utils/logger/logger.d.ts.map +1 -0
- package/esm/src/utils/logger/logger.js +490 -0
- package/esm/src/utils/logger/redact.d.ts +74 -0
- package/esm/src/utils/logger/redact.d.ts.map +1 -0
- package/esm/src/utils/logger/redact.js +294 -0
- package/esm/src/utils/logger/request-context.d.ts +27 -0
- package/esm/src/utils/logger/request-context.d.ts.map +1 -0
- package/esm/src/utils/logger/request-context.js +28 -0
- package/esm/src/utils/memoize.d.ts +19 -0
- package/esm/src/utils/memoize.d.ts.map +1 -0
- package/esm/src/utils/memoize.js +72 -0
- package/esm/src/utils/parallel.d.ts +25 -0
- package/esm/src/utils/parallel.d.ts.map +1 -0
- package/esm/src/utils/parallel.js +91 -0
- package/esm/src/utils/path-utils.d.ts +34 -0
- package/esm/src/utils/path-utils.d.ts.map +1 -0
- package/esm/src/utils/path-utils.js +138 -0
- package/esm/src/utils/perf-timer.d.ts +11 -0
- package/esm/src/utils/perf-timer.d.ts.map +1 -0
- package/esm/src/utils/perf-timer.js +114 -0
- package/esm/src/utils/platform.d.ts +9 -0
- package/esm/src/utils/platform.d.ts.map +1 -0
- package/esm/src/utils/platform.js +20 -0
- package/esm/src/utils/runtime-guards.d.ts +29 -0
- package/esm/src/utils/runtime-guards.d.ts.map +1 -0
- package/esm/src/utils/runtime-guards.js +23 -0
- package/esm/src/utils/version-constant.d.ts +3 -0
- package/esm/src/utils/version-constant.d.ts.map +1 -0
- package/esm/src/utils/version-constant.js +4 -0
- package/esm/src/utils/version.d.ts +17 -0
- package/esm/src/utils/version.d.ts.map +1 -0
- package/esm/src/utils/version.js +36 -0
- package/package.json +25 -7
- package/esm/index.d.ts.map +0 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as dntShim from "../../_dnt.shims.js";
|
|
2
|
+
import { FNV1A_PRIME_32 } from "./constants/crypto.js";
|
|
3
|
+
import { HASH_SEED_FNV1A } from "./constants/hash.js";
|
|
4
|
+
/** Number of hex characters kept by shortHash (8 hex chars = 32 bits) */
|
|
5
|
+
const SHORT_HASH_LENGTH = 8;
|
|
6
|
+
/** Compute hash. */
|
|
7
|
+
export async function computeHash(content) {
|
|
8
|
+
const data = new TextEncoder().encode(content);
|
|
9
|
+
const hashBuffer = await dntShim.crypto.subtle.digest("SHA-256", data);
|
|
10
|
+
return Array.from(new Uint8Array(hashBuffer), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
11
|
+
}
|
|
12
|
+
/** Compute code hash. */
|
|
13
|
+
export function computeCodeHash(code) {
|
|
14
|
+
return computeHash(`${code.code}${code.css ?? ""}${code.sourceMap ?? ""}`);
|
|
15
|
+
}
|
|
16
|
+
/** Create simple hash. */
|
|
17
|
+
export function simpleHash(str) {
|
|
18
|
+
let hash = 0;
|
|
19
|
+
for (let i = 0; i < str.length; i++) {
|
|
20
|
+
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
21
|
+
hash &= hash;
|
|
22
|
+
}
|
|
23
|
+
return Math.abs(hash);
|
|
24
|
+
}
|
|
25
|
+
/** Hash string to hex (base 16) - used for module filenames */
|
|
26
|
+
export function hashCodeHex(str) {
|
|
27
|
+
return simpleHash(str).toString(16);
|
|
28
|
+
}
|
|
29
|
+
/** Create short hash. */
|
|
30
|
+
export async function shortHash(content) {
|
|
31
|
+
const fullHash = await computeHash(content);
|
|
32
|
+
return fullHash.slice(0, SHORT_HASH_LENGTH);
|
|
33
|
+
}
|
|
34
|
+
/** FNV-1a hash for strings - returns hex string */
|
|
35
|
+
export function fnv1aHash(input) {
|
|
36
|
+
let hash = HASH_SEED_FNV1A >>> 0;
|
|
37
|
+
for (const char of input) {
|
|
38
|
+
hash ^= char.charCodeAt(0);
|
|
39
|
+
hash = Math.imul(hash, FNV1A_PRIME_32);
|
|
40
|
+
}
|
|
41
|
+
return (hash >>> 0).toString(16);
|
|
42
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface LockfileEntry {
|
|
2
|
+
resolved: string;
|
|
3
|
+
integrity: string;
|
|
4
|
+
dependencies?: string[];
|
|
5
|
+
fetchedAt?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface LockfileData {
|
|
8
|
+
version: 1;
|
|
9
|
+
imports: Record<string, LockfileEntry>;
|
|
10
|
+
}
|
|
11
|
+
export declare function createEmptyLockfile(): LockfileData;
|
|
12
|
+
/** Compute integrity. */
|
|
13
|
+
export declare function computeIntegrity(content: string): Promise<string>;
|
|
14
|
+
export declare function verifyIntegrity(content: string, integrity: string): Promise<boolean>;
|
|
15
|
+
/** Public API contract for lockfile manager. */
|
|
16
|
+
export interface LockfileManager {
|
|
17
|
+
read(): Promise<LockfileData | null>;
|
|
18
|
+
write(data: LockfileData): Promise<void>;
|
|
19
|
+
get(url: string): Promise<LockfileEntry | null>;
|
|
20
|
+
set(url: string, entry: LockfileEntry): Promise<void>;
|
|
21
|
+
has(url: string): Promise<boolean>;
|
|
22
|
+
clear(): Promise<void>;
|
|
23
|
+
flush(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export type FSAdapter = {
|
|
26
|
+
readFile(path: string): Promise<string>;
|
|
27
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
28
|
+
exists(path: string): Promise<boolean>;
|
|
29
|
+
remove?(path: string): Promise<void>;
|
|
30
|
+
};
|
|
31
|
+
/** Create lockfile manager. */
|
|
32
|
+
export declare function createLockfileManager(projectDir: string, fsAdapter?: FSAdapter): LockfileManager;
|
|
33
|
+
export interface FetchWithLockOptions {
|
|
34
|
+
lockfile: LockfileManager;
|
|
35
|
+
url: string;
|
|
36
|
+
fetchFn?: typeof fetch;
|
|
37
|
+
strict?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface FetchWithLockResult {
|
|
40
|
+
content: string;
|
|
41
|
+
resolvedUrl: string;
|
|
42
|
+
fromCache: boolean;
|
|
43
|
+
integrity: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function fetchWithLock(options: FetchWithLockOptions): Promise<FetchWithLockResult>;
|
|
46
|
+
export interface ParsedImport {
|
|
47
|
+
specifier: string;
|
|
48
|
+
type: "static" | "dynamic";
|
|
49
|
+
}
|
|
50
|
+
export declare function extractImports(content: string): ParsedImport[];
|
|
51
|
+
export declare function resolveImportUrl(specifier: string, baseUrl: string): string | null;
|
|
52
|
+
//# sourceMappingURL=import-lockfile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-lockfile.d.ts","sourceRoot":"","sources":["../../../src/src/utils/import-lockfile.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CACxC;AAKD,wBAAgB,mBAAmB,IAAI,YAAY,CAElD;AAED,yBAAyB;AACzB,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGvE;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,O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C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAID,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA2D/F;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC5B;AAMD,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,CAmB9D;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUlF"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { computeHash } from "./hash-utils.js";
|
|
2
|
+
import { serverLogger } from "./logger/index.js";
|
|
3
|
+
import { createFileSystem } from "../platform/compat/fs.js";
|
|
4
|
+
import { CACHE_ERROR, NETWORK_ERROR } from "../errors/error-registry.js";
|
|
5
|
+
const logger = serverLogger.component("lockfile");
|
|
6
|
+
const LOCKFILE_NAME = "veryfront.lock";
|
|
7
|
+
const LOCKFILE_VERSION = 1;
|
|
8
|
+
export function createEmptyLockfile() {
|
|
9
|
+
return { version: LOCKFILE_VERSION, imports: {} };
|
|
10
|
+
}
|
|
11
|
+
/** Compute integrity. */
|
|
12
|
+
export async function computeIntegrity(content) {
|
|
13
|
+
const hash = await computeHash(content);
|
|
14
|
+
return `sha256-${hash}`;
|
|
15
|
+
}
|
|
16
|
+
export async function verifyIntegrity(content, integrity) {
|
|
17
|
+
const computed = await computeIntegrity(content);
|
|
18
|
+
return computed === integrity;
|
|
19
|
+
}
|
|
20
|
+
function createPlatformFSAdapter() {
|
|
21
|
+
const fs = createFileSystem();
|
|
22
|
+
return {
|
|
23
|
+
readFile(path) {
|
|
24
|
+
return fs.readTextFile(path);
|
|
25
|
+
},
|
|
26
|
+
writeFile(path, content) {
|
|
27
|
+
return fs.writeTextFile(path, content);
|
|
28
|
+
},
|
|
29
|
+
exists(path) {
|
|
30
|
+
return fs.exists(path);
|
|
31
|
+
},
|
|
32
|
+
remove(path) {
|
|
33
|
+
return fs.remove(path);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Create lockfile manager. */
|
|
38
|
+
export function createLockfileManager(projectDir, fsAdapter) {
|
|
39
|
+
const fs = fsAdapter ?? createPlatformFSAdapter();
|
|
40
|
+
const lockfilePath = `${projectDir}/${LOCKFILE_NAME}`;
|
|
41
|
+
let cache = null;
|
|
42
|
+
let dirty = false;
|
|
43
|
+
async function read() {
|
|
44
|
+
if (cache)
|
|
45
|
+
return cache;
|
|
46
|
+
try {
|
|
47
|
+
const exists = await fs.exists(lockfilePath);
|
|
48
|
+
if (!exists)
|
|
49
|
+
return null;
|
|
50
|
+
const content = await fs.readFile(lockfilePath);
|
|
51
|
+
const parsed = JSON.parse(content);
|
|
52
|
+
if (parsed.version !== LOCKFILE_VERSION) {
|
|
53
|
+
logger.warn(`[lockfile] Version mismatch, expected ${LOCKFILE_VERSION}, got ${parsed.version}`);
|
|
54
|
+
cache = createEmptyLockfile();
|
|
55
|
+
return cache;
|
|
56
|
+
}
|
|
57
|
+
cache = parsed;
|
|
58
|
+
return cache;
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
logger.debug(`Could not read lockfile: ${e}`);
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async function write(data) {
|
|
66
|
+
cache = data;
|
|
67
|
+
const sorted = {
|
|
68
|
+
version: data.version,
|
|
69
|
+
imports: Object.fromEntries(Object.entries(data.imports).sort(([a], [b]) => a.localeCompare(b))),
|
|
70
|
+
};
|
|
71
|
+
await fs.writeFile(lockfilePath, `${JSON.stringify(sorted, null, 2)}\n`);
|
|
72
|
+
dirty = false;
|
|
73
|
+
logger.debug(`Written ${Object.keys(data.imports).length} entries`);
|
|
74
|
+
}
|
|
75
|
+
async function get(url) {
|
|
76
|
+
const data = await read();
|
|
77
|
+
return data?.imports[url] ?? null;
|
|
78
|
+
}
|
|
79
|
+
async function set(url, entry) {
|
|
80
|
+
const data = (await read()) ?? createEmptyLockfile();
|
|
81
|
+
data.imports[url] = entry;
|
|
82
|
+
cache = data;
|
|
83
|
+
dirty = true;
|
|
84
|
+
}
|
|
85
|
+
async function has(url) {
|
|
86
|
+
const data = await read();
|
|
87
|
+
return url in (data?.imports ?? {});
|
|
88
|
+
}
|
|
89
|
+
async function clear() {
|
|
90
|
+
cache = createEmptyLockfile();
|
|
91
|
+
dirty = false;
|
|
92
|
+
if (!fs.remove)
|
|
93
|
+
return;
|
|
94
|
+
const exists = await fs.exists(lockfilePath);
|
|
95
|
+
if (!exists)
|
|
96
|
+
return;
|
|
97
|
+
await fs.remove(lockfilePath);
|
|
98
|
+
}
|
|
99
|
+
async function flush() {
|
|
100
|
+
if (!dirty || !cache)
|
|
101
|
+
return;
|
|
102
|
+
await write(cache);
|
|
103
|
+
}
|
|
104
|
+
return { read, write, get, set, has, clear, flush };
|
|
105
|
+
}
|
|
106
|
+
const USER_AGENT_HEADERS = { "user-agent": "Mozilla/5.0 Veryfront/1.0" };
|
|
107
|
+
export async function fetchWithLock(options) {
|
|
108
|
+
const { lockfile, url, fetchFn = fetch, strict = false } = options;
|
|
109
|
+
const entry = await lockfile.get(url);
|
|
110
|
+
if (entry) {
|
|
111
|
+
logger.debug(`Cache hit for ${url}`);
|
|
112
|
+
const res = await fetchFn(entry.resolved, { headers: USER_AGENT_HEADERS });
|
|
113
|
+
if (!res.ok) {
|
|
114
|
+
if (strict) {
|
|
115
|
+
throw CACHE_ERROR.create({
|
|
116
|
+
detail: `Lockfile entry stale: ${url} resolved to ${entry.resolved} returned ${res.status}`,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
logger.warn(`Cached URL ${entry.resolved} returned ${res.status}, refetching`);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
const content = await res.text();
|
|
123
|
+
const currentIntegrity = await computeIntegrity(content);
|
|
124
|
+
if (currentIntegrity === entry.integrity) {
|
|
125
|
+
return {
|
|
126
|
+
content,
|
|
127
|
+
resolvedUrl: entry.resolved,
|
|
128
|
+
fromCache: true,
|
|
129
|
+
integrity: entry.integrity,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
if (strict) {
|
|
133
|
+
throw CACHE_ERROR.create({
|
|
134
|
+
detail: `Integrity mismatch for ${url}: expected ${entry.integrity}, got ${currentIntegrity}`,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
logger.warn(`Integrity mismatch for ${url}, updating lockfile`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
logger.debug(`Fetching fresh: ${url}`);
|
|
141
|
+
const res = await fetchFn(url, { headers: USER_AGENT_HEADERS, redirect: "follow" });
|
|
142
|
+
if (!res.ok)
|
|
143
|
+
throw NETWORK_ERROR.create({ detail: `Failed to fetch ${url}: ${res.status}` });
|
|
144
|
+
const content = await res.text();
|
|
145
|
+
const resolvedUrl = res.url || url;
|
|
146
|
+
const integrity = await computeIntegrity(content);
|
|
147
|
+
await lockfile.set(url, {
|
|
148
|
+
resolved: resolvedUrl,
|
|
149
|
+
integrity,
|
|
150
|
+
fetchedAt: new Date().toISOString(),
|
|
151
|
+
});
|
|
152
|
+
await lockfile.flush();
|
|
153
|
+
return { content, resolvedUrl, fromCache: false, integrity };
|
|
154
|
+
}
|
|
155
|
+
const IMPORT_REGEX = /import\s+(?:(?:[\w*\s{},]*)\s+from\s+)?['"]([^'"]+)['"]/g;
|
|
156
|
+
const DYNAMIC_IMPORT_REGEX = /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
157
|
+
const EXPORT_FROM_REGEX = /export\s+(?:[\w*\s{},]*)\s+from\s+['"]([^'"]+)['"]/g;
|
|
158
|
+
export function extractImports(content) {
|
|
159
|
+
const imports = [];
|
|
160
|
+
const seen = new Set();
|
|
161
|
+
function addMatches(regex, type) {
|
|
162
|
+
for (const match of content.matchAll(regex)) {
|
|
163
|
+
const specifier = match[1];
|
|
164
|
+
if (!specifier || seen.has(specifier))
|
|
165
|
+
continue;
|
|
166
|
+
seen.add(specifier);
|
|
167
|
+
imports.push({ specifier, type });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
addMatches(IMPORT_REGEX, "static");
|
|
171
|
+
addMatches(EXPORT_FROM_REGEX, "static");
|
|
172
|
+
addMatches(DYNAMIC_IMPORT_REGEX, "dynamic");
|
|
173
|
+
return imports;
|
|
174
|
+
}
|
|
175
|
+
export function resolveImportUrl(specifier, baseUrl) {
|
|
176
|
+
if (specifier.startsWith("http://") || specifier.startsWith("https://"))
|
|
177
|
+
return specifier;
|
|
178
|
+
if (!specifier.startsWith("./") && !specifier.startsWith("../"))
|
|
179
|
+
return null;
|
|
180
|
+
try {
|
|
181
|
+
return new URL(specifier, baseUrl).toString();
|
|
182
|
+
}
|
|
183
|
+
catch (_) {
|
|
184
|
+
/* expected: specifier may not be a valid relative URL */
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime detection, logging, constants, hashing, and feature flags.
|
|
3
|
+
*
|
|
4
|
+
* @module utils
|
|
5
|
+
*
|
|
6
|
+
* @example Structured logging
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { serverLogger } from "veryfront/utils";
|
|
9
|
+
*
|
|
10
|
+
* serverLogger.info("Booting server", { project_id: "proj_123" });
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export { type GlobalWithBun, type GlobalWithDeno, type GlobalWithProcess, hasBunRuntime, hasDenoRuntime, hasNodeProcess, } from "./runtime-guards.js";
|
|
14
|
+
export { __registerTraceContextGetter, __registerTraceContextGetter as registerTraceContextGetter, agentLogger, bundlerLogger, createRunUserLogger, logger, refreshLoggerConfig, rendererLogger, runWithRequestContextAsync, serverLogger, } from "./logger/index.js";
|
|
15
|
+
export type { Logger, RequestContext } from "./logger/index.js";
|
|
16
|
+
export { BREAKPOINT_LG, BREAKPOINT_MD, BREAKPOINT_SM, BREAKPOINT_XL, BYTES_PER_KB, DEFAULT_ALLOWED_CDN_HOSTS, DEFAULT_BUILD_CONCURRENCY, DEFAULT_DASHBOARD_PORT, DEFAULT_LRU_MAX_ENTRIES, DEV_SERVER_ENDPOINTS, FORBIDDEN_PATH_PATTERNS, getDenoStdNodeBase, getReactImportMap, HASH_SEED_DJB2, HASH_SEED_FNV1A, HMR_CLIENT_RELOAD_DELAY_MS, HMR_CLOSE_MESSAGE_TOO_LARGE, HMR_CLOSE_NORMAL, HMR_CLOSE_RATE_LIMIT, HMR_MAX_MESSAGE_SIZE_BYTES, HMR_MAX_MESSAGES_PER_MINUTE, HMR_RATE_LIMIT_WINDOW_MS, HTTP_BAD_REQUEST, HTTP_CONTENT_TYPE_IMAGE_GIF, HTTP_CONTENT_TYPE_IMAGE_ICO, HTTP_CONTENT_TYPE_IMAGE_JPEG, HTTP_CONTENT_TYPE_IMAGE_PNG, HTTP_CONTENT_TYPE_IMAGE_SVG, HTTP_CONTENT_TYPE_IMAGE_WEBP, HTTP_CONTENT_TYPES, HTTP_MODULE_FETCH_TIMEOUT_MS, HTTP_NETWORK_CONNECT_TIMEOUT, HTTP_NOT_FOUND, HTTP_NOT_IMPLEMENTED, HTTP_OK, HTTP_REDIRECT_FOUND, HTTP_SERVER_ERROR, HTTP_STATUS_CLIENT_ERROR_MIN, HTTP_STATUS_REDIRECT_MIN, HTTP_STATUS_SERVER_ERROR_MIN, HTTP_STATUS_SUCCESS_MIN, HTTP_UNAVAILABLE, IMAGE_OPTIMIZATION, MAX_BATCH_SIZE, MAX_PATH_LENGTH, MAX_PATH_TRAVERSAL_DEPTH, MS_PER_SECOND, PREFETCH_DEFAULT_DELAY_MS, PREFETCH_DEFAULT_TIMEOUT_MS, PREFETCH_MAX_SIZE_BYTES, REACT_DEFAULT_VERSION, RESPONSIVE_IMAGE_WIDTH_LG, RESPONSIVE_IMAGE_WIDTHS, RSC_MANIFEST_CACHE_TTL_MS, TSX_LAYOUT_MAX_ENTRIES, TSX_LAYOUT_PER_PROJECT_MAX_ENTRIES, Z_INDEX_DEV_INDICATOR, Z_INDEX_ERROR_OVERLAY, } from "./constants/index.js";
|
|
17
|
+
export { VERSION } from "./version.js";
|
|
18
|
+
export { type BundleCode as HashBundleCode, computeCodeHash, computeHash, fnv1aHash, shortHash, simpleHash, } from "./hash-utils.js";
|
|
19
|
+
export { MemoCache, memoize, memoizeAsync, simpleHash as memoizeHash } from "./memoize.js";
|
|
20
|
+
export { normalizePath } from "./path-utils.js";
|
|
21
|
+
export { type BundleCode, type BundleMetadata, getBundleManifestStore } from "./bundle-manifest.js";
|
|
22
|
+
export { isRSCEnabled } from "./feature-flags.js";
|
|
23
|
+
export { isCompiledBinary } from "./platform.js";
|
|
24
|
+
export { computeIntegrity, createLockfileManager, type LockfileManager, } from "./import-lockfile.js";
|
|
25
|
+
export { endRequest, isEnabled, startRequest, startTimer, timeAsync } from "./perf-timer.js";
|
|
26
|
+
export { parallelMap } from "./parallel.js";
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,IAAI,0BAA0B,EAC1D,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,MAAM,EACN,mBAAmB,EACnB,cAAc,EACd,0BAA0B,EAC1B,YAAY,GAC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,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEpG,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,eAAe,GACrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE7F,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime detection, logging, constants, hashing, and feature flags.
|
|
3
|
+
*
|
|
4
|
+
* @module utils
|
|
5
|
+
*
|
|
6
|
+
* @example Structured logging
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { serverLogger } from "veryfront/utils";
|
|
9
|
+
*
|
|
10
|
+
* serverLogger.info("Booting server", { project_id: "proj_123" });
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export { hasBunRuntime, hasDenoRuntime, hasNodeProcess, } from "./runtime-guards.js";
|
|
14
|
+
export { __registerTraceContextGetter, __registerTraceContextGetter as registerTraceContextGetter, agentLogger, bundlerLogger, createRunUserLogger, logger, refreshLoggerConfig, rendererLogger, runWithRequestContextAsync, serverLogger, } from "./logger/index.js";
|
|
15
|
+
export { BREAKPOINT_LG, BREAKPOINT_MD, BREAKPOINT_SM, BREAKPOINT_XL, BYTES_PER_KB, DEFAULT_ALLOWED_CDN_HOSTS, DEFAULT_BUILD_CONCURRENCY, DEFAULT_DASHBOARD_PORT, DEFAULT_LRU_MAX_ENTRIES, DEV_SERVER_ENDPOINTS, FORBIDDEN_PATH_PATTERNS, getDenoStdNodeBase, getReactImportMap, HASH_SEED_DJB2, HASH_SEED_FNV1A, HMR_CLIENT_RELOAD_DELAY_MS, HMR_CLOSE_MESSAGE_TOO_LARGE, HMR_CLOSE_NORMAL, HMR_CLOSE_RATE_LIMIT, HMR_MAX_MESSAGE_SIZE_BYTES, HMR_MAX_MESSAGES_PER_MINUTE, HMR_RATE_LIMIT_WINDOW_MS, HTTP_BAD_REQUEST, HTTP_CONTENT_TYPE_IMAGE_GIF, HTTP_CONTENT_TYPE_IMAGE_ICO, HTTP_CONTENT_TYPE_IMAGE_JPEG, HTTP_CONTENT_TYPE_IMAGE_PNG, HTTP_CONTENT_TYPE_IMAGE_SVG, HTTP_CONTENT_TYPE_IMAGE_WEBP, HTTP_CONTENT_TYPES, HTTP_MODULE_FETCH_TIMEOUT_MS, HTTP_NETWORK_CONNECT_TIMEOUT, HTTP_NOT_FOUND, HTTP_NOT_IMPLEMENTED, HTTP_OK, HTTP_REDIRECT_FOUND, HTTP_SERVER_ERROR, HTTP_STATUS_CLIENT_ERROR_MIN, HTTP_STATUS_REDIRECT_MIN, HTTP_STATUS_SERVER_ERROR_MIN, HTTP_STATUS_SUCCESS_MIN, HTTP_UNAVAILABLE, IMAGE_OPTIMIZATION, MAX_BATCH_SIZE, MAX_PATH_LENGTH, MAX_PATH_TRAVERSAL_DEPTH, MS_PER_SECOND, PREFETCH_DEFAULT_DELAY_MS, PREFETCH_DEFAULT_TIMEOUT_MS, PREFETCH_MAX_SIZE_BYTES, REACT_DEFAULT_VERSION, RESPONSIVE_IMAGE_WIDTH_LG, RESPONSIVE_IMAGE_WIDTHS, RSC_MANIFEST_CACHE_TTL_MS, TSX_LAYOUT_MAX_ENTRIES, TSX_LAYOUT_PER_PROJECT_MAX_ENTRIES, Z_INDEX_DEV_INDICATOR, Z_INDEX_ERROR_OVERLAY, } from "./constants/index.js";
|
|
16
|
+
export { VERSION } from "./version.js";
|
|
17
|
+
export { computeCodeHash, computeHash, fnv1aHash, shortHash, simpleHash, } from "./hash-utils.js";
|
|
18
|
+
export { MemoCache, memoize, memoizeAsync, simpleHash as memoizeHash } from "./memoize.js";
|
|
19
|
+
export { normalizePath } from "./path-utils.js";
|
|
20
|
+
export { getBundleManifestStore } from "./bundle-manifest.js";
|
|
21
|
+
export { isRSCEnabled } from "./feature-flags.js";
|
|
22
|
+
export { isCompiledBinary } from "./platform.js";
|
|
23
|
+
export { computeIntegrity, createLockfileManager, } from "./import-lockfile.js";
|
|
24
|
+
export { endRequest, isEnabled, startRequest, startTimer, timeAsync } from "./perf-timer.js";
|
|
25
|
+
export { parallelMap } from "./parallel.js";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical component names for structured logging.
|
|
3
|
+
*
|
|
4
|
+
* These names are used with `logger.component("name")` to create
|
|
5
|
+
* component-scoped loggers. The component field appears in JSON output
|
|
6
|
+
* for Grafana/Loki filtering and as `[name]` in text output.
|
|
7
|
+
*
|
|
8
|
+
* Convention: lowercase-kebab-case.
|
|
9
|
+
* Not enforced at runtime — any string is accepted. This registry is a
|
|
10
|
+
* non-exhaustive reference to promote reuse and discoverability.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
export declare const LogComponents: {
|
|
15
|
+
readonly server: "server";
|
|
16
|
+
readonly config: "config";
|
|
17
|
+
readonly middleware: "middleware";
|
|
18
|
+
readonly cors: "cors";
|
|
19
|
+
readonly security: "security";
|
|
20
|
+
readonly discovery: "discovery";
|
|
21
|
+
readonly pipeline: "pipeline";
|
|
22
|
+
readonly global: "global";
|
|
23
|
+
readonly ssr: "ssr";
|
|
24
|
+
readonly ssrService: "ssr-service";
|
|
25
|
+
readonly ssrOrchestrator: "ssr-orchestrator";
|
|
26
|
+
readonly rsc: "rsc";
|
|
27
|
+
readonly html: "html";
|
|
28
|
+
readonly htmlGenerator: "html-generator";
|
|
29
|
+
readonly mdx: "mdx";
|
|
30
|
+
readonly mdxCompiler: "mdx-compiler";
|
|
31
|
+
readonly mdxCache: "mdx-cache";
|
|
32
|
+
readonly hmr: "hmr";
|
|
33
|
+
readonly hmrHandler: "hmr-handler";
|
|
34
|
+
readonly hmrServer: "hmr-server";
|
|
35
|
+
readonly renderer: "renderer";
|
|
36
|
+
readonly snippetRenderer: "snippet-renderer";
|
|
37
|
+
readonly build: "build";
|
|
38
|
+
readonly esm: "esm";
|
|
39
|
+
readonly esmTransform: "esm-transform";
|
|
40
|
+
readonly ssrTransform: "ssr-transform";
|
|
41
|
+
readonly ssrModuleLoader: "ssr-module-loader";
|
|
42
|
+
readonly moduleLoader: "module-loader";
|
|
43
|
+
readonly moduleServer: "module-server";
|
|
44
|
+
readonly cache: "cache";
|
|
45
|
+
readonly cacheRegistry: "cache-registry";
|
|
46
|
+
readonly distributedCache: "distributed-cache";
|
|
47
|
+
readonly httpCache: "http-cache";
|
|
48
|
+
readonly httpCacheWrapper: "http-cache-wrapper";
|
|
49
|
+
readonly ssrHttpCache: "ssr-http-cache";
|
|
50
|
+
readonly fileCache: "file-cache";
|
|
51
|
+
readonly moduleCache: "module-cache";
|
|
52
|
+
readonly transformCache: "transform-cache";
|
|
53
|
+
readonly api: "api";
|
|
54
|
+
readonly httpHandler: "http-handler";
|
|
55
|
+
readonly client: "client";
|
|
56
|
+
readonly runtimeHandler: "runtime-handler";
|
|
57
|
+
readonly redis: "redis";
|
|
58
|
+
readonly fsIntegration: "fs-integration";
|
|
59
|
+
readonly readOperations: "read-operations";
|
|
60
|
+
readonly otel: "otel";
|
|
61
|
+
readonly tracing: "tracing";
|
|
62
|
+
readonly metrics: "metrics";
|
|
63
|
+
readonly autoInstrument: "auto-instrument";
|
|
64
|
+
readonly perf: "perf";
|
|
65
|
+
readonly agent: "agent";
|
|
66
|
+
readonly tool: "tool";
|
|
67
|
+
readonly workflowDiscovery: "workflow-discovery";
|
|
68
|
+
readonly validator: "validator";
|
|
69
|
+
readonly error: "error";
|
|
70
|
+
readonly env: "env";
|
|
71
|
+
};
|
|
72
|
+
export type LogComponent = (typeof LogComponents)[keyof typeof LogComponents];
|
|
73
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../../src/src/utils/logger/components.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4EhB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical component names for structured logging.
|
|
3
|
+
*
|
|
4
|
+
* These names are used with `logger.component("name")` to create
|
|
5
|
+
* component-scoped loggers. The component field appears in JSON output
|
|
6
|
+
* for Grafana/Loki filtering and as `[name]` in text output.
|
|
7
|
+
*
|
|
8
|
+
* Convention: lowercase-kebab-case.
|
|
9
|
+
* Not enforced at runtime — any string is accepted. This registry is a
|
|
10
|
+
* non-exhaustive reference to promote reuse and discoverability.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
export const LogComponents = {
|
|
15
|
+
// Server & infrastructure
|
|
16
|
+
server: "server",
|
|
17
|
+
config: "config",
|
|
18
|
+
middleware: "middleware",
|
|
19
|
+
cors: "cors",
|
|
20
|
+
security: "security",
|
|
21
|
+
discovery: "discovery",
|
|
22
|
+
pipeline: "pipeline",
|
|
23
|
+
global: "global",
|
|
24
|
+
// Rendering
|
|
25
|
+
ssr: "ssr",
|
|
26
|
+
ssrService: "ssr-service",
|
|
27
|
+
ssrOrchestrator: "ssr-orchestrator",
|
|
28
|
+
rsc: "rsc",
|
|
29
|
+
html: "html",
|
|
30
|
+
htmlGenerator: "html-generator",
|
|
31
|
+
mdx: "mdx",
|
|
32
|
+
mdxCompiler: "mdx-compiler",
|
|
33
|
+
mdxCache: "mdx-cache",
|
|
34
|
+
hmr: "hmr",
|
|
35
|
+
hmrHandler: "hmr-handler",
|
|
36
|
+
hmrServer: "hmr-server",
|
|
37
|
+
renderer: "renderer",
|
|
38
|
+
snippetRenderer: "snippet-renderer",
|
|
39
|
+
// Build & transforms
|
|
40
|
+
build: "build",
|
|
41
|
+
esm: "esm",
|
|
42
|
+
esmTransform: "esm-transform",
|
|
43
|
+
ssrTransform: "ssr-transform",
|
|
44
|
+
ssrModuleLoader: "ssr-module-loader",
|
|
45
|
+
moduleLoader: "module-loader",
|
|
46
|
+
moduleServer: "module-server",
|
|
47
|
+
// Caching
|
|
48
|
+
cache: "cache",
|
|
49
|
+
cacheRegistry: "cache-registry",
|
|
50
|
+
distributedCache: "distributed-cache",
|
|
51
|
+
httpCache: "http-cache",
|
|
52
|
+
httpCacheWrapper: "http-cache-wrapper",
|
|
53
|
+
ssrHttpCache: "ssr-http-cache",
|
|
54
|
+
fileCache: "file-cache",
|
|
55
|
+
moduleCache: "module-cache",
|
|
56
|
+
transformCache: "transform-cache",
|
|
57
|
+
// API & HTTP
|
|
58
|
+
api: "api",
|
|
59
|
+
httpHandler: "http-handler",
|
|
60
|
+
client: "client",
|
|
61
|
+
runtimeHandler: "runtime-handler",
|
|
62
|
+
// Platform & adapters
|
|
63
|
+
redis: "redis",
|
|
64
|
+
fsIntegration: "fs-integration",
|
|
65
|
+
readOperations: "read-operations",
|
|
66
|
+
// Observability
|
|
67
|
+
otel: "otel",
|
|
68
|
+
tracing: "tracing",
|
|
69
|
+
metrics: "metrics",
|
|
70
|
+
autoInstrument: "auto-instrument",
|
|
71
|
+
perf: "perf",
|
|
72
|
+
// Agent & AI
|
|
73
|
+
agent: "agent",
|
|
74
|
+
tool: "tool",
|
|
75
|
+
// Workflow
|
|
76
|
+
workflowDiscovery: "workflow-discovery",
|
|
77
|
+
// Misc
|
|
78
|
+
validator: "validator",
|
|
79
|
+
error: "error",
|
|
80
|
+
env: "env",
|
|
81
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared logger formatting utilities.
|
|
3
|
+
* This module contains pure formatting functions with no external dependencies,
|
|
4
|
+
* enabling reuse between the main logger and proxy logger.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
export declare const TAG_WIDTH = 10;
|
|
9
|
+
export declare const PREFIX_WIDTH = 23;
|
|
10
|
+
export type LogLevelName = "debug" | "info" | "warn" | "error";
|
|
11
|
+
export declare const LEVEL_GLYPHS: Record<LogLevelName, string>;
|
|
12
|
+
export declare const ANSI: {
|
|
13
|
+
readonly reset: "\u001B[0m";
|
|
14
|
+
readonly dim: "\u001B[2m";
|
|
15
|
+
readonly gray: "\u001B[90m";
|
|
16
|
+
readonly red: "\u001B[31m";
|
|
17
|
+
readonly green: "\u001B[32m";
|
|
18
|
+
readonly yellow: "\u001B[33m";
|
|
19
|
+
readonly blue: "\u001B[34m";
|
|
20
|
+
readonly magenta: "\u001B[35m";
|
|
21
|
+
readonly cyan: "\u001B[36m";
|
|
22
|
+
};
|
|
23
|
+
export declare const LEVEL_COLORS: Record<LogLevelName, string>;
|
|
24
|
+
/**
|
|
25
|
+
* Pad or truncate a tag to fixed width for aligned output.
|
|
26
|
+
*/
|
|
27
|
+
export declare function padTag(tag: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Format a timestamp as HH:MM:SS.
|
|
30
|
+
*/
|
|
31
|
+
export declare function formatTimestamp(date?: Date): string;
|
|
32
|
+
/**
|
|
33
|
+
* Apply ANSI color codes to text if enabled.
|
|
34
|
+
*/
|
|
35
|
+
export declare function colorize(text: string, color: string | undefined, enable: boolean): string;
|
|
36
|
+
/**
|
|
37
|
+
* Normalize whitespace in text (collapse multiple spaces to single space).
|
|
38
|
+
*/
|
|
39
|
+
export declare function normalizeText(value: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Truncate text to maxLength, adding ellipsis if truncated.
|
|
42
|
+
*/
|
|
43
|
+
export declare function truncateText(value: string, maxLength?: number): string;
|
|
44
|
+
/**
|
|
45
|
+
* Format a value for log output (handles strings, numbers, booleans, objects).
|
|
46
|
+
*/
|
|
47
|
+
export declare function formatValue(value: unknown): string;
|
|
48
|
+
/**
|
|
49
|
+
* Serialized error structure for structured logging.
|
|
50
|
+
*/
|
|
51
|
+
export interface SerializedError {
|
|
52
|
+
name: string;
|
|
53
|
+
message: string;
|
|
54
|
+
stack?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Format a serialized error for text output.
|
|
58
|
+
*/
|
|
59
|
+
export declare function formatErrorText(error: SerializedError | undefined): string;
|
|
60
|
+
/**
|
|
61
|
+
* Serialize an error object for structured logging.
|
|
62
|
+
*/
|
|
63
|
+
export declare function serializeError(error: unknown): SerializedError | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Format context and error as indented key=value pairs.
|
|
66
|
+
* Filters out undefined values for cleaner output.
|
|
67
|
+
*/
|
|
68
|
+
export declare function formatContextText(context: Record<string, unknown>, error: SerializedError | undefined, enableColor: boolean): string;
|
|
69
|
+
/**
|
|
70
|
+
* Check if value is a non-null, non-array object (plain record).
|
|
71
|
+
*/
|
|
72
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
73
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../src/src/utils/logger/core.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE/D,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAKrD,CAAC;AAEF,eAAO,MAAM,IAAI;;;;;;;;;;CAUP,CAAC;AA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