zormz 1.1.0 → 1.1.2

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.cjs CHANGED
@@ -42,19 +42,20 @@ __export(index_exports, {
42
42
  DB: () => DB,
43
43
  DeleteR: () => DeleteR,
44
44
  ILIKE: () => ILIKE,
45
+ MAYOR: () => MAYOR,
46
+ MENOR: () => MENOR,
45
47
  NOTNULL: () => NOTNULL,
48
+ NOW: () => NOW,
46
49
  NULL: () => NULL,
47
50
  OR: () => OR,
48
51
  ORQ: () => ORQ,
49
52
  QueryBuilder: () => QueryBuilder,
50
53
  Select: () => Select,
51
54
  Update: () => Update,
55
+ defineTable: () => defineTable,
52
56
  eq: () => eq,
53
57
  getConexion: () => getConexion,
54
- getRed: () => getRed,
55
- mayor: () => mayor,
56
- menor: () => menor,
57
- now: () => now
58
+ getRed: () => getRed
58
59
  });
59
60
  module.exports = __toCommonJS(index_exports);
60
61
 
@@ -161,6 +162,23 @@ function getConexion(bd, datos) {
161
162
  function getRed() {
162
163
  return conexion1;
163
164
  }
165
+ function defineTable(tableName, columns) {
166
+ const fn = () => tableName;
167
+ const proxy = new Proxy(fn, {
168
+ get(_target, prop) {
169
+ if (prop === "name") return tableName;
170
+ if (prop === "toString") return () => tableName;
171
+ if (prop === "valueOf") return () => tableName;
172
+ const col = columns[prop];
173
+ if (col !== void 0) return `${tableName}.${col}`;
174
+ return fn[prop];
175
+ },
176
+ apply() {
177
+ return tableName;
178
+ }
179
+ });
180
+ return proxy;
181
+ }
164
182
 
165
183
  // conection/middleware/delete.ts
166
184
  var _condicion, _tabla;
@@ -403,11 +421,11 @@ var Select = class {
403
421
 
404
422
  // conection/middleware/condicionals.ts
405
423
  var AND = (...valor1) => {
406
- const separacion = valor1.join(" and ");
424
+ const separacion = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" and ");
407
425
  return `(${separacion})`;
408
426
  };
409
427
  var OR = (...valor1) => {
410
- const separadosComas = valor1.join(" or ");
428
+ const separadosComas = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" or ");
411
429
  return `(${separadosComas})`;
412
430
  };
