@crowdedkingdomstudios/crowdyjs 5.1.0 → 5.2.1

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.
Files changed (75) hide show
  1. package/MIGRATION.md +64 -0
  2. package/README.md +19 -0
  3. package/dist/client.d.ts +98 -5
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +74 -5
  6. package/dist/crowdy-client.d.ts +31 -0
  7. package/dist/crowdy-client.d.ts.map +1 -1
  8. package/dist/crowdy-client.js +8 -0
  9. package/dist/domains/actors.d.ts +88 -5
  10. package/dist/domains/actors.d.ts.map +1 -1
  11. package/dist/domains/actors.js +89 -6
  12. package/dist/domains/apps.d.ts +95 -41
  13. package/dist/domains/apps.d.ts.map +1 -1
  14. package/dist/domains/apps.js +80 -33
  15. package/dist/domains/auth.d.ts +139 -19
  16. package/dist/domains/auth.d.ts.map +1 -1
  17. package/dist/domains/auth.js +137 -17
  18. package/dist/domains/channels.d.ts +264 -5
  19. package/dist/domains/channels.d.ts.map +1 -1
  20. package/dist/domains/channels.js +264 -5
  21. package/dist/domains/chunks.d.ts +116 -3
  22. package/dist/domains/chunks.d.ts.map +1 -1
  23. package/dist/domains/chunks.js +116 -3
  24. package/dist/domains/gameModel.d.ts +412 -6
  25. package/dist/domains/gameModel.d.ts.map +1 -1
  26. package/dist/domains/gameModel.js +412 -6
  27. package/dist/domains/platform.d.ts +36 -20
  28. package/dist/domains/platform.d.ts.map +1 -1
  29. package/dist/domains/platform.js +29 -18
  30. package/dist/domains/serverStatus.d.ts +74 -6
  31. package/dist/domains/serverStatus.d.ts.map +1 -1
  32. package/dist/domains/serverStatus.js +74 -6
  33. package/dist/domains/state.d.ts +50 -2
  34. package/dist/domains/state.d.ts.map +1 -1
  35. package/dist/domains/state.js +50 -2
  36. package/dist/domains/teams.d.ts +265 -7
  37. package/dist/domains/teams.d.ts.map +1 -1
  38. package/dist/domains/teams.js +267 -9
  39. package/dist/domains/teleport.d.ts +30 -2
  40. package/dist/domains/teleport.d.ts.map +1 -1
  41. package/dist/domains/teleport.js +30 -2
  42. package/dist/domains/udp.d.ts +341 -5
  43. package/dist/domains/udp.d.ts.map +1 -1
  44. package/dist/domains/udp.js +341 -5
  45. package/dist/domains/users.d.ts +42 -11
  46. package/dist/domains/users.d.ts.map +1 -1
  47. package/dist/domains/users.js +41 -10
  48. package/dist/domains/voxels.d.ts +107 -2
  49. package/dist/domains/voxels.d.ts.map +1 -1
  50. package/dist/domains/voxels.js +107 -2
  51. package/dist/errors.d.ts +116 -0
  52. package/dist/errors.d.ts.map +1 -1
  53. package/dist/errors.js +100 -0
  54. package/dist/generated/graphql.d.ts +1787 -110
  55. package/dist/generated/graphql.d.ts.map +1 -1
  56. package/dist/generated/graphql.js +75 -9
  57. package/dist/index.d.ts +2 -1
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +2 -1
  60. package/dist/realtime.d.ts +226 -0
  61. package/dist/realtime.d.ts.map +1 -1
  62. package/dist/realtime.js +90 -0
  63. package/dist/session.d.ts +46 -0
  64. package/dist/session.d.ts.map +1 -1
  65. package/dist/session.js +35 -0
  66. package/dist/types.d.ts +429 -0
  67. package/dist/types.d.ts.map +1 -1
  68. package/dist/types.js +53 -0
  69. package/dist/utils.d.ts +86 -0
  70. package/dist/utils.d.ts.map +1 -1
  71. package/dist/utils.js +86 -0
  72. package/dist/world.d.ts +192 -0
  73. package/dist/world.d.ts.map +1 -1
  74. package/dist/world.js +170 -0
  75. package/package.json +1 -1
