@lensjs/core 2.1.0 → 2.2.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.
- 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 +59 -39
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +59 -39
- 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-3t8U516j.js → CacheActionBadge-DhWgzJKU.js} +1 -1
- package/dist/ui/assets/CacheEntriesTable-BHqlkmET.js +1 -0
- package/dist/ui/assets/CacheEntryContainer-Bp2C09iw.js +2 -0
- package/dist/ui/assets/{CacheEntryDetails-Dm-oXALj.js → CacheEntryDetails-BUZc5j1q.js} +1 -1
- package/dist/ui/assets/CacheEntryDetailsContainer-C_EUSu_d.js +2 -0
- package/dist/ui/assets/ExceptionContainer-DYNMF7Fh.js +2 -0
- package/dist/ui/assets/{ExceptionDetails-gmpSQ_eu.js → ExceptionDetails-OVDydGbv.js} +1 -1
- package/dist/ui/assets/ExceptionDetailsContainer-xXWwVaQA.js +2 -0
- package/dist/ui/assets/{ExceptionTable-BhrX9MSS.js → ExceptionTable-D9KqPbq2.js} +1 -1
- package/dist/ui/assets/{LoadMore-26PcNWcP.js → LoadMore-CG1d6vXW.js} +1 -1
- package/dist/ui/assets/QueriesContainer-CMcyoEiM.js +2 -0
- package/dist/ui/assets/{QueryDetailsContainer-BjQM9QIb.js → QueryDetailsContainer-DFQCEBLy.js} +1 -1
- package/dist/ui/assets/{QueryTable-szgIT5Uc.js → QueryTable-WVYW33VB.js} +1 -1
- package/dist/ui/assets/RequestDetails-BIY8CWBr.js +1 -0
- package/dist/ui/assets/{RequestDetailsContainer-XYPFJFX0.js → RequestDetailsContainer-Apuww5Zb.js} +2 -2
- package/dist/ui/assets/{RequestsContainer-D0QPK2Ii.js → RequestsContainer-BGQCjoDx.js} +2 -2
- package/dist/ui/assets/{RequetsTable-6Fqchsrt.js → RequetsTable-C0uox4Jg.js} +1 -1
- package/dist/ui/assets/{StatusCode-CfVCLID2.js → StatusCode-1rRaEP-3.js} +1 -1
- package/dist/ui/assets/TabbedDataViewer-Cj9wJA8v.js +1 -0
- package/dist/ui/assets/{Table-CGe8JwTO.js → Table-B7P54I_5.js} +1 -1
- package/dist/ui/assets/{columns-Cw7tw3Em.js → columns-DpE4hBXR.js} +1 -1
- package/dist/ui/assets/{columns-RiCoo9Ea.js → columns-T9b-fLbu.js} +1 -1
- package/dist/ui/assets/{columns-BFxCubt5.js → columns-yzAlNtNs.js} +1 -1
- package/dist/ui/assets/{index-BzFeZyjf.css → index-B2QCOgug.css} +1 -1
- package/dist/ui/assets/{index-XoJlyTFO.js → index-ymy5EHnx.js} +2 -2
- package/dist/ui/assets/{useCacheEntries-SCADuxKq.js → useCacheEntries-C5Y3eu1s.js} +1 -1
- package/dist/ui/assets/{useExceptions-BMGL3nir.js → useExceptions-CN6DxiEv.js} +1 -1
- package/dist/ui/assets/{useLensApi-BYyiIIZR.js → useLensApi-ufHx5Ujl.js} +1 -1
- package/dist/ui/assets/{useLoadMore-CksOcXOF.js → useLoadMore-dVvcuWYt.js} +1 -1
- package/dist/ui/assets/{useQueries-6nYr0oG5.js → useQueries-BsRJ7RGS.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/utils/index.cjs +28 -12
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +27 -12
- package/package.json +1 -1
- package/dist/ui/assets/CacheEntriesTable-BqLquILg.js +0 -1
- package/dist/ui/assets/CacheEntryContainer-B86waEsR.js +0 -2
- package/dist/ui/assets/CacheEntryDetailsContainer-BCyXGgkx.js +0 -2
- package/dist/ui/assets/ExceptionContainer-DSQBz5cb.js +0 -2
- package/dist/ui/assets/ExceptionDetailsContainer-BHIz-TUv.js +0 -2
- package/dist/ui/assets/QueriesContainer-BSF-O4s3.js +0 -2
- package/dist/ui/assets/RequestDetails-CvQhX-2F.js +0 -1
- package/dist/ui/assets/TabbedDataViewer-Cl5ednx4.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);
|
|
@@ -469,6 +482,7 @@ function prepareIgnoredPaths(path4, ignoredPaths) {
|
|
|
469
482
|
...ignoredPaths,
|
|
470
483
|
new RegExp(`^/?${normalizedPath}(/|$)`),
|
|
471
484
|
/^\/?lens-config$/,
|
|
485
|
+
/^\/?favicon\.ico$/,
|
|
472
486
|
/^\/\.well-known\//
|
|
473
487
|
];
|
|
474
488
|
return { ignoredPaths, normalizedPath };
|
|
@@ -499,6 +513,9 @@ function prettyHrTime(hrtime, verbose = false) {
|
|
|
499
513
|
}
|
|
500
514
|
return `${(ms / 1e3).toFixed(1)} s`;
|
|
501
515
|
}
|
|
516
|
+
function normalizePath(path4) {
|
|
517
|
+
return path4.startsWith("/") ? path4 : `/${path4}`;
|
|
518
|
+
}
|
|
502
519
|
|
|
503
520
|
// src/core/lens.ts
|
|
504
521
|
var import_meta = {};
|
|
@@ -529,8 +546,7 @@ var Lens = class {
|
|
|
529
546
|
basePath: config.basePath
|
|
530
547
|
});
|
|
531
548
|
adapter.registerRoutes(apiRoutes);
|
|
532
|
-
const
|
|
533
|
-
const uiPath = path2.resolve(this.normalizeDirName(__dirname2), "ui");
|
|
549
|
+
const uiPath = this.getUiPath();
|
|
534
550
|
adapter.serveUI(uiPath, config.basePath, getUiConfig());
|
|
535
551
|
}
|
|
536
552
|
static setStore(store) {
|
|
@@ -550,22 +566,9 @@ var Lens = class {
|
|
|
550
566
|
}
|
|
551
567
|
return this.adapter;
|
|
552
568
|
}
|
|
553
|
-
static
|
|
554
|
-
const
|
|
555
|
-
|
|
556
|
-
Container.singleton("uiConfig", () => {
|
|
557
|
-
return {
|
|
558
|
-
appName: config.appName,
|
|
559
|
-
path: `/${config.basePath}`,
|
|
560
|
-
api: {
|
|
561
|
-
requests: `/${config.basePath}/api/requests`,
|
|
562
|
-
queries: `/${config.basePath}/api/queries`,
|
|
563
|
-
cache: `/${config.basePath}/api/cache`,
|
|
564
|
-
exceptions: `/${config.basePath}/api/exceptions`,
|
|
565
|
-
truncate: `/${config.basePath}/api/truncate`
|
|
566
|
-
}
|
|
567
|
-
};
|
|
568
|
-
});
|
|
569
|
+
static getUiPath() {
|
|
570
|
+
const { __dirname: __dirname2 } = getMeta(import_meta.url);
|
|
571
|
+
return path2.resolve(this.normalizeDirName(__dirname2), "ui");
|
|
569
572
|
}
|
|
570
573
|
static getRoutes({ basePath }) {
|
|
571
574
|
const apiRoutes = [
|
|
@@ -576,52 +579,69 @@ var Lens = class {
|
|
|
576
579
|
},
|
|
577
580
|
{
|
|
578
581
|
method: "GET",
|
|
579
|
-
path:
|
|
582
|
+
path: `/${basePath}/api/requests`,
|
|
580
583
|
handler: async (data) => await ApiController.getRequests(data)
|
|
581
584
|
},
|
|
582
585
|
{
|
|
583
586
|
method: "GET",
|
|
584
|
-
path:
|
|
587
|
+
path: `/${basePath}/api/requests/:id`,
|
|
585
588
|
handler: async (data) => await ApiController.getRequest(data)
|
|
586
589
|
},
|
|
587
590
|
{
|
|
588
591
|
method: "GET",
|
|
589
|
-
path:
|
|
592
|
+
path: `/${basePath}/api/queries`,
|
|
590
593
|
handler: async (data) => await ApiController.getQueries(data)
|
|
591
594
|
},
|
|
592
595
|
{
|
|
593
596
|
method: "GET",
|
|
594
|
-
path:
|
|
597
|
+
path: `/${basePath}/api/queries/:id`,
|
|
595
598
|
handler: async (data) => await ApiController.getQuery(data)
|
|
596
599
|
},
|
|
597
600
|
{
|
|
598
601
|
method: "GET",
|
|
599
|
-
path:
|
|
602
|
+
path: `/${basePath}/api/cache`,
|
|
600
603
|
handler: async (data) => await ApiController.getCacheEntries(data)
|
|
601
604
|
},
|
|
602
605
|
{
|
|
603
606
|
method: "GET",
|
|
604
|
-
path:
|
|
607
|
+
path: `/${basePath}/api/cache/:id`,
|
|
605
608
|
handler: async (data) => await ApiController.getCacheEntry(data)
|
|
606
609
|
},
|
|
607
610
|
{
|
|
608
611
|
method: "GET",
|
|
609
|
-
path:
|
|
612
|
+
path: `/${basePath}/api/exceptions`,
|
|
610
613
|
handler: async (data) => await ApiController.getExceptions(data)
|
|
611
614
|
},
|
|
612
615
|
{
|
|
613
616
|
method: "GET",
|
|
614
|
-
path:
|
|
617
|
+
path: `/${basePath}/api/exceptions/:id`,
|
|
615
618
|
handler: async (data) => await ApiController.getException(data)
|
|
616
619
|
},
|
|
617
620
|
{
|
|
618
621
|
method: "DELETE",
|
|
619
|
-
path:
|
|
622
|
+
path: `/${basePath}/api/truncate`,
|
|
620
623
|
handler: async () => await ApiController.truncate()
|
|
621
624
|
}
|
|
622
625
|
];
|
|
623
626
|
return { apiRoutes };
|
|
624
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
|
+
}
|
|
625
645
|
static async getDefaultStore() {
|
|
626
646
|
const store = new BetterSqliteStore();
|
|
627
647
|
await store.initialize();
|
package/dist/index.d.cts
CHANGED
|
@@ -9,7 +9,7 @@ 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';
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { default as LensAdapter } from './abstracts/adapter.js';
|
|
|
9
9
|
export { default as LensStore } from './abstracts/store.js';
|
|
10
10
|
export { default as LensWatcher } from './core/watcher.js';
|
|
11
11
|
export { getStore as getLensStore } from './context/context.js';
|
|
12
|
-
export { i as lensUtils } from './index-
|
|
12
|
+
export { i as lensUtils } from './index-CMvlRWcQ.js';
|
|
13
13
|
export { e as lensExceptionUtils } from './exception-3AZsPtAg.js';
|
|
14
14
|
export { createEmittery, lensEmitter } from './utils/event_emitter.js';
|
|
15
15
|
export { handleUncaughExceptions, lensContext } from './utils/async_context.js';
|