TenantAtlas/apps/platform/.pnpm-store/v10/files/a6/99d7f58ba8139a7f0fd240ff79560e4d0e9e79c949d99c0b2d0c9130990514756d1866f6e399985a961f2e1efcb740a4bdfd86e258f2587fbd4bdcf4382196
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

51 lines
1.6 KiB
Plaintext

import { entityKind } from "../../entity.js";
import { getColumnNameAndConfig } from "../../utils.js";
import { SingleStoreColumn, SingleStoreColumnBuilder } from "./common.js";
class SingleStoreCustomColumnBuilder extends SingleStoreColumnBuilder {
static [entityKind] = "SingleStoreCustomColumnBuilder";
constructor(name, fieldConfig, customTypeParams) {
super(name, "custom", "SingleStoreCustomColumn");
this.config.fieldConfig = fieldConfig;
this.config.customTypeParams = customTypeParams;
}
/** @internal */
build(table) {
return new SingleStoreCustomColumn(
table,
this.config
);
}
}
class SingleStoreCustomColumn extends SingleStoreColumn {
static [entityKind] = "SingleStoreCustomColumn";
sqlName;
mapTo;
mapFrom;
constructor(table, config) {
super(table, config);
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
this.mapTo = config.customTypeParams.toDriver;
this.mapFrom = config.customTypeParams.fromDriver;
}
getSQLType() {
return this.sqlName;
}
mapFromDriverValue(value) {
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
}
mapToDriverValue(value) {
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
}
}
function customType(customTypeParams) {
return (a, b) => {
const { name, config } = getColumnNameAndConfig(a, b);
return new SingleStoreCustomColumnBuilder(name, config, customTypeParams);
};
}
export {
SingleStoreCustomColumn,
SingleStoreCustomColumnBuilder,
customType
};
//# sourceMappingURL=custom.js.map