CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
common.cjs84 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 common_exports = {};20__export(common_exports, {21  SQLiteColumn: () => SQLiteColumn,22  SQLiteColumnBuilder: () => SQLiteColumnBuilder23});24module.exports = __toCommonJS(common_exports);25var import_column_builder = require("../../column-builder.cjs");26var import_column = require("../../column.cjs");27var import_entity = require("../../entity.cjs");28var import_foreign_keys = require("../foreign-keys.cjs");29var import_unique_constraint = require("../unique-constraint.cjs");30class SQLiteColumnBuilder extends import_column_builder.ColumnBuilder {31  static [import_entity.entityKind] = "SQLiteColumnBuilder";32  foreignKeyConfigs = [];33  references(ref, actions = {}) {34    this.foreignKeyConfigs.push({ ref, actions });35    return this;36  }37  unique(name) {38    this.config.isUnique = true;39    this.config.uniqueName = name;40    return this;41  }42  generatedAlwaysAs(as, config) {43    this.config.generated = {44      as,45      type: "always",46      mode: config?.mode ?? "virtual"47    };48    return this;49  }50  /** @internal */51  buildForeignKeys(column, table) {52    return this.foreignKeyConfigs.map(({ ref, actions }) => {53      return ((ref2, actions2) => {54        const builder = new import_foreign_keys.ForeignKeyBuilder(() => {55          const foreignColumn = ref2();56          return { columns: [column], foreignColumns: [foreignColumn] };57        });58        if (actions2.onUpdate) {59          builder.onUpdate(actions2.onUpdate);60        }61        if (actions2.onDelete) {62          builder.onDelete(actions2.onDelete);63        }64        return builder.build(table);65      })(ref, actions);66    });67  }68}69class SQLiteColumn extends import_column.Column {70  constructor(table, config) {71    if (!config.uniqueName) {72      config.uniqueName = (0, import_unique_constraint.uniqueKeyName)(table, [config.name]);73    }74    super(table, config);75    this.table = table;76  }77  static [import_entity.entityKind] = "SQLiteColumn";78}79// Annotate the CommonJS export names for ESM import in node:800 && (module.exports = {81  SQLiteColumn,82  SQLiteColumnBuilder83});84//# sourceMappingURL=common.cjs.map