413
431
  var ORQ = (condicion1, ...condicionals) => {
@@ -419,9 +437,9 @@ var ORQ = (condicion1, ...condicionals) => {
419
437
  return separador;
420
438
  };
421
439
  var ILIKE = (valor1, valor2) => {
422
- return `${valor1} ILIKE '%${valor2}%'`;
440
+ return `${valor1} ILIKE '${valor2}'`;
423
441
  };
424
- var now = (variable, diasTrancurridos, minor = true) => {
442
+ var NOW = (variable, diasTrancurridos, minor = true) => {
425
443
  if (typeof variable !== "string") {
426
444
  throw new Error("Variable no valida");
427
445
  }
@@ -447,10 +465,10 @@ var eq = (valor1, valor2, literal = true) => {
447
465
  }
448
466
  return `${valor1} = '${valor2}'`;
449
467
  };
450
- var mayor = (valor, valor2) => {
468
+ var MAYOR = (valor, valor2) => {
451
469
  return ` ${valor} > ${valor2} `;
452
470
  };
453
- var menor = (valor, valor2) => {
471
+ var MENOR = (valor, valor2) => {
454
472
  return ` ${valor} < ${valor2} `;
455
473
  };
456
474
 
@@ -575,17 +593,18 @@ var DB = class {
575
593
  DB,
576
594
  DeleteR,
577
595
  ILIKE,
596
+ MAYOR,
597
+ MENOR,
578
598
  NOTNULL,
599
+ NOW,
579
600
  NULL,
580
601
  OR,
581
602
  ORQ,
582
603
  QueryBuilder,
583
604
  Select,
584
605
  Update,
606
+ defineTable,
585
607
  eq,
586
608
  getConexion,
587
- getRed,
588
- mayor,
589
- menor,
590
- now
609
+ getRed
591
610
  });
package/dist/index.d.cts CHANGED
@@ -31,6 +31,22 @@ declare class BDconnection {
31
31
  */
32
32
  declare function getConexion(bd: connectionDB, datos: connecionLocal | connecionRed): void;
33
33
  declare function getRed(): BDconnection;
34
+ type ColumnsMap = Record<string, string>;
35
+ /**
36
+ *
37
+ * @param {string} tableName
38
+ * @param {string} columns
39
+ * @example
40
+ * export const productosPrueba = defineTable("productosPrueba",{
41
+ * id:"id",
42
+ * nombre:"nombre",
43
+ * descripcion:"descripcion"
44
+ * });
45
+ * @returns
46
+ */
47
+ declare function defineTable<T extends ColumnsMap>(tableName: string, columns: T): T & (() => string) & {
48
+ name: string;
49
+ };
34
50
 
35
51
  declare class DeleteR {
36
52
  #private;
@@ -229,13 +245,23 @@ declare const OR: (...valor1: Valor[]) => string;
229
245
  * @returns
230
246
  */
231
247
  declare const ORQ: (condicion1: Valor, ...condicionals: Valor[]) => string;
248
+ /**
249
+ *
250
+ * @param {string} valor1
251
+ * @param {string} valor2
252
+ * @example
253
+ * SELECT().WHERE(ILIKE(t_productos.nombre, `%${contenido}`))
254
+ * SELECT().WHERE(ILIKE(t_productos.nombre, `${contenido}%`))
255
+ * SELECT().WHERE(ILIKE(t_productos.nombre, `%${contenido}%`))
256
+ * @returns
257
+ */
232
258
  declare const ILIKE: (valor1: string, valor2: string) => string;
233
259
  /**
234
260
  *
235
261
  * @param {String} variable -Type timestamp
236
262
  * @param {Number} diasTrancurridos -type number
237
263
  */
238
- declare const now: (variable: string, diasTrancurridos: number, minor?: boolean) => string;
264
+ declare const NOW: (variable: string, diasTrancurridos: number, minor?: boolean) => string;
239
265
  /**
240
266
  *
241
267
  * @param {String} variable - variable
@@ -260,7 +286,23 @@ declare const NOTNULL: (variable: string) => string;
260
286
  * eq('id',valor1, false)
261
287
  */
262
288
  declare const eq: (valor1: Valor, valor2: Valor, literal?: boolean) => string;
263
- declare const mayor: (valor: string, valor2: string) => string;
264
- declare const menor: (valor: string, valor2: string) => string;
289
+ /**
290
+ *
291
+ * @param {string} valor
292
+ * @param {string} valor2
293
+ * @example
294
+ * MAYOR(t_productos.id, `${maxPageSize * 2}`),
295
+ * @returns
296
+ */
297
+ declare const MAYOR: (valor: string, valor2: string) => string;
298
+ /**
299
+ *
300
+ * @param {string} valor
301
+ * @param {string} valor2
302
+ * @example
303
+ * MENOR(t_productos.id, `${maxPageSize * 2}`),
304
+ * @returns
305
+ */
306
+ declare const MENOR: (valor: string, valor2: string) => string;
265
307
 
266
- export { AND, BDconnection, type Consultas, DB, DeleteR, ILIKE, NOTNULL, NULL, OR, ORQ, QueryBuilder, Select, type Tipos, Update, type Valores, type arrayData, type arrayDatas, type connecionLocal, type connecionRed, type connectionDB, eq, getConexion, getRed, mayor, menor, now, type valor };
308
+ export { AND, BDconnection, type Consultas, DB, DeleteR, ILIKE, MAYOR, MENOR, NOTNULL, NOW, NULL, OR, ORQ, QueryBuilder, Select, type Tipos, Update, type Valores, type arrayData, type arrayDatas, type connecionLocal, type connecionRed, type connectionDB, defineTable, eq, getConexion, getRed, type valor };
package/dist/index.d.ts CHANGED
@@ -31,6 +31,22 @@ declare class BDconnection {
31
31
  */
32
32
  declare function getConexion(bd: connectionDB, datos: connecionLocal | connecionRed): void;
33
33
  declare function getRed(): BDconnection;
34
+ type ColumnsMap = Record<string, string>;
35
+ /**
36
+ *
37
+ * @param {string} tableName
38
+ * @param {string} columns
39
+ * @example
40
+ * export const productosPrueba = defineTable("productosPrueba",{
41
+ * id:"id",
42
+ * nombre:"nombre",
43
+ * descripcion:"descripcion"
44
+ * });
45
+ * @returns
46
+ */
47
+ declare function defineTable<T extends ColumnsMap>(tableName: string, columns: T): T & (() => string) & {
48
+ name: string;
49
+ };
34
50
 
35
51
  declare class DeleteR {
36
52
  #private;
@@ -229,13 +245,23 @@ declare const OR: (...valor1: Valor[]) => string;
229
245
  * @returns
230
246
  */
231
247
  declare const ORQ: (condicion1: Valor, ...condicionals: Valor[]) => string;
248
+ /**
249
+ *
250
+ * @param {string} valor1
251
+ * @param {string} valor2
252
+ * @example
253
+ * SELECT().WHERE(ILIKE(t_productos.nombre, `%${contenido}`))
254
+ * SELECT().WHERE(ILIKE(t_productos.nombre, `${contenido}%`))
255
+ * SELECT().WHERE(ILIKE(t_productos.nombre, `%${contenido}%`))
256
+ * @returns
257
+ */
232
258
  declare const ILIKE: (valor1: string, valor2: string) => string;
233
259
  /**
234
260
  *
235
261
  * @param {String} variable -Type timestamp
236
262
  * @param {Number} diasTrancurridos -type number
237
263
  */
238
- declare const now: (variable: string, diasTrancurridos: number, minor?: boolean) => string;
264
+ declare const NOW: (variable: string, diasTrancurridos: number, minor?: boolean) => string;
239
265
  /**
240
266
  *
241
267
  * @param {String} variable - variable
@@ -260,7 +286,23 @@ declare const NOTNULL: (variable: string) => string;
260
286
  * eq('id',valor1, false)
261
287
  */
262
288
  declare const eq: (valor1: Valor, valor2: Valor, literal?: boolean) => string;
263
- declare const mayor: (valor: string, valor2: string) => string;
264
- declare const menor: (valor: string, valor2: string) => string;
289
+ /**
290
+ *
291
+ * @param {string} valor
292
+ * @param {string} valor2
293
+ * @example
294
+ * MAYOR(t_productos.id, `${maxPageSize * 2}`),
295
+ * @returns
296
+ */
297
+ declare const MAYOR: (valor: string, valor2: string) => string;
298
+ /**
299
+ *
300
+ * @param {string} valor
301
+ * @param {string} valor2
302
+ * @example
303
+ * MENOR(t_productos.id, `${maxPageSize * 2}`),
304
+ * @returns
305
+ */
306
+ declare const MENOR: (valor: string, valor2: string) => string;
265
307
 
266
- export { AND, BDconnection, type Consultas, DB, DeleteR, ILIKE, NOTNULL, NULL, OR, ORQ, QueryBuilder, Select, type Tipos, Update, type Valores, type arrayData, type arrayDatas, type connecionLocal, type connecionRed, type connectionDB, eq, getConexion, getRed, mayor, menor, now, type valor };
308
+ export { AND, BDconnection, type Consultas, DB, DeleteR, ILIKE, MAYOR, MENOR, NOTNULL, NOW, NULL, OR, ORQ, QueryBuilder, Select, type Tipos, Update, type Valores, type arrayData, type arrayDatas, type connecionLocal, type connecionRed, type connectionDB, defineTable, eq, getConexion, getRed, type valor };
package/dist/index.js CHANGED
@@ -109,6 +109,23 @@ function getConexion(bd, datos) {
109
109
  function getRed() {
110
110
  return conexion1;
111
111
  }
112
+ function defineTable(tableName, columns) {
113
+ const fn = () => tableName;
114
+ const proxy = new Proxy(fn, {
115
+ get(_target, prop) {
116
+ if (prop === "name") return tableName;
117
+ if (prop === "toString") return () => tableName;
118
+ if (prop === "valueOf") return () => tableName;
119
+ const col = columns[prop];
120
+ if (col !== void 0) return `${tableName}.${col}`;
121
+ return fn[prop];
122
+ },
123
+ apply() {
124
+ return tableName;
125
+ }
126
+ });
127
+ return proxy;
128
+ }
112
129
 
113
130
  // conection/middleware/delete.ts
114
131
  var _condicion, _tabla;
@@ -351,11 +368,11 @@ var Select = class {
351
368
 
352
369
  // conection/middleware/condicionals.ts
353
370
  var AND = (...valor1) => {
354
- const separacion = valor1.join(" and ");
371
+ const separacion = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" and ");
355
372
  return `(${separacion})`;
356
373
  };
357
374
  var OR = (...valor1) => {
358
- const separadosComas = valor1.join(" or ");
375
+ const separadosComas = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" or ");
359
376
  return `(${separadosComas})`;
360
377
  };
361
378
  var ORQ = (condicion1, ...condicionals) => {
@@ -367,9 +384,9 @@ var ORQ = (condicion1, ...condicionals) => {
367
384
  return separador;
368
385
  };
369
386
  var ILIKE = (valor1, valor2) => {
370
- return `${valor1} ILIKE '%${valor2}%'`;
387
+ return `${valor1} ILIKE '${valor2}'`;
371
388
  };
372
- var now = (variable, diasTrancurridos, minor = true) => {
389
+ var NOW = (variable, diasTrancurridos, minor = true) => {
373
390
  if (typeof variable !== "string") {
374
391
  throw new Error("Variable no valida");
375
392
  }
@@ -395,10 +412,10 @@ var eq = (valor1, valor2, literal = true) => {
395
412
  }
396
413
  return `${valor1} = '${valor2}'`;
397
414
  };
398
- var mayor = (valor, valor2) => {
415
+ var MAYOR = (valor, valor2) => {
399
416
  return ` ${valor} > ${valor2} `;
400
417
  };
401
- var menor = (valor, valor2) => {
418
+ var MENOR = (valor, valor2) => {
402
419
  return ` ${valor} < ${valor2} `;
403
420
  };
404
421
 
@@ -522,17 +539,18 @@ export {
522
539
  DB,
523
540
  DeleteR,
524
541
  ILIKE,
542
+ MAYOR,
543
+ MENOR,
525
544
  NOTNULL,
545
+ NOW,
526
546
  NULL,
527
547
  OR,
528
548
  ORQ,
529
549
  QueryBuilder,
530
550
  Select,
531
551
  Update,
552
+ defineTable,
532
553
  eq,
533
554
  getConexion,
534
- getRed,
535
- mayor,
536
- menor,
537
- now
555
+ getRed
538
556
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zormz",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "ISC",