@crowdedkingdoms/crowdyjs 7.1.1 → 8.0.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.
- package/MIGRATION.md +46 -0
- package/README.md +51 -14
- package/dist/client.d.ts +8 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -0
- package/dist/crowdy-client.d.ts +7 -0
- package/dist/crowdy-client.d.ts.map +1 -1
- package/dist/crowdy-client.js +4 -0
- package/dist/domains/auth.d.ts +77 -140
- package/dist/domains/auth.d.ts.map +1 -1
- package/dist/domains/auth.js +81 -178
- package/dist/domains/gameModel.d.ts +54 -3
- package/dist/domains/gameModel.d.ts.map +1 -1
- package/dist/domains/gameModel.js +67 -4
- package/dist/domains/host.d.ts +14 -3
- package/dist/domains/host.d.ts.map +1 -1
- package/dist/domains/host.js +17 -3
- package/dist/domains/organizations.d.ts +3 -3
- package/dist/domains/organizations.js +3 -3
- package/dist/domains/portal.d.ts +43 -1
- package/dist/domains/portal.d.ts.map +1 -1
- package/dist/domains/portal.js +59 -1
- package/dist/domains/quotas.d.ts +1 -1
- package/dist/domains/quotas.js +1 -1
- package/dist/domains/udp.d.ts +28 -17
- package/dist/domains/udp.d.ts.map +1 -1
- package/dist/domains/udp.js +28 -17
- package/dist/generated/graphql.d.ts +420 -106
- package/dist/generated/graphql.d.ts.map +1 -1
- package/dist/generated/graphql.js +6 -8
- package/dist/index.d.ts +14 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -8
- package/dist/lb-cookie-store.d.ts +20 -0
- package/dist/lb-cookie-store.d.ts.map +1 -0
- package/dist/lb-cookie-store.js +73 -0
- package/dist/realtime.d.ts +20 -5
- package/dist/realtime.d.ts.map +1 -1
- package/dist/realtime.js +38 -0
- package/dist/types.d.ts +22 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/world.d.ts +13 -8
- package/dist/world.d.ts.map +1 -1
- package/dist/world.js +13 -8
- package/package.json +6 -4
package/dist/domains/auth.js
CHANGED
|
@@ -1,207 +1,110 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* without you threading the token through by hand. Use {@link setToken} to
|
|
15
|
-
* rehydrate a saved token and {@link getToken} to read the current one. `BigInt`
|
|
16
|
-
* ids on the returned user (e.g. `userId`, `orgId`) are decimal strings.
|
|
17
|
-
*
|
|
18
|
-
* **Public — no session required:** {@link login}, {@link register},
|
|
19
|
-
* {@link confirmEmail}, {@link requestPasswordReset}, {@link resetPassword}, and
|
|
20
|
-
* {@link resendConfirmationEmail}. **Require a valid session:** {@link logout},
|
|
21
|
-
* {@link logoutAllDevices}, and {@link changePassword}, which otherwise throw
|
|
22
|
-
* {@link CrowdyGraphQLError} with `UNAUTHENTICATED` when the bearer token is
|
|
23
|
-
* missing, expired, or revoked.
|
|
24
|
-
*/
|
|
1
|
+
import { parse } from 'graphql';
|
|
2
|
+
import { LogoutAllDevicesDocument, LogoutDocument } from '../generated/graphql.js';
|
|
3
|
+
const AUTH_RESPONSE_FIELDS = 'token gameTokenId user { userId email gamertag }';
|
|
4
|
+
const IDENTITY_FIELDS = 'identityId provider subject email emailVerified createdAt lastLoginAt';
|
|
5
|
+
const RequestLoginLinkDocument = parse(`mutation RequestLoginLink($input: RequestLoginLinkInput!) { requestLoginLink(input: $input) { sent devToken } }`);
|
|
6
|
+
const CompleteLoginLinkDocument = parse(`mutation CompleteLoginLink($input: CompleteLoginLinkInput!) { completeLoginLink(input: $input) { ${AUTH_RESPONSE_FIELDS} } }`);
|
|
7
|
+
const SocialLoginStartDocument = parse(`mutation SocialLoginStart($input: SocialLoginStartInput!) { socialLoginStart(input: $input) { authorizeUrl state } }`);
|
|
8
|
+
const SocialLoginCompleteDocument = parse(`mutation SocialLoginComplete($input: SocialLoginCompleteInput!) { socialLoginComplete(input: $input) { ${AUTH_RESPONSE_FIELDS} } }`);
|
|
9
|
+
const DevLoginDocument = parse(`mutation DevLogin($input: DevLoginInput!) { devLogin(input: $input) { ${AUTH_RESPONSE_FIELDS} } }`);
|
|
10
|
+
const AvailableLoginProvidersDocument = parse(`query AvailableLoginProviders { availableLoginProviders }`);
|
|
11
|
+
const MyIdentitiesDocument = parse(`query MyIdentities { myIdentities { ${IDENTITY_FIELDS} } }`);
|
|
12
|
+
const LinkIdentityDocument = parse(`mutation LinkIdentity($input: LinkIdentityInput!) { linkIdentity(input: $input) { ${IDENTITY_FIELDS} } }`);
|
|
13
|
+
const UnlinkIdentityDocument = parse(`mutation UnlinkIdentity($identityId: String!) { unlinkIdentity(identityId: $identityId) }`);
|
|
25
14
|
export class AuthAPI {
|
|
26
15
|
constructor(graphql, session) {
|
|
27
16
|
this.graphql = graphql;
|
|
28
17
|
this.session = session;
|
|
29
18
|
}
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* On success the returned `token` is minted **and** stored on the shared
|
|
35
|
-
* session state, so subsequent calls on any sub-client (management-api or
|
|
36
|
-
* game-api) carry it automatically — no need to call {@link setToken}.
|
|
37
|
-
*
|
|
38
|
-
* @param input - Credentials ({@link LoginUserInput}): `email` and `password`
|
|
39
|
-
* (min 8 characters).
|
|
40
|
-
* @returns An {@link AuthResponse}: the opaque session `token` (sent as
|
|
41
|
-
* `Authorization: Bearer <token>`), `gameTokenId` (the session row id, a
|
|
42
|
-
* string), and the authenticated `user`.
|
|
43
|
-
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` on invalid credentials, or
|
|
44
|
-
* `BAD_USER_INPUT` on malformed input.
|
|
45
|
-
* @example
|
|
46
|
-
* ```ts
|
|
47
|
-
* const { user } = await client.auth.login({ email, password });
|
|
48
|
-
* // the session token is now stored; later calls are authenticated for you
|
|
49
|
-
* await client.users.me();
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
async login(input) {
|
|
53
|
-
const data = await this.graphql.request(LoginDocument, { input });
|
|
54
|
-
if (data.login?.token) {
|
|
55
|
-
this.session.setToken(data.login.token);
|
|
56
|
-
}
|
|
57
|
-
return data.login;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Create a new (initially unconfirmed) account, send a confirmation email, and
|
|
61
|
-
* return a session for immediate login. **Public** — no existing session
|
|
62
|
-
* required. Same token-persistence behaviour as {@link login}: the new `token`
|
|
63
|
-
* is stored on the shared session state automatically.
|
|
64
|
-
*
|
|
65
|
-
* @param input - New-account details ({@link RegisterUserInput}): `email`
|
|
66
|
-
* (where the confirmation email is sent), `password` (min 8 characters), and
|
|
67
|
-
* an optional initial `gamertag` (min 3 characters; can also be set later via
|
|
68
|
-
* `client.users.updateGamertag`).
|
|
69
|
-
* @returns An {@link AuthResponse} (session `token`, `gameTokenId`, and the new
|
|
70
|
-
* `user`).
|
|
71
|
-
* @throws {CrowdyGraphQLError} `BAD_USER_INPUT` if the email already exists or
|
|
72
|
-
* the input is invalid.
|
|
73
|
-
*/
|
|
74
|
-
async register(input) {
|
|
75
|
-
const data = await this.graphql.request(RegisterDocument, { input });
|
|
76
|
-
if (data.register?.token) {
|
|
77
|
-
this.session.setToken(data.register.token);
|
|
78
|
-
}
|
|
79
|
-
return data.register;
|
|
19
|
+
/** The federated sign-in providers currently enabled (e.g. `['google']`). */
|
|
20
|
+
async availableLoginProviders() {
|
|
21
|
+
const data = await this.graphql.request(AvailableLoginProvidersDocument);
|
|
22
|
+
return data.availableLoginProviders;
|
|
80
23
|
}
|
|
81
24
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* @returns `true` if a token was revoked, or `false` if the request carried no
|
|
88
|
-
* game token.
|
|
89
|
-
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` if the session is invalid.
|
|
25
|
+
* Passwordless: email the address a one-time magic sign-in link (creating the
|
|
26
|
+
* account on first sign-in). Always resolves `sent: true` (no enumeration). In
|
|
27
|
+
* development (`DEV_AUTH_BYPASS`) the response also carries `devToken`, the
|
|
28
|
+
* token to pass straight to {@link completeLoginLink} without an inbox.
|
|
90
29
|
*/
|
|
91
|
-
async
|
|
92
|
-
const data = await this.graphql.request(
|
|
93
|
-
|
|
94
|
-
return data.logout;
|
|
30
|
+
async requestLoginLink(input) {
|
|
31
|
+
const data = await this.graphql.request(RequestLoginLinkDocument, { input });
|
|
32
|
+
return data.requestLoginLink;
|
|
95
33
|
}
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
* @returns `true` on success.
|
|
105
|
-
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` if the session is invalid.
|
|
106
|
-
*/
|
|
107
|
-
async logoutAllDevices() {
|
|
108
|
-
const data = await this.graphql.request(LogoutAllDevicesDocument);
|
|
109
|
-
return data.logoutAllDevices;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Confirm a user's email address using the token from the confirmation email.
|
|
113
|
-
* **Public** — the token itself authorizes the call.
|
|
114
|
-
*
|
|
115
|
-
* @param token - The confirmation token from the emailed link.
|
|
116
|
-
* @returns `true` on success, or `false` if the token is invalid or expired.
|
|
117
|
-
* @throws {CrowdyGraphQLError} on transport/validation failures (invalid or
|
|
118
|
-
* expired tokens resolve to `false` rather than throwing).
|
|
119
|
-
*/
|
|
120
|
-
async confirmEmail(token) {
|
|
121
|
-
const data = await this.graphql.request(ConfirmEmailDocument, { token });
|
|
122
|
-
return data.confirmEmail;
|
|
34
|
+
/** Complete a magic-link sign-in; stores the session token on success. */
|
|
35
|
+
async completeLoginLink(token) {
|
|
36
|
+
const data = await this.graphql.request(CompleteLoginLinkDocument, {
|
|
37
|
+
input: { token },
|
|
38
|
+
});
|
|
39
|
+
if (data.completeLoginLink?.token)
|
|
40
|
+
this.session.setToken(data.completeLoginLink.token);
|
|
41
|
+
return data.completeLoginLink;
|
|
123
42
|
}
|
|
124
43
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* is confirmed, to prevent account enumeration.
|
|
128
|
-
*
|
|
129
|
-
* @param email - Email address to send the password-reset link to.
|
|
130
|
-
* @returns `true` (always, even when no such account exists).
|
|
131
|
-
* @throws {CrowdyGraphQLError} on transport/validation failures.
|
|
44
|
+
* Begin a federated (social) sign-in. Returns an `authorizeUrl` to redirect the
|
|
45
|
+
* user to and an opaque `state` to round-trip back to {@link socialLoginComplete}.
|
|
132
46
|
*/
|
|
133
|
-
async
|
|
134
|
-
const data = await this.graphql.request(
|
|
135
|
-
|
|
47
|
+
async socialLoginStart(provider, redirectUri) {
|
|
48
|
+
const data = await this.graphql.request(SocialLoginStartDocument, {
|
|
49
|
+
input: { provider, redirectUri },
|
|
136
50
|
});
|
|
137
|
-
return data.
|
|
51
|
+
return data.socialLoginStart;
|
|
138
52
|
}
|
|
139
|
-
/**
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
* **not** revoked.
|
|
143
|
-
*
|
|
144
|
-
* @param input - {@link ResetPasswordInput}: the `token` from the emailed reset
|
|
145
|
-
* link and the `newPassword` to set (min 8 characters).
|
|
146
|
-
* @returns `true` on success.
|
|
147
|
-
* @throws {CrowdyGraphQLError} `BAD_USER_INPUT` if the token is invalid or
|
|
148
|
-
* expired.
|
|
149
|
-
*/
|
|
150
|
-
async resetPassword(input) {
|
|
151
|
-
const data = await this.graphql.request(ResetPasswordDocument, {
|
|
53
|
+
/** Complete a federated sign-in from the provider callback; stores the token. */
|
|
54
|
+
async socialLoginComplete(input) {
|
|
55
|
+
const data = await this.graphql.request(SocialLoginCompleteDocument, {
|
|
152
56
|
input,
|
|
153
57
|
});
|
|
154
|
-
|
|
58
|
+
if (data.socialLoginComplete?.token)
|
|
59
|
+
this.session.setToken(data.socialLoginComplete.token);
|
|
60
|
+
return data.socialLoginComplete;
|
|
155
61
|
}
|
|
156
62
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* accounts.
|
|
161
|
-
*
|
|
162
|
-
* @param email - Email address of the account to re-send confirmation to.
|
|
163
|
-
* @returns `true` (always).
|
|
164
|
-
* @throws {CrowdyGraphQLError} on transport/validation failures.
|
|
63
|
+
* DEV ONLY bypass sign-in (active only when the server has `DEV_AUTH_BYPASS`).
|
|
64
|
+
* Returns a session for `email` without email/social verification; stores it.
|
|
65
|
+
* Throws `FORBIDDEN` when the bypass is disabled (e.g. production).
|
|
165
66
|
*/
|
|
166
|
-
async
|
|
167
|
-
const data = await this.graphql.request(
|
|
168
|
-
email,
|
|
67
|
+
async devLogin(email) {
|
|
68
|
+
const data = await this.graphql.request(DevLoginDocument, {
|
|
69
|
+
input: { email },
|
|
169
70
|
});
|
|
170
|
-
|
|
71
|
+
if (data.devLogin?.token)
|
|
72
|
+
this.session.setToken(data.devLogin.token);
|
|
73
|
+
return data.devLogin;
|
|
171
74
|
}
|
|
172
|
-
/**
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
75
|
+
/** The signed-in user's linked sign-in identities. Requires a session. */
|
|
76
|
+
async myIdentities() {
|
|
77
|
+
const data = await this.graphql.request(MyIdentitiesDocument);
|
|
78
|
+
return data.myIdentities;
|
|
79
|
+
}
|
|
80
|
+
/** Link an additional federated identity (from a social callback). */
|
|
81
|
+
async linkIdentity(input) {
|
|
82
|
+
const data = await this.graphql.request(LinkIdentityDocument, { input });
|
|
83
|
+
return data.linkIdentity;
|
|
84
|
+
}
|
|
85
|
+
/** Unlink a federated identity (cannot remove the last sign-in method). */
|
|
86
|
+
async unlinkIdentity(identityId) {
|
|
87
|
+
const data = await this.graphql.request(UnlinkIdentityDocument, {
|
|
88
|
+
identityId,
|
|
186
89
|
});
|
|
187
|
-
return data.
|
|
90
|
+
return data.unlinkIdentity;
|
|
188
91
|
}
|
|
189
|
-
/**
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
92
|
+
/** Single-device logout; clears the in-memory token on success. */
|
|
93
|
+
async logout() {
|
|
94
|
+
const data = await this.graphql.request(LogoutDocument);
|
|
95
|
+
this.session.setToken(null);
|
|
96
|
+
return data.logout;
|
|
97
|
+
}
|
|
98
|
+
/** Revoke every active session for the user. Requires a session. */
|
|
99
|
+
async logoutAllDevices() {
|
|
100
|
+
const data = await this.graphql.request(LogoutAllDevicesDocument);
|
|
101
|
+
return data.logoutAllDevices;
|
|
102
|
+
}
|
|
103
|
+
/** Imperatively set the in-memory bearer token (e.g. rehydrate). */
|
|
196
104
|
setToken(token) {
|
|
197
105
|
this.session.setToken(token);
|
|
198
106
|
}
|
|
199
|
-
/**
|
|
200
|
-
* Read the current in-memory bearer token from the shared session state. Local
|
|
201
|
-
* only — performs no network call.
|
|
202
|
-
*
|
|
203
|
-
* @returns The current bearer token, or `null` if none is set.
|
|
204
|
-
*/
|
|
107
|
+
/** Read the current in-memory bearer token. */
|
|
205
108
|
getToken() {
|
|
206
109
|
return this.session.getToken();
|
|
207
110
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GraphQLClient } from '../client.js';
|
|
2
|
-
import { type GameModelCreateSessionMutation, type GameModelCreateSessionMutationVariables, type GameModelJoinSessionMutation, type GameModelJoinSessionMutationVariables, type GameModelSetSessionTurnMutation, type GameModelSetSessionTurnMutationVariables, type GameModelCreateContainerMutation, type GameModelCreateContainerMutationVariables, type GameModelSetPropertyMutation, type GameModelSetPropertyMutationVariables, type GameModelAddEdgeMutation, type GameModelAddEdgeMutationVariables, type GameModelInvokeMutation, type GameModelInvokeMutationVariables, type GameModelContainerQuery, type GameModelContainerQueryVariables, type GameModelContainersQuery, type GameModelContainersQueryVariables, type GameModelContainerStateQuery, type GameModelContainerStateQueryVariables, type GameModelTraverseQuery, type GameModelTraverseQueryVariables, type GameModelSessionQuery, type GameModelSessionQueryVariables, type GameModelSessionsQuery, type GameModelSessionsQueryVariables, type GameModelEventsQuery, type GameModelEventsQueryVariables, type GameModelSeedMutation, type GameModelSeedMutationVariables, type GameModelUpsertContainerTypeMutation, type GameModelUpsertContainerTypeMutationVariables, type GameModelUpsertPropertyDefMutation, type GameModelUpsertPropertyDefMutationVariables, type GameModelUpsertFunctionMutation, type GameModelUpsertFunctionMutationVariables, type GameModelDeleteFunctionMutation, type GameModelDeleteFunctionMutationVariables, type GameModelDefineFeatureMutation, type GameModelDefineFeatureMutationVariables, type GameModelGrantTierFeatureMutation, type GameModelGrantTierFeatureMutationVariables, type GameModelSetPolicyMutation, type GameModelSetPolicyMutationVariables, type GameModelTypeSchemaQuery, type GameModelTypeSchemaQueryVariables, type GameModelContainerTypesQuery, type GameModelContainerTypesQueryVariables, type GameModelPropertyDefsQuery, type GameModelPropertyDefsQueryVariables, type GameModelFunctionQuery, type GameModelFunctionQueryVariables, type GameModelFunctionsQuery, type GameModelFunctionsQueryVariables, type GameModelFeaturesQuery, type GameModelFeaturesQueryVariables, type GameModelTierFeaturesQuery, type GameModelTierFeaturesQueryVariables, type GameModelPolicyQuery, type GameModelPolicyQueryVariables, type GameModelRevokeTierFeatureMutation, type GameModelRevokeTierFeatureMutationVariables, type GameModelEventsConnectionQuery, type GameModelEventsConnectionQueryVariables, type GameModelUpsertAutomationMutation, type GameModelUpsertAutomationMutationVariables, type GameModelDeleteAutomationMutation, type GameModelDeleteAutomationMutationVariables, type GameModelSetAutomationEnabledMutation, type GameModelSetAutomationEnabledMutationVariables, type GameModelUpsertAutomationTriggerMutation, type GameModelUpsertAutomationTriggerMutationVariables, type GameModelDeleteAutomationTriggerMutation, type GameModelDeleteAutomationTriggerMutationVariables, type GameModelSetAutomationPolicyMutation, type GameModelSetAutomationPolicyMutationVariables, type GameModelRunAutomationMutation, type GameModelRunAutomationMutationVariables, type GameModelAutomationsQuery, type GameModelAutomationsQueryVariables, type GameModelAutomationQuery, type GameModelAutomationQueryVariables, type GameModelAutomationTriggersQuery, type GameModelAutomationTriggersQueryVariables, type GameModelAutomationPolicyQuery, type GameModelAutomationPolicyQueryVariables, type GameModelAutomationRunsQuery, type GameModelAutomationRunsQueryVariables, type GameModelAutomationStatsQuery, type GameModelAutomationStatsQueryVariables, type GameModelAppDiagnosticsQuery, type GameModelAppDiagnosticsQueryVariables } from '../generated/graphql.js';
|
|
2
|
+
import { type GameModelCreateSessionMutation, type GameModelCreateSessionMutationVariables, type GameModelJoinSessionMutation, type GameModelJoinSessionMutationVariables, type GameModelSetSessionTurnMutation, type GameModelSetSessionTurnMutationVariables, type GameModelCreateContainerMutation, type GameModelCreateContainerMutationVariables, type GameModelDeleteContainerMutation, type GameModelDeleteContainerMutationVariables, type GameModelSetPropertyMutation, type GameModelSetPropertyMutationVariables, type GameModelAddEdgeMutation, type GameModelAddEdgeMutationVariables, type GameModelDeleteEdgeMutation, type GameModelDeleteEdgeMutationVariables, type GameModelInvokeMutation, type GameModelInvokeMutationVariables, type GameModelContainerQuery, type GameModelContainerQueryVariables, type GameModelContainersQuery, type GameModelContainersQueryVariables, type GameModelContainerStateQuery, type GameModelContainerStateQueryVariables, type GameModelTraverseQuery, type GameModelTraverseQueryVariables, type GameModelSessionQuery, type GameModelSessionQueryVariables, type GameModelSessionsQuery, type GameModelSessionsQueryVariables, type GameModelEventsQuery, type GameModelEventsQueryVariables, type GameModelSeedMutation, type GameModelSeedMutationVariables, type GameModelUpsertContainerTypeMutation, type GameModelUpsertContainerTypeMutationVariables, type GameModelUpsertPropertyDefMutation, type GameModelUpsertPropertyDefMutationVariables, type GameModelDeletePropertyDefMutation, type GameModelDeletePropertyDefMutationVariables, type GameModelDeleteContainerTypeMutation, type GameModelDeleteContainerTypeMutationVariables, type GameModelUpsertFunctionMutation, type GameModelUpsertFunctionMutationVariables, type GameModelDeleteFunctionMutation, type GameModelDeleteFunctionMutationVariables, type GameModelDefineFeatureMutation, type GameModelDefineFeatureMutationVariables, type GameModelGrantTierFeatureMutation, type GameModelGrantTierFeatureMutationVariables, type GameModelSetPolicyMutation, type GameModelSetPolicyMutationVariables, type GameModelTypeSchemaQuery, type GameModelTypeSchemaQueryVariables, type GameModelContainerTypesQuery, type GameModelContainerTypesQueryVariables, type GameModelPropertyDefsQuery, type GameModelPropertyDefsQueryVariables, type GameModelFunctionQuery, type GameModelFunctionQueryVariables, type GameModelFunctionsQuery, type GameModelFunctionsQueryVariables, type GameModelFeaturesQuery, type GameModelFeaturesQueryVariables, type GameModelTierFeaturesQuery, type GameModelTierFeaturesQueryVariables, type GameModelPolicyQuery, type GameModelPolicyQueryVariables, type GameModelRevokeTierFeatureMutation, type GameModelRevokeTierFeatureMutationVariables, type GameModelEventsConnectionQuery, type GameModelEventsConnectionQueryVariables, type GameModelUpsertAutomationMutation, type GameModelUpsertAutomationMutationVariables, type GameModelDeleteAutomationMutation, type GameModelDeleteAutomationMutationVariables, type GameModelSetAutomationEnabledMutation, type GameModelSetAutomationEnabledMutationVariables, type GameModelUpsertAutomationTriggerMutation, type GameModelUpsertAutomationTriggerMutationVariables, type GameModelDeleteAutomationTriggerMutation, type GameModelDeleteAutomationTriggerMutationVariables, type GameModelSetAutomationPolicyMutation, type GameModelSetAutomationPolicyMutationVariables, type GameModelRunAutomationMutation, type GameModelRunAutomationMutationVariables, type GameModelAutomationsQuery, type GameModelAutomationsQueryVariables, type GameModelAutomationQuery, type GameModelAutomationQueryVariables, type GameModelAutomationTriggersQuery, type GameModelAutomationTriggersQueryVariables, type GameModelAutomationPolicyQuery, type GameModelAutomationPolicyQueryVariables, type GameModelAutomationRunsQuery, type GameModelAutomationRunsQueryVariables, type GameModelAutomationStatsQuery, type GameModelAutomationStatsQueryVariables, type GameModelAppDiagnosticsQuery, type GameModelAppDiagnosticsQueryVariables } from '../generated/graphql.js';
|
|
3
3
|
/**
|
|
4
4
|
* Abstract **game-model** sub-client on the **game-api** — a schema-driven,
|
|
5
5
|
* server-authoritative layer for modelling game/world logic on top of the
|
|
@@ -52,8 +52,9 @@ import { type GameModelCreateSessionMutation, type GameModelCreateSessionMutatio
|
|
|
52
52
|
* `client.auth.login()` or `client.setToken()`) scoped to the target app, or it
|
|
53
53
|
* throws {@link CrowdyGraphQLError} (`UNAUTHENTICATED` / `SCOPE_MISSING`). The
|
|
54
54
|
* **studio-authoring** methods ({@link seed}, {@link upsertContainerType},
|
|
55
|
-
* {@link upsertPropertyDef}, {@link
|
|
56
|
-
* {@link
|
|
55
|
+
* {@link upsertPropertyDef}, {@link deletePropertyDef}, {@link upsertFunction},
|
|
56
|
+
* {@link deleteFunction}, {@link deleteContainerType}, {@link defineFeature},
|
|
57
|
+
* {@link grantTierFeature}, {@link setPolicy}) and the
|
|
57
58
|
* {@link typeSchema} query additionally require the app-admin **`manage_apps`**
|
|
58
59
|
* permission (otherwise `FORBIDDEN`, with `extensions.requiredPermission ===
|
|
59
60
|
* 'manage_apps'`); the runtime/player methods need only a valid token plus
|
|
@@ -139,6 +140,18 @@ export declare class GameModelAPI {
|
|
|
139
140
|
* unknown type, or `BAD_USER_INPUT` for malformed properties.
|
|
140
141
|
*/
|
|
141
142
|
createContainer(input: GameModelCreateContainerMutationVariables['input']): Promise<GameModelCreateContainerMutation['gameModelCreateContainer']>;
|
|
143
|
+
/**
|
|
144
|
+
* **Containers** — delete a container instance. Cascades its instance
|
|
145
|
+
* properties and any edges connected to it. Allowed for an app admin or the
|
|
146
|
+
* container owner. **Destructive.**
|
|
147
|
+
*
|
|
148
|
+
* @param variables - `{ appId, containerId }`: `appId` (decimal string) and
|
|
149
|
+
* the container UUID to delete.
|
|
150
|
+
* @returns `true` if a container was deleted, `false` if none matched.
|
|
151
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `SCOPE_MISSING`, or
|
|
152
|
+
* `FORBIDDEN` if the caller is neither an app admin nor the owner.
|
|
153
|
+
*/
|
|
154
|
+
deleteContainer(variables: GameModelDeleteContainerMutationVariables): Promise<GameModelDeleteContainerMutation['gameModelDeleteContainer']>;
|
|
142
155
|
/**
|
|
143
156
|
* **Containers** — set a single property value on a container directly (outside
|
|
144
157
|
* a function). Allowed only when the property's `writable` rule
|
|
@@ -169,6 +182,17 @@ export declare class GameModelAPI {
|
|
|
169
182
|
* `NOT_FOUND` if either container is unknown, or `BAD_USER_INPUT`.
|
|
170
183
|
*/
|
|
171
184
|
addEdge(input: GameModelAddEdgeMutationVariables['input']): Promise<GameModelAddEdgeMutation['gameModelAddEdge']>;
|
|
185
|
+
/**
|
|
186
|
+
* **Edges** — delete a directed relationship edge. Allowed for an app admin or
|
|
187
|
+
* the owner of the source (`from`) container. **Destructive.**
|
|
188
|
+
*
|
|
189
|
+
* @param variables - `{ appId, edgeId }`: `appId` (decimal string) and the
|
|
190
|
+
* edge UUID to delete.
|
|
191
|
+
* @returns `true` if an edge was deleted, `false` if none matched.
|
|
192
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `SCOPE_MISSING`, or
|
|
193
|
+
* `FORBIDDEN` if the caller may not delete the edge.
|
|
194
|
+
*/
|
|
195
|
+
deleteEdge(variables: GameModelDeleteEdgeMutationVariables): Promise<GameModelDeleteEdgeMutation['gameModelDeleteEdge']>;
|
|
172
196
|
/**
|
|
173
197
|
* **Functions** — invoke a studio-defined function against a `self` container
|
|
174
198
|
* with JSON params. This is the primary, *safe* way for players to mutate game
|
|
@@ -359,6 +383,33 @@ export declare class GameModelAPI {
|
|
|
359
383
|
* unknown container type, or `BAD_USER_INPUT`.
|
|
360
384
|
*/
|
|
361
385
|
upsertPropertyDef(input: GameModelUpsertPropertyDefMutationVariables['input']): Promise<GameModelUpsertPropertyDefMutation['gameModelUpsertPropertyDef']>;
|
|
386
|
+
/**
|
|
387
|
+
* **Property definitions** — delete a property definition from a container
|
|
388
|
+
* type. Does **not** remove instance property values already stored on
|
|
389
|
+
* containers. **Destructive.**
|
|
390
|
+
*
|
|
391
|
+
* Requires the app-admin **`manage_apps`** permission.
|
|
392
|
+
*
|
|
393
|
+
* @param variables - `{ appId, containerTypeName, key }`.
|
|
394
|
+
* @returns `true` if a definition was deleted, `false` if none matched.
|
|
395
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `SCOPE_MISSING`, or
|
|
396
|
+
* `FORBIDDEN` (`requiredPermission === 'manage_apps'`).
|
|
397
|
+
*/
|
|
398
|
+
deletePropertyDef(variables: GameModelDeletePropertyDefMutationVariables): Promise<GameModelDeletePropertyDefMutation['gameModelDeletePropertyDef']>;
|
|
399
|
+
/**
|
|
400
|
+
* **Container types** — delete a container type and its property definitions.
|
|
401
|
+
* Refuses if live containers of that type exist, or if functions are bound to
|
|
402
|
+
* it — delete those first. **Destructive.**
|
|
403
|
+
*
|
|
404
|
+
* Requires the app-admin **`manage_apps`** permission.
|
|
405
|
+
*
|
|
406
|
+
* @param variables - `{ appId, typeName }`.
|
|
407
|
+
* @returns `true` if a type was deleted, `false` if none matched.
|
|
408
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `SCOPE_MISSING`,
|
|
409
|
+
* `FORBIDDEN` (`requiredPermission === 'manage_apps'`), or `BAD_USER_INPUT`
|
|
410
|
+
* when containers or bound functions still exist.
|
|
411
|
+
*/
|
|
412
|
+
deleteContainerType(variables: GameModelDeleteContainerTypeMutationVariables): Promise<GameModelDeleteContainerTypeMutation['gameModelDeleteContainerType']>;
|
|
362
413
|
/**
|
|
363
414
|
* **Functions** — create or update a studio-defined function: a named,
|
|
364
415
|
* sandboxed behaviour with typed parameters, declared property mutations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gameModel.d.ts","sourceRoot":"","sources":["../../src/domains/gameModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAG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C5C,OAAO,CAAC,yBAAyB,CAAC,sBAAsB,CAAC,CAAC;IAK7D;;;;;;OAMG;IACG,UAAU,CACd,SAAS,EAAE,iCAAiC,GAC3C,OAAO,CAAC,wBAAwB,CAAC,qBAAqB,CAAC,CAAC;IAK3D;;;;;;OAMG;IACG,kBAAkB,CACtB,SAAS,EAAE,yCAAyC,GACnD,OAAO,CAAC,gCAAgC,CAAC,6BAA6B,CAAC,CAAC;IAK3E;;;;;;OAMG;IACG,gBAAgB,CACpB,SAAS,EAAE,uCAAuC,GACjD,OAAO,CAAC,8BAA8B,CAAC,2BAA2B,CAAC,CAAC;IAKvE;;;;;;;OAOG;IACG,cAAc,CAClB,SAAS,EAAE,qCAAqC,GAC/C,OAAO,CAAC,4BAA4B,CAAC,yBAAyB,CAAC,CAAC;IAKnE;;;;;;;;OAQG;IACG,eAAe,CACnB,SAAS,EAAE,sCAAsC,GAChD,OAAO,CAAC,6BAA6B,CAAC,0BAA0B,CAAC,CAAC;IAKrE;;;;;;;;OAQG;IACG,cAAc,CAClB,SAAS,EAAE,qCAAqC,GAC/C,OAAO,CAAC,4BAA4B,CAAC,yBAAyB,CAAC,CAAC;CAIpE"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
// Runtime (player) ops
|
|
3
|
-
GameModelCreateSessionDocument, GameModelJoinSessionDocument, GameModelSetSessionTurnDocument, GameModelCreateContainerDocument, GameModelSetPropertyDocument, GameModelAddEdgeDocument, GameModelInvokeDocument, GameModelContainerDocument, GameModelContainersDocument, GameModelContainerStateDocument, GameModelTraverseDocument, GameModelSessionDocument, GameModelSessionsDocument, GameModelEventsDocument,
|
|
3
|
+
GameModelCreateSessionDocument, GameModelJoinSessionDocument, GameModelSetSessionTurnDocument, GameModelCreateContainerDocument, GameModelDeleteContainerDocument, GameModelSetPropertyDocument, GameModelAddEdgeDocument, GameModelDeleteEdgeDocument, GameModelInvokeDocument, GameModelContainerDocument, GameModelContainersDocument, GameModelContainerStateDocument, GameModelTraverseDocument, GameModelSessionDocument, GameModelSessionsDocument, GameModelEventsDocument,
|
|
4
4
|
// Studio authoring ops
|
|
5
|
-
GameModelSeedDocument, GameModelUpsertContainerTypeDocument, GameModelUpsertPropertyDefDocument, GameModelUpsertFunctionDocument, GameModelDeleteFunctionDocument, GameModelDefineFeatureDocument, GameModelGrantTierFeatureDocument, GameModelSetPolicyDocument, GameModelTypeSchemaDocument, GameModelContainerTypesDocument, GameModelPropertyDefsDocument, GameModelFunctionDocument, GameModelFunctionsDocument, GameModelFeaturesDocument, GameModelTierFeaturesDocument, GameModelPolicyDocument, GameModelRevokeTierFeatureDocument, GameModelEventsConnectionDocument,
|
|
5
|
+
GameModelSeedDocument, GameModelUpsertContainerTypeDocument, GameModelUpsertPropertyDefDocument, GameModelDeletePropertyDefDocument, GameModelDeleteContainerTypeDocument, GameModelUpsertFunctionDocument, GameModelDeleteFunctionDocument, GameModelDefineFeatureDocument, GameModelGrantTierFeatureDocument, GameModelSetPolicyDocument, GameModelTypeSchemaDocument, GameModelContainerTypesDocument, GameModelPropertyDefsDocument, GameModelFunctionDocument, GameModelFunctionsDocument, GameModelFeaturesDocument, GameModelTierFeaturesDocument, GameModelPolicyDocument, GameModelRevokeTierFeatureDocument, GameModelEventsConnectionDocument,
|
|
6
6
|
// Automations (autonomous processes / NPCs)
|
|
7
7
|
GameModelUpsertAutomationDocument, GameModelDeleteAutomationDocument, GameModelSetAutomationEnabledDocument, GameModelUpsertAutomationTriggerDocument, GameModelDeleteAutomationTriggerDocument, GameModelSetAutomationPolicyDocument, GameModelRunAutomationDocument, GameModelAutomationsDocument, GameModelAutomationDocument, GameModelAutomationTriggersDocument, GameModelAutomationPolicyDocument, GameModelAutomationRunsDocument, GameModelAutomationStatsDocument, GameModelAppDiagnosticsDocument, } from '../generated/graphql.js';
|
|
8
8
|
/**
|
|
@@ -57,8 +57,9 @@ GameModelUpsertAutomationDocument, GameModelDeleteAutomationDocument, GameModelS
|
|
|
57
57
|
* `client.auth.login()` or `client.setToken()`) scoped to the target app, or it
|
|
58
58
|
* throws {@link CrowdyGraphQLError} (`UNAUTHENTICATED` / `SCOPE_MISSING`). The
|
|
59
59
|
* **studio-authoring** methods ({@link seed}, {@link upsertContainerType},
|
|
60
|
-
* {@link upsertPropertyDef}, {@link
|
|
61
|
-
* {@link
|
|
60
|
+
* {@link upsertPropertyDef}, {@link deletePropertyDef}, {@link upsertFunction},
|
|
61
|
+
* {@link deleteFunction}, {@link deleteContainerType}, {@link defineFeature},
|
|
62
|
+
* {@link grantTierFeature}, {@link setPolicy}) and the
|
|
62
63
|
* {@link typeSchema} query additionally require the app-admin **`manage_apps`**
|
|
63
64
|
* permission (otherwise `FORBIDDEN`, with `extensions.requiredPermission ===
|
|
64
65
|
* 'manage_apps'`); the runtime/player methods need only a valid token plus
|
|
@@ -158,6 +159,21 @@ export class GameModelAPI {
|
|
|
158
159
|
const data = await this.gql.request(GameModelCreateContainerDocument, { input });
|
|
159
160
|
return data.gameModelCreateContainer;
|
|
160
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* **Containers** — delete a container instance. Cascades its instance
|
|
164
|
+
* properties and any edges connected to it. Allowed for an app admin or the
|
|
165
|
+
* container owner. **Destructive.**
|
|
166
|
+
*
|
|
167
|
+
* @param variables - `{ appId, containerId }`: `appId` (decimal string) and
|
|
168
|
+
* the container UUID to delete.
|
|
169
|
+
* @returns `true` if a container was deleted, `false` if none matched.
|
|
170
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `SCOPE_MISSING`, or
|
|
171
|
+
* `FORBIDDEN` if the caller is neither an app admin nor the owner.
|
|
172
|
+
*/
|
|
173
|
+
async deleteContainer(variables) {
|
|
174
|
+
const data = await this.gql.request(GameModelDeleteContainerDocument, variables);
|
|
175
|
+
return data.gameModelDeleteContainer;
|
|
176
|
+
}
|
|
161
177
|
/**
|
|
162
178
|
* **Containers** — set a single property value on a container directly (outside
|
|
163
179
|
* a function). Allowed only when the property's `writable` rule
|
|
@@ -194,6 +210,20 @@ export class GameModelAPI {
|
|
|
194
210
|
const data = await this.gql.request(GameModelAddEdgeDocument, { input });
|
|
195
211
|
return data.gameModelAddEdge;
|
|
196
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* **Edges** — delete a directed relationship edge. Allowed for an app admin or
|
|
215
|
+
* the owner of the source (`from`) container. **Destructive.**
|
|
216
|
+
*
|
|
217
|
+
* @param variables - `{ appId, edgeId }`: `appId` (decimal string) and the
|
|
218
|
+
* edge UUID to delete.
|
|
219
|
+
* @returns `true` if an edge was deleted, `false` if none matched.
|
|
220
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `SCOPE_MISSING`, or
|
|
221
|
+
* `FORBIDDEN` if the caller may not delete the edge.
|
|
222
|
+
*/
|
|
223
|
+
async deleteEdge(variables) {
|
|
224
|
+
const data = await this.gql.request(GameModelDeleteEdgeDocument, variables);
|
|
225
|
+
return data.gameModelDeleteEdge;
|
|
226
|
+
}
|
|
197
227
|
/**
|
|
198
228
|
* **Functions** — invoke a studio-defined function against a `self` container
|
|
199
229
|
* with JSON params. This is the primary, *safe* way for players to mutate game
|
|
@@ -421,6 +451,39 @@ export class GameModelAPI {
|
|
|
421
451
|
const data = await this.gql.request(GameModelUpsertPropertyDefDocument, { input });
|
|
422
452
|
return data.gameModelUpsertPropertyDef;
|
|
423
453
|
}
|
|
454
|
+
/**
|
|
455
|
+
* **Property definitions** — delete a property definition from a container
|
|
456
|
+
* type. Does **not** remove instance property values already stored on
|
|
457
|
+
* containers. **Destructive.**
|
|
458
|
+
*
|
|
459
|
+
* Requires the app-admin **`manage_apps`** permission.
|
|
460
|
+
*
|
|
461
|
+
* @param variables - `{ appId, containerTypeName, key }`.
|
|
462
|
+
* @returns `true` if a definition was deleted, `false` if none matched.
|
|
463
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `SCOPE_MISSING`, or
|
|
464
|
+
* `FORBIDDEN` (`requiredPermission === 'manage_apps'`).
|
|
465
|
+
*/
|
|
466
|
+
async deletePropertyDef(variables) {
|
|
467
|
+
const data = await this.gql.request(GameModelDeletePropertyDefDocument, variables);
|
|
468
|
+
return data.gameModelDeletePropertyDef;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* **Container types** — delete a container type and its property definitions.
|
|
472
|
+
* Refuses if live containers of that type exist, or if functions are bound to
|
|
473
|
+
* it — delete those first. **Destructive.**
|
|
474
|
+
*
|
|
475
|
+
* Requires the app-admin **`manage_apps`** permission.
|
|
476
|
+
*
|
|
477
|
+
* @param variables - `{ appId, typeName }`.
|
|
478
|
+
* @returns `true` if a type was deleted, `false` if none matched.
|
|
479
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `SCOPE_MISSING`,
|
|
480
|
+
* `FORBIDDEN` (`requiredPermission === 'manage_apps'`), or `BAD_USER_INPUT`
|
|
481
|
+
* when containers or bound functions still exist.
|
|
482
|
+
*/
|
|
483
|
+
async deleteContainerType(variables) {
|
|
484
|
+
const data = await this.gql.request(GameModelDeleteContainerTypeDocument, variables);
|
|
485
|
+
return data.gameModelDeleteContainerType;
|
|
486
|
+
}
|
|
424
487
|
/**
|
|
425
488
|
* **Functions** — create or update a studio-defined function: a named,
|
|
426
489
|
* sandboxed behaviour with typed parameters, declared property mutations
|
package/dist/domains/host.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GraphQLClient } from '../client.js';
|
|
2
|
-
import { type GameHostQuery, type ActorHeartbeatMutation } from '../generated/graphql.js';
|
|
2
|
+
import { type GameHostQuery, type AmIGameHostQuery, type ActorHeartbeatMutation } from '../generated/graphql.js';
|
|
3
3
|
/**
|
|
4
4
|
* Game-host election + actor liveness heartbeat — exposed as `client.host`.
|
|
5
5
|
*
|
|
@@ -7,8 +7,10 @@ import { type GameHostQuery, type ActorHeartbeatMutation } from '../generated/gr
|
|
|
7
7
|
* game-api replicas (the user whose earliest still-connected actor was created
|
|
8
8
|
* first wins). {@link heartbeat} refreshes the caller's actor freshness (keeping
|
|
9
9
|
* them host-eligible) and returns the freshly-elected host in one round-trip —
|
|
10
|
-
* call it on an interval shorter than the server's freshness window.
|
|
11
|
-
*
|
|
10
|
+
* call it on an interval shorter than the server's freshness window.
|
|
11
|
+
* {@link amIHost} is a UI convenience (not authoritative for mutations — use
|
|
12
|
+
* `gameModelInvoke`'s `is_host` policy for that). All require a valid session;
|
|
13
|
+
* `appId` is a `BigInt` decimal string.
|
|
12
14
|
*
|
|
13
15
|
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` without a session.
|
|
14
16
|
*/
|
|
@@ -23,6 +25,15 @@ export declare class HostAPI {
|
|
|
23
25
|
* @returns The elected {@link GameHost}, or `null`.
|
|
24
26
|
*/
|
|
25
27
|
get(appId: string): Promise<GameHostQuery['gameHost']>;
|
|
28
|
+
/**
|
|
29
|
+
* Return whether the authenticated caller is the currently elected host for
|
|
30
|
+
* the app. Convenience for UI only — not authoritative for server mutations
|
|
31
|
+
* (use `gameModelInvoke`'s `is_host` policy for that).
|
|
32
|
+
*
|
|
33
|
+
* @param appId - The app to check host election for.
|
|
34
|
+
* @returns `true` if the caller is the elected host; otherwise `false`.
|
|
35
|
+
*/
|
|
36
|
+
amIHost(appId: string): Promise<AmIGameHostQuery['amIGameHost']>;
|
|
26
37
|
/**
|
|
27
38
|
* Refresh the caller's actor freshness in an app and return the freshly
|
|
28
39
|
* elected host. Returns `null` when no fresh actors exist for the app.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/domains/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/domains/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC5B,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;GAaG;AACH,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,aAAa;IAEnD;;;;;;OAMG;IACG,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAK5D;;;;;;;OAOG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAKtE;;;;;;OAMG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;CAIlF"}
|
package/dist/domains/host.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GameHostDocument, ActorHeartbeatDocument, } from '../generated/graphql.js';
|
|
1
|
+
import { GameHostDocument, AmIGameHostDocument, ActorHeartbeatDocument, } from '../generated/graphql.js';
|
|
2
2
|
/**
|
|
3
3
|
* Game-host election + actor liveness heartbeat — exposed as `client.host`.
|
|
4
4
|
*
|
|
@@ -6,8 +6,10 @@ import { GameHostDocument, ActorHeartbeatDocument, } from '../generated/graphql.
|
|
|
6
6
|
* game-api replicas (the user whose earliest still-connected actor was created
|
|
7
7
|
* first wins). {@link heartbeat} refreshes the caller's actor freshness (keeping
|
|
8
8
|
* them host-eligible) and returns the freshly-elected host in one round-trip —
|
|
9
|
-
* call it on an interval shorter than the server's freshness window.
|
|
10
|
-
*
|
|
9
|
+
* call it on an interval shorter than the server's freshness window.
|
|
10
|
+
* {@link amIHost} is a UI convenience (not authoritative for mutations — use
|
|
11
|
+
* `gameModelInvoke`'s `is_host` policy for that). All require a valid session;
|
|
12
|
+
* `appId` is a `BigInt` decimal string.
|
|
11
13
|
*
|
|
12
14
|
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` without a session.
|
|
13
15
|
*/
|
|
@@ -26,6 +28,18 @@ export class HostAPI {
|
|
|
26
28
|
const data = await this.graphql.request(GameHostDocument, { appId });
|
|
27
29
|
return data.gameHost;
|
|
28
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Return whether the authenticated caller is the currently elected host for
|
|
33
|
+
* the app. Convenience for UI only — not authoritative for server mutations
|
|
34
|
+
* (use `gameModelInvoke`'s `is_host` policy for that).
|
|
35
|
+
*
|
|
36
|
+
* @param appId - The app to check host election for.
|
|
37
|
+
* @returns `true` if the caller is the elected host; otherwise `false`.
|
|
38
|
+
*/
|
|
39
|
+
async amIHost(appId) {
|
|
40
|
+
const data = await this.graphql.request(AmIGameHostDocument, { appId });
|
|
41
|
+
return data.amIGameHost;
|
|
42
|
+
}
|
|
29
43
|
/**
|
|
30
44
|
* Refresh the caller's actor freshness in an app and return the freshly
|
|
31
45
|
* elected host. Returns `null` when no fresh actors exist for the app.
|