@crowdedkingdoms/crowdyjs 1.0.0
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/LICENSE +21 -0
- package/MIGRATION.md +247 -0
- package/README.md +303 -0
- package/dist/auth-state.d.ts +11 -0
- package/dist/auth-state.d.ts.map +1 -0
- package/dist/auth-state.js +13 -0
- package/dist/client.d.ts +135 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +150 -0
- package/dist/crowdy-client.d.ts +182 -0
- package/dist/crowdy-client.d.ts.map +1 -0
- package/dist/crowdy-client.js +146 -0
- package/dist/domains/actors.d.ts +117 -0
- package/dist/domains/actors.d.ts.map +1 -0
- package/dist/domains/actors.js +140 -0
- package/dist/domains/admin.d.ts +61 -0
- package/dist/domains/admin.d.ts.map +1 -0
- package/dist/domains/admin.js +33 -0
- package/dist/domains/appAccess.d.ts +141 -0
- package/dist/domains/appAccess.d.ts.map +1 -0
- package/dist/domains/appAccess.js +198 -0
- package/dist/domains/apps.d.ts +192 -0
- package/dist/domains/apps.d.ts.map +1 -0
- package/dist/domains/apps.js +217 -0
- package/dist/domains/auth.d.ts +163 -0
- package/dist/domains/auth.d.ts.map +1 -0
- package/dist/domains/auth.js +208 -0
- package/dist/domains/avatars.d.ts +94 -0
- package/dist/domains/avatars.d.ts.map +1 -0
- package/dist/domains/avatars.js +137 -0
- package/dist/domains/billing.d.ts +97 -0
- package/dist/domains/billing.d.ts.map +1 -0
- package/dist/domains/billing.js +131 -0
- package/dist/domains/channels.d.ts +293 -0
- package/dist/domains/channels.d.ts.map +1 -0
- package/dist/domains/channels.js +353 -0
- package/dist/domains/chunks.d.ts +133 -0
- package/dist/domains/chunks.d.ts.map +1 -0
- package/dist/domains/chunks.js +153 -0
- package/dist/domains/controlPlane.d.ts +174 -0
- package/dist/domains/controlPlane.d.ts.map +1 -0
- package/dist/domains/controlPlane.js +252 -0
- package/dist/domains/environments.d.ts +155 -0
- package/dist/domains/environments.d.ts.map +1 -0
- package/dist/domains/environments.js +223 -0
- package/dist/domains/gameApps.d.ts +114 -0
- package/dist/domains/gameApps.d.ts.map +1 -0
- package/dist/domains/gameApps.js +169 -0
- package/dist/domains/gameModel.d.ts +668 -0
- package/dist/domains/gameModel.d.ts.map +1 -0
- package/dist/domains/gameModel.js +816 -0
- package/dist/domains/host.d.ts +35 -0
- package/dist/domains/host.d.ts.map +1 -0
- package/dist/domains/host.js +40 -0
- package/dist/domains/organizations.d.ts +179 -0
- package/dist/domains/organizations.d.ts.map +1 -0
- package/dist/domains/organizations.js +269 -0
- package/dist/domains/payments.d.ts +104 -0
- package/dist/domains/payments.d.ts.map +1 -0
- package/dist/domains/payments.js +129 -0
- package/dist/domains/platform.d.ts +49 -0
- package/dist/domains/platform.d.ts.map +1 -0
- package/dist/domains/platform.js +50 -0
- package/dist/domains/quotas.d.ts +62 -0
- package/dist/domains/quotas.d.ts.map +1 -0
- package/dist/domains/quotas.js +79 -0
- package/dist/domains/serverStatus.d.ts +90 -0
- package/dist/domains/serverStatus.d.ts.map +1 -0
- package/dist/domains/serverStatus.js +104 -0
- package/dist/domains/sharedEnvironment.d.ts +133 -0
- package/dist/domains/sharedEnvironment.d.ts.map +1 -0
- package/dist/domains/sharedEnvironment.js +179 -0
- package/dist/domains/state.d.ts +64 -0
- package/dist/domains/state.d.ts.map +1 -0
- package/dist/domains/state.js +75 -0
- package/dist/domains/teams.d.ts +292 -0
- package/dist/domains/teams.d.ts.map +1 -0
- package/dist/domains/teams.js +352 -0
- package/dist/domains/teleport.d.ts +41 -0
- package/dist/domains/teleport.d.ts.map +1 -0
- package/dist/domains/teleport.js +43 -0
- package/dist/domains/udp.d.ts +405 -0
- package/dist/domains/udp.d.ts.map +1 -0
- package/dist/domains/udp.js +457 -0
- package/dist/domains/usage.d.ts +76 -0
- package/dist/domains/usage.d.ts.map +1 -0
- package/dist/domains/usage.js +110 -0
- package/dist/domains/users.d.ts +147 -0
- package/dist/domains/users.d.ts.map +1 -0
- package/dist/domains/users.js +195 -0
- package/dist/domains/voxels.d.ts +136 -0
- package/dist/domains/voxels.d.ts.map +1 -0
- package/dist/domains/voxels.js +153 -0
- package/dist/errors.d.ts +158 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +142 -0
- package/dist/generated/graphql.d.ts +12206 -0
- package/dist/generated/graphql.d.ts.map +1 -0
- package/dist/generated/graphql.js +474 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/logger.d.ts +8 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +1 -0
- package/dist/realtime.d.ts +319 -0
- package/dist/realtime.d.ts.map +1 -0
- package/dist/realtime.js +390 -0
- package/dist/session.d.ts +73 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +96 -0
- package/dist/subscriptions.d.ts +2 -0
- package/dist/subscriptions.d.ts.map +1 -0
- package/dist/subscriptions.js +1 -0
- package/dist/types.d.ts +658 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +61 -0
- package/dist/utils.d.ts +98 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +136 -0
- package/dist/world.d.ts +236 -0
- package/dist/world.d.ts.map +1 -0
- package/dist/world.js +275 -0
- package/package.json +73 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { GraphQLClient } from '../client.js';
|
|
2
|
+
import { type MeQuery, type UpdateGamertagInput, type UpdateGamertagMutation, type UserQuery, type UsersPaginatedQuery, type UsersPaginatedQueryVariables, type UsersConnectionQuery, type UsersConnectionQueryVariables, type SetSuperAdminMutation, type SetOperatorMutation, type SetEarlyAccessOverrideMutation, type UpdateUserTypeMutation, type ForceLogoutUserMutation, type UpdateUserStateMutation, type UpdateUserStateInput, type FreePlayWindowQuery } from '../generated/graphql.js';
|
|
3
|
+
/**
|
|
4
|
+
* User identity & account management — exposed as `client.users`.
|
|
5
|
+
*
|
|
6
|
+
* Targets the **management-api** (every call routes to `managementUrl`). After
|
|
7
|
+
* the database split the users table is management-owned, so game-api no longer
|
|
8
|
+
* exposes these identity mutations — calling them against a game-api endpoint
|
|
9
|
+
* throws {@link CrowdyGraphQLError} with `FORBIDDEN`, directing you to the
|
|
10
|
+
* management API. Only the read/identity surface a game client realistically
|
|
11
|
+
* needs lives here; super-admin / operator screens use the management UI
|
|
12
|
+
* directly rather than the SDK.
|
|
13
|
+
*
|
|
14
|
+
* Every method needs a valid session (a bearer token set by
|
|
15
|
+
* `client.auth.login()` / `register()` or `client.setToken()`); without one the
|
|
16
|
+
* server returns `UNAUTHENTICATED` — except {@link me}, which resolves to
|
|
17
|
+
* `null`. `BigInt` ids such as `userId` and `orgId` are decimal strings.
|
|
18
|
+
*/
|
|
19
|
+
export declare class UsersAPI {
|
|
20
|
+
private readonly graphql;
|
|
21
|
+
constructor(graphql: GraphQLClient);
|
|
22
|
+
/**
|
|
23
|
+
* Validate the current bearer token and return the authenticated user record.
|
|
24
|
+
* Handy for restoring a session on SDK init.
|
|
25
|
+
*
|
|
26
|
+
* @returns The {@link User}, or `null` if the token is missing, expired, or
|
|
27
|
+
* revoked (an invalid token resolves to `null` rather than throwing).
|
|
28
|
+
* @throws {CrowdyGraphQLError} on transport/validation failures.
|
|
29
|
+
*/
|
|
30
|
+
me(): Promise<MeQuery['me']>;
|
|
31
|
+
/**
|
|
32
|
+
* Set the authenticated user's gamertag and disambiguation (and append a
|
|
33
|
+
* gamertag-history row). Only ever updates the caller. Requires a valid
|
|
34
|
+
* session.
|
|
35
|
+
*
|
|
36
|
+
* @param input - {@link UpdateGamertagInput}: the new `gamertag` (max 64
|
|
37
|
+
* characters) and `disambiguation` (max 128 characters); the pair must be
|
|
38
|
+
* unique across the platform.
|
|
39
|
+
* @returns The updated {@link User} (its `userId`, `gamertag`,
|
|
40
|
+
* `disambiguation`, and `userType`).
|
|
41
|
+
* @throws {CrowdyGraphQLError} `BAD_USER_INPUT` if the gamertag +
|
|
42
|
+
* disambiguation pair is already taken, `UNAUTHENTICATED` without a session,
|
|
43
|
+
* or `FORBIDDEN` when called against game-api (call the management API).
|
|
44
|
+
*/
|
|
45
|
+
updateGamertag(input: UpdateGamertagInput): Promise<UpdateGamertagMutation['updateGamertag']>;
|
|
46
|
+
/**
|
|
47
|
+
* **Destructive, self-service** soft-delete of the caller's **own** account:
|
|
48
|
+
* anonymizes PII and revokes all sessions. Wallet, voxel, and donation history
|
|
49
|
+
* stay intact via foreign keys. Acts only on the caller (no target argument).
|
|
50
|
+
* Requires a valid session.
|
|
51
|
+
*
|
|
52
|
+
* @returns `true` on success.
|
|
53
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` without a session, or
|
|
54
|
+
* `FORBIDDEN` when called against game-api (call the management API).
|
|
55
|
+
*/
|
|
56
|
+
deleteMyAccount(): Promise<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Report whether a free-play window is currently active and when the next one
|
|
59
|
+
* starts. **Public** — no session required.
|
|
60
|
+
*
|
|
61
|
+
* @returns The {@link FreePlayWindowInfo}.
|
|
62
|
+
*/
|
|
63
|
+
freePlayWindow(): Promise<FreePlayWindowQuery['freePlayWindowInfo']>;
|
|
64
|
+
/**
|
|
65
|
+
* Look up any user by id. **Super-admin only** (regular callers can only read
|
|
66
|
+
* their own profile via {@link me}).
|
|
67
|
+
*
|
|
68
|
+
* @param id - Numeric user id (`BigInt` as a decimal string).
|
|
69
|
+
* @returns The {@link User}, or `null` if no such user.
|
|
70
|
+
*/
|
|
71
|
+
get(id: string): Promise<UserQuery['user']>;
|
|
72
|
+
/**
|
|
73
|
+
* Search/list users with offset pagination. **Super-admin only.**
|
|
74
|
+
*
|
|
75
|
+
* @param opts - Optional `query` (prefix match over email/gamertag/id) and
|
|
76
|
+
* `limit` / `offset`.
|
|
77
|
+
* @returns A page of users.
|
|
78
|
+
* @remarks Prefer {@link listConnection} (Relay cursor pagination) for large
|
|
79
|
+
* result sets; the offset args here are deprecated server-side.
|
|
80
|
+
*/
|
|
81
|
+
paginated(opts?: {
|
|
82
|
+
query?: UsersPaginatedQueryVariables['query'];
|
|
83
|
+
limit?: UsersPaginatedQueryVariables['limit'];
|
|
84
|
+
offset?: UsersPaginatedQueryVariables['offset'];
|
|
85
|
+
}): Promise<UsersPaginatedQuery['usersPaginated']>;
|
|
86
|
+
/**
|
|
87
|
+
* Relay-style cursor pagination over users — the preferred alternative to
|
|
88
|
+
* {@link paginated}. **Super-admin only.** Page with `first` plus the previous
|
|
89
|
+
* page's `pageInfo.endCursor` as `after`. See
|
|
90
|
+
* https://docs.crowdedkingdoms.com/overview/pagination.
|
|
91
|
+
*
|
|
92
|
+
* @param args - Optional `first`, `after`, and `query`.
|
|
93
|
+
* @returns A {@link UsersConnection}.
|
|
94
|
+
*/
|
|
95
|
+
listConnection(args?: UsersConnectionQueryVariables): Promise<UsersConnectionQuery['usersConnection']>;
|
|
96
|
+
/**
|
|
97
|
+
* Grant or revoke the platform `is_super_admin` flag on a user. **Super-admin
|
|
98
|
+
* only.**
|
|
99
|
+
*
|
|
100
|
+
* @param userId - Target user id.
|
|
101
|
+
* @param value - `true` to grant, `false` to revoke.
|
|
102
|
+
* @returns The updated user's `userId` + `isSuperAdmin`.
|
|
103
|
+
*/
|
|
104
|
+
setSuperAdmin(userId: string, value: boolean): Promise<SetSuperAdminMutation['setSuperAdmin']>;
|
|
105
|
+
/**
|
|
106
|
+
* Grant or revoke the platform `is_operator` flag (control-plane access) on a
|
|
107
|
+
* user. **Super-admin only.**
|
|
108
|
+
*
|
|
109
|
+
* @param userId - Target user id.
|
|
110
|
+
* @param value - `true` to grant, `false` to revoke.
|
|
111
|
+
* @returns The updated user's `userId` + `isOperator`.
|
|
112
|
+
*/
|
|
113
|
+
setOperator(userId: string, value: boolean): Promise<SetOperatorMutation['setOperator']>;
|
|
114
|
+
/**
|
|
115
|
+
* Force an early-access override on a user (bypasses the early-access gate).
|
|
116
|
+
* **Super-admin only.**
|
|
117
|
+
*
|
|
118
|
+
* @param userId - Target user id.
|
|
119
|
+
* @param value - `true` to grant the override, `false` to clear it.
|
|
120
|
+
* @returns The updated user's `userId` + `grantEarlyAccessOverride`.
|
|
121
|
+
*/
|
|
122
|
+
setEarlyAccessOverride(userId: string, value: boolean): Promise<SetEarlyAccessOverrideMutation['setEarlyAccessOverride']>;
|
|
123
|
+
/**
|
|
124
|
+
* Set a user's `user_type`. **Super-admin only.**
|
|
125
|
+
*
|
|
126
|
+
* @param userId - Target user id.
|
|
127
|
+
* @param value - The new user type string.
|
|
128
|
+
* @returns The updated user's `userId` + `userType`.
|
|
129
|
+
*/
|
|
130
|
+
updateType(userId: string, value: string): Promise<UpdateUserTypeMutation['updateUserType']>;
|
|
131
|
+
/**
|
|
132
|
+
* Revoke all of a user's sessions (force logout everywhere). **Super-admin
|
|
133
|
+
* only.**
|
|
134
|
+
*
|
|
135
|
+
* @param userId - Target user id.
|
|
136
|
+
* @returns `true` on success.
|
|
137
|
+
*/
|
|
138
|
+
forceLogout(userId: string): Promise<ForceLogoutUserMutation['forceLogoutUser']>;
|
|
139
|
+
/**
|
|
140
|
+
* Replace a user's top-level state blob. **Super-admin only.**
|
|
141
|
+
*
|
|
142
|
+
* @param input - {@link UpdateUserStateInput} (`userId` + base64 `state`).
|
|
143
|
+
* @returns The updated user's `userId` + `state`.
|
|
144
|
+
*/
|
|
145
|
+
updateState(input: UpdateUserStateInput): Promise<UpdateUserStateMutation['updateUserState']>;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=users.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/domains/users.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAcL,KAAK,OAAO,EACZ,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EACzB,KAAK,6BAA6B,EAClC,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,aAAa;IAEnD;;;;;;;OAOG;IACG,EAAE,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAKlC;;;;;;;;;;;;;OAaG;IACG,cAAc,CAClB,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;IAKpD;;;;;;;;;OASG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAKzC;;;;;OAKG;IACG,cAAc,IAAI,OAAO,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;IAK1E;;;;;;OAMG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAKjD;;;;;;;;OAQG;IACG,SAAS,CACb,IAAI,GAAE;QACJ,KAAK,CAAC,EAAE,4BAA4B,CAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,CAAC,EAAE,4BAA4B,CAAC,OAAO,CAAC,CAAC;QAC9C,MAAM,CAAC,EAAE,4BAA4B,CAAC,QAAQ,CAAC,CAAC;KAC5C,GACL,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAKjD;;;;;;;;OAQG;IACG,cAAc,CAClB,IAAI,GAAE,6BAAkC,GACvC,OAAO,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IAKnD;;;;;;;OAOG;IACG,aAAa,CACjB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC;IAQlD;;;;;;;OAOG;IACG,WAAW,CACf,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAQ9C;;;;;;;OAOG;IACG,sBAAsB,CAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,8BAA8B,CAAC,wBAAwB,CAAC,CAAC;IAQpE;;;;;;OAMG;IACG,UAAU,CACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;IAQpD;;;;;;OAMG;IACG,WAAW,CACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;IAOtD;;;;;OAKG;IACG,WAAW,CACf,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;CAIvD"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { MeDocument, UpdateGamertagDocument, DeleteMyAccountDocument, UserDocument, UsersPaginatedDocument, UsersConnectionDocument, SetSuperAdminDocument, SetOperatorDocument, SetEarlyAccessOverrideDocument, UpdateUserTypeDocument, ForceLogoutUserDocument, UpdateUserStateDocument, FreePlayWindowDocument, } from '../generated/graphql.js';
|
|
2
|
+
/**
|
|
3
|
+
* User identity & account management — exposed as `client.users`.
|
|
4
|
+
*
|
|
5
|
+
* Targets the **management-api** (every call routes to `managementUrl`). After
|
|
6
|
+
* the database split the users table is management-owned, so game-api no longer
|
|
7
|
+
* exposes these identity mutations — calling them against a game-api endpoint
|
|
8
|
+
* throws {@link CrowdyGraphQLError} with `FORBIDDEN`, directing you to the
|
|
9
|
+
* management API. Only the read/identity surface a game client realistically
|
|
10
|
+
* needs lives here; super-admin / operator screens use the management UI
|
|
11
|
+
* directly rather than the SDK.
|
|
12
|
+
*
|
|
13
|
+
* Every method needs a valid session (a bearer token set by
|
|
14
|
+
* `client.auth.login()` / `register()` or `client.setToken()`); without one the
|
|
15
|
+
* server returns `UNAUTHENTICATED` — except {@link me}, which resolves to
|
|
16
|
+
* `null`. `BigInt` ids such as `userId` and `orgId` are decimal strings.
|
|
17
|
+
*/
|
|
18
|
+
export class UsersAPI {
|
|
19
|
+
constructor(graphql) {
|
|
20
|
+
this.graphql = graphql;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Validate the current bearer token and return the authenticated user record.
|
|
24
|
+
* Handy for restoring a session on SDK init.
|
|
25
|
+
*
|
|
26
|
+
* @returns The {@link User}, or `null` if the token is missing, expired, or
|
|
27
|
+
* revoked (an invalid token resolves to `null` rather than throwing).
|
|
28
|
+
* @throws {CrowdyGraphQLError} on transport/validation failures.
|
|
29
|
+
*/
|
|
30
|
+
async me() {
|
|
31
|
+
const data = await this.graphql.request(MeDocument);
|
|
32
|
+
return data.me;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Set the authenticated user's gamertag and disambiguation (and append a
|
|
36
|
+
* gamertag-history row). Only ever updates the caller. Requires a valid
|
|
37
|
+
* session.
|
|
38
|
+
*
|
|
39
|
+
* @param input - {@link UpdateGamertagInput}: the new `gamertag` (max 64
|
|
40
|
+
* characters) and `disambiguation` (max 128 characters); the pair must be
|
|
41
|
+
* unique across the platform.
|
|
42
|
+
* @returns The updated {@link User} (its `userId`, `gamertag`,
|
|
43
|
+
* `disambiguation`, and `userType`).
|
|
44
|
+
* @throws {CrowdyGraphQLError} `BAD_USER_INPUT` if the gamertag +
|
|
45
|
+
* disambiguation pair is already taken, `UNAUTHENTICATED` without a session,
|
|
46
|
+
* or `FORBIDDEN` when called against game-api (call the management API).
|
|
47
|
+
*/
|
|
48
|
+
async updateGamertag(input) {
|
|
49
|
+
const data = await this.graphql.request(UpdateGamertagDocument, { input });
|
|
50
|
+
return data.updateGamertag;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* **Destructive, self-service** soft-delete of the caller's **own** account:
|
|
54
|
+
* anonymizes PII and revokes all sessions. Wallet, voxel, and donation history
|
|
55
|
+
* stay intact via foreign keys. Acts only on the caller (no target argument).
|
|
56
|
+
* Requires a valid session.
|
|
57
|
+
*
|
|
58
|
+
* @returns `true` on success.
|
|
59
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` without a session, or
|
|
60
|
+
* `FORBIDDEN` when called against game-api (call the management API).
|
|
61
|
+
*/
|
|
62
|
+
async deleteMyAccount() {
|
|
63
|
+
const data = await this.graphql.request(DeleteMyAccountDocument);
|
|
64
|
+
return data.deleteMyAccount;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Report whether a free-play window is currently active and when the next one
|
|
68
|
+
* starts. **Public** — no session required.
|
|
69
|
+
*
|
|
70
|
+
* @returns The {@link FreePlayWindowInfo}.
|
|
71
|
+
*/
|
|
72
|
+
async freePlayWindow() {
|
|
73
|
+
const data = await this.graphql.request(FreePlayWindowDocument);
|
|
74
|
+
return data.freePlayWindowInfo;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Look up any user by id. **Super-admin only** (regular callers can only read
|
|
78
|
+
* their own profile via {@link me}).
|
|
79
|
+
*
|
|
80
|
+
* @param id - Numeric user id (`BigInt` as a decimal string).
|
|
81
|
+
* @returns The {@link User}, or `null` if no such user.
|
|
82
|
+
*/
|
|
83
|
+
async get(id) {
|
|
84
|
+
const data = await this.graphql.request(UserDocument, { id });
|
|
85
|
+
return data.user;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Search/list users with offset pagination. **Super-admin only.**
|
|
89
|
+
*
|
|
90
|
+
* @param opts - Optional `query` (prefix match over email/gamertag/id) and
|
|
91
|
+
* `limit` / `offset`.
|
|
92
|
+
* @returns A page of users.
|
|
93
|
+
* @remarks Prefer {@link listConnection} (Relay cursor pagination) for large
|
|
94
|
+
* result sets; the offset args here are deprecated server-side.
|
|
95
|
+
*/
|
|
96
|
+
async paginated(opts = {}) {
|
|
97
|
+
const data = await this.graphql.request(UsersPaginatedDocument, opts);
|
|
98
|
+
return data.usersPaginated;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Relay-style cursor pagination over users — the preferred alternative to
|
|
102
|
+
* {@link paginated}. **Super-admin only.** Page with `first` plus the previous
|
|
103
|
+
* page's `pageInfo.endCursor` as `after`. See
|
|
104
|
+
* https://docs.crowdedkingdoms.com/overview/pagination.
|
|
105
|
+
*
|
|
106
|
+
* @param args - Optional `first`, `after`, and `query`.
|
|
107
|
+
* @returns A {@link UsersConnection}.
|
|
108
|
+
*/
|
|
109
|
+
async listConnection(args = {}) {
|
|
110
|
+
const data = await this.graphql.request(UsersConnectionDocument, args);
|
|
111
|
+
return data.usersConnection;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Grant or revoke the platform `is_super_admin` flag on a user. **Super-admin
|
|
115
|
+
* only.**
|
|
116
|
+
*
|
|
117
|
+
* @param userId - Target user id.
|
|
118
|
+
* @param value - `true` to grant, `false` to revoke.
|
|
119
|
+
* @returns The updated user's `userId` + `isSuperAdmin`.
|
|
120
|
+
*/
|
|
121
|
+
async setSuperAdmin(userId, value) {
|
|
122
|
+
const data = await this.graphql.request(SetSuperAdminDocument, {
|
|
123
|
+
userId,
|
|
124
|
+
value,
|
|
125
|
+
});
|
|
126
|
+
return data.setSuperAdmin;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Grant or revoke the platform `is_operator` flag (control-plane access) on a
|
|
130
|
+
* user. **Super-admin only.**
|
|
131
|
+
*
|
|
132
|
+
* @param userId - Target user id.
|
|
133
|
+
* @param value - `true` to grant, `false` to revoke.
|
|
134
|
+
* @returns The updated user's `userId` + `isOperator`.
|
|
135
|
+
*/
|
|
136
|
+
async setOperator(userId, value) {
|
|
137
|
+
const data = await this.graphql.request(SetOperatorDocument, {
|
|
138
|
+
userId,
|
|
139
|
+
value,
|
|
140
|
+
});
|
|
141
|
+
return data.setOperator;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Force an early-access override on a user (bypasses the early-access gate).
|
|
145
|
+
* **Super-admin only.**
|
|
146
|
+
*
|
|
147
|
+
* @param userId - Target user id.
|
|
148
|
+
* @param value - `true` to grant the override, `false` to clear it.
|
|
149
|
+
* @returns The updated user's `userId` + `grantEarlyAccessOverride`.
|
|
150
|
+
*/
|
|
151
|
+
async setEarlyAccessOverride(userId, value) {
|
|
152
|
+
const data = await this.graphql.request(SetEarlyAccessOverrideDocument, {
|
|
153
|
+
userId,
|
|
154
|
+
value,
|
|
155
|
+
});
|
|
156
|
+
return data.setEarlyAccessOverride;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Set a user's `user_type`. **Super-admin only.**
|
|
160
|
+
*
|
|
161
|
+
* @param userId - Target user id.
|
|
162
|
+
* @param value - The new user type string.
|
|
163
|
+
* @returns The updated user's `userId` + `userType`.
|
|
164
|
+
*/
|
|
165
|
+
async updateType(userId, value) {
|
|
166
|
+
const data = await this.graphql.request(UpdateUserTypeDocument, {
|
|
167
|
+
userId,
|
|
168
|
+
value,
|
|
169
|
+
});
|
|
170
|
+
return data.updateUserType;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Revoke all of a user's sessions (force logout everywhere). **Super-admin
|
|
174
|
+
* only.**
|
|
175
|
+
*
|
|
176
|
+
* @param userId - Target user id.
|
|
177
|
+
* @returns `true` on success.
|
|
178
|
+
*/
|
|
179
|
+
async forceLogout(userId) {
|
|
180
|
+
const data = await this.graphql.request(ForceLogoutUserDocument, {
|
|
181
|
+
userId,
|
|
182
|
+
});
|
|
183
|
+
return data.forceLogoutUser;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Replace a user's top-level state blob. **Super-admin only.**
|
|
187
|
+
*
|
|
188
|
+
* @param input - {@link UpdateUserStateInput} (`userId` + base64 `state`).
|
|
189
|
+
* @returns The updated user's `userId` + `state`.
|
|
190
|
+
*/
|
|
191
|
+
async updateState(input) {
|
|
192
|
+
const data = await this.graphql.request(UpdateUserStateDocument, { input });
|
|
193
|
+
return data.updateUserState;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { GraphQLClient } from '../client.js';
|
|
2
|
+
import { type ListVoxelsQuery, type ListVoxelsQueryVariables, type ListVoxelUpdatesByDistanceQuery, type ListVoxelUpdatesByDistanceQueryVariables, type UpdateVoxelMutation, type UpdateVoxelMutationVariables, type VoxelUpdateHistoryQuery, type VoxelUpdateHistoryQueryVariables, type VoxelUpdateHistoryConnectionQuery, type VoxelUpdateHistoryConnectionQueryVariables, type RollbackVoxelUpdatesMutation, type RollbackVoxelUpdatesMutationVariables } from '../generated/graphql.js';
|
|
3
|
+
/**
|
|
4
|
+
* Voxel-edit queries and mutations for an app's world on the **game-api**: list,
|
|
5
|
+
* distance scans, history, rollback, and single-voxel writes. Exposed as
|
|
6
|
+
* `client.voxels`.
|
|
7
|
+
*
|
|
8
|
+
* A "voxel edit" is one row of the `voxel_updates` log (a {@link Voxel}): the
|
|
9
|
+
* app / chunk / local position that changed, the new voxel type, an optional
|
|
10
|
+
* base64 state blob, and who/when. A background maintenance job later folds these
|
|
11
|
+
* edits into the chunk's packed grid (see {@link ChunksAPI}). For high-frequency
|
|
12
|
+
* realtime edits prefer the UDP path (`client.udp.sendVoxelUpdate(...)`); use
|
|
13
|
+
* this API for authoritative reads, audit history, and administrative rollback.
|
|
14
|
+
*
|
|
15
|
+
* Coordinate & encoding conventions:
|
|
16
|
+
* - **Chunk coordinates** are int64 **decimal strings**; **voxel positions**
|
|
17
|
+
* (`location`) are signed 16-bit ints, `0-15` per axis for in-bounds voxels.
|
|
18
|
+
* - `appId` / `userId` are `BigInt` sent and received as decimal strings.
|
|
19
|
+
* - Voxel `state` blobs are **base64-encoded** binary.
|
|
20
|
+
*
|
|
21
|
+
* Every method requires an authenticated session (a Bearer token set via
|
|
22
|
+
* `client.auth.login()` or `client.setToken()`); an app-scoped token may only
|
|
23
|
+
* touch its own app, otherwise {@link CrowdyGraphQLError} is thrown
|
|
24
|
+
* (`UNAUTHENTICATED` / `FORBIDDEN`). {@link VoxelsAPI.update} additionally
|
|
25
|
+
* requires the `update_voxel_data` runtime permission and
|
|
26
|
+
* {@link VoxelsAPI.rollback} the `manage_apps` permission
|
|
27
|
+
* (`SCOPE_MISSING` / `FORBIDDEN`).
|
|
28
|
+
*/
|
|
29
|
+
export declare class VoxelsAPI {
|
|
30
|
+
private gql;
|
|
31
|
+
constructor(gql: GraphQLClient);
|
|
32
|
+
/**
|
|
33
|
+
* List recorded voxel edits for a single chunk, newest first (optionally only
|
|
34
|
+
* those at/after a timestamp). Read-only.
|
|
35
|
+
*
|
|
36
|
+
* @param input - {@link ListVoxelsInput}: `appId`, chunk `coordinates`, and an
|
|
37
|
+
* optional inclusive `since` lower time bound (only edits with
|
|
38
|
+
* `createdAt >= since`).
|
|
39
|
+
* @returns The matching {@link Voxel} edits, newest first (each `state` blob
|
|
40
|
+
* base64-encoded).
|
|
41
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN`.
|
|
42
|
+
*/
|
|
43
|
+
list(input: ListVoxelsQueryVariables['input']): Promise<ListVoxelsQuery['listVoxels']>;
|
|
44
|
+
/**
|
|
45
|
+
* List recorded voxel edits for all chunks within a cubic (Chebyshev) radius of
|
|
46
|
+
* a center chunk, grouped per chunk and ordered by increasing distance,
|
|
47
|
+
* paginated over chunks. Read-only.
|
|
48
|
+
*
|
|
49
|
+
* @param input - {@link ListVoxelUpdatesByDistanceInput}: `appId`,
|
|
50
|
+
* `centerCoordinate`, `maxDistance` (in chunk units, integer `1-8`), optional
|
|
51
|
+
* `limit` (max **chunks**, not voxels — default 1000) / `skip` (default 0),
|
|
52
|
+
* and an optional `since` lower time bound.
|
|
53
|
+
* @returns A {@link VoxelUpdatesByDistanceResponse}: per-chunk groups of voxel
|
|
54
|
+
* edits ordered by increasing distance from `centerCoordinate`, plus an echo
|
|
55
|
+
* of the applied `limit`/`skip`.
|
|
56
|
+
* @throws {CrowdyGraphQLError} `BAD_USER_INPUT` (e.g. `maxDistance` outside
|
|
57
|
+
* `1-8`), `UNAUTHENTICATED`, or `FORBIDDEN`.
|
|
58
|
+
*/
|
|
59
|
+
listByDistance(input: ListVoxelUpdatesByDistanceQueryVariables['input']): Promise<ListVoxelUpdatesByDistanceQuery['listVoxelUpdatesByDistance']>;
|
|
60
|
+
/**
|
|
61
|
+
* Record (upsert) a single voxel edit in the `voxel_updates` log for one chunk.
|
|
62
|
+
* **Writes world state**; a background job later folds the edit into the
|
|
63
|
+
* chunk's packed grid. Requires voxel-edit permission for the target region:
|
|
64
|
+
* active app access plus the `update_voxel_data` runtime permission (and, where
|
|
65
|
+
* grids cover the chunk, `update_voxel_data` on a covering grid).
|
|
66
|
+
*
|
|
67
|
+
* @param input - {@link UpdateVoxelInput}: `appId`, chunk `coordinates`, the
|
|
68
|
+
* local voxel `location` (`0-15` per axis), the `voxelType` to write
|
|
69
|
+
* (`0-255`), and an optional base64 `state` blob.
|
|
70
|
+
* @returns The resulting {@link Voxel}.
|
|
71
|
+
* @throws {CrowdyGraphQLError} `SCOPE_MISSING` / `FORBIDDEN` (missing
|
|
72
|
+
* `update_voxel_data`), `BAD_USER_INPUT`, or `UNAUTHENTICATED`.
|
|
73
|
+
*/
|
|
74
|
+
update(input: UpdateVoxelMutationVariables['input']): Promise<UpdateVoxelMutation['updateVoxel']>;
|
|
75
|
+
/**
|
|
76
|
+
* Read entries from the immutable voxel edit history (`voxel_updates_history`)
|
|
77
|
+
* for an app, newest first, optionally filtered by user id and a changed-at
|
|
78
|
+
* time window. Read-only.
|
|
79
|
+
*
|
|
80
|
+
* @param args - Query variables:
|
|
81
|
+
* - `appId` — app whose history to read (`BigInt` decimal string).
|
|
82
|
+
* - `userId` — optional filter: only edits made by this user (decimal string).
|
|
83
|
+
* - `from` / `to` — optional inclusive changed-at time window (ISO-8601).
|
|
84
|
+
* - `limit` — **deprecated** max entries (default 500, range `1-50000`).
|
|
85
|
+
* - `offset` — **deprecated** entries to skip (default 0, range `0-1000000`).
|
|
86
|
+
* @returns The matching {@link VoxelUpdateHistoryEvent} entries, newest first.
|
|
87
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN`.
|
|
88
|
+
* @remarks The `limit`/`offset` arguments use deprecated offset pagination.
|
|
89
|
+
* For large histories prefer the Relay-style `voxelUpdateHistoryConnection(first:,
|
|
90
|
+
* after:)` query (available on the schema via `client.graphql`) — page with
|
|
91
|
+
* `first` plus the previous page's `after` cursor. See
|
|
92
|
+
* https://docs.crowdedkingdoms.com/overview/pagination.
|
|
93
|
+
*/
|
|
94
|
+
history(args: VoxelUpdateHistoryQueryVariables): Promise<VoxelUpdateHistoryQuery['voxelUpdateHistory']>;
|
|
95
|
+
/**
|
|
96
|
+
* Relay-style cursor pagination over the immutable voxel edit history — the
|
|
97
|
+
* preferred alternative to {@link history} for large histories. Page with
|
|
98
|
+
* `first` plus the previous page's `pageInfo.endCursor` as `after`; the
|
|
99
|
+
* `appId` is required and `userId`/`from`/`to` filters are optional. See
|
|
100
|
+
* https://docs.crowdedkingdoms.com/overview/pagination.
|
|
101
|
+
*
|
|
102
|
+
* @param args - `appId` plus optional `userId`/`from`/`to` filters and
|
|
103
|
+
* `first`/`after` cursor paging.
|
|
104
|
+
* @returns A {@link VoxelUpdateHistoryConnection} (`edges { cursor node }`,
|
|
105
|
+
* `pageInfo`, `totalCount`).
|
|
106
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN`.
|
|
107
|
+
*/
|
|
108
|
+
historyConnection(args: VoxelUpdateHistoryConnectionQueryVariables): Promise<VoxelUpdateHistoryConnectionQuery['voxelUpdateHistoryConnection']>;
|
|
109
|
+
/**
|
|
110
|
+
* Revert every voxel edit made by `userId` in `appId` between `from` and `to`,
|
|
111
|
+
* returning one result per affected voxel. **Defaults to a dry run**
|
|
112
|
+
* (`dryRun: true`) that only PREVIEWS the planned reversions without writing;
|
|
113
|
+
* pass `dryRun: false` to actually apply them (**destructive** — mutates world
|
|
114
|
+
* state). Privileged: requires the `manage_apps` permission on the org that
|
|
115
|
+
* owns `appId` (super admins bypass). Requires game-api ≥ v0.10.3.
|
|
116
|
+
*
|
|
117
|
+
* Pass `idempotencyKey` to make retries safe: replaying with the same key and
|
|
118
|
+
* identical input returns the first result instead of re-applying, while the
|
|
119
|
+
* same key with **different** input throws {@link CrowdyGraphQLError} with
|
|
120
|
+
* `code === 'IDEMPOTENCY_CONFLICT'`. Keys expire server-side after 24h. Unlike
|
|
121
|
+
* {@link ActorsAPI.delete}, the key is a **field on the input object**
|
|
122
|
+
* ({@link RollbackVoxelUpdatesInput}), not a separate argument.
|
|
123
|
+
*
|
|
124
|
+
* @param input - {@link RollbackVoxelUpdatesInput}: `appId`, `userId` (decimal
|
|
125
|
+
* strings), the inclusive `from`/`to` window, `dryRun` (default `true`), and
|
|
126
|
+
* an optional `idempotencyKey`.
|
|
127
|
+
* @returns One {@link RollbackVoxelEventResult} per affected voxel; each
|
|
128
|
+
* `applied` flag is `true` only when actually written (always `false` in a
|
|
129
|
+
* dry run).
|
|
130
|
+
* @throws {CrowdyGraphQLError} `IDEMPOTENCY_CONFLICT`, `SCOPE_MISSING` /
|
|
131
|
+
* `FORBIDDEN` (missing `manage_apps`), `BAD_USER_INPUT`, or
|
|
132
|
+
* `UNAUTHENTICATED`.
|
|
133
|
+
*/
|
|
134
|
+
rollback(input: RollbackVoxelUpdatesMutationVariables['input']): Promise<RollbackVoxelUpdatesMutation['rollbackVoxelUpdates']>;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=voxels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voxels.d.ts","sourceRoot":"","sources":["../../src/domains/voxels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAE7B,KAAK,+BAA+B,EACpC,KAAK,wCAAwC,EAE7C,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EAEjC,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EAErC,KAAK,iCAAiC,EACtC,KAAK,0CAA0C,EAE/C,KAAK,4BAA4B,EACjC,KAAK,qCAAqC,EAC3C,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,SAAS;IACR,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEtC;;;;;;;;;;OAUG;IACG,IAAI,CACR,KAAK,EAAE,wBAAwB,CAAC,OAAO,CAAC,GACvC,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IAKzC;;;;;;;;;;;;;;OAcG;IACG,cAAc,CAClB,KAAK,EAAE,wCAAwC,CAAC,OAAO,CAAC,GACvD,OAAO,CAAC,+BAA+B,CAAC,4BAA4B,CAAC,CAAC;IAKzE;;;;;;;;;;;;;OAaG;IACG,MAAM,CACV,KAAK,EAAE,4BAA4B,CAAC,OAAO,CAAC,GAC3C,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAK9C;;;;;;;;;;;;;;;;;;OAkBG;IACG,OAAO,CACX,IAAI,EAAE,gCAAgC,GACrC,OAAO,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;IAKzD;;;;;;;;;;;;OAYG;IACG,iBAAiB,CACrB,IAAI,EAAE,0CAA0C,GAC/C,OAAO,CAAC,iCAAiC,CAAC,8BAA8B,CAAC,CAAC;IAQ7E;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,QAAQ,CACZ,KAAK,EAAE,qCAAqC,CAAC,OAAO,CAAC,GACpD,OAAO,CAAC,4BAA4B,CAAC,sBAAsB,CAAC,CAAC;CAIjE"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { ListVoxelsDocument, ListVoxelUpdatesByDistanceDocument, UpdateVoxelDocument, VoxelUpdateHistoryDocument, VoxelUpdateHistoryConnectionDocument, RollbackVoxelUpdatesDocument, } from '../generated/graphql.js';
|
|
2
|
+
/**
|
|
3
|
+
* Voxel-edit queries and mutations for an app's world on the **game-api**: list,
|
|
4
|
+
* distance scans, history, rollback, and single-voxel writes. Exposed as
|
|
5
|
+
* `client.voxels`.
|
|
6
|
+
*
|
|
7
|
+
* A "voxel edit" is one row of the `voxel_updates` log (a {@link Voxel}): the
|
|
8
|
+
* app / chunk / local position that changed, the new voxel type, an optional
|
|
9
|
+
* base64 state blob, and who/when. A background maintenance job later folds these
|
|
10
|
+
* edits into the chunk's packed grid (see {@link ChunksAPI}). For high-frequency
|
|
11
|
+
* realtime edits prefer the UDP path (`client.udp.sendVoxelUpdate(...)`); use
|
|
12
|
+
* this API for authoritative reads, audit history, and administrative rollback.
|
|
13
|
+
*
|
|
14
|
+
* Coordinate & encoding conventions:
|
|
15
|
+
* - **Chunk coordinates** are int64 **decimal strings**; **voxel positions**
|
|
16
|
+
* (`location`) are signed 16-bit ints, `0-15` per axis for in-bounds voxels.
|
|
17
|
+
* - `appId` / `userId` are `BigInt` sent and received as decimal strings.
|
|
18
|
+
* - Voxel `state` blobs are **base64-encoded** binary.
|
|
19
|
+
*
|
|
20
|
+
* Every method requires an authenticated session (a Bearer token set via
|
|
21
|
+
* `client.auth.login()` or `client.setToken()`); an app-scoped token may only
|
|
22
|
+
* touch its own app, otherwise {@link CrowdyGraphQLError} is thrown
|
|
23
|
+
* (`UNAUTHENTICATED` / `FORBIDDEN`). {@link VoxelsAPI.update} additionally
|
|
24
|
+
* requires the `update_voxel_data` runtime permission and
|
|
25
|
+
* {@link VoxelsAPI.rollback} the `manage_apps` permission
|
|
26
|
+
* (`SCOPE_MISSING` / `FORBIDDEN`).
|
|
27
|
+
*/
|
|
28
|
+
export class VoxelsAPI {
|
|
29
|
+
constructor(gql) {
|
|
30
|
+
this.gql = gql;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* List recorded voxel edits for a single chunk, newest first (optionally only
|
|
34
|
+
* those at/after a timestamp). Read-only.
|
|
35
|
+
*
|
|
36
|
+
* @param input - {@link ListVoxelsInput}: `appId`, chunk `coordinates`, and an
|
|
37
|
+
* optional inclusive `since` lower time bound (only edits with
|
|
38
|
+
* `createdAt >= since`).
|
|
39
|
+
* @returns The matching {@link Voxel} edits, newest first (each `state` blob
|
|
40
|
+
* base64-encoded).
|
|
41
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN`.
|
|
42
|
+
*/
|
|
43
|
+
async list(input) {
|
|
44
|
+
const data = await this.gql.request(ListVoxelsDocument, { input });
|
|
45
|
+
return data.listVoxels;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* List recorded voxel edits for all chunks within a cubic (Chebyshev) radius of
|
|
49
|
+
* a center chunk, grouped per chunk and ordered by increasing distance,
|
|
50
|
+
* paginated over chunks. Read-only.
|
|
51
|
+
*
|
|
52
|
+
* @param input - {@link ListVoxelUpdatesByDistanceInput}: `appId`,
|
|
53
|
+
* `centerCoordinate`, `maxDistance` (in chunk units, integer `1-8`), optional
|
|
54
|
+
* `limit` (max **chunks**, not voxels — default 1000) / `skip` (default 0),
|
|
55
|
+
* and an optional `since` lower time bound.
|
|
56
|
+
* @returns A {@link VoxelUpdatesByDistanceResponse}: per-chunk groups of voxel
|
|
57
|
+
* edits ordered by increasing distance from `centerCoordinate`, plus an echo
|
|
58
|
+
* of the applied `limit`/`skip`.
|
|
59
|
+
* @throws {CrowdyGraphQLError} `BAD_USER_INPUT` (e.g. `maxDistance` outside
|
|
60
|
+
* `1-8`), `UNAUTHENTICATED`, or `FORBIDDEN`.
|
|
61
|
+
*/
|
|
62
|
+
async listByDistance(input) {
|
|
63
|
+
const data = await this.gql.request(ListVoxelUpdatesByDistanceDocument, { input });
|
|
64
|
+
return data.listVoxelUpdatesByDistance;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Record (upsert) a single voxel edit in the `voxel_updates` log for one chunk.
|
|
68
|
+
* **Writes world state**; a background job later folds the edit into the
|
|
69
|
+
* chunk's packed grid. Requires voxel-edit permission for the target region:
|
|
70
|
+
* active app access plus the `update_voxel_data` runtime permission (and, where
|
|
71
|
+
* grids cover the chunk, `update_voxel_data` on a covering grid).
|
|
72
|
+
*
|
|
73
|
+
* @param input - {@link UpdateVoxelInput}: `appId`, chunk `coordinates`, the
|
|
74
|
+
* local voxel `location` (`0-15` per axis), the `voxelType` to write
|
|
75
|
+
* (`0-255`), and an optional base64 `state` blob.
|
|
76
|
+
* @returns The resulting {@link Voxel}.
|
|
77
|
+
* @throws {CrowdyGraphQLError} `SCOPE_MISSING` / `FORBIDDEN` (missing
|
|
78
|
+
* `update_voxel_data`), `BAD_USER_INPUT`, or `UNAUTHENTICATED`.
|
|
79
|
+
*/
|
|
80
|
+
async update(input) {
|
|
81
|
+
const data = await this.gql.request(UpdateVoxelDocument, { input });
|
|
82
|
+
return data.updateVoxel;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Read entries from the immutable voxel edit history (`voxel_updates_history`)
|
|
86
|
+
* for an app, newest first, optionally filtered by user id and a changed-at
|
|
87
|
+
* time window. Read-only.
|
|
88
|
+
*
|
|
89
|
+
* @param args - Query variables:
|
|
90
|
+
* - `appId` — app whose history to read (`BigInt` decimal string).
|
|
91
|
+
* - `userId` — optional filter: only edits made by this user (decimal string).
|
|
92
|
+
* - `from` / `to` — optional inclusive changed-at time window (ISO-8601).
|
|
93
|
+
* - `limit` — **deprecated** max entries (default 500, range `1-50000`).
|
|
94
|
+
* - `offset` — **deprecated** entries to skip (default 0, range `0-1000000`).
|
|
95
|
+
* @returns The matching {@link VoxelUpdateHistoryEvent} entries, newest first.
|
|
96
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN`.
|
|
97
|
+
* @remarks The `limit`/`offset` arguments use deprecated offset pagination.
|
|
98
|
+
* For large histories prefer the Relay-style `voxelUpdateHistoryConnection(first:,
|
|
99
|
+
* after:)` query (available on the schema via `client.graphql`) — page with
|
|
100
|
+
* `first` plus the previous page's `after` cursor. See
|
|
101
|
+
* https://docs.crowdedkingdoms.com/overview/pagination.
|
|
102
|
+
*/
|
|
103
|
+
async history(args) {
|
|
104
|
+
const data = await this.gql.request(VoxelUpdateHistoryDocument, args);
|
|
105
|
+
return data.voxelUpdateHistory;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Relay-style cursor pagination over the immutable voxel edit history — the
|
|
109
|
+
* preferred alternative to {@link history} for large histories. Page with
|
|
110
|
+
* `first` plus the previous page's `pageInfo.endCursor` as `after`; the
|
|
111
|
+
* `appId` is required and `userId`/`from`/`to` filters are optional. See
|
|
112
|
+
* https://docs.crowdedkingdoms.com/overview/pagination.
|
|
113
|
+
*
|
|
114
|
+
* @param args - `appId` plus optional `userId`/`from`/`to` filters and
|
|
115
|
+
* `first`/`after` cursor paging.
|
|
116
|
+
* @returns A {@link VoxelUpdateHistoryConnection} (`edges { cursor node }`,
|
|
117
|
+
* `pageInfo`, `totalCount`).
|
|
118
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN`.
|
|
119
|
+
*/
|
|
120
|
+
async historyConnection(args) {
|
|
121
|
+
const data = await this.gql.request(VoxelUpdateHistoryConnectionDocument, args);
|
|
122
|
+
return data.voxelUpdateHistoryConnection;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Revert every voxel edit made by `userId` in `appId` between `from` and `to`,
|
|
126
|
+
* returning one result per affected voxel. **Defaults to a dry run**
|
|
127
|
+
* (`dryRun: true`) that only PREVIEWS the planned reversions without writing;
|
|
128
|
+
* pass `dryRun: false` to actually apply them (**destructive** — mutates world
|
|
129
|
+
* state). Privileged: requires the `manage_apps` permission on the org that
|
|
130
|
+
* owns `appId` (super admins bypass). Requires game-api ≥ v0.10.3.
|
|
131
|
+
*
|
|
132
|
+
* Pass `idempotencyKey` to make retries safe: replaying with the same key and
|
|
133
|
+
* identical input returns the first result instead of re-applying, while the
|
|
134
|
+
* same key with **different** input throws {@link CrowdyGraphQLError} with
|
|
135
|
+
* `code === 'IDEMPOTENCY_CONFLICT'`. Keys expire server-side after 24h. Unlike
|
|
136
|
+
* {@link ActorsAPI.delete}, the key is a **field on the input object**
|
|
137
|
+
* ({@link RollbackVoxelUpdatesInput}), not a separate argument.
|
|
138
|
+
*
|
|
139
|
+
* @param input - {@link RollbackVoxelUpdatesInput}: `appId`, `userId` (decimal
|
|
140
|
+
* strings), the inclusive `from`/`to` window, `dryRun` (default `true`), and
|
|
141
|
+
* an optional `idempotencyKey`.
|
|
142
|
+
* @returns One {@link RollbackVoxelEventResult} per affected voxel; each
|
|
143
|
+
* `applied` flag is `true` only when actually written (always `false` in a
|
|
144
|
+
* dry run).
|
|
145
|
+
* @throws {CrowdyGraphQLError} `IDEMPOTENCY_CONFLICT`, `SCOPE_MISSING` /
|
|
146
|
+
* `FORBIDDEN` (missing `manage_apps`), `BAD_USER_INPUT`, or
|
|
147
|
+
* `UNAUTHENTICATED`.
|
|
148
|
+
*/
|
|
149
|
+
async rollback(input) {
|
|
150
|
+
const data = await this.gql.request(RollbackVoxelUpdatesDocument, { input });
|
|
151
|
+
return data.rollbackVoxelUpdates;
|
|
152
|
+
}
|
|
153
|
+
}
|