updated config files and starting work on utils lib

This commit is contained in:
Boki 2025-06-19 09:35:03 -04:00
parent 8e218cb802
commit 25d9f2dd85
20 changed files with 900 additions and 9 deletions

View file

@ -55,7 +55,7 @@ export class SecretValue<T = string> {
/**
* Zod schema for secret values
*/
export const secretSchema = <T extends z.ZodTypeAny>(schema: T) => {
export const secretSchema = <T extends z.ZodTypeAny>(_schema: T) => {
return z.custom<SecretValue<z.infer<T>>>(
(val) => val instanceof SecretValue,
{
@ -100,15 +100,16 @@ export function redactSecrets<T extends Record<string, any>>(
let current: any = result;
for (let i = 0; i < keys.length - 1; i++) {
if (current[keys[i]] && typeof current[keys[i]] === 'object') {
current = current[keys[i]];
const key = keys[i];
if (key && current[key] && typeof current[key] === 'object') {
current = current[key];
} else {
break;
}
}
const lastKey = keys[keys.length - 1];
if (current && lastKey in current) {
if (current && lastKey && lastKey in current) {
current[lastKey] = '***REDACTED***';
}
}

View file

@ -1,5 +1,4 @@
import { z } from 'zod';
import { ConfigValidationError } from '../errors';
export interface ValidationResult {
valid: boolean;
@ -58,7 +57,7 @@ export function checkDeprecations(
if (pathStr in deprecations) {
warnings?.push({
path: pathStr,
message: deprecations[pathStr],
message: deprecations[pathStr]!,
});
}
@ -183,10 +182,10 @@ export function mergeSchemas<T extends z.ZodSchema[]>(
throw new Error('At least two schemas required for merge');
}
let result = schemas[0].and(schemas[1]);
let result = schemas[0]!.and(schemas[1]!);
for (let i = 2; i < schemas.length; i++) {
result = result.and(schemas[i]) as any;
result = result.and(schemas[i]!) as any;
}
return result as any;