@lensjs/core 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abstracts/adapter.cjs +8 -0
- package/dist/abstracts/adapter.d.cts +19 -0
- package/dist/abstracts/adapter.d.ts +19 -0
- package/dist/abstracts/adapter.js +8 -0
- package/dist/abstracts/store.cjs +7 -0
- package/dist/abstracts/store.d.cts +23 -0
- package/dist/abstracts/store.d.ts +23 -0
- package/dist/abstracts/store.js +7 -0
- package/dist/chunk-2HRVJRKV.cjs +10 -0
- package/dist/chunk-3R5QARPT.cjs +14 -0
- package/{src/watchers/request_watcher.ts → dist/chunk-4HLDYZJA.js} +18 -11
- package/dist/chunk-5PYQWLAZ.js +129 -0
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/chunk-7EKM5HB5.cjs +1 -0
- package/dist/chunk-AUDSBNLF.cjs +122 -0
- package/dist/chunk-BFFOUTTE.cjs +32 -0
- package/dist/chunk-BL4Z6JFH.cjs +34 -0
- package/dist/chunk-CQ2Z4TCR.js +7 -0
- package/dist/chunk-EHOWCXZV.cjs +7 -0
- package/{src/utils/index.ts → dist/chunk-EJ5BW35V.js} +69 -86
- package/dist/chunk-EKG3FVLV.cjs +7 -0
- package/dist/chunk-FCMQ3WE3.cjs +129 -0
- package/dist/chunk-FKMBNWX4.js +7 -0
- package/dist/chunk-FLOVBBFU.js +10 -0
- package/dist/chunk-GI7SJDNQ.cjs +38 -0
- package/dist/chunk-IPMTMCFP.js +122 -0
- package/dist/chunk-JZ2JLQXL.cjs +87 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-QRZUNYF6.cjs +16 -0
- package/dist/chunk-RMZ4UAQ2.js +14 -0
- package/dist/chunk-SJXZARBJ.cjs +22 -0
- package/dist/chunk-TJDE6AZM.js +87 -0
- package/dist/chunk-TPUVRGYT.js +32 -0
- package/dist/chunk-UF5HFNMI.js +22 -0
- package/dist/chunk-VD5IMUWL.js +0 -0
- package/dist/chunk-WU6IZUEV.cjs +159 -0
- package/dist/chunk-XXYRWHSQ.js +0 -0
- package/dist/chunk-XYXPHWEI.js +16 -0
- package/dist/chunk-XZFXXD3A.cjs +1 -0
- package/dist/chunk-YC6T4XWI.js +38 -0
- package/dist/context/container.cjs +7 -0
- package/dist/context/container.d.cts +28 -0
- package/dist/context/container.d.ts +28 -0
- package/dist/context/container.js +7 -0
- package/dist/context/context.cjs +10 -0
- package/dist/context/context.d.cts +15 -0
- package/dist/context/context.d.ts +15 -0
- package/dist/context/context.js +10 -0
- package/dist/core/api_controller.cjs +10 -0
- package/dist/core/api_controller.d.cts +25 -0
- package/dist/core/api_controller.d.ts +25 -0
- package/dist/core/api_controller.js +10 -0
- package/dist/core/lens.cjs +15 -0
- package/dist/core/lens.d.cts +24 -0
- package/dist/core/lens.d.ts +24 -0
- package/dist/core/lens.js +15 -0
- package/dist/core/watcher.cjs +7 -0
- package/dist/core/watcher.d.cts +9 -0
- package/dist/core/watcher.d.ts +9 -0
- package/dist/core/watcher.js +7 -0
- package/dist/index-D0Vszdac.d.cts +49 -0
- package/dist/index-D0Vszdac.d.ts +49 -0
- package/dist/index.cjs +55 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +55 -0
- package/dist/stores/better_sqlite.cjs +10 -0
- package/dist/stores/better_sqlite.d.cts +51 -0
- package/dist/stores/better_sqlite.d.ts +51 -0
- package/dist/stores/better_sqlite.js +10 -0
- package/dist/stores/index.cjs +11 -0
- package/dist/stores/index.d.cts +5 -0
- package/dist/stores/index.d.ts +5 -0
- package/dist/stores/index.js +11 -0
- package/dist/types/index.cjs +7 -0
- package/dist/types/index.d.cts +91 -0
- package/dist/types/index.d.ts +91 -0
- package/dist/types/index.js +7 -0
- package/dist/ui/assets/QueriesContainer-Bxr99HkT.js +2 -0
- package/dist/ui/assets/QueryDetailsContainer-BcbxQyxT.js +48 -0
- package/dist/ui/assets/QueryTable-Dx1MyXwe.js +1 -0
- package/dist/ui/assets/RequestDetails-B9rQn1tY.js +1 -0
- package/dist/ui/assets/RequestDetailsContainer-C0sOvaO2.js +2 -0
- package/dist/ui/assets/RequestsContainer-DYNNLt6S.js +2 -0
- package/dist/ui/assets/RequetsTable-BN-1fud-.js +1 -0
- package/dist/ui/assets/StatusCode-ByIHR7Pe.js +1 -0
- package/dist/ui/assets/TabbedDataViewer-CoLeLuBm.js +1 -0
- package/dist/ui/assets/Table-CXg4Wfwf.js +6 -0
- package/dist/ui/assets/date-BXZFS9Wq.js +1 -0
- package/dist/ui/assets/index-BPTSPdZM.css +1 -0
- package/dist/ui/assets/index-C3XpMOuU.js +114 -0
- package/dist/ui/assets/useLensApi-BlL4RwJa.js +1 -0
- package/dist/ui/assets/useLoadMore-BqF649Mm.js +1 -0
- package/dist/ui/assets/useQueries-Iwl8o-Xk.js +1 -0
- package/dist/ui/favicon.ico +0 -0
- package/dist/ui/index.html +14 -0
- package/dist/utils/event_emitter.cjs +11 -0
- package/dist/utils/event_emitter.d.cts +16 -0
- package/dist/utils/event_emitter.d.ts +16 -0
- package/dist/utils/event_emitter.js +11 -0
- package/dist/utils/index.cjs +31 -0
- package/dist/utils/index.d.cts +3 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +31 -0
- package/dist/watchers/index.cjs +16 -0
- package/dist/watchers/index.d.cts +5 -0
- package/dist/watchers/index.d.ts +5 -0
- package/dist/watchers/index.js +16 -0
- package/dist/watchers/query_watcher.cjs +11 -0
- package/dist/watchers/query_watcher.d.cts +10 -0
- package/dist/watchers/query_watcher.d.ts +10 -0
- package/dist/watchers/query_watcher.js +11 -0
- package/dist/watchers/request_watcher.cjs +11 -0
- package/dist/watchers/request_watcher.d.cts +10 -0
- package/dist/watchers/request_watcher.d.ts +10 -0
- package/dist/watchers/request_watcher.js +11 -0
- package/package.json +4 -1
- package/copy-front-build.cjs +0 -16
- package/src/abstracts/adapter.ts +0 -41
- package/src/abstracts/store.ts +0 -36
- package/src/context/container.ts +0 -67
- package/src/context/context.ts +0 -9
- package/src/core/api_controller.ts +0 -116
- package/src/core/lens.ts +0 -147
- package/src/core/watcher.ts +0 -6
- package/src/index.ts +0 -11
- package/src/stores/better_sqlite.ts +0 -176
- package/src/stores/index.ts +0 -1
- package/src/types/index.ts +0 -103
- package/src/ui/README.md +0 -69
- package/src/ui/bun.lock +0 -750
- package/src/ui/eslint.config.js +0 -27
- package/src/ui/index.html +0 -13
- package/src/ui/package-lock.json +0 -2953
- package/src/ui/package.json +0 -40
- package/src/ui/src/App.tsx +0 -40
- package/src/ui/src/components/DetailPanel.tsx +0 -70
- package/src/ui/src/components/JsonViewer.tsx +0 -232
- package/src/ui/src/components/LoadMore.tsx +0 -25
- package/src/ui/src/components/MethodBadge.tsx +0 -19
- package/src/ui/src/components/Modal.tsx +0 -48
- package/src/ui/src/components/StatusCode.tsx +0 -20
- package/src/ui/src/components/Table.tsx +0 -127
- package/src/ui/src/components/layout/DeleteButton.tsx +0 -60
- package/src/ui/src/components/layout/Footer.tsx +0 -12
- package/src/ui/src/components/layout/Header.tsx +0 -40
- package/src/ui/src/components/layout/Layout.tsx +0 -49
- package/src/ui/src/components/layout/LoadingScreen.tsx +0 -14
- package/src/ui/src/components/layout/Sidebar.tsx +0 -67
- package/src/ui/src/components/queryFormatters/MongoViewer.tsx +0 -92
- package/src/ui/src/components/queryFormatters/QueryViewer.tsx +0 -18
- package/src/ui/src/components/queryFormatters/SqlViewer.tsx +0 -105
- package/src/ui/src/components/table/NoData.tsx +0 -26
- package/src/ui/src/components/tabs/TabbedDataViewer.tsx +0 -77
- package/src/ui/src/containers/queries/QueriesContainer.tsx +0 -21
- package/src/ui/src/containers/queries/QueryDetailsContainer.tsx +0 -15
- package/src/ui/src/containers/requests/RequestDetailsContainer.tsx +0 -16
- package/src/ui/src/containers/requests/RequestsContainer.tsx +0 -22
- package/src/ui/src/hooks/useLensApi.ts +0 -92
- package/src/ui/src/hooks/useLoadMore.ts +0 -48
- package/src/ui/src/hooks/useQueries.ts +0 -58
- package/src/ui/src/hooks/useRequests.ts +0 -79
- package/src/ui/src/hooks/useTanstackApi.ts +0 -126
- package/src/ui/src/index.css +0 -78
- package/src/ui/src/interfaces/index.ts +0 -10
- package/src/ui/src/main.tsx +0 -33
- package/src/ui/src/router/Router.ts +0 -11
- package/src/ui/src/router/routes/Loading.tsx +0 -5
- package/src/ui/src/router/routes/index.tsx +0 -85
- package/src/ui/src/types/index.ts +0 -95
- package/src/ui/src/utils/api.ts +0 -7
- package/src/ui/src/utils/context.ts +0 -24
- package/src/ui/src/utils/date.ts +0 -36
- package/src/ui/src/views/queries/QueryDetails.tsx +0 -58
- package/src/ui/src/views/queries/QueryTable.tsx +0 -21
- package/src/ui/src/views/queries/columns.tsx +0 -83
- package/src/ui/src/views/requests/BasicRequestDetails.tsx +0 -82
- package/src/ui/src/views/requests/RequestDetails.tsx +0 -70
- package/src/ui/src/views/requests/RequetsTable.tsx +0 -19
- package/src/ui/src/views/requests/columns.tsx +0 -62
- package/src/ui/src/vite-env.d.ts +0 -1
- package/src/ui/tsconfig.app.json +0 -27
- package/src/ui/tsconfig.json +0 -7
- package/src/ui/tsconfig.node.json +0 -25
- package/src/ui/vite.config.ts +0 -9
- package/src/utils/event_emitter.ts +0 -13
- package/src/watchers/index.ts +0 -2
- package/src/watchers/query_watcher.ts +0 -15
- package/tests/core/lens.test.ts +0 -89
- package/tests/stores/better_sqlite.test.ts +0 -168
- package/tests/utils/index.test.ts +0 -182
- package/tests/watchers/query_watcher.test.ts +0 -35
- package/tests/watchers/request_watcher.test.ts +0 -59
- package/tsconfig.json +0 -3
- package/tsup.config.ts +0 -15
- package/vitest.config.ts +0 -9
- /package/{src/ui/public/favicon.ico → dist/ui/assets/favicon-D0UnoCWN.ico} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as g,l as n}from"./index-C3XpMOuU.js";const h={currentPage:1,lastPage:1,total:0},q=()=>{const r=g();async function s(e,a){const t=await fetch(e,{headers:{"Content-Type":"application/json"},...a});if(!t.ok)throw new Error(`Failed to fetch: ${e}`);return t.json()}const i=(e,a)=>{const t=new URLSearchParams(Object.entries(a||{}).reduce((u,[c,o])=>(o!=null&&(u[c]=String(o)),u),{}));return`${e}${t.toString()?`?${t}`:""}`};return{getAllRequests:async e=>s(n(i(r.api.requests,{page:e}))),getRequestById:async e=>s(n(`${r.api.requests}/${e}`)),getQueries:async e=>s(n(i(r.api.queries,{page:e}))),getQueryById:async e=>s(n(`${r.api.queries}/${e}`))}};export{h as D,q as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./index-C3XpMOuU.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./index-C3XpMOuU.js";import{D as Q,u as g}from"./useLensApi-BlL4RwJa.js";function q(){const[u,c]=e.useState([]),[i,l]=e.useState(),[n,a]=e.useState(!1),[r,f]=e.useState(Q),{getQueries:t,getQueryById:y}=g(),d=e.useCallback(async o=>{a(!0),y(o).then(s=>{console.log(s,"das2s"),l(s.data)}).finally(()=>{a(!1)})},[t]),m=e.useCallback(async o=>{a(!0),await t(o??1).then(s=>{c(s.data),f(s.meta)}).finally(()=>{a(!1)})},[t]);return{loadMoreRequests:e.useMemo(()=>({initialData:u,meta:r,loading:n,fetchRawPage:t}),[u,r,n,t]),fetchQueries:m,fetchQuery:d,queries:u,query:i}}export{q as u};
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="./assets/favicon-D0UnoCWN.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Lens</title>
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-C3XpMOuU.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="./assets/index-BPTSPdZM.css">
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="root"></div>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunk3R5QARPTcjs = require('../chunk-3R5QARPT.cjs');
|
|
6
|
+
require('../chunk-75ZPJI57.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.createEmittery = _chunk3R5QARPTcjs.createEmittery; exports.lensEmitter = _chunk3R5QARPTcjs.lensEmitter; exports.lensResource = _chunk3R5QARPTcjs.lensResource;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as emittery from 'emittery';
|
|
2
|
+
import emittery__default from 'emittery';
|
|
3
|
+
import { AsyncResource } from 'node:async_hooks';
|
|
4
|
+
import { QueryEntry } from '../types/index.cjs';
|
|
5
|
+
import 'sql-formatter';
|
|
6
|
+
|
|
7
|
+
interface CoreEvents {
|
|
8
|
+
query: {
|
|
9
|
+
query: QueryEntry["data"];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
declare const createEmittery: <T extends Record<string, any>>() => emittery__default<T, T & emittery.OmnipresentEventData, emittery.DatalessEventNames<T>>;
|
|
13
|
+
declare const lensResource: AsyncResource;
|
|
14
|
+
declare const lensEmitter: emittery__default<CoreEvents, CoreEvents & emittery.OmnipresentEventData, never>;
|
|
15
|
+
|
|
16
|
+
export { createEmittery, lensEmitter, lensResource };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as emittery from 'emittery';
|
|
2
|
+
import emittery__default from 'emittery';
|
|
3
|
+
import { AsyncResource } from 'node:async_hooks';
|
|
4
|
+
import { QueryEntry } from '../types/index.js';
|
|
5
|
+
import 'sql-formatter';
|
|
6
|
+
|
|
7
|
+
interface CoreEvents {
|
|
8
|
+
query: {
|
|
9
|
+
query: QueryEntry["data"];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
declare const createEmittery: <T extends Record<string, any>>() => emittery__default<T, T & emittery.OmnipresentEventData, emittery.DatalessEventNames<T>>;
|
|
13
|
+
declare const lensResource: AsyncResource;
|
|
14
|
+
declare const lensEmitter: emittery__default<CoreEvents, CoreEvents & emittery.OmnipresentEventData, never>;
|
|
15
|
+
|
|
16
|
+
export { createEmittery, lensEmitter, lensResource };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _chunkWU6IZUEVcjs = require('../chunk-WU6IZUEV.cjs');
|
|
16
|
+
require('../chunk-75ZPJI57.cjs');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
exports.convertToUTC = _chunkWU6IZUEVcjs.convertToUTC; exports.formatSqlQuery = _chunkWU6IZUEVcjs.formatSqlQuery; exports.generateRandomUuid = _chunkWU6IZUEVcjs.generateRandomUuid; exports.getMeta = _chunkWU6IZUEVcjs.getMeta; exports.interpolateQuery = _chunkWU6IZUEVcjs.interpolateQuery; exports.isStaticFile = _chunkWU6IZUEVcjs.isStaticFile; exports.now = _chunkWU6IZUEVcjs.now; exports.nowISO = _chunkWU6IZUEVcjs.nowISO; exports.prepareIgnoredPaths = _chunkWU6IZUEVcjs.prepareIgnoredPaths; exports.prettyHrTime = _chunkWU6IZUEVcjs.prettyHrTime; exports.shouldIgnoreCurrentPath = _chunkWU6IZUEVcjs.shouldIgnoreCurrentPath; exports.sqlDateTime = _chunkWU6IZUEVcjs.sqlDateTime; exports.stripBeforeAssetsPath = _chunkWU6IZUEVcjs.stripBeforeAssetsPath;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import 'luxon';
|
|
2
|
+
import 'sql-formatter';
|
|
3
|
+
export { c as convertToUTC, f as formatSqlQuery, g as generateRandomUuid, d as getMeta, a as interpolateQuery, e as isStaticFile, n as now, b as nowISO, p as prepareIgnoredPaths, k as prettyHrTime, j as shouldIgnoreCurrentPath, s as sqlDateTime, h as stripBeforeAssetsPath } from '../index-D0Vszdac.cjs';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import 'luxon';
|
|
2
|
+
import 'sql-formatter';
|
|
3
|
+
export { c as convertToUTC, f as formatSqlQuery, g as generateRandomUuid, d as getMeta, a as interpolateQuery, e as isStaticFile, n as now, b as nowISO, p as prepareIgnoredPaths, k as prettyHrTime, j as shouldIgnoreCurrentPath, s as sqlDateTime, h as stripBeforeAssetsPath } from '../index-D0Vszdac.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
convertToUTC,
|
|
3
|
+
formatSqlQuery,
|
|
4
|
+
generateRandomUuid,
|
|
5
|
+
getMeta,
|
|
6
|
+
interpolateQuery,
|
|
7
|
+
isStaticFile,
|
|
8
|
+
now,
|
|
9
|
+
nowISO,
|
|
10
|
+
prepareIgnoredPaths,
|
|
11
|
+
prettyHrTime,
|
|
12
|
+
shouldIgnoreCurrentPath,
|
|
13
|
+
sqlDateTime,
|
|
14
|
+
stripBeforeAssetsPath
|
|
15
|
+
} from "../chunk-EJ5BW35V.js";
|
|
16
|
+
import "../chunk-MLKGABMK.js";
|
|
17
|
+
export {
|
|
18
|
+
convertToUTC,
|
|
19
|
+
formatSqlQuery,
|
|
20
|
+
generateRandomUuid,
|
|
21
|
+
getMeta,
|
|
22
|
+
interpolateQuery,
|
|
23
|
+
isStaticFile,
|
|
24
|
+
now,
|
|
25
|
+
nowISO,
|
|
26
|
+
prepareIgnoredPaths,
|
|
27
|
+
prettyHrTime,
|
|
28
|
+
shouldIgnoreCurrentPath,
|
|
29
|
+
sqlDateTime,
|
|
30
|
+
stripBeforeAssetsPath
|
|
31
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-7EKM5HB5.cjs');
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkSJXZARBJcjs = require('../chunk-SJXZARBJ.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkBL4Z6JFHcjs = require('../chunk-BL4Z6JFH.cjs');
|
|
8
|
+
require('../chunk-2HRVJRKV.cjs');
|
|
9
|
+
require('../chunk-QRZUNYF6.cjs');
|
|
10
|
+
require('../chunk-GI7SJDNQ.cjs');
|
|
11
|
+
require('../chunk-EKG3FVLV.cjs');
|
|
12
|
+
require('../chunk-75ZPJI57.cjs');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
exports.QueryWatcher = _chunkSJXZARBJcjs.QueryWatcher; exports.RequestWatcher = _chunkBL4Z6JFHcjs.RequestWatcher;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "../chunk-XXYRWHSQ.js";
|
|
2
|
+
import {
|
|
3
|
+
QueryWatcher
|
|
4
|
+
} from "../chunk-UF5HFNMI.js";
|
|
5
|
+
import {
|
|
6
|
+
RequestWatcher
|
|
7
|
+
} from "../chunk-4HLDYZJA.js";
|
|
8
|
+
import "../chunk-FLOVBBFU.js";
|
|
9
|
+
import "../chunk-XYXPHWEI.js";
|
|
10
|
+
import "../chunk-YC6T4XWI.js";
|
|
11
|
+
import "../chunk-CQ2Z4TCR.js";
|
|
12
|
+
import "../chunk-MLKGABMK.js";
|
|
13
|
+
export {
|
|
14
|
+
QueryWatcher,
|
|
15
|
+
RequestWatcher
|
|
16
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkSJXZARBJcjs = require('../chunk-SJXZARBJ.cjs');
|
|
4
|
+
require('../chunk-2HRVJRKV.cjs');
|
|
5
|
+
require('../chunk-QRZUNYF6.cjs');
|
|
6
|
+
require('../chunk-GI7SJDNQ.cjs');
|
|
7
|
+
require('../chunk-EKG3FVLV.cjs');
|
|
8
|
+
require('../chunk-75ZPJI57.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.default = _chunkSJXZARBJcjs.QueryWatcher;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Watcher from '../core/watcher.cjs';
|
|
2
|
+
import { WatcherTypeEnum, QueryEntry } from '../types/index.cjs';
|
|
3
|
+
import 'sql-formatter';
|
|
4
|
+
|
|
5
|
+
declare class QueryWatcher extends Watcher {
|
|
6
|
+
name: WatcherTypeEnum;
|
|
7
|
+
log(entry: QueryEntry): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { QueryWatcher as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Watcher from '../core/watcher.js';
|
|
2
|
+
import { WatcherTypeEnum, QueryEntry } from '../types/index.js';
|
|
3
|
+
import 'sql-formatter';
|
|
4
|
+
|
|
5
|
+
declare class QueryWatcher extends Watcher {
|
|
6
|
+
name: WatcherTypeEnum;
|
|
7
|
+
log(entry: QueryEntry): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { QueryWatcher as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
QueryWatcher
|
|
3
|
+
} from "../chunk-UF5HFNMI.js";
|
|
4
|
+
import "../chunk-FLOVBBFU.js";
|
|
5
|
+
import "../chunk-XYXPHWEI.js";
|
|
6
|
+
import "../chunk-YC6T4XWI.js";
|
|
7
|
+
import "../chunk-CQ2Z4TCR.js";
|
|
8
|
+
import "../chunk-MLKGABMK.js";
|
|
9
|
+
export {
|
|
10
|
+
QueryWatcher as default
|
|
11
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkBL4Z6JFHcjs = require('../chunk-BL4Z6JFH.cjs');
|
|
4
|
+
require('../chunk-2HRVJRKV.cjs');
|
|
5
|
+
require('../chunk-QRZUNYF6.cjs');
|
|
6
|
+
require('../chunk-GI7SJDNQ.cjs');
|
|
7
|
+
require('../chunk-EKG3FVLV.cjs');
|
|
8
|
+
require('../chunk-75ZPJI57.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.default = _chunkBL4Z6JFHcjs.RequestWatcher;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Watcher from '../core/watcher.cjs';
|
|
2
|
+
import { WatcherTypeEnum, RequestEntry } from '../types/index.cjs';
|
|
3
|
+
import 'sql-formatter';
|
|
4
|
+
|
|
5
|
+
declare class RequestWatcher extends Watcher {
|
|
6
|
+
name: WatcherTypeEnum;
|
|
7
|
+
log(data: RequestEntry): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { RequestWatcher as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Watcher from '../core/watcher.js';
|
|
2
|
+
import { WatcherTypeEnum, RequestEntry } from '../types/index.js';
|
|
3
|
+
import 'sql-formatter';
|
|
4
|
+
|
|
5
|
+
declare class RequestWatcher extends Watcher {
|
|
6
|
+
name: WatcherTypeEnum;
|
|
7
|
+
log(data: RequestEntry): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { RequestWatcher as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RequestWatcher
|
|
3
|
+
} from "../chunk-4HLDYZJA.js";
|
|
4
|
+
import "../chunk-FLOVBBFU.js";
|
|
5
|
+
import "../chunk-XYXPHWEI.js";
|
|
6
|
+
import "../chunk-YC6T4XWI.js";
|
|
7
|
+
import "../chunk-CQ2Z4TCR.js";
|
|
8
|
+
import "../chunk-MLKGABMK.js";
|
|
9
|
+
export {
|
|
10
|
+
RequestWatcher as default
|
|
11
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lensjs/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
14
17
|
"publishConfig": {
|
|
15
18
|
"access": "public"
|
|
16
19
|
},
|
package/copy-front-build.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const { execSync } = require("child_process");
|
|
2
|
-
const { platform } = require("os");
|
|
3
|
-
|
|
4
|
-
try {
|
|
5
|
-
if (platform() === "win32") {
|
|
6
|
-
console.log("Copying files for Windows...");
|
|
7
|
-
execSync('xcopy /E /I /Y "src/ui/dist" "dist/ui\\"', { stdio: "inherit" });
|
|
8
|
-
} else {
|
|
9
|
-
console.log("Copying files for Unix/Linux...");
|
|
10
|
-
execSync("cp -r src/ui/dist/ dist/ui --force", { stdio: "inherit" });
|
|
11
|
-
}
|
|
12
|
-
console.log("Files copied successfully!");
|
|
13
|
-
} catch (error) {
|
|
14
|
-
console.error("Error copying files:", error);
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
package/src/abstracts/adapter.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type Watcher from "../core/watcher";
|
|
2
|
-
import type { RouteDefinition } from "../types";
|
|
3
|
-
import { shouldIgnoreCurrentPath } from "../utils";
|
|
4
|
-
|
|
5
|
-
export default abstract class Adapter {
|
|
6
|
-
private watchers: Watcher[] = [];
|
|
7
|
-
protected ignoredPaths: RegExp[] = [];
|
|
8
|
-
protected onlyPaths: RegExp[] = [];
|
|
9
|
-
|
|
10
|
-
abstract setup(): void;
|
|
11
|
-
|
|
12
|
-
setWatchers(watchers: Watcher[]) {
|
|
13
|
-
this.watchers = watchers;
|
|
14
|
-
return this;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
setIgnoredPaths(paths: RegExp[]) {
|
|
18
|
-
this.ignoredPaths = paths;
|
|
19
|
-
return this;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
setOnlyPaths(paths: RegExp[]) {
|
|
23
|
-
this.onlyPaths = paths;
|
|
24
|
-
return this;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
getWatchers() {
|
|
28
|
-
return this.watchers;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
shouldIgnorePath(path: string) {
|
|
32
|
-
return shouldIgnoreCurrentPath(path, this.ignoredPaths, this.onlyPaths);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
abstract registerRoutes(routes: RouteDefinition[]): void;
|
|
36
|
-
abstract serveUI(
|
|
37
|
-
uiPath: string,
|
|
38
|
-
spaRoute: string,
|
|
39
|
-
dataToInject: Record<string, any>,
|
|
40
|
-
): void;
|
|
41
|
-
}
|
package/src/abstracts/store.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
PaginationParams,
|
|
3
|
-
Paginator,
|
|
4
|
-
LensEntry,
|
|
5
|
-
WatcherTypeEnum,
|
|
6
|
-
} from "../types";
|
|
7
|
-
|
|
8
|
-
export default abstract class Store {
|
|
9
|
-
abstract initialize(): Promise<void>;
|
|
10
|
-
abstract save(entry: {
|
|
11
|
-
id?: string;
|
|
12
|
-
data: Record<string, any>;
|
|
13
|
-
minimal_data?: Record<string, any>;
|
|
14
|
-
type: WatcherTypeEnum;
|
|
15
|
-
timestamp?: string;
|
|
16
|
-
requestId?: string;
|
|
17
|
-
}): Promise<void>;
|
|
18
|
-
abstract getAllRequests(
|
|
19
|
-
paginationParams: PaginationParams,
|
|
20
|
-
): Promise<Paginator<Omit<LensEntry, "data">[]>>;
|
|
21
|
-
abstract getAllQueries(
|
|
22
|
-
paginationParams: PaginationParams,
|
|
23
|
-
): Promise<Paginator<LensEntry[]>>;
|
|
24
|
-
abstract allByRequestId(
|
|
25
|
-
requestId: string,
|
|
26
|
-
type: WatcherTypeEnum,
|
|
27
|
-
): Promise<LensEntry[]>;
|
|
28
|
-
abstract find(type: WatcherTypeEnum, id: string): Promise<LensEntry|null>;
|
|
29
|
-
abstract truncate(): Promise<void>;
|
|
30
|
-
abstract paginate<T>(
|
|
31
|
-
type: WatcherTypeEnum,
|
|
32
|
-
pagination: PaginationParams,
|
|
33
|
-
): Promise<Paginator<T>>;
|
|
34
|
-
|
|
35
|
-
abstract count(type: WatcherTypeEnum): Promise<number>;
|
|
36
|
-
}
|
package/src/context/container.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type Store from "../abstracts/store";
|
|
2
|
-
|
|
3
|
-
type Factory<T = any> = () => T;
|
|
4
|
-
|
|
5
|
-
type ContextStore = {
|
|
6
|
-
store: Store;
|
|
7
|
-
uiConfig: {
|
|
8
|
-
appName: string;
|
|
9
|
-
path: string;
|
|
10
|
-
api: {
|
|
11
|
-
requests: string;
|
|
12
|
-
queries: string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default class Container {
|
|
18
|
-
private static bindings = new Map<keyof ContextStore, Factory>();
|
|
19
|
-
private static singletons = new Map<keyof ContextStore, Factory>();
|
|
20
|
-
private static instances = new Map<keyof ContextStore, any>();
|
|
21
|
-
|
|
22
|
-
static bind<K extends keyof ContextStore>(
|
|
23
|
-
key: K,
|
|
24
|
-
factory: Factory<ContextStore[K]>,
|
|
25
|
-
) {
|
|
26
|
-
this.bindings.set(key, factory);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static singleton<K extends keyof ContextStore>(
|
|
30
|
-
key: K,
|
|
31
|
-
factory: Factory<ContextStore[K]>,
|
|
32
|
-
) {
|
|
33
|
-
this.singletons.set(key, factory);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static make<K extends keyof ContextStore>(key: K): ContextStore[K] {
|
|
37
|
-
if (this.instances.has(key)) {
|
|
38
|
-
return this.instances.get(key);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (this.singletons.has(key)) {
|
|
42
|
-
const instance = this.singletons.get(key)!();
|
|
43
|
-
this.instances.set(key, instance);
|
|
44
|
-
return instance;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (this.bindings.has(key)) {
|
|
48
|
-
return this.bindings.get(key)!();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
throw new Error(`Service "${key}" is not bound in the container`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static has(key: keyof ContextStore): boolean {
|
|
55
|
-
return (
|
|
56
|
-
this.bindings.has(key) ||
|
|
57
|
-
this.singletons.has(key) ||
|
|
58
|
-
this.instances.has(key)
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
static clear(): void {
|
|
63
|
-
this.bindings.clear();
|
|
64
|
-
this.singletons.clear();
|
|
65
|
-
this.instances.clear();
|
|
66
|
-
}
|
|
67
|
-
}
|
package/src/context/context.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { getStore, getUiConfig } from "../context/context";
|
|
2
|
-
import { WatcherTypeEnum } from "../types";
|
|
3
|
-
import type {
|
|
4
|
-
ApiResponse,
|
|
5
|
-
LensEntry as LensEntry,
|
|
6
|
-
Paginator,
|
|
7
|
-
RouteDefinitionHandler,
|
|
8
|
-
} from "../types";
|
|
9
|
-
|
|
10
|
-
export class ApiController {
|
|
11
|
-
static async getRequests({ qs }: RouteDefinitionHandler) {
|
|
12
|
-
return this.paginatedResponse(
|
|
13
|
-
await getStore().getAllRequests(this.extractPaginationParams(qs)),
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static async getRequest({
|
|
18
|
-
params,
|
|
19
|
-
}: RouteDefinitionHandler): Promise<ApiResponse<LensEntry>> {
|
|
20
|
-
const request = await getStore().find(WatcherTypeEnum.REQUEST, params.id);
|
|
21
|
-
|
|
22
|
-
if (!request) {
|
|
23
|
-
return this.notFoundResponse();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return this.resourceResponse(request);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static async getQueries({
|
|
30
|
-
qs,
|
|
31
|
-
}: RouteDefinitionHandler): Promise<ApiResponse<LensEntry[]>> {
|
|
32
|
-
const queries = await getStore().getAllQueries(
|
|
33
|
-
this.extractPaginationParams(qs),
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return this.paginatedResponse(queries);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static async getQuery({
|
|
40
|
-
params,
|
|
41
|
-
}: RouteDefinitionHandler): Promise<ApiResponse<LensEntry>> {
|
|
42
|
-
const query = await getStore().find(WatcherTypeEnum.QUERY, params.id);
|
|
43
|
-
|
|
44
|
-
if (!query) {
|
|
45
|
-
return this.notFoundResponse();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return this.resourceResponse(query);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
static async truncate() {
|
|
52
|
-
await getStore().truncate();
|
|
53
|
-
|
|
54
|
-
return this.baseResponse({}, 200, "All entries cleared");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
static fetchUiConfig() {
|
|
58
|
-
return getUiConfig();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private static extractPaginationParams(qs?: Record<string, any>) {
|
|
62
|
-
if (!qs || Object.keys(qs).length === 0) {
|
|
63
|
-
return { page: 1, perPage: 100 };
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
let page = Number(qs.page);
|
|
67
|
-
let perPage = Number(qs.perPage);
|
|
68
|
-
|
|
69
|
-
if (!Number.isInteger(perPage) || perPage > 100 || perPage < 5) {
|
|
70
|
-
perPage = 100;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!Number.isInteger(page) || page < 1) {
|
|
74
|
-
page = 1;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return { page, perPage };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private static resourceResponse<T extends Object>(data: T): ApiResponse<T> {
|
|
81
|
-
return this.baseResponse<T>(data, 200, "Data fetched successfully");
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private static notFoundResponse<T extends Object>(
|
|
85
|
-
message = "Could not find the requested resource",
|
|
86
|
-
): ApiResponse<T> {
|
|
87
|
-
return this.baseResponse<T>(null, 404, message);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private static paginatedResponse<T extends Object>(
|
|
91
|
-
data: Paginator<T>,
|
|
92
|
-
): ApiResponse<T> {
|
|
93
|
-
return this.baseResponse<T>(data, 200, "Data fetched successfully");
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
private static baseResponse<T extends Object>(
|
|
97
|
-
data: Paginator<T> | T | null,
|
|
98
|
-
status: number,
|
|
99
|
-
message: string,
|
|
100
|
-
): ApiResponse<T> {
|
|
101
|
-
if (!data) {
|
|
102
|
-
return { status, message, data: null };
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if ("meta" in data) {
|
|
106
|
-
return {
|
|
107
|
-
status,
|
|
108
|
-
message,
|
|
109
|
-
data: data.data,
|
|
110
|
-
meta: data.meta,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return { status, message, data };
|
|
115
|
-
}
|
|
116
|
-
}
|