Files
ebaysnipeextension/APPWRITE_COLLECTION_SETUP.md
Kenso Grimm 216a972fef 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
2026-01-12 17:46:42 +01:00

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

  1. Go to your AppWrite console: https://appwrite.webklar.com (or your AppWrite URL)
  2. Login with your credentials
  3. Select your project: 6963df38003b96dab5aa

Step 2: Navigate to Database

  1. Click "Databases" in the left sidebar
  2. Select database: amazon-extension-db
  3. You should see your existing collections

Step 3: Fix Each Collection

For each collection listed above:

  1. Click on the collection name
  2. Go to "Attributes" tab
  3. Check if userId attribute exists
  4. If missing, click "Create Attribute":
    • Type: String
    • Key: userId
    • Size: 255
    • Required: Yes
    • Array: No
  5. 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:

  1. Click on collection name
  2. Click "Settings" tab (not "Attributes")
  3. Scroll to "Permissions" section
  4. For each permission type, click "Add a permission"
  5. Select the appropriate permission from dropdown
  6. Click "Update" to save

What these permissions mean:

  • users = Any authenticated user
  • user:$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:

  1. Reload the extension in Chrome
  2. Go to Amazon (amazon.de/s?k=smartphone)
  3. Check browser console - should see no more "userId" errors
  4. 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

  1. Double-check collection names - they must match exactly
  2. Verify attribute names - userId is case-sensitive
  3. Check permissions - users must have read/write access
  4. Clear browser cache - reload the extension completely

Alternative: Recreate Collections 🔄

If adding attributes doesn't work, you can:

  1. Delete existing collections (backup data first!)
  2. Create new collections with all required attributes
  3. Set proper permissions
  4. Test the extension

This will give you a clean setup that matches the extension's expectations.