@lensjs/core 1.0.1 → 1.0.2

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 (197) hide show
  1. package/dist/abstracts/adapter.cjs +8 -0
  2. package/dist/abstracts/adapter.d.cts +19 -0
  3. package/dist/abstracts/adapter.d.ts +19 -0
  4. package/dist/abstracts/adapter.js +8 -0
  5. package/dist/abstracts/store.cjs +7 -0
  6. package/dist/abstracts/store.d.cts +23 -0
  7. package/dist/abstracts/store.d.ts +23 -0
  8. package/dist/abstracts/store.js +7 -0
  9. package/dist/chunk-2HRVJRKV.cjs +10 -0
  10. package/dist/chunk-3R5QARPT.cjs +14 -0
  11. package/{src/watchers/request_watcher.ts → dist/chunk-4HLDYZJA.js} +18 -11
  12. package/dist/chunk-5PYQWLAZ.js +129 -0
  13. package/dist/chunk-75ZPJI57.cjs +9 -0
  14. package/dist/chunk-7EKM5HB5.cjs +1 -0
  15. package/dist/chunk-AUDSBNLF.cjs +122 -0
  16. package/dist/chunk-BFFOUTTE.cjs +32 -0
  17. package/dist/chunk-BL4Z6JFH.cjs +34 -0
  18. package/dist/chunk-CQ2Z4TCR.js +7 -0
  19. package/dist/chunk-EHOWCXZV.cjs +7 -0
  20. package/{src/utils/index.ts → dist/chunk-EJ5BW35V.js} +69 -86
  21. package/dist/chunk-EKG3FVLV.cjs +7 -0
  22. package/dist/chunk-FCMQ3WE3.cjs +129 -0
  23. package/dist/chunk-FKMBNWX4.js +7 -0
  24. package/dist/chunk-FLOVBBFU.js +10 -0
  25. package/dist/chunk-GI7SJDNQ.cjs +38 -0
  26. package/dist/chunk-IPMTMCFP.js +122 -0
  27. package/dist/chunk-JZ2JLQXL.cjs +87 -0
  28. package/dist/chunk-MLKGABMK.js +9 -0
  29. package/dist/chunk-QRZUNYF6.cjs +16 -0
  30. package/dist/chunk-RMZ4UAQ2.js +14 -0
  31. package/dist/chunk-SJXZARBJ.cjs +22 -0
  32. package/dist/chunk-TJDE6AZM.js +87 -0
  33. package/dist/chunk-TPUVRGYT.js +32 -0
  34. package/dist/chunk-UF5HFNMI.js +22 -0
  35. package/dist/chunk-VD5IMUWL.js +0 -0
  36. package/dist/chunk-WU6IZUEV.cjs +159 -0
  37. package/dist/chunk-XXYRWHSQ.js +0 -0
  38. package/dist/chunk-XYXPHWEI.js +16 -0
  39. package/dist/chunk-XZFXXD3A.cjs +1 -0
  40. package/dist/chunk-YC6T4XWI.js +38 -0
  41. package/dist/context/container.cjs +7 -0
  42. package/dist/context/container.d.cts +28 -0
  43. package/dist/context/container.d.ts +28 -0
  44. package/dist/context/container.js +7 -0
  45. package/dist/context/context.cjs +10 -0
  46. package/dist/context/context.d.cts +15 -0
  47. package/dist/context/context.d.ts +15 -0
  48. package/dist/context/context.js +10 -0
  49. package/dist/core/api_controller.cjs +10 -0
  50. package/dist/core/api_controller.d.cts +25 -0
  51. package/dist/core/api_controller.d.ts +25 -0
  52. package/dist/core/api_controller.js +10 -0
  53. package/dist/core/lens.cjs +15 -0
  54. package/dist/core/lens.d.cts +24 -0
  55. package/dist/core/lens.d.ts +24 -0
  56. package/dist/core/lens.js +15 -0
  57. package/dist/core/watcher.cjs +7 -0
  58. package/dist/core/watcher.d.cts +9 -0
  59. package/dist/core/watcher.d.ts +9 -0
  60. package/dist/core/watcher.js +7 -0
  61. package/dist/index-D0Vszdac.d.cts +49 -0
  62. package/dist/index-D0Vszdac.d.ts +49 -0
  63. package/dist/index.cjs +55 -0
  64. package/dist/index.d.cts +16 -0
  65. package/dist/index.d.ts +16 -0
  66. package/dist/index.js +55 -0
  67. package/dist/stores/better_sqlite.cjs +10 -0
  68. package/dist/stores/better_sqlite.d.cts +51 -0
  69. package/dist/stores/better_sqlite.d.ts +51 -0
  70. package/dist/stores/better_sqlite.js +10 -0
  71. package/dist/stores/index.cjs +11 -0
  72. package/dist/stores/index.d.cts +5 -0
  73. package/dist/stores/index.d.ts +5 -0
  74. package/dist/stores/index.js +11 -0
  75. package/dist/types/index.cjs +7 -0
  76. package/dist/types/index.d.cts +91 -0
  77. package/dist/types/index.d.ts +91 -0
  78. package/dist/types/index.js +7 -0
  79. package/dist/ui/assets/QueriesContainer-Bxr99HkT.js +2 -0
  80. package/dist/ui/assets/QueryDetailsContainer-BcbxQyxT.js +48 -0
  81. package/dist/ui/assets/QueryTable-Dx1MyXwe.js +1 -0
  82. package/dist/ui/assets/RequestDetails-B9rQn1tY.js +1 -0
  83. package/dist/ui/assets/RequestDetailsContainer-C0sOvaO2.js +2 -0
  84. package/dist/ui/assets/RequestsContainer-DYNNLt6S.js +2 -0
  85. package/dist/ui/assets/RequetsTable-BN-1fud-.js +1 -0
  86. package/dist/ui/assets/StatusCode-ByIHR7Pe.js +1 -0
  87. package/dist/ui/assets/TabbedDataViewer-CoLeLuBm.js +1 -0
  88. package/dist/ui/assets/Table-CXg4Wfwf.js +6 -0
  89. package/dist/ui/assets/date-BXZFS9Wq.js +1 -0
  90. package/dist/ui/assets/index-BPTSPdZM.css +1 -0
  91. package/dist/ui/assets/index-C3XpMOuU.js +114 -0
  92. package/dist/ui/assets/useLensApi-BlL4RwJa.js +1 -0
  93. package/dist/ui/assets/useLoadMore-BqF649Mm.js +1 -0
  94. package/dist/ui/assets/useQueries-Iwl8o-Xk.js +1 -0
  95. package/dist/ui/favicon.ico +0 -0
  96. package/dist/ui/index.html +14 -0
  97. package/dist/utils/event_emitter.cjs +11 -0
  98. package/dist/utils/event_emitter.d.cts +16 -0
  99. package/dist/utils/event_emitter.d.ts +16 -0
  100. package/dist/utils/event_emitter.js +11 -0
  101. package/dist/utils/index.cjs +31 -0
  102. package/dist/utils/index.d.cts +3 -0
  103. package/dist/utils/index.d.ts +3 -0
  104. package/dist/utils/index.js +31 -0
  105. package/dist/watchers/index.cjs +16 -0
  106. package/dist/watchers/index.d.cts +5 -0
  107. package/dist/watchers/index.d.ts +5 -0
  108. package/dist/watchers/index.js +16 -0
  109. package/dist/watchers/query_watcher.cjs +11 -0
  110. package/dist/watchers/query_watcher.d.cts +10 -0
  111. package/dist/watchers/query_watcher.d.ts +10 -0
  112. package/dist/watchers/query_watcher.js +11 -0
  113. package/dist/watchers/request_watcher.cjs +11 -0
  114. package/dist/watchers/request_watcher.d.cts +10 -0
  115. package/dist/watchers/request_watcher.d.ts +10 -0
  116. package/dist/watchers/request_watcher.js +11 -0
  117. package/package.json +4 -1
  118. package/copy-front-build.cjs +0 -16
  119. package/src/abstracts/adapter.ts +0 -41
  120. package/src/abstracts/store.ts +0 -36
  121. package/src/context/container.ts +0 -67
  122. package/src/context/context.ts +0 -9
  123. package/src/core/api_controller.ts +0 -116
  124. package/src/core/lens.ts +0 -147
  125. package/src/core/watcher.ts +0 -6
  126. package/src/index.ts +0 -11
  127. package/src/stores/better_sqlite.ts +0 -176
  128. package/src/stores/index.ts +0 -1
  129. package/src/types/index.ts +0 -103
  130. package/src/ui/README.md +0 -69
  131. package/src/ui/bun.lock +0 -750
  132. package/src/ui/eslint.config.js +0 -27
  133. package/src/ui/index.html +0 -13
  134. package/src/ui/package-lock.json +0 -2953
  135. package/src/ui/package.json +0 -40
  136. package/src/ui/src/App.tsx +0 -40
  137. package/src/ui/src/components/DetailPanel.tsx +0 -70
  138. package/src/ui/src/components/JsonViewer.tsx +0 -232
  139. package/src/ui/src/components/LoadMore.tsx +0 -25
  140. package/src/ui/src/components/MethodBadge.tsx +0 -19
  141. package/src/ui/src/components/Modal.tsx +0 -48
  142. package/src/ui/src/components/StatusCode.tsx +0 -20
  143. package/src/ui/src/components/Table.tsx +0 -127
  144. package/src/ui/src/components/layout/DeleteButton.tsx +0 -60
  145. package/src/ui/src/components/layout/Footer.tsx +0 -12
  146. package/src/ui/src/components/layout/Header.tsx +0 -40
  147. package/src/ui/src/components/layout/Layout.tsx +0 -49
  148. package/src/ui/src/components/layout/LoadingScreen.tsx +0 -14
  149. package/src/ui/src/components/layout/Sidebar.tsx +0 -67
  150. package/src/ui/src/components/queryFormatters/MongoViewer.tsx +0 -92
  151. package/src/ui/src/components/queryFormatters/QueryViewer.tsx +0 -18
  152. package/src/ui/src/components/queryFormatters/SqlViewer.tsx +0 -105
  153. package/src/ui/src/components/table/NoData.tsx +0 -26
  154. package/src/ui/src/components/tabs/TabbedDataViewer.tsx +0 -77
  155. package/src/ui/src/containers/queries/QueriesContainer.tsx +0 -21
  156. package/src/ui/src/containers/queries/QueryDetailsContainer.tsx +0 -15
  157. package/src/ui/src/containers/requests/RequestDetailsContainer.tsx +0 -16
  158. package/src/ui/src/containers/requests/RequestsContainer.tsx +0 -22
  159. package/src/ui/src/hooks/useLensApi.ts +0 -92
  160. package/src/ui/src/hooks/useLoadMore.ts +0 -48
  161. package/src/ui/src/hooks/useQueries.ts +0 -58
  162. package/src/ui/src/hooks/useRequests.ts +0 -79
  163. package/src/ui/src/hooks/useTanstackApi.ts +0 -126
  164. package/src/ui/src/index.css +0 -78
  165. package/src/ui/src/interfaces/index.ts +0 -10
  166. package/src/ui/src/main.tsx +0 -33
  167. package/src/ui/src/router/Router.ts +0 -11
  168. package/src/ui/src/router/routes/Loading.tsx +0 -5
  169. package/src/ui/src/router/routes/index.tsx +0 -85
  170. package/src/ui/src/types/index.ts +0 -95
  171. package/src/ui/src/utils/api.ts +0 -7
  172. package/src/ui/src/utils/context.ts +0 -24
  173. package/src/ui/src/utils/date.ts +0 -36
  174. package/src/ui/src/views/queries/QueryDetails.tsx +0 -58
  175. package/src/ui/src/views/queries/QueryTable.tsx +0 -21
  176. package/src/ui/src/views/queries/columns.tsx +0 -83
  177. package/src/ui/src/views/requests/BasicRequestDetails.tsx +0 -82
  178. package/src/ui/src/views/requests/RequestDetails.tsx +0 -70
  179. package/src/ui/src/views/requests/RequetsTable.tsx +0 -19
  180. package/src/ui/src/views/requests/columns.tsx +0 -62
  181. package/src/ui/src/vite-env.d.ts +0 -1
  182. package/src/ui/tsconfig.app.json +0 -27
  183. package/src/ui/tsconfig.json +0 -7
  184. package/src/ui/tsconfig.node.json +0 -25
  185. package/src/ui/vite.config.ts +0 -9
  186. package/src/utils/event_emitter.ts +0 -13
  187. package/src/watchers/index.ts +0 -2
  188. package/src/watchers/query_watcher.ts +0 -15
  189. package/tests/core/lens.test.ts +0 -89
  190. package/tests/stores/better_sqlite.test.ts +0 -168
  191. package/tests/utils/index.test.ts +0 -182
  192. package/tests/watchers/query_watcher.test.ts +0 -35
  193. package/tests/watchers/request_watcher.test.ts +0 -59
  194. package/tsconfig.json +0 -3
  195. package/tsup.config.ts +0 -15
  196. package/vitest.config.ts +0 -9
  197. /package/{src/ui/public/favicon.ico → dist/ui/assets/favicon-D0UnoCWN.ico} +0 -0
