@layer-ai/core 2.0.51 → 2.0.53

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.
@@ -1 +1 @@
1
- {"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../../src/routes/v1/logs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAGpD,QAAA,MAAM,MAAM,EAAE,UAAqB,CAAC;AA6LpC,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../../src/routes/v1/logs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAGpD,QAAA,MAAM,MAAM,EAAE,UAAqB,CAAC;AA+MpC,eAAe,MAAM,CAAC"}
@@ -29,17 +29,23 @@ router.get('/', async (req, res) => {
29
29
  FROM requests
30
30
  WHERE user_id = $1
31
31
  `;
32
- const params = [userId];
32
+ const filterParams = [userId];
33
+ let filterClause = '';
33
34
  if (gate) {
34
- query += ` AND gate_id = $2`;
35
- params.push(gate);
35
+ filterClause += ` AND gate_id = $${filterParams.length + 1}`;
36
+ filterParams.push(gate);
36
37
  }
37
38
  if (success !== undefined) {
38
- query += ` AND success = $${params.length + 1}`;
39
- params.push(success === 'true');
39
+ filterClause += ` AND success = $${filterParams.length + 1}`;
40
+ filterParams.push(success === 'true');
40
41
  }
41
- query += ` ORDER BY created_at DESC LIMIT $${params.length + 1} OFFSET $${params.length + 2}`;
42
- params.push(limit, offset);
42
+ // Get total count
43
+ const countResult = await db.query(`SELECT COUNT(*) FROM requests WHERE user_id = $1${filterClause}`, filterParams);
44
+ const total = parseInt(countResult.rows[0].count);
45
+ // Get paginated data
46
+ query += filterClause;
47
+ query += ` ORDER BY created_at DESC LIMIT $${filterParams.length + 1} OFFSET $${filterParams.length + 2}`;
48
+ const params = [...filterParams, limit, offset];
43
49
  const result = await db.query(query, params);
44
50
  const logs = result.rows.map((row) => ({
45
51
  id: row.id,
@@ -58,7 +64,15 @@ router.get('/', async (req, res) => {
58
64
  responsePayload: row.response_payload,
59
65
  loggedAt: row.logged_at,
60
66
  }));
61
- res.json(logs);
67
+ res.json({
68
+ logs,
69
+ pagination: {
70
+ total,
71
+ limit,
72
+ offset,
73
+ hasMore: offset + limit < total,
74
+ },
75
+ });
62
76
  }
63
77
  catch (error) {
64
78
  console.error('Logs list error:', error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layer-ai/core",
3
- "version": "2.0.51",
3
+ "version": "2.0.53",
4
4
  "description": "Core API routes and services for Layer AI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "node-cron": "^4.2.1",
38
38
  "openai": "^4.24.0",
39
39
  "pg": "^8.11.3",
40
- "@layer-ai/sdk": "^2.5.14"
40
+ "@layer-ai/sdk": "^2.5.15"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/bcryptjs": "^2.4.6",