chore: initialize project repository with core extension files

- Add .gitignore to exclude node_modules, dist, logs, and system files
- Add comprehensive project documentation including README, deployment guide, and development setup
- Add .kiro project specifications for amazon-product-bar-extension, appwrite-cloud-storage, appwrite-userid-repair, blacklist-feature, and enhanced-item-management
- Add .kiro steering documents for product, structure, styling, and tech guidelines
- Add VSCode settings configuration for consistent development environment
- Add manifest.json and babel/vite configuration for extension build setup
- Add complete source code implementation including AppWrite integration, storage managers, UI components, and services
- Add comprehensive test suite with Jest configuration and 30+ test files covering all major modules
- Add test HTML files for integration testing and validation
- Add coverage reports and build validation scripts
- Add AppWrite setup and repair documentation for database schema management
- Add migration guides and responsive accessibility implementation documentation
- Establish foundation for Amazon product bar extension with full feature set including blacklist management, enhanced item workflows, and real-time synchronization
This commit is contained in:
2026-01-12 17:46:42 +01:00
commit 216a972fef
180 changed files with 88019 additions and 0 deletions

View File

@@ -0,0 +1,295 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AppWrite Collections Test - Amazon Extension</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background: #f5f5f5;
}
.test-container {
max-width: 1000px;
margin: 0 auto;
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.status {
padding: 10px;
margin: 10px 0;
border-radius: 4px;
font-weight: bold;
}
.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.warning { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }
.info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.collection-test {
margin: 15px 0;
padding: 15px;
border: 1px solid #ddd;
border-radius: 4px;
background: #fafafa;
}
.collection-name {
font-weight: bold;
color: #333;
margin-bottom: 10px;
}
.attribute-list {
font-family: monospace;
font-size: 12px;
background: #f8f9fa;
padding: 10px;
border-radius: 4px;
margin: 10px 0;
}
button {
background: #007bff;
color: white;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
margin: 5px;
}
button:hover {
background: #0056b3;
}
.log {
background: #f8f9fa;
border: 1px solid #e9ecef;
padding: 10px;
margin: 10px 0;
border-radius: 4px;
font-family: monospace;
font-size: 12px;
max-height: 400px;
overflow-y: auto;
}
</style>
</head>
<body>
<div class="test-container">
<h1>🔧 AppWrite Collections Test</h1>
<div class="status info">
<strong>Purpose:</strong> Verify that all AppWrite collections have the required attributes, especially the critical <code>userId</code> attribute.
</div>
<div class="status error" id="main-error" style="display: none;">
<strong>Critical Issue Found:</strong> <span id="error-message"></span>
</div>
<div class="status success" id="main-success" style="display: none;">
<strong>All Collections Valid:</strong> Your AppWrite setup is correct!
</div>
<button onclick="testAllCollections()">🧪 Test All Collections</button>
<button onclick="clearLog()">Clear Log</button>
<h2>Required Collections & Attributes</h2>
<div class="collection-test">
<div class="collection-name">1. amazon-ext-enhanced-items</div>
<div class="attribute-list">
Required: userId (string), title (string), url (string), createdAt (datetime), updatedAt (datetime)
Optional: price (string), image (string), brand (string), aiTitle (string)
</div>
<button onclick="testCollection('amazon-ext-enhanced-items')">Test This Collection</button>
</div>
<div class="collection-test">
<div class="collection-name">2. amazon-ext-saved-products</div>
<div class="attribute-list">
Required: userId (string), title (string), url (string), createdAt (datetime)
Optional: price (string), image (string)
</div>
<button onclick="testCollection('amazon-ext-saved-products')">Test This Collection</button>
</div>
<div class="collection-test">
<div class="collection-name">3. amazon_ext_blacklist</div>
<div class="attribute-list">
Required: userId (string), brand (string), createdAt (datetime)
</div>
<button onclick="testCollection('amazon_ext_blacklist')">Test This Collection</button>
</div>
<div class="collection-test">
<div class="collection-name">4. amazon-ext-enhanced-settings</div>
<div class="attribute-list">
Required: userId (string), settingKey (string), settingValue (string), isEncrypted (boolean), updatedAt (datetime)
</div>
<button onclick="testCollection('amazon-ext-enhanced-settings')">Test This Collection</button>
</div>
<div class="collection-test">
<div class="collection-name">5. amazon-ext-migration-status</div>
<div class="attribute-list">
Required: userId (string), migrationType (string), status (string)
Optional: itemCount (integer), errorMessage (string), completedAt (datetime)
</div>
<button onclick="testCollection('amazon-ext-migration-status')">Test This Collection</button>
</div>
<h2>Test Log</h2>
<div id="test-log" class="log">Waiting for tests...</div>
</div>
<!-- Load the extension content script -->
<script src="dist/content.js"></script>
<script>
let logContainer = document.getElementById('test-log');
let testResults = {};
function log(message, type = 'info') {
const timestamp = new Date().toLocaleTimeString();
const logEntry = document.createElement('div');
logEntry.innerHTML = `<span style="color: #666;">[${timestamp}]</span> <span style="color: ${type === 'error' ? 'red' : type === 'success' ? 'green' : type === 'warning' ? 'orange' : 'blue'};">${message}</span>`;
logContainer.appendChild(logEntry);
logContainer.scrollTop = logContainer.scrollHeight;
}
function clearLog() {
logContainer.innerHTML = 'Log cleared...';
testResults = {};
}
function showMainError(message) {
document.getElementById('main-error').style.display = 'block';
document.getElementById('main-success').style.display = 'none';
document.getElementById('error-message').textContent = message;
}
function showMainSuccess() {
document.getElementById('main-error').style.display = 'none';
document.getElementById('main-success').style.display = 'block';
}
async function testCollection(collectionId) {
log(`🧪 Testing collection: ${collectionId}`, 'info');
if (!window.appWriteManager) {
log('❌ AppWriteManager not available', 'error');
testResults[collectionId] = { success: false, error: 'AppWriteManager not available' };
return;
}
try {
// Try to query the collection with userId filter
// This will fail if userId attribute doesn't exist or permissions are wrong
const testQuery = {
method: 'equal',
attribute: 'userId',
values: ['test-user-id']
};
log(` Testing userId attribute and permissions...`, 'info');
// This should either return empty results or fail with specific errors
const result = await window.appWriteManager.listDocuments(collectionId, [testQuery]);
log(` ✅ Collection ${collectionId} has userId attribute and correct permissions`, 'success');
log(` 📊 Query returned ${result.documents?.length || 0} documents`, 'info');
testResults[collectionId] = { success: true, documents: result.documents?.length || 0 };
} catch (error) {
if (error.message.includes('Attribute not found in schema: userId')) {
log(` ❌ CRITICAL: Collection ${collectionId} missing userId attribute!`, 'error');
log(` 🔧 Fix: Add userId (string, required, 255 chars) to this collection`, 'warning');
testResults[collectionId] = { success: false, error: 'Missing userId attribute' };
} else if (error.message.includes('Collection not found')) {
log(` ❌ Collection ${collectionId} does not exist!`, 'error');
log(` 🔧 Fix: Create this collection in AppWrite console`, 'warning');
testResults[collectionId] = { success: false, error: 'Collection not found' };
} else if (error.message.includes('not authorized') || error.message.includes('401')) {
log(` ❌ PERMISSIONS: Collection ${collectionId} has incorrect permissions!`, 'error');
log(` 🔧 Fix: Set permissions - Create: users, Read/Update/Delete: user:$userId`, 'warning');
testResults[collectionId] = { success: false, error: 'Permission denied - fix collection permissions' };
} else {
log(` ⚠️ Collection ${collectionId} test failed: ${error.message}`, 'warning');
log(` This might be a configuration issue`, 'info');
testResults[collectionId] = { success: false, error: error.message };
}
}
}
async function testAllCollections() {
log('🚀 Starting comprehensive collection test...', 'info');
const collections = [
'amazon-ext-enhanced-items',
'amazon-ext-saved-products',
'amazon_ext_blacklist',
'amazon-ext-enhanced-settings',
'amazon-ext-migration-status'
];
testResults = {};
for (const collection of collections) {
await testCollection(collection);
// Small delay between tests
await new Promise(resolve => setTimeout(resolve, 500));
}
// Analyze results
const totalCollections = collections.length;
const successfulCollections = Object.values(testResults).filter(r => r.success).length;
const failedCollections = totalCollections - successfulCollections;
log(`\n📊 Test Summary:`, 'info');
log(` ✅ Successful: ${successfulCollections}/${totalCollections}`, successfulCollections === totalCollections ? 'success' : 'warning');
log(` ❌ Failed: ${failedCollections}/${totalCollections}`, failedCollections === 0 ? 'success' : 'error');
if (failedCollections === 0) {
log(`\n🎉 All collections are properly configured!`, 'success');
showMainSuccess();
} else {
log(`\n🔧 Action Required: Fix the failed collections`, 'error');
log(` 1. Go to AppWrite Console → Databases → amazon-extension-db`, 'info');
log(` 2. For each failed collection, add missing userId attribute`, 'info');
log(` 3. See APPWRITE_COLLECTION_SETUP.md for detailed instructions`, 'info');
showMainError(`${failedCollections} collections need to be fixed`);
}
// Show specific failures
Object.entries(testResults).forEach(([collection, result]) => {
if (!result.success) {
log(`${collection}: ${result.error}`, 'error');
}
});
}
// Auto-run test when page loads
window.addEventListener('load', () => {
log('🔧 AppWrite Collections Test loaded', 'info');
// Wait for extension to initialize
setTimeout(() => {
if (window.appWriteManager) {
log('✅ AppWriteManager detected', 'success');
// Auto-run the test
setTimeout(testAllCollections, 1000);
} else {
log('❌ AppWriteManager not found - extension may not be loaded', 'error');
}
}, 2000);
});
</script>
</body>
</html>