utils.ts — astro Source File
Architecture documentation for utils.ts, a typescript file in the astro codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 924e15be_41c4_285d_a2d3_ec38d467be5a["utils.ts"] 91decf0f_8a76_7391_4c56_d2f49dbb7487["client"] 924e15be_41c4_285d_a2d3_ec38d467be5a --> 91decf0f_8a76_7391_4c56_d2f49dbb7487 f8c9251e_f535_6281_2118_9e79a4155212["v4"] 924e15be_41c4_285d_a2d3_ec38d467be5a --> f8c9251e_f535_6281_2118_9e79a4155212 style 924e15be_41c4_285d_a2d3_ec38d467be5a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { Config as LibSQLConfig } from '@libsql/client';
import * as z from 'zod/v4';
const rawLibSQLOptions = z.record(z.string(), z.string());
const parseNumber = (value: string) => z.coerce.number().parse(value);
const parseBoolean = (value: string) => z.coerce.boolean().parse(value);
const booleanValues = ['true', 'false'];
// parse a value that should be a boolean, but could be a valueless variable:
// e.g. 'file://local-copy.db?readYourWrites' & 'file://local-copy.db?readYourWrites=true' should be parsed as true
const parseOptionalBoolean = (value: string) => {
if (booleanValues.includes(value)) {
return parseBoolean(value);
}
return true; // If the value is not explicitly 'true' or 'false', assume it's true (valueless variable)
};
const libSQLConfigTransformed = rawLibSQLOptions.transform((raw) => {
// Ensure the URL is always present
const parsed: Partial<LibSQLConfig> = {};
// Optional fields
for (const [key, value] of Object.entries(raw)) {
switch (key) {
case 'syncInterval':
case 'concurrency':
parsed[key] = parseNumber(value);
break;
case 'readYourWrites':
case 'offline':
case 'tls':
parsed[key] = parseOptionalBoolean(value);
break;
case 'authToken':
case 'encryptionKey':
case 'syncUrl':
parsed[key] = value;
break;
}
}
// Return the parsed config
return parsed;
});
export const parseLibSQLConfig = (config: Record<string, string>): Partial<LibSQLConfig> => {
try {
return libSQLConfigTransformed.parse(config);
} catch (error) {
if (error instanceof z.ZodError) {
throw new Error(`Invalid LibSQL config: ${error.issues.map((e) => e.message).join(', ')}`);
}
throw error;
}
};
Domain
Subdomains
Functions
Dependencies
- client
- v4
Source
Frequently Asked Questions
What does utils.ts do?
utils.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, CoreMiddleware subdomain.
What functions are defined in utils.ts?
utils.ts defines 5 function(s): libSQLConfigTransformed, parseBoolean, parseLibSQLConfig, parseNumber, parseOptionalBoolean.
What does utils.ts depend on?
utils.ts imports 2 module(s): client, v4.
Where is utils.ts in the architecture?
utils.ts is located at packages/db/src/core/db-client/utils.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/db/src/core/db-client).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free