@crowdedkingdomstudios/crowdyjs 5.0.0 → 5.1.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/MIGRATION.md CHANGED
@@ -1,3 +1,34 @@
1
+ # CrowdyJS v5.1 Notes
2
+
3
+ v5.1 is additive and non-breaking.
4
+
5
+ ## Added
6
+
7
+ - **`client.teams`** — the Teams API is now a first-class sub-client, mirroring
8
+ `client.channels`. Create / update / delete teams, manage membership and
9
+ roles, set the per-app team policy, and read `mine` (`myTeams`), `list`
10
+ (`teams`), `get`, `members`, `roles`, and `policy`. Teams are app-scoped
11
+ player groups with roles and delegated management (no realtime messaging
12
+ path — that is Channels).
13
+
14
+ ```ts
15
+ const team = await client.teams.create({ appId: '1', name: 'Red Squad' });
16
+ await client.teams.join(team.groupId);
17
+ const mine = await client.teams.mine('1');
18
+ ```
19
+
20
+ ## Removed
21
+
22
+ - The `gameModelEventStream` GraphQL subscription has been removed from the Game
23
+ API and the bundled schema. It was never wrapped by a CrowdyJS method, so no
24
+ SDK call sites change. To react to game-model changes, have the mutating
25
+ client send a lightweight notification over the realtime UDP path — a channel
26
+ message (`client.udp.sendChannelMessage`, recommended) or a spatial client
27
+ event (`client.udp.sendClientEvent`) — and have peers re-pull authoritative
28
+ state via `client.gameModel.containerState(...)` / `client.gameModel.events(...)`.
29
+
30
+ ---
31
+
1
32
  # CrowdyJS v5 Migration Notes
2
33
 
3
34
  CrowdyJS v5 makes the realtime subscription **app-scoped** to fix a cross-app
package/README.md CHANGED
@@ -65,7 +65,7 @@ Auth and user reads always target `managementUrl`. Everything else targets `http
65
65
  ## Game-loop lifecycle
66
66
 
67
67
  1. Authenticate with `client.auth.login()` or restore a previous token through `client.session.restore()`.
68
- 2. Subscribe to UDP proxy notifications with `client.udp.subscribe()` (the SDK will open the realtime socket on demand).
68
+ 2. Subscribe to UDP proxy notifications with `client.udp.subscribe(handlers, appId)` — `appId` is **required** (the SDK opens the realtime socket on demand and scopes it to that app).
69
69
  3. Join a chunk by sending an initial actor update.
70
70
  4. Send actor, voxel, text, audio, and client-event updates through `client.udp` or the higher-level `client.world(appId)` helpers.
71
71
  5. Call `client.udp.disconnect()` when leaving the world.
@@ -76,43 +76,63 @@ Auth and user reads always target `managementUrl`. Everything else targets `http
76
76
  When a player is about to join an app, query its routing fields on the management API first:
77
77
 
78
78
  ```graphql
79
- query AppForRouting($id: BigInt!) {
80
- app(id: $id) {
79
+ query AppForRouting($appId: BigInt!) {
80
+ app(appId: $appId) {
81
81
  appId
82
82
  splitMode
83
+ deploymentTarget
83
84
  gameApiUrl
84
85
  }
85
86
  }
86
87
  ```
87
88
 
88
- If `splitMode && gameApiUrl`, the app lives behind its own Game API deployment. Build a **second** `CrowdyClient` with `httpUrl: gameApiUrl` (and the matching `wsUrl`) **sharing the same `tokenStore` as the first client**, then drive gameplay through that client. Apps without `splitMode` keep working against the default `httpUrl` you configured.
89
+ `gameApiUrl` is populated for **both** dedicated (`splitMode`) and shared
90
+ (`deploymentTarget: "shared"`) apps. When it's set, build a **second**
91
+ `CrowdyClient` with `httpUrl: gameApiUrl` (and the matching `wsUrl`) **sharing the
92
+ same `tokenStore` as the first client**, then drive gameplay through that client.
93
+ Apps with no `gameApiUrl` keep working against the default `httpUrl` you
94
+ configured.
89
95
 
