feat: add pricing observation API
Quality / test (push) Canceled after 0s

Add seller-owned pricing observation persistence, median market valuation calculation, admin routes, contracts, validation, migration, and focused tests.
This commit is contained in:
2026-09-09 01:05:41 -04:00
parent 455971431f
commit 721b590a89
14 changed files with 279 additions and 0 deletions
@@ -0,0 +1,26 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { createPricingService } from '../../src/modules/pricing/services/pricing-service.js';
test('records an owned pricing observation and calculates a valuation', async () => {
const service = createPricingService({
pricingRepository: {
async addObservationForSeller({ observation, sellerId }) {
assert.equal(sellerId, 'seller-1');
return { status: 'CREATED', observation };
},
async calculateForSeller() {
return { status: 'CALCULATED', valuation: { valueMinor: 2500 }, observations: [] };
},
},
});
const observation = await service.addObservation({
sellerId: 'seller-1', productId: 'product-1', inventoryItemId: 'inventory-1',
providerId: 'manual', priceMinor: 2500, sourceIdentifier: 'source-1', conditionId: 'condition-1',
});
assert.equal(observation.priceMinor, 2500);
const valuation = await service.calculate({ sellerId: 'seller-1', inventoryItemId: 'inventory-1' });
assert.equal(valuation.valuation.valueMinor, 2500);
});