@@ -0,0 +1,22 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
2
+
3
+ var _chunkQRZUNYF6cjs = require('./chunk-QRZUNYF6.cjs');
4
+
5
+
6
+ var _chunkEKG3FVLVcjs = require('./chunk-EKG3FVLV.cjs');
7
+
8
+ // src/watchers/query_watcher.ts
9
+ var QueryWatcher = (_class = class extends _chunkEKG3FVLVcjs.Watcher {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
10
+ __init() {this.name = "query"} /* QUERY */
11
+ async log(entry) {
12
+ await _chunkQRZUNYF6cjs.getStore.call(void 0, ).save({
13
+ type: this.name,
14
+ data: entry.data,
15
+ requestId: _nullishCoalesce(entry.requestId, () => ( ""))
16
+ });
17
+ }
18
+ }, _class);
19
+
20
+
21
+
22
+ exports.QueryWatcher = QueryWatcher;
@@ -0,0 +1,87 @@
1
+ import {
2
+ getStore,
3
+ getUiConfig
4
+ } from "./chunk-XYXPHWEI.js";
5
+
6
+ // src/core/api_controller.ts
7
+ var ApiController = class {
8
+ static async getRequests({ qs }) {
9
+ return this.paginatedResponse(
10
+ await getStore().getAllRequests(this.extractPaginationParams(qs))
11
+ );
12
+ }
13
+ static async getRequest({
14
+ params
15
+ }) {
16
+ const request = await getStore().find("request" /* REQUEST */, params.id);
17
+ if (!request) {
18
+ return this.notFoundResponse();
19
+ }
20
+ return this.resourceResponse(request);
21
+ }
22
+ static async getQueries({
23
+ qs
24
+ }) {
25
+ const queries = await getStore().getAllQueries(
26
+ this.extractPaginationParams(qs)
27
+ );
28
+ return this.paginatedResponse(queries);
29
+ }
30
+ static async getQuery({
31
+ params
32
+ }) {
33
+ const query = await getStore().find("query" /* QUERY */, params.id);
34
+ if (!query) {
35
+ return this.notFoundResponse();
36
+ }
37
+ return this.resourceResponse(query);
38
+ }
39
+ static async truncate() {
40
+ await getStore().truncate();
41
+ return this.baseResponse({}, 200, "All entries cleared");
42
+ }
43
+ static fetchUiConfig() {
44
+ return getUiConfig();
45
+ }
46
+ static extractPaginationParams(qs) {
47
+ if (!qs || Object.keys(qs).length === 0) {
48
+ return { page: 1, perPage: 100 };
49
+ }
50
+ let page = Number(qs.page);
51
+ let perPage = Number(qs.perPage);
52
+ if (!Number.isInteger(perPage) || perPage > 100 || perPage < 5) {
53
+ perPage = 100;
54
+ }
55
+ if (!Number.isInteger(page) || page < 1) {
56
+ page = 1;
57
+ }
58
+ return { page, perPage };
59
+ }
60
+ static resourceResponse(data) {
61
+ return this.baseResponse(data, 200, "Data fetched successfully");
62
+ }
63
+ static notFoundResponse(message = "Could not find the requested resource") {
64
+ return this.baseResponse(null, 404, message);
65
+ }
66
+ static paginatedResponse(data) {
67
+ return this.baseResponse(data, 200, "Data fetched successfully");
68
+ }
69
+ static baseResponse(data, status, message) {
70
+ if (!data) {
71
+ return { status, message, data: null };
72
+ }
73
+ if ("meta" in data) {
74
+ return {
75
+ status,
76
+ message,
77
+ data: data.data,
78
+ meta: data.meta
79
+ };
80
+ }
81
+ return { status, message, data };
82
+ }
83
+ };
84
+
85
+ export {
86
+ ApiController
87
+ };
@@ -0,0 +1,32 @@
1
+ import {
2
+ shouldIgnoreCurrentPath
3
+ } from "./chunk-EJ5BW35V.js";
4
+
5
+ // src/abstracts/adapter.ts
6
+ var Adapter = class {
7
+ watchers = [];
8
+ ignoredPaths = [];
9
+ 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 shouldIgnoreCurrentPath(path, this.ignoredPaths, this.onlyPaths);
27
+ }
28
+ };
29
+
30
+ export {
31
+ Adapter
32
+ };
@@ -0,0 +1,22 @@
1
+ import {
2
+ getStore
3
+ } from "./chunk-XYXPHWEI.js";
4
+ import {
5
+ Watcher
6
+ } from "./chunk-CQ2Z4TCR.js";
7
+
8
+ // src/watchers/query_watcher.ts
9
+ var QueryWatcher = class extends Watcher {
10
+ name = "query" /* QUERY */;
11
+ async log(entry) {
12
+ await getStore().save({
13
+ type: this.name,
14
+ data: entry.data,
15
+ requestId: entry.requestId ?? ""
16
+ });
17
+ }
18
+ };
19
+
20
+ export {
21
+ QueryWatcher
22
+ };
File without changes
@@ -0,0 +1,159 @@
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 _chunk75ZPJI57cjs = require('./chunk-75ZPJI57.cjs');
4
+
5
+ // src/utils/index.ts
6
+ var utils_exports = {};
7
+ _chunk75ZPJI57cjs.__export.call(void 0, utils_exports, {
8
+ convertToUTC: () => convertToUTC,
9
+ formatSqlQuery: () => formatSqlQuery,
10
+ generateRandomUuid: () => generateRandomUuid,
11
+ getMeta: () => getMeta,
12
+ interpolateQuery: () => interpolateQuery,
13
+ isStaticFile: () => isStaticFile,
14
+ now: () => now,
15
+ nowISO: () => nowISO,
16
+ prepareIgnoredPaths: () => prepareIgnoredPaths,
17
+ prettyHrTime: () => prettyHrTime,
18
+ shouldIgnoreCurrentPath: () => shouldIgnoreCurrentPath,
19
+ sqlDateTime: () => sqlDateTime,
20
+ stripBeforeAssetsPath: () => stripBeforeAssetsPath
21
+ });
22
+ var _luxon = require('luxon');
23
+ var _sqlformatter = require('sql-formatter');
24
+ var _crypto = require('crypto');
25
+ var _url = require('url');
26
+ var _posix = require('path/posix'); var _posix2 = _interopRequireDefault(_posix);
27
+ var generateRandomUuid = () => {
28
+ return _crypto.randomUUID.call(void 0, );
29
+ };
30
+ function interpolateQuery(query, bindings) {
31
+ const formatValue = (value) => {
32
+ if (value === null || value === void 0) return "NULL";
33
+ if (typeof value === "string") return `'${value.replace(/'/g, "''")}'`;
34
+ if (value instanceof _luxon.DateTime) return `'${value.toISO()}'`;
35
+ if (value instanceof Date) return `'${value.toISOString()}'`;
36
+ if (Array.isArray(value))
37
+ return value.map((v) => typeof v === "string" ? `'${v.replace(/'/g, "''")}'` : v).join(", ");
38
+ if (typeof value === "object")
39
+ return `'${JSON.stringify(value).replace(/'/g, "''")}'`;
40
+ return value.toString();
41
+ };
42
+ if (Array.isArray(bindings)) {
43
+ let i = 0;
44
+ return query.replace(/\?/g, () => {
45
+ if (i >= bindings.length)
46
+ throw new Error("Not enough bindings for placeholders");
47
+ return formatValue(bindings[i++]);
48
+ });
49
+ }
50
+ return query.replace(/(\$|\:)(\w+)/g, (match, prefix, keyOrIndex) => {
51
+ let value;
52
+ if (prefix === "$" && /^\d+$/.test(keyOrIndex)) {
53
+ const index = parseInt(keyOrIndex, 10) - 1;
54
+ const keys = Object.keys(bindings);
55
+ if (index < 0 || index >= keys.length)
56
+ throw new Error(`Missing binding for ${match}`);
57
+ value = bindings[keys[index]];
58
+ } else {
59
+ if (!(keyOrIndex in bindings))
60
+ throw new Error(`Missing binding for ${match}`);
61
+ value = bindings[keyOrIndex];
62
+ }
63
+ return formatValue(value);
64
+ });
65
+ }
66
+ var formatSqlQuery = (query, language) => {
67
+ return _sqlformatter.format.call(void 0, query, {
68
+ language,
69
+ dataTypeCase: "upper",
70
+ keywordCase: "upper",
71
+ functionCase: "upper"
72
+ });
73
+ };
74
+ function now() {
75
+ return _luxon.DateTime.now().setZone("utc");
76
+ }
77
+ function nowISO() {
78
+ return now().toISO({ includeOffset: false });
79
+ }
80
+ function sqlDateTime(dateTime) {
81
+ const time = _nullishCoalesce(dateTime, () => ( now()));
82
+ return time.toSQL({ includeOffset: false });
83
+ }
84
+ function convertToUTC(dateTime) {
85
+ return _luxon.DateTime.fromISO(dateTime).setZone("utc").toISO({ includeOffset: false });
86
+ }
87
+ function getMeta(metaUrl) {
88
+ const isESM = typeof __dirname === "undefined";
89
+ if (isESM) {
90
+ if (!metaUrl) {
91
+ throw new Error("In ESM, you must pass import.meta.url to getMeta()");
92
+ }
93
+ const __filename2 = _url.fileURLToPath.call(void 0, metaUrl);
94
+ const __dirname2 = _posix2.default.dirname(__filename2);
95
+ return { __filename: __filename2, __dirname: __dirname2 };
96
+ } else {
97
+ return { __filename, __dirname };
98
+ }
99
+ }
100
+ function isStaticFile(params) {
101
+ return params.includes("assets");
102
+ }
103
+ function stripBeforeAssetsPath(url) {
104
+ const match = url.match(/assets.*/);
105
+ return match ? match[0] : url;
106
+ }
107
+ function prepareIgnoredPaths(path2, ignoredPaths) {
108
+ const normalizedPath = path2.replace(/^\/+|\/+$/g, "");
109
+ ignoredPaths = [
110
+ ...ignoredPaths,
111
+ new RegExp(`^/?${normalizedPath}(/|$)`),
112
+ /^\/?lens-config$/,
113
+ /^\/\.well-known\//
114
+ ];
115
+ return { ignoredPaths, normalizedPath };
116
+ }
117
+ function shouldIgnoreCurrentPath(path2, ignoredPaths, onlyPaths) {
118
+ if (onlyPaths.length > 0) {
119
+ return !onlyPaths.some((pattern) => pattern.test(path2));
120
+ }
121
+ return ignoredPaths.some((pattern) => pattern.test(path2));
122
+ }
123
+ function prettyHrTime(hrtime, verbose = false) {
124
+ const seconds = hrtime[0];
125
+ const nanoseconds = hrtime[1];
126
+ const ms = seconds * 1e3 + nanoseconds / 1e6;
127
+ if (verbose) {
128
+ if (seconds > 60) {
129
+ const minutes = Math.floor(seconds / 60);
130
+ const remainingSeconds = seconds % 60;
131
+ return `${minutes}m ${remainingSeconds}s`;
132
+ }
133
+ if (seconds >= 1) {
134
+ return `${seconds}.${Math.floor(nanoseconds / 1e7)}s`;
135
+ }
136
+ return `${ms.toFixed(3)} ms`;
137
+ }
138
+ if (ms < 1e3) {
139
+ return `${ms.toFixed(0)} ms`;
140
+ }
141
+ return `${(ms / 1e3).toFixed(1)} s`;
142
+ }
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+ exports.generateRandomUuid = generateRandomUuid; exports.interpolateQuery = interpolateQuery; exports.formatSqlQuery = formatSqlQuery; exports.now = now; exports.nowISO = nowISO; exports.sqlDateTime = sqlDateTime; exports.convertToUTC = convertToUTC; exports.getMeta = getMeta; exports.isStaticFile = isStaticFile; exports.stripBeforeAssetsPath = stripBeforeAssetsPath; exports.prepareIgnoredPaths = prepareIgnoredPaths; exports.shouldIgnoreCurrentPath = shouldIgnoreCurrentPath; exports.prettyHrTime = prettyHrTime; exports.utils_exports = utils_exports;
File without changes
@@ -0,0 +1,16 @@
1
+ import {
2
+ Container
3
+ } from "./chunk-YC6T4XWI.js";
4
+
5
+ // src/context/context.ts
6
+ var getStore = () => {
7
+ return Container.make("store");
8
+ };
9
+ var getUiConfig = () => {
10
+ return Container.make("uiConfig");
11
+ };
12
+
13
+ export {
14
+ getStore,
15
+ getUiConfig
16
+ };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,38 @@
1
+ // src/context/container.ts
2
+ var Container = class {
3
+ static bindings = /* @__PURE__ */ new Map();
4
+ static singletons = /* @__PURE__ */ new Map();
5
+ static instances = /* @__PURE__ */ new Map();
6
+ static bind(key, factory) {
7
+ this.bindings.set(key, factory);
8
+ }
9
+ static singleton(key, factory) {
10
+ this.singletons.set(key, factory);
11
+ }
12
+ static make(key) {
13
+ if (this.instances.has(key)) {
14
+ return this.instances.get(key);
15
+ }
16
+ if (this.singletons.has(key)) {
17
+ const instance = this.singletons.get(key)();
18
+ this.instances.set(key, instance);
19
+ return instance;
20
+ }
21
+ if (this.bindings.has(key)) {
22
+ return this.bindings.get(key)();
23
+ }
24
+ throw new Error(`Service "${key}" is not bound in the container`);
25
+ }
26
+ static has(key) {
27
+ return this.bindings.has(key) || this.singletons.has(key) || this.instances.has(key);
28
+ }
29
+ static clear() {
30
+ this.bindings.clear();
31
+ this.singletons.clear();
32
+ this.instances.clear();
33
+ }
34
+ };
35
+
36
+ export {
37
+ Container
38
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkGI7SJDNQcjs = require('../chunk-GI7SJDNQ.cjs');
4
+ require('../chunk-75ZPJI57.cjs');
5
+
6
+
7
+ exports.default = _chunkGI7SJDNQcjs.Container;
@@ -0,0 +1,28 @@
1
+ import Store from '../abstracts/store.cjs';
2
+ import '../types/index.cjs';
3
+ import 'sql-formatter';
4
+
5
+ type Factory<T = any> = () => T;
6
+ type ContextStore = {
7
+ store: Store;
8
+ uiConfig: {
9
+ appName: string;
10
+ path: string;
11
+ api: {
12
+ requests: string;
13
+ queries: string;
14
+ };
15
+ };
16
+ };
17
+ declare class Container {
18
+ private static bindings;
19
+ private static singletons;
20
+ private static instances;
21
+ static bind<K extends keyof ContextStore>(key: K, factory: Factory<ContextStore[K]>): void;
22
+ static singleton<K extends keyof ContextStore>(key: K, factory: Factory<ContextStore[K]>): void;
23
+ static make<K extends keyof ContextStore>(key: K): ContextStore[K];
24
+ static has(key: keyof ContextStore): boolean;
25
+ static clear(): void;
26
+ }
27
+
28
+ export { Container as default };
@@ -0,0 +1,28 @@
1
+ import Store from '../abstracts/store.js';
2
+ import '../types/index.js';
3
+ import 'sql-formatter';
4
+
5
+ type Factory<T = any> = () => T;
6
+ type ContextStore = {
7
+ store: Store;
8
+ uiConfig: {
9
+ appName: string;
10
+ path: string;
11
+ api: {
12
+ requests: string;
13
+ queries: string;
14
+ };
15
+ };
16
+ };
17
+ declare class Container {
18
+ private static bindings;
19
+ private static singletons;
20
+ private static instances;
21
+ static bind<K extends keyof ContextStore>(key: K, factory: Factory<ContextStore[K]>): void;
22
+ static singleton<K extends keyof ContextStore>(key: K, factory: Factory<ContextStore[K]>): void;
23
+ static make<K extends keyof ContextStore>(key: K): ContextStore[K];
24
+ static has(key: keyof ContextStore): boolean;
25
+ static clear(): void;
26
+ }
27
+
28
+ export { Container as default };
@@ -0,0 +1,7 @@
1
+ import {
2
+ Container
3
+ } from "../chunk-YC6T4XWI.js";
4
+ import "../chunk-MLKGABMK.js";
5
+ export {
6
+ Container as default
7
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkQRZUNYF6cjs = require('../chunk-QRZUNYF6.cjs');
5
+ require('../chunk-GI7SJDNQ.cjs');
6
+ require('../chunk-75ZPJI57.cjs');
7
+
8
+
9
+
10
+ exports.getStore = _chunkQRZUNYF6cjs.getStore; exports.getUiConfig = _chunkQRZUNYF6cjs.getUiConfig;
@@ -0,0 +1,15 @@
1
+ import Store from '../abstracts/store.cjs';
2
+ import '../types/index.cjs';
3
+ import 'sql-formatter';
4
+
5
+ declare const getStore: () => Store;
6
+ declare const getUiConfig: () => {
7
+ appName: string;
8
+ path: string;
9
+ api: {
10
+ requests: string;
11
+ queries: string;
12
+ };
13
+ };
14
+
15
+ export { getStore, getUiConfig };
@@ -0,0 +1,15 @@
1
+ import Store from '../abstracts/store.js';
2
+ import '../types/index.js';
3
+ import 'sql-formatter';
4
+
5
+ declare const getStore: () => Store;
6
+ declare const getUiConfig: () => {
7
+ appName: string;
8
+ path: string;
9
+ api: {
10
+ requests: string;
11
+ queries: string;
12
+ };
13
+ };
14
+
15
+ export { getStore, getUiConfig };
@@ -0,0 +1,10 @@
1
+ import {
2
+ getStore,
3
+ getUiConfig
4
+ } from "../chunk-XYXPHWEI.js";
5
+ import "../chunk-YC6T4XWI.js";
6
+ import "../chunk-MLKGABMK.js";
7
+ export {
8
+ getStore,
9
+ getUiConfig
10
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkJZ2JLQXLcjs = require('../chunk-JZ2JLQXL.cjs');
4
+ require('../chunk-2HRVJRKV.cjs');
5
+ require('../chunk-QRZUNYF6.cjs');
6
+ require('../chunk-GI7SJDNQ.cjs');
7
+ require('../chunk-75ZPJI57.cjs');
8
+
9
+
10
+ exports.ApiController = _chunkJZ2JLQXLcjs.ApiController;
@@ -0,0 +1,25 @@
1
+ import { RouteDefinitionHandler, ApiResponse, LensEntry } from '../types/index.cjs';
2
+ import 'sql-formatter';
3
+
4
+ declare class ApiController {
5
+ static getRequests({ qs }: RouteDefinitionHandler): Promise<ApiResponse<Omit<LensEntry, "data">[]>>;
6
+ static getRequest({ params, }: RouteDefinitionHandler): Promise<ApiResponse<LensEntry>>;
7
+ static getQueries({ qs, }: RouteDefinitionHandler): Promise<ApiResponse<LensEntry[]>>;
8
+ static getQuery({ params, }: RouteDefinitionHandler): Promise<ApiResponse<LensEntry>>;
9
+ static truncate(): Promise<ApiResponse<{}>>;
10
+ static fetchUiConfig(): {
11
+ appName: string;
12
+ path: string;
13
+ api: {
14
+ requests: string;
15
+ queries: string;
16
+ };
17
+ };
18
+ private static extractPaginationParams;
19
+ private static resourceResponse;
20
+ private static notFoundResponse;
21
+ private static paginatedResponse;
22
+ private static baseResponse;
23
+ }
24
+
25
+ export { ApiController };
@@ -0,0 +1,25 @@
1
+ import { RouteDefinitionHandler, ApiResponse, LensEntry } from '../types/index.js';
2
+ import 'sql-formatter';
3
+
4
+ declare class ApiController {
5
+ static getRequests({ qs }: RouteDefinitionHandler): Promise<ApiResponse<Omit<LensEntry, "data">[]>>;
6
+ static getRequest({ params, }: RouteDefinitionHandler): Promise<ApiResponse<LensEntry>>;
7
+ static getQueries({ qs, }: RouteDefinitionHandler): Promise<ApiResponse<LensEntry[]>>;
8
+ static getQuery({ params, }: RouteDefinitionHandler): Promise<ApiResponse<LensEntry>>;
9
+ static truncate(): Promise<ApiResponse<{}>>;
10
+ static fetchUiConfig(): {
11
+ appName: string;
12
+ path: string;
13
+ api: {
14
+ requests: string;
15
+ queries: string;
16
+ };
17
+ };
18
+ private static extractPaginationParams;
19
+ private static resourceResponse;
20
+ private static notFoundResponse;
21
+ private static paginatedResponse;
22
+ private static baseResponse;
23
+ }
24
+
25
+ export { ApiController };
@@ -0,0 +1,10 @@
1
+ import {
2
+ ApiController
3
+ } from "../chunk-TJDE6AZM.js";
4
+ import "../chunk-FLOVBBFU.js";
5
+ import "../chunk-XYXPHWEI.js";
6
+ import "../chunk-YC6T4XWI.js";
7
+ import "../chunk-MLKGABMK.js";
8
+ export {
9
+ ApiController
10
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkFCMQ3WE3cjs = require('../chunk-FCMQ3WE3.cjs');
4
+ require('../chunk-XZFXXD3A.cjs');
5
+ require('../chunk-AUDSBNLF.cjs');
6
+ require('../chunk-WU6IZUEV.cjs');
7
+ require('../chunk-EHOWCXZV.cjs');
8
+ require('../chunk-JZ2JLQXL.cjs');
9
+ require('../chunk-2HRVJRKV.cjs');
10
+ require('../chunk-QRZUNYF6.cjs');
11
+ require('../chunk-GI7SJDNQ.cjs');
12
+ require('../chunk-75ZPJI57.cjs');
13
+
14
+
15
+ exports.default = _chunkFCMQ3WE3cjs.Lens;
@@ -0,0 +1,24 @@
1
+ import Store from '../abstracts/store.cjs';
2
+ import Adapter from '../abstracts/adapter.cjs';
3
+ import Watcher from './watcher.cjs';
4
+ import { LensConfig } from '../types/index.cjs';
5
+ import 'sql-formatter';
6
+
7
+ declare class Lens {
8
+ private static watchers;
9
+ private static store;
10
+ private static adapter;
11
+ static watch(watcher: Watcher): typeof Lens;
12
+ static setWatchers(watchers: Watcher[]): typeof Lens;
13
+ static start(config?: LensConfig): Promise<void>;
14
+ static setStore(store: Store): typeof Lens;
15
+ static getStore(): Promise<Store>;
16
+ static setAdapter(adapter: Adapter): typeof Lens;
17
+ static getAdapter(): Adapter;
18
+ private static bindContainerDeps;
19
+ private static getRoutes;
20
+ private static getDefaultStore;
21
+ private static normalizeDirName;
22
+ }
23
+
24
+ export { Lens as default };
@@ -0,0 +1,24 @@
1
+ import Store from '../abstracts/store.js';
2
+ import Adapter from '../abstracts/adapter.js';
3
+ import Watcher from './watcher.js';
4
+ import { LensConfig } from '../types/index.js';
5
+ import 'sql-formatter';
6
+
7
+ declare class Lens {
8
+ private static watchers;
9
+ private static store;
10
+ private static adapter;
11
+ static watch(watcher: Watcher): typeof Lens;
12
+ static setWatchers(watchers: Watcher[]): typeof Lens;
13
+ static start(config?: LensConfig): Promise<void>;
14
+ static setStore(store: Store): typeof Lens;
15
+ static getStore(): Promise<Store>;
16
+ static setAdapter(adapter: Adapter): typeof Lens;
17
+ static getAdapter(): Adapter;
18
+ private static bindContainerDeps;
19
+ private static getRoutes;
20
+ private static getDefaultStore;
21
+ private static normalizeDirName;
22
+ }
23
+
24
+ export { Lens as default };
@@ -0,0 +1,15 @@
1
+ import {
2
+ Lens
3
+ } from "../chunk-5PYQWLAZ.js";
4
+ import "../chunk-VD5IMUWL.js";
5
+ import "../chunk-IPMTMCFP.js";
6
+ import "../chunk-EJ5BW35V.js";
7
+ import "../chunk-FKMBNWX4.js";
8
+ import "../chunk-TJDE6AZM.js";
9
+ import "../chunk-FLOVBBFU.js";
10
+ import "../chunk-XYXPHWEI.js";
11
+ import "../chunk-YC6T4XWI.js";
12
+ import "../chunk-MLKGABMK.js";
13
+ export {
14
+ Lens as default
15
+ };