This commit is contained in:
parent
85ad7f7387
commit
e9e2723c28
30 changed files with 380 additions and 44 deletions
|
|
@ -14,6 +14,8 @@ export type EquityPrintJoinRecord = {
|
|||
join_quality_json: string;
|
||||
};
|
||||
|
||||
type JsonPrimitiveRecord = Record<string, string | number | boolean>;
|
||||
|
||||
export const equityPrintJoinsTableDDL = (): string => {
|
||||
return `
|
||||
CREATE TABLE IF NOT EXISTS ${EQUITY_PRINT_JOINS_TABLE} (
|
||||
|
|
@ -46,11 +48,11 @@ export const toEquityPrintJoinRecord = (join: EquityPrintJoin): EquityPrintJoinR
|
|||
};
|
||||
};
|
||||
|
||||
const safeJson = (value: string, fallback: Record<string, unknown>): Record<string, unknown> => {
|
||||
const safeJson = (value: string, fallback: JsonPrimitiveRecord): JsonPrimitiveRecord => {
|
||||
try {
|
||||
const parsed = JSON.parse(value);
|
||||
if (parsed && typeof parsed === "object") {
|
||||
return parsed as Record<string, unknown>;
|
||||
return parsed as JsonPrimitiveRecord;
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ export type FlowPacketRecord = {
|
|||
join_quality_json: string;
|
||||
};
|
||||
|
||||
type JsonPrimitiveRecord = Record<string, string | number | boolean>;
|
||||
|
||||
export const flowPacketsTableDDL = (): string => {
|
||||
return `
|
||||
CREATE TABLE IF NOT EXISTS ${FLOW_PACKETS_TABLE} (
|
||||
|
|
@ -43,11 +45,11 @@ export const toFlowPacketRecord = (packet: FlowPacket): FlowPacketRecord => {
|
|||
};
|
||||
};
|
||||
|
||||
const safeJson = (value: string, fallback: Record<string, unknown>): Record<string, unknown> => {
|
||||
const safeJson = (value: string, fallback: JsonPrimitiveRecord): JsonPrimitiveRecord => {
|
||||
try {
|
||||
const parsed = JSON.parse(value);
|
||||
if (parsed && typeof parsed === "object") {
|
||||
return parsed as Record<string, unknown>;
|
||||
return parsed as JsonPrimitiveRecord;
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"types": []
|
||||
"types": ["bun"]
|
||||
},
|
||||
"include": ["src/**/*.ts", "tests/**/*.ts"]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue