@lensjs/core 2.2.1 → 2.3.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 (88) hide show
  1. package/dist/abstracts/store.cjs +2 -0
  2. package/dist/abstracts/store.d.cts +1 -0
  3. package/dist/abstracts/store.d.ts +1 -0
  4. package/dist/abstracts/store.js +2 -0
  5. package/dist/core/lens.cjs +115 -23
  6. package/dist/core/lens.d.cts +3 -2
  7. package/dist/core/lens.d.ts +3 -2
  8. package/dist/core/lens.js +115 -23
  9. package/dist/{index-CMvlRWcQ.d.cts → index-CZsa0Zcm.d.ts} +3 -1
  10. package/dist/{index-CMvlRWcQ.d.ts → index-QmOJr0K-.d.cts} +3 -1
  11. package/dist/index.cjs +163 -28
  12. package/dist/index.d.cts +5 -2
  13. package/dist/index.d.ts +5 -2
  14. package/dist/index.js +162 -28
  15. package/dist/mixins/queued_store.cjs +113 -0
  16. package/dist/mixins/queued_store.d.cts +38 -0
  17. package/dist/mixins/queued_store.d.ts +38 -0
  18. package/dist/mixins/queued_store.js +78 -0
  19. package/dist/stores/better_sqlite.cjs +2 -0
  20. package/dist/stores/better_sqlite.js +2 -0
  21. package/dist/stores/index.cjs +94 -2
  22. package/dist/stores/index.d.cts +2 -0
  23. package/dist/stores/index.d.ts +2 -0
  24. package/dist/stores/index.js +92 -1
  25. package/dist/stores/queued_sqlite.cjs +278 -0
  26. package/dist/stores/queued_sqlite.d.cts +43 -0
  27. package/dist/stores/queued_sqlite.d.ts +43 -0
  28. package/dist/stores/queued_sqlite.js +245 -0
  29. package/dist/types/index.d.cts +14 -2
  30. package/dist/types/index.d.ts +14 -2
  31. package/dist/ui/assets/{CacheActionBadge-WGVr5yhe.js → CacheActionBadge-BB4uokI1.js} +1 -1
  32. package/dist/ui/assets/CacheEntriesTable-B8cUXhos.js +1 -0
  33. package/dist/ui/assets/CacheEntryContainer-WkdnGvnu.js +2 -0
  34. package/dist/ui/assets/CacheEntryDetails-BeZnoIpm.js +1 -0
  35. package/dist/ui/assets/CacheEntryDetailsContainer-DI0mEvpu.js +2 -0
  36. package/dist/ui/assets/ExceptionContainer-YNcR0F5U.js +2 -0
  37. package/dist/ui/assets/{ExceptionDetails-DX14YGmx.js → ExceptionDetails-BKHzv6hf.js} +1 -1
  38. package/dist/ui/assets/ExceptionDetailsContainer-CJHILjb3.js +2 -0
  39. package/dist/ui/assets/{ExceptionTable-Chiah5kT.js → ExceptionTable-DzBmQLLa.js} +1 -1
  40. package/dist/ui/assets/JsonViewer-D-KPN089.js +1 -0
  41. package/dist/ui/assets/{LoadMore-CosGy1fp.js → LoadMore-CLPR6Zd4.js} +1 -1
  42. package/dist/ui/assets/QueriesContainer-B_PmBkHR.js +2 -0
  43. package/dist/ui/assets/{QueryDetailsContainer-Dimuidq4.js → QueryDetailsContainer-Cqj3E6Dr.js} +16 -26
  44. package/dist/ui/assets/{QueryTable-BLpmWt7g.js → QueryTable-DmWdZSnJ.js} +1 -1
  45. package/dist/ui/assets/{RequestDetails-DeJofxSW.js → RequestDetails-CF338Kcv.js} +1 -1
  46. package/dist/ui/assets/{RequestDetailsContainer-BtDTKq1O.js → RequestDetailsContainer-aW4GLool.js} +2 -2
  47. package/dist/ui/assets/{RequestsContainer-CxIavrPj.js → RequestsContainer-DdLSvAbl.js} +2 -2
  48. package/dist/ui/assets/{RequetsTable-CUevs9X4.js → RequetsTable-Bdp_PhGU.js} +1 -1
  49. package/dist/ui/assets/StatusCode-C605nHvd.js +1 -0
  50. package/dist/ui/assets/TabbedDataViewer-ofhEq_Wj.js +2 -0
  51. package/dist/ui/assets/{Table-z_QSS7J8.js → Table-kak5sL5X.js} +1 -1
  52. package/dist/ui/assets/{columns-Bxz-DZCj.js → columns-BEyDhUNq.js} +1 -1
  53. package/dist/ui/assets/{columns-D0UC1pqC.js → columns-Bu5psHyp.js} +1 -1
  54. package/dist/ui/assets/{columns-DJaOm2Yg.js → columns-BvIUTkjN.js} +1 -1
  55. package/dist/ui/assets/copy-DzXuP4eO.js +11 -0
  56. package/dist/ui/assets/index-CsnKQ5Mh.css +1 -0
  57. package/dist/ui/assets/{index-CQJv-KV7.js → index-TW_-MgRG.js} +25 -25
  58. package/dist/ui/assets/{useCacheEntries-DWzLAzvE.js → useCacheEntries-Pvte_aNc.js} +1 -1
  59. package/dist/ui/assets/{useExceptions-BF0fHNek.js → useExceptions-P3cnURvN.js} +1 -1
  60. package/dist/ui/assets/{useLensApi-BEMg_OuP.js → useLensApi-BFdsfrzR.js} +1 -1
  61. package/dist/ui/assets/{useLoadMore-ClIkZ0Gw.js → useLoadMore-JCWak1Dg.js} +1 -1
  62. package/dist/ui/assets/{useQueries-C0vKfgzw.js → useQueries-CNquFtm0.js} +1 -1
  63. package/dist/ui/index.html +2 -2
  64. package/dist/utils/compose.cjs +32 -0
  65. package/dist/utils/compose.d.cts +11 -0
  66. package/dist/utils/compose.d.ts +11 -0
  67. package/dist/utils/compose.js +7 -0
  68. package/dist/utils/index.cjs +9 -0
  69. package/dist/utils/index.d.cts +3 -1
  70. package/dist/utils/index.d.ts +3 -1
  71. package/dist/utils/index.js +8 -0
  72. package/dist/watchers/index.cjs +45 -5
  73. package/dist/watchers/index.js +45 -5
  74. package/dist/watchers/request_watcher.cjs +45 -5
  75. package/dist/watchers/request_watcher.d.cts +12 -1
  76. package/dist/watchers/request_watcher.d.ts +12 -1
  77. package/dist/watchers/request_watcher.js +45 -5
  78. package/package.json +2 -1
  79. package/dist/ui/assets/CacheEntriesTable-txREHfFk.js +0 -1
  80. package/dist/ui/assets/CacheEntryContainer-BoeiVJN6.js +0 -2
  81. package/dist/ui/assets/CacheEntryDetails-DovbpPae.js +0 -1
  82. package/dist/ui/assets/CacheEntryDetailsContainer-DcmH8iqv.js +0 -2
  83. package/dist/ui/assets/ExceptionContainer-C0H0kKkb.js +0 -2
  84. package/dist/ui/assets/ExceptionDetailsContainer-CHAXdzwk.js +0 -2
  85. package/dist/ui/assets/QueriesContainer-CporgPyk.js +0 -2
  86. package/dist/ui/assets/StatusCode-D_bCVpUf.js +0 -1
  87. package/dist/ui/assets/TabbedDataViewer-CbZANxvH.js +0 -1
  88. package/dist/ui/assets/index-B2QCOgug.css +0 -1
