Skip to content

[EXTRACT] StockService - Rip stock operations from monolith #44

@democratize-technology-code-reviewer

Description

🔪 Extraction Target

Extract all stock-related operations from the 19,843-line index.mjs into a focused StockService class. No backward compatibility. No mercy.

📁 Methods to Extract

// All of these get ripped out and moved to StockService
addToStock()
consumeFromStock()
inventoryProduct()
openProduct()
getStock()
getStockEntries()
getStockEntry()
getStockLocations()
getStockProductDetails()
transferProduct()
// ... and any other stock-related methods

🎯 Definition of Done

  • Create services/StockService.js extending BaseService
  • Extract ALL stock methods from index.mjs
  • File size < 500 lines (enforced by linter)
  • All existing tests pass WITHOUT modification
  • Add JSDoc comments for each method
  • No deprecated methods or compatibility layers
  • Update all imports/references in index.mjs
  • Zero regression - identical functionality

⚡ Implementation

// services/StockService.js
export class StockService extends BaseService {
  async addToStock(productId, amount, bestBeforeDate, price, locationId, transactionType) {
    // Direct copy from index.mjs - no changes
  }
  
  async consumeFromStock(productId, amount, spoiled, locationId, recipeId, exact) {
    // Direct copy from index.mjs - no changes
  }
  
  // ... rest of stock methods
}

🚫 NOT in Scope

  • Backward compatibility
  • Deprecation warnings
  • Proxy methods in GrocyClient
  • Changing method signatures
  • Adding new features

💀 Breaking Changes

Yes. Deal with it. Update your code.

Related to

Parent issue: #11

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions