1import { NextRequest, NextResponse } from 'next/server';
2import { fieldpineServerApi } from '@/lib/server/fieldpineApi';
3import { getStoredAuth } from '@/lib/server/auth';
6 * OpenAPI Stock2 Primitive Endpoint
7 * POST /api/v1/openapi/stock2/primitive
8 * Process stock primitive commands for low-level stock control
10export async function POST(request: NextRequest) {
12 const authData = await getStoredAuth();
13 if (!authData || !authData.authenticated) {
14 return NextResponse.json(
15 { error: 'Authentication required' },
20 const body = await request.json();
22 const result = await fieldpineServerApi.apiCall("/Stock2/Primitive", {
25 cookie: authData.apiKey,
29 return NextResponse.json({
36 console.error('Stock2 Primitive POST error:', error);
37 return NextResponse.json(
38 { error: 'Failed to process stock primitive' },