zormz 1.6.0 → 1.6.1
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 +15 -6
- package/dist/index.d.ts +15 -6
- package/dist/index.js +89 -41
- package/dist/index.mjs +90 -41
- package/package.json +7 -6
package/dist/index.d.mts
CHANGED
|
@@ -194,6 +194,7 @@ declare class Select {
|
|
|
194
194
|
private limit;
|
|
195
195
|
private condicion;
|
|
196
196
|
private orderBy;
|
|
197
|
+
private offset;
|
|
197
198
|
/**
|
|
198
199
|
* @param {string[]} parametros - campo obligatorio
|
|
199
200
|
* @param {string} tabla - nombre de la ta tabla - campo obligatorio
|
|
@@ -229,6 +230,14 @@ declare class Select {
|
|
|
229
230
|
* @param {Number} cantidad
|
|
230
231
|
*/
|
|
231
232
|
LIMIT(cantidad?: number): this;
|
|
233
|
+
/**
|
|
234
|
+
*
|
|
235
|
+
* @param {number} cant
|
|
236
|
+
* @returns
|
|
237
|
+
* @example
|
|
238
|
+
* .LIMIT(10).OFFSET(10).execute()
|
|
239
|
+
*/
|
|
240
|
+
OFFSET(cant: number): this;
|
|
232
241
|
/**
|
|
233
242
|
*
|
|
234
243
|
* @param {String} texto
|
|
@@ -295,7 +304,7 @@ declare class DB {
|
|
|
295
304
|
static Delete(nombreTabla: string): DeleteR;
|
|
296
305
|
}
|
|
297
306
|
|
|
298
|
-
type Valor = string | number | boolean;
|
|
307
|
+
type Valor = string | number | boolean | null;
|
|
299
308
|
/**
|
|
300
309
|
*
|
|
301
310
|
* @param {(string | number | boolean )} valor1 - eq(val,val1)
|
|
@@ -304,18 +313,18 @@ type Valor = string | number | boolean;
|
|
|
304
313
|
* //para varios condiciones
|
|
305
314
|
* AND(eq(),eq(),eq(),eq(),OR())
|
|
306
315
|
*/
|
|
307
|
-
declare const AND: (...valor1:
|
|
308
|
-
declare function ANDD(valores: string[]): string;
|
|
316
|
+
declare const AND: (...valor1: (string | null)[]) => string;
|
|
317
|
+
declare function ANDD(valores: (string | null)[]): string;
|
|
309
318
|
/**
|
|
310
319
|
*
|
|
311
|
-
* @param {
|
|
320
|
+
* @param {string} valor1 - eq(val,val1)
|
|
312
321
|
* @example
|
|
313
322
|
* //para una sola condicion
|
|
314
323
|
* OR(eq())
|
|
315
324
|
* //para varios condiciones
|
|
316
325
|
* OR(eq(),eq(),eq(),eq(),AND())
|
|
317
326
|
*/
|
|
318
|
-
declare const OR: (...valor1:
|
|
327
|
+
declare const OR: (...valor1: (string | null)[]) => string;
|
|
319
328
|
/**
|
|
320
329
|
*
|
|
321
330
|
* @param {string} valores
|
|
@@ -323,7 +332,7 @@ declare const OR: (...valor1: Valor[]) => string;
|
|
|
323
332
|
* @example
|
|
324
333
|
* ORD([eq(),eq()])
|
|
325
334
|
*/
|
|
326
|
-
declare const ORD: (valores: string[]) => string;
|
|
335
|
+
declare const ORD: (valores: (string | null)[]) => string;
|
|
327
336
|
/**
|
|
328
337
|
*
|
|
329
338
|
* @param {Valor} condicion1
|
package/dist/index.d.ts
CHANGED
|
@@ -194,6 +194,7 @@ declare class Select {
|
|
|
194
194
|
private limit;
|
|
195
195
|
private condicion;
|
|
196
196
|
private orderBy;
|
|
197
|
+
private offset;
|
|
197
198
|
/**
|
|
198
199
|
* @param {string[]} parametros - campo obligatorio
|
|
199
200
|
* @param {string} tabla - nombre de la ta tabla - campo obligatorio
|
|
@@ -229,6 +230,14 @@ declare class Select {
|
|
|
229
230
|
* @param {Number} cantidad
|
|
230
231
|
*/
|
|
231
232
|
LIMIT(cantidad?: number): this;
|
|
233
|
+
/**
|
|
234
|
+
*
|
|
235
|
+
* @param {number} cant
|
|
236
|
+
* @returns
|
|
237
|
+
* @example
|
|
238
|
+
* .LIMIT(10).OFFSET(10).execute()
|
|
239
|
+
*/
|
|
240
|
+
OFFSET(cant: number): this;
|
|
232
241
|
/**
|
|
233
242
|
*
|
|
234
243
|
* @param {String} texto
|
|
@@ -295,7 +304,7 @@ declare class DB {
|
|
|
295
304
|
static Delete(nombreTabla: string): DeleteR;
|
|
296
305
|
}
|
|
297
306
|
|
|
298
|
-
type Valor = string | number | boolean;
|
|
307
|
+
type Valor = string | number | boolean | null;
|
|
299
308
|
/**
|
|
300
309
|
*
|
|
301
310
|
* @param {(string | number | boolean )} valor1 - eq(val,val1)
|
|
@@ -304,18 +313,18 @@ type Valor = string | number | boolean;
|
|
|
304
313
|
* //para varios condiciones
|
|
305
314
|
* AND(eq(),eq(),eq(),eq(),OR())
|
|
306
315
|
*/
|
|
307
|
-
declare const AND: (...valor1:
|
|
308
|
-
declare function ANDD(valores: string[]): string;
|
|
316
|
+
declare const AND: (...valor1: (string | null)[]) => string;
|
|
317
|
+
declare function ANDD(valores: (string | null)[]): string;
|
|
309
318
|
/**
|
|
310
319
|
*
|
|
311
|
-
* @param {
|
|
320
|
+
* @param {string} valor1 - eq(val,val1)
|
|
312
321
|
* @example
|
|
313
322
|
* //para una sola condicion
|
|
314
323
|
* OR(eq())
|
|
315
324
|
* //para varios condiciones
|
|
316
325
|
* OR(eq(),eq(),eq(),eq(),AND())
|
|
317
326
|
*/
|
|
318
|
-
declare const OR: (...valor1:
|
|
327
|
+
declare const OR: (...valor1: (string | null)[]) => string;
|
|
319
328
|
/**
|
|
320
329
|
*
|
|
321
330
|
* @param {string} valores
|
|
@@ -323,7 +332,7 @@ declare const OR: (...valor1: Valor[]) => string;
|
|
|
323
332
|
* @example
|
|
324
333
|
* ORD([eq(),eq()])
|
|
325
334
|
*/
|
|
326
|
-
declare const ORD: (valores: string[]) => string;
|
|
335
|
+
declare const ORD: (valores: (string | null)[]) => string;
|
|
327
336
|
/**
|
|
328
337
|
*
|
|
329
338
|
* @param {Valor} condicion1
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
|
8
8
|
var __typeError = (msg) => {
|
|
9
9
|
throw TypeError(msg);
|
|
10
10
|
};
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
12
|
var __export = (target, all) => {
|
|
12
13
|
for (var name in all)
|
|
13
14
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -29,6 +30,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
30
|
mod
|
|
30
31
|
));
|
|
31
32
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
32
34
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
33
35
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
34
36
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
@@ -82,9 +84,9 @@ module.exports = __toCommonJS(index_exports);
|
|
|
82
84
|
// conection/validator.ts
|
|
83
85
|
var Validator = class {
|
|
84
86
|
};
|
|
85
|
-
Validator
|
|
86
|
-
Validator
|
|
87
|
-
Validator
|
|
87
|
+
__publicField(Validator, "isValidTable", (val) => /^(?![0-9_])[a-z][a-z0-9_]{0,62}$/.test(val));
|
|
88
|
+
__publicField(Validator, "isValidColumn", (val) => /^[a-zA-Z][a-zA-Z0-9]{0,62}$/.test(val));
|
|
89
|
+
__publicField(Validator, "isValidUsername", (val) => /^[a-zA-Z0-9\-_]+$/.test(val));
|
|
88
90
|
var RESERVED_WORDS = /* @__PURE__ */ new Set([
|
|
89
91
|
"select",
|
|
90
92
|
"table",
|
|
@@ -98,16 +100,19 @@ var RESERVED_WORDS = /* @__PURE__ */ new Set([
|
|
|
98
100
|
// conection/db.ts
|
|
99
101
|
var BDconnection = class {
|
|
100
102
|
constructor(bd, datos) {
|
|
101
|
-
this
|
|
103
|
+
__publicField(this, "tipo", "pg");
|
|
104
|
+
__publicField(this, "pool");
|
|
105
|
+
__publicField(this, "connection");
|
|
102
106
|
this.tipo = bd;
|
|
103
107
|
this.connection = datos;
|
|
104
108
|
}
|
|
105
109
|
async conexionMysql() {
|
|
106
110
|
try {
|
|
107
|
-
const
|
|
108
|
-
if ("connectionString" in this.connection)
|
|
111
|
+
const { createPool } = await import("mysql2/promise");
|
|
112
|
+
if ("connectionString" in this.connection) {
|
|
109
113
|
throw new Error("La conexion mysql no tiene una conexion de red");
|
|
110
|
-
|
|
114
|
+
}
|
|
115
|
+
const pool = createPool({
|
|
111
116
|
host: this.connection.host,
|
|
112
117
|
port: this.connection.port,
|
|
113
118
|
database: this.connection.database,
|
|
@@ -388,6 +393,7 @@ var DeleteR = class {
|
|
|
388
393
|
constructor(conexion, tabla) {
|
|
389
394
|
__privateAdd(this, _condicion);
|
|
390
395
|
__privateAdd(this, _tabla);
|
|
396
|
+
__publicField(this, "conexion");
|
|
391
397
|
__privateSet(this, _tabla, tabla);
|
|
392
398
|
__privateSet(this, _condicion, "");
|
|
393
399
|
this.conexion = conexion;
|
|
@@ -440,6 +446,11 @@ var QueryBuilder = class {
|
|
|
440
446
|
* @param {string[]} values - campo obligatorio
|
|
441
447
|
*/
|
|
442
448
|
constructor(conexion, tabla, parametros) {
|
|
449
|
+
__publicField(this, "tabla");
|
|
450
|
+
__publicField(this, "parametros");
|
|
451
|
+
__publicField(this, "valores");
|
|
452
|
+
__publicField(this, "returning");
|
|
453
|
+
__publicField(this, "conexion");
|
|
443
454
|
if (!parametros || !Array.isArray(parametros)) {
|
|
444
455
|
throw new Error(`campos obligatorios`);
|
|
445
456
|
}
|
|
@@ -570,6 +581,17 @@ var Select = class {
|
|
|
570
581
|
* @param {string} condition - tabla1.id = tabla2.idtabla1 - id='2' - id='2' AND id='3'
|
|
571
582
|
*/
|
|
572
583
|
constructor(conexion, parametros = "*") {
|
|
584
|
+
__publicField(this, "conexion");
|
|
585
|
+
__publicField(this, "valores");
|
|
586
|
+
__publicField(this, "parametros");
|
|
587
|
+
__publicField(this, "tabla");
|
|
588
|
+
__publicField(this, "innerJoin");
|
|
589
|
+
__publicField(this, "leftjoins");
|
|
590
|
+
__publicField(this, "rigthjoins");
|
|
591
|
+
__publicField(this, "limit");
|
|
592
|
+
__publicField(this, "condicion");
|
|
593
|
+
__publicField(this, "orderBy");
|
|
594
|
+
__publicField(this, "offset");
|
|
573
595
|
this.conexion = conexion;
|
|
574
596
|
this.valores = !Array.isArray(parametros) ? false : true;
|
|
575
597
|
this.parametros = parametros;
|
|
@@ -580,6 +602,7 @@ var Select = class {
|
|
|
580
602
|
this.limit = "";
|
|
581
603
|
this.condicion = "";
|
|
582
604
|
this.orderBy = "";
|
|
605
|
+
this.offset = "";
|
|
583
606
|
}
|
|
584
607
|
/**
|
|
585
608
|
* @param {string} tabla - nombre de la ta tabla - campo obligatorio
|
|
@@ -662,6 +685,20 @@ var Select = class {
|
|
|
662
685
|
this.limit = `LIMIT ${cantidad}`;
|
|
663
686
|
return this;
|
|
664
687
|
}
|
|
688
|
+
/**
|
|
689
|
+
*
|
|
690
|
+
* @param {number} cant
|
|
691
|
+
* @returns
|
|
692
|
+
* @example
|
|
693
|
+
* .LIMIT(10).OFFSET(10).execute()
|
|
694
|
+
*/
|
|
695
|
+
OFFSET(cant) {
|
|
696
|
+
if (typeof cant !== "number") {
|
|
697
|
+
throw new Error("Cant tiene que ser un numero");
|
|
698
|
+
}
|
|
699
|
+
this.offset = ` OFFSET ${cant}`;
|
|
700
|
+
return this;
|
|
701
|
+
}
|
|
665
702
|
/**
|
|
666
703
|
*
|
|
667
704
|
* @param {String} texto
|
|
@@ -676,7 +713,7 @@ var Select = class {
|
|
|
676
713
|
selectFields = this.parametros.join(",");
|
|
677
714
|
}
|
|
678
715
|
}
|
|
679
|
-
const query = `SELECT ${selectFields} from ${this.tabla} ${this.innerJoin} ${this.leftjoins} ${this.rigthjoins} ${this.condicion} ${this.orderBy} ${this.limit};`;
|
|
716
|
+
const query = `SELECT ${selectFields} from ${this.tabla} ${this.innerJoin} ${this.leftjoins} ${this.rigthjoins} ${this.condicion} ${this.orderBy} ${this.limit} ${this.offset} ;`;
|
|
680
717
|
if (see) {
|
|
681
718
|
console.log(query);
|
|
682
719
|
}
|
|
@@ -701,32 +738,38 @@ var Select = class {
|
|
|
701
738
|
|
|
702
739
|
// conection/middleware/condicionals.ts
|
|
703
740
|
var AND = (...valor1) => {
|
|
704
|
-
const separacion = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" and ");
|
|
741
|
+
const separacion = valor1.filter((dato) => dato !== void 0 && dato !== null && dato.length !== 0).join(" and ");
|
|
705
742
|
return ` (${separacion}) `;
|
|
706
743
|
};
|
|
707
744
|
function ANDD(valores) {
|
|
708
|
-
const separacion = valores.filter((dato) => dato !== void 0 && dato !== null).join(" and ");
|
|
745
|
+
const separacion = valores.filter((dato) => dato !== void 0 && dato !== null && dato.length !== 0).join(" and ");
|
|
709
746
|
return ` (${separacion}) `;
|
|
710
747
|
}
|
|
711
748
|
var OR = (...valor1) => {
|
|
712
|
-
const separadosComas = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" or ");
|
|
749
|
+
const separadosComas = valor1.filter((dato) => dato !== void 0 && dato !== null && dato.length !== 0).join(" or ");
|
|
713
750
|
return ` (${separadosComas}) `;
|
|
714
751
|
};
|
|
715
752
|
var ORD = (valores) => {
|
|
716
|
-
const separador = valores.filter((dato) => dato !== void 0 && dato !== null).join(" or ");
|
|
753
|
+
const separador = valores.filter((dato) => dato !== void 0 && dato !== null && dato.length !== 0).join(" or ");
|
|
717
754
|
return ` (${separador}) `;
|
|
718
755
|
};
|
|
719
756
|
var ORQ = (condicion1, ...condicionals) => {
|
|
720
|
-
const data2 = condicionals.
|
|
721
|
-
|
|
757
|
+
const data2 = condicionals.filter(
|
|
758
|
+
(dato) => dato !== null && !(typeof dato === "string" && dato.length === 0)
|
|
759
|
+
).map((dato) => {
|
|
760
|
+
if (typeof dato == "number" || typeof dato == "boolean")
|
|
761
|
+
return ` ${condicion1} = ${dato}`;
|
|
722
762
|
return ` ${condicion1} = '${dato}' `;
|
|
723
763
|
});
|
|
724
764
|
const separador = data2.join(" or ");
|
|
725
765
|
return ` (${separador}) `;
|
|
726
766
|
};
|
|
727
767
|
var ORQD = (condicion, valores) => {
|
|
728
|
-
const data = valores.
|
|
729
|
-
|
|
768
|
+
const data = valores.filter(
|
|
769
|
+
(dato) => dato !== null && !(typeof dato === "string" && dato.length === 0)
|
|
770
|
+
).map((dato) => {
|
|
771
|
+
if (typeof dato == "number" || typeof dato === "boolean")
|
|
772
|
+
return ` ${condicion} = ${dato}`;
|
|
730
773
|
return ` ${condicion} = '${dato}' `;
|
|
731
774
|
});
|
|
732
775
|
const separador = data.join(" or ");
|
|
@@ -793,9 +836,10 @@ var Update = class {
|
|
|
793
836
|
* @param {string} nombreTabla - nombre de la tabla a actualizar
|
|
794
837
|
*/
|
|
795
838
|
constructor(conexion, nombreTabla) {
|
|
796
|
-
this
|
|
797
|
-
this
|
|
798
|
-
this
|
|
839
|
+
__publicField(this, "conexion");
|
|
840
|
+
__publicField(this, "nombreTabla", "");
|
|
841
|
+
__publicField(this, "valores", "");
|
|
842
|
+
__publicField(this, "condicion", "");
|
|
799
843
|
if (typeof nombreTabla !== "string") {
|
|
800
844
|
throw new Error("el valor ingresado requiere un string");
|
|
801
845
|
}
|
|
@@ -915,11 +959,13 @@ var DB = class {
|
|
|
915
959
|
// conection/controls/int.ts
|
|
916
960
|
var IntColumn = class {
|
|
917
961
|
constructor() {
|
|
918
|
-
this
|
|
919
|
-
this
|
|
920
|
-
this
|
|
921
|
-
this
|
|
922
|
-
this
|
|
962
|
+
__publicField(this, "requerido", false);
|
|
963
|
+
__publicField(this, "unique", false);
|
|
964
|
+
__publicField(this, "autoIncrement", false);
|
|
965
|
+
__publicField(this, "defaultData");
|
|
966
|
+
__publicField(this, "pk");
|
|
967
|
+
__publicField(this, "unsingned", { uso: false, valor: 0 });
|
|
968
|
+
__publicField(this, "comentario", "");
|
|
923
969
|
}
|
|
924
970
|
Required() {
|
|
925
971
|
this.requerido = true;
|
|
@@ -1010,13 +1056,13 @@ function int() {
|
|
|
1010
1056
|
// conection/controls/varchar.ts
|
|
1011
1057
|
var Varchar = class {
|
|
1012
1058
|
constructor(cantidad = 100) {
|
|
1013
|
-
this
|
|
1014
|
-
this
|
|
1015
|
-
this
|
|
1016
|
-
this
|
|
1017
|
-
this
|
|
1018
|
-
this
|
|
1019
|
-
this
|
|
1059
|
+
__publicField(this, "maxLenth", 100);
|
|
1060
|
+
__publicField(this, "defaultData", "");
|
|
1061
|
+
__publicField(this, "requerido", false);
|
|
1062
|
+
__publicField(this, "unique", false);
|
|
1063
|
+
__publicField(this, "enum", "");
|
|
1064
|
+
__publicField(this, "campo", "");
|
|
1065
|
+
__publicField(this, "comentarios", "");
|
|
1020
1066
|
this.maxLenth = cantidad;
|
|
1021
1067
|
}
|
|
1022
1068
|
withType({
|
|
@@ -1086,8 +1132,9 @@ function varchar(cantidad = 100) {
|
|
|
1086
1132
|
// conection/controls/bool.ts
|
|
1087
1133
|
var BoolColumn = class {
|
|
1088
1134
|
constructor() {
|
|
1089
|
-
this
|
|
1090
|
-
this
|
|
1135
|
+
__publicField(this, "requerido", false);
|
|
1136
|
+
__publicField(this, "defaultData");
|
|
1137
|
+
__publicField(this, "comentario", "");
|
|
1091
1138
|
}
|
|
1092
1139
|
required() {
|
|
1093
1140
|
this.requerido = true;
|
|
@@ -1129,10 +1176,10 @@ function bool() {
|
|
|
1129
1176
|
// conection/controls/timestamp.ts
|
|
1130
1177
|
var Timestamp = class {
|
|
1131
1178
|
constructor() {
|
|
1132
|
-
this
|
|
1133
|
-
this
|
|
1134
|
-
this
|
|
1135
|
-
this
|
|
1179
|
+
__publicField(this, "requerido", false);
|
|
1180
|
+
__publicField(this, "defaultNow", false);
|
|
1181
|
+
__publicField(this, "onUpdateNow", false);
|
|
1182
|
+
__publicField(this, "comentario", "");
|
|
1136
1183
|
}
|
|
1137
1184
|
required() {
|
|
1138
1185
|
this.requerido = true;
|
|
@@ -1179,10 +1226,11 @@ function timestamp() {
|
|
|
1179
1226
|
// conection/controls/money.ts
|
|
1180
1227
|
var Money = class {
|
|
1181
1228
|
constructor(presicion = 10, decimales = 2) {
|
|
1182
|
-
this
|
|
1183
|
-
this
|
|
1184
|
-
this
|
|
1185
|
-
this
|
|
1229
|
+
__publicField(this, "precision", 10);
|
|
1230
|
+
__publicField(this, "scale", 2);
|
|
1231
|
+
__publicField(this, "requerido", false);
|
|
1232
|
+
__publicField(this, "defaultData");
|
|
1233
|
+
__publicField(this, "comentario", "");
|
|
1186
1234
|
this.precision = presicion;
|
|
1187
1235
|
this.scale = decimales;
|
|
1188
1236
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
1
2
|
var __typeError = (msg) => {
|
|
2
3
|
throw TypeError(msg);
|
|
3
4
|
};
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
7
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
8
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
@@ -9,9 +12,9 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
9
12
|
// conection/validator.ts
|
|
10
13
|
var Validator = class {
|
|
11
14
|
};
|
|
12
|
-
Validator
|
|
13
|
-
Validator
|
|
14
|
-
Validator
|
|
15
|
+
__publicField(Validator, "isValidTable", (val) => /^(?![0-9_])[a-z][a-z0-9_]{0,62}$/.test(val));
|
|
16
|
+
__publicField(Validator, "isValidColumn", (val) => /^[a-zA-Z][a-zA-Z0-9]{0,62}$/.test(val));
|
|
17
|
+
__publicField(Validator, "isValidUsername", (val) => /^[a-zA-Z0-9\-_]+$/.test(val));
|
|
15
18
|
var RESERVED_WORDS = /* @__PURE__ */ new Set([
|
|
16
19
|
"select",
|
|
17
20
|
"table",
|
|
@@ -25,16 +28,19 @@ var RESERVED_WORDS = /* @__PURE__ */ new Set([
|
|
|
25
28
|
// conection/db.ts
|
|
26
29
|
var BDconnection = class {
|
|
27
30
|
constructor(bd, datos) {
|
|
28
|
-
this
|
|
31
|
+
__publicField(this, "tipo", "pg");
|
|
32
|
+
__publicField(this, "pool");
|
|
33
|
+
__publicField(this, "connection");
|
|
29
34
|
this.tipo = bd;
|
|
30
35
|
this.connection = datos;
|
|
31
36
|
}
|
|
32
37
|
async conexionMysql() {
|
|
33
38
|
try {
|
|
34
|
-
const
|
|
35
|
-
if ("connectionString" in this.connection)
|
|
39
|
+
const { createPool } = await import("mysql2/promise");
|
|
40
|
+
if ("connectionString" in this.connection) {
|
|
36
41
|
throw new Error("La conexion mysql no tiene una conexion de red");
|
|
37
|
-
|
|
42
|
+
}
|
|
43
|
+
const pool = createPool({
|
|
38
44
|
host: this.connection.host,
|
|
39
45
|
port: this.connection.port,
|
|
40
46
|
database: this.connection.database,
|
|
@@ -315,6 +321,7 @@ var DeleteR = class {
|
|
|
315
321
|
constructor(conexion, tabla) {
|
|
316
322
|
__privateAdd(this, _condicion);
|
|
317
323
|
__privateAdd(this, _tabla);
|
|
324
|
+
__publicField(this, "conexion");
|
|
318
325
|
__privateSet(this, _tabla, tabla);
|
|
319
326
|
__privateSet(this, _condicion, "");
|
|
320
327
|
this.conexion = conexion;
|
|
@@ -367,6 +374,11 @@ var QueryBuilder = class {
|
|
|
367
374
|
* @param {string[]} values - campo obligatorio
|
|
368
375
|
*/
|
|
369
376
|
constructor(conexion, tabla, parametros) {
|
|
377
|
+
__publicField(this, "tabla");
|
|
378
|
+
__publicField(this, "parametros");
|
|
379
|
+
__publicField(this, "valores");
|
|
380
|
+
__publicField(this, "returning");
|
|
381
|
+
__publicField(this, "conexion");
|
|
370
382
|
if (!parametros || !Array.isArray(parametros)) {
|
|
371
383
|
throw new Error(`campos obligatorios`);
|
|
372
384
|
}
|
|
@@ -497,6 +509,17 @@ var Select = class {
|
|
|
497
509
|
* @param {string} condition - tabla1.id = tabla2.idtabla1 - id='2' - id='2' AND id='3'
|
|
498
510
|
*/
|
|
499
511
|
constructor(conexion, parametros = "*") {
|
|
512
|
+
__publicField(this, "conexion");
|
|
513
|
+
__publicField(this, "valores");
|
|
514
|
+
__publicField(this, "parametros");
|
|
515
|
+
__publicField(this, "tabla");
|
|
516
|
+
__publicField(this, "innerJoin");
|
|
517
|
+
__publicField(this, "leftjoins");
|
|
518
|
+
__publicField(this, "rigthjoins");
|
|
519
|
+
__publicField(this, "limit");
|
|
520
|
+
__publicField(this, "condicion");
|
|
521
|
+
__publicField(this, "orderBy");
|
|
522
|
+
__publicField(this, "offset");
|
|
500
523
|
this.conexion = conexion;
|
|
501
524
|
this.valores = !Array.isArray(parametros) ? false : true;
|
|
502
525
|
this.parametros = parametros;
|
|
@@ -507,6 +530,7 @@ var Select = class {
|
|
|
507
530
|
this.limit = "";
|
|
508
531
|
this.condicion = "";
|
|
509
532
|
this.orderBy = "";
|
|
533
|
+
this.offset = "";
|
|
510
534
|
}
|
|
511
535
|
/**
|
|
512
536
|
* @param {string} tabla - nombre de la ta tabla - campo obligatorio
|
|
@@ -589,6 +613,20 @@ var Select = class {
|
|
|
589
613
|
this.limit = `LIMIT ${cantidad}`;
|
|
590
614
|
return this;
|
|
591
615
|
}
|
|
616
|
+
/**
|
|
617
|
+
*
|
|
618
|
+
* @param {number} cant
|
|
619
|
+
* @returns
|
|
620
|
+
* @example
|
|
621
|
+
* .LIMIT(10).OFFSET(10).execute()
|
|
622
|
+
*/
|
|
623
|
+
OFFSET(cant) {
|
|
624
|
+
if (typeof cant !== "number") {
|
|
625
|
+
throw new Error("Cant tiene que ser un numero");
|
|
626
|
+
}
|
|
627
|
+
this.offset = ` OFFSET ${cant}`;
|
|
628
|
+
return this;
|
|
629
|
+
}
|
|
592
630
|
/**
|
|
593
631
|
*
|
|
594
632
|
* @param {String} texto
|
|
@@ -603,7 +641,7 @@ var Select = class {
|
|
|
603
641
|
selectFields = this.parametros.join(",");
|
|
604
642
|
}
|
|
605
643
|
}
|
|
606
|
-
const query = `SELECT ${selectFields} from ${this.tabla} ${this.innerJoin} ${this.leftjoins} ${this.rigthjoins} ${this.condicion} ${this.orderBy} ${this.limit};`;
|
|
644
|
+
const query = `SELECT ${selectFields} from ${this.tabla} ${this.innerJoin} ${this.leftjoins} ${this.rigthjoins} ${this.condicion} ${this.orderBy} ${this.limit} ${this.offset} ;`;
|
|
607
645
|
if (see) {
|
|
608
646
|
console.log(query);
|
|
609
647
|
}
|
|
@@ -628,32 +666,38 @@ var Select = class {
|
|
|
628
666
|
|
|
629
667
|
// conection/middleware/condicionals.ts
|
|
630
668
|
var AND = (...valor1) => {
|
|
631
|
-
const separacion = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" and ");
|
|
669
|
+
const separacion = valor1.filter((dato) => dato !== void 0 && dato !== null && dato.length !== 0).join(" and ");
|
|
632
670
|
return ` (${separacion}) `;
|
|
633
671
|
};
|
|
634
672
|
function ANDD(valores) {
|
|
635
|
-
const separacion = valores.filter((dato) => dato !== void 0 && dato !== null).join(" and ");
|
|
673
|
+
const separacion = valores.filter((dato) => dato !== void 0 && dato !== null && dato.length !== 0).join(" and ");
|
|
636
674
|
return ` (${separacion}) `;
|
|
637
675
|
}
|
|
638
676
|
var OR = (...valor1) => {
|
|
639
|
-
const separadosComas = valor1.filter((dato) => dato !== void 0 && dato !== null).join(" or ");
|
|
677
|
+
const separadosComas = valor1.filter((dato) => dato !== void 0 && dato !== null && dato.length !== 0).join(" or ");
|
|
640
678
|
return ` (${separadosComas}) `;
|
|
641
679
|
};
|
|
642
680
|
var ORD = (valores) => {
|
|
643
|
-
const separador = valores.filter((dato) => dato !== void 0 && dato !== null).join(" or ");
|
|
681
|
+
const separador = valores.filter((dato) => dato !== void 0 && dato !== null && dato.length !== 0).join(" or ");
|
|
644
682
|
return ` (${separador}) `;
|
|
645
683
|
};
|
|
646
684
|
var ORQ = (condicion1, ...condicionals) => {
|
|
647
|
-
const data2 = condicionals.
|
|
648
|
-
|
|
685
|
+
const data2 = condicionals.filter(
|
|
686
|
+
(dato) => dato !== null && !(typeof dato === "string" && dato.length === 0)
|
|
687
|
+
).map((dato) => {
|
|
688
|
+
if (typeof dato == "number" || typeof dato == "boolean")
|
|
689
|
+
return ` ${condicion1} = ${dato}`;
|
|
649
690
|
return ` ${condicion1} = '${dato}' `;
|
|
650
691
|
});
|
|
651
692
|
const separador = data2.join(" or ");
|
|
652
693
|
return ` (${separador}) `;
|
|
653
694
|
};
|
|
654
695
|
var ORQD = (condicion, valores) => {
|
|
655
|
-
const data = valores.
|
|
656
|
-
|
|
696
|
+
const data = valores.filter(
|
|
697
|
+
(dato) => dato !== null && !(typeof dato === "string" && dato.length === 0)
|
|
698
|
+
).map((dato) => {
|
|
699
|
+
if (typeof dato == "number" || typeof dato === "boolean")
|
|
700
|
+
return ` ${condicion} = ${dato}`;
|
|
657
701
|
return ` ${condicion} = '${dato}' `;
|
|
658
702
|
});
|
|
659
703
|
const separador = data.join(" or ");
|
|
@@ -720,9 +764,10 @@ var Update = class {
|
|
|
720
764
|
* @param {string} nombreTabla - nombre de la tabla a actualizar
|
|
721
765
|
*/
|
|
722
766
|
constructor(conexion, nombreTabla) {
|
|
723
|
-
this
|
|
724
|
-
this
|
|
725
|
-
this
|
|
767
|
+
__publicField(this, "conexion");
|
|
768
|
+
__publicField(this, "nombreTabla", "");
|
|
769
|
+
__publicField(this, "valores", "");
|
|
770
|
+
__publicField(this, "condicion", "");
|
|
726
771
|
if (typeof nombreTabla !== "string") {
|
|
727
772
|
throw new Error("el valor ingresado requiere un string");
|
|
728
773
|
}
|
|
@@ -842,11 +887,13 @@ var DB = class {
|
|
|
842
887
|
// conection/controls/int.ts
|
|
843
888
|
var IntColumn = class {
|
|
844
889
|
constructor() {
|
|
845
|
-
this
|
|
846
|
-
this
|
|
847
|
-
this
|
|
848
|
-
this
|
|
849
|
-
this
|
|
890
|
+
__publicField(this, "requerido", false);
|
|
891
|
+
__publicField(this, "unique", false);
|
|
892
|
+
__publicField(this, "autoIncrement", false);
|
|
893
|
+
__publicField(this, "defaultData");
|
|
894
|
+
__publicField(this, "pk");
|
|
895
|
+
__publicField(this, "unsingned", { uso: false, valor: 0 });
|
|
896
|
+
__publicField(this, "comentario", "");
|
|
850
897
|
}
|
|
851
898
|
Required() {
|
|
852
899
|
this.requerido = true;
|
|
@@ -937,13 +984,13 @@ function int() {
|
|
|
937
984
|
// conection/controls/varchar.ts
|
|
938
985
|
var Varchar = class {
|
|
939
986
|
constructor(cantidad = 100) {
|
|
940
|
-
this
|
|
941
|
-
this
|
|
942
|
-
this
|
|
943
|
-
this
|
|
944
|
-
this
|
|
945
|
-
this
|
|
946
|
-
this
|
|
987
|
+
__publicField(this, "maxLenth", 100);
|
|
988
|
+
__publicField(this, "defaultData", "");
|
|
989
|
+
__publicField(this, "requerido", false);
|
|
990
|
+
__publicField(this, "unique", false);
|
|
991
|
+
__publicField(this, "enum", "");
|
|
992
|
+
__publicField(this, "campo", "");
|
|
993
|
+
__publicField(this, "comentarios", "");
|
|
947
994
|
this.maxLenth = cantidad;
|
|
948
995
|
}
|
|
949
996
|
withType({
|
|
@@ -1013,8 +1060,9 @@ function varchar(cantidad = 100) {
|
|
|
1013
1060
|
// conection/controls/bool.ts
|
|
1014
1061
|
var BoolColumn = class {
|
|
1015
1062
|
constructor() {
|
|
1016
|
-
this
|
|
1017
|
-
this
|
|
1063
|
+
__publicField(this, "requerido", false);
|
|
1064
|
+
__publicField(this, "defaultData");
|
|
1065
|
+
__publicField(this, "comentario", "");
|
|
1018
1066
|
}
|
|
1019
1067
|
required() {
|
|
1020
1068
|
this.requerido = true;
|
|
@@ -1056,10 +1104,10 @@ function bool() {
|
|
|
1056
1104
|
// conection/controls/timestamp.ts
|
|
1057
1105
|
var Timestamp = class {
|
|
1058
1106
|
constructor() {
|
|
1059
|
-
this
|
|
1060
|
-
this
|
|
1061
|
-
this
|
|
1062
|
-
this
|
|
1107
|
+
__publicField(this, "requerido", false);
|
|
1108
|
+
__publicField(this, "defaultNow", false);
|
|
1109
|
+
__publicField(this, "onUpdateNow", false);
|
|
1110
|
+
__publicField(this, "comentario", "");
|
|
1063
1111
|
}
|
|
1064
1112
|
required() {
|
|
1065
1113
|
this.requerido = true;
|
|
@@ -1106,10 +1154,11 @@ function timestamp() {
|
|
|
1106
1154
|
// conection/controls/money.ts
|
|
1107
1155
|
var Money = class {
|
|
1108
1156
|
constructor(presicion = 10, decimales = 2) {
|
|
1109
|
-
this
|
|
1110
|
-
this
|
|
1111
|
-
this
|
|
1112
|
-
this
|
|
1157
|
+
__publicField(this, "precision", 10);
|
|
1158
|
+
__publicField(this, "scale", 2);
|
|
1159
|
+
__publicField(this, "requerido", false);
|
|
1160
|
+
__publicField(this, "defaultData");
|
|
1161
|
+
__publicField(this, "comentario", "");
|
|
1113
1162
|
this.precision = presicion;
|
|
1114
1163
|
this.scale = decimales;
|
|
1115
1164
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zormz",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Un ORM que busca ser ligero y facil de usar",
|
|
5
5
|
"author": "yukio-kayaba",
|
|
6
6
|
"license": "ISC",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"mysql",
|
|
13
13
|
"sql",
|
|
14
14
|
"typescript",
|
|
15
|
-
"
|
|
15
|
+
"zorm",
|
|
16
|
+
"ZORMZ",
|
|
16
17
|
"pg"
|
|
17
18
|
],
|
|
18
19
|
"main": "./dist/index.cjs",
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
},
|
|
35
36
|
"peerDependencies": {
|
|
36
37
|
"mysql": "*",
|
|
37
|
-
"pg": "^8.
|
|
38
|
+
"pg": "^8.20.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependenciesMeta": {
|
|
40
41
|
"pg": {
|
|
@@ -44,13 +45,13 @@
|
|
|
44
45
|
"optional": true
|
|
45
46
|
}
|
|
46
47
|
},
|
|
47
|
-
"dependencies": {
|
|
48
|
-
"mysql2": "^3.15.3"
|
|
49
|
-
},
|
|
50
48
|
"devDependencies": {
|
|
51
49
|
"@types/node": "^24.10.1",
|
|
52
50
|
"ts-node": "^10.9.2",
|
|
53
51
|
"tsup": "^8.5.1",
|
|
54
52
|
"typescript": "^5.9.3"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"mysql2": "^3.22.0"
|
|
55
56
|
}
|
|
56
57
|
}
|