@@ -1 +1 @@
1
- import{r as t}from"./index-CQJv-KV7.js";import{D as I,u as h}from"./useLensApi-BEMg_OuP.js";function C(){const[n,r]=t.useState([]),[l,m]=t.useState(),[c,a]=t.useState(!1),[i,u]=t.useState(I),{getCacheEntries:e,getCacheEntryById:f}=h(),d=t.useCallback(async o=>{a(!0),f(o).then(s=>{m(s.data)}).finally(()=>{a(!1)})},[e]),g=t.useCallback(async o=>{a(!0),await e(o??1).then(s=>{r(s.data),u(s.meta)}).finally(()=>{a(!1)})},[e]);return{loadMoreItems:t.useMemo(()=>({initialData:n,meta:i,loading:c,fetchRawPage:e}),[n,i,c,e]),getItems:g,getItem:d,items:n,item:l}}export{C as u};
1
+ import{r as t}from"./index-TW_-MgRG.js";import{D as I,u as h}from"./useLensApi-BFdsfrzR.js";function C(){const[n,r]=t.useState([]),[l,m]=t.useState(),[c,a]=t.useState(!1),[i,u]=t.useState(I),{getCacheEntries:e,getCacheEntryById:f}=h(),d=t.useCallback(async o=>{a(!0),f(o).then(s=>{m(s.data)}).finally(()=>{a(!1)})},[e]),g=t.useCallback(async o=>{a(!0),await e(o??1).then(s=>{r(s.data),u(s.meta)}).finally(()=>{a(!1)})},[e]);return{loadMoreItems:t.useMemo(()=>({initialData:n,meta:i,loading:c,fetchRawPage:e}),[n,i,c,e]),getItems:g,getItem:d,items:n,item:l}}export{C as u};
@@ -1 +1 @@
1
- import{r as t}from"./index-CQJv-KV7.js";import{D as g,u as I}from"./useLensApi-BEMg_OuP.js";function M(){const[o,l]=t.useState([]),[m,u]=t.useState(),[c,a]=t.useState(!1),[i,r]=t.useState(g),{getExceptions:e,getExceptionById:f}=I(),p=t.useCallback(async n=>{a(!0),f(n).then(s=>{u(s.data)}).finally(()=>{a(!1)})},[e]),d=t.useCallback(async n=>{a(!0),await e(n??1).then(s=>{l(s.data),r(s.meta)}).finally(()=>{a(!1)})},[e]);return{loadMoreItems:t.useMemo(()=>({initialData:o,meta:i,loading:c,fetchRawPage:e}),[o,i,c,e]),getItems:d,getItem:p,items:o,item:m}}export{M as u};
1
+ import{r as t}from"./index-TW_-MgRG.js";import{D as g,u as I}from"./useLensApi-BFdsfrzR.js";function M(){const[o,l]=t.useState([]),[m,u]=t.useState(),[c,a]=t.useState(!1),[i,r]=t.useState(g),{getExceptions:e,getExceptionById:f}=I(),p=t.useCallback(async n=>{a(!0),f(n).then(s=>{u(s.data)}).finally(()=>{a(!1)})},[e]),d=t.useCallback(async n=>{a(!0),await e(n??1).then(s=>{l(s.data),r(s.meta)}).finally(()=>{a(!1)})},[e]);return{loadMoreItems:t.useMemo(()=>({initialData:o,meta:i,loading:c,fetchRawPage:e}),[o,i,c,e]),getItems:d,getItem:p,items:o,item:m}}export{M as u};
@@ -1 +1 @@
1
- import{k as p,l as s}from"./index-CQJv-KV7.js";const B={currentPage:1,lastPage:1,total:0},I=()=>{const t=p();async function n(e,a){const r=await fetch(e,{headers:{"Content-Type":"application/json"},...a});if(!r.ok)throw new Error(`Failed to fetch: ${e}`);return r.json()}const c=(e,a)=>{const r=new URLSearchParams(Object.entries(a||{}).reduce((i,[u,o])=>(o!=null&&(i[u]=String(o)),i),{}));return`${e}${r.toString()?`?${r}`:""}`};return{getAllRequests:async e=>n(s(c(t.api.requests,{page:e}))),getRequestById:async e=>n(s(`${t.api.requests}/${e}`)),getQueries:async e=>n(s(c(t.api.queries,{page:e}))),getQueryById:async e=>n(s(`${t.api.queries}/${e}`)),getCacheEntries:async e=>n(s(c(t.api.cache,{page:e}))),getCacheEntryById:async e=>n(s(`${t.api.cache}/${e}`)),getExceptions:async e=>n(s(c(t.api.exceptions,{page:e}))),getExceptionById:async e=>n(s(`${t.api.exceptions}/${e}`))}};export{B as D,I as u};
1
+ import{k as p,l as s}from"./index-TW_-MgRG.js";const B={currentPage:1,lastPage:1,total:0},I=()=>{const t=p();async function n(e,a){const r=await fetch(e,{headers:{"Content-Type":"application/json"},...a});if(!r.ok)throw new Error(`Failed to fetch: ${e}`);return r.json()}const c=(e,a)=>{const r=new URLSearchParams(Object.entries(a||{}).reduce((i,[u,o])=>(o!=null&&(i[u]=String(o)),i),{}));return`${e}${r.toString()?`?${r}`:""}`};return{getAllRequests:async e=>n(s(c(t.api.requests,{page:e}))),getRequestById:async e=>n(s(`${t.api.requests}/${e}`)),getQueries:async e=>n(s(c(t.api.queries,{page:e}))),getQueryById:async e=>n(s(`${t.api.queries}/${e}`)),getCacheEntries:async e=>n(s(c(t.api.cache,{page:e}))),getCacheEntryById:async e=>n(s(`${t.api.cache}/${e}`)),getExceptions:async e=>n(s(c(t.api.exceptions,{page:e}))),getExceptionById:async e=>n(s(`${t.api.exceptions}/${e}`))}};export{B as D,I as u};
@@ -1 +1 @@
1
- import{r as e}from"./index-CQJv-KV7.js";function D({paginatedPage:t}){const[f,r]=e.useState([]),[m,l]=e.useState(1),[c,s]=e.useState(!1),[n,o]=e.useState(!1);return e.useEffect(()=>{s(t.loading),o(t.meta.currentPage<t.meta.lastPage),l(1),t.loading||r(t.initialData)},[t.initialData,t.loading,t.meta.currentPage,t.meta.lastPage]),{data:f,loading:c,hasMore:n,loadMore:async()=>{if(c||!n)return;s(!0);const u=m+1,a=await t.fetchRawPage(u);r(i=>[...i,...a.data]),l(u),a?.meta?o(a.meta.currentPage<a.meta.lastPage):o(!1),s(!1)}}}export{D as u};
1
+ import{r as e}from"./index-TW_-MgRG.js";function D({paginatedPage:t}){const[f,r]=e.useState([]),[m,l]=e.useState(1),[c,s]=e.useState(!1),[n,o]=e.useState(!1);return e.useEffect(()=>{s(t.loading),o(t.meta.currentPage<t.meta.lastPage),l(1),t.loading||r(t.initialData)},[t.initialData,t.loading,t.meta.currentPage,t.meta.lastPage]),{data:f,loading:c,hasMore:n,loadMore:async()=>{if(c||!n)return;s(!0);const u=m+1,a=await t.fetchRawPage(u);r(i=>[...i,...a.data]),l(u),a?.meta?o(a.meta.currentPage<a.meta.lastPage):o(!1),s(!1)}}}export{D as u};
@@ -1 +1 @@
1
- import{r as e}from"./index-CQJv-KV7.js";import{D as Q,u as g}from"./useLensApi-BEMg_OuP.js";function q(){const[u,c]=e.useState([]),[i,l]=e.useState(),[r,s]=e.useState(!1),[n,f]=e.useState(Q),{getQueries:t,getQueryById:y}=g(),d=e.useCallback(async o=>{s(!0),y(o).then(a=>{l(a.data)}).finally(()=>{s(!1)})},[t]),m=e.useCallback(async o=>{s(!0),await t(o??1).then(a=>{c(a.data),f(a.meta)}).finally(()=>{s(!1)})},[t]);return{loadMoreRequests:e.useMemo(()=>({initialData:u,meta:n,loading:r,fetchRawPage:t}),[u,n,r,t]),fetchQueries:m,fetchQuery:d,queries:u,query:i}}export{q as u};
1
+ import{r as e}from"./index-TW_-MgRG.js";import{D as Q,u as g}from"./useLensApi-BFdsfrzR.js";function q(){const[u,c]=e.useState([]),[i,l]=e.useState(),[r,s]=e.useState(!1),[n,f]=e.useState(Q),{getQueries:t,getQueryById:y}=g(),d=e.useCallback(async o=>{s(!0),y(o).then(a=>{l(a.data)}).finally(()=>{s(!1)})},[t]),m=e.useCallback(async o=>{s(!0),await t(o??1).then(a=>{c(a.data),f(a.meta)}).finally(()=>{s(!1)})},[t]);return{loadMoreRequests:e.useMemo(()=>({initialData:u,meta:n,loading:r,fetchRawPage:t}),[u,n,r,t]),fetchQueries:m,fetchQuery:d,queries:u,query:i}}export{q as u};
@@ -5,8 +5,8 @@
5
5
  <link rel="icon" type="image/svg+xml" href="./assets/favicon-CwRXoGYE.ico" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Lens</title>
