line.cjs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 line_exports = {};
  20. __export(line_exports, {
  21. PgLineABC: () => PgLineABC,
  22. PgLineABCBuilder: () => PgLineABCBuilder,
  23. PgLineBuilder: () => PgLineBuilder,
  24. PgLineTuple: () => PgLineTuple,
  25. line: () => line
  26. });
  27. module.exports = __toCommonJS(line_exports);
  28. var import_entity = require("../../entity.cjs");
  29. var import_utils = require("../../utils.cjs");
  30. var import_common = require("./common.cjs");
  31. class PgLineBuilder extends import_common.PgColumnBuilder {
  32. static [import_entity.entityKind] = "PgLineBuilder";
  33. constructor(name) {
  34. super(name, "array", "PgLine");
  35. }
  36. /** @internal */
  37. build(table) {
  38. return new PgLineTuple(
  39. table,
  40. this.config
  41. );
  42. }
  43. }
  44. class PgLineTuple extends import_common.PgColumn {
  45. static [import_entity.entityKind] = "PgLine";
  46. getSQLType() {
  47. return "line";
  48. }
  49. mapFromDriverValue(value) {
  50. const [a, b, c] = value.slice(1, -1).split(",");
  51. return [Number.parseFloat(a), Number.parseFloat(b), Number.parseFloat(c)];
  52. }
  53. mapToDriverValue(value) {
  54. return `{${value[0]},${value[1]},${value[2]}}`;
  55. }
  56. }
  57. class PgLineABCBuilder extends import_common.PgColumnBuilder {
  58. static [import_entity.entityKind] = "PgLineABCBuilder";
  59. constructor(name) {
  60. super(name, "json", "PgLineABC");
  61. }
  62. /** @internal */
  63. build(table) {
  64. return new PgLineABC(
  65. table,
  66. this.config
  67. );
  68. }
  69. }
  70. class PgLineABC extends import_common.PgColumn {
  71. static [import_entity.entityKind] = "PgLineABC";
  72. getSQLType() {
  73. return "line";
  74. }
  75. mapFromDriverValue(value) {
  76. const [a, b, c] = value.slice(1, -1).split(",");
  77. return { a: Number.parseFloat(a), b: Number.parseFloat(b), c: Number.parseFloat(c) };
  78. }
  79. mapToDriverValue(value) {
  80. return `{${value.a},${value.b},${value.c}}`;
  81. }
  82. }
  83. function line(a, b) {
  84. const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
  85. if (!config?.mode || config.mode === "tuple") {
  86. return new PgLineBuilder(name);
  87. }
  88. return new PgLineABCBuilder(name);
  89. }
  90. // Annotate the CommonJS export names for ESM import in node:
  91. 0 && (module.exports = {
  92. PgLineABC,
  93. PgLineABCBuilder,
  94. PgLineBuilder,
  95. PgLineTuple,
  96. line
  97. });
  98. //# sourceMappingURL=line.cjs.map