@platformatic/runtime 1.35.2 → 1.35.3

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/lib/api-client.js CHANGED
@@ -346,7 +346,20 @@ class RuntimeApiClient extends EventEmitter {
346
346
  })
347
347
  }
348
348
 
349
- async getLogIds () {
349
+ async getLogIds (runtimePID) {
350
+ runtimePID = runtimePID ?? process.pid
351
+
352
+ const runtimeLogFiles = await this.#getRuntimeLogFiles(runtimePID)
353
+ const runtimeLogIds = []
354
+
355
+ for (const logFile of runtimeLogFiles) {
356
+ const logId = parseInt(logFile.slice('logs.'.length))
357
+ runtimeLogIds.push(logId)
358
+ }
359
+ return runtimeLogIds
360
+ }
361
+
362
+ async getAllLogIds () {
350
363
  const runtimesLogFiles = await this.#getAllLogsFiles()
351
364
  const runtimesLogsIds = []
352
365
 
@@ -140,25 +140,21 @@ async function createManagementApi (runtimeApiClient) {
140
140
  app.get('/logs/indexes', async (req) => {
141
141
  const returnAllIds = req.query.all === 'true'
142
142
 
143
- const runtimesLogsIds = await runtimeApiClient.getLogIds()
144
143
  if (returnAllIds) {
144
+ const runtimesLogsIds = await runtimeApiClient.getAllLogIds()
145
145
  return runtimesLogsIds
146
146
  }
147
147
 
148
- if (runtimesLogsIds.length === 0) {
149
- return []
150
- }
151
-
152
- return { indexes: runtimesLogsIds.at(-1).indexes }
148
+ const runtimeLogsIds = await runtimeApiClient.getLogIds()
149
+ return { indexes: runtimeLogsIds }
153
150
  })
154
151
 
155
152
  app.get('/logs/all', async (req, reply) => {
156
153
  const runtimePID = parseInt(req.query.pid) || process.pid
157
154
 
158
- const allLogIds = await runtimeApiClient.getLogIds()
159
- const logsIds = allLogIds.find((logs) => logs.pid === runtimePID)
160
- const startLogId = logsIds.indexes.at(0)
161
- const endLogId = logsIds.indexes.at(-1)
155
+ const logsIds = await runtimeApiClient.getLogIds(runtimePID)
156
+ const startLogId = logsIds.at(0)
157
+ const endLogId = logsIds.at(-1)
162
158
 
163
159
  reply.hijack()
164
160
 
@@ -175,9 +171,8 @@ async function createManagementApi (runtimeApiClient) {
175
171
  const logId = parseInt(req.params.id)
176
172
  const runtimePID = parseInt(req.query.pid) || process.pid
177
173
 
178
- const allLogIds = await runtimeApiClient.getLogIds()
179
- const runtimeLogsIds = allLogIds.find((logs) => logs.pid === runtimePID)
180
- if (!runtimeLogsIds || !runtimeLogsIds.indexes.includes(logId)) {
174
+ const logIds = await runtimeApiClient.getLogIds(runtimePID)
175
+ if (!logIds || !logIds.includes(logId)) {
181
176
  throw new errors.LogFileNotFound(logId)
182
177
  }
183
178
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/runtime",
3
- "version": "1.35.2",
3
+ "version": "1.35.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -33,8 +33,8 @@
33
33
  "typescript": "^5.4.2",
34
34
  "undici-oidc-interceptor": "^0.5.0",
35
35
  "why-is-node-running": "^2.2.2",
36
- "@platformatic/sql-graphql": "1.35.2",
37
- "@platformatic/sql-mapper": "1.35.2"
36
+ "@platformatic/sql-graphql": "1.35.3",
37
+ "@platformatic/sql-mapper": "1.35.3"
38
38
  },
39
39
  "dependencies": {
40
40
  "ws": "^8.16.0",
@@ -62,13 +62,13 @@
62
62
  "tail-file-stream": "^0.1.0",
63
63
  "undici": "^6.9.0",
64
64
  "why-is-node-running": "^2.2.2",
65
- "@platformatic/composer": "1.35.2",
66
- "@platformatic/config": "1.35.2",
67
- "@platformatic/db": "1.35.2",
68
- "@platformatic/service": "1.35.2",
69
- "@platformatic/telemetry": "1.35.2",
70
- "@platformatic/utils": "1.35.2",
71
- "@platformatic/generators": "1.35.2"
65
+ "@platformatic/composer": "1.35.3",
66
+ "@platformatic/db": "1.35.3",
67
+ "@platformatic/config": "1.35.3",
68
+ "@platformatic/generators": "1.35.3",
69
+ "@platformatic/telemetry": "1.35.3",
70
+ "@platformatic/service": "1.35.3",
71
+ "@platformatic/utils": "1.35.3"
72
72
  },
73
73
  "standard": {
74
74
  "ignore": [