package/MIGRATION.md CHANGED
@@ -1,3 +1,67 @@
1
+ # CrowdyJS v5.2.1 Notes
2
+
3
+ v5.2.1 is **documentation-only** — no API, type, or behavior changes.
4
+
5
+ ## Changed
6
+
7
+ - Comprehensive TSDoc across the entire public surface (every sub-client class
8
+ and method, the error classes, the realtime types, the token store, and the
9
+ config). Descriptions mirror the GraphQL schema's field semantics and add
10
+ SDK-specific notes — auth/permission requirements, the stable
11
+ `extensions.code`s each call can throw, encoding/units conventions (`BigInt`
12
+ as decimal strings, base64 blobs, 32-char actor ids, chunk-unit distances),
13
+ idempotency-key replay/`IDEMPOTENCY_CONFLICT` behavior, and realtime
14
+ `...AndWait` echo/timeout semantics. These now show up on hover in your IDE
15
+ and in the published `.d.ts`.
16
+ - Two doc-accuracy fixes: `...AndWait` echo timeouts reject with
17
+ `CrowdyRealtimeError` (`code === 'UDP_SEQUENCE_TIMEOUT'`), not
18
+ `CrowdyTimeoutError`; and only actor/voxel sends echo to the sender, so the
19
+ audio/text/event `...AndWait` variants are documented as fire-and-forget-with-error-wait.
20
+
21
+ ---
22
+
23
+ # CrowdyJS v5.2 Notes
24
+
25
+ v5.2 is additive at the SDK API level (new optional parameters only) and
26
+ refreshes the bundled schema, but it **raises the minimum server version**.
27
+
28
+ ## Added
29
+
30
+ - **Idempotency keys on destructive mutations.** The four destructive
31
+ game-client mutations now accept an optional idempotency key. Replaying the
32
+ same call with the same key returns the first result instead of re-applying
33
+ the side effect; the same key with different arguments returns an
34
+ `IDEMPOTENCY_CONFLICT` error. Keys expire server-side after 24h.
35
+
36
+ ```ts
37
+ const key = crypto.randomUUID();
38
+ await client.actors.delete(uuid, key); // first call deletes
39
+ await client.actors.delete(uuid, key); // retry replays the first result
40
+ await client.teams.remove(groupId, key);
41
+ await client.teams.leave(groupId, key);
42
+ await client.voxels.rollback({ ...input, idempotencyKey: key }); // input field
43
+ ```
44
+
45
+ All four parameters are optional and trailing, so existing call sites are
46
+ unchanged.
47
+
48
+ - **Refreshed bundled schema.** Re-synced against `cks-management-api` and
49
+ `cks-game-api` so generated types now include the new Relay-style `*Connection`
50
+ queries (offset `limit`/`offset` args are now marked `@deprecated`), the
51
+ machine-readable `@requiresPermission` directive metadata, and the enumerated
52
+ error codes. `CrowdyGraphQLError` already surfaces these via `extensions.code`,
53
+ `extensions.remediation`, and `extensions.requiredPermission` — no new error
54
+ class is needed.
55
+
56
+ ## Requires
57
+
58
+ - `cks-game-api >= v0.10.3` and `cks-management-api >= v0.1.70`. The destructive
59
+ mutation documents now send the `idempotencyKey` argument, so those four
60
+ operations require a server that defines it. Point the SDK at an environment
61
+ running release **v0.1.19** or later.
62
+
63
+ ---
64
+
1
65
  # CrowdyJS v5.1 Notes
2
66
 
3
67
  v5.1 is additive and non-breaking.
package/README.md CHANGED
@@ -10,6 +10,8 @@ npm install @crowdedkingdomstudios/crowdyjs
10
10
 
11
11
  CrowdyJS v4 targets browsers by default and uses native `fetch`, `WebSocket`, `crypto`, `btoa`, and `atob`. Node tools can still use the SDK, but must provide browser-compatible globals when opening realtime connections.
12
12
 
13
+ > **Server compatibility:** v5.2+ targets environments on release **v0.1.19 or later** (`cks-game-api >= v0.10.3`, `cks-management-api >= v0.1.70`). The destructive mutations send an `idempotencyKey` argument that older servers don't define.
14
+
13
15
  ## Quick start
14
16
 
