driver.cjs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 driver_exports = {};
  20. __export(driver_exports, {
  21. LibSQLDatabase: () => import_driver_core2.LibSQLDatabase,
  22. drizzle: () => drizzle
  23. });
  24. module.exports = __toCommonJS(driver_exports);
  25. var import_client = require("@libsql/client");
  26. var import_utils = require("../utils.cjs");
  27. var import_driver_core = require("./driver-core.cjs");
  28. var import_driver_core2 = require("./driver-core.cjs");
  29. function drizzle(...params) {
  30. if (typeof params[0] === "string") {
  31. const instance = (0, import_client.createClient)({
  32. url: params[0]
  33. });
  34. return (0, import_driver_core.construct)(instance, params[1]);
  35. }
  36. if ((0, import_utils.isConfig)(params[0])) {
  37. const { connection, client, ...drizzleConfig } = params[0];
  38. if (client) return (0, import_driver_core.construct)(client, drizzleConfig);
  39. const instance = typeof connection === "string" ? (0, import_client.createClient)({ url: connection }) : (0, import_client.createClient)(connection);
  40. return (0, import_driver_core.construct)(instance, drizzleConfig);
  41. }
  42. return (0, import_driver_core.construct)(params[0], params[1]);
  43. }
  44. ((drizzle2) => {
  45. function mock(config) {
  46. return (0, import_driver_core.construct)({}, config);
  47. }
  48. drizzle2.mock = mock;
  49. })(drizzle || (drizzle = {}));
  50. // Annotate the CommonJS export names for ESM import in node:
  51. 0 && (module.exports = {
  52. LibSQLDatabase,
  53. drizzle
  54. });
  55. //# sourceMappingURL=driver.cjs.map