feat(rpartstore): Renault/Dacia için RPartStore VIN-decode fallback kaynağı
Some checks are pending
QA Gate (P0/P1) / Test affected app (pull_request) Waiting to run
Some checks are pending
QA Gate (P0/P1) / Test affected app (pull_request) Waiting to run
rpartstore.renault.com (Renault Group bayi portalı) yeni decode kaynağı olarak eklendi. Portal REST değil STOMP 1.2 over WebSocket konuşuyor; login Okta OIE (IDX JSON API + PKCE), tarayıcı gerekmiyor. Sıralama Renault/Dacia için: pcat + PL24 + emex yarışı → rpartstore → (bayrağı açıksa) Vinpin son çare. - integrations/rpartstore: STOMP codec, Okta login, oturum (trace-id ile çok-mesajlı cevap eşleme), istemci (Redis'te 1 saatlik token), Renault/Dacia yönlendirme, RPartStore → PL24 catalog_vehicles model eşleyici (roman rakam, karoseri niteleyici, yanlış-pazar cezası). - rpartstore_decodes tablosu (migration 0037) + rpartstore-decode BullMQ kuyruğu; worker concurrency 1 + 1 iş / 6 s limiter (portal 2 arama / 10 s). - Günlük sert kota RPARTSTORE_DAILY_CAP (varsayılan 10, İstanbul günü): işlemci göndermeden önce Redis INCR ile rezervasyon yapar, aşan VIN'ler `capped` olur ve 24 saat sonra tekrar denenir; API kota doluysa kuyruğa hiç almaz. Kısa vadeli rate-limit cevabında retryAfter kadar bekleyip bir kez tekrar dener. - VehiclesService.tryRpartstoreFallback: Vinpin fallback ile aynı sözleşme (decoding/catalogVehicle cevapları, tek başarısızlık log satırı). - Env: RPARTSTORE_ENABLED/USER/PASS/DAILY_CAP/BROKER_URL/APP_VERSION (compose api+worker). Vinpin koda dokunulmadan pasif kalır (VINPIN_ENABLED). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
34
apps/api/drizzle/0037_rpartstore_decodes.sql
Normal file
34
apps/api/drizzle/0037_rpartstore_decodes.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
-- RPartStore (rpartstore.renault.com, Renault Group dealer portal) VIN-decode
|
||||
-- fallback cache (feature-flagged: RPARTSTORE_ENABLED). One row per VIN. The
|
||||
-- rpartstore-decode BullMQ job asks the RPartStore BFF (STOMP over WebSocket)
|
||||
-- for Renault/Dacia VINs the normal chain (pcat/PL24/emex) can't identify, then
|
||||
-- matches the decoded model to an EXISTING PL24 catalog_vehicle. RPartStore is
|
||||
-- ONLY a decode oracle here — parts are served from PL24's existing catalog.
|
||||
-- status: 'pending' | 'decoded' | 'not_found' | 'capped' | 'failed'.
|
||||
CREATE TABLE IF NOT EXISTS "rpartstore_decodes" (
|
||||
"vin" text PRIMARY KEY NOT NULL,
|
||||
"status" text DEFAULT 'pending' NOT NULL,
|
||||
"brand_name" text,
|
||||
"model" text,
|
||||
"model_code" text,
|
||||
"family_code" text,
|
||||
"model_year" text,
|
||||
"engine" text,
|
||||
"gearbox" text,
|
||||
"energy_type" text,
|
||||
"manufacturing_date" text,
|
||||
"catalog_vehicle_id" uuid,
|
||||
"raw" jsonb,
|
||||
"attempts" integer DEFAULT 0 NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone,
|
||||
"decoded_at" timestamp with time zone
|
||||
);
|
||||
--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
ALTER TABLE "rpartstore_decodes" ADD CONSTRAINT "rpartstore_decodes_catalog_vehicle_id_catalog_vehicles_id_fk" FOREIGN KEY ("catalog_vehicle_id") REFERENCES "public"."catalog_vehicles"("id") ON DELETE set null ON UPDATE no action;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
--> statement-breakpoint
|
||||
CREATE INDEX IF NOT EXISTS "rpartstore_decodes_status_idx" ON "rpartstore_decodes" USING btree ("status");
|
||||
Reference in New Issue
Block a user