15
17
  ```ts
@@ -207,6 +209,23 @@ Transport and protocol failures throw structured error classes:
207
209
  - `CrowdyRealtimeError` — realtime subscription couldn't be established or was dropped.
208
210
  - `CrowdyProtocolError` — server response failed schema validation.
209
211
 
212
+ GraphQL errors carry a stable `extensions.code` (e.g. `UNAUTHENTICATED`, `SCOPE_MISSING`, `FORBIDDEN`, `IDEMPOTENCY_CONFLICT`) plus, where applicable, `extensions.remediation` and `extensions.requiredPermission`. Branch on `error.extensions?.code` rather than parsing messages.
213
+
214
+ ## Idempotent retries
215
+
216
+ Destructive game-client mutations accept an optional **idempotency key**. Pass a stable key (e.g. `crypto.randomUUID()`) and a network retry replays the first result instead of applying the side effect twice. Reusing a key with different arguments throws a `CrowdyGraphQLError` with `extensions.code === 'IDEMPOTENCY_CONFLICT'`. Keys expire server-side after 24h.
217
+
218
+ ```ts
219
+ const key = crypto.randomUUID();
220
+ await client.actors.delete(uuid, key); // first call deletes
221
+ await client.actors.delete(uuid, key); // retry → replays the first result
222
+ await client.teams.remove(groupId, key); // deleteTeam
223
+ await client.teams.leave(groupId, key); // leaveTeam
224
+ await client.voxels.rollback({ ...input, idempotencyKey: key }); // input field
225
+ ```
226
+
227
+ The key parameter is optional and trailing, so it's safe to omit. Requires a server on release v0.1.19+ (see Server compatibility above).
228
+
210
229
  ## Auth notes
211
230
 
212
231
  - Use `client.auth.setToken(token)` if you need to seed a token externally (e.g. when restoring auth from a non-default storage).
package/dist/client.d.ts CHANGED
@@ -9,34 +9,127 @@
9
9
  import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
10
10
  import type { SessionStore } from './session.js';
11
11
  import type { CrowdyLogger } from './logger.js';
12
+ /**
13
+ * Configuration for {@link GraphQLClient}, the low-level HTTP transport. You
14
+ * normally don't build this yourself — `CrowdyClient` constructs the transport
15
+ * from its own config — but it is exported for advanced or standalone use.
16
+ */
12
17
  export interface GraphQLClientConfig {
18
+ /**
19
+ * Absolute base URL of the GraphQL HTTP service (e.g.
20
+ * `https://game.example.com/graphql`). Used when {@link graphqlEndpoint} is
21
+ * not set. When both are omitted the client falls back to
22
+ * `http://localhost:3000/graphql`.
23
+ */
13
24
  httpUrl?: string;
25
+ /**
26
+ * Explicit GraphQL endpoint URL. Takes precedence over {@link httpUrl} when
27
+ * both are provided.
28
+ */
14
29
  graphqlEndpoint?: string;
30
+ /**
31
+ * Per-request timeout in **milliseconds**. When it elapses the request is
32
+ * aborted and a {@link CrowdyTimeoutError} is thrown. Defaults to `60000`
33
+ * (60 seconds).
34
+ */
15
35
  timeout?: number;
36
+ /**
37
+ * Optional logger for transport diagnostics. Defaults to a silent logger
38
+ * that discards all output.
39
+ */
16
40
  logger?: CrowdyLogger;
17
41
  }
