feat(import-fifa17): seed unopenedPackIds as Core entitlements

Carry unopenedPackIds through the importer: Profile model -> Report ->
ApplyPlan. GenericImportRequest now emits entitlements[] (one definition_id
per unopened pack instance, order+duplicates preserved), which Core's import
seeds as unconsumed packs rows in the same transaction. Closes the economy
import gap so a migrated profile's unopened packs become Core entitlements
(feeding purchasegroup/credits/userMassInfo). Idempotency unchanged (import
fingerprint). +1 test; 26 pass, clippy -D warnings clean.
This commit is contained in:
OpenFUT Agent
2026-08-13 19:38:04 +00:00
parent 49c5185ae3
commit 96e80ab293
4 changed files with 46 additions and 0 deletions
+23
View File
@@ -462,6 +462,29 @@ fn plan_apply_builds_generic_request_mappings_and_squad() {
.any(|s| s.owned_item_id == cap_owned && s.is_captain));
}
#[test]
fn plan_apply_seeds_entitlements_from_unopened_packs() {
let items = [player(100000001, 20801, 20801, 94)];
let json = format!(
r#"{{"personaId":33068179,"personaName":"CAGE","clubName":"OpenFUT","clubAbbr":"OFC",
"coins":1000,"nextItemId":100000500,"items":[{}],"squads":[],"unopenedPackIds":[70,70,5]}}"#,
items.join(",")
);
let prof = Profile::from_json_str(&json).unwrap();
let report = analyze(&prof, &roster(), &entities(), &none());
assert_eq!(report.unopened_pack_ids, [70, 70, 5]);
let raw: serde_json::Value = serde_json::from_str(&json).unwrap();
let plan = plan_apply(&report, &raw, "fp-ent").unwrap();
let defs: Vec<&str> = plan
.request
.entitlements
.iter()
.map(|e| e.definition_id.as_str())
.collect();
// One entitlement per unopened pack instance, order preserved (dup 70 kept).
assert_eq!(defs, ["70", "70", "5"]);
}
#[test]
fn plan_apply_refuses_when_blockers_present() {
// unapproved same-resourceId conflict -> blocker.