@pasosdejesus/m 0.17.0 → 0.17.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/tasks/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/tasks/db.ts"],"names":[],"mappings":"AAyNA,wBAAsB,WAAW,kBAUhC;AAED,wBAAsB,SAAS,kBAU9B;AAED,wBAAsB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/tasks/db.ts"],"names":[],"mappings":"AAyNA,wBAAsB,WAAW,kBAUhC;AAED,wBAAsB,SAAS,kBAU9B;AAED,wBAAsB,oBAAoB,kBAyJzC;AAED,wBAAsB,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,iBAyDhD;AAED,wBAAsB,mBAAmB,kBAkBxC;AAkBD,wBAAsB,kBAAkB,kBAyCvC;AAED,wBAAsB,kBAAkB,kBAgCvC;AAED,wBAAsB,aAAa,kBAclC;AAED,wBAAsB,YAAY,kBAwCjC;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,iBA4B9C;AAED,wBAAsB,aAAa,kBAuBlC;AAED,wBAAsB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,iBA6B5C;AAED,wBAAsB,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,iBAmD/C;AAED,wBAAsB,SAAS,kBAAoD;AAEnF;;GAEG;AACH,wBAAsB,UAAU,kBAsF/B"}
|
package/dist/tasks/db.js
CHANGED
|
@@ -254,6 +254,10 @@ export async function runDbSuperCreateUser() {
|
|
|
254
254
|
// No modificar la siguiente línea fruto de larga experimentación.
|
|
255
255
|
const alterCmdForOpenBSD = `psql ${psqlSuperArgs} -d postgres -c \\\"ALTER USER ${user} WITH PASSWORD '${pass}';\\\"`.trim();
|
|
256
256
|
const alterCmdForShell = `psql ${psqlConnArgs} -d postgres -c "ALTER USER \"${user}\" WITH PASSWORD '${pass}';"`;
|
|
257
|
+
// Conceder privilegios de superusuario al usuario recién creado.
|
|
258
|
+
// Usa psqlSuperArgs porque otorgar SUPERUSER requiere conexión como superusuario.
|
|
259
|
+
const superuserCmdForOpenBSD = `psql ${psqlSuperArgs} -d postgres -c \\\"ALTER USER ${user} WITH SUPERUSER;\\\"`.trim();
|
|
260
|
+
const superuserCmdForShell = `psql ${psqlSuperArgs} -d postgres -c "ALTER USER \"${user}\" WITH SUPERUSER;"`;
|
|
257
261
|
const pgSuperUser = process.env.PG_SUPERUSER;
|
|
258
262
|
const pgSuperUserPassword = process.env.PG_SUPERUSER_PASSWORD;
|
|
259
263
|
const runPriv = (mode, cmd) => {
|
|
@@ -331,6 +335,17 @@ export async function runDbSuperCreateUser() {
|
|
|
331
335
|
problem(t('db.super.password_failed_mode', mode, lastErr));
|
|
332
336
|
continue;
|
|
333
337
|
}
|
|
338
|
+
else {
|
|
339
|
+
success(t('db.super.password_success', user));
|
|
340
|
+
}
|
|
341
|
+
const superuserCmd = (mode === 'openbsd_su') ? superuserCmdForOpenBSD : superuserCmdForShell;
|
|
342
|
+
res = runPriv(mode, superuserCmd);
|
|
343
|
+
if (res.status !== 0) {
|
|
344
|
+
const stderr = (res.stderr || '').toString();
|
|
345
|
+
lastErr = stderr || `Exit code ${res.status}`;
|
|
346
|
+
problem(t('db.super.password_failed_mode', mode, lastErr));
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
334
349
|
else {
|
|
335
350
|
success(t('db.super.password_success', user));
|
|
336
351
|
opSuccess = true;
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
export declare class MockKysely {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
_executeTakeFirst: (...args: any[]) => any;
|
|
16
|
+
_execute: (...args: any[]) => any;
|
|
17
|
+
_sqlExecute: (query: any) => any;
|
|
18
18
|
constructor(options?: {
|
|
19
19
|
executeTakeFirst?: (...args: any[]) => any;
|
|
20
20
|
execute?: (...args: any[]) => any;
|
|
@@ -89,7 +89,63 @@ export declare function createMockKysely(options?: {
|
|
|
89
89
|
/** Whether to skip mocking the config module (default: false) */
|
|
90
90
|
skipConfigMock?: boolean;
|
|
91
91
|
}): {
|
|
92
|
-
MockKysely:
|
|
92
|
+
MockKysely: {
|
|
93
|
+
new (): {
|
|
94
|
+
_executeTakeFirst: (...args: any[]) => any;
|
|
95
|
+
_execute: (...args: any[]) => any;
|
|
96
|
+
_sqlExecute: (query: any) => any;
|
|
97
|
+
selectFrom(): /*elided*/ any;
|
|
98
|
+
where(): /*elided*/ any;
|
|
99
|
+
selectAll(): /*elided*/ any;
|
|
100
|
+
select(...args: any[]): /*elided*/ any;
|
|
101
|
+
orderBy(): /*elided*/ any;
|
|
102
|
+
limit(): /*elided*/ any;
|
|
103
|
+
groupBy(): /*elided*/ any;
|
|
104
|
+
having(): /*elided*/ any;
|
|
105
|
+
leftJoin(): /*elided*/ any;
|
|
106
|
+
innerJoin(): /*elided*/ any;
|
|
107
|
+
insertInto(): /*elided*/ any;
|
|
108
|
+
values(): /*elided*/ any;
|
|
109
|
+
returningAll(): /*elided*/ any;
|
|
110
|
+
updateTable(): /*elided*/ any;
|
|
111
|
+
set(): /*elided*/ any;
|
|
112
|
+
deleteFrom(): /*elided*/ any;
|
|
113
|
+
with(): /*elided*/ any;
|
|
114
|
+
transaction(): {
|
|
115
|
+
execute: (callback: any) => Promise<any>;
|
|
116
|
+
};
|
|
117
|
+
executeTakeFirst(): any;
|
|
118
|
+
executeTakeFirstOrThrow(): any;
|
|
119
|
+
execute(): any;
|
|
120
|
+
getExecutor(): {
|
|
121
|
+
executeQuery: (query: any) => any;
|
|
122
|
+
provideConnection: (callback: any) => Promise<any>;
|
|
123
|
+
releaseConnection: () => void;
|
|
124
|
+
transformQuery: (query: any, transformer: any) => any;
|
|
125
|
+
compileQuery: (query: any, ctx: any) => {
|
|
126
|
+
sql: string;
|
|
127
|
+
parameters: never[];
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
fn: {
|
|
131
|
+
countAll: import("vitest").Mock<() => {
|
|
132
|
+
as: import("vitest").Mock<() => {}>;
|
|
133
|
+
}>;
|
|
134
|
+
sum: import("vitest").Mock<() => {
|
|
135
|
+
as: import("vitest").Mock<() => {}>;
|
|
136
|
+
}>;
|
|
137
|
+
avg: import("vitest").Mock<() => {
|
|
138
|
+
as: import("vitest").Mock<() => {}>;
|
|
139
|
+
}>;
|
|
140
|
+
max: import("vitest").Mock<() => {
|
|
141
|
+
as: import("vitest").Mock<() => {}>;
|
|
142
|
+
}>;
|
|
143
|
+
min: import("vitest").Mock<() => {
|
|
144
|
+
as: import("vitest").Mock<() => {}>;
|
|
145
|
+
}>;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
};
|
|
93
149
|
mockExecuteTakeFirst: import("vitest").Mock<(...args: any[]) => any>;
|
|
94
150
|
mockExecute: import("vitest").Mock<(...args: any[]) => any>;
|
|
95
151
|
mockSqlExecute: import("vitest").Mock<(...args: any[]) => any>;
|
|
@@ -117,7 +173,63 @@ export declare function createMockKysely(options?: {
|
|
|
117
173
|
* Pre-configured mock for database operations in API routes
|
|
118
174
|
*/
|
|
119
175
|
export declare const apiDbMocks: {
|
|
120
|
-
MockKysely:
|
|
176
|
+
MockKysely: {
|
|
177
|
+
new (): {
|
|
178
|
+
_executeTakeFirst: (...args: any[]) => any;
|
|
179
|
+
_execute: (...args: any[]) => any;
|
|
180
|
+
_sqlExecute: (query: any) => any;
|
|
181
|
+
selectFrom(): /*elided*/ any;
|
|
182
|
+
where(): /*elided*/ any;
|
|
183
|
+
selectAll(): /*elided*/ any;
|
|
184
|
+
select(...args: any[]): /*elided*/ any;
|
|
185
|
+
orderBy(): /*elided*/ any;
|
|
186
|
+
limit(): /*elided*/ any;
|
|
187
|
+
groupBy(): /*elided*/ any;
|
|
188
|
+
having(): /*elided*/ any;
|
|
189
|
+
leftJoin(): /*elided*/ any;
|
|
190
|
+
innerJoin(): /*elided*/ any;
|
|
191
|
+
insertInto(): /*elided*/ any;
|
|
192
|
+
values(): /*elided*/ any;
|
|
193
|
+
returningAll(): /*elided*/ any;
|
|
194
|
+
updateTable(): /*elided*/ any;
|
|
195
|
+
set(): /*elided*/ any;
|
|
196
|
+
deleteFrom(): /*elided*/ any;
|
|
197
|
+
with(): /*elided*/ any;
|
|
198
|
+
transaction(): {
|
|
199
|
+
execute: (callback: any) => Promise<any>;
|
|
200
|
+
};
|
|
201
|
+
executeTakeFirst(): any;
|
|
202
|
+
executeTakeFirstOrThrow(): any;
|
|
203
|
+
execute(): any;
|
|
204
|
+
getExecutor(): {
|
|
205
|
+
executeQuery: (query: any) => any;
|
|
206
|
+
provideConnection: (callback: any) => Promise<any>;
|
|
207
|
+
releaseConnection: () => void;
|
|
208
|
+
transformQuery: (query: any, transformer: any) => any;
|
|
209
|
+
compileQuery: (query: any, ctx: any) => {
|
|
210
|
+
sql: string;
|
|
211
|
+
parameters: never[];
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
fn: {
|
|
215
|
+
countAll: import("vitest").Mock<() => {
|
|
216
|
+
as: import("vitest").Mock<() => {}>;
|
|
217
|
+
}>;
|
|
218
|
+
sum: import("vitest").Mock<() => {
|
|
219
|
+
as: import("vitest").Mock<() => {}>;
|
|
220
|
+
}>;
|
|
221
|
+
avg: import("vitest").Mock<() => {
|
|
222
|
+
as: import("vitest").Mock<() => {}>;
|
|
223
|
+
}>;
|
|
224
|
+
max: import("vitest").Mock<() => {
|
|
225
|
+
as: import("vitest").Mock<() => {}>;
|
|
226
|
+
}>;
|
|
227
|
+
min: import("vitest").Mock<() => {
|
|
228
|
+
as: import("vitest").Mock<() => {}>;
|
|
229
|
+
}>;
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
};
|
|
121
233
|
mockExecuteTakeFirst: import("vitest").Mock<(...args: any[]) => any>;
|
|
122
234
|
mockExecute: import("vitest").Mock<(...args: any[]) => any>;
|
|
123
235
|
mockSqlExecute: import("vitest").Mock<(...args: any[]) => any>;
|
|
@@ -145,7 +257,63 @@ export declare const apiDbMocks: {
|
|
|
145
257
|
* Pre-configured mock for database operations in lib functions
|
|
146
258
|
*/
|
|
147
259
|
export declare const libDbMocks: {
|
|
148
|
-
MockKysely:
|
|
260
|
+
MockKysely: {
|
|
261
|
+
new (): {
|
|
262
|
+
_executeTakeFirst: (...args: any[]) => any;
|
|
263
|
+
_execute: (...args: any[]) => any;
|
|
264
|
+
_sqlExecute: (query: any) => any;
|
|
265
|
+
selectFrom(): /*elided*/ any;
|
|
266
|
+
where(): /*elided*/ any;
|
|
267
|
+
selectAll(): /*elided*/ any;
|
|
268
|
+
select(...args: any[]): /*elided*/ any;
|
|
269
|
+
orderBy(): /*elided*/ any;
|
|
270
|
+
limit(): /*elided*/ any;
|
|
271
|
+
groupBy(): /*elided*/ any;
|
|
272
|
+
having(): /*elided*/ any;
|
|
273
|
+
leftJoin(): /*elided*/ any;
|
|
274
|
+
innerJoin(): /*elided*/ any;
|
|
275
|
+
insertInto(): /*elided*/ any;
|
|
276
|
+
values(): /*elided*/ any;
|
|
277
|
+
returningAll(): /*elided*/ any;
|
|
278
|
+
updateTable(): /*elided*/ any;
|
|
279
|
+
set(): /*elided*/ any;
|
|
280
|
+
deleteFrom(): /*elided*/ any;
|
|
281
|
+
with(): /*elided*/ any;
|
|
282
|
+
transaction(): {
|
|
283
|
+
execute: (callback: any) => Promise<any>;
|
|
284
|
+
};
|
|
285
|
+
executeTakeFirst(): any;
|
|
286
|
+
executeTakeFirstOrThrow(): any;
|
|
287
|
+
execute(): any;
|
|
288
|
+
getExecutor(): {
|
|
289
|
+
executeQuery: (query: any) => any;
|
|
290
|
+
provideConnection: (callback: any) => Promise<any>;
|
|
291
|
+
releaseConnection: () => void;
|
|
292
|
+
transformQuery: (query: any, transformer: any) => any;
|
|
293
|
+
compileQuery: (query: any, ctx: any) => {
|
|
294
|
+
sql: string;
|
|
295
|
+
parameters: never[];
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
fn: {
|
|
299
|
+
countAll: import("vitest").Mock<() => {
|
|
300
|
+
as: import("vitest").Mock<() => {}>;
|
|
301
|
+
}>;
|
|
302
|
+
sum: import("vitest").Mock<() => {
|
|
303
|
+
as: import("vitest").Mock<() => {}>;
|
|
304
|
+
}>;
|
|
305
|
+
avg: import("vitest").Mock<() => {
|
|
306
|
+
as: import("vitest").Mock<() => {}>;
|
|
307
|
+
}>;
|
|
308
|
+
max: import("vitest").Mock<() => {
|
|
309
|
+
as: import("vitest").Mock<() => {}>;
|
|
310
|
+
}>;
|
|
311
|
+
min: import("vitest").Mock<() => {
|
|
312
|
+
as: import("vitest").Mock<() => {}>;
|
|
313
|
+
}>;
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
};
|
|
149
317
|
mockExecuteTakeFirst: import("vitest").Mock<(...args: any[]) => any>;
|
|
150
318
|
mockExecute: import("vitest").Mock<(...args: any[]) => any>;
|
|
151
319
|
mockSqlExecute: import("vitest").Mock<(...args: any[]) => any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kysely-mocks.d.ts","sourceRoot":"","sources":["../../src/test-utils/kysely-mocks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;GAOG;AACH,qBAAa,UAAU;IACrB,
|
|
1
|
+
{"version":3,"file":"kysely-mocks.d.ts","sourceRoot":"","sources":["../../src/test-utils/kysely-mocks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;GAOG;AACH,qBAAa,UAAU;IACrB,iBAAiB,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IAC1C,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IACjC,WAAW,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAA;gBAE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GAAG,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yCA8DpB,GAAG;;;IAapB;;;OAGG;;IAqBH;;OAEG;;IASH;;OAEG;;EAQN;AAED;;GAEG;AACH,eAAO,MAAM,UAAU;;;+BAlLF,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;sBAChC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;yBACpB,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG;;;;4BAehB,GAAG,EAAE;;;;;;;;;;;;;;;oCAiBS,GAAG;;;;;;sCAeP,GAAG;8CACW,GAAG;;wCAEf,GAAG,eAAe,GAAG;sCACvB,GAAG,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yCA8DpB,GAAG;;;IAapB;;;OAGG;;IAqBH;;OAEG;;IASH;;OAEG;;CAaqC,CAAA;AAE5C;;GAEG;AACH,eAAO,MAAM,UAAU;;;+BAvLF,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;sBAChC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;yBACpB,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG;;;;4BAehB,GAAG,EAAE;;;;;;;;;;;;;;;oCAiBS,GAAG;;;;;;sCAeP,GAAG;8CACW,GAAG;;wCAEf,GAAG,eAAe,GAAG;sCACvB,GAAG,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yCA8DpB,GAAG;;;IAapB;;;OAGG;;IAqBH;;OAEG;;IASH;;OAEG;;CAkBqC,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY;;;;;;;;;;;;;;;;;;;;;;;EAyB3B"}
|
|
@@ -91,6 +91,17 @@ export function createMockKysely(options = {}) {
|
|
|
91
91
|
if (opts.sqlExecute !== undefined) {
|
|
92
92
|
mockSqlExecute.mockImplementation(options.sqlExecute);
|
|
93
93
|
}
|
|
94
|
+
// Wire the MockKysely class to the shared mock functions so that
|
|
95
|
+
// libDbMocks.mockExecute (etc.) reflect actual DB calls made by the code.
|
|
96
|
+
class WiredMockKysely extends MockKysely {
|
|
97
|
+
constructor() {
|
|
98
|
+
super({
|
|
99
|
+
executeTakeFirst: mockExecuteTakeFirst,
|
|
100
|
+
execute: mockExecute,
|
|
101
|
+
sqlExecute: mockSqlExecute,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
94
105
|
const mockSql = vi.fn(() => ({
|
|
95
106
|
as: vi.fn().mockReturnValue({}),
|
|
96
107
|
execute: mockSqlExecute,
|
|
@@ -98,7 +109,7 @@ export function createMockKysely(options = {}) {
|
|
|
98
109
|
}));
|
|
99
110
|
const mockPgPool = vi.fn();
|
|
100
111
|
return {
|
|
101
|
-
MockKysely,
|
|
112
|
+
MockKysely: WiredMockKysely,
|
|
102
113
|
mockExecuteTakeFirst,
|
|
103
114
|
mockExecute,
|
|
104
115
|
mockSqlExecute,
|
|
@@ -110,7 +121,7 @@ export function createMockKysely(options = {}) {
|
|
|
110
121
|
*/
|
|
111
122
|
setupMocks() {
|
|
112
123
|
vi.mock('kysely', () => ({
|
|
113
|
-
Kysely:
|
|
124
|
+
Kysely: WiredMockKysely,
|
|
114
125
|
PostgresDialect: vi.fn(),
|
|
115
126
|
sql: mockSql,
|
|
116
127
|
}));
|
|
@@ -121,7 +132,7 @@ export function createMockKysely(options = {}) {
|
|
|
121
132
|
const skipConfigMock = opts.skipConfigMock || false;
|
|
122
133
|
if (!skipConfigMock) {
|
|
123
134
|
vi.mock('@/.config/kysely.config', () => ({
|
|
124
|
-
newKyselyPostgresql: vi.fn(() => new
|
|
135
|
+
newKyselyPostgresql: vi.fn(() => new WiredMockKysely()),
|
|
125
136
|
}));
|
|
126
137
|
}
|
|
127
138
|
},
|