Skip to content

feat(data)!: add range-event activity types and parse unknown ones - #495

Merged
kartojal merged 7 commits into
mainfrom
fix/activity-unknown-types
Nov 5, 2026
Merged

kartojal merged 7 commits into
mainfrom
fix/activity-unknown-types

Conversation

@kartojal

@kartojal kartojal commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Adds DIRECTIONAL_SPLIT, DIRECTIONAL_MERGE, THRESHOLD_COMPOSE and THRESHOLD_DECOMPOSE activity types. Threshold rows report the moved line position as shares, since no collateral moves and the feed serves 0 in usdc_size. Titles, slugs and outcome labels are optional on all four types.

Rows with any other type no longer fail the page. They carry only the shared account fields, and their type is an OpaqueActivityType built on a private unique symbol. It never overlaps a listed ActivityType, so comparing activity.type with an ActivityType member still narrows each row, while exhaustive switches need a default branch. At runtime type stays the served string.

Python parity: Polymarket/py-sdk#404.

🤖 Generated with Claude Code


Note

Medium Risk
Breaking public types on a core feed model may require consumer migrations; runtime parsing behavior changes for unknown activity types (graceful degradation vs. previous failure).

Overview
Adds four range-event activity variants to ActivityType and the Activity union: event-scoped DIRECTIONAL_SPLIT / DIRECTIONAL_MERGE (USD amount, optional event metadata, no single-market conditionId) and line-scoped THRESHOLD_COMPOSE / THRESHOLD_DECOMPOSE (required conditionId, shares from wire size instead of collateral). They are valid listActivity type filter values via the updated enum.

Forward compatibility: wire type is parsed as any non-empty string instead of a strict enum, so rows whose type is not yet listed normalize to shared account fields only with an OpaqueActivityType—activity pages no longer fail when the API ships new types first.

Breaking TypeScript behavior: activity.type is no longer a string or usable as a record key; consumers need String(activity.type) for labels/maps and a default branch (plus new cases) in exhaustive switches. Docs and a changeset describe the migration.

Reviewed by Cursor Bugbot for commit 6624cf1. Bugbot is set up for automated code reviews on this repo. Configure here.

kartojal and others added 2 commits November 4, 2026 15:58
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kartojal kartojal changed the title fix(data): parse activity rows with unknown types fix(data)!: parse activity rows with unknown types Nov 4, 2026
@kartojal
kartojal marked this pull request as ready for review November 4, 2026 16:27
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kartojal kartojal changed the title fix(data)!: parse activity rows with unknown types feat(data)!: add range-event activity types and parse unknown ones Nov 4, 2026
…types

Drop the exported UnknownActivity name. Rows with types this SDK version
does not list are an unnamed Activity member with type: undefined and
rawType, so narrowing on ActivityType stays exact.

Threshold compose/decompose rows move line tokens without collateral: the
feed serves the amount in size and 0 in usdc_size. Expose it as shares
instead of an always-zero USD amount.

Unlisted rows gain isCombo so a Combo condition id is not mistaken for a
market. Range-event titles, slugs and outcome labels are optional, matching
the Python SDK; threshold rows still require the line's condition id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kartojal and others added 2 commits November 5, 2026 12:20
Rows with a type this SDK version does not list now carry only the shared
account fields and type: OpaqueActivityType, an opaque type built on a
private unique symbol. It never overlaps a listed ActivityType, so equality
narrowing on known variants stays exact while exhaustive switches still
need a default branch. The served type string stays at runtime.

Drop rawType, isCombo, amount, conditionId and the display fields from the
fallback row so consumers do not build on fields of types the SDK does not
model yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Call out that the opaque activity type is a breaking change, and show how
to read the served type with String(activity.type) where code assigned
activity.type to a string or used it as a record key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kartojal
kartojal requested a review from cesarenaldi November 5, 2026 15:33
@kartojal
kartojal merged commit e860929 into main Nov 5, 2026
8 checks passed
@kartojal
kartojal deleted the fix/activity-unknown-types branch November 5, 2026 17:53
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.

2 participants