@crowdedkingdomstudios/crowdyjs 3.0.0 → 4.3.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/README.md +125 -57
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -1
- package/dist/crowdy-client.d.ts +49 -13
- package/dist/crowdy-client.d.ts.map +1 -1
- package/dist/crowdy-client.js +47 -16
- package/dist/domains/apps.d.ts +59 -20
- package/dist/domains/apps.d.ts.map +1 -1
- package/dist/domains/apps.js +61 -35
- package/dist/domains/auth.d.ts +33 -22
- package/dist/domains/auth.d.ts.map +1 -1
- package/dist/domains/auth.js +51 -33
- package/dist/domains/channels.d.ts +34 -0
- package/dist/domains/channels.d.ts.map +1 -0
- package/dist/domains/channels.js +94 -0
- package/dist/domains/gameModel.d.ts +40 -0
- package/dist/domains/gameModel.d.ts.map +1 -0
- package/dist/domains/gameModel.js +114 -0
- package/dist/domains/platform.d.ts +33 -0
- package/dist/domains/platform.d.ts.map +1 -0
- package/dist/domains/platform.js +39 -0
- package/dist/domains/udp.d.ts +17 -1
- package/dist/domains/udp.d.ts.map +1 -1
- package/dist/domains/udp.js +25 -1
- package/dist/domains/users.d.ts +19 -16
- package/dist/domains/users.d.ts.map +1 -1
- package/dist/domains/users.js +21 -39
- package/dist/generated/graphql.d.ts +2912 -63
- package/dist/generated/graphql.d.ts.map +1 -1
- package/dist/generated/graphql.js +82 -10
- package/dist/index.d.ts +32 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -15
- package/dist/realtime.d.ts +6 -0
- package/dist/realtime.d.ts.map +1 -1
- package/dist/realtime.js +6 -0
- package/dist/types.d.ts +2 -31
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +5 -33
- package/dist/world.d.ts +9 -0
- package/dist/world.d.ts.map +1 -1
- package/dist/world.js +17 -0
- package/package.json +2 -2
- package/dist/domains/appAccess.d.ts +0 -23
- package/dist/domains/appAccess.d.ts.map +0 -1
- package/dist/domains/appAccess.js +0 -42
- package/dist/domains/billing.d.ts +0 -17
- package/dist/domains/billing.d.ts.map +0 -1
- package/dist/domains/billing.js +0 -31
- package/dist/domains/organizations.d.ts +0 -33
- package/dist/domains/organizations.d.ts.map +0 -1
- package/dist/domains/organizations.js +0 -90
- package/dist/domains/payments.d.ts +0 -20
- package/dist/domains/payments.d.ts.map +0 -1
- package/dist/domains/payments.js +0 -28
- package/dist/domains/quotas.d.ts +0 -20
- package/dist/domains/quotas.d.ts.map +0 -1
- package/dist/domains/quotas.js +0 -34
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform discovery sub-client. Targets `cks-management-api`. Lets a client
|
|
3
|
+
* find the shared game-api URL (for apps published to the shared environment)
|
|
4
|
+
* BEFORE it has a per-app endpoint, then build a game-api `CrowdyClient`
|
|
5
|
+
* against it.
|
|
6
|
+
*
|
|
7
|
+
* Typical pattern:
|
|
8
|
+
*
|
|
9
|
+
* const base = createCrowdyClient({ managementUrl: 'https://api.example.com' });
|
|
10
|
+
* const cfg = await base.platform.config();
|
|
11
|
+
* const gameClient = createCrowdyClient({
|
|
12
|
+
* managementUrl: 'https://api.example.com',
|
|
13
|
+
* httpUrl: cfg.sharedGameApiUrl ?? undefined,
|
|
14
|
+
* wsUrl: cfg.sharedGameApiWsUrl ?? undefined,
|
|
15
|
+
* tokenStore: base.session.tokenStore,
|
|
16
|
+
* });
|
|
17
|
+
*/
|
|
18
|
+
import type { GraphQLClient } from '../client.js';
|
|
19
|
+
export interface PlatformConfig {
|
|
20
|
+
/** Shared game-api HTTP/GraphQL root for shared-environment apps. */
|
|
21
|
+
sharedGameApiUrl: string | null;
|
|
22
|
+
/** Shared game-api WebSocket root (subscriptions / UDP proxy). */
|
|
23
|
+
sharedGameApiWsUrl: string | null;
|
|
24
|
+
/** Free shared app slots an org gets before a paid subscription. */
|
|
25
|
+
freeAppsPerOrg: number;
|
|
26
|
+
}
|
|
27
|
+
export declare class PlatformAPI {
|
|
28
|
+
private readonly management;
|
|
29
|
+
constructor(management: GraphQLClient);
|
|
30
|
+
/** Fetch public platform discovery (shared game-api URL, free app quota). */
|
|
31
|
+
config(): Promise<PlatformConfig>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/domains/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,qEAAqE;IACrE,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,kEAAkE;IAClE,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,oEAAoE;IACpE,cAAc,EAAE,MAAM,CAAC;CACxB;AAiBD,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,aAAa;IAEtD,6EAA6E;IACvE,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC;CAIxC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform discovery sub-client. Targets `cks-management-api`. Lets a client
|
|
3
|
+
* find the shared game-api URL (for apps published to the shared environment)
|
|
4
|
+
* BEFORE it has a per-app endpoint, then build a game-api `CrowdyClient`
|
|
5
|
+
* against it.
|
|
6
|
+
*
|
|
7
|
+
* Typical pattern:
|
|
8
|
+
*
|
|
9
|
+
* const base = createCrowdyClient({ managementUrl: 'https://api.example.com' });
|
|
10
|
+
* const cfg = await base.platform.config();
|
|
11
|
+
* const gameClient = createCrowdyClient({
|
|
12
|
+
* managementUrl: 'https://api.example.com',
|
|
13
|
+
* httpUrl: cfg.sharedGameApiUrl ?? undefined,
|
|
14
|
+
* wsUrl: cfg.sharedGameApiWsUrl ?? undefined,
|
|
15
|
+
* tokenStore: base.session.tokenStore,
|
|
16
|
+
* });
|
|
17
|
+
*/
|
|
18
|
+
import { parse } from 'graphql';
|
|
19
|
+
// Hand-written document so the SDK can discover the shared game-api URL even
|
|
20
|
+
// before codegen picks up the new schema (see src/operations/platform/).
|
|
21
|
+
const PlatformConfigDocument = parse(/* GraphQL */ `
|
|
22
|
+
query PlatformConfig {
|
|
23
|
+
platformConfig {
|
|
24
|
+
sharedGameApiUrl
|
|
25
|
+
sharedGameApiWsUrl
|
|
26
|
+
freeAppsPerOrg
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`);
|
|
30
|
+
export class PlatformAPI {
|
|
31
|
+
constructor(management) {
|
|
32
|
+
this.management = management;
|
|
33
|
+
}
|
|
34
|
+
/** Fetch public platform discovery (shared game-api URL, free app quota). */
|
|
35
|
+
async config() {
|
|
36
|
+
const data = await this.management.request(PlatformConfigDocument, {});
|
|
37
|
+
return data.platformConfig;
|
|
38
|
+
}
|
|
39
|
+
}
|
package/dist/domains/udp.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GraphQLClient } from '../client.js';
|
|
2
2
|
import type { SubscriptionManager, UdpNotificationHandlers } from '../subscriptions.js';
|
|
3
|
-
import { type ConnectUdpProxyMutation, type UdpProxyConnectionStatusQuery, type SendActorUpdateMutationVariables, type SendVoxelUpdateMutationVariables, type SendAudioPacketMutationVariables, type SendTextPacketMutationVariables, type SendClientEventMutationVariables } from '../generated/graphql.js';
|
|
3
|
+
import { type ConnectUdpProxyMutation, type UdpProxyConnectionStatusQuery, type SendActorUpdateMutationVariables, type SendVoxelUpdateMutationVariables, type SendAudioPacketMutationVariables, type SendTextPacketMutationVariables, type SendClientEventMutationVariables, type SendSingleActorMessageMutationVariables, type SendChannelMessageMutationVariables } from '../generated/graphql.js';
|
|
4
4
|
import type { SpatialNotification } from '../realtime.js';
|
|
5
5
|
/**
|
|
6
6
|
* UDP proxy access for browser-style clients that can't open raw UDP
|
|
@@ -37,6 +37,22 @@ export declare class UdpAPI {
|
|
|
37
37
|
sendClientEventAndWait(input: SendClientEventMutationVariables['input'], options?: {
|
|
38
38
|
timeoutMs?: number;
|
|
39
39
|
}): Promise<SpatialNotification>;
|
|
40
|
+
/**
|
|
41
|
+
* Send a direct actor-to-actor message, delivered only to the actor whose
|
|
42
|
+
* UUID matches `input.targetUuid` (the sender must know that actor's chunk).
|
|
43
|
+
* Fire-and-forget: the sender receives no echo, so there is no
|
|
44
|
+
* `sendSingleActorMessageAndWait` variant. The target receives a
|
|
45
|
+
* `SingleActorMessageNotification` on its `udpNotifications` subscription.
|
|
46
|
+
*/
|
|
47
|
+
sendSingleActorMessage(input: SendSingleActorMessageMutationVariables['input']): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Publish a message to a channel. Delivered to every active member of the
|
|
50
|
+
* channel (regardless of location) as a `ChannelMessageNotification` on their
|
|
51
|
+
* `udpNotifications` subscription. Requires the channel `send_messages`
|
|
52
|
+
* permission; the server drops the message otherwise. Fire-and-forget: the
|
|
53
|
+
* sender receives no echo.
|
|
54
|
+
*/
|
|
55
|
+
sendChannelMessage(input: SendChannelMessageMutationVariables['input']): Promise<boolean>;
|
|
40
56
|
/**
|
|
41
57
|
* Subscribe to udpNotifications. Pass any combination of typename
|
|
42
58
|
* handlers; the returned function detaches all of them. The first
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"udp.d.ts","sourceRoot":"","sources":["../../src/domains/udp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAEL,KAAK,uBAAuB,EAG5B,KAAK,6BAA6B,EAElC,KAAK,gCAAgC,EAErC,KAAK,gCAAgC,EAErC,KAAK,gCAAgC,EAErC,KAAK,+BAA+B,EAEpC,KAAK,gCAAgC,
|
|
1
|
+
{"version":3,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ument, UdpProxyConnectionStatusDocument, SendActorUpdateDocument, SendVoxelUpdateDocument, SendAudioPacketDocument, SendTextPacketDocument, SendClientEventDocument, } from '../generated/graphql.js';
|
|
1
|
+
import { ConnectUdpProxyDocument, DisconnectUdpProxyDocument, UdpProxyConnectionStatusDocument, SendActorUpdateDocument, SendVoxelUpdateDocument, SendAudioPacketDocument, SendTextPacketDocument, SendClientEventDocument, SendSingleActorMessageDocument, SendChannelMessageDocument, } from '../generated/graphql.js';
|
|
2
2
|
import { SequenceAllocator } from '../utils.js';
|
|
3
3
|
/**
|
|
4
4
|
* UDP proxy access for browser-style clients that can't open raw UDP
|
|
@@ -75,6 +75,30 @@ export class UdpAPI {
|
|
|
75
75
|
await this.sendClientEvent(request);
|
|
76
76
|
return wait;
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Send a direct actor-to-actor message, delivered only to the actor whose
|
|
80
|
+
* UUID matches `input.targetUuid` (the sender must know that actor's chunk).
|
|
81
|
+
* Fire-and-forget: the sender receives no echo, so there is no
|
|
82
|
+
* `sendSingleActorMessageAndWait` variant. The target receives a
|
|
83
|
+
* `SingleActorMessageNotification` on its `udpNotifications` subscription.
|
|
84
|
+
*/
|
|
85
|
+
async sendSingleActorMessage(input) {
|
|
86
|
+
const data = await this.gql.request(SendSingleActorMessageDocument, {
|
|
87
|
+
input,
|
|
88
|
+
});
|
|
89
|
+
return data.sendSingleActorMessage;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Publish a message to a channel. Delivered to every active member of the
|
|
93
|
+
* channel (regardless of location) as a `ChannelMessageNotification` on their
|
|
94
|
+
* `udpNotifications` subscription. Requires the channel `send_messages`
|
|
95
|
+
* permission; the server drops the message otherwise. Fire-and-forget: the
|
|
96
|
+
* sender receives no echo.
|
|
97
|
+
*/
|
|
98
|
+
async sendChannelMessage(input) {
|
|
99
|
+
const data = await this.gql.request(SendChannelMessageDocument, { input });
|
|
100
|
+
return data.sendChannelMessage;
|
|
101
|
+
}
|
|
78
102
|
/**
|
|
79
103
|
* Subscribe to udpNotifications. Pass any combination of typename
|
|
80
104
|
* handlers; the returned function detaches all of them. The first
|
package/dist/domains/users.d.ts
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import type { GraphQLClient } from '../client.js';
|
|
2
|
-
import { type MeQuery, type UserQuery, type UserQueryVariables, type UsersPaginatedQuery, type UsersPaginatedQueryVariables, type UpdateGamertagMutation, type UpdateGamertagMutationVariables, type UpdateUserStateMutation, type UpdateUserStateMutationVariables, type SetSuperAdminMutation, type SetSuperAdminMutationVariables, type SetEarlyAccessOverrideMutation, type SetEarlyAccessOverrideMutationVariables, type UpdateUserTypeMutation, type UpdateUserTypeMutationVariables, type ForceLogoutUserMutationVariables } from '../generated/graphql.js';
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
2
|
+
* Users sub-client. Targets `cks-management-api` — game-api never exposes
|
|
3
|
+
* identity mutations after the split.
|
|
5
4
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Only the read/identity surface that game clients realistically need is
|
|
6
|
+
* here. Super-admin / operator screens use cks-management-ui (Apollo)
|
|
7
|
+
* directly rather than the SDK.
|
|
9
8
|
*/
|
|
9
|
+
import type { GraphQLClient } from '../client.js';
|
|
10
|
+
import { type MeQuery, type UpdateGamertagInput, type UpdateGamertagMutation } from '../generated/graphql.js';
|
|
10
11
|
export declare class UsersAPI {
|
|
11
|
-
private
|
|
12
|
-
constructor(
|
|
12
|
+
private readonly graphql;
|
|
13
|
+
constructor(graphql: GraphQLClient);
|
|
14
|
+
/**
|
|
15
|
+
* Validate the current Bearer token and return the user record. Returns
|
|
16
|
+
* null if the token is expired/revoked. Use this for session restore on
|
|
17
|
+
* SDK init.
|
|
18
|
+
*/
|
|
13
19
|
me(): Promise<MeQuery['me']>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
setEarlyAccessOverride(args: SetEarlyAccessOverrideMutationVariables): Promise<SetEarlyAccessOverrideMutation['setEarlyAccessOverride']>;
|
|
20
|
-
updateUserType(args: UpdateUserTypeMutationVariables): Promise<UpdateUserTypeMutation['updateUserType']>;
|
|
21
|
-
forceLogoutUser(userId: ForceLogoutUserMutationVariables['userId']): Promise<boolean>;
|
|
20
|
+
updateGamertag(input: UpdateGamertagInput): Promise<UpdateGamertagMutation['updateGamertag']>;
|
|
21
|
+
/**
|
|
22
|
+
* Soft-deletes the current user's account: anonymizes PII and revokes
|
|
23
|
+
* sessions. Wallet / donation history stays intact via FK.
|
|
24
|
+
*/
|
|
22
25
|
deleteMyAccount(): Promise<boolean>;
|
|
23
26
|
}
|
|
24
27
|
//# sourceMappingURL=users.d.ts.map
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/domains/users.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC5B,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,aAAa;IAEnD;;;;OAIG;IACG,EAAE,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAK5B,cAAc,CAClB,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;IAKpD;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;CAI1C"}
|
package/dist/domains/users.js
CHANGED
|
@@ -1,53 +1,35 @@
|
|
|
1
|
-
import { MeDocument, UserDocument, UsersPaginatedDocument, UpdateGamertagDocument, UpdateUserStateDocument, SetSuperAdminDocument, SetEarlyAccessOverrideDocument, UpdateUserTypeDocument, ForceLogoutUserDocument, DeleteMyAccountDocument, } from '../generated/graphql.js';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* Users sub-client. Targets `cks-management-api` — game-api never exposes
|
|
3
|
+
* identity mutations after the split.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Only the read/identity surface that game clients realistically need is
|
|
6
|
+
* here. Super-admin / operator screens use cks-management-ui (Apollo)
|
|
7
|
+
* directly rather than the SDK.
|
|
8
8
|
*/
|
|
9
|
+
import { MeDocument, UpdateGamertagDocument, DeleteMyAccountDocument, } from '../generated/graphql.js';
|
|
9
10
|
export class UsersAPI {
|
|
10
|
-
constructor(
|
|
11
|
-
this.
|
|
12
|
-
}
|
|
11
|
+
constructor(graphql) {
|
|
12
|
+
this.graphql = graphql;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Validate the current Bearer token and return the user record. Returns
|
|
16
|
+
* null if the token is expired/revoked. Use this for session restore on
|
|
17
|
+
* SDK init.
|
|
18
|
+
*/
|
|
13
19
|
async me() {
|
|
14
|
-
const data = await this.
|
|
20
|
+
const data = await this.graphql.request(MeDocument);
|
|
15
21
|
return data.me;
|
|
16
22
|
}
|
|
17
|
-
async byId(id) {
|
|
18
|
-
const data = await this.gql.request(UserDocument, { id });
|
|
19
|
-
return data.user;
|
|
20
|
-
}
|
|
21
|
-
async searchPaginated(args = {}) {
|
|
22
|
-
const data = await this.gql.request(UsersPaginatedDocument, args);
|
|
23
|
-
return data.usersPaginated;
|
|
24
|
-
}
|
|
25
23
|
async updateGamertag(input) {
|
|
26
|
-
const data = await this.
|
|
24
|
+
const data = await this.graphql.request(UpdateGamertagDocument, { input });
|
|
27
25
|
return data.updateGamertag;
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
async setSuperAdmin(args) {
|
|
34
|
-
const data = await this.gql.request(SetSuperAdminDocument, args);
|
|
35
|
-
return data.setSuperAdmin;
|
|
36
|
-
}
|
|
37
|
-
async setEarlyAccessOverride(args) {
|
|
38
|
-
const data = await this.gql.request(SetEarlyAccessOverrideDocument, args);
|
|
39
|
-
return data.setEarlyAccessOverride;
|
|
40
|
-
}
|
|
41
|
-
async updateUserType(args) {
|
|
42
|
-
const data = await this.gql.request(UpdateUserTypeDocument, args);
|
|
43
|
-
return data.updateUserType;
|
|
44
|
-
}
|
|
45
|
-
async forceLogoutUser(userId) {
|
|
46
|
-
const data = await this.gql.request(ForceLogoutUserDocument, { userId });
|
|
47
|
-
return data.forceLogoutUser;
|
|
48
|
-
}
|
|
27
|
+
/**
|
|
28
|
+
* Soft-deletes the current user's account: anonymizes PII and revokes
|
|
29
|
+
* sessions. Wallet / donation history stays intact via FK.
|
|
30
|
+
*/
|
|
49
31
|
async deleteMyAccount() {
|
|
50
|
-
const data = await this.
|
|
32
|
+
const data = await this.graphql.request(DeleteMyAccountDocument);
|
|
51
33
|
return data.deleteMyAccount;
|
|
52
34
|
}
|
|
53
35
|
}
|