@lensjs/core 2.5.0 → 2.6.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 (129) hide show
  1. package/dist/abstracts/adapter.d.cts +1 -0
  2. package/dist/abstracts/adapter.d.ts +1 -0
  3. package/dist/abstracts/store.cjs +3 -0
  4. package/dist/abstracts/store.d.cts +2 -0
  5. package/dist/abstracts/store.d.ts +2 -0
  6. package/dist/abstracts/store.js +3 -0
  7. package/dist/context/container.d.cts +1 -0
  8. package/dist/context/container.d.ts +1 -0
  9. package/dist/context/context.d.cts +1 -0
  10. package/dist/context/context.d.ts +1 -0
  11. package/dist/core/api_controller.cjs +19 -1
  12. package/dist/core/api_controller.d.cts +3 -0
  13. package/dist/core/api_controller.d.ts +3 -0
  14. package/dist/core/api_controller.js +19 -1
  15. package/dist/core/lens.cjs +36 -1
  16. package/dist/core/lens.d.cts +1 -0
  17. package/dist/core/lens.d.ts +1 -0
  18. package/dist/core/lens.js +36 -1
  19. package/dist/core/watcher.d.cts +1 -0
  20. package/dist/core/watcher.d.ts +1 -0
  21. package/dist/index.cjs +60 -3
  22. package/dist/index.d.cts +3 -1
  23. package/dist/index.d.ts +3 -1
  24. package/dist/index.js +59 -3
  25. package/dist/mixins/queued_store.d.cts +1 -0
  26. package/dist/mixins/queued_store.d.ts +1 -0
  27. package/dist/stores/better_sqlite.cjs +6 -0
  28. package/dist/stores/better_sqlite.d.cts +9 -0
  29. package/dist/stores/better_sqlite.d.ts +9 -0
  30. package/dist/stores/better_sqlite.js +6 -0
  31. package/dist/stores/index.cjs +6 -0
  32. package/dist/stores/index.d.cts +1 -0
  33. package/dist/stores/index.d.ts +1 -0
  34. package/dist/stores/index.js +6 -0
  35. package/dist/stores/queued_sqlite.cjs +6 -0
  36. package/dist/stores/queued_sqlite.d.cts +1 -0
  37. package/dist/stores/queued_sqlite.d.ts +1 -0
  38. package/dist/stores/queued_sqlite.js +6 -0
  39. package/dist/types/index.cjs +1 -0
  40. package/dist/types/index.d.cts +4 -9
  41. package/dist/types/index.d.ts +4 -9
  42. package/dist/types/index.js +1 -0
  43. package/dist/types/mail.cjs +18 -0
  44. package/dist/types/mail.d.cts +235 -0
  45. package/dist/types/mail.d.ts +235 -0
  46. package/dist/types/mail.js +0 -0
  47. package/dist/ui/assets/CacheActionBadge-BjZ4pc-P.js +1 -0
  48. package/dist/ui/assets/CacheEntriesTable-CrVfGRQp.js +1 -0
  49. package/dist/ui/assets/CacheEntryContainer-C3VFggtA.js +2 -0
  50. package/dist/ui/assets/{CacheEntryDetails-CBADpZbF.js → CacheEntryDetails-DeBbBbPE.js} +1 -1
  51. package/dist/ui/assets/CacheEntryDetailsContainer-C91cW6AU.js +2 -0
  52. package/dist/ui/assets/ExceptionContainer-CfMuOCmH.js +2 -0
  53. package/dist/ui/assets/{ExceptionDetails-Ck4wRqzO.js → ExceptionDetails-D2OCJVfz.js} +1 -1
  54. package/dist/ui/assets/ExceptionDetailsContainer-CR-lxRD2.js +2 -0
  55. package/dist/ui/assets/{ExceptionTable-DB3Qj-dz.js → ExceptionTable-CpkppRjX.js} +1 -1
  56. package/dist/ui/assets/{JsonViewer-DWH4jnOr.js → JsonViewer-ATo_F1hS.js} +1 -1
  57. package/dist/ui/assets/{LoadMore-DzhiQWZs.js → LoadMore-BN7PRRRi.js} +1 -1
  58. package/dist/ui/assets/MailContainer-CT2lVazH.js +2 -0
  59. package/dist/ui/assets/MailDetails-B653XXBL.js +25 -0
  60. package/dist/ui/assets/MailDetailsContainer-87DOHjt8.js +2 -0
  61. package/dist/ui/assets/MailTable-DKB1K8iz.js +1 -0
  62. package/dist/ui/assets/QueriesContainer-Bk2r-ERW.js +2 -0
  63. package/dist/ui/assets/{QueryDetailsContainer-DskbLiCu.js → QueryDetailsContainer-SuM5VQhc.js} +7 -7
  64. package/dist/ui/assets/{QueryTable-D6F5vd_0.js → QueryTable-C2io_PkC.js} +1 -1
  65. package/dist/ui/assets/RequestDetails-CpThVPU7.js +1 -0
  66. package/dist/ui/assets/RequestDetailsContainer-BXIDvHw4.js +2 -0
  67. package/dist/ui/assets/RequestsContainer-CrgOytwQ.js +2 -0
  68. package/dist/ui/assets/{RequetsTable-BZFI1zdc.js → RequetsTable-DQwdUFOa.js} +1 -1
  69. package/dist/ui/assets/SearchInput-_Uf26G0_.js +6 -0
  70. package/dist/ui/assets/StatusCode-BmJMJ27T.js +1 -0
  71. package/dist/ui/assets/TabbedDataViewer-CSqO-90o.js +2 -0
  72. package/dist/ui/assets/Table-DHM1Nl4B.js +6 -0
  73. package/dist/ui/assets/columns-2NwKukUf.js +1 -0
  74. package/dist/ui/assets/{columns-BrzDipRl.js → columns-B3JsHnVe.js} +1 -1
  75. package/dist/ui/assets/{columns-BlLxfkXy.js → columns-D2emfeN1.js} +1 -1
  76. package/dist/ui/assets/{columns-D_gRck3K.js → columns-DbVoTM0z.js} +1 -1
  77. package/dist/ui/assets/{copy-BtL5cknV.js → copy-DkbKgCsc.js} +1 -1
  78. package/dist/ui/assets/index-DuJe0XlW.js +129 -0
  79. package/dist/ui/assets/index-DyMy6gzm.css +1 -0
  80. package/dist/ui/assets/{useCacheEntries-6yS-HoM5.js → useCacheEntries-ClCDpOYz.js} +1 -1
  81. package/dist/ui/assets/{useExceptions-CGpZVTaG.js → useExceptions-DeHzgA7U.js} +1 -1
  82. package/dist/ui/assets/useLensApi-SUqoFD39.js +1 -0
  83. package/dist/ui/assets/{useLoadMore-99QUZoHk.js → useLoadMore-DdSLuDVd.js} +1 -1
  84. package/dist/ui/assets/{useQueries-DWLdKE1b.js → useQueries-DeAAkcnt.js} +1 -1
  85. package/dist/ui/assets/useTanstackApi-DiA8BdmO.js +1 -0
  86. package/dist/ui/index.html +2 -2
  87. package/dist/utils/async_context.d.cts +1 -0
  88. package/dist/utils/async_context.d.ts +1 -0
  89. package/dist/utils/compose.d.cts +1 -0
  90. package/dist/utils/compose.d.ts +1 -0
  91. package/dist/utils/event_emitter.d.cts +2 -0
  92. package/dist/utils/event_emitter.d.ts +2 -0
  93. package/dist/utils/exception.d.cts +1 -0
  94. package/dist/utils/exception.d.ts +1 -0
  95. package/dist/utils/index.d.cts +1 -0
  96. package/dist/utils/index.d.ts +1 -0
  97. package/dist/watchers/cache_watcher.d.cts +1 -0
  98. package/dist/watchers/cache_watcher.d.ts +1 -0
  99. package/dist/watchers/exception_watcher.d.cts +1 -0
  100. package/dist/watchers/exception_watcher.d.ts +1 -0
  101. package/dist/watchers/index.cjs +21 -0
  102. package/dist/watchers/index.d.cts +2 -0
  103. package/dist/watchers/index.d.ts +2 -0
  104. package/dist/watchers/index.js +20 -0
  105. package/dist/watchers/mail_watcher.cjs +88 -0
  106. package/dist/watchers/mail_watcher.d.cts +11 -0
  107. package/dist/watchers/mail_watcher.d.ts +11 -0
  108. package/dist/watchers/mail_watcher.js +67 -0
  109. package/dist/watchers/query_watcher.d.cts +1 -0
  110. package/dist/watchers/query_watcher.d.ts +1 -0
  111. package/dist/watchers/request_watcher.d.cts +1 -0
  112. package/dist/watchers/request_watcher.d.ts +1 -0
  113. package/package.json +2 -2
  114. package/dist/ui/assets/CacheActionBadge-DU2ybwlp.js +0 -1
  115. package/dist/ui/assets/CacheEntriesTable-B5KvEEDm.js +0 -1
  116. package/dist/ui/assets/CacheEntryContainer-Br3Tvn8k.js +0 -2
  117. package/dist/ui/assets/CacheEntryDetailsContainer-hj1KrI3J.js +0 -2
  118. package/dist/ui/assets/ExceptionContainer-5Ov2El_x.js +0 -2
  119. package/dist/ui/assets/ExceptionDetailsContainer-CwZGYiSC.js +0 -2
  120. package/dist/ui/assets/QueriesContainer-DL-W0hBH.js +0 -2
  121. package/dist/ui/assets/RequestDetails-9ePMJXrH.js +0 -1
  122. package/dist/ui/assets/RequestDetailsContainer-BuhVtYb1.js +0 -2
  123. package/dist/ui/assets/RequestsContainer-CrLF7ZpJ.js +0 -7
  124. package/dist/ui/assets/StatusCode-CKfRhO8c.js +0 -1
  125. package/dist/ui/assets/TabbedDataViewer-DoV369_f.js +0 -2
  126. package/dist/ui/assets/Table-D3lFs2Tc.js +0 -6
  127. package/dist/ui/assets/index-CbdHkrK8.js +0 -124
  128. package/dist/ui/assets/index-DC5vZ53Q.css +0 -1
  129. package/dist/ui/assets/useLensApi-Bp8UnZ0w.js +0 -1
