Skip to content

Feature/funpayparsers 080 sync#35

Open
Flummy1 wants to merge 9 commits intodevfrom
feature/funpayparsers-080-sync-v2
Open

Feature/funpayparsers 080 sync#35
Flummy1 wants to merge 9 commits intodevfrom
feature/funpayparsers-080-sync-v2

Conversation

@Flummy1
Copy link
Copy Markdown
Contributor

@Flummy1 Flummy1 commented Apr 20, 2026

Summary

  • Bumps funpayparsers dependency from >=0.7.0,<0.8.0 to >=0.8.0,<0.9.0
  • Adds new types introduced in funpayparsers 0.8.0 to funpaybotengine.types

Changes

New module — types/subcategory_structure.py

Re-exports three new types from funpayparsers.types.subcategory_structure:

  • FieldCondition — visibility condition for a subcategory field (field_id + set of trigger values)
  • SubcategoryFieldDef — full definition of a single subcategory field (id, type, label, conditions, options)
  • SubcategoryStructure — derived structure for O(1) lookup by field ID, with label_map and lower_label_map (case-insensitive)

Note: SubcategoryFieldType enum is already available via enums.py (re-exported from funpayparsers).

OfferFields — two new members

  • field_schema: list[SubcategoryFieldDef] — populated by OfferFieldsParser from the data-fields JSON attribute; empty list for chips offers
  • subcategory_structure property — builds a SubcategoryStructure from field_schema on demand

Breaking changes

None. All additions are backwards-compatible (field_schema defaults to [])

Flummy1 and others added 3 commits April 20, 2026 13:50
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ypes

Re-export FieldCondition, SubcategoryFieldDef, SubcategoryStructure from
funpayparsers.types.subcategory_structure via a new types module.

Add field_schema: list[SubcategoryFieldDef] field to OfferFields and a
subcategory_structure property that builds a SubcategoryStructure on demand.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
FieldCondition, SubcategoryFieldDef and SubcategoryStructure are now
proper Pydantic models inheriting from FunPayObject instead of
re-exporting the funpayparsers dataclasses directly.

Each class owns its _add_raw_source validator:
- FieldCondition/SubcategoryStructure: no raw_source on the parser side,
  generate a stable JSON identifier on construction
- SubcategoryFieldDef: raw_source already present on the parser dataclass,
  let from_attributes carry it through; fallback for dict construction

SubcategoryStructure.from_offer_fields is added as a classmethod and used
by OfferFields.subcategory_structure property. OfferFields.field_schema now
stores engine SubcategoryFieldDef instances.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Flummy1 Flummy1 requested a review from qvvonk as a code owner April 20, 2026 10:51
Flummy1 added 6 commits May 2, 2026 16:05
…rets'

Mirrors funpayparsers cbbbd5b. Without this, saving auto-delivery secrets
through the engine writes the wrong form key and FunPay silently drops it.
Mirrors funpayparsers PR #102 (b942fae). The listing page parser
populates SubcategoryStructure from data-fields JSON; without this
field the structure was silently dropped on the engine side.
…e matching with parser

- label_map / lower_label_map now return dict[str, list[str]] and use
  cached_property, matching funpayparsers 66e6cd0. Previously a single-id
  dict silently dropped fields with duplicate labels (notably empty
  labels on form fields without <label>).
- FieldCondition.is_satisfied_by and stored values are case-insensitive
  via casefold, mirroring parser fc6190d. FunPay's listing page and
  offerEdit form render the same value with inconsistent casing.
Mirrors funpayparsers f2d2851. The parser stamps subcategory context
(OFFERS/CHIPS) onto every preview based on the offer URL; the engine
wrapper was dropping it.
…tegoryStructure validator

The parser ships SubcategoryStructure as a plain @DataClass (no
FunPayObject mixin). When pydantic ingests a parser instance via
model_validate, the existing 'before' validator only handled dict
input and returned dataclass instances unchanged, causing
'raw_source: Field required' validation errors on every page that
actually has a populated structure (e.g. subcat 1, 27, 41).

Mirrors the same pattern already used for FieldCondition. Verified on
live subcategories with rich filter blocks.
…fferPage.images

Mirrors funpayparsers (types/pages/order_page.py:53, types/pages/offer_page.py:48).
Both helpers were missing in engine, breaking the documented flow:

  message.meta.order_id -> get_order_page -> structure -> field_id mapping.

Also adds OfferPage.images (engine wrapper was missing the list parsed
from div.param-list attachments).

Verified end-to-end on live FunPay session.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant