@nextsparkjs/plugin-langchain 0.1.0-beta.50 → 0.1.0-beta.51
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.
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { NextRequest, NextResponse } from 'next/server'
|
|
9
9
|
import { authenticateRequest } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
10
|
+
import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
|
|
10
11
|
import { queryWithRLS } from '@nextsparkjs/core/lib/db'
|
|
11
12
|
|
|
12
13
|
interface MetricsRow {
|
|
@@ -24,7 +25,7 @@ const PERIOD_HOURS: Record<string, number> = {
|
|
|
24
25
|
'30d': 24 * 30,
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
const getHandler = async (req: NextRequest) => {
|
|
28
29
|
// 1. Authenticate (superadmin only)
|
|
29
30
|
const authResult = await authenticateRequest(req)
|
|
30
31
|
if (!authResult.success || !authResult.user) {
|
|
@@ -108,3 +109,5 @@ export async function GET(req: NextRequest) {
|
|
|
108
109
|
)
|
|
109
110
|
}
|
|
110
111
|
}
|
|
112
|
+
|
|
113
|
+
export const GET = withRateLimitTier(getHandler, 'read')
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { NextRequest, NextResponse } from 'next/server'
|
|
9
9
|
import { authenticateRequest } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
10
|
+
import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
|
|
10
11
|
import { queryWithRLS } from '@nextsparkjs/core/lib/db'
|
|
11
12
|
import type { Trace, Span } from '../../../../types/observability.types'
|
|
12
13
|
|
|
@@ -62,10 +63,10 @@ interface SpanRow {
|
|
|
62
63
|
createdAt: Date
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
const getHandler = async (
|
|
66
67
|
req: NextRequest,
|
|
67
68
|
{ params }: { params: Promise<{ traceId: string }> }
|
|
68
|
-
) {
|
|
69
|
+
) => {
|
|
69
70
|
// 1. Authenticate (superadmin only)
|
|
70
71
|
const authResult = await authenticateRequest(req)
|
|
71
72
|
if (!authResult.success || !authResult.user) {
|
|
@@ -396,3 +397,5 @@ export async function GET(
|
|
|
396
397
|
)
|
|
397
398
|
}
|
|
398
399
|
}
|
|
400
|
+
|
|
401
|
+
export const GET = withRateLimitTier(getHandler, 'read')
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { NextRequest, NextResponse } from 'next/server'
|
|
9
9
|
import { authenticateRequest } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
10
|
+
import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
|
|
10
11
|
import { queryWithRLS } from '@nextsparkjs/core/lib/db'
|
|
11
12
|
import type { Trace } from '../../../types/observability.types'
|
|
12
13
|
|
|
@@ -38,7 +39,7 @@ interface TraceRow {
|
|
|
38
39
|
createdAt: Date
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
const getHandler = async (req: NextRequest) => {
|
|
42
43
|
// 1. Authenticate (superadmin only)
|
|
43
44
|
const authResult = await authenticateRequest(req)
|
|
44
45
|
if (!authResult.success || !authResult.user) {
|
|
@@ -203,3 +204,5 @@ export async function GET(req: NextRequest) {
|
|
|
203
204
|
)
|
|
204
205
|
}
|
|
205
206
|
}
|
|
207
|
+
|
|
208
|
+
export const GET = withRateLimitTier(getHandler, 'read')
|
package/api/sessions/route.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server'
|
|
2
2
|
import { authenticateRequest } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
3
|
+
import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
|
|
3
4
|
import { dbMemoryStore, CONVERSATION_LIMITS } from '../../lib/db-memory-store'
|
|
4
5
|
import { config } from '../../plugin.config'
|
|
5
6
|
import type {
|
|
@@ -36,7 +37,7 @@ function toApiConversationInfo(conv: {
|
|
|
36
37
|
* Without id: returns list of all conversations
|
|
37
38
|
* With id: returns single conversation details
|
|
38
39
|
*/
|
|
39
|
-
|
|
40
|
+
const getHandler = async (req: NextRequest) => {
|
|
40
41
|
// 1. Auth
|
|
41
42
|
const authResult = await authenticateRequest(req)
|
|
42
43
|
if (!authResult.success || !authResult.user) {
|
|
@@ -103,13 +104,15 @@ export async function GET(req: NextRequest) {
|
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
|
|
107
|
+
export const GET = withRateLimitTier(getHandler, 'read')
|
|
108
|
+
|
|
106
109
|
/**
|
|
107
110
|
* POST - Create a new conversation
|
|
108
111
|
*
|
|
109
112
|
* Body:
|
|
110
113
|
* - name: Optional name for the conversation
|
|
111
114
|
*/
|
|
112
|
-
|
|
115
|
+
const postHandler = async (req: NextRequest) => {
|
|
113
116
|
// 1. Auth
|
|
114
117
|
const authResult = await authenticateRequest(req)
|
|
115
118
|
if (!authResult.success || !authResult.user) {
|
|
@@ -183,6 +186,8 @@ export async function POST(req: NextRequest) {
|
|
|
183
186
|
}
|
|
184
187
|
}
|
|
185
188
|
|
|
189
|
+
export const POST = withRateLimitTier(postHandler, 'write')
|
|
190
|
+
|
|
186
191
|
/**
|
|
187
192
|
* PATCH - Update a conversation (rename, pin/unpin)
|
|
188
193
|
*
|
|
@@ -191,7 +196,7 @@ export async function POST(req: NextRequest) {
|
|
|
191
196
|
* - name: New name (optional)
|
|
192
197
|
* - isPinned: New pin status (optional)
|
|
193
198
|
*/
|
|
194
|
-
|
|
199
|
+
const patchHandler = async (req: NextRequest) => {
|
|
195
200
|
// 1. Auth
|
|
196
201
|
const authResult = await authenticateRequest(req)
|
|
197
202
|
if (!authResult.success || !authResult.user) {
|
|
@@ -262,13 +267,15 @@ export async function PATCH(req: NextRequest) {
|
|
|
262
267
|
}
|
|
263
268
|
}
|
|
264
269
|
|
|
270
|
+
export const PATCH = withRateLimitTier(patchHandler, 'write')
|
|
271
|
+
|
|
265
272
|
/**
|
|
266
273
|
* DELETE - Delete a conversation
|
|
267
274
|
*
|
|
268
275
|
* Body:
|
|
269
276
|
* - sessionId: Session ID to delete (required)
|
|
270
277
|
*/
|
|
271
|
-
|
|
278
|
+
const deleteHandler = async (req: NextRequest) => {
|
|
272
279
|
// 1. Auth
|
|
273
280
|
const authResult = await authenticateRequest(req)
|
|
274
281
|
if (!authResult.success || !authResult.user) {
|
|
@@ -330,3 +337,5 @@ export async function DELETE(req: NextRequest) {
|
|
|
330
337
|
)
|
|
331
338
|
}
|
|
332
339
|
}
|
|
340
|
+
|
|
341
|
+
export const DELETE = withRateLimitTier(deleteHandler, 'write')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextsparkjs/plugin-langchain",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.51",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "./plugin.config.ts",
|
|
6
6
|
"requiredPlugins": [],
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"react": "^19.0.0",
|
|
24
24
|
"react-dom": "^19.0.0",
|
|
25
25
|
"zod": "^4.0.0",
|
|
26
|
-
"@nextsparkjs/core": "0.1.0-beta.
|
|
26
|
+
"@nextsparkjs/core": "0.1.0-beta.51"
|
|
27
27
|
},
|
|
28
28
|
"nextspark": {
|
|
29
29
|
"type": "plugin",
|