@@ -1,6 +1,7 @@
1
1
  import Watcher from '../core/watcher.cjs';
2
2
  import { RouteDefinition } from '../types/index.cjs';
3
3
  import 'sql-formatter';
4
+ import '../types/mail.cjs';
4
5
 
5
6
  declare abstract class Adapter {
6
7
  private watchers;
@@ -1,6 +1,7 @@
1
1
  import Watcher from '../core/watcher.js';
2
2
  import { RouteDefinition } from '../types/index.js';
3
3
  import 'sql-formatter';
4
+ import '../types/mail.js';
4
5
 
5
6
  declare abstract class Adapter {
6
7
  private watchers;
@@ -30,6 +30,9 @@ var Store = class {
30
30
  getAllExceptions(_paginationParams) {
31
31
  return this.defaultMinimalPaginate();
32
32
  }
33
+ getAllEmails(_paginationParams) {
34
+ return this.defaultMinimalPaginate();
35
+ }
33
36
  stringifyData(data) {
34
37
  if (typeof data === "string") {
35
38
  return data;
@@ -1,5 +1,6 @@
1
1
  import { QueuedStoreConfig, WatcherTypeEnum, PaginationParams, Paginator, LensEntry } from '../types/index.cjs';
2
2
  import 'sql-formatter';
3
+ import '../types/mail.cjs';
3
4
 
4
5
  type MinimalPaginatePromise = Promise<Paginator<Omit<LensEntry, "data">[]>>;
5
6
  declare abstract class Store {
@@ -23,6 +24,7 @@ declare abstract class Store {
23
24
  abstract paginate<T>(type: WatcherTypeEnum, pagination: PaginationParams): Promise<Paginator<T>>;
24
25
  abstract count(type: WatcherTypeEnum): Promise<number>;
25
26
  getAllExceptions(_paginationParams: PaginationParams): MinimalPaginatePromise;
27
+ getAllEmails(_paginationParams: PaginationParams): MinimalPaginatePromise;
26
28
  protected stringifyData(data: Record<string, any> | string): string | undefined;
27
29
  protected defaultMinimalPaginate(): MinimalPaginatePromise;
28
30
  }
@@ -1,5 +1,6 @@
1
1
  import { QueuedStoreConfig, WatcherTypeEnum, PaginationParams, Paginator, LensEntry } from '../types/index.js';
2
2
  import 'sql-formatter';
3
+ import '../types/mail.js';
3
4
 
4
5
  type MinimalPaginatePromise = Promise<Paginator<Omit<LensEntry, "data">[]>>;
5
6
  declare abstract class Store {
@@ -23,6 +24,7 @@ declare abstract class Store {
23
24
  abstract paginate<T>(type: WatcherTypeEnum, pagination: PaginationParams): Promise<Paginator<T>>;
24
25
  abstract count(type: WatcherTypeEnum): Promise<number>;
25
26
  getAllExceptions(_paginationParams: PaginationParams): MinimalPaginatePromise;
27
+ getAllEmails(_paginationParams: PaginationParams): MinimalPaginatePromise;
26
28
  protected stringifyData(data: Record<string, any> | string): string | undefined;
27
29
  protected defaultMinimalPaginate(): MinimalPaginatePromise;
28
30
  }
@@ -6,6 +6,9 @@ var Store = class {
6
6
  getAllExceptions(_paginationParams) {
7
7
  return this.defaultMinimalPaginate();
8
8
  }
9
+ getAllEmails(_paginationParams) {
10
+ return this.defaultMinimalPaginate();
11
+ }
9
12
  stringifyData(data) {
10
13
  if (typeof data === "string") {
11
14
  return data;
@@ -1,6 +1,7 @@
1
1
  import Store from '../abstracts/store.cjs';
2
2
  import '../types/index.cjs';
3
3
  import 'sql-formatter';
4
+ import '../types/mail.cjs';
4
5
 
5
6
  type Factory<T = any> = () => T;
6
7
  type ContextStore = {
@@ -1,6 +1,7 @@
1
1
  import Store from '../abstracts/store.js';
2
2
  import '../types/index.js';
3
3
  import 'sql-formatter';
4
+ import '../types/mail.js';
4
5
 
5
6
  type Factory<T = any> = () => T;
6
7
  type ContextStore = {
@@ -1,6 +1,7 @@
1
1
  import Store from '../abstracts/store.cjs';
2
2
  import '../types/index.cjs';
3
3
  import 'sql-formatter';
4
+ import '../types/mail.cjs';
4
5
 
5
6
  declare const getStore: () => Store;
6
7
  declare const getUiConfig: () => {
@@ -1,6 +1,7 @@
1
1
  import Store from '../abstracts/store.js';
2
2
  import '../types/index.js';
3
3
  import 'sql-formatter';
4
+ import '../types/mail.js';
4
5
 
5
6
  declare const getStore: () => Store;
6
7
  declare const getUiConfig: () => {
@@ -92,11 +92,17 @@ var ApiController = class {
92
92
  "exception" /* EXCEPTION */,
93
93
  false
94
94
  );
95
+ const emails = await getStore().allByRequestId(
96
+ request.id,
97
+ "mail" /* MAIL */,
98
+ false
99
+ );
95
100
  return this.resourceResponse({
96
101
  request,
97
102
  queries,
98
103
  cacheEntries,
99
- exceptions
104
+ exceptions,
105
+ emails
100
106
  });
101
107
  }
102
108
  static async getQueries({
@@ -143,6 +149,18 @@ var ApiController = class {
143
149
  }
144
150
  return this.resourceResponse(exception);
145
151
  }
152
+ static async getEmails({ qs }) {
153
+ return this.paginatedResponse(
154
+ await getStore().getAllEmails(this.extractPaginationParams(qs))
155
+ );
156
+ }
157
+ static async getEmail({ params }) {
158
+ const email = await getStore().find("mail" /* MAIL */, params.id);
159
+ if (!email) {
160
+ return this.notFoundResponse();
161
+ }
162
+ return this.resourceResponse(email);
163
+ }
146
164
  static async truncate() {
147
165
  await getStore().truncate();
148
166
  return this.baseResponse({}, 200, "All entries cleared");
@@ -1,5 +1,6 @@
1
1
  import { RouteDefinitionHandler, ApiResponse, LensEntry, Paginator } from '../types/index.cjs';
2
2
  import 'sql-formatter';
3
+ import '../types/mail.cjs';
3
4
 
4
5
  declare class ApiController {
5
6
  static getRequests({ qs }: RouteDefinitionHandler): Promise<ApiResponse<Omit<LensEntry, "data">[]>>;
@@ -10,6 +11,8 @@ declare class ApiController {
10
11
  static getCacheEntry({ params }: RouteDefinitionHandler): Promise<ApiResponse<Object>>;
11
12
  static getExceptions({ qs }: RouteDefinitionHandler): Promise<ApiResponse<Omit<LensEntry, "data">[]>>;
12
13
  static getException({ params }: RouteDefinitionHandler): Promise<ApiResponse<Object>>;
14
+ static getEmails({ qs }: RouteDefinitionHandler): Promise<ApiResponse<Omit<LensEntry, "data">[]>>;
15
+ static getEmail({ params }: RouteDefinitionHandler): Promise<ApiResponse<Object>>;
13
16
  static truncate(): Promise<ApiResponse<{}>>;
14
17
  static fetchUiConfig(): {
15
18
  appName: string;
@@ -1,5 +1,6 @@
1
1
  import { RouteDefinitionHandler, ApiResponse, LensEntry, Paginator } from '../types/index.js';
2
2
  import 'sql-formatter';
3
+ import '../types/mail.js';
3
4
 
4
5
  declare class ApiController {
5
6
  static getRequests({ qs }: RouteDefinitionHandler): Promise<ApiResponse<Omit<LensEntry, "data">[]>>;
@@ -10,6 +11,8 @@ declare class ApiController {
10
11
  static getCacheEntry({ params }: RouteDefinitionHandler): Promise<ApiResponse<Object>>;
11
12
  static getExceptions({ qs }: RouteDefinitionHandler): Promise<ApiResponse<Omit<LensEntry, "data">[]>>;
12
13
  static getException({ params }: RouteDefinitionHandler): Promise<ApiResponse<Object>>;
14
+ static getEmails({ qs }: RouteDefinitionHandler): Promise<ApiResponse<Omit<LensEntry, "data">[]>>;
15
+ static getEmail({ params }: RouteDefinitionHandler): Promise<ApiResponse<Object>>;
13
16
  static truncate(): Promise<ApiResponse<{}>>;
14
17
  static fetchUiConfig(): {
15
18
  appName: string;
@@ -66,11 +66,17 @@ var ApiController = class {
66
66
  "exception" /* EXCEPTION */,
67
67
  false
68
68
  );
69
+ const emails = await getStore().allByRequestId(
70
+ request.id,
71
+ "mail" /* MAIL */,
72
+ false
73
+ );
69
74
  return this.resourceResponse({
70
75
  request,
71
76
  queries,
72
77
  cacheEntries,
73
- exceptions
78
+ exceptions,
79
+ emails
74
80
  });
75
81
  }
76
82
  static async getQueries({
@@ -117,6 +123,18 @@ var ApiController = class {
117
123
  }
118
124
  return this.resourceResponse(exception);
119
125
  }
126
+ static async getEmails({ qs }) {
127
+ return this.paginatedResponse(
128
+ await getStore().getAllEmails(this.extractPaginationParams(qs))
129
+ );
130
+ }
131
+ static async getEmail({ params }) {
132
+ const email = await getStore().find("mail" /* MAIL */, params.id);
133
+ if (!email) {
134
+ return this.notFoundResponse();
135
+ }
136
+ return this.resourceResponse(email);
137
+ }
120
138
  static async truncate() {
121
139
  await getStore().truncate();
122
140
  return this.baseResponse({}, 200, "All entries cleared");
@@ -102,11 +102,17 @@ var ApiController = class {
102
102
  "exception" /* EXCEPTION */,
103
103
  false
104
104
  );
105
+ const emails = await getStore().allByRequestId(
106
+ request.id,
107
+ "mail" /* MAIL */,
108
+ false
109
+ );
105
110
  return this.resourceResponse({
106
111
  request,
107
112
  queries,
108
113
  cacheEntries,
109
- exceptions
114
+ exceptions,
115
+ emails
110
116
  });
111
117
  }
112
118
  static async getQueries({
@@ -153,6 +159,18 @@ var ApiController = class {
153
159
  }
154
160
  return this.resourceResponse(exception);
155
161
  }
162
+ static async getEmails({ qs }) {
163
+ return this.paginatedResponse(
164
+ await getStore().getAllEmails(this.extractPaginationParams(qs))
165
+ );
166
+ }
167
+ static async getEmail({ params }) {
168
+ const email = await getStore().find("mail" /* MAIL */, params.id);
169
+ if (!email) {
170
+ return this.notFoundResponse();
171
+ }
172
+ return this.resourceResponse(email);
173
+ }
156
174
  static async truncate() {
157
175
  await getStore().truncate();
158
176
  return this.baseResponse({}, 200, "All entries cleared");
@@ -210,6 +228,9 @@ var Store = class {
210
228
  getAllExceptions(_paginationParams) {
211
229
  return this.defaultMinimalPaginate();
212
230
  }
231
+ getAllEmails(_paginationParams) {
232
+ return this.defaultMinimalPaginate();
233
+ }
213
234
  stringifyData(data) {
214
235
  if (typeof data === "string") {
215
236
  return data;
@@ -274,6 +295,9 @@ var BetterSqliteStore = class extends Store {
274
295
  async getAllExceptions(pagination) {
275
296
  return await this.paginate("exception" /* EXCEPTION */, pagination, false);
276
297
  }
298
+ async getAllEmails(pagination) {
299
+ return await this.paginate("mail" /* MAIL */, pagination, false);
300
+ }
277
301
  async allByRequestId(requestId, type, includeFullData = true) {
278
302
  const rows = this.connection.prepare(
279
303
  `${this.getSelectedColumns(includeFullData)} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
@@ -602,6 +626,16 @@ var Lens = class {
602
626
  path: `/${path3}/api/exceptions/:id`,
603
627
  handler: async (data) => await ApiController.getException(data)
604
628
  },
629
+ {
630
+ method: "GET",
631
+ path: `/${path3}/api/mail`,
632
+ handler: async (data) => await ApiController.getEmails(data)
633
+ },
634
+ {
635
+ method: "GET",
636
+ path: `/${path3}/api/mail/:id`,
637
+ handler: async (data) => await ApiController.getEmail(data)
638
+ },
605
639
  {
606
640
  method: "DELETE",
607
641
  path: `/${path3}/api/truncate`,
@@ -622,6 +656,7 @@ var Lens = class {
622
656
  queries: `/${this.config.path}/api/queries`,
623
657
  cache: `/${this.config.path}/api/cache`,
624
658
  exceptions: `/${this.config.path}/api/exceptions`,
659
+ mail: `/${this.config.path}/api/mail`,
625
660
  truncate: `/${this.config.path}/api/truncate`
626
661
  }
627
662
  };
@@ -3,6 +3,7 @@ import { LensConfig, RouteDefinitionHandler, ApiResponse } from '../types/index.
3
3
  import Watcher from './watcher.cjs';
4
4
  import Adapter from '../abstracts/adapter.cjs';
5
5
  import 'sql-formatter';
6
+ import '../types/mail.cjs';
6
7
 
7
8
  declare class Lens {
8
9
  private static watchers;
@@ -3,6 +3,7 @@ import { LensConfig, RouteDefinitionHandler, ApiResponse } from '../types/index.
3
3
  import Watcher from './watcher.js';
4
4
  import Adapter from '../abstracts/adapter.js';
5
5
  import 'sql-formatter';
6
+ import '../types/mail.js';
6
7
 
7
8
  declare class Lens {
8
9
  private static watchers;
package/dist/core/lens.js CHANGED
@@ -66,11 +66,17 @@ var ApiController = class {
66
66
  "exception" /* EXCEPTION */,
67
67
  false
68
68
  );
69
+ const emails = await getStore().allByRequestId(
70
+ request.id,
71
+ "mail" /* MAIL */,
72
+ false
73
+ );
69
74
  return this.resourceResponse({
70
75
  request,
71
76
  queries,
72
77
  cacheEntries,
73
- exceptions
78
+ exceptions,
79
+ emails
74
80
  });
75
81
  }
76
82
  static async getQueries({
@@ -117,6 +123,18 @@ var ApiController = class {
117
123
  }
118
124
  return this.resourceResponse(exception);
119
125
  }
126
+ static async getEmails({ qs }) {
127
+ return this.paginatedResponse(
128
+ await getStore().getAllEmails(this.extractPaginationParams(qs))
129
+ );
130
+ }
131
+ static async getEmail({ params }) {
132
+ const email = await getStore().find("mail" /* MAIL */, params.id);
133
+ if (!email) {
134
+ return this.notFoundResponse();
135
+ }
136
+ return this.resourceResponse(email);
137
+ }
120
138
  static async truncate() {
121
139
  await getStore().truncate();
122
140
  return this.baseResponse({}, 200, "All entries cleared");
@@ -174,6 +192,9 @@ var Store = class {
174
192
  getAllExceptions(_paginationParams) {
175
193
  return this.defaultMinimalPaginate();
176
194
  }
195
+ getAllEmails(_paginationParams) {
196
+ return this.defaultMinimalPaginate();
197
+ }
177
198
  stringifyData(data) {
178
199
  if (typeof data === "string") {
179
200
  return data;
@@ -238,6 +259,9 @@ var BetterSqliteStore = class extends Store {
238
259
  async getAllExceptions(pagination) {
239
260
  return await this.paginate("exception" /* EXCEPTION */, pagination, false);
240
261
  }
262
+ async getAllEmails(pagination) {
263
+ return await this.paginate("mail" /* MAIL */, pagination, false);
264
+ }
241
265
  async allByRequestId(requestId, type, includeFullData = true) {
242
266
  const rows = this.connection.prepare(
243
267
  `${this.getSelectedColumns(includeFullData)} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
@@ -565,6 +589,16 @@ var Lens = class {
565
589
  path: `/${path3}/api/exceptions/:id`,
566
590
  handler: async (data) => await ApiController.getException(data)
567
591
  },
592
+ {
593
+ method: "GET",
594
+ path: `/${path3}/api/mail`,
595
+ handler: async (data) => await ApiController.getEmails(data)
596
+ },
597
+ {
598
+ method: "GET",
599
+ path: `/${path3}/api/mail/:id`,
600
+ handler: async (data) => await ApiController.getEmail(data)
601
+ },
568
602
  {
569
603
  method: "DELETE",
570
604
  path: `/${path3}/api/truncate`,
@@ -585,6 +619,7 @@ var Lens = class {
585
619
  queries: `/${this.config.path}/api/queries`,
586
620
  cache: `/${this.config.path}/api/cache`,
587
621
  exceptions: `/${this.config.path}/api/exceptions`,
622
+ mail: `/${this.config.path}/api/mail`,
588
623
  truncate: `/${this.config.path}/api/truncate`
589
624
  }
590
625
  };
@@ -1,5 +1,6 @@
1
1
  import { WatcherTypeEnum } from '../types/index.cjs';
2
2
  import 'sql-formatter';
3
+ import '../types/mail.cjs';
3
4
 
4
5
  declare abstract class Watcher {
5
6
  abstract name: WatcherTypeEnum;
@@ -1,5 +1,6 @@
1
1
  import { WatcherTypeEnum } from '../types/index.js';
2
2
  import 'sql-formatter';
3
+ import '../types/mail.js';
3
4
 
4
5
  declare abstract class Watcher {
5
6
  abstract name: WatcherTypeEnum;
package/dist/index.cjs CHANGED
@@ -37,6 +37,7 @@ __export(index_exports, {
37
37
  LensAdapter: () => Adapter,
38
38
  LensStore: () => Store,
39
39
  LensWatcher: () => Watcher,
40
+ MailWatcher: () => MailWatcher,
40
41
  QueryWatcher: () => QueryWatcher,
41
42
  QueuedSqliteStore: () => QueuedSqliteStore,
42
43
  RequestWatcher: () => RequestWatcher,
@@ -100,6 +101,7 @@ var WatcherTypeEnum = /* @__PURE__ */ ((WatcherTypeEnum2) => {
100
101
  WatcherTypeEnum2["QUERY"] = "query";
101
102
  WatcherTypeEnum2["CACHE"] = "cache";
102
103
  WatcherTypeEnum2["EXCEPTION"] = "exception";
104
+ WatcherTypeEnum2["MAIL"] = "mail";
103
105
  return WatcherTypeEnum2;
104
106
  })(WatcherTypeEnum || {});
105
107
 
@@ -128,11 +130,17 @@ var ApiController = class {
128
130
  "exception" /* EXCEPTION */,
129
131
  false
130
132
  );
133
+ const emails = await getStore().allByRequestId(
134
+ request.id,
135
+ "mail" /* MAIL */,
136
+ false
137
+ );
131
138
  return this.resourceResponse({
132
139
  request,
133
140
  queries,
134
141
  cacheEntries,
135
- exceptions
142
+ exceptions,
143
+ emails
136
144
  });
137
145
  }
138
146
  static async getQueries({
@@ -179,6 +187,18 @@ var ApiController = class {
179
187
  }
180
188
  return this.resourceResponse(exception);
181
189
  }
190
+ static async getEmails({ qs }) {
191
+ return this.paginatedResponse(
192
+ await getStore().getAllEmails(this.extractPaginationParams(qs))
193
+ );
194
+ }
195
+ static async getEmail({ params }) {
196
+ const email = await getStore().find("mail" /* MAIL */, params.id);
197
+ if (!email) {
198
+ return this.notFoundResponse();
199
+ }
200
+ return this.resourceResponse(email);
201
+ }
182
202
  static async truncate() {
183
203
  await getStore().truncate();
184
204
  return this.baseResponse({}, 200, "All entries cleared");
@@ -236,6 +256,9 @@ var Store = class {
236
256
  getAllExceptions(_paginationParams) {
237
257
  return this.defaultMinimalPaginate();
238
258
  }
259
+ getAllEmails(_paginationParams) {
260
+ return this.defaultMinimalPaginate();
261
+ }
239
262
  stringifyData(data) {
240
263
  if (typeof data === "string") {
241
264
  return data;
@@ -300,6 +323,9 @@ var BetterSqliteStore = class extends Store {
300
323
  async getAllExceptions(pagination) {
301
324
  return await this.paginate("exception" /* EXCEPTION */, pagination, false);
302
325
  }
326
+ async getAllEmails(pagination) {
327
+ return await this.paginate("mail" /* MAIL */, pagination, false);
328
+ }
303
329
  async allByRequestId(requestId, type, includeFullData = true) {
304
330
  const rows = this.connection.prepare(
305
331
  `${this.getSelectedColumns(includeFullData)} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
@@ -746,6 +772,16 @@ var Lens = class {
746
772
  path: `/${path4}/api/exceptions/:id`,
747
773
  handler: async (data) => await ApiController.getException(data)
748
774
  },
775
+ {
776
+ method: "GET",
777
+ path: `/${path4}/api/mail`,
778
+ handler: async (data) => await ApiController.getEmails(data)
779
+ },
780
+ {
781
+ method: "GET",
782
+ path: `/${path4}/api/mail/:id`,
783
+ handler: async (data) => await ApiController.getEmail(data)
784
+ },
749
785
  {
750
786
  method: "DELETE",
751
787
  path: `/${path4}/api/truncate`,
@@ -766,6 +802,7 @@ var Lens = class {
766
802
  queries: `/${this.config.path}/api/queries`,
767
803
  cache: `/${this.config.path}/api/cache`,
768
804
  exceptions: `/${this.config.path}/api/exceptions`,
805
+ mail: `/${this.config.path}/api/mail`,
769
806
  truncate: `/${this.config.path}/api/truncate`
770
807
  }
771
808
  };
@@ -918,6 +955,25 @@ var ExceptionWatcher = class extends Watcher {
918
955
  }
919
956
  };
920
957
 
958
+ // src/watchers/mail_watcher.ts
959
+ var import_date2 = require("@lensjs/date");
960
+ var MailWatcher = class extends Watcher {
961
+ name = "mail" /* MAIL */;
962
+ async log(data) {
963
+ const recipientsCount = (data.to?.length ?? 0) + (data.cc?.length ?? 0) + (data.bcc?.length ?? 0);
964
+ await getStore().save({
965
+ requestId: data.requestId ?? "",
966
+ type: this.name,
967
+ minimal_data: {
968
+ subject: data.subject ?? "",
969
+ recipientsCount,
970
+ createdAt: data.date ?? (0, import_date2.nowISO)()
971
+ },
972
+ data
973
+ });
974
+ }
975
+ };
976
+
921
977
  // src/abstracts/adapter.ts
922
978
  var Adapter = class {
923
979
  watchers = [];
@@ -955,7 +1011,7 @@ __export(exception_exports, {
955
1011
  var import_stack_utils = __toESM(require("stack-utils"), 1);
956
1012
  var import_node_path = __toESM(require("path"), 1);
957
1013
  var import_node_fs = require("fs");
958
- var import_date2 = require("@lensjs/date");
1014
+ var import_date3 = require("@lensjs/date");
959
1015
  var stackUtils = new import_stack_utils.default({
960
1016
  cwd: process.cwd(),
961
1017
  internals: import_stack_utils.default.nodeInternals()
@@ -1024,7 +1080,7 @@ function constructErrorObject(err) {
1024
1080
  return {
1025
1081
  name: err.name,
1026
1082
  message: err.message,
1027
- createdAt: (0, import_date2.nowISO)(),
1083
+ createdAt: (0, import_date3.nowISO)(),
1028
1084
  fileInfo: {
1029
1085
  file: fileInfo.file,
1030
1086
  function: fileInfo.function
@@ -1087,6 +1143,7 @@ var handleUncaughExceptions = (logger) => {
1087
1143
  LensAdapter,
1088
1144
  LensStore,
1089
1145
  LensWatcher,
1146
+ MailWatcher,
1090
1147
  QueryWatcher,
1091
1148
  QueuedSqliteStore,
1092
1149
  RequestWatcher,
package/dist/index.d.cts CHANGED
@@ -5,7 +5,8 @@ export { default as QueryWatcher } from './watchers/query_watcher.cjs';
5
5
  export { default as RequestWatcher } from './watchers/request_watcher.cjs';
6
6
  export { default as CacheWatcher } from './watchers/cache_watcher.cjs';
7
7
  export { default as ExceptionWatcher } from './watchers/exception_watcher.cjs';
8
- export { ApiResponse, CacheAction, CacheEntry, Constructor, Entry, ExceptionEntry, HttpMethod, LensConfig, LensEntry, PaginationParams, Paginator, QueryEntry, QueryType, QueuedStoreConfig, RequestEntry, RouteDefinition, RouteDefinitionHandler, RouteHttpMethod, SqlQueryType, UserEntry, WatcherTypeEnum } from './types/index.cjs';
8
+ export { default as MailWatcher } from './watchers/mail_watcher.cjs';
9
+ export { ApiResponse, CacheAction, CacheEntry, Constructor, ExceptionEntry, HttpMethod, LensConfig, LensEntry, PaginationParams, Paginator, QueryEntry, QueryType, QueuedStoreConfig, RequestEntry, RouteDefinition, RouteDefinitionHandler, RouteHttpMethod, SqlQueryType, UserEntry, WatcherTypeEnum } from './types/index.cjs';
9
10
  export { default as LensAdapter } from './abstracts/adapter.cjs';
10
11
  export { default as LensStore } from './abstracts/store.cjs';
11
12
  export { default as LensWatcher } from './core/watcher.cjs';
@@ -14,6 +15,7 @@ export { i as lensUtils } from './index-CDaOwv3y.cjs';
14
15
  export { e as lensExceptionUtils } from './exception-BJqUL0j5.cjs';
15
16
  export { createEmittery, lensEmitter } from './utils/event_emitter.cjs';
16
17
  export { handleUncaughExceptions, lensContext } from './utils/async_context.cjs';
18
+ export { MailEntry, MailEnvelope, MailHeader, MailMeta, MailRawSource, Mailbox, MimePart } from './types/mail.cjs';
17
19
  import 'libsql';
18
20
  import 'denque';
19
21
  import 'sql-formatter';
package/dist/index.d.ts CHANGED
@@ -5,7 +5,8 @@ export { default as QueryWatcher } from './watchers/query_watcher.js';
5
5
  export { default as RequestWatcher } from './watchers/request_watcher.js';
6
6
  export { default as CacheWatcher } from './watchers/cache_watcher.js';
7
7
  export { default as ExceptionWatcher } from './watchers/exception_watcher.js';
8
- export { ApiResponse, CacheAction, CacheEntry, Constructor, Entry, ExceptionEntry, HttpMethod, LensConfig, LensEntry, PaginationParams, Paginator, QueryEntry, QueryType, QueuedStoreConfig, RequestEntry, RouteDefinition, RouteDefinitionHandler, RouteHttpMethod, SqlQueryType, UserEntry, WatcherTypeEnum } from './types/index.js';
8
+ export { default as MailWatcher } from './watchers/mail_watcher.js';
9
+ export { ApiResponse, CacheAction, CacheEntry, Constructor, ExceptionEntry, HttpMethod, LensConfig, LensEntry, PaginationParams, Paginator, QueryEntry, QueryType, QueuedStoreConfig, RequestEntry, RouteDefinition, RouteDefinitionHandler, RouteHttpMethod, SqlQueryType, UserEntry, WatcherTypeEnum } from './types/index.js';
9
10
  export { default as LensAdapter } from './abstracts/adapter.js';
10
11
  export { default as LensStore } from './abstracts/store.js';
11
12
  export { default as LensWatcher } from './core/watcher.js';
@@ -14,6 +15,7 @@ export { i as lensUtils } from './index-DRfxZjgs.js';
14
15
  export { e as lensExceptionUtils } from './exception-DYe0t9-2.js';
15
16
  export { createEmittery, lensEmitter } from './utils/event_emitter.js';
16
17
  export { handleUncaughExceptions, lensContext } from './utils/async_context.js';
18
+ export { MailEntry, MailEnvelope, MailHeader, MailMeta, MailRawSource, Mailbox, MimePart } from './types/mail.js';
17
19
  import 'libsql';
18
20
  import 'denque';
19
21
  import 'sql-formatter';