@lensjs/core 1.0.7 → 1.0.10
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-D0Vszdac.d.ts → index-DiLfwsvc.d.cts} +2 -11
- package/dist/{index-D0Vszdac.d.cts → index-DiLfwsvc.d.ts} +2 -11
- package/dist/index.cjs +611 -55
- package/dist/index.d.cts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +556 -42
- package/dist/stores/better_sqlite.cjs +149 -7
- package/dist/stores/better_sqlite.js +116 -7
- package/dist/stores/index.cjs +153 -8
- package/dist/stores/index.js +116 -8
- 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-BkaktbOw.js → QueryDetailsContainer-E7P-IO7f.js} +19 -19
- package/dist/ui/assets/QueryTable-BcrtUssT.js +1 -0
- package/dist/ui/assets/RequestDetails-C2DZBu5H.js +1 -0
- package/dist/ui/assets/RequestDetailsContainer-DuDo-IqS.js +2 -0
- package/dist/ui/assets/{RequestsContainer-zoWMoB7o.js → RequestsContainer-DK3hQVz9.js} +2 -2
- package/dist/ui/assets/RequetsTable-DgP8p60b.js +1 -0
- package/dist/ui/assets/{StatusCode-DH20lQ6a.js → StatusCode-FQEjz7gK.js} +1 -1
- package/dist/ui/assets/TabbedDataViewer-cBDdPwIz.js +1 -0
- package/dist/ui/assets/{Table-HwlddLhp.js → Table-DYaXk80S.js} +2 -2
- package/dist/ui/assets/index-BS8XxorB.js +114 -0
- package/dist/ui/assets/index-CpP2Ap5X.js +1 -0
- package/dist/ui/assets/index-DzNHqeKh.css +1 -0
- package/dist/ui/assets/{useLensApi-Bmk2bGb0.js → useLensApi-DG6atd6d.js} +1 -1
- package/dist/ui/assets/{useLoadMore-CvIajdjM.js → useLoadMore-CJltToLI.js} +1 -1
- package/dist/ui/assets/{useQueries-DuyhGJyf.js → useQueries-C8mDDDc6.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/utils/event_emitter.cjs +42 -10
- package/dist/utils/event_emitter.d.cts +1 -11
- package/dist/utils/event_emitter.d.ts +1 -11
- package/dist/utils/event_emitter.js +6 -9
- package/dist/utils/index.cjs +163 -31
- package/dist/utils/index.d.cts +1 -2
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.js +109 -20
- 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 +18 -18
- package/README.md +0 -1
- package/dist/chunk-2HRVJRKV.cjs +0 -10
- package/dist/chunk-3R5QARPT.cjs +0 -14
- package/dist/chunk-4HLDYZJA.js +0 -34
- package/dist/chunk-5PYQWLAZ.js +0 -129
- package/dist/chunk-75ZPJI57.cjs +0 -9
- package/dist/chunk-7EKM5HB5.cjs +0 -1
- package/dist/chunk-AUDSBNLF.cjs +0 -122
- package/dist/chunk-BFFOUTTE.cjs +0 -32
- package/dist/chunk-BL4Z6JFH.cjs +0 -34
- package/dist/chunk-CQ2Z4TCR.js +0 -7
- package/dist/chunk-EHOWCXZV.cjs +0 -7
- package/dist/chunk-EJ5BW35V.js +0 -159
- package/dist/chunk-EKG3FVLV.cjs +0 -7
- package/dist/chunk-FCMQ3WE3.cjs +0 -129
- package/dist/chunk-FKMBNWX4.js +0 -7
- package/dist/chunk-FLOVBBFU.js +0 -10
- package/dist/chunk-GI7SJDNQ.cjs +0 -38
- package/dist/chunk-IPMTMCFP.js +0 -122
- package/dist/chunk-JZ2JLQXL.cjs +0 -87
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/chunk-QRZUNYF6.cjs +0 -16
- package/dist/chunk-RMZ4UAQ2.js +0 -14
- package/dist/chunk-SJXZARBJ.cjs +0 -22
- package/dist/chunk-TJDE6AZM.js +0 -87
- package/dist/chunk-TPUVRGYT.js +0 -32
- package/dist/chunk-UF5HFNMI.js +0 -22
- package/dist/chunk-VD5IMUWL.js +0 -0
- package/dist/chunk-WU6IZUEV.cjs +0 -159
- 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/ui/assets/QueriesContainer-DHnHEGG1.js +0 -2
- package/dist/ui/assets/QueryTable-DegVNDkJ.js +0 -1
- package/dist/ui/assets/RequestDetails-zrL0n6gL.js +0 -1
- package/dist/ui/assets/RequestDetailsContainer-CsHWDxn7.js +0 -2
- package/dist/ui/assets/RequetsTable-1K9hhs0W.js +0 -1
- package/dist/ui/assets/TabbedDataViewer-DDVxzZiW.js +0 -1
- package/dist/ui/assets/date-CZdBf-JH.js +0 -1
- package/dist/ui/assets/index-C-9tn0L6.js +0 -114
- package/dist/ui/assets/index-DaNx3ROH.css +0 -1
package/dist/utils/index.js
CHANGED
|
@@ -1,31 +1,120 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
// src/utils/index.ts
|
|
2
|
+
import { DateTime } from "luxon";
|
|
3
|
+
import { format } from "sql-formatter";
|
|
4
|
+
import { randomUUID } from "crypto";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import * as path from "path";
|
|
7
|
+
var generateRandomUuid = () => {
|
|
8
|
+
return randomUUID();
|
|
9
|
+
};
|
|
10
|
+
function interpolateQuery(query, bindings) {
|
|
11
|
+
const formatValue = (value) => {
|
|
12
|
+
if (value === null || value === void 0) return "NULL";
|
|
13
|
+
if (typeof value === "string") return `'${value.replace(/'/g, "''")}'`;
|
|
14
|
+
if (value instanceof DateTime) return `'${value.toISO()}'`;
|
|
15
|
+
if (value instanceof Date) return `'${value.toISOString()}'`;
|
|
16
|
+
if (Array.isArray(value))
|
|
17
|
+
return value.map((v) => typeof v === "string" ? `'${v.replace(/'/g, "''")}'` : v).join(", ");
|
|
18
|
+
if (typeof value === "object")
|
|
19
|
+
return `'${JSON.stringify(value).replace(/'/g, "''")}'`;
|
|
20
|
+
return value.toString();
|
|
21
|
+
};
|
|
22
|
+
if (Array.isArray(bindings)) {
|
|
23
|
+
let i = 0;
|
|
24
|
+
return query.replace(/\?/g, () => {
|
|
25
|
+
if (i >= bindings.length)
|
|
26
|
+
throw new Error("Not enough bindings for placeholders");
|
|
27
|
+
return formatValue(bindings[i++]);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return query.replace(/(\$|\:)(\w+)/g, (match, prefix, keyOrIndex) => {
|
|
31
|
+
let value;
|
|
32
|
+
if (prefix === "$" && /^\d+$/.test(keyOrIndex)) {
|
|
33
|
+
const index = parseInt(keyOrIndex, 10) - 1;
|
|
34
|
+
const keys = Object.keys(bindings);
|
|
35
|
+
if (index < 0 || index >= keys.length)
|
|
36
|
+
throw new Error(`Missing binding for ${match}`);
|
|
37
|
+
value = bindings[keys[index]];
|
|
38
|
+
} else {
|
|
39
|
+
if (!(keyOrIndex in bindings))
|
|
40
|
+
throw new Error(`Missing binding for ${match}`);
|
|
41
|
+
value = bindings[keyOrIndex];
|
|
42
|
+
}
|
|
43
|
+
return formatValue(value);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
var formatSqlQuery = (query, language) => {
|
|
47
|
+
return format(query, {
|
|
48
|
+
language,
|
|
49
|
+
dataTypeCase: "upper",
|
|
50
|
+
keywordCase: "upper",
|
|
51
|
+
functionCase: "upper"
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
function getMeta(metaUrl) {
|
|
55
|
+
const isESM = typeof __dirname === "undefined";
|
|
56
|
+
if (isESM) {
|
|
57
|
+
if (!metaUrl) {
|
|
58
|
+
throw new Error("In ESM, you must pass import.meta.url to getMeta()");
|
|
59
|
+
}
|
|
60
|
+
const __filename2 = fileURLToPath(metaUrl);
|
|
61
|
+
const __dirname2 = path.dirname(__filename2);
|
|
62
|
+
return { __filename: __filename2, __dirname: __dirname2 };
|
|
63
|
+
} else {
|
|
64
|
+
return { __filename, __dirname };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function isStaticFile(params) {
|
|
68
|
+
return params.includes("assets");
|
|
69
|
+
}
|
|
70
|
+
function stripBeforeAssetsPath(url) {
|
|
71
|
+
const match = url.match(/assets.*/);
|
|
72
|
+
return match ? match[0] : url;
|
|
73
|
+
}
|
|
74
|
+
function prepareIgnoredPaths(path2, ignoredPaths) {
|
|
75
|
+
const normalizedPath = path2.replace(/^\/+|\/+$/g, "");
|
|
76
|
+
ignoredPaths = [
|
|
77
|
+
...ignoredPaths,
|
|
78
|
+
new RegExp(`^/?${normalizedPath}(/|$)`),
|
|
79
|
+
/^\/?lens-config$/,
|
|
80
|
+
/^\/\.well-known\//
|
|
81
|
+
];
|
|
82
|
+
return { ignoredPaths, normalizedPath };
|
|
83
|
+
}
|
|
84
|
+
function shouldIgnoreCurrentPath(path2, ignoredPaths, onlyPaths) {
|
|
85
|
+
if (onlyPaths.length > 0) {
|
|
86
|
+
return !onlyPaths.some((pattern) => pattern.test(path2));
|
|
87
|
+
}
|
|
88
|
+
return ignoredPaths.some((pattern) => pattern.test(path2));
|
|
89
|
+
}
|
|
90
|
+
function prettyHrTime(hrtime, verbose = false) {
|
|
91
|
+
const seconds = hrtime[0];
|
|
92
|
+
const nanoseconds = hrtime[1];
|
|
93
|
+
const ms = seconds * 1e3 + nanoseconds / 1e6;
|
|
94
|
+
if (verbose) {
|
|
95
|
+
if (seconds > 60) {
|
|
96
|
+
const minutes = Math.floor(seconds / 60);
|
|
97
|
+
const remainingSeconds = seconds % 60;
|
|
98
|
+
return `${minutes}m ${remainingSeconds}s`;
|
|
99
|
+
}
|
|
100
|
+
if (seconds >= 1) {
|
|
101
|
+
return `${seconds}.${Math.floor(nanoseconds / 1e7)}s`;
|
|
102
|
+
}
|
|
103
|
+
return `${ms.toFixed(3)} ms`;
|
|
104
|
+
}
|
|
105
|
+
if (ms < 1e3) {
|
|
106
|
+
return `${ms.toFixed(0)} ms`;
|
|
107
|
+
}
|
|
108
|
+
return `${(ms / 1e3).toFixed(1)} s`;
|
|
109
|
+
}
|
|
17
110
|
export {
|
|
18
|
-
convertToUTC,
|
|
19
111
|
formatSqlQuery,
|
|
20
112
|
generateRandomUuid,
|
|
21
113
|
getMeta,
|
|
22
114
|
interpolateQuery,
|
|
23
115
|
isStaticFile,
|
|
24
|
-
now,
|
|
25
|
-
nowISO,
|
|
26
116
|
prepareIgnoredPaths,
|
|
27
117
|
prettyHrTime,
|
|
28
118
|
shouldIgnoreCurrentPath,
|
|
29
|
-
sqlDateTime,
|
|
30
119
|
stripBeforeAssetsPath
|
|
31
120
|
};
|
package/dist/watchers/index.cjs
CHANGED
|
@@ -1,16 +1,111 @@
|
|
|
1
|
-
"use strict";
|
|
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);
|
|
2
19
|
|
|
20
|
+
// src/watchers/index.ts
|
|
21
|
+
var watchers_exports = {};
|
|
22
|
+
__export(watchers_exports, {
|
|
23
|
+
QueryWatcher: () => QueryWatcher,
|
|
24
|
+
RequestWatcher: () => RequestWatcher
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(watchers_exports);
|
|
3
27
|
|
|
4
|
-
|
|
28
|
+
// src/context/container.ts
|
|
29
|
+
var Container = class {
|
|
30
|
+
static bindings = /* @__PURE__ */ new Map();
|
|
31
|
+
static singletons = /* @__PURE__ */ new Map();
|
|
32
|
+
static instances = /* @__PURE__ */ new Map();
|
|
33
|
+
static bind(key, factory) {
|
|
34
|
+
this.bindings.set(key, factory);
|
|
35
|
+
}
|
|
36
|
+
static singleton(key, factory) {
|
|
37
|
+
this.singletons.set(key, factory);
|
|
38
|
+
}
|
|
39
|
+
static make(key) {
|
|
40
|
+
if (this.instances.has(key)) {
|
|
41
|
+
return this.instances.get(key);
|
|
42
|
+
}
|
|
43
|
+
if (this.singletons.has(key)) {
|
|
44
|
+
const instance = this.singletons.get(key)();
|
|
45
|
+
this.instances.set(key, instance);
|
|
46
|
+
return instance;
|
|
47
|
+
}
|
|
48
|
+
if (this.bindings.has(key)) {
|
|
49
|
+
return this.bindings.get(key)();
|
|
50
|
+
}
|
|
51
|
+
throw new Error(`Service "${key}" is not bound in the container`);
|
|
52
|
+
}
|
|
53
|
+
static has(key) {
|
|
54
|
+
return this.bindings.has(key) || this.singletons.has(key) || this.instances.has(key);
|
|
55
|
+
}
|
|
56
|
+
static clear() {
|
|
57
|
+
this.bindings.clear();
|
|
58
|
+
this.singletons.clear();
|
|
59
|
+
this.instances.clear();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
5
62
|
|
|
63
|
+
// src/context/context.ts
|
|
64
|
+
var getStore = () => {
|
|
65
|
+
return Container.make("store");
|
|
66
|
+
};
|
|
6
67
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
require('../chunk-GI7SJDNQ.cjs');
|
|
11
|
-
require('../chunk-EKG3FVLV.cjs');
|
|
12
|
-
require('../chunk-75ZPJI57.cjs');
|
|
68
|
+
// src/core/watcher.ts
|
|
69
|
+
var Watcher = class {
|
|
70
|
+
};
|
|
13
71
|
|
|
72
|
+
// src/watchers/query_watcher.ts
|
|
73
|
+
var QueryWatcher = class extends Watcher {
|
|
74
|
+
name = "query" /* QUERY */;
|
|
75
|
+
async log(entry) {
|
|
76
|
+
await getStore().save({
|
|
77
|
+
type: this.name,
|
|
78
|
+
data: entry.data,
|
|
79
|
+
requestId: entry.requestId ?? ""
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
14
83
|
|
|
15
|
-
|
|
16
|
-
|
|
84
|
+
// src/watchers/request_watcher.ts
|
|
85
|
+
var RequestWatcher = class extends Watcher {
|
|
86
|
+
name = "request" /* REQUEST */;
|
|
87
|
+
async log(data) {
|
|
88
|
+
await getStore().save({
|
|
89
|
+
id: data.request.id,
|
|
90
|
+
type: this.name,
|
|
91
|
+
minimal_data: {
|
|
92
|
+
id: data.request.id,
|
|
93
|
+
method: data.request.method,
|
|
94
|
+
path: data.request.path,
|
|
95
|
+
duration: data.request.duration,
|
|
96
|
+
createdAt: data.request.createdAt,
|
|
97
|
+
status: data.request.status
|
|
98
|
+
},
|
|
99
|
+
data: {
|
|
100
|
+
...data.request,
|
|
101
|
+
user: data.user,
|
|
102
|
+
response: data.response
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
+
0 && (module.exports = {
|
|
109
|
+
QueryWatcher,
|
|
110
|
+
RequestWatcher
|
|
111
|
+
});
|
package/dist/watchers/index.js
CHANGED
|
@@ -1,15 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
// src/context/context.ts
|
|
37
|
+
var getStore = () => {
|
|
38
|
+
return Container.make("store");
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/core/watcher.ts
|
|
42
|
+
var Watcher = class {
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// src/watchers/query_watcher.ts
|
|
46
|
+
var QueryWatcher = class extends Watcher {
|
|
47
|
+
name = "query" /* QUERY */;
|
|
48
|
+
async log(entry) {
|
|
49
|
+
await getStore().save({
|
|
50
|
+
type: this.name,
|
|
51
|
+
data: entry.data,
|
|
52
|
+
requestId: entry.requestId ?? ""
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// src/watchers/request_watcher.ts
|
|
58
|
+
var RequestWatcher = class extends Watcher {
|
|
59
|
+
name = "request" /* REQUEST */;
|
|
60
|
+
async log(data) {
|
|
61
|
+
await getStore().save({
|
|
62
|
+
id: data.request.id,
|
|
63
|
+
type: this.name,
|
|
64
|
+
minimal_data: {
|
|
65
|
+
id: data.request.id,
|
|
66
|
+
method: data.request.method,
|
|
67
|
+
path: data.request.path,
|
|
68
|
+
duration: data.request.duration,
|
|
69
|
+
createdAt: data.request.createdAt,
|
|
70
|
+
status: data.request.status
|
|
71
|
+
},
|
|
72
|
+
data: {
|
|
73
|
+
...data.request,
|
|
74
|
+
user: data.user,
|
|
75
|
+
response: data.response
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
13
80
|
export {
|
|
14
81
|
QueryWatcher,
|
|
15
82
|
RequestWatcher
|
|
@@ -1,11 +1,81 @@
|
|
|
1
|
-
"use strict";
|
|
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);
|
|
2
19
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
20
|
+
// src/watchers/query_watcher.ts
|
|
21
|
+
var query_watcher_exports = {};
|
|
22
|
+
__export(query_watcher_exports, {
|
|
23
|
+
default: () => QueryWatcher
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(query_watcher_exports);
|
|
9
26
|
|
|
27
|
+
// src/context/container.ts
|
|
28
|
+
var Container = class {
|
|
29
|
+
static bindings = /* @__PURE__ */ new Map();
|
|
30
|
+
static singletons = /* @__PURE__ */ new Map();
|
|
31
|
+
static instances = /* @__PURE__ */ new Map();
|
|
32
|
+
static bind(key, factory) {
|
|
33
|
+
this.bindings.set(key, factory);
|
|
34
|
+
}
|
|
35
|
+
static singleton(key, factory) {
|
|
36
|
+
this.singletons.set(key, factory);
|
|
37
|
+
}
|
|
38
|
+
static make(key) {
|
|
39
|
+
if (this.instances.has(key)) {
|
|
40
|
+
return this.instances.get(key);
|
|
41
|
+
}
|
|
42
|
+
if (this.singletons.has(key)) {
|
|
43
|
+
const instance = this.singletons.get(key)();
|
|
44
|
+
this.instances.set(key, instance);
|
|
45
|
+
return instance;
|
|
46
|
+
}
|
|
47
|
+
if (this.bindings.has(key)) {
|
|
48
|
+
return this.bindings.get(key)();
|
|
49
|
+
}
|
|
50
|
+
throw new Error(`Service "${key}" is not bound in the container`);
|
|
51
|
+
}
|
|
52
|
+
static has(key) {
|
|
53
|
+
return this.bindings.has(key) || this.singletons.has(key) || this.instances.has(key);
|
|
54
|
+
}
|
|
55
|
+
static clear() {
|
|
56
|
+
this.bindings.clear();
|
|
57
|
+
this.singletons.clear();
|
|
58
|
+
this.instances.clear();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
10
61
|
|
|
11
|
-
|
|
62
|
+
// src/context/context.ts
|
|
63
|
+
var getStore = () => {
|
|
64
|
+
return Container.make("store");
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// src/core/watcher.ts
|
|
68
|
+
var Watcher = class {
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// src/watchers/query_watcher.ts
|
|
72
|
+
var QueryWatcher = class extends Watcher {
|
|
73
|
+
name = "query" /* QUERY */;
|
|
74
|
+
async log(entry) {
|
|
75
|
+
await getStore().save({
|
|
76
|
+
type: this.name,
|
|
77
|
+
data: entry.data,
|
|
78
|
+
requestId: entry.requestId ?? ""
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
};
|
|
@@ -1,11 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
// src/context/context.ts
|
|
37
|
+
var getStore = () => {
|
|
38
|
+
return Container.make("store");
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/core/watcher.ts
|
|
42
|
+
var Watcher = class {
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// src/watchers/query_watcher.ts
|
|
46
|
+
var QueryWatcher = class extends Watcher {
|
|
47
|
+
name = "query" /* QUERY */;
|
|
48
|
+
async log(entry) {
|
|
49
|
+
await getStore().save({
|
|
50
|
+
type: this.name,
|
|
51
|
+
data: entry.data,
|
|
52
|
+
requestId: entry.requestId ?? ""
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
9
56
|
export {
|
|
10
57
|
QueryWatcher as default
|
|
11
58
|
};
|
|
@@ -1,11 +1,93 @@
|
|
|
1
|
-
"use strict";
|
|
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);
|
|
2
19
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
20
|
+
// src/watchers/request_watcher.ts
|
|
21
|
+
var request_watcher_exports = {};
|
|
22
|
+
__export(request_watcher_exports, {
|
|
23
|
+
default: () => RequestWatcher
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(request_watcher_exports);
|
|
9
26
|
|
|
27
|
+
// src/context/container.ts
|
|
28
|
+
var Container = class {
|
|
29
|
+
static bindings = /* @__PURE__ */ new Map();
|
|
30
|
+
static singletons = /* @__PURE__ */ new Map();
|
|
31
|
+
static instances = /* @__PURE__ */ new Map();
|
|
32
|
+
static bind(key, factory) {
|
|
33
|
+
this.bindings.set(key, factory);
|
|
34
|
+
}
|
|
35
|
+
static singleton(key, factory) {
|
|
36
|
+
this.singletons.set(key, factory);
|
|
37
|
+
}
|
|
38
|
+
static make(key) {
|
|
39
|
+
if (this.instances.has(key)) {
|
|
40
|
+
return this.instances.get(key);
|
|
41
|
+
}
|
|
42
|
+
if (this.singletons.has(key)) {
|
|
43
|
+
const instance = this.singletons.get(key)();
|
|
44
|
+
this.instances.set(key, instance);
|
|
45
|
+
return instance;
|
|
46
|
+
}
|
|
47
|
+
if (this.bindings.has(key)) {
|
|
48
|
+
return this.bindings.get(key)();
|
|
49
|
+
}
|
|
50
|
+
throw new Error(`Service "${key}" is not bound in the container`);
|
|
51
|
+
}
|
|
52
|
+
static has(key) {
|
|
53
|
+
return this.bindings.has(key) || this.singletons.has(key) || this.instances.has(key);
|
|
54
|
+
}
|
|
55
|
+
static clear() {
|
|
56
|
+
this.bindings.clear();
|
|
57
|
+
this.singletons.clear();
|
|
58
|
+
this.instances.clear();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
10
61
|
|
|
11
|
-
|
|
62
|
+
// src/context/context.ts
|
|
63
|
+
var getStore = () => {
|
|
64
|
+
return Container.make("store");
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// src/core/watcher.ts
|
|
68
|
+
var Watcher = class {
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// src/watchers/request_watcher.ts
|
|
72
|
+
var RequestWatcher = class extends Watcher {
|
|
73
|
+
name = "request" /* REQUEST */;
|
|
74
|
+
async log(data) {
|
|
75
|
+
await getStore().save({
|
|
76
|
+
id: data.request.id,
|
|
77
|
+
type: this.name,
|
|
78
|
+
minimal_data: {
|
|
79
|
+
id: data.request.id,
|
|
80
|
+
method: data.request.method,
|
|
81
|
+
path: data.request.path,
|
|
82
|
+
duration: data.request.duration,
|
|
83
|
+
createdAt: data.request.createdAt,
|
|
84
|
+
status: data.request.status
|
|
85
|
+
},
|
|
86
|
+
data: {
|
|
87
|
+
...data.request,
|
|
88
|
+
user: data.user,
|
|
89
|
+
response: data.response
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
@@ -1,11 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
// src/context/context.ts
|
|
37
|
+
var getStore = () => {
|
|
38
|
+
return Container.make("store");
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/core/watcher.ts
|
|
42
|
+
var Watcher = class {
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// src/watchers/request_watcher.ts
|
|
46
|
+
var RequestWatcher = class extends Watcher {
|
|
47
|
+
name = "request" /* REQUEST */;
|
|
48
|
+
async log(data) {
|
|
49
|
+
await getStore().save({
|
|
50
|
+
id: data.request.id,
|
|
51
|
+
type: this.name,
|
|
52
|
+
minimal_data: {
|
|
53
|
+
id: data.request.id,
|
|
54
|
+
method: data.request.method,
|
|
55
|
+
path: data.request.path,
|
|
56
|
+
duration: data.request.duration,
|
|
57
|
+
createdAt: data.request.createdAt,
|
|
58
|
+
status: data.request.status
|
|
59
|
+
},
|
|
60
|
+
data: {
|
|
61
|
+
...data.request,
|
|
62
|
+
user: data.user,
|
|
63
|
+
response: data.response
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
9
68
|
export {
|
|
10
69
|
RequestWatcher as default
|
|
11
70
|
};
|