- 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
6.7 KiB
🔧 AppWrite Collection Setup Guide
Problem Identified ❌
Your AppWrite collections are missing the required userId attribute. The error shows:
Invalid query: Attribute not found in schema: userId
Required Collections & Attributes ✅
You need to create these exact collections with exact attributes in your AppWrite console:
1. Collection: amazon-ext-enhanced-items
Purpose: Enhanced items with AI-generated titles
Required Attributes:
userId (string, required, 255 chars) - User identification
title (string, required, 500 chars) - Product title
url (string, required, 1000 chars) - Product URL
price (string, optional, 50 chars) - Product price
image (string, optional, 1000 chars) - Product image URL
brand (string, optional, 100 chars) - Product brand
aiTitle (string, optional, 500 chars) - AI-generated title
createdAt (datetime, required) - Creation timestamp
updatedAt (datetime, required) - Last update timestamp
2. Collection: amazon-ext-saved-products
Purpose: Basic saved products
Required Attributes:
userId (string, required, 255 chars) - User identification
title (string, required, 500 chars) - Product title
url (string, required, 1000 chars) - Product URL
price (string, optional, 50 chars) - Product price
image (string, optional, 1000 chars) - Product image URL
createdAt (datetime, required) - Creation timestamp
3. Collection: amazon_ext_blacklist
Purpose: Blacklisted brands per user
Required Attributes:
userId (string, required, 255 chars) - User identification
brand (string, required, 100 chars) - Brand name
createdAt (datetime, required) - Creation timestamp
4. Collection: amazon-ext-enhanced-settings
Purpose: User settings and API keys (encrypted)
Required Attributes:
userId (string, required, 255 chars) - User identification
settingKey (string, required, 100 chars) - Setting key name
settingValue (string, required, 2000 chars) - Setting value (encrypted for sensitive data)
isEncrypted (boolean, required) - Whether value is encrypted
updatedAt (datetime, required) - Last update timestamp
5. Collection: amazon-ext-migration-status
Purpose: Track data migration from localStorage
Required Attributes:
userId (string, required, 255 chars) - User identification
migrationType (string, required, 50 chars) - Type of migration
status (string, required, 20 chars) - 'pending', 'completed', 'failed'
itemCount (integer, optional) - Number of items migrated
errorMessage (string, optional, 1000 chars) - Error message if failed
completedAt (datetime, optional) - Completion timestamp
Step-by-Step Setup Instructions 📋
Step 1: Access AppWrite Console
- Go to your AppWrite console: https://appwrite.webklar.com (or your AppWrite URL)
- Login with your credentials
- Select your project:
6963df38003b96dab5aa
Step 2: Navigate to Database
- Click "Databases" in the left sidebar
- Select database:
amazon-extension-db - You should see your existing collections
Step 3: Fix Each Collection
For each collection listed above:
- Click on the collection name
- Go to "Attributes" tab
- Check if
userIdattribute exists - If missing, click "Create Attribute":
- Type:
String - Key:
userId - Size:
255 - Required:
Yes - Array:
No
- Type:
- Add any other missing attributes from the lists above
Step 4: Set Permissions
For each collection, go to "Settings" tab and set permissions:
CRITICAL PERMISSIONS (must be exact):
- Create:
users - Read:
user:$userId - Update:
user:$userId - Delete:
user:$userId
How to set permissions:
- Click on collection name
- Click "Settings" tab (not "Attributes")
- Scroll to "Permissions" section
- For each permission type, click "Add a permission"
- Select the appropriate permission from dropdown
- Click "Update" to save
What these permissions mean:
users= Any authenticated useruser:$userId= Only the user whose ID matches the document's userId field
This ensures data isolation - users can only see their own data!
Quick Fix Commands 🚀
If you have AppWrite CLI installed, you can run these commands:
# Add userId attribute to enhanced-items collection
appwrite databases createStringAttribute \
--databaseId amazon-extension-db \
--collectionId amazon-ext-enhanced-items \
--key userId \
--size 255 \
--required true
# Add userId attribute to saved-products collection
appwrite databases createStringAttribute \
--databaseId amazon-extension-db \
--collectionId amazon-ext-saved-products \
--key userId \
--size 255 \
--required true
# Add userId attribute to blacklist collection
appwrite databases createStringAttribute \
--databaseId amazon-extension-db \
--collectionId amazon_ext_blacklist \
--key userId \
--size 255 \
--required true
# Add userId attribute to settings collection
appwrite databases createStringAttribute \
--databaseId amazon-extension-db \
--collectionId amazon-ext-enhanced-settings \
--key userId \
--size 255 \
--required true
# Add userId attribute to migration-status collection
appwrite databases createStringAttribute \
--databaseId amazon-extension-db \
--collectionId amazon-ext-migration-status \
--key userId \
--size 255 \
--required true
Verification ✅
After adding the attributes, test the extension:
- Reload the extension in Chrome
- Go to Amazon (amazon.de/s?k=smartphone)
- Check browser console - should see no more "userId" errors
- Try Enhanced Items - should work without errors
Expected Console Messages ✅
After fixing the collections, you should see:
✅ AppWrite connection successful
✅ Collections accessible
✅ Real-time sync working
✅ No more "userId" errors
If You Still See Errors ❌
- Double-check collection names - they must match exactly
- Verify attribute names -
userIdis case-sensitive - Check permissions - users must have read/write access
- Clear browser cache - reload the extension completely
Alternative: Recreate Collections 🔄
If adding attributes doesn't work, you can:
- Delete existing collections (backup data first!)
- Create new collections with all required attributes
- Set proper permissions
- Test the extension
This will give you a clean setup that matches the extension's expectations.