fix: extend architecture validation to vendor/shared JS files
- Include static/vendor/js and static/shared/js in JS validation - Fix onboarding.js: use apiClient (not window.apiClient), use logger - Fix onboarding.js: use relative paths (not /api/v1/ prefix) - Add noqa comments for standalone pages (login, onboarding) - Add ...data() to messages.js for layout inheritance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2689,7 +2689,12 @@ class ArchitectureValidator:
|
|||||||
"""Validate JavaScript patterns"""
|
"""Validate JavaScript patterns"""
|
||||||
print("🟨 Validating JavaScript...")
|
print("🟨 Validating JavaScript...")
|
||||||
|
|
||||||
js_files = list(target_path.glob("static/admin/js/**/*.js"))
|
# Include admin, vendor, and shared JS files
|
||||||
|
js_files = (
|
||||||
|
list(target_path.glob("static/admin/js/**/*.js"))
|
||||||
|
+ list(target_path.glob("static/vendor/js/**/*.js"))
|
||||||
|
+ list(target_path.glob("static/shared/js/**/*.js"))
|
||||||
|
)
|
||||||
self.result.files_checked += len(js_files)
|
self.result.files_checked += len(js_files)
|
||||||
|
|
||||||
for file_path in js_files:
|
for file_path in js_files:
|
||||||
|
|||||||
2
static/vendor/js/login.js
vendored
2
static/vendor/js/login.js
vendored
@@ -1,4 +1,6 @@
|
|||||||
// app/static/vendor/js/login.js
|
// app/static/vendor/js/login.js
|
||||||
|
// noqa: js-003 - Standalone login page without vendor layout
|
||||||
|
// noqa: js-004 - Standalone page has no currentPage sidebar highlight
|
||||||
/**
|
/**
|
||||||
* Vendor login page logic
|
* Vendor login page logic
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
static/vendor/js/messages.js
vendored
2
static/vendor/js/messages.js
vendored
@@ -15,6 +15,8 @@ const messagesLog = window.LogConfig?.createLogger('VENDOR-MESSAGES') || console
|
|||||||
*/
|
*/
|
||||||
function vendorMessages(initialConversationId = null) {
|
function vendorMessages(initialConversationId = null) {
|
||||||
return {
|
return {
|
||||||
|
...data(),
|
||||||
|
|
||||||
// Loading states
|
// Loading states
|
||||||
loading: true,
|
loading: true,
|
||||||
loadingConversations: false,
|
loadingConversations: false,
|
||||||
|
|||||||
34
static/vendor/js/onboarding.js
vendored
34
static/vendor/js/onboarding.js
vendored
@@ -1,4 +1,6 @@
|
|||||||
// static/vendor/js/onboarding.js
|
// static/vendor/js/onboarding.js
|
||||||
|
// noqa: js-003 - Standalone page without vendor layout (no base.html extends)
|
||||||
|
// noqa: js-004 - Standalone page has no currentPage sidebar highlight
|
||||||
/**
|
/**
|
||||||
* Vendor Onboarding Wizard
|
* Vendor Onboarding Wizard
|
||||||
*
|
*
|
||||||
@@ -9,6 +11,8 @@
|
|||||||
* 4. Order Sync (historical import)
|
* 4. Order Sync (historical import)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const onboardingLog = window.LogConfig?.createLogger('ONBOARDING') || console;
|
||||||
|
|
||||||
function vendorOnboarding() {
|
function vendorOnboarding() {
|
||||||
return {
|
return {
|
||||||
// State
|
// State
|
||||||
@@ -88,7 +92,7 @@ function vendorOnboarding() {
|
|||||||
this.error = null;
|
this.error = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await apiClient.get('/api/v1/vendor/onboarding/status');
|
const response = await apiClient.get('/vendor/onboarding/status');
|
||||||
this.status = response;
|
this.status = response;
|
||||||
this.currentStep = response.current_step;
|
this.currentStep = response.current_step;
|
||||||
this.completedSteps = response.completed_steps_count;
|
this.completedSteps = response.completed_steps_count;
|
||||||
@@ -107,7 +111,7 @@ function vendorOnboarding() {
|
|||||||
// Load step-specific data
|
// Load step-specific data
|
||||||
await this.loadStepData();
|
await this.loadStepData();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to load onboarding status:', err);
|
onboardingLog.error('Failed to load onboarding status:', err);
|
||||||
this.error = err.message || 'Failed to load onboarding status';
|
this.error = err.message || 'Failed to load onboarding status';
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
@@ -118,12 +122,12 @@ function vendorOnboarding() {
|
|||||||
async loadStepData() {
|
async loadStepData() {
|
||||||
try {
|
try {
|
||||||
if (this.currentStep === 'company_profile') {
|
if (this.currentStep === 'company_profile') {
|
||||||
const data = await apiClient.get('/api/v1/vendor/onboarding/step/company-profile');
|
const data = await apiClient.get('/vendor/onboarding/step/company-profile');
|
||||||
if (data) {
|
if (data) {
|
||||||
Object.assign(this.formData, data);
|
Object.assign(this.formData, data);
|
||||||
}
|
}
|
||||||
} else if (this.currentStep === 'product_import') {
|
} else if (this.currentStep === 'product_import') {
|
||||||
const data = await apiClient.get('/api/v1/vendor/onboarding/step/product-import');
|
const data = await apiClient.get('/vendor/onboarding/step/product-import');
|
||||||
if (data) {
|
if (data) {
|
||||||
Object.assign(this.formData, {
|
Object.assign(this.formData, {
|
||||||
csv_url_fr: data.csv_url_fr || '',
|
csv_url_fr: data.csv_url_fr || '',
|
||||||
@@ -136,7 +140,7 @@ function vendorOnboarding() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn('Failed to load step data:', err);
|
onboardingLog.warn('Failed to load step data:', err);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -163,7 +167,7 @@ function vendorOnboarding() {
|
|||||||
this.connectionError = null;
|
this.connectionError = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await apiClient.post('/api/v1/vendor/onboarding/step/letzshop-api/test', {
|
const response = await apiClient.post('/vendor/onboarding/step/letzshop-api/test', {
|
||||||
api_key: this.formData.api_key,
|
api_key: this.formData.api_key,
|
||||||
shop_slug: this.formData.shop_slug,
|
shop_slug: this.formData.shop_slug,
|
||||||
});
|
});
|
||||||
@@ -187,7 +191,7 @@ function vendorOnboarding() {
|
|||||||
this.saving = true;
|
this.saving = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await apiClient.post('/api/v1/vendor/onboarding/step/order-sync/trigger', {
|
const response = await apiClient.post('/vendor/onboarding/step/order-sync/trigger', {
|
||||||
days_back: parseInt(this.formData.days_back),
|
days_back: parseInt(this.formData.days_back),
|
||||||
include_products: true,
|
include_products: true,
|
||||||
});
|
});
|
||||||
@@ -199,7 +203,7 @@ function vendorOnboarding() {
|
|||||||
throw new Error(response.message || 'Failed to start import');
|
throw new Error(response.message || 'Failed to start import');
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to start order sync:', err);
|
onboardingLog.error('Failed to start order sync:', err);
|
||||||
this.error = err.message || 'Failed to start import';
|
this.error = err.message || 'Failed to start import';
|
||||||
} finally {
|
} finally {
|
||||||
this.saving = false;
|
this.saving = false;
|
||||||
@@ -217,7 +221,7 @@ function vendorOnboarding() {
|
|||||||
async pollSyncProgress() {
|
async pollSyncProgress() {
|
||||||
try {
|
try {
|
||||||
const response = await apiClient.get(
|
const response = await apiClient.get(
|
||||||
`/api/v1/vendor/onboarding/step/order-sync/progress/${this.syncJobId}`
|
`/vendor/onboarding/step/order-sync/progress/${this.syncJobId}`
|
||||||
);
|
);
|
||||||
|
|
||||||
this.syncProgress = response.progress_percentage || 0;
|
this.syncProgress = response.progress_percentage || 0;
|
||||||
@@ -230,7 +234,7 @@ function vendorOnboarding() {
|
|||||||
this.syncProgress = response.status === 'completed' ? 100 : this.syncProgress;
|
this.syncProgress = response.status === 'completed' ? 100 : this.syncProgress;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to poll sync progress:', err);
|
onboardingLog.error('Failed to poll sync progress:', err);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -265,7 +269,7 @@ function vendorOnboarding() {
|
|||||||
|
|
||||||
switch (this.currentStep) {
|
switch (this.currentStep) {
|
||||||
case 'company_profile':
|
case 'company_profile':
|
||||||
endpoint = '/api/v1/vendor/onboarding/step/company-profile';
|
endpoint = '/vendor/onboarding/step/company-profile';
|
||||||
payload = {
|
payload = {
|
||||||
company_name: this.formData.company_name,
|
company_name: this.formData.company_name,
|
||||||
brand_name: this.formData.brand_name,
|
brand_name: this.formData.brand_name,
|
||||||
@@ -281,7 +285,7 @@ function vendorOnboarding() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'letzshop_api':
|
case 'letzshop_api':
|
||||||
endpoint = '/api/v1/vendor/onboarding/step/letzshop-api';
|
endpoint = '/vendor/onboarding/step/letzshop-api';
|
||||||
payload = {
|
payload = {
|
||||||
api_key: this.formData.api_key,
|
api_key: this.formData.api_key,
|
||||||
shop_slug: this.formData.shop_slug,
|
shop_slug: this.formData.shop_slug,
|
||||||
@@ -289,7 +293,7 @@ function vendorOnboarding() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'product_import':
|
case 'product_import':
|
||||||
endpoint = '/api/v1/vendor/onboarding/step/product-import';
|
endpoint = '/vendor/onboarding/step/product-import';
|
||||||
payload = {
|
payload = {
|
||||||
csv_url_fr: this.formData.csv_url_fr || null,
|
csv_url_fr: this.formData.csv_url_fr || null,
|
||||||
csv_url_en: this.formData.csv_url_en || null,
|
csv_url_en: this.formData.csv_url_en || null,
|
||||||
@@ -302,7 +306,7 @@ function vendorOnboarding() {
|
|||||||
|
|
||||||
case 'order_sync':
|
case 'order_sync':
|
||||||
// Complete onboarding
|
// Complete onboarding
|
||||||
endpoint = '/api/v1/vendor/onboarding/step/order-sync/complete';
|
endpoint = '/vendor/onboarding/step/order-sync/complete';
|
||||||
payload = {
|
payload = {
|
||||||
job_id: this.syncJobId,
|
job_id: this.syncJobId,
|
||||||
};
|
};
|
||||||
@@ -330,7 +334,7 @@ function vendorOnboarding() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to save step:', err);
|
onboardingLog.error('Failed to save step:', err);
|
||||||
this.error = err.message || 'Failed to save. Please try again.';
|
this.error = err.message || 'Failed to save. Please try again.';
|
||||||
} finally {
|
} finally {
|
||||||
this.saving = false;
|
this.saving = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user