@typed-assistant/builder 0.0.76 → 0.0.77

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @typed-assistant/builder
2
2
 
3
+ ## 0.0.77
4
+
5
+ ### Patch Changes
6
+
7
+ - Optimise retrieval of logs.
8
+
3
9
  ## 0.0.76
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typed-assistant/builder",
3
- "version": "0.0.76",
3
+ "version": "0.0.77",
4
4
  "exports": {
5
5
  "./appProcess": "./src/appProcess.tsx",
6
6
  "./bunInstall": "./src/bunInstall.tsx",
@@ -28,10 +28,10 @@
28
28
  "eslint-plugin-html": "^7.1.0",
29
29
  "ts-toolbelt": "^9.6.0",
30
30
  "typescript": "^5.4.0",
31
- "@typed-assistant/eslint-config": "0.0.10",
32
31
  "@typed-assistant/logger": "0.0.21",
33
32
  "@typed-assistant/utils": "0.0.18",
34
- "@typed-assistant/typescript-config": "0.0.10"
33
+ "@typed-assistant/typescript-config": "0.0.10",
34
+ "@typed-assistant/eslint-config": "0.0.10"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public",
@@ -361,30 +361,30 @@ const getLogsFromFile = async ({
361
361
  try {
362
362
  const limit = Number(limitProp)
363
363
  const offset = Number(offsetProp)
364
- const lines = (await Bun.file("./log.txt").text())
365
- .split("\n")
366
- .map(
367
- (line) =>
368
- (line
369
- ? JSON.parse(line)
370
- : { msg: "Empty line", level: levels.fatal }) as LogSchema,
371
- )
372
- .filter((log) => log.level >= levels[level])
373
- .filter((log) => {
374
- if (!filter) return true
375
- const keywords = filter.toLowerCase().split(" ")
376
- const logText = JSON.stringify(log).toLowerCase()
377
- return keywords.every((keyword) => logText.includes(keyword))
378
- })
379
-
380
- const logFile = limit
381
- ? lines.slice(
382
- lines.length - 1 - limit * (offset + 1),
383
- lines.length - 1 - limit * offset,
364
+ const logs = (
365
+ await Bun.file("./log.txt")
366
+ .text()
367
+ .then((text) => text.split("\n"))
368
+ .then((lines) =>
369
+ limit
370
+ ? lines.slice(
371
+ lines.length - 1 - limit * (offset + 1),
372
+ lines.length - 1 - limit * offset,
373
+ )
374
+ : lines,
384
375
  )
385
- : lines
376
+ ).reduce((result, line) => {
377
+ if (filter && !line.toLowerCase().includes(filter.toLowerCase()))
378
+ return result
379
+
380
+ const log = line
381
+ ? JSON.parse(line)
382
+ : { msg: "Empty line", level: levels.fatal }
383
+ if (log.level < levels[level]) return result
384
+ return result.concat(log)
385
+ }, [] as LogSchema[])
386
386
 
387
- return { logs: logFile }
387
+ return { logs }
388
388
  } catch (e) {
389
389
  return {
390
390
  logs: [