@lensjs/core 1.0.8 → 1.0.11
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 +70 -5
- package/dist/abstracts/adapter.js +37 -5
- package/dist/abstracts/store.cjs +26 -6
- package/dist/abstracts/store.js +3 -4
- package/dist/context/container.cjs +57 -6
- package/dist/context/container.js +34 -4
- package/dist/context/context.cjs +71 -7
- package/dist/context/context.js +42 -6
- package/dist/core/api_controller.cjs +148 -7
- package/dist/core/api_controller.js +121 -7
- package/dist/core/lens.cjs +404 -12
- package/dist/core/lens.js +370 -12
- package/dist/core/watcher.cjs +26 -6
- package/dist/core/watcher.js +3 -4
- package/dist/index.cjs +611 -51
- package/dist/index.js +556 -38
- package/dist/stores/better_sqlite.cjs +149 -6
- package/dist/stores/better_sqlite.js +116 -6
- package/dist/stores/index.cjs +153 -7
- package/dist/stores/index.js +116 -7
- package/dist/types/index.cjs +33 -6
- package/dist/types/index.js +6 -4
- package/dist/ui/assets/QueriesContainer-CAAsjjW5.js +2 -0
- package/dist/ui/assets/{QueryDetailsContainer-CtNxjUvF.js → QueryDetailsContainer-E7P-IO7f.js} +3 -3
- package/dist/ui/assets/{QueryTable-B6L0F5jL.js → QueryTable-BcrtUssT.js} +1 -1
- package/dist/ui/assets/{RequestDetails-BfxFQmp1.js → RequestDetails-C2DZBu5H.js} +1 -1
- package/dist/ui/assets/{RequestDetailsContainer-C0s7VLpw.js → RequestDetailsContainer-DuDo-IqS.js} +2 -2
- package/dist/ui/assets/{RequestsContainer-rWbSc4Py.js → RequestsContainer-DK3hQVz9.js} +2 -2
- package/dist/ui/assets/{RequetsTable-D2qBWqFN.js → RequetsTable-DgP8p60b.js} +1 -1
- package/dist/ui/assets/{StatusCode-BZGwjlgz.js → StatusCode-FQEjz7gK.js} +1 -1
- package/dist/ui/assets/{TabbedDataViewer-CmztxF70.js → TabbedDataViewer-cBDdPwIz.js} +1 -1
- package/dist/ui/assets/{Table-DF4sxTNg.js → Table-DYaXk80S.js} +2 -2
- package/dist/ui/assets/favicon-CwRXoGYE.ico +0 -0
- package/dist/ui/assets/{index-Dzy6B_ZD.js → index-BS8XxorB.js} +11 -11
- package/dist/ui/assets/{index-byVaIWe8.js → index-CpP2Ap5X.js} +1 -1
- package/dist/ui/assets/{useLensApi-CkgX8mtY.js → useLensApi-DG6atd6d.js} +1 -1
- package/dist/ui/assets/{useLoadMore-BRca6vvh.js → useLoadMore-CJltToLI.js} +1 -1
- package/dist/ui/assets/{useQueries-CVt1cLYV.js → useQueries-C8mDDDc6.js} +1 -1
- package/dist/ui/favicon.ico +0 -0
- package/dist/ui/index.html +2 -2
- package/dist/utils/event_emitter.cjs +42 -6
- package/dist/utils/event_emitter.js +5 -4
- package/dist/utils/index.cjs +163 -23
- package/dist/utils/index.js +109 -12
- package/dist/watchers/index.cjs +105 -10
- package/dist/watchers/index.js +79 -12
- package/dist/watchers/query_watcher.cjs +78 -8
- package/dist/watchers/query_watcher.js +55 -8
- package/dist/watchers/request_watcher.cjs +90 -8
- package/dist/watchers/request_watcher.js +67 -8
- package/package.json +3 -3
- package/dist/chunk-2HRVJRKV.cjs +0 -10
- package/dist/chunk-45JBO7ME.cjs +0 -120
- package/dist/chunk-4HLDYZJA.js +0 -34
- package/dist/chunk-66RDYK2I.js +0 -9
- package/dist/chunk-75ZPJI57.cjs +0 -9
- package/dist/chunk-7EKM5HB5.cjs +0 -1
- package/dist/chunk-7FBZAVQ3.cjs +0 -138
- package/dist/chunk-7MOTQS6N.cjs +0 -32
- package/dist/chunk-BL4Z6JFH.cjs +0 -34
- package/dist/chunk-CGPET47D.cjs +0 -129
- package/dist/chunk-CQ2Z4TCR.js +0 -7
- package/dist/chunk-EHOWCXZV.cjs +0 -7
- package/dist/chunk-EKG3FVLV.cjs +0 -7
- package/dist/chunk-FKMBNWX4.js +0 -7
- package/dist/chunk-FLOVBBFU.js +0 -10
- package/dist/chunk-GI7SJDNQ.cjs +0 -38
- package/dist/chunk-HLBMQ3ID.js +0 -120
- package/dist/chunk-HMBQ2DF7.js +0 -129
- package/dist/chunk-JTRKNE5Q.js +0 -32
- package/dist/chunk-JZ2JLQXL.cjs +0 -87
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/chunk-NUSVID2Q.cjs +0 -9
- package/dist/chunk-QRZUNYF6.cjs +0 -16
- package/dist/chunk-SJXZARBJ.cjs +0 -22
- package/dist/chunk-TJDE6AZM.js +0 -87
- package/dist/chunk-UF5HFNMI.js +0 -22
- package/dist/chunk-VD5IMUWL.js +0 -0
- package/dist/chunk-XXYRWHSQ.js +0 -0
- package/dist/chunk-XYXPHWEI.js +0 -16
- package/dist/chunk-XZFXXD3A.cjs +0 -1
- package/dist/chunk-YC6T4XWI.js +0 -38
- package/dist/chunk-YXSPADWE.js +0 -138
- package/dist/ui/assets/QueriesContainer-DhnU1ndx.js +0 -2
- package/dist/ui/assets/favicon-D0UnoCWN.ico +0 -0
package/dist/chunk-TJDE6AZM.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getStore,
|
|
3
|
-
getUiConfig
|
|
4
|
-
} from "./chunk-XYXPHWEI.js";
|
|
5
|
-
|
|
6
|
-
// src/core/api_controller.ts
|
|
7
|
-
var ApiController = class {
|
|
8
|
-
static async getRequests({ qs }) {
|
|
9
|
-
return this.paginatedResponse(
|
|
10
|
-
await getStore().getAllRequests(this.extractPaginationParams(qs))
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
static async getRequest({
|
|
14
|
-
params
|
|
15
|
-
}) {
|
|
16
|
-
const request = await getStore().find("request" /* REQUEST */, params.id);
|
|
17
|
-
if (!request) {
|
|
18
|
-
return this.notFoundResponse();
|
|
19
|
-
}
|
|
20
|
-
return this.resourceResponse(request);
|
|
21
|
-
}
|
|
22
|
-
static async getQueries({
|
|
23
|
-
qs
|
|
24
|
-
}) {
|
|
25
|
-
const queries = await getStore().getAllQueries(
|
|
26
|
-
this.extractPaginationParams(qs)
|
|
27
|
-
);
|
|
28
|
-
return this.paginatedResponse(queries);
|
|
29
|
-
}
|
|
30
|
-
static async getQuery({
|
|
31
|
-
params
|
|
32
|
-
}) {
|
|
33
|
-
const query = await getStore().find("query" /* QUERY */, params.id);
|
|
34
|
-
if (!query) {
|
|
35
|
-
return this.notFoundResponse();
|
|
36
|
-
}
|
|
37
|
-
return this.resourceResponse(query);
|
|
38
|
-
}
|
|
39
|
-
static async truncate() {
|
|
40
|
-
await getStore().truncate();
|
|
41
|
-
return this.baseResponse({}, 200, "All entries cleared");
|
|
42
|
-
}
|
|
43
|
-
static fetchUiConfig() {
|
|
44
|
-
return getUiConfig();
|
|
45
|
-
}
|
|
46
|
-
static extractPaginationParams(qs) {
|
|
47
|
-
if (!qs || Object.keys(qs).length === 0) {
|
|
48
|
-
return { page: 1, perPage: 100 };
|
|
49
|
-
}
|
|
50
|
-
let page = Number(qs.page);
|
|
51
|
-
let perPage = Number(qs.perPage);
|
|
52
|
-
if (!Number.isInteger(perPage) || perPage > 100 || perPage < 5) {
|
|
53
|
-
perPage = 100;
|
|
54
|
-
}
|
|
55
|
-
if (!Number.isInteger(page) || page < 1) {
|
|
56
|
-
page = 1;
|
|
57
|
-
}
|
|
58
|
-
return { page, perPage };
|
|
59
|
-
}
|
|
60
|
-
static resourceResponse(data) {
|
|
61
|
-
return this.baseResponse(data, 200, "Data fetched successfully");
|
|
62
|
-
}
|
|
63
|
-
static notFoundResponse(message = "Could not find the requested resource") {
|
|
64
|
-
return this.baseResponse(null, 404, message);
|
|
65
|
-
}
|
|
66
|
-
static paginatedResponse(data) {
|
|
67
|
-
return this.baseResponse(data, 200, "Data fetched successfully");
|
|
68
|
-
}
|
|
69
|
-
static baseResponse(data, status, message) {
|
|
70
|
-
if (!data) {
|
|
71
|
-
return { status, message, data: null };
|
|
72
|
-
}
|
|
73
|
-
if ("meta" in data) {
|
|
74
|
-
return {
|
|
75
|
-
status,
|
|
76
|
-
message,
|
|
77
|
-
data: data.data,
|
|
78
|
-
meta: data.meta
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
return { status, message, data };
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export {
|
|
86
|
-
ApiController
|
|
87
|
-
};
|
package/dist/chunk-UF5HFNMI.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getStore
|
|
3
|
-
} from "./chunk-XYXPHWEI.js";
|
|
4
|
-
import {
|
|
5
|
-
Watcher
|
|
6
|
-
} from "./chunk-CQ2Z4TCR.js";
|
|
7
|
-
|
|
8
|
-
// src/watchers/query_watcher.ts
|
|
9
|
-
var QueryWatcher = class extends Watcher {
|
|
10
|
-
name = "query" /* QUERY */;
|
|
11
|
-
async log(entry) {
|
|
12
|
-
await getStore().save({
|
|
13
|
-
type: this.name,
|
|
14
|
-
data: entry.data,
|
|
15
|
-
requestId: entry.requestId ?? ""
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
QueryWatcher
|
|
22
|
-
};
|
package/dist/chunk-VD5IMUWL.js
DELETED
|
File without changes
|
package/dist/chunk-XXYRWHSQ.js
DELETED
|
File without changes
|
package/dist/chunk-XYXPHWEI.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Container
|
|
3
|
-
} from "./chunk-YC6T4XWI.js";
|
|
4
|
-
|
|
5
|
-
// src/context/context.ts
|
|
6
|
-
var getStore = () => {
|
|
7
|
-
return Container.make("store");
|
|
8
|
-
};
|
|
9
|
-
var getUiConfig = () => {
|
|
10
|
-
return Container.make("uiConfig");
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
getStore,
|
|
15
|
-
getUiConfig
|
|
16
|
-
};
|
package/dist/chunk-XZFXXD3A.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/chunk-YC6T4XWI.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// src/context/container.ts
|
|
2
|
-
var Container = class {
|
|
3
|
-
static bindings = /* @__PURE__ */ new Map();
|
|
4
|
-
static singletons = /* @__PURE__ */ new Map();
|
|
5
|
-
static instances = /* @__PURE__ */ new Map();
|
|
6
|
-
static bind(key, factory) {
|
|
7
|
-
this.bindings.set(key, factory);
|
|
8
|
-
}
|
|
9
|
-
static singleton(key, factory) {
|
|
10
|
-
this.singletons.set(key, factory);
|
|
11
|
-
}
|
|
12
|
-
static make(key) {
|
|
13
|
-
if (this.instances.has(key)) {
|
|
14
|
-
return this.instances.get(key);
|
|
15
|
-
}
|
|
16
|
-
if (this.singletons.has(key)) {
|
|
17
|
-
const instance = this.singletons.get(key)();
|
|
18
|
-
this.instances.set(key, instance);
|
|
19
|
-
return instance;
|
|
20
|
-
}
|
|
21
|
-
if (this.bindings.has(key)) {
|
|
22
|
-
return this.bindings.get(key)();
|
|
23
|
-
}
|
|
24
|
-
throw new Error(`Service "${key}" is not bound in the container`);
|
|
25
|
-
}
|
|
26
|
-
static has(key) {
|
|
27
|
-
return this.bindings.has(key) || this.singletons.has(key) || this.instances.has(key);
|
|
28
|
-
}
|
|
29
|
-
static clear() {
|
|
30
|
-
this.bindings.clear();
|
|
31
|
-
this.singletons.clear();
|
|
32
|
-
this.instances.clear();
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export {
|
|
37
|
-
Container
|
|
38
|
-
};
|
package/dist/chunk-YXSPADWE.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__export
|
|
3
|
-
} from "./chunk-MLKGABMK.js";
|
|
4
|
-
|
|
5
|
-
// src/utils/index.ts
|
|
6
|
-
var utils_exports = {};
|
|
7
|
-
__export(utils_exports, {
|
|
8
|
-
formatSqlQuery: () => formatSqlQuery,
|
|
9
|
-
generateRandomUuid: () => generateRandomUuid,
|
|
10
|
-
getMeta: () => getMeta,
|
|
11
|
-
interpolateQuery: () => interpolateQuery,
|
|
12
|
-
isStaticFile: () => isStaticFile,
|
|
13
|
-
prepareIgnoredPaths: () => prepareIgnoredPaths,
|
|
14
|
-
prettyHrTime: () => prettyHrTime,
|
|
15
|
-
shouldIgnoreCurrentPath: () => shouldIgnoreCurrentPath,
|
|
16
|
-
stripBeforeAssetsPath: () => stripBeforeAssetsPath
|
|
17
|
-
});
|
|
18
|
-
import { DateTime } from "luxon";
|
|
19
|
-
import { format } from "sql-formatter";
|
|
20
|
-
import { randomUUID } from "crypto";
|
|
21
|
-
import { fileURLToPath } from "url";
|
|
22
|
-
import * as path from "path";
|
|
23
|
-
var generateRandomUuid = () => {
|
|
24
|
-
return randomUUID();
|
|
25
|
-
};
|
|
26
|
-
function interpolateQuery(query, bindings) {
|
|
27
|
-
const formatValue = (value) => {
|
|
28
|
-
if (value === null || value === void 0) return "NULL";
|
|
29
|
-
if (typeof value === "string") return `'${value.replace(/'/g, "''")}'`;
|
|
30
|
-
if (value instanceof DateTime) return `'${value.toISO()}'`;
|
|
31
|
-
if (value instanceof Date) return `'${value.toISOString()}'`;
|
|
32
|
-
if (Array.isArray(value))
|
|
33
|
-
return value.map((v) => typeof v === "string" ? `'${v.replace(/'/g, "''")}'` : v).join(", ");
|
|
34
|
-
if (typeof value === "object")
|
|
35
|
-
return `'${JSON.stringify(value).replace(/'/g, "''")}'`;
|
|
36
|
-
return value.toString();
|
|
37
|
-
};
|
|
38
|
-
if (Array.isArray(bindings)) {
|
|
39
|
-
let i = 0;
|
|
40
|
-
return query.replace(/\?/g, () => {
|
|
41
|
-
if (i >= bindings.length)
|
|
42
|
-
throw new Error("Not enough bindings for placeholders");
|
|
43
|
-
return formatValue(bindings[i++]);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return query.replace(/(\$|\:)(\w+)/g, (match, prefix, keyOrIndex) => {
|
|
47
|
-
let value;
|
|
48
|
-
if (prefix === "$" && /^\d+$/.test(keyOrIndex)) {
|
|
49
|
-
const index = parseInt(keyOrIndex, 10) - 1;
|
|
50
|
-
const keys = Object.keys(bindings);
|
|
51
|
-
if (index < 0 || index >= keys.length)
|
|
52
|
-
throw new Error(`Missing binding for ${match}`);
|
|
53
|
-
value = bindings[keys[index]];
|
|
54
|
-
} else {
|
|
55
|
-
if (!(keyOrIndex in bindings))
|
|
56
|
-
throw new Error(`Missing binding for ${match}`);
|
|
57
|
-
value = bindings[keyOrIndex];
|
|
58
|
-
}
|
|
59
|
-
return formatValue(value);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
var formatSqlQuery = (query, language) => {
|
|
63
|
-
return format(query, {
|
|
64
|
-
language,
|
|
65
|
-
dataTypeCase: "upper",
|
|
66
|
-
keywordCase: "upper",
|
|
67
|
-
functionCase: "upper"
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
function getMeta(metaUrl) {
|
|
71
|
-
const isESM = typeof __dirname === "undefined";
|
|
72
|
-
if (isESM) {
|
|
73
|
-
if (!metaUrl) {
|
|
74
|
-
throw new Error("In ESM, you must pass import.meta.url to getMeta()");
|
|
75
|
-
}
|
|
76
|
-
const __filename2 = fileURLToPath(metaUrl);
|
|
77
|
-
const __dirname2 = path.dirname(__filename2);
|
|
78
|
-
return { __filename: __filename2, __dirname: __dirname2 };
|
|
79
|
-
} else {
|
|
80
|
-
return { __filename, __dirname };
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function isStaticFile(params) {
|
|
84
|
-
return params.includes("assets");
|
|
85
|
-
}
|
|
86
|
-
function stripBeforeAssetsPath(url) {
|
|
87
|
-
const match = url.match(/assets.*/);
|
|
88
|
-
return match ? match[0] : url;
|
|
89
|
-
}
|
|
90
|
-
function prepareIgnoredPaths(path2, ignoredPaths) {
|
|
91
|
-
const normalizedPath = path2.replace(/^\/+|\/+$/g, "");
|
|
92
|
-
ignoredPaths = [
|
|
93
|
-
...ignoredPaths,
|
|
94
|
-
new RegExp(`^/?${normalizedPath}(/|$)`),
|
|
95
|
-
/^\/?lens-config$/,
|
|
96
|
-
/^\/\.well-known\//
|
|
97
|
-
];
|
|
98
|
-
return { ignoredPaths, normalizedPath };
|
|
99
|
-
}
|
|
100
|
-
function shouldIgnoreCurrentPath(path2, ignoredPaths, onlyPaths) {
|
|
101
|
-
if (onlyPaths.length > 0) {
|
|
102
|
-
return !onlyPaths.some((pattern) => pattern.test(path2));
|
|
103
|
-
}
|
|
104
|
-
return ignoredPaths.some((pattern) => pattern.test(path2));
|
|
105
|
-
}
|
|
106
|
-
function prettyHrTime(hrtime, verbose = false) {
|
|
107
|
-
const seconds = hrtime[0];
|
|
108
|
-
const nanoseconds = hrtime[1];
|
|
109
|
-
const ms = seconds * 1e3 + nanoseconds / 1e6;
|
|
110
|
-
if (verbose) {
|
|
111
|
-
if (seconds > 60) {
|
|
112
|
-
const minutes = Math.floor(seconds / 60);
|
|
113
|
-
const remainingSeconds = seconds % 60;
|
|
114
|
-
return `${minutes}m ${remainingSeconds}s`;
|
|
115
|
-
}
|
|
116
|
-
if (seconds >= 1) {
|
|
117
|
-
return `${seconds}.${Math.floor(nanoseconds / 1e7)}s`;
|
|
118
|
-
}
|
|
119
|
-
return `${ms.toFixed(3)} ms`;
|
|
120
|
-
}
|
|
121
|
-
if (ms < 1e3) {
|
|
122
|
-
return `${ms.toFixed(0)} ms`;
|
|
123
|
-
}
|
|
124
|
-
return `${(ms / 1e3).toFixed(1)} s`;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export {
|
|
128
|
-
generateRandomUuid,
|
|
129
|
-
interpolateQuery,
|
|
130
|
-
formatSqlQuery,
|
|
131
|
-
getMeta,
|
|
132
|
-
isStaticFile,
|
|
133
|
-
stripBeforeAssetsPath,
|
|
134
|
-
prepareIgnoredPaths,
|
|
135
|
-
shouldIgnoreCurrentPath,
|
|
136
|
-
prettyHrTime,
|
|
137
|
-
utils_exports
|
|
138
|
-
};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./QueryTable-B6L0F5jL.js","./index-Dzy6B_ZD.js","./index-DzNHqeKh.css","./Table-DF4sxTNg.js","./index-byVaIWe8.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as t,j as s,_ as a}from"./index-Dzy6B_ZD.js";import{u as i}from"./useQueries-CVt1cLYV.js";import{u}from"./useLoadMore-BRca6vvh.js";import"./useLensApi-CkgX8mtY.js";const m=t.lazy(()=>a(()=>import("./QueryTable-B6L0F5jL.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url)),l=()=>{const{loadMoreRequests:o,fetchQueries:r}=i(),e=u({paginatedPage:o});return t.useEffect(()=>{r()},[]),console.log("data",e.data),s.jsx(m,{hasMoreObject:e})};export{l as default};
|
|
Binary file
|