@lensjs/core 1.0.8 → 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 (82) 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/{index-Dzy6B_ZD.js → index-BS8XxorB.js} +11 -11
  34. package/dist/ui/assets/{index-byVaIWe8.js → index-CpP2Ap5X.js} +1 -1
  35. package/dist/ui/assets/{useLensApi-CkgX8mtY.js → useLensApi-DG6atd6d.js} +1 -1
  36. package/dist/ui/assets/{useLoadMore-BRca6vvh.js → useLoadMore-CJltToLI.js} +1 -1
  37. package/dist/ui/assets/{useQueries-CVt1cLYV.js → useQueries-C8mDDDc6.js} +1 -1
  38. package/dist/ui/index.html +1 -1
  39. package/dist/utils/event_emitter.cjs +42 -6
  40. package/dist/utils/event_emitter.js +5 -4
  41. package/dist/utils/index.cjs +163 -23
  42. package/dist/utils/index.js +109 -12
  43. package/dist/watchers/index.cjs +105 -10
  44. package/dist/watchers/index.js +79 -12
  45. package/dist/watchers/query_watcher.cjs +78 -8
  46. package/dist/watchers/query_watcher.js +55 -8
  47. package/dist/watchers/request_watcher.cjs +90 -8
  48. package/dist/watchers/request_watcher.js +67 -8
  49. package/package.json +3 -3
  50. package/dist/chunk-2HRVJRKV.cjs +0 -10
  51. package/dist/chunk-45JBO7ME.cjs +0 -120
  52. package/dist/chunk-4HLDYZJA.js +0 -34
  53. package/dist/chunk-66RDYK2I.js +0 -9
  54. package/dist/chunk-75ZPJI57.cjs +0 -9
  55. package/dist/chunk-7EKM5HB5.cjs +0 -1
  56. package/dist/chunk-7FBZAVQ3.cjs +0 -138
  57. package/dist/chunk-7MOTQS6N.cjs +0 -32
  58. package/dist/chunk-BL4Z6JFH.cjs +0 -34
  59. package/dist/chunk-CGPET47D.cjs +0 -129
  60. package/dist/chunk-CQ2Z4TCR.js +0 -7
  61. package/dist/chunk-EHOWCXZV.cjs +0 -7
  62. package/dist/chunk-EKG3FVLV.cjs +0 -7
  63. package/dist/chunk-FKMBNWX4.js +0 -7
  64. package/dist/chunk-FLOVBBFU.js +0 -10
  65. package/dist/chunk-GI7SJDNQ.cjs +0 -38
  66. package/dist/chunk-HLBMQ3ID.js +0 -120
  67. package/dist/chunk-HMBQ2DF7.js +0 -129
  68. package/dist/chunk-JTRKNE5Q.js +0 -32
  69. package/dist/chunk-JZ2JLQXL.cjs +0 -87
  70. package/dist/chunk-MLKGABMK.js +0 -9
  71. package/dist/chunk-NUSVID2Q.cjs +0 -9
  72. package/dist/chunk-QRZUNYF6.cjs +0 -16
  73. package/dist/chunk-SJXZARBJ.cjs +0 -22
  74. package/dist/chunk-TJDE6AZM.js +0 -87
  75. package/dist/chunk-UF5HFNMI.js +0 -22
  76. package/dist/chunk-VD5IMUWL.js +0 -0
  77. package/dist/chunk-XXYRWHSQ.js +0 -0
  78. package/dist/chunk-XYXPHWEI.js +0 -16
  79. package/dist/chunk-XZFXXD3A.cjs +0 -1
  80. package/dist/chunk-YC6T4XWI.js +0 -38
  81. package/dist/chunk-YXSPADWE.js +0 -138
  82. package/dist/ui/assets/QueriesContainer-DhnU1ndx.js +0 -2
@@ -1,8 +1,73 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
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);
2
29
 
3
- var _chunk7MOTQS6Ncjs = require('../chunk-7MOTQS6N.cjs');
4
- require('../chunk-7FBZAVQ3.cjs');
5
- require('../chunk-75ZPJI57.cjs');
30
+ // src/abstracts/adapter.ts
31
+ var adapter_exports = {};
32
+ __export(adapter_exports, {
33
+ default: () => Adapter
34
+ });
35
+ module.exports = __toCommonJS(adapter_exports);
6
36
 
37
+ // src/utils/index.ts
38
+ var import_luxon = require("luxon");
39
+ var import_sql_formatter = require("sql-formatter");
40
+ var import_crypto = require("crypto");
41
+ var import_url = require("url");
42
+ var path = __toESM(require("path"), 1);
43
+ function shouldIgnoreCurrentPath(path2, ignoredPaths, onlyPaths) {
44
+ if (onlyPaths.length > 0) {
45
+ return !onlyPaths.some((pattern) => pattern.test(path2));
46
+ }
47
+ return ignoredPaths.some((pattern) => pattern.test(path2));
48
+ }
7
49
 
