CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
custom.cjs81 linesDownload Raw Back to columns
1"use strict";2var __defProp = Object.defineProperty;3var __getOwnPropDesc = Object.getOwnPropertyDescriptor;4var __getOwnPropNames = Object.getOwnPropertyNames;5var __hasOwnProp = Object.prototype.hasOwnProperty;6var __export = (target, all) => {7  for (var name in all)8    __defProp(target, name, { get: all[name], enumerable: true });9};10var __copyProps = (to, from, except, desc) => {11  if (from && typeof from === "object" || typeof from === "function") {12    for (let key of __getOwnPropNames(from))13      if (!__hasOwnProp.call(to, key) && key !== except)14        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });15  }16  return to;17};18var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);19var custom_exports = {};20__export(custom_exports, {21  SQLiteCustomColumn: () => SQLiteCustomColumn,22  SQLiteCustomColumnBuilder: () => SQLiteCustomColumnBuilder,23  customType: () => customType24});25module.exports = __toCommonJS(custom_exports);26var import_entity = require("../../entity.cjs");27var import_utils = require("../../utils.cjs");28var import_common = require("./common.cjs");29class SQLiteCustomColumnBuilder extends import_common.SQLiteColumnBuilder {30  static [import_entity.entityKind] = "SQLiteCustomColumnBuilder";31  constructor(name, fieldConfig, customTypeParams) {32    super(name, "custom", "SQLiteCustomColumn");33    this.config.fieldConfig = fieldConfig;34    this.config.customTypeParams = customTypeParams;35  }36  /** @internal */37  build(table) {38    return new SQLiteCustomColumn(39      table,40      this.config41    );42  }43}44class SQLiteCustomColumn extends import_common.SQLiteColumn {45  static [import_entity.entityKind] = "SQLiteCustomColumn";46  sqlName;47  mapTo;48  mapFrom;49  constructor(table, config) {50    super(table, config);51    this.sqlName = config.customTypeParams.dataType(config.fieldConfig);52    this.mapTo = config.customTypeParams.toDriver;53    this.mapFrom = config.customTypeParams.fromDriver;54  }55  getSQLType() {56    return this.sqlName;57  }58  mapFromDriverValue(value) {59    return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;60  }61  mapToDriverValue(value) {62    return typeof this.mapTo === "function" ? this.mapTo(value) : value;63  }64}65function customType(customTypeParams) {66  return (a, b) => {67    const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);68    return new SQLiteCustomColumnBuilder(69      name,70      config,71      customTypeParams72    );73  };74}75// Annotate the CommonJS export names for ESM import in node:760 && (module.exports = {77  SQLiteCustomColumn,78  SQLiteCustomColumnBuilder,79  customType80});81//# sourceMappingURL=custom.cjs.map