@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,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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensjs/core",
3
- "version": "1.0.8",
3
+ "version": "1.0.11",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  "@types/luxon": "^3.7.1",
22
22
  "cross-env": "^10.0.0",
23
23
  "vitest": "^3.2.4",
24
- "@repo/typescript-config": "0.0.1"
24
+ "@lensjs/typescript-config": "1.0.11"
25
25
  },
26
26
  "dependencies": {
27
27
  "emittery": "^1.2.0",
@@ -30,7 +30,7 @@
30
30
  "rimraf": "^6.0.1",
31
31
  "sql-formatter": "^15.6.6",
32
32
  "tailwind-merge": "^3.3.1",
33
- "@repo/date": "0.0.1"
33
+ "@lensjs/date": "1.0.11"
34
34
  },
35
35
  "gitHead": "a229fde5700970ec290ff31f1e3b7d84cc56d325",
36
36
  "scripts": {
@@ -1,10 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/types/index.ts
2
- var WatcherTypeEnum = /* @__PURE__ */ ((WatcherTypeEnum2) => {
3
- WatcherTypeEnum2["REQUEST"] = "request";
4
- WatcherTypeEnum2["QUERY"] = "query";
5
- return WatcherTypeEnum2;
6
- })(WatcherTypeEnum || {});
7
-
8
-
9
-
10
- exports.WatcherTypeEnum = WatcherTypeEnum;
@@ -1,120 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
-
3
- var _chunkEHOWCXZVcjs = require('./chunk-EHOWCXZV.cjs');
4
-
5
- // src/stores/better_sqlite.ts
6
- var _crypto = require('crypto');
7
- var _libsql = require('libsql'); var _libsql2 = _interopRequireDefault(_libsql);
8
- var _date = require('@repo/date');
9
- var TABLE_NAME = "lens_entries";
10
- var BetterSqliteStore = class extends _chunkEHOWCXZVcjs.Store {
11
-
12
- async initialize() {
13
- this.connection = new (0, _libsql2.default)("lens.db");
14
- this.setupSchema();
15
- console.log("Connected to Lens (SQLite) database.");
16
- }
17
- async truncate() {
18
- this.connection.prepare(`DELETE FROM ${TABLE_NAME};`).run();
19
- }
20
- async save(entry) {
21
- this.connection.prepare(
22
- `INSERT INTO ${TABLE_NAME} (id, data, type, created_at, lens_entry_id, minimal_data) values($id, $data, $type, $created_at, $lens_entry_id, $minimalData)`
23
- ).run({
24
- id: _nullishCoalesce(entry.id, () => ( _crypto.randomUUID.call(void 0, ))),
25
- data: JSON.stringify(entry.data),
26
- type: entry.type,
27
- created_at: _nullishCoalesce(entry.timestamp, () => ( _date.sqlDateTime.call(void 0, ))),
28
- lens_entry_id: entry.requestId || null,
29
- minimalData: JSON.stringify(_nullishCoalesce(entry.minimal_data, () => ( {})))
30
- });
31
- }
32
- async getAllQueries(pagination) {
33
- return await this.paginate("query" /* QUERY */, pagination);
34
- }
35
- async getAllRequests(pagination) {
36
- return await this.paginate("request" /* REQUEST */, pagination, false);
37
- }
38
- async allByRequestId(requestId, type) {
39
- const rows = this.connection.prepare(
40
- `${this.getSelectedColumns()} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
41
- ).all({ type, requestId });
42
- return this.mapRows(rows);
43
- }
44
- async paginate(type, { page, perPage }, includeFullData = true) {
45
- const offset = (page - 1) * perPage;
46
- const query = `${this.getSelectedColumns(
47
- includeFullData
48
- )} FROM ${TABLE_NAME} WHERE type = ? ORDER BY created_at DESC LIMIT ? OFFSET ?`;
49
- const count = await this.count(type);
50
- const rows = this.connection.prepare(query).all(type, perPage, offset);
51
- const mappedRows = this.mapRows(rows, includeFullData);
52
- return {
53
- meta: {
54
- total: count,
55
- lastPage: Math.ceil(count / perPage),
56
- currentPage: page
57
- },
58
- data: mappedRows
59
- };
60
- }
61
- async count(type) {
62
- const result = this.connection.prepare(`SELECT count(*) as count FROM ${TABLE_NAME} WHERE type = ?`).get(type);
63
- return Number(result.count);
64
- }
65
- async find(type, id) {
66
- const row = this.connection.prepare(
67
- `${this.getSelectedColumns()} FROM ${TABLE_NAME} WHERE id = ? AND type = ? LIMIT 1`
68
- ).get(id, type);
69
- if (!row) {
70
- return null;
71
- }
72
- return this.mapRow(row, true);
73
- }
74
- setupSchema() {
75
- const createTable = `
76
- CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
77
- id TEXT PRIMARY KEY,
78
- minimal_data TEXT,
79
- data TEXT NOT NULL,
80
- type TEXT NOT NULL,
81
- created_at TEXT NOT NULL,
82
- updated_at TEXT,
83
- lens_entry_id TEXT NULL
84
- );
85
- `;
86
- const createIndex = `
87
- CREATE INDEX IF NOT EXISTS lens_entries_id_type_index
88
- ON ${TABLE_NAME} (id, type);
89
- `;
90
- this.connection.exec(createTable);
91
- this.connection.exec(createIndex);
92
- }
93
- mapRow(row, includeFullData = true) {
94
- let data = includeFullData ? JSON.parse(row.data) : {};
95
- if (!includeFullData) {
96
- data = JSON.parse(row.minimal_data);
97
- }
98
- return {
99
- id: row.id,
100
- type: row.type,
101
- created_at: row.created_at,
102
- lens_entry_id: row.lens_entry_id,
103
- data
104
- };
105
- }
106
- mapRows(rows, includeFullData = true) {
107
- let mappedRows = [];
108
- for (const row of rows) {
109
- mappedRows.push(this.mapRow(row, includeFullData));
110
- }
111
- return mappedRows;
112
- }
113
- getSelectedColumns(includeFullData = true) {
114
- return `SELECT id, minimal_data, type, created_at, lens_entry_id ${includeFullData ? ",data" : ""}`;
115
- }
116
- };
117
-
118
-
119
-
120
- exports.BetterSqliteStore = BetterSqliteStore;
@@ -1,34 +0,0 @@
1
- import {
2
- getStore
3
- } from "./chunk-XYXPHWEI.js";
4
- import {
5
- Watcher
6
- } from "./chunk-CQ2Z4TCR.js";
7
-
8
- // src/watchers/request_watcher.ts
9
- var RequestWatcher = class extends Watcher {
10
- name = "request" /* REQUEST */;
11
- async log(data) {
12
- await getStore().save({
13
- id: data.request.id,
14
- type: this.name,
15
- minimal_data: {
16
- id: data.request.id,
17
- method: data.request.method,
18
- path: data.request.path,
19
- duration: data.request.duration,
20
- createdAt: data.request.createdAt,
21
- status: data.request.status
22
- },
23
- data: {
24
- ...data.request,
25
- user: data.user,
26
- response: data.response
27
- }
28
- });
29
- }
30
- };
31
-
32
- export {
33
- RequestWatcher
34
- };
@@ -1,9 +0,0 @@
1
- // src/utils/event_emitter.ts
2
- import Emittery from "emittery";
3
- var createEmittery = () => {
4
- return new Emittery();
5
- };
6
-
7
- export {
8
- createEmittery
9
- };
@@ -1,9 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
5
- };
6
-
7
-
8
-
9
- exports.__export = __export;
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,138 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
2
-
3
- var _chunk75ZPJI57cjs = require('./chunk-75ZPJI57.cjs');
4
-
5
- // src/utils/index.ts
6
- var utils_exports = {};
7
- _chunk75ZPJI57cjs.__export.call(void 0, 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
- var _luxon = require('luxon');
19
- var _sqlformatter = require('sql-formatter');
20
- var _crypto = require('crypto');
21
- var _url = require('url');
22
- var _path = require('path'); var path = _interopRequireWildcard(_path);
23
- var generateRandomUuid = () => {
24
- return _crypto.randomUUID.call(void 0, );
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 _luxon.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 _sqlformatter.format.call(void 0, 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 = _url.fileURLToPath.call(void 0, 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
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
- exports.generateRandomUuid = generateRandomUuid; exports.interpolateQuery = interpolateQuery; exports.formatSqlQuery = formatSqlQuery; exports.getMeta = getMeta; exports.isStaticFile = isStaticFile; exports.stripBeforeAssetsPath = stripBeforeAssetsPath; exports.prepareIgnoredPaths = prepareIgnoredPaths; exports.shouldIgnoreCurrentPath = shouldIgnoreCurrentPath; exports.prettyHrTime = prettyHrTime; exports.utils_exports = utils_exports;
@@ -1,32 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
-
3
- var _chunk7FBZAVQ3cjs = require('./chunk-7FBZAVQ3.cjs');
4
-
5
- // src/abstracts/adapter.ts
6
- var Adapter = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this); }
7
- __init() {this.watchers = []}
8
- __init2() {this.ignoredPaths = []}
9
- __init3() {this.onlyPaths = []}
10
- setWatchers(watchers) {
11
- this.watchers = watchers;
12
- return this;
13
- }
14
- setIgnoredPaths(paths) {
15
- this.ignoredPaths = paths;
16
- return this;
17
- }
18
- setOnlyPaths(paths) {
19
- this.onlyPaths = paths;
20
- return this;
21
- }
22
- getWatchers() {
23
- return this.watchers;
24
- }
25
- shouldIgnorePath(path) {
26
- return _chunk7FBZAVQ3cjs.shouldIgnoreCurrentPath.call(void 0, path, this.ignoredPaths, this.onlyPaths);
27
- }
28
- }, _class);
29
-
30
-
31
-
32
- exports.Adapter = Adapter;
@@ -1,34 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
-
3
- var _chunkQRZUNYF6cjs = require('./chunk-QRZUNYF6.cjs');
4
-
5
-
6
- var _chunkEKG3FVLVcjs = require('./chunk-EKG3FVLV.cjs');
7
-
8
- // src/watchers/request_watcher.ts
9
- var RequestWatcher = (_class = class extends _chunkEKG3FVLVcjs.Watcher {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
10
- __init() {this.name = "request"} /* REQUEST */
11
- async log(data) {
12
- await _chunkQRZUNYF6cjs.getStore.call(void 0, ).save({
13
- id: data.request.id,
14
- type: this.name,
15
- minimal_data: {
16
- id: data.request.id,
17
- method: data.request.method,
18
- path: data.request.path,
19
- duration: data.request.duration,
20
- createdAt: data.request.createdAt,
21
- status: data.request.status
22
- },
23
- data: {
24
- ...data.request,
25
- user: data.user,
26
- response: data.response
27
- }
28
- });
29
- }
30
- }, _class);
31
-
32
-
33
-
34
- exports.RequestWatcher = RequestWatcher;