@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.
Files changed (85) 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.cjs +611 -51
  16. package/dist/index.js +556 -38
  17. package/dist/stores/better_sqlite.cjs +149 -6
  18. package/dist/stores/better_sqlite.js +116 -6
  19. package/dist/stores/index.cjs +153 -7
  20. package/dist/stores/index.js +116 -7
  21. package/dist/types/index.cjs +33 -6
  22. package/dist/types/index.js +6 -4
  23. package/dist/ui/assets/QueriesContainer-CAAsjjW5.js +2 -0
  24. package/dist/ui/assets/{QueryDetailsContainer-CtNxjUvF.js → QueryDetailsContainer-E7P-IO7f.js} +3 -3
  25. package/dist/ui/assets/{QueryTable-B6L0F5jL.js → QueryTable-BcrtUssT.js} +1 -1
  26. package/dist/ui/assets/{RequestDetails-BfxFQmp1.js → RequestDetails-C2DZBu5H.js} +1 -1
  27. package/dist/ui/assets/{RequestDetailsContainer-C0s7VLpw.js → RequestDetailsContainer-DuDo-IqS.js} +2 -2
  28. package/dist/ui/assets/{RequestsContainer-rWbSc4Py.js → RequestsContainer-DK3hQVz9.js} +2 -2
  29. package/dist/ui/assets/{RequetsTable-D2qBWqFN.js → RequetsTable-DgP8p60b.js} +1 -1
  30. package/dist/ui/assets/{StatusCode-BZGwjlgz.js → StatusCode-FQEjz7gK.js} +1 -1
  31. package/dist/ui/assets/{TabbedDataViewer-CmztxF70.js → TabbedDataViewer-cBDdPwIz.js} +1 -1
  32. package/dist/ui/assets/{Table-DF4sxTNg.js → Table-DYaXk80S.js} +2 -2
  33. package/dist/ui/assets/favicon-CwRXoGYE.ico +0 -0
  34. package/dist/ui/assets/{index-Dzy6B_ZD.js → index-BS8XxorB.js} +11 -11
  35. package/dist/ui/assets/{index-byVaIWe8.js → index-CpP2Ap5X.js} +1 -1
  36. package/dist/ui/assets/{useLensApi-CkgX8mtY.js → useLensApi-DG6atd6d.js} +1 -1
  37. package/dist/ui/assets/{useLoadMore-BRca6vvh.js → useLoadMore-CJltToLI.js} +1 -1
  38. package/dist/ui/assets/{useQueries-CVt1cLYV.js → useQueries-C8mDDDc6.js} +1 -1
  39. package/dist/ui/favicon.ico +0 -0
  40. package/dist/ui/index.html +2 -2
  41. package/dist/utils/event_emitter.cjs +42 -6
  42. package/dist/utils/event_emitter.js +5 -4
  43. package/dist/utils/index.cjs +163 -23
  44. package/dist/utils/index.js +109 -12
  45. package/dist/watchers/index.cjs +105 -10
  46. package/dist/watchers/index.js +79 -12
  47. package/dist/watchers/query_watcher.cjs +78 -8
  48. package/dist/watchers/query_watcher.js +55 -8
  49. package/dist/watchers/request_watcher.cjs +90 -8
  50. package/dist/watchers/request_watcher.js +67 -8
  51. package/package.json +3 -3
  52. package/dist/chunk-2HRVJRKV.cjs +0 -10
  53. package/dist/chunk-45JBO7ME.cjs +0 -120
  54. package/dist/chunk-4HLDYZJA.js +0 -34
  55. package/dist/chunk-66RDYK2I.js +0 -9
  56. package/dist/chunk-75ZPJI57.cjs +0 -9
  57. package/dist/chunk-7EKM5HB5.cjs +0 -1
  58. package/dist/chunk-7FBZAVQ3.cjs +0 -138
  59. package/dist/chunk-7MOTQS6N.cjs +0 -32
  60. package/dist/chunk-BL4Z6JFH.cjs +0 -34
  61. package/dist/chunk-CGPET47D.cjs +0 -129
  62. package/dist/chunk-CQ2Z4TCR.js +0 -7
  63. package/dist/chunk-EHOWCXZV.cjs +0 -7
  64. package/dist/chunk-EKG3FVLV.cjs +0 -7
  65. package/dist/chunk-FKMBNWX4.js +0 -7
  66. package/dist/chunk-FLOVBBFU.js +0 -10
  67. package/dist/chunk-GI7SJDNQ.cjs +0 -38
  68. package/dist/chunk-HLBMQ3ID.js +0 -120
  69. package/dist/chunk-HMBQ2DF7.js +0 -129
  70. package/dist/chunk-JTRKNE5Q.js +0 -32
  71. package/dist/chunk-JZ2JLQXL.cjs +0 -87
  72. package/dist/chunk-MLKGABMK.js +0 -9
  73. package/dist/chunk-NUSVID2Q.cjs +0 -9
  74. package/dist/chunk-QRZUNYF6.cjs +0 -16
  75. package/dist/chunk-SJXZARBJ.cjs +0 -22
  76. package/dist/chunk-TJDE6AZM.js +0 -87
  77. package/dist/chunk-UF5HFNMI.js +0 -22
  78. package/dist/chunk-VD5IMUWL.js +0 -0
  79. package/dist/chunk-XXYRWHSQ.js +0 -0
  80. package/dist/chunk-XYXPHWEI.js +0 -16
  81. package/dist/chunk-XZFXXD3A.cjs +0 -1
  82. package/dist/chunk-YC6T4XWI.js +0 -38
  83. package/dist/chunk-YXSPADWE.js +0 -138
  84. package/dist/ui/assets/QueriesContainer-DhnU1ndx.js +0 -2
  85. package/dist/ui/assets/favicon-D0UnoCWN.ico +0 -0
