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
+30
View File
@@ -0,0 +1,30 @@
CREATE TABLE "pricing_observations" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"product_id" uuid NOT NULL REFERENCES "products"("id"),
"inventory_item_id" uuid NOT NULL REFERENCES "inventory_items"("id"),
"provider_id" text NOT NULL,
"price_minor" integer NOT NULL,
"currency" text NOT NULL,
"source_identifier" text NOT NULL,
"condition_id" uuid NOT NULL REFERENCES "conditions"("id"),
"source_url" text,
"quality_score" integer,
"is_outlier" boolean DEFAULT false NOT NULL,
"outlier_reason" text,
"observed_at" timestamp with time zone DEFAULT now() NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE INDEX "pricing_observations_inventory_item_id_index" ON "pricing_observations" USING btree ("inventory_item_id");
--> statement-breakpoint
CREATE TABLE "market_valuations" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"inventory_item_id" uuid NOT NULL REFERENCES "inventory_items"("id"),
"value_minor" integer NOT NULL,
"currency" text NOT NULL,
"strategy" text NOT NULL,
"confidence" text NOT NULL,
"source_count" integer NOT NULL,
"calculated_at" timestamp with time zone DEFAULT now() NOT NULL
);
+7
View File
@@ -106,6 +106,13 @@
"when": 1789804800000,
"tag": "0014_acquisitions",
"breakpoints": true
},
{
"idx": 15,
"version": "7",
"when": 1789891200000,
"tag": "0015_pricing",
"breakpoints": true
}
]
}