- Resolved persistent 'SyntaxError: Unexpected token class' by refactoring 'MediaState' and 'UI' classes in MediaManager.html to standard ES5 function constructors. - Resolved 'SyntaxError: Unexpected identifier src' by rewriting 'createCard' to use 'document.createElement' instead of template strings for dynamic media elements. - Consolidated script tags in MediaManager.html to prevent Apps Script parser merge issues. - Updated docs/ARCHITECTURE.md and MEMORY.md to formally document client-side constraints (No ES6 classes, strict DOM manipulation for media). - Note: Google Drive video animate-on-hover functionality is implemented but currently pending verification/fix.
3.3 KiB
3.3 KiB
Project Memory
Project Context
This project (product_inventory) integrates Google Sheets with Shopify. It serves as a master inventory management tool where users edit product data in a Google Sheet, and scripts automatically sync those changes to Shopify.
Critical Components:
- Google Apps Script: Runs the logic.
- "vars" Sheet: Holds all configuration and API keys. NEVER hardcode credentials.
- Shopify Admin API: Used for syncing. REST for Orders, GraphQL for Products.
Work Patterns & Agreements
- Documentation First: Before implementing complex features, we update the plan and often the documentation (README/ARCHITECTURE).
- Safety First: We use
SafeToAutoRun: falsefor commands that deploy or modify external state until verified. - Strict Typing: We use TypeScript. No
anyunless absolutely necessary (and even then, we try to avoid it). - TDD: We follow Test Driven Development (Red/Green/Refactor). Write failing tests before implementing features.
- Artifact Usage: We use
task.md,implementation_plan.md, andwalkthrough.mdto track state.
Key Technical Decisions
- Queue System: We implemented
onEditQueue.tsto batch edits. This prevents hitting Shopify API rate limits and Google Apps Script execution limits during rapid manual edits. - Hybrid API: We use REST for retrieving Orders (legacy/easier for flat data) and GraphQL for Products (more efficient/flexible).
- Global Exports: Functions in
src/global.tsare explicitly exposed to be callable by Apps Script triggers.
User Preferences
- OS: Windows.
- Shell: PowerShell.
- Node Manager:
fnm. 28: 29: ## Integrated Media Manager 30: We implemented a "Sidebar-First" architecture for product media (Option 2): 31: - Frontend:MediaSidebar.htmluses Glassmorphism CSS and Client-Side Polling to detect SKU changes. 32: - Google Picker: Integrated viapicker.jsusing an API Key and OAuth Token passed securely from backend. 33: - Drive as Source of Truth: All uploads go to Drive first (Folder structure:Root/SKU/Files). 34: - Shopify Sync:MediaServiceorchestrates the complexStaged Uploads->Create Mediamutation flow. 35: - Security:appsscript.jsonrequires explicit scopes foruserinfo.email(Picker),drive(Files), anddrive(Advanced Service). API Keys are stored invarssheet, never hardcoded.
Media Handling Quirks
- Google Photos Picker:
- The
baseUrlreturned by the Picker API is hidden insidemediaFile.baseUrl(not top-level). - Downloading this URL requires an Authorization header with the script's OAuth token, or it returns 403.
- Sanitize with
Utilities.newBlob(). - Fallback to Advanced Drive Service (
Drive.Files.create/v3) if standard creation fails.
- Sanitize with
- The
- Video Previews:
- Video Previews:
- Use
document.createElement('video')to inject video tags. Avoid template strings (<video src="...">) as the parser sanitizes them aggressively. - Fallback to
<iframe>only if native playback fails.
- Use
- Client-Side Syntax:
- ES5 ONLY: Do not use
classin client-side HTML files. The Apps Script sanitizer often fails to parse them. Usefunctionconstructors.
- ES5 ONLY: Do not use