42
+ /**
43
+ * Low-level HTTP transport for GraphQL operations against the game or
44
+ * management API. It POSTs operations to a single endpoint, attaches the
45
+ * shared Bearer token read fresh from the {@link SessionStore} on every
46
+ * request (so the HTTP client and the realtime socket never disagree about who
47
+ * is authenticated), enforces a timeout, and normalizes every failure into a
48
+ * typed {@link CrowdyError} subclass.
49
+ *
50
+ * Most consumers should use the typed sub-clients on `CrowdyClient` instead;
51
+ * reach for this directly only via the low-level escape hatch
52
+ * (`client.graphql.request(...)`).
53
+ *
54
+ * Failure modes:
55
+ * - {@link CrowdyHttpError} — the endpoint returned a non-2xx HTTP status.
56
+ * - {@link CrowdyGraphQLError} — a 200 response whose `errors[]` was non-empty.
57
+ * - {@link CrowdyNetworkError} — `fetch` itself failed (DNS, TLS, refused).
58
+ * - {@link CrowdyTimeoutError} — the request exceeded
59
+ * {@link GraphQLClientConfig.timeout}.
60
+ *
61
+ * Also exported under the alias {@link GraphQLTransport}.
62
+ */
18
63
  export declare class GraphQLClient {
19
64
  private readonly graphqlEndpoint;
20
65
  private readonly timeout;
21
66
  private readonly session;
22
67
  private readonly logger;
68
+ /**
69
+ * @param config - Endpoint, timeout, and logger options; see
70
+ * {@link GraphQLClientConfig}.
71
+ * @param session - Shared session/token store. Its current token is read
72
+ * fresh on every request and sent as `Authorization: Bearer <token>`, so
73
+ * HTTP auth always tracks the active session.
74
+ */
23
75
  constructor(config: GraphQLClientConfig | undefined, session: SessionStore);
76
+ /**
77
+ * The resolved GraphQL endpoint URL this client POSTs to.
78
+ *
79
+ * @returns The absolute endpoint URL.
80
+ */
24
81
  getEndpoint(): string;
25
82
  /**
26
- * Execute a typed GraphQL operation produced by codegen and return the
27
- * `data` payload. Throws on transport errors, GraphQL errors, or timeouts.
83
+ * Execute a typed GraphQL operation produced by codegen and return its
84
+ * `data` payload. This is the preferred entry point: the
85
+ * {@link TypedDocumentNode} ties `variables` and the result together so both
86
+ * are fully type-checked.
87
+ *
88
+ * @typeParam TResult - The operation's result (`data`) type.
89
+ * @typeParam TVariables - The operation's variables type.
90
+ * @param document - The typed operation document (e.g. `ActorDocument`).
91
+ * @param variables - Variables for the operation; omit for operations that
92
+ * take none.
93
+ * @param options - Optional `signal` to abort the request from your own
94
+ * `AbortController` (in addition to the built-in timeout).
95
+ * @returns The operation's `data` payload.
96
+ * @throws {CrowdyHttpError} on a non-2xx HTTP status.
97
+ * @throws {CrowdyGraphQLError} when the response carries a non-empty
98
+ * `errors[]` array.
99
+ * @throws {CrowdyNetworkError} on a network-level `fetch` failure.
100
+ * @throws {CrowdyTimeoutError} when the request exceeds the configured
101
+ * timeout.
28
102
  */
29
103
  request<TResult, TVariables>(document: TypedDocumentNode<TResult, TVariables>, variables?: TVariables, options?: {
30
104
  signal?: AbortSignal;
31
105
  }): Promise<TResult>;
32
106
  /**
33
- * Internal escape hatch for raw query strings (used by hand-written
34
- * adapters that haven't migrated to typed documents yet). Prefer
35
- * `request()` with a `TypedDocumentNode`.
107
+ * Escape hatch for executing a **raw** GraphQL query string. Prefer
108
+ * {@link request} with a {@link TypedDocumentNode}; this exists for
109
+ * hand-written adapters that haven't migrated to typed documents yet. It
110
+ * POSTs `{ query, variables }`, attaches the Bearer token, applies the
111
+ * timeout, and unwraps the response's `data`.
112
+ *
113
+ * @typeParam T - Expected shape of the returned `data` (defaults to `any`).
114
+ * @param query - The GraphQL document text.
115
+ * @param variables - Variable values keyed by name. Defaults to `{}`.
116
+ * @param options - Optional `signal` to abort from your own
117
+ * `AbortController`; otherwise the internal timeout controls abortion.
118
+ * @returns The response's `data` payload, typed as `T`.
119
+ * @throws {CrowdyHttpError} on a non-2xx HTTP status.
120
+ * @throws {CrowdyGraphQLError} when the response carries a non-empty
121
+ * `errors[]` array.
122
+ * @throws {CrowdyNetworkError} on a network-level `fetch` failure.
123
+ * @throws {CrowdyTimeoutError} when the request exceeds the configured
124
+ * timeout.
36
125
  */
37
126
  query<T = any>(query: string, variables?: Record<string, unknown>, options?: {
38
127
  signal?: AbortSignal;
39
128
  }): Promise<T>;
40
129
  }
130
+ /**
131
+ * Alias for {@link GraphQLClient}, provided so callers can refer to the HTTP
132
+ * layer as a "transport". The two names are the exact same class.
133
+ */
41
134
  export { GraphQLClient as GraphQLTransport };
42
135
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAA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H,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,CAAC"}
package/dist/client.js CHANGED
@@ -9,7 +9,35 @@
9
9
  import { print } from 'graphql';
10
10
  import { silentLogger } from './logger.js';
11
11
  import { CrowdyError, CrowdyGraphQLError, CrowdyHttpError, CrowdyNetworkError, CrowdyTimeoutError, } from './errors.js';