8
- exports.default = _chunk7MOTQS6Ncjs.Adapter;
50
+ // src/abstracts/adapter.ts
51
+ var Adapter = class {
52
+ watchers = [];
53
+ ignoredPaths = [];
54
+ onlyPaths = [];
55
+ setWatchers(watchers) {
56
+ this.watchers = watchers;
57
+ return this;
58
+ }
59
+ setIgnoredPaths(paths) {
60
+ this.ignoredPaths = paths;
61
+ return this;
62
+ }
63
+ setOnlyPaths(paths) {
64
+ this.onlyPaths = paths;
65
+ return this;
66
+ }
67
+ getWatchers() {
68
+ return this.watchers;
69
+ }
70
+ shouldIgnorePath(path2) {
71
+ return shouldIgnoreCurrentPath(path2, this.ignoredPaths, this.onlyPaths);
72
+ }
73
+ };
@@ -1,8 +1,40 @@
1
- import {
2
- Adapter
3
- } from "../chunk-JTRKNE5Q.js";
4
- import "../chunk-YXSPADWE.js";
5
- 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
+ function shouldIgnoreCurrentPath(path2, ignoredPaths, onlyPaths) {
8
+ if (onlyPaths.length > 0) {
9
+ return !onlyPaths.some((pattern) => pattern.test(path2));
10
+ }
11
+ return ignoredPaths.some((pattern) => pattern.test(path2));
12
+ }
13
+
14
+ // src/abstracts/adapter.ts
15
+ var Adapter = class {
16
+ watchers = [];
17
+ ignoredPaths = [];
18
+ onlyPaths = [];
19
+ setWatchers(watchers) {
20
+ this.watchers = watchers;
21
+ return this;
22
+ }
23
+ setIgnoredPaths(paths) {
24
+ this.ignoredPaths = paths;
25
+ return this;
26
+ }
27
+ setOnlyPaths(paths) {
28
+ this.onlyPaths = paths;
29
+ return this;
30
+ }
31
+ getWatchers() {
32
+ return this.watchers;
33
+ }
34
+ shouldIgnorePath(path2) {
35
+ return shouldIgnoreCurrentPath(path2, this.ignoredPaths, this.onlyPaths);
36
+ }
37
+ };
6
38
  export {
7
39
  Adapter as default
8
40
  };
@@ -1,7 +1,27 @@
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 _chunkEHOWCXZVcjs = require('../chunk-EHOWCXZV.cjs');
4
- require('../chunk-75ZPJI57.cjs');
5
-
6
-
7
- exports.default = _chunkEHOWCXZVcjs.Store;
20
+ // src/abstracts/store.ts
21
+ var store_exports = {};
22
+ __export(store_exports, {
23
+ default: () => Store
24
+ });
25
+ module.exports = __toCommonJS(store_exports);
26
+ var Store = class {
27
+ };
@@ -1,7 +1,6 @@
1
- import {
2
- Store
3
- } from "../chunk-FKMBNWX4.js";
4
- import "../chunk-MLKGABMK.js";
1
+ // src/abstracts/store.ts
2
+ var Store = class {
3
+ };
5
4
  export {
6
5
  Store as default
7
6
  };
@@ -1,7 +1,58 @@
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 _chunkGI7SJDNQcjs = require('../chunk-GI7SJDNQ.cjs');
4
- require('../chunk-75ZPJI57.cjs');
5
-
6
-
7
- exports.default = _chunkGI7SJDNQcjs.Container;
20
+ // src/context/container.ts
21
+ var container_exports = {};
22
+ __export(container_exports, {
23
+ default: () => Container
24
+ });
25
+ module.exports = __toCommonJS(container_exports);
26
+ var Container = class {
27
+ static bindings = /* @__PURE__ */ new Map();
28
+ static singletons = /* @__PURE__ */ new Map();
29
+ static instances = /* @__PURE__ */ new Map();
30
+ static bind(key, factory) {
31
+ this.bindings.set(key, factory);
32
+ }
33
+ static singleton(key, factory) {
34
+ this.singletons.set(key, factory);
35
+ }
36
+ static make(key) {
37
+ if (this.instances.has(key)) {
38
+ return this.instances.get(key);
39
+ }
40
+ if (this.singletons.has(key)) {
41
+ const instance = this.singletons.get(key)();
42
+ this.instances.set(key, instance);
43
+ return instance;
44
+ }
45
+ if (this.bindings.has(key)) {
46
+ return this.bindings.get(key)();
47
+ }
48
+ throw new Error(`Service "${key}" is not bound in the container`);
49
+ }
50
+ static has(key) {
51
+ return this.bindings.has(key) || this.singletons.has(key) || this.instances.has(key);
52
+ }
53
+ static clear() {
54
+ this.bindings.clear();
55
+ this.singletons.clear();
56
+ this.instances.clear();
57
+ }
58
+ };
@@ -1,7 +1,37 @@
1
- import {
2
- Container
3
- } from "../chunk-YC6T4XWI.js";
4
- 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
+ };
5
35
  export {
6
36
  Container as default
7
37
  };
