@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.
Files changed (100) hide show
  1. package/dist/abstracts/adapter.cjs +70 -5
  2. package/dist/abstracts/adapter.js +37 -5
  3. package/dist/abstracts/store.cjs +26 -6
  4. package/dist/abstracts/store.js +3 -4
  5. package/dist/context/container.cjs +57 -6
  6. package/dist/context/container.js +34 -4
  7. package/dist/context/context.cjs +71 -7
  8. package/dist/context/context.js +42 -6
  9. package/dist/core/api_controller.cjs +148 -7
  10. package/dist/core/api_controller.js +121 -7
  11. package/dist/core/lens.cjs +404 -12
  12. package/dist/core/lens.js +370 -12
  13. package/dist/core/watcher.cjs +26 -6
  14. package/dist/core/watcher.js +3 -4
  15. package/dist/{index-D0Vszdac.d.ts → index-DiLfwsvc.d.cts} +2 -11
  16. package/dist/{index-D0Vszdac.d.cts → index-DiLfwsvc.d.ts} +2 -11
  17. package/dist/index.cjs +611 -55
  18. package/dist/index.d.cts +2 -4
  19. package/dist/index.d.ts +2 -4
  20. package/dist/index.js +556 -42
  21. package/dist/stores/better_sqlite.cjs +149 -7
  22. package/dist/stores/better_sqlite.js +116 -7
  23. package/dist/stores/index.cjs +153 -8
  24. package/dist/stores/index.js +116 -8
  25. package/dist/types/index.cjs +33 -6
  26. package/dist/types/index.js +6 -4
  27. package/dist/ui/assets/QueriesContainer-CAAsjjW5.js +2 -0
  28. package/dist/ui/assets/{QueryDetailsContainer-BkaktbOw.js → QueryDetailsContainer-E7P-IO7f.js} +19 -19
  29. package/dist/ui/assets/QueryTable-BcrtUssT.js +1 -0
  30. package/dist/ui/assets/RequestDetails-C2DZBu5H.js +1 -0
  31. package/dist/ui/assets/RequestDetailsContainer-DuDo-IqS.js +2 -0
  32. package/dist/ui/assets/{RequestsContainer-zoWMoB7o.js → RequestsContainer-DK3hQVz9.js} +2 -2
  33. package/dist/ui/assets/RequetsTable-DgP8p60b.js +1 -0
  34. package/dist/ui/assets/{StatusCode-DH20lQ6a.js → StatusCode-FQEjz7gK.js} +1 -1
  35. package/dist/ui/assets/TabbedDataViewer-cBDdPwIz.js +1 -0
  36. package/dist/ui/assets/{Table-HwlddLhp.js → Table-DYaXk80S.js} +2 -2
  37. package/dist/ui/assets/index-BS8XxorB.js +114 -0
  38. package/dist/ui/assets/index-CpP2Ap5X.js +1 -0
  39. package/dist/ui/assets/index-DzNHqeKh.css +1 -0
  40. package/dist/ui/assets/{useLensApi-Bmk2bGb0.js → useLensApi-DG6atd6d.js} +1 -1
  41. package/dist/ui/assets/{useLoadMore-CvIajdjM.js → useLoadMore-CJltToLI.js} +1 -1
  42. package/dist/ui/assets/{useQueries-DuyhGJyf.js → useQueries-C8mDDDc6.js} +1 -1
  43. package/dist/ui/index.html +2 -2
  44. package/dist/utils/event_emitter.cjs +42 -10
  45. package/dist/utils/event_emitter.d.cts +1 -11
  46. package/dist/utils/event_emitter.d.ts +1 -11
  47. package/dist/utils/event_emitter.js +6 -9
  48. package/dist/utils/index.cjs +163 -31
  49. package/dist/utils/index.d.cts +1 -2
  50. package/dist/utils/index.d.ts +1 -2
  51. package/dist/utils/index.js +109 -20
  52. package/dist/watchers/index.cjs +105 -10
  53. package/dist/watchers/index.js +79 -12
  54. package/dist/watchers/query_watcher.cjs +78 -8
  55. package/dist/watchers/query_watcher.js +55 -8
  56. package/dist/watchers/request_watcher.cjs +90 -8
  57. package/dist/watchers/request_watcher.js +67 -8
  58. package/package.json +18 -18
  59. package/README.md +0 -1
  60. package/dist/chunk-2HRVJRKV.cjs +0 -10
  61. package/dist/chunk-3R5QARPT.cjs +0 -14
  62. package/dist/chunk-4HLDYZJA.js +0 -34
  63. package/dist/chunk-5PYQWLAZ.js +0 -129
  64. package/dist/chunk-75ZPJI57.cjs +0 -9
  65. package/dist/chunk-7EKM5HB5.cjs +0 -1
  66. package/dist/chunk-AUDSBNLF.cjs +0 -122
  67. package/dist/chunk-BFFOUTTE.cjs +0 -32
  68. package/dist/chunk-BL4Z6JFH.cjs +0 -34
  69. package/dist/chunk-CQ2Z4TCR.js +0 -7
  70. package/dist/chunk-EHOWCXZV.cjs +0 -7
  71. package/dist/chunk-EJ5BW35V.js +0 -159
  72. package/dist/chunk-EKG3FVLV.cjs +0 -7
  73. package/dist/chunk-FCMQ3WE3.cjs +0 -129
  74. package/dist/chunk-FKMBNWX4.js +0 -7
  75. package/dist/chunk-FLOVBBFU.js +0 -10
  76. package/dist/chunk-GI7SJDNQ.cjs +0 -38
  77. package/dist/chunk-IPMTMCFP.js +0 -122
  78. package/dist/chunk-JZ2JLQXL.cjs +0 -87
  79. package/dist/chunk-MLKGABMK.js +0 -9
  80. package/dist/chunk-QRZUNYF6.cjs +0 -16
  81. package/dist/chunk-RMZ4UAQ2.js +0 -14
  82. package/dist/chunk-SJXZARBJ.cjs +0 -22
  83. package/dist/chunk-TJDE6AZM.js +0 -87
  84. package/dist/chunk-TPUVRGYT.js +0 -32
  85. package/dist/chunk-UF5HFNMI.js +0 -22
  86. package/dist/chunk-VD5IMUWL.js +0 -0
  87. package/dist/chunk-WU6IZUEV.cjs +0 -159
  88. package/dist/chunk-XXYRWHSQ.js +0 -0
  89. package/dist/chunk-XYXPHWEI.js +0 -16
  90. package/dist/chunk-XZFXXD3A.cjs +0 -1
  91. package/dist/chunk-YC6T4XWI.js +0 -38
  92. package/dist/ui/assets/QueriesContainer-DHnHEGG1.js +0 -2
  93. package/dist/ui/assets/QueryTable-DegVNDkJ.js +0 -1
  94. package/dist/ui/assets/RequestDetails-zrL0n6gL.js +0 -1
  95. package/dist/ui/assets/RequestDetailsContainer-CsHWDxn7.js +0 -2
  96. package/dist/ui/assets/RequetsTable-1K9hhs0W.js +0 -1
  97. package/dist/ui/assets/TabbedDataViewer-DDVxzZiW.js +0 -1
  98. package/dist/ui/assets/date-CZdBf-JH.js +0 -1
  99. package/dist/ui/assets/index-C-9tn0L6.js +0 -114
  100. package/dist/ui/assets/index-DaNx3ROH.css +0 -1
@@ -1,31 +1,120 @@
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";
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
  };
@@ -1,16 +1,111 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-7EKM5HB5.cjs');
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
- var _chunkSJXZARBJcjs = require('../chunk-SJXZARBJ.cjs');
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
- 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');
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
- exports.QueryWatcher = _chunkSJXZARBJcjs.QueryWatcher; exports.RequestWatcher = _chunkBL4Z6JFHcjs.RequestWatcher;
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
+ });
@@ -1,15 +1,82 @@
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";
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";Object.defineProperty(exports, "__esModule", {value: true});
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
- 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');
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
- exports.default = _chunkSJXZARBJcjs.QueryWatcher;
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
- 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";
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";Object.defineProperty(exports, "__esModule", {value: true});
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
- 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');
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
- exports.default = _chunkBL4Z6JFHcjs.RequestWatcher;
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
- 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";
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
  };