@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.
- package/dist/abstracts/adapter.cjs +70 -5
- package/dist/abstracts/adapter.js +37 -5
- package/dist/abstracts/store.cjs +26 -6
- package/dist/abstracts/store.js +3 -4
- package/dist/context/container.cjs +57 -6
- package/dist/context/container.js +34 -4
- package/dist/context/context.cjs +71 -7
- package/dist/context/context.js +42 -6
- package/dist/core/api_controller.cjs +148 -7
- package/dist/core/api_controller.js +121 -7
- package/dist/core/lens.cjs +404 -12
- package/dist/core/lens.js +370 -12
- package/dist/core/watcher.cjs +26 -6
- package/dist/core/watcher.js +3 -4
- package/dist/index.cjs +611 -51
- package/dist/index.js +556 -38
- package/dist/stores/better_sqlite.cjs +149 -6
- package/dist/stores/better_sqlite.js +116 -6
- package/dist/stores/index.cjs +153 -7
- package/dist/stores/index.js +116 -7
- package/dist/types/index.cjs +33 -6
- package/dist/types/index.js +6 -4
- package/dist/ui/assets/QueriesContainer-CAAsjjW5.js +2 -0
- package/dist/ui/assets/{QueryDetailsContainer-CtNxjUvF.js → QueryDetailsContainer-E7P-IO7f.js} +3 -3
- package/dist/ui/assets/{QueryTable-B6L0F5jL.js → QueryTable-BcrtUssT.js} +1 -1
- package/dist/ui/assets/{RequestDetails-BfxFQmp1.js → RequestDetails-C2DZBu5H.js} +1 -1
- package/dist/ui/assets/{RequestDetailsContainer-C0s7VLpw.js → RequestDetailsContainer-DuDo-IqS.js} +2 -2
- package/dist/ui/assets/{RequestsContainer-rWbSc4Py.js → RequestsContainer-DK3hQVz9.js} +2 -2
- package/dist/ui/assets/{RequetsTable-D2qBWqFN.js → RequetsTable-DgP8p60b.js} +1 -1
- package/dist/ui/assets/{StatusCode-BZGwjlgz.js → StatusCode-FQEjz7gK.js} +1 -1
- package/dist/ui/assets/{TabbedDataViewer-CmztxF70.js → TabbedDataViewer-cBDdPwIz.js} +1 -1
- package/dist/ui/assets/{Table-DF4sxTNg.js → Table-DYaXk80S.js} +2 -2
- package/dist/ui/assets/favicon-CwRXoGYE.ico +0 -0
- package/dist/ui/assets/{index-Dzy6B_ZD.js → index-BS8XxorB.js} +11 -11
- package/dist/ui/assets/{index-byVaIWe8.js → index-CpP2Ap5X.js} +1 -1
- package/dist/ui/assets/{useLensApi-CkgX8mtY.js → useLensApi-DG6atd6d.js} +1 -1
- package/dist/ui/assets/{useLoadMore-BRca6vvh.js → useLoadMore-CJltToLI.js} +1 -1
- package/dist/ui/assets/{useQueries-CVt1cLYV.js → useQueries-C8mDDDc6.js} +1 -1
- package/dist/ui/favicon.ico +0 -0
- package/dist/ui/index.html +2 -2
- package/dist/utils/event_emitter.cjs +42 -6
- package/dist/utils/event_emitter.js +5 -4
- package/dist/utils/index.cjs +163 -23
- package/dist/utils/index.js +109 -12
- package/dist/watchers/index.cjs +105 -10
- package/dist/watchers/index.js +79 -12
- package/dist/watchers/query_watcher.cjs +78 -8
- package/dist/watchers/query_watcher.js +55 -8
- package/dist/watchers/request_watcher.cjs +90 -8
- package/dist/watchers/request_watcher.js +67 -8
- package/package.json +3 -3
- package/dist/chunk-2HRVJRKV.cjs +0 -10
- package/dist/chunk-45JBO7ME.cjs +0 -120
- package/dist/chunk-4HLDYZJA.js +0 -34
- package/dist/chunk-66RDYK2I.js +0 -9
- package/dist/chunk-75ZPJI57.cjs +0 -9
- package/dist/chunk-7EKM5HB5.cjs +0 -1
- package/dist/chunk-7FBZAVQ3.cjs +0 -138
- package/dist/chunk-7MOTQS6N.cjs +0 -32
- package/dist/chunk-BL4Z6JFH.cjs +0 -34
- package/dist/chunk-CGPET47D.cjs +0 -129
- package/dist/chunk-CQ2Z4TCR.js +0 -7
- package/dist/chunk-EHOWCXZV.cjs +0 -7
- package/dist/chunk-EKG3FVLV.cjs +0 -7
- package/dist/chunk-FKMBNWX4.js +0 -7
- package/dist/chunk-FLOVBBFU.js +0 -10
- package/dist/chunk-GI7SJDNQ.cjs +0 -38
- package/dist/chunk-HLBMQ3ID.js +0 -120
- package/dist/chunk-HMBQ2DF7.js +0 -129
- package/dist/chunk-JTRKNE5Q.js +0 -32
- package/dist/chunk-JZ2JLQXL.cjs +0 -87
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/chunk-NUSVID2Q.cjs +0 -9
- package/dist/chunk-QRZUNYF6.cjs +0 -16
- package/dist/chunk-SJXZARBJ.cjs +0 -22
- package/dist/chunk-TJDE6AZM.js +0 -87
- package/dist/chunk-UF5HFNMI.js +0 -22
- package/dist/chunk-VD5IMUWL.js +0 -0
- package/dist/chunk-XXYRWHSQ.js +0 -0
- package/dist/chunk-XYXPHWEI.js +0 -16
- package/dist/chunk-XZFXXD3A.cjs +0 -1
- package/dist/chunk-YC6T4XWI.js +0 -38
- package/dist/chunk-YXSPADWE.js +0 -138
- package/dist/ui/assets/QueriesContainer-DhnU1ndx.js +0 -2
- package/dist/ui/assets/favicon-D0UnoCWN.ico +0 -0
|
@@ -1,8 +1,73 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
} from "
|
|
4
|
-
import "
|
|
5
|
-
import "
|
|
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
|
};
|
package/dist/abstracts/store.cjs
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
};
|
package/dist/abstracts/store.js
CHANGED
|
@@ -1,7 +1,58 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
};
|
package/dist/context/context.cjs
CHANGED
|
@@ -1,10 +1,74 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
+
});
|
package/dist/context/context.js
CHANGED
|
@@ -1,9 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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";
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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
|
+
});
|