TenantAtlas/apps/platform/.pnpm-store/v10/files/e8/054f2339579080c1eeafc00ed2ac3a3809e9298ba496a8faa1f5881599bf6ac7e499d3564c91d1d0ea382dcc2a82b742cb232a4bb4837213309e5a4fad0376
Ahmed Darrazi 9f74f7a658
Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 51s
feat: compress governance operator outcomes
2026-04-19 14:15:11 +02:00

86 lines
2.2 KiB
Plaintext

import { entityKind } from "../../entity.js";
import { getColumnNameAndConfig } from "../../utils.js";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.js";
class SQLiteNumericBuilder extends SQLiteColumnBuilder {
static [entityKind] = "SQLiteNumericBuilder";
constructor(name) {
super(name, "string", "SQLiteNumeric");
}
/** @internal */
build(table) {
return new SQLiteNumeric(
table,
this.config
);
}
}
class SQLiteNumeric extends SQLiteColumn {
static [entityKind] = "SQLiteNumeric";
mapFromDriverValue(value) {
if (typeof value === "string") return value;
return String(value);
}
getSQLType() {
return "numeric";
}
}
class SQLiteNumericNumberBuilder extends SQLiteColumnBuilder {
static [entityKind] = "SQLiteNumericNumberBuilder";
constructor(name) {
super(name, "number", "SQLiteNumericNumber");
}
/** @internal */
build(table) {
return new SQLiteNumericNumber(
table,
this.config
);
}
}
class SQLiteNumericNumber extends SQLiteColumn {
static [entityKind] = "SQLiteNumericNumber";
mapFromDriverValue(value) {
if (typeof value === "number") return value;
return Number(value);
}
mapToDriverValue = String;
getSQLType() {
return "numeric";
}
}
class SQLiteNumericBigIntBuilder extends SQLiteColumnBuilder {
static [entityKind] = "SQLiteNumericBigIntBuilder";
constructor(name) {
super(name, "bigint", "SQLiteNumericBigInt");
}
/** @internal */
build(table) {
return new SQLiteNumericBigInt(
table,
this.config
);
}
}
class SQLiteNumericBigInt extends SQLiteColumn {
static [entityKind] = "SQLiteNumericBigInt";
mapFromDriverValue = BigInt;
mapToDriverValue = String;
getSQLType() {
return "numeric";
}
}
function numeric(a, b) {
const { name, config } = getColumnNameAndConfig(a, b);
const mode = config?.mode;
return mode === "number" ? new SQLiteNumericNumberBuilder(name) : mode === "bigint" ? new SQLiteNumericBigIntBuilder(name) : new SQLiteNumericBuilder(name);
}
export {
SQLiteNumeric,
SQLiteNumericBigInt,
SQLiteNumericBigIntBuilder,
SQLiteNumericBuilder,
SQLiteNumericNumber,
SQLiteNumericNumberBuilder,
numeric
};
//# sourceMappingURL=numeric.js.map