chore: remove effects leftovers, dead SyncedState.set, add modules/resources skill refs
This commit is contained in:
@@ -6,8 +6,8 @@ description: Use when working with the Rudder TypeScript/JavaScript SDK (@rudder
|
||||
# Rudder Web SDK (@rudder/js-sdk)
|
||||
|
||||
Browser-facing player SDK for the Rudder LiveOps platform. Source of truth:
|
||||
`liveops-web-sdk/src` (generated wire types in `src/generated` come from the
|
||||
gateway's apigen — never edit them by hand).
|
||||
`liveops-web-sdk/src` (generated wire types in `src/generated` come from
|
||||
`liveops-backend/apigen` — never edit them by hand).
|
||||
|
||||
2.0 kernel surface: auth, player (wallets), catalog currencies, storage,
|
||||
project storage, revision sync, `client.modules.call(module, fn, args)`,
|
||||
@@ -40,7 +40,6 @@ const client = new RudderClient({
|
||||
// tokenStore?: TokenStore — default: localStorage, in-memory fallback
|
||||
// requestTimeoutMs?: number — default 10000
|
||||
// syncIntervalMs?: number — revision poll, default 30000 (±20% jitter)
|
||||
// onEffectError?: (error) => void — default console.error
|
||||
});
|
||||
```
|
||||
|
||||
@@ -86,11 +85,12 @@ Tokens are saved to the `TokenStore` automatically. The transport injects
|
||||
| Modules | `client.modules.call(module, fn, args?)` | `CallModuleFunctionClientResponse` (`{ result }`) |
|
||||
| Resources | `client.resources(slug)` | `list` / `get` / `create` / `update` / `delete` |
|
||||
|
||||
There is no UGC, wallet service, or standalone economy service — wallets live
|
||||
on `client.player.data.wallets`. Quests, stores, inventory, leaderboards,
|
||||
battle pass, and remote config are installed modules: call
|
||||
`client.modules.call('quests', 'list')` (etc.) and read rows with
|
||||
`client.resources('items')`.
|
||||
Wallets live on `client.player.data.wallets`. Game features are installed
|
||||
modules, not SDK services (first-party modules: items, inventory, reward,
|
||||
remote_config, leaderboards, quests, store, battlepass). Call them with
|
||||
`client.modules.call('my_module', 'hello', { ... })` and read their rows with
|
||||
`client.resources(slug)`. Details: [reference/modules.md](reference/modules.md),
|
||||
[reference/resources.md](reference/resources.md).
|
||||
|
||||
## Observable domains — the shared pattern
|
||||
|
||||
@@ -137,3 +137,5 @@ documents. A module trap is a 500 and a timeout a 504, both without details.
|
||||
- [reference/auth.md](reference/auth.md) — login flows, options, token store, session lifecycle
|
||||
- [reference/player.md](reference/player.md) — profile + wallets (`PlayerProfile`, `Wallet`)
|
||||
- [reference/storage.md](reference/storage.md) — player + project storage, limits
|
||||
- [reference/modules.md](reference/modules.md) — `modules.call`, response, module errors
|
||||
- [reference/resources.md](reference/resources.md) — `resources(slug)` row operations
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# Modules
|
||||
|
||||
Source: `src/domains/ModulesDomain.ts`. Calls an installed module function as
|
||||
the signed-in player through `POST /sdk/v1/modules/{module}/{fn}`.
|
||||
|
||||
```ts
|
||||
client.modules.call(module: string, fn: string, args?: unknown): Promise<CallModuleFunctionClientResponse>
|
||||
// CallModuleFunctionClientResponse = { result?: unknown }
|
||||
```
|
||||
|
||||
```ts
|
||||
const { result } = await client.modules.call('my_module', 'hello', { name: 'Bob' });
|
||||
```
|
||||
|
||||
`args` is sent as `{ args }`. The response carries only `result`; console
|
||||
output and the kernel call log stay on the platform dry run.
|
||||
|
||||
A business error raised by the module rejects with `RudderHttpError`
|
||||
(`status` 422, body `{ error, code, requestId }`) whose `code` is the
|
||||
module's own open string code; there are no generated constants for it. A
|
||||
trap is a 500 and a timeout a 504, both without details.
|
||||
|
||||
```ts
|
||||
try {
|
||||
await client.modules.call('my_module', 'hello');
|
||||
} catch (error) {
|
||||
if (error instanceof RudderHttpError && error.status === 422) {
|
||||
console.warn(error.code); // module-defined
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,29 @@
|
||||
# Resources
|
||||
|
||||
Source: `src/domains/ResourcesDomain.ts`. Row operations on a resource as the
|
||||
signed-in player through `/sdk/v1/resources/{slug}`. `client.resources(slug)`
|
||||
returns a `ResourceHandle`; it performs no request by itself.
|
||||
|
||||
```ts
|
||||
const items = client.resources('items');
|
||||
items.list(): Promise<ListResourceRowsResponse> // GET /{slug} → { items?: ResourceRow[], total?: number }
|
||||
items.get(id): Promise<ResourceRow> // GET /{slug}/{id}
|
||||
items.create({ id?, data? }): Promise<ResourceRow> // POST /{slug}
|
||||
items.update(id, { data?, version? }): Promise<ResourceRow> // PATCH /{slug}/{id}
|
||||
items.delete(id): Promise<void> // DELETE /{slug}/{id}
|
||||
```
|
||||
|
||||
`ResourceRow` is `{ id, playerId, data, version, rank, createdAt, updatedAt }`
|
||||
(all optional in the generated type). Pass `version` on `update` for
|
||||
optimistic concurrency.
|
||||
|
||||
```ts
|
||||
const row = await client.resources('items').create({ data: { name: 'Sword' } });
|
||||
await client.resources('items').update(row.id!, { data: { name: 'Axe' }, version: row.version });
|
||||
```
|
||||
|
||||
What a player may read or write is decided by the resource's access rules on
|
||||
the server; a denied operation rejects with `RudderHttpError` `code`
|
||||
`forbidden`. Deleting a row that other rows still reference rejects with
|
||||
status 409 and `code` `row_referenced`. Resources are not observable domains:
|
||||
call `list()` again when you need fresh rows.
|
||||
Reference in New Issue
Block a user