90
96
  ## Realtime notifications
91
97
 
98
+ `subscribe` takes the handlers **and a required `appId`** (second argument). The
99
+ Game API scopes the realtime session to that app and rejects an app-agnostic
100
+ subscription with a `RealtimeConnectionEvent` (`code: 'APP_ID_REQUIRED'`). Run
101
+ one client per app (sharing the same `tokenStore`) when a player is in multiple
102
+ apps at once.
103
+
92
104
  ```ts
93
- const unsubscribe = client.udp.subscribe({
94
- actorUpdate: (event) => {
95
- console.log(event.uuid, event.state);
96
- },
97
- voxelUpdate: (event) => { /* ... */ },
98
- text: (event) => { /* ... */ },
99
- audio: (event) => { /* ... */ },
100
- clientEvent: (event) => { /* ... */ },
101
- serverEvent: (event) => { /* ... */ },
102
- singleActorMessage: (event) => {
103
- // A direct actor-to-actor message addressed to you.
104
- console.log(event.uuid, event.payload); // payload is base64
105
- },
106
- genericError: (event) => {
107
- console.warn(event.sequenceNumber, event.errorCode);
108
- },
109
- connectionEvent: (event) => {
110
- console.warn(event.code, event.message);
105
+ const appId = '1';
106
+
107
+ const unsubscribe = client.udp.subscribe(
108
+ {
109
+ actorUpdate: (event) => {
110
+ console.log(event.uuid, event.state);
111
+ },
112
+ voxelUpdate: (event) => { /* ... */ },
113
+ text: (event) => { /* ... */ },
114
+ audio: (event) => { /* ... */ },
115
+ clientEvent: (event) => { /* ... */ },
116
+ serverEvent: (event) => { /* ... */ },
117
+ singleActorMessage: (event) => {
118
+ // A direct actor-to-actor message addressed to you.
119
+ console.log(event.uuid, event.payload); // payload is base64
120
+ },
121
+ genericError: (event) => {
122
+ console.warn(event.sequenceNumber, event.errorCode);
123
+ },
124
+ connectionEvent: (event) => {
125
+ console.warn(event.code, event.message);
126
+ },
127
+ error: (error) => {
128
+ console.error(error.code, error.message);
129
+ },
111
130
  },
112
- error: (error) => {
113
- console.error(error.code, error.message);
114
- },
115
- });
131
+ appId,
132
+ );
133
+
134
+ // Or use the world helper, which passes its appId automatically:
135
+ // client.world(appId).subscribe(handlers);
116
136
 
117
137
  client.realtime.onStatus((status) => {
118
138
  console.log('realtime:', status);
@@ -37,6 +37,7 @@ import { TeleportAPI } from './domains/teleport.js';
37
37
  import { StateAPI } from './domains/state.js';
38
38
  import { ServerStatusAPI } from './domains/serverStatus.js';
39
39
  import { ChannelsAPI } from './domains/channels.js';
40
+ import { TeamsAPI } from './domains/teams.js';
40
41
  import { UdpAPI } from './domains/udp.js';
41
42
  import { GameModelAPI } from './domains/gameModel.js';
42
43
  export interface CrowdyClientConfig {
@@ -89,6 +90,8 @@ export declare class CrowdyClient {
89
90
  readonly state: StateAPI;
90
91
  readonly serverStatus: ServerStatusAPI;
91
92
  readonly channels: ChannelsAPI;
93
+ /** Teams: app-scoped player groups with roles and delegated management. */
94
+ readonly teams: TeamsAPI;
92
95
  readonly udp: UdpAPI;
93
96
  /** Abstract game model: containers, properties, functions, sessions. */
94
97
  readonly gameModel: GameModelAPI;
@@ -1 +1 @@
1
- {"version":3,"file":"crowdy-client.d.ts","sourceRoot":"","sources":["../src/crowdy-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE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
36
36
  import { ServerStatusAPI } from './domains/serverStatus.js';
37
37
  import { ChannelsAPI } from './domains/channels.js';
38
+ import { TeamsAPI } from './domains/teams.js';
38
39
  import { UdpAPI } from './domains/udp.js';
39
40
  import { GameModelAPI } from './domains/gameModel.js';
40
41
  export class CrowdyClient {
@@ -75,6 +76,7 @@ export class CrowdyClient {
75
76
  this.state = new StateAPI(this.graphql);
76
77
  this.serverStatus = new ServerStatusAPI(this.graphql);
77
78
  this.channels = new ChannelsAPI(this.graphql);
79
+ this.teams = new TeamsAPI(this.graphql);
78
80
  this.udp = new UdpAPI(this.graphql, this.realtime);
79
81
  this.gameModel = new GameModelAPI(this.graphql);
80
82
  }
@@ -0,0 +1,34 @@
1
+ import type { GraphQLClient } from '../client.js';
2
+ import { type MyTeamsQuery, type MyTeamsQueryVariables, type TeamsQuery, type TeamsQueryVariables, type TeamQuery, type TeamQueryVariables, type TeamMembersQuery, type TeamMembersQueryVariables, type TeamRolesQuery, type TeamRolesQueryVariables, type TeamPolicyQuery, type TeamPolicyQueryVariables, type SetTeamPolicyMutation, type SetTeamPolicyMutationVariables, type CreateTeamMutation, type CreateTeamMutationVariables, type UpdateTeamMutation, type UpdateTeamMutationVariables, type DeleteTeamMutationVariables, type JoinTeamMutation, type JoinTeamMutationVariables, type RequestToJoinTeamMutation, type RequestToJoinTeamMutationVariables, type LeaveTeamMutationVariables, type AddTeamMemberMutation, type AddTeamMemberMutationVariables, type RemoveTeamMemberMutationVariables, type SetTeamMemberRolesMutation, type SetTeamMemberRolesMutationVariables, type CreateTeamRoleMutation, type CreateTeamRoleMutationVariables, type UpdateTeamRoleMutation, type UpdateTeamRoleMutationVariables, type DeleteTeamRoleMutationVariables } from '../generated/graphql.js';
3
+ /**
4
+ * Teams: app-scoped player groups with roles and delegated management, built
5
+ * on the same generic groups subsystem as Channels (group_type='team'). Team
6
+ * CRUD, membership, and roles run over the game-api GraphQL endpoint. Unlike
7
+ * channels, teams have no realtime messaging path.
8
+ *
9
+ * Exposed as `client.teams`.
10
+ */
11
+ export declare class TeamsAPI {
12
+ private gql;
13
+ constructor(gql: GraphQLClient);
14
+ mine(appId: MyTeamsQueryVariables['appId']): Promise<MyTeamsQuery['myTeams']>;
15
+ list(appId: TeamsQueryVariables['appId']): Promise<TeamsQuery['teams']>;
16
+ get(groupId: TeamQueryVariables['groupId']): Promise<TeamQuery['team']>;
17
+ members(groupId: TeamMembersQueryVariables['groupId']): Promise<TeamMembersQuery['teamMembers']>;
18
+ roles(groupId: TeamRolesQueryVariables['groupId']): Promise<TeamRolesQuery['teamRoles']>;
19
+ policy(appId: TeamPolicyQueryVariables['appId']): Promise<TeamPolicyQuery['teamPolicy']>;
20
+ create(input: CreateTeamMutationVariables['input']): Promise<CreateTeamMutation['createTeam']>;
21
+ update(input: UpdateTeamMutationVariables['input']): Promise<UpdateTeamMutation['updateTeam']>;
22
+ remove(groupId: DeleteTeamMutationVariables['groupId']): Promise<boolean>;
23
+ setPolicy(input: SetTeamPolicyMutationVariables['input']): Promise<SetTeamPolicyMutation['setTeamPolicy']>;
24
+ join(groupId: JoinTeamMutationVariables['groupId']): Promise<JoinTeamMutation['joinTeam']>;
25
+ requestToJoin(groupId: RequestToJoinTeamMutationVariables['groupId']): Promise<RequestToJoinTeamMutation['requestToJoinTeam']>;
26
+ leave(groupId: LeaveTeamMutationVariables['groupId']): Promise<boolean>;
27
+ addMember(groupId: AddTeamMemberMutationVariables['groupId'], userId: AddTeamMemberMutationVariables['userId']): Promise<AddTeamMemberMutation['addTeamMember']>;
28
+ removeMember(groupId: RemoveTeamMemberMutationVariables['groupId'], userId: RemoveTeamMemberMutationVariables['userId']): Promise<boolean>;
29
+ setMemberRoles(input: SetTeamMemberRolesMutationVariables['input']): Promise<SetTeamMemberRolesMutation['setTeamMemberRoles']>;
30
+ createRole(input: CreateTeamRoleMutationVariables['input']): Promise<CreateTeamRoleMutation['createTeamRole']>;
31
+ updateRole(input: UpdateTeamRoleMutationVariables['input']): Promise<UpdateTeamRoleMutation['updateTeamRole']>;
32
+ deleteRole(groupRoleId: DeleteTeamRoleMutationVariables['groupRoleId']): Promise<boolean>;
33
+ }
34
+ //# sourceMappingURL=teams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"teams.d.ts","sourceRoot":"","sources":["../../src/domains/teams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAE1B,KAAK,UAAU,EACf,KAAK,mBAAmB,EAExB,KAAK,SAAS,EACd,KAAK,kBAAkB,EAEvB,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAE9B,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAE5B,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAE7B,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EAEnC,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAEhC,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAEhC,KAAK,2BAA2B,EAEhC,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAE9B,KAAK,yBAAyB,EAC9B,KAAK,kCAAkC,EAEvC,KAAK,0BAA0B,EAE/B,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EAEnC,KAAK,iCAAiC,EAEtC,KAAK,0BAA0B,EAC/B,KAAK,mCAAmC,EAExC,KAAK,sBAAsB,EAC3B,KAAK,+BAA+B,EAEpC,KAAK,sBAAsB,EAC3B,KAAK,+BAA+B,EAEpC,KAAK,+BAA+B,EACrC,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;GAOG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAIhC,IAAI,CACR,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC,GACpC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAK7B,IAAI,CACR,KAAK,EAAE,mBA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OAAO,EAAE,8BAA8B,CAAC,SAAS,CAAC,EAClD,MAAM,EAAE,8BAA8B,CAAC,QAAQ,CAAC,GAC/C,OAAO,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC;IAK5C,YAAY,CAChB,OAAO,EAAE,iCAAiC,CAAC,SAAS,CAAC,EACrD,MAAM,EAAE,iCAAiC,CAAC,QAAQ,CAAC,GAClD,OAAO,CAAC,OAAO,CAAC;IAKb,cAAc,CAClB,KAAK,EAAE,mCAAmC,CAAC,OAAO,CAAC,GAClD,OAAO,CAAC,0BAA0B,CAAC,oBAAoB,CAAC,CAAC;IAOtD,UAAU,CACd,KAAK,EAAE,+BAA+B,CAAC,OAAO,CAAC,GAC9C,OAAO,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;IAK9C,UAAU,CACd,KAAK,EAAE,+BAA+B,CAAC,OAAO,CAAC,GAC9C,OAAO,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;IAK9C,UAAU,CACd,WAAW,EAAE,+BAA+B,CAAC,aAAa,CAAC,GAC1D,OAAO,CAAC,OAAO,CAAC;CAIpB"}
@@ -0,0 +1,94 @@
1
+ import { MyTeamsDocument, TeamsDocument, TeamDocument, TeamMembersDocument, TeamRolesDocument, TeamPolicyDocument, SetTeamPolicyDocument, CreateTeamDocument, UpdateTeamDocument, DeleteTeamDocument, JoinTeamDocument, RequestToJoinTeamDocument, LeaveTeamDocument, AddTeamMemberDocument, RemoveTeamMemberDocument, SetTeamMemberRolesDocument, CreateTeamRoleDocument, UpdateTeamRoleDocument, DeleteTeamRoleDocument, } from '../generated/graphql.js';
2
+ /**
3
+ * Teams: app-scoped player groups with roles and delegated management, built
4
+ * on the same generic groups subsystem as Channels (group_type='team'). Team
5
+ * CRUD, membership, and roles run over the game-api GraphQL endpoint. Unlike
6
+ * channels, teams have no realtime messaging path.
7
+ *
8
+ * Exposed as `client.teams`.
9
+ */
10
+ export class TeamsAPI {
11
+ constructor(gql) {
12
+ this.gql = gql;
13
+ }
14
+ // -- Queries --------------------------------------------------------------
15
+ async mine(appId) {
16
+ const data = await this.gql.request(MyTeamsDocument, { appId });
17
+ return data.myTeams;
18
+ }
19
+ async list(appId) {
20
+ const data = await this.gql.request(TeamsDocument, { appId });
21
+ return data.teams;
22
+ }
23
+ async get(groupId) {
24
+ const data = await this.gql.request(TeamDocument, { groupId });
25
+ return data.team;
26
+ }
27
+ async members(groupId) {
28
+ const data = await this.gql.request(TeamMembersDocument, { groupId });
29
+ return data.teamMembers;
30
+ }
31
+ async roles(groupId) {
32
+ const data = await this.gql.request(TeamRolesDocument, { groupId });
33
+ return data.teamRoles;
34
+ }
35
+ async policy(appId) {
36
+ const data = await this.gql.request(TeamPolicyDocument, { appId });
37
+ return data.teamPolicy;
38
+ }
39
+ // -- Team mutations -------------------------------------------------------
40
+ async create(input) {
41
+ const data = await this.gql.request(CreateTeamDocument, { input });
42
+ return data.createTeam;
43
+ }
44
+ async update(input) {
45
+ const data = await this.gql.request(UpdateTeamDocument, { input });
46
+ return data.updateTeam;
47
+ }
48
+ async remove(groupId) {
49
+ const data = await this.gql.request(DeleteTeamDocument, { groupId });
50
+ return data.deleteTeam;
51
+ }
52
+ async setPolicy(input) {
53
+ const data = await this.gql.request(SetTeamPolicyDocument, { input });
54
+ return data.setTeamPolicy;
55
+ }
56
+ // -- Membership mutations -------------------------------------------------
57
+ async join(groupId) {
58
+ const data = await this.gql.request(JoinTeamDocument, { groupId });
59
+ return data.joinTeam;
60
+ }
61
+ async requestToJoin(groupId) {
62
+ const data = await this.gql.request(RequestToJoinTeamDocument, { groupId });
63
+ return data.requestToJoinTeam;
64
+ }
65
+ async leave(groupId) {
66
+ const data = await this.gql.request(LeaveTeamDocument, { groupId });
67
+ return data.leaveTeam;
68
+ }
69
+ async addMember(groupId, userId) {
70
+ const data = await this.gql.request(AddTeamMemberDocument, { groupId, userId });
71
+ return data.addTeamMember;
72
+ }
73
+ async removeMember(groupId, userId) {
74
+ const data = await this.gql.request(RemoveTeamMemberDocument, { groupId, userId });
75
+ return data.removeTeamMember;
76
+ }
77
+ async setMemberRoles(input) {
78
+ const data = await this.gql.request(SetTeamMemberRolesDocument, { input });
79
+ return data.setTeamMemberRoles;
80
+ }
81
+ // -- Role mutations -------------------------------------------------------
82
+ async createRole(input) {
83
+ const data = await this.gql.request(CreateTeamRoleDocument, { input });
84
+ return data.createTeamRole;
85
+ }
86
+ async updateRole(input) {
87
+ const data = await this.gql.request(UpdateTeamRoleDocument, { input });
88
+ return data.updateTeamRole;
89
+ }
90
+ async deleteRole(groupRoleId) {
91
+ const data = await this.gql.request(DeleteTeamRoleDocument, { groupRoleId });
92
+ return data.deleteTeamRole;
93
+ }
94
+ }