@lensjs/core 2.1.1 → 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.
Files changed (56) hide show
  1. package/dist/core/lens.cjs +32 -27
  2. package/dist/core/lens.d.cts +27 -3
  3. package/dist/core/lens.d.ts +27 -3
  4. package/dist/core/lens.js +32 -27
  5. package/dist/{index-DiLfwsvc.d.cts → index-CMvlRWcQ.d.cts} +5 -4
  6. package/dist/{index-DiLfwsvc.d.ts → index-CMvlRWcQ.d.ts} +5 -4
  7. package/dist/index.cjs +58 -39
  8. package/dist/index.d.cts +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +58 -39
  11. package/dist/stores/better_sqlite.cjs +2 -0
  12. package/dist/stores/better_sqlite.js +2 -0
  13. package/dist/stores/index.cjs +2 -0
  14. package/dist/stores/index.js +2 -0
  15. package/dist/ui/assets/{CacheActionBadge-CK7JdKoE.js → CacheActionBadge-DhWgzJKU.js} +1 -1
  16. package/dist/ui/assets/CacheEntriesTable-BHqlkmET.js +1 -0
  17. package/dist/ui/assets/CacheEntryContainer-Bp2C09iw.js +2 -0
  18. package/dist/ui/assets/{CacheEntryDetails-D9Xy7d9u.js → CacheEntryDetails-BUZc5j1q.js} +1 -1
  19. package/dist/ui/assets/CacheEntryDetailsContainer-C_EUSu_d.js +2 -0
  20. package/dist/ui/assets/ExceptionContainer-DYNMF7Fh.js +2 -0
  21. package/dist/ui/assets/{ExceptionDetails-BbIFoM7M.js → ExceptionDetails-OVDydGbv.js} +1 -1
  22. package/dist/ui/assets/ExceptionDetailsContainer-xXWwVaQA.js +2 -0
  23. package/dist/ui/assets/{ExceptionTable-DY3mmGT4.js → ExceptionTable-D9KqPbq2.js} +1 -1
  24. package/dist/ui/assets/{LoadMore-CJh7FLbl.js → LoadMore-CG1d6vXW.js} +1 -1
  25. package/dist/ui/assets/QueriesContainer-CMcyoEiM.js +2 -0
  26. package/dist/ui/assets/{QueryDetailsContainer-7CA9a5de.js → QueryDetailsContainer-DFQCEBLy.js} +1 -1
  27. package/dist/ui/assets/{QueryTable-pn7Ayura.js → QueryTable-WVYW33VB.js} +1 -1
  28. package/dist/ui/assets/RequestDetails-BIY8CWBr.js +1 -0
  29. package/dist/ui/assets/{RequestDetailsContainer-BECT0XJh.js → RequestDetailsContainer-Apuww5Zb.js} +2 -2
  30. package/dist/ui/assets/{RequestsContainer-DLkjpX67.js → RequestsContainer-BGQCjoDx.js} +2 -2
  31. package/dist/ui/assets/{RequetsTable-Cgas07Fe.js → RequetsTable-C0uox4Jg.js} +1 -1
  32. package/dist/ui/assets/{StatusCode-C5lihzKZ.js → StatusCode-1rRaEP-3.js} +1 -1
  33. package/dist/ui/assets/{TabbedDataViewer-BUMQ0QVm.js → TabbedDataViewer-Cj9wJA8v.js} +1 -1
  34. package/dist/ui/assets/{Table-BesHc4Lc.js → Table-B7P54I_5.js} +1 -1
  35. package/dist/ui/assets/{columns-C1CwS8yE.js → columns-DpE4hBXR.js} +1 -1
  36. package/dist/ui/assets/{columns-CULxhcpY.js → columns-T9b-fLbu.js} +1 -1
  37. package/dist/ui/assets/{columns-gYFQU5qH.js → columns-yzAlNtNs.js} +1 -1
  38. package/dist/ui/assets/{index-PEcJ5nx0.js → index-ymy5EHnx.js} +2 -2
  39. package/dist/ui/assets/{useCacheEntries-jbGe2CRY.js → useCacheEntries-C5Y3eu1s.js} +1 -1
  40. package/dist/ui/assets/{useExceptions-uYUhAW-J.js → useExceptions-CN6DxiEv.js} +1 -1
  41. package/dist/ui/assets/{useLensApi-BsDmB7vx.js → useLensApi-ufHx5Ujl.js} +1 -1
  42. package/dist/ui/assets/{useLoadMore-sLsrekV5.js → useLoadMore-dVvcuWYt.js} +1 -1
  43. package/dist/ui/assets/{useQueries-DJE91mYq.js → useQueries-BsRJ7RGS.js} +1 -1
  44. package/dist/ui/index.html +1 -1
  45. package/dist/utils/index.cjs +27 -12
  46. package/dist/utils/index.d.cts +1 -1
  47. package/dist/utils/index.d.ts +1 -1
  48. package/dist/utils/index.js +26 -12
  49. package/package.json +1 -1
  50. package/dist/ui/assets/CacheEntriesTable-C5HcgCZI.js +0 -1
  51. package/dist/ui/assets/CacheEntryContainer-C0no2_6_.js +0 -2
  52. package/dist/ui/assets/CacheEntryDetailsContainer-BcwliP55.js +0 -2
  53. package/dist/ui/assets/ExceptionContainer-CQalcd8x.js +0 -2
  54. package/dist/ui/assets/ExceptionDetailsContainer-fajmF7id.js +0 -2
  55. package/dist/ui/assets/QueriesContainer-DWTsKzEk.js +0 -2
  56. package/dist/ui/assets/RequestDetails-CYSM4og8.js +0 -1