8
- <script type="module" crossorigin src="./assets/index-CQJv-KV7.js"></script>
9
- <link rel="stylesheet" crossorigin href="./assets/index-B2QCOgug.css">
8
+ <script type="module" crossorigin src="./assets/index-TW_-MgRG.js"></script>
9
+ <link rel="stylesheet" crossorigin href="./assets/index-CsnKQ5Mh.css">
10
10
  </head>
11
11
  <body>
12
12
  <div id="root"></div>
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/compose.ts
21
+ var compose_exports = {};
22
+ __export(compose_exports, {
23
+ compose: () => compose
24
+ });
25
+ module.exports = __toCommonJS(compose_exports);
26
+ function compose(superclass, ...mixins) {
27
+ return mixins.reduce((c, mixin) => mixin(c), superclass);
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ compose
32
+ });
@@ -0,0 +1,11 @@
1
+ import { Constructor } from '../types/index.cjs';
2
+ import 'sql-formatter';
3
+
4
+ interface UnaryFunction<T, R> {
5
+ (source: T): R;
6
+ }
7
+ declare function compose<T extends Constructor, A>(superclass: T, mixin: UnaryFunction<T, A>): A;
8
+ declare function compose<T extends Constructor, A, B>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>): B;
9
+ declare function compose<T extends Constructor, A, B, C>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>, mixinC: UnaryFunction<B, C>): C;
10
+
11
+ export { compose };
@@ -0,0 +1,11 @@
1
+ import { Constructor } from '../types/index.js';
2
+ import 'sql-formatter';
3
+
4
+ interface UnaryFunction<T, R> {
5
+ (source: T): R;
6
+ }
7
+ declare function compose<T extends Constructor, A>(superclass: T, mixin: UnaryFunction<T, A>): A;
8
+ declare function compose<T extends Constructor, A, B>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>): B;
9
+ declare function compose<T extends Constructor, A, B, C>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>, mixinC: UnaryFunction<B, C>): C;
10
+
11
+ export { compose };
@@ -0,0 +1,7 @@
1
+ // src/utils/compose.ts
2
+ function compose(superclass, ...mixins) {
3
+ return mixins.reduce((c, mixin) => mixin(c), superclass);
4
+ }
5
+ export {
6
+ compose
7
+ };
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/utils/index.ts
31
31
  var utils_exports = {};