@@ -1,23 +1,163 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
- var _chunk7FBZAVQ3cjs = require('../chunk-7FBZAVQ3.cjs');
12
- require('../chunk-75ZPJI57.cjs');
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
- exports.formatSqlQuery = _chunk7FBZAVQ3cjs.formatSqlQuery; exports.generateRandomUuid = _chunk7FBZAVQ3cjs.generateRandomUuid; exports.getMeta = _chunk7FBZAVQ3cjs.getMeta; exports.interpolateQuery = _chunk7FBZAVQ3cjs.interpolateQuery; exports.isStaticFile = _chunk7FBZAVQ3cjs.isStaticFile; exports.prepareIgnoredPaths = _chunk7FBZAVQ3cjs.prepareIgnoredPaths; exports.prettyHrTime = _chunk7FBZAVQ3cjs.prettyHrTime; exports.shouldIgnoreCurrentPath = _chunk7FBZAVQ3cjs.shouldIgnoreCurrentPath; exports.stripBeforeAssetsPath = _chunk7FBZAVQ3cjs.stripBeforeAssetsPath;
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/utils/index.ts
31
+ var utils_exports = {};
32
+ __export(utils_exports, {
33
+ formatSqlQuery: () => formatSqlQuery,
34
+ generateRandomUuid: () => generateRandomUuid,
35
+ getMeta: () => getMeta,
36
+ interpolateQuery: () => interpolateQuery,
37
+ isStaticFile: () => isStaticFile,
38
+ prepareIgnoredPaths: () => prepareIgnoredPaths,
39
+ prettyHrTime: () => prettyHrTime,
40
+ shouldIgnoreCurrentPath: () => shouldIgnoreCurrentPath,
41
+ stripBeforeAssetsPath: () => stripBeforeAssetsPath
42
+ });
43
+ module.exports = __toCommonJS(utils_exports);
44
+ var import_luxon = require("luxon");
45
+ var import_sql_formatter = require("sql-formatter");
46
+ var import_crypto = require("crypto");
47
+ var import_url = require("url");
48
+ var path = __toESM(require("path"), 1);
49
+ var generateRandomUuid = () => {
50
+ return (0, import_crypto.randomUUID)();
51
+ };
52
+ function interpolateQuery(query, bindings) {
53
+ const formatValue = (value) => {
54
+ if (value === null || value === void 0) return "NULL";
55
+ if (typeof value === "string") return `'${value.replace(/'/g, "''")}'`;
56
+ if (value instanceof import_luxon.DateTime) return `'${value.toISO()}'`;
57
+ if (value instanceof Date) return `'${value.toISOString()}'`;
58
+ if (Array.isArray(value))
59
+ return value.map((v) => typeof v === "string" ? `'${v.replace(/'/g, "''")}'` : v).join(", ");
60
+ if (typeof value === "object")
61
+ return `'${JSON.stringify(value).replace(/'/g, "''")}'`;
62
+ return value.toString();
63
+ };
64
+ if (Array.isArray(bindings)) {
65
+ let i = 0;
66
+ return query.replace(/\?/g, () => {
67
+ if (i >= bindings.length)
68
+ throw new Error("Not enough bindings for placeholders");
69
+ return formatValue(bindings[i++]);
70
+ });
71
+ }
72
+ return query.replace(/(\$|\:)(\w+)/g, (match, prefix, keyOrIndex) => {
73
+ let value;
74
+ if (prefix === "$" && /^\d+$/.test(keyOrIndex)) {
75
+ const index = parseInt(keyOrIndex, 10) - 1;
76
+ const keys = Object.keys(bindings);
77
+ if (index < 0 || index >= keys.length)
78
+ throw new Error(`Missing binding for ${match}`);
79
+ value = bindings[keys[index]];
80
+ } else {
81
+ if (!(keyOrIndex in bindings))
82
+ throw new Error(`Missing binding for ${match}`);
83
+ value = bindings[keyOrIndex];
84
+ }
85
+ return formatValue(value);
86
+ });
87
+ }
88
+ var formatSqlQuery = (query, language) => {
89
+ return (0, import_sql_formatter.format)(query, {
90
+ language,
91
+ dataTypeCase: "upper",
92
+ keywordCase: "upper",
93
+ functionCase: "upper"
94
+ });
95
+ };
96
+ function getMeta(metaUrl) {
97
+ const isESM = typeof __dirname === "undefined";
98
+ if (isESM) {
99
+ if (!metaUrl) {
100
+ throw new Error("In ESM, you must pass import.meta.url to getMeta()");
101
+ }
102
+ const __filename2 = (0, import_url.fileURLToPath)(metaUrl);
103
+ const __dirname2 = path.dirname(__filename2);
104
+ return { __filename: __filename2, __dirname: __dirname2 };
105
+ } else {
106
+ return { __filename, __dirname };
107
+ }
108
+ }
109
+ function isStaticFile(params) {
110
+ return params.includes("assets");
111
+ }
112
+ function stripBeforeAssetsPath(url) {
113
+ const match = url.match(/assets.*/);
114
+ return match ? match[0] : url;
115
+ }
116
+ function prepareIgnoredPaths(path2, ignoredPaths) {
117
+ const normalizedPath = path2.replace(/^\/+|\/+$/g, "");
118
+ ignoredPaths = [
119
+ ...ignoredPaths,
120
+ new RegExp(`^/?${normalizedPath}(/|$)`),
121
+ /^\/?lens-config$/,
122
+ /^\/\.well-known\//
123
+ ];
124
+ return { ignoredPaths, normalizedPath };
125
+ }
126
+ function shouldIgnoreCurrentPath(path2, ignoredPaths, onlyPaths) {
127
+ if (onlyPaths.length > 0) {
128
+ return !onlyPaths.some((pattern) => pattern.test(path2));
129
+ }
130
+ return ignoredPaths.some((pattern) => pattern.test(path2));
131
+ }
132
+ function prettyHrTime(hrtime, verbose = false) {
133
+ const seconds = hrtime[0];
134
+ const nanoseconds = hrtime[1];
135
+ const ms = seconds * 1e3 + nanoseconds / 1e6;
136
+ if (verbose) {
137
+ if (seconds > 60) {
138
+ const minutes = Math.floor(seconds / 60);
139
+ const remainingSeconds = seconds % 60;
140
+ return `${minutes}m ${remainingSeconds}s`;
141
+ }
142
+ if (seconds >= 1) {
143
+ return `${seconds}.${Math.floor(nanoseconds / 1e7)}s`;
144
+ }
145
+ return `${ms.toFixed(3)} ms`;
146
+ }
147
+ if (ms < 1e3) {
148
+ return `${ms.toFixed(0)} ms`;
149
+ }
150
+ return `${(ms / 1e3).toFixed(1)} s`;
151
+ }
152
+ // Annotate the CommonJS export names for ESM import in node:
153
+ 0 && (module.exports = {
154
+ formatSqlQuery,
155
+ generateRandomUuid,
156
+ getMeta,
157
+ interpolateQuery,
158
+ isStaticFile,
159
+ prepareIgnoredPaths,
160
+ prettyHrTime,
161
+ shouldIgnoreCurrentPath,
162
+ stripBeforeAssetsPath
163
+ });
@@ -1,15 +1,112 @@
1
- import {
2
- formatSqlQuery,
3
- generateRandomUuid,
4
- getMeta,
5
- interpolateQuery,
6
- isStaticFile,
7
- prepareIgnoredPaths,
8
- prettyHrTime,
9
- shouldIgnoreCurrentPath,
10
- stripBeforeAssetsPath
11
- } from "../chunk-YXSPADWE.js";
12
- 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
+ }
13
110
  export {
14
111
  formatSqlQuery,
15
112
  generateRandomUuid,
@@ -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
  };