@@ -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 { __dirname: __dirname2 } = getMeta(import_meta.url);
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 async bindContainerDeps(config) {
427
- const dbStore = await this.getStore();
428
- Container.singleton("store", () => dbStore);
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: `${basePath}/api/requests`,
440
+ path: `/${basePath}/api/requests`,
453
441
  handler: async (data) => await ApiController.getRequests(data)
454
442
  },
455
443
  {
456
444
  method: "GET",
457
- path: `${basePath}/api/requests/:id`,
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: `${basePath}/api/queries`,
450
+ path: `/${basePath}/api/queries`,
463
451
  handler: async (data) => await ApiController.getQueries(data)
464
452
  },
465
453
  {
466
454
  method: "GET",
467
- path: `${basePath}/api/queries/:id`,
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: `${basePath}/api/cache`,
460
+ path: `/${basePath}/api/cache`,
473
461
  handler: async (data) => await ApiController.getCacheEntries(data)
474
462
  },
475
463
  {
476
464
  method: "GET",
477
- path: `${basePath}/api/cache/:id`,
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: `${basePath}/api/exceptions`,
470
+ path: `/${basePath}/api/exceptions`,
483
471
  handler: async (data) => await ApiController.getExceptions(data)
484
472
  },
485
473
  {
486
474
  method: "GET",
487
- path: `${basePath}/api/exceptions/:id`,
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: `${basePath}/api/truncate`,
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();
@@ -1,7 +1,7 @@
1
1
  import Store from '../abstracts/store.cjs';
2
- import Adapter from '../abstracts/adapter.cjs';
2
+ import { LensConfig, RouteDefinitionHandler, ApiResponse } from '../types/index.cjs';
3
3
  import Watcher from './watcher.cjs';
4
- import { LensConfig } from '../types/index.cjs';
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
  }
@@ -1,7 +1,7 @@
1
1
  import Store from '../abstracts/store.js';
2
- import Adapter from '../abstracts/adapter.js';
2
+ import { LensConfig, RouteDefinitionHandler, ApiResponse } from '../types/index.js';
3
3
  import Watcher from './watcher.js';
4
- import { LensConfig } from '../types/index.js';
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 { __dirname: __dirname2 } = getMeta(import.meta.url);
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 async bindContainerDeps(config) {
390
- const dbStore = await this.getStore();
391
- Container.singleton("store", () => dbStore);
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: `${basePath}/api/requests`,
403
+ path: `/${basePath}/api/requests`,
416
404
  handler: async (data) => await ApiController.getRequests(data)
417
405
  },
418
406
  {
419
407
  method: "GET",
420
- path: `${basePath}/api/requests/:id`,
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: `${basePath}/api/queries`,
413
+ path: `/${basePath}/api/queries`,
426
414
  handler: async (data) => await ApiController.getQueries(data)
427
415
  },
428
416
  {
429
417
  method: "GET",
430
- path: `${basePath}/api/queries/:id`,
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: `${basePath}/api/cache`,
423
+ path: `/${basePath}/api/cache`,
436
424
  handler: async (data) => await ApiController.getCacheEntries(data)
437
425
  },
438
426
  {
439
427
  method: "GET",
440
- path: `${basePath}/api/cache/:id`,
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: `${basePath}/api/exceptions`,
433
+ path: `/${basePath}/api/exceptions`,
446
434
  handler: async (data) => await ApiController.getExceptions(data)
447
435
  },
448
436
  {
449
437
  method: "GET",
450
- path: `${basePath}/api/exceptions/:id`,
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: `${basePath}/api/truncate`,
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: Bindings): string;
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: Bindings): string;
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") return `'${value.replace(/'/g, "''")}'`;
406
- if (value instanceof import_luxon.DateTime) return `'${value.toISO()}'`;
407
- if (value instanceof Date) return `'${value.toISOString()}'`;
408
- if (Array.isArray(value))
409
- return value.map((v) => typeof v === "string" ? `'${v.replace(/'/g, "''")}'` : v).join(", ");
410
- if (typeof value === "object")
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 index = parseInt(keyOrIndex, 10) - 1;
426
- const keys = Object.keys(bindings);
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
- value = bindings[keys[index]];
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 { __dirname: __dirname2 } = getMeta(import_meta.url);
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 async bindContainerDeps(config) {
555
- const dbStore = await this.getStore();
556
- Container.singleton("store", () => dbStore);
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: `${basePath}/api/requests`,
582
+ path: `/${basePath}/api/requests`,
581
583
  handler: async (data) => await ApiController.getRequests(data)
582
584
  },
583
585
  {
584
586
  method: "GET",
585
- path: `${basePath}/api/requests/:id`,
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: `${basePath}/api/queries`,
592
+ path: `/${basePath}/api/queries`,
591
593
  handler: async (data) => await ApiController.getQueries(data)
592
594
  },
593
595
  {
594
596
  method: "GET",
595
- path: `${basePath}/api/queries/:id`,
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: `${basePath}/api/cache`,
602
+ path: `/${basePath}/api/cache`,
601
603
  handler: async (data) => await ApiController.getCacheEntries(data)
602
604
  },
603
605
  {
604
606
  method: "GET",
605
- path: `${basePath}/api/cache/:id`,
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: `${basePath}/api/exceptions`,
612
+ path: `/${basePath}/api/exceptions`,
611
613
  handler: async (data) => await ApiController.getExceptions(data)
612
614
  },
613
615
  {
614
616
  method: "GET",
615
- path: `${basePath}/api/exceptions/:id`,
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: `${basePath}/api/truncate`,
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();
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-DiLfwsvc.cjs';
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-DiLfwsvc.js';
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';