@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
@@ -1,92 +1,350 @@
1
1
  import { MyTeamsDocument, TeamsDocument, TeamDocument, TeamMembersDocument, TeamRolesDocument, TeamPolicyDocument, SetTeamPolicyDocument, CreateTeamDocument, UpdateTeamDocument, DeleteTeamDocument, JoinTeamDocument, RequestToJoinTeamDocument, LeaveTeamDocument, AddTeamMemberDocument, RemoveTeamMemberDocument, SetTeamMemberRolesDocument, CreateTeamRoleDocument, UpdateTeamRoleDocument, DeleteTeamRoleDocument, } from '../generated/graphql.js';
2
2
  /**
3
- * Teams: app-scoped player groups with roles and delegated management, built
4
- * on the same generic groups subsystem as Channels (group_type='team'). Team
5
- * CRUD, membership, and roles run over the game-api GraphQL endpoint. Unlike
6
- * channels, teams have no realtime messaging path.
3
+ * Teams: app-scoped player groups with roles and delegated management on the
4
+ * **game-api**. Exposed as `client.teams`.
7
5
  *
8
- * Exposed as `client.teams`.
6
+ * A team is a named, app-scoped set of players with a role/permission model,
7
+ * built on the same generic groups subsystem as Channels (`group_type='team'`).
8
+ * The methods here cover a team's full lifecycle — creating teams, listing and
9
+ * fetching them, managing membership (join / request-to-join / leave / add /
10
+ * remove), roles, and the per-app team policy — all over the game-api GraphQL
11
+ * endpoint. Unlike channels, teams have no realtime messaging path.
12
+ *
13
+ * `BigInt` ids (`appId`, `groupId`, `userId`, `groupRoleId`) are sent and
14
+ * received as decimal strings.
15
+ *
16
+ * Every method requires an authenticated session (a Bearer token set via
17
+ * `client.auth.login()` or `client.setToken()`) and the caller must be
18
+ * entitled to the target app; membership/role/policy mutations additionally
19
+ * require a specific team permission (e.g. `manage_group`, `manage_members`,
20
+ * `manage_roles`) or app-admin (`manage_apps`). Failures throw
21
+ * {@link CrowdyGraphQLError} carrying a stable `extensions.code` such as
22
+ * `UNAUTHENTICATED`, `SCOPE_MISSING`, or `FORBIDDEN`.
9
23
  */
