@smartico/public-api 0.0.403 → 0.0.405
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/api-tsdoc/SKILL.md +675 -0
- package/.claude/skills/api-tsdoc-final/SKILL.md +266 -0
- package/.claude/skills/api-tsdoc-howto/SKILL.md +143 -0
- package/dist/MiniGames/SAWTemplate.d.ts +4 -0
- package/dist/MiniGames/SAWTemplateUI.d.ts +6 -2
- package/dist/SmarticoGlobal.d.ts +0 -6
- package/dist/WSAPI/WSAPITypes.d.ts +43 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +2 -0
- package/dist/index.modern.mjs.map +1 -1
- package/docs/api/interfaces/SAWTemplate.md +16 -0
- package/docs/api/interfaces/TMiniGameTemplate.md +21 -0
- package/docs/api/interfaces/TUserProfile.md +136 -0
- package/docs/capabilities/_responses/buyStoreItem.json +4 -0
- package/docs/capabilities/_responses/claimBonus.json +4 -0
- package/docs/capabilities/_responses/gamePickGetActiveRound.json +95 -0
- package/docs/capabilities/_responses/gamePickGetActiveRounds.json +191 -0
- package/docs/capabilities/_responses/gamePickGetBoard.json +47 -0
- package/docs/capabilities/_responses/gamePickGetGameInfo.json +355 -0
- package/docs/capabilities/_responses/gamePickGetHistory.json +191 -0
- package/docs/capabilities/_responses/gamePickGetUserInfo.json +14 -0
- package/docs/capabilities/_responses/getAchCategories.json +12 -0
- package/docs/capabilities/_responses/getActivityLog.json +1 -0
- package/docs/capabilities/_responses/getAvatarPrompts.json +16 -0
- package/docs/capabilities/_responses/getAvatarsCustomized.json +12 -0
- package/docs/capabilities/_responses/getAvatarsList.json +24 -0
- package/docs/capabilities/_responses/getBadges.json +98 -0
- package/docs/capabilities/_responses/getBonuses.json +18 -0
- package/docs/capabilities/_responses/getClanInfo.json +39 -0
- package/docs/capabilities/_responses/getClans.json +35 -0
- package/docs/capabilities/_responses/getCurrentLevel.json +20 -0
- package/docs/capabilities/_responses/getCustomSections.json +25 -0
- package/docs/capabilities/_responses/getInboxMessageBody.json +7 -0
- package/docs/capabilities/_responses/getInboxMessages.json +18 -0
- package/docs/capabilities/_responses/getInboxUnreadCount.json +1 -0
- package/docs/capabilities/_responses/getJackpotEligibleGames.json +20 -0
- package/docs/capabilities/_responses/getJackpotWinners.json +28 -0
- package/docs/capabilities/_responses/getLeaderBoard.json +45 -0
- package/docs/capabilities/_responses/getLevels.json +40 -0
- package/docs/capabilities/_responses/getMiniGames.json +208 -0
- package/docs/capabilities/_responses/getMiniGamesHistory.json +1 -0
- package/docs/capabilities/_responses/getMissions.json +117 -0
- package/docs/capabilities/_responses/getRaffleDrawRun.json +62 -0
- package/docs/capabilities/_responses/getRaffleDrawRunsHistory.json +34 -0
- package/docs/capabilities/_responses/getRaffles.json +140 -0
- package/docs/capabilities/_responses/getStoreCategories.json +12 -0
- package/docs/capabilities/_responses/getStoreItems.json +47 -0
- package/docs/capabilities/_responses/getStorePurchasedItems.json +49 -0
- package/docs/capabilities/_responses/getTournamentInstanceInfo.json +75 -0
- package/docs/capabilities/_responses/getTournamentsList.json +66 -0
- package/docs/capabilities/_responses/getTranslations.json +25 -0
- package/docs/capabilities/_responses/getUserLevelExtraCounters.json +4 -0
- package/docs/capabilities/_responses/getUserProfile.json +34 -0
- package/docs/capabilities/_responses/jackpotGet.json +113 -0
- package/docs/capabilities/_responses/jackpotOptIn.json +9 -0
- package/docs/capabilities/_responses/jackpotOptOut.json +9 -0
- package/docs/capabilities/_responses/markAllInboxMessagesAsRead.json +4 -0
- package/docs/capabilities/_responses/markInboxMessageAsRead.json +4 -0
- package/docs/capabilities/_responses/markUnmarkInboxMessageAsFavorite.json +4 -0
- package/docs/capabilities/_responses/miniGameWinAcknowledgeRequest.json +10 -0
- package/docs/capabilities/_responses/playMiniGame.json +6 -0
- package/docs/capabilities/_responses/playMiniGameBatch.json +9 -0
- package/docs/capabilities/_responses/registerInTournament.json +4 -0
- package/docs/capabilities/_responses/requestMissionOptIn.json +4 -0
- package/docs/capabilities/_responses/setAvatar.json +4 -0
- package/docs/capabilities/avatarsCustomize.md +115 -0
- package/docs/capabilities/buyStoreItem.md +179 -0
- package/docs/capabilities/checkSegmentListMatch.md +69 -0
- package/docs/capabilities/checkSegmentMatch.md +74 -0
- package/docs/capabilities/claimBonus.md +125 -0
- package/docs/capabilities/claimRafflePrize.md +116 -0
- package/docs/capabilities/deleteAllInboxMessages.md +66 -0
- package/docs/capabilities/deleteInboxMessage.md +60 -0
- package/docs/capabilities/gamePickGetActiveRound.md +248 -0
- package/docs/capabilities/gamePickGetActiveRounds.md +259 -0
- package/docs/capabilities/gamePickGetBoard.md +202 -0
- package/docs/capabilities/gamePickGetGameInfo.md +318 -0
- package/docs/capabilities/gamePickGetHistory.md +244 -0
- package/docs/capabilities/gamePickGetRoundInfoForUser.md +189 -0
- package/docs/capabilities/gamePickGetUserInfo.md +91 -0
- package/docs/capabilities/gamePickSubmitSelection.md +222 -0
- package/docs/capabilities/gamePickSubmitSelectionQuiz.md +198 -0
- package/docs/capabilities/getAchCategories.md +119 -0
- package/docs/capabilities/getActivityLog.md +108 -0
- package/docs/capabilities/getAvatarPrompts.md +81 -0
- package/docs/capabilities/getAvatarsCustomized.md +96 -0
- package/docs/capabilities/getAvatarsList.md +101 -0
- package/docs/capabilities/getBadges.md +237 -0
- package/docs/capabilities/getBonuses.md +159 -0
- package/docs/capabilities/getClanInfo.md +164 -0
- package/docs/capabilities/getClanTournamentPlayers.md +112 -0
- package/docs/capabilities/getClans.md +168 -0
- package/docs/capabilities/getCurrentLevel.md +123 -0
- package/docs/capabilities/getCustomSections.md +96 -0
- package/docs/capabilities/getInboxMessageBody.md +87 -0
- package/docs/capabilities/getInboxMessages.md +146 -0
- package/docs/capabilities/getInboxUnreadCount.md +54 -0
- package/docs/capabilities/getJackpotEligibleGames.md +93 -0
- package/docs/capabilities/getJackpotWinners.md +113 -0
- package/docs/capabilities/getLeaderBoard.md +187 -0
- package/docs/capabilities/getLeaderBoards.md +88 -0
- package/docs/capabilities/getLevels.md +118 -0
- package/docs/capabilities/getMiniGames.md +295 -0
- package/docs/capabilities/getMiniGamesHistory.md +183 -0
- package/docs/capabilities/getMissions.md +253 -0
- package/docs/capabilities/getRaffleDrawRun.md +210 -0
- package/docs/capabilities/getRaffleDrawRunsHistory.md +116 -0
- package/docs/capabilities/getRaffleWonPrizes.md +153 -0
- package/docs/capabilities/getRaffles.md +249 -0
- package/docs/capabilities/getRelatedItemsForGame.md +236 -0
- package/docs/capabilities/getStoreCategories.md +128 -0
- package/docs/capabilities/getStoreItems.md +260 -0
- package/docs/capabilities/getStorePurchasedItems.md +280 -0
- package/docs/capabilities/getTournamentInstanceInfo.md +301 -0
- package/docs/capabilities/getTournamentsList.md +234 -0
- package/docs/capabilities/getTranslations.md +95 -0
- package/docs/capabilities/getUserLevelExtraCounters.md +92 -0
- package/docs/capabilities/getUserProfile.md +184 -0
- package/docs/capabilities/jackpotGet.md +173 -0
- package/docs/capabilities/jackpotOptIn.md +94 -0
- package/docs/capabilities/jackpotOptOut.md +92 -0
- package/docs/capabilities/joinClan.md +169 -0
- package/docs/capabilities/markAllInboxMessagesAsRead.md +72 -0
- package/docs/capabilities/markInboxMessageAsRead.md +69 -0
- package/docs/capabilities/markUnmarkInboxMessageAsFavorite.md +75 -0
- package/docs/capabilities/miniGameWinAcknowledgeRequest.md +98 -0
- package/docs/capabilities/playMiniGame.md +217 -0
- package/docs/capabilities/playMiniGameBatch.md +129 -0
- package/docs/capabilities/registerInTournament.md +187 -0
- package/docs/capabilities/reportClickEvent.md +74 -0
- package/docs/capabilities/reportImpressionEvent.md +67 -0
- package/docs/capabilities/requestMissionClaimReward.md +117 -0
- package/docs/capabilities/requestMissionOptIn.md +98 -0
- package/docs/capabilities/requestRaffleOptin.md +108 -0
- package/docs/capabilities/setAvatar.md +132 -0
- package/docs/capabilities/smarticoCallbacks.md +165 -0
- package/docs/capabilities/smarticoGlobal.md +62 -0
- package/package.json +3 -2
- package/readme-smartico-dev.md +208 -0
- package/scripts/capture-responses-browser.mjs +301 -0
- package/scripts/gen-capabilities.js +368 -0
- package/scripts/run-public-api.mjs +105 -0
- package/src/MiniGames/SAWGetTemplatesResponse.ts +2 -0
- package/src/MiniGames/SAWTemplate.ts +5 -0
- package/src/MiniGames/SAWTemplateUI.ts +6 -2
- package/src/SmarticoGlobal.ts +0 -7
- package/src/WSAPI/WSAPITypes.ts +44 -0
|
@@ -0,0 +1,675 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-tsdoc
|
|
3
|
+
description: Enrich TSDoc comments in Smartico's public-api SDK (`/Users/aa/Desktop/SM/public-api/src/`) by mining real-world usage from the `ach` codebase and validating against server-side handlers. Use when the user asks to document, enrich, or improve TSDoc for any `_smartico.api.*` method or related WSAPI type.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# api-tsdoc
|
|
7
|
+
|
|
8
|
+
Enrich a Smartico public-api SDK method's TSDoc with real-world implementation insights from `ach` (the in-tracker gamification UI) + `r-server` (the protocol-handler backend). Apply edits directly, never commit.
|
|
9
|
+
|
|
10
|
+
## When to invoke
|
|
11
|
+
- User types `/api-tsdoc <method-or-feature>`
|
|
12
|
+
- User asks: "enrich TSDoc for X", "document X using ach", "improve SDK docs for X"
|
|
13
|
+
- User points at a `_smartico.api.*` method whose TSDoc is thin
|
|
14
|
+
|
|
15
|
+
## Hard scope rules
|
|
16
|
+
|
|
17
|
+
- **ONLY edit `.ts` files under `/Users/aa/Desktop/SM/public-api/src/`** (the domain class files: `WSAPI/WSAPI<Domain>.ts` — see "File layout" below — plus `WSAPI/WSAPITypes.ts` for return-type interfaces, occasionally `SmarticoLib/*`).
|
|
18
|
+
- **ONLY write UI guidance to `.md` files under `/Users/aa/Desktop/SM/public-api/docs/ui/<domain>/UIGuide_<methodName>.md`** — never inline long UI sections in TSDoc. The method's TSDoc gets a single `**UI guidance**: see [link]` reference.
|
|
19
|
+
- **NEVER edit `/Users/aa/Desktop/SM/public-api/docs/api/**`** — TypeDoc-generated; gets overwritten by `npm run doc`.
|
|
20
|
+
- **NEVER run `npm run doc`** — human-triggered separately after a batch of approved enrichments.
|
|
21
|
+
- **NEVER commit, stage, or push.** All changes wait for human review.
|
|
22
|
+
- **NEVER skip the validation pass** — server-side semantics (Java handlers in r-server) are the most common place ach-only extraction misses something. The first round on `requestMissionOptIn` literally got the error-code list wrong without validation.
|
|
23
|
+
- **NEVER paste ach-internal types** (`AchievementOptinRequest`, `ProtocolMessage`, `Context.interaction.*`, anything from `lib-common/protocol/*`) into examples or @remarks. Translate to SDK-shaped behavior.
|
|
24
|
+
- **NEVER use pseudo-API handlers** in `@example` blocks (`showError`, `showUnlockTasks`, `refreshUI`, `notify`, `toast`, etc.). Instead, use `console.log()` / `console.error()` with **descriptive messages that state what the consumer's UI should actually do at that point**. The example then doubles as documentation of expected UI behavior without committing to any particular framework.
|
|
25
|
+
Bad: `showError(r.err_message)`
|
|
26
|
+
Good: `console.error('[smartico] opt-in failed — show error toast with this message to the user:', r.err_message)`
|
|
27
|
+
- **NEVER expose internal Smartico implementation details** in `/** */` blocks. This is the public SDK contract — 3rd-party integrators read these docs. Specifically banned in `@remarks` / `@example` / `@param` / `@returns`:
|
|
28
|
+
- **DB schemas / table / column / function names**: `cjm_ach.ach_category`, `ach_completed`, `ach_completed_recurring`, `cjm.users`, `sm_crm.*`, `spk_ai.*`, `fnc_get_user_achievements_map`, `fnc_ach_unlock`, etc. Talk about *behavior*, not storage.
|
|
29
|
+
- **Server-side class / method / file references**: `AchievementService.java`, `AchievementOptinRequestHandler`, `AchievementsMultiLabelConsumer:L182-191`, `WsSessionManager.postProcess`, `TagReplacementDbService`, `AchievementsDbService.optInToAchievement`, etc. Talk about *what the server does*, not which class does it.
|
|
30
|
+
- **Internal numeric status / enum codes**: "(status 1)", "(status 4)", "category_status_id = 1", "ach_status_id = 7". Refer to **public** enums by name (e.g. `AchievementStatus.RECURRING`, `AchievementAvailabilityStatus`) but never expose raw numeric codes for internal-only enums.
|
|
31
|
+
- **Internal label-setting keys**: `DEMO_ALWAYS_SEND_RELOAD_ACHIEVEMENT`, `SHOW_COMPLETED_GAMIFICATION_NOT_VISIBLE`, `GAMIFICATION_VISTOR_MODE_USER_EXT_ID`. Talk about *configurable behavior*, not setting keys.
|
|
32
|
+
- **Internal cache / infra names**: `OCache`, `ECacheContext`, `CACHE_DATA_SEC`, "server-side OCache 60 s", "HTTP Cache-Control: max-age=300", "BigQuery analytics event", "Kafka event", "in-memory cache invalidated", "`updateMissions()`". Say "the SDK caches the response for 30 seconds" — not which class/key/constant implements it.
|
|
33
|
+
- **Jira ticket refs**: `(SMR-46737)`, `DESK-1234`. Internal tracker noise.
|
|
34
|
+
- **BO admin paths**: "BO → Gamification → Settings → Categories". Say "configured by the operator" or omit. Operator-facing UI paths are out of scope for the SDK contract.
|
|
35
|
+
- **File:line refs into r-server / bo-server / ach**: `AchievementService.java:L375-405`, `AchievementsDbService:L3378-3385`. These belong in the agent's return summary for the human reviewer, not in any source-file comment.
|
|
36
|
+
- **`ClassId` enum values** (e.g. `ClassId.MISSION_OPTIN_RESPONSE`, `ClassId.BUY_SHOP_ITEM_RESPONSE`, `ClassId.CLIENT_PUBLIC_PROPERTIES_CHANGED_EVENT`, `ClassId.RELOAD_ACHIEVEMENTS_EVENT`). Even though `ClassId` is technically exported, it's a **protocol-layer abstraction** the SDK consumer should never need to think about. The consumer's mental model is "I call `getMissions({onUpdate})` and my callback fires" — NOT "I subscribe to `MISSION_OPTIN_RESPONSE`". Every push event reaches the consumer via some API surface (an `onUpdate` callback on a fetch method, a Promise resolution on a mutation, a state-update on a user-profile field). Describe the API trigger, not the wire-level event. Examples:
|
|
37
|
+
- Bad: `{@link ClassId.MISSION_OPTIN_RESPONSE} — fired after opt-in.`
|
|
38
|
+
- Good: `Fires after \`requestMissionOptIn(...)\` resolves (any \`err_code\`).`
|
|
39
|
+
- Bad: `the SDK refreshes on a {@link ClassId.BUY_SHOP_ITEM_RESPONSE} push`
|
|
40
|
+
- Good: `the SDK refreshes after every \`buyStoreItem(...)\` call resolves`
|
|
41
|
+
- Bad: `balances arrive via {@link ClassId.CLIENT_PUBLIC_PROPERTIES_CHANGED_EVENT}`
|
|
42
|
+
- Good: `balances on \`getUserProfile()\` are kept live by the SDK's user-properties channel`
|
|
43
|
+
|
|
44
|
+
**What IS safe to reference** in `/** */`:
|
|
45
|
+
- **Public status/enum types**: `AchievementStatus`, `AchievementAvailabilityStatus`, `SAWSpinErrorCode`, `JoinClanErrorCode`, etc. — anything `export enum`-ed under `src/Missions/`, `src/MiniGames/`, etc. Reference by enum **name**, not by numeric value.
|
|
46
|
+
- **Fields on the public return type** (e.g. `TMissionOrBadge.is_opted_in`, `mission.ach_public_meta.hide_locked_mission`) — these are part of the SDK contract.
|
|
47
|
+
- **Numeric error codes returned by the SDK method itself** (e.g. `40010`, `40014`) — these reach the consumer in `err_code`, so consumers must branch on them. Document the codes WITHOUT exposing which internal handler emits them.
|
|
48
|
+
- **Other public SDK methods** (`{@link buyStoreItem}`, `{@link getMissions}`) — these are part of the SDK contract.
|
|
49
|
+
|
|
50
|
+
**Reference UI naming**: when documenting "the reference UI does X" (e.g. ach's specific rendering pattern), call it **"the default Smartico UI"** — not "the official tracker", "ach", "the tracker UI", or any internal name. This matches public marketing language.
|
|
51
|
+
|
|
52
|
+
**Rule of thumb**: if removing the internal-name reference makes the doc less useful to a 3rd-party widget developer, you needed a better consumer-facing phrasing — not the internal name. Internal-reference audit trails belong in the agent's return summary to the human reviewer, NOT in source-file comments.
|
|
53
|
+
|
|
54
|
+
## Type / method documentation contract
|
|
55
|
+
|
|
56
|
+
A clean separation between the type docs (`WSAPITypes.ts` field comments) and the method docs (`WSAPI<Domain>.ts` TSDoc) keeps both useful without bifurcating information across two large surfaces.
|
|
57
|
+
|
|
58
|
+
**`WSAPITypes.ts` field comments** — terse, lookup-friendly reference. One short sentence per field stating:
|
|
59
|
+
- What it is (the SDK field name and what it represents)
|
|
60
|
+
- Type if non-obvious (e.g. "Unix ms timestamp", "0–100 integer percentage")
|
|
61
|
+
- Null/undefined semantics ("Undefined for badges", "Null when unlimited")
|
|
62
|
+
- Cross-reference to a public enum if the values come from one
|
|
63
|
+
|
|
64
|
+
That's it. Do NOT expand field comments into multi-paragraph behavioral essays. Consumers and AI agents look these up; they don't read them top-to-bottom.
|
|
65
|
+
|
|
66
|
+
**Method `WSAPI<Domain>.ts` TSDoc** — narrative, usage-oriented prose. Explains **how to use** the call:
|
|
67
|
+
- Preconditions, error codes, refresh semantics, idempotency, side effects, cache, visitor mode
|
|
68
|
+
- WHEN fields update relative to the call (e.g. "after `requestMissionOptIn(...)` resolves, `is_opted_in` flips on the next refresh — not optimistically")
|
|
69
|
+
- Recommended UI patterns that depend on field combinations
|
|
70
|
+
- Inline references to specific fields when they're load-bearing for the explanation
|
|
71
|
+
|
|
72
|
+
Do NOT include a **`Field semantics`** bullet section in method TSDoc that parallels the type's field list. That creates a second field-by-field reference that drifts from the type docs over time, and forces AI agents to load both `WSAPITypes.ts` and the method file to assemble the full picture.
|
|
73
|
+
|
|
74
|
+
**Discriminator 1 — parallel reference (method-side)**
|
|
75
|
+
|
|
76
|
+
If you're about to write a bullet that's "`field_name` is/means X" and the next bullet is the same shape for another field, you're writing a parallel reference and should stop. Move that content into prose somewhere else in @remarks — Refresh after success / Subscription model / UI guidance — where the field is mentioned in the context of WHAT YOU DO with it, not WHAT IT IS.
|
|
77
|
+
|
|
78
|
+
| Bad (parallel reference) | Good (usage prose) |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `**Field semantics**`<br>`- ` is_opted_in ` does NOT flip optimistically...`<br>`- ` dt_start ` doubles as opt-in timestamp...` | `**Refresh after success**`<br>The SDK auto-refreshes the mission list on response. `is_opted_in` becomes true on the refreshed array; don't flip it optimistically. `dt_start` on the refreshed mission is the opt-in timestamp; expiration is `dt_start + time_limit_ms`. |
|
|
81
|
+
|
|
82
|
+
**Discriminator 2 — definition vs. instruction (type-side)**
|
|
83
|
+
|
|
84
|
+
A field comment answers: "what is this field?" — a definition. A method TSDoc answers: "what do I do with it?" — an instruction.
|
|
85
|
+
|
|
86
|
+
If a field comment contains any of these, the content belongs in the method TSDoc, not the field:
|
|
87
|
+
- An imperative verb in the consumer's voice ("sort by …", "pass to …", "never cache …", "always read from a fresh fetch", "must call X first")
|
|
88
|
+
- A code snippet showing the consumer using the value (e.g. `categories.sort(...)`)
|
|
89
|
+
- A multi-step instruction
|
|
90
|
+
- A cross-method invariant ("call Y before this", "after Z the field flips")
|
|
91
|
+
|
|
92
|
+
Field comments may include: what the value represents · type/units (px, ms, 0–100 percent, Unix-ms timestamp) · null/undefined semantics · cross-ref to the public enum the values come from · one short "Returned by `getX()`" pointer. That's it.
|
|
93
|
+
|
|
94
|
+
| Bad (instruction in field comment) | Good (definition in field; instruction in method) |
|
|
95
|
+
|---|---|
|
|
96
|
+
| `name: Display label. Pre-translated to the user's stored language. In visitor mode driven by ` `_smartico.vapi(lang)` `. Falls back to EN. Never null.` | Field: `name: Display label, pre-translated server-side. Never null.`<br>Method TSDoc: `**Localization**: server pre-translates to user language; falls back to EN; visitor mode uses ` `vapi(lang)` ` argument.` |
|
|
97
|
+
| `order: Relative position (lower first). Server does NOT pre-sort — caller must run ` `categories.sort((a,b)=>a.order-b.order)` `. Default 1.` | Field: `order: Relative display position (lower = first). Default 1.`<br>Method TSDoc: `**Sort order**: server does NOT pre-sort; caller must sort by ` `order` ` ascending.` |
|
|
98
|
+
| `xxx_completed_id: Stable identifier of the completion. Pass to ` `requestXxxClaim()` `. Always re-read from a fresh ` `getXxxs()` ` result; never synthesise or cache across sessions. Undefined for badges and incomplete entries.` | Field: `xxx_completed_id: Stable identifier of this completion. Undefined for entries not yet completed.`<br>Method ` `@param` ` block: usage / never-cache / freshness guidance. |
|
|
99
|
+
|
|
100
|
+
**Wrapper result types — the most common type-side violation**
|
|
101
|
+
|
|
102
|
+
Interfaces that exist solely to wrap one method's return value — typically `TXResult` with `err_code` / `err_message` — are 1:1 with their owning method. The method's TSDoc owns the full error-code table; the wrapper type's `err_code` field is one short sentence + pointer:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
/** Error code. `0` = success. See `<methodName>` TSDoc for the full table. */
|
|
106
|
+
err_code: number;
|
|
107
|
+
/** Optional error message; populated on non-zero `err_code`. */
|
|
108
|
+
err_message: string;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Do NOT enumerate the same codes in both places. Two places to maintain when a new code is added is exactly the bifurcation the contract is meant to prevent. If you find an existing wrapper-type comment with the table duplicated (an artifact from pre-contract enrichment), trim it on the spillover pass — see step 8.
|
|
112
|
+
|
|
113
|
+
**Organic cleanup**: For existing docs that violate either discriminator: rewrite when next touching that method or type. Don't do a sweep-clean — organic cleanup is fine.
|
|
114
|
+
|
|
115
|
+
## File layout
|
|
116
|
+
|
|
117
|
+
The SDK surface is split across one class per domain via an inheritance chain. The public name `WSAPI` is the terminator; consumers call `_smartico.api.X(...)` and the method resolves up the prototype chain. Each domain class lives in its own file:
|
|
118
|
+
|
|
119
|
+
| Domain class | File | Methods |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `WSAPIBase` | `src/WSAPI/WSAPIBase.ts` | abstract; constructor, shared state, `clearCaches`, `updateEntity` helper, `onUpdateContextKey` enum |
|
|
122
|
+
| `WSAPIUser` | `src/WSAPI/WSAPIUser.ts` | `getUserProfile`, `getCurrentLevel`, `getLevels`, `getUserLevelExtraCounters`, `checkSegmentMatch`, `checkSegmentListMatch` |
|
|
123
|
+
| `WSAPIGeneral` | `src/WSAPI/WSAPIGeneral.ts` | `getCustomSections`, `getTranslations`, `reportImpressionEvent`, `reportClickEvent`, `getActivityLog`, `getRelatedItemsForGame` |
|
|
124
|
+
| `WSAPIMissions` | `src/WSAPI/WSAPIMissions.ts` | `getMissions`, `getBadges`, `getAchCategories`, `requestMissionOptIn`, `requestMissionClaimReward` |
|
|
125
|
+
| `WSAPIBonuses` | `src/WSAPI/WSAPIBonuses.ts` | `getBonuses`, `claimBonus` |
|
|
126
|
+
| `WSAPIStore` | `src/WSAPI/WSAPIStore.ts` | `getStoreItems`, `buyStoreItem`, `getStoreCategories`, `getStorePurchasedItems` |
|
|
127
|
+
| `WSAPITournaments` | `src/WSAPI/WSAPITournaments.ts` | `getTournamentsList`, `getTournamentInstanceInfo`, `registerInTournament`, `getClanTournamentPlayers` |
|
|
128
|
+
| `WSAPIClans` | `src/WSAPI/WSAPIClans.ts` | `getClans`, `getClanInfo`, `joinClan` |
|
|
129
|
+
| `WSAPIJackpots` | `src/WSAPI/WSAPIJackpots.ts` | `jackpotGet`, `jackpotOptIn`, `jackpotOptOut`, `getJackpotWinners`, `getJackpotEligibleGames` |
|
|
130
|
+
| `WSAPIRaffles` | `src/WSAPI/WSAPIRaffles.ts` | `getRaffles`, `getRaffleDrawRun`, `getRaffleDrawRunsHistory`, `claimRafflePrize`, `requestRaffleOptin` |
|
|
131
|
+
| `WSAPIMiniGames` | `src/WSAPI/WSAPIMiniGames.ts` | `getMiniGames`, `getMiniGamesHistory`, `playMiniGame`, `miniGameWinAcknowledgeRequest`, `playMiniGameBatch` |
|
|
132
|
+
| `WSAPIAvatars` | `src/WSAPI/WSAPIAvatars.ts` | `getAvatarsList`, `getAvatarsCustomized`, `getAvatarPrompts`, `setAvatar` |
|
|
133
|
+
| `WSAPIGamePick` | `src/WSAPI/WSAPIGamePick.ts` | `gamePickGet*`, `gamePickSubmit*` (9 methods) |
|
|
134
|
+
| `WSAPILeaderBoard` | `src/WSAPI/WSAPILeaderBoard.ts` | `getLeaderBoard` |
|
|
135
|
+
| `WSAPIInbox` | `src/WSAPI/WSAPIInbox.ts` | `getInboxMessages`, `getInboxUnreadCount`, `markInboxMessageAsRead`, `markAllInboxMessagesAsRead`, `markUnmarkInboxMessageAsFavorite`, `deleteInboxMessage`, `deleteAllInboxMessages`, `getInboxMessageBody` |
|
|
136
|
+
| `WSAPI` (terminator) | `src/WSAPI/WSAPI.ts` | empty body; constructor runs push-subscription wiring |
|
|
137
|
+
|
|
138
|
+
**UI guides** live at `docs/ui/<domain-slug>/UIGuide_<methodName>.md`. Domain slugs in use today: `missions/`, `store/`. When enriching a method in a domain that doesn't have a UI directory yet, create it (`docs/ui/<lowercase-domain>/`).
|
|
139
|
+
|
|
140
|
+
## Workflow
|
|
141
|
+
|
|
142
|
+
### 1. Locate the SDK method
|
|
143
|
+
|
|
144
|
+
First identify which domain class file owns the method using the file layout below. Then read that file and find the target method. Capture:
|
|
145
|
+
|
|
146
|
+
- Current TSDoc (the floor — don't lose existing content like "Visitor mode: not supported")
|
|
147
|
+
- Method signature + return type
|
|
148
|
+
- The internal `this.api.xxx(...)` it wraps — that's the **protocol-layer name** (e.g. `requestMissionOptIn` wraps `missionOptIn`)
|
|
149
|
+
- The return-type interface in `WSAPITypes.ts` (e.g. `TMissionOptInResult`) — read it too
|
|
150
|
+
|
|
151
|
+
### 2. Hive extraction (`mcp__hive__chat`)
|
|
152
|
+
|
|
153
|
+
Call hive with `goal: "Deep Dive Code"`, `mode: "high"`. Pass **both names** (SDK + protocol-layer) so hive can locate both sides.
|
|
154
|
+
|
|
155
|
+
Prompt template:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
Investigate the Smartico ach codebase (the in-tracker gamification UI at
|
|
159
|
+
/Users/aa/Desktop/SM/tracker/ach/src) for the **<FEATURE>** flow.
|
|
160
|
+
|
|
161
|
+
Context: I'm enriching the TSDoc of `_smartico.api.<SDK_METHOD>(...)`. The
|
|
162
|
+
SDK wraps an internal `<PROTOCOL_METHOD>` that goes over the protocol layer
|
|
163
|
+
(ClassId `<CID_REQUEST>` → `<CID_RESPONSE>`). I need observable behavior
|
|
164
|
+
the SDK consumer needs.
|
|
165
|
+
|
|
166
|
+
Return a structured summary with these sections, citing ach files with
|
|
167
|
+
line numbers.
|
|
168
|
+
|
|
169
|
+
**Part A — API behavior**:
|
|
170
|
+
|
|
171
|
+
1. Call sequence — what runs before and after; prerequisite calls; follow-up calls
|
|
172
|
+
2. Response handling — which response fields ach consumes; which it ignores
|
|
173
|
+
3. Error codes — every distinct errCode value handled, with UI behavior per code
|
|
174
|
+
4. Refresh cadence / triggers — what triggers re-fetch after the call; push vs poll
|
|
175
|
+
5. Prerequisites / gating — user state, mission flags, level/brand/auth requirements
|
|
176
|
+
6. Idempotency — safe to call twice? guards against double-clicks?
|
|
177
|
+
7. Edge cases — locked, time-elapsed, deleted, network failure, timeout
|
|
178
|
+
8. Observable side effects — what other state changes (points, badges, visibility)
|
|
179
|
+
|
|
180
|
+
**Part B — UI rendering** (mandatory for fetch methods returning rich
|
|
181
|
+
entities and mutations with state-dependent buttons; omit subsections that
|
|
182
|
+
don't apply for the method type):
|
|
183
|
+
|
|
184
|
+
9. **List view** (fetch methods returning arrays of rich entities): how is
|
|
185
|
+
the list organized? Tabs / sections / filter chips / flat list? Status
|
|
186
|
+
bucketing — what buckets and what's the priority order for assignment?
|
|
187
|
+
Sort order per bucket? Empty state copy per bucket? Pagination /
|
|
188
|
+
virtualization (if any)?
|
|
189
|
+
10. **Item card / tile** (list-renderable entities): EVERY field from the
|
|
190
|
+
response type that appears on a card; the visual hierarchy
|
|
191
|
+
(title-image-status-progress-reward-CTA layout); what's NOT on the
|
|
192
|
+
card and lives only in the detail view; whole-card click vs sub-element
|
|
193
|
+
handlers.
|
|
194
|
+
11. **Detail view / popup** (entities with a "view more" expansion): the
|
|
195
|
+
top-to-bottom section list; what fields appear ONLY in the detail vs
|
|
196
|
+
also on the card; image size differences.
|
|
197
|
+
12. **Action button decision matrix** (entities with state-dependent
|
|
198
|
+
actions): for every meaningful combination of entity state flags
|
|
199
|
+
(locked, opted-in, completed, requires_claim, missed, expired, etc.),
|
|
200
|
+
what button is shown with what label, when enabled/disabled, what
|
|
201
|
+
click action is dispatched. This must be exhaustive.
|
|
202
|
+
13. **Image / asset specs**: documented source dimensions and aspect
|
|
203
|
+
ratios for all image-bearing fields (entity icon, ribbon, thumbnails,
|
|
204
|
+
etc.). Fallback handling when fields are empty.
|
|
205
|
+
14. **Status-specific visual treatments**: per status (locked / completed
|
|
206
|
+
/ missed / in-progress / featured / claimable), what visual modifier
|
|
207
|
+
is applied (overlay icon, tint, glow, grayscale, etc.).
|
|
208
|
+
15. **Countdown / timing formatting** (entities with deadlines): the
|
|
209
|
+
string format for time-remaining displays; update cadence;
|
|
210
|
+
not-yet-started vs in-progress vs expired text variants.
|
|
211
|
+
16. **Animations / transitions**: list entry animations, popup open/close,
|
|
212
|
+
progress bar fill, success celebrations, loading indicators.
|
|
213
|
+
17. **Mobile vs desktop**: differences in grid layout, card density, or
|
|
214
|
+
interaction patterns.
|
|
215
|
+
18. **Empty / loading / error states**: copy and visual treatment.
|
|
216
|
+
|
|
217
|
+
Constraints on your answer:
|
|
218
|
+
- Focus on observable SDK-consumer behavior. Translate protocol-layer
|
|
219
|
+
internals (ClassId, ProtocolMessage, lib-common/protocol/*,
|
|
220
|
+
Context.interaction.protocolRequest) into "what happens" terms.
|
|
221
|
+
- Do NOT describe Redux/InteractionSlave/Context plumbing.
|
|
222
|
+
- Flag tracker-only behaviors (iframe height messaging, deep-link
|
|
223
|
+
auto-dispatch, parent-frame postMessage scroll locks, etc.) as
|
|
224
|
+
"tracker-only, ignore for SDK".
|
|
225
|
+
- Cite ach files with `file.ts:line` for every claim.
|
|
226
|
+
- For Part B, prefer concrete numbers (px, %, aspect ratios) over vague
|
|
227
|
+
descriptions. If the dimension lives in SCSS that's not indexed, say so
|
|
228
|
+
and quote the documented size from the TSDoc on the public type.
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### 3. Direct verification
|
|
232
|
+
|
|
233
|
+
Read 3–5 cited ach files via `Bash`+`sed` or `Read` to verify hive's claims against actual code. Especially verify:
|
|
234
|
+
|
|
235
|
+
- **Exact error code numeric values** (`OptInErrorCode.AlreadyOptedIn = 40010` etc.)
|
|
236
|
+
- **Field-naming mismatch**: ach uses camelCase internally (`mission.isOptedIn`); SDK exposes snake_case (`mission.is_opted_in`). Examples must use SDK shape.
|
|
237
|
+
- **Control-flow branches**: response.errCode branches and what each one does
|
|
238
|
+
|
|
239
|
+
Do not skip this — hive's summary occasionally collapses or paraphrases logic that the direct read catches.
|
|
240
|
+
|
|
241
|
+
### 4. Draft TSDoc using the template below
|
|
242
|
+
|
|
243
|
+
### 5. Hive validation pass (MANDATORY)
|
|
244
|
+
|
|
245
|
+
A second `mcp__hive__chat` call to verify the draft's specific claims, especially anything sourced from server-side handlers (r-server Java code) that the ach-side analysis can't see.
|
|
246
|
+
|
|
247
|
+
Prompt template:
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
VALIDATION PASS for `<SDK_METHOD>`.
|
|
251
|
+
|
|
252
|
+
Context: I'm finalizing TSDoc for `_smartico.api.<SDK_METHOD>`. Verify
|
|
253
|
+
these claims with citations to the authoritative code path (use r-server
|
|
254
|
+
handlers, DB functions, ach engines — whatever is canonical).
|
|
255
|
+
|
|
256
|
+
For each claim, reply CONFIRMED / INCORRECT / PARTIAL with citation:
|
|
257
|
+
|
|
258
|
+
1. <claim>
|
|
259
|
+
2. <claim>
|
|
260
|
+
3. <claim>
|
|
261
|
+
4. <claim>
|
|
262
|
+
|
|
263
|
+
Don't re-narrate the full flow — just verify these claims.
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Pick 3–5 claims that are:
|
|
267
|
+
- Server-side behavior (error codes, DB writes, side effects) — ach can't authoritatively confirm
|
|
268
|
+
- Cross-system invariants ("X is/isn't idempotent", "X triggers Y")
|
|
269
|
+
- Numeric thresholds (cadences, limits, timeouts)
|
|
270
|
+
|
|
271
|
+
If validation returns `INCORRECT` or `PARTIAL` for any claim, **update the draft before applying**. Add the corrected info; do not paper over the discrepancy.
|
|
272
|
+
|
|
273
|
+
### 6. Apply the Edit (TSDoc)
|
|
274
|
+
|
|
275
|
+
Use the `Edit` tool to replace the existing TSDoc block in the domain class file. The TSDoc keeps **only API behavior**: summary, `@remarks` sections (Preconditions, Error codes, Refresh, Idempotency, Side effects, Cache TTL, Visitor mode), `@param`, `@returns`, `@example`. UI guidance does NOT go inline — it lives in a separate markdown file (see step 7).
|
|
276
|
+
|
|
277
|
+
Replace any pre-existing `**UI guidance — X**` subsections with a single line:
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
* **UI guidance**: see [UI Guide — `<methodName>`](../../docs/ui/<domain>/UIGuide_<methodName>.md).
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
The relative path `../../docs/ui/...` resolves from `src/WSAPI/` to the docs tree (this is the **source-side** path). The post-doc cleanup script (`scripts/postdoc-cleanup.js`) automatically rewrites this to `../../ui/<domain>/...` for the typedoc-rendered output at `docs/api/classes/<class>.md`, where the correct relative path is one segment shorter. If you ever bypass the post-doc cleanup, the rendered `.md` files will have broken UI guide links pointing into `docs/docs/ui/...` (which doesn't exist).
|
|
284
|
+
|
|
285
|
+
**Pre-apply audit** (10-second check on the draft before calling `Edit`):
|
|
286
|
+
|
|
287
|
+
- [ ] No bullet block in @remarks where each bullet has the shape `` `field_name` is/means X `` (Discriminator 1).
|
|
288
|
+
- [ ] No comma-separated prose list of fields all stating the same predicate (e.g. "`a`, `b`, `c`, `d` are not used") — group categorically instead ("opt-in / claim / recurring fields are not used"). A grouped phrase reads as one fact; an itemized list reads as a parallel reference.
|
|
289
|
+
- [ ] No two @remarks sections describing the same conceptual axis (e.g. `**Subscription model**` and `**What triggers async refresh**` both cover "what fires updates" — merge into one section with a sub-list, not two separate sections). LLMs doing section-level retrieval pull only one.
|
|
290
|
+
- [ ] No claim in @remarks that the summary sentence already states word-for-word. The summary is the one-line orientation; @remarks add detail, not echoes.
|
|
291
|
+
- [ ] Wrapper result type (`TXResult`) being touched in spillover: its `err_code` field comment is a one-line pointer to the method TSDoc, NOT a re-enumeration of the codes.
|
|
292
|
+
- [ ] Code snippet in @example uses only public SDK methods, public enums, and `console.log/error` for UI guidance (no pseudo-handlers).
|
|
293
|
+
|
|
294
|
+
Fix the draft *before* calling `Edit`. These violations are cheap to fix pre-write and expensive to find post-write.
|
|
295
|
+
|
|
296
|
+
Apply directly. Do NOT commit. Do NOT push. Do NOT run `npm run doc`.
|
|
297
|
+
|
|
298
|
+
Do NOT leave any `TODO:`, `TODOYY:`, `FIXME:`, `XXX:`, or similar reviewer-note comments in the source. All uncertainty — anything you're not 100% sure of, anything sourced only from hive without direct verification, anything that needs human / system-owner confirmation — goes into the **return summary** to the user, not into the code.
|
|
299
|
+
|
|
300
|
+
### 7. Write / update the UI guide markdown
|
|
301
|
+
|
|
302
|
+
For methods of type "Rich-entity fetch", "Single-entity detail fetch", or "Mutation with state-dependent label/branching" (see classifier below), write the full UI guidance to:
|
|
303
|
+
|
|
304
|
+
```
|
|
305
|
+
docs/ui/<domain>/UIGuide_<methodName>.md
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
The file is plain markdown — sections are `## Heading`, lists are markdown lists, code blocks are fenced. Structure:
|
|
309
|
+
|
|
310
|
+
```markdown
|
|
311
|
+
# UI Guide — `<methodName>`
|
|
312
|
+
|
|
313
|
+
## List view organization
|
|
314
|
+
<bucketing, sort, empty states>
|
|
315
|
+
|
|
316
|
+
## Item card / tile
|
|
317
|
+
<field-by-field render list, click target>
|
|
318
|
+
|
|
319
|
+
## Detail view / popup
|
|
320
|
+
<top-to-bottom layout>
|
|
321
|
+
|
|
322
|
+
## Action button decision matrix
|
|
323
|
+
<priority-ordered list of state combinations>
|
|
324
|
+
|
|
325
|
+
## Companion action caveats
|
|
326
|
+
<synchronous deep-links, etc.>
|
|
327
|
+
|
|
328
|
+
## Image / asset specs
|
|
329
|
+
<dimensions, aspect ratios, fallbacks>
|
|
330
|
+
|
|
331
|
+
## Status-specific visual treatments
|
|
332
|
+
<per status>
|
|
333
|
+
|
|
334
|
+
## Countdown / timing format
|
|
335
|
+
<6-tier compact format>
|
|
336
|
+
|
|
337
|
+
## Empty / loading / error states
|
|
338
|
+
|
|
339
|
+
## Animations / transitions
|
|
340
|
+
|
|
341
|
+
## Mobile vs desktop
|
|
342
|
+
|
|
343
|
+
## Performance
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Omit sections that don't apply for the method type (e.g. a metadata-only fetch like `getStoreCategories` needs only `## List view organization`, `## Empty states`, `## Cache / refresh notes`).
|
|
347
|
+
|
|
348
|
+
**Style rules for the markdown** (same as the TSDoc rules):
|
|
349
|
+
- No protocol-layer references (no `ClassId.X`, no DB schema, no internal class names).
|
|
350
|
+
- Code examples use `console.log()` / `console.error()` with descriptive messages, never pseudo-API handlers.
|
|
351
|
+
- Reference the reference UI as "the default Smartico UI", not "official tracker" / "ach" / "the tracker".
|
|
352
|
+
- The TSDoc method link uses the format above so docs renderers (typedoc, GitHub, etc.) can navigate to the file.
|
|
353
|
+
|
|
354
|
+
For metadata-getters / scalars / fire-and-forget telemetry — **do NOT create a UI guide file**. The TSDoc just doesn't include the `**UI guidance**: see ...` line. The skill's classifier determines this.
|
|
355
|
+
|
|
356
|
+
### 8. Spillover updates and other cross-method effects
|
|
357
|
+
|
|
358
|
+
If the investigation surfaced corrections to OTHER methods, error codes, types, or mappings, apply those too. Common cases:
|
|
359
|
+
|
|
360
|
+
- **Related interface in WSAPITypes.ts** — apply the type/method contract (Discriminator 2 — definition vs. instruction). Two specific sub-patterns:
|
|
361
|
+
- **Wrapper result type** (`TXResult` with `err_code` / `err_message` — exists 1:1 with one method): the `err_code` field comment is ONE line + pointer to the method TSDoc. Never enumerate the same code table in both files. If you find an existing wrapper with the table duplicated (pre-contract enrichment artifact), trim it now — this is the spillover step where that gets caught.
|
|
362
|
+
- **Domain type** (e.g. `TStoreItem`, `TTournament`, `TMissionOrBadge`, `TAchCategory`): each field comment is a definition + null/undefined semantics. Scan for usage-prose drift (sort instructions, "never cache", translation chains, multi-step "always do X then Y" guidance) and strip — the method TSDoc owns it. Add a one-line `Returned by ` `getX()` `` pointer if missing.
|
|
363
|
+
- **A neighbor method has the same error codes** — note them in its TSDoc too if applicable. Cross-reference with "See `<other_method>` for the full error-code table."
|
|
364
|
+
- **An incorrect existing claim** in nearby TSDoc — fix it.
|
|
365
|
+
- **A type alias that returns the wrong shape** — fix the type and flag it as a potential breaking change in the return summary.
|
|
366
|
+
|
|
367
|
+
For each spillover, the same rules apply: apply directly, never commit, surface uncertainty in the return summary (not in code comments).
|
|
368
|
+
|
|
369
|
+
### 9. Post-write housekeeping (manual-support files)
|
|
370
|
+
|
|
371
|
+
Each per-method enrichment produces small deltas to manually-maintained files. Apply them as part of the same run.
|
|
372
|
+
|
|
373
|
+
#### 9a. Update the project `README.md`
|
|
374
|
+
|
|
375
|
+
The `README.md` at the public-api project root has an **API reference table** with a `UI Guides` column. After writing a UI guide markdown file (per step 7), add a link to it in the relevant row.
|
|
376
|
+
|
|
377
|
+
Format: each cell is a `·`-separated list of `` [`<methodName>`](docs/ui/<domain>/UIGuide_<methodName>.md) `` entries. Insert the new link in source-order (matches the order methods are declared in the domain class).
|
|
378
|
+
|
|
379
|
+
If the row currently shows `—` (no UI guides yet for that domain), replace `—` with the new link.
|
|
380
|
+
|
|
381
|
+
Skip this step for method-types where no UI guide was created (metadata getters / scalars / telemetry — see classifier).
|
|
382
|
+
|
|
383
|
+
#### 9b. Update `doc-todo.md` running tally
|
|
384
|
+
|
|
385
|
+
Add one row to the **Running tally** table at the bottom of `/Users/aa/Desktop/SM/public-api/doc-todo.md`:
|
|
386
|
+
|
|
387
|
+
```
|
|
388
|
+
| YYYY-MM-DD | `<methodName>` | ✅ | <todoyy-count> | $<hive-cost> | ~<min> min | — | <one-line note> |
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
Mark the method's checkbox in its domain section (`[ ]` → `[x]`) and add a brief one-line summary inline if applicable.
|
|
392
|
+
|
|
393
|
+
If the per-batch totals row at the bottom needs an update (cumulative method count, cost, etc.), update it too.
|
|
394
|
+
|
|
395
|
+
#### 9c. Fix cross-document links in the just-written UI guide
|
|
396
|
+
|
|
397
|
+
UI guide markdown is written into `docs/ui/<domain>/UIGuide_<methodName>.md`. When the source content was extracted (or hive-pulled) from a typedoc-rendered context, embedded links assume `docs/api/classes/` adjacency and are wrong from `docs/ui/<domain>/`. Three patterns recur:
|
|
398
|
+
|
|
399
|
+
| Original (wrong) | Fixed |
|
|
400
|
+
|---|---|
|
|
401
|
+
| `(WSAPIMissions.md#getmissions)` | `(../../api/classes/WSAPIMissions.md#getmissions)` |
|
|
402
|
+
| `(WSAPIStore.md#buystoreitem)` | `(../../api/classes/WSAPIStore.md#buystoreitem)` |
|
|
403
|
+
| `(../enumerations/AchievementAvailabilityStatus.md)` | `(../../api/enumerations/AchievementAvailabilityStatus.md)` |
|
|
404
|
+
| `(../interfaces/TMissionOrBadge.md)` | `(../../api/interfaces/TMissionOrBadge.md)` |
|
|
405
|
+
| `(#buystoreitem)` (bare anchor that pointed to a sibling method) | `(../../api/classes/WSAPI<Class>.md#buystoreitem)` — figure out the class from the inheritance chain |
|
|
406
|
+
|
|
407
|
+
Rule of thumb: any relative path in a UI guide that points to an SDK reference resource (class doc, interface doc, enum doc) must be prefixed with `../../api/` from `docs/ui/<domain>/`.
|
|
408
|
+
|
|
409
|
+
Run all three of these greps on the new UI guide and fix every match:
|
|
410
|
+
|
|
411
|
+
```sh
|
|
412
|
+
# Cross-class refs (the wsapi class name as a relative file)
|
|
413
|
+
grep -nE "\]\(WSAPI[A-Za-z]+\.md" docs/ui/<domain>/UIGuide_<methodName>.md
|
|
414
|
+
|
|
415
|
+
# Wrong-depth enum / interface refs (single `../` instead of `../../api/`)
|
|
416
|
+
grep -nE "\]\(\.\./[a-z]+/" docs/ui/<domain>/UIGuide_<methodName>.md
|
|
417
|
+
|
|
418
|
+
# Bare same-page anchors that should point to a sibling class
|
|
419
|
+
grep -nE "\]\(#[a-z]" docs/ui/<domain>/UIGuide_<methodName>.md
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
Then sanity-check that every target file exists:
|
|
423
|
+
|
|
424
|
+
```sh
|
|
425
|
+
# For each `(../../api/X/Y.md...)` reference, verify the file exists:
|
|
426
|
+
grep -ohE "\(\.\./\.\./api/[^)#]+\)" docs/ui/<domain>/UIGuide_<methodName>.md \
|
|
427
|
+
| tr -d '()' \
|
|
428
|
+
| while read p; do
|
|
429
|
+
target="docs/$(echo "$p" | cut -c7-)"
|
|
430
|
+
[ -f "$target" ] && echo "OK $p" || echo "MISS $p (looking at $target)"
|
|
431
|
+
done
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
If any are MISS, the reference points to a doc typedoc never generated (e.g. a type that isn't in `tsconfig.entryPoints`). Two options: add the entry point and re-run `npm run doc`, or convert the broken link to backtick-code (`` `AchievementClaimPeriodTypeId` ``) so it renders as plain reference without a hyperlink.
|
|
435
|
+
|
|
436
|
+
#### 9d. Verify `npm run doc` still emits cleanly
|
|
437
|
+
|
|
438
|
+
Run `npm run doc` (from `/Users/aa/Desktop/SM/public-api`) and confirm:
|
|
439
|
+
|
|
440
|
+
- Exit code 0
|
|
441
|
+
- No new warnings beyond pre-existing ones
|
|
442
|
+
- `docs/api/classes/<DomainClass>.md` reflects the new TSDoc
|
|
443
|
+
- `docs/api/_media/` does NOT contain a stale copy of the new UI guide (post-doc cleanup handles this)
|
|
444
|
+
|
|
445
|
+
If warnings appear about unresolved `{@link X}` references, fix them by converting to backtick-code (`` `X` ``) when `X` is a public method in a class that's later in the inheritance chain — those don't resolve and there's no point in fighting it.
|
|
446
|
+
|
|
447
|
+
**Verify UI guide links in the generated class doc resolve correctly**. The post-doc cleanup script rewrites paths from `../../docs/ui/...` (source-side, relative to `src/WSAPI/`) to `../../ui/...` (rendered-side, relative to `docs/api/classes/`). Any broken rewrite would point at `docs/docs/ui/...`, which doesn't exist. Quick sanity check:
|
|
448
|
+
|
|
449
|
+
```sh
|
|
450
|
+
# Confirm no stray ../../docs/ui/ in rendered class docs (correct prefix is ../../ui/)
|
|
451
|
+
grep -rn "../../docs/ui/" docs/api/classes/ && echo "BROKEN" || echo "OK"
|
|
452
|
+
|
|
453
|
+
# Resolve every UI guide link in class docs and confirm the target exists
|
|
454
|
+
for p in $(grep -rohE '\(\.\./\.\./ui/[^)]+\)' docs/api/classes/ | tr -d '()' | sort -u); do
|
|
455
|
+
target=$(python3 -c "import os; print(os.path.normpath('docs/api/classes/$p'))")
|
|
456
|
+
[ -f "$target" ] && echo " ✓ $p" || echo " ✗ $p (missing $target)"
|
|
457
|
+
done
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
Same idea for UI guides: any reference into `docs/api/...` from a UI guide must use `../../api/...` (single `docs/` segment in the resolved path). Quick check for class docs and UI guides together:
|
|
461
|
+
|
|
462
|
+
```sh
|
|
463
|
+
# UI guides should not have a bare ../../docs/ui pattern either; they live in docs/ui/.
|
|
464
|
+
grep -rn "docs/docs/" docs/api/ docs/ui/ && echo "BROKEN" || echo "OK"
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### 10. Present the result
|
|
468
|
+
|
|
469
|
+
Output a tight summary (under 300 words). Include:
|
|
470
|
+
|
|
471
|
+
- **Files edited** with paths
|
|
472
|
+
- **Sections added/changed** per file
|
|
473
|
+
- **Open questions / unverified claims** — anything sourced from hive that you didn't directly verify, anything that needs human or system-owner confirmation. This is the audit trail; be specific (cite the originating ach / r-server location for each claim so the reviewer can re-check).
|
|
474
|
+
- **Reviewer checklist** — server-side claims to confirm, type-shape risks, breaking changes, spillover edits to other methods/types
|
|
475
|
+
- **Cost** (hive call totals + duration)
|
|
476
|
+
|
|
477
|
+
Then **stop**. Do not commit. Do not run docs regeneration. Do not push.
|
|
478
|
+
|
|
479
|
+
## Output template — TSDoc structure
|
|
480
|
+
|
|
481
|
+
Use this skeleton for any async server-roundtrip SDK method. Trim sections that don't apply, but keep the order:
|
|
482
|
+
|
|
483
|
+
```ts
|
|
484
|
+
/**
|
|
485
|
+
* <One-line summary of WHAT the method does and WHO it's for.>
|
|
486
|
+
*
|
|
487
|
+
* <Optional second sentence with the most important behavioral hook —
|
|
488
|
+
* "events fired before opt-in don't count retroactively" — that the
|
|
489
|
+
* consumer must know before reading the @remarks.>
|
|
490
|
+
*
|
|
491
|
+
* @remarks
|
|
492
|
+
* **Preconditions**
|
|
493
|
+
* <What must be true before calling. Reference the source of truth
|
|
494
|
+
* for these flags (usually getX() / getProfile()).>
|
|
495
|
+
*
|
|
496
|
+
* **Error codes** (in `err_code`)
|
|
497
|
+
* - `0` — success; <what happens>
|
|
498
|
+
* - `<code>` — <semantic meaning>. <UI handling guidance.>
|
|
499
|
+
* - <... one bullet per distinct named code from server>
|
|
500
|
+
* - other non-zero — generic server error. Surface `err_message` if any.
|
|
501
|
+
*
|
|
502
|
+
* **<Behavior-specific section>** (e.g. "Time-limited missions",
|
|
503
|
+
* "Pagination", "Cache TTL")
|
|
504
|
+
* <Server-recorded invariants and timing rules.>
|
|
505
|
+
*
|
|
506
|
+
* **Refresh after success**
|
|
507
|
+
* <How the SDK / consumer state updates after this call. Mention
|
|
508
|
+
* any onUpdate callbacks, automatic cache busts, manual re-fetch
|
|
509
|
+
* requirements.>
|
|
510
|
+
*
|
|
511
|
+
* **Idempotency**: <yes/no>. <If no, what code does a retry return?>
|
|
512
|
+
* <Guidance on guarding the call site.>
|
|
513
|
+
*
|
|
514
|
+
* **Side effects**: <points, badges, levels, visibility of other
|
|
515
|
+
* entities. Be explicit about what DOESN'T happen too.>
|
|
516
|
+
*
|
|
517
|
+
* **UI guidance**: see [UI Guide — `<methodName>`](../../docs/ui/<domain>/UIGuide_<methodName>.md).
|
|
518
|
+
*
|
|
519
|
+
* (UI guidance body lives in the linked markdown file — list bucketing,
|
|
520
|
+
* card/detail layouts, action-button matrix, image specs, animations,
|
|
521
|
+
* etc. The TSDoc only links; the markdown owns the content.)
|
|
522
|
+
*
|
|
523
|
+
* (Omit the `**UI guidance**: see ...` line entirely for metadata-only
|
|
524
|
+
* getters, scalar counters, and fire-and-forget telemetry methods —
|
|
525
|
+
* those don't need a UI guide. See the classifier below.)
|
|
526
|
+
*
|
|
527
|
+
* **Visitor mode**: <supported / not supported>
|
|
528
|
+
*
|
|
529
|
+
* @param <name> <Description. Reference the source for the value.>
|
|
530
|
+
* @returns <Shape. Success condition.>
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* ```ts
|
|
534
|
+
* <Realistic snippet using SDK types only. Show the preconditions gate,
|
|
535
|
+
* the loading state, and the per-error-code branches. Use console.log /
|
|
536
|
+
* console.error with descriptive messages stating what the consumer's UI
|
|
537
|
+
* should do at that point — NEVER use pseudo-handlers like showError,
|
|
538
|
+
* showUnlockTasks, refreshUI, notify, toast, etc. The example must run
|
|
539
|
+
* as-is (so a consumer can paste it and verify the flow in devtools)
|
|
540
|
+
* AND describe expected UI behavior in the log message.>
|
|
541
|
+
* ```
|
|
542
|
+
*/
|
|
543
|
+
public async <method>(...) { ... }
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
No reviewer-note comments (`TODO:`, `FIXME:`, `XXX:`, etc.) above the signature. Surface uncertainty in the return summary instead.
|
|
547
|
+
|
|
548
|
+
## Feature → ach subtree map
|
|
549
|
+
|
|
550
|
+
Orientation for hive prompts. Hive can explore wider on its own; this is just where to start.
|
|
551
|
+
|
|
552
|
+
| Feature | ach subtree(s) |
|
|
553
|
+
|---|---|
|
|
554
|
+
| Missions / Achievements | `core/engine/AchievementEngine.ts`, `core/redux/achievement/*`, `component/missions/*`, `component/ach3/modal/ModalMission.tsx`, `component/ach3/page/PageMissions*.tsx`, `component/ach3/page/PageLiquidSection.tsx` |
|
|
555
|
+
| Tournaments | `core/engine/TournamentEngine.ts`, `core/redux/tournament/*`, `component/tournament/*`, `component/ach3/tournament/*`, `component/ach3/tournament-new/*`, `component/ach3/page/PageTournament*.tsx` |
|
|
556
|
+
| Jackpots | `core/engine/JackpotEngine.ts`, `core/redux/jackpots/*` |
|
|
557
|
+
| Raffles / Draws | `core/engine/RaffleEngine.ts`, `core/redux/raffle/*`, `component/ach3/raffle/*` |
|
|
558
|
+
| Store / Shop | `core/engine/StoreEngine.ts`, `core/redux/store/*` |
|
|
559
|
+
| Inbox / Messages | `core/engine/InboxEngine.ts`, `core/redux/inbox/*`, `core/redux/shortInbox/*`, `component/inbox/*` |
|
|
560
|
+
| Levels | `core/redux/levels/*`, `core/engine/UserEngine.ts` |
|
|
561
|
+
| SAW / MiniGame / Lootbox | `core/engine/SawEngine.ts`, `component/saw/*` |
|
|
562
|
+
| Avatars | `core/engine/AvatarsV2Engine.ts`, `core/redux/avatarsV2/*` |
|
|
563
|
+
| Clans | `core/engine/ClansEngine.ts` |
|
|
564
|
+
| User profile | `core/engine/UserEngine.ts`, `core/redux/user/*` |
|
|
565
|
+
| Bonuses | `core/engine/BonusEngine.ts` |
|
|
566
|
+
| LeaderBoards | `core/engine/LeaderBoardEngine.ts` |
|
|
567
|
+
| Activity Log | `core/engine/ActivityLogEngine.ts`, `component/activityLog/*` |
|
|
568
|
+
|
|
569
|
+
## Method-type classifier — how much UI depth?
|
|
570
|
+
|
|
571
|
+
Not every method needs the full UI matrix. Classify the target method first; produce the matching depth.
|
|
572
|
+
|
|
573
|
+
| Method shape | Example | UI depth | UI guide file? |
|
|
574
|
+
|---|---|---|---|
|
|
575
|
+
| **Rich-entity fetch + subscription** | `getMissions({onUpdate})`, `getStoreItems({onUpdate})`, `getTournamentsList({onUpdate})` | **Full**: list bucketing + card + detail popup + action matrix + image specs + animations | **Yes** — write `docs/ui/<domain>/UIGuide_<method>.md` |
|
|
576
|
+
| **Rich-entity fetch (no subscription)** | `getBadges()`, `getRaffles({onUpdate})`, `getJackpotWinners` | **Full minus subscription** — same as above but no `onUpdate` lifecycle | **Yes** |
|
|
577
|
+
| **Mutation with state-dependent label/branching** | `buyStoreItem`, `requestMissionOptIn`, `claimRafflePrize`, `joinClan` | **Action-focused**: button-states matrix per error code + loading + error-handling UI + idempotency UI guard | **Yes** |
|
|
578
|
+
| **Single-entity detail fetch** | `getTournamentInstanceInfo`, `getClanInfo`, `getRaffleDrawRun` | **Detail-focused**: section layout + image specs + state-specific treatments | **Yes** |
|
|
579
|
+
| **Metadata / categories** | `getStoreCategories`, `getAchCategories`, `getLevels` | **Light**: rendering hints (sort, translation, fallback), empty state | **Yes — short** (1–2 KB) |
|
|
580
|
+
| **Counter / scalar** | `getInboxUnreadCount`, `getCurrentLevel` | **Minimal**: how to render the single value, refresh behavior | **No** — TSDoc only |
|
|
581
|
+
| **Fire-and-forget telemetry** | `reportImpressionEvent`, `reportClickEvent` | **None for UI** — focus on call-site placement guidance instead | **No** — TSDoc only |
|
|
582
|
+
|
|
583
|
+
When a UI guide is written, the method's TSDoc gets the `**UI guidance**: see [UI Guide — `<method>`](../../docs/ui/<domain>/UIGuide_<method>.md).` link line. When not, the TSDoc omits the UI line entirely.
|
|
584
|
+
|
|
585
|
+
When in doubt, ask: "would a designer reading the docs need to know this to build a screen?" If yes, document it. If no, leave it out.
|
|
586
|
+
|
|
587
|
+
## Argument handling
|
|
588
|
+
|
|
589
|
+
- `<method_name>` — a specific SDK method like `requestMissionOptIn`. Skill focuses on that one method end-to-end.
|
|
590
|
+
- `<feature_keyword>` — a feature like `missions` or `tournaments`. Skill lists candidate SDK methods in that area and asks the user which to enrich (or processes them in sequence on confirmation).
|
|
591
|
+
- No argument — skill scans all `src/WSAPI/WSAPI<Domain>.ts` files for methods with thin TSDoc (single-line description) and presents a candidate list.
|
|
592
|
+
|
|
593
|
+
## Cost guidance
|
|
594
|
+
|
|
595
|
+
- Per method: ~$1 hive cost + ~5 minutes wall-clock. Across 50 SDK methods: ~$50 + ~4 hours of operator review time.
|
|
596
|
+
- If a method's hive extraction looks unusually short (under 30s) or unusually long (over 5min), that's a signal to re-prompt with more context. Don't accept low-quality output silently.
|
|
597
|
+
|
|
598
|
+
## Anti-patterns to avoid
|
|
599
|
+
|
|
600
|
+
- **"Looks good, applying"** without verification — always read at least 2 ach files directly to spot-check hive's claims.
|
|
601
|
+
- **Leaving any reviewer-note comments** (`TODO:`, `TODOYY:`, `FIXME:`, `XXX:`, etc.) in the source. Uncertainty goes into the return summary, not into code.
|
|
602
|
+
- **Inventing error codes** that hive didn't surface — if hive didn't find a code and validation didn't surface it, the SDK consumer doesn't need to handle it. Don't pad the list.
|
|
603
|
+
- **Using `Promise<T>` shape that doesn't match the actual return** — always re-read the method body to confirm what's actually returned, not what feels right.
|
|
604
|
+
- **Skipping the validation pass on a "trivial" enrichment** — the first real run found a 5-vs-1 error-code discrepancy. Validation isn't optional.
|
|
605
|
+
- **Two @remarks sections covering the same conceptual axis** — e.g. `**Subscription model**` and `**What triggers async refresh**` are both about "what fires updates". Merge into one section with a sub-list, not two. LLMs doing section-level retrieval pull only one and miss the other; human readers skim section headers and lose half the story.
|
|
606
|
+
- **Duplicating an error-code table** between the method TSDoc and the result-type field comment — see Discriminator 2 / "Wrapper result types" in the contract section. The method owns the table; the result type's `err_code` field is a one-line pointer.
|
|
607
|
+
- **Usage instructions in field comments** — sort/translate/never-cache/always-re-read verbs belong in the method TSDoc, not the field. Field comments answer "what is this"; method TSDocs answer "what do I do with it". See Discriminator 2.
|
|
608
|
+
- **Summary that's echoed by an @remarks section verbatim** — the summary is one-line orientation; @remarks add detail. If the summary already says "no opt-in, no claim", don't open a "Differences" section by re-stating "no opt-in, no claim" — start it with the *next* level of detail (what badges DO have, what fields drive behavior instead).
|
|
609
|
+
- **Comma-separated prose lists of fields all stating the same predicate** — e.g. "`a`, `b`, `c`, `d`, `e` are not used" is just Discriminator 1 in disguise. Group categorically ("opt-in / claim / recurring fields are not used") so it reads as one fact, not five.
|
|
610
|
+
|
|
611
|
+
## Capability pages (RAG ingestion) — capture real responses + regenerate
|
|
612
|
+
|
|
613
|
+
The IDE coding agent does NOT read this repo's raw source or the TypeDoc pages.
|
|
614
|
+
It retrieves from **capability pages** — one self-contained markdown doc per
|
|
615
|
+
method at `docs/capabilities/<method>.md`, produced by the deterministic
|
|
616
|
+
generator `scripts/gen-capabilities.js` (`npm run gen-capabilities`). The
|
|
617
|
+
generator stitches: the method TSDoc you just enriched (summary / `@remarks`
|
|
618
|
+
contract / `@param` / `@example` / `{@link}` → Related) + the **return type's own
|
|
619
|
+
field comments** (per-type resolved, inheritance-aware — so `id`/`name`/`type`
|
|
620
|
+
get the right domain's definition) + a **captured REAL response payload**.
|
|
621
|
+
|
|
622
|
+
**Never hand-edit `docs/capabilities/*.md` — they are generated and overwritten.**
|
|
623
|
+
Your job per method is the two inputs the generator can't synthesize: a clean
|
|
624
|
+
TSDoc (the rest of this skill) and a captured response.
|
|
625
|
+
|
|
626
|
+
### Step A — capture the real response shape
|
|
627
|
+
|
|
628
|
+
The single highest-leverage doc artifact (it removes the agent's ~20-probe
|
|
629
|
+
live-SDK fallback). Use the `mcp__hive__run_public_api` MCP tool — it runs the
|
|
630
|
+
real `@smartico/public-api` WSAPI server-side, bound to a label+brand+player, and
|
|
631
|
+
returns the SAME transformed T-shapes a browser sees. **No user-hash, no browser,
|
|
632
|
+
no CORS.** Default test player (env4 — confirm/refresh with the user if rotated):
|
|
633
|
+
|
|
634
|
+
- `label_api_key`: `a6e7ac26-c368-4892-9380-96e7ff82cf3e-4`
|
|
635
|
+
- `brand_api_key`: `f86271e6`
|
|
636
|
+
- `user_ext_id`: `4579cace-9069-4d65-93ff-9b8b6c83c45b`
|
|
637
|
+
|
|
638
|
+
Call the method, slice arrays to **1 representative item**, return it:
|
|
639
|
+
|
|
640
|
+
```
|
|
641
|
+
// code arg to run_public_api:
|
|
642
|
+
const r = await api.<method>(<params>);
|
|
643
|
+
return Array.isArray(r) ? r.slice(0, 1) : r;
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
Write the result to `docs/capabilities/_responses/<method>.json` (raw array/object
|
|
647
|
+
the method returns; the generator trims long strings + re-slices). **Anonymize
|
|
648
|
+
before saving**: replace real CDN hosts with `https://cdn.example/...`, GUIDs /
|
|
649
|
+
`message_guid` / any user identifier with zero-GUIDs, and trim operator HTML
|
|
650
|
+
(tournament/mission `description`) to a short placeholder. Product config (mission
|
|
651
|
+
names, store-item names, prize tables) is fine to keep — it's the field *shape*
|
|
652
|
+
that matters.
|
|
653
|
+
|
|
654
|
+
**Caveat — tracker-state methods can't be captured this way.** `getUserProfile`
|
|
655
|
+
(and other methods that read tracker state, not a WSAPI roundtrip) return
|
|
656
|
+
`"Tracker is not initialized"`. For those few, capture via the headless-browser
|
|
657
|
+
fallback: load the SDK on a page (`_smartico('init', LABEL, { brand_key })`),
|
|
658
|
+
identify the player, call the method, dump JSON from devtools. Note the method in
|
|
659
|
+
the return summary as browser-captured.
|
|
660
|
+
|
|
661
|
+
### Step B — regenerate + verify
|
|
662
|
+
|
|
663
|
+
Run `npm run gen-capabilities`, then spot-check the new
|
|
664
|
+
`docs/capabilities/<method>.md`:
|
|
665
|
+
- **Returns** lists the real fields with the *right* per-domain comments (if a
|
|
666
|
+
field shows another domain's definition, the field-comment collision means the
|
|
667
|
+
return type is missing that field — fix the type, not the page).
|
|
668
|
+
- **Behavioral contract** carries your `@remarks` (no empty `(see )` — those mean
|
|
669
|
+
a `{@link}` target the generator couldn't render; usually fine).
|
|
670
|
+
- **Example response** shows the real shape.
|
|
671
|
+
- No internal leaks surfaced from a type comment (DB tables, `ClassId`, etc.) — if
|
|
672
|
+
one appears, fix the source field comment (it violates the public-contract rule).
|
|
673
|
+
|
|
674
|
+
Do NOT run `gen-capabilities` as part of an unrelated code change, and do not
|
|
675
|
+
commit. It is part of the doc batch (see `api-tsdoc-final`).
|