Skip to content

Commit 9af4ef3

Browse files
MarTrepodiclaude
andcommitted
docs: align DataItems usage examples with server-side GameDataItemsEnum
Update helper docstring, helpers.md API reference, and the Sync/Async get_game_data example scripts to use the server-accepted SEGMENT1-4 aggregates rather than raw single-collection bit values (DataItems.UNITS, "UnitDefinitions"), which the Comlink server rejects with HTTP 400. Also adds a new "GameDataItems server alignment" section to the v1 to v2 migration guide documenting the Segment2 and Segment4 aggregate value changes and the new DataItems members (ABILITY_DECISION_TREE, ERA_DEFINITION, UBS_UPDATE) introduced when re-syncing against the live enum. Fixes a pre-existing typo in the migration guide where the Constants.get Segment1 example was annotated as returning '206158430208' (Segment3's value) instead of '2097151'. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9fecd0c commit 9af4ef3

5 files changed

Lines changed: 78 additions & 22 deletions

File tree

docs/api/helpers.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,23 @@ from swgoh_comlink.helpers import DataItems
2222

2323
comlink = SwgohComlink()
2424

25-
# Single collection
26-
units = comlink.get_game_data(items=DataItems.UNITS)
25+
# Single segment (server-accepted)
26+
segment1 = comlink.get_game_data(items=DataItems.SEGMENT1)
2727

28-
# Multiple collections via addition
29-
data = comlink.get_game_data(items=DataItems.SKILL + DataItems.EQUIPMENT)
28+
# Multiple segments combined
29+
data = comlink.get_game_data(items=DataItems.SEGMENT1 + DataItems.SEGMENT2)
3030

3131
# All collections
3232
everything = comlink.get_game_data(items=DataItems.ALL)
3333
```
3434

35+
!!! note
36+
Comlink servers validate `items` against the server-side `GameDataItemsEnum`. They
37+
accept the `SEGMENT1``SEGMENT4` aggregates and `DataItems.ALL`, but may reject raw
38+
single-collection bit values (e.g. `DataItems.UNITS`) with an HTTP 400. Prefer the
39+
segment aggregates for `get_game_data()` calls. The single-bit members remain useful
40+
for inspecting / composing custom bitfields and for `Constants.get()` lookups.
41+
3542
Use `DataItems.members()` to list all available member names.
3643

3744
::: swgoh_comlink.helpers._data_items.DataItems

docs/migration.md

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,17 @@ from swgoh_comlink.helpers import Constants
159159
# All three forms still work:
160160
Constants.get("UnitDefinitions") # -> '137438953472' (legacy name)
161161
Constants.get("UNITS") # -> '137438953472' (DataItems name)
162-
Constants.get("Segment1") # -> '206158430208' (class attribute)
162+
Constants.get("Segment1") # -> '2097151' (class attribute)
163163
```
164164

165-
**Recommendation:** Prefer using `DataItems` enum values directly for type safety:
165+
**Recommendation:** Prefer using `DataItems` enum values directly for type safety, and
166+
use the segment aggregates (`SEGMENT1``SEGMENT4`) when calling `get_game_data()` — see
167+
[GameDataItems server alignment](#9-gamedataitems-server-alignment) below:
166168

167169
```python
168170
from swgoh_comlink.helpers import DataItems
169171

170-
items = DataItems.UNITS | DataItems.CATEGORY
172+
items = DataItems.SEGMENT1 + DataItems.SEGMENT2
171173
data = comlink.get_game_data(items=items)
172174
```
173175

@@ -263,6 +265,41 @@ default to `None`.
263265
brackets in parallel batches via `asyncio.gather`. No code changes are needed
264266
on your side — the return format is identical.
265267

268+
## 9. GameDataItems server alignment
269+
270+
`DataItems` and `Constants` were re-synced against the live `GameDataItemsEnum` that
271+
`get_enums()` now exposes. Two practical impacts:
272+
273+
**`Segment2` and `Segment4` aggregate values changed.** If you hardcoded the integers
274+
in your own code (rather than referencing the constants by name), update them:
275+
276+
| Constant | Old value | New value |
277+
|----------|-----------|-----------|
278+
| `DataItems.SEGMENT2` / `Constants.Segment2` | `68717379584` | `1125968624222208` |
279+
| `DataItems.SEGMENT4` / `Constants.Segment4` | `281200098803712` | `3377424842620928` |
280+
281+
`SEGMENT1` (`2097151`) and `SEGMENT3` (`206158430208`) are unchanged.
282+
283+
Code that references the constant by name (`DataItems.SEGMENT2`, `Constants.Segment2`,
284+
`Constants.get("Segment2")`) picks up the new values automatically.
285+
286+
**`get_game_data(items=...)` now requires server-accepted values.** Comlink servers
287+
validate `items` against the server-side `GameDataItemsEnum` and may reject raw
288+
single-collection bit values with an HTTP 400. Prefer the `SEGMENT1`–`SEGMENT4`
289+
aggregates and `DataItems.ALL`:
290+
291+
```diff
292+
- comlink.get_game_data(items=DataItems.UNITS)
293+
+ comlink.get_game_data(items=DataItems.SEGMENT1)
294+
```
295+
296+
The single-bit `DataItems` members (e.g. `UNITS`, `SKILL`, `EQUIPMENT`) remain useful
297+
for inspecting / composing custom bitfields and for `Constants.get()` lookups.
298+
299+
**New members added** (from the live `GameDataItemsEnum`): `ABILITY_DECISION_TREE`,
300+
`ERA_DEFINITION`, `UBS_UPDATE`. New legacy-name aliases: `AbilityDecisionTrees`,
301+
`EraDefinitions`, `UBSUpdate`, `EpisodeDefinitions` (plural), `AccountLinking`.
302+
266303
## Summary of changes
267304

268305
| Area | Before (v1.x) | After |
@@ -281,3 +318,6 @@ default to `None`.
281318
| `get_gac_brackets(limit=)` | Sentinel default | `int` default `0` (0 = no limit) |
282319
| GAC bracket scanning | Linear O(n) | Exponential probe + binary search O(log n) |
283320
| Migration checker | Not available | `swgoh-migrate` CLI / `python -m swgoh_comlink.migrate` |
321+
| `DataItems.SEGMENT2` value | `68717379584` | `1125968624222208` (server-aligned) |
322+
| `DataItems.SEGMENT4` value | `281200098803712` | `3377424842620928` (server-aligned) |
323+
| `get_game_data(items=)` single-bit values | Accepted | Rejected (HTTP 400); use segment aggregates |

examples/Async/get_game_data.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import asyncio
88

99
from swgoh_comlink import SwgohComlinkAsync
10-
from swgoh_comlink.helpers import Constants
10+
from swgoh_comlink.helpers import Constants, DataItems
1111

1212

1313
async def main():
@@ -16,13 +16,15 @@ async def main():
1616
# Retrieve all of the available game data
1717
game_data = await cl.get_game_data(items="ALL")
1818

19-
# Alternatively, retrieve only the unit information collection
20-
unit_data = await cl.get_game_data(items="UnitDefinitions")
19+
# Retrieve a single segment. The Comlink server validates `items` against its
20+
# GameDataItemsEnum and accepts the Segment1-4 aggregates; raw single-collection
21+
# bit values (e.g. DataItems.UNITS) may be rejected with an HTTP 400.
22+
segment1_data = await cl.get_game_data(items=DataItems.SEGMENT1)
2123

22-
# This is the same call as above but without the PVE units
23-
unit_data_no_pve = await cl.get_game_data(items="UnitDefinitions", include_pve_units=False)
24+
# The same call without the PVE units
25+
segment1_no_pve = await cl.get_game_data(items=DataItems.SEGMENT1, include_pve_units=False)
2426

25-
# If you want to get more than one collection at once, simply combine the collection values
27+
# Combine segments to request multiple collections at once
2628
game_data_segments_1_and_2 = await cl.get_game_data(items=Constants.Segment1 + Constants.Segment2)
2729

2830
# Note that the 'items' and legacy 'request_segment' parameters are mutually exclusive.

examples/Sync/get_game_data.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@
55
"""
66

77
from swgoh_comlink import SwgohComlink
8-
from swgoh_comlink.helpers import Constants
8+
from swgoh_comlink.helpers import Constants, DataItems
99

1010
# Create an instance of SwgohComlink
1111
cl = SwgohComlink()
1212

1313
# Retrieve all of the available game data
1414
game_data = cl.get_game_data(items="ALL")
1515

16-
# Alternatively, retrieve only the unit information collection
17-
unit_data = cl.get_game_data(items="UnitDefinitions")
16+
# Retrieve a single segment. The Comlink server validates `items` against its
17+
# GameDataItemsEnum and accepts the Segment1-4 aggregates; raw single-collection
18+
# bit values (e.g. DataItems.UNITS) may be rejected with an HTTP 400.
19+
segment1_data = cl.get_game_data(items=DataItems.SEGMENT1)
1820

19-
# This is the same call as above but without the PVE units
20-
unit_data_no_pve = cl.get_game_data(items="UnitDefinitions", include_pve_units=False)
21+
# The same call without the PVE units
22+
segment1_no_pve = cl.get_game_data(items=DataItems.SEGMENT1, include_pve_units=False)
2123

22-
# If you want to get more than one collection at once, simply combine the collection values
24+
# Combine segments to request multiple collections at once
2325
game_data_segments_1_and_2 = cl.get_game_data(items=Constants.Segment1 + Constants.Segment2)
2426

2527
# Note that the 'items' and legacy 'request_segment' parameters are mutually exclusive.

src/swgoh_comlink/helpers/_data_items.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ class DataItems(IntFlag):
1616
more than one collection in a single call.
1717
1818
Examples:
19-
effect = comlink.get_game_data(items=DataItems.EFFECT)
20-
skill_equipment = comlink.get_game_data(items=(DataItems.SKILL + DataItems.EQUIPMENT))
21-
units_no_pve = comlink.get_game_data(items=DataItems.UNITS, include_pve_units=False)
19+
segment1 = comlink.get_game_data(items=DataItems.SEGMENT1)
20+
segments_1_and_2 = comlink.get_game_data(items=(DataItems.SEGMENT1 + DataItems.SEGMENT2))
21+
segment3_no_pve = comlink.get_game_data(items=DataItems.SEGMENT3, include_pve_units=False)
22+
23+
Note:
24+
Comlink servers validate `items` against the server-side `GameDataItemsEnum` and may reject
25+
raw single-collection bit values (e.g. `DataItems.UNITS`) with an HTTP 400. The `SEGMENT1`–
26+
`SEGMENT4` aggregates (and `DataItems.ALL`) are the values the server explicitly accepts.
2227
2328
Some of the DataItems members are actually aliases for other members. For example, the `TABLE` member is an
2429
alias for the `XP_TABLE` member. This is done because both members represent the same collection in the game data.

0 commit comments

Comments
 (0)