zormz 1.0.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.
@@ -0,0 +1,266 @@
1
+ interface connecionLocal {
2
+ host: string;
3
+ port: number;
4
+ database: string;
5
+ user: string;
6
+ password: string;
7
+ }
8
+ interface Consultas {
9
+ query: string;
10
+ valores?: any[] | [[]];
11
+ mensaje?: string;
12
+ }
13
+ interface connecionRed {
14
+ connectionString: string;
15
+ }
16
+ type connectionDB = "mysql" | "pg";
17
+ declare class BDconnection {
18
+ tipo: connectionDB;
19
+ pool: any;
20
+ private connection;
21
+ constructor(bd: connectionDB, datos: connecionLocal | connecionRed);
22
+ private connecionMyql;
23
+ private connectionPG;
24
+ executeConsulta({ query, valores, mensaje, }: Consultas): Promise<any>;
25
+ }
26
+ /**
27
+ *
28
+ * @param bd
29
+ * @param datos
30
+ * //esta funcion realmente puedes ponerlo en tu archivo raiz para que funcion en todo tu programa
31
+ */
32
+ declare function getConexion(bd: connectionDB, datos: connecionLocal | connecionRed): void;
33
+ declare function getRed(): BDconnection;
34
+
35
+ declare class DeleteR {
36
+ #private;
37
+ private conexion;
38
+ /**
39
+ *
40
+ * @param {string} tabla -- tabla a eliminar
41
+ * @example
42
+ * delete from tabla
43
+ */
44
+ constructor(conexion: BDconnection, tabla: string);
45
+ /**
46
+ *
47
+ * @param {string} condicion -- condicional de tabla
48
+ * @example
49
+ * DB.Delete(tabla).WHERE(eq(valor,valor))
50
+ * DB.Delete(tabla).WHERE(AND(eq(valor,valor), eq(valor2,valor2)))
51
+ */
52
+ where(condicion: string): this;
53
+ execute(): Promise<any>;
54
+ }
55
+
56
+ type arrayData = (string | number)[];
57
+ type arrayDatas = (string | number)[][];
58
+ declare class QueryBuilder {
59
+ private tabla;
60
+ private parametros;
61
+ private valores;
62
+ private valorRetorno;
63
+ private conexion;
64
+ /**
65
+ * @throws {Error} Si la consulta es vacía.
66
+ */
67
+ /**
68
+ * @param {string[]} parametros - campo obligatorio
69
+ * @param {string} tabla - nombre de la ta tabla - campo obligatorio
70
+ * @param {string[]} values - campo obligatorio
71
+ */
72
+ constructor(conexion: BDconnection, tabla: string, parametros: string[]);
73
+ /**
74
+ *
75
+ * @param {arrayData | arrayDatas} values
76
+ * @example
77
+ * //para un salo dato
78
+ * ['dato1','dato2']
79
+ * //para varios datos
80
+ * [['dato1','dato1/2'],['dato2','dato2/2']]
81
+ *
82
+ * @returns
83
+ */
84
+ Values(values: arrayData | arrayDatas): this;
85
+ execute(): Promise<any>;
86
+ }
87
+
88
+ type valor = "ASC" | "DESC";
89
+ type Tipos = {
90
+ [clave: string]: valor;
91
+ };
92
+ declare class Select {
93
+ private conexion;
94
+ private valores;
95
+ private parametros;
96
+ private tabla;
97
+ private innerJoin;
98
+ private leftjoins;
99
+ private rigthjoins;
100
+ private limit;
101
+ private condicion;
102
+ private orderBy;
103
+ /**
104
+ * @param {string[]} parametros - campo obligatorio
105
+ * @param {string} tabla - nombre de la ta tabla - campo obligatorio
106
+ * @param {string[]} values - campo obligatorio
107
+ * @param {string} condition - tabla1.id = tabla2.idtabla1 - id='2' - id='2' AND id='3'
108
+ */
109
+ constructor(conexion: BDconnection, parametros?: string[] | string);
110
+ /**
111
+ * @param {string} tabla - nombre de la ta tabla - campo obligatorio
112
+ */
113
+ from(tabla: string): this;
114
+ innerJOIN(tabla: string, condition: string): this;
115
+ leftJoin(tabla: string, condition: string): this;
116
+ rigthJoin(tabla: string, condition: string): this;
117
+ /**
118
+ * @param {string} condition - tabla1.id = tabla2.idtabla1 - id='2' - id='2' AND id='3'
119
+ */
120
+ where(condition?: string | undefined): this;
121
+ /**
122
+ * @typedef { "ASC" | "DESC" } tipos
123
+ */
124
+ /**
125
+ *
126
+ * @param {{
127
+ * [clave:string]:tipos
128
+ * }} objeto --Filtrado
129
+ * @example
130
+ * select().orderBy({nombre:'DESC',id:'ASC'});
131
+ */
132
+ OrderBy(objeto: Tipos): this;
133
+ /**
134
+ *
135
+ * @param {Number} cantidad
136
+ */
137
+ LIMIT(cantidad?: number): this;
138
+ /**
139
+ *
140
+ * @param {String} texto
141
+ */
142
+ /**
143
+ * @returns {Promise<Array<Object>>}
144
+ */
145
+ execute(): Promise<any>;
146
+ }
147
+
148
+ type Valores = Record<string, string | number | undefined>;
149
+ declare class Update {
150
+ private conexion;
151
+ private nombreTabla;
152
+ private valores;
153
+ private condicion;
154
+ /**
155
+ * @param {string} nombreTabla - nombre de la tabla a actualizar
156
+ */
157
+ constructor(conexion: BDconnection, nombreTabla: string);
158
+ /**
159
+ * @param {Valores} valores - valores a actualizar
160
+ * @example
161
+ * .set({'campo1':'valor1', 'campo2':'valor2'})
162
+ */
163
+ set(valores: Valores): this;
164
+ /**
165
+ * @param {string} condicion - valor condicional
166
+ * @example
167
+ * //para completar una condicional puedes usar
168
+ * where(eq())
169
+ * where(AND())
170
+ * where(OR())
171
+ * where(ORQ())
172
+ */
173
+ where(condicion: string): this;
174
+ execute(): Promise<any>;
175
+ }
176
+
177
+ declare class DB {
178
+ /**
179
+ * @param {string} tabla - campo obligatorio
180
+ * @param {string[]} parametros - campo obligatorio
181
+ * @example
182
+ * DB.Insert('tabla',['campo1','campo2'])
183
+ */
184
+ static Insert(tabla: string, parametros: string[]): QueryBuilder;
185
+ /**
186
+ * @param {string[]} parametros - campo opcional
187
+ */
188
+ static select(parametros?: string[]): Select;
189
+ /**
190
+ * @param {string} nombreTabla - nombre de la tabla a actualizar
191
+ */
192
+ static update(nombreTabla: string): Update;
193
+ /**
194
+ *
195
+ * @param {string} nombreTabla -- tabla a eliminar
196
+ * @example
197
+ * delete from tabla
198
+ */
199
+ static Delete(nombreTabla: string): DeleteR;
200
+ }
201
+
202
+ type Valor = string | number | boolean;
203
+ /**
204
+ *
205
+ * @param {(string | number | boolean )} valor1 - eq(val,val1)
206
+ * //para una sola condicion
207
+ * AND(eq())
208
+ * //para varios condiciones
209
+ * AND(eq(),eq(),eq(),eq(),OR())
210
+ */
211
+ declare const AND: (...valor1: Valor[]) => string;
212
+ /**
213
+ *
214
+ * @param {(string | number | boolean )} valor1 - eq(val,val1)
215
+ * @example
216
+ * //para una sola condicion
217
+ * OR(eq())
218
+ * //para varios condiciones
219
+ * OR(eq(),eq(),eq(),eq(),AND())
220
+ */
221
+ declare const OR: (...valor1: Valor[]) => string;
222
+ /**
223
+ *
224
+ * @param {Valor} condicion1
225
+ * @param {Valor[]} condicionals
226
+ * @example
227
+ * //basta con definir una ves la condicion repetida
228
+ * ORQ('id',1,2);
229
+ * @returns
230
+ */
231
+ declare const ORQ: (condicion1: Valor, ...condicionals: Valor[]) => string;
232
+ declare const ILIKE: (valor1: string, valor2: string) => string;
233
+ /**
234
+ *
235
+ * @param {String} variable -Type timestamp
236
+ * @param {Number} diasTrancurridos -type number
237
+ */
238
+ declare const now: (variable: string, diasTrancurridos: number, minor?: boolean) => string;
239
+ /**
240
+ *
241
+ * @param {String} variable - variable
242
+ */
243
+ declare const NULL: (variable: string) => string;
244
+ /**
245
+ *
246
+ * @param {String} variable
247
+ * @returns
248
+ */
249
+ declare const NOTNULL: (variable: string) => string;
250
+ /**
251
+ *
252
+ * @param {(string | number | boolean )} valor1 - primer valor
253
+ * @param {(string | number | boolean )} valor2 - segundo valor
254
+ * @param {(boolean )} literal
255
+ *
256
+ * @example
257
+ * //en caso sea un valores normalres
258
+ * eq('id','1')
259
+ * //en caso de que seaq un valor de tabla columna
260
+ * eq('id',valor1, false)
261
+ */
262
+ 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;
265
+
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 };
@@ -0,0 +1,266 @@
1
+ interface connecionLocal {
2
+ host: string;
3
+ port: number;
4
+ database: string;
5
+ user: string;
6
+ password: string;
7
+ }
8
+ interface Consultas {
9
+ query: string;
10
+ valores?: any[] | [[]];
11
+ mensaje?: string;
12
+ }
13
+ interface connecionRed {
14
+ connectionString: string;
15
+ }
16
+ type connectionDB = "mysql" | "pg";
17
+ declare class BDconnection {
18
+ tipo: connectionDB;
19
+ pool: any;
20
+ private connection;
21
+ constructor(bd: connectionDB, datos: connecionLocal | connecionRed);
22
+ private connecionMyql;
23
+ private connectionPG;
24
+ executeConsulta({ query, valores, mensaje, }: Consultas): Promise<any>;
25
+ }
26
+ /**
27
+ *
28
+ * @param bd
29
+ * @param datos
30
+ * //esta funcion realmente puedes ponerlo en tu archivo raiz para que funcion en todo tu programa
31
+ */
32
+ declare function getConexion(bd: connectionDB, datos: connecionLocal | connecionRed): void;
33
+ declare function getRed(): BDconnection;
34
+
35
+ declare class DeleteR {
36
+ #private;
37
+ private conexion;
38
+ /**
39
+ *
40
+ * @param {string} tabla -- tabla a eliminar
41
+ * @example
42
+ * delete from tabla
43
+ */
44
+ constructor(conexion: BDconnection, tabla: string);
45
+ /**
46
+ *
47
+ * @param {string} condicion -- condicional de tabla
48
+ * @example
49
+ * DB.Delete(tabla).WHERE(eq(valor,valor))
50
+ * DB.Delete(tabla).WHERE(AND(eq(valor,valor), eq(valor2,valor2)))
51
+ */
52
+ where(condicion: string): this;
53
+ execute(): Promise<any>;
54
+ }
55
+
56
+ type arrayData = (string | number)[];
57
+ type arrayDatas = (string | number)[][];
58
+ declare class QueryBuilder {
59
+ private tabla;
60
+ private parametros;
61
+ private valores;
62
+ private valorRetorno;
63
+ private conexion;
64
+ /**
65
+ * @throws {Error} Si la consulta es vacía.
66
+ */
67
+ /**
68
+ * @param {string[]} parametros - campo obligatorio
69
+ * @param {string} tabla - nombre de la ta tabla - campo obligatorio
70
+ * @param {string[]} values - campo obligatorio
71
+ */
72
+ constructor(conexion: BDconnection, tabla: string, parametros: string[]);
73
+ /**
74
+ *
75
+ * @param {arrayData | arrayDatas} values
76
+ * @example
77
+ * //para un salo dato
78
+ * ['dato1','dato2']
79
+ * //para varios datos
80
+ * [['dato1','dato1/2'],['dato2','dato2/2']]
81
+ *
82
+ * @returns
83
+ */
84
+ Values(values: arrayData | arrayDatas): this;
85
+ execute(): Promise<any>;
86
+ }
87
+
88
+ type valor = "ASC" | "DESC";
89
+ type Tipos = {
90
+ [clave: string]: valor;
91
+ };
92
+ declare class Select {
93
+ private conexion;
94
+ private valores;
95
+ private parametros;
96
+ private tabla;
97
+ private innerJoin;
98
+ private leftjoins;
99
+ private rigthjoins;
100
+ private limit;
101
+ private condicion;
102
+ private orderBy;
103
+ /**
104
+ * @param {string[]} parametros - campo obligatorio
105
+ * @param {string} tabla - nombre de la ta tabla - campo obligatorio
106
+ * @param {string[]} values - campo obligatorio
107
+ * @param {string} condition - tabla1.id = tabla2.idtabla1 - id='2' - id='2' AND id='3'
108
+ */
109
+ constructor(conexion: BDconnection, parametros?: string[] | string);
110
+ /**
111
+ * @param {string} tabla - nombre de la ta tabla - campo obligatorio
112
+ */
113
+ from(tabla: string): this;
114
+ innerJOIN(tabla: string, condition: string): this;
115
+ leftJoin(tabla: string, condition: string): this;
116
+ rigthJoin(tabla: string, condition: string): this;
117
+ /**
118
+ * @param {string} condition - tabla1.id = tabla2.idtabla1 - id='2' - id='2' AND id='3'
119
+ */
120
+ where(condition?: string | undefined): this;
121
+ /**
122
+ * @typedef { "ASC" | "DESC" } tipos
123
+ */
124
+ /**
125
+ *
126
+ * @param {{
127
+ * [clave:string]:tipos
128
+ * }} objeto --Filtrado
129
+ * @example
130
+ * select().orderBy({nombre:'DESC',id:'ASC'});
131
+ */
132
+ OrderBy(objeto: Tipos): this;
133
+ /**
134
+ *
135
+ * @param {Number} cantidad
136
+ */
137
+ LIMIT(cantidad?: number): this;
138
+ /**
139
+ *
140
+ * @param {String} texto
141
+ */
142
+ /**
143
+ * @returns {Promise<Array<Object>>}
144
+ */
145
+ execute(): Promise<any>;
146
+ }
147
+
148
+ type Valores = Record<string, string | number | undefined>;
149
+ declare class Update {
150
+ private conexion;
151
+ private nombreTabla;
152
+ private valores;
153
+ private condicion;
154
+ /**
155
+ * @param {string} nombreTabla - nombre de la tabla a actualizar
156
+ */
157
+ constructor(conexion: BDconnection, nombreTabla: string);
158
+ /**
159
+ * @param {Valores} valores - valores a actualizar
160
+ * @example
161
+ * .set({'campo1':'valor1', 'campo2':'valor2'})
162
+ */
163
+ set(valores: Valores): this;
164
+ /**
165
+ * @param {string} condicion - valor condicional
166
+ * @example
167
+ * //para completar una condicional puedes usar
168
+ * where(eq())
169
+ * where(AND())
170
+ * where(OR())
171
+ * where(ORQ())
172
+ */
173
+ where(condicion: string): this;
174
+ execute(): Promise<any>;
175
+ }
176
+
177
+ declare class DB {
178
+ /**
179
+ * @param {string} tabla - campo obligatorio
180
+ * @param {string[]} parametros - campo obligatorio
181
+ * @example
182
+ * DB.Insert('tabla',['campo1','campo2'])
183
+ */
184
+ static Insert(tabla: string, parametros: string[]): QueryBuilder;
185
+ /**
186
+ * @param {string[]} parametros - campo opcional
187
+ */
188
+ static select(parametros?: string[]): Select;
189
+ /**
190
+ * @param {string} nombreTabla - nombre de la tabla a actualizar
191
+ */
192
+ static update(nombreTabla: string): Update;
193
+ /**
194
+ *
195
+ * @param {string} nombreTabla -- tabla a eliminar
196
+ * @example
197
+ * delete from tabla
198
+ */
199
+ static Delete(nombreTabla: string): DeleteR;
200
+ }
201
+
202
+ type Valor = string | number | boolean;
203
+ /**
204
+ *
205
+ * @param {(string | number | boolean )} valor1 - eq(val,val1)
206
+ * //para una sola condicion
207
+ * AND(eq())
208
+ * //para varios condiciones
209
+ * AND(eq(),eq(),eq(),eq(),OR())
210
+ */
211
+ declare const AND: (...valor1: Valor[]) => string;
212
+ /**
213
+ *
214
+ * @param {(string | number | boolean )} valor1 - eq(val,val1)
215
+ * @example
216
+ * //para una sola condicion
217
+ * OR(eq())
218
+ * //para varios condiciones
219
+ * OR(eq(),eq(),eq(),eq(),AND())
220
+ */
221
+ declare const OR: (...valor1: Valor[]) => string;
222
+ /**
223
+ *
224
+ * @param {Valor} condicion1
225
+ * @param {Valor[]} condicionals
226
+ * @example
227
+ * //basta con definir una ves la condicion repetida
228
+ * ORQ('id',1,2);
229
+ * @returns
230
+ */
231
+ declare const ORQ: (condicion1: Valor, ...condicionals: Valor[]) => string;
232
+ declare const ILIKE: (valor1: string, valor2: string) => string;
233
+ /**
234
+ *
235
+ * @param {String} variable -Type timestamp
236
+ * @param {Number} diasTrancurridos -type number
237
+ */
238
+ declare const now: (variable: string, diasTrancurridos: number, minor?: boolean) => string;
239
+ /**
240
+ *
241
+ * @param {String} variable - variable
242
+ */
243
+ declare const NULL: (variable: string) => string;
244
+ /**
245
+ *
246
+ * @param {String} variable
247
+ * @returns
248
+ */
249
+ declare const NOTNULL: (variable: string) => string;
250
+ /**
251
+ *
252
+ * @param {(string | number | boolean )} valor1 - primer valor
253
+ * @param {(string | number | boolean )} valor2 - segundo valor
254
+ * @param {(boolean )} literal
255
+ *
256
+ * @example
257
+ * //en caso sea un valores normalres
258
+ * eq('id','1')
259
+ * //en caso de que seaq un valor de tabla columna
260
+ * eq('id',valor1, false)
261
+ */
262
+ 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;
265
+
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 };