docs: README, CHANGELOG and skill for @rudder/sdk 0.1.0 with generated module clients
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
# Storage — `client.storage` + `client.projectStorage`
|
||||
# Storage — `client.storage`
|
||||
|
||||
Two key/value stores: per-player (`StorageDomain`, revision key `storage`) and
|
||||
project-wide shared (`ProjectStorageDomain`, revision key `projectStorage`).
|
||||
Sources: `src/domains/StorageDomain.ts`, `src/domains/ProjectStorageDomain.ts`.
|
||||
|
||||
## Player storage
|
||||
Per-player storage, one item per `type`. `StorageDomain`, revision key
|
||||
`storage`. Source: `src/domains/StorageDomain.ts`.
|
||||
|
||||
```ts
|
||||
client.storage.data // GetStorageResponse | undefined
|
||||
await client.storage.save(items);
|
||||
client.storage.value // GetStorageResponse | undefined
|
||||
await client.storage.save(type, data);
|
||||
await client.storage.delete(type);
|
||||
```
|
||||
|
||||
@@ -18,52 +15,21 @@ interface GetStorageResponse {
|
||||
nextCursor?: string;
|
||||
}
|
||||
interface StorageItem {
|
||||
data?: string; // opaque payload, JSON-stringify yourself if needed
|
||||
id?: string;
|
||||
type?: string; // the storage "collection" key
|
||||
data?: string; // opaque payload, JSON-stringify yourself
|
||||
id?: string; // server-assigned
|
||||
type?: string; // the storage key
|
||||
}
|
||||
```
|
||||
|
||||
- `save(items: StorageItem[]): Promise<void>` — upserts items, then
|
||||
invalidates the domain so subscribers refetch.
|
||||
- `delete(type: string): Promise<void>` — deletes **all** player storage items
|
||||
of that type, then invalidates.
|
||||
|
||||
## Project storage
|
||||
|
||||
```ts
|
||||
client.projectStorage.data // GetProjectStorageResponse | undefined
|
||||
await client.projectStorage.save(items);
|
||||
```
|
||||
|
||||
```ts
|
||||
interface GetProjectStorageResponse {
|
||||
items?: ProjectStorageItem[];
|
||||
nextCursor?: string;
|
||||
}
|
||||
interface ProjectStorageItem {
|
||||
data?: string;
|
||||
expiresAt?: string;
|
||||
id?: string;
|
||||
readPermission?: 'public' | 'serverOnly';
|
||||
size?: number;
|
||||
type?: string;
|
||||
updatedAt?: string;
|
||||
version?: number;
|
||||
writePermission?: 'public' | 'serverOnly';
|
||||
}
|
||||
interface ProjectStorageUpdateItem { data?: string; type?: string }
|
||||
```
|
||||
|
||||
- `save(items: ProjectStorageUpdateItem[]): Promise<void>` — upserts, then
|
||||
invalidates. Writing is only possible for items whose `writePermission` is
|
||||
`public`; `serverOnly` items are read-only for clients.
|
||||
- The SDK exposes no client-side project-storage delete.
|
||||
- `save(type: string, data: string): Promise<void>`: upserts the item of
|
||||
`type` (the server keeps one item per player and type), then invalidates.
|
||||
- `delete(type: string): Promise<void>`: deletes the item of `type`, then
|
||||
invalidates.
|
||||
|
||||
## Limits and notes
|
||||
|
||||
- Both domains load with `{ limit: 100 }` — the observable snapshot holds at
|
||||
most 100 items and `nextCursor` pagination is not surfaced by the domain.
|
||||
- `data` is a raw string on the wire; serialize/deserialize JSON yourself.
|
||||
- Both are observable (`SyncedState`) and warmed by the revision poll only when
|
||||
in use; mutations self-invalidate.
|
||||
- The state loads with `{ limit: 100 }`; `nextCursor` pagination is not
|
||||
surfaced.
|
||||
- `data` is a raw string on the wire; serialize and parse JSON yourself.
|
||||
- Project storage is not reachable from the client SDK. It stays available to
|
||||
modules, the dashboard and `/game/v1`.
|
||||
|
||||
Reference in New Issue
Block a user