12
+ /**
13
+ * Low-level HTTP transport for GraphQL operations against the game or
14
+ * management API. It POSTs operations to a single endpoint, attaches the
15
+ * shared Bearer token read fresh from the {@link SessionStore} on every
16
+ * request (so the HTTP client and the realtime socket never disagree about who
17
+ * is authenticated), enforces a timeout, and normalizes every failure into a
18
+ * typed {@link CrowdyError} subclass.
19
+ *
20
+ * Most consumers should use the typed sub-clients on `CrowdyClient` instead;
21
+ * reach for this directly only via the low-level escape hatch
22
+ * (`client.graphql.request(...)`).
23
+ *
24
+ * Failure modes:
25
+ * - {@link CrowdyHttpError} — the endpoint returned a non-2xx HTTP status.
26
+ * - {@link CrowdyGraphQLError} — a 200 response whose `errors[]` was non-empty.
27
+ * - {@link CrowdyNetworkError} — `fetch` itself failed (DNS, TLS, refused).
28
+ * - {@link CrowdyTimeoutError} — the request exceeded
29
+ * {@link GraphQLClientConfig.timeout}.
30
+ *
31
+ * Also exported under the alias {@link GraphQLTransport}.
32
+ */
12
33
  export class GraphQLClient {
34
+ /**
35
+ * @param config - Endpoint, timeout, and logger options; see
36
+ * {@link GraphQLClientConfig}.
37
+ * @param session - Shared session/token store. Its current token is read
38
+ * fresh on every request and sent as `Authorization: Bearer <token>`, so
39
+ * HTTP auth always tracks the active session.
40
+ */
13
41
  constructor(config = {}, session) {
14
42
  this.graphqlEndpoint =
15
43
  config.graphqlEndpoint ||
@@ -19,21 +47,58 @@ export class GraphQLClient {
19
47
  this.session = session;
20
48
  this.logger = config.logger ?? silentLogger;
21
49
  }
50
+ /**
51
+ * The resolved GraphQL endpoint URL this client POSTs to.
52
+ *
53
+ * @returns The absolute endpoint URL.
54
+ */
22
55
  getEndpoint() {
23
56
  return this.graphqlEndpoint;
24
57
  }
25
58
  /**
26
- * Execute a typed GraphQL operation produced by codegen and return the
27
- * `data` payload. Throws on transport errors, GraphQL errors, or timeouts.
59
+ * Execute a typed GraphQL operation produced by codegen and return its
60
+ * `data` payload. This is the preferred entry point: the
61
+ * {@link TypedDocumentNode} ties `variables` and the result together so both
62
+ * are fully type-checked.
63
+ *
64
+ * @typeParam TResult - The operation's result (`data`) type.
65
+ * @typeParam TVariables - The operation's variables type.
66
+ * @param document - The typed operation document (e.g. `ActorDocument`).
67
+ * @param variables - Variables for the operation; omit for operations that
68
+ * take none.
69
+ * @param options - Optional `signal` to abort the request from your own
70
+ * `AbortController` (in addition to the built-in timeout).
71
+ * @returns The operation's `data` payload.
72
+ * @throws {CrowdyHttpError} on a non-2xx HTTP status.
73
+ * @throws {CrowdyGraphQLError} when the response carries a non-empty
74
+ * `errors[]` array.
75
+ * @throws {CrowdyNetworkError} on a network-level `fetch` failure.
76
+ * @throws {CrowdyTimeoutError} when the request exceeds the configured
77
+ * timeout.
28
78
  */
29
79
  async request(document, variables, options = {}) {
30
80
  const queryStr = print(document);
31
81
  return this.query(queryStr, (variables ?? {}), options);
32
82
  }
33
83
  /**
34
- * Internal escape hatch for raw query strings (used by hand-written
35
- * adapters that haven't migrated to typed documents yet). Prefer
36
- * `request()` with a `TypedDocumentNode`.
84
+ * Escape hatch for executing a **raw** GraphQL query string. Prefer
85
+ * {@link request} with a {@link TypedDocumentNode}; this exists for
86
+ * hand-written adapters that haven't migrated to typed documents yet. It
87
+ * POSTs `{ query, variables }`, attaches the Bearer token, applies the
88
+ * timeout, and unwraps the response's `data`.
89
+ *
90
+ * @typeParam T - Expected shape of the returned `data` (defaults to `any`).
91
+ * @param query - The GraphQL document text.
92
+ * @param variables - Variable values keyed by name. Defaults to `{}`.
93
+ * @param options - Optional `signal` to abort from your own
94
+ * `AbortController`; otherwise the internal timeout controls abortion.
95
+ * @returns The response's `data` payload, typed as `T`.
96
+ * @throws {CrowdyHttpError} on a non-2xx HTTP status.
97
+ * @throws {CrowdyGraphQLError} when the response carries a non-empty
98
+ * `errors[]` array.
99
+ * @throws {CrowdyNetworkError} on a network-level `fetch` failure.
100
+ * @throws {CrowdyTimeoutError} when the request exceeds the configured
101
+ * timeout.
37
102
  */
38
103
  async query(query, variables = {}, options = {}) {
39
104
  const controller = new AbortController();
@@ -78,4 +143,8 @@ export class GraphQLClient {
78
143
  }
79
144
  }
80
145
  }
146
+ /**
147
+ * Alias for {@link GraphQLClient}, provided so callers can refer to the HTTP
148
+ * layer as a "transport". The two names are the exact same class.
149
+ */
81
150
  export { GraphQLClient as GraphQLTransport };
@@ -59,13 +59,25 @@ export interface CrowdyClientConfig {
59
59
  managementUrl?: string;
60
60
  /** management-api GraphQL endpoint. Defaults to `${managementUrl}/graphql`. */
61
61
  managementGraphqlEndpoint?: string;
62
+ /** Per-request HTTP timeout in milliseconds (applies to both endpoints). */
62
63
  timeout?: number;
64
+ /**
65
+ * Persistence for the Bearer token across reloads. `BrowserLocalStorageTokenStore`
66
+ * is provided; supply your own for SSR/Node. When omitted the token lives only
67
+ * in memory for the lifetime of the client.
68
+ */
63
69
  tokenStore?: TokenStore;
70
+ /** Optional logger for SDK diagnostics (request/realtime lifecycle). */
64
71
  logger?: CrowdyLogger;
72
+ /** Realtime (WebSocket) tuning for reconnect backoff and `...AndWait` timeouts. */
65
73
  realtime?: {
74
+ /** Max reconnect attempts before giving up (default tuned for browsers). */
66
75
  retryAttempts?: number;
76
+ /** Initial reconnect backoff in milliseconds. */
67
77
  retryInitialDelayMs?: number;
78
+ /** Maximum reconnect backoff in milliseconds (the backoff is capped here). */
68
79
  retryMaxDelayMs?: number;
80
+ /** Default timeout for `...AndWait` round-trips that await a matching echo. */
69
81
  waitTimeoutMs?: number;
70
82
  };
71
83
  }
@@ -78,20 +90,31 @@ export declare class CrowdyClient {
78
90
  readonly realtime: SubscriptionManager;
79
91
  /** management-api HTTP client. Same `AuthState` as `graphql`. */
80
92
  readonly management: GraphQLClient;
93
+ /** Auth + session: login, register, logout, password/email flows. */
81
94
  readonly auth: AuthAPI;
95
+ /** Current-user identity: `me`, gamertag, account deletion. */
82
96
  readonly users: UsersAPI;
97
+ /** App discovery + routing (which game-api serves a given app). */
83
98
  readonly apps: AppsAPI;
84
99
  /** Public platform discovery (shared game-api URL, free app quota). */
85
100
  readonly platform: PlatformAPI;
101
+ /** Chunk reads/writes: terrain, LODs, chunk state, distance queries. */
86
102
  readonly chunks: ChunksAPI;
103
+ /** Voxel reads/writes: list, history, rollback, single-voxel edits. */
87
104
  readonly voxels: VoxelsAPI;
105
+ /** Persisted-actor CRUD (durable records; realtime is `udp`/`world`). */
88
106
  readonly actors: ActorsAPI;
107
+ /** Teleport: move an actor to a destination chunk/world. */
89
108
  readonly teleport: TeleportAPI;
109
+ /** Per-user/per-app persisted state blobs. */
90
110
  readonly state: StateAPI;
111
+ /** Server status + version discovery (UDP availability, version floors). */
91
112
  readonly serverStatus: ServerStatusAPI;
113
+ /** Channels: location-independent pub/sub messaging groups. */
92
114
  readonly channels: ChannelsAPI;
93
115
  /** Teams: app-scoped player groups with roles and delegated management. */
94
116
  readonly teams: TeamsAPI;
117
+ /** UDP proxy: spatial sends + the shared realtime notification subscription. */
95
118
  readonly udp: UdpAPI;
96
119
  /** Abstract game model: containers, properties, functions, sessions. */
97
120
  readonly gameModel: GameModelAPI;
@@ -100,6 +123,14 @@ export declare class CrowdyClient {
100
123
  setToken(token: string | null): void;
101
124
  /** Read the current Bearer token (null if no session). */
102
125
  getToken(): string | null;
126
+ /**
127
+ * Ergonomic, app-scoped realtime facade. `client.world(appId)` returns a
128
+ * {@link WorldClient} whose `actor()` and `subscribe()` helpers pass `appId`
129
+ * for you and manage chunk/sequence bookkeeping — the recommended entry point
130
+ * for game loops. The lower-level `client.udp` remains available.
131
+ *
132
+ * @param appId - The app to scope realtime traffic to (BigInt as a decimal string).
133
+ */
103
134
  world(appId: string): WorldClient;
104
135
  /** Closes the WebSocket and clears the in-memory auth token. */
105
136
  close(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"crowdy-client.d.ts","sourceRoot":"","sources":["../src/crowdy-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,WAAW,kBAAkB;IAEjC,4EAA4E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AAI,GAAG,IAAI;IAIpC,0DAA0D;IAC1D,QAAQ,IAAI,MAAM,GAAG,IAAI;IAIzB;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;IAIjC,gEAAgE;IAChE,KAAK,IAAI,IAAI;CAId;AAED,wBAAgB,kBAAkB,CAChC,MAAM,GAAE,kBAAuB,GAC9B,YAAY,CAEd"}
@@ -88,6 +88,14 @@ export class CrowdyClient {
88
88
  getToken() {
89
89
  return this.session.getToken();
90
90
  }
91
+ /**
92
+ * Ergonomic, app-scoped realtime facade. `client.world(appId)` returns a
93
+ * {@link WorldClient} whose `actor()` and `subscribe()` helpers pass `appId`
94
+ * for you and manage chunk/sequence bookkeeping — the recommended entry point
95
+ * for game loops. The lower-level `client.udp` remains available.
96
+ *
97
+ * @param appId - The app to scope realtime traffic to (BigInt as a decimal string).
98
+ */
91
99
  world(appId) {
92
100
  return new WorldClient(appId, this.udp);
93
101
  }
@@ -1,22 +1,105 @@
1
1
  import type { GraphQLClient } from '../client.js';
2
2
  import { type ActorQuery, type ActorQueryVariables, type ActorsQuery, type ActorsQueryVariables, type BatchLookupActorsQuery, type BatchLookupActorsQueryVariables, type CreateActorMutation, type CreateActorMutationVariables, type UpdateActorMutation, type UpdateActorMutationVariables, type DeleteActorMutation, type DeleteActorMutationVariables, type UpdateActorStateMutation, type UpdateActorStateMutationVariables } from '../generated/graphql.js';
3
3
  /**
4
- * Actor (player / NPC) CRUD and filtering.
4
+ * Persisted-actor (player / NPC) CRUD and filtering on the **game-api**.
5
+ * Exposed as `client.actors`.
5
6
  *
6
- * Note: this is the persisted-actor API. For high-frequency replication see
7
- * the existing `client.sendActorUpdate()` UDP path (unchanged).
7
+ * An "actor" here is the durable, server-stored record of a participant
8
+ * (identity, owning app, optional avatar, last-known chunk, and a state blob)
9
+ * not the high-frequency spatial replication stream. For real-time position
10
+ * and state fan-out use the UDP path instead (`client.udp.sendActorUpdate(...)`
11
+ * or the ergonomic `client.world(appId).actor()` helper), which is unchanged
12
+ * and far cheaper per update.
8
13
  *
9
- * Exposed as `client.actors`.
14
+ * Actor ids are exactly **32 ASCII characters** (the UDP-wire actor id), **not**
15
+ * a hyphenated RFC-4122 UUID. Use {@link generateCrowdyUuid} to mint one.
16
+ * `BigInt` values (`appId`, `avatarId`, `userId`) are sent and received as
17
+ * decimal strings.
18
+ *
19
+ * Every method requires an authenticated session (a Bearer token set via
20
+ * `client.auth.login()` or `client.setToken()`) and that the caller is
21
+ * entitled to the target app, or it throws {@link CrowdyGraphQLError}
22
+ * (`UNAUTHENTICATED` / `FORBIDDEN`).
10
23
  */
11
24
  export declare class ActorsAPI {
12
25
  private gql;
13
26
  constructor(gql: GraphQLClient);
27
+ /**
28
+ * Fetch a single persisted actor by its 32-character actor id.
29
+ *
30
+ * @param uuid - The actor's 32-ASCII-character id.
31
+ * @returns The {@link Actor}, or `null` if no actor with that id exists.
32
+ * @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN` if the caller
33
+ * isn't entitled to the actor's app.
34
+ */
14
35
  get(uuid: ActorQueryVariables['uuid']): Promise<ActorQuery['actor']>;
36
+ /**
37
+ * List persisted actors, optionally narrowed by an {@link ActorFilterInput}
38
+ * (e.g. by app, owning user, or avatar). Omit the filter to use its defaults.
39
+ *
40
+ * @param filter - Optional filter; fields are ANDed together.
41
+ * @returns The matching actors.
42
+ * @throws {CrowdyGraphQLError} on auth/validation failures.
43
+ */
15
44
  list(filter?: ActorsQueryVariables['filter']): Promise<ActorsQuery['actors']>;
45
+ /**
46
+ * Resolve many actors in one round-trip by id (and/or the other keys the
47
+ * {@link BatchActorLookupInput} accepts). Prefer this over calling
48
+ * {@link get} in a loop — it avoids N requests and N auth checks.
49
+ *
50
+ * @param input - The batch lookup keys.
51
+ * @returns The actors that were found (missing ids are simply omitted).
52
+ */
16
53
  batchLookup(input: BatchLookupActorsQueryVariables['input']): Promise<BatchLookupActorsQuery['batchLookupActors']>;
54
+ /**
55
+ * Create a persisted actor. `input.uuid` must be a unique 32-ASCII-character
56
+ * id and `input.appId` the owning app; `chunk` is the initial grid position.
57
+ * `avatarId`, `privateState`, and `publicState` are optional (state blobs are
58
+ * base64-encoded binary).
59
+ *
60
+ * @param input - {@link CreateActorInput}.
61
+ * @returns The newly created {@link Actor}.
62
+ * @throws {CrowdyGraphQLError} `BAD_USER_INPUT` (e.g. malformed/duplicate
63
+ * uuid), `FORBIDDEN` if not entitled to the app, or `UNAUTHENTICATED`.
64
+ */
17
65
  create(input: CreateActorMutationVariables['input']): Promise<CreateActorMutation['createActor']>;
66
+ /**
67
+ * Patch an existing actor. Only the fields present on `input` change; omitted
68
+ * fields are left untouched.
69
+ *
70
+ * @param uuid - The actor's 32-character id.
71
+ * @param input - Fields to change ({@link UpdateActorInput}).
72
+ * @returns The updated {@link Actor}.
73
+ * @throws {CrowdyGraphQLError} if the actor doesn't exist or the caller lacks
74
+ * access.
75
+ */
18
76
  update(uuid: UpdateActorMutationVariables['uuid'], input: UpdateActorMutationVariables['input']): Promise<UpdateActorMutation['updateActor']>;
19
- delete(uuid: DeleteActorMutationVariables['uuid']): Promise<DeleteActorMutation['deleteActor']>;
77
+ /**
78
+ * Delete a persisted actor.
79
+ *
80
+ * Pass an `idempotencyKey` to make retries safe: replaying with the same key
81
+ * returns the first result instead of re-applying, while the same key with a
82
+ * **different** `uuid` throws {@link CrowdyGraphQLError} with
83
+ * `code === 'IDEMPOTENCY_CONFLICT'`. Keys expire server-side after 24h.
84
+ * Requires game-api ≥ v0.10.3.
85
+ *
86
+ * @param uuid - The actor's 32-character id.
87
+ * @param idempotencyKey - Optional client-supplied key for safe retries.
88
+ * @returns The deleted {@link Actor} (its identifying fields).
89
+ * @throws {CrowdyGraphQLError} `IDEMPOTENCY_CONFLICT`, `FORBIDDEN`, or
90
+ * `UNAUTHENTICATED`.
91
+ */
92
+ delete(uuid: DeleteActorMutationVariables['uuid'], idempotencyKey?: DeleteActorMutationVariables['idempotencyKey']): Promise<DeleteActorMutation['deleteActor']>;
93
+ /**
94
+ * Replace just an actor's state blob(s) without touching its other fields —
95
+ * a lighter write than {@link update} when only `privateState`/`publicState`
96
+ * change. State is base64-encoded binary.
97
+ *
98
+ * @param uuid - The actor's 32-character id.
99
+ * @param input - {@link UpdateActorStateInput}.
100
+ * @returns The updated {@link Actor}.
101
+ * @throws {CrowdyGraphQLError} on auth/validation failures.
102
+ */
20
103
  updateState(uuid: UpdateActorStateMutationVariables['uuid'], input: UpdateActorStateMutationVariables['input']): Promise<UpdateActorStateMutation['updateActorState']>;
21
104
  }
22
105
  //# sourceMappingURL=actors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../../src/domains/actors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,mBAAmB,EAExB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EAEzB,KAAK,sBAAsB,EAC3B,KAAK,+BAA+B,EAEpC,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EAEjC,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EAEjC,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EAEjC,KAAK,wBAAwB,EAC7B,KAAK,iCAAiC,EACvC,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;GAOG;AACH,qBAAa,SAAS;IACR,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEhC,GAAG,CAAC,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAKpE,IAAI,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAK7E,WAAW,CACf,KAAK,EAAE,+BAA+B,CAAC,OAAO,CAAC,GAC9C,OAAO,CA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