@@ -1,10 +1,74 @@
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
 
20
+ // src/context/context.ts
21
+ var context_exports = {};
22
+ __export(context_exports, {
23
+ getStore: () => getStore,
24
+ getUiConfig: () => getUiConfig
25
+ });
26
+ module.exports = __toCommonJS(context_exports);
3
27
 
4
- var _chunkQRZUNYF6cjs = require('../chunk-QRZUNYF6.cjs');
5
- require('../chunk-GI7SJDNQ.cjs');
6
- require('../chunk-75ZPJI57.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
+ };
7
62
 
8
-
9
-
10
- exports.getStore = _chunkQRZUNYF6cjs.getStore; exports.getUiConfig = _chunkQRZUNYF6cjs.getUiConfig;
63
+ // src/context/context.ts
64
+ var getStore = () => {
65
+ return Container.make("store");
66
+ };
67
+ var getUiConfig = () => {
68
+ return Container.make("uiConfig");
69
+ };
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ getStore,
73
+ getUiConfig
74
+ });
@@ -1,9 +1,45 @@
1
- import {
2
- getStore,
3
- getUiConfig
4
- } from "../chunk-XYXPHWEI.js";
5
- import "../chunk-YC6T4XWI.js";
6
- 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
+ var getUiConfig = () => {
41
+ return Container.make("uiConfig");
42
+ };
7
43
  export {
8
44
  getStore,
9
45
  getUiConfig
@@ -1,10 +1,151 @@
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 _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');
20
+ // src/core/api_controller.ts
21
+ var api_controller_exports = {};
22
+ __export(api_controller_exports, {
23
+ ApiController: () => ApiController
24
+ });
25
+ module.exports = __toCommonJS(api_controller_exports);
8
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
+ };
9
61
 
10
- exports.ApiController = _chunkJZ2JLQXLcjs.ApiController;
62
+ // src/context/context.ts
63
+ var getStore = () => {
64
+ return Container.make("store");
65
+ };
66
+ var getUiConfig = () => {
67
+ return Container.make("uiConfig");
68
+ };
69
+
70
+ // src/core/api_controller.ts
71
+ var ApiController = class {
72
+ static async getRequests({ qs }) {
73
+ return this.paginatedResponse(
74
+ await getStore().getAllRequests(this.extractPaginationParams(qs))
75
+ );
76
+ }
77
+ static async getRequest({
78
+ params
79
+ }) {
80
+ const request = await getStore().find("request" /* REQUEST */, params.id);
81
+ if (!request) {
82
+ return this.notFoundResponse();
83
+ }
84
+ return this.resourceResponse(request);
85
+ }
86
+ static async getQueries({
87
+ qs
88
+ }) {
89
+ const queries = await getStore().getAllQueries(
90
+ this.extractPaginationParams(qs)
91
+ );
92
+ return this.paginatedResponse(queries);
93
+ }
94
+ static async getQuery({
95
+ params
96
+ }) {
97
+ const query = await getStore().find("query" /* QUERY */, params.id);
98
+ if (!query) {
99
+ return this.notFoundResponse();
100
+ }
101
+ return this.resourceResponse(query);
102
+ }
103
+ static async truncate() {
104
+ await getStore().truncate();
105
+ return this.baseResponse({}, 200, "All entries cleared");
106
+ }
107
+ static fetchUiConfig() {
108
+ return getUiConfig();
109
+ }
110
+ static extractPaginationParams(qs) {
111
+ if (!qs || Object.keys(qs).length === 0) {
112
+ return { page: 1, perPage: 100 };
113
+ }
114
+ let page = Number(qs.page);
115
+ let perPage = Number(qs.perPage);
116
+ if (!Number.isInteger(perPage) || perPage > 100 || perPage < 5) {
117
+ perPage = 100;
118
+ }
119
+ if (!Number.isInteger(page) || page < 1) {
120
+ page = 1;
121
+ }
122
+ return { page, perPage };
123
+ }
124
+ static resourceResponse(data) {
125
+ return this.baseResponse(data, 200, "Data fetched successfully");
126
+ }
127
+ static notFoundResponse(message = "Could not find the requested resource") {
128
+ return this.baseResponse(null, 404, message);
129
+ }
130
+ static paginatedResponse(data) {
131
+ return this.baseResponse(data, 200, "Data fetched successfully");
132
+ }
133
+ static baseResponse(data, status, message) {
134
+ if (!data) {
135
+ return { status, message, data: null };
136
+ }
137
+ if ("meta" in data) {
138
+ return {
139
+ status,
140
+ message,
141
+ data: data.data,
142
+ meta: data.meta
143
+ };
144
+ }
145
+ return { status, message, data };
146
+ }
147
+ };
148
+ // Annotate the CommonJS export names for ESM import in node:
149
+ 0 && (module.exports = {
150
+ ApiController
151
+ });