|
|
@@ -1,10 +1,10 @@
|
|
|
import { Request, Response } from 'express';
|
|
|
import { BaseEndpointComponent, EndpointMethod } from '../core/types';
|
|
|
import { logger } from '../../utils/logger';
|
|
|
-import { ShopDatabase } from '../../database/Database';
|
|
|
+import { SiteDatabase } from '../../database/Database';
|
|
|
|
|
|
-export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
- constructor(private db: ShopDatabase) {
|
|
|
+export class SitesEndpoint extends BaseEndpointComponent {
|
|
|
+ constructor(private db: SiteDatabase) {
|
|
|
super();
|
|
|
}
|
|
|
|
|
|
@@ -12,33 +12,33 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
return [
|
|
|
this.createEndpoint(
|
|
|
'GET',
|
|
|
- '/api/shops',
|
|
|
+ '/api/sites',
|
|
|
this.getAllShops.bind(this),
|
|
|
{
|
|
|
- summary: 'List all shops',
|
|
|
- description: 'Retrieves a list of all shops with their analytics',
|
|
|
- tags: ['Shops'],
|
|
|
+ summary: 'List all sites',
|
|
|
+ description: 'Retrieves a list of all sites with their analytics',
|
|
|
+ tags: ['Sites'],
|
|
|
parameters: [
|
|
|
{
|
|
|
name: 'limit',
|
|
|
in: 'query',
|
|
|
type: 'number',
|
|
|
- description: 'Maximum number of shops to return (default: 100)'
|
|
|
+ description: 'Maximum number of sites to return (default: 100)'
|
|
|
},
|
|
|
{
|
|
|
name: 'offset',
|
|
|
in: 'query',
|
|
|
type: 'number',
|
|
|
- description: 'Number of shops to skip for pagination (default: 0)'
|
|
|
+ description: 'Number of sites to skip for pagination (default: 0)'
|
|
|
}
|
|
|
],
|
|
|
responses: {
|
|
|
'200': {
|
|
|
- description: 'List of shops with analytics',
|
|
|
+ description: 'List of sites with analytics',
|
|
|
schema: {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
- shops: {
|
|
|
+ sites: {
|
|
|
type: 'array',
|
|
|
items: {
|
|
|
type: 'object',
|
|
|
@@ -47,7 +47,7 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
custom_id: { type: 'string', nullable: true },
|
|
|
url: { type: 'string' },
|
|
|
sitemap_url: { type: 'string' },
|
|
|
- webshop_type: { type: 'string' },
|
|
|
+ site_type: { type: 'string' },
|
|
|
created_at: { type: 'string' },
|
|
|
updated_at: { type: 'string' },
|
|
|
analytics: {
|
|
|
@@ -85,28 +85,28 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
),
|
|
|
this.createEndpoint(
|
|
|
'GET',
|
|
|
- '/api/shops/:id',
|
|
|
+ '/api/sites/:id',
|
|
|
this.getShop.bind(this),
|
|
|
{
|
|
|
- summary: 'Get detailed shop information',
|
|
|
- description: 'Retrieves detailed information about a specific shop including analytics, content metadata, scrape history, and scheduled jobs',
|
|
|
- tags: ['Shops'],
|
|
|
+ summary: 'Get detailed site information',
|
|
|
+ description: 'Retrieves detailed information about a specific site including analytics, content metadata, scrape history, and scheduled jobs',
|
|
|
+ tags: ['Sites'],
|
|
|
parameters: [
|
|
|
{
|
|
|
name: 'id',
|
|
|
in: 'path',
|
|
|
type: 'string',
|
|
|
required: true,
|
|
|
- description: 'Shop ID (internal UUID or custom UUID)'
|
|
|
+ description: 'Site ID (internal UUID or custom UUID)'
|
|
|
}
|
|
|
],
|
|
|
responses: {
|
|
|
'200': {
|
|
|
- description: 'Detailed shop information',
|
|
|
+ description: 'Detailed site information',
|
|
|
schema: {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
- shop: { type: 'object' },
|
|
|
+ site: { type: 'object' },
|
|
|
analytics: { type: 'object' },
|
|
|
content_metadata: { type: 'object' },
|
|
|
scrape_history: { type: 'array' },
|
|
|
@@ -115,7 +115,7 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
}
|
|
|
},
|
|
|
'404': {
|
|
|
- description: 'Shop not found'
|
|
|
+ description: 'Site not found'
|
|
|
}
|
|
|
},
|
|
|
requiresAuth: true
|
|
|
@@ -123,19 +123,19 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
),
|
|
|
this.createEndpoint(
|
|
|
'GET',
|
|
|
- '/api/shops/:id/results',
|
|
|
+ '/api/sites/:id/results',
|
|
|
this.getShopResults.bind(this),
|
|
|
{
|
|
|
- summary: 'Get shop results with full content',
|
|
|
- description: 'Retrieves scraped content for a shop with optional filtering',
|
|
|
- tags: ['Shops'],
|
|
|
+ summary: 'Get site results with full content',
|
|
|
+ description: 'Retrieves scraped content for a site with optional filtering',
|
|
|
+ tags: ['Sites'],
|
|
|
parameters: [
|
|
|
{
|
|
|
name: 'id',
|
|
|
in: 'path',
|
|
|
type: 'string',
|
|
|
required: true,
|
|
|
- description: 'Shop ID (internal UUID or custom UUID)'
|
|
|
+ description: 'Site ID (internal UUID or custom UUID)'
|
|
|
},
|
|
|
{
|
|
|
name: 'limit',
|
|
|
@@ -170,11 +170,11 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
],
|
|
|
responses: {
|
|
|
'200': {
|
|
|
- description: 'Shop results with content',
|
|
|
+ description: 'Site results with content',
|
|
|
schema: {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
- shop_id: { type: 'string' },
|
|
|
+ site_id: { type: 'string' },
|
|
|
filters: { type: 'object' },
|
|
|
results: {
|
|
|
type: 'object',
|
|
|
@@ -189,7 +189,7 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
}
|
|
|
},
|
|
|
'404': {
|
|
|
- description: 'Shop not found'
|
|
|
+ description: 'Site not found'
|
|
|
}
|
|
|
},
|
|
|
requiresAuth: true
|
|
|
@@ -197,19 +197,19 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
),
|
|
|
this.createEndpoint(
|
|
|
'PATCH',
|
|
|
- '/api/shops/:id/schedule',
|
|
|
+ '/api/sites/:id/schedule',
|
|
|
this.updateSchedule.bind(this),
|
|
|
{
|
|
|
summary: 'Enable or disable scheduled scraping',
|
|
|
- description: 'Updates the scheduling status for a shop',
|
|
|
- tags: ['Shops'],
|
|
|
+ description: 'Updates the scheduling status for a site',
|
|
|
+ tags: ['Sites'],
|
|
|
parameters: [
|
|
|
{
|
|
|
name: 'id',
|
|
|
in: 'path',
|
|
|
type: 'string',
|
|
|
required: true,
|
|
|
- description: 'Shop ID'
|
|
|
+ description: 'Site ID'
|
|
|
}
|
|
|
],
|
|
|
requestBody: {
|
|
|
@@ -231,14 +231,14 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
schema: {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
- shop_id: { type: 'string' },
|
|
|
+ site_id: { type: 'string' },
|
|
|
schedule_enabled: { type: 'boolean' },
|
|
|
message: { type: 'string' }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
'404': {
|
|
|
- description: 'Shop not found'
|
|
|
+ description: 'Site not found'
|
|
|
}
|
|
|
},
|
|
|
requiresAuth: true
|
|
|
@@ -246,19 +246,19 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
),
|
|
|
this.createEndpoint(
|
|
|
'PATCH',
|
|
|
- '/api/shops/:id/custom-id',
|
|
|
+ '/api/sites/:id/custom-id',
|
|
|
this.updateCustomId.bind(this),
|
|
|
{
|
|
|
- summary: 'Set or update custom ID for a shop',
|
|
|
- description: 'Updates the custom UUID identifier for a shop',
|
|
|
- tags: ['Shops'],
|
|
|
+ summary: 'Set or update custom ID for a site',
|
|
|
+ description: 'Updates the custom UUID identifier for a site',
|
|
|
+ tags: ['Sites'],
|
|
|
parameters: [
|
|
|
{
|
|
|
name: 'id',
|
|
|
in: 'path',
|
|
|
type: 'string',
|
|
|
required: true,
|
|
|
- description: 'Shop ID (internal UUID or current custom UUID)'
|
|
|
+ description: 'Site ID (internal UUID or current custom UUID)'
|
|
|
}
|
|
|
],
|
|
|
requestBody: {
|
|
|
@@ -282,7 +282,7 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
schema: {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
- shop_id: { type: 'string' },
|
|
|
+ site_id: { type: 'string' },
|
|
|
custom_id: { type: 'string', nullable: true },
|
|
|
message: { type: 'string' }
|
|
|
}
|
|
|
@@ -292,7 +292,7 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
description: 'Invalid custom ID format'
|
|
|
},
|
|
|
'404': {
|
|
|
- description: 'Shop not found'
|
|
|
+ description: 'Site not found'
|
|
|
},
|
|
|
'409': {
|
|
|
description: 'Custom ID already in use'
|
|
|
@@ -303,19 +303,19 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
),
|
|
|
this.createEndpoint(
|
|
|
'PATCH',
|
|
|
- '/api/shops/:id/qdrant',
|
|
|
+ '/api/sites/:id/qdrant',
|
|
|
this.updateQdrantStatus.bind(this),
|
|
|
{
|
|
|
summary: 'Enable or disable Qdrant vector search',
|
|
|
- description: 'Updates the Qdrant integration status for a shop',
|
|
|
- tags: ['Shops'],
|
|
|
+ description: 'Updates the Qdrant integration status for a site',
|
|
|
+ tags: ['Sites'],
|
|
|
parameters: [
|
|
|
{
|
|
|
name: 'id',
|
|
|
in: 'path',
|
|
|
type: 'string',
|
|
|
required: true,
|
|
|
- description: 'Shop ID (internal UUID or custom UUID)'
|
|
|
+ description: 'Site ID (internal UUID or custom UUID)'
|
|
|
}
|
|
|
],
|
|
|
requestBody: {
|
|
|
@@ -337,14 +337,14 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
schema: {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
- shop_id: { type: 'string' },
|
|
|
+ site_id: { type: 'string' },
|
|
|
qdrant_enabled: { type: 'boolean' },
|
|
|
message: { type: 'string' }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
'404': {
|
|
|
- description: 'Shop not found'
|
|
|
+ description: 'Site not found'
|
|
|
}
|
|
|
},
|
|
|
requiresAuth: true
|
|
|
@@ -352,34 +352,34 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
),
|
|
|
this.createEndpoint(
|
|
|
'DELETE',
|
|
|
- '/api/shops/:id',
|
|
|
+ '/api/sites/:id',
|
|
|
this.deleteShop.bind(this),
|
|
|
{
|
|
|
- summary: 'Soft delete a shop',
|
|
|
- description: 'Marks a shop as deleted without removing data immediately. The shop will not appear in API responses.',
|
|
|
- tags: ['Shops'],
|
|
|
+ summary: 'Soft delete a site',
|
|
|
+ description: 'Marks a site as deleted without removing data immediately. The site will not appear in API responses.',
|
|
|
+ tags: ['Sites'],
|
|
|
parameters: [
|
|
|
{
|
|
|
name: 'id',
|
|
|
in: 'path',
|
|
|
type: 'string',
|
|
|
required: true,
|
|
|
- description: 'Shop ID (internal UUID or custom UUID)'
|
|
|
+ description: 'Site ID (internal UUID or custom UUID)'
|
|
|
}
|
|
|
],
|
|
|
responses: {
|
|
|
'200': {
|
|
|
- description: 'Shop deleted successfully',
|
|
|
+ description: 'Site deleted successfully',
|
|
|
schema: {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
message: { type: 'string' },
|
|
|
- shop_id: { type: 'string' }
|
|
|
+ site_id: { type: 'string' }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
'404': {
|
|
|
- description: 'Shop not found'
|
|
|
+ description: 'Site not found'
|
|
|
}
|
|
|
},
|
|
|
requiresAuth: true
|
|
|
@@ -387,19 +387,19 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
),
|
|
|
this.createEndpoint(
|
|
|
'GET',
|
|
|
- '/api/shops/deleted',
|
|
|
+ '/api/sites/deleted',
|
|
|
this.getDeletedShops.bind(this),
|
|
|
{
|
|
|
summary: 'List deleted shops',
|
|
|
- description: 'Retrieves a list of soft-deleted shops that can be force-deleted',
|
|
|
- tags: ['Shops'],
|
|
|
+ description: 'Retrieves a list of soft-deleted sites that can be force-deleted',
|
|
|
+ tags: ['Sites'],
|
|
|
responses: {
|
|
|
'200': {
|
|
|
description: 'List of deleted shops',
|
|
|
schema: {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
- shops: {
|
|
|
+ sites: {
|
|
|
type: 'array',
|
|
|
items: {
|
|
|
type: 'object',
|
|
|
@@ -420,34 +420,34 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
),
|
|
|
this.createEndpoint(
|
|
|
'DELETE',
|
|
|
- '/api/shops/:id/force',
|
|
|
+ '/api/sites/:id/force',
|
|
|
this.forceDeleteShop.bind(this),
|
|
|
{
|
|
|
- summary: 'Force delete a shop',
|
|
|
- description: 'Permanently removes a shop and all associated data including scrape history, scheduled jobs, content, and queues Qdrant cleanup',
|
|
|
- tags: ['Shops'],
|
|
|
+ summary: 'Force delete a site',
|
|
|
+ description: 'Permanently removes a site and all associated data including scrape history, scheduled jobs, content, and queues Qdrant cleanup',
|
|
|
+ tags: ['Sites'],
|
|
|
parameters: [
|
|
|
{
|
|
|
name: 'id',
|
|
|
in: 'path',
|
|
|
type: 'string',
|
|
|
required: true,
|
|
|
- description: 'Shop ID (internal UUID or custom UUID)'
|
|
|
+ description: 'Site ID (internal UUID or custom UUID)'
|
|
|
}
|
|
|
],
|
|
|
responses: {
|
|
|
'200': {
|
|
|
- description: 'Shop force deleted successfully',
|
|
|
+ description: 'Site force deleted successfully',
|
|
|
schema: {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
message: { type: 'string' },
|
|
|
- shop_id: { type: 'string' }
|
|
|
+ site_id: { type: 'string' }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
'404': {
|
|
|
- description: 'Shop not found'
|
|
|
+ description: 'Site not found'
|
|
|
}
|
|
|
},
|
|
|
requiresAuth: true
|
|
|
@@ -468,14 +468,14 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
const offset = req.query.offset ? parseInt(req.query.offset as string) : 0;
|
|
|
|
|
|
// Use optimized method that avoids N+1 query problem
|
|
|
- const shopsWithAnalytics = this.db.getAllShopsWithAnalytics({ limit, offset });
|
|
|
+ const sitesWithAnalytics = this.db.getAllSitesWithAnalytics({ limit, offset });
|
|
|
|
|
|
// Count total items for pagination
|
|
|
- const totalReturned = shopsWithAnalytics.length;
|
|
|
+ const totalReturned = sitesWithAnalytics.length;
|
|
|
const hasMore = totalReturned === limit;
|
|
|
|
|
|
res.json({
|
|
|
- shops: shopsWithAnalytics,
|
|
|
+ sites: sitesWithAnalytics,
|
|
|
pagination: {
|
|
|
total_returned: totalReturned,
|
|
|
limit,
|
|
|
@@ -484,7 +484,7 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
}
|
|
|
});
|
|
|
} catch (error) {
|
|
|
- logger.error('Error listing shops', error);
|
|
|
+ logger.error('Error listing sites', error);
|
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
|
}
|
|
|
}
|
|
|
@@ -497,19 +497,19 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
}
|
|
|
|
|
|
const { id } = req.params;
|
|
|
- const shop = this.db.getShopByAnyId(id);
|
|
|
+ const site = this.db.getSiteByAnyId(id);
|
|
|
|
|
|
- if (!shop) {
|
|
|
- res.status(404).json({ error: 'Shop not found' });
|
|
|
+ if (!site) {
|
|
|
+ res.status(404).json({ error: 'Site not found' });
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// Note: better-sqlite3 is synchronous, but we keep these calls organized
|
|
|
// They execute fast due to proper indexing
|
|
|
- const analytics = this.db.getShopAnalytics(shop.id);
|
|
|
- const scrapeHistory = this.db.getScrapeHistory(shop.id, 10);
|
|
|
- const latestContent = this.db.getLatestContentByType(shop.id);
|
|
|
- const scheduledJobs = this.db.getScheduledJobs(shop.id);
|
|
|
+ const analytics = this.db.getSiteAnalytics(site.id);
|
|
|
+ const scrapeHistory = this.db.getScrapeHistory(site.id, 10);
|
|
|
+ const latestContent = this.db.getLatestContentByType(site.id);
|
|
|
+ const scheduledJobs = this.db.getScheduledJobs(site.id);
|
|
|
|
|
|
// Build response with content change markers and URLs only (no content)
|
|
|
const contentMetadata: any = {
|
|
|
@@ -544,15 +544,15 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
};
|
|
|
|
|
|
res.json({
|
|
|
- shop: {
|
|
|
- id: shop.id,
|
|
|
- custom_id: shop.custom_id,
|
|
|
- url: shop.url,
|
|
|
- sitemap_url: shop.sitemap_url,
|
|
|
- webshop_type: shop.webshop_type,
|
|
|
- qdrant_enabled: shop.qdrant_enabled,
|
|
|
- created_at: shop.created_at,
|
|
|
- updated_at: shop.updated_at
|
|
|
+ site: {
|
|
|
+ id: site.id,
|
|
|
+ custom_id: site.custom_id,
|
|
|
+ url: site.url,
|
|
|
+ sitemap_url: site.sitemap_url,
|
|
|
+ site_type: site.site_type,
|
|
|
+ qdrant_enabled: site.qdrant_enabled,
|
|
|
+ created_at: site.created_at,
|
|
|
+ updated_at: site.updated_at
|
|
|
},
|
|
|
analytics: {
|
|
|
total_scrapes: analytics?.total_scrapes || 0,
|
|
|
@@ -584,7 +584,7 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
}))
|
|
|
});
|
|
|
} catch (error) {
|
|
|
- logger.error('Error fetching shop details', error);
|
|
|
+ logger.error('Error fetching site details', error);
|
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
|
}
|
|
|
}
|
|
|
@@ -597,10 +597,10 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
}
|
|
|
|
|
|
const { id } = req.params;
|
|
|
- const shop = this.db.getShopByAnyId(id);
|
|
|
+ const site = this.db.getSiteByAnyId(id);
|
|
|
|
|
|
- if (!shop) {
|
|
|
- res.status(404).json({ error: 'Shop not found' });
|
|
|
+ if (!site) {
|
|
|
+ res.status(404).json({ error: 'Site not found' });
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -612,7 +612,7 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
const contentType = req.query.content_type as string | undefined;
|
|
|
|
|
|
// Get content with filters (now returns only latest versions)
|
|
|
- const allContent = this.db.getAllContent(shop.id, {
|
|
|
+ const allContent = this.db.getAllContent(site.id, {
|
|
|
limit,
|
|
|
offset,
|
|
|
dateFrom,
|
|
|
@@ -650,7 +650,7 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
const hasMore = totalItems === limit;
|
|
|
|
|
|
res.json({
|
|
|
- shop_id: shop.id,
|
|
|
+ site_id: site.id,
|
|
|
filters: {
|
|
|
limit,
|
|
|
offset,
|
|
|
@@ -667,7 +667,7 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
results: grouped
|
|
|
});
|
|
|
} catch (error) {
|
|
|
- logger.error('Error fetching shop results', error);
|
|
|
+ logger.error('Error fetching site results', error);
|
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
|
}
|
|
|
}
|
|
|
@@ -687,17 +687,17 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // Get shop by any ID (try custom_id first, then internal ID)
|
|
|
- const shop = this.db.getShopByAnyId(id);
|
|
|
- if (!shop) {
|
|
|
- res.status(404).json({ error: 'Shop not found' });
|
|
|
+ // Get site by any ID (try custom_id first, then internal ID)
|
|
|
+ const site = this.db.getSiteByAnyId(id);
|
|
|
+ if (!site) {
|
|
|
+ res.status(404).json({ error: 'Site not found' });
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- this.db.setScheduleEnabled(shop.id, enabled);
|
|
|
+ this.db.setScheduleEnabled(site.id, enabled);
|
|
|
|
|
|
res.json({
|
|
|
- shop_id: shop.id,
|
|
|
+ site_id: site.id,
|
|
|
schedule_enabled: enabled,
|
|
|
message: `Schedule ${enabled ? 'enabled' : 'disabled'} successfully`
|
|
|
});
|
|
|
@@ -717,9 +717,9 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
const { id } = req.params;
|
|
|
const { custom_id } = req.body;
|
|
|
|
|
|
- const shop = this.db.getShopByAnyId(id);
|
|
|
- if (!shop) {
|
|
|
- res.status(404).json({ error: 'Shop not found' });
|
|
|
+ const site = this.db.getSiteByAnyId(id);
|
|
|
+ if (!site) {
|
|
|
+ res.status(404).json({ error: 'Site not found' });
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -729,23 +729,23 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // Check if custom_id is already in use by another shop
|
|
|
+ // Check if custom_id is already in use by another site
|
|
|
if (custom_id) {
|
|
|
- const existingShop = this.db.getShopByCustomId(custom_id);
|
|
|
- if (existingShop && existingShop.id !== shop.id) {
|
|
|
+ const existingShop = this.db.getSiteByCustomId(custom_id);
|
|
|
+ if (existingShop && existingShop.id !== site.id) {
|
|
|
res.status(409).json({ error: 'custom_id is already in use' });
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const success = this.db.setCustomId(shop.id, custom_id);
|
|
|
+ const success = this.db.setCustomId(site.id, custom_id);
|
|
|
if (!success) {
|
|
|
res.status(500).json({ error: 'Failed to update custom_id' });
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
res.json({
|
|
|
- shop_id: shop.id,
|
|
|
+ site_id: site.id,
|
|
|
custom_id: custom_id,
|
|
|
message: custom_id ? `Custom ID set to ${custom_id}` : 'Custom ID removed'
|
|
|
});
|
|
|
@@ -770,16 +770,16 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const shop = this.db.getShopByAnyId(id);
|
|
|
- if (!shop) {
|
|
|
- res.status(404).json({ error: 'Shop not found' });
|
|
|
+ const site = this.db.getSiteByAnyId(id);
|
|
|
+ if (!site) {
|
|
|
+ res.status(404).json({ error: 'Site not found' });
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- this.db.setQdrantEnabled(shop.id, enabled);
|
|
|
+ this.db.setQdrantEnabled(site.id, enabled);
|
|
|
|
|
|
res.json({
|
|
|
- shop_id: shop.id,
|
|
|
+ site_id: site.id,
|
|
|
qdrant_enabled: enabled,
|
|
|
message: `Qdrant ${enabled ? 'enabled' : 'disabled'} successfully`
|
|
|
});
|
|
|
@@ -797,21 +797,21 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
}
|
|
|
|
|
|
const { id } = req.params;
|
|
|
- const shop = this.db.getShopByAnyId(id);
|
|
|
+ const site = this.db.getSiteByAnyId(id);
|
|
|
|
|
|
- if (!shop) {
|
|
|
- res.status(404).json({ error: 'Shop not found' });
|
|
|
+ if (!site) {
|
|
|
+ res.status(404).json({ error: 'Site not found' });
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- this.db.deleteShop(shop.id);
|
|
|
+ this.db.deleteSite(site.id);
|
|
|
|
|
|
res.json({
|
|
|
- message: 'Shop soft deleted successfully. Use force delete to permanently remove.',
|
|
|
- shop_id: shop.id
|
|
|
+ message: 'Site soft deleted successfully. Use force delete to permanently remove.',
|
|
|
+ site_id: site.id
|
|
|
});
|
|
|
} catch (error) {
|
|
|
- logger.error('Error deleting shop', error);
|
|
|
+ logger.error('Error deleting site', error);
|
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
|
}
|
|
|
}
|
|
|
@@ -823,11 +823,11 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const shops = this.db.getDeletedShops();
|
|
|
+ const shops = this.db.getDeletedSites();
|
|
|
|
|
|
res.json({ shops });
|
|
|
} catch (error) {
|
|
|
- logger.error('Error listing deleted shops', error);
|
|
|
+ logger.error('Error listing deleted sites', error);
|
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
|
}
|
|
|
}
|
|
|
@@ -841,24 +841,24 @@ export class ShopsEndpoint extends BaseEndpointComponent {
|
|
|
|
|
|
const { id } = req.params;
|
|
|
|
|
|
- // Find shop without filtering deleted_at
|
|
|
+ // Find site without filtering deleted_at
|
|
|
const stmt = (this.db as any).db.prepare('SELECT * FROM shops WHERE id = ? OR custom_id = ?');
|
|
|
const result = stmt.get(id, id) as any;
|
|
|
- const shop = result ? { ...result, qdrant_enabled: Boolean(result.qdrant_enabled) } : null;
|
|
|
+ const site = result ? { ...result, qdrant_enabled: Boolean(result.qdrant_enabled) } : null;
|
|
|
|
|
|
- if (!shop) {
|
|
|
- res.status(404).json({ error: 'Shop not found' });
|
|
|
+ if (!site) {
|
|
|
+ res.status(404).json({ error: 'Site not found' });
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- this.db.forceDeleteShop(shop.id);
|
|
|
+ this.db.forceDeleteSite(site.id);
|
|
|
|
|
|
res.json({
|
|
|
- message: 'Shop and all related data permanently deleted. Qdrant cleanup queued.',
|
|
|
- shop_id: shop.id
|
|
|
+ message: 'Site and all related data permanently deleted. Qdrant cleanup queued.',
|
|
|
+ site_id: site.id
|
|
|
});
|
|
|
} catch (error) {
|
|
|
- logger.error('Error force deleting shop', error);
|
|
|
+ logger.error('Error force deleting site', error);
|
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
|
}
|
|
|
}
|