|
@@ -66,7 +66,10 @@ serve(wrapHandler('shoprenter-scheduled-sync', async (req) => {
|
|
|
sync_orders,
|
|
sync_orders,
|
|
|
sync_customers,
|
|
sync_customers,
|
|
|
last_sync_at,
|
|
last_sync_at,
|
|
|
- next_sync_at
|
|
|
|
|
|
|
+ next_sync_at,
|
|
|
|
|
+ products_access_policy,
|
|
|
|
|
+ customers_access_policy,
|
|
|
|
|
+ orders_access_policy
|
|
|
)
|
|
)
|
|
|
`)
|
|
`)
|
|
|
.eq('platform_name', 'shoprenter')
|
|
.eq('platform_name', 'shoprenter')
|
|
@@ -136,8 +139,19 @@ serve(wrapHandler('shoprenter-scheduled-sync', async (req) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- // Sync Products (only data type we cache now for GDPR compliance)
|
|
|
|
|
- if (config?.sync_products !== false) {
|
|
|
|
|
|
|
+ // Check access policies (GDPR compliance - Issue #95)
|
|
|
|
|
+ const productsPolicy = config?.products_access_policy || 'sync'
|
|
|
|
|
+ const ordersPolicy = config?.orders_access_policy || 'sync'
|
|
|
|
|
+ const customersPolicy = config?.customers_access_policy || 'sync'
|
|
|
|
|
+
|
|
|
|
|
+ console.log(`[ShopRenter Scheduled Sync] Store ${storeId} access policies:`, {
|
|
|
|
|
+ products: productsPolicy,
|
|
|
|
|
+ orders: ordersPolicy,
|
|
|
|
|
+ customers: customersPolicy
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // Sync Products (only if policy allows sync)
|
|
|
|
|
+ if (config?.sync_products !== false && productsPolicy === 'sync') {
|
|
|
try {
|
|
try {
|
|
|
console.log(`[ShopRenter Scheduled Sync] Syncing products for store ${storeId}`)
|
|
console.log(`[ShopRenter Scheduled Sync] Syncing products for store ${storeId}`)
|
|
|
let page = 0 // ShopRenter API uses zero-based pagination
|
|
let page = 0 // ShopRenter API uses zero-based pagination
|
|
@@ -195,21 +209,19 @@ serve(wrapHandler('shoprenter-scheduled-sync', async (req) => {
|
|
|
syncStats.products.errors++
|
|
syncStats.products.errors++
|
|
|
syncStats.status = 'partial'
|
|
syncStats.status = 'partial'
|
|
|
}
|
|
}
|
|
|
|
|
+ } else if (config?.sync_products !== false && productsPolicy !== 'sync') {
|
|
|
|
|
+ console.log(`[ShopRenter Scheduled Sync] Products sync skipped for store ${storeId}: access policy is '${productsPolicy}' (requires 'sync')`)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Sync Orders and Customers to Qdrant (if enabled)
|
|
|
|
|
|
|
+ // Sync Orders and Customers to Qdrant (if enabled and policy allows)
|
|
|
// Note: Orders/customers are NOT cached to database for GDPR compliance
|
|
// Note: Orders/customers are NOT cached to database for GDPR compliance
|
|
|
// They are only synced to Qdrant for AI access when flags are enabled
|
|
// They are only synced to Qdrant for AI access when flags are enabled
|
|
|
const qdrantEnabled = store.qdrant_sync_enabled !== false
|
|
const qdrantEnabled = store.qdrant_sync_enabled !== false
|
|
|
- // Report access policy status (for logging/monitoring)
|
|
|
|
|
- const canSyncOrders = config.orders_access_policy === 'sync'
|
|
|
|
|
- const canSyncCustomers = config.customers_access_policy === 'sync'
|
|
|
|
|
- const canSyncProducts = config.products_access_policy === 'sync'
|
|
|
|
|
- const shouldSyncOrders = config?.sync_orders === true
|
|
|
|
|
- const shouldSyncCustomers = config?.sync_customers === true
|
|
|
|
|
|
|
+ const shouldSyncOrders = config?.sync_orders === true && ordersPolicy === 'sync'
|
|
|
|
|
+ const shouldSyncCustomers = config?.sync_customers === true && customersPolicy === 'sync'
|
|
|
|
|
|
|
|
// Call shoprenter-sync to handle full sync (products + orders + customers)
|
|
// Call shoprenter-sync to handle full sync (products + orders + customers)
|
|
|
- // This ensures orders and customers are synced to Qdrant
|
|
|
|
|
|
|
+ // This ensures orders and customers are synced to Qdrant (only if policies allow)
|
|
|
if (qdrantEnabled && (shouldSyncOrders || shouldSyncCustomers)) {
|
|
if (qdrantEnabled && (shouldSyncOrders || shouldSyncCustomers)) {
|
|
|
try {
|
|
try {
|
|
|
console.log(`[ShopRenter Scheduled Sync] Calling shoprenter-sync for full sync on store ${storeId}`)
|
|
console.log(`[ShopRenter Scheduled Sync] Calling shoprenter-sync for full sync on store ${storeId}`)
|
|
@@ -247,8 +259,8 @@ serve(wrapHandler('shoprenter-scheduled-sync', async (req) => {
|
|
|
qdrantEnabled,
|
|
qdrantEnabled,
|
|
|
shouldSyncOrders,
|
|
shouldSyncOrders,
|
|
|
shouldSyncCustomers,
|
|
shouldSyncCustomers,
|
|
|
- canSyncOrders,
|
|
|
|
|
- canSyncCustomers
|
|
|
|
|
|
|
+ ordersPolicy,
|
|
|
|
|
+ customersPolicy
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|