@lensjs/core 1.0.7 → 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.
- 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-D0Vszdac.d.ts → index-DiLfwsvc.d.cts} +2 -11
- package/dist/{index-D0Vszdac.d.cts → index-DiLfwsvc.d.ts} +2 -11
- package/dist/index.cjs +611 -55
- package/dist/index.d.cts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +556 -42
- package/dist/stores/better_sqlite.cjs +149 -7
- package/dist/stores/better_sqlite.js +116 -7
- package/dist/stores/index.cjs +153 -8
- package/dist/stores/index.js +116 -8
- 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-BkaktbOw.js → QueryDetailsContainer-E7P-IO7f.js} +19 -19
- package/dist/ui/assets/QueryTable-BcrtUssT.js +1 -0
- package/dist/ui/assets/RequestDetails-C2DZBu5H.js +1 -0
- package/dist/ui/assets/RequestDetailsContainer-DuDo-IqS.js +2 -0
- package/dist/ui/assets/{RequestsContainer-zoWMoB7o.js → RequestsContainer-DK3hQVz9.js} +2 -2
- package/dist/ui/assets/RequetsTable-DgP8p60b.js +1 -0
- package/dist/ui/assets/{StatusCode-DH20lQ6a.js → StatusCode-FQEjz7gK.js} +1 -1
- package/dist/ui/assets/TabbedDataViewer-cBDdPwIz.js +1 -0
- package/dist/ui/assets/{Table-HwlddLhp.js → Table-DYaXk80S.js} +2 -2
- package/dist/ui/assets/index-BS8XxorB.js +114 -0
- package/dist/ui/assets/index-CpP2Ap5X.js +1 -0
- package/dist/ui/assets/index-DzNHqeKh.css +1 -0
- package/dist/ui/assets/{useLensApi-Bmk2bGb0.js → useLensApi-DG6atd6d.js} +1 -1
- package/dist/ui/assets/{useLoadMore-CvIajdjM.js → useLoadMore-CJltToLI.js} +1 -1
- package/dist/ui/assets/{useQueries-DuyhGJyf.js → useQueries-C8mDDDc6.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/utils/event_emitter.cjs +42 -10
- package/dist/utils/event_emitter.d.cts +1 -11
- package/dist/utils/event_emitter.d.ts +1 -11
- package/dist/utils/event_emitter.js +6 -9
- package/dist/utils/index.cjs +163 -31
- package/dist/utils/index.d.cts +1 -2
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.js +109 -20
- 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 +18 -18
- package/README.md +0 -1
- package/dist/chunk-2HRVJRKV.cjs +0 -10
- package/dist/chunk-3R5QARPT.cjs +0 -14
- package/dist/chunk-4HLDYZJA.js +0 -34
- package/dist/chunk-5PYQWLAZ.js +0 -129
- package/dist/chunk-75ZPJI57.cjs +0 -9
- package/dist/chunk-7EKM5HB5.cjs +0 -1
- package/dist/chunk-AUDSBNLF.cjs +0 -122
- package/dist/chunk-BFFOUTTE.cjs +0 -32
- package/dist/chunk-BL4Z6JFH.cjs +0 -34
- package/dist/chunk-CQ2Z4TCR.js +0 -7
- package/dist/chunk-EHOWCXZV.cjs +0 -7
- package/dist/chunk-EJ5BW35V.js +0 -159
- package/dist/chunk-EKG3FVLV.cjs +0 -7
- package/dist/chunk-FCMQ3WE3.cjs +0 -129
- package/dist/chunk-FKMBNWX4.js +0 -7
- package/dist/chunk-FLOVBBFU.js +0 -10
- package/dist/chunk-GI7SJDNQ.cjs +0 -38
- package/dist/chunk-IPMTMCFP.js +0 -122
- package/dist/chunk-JZ2JLQXL.cjs +0 -87
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/chunk-QRZUNYF6.cjs +0 -16
- package/dist/chunk-RMZ4UAQ2.js +0 -14
- package/dist/chunk-SJXZARBJ.cjs +0 -22
- package/dist/chunk-TJDE6AZM.js +0 -87
- package/dist/chunk-TPUVRGYT.js +0 -32
- package/dist/chunk-UF5HFNMI.js +0 -22
- package/dist/chunk-VD5IMUWL.js +0 -0
- package/dist/chunk-WU6IZUEV.cjs +0 -159
- 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/ui/assets/QueriesContainer-DHnHEGG1.js +0 -2
- package/dist/ui/assets/QueryTable-DegVNDkJ.js +0 -1
- package/dist/ui/assets/RequestDetails-zrL0n6gL.js +0 -1
- package/dist/ui/assets/RequestDetailsContainer-CsHWDxn7.js +0 -2
- package/dist/ui/assets/RequetsTable-1K9hhs0W.js +0 -1
- package/dist/ui/assets/TabbedDataViewer-DDVxzZiW.js +0 -1
- package/dist/ui/assets/date-CZdBf-JH.js +0 -1
- package/dist/ui/assets/index-C-9tn0L6.js +0 -114
- package/dist/ui/assets/index-DaNx3ROH.css +0 -1
package/dist/chunk-FCMQ3WE3.cjs
DELETED
|
@@ -1,129 +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; } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } var _class;
|
|
2
|
-
|
|
3
|
-
var _chunkAUDSBNLFcjs = require('./chunk-AUDSBNLF.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkWU6IZUEVcjs = require('./chunk-WU6IZUEV.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunkJZ2JLQXLcjs = require('./chunk-JZ2JLQXL.cjs');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _chunkQRZUNYF6cjs = require('./chunk-QRZUNYF6.cjs');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _chunkGI7SJDNQcjs = require('./chunk-GI7SJDNQ.cjs');
|
|
16
|
-
|
|
17
|
-
// src/core/lens.ts
|
|
18
|
-
var _path = require('path'); var path = _interopRequireWildcard(_path);
|
|
19
|
-
var Lens = (_class = class {
|
|
20
|
-
static __initStatic() {this.watchers = /* @__PURE__ */ new Map()}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
static watch(watcher) {
|
|
24
|
-
this.watchers.set(watcher.name, watcher);
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
static setWatchers(watchers) {
|
|
28
|
-
this.watchers = new Map(watchers.map((watcher) => [watcher.name, watcher]));
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
static async start(config = {
|
|
32
|
-
basePath: "lens",
|
|
33
|
-
appName: "Lens",
|
|
34
|
-
enabled: true
|
|
35
|
-
}) {
|
|
36
|
-
if (!config.enabled) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
await this.bindContainerDeps(config);
|
|
40
|
-
let adapter = this.getAdapter();
|
|
41
|
-
adapter.setWatchers(Array.from(this.watchers.values())).setup();
|
|
42
|
-
const { apiRoutes } = this.getRoutes({
|
|
43
|
-
basePath: config.basePath
|
|
44
|
-
});
|
|
45
|
-
adapter.registerRoutes(apiRoutes);
|
|
46
|
-
const { __dirname } = _chunkWU6IZUEVcjs.getMeta.call(void 0, import.meta.url);
|
|
47
|
-
const uiPath = path.resolve(this.normalizeDirName(__dirname), "ui");
|
|
48
|
-
adapter.serveUI(uiPath, config.basePath, _chunkQRZUNYF6cjs.getUiConfig.call(void 0, ));
|
|
49
|
-
}
|
|
50
|
-
static setStore(store) {
|
|
51
|
-
this.store = store;
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
static async getStore() {
|
|
55
|
-
return await _asyncNullishCoalesce(this.store, async () => ( await this.getDefaultStore()));
|
|
56
|
-
}
|
|
57
|
-
static setAdapter(adapter) {
|
|
58
|
-
this.adapter = adapter;
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
static getAdapter() {
|
|
62
|
-
if (!this.adapter) {
|
|
63
|
-
throw new Error("No adapter has been set");
|
|
64
|
-
}
|
|
65
|
-
return this.adapter;
|
|
66
|
-
}
|
|
67
|
-
static async bindContainerDeps(config) {
|
|
68
|
-
const dbStore = await this.getStore();
|
|
69
|
-
_chunkGI7SJDNQcjs.Container.singleton("store", () => dbStore);
|
|
70
|
-
_chunkGI7SJDNQcjs.Container.singleton("uiConfig", () => {
|
|
71
|
-
return {
|
|
72
|
-
appName: config.appName,
|
|
73
|
-
path: `/${config.basePath}`,
|
|
74
|
-
api: {
|
|
75
|
-
requests: `/${config.basePath}/api/requests`,
|
|
76
|
-
queries: `/${config.basePath}/api/queries`,
|
|
77
|
-
truncate: `/${config.basePath}/api/truncate`
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
static getRoutes({ basePath }) {
|
|
83
|
-
const apiRoutes = [
|
|
84
|
-
{
|
|
85
|
-
method: "GET",
|
|
86
|
-
path: `/lens-config`,
|
|
87
|
-
handler: () => _chunkJZ2JLQXLcjs.ApiController.fetchUiConfig()
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
method: "GET",
|
|
91
|
-
path: `${basePath}/api/requests`,
|
|
92
|
-
handler: async (data) => await _chunkJZ2JLQXLcjs.ApiController.getRequests(data)
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
method: "GET",
|
|
96
|
-
path: `${basePath}/api/requests/:id`,
|
|
97
|
-
handler: async (data) => await _chunkJZ2JLQXLcjs.ApiController.getRequest(data)
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
method: "GET",
|
|
101
|
-
path: `${basePath}/api/queries`,
|
|
102
|
-
handler: async (data) => await _chunkJZ2JLQXLcjs.ApiController.getQueries(data)
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
method: "GET",
|
|
106
|
-
path: `${basePath}/api/queries/:id`,
|
|
107
|
-
handler: async (data) => await _chunkJZ2JLQXLcjs.ApiController.getQuery(data)
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
method: "DELETE",
|
|
111
|
-
path: `${basePath}/api/truncate`,
|
|
112
|
-
handler: async () => await _chunkJZ2JLQXLcjs.ApiController.truncate()
|
|
113
|
-
}
|
|
114
|
-
];
|
|
115
|
-
return { apiRoutes };
|
|
116
|
-
}
|
|
117
|
-
static async getDefaultStore() {
|
|
118
|
-
const store = new (0, _chunkAUDSBNLFcjs.BetterSqliteStore)();
|
|
119
|
-
await store.initialize();
|
|
120
|
-
return store;
|
|
121
|
-
}
|
|
122
|
-
static normalizeDirName(path2) {
|
|
123
|
-
return path2.replace(/(\/packages\/)[^/]+(?=\/dist)/, "$1core");
|
|
124
|
-
}
|
|
125
|
-
}, _class.__initStatic(), _class);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
exports.Lens = Lens;
|
package/dist/chunk-FKMBNWX4.js
DELETED
package/dist/chunk-FLOVBBFU.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// src/types/index.ts
|
|
2
|
-
var WatcherTypeEnum = /* @__PURE__ */ ((WatcherTypeEnum2) => {
|
|
3
|
-
WatcherTypeEnum2["REQUEST"] = "request";
|
|
4
|
-
WatcherTypeEnum2["QUERY"] = "query";
|
|
5
|
-
return WatcherTypeEnum2;
|
|
6
|
-
})(WatcherTypeEnum || {});
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
WatcherTypeEnum
|
|
10
|
-
};
|
package/dist/chunk-GI7SJDNQ.cjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;// src/context/container.ts
|
|
2
|
-
var Container = (_class = class {
|
|
3
|
-
static __initStatic() {this.bindings = /* @__PURE__ */ new Map()}
|
|
4
|
-
static __initStatic2() {this.singletons = /* @__PURE__ */ new Map()}
|
|
5
|
-
static __initStatic3() {this.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
|
-
}, _class.__initStatic(), _class.__initStatic2(), _class.__initStatic3(), _class);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
exports.Container = Container;
|
package/dist/chunk-IPMTMCFP.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
sqlDateTime
|
|
3
|
-
} from "./chunk-EJ5BW35V.js";
|
|
4
|
-
import {
|
|
5
|
-
Store
|
|
6
|
-
} from "./chunk-FKMBNWX4.js";
|
|
7
|
-
|
|
8
|
-
// src/stores/better_sqlite.ts
|
|
9
|
-
import { randomUUID } from "crypto";
|
|
10
|
-
import Database from "libsql";
|
|
11
|
-
var TABLE_NAME = "lens_entries";
|
|
12
|
-
var BetterSqliteStore = class extends Store {
|
|
13
|
-
connection;
|
|
14
|
-
async initialize() {
|
|
15
|
-
this.connection = new Database("lens.db");
|
|
16
|
-
this.setupSchema();
|
|
17
|
-
console.log("Connected to Lens (SQLite) database.");
|
|
18
|
-
}
|
|
19
|
-
async truncate() {
|
|
20
|
-
this.connection.prepare(`DELETE FROM ${TABLE_NAME};`).run();
|
|
21
|
-
}
|
|
22
|
-
async save(entry) {
|
|
23
|
-
this.connection.prepare(
|
|
24
|
-
`INSERT INTO ${TABLE_NAME} (id, data, type, created_at, lens_entry_id, minimal_data) values($id, $data, $type, $created_at, $lens_entry_id, $minimalData)`
|
|
25
|
-
).run({
|
|
26
|
-
id: entry.id ?? randomUUID(),
|
|
27
|
-
data: JSON.stringify(entry.data),
|
|
28
|
-
type: entry.type,
|
|
29
|
-
created_at: entry.timestamp ?? sqlDateTime(),
|
|
30
|
-
lens_entry_id: entry.requestId || null,
|
|
31
|
-
minimalData: JSON.stringify(entry.minimal_data ?? {})
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
async getAllQueries(pagination) {
|
|
35
|
-
return await this.paginate("query" /* QUERY */, pagination);
|
|
36
|
-
}
|
|
37
|
-
async getAllRequests(pagination) {
|
|
38
|
-
return await this.paginate("request" /* REQUEST */, pagination, false);
|
|
39
|
-
}
|
|
40
|
-
async allByRequestId(requestId, type) {
|
|
41
|
-
const rows = this.connection.prepare(
|
|
42
|
-
`${this.getSelectedColumns()} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
|
|
43
|
-
).all({ type, requestId });
|
|
44
|
-
return this.mapRows(rows);
|
|
45
|
-
}
|
|
46
|
-
async paginate(type, { page, perPage }, includeFullData = true) {
|
|
47
|
-
const offset = (page - 1) * perPage;
|
|
48
|
-
const query = `${this.getSelectedColumns(
|
|
49
|
-
includeFullData
|
|
50
|
-
)} FROM ${TABLE_NAME} WHERE type = ? ORDER BY created_at DESC LIMIT ? OFFSET ?`;
|
|
51
|
-
const count = await this.count(type);
|
|
52
|
-
const rows = this.connection.prepare(query).all(type, perPage, offset);
|
|
53
|
-
const mappedRows = this.mapRows(rows, includeFullData);
|
|
54
|
-
return {
|
|
55
|
-
meta: {
|
|
56
|
-
total: count,
|
|
57
|
-
lastPage: Math.ceil(count / perPage),
|
|
58
|
-
currentPage: page
|
|
59
|
-
},
|
|
60
|
-
data: mappedRows
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
async count(type) {
|
|
64
|
-
const result = this.connection.prepare(`SELECT count(*) as count FROM ${TABLE_NAME} WHERE type = ?`).get(type);
|
|
65
|
-
return Number(result.count);
|
|
66
|
-
}
|
|
67
|
-
async find(type, id) {
|
|
68
|
-
const row = this.connection.prepare(
|
|
69
|
-
`${this.getSelectedColumns()} FROM ${TABLE_NAME} WHERE id = ? AND type = ? LIMIT 1`
|
|
70
|
-
).get(id, type);
|
|
71
|
-
if (!row) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
return this.mapRow(row, true);
|
|
75
|
-
}
|
|
76
|
-
setupSchema() {
|
|
77
|
-
const createTable = `
|
|
78
|
-
CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
|
|
79
|
-
id TEXT PRIMARY KEY,
|
|
80
|
-
minimal_data TEXT,
|
|
81
|
-
data TEXT NOT NULL,
|
|
82
|
-
type TEXT NOT NULL,
|
|
83
|
-
created_at TEXT NOT NULL,
|
|
84
|
-
updated_at TEXT,
|
|
85
|
-
lens_entry_id TEXT NULL
|
|
86
|
-
);
|
|
87
|
-
`;
|
|
88
|
-
const createIndex = `
|
|
89
|
-
CREATE INDEX IF NOT EXISTS lens_entries_id_type_index
|
|
90
|
-
ON ${TABLE_NAME} (id, type);
|
|
91
|
-
`;
|
|
92
|
-
this.connection.exec(createTable);
|
|
93
|
-
this.connection.exec(createIndex);
|
|
94
|
-
}
|
|
95
|
-
mapRow(row, includeFullData = true) {
|
|
96
|
-
let data = includeFullData ? JSON.parse(row.data) : {};
|
|
97
|
-
if (!includeFullData) {
|
|
98
|
-
data = JSON.parse(row.minimal_data);
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
id: row.id,
|
|
102
|
-
type: row.type,
|
|
103
|
-
created_at: row.created_at,
|
|
104
|
-
lens_entry_id: row.lens_entry_id,
|
|
105
|
-
data
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
mapRows(rows, includeFullData = true) {
|
|
109
|
-
let mappedRows = [];
|
|
110
|
-
for (const row of rows) {
|
|
111
|
-
mappedRows.push(this.mapRow(row, includeFullData));
|
|
112
|
-
}
|
|
113
|
-
return mappedRows;
|
|
114
|
-
}
|
|
115
|
-
getSelectedColumns(includeFullData = true) {
|
|
116
|
-
return `SELECT id, minimal_data, type, created_at, lens_entry_id ${includeFullData ? ",data" : ""}`;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export {
|
|
121
|
-
BetterSqliteStore
|
|
122
|
-
};
|
package/dist/chunk-JZ2JLQXL.cjs
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkQRZUNYF6cjs = require('./chunk-QRZUNYF6.cjs');
|
|
5
|
-
|
|
6
|
-
// src/core/api_controller.ts
|
|
7
|
-
var ApiController = class {
|
|
8
|
-
static async getRequests({ qs }) {
|
|
9
|
-
return this.paginatedResponse(
|
|
10
|
-
await _chunkQRZUNYF6cjs.getStore.call(void 0, ).getAllRequests(this.extractPaginationParams(qs))
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
static async getRequest({
|
|
14
|
-
params
|
|
15
|
-
}) {
|
|
16
|
-
const request = await _chunkQRZUNYF6cjs.getStore.call(void 0, ).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 _chunkQRZUNYF6cjs.getStore.call(void 0, ).getAllQueries(
|
|
26
|
-
this.extractPaginationParams(qs)
|
|
27
|
-
);
|
|
28
|
-
return this.paginatedResponse(queries);
|
|
29
|
-
}
|
|
30
|
-
static async getQuery({
|
|
31
|
-
params
|
|
32
|
-
}) {
|
|
33
|
-
const query = await _chunkQRZUNYF6cjs.getStore.call(void 0, ).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 _chunkQRZUNYF6cjs.getStore.call(void 0, ).truncate();
|
|
41
|
-
return this.baseResponse({}, 200, "All entries cleared");
|
|
42
|
-
}
|
|
43
|
-
static fetchUiConfig() {
|
|
44
|
-
return _chunkQRZUNYF6cjs.getUiConfig.call(void 0, );
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
exports.ApiController = ApiController;
|
package/dist/chunk-MLKGABMK.js
DELETED
package/dist/chunk-QRZUNYF6.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkGI7SJDNQcjs = require('./chunk-GI7SJDNQ.cjs');
|
|
4
|
-
|
|
5
|
-
// src/context/context.ts
|
|
6
|
-
var getStore = () => {
|
|
7
|
-
return _chunkGI7SJDNQcjs.Container.make("store");
|
|
8
|
-
};
|
|
9
|
-
var getUiConfig = () => {
|
|
10
|
-
return _chunkGI7SJDNQcjs.Container.make("uiConfig");
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.getStore = getStore; exports.getUiConfig = getUiConfig;
|
package/dist/chunk-RMZ4UAQ2.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// src/utils/event_emitter.ts
|
|
2
|
-
import { AsyncResource } from "async_hooks";
|
|
3
|
-
import Emittery from "emittery";
|
|
4
|
-
var createEmittery = () => {
|
|
5
|
-
return new Emittery();
|
|
6
|
-
};
|
|
7
|
-
var lensResource = new AsyncResource("lens-emitter");
|
|
8
|
-
var lensEmitter = new Emittery();
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
createEmittery,
|
|
12
|
-
lensResource,
|
|
13
|
-
lensEmitter
|
|
14
|
-
};
|
package/dist/chunk-SJXZARBJ.cjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
package/dist/chunk-TJDE6AZM.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/chunk-TPUVRGYT.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/chunk-UF5HFNMI.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/chunk-VD5IMUWL.js
DELETED
|
File without changes
|