table.cjs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __hasOwnProp = Object.prototype.hasOwnProperty;
  6. var __export = (target, all) => {
  7. for (var name in all)
  8. __defProp(target, name, { get: all[name], enumerable: true });
  9. };
  10. var __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. };
  18. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  19. var table_exports = {};
  20. __export(table_exports, {
  21. SingleStoreTable: () => SingleStoreTable,
  22. singlestoreTable: () => singlestoreTable,
  23. singlestoreTableCreator: () => singlestoreTableCreator,
  24. singlestoreTableWithSchema: () => singlestoreTableWithSchema
  25. });
  26. module.exports = __toCommonJS(table_exports);
  27. var import_entity = require("../entity.cjs");
  28. var import_table = require("../table.cjs");
  29. var import_all = require("./columns/all.cjs");
  30. class SingleStoreTable extends import_table.Table {
  31. static [import_entity.entityKind] = "SingleStoreTable";
  32. /** @internal */
  33. static Symbol = Object.assign({}, import_table.Table.Symbol, {});
  34. /** @internal */
  35. [import_table.Table.Symbol.Columns];
  36. /** @internal */
  37. [import_table.Table.Symbol.ExtraConfigBuilder] = void 0;
  38. }
  39. function singlestoreTableWithSchema(name, columns, extraConfig, schema, baseName = name) {
  40. const rawTable = new SingleStoreTable(name, schema, baseName);
  41. const parsedColumns = typeof columns === "function" ? columns((0, import_all.getSingleStoreColumnBuilders)()) : columns;
  42. const builtColumns = Object.fromEntries(
  43. Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
  44. const colBuilder = colBuilderBase;
  45. colBuilder.setName(name2);
  46. const column = colBuilder.build(rawTable);
  47. return [name2, column];
  48. })
  49. );
  50. const table = Object.assign(rawTable, builtColumns);
  51. table[import_table.Table.Symbol.Columns] = builtColumns;
  52. table[import_table.Table.Symbol.ExtraConfigColumns] = builtColumns;
  53. if (extraConfig) {
  54. table[SingleStoreTable.Symbol.ExtraConfigBuilder] = extraConfig;
  55. }
  56. return table;
  57. }
  58. const singlestoreTable = (name, columns, extraConfig) => {
  59. return singlestoreTableWithSchema(name, columns, extraConfig, void 0, name);
  60. };
  61. function singlestoreTableCreator(customizeTableName) {
  62. return (name, columns, extraConfig) => {
  63. return singlestoreTableWithSchema(customizeTableName(name), columns, extraConfig, void 0, name);
  64. };
  65. }
  66. // Annotate the CommonJS export names for ESM import in node:
  67. 0 && (module.exports = {
  68. SingleStoreTable,
  69. singlestoreTable,
  70. singlestoreTableCreator,
  71. singlestoreTableWithSchema
  72. });
  73. //# sourceMappingURL=table.cjs.map