32
32
  __export(utils_exports, {
33
+ compose: () => compose,
33
34
  formatSqlQuery: () => formatSqlQuery,
34
35
  generateRandomUuid: () => generateRandomUuid,
35
36
  getMeta: () => getMeta,
@@ -47,6 +48,13 @@ var import_sql_formatter = require("sql-formatter");
47
48
  var import_crypto = require("crypto");
48
49
  var import_url = require("url");
49
50
  var path = __toESM(require("path"), 1);
51
+
52
+ // src/utils/compose.ts
53
+ function compose(superclass, ...mixins) {
54
+ return mixins.reduce((c, mixin) => mixin(c), superclass);
55
+ }
56
+
57
+ // src/utils/index.ts
50
58
  var generateRandomUuid = () => {
51
59
  return (0, import_crypto.randomUUID)();
52
60
  };
@@ -166,6 +174,7 @@ function normalizePath(path2) {
166
174
  }
167
175
  // Annotate the CommonJS export names for ESM import in node:
168
176
  0 && (module.exports = {
177
+ compose,
169
178
  formatSqlQuery,
170
179
  generateRandomUuid,
171
180
  getMeta,
@@ -1,2 +1,4 @@
1
1
  import 'sql-formatter';
2
- export { f as formatSqlQuery, g as generateRandomUuid, b as getMeta, a as interpolateQuery, c as isStaticFile, n as normalizePath, p as prepareIgnoredPaths, e as prettyHrTime, d as shouldIgnoreCurrentPath, s as stripBeforeAssetsPath } from '../index-CMvlRWcQ.cjs';
2
+ export { compose } from './compose.cjs';
3
+ export { f as formatSqlQuery, g as generateRandomUuid, b as getMeta, a as interpolateQuery, c as isStaticFile, n as normalizePath, p as prepareIgnoredPaths, e as prettyHrTime, d as shouldIgnoreCurrentPath, s as stripBeforeAssetsPath } from '../index-QmOJr0K-.cjs';
4
+ import '../types/index.cjs';
@@ -1,2 +1,4 @@
1
1
  import 'sql-formatter';
2
- export { f as formatSqlQuery, g as generateRandomUuid, b as getMeta, a as interpolateQuery, c as isStaticFile, n as normalizePath, p as prepareIgnoredPaths, e as prettyHrTime, d as shouldIgnoreCurrentPath, s as stripBeforeAssetsPath } from '../index-CMvlRWcQ.js';
2
+ export { compose } from './compose.js';
3
+ export { f as formatSqlQuery, g as generateRandomUuid, b as getMeta, a as interpolateQuery, c as isStaticFile, n as normalizePath, p as prepareIgnoredPaths, e as prettyHrTime, d as shouldIgnoreCurrentPath, s as stripBeforeAssetsPath } from '../index-CZsa0Zcm.js';
4
+ import '../types/index.js';
@@ -4,6 +4,13 @@ import { format } from "sql-formatter";
4
4
  import { randomUUID } from "crypto";
5
5
  import { fileURLToPath } from "url";
6
6
  import * as path from "path";
7
+
8
+ // src/utils/compose.ts
9
+ function compose(superclass, ...mixins) {
10
+ return mixins.reduce((c, mixin) => mixin(c), superclass);
11
+ }
12
+
13
+ // src/utils/index.ts
7
14
  var generateRandomUuid = () => {
8
15
  return randomUUID();
9
16
  };
@@ -122,6 +129,7 @@ function normalizePath(path2) {
122
129
  return path2.startsWith("/") ? path2 : `/${path2}`;
123
130
  }
124
131
  export {
132
+ compose,
125
133
  formatSqlQuery,
126
134
  generateRandomUuid,
127
135
  getMeta,
@@ -94,10 +94,19 @@ var QueryWatcher = class extends Watcher {
94
94
  };
95
95
 
96
96
  // src/watchers/request_watcher.ts
97
- var RequestWatcher = class extends Watcher {
97
+ var RequestWatcher = class _RequestWatcher extends Watcher {
98
98
  name = "request" /* REQUEST */;
99
- async log(data) {
100
- await getStore().save({
99
+ static DEFAULT_HIDDEN_HEADERS = ["Authorization", "Basic"];
100
+ static DEFAULT_HIDDEN_BODY_PARAMS = [
101
+ "password",
102
+ "passwordConfirmation",
103
+ "secret",
104
+ "password_confirmation"
105
+ ];
106
+ async log(data, hidden = {}) {
107
+ const headersToHide = (hidden.headers?.length ? hidden.headers : _RequestWatcher.DEFAULT_HIDDEN_HEADERS).map((header) => header.toLowerCase());
108
+ const bodyParamsToHide = hidden.bodyParams?.length ? hidden.bodyParams : _RequestWatcher.DEFAULT_HIDDEN_BODY_PARAMS;
109
+ const payload = {
101
110
  id: data.request.id,
102
111
  type: this.name,
103
112
  minimal_data: {
@@ -111,9 +120,40 @@ var RequestWatcher = class extends Watcher {
111
120
  data: {
112
121
  ...data.request,
113
122
  user: data.user,
114
- response: data.response
123
+ response: data.response || {}
115
124
  }
116
- });
125
+ };
126
+ payload.data.headers = this.hideSensitive(
127
+ this.normalizeHeaders(payload.data.headers),
128
+ headersToHide
129
+ );
130
+ payload.data.response.headers = this.hideSensitive(
131
+ this.normalizeHeaders(payload.data.response?.headers),
132
+ headersToHide
133
+ );
134
+ payload.data.body = this.hideSensitive(payload.data.body, bodyParamsToHide, false);
135
+ await getStore().save(payload);
136
+ }
137
+ /**
138
+ * Normalize headers: converts keys to lowercase.
139
+ */
140
+ normalizeHeaders(headers) {
141
+ if (!headers || typeof headers !== "object") return {};
142
+ return Object.fromEntries(
143
+ Object.entries(headers).map(([k, v]) => [k.toLowerCase(), v])
144
+ );
145
+ }
146
+ hideSensitive(obj, keysToHide = [], isObjHeaders = true) {
147
+ if (!obj || typeof obj !== "object") {
148
+ return isObjHeaders ? {} : obj;
149
+ }
150
+ const clone = { ...obj };
151
+ for (const key of keysToHide) {
152
+ if (key in clone) {
153
+ clone[key] = "*******";
154
+ }
155
+ }
156
+ return clone;
117
157
  }
118
158
  };
119
159
 
@@ -55,10 +55,19 @@ var QueryWatcher = class extends Watcher {
55
55
  };
56
56
 
57
57
  // src/watchers/request_watcher.ts
58
- var RequestWatcher = class extends Watcher {
58
+ var RequestWatcher = class _RequestWatcher extends Watcher {
59
59
  name = "request" /* REQUEST */;
60
- async log(data) {
61
- await getStore().save({
60
+ static DEFAULT_HIDDEN_HEADERS = ["Authorization", "Basic"];
61
+ static DEFAULT_HIDDEN_BODY_PARAMS = [
62
+ "password",
63
+ "passwordConfirmation",
64
+ "secret",
65
+ "password_confirmation"
66
+ ];
67
+ async log(data, hidden = {}) {
68
+ const headersToHide = (hidden.headers?.length ? hidden.headers : _RequestWatcher.DEFAULT_HIDDEN_HEADERS).map((header) => header.toLowerCase());
69
+ const bodyParamsToHide = hidden.bodyParams?.length ? hidden.bodyParams : _RequestWatcher.DEFAULT_HIDDEN_BODY_PARAMS;
70
+ const payload = {
62
71
  id: data.request.id,
63
72
  type: this.name,
64
73
  minimal_data: {
@@ -72,9 +81,40 @@ var RequestWatcher = class extends Watcher {
72
81
  data: {
73
82
  ...data.request,
74
83
  user: data.user,
75
- response: data.response
84
+ response: data.response || {}
76
85
  }
77
- });
86
+ };
87
+ payload.data.headers = this.hideSensitive(
88
+ this.normalizeHeaders(payload.data.headers),
89
+ headersToHide
90
+ );
91
+ payload.data.response.headers = this.hideSensitive(
92
+ this.normalizeHeaders(payload.data.response?.headers),
93
+ headersToHide
94
+ );
95
+ payload.data.body = this.hideSensitive(payload.data.body, bodyParamsToHide, false);
96
+ await getStore().save(payload);
97
+ }
98
+ /**
99
+ * Normalize headers: converts keys to lowercase.
100
+ */
101
+ normalizeHeaders(headers) {
102
+ if (!headers || typeof headers !== "object") return {};
103
+ return Object.fromEntries(
104
+ Object.entries(headers).map(([k, v]) => [k.toLowerCase(), v])
105
+ );
106
+ }
107
+ hideSensitive(obj, keysToHide = [], isObjHeaders = true) {
108
+ if (!obj || typeof obj !== "object") {
109
+ return isObjHeaders ? {} : obj;
110
+ }
111
+ const clone = { ...obj };
112
+ for (const key of keysToHide) {
113
+ if (key in clone) {
114
+ clone[key] = "*******";
115
+ }
116
+ }
117
+ return clone;
78
118
  }
79
119
  };
80
120
 
@@ -69,10 +69,19 @@ var Watcher = class {
69
69
  };
70
70
 
71
71
  // src/watchers/request_watcher.ts
72
- var RequestWatcher = class extends Watcher {
72
+ var RequestWatcher = class _RequestWatcher extends Watcher {
73
73
  name = "request" /* REQUEST */;
74
- async log(data) {
75
- await getStore().save({
74
+ static DEFAULT_HIDDEN_HEADERS = ["Authorization", "Basic"];
75
+ static DEFAULT_HIDDEN_BODY_PARAMS = [
76
+ "password",
77
+ "passwordConfirmation",
78
+ "secret",
79
+ "password_confirmation"
80
+ ];
81
+ async log(data, hidden = {}) {
82
+ const headersToHide = (hidden.headers?.length ? hidden.headers : _RequestWatcher.DEFAULT_HIDDEN_HEADERS).map((header) => header.toLowerCase());
83
+ const bodyParamsToHide = hidden.bodyParams?.length ? hidden.bodyParams : _RequestWatcher.DEFAULT_HIDDEN_BODY_PARAMS;
84
+ const payload = {
76
85
  id: data.request.id,
77
86
  type: this.name,
78
87
  minimal_data: {
@@ -86,8 +95,39 @@ var RequestWatcher = class extends Watcher {
86
95
  data: {
87
96
  ...data.request,
88
97
  user: data.user,
89
- response: data.response
98
+ response: data.response || {}
90
99
  }
91
- });
100
+ };
101
+ payload.data.headers = this.hideSensitive(
102
+ this.normalizeHeaders(payload.data.headers),
103
+ headersToHide
104
+ );
105
+ payload.data.response.headers = this.hideSensitive(
106
+ this.normalizeHeaders(payload.data.response?.headers),
107
+ headersToHide
108
+ );
109
+ payload.data.body = this.hideSensitive(payload.data.body, bodyParamsToHide, false);
110
+ await getStore().save(payload);
111
+ }
112
+ /**
113
+ * Normalize headers: converts keys to lowercase.
114
+ */
115
+ normalizeHeaders(headers) {
116
+ if (!headers || typeof headers !== "object") return {};
117
+ return Object.fromEntries(
118
+ Object.entries(headers).map(([k, v]) => [k.toLowerCase(), v])
119
+ );
120
+ }
121
+ hideSensitive(obj, keysToHide = [], isObjHeaders = true) {
122
+ if (!obj || typeof obj !== "object") {
123
+ return isObjHeaders ? {} : obj;
124
+ }
125
+ const clone = { ...obj };
126
+ for (const key of keysToHide) {
127
+ if (key in clone) {
128
+ clone[key] = "*******";
129
+ }
130
+ }
131
+ return clone;
92
132
  }
93
133
  };
@@ -2,9 +2,20 @@ import Watcher from '../core/watcher.cjs';
2
2
  import { WatcherTypeEnum, RequestEntry } from '../types/index.cjs';
3
3
  import 'sql-formatter';
4
4
 
5
+ type HiddenFields = {
6
+ headers?: string[];
7
+ bodyParams?: string[];
8
+ };
5
9
  declare class RequestWatcher extends Watcher {
6
10
  name: WatcherTypeEnum;
7
- log(data: RequestEntry): Promise<void>;
11
+ private static readonly DEFAULT_HIDDEN_HEADERS;
12
+ private static readonly DEFAULT_HIDDEN_BODY_PARAMS;
13
+ log(data: RequestEntry, hidden?: HiddenFields): Promise<void>;
14
+ /**
15
+ * Normalize headers: converts keys to lowercase.
16
+ */
17
+ protected normalizeHeaders(headers?: Record<string, string>): Record<string, string>;
18
+ protected hideSensitive<T extends Record<string, any>>(obj?: T, keysToHide?: string[], isObjHeaders?: boolean): T;
8
19
  }
9
20
 
10
21
  export { RequestWatcher as default };
@@ -2,9 +2,20 @@ import Watcher from '../core/watcher.js';
2
2
  import { WatcherTypeEnum, RequestEntry } from '../types/index.js';
3
3
  import 'sql-formatter';
4
4
 
5
+ type HiddenFields = {
6
+ headers?: string[];
7
+ bodyParams?: string[];
8
+ };
5
9
  declare class RequestWatcher extends Watcher {
6
10
  name: WatcherTypeEnum;
7
- log(data: RequestEntry): Promise<void>;
11
+ private static readonly DEFAULT_HIDDEN_HEADERS;
12
+ private static readonly DEFAULT_HIDDEN_BODY_PARAMS;
13
+ log(data: RequestEntry, hidden?: HiddenFields): Promise<void>;
14
+ /**
15
+ * Normalize headers: converts keys to lowercase.
16
+ */
17
+ protected normalizeHeaders(headers?: Record<string, string>): Record<string, string>;
18
+ protected hideSensitive<T extends Record<string, any>>(obj?: T, keysToHide?: string[], isObjHeaders?: boolean): T;
8
19
  }
9
20
 
10
21
  export { RequestWatcher as default };
@@ -43,10 +43,19 @@ var Watcher = class {
43
43
  };
44
44
 
45
45
  // src/watchers/request_watcher.ts
46
- var RequestWatcher = class extends Watcher {
46
+ var RequestWatcher = class _RequestWatcher extends Watcher {
47
47
  name = "request" /* REQUEST */;
48
- async log(data) {
49
- await getStore().save({
48
+ static DEFAULT_HIDDEN_HEADERS = ["Authorization", "Basic"];
49
+ static DEFAULT_HIDDEN_BODY_PARAMS = [
50
+ "password",
51
+ "passwordConfirmation",
52
+ "secret",
53
+ "password_confirmation"
54
+ ];
55
+ async log(data, hidden = {}) {
56
+ const headersToHide = (hidden.headers?.length ? hidden.headers : _RequestWatcher.DEFAULT_HIDDEN_HEADERS).map((header) => header.toLowerCase());
57
+ const bodyParamsToHide = hidden.bodyParams?.length ? hidden.bodyParams : _RequestWatcher.DEFAULT_HIDDEN_BODY_PARAMS;
58
+ const payload = {
50
59
  id: data.request.id,
51
60
  type: this.name,
52
61
  minimal_data: {
@@ -60,9 +69,40 @@ var RequestWatcher = class extends Watcher {
60
69
  data: {
61
70
  ...data.request,
62
71
  user: data.user,
63
- response: data.response
72
+ response: data.response || {}
64
73
  }
65
- });
74
+ };
75
+ payload.data.headers = this.hideSensitive(
76
+ this.normalizeHeaders(payload.data.headers),
77
+ headersToHide
78
+ );
79
+ payload.data.response.headers = this.hideSensitive(
80
+ this.normalizeHeaders(payload.data.response?.headers),
81
+ headersToHide
82
+ );
83
+ payload.data.body = this.hideSensitive(payload.data.body, bodyParamsToHide, false);
84
+ await getStore().save(payload);
85
+ }
86
+ /**
87
+ * Normalize headers: converts keys to lowercase.
88
+ */
89
+ normalizeHeaders(headers) {
90
+ if (!headers || typeof headers !== "object") return {};
91
+ return Object.fromEntries(
92
+ Object.entries(headers).map(([k, v]) => [k.toLowerCase(), v])
93
+ );
94
+ }
95
+ hideSensitive(obj, keysToHide = [], isObjHeaders = true) {
96
+ if (!obj || typeof obj !== "object") {
97
+ return isObjHeaders ? {} : obj;
98
+ }
99
+ const clone = { ...obj };
100
+ for (const key of keysToHide) {
101
+ if (key in clone) {
102
+ clone[key] = "*******";
103
+ }
104
+ }
105
+ return clone;
66
106
  }
67
107
  };
68
108
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensjs/core",
3
- "version": "2.2.1",
3
+ "version": "2.3.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -25,6 +25,7 @@
25
25
  "@lensjs/typescript-config": "1.0.12"
26
26
  },
27
27
  "dependencies": {
28
+ "denque": "^2.1.0",
28
29
  "libsql": "^0.5.22",
29
30
  "luxon": "^3.7.2",
30
31
  "rimraf": "^6.0.1",
@@ -1 +0,0 @@
1
- import{j as a}from"./index-CQJv-KV7.js";import{L as s}from"./LoadMore-CosGy1fp.js";import{T as t}from"./Table-z_QSS7J8.js";import{g as r}from"./columns-DJaOm2Yg.js";import"./index-BRRKsoNv.js";import"./CacheActionBadge-WGVr5yhe.js";const p=({hasMoreObject:o})=>a.jsxs("div",{className:"w-full",children:[a.jsx("div",{className:"overflow-x-auto",children:a.jsx(t,{columns:r(),data:o.data})}),a.jsx(s,{paginatedPage:o})]});export{p as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CacheEntriesTable-txREHfFk.js","./index-CQJv-KV7.js","./index-B2QCOgug.css","./LoadMore-CosGy1fp.js","./Table-z_QSS7J8.js","./columns-DJaOm2Yg.js","./index-BRRKsoNv.js","./CacheActionBadge-WGVr5yhe.js"])))=>i.map(i=>d[i]);
2
- import{r as t,j as a,_ as s}from"./index-CQJv-KV7.js";import{u as i}from"./useLoadMore-ClIkZ0Gw.js";import{u as m}from"./useCacheEntries-DWzLAzvE.js";import"./useLensApi-BEMg_OuP.js";const n=t.lazy(()=>s(()=>import("./CacheEntriesTable-txREHfFk.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url)),_=()=>{const{loadMoreItems:e,getItems:r}=m(),o=i({paginatedPage:e});return t.useEffect(()=>{r()},[]),a.jsx(n,{hasMoreObject:o})};export{_ as default};
@@ -1 +0,0 @@
1
- import{j as a,L as s,q as i,k as r}from"./index-CQJv-KV7.js";import{D as n,T as o,J as u}from"./TabbedDataViewer-CbZANxvH.js";import{C as d}from"./CacheActionBadge-WGVr5yhe.js";function y({data:e}){const t=[e.lens_entry_id?{label:"Request",value:a.jsx(s,{to:`${i(r()).REQUESTS}/${e.lens_entry_id}`,className:"text-blue-600 hover:underline font-semibold",children:"View Request"}),className:"text-gray-900 dark:text-gray-100"}:null,{label:"Operation",value:a.jsx(d,{action:e.data.action}),className:"text-gray-900 dark:text-gray-100"},e.data.data.key?{label:"Key",value:e.data.data.key??"__",className:"text-gray-900 dark:text-gray-100"}:null].filter(l=>!!l);return a.jsxs("div",{className:"flex flex-col gap-4",children:[a.jsx(n,{title:"Details",items:t}),a.jsx(o,{tabs:[{id:"value",label:"Value",shouldShow:!!e.data.data.value,content:a.jsx(u,{data:e.data.data.value})}],defaultActiveTab:"value"})]})}export{y as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CacheEntryDetails-DovbpPae.js","./index-CQJv-KV7.js","./index-B2QCOgug.css","./TabbedDataViewer-CbZANxvH.js","./CacheActionBadge-WGVr5yhe.js"])))=>i.map(i=>d[i]);
2
- import{m as o,r as s,j as r,_ as i}from"./index-CQJv-KV7.js";import{u as m}from"./useCacheEntries-DWzLAzvE.js";import"./useLensApi-BEMg_OuP.js";const n=s.lazy(()=>i(()=>import("./CacheEntryDetails-DovbpPae.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url)),E=()=>{const{item:e,getItem:a}=m(),{id:t}=o();return s.useEffect(()=>{t&&a(t)},[t]),r.jsx("div",{children:e&&r.jsx(n,{data:e})})};export{E as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ExceptionTable-Chiah5kT.js","./index-CQJv-KV7.js","./index-B2QCOgug.css","./LoadMore-CosGy1fp.js","./Table-z_QSS7J8.js","./columns-Bxz-DZCj.js","./index-BRRKsoNv.js"])))=>i.map(i=>d[i]);
2
- import{r as t,j as s,_ as a}from"./index-CQJv-KV7.js";import{u as i}from"./useLoadMore-ClIkZ0Gw.js";import{u as m}from"./useExceptions-BF0fHNek.js";import"./useLensApi-BEMg_OuP.js";const n=t.lazy(()=>a(()=>import("./ExceptionTable-Chiah5kT.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url)),_=()=>{const{loadMoreItems:e,getItems:o}=m(),r=i({paginatedPage:e});return t.useEffect(()=>{o()},[]),s.jsx(n,{hasMoreObject:r})};export{_ as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ExceptionDetails-DX14YGmx.js","./index-CQJv-KV7.js","./index-B2QCOgug.css","./TabbedDataViewer-CbZANxvH.js"])))=>i.map(i=>d[i]);
2
- import{m as a,r as s,j as r,_ as i}from"./index-CQJv-KV7.js";import{u as m}from"./useExceptions-BF0fHNek.js";import"./useLensApi-BEMg_OuP.js";const n=s.lazy(()=>i(()=>import("./ExceptionDetails-DX14YGmx.js"),__vite__mapDeps([0,1,2,3]),import.meta.url)),x=()=>{const{item:e,getItem:o}=m(),{id:t}=a();return s.useEffect(()=>{t&&o(t)},[t]),r.jsx("div",{children:e&&r.jsx(n,{data:e})})};export{x as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./QueryTable-BLpmWt7g.js","./index-CQJv-KV7.js","./index-B2QCOgug.css","./LoadMore-CosGy1fp.js","./Table-z_QSS7J8.js","./columns-D0UC1pqC.js","./index-BRRKsoNv.js"])))=>i.map(i=>d[i]);
2
- import{r as e,j as s,_ as a}from"./index-CQJv-KV7.js";import{u as i}from"./useQueries-C0vKfgzw.js";import{u}from"./useLoadMore-ClIkZ0Gw.js";import"./useLensApi-BEMg_OuP.js";const m=e.lazy(()=>a(()=>import("./QueryTable-BLpmWt7g.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url)),f=()=>{const{loadMoreRequests:r,fetchQueries:t}=i(),o=u({paginatedPage:r});return e.useEffect(()=>{t()},[]),s.jsx(m,{hasMoreObject:o})};export{f as default};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-CQJv-KV7.js";function g({method:e}){const t={GET:"bg-gray-100 text-gray-800 dark:bg-gray-600 dark:text-white",POST:"bg-blue-100 text-blue-800 dark:bg-blue-600 dark:text-white",PUT:"bg-yellow-100 text-yellow-800 dark:bg-yellow-600 dark:text-white",DELETE:"bg-red-100 text-red-800 dark:bg-red-600 dark:text-white"};return r.jsx("span",{className:`rounded px-2 py-1 text-sm font-semibold ${t[e.toUpperCase()]||"bg-gray-100 text-gray-800 dark:bg-gray-600 dark:text-white"}`,children:e})}const d=e=>e>=200&&e<300?"bg-green-100 text-green-800 dark:bg-green-700 dark:text-green-100":e>=300&&e<400?"bg-blue-100 text-blue-800 dark:bg-blue-700 dark:text-blue-100":e>=400&&e<500?"bg-yellow-100 text-yellow-800 dark:bg-yellow-700 dark:text-yellow-100":e>=500?"bg-red-100 text-red-800 dark:bg-red-700 dark:text-red-100":"bg-gray-100 text-gray-800 dark:bg-neutral-700 dark:text-neutral-200",l=({status:e})=>r.jsx("span",{className:`rounded-lg px-2 py-1 text-sm font-semibold ${d(e)}`,children:e});export{g as R,l as S};