@lensjs/core 2.1.1 → 2.2.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/core/lens.cjs +32 -27
- package/dist/core/lens.d.cts +27 -3
- package/dist/core/lens.d.ts +27 -3
- package/dist/core/lens.js +32 -27
- package/dist/{index-DiLfwsvc.d.cts → index-CMvlRWcQ.d.cts} +5 -4
- package/dist/{index-DiLfwsvc.d.ts → index-CMvlRWcQ.d.ts} +5 -4
- package/dist/index.cjs +79 -42
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +79 -42
- package/dist/stores/better_sqlite.cjs +2 -0
- package/dist/stores/better_sqlite.js +2 -0
- package/dist/stores/index.cjs +2 -0
- package/dist/stores/index.js +2 -0
- package/dist/ui/assets/{CacheActionBadge-CK7JdKoE.js → CacheActionBadge-WGVr5yhe.js} +1 -1
- package/dist/ui/assets/CacheEntriesTable-txREHfFk.js +1 -0
- package/dist/ui/assets/CacheEntryContainer-BoeiVJN6.js +2 -0
- package/dist/ui/assets/{CacheEntryDetails-D9Xy7d9u.js → CacheEntryDetails-DovbpPae.js} +1 -1
- package/dist/ui/assets/CacheEntryDetailsContainer-DcmH8iqv.js +2 -0
- package/dist/ui/assets/ExceptionContainer-C0H0kKkb.js +2 -0
- package/dist/ui/assets/{ExceptionDetails-BbIFoM7M.js → ExceptionDetails-DX14YGmx.js} +1 -1
- package/dist/ui/assets/ExceptionDetailsContainer-CHAXdzwk.js +2 -0
- package/dist/ui/assets/{ExceptionTable-DY3mmGT4.js → ExceptionTable-Chiah5kT.js} +1 -1
- package/dist/ui/assets/{LoadMore-CJh7FLbl.js → LoadMore-CosGy1fp.js} +1 -1
- package/dist/ui/assets/QueriesContainer-CporgPyk.js +2 -0
- package/dist/ui/assets/{QueryDetailsContainer-7CA9a5de.js → QueryDetailsContainer-Dimuidq4.js} +1 -1
- package/dist/ui/assets/{QueryTable-pn7Ayura.js → QueryTable-BLpmWt7g.js} +1 -1
- package/dist/ui/assets/RequestDetails-DeJofxSW.js +1 -0
- package/dist/ui/assets/{RequestDetailsContainer-BECT0XJh.js → RequestDetailsContainer-BtDTKq1O.js} +2 -2
- package/dist/ui/assets/{RequestsContainer-DLkjpX67.js → RequestsContainer-CxIavrPj.js} +2 -2
- package/dist/ui/assets/{RequetsTable-Cgas07Fe.js → RequetsTable-CUevs9X4.js} +1 -1
- package/dist/ui/assets/{StatusCode-C5lihzKZ.js → StatusCode-D_bCVpUf.js} +1 -1
- package/dist/ui/assets/{TabbedDataViewer-BUMQ0QVm.js → TabbedDataViewer-CbZANxvH.js} +1 -1
- package/dist/ui/assets/{Table-BesHc4Lc.js → Table-z_QSS7J8.js} +1 -1
- package/dist/ui/assets/{columns-C1CwS8yE.js → columns-Bxz-DZCj.js} +1 -1
- package/dist/ui/assets/{columns-CULxhcpY.js → columns-D0UC1pqC.js} +1 -1
- package/dist/ui/assets/columns-DJaOm2Yg.js +1 -0
- package/dist/ui/assets/{index-PEcJ5nx0.js → index-CQJv-KV7.js} +2 -2
- package/dist/ui/assets/{useCacheEntries-jbGe2CRY.js → useCacheEntries-DWzLAzvE.js} +1 -1
- package/dist/ui/assets/{useExceptions-uYUhAW-J.js → useExceptions-BF0fHNek.js} +1 -1
- package/dist/ui/assets/{useLensApi-BsDmB7vx.js → useLensApi-BEMg_OuP.js} +1 -1
- package/dist/ui/assets/{useLoadMore-sLsrekV5.js → useLoadMore-ClIkZ0Gw.js} +1 -1
- package/dist/ui/assets/{useQueries-DJE91mYq.js → useQueries-C0vKfgzw.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/utils/event_emitter.cjs +20 -12
- package/dist/utils/event_emitter.d.cts +12 -7
- package/dist/utils/event_emitter.d.ts +12 -7
- package/dist/utils/event_emitter.js +20 -2
- package/dist/utils/index.cjs +27 -12
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +26 -12
- package/dist/watchers/cache_watcher.cjs +1 -1
- package/dist/watchers/cache_watcher.js +1 -1
- package/dist/watchers/index.cjs +1 -1
- package/dist/watchers/index.js +1 -1
- package/package.json +1 -2
- package/dist/ui/assets/CacheEntriesTable-C5HcgCZI.js +0 -1
- package/dist/ui/assets/CacheEntryContainer-C0no2_6_.js +0 -2
- package/dist/ui/assets/CacheEntryDetailsContainer-BcwliP55.js +0 -2
- package/dist/ui/assets/ExceptionContainer-CQalcd8x.js +0 -2
- package/dist/ui/assets/ExceptionDetailsContainer-fajmF7id.js +0 -2
- package/dist/ui/assets/QueriesContainer-DWTsKzEk.js +0 -2
- package/dist/ui/assets/RequestDetails-CYSM4og8.js +0 -1
- package/dist/ui/assets/columns-gYFQU5qH.js +0 -1
package/dist/core/lens.cjs
CHANGED
|
@@ -305,6 +305,8 @@ var BetterSqliteStore = class extends Store {
|
|
|
305
305
|
return this.mapRow(row, true);
|
|
306
306
|
}
|
|
307
307
|
setupSchema() {
|
|
308
|
+
this.connection.exec("PRAGMA journal_mode = WAL;");
|
|
309
|
+
this.connection.exec("PRAGMA synchronous = NORMAL;");
|
|
308
310
|
const createTable = `
|
|
309
311
|
CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
|
|
310
312
|
id TEXT PRIMARY KEY,
|
|
@@ -402,8 +404,7 @@ var Lens = class {
|
|
|
402
404
|
basePath: config.basePath
|
|
403
405
|
});
|
|
404
406
|
adapter.registerRoutes(apiRoutes);
|
|
405
|
-
const
|
|
406
|
-
const uiPath = path2.resolve(this.normalizeDirName(__dirname2), "ui");
|
|
407
|
+
const uiPath = this.getUiPath();
|
|
407
408
|
adapter.serveUI(uiPath, config.basePath, getUiConfig());
|
|
408
409
|
}
|
|
409
410
|
static setStore(store) {
|
|
@@ -423,22 +424,9 @@ var Lens = class {
|
|
|
423
424
|
}
|
|
424
425
|
return this.adapter;
|
|
425
426
|
}
|
|
426
|
-
static
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
Container.singleton("uiConfig", () => {
|
|
430
|
-
return {
|
|
431
|
-
appName: config.appName,
|
|
432
|
-
path: `/${config.basePath}`,
|
|
433
|
-
api: {
|
|
434
|
-
requests: `/${config.basePath}/api/requests`,
|
|
435
|
-
queries: `/${config.basePath}/api/queries`,
|
|
436
|
-
cache: `/${config.basePath}/api/cache`,
|
|
437
|
-
exceptions: `/${config.basePath}/api/exceptions`,
|
|
438
|
-
truncate: `/${config.basePath}/api/truncate`
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
});
|
|
427
|
+
static getUiPath() {
|
|
428
|
+
const { __dirname: __dirname2 } = getMeta(import_meta.url);
|
|
429
|
+
return path2.resolve(this.normalizeDirName(__dirname2), "ui");
|
|
442
430
|
}
|
|
443
431
|
static getRoutes({ basePath }) {
|
|
444
432
|
const apiRoutes = [
|
|
@@ -449,52 +437,69 @@ var Lens = class {
|
|
|
449
437
|
},
|
|
450
438
|
{
|
|
451
439
|
method: "GET",
|
|
452
|
-
path:
|
|
440
|
+
path: `/${basePath}/api/requests`,
|
|
453
441
|
handler: async (data) => await ApiController.getRequests(data)
|
|
454
442
|
},
|
|
455
443
|
{
|
|
456
444
|
method: "GET",
|
|
457
|
-
path:
|
|
445
|
+
path: `/${basePath}/api/requests/:id`,
|
|
458
446
|
handler: async (data) => await ApiController.getRequest(data)
|
|
459
447
|
},
|
|
460
448
|
{
|
|
461
449
|
method: "GET",
|
|
462
|
-
path:
|
|
450
|
+
path: `/${basePath}/api/queries`,
|
|
463
451
|
handler: async (data) => await ApiController.getQueries(data)
|
|
464
452
|
},
|
|
465
453
|
{
|
|
466
454
|
method: "GET",
|
|
467
|
-
path:
|
|
455
|
+
path: `/${basePath}/api/queries/:id`,
|
|
468
456
|
handler: async (data) => await ApiController.getQuery(data)
|
|
469
457
|
},
|
|
470
458
|
{
|
|
471
459
|
method: "GET",
|
|
472
|
-
path:
|
|
460
|
+
path: `/${basePath}/api/cache`,
|
|
473
461
|
handler: async (data) => await ApiController.getCacheEntries(data)
|
|
474
462
|
},
|
|
475
463
|
{
|
|
476
464
|
method: "GET",
|
|
477
|
-
path:
|
|
465
|
+
path: `/${basePath}/api/cache/:id`,
|
|
478
466
|
handler: async (data) => await ApiController.getCacheEntry(data)
|
|
479
467
|
},
|
|
480
468
|
{
|
|
481
469
|
method: "GET",
|
|
482
|
-
path:
|
|
470
|
+
path: `/${basePath}/api/exceptions`,
|
|
483
471
|
handler: async (data) => await ApiController.getExceptions(data)
|
|
484
472
|
},
|
|
485
473
|
{
|
|
486
474
|
method: "GET",
|
|
487
|
-
path:
|
|
475
|
+
path: `/${basePath}/api/exceptions/:id`,
|
|
488
476
|
handler: async (data) => await ApiController.getException(data)
|
|
489
477
|
},
|
|
490
478
|
{
|
|
491
479
|
method: "DELETE",
|
|
492
|
-
path:
|
|
480
|
+
path: `/${basePath}/api/truncate`,
|
|
493
481
|
handler: async () => await ApiController.truncate()
|
|
494
482
|
}
|
|
495
483
|
];
|
|
496
484
|
return { apiRoutes };
|
|
497
485
|
}
|
|
486
|
+
static async bindContainerDeps(config) {
|
|
487
|
+
const dbStore = await this.getStore();
|
|
488
|
+
Container.singleton("store", () => dbStore);
|
|
489
|
+
Container.singleton("uiConfig", () => {
|
|
490
|
+
return {
|
|
491
|
+
appName: config.appName,
|
|
492
|
+
path: `/${config.basePath}`,
|
|
493
|
+
api: {
|
|
494
|
+
requests: `/${config.basePath}/api/requests`,
|
|
495
|
+
queries: `/${config.basePath}/api/queries`,
|
|
496
|
+
cache: `/${config.basePath}/api/cache`,
|
|
497
|
+
exceptions: `/${config.basePath}/api/exceptions`,
|
|
498
|
+
truncate: `/${config.basePath}/api/truncate`
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
});
|
|
502
|
+
}
|
|
498
503
|
static async getDefaultStore() {
|
|
499
504
|
const store = new BetterSqliteStore();
|
|
500
505
|
await store.initialize();
|
package/dist/core/lens.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Store from '../abstracts/store.cjs';
|
|
2
|
-
import
|
|
2
|
+
import { LensConfig, RouteDefinitionHandler, ApiResponse } from '../types/index.cjs';
|
|
3
3
|
import Watcher from './watcher.cjs';
|
|
4
|
-
import
|
|
4
|
+
import Adapter from '../abstracts/adapter.cjs';
|
|
5
5
|
import 'sql-formatter';
|
|
6
6
|
|
|
7
7
|
declare class Lens {
|
|
@@ -15,8 +15,32 @@ declare class Lens {
|
|
|
15
15
|
static getStore(): Promise<Store>;
|
|
16
16
|
static setAdapter(adapter: Adapter): typeof Lens;
|
|
17
17
|
static getAdapter(): Adapter;
|
|
18
|
+
static getUiPath(): string;
|
|
19
|
+
static getRoutes({ basePath }: {
|
|
20
|
+
basePath: string;
|
|
21
|
+
}): {
|
|
22
|
+
apiRoutes: ({
|
|
23
|
+
method: "GET";
|
|
24
|
+
path: string;
|
|
25
|
+
handler: () => {
|
|
26
|
+
appName: string;
|
|
27
|
+
path: string;
|
|
28
|
+
api: {
|
|
29
|
+
requests: string;
|
|
30
|
+
queries: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
method: "GET";
|
|
35
|
+
path: string;
|
|
36
|
+
handler: (data: RouteDefinitionHandler) => Promise<ApiResponse<Object>>;
|
|
37
|
+
} | {
|
|
38
|
+
method: "DELETE";
|
|
39
|
+
path: string;
|
|
40
|
+
handler: () => Promise<ApiResponse<{}>>;
|
|
41
|
+
})[];
|
|
42
|
+
};
|
|
18
43
|
private static bindContainerDeps;
|
|
19
|
-
private static getRoutes;
|
|
20
44
|
private static getDefaultStore;
|
|
21
45
|
private static normalizeDirName;
|
|
22
46
|
}
|
package/dist/core/lens.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Store from '../abstracts/store.js';
|
|
2
|
-
import
|
|
2
|
+
import { LensConfig, RouteDefinitionHandler, ApiResponse } from '../types/index.js';
|
|
3
3
|
import Watcher from './watcher.js';
|
|
4
|
-
import
|
|
4
|
+
import Adapter from '../abstracts/adapter.js';
|
|
5
5
|
import 'sql-formatter';
|
|
6
6
|
|
|
7
7
|
declare class Lens {
|
|
@@ -15,8 +15,32 @@ declare class Lens {
|
|
|
15
15
|
static getStore(): Promise<Store>;
|
|
16
16
|
static setAdapter(adapter: Adapter): typeof Lens;
|
|
17
17
|
static getAdapter(): Adapter;
|
|
18
|
+
static getUiPath(): string;
|
|
19
|
+
static getRoutes({ basePath }: {
|
|
20
|
+
basePath: string;
|
|
21
|
+
}): {
|
|
22
|
+
apiRoutes: ({
|
|
23
|
+
method: "GET";
|
|
24
|
+
path: string;
|
|
25
|
+
handler: () => {
|
|
26
|
+
appName: string;
|
|
27
|
+
path: string;
|
|
28
|
+
api: {
|
|
29
|
+
requests: string;
|
|
30
|
+
queries: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
method: "GET";
|
|
35
|
+
path: string;
|
|
36
|
+
handler: (data: RouteDefinitionHandler) => Promise<ApiResponse<Object>>;
|
|
37
|
+
} | {
|
|
38
|
+
method: "DELETE";
|
|
39
|
+
path: string;
|
|
40
|
+
handler: () => Promise<ApiResponse<{}>>;
|
|
41
|
+
})[];
|
|
42
|
+
};
|
|
18
43
|
private static bindContainerDeps;
|
|
19
|
-
private static getRoutes;
|
|
20
44
|
private static getDefaultStore;
|
|
21
45
|
private static normalizeDirName;
|
|
22
46
|
}
|
package/dist/core/lens.js
CHANGED
|
@@ -269,6 +269,8 @@ var BetterSqliteStore = class extends Store {
|
|
|
269
269
|
return this.mapRow(row, true);
|
|
270
270
|
}
|
|
271
271
|
setupSchema() {
|
|
272
|
+
this.connection.exec("PRAGMA journal_mode = WAL;");
|
|
273
|
+
this.connection.exec("PRAGMA synchronous = NORMAL;");
|
|
272
274
|
const createTable = `
|
|
273
275
|
CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
|
|
274
276
|
id TEXT PRIMARY KEY,
|
|
@@ -365,8 +367,7 @@ var Lens = class {
|
|
|
365
367
|
basePath: config.basePath
|
|
366
368
|
});
|
|
367
369
|
adapter.registerRoutes(apiRoutes);
|
|
368
|
-
const
|
|
369
|
-
const uiPath = path2.resolve(this.normalizeDirName(__dirname2), "ui");
|
|
370
|
+
const uiPath = this.getUiPath();
|
|
370
371
|
adapter.serveUI(uiPath, config.basePath, getUiConfig());
|
|
371
372
|
}
|
|
372
373
|
static setStore(store) {
|
|
@@ -386,22 +387,9 @@ var Lens = class {
|
|
|
386
387
|
}
|
|
387
388
|
return this.adapter;
|
|
388
389
|
}
|
|
389
|
-
static
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
Container.singleton("uiConfig", () => {
|
|
393
|
-
return {
|
|
394
|
-
appName: config.appName,
|
|
395
|
-
path: `/${config.basePath}`,
|
|
396
|
-
api: {
|
|
397
|
-
requests: `/${config.basePath}/api/requests`,
|
|
398
|
-
queries: `/${config.basePath}/api/queries`,
|
|
399
|
-
cache: `/${config.basePath}/api/cache`,
|
|
400
|
-
exceptions: `/${config.basePath}/api/exceptions`,
|
|
401
|
-
truncate: `/${config.basePath}/api/truncate`
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
});
|
|
390
|
+
static getUiPath() {
|
|
391
|
+
const { __dirname: __dirname2 } = getMeta(import.meta.url);
|
|
392
|
+
return path2.resolve(this.normalizeDirName(__dirname2), "ui");
|
|
405
393
|
}
|
|
406
394
|
static getRoutes({ basePath }) {
|
|
407
395
|
const apiRoutes = [
|
|
@@ -412,52 +400,69 @@ var Lens = class {
|
|
|
412
400
|
},
|
|
413
401
|
{
|
|
414
402
|
method: "GET",
|
|
415
|
-
path:
|
|
403
|
+
path: `/${basePath}/api/requests`,
|
|
416
404
|
handler: async (data) => await ApiController.getRequests(data)
|
|
417
405
|
},
|
|
418
406
|
{
|
|
419
407
|
method: "GET",
|
|
420
|
-
path:
|
|
408
|
+
path: `/${basePath}/api/requests/:id`,
|
|
421
409
|
handler: async (data) => await ApiController.getRequest(data)
|
|
422
410
|
},
|
|
423
411
|
{
|
|
424
412
|
method: "GET",
|
|
425
|
-
path:
|
|
413
|
+
path: `/${basePath}/api/queries`,
|
|
426
414
|
handler: async (data) => await ApiController.getQueries(data)
|
|
427
415
|
},
|
|
428
416
|
{
|
|
429
417
|
method: "GET",
|
|
430
|
-
path:
|
|
418
|
+
path: `/${basePath}/api/queries/:id`,
|
|
431
419
|
handler: async (data) => await ApiController.getQuery(data)
|
|
432
420
|
},
|
|
433
421
|
{
|
|
434
422
|
method: "GET",
|
|
435
|
-
path:
|
|
423
|
+
path: `/${basePath}/api/cache`,
|
|
436
424
|
handler: async (data) => await ApiController.getCacheEntries(data)
|
|
437
425
|
},
|
|
438
426
|
{
|
|
439
427
|
method: "GET",
|
|
440
|
-
path:
|
|
428
|
+
path: `/${basePath}/api/cache/:id`,
|
|
441
429
|
handler: async (data) => await ApiController.getCacheEntry(data)
|
|
442
430
|
},
|
|
443
431
|
{
|
|
444
432
|
method: "GET",
|
|
445
|
-
path:
|
|
433
|
+
path: `/${basePath}/api/exceptions`,
|
|
446
434
|
handler: async (data) => await ApiController.getExceptions(data)
|
|
447
435
|
},
|
|
448
436
|
{
|
|
449
437
|
method: "GET",
|
|
450
|
-
path:
|
|
438
|
+
path: `/${basePath}/api/exceptions/:id`,
|
|
451
439
|
handler: async (data) => await ApiController.getException(data)
|
|
452
440
|
},
|
|
453
441
|
{
|
|
454
442
|
method: "DELETE",
|
|
455
|
-
path:
|
|
443
|
+
path: `/${basePath}/api/truncate`,
|
|
456
444
|
handler: async () => await ApiController.truncate()
|
|
457
445
|
}
|
|
458
446
|
];
|
|
459
447
|
return { apiRoutes };
|
|
460
448
|
}
|
|
449
|
+
static async bindContainerDeps(config) {
|
|
450
|
+
const dbStore = await this.getStore();
|
|
451
|
+
Container.singleton("store", () => dbStore);
|
|
452
|
+
Container.singleton("uiConfig", () => {
|
|
453
|
+
return {
|
|
454
|
+
appName: config.appName,
|
|
455
|
+
path: `/${config.basePath}`,
|
|
456
|
+
api: {
|
|
457
|
+
requests: `/${config.basePath}/api/requests`,
|
|
458
|
+
queries: `/${config.basePath}/api/queries`,
|
|
459
|
+
cache: `/${config.basePath}/api/cache`,
|
|
460
|
+
exceptions: `/${config.basePath}/api/exceptions`,
|
|
461
|
+
truncate: `/${config.basePath}/api/truncate`
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
});
|
|
465
|
+
}
|
|
461
466
|
static async getDefaultStore() {
|
|
462
467
|
const store = new BetterSqliteStore();
|
|
463
468
|
await store.initialize();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SqlLanguage } from 'sql-formatter';
|
|
2
2
|
|
|
3
3
|
declare const generateRandomUuid: () => `${string}-${string}-${string}-${string}-${string}`;
|
|
4
|
-
type Bindings = any[] | Record<string, any>;
|
|
5
4
|
/**
|
|
6
5
|
* Interpolates SQL query placeholders with actual values.
|
|
7
6
|
* Supports:
|
|
@@ -9,7 +8,7 @@ type Bindings = any[] | Record<string, any>;
|
|
|
9
8
|
* - $1, $name (numeric or named)
|
|
10
9
|
* - :name (named)
|
|
11
10
|
*/
|
|
12
|
-
declare function interpolateQuery(query: string, bindings:
|
|
11
|
+
declare function interpolateQuery(query: string, bindings: any): string;
|
|
13
12
|
declare const formatSqlQuery: (query: string, language: SqlLanguage) => string;
|
|
14
13
|
declare function getMeta(metaUrl?: string): {
|
|
15
14
|
__filename: string;
|
|
@@ -23,18 +22,20 @@ declare function prepareIgnoredPaths(path: string, ignoredPaths: RegExp[]): {
|
|
|
23
22
|
};
|
|
24
23
|
declare function shouldIgnoreCurrentPath(path: string, ignoredPaths: RegExp[], onlyPaths: RegExp[]): boolean;
|
|
25
24
|
declare function prettyHrTime(hrtime: [number, number], verbose?: boolean): string;
|
|
25
|
+
declare function normalizePath(path: string): string;
|
|
26
26
|
|
|
27
27
|
declare const index_formatSqlQuery: typeof formatSqlQuery;
|
|
28
28
|
declare const index_generateRandomUuid: typeof generateRandomUuid;
|
|
29
29
|
declare const index_getMeta: typeof getMeta;
|
|
30
30
|
declare const index_interpolateQuery: typeof interpolateQuery;
|
|
31
31
|
declare const index_isStaticFile: typeof isStaticFile;
|
|
32
|
+
declare const index_normalizePath: typeof normalizePath;
|
|
32
33
|
declare const index_prepareIgnoredPaths: typeof prepareIgnoredPaths;
|
|
33
34
|
declare const index_prettyHrTime: typeof prettyHrTime;
|
|
34
35
|
declare const index_shouldIgnoreCurrentPath: typeof shouldIgnoreCurrentPath;
|
|
35
36
|
declare const index_stripBeforeAssetsPath: typeof stripBeforeAssetsPath;
|
|
36
37
|
declare namespace index {
|
|
37
|
-
export { index_formatSqlQuery as formatSqlQuery, index_generateRandomUuid as generateRandomUuid, index_getMeta as getMeta, index_interpolateQuery as interpolateQuery, index_isStaticFile as isStaticFile, index_prepareIgnoredPaths as prepareIgnoredPaths, index_prettyHrTime as prettyHrTime, index_shouldIgnoreCurrentPath as shouldIgnoreCurrentPath, index_stripBeforeAssetsPath as stripBeforeAssetsPath };
|
|
38
|
+
export { index_formatSqlQuery as formatSqlQuery, index_generateRandomUuid as generateRandomUuid, index_getMeta as getMeta, index_interpolateQuery as interpolateQuery, index_isStaticFile as isStaticFile, index_normalizePath as normalizePath, index_prepareIgnoredPaths as prepareIgnoredPaths, index_prettyHrTime as prettyHrTime, index_shouldIgnoreCurrentPath as shouldIgnoreCurrentPath, index_stripBeforeAssetsPath as stripBeforeAssetsPath };
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
export { interpolateQuery as a, getMeta as b, isStaticFile as c, shouldIgnoreCurrentPath as d, prettyHrTime as e, formatSqlQuery as f, generateRandomUuid as g, index as i, prepareIgnoredPaths as p, stripBeforeAssetsPath as s };
|
|
41
|
+
export { interpolateQuery as a, getMeta as b, isStaticFile as c, shouldIgnoreCurrentPath as d, prettyHrTime as e, formatSqlQuery as f, generateRandomUuid as g, index as i, normalizePath as n, prepareIgnoredPaths as p, stripBeforeAssetsPath as s };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SqlLanguage } from 'sql-formatter';
|
|
2
2
|
|
|
3
3
|
declare const generateRandomUuid: () => `${string}-${string}-${string}-${string}-${string}`;
|
|
4
|
-
type Bindings = any[] | Record<string, any>;
|
|
5
4
|
/**
|
|
6
5
|
* Interpolates SQL query placeholders with actual values.
|
|
7
6
|
* Supports:
|
|
@@ -9,7 +8,7 @@ type Bindings = any[] | Record<string, any>;
|
|
|
9
8
|
* - $1, $name (numeric or named)
|
|
10
9
|
* - :name (named)
|
|
11
10
|
*/
|
|
12
|
-
declare function interpolateQuery(query: string, bindings:
|
|
11
|
+
declare function interpolateQuery(query: string, bindings: any): string;
|
|
13
12
|
declare const formatSqlQuery: (query: string, language: SqlLanguage) => string;
|
|
14
13
|
declare function getMeta(metaUrl?: string): {
|
|
15
14
|
__filename: string;
|
|
@@ -23,18 +22,20 @@ declare function prepareIgnoredPaths(path: string, ignoredPaths: RegExp[]): {
|
|
|
23
22
|
};
|
|
24
23
|
declare function shouldIgnoreCurrentPath(path: string, ignoredPaths: RegExp[], onlyPaths: RegExp[]): boolean;
|
|
25
24
|
declare function prettyHrTime(hrtime: [number, number], verbose?: boolean): string;
|
|
25
|
+
declare function normalizePath(path: string): string;
|
|
26
26
|
|
|
27
27
|
declare const index_formatSqlQuery: typeof formatSqlQuery;
|
|
28
28
|
declare const index_generateRandomUuid: typeof generateRandomUuid;
|
|
29
29
|
declare const index_getMeta: typeof getMeta;
|
|
30
30
|
declare const index_interpolateQuery: typeof interpolateQuery;
|
|
31
31
|
declare const index_isStaticFile: typeof isStaticFile;
|
|
32
|
+
declare const index_normalizePath: typeof normalizePath;
|
|
32
33
|
declare const index_prepareIgnoredPaths: typeof prepareIgnoredPaths;
|
|
33
34
|
declare const index_prettyHrTime: typeof prettyHrTime;
|
|
34
35
|
declare const index_shouldIgnoreCurrentPath: typeof shouldIgnoreCurrentPath;
|
|
35
36
|
declare const index_stripBeforeAssetsPath: typeof stripBeforeAssetsPath;
|
|
36
37
|
declare namespace index {
|
|
37
|
-
export { index_formatSqlQuery as formatSqlQuery, index_generateRandomUuid as generateRandomUuid, index_getMeta as getMeta, index_interpolateQuery as interpolateQuery, index_isStaticFile as isStaticFile, index_prepareIgnoredPaths as prepareIgnoredPaths, index_prettyHrTime as prettyHrTime, index_shouldIgnoreCurrentPath as shouldIgnoreCurrentPath, index_stripBeforeAssetsPath as stripBeforeAssetsPath };
|
|
38
|
+
export { index_formatSqlQuery as formatSqlQuery, index_generateRandomUuid as generateRandomUuid, index_getMeta as getMeta, index_interpolateQuery as interpolateQuery, index_isStaticFile as isStaticFile, index_normalizePath as normalizePath, index_prepareIgnoredPaths as prepareIgnoredPaths, index_prettyHrTime as prettyHrTime, index_shouldIgnoreCurrentPath as shouldIgnoreCurrentPath, index_stripBeforeAssetsPath as stripBeforeAssetsPath };
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
export { interpolateQuery as a, getMeta as b, isStaticFile as c, shouldIgnoreCurrentPath as d, prettyHrTime as e, formatSqlQuery as f, generateRandomUuid as g, index as i, prepareIgnoredPaths as p, stripBeforeAssetsPath as s };
|
|
41
|
+
export { interpolateQuery as a, getMeta as b, isStaticFile as c, shouldIgnoreCurrentPath as d, prettyHrTime as e, formatSqlQuery as f, generateRandomUuid as g, index as i, normalizePath as n, prepareIgnoredPaths as p, stripBeforeAssetsPath as s };
|
package/dist/index.cjs
CHANGED
|
@@ -330,6 +330,8 @@ var BetterSqliteStore = class extends Store {
|
|
|
330
330
|
return this.mapRow(row, true);
|
|
331
331
|
}
|
|
332
332
|
setupSchema() {
|
|
333
|
+
this.connection.exec("PRAGMA journal_mode = WAL;");
|
|
334
|
+
this.connection.exec("PRAGMA synchronous = NORMAL;");
|
|
333
335
|
const createTable = `
|
|
334
336
|
CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
|
|
335
337
|
id TEXT PRIMARY KEY,
|
|
@@ -386,6 +388,7 @@ __export(utils_exports, {
|
|
|
386
388
|
getMeta: () => getMeta,
|
|
387
389
|
interpolateQuery: () => interpolateQuery,
|
|
388
390
|
isStaticFile: () => isStaticFile,
|
|
391
|
+
normalizePath: () => normalizePath,
|
|
389
392
|
prepareIgnoredPaths: () => prepareIgnoredPaths,
|
|
390
393
|
prettyHrTime: () => prettyHrTime,
|
|
391
394
|
shouldIgnoreCurrentPath: () => shouldIgnoreCurrentPath,
|
|
@@ -402,34 +405,44 @@ var generateRandomUuid = () => {
|
|
|
402
405
|
function interpolateQuery(query, bindings) {
|
|
403
406
|
const formatValue = (value) => {
|
|
404
407
|
if (value === null || value === void 0) return "NULL";
|
|
405
|
-
if (typeof value === "string")
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if (
|
|
409
|
-
return
|
|
410
|
-
|
|
408
|
+
if (typeof value === "string") {
|
|
409
|
+
return `'${value.replace(/'/g, "''")}'`;
|
|
410
|
+
}
|
|
411
|
+
if (value instanceof import_luxon.DateTime) {
|
|
412
|
+
return `'${value.toISO()}'`;
|
|
413
|
+
}
|
|
414
|
+
if (value instanceof Date) {
|
|
415
|
+
return `'${value.toISOString()}'`;
|
|
416
|
+
}
|
|
417
|
+
if (Array.isArray(value)) {
|
|
418
|
+
return value.map((v) => formatValue(v)).join(", ");
|
|
419
|
+
}
|
|
420
|
+
if (typeof value === "object") {
|
|
411
421
|
return `'${JSON.stringify(value).replace(/'/g, "''")}'`;
|
|
422
|
+
}
|
|
412
423
|
return value.toString();
|
|
413
424
|
};
|
|
414
425
|
if (Array.isArray(bindings)) {
|
|
415
426
|
let i = 0;
|
|
416
427
|
return query.replace(/\?/g, () => {
|
|
417
|
-
if (i >= bindings.length)
|
|
428
|
+
if (i >= bindings.length) {
|
|
418
429
|
throw new Error("Not enough bindings for placeholders");
|
|
430
|
+
}
|
|
419
431
|
return formatValue(bindings[i++]);
|
|
420
432
|
});
|
|
421
433
|
}
|
|
422
434
|
return query.replace(/(\$|\:)(\w+)/g, (match, prefix, keyOrIndex) => {
|
|
423
435
|
let value;
|
|
424
436
|
if (prefix === "$" && /^\d+$/.test(keyOrIndex)) {
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
if (index < 0 || index >= keys.length)
|
|
437
|
+
const placeholder = `$${keyOrIndex}`;
|
|
438
|
+
if (!(placeholder in bindings)) {
|
|
428
439
|
throw new Error(`Missing binding for ${match}`);
|
|
429
|
-
|
|
440
|
+
}
|
|
441
|
+
value = bindings[placeholder];
|
|
430
442
|
} else {
|
|
431
|
-
if (!(keyOrIndex in bindings))
|
|
443
|
+
if (!(keyOrIndex in bindings)) {
|
|
432
444
|
throw new Error(`Missing binding for ${match}`);
|
|
445
|
+
}
|
|
433
446
|
value = bindings[keyOrIndex];
|
|
434
447
|
}
|
|
435
448
|
return formatValue(value);
|
|
@@ -500,6 +513,9 @@ function prettyHrTime(hrtime, verbose = false) {
|
|
|
500
513
|
}
|
|
501
514
|
return `${(ms / 1e3).toFixed(1)} s`;
|
|
502
515
|
}
|
|
516
|
+
function normalizePath(path4) {
|
|
517
|
+
return path4.startsWith("/") ? path4 : `/${path4}`;
|
|
518
|
+
}
|
|
503
519
|
|
|
504
520
|
// src/core/lens.ts
|
|
505
521
|
var import_meta = {};
|
|
@@ -530,8 +546,7 @@ var Lens = class {
|
|
|
530
546
|
basePath: config.basePath
|
|
531
547
|
});
|
|
532
548
|
adapter.registerRoutes(apiRoutes);
|
|
533
|
-
const
|
|
534
|
-
const uiPath = path2.resolve(this.normalizeDirName(__dirname2), "ui");
|
|
549
|
+
const uiPath = this.getUiPath();
|
|
535
550
|
adapter.serveUI(uiPath, config.basePath, getUiConfig());
|
|
536
551
|
}
|
|
537
552
|
static setStore(store) {
|
|
@@ -551,22 +566,9 @@ var Lens = class {
|
|
|
551
566
|
}
|
|
552
567
|
return this.adapter;
|
|
553
568
|
}
|
|
554
|
-
static
|
|
555
|
-
const
|
|
556
|
-
|
|
557
|
-
Container.singleton("uiConfig", () => {
|
|
558
|
-
return {
|
|
559
|
-
appName: config.appName,
|
|
560
|
-
path: `/${config.basePath}`,
|
|
561
|
-
api: {
|
|
562
|
-
requests: `/${config.basePath}/api/requests`,
|
|
563
|
-
queries: `/${config.basePath}/api/queries`,
|
|
564
|
-
cache: `/${config.basePath}/api/cache`,
|
|
565
|
-
exceptions: `/${config.basePath}/api/exceptions`,
|
|
566
|
-
truncate: `/${config.basePath}/api/truncate`
|
|
567
|
-
}
|
|
568
|
-
};
|
|
569
|
-
});
|
|
569
|
+
static getUiPath() {
|
|
570
|
+
const { __dirname: __dirname2 } = getMeta(import_meta.url);
|
|
571
|
+
return path2.resolve(this.normalizeDirName(__dirname2), "ui");
|
|
570
572
|
}
|
|
571
573
|
static getRoutes({ basePath }) {
|
|
572
574
|
const apiRoutes = [
|
|
@@ -577,52 +579,69 @@ var Lens = class {
|
|
|
577
579
|
},
|
|
578
580
|
{
|
|
579
581
|
method: "GET",
|
|
580
|
-
path:
|
|
582
|
+
path: `/${basePath}/api/requests`,
|
|
581
583
|
handler: async (data) => await ApiController.getRequests(data)
|
|
582
584
|
},
|
|
583
585
|
{
|
|
584
586
|
method: "GET",
|
|
585
|
-
path:
|
|
587
|
+
path: `/${basePath}/api/requests/:id`,
|
|
586
588
|
handler: async (data) => await ApiController.getRequest(data)
|
|
587
589
|
},
|
|
588
590
|
{
|
|
589
591
|
method: "GET",
|
|
590
|
-
path:
|
|
592
|
+
path: `/${basePath}/api/queries`,
|
|
591
593
|
handler: async (data) => await ApiController.getQueries(data)
|
|
592
594
|
},
|
|
593
595
|
{
|
|
594
596
|
method: "GET",
|
|
595
|
-
path:
|
|
597
|
+
path: `/${basePath}/api/queries/:id`,
|
|
596
598
|
handler: async (data) => await ApiController.getQuery(data)
|
|
597
599
|
},
|
|
598
600
|
{
|
|
599
601
|
method: "GET",
|
|
600
|
-
path:
|
|
602
|
+
path: `/${basePath}/api/cache`,
|
|
601
603
|
handler: async (data) => await ApiController.getCacheEntries(data)
|
|
602
604
|
},
|
|
603
605
|
{
|
|
604
606
|
method: "GET",
|
|
605
|
-
path:
|
|
607
|
+
path: `/${basePath}/api/cache/:id`,
|
|
606
608
|
handler: async (data) => await ApiController.getCacheEntry(data)
|
|
607
609
|
},
|
|
608
610
|
{
|
|
609
611
|
method: "GET",
|
|
610
|
-
path:
|
|
612
|
+
path: `/${basePath}/api/exceptions`,
|
|
611
613
|
handler: async (data) => await ApiController.getExceptions(data)
|
|
612
614
|
},
|
|
613
615
|
{
|
|
614
616
|
method: "GET",
|
|
615
|
-
path:
|
|
617
|
+
path: `/${basePath}/api/exceptions/:id`,
|
|
616
618
|
handler: async (data) => await ApiController.getException(data)
|
|
617
619
|
},
|
|
618
620
|
{
|
|
619
621
|
method: "DELETE",
|
|
620
|
-
path:
|
|
622
|
+
path: `/${basePath}/api/truncate`,
|
|
621
623
|
handler: async () => await ApiController.truncate()
|
|
622
624
|
}
|
|
623
625
|
];
|
|
624
626
|
return { apiRoutes };
|
|
625
627
|
}
|
|
628
|
+
static async bindContainerDeps(config) {
|
|
629
|
+
const dbStore = await this.getStore();
|
|
630
|
+
Container.singleton("store", () => dbStore);
|
|
631
|
+
Container.singleton("uiConfig", () => {
|
|
632
|
+
return {
|
|
633
|
+
appName: config.appName,
|
|
634
|
+
path: `/${config.basePath}`,
|
|
635
|
+
api: {
|
|
636
|
+
requests: `/${config.basePath}/api/requests`,
|
|
637
|
+
queries: `/${config.basePath}/api/queries`,
|
|
638
|
+
cache: `/${config.basePath}/api/cache`,
|
|
639
|
+
exceptions: `/${config.basePath}/api/exceptions`,
|
|
640
|
+
truncate: `/${config.basePath}/api/truncate`
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
});
|
|
644
|
+
}
|
|
626
645
|
static async getDefaultStore() {
|
|
627
646
|
const store = new BetterSqliteStore();
|
|
628
647
|
await store.initialize();
|
|
@@ -699,7 +718,7 @@ var CacheWatcher = class extends Watcher {
|
|
|
699
718
|
let value = "";
|
|
700
719
|
if ("data" in data && typeof data.data === "object" && data.data !== null) {
|
|
701
720
|
if ("key" in data.data) {
|
|
702
|
-
key = String(data.data.key);
|
|
721
|
+
key = String(data.data.key ?? "__");
|
|
703
722
|
}
|
|
704
723
|
if ("value" in data.data) {
|
|
705
724
|
value = data.data.value;
|
|
@@ -849,9 +868,27 @@ function constructErrorObject(err) {
|
|
|
849
868
|
}
|
|
850
869
|
|
|
851
870
|
// src/utils/event_emitter.ts
|
|
852
|
-
var
|
|
871
|
+
var import_events = require("events");
|
|
872
|
+
var TypedEventEmitter = class {
|
|
873
|
+
emitter = new import_events.EventEmitter();
|
|
874
|
+
on(event, listener) {
|
|
875
|
+
this.emitter.on(event, listener);
|
|
876
|
+
return this;
|
|
877
|
+
}
|
|
878
|
+
off(event, listener) {
|
|
879
|
+
this.emitter.off(event, listener);
|
|
880
|
+
return this;
|
|
881
|
+
}
|
|
882
|
+
once(event, listener) {
|
|
883
|
+
this.emitter.once(event, listener);
|
|
884
|
+
return this;
|
|
885
|
+
}
|
|
886
|
+
emit(event, payload) {
|
|
887
|
+
return this.emitter.emit(event, payload);
|
|
888
|
+
}
|
|
889
|
+
};
|
|
853
890
|
var createEmittery = () => {
|
|
854
|
-
return new
|
|
891
|
+
return new TypedEventEmitter();
|
|
855
892
|
};
|
|
856
893
|
var lensEmitter = createEmittery();
|
|
857
894
|
|
package/dist/index.d.cts
CHANGED
|
@@ -9,11 +9,11 @@ export { default as LensAdapter } from './abstracts/adapter.cjs';
|
|
|
9
9
|
export { default as LensStore } from './abstracts/store.cjs';
|
|
10
10
|
export { default as LensWatcher } from './core/watcher.cjs';
|
|
11
11
|
export { getStore as getLensStore } from './context/context.cjs';
|
|
12
|
-
export { i as lensUtils } from './index-
|
|
12
|
+
export { i as lensUtils } from './index-CMvlRWcQ.cjs';
|
|
13
13
|
export { e as lensExceptionUtils } from './exception-C69UCHPk.cjs';
|
|
14
14
|
export { createEmittery, lensEmitter } from './utils/event_emitter.cjs';
|
|
15
15
|
export { handleUncaughExceptions, lensContext } from './utils/async_context.cjs';
|
|
16
16
|
import 'libsql';
|
|
17
17
|
import 'sql-formatter';
|
|
18
|
-
import '
|
|
18
|
+
import 'events';
|
|
19
19
|
import 'async_hooks';
|