10
24
  export class TeamsAPI {
11
25
  constructor(gql) {
12
26
  this.gql = gql;
13
27
  }
14
28
  // -- Queries --------------------------------------------------------------
29
+ /**
30
+ * List the caller's own teams in an app, each with the caller's roles and
31
+ * effective team permissions. Use this to discover which teams the current
32
+ * user belongs to and what they may do in each.
33
+ *
34
+ * @param appId - The app (tenant) to list the caller's teams within, as a
35
+ * decimal `BigInt` string.
36
+ * @returns One {@link GroupMembership} per team the caller belongs to (the
37
+ * team {@link Group}, the caller's {@link GroupRole}s, their effective
38
+ * permission keys, and the join time).
39
+ * @throws {CrowdyGraphQLError} `UNAUTHENTICATED` if there is no valid token,
40
+ * or `SCOPE_MISSING` / `FORBIDDEN` if the caller isn't entitled to the app.
41
+ */
15
42
  async mine(appId) {
16
43
  const data = await this.gql.request(MyTeamsDocument, { appId });
17
44
  return data.myTeams;
18
45
  }
46
+ /**
47
+ * List all active teams in an app — not just the caller's. Use {@link mine}
48
+ * instead when you only want the teams the caller belongs to.
49
+ *
50
+ * @param appId - The app (tenant) whose teams to list, as a decimal `BigInt`
51
+ * string.
52
+ * @returns Every active team in the app as {@link Group} records.
53
+ * @throws {CrowdyGraphQLError} `UNAUTHENTICATED`, or `SCOPE_MISSING` /
54
+ * `FORBIDDEN` if the caller isn't entitled to the app.
55
+ */
19
56
  async list(appId) {
20
57
  const data = await this.gql.request(TeamsDocument, { appId });
21
58
  return data.teams;
22
59
  }
60
+ /**
61
+ * Fetch a single team by its group id.
62
+ *
63
+ * @param groupId - The team's group id, as a decimal `BigInt` string.
64
+ * @returns The team as a {@link Group}.
65
+ * @throws {CrowdyGraphQLError} if the id does not resolve to a team (e.g. it
66
+ * is a channel, or does not exist), or `UNAUTHENTICATED` / `FORBIDDEN` if
67
+ * the caller isn't entitled to the app.
68
+ */
23
69
  async get(groupId) {
24
70
  const data = await this.gql.request(TeamDocument, { groupId });
25
71
  return data.team;
26
72
  }
73
+ /**
74
+ * List a team's members, including pending join requests, each with their
75
+ * membership status and roles.
76
+ *
77
+ * @param groupId - The team whose members to list, as a decimal `BigInt`
78
+ * string.
79
+ * @returns The team's members as {@link GroupMember} records.
80
+ * @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN` if the caller
81
+ * isn't entitled to the team's app.
82
+ */
27
83
  async members(groupId) {
28
84
  const data = await this.gql.request(TeamMembersDocument, { groupId });
29
85
  return data.teamMembers;
30
86
  }
87
+ /**
88
+ * List a team's roles, including the system `leader` role, each with the
89
+ * group-management permission keys it grants.
90
+ *
91
+ * @param groupId - The team whose roles to list, as a decimal `BigInt`
92
+ * string.
93
+ * @returns The team's roles as {@link GroupRole} records.
94
+ * @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN` if the caller
95
+ * isn't entitled to the team's app.
96
+ */
31
97
  async roles(groupId) {
32
98
  const data = await this.gql.request(TeamRolesDocument, { groupId });
33
99
  return data.teamRoles;
34
100
  }
101
+ /**
102
+ * Read an app's current team policy: who may create teams and the default
103
+ * membership policy applied to new teams. Falls back to app defaults when
104
+ * unset.
105
+ *
106
+ * @param appId - The app (tenant) whose team policy to read, as a decimal
107
+ * `BigInt` string.
108
+ * @returns The effective {@link AppGroupPolicy} for teams in the app
109
+ * (creation policy, default membership policy, and any member/group caps).
110
+ * @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN` if the caller
111
+ * isn't entitled to the app.
112
+ */
35
113
  async policy(appId) {
36
114
  const data = await this.gql.request(TeamPolicyDocument, { appId });
37
115
  return data.teamPolicy;
38
116
  }
39
117
  // -- Team mutations -------------------------------------------------------
118
+ /**
119
+ * Create a team in an app. Whether the caller may create one is governed by
120
+ * the per-app team creation policy (`admin` | `member` | `anyone`). The
121
+ * caller becomes the owner and is granted a system `leader` role holding
122
+ * every team permission. New teams default to the app's default membership
123
+ * policy unless `input.membershipPolicy` overrides it.
124
+ *
125
+ * @param input - {@link CreateTeamInput}: the owning `appId`, the team `name`
126
+ * (max 128 chars, unique per app + type), and optional `description` and
127
+ * `membershipPolicy` (`open` | `request` | `invite` | `admin`).
128
+ * @returns The newly created team as a {@link Group}.
129
+ * @throws {CrowdyGraphQLError} `BAD_USER_INPUT` (e.g. name too long or a
130
+ * duplicate name), `FORBIDDEN` if the team policy disallows creation, or
131
+ * `UNAUTHENTICATED`.
132
+ */
40
133
  async create(input) {
41
134
  const data = await this.gql.request(CreateTeamDocument, { input });
42
135
  return data.createTeam;
43
136
  }
137
+ /**
138
+ * Update a team's name, description, and/or membership policy. Only the
139
+ * fields present on `input` change; omitted fields are left as-is. Requires
140
+ * the `manage_group` team permission (app admins bypass).
141
+ *
142
+ * @param input - {@link UpdateTeamInput}: the `groupId` plus the fields to
143
+ * change — `name` (max 128 chars), `description`, and/or `membershipPolicy`
144
+ * (`open` | `request` | `invite` | `admin`).
145
+ * @returns The updated team as a {@link Group}.
146
+ * @throws {CrowdyGraphQLError} `FORBIDDEN` / `SCOPE_MISSING` if the caller
147
+ * lacks `manage_group`, `BAD_USER_INPUT` on a validation failure, or
148
+ * `UNAUTHENTICATED`.
149
+ */
44
150
  async update(input) {
45
151
  const data = await this.gql.request(UpdateTeamDocument, { input });
46
152
  return data.updateTeam;
47
153
  }
48
- async remove(groupId) {
49
- const data = await this.gql.request(DeleteTeamDocument, { groupId });
154
+ /**
155
+ * Delete a team. Requires the `manage_group` team permission (app admins
156
+ * bypass). **Destructive**: cascades to the team's members and roles, drops
157
+ * any grid grants the team conferred, and recomputes the effective grid ACL
158
+ * for affected grids.
159
+ *
160
+ * Pass an `idempotencyKey` to make retries safe: replaying with the same key
161
+ * and identical arguments returns the first result instead of re-applying,
162
+ * while the same key with a **different** `groupId` throws
163
+ * {@link CrowdyGraphQLError} with `code === 'IDEMPOTENCY_CONFLICT'`. Keys
164
+ * expire server-side after 24h. Requires game-api ≥ v0.10.3.
165
+ *
166
+ * @param groupId - The team to delete, as a decimal `BigInt` string.
167
+ * @param idempotencyKey - Optional client-supplied key for safe retries.
168
+ * @returns `true` on success.
169
+ * @throws {CrowdyGraphQLError} `IDEMPOTENCY_CONFLICT` (key reused with
170
+ * different arguments), `FORBIDDEN` / `SCOPE_MISSING` if the caller lacks
171
+ * `manage_group`, or `UNAUTHENTICATED`.
172
+ */
173
+ async remove(groupId, idempotencyKey) {
174
+ const data = await this.gql.request(DeleteTeamDocument, { groupId, idempotencyKey });
50
175
  return data.deleteTeam;
51
176
  }
177
+ /**
178
+ * Set who may create teams in an app and the default membership policy for
179
+ * new teams. Requires app-admin (`manage_apps`). Affects future team
180
+ * creation only — existing teams are unchanged.
181
+ *
182
+ * @param input - {@link SetTeamPolicyInput}: the `appId`, the `creationPolicy`
183
+ * (`admin` | `member` | `anyone`), the `defaultMembershipPolicy` (`open` |
184
+ * `request` | `invite` | `admin`), and optional `maxMembers` /
185
+ * `maxGroupsPerUser` caps (`null` = unlimited).
186
+ * @returns The updated {@link AppGroupPolicy}.
187
+ * @throws {CrowdyGraphQLError} `FORBIDDEN` / `SCOPE_MISSING` if the caller
188
+ * isn't app-admin, `BAD_USER_INPUT` on an invalid policy value, or
189
+ * `UNAUTHENTICATED`.
190
+ */
52
191
  async setPolicy(input) {
53
192
  const data = await this.gql.request(SetTeamPolicyDocument, { input });
54
193
  return data.setTeamPolicy;
55
194
  }
56
195
  // -- Membership mutations -------------------------------------------------
196
+ /**
197
+ * Join a team as the caller. Honors the team's membership policy: `open` →
198
+ * active immediately; `request` → pending until a manager approves; `invite`
199
+ * / `admin` → rejected. Banned users are rejected. No special permission is
200
+ * required.
201
+ *
202
+ * @param groupId - The team to join, as a decimal `BigInt` string.
203
+ * @returns The caller's {@link GroupMember} record; its `status` reflects
204
+ * `active` vs. `pending`.
205
+ * @throws {CrowdyGraphQLError} `FORBIDDEN` if the membership policy or a ban
206
+ * rejects the join, or `UNAUTHENTICATED`.
207
+ */
57
208
  async join(groupId) {
58
209
  const data = await this.gql.request(JoinTeamDocument, { groupId });
59
210
  return data.joinTeam;
60
211
  }
212
+ /**
213
+ * Request to join a request-only team, creating a pending membership a
214
+ * manager can later approve via {@link addMember}. Behaves identically to
215
+ * {@link join}; it exists as a clearer name for request-policy UIs.
216
+ *
217
+ * @param groupId - The request-only team to request to join, as a decimal
218
+ * `BigInt` string.
219
+ * @returns The caller's pending {@link GroupMember} record.
220
+ * @throws {CrowdyGraphQLError} `FORBIDDEN` if the membership policy rejects
221
+ * the request, or `UNAUTHENTICATED`.
222
+ */
61
223
  async requestToJoin(groupId) {
62
224
  const data = await this.gql.request(RequestToJoinTeamDocument, { groupId });
63
225
  return data.requestToJoinTeam;
64
226
  }
65
- async leave(groupId) {
66
- const data = await this.gql.request(LeaveTeamDocument, { groupId });
227
+ /**
228
+ * Leave a team (removes the caller's own membership).
229
+ *
230
+ * Pass an `idempotencyKey` to make retries safe: replaying with the same key
231
+ * and identical arguments returns the first result instead of re-applying,
232
+ * while the same key with a **different** `groupId` throws
233
+ * {@link CrowdyGraphQLError} with `code === 'IDEMPOTENCY_CONFLICT'`. Keys
234
+ * expire server-side after 24h. Requires game-api ≥ v0.10.3.
235
+ *
236
+ * @param groupId - The team to leave, as a decimal `BigInt` string.
237
+ * @param idempotencyKey - Optional client-supplied key for safe retries.
238
+ * @returns `true` if a membership was removed (`false` if the caller wasn't
239
+ * a member).
240
+ * @throws {CrowdyGraphQLError} `IDEMPOTENCY_CONFLICT` (key reused with
241
+ * different arguments), or `UNAUTHENTICATED`.
242
+ */
243
+ async leave(groupId, idempotencyKey) {
244
+ const data = await this.gql.request(LeaveTeamDocument, { groupId, idempotencyKey });
67
245
  return data.leaveTeam;
68
246
  }
247
+ /**
248
+ * Add a user to a team, or approve their pending join request (upserts the
249
+ * membership to `active`). Requires the `manage_members` team permission (app
250
+ * admins bypass). Auto-assigns the team's default role if configured.
251
+ *
252
+ * @param groupId - The team to add the user to, as a decimal `BigInt`
253
+ * string.
254
+ * @param userId - The user to add or approve, as a decimal `BigInt` string.
255
+ * @returns The added/approved {@link GroupMember} record.
256
+ * @throws {CrowdyGraphQLError} `FORBIDDEN` / `SCOPE_MISSING` if the caller
257
+ * lacks `manage_members`, or `UNAUTHENTICATED`.
258
+ */
69
259
  async addMember(groupId, userId) {
70
260
  const data = await this.gql.request(AddTeamMemberDocument, { groupId, userId });
71
261
  return data.addTeamMember;
72
262
  }
263
+ /**
264
+ * Remove a member from a team. Requires the `manage_members` team permission,
265
+ * except that any member may remove themselves (pass their own `userId`).
266
+ * **Destructive**: drops the membership and its roles.
267
+ *
268
+ * @param groupId - The team to remove the user from, as a decimal `BigInt`
269
+ * string.
270
+ * @param userId - The user to remove; may be the caller's own id to
271
+ * self-remove. Decimal `BigInt` string.
272
+ * @returns `true` if a membership was removed.
273
+ * @throws {CrowdyGraphQLError} `FORBIDDEN` / `SCOPE_MISSING` when removing
274
+ * another member without `manage_members`, or `UNAUTHENTICATED`.
275
+ */
73
276
  async removeMember(groupId, userId) {
74
277
  const data = await this.gql.request(RemoveTeamMemberDocument, { groupId, userId });
75
278
  return data.removeTeamMember;
76
279
  }
280
+ /**
281
+ * Replace a member's team roles with the given set. This is **not additive**
282
+ * — roles not listed are removed. Requires the `manage_roles` team permission
283
+ * (app admins bypass).
284
+ *
285
+ * @param input - {@link SetMemberRolesInput}: the `groupId`, the target
286
+ * `userId`, and `roleIds` — the complete set of team role ids the member
287
+ * should have (ids that are unknown or belong to another group are
288
+ * ignored).
289
+ * @returns The updated {@link GroupMember} record with its new roles.
290
+ * @throws {CrowdyGraphQLError} `FORBIDDEN` / `SCOPE_MISSING` if the caller
291
+ * lacks `manage_roles`, or `UNAUTHENTICATED`.
292
+ */
77
293
  async setMemberRoles(input) {
78
294
  const data = await this.gql.request(SetTeamMemberRolesDocument, { input });
79
295
  return data.setTeamMemberRoles;
80
296
  }
81
297
  // -- Role mutations -------------------------------------------------------
298
+ /**
299
+ * Create a custom (non-system) team role granting the given team permission
300
+ * keys. Requires the `manage_roles` team permission (app admins bypass). Keys
301
+ * must be valid team permission keys (`group_permission_defs`).
302
+ *
303
+ * @param input - {@link CreateGroupRoleInput}: the `groupId`, the `roleName`
304
+ * (max 128 chars, unique within the team), the `permissions` keys to grant
305
+ * (e.g. `manage_members`, `manage_roles`, `manage_group`; each max 64
306
+ * chars, defaults to none), and an optional `rank` (higher = more senior;
307
+ * defaults to 0).
308
+ * @returns The created {@link GroupRole}.
309
+ * @throws {CrowdyGraphQLError} `BAD_USER_INPUT` on an invalid/duplicate name
310
+ * or unknown permission key, `FORBIDDEN` / `SCOPE_MISSING` if the caller
311
+ * lacks `manage_roles`, or `UNAUTHENTICATED`.
312
+ */
82
313
  async createRole(input) {
83
314
  const data = await this.gql.request(CreateTeamRoleDocument, { input });
84
315
  return data.createTeamRole;
85
316
  }
317
+ /**
318
+ * Update a team role's name, rank, and/or permission keys (system roles
319
+ * cannot be renamed or re-ranked). When `input.permissions` is supplied it
320
+ * **replaces** the role's existing keys. Requires the `manage_roles` team
321
+ * permission (app admins bypass).
322
+ *
323
+ * @param input - {@link UpdateGroupRoleInput}: the `groupRoleId` plus the
324
+ * fields to change (`roleName`, `permissions`, `rank`); omitted fields are
325
+ * left unchanged.
326
+ * @returns The updated {@link GroupRole}.
327
+ * @throws {CrowdyGraphQLError} `BAD_USER_INPUT` on a validation failure,
328
+ * `FORBIDDEN` / `SCOPE_MISSING` if the caller lacks `manage_roles`, or
329
+ * `UNAUTHENTICATED`.
330
+ */
86
331
  async updateRole(input) {
87
332
  const data = await this.gql.request(UpdateTeamRoleDocument, { input });
88
333
  return data.updateTeamRole;
89
334
  }
335
+ /**
336
+ * Delete a non-system team role. Requires the `manage_roles` team permission
337
+ * (app admins bypass). The system `leader` role cannot be deleted.
338
+ * **Destructive**: removes the role from any members that held it and
339
+ * recomputes any grid ACLs the role granted on.
340
+ *
341
+ * @param groupRoleId - The team role to delete (must be a non-system role),
342
+ * as a decimal `BigInt` string.
343
+ * @returns `true` if a role was deleted.
344
+ * @throws {CrowdyGraphQLError} `FORBIDDEN` / `SCOPE_MISSING` if the caller
345
+ * lacks `manage_roles`, `BAD_USER_INPUT` if targeting a system role, or
346
+ * `UNAUTHENTICATED`.
347
+ */
90
348
  async deleteRole(groupRoleId) {
91
349
  const data = await this.gql.request(DeleteTeamRoleDocument, { groupRoleId });
92
350
  return data.deleteTeamRole;
@@ -1,13 +1,41 @@
1
1
  import type { GraphQLClient } from '../client.js';
2
2
  import { type TeleportRequestMutation, type TeleportRequestMutationVariables } from '../generated/graphql.js';
3
3
  /**
4
- * Teleport API.
4
+ * Teleport authorization checks on the **game-api**. Exposed as
5
+ * `client.teleport`.
5
6
  *
6
- * Exposed as `client.teleport`.
7
+ * This domain only *authorizes* a teleport — it does **not** move the actor. A
8
+ * successful response means the caller is allowed to teleport the actor to the
9
+ * destination; the UDP runtime performs the actual movement. `appId` is a
10
+ * `BigInt` decimal string and the actor `uuid` is exactly **32 ASCII
11
+ * characters** (the UDP-wire actor id), **not** a hyphenated RFC-4122 UUID.
12
+ *
13
+ * Requires an authenticated session (a Bearer game token set via
14
+ * `client.auth.login()` or `client.setToken()`) plus the app-level `teleport`
15
+ * runtime permission. A missing/invalid token throws {@link CrowdyGraphQLError}
16
+ * (`UNAUTHENTICATED`); authorization outcomes are otherwise reported in-band on
17
+ * the response (`success` / `errorCode`) rather than thrown.
7
18
  */
8
19
  export declare class TeleportAPI {
9
20
  private gql;
10
21
  constructor(gql: GraphQLClient);
22
+ /**
23
+ * Check whether the authenticated user may teleport an actor to a destination
24
+ * within an app. Authorization only — it does **not** move the actor (the UDP
25
+ * runtime does that).
26
+ *
27
+ * @param input - {@link TeleportRequestInput}: `appId` (decimal string, must be
28
+ * `> 0`), the destination `chunkAddress` (int64 decimal strings; the reserved
29
+ * sentinel `(-6, -6, -6)` is rejected) and `voxelAddress` (signed 16-bit
30
+ * ints), and the actor `uuid` (exactly 32 ASCII characters).
31
+ * @returns A {@link TeleportResponse}: `success` plus an `errorCode`
32
+ * ({@link UdpErrorCode}) — `NO_ERROR` when allowed, `INVALID_APP_ID` for a
33
+ * non-positive `appId`, or `UNAUTHORIZED` for the sentinel destination or a
34
+ * missing `teleport` permission.
35
+ * @throws {CrowdyGraphQLError} `UNAUTHENTICATED` if no valid game token is
36
+ * present. Authorization failures are reported via `success: false` +
37
+ * `errorCode`, not thrown.
38
+ */
11
39
  request(input: TeleportRequestMutationVariables['input']): Promise<TeleportRequestMutation['teleportRequest']>;
12
40
  }
13
41
  //# sourceMappingURL=teleport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"teleport.d.ts","sourceRoot":"","sources":["../../src/domains/teleport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EACtC,MAAM,yBAAyB,CAAC;AAEjC;;;;GAIG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEhC,OAAO,CACX,KAAK,EAAE,gCAAgC,CAAC,OAAO,CAAC,GAC/C,OAAO,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;CAIvD"}
1
+ {"version":3,"file":"teleport.d.ts","sourceRoot":"","sources":["../../src/domains/teleport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EACtC,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEtC;;;;;;;;;;;;;;;;OAgBG;IACG,OAAO,CACX,KAAK,EAAE,gCAAgC,CAAC,OAAO,CAAC,GAC/C,OAAO,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;CAIvD"}
@@ -1,13 +1,41 @@
1
1
  import { TeleportRequestDocument, } from '../generated/graphql.js';
2
2
  /**
3
- * Teleport API.
3
+ * Teleport authorization checks on the **game-api**. Exposed as
4
+ * `client.teleport`.
4
5
  *
5
- * Exposed as `client.teleport`.
6
+ * This domain only *authorizes* a teleport — it does **not** move the actor. A
7
+ * successful response means the caller is allowed to teleport the actor to the
8
+ * destination; the UDP runtime performs the actual movement. `appId` is a
9
+ * `BigInt` decimal string and the actor `uuid` is exactly **32 ASCII
10
+ * characters** (the UDP-wire actor id), **not** a hyphenated RFC-4122 UUID.
11
+ *
12
+ * Requires an authenticated session (a Bearer game token set via
13
+ * `client.auth.login()` or `client.setToken()`) plus the app-level `teleport`
14
+ * runtime permission. A missing/invalid token throws {@link CrowdyGraphQLError}
15
+ * (`UNAUTHENTICATED`); authorization outcomes are otherwise reported in-band on
16
+ * the response (`success` / `errorCode`) rather than thrown.
6
17
  */
7
18
  export class TeleportAPI {
8
19
  constructor(gql) {
9
20
  this.gql = gql;
10
21
  }
22
+ /**
23
+ * Check whether the authenticated user may teleport an actor to a destination
24
+ * within an app. Authorization only — it does **not** move the actor (the UDP
25
+ * runtime does that).
26
+ *
27
+ * @param input - {@link TeleportRequestInput}: `appId` (decimal string, must be
28
+ * `> 0`), the destination `chunkAddress` (int64 decimal strings; the reserved
29
+ * sentinel `(-6, -6, -6)` is rejected) and `voxelAddress` (signed 16-bit
30
+ * ints), and the actor `uuid` (exactly 32 ASCII characters).
31
+ * @returns A {@link TeleportResponse}: `success` plus an `errorCode`
32
+ * ({@link UdpErrorCode}) — `NO_ERROR` when allowed, `INVALID_APP_ID` for a
33
+ * non-positive `appId`, or `UNAUTHORIZED` for the sentinel destination or a
34
+ * missing `teleport` permission.
35
+ * @throws {CrowdyGraphQLError} `UNAUTHENTICATED` if no valid game token is
36
+ * present. Authorization failures are reported via `success: false` +
37
+ * `errorCode`, not thrown.
38
+ */
11
39
  async request(input) {
12
40
  const data = await this.gql.request(TeleportRequestDocument, { input });
13
41
  return data.teleportRequest;