zormz 1.2.8 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -46,16 +46,16 @@ interface connecionRed {
46
46
  connectionString: string;
47
47
  }
48
48
  type connectionDB = "mysql" | "pg";
49
- declare function getTipoConexion(): connectionDB;
50
49
  declare class BDconnection {
51
50
  tipo: connectionDB;
52
51
  pool: any;
53
52
  private connection;
54
53
  constructor(bd: connectionDB, datos: connecionLocal | connecionRed);
55
- private connecionMyql;
54
+ private conexionMysql;
56
55
  private connectionPG;
57
56
  executeConsulta({ query, valores, mensaje, }: Consultas): Promise<any>;
58
57
  }
58
+ declare function getTipoConexion(): connectionDB;
59
59
  /**
60
60
  *
61
61
  * @param bd
package/dist/index.d.ts CHANGED
@@ -46,16 +46,16 @@ interface connecionRed {
46
46
  connectionString: string;
47
47
  }
48
48
  type connectionDB = "mysql" | "pg";
49
- declare function getTipoConexion(): connectionDB;
50
49
  declare class BDconnection {
51
50
  tipo: connectionDB;
52
51
  pool: any;
53
52
  private connection;
54
53
  constructor(bd: connectionDB, datos: connecionLocal | connecionRed);
55
- private connecionMyql;
54
+ private conexionMysql;
56
55
  private connectionPG;
57
56
  executeConsulta({ query, valores, mensaje, }: Consultas): Promise<any>;
58
57
  }
58
+ declare function getTipoConexion(): connectionDB;
59
59
  /**
60
60
  *
61
61
  * @param bd
package/dist/index.js CHANGED
@@ -68,18 +68,13 @@ __export(index_exports, {
68
68
  module.exports = __toCommonJS(index_exports);
69
69
 
70
70
  // conection/db.ts
71
- var conexionZORMZ3691;
72
- var tipoConexionZORMZ3691;
73
- function getTipoConexion() {
74
- return tipoConexionZORMZ3691;
75
- }
76
71
  var BDconnection = class {
77
72
  constructor(bd, datos) {
78
73
  this.tipo = "pg";
79
74
  this.tipo = bd;
80
75
  this.connection = datos;
81
76
  }
82
- async connecionMyql() {
77
+ async conexionMysql() {
83
78
  try {
84
79
  const mysql = await import("mysql2/promise");
85
80
  if ("connectionString" in this.connection)
@@ -119,6 +114,7 @@ var BDconnection = class {
119
114
  console.error(
120
115
  "PostgreSQL no esta instalado. para instalarlo corre : npm install pg"
121
116
  );
117
+ throw new Error("PostgreSQL no esta instalado. para instalarlo corre : npm install pg");
122
118
  }
123
119
  }
124
120
  async executeConsulta({
@@ -128,7 +124,7 @@ var BDconnection = class {
128
124
  }) {
129
125
  try {
130
126
  if (this.tipo === "mysql") {
131
- const pool = await this.connecionMyql();
127
+ const pool = await this.conexionMysql();
132
128
  const [rows] = await pool.query(query, valores);
133
129
  return rows;
134
130
  } else if (this.tipo === "pg") {
@@ -146,6 +142,9 @@ var BDconnection = class {
146
142
  }
147
143
  }
148
144
  const pool2 = await this.connectionPG();
145
+ if (!pool2) {
146
+ throw new Error("No se pudo establecer la conexi\xF3n con PostgreSQL");
147
+ }
149
148
  const respuesta = await pool2.query(query2, valores);
150
149
  if (!respuesta) {
151
150
  throw new Error(` Este usuario no esta registrado `);
@@ -163,6 +162,14 @@ var BDconnection = class {
163
162
  }
164
163
  }
165
164
  };
165
+ var conexionZORMZ3691;
166
+ var tipoConexionZORMZ3691;
167
+ function getTipoConexion() {
168
+ if (!tipoConexionZORMZ3691) {
169
+ throw new Error("La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero.");
170
+ }
171
+ return tipoConexionZORMZ3691;
172
+ }
166
173
  async function getConexion(bd, datos) {
167
174
  conexionZORMZ3691 = new BDconnection(bd, datos);
168
175
  tipoConexionZORMZ3691 = conexionZORMZ3691.tipo;
@@ -170,9 +177,13 @@ async function getConexion(bd, datos) {
170
177
  console.log(`\u{1F44D}\u{1F44D} Conexi\xF3n ${tipoConexionZORMZ3691} exitosa \u{1F61C}`);
171
178
  }).catch((err) => {
172
179
  console.error(" \u{1F622}\u{1F622} Error al conectar a " + tipoConexionZORMZ3691);
180
+ console.log(err);
173
181
  });
174
182
  }
175
183
  function getRed() {
184
+ if (!conexionZORMZ3691) {
185
+ throw new Error("La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero.");
186
+ }
176
187
  return conexionZORMZ3691;
177
188
  }
178
189
  function defineTable(tableName, columns) {
@@ -234,6 +245,9 @@ async function generateTable(tabla, columns) {
234
245
  `;
235
246
  queries += columnDefs.join(", \n");
236
247
  queries += ");";
248
+ if (!conexionZORMZ3691 || !tipoConexionZORMZ3691) {
249
+ throw new Error("La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero.");
250
+ }
237
251
  if (tipoConexionZORMZ3691 === "mysql") {
238
252
  const response = await conexionZORMZ3691.executeConsulta({ query: queries, mensaje: "Error al crear la base de datos" });
239
253
  if (response.warningStatus > 0) {
package/dist/index.mjs CHANGED
@@ -7,18 +7,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
7
7
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
8
 
9
9
  // conection/db.ts
10
- var conexionZORMZ3691;
11
- var tipoConexionZORMZ3691;
12
- function getTipoConexion() {
13
- return tipoConexionZORMZ3691;
14
- }
15
10
  var BDconnection = class {
16
11
  constructor(bd, datos) {
17
12
  this.tipo = "pg";
18
13
  this.tipo = bd;
19
14
  this.connection = datos;
20
15
  }
21
- async connecionMyql() {
16
+ async conexionMysql() {
22
17
  try {
23
18
  const mysql = await import("mysql2/promise");
24
19
  if ("connectionString" in this.connection)
@@ -58,6 +53,7 @@ var BDconnection = class {
58
53
  console.error(
59
54
  "PostgreSQL no esta instalado. para instalarlo corre : npm install pg"
60
55
  );
56
+ throw new Error("PostgreSQL no esta instalado. para instalarlo corre : npm install pg");
61
57
  }
62
58
  }
63
59
  async executeConsulta({
@@ -67,7 +63,7 @@ var BDconnection = class {
67
63
  }) {
68
64
  try {
69
65
  if (this.tipo === "mysql") {
70
- const pool = await this.connecionMyql();
66
+ const pool = await this.conexionMysql();
71
67
  const [rows] = await pool.query(query, valores);
72
68
  return rows;
73
69
  } else if (this.tipo === "pg") {
@@ -85,6 +81,9 @@ var BDconnection = class {
85
81
  }
86
82
  }
87
83
  const pool2 = await this.connectionPG();
84
+ if (!pool2) {
85
+ throw new Error("No se pudo establecer la conexi\xF3n con PostgreSQL");
86
+ }
88
87
  const respuesta = await pool2.query(query2, valores);
89
88
  if (!respuesta) {
90
89
  throw new Error(` Este usuario no esta registrado `);
@@ -102,6 +101,14 @@ var BDconnection = class {
102
101
  }
103
102
  }
104
103
  };
104
+ var conexionZORMZ3691;
105
+ var tipoConexionZORMZ3691;
106
+ function getTipoConexion() {
107
+ if (!tipoConexionZORMZ3691) {
108
+ throw new Error("La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero.");
109
+ }
110
+ return tipoConexionZORMZ3691;
111
+ }
105
112
  async function getConexion(bd, datos) {
106
113
  conexionZORMZ3691 = new BDconnection(bd, datos);
107
114
  tipoConexionZORMZ3691 = conexionZORMZ3691.tipo;
@@ -109,9 +116,13 @@ async function getConexion(bd, datos) {
109
116
  console.log(`\u{1F44D}\u{1F44D} Conexi\xF3n ${tipoConexionZORMZ3691} exitosa \u{1F61C}`);
110
117
  }).catch((err) => {
111
118
  console.error(" \u{1F622}\u{1F622} Error al conectar a " + tipoConexionZORMZ3691);
119
+ console.log(err);
112
120
  });
113
121
  }
114
122
  function getRed() {
123
+ if (!conexionZORMZ3691) {
124
+ throw new Error("La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero.");
125
+ }
115
126
  return conexionZORMZ3691;
116
127
  }
117
128
  function defineTable(tableName, columns) {
@@ -173,6 +184,9 @@ async function generateTable(tabla, columns) {
173
184
  `;
174
185
  queries += columnDefs.join(", \n");
175
186
  queries += ");";
187
+ if (!conexionZORMZ3691 || !tipoConexionZORMZ3691) {
188
+ throw new Error("La conexi\xF3n no ha sido inicializada. Por favor, llama a getConexion() primero.");
189
+ }
176
190
  if (tipoConexionZORMZ3691 === "mysql") {
177
191
  const response = await conexionZORMZ3691.executeConsulta({ query: queries, mensaje: "Error al crear la base de datos" });
178
192
  if (response.warningStatus > 0) {
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "zormz",
3
- "version": "1.2.8",
4
- "description": "",
5
- "author": "",
3
+ "version": "1.3.0",
4
+ "description": "Un ORM que busca ser ligero y facil de usar",
5
+ "author": "yukio-kayaba",
6
6
  "license": "ISC",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.js",
9
9
  "types": "./dist/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
12
+ "require": "./dist/index.js",
13
+ "import": "./dist/index.mjs"
14
14
  }
15
15
  },
16
16
  "files": [