|
@@ -272,6 +272,55 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
requiresAuth: true
|
|
requiresAuth: true
|
|
|
}
|
|
}
|
|
|
),
|
|
),
|
|
|
|
|
+ this.createEndpoint(
|
|
|
|
|
+ 'PATCH',
|
|
|
|
|
+ '/api/shops/:id/qdrant',
|
|
|
|
|
+ this.updateQdrantStatus.bind(this),
|
|
|
|
|
+ {
|
|
|
|
|
+ summary: 'Enable or disable Qdrant vector search',
|
|
|
|
|
+ description: 'Updates the Qdrant integration status for a shop',
|
|
|
|
|
+ tags: ['Shops'],
|
|
|
|
|
+ parameters: [
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'id',
|
|
|
|
|
+ in: 'path',
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ description: 'Shop ID (internal UUID or custom UUID)'
|
|
|
|
|
+ }
|
|
|
|
|
+ ],
|
|
|
|
|
+ requestBody: {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ schema: {
|
|
|
|
|
+ type: 'object',
|
|
|
|
|
+ properties: {
|
|
|
|
|
+ enabled: {
|
|
|
|
|
+ type: 'boolean',
|
|
|
|
|
+ description: 'Whether to enable or disable Qdrant integration'
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ required: ['enabled']
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ responses: {
|
|
|
|
|
+ '200': {
|
|
|
|
|
+ description: 'Qdrant status updated',
|
|
|
|
|
+ schema: {
|
|
|
|
|
+ type: 'object',
|
|
|
|
|
+ properties: {
|
|
|
|
|
+ shop_id: { type: 'string' },
|
|
|
|
|
+ qdrant_enabled: { type: 'boolean' },
|
|
|
|
|
+ message: { type: 'string' }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ '404': {
|
|
|
|
|
+ description: 'Shop not found'
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ requiresAuth: true
|
|
|
|
|
+ }
|
|
|
|
|
+ ),
|
|
|
this.createEndpoint(
|
|
this.createEndpoint(
|
|
|
'DELETE',
|
|
'DELETE',
|
|
|
'/api/shops/:id',
|
|
'/api/shops/:id',
|
|
@@ -391,6 +440,7 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
url: shop.url,
|
|
url: shop.url,
|
|
|
sitemap_url: shop.sitemap_url,
|
|
sitemap_url: shop.sitemap_url,
|
|
|
webshop_type: shop.webshop_type,
|
|
webshop_type: shop.webshop_type,
|
|
|
|
|
+ qdrant_enabled: shop.qdrant_enabled,
|
|
|
created_at: shop.created_at,
|
|
created_at: shop.created_at,
|
|
|
updated_at: shop.updated_at
|
|
updated_at: shop.updated_at
|
|
|
},
|
|
},
|
|
@@ -595,6 +645,40 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private async updateQdrantStatus(req: Request, res: Response): Promise<void> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (!this.db) {
|
|
|
|
|
+ res.status(503).json({ error: 'Database not available' });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const { id } = req.params;
|
|
|
|
|
+ const { enabled } = req.body;
|
|
|
|
|
+
|
|
|
|
|
+ if (typeof enabled !== 'boolean') {
|
|
|
|
|
+ res.status(400).json({ error: 'enabled field must be a boolean' });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const shop = this.db.getShopByAnyId(id);
|
|
|
|
|
+ if (!shop) {
|
|
|
|
|
+ res.status(404).json({ error: 'Shop not found' });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.db.setQdrantEnabled(shop.id, enabled);
|
|
|
|
|
+
|
|
|
|
|
+ res.json({
|
|
|
|
|
+ shop_id: shop.id,
|
|
|
|
|
+ qdrant_enabled: enabled,
|
|
|
|
|
+ message: `Qdrant ${enabled ? 'enabled' : 'disabled'} successfully`
|
|
|
|
|
+ });
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ logger.error('Error updating Qdrant status', error);
|
|
|
|
|
+ res.status(500).json({ error: 'Internal server error' });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private async deleteShop(req: Request, res: Response): Promise<void> {
|
|
private async deleteShop(req: Request, res: Response): Promise<void> {
|
|
|
try {
|
|
try {
|
|
|
if (!this.db) {
|